@dmitryvim/form-builder 0.2.29 → 0.2.30

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,4 +1,4 @@
1
- var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.locale||"en",o=t.config.translations[r],i=t.config.translations.en;let l=(o==null?void 0:o[e])||(i==null?void 0:i[e])||e;if(n)for(const[a,s]of Object.entries(n))l=l.replace(new RegExp(`\\{${a}\\}`,"g"),String(s));return l}function Xn(e,t,n){(e.minLength!=null||e.maxLength!=null)&&(e.minLength!=null&&e.maxLength!=null?t.push($("hintLengthRange",n,{min:e.minLength,max:e.maxLength})):e.maxLength!=null?t.push($("hintMaxLength",n,{max:e.maxLength})):e.minLength!=null&&t.push($("hintMinLength",n,{min:e.minLength})))}function Gn(e,t,n){(e.min!=null||e.max!=null)&&(e.min!=null&&e.max!=null?t.push($("hintValueRange",n,{min:e.min,max:e.max})):e.max!=null?t.push($("hintMaxValue",n,{max:e.max})):e.min!=null&&t.push($("hintMinValue",n,{min:e.min})))}function Zn(e,t,n){e.maxSizeMB&&t.push($("hintMaxSize",n,{size:e.maxSizeMB}))}function Qn(e,t,n){var r;(r=e.accept)!=null&&r.extensions&&t.push($("hintFormats",n,{formats:e.accept.extensions.map(o=>o.toUpperCase()).join(",")}))}function er(e,t,n){e.pattern&&t.push($("hintPattern",n,{pattern:e.pattern}))}function ve(e,t){const n=[];return Xn(e,n,t),e.type!=="slider"&&Gn(e,n,t),Zn(e,n,t),Qn(e,n,t),er(e,n,t),n.join(" \u2022 ")}function ht(e){const t=[];if(!e||typeof e!="object")return t.push("Schema must be an object"),t;if(!Array.isArray(e.elements))return t.push("Schema missing elements array"),t;if("columns"in e&&e.columns!==void 0){const o=e.columns,i=[1,2,3,4];(!Number.isInteger(o)||!i.includes(o))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${o})`)}if("prefillHints"in e&&e.prefillHints){const o=e.prefillHints;Array.isArray(o)&&o.forEach((i,l)=>{if((!i.label||typeof i.label!="string")&&t.push(`schema.prefillHints[${l}] must have a 'label' property of type string`),!i.values||typeof i.values!="object")t.push(`schema.prefillHints[${l}] must have a 'values' property of type object`);else for(const a in i.values)e.elements.some(s=>s.key===a)||t.push(`schema.prefillHints[${l}] references non-existent field "${a}"`)})}function n(o,i){var l,a;const s=new Set;for(const c of o)if(c.type==="richinput"&&c.flatOutput){const p=c,u=(l=p.textKey)!=null?l:"text",d=(a=p.filesKey)!=null?a:"files";for(const f of o)f!==c&&(f.key===u&&t.push(`${i}: RichInput "${c.key}" flatOutput textKey "${u}" collides with element key "${f.key}"`),f.key===d&&t.push(`${i}: RichInput "${c.key}" flatOutput filesKey "${d}" collides with element key "${f.key}"`));s.has(u)&&t.push(`${i}: RichInput "${c.key}" flatOutput textKey "${u}" collides with another flatOutput key`),s.has(d)&&t.push(`${i}: RichInput "${c.key}" flatOutput filesKey "${d}" collides with another flatOutput key`),s.add(u),s.add(d)}else s.has(c.key)&&t.push(`${i}: Element key "${c.key}" collides with a flatOutput richinput key`),s.add(c.key)}function r(o,i){o.forEach((l,a)=>{const s=`${i}[${a}]`;if(l.type||t.push(`${s}: missing type`),l.key||t.push(`${s}: missing key`),l.enableIf){const c=l.enableIf;(!c.key||typeof c.key!="string")&&t.push(`${s}: enableIf must have a 'key' property of type string`),"equals"in c||t.push(`${s}: enableIf must have at least one operator (equals, etc.)`)}if(l.type==="group"&&"elements"in l&&l.elements&&r(l.elements,`${s}.elements`),l.type==="container"&&l.elements){if("columns"in l&&l.columns!==void 0){const c=l.columns,p=[1,2,3,4];(!Number.isInteger(c)||!p.includes(c))&&t.push(`${s}: columns must be 1, 2, 3, or 4 (got ${c})`)}if("prefillHints"in l&&l.prefillHints){const c=l.prefillHints;Array.isArray(c)&&c.forEach((p,u)=>{if((!p.label||typeof p.label!="string")&&t.push(`${s}: prefillHints[${u}] must have a 'label' property of type string`),!p.values||typeof p.values!="object")t.push(`${s}: prefillHints[${u}] must have a 'values' property of type object`);else for(const d in p.values)l.elements.some(f=>f.key===d)||t.push(`container "${l.key}": prefillHints[${u}] references non-existent field "${d}"`)})}r(l.elements,`${s}.elements`),n(l.elements,`${s}.elements`)}if(l.type==="select"&&l.options){const c=l.default;c!=null&&c!==""&&(l.options.some(p=>p.value===c)||t.push(`${s}: default "${c}" not in options`))}})}return Array.isArray(e.elements)&&(r(e.elements,"elements"),n(e.elements,"elements")),t}function le(e,t,n){return e.readonly===!0||t.config.readonly===!0||(n==null?void 0:n.inheritedReadonly)===!0}function Je(e){return e&&typeof e=="object"&&e.constructor===Object}function re(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function xe(e,t){return e?`${e}.${t}`:t}function be(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function tr(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Ht(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Bt(e){if(e==="")return null;try{return JSON.parse(e)}catch(t){return e}}function De(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.setAttribute("data-hidden-field","true"),n.value=Ht(t),n}function vt(e,t){if(!e||typeof e!="object")return;const n=t.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return;let r=e;for(const o of n){if(r==null)return;if(o.startsWith("[")&&o.endsWith("]")){const i=parseInt(o.slice(1,-1),10);if(!Array.isArray(r)||isNaN(i))return;r=r[i]}else r=r[o]}return r}function Ne(e,t,n){var r;if(!e||!e.key)throw new Error("Invalid enableIf condition: must have a 'key' property");const o=(r=e.scope)!=null?r:"relative";let i;if(o==="relative")i=n!=null?n:t;else if(o==="absolute")i=t;else throw new Error(`Invalid enableIf scope: must be "relative" or "absolute" (got "${o}")`);const l=vt(i,e.key);if("equals"in e)return nr(l,e.equals);throw new Error("Invalid enableIf condition: no recognized operator (equals, etc.)")}function nr(e,t){if(e===t)return!0;if(e==null||t==null)return e===t;if(typeof e!=typeof t)return!1;if(typeof e=="object"&&typeof t=="object")try{return JSON.stringify(e)===JSON.stringify(t)}catch(n){if(n instanceof TypeError&&(n.message.includes("circular")||n.message.includes("cyclic")))return console.warn("deepEqual: Circular reference detected in enableIf comparison, using reference equality"),e===t;throw n}return e===t}function je(e,t,n=!1){const r=document.createElement("span");r.className="char-counter",r.style.cssText=`
1
+ var FormBuilder=(function(Ce){"use strict";function $(e,t,n){const r=t.config.locale||"en",o=t.config.translations[r],i=t.config.translations.en;let l=(o==null?void 0:o[e])||(i==null?void 0:i[e])||e;if(n)for(const[a,c]of Object.entries(n))l=l.replace(new RegExp(`\\{${a}\\}`,"g"),String(c));return l}function rr(e,t,n){(e.minLength!=null||e.maxLength!=null)&&(e.minLength!=null&&e.maxLength!=null?t.push($("hintLengthRange",n,{min:e.minLength,max:e.maxLength})):e.maxLength!=null?t.push($("hintMaxLength",n,{max:e.maxLength})):e.minLength!=null&&t.push($("hintMinLength",n,{min:e.minLength})))}function or(e,t,n){(e.min!=null||e.max!=null)&&(e.min!=null&&e.max!=null?t.push($("hintValueRange",n,{min:e.min,max:e.max})):e.max!=null?t.push($("hintMaxValue",n,{max:e.max})):e.min!=null&&t.push($("hintMinValue",n,{min:e.min})))}function lr(e,t,n){e.maxSizeMB&&t.push($("hintMaxSize",n,{size:e.maxSizeMB}))}function ir(e,t,n){var r;(r=e.accept)!=null&&r.extensions&&t.push($("hintFormats",n,{formats:e.accept.extensions.map(o=>o.toUpperCase()).join(",")}))}function ar(e,t,n){e.pattern&&t.push($("hintPattern",n,{pattern:e.pattern}))}function be(e,t){const n=[];return rr(e,n,t),e.type!=="slider"&&or(e,n,t),lr(e,n,t),ir(e,n,t),ar(e,n,t),n.join(" \u2022 ")}function bt(e){const t=[];if(!e||typeof e!="object")return t.push("Schema must be an object"),t;if(!Array.isArray(e.elements))return t.push("Schema missing elements array"),t;if("columns"in e&&e.columns!==void 0){const o=e.columns,i=[1,2,3,4];(!Number.isInteger(o)||!i.includes(o))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${o})`)}if("prefillHints"in e&&e.prefillHints){const o=e.prefillHints;Array.isArray(o)&&o.forEach((i,l)=>{if((!i.label||typeof i.label!="string")&&t.push(`schema.prefillHints[${l}] must have a 'label' property of type string`),!i.values||typeof i.values!="object")t.push(`schema.prefillHints[${l}] must have a 'values' property of type object`);else for(const a in i.values)e.elements.some(c=>c.key===a)||t.push(`schema.prefillHints[${l}] references non-existent field "${a}"`)})}function n(o,i){var l,a;const c=new Set;for(const s of o)if(s.type==="richinput"&&s.flatOutput){const p=s,u=(l=p.textKey)!=null?l:"text",f=(a=p.filesKey)!=null?a:"files";for(const d of o)d!==s&&(d.key===u&&t.push(`${i}: RichInput "${s.key}" flatOutput textKey "${u}" collides with element key "${d.key}"`),d.key===f&&t.push(`${i}: RichInput "${s.key}" flatOutput filesKey "${f}" collides with element key "${d.key}"`));c.has(u)&&t.push(`${i}: RichInput "${s.key}" flatOutput textKey "${u}" collides with another flatOutput key`),c.has(f)&&t.push(`${i}: RichInput "${s.key}" flatOutput filesKey "${f}" collides with another flatOutput key`),c.add(u),c.add(f)}else s.key&&(c.has(s.key)&&t.push(`${i}: Element key "${s.key}" collides with a flatOutput richinput key`),c.add(s.key))}function r(o,i){o.forEach((l,a)=>{const c=`${i}[${a}]`;if(l.type||t.push(`${c}: missing type`),!l.key&&l.type!=="markdown"&&t.push(`${c}: missing key`),l.type==="markdown"){const s=l.content;typeof s!="string"&&t.push(`${c}: markdown element requires "content" to be a string (got ${s===null?"null":typeof s})`)}if(l.enableIf){const s=l.enableIf;(!s.key||typeof s.key!="string")&&t.push(`${c}: enableIf must have a 'key' property of type string`),"equals"in s||t.push(`${c}: enableIf must have at least one operator (equals, etc.)`)}if(l.type==="group"&&"elements"in l&&l.elements&&r(l.elements,`${c}.elements`),l.type==="container"&&l.elements){if("columns"in l&&l.columns!==void 0){const s=l.columns,p=[1,2,3,4];(!Number.isInteger(s)||!p.includes(s))&&t.push(`${c}: columns must be 1, 2, 3, or 4 (got ${s})`)}if("prefillHints"in l&&l.prefillHints){const s=l.prefillHints;Array.isArray(s)&&s.forEach((p,u)=>{if((!p.label||typeof p.label!="string")&&t.push(`${c}: prefillHints[${u}] must have a 'label' property of type string`),!p.values||typeof p.values!="object")t.push(`${c}: prefillHints[${u}] must have a 'values' property of type object`);else for(const f in p.values)l.elements.some(d=>d.key===f)||t.push(`container "${l.key}": prefillHints[${u}] references non-existent field "${f}"`)})}r(l.elements,`${c}.elements`),n(l.elements,`${c}.elements`)}if(l.type==="select"&&l.options){const s=l.default;s!=null&&s!==""&&(l.options.some(p=>p.value===s)||t.push(`${c}: default "${s}" not in options`))}})}return Array.isArray(e.elements)&&(r(e.elements,"elements"),n(e.elements,"elements")),t}function le(e,t,n){return e.readonly===!0||t.config.readonly===!0||(n==null?void 0:n.inheritedReadonly)===!0}function Ye(e){return e&&typeof e=="object"&&e.constructor===Object}function oe(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function vt(e,t){if(e.key)return e.key;const n=t.syntheticElementIds.get(e);if(n!==void 0)return n;const r=`fb-synthetic-${t.syntheticElementIdCounter++}`;return t.syntheticElementIds.set(e,r),r}function xe(e,t){return e?`${e}.${t}`:t}function ve(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function sr(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function jt(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Ot(e){if(e==="")return null;try{return JSON.parse(e)}catch(t){return e}}function De(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.setAttribute("data-hidden-field","true"),n.value=jt(t),n}function gt(e,t){if(!e||typeof e!="object")return;const n=t.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return;let r=e;for(const o of n){if(r==null)return;if(o.startsWith("[")&&o.endsWith("]")){const i=parseInt(o.slice(1,-1),10);if(!Array.isArray(r)||isNaN(i))return;r=r[i]}else r=r[o]}return r}function ze(e,t,n){var r;if(!e||!e.key)throw new Error("Invalid enableIf condition: must have a 'key' property");const o=(r=e.scope)!=null?r:"relative";let i;if(o==="relative")i=n!=null?n:t;else if(o==="absolute")i=t;else throw new Error(`Invalid enableIf scope: must be "relative" or "absolute" (got "${o}")`);const l=gt(i,e.key);if("equals"in e)return cr(l,e.equals);throw new Error("Invalid enableIf condition: no recognized operator (equals, etc.)")}function cr(e,t){if(e===t)return!0;if(e==null||t==null)return e===t;if(typeof e!=typeof t)return!1;if(typeof e=="object"&&typeof t=="object")try{return JSON.stringify(e)===JSON.stringify(t)}catch(n){if(n instanceof TypeError&&(n.message.includes("circular")||n.message.includes("cyclic")))return console.warn("deepEqual: Circular reference detected in enableIf comparison, using reference equality"),e===t;throw n}return e===t}function je(e,t,n=!1){const r=document.createElement("span");r.className="char-counter",r.style.cssText=`
2
2
  position: absolute;
3
3
  ${n?"bottom: 8px":"top: 50%; transform: translateY(-50%)"};
4
4
  right: 10px;
@@ -7,7 +7,7 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
7
7
  pointer-events: none;
8
8
  background: var(--fb-background-color);
9
9
  padding: 0 4px;
10
- `;const o=()=>{const i=t.value.length,l=e.minLength,a=e.maxLength;if(l==null&&a==null){r.textContent="";return}i===0||l!=null&&i<l?(l!=null&&a!=null?r.textContent=`${l}-${a}`:a!=null?r.textContent=`\u2264${a}`:l!=null&&(r.textContent=`\u2265${l}`),r.style.color="var(--fb-text-secondary-color)"):a!=null&&i>a?(r.textContent=`${i}/${a}`,r.style.color="var(--fb-error-color)"):(a!=null?r.textContent=`${i}/${a}`:r.textContent=`${i}`,r.style.color="var(--fb-text-secondary-color)")};return t.addEventListener("input",o),o(),r}function rr(e,t,n,r){const o=t.state,i=le(e,o,t),l=document.createElement("div");l.style.cssText="position: relative;";const a=document.createElement("input");if(a.type="text",a.className="w-full rounded-lg",a.style.cssText=`
10
+ `;const o=()=>{const i=t.value.length,l=e.minLength,a=e.maxLength;if(l==null&&a==null){r.textContent="";return}i===0||l!=null&&i<l?(l!=null&&a!=null?r.textContent=`${l}-${a}`:a!=null?r.textContent=`\u2264${a}`:l!=null&&(r.textContent=`\u2265${l}`),r.style.color="var(--fb-text-secondary-color)"):a!=null&&i>a?(r.textContent=`${i}/${a}`,r.style.color="var(--fb-error-color)"):(a!=null?r.textContent=`${i}/${a}`:r.textContent=`${i}`,r.style.color="var(--fb-text-secondary-color)")};return t.addEventListener("input",o),o(),r}function ur(e,t,n,r){const o=t.state,i=le(e,o,t),l=document.createElement("div");l.style.cssText="position: relative;";const a=document.createElement("input");if(a.type="text",a.className="w-full rounded-lg",a.style.cssText=`
11
11
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
12
12
  padding-right: 60px;
13
13
  border: var(--fb-border-width) solid var(--fb-border-color);
@@ -19,7 +19,7 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
19
19
  transition: all var(--fb-transition-duration) ease-in-out;
20
20
  width: 100%;
21
21
  box-sizing: border-box;
22
- `,a.name=r,a.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",a.value=t.prefill[e.key]||e.default||"",a.readOnly=i,i||(a.addEventListener("focus",()=>{a.style.borderColor="var(--fb-border-focus-color)",a.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",a.style.outlineOffset="0"}),a.addEventListener("blur",()=>{a.style.borderColor="var(--fb-border-color)",a.style.outline="none"}),a.addEventListener("mouseenter",()=>{document.activeElement!==a&&(a.style.borderColor="var(--fb-border-hover-color)")}),a.addEventListener("mouseleave",()=>{document.activeElement!==a&&(a.style.borderColor="var(--fb-border-color)")})),!i&&t.instance){const s=()=>{const c=a.value===""?null:a.value;t.instance.triggerOnChange(r,c)};a.addEventListener("blur",s),a.addEventListener("input",s)}if(l.appendChild(a),!i&&(e.minLength!=null||e.maxLength!=null)){const s=je(e,a,!1);l.appendChild(s)}n.appendChild(l)}function or(e,t,n,r){var o,i;const l=t.state,a=le(e,l,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],p=(o=e.minCount)!=null?o:1,u=(i=e.maxCount)!=null?i:1/0;for(;c.length<p;)c.push(e.default||"");const d=document.createElement("div");d.className="space-y-2",n.appendChild(d);function f(){d.querySelectorAll(".multiple-text-item").forEach((h,g)=>{const E=h.querySelector("input");E&&(E.name=`${r}[${g}]`)})}function m(h="",g=-1){const E=document.createElement("div");E.className="multiple-text-item flex items-center gap-2";const C=document.createElement("div");C.style.cssText="position: relative; flex: 1;";const x=document.createElement("input");if(x.type="text",x.style.cssText=`
22
+ `,a.name=r,a.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",a.value=t.prefill[e.key]||e.default||"",a.readOnly=i,i||(a.addEventListener("focus",()=>{a.style.borderColor="var(--fb-border-focus-color)",a.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",a.style.outlineOffset="0"}),a.addEventListener("blur",()=>{a.style.borderColor="var(--fb-border-color)",a.style.outline="none"}),a.addEventListener("mouseenter",()=>{document.activeElement!==a&&(a.style.borderColor="var(--fb-border-hover-color)")}),a.addEventListener("mouseleave",()=>{document.activeElement!==a&&(a.style.borderColor="var(--fb-border-color)")})),!i&&t.instance){const c=()=>{const s=a.value===""?null:a.value;t.instance.triggerOnChange(r,s)};a.addEventListener("blur",c),a.addEventListener("input",c)}if(l.appendChild(a),!i&&(e.minLength!=null||e.maxLength!=null)){const c=je(e,a,!1);l.appendChild(c)}n.appendChild(l)}function dr(e,t,n,r){var o,i;const l=t.state,a=le(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],p=(o=e.minCount)!=null?o:1,u=(i=e.maxCount)!=null?i:1/0;for(;s.length<p;)s.push(e.default||"");const f=document.createElement("div");f.className="space-y-2",n.appendChild(f);function d(){f.querySelectorAll(".multiple-text-item").forEach((h,g)=>{const E=h.querySelector("input");E&&(E.name=`${r}[${g}]`)})}function m(h="",g=-1){const E=document.createElement("div");E.className="multiple-text-item flex items-center gap-2";const w=document.createElement("div");w.style.cssText="position: relative; flex: 1;";const x=document.createElement("input");if(x.type="text",x.style.cssText=`
23
23
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
24
24
  padding-right: 60px;
25
25
  border: var(--fb-border-width) solid var(--fb-border-color);
@@ -31,27 +31,27 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
31
31
  transition: all var(--fb-transition-duration) ease-in-out;
32
32
  width: 100%;
33
33
  box-sizing: border-box;
34
- `,x.placeholder=e.placeholder||$("placeholderText",l),x.value=h,x.readOnly=a,a||(x.addEventListener("focus",()=>{x.style.borderColor="var(--fb-border-focus-color)",x.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",x.style.outlineOffset="0"}),x.addEventListener("blur",()=>{x.style.borderColor="var(--fb-border-color)",x.style.outline="none"}),x.addEventListener("mouseenter",()=>{document.activeElement!==x&&(x.style.borderColor="var(--fb-border-hover-color)")}),x.addEventListener("mouseleave",()=>{document.activeElement!==x&&(x.style.borderColor="var(--fb-border-color)")})),!a&&t.instance){const k=()=>{const q=x.value===""?null:x.value;t.instance.triggerOnChange(x.name,q)};x.addEventListener("blur",k),x.addEventListener("input",k)}if(C.appendChild(x),!a&&(e.minLength!=null||e.maxLength!=null)){const k=je(e,x,!1);C.appendChild(k)}return E.appendChild(C),g===-1?d.appendChild(E):d.insertBefore(E,d.children[g]),f(),E}function b(){if(a)return;const h=d.querySelectorAll(".multiple-text-item"),g=h.length;h.forEach(E=>{let C=E.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn px-2 py-1 rounded",C.style.cssText=`
34
+ `,x.placeholder=e.placeholder||$("placeholderText",l),x.value=h,x.readOnly=a,a||(x.addEventListener("focus",()=>{x.style.borderColor="var(--fb-border-focus-color)",x.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",x.style.outlineOffset="0"}),x.addEventListener("blur",()=>{x.style.borderColor="var(--fb-border-color)",x.style.outline="none"}),x.addEventListener("mouseenter",()=>{document.activeElement!==x&&(x.style.borderColor="var(--fb-border-hover-color)")}),x.addEventListener("mouseleave",()=>{document.activeElement!==x&&(x.style.borderColor="var(--fb-border-color)")})),!a&&t.instance){const k=()=>{const I=x.value===""?null:x.value;t.instance.triggerOnChange(x.name,I)};x.addEventListener("blur",k),x.addEventListener("input",k)}if(w.appendChild(x),!a&&(e.minLength!=null||e.maxLength!=null)){const k=je(e,x,!1);w.appendChild(k)}return E.appendChild(w),g===-1?f.appendChild(E):f.insertBefore(E,f.children[g]),d(),E}function v(){if(a)return;const h=f.querySelectorAll(".multiple-text-item"),g=h.length;h.forEach(E=>{let w=E.querySelector(".remove-item-btn");w||(w=document.createElement("button"),w.type="button",w.className="remove-item-btn px-2 py-1 rounded",w.style.cssText=`
35
35
  color: var(--fb-error-color);
36
36
  background-color: transparent;
37
37
  transition: background-color var(--fb-transition-duration);
38
- `,C.innerHTML="\u2715",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{const k=Array.from(d.children).indexOf(E);d.children.length>p&&(c.splice(k,1),E.remove(),f(),v(),b())},E.appendChild(C));const x=g<=p;C.disabled=x,C.style.opacity=x?"0.5":"1",C.style.pointerEvents=x?"none":"auto"})}let y=null,w=null;if(!a){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const h=document.createElement("button");h.type="button",h.className="add-text-btn px-3 py-1 rounded",h.style.cssText=`
38
+ `,w.innerHTML="\u2715",w.addEventListener("mouseenter",()=>{w.style.backgroundColor="var(--fb-background-hover-color)"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="transparent"}),w.onclick=()=>{const k=Array.from(f.children).indexOf(E);f.children.length>p&&(s.splice(k,1),E.remove(),d(),b(),v())},E.appendChild(w));const x=g<=p;w.disabled=x,w.style.opacity=x?"0.5":"1",w.style.pointerEvents=x?"none":"auto"})}let y=null,C=null;if(!a){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const h=document.createElement("button");h.type="button",h.className="add-text-btn px-3 py-1 rounded",h.style.cssText=`
39
39
  color: var(--fb-primary-color);
40
40
  border: var(--fb-border-width) solid var(--fb-primary-color);
41
41
  background-color: transparent;
42
42
  font-size: var(--fb-font-size);
43
43
  transition: all var(--fb-transition-duration);
44
- `,h.textContent="+",h.addEventListener("mouseenter",()=>{h.style.backgroundColor="var(--fb-background-hover-color)"}),h.addEventListener("mouseleave",()=>{h.style.backgroundColor="transparent"}),h.onclick=()=>{c.push(e.default||""),m(e.default||""),v(),b()},w=document.createElement("span"),w.className="text-sm text-gray-500",y.appendChild(h),y.appendChild(w),n.appendChild(y)}function v(){if(!y||!w)return;const h=y.querySelector(".add-text-btn");if(h){const g=c.length>=u;h.disabled=g,h.style.opacity=g?"0.5":"1",h.style.pointerEvents=g?"none":"auto"}w.textContent=`${c.length}/${u===1/0?"\u221E":u}`}c.forEach(h=>m(h)),v(),b()}function Dt(e,t,n){var r,o,i;const l=[],{scopeRoot:a,skipValidation:s}=n,c=(u,d)=>{var f,m;if(!u)return;const b=`error-${u.getAttribute("name")||Math.random().toString(36).substring(7)}`;let y=document.getElementById(b);d?(u.classList.add("invalid"),u.title=d,y||(y=document.createElement("div"),y.id=b,y.className="error-message",y.style.cssText=`
44
+ `,h.textContent="+",h.addEventListener("mouseenter",()=>{h.style.backgroundColor="var(--fb-background-hover-color)"}),h.addEventListener("mouseleave",()=>{h.style.backgroundColor="transparent"}),h.onclick=()=>{s.push(e.default||""),m(e.default||""),b(),v()},C=document.createElement("span"),C.className="text-sm text-gray-500",y.appendChild(h),y.appendChild(C),n.appendChild(y)}function b(){if(!y||!C)return;const h=y.querySelector(".add-text-btn");if(h){const g=s.length>=u;h.disabled=g,h.style.opacity=g?"0.5":"1",h.style.pointerEvents=g?"none":"auto"}C.textContent=`${s.length}/${u===1/0?"\u221E":u}`}s.forEach(h=>m(h)),b(),v()}function Ut(e,t,n){var r,o,i;const l=[],{scopeRoot:a,skipValidation:c}=n,s=(u,f)=>{var d,m;if(!u)return;const v=`error-${u.getAttribute("name")||Math.random().toString(36).substring(7)}`;let y=document.getElementById(v);f?(u.classList.add("invalid"),u.title=f,y||(y=document.createElement("div"),y.id=v,y.className="error-message",y.style.cssText=`
45
45
  color: var(--fb-error-color);
46
46
  font-size: var(--fb-font-size-small);
47
47
  margin-top: 0.25rem;
48
- `,u.nextSibling?(f=u.parentNode)==null||f.insertBefore(y,u.nextSibling):(m=u.parentNode)==null||m.appendChild(y)),y.textContent=d,y.style.display="block"):(u.classList.remove("invalid"),u.title="",y&&y.remove())},p=(u,d,f)=>{let m=!1;const{state:b}=n;if(!s&&d){if(e.minLength!==void 0&&e.minLength!==null&&d.length<e.minLength){const y=$("minLength",b,{min:e.minLength});l.push(`${f}: ${y}`),c(u,y),m=!0}else if(e.maxLength!==void 0&&e.maxLength!==null&&d.length>e.maxLength){const y=$("maxLength",b,{max:e.maxLength});l.push(`${f}: ${y}`),c(u,y),m=!0}else if(e.pattern)try{if(!new RegExp(e.pattern).test(d)){const y=$("patternMismatch",b);l.push(`${f}: ${y}`),c(u,y),m=!0}}catch(y){const w=$("invalidPattern",b);l.push(`${f}: ${w}`),c(u,w),m=!0}}m||c(u,null)};if(e.multiple){const u=a.querySelectorAll(`[name^="${t}["]`),d=[],f=[];if(u.forEach((m,b)=>{var y;const w=(y=m==null?void 0:m.value)!=null?y:"";f.push(w),d.push(w===""?null:w),p(m,w,`${t}[${b}]`)}),!s){const{state:m}=n,b=(r=e.minCount)!=null?r:1,y=(o=e.maxCount)!=null?o:1/0,w=f.filter(v=>v.trim()!=="");e.required&&w.length===0&&l.push(`${t}: ${$("required",m)}`),w.length<b&&l.push(`${t}: ${$("minItems",m,{min:b})}`),w.length>y&&l.push(`${t}: ${$("maxItems",m,{max:y})}`)}return{value:d,errors:l}}else{const u=a.querySelector(`[name$="${t}"]`),d=(i=u==null?void 0:u.value)!=null?i:"";if(!s&&e.required&&d===""){const f=$("required",n.state);return l.push(`${t}: ${f}`),c(u,f),{value:null,errors:l}}return u&&p(u,d,t),{value:d===""?null:d,errors:l}}}function jt(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateTextField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}["]`);i.forEach((l,a)=>{a<n.length&&(l.value=n[a]!=null?String(n[a]):"",l.classList.remove("invalid"),l.title="")}),n.length!==i.length&&console.warn(`updateTextField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.classList.remove("invalid"),i.title="")}}function Ot(e){e.style.overflow="hidden",e.style.resize="none";const t=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(1,t);const n=()=>{e.isConnected&&(e.style.height="0",e.style.height=`${e.scrollHeight}px`)};e.addEventListener("input",n),setTimeout(()=>{e.isConnected&&n()},0)}function lr(e,t,n,r){const o=t.state,i=le(e,o,t),l=document.createElement("div");l.style.cssText="position: relative;";const a=document.createElement("textarea");if(a.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",a.style.cssText="padding-bottom: 24px;",a.name=r,a.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",a.rows=e.rows||4,a.value=t.prefill[e.key]||e.default||"",a.readOnly=i,!i&&t.instance){const s=()=>{const c=a.value===""?null:a.value;t.instance.triggerOnChange(r,c)};a.addEventListener("blur",s),a.addEventListener("input",s)}if((e.autoExpand||i)&&Ot(a),l.appendChild(a),!i&&(e.minLength!=null||e.maxLength!=null)){const s=je(e,a,!0);l.appendChild(s)}n.appendChild(l)}function ir(e,t,n,r){var o,i;const l=t.state,a=le(e,l,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],p=(o=e.minCount)!=null?o:1,u=(i=e.maxCount)!=null?i:1/0;for(;c.length<p;)c.push(e.default||"");const d=document.createElement("div");d.className="space-y-2",n.appendChild(d);function f(){d.querySelectorAll(".multiple-textarea-item").forEach((h,g)=>{const E=h.querySelector("textarea");E&&(E.name=`${r}[${g}]`)})}function m(h="",g=-1){const E=document.createElement("div");E.className="multiple-textarea-item";const C=document.createElement("div");C.style.cssText="position: relative;";const x=document.createElement("textarea");if(x.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",x.style.cssText="padding-bottom: 24px;",x.placeholder=e.placeholder||$("placeholderText",l),x.rows=e.rows||4,x.value=h,x.readOnly=a,!a&&t.instance){const k=()=>{const q=x.value===""?null:x.value;t.instance.triggerOnChange(x.name,q)};x.addEventListener("blur",k),x.addEventListener("input",k)}if((e.autoExpand||a)&&Ot(x),C.appendChild(x),!a&&(e.minLength!=null||e.maxLength!=null)){const k=je(e,x,!0);C.appendChild(k)}return E.appendChild(C),g===-1?d.appendChild(E):d.insertBefore(E,d.children[g]),f(),E}function b(){if(a)return;const h=d.querySelectorAll(".multiple-textarea-item"),g=h.length;h.forEach(E=>{let C=E.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn mt-1 px-2 py-1 text-red-600 hover:bg-red-50 rounded text-sm",C.innerHTML="\u2715",C.onclick=()=>{const k=Array.from(d.children).indexOf(E);d.children.length>p&&(c.splice(k,1),E.remove(),f(),v(),b())},E.appendChild(C));const x=g<=p;C.disabled=x,C.style.opacity=x?"0.5":"1",C.style.pointerEvents=x?"none":"auto"})}let y=null,w=null;if(!a){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const h=document.createElement("button");h.type="button",h.className="add-textarea-btn px-3 py-1 rounded",h.style.cssText=`
48
+ `,u.nextSibling?(d=u.parentNode)==null||d.insertBefore(y,u.nextSibling):(m=u.parentNode)==null||m.appendChild(y)),y.textContent=f,y.style.display="block"):(u.classList.remove("invalid"),u.title="",y&&y.remove())},p=(u,f,d)=>{let m=!1;const{state:v}=n;if(!c&&f){if(e.minLength!==void 0&&e.minLength!==null&&f.length<e.minLength){const y=$("minLength",v,{min:e.minLength});l.push(`${d}: ${y}`),s(u,y),m=!0}else if(e.maxLength!==void 0&&e.maxLength!==null&&f.length>e.maxLength){const y=$("maxLength",v,{max:e.maxLength});l.push(`${d}: ${y}`),s(u,y),m=!0}else if(e.pattern)try{if(!new RegExp(e.pattern).test(f)){const y=$("patternMismatch",v);l.push(`${d}: ${y}`),s(u,y),m=!0}}catch(y){const C=$("invalidPattern",v);l.push(`${d}: ${C}`),s(u,C),m=!0}}m||s(u,null)};if(e.multiple){const u=a.querySelectorAll(`[name^="${t}["]`),f=[],d=[];if(u.forEach((m,v)=>{var y;const C=(y=m==null?void 0:m.value)!=null?y:"";d.push(C),f.push(C===""?null:C),p(m,C,`${t}[${v}]`)}),!c){const{state:m}=n,v=(r=e.minCount)!=null?r:1,y=(o=e.maxCount)!=null?o:1/0,C=d.filter(b=>b.trim()!=="");e.required&&C.length===0&&l.push(`${t}: ${$("required",m)}`),C.length<v&&l.push(`${t}: ${$("minItems",m,{min:v})}`),C.length>y&&l.push(`${t}: ${$("maxItems",m,{max:y})}`)}return{value:f,errors:l}}else{const u=a.querySelector(`[name$="${t}"]`),f=(i=u==null?void 0:u.value)!=null?i:"";if(!c&&e.required&&f===""){const d=$("required",n.state);return l.push(`${t}: ${d}`),s(u,d),{value:null,errors:l}}return u&&p(u,f,t),{value:f===""?null:f,errors:l}}}function Pt(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateTextField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}["]`);i.forEach((l,a)=>{a<n.length&&(l.value=n[a]!=null?String(n[a]):"",l.classList.remove("invalid"),l.title="")}),n.length!==i.length&&console.warn(`updateTextField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.classList.remove("invalid"),i.title="")}}function Vt(e){e.style.overflow="hidden",e.style.resize="none";const t=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(1,t);const n=()=>{e.isConnected&&(e.style.height="0",e.style.height=`${e.scrollHeight}px`)};e.addEventListener("input",n),setTimeout(()=>{e.isConnected&&n()},0)}function fr(e,t,n,r){const o=t.state,i=le(e,o,t),l=document.createElement("div");l.style.cssText="position: relative;";const a=document.createElement("textarea");if(a.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",a.style.cssText="padding-bottom: 24px;",a.name=r,a.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",a.rows=e.rows||4,a.value=t.prefill[e.key]||e.default||"",a.readOnly=i,!i&&t.instance){const c=()=>{const s=a.value===""?null:a.value;t.instance.triggerOnChange(r,s)};a.addEventListener("blur",c),a.addEventListener("input",c)}if((e.autoExpand||i)&&Vt(a),l.appendChild(a),!i&&(e.minLength!=null||e.maxLength!=null)){const c=je(e,a,!0);l.appendChild(c)}n.appendChild(l)}function pr(e,t,n,r){var o,i;const l=t.state,a=le(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],p=(o=e.minCount)!=null?o:1,u=(i=e.maxCount)!=null?i:1/0;for(;s.length<p;)s.push(e.default||"");const f=document.createElement("div");f.className="space-y-2",n.appendChild(f);function d(){f.querySelectorAll(".multiple-textarea-item").forEach((h,g)=>{const E=h.querySelector("textarea");E&&(E.name=`${r}[${g}]`)})}function m(h="",g=-1){const E=document.createElement("div");E.className="multiple-textarea-item";const w=document.createElement("div");w.style.cssText="position: relative;";const x=document.createElement("textarea");if(x.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",x.style.cssText="padding-bottom: 24px;",x.placeholder=e.placeholder||$("placeholderText",l),x.rows=e.rows||4,x.value=h,x.readOnly=a,!a&&t.instance){const k=()=>{const I=x.value===""?null:x.value;t.instance.triggerOnChange(x.name,I)};x.addEventListener("blur",k),x.addEventListener("input",k)}if((e.autoExpand||a)&&Vt(x),w.appendChild(x),!a&&(e.minLength!=null||e.maxLength!=null)){const k=je(e,x,!0);w.appendChild(k)}return E.appendChild(w),g===-1?f.appendChild(E):f.insertBefore(E,f.children[g]),d(),E}function v(){if(a)return;const h=f.querySelectorAll(".multiple-textarea-item"),g=h.length;h.forEach(E=>{let w=E.querySelector(".remove-item-btn");w||(w=document.createElement("button"),w.type="button",w.className="remove-item-btn mt-1 px-2 py-1 text-red-600 hover:bg-red-50 rounded text-sm",w.innerHTML="\u2715",w.onclick=()=>{const k=Array.from(f.children).indexOf(E);f.children.length>p&&(s.splice(k,1),E.remove(),d(),b(),v())},E.appendChild(w));const x=g<=p;w.disabled=x,w.style.opacity=x?"0.5":"1",w.style.pointerEvents=x?"none":"auto"})}let y=null,C=null;if(!a){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const h=document.createElement("button");h.type="button",h.className="add-textarea-btn px-3 py-1 rounded",h.style.cssText=`
49
49
  color: var(--fb-primary-color);
50
50
  border: var(--fb-border-width) solid var(--fb-primary-color);
51
51
  background-color: transparent;
52
52
  font-size: var(--fb-font-size);
53
53
  transition: all var(--fb-transition-duration);
54
- `,h.textContent="+",h.addEventListener("mouseenter",()=>{h.style.backgroundColor="var(--fb-background-hover-color)"}),h.addEventListener("mouseleave",()=>{h.style.backgroundColor="transparent"}),h.onclick=()=>{c.push(e.default||""),m(e.default||""),v(),b()},w=document.createElement("span"),w.className="text-sm text-gray-500",y.appendChild(h),y.appendChild(w),n.appendChild(y)}function v(){if(!y||!w)return;const h=y.querySelector(".add-textarea-btn");if(h){const g=c.length>=u;h.disabled=g,h.style.opacity=g?"0.5":"1",h.style.pointerEvents=g?"none":"auto"}w.textContent=`${c.length}/${u===1/0?"\u221E":u}`}c.forEach(h=>m(h)),v(),b()}function ar(e,t,n){return Dt(e,t,n)}function sr(e,t,n,r){jt(e,t,n,r);const{scopeRoot:o,state:i}=r;if(e.autoExpand||le(e,i))if(e.multiple)o.querySelectorAll(`textarea[name^="${t}["]`).forEach(l=>{l.dispatchEvent(new Event("input"))});else{const l=o.querySelector(`textarea[name="${t}"]`);l&&l.dispatchEvent(new Event("input"))}}function Ut(e,t){const n=document.createElement("span");n.className="number-range-hint",n.style.cssText=`
54
+ `,h.textContent="+",h.addEventListener("mouseenter",()=>{h.style.backgroundColor="var(--fb-background-hover-color)"}),h.addEventListener("mouseleave",()=>{h.style.backgroundColor="transparent"}),h.onclick=()=>{s.push(e.default||""),m(e.default||""),b(),v()},C=document.createElement("span"),C.className="text-sm text-gray-500",y.appendChild(h),y.appendChild(C),n.appendChild(y)}function b(){if(!y||!C)return;const h=y.querySelector(".add-textarea-btn");if(h){const g=s.length>=u;h.disabled=g,h.style.opacity=g?"0.5":"1",h.style.pointerEvents=g?"none":"auto"}C.textContent=`${s.length}/${u===1/0?"\u221E":u}`}s.forEach(h=>m(h)),b(),v()}function mr(e,t,n){return Ut(e,t,n)}function hr(e,t,n,r){Pt(e,t,n,r);const{scopeRoot:o,state:i}=r;if(e.autoExpand||le(e,i))if(e.multiple)o.querySelectorAll(`textarea[name^="${t}["]`).forEach(l=>{l.dispatchEvent(new Event("input"))});else{const l=o.querySelector(`textarea[name="${t}"]`);l&&l.dispatchEvent(new Event("input"))}}function Wt(e,t){const n=document.createElement("span");n.className="number-range-hint",n.style.cssText=`
55
55
  position: absolute;
56
56
  top: 50%;
57
57
  transform: translateY(-50%);
@@ -61,31 +61,31 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
61
61
  pointer-events: none;
62
62
  background: var(--fb-background-color);
63
63
  padding: 0 4px;
64
- `;const r=e.min,o=e.max;let i="";r!=null&&o!=null?i=`${r} \u2013 ${o}`:o!=null?i=`\u2264${o}`:r!=null&&(i=`\u2265${r}`),n.textContent=i;const l=()=>{const a=t.value?parseFloat(t.value):null;if(a!=null){const s=r!=null&&a<r,c=o!=null&&a>o;n.style.color=s||c?"var(--fb-error-color)":"var(--fb-text-secondary-color)"}else n.style.color="var(--fb-text-secondary-color)"};return t.addEventListener("input",l),l(),n}function cr(e,t,n,r){const o=t.state,i=le(e,o,t),l=document.createElement("div");l.style.cssText="position: relative;";const a=document.createElement("input");if(a.type="number",a.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",a.style.cssText="padding-right: 60px; width: 100%; box-sizing: border-box;",a.name=r,a.placeholder=e.placeholder||"0",e.min!==void 0&&(a.min=e.min.toString()),e.max!==void 0&&(a.max=e.max.toString()),e.step!==void 0&&(a.step=e.step.toString()),a.value=t.prefill[e.key]||e.default||"",a.readOnly=i,!i&&t.instance){const s=()=>{const c=a.value?parseFloat(a.value):null;t.instance.triggerOnChange(r,c)};a.addEventListener("blur",s),a.addEventListener("input",s)}if(l.appendChild(a),!i&&(e.min!=null||e.max!=null)){const s=Ut(e,a);l.appendChild(s)}n.appendChild(l)}function ur(e,t,n,r){var o,i;const l=t.state,a=le(e,l,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],p=(o=e.minCount)!=null?o:1,u=(i=e.maxCount)!=null?i:1/0;for(;c.length<p;)c.push(e.default||"");const d=document.createElement("div");d.className="space-y-2",n.appendChild(d);function f(){d.querySelectorAll(".multiple-number-item").forEach((h,g)=>{const E=h.querySelector("input");E&&(E.name=`${r}[${g}]`)})}function m(h="",g=-1){const E=document.createElement("div");E.className="multiple-number-item flex items-center gap-2";const C=document.createElement("div");C.style.cssText="position: relative; flex: 1;";const x=document.createElement("input");if(x.type="number",x.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",x.style.cssText="padding-right: 60px; width: 100%; box-sizing: border-box;",x.placeholder=e.placeholder||"0",e.min!==void 0&&(x.min=e.min.toString()),e.max!==void 0&&(x.max=e.max.toString()),e.step!==void 0&&(x.step=e.step.toString()),x.value=h.toString(),x.readOnly=a,!a&&t.instance){const k=()=>{const q=x.value?parseFloat(x.value):null;t.instance.triggerOnChange(x.name,q)};x.addEventListener("blur",k),x.addEventListener("input",k)}if(C.appendChild(x),!a&&(e.min!=null||e.max!=null)){const k=Ut(e,x);C.appendChild(k)}return E.appendChild(C),g===-1?d.appendChild(E):d.insertBefore(E,d.children[g]),f(),E}function b(){if(a)return;const h=d.querySelectorAll(".multiple-number-item"),g=h.length;h.forEach(E=>{let C=E.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",C.innerHTML="\u2715",C.onclick=()=>{const k=Array.from(d.children).indexOf(E);d.children.length>p&&(c.splice(k,1),E.remove(),f(),v(),b())},E.appendChild(C));const x=g<=p;C.disabled=x,C.style.opacity=x?"0.5":"1",C.style.pointerEvents=x?"none":"auto"})}let y=null,w=null;if(!a){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const h=document.createElement("button");h.type="button",h.className="add-number-btn px-3 py-1 rounded",h.style.cssText=`
64
+ `;const r=e.min,o=e.max;let i="";r!=null&&o!=null?i=`${r} \u2013 ${o}`:o!=null?i=`\u2264${o}`:r!=null&&(i=`\u2265${r}`),n.textContent=i;const l=()=>{const a=t.value?parseFloat(t.value):null;if(a!=null){const c=r!=null&&a<r,s=o!=null&&a>o;n.style.color=c||s?"var(--fb-error-color)":"var(--fb-text-secondary-color)"}else n.style.color="var(--fb-text-secondary-color)"};return t.addEventListener("input",l),l(),n}function br(e,t,n,r){const o=t.state,i=le(e,o,t),l=document.createElement("div");l.style.cssText="position: relative;";const a=document.createElement("input");if(a.type="number",a.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",a.style.cssText="padding-right: 60px; width: 100%; box-sizing: border-box;",a.name=r,a.placeholder=e.placeholder||"0",e.min!==void 0&&(a.min=e.min.toString()),e.max!==void 0&&(a.max=e.max.toString()),e.step!==void 0&&(a.step=e.step.toString()),a.value=t.prefill[e.key]||e.default||"",a.readOnly=i,!i&&t.instance){const c=()=>{const s=a.value?parseFloat(a.value):null;t.instance.triggerOnChange(r,s)};a.addEventListener("blur",c),a.addEventListener("input",c)}if(l.appendChild(a),!i&&(e.min!=null||e.max!=null)){const c=Wt(e,a);l.appendChild(c)}n.appendChild(l)}function vr(e,t,n,r){var o,i;const l=t.state,a=le(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],p=(o=e.minCount)!=null?o:1,u=(i=e.maxCount)!=null?i:1/0;for(;s.length<p;)s.push(e.default||"");const f=document.createElement("div");f.className="space-y-2",n.appendChild(f);function d(){f.querySelectorAll(".multiple-number-item").forEach((h,g)=>{const E=h.querySelector("input");E&&(E.name=`${r}[${g}]`)})}function m(h="",g=-1){const E=document.createElement("div");E.className="multiple-number-item flex items-center gap-2";const w=document.createElement("div");w.style.cssText="position: relative; flex: 1;";const x=document.createElement("input");if(x.type="number",x.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",x.style.cssText="padding-right: 60px; width: 100%; box-sizing: border-box;",x.placeholder=e.placeholder||"0",e.min!==void 0&&(x.min=e.min.toString()),e.max!==void 0&&(x.max=e.max.toString()),e.step!==void 0&&(x.step=e.step.toString()),x.value=h.toString(),x.readOnly=a,!a&&t.instance){const k=()=>{const I=x.value?parseFloat(x.value):null;t.instance.triggerOnChange(x.name,I)};x.addEventListener("blur",k),x.addEventListener("input",k)}if(w.appendChild(x),!a&&(e.min!=null||e.max!=null)){const k=Wt(e,x);w.appendChild(k)}return E.appendChild(w),g===-1?f.appendChild(E):f.insertBefore(E,f.children[g]),d(),E}function v(){if(a)return;const h=f.querySelectorAll(".multiple-number-item"),g=h.length;h.forEach(E=>{let w=E.querySelector(".remove-item-btn");w||(w=document.createElement("button"),w.type="button",w.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",w.innerHTML="\u2715",w.onclick=()=>{const k=Array.from(f.children).indexOf(E);f.children.length>p&&(s.splice(k,1),E.remove(),d(),b(),v())},E.appendChild(w));const x=g<=p;w.disabled=x,w.style.opacity=x?"0.5":"1",w.style.pointerEvents=x?"none":"auto"})}let y=null,C=null;if(!a){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const h=document.createElement("button");h.type="button",h.className="add-number-btn px-3 py-1 rounded",h.style.cssText=`
65
65
  color: var(--fb-primary-color);
66
66
  border: var(--fb-border-width) solid var(--fb-primary-color);
67
67
  background-color: transparent;
68
68
  font-size: var(--fb-font-size);
69
69
  transition: all var(--fb-transition-duration);
70
- `,h.textContent="+",h.addEventListener("mouseenter",()=>{h.style.backgroundColor="var(--fb-background-hover-color)"}),h.addEventListener("mouseleave",()=>{h.style.backgroundColor="transparent"}),h.onclick=()=>{c.push(e.default||""),m(e.default||""),v(),b()},w=document.createElement("span"),w.className="text-sm text-gray-500",y.appendChild(h),y.appendChild(w),n.appendChild(y)}function v(){if(!y||!w)return;const h=y.querySelector(".add-number-btn");if(h){const g=c.length>=u;h.disabled=g,h.style.opacity=g?"0.5":"1",h.style.pointerEvents=g?"none":"auto"}w.textContent=`${c.length}/${u===1/0?"\u221E":u}`}c.forEach(h=>m(h)),v(),b()}function dr(e,t,n){var r,o,i,l,a;const s=[],{scopeRoot:c,skipValidation:p}=n,u=(f,m)=>{var b,y;if(!f)return;const w=`error-${f.getAttribute("name")||Math.random().toString(36).substring(7)}`;let v=document.getElementById(w);m?(f.classList.add("invalid"),f.title=m,v||(v=document.createElement("div"),v.id=w,v.className="error-message",v.style.cssText=`
70
+ `,h.textContent="+",h.addEventListener("mouseenter",()=>{h.style.backgroundColor="var(--fb-background-hover-color)"}),h.addEventListener("mouseleave",()=>{h.style.backgroundColor="transparent"}),h.onclick=()=>{s.push(e.default||""),m(e.default||""),b(),v()},C=document.createElement("span"),C.className="text-sm text-gray-500",y.appendChild(h),y.appendChild(C),n.appendChild(y)}function b(){if(!y||!C)return;const h=y.querySelector(".add-number-btn");if(h){const g=s.length>=u;h.disabled=g,h.style.opacity=g?"0.5":"1",h.style.pointerEvents=g?"none":"auto"}C.textContent=`${s.length}/${u===1/0?"\u221E":u}`}s.forEach(h=>m(h)),b(),v()}function gr(e,t,n){var r,o,i,l,a;const c=[],{scopeRoot:s,skipValidation:p}=n,u=(d,m)=>{var v,y;if(!d)return;const C=`error-${d.getAttribute("name")||Math.random().toString(36).substring(7)}`;let b=document.getElementById(C);m?(d.classList.add("invalid"),d.title=m,b||(b=document.createElement("div"),b.id=C,b.className="error-message",b.style.cssText=`
71
71
  color: var(--fb-error-color);
72
72
  font-size: var(--fb-font-size-small);
73
73
  margin-top: 0.25rem;
74
- `,f.nextSibling?(b=f.parentNode)==null||b.insertBefore(v,f.nextSibling):(y=f.parentNode)==null||y.appendChild(v)),v.textContent=m,v.style.display="block"):(f.classList.remove("invalid"),f.title="",v&&v.remove())},d=(f,m,b)=>{let y=!1;const{state:w}=n;if(!p&&e.min!==void 0&&e.min!==null&&m<e.min){const v=$("minValue",w,{min:e.min});s.push(`${b}: ${v}`),u(f,v),y=!0}else if(!p&&e.max!==void 0&&e.max!==null&&m>e.max){const v=$("maxValue",w,{max:e.max});s.push(`${b}: ${v}`),u(f,v),y=!0}y||u(f,null)};if(e.multiple){const f=c.querySelectorAll(`[name^="${t}["]`),m=[];if(f.forEach((b,y)=>{var w,v,h;const g=(w=b==null?void 0:b.value)!=null?w:"";if(g===""){m.push(null),u(b,null);return}const E=parseFloat(g);if(!p&&!Number.isFinite(E)){const x=$("notANumber",n.state);s.push(`${t}[${y}]: ${x}`),u(b,x),m.push(null);return}d(b,E,`${t}[${y}]`);const C=Number.isInteger((v=e.decimals)!=null?v:0)&&(h=e.decimals)!=null?h:0;m.push(Number(E.toFixed(C)))}),!p){const{state:b}=n,y=(r=e.minCount)!=null?r:1,w=(o=e.maxCount)!=null?o:1/0,v=m.filter(h=>h!==null);e.required&&v.length===0&&s.push(`${t}: ${$("required",b)}`),v.length<y&&s.push(`${t}: ${$("minItems",b,{min:y})}`),v.length>w&&s.push(`${t}: ${$("maxItems",b,{max:w})}`)}return{value:m,errors:s}}else{const f=c.querySelector(`[name$="${t}"]`),m=(i=f==null?void 0:f.value)!=null?i:"",{state:b}=n;if(!p&&e.required&&m===""){const v=$("required",b);return s.push(`${t}: ${v}`),u(f,v),{value:null,errors:s}}if(m==="")return u(f,null),{value:null,errors:s};const y=parseFloat(m);if(!p&&!Number.isFinite(y)){const v=$("notANumber",b);return s.push(`${t}: ${v}`),u(f,v),{value:null,errors:s}}d(f,y,t);const w=Number.isInteger((l=e.decimals)!=null?l:0)&&(a=e.decimals)!=null?a:0;return{value:Number(y.toFixed(w)),errors:s}}}function fr(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateNumberField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}["]`);i.forEach((l,a)=>{a<n.length&&(l.value=n[a]!=null?String(n[a]):"",l.classList.remove("invalid"),l.title="")}),n.length!==i.length&&console.warn(`updateNumberField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.classList.remove("invalid"),i.title="")}}function pr(e,t,n,r){const o=t.state,i=le(e,o,t),l=document.createElement("select");if(l.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",l.name=r,l.disabled=i,(e.options||[]).forEach(a=>{const s=document.createElement("option");s.value=a.value,s.textContent=a.label,(t.prefill[e.key]||e.default)===a.value&&(s.selected=!0),l.appendChild(s)}),!i&&t.instance){const a=()=>{t.instance.triggerOnChange(r,l.value)};l.addEventListener("change",a)}if(n.appendChild(l),!i){const a=document.createElement("p");a.className="text-xs text-gray-500 mt-1",a.textContent=ve(e,o),n.appendChild(a)}}function mr(e,t,n,r){var o,i,l,a;const s=t.state,c=le(e,s,t),p=t.prefill[e.key]||[],u=Array.isArray(p)?[...p]:[],d=(o=e.minCount)!=null?o:1,f=(i=e.maxCount)!=null?i:1/0;for(;u.length<d;)u.push(e.default||((a=(l=e.options)==null?void 0:l[0])==null?void 0:a.value)||"");const m=document.createElement("div");m.className="space-y-2",n.appendChild(m);function b(){m.querySelectorAll(".multiple-select-item").forEach((E,C)=>{const x=E.querySelector("select");x&&(x.name=`${r}[${C}]`)})}function y(E="",C=-1){const x=document.createElement("div");x.className="multiple-select-item flex items-center gap-2";const k=document.createElement("select");if(k.className="flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",k.disabled=c,(e.options||[]).forEach(q=>{const K=document.createElement("option");K.value=q.value,K.textContent=q.label,E===q.value&&(K.selected=!0),k.appendChild(K)}),!c&&t.instance){const q=()=>{t.instance.triggerOnChange(k.name,k.value)};k.addEventListener("change",q)}return x.appendChild(k),C===-1?m.appendChild(x):m.insertBefore(x,m.children[C]),b(),x}function w(){if(c)return;const E=m.querySelectorAll(".multiple-select-item"),C=E.length;E.forEach(x=>{let k=x.querySelector(".remove-item-btn");k||(k=document.createElement("button"),k.type="button",k.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",k.innerHTML="\u2715",k.onclick=()=>{const K=Array.from(m.children).indexOf(x);m.children.length>d&&(u.splice(K,1),x.remove(),b(),g(),w())},x.appendChild(k));const q=C<=d;k.disabled=q,k.style.opacity=q?"0.5":"1",k.style.pointerEvents=q?"none":"auto"})}let v=null,h=null;if(!c){v=document.createElement("div"),v.className="flex items-center gap-3 mt-2";const E=document.createElement("button");E.type="button",E.className="add-select-btn px-3 py-1 rounded",E.style.cssText=`
74
+ `,d.nextSibling?(v=d.parentNode)==null||v.insertBefore(b,d.nextSibling):(y=d.parentNode)==null||y.appendChild(b)),b.textContent=m,b.style.display="block"):(d.classList.remove("invalid"),d.title="",b&&b.remove())},f=(d,m,v)=>{let y=!1;const{state:C}=n;if(!p&&e.min!==void 0&&e.min!==null&&m<e.min){const b=$("minValue",C,{min:e.min});c.push(`${v}: ${b}`),u(d,b),y=!0}else if(!p&&e.max!==void 0&&e.max!==null&&m>e.max){const b=$("maxValue",C,{max:e.max});c.push(`${v}: ${b}`),u(d,b),y=!0}y||u(d,null)};if(e.multiple){const d=s.querySelectorAll(`[name^="${t}["]`),m=[];if(d.forEach((v,y)=>{var C,b,h;const g=(C=v==null?void 0:v.value)!=null?C:"";if(g===""){m.push(null),u(v,null);return}const E=parseFloat(g);if(!p&&!Number.isFinite(E)){const x=$("notANumber",n.state);c.push(`${t}[${y}]: ${x}`),u(v,x),m.push(null);return}f(v,E,`${t}[${y}]`);const w=Number.isInteger((b=e.decimals)!=null?b:0)&&(h=e.decimals)!=null?h:0;m.push(Number(E.toFixed(w)))}),!p){const{state:v}=n,y=(r=e.minCount)!=null?r:1,C=(o=e.maxCount)!=null?o:1/0,b=m.filter(h=>h!==null);e.required&&b.length===0&&c.push(`${t}: ${$("required",v)}`),b.length<y&&c.push(`${t}: ${$("minItems",v,{min:y})}`),b.length>C&&c.push(`${t}: ${$("maxItems",v,{max:C})}`)}return{value:m,errors:c}}else{const d=s.querySelector(`[name$="${t}"]`),m=(i=d==null?void 0:d.value)!=null?i:"",{state:v}=n;if(!p&&e.required&&m===""){const b=$("required",v);return c.push(`${t}: ${b}`),u(d,b),{value:null,errors:c}}if(m==="")return u(d,null),{value:null,errors:c};const y=parseFloat(m);if(!p&&!Number.isFinite(y)){const b=$("notANumber",v);return c.push(`${t}: ${b}`),u(d,b),{value:null,errors:c}}f(d,y,t);const C=Number.isInteger((l=e.decimals)!=null?l:0)&&(a=e.decimals)!=null?a:0;return{value:Number(y.toFixed(C)),errors:c}}}function yr(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateNumberField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}["]`);i.forEach((l,a)=>{a<n.length&&(l.value=n[a]!=null?String(n[a]):"",l.classList.remove("invalid"),l.title="")}),n.length!==i.length&&console.warn(`updateNumberField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.classList.remove("invalid"),i.title="")}}function xr(e,t,n,r){const o=t.state,i=le(e,o,t),l=document.createElement("select");if(l.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",l.name=r,l.disabled=i,(e.options||[]).forEach(a=>{const c=document.createElement("option");c.value=a.value,c.textContent=a.label,(t.prefill[e.key]||e.default)===a.value&&(c.selected=!0),l.appendChild(c)}),!i&&t.instance){const a=()=>{t.instance.triggerOnChange(r,l.value)};l.addEventListener("change",a)}if(n.appendChild(l),!i){const a=document.createElement("p");a.className="text-xs text-gray-500 mt-1",a.textContent=be(e,o),n.appendChild(a)}}function Er(e,t,n,r){var o,i,l,a;const c=t.state,s=le(e,c,t),p=t.prefill[e.key]||[],u=Array.isArray(p)?[...p]:[],f=(o=e.minCount)!=null?o:1,d=(i=e.maxCount)!=null?i:1/0;for(;u.length<f;)u.push(e.default||((a=(l=e.options)==null?void 0:l[0])==null?void 0:a.value)||"");const m=document.createElement("div");m.className="space-y-2",n.appendChild(m);function v(){m.querySelectorAll(".multiple-select-item").forEach((E,w)=>{const x=E.querySelector("select");x&&(x.name=`${r}[${w}]`)})}function y(E="",w=-1){const x=document.createElement("div");x.className="multiple-select-item flex items-center gap-2";const k=document.createElement("select");if(k.className="flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",k.disabled=s,(e.options||[]).forEach(I=>{const K=document.createElement("option");K.value=I.value,K.textContent=I.label,E===I.value&&(K.selected=!0),k.appendChild(K)}),!s&&t.instance){const I=()=>{t.instance.triggerOnChange(k.name,k.value)};k.addEventListener("change",I)}return x.appendChild(k),w===-1?m.appendChild(x):m.insertBefore(x,m.children[w]),v(),x}function C(){if(s)return;const E=m.querySelectorAll(".multiple-select-item"),w=E.length;E.forEach(x=>{let k=x.querySelector(".remove-item-btn");k||(k=document.createElement("button"),k.type="button",k.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",k.innerHTML="\u2715",k.onclick=()=>{const K=Array.from(m.children).indexOf(x);m.children.length>f&&(u.splice(K,1),x.remove(),v(),g(),C())},x.appendChild(k));const I=w<=f;k.disabled=I,k.style.opacity=I?"0.5":"1",k.style.pointerEvents=I?"none":"auto"})}let b=null,h=null;if(!s){b=document.createElement("div"),b.className="flex items-center gap-3 mt-2";const E=document.createElement("button");E.type="button",E.className="add-select-btn px-3 py-1 rounded",E.style.cssText=`
75
75
  color: var(--fb-primary-color);
76
76
  border: var(--fb-border-width) solid var(--fb-primary-color);
77
77
  background-color: transparent;
78
78
  font-size: var(--fb-font-size);
79
79
  transition: all var(--fb-transition-duration);
80
- `,E.textContent="+",E.addEventListener("mouseenter",()=>{E.style.backgroundColor="var(--fb-background-hover-color)"}),E.addEventListener("mouseleave",()=>{E.style.backgroundColor="transparent"}),E.onclick=()=>{var C,x;const k=e.default||((x=(C=e.options)==null?void 0:C[0])==null?void 0:x.value)||"";u.push(k),y(k),g(),w()},h=document.createElement("span"),h.className="text-sm text-gray-500",v.appendChild(E),v.appendChild(h),n.appendChild(v)}function g(){if(!v||!h)return;const E=v.querySelector(".add-select-btn");if(E){const C=u.length>=f;E.disabled=C,E.style.opacity=C?"0.5":"1",E.style.pointerEvents=C?"none":"auto"}h.textContent=`${u.length}/${f===1/0?"\u221E":f}`}if(u.forEach(E=>y(E)),g(),w(),!c){const E=document.createElement("p");E.className="text-xs text-gray-500 mt-1",E.textContent=ve(e,s),n.appendChild(E)}}function hr(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:l}=n,a=(c,p)=>{var u,d;if(!c)return;const f=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let m=document.getElementById(f);p?(c.classList.add("invalid"),c.title=p,m||(m=document.createElement("div"),m.id=f,m.className="error-message",m.style.cssText=`
80
+ `,E.textContent="+",E.addEventListener("mouseenter",()=>{E.style.backgroundColor="var(--fb-background-hover-color)"}),E.addEventListener("mouseleave",()=>{E.style.backgroundColor="transparent"}),E.onclick=()=>{var w,x;const k=e.default||((x=(w=e.options)==null?void 0:w[0])==null?void 0:x.value)||"";u.push(k),y(k),g(),C()},h=document.createElement("span"),h.className="text-sm text-gray-500",b.appendChild(E),b.appendChild(h),n.appendChild(b)}function g(){if(!b||!h)return;const E=b.querySelector(".add-select-btn");if(E){const w=u.length>=d;E.disabled=w,E.style.opacity=w?"0.5":"1",E.style.pointerEvents=w?"none":"auto"}h.textContent=`${u.length}/${d===1/0?"\u221E":d}`}if(u.forEach(E=>y(E)),g(),C(),!s){const E=document.createElement("p");E.className="text-xs text-gray-500 mt-1",E.textContent=be(e,c),n.appendChild(E)}}function wr(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:l}=n,a=(s,p)=>{var u,f;if(!s)return;const d=`error-${s.getAttribute("name")||Math.random().toString(36).substring(7)}`;let m=document.getElementById(d);p?(s.classList.add("invalid"),s.title=p,m||(m=document.createElement("div"),m.id=d,m.className="error-message",m.style.cssText=`
81
81
  color: var(--fb-error-color);
82
82
  font-size: var(--fb-font-size-small);
83
83
  margin-top: 0.25rem;
84
- `,c.nextSibling?(u=c.parentNode)==null||u.insertBefore(m,c.nextSibling):(d=c.parentNode)==null||d.appendChild(m)),m.textContent=p,m.style.display="block"):(c.classList.remove("invalid"),c.title="",m&&m.remove())},s=(c,p,u,d)=>{var f,m;if(l)return;const{state:b}=n,y=p.filter(d),w="minCount"in u&&(f=u.minCount)!=null?f:1,v="maxCount"in u&&(m=u.maxCount)!=null?m:1/0;u.required&&y.length===0&&o.push(`${c}: ${$("required",b)}`),y.length<w&&o.push(`${c}: ${$("minItems",b,{min:w})}`),y.length>v&&o.push(`${c}: ${$("maxItems",b,{max:v})}`)};if("multiple"in e&&e.multiple){const c=i.querySelectorAll(`[name^="${t}["]`),p=[];return c.forEach(u=>{var d;const f=(d=u==null?void 0:u.value)!=null?d:"";p.push(f),a(u,null)}),s(t,p,e,u=>u!==""),{value:p,errors:o}}else{const c=i.querySelector(`[name$="${t}"]`),p=(r=c==null?void 0:c.value)!=null?r:"";if(!l&&e.required&&p===""){const u=$("required",n.state);return o.push(`${t}: ${u}`),a(c,u),{value:null,errors:o}}else a(c,null);return{value:p===""?null:p,errors:o}}}function vr(e,t,n,r){const{scopeRoot:o}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSelectField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}["]`);i.forEach((l,a)=>{a<n.length&&(l.value=n[a]!=null?String(n[a]):"",l.querySelectorAll("option").forEach(s=>{s.selected=s.value===String(n[a])}),l.classList.remove("invalid"),l.title="")}),n.length!==i.length&&console.warn(`updateSelectField: Multiple field "${t}" has ${i.length} selects but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.querySelectorAll("option").forEach(l=>{l.selected=l.value===String(n)}),i.classList.remove("invalid"),i.title="")}}function Ye(e){e.style.backgroundColor="var(--fb-primary-color)",e.style.color="#ffffff",e.style.borderColor="var(--fb-primary-color)"}function Xe(e){e.style.backgroundColor="transparent",e.style.color="var(--fb-text-color)",e.style.borderColor="var(--fb-border-color)"}function Pt(e,t,n,r,o){const i=e.options||[],l=document.createElement("div");l.className="fb-switcher-group",l.style.cssText=`
84
+ `,s.nextSibling?(u=s.parentNode)==null||u.insertBefore(m,s.nextSibling):(f=s.parentNode)==null||f.appendChild(m)),m.textContent=p,m.style.display="block"):(s.classList.remove("invalid"),s.title="",m&&m.remove())},c=(s,p,u,f)=>{var d,m;if(l)return;const{state:v}=n,y=p.filter(f),C="minCount"in u&&(d=u.minCount)!=null?d:1,b="maxCount"in u&&(m=u.maxCount)!=null?m:1/0;u.required&&y.length===0&&o.push(`${s}: ${$("required",v)}`),y.length<C&&o.push(`${s}: ${$("minItems",v,{min:C})}`),y.length>b&&o.push(`${s}: ${$("maxItems",v,{max:b})}`)};if("multiple"in e&&e.multiple){const s=i.querySelectorAll(`[name^="${t}["]`),p=[];return s.forEach(u=>{var f;const d=(f=u==null?void 0:u.value)!=null?f:"";p.push(d),a(u,null)}),c(t,p,e,u=>u!==""),{value:p,errors:o}}else{const s=i.querySelector(`[name$="${t}"]`),p=(r=s==null?void 0:s.value)!=null?r:"";if(!l&&e.required&&p===""){const u=$("required",n.state);return o.push(`${t}: ${u}`),a(s,u),{value:null,errors:o}}else a(s,null);return{value:p===""?null:p,errors:o}}}function Cr(e,t,n,r){const{scopeRoot:o}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSelectField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}["]`);i.forEach((l,a)=>{a<n.length&&(l.value=n[a]!=null?String(n[a]):"",l.querySelectorAll("option").forEach(c=>{c.selected=c.value===String(n[a])}),l.classList.remove("invalid"),l.title="")}),n.length!==i.length&&console.warn(`updateSelectField: Multiple field "${t}" has ${i.length} selects but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.querySelectorAll("option").forEach(l=>{l.selected=l.value===String(n)}),i.classList.remove("invalid"),i.title="")}}function Xe(e){e.style.backgroundColor="var(--fb-primary-color)",e.style.color="#ffffff",e.style.borderColor="var(--fb-primary-color)"}function Ge(e){e.style.backgroundColor="transparent",e.style.color="var(--fb-text-color)",e.style.borderColor="var(--fb-border-color)"}function Kt(e,t,n,r,o){const i=e.options||[],l=document.createElement("div");l.className="fb-switcher-group",l.style.cssText=`
85
85
  display: inline-flex;
86
86
  flex-direction: row;
87
87
  flex-wrap: nowrap;
88
- `;const a=[];return i.forEach((s,c)=>{const p=document.createElement("button");p.type="button",p.className="fb-switcher-btn",p.dataset.value=s.value,p.textContent=s.label,p.style.cssText=`
88
+ `;const a=[];return i.forEach((c,s)=>{const p=document.createElement("button");p.type="button",p.className="fb-switcher-btn",p.dataset.value=c.value,p.textContent=c.label,p.style.cssText=`
89
89
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
90
90
  font-size: var(--fb-font-size);
91
91
  border-width: var(--fb-border-width);
@@ -95,21 +95,21 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
95
95
  white-space: nowrap;
96
96
  line-height: 1.25;
97
97
  outline: none;
98
- `,i.length===1?p.style.borderRadius="var(--fb-border-radius)":c===0?(p.style.borderRadius="var(--fb-border-radius) 0 0 var(--fb-border-radius)",p.style.borderRightWidth="0"):c===i.length-1?p.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(p.style.borderRadius="0",p.style.borderRightWidth="0"),s.value===t?Ye(p):Xe(p),r||(p.addEventListener("click",()=>{n.value=s.value,a.forEach(u=>{u.dataset.value===s.value?Ye(u):Xe(u)}),o&&o(s.value)}),p.addEventListener("mouseenter",()=>{n.value!==s.value&&(p.style.backgroundColor="var(--fb-background-hover-color)")}),p.addEventListener("mouseleave",()=>{n.value!==s.value&&(p.style.backgroundColor="transparent")})),a.push(p),l.appendChild(p)}),l}function br(e,t,n,r){var o,i;const l=t.state,a=String((i=(o=t.prefill[e.key])!=null?o:e.default)!=null?i:""),s=document.createElement("input");s.type="hidden",s.name=r,s.value=a;const c=le(e,l,t),p=!c&&t.instance?d=>{t.instance.triggerOnChange(r,d)}:null,u=Pt(e,a,s,c,p);if(n.appendChild(s),n.appendChild(u),!c){const d=document.createElement("p");d.className="text-xs text-gray-500 mt-1",d.textContent=ve(e,l),n.appendChild(d)}}function gr(e,t,n,r){var o,i,l,a;const s=t.state,c=t.prefill[e.key]||[],p=Array.isArray(c)?[...c]:[],u=(o=e.minCount)!=null?o:1,d=(i=e.maxCount)!=null?i:1/0;for(;p.length<u;)p.push(e.default||((a=(l=e.options)==null?void 0:l[0])==null?void 0:a.value)||"");const f=le(e,s,t),m=document.createElement("div");m.className="space-y-2",n.appendChild(m);function b(){m.querySelectorAll(".multiple-switcher-item").forEach((E,C)=>{const x=E.querySelector("input[type=hidden]");x&&(x.name=`${r}[${C}]`)})}function y(E="",C=-1){const x=C===-1?m.children.length:C,k=`${r}[${x}]`,q=document.createElement("div");q.className="multiple-switcher-item flex items-center gap-2";const K=document.createElement("input");K.type="hidden",K.name=k,K.value=E,q.appendChild(K);const R=!f&&t.instance?Z=>{t.instance.triggerOnChange(K.name,Z)}:null,G=Pt(e,E,K,f,R);return q.appendChild(G),C===-1?m.appendChild(q):m.insertBefore(q,m.children[C]),b(),q}function w(){if(f)return;const E=m.querySelectorAll(".multiple-switcher-item"),C=E.length;E.forEach(x=>{let k=x.querySelector(".remove-item-btn");k||(k=document.createElement("button"),k.type="button",k.className="remove-item-btn px-2 py-1 rounded",k.style.cssText=`
98
+ `,i.length===1?p.style.borderRadius="var(--fb-border-radius)":s===0?(p.style.borderRadius="var(--fb-border-radius) 0 0 var(--fb-border-radius)",p.style.borderRightWidth="0"):s===i.length-1?p.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(p.style.borderRadius="0",p.style.borderRightWidth="0"),c.value===t?Xe(p):Ge(p),r||(p.addEventListener("click",()=>{n.value=c.value,a.forEach(u=>{u.dataset.value===c.value?Xe(u):Ge(u)}),o&&o(c.value)}),p.addEventListener("mouseenter",()=>{n.value!==c.value&&(p.style.backgroundColor="var(--fb-background-hover-color)")}),p.addEventListener("mouseleave",()=>{n.value!==c.value&&(p.style.backgroundColor="transparent")})),a.push(p),l.appendChild(p)}),l}function kr(e,t,n,r){var o,i;const l=t.state,a=String((i=(o=t.prefill[e.key])!=null?o:e.default)!=null?i:""),c=document.createElement("input");c.type="hidden",c.name=r,c.value=a;const s=le(e,l,t),p=!s&&t.instance?f=>{t.instance.triggerOnChange(r,f)}:null,u=Kt(e,a,c,s,p);if(n.appendChild(c),n.appendChild(u),!s){const f=document.createElement("p");f.className="text-xs text-gray-500 mt-1",f.textContent=be(e,l),n.appendChild(f)}}function $r(e,t,n,r){var o,i,l,a;const c=t.state,s=t.prefill[e.key]||[],p=Array.isArray(s)?[...s]:[],u=(o=e.minCount)!=null?o:1,f=(i=e.maxCount)!=null?i:1/0;for(;p.length<u;)p.push(e.default||((a=(l=e.options)==null?void 0:l[0])==null?void 0:a.value)||"");const d=le(e,c,t),m=document.createElement("div");m.className="space-y-2",n.appendChild(m);function v(){m.querySelectorAll(".multiple-switcher-item").forEach((E,w)=>{const x=E.querySelector("input[type=hidden]");x&&(x.name=`${r}[${w}]`)})}function y(E="",w=-1){const x=w===-1?m.children.length:w,k=`${r}[${x}]`,I=document.createElement("div");I.className="multiple-switcher-item flex items-center gap-2";const K=document.createElement("input");K.type="hidden",K.name=k,K.value=E,I.appendChild(K);const R=!d&&t.instance?X=>{t.instance.triggerOnChange(K.name,X)}:null,J=Kt(e,E,K,d,R);return I.appendChild(J),w===-1?m.appendChild(I):m.insertBefore(I,m.children[w]),v(),I}function C(){if(d)return;const E=m.querySelectorAll(".multiple-switcher-item"),w=E.length;E.forEach(x=>{let k=x.querySelector(".remove-item-btn");k||(k=document.createElement("button"),k.type="button",k.className="remove-item-btn px-2 py-1 rounded",k.style.cssText=`
99
99
  color: var(--fb-error-color);
100
100
  background-color: transparent;
101
101
  transition: background-color var(--fb-transition-duration);
102
- `,k.innerHTML="\u2715",k.addEventListener("mouseenter",()=>{k.style.backgroundColor="var(--fb-background-hover-color)"}),k.addEventListener("mouseleave",()=>{k.style.backgroundColor="transparent"}),k.onclick=()=>{const K=Array.from(m.children).indexOf(x);m.children.length>u&&(p.splice(K,1),x.remove(),b(),g(),w())},x.appendChild(k));const q=C<=u;k.disabled=q,k.style.opacity=q?"0.5":"1",k.style.pointerEvents=q?"none":"auto"})}let v=null,h=null;if(!f){v=document.createElement("div"),v.className="flex items-center gap-3 mt-2";const E=document.createElement("button");E.type="button",E.className="add-switcher-btn px-3 py-1 rounded",E.style.cssText=`
102
+ `,k.innerHTML="\u2715",k.addEventListener("mouseenter",()=>{k.style.backgroundColor="var(--fb-background-hover-color)"}),k.addEventListener("mouseleave",()=>{k.style.backgroundColor="transparent"}),k.onclick=()=>{const K=Array.from(m.children).indexOf(x);m.children.length>u&&(p.splice(K,1),x.remove(),v(),g(),C())},x.appendChild(k));const I=w<=u;k.disabled=I,k.style.opacity=I?"0.5":"1",k.style.pointerEvents=I?"none":"auto"})}let b=null,h=null;if(!d){b=document.createElement("div"),b.className="flex items-center gap-3 mt-2";const E=document.createElement("button");E.type="button",E.className="add-switcher-btn px-3 py-1 rounded",E.style.cssText=`
103
103
  color: var(--fb-primary-color);
104
104
  border: var(--fb-border-width) solid var(--fb-primary-color);
105
105
  background-color: transparent;
106
106
  font-size: var(--fb-font-size);
107
107
  transition: all var(--fb-transition-duration);
108
- `,E.textContent="+",E.addEventListener("mouseenter",()=>{E.style.backgroundColor="var(--fb-background-hover-color)"}),E.addEventListener("mouseleave",()=>{E.style.backgroundColor="transparent"}),E.onclick=()=>{var C,x;const k=e.default||((x=(C=e.options)==null?void 0:C[0])==null?void 0:x.value)||"";p.push(k),y(k),g(),w()},h=document.createElement("span"),h.className="text-sm text-gray-500",v.appendChild(E),v.appendChild(h),n.appendChild(v)}function g(){if(!v||!h)return;const E=v.querySelector(".add-switcher-btn");if(E){const C=p.length>=d;E.disabled=C,E.style.opacity=C?"0.5":"1",E.style.pointerEvents=C?"none":"auto"}h.textContent=`${p.length}/${d===1/0?"\u221E":d}`}if(p.forEach(E=>y(E)),g(),w(),!f){const E=document.createElement("p");E.className="text-xs text-gray-500 mt-1",E.textContent=ve(e,s),n.appendChild(E)}}function yr(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:l}=n,a=(p,u)=>{var d,f;if(!p)return;const m=`error-${p.getAttribute("name")||Math.random().toString(36).substring(7)}`;let b=document.getElementById(m);u?(p.classList.add("invalid"),p.title=u,b||(b=document.createElement("div"),b.id=m,b.className="error-message",b.style.cssText=`
108
+ `,E.textContent="+",E.addEventListener("mouseenter",()=>{E.style.backgroundColor="var(--fb-background-hover-color)"}),E.addEventListener("mouseleave",()=>{E.style.backgroundColor="transparent"}),E.onclick=()=>{var w,x;const k=e.default||((x=(w=e.options)==null?void 0:w[0])==null?void 0:x.value)||"";p.push(k),y(k),g(),C()},h=document.createElement("span"),h.className="text-sm text-gray-500",b.appendChild(E),b.appendChild(h),n.appendChild(b)}function g(){if(!b||!h)return;const E=b.querySelector(".add-switcher-btn");if(E){const w=p.length>=f;E.disabled=w,E.style.opacity=w?"0.5":"1",E.style.pointerEvents=w?"none":"auto"}h.textContent=`${p.length}/${f===1/0?"\u221E":f}`}if(p.forEach(E=>y(E)),g(),C(),!d){const E=document.createElement("p");E.className="text-xs text-gray-500 mt-1",E.textContent=be(e,c),n.appendChild(E)}}function Lr(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:l}=n,a=(p,u)=>{var f,d;if(!p)return;const m=`error-${p.getAttribute("name")||Math.random().toString(36).substring(7)}`;let v=document.getElementById(m);u?(p.classList.add("invalid"),p.title=u,v||(v=document.createElement("div"),v.id=m,v.className="error-message",v.style.cssText=`
109
109
  color: var(--fb-error-color);
110
110
  font-size: var(--fb-font-size-small);
111
111
  margin-top: 0.25rem;
112
- `,p.nextSibling?(d=p.parentNode)==null||d.insertBefore(b,p.nextSibling):(f=p.parentNode)==null||f.appendChild(b)),b.textContent=u,b.style.display="block"):(p.classList.remove("invalid"),p.title="",b&&b.remove())},s=(p,u,d,f)=>{var m,b;if(l)return;const{state:y}=n,w=u.filter(f),v="minCount"in d&&(m=d.minCount)!=null?m:1,h="maxCount"in d&&(b=d.maxCount)!=null?b:1/0;d.required&&w.length===0&&o.push(`${p}: ${$("required",y)}`),w.length<v&&o.push(`${p}: ${$("minItems",y,{min:v})}`),w.length>h&&o.push(`${p}: ${$("maxItems",y,{max:h})}`)},c=new Set("options"in e?e.options.map(p=>p.value):[]);if("multiple"in e&&e.multiple){const p=i.querySelectorAll(`input[type="hidden"][name^="${t}["]`),u=[];return p.forEach(d=>{var f;const m=(f=d==null?void 0:d.value)!=null?f:"";if(u.push(m),!l&&m!==""&&!c.has(m)){const b=$("invalidOption",n.state);a(d,b),o.push(`${t}: ${b}`)}else a(d,null)}),s(t,u,e,d=>d!==""),{value:u,errors:o}}else{const p=i.querySelector(`input[type="hidden"][name$="${t}"]`),u=(r=p==null?void 0:p.value)!=null?r:"";if(!l&&e.required&&u===""){const d=$("required",n.state);return o.push(`${t}: ${d}`),a(p,d),{value:null,errors:o}}if(!l&&u!==""&&!c.has(u)){const d=$("invalidOption",n.state);return o.push(`${t}: ${d}`),a(p,d),{value:null,errors:o}}return a(p,null),{value:u===""?null:u,errors:o}}}function xr(e,t,n,r){var o;const{scopeRoot:i}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSwitcherField: Expected array for multiple field "${t}", got ${typeof n}`);return}const l=i.querySelectorAll(`input[type="hidden"][name^="${t}["]`);l.forEach((a,s)=>{var c;if(s<n.length){const p=n[s]!=null?String(n[s]):"";a.value=p;const u=(c=a.parentElement)==null?void 0:c.querySelector(".fb-switcher-group");u&&u.querySelectorAll(".fb-switcher-btn").forEach(d=>{d.dataset.value===p?Ye(d):Xe(d)}),a.classList.remove("invalid"),a.title=""}}),n.length!==l.length&&console.warn(`updateSwitcherField: Multiple field "${t}" has ${l.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const l=i.querySelector(`input[type="hidden"][name="${t}"]`);if(l){const a=n!=null?String(n):"";l.value=a;const s=(o=l.parentElement)==null?void 0:o.querySelector(".fb-switcher-group");s&&s.querySelectorAll(".fb-switcher-btn").forEach(c=>{c.dataset.value===a?Ye(c):Xe(c)}),l.classList.remove("invalid"),l.title=""}}}function ke(e){return e?typeof e=="object"&&Array.isArray(e.extensions)?e.extensions.map(t=>t.toLowerCase()):typeof e=="string"?e.split(",").map(t=>t.trim()).filter(t=>t.startsWith(".")).map(t=>t.substring(1).toLowerCase()):[]:[]}function ze(e,t){var n,r;if(t.length===0)return!0;const o=(r=(n=e.split(".").pop())==null?void 0:n.toLowerCase())!=null?r:"";return t.includes(o)}function Vt(e,t){return t===1/0?!0:e<=t*1024*1024}function Ge(e,t){return Vt(e.size,t)}function qe(e){return e?typeof e=="string"?[]:Array.isArray(e.mime)?e.mime.map(t=>t.toLowerCase()):[]:[]}function Oe(e,t){if(t.length===0)return!0;const n=e.toLowerCase();return t.some(r=>{if(r.endsWith("/*")){const o=r.slice(0,-1);return n.startsWith(o)}return n===r})}function Er(e){var t;const n=(t=(e.split("/").pop()||"file").split(".").pop())==null?void 0:t.toLowerCase();if(n){if(["jpg","jpeg","png","gif","webp"].includes(n))return`image/${n==="jpg"?"jpeg":n}`;if(["mp4","webm","mov","avi"].includes(n))return`video/${n==="mov"?"quicktime":n}`}return"application/octet-stream"}function Ze(e,t){if(t.has(e))return;const n=e.split("/").pop()||"file";t.set(e,{name:n,type:Er(e),size:0,uploadedAt:new Date,file:void 0,inferredFromExtension:!0})}function Qe(e,t){for(const n of e)Ze(n,t)}const Wt="fb-file-styles";function et(){if(typeof document=="undefined"||document.getElementById(Wt))return;const e=document.createElement("style");e.id=Wt,e.setAttribute("data-fb-file-styles","true"),e.textContent=`
112
+ `,p.nextSibling?(f=p.parentNode)==null||f.insertBefore(v,p.nextSibling):(d=p.parentNode)==null||d.appendChild(v)),v.textContent=u,v.style.display="block"):(p.classList.remove("invalid"),p.title="",v&&v.remove())},c=(p,u,f,d)=>{var m,v;if(l)return;const{state:y}=n,C=u.filter(d),b="minCount"in f&&(m=f.minCount)!=null?m:1,h="maxCount"in f&&(v=f.maxCount)!=null?v:1/0;f.required&&C.length===0&&o.push(`${p}: ${$("required",y)}`),C.length<b&&o.push(`${p}: ${$("minItems",y,{min:b})}`),C.length>h&&o.push(`${p}: ${$("maxItems",y,{max:h})}`)},s=new Set("options"in e?e.options.map(p=>p.value):[]);if("multiple"in e&&e.multiple){const p=i.querySelectorAll(`input[type="hidden"][name^="${t}["]`),u=[];return p.forEach(f=>{var d;const m=(d=f==null?void 0:f.value)!=null?d:"";if(u.push(m),!l&&m!==""&&!s.has(m)){const v=$("invalidOption",n.state);a(f,v),o.push(`${t}: ${v}`)}else a(f,null)}),c(t,u,e,f=>f!==""),{value:u,errors:o}}else{const p=i.querySelector(`input[type="hidden"][name$="${t}"]`),u=(r=p==null?void 0:p.value)!=null?r:"";if(!l&&e.required&&u===""){const f=$("required",n.state);return o.push(`${t}: ${f}`),a(p,f),{value:null,errors:o}}if(!l&&u!==""&&!s.has(u)){const f=$("invalidOption",n.state);return o.push(`${t}: ${f}`),a(p,f),{value:null,errors:o}}return a(p,null),{value:u===""?null:u,errors:o}}}function Sr(e,t,n,r){var o;const{scopeRoot:i}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSwitcherField: Expected array for multiple field "${t}", got ${typeof n}`);return}const l=i.querySelectorAll(`input[type="hidden"][name^="${t}["]`);l.forEach((a,c)=>{var s;if(c<n.length){const p=n[c]!=null?String(n[c]):"";a.value=p;const u=(s=a.parentElement)==null?void 0:s.querySelector(".fb-switcher-group");u&&u.querySelectorAll(".fb-switcher-btn").forEach(f=>{f.dataset.value===p?Xe(f):Ge(f)}),a.classList.remove("invalid"),a.title=""}}),n.length!==l.length&&console.warn(`updateSwitcherField: Multiple field "${t}" has ${l.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const l=i.querySelector(`input[type="hidden"][name="${t}"]`);if(l){const a=n!=null?String(n):"";l.value=a;const c=(o=l.parentElement)==null?void 0:o.querySelector(".fb-switcher-group");c&&c.querySelectorAll(".fb-switcher-btn").forEach(s=>{s.dataset.value===a?Xe(s):Ge(s)}),l.classList.remove("invalid"),l.title=""}}}function ke(e){return e?typeof e=="object"&&Array.isArray(e.extensions)?e.extensions.map(t=>t.toLowerCase()):typeof e=="string"?e.split(",").map(t=>t.trim()).filter(t=>t.startsWith(".")).map(t=>t.substring(1).toLowerCase()):[]:[]}function Ne(e,t){var n,r;if(t.length===0)return!0;const o=(r=(n=e.split(".").pop())==null?void 0:n.toLowerCase())!=null?r:"";return t.includes(o)}function _t(e,t){return t===1/0?!0:e<=t*1024*1024}function Ze(e,t){return _t(e.size,t)}function Ie(e){return e?typeof e=="string"?[]:Array.isArray(e.mime)?e.mime.map(t=>t.toLowerCase()):[]:[]}function Oe(e,t){if(t.length===0)return!0;const n=e.toLowerCase();return t.some(r=>{if(r.endsWith("/*")){const o=r.slice(0,-1);return n.startsWith(o)}return n===r})}function Tr(e){var t;const n=(t=(e.split("/").pop()||"file").split(".").pop())==null?void 0:t.toLowerCase();if(n){if(["jpg","jpeg","png","gif","webp"].includes(n))return`image/${n==="jpg"?"jpeg":n}`;if(["mp4","webm","mov","avi"].includes(n))return`video/${n==="mov"?"quicktime":n}`}return"application/octet-stream"}function Qe(e,t){if(t.has(e))return;const n=e.split("/").pop()||"file";t.set(e,{name:n,type:Tr(e),size:0,uploadedAt:new Date,file:void 0,inferredFromExtension:!0})}function et(e,t){for(const n of e)Qe(n,t)}const Jt="fb-file-styles";function tt(){if(typeof document=="undefined"||document.getElementById(Jt))return;const e=document.createElement("style");e.id=Jt,e.setAttribute("data-fb-file-styles","true"),e.textContent=`
113
113
  @keyframes fb-spin { to { transform: rotate(360deg); } }
114
114
 
115
115
  /* Spinner used during single-file and multi-file upload */
@@ -478,109 +478,109 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
478
478
  background: var(--fb-file-upload-bg-color, #f3f4f6);
479
479
  border-radius: calc(var(--fb-border-radius, 0.5rem) - 2px);
480
480
  }
481
- `,document.head.appendChild(e)}const tt="160px";function bt(){et();const e=document.createElement("div");return e.className="fb-tile",e}function Ee(e,t){var n,r;const o=(n=e.closest(".space-y-2"))==null?void 0:n.querySelector(".file-error-message");o&&o.remove();const i=document.createElement("div");i.className="file-error-message error-message",i.style.cssText=`
481
+ `,document.head.appendChild(e)}const nt="160px";function yt(){tt();const e=document.createElement("div");return e.className="fb-tile",e}function Ee(e,t){var n,r;const o=(n=e.closest(".space-y-2"))==null?void 0:n.querySelector(".file-error-message");o&&o.remove();const i=document.createElement("div");i.className="file-error-message error-message",i.style.cssText=`
482
482
  color: var(--fb-error-color);
483
483
  font-size: var(--fb-font-size-small);
484
484
  margin-top: 0.25rem;
485
- `,i.textContent=t,(r=e.closest(".space-y-2"))==null||r.appendChild(i)}function Ue(e){var t;const n=(t=e.closest(".space-y-2"))==null?void 0:t.querySelector(".file-error-message");n&&n.remove()}function Cr(e,t,n){const r=e.querySelector(".delete-overlay");r&&r.remove();const o=document.createElement("div");o.className="delete-overlay absolute inset-0 bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center";const i=document.createElement("button");i.className="bg-red-600 text-white px-3 py-1 rounded text-sm hover:bg-red-700 transition-colors",i.textContent=$("removeElement",t),i.onclick=l=>{l.stopPropagation(),n()},o.appendChild(i),e.appendChild(o)}function wr(e){var t;let n=e.parentElement;for(;n&&!n.dataset.filesWrapper;)n=n.parentElement;return(t=n==null?void 0:n.querySelector('input[type="file"]'))!=null?t:null}function kr(e,t){et();const n=bt();n.classList.add("fb-tile-uploading"),n.className+=" fb-uploading-tile";const r=e.length>10?e.substring(0,8)+"\u2026":e;return n.innerHTML=`
485
+ `,i.textContent=t,(r=e.closest(".space-y-2"))==null||r.appendChild(i)}function Ue(e){var t;const n=(t=e.closest(".space-y-2"))==null?void 0:t.querySelector(".file-error-message");n&&n.remove()}function Ar(e,t,n){const r=e.querySelector(".delete-overlay");r&&r.remove();const o=document.createElement("div");o.className="delete-overlay absolute inset-0 bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center";const i=document.createElement("button");i.className="bg-red-600 text-white px-3 py-1 rounded text-sm hover:bg-red-700 transition-colors",i.textContent=$("removeElement",t),i.onclick=l=>{l.stopPropagation(),n()},o.appendChild(i),e.appendChild(o)}function Fr(e){var t;let n=e.parentElement;for(;n&&!n.dataset.filesWrapper;)n=n.parentElement;return(t=n==null?void 0:n.querySelector('input[type="file"]'))!=null?t:null}function Mr(e,t){tt();const n=yt();n.classList.add("fb-tile-uploading"),n.className+=" fb-uploading-tile";const r=e.length>10?e.substring(0,8)+"\u2026":e;return n.innerHTML=`
486
486
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:4px;">
487
487
  <div class="fb-spinner"></div>
488
- <div class="fb-tile-label">${re(r)}</div>
489
- <div class="fb-tile-uploading-text">${re($("uploadingFile",t))}</div>
490
- </div>`,n}function $r(e){const t=e.querySelector(".fb-tiles-wrap");if(t)return t;const n=e.querySelector(".fb-file-dropzone");n&&n.remove();const r=document.createElement("div");r.className="fb-tiles-wrap",r.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";const o=document.createElement("div");return o.className="fb-tile fb-tile-add",o.innerHTML="+",r.appendChild(o),e.appendChild(r),r}function nt(e,t,n){const r=n?`<div class="text-xs text-gray-500 mt-1">${re(n)}</div>`:"";e.innerHTML=`
488
+ <div class="fb-tile-label">${oe(r)}</div>
489
+ <div class="fb-tile-uploading-text">${oe($("uploadingFile",t))}</div>
490
+ </div>`,n}function zr(e){const t=e.querySelector(".fb-tiles-wrap");if(t)return t;const n=e.querySelector(".fb-file-dropzone");n&&n.remove();const r=document.createElement("div");r.className="fb-tiles-wrap",r.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";const o=document.createElement("div");return o.className="fb-tile fb-tile-add",o.innerHTML="+",r.appendChild(o),e.appendChild(r),r}function rt(e,t,n){const r=n?`<div class="text-xs text-gray-500 mt-1">${oe(n)}</div>`:"";e.innerHTML=`
491
491
  <div class="flex flex-col items-center justify-center h-full text-gray-400">
492
492
  <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
493
493
  <path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/>
494
494
  </svg>
495
- <div class="text-sm text-center">${re($("clickDragText",t))}</div>
495
+ <div class="text-sm text-center">${oe($("clickDragText",t))}</div>
496
496
  ${r}
497
497
  </div>
498
- `}const Kt=new WeakMap;function Pe(e,t){const n=Kt.get(e);n&&(e.removeEventListener("dragover",n.dragover),e.removeEventListener("dragleave",n.dragleave),e.removeEventListener("drop",n.drop));const r=l=>{l.preventDefault(),e.classList.add("border-blue-500","bg-blue-50")},o=l=>{l.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50")},i=l=>{var a;l.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50");const s=(a=l.dataTransfer)==null?void 0:a.files;s&&t(s)};e.addEventListener("dragover",r),e.addEventListener("dragleave",o),e.addEventListener("drop",i),Kt.set(e,{dragover:r,dragleave:o,drop:i})}const Lr='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',Sr='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',Tr='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6"/><path d="M14 11v6"/><path d="M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"/></svg>';function Fr(e,t){return!!(e.config.downloadFile||e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function Ar(e,t){return!!(e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function _t(e){const{canRemove:t,removeHandler:n,state:r,resourceId:o,fileName:i,meta:l}=e,a=document.createElement("div");a.className="fb-tile-actions";const s=(c,p,u)=>{const d=document.createElement("button");return d.type="button",d.className=`fb-tile-action-btn ${u}`,d.innerHTML=c,d.title=p,d.setAttribute("aria-label",p),d.addEventListener("click",f=>{f.stopPropagation()}),d};if(Fr(r,l)){const c=s(Lr,$("downloadFile",r),"fb-tile-action-download");c.addEventListener("click",()=>{Mr(o,i,r,l)}),a.appendChild(c)}if(Ar(r,l)){const c=s(Sr,$("openInNewTab",r),"fb-tile-action-open");c.addEventListener("click",()=>{Nr(o,r,l).catch(p=>{console.error("Open failed:",p)})}),a.appendChild(c)}if(t&&n){const c=s(Tr,$("removeElement",r),"fb-tile-action-remove");c.addEventListener("click",()=>{n()}),a.appendChild(c)}return a}const rt=new WeakMap;function Jt(e){let t=rt.get(e);return t||(t=URL.createObjectURL(e),rt.set(e,t)),t}function gt(e){if(!e)return;const t=rt.get(e);t&&(URL.revokeObjectURL(t),rt.delete(e))}function Mr(e,t,n,r){if(n.config.downloadFile){n.config.downloadFile(e,t);return}if((r==null?void 0:r.file)instanceof File){tn(r.file,t||r.file.name);return}en(e,t,n).catch(o=>{console.error("Download failed:",o)})}async function Nr(e,t,n){let r=null;t.config.getDownloadUrl?r=t.config.getDownloadUrl(e):t.config.getThumbnail?r=await t.config.getThumbnail(e):(n==null?void 0:n.file)instanceof File&&(r=Jt(n.file)),r&&window.open(r,"_blank")}let ge=null,$e=null,Fe=null,ot=null;function zr(){if(!ge){ge=document.createElement("div"),ge.className="fb-tile-zoom-preview";const e=document.createElement("img");e.className="fb-tile-zoom-preview-img",ge.appendChild(e),ge.addEventListener("mouseenter",Xt),ge.addEventListener("mouseleave",Yt)}return ge}function qr(e,t){const n=t.getBoundingClientRect(),r=350,o=6,i=8;let l;n.top-r-o>=i?l=n.top-r-o:n.bottom+o+r+i<=window.innerHeight?l=n.bottom+o:l=Math.max(i,Math.min(window.innerHeight-r-i,n.top));let a=n.left+n.width/2-r/2;a=Math.max(i,Math.min(window.innerWidth-r-i,a)),e.style.top=`${l}px`,e.style.left=`${a}px`}function Yt(){Fe!==null&&clearTimeout(Fe),Fe=setTimeout(()=>{Fe=null,Gt()},100)}function Xt(){Fe!==null&&(clearTimeout(Fe),Fe=null)}function Gt(){$e!==null&&(clearTimeout($e),$e=null),ge&&ge.parentNode&&(ge.classList.remove("fb-tile-zoom-preview--visible"),ge.parentNode.removeChild(ge)),ot=null}function yt(e,t,n,r){e.dataset.zoomSrc=t,e.dataset.zoomAlt=n,e.addEventListener("mouseenter",()=>{Xt(),ot!==e&&Gt(),ot=e,$e=setTimeout(()=>{$e=null;const o=zr(),i=o.querySelector(".fb-tile-actions");i&&i.remove();const l=o.querySelector(".fb-tile-zoom-preview-img");l.src=t,l.alt=n,r&&(o.appendChild(r.cloneNode(!0)),Ir(o.querySelector(".fb-tile-actions"),r)),o.style.pointerEvents="auto",qr(o,e),document.body.appendChild(o),o.getBoundingClientRect(),o.classList.add("fb-tile-zoom-preview--visible")},200)}),e.addEventListener("mouseleave",()=>{$e!==null?(clearTimeout($e),$e=null,ot=null):Yt()})}function Ir(e,t){const n=Array.from(t.querySelectorAll(".fb-tile-action-btn"));Array.from(e.querySelectorAll(".fb-tile-action-btn")).forEach((r,o)=>{const i=n[o];i&&r.addEventListener("click",l=>{l.stopPropagation(),i.click()})})}function Rr(e,t,n,r){const o=document.createElement("img");o.className="w-full h-full object-contain",o.style.background="var(--fb-file-upload-bg-color,#f3f4f6)",o.alt=n||$("previewAlt",r);const i=new FileReader;i.onload=l=>{var a;o.src=((a=l.target)==null?void 0:a.result)||""},i.readAsDataURL(t),e.appendChild(o)}function Hr(e,t){e.onclick=null;const n=e.cloneNode(!1);return e.parentNode&&e.parentNode.replaceChild(n,e),n}function Br(e,t,n,r,o,i){const l=URL.createObjectURL(t),a=Hr(e);return a.innerHTML=`
498
+ `}const Yt=new WeakMap;function Pe(e,t){const n=Yt.get(e);n&&(e.removeEventListener("dragover",n.dragover),e.removeEventListener("dragleave",n.dragleave),e.removeEventListener("drop",n.drop));const r=l=>{l.preventDefault(),e.classList.add("border-blue-500","bg-blue-50")},o=l=>{l.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50")},i=l=>{var a;l.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50");const c=(a=l.dataTransfer)==null?void 0:a.files;c&&t(c)};e.addEventListener("dragover",r),e.addEventListener("dragleave",o),e.addEventListener("drop",i),Yt.set(e,{dragover:r,dragleave:o,drop:i})}const Nr='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',Ir='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',qr='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6"/><path d="M14 11v6"/><path d="M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"/></svg>';function Rr(e,t){return!!(e.config.downloadFile||e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function Hr(e,t){return!!(e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function Xt(e){const{canRemove:t,removeHandler:n,state:r,resourceId:o,fileName:i,meta:l}=e,a=document.createElement("div");a.className="fb-tile-actions";const c=(s,p,u)=>{const f=document.createElement("button");return f.type="button",f.className=`fb-tile-action-btn ${u}`,f.innerHTML=s,f.title=p,f.setAttribute("aria-label",p),f.addEventListener("click",d=>{d.stopPropagation()}),f};if(Rr(r,l)){const s=c(Nr,$("downloadFile",r),"fb-tile-action-download");s.addEventListener("click",()=>{Br(o,i,r,l)}),a.appendChild(s)}if(Hr(r,l)){const s=c(Ir,$("openInNewTab",r),"fb-tile-action-open");s.addEventListener("click",()=>{Dr(o,r,l).catch(p=>{console.error("Open failed:",p)})}),a.appendChild(s)}if(t&&n){const s=c(qr,$("removeElement",r),"fb-tile-action-remove");s.addEventListener("click",()=>{n()}),a.appendChild(s)}return a}const ot=new WeakMap;function Gt(e){let t=ot.get(e);return t||(t=URL.createObjectURL(e),ot.set(e,t)),t}function xt(e){if(!e)return;const t=ot.get(e);t&&(URL.revokeObjectURL(t),ot.delete(e))}function Br(e,t,n,r){if(n.config.downloadFile){n.config.downloadFile(e,t);return}if((r==null?void 0:r.file)instanceof File){on(r.file,t||r.file.name);return}rn(e,t,n).catch(o=>{console.error("Download failed:",o)})}async function Dr(e,t,n){let r=null;t.config.getDownloadUrl?r=t.config.getDownloadUrl(e):t.config.getThumbnail?r=await t.config.getThumbnail(e):(n==null?void 0:n.file)instanceof File&&(r=Gt(n.file)),r&&window.open(r,"_blank")}let ge=null,$e=null,Ae=null,lt=null;function jr(){if(!ge){ge=document.createElement("div"),ge.className="fb-tile-zoom-preview";const e=document.createElement("img");e.className="fb-tile-zoom-preview-img",ge.appendChild(e),ge.addEventListener("mouseenter",Qt),ge.addEventListener("mouseleave",Zt)}return ge}function Or(e,t){const n=t.getBoundingClientRect(),r=350,o=6,i=8;let l;n.top-r-o>=i?l=n.top-r-o:n.bottom+o+r+i<=window.innerHeight?l=n.bottom+o:l=Math.max(i,Math.min(window.innerHeight-r-i,n.top));let a=n.left+n.width/2-r/2;a=Math.max(i,Math.min(window.innerWidth-r-i,a)),e.style.top=`${l}px`,e.style.left=`${a}px`}function Zt(){Ae!==null&&clearTimeout(Ae),Ae=setTimeout(()=>{Ae=null,en()},100)}function Qt(){Ae!==null&&(clearTimeout(Ae),Ae=null)}function en(){$e!==null&&(clearTimeout($e),$e=null),ge&&ge.parentNode&&(ge.classList.remove("fb-tile-zoom-preview--visible"),ge.parentNode.removeChild(ge)),lt=null}function Et(e,t,n,r){e.dataset.zoomSrc=t,e.dataset.zoomAlt=n,e.addEventListener("mouseenter",()=>{Qt(),lt!==e&&en(),lt=e,$e=setTimeout(()=>{$e=null;const o=jr(),i=o.querySelector(".fb-tile-actions");i&&i.remove();const l=o.querySelector(".fb-tile-zoom-preview-img");l.src=t,l.alt=n,r&&(o.appendChild(r.cloneNode(!0)),Ur(o.querySelector(".fb-tile-actions"),r)),o.style.pointerEvents="auto",Or(o,e),document.body.appendChild(o),o.getBoundingClientRect(),o.classList.add("fb-tile-zoom-preview--visible")},200)}),e.addEventListener("mouseleave",()=>{$e!==null?(clearTimeout($e),$e=null,lt=null):Zt()})}function Ur(e,t){const n=Array.from(t.querySelectorAll(".fb-tile-action-btn"));Array.from(e.querySelectorAll(".fb-tile-action-btn")).forEach((r,o)=>{const i=n[o];i&&r.addEventListener("click",l=>{l.stopPropagation(),i.click()})})}function Pr(e,t,n,r){const o=document.createElement("img");o.className="w-full h-full object-contain",o.style.background="var(--fb-file-upload-bg-color,#f3f4f6)",o.alt=n||$("previewAlt",r);const i=new FileReader;i.onload=l=>{var a;o.src=((a=l.target)==null?void 0:a.result)||""},i.readAsDataURL(t),e.appendChild(o)}function Vr(e,t){e.onclick=null;const n=e.cloneNode(!1);return e.parentNode&&e.parentNode.replaceChild(n,e),n}function Wr(e,t,n,r,o,i){const l=URL.createObjectURL(t),a=Vr(e);return a.innerHTML=`
499
499
  <div class="fb-video-preview-wrap">
500
500
  <video class="w-full h-full object-contain" controls preload="auto" muted src="${l}">
501
- ${re($("videoNotSupported",o))}
501
+ ${oe($("videoNotSupported",o))}
502
502
  </video>
503
503
  <div class="fb-video-btn-overlay">
504
504
  <button class="fb-video-btn fb-video-btn-delete delete-file-btn">
505
- ${re($("removeElement",o))}
505
+ ${oe($("removeElement",o))}
506
506
  </button>
507
507
  <button class="fb-video-btn fb-video-btn-change change-file-btn">
508
- ${re($("changeButton",o))}
508
+ ${oe($("changeButton",o))}
509
509
  </button>
510
510
  </div>
511
511
  </div>
512
- `,Dr(a,r,o,i),a}function Dr(e,t,n,r){const o=e.querySelector(".change-file-btn");o&&(o.onclick=l=>{var a;l.stopPropagation(),(a=r==null?void 0:r.picker)==null||a.click()});const i=e.querySelector(".delete-file-btn");i&&(i.onclick=l=>{l.stopPropagation(),jr(e,t,n,r)})}function jr(e,t,n,r){var o;n.resourceIndex.delete(t);const i=(o=e.parentElement)==null?void 0:o.querySelector('input[type="hidden"]');i&&(i.value=""),r!=null&&r.fileUploadHandler&&(e.onclick=r.fileUploadHandler),e.innerHTML=`
512
+ `,Kr(a,r,o,i),a}function Kr(e,t,n,r){const o=e.querySelector(".change-file-btn");o&&(o.onclick=l=>{var a;l.stopPropagation(),(a=r==null?void 0:r.picker)==null||a.click()});const i=e.querySelector(".delete-file-btn");i&&(i.onclick=l=>{l.stopPropagation(),_r(e,t,n,r)})}function _r(e,t,n,r){var o;n.resourceIndex.delete(t);const i=(o=e.parentElement)==null?void 0:o.querySelector('input[type="hidden"]');i&&(i.value=""),r!=null&&r.fileUploadHandler&&(e.onclick=r.fileUploadHandler),e.innerHTML=`
513
513
  <div class="flex flex-col items-center justify-center h-full text-gray-400">
514
514
  <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
515
515
  <path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/>
516
516
  </svg>
517
- <div class="text-sm text-center">${re($("clickDragText",n))}</div>
517
+ <div class="text-sm text-center">${oe($("clickDragText",n))}</div>
518
518
  </div>
519
- `,r!=null&&r.setupDrop&&r.setupDrop(e)}function Zt(e,t,n){Cr(e,n,()=>{var r;n.resourceIndex.delete(t);const o=(r=e.parentElement)==null?void 0:r.querySelector('input[type="hidden"]');o&&(o.value=""),e.innerHTML=`
519
+ `,r!=null&&r.setupDrop&&r.setupDrop(e)}function tn(e,t,n){Ar(e,n,()=>{var r;n.resourceIndex.delete(t);const o=(r=e.parentElement)==null?void 0:r.querySelector('input[type="hidden"]');o&&(o.value=""),e.innerHTML=`
520
520
  <div class="flex flex-col items-center justify-center h-full text-gray-400">
521
521
  <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
522
522
  <path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/>
523
523
  </svg>
524
- <div class="text-sm text-center">${re($("clickDragText",n))}</div>
524
+ <div class="text-sm text-center">${oe($("clickDragText",n))}</div>
525
525
  </div>
526
- `})}async function Or(e,t,n,r,o,i,l){var a,s,c;!t.file||!(t.file instanceof File)||((a=t.type)!=null&&a.startsWith("image/")?Rr(e,t.file,n,i):(s=t.type)!=null&&s.startsWith("video/")?e=Br(e,t.file,t.type,r,i,l):e.innerHTML=`<div class="flex flex-col items-center justify-center h-full text-gray-400"><div style="font-size:36px;" class="mb-2">\u{1F4C1}</div><div class="text-sm">${re(n)}</div></div>`,!o&&!((c=t.type)!=null&&c.startsWith("video/"))&&Zt(e,r,i))}function Ur(e,t,n){const r=document.createElement("video");r.className="w-full h-full object-contain",r.controls=!0,r.preload="metadata",r.muted=!0,r.src=t,r.appendChild(document.createTextNode($("videoNotSupported",n))),e.appendChild(r)}async function Pr(e,t,n,r,o){var i;if(!o.config.getThumbnail){nt(e,o);return}try{const l=await o.config.getThumbnail(t);if(l)if(be(e),(i=r==null?void 0:r.type)!=null&&i.startsWith("video/"))Ur(e,l,o);else{const a=document.createElement("img");a.className="w-full h-full object-contain",a.style.background="var(--fb-file-upload-bg-color,#f3f4f6)",a.alt=n||$("previewAlt",o),a.src=l,e.appendChild(a)}else nt(e,o)}catch(l){console.error("Failed to get thumbnail:",l),e.innerHTML=`
526
+ `})}async function Jr(e,t,n,r,o,i,l){var a,c,s;!t.file||!(t.file instanceof File)||((a=t.type)!=null&&a.startsWith("image/")?Pr(e,t.file,n,i):(c=t.type)!=null&&c.startsWith("video/")?e=Wr(e,t.file,t.type,r,i,l):e.innerHTML=`<div class="flex flex-col items-center justify-center h-full text-gray-400"><div style="font-size:36px;" class="mb-2">\u{1F4C1}</div><div class="text-sm">${oe(n)}</div></div>`,!o&&!((s=t.type)!=null&&s.startsWith("video/"))&&tn(e,r,i))}function Yr(e,t,n){const r=document.createElement("video");r.className="w-full h-full object-contain",r.controls=!0,r.preload="metadata",r.muted=!0,r.src=t,r.appendChild(document.createTextNode($("videoNotSupported",n))),e.appendChild(r)}async function Xr(e,t,n,r,o){var i;if(!o.config.getThumbnail){rt(e,o);return}try{const l=await o.config.getThumbnail(t);if(l)if(ve(e),(i=r==null?void 0:r.type)!=null&&i.startsWith("video/"))Yr(e,l,o);else{const a=document.createElement("img");a.className="w-full h-full object-contain",a.style.background="var(--fb-file-upload-bg-color,#f3f4f6)",a.alt=n||$("previewAlt",o),a.src=l,e.appendChild(a)}else rt(e,o)}catch(l){console.error("Failed to get thumbnail:",l),e.innerHTML=`
527
527
  <div class="flex flex-col items-center justify-center h-full text-gray-400">
528
528
  <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
529
529
  <path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/>
530
530
  </svg>
531
- <div class="text-sm text-center">${re(n||$("previewUnavailable",o))}</div>
531
+ <div class="text-sm text-center">${oe(n||$("previewUnavailable",o))}</div>
532
532
  </div>
533
- `}}async function Qt(e,t,n,r={}){var o;const{fileName:i="",isReadonly:l=!1,deps:a=null}=r;if(!l&&a&&(!a.picker||!a.fileUploadHandler||!a.dragHandler))throw new Error("renderFilePreview: missing deps {picker, fileUploadHandler, dragHandler}");be(e);const s=n.resourceIndex.get(t);if(s&&s.file&&s.file instanceof File)await Or(e,s,i,t,l,n,a);else{await Pr(e,t,i,s,n);const c=(o=s==null?void 0:s.type)==null?void 0:o.startsWith("video/");!l&&!c&&Zt(e,t,n)}}function Vr(e,t,n){var r;if(n)return n;if((r=t==null?void 0:t.name)!=null&&r.includes("."))return t.name;const o=e.includes("/")?e.split("/").pop():e;return o!=null&&o.includes(".")?o:""}async function xt(e,t,n,r={}){var o,i;const l=t.resourceIndex.get(e),a=Vr(e,l,n),{canRemove:s=!1,removeHandler:c=null}=r,p=((o=l==null?void 0:l.type)==null?void 0:o.startsWith("image/"))||!!a.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/),u=((i=l==null?void 0:l.type)==null?void 0:i.startsWith("video/"))||!!a.toLowerCase().match(/\.(mp4|webm|avi|mov)$/),d=bt();d.classList.add("fb-tile-resource"),d.style.cursor="pointer",a&&(d.title=a);const f=(l==null?void 0:l.file)instanceof File?Jt(l.file):null,m=async()=>t.config.getDownloadUrl?t.config.getDownloadUrl(e):t.config.getThumbnail?t.config.getThumbnail(e):f;d.onclick=async()=>{const v=await m();v?window.open(v,"_blank"):t.config.downloadFile?t.config.downloadFile(e,a):en(e,a,t).catch(h=>{console.error("Download failed:",h)})};const b=_t({canRemove:s,removeHandler:c,state:t,resourceId:e,fileName:a,meta:l}),y=async()=>{if(t.config.getThumbnail)try{const v=await t.config.getThumbnail(e);if(v)return v}catch(v){}return f},w=()=>{d.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>',d.appendChild(b)};if(p){const v=await y();if(v){const h=document.createElement("img");h.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",h.alt=a,h.src=v,d.appendChild(h),d.appendChild(b),yt(d,v,a,b)}else w()}else if(u)if(t.config.getThumbnail)try{const v=await t.config.getThumbnail(e);v?(d.innerHTML=`
534
- <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${re(a)}" src="${v}">
533
+ `}}async function nn(e,t,n,r={}){var o;const{fileName:i="",isReadonly:l=!1,deps:a=null}=r;if(!l&&a&&(!a.picker||!a.fileUploadHandler||!a.dragHandler))throw new Error("renderFilePreview: missing deps {picker, fileUploadHandler, dragHandler}");ve(e);const c=n.resourceIndex.get(t);if(c&&c.file&&c.file instanceof File)await Jr(e,c,i,t,l,n,a);else{await Xr(e,t,i,c,n);const s=(o=c==null?void 0:c.type)==null?void 0:o.startsWith("video/");!l&&!s&&tn(e,t,n)}}function Gr(e,t,n){var r;if(n)return n;if((r=t==null?void 0:t.name)!=null&&r.includes("."))return t.name;const o=e.includes("/")?e.split("/").pop():e;return o!=null&&o.includes(".")?o:""}async function wt(e,t,n,r={}){var o,i;const l=t.resourceIndex.get(e),a=Gr(e,l,n),{canRemove:c=!1,removeHandler:s=null}=r,p=((o=l==null?void 0:l.type)==null?void 0:o.startsWith("image/"))||!!a.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/),u=((i=l==null?void 0:l.type)==null?void 0:i.startsWith("video/"))||!!a.toLowerCase().match(/\.(mp4|webm|avi|mov)$/),f=yt();f.classList.add("fb-tile-resource"),f.style.cursor="pointer",a&&(f.title=a);const d=(l==null?void 0:l.file)instanceof File?Gt(l.file):null,m=async()=>t.config.getDownloadUrl?t.config.getDownloadUrl(e):t.config.getThumbnail?t.config.getThumbnail(e):d;f.onclick=async()=>{const b=await m();b?window.open(b,"_blank"):t.config.downloadFile?t.config.downloadFile(e,a):rn(e,a,t).catch(h=>{console.error("Download failed:",h)})};const v=Xt({canRemove:c,removeHandler:s,state:t,resourceId:e,fileName:a,meta:l}),y=async()=>{if(t.config.getThumbnail)try{const b=await t.config.getThumbnail(e);if(b)return b}catch(b){}return d},C=()=>{f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>',f.appendChild(v)};if(p){const b=await y();if(b){const h=document.createElement("img");h.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",h.alt=a,h.src=b,f.appendChild(h),f.appendChild(v),Et(f,b,a,v)}else C()}else if(u)if(t.config.getThumbnail)try{const b=await t.config.getThumbnail(e);b?(f.innerHTML=`
534
+ <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${oe(a)}" src="${b}">
535
535
  <div class="fb-video-overlay">
536
536
  <div class="fb-play-btn" style="width:22px;height:22px;">
537
537
  <svg width="10" height="12" viewBox="0 0 10 12" fill="currentColor"><path d="M0 0l10 6-10 6z"/></svg>
538
538
  </div>
539
- </div>`,d.appendChild(b)):(d.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',d.appendChild(b))}catch(v){d.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',d.appendChild(b)}else d.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',d.appendChild(b);else{if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);if(h){const g=document.createElement("img");return g.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",g.alt=a||e,g.src=h,d.appendChild(g),d.appendChild(b),d}}catch(h){}const v=a?`<div class="fb-tile-label">${re(a.length>10?a.substring(0,8)+"\u2026":a)}</div>
540
- <svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M19 9h-4V3H9v6H5l7 7 7-7zm-7 9H5v2h14v-2h-7z"/></svg>`:"";d.innerHTML=`
539
+ </div>`,f.appendChild(v)):(f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',f.appendChild(v))}catch(b){f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',f.appendChild(v)}else f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',f.appendChild(v);else{if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);if(h){const g=document.createElement("img");return g.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",g.alt=a||e,g.src=h,f.appendChild(g),f.appendChild(v),f}}catch(h){}const b=a?`<div class="fb-tile-label">${oe(a.length>10?a.substring(0,8)+"\u2026":a)}</div>
540
+ <svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M19 9h-4V3H9v6H5l7 7 7-7zm-7 9H5v2h14v-2h-7z"/></svg>`:"";f.innerHTML=`
541
541
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
542
542
  <div style="font-size:36px;">\u{1F4C1}</div>
543
- ${v}
544
- </div>`,d.appendChild(b)}return d}async function Et(e,t,n,r){var o,i,l;const a=n.resourceIndex.get(t),s=(i=(o=a==null?void 0:a.name)!=null?o:t.split("/").pop())!=null?i:"",c=(l=r.onRemove)!=null?l:null,p=await xt(t,n,s,{canRemove:!0,removeHandler:c});e.className="file-preview-container",e.removeAttribute("style"),be(e),e.appendChild(p)}async function Wr(e,t,n,r,o){var i,l,a;if((i=n==null?void 0:n.type)!=null&&i.startsWith("image/")){if(n.file&&n.file instanceof File){const s=document.createElement("img");s.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",s.alt=n.name;const c=new FileReader;c.onload=p=>{var u;s.src=((u=p.target)==null?void 0:u.result)||"",yt(e,s.src,n.name,o!=null?o:null)},c.readAsDataURL(n.file),e.appendChild(s)}else if(r.config.getThumbnail)try{const s=await r.config.getThumbnail(t);if(s){const c=document.createElement("img");c.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",c.alt=n.name,c.src=s,e.appendChild(c),yt(e,s,n.name,o!=null?o:null)}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>'}catch(s){const c=s instanceof Error?s:new Error(String(s));r.config.onThumbnailError&&r.config.onThumbnailError(c,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>';o&&e.appendChild(o)}else if((l=n==null?void 0:n.type)!=null&&l.startsWith("video/")){if(n.file&&n.file instanceof File){const s=URL.createObjectURL(n.file);e.innerHTML=`
545
- <video style="width:100%;height:100%;" preload="metadata" muted src="${s}"></video>
543
+ ${b}
544
+ </div>`,f.appendChild(v)}return f}async function Ct(e,t,n,r){var o,i,l;const a=n.resourceIndex.get(t),c=(i=(o=a==null?void 0:a.name)!=null?o:t.split("/").pop())!=null?i:"",s=(l=r.onRemove)!=null?l:null,p=await wt(t,n,c,{canRemove:!0,removeHandler:s});e.className="file-preview-container",e.removeAttribute("style"),ve(e),e.appendChild(p)}async function Zr(e,t,n,r,o){var i,l,a;if((i=n==null?void 0:n.type)!=null&&i.startsWith("image/")){if(n.file&&n.file instanceof File){const c=document.createElement("img");c.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",c.alt=n.name;const s=new FileReader;s.onload=p=>{var u;c.src=((u=p.target)==null?void 0:u.result)||"",Et(e,c.src,n.name,o!=null?o:null)},s.readAsDataURL(n.file),e.appendChild(c)}else if(r.config.getThumbnail)try{const c=await r.config.getThumbnail(t);if(c){const s=document.createElement("img");s.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",s.alt=n.name,s.src=c,e.appendChild(s),Et(e,c,n.name,o!=null?o:null)}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>'}catch(c){const s=c instanceof Error?c:new Error(String(c));r.config.onThumbnailError&&r.config.onThumbnailError(s,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>';o&&e.appendChild(o)}else if((l=n==null?void 0:n.type)!=null&&l.startsWith("video/")){if(n.file&&n.file instanceof File){const c=URL.createObjectURL(n.file);e.innerHTML=`
545
+ <video style="width:100%;height:100%;" preload="metadata" muted src="${c}"></video>
546
546
  <div class="fb-video-overlay">
547
547
  <div class="fb-play-btn" style="width:20px;height:20px;">
548
548
  <svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
549
549
  </div>
550
- </div>`}else if(r.config.getThumbnail)try{const s=await r.config.getThumbnail(t);s?e.innerHTML=`
551
- <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${re(n.name)}" src="${s}">
550
+ </div>`}else if(r.config.getThumbnail)try{const c=await r.config.getThumbnail(t);c?e.innerHTML=`
551
+ <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${oe(n.name)}" src="${c}">
552
552
  <div class="fb-video-overlay">
553
553
  <div class="fb-play-btn" style="width:20px;height:20px;">
554
554
  <svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
555
555
  </div>
556
- </div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(s){const c=s instanceof Error?s:new Error(String(s));r.config.onThumbnailError&&r.config.onThumbnailError(c,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>';o&&e.appendChild(o)}else{const s=(a=n==null?void 0:n.name)!=null?a:"",c=s.includes(".")?`<div class="fb-tile-label">${re(s.length>10?s.substring(0,8)+"\u2026":s)}</div>`:"";e.innerHTML=`
556
+ </div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(c){const s=c instanceof Error?c:new Error(String(c));r.config.onThumbnailError&&r.config.onThumbnailError(s,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>';o&&e.appendChild(o)}else{const c=(a=n==null?void 0:n.name)!=null?a:"",s=c.includes(".")?`<div class="fb-tile-label">${oe(c.length>10?c.substring(0,8)+"\u2026":c)}</div>`:"";e.innerHTML=`
557
557
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
558
558
  <div style="font-size:36px;">\u{1F4C1}</div>
559
- ${c}
560
- </div>`,o&&e.appendChild(o)}}async function en(e,t,n){try{let r=null;if(n.config.getDownloadUrl?r=n.config.getDownloadUrl(e):n.config.getThumbnail&&(r=await n.config.getThumbnail(e)),r){const o=r.startsWith("http")?r:new URL(r,window.location.href).href,i=await fetch(o);if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const l=await i.blob();tn(l,t)}else throw new Error("No download URL available for resource")}catch(r){const o=r instanceof Error?r:new Error(String(r));throw n.config.onDownloadError&&n.config.onDownloadError(o,e,t),console.error(`File download failed for ${t}:`,o),o}}function tn(e,t){try{const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>{URL.revokeObjectURL(n)},100)}catch(n){throw new Error(`Blob download failed: ${n.message}`)}}async function nn(e,t){if(!t.config.uploadFile)throw new Error("No upload handler configured. Set uploadHandler via FormBuilder.setUploadHandler()");try{const n=await t.config.uploadFile(e);if(typeof n!="string")throw new Error("Upload handler must return a string resource ID");return n}catch(n){const r=n instanceof Error?n:new Error(String(n));throw t.config.onUploadError&&t.config.onUploadError(r,e),new Error(`File upload failed: ${r.message}`)}}async function rn(e){var t,n;const{file:r,container:o,fieldName:i,state:l,deps:a=null,instance:s=null,allowedExtensions:c=[],allowedMimes:p=[],maxSizeMB:u=1/0}=e;if(!ze(r.name,c)){const m=c.join(", ");Ee(o,$("invalidFileExtension",l,{name:r.name,formats:m}));return}if(!Oe(r.type,p)){const m=p.join(", ");Ee(o,$("invalidFileMime",l,{name:r.name,type:r.type,mimes:m}));return}if(!Ge(r,u)){Ee(o,$("fileTooLarge",l,{name:r.name,maxSize:u}));return}Ue(o),et(),o.innerHTML=`
559
+ ${s}
560
+ </div>`,o&&e.appendChild(o)}}async function rn(e,t,n){try{let r=null;if(n.config.getDownloadUrl?r=n.config.getDownloadUrl(e):n.config.getThumbnail&&(r=await n.config.getThumbnail(e)),r){const o=r.startsWith("http")?r:new URL(r,window.location.href).href,i=await fetch(o);if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const l=await i.blob();on(l,t)}else throw new Error("No download URL available for resource")}catch(r){const o=r instanceof Error?r:new Error(String(r));throw n.config.onDownloadError&&n.config.onDownloadError(o,e,t),console.error(`File download failed for ${t}:`,o),o}}function on(e,t){try{const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>{URL.revokeObjectURL(n)},100)}catch(n){throw new Error(`Blob download failed: ${n.message}`)}}async function ln(e,t){if(!t.config.uploadFile)throw new Error("No upload handler configured. Set uploadHandler via FormBuilder.setUploadHandler()");try{const n=await t.config.uploadFile(e);if(typeof n!="string")throw new Error("Upload handler must return a string resource ID");return n}catch(n){const r=n instanceof Error?n:new Error(String(n));throw t.config.onUploadError&&t.config.onUploadError(r,e),new Error(`File upload failed: ${r.message}`)}}async function an(e){var t,n;const{file:r,container:o,fieldName:i,state:l,deps:a=null,instance:c=null,allowedExtensions:s=[],allowedMimes:p=[],maxSizeMB:u=1/0}=e;if(!Ne(r.name,s)){const m=s.join(", ");Ee(o,$("invalidFileExtension",l,{name:r.name,formats:m}));return}if(!Oe(r.type,p)){const m=p.join(", ");Ee(o,$("invalidFileMime",l,{name:r.name,type:r.type,mimes:m}));return}if(!Ze(r,u)){Ee(o,$("fileTooLarge",l,{name:r.name,maxSize:u}));return}Ue(o),tt(),o.innerHTML=`
561
561
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:6px;">
562
562
  <div class="fb-spinner"></div>
563
- <div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${re($("uploadingFile",l))}</div>
564
- </div>`;let d;try{d=await nn(r,l)}catch(m){throw nt(o,l),m}l.resourceIndex.set(d,{name:r.name,type:r.type,size:r.size,uploadedAt:new Date,file:r});let f=(t=o.parentElement)==null?void 0:t.querySelector('input[type="hidden"]');f||(f=document.createElement("input"),f.type="hidden",f.name=i,(n=o.parentElement)==null||n.appendChild(f)),f.value=d,!r.type.startsWith("video/")&&a?Et(o,d,l,a).catch(console.error):Qt(o,d,l,{fileName:r.name,isReadonly:!1,deps:a}).catch(console.error),s&&!l.config.readonly&&s.triggerOnChange(i,d)}function on(e,t,n,r){const o=e.filter(m=>!ze(m.name,n.allowedExtensions)),i=e.filter(m=>ze(m.name,n.allowedExtensions)),l=i.filter(m=>!Oe(m.type,n.allowedMimes)),a=i.filter(m=>Oe(m.type,n.allowedMimes)),s=a.filter(m=>!Ge(m,n.maxSize)),c=a.filter(m=>Ge(m,n.maxSize)),p=n.maxCount===1/0?c.length:Math.max(0,n.maxCount-t),u=c.slice(0,p),d=c.length-u.length,f=[];if(o.length>0){const m=n.allowedExtensions.join(", "),b=o.map(y=>y.name).join(", ");f.push($("invalidFileExtension",r,{name:b,formats:m}))}if(l.length>0){const m=n.allowedMimes.join(", "),b=l.map(y=>y.name).join(", ");f.push($("invalidFileMime",r,{name:b,type:l.map(y=>y.type).join(", "),mimes:m}))}if(s.length>0){const m=s.map(b=>b.name).join(", ");f.push($("fileTooLarge",r,{name:m,maxSize:n.maxSize}))}return d>0&&f.push($("filesLimitExceeded",r,{skipped:d,max:n.maxCount})),{accepted:u,errorMessage:f.join(" \u2022 ")}}async function ln(e,t,n,r){await Promise.all(e.map(async o=>{const i=kr(o.name,r);if(n){const l=$r(n),a=l.querySelector(".fb-tile-add");a?l.insertBefore(i,a):l.appendChild(i)}try{const l=await nn(o,r);r.resourceIndex.set(l,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:void 0}),t.push(l)}finally{i.remove()}}))}function an(e,t,n,r,o,i,l){Pe(e,async a=>{var s;const{accepted:c,errorMessage:p}=on(Array.from(a),t.length,o,n);p?Ee(e,p):Ue(e);const u=(s=e.querySelector(".files-list"))!=null?s:e;await ln(c,t,u,n),r(),l&&i&&!n.config.readonly&&l.triggerOnChange(i,t)})}function sn(e,t,n,r,o,i,l){e.onchange=async()=>{if(!e.files)return;const a=e.closest(".space-y-2")||e.parentElement,{accepted:s,errorMessage:c}=on(Array.from(e.files),t.length,o,n);c&&a?Ee(a,c):a&&Ue(a);const p=a==null?void 0:a.querySelector(".files-list");await ln(s,t,p!=null?p:null,n),r(),e.value="",l&&i&&!n.config.readonly&&l.triggerOnChange(i,t)}}function cn(e){var t,n;if(!e.accept)return;if(typeof e.accept=="string"){const a=ke(e.accept);return a.length>0?{extensions:a}:void 0}const r=(t=e.accept.extensions)!=null?t:[],o=(n=e.accept.mime)!=null?n:[],i=r.map(a=>a.toLowerCase());if(i.length===0&&o.length===0)return;const l={};return i.length>0&&(l.extensions=i),o.length>0&&(l.mime=o),l}function un(e,t,n,r,o){if(!ze(e.name,t)){const i=t.join(", ");return $("invalidFileExtension",o,{name:e.name,formats:i})}if(!Oe(e.type,n)){const i=n.join(", ");return $("invalidFileMime",o,{name:e.name,type:e.type,mimes:i})}return Vt(e.size,r)?null:$("fileTooLarge",o,{name:e.name,maxSize:r})}function Kr(e){const t=e.dataset.resourceIds;if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n:[]}catch(n){return[]}}function dn(e,t){var n;const r=t.resourceIndex.get(e.resourceId);t.resourceIndex.set(e.resourceId,{name:e.name,type:e.type,size:e.size,uploadedAt:(n=r==null?void 0:r.uploadedAt)!=null?n:new Date,file:r==null?void 0:r.file})}function fn(e,t){return e instanceof Error&&e.message?e.message:$("pickerError",t)}async function pn(e,t,n,r,o,i,l,a){var s;if(!e.config.pickExistingFiles)return;const c=ke(t.accept),p=qe(t.accept),u=(s=t.maxSize)!=null?s:1/0,d=Kr(n),f=i===1/0?1/0:Math.max(0,i-d.length);let m;try{m=await e.config.pickExistingFiles({fieldPath:r,mode:"multiple",accept:cn(t),maxSizeMB:u===1/0?void 0:u,remainingSlots:f===1/0?void 0:f,selectedResourceIds:[...d]})}catch(E){Ee(n,fn(E,e));return}if(m.length===0)return;const b=new Set(d),y=new Set,w=m.filter(E=>b.has(E.resourceId)||y.has(E.resourceId)?!1:(y.add(E.resourceId),!0)).filter(E=>un(E,c,p,u,e)===null),v=i===1/0?w.length:Math.max(0,i-o.length),h=w.slice(0,v),g=w.length-h.length;if(h.length!==0){Ue(n),g>0&&Ee(n,$("filesLimitExceeded",e,{skipped:g,max:i}));for(const E of h)dn(E,e),o.push(E.resourceId);n.dataset.resourceIds=JSON.stringify(o),l(),e.config.readonly||a.triggerOnChange(r,o)}}async function _r(e,t,n,r,o,i,l,a){var s;if(!e.config.pickExistingFiles)return;const c=ke(t.accept),p=qe(t.accept),u=(s=t.maxSize)!=null?s:1/0;let d;try{d=await e.config.pickExistingFiles({fieldPath:i,mode:"single",accept:cn(t),maxSizeMB:u===1/0?void 0:u,selectedResourceIds:[]})}catch(y){Ee(n,fn(y,e));return}if(d.length===0)return;const f=d[0],m=un(f,c,p,u,e);if(m!==null){Ee(n,m);return}Ue(n),dn(f,e);let b=r.querySelector('input[type="hidden"]');b||(b=document.createElement("input"),b.type="hidden",b.name=o,r.appendChild(b)),b.value=f.resourceId,await l(f.resourceId),e.config.readonly||a.triggerOnChange(i,f.resourceId)}function Jr(e,t,n,r,o,i){var l;Ze(e,o.resourceIndex);const a=o.resourceIndex.get(e);(l=a==null?void 0:a.type)!=null&&l.startsWith("video/")?Qt(t,e,o,{fileName:e,isReadonly:!1,deps:i}).catch(console.error):Et(t,e,o,i).catch(console.error);const s=document.createElement("input");s.type="hidden",s.name=n,s.value=e,r.appendChild(s)}const Yr=`<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" style="flex-shrink:0;color:var(--fb-file-upload-text-color,#9ca3af);">
563
+ <div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${oe($("uploadingFile",l))}</div>
564
+ </div>`;let f;try{f=await ln(r,l)}catch(m){throw rt(o,l),m}l.resourceIndex.set(f,{name:r.name,type:r.type,size:r.size,uploadedAt:new Date,file:r});let d=(t=o.parentElement)==null?void 0:t.querySelector('input[type="hidden"]');d||(d=document.createElement("input"),d.type="hidden",d.name=i,(n=o.parentElement)==null||n.appendChild(d)),d.value=f,!r.type.startsWith("video/")&&a?Ct(o,f,l,a).catch(console.error):nn(o,f,l,{fileName:r.name,isReadonly:!1,deps:a}).catch(console.error),c&&!l.config.readonly&&c.triggerOnChange(i,f)}function sn(e,t,n,r){const o=e.filter(m=>!Ne(m.name,n.allowedExtensions)),i=e.filter(m=>Ne(m.name,n.allowedExtensions)),l=i.filter(m=>!Oe(m.type,n.allowedMimes)),a=i.filter(m=>Oe(m.type,n.allowedMimes)),c=a.filter(m=>!Ze(m,n.maxSize)),s=a.filter(m=>Ze(m,n.maxSize)),p=n.maxCount===1/0?s.length:Math.max(0,n.maxCount-t),u=s.slice(0,p),f=s.length-u.length,d=[];if(o.length>0){const m=n.allowedExtensions.join(", "),v=o.map(y=>y.name).join(", ");d.push($("invalidFileExtension",r,{name:v,formats:m}))}if(l.length>0){const m=n.allowedMimes.join(", "),v=l.map(y=>y.name).join(", ");d.push($("invalidFileMime",r,{name:v,type:l.map(y=>y.type).join(", "),mimes:m}))}if(c.length>0){const m=c.map(v=>v.name).join(", ");d.push($("fileTooLarge",r,{name:m,maxSize:n.maxSize}))}return f>0&&d.push($("filesLimitExceeded",r,{skipped:f,max:n.maxCount})),{accepted:u,errorMessage:d.join(" \u2022 ")}}async function cn(e,t,n,r){await Promise.all(e.map(async o=>{const i=Mr(o.name,r);if(n){const l=zr(n),a=l.querySelector(".fb-tile-add");a?l.insertBefore(i,a):l.appendChild(i)}try{const l=await ln(o,r);r.resourceIndex.set(l,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:void 0}),t.push(l)}finally{i.remove()}}))}function un(e,t,n,r,o,i,l){Pe(e,async a=>{var c;const{accepted:s,errorMessage:p}=sn(Array.from(a),t.length,o,n);p?Ee(e,p):Ue(e);const u=(c=e.querySelector(".files-list"))!=null?c:e;await cn(s,t,u,n),r(),l&&i&&!n.config.readonly&&l.triggerOnChange(i,t)})}function dn(e,t,n,r,o,i,l){e.onchange=async()=>{if(!e.files)return;const a=e.closest(".space-y-2")||e.parentElement,{accepted:c,errorMessage:s}=sn(Array.from(e.files),t.length,o,n);s&&a?Ee(a,s):a&&Ue(a);const p=a==null?void 0:a.querySelector(".files-list");await cn(c,t,p!=null?p:null,n),r(),e.value="",l&&i&&!n.config.readonly&&l.triggerOnChange(i,t)}}function fn(e){var t,n;if(!e.accept)return;if(typeof e.accept=="string"){const a=ke(e.accept);return a.length>0?{extensions:a}:void 0}const r=(t=e.accept.extensions)!=null?t:[],o=(n=e.accept.mime)!=null?n:[],i=r.map(a=>a.toLowerCase());if(i.length===0&&o.length===0)return;const l={};return i.length>0&&(l.extensions=i),o.length>0&&(l.mime=o),l}function pn(e,t,n,r,o){if(!Ne(e.name,t)){const i=t.join(", ");return $("invalidFileExtension",o,{name:e.name,formats:i})}if(!Oe(e.type,n)){const i=n.join(", ");return $("invalidFileMime",o,{name:e.name,type:e.type,mimes:i})}return _t(e.size,r)?null:$("fileTooLarge",o,{name:e.name,maxSize:r})}function Qr(e){const t=e.dataset.resourceIds;if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n:[]}catch(n){return[]}}function mn(e,t){var n;const r=t.resourceIndex.get(e.resourceId);t.resourceIndex.set(e.resourceId,{name:e.name,type:e.type,size:e.size,uploadedAt:(n=r==null?void 0:r.uploadedAt)!=null?n:new Date,file:r==null?void 0:r.file})}function hn(e,t){return e instanceof Error&&e.message?e.message:$("pickerError",t)}async function bn(e,t,n,r,o,i,l,a){var c;if(!e.config.pickExistingFiles)return;const s=ke(t.accept),p=Ie(t.accept),u=(c=t.maxSize)!=null?c:1/0,f=Qr(n),d=i===1/0?1/0:Math.max(0,i-f.length);let m;try{m=await e.config.pickExistingFiles({fieldPath:r,mode:"multiple",accept:fn(t),maxSizeMB:u===1/0?void 0:u,remainingSlots:d===1/0?void 0:d,selectedResourceIds:[...f]})}catch(E){Ee(n,hn(E,e));return}if(m.length===0)return;const v=new Set(f),y=new Set,C=m.filter(E=>v.has(E.resourceId)||y.has(E.resourceId)?!1:(y.add(E.resourceId),!0)).filter(E=>pn(E,s,p,u,e)===null),b=i===1/0?C.length:Math.max(0,i-o.length),h=C.slice(0,b),g=C.length-h.length;if(h.length!==0){Ue(n),g>0&&Ee(n,$("filesLimitExceeded",e,{skipped:g,max:i}));for(const E of h)mn(E,e),o.push(E.resourceId);n.dataset.resourceIds=JSON.stringify(o),l(),e.config.readonly||a.triggerOnChange(r,o)}}async function eo(e,t,n,r,o,i,l,a){var c;if(!e.config.pickExistingFiles)return;const s=ke(t.accept),p=Ie(t.accept),u=(c=t.maxSize)!=null?c:1/0;let f;try{f=await e.config.pickExistingFiles({fieldPath:i,mode:"single",accept:fn(t),maxSizeMB:u===1/0?void 0:u,selectedResourceIds:[]})}catch(y){Ee(n,hn(y,e));return}if(f.length===0)return;const d=f[0],m=pn(d,s,p,u,e);if(m!==null){Ee(n,m);return}Ue(n),mn(d,e);let v=r.querySelector('input[type="hidden"]');v||(v=document.createElement("input"),v.type="hidden",v.name=o,r.appendChild(v)),v.value=d.resourceId,await l(d.resourceId),e.config.readonly||a.triggerOnChange(i,d.resourceId)}function to(e,t,n,r,o,i){var l;Qe(e,o.resourceIndex);const a=o.resourceIndex.get(e);(l=a==null?void 0:a.type)!=null&&l.startsWith("video/")?nn(t,e,o,{fileName:e,isReadonly:!1,deps:i}).catch(console.error):Ct(t,e,o,i).catch(console.error);const c=document.createElement("input");c.type="hidden",c.name=n,c.value=e,r.appendChild(c)}const no=`<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" style="flex-shrink:0;color:var(--fb-file-upload-text-color,#9ca3af);">
565
565
  <path d="M19.35 10.04A7.49 7.49 0 0012 4C9.11 4 6.6 5.64 5.35 8.04A5.994 5.994 0 000 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"/>
566
- </svg>`;function Ct(e,t,n,r){const o=document.createElement("div");return o.className="fb-file-dropzone",o.innerHTML=`
567
- ${Yr}
568
- <div class="fb-dropzone-primary-text">${re(t)}</div>
569
- ${n?`<div class="fb-dropzone-hint-text">${re(n)}</div>`:""}
570
- `,o.onclick=r,o}function wt(e,t,n){const r=document.createElement("button");return r.type="button",r.className=e==="card"?"fb-file-library-card":"fb-tile fb-tile-add-library",e==="card"?r.innerHTML=`
566
+ </svg>`;function kt(e,t,n,r){const o=document.createElement("div");return o.className="fb-file-dropzone",o.innerHTML=`
567
+ ${no}
568
+ <div class="fb-dropzone-primary-text">${oe(t)}</div>
569
+ ${n?`<div class="fb-dropzone-hint-text">${oe(n)}</div>`:""}
570
+ `,o.onclick=r,o}function $t(e,t,n){const r=document.createElement("button");return r.type="button",r.className=e==="card"?"fb-file-library-card":"fb-tile fb-tile-add-library",e==="card"?r.innerHTML=`
571
571
  <span class="fb-file-library-card-icon" aria-hidden="true">\u{1F4DA}</span>
572
- <span class="fb-file-library-card-label">${re($("fromLibrary",t))}</span>
573
- <span class="fb-file-library-card-hint">${re($("libraryHint",t))}</span>
574
- `:(r.innerHTML='<span aria-hidden="true">\u{1F4DA}</span>',r.title=$("fromLibrary",t),r.setAttribute("aria-label",$("fromLibrary",t))),r.addEventListener("click",n),r}function mn(e){var t;const{container:n,rids:r,state:o,onRemove:i,hint:l,countInfo:a,maxCount:s,isReadonly:c=!1,onLibraryPick:p}=e;et();const u=n.closest("[data-files-wrapper]");for(u&&(u.dataset.resourceIds=JSON.stringify(r!=null?r:[]));n.firstChild;)n.removeChild(n.firstChild);const d=r!=null?r:[],f=s!==void 0&&d.length>=s,m=!c&&typeof p=="function",b=()=>{const h=[];return l&&h.push(l),a&&h.push(a),h.join(" \u2022 ")},y=()=>{const h=wr(n);h&&h.click()};if(d.length===0){if(c){const h=document.createElement("div");h.className="fb-tile-empty-text",h.textContent=$("noFilesSelected",o),n.appendChild(h)}else if(m){const h=document.createElement("div");h.className="fb-file-card-row";const g=Ct(o,$("clickDragTextMultiple",o),b(),y),E=wt("card",o,p);h.appendChild(g),h.appendChild(E),n.appendChild(h)}else{const h=Ct(o,$("clickDragTextMultiple",o),b(),y);n.appendChild(h)}return}const w=document.createElement("div");w.className="fb-tiles-wrap",w.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";for(const h of d){const g=o.resourceIndex.get(h),E=bt();E.classList.add("fb-tile-resource","resource-pill"),E.dataset.resourceId=h;const C=_t({canRemove:!c&&i!==null,removeHandler:i?()=>i(h):null,state:o,resourceId:h,fileName:(t=g==null?void 0:g.name)!=null?t:""});Wr(E,h,g,o,C).catch(x=>{console.error("Failed to render tile:",x)}),w.appendChild(E)}if(!c&&!f){const h=document.createElement("div");if(h.className="fb-tile fb-tile-add",h.innerHTML="+",h.onclick=y,w.appendChild(h),m){const g=wt("tile",o,p);w.appendChild(g)}}else if(!c&&f){const h=document.createElement("div");h.className="fb-tile-counter",h.textContent=$("filesCounter",o,{count:d.length,max:s}),w.appendChild(h)}n.appendChild(w);const v=b();if(v){const h=document.createElement("div");h.className="fb-tile-hint",h.textContent=v,n.appendChild(h)}}function Xr(e,t,n,r){var o,i,l,a,s;const c=t.state,p=document.createElement("div");p.className="space-y-2";const u=document.createElement("input");u.type="file",u.name=r,u.style.display="none",e.accept&&(u.accept=typeof e.accept=="string"?e.accept:[...(i=(o=e.accept.extensions)==null?void 0:o.map(g=>`.${g}`))!=null?i:[],...(l=e.accept.mime)!=null?l:[]].join(",")||"");const d=document.createElement("div");d.className="file-preview-container";const f=t.prefill[e.key],m=ke(e.accept),b=qe(e.accept),y=(a=e.maxSize)!=null?a:1/0,w={fileUploadHandler(){u.click()},dragHandler(g){g.length>0&&rn({file:g[0],container:d,fieldName:r,state:c,deps:v(),instance:t.instance,allowedExtensions:m,allowedMimes:b,maxSizeMB:y})},setupDrop(g){Pe(g,w.dragHandler)},restoreDropzone(){const g=ve(e,c);d.className="file-preview-container w-full max-w-md bg-gray-100 rounded-lg overflow-hidden relative group cursor-pointer",d.style.height="128px",nt(d,c,g),d.onclick=w.fileUploadHandler,Pe(d,w.dragHandler)},onRemove(){var g;const E=p.querySelector('input[type="hidden"]'),C=E==null?void 0:E.value;C&&gt((g=c.resourceIndex.get(C))==null?void 0:g.file),E&&(E.value=""),h()}},v=()=>({picker:u,fileUploadHandler:w.fileUploadHandler,dragHandler:w.dragHandler,setupDrop:w.setupDrop,onRemove:w.onRemove}),h=()=>{if(c.config.pickExistingFiles&&!e.disableLibrary){for(d.className="file-preview-container",d.removeAttribute("style"),d.onclick=null;d.firstChild;)d.removeChild(d.firstChild);const g=document.createElement("div");g.className="fb-file-card-row",g.style.cssText="display:flex;gap:8px;align-items:stretch;";const E=ve(e,c),C=Ct(c,$("clickDragText",c),E,w.fileUploadHandler);C.style.cssText="flex:1;min-width:0;height:128px;",Pe(C,w.dragHandler);const x=wt("card",c,()=>{_r(c,e,d,p,r,r,async k=>{await Et(d,k,c,v())},t.instance).catch(k=>{console.error("Library pick failed:",k)})});x.style.cssText="flex:1;min-width:0;",g.appendChild(C),g.appendChild(x),d.appendChild(g)}else w.restoreDropzone()};if(f){Jr(f,d,r,p,c,v());const g=c.resourceIndex.get(f);(s=g==null?void 0:g.type)!=null&&s.startsWith("video/")&&(d.onclick=w.fileUploadHandler,Pe(d,w.dragHandler))}else h();u.onchange=()=>{u.files&&u.files.length>0&&rn({file:u.files[0],container:d,fieldName:r,state:c,deps:v(),instance:t.instance,allowedExtensions:m,allowedMimes:b,maxSizeMB:y})},p.appendChild(d),p.appendChild(u),n.appendChild(p)}function Gr(e,t,n,r){var o,i,l,a;const s=t.state,c=document.createElement("div");c.className="space-y-2",c.dataset.filesWrapper=r;const p=document.createElement("input");p.type="file",p.name=r,p.multiple=!0,p.style.display="none",e.accept&&(p.accept=typeof e.accept=="string"?e.accept:[...(i=(o=e.accept.extensions)==null?void 0:o.map(v=>`.${v}`))!=null?i:[],...(l=e.accept.mime)!=null?l:[]].join(",")||"");const u=document.createElement("div");u.className="files-list-wrapper",u.style.cssText="border:2px dashed var(--fb-file-upload-border-color,#d1d5db);border-radius:var(--fb-border-radius,0.5rem);padding:8px;transition:border-color var(--fb-transition-duration,200ms),background var(--fb-transition-duration,200ms);";const d=document.createElement("div");d.className="files-list";const f=t.prefill[e.key]||[];Qe(f,s.resourceIndex),c.dataset.resourceIds=JSON.stringify(f);const m=ve(e,s),b={maxCount:1/0,allowedExtensions:ke(e.accept),allowedMimes:qe(e.accept),maxSize:(a=e.maxSize)!=null?a:1/0};u.appendChild(d),c.appendChild(p),c.appendChild(u),n.appendChild(c);const y=s.config.pickExistingFiles&&!e.disableLibrary?()=>{pn(s,e,c,r,f,1/0,w,t.instance).catch(v=>{console.error("Library pick failed:",v)})}:null;function w(){const v=le(e,s);mn({container:d,rids:f,state:s,onRemove:v?null:h=>{var g;gt((g=s.resourceIndex.get(h))==null?void 0:g.file);const E=f.indexOf(h);E>-1&&f.splice(E,1),w()},hint:m,isReadonly:v,onLibraryPick:v?null:y})}w(),an(u,f,s,w,b,r,t.instance),sn(p,f,s,w,b,r,t.instance)}function Zr(e,t,n,r){var o,i,l,a,s,c;const p=t.state,u=(o=e.minCount)!=null?o:0,d=(i=e.maxCount)!=null?i:1/0,f=document.createElement("div");f.className="space-y-2",f.dataset.filesWrapper=r;const m=document.createElement("input");m.type="file",m.name=r,m.multiple=!0,m.style.display="none",e.accept&&(m.accept=typeof e.accept=="string"?e.accept:[...(a=(l=e.accept.extensions)==null?void 0:l.map(x=>`.${x}`))!=null?a:[],...(s=e.accept.mime)!=null?s:[]].join(",")||"");const b=document.createElement("div");b.className="files-list-wrapper",b.style.cssText="border:2px dashed var(--fb-file-upload-border-color,#d1d5db);border-radius:var(--fb-border-radius,0.5rem);padding:8px;transition:border-color var(--fb-transition-duration,200ms),background var(--fb-transition-duration,200ms);";const y=document.createElement("div");y.className="files-list",f.appendChild(m),f.appendChild(b),b.appendChild(y);const w=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];Qe(w,p.resourceIndex),f.dataset.resourceIds=JSON.stringify(w);const v=ve(e,p),h={maxCount:d,allowedExtensions:ke(e.accept),allowedMimes:qe(e.accept),maxSize:(c=e.maxSize)!=null?c:1/0},g=()=>{const x=w.length===1?$("fileCountSingle",p,{count:w.length}):$("fileCountPlural",p,{count:w.length}),k=u>0||d<1/0?` ${$("fileCountRange",p,{min:u,max:d})}`:"";return x+k},E=p.config.pickExistingFiles&&!e.disableLibrary?()=>{pn(p,e,f,r,w,d,C,t.instance).catch(x=>{console.error("Library pick failed:",x)})}:null,C=()=>{const x=le(e,p);mn({container:y,rids:w,state:p,onRemove:x?null:k=>{var q;gt((q=p.resourceIndex.get(k))==null?void 0:q.file),w.splice(w.indexOf(k),1),C()},hint:v,countInfo:g(),maxCount:d<1/0?d:void 0,isReadonly:x,onLibraryPick:x?null:E})};an(b,w,p,C,h,r,t.instance),sn(m,w,p,C,h,r,t.instance),C(),n.appendChild(f)}function Qr(e,t){const n=e.querySelector(`[data-files-wrapper="${t}"]`);if(!n)return[];const r=n.dataset.resourceIds;if(r===void 0)throw new Error(`readMultiFileResourceIds: [data-files-wrapper="${t}"] is missing data-resource-ids attribute. This is a render bug.`);const o=JSON.parse(r);if(!Array.isArray(o))throw new Error(`readMultiFileResourceIds: data-resource-ids on [data-files-wrapper="${t}"] is not a JSON array. Got: ${r}`);return o}function eo(e,t,n,r,o){var i,l;const a="minCount"in n&&(i=n.minCount)!=null?i:0,s="maxCount"in n&&(l=n.maxCount)!=null?l:1/0;n.required&&t.length===0&&o.push(`${e}: ${$("required",r)}`),t.length<a&&o.push(`${e}: ${$("minFiles",r,{min:a})}`),t.length>s&&o.push(`${e}: ${$("maxFiles",r,{max:s})}`)}function hn(e,t,n,r,o){var i,l;const a="accept"in n?n.accept:void 0,s=ke(a),c=qe(a);if(s.length===0&&c.length===0)return;const p=s.join(", "),u=c.join(", ");for(const d of t){const f=r.resourceIndex.get(d),m=(i=f==null?void 0:f.name)!=null?i:d;if(s.length>0&&!ze(m,s)){o.push(`${e}: ${$("invalidFileExtension",r,{name:m,formats:p})}`);continue}if(c.length>0&&!(f!=null&&f.inferredFromExtension)){const b=(l=f==null?void 0:f.type)!=null?l:"";Oe(b,c)||o.push(`${e}: ${$("invalidFileMime",r,{name:m,type:b,mimes:u})}`)}}}function vn(e,t,n,r,o){var i;const l="maxSize"in n&&(i=n.maxSize)!=null?i:1/0;if(l!==1/0)for(const a of t){const s=r.resourceIndex.get(a);s&&s.size>l*1024*1024&&o.push(`${e}: ${$("fileTooLarge",r,{name:s.name,maxSize:l})}`)}}function to(e,t,n){const{scopeRoot:r,skipValidation:o,path:i,state:l}=n,a=[],s=xe(i,t),c=Qr(r,s);return o||(eo(t,c,e,l,a),hn(t,c,e,l,a),vn(t,c,e,l,a)),{value:c,errors:a}}function no(e,t,n){var r;const{scopeRoot:o,skipValidation:i,state:l}=n,a=[],s=o.querySelector(`input[name$="${t}"][type="hidden"]`),c=(r=s==null?void 0:s.value)!=null?r:"";return!i&&e.required&&c===""?(a.push(`${t}: ${$("required",l)}`),{value:null,errors:a}):(!i&&c!==""&&(hn(t,[c],e,l,a),vn(t,[c],e,l,a)),{value:c||null,errors:a})}function bn(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?to(e,t,n):no(e,t,n)}function ro(e,t,n,r){const o=t.state,i=t.prefill[e.key],l=typeof i=="string"?i:"";if(l){Qe([l],o.resourceIndex);const a=document.createElement("input");a.type="hidden",a.name=r,a.value=l,n.appendChild(a),xt(l,o).then(s=>{n.appendChild(s)}).catch(s=>{console.error("Failed to render file preview:",s),n.appendChild(gn(o))})}else n.appendChild(gn(o))}function gn(e){const t=document.createElement("div");return t.style.cssText=`
575
- width:${tt};
576
- height:${tt};
572
+ <span class="fb-file-library-card-label">${oe($("fromLibrary",t))}</span>
573
+ <span class="fb-file-library-card-hint">${oe($("libraryHint",t))}</span>
574
+ `:(r.innerHTML='<span aria-hidden="true">\u{1F4DA}</span>',r.title=$("fromLibrary",t),r.setAttribute("aria-label",$("fromLibrary",t))),r.addEventListener("click",n),r}function vn(e){var t;const{container:n,rids:r,state:o,onRemove:i,hint:l,countInfo:a,maxCount:c,isReadonly:s=!1,onLibraryPick:p}=e;tt();const u=n.closest("[data-files-wrapper]");for(u&&(u.dataset.resourceIds=JSON.stringify(r!=null?r:[]));n.firstChild;)n.removeChild(n.firstChild);const f=r!=null?r:[],d=c!==void 0&&f.length>=c,m=!s&&typeof p=="function",v=()=>{const h=[];return l&&h.push(l),a&&h.push(a),h.join(" \u2022 ")},y=()=>{const h=Fr(n);h&&h.click()};if(f.length===0){if(s){const h=document.createElement("div");h.className="fb-tile-empty-text",h.textContent=$("noFilesSelected",o),n.appendChild(h)}else if(m){const h=document.createElement("div");h.className="fb-file-card-row";const g=kt(o,$("clickDragTextMultiple",o),v(),y),E=$t("card",o,p);h.appendChild(g),h.appendChild(E),n.appendChild(h)}else{const h=kt(o,$("clickDragTextMultiple",o),v(),y);n.appendChild(h)}return}const C=document.createElement("div");C.className="fb-tiles-wrap",C.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";for(const h of f){const g=o.resourceIndex.get(h),E=yt();E.classList.add("fb-tile-resource","resource-pill"),E.dataset.resourceId=h;const w=Xt({canRemove:!s&&i!==null,removeHandler:i?()=>i(h):null,state:o,resourceId:h,fileName:(t=g==null?void 0:g.name)!=null?t:""});Zr(E,h,g,o,w).catch(x=>{console.error("Failed to render tile:",x)}),C.appendChild(E)}if(!s&&!d){const h=document.createElement("div");if(h.className="fb-tile fb-tile-add",h.innerHTML="+",h.onclick=y,C.appendChild(h),m){const g=$t("tile",o,p);C.appendChild(g)}}else if(!s&&d){const h=document.createElement("div");h.className="fb-tile-counter",h.textContent=$("filesCounter",o,{count:f.length,max:c}),C.appendChild(h)}n.appendChild(C);const b=v();if(b){const h=document.createElement("div");h.className="fb-tile-hint",h.textContent=b,n.appendChild(h)}}function ro(e,t,n,r){var o,i,l,a,c;const s=t.state,p=document.createElement("div");p.className="space-y-2";const u=document.createElement("input");u.type="file",u.name=r,u.style.display="none",e.accept&&(u.accept=typeof e.accept=="string"?e.accept:[...(i=(o=e.accept.extensions)==null?void 0:o.map(g=>`.${g}`))!=null?i:[],...(l=e.accept.mime)!=null?l:[]].join(",")||"");const f=document.createElement("div");f.className="file-preview-container";const d=t.prefill[e.key],m=ke(e.accept),v=Ie(e.accept),y=(a=e.maxSize)!=null?a:1/0,C={fileUploadHandler(){u.click()},dragHandler(g){g.length>0&&an({file:g[0],container:f,fieldName:r,state:s,deps:b(),instance:t.instance,allowedExtensions:m,allowedMimes:v,maxSizeMB:y})},setupDrop(g){Pe(g,C.dragHandler)},restoreDropzone(){const g=be(e,s);f.className="file-preview-container w-full max-w-md bg-gray-100 rounded-lg overflow-hidden relative group cursor-pointer",f.style.height="128px",rt(f,s,g),f.onclick=C.fileUploadHandler,Pe(f,C.dragHandler)},onRemove(){var g;const E=p.querySelector('input[type="hidden"]'),w=E==null?void 0:E.value;w&&xt((g=s.resourceIndex.get(w))==null?void 0:g.file),E&&(E.value=""),h()}},b=()=>({picker:u,fileUploadHandler:C.fileUploadHandler,dragHandler:C.dragHandler,setupDrop:C.setupDrop,onRemove:C.onRemove}),h=()=>{if(s.config.pickExistingFiles&&!e.disableLibrary){for(f.className="file-preview-container",f.removeAttribute("style"),f.onclick=null;f.firstChild;)f.removeChild(f.firstChild);const g=document.createElement("div");g.className="fb-file-card-row",g.style.cssText="display:flex;gap:8px;align-items:stretch;";const E=be(e,s),w=kt(s,$("clickDragText",s),E,C.fileUploadHandler);w.style.cssText="flex:1;min-width:0;height:128px;",Pe(w,C.dragHandler);const x=$t("card",s,()=>{eo(s,e,f,p,r,r,async k=>{await Ct(f,k,s,b())},t.instance).catch(k=>{console.error("Library pick failed:",k)})});x.style.cssText="flex:1;min-width:0;",g.appendChild(w),g.appendChild(x),f.appendChild(g)}else C.restoreDropzone()};if(d){to(d,f,r,p,s,b());const g=s.resourceIndex.get(d);(c=g==null?void 0:g.type)!=null&&c.startsWith("video/")&&(f.onclick=C.fileUploadHandler,Pe(f,C.dragHandler))}else h();u.onchange=()=>{u.files&&u.files.length>0&&an({file:u.files[0],container:f,fieldName:r,state:s,deps:b(),instance:t.instance,allowedExtensions:m,allowedMimes:v,maxSizeMB:y})},p.appendChild(f),p.appendChild(u),n.appendChild(p)}function oo(e,t,n,r){var o,i,l,a;const c=t.state,s=document.createElement("div");s.className="space-y-2",s.dataset.filesWrapper=r;const p=document.createElement("input");p.type="file",p.name=r,p.multiple=!0,p.style.display="none",e.accept&&(p.accept=typeof e.accept=="string"?e.accept:[...(i=(o=e.accept.extensions)==null?void 0:o.map(b=>`.${b}`))!=null?i:[],...(l=e.accept.mime)!=null?l:[]].join(",")||"");const u=document.createElement("div");u.className="files-list-wrapper",u.style.cssText="border:2px dashed var(--fb-file-upload-border-color,#d1d5db);border-radius:var(--fb-border-radius,0.5rem);padding:8px;transition:border-color var(--fb-transition-duration,200ms),background var(--fb-transition-duration,200ms);";const f=document.createElement("div");f.className="files-list";const d=t.prefill[e.key]||[];et(d,c.resourceIndex),s.dataset.resourceIds=JSON.stringify(d);const m=be(e,c),v={maxCount:1/0,allowedExtensions:ke(e.accept),allowedMimes:Ie(e.accept),maxSize:(a=e.maxSize)!=null?a:1/0};u.appendChild(f),s.appendChild(p),s.appendChild(u),n.appendChild(s);const y=c.config.pickExistingFiles&&!e.disableLibrary?()=>{bn(c,e,s,r,d,1/0,C,t.instance).catch(b=>{console.error("Library pick failed:",b)})}:null;function C(){const b=le(e,c);vn({container:f,rids:d,state:c,onRemove:b?null:h=>{var g;xt((g=c.resourceIndex.get(h))==null?void 0:g.file);const E=d.indexOf(h);E>-1&&d.splice(E,1),C()},hint:m,isReadonly:b,onLibraryPick:b?null:y})}C(),un(u,d,c,C,v,r,t.instance),dn(p,d,c,C,v,r,t.instance)}function lo(e,t,n,r){var o,i,l,a,c,s;const p=t.state,u=(o=e.minCount)!=null?o:0,f=(i=e.maxCount)!=null?i:1/0,d=document.createElement("div");d.className="space-y-2",d.dataset.filesWrapper=r;const m=document.createElement("input");m.type="file",m.name=r,m.multiple=!0,m.style.display="none",e.accept&&(m.accept=typeof e.accept=="string"?e.accept:[...(a=(l=e.accept.extensions)==null?void 0:l.map(x=>`.${x}`))!=null?a:[],...(c=e.accept.mime)!=null?c:[]].join(",")||"");const v=document.createElement("div");v.className="files-list-wrapper",v.style.cssText="border:2px dashed var(--fb-file-upload-border-color,#d1d5db);border-radius:var(--fb-border-radius,0.5rem);padding:8px;transition:border-color var(--fb-transition-duration,200ms),background var(--fb-transition-duration,200ms);";const y=document.createElement("div");y.className="files-list",d.appendChild(m),d.appendChild(v),v.appendChild(y);const C=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];et(C,p.resourceIndex),d.dataset.resourceIds=JSON.stringify(C);const b=be(e,p),h={maxCount:f,allowedExtensions:ke(e.accept),allowedMimes:Ie(e.accept),maxSize:(s=e.maxSize)!=null?s:1/0},g=()=>{const x=C.length===1?$("fileCountSingle",p,{count:C.length}):$("fileCountPlural",p,{count:C.length}),k=u>0||f<1/0?` ${$("fileCountRange",p,{min:u,max:f})}`:"";return x+k},E=p.config.pickExistingFiles&&!e.disableLibrary?()=>{bn(p,e,d,r,C,f,w,t.instance).catch(x=>{console.error("Library pick failed:",x)})}:null,w=()=>{const x=le(e,p);vn({container:y,rids:C,state:p,onRemove:x?null:k=>{var I;xt((I=p.resourceIndex.get(k))==null?void 0:I.file),C.splice(C.indexOf(k),1),w()},hint:b,countInfo:g(),maxCount:f<1/0?f:void 0,isReadonly:x,onLibraryPick:x?null:E})};un(v,C,p,w,h,r,t.instance),dn(m,C,p,w,h,r,t.instance),w(),n.appendChild(d)}function io(e,t){const n=e.querySelector(`[data-files-wrapper="${t}"]`);if(!n)return[];const r=n.dataset.resourceIds;if(r===void 0)throw new Error(`readMultiFileResourceIds: [data-files-wrapper="${t}"] is missing data-resource-ids attribute. This is a render bug.`);const o=JSON.parse(r);if(!Array.isArray(o))throw new Error(`readMultiFileResourceIds: data-resource-ids on [data-files-wrapper="${t}"] is not a JSON array. Got: ${r}`);return o}function ao(e,t,n,r,o){var i,l;const a="minCount"in n&&(i=n.minCount)!=null?i:0,c="maxCount"in n&&(l=n.maxCount)!=null?l:1/0;n.required&&t.length===0&&o.push(`${e}: ${$("required",r)}`),t.length<a&&o.push(`${e}: ${$("minFiles",r,{min:a})}`),t.length>c&&o.push(`${e}: ${$("maxFiles",r,{max:c})}`)}function gn(e,t,n,r,o){var i,l;const a="accept"in n?n.accept:void 0,c=ke(a),s=Ie(a);if(c.length===0&&s.length===0)return;const p=c.join(", "),u=s.join(", ");for(const f of t){const d=r.resourceIndex.get(f),m=(i=d==null?void 0:d.name)!=null?i:f;if(c.length>0&&!Ne(m,c)){o.push(`${e}: ${$("invalidFileExtension",r,{name:m,formats:p})}`);continue}if(s.length>0&&!(d!=null&&d.inferredFromExtension)){const v=(l=d==null?void 0:d.type)!=null?l:"";Oe(v,s)||o.push(`${e}: ${$("invalidFileMime",r,{name:m,type:v,mimes:u})}`)}}}function yn(e,t,n,r,o){var i;const l="maxSize"in n&&(i=n.maxSize)!=null?i:1/0;if(l!==1/0)for(const a of t){const c=r.resourceIndex.get(a);c&&c.size>l*1024*1024&&o.push(`${e}: ${$("fileTooLarge",r,{name:c.name,maxSize:l})}`)}}function so(e,t,n){const{scopeRoot:r,skipValidation:o,path:i,state:l}=n,a=[],c=xe(i,t),s=io(r,c);return o||(ao(t,s,e,l,a),gn(t,s,e,l,a),yn(t,s,e,l,a)),{value:s,errors:a}}function co(e,t,n){var r;const{scopeRoot:o,skipValidation:i,state:l}=n,a=[],c=o.querySelector(`input[name$="${t}"][type="hidden"]`),s=(r=c==null?void 0:c.value)!=null?r:"";return!i&&e.required&&s===""?(a.push(`${t}: ${$("required",l)}`),{value:null,errors:a}):(!i&&s!==""&&(gn(t,[s],e,l,a),yn(t,[s],e,l,a)),{value:s||null,errors:a})}function xn(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?so(e,t,n):co(e,t,n)}function uo(e,t,n,r){const o=t.state,i=t.prefill[e.key],l=typeof i=="string"?i:"";if(l){et([l],o.resourceIndex);const a=document.createElement("input");a.type="hidden",a.name=r,a.value=l,n.appendChild(a),wt(l,o).then(c=>{n.appendChild(c)}).catch(c=>{console.error("Failed to render file preview:",c),n.appendChild(En(o))})}else n.appendChild(En(o))}function En(e){const t=document.createElement("div");return t.style.cssText=`
575
+ width:${nt};
576
+ height:${nt};
577
577
  display:flex;
578
578
  align-items:center;
579
579
  justify-content:center;
580
580
  background:var(--fb-file-upload-bg-color,#f3f4f6);
581
581
  border-radius:var(--fb-border-radius,0.5rem);
582
582
  border:1px solid var(--fb-file-upload-border-color,#d1d5db);
583
- `,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${re($("noFileSelected",e))}</div>`,t}function yn(e,t,n,r,o){Qe(e,t.resourceIndex);const i=document.createElement("div");if(i.dataset.filesWrapper=r,i.dataset.resourceIds=JSON.stringify(e),n.appendChild(i),e.length===0){const s=document.createElement("div");s.className="fb-tile-empty-text",s.textContent=$("noFilesSelected",t),i.appendChild(s);return}const l=document.createElement("div");l.style.cssText=`display:flex;flex-wrap:wrap;gap:6px;${o?`margin-top:${o};`:""}`,i.appendChild(l);const a=e.map(()=>{const s=document.createElement("div");return s.style.cssText=`width:${tt};height:${tt};`,l.appendChild(s),s});for(let s=0;s<e.length;s++){const c=e[s],p=a[s];xt(c,t).then(u=>{p.replaceWith(u)}).catch(u=>{console.error("Failed to render readonly tile:",u)})}}function oo(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];yn(i,t.state,n,r)}function lo(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];yn(i,t.state,n,r,"4px")}function io(e,t,n,r){le(e,t.state,t)?ro(e,t,n,r):Xr(e,t,n,r)}function ao(e,t,n,r){le(e,t.state,t)?oo(e,t,n,r):Gr(e,t,n,r)}function so(e,t,n,r){le(e,t.state,t)?lo(e,t,n,r):Zr(e,t,n,r)}function xn(e,t,n,r){const{scopeRoot:o,state:i}=r;if(e.type==="files"||"multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateFileField: Expected array for multiple file field "${t}", got ${typeof n}`);return}n.forEach(a=>{a&&typeof a=="string"&&Ze(a,i.resourceIndex)});const l=o.querySelector(`[data-files-wrapper="${t}"]`);l?l.dataset.resourceIds=JSON.stringify(n):console.warn(`updateFileField: [data-files-wrapper="${t}"] not found in DOM; data-resource-ids not updated`)}else{const l=o.querySelector(`input[name="${t}"][type="hidden"]`);if(!l){console.warn(`updateFileField: Hidden input not found for file field "${t}"`);return}l.value=n!=null?String(n):"",n&&typeof n=="string"&&(Ze(n,i.resourceIndex),console.info(`updateFileField: File field "${t}" updated. Preview update requires re-render.`))}}function Ie(e){return e?e.toUpperCase():"#000000"}function kt(e){return/^#[0-9A-F]{6}$/i.test(e)||/^#[0-9A-F]{3}$/i.test(e)}function En(e){if(/^#[0-9A-F]{3}$/i.test(e)){const t=e[1],n=e[2],r=e[3];return`#${t}${t}${n}${n}${r}${r}`.toUpperCase()}return e.toUpperCase()}function Cn(e){const t=document.createElement("div");t.className="flex items-center gap-2";const n=Ie(e),r=document.createElement("div");r.style.cssText=`
583
+ `,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${oe($("noFileSelected",e))}</div>`,t}function wn(e,t,n,r,o){et(e,t.resourceIndex);const i=document.createElement("div");if(i.dataset.filesWrapper=r,i.dataset.resourceIds=JSON.stringify(e),n.appendChild(i),e.length===0){const c=document.createElement("div");c.className="fb-tile-empty-text",c.textContent=$("noFilesSelected",t),i.appendChild(c);return}const l=document.createElement("div");l.style.cssText=`display:flex;flex-wrap:wrap;gap:6px;${o?`margin-top:${o};`:""}`,i.appendChild(l);const a=e.map(()=>{const c=document.createElement("div");return c.style.cssText=`width:${nt};height:${nt};`,l.appendChild(c),c});for(let c=0;c<e.length;c++){const s=e[c],p=a[c];wt(s,t).then(u=>{p.replaceWith(u)}).catch(u=>{console.error("Failed to render readonly tile:",u)})}}function fo(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];wn(i,t.state,n,r)}function po(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];wn(i,t.state,n,r,"4px")}function mo(e,t,n,r){le(e,t.state,t)?uo(e,t,n,r):ro(e,t,n,r)}function ho(e,t,n,r){le(e,t.state,t)?fo(e,t,n,r):oo(e,t,n,r)}function bo(e,t,n,r){le(e,t.state,t)?po(e,t,n,r):lo(e,t,n,r)}function Cn(e,t,n,r){const{scopeRoot:o,state:i}=r;if(e.type==="files"||"multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateFileField: Expected array for multiple file field "${t}", got ${typeof n}`);return}n.forEach(a=>{a&&typeof a=="string"&&Qe(a,i.resourceIndex)});const l=o.querySelector(`[data-files-wrapper="${t}"]`);l?l.dataset.resourceIds=JSON.stringify(n):console.warn(`updateFileField: [data-files-wrapper="${t}"] not found in DOM; data-resource-ids not updated`)}else{const l=o.querySelector(`input[name="${t}"][type="hidden"]`);if(!l){console.warn(`updateFileField: Hidden input not found for file field "${t}"`);return}l.value=n!=null?String(n):"",n&&typeof n=="string"&&(Qe(n,i.resourceIndex),console.info(`updateFileField: File field "${t}" updated. Preview update requires re-render.`))}}function qe(e){return e?e.toUpperCase():"#000000"}function Lt(e){return/^#[0-9A-F]{6}$/i.test(e)||/^#[0-9A-F]{3}$/i.test(e)}function kn(e){if(/^#[0-9A-F]{3}$/i.test(e)){const t=e[1],n=e[2],r=e[3];return`#${t}${t}${n}${n}${r}${r}`.toUpperCase()}return e.toUpperCase()}function $n(e){const t=document.createElement("div");t.className="flex items-center gap-2";const n=qe(e),r=document.createElement("div");r.style.cssText=`
584
584
  width: 32px;
585
585
  height: 32px;
586
586
  border-radius: var(--fb-border-radius);
@@ -590,7 +590,7 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
590
590
  font-size: var(--fb-font-size);
591
591
  color: var(--fb-text-color);
592
592
  font-family: var(--fb-font-family-mono, monospace);
593
- `,o.textContent=n,t.appendChild(r),t.appendChild(o),t}function wn(e,t,n){const r=Ie(e),o=document.createElement("div");o.className="colour-picker-wrapper",o.style.cssText=`
593
+ `,o.textContent=n,t.appendChild(r),t.appendChild(o),t}function Ln(e,t,n){const r=qe(e),o=document.createElement("div");o.className="colour-picker-wrapper",o.style.cssText=`
594
594
  display: flex;
595
595
  align-items: center;
596
596
  gap: 8px;
@@ -617,45 +617,45 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
617
617
  position: absolute;
618
618
  opacity: 0;
619
619
  pointer-events: none;
620
- `,l.addEventListener("input",()=>{const s=l.value.trim();if(kt(s)){const c=En(s);i.style.backgroundColor=c,a.value=c.toLowerCase(),l.classList.remove("invalid"),n.instance&&n.instance.triggerOnChange(t,c)}else l.classList.add("invalid")}),l.addEventListener("blur",()=>{const s=l.value.trim();if(kt(s)){const c=En(s);l.value=c,i.style.backgroundColor=c,a.value=c.toLowerCase(),l.classList.remove("invalid")}}),a.addEventListener("change",()=>{const s=Ie(a.value);l.value=s,i.style.backgroundColor=s,n.instance&&n.instance.triggerOnChange(t,s)}),i.addEventListener("click",()=>{a.click()}),i.addEventListener("mouseenter",()=>{i.style.borderColor="var(--fb-border-hover-color)"}),i.addEventListener("mouseleave",()=>{i.style.borderColor="var(--fb-border-color)"}),l.addEventListener("focus",()=>{l.style.borderColor="var(--fb-border-focus-color)",l.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",l.style.outlineOffset="0"}),l.addEventListener("blur",()=>{l.style.borderColor="var(--fb-border-color)",l.style.outline="none"}),l.addEventListener("mouseenter",()=>{document.activeElement!==l&&(l.style.borderColor="var(--fb-border-hover-color)")}),l.addEventListener("mouseleave",()=>{document.activeElement!==l&&(l.style.borderColor="var(--fb-border-color)")}),o.appendChild(i),o.appendChild(l),o.appendChild(a),o}function co(e,t,n,r){const o=t.state,i=le(e,o,t),l=t.prefill[e.key]||e.default||"#000000";if(i){const a=Cn(l);n.appendChild(a)}else{const a=wn(l,r,t);n.appendChild(a)}if(!i){const a=document.createElement("p");a.className="mt-1",a.style.cssText=`
620
+ `,l.addEventListener("input",()=>{const c=l.value.trim();if(Lt(c)){const s=kn(c);i.style.backgroundColor=s,a.value=s.toLowerCase(),l.classList.remove("invalid"),n.instance&&n.instance.triggerOnChange(t,s)}else l.classList.add("invalid")}),l.addEventListener("blur",()=>{const c=l.value.trim();if(Lt(c)){const s=kn(c);l.value=s,i.style.backgroundColor=s,a.value=s.toLowerCase(),l.classList.remove("invalid")}}),a.addEventListener("change",()=>{const c=qe(a.value);l.value=c,i.style.backgroundColor=c,n.instance&&n.instance.triggerOnChange(t,c)}),i.addEventListener("click",()=>{a.click()}),i.addEventListener("mouseenter",()=>{i.style.borderColor="var(--fb-border-hover-color)"}),i.addEventListener("mouseleave",()=>{i.style.borderColor="var(--fb-border-color)"}),l.addEventListener("focus",()=>{l.style.borderColor="var(--fb-border-focus-color)",l.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",l.style.outlineOffset="0"}),l.addEventListener("blur",()=>{l.style.borderColor="var(--fb-border-color)",l.style.outline="none"}),l.addEventListener("mouseenter",()=>{document.activeElement!==l&&(l.style.borderColor="var(--fb-border-hover-color)")}),l.addEventListener("mouseleave",()=>{document.activeElement!==l&&(l.style.borderColor="var(--fb-border-color)")}),o.appendChild(i),o.appendChild(l),o.appendChild(a),o}function vo(e,t,n,r){const o=t.state,i=le(e,o,t),l=t.prefill[e.key]||e.default||"#000000";if(i){const a=$n(l);n.appendChild(a)}else{const a=Ln(l,r,t);n.appendChild(a)}if(!i){const a=document.createElement("p");a.className="mt-1",a.style.cssText=`
621
621
  font-size: var(--fb-font-size-small);
622
622
  color: var(--fb-text-secondary-color);
623
- `,a.textContent=ve(e,o),n.appendChild(a)}}function uo(e,t,n,r){var o,i;const l=t.state,a=le(e,l,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],p=(o=e.minCount)!=null?o:1,u=(i=e.maxCount)!=null?i:1/0;for(;c.length<p;)c.push(e.default||"#000000");const d=document.createElement("div");d.className="space-y-2",n.appendChild(d);function f(){d.querySelectorAll(".multiple-colour-item").forEach((h,g)=>{const E=h.querySelector("input");E&&(E.name=`${r}[${g}]`)})}function m(h="#000000",g=-1){const E=document.createElement("div");if(E.className="multiple-colour-item flex items-center gap-2",a){const C=Cn(h);for(;C.firstChild;)E.appendChild(C.firstChild)}else{const C=`${r}[${d.children.length}]`,x=wn(h,C,t);x.style.flex="1",E.appendChild(x)}return g===-1?d.appendChild(E):d.insertBefore(E,d.children[g]),f(),E}function b(){if(a)return;const h=d.querySelectorAll(".multiple-colour-item"),g=h.length;h.forEach(E=>{let C=E.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn px-2 py-1 rounded",C.style.cssText=`
623
+ `,a.textContent=be(e,o),n.appendChild(a)}}function go(e,t,n,r){var o,i;const l=t.state,a=le(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],p=(o=e.minCount)!=null?o:1,u=(i=e.maxCount)!=null?i:1/0;for(;s.length<p;)s.push(e.default||"#000000");const f=document.createElement("div");f.className="space-y-2",n.appendChild(f);function d(){f.querySelectorAll(".multiple-colour-item").forEach((h,g)=>{const E=h.querySelector("input");E&&(E.name=`${r}[${g}]`)})}function m(h="#000000",g=-1){const E=document.createElement("div");if(E.className="multiple-colour-item flex items-center gap-2",a){const w=$n(h);for(;w.firstChild;)E.appendChild(w.firstChild)}else{const w=`${r}[${f.children.length}]`,x=Ln(h,w,t);x.style.flex="1",E.appendChild(x)}return g===-1?f.appendChild(E):f.insertBefore(E,f.children[g]),d(),E}function v(){if(a)return;const h=f.querySelectorAll(".multiple-colour-item"),g=h.length;h.forEach(E=>{let w=E.querySelector(".remove-item-btn");w||(w=document.createElement("button"),w.type="button",w.className="remove-item-btn px-2 py-1 rounded",w.style.cssText=`
624
624
  color: var(--fb-error-color);
625
625
  background-color: transparent;
626
626
  transition: background-color var(--fb-transition-duration);
627
- `,C.innerHTML="\u2715",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{const k=Array.from(d.children).indexOf(E);d.children.length>p&&(c.splice(k,1),E.remove(),f(),v(),b())},E.appendChild(C));const x=g<=p;C.disabled=x,C.style.opacity=x?"0.5":"1",C.style.pointerEvents=x?"none":"auto"})}let y=null,w=null;if(!a){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const h=document.createElement("button");h.type="button",h.className="add-colour-btn px-3 py-1 rounded",h.style.cssText=`
627
+ `,w.innerHTML="\u2715",w.addEventListener("mouseenter",()=>{w.style.backgroundColor="var(--fb-background-hover-color)"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="transparent"}),w.onclick=()=>{const k=Array.from(f.children).indexOf(E);f.children.length>p&&(s.splice(k,1),E.remove(),d(),b(),v())},E.appendChild(w));const x=g<=p;w.disabled=x,w.style.opacity=x?"0.5":"1",w.style.pointerEvents=x?"none":"auto"})}let y=null,C=null;if(!a){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const h=document.createElement("button");h.type="button",h.className="add-colour-btn px-3 py-1 rounded",h.style.cssText=`
628
628
  color: var(--fb-primary-color);
629
629
  border: var(--fb-border-width) solid var(--fb-primary-color);
630
630
  background-color: transparent;
631
631
  font-size: var(--fb-font-size);
632
632
  transition: all var(--fb-transition-duration);
633
- `,h.textContent="+",h.addEventListener("mouseenter",()=>{h.style.backgroundColor="var(--fb-background-hover-color)"}),h.addEventListener("mouseleave",()=>{h.style.backgroundColor="transparent"}),h.onclick=()=>{const g=e.default||"#000000";c.push(g),m(g),v(),b()},w=document.createElement("span"),w.className="text-sm text-gray-500",y.appendChild(h),y.appendChild(w),n.appendChild(y)}function v(){if(!y||!w)return;const h=y.querySelector(".add-colour-btn");if(h){const g=c.length>=u;h.disabled=g,h.style.opacity=g?"0.5":"1",h.style.pointerEvents=g?"none":"auto"}w.textContent=`${c.length}/${u===1/0?"\u221E":u}`}if(c.forEach(h=>m(h)),v(),b(),!a){const h=document.createElement("p");h.className="mt-1",h.style.cssText=`
633
+ `,h.textContent="+",h.addEventListener("mouseenter",()=>{h.style.backgroundColor="var(--fb-background-hover-color)"}),h.addEventListener("mouseleave",()=>{h.style.backgroundColor="transparent"}),h.onclick=()=>{const g=e.default||"#000000";s.push(g),m(g),b(),v()},C=document.createElement("span"),C.className="text-sm text-gray-500",y.appendChild(h),y.appendChild(C),n.appendChild(y)}function b(){if(!y||!C)return;const h=y.querySelector(".add-colour-btn");if(h){const g=s.length>=u;h.disabled=g,h.style.opacity=g?"0.5":"1",h.style.pointerEvents=g?"none":"auto"}C.textContent=`${s.length}/${u===1/0?"\u221E":u}`}if(s.forEach(h=>m(h)),b(),v(),!a){const h=document.createElement("p");h.className="mt-1",h.style.cssText=`
634
634
  font-size: var(--fb-font-size-small);
635
635
  color: var(--fb-text-secondary-color);
636
- `,h.textContent=ve(e,l),n.appendChild(h)}}function fo(e,t,n){var r,o,i;const l=[],{scopeRoot:a,skipValidation:s}=n,c=(u,d)=>{var f,m;if(!u)return;const b=`error-${u.getAttribute("name")||Math.random().toString(36).substring(7)}`;let y=document.getElementById(b);d?(u.classList.add("invalid"),u.title=d,y||(y=document.createElement("div"),y.id=b,y.className="error-message",y.style.cssText=`
636
+ `,h.textContent=be(e,l),n.appendChild(h)}}function yo(e,t,n){var r,o,i;const l=[],{scopeRoot:a,skipValidation:c}=n,s=(u,f)=>{var d,m;if(!u)return;const v=`error-${u.getAttribute("name")||Math.random().toString(36).substring(7)}`;let y=document.getElementById(v);f?(u.classList.add("invalid"),u.title=f,y||(y=document.createElement("div"),y.id=v,y.className="error-message",y.style.cssText=`
637
637
  color: var(--fb-error-color);
638
638
  font-size: var(--fb-font-size-small);
639
639
  margin-top: 0.25rem;
640
- `,u.nextSibling?(f=u.parentNode)==null||f.insertBefore(y,u.nextSibling):(m=u.parentNode)==null||m.appendChild(y)),y.textContent=d,y.style.display="block"):(u.classList.remove("invalid"),u.title="",y&&y.remove())},p=(u,d,f)=>{const{state:m}=n;if(!d){if(!s&&e.required){const y=$("required",m);return l.push(`${f}: ${y}`),c(u,y),""}return c(u,null),""}const b=Ie(d);if(!s&&!kt(b)){const y=$("invalidHexColour",m);return l.push(`${f}: ${y}`),c(u,y),d}return c(u,null),b};if(e.multiple){const u=a.querySelectorAll(`[name^="${t}["].colour-hex-input`),d=[];if(u.forEach((f,m)=>{var b;const y=(b=f==null?void 0:f.value)!=null?b:"",w=p(f,y,`${t}[${m}]`);d.push(w)}),!s){const{state:f}=n,m=(r=e.minCount)!=null?r:1,b=(o=e.maxCount)!=null?o:1/0,y=d.filter(w=>w!=="");e.required&&y.length===0&&l.push(`${t}: ${$("required",f)}`),y.length<m&&l.push(`${t}: ${$("minItems",f,{min:m})}`),y.length>b&&l.push(`${t}: ${$("maxItems",f,{max:b})}`)}return{value:d,errors:l}}else{const u=a.querySelector(`[name="${t}"].colour-hex-input`),d=(i=u==null?void 0:u.value)!=null?i:"";if(!s&&e.required&&d===""){const f=$("required",n.state);return l.push(`${t}: ${f}`),c(u,f),{value:"",errors:l}}return{value:p(u,d,t),errors:l}}}function po(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateColourField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}["].colour-hex-input`);i.forEach((l,a)=>{if(a<n.length){const s=Ie(n[a]);l.value=s,l.classList.remove("invalid"),l.title="";const c=l.closest(".colour-picker-wrapper");if(c){const p=c.querySelector(".colour-swatch"),u=c.querySelector(".colour-picker-hidden");p&&(p.style.backgroundColor=s),u&&(u.value=s.toLowerCase())}}}),n.length!==i.length&&console.warn(`updateColourField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"].colour-hex-input`);if(i){const l=Ie(n);i.value=l,i.classList.remove("invalid"),i.title="";const a=i.closest(".colour-picker-wrapper");if(a){const s=a.querySelector(".colour-swatch"),c=a.querySelector(".colour-picker-hidden");s&&(s.style.backgroundColor=l),c&&(c.value=l.toLowerCase())}}}}function kn(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return Math.exp(r+e*(o-r))}function $t(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return(Math.log(e)-r)/(o-r)}function lt(e,t){return Math.round(e/t)*t}function $n(e,t,n,r,o){var i;const l=document.createElement("div");l.className="slider-container";const a=document.createElement("div");a.className="flex items-start gap-3";const s=document.createElement("div");s.className="flex-1";const c=document.createElement("input");c.type="range",c.name=t,c.className="slider-input w-full",c.disabled=o;const p=n.scale||"linear",u=n.min,d=n.max,f=(i=n.step)!=null?i:1;if(p==="exponential"){if(u<=0)throw new Error(`Slider "${n.key}": exponential scale requires min > 0 (got ${u})`);c.min="0",c.max="1000",c.step="1";const v=$t(e,u,d);c.value=(v*1e3).toString()}else c.min=u.toString(),c.max=d.toString(),c.step=f.toString(),c.value=e.toString();c.style.cssText=`
640
+ `,u.nextSibling?(d=u.parentNode)==null||d.insertBefore(y,u.nextSibling):(m=u.parentNode)==null||m.appendChild(y)),y.textContent=f,y.style.display="block"):(u.classList.remove("invalid"),u.title="",y&&y.remove())},p=(u,f,d)=>{const{state:m}=n;if(!f){if(!c&&e.required){const y=$("required",m);return l.push(`${d}: ${y}`),s(u,y),""}return s(u,null),""}const v=qe(f);if(!c&&!Lt(v)){const y=$("invalidHexColour",m);return l.push(`${d}: ${y}`),s(u,y),f}return s(u,null),v};if(e.multiple){const u=a.querySelectorAll(`[name^="${t}["].colour-hex-input`),f=[];if(u.forEach((d,m)=>{var v;const y=(v=d==null?void 0:d.value)!=null?v:"",C=p(d,y,`${t}[${m}]`);f.push(C)}),!c){const{state:d}=n,m=(r=e.minCount)!=null?r:1,v=(o=e.maxCount)!=null?o:1/0,y=f.filter(C=>C!=="");e.required&&y.length===0&&l.push(`${t}: ${$("required",d)}`),y.length<m&&l.push(`${t}: ${$("minItems",d,{min:m})}`),y.length>v&&l.push(`${t}: ${$("maxItems",d,{max:v})}`)}return{value:f,errors:l}}else{const u=a.querySelector(`[name="${t}"].colour-hex-input`),f=(i=u==null?void 0:u.value)!=null?i:"";if(!c&&e.required&&f===""){const d=$("required",n.state);return l.push(`${t}: ${d}`),s(u,d),{value:"",errors:l}}return{value:p(u,f,t),errors:l}}}function xo(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateColourField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}["].colour-hex-input`);i.forEach((l,a)=>{if(a<n.length){const c=qe(n[a]);l.value=c,l.classList.remove("invalid"),l.title="";const s=l.closest(".colour-picker-wrapper");if(s){const p=s.querySelector(".colour-swatch"),u=s.querySelector(".colour-picker-hidden");p&&(p.style.backgroundColor=c),u&&(u.value=c.toLowerCase())}}}),n.length!==i.length&&console.warn(`updateColourField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"].colour-hex-input`);if(i){const l=qe(n);i.value=l,i.classList.remove("invalid"),i.title="";const a=i.closest(".colour-picker-wrapper");if(a){const c=a.querySelector(".colour-swatch"),s=a.querySelector(".colour-picker-hidden");c&&(c.style.backgroundColor=l),s&&(s.value=l.toLowerCase())}}}}function Sn(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return Math.exp(r+e*(o-r))}function St(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return(Math.log(e)-r)/(o-r)}function it(e,t){return Math.round(e/t)*t}function Tn(e,t,n,r,o){var i;const l=document.createElement("div");l.className="slider-container";const a=document.createElement("div");a.className="flex items-start gap-3";const c=document.createElement("div");c.className="flex-1";const s=document.createElement("input");s.type="range",s.name=t,s.className="slider-input w-full",s.disabled=o;const p=n.scale||"linear",u=n.min,f=n.max,d=(i=n.step)!=null?i:1;if(p==="exponential"){if(u<=0)throw new Error(`Slider "${n.key}": exponential scale requires min > 0 (got ${u})`);s.min="0",s.max="1000",s.step="1";const b=St(e,u,f);s.value=(b*1e3).toString()}else s.min=u.toString(),s.max=f.toString(),s.step=d.toString(),s.value=e.toString();s.style.cssText=`
641
641
  height: 6px;
642
642
  border-radius: 3px;
643
643
  background: linear-gradient(
644
644
  to right,
645
645
  var(--fb-primary-color) 0%,
646
- var(--fb-primary-color) ${(e-u)/(d-u)*100}%,
647
- var(--fb-border-color) ${(e-u)/(d-u)*100}%,
646
+ var(--fb-primary-color) ${(e-u)/(f-u)*100}%,
647
+ var(--fb-border-color) ${(e-u)/(f-u)*100}%,
648
648
  var(--fb-border-color) 100%
649
649
  );
650
650
  outline: none;
651
651
  transition: background 0.1s ease-in-out;
652
652
  cursor: ${o?"not-allowed":"pointer"};
653
653
  opacity: ${o?"0.6":"1"};
654
- `,s.appendChild(c);const m=document.createElement("div");m.className="flex justify-between",m.style.cssText=`
654
+ `,c.appendChild(s);const m=document.createElement("div");m.className="flex justify-between",m.style.cssText=`
655
655
  font-size: var(--fb-font-size-small);
656
656
  color: var(--fb-text-secondary-color);
657
657
  margin-top: 4px;
658
- `;const b=document.createElement("span");b.textContent=u.toString();const y=document.createElement("span");y.textContent=d.toString(),m.appendChild(b),m.appendChild(y),s.appendChild(m);const w=document.createElement("span");if(w.className="slider-value",w.style.cssText=`
658
+ `;const v=document.createElement("span");v.textContent=u.toString();const y=document.createElement("span");y.textContent=f.toString(),m.appendChild(v),m.appendChild(y),c.appendChild(m);const C=document.createElement("span");if(C.className="slider-value",C.style.cssText=`
659
659
  min-width: 60px;
660
660
  text-align: right;
661
661
  font-size: var(--fb-font-size);
@@ -663,64 +663,64 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
663
663
  font-family: var(--fb-font-family-mono, monospace);
664
664
  font-weight: 500;
665
665
  padding-top: 2px;
666
- `,w.textContent=e.toFixed(f<1?2:0),a.appendChild(s),a.appendChild(w),l.appendChild(a),!o){const v=()=>{let h;if(p==="exponential"){const E=parseFloat(c.value)/1e3;h=kn(E,u,d),h=lt(h,f),h=Math.max(u,Math.min(d,h))}else h=parseFloat(c.value),h=lt(h,f);w.textContent=h.toFixed(f<1?2:0);const g=(h-u)/(d-u)*100;c.style.background=`linear-gradient(
666
+ `,C.textContent=e.toFixed(d<1?2:0),a.appendChild(c),a.appendChild(C),l.appendChild(a),!o){const b=()=>{let h;if(p==="exponential"){const E=parseFloat(s.value)/1e3;h=Sn(E,u,f),h=it(h,d),h=Math.max(u,Math.min(f,h))}else h=parseFloat(s.value),h=it(h,d);C.textContent=h.toFixed(d<1?2:0);const g=(h-u)/(f-u)*100;s.style.background=`linear-gradient(
667
667
  to right,
668
668
  var(--fb-primary-color) 0%,
669
669
  var(--fb-primary-color) ${g}%,
670
670
  var(--fb-border-color) ${g}%,
671
671
  var(--fb-border-color) 100%
672
- )`,r.instance&&r.instance.triggerOnChange(t,h)};c.addEventListener("input",v),c.addEventListener("change",v)}return l}function mo(e,t,n,r){var o;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const i=t.state,l=le(e,i,t),a=e.default!==void 0?e.default:(e.min+e.max)/2,s=(o=t.prefill[e.key])!=null?o:a,c=$n(s,r,e,t,l);if(n.appendChild(c),!l){const p=document.createElement("p");p.className="mt-1",p.style.cssText=`
672
+ )`,r.instance&&r.instance.triggerOnChange(t,h)};s.addEventListener("input",b),s.addEventListener("change",b)}return l}function Eo(e,t,n,r){var o;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const i=t.state,l=le(e,i,t),a=e.default!==void 0?e.default:(e.min+e.max)/2,c=(o=t.prefill[e.key])!=null?o:a,s=Tn(c,r,e,t,l);if(n.appendChild(s),!l){const p=document.createElement("p");p.className="mt-1",p.style.cssText=`
673
673
  font-size: var(--fb-font-size-small);
674
674
  color: var(--fb-text-secondary-color);
675
- `,p.textContent=ve(e,i),n.appendChild(p)}}function ho(e,t,n,r){var o,i;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const l=t.state,a=le(e,l,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],p=(o=e.minCount)!=null?o:1,u=(i=e.maxCount)!=null?i:1/0,d=e.default!==void 0?e.default:(e.min+e.max)/2;for(;c.length<p;)c.push(d);const f=document.createElement("div");f.className="space-y-3",n.appendChild(f);function m(){f.querySelectorAll(".multiple-slider-item").forEach((g,E)=>{const C=g.querySelector("input[type=range]");C&&C.setAttribute("name",`${r}[${E}]`)})}function b(g=d,E=-1){const C=document.createElement("div");C.className="multiple-slider-item flex items-start gap-2";const x=`${r}[${f.children.length}]`,k=$n(g,x,e,t,a);return k.style.flex="1",C.appendChild(k),E===-1?f.appendChild(C):f.insertBefore(C,f.children[E]),m(),C}function y(){if(a)return;const g=f.querySelectorAll(".multiple-slider-item"),E=g.length;g.forEach(C=>{let x=C.querySelector(".remove-item-btn");x||(x=document.createElement("button"),x.type="button",x.className="remove-item-btn px-2 py-1 rounded",x.style.cssText=`
675
+ `,p.textContent=be(e,i),n.appendChild(p)}}function wo(e,t,n,r){var o,i;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const l=t.state,a=le(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],p=(o=e.minCount)!=null?o:1,u=(i=e.maxCount)!=null?i:1/0,f=e.default!==void 0?e.default:(e.min+e.max)/2;for(;s.length<p;)s.push(f);const d=document.createElement("div");d.className="space-y-3",n.appendChild(d);function m(){d.querySelectorAll(".multiple-slider-item").forEach((g,E)=>{const w=g.querySelector("input[type=range]");w&&w.setAttribute("name",`${r}[${E}]`)})}function v(g=f,E=-1){const w=document.createElement("div");w.className="multiple-slider-item flex items-start gap-2";const x=`${r}[${d.children.length}]`,k=Tn(g,x,e,t,a);return k.style.flex="1",w.appendChild(k),E===-1?d.appendChild(w):d.insertBefore(w,d.children[E]),m(),w}function y(){if(a)return;const g=d.querySelectorAll(".multiple-slider-item"),E=g.length;g.forEach(w=>{let x=w.querySelector(".remove-item-btn");x||(x=document.createElement("button"),x.type="button",x.className="remove-item-btn px-2 py-1 rounded",x.style.cssText=`
676
676
  color: var(--fb-error-color);
677
677
  background-color: transparent;
678
678
  transition: background-color var(--fb-transition-duration);
679
679
  margin-top: 8px;
680
- `,x.innerHTML="\u2715",x.addEventListener("mouseenter",()=>{x.style.backgroundColor="var(--fb-background-hover-color)"}),x.addEventListener("mouseleave",()=>{x.style.backgroundColor="transparent"}),x.onclick=()=>{const q=Array.from(f.children).indexOf(C);f.children.length>p&&(c.splice(q,1),C.remove(),m(),h(),y())},C.appendChild(x));const k=E<=p;x.disabled=k,x.style.opacity=k?"0.5":"1",x.style.pointerEvents=k?"none":"auto"})}let w=null,v=null;if(!a){w=document.createElement("div"),w.className="flex items-center gap-3 mt-2";const g=document.createElement("button");g.type="button",g.className="add-slider-btn px-3 py-1 rounded",g.style.cssText=`
680
+ `,x.innerHTML="\u2715",x.addEventListener("mouseenter",()=>{x.style.backgroundColor="var(--fb-background-hover-color)"}),x.addEventListener("mouseleave",()=>{x.style.backgroundColor="transparent"}),x.onclick=()=>{const I=Array.from(d.children).indexOf(w);d.children.length>p&&(s.splice(I,1),w.remove(),m(),h(),y())},w.appendChild(x));const k=E<=p;x.disabled=k,x.style.opacity=k?"0.5":"1",x.style.pointerEvents=k?"none":"auto"})}let C=null,b=null;if(!a){C=document.createElement("div"),C.className="flex items-center gap-3 mt-2";const g=document.createElement("button");g.type="button",g.className="add-slider-btn px-3 py-1 rounded",g.style.cssText=`
681
681
  color: var(--fb-primary-color);
682
682
  border: var(--fb-border-width) solid var(--fb-primary-color);
683
683
  background-color: transparent;
684
684
  font-size: var(--fb-font-size);
685
685
  transition: all var(--fb-transition-duration);
686
- `,g.textContent="+",g.addEventListener("mouseenter",()=>{g.style.backgroundColor="var(--fb-background-hover-color)"}),g.addEventListener("mouseleave",()=>{g.style.backgroundColor="transparent"}),g.onclick=()=>{c.push(d),b(d),h(),y()},v=document.createElement("span"),v.className="text-sm text-gray-500",w.appendChild(g),w.appendChild(v),n.appendChild(w)}function h(){if(!w||!v)return;const g=w.querySelector(".add-slider-btn");if(g){const E=c.length>=u;g.disabled=E,g.style.opacity=E?"0.5":"1",g.style.pointerEvents=E?"none":"auto"}v.textContent=`${c.length}/${u===1/0?"\u221E":u}`}if(c.forEach(g=>b(g)),h(),y(),!a){const g=document.createElement("p");g.className="mt-1",g.style.cssText=`
686
+ `,g.textContent="+",g.addEventListener("mouseenter",()=>{g.style.backgroundColor="var(--fb-background-hover-color)"}),g.addEventListener("mouseleave",()=>{g.style.backgroundColor="transparent"}),g.onclick=()=>{s.push(f),v(f),h(),y()},b=document.createElement("span"),b.className="text-sm text-gray-500",C.appendChild(g),C.appendChild(b),n.appendChild(C)}function h(){if(!C||!b)return;const g=C.querySelector(".add-slider-btn");if(g){const E=s.length>=u;g.disabled=E,g.style.opacity=E?"0.5":"1",g.style.pointerEvents=E?"none":"auto"}b.textContent=`${s.length}/${u===1/0?"\u221E":u}`}if(s.forEach(g=>v(g)),h(),y(),!a){const g=document.createElement("p");g.className="mt-1",g.style.cssText=`
687
687
  font-size: var(--fb-font-size-small);
688
688
  color: var(--fb-text-secondary-color);
689
- `,g.textContent=ve(e,l),n.appendChild(g)}}function vo(e,t,n){var r,o,i;const l=[],{scopeRoot:a,skipValidation:s}=n;if(e.min===void 0||e.min===null)throw new Error(`Slider validation: field "${t}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider validation: field "${t}" requires "max" property`);const c=e.min,p=e.max,u=(r=e.step)!=null?r:1,d=e.scale||"linear",f=(b,y)=>{var w,v;if(!b)return;const h=`error-${b.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(h);if(y){if(b.classList.add("invalid"),b.title=y,!g){g=document.createElement("div"),g.id=h,g.className="error-message",g.style.cssText=`
689
+ `,g.textContent=be(e,l),n.appendChild(g)}}function Co(e,t,n){var r,o,i;const l=[],{scopeRoot:a,skipValidation:c}=n;if(e.min===void 0||e.min===null)throw new Error(`Slider validation: field "${t}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider validation: field "${t}" requires "max" property`);const s=e.min,p=e.max,u=(r=e.step)!=null?r:1,f=e.scale||"linear",d=(v,y)=>{var C,b;if(!v)return;const h=`error-${v.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(h);if(y){if(v.classList.add("invalid"),v.title=y,!g){g=document.createElement("div"),g.id=h,g.className="error-message",g.style.cssText=`
690
690
  color: var(--fb-error-color);
691
691
  font-size: var(--fb-font-size-small);
692
692
  margin-top: 0.25rem;
693
- `;const E=b.closest(".slider-container");E&&E.nextSibling?(w=E.parentNode)==null||w.insertBefore(g,E.nextSibling):E&&((v=E.parentNode)==null||v.appendChild(g))}g.textContent=y,g.style.display="block"}else b.classList.remove("invalid"),b.title="",g&&g.remove()},m=(b,y)=>{const{state:w}=n,v=b.value;if(!v){if(!s&&e.required){const g=$("required",w);return l.push(`${y}: ${g}`),f(b,g),null}return f(b,null),null}let h;if(d==="exponential"){const g=parseFloat(v)/1e3;h=kn(g,c,p),h=lt(h,u)}else h=parseFloat(v),h=lt(h,u);if(!s){if(h<c){const g=$("minValue",w,{min:c});return l.push(`${y}: ${g}`),f(b,g),h}if(h>p){const g=$("maxValue",w,{max:p});return l.push(`${y}: ${g}`),f(b,g),h}}return f(b,null),h};if(e.multiple){const b=a.querySelectorAll(`input[type="range"][name^="${t}["]`),y=[];if(b.forEach((w,v)=>{const h=m(w,`${t}[${v}]`);y.push(h)}),!s){const{state:w}=n,v=(o=e.minCount)!=null?o:1,h=(i=e.maxCount)!=null?i:1/0,g=y.filter(E=>E!==null);e.required&&g.length===0&&l.push(`${t}: ${$("required",w)}`),g.length<v&&l.push(`${t}: ${$("minItems",w,{min:v})}`),g.length>h&&l.push(`${t}: ${$("maxItems",w,{max:h})}`)}return{value:y,errors:l}}else{const b=a.querySelector(`input[type="range"][name="${t}"]`);return b?{value:m(b,t),errors:l}:(!s&&e.required&&l.push(`${t}: ${$("required",n.state)}`),{value:null,errors:l})}}function bo(e,t,n,r){var o;const{scopeRoot:i}=r,l=e.min,a=e.max,s=(o=e.step)!=null?o:1,c=e.scale||"linear";if(e.multiple){if(!Array.isArray(n)){console.warn(`updateSliderField: Expected array for multiple field "${t}", got ${typeof n}`);return}const p=i.querySelectorAll(`input[type="range"][name^="${t}["]`);p.forEach((u,d)=>{if(d<n.length&&n[d]!==null){const f=Number(n[d]);if(c==="exponential"){const b=$t(f,l,a);u.value=(b*1e3).toString()}else u.value=f.toString();const m=u.closest(".slider-container");if(m){const b=m.querySelector(".slider-value");b&&(b.textContent=f.toFixed(s<1?2:0));const y=(f-l)/(a-l)*100;u.style.background=`linear-gradient(
693
+ `;const E=v.closest(".slider-container");E&&E.nextSibling?(C=E.parentNode)==null||C.insertBefore(g,E.nextSibling):E&&((b=E.parentNode)==null||b.appendChild(g))}g.textContent=y,g.style.display="block"}else v.classList.remove("invalid"),v.title="",g&&g.remove()},m=(v,y)=>{const{state:C}=n,b=v.value;if(!b){if(!c&&e.required){const g=$("required",C);return l.push(`${y}: ${g}`),d(v,g),null}return d(v,null),null}let h;if(f==="exponential"){const g=parseFloat(b)/1e3;h=Sn(g,s,p),h=it(h,u)}else h=parseFloat(b),h=it(h,u);if(!c){if(h<s){const g=$("minValue",C,{min:s});return l.push(`${y}: ${g}`),d(v,g),h}if(h>p){const g=$("maxValue",C,{max:p});return l.push(`${y}: ${g}`),d(v,g),h}}return d(v,null),h};if(e.multiple){const v=a.querySelectorAll(`input[type="range"][name^="${t}["]`),y=[];if(v.forEach((C,b)=>{const h=m(C,`${t}[${b}]`);y.push(h)}),!c){const{state:C}=n,b=(o=e.minCount)!=null?o:1,h=(i=e.maxCount)!=null?i:1/0,g=y.filter(E=>E!==null);e.required&&g.length===0&&l.push(`${t}: ${$("required",C)}`),g.length<b&&l.push(`${t}: ${$("minItems",C,{min:b})}`),g.length>h&&l.push(`${t}: ${$("maxItems",C,{max:h})}`)}return{value:y,errors:l}}else{const v=a.querySelector(`input[type="range"][name="${t}"]`);return v?{value:m(v,t),errors:l}:(!c&&e.required&&l.push(`${t}: ${$("required",n.state)}`),{value:null,errors:l})}}function ko(e,t,n,r){var o;const{scopeRoot:i}=r,l=e.min,a=e.max,c=(o=e.step)!=null?o:1,s=e.scale||"linear";if(e.multiple){if(!Array.isArray(n)){console.warn(`updateSliderField: Expected array for multiple field "${t}", got ${typeof n}`);return}const p=i.querySelectorAll(`input[type="range"][name^="${t}["]`);p.forEach((u,f)=>{if(f<n.length&&n[f]!==null){const d=Number(n[f]);if(s==="exponential"){const v=St(d,l,a);u.value=(v*1e3).toString()}else u.value=d.toString();const m=u.closest(".slider-container");if(m){const v=m.querySelector(".slider-value");v&&(v.textContent=d.toFixed(c<1?2:0));const y=(d-l)/(a-l)*100;u.style.background=`linear-gradient(
694
694
  to right,
695
695
  var(--fb-primary-color) 0%,
696
696
  var(--fb-primary-color) ${y}%,
697
697
  var(--fb-border-color) ${y}%,
698
698
  var(--fb-border-color) 100%
699
- )`}u.classList.remove("invalid"),u.title=""}}),n.length!==p.length&&console.warn(`updateSliderField: Multiple field "${t}" has ${p.length} sliders but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const p=i.querySelector(`input[type="range"][name="${t}"]`);if(p&&n!==null&&n!==void 0){const u=Number(n);if(c==="exponential"){const f=$t(u,l,a);p.value=(f*1e3).toString()}else p.value=u.toString();const d=p.closest(".slider-container");if(d){const f=d.querySelector(".slider-value");f&&(f.textContent=u.toFixed(s<1?2:0));const m=(u-l)/(a-l)*100;p.style.background=`linear-gradient(
699
+ )`}u.classList.remove("invalid"),u.title=""}}),n.length!==p.length&&console.warn(`updateSliderField: Multiple field "${t}" has ${p.length} sliders but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const p=i.querySelector(`input[type="range"][name="${t}"]`);if(p&&n!==null&&n!==void 0){const u=Number(n);if(s==="exponential"){const d=St(u,l,a);p.value=(d*1e3).toString()}else p.value=u.toString();const f=p.closest(".slider-container");if(f){const d=f.querySelector(".slider-value");d&&(d.textContent=u.toFixed(c<1?2:0));const m=(u-l)/(a-l)*100;p.style.background=`linear-gradient(
700
700
  to right,
701
701
  var(--fb-primary-color) 0%,
702
702
  var(--fb-primary-color) ${m}%,
703
703
  var(--fb-border-color) ${m}%,
704
704
  var(--fb-border-color) 100%
705
- )`}p.classList.remove("invalid"),p.title=""}}}function Ln(e){const t={};for(const n of e)"default"in n&&n.default!==void 0&&(t[n.key]=n.default);return t}function Sn(e,t){return{...t,...e}}function Lt(e){const t={};return e.querySelectorAll("input, select, textarea").forEach(n=>{const r=n.getAttribute("name");r&&!r.includes("[")&&!r.includes(".")&&(n instanceof HTMLSelectElement?t[r]=n.value:n instanceof HTMLInputElement?n.type==="checkbox"?t[r]=n.checked:n.type==="radio"?n.checked&&(t[r]=n.value):t[r]=n.value:n instanceof HTMLTextAreaElement&&(t[r]=n.value))}),t}let St=null;function go(e){St=e}function it(e,t){if(!St)throw new Error("renderElement not initialized. Import from components/index.ts");return St(e,t)}function Tn(e,t){if(!e.prefillHints||e.prefillHints.length===0)return null;const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-4",e.prefillHints.forEach((r,o)=>{const i=document.createElement("button");i.type="button",i.className="fb-prefill-hint",i.textContent=r.label,i.setAttribute("data-hint-values",JSON.stringify(r.values)),i.setAttribute("data-container-key",t),i.setAttribute("data-hint-index",String(o)),n.appendChild(i)}),n}function Fn(e,t,n,r){var o,i;const l=document.createElement("div");l.className="border border-gray-200 rounded-lg p-4 bg-gray-50",l.setAttribute("data-container",r);const a=document.createElement("div"),s=e.columns||1;s===1?a.className="space-y-4":a.className=`grid grid-cols-${s} gap-4`;const c=le(e,t.state,t);if(!c){const m=Tn(e,r);m&&l.appendChild(m)}const p=Ln(e.elements),u=((o=t.prefill)==null?void 0:o[e.key])||{},d=Sn(u,p),f={path:xe(t.path,e.key),prefill:d,formData:(i=t.formData)!=null?i:t.prefill,state:t.state,inheritedReadonly:c||t.inheritedReadonly};e.elements.forEach(m=>{var b,y;if(m.hidden||m.type==="hidden"){const w=(y=(b=u[m.key])!=null?b:m.default)!=null?y:null;a.appendChild(De(xe(f.path,m.key),w))}else a.appendChild(it(m,f))}),l.appendChild(a),n.appendChild(l)}function An(e,t,n,r){var o,i,l,a;const s=t.state,c=le(e,s,t),p=c||t.inheritedReadonly,u=document.createElement("div");u.className="border border-gray-200 rounded-lg p-4 bg-gray-50";const d=document.createElement("span");d.className="text-sm text-gray-500";const f=document.createElement("div");if(f.className="space-y-4",!c){const C=Tn(e,e.key);C&&u.appendChild(C)}const m=(o=e.minCount)!=null?o:0,b=(i=e.maxCount)!=null?i:1/0,y=Array.isArray((l=t.prefill)==null?void 0:l[e.key])?t.prefill[e.key]:null,w=Ln(e.elements),v=()=>f.querySelectorAll(":scope > .containerItem").length,h=()=>{const C=document.createElement("button");return C.type="button",C.className="add-container-btn px-3 py-1 rounded",C.style.cssText=`
705
+ )`}p.classList.remove("invalid"),p.title=""}}}function An(e){const t={};for(const n of e)n.key&&"default"in n&&n.default!==void 0&&(t[n.key]=n.default);return t}function Fn(e,t){return{...t,...e}}function Tt(e){const t={};return e.querySelectorAll("input, select, textarea").forEach(n=>{const r=n.getAttribute("name");r&&!r.includes("[")&&!r.includes(".")&&(n instanceof HTMLSelectElement?t[r]=n.value:n instanceof HTMLInputElement?n.type==="checkbox"?t[r]=n.checked:n.type==="radio"?n.checked&&(t[r]=n.value):t[r]=n.value:n instanceof HTMLTextAreaElement&&(t[r]=n.value))}),t}let At=null;function $o(e){At=e}function at(e,t){if(!At)throw new Error("renderElement not initialized. Import from components/index.ts");return At(e,t)}function Mn(e,t){if(!e.prefillHints||e.prefillHints.length===0)return null;const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-4",e.prefillHints.forEach((r,o)=>{const i=document.createElement("button");i.type="button",i.className="fb-prefill-hint",i.textContent=r.label,i.setAttribute("data-hint-values",JSON.stringify(r.values)),i.setAttribute("data-container-key",t),i.setAttribute("data-hint-index",String(o)),n.appendChild(i)}),n}function zn(e,t,n,r){var o,i;const l=document.createElement("div");l.className="border border-gray-200 rounded-lg p-4 bg-gray-50",l.setAttribute("data-container",r);const a=document.createElement("div"),c=e.columns||1;c===1?a.className="space-y-4":a.className=`grid grid-cols-${c} gap-4`;const s=le(e,t.state,t);if(!s){const m=Mn(e,r);m&&l.appendChild(m)}const p=An(e.elements),u=((o=t.prefill)==null?void 0:o[e.key])||{},f=Fn(u,p),d={path:xe(t.path,e.key),prefill:f,formData:(i=t.formData)!=null?i:t.prefill,state:t.state,inheritedReadonly:s||t.inheritedReadonly};e.elements.forEach(m=>{var v,y;if(m.type!=="markdown"&&(m.hidden||m.type==="hidden")){const C=(y=(v=u[m.key])!=null?v:"default"in m?m.default:null)!=null?y:null;a.appendChild(De(xe(d.path,m.key),C))}else a.appendChild(at(m,d))}),l.appendChild(a),n.appendChild(l)}function Nn(e,t,n,r){var o,i,l,a;const c=t.state,s=le(e,c,t),p=s||t.inheritedReadonly,u=document.createElement("div");u.className="border border-gray-200 rounded-lg p-4 bg-gray-50";const f=document.createElement("span");f.className="text-sm text-gray-500";const d=document.createElement("div");if(d.className="space-y-4",!s){const w=Mn(e,e.key);w&&u.appendChild(w)}const m=(o=e.minCount)!=null?o:0,v=(i=e.maxCount)!=null?i:1/0,y=Array.isArray((l=t.prefill)==null?void 0:l[e.key])?t.prefill[e.key]:null,C=An(e.elements),b=()=>d.querySelectorAll(":scope > .containerItem").length,h=()=>{const w=document.createElement("button");return w.type="button",w.className="add-container-btn px-3 py-1 rounded",w.style.cssText=`
706
706
  color: var(--fb-primary-color);
707
707
  border: var(--fb-border-width) solid var(--fb-primary-color);
708
708
  background-color: transparent;
709
709
  font-size: var(--fb-font-size);
710
710
  transition: all var(--fb-transition-duration);
711
- `,C.textContent="+",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{if(v()<b){const x=v(),k=s.formRoot?Lt(s.formRoot):{},q={state:t.state,path:xe(t.path,`${e.key}[${x}]`),prefill:w,formData:k,inheritedReadonly:p},K=document.createElement("div");K.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",K.setAttribute("data-container-item",`${e.key}[${x}]`);const R=document.createElement("div"),G=e.columns||1;if(G===1?R.className="space-y-4":R.className=`grid grid-cols-${G} gap-4`,e.elements.forEach(Z=>{var oe;Z.hidden||Z.type==="hidden"?R.appendChild(De(xe(q.path,Z.key),(oe=Z.default)!=null?oe:null)):R.appendChild(it(Z,q))}),K.appendChild(R),!c){const Z=document.createElement("button");Z.type="button",Z.className="absolute top-2 right-2 px-2 py-1 rounded",Z.style.cssText=`
711
+ `,w.textContent="+",w.addEventListener("mouseenter",()=>{w.style.backgroundColor="var(--fb-background-hover-color)"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="transparent"}),w.onclick=()=>{if(b()<v){const x=b(),k=c.formRoot?Tt(c.formRoot):{},I={state:t.state,path:xe(t.path,`${e.key}[${x}]`),prefill:C,formData:k,inheritedReadonly:p},K=document.createElement("div");K.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",K.setAttribute("data-container-item",`${e.key}[${x}]`);const R=document.createElement("div"),J=e.columns||1;if(J===1?R.className="space-y-4":R.className=`grid grid-cols-${J} gap-4`,e.elements.forEach(X=>{var re;X.type!=="markdown"&&(X.hidden||X.type==="hidden")?R.appendChild(De(xe(I.path,X.key),(re="default"in X?X.default:null)!=null?re:null)):R.appendChild(at(X,I))}),K.appendChild(R),!s){const X=document.createElement("button");X.type="button",X.className="absolute top-2 right-2 px-2 py-1 rounded",X.style.cssText=`
712
712
  color: var(--fb-error-color);
713
713
  background-color: transparent;
714
714
  transition: background-color var(--fb-transition-duration);
715
- `,Z.textContent="\u2715",Z.addEventListener("mouseenter",()=>{Z.style.backgroundColor="var(--fb-background-hover-color)"}),Z.addEventListener("mouseleave",()=>{Z.style.backgroundColor="transparent"}),Z.onclick=()=>E(K),K.style.position="relative",K.appendChild(Z)}f.appendChild(K),g()}},C},g=()=>{const C=v(),x=u.querySelector(".add-container-btn");x&&(x.disabled=C>=b,x.style.opacity=C>=b?"0.5":"1",x.style.pointerEvents=C>=b?"none":"auto"),d.textContent=`${C}/${b===1/0?"\u221E":b}`},E=C=>{C.remove(),g()};if(y&&Array.isArray(y)&&y.forEach((C,x)=>{var k;const q=Sn(C||{},w),K={state:t.state,path:xe(t.path,`${e.key}[${x}]`),prefill:q,formData:(k=t.formData)!=null?k:t.prefill,inheritedReadonly:p},R=document.createElement("div");R.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",R.setAttribute("data-container-item",`${e.key}[${x}]`);const G=document.createElement("div"),Z=e.columns||1;if(Z===1?G.className="space-y-4":G.className=`grid grid-cols-${Z} gap-4`,e.elements.forEach(oe=>{var Ae,fe;if(oe.hidden||oe.type==="hidden"){const Se=(fe=(Ae=C==null?void 0:C[oe.key])!=null?Ae:oe.default)!=null?fe:null;G.appendChild(De(xe(K.path,oe.key),Se))}else G.appendChild(it(oe,K))}),R.appendChild(G),!c){const oe=document.createElement("button");oe.type="button",oe.className="absolute top-2 right-2 px-2 py-1 rounded",oe.style.cssText=`
715
+ `,X.textContent="\u2715",X.addEventListener("mouseenter",()=>{X.style.backgroundColor="var(--fb-background-hover-color)"}),X.addEventListener("mouseleave",()=>{X.style.backgroundColor="transparent"}),X.onclick=()=>E(K),K.style.position="relative",K.appendChild(X)}d.appendChild(K),g()}},w},g=()=>{const w=b(),x=u.querySelector(".add-container-btn");x&&(x.disabled=w>=v,x.style.opacity=w>=v?"0.5":"1",x.style.pointerEvents=w>=v?"none":"auto"),f.textContent=`${w}/${v===1/0?"\u221E":v}`},E=w=>{w.remove(),g()};if(y&&Array.isArray(y)&&y.forEach((w,x)=>{var k;const I=Fn(w||{},C),K={state:t.state,path:xe(t.path,`${e.key}[${x}]`),prefill:I,formData:(k=t.formData)!=null?k:t.prefill,inheritedReadonly:p},R=document.createElement("div");R.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",R.setAttribute("data-container-item",`${e.key}[${x}]`);const J=document.createElement("div"),X=e.columns||1;if(X===1?J.className="space-y-4":J.className=`grid grid-cols-${X} gap-4`,e.elements.forEach(re=>{var Fe,fe;if(re.type!=="markdown"&&(re.hidden||re.type==="hidden")){const Se=(fe=(Fe=w==null?void 0:w[re.key])!=null?Fe:"default"in re?re.default:null)!=null?fe:null;J.appendChild(De(xe(K.path,re.key),Se))}else J.appendChild(at(re,K))}),R.appendChild(J),!s){const re=document.createElement("button");re.type="button",re.className="absolute top-2 right-2 px-2 py-1 rounded",re.style.cssText=`
716
716
  color: var(--fb-error-color);
717
717
  background-color: transparent;
718
718
  transition: background-color var(--fb-transition-duration);
719
- `,oe.textContent="\u2715",oe.addEventListener("mouseenter",()=>{oe.style.backgroundColor="var(--fb-background-hover-color)"}),oe.addEventListener("mouseleave",()=>{oe.style.backgroundColor="transparent"}),oe.onclick=()=>E(R),R.style.position="relative",R.appendChild(oe)}f.appendChild(R)}),!c)for(;v()<m;){const C=v(),x={state:t.state,path:xe(t.path,`${e.key}[${C}]`),prefill:w,formData:(a=t.formData)!=null?a:t.prefill,inheritedReadonly:p},k=document.createElement("div");k.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",k.setAttribute("data-container-item",`${e.key}[${C}]`);const q=document.createElement("div"),K=e.columns||1;K===1?q.className="space-y-4":q.className=`grid grid-cols-${K} gap-4`,e.elements.forEach(G=>{var Z;G.hidden||G.type==="hidden"?q.appendChild(De(xe(x.path,G.key),(Z=G.default)!=null?Z:null)):q.appendChild(it(G,x))}),k.appendChild(q);const R=document.createElement("button");R.type="button",R.className="absolute top-2 right-2 px-2 py-1 rounded",R.style.cssText=`
719
+ `,re.textContent="\u2715",re.addEventListener("mouseenter",()=>{re.style.backgroundColor="var(--fb-background-hover-color)"}),re.addEventListener("mouseleave",()=>{re.style.backgroundColor="transparent"}),re.onclick=()=>E(R),R.style.position="relative",R.appendChild(re)}d.appendChild(R)}),!s)for(;b()<m;){const w=b(),x={state:t.state,path:xe(t.path,`${e.key}[${w}]`),prefill:C,formData:(a=t.formData)!=null?a:t.prefill,inheritedReadonly:p},k=document.createElement("div");k.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",k.setAttribute("data-container-item",`${e.key}[${w}]`);const I=document.createElement("div"),K=e.columns||1;K===1?I.className="space-y-4":I.className=`grid grid-cols-${K} gap-4`,e.elements.forEach(J=>{var X;J.type!=="markdown"&&(J.hidden||J.type==="hidden")?I.appendChild(De(xe(x.path,J.key),(X="default"in J?J.default:null)!=null?X:null)):I.appendChild(at(J,x))}),k.appendChild(I);const R=document.createElement("button");R.type="button",R.className="absolute top-2 right-2 px-2 py-1 rounded",R.style.cssText=`
720
720
  color: var(--fb-error-color);
721
721
  background-color: transparent;
722
722
  transition: background-color var(--fb-transition-duration);
723
- `,R.textContent="\u2715",R.addEventListener("mouseenter",()=>{R.style.backgroundColor="var(--fb-background-hover-color)"}),R.addEventListener("mouseleave",()=>{R.style.backgroundColor="transparent"}),R.onclick=()=>{v()>m&&E(k)},k.style.position="relative",k.appendChild(R),f.appendChild(k)}if(u.appendChild(f),!c){const C=document.createElement("div");C.className="flex items-center gap-3 mt-2",C.appendChild(h()),C.appendChild(d),u.appendChild(C)}g(),n.appendChild(u)}let Tt=null;function yo(e){Tt=e}function Mn(e,t,n){if(!Tt)throw new Error("validateElement not initialized. Should be set from FormBuilderInstance");return Tt(e,t,n)}function Nn(e,t,n){const r=[],{scopeRoot:o,skipValidation:i,path:l}=n;if(!("elements"in e))return{value:null,errors:r};const a=(s,c,p)=>{var u,d;if(i)return;const{state:f}=n,m="minCount"in p&&(u=p.minCount)!=null?u:0,b="maxCount"in p&&(d=p.maxCount)!=null?d:1/0;p.required&&c.length===0&&r.push(`${s}: ${$("required",f)}`),c.length<m&&r.push(`${s}: ${$("minItems",f,{min:m})}`),c.length>b&&r.push(`${s}: ${$("maxItems",f,{max:b})}`)};if("multiple"in e&&e.multiple){const s=[],c=o.querySelectorAll("[data-container-item]");return Array.from(c).filter(p=>{const u=p.getAttribute("data-container-item")||"";if(!u.startsWith(`${t}[`))return!1;const d=u.slice(t.length);return/^\[\d+\]$/.test(d)}).forEach(p=>{const u={},d=(p.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),f=d?parseInt(d[1],10):0;e.elements.forEach(m=>{var b;if(m.enableIf)try{const v=(b=n.instance)!=null&&b.getState().formRoot?Lt(n.instance.getState().formRoot):{};if(!Ne(m.enableIf,v,u))return}catch(v){console.error(`Error evaluating enableIf for field "${m.key}" in container "${t}[${f}]":`,v)}const y=`${t}[${f}].${m.key}`,w=Mn({...m,key:y},{path:l},p);w.spread&&w.value!==null&&typeof w.value=="object"?Object.assign(u,w.value):u[m.key]=w.value}),s.push(u)}),a(t,s,e),{value:s,errors:r}}else{const s={},c=o.querySelector(`[data-container="${t}"]`)||o;return e.elements.forEach(p=>{var u;if(p.enableIf)try{const d=(u=n.instance)!=null&&u.getState().formRoot?Lt(n.instance.getState().formRoot):{};if(!Ne(p.enableIf,d,s))return}catch(d){console.error(`Error evaluating enableIf for field "${p.key}" in container "${t}":`,d)}{const d=`${t}.${p.key}`,f=Mn({...p,key:d},{path:l},c);f.spread&&f.value!==null&&typeof f.value=="object"?Object.assign(s,f.value):s[p.key]=f.value}}),{value:s,errors:r}}}function zn(e,t,n,r){const{instance:o,scopeRoot:i}=r;if("elements"in e)if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateContainerField: Expected array for multiple container field "${t}", got ${typeof n}`);return}n.forEach((a,s)=>{Je(a)&&e.elements.forEach(c=>{var p,u;const d=`${t}[${s}].${c.key}`;if(c.type==="richinput"&&c.flatOutput){const f=c,m=(p=f.textKey)!=null?p:"text",b=(u=f.filesKey)!=null?u:"files",y=a,w={};m in y&&(w[m]=y[m]),b in y&&(w[b]=y[b]),Object.keys(w).length>0&&o.updateField(d,w)}else{const f=a[c.key];f!==void 0&&o.updateField(d,f)}})});const l=i.querySelectorAll(`[data-container-item^="${t}["]`);n.length!==l.length&&console.warn(`updateContainerField: Multiple container field "${t}" item count mismatch. Consider re-rendering for add/remove.`)}else{if(!Je(n)){console.warn(`updateContainerField: Expected object for container field "${t}", got ${typeof n}`);return}e.elements.forEach(l=>{var a,s;const c=`${t}.${l.key}`;if(l.type==="richinput"&&l.flatOutput){const p=l,u=(a=p.textKey)!=null?a:"text",d=(s=p.filesKey)!=null?s:"files",f=n,m={};u in f&&(m[u]=f[u]),d in f&&(m[d]=f[d]),Object.keys(m).length>0&&o.updateField(c,m)}else{const p=n[l.key];p!==void 0&&o.updateField(c,p)}})}}function xo(e,t,n,r){var o,i;typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated and will be removed in a future version. Please use type: "container" with multiple: true instead. Field key: "${e.key}"`);const l={key:e.key,label:e.label,description:e.description,hint:e.hint,required:e.required,hidden:e.hidden,default:e.default,actions:e.actions,elements:e.elements,multiple:!!(e.repeat&&Je(e.repeat)),minCount:(o=e.repeat)==null?void 0:o.min,maxCount:(i=e.repeat)==null?void 0:i.max};l.multiple?An(l,t,n):Fn(l,t,n,r)}function qn(e){var t,n;const r=e;return{type:"container",key:r.key,label:r.label,description:r.description,hint:r.hint,required:r.required,hidden:r.hidden,default:r.default,actions:r.actions,elements:r.elements,multiple:!!(r.repeat&&Je(r.repeat)),minCount:(t=r.repeat)==null?void 0:t.min,maxCount:(n=r.repeat)==null?void 0:n.max}}function Eo(e,t,n){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field key: "${t}"`);const r=qn(e);return Nn(r,t,n)}function Co(e,t,n,r){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field path: "${t}"`);const o=qn(e);return zn(o,t,n,r)}function wo(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function ko(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.top=="number"&&typeof t.left=="number"&&typeof t.bottom=="number"&&typeof t.right=="number"}function $o(e){return wo(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:ko(e)?e:null}function Re(e){return e.map($o).filter(t=>t!==null)}function In(e,t){return Array.from({length:e},()=>Array.from({length:t},()=>""))}function Ft(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(o.top<0||o.left<0||o.bottom>=t||o.right>=n||o.top>o.bottom||o.left>o.right)return`Merge ${r} out of bounds`;for(let i=r+1;i<e.length;i++){const l=e[i];if(o.top<=l.bottom&&o.bottom>=l.top&&o.left<=l.right&&o.right>=l.left)return`Merges ${r} and ${i} overlap`}}return null}function Rn(e,t,n){for(const r of n){if(r.top===e&&r.left===t)return null;if(e>=r.top&&e<=r.bottom&&t>=r.left&&t<=r.right)return r}return null}function at(e,t,n){var r;return(r=n.find(o=>o.top===e&&o.left===t))!=null?r:null}function Le(e){var t;if(!e.anchor)return null;const n=(t=e.focus)!=null?t:e.anchor;return{r1:Math.min(e.anchor.row,n.row),c1:Math.min(e.anchor.col,n.col),r2:Math.max(e.anchor.row,n.row),c2:Math.max(e.anchor.col,n.col)}}function He(e){const t=document.createElement("button");return t.type="button",t.textContent=e.label,t.title=e.title,t.style.cssText=`
723
+ `,R.textContent="\u2715",R.addEventListener("mouseenter",()=>{R.style.backgroundColor="var(--fb-background-hover-color)"}),R.addEventListener("mouseleave",()=>{R.style.backgroundColor="transparent"}),R.onclick=()=>{b()>m&&E(k)},k.style.position="relative",k.appendChild(R),d.appendChild(k)}if(u.appendChild(d),!s){const w=document.createElement("div");w.className="flex items-center gap-3 mt-2",w.appendChild(h()),w.appendChild(f),u.appendChild(w)}g(),n.appendChild(u)}let Ft=null;function Lo(e){Ft=e}function In(e,t,n){if(!Ft)throw new Error("validateElement not initialized. Should be set from FormBuilderInstance");return Ft(e,t,n)}function qn(e,t,n){const r=[],{scopeRoot:o,skipValidation:i,path:l}=n;if(!("elements"in e))return{value:null,errors:r};const a=(c,s,p)=>{var u,f;if(i)return;const{state:d}=n,m="minCount"in p&&(u=p.minCount)!=null?u:0,v="maxCount"in p&&(f=p.maxCount)!=null?f:1/0;p.required&&s.length===0&&r.push(`${c}: ${$("required",d)}`),s.length<m&&r.push(`${c}: ${$("minItems",d,{min:m})}`),s.length>v&&r.push(`${c}: ${$("maxItems",d,{max:v})}`)};if("multiple"in e&&e.multiple){const c=[],s=o.querySelectorAll("[data-container-item]");return Array.from(s).filter(p=>{const u=p.getAttribute("data-container-item")||"";if(!u.startsWith(`${t}[`))return!1;const f=u.slice(t.length);return/^\[\d+\]$/.test(f)}).forEach(p=>{const u={},f=(p.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),d=f?parseInt(f[1],10):0;e.elements.forEach(m=>{var v;if(m.enableIf)try{const b=(v=n.instance)!=null&&v.getState().formRoot?Tt(n.instance.getState().formRoot):{};if(!ze(m.enableIf,b,u))return}catch(b){console.error(`Error evaluating enableIf for field "${m.key}" in container "${t}[${d}]":`,b)}const y=`${t}[${d}].${m.key}`,C=In({...m,key:y},{path:l},p);C.spread&&C.value!==null&&typeof C.value=="object"?Object.assign(u,C.value):u[m.key]=C.value}),c.push(u)}),a(t,c,e),{value:c,errors:r}}else{const c={},s=o.querySelector(`[data-container="${t}"]`)||o;return e.elements.forEach(p=>{var u;if(p.enableIf)try{const f=(u=n.instance)!=null&&u.getState().formRoot?Tt(n.instance.getState().formRoot):{};if(!ze(p.enableIf,f,c))return}catch(f){console.error(`Error evaluating enableIf for field "${p.key}" in container "${t}":`,f)}{const f=`${t}.${p.key}`,d=In({...p,key:f},{path:l},s);d.spread&&d.value!==null&&typeof d.value=="object"?Object.assign(c,d.value):c[p.key]=d.value}}),{value:c,errors:r}}}function Rn(e,t,n,r){const{instance:o,scopeRoot:i}=r;if("elements"in e)if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateContainerField: Expected array for multiple container field "${t}", got ${typeof n}`);return}n.forEach((a,c)=>{Ye(a)&&e.elements.forEach(s=>{var p,u;if(s.type==="markdown"||!s.key)return;const f=`${t}[${c}].${s.key}`;if(s.type==="richinput"&&s.flatOutput){const d=s,m=(p=d.textKey)!=null?p:"text",v=(u=d.filesKey)!=null?u:"files",y=a,C={};m in y&&(C[m]=y[m]),v in y&&(C[v]=y[v]),Object.keys(C).length>0&&o.updateField(f,C)}else{const d=a[s.key];d!==void 0&&o.updateField(f,d)}})});const l=i.querySelectorAll(`[data-container-item^="${t}["]`);n.length!==l.length&&console.warn(`updateContainerField: Multiple container field "${t}" item count mismatch. Consider re-rendering for add/remove.`)}else{if(!Ye(n)){console.warn(`updateContainerField: Expected object for container field "${t}", got ${typeof n}`);return}e.elements.forEach(l=>{var a,c;if(l.type==="markdown"||!l.key)return;const s=`${t}.${l.key}`;if(l.type==="richinput"&&l.flatOutput){const p=l,u=(a=p.textKey)!=null?a:"text",f=(c=p.filesKey)!=null?c:"files",d=n,m={};u in d&&(m[u]=d[u]),f in d&&(m[f]=d[f]),Object.keys(m).length>0&&o.updateField(s,m)}else{const p=n[l.key];p!==void 0&&o.updateField(s,p)}})}}function So(e,t,n,r){var o,i;typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated and will be removed in a future version. Please use type: "container" with multiple: true instead. Field key: "${e.key}"`);const l={key:e.key,label:e.label,description:e.description,hint:e.hint,required:e.required,hidden:e.hidden,default:e.default,actions:e.actions,elements:e.elements,multiple:!!(e.repeat&&Ye(e.repeat)),minCount:(o=e.repeat)==null?void 0:o.min,maxCount:(i=e.repeat)==null?void 0:i.max};l.multiple?Nn(l,t,n):zn(l,t,n,r)}function Hn(e){var t,n;const r=e;return{type:"container",key:r.key,label:r.label,description:r.description,hint:r.hint,required:r.required,hidden:r.hidden,default:r.default,actions:r.actions,elements:r.elements,multiple:!!(r.repeat&&Ye(r.repeat)),minCount:(t=r.repeat)==null?void 0:t.min,maxCount:(n=r.repeat)==null?void 0:n.max}}function To(e,t,n){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field key: "${t}"`);const r=Hn(e);return qn(r,t,n)}function Ao(e,t,n,r){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field path: "${t}"`);const o=Hn(e);return Rn(o,t,n,r)}function Fo(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function Mo(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.top=="number"&&typeof t.left=="number"&&typeof t.bottom=="number"&&typeof t.right=="number"}function zo(e){return Fo(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:Mo(e)?e:null}function Re(e){return e.map(zo).filter(t=>t!==null)}function Bn(e,t){return Array.from({length:e},()=>Array.from({length:t},()=>""))}function Mt(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(o.top<0||o.left<0||o.bottom>=t||o.right>=n||o.top>o.bottom||o.left>o.right)return`Merge ${r} out of bounds`;for(let i=r+1;i<e.length;i++){const l=e[i];if(o.top<=l.bottom&&o.bottom>=l.top&&o.left<=l.right&&o.right>=l.left)return`Merges ${r} and ${i} overlap`}}return null}function Dn(e,t,n){for(const r of n){if(r.top===e&&r.left===t)return null;if(e>=r.top&&e<=r.bottom&&t>=r.left&&t<=r.right)return r}return null}function st(e,t,n){var r;return(r=n.find(o=>o.top===e&&o.left===t))!=null?r:null}function Le(e){var t;if(!e.anchor)return null;const n=(t=e.focus)!=null?t:e.anchor;return{r1:Math.min(e.anchor.row,n.row),c1:Math.min(e.anchor.col,n.col),r2:Math.max(e.anchor.row,n.row),c2:Math.max(e.anchor.col,n.col)}}function He(e){const t=document.createElement("button");return t.type="button",t.textContent=e.label,t.title=e.title,t.style.cssText=`
724
724
  position: absolute;
725
725
  width: ${e.size}px;
726
726
  height: ${e.size}px;
@@ -740,7 +740,7 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
740
740
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
741
741
  transition: transform 0.1s, opacity 0.1s;
742
742
  pointer-events: all;
743
- `,t.addEventListener("mouseenter",()=>{t.style.transform="scale(1.15)"}),t.addEventListener("mouseleave",()=>{t.style.transform="scale(1)"}),t.addEventListener("click",n=>{n.stopPropagation(),e.onClick(n)}),t}function Lo(e,t){const{cells:n,merges:r=[]}=e;if(n.length===0)return;const o=n[0].length,i=document.createElement("table");i.style.cssText=`
743
+ `,t.addEventListener("mouseenter",()=>{t.style.transform="scale(1.15)"}),t.addEventListener("mouseleave",()=>{t.style.transform="scale(1)"}),t.addEventListener("click",n=>{n.stopPropagation(),e.onClick(n)}),t}function No(e,t){const{cells:n,merges:r=[]}=e;if(n.length===0)return;const o=n[0].length,i=document.createElement("table");i.style.cssText=`
744
744
  width: 100%;
745
745
  border-collapse: collapse;
746
746
  border: var(--fb-border-width) solid var(--fb-border-color);
@@ -748,13 +748,13 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
748
748
  font-size: var(--fb-font-size);
749
749
  font-family: var(--fb-font-family);
750
750
  color: var(--fb-text-color);
751
- `,n.forEach((a,s)=>{var c,p;const u=(s===0?i.createTHead():(c=i.tBodies[0])!=null?c:i.createTBody()).insertRow();for(let d=0;d<o;d++){if(Rn(s,d,r))continue;const f=at(s,d,r),m=document.createElement(s===0?"th":"td");if(f){const b=f.bottom-f.top+1,y=f.right-f.left+1;b>1&&(m.rowSpan=b),y>1&&(m.colSpan=y)}m.textContent=(p=a[d])!=null?p:"",m.style.cssText=`
751
+ `,n.forEach((a,c)=>{var s,p;const u=(c===0?i.createTHead():(s=i.tBodies[0])!=null?s:i.createTBody()).insertRow();for(let f=0;f<o;f++){if(Dn(c,f,r))continue;const d=st(c,f,r),m=document.createElement(c===0?"th":"td");if(d){const v=d.bottom-d.top+1,y=d.right-d.left+1;v>1&&(m.rowSpan=v),y>1&&(m.colSpan=y)}m.textContent=(p=a[f])!=null?p:"",m.style.cssText=`
752
752
  padding: 6px 10px;
753
753
  border: var(--fb-border-width) solid var(--fb-border-color);
754
754
  text-align: left;
755
755
  vertical-align: top;
756
- ${s===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":""}
757
- `,u.appendChild(m)}});const l=document.createElement("div");l.style.cssText="overflow-x: auto; max-width: 100%;",l.appendChild(i),t.appendChild(l)}function So(e,t,n,r,o,i){if(e.contentEditable==="true")return;e.contentEditable="true",e.focus();const l=document.createRange(),a=window.getSelection();l.selectNodeContents(e),l.collapse(!1),a==null||a.removeAllRanges(),a==null||a.addRange(l);function s(){var u;e.contentEditable="inherit";const d=r();d[t]&&(d[t][n]=(u=e.textContent)!=null?u:""),o()}function c(u){var d,f,m,b;const y=r(),w=(f=(d=y[0])==null?void 0:d.length)!=null?f:0;if(u.key==="Escape"){e.contentEditable="inherit",e.textContent=(b=(m=y[t])==null?void 0:m[n])!=null?b:"",e.removeEventListener("keydown",c),e.removeEventListener("blur",p);return}if(u.key==="Enter"&&!u.shiftKey){u.preventDefault(),u.stopPropagation(),s(),e.removeEventListener("keydown",c),e.removeEventListener("blur",p);const v=t+1<y.length?t+1:t;i(v,n);return}if(u.key==="Tab"){u.preventDefault(),u.stopPropagation(),s(),e.removeEventListener("keydown",c),e.removeEventListener("blur",p);let v=t,h=u.shiftKey?n-1:n+1;h<0&&(h=w-1,v=Math.max(0,t-1)),h>=w&&(h=0,v=Math.min(y.length-1,t+1)),i(v,h)}}function p(){e.contentEditable==="true"&&(s(),e.removeEventListener("keydown",c),e.removeEventListener("blur",p))}e.addEventListener("keydown",c),e.addEventListener("blur",p)}function To(){if(document.getElementById("fb-spin-keyframes"))return;const e=document.createElement("style");e.id="fb-spin-keyframes",e.textContent="@keyframes fb-spin { to { transform: rotate(360deg); } }",document.head.appendChild(e)}function Fo(e,t){To();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
756
+ ${c===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":""}
757
+ `,u.appendChild(m)}});const l=document.createElement("div");l.style.cssText="overflow-x: auto; max-width: 100%;",l.appendChild(i),t.appendChild(l)}function Io(e,t,n,r,o,i){if(e.contentEditable==="true")return;e.contentEditable="true",e.focus();const l=document.createRange(),a=window.getSelection();l.selectNodeContents(e),l.collapse(!1),a==null||a.removeAllRanges(),a==null||a.addRange(l);function c(){var u;e.contentEditable="inherit";const f=r();f[t]&&(f[t][n]=(u=e.textContent)!=null?u:""),o()}function s(u){var f,d,m,v;const y=r(),C=(d=(f=y[0])==null?void 0:f.length)!=null?d:0;if(u.key==="Escape"){e.contentEditable="inherit",e.textContent=(v=(m=y[t])==null?void 0:m[n])!=null?v:"",e.removeEventListener("keydown",s),e.removeEventListener("blur",p);return}if(u.key==="Enter"&&!u.shiftKey){u.preventDefault(),u.stopPropagation(),c(),e.removeEventListener("keydown",s),e.removeEventListener("blur",p);const b=t+1<y.length?t+1:t;i(b,n);return}if(u.key==="Tab"){u.preventDefault(),u.stopPropagation(),c(),e.removeEventListener("keydown",s),e.removeEventListener("blur",p);let b=t,h=u.shiftKey?n-1:n+1;h<0&&(h=C-1,b=Math.max(0,t-1)),h>=C&&(h=0,b=Math.min(y.length-1,t+1)),i(b,h)}}function p(){e.contentEditable==="true"&&(c(),e.removeEventListener("keydown",s),e.removeEventListener("blur",p))}e.addEventListener("keydown",s),e.addEventListener("blur",p)}function qo(){if(document.getElementById("fb-spin-keyframes"))return;const e=document.createElement("style");e.id="fb-spin-keyframes",e.textContent="@keyframes fb-spin { to { transform: rotate(360deg); } }",document.head.appendChild(e)}function Ro(e,t){qo();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
758
758
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
759
759
  background: rgba(255,255,255,0.8); display: flex;
760
760
  align-items: center; justify-content: center; flex-direction: column;
@@ -763,13 +763,13 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
763
763
  width: 24px; height: 24px; border: 3px solid var(--fb-border-color, #ccc);
764
764
  border-top-color: var(--fb-primary-color, #0066cc); border-radius: 50%;
765
765
  animation: fb-spin 0.8s linear infinite;
766
- `;const o=document.createElement("span");return o.textContent=t,o.style.cssText="font-size: var(--fb-font-size-small, 12px); color: var(--fb-text-color, #333);",n.appendChild(r),n.appendChild(o),e.appendChild(n),n}function Ao(e,t,n,r,o){var i,l,a,s,c,p,u,d;const f=r.state,m=r.instance,b=e.mergeAllowed!==!1,y=(l=(i=e.fieldNames)==null?void 0:i.cells)!=null?l:"cells",w=(s=(a=e.fieldNames)==null?void 0:a.merges)!=null?s:"merges",v=t.cells.length>0?t.cells.map(F=>[...F]):In((c=e.rows)!=null?c:3,(p=e.columns)!=null?p:3);let h=t.merges?[...t.merges]:[];const g={anchor:null,focus:null,dragging:!1},E=document.createElement("input");E.type="hidden",E.name=n,E.value=JSON.stringify({[y]:v,[w]:h}),o.appendChild(E);function C(){E.value=JSON.stringify({[y]:v,[w]:h}),m&&m.triggerOnChange(n,{[y]:v,[w]:h})}E._applyExternalUpdate=F=>{v.length=0,F.cells.forEach(T=>v.push([...T])),h.length=0,F.merges&&F.merges.forEach(T=>h.push({...T})),g.anchor=null,g.focus=null,C(),M()};const x=document.createElement("div");x.style.cssText="position: relative; padding: 20px 20px 20px 24px; overflow-x: auto; max-width: 100%;";const k=document.createElement("table");k.style.cssText=`
766
+ `;const o=document.createElement("span");return o.textContent=t,o.style.cssText="font-size: var(--fb-font-size-small, 12px); color: var(--fb-text-color, #333);",n.appendChild(r),n.appendChild(o),e.appendChild(n),n}function Ho(e,t,n,r,o){var i,l,a,c,s,p,u,f;const d=r.state,m=r.instance,v=e.mergeAllowed!==!1,y=(l=(i=e.fieldNames)==null?void 0:i.cells)!=null?l:"cells",C=(c=(a=e.fieldNames)==null?void 0:a.merges)!=null?c:"merges",b=t.cells.length>0?t.cells.map(A=>[...A]):Bn((s=e.rows)!=null?s:3,(p=e.columns)!=null?p:3);let h=t.merges?[...t.merges]:[];const g={anchor:null,focus:null,dragging:!1},E=document.createElement("input");E.type="hidden",E.name=n,E.value=JSON.stringify({[y]:b,[C]:h}),o.appendChild(E);function w(){E.value=JSON.stringify({[y]:b,[C]:h}),m&&m.triggerOnChange(n,{[y]:b,[C]:h})}E._applyExternalUpdate=A=>{b.length=0,A.cells.forEach(T=>b.push([...T])),h.length=0,A.merges&&A.merges.forEach(T=>h.push({...T})),g.anchor=null,g.focus=null,w(),M()};const x=document.createElement("div");x.style.cssText="position: relative; padding: 20px 20px 20px 24px; overflow-x: auto; max-width: 100%;";const k=document.createElement("table");k.style.cssText=`
767
767
  border-collapse: collapse;
768
768
  font-size: var(--fb-font-size);
769
769
  font-family: var(--fb-font-family);
770
770
  color: var(--fb-text-color);
771
771
  table-layout: fixed;
772
- `,x.appendChild(k);const q=(d=(u=e.importAccept)==null?void 0:u.map(F=>`.${F.toLowerCase()}`))!=null?d:[];async function K(F){var T,S,B;if(!f.config.parseTableFile)return;if(q.length>0){const A=F.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!q.includes(A))return}const D=Fo(x,$("tableImporting",f));try{const A=await f.config.parseTableFile(F),Q=A.cells,O=(T=A.merges)!=null?T:[];if(O.length>0){const U=Ft(O,Q.length,(B=(S=Q[0])==null?void 0:S.length)!=null?B:0);if(U)throw new Error(U)}v.length=0,Q.forEach(U=>v.push([...U])),h.length=0,O.forEach(U=>h.push({...U})),g.anchor=null,g.focus=null,C(),M()}catch(A){const Q=A instanceof Error?A.message:String(A);console.error($("tableImportError",f).replace("{error}",Q))}finally{D.remove()}}if(e.importAccept&&f.config.parseTableFile){const F=document.createElement("button");F.type="button",F.title=$("tableImportFile",f),F.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"/></svg>',F.style.cssText=`
772
+ `,x.appendChild(k);const I=(f=(u=e.importAccept)==null?void 0:u.map(A=>`.${A.toLowerCase()}`))!=null?f:[];async function K(A){var T,S,B;if(!d.config.parseTableFile)return;if(I.length>0){const F=A.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!I.includes(F))return}const D=Ro(x,$("tableImporting",d));try{const F=await d.config.parseTableFile(A),Q=F.cells,O=(T=F.merges)!=null?T:[];if(O.length>0){const U=Mt(O,Q.length,(B=(S=Q[0])==null?void 0:S.length)!=null?B:0);if(U)throw new Error(U)}b.length=0,Q.forEach(U=>b.push([...U])),h.length=0,O.forEach(U=>h.push({...U})),g.anchor=null,g.focus=null,w(),M()}catch(F){const Q=F instanceof Error?F.message:String(F);console.error($("tableImportError",d).replace("{error}",Q))}finally{D.remove()}}if(e.importAccept&&d.config.parseTableFile){const A=document.createElement("button");A.type="button",A.title=$("tableImportFile",d),A.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"/></svg>',A.style.cssText=`
773
773
  position: absolute; top: 2px; left: 2px;
774
774
  width: 20px; height: 20px;
775
775
  padding: 0;
@@ -779,7 +779,7 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
779
779
  background: transparent;
780
780
  cursor: pointer;
781
781
  z-index: 2;
782
- `,F.addEventListener("mouseenter",()=>{F.style.color="var(--fb-primary-color, #0066cc)"}),F.addEventListener("mouseleave",()=>{F.style.color="var(--fb-text-color, #999)"});const T=document.createElement("input");T.type="file",T.accept=q.join(","),T.style.display="none",x.appendChild(T),F.addEventListener("click",()=>{T.click()}),T.addEventListener("change",()=>{var B;const D=(B=T.files)==null?void 0:B[0];D&&K(D),T.value=""}),x.appendChild(F);let S=0;x.addEventListener("dragenter",B=>{B.preventDefault(),S++,S===1&&(x.style.outline="2px dashed var(--fb-primary-color, #0066cc)",x.style.outlineOffset="-2px")}),x.addEventListener("dragover",B=>{B.preventDefault(),B.dataTransfer&&(B.dataTransfer.dropEffect="copy")}),x.addEventListener("dragleave",B=>{B.preventDefault(),S--,S<=0&&(S=0,x.style.outline="",x.style.outlineOffset="")}),x.addEventListener("drop",B=>{var D,A;B.preventDefault(),S=0,x.style.outline="",x.style.outlineOffset="";const Q=(A=(D=B.dataTransfer)==null?void 0:D.files)==null?void 0:A[0];Q&&K(Q)})}o.appendChild(x);const R=document.createElement("div");R.style.cssText=`
782
+ `,A.addEventListener("mouseenter",()=>{A.style.color="var(--fb-primary-color, #0066cc)"}),A.addEventListener("mouseleave",()=>{A.style.color="var(--fb-text-color, #999)"});const T=document.createElement("input");T.type="file",T.accept=I.join(","),T.style.display="none",x.appendChild(T),A.addEventListener("click",()=>{T.click()}),T.addEventListener("change",()=>{var B;const D=(B=T.files)==null?void 0:B[0];D&&K(D),T.value=""}),x.appendChild(A);let S=0;x.addEventListener("dragenter",B=>{B.preventDefault(),S++,S===1&&(x.style.outline="2px dashed var(--fb-primary-color, #0066cc)",x.style.outlineOffset="-2px")}),x.addEventListener("dragover",B=>{B.preventDefault(),B.dataTransfer&&(B.dataTransfer.dropEffect="copy")}),x.addEventListener("dragleave",B=>{B.preventDefault(),S--,S<=0&&(S=0,x.style.outline="",x.style.outlineOffset="")}),x.addEventListener("drop",B=>{var D,F;B.preventDefault(),S=0,x.style.outline="",x.style.outlineOffset="";const Q=(F=(D=B.dataTransfer)==null?void 0:D.files)==null?void 0:F[0];Q&&K(Q)})}o.appendChild(x);const R=document.createElement("div");R.style.cssText=`
783
783
  position: fixed;
784
784
  display: none;
785
785
  background: white;
@@ -790,7 +790,7 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
790
790
  z-index: 1000;
791
791
  gap: 4px;
792
792
  flex-direction: column;
793
- `,o.appendChild(R);function G(F,T){const S=document.createElement("button");return S.type="button",S.textContent=F,S.style.cssText=`
793
+ `,o.appendChild(R);function J(A,T){const S=document.createElement("button");return S.type="button",S.textContent=A,S.style.cssText=`
794
794
  padding: 4px 10px;
795
795
  font-size: var(--fb-font-size-small);
796
796
  color: var(--fb-text-color);
@@ -800,8 +800,8 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
800
800
  cursor: pointer;
801
801
  white-space: nowrap;
802
802
  text-align: left;
803
- `,S.addEventListener("mouseenter",()=>{S.style.background="var(--fb-background-hover-color)"}),S.addEventListener("mouseleave",()=>{S.style.background="transparent"}),S.addEventListener("click",()=>{oe(),T()}),S}function Z(F,T){if(!b)return;R.innerHTML="",R.style.display="flex";const S=Le(g),B=S&&(S.r1!==S.r2||S.c1!==S.c2),D=g.anchor&&at(g.anchor.row,g.anchor.col,h);if(B&&R.appendChild(G($("tableMergeCells",f),z)),D&&R.appendChild(G($("tableSplitCell",f),N)),!R.firstChild){oe();return}const A=140,Q=R.children.length*32+8,O=window.innerWidth,U=window.innerHeight,V=F+A>O?F-A:F,J=T+Q>U?T-Q:T;R.style.left=`${V}px`,R.style.top=`${J}px`}function oe(){R.style.display="none"}const Ae=new AbortController;document.addEventListener("mousedown",F=>{if(!o.isConnected){Ae.abort();return}R.contains(F.target)||oe()},{signal:Ae.signal});function fe(){const F=Le(g);k.querySelectorAll("td[data-row]").forEach(T=>{const S=parseInt(T.getAttribute("data-row")||"0",10),B=parseInt(T.getAttribute("data-col")||"0",10),D=g.anchor!==null&&g.anchor.row===S&&g.anchor.col===B,A=F!==null&&S>=F.r1&&S<=F.r2&&B>=F.c1&&B<=F.c2;T.style.outline=D?"2px solid var(--fb-primary-color, #0066cc)":"",T.style.outlineOffset=D?"-2px":"",S===0?T.style.backgroundColor="var(--fb-background-hover-color)":T.style.backgroundColor=A&&!D?"rgba(0,102,204,0.08)":""})}function Se(F,T){g.anchor={row:F,col:T},g.focus=null,fe(),k.focus()}function We(F,T){const S=k.querySelector(`td[data-row="${F}"][data-col="${T}"]`);if(!S)return;const B=S.querySelector("span");B&&(g.anchor={row:F,col:T},g.focus=null,fe(),So(B,F,T,()=>v,C,Se))}function Ce(F){var T;const S=v.length>0?v[0].length:(T=e.columns)!=null?T:3,B=Array(S).fill(""),D=F!==void 0?F+1:v.length;v.splice(D,0,B),h=h.map(A=>A.top>=D?{...A,top:A.top+1,bottom:A.bottom+1}:A.top<D&&A.bottom>=D?{...A,bottom:A.bottom+1}:A),C(),M()}function mt(F){if(v.length<=1)return;const T=F!==void 0?F:g.anchor?g.anchor.row:v.length-1;h=h.map(S=>S.top===T&&S.bottom===T?null:S.top===T?{...S,bottom:S.bottom-1}:S.bottom===T?{...S,bottom:S.bottom-1}:S.top<T&&S.bottom>T?{...S,bottom:S.bottom-1}:S.top>T?{...S,top:S.top-1,bottom:S.bottom-1}:S).filter(S=>S!==null),v.splice(T,1),g.anchor&&g.anchor.row>=v.length&&(g.anchor={row:v.length-1,col:g.anchor.col}),C(),M()}function Ke(F){var T,S;const B=F!==void 0?F+1:(S=(T=v[0])==null?void 0:T.length)!=null?S:0;v.forEach(D=>D.splice(B,0,"")),h=h.map(D=>D.left>=B?{...D,left:D.left+1,right:D.right+1}:D.left<B&&D.right>=B?{...D,right:D.right+1}:D),C(),M()}function L(F){if(v.length===0||v[0].length<=1)return;const T=F!==void 0?F:g.anchor?g.anchor.col:v[0].length-1;h=h.map(S=>S.left===T&&S.right===T?null:S.left===T?{...S,right:S.right-1}:S.right===T?{...S,right:S.right-1}:S.left<T&&S.right>T?{...S,right:S.right-1}:S.left>T?{...S,left:S.left-1,right:S.right-1}:S).filter(S=>S!==null),v.forEach(S=>S.splice(T,1)),g.anchor&&g.anchor.col>=v[0].length&&(g.anchor={row:g.anchor.row,col:v[0].length-1}),C(),M()}function z(){var F,T;if(!b)return;const S=Le(g);if(!S)return;const{r1:B,c1:D,r2:A,c2:Q}=S;if(B===A&&D===Q)return;h=h.filter(j=>!(j.top<=A&&j.bottom>=B&&j.left<=Q&&j.right>=D));const O=v[B][D];for(let j=B;j<=A;j++)for(let Y=D;Y<=Q;Y++)(j!==B||Y!==D)&&(v[j][Y]="");v[B][D]=O;const U={top:B,left:D,bottom:A,right:Q},V=[...h,U],J=Ft(V,v.length,(T=(F=v[0])==null?void 0:F.length)!=null?T:0);if(J){console.warn("Merge validation failed:",J);return}h.push(U),g.anchor={row:B,col:D},g.focus=null,C(),M()}function N(){if(!b||!g.anchor)return;const{row:F,col:T}=g.anchor,S=h.findIndex(B=>B.top===F&&B.left===T);S!==-1&&(h.splice(S,1),g.focus=null,C(),M())}function M(){var F,T;k.innerHTML="";const S=v.length,B=S>0?v[0].length:0,D=Le(g);for(let A=0;A<S;A++){const Q=(A===0?(F=k.tHead)!=null?F:k.createTHead():(T=k.tBodies[0])!=null?T:k.createTBody()).insertRow();for(let O=0;O<B;O++){if(Rn(A,O,h))continue;const U=at(A,O,h),V=document.createElement("td");if(V.setAttribute("data-row",String(A)),V.setAttribute("data-col",String(O)),U){const X=U.bottom-U.top+1,W=U.right-U.left+1;X>1&&(V.rowSpan=X),W>1&&(V.colSpan=W)}const J=D!==null&&A>=D.r1&&A<=D.r2&&O>=D.c1&&O<=D.c2,j=g.anchor!==null&&g.anchor.row===A&&g.anchor.col===O;V.style.cssText=["border: var(--fb-border-width) solid var(--fb-border-color);","padding: 4px 8px;","min-width: 80px;","vertical-align: top;","cursor: text;","position: relative;",A===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":"",J&&!j?"background-color: rgba(0,102,204,0.08);":"",j?"outline: 2px solid var(--fb-primary-color, #0066cc); outline-offset: -2px;":""].join(" ");const Y=document.createElement("span");Y.textContent=v[A][O],Y.style.cssText="display: block; min-height: 1.4em; white-space: pre-wrap; word-break: break-word; outline: none;",V.appendChild(Y);const _=A,ne=O;V.addEventListener("mousedown",X=>{if(X.target.tagName!=="BUTTON"&&X.target.contentEditable!=="true"){if(X.button===2){const W=Le(g);if(W&&_>=W.r1&&_<=W.r2&&ne>=W.c1&&ne<=W.c2)return}X.shiftKey&&g.anchor?(X.preventDefault(),g.focus={row:_,col:ne},g.dragging=!1,fe()):(g.anchor={row:_,col:ne},g.focus=null,g.dragging=!0,fe())}}),V.addEventListener("mouseup",X=>{if(X.target.tagName!=="BUTTON"&&g.dragging){g.dragging=!1;const W=Le(g);(!W||W.r1===W.r2&&W.c1===W.c2)&&We(_,ne)}}),V.addEventListener("mousemove",X=>{if(g.dragging&&X.buttons===1){const W=g.anchor;W&&(W.row!==_||W.col!==ne)&&(g.focus={row:_,col:ne},fe())}}),V.addEventListener("contextmenu",X=>{if(!b)return;const W=Le(g),ue=W&&(W.r1!==W.r2||W.c1!==W.c2),ce=g.anchor&&at(g.anchor.row,g.anchor.col,h);(ue||ce)&&(X.preventDefault(),Z(X.clientX,X.clientY))}),Q.appendChild(V)}}pe(),k.setAttribute("tabindex","0"),k.onkeydown=A=>{var Q,O;if(k.querySelector("[contenteditable='true']"))return;const U=g.anchor;if(!U)return;const V=v.length,J=V>0?v[0].length:0,j={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]};if(j[A.key]){A.preventDefault();const[Y,_]=j[A.key],ne=Math.max(0,Math.min(V-1,U.row+Y)),X=Math.max(0,Math.min(J-1,U.col+_));A.shiftKey?(g.focus={row:ne,col:X},fe()):Se(ne,X);return}if(A.key==="Enter"){A.preventDefault(),We(U.row,U.col);return}if(A.key==="Tab"){A.preventDefault();const Y=(O=(Q=v[0])==null?void 0:Q.length)!=null?O:0;let _=U.row,ne=A.shiftKey?U.col-1:U.col+1;ne<0&&(ne=Y-1,_=Math.max(0,_-1)),ne>=Y&&(ne=0,_=Math.min(v.length-1,_+1)),Se(_,ne);return}if(b&&A.key==="m"&&A.ctrlKey&&!A.shiftKey){A.preventDefault(),z();return}b&&A.key==="M"&&A.ctrlKey&&A.shiftKey&&(A.preventDefault(),N())},k.oncopy=A=>{var Q,O,U,V;const J=Le(g);if(!J)return;A.preventDefault();const{r1:j,c1:Y,r2:_,c2:ne}=J,X=[],W=[];for(let P=j;P<=_;P++){const se=[],me=[];for(let he=Y;he<=ne;he++){const ye=(O=(Q=v[P])==null?void 0:Q[he])!=null?O:"";se.push(ye);const Me=ye.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");me.push(`<td>${Me}</td>`)}X.push(se.join(" ")),W.push(`<tr>${me.join("")}</tr>`)}const ue=X.join(`
804
- `),ce=`<table>${W.join("")}</table>`;(U=A.clipboardData)==null||U.setData("text/plain",ue),(V=A.clipboardData)==null||V.setData("text/html",ce)},k.onpaste=A=>{var Q,O,U,V,J,j,Y,_,ne;const X=g.anchor;if(!X)return;const W=(O=(Q=A.clipboardData)==null?void 0:Q.getData("text/plain"))!=null?O:"",ue=W.includes(" ")||W.split(/\r?\n/).filter(de=>de).length>1,ce=k.querySelector("[contenteditable='true']");if(ce&&!ue)return;if(A.preventDefault(),ce){ce.contentEditable="inherit";const de=parseInt((V=(U=ce.closest("td"))==null?void 0:U.getAttribute("data-row"))!=null?V:"0",10),Te=parseInt((j=(J=ce.closest("td"))==null?void 0:J.getAttribute("data-col"))!=null?j:"0",10);v[de]&&(v[de][Te]=(Y=ce.textContent)!=null?Y:"")}if(!W.trim())return;const P=W.split(/\r?\n/).map(de=>de.split(" "));P.length>1&&P[P.length-1].length===1&&P[P.length-1][0]===""&&P.pop();const se=X.row,me=X.col,he=se+P.length;for(;v.length<he;)v.push(Array((ne=(_=v[0])==null?void 0:_.length)!=null?ne:1).fill(""));const ye=Math.max(...P.map(de=>de.length)),Me=me+ye;if(v[0]&&Me>v[0].length){const de=Me-v[0].length;v.forEach(Te=>{for(let _e=0;_e<de;_e++)Te.push("")})}for(let de=0;de<P.length;de++)for(let Te=0;Te<P[de].length;Te++){const _e=se+de,sl=me+Te;v[_e]&&(v[_e][sl]=P[de][Te])}C(),M()}}const I=He({label:"+",title:$("tableAddColumn",f),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var F;const T=parseInt((F=I.dataset.afterCol)!=null?F:"0",10);Ke(T)}});I.style.position="absolute",I.style.display="none",x.appendChild(I);const H=He({label:"+",title:$("tableAddRow",f),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var F;const T=parseInt((F=H.dataset.afterRow)!=null?F:"0",10);Ce(T)}});H.style.position="absolute",H.style.display="none",x.appendChild(H);let ee=[],te=[];const ae=He({label:"+",title:$("tableAddColumn",f),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>Ke()});ae.style.position="absolute",ae.style.display="none",x.appendChild(ae);const ie=He({label:"+",title:$("tableAddRow",f),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>Ce()});ie.style.position="absolute",ie.style.display="none",x.appendChild(ie);function pe(){var F,T;ee.forEach(O=>O.remove()),ee=[],te.forEach(O=>O.remove()),te=[];const S=v.length>0?v[0].length:0,B=v.length;if(S>1){const O=Array.from(k.querySelectorAll("thead td[data-col]"));for(const U of O){const V=parseInt((F=U.getAttribute("data-col"))!=null?F:"0",10),J=He({label:"\xD7",title:$("tableRemoveColumn",f),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>L(V)});J.setAttribute("data-action","remove-col"),J.setAttribute("data-col",String(V)),J.style.position="absolute",J.style.display="none",x.appendChild(J),ee.push(J)}}if(B>1){const O=[...k.tHead?Array.from(k.tHead.rows):[],...k.tBodies[0]?Array.from(k.tBodies[0].rows):[]].filter(U=>U.querySelector("td[data-row]"));for(const U of O){const V=U.querySelector("td[data-row]");if(!V)continue;const J=parseInt((T=V.getAttribute("data-row"))!=null?T:"0",10),j=He({label:"\xD7",title:$("tableRemoveRow",f),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>mt(J)});j.setAttribute("data-action","remove-row"),j.setAttribute("data-row",String(J)),j.style.position="absolute",j.style.display="none",x.appendChild(j),te.push(j)}}function D(O,U,V,J,j){var Y;const _=j?Array.from(k.querySelectorAll("thead td[data-col]")):[];let ne=-1,X=1/0,W=-1,ue=-1,ce=1/0;for(let P=0;P<_.length;P++){const se=_[P].getBoundingClientRect(),me=(se.left+se.right)/2,he=Math.abs(O-me);he<X&&(X=he,ne=P);const ye=Math.abs(O-se.right);ye<ce&&ye<20&&(ce=ye,W=se.right-U.left+J,ue=parseInt((Y=_[P].getAttribute("data-col"))!=null?Y:"0",10))}ee.forEach((P,se)=>{if(!j||se!==ne){P.style.display="none";return}const me=_[se].getBoundingClientRect(),he=(me.left+me.right)/2-U.left+J;P.style.left=`${he-8}px`,P.style.top="2px",P.style.display="flex"}),j&&ue>=0?(I.style.display="flex",I.style.left=`${W-10}px`,I.style.top=`${V.top-U.top-10}px`,I.dataset.afterCol=String(ue)):I.style.display="none"}function A(O,U,V,J,j){var Y;const _=[];if(j){if(k.tHead)for(const P of Array.from(k.tHead.rows))P.querySelector("td[data-row]")&&_.push(P);if(k.tBodies[0])for(const P of Array.from(k.tBodies[0].rows))P.querySelector("td[data-row]")&&_.push(P)}let ne=-1,X=1/0,W=-1,ue=-1,ce=1/0;for(let P=0;P<_.length;P++){const se=_[P].getBoundingClientRect(),me=(se.top+se.bottom)/2,he=Math.abs(O-me);he<X&&(X=he,ne=P);const ye=Math.abs(O-se.bottom);if(ye<ce&&ye<14){ce=ye,W=se.bottom-U.top;const Me=_[P].querySelector("td[data-row]");ue=parseInt((Y=Me==null?void 0:Me.getAttribute("data-row"))!=null?Y:"0",10)}}te.forEach((P,se)=>{if(!j||se!==ne){P.style.display="none";return}const me=_[se].getBoundingClientRect(),he=(me.top+me.bottom)/2-U.top;P.style.left="4px",P.style.top=`${he-8}px`,P.style.display="flex"}),j&&ue>=0?(H.style.display="flex",H.style.top=`${W-10}px`,H.style.left=`${V.left-U.left+J-10}px`,H.dataset.afterRow=String(ue)):H.style.display="none"}let Q=!1;x.onmousemove=O=>{const U=O.target;if(U.tagName==="BUTTON"&&U.parentElement===x||Q)return;Q=!0;const V=O.clientX,J=O.clientY;requestAnimationFrame(()=>{Q=!1;const j=x.getBoundingClientRect(),Y=k.getBoundingClientRect(),_=x.scrollLeft,ne=J>=j.top&&J<Y.top+4,X=V>=j.left&&V<Y.left+4,W=Math.min(Y.right,j.right),ue=V>W-20&&V<=j.right,ce=J>Y.bottom-4&&J<=j.bottom+20;if(D(V,j,Y,_,ne),A(J,j,Y,_,X),ae.style.display=ue?"flex":"none",ue&&(ae.style.left=`${j.right-j.left+_-20}px`,ae.style.top=`${(Y.top+Y.bottom)/2-j.top-10}px`),ie.style.display=ce?"flex":"none",ce){const P=(j.left+j.right)/2-j.left+_;ie.style.left=`${P-10}px`,ie.style.top=`${Y.bottom-j.top-10}px`}})},x.onmouseleave=()=>{ee.forEach(O=>{O.style.display="none"}),te.forEach(O=>{O.style.display="none"}),I.style.display="none",H.style.display="none",ae.style.display="none",ie.style.display="none"}}M()}function Mo(e){var t,n;return{cells:In((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function At(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function Mt(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function No(e,t,n,r){var o,i,l,a;const s=t.state,c=le(e,s,t),p=t.prefill[e.key],u=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",d=(a=(l=e.fieldNames)==null?void 0:l.merges)!=null?a:"merges";let f;if(At(p))f={cells:p.cells,merges:p.merges?Re(p.merges):[]};else if(p&&Mt(p,u)){const m=p[d];f={cells:p[u],merges:m?Re(m):[]}}else if(At(e.default))f={cells:e.default.cells,merges:e.default.merges?Re(e.default.merges):[]};else if(e.default&&Mt(e.default,u)){const m=e.default[d];f={cells:e.default[u],merges:m?Re(m):[]}}else f=Mo(e);if(f.merges&&f.merges.length>0){const m=f.cells.length,b=m>0?f.cells[0].length:0,y=Ft(f.merges,m,b);y&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${y})`),f={...f,merges:[]})}c?Lo(f,n):Ao(e,f,r,t,n)}function zo(e,t,n){var r,o;const{scopeRoot:i,skipValidation:l}=n,a=[],s=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",c=i.querySelector(`[name="${t}"]`);if(!c)return{value:null,errors:a};let p=null;try{p=JSON.parse(c.value)}catch(u){return a.push(`${t}: invalid table data`),{value:null,errors:a}}if(!l&&e.required){const u=p[s];u!=null&&u.some(d=>d.some(f=>f.trim()!==""))||a.push(`${t}: ${$("required",n.state)}`)}return{value:p,errors:a}}function qo(e,t,n,r){var o,i,l,a;const{scopeRoot:s}=r,c=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",p=(a=(l=e.fieldNames)==null?void 0:l.merges)!=null?a:"merges",u=s.querySelector(`[name="${t}"]`);if(!u){console.warn(`updateTableField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let d=null;if(At(n))d={cells:n.cells,merges:n.merges?Re(n.merges):[]};else if(n&&Mt(n,c)){const f=n[p];d={cells:n[c],merges:f?Re(f):[]}}d&&u._applyExternalUpdate?u._applyExternalUpdate(d):u.value=JSON.stringify(n)}function Io(e,t){e.style.overflow="hidden",e.style.resize="none";const n=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(3,n);const r=()=>{e.isConnected&&(e.style.height="0",e.style.height=`${e.scrollHeight}px`,t&&(t.style.height=`${e.scrollHeight}px`))};e.addEventListener("input",r),setTimeout(()=>{e.isConnected&&r()},0)}function Nt(e,t){var n,r,o,i;const l=new Map,a=new Map;for(const s of e){const c=t.resourceIndex.get(s),p=(n=c==null?void 0:c.name)!=null?n:s;a.set(p,((r=a.get(p))!=null?r:0)+1)}for(const s of e){const c=t.resourceIndex.get(s),p=(o=c==null?void 0:c.name)!=null?o:s;((i=a.get(p))!=null?i:1)>1&&c?l.set(s,`${p} (${tr(c.size)})`):l.set(s,p)}return l}function zt(e){return e?e.type.startsWith("image/"):!1}function Hn(e,t){const n=Nt(e,t),r=new Map;for(const o of e){const i=n.get(o);i&&r.set(i,o)}return r}function qt(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function st(e){const t=[],n=e.length;let r=0;for(;r<n;)if(e[r]==="@"){if(r>0&&!/\s/.test(e[r-1])){r++;continue}const o=r;if(r++,r<n&&e[r]==='"'){r++;let i="";for(;r<n&&e[r]!=='"';)e[r]==="\\"&&r+1<n?(i+=e[r+1],r+=2):(i+=e[r],r++);r<n&&e[r]==='"'&&(r++,(r>=n||/\s/.test(e[r]))&&t.push({start:o,end:r,raw:e.slice(o,r),name:i}))}else if(r<n&&!/\s/.test(e[r])){const i=r;for(;r<n&&!/\s/.test(e[r]);)r++;const l=e.slice(i,r);t.push({start:o,end:r,raw:e.slice(o,r),name:l})}}else r++;return t}function Ro(e,t){if(t.size===0)return[];const n=st(e),r=[];for(const o of n){const i=t.get(o.name);i&&r.push({start:o.start,end:o.end,name:o.name,rid:i})}return r}function Ho(e,t){const n=Ro(e,t);if(n.length===0)return e;let r="",o=0;for(const i of n)r+=e.slice(o,i.start),r+=`@${i.rid}`,o=i.end;return r+=e.slice(o),r}function Bn(e,t,n){const r=Nt(t,n),o=new Map;for(const s of t){const c=r.get(s);c&&o.set(s,c)}const i=st(e);if(i.length===0)return e;let l="",a=0;for(const s of i){l+=e.slice(a,s.start);const c=o.get(s.name);c?l+=qt(c):l+=s.raw,a=s.end}return l+=e.slice(a),l}function Dn(e,t,n,r){if(be(e),n!=null&&n.file&&zt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const i=new FileReader;i.onload=l=>{var a;o.src=((a=l.target)==null?void 0:a.result)||""},i.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(i=>{var l;if(!i||!e.isConnected)return;const a=document.createElement("img");a.alt=(l=n==null?void 0:n.name)!=null?l:t,a.src=i,a.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",be(e),e.appendChild(a)}).catch(i=>{var l,a;(a=(l=r.config).onThumbnailError)==null||a.call(l,i,t)});const o=document.createElement("div");o.style.cssText="width: 100%; height: 100%; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',e.appendChild(o)}else{const o=document.createElement("div");if(o.style.cssText="width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px; box-sizing: border-box;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>',n!=null&&n.name){const i=document.createElement("span");i.style.cssText="font-size: 9px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 44px; color: var(--fb-text-color, #111827);",i.textContent=n.name,o.appendChild(i)}e.appendChild(o)}}function jn(e,t,n,r){if(be(e),n!=null&&n.file&&zt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;";const i=new FileReader;i.onload=l=>{var a;o.src=((a=l.target)==null?void 0:a.result)||""},i.readAsDataURL(n.file),e.appendChild(o)}else r.config.getThumbnail&&r.config.getThumbnail(t).then(o=>{var i;if(!o||!e.isConnected)return;const l=document.createElement("img");l.alt=(i=n==null?void 0:n.name)!=null?i:t,l.src=o,l.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",be(e),e.appendChild(l)}).catch(o=>{var i,l;(l=(i=r.config).onThumbnailError)==null||l.call(i,o,t)})}function On(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=Math.max(4,Math.min(n.left+n.width/2-r.width/2,window.innerWidth-r.width-4)),i=n.top-r.height-8,l=n.bottom+8,a=i>=4?i:l;e.style.left=`${o}px`,e.style.top=`${Math.max(4,a)}px`}function Un(e,t,n){const r=n.resourceIndex.get(t),o=document.createElement("div");o.className="fb-richinput-portal-tooltip fb-richinput-mention-tooltip",o.style.cssText=`
803
+ `,S.addEventListener("mouseenter",()=>{S.style.background="var(--fb-background-hover-color)"}),S.addEventListener("mouseleave",()=>{S.style.background="transparent"}),S.addEventListener("click",()=>{re(),T()}),S}function X(A,T){if(!v)return;R.innerHTML="",R.style.display="flex";const S=Le(g),B=S&&(S.r1!==S.r2||S.c1!==S.c2),D=g.anchor&&st(g.anchor.row,g.anchor.col,h);if(B&&R.appendChild(J($("tableMergeCells",d),N)),D&&R.appendChild(J($("tableSplitCell",d),z)),!R.firstChild){re();return}const F=140,Q=R.children.length*32+8,O=window.innerWidth,U=window.innerHeight,V=A+F>O?A-F:A,Y=T+Q>U?T-Q:T;R.style.left=`${V}px`,R.style.top=`${Y}px`}function re(){R.style.display="none"}const Fe=new AbortController;document.addEventListener("mousedown",A=>{if(!o.isConnected){Fe.abort();return}R.contains(A.target)||re()},{signal:Fe.signal});function fe(){const A=Le(g);k.querySelectorAll("td[data-row]").forEach(T=>{const S=parseInt(T.getAttribute("data-row")||"0",10),B=parseInt(T.getAttribute("data-col")||"0",10),D=g.anchor!==null&&g.anchor.row===S&&g.anchor.col===B,F=A!==null&&S>=A.r1&&S<=A.r2&&B>=A.c1&&B<=A.c2;T.style.outline=D?"2px solid var(--fb-primary-color, #0066cc)":"",T.style.outlineOffset=D?"-2px":"",S===0?T.style.backgroundColor="var(--fb-background-hover-color)":T.style.backgroundColor=F&&!D?"rgba(0,102,204,0.08)":""})}function Se(A,T){g.anchor={row:A,col:T},g.focus=null,fe(),k.focus()}function Ke(A,T){const S=k.querySelector(`td[data-row="${A}"][data-col="${T}"]`);if(!S)return;const B=S.querySelector("span");B&&(g.anchor={row:A,col:T},g.focus=null,fe(),Io(B,A,T,()=>b,w,Se))}function we(A){var T;const S=b.length>0?b[0].length:(T=e.columns)!=null?T:3,B=Array(S).fill(""),D=A!==void 0?A+1:b.length;b.splice(D,0,B),h=h.map(F=>F.top>=D?{...F,top:F.top+1,bottom:F.bottom+1}:F.top<D&&F.bottom>=D?{...F,bottom:F.bottom+1}:F),w(),M()}function ht(A){if(b.length<=1)return;const T=A!==void 0?A:g.anchor?g.anchor.row:b.length-1;h=h.map(S=>S.top===T&&S.bottom===T?null:S.top===T?{...S,bottom:S.bottom-1}:S.bottom===T?{...S,bottom:S.bottom-1}:S.top<T&&S.bottom>T?{...S,bottom:S.bottom-1}:S.top>T?{...S,top:S.top-1,bottom:S.bottom-1}:S).filter(S=>S!==null),b.splice(T,1),g.anchor&&g.anchor.row>=b.length&&(g.anchor={row:b.length-1,col:g.anchor.col}),w(),M()}function _e(A){var T,S;const B=A!==void 0?A+1:(S=(T=b[0])==null?void 0:T.length)!=null?S:0;b.forEach(D=>D.splice(B,0,"")),h=h.map(D=>D.left>=B?{...D,left:D.left+1,right:D.right+1}:D.left<B&&D.right>=B?{...D,right:D.right+1}:D),w(),M()}function L(A){if(b.length===0||b[0].length<=1)return;const T=A!==void 0?A:g.anchor?g.anchor.col:b[0].length-1;h=h.map(S=>S.left===T&&S.right===T?null:S.left===T?{...S,right:S.right-1}:S.right===T?{...S,right:S.right-1}:S.left<T&&S.right>T?{...S,right:S.right-1}:S.left>T?{...S,left:S.left-1,right:S.right-1}:S).filter(S=>S!==null),b.forEach(S=>S.splice(T,1)),g.anchor&&g.anchor.col>=b[0].length&&(g.anchor={row:g.anchor.row,col:b[0].length-1}),w(),M()}function N(){var A,T;if(!v)return;const S=Le(g);if(!S)return;const{r1:B,c1:D,r2:F,c2:Q}=S;if(B===F&&D===Q)return;h=h.filter(j=>!(j.top<=F&&j.bottom>=B&&j.left<=Q&&j.right>=D));const O=b[B][D];for(let j=B;j<=F;j++)for(let G=D;G<=Q;G++)(j!==B||G!==D)&&(b[j][G]="");b[B][D]=O;const U={top:B,left:D,bottom:F,right:Q},V=[...h,U],Y=Mt(V,b.length,(T=(A=b[0])==null?void 0:A.length)!=null?T:0);if(Y){console.warn("Merge validation failed:",Y);return}h.push(U),g.anchor={row:B,col:D},g.focus=null,w(),M()}function z(){if(!v||!g.anchor)return;const{row:A,col:T}=g.anchor,S=h.findIndex(B=>B.top===A&&B.left===T);S!==-1&&(h.splice(S,1),g.focus=null,w(),M())}function M(){var A,T;k.innerHTML="";const S=b.length,B=S>0?b[0].length:0,D=Le(g);for(let F=0;F<S;F++){const Q=(F===0?(A=k.tHead)!=null?A:k.createTHead():(T=k.tBodies[0])!=null?T:k.createTBody()).insertRow();for(let O=0;O<B;O++){if(Dn(F,O,h))continue;const U=st(F,O,h),V=document.createElement("td");if(V.setAttribute("data-row",String(F)),V.setAttribute("data-col",String(O)),U){const Z=U.bottom-U.top+1,W=U.right-U.left+1;Z>1&&(V.rowSpan=Z),W>1&&(V.colSpan=W)}const Y=D!==null&&F>=D.r1&&F<=D.r2&&O>=D.c1&&O<=D.c2,j=g.anchor!==null&&g.anchor.row===F&&g.anchor.col===O;V.style.cssText=["border: var(--fb-border-width) solid var(--fb-border-color);","padding: 4px 8px;","min-width: 80px;","vertical-align: top;","cursor: text;","position: relative;",F===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":"",Y&&!j?"background-color: rgba(0,102,204,0.08);":"",j?"outline: 2px solid var(--fb-primary-color, #0066cc); outline-offset: -2px;":""].join(" ");const G=document.createElement("span");G.textContent=b[F][O],G.style.cssText="display: block; min-height: 1.4em; white-space: pre-wrap; word-break: break-word; outline: none;",V.appendChild(G);const _=F,ne=O;V.addEventListener("mousedown",Z=>{if(Z.target.tagName!=="BUTTON"&&Z.target.contentEditable!=="true"){if(Z.button===2){const W=Le(g);if(W&&_>=W.r1&&_<=W.r2&&ne>=W.c1&&ne<=W.c2)return}Z.shiftKey&&g.anchor?(Z.preventDefault(),g.focus={row:_,col:ne},g.dragging=!1,fe()):(g.anchor={row:_,col:ne},g.focus=null,g.dragging=!0,fe())}}),V.addEventListener("mouseup",Z=>{if(Z.target.tagName!=="BUTTON"&&g.dragging){g.dragging=!1;const W=Le(g);(!W||W.r1===W.r2&&W.c1===W.c2)&&Ke(_,ne)}}),V.addEventListener("mousemove",Z=>{if(g.dragging&&Z.buttons===1){const W=g.anchor;W&&(W.row!==_||W.col!==ne)&&(g.focus={row:_,col:ne},fe())}}),V.addEventListener("contextmenu",Z=>{if(!v)return;const W=Le(g),ue=W&&(W.r1!==W.r2||W.c1!==W.c2),ce=g.anchor&&st(g.anchor.row,g.anchor.col,h);(ue||ce)&&(Z.preventDefault(),X(Z.clientX,Z.clientY))}),Q.appendChild(V)}}pe(),k.setAttribute("tabindex","0"),k.onkeydown=F=>{var Q,O;if(k.querySelector("[contenteditable='true']"))return;const U=g.anchor;if(!U)return;const V=b.length,Y=V>0?b[0].length:0,j={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]};if(j[F.key]){F.preventDefault();const[G,_]=j[F.key],ne=Math.max(0,Math.min(V-1,U.row+G)),Z=Math.max(0,Math.min(Y-1,U.col+_));F.shiftKey?(g.focus={row:ne,col:Z},fe()):Se(ne,Z);return}if(F.key==="Enter"){F.preventDefault(),Ke(U.row,U.col);return}if(F.key==="Tab"){F.preventDefault();const G=(O=(Q=b[0])==null?void 0:Q.length)!=null?O:0;let _=U.row,ne=F.shiftKey?U.col-1:U.col+1;ne<0&&(ne=G-1,_=Math.max(0,_-1)),ne>=G&&(ne=0,_=Math.min(b.length-1,_+1)),Se(_,ne);return}if(v&&F.key==="m"&&F.ctrlKey&&!F.shiftKey){F.preventDefault(),N();return}v&&F.key==="M"&&F.ctrlKey&&F.shiftKey&&(F.preventDefault(),z())},k.oncopy=F=>{var Q,O,U,V;const Y=Le(g);if(!Y)return;F.preventDefault();const{r1:j,c1:G,r2:_,c2:ne}=Y,Z=[],W=[];for(let P=j;P<=_;P++){const se=[],me=[];for(let he=G;he<=ne;he++){const ye=(O=(Q=b[P])==null?void 0:Q[he])!=null?O:"";se.push(ye);const Me=ye.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");me.push(`<td>${Me}</td>`)}Z.push(se.join(" ")),W.push(`<tr>${me.join("")}</tr>`)}const ue=Z.join(`
804
+ `),ce=`<table>${W.join("")}</table>`;(U=F.clipboardData)==null||U.setData("text/plain",ue),(V=F.clipboardData)==null||V.setData("text/html",ce)},k.onpaste=F=>{var Q,O,U,V,Y,j,G,_,ne;const Z=g.anchor;if(!Z)return;const W=(O=(Q=F.clipboardData)==null?void 0:Q.getData("text/plain"))!=null?O:"",ue=W.includes(" ")||W.split(/\r?\n/).filter(de=>de).length>1,ce=k.querySelector("[contenteditable='true']");if(ce&&!ue)return;if(F.preventDefault(),ce){ce.contentEditable="inherit";const de=parseInt((V=(U=ce.closest("td"))==null?void 0:U.getAttribute("data-row"))!=null?V:"0",10),Te=parseInt((j=(Y=ce.closest("td"))==null?void 0:Y.getAttribute("data-col"))!=null?j:"0",10);b[de]&&(b[de][Te]=(G=ce.textContent)!=null?G:"")}if(!W.trim())return;const P=W.split(/\r?\n/).map(de=>de.split(" "));P.length>1&&P[P.length-1].length===1&&P[P.length-1][0]===""&&P.pop();const se=Z.row,me=Z.col,he=se+P.length;for(;b.length<he;)b.push(Array((ne=(_=b[0])==null?void 0:_.length)!=null?ne:1).fill(""));const ye=Math.max(...P.map(de=>de.length)),Me=me+ye;if(b[0]&&Me>b[0].length){const de=Me-b[0].length;b.forEach(Te=>{for(let Je=0;Je<de;Je++)Te.push("")})}for(let de=0;de<P.length;de++)for(let Te=0;Te<P[de].length;Te++){const Je=se+de,Cl=me+Te;b[Je]&&(b[Je][Cl]=P[de][Te])}w(),M()}}const q=He({label:"+",title:$("tableAddColumn",d),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=q.dataset.afterCol)!=null?A:"0",10);_e(T)}});q.style.position="absolute",q.style.display="none",x.appendChild(q);const H=He({label:"+",title:$("tableAddRow",d),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=H.dataset.afterRow)!=null?A:"0",10);we(T)}});H.style.position="absolute",H.style.display="none",x.appendChild(H);let ee=[],te=[];const ae=He({label:"+",title:$("tableAddColumn",d),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>_e()});ae.style.position="absolute",ae.style.display="none",x.appendChild(ae);const ie=He({label:"+",title:$("tableAddRow",d),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>we()});ie.style.position="absolute",ie.style.display="none",x.appendChild(ie);function pe(){var A,T;ee.forEach(O=>O.remove()),ee=[],te.forEach(O=>O.remove()),te=[];const S=b.length>0?b[0].length:0,B=b.length;if(S>1){const O=Array.from(k.querySelectorAll("thead td[data-col]"));for(const U of O){const V=parseInt((A=U.getAttribute("data-col"))!=null?A:"0",10),Y=He({label:"\xD7",title:$("tableRemoveColumn",d),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>L(V)});Y.setAttribute("data-action","remove-col"),Y.setAttribute("data-col",String(V)),Y.style.position="absolute",Y.style.display="none",x.appendChild(Y),ee.push(Y)}}if(B>1){const O=[...k.tHead?Array.from(k.tHead.rows):[],...k.tBodies[0]?Array.from(k.tBodies[0].rows):[]].filter(U=>U.querySelector("td[data-row]"));for(const U of O){const V=U.querySelector("td[data-row]");if(!V)continue;const Y=parseInt((T=V.getAttribute("data-row"))!=null?T:"0",10),j=He({label:"\xD7",title:$("tableRemoveRow",d),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>ht(Y)});j.setAttribute("data-action","remove-row"),j.setAttribute("data-row",String(Y)),j.style.position="absolute",j.style.display="none",x.appendChild(j),te.push(j)}}function D(O,U,V,Y,j){var G;const _=j?Array.from(k.querySelectorAll("thead td[data-col]")):[];let ne=-1,Z=1/0,W=-1,ue=-1,ce=1/0;for(let P=0;P<_.length;P++){const se=_[P].getBoundingClientRect(),me=(se.left+se.right)/2,he=Math.abs(O-me);he<Z&&(Z=he,ne=P);const ye=Math.abs(O-se.right);ye<ce&&ye<20&&(ce=ye,W=se.right-U.left+Y,ue=parseInt((G=_[P].getAttribute("data-col"))!=null?G:"0",10))}ee.forEach((P,se)=>{if(!j||se!==ne){P.style.display="none";return}const me=_[se].getBoundingClientRect(),he=(me.left+me.right)/2-U.left+Y;P.style.left=`${he-8}px`,P.style.top="2px",P.style.display="flex"}),j&&ue>=0?(q.style.display="flex",q.style.left=`${W-10}px`,q.style.top=`${V.top-U.top-10}px`,q.dataset.afterCol=String(ue)):q.style.display="none"}function F(O,U,V,Y,j){var G;const _=[];if(j){if(k.tHead)for(const P of Array.from(k.tHead.rows))P.querySelector("td[data-row]")&&_.push(P);if(k.tBodies[0])for(const P of Array.from(k.tBodies[0].rows))P.querySelector("td[data-row]")&&_.push(P)}let ne=-1,Z=1/0,W=-1,ue=-1,ce=1/0;for(let P=0;P<_.length;P++){const se=_[P].getBoundingClientRect(),me=(se.top+se.bottom)/2,he=Math.abs(O-me);he<Z&&(Z=he,ne=P);const ye=Math.abs(O-se.bottom);if(ye<ce&&ye<14){ce=ye,W=se.bottom-U.top;const Me=_[P].querySelector("td[data-row]");ue=parseInt((G=Me==null?void 0:Me.getAttribute("data-row"))!=null?G:"0",10)}}te.forEach((P,se)=>{if(!j||se!==ne){P.style.display="none";return}const me=_[se].getBoundingClientRect(),he=(me.top+me.bottom)/2-U.top;P.style.left="4px",P.style.top=`${he-8}px`,P.style.display="flex"}),j&&ue>=0?(H.style.display="flex",H.style.top=`${W-10}px`,H.style.left=`${V.left-U.left+Y-10}px`,H.dataset.afterRow=String(ue)):H.style.display="none"}let Q=!1;x.onmousemove=O=>{const U=O.target;if(U.tagName==="BUTTON"&&U.parentElement===x||Q)return;Q=!0;const V=O.clientX,Y=O.clientY;requestAnimationFrame(()=>{Q=!1;const j=x.getBoundingClientRect(),G=k.getBoundingClientRect(),_=x.scrollLeft,ne=Y>=j.top&&Y<G.top+4,Z=V>=j.left&&V<G.left+4,W=Math.min(G.right,j.right),ue=V>W-20&&V<=j.right,ce=Y>G.bottom-4&&Y<=j.bottom+20;if(D(V,j,G,_,ne),F(Y,j,G,_,Z),ae.style.display=ue?"flex":"none",ue&&(ae.style.left=`${j.right-j.left+_-20}px`,ae.style.top=`${(G.top+G.bottom)/2-j.top-10}px`),ie.style.display=ce?"flex":"none",ce){const P=(j.left+j.right)/2-j.left+_;ie.style.left=`${P-10}px`,ie.style.top=`${G.bottom-j.top-10}px`}})},x.onmouseleave=()=>{ee.forEach(O=>{O.style.display="none"}),te.forEach(O=>{O.style.display="none"}),q.style.display="none",H.style.display="none",ae.style.display="none",ie.style.display="none"}}M()}function Bo(e){var t,n;return{cells:Bn((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function zt(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function Nt(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function Do(e,t,n,r){var o,i,l,a;const c=t.state,s=le(e,c,t),p=t.prefill[e.key],u=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",f=(a=(l=e.fieldNames)==null?void 0:l.merges)!=null?a:"merges";let d;if(zt(p))d={cells:p.cells,merges:p.merges?Re(p.merges):[]};else if(p&&Nt(p,u)){const m=p[f];d={cells:p[u],merges:m?Re(m):[]}}else if(zt(e.default))d={cells:e.default.cells,merges:e.default.merges?Re(e.default.merges):[]};else if(e.default&&Nt(e.default,u)){const m=e.default[f];d={cells:e.default[u],merges:m?Re(m):[]}}else d=Bo(e);if(d.merges&&d.merges.length>0){const m=d.cells.length,v=m>0?d.cells[0].length:0,y=Mt(d.merges,m,v);y&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${y})`),d={...d,merges:[]})}s?No(d,n):Ho(e,d,r,t,n)}function jo(e,t,n){var r,o;const{scopeRoot:i,skipValidation:l}=n,a=[],c=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",s=i.querySelector(`[name="${t}"]`);if(!s)return{value:null,errors:a};let p=null;try{p=JSON.parse(s.value)}catch(u){return a.push(`${t}: invalid table data`),{value:null,errors:a}}if(!l&&e.required){const u=p[c];u!=null&&u.some(f=>f.some(d=>d.trim()!==""))||a.push(`${t}: ${$("required",n.state)}`)}return{value:p,errors:a}}function Oo(e,t,n,r){var o,i,l,a;const{scopeRoot:c}=r,s=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",p=(a=(l=e.fieldNames)==null?void 0:l.merges)!=null?a:"merges",u=c.querySelector(`[name="${t}"]`);if(!u){console.warn(`updateTableField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let f=null;if(zt(n))f={cells:n.cells,merges:n.merges?Re(n.merges):[]};else if(n&&Nt(n,s)){const d=n[p];f={cells:n[s],merges:d?Re(d):[]}}f&&u._applyExternalUpdate?u._applyExternalUpdate(f):u.value=JSON.stringify(n)}function Uo(e,t){e.style.overflow="hidden",e.style.resize="none";const n=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(3,n);const r=()=>{e.isConnected&&(e.style.height="0",e.style.height=`${e.scrollHeight}px`,t&&(t.style.height=`${e.scrollHeight}px`))};e.addEventListener("input",r),setTimeout(()=>{e.isConnected&&r()},0)}function It(e,t){var n,r,o,i;const l=new Map,a=new Map;for(const c of e){const s=t.resourceIndex.get(c),p=(n=s==null?void 0:s.name)!=null?n:c;a.set(p,((r=a.get(p))!=null?r:0)+1)}for(const c of e){const s=t.resourceIndex.get(c),p=(o=s==null?void 0:s.name)!=null?o:c;((i=a.get(p))!=null?i:1)>1&&s?l.set(c,`${p} (${sr(s.size)})`):l.set(c,p)}return l}function qt(e){return e?e.type.startsWith("image/"):!1}function jn(e,t){const n=It(e,t),r=new Map;for(const o of e){const i=n.get(o);i&&r.set(i,o)}return r}function Rt(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function ct(e){const t=[],n=e.length;let r=0;for(;r<n;)if(e[r]==="@"){if(r>0&&!/\s/.test(e[r-1])){r++;continue}const o=r;if(r++,r<n&&e[r]==='"'){r++;let i="";for(;r<n&&e[r]!=='"';)e[r]==="\\"&&r+1<n?(i+=e[r+1],r+=2):(i+=e[r],r++);r<n&&e[r]==='"'&&(r++,(r>=n||/\s/.test(e[r]))&&t.push({start:o,end:r,raw:e.slice(o,r),name:i}))}else if(r<n&&!/\s/.test(e[r])){const i=r;for(;r<n&&!/\s/.test(e[r]);)r++;const l=e.slice(i,r);t.push({start:o,end:r,raw:e.slice(o,r),name:l})}}else r++;return t}function Po(e,t){if(t.size===0)return[];const n=ct(e),r=[];for(const o of n){const i=t.get(o.name);i&&r.push({start:o.start,end:o.end,name:o.name,rid:i})}return r}function Vo(e,t){const n=Po(e,t);if(n.length===0)return e;let r="",o=0;for(const i of n)r+=e.slice(o,i.start),r+=`@${i.rid}`,o=i.end;return r+=e.slice(o),r}function On(e,t,n){const r=It(t,n),o=new Map;for(const c of t){const s=r.get(c);s&&o.set(c,s)}const i=ct(e);if(i.length===0)return e;let l="",a=0;for(const c of i){l+=e.slice(a,c.start);const s=o.get(c.name);s?l+=Rt(s):l+=c.raw,a=c.end}return l+=e.slice(a),l}function Un(e,t,n,r){if(ve(e),n!=null&&n.file&&qt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const i=new FileReader;i.onload=l=>{var a;o.src=((a=l.target)==null?void 0:a.result)||""},i.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(i=>{var l;if(!i||!e.isConnected)return;const a=document.createElement("img");a.alt=(l=n==null?void 0:n.name)!=null?l:t,a.src=i,a.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",ve(e),e.appendChild(a)}).catch(i=>{var l,a;(a=(l=r.config).onThumbnailError)==null||a.call(l,i,t)});const o=document.createElement("div");o.style.cssText="width: 100%; height: 100%; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',e.appendChild(o)}else{const o=document.createElement("div");if(o.style.cssText="width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px; box-sizing: border-box;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>',n!=null&&n.name){const i=document.createElement("span");i.style.cssText="font-size: 9px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 44px; color: var(--fb-text-color, #111827);",i.textContent=n.name,o.appendChild(i)}e.appendChild(o)}}function Pn(e,t,n,r){if(ve(e),n!=null&&n.file&&qt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;";const i=new FileReader;i.onload=l=>{var a;o.src=((a=l.target)==null?void 0:a.result)||""},i.readAsDataURL(n.file),e.appendChild(o)}else r.config.getThumbnail&&r.config.getThumbnail(t).then(o=>{var i;if(!o||!e.isConnected)return;const l=document.createElement("img");l.alt=(i=n==null?void 0:n.name)!=null?i:t,l.src=o,l.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",ve(e),e.appendChild(l)}).catch(o=>{var i,l;(l=(i=r.config).onThumbnailError)==null||l.call(i,o,t)})}function Vn(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=Math.max(4,Math.min(n.left+n.width/2-r.width/2,window.innerWidth-r.width-4)),i=n.top-r.height-8,l=n.bottom+8,a=i>=4?i:l;e.style.left=`${o}px`,e.style.top=`${Math.max(4,a)}px`}function Wn(e,t,n){const r=n.resourceIndex.get(t),o=document.createElement("div");o.className="fb-richinput-portal-tooltip fb-richinput-mention-tooltip",o.style.cssText=`
805
805
  position: fixed;
806
806
  z-index: 99999;
807
807
  background: #fff;
@@ -812,7 +812,7 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
812
812
  pointer-events: none;
813
813
  min-width: 60px;
814
814
  max-width: 140px;
815
- `;const i=document.createElement("div");return i.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",jn(i,t,r,n),o.appendChild(i),document.body.appendChild(o),On(o,e),o}function Pn(e,t){var n,r;const{rid:o,state:i,isReadonly:l,onMention:a,onRemove:s}=t,c=i.resourceIndex.get(o),p=(n=c==null?void 0:c.name)!=null?n:o,u=document.createElement("div");u.className="fb-richinput-portal-tooltip fb-richinput-file-tooltip",u.style.cssText=`
815
+ `;const i=document.createElement("div");return i.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",Pn(i,t,r,n),o.appendChild(i),document.body.appendChild(o),Vn(o,e),o}function Kn(e,t){var n,r;const{rid:o,state:i,isReadonly:l,onMention:a,onRemove:c}=t,s=i.resourceIndex.get(o),p=(n=s==null?void 0:s.name)!=null?n:o,u=document.createElement("div");u.className="fb-richinput-portal-tooltip fb-richinput-file-tooltip",u.style.cssText=`
816
816
  position: fixed;
817
817
  z-index: 99999;
818
818
  background: #fff;
@@ -823,17 +823,17 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
823
823
  pointer-events: auto;
824
824
  min-width: 80px;
825
825
  max-width: 260px;
826
- `;const d=document.createElement("div");d.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",jn(d,o,c,i),u.appendChild(d);const f=document.createElement("div");f.style.cssText="padding: 4px 6px 2px; font-size: 12px; color: var(--fb-text-color, #111827); word-break: break-word; border-top: 1px solid var(--fb-border-color, #d1d5db);",f.textContent=p,u.appendChild(f);const m=document.createElement("div");m.style.cssText="display: flex; align-items: center; gap: 2px; padding: 3px 4px 2px; border-top: 1px solid var(--fb-border-color, #d1d5db); justify-content: center;";const b="background: none; border: none; cursor: pointer; padding: 3px 5px; border-radius: 4px; color: var(--fb-text-muted-color, #6b7280); display: flex; align-items: center; transition: background 0.1s, color 0.1s;",y=v=>{v.style.background="var(--fb-background-hover-color, #f3f4f6)",v.style.color="var(--fb-text-color, #111827)"},w=v=>{v.style.background="none",v.style.color="var(--fb-text-muted-color, #6b7280)"};if(!l&&a){const v=document.createElement("button");v.type="button",v.title="Mention",v.style.cssText=b,v.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"/></svg>',v.addEventListener("mouseenter",()=>y(v)),v.addEventListener("mouseleave",()=>w(v)),v.addEventListener("click",h=>{h.stopPropagation(),a(),u.remove()}),m.appendChild(v)}if(i.config.downloadFile){const v=document.createElement("button");v.type="button",v.title="Download",v.style.cssText=b,v.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',v.addEventListener("mouseenter",()=>y(v)),v.addEventListener("mouseleave",()=>w(v)),v.addEventListener("click",h=>{var g,E;h.stopPropagation(),(E=(g=i.config).downloadFile)==null||E.call(g,o,p)}),m.appendChild(v)}if((r=i.config.getDownloadUrl)!=null?r:i.config.getThumbnail){const v=document.createElement("button");v.type="button",v.title="Open in new window",v.style.cssText=b,v.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',v.addEventListener("mouseenter",()=>y(v)),v.addEventListener("mouseleave",()=>w(v)),v.addEventListener("click",h=>{var g,E,C,x;if(h.stopPropagation(),i.config.getDownloadUrl){const k=i.config.getDownloadUrl(o);k?window.open(k,"_blank"):(E=(g=i.config).getThumbnail)==null||E.call(g,o).then(q=>{q&&window.open(q,"_blank")}).catch(()=>{})}else(x=(C=i.config).getThumbnail)==null||x.call(C,o).then(k=>{k&&window.open(k,"_blank")}).catch(()=>{})}),m.appendChild(v)}if(!l&&s){const v=document.createElement("button");v.type="button",v.title="Remove",v.style.cssText=b,v.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',v.addEventListener("mouseenter",()=>{v.style.background="var(--fb-background-hover-color, #f3f4f6)",v.style.color="var(--fb-error-color, #ef4444)"}),v.addEventListener("mouseleave",()=>w(v)),v.addEventListener("click",h=>{h.stopPropagation(),u.remove(),s()}),m.appendChild(v)}return m.children.length>0&&u.appendChild(m),document.body.appendChild(u),On(u,e),u}function Vn(){return{element:null,hideTimer:null}}function ct(e,t=150){e.hideTimer===null&&(e.hideTimer=setTimeout(()=>{e.hideTimer=null,e.element&&(e.element.remove(),e.element=null)},t))}function ut(e){e.hideTimer!==null&&(clearTimeout(e.hideTimer),e.hideTimer=null)}function Be(e){return e&&e.remove(),null}function Bo(e){var t;const n=(t=e.selectionStart)!=null?t:0,r=e.value.slice(0,n);for(let o=r.length-1;o>=0;o--)if(r[o]==="@"){if(o===0||/\s/.test(r[o-1])){let i=r.slice(o+1);return i.startsWith('"')&&(i=i.slice(1)),{query:i,pos:o}}return null}return null}function Wn(e,t,n){const r=e.toLowerCase();return t.filter(o=>{var i;return((i=n.get(o))!=null?i:o).toLowerCase().includes(r)})}const dt="font-size: var(--fb-font-size, 14px); font-family: var(--fb-font-family, inherit); line-height: 1.6;",Kn="padding: 12px 52px 12px 14px;";function Do(e,t,n,r,o){var i;const l=t.state,a=[...o.files],s={open:!1,query:"",triggerPos:-1,selectedIndex:0},c=new AbortController,p=document.createElement("input");p.type="hidden",p.name=r;function u(){var L,z;const N=x.value,M=Hn(a,l),I=N?Ho(N,M):null,H=(L=e.textKey)!=null?L:"text",ee=(z=e.filesKey)!=null?z:"files";return{[H]:N===""?null:I,[ee]:[...a]}}function d(){p.value=JSON.stringify(u())}const f=document.createElement("div");f.className="fb-richinput-wrapper",f.style.cssText=`
826
+ `;const f=document.createElement("div");f.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",Pn(f,o,s,i),u.appendChild(f);const d=document.createElement("div");d.style.cssText="padding: 4px 6px 2px; font-size: 12px; color: var(--fb-text-color, #111827); word-break: break-word; border-top: 1px solid var(--fb-border-color, #d1d5db);",d.textContent=p,u.appendChild(d);const m=document.createElement("div");m.style.cssText="display: flex; align-items: center; gap: 2px; padding: 3px 4px 2px; border-top: 1px solid var(--fb-border-color, #d1d5db); justify-content: center;";const v="background: none; border: none; cursor: pointer; padding: 3px 5px; border-radius: 4px; color: var(--fb-text-muted-color, #6b7280); display: flex; align-items: center; transition: background 0.1s, color 0.1s;",y=b=>{b.style.background="var(--fb-background-hover-color, #f3f4f6)",b.style.color="var(--fb-text-color, #111827)"},C=b=>{b.style.background="none",b.style.color="var(--fb-text-muted-color, #6b7280)"};if(!l&&a){const b=document.createElement("button");b.type="button",b.title="Mention",b.style.cssText=v,b.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"/></svg>',b.addEventListener("mouseenter",()=>y(b)),b.addEventListener("mouseleave",()=>C(b)),b.addEventListener("click",h=>{h.stopPropagation(),a(),u.remove()}),m.appendChild(b)}if(i.config.downloadFile){const b=document.createElement("button");b.type="button",b.title="Download",b.style.cssText=v,b.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',b.addEventListener("mouseenter",()=>y(b)),b.addEventListener("mouseleave",()=>C(b)),b.addEventListener("click",h=>{var g,E;h.stopPropagation(),(E=(g=i.config).downloadFile)==null||E.call(g,o,p)}),m.appendChild(b)}if((r=i.config.getDownloadUrl)!=null?r:i.config.getThumbnail){const b=document.createElement("button");b.type="button",b.title="Open in new window",b.style.cssText=v,b.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',b.addEventListener("mouseenter",()=>y(b)),b.addEventListener("mouseleave",()=>C(b)),b.addEventListener("click",h=>{var g,E,w,x;if(h.stopPropagation(),i.config.getDownloadUrl){const k=i.config.getDownloadUrl(o);k?window.open(k,"_blank"):(E=(g=i.config).getThumbnail)==null||E.call(g,o).then(I=>{I&&window.open(I,"_blank")}).catch(()=>{})}else(x=(w=i.config).getThumbnail)==null||x.call(w,o).then(k=>{k&&window.open(k,"_blank")}).catch(()=>{})}),m.appendChild(b)}if(!l&&c){const b=document.createElement("button");b.type="button",b.title="Remove",b.style.cssText=v,b.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',b.addEventListener("mouseenter",()=>{b.style.background="var(--fb-background-hover-color, #f3f4f6)",b.style.color="var(--fb-error-color, #ef4444)"}),b.addEventListener("mouseleave",()=>C(b)),b.addEventListener("click",h=>{h.stopPropagation(),u.remove(),c()}),m.appendChild(b)}return m.children.length>0&&u.appendChild(m),document.body.appendChild(u),Vn(u,e),u}function _n(){return{element:null,hideTimer:null}}function ut(e,t=150){e.hideTimer===null&&(e.hideTimer=setTimeout(()=>{e.hideTimer=null,e.element&&(e.element.remove(),e.element=null)},t))}function dt(e){e.hideTimer!==null&&(clearTimeout(e.hideTimer),e.hideTimer=null)}function Be(e){return e&&e.remove(),null}function Wo(e){var t;const n=(t=e.selectionStart)!=null?t:0,r=e.value.slice(0,n);for(let o=r.length-1;o>=0;o--)if(r[o]==="@"){if(o===0||/\s/.test(r[o-1])){let i=r.slice(o+1);return i.startsWith('"')&&(i=i.slice(1)),{query:i,pos:o}}return null}return null}function Jn(e,t,n){const r=e.toLowerCase();return t.filter(o=>{var i;return((i=n.get(o))!=null?i:o).toLowerCase().includes(r)})}const ft="font-size: var(--fb-font-size, 14px); font-family: var(--fb-font-family, inherit); line-height: 1.6;",Yn="padding: 12px 52px 12px 14px;";function Ko(e,t,n,r,o){var i;const l=t.state,a=[...o.files],c={open:!1,query:"",triggerPos:-1,selectedIndex:0},s=new AbortController,p=document.createElement("input");p.type="hidden",p.name=r;function u(){var L,N;const z=x.value,M=jn(a,l),q=z?Vo(z,M):null,H=(L=e.textKey)!=null?L:"text",ee=(N=e.filesKey)!=null?N:"files";return{[H]:z===""?null:q,[ee]:[...a]}}function f(){p.value=JSON.stringify(u())}const d=document.createElement("div");d.className="fb-richinput-wrapper",d.style.cssText=`
827
827
  position: relative;
828
828
  border: 1px solid var(--fb-border-color, #d1d5db);
829
829
  border-radius: 16px;
830
830
  background: var(--fb-background-color, #f9fafb);
831
831
  transition: box-shadow 0.15s, border-color 0.15s;
832
- `,f.addEventListener("focusin",()=>{f.style.borderColor="var(--fb-primary-color, #0066cc)",f.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),f.addEventListener("focusout",()=>{f.style.borderColor="var(--fb-border-color, #d1d5db)",f.style.boxShadow="none"});const m=document.createElement("div");m.className="fb-richinput-error",m.style.cssText="display: none; color: var(--fb-error-color, #ef4444); font-size: var(--fb-font-size-small, 12px); padding: 4px 14px 8px;";let b=null;function y(L){m.textContent=L,m.style.display="block",b&&clearTimeout(b),b=setTimeout(()=>{m.style.display="none",m.textContent="",b=null},5e3)}function w(L){var z;const N=ke(e.accept);if(!ze(L.name,N)){const I=N.join(", ");return y($("invalidFileExtension",l,{name:L.name,formats:I})),!1}const M=(z=e.maxSize)!=null?z:1/0;return Ge(L,M)?!0:(y($("fileTooLarge",l,{name:L.name,maxSize:M})),!1)}let v=0;f.addEventListener("dragenter",L=>{L.preventDefault(),v++,f.style.borderColor="var(--fb-primary-color, #0066cc)",f.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),f.addEventListener("dragover",L=>{L.preventDefault()}),f.addEventListener("dragleave",L=>{L.preventDefault(),v--,v<=0&&(v=0,f.style.borderColor="var(--fb-border-color, #d1d5db)",f.style.boxShadow="none")}),f.addEventListener("drop",L=>{var z,N;L.preventDefault(),v=0,f.style.borderColor="var(--fb-border-color, #d1d5db)",f.style.boxShadow="none";const M=(z=L.dataTransfer)==null?void 0:z.files;if(!M||!l.config.uploadFile)return;const I=(N=e.maxFiles)!=null?N:1/0;for(let H=0;H<M.length;H++){if(a.length>=I){y($("filesLimitExceeded",l,{skipped:M.length-H,max:I}));break}w(M[H])&&mt(M[H])}});const h=document.createElement("div");h.className="fb-richinput-files",h.style.cssText="display: none; flex-wrap: wrap; gap: 6px; padding: 10px 14px 0; align-items: center;";const g=document.createElement("input");g.type="file",g.multiple=!0,g.style.display="none",e.accept&&(typeof e.accept=="string"?g.accept=e.accept:g.accept=e.accept.extensions.map(L=>L.startsWith(".")?L:`.${L}`).join(","));const E=document.createElement("div");E.style.cssText="position: relative;";const C=document.createElement("div");C.className="fb-richinput-backdrop",C.style.cssText=`
832
+ `,d.addEventListener("focusin",()=>{d.style.borderColor="var(--fb-primary-color, #0066cc)",d.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),d.addEventListener("focusout",()=>{d.style.borderColor="var(--fb-border-color, #d1d5db)",d.style.boxShadow="none"});const m=document.createElement("div");m.className="fb-richinput-error",m.style.cssText="display: none; color: var(--fb-error-color, #ef4444); font-size: var(--fb-font-size-small, 12px); padding: 4px 14px 8px;";let v=null;function y(L){m.textContent=L,m.style.display="block",v&&clearTimeout(v),v=setTimeout(()=>{m.style.display="none",m.textContent="",v=null},5e3)}function C(L){var N;const z=ke(e.accept);if(!Ne(L.name,z)){const q=z.join(", ");return y($("invalidFileExtension",l,{name:L.name,formats:q})),!1}const M=(N=e.maxSize)!=null?N:1/0;return Ze(L,M)?!0:(y($("fileTooLarge",l,{name:L.name,maxSize:M})),!1)}let b=0;d.addEventListener("dragenter",L=>{L.preventDefault(),b++,d.style.borderColor="var(--fb-primary-color, #0066cc)",d.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),d.addEventListener("dragover",L=>{L.preventDefault()}),d.addEventListener("dragleave",L=>{L.preventDefault(),b--,b<=0&&(b=0,d.style.borderColor="var(--fb-border-color, #d1d5db)",d.style.boxShadow="none")}),d.addEventListener("drop",L=>{var N,z;L.preventDefault(),b=0,d.style.borderColor="var(--fb-border-color, #d1d5db)",d.style.boxShadow="none";const M=(N=L.dataTransfer)==null?void 0:N.files;if(!M||!l.config.uploadFile)return;const q=(z=e.maxFiles)!=null?z:1/0;for(let H=0;H<M.length;H++){if(a.length>=q){y($("filesLimitExceeded",l,{skipped:M.length-H,max:q}));break}C(M[H])&&ht(M[H])}});const h=document.createElement("div");h.className="fb-richinput-files",h.style.cssText="display: none; flex-wrap: wrap; gap: 6px; padding: 10px 14px 0; align-items: center;";const g=document.createElement("input");g.type="file",g.multiple=!0,g.style.display="none",e.accept&&(typeof e.accept=="string"?g.accept=e.accept:g.accept=e.accept.extensions.map(L=>L.startsWith(".")?L:`.${L}`).join(","));const E=document.createElement("div");E.style.cssText="position: relative;";const w=document.createElement("div");w.className="fb-richinput-backdrop",w.style.cssText=`
833
833
  position: absolute;
834
834
  top: 0; left: 0; right: 0; bottom: 0;
835
- ${Kn}
836
- ${dt}
835
+ ${Yn}
836
+ ${ft}
837
837
  white-space: pre-wrap;
838
838
  word-break: break-word;
839
839
  color: transparent;
@@ -842,10 +842,10 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
842
842
  border-radius: inherit;
843
843
  box-sizing: border-box;
844
844
  z-index: 2;
845
- `;const x=document.createElement("textarea");x.name=`${r}__text`,x.placeholder=e.placeholder||$("richinputPlaceholder",l);const k=(i=o.text)!=null?i:"";x.value=k?Bn(k,a,l):"",x.style.cssText=`
845
+ `;const x=document.createElement("textarea");x.name=`${r}__text`,x.placeholder=e.placeholder||$("richinputPlaceholder",l);const k=(i=o.text)!=null?i:"";x.value=k?On(k,a,l):"",x.style.cssText=`
846
846
  width: 100%;
847
- ${Kn}
848
- ${dt}
847
+ ${Yn}
848
+ ${ft}
849
849
  background: transparent;
850
850
  border: none;
851
851
  outline: none;
@@ -855,8 +855,8 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
855
855
  position: relative;
856
856
  z-index: 1;
857
857
  caret-color: var(--fb-text-color, #111827);
858
- `,Io(x,C),x.addEventListener("scroll",()=>{C.scrollTop=x.scrollTop});let q=null;C.addEventListener("mouseover",L=>{var z,N;const M=(N=(z=L.target).closest)==null?void 0:N.call(z,"mark");M!=null&&M.dataset.rid&&(q=Be(q),q=Un(M,M.dataset.rid,l))}),C.addEventListener("mouseout",L=>{var z,N,M;if(!((N=(z=L.target).closest)!=null&&N.call(z,"mark")))return;const I=L.relatedTarget;(M=I==null?void 0:I.closest)!=null&&M.call(I,"mark")||(q=Be(q))}),C.addEventListener("mousedown",L=>{var z,N;if(!((N=(z=L.target).closest)!=null&&N.call(z,"mark")))return;q=Be(q);const M=C.querySelectorAll("mark");M.forEach(H=>H.style.pointerEvents="none");const I=document.elementFromPoint(L.clientX,L.clientY);I&&I.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,clientX:L.clientX,clientY:L.clientY,button:L.button,buttons:L.buttons,detail:L.detail})),document.addEventListener("mouseup",()=>{M.forEach(H=>H.style.pointerEvents="auto")},{once:!0})});function K(){const L=x.value,z=Hn(a,l),N=st(L);if(N.length===0){C.innerHTML=re(L)+`
859
- `;return}let M="",I=0;for(const H of N){M+=re(L.slice(I,H.start));const ee=z.get(H.name);ee?M+=`<mark data-rid="${re(ee)}" style="background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent); color: transparent; border-radius: 8px; padding: 0; border: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent), 0 0 0 3px color-mix(in srgb, var(--fb-primary-color, #0066cc) 30%, transparent); box-decoration-break: clone; -webkit-box-decoration-break: clone; pointer-events: auto; cursor: text;">${re(L.slice(H.start,H.end))}</mark>`:M+=`<mark style="color: transparent; background: none; padding: 0; border: none; text-decoration-line: underline; text-decoration-style: wavy; text-decoration-color: rgba(239, 68, 68, 0.45); text-underline-offset: 2px;">${re(L.slice(H.start,H.end))}</mark>`,I=H.end}M+=re(L.slice(I)),C.innerHTML=M+`
858
+ `,Uo(x,w),x.addEventListener("scroll",()=>{w.scrollTop=x.scrollTop});let I=null;w.addEventListener("mouseover",L=>{var N,z;const M=(z=(N=L.target).closest)==null?void 0:z.call(N,"mark");M!=null&&M.dataset.rid&&(I=Be(I),I=Wn(M,M.dataset.rid,l))}),w.addEventListener("mouseout",L=>{var N,z,M;if(!((z=(N=L.target).closest)!=null&&z.call(N,"mark")))return;const q=L.relatedTarget;(M=q==null?void 0:q.closest)!=null&&M.call(q,"mark")||(I=Be(I))}),w.addEventListener("mousedown",L=>{var N,z;if(!((z=(N=L.target).closest)!=null&&z.call(N,"mark")))return;I=Be(I);const M=w.querySelectorAll("mark");M.forEach(H=>H.style.pointerEvents="none");const q=document.elementFromPoint(L.clientX,L.clientY);q&&q.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,clientX:L.clientX,clientY:L.clientY,button:L.button,buttons:L.buttons,detail:L.detail})),document.addEventListener("mouseup",()=>{M.forEach(H=>H.style.pointerEvents="auto")},{once:!0})});function K(){const L=x.value,N=jn(a,l),z=ct(L);if(z.length===0){w.innerHTML=oe(L)+`
859
+ `;return}let M="",q=0;for(const H of z){M+=oe(L.slice(q,H.start));const ee=N.get(H.name);ee?M+=`<mark data-rid="${oe(ee)}" style="background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent); color: transparent; border-radius: 8px; padding: 0; border: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent), 0 0 0 3px color-mix(in srgb, var(--fb-primary-color, #0066cc) 30%, transparent); box-decoration-break: clone; -webkit-box-decoration-break: clone; pointer-events: auto; cursor: text;">${oe(L.slice(H.start,H.end))}</mark>`:M+=`<mark style="color: transparent; background: none; padding: 0; border: none; text-decoration-line: underline; text-decoration-style: wavy; text-decoration-color: rgba(239, 68, 68, 0.45); text-underline-offset: 2px;">${oe(L.slice(H.start,H.end))}</mark>`,q=H.end}M+=oe(L.slice(q)),w.innerHTML=M+`
860
860
  `}const R=document.createElement("button");R.type="button",R.title=$("richinputAttachFile",l),R.style.cssText=`
861
861
  position: absolute;
862
862
  right: 10px;
@@ -873,7 +873,7 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
873
873
  justify-content: center;
874
874
  color: var(--fb-text-muted-color, #9ca3af);
875
875
  transition: color 0.15s, background 0.15s;
876
- `,R.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>',R.addEventListener("mouseenter",()=>{R.style.color="var(--fb-primary-color, #0066cc)",R.style.background="var(--fb-background-hover-color, #f3f4f6)"}),R.addEventListener("mouseleave",()=>{R.style.color="var(--fb-text-muted-color, #9ca3af)",R.style.background="transparent"}),R.addEventListener("click",()=>{var L;const z=(L=e.maxFiles)!=null?L:1/0;if(a.length>=z){y($("filesLimitExceeded",l,{skipped:1,max:z}));return}g.click()});const G=document.createElement("div");G.className="fb-richinput-dropdown",G.style.cssText=`
876
+ `,R.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>',R.addEventListener("mouseenter",()=>{R.style.color="var(--fb-primary-color, #0066cc)",R.style.background="var(--fb-background-hover-color, #f3f4f6)"}),R.addEventListener("mouseleave",()=>{R.style.color="var(--fb-text-muted-color, #9ca3af)",R.style.background="transparent"}),R.addEventListener("click",()=>{var L;const N=(L=e.maxFiles)!=null?L:1/0;if(a.length>=N){y($("filesLimitExceeded",l,{skipped:1,max:N}));return}g.click()});const J=document.createElement("div");J.className="fb-richinput-dropdown",J.style.cssText=`
877
877
  display: none;
878
878
  position: absolute;
879
879
  bottom: 100%;
@@ -888,16 +888,16 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
888
888
  max-height: 200px;
889
889
  overflow-y: auto;
890
890
  margin-bottom: 4px;
891
- ${dt}
892
- `;function Z(){return Nt(a,l)}function oe(L){be(G);const z=Z();if(L.length===0){G.style.display="none",s.open=!1;return}L.forEach((N,M)=>{var I;const H=l.resourceIndex.get(N),ee=document.createElement("div");ee.className="fb-richinput-dropdown-item",ee.dataset.rid=N,ee.style.cssText=`
891
+ ${ft}
892
+ `;function X(){return It(a,l)}function re(L){ve(J);const N=X();if(L.length===0){J.style.display="none",c.open=!1;return}L.forEach((z,M)=>{var q;const H=l.resourceIndex.get(z),ee=document.createElement("div");ee.className="fb-richinput-dropdown-item",ee.dataset.rid=z,ee.style.cssText=`
893
893
  padding: 5px 10px;
894
894
  cursor: pointer;
895
895
  color: var(--fb-text-color, #111827);
896
- background: ${M===s.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
896
+ background: ${M===c.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
897
897
  display: flex;
898
898
  align-items: center;
899
899
  gap: 8px;
900
- `;const te=document.createElement("div");if(te.style.cssText="width: 24px; height: 24px; border-radius: 4px; overflow: hidden; flex-shrink: 0; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",H!=null&&H.file&&zt(H)){const ie=document.createElement("img");ie.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const pe=new FileReader;pe.onload=F=>{var T;ie.src=((T=F.target)==null?void 0:T.result)||""},pe.readAsDataURL(H.file),te.appendChild(ie)}else l.config.getThumbnail&&l.config.getThumbnail(N).then(ie=>{if(!ie||!te.isConnected)return;const pe=document.createElement("img");pe.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",pe.src=ie,be(te),te.appendChild(pe)}).catch(()=>{}),te.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>';ee.appendChild(te);const ae=document.createElement("span");ae.style.cssText="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",ae.textContent=(I=z.get(N))!=null?I:N,ee.appendChild(ae),G.appendChild(ee)}),G.onmousemove=N=>{var M,I,H;const ee=(I=(M=N.target).closest)==null?void 0:I.call(M,".fb-richinput-dropdown-item");if(!ee)return;const te=L.indexOf((H=ee.dataset.rid)!=null?H:"");te===-1||te===s.selectedIndex||(G.querySelectorAll(".fb-richinput-dropdown-item").forEach((ae,ie)=>{ae.style.background=ie===te?"var(--fb-background-hover-color, #f3f4f6)":"transparent"}),s.selectedIndex=te)},G.onmousedown=N=>{var M,I;N.preventDefault(),N.stopPropagation();const H=(I=(M=N.target).closest)==null?void 0:I.call(M,".fb-richinput-dropdown-item");H!=null&&H.dataset.rid&&Se(H.dataset.rid)},G.style.display="block",s.open=!0}function Ae(){const L=Bo(x);if(!L){fe();return}s.query=L.query,s.triggerPos=L.pos,s.selectedIndex=0;const z=Z(),N=Wn(L.query,a,z);oe(N)}function fe(){G.style.display="none",s.open=!1}function Se(L){var z,N,M,I;const H=(M=(N=Z().get(L))!=null?N:(z=l.resourceIndex.get(L))==null?void 0:z.name)!=null?M:L,ee=(I=x.selectionStart)!=null?I:0,te=x.value.slice(0,s.triggerPos),ae=x.value.slice(ee),ie=`${qt(H)} `;x.value=`${te}${ie}${ae}`;const pe=te.length+ie.length;x.setSelectionRange(pe,pe),x.dispatchEvent(new Event("input")),fe()}x.addEventListener("input",()=>{var L;K(),d(),(L=t.instance)==null||L.triggerOnChange(r,u()),a.length>0?Ae():fe()});function We(){G.querySelectorAll(".fb-richinput-dropdown-item").forEach((L,z)=>{L.style.background=z===s.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}x.addEventListener("keydown",L=>{if(!s.open)return;const z=Z(),N=Wn(s.query,a,z);L.key==="ArrowDown"?(L.preventDefault(),s.selectedIndex=Math.min(s.selectedIndex+1,N.length-1),We()):L.key==="ArrowUp"?(L.preventDefault(),s.selectedIndex=Math.max(s.selectedIndex-1,0),We()):L.key==="Enter"&&N.length>0?(L.preventDefault(),Se(N[s.selectedIndex])):L.key==="Escape"&&fe()}),document.addEventListener("click",L=>{!f.contains(L.target)&&!G.contains(L.target)&&fe()},{signal:c.signal});function Ce(){if(be(h),a.length===0){h.style.display="none";return}h.style.display="flex",a.forEach(L=>{const z=l.resourceIndex.get(L),N=document.createElement("div");N.className="fb-richinput-file-thumb",N.style.cssText=`
900
+ `;const te=document.createElement("div");if(te.style.cssText="width: 24px; height: 24px; border-radius: 4px; overflow: hidden; flex-shrink: 0; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",H!=null&&H.file&&qt(H)){const ie=document.createElement("img");ie.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const pe=new FileReader;pe.onload=A=>{var T;ie.src=((T=A.target)==null?void 0:T.result)||""},pe.readAsDataURL(H.file),te.appendChild(ie)}else l.config.getThumbnail&&l.config.getThumbnail(z).then(ie=>{if(!ie||!te.isConnected)return;const pe=document.createElement("img");pe.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",pe.src=ie,ve(te),te.appendChild(pe)}).catch(()=>{}),te.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>';ee.appendChild(te);const ae=document.createElement("span");ae.style.cssText="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",ae.textContent=(q=N.get(z))!=null?q:z,ee.appendChild(ae),J.appendChild(ee)}),J.onmousemove=z=>{var M,q,H;const ee=(q=(M=z.target).closest)==null?void 0:q.call(M,".fb-richinput-dropdown-item");if(!ee)return;const te=L.indexOf((H=ee.dataset.rid)!=null?H:"");te===-1||te===c.selectedIndex||(J.querySelectorAll(".fb-richinput-dropdown-item").forEach((ae,ie)=>{ae.style.background=ie===te?"var(--fb-background-hover-color, #f3f4f6)":"transparent"}),c.selectedIndex=te)},J.onmousedown=z=>{var M,q;z.preventDefault(),z.stopPropagation();const H=(q=(M=z.target).closest)==null?void 0:q.call(M,".fb-richinput-dropdown-item");H!=null&&H.dataset.rid&&Se(H.dataset.rid)},J.style.display="block",c.open=!0}function Fe(){const L=Wo(x);if(!L){fe();return}c.query=L.query,c.triggerPos=L.pos,c.selectedIndex=0;const N=X(),z=Jn(L.query,a,N);re(z)}function fe(){J.style.display="none",c.open=!1}function Se(L){var N,z,M,q;const H=(M=(z=X().get(L))!=null?z:(N=l.resourceIndex.get(L))==null?void 0:N.name)!=null?M:L,ee=(q=x.selectionStart)!=null?q:0,te=x.value.slice(0,c.triggerPos),ae=x.value.slice(ee),ie=`${Rt(H)} `;x.value=`${te}${ie}${ae}`;const pe=te.length+ie.length;x.setSelectionRange(pe,pe),x.dispatchEvent(new Event("input")),fe()}x.addEventListener("input",()=>{var L;K(),f(),(L=t.instance)==null||L.triggerOnChange(r,u()),a.length>0?Fe():fe()});function Ke(){J.querySelectorAll(".fb-richinput-dropdown-item").forEach((L,N)=>{L.style.background=N===c.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}x.addEventListener("keydown",L=>{if(!c.open)return;const N=X(),z=Jn(c.query,a,N);L.key==="ArrowDown"?(L.preventDefault(),c.selectedIndex=Math.min(c.selectedIndex+1,z.length-1),Ke()):L.key==="ArrowUp"?(L.preventDefault(),c.selectedIndex=Math.max(c.selectedIndex-1,0),Ke()):L.key==="Enter"&&z.length>0?(L.preventDefault(),Se(z[c.selectedIndex])):L.key==="Escape"&&fe()}),document.addEventListener("click",L=>{!d.contains(L.target)&&!J.contains(L.target)&&fe()},{signal:s.signal});function we(){if(ve(h),a.length===0){h.style.display="none";return}h.style.display="flex",a.forEach(L=>{const N=l.resourceIndex.get(L),z=document.createElement("div");z.className="fb-richinput-file-thumb",z.style.cssText=`
901
901
  position: relative;
902
902
  width: 48px;
903
903
  height: 48px;
@@ -907,14 +907,14 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
907
907
  flex-shrink: 0;
908
908
  cursor: pointer;
909
909
  background: #fff;
910
- `;const M=document.createElement("div");M.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",Dn(M,L,z,l),N.appendChild(M);const I=Vn(),H=()=>{var te,ae,ie;const pe=(te=x.selectionStart)!=null?te:x.value.length,F=(ie=(ae=Z().get(L))!=null?ae:z==null?void 0:z.name)!=null?ie:L,T=x.value.slice(0,pe),S=x.value.slice(pe),B=`${T.length>0&&!/[\s\n]$/.test(T)?`
911
- `:""}${qt(F)} `;x.value=`${T}${B}${S}`;const D=pe+B.length;x.setSelectionRange(D,D),x.focus(),x.dispatchEvent(new Event("input"))},ee=()=>{var te;const ae=a.indexOf(L);ae!==-1&&a.splice(ae,1),Ce(),K(),d(),(te=t.instance)==null||te.triggerOnChange(r,u())};N.addEventListener("mouseenter",()=>{ut(I),I.element||(I.element=Pn(N,{rid:L,state:l,isReadonly:!1,onMention:H,onRemove:ee}),I.element.addEventListener("mouseenter",()=>{ut(I)}),I.element.addEventListener("mouseleave",()=>{ct(I)}))}),N.addEventListener("mouseleave",()=>{ct(I)}),h.appendChild(N)})}function mt(L){if(!l.config.uploadFile)return;const z=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;l.resourceIndex.set(z,{name:L.name,type:L.type,size:L.size,uploadedAt:new Date,file:L}),a.push(z),Ce();const N=h.querySelectorAll(".fb-richinput-file-thumb"),M=N[N.length-1];M&&(M.style.opacity="0.5"),l.config.uploadFile(L).then(I=>{var H;const ee=a.indexOf(z);ee!==-1&&(a[ee]=I),l.resourceIndex.delete(z),l.resourceIndex.set(I,{name:L.name,type:L.type,size:L.size,uploadedAt:new Date,file:L}),Ce(),K(),d(),(H=t.instance)==null||H.triggerOnChange(r,u())}).catch(I=>{var H,ee;const te=a.indexOf(z);te!==-1&&a.splice(te,1),l.resourceIndex.delete(z),Ce(),(ee=(H=l.config).onUploadError)==null||ee.call(H,I,L)})}if(g.addEventListener("change",()=>{var L;const z=g.files;if(!z||z.length===0)return;const N=(L=e.maxFiles)!=null?L:1/0;for(let M=0;M<z.length;M++){if(a.length>=N){y($("filesLimitExceeded",l,{skipped:z.length-M,max:N}));break}w(z[M])&&mt(z[M])}g.value=""}),E.appendChild(C),E.appendChild(x),E.appendChild(R),E.appendChild(G),f.appendChild(h),f.appendChild(E),f.appendChild(m),e.minLength!=null||e.maxLength!=null){const L=document.createElement("div");L.style.cssText="position: relative; padding: 2px 14px 6px; text-align: right;";const z=je(e,x,!1);z.style.cssText=`
910
+ `;const M=document.createElement("div");M.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",Un(M,L,N,l),z.appendChild(M);const q=_n(),H=()=>{var te,ae,ie;const pe=(te=x.selectionStart)!=null?te:x.value.length,A=(ie=(ae=X().get(L))!=null?ae:N==null?void 0:N.name)!=null?ie:L,T=x.value.slice(0,pe),S=x.value.slice(pe),B=`${T.length>0&&!/[\s\n]$/.test(T)?`
911
+ `:""}${Rt(A)} `;x.value=`${T}${B}${S}`;const D=pe+B.length;x.setSelectionRange(D,D),x.focus(),x.dispatchEvent(new Event("input"))},ee=()=>{var te;const ae=a.indexOf(L);ae!==-1&&a.splice(ae,1),we(),K(),f(),(te=t.instance)==null||te.triggerOnChange(r,u())};z.addEventListener("mouseenter",()=>{dt(q),q.element||(q.element=Kn(z,{rid:L,state:l,isReadonly:!1,onMention:H,onRemove:ee}),q.element.addEventListener("mouseenter",()=>{dt(q)}),q.element.addEventListener("mouseleave",()=>{ut(q)}))}),z.addEventListener("mouseleave",()=>{ut(q)}),h.appendChild(z)})}function ht(L){if(!l.config.uploadFile)return;const N=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;l.resourceIndex.set(N,{name:L.name,type:L.type,size:L.size,uploadedAt:new Date,file:L}),a.push(N),we();const z=h.querySelectorAll(".fb-richinput-file-thumb"),M=z[z.length-1];M&&(M.style.opacity="0.5"),l.config.uploadFile(L).then(q=>{var H;const ee=a.indexOf(N);ee!==-1&&(a[ee]=q),l.resourceIndex.delete(N),l.resourceIndex.set(q,{name:L.name,type:L.type,size:L.size,uploadedAt:new Date,file:L}),we(),K(),f(),(H=t.instance)==null||H.triggerOnChange(r,u())}).catch(q=>{var H,ee;const te=a.indexOf(N);te!==-1&&a.splice(te,1),l.resourceIndex.delete(N),we(),(ee=(H=l.config).onUploadError)==null||ee.call(H,q,L)})}if(g.addEventListener("change",()=>{var L;const N=g.files;if(!N||N.length===0)return;const z=(L=e.maxFiles)!=null?L:1/0;for(let M=0;M<N.length;M++){if(a.length>=z){y($("filesLimitExceeded",l,{skipped:N.length-M,max:z}));break}C(N[M])&&ht(N[M])}g.value=""}),E.appendChild(w),E.appendChild(x),E.appendChild(R),E.appendChild(J),d.appendChild(h),d.appendChild(E),d.appendChild(m),e.minLength!=null||e.maxLength!=null){const L=document.createElement("div");L.style.cssText="position: relative; padding: 2px 14px 6px; text-align: right;";const N=je(e,x,!1);N.style.cssText=`
912
912
  position: static;
913
913
  display: inline-block;
914
914
  font-size: var(--fb-font-size-small);
915
915
  color: var(--fb-text-secondary-color);
916
916
  pointer-events: none;
917
- `,L.appendChild(z),f.appendChild(L)}f.appendChild(p),f.appendChild(g),d(),K(),p._applyExternalUpdate=L=>{var z;const N=(z=L.text)!=null?z:"";x.value=N?Bn(N,a,l):"",x.dispatchEvent(new Event("input")),a.length=0;for(const M of L.files)a.push(M);Ce(),K(),d()},n.appendChild(f),Ce();const Ke=new MutationObserver(()=>{f.isConnected||(c.abort(),q=Be(q),Ke.disconnect())});f.parentElement&&Ke.observe(f.parentElement,{childList:!0})}function jo(e,t,n,r,o){var i,l;const a=t.state,{text:s,files:c}=o,p=new Map;for(const u of c){const d=a.resourceIndex.get(u);d!=null&&d.name&&p.set(u,d.name)}if(c.length>0){const u=document.createElement("div");u.style.cssText="display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px;",c.forEach(d=>{const f=a.resourceIndex.get(d),m=document.createElement("div");m.style.cssText=`
917
+ `,L.appendChild(N),d.appendChild(L)}d.appendChild(p),d.appendChild(g),f(),K(),p._applyExternalUpdate=L=>{var N;const z=(N=L.text)!=null?N:"";x.value=z?On(z,a,l):"",x.dispatchEvent(new Event("input")),a.length=0;for(const M of L.files)a.push(M);we(),K(),f()},n.appendChild(d),we();const _e=new MutationObserver(()=>{d.isConnected||(s.abort(),I=Be(I),_e.disconnect())});d.parentElement&&_e.observe(d.parentElement,{childList:!0})}function _o(e,t,n,r,o){var i,l;const a=t.state,{text:c,files:s}=o,p=new Map;for(const u of s){const f=a.resourceIndex.get(u);f!=null&&f.name&&p.set(u,f.name)}if(s.length>0){const u=document.createElement("div");u.style.cssText="display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px;",s.forEach(f=>{const d=a.resourceIndex.get(f),m=document.createElement("div");m.style.cssText=`
918
918
  position: relative;
919
919
  width: 48px; height: 48px;
920
920
  border: 1px solid var(--fb-border-color, #d1d5db);
@@ -923,12 +923,12 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
923
923
  flex-shrink: 0;
924
924
  background: #fff;
925
925
  cursor: default;
926
- `;const b=document.createElement("div");b.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",Dn(b,d,f,a),m.appendChild(b);const y=Vn();m.addEventListener("mouseenter",()=>{ut(y),y.element||(y.element=Pn(m,{rid:d,state:a,isReadonly:!0}),y.element.addEventListener("mouseenter",()=>{ut(y)}),y.element.addEventListener("mouseleave",()=>{ct(y)}))}),m.addEventListener("mouseleave",()=>{ct(y)}),u.appendChild(m)}),n.appendChild(u)}if(s){const u=document.createElement("div");u.style.cssText=`
927
- ${dt}
926
+ `;const v=document.createElement("div");v.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",Un(v,f,d,a),m.appendChild(v);const y=_n();m.addEventListener("mouseenter",()=>{dt(y),y.element||(y.element=Kn(m,{rid:f,state:a,isReadonly:!0}),y.element.addEventListener("mouseenter",()=>{dt(y)}),y.element.addEventListener("mouseleave",()=>{ut(y)}))}),m.addEventListener("mouseleave",()=>{ut(y)}),u.appendChild(m)}),n.appendChild(u)}if(c){const u=document.createElement("div");u.style.cssText=`
927
+ ${ft}
928
928
  color: var(--fb-text-color, #111827);
929
929
  white-space: pre-wrap;
930
930
  word-break: break-word;
931
- `;const d=st(s).filter(f=>p.has(f.name)||[...p.values()].includes(f.name));if(d.length===0)u.textContent=s;else{let f=0;for(const m of d){m.start>f&&u.appendChild(document.createTextNode(s.slice(f,m.start)));const b=document.createElement("span");b.style.cssText=`
931
+ `;const f=ct(c).filter(d=>p.has(d.name)||[...p.values()].includes(d.name));if(f.length===0)u.textContent=c;else{let d=0;for(const m of f){m.start>d&&u.appendChild(document.createTextNode(c.slice(d,m.start)));const v=document.createElement("span");v.style.cssText=`
932
932
  display: inline;
933
933
  background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent);
934
934
  color: var(--fb-primary-color, #0066cc);
@@ -936,12 +936,89 @@ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.lo
936
936
  padding: 1px 6px;
937
937
  font-weight: 500;
938
938
  cursor: default;
939
- `;const y=p.has(m.name)?m.name:(i=[...p.entries()].find(([,v])=>v===m.name))==null?void 0:i[0],w=(l=p.get(m.name))!=null?l:m.name;if(b.textContent=`@${w}`,y){let v=null;const h=y;b.addEventListener("mouseenter",()=>{v=Be(v),v=Un(b,h,a)}),b.addEventListener("mouseleave",()=>{v=Be(v)})}u.appendChild(b),f=m.end}f<s.length&&u.appendChild(document.createTextNode(s.slice(f)))}n.appendChild(u)}if(!s&&c.length===0){const u=document.createElement("div");u.style.cssText="color: var(--fb-text-muted-color, #6b7280); font-size: var(--fb-font-size, 14px);",u.textContent="\u2014",n.appendChild(u)}}function Oo(e,t,n,r){var o,i,l,a;const s=t.state,c=le(e,s,t),p=(o=e.textKey)!=null?o:"text",u=(i=e.filesKey)!=null?i:"files";let d;if(e.flatOutput){const f=t.prefill[p],m=t.prefill[u];d={text:typeof f=="string"?f:null,files:Array.isArray(m)?m:[]}}else{const f=t.prefill[e.key];if(f&&typeof f=="object"&&!Array.isArray(f)){const m=f,b=(l=m[p])!=null?l:m.text,y=(a=m[u])!=null?a:m.files;d={text:typeof b=="string"?b:null,files:Array.isArray(y)?y:[]}}else typeof f=="string"?d={text:f||null,files:[]}:d={text:null,files:[]}}for(const f of d.files)s.resourceIndex.has(f)||s.resourceIndex.set(f,{name:f,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(c)jo(e,t,n,r,d);else{if(!s.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);Do(e,t,n,r,d)}}function Uo(e,t,n){var r,o;const{scopeRoot:i,state:l,skipValidation:a}=n,s=[],c=(r=e.textKey)!=null?r:"text",p=(o=e.filesKey)!=null?o:"files",u=i.querySelector(`[name="${t}"]`);if(!u)return{value:null,errors:s};let d={};try{const v=JSON.parse(u.value);if(v&&typeof v=="object"&&!Array.isArray(v))d=v;else return s.push(`${t}: invalid richinput data`),{value:null,errors:s}}catch(v){return s.push(`${t}: invalid richinput data`),{value:null,errors:s}}const f=d[c],m=d[p],b=f===null||typeof f=="string"?f:null,y=Array.isArray(m)?m:[],w={[c]:b!=null?b:null,[p]:y};if(!a){const v=!b||b.trim()==="",h=y.length===0;e.required&&v&&h&&s.push(`${t}: ${$("required",l)}`),!v&&b&&(e.minLength!=null&&b.length<e.minLength&&s.push(`${t}: ${$("minLength",l,{min:e.minLength})}`),e.maxLength!=null&&b.length>e.maxLength&&s.push(`${t}: ${$("maxLength",l,{max:e.maxLength})}`)),e.maxFiles!=null&&y.length>e.maxFiles&&s.push(`${t}: ${$("maxFiles",l,{max:e.maxFiles})}`)}return{value:w,errors:s,spread:!!e.flatOutput}}function Po(e,t,n,r){var o,i,l,a;const{scopeRoot:s}=r,c=s.querySelector(`[name="${t}"]`);if(!c){console.warn(`updateRichInputField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let p=null;if(n&&typeof n=="object"&&!Array.isArray(n)){const u=n,d=(o=e.textKey)!=null?o:"text",f=(i=e.filesKey)!=null?i:"files",m=(l=u[d])!=null?l:u.text,b=(a=u[f])!=null?a:u.files;(m!==void 0||b!==void 0)&&(p={text:typeof m=="string"?m:null,files:Array.isArray(b)?b:[]})}p&&c._applyExternalUpdate?c._applyExternalUpdate(p):p&&(c.value=JSON.stringify(p))}function Vo(e,t){const n=document.getElementById(e);if(!n)return;const r=!n.classList.contains("hidden");if(document.querySelectorAll('[id^="tooltip-"]').forEach(p=>{p.classList.add("hidden")}),r)return;const o=t.getBoundingClientRect(),i=window.innerWidth,l=window.innerHeight;n&&n.parentElement!==document.body&&document.body.appendChild(n),n.style.visibility="hidden",n.style.position="fixed",n.classList.remove("hidden");const a=n.getBoundingClientRect();n.classList.add("hidden"),n.style.visibility="visible";let s=o.left,c=o.bottom+5;s+a.width>i&&(s=o.right-a.width),c+a.height>l&&(c=o.top-a.height-5),s<10&&(s=10),c<10&&(c=o.bottom+5),n.style.left=`${s}px`,n.style.top=`${c}px`,n.classList.remove("hidden"),setTimeout(()=>{n.classList.add("hidden")},25e3)}typeof document!="undefined"&&document.addEventListener("click",e=>{const t=e.target,n=t.closest("button")&&t.closest("button").onclick,r=t.closest('[id^="tooltip-"]');!n&&!r&&document.querySelectorAll('[id^="tooltip-"]').forEach(o=>{o.classList.add("hidden")})});function Wo(e,t){var n,r,o;if(!e.enableIf)return!1;try{const i=(r=(n=t.formData)!=null?n:t.prefill)!=null?r:{},l=((o=e.enableIf.scope)!=null?o:"relative")==="relative"&&t.path?t.prefill:void 0;return!Ne(e.enableIf,i,l)}catch(i){console.error(`Error evaluating enableIf for field "${e.key}":`,i)}return!1}function Ko(e,t){const n=t.querySelector(`[name="${e}"]`);if(n){if(n instanceof HTMLSelectElement)return n.value;if(n instanceof HTMLInputElement){if(n.type==="checkbox")return n.checked;if(n.type==="radio"){const r=t.querySelector(`[name="${e}"]:checked`);return r?r.value:void 0}else return n.value}else if(n instanceof HTMLTextAreaElement)return n.value}}function ft(e,t,n){var r,o;if(!t.enableIf)return;const i=n.state.formRoot;if(!i){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const l=t.enableIf,a=(r=l.scope)!=null?r:"relative";let s={};const c={};if((!n.path||n.path===""?"absolute":a)==="relative"&&n.path){const p=n.path.match(/^(.+)\[(\d+)\]$/);if(p){const u=p[1],d=parseInt(p[2],10),f=i.querySelector(`[data-container-item="${u}[${d}]"]`);f&&f.querySelectorAll("input, select, textarea").forEach(m=>{const b=m.getAttribute("name");if(b){const y=b.match(/\.([^.[\]]+)$/);if(y){const w=y[1];m instanceof HTMLSelectElement?c[w]=m.value:m instanceof HTMLInputElement?m.type==="checkbox"?c[w]=m.checked:m.type==="radio"?m.checked&&(c[w]=m.value):c[w]=m.value:m instanceof HTMLTextAreaElement&&(c[w]=m.value)}}})}}else{const p=l.key,u=Ko(p,i);u!==void 0?s[p]=u:s=(o=n.formData)!=null?o:n.prefill}try{Ne(l,s,c)?(e.style.display="",e.classList.remove("fb-field-wrapper-disabled"),e.removeAttribute("data-conditionally-disabled")):(e.style.display="none",e.classList.add("fb-field-wrapper-disabled"),e.setAttribute("data-conditionally-disabled","true"))}catch(p){console.error(`Error re-evaluating enableIf for field "${t.key}":`,p)}}function _o(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot setup enableIf listeners: formRoot is null");return}const i=t.enableIf,l=(r=i.scope)!=null?r:"relative",a=i.key;let s;l==="relative"&&n.path?s=`${n.path}.${a}`:s=a;const c=o.querySelector(`[name="${s}"]`);if(!c){const p=new MutationObserver(()=>{const u=o.querySelector(`[name="${s}"]`);u&&(u.addEventListener("change",()=>{ft(e,t,n)}),u.addEventListener("input",()=>{ft(e,t,n)}),p.disconnect())});p.observe(o,{childList:!0,subtree:!0});return}c.addEventListener("change",()=>{ft(e,t,n)}),c.addEventListener("input",()=>{ft(e,t,n)})}function Jo(e){const t=document.createElement("label");if(t.className="text-sm font-medium text-gray-900",t.textContent=e.label||e.key,e.required){const n=document.createElement("span");n.className="text-red-500 ml-1",n.textContent="*",t.appendChild(n)}return t}function Yo(e){const t=document.createElement("button");t.type="button",t.className="ml-2 text-gray-400 hover:text-gray-600",t.innerHTML='<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>';const n=`tooltip-${e.key}-${Math.random().toString(36).substr(2,9)}`,r=document.createElement("div");return r.id=n,r.className="hidden absolute z-50 bg-gray-200 text-gray-900 text-sm rounded-lg p-3 max-w-sm border border-gray-300 shadow-lg",r.style.position="fixed",r.textContent=e.description||e.hint||"Field information",document.body.appendChild(r),t.onclick=o=>{o.preventDefault(),o.stopPropagation(),Vo(n,t)},t}function Xo(e){const t=document.createElement("div");t.className="flex items-center mb-2";const n=Jo(e);if(t.appendChild(n),e.description||e.hint){const r=Yo(e);t.appendChild(r)}return t}function Go(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?or(e,t,n,r):rr(e,t,n,r);break;case"textarea":o?ir(e,t,n,r):lr(e,t,n,r);break;case"number":o?ur(e,t,n,r):cr(e,t,n,r);break;case"select":o?mr(e,t,n,r):pr(e,t,n,r);break;case"switcher":o?gr(e,t,n,r):br(e,t,n,r);break;case"file":o?so(e,t,n,r):io(e,t,n,r);break;case"files":ao(e,t,n,r);break;case"colour":o?uo(e,t,n,r):co(e,t,n,r);break;case"slider":o?ho(e,t,n,r):mo(e,t,n,r);break;case"group":xo(e,t,n,r);break;case"container":o?An(e,t,n):Fn(e,t,n,r);break;case"table":No(e,t,n,r);break;case"richinput":Oo(e,t,n,r);break;default:{const i=document.createElement("div");i.className="text-red-500 text-sm",i.textContent=$("unsupportedFieldType",t.state,{type:e.type}),n.appendChild(i)}}}function It(e,t){const n=Wo(e,t),r=document.createElement("div");r.className="mb-6 fb-field-wrapper",r.setAttribute("data-field-key",e.key);const o=Xo(e);r.appendChild(o);const i=xe(t.path,e.key);return Go(e,t,r,i),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),_o(r,e,t),r}go(It);const Rt={uploadFile:null,downloadFile:null,getThumbnail:null,getDownloadUrl:null,actionHandler:null,onChange:null,onFieldChange:null,onThumbnailError:null,onUploadError:null,onDownloadError:null,debounceMs:300,verboseErrors:!1,enableFilePreview:!0,maxPreviewSize:"200px",readonly:!1,pickExistingFiles:null,parseTableFile:null,locale:"en",translations:{en:{removeElement:"Remove",clickDragText:"Click or drag file",clickDragTextMultiple:"Click or drag files",noFileSelected:"No file selected",noFilesSelected:"No files selected",downloadButton:"Download",downloadFile:"Download",openInNewTab:"Open in new tab",changeButton:"Change",placeholderText:"Enter text",previewAlt:"Preview",previewUnavailable:"Preview unavailable",previewError:"Preview error",videoNotSupported:"Your browser does not support the video tag.",hintLengthRange:"{min}-{max} chars",hintMaxLength:"\u2264{max} chars",hintMinLength:"\u2265{min} chars",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}MB",hintFormats:"{formats}",hintRequired:"Required",hintOptional:"Optional",hintPattern:"Format: {pattern}",fileCountSingle:"{count} file",fileCountPlural:"{count} files",fileCountRange:"({min}-{max})",uploadingFile:"Uploading\u2026",filesCounter:"{count}/{max}",fromLibrary:"From library",libraryEmpty:"Library is empty",libraryHint:"Choose from previously uploaded files",pickerError:"Failed to load files from library",required:"Required",minItems:"Minimum {min} items required",maxItems:"Maximum {max} items allowed",minLength:"Minimum {min} characters",maxLength:"Maximum {max} characters",minValue:"Must be at least {min}",maxValue:"Must be at most {max}",patternMismatch:"Invalid format",invalidPattern:"Invalid pattern in schema",notANumber:"Must be a number",invalidHexColour:"Invalid hex color",minFiles:"Minimum {min} files required",maxFiles:"Maximum {max} files allowed",invalidFileExtension:'File "{name}" has unsupported format. Allowed: {formats}',invalidFileMime:'File "{name}": file type {type} not allowed (allowed: {mimes})',fileTooLarge:'File "{name}" exceeds maximum size of {maxSize}MB',filesLimitExceeded:"{skipped} file(s) skipped: maximum {max} files allowed",unsupportedFieldType:"Unsupported field type: {type}",invalidOption:"Invalid option",tableAddRow:"Add row",tableAddColumn:"Add column",tableRemoveRow:"Remove row",tableRemoveColumn:"Remove column",tableMergeCells:"Merge cells (Ctrl+M)",tableSplitCell:"Split cell (Ctrl+Shift+M)",tableImportFile:"Import",tableImporting:"Importing...",tableImportError:"Import failed: {error}",richinputPlaceholder:"Type text...",richinputAttachFile:"Attach file",richinputMention:"Mention",richinputRemoveFile:"Remove"},ru:{removeElement:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C",clickDragText:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B",clickDragTextMultiple:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B\u044B",noFileSelected:"\u0424\u0430\u0439\u043B \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D",noFilesSelected:"\u041D\u0435\u0442 \u0444\u0430\u0439\u043B\u043E\u0432",downloadButton:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",downloadFile:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",openInNewTab:"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432 \u043D\u043E\u0432\u043E\u0439 \u0432\u043A\u043B\u0430\u0434\u043A\u0435",changeButton:"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C",placeholderText:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",previewAlt:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440",previewUnavailable:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D",previewError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0430",videoNotSupported:"\u0412\u0430\u0448 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u0438\u0434\u0435\u043E.",hintLengthRange:"{min}-{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMaxLength:"\u2264{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMinLength:"\u2265{min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}\u041C\u0411",hintFormats:"{formats}",hintRequired:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintOptional:"\u041D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintPattern:"\u0424\u043E\u0440\u043C\u0430\u0442: {pattern}",fileCountSingle:"{count} \u0444\u0430\u0439\u043B",fileCountPlural:"{count} \u0444\u0430\u0439\u043B\u043E\u0432",fileCountRange:"({min}-{max})",uploadingFile:"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026",filesCounter:"{count}/{max}",fromLibrary:"\u0418\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",libraryEmpty:"\u0411\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0430 \u043F\u0443\u0441\u0442\u0430",libraryHint:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0438\u0437 \u0440\u0430\u043D\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0445 \u0444\u0430\u0439\u043B\u043E\u0432",pickerError:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u0430\u0439\u043B\u044B \u0438\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",required:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u043F\u043E\u043B\u0435",minItems:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",maxItems:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",minLength:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",maxLength:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",minValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {min}",maxValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {max}",patternMismatch:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442",invalidPattern:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043F\u0430\u0442\u0442\u0435\u0440\u043D \u0432 \u0441\u0445\u0435\u043C\u0435",notANumber:"\u0414\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0447\u0438\u0441\u043B\u043E\u043C",invalidHexColour:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 \u0446\u0432\u0435\u0442\u0430",minFiles:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0444\u0430\u0439\u043B\u043E\u0432",maxFiles:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",invalidFileExtension:'\u0424\u0430\u0439\u043B "{name}" \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442. \u0414\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0435: {formats}',invalidFileMime:'\u0424\u0430\u0439\u043B "{name}": \u0442\u0438\u043F \u0444\u0430\u0439\u043B\u0430 {type} \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u044B: {mimes})',fileTooLarge:'\u0424\u0430\u0439\u043B "{name}" \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440 {maxSize}\u041C\u0411',filesLimitExceeded:"{skipped} \u0444\u0430\u0439\u043B(\u043E\u0432) \u043F\u0440\u043E\u043F\u0443\u0449\u0435\u043D\u043E: \u043C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",unsupportedFieldType:"\u041D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \u043F\u043E\u043B\u044F: {type}",invalidOption:"\u041D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435",tableAddRow:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableAddColumn:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableRemoveRow:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableRemoveColumn:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableMergeCells:"\u041E\u0431\u044A\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0438 (Ctrl+M)",tableSplitCell:"\u0420\u0430\u0437\u0434\u0435\u043B\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0443 (Ctrl+Shift+M)",tableImportFile:"\u0418\u043C\u043F\u043E\u0440\u0442",tableImporting:"\u0418\u043C\u043F\u043E\u0440\u0442...",tableImportError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u0438\u043C\u043F\u043E\u0440\u0442\u0430: {error}",richinputPlaceholder:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442...",richinputAttachFile:"\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0444\u0430\u0439\u043B",richinputMention:"\u0423\u043F\u043E\u043C\u044F\u043D\u0443\u0442\u044C",richinputRemoveFile:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C"}},theme:{}};function Zo(e){const t={...Rt.translations};if(e!=null&&e.translations)for(const[n,r]of Object.entries(e.translations))t[n]={...Rt.translations[n]||{},...r};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...Rt,...e,translations:t},debounceTimer:null,prefill:{}}}function Qo(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const Ve={primaryColor:"#3b82f6",primaryHoverColor:"#2563eb",errorColor:"#ef4444",errorHoverColor:"#dc2626",successColor:"#10b981",borderColor:"#d1d5db",borderHoverColor:"#9ca3af",borderFocusColor:"#3b82f6",backgroundColor:"#ffffff",backgroundHoverColor:"#f9fafb",backgroundReadonlyColor:"#f3f4f6",textColor:"#1f2937",textSecondaryColor:"#6b7280",textPlaceholderColor:"#9ca3af",textDisabledColor:"#d1d5db",buttonBgColor:"#3b82f6",buttonTextColor:"#ffffff",buttonBorderColor:"#2563eb",buttonHoverBgColor:"#2563eb",buttonHoverBorderColor:"#1d4ed8",actionBgColor:"#ffffff",actionTextColor:"#374151",actionBorderColor:"#e5e7eb",actionHoverBgColor:"#f9fafb",actionHoverBorderColor:"#d1d5db",fileUploadBgColor:"#f3f4f6",fileUploadBorderColor:"#d1d5db",fileUploadTextColor:"#9ca3af",fileUploadHoverBorderColor:"#3b82f6",inputPaddingX:"0.75rem",inputPaddingY:"0.5rem",borderRadius:"0.5rem",borderWidth:"1px",fontSize:"0.875rem",fontSizeSmall:"0.75rem",fontSizeExtraSmall:"0.625rem",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontWeightNormal:"400",fontWeightMedium:"500",focusRingWidth:"2px",focusRingColor:"#3b82f6",focusRingOpacity:"0.5",transitionDuration:"200ms"};function el(e){const t={...Ve,...e},n=[];return Object.entries(t).forEach(([r,o])=>{const i=r.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(` --fb-${i}: ${o};`)}),n.join(`
940
- `)}function tl(e,t){const n=el(t);let r=e.querySelector("style[data-fb-theme]");r||(r=document.createElement("style"),r.setAttribute("data-fb-theme","true"),e.appendChild(r)),r.textContent=`
939
+ `;const y=p.has(m.name)?m.name:(i=[...p.entries()].find(([,b])=>b===m.name))==null?void 0:i[0],C=(l=p.get(m.name))!=null?l:m.name;if(v.textContent=`@${C}`,y){let b=null;const h=y;v.addEventListener("mouseenter",()=>{b=Be(b),b=Wn(v,h,a)}),v.addEventListener("mouseleave",()=>{b=Be(b)})}u.appendChild(v),d=m.end}d<c.length&&u.appendChild(document.createTextNode(c.slice(d)))}n.appendChild(u)}if(!c&&s.length===0){const u=document.createElement("div");u.style.cssText="color: var(--fb-text-muted-color, #6b7280); font-size: var(--fb-font-size, 14px);",u.textContent="\u2014",n.appendChild(u)}}function Jo(e,t,n,r){var o,i,l,a;const c=t.state,s=le(e,c,t),p=(o=e.textKey)!=null?o:"text",u=(i=e.filesKey)!=null?i:"files";let f;if(e.flatOutput){const d=t.prefill[p],m=t.prefill[u];f={text:typeof d=="string"?d:null,files:Array.isArray(m)?m:[]}}else{const d=t.prefill[e.key];if(d&&typeof d=="object"&&!Array.isArray(d)){const m=d,v=(l=m[p])!=null?l:m.text,y=(a=m[u])!=null?a:m.files;f={text:typeof v=="string"?v:null,files:Array.isArray(y)?y:[]}}else typeof d=="string"?f={text:d||null,files:[]}:f={text:null,files:[]}}for(const d of f.files)c.resourceIndex.has(d)||c.resourceIndex.set(d,{name:d,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(s)_o(e,t,n,r,f);else{if(!c.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);Ko(e,t,n,r,f)}}function Yo(e,t,n){var r,o;const{scopeRoot:i,state:l,skipValidation:a}=n,c=[],s=(r=e.textKey)!=null?r:"text",p=(o=e.filesKey)!=null?o:"files",u=i.querySelector(`[name="${t}"]`);if(!u)return{value:null,errors:c};let f={};try{const b=JSON.parse(u.value);if(b&&typeof b=="object"&&!Array.isArray(b))f=b;else return c.push(`${t}: invalid richinput data`),{value:null,errors:c}}catch(b){return c.push(`${t}: invalid richinput data`),{value:null,errors:c}}const d=f[s],m=f[p],v=d===null||typeof d=="string"?d:null,y=Array.isArray(m)?m:[],C={[s]:v!=null?v:null,[p]:y};if(!a){const b=!v||v.trim()==="",h=y.length===0;e.required&&b&&h&&c.push(`${t}: ${$("required",l)}`),!b&&v&&(e.minLength!=null&&v.length<e.minLength&&c.push(`${t}: ${$("minLength",l,{min:e.minLength})}`),e.maxLength!=null&&v.length>e.maxLength&&c.push(`${t}: ${$("maxLength",l,{max:e.maxLength})}`)),e.maxFiles!=null&&y.length>e.maxFiles&&c.push(`${t}: ${$("maxFiles",l,{max:e.maxFiles})}`)}return{value:C,errors:c,spread:!!e.flatOutput}}function Xo(e,t,n,r){var o,i,l,a;const{scopeRoot:c}=r,s=c.querySelector(`[name="${t}"]`);if(!s){console.warn(`updateRichInputField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let p=null;if(n&&typeof n=="object"&&!Array.isArray(n)){const u=n,f=(o=e.textKey)!=null?o:"text",d=(i=e.filesKey)!=null?i:"files",m=(l=u[f])!=null?l:u.text,v=(a=u[d])!=null?a:u.files;(m!==void 0||v!==void 0)&&(p={text:typeof m=="string"?m:null,files:Array.isArray(v)?v:[]})}p&&s._applyExternalUpdate?s._applyExternalUpdate(p):p&&(s.value=JSON.stringify(p))}const Go={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function Xn(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function Ve(e){return(e+"").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ht(e,t){const n=/((?:^|\n+)(?:\n---+|\*[ ]\*(?:[ ]\*)+)\n)|(?:^```[ ]*(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t|[ ]{2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|([ ]{2}\n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,r=[];let o="";const i=t||{};let l=0,a,c,s,p,u;function f(m){const v=Go[m[1]||""],y=r[r.length-1]===m;return v?v[1]?(y?r.pop():r.push(m),v[y?1:0]):v[0]:m}function d(){let m="";for(;r.length;)m+=f(r[r.length-1]);return m}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,(m,v,y)=>(i[v.toLowerCase()]=y,"")).replace(/^\n+|\n+$/g,"");s=n.exec(e);)c=e.substring(l,s.index),l=n.lastIndex,a=s[0],c.match(/[^\\](\\\\)*\\$/)||((u=s[3]||s[4])?a='<pre class="code '+(s[4]?"poetry":s[2].toLowerCase())+'"><code'+(s[2]?` class="language-${s[2].toLowerCase()}"`:"")+">"+Xn(Ve(u).replace(/^\n+|\n+$/g,""))+"</code></pre>":(u=s[6])?(u.match(/\./)&&(s[5]=s[5].replace(/^\d+/gm,"")),p=Ht(Xn(s[5].replace(/^\s*[>*+.-]/gm,""))),u===">"?u="blockquote":(u=u.match(/\./)?"ol":"ul",p=p.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),a="<"+u+">"+p+"</"+u+">"):s[8]?a=`<img src="${Ve(s[8])}" alt="${Ve(s[7])}">`:s[10]?(o=o.replace("<a>",`<a href="${Ve(s[11]||i[c.toLowerCase()])}">`),a=d()+"</a>"):s[9]?a="<a>":s[12]||s[14]?(u="h"+(s[14]?s[14].length:s[13]>"="?1:2),a="<"+u+">"+Ht(s[12]||s[15],i)+"</"+u+">"):s[16]?a="<code>"+Ve(s[16])+"</code>":(s[17]||s[1])&&(a=f(s[17]||"--"))),o+=c,o+=a;return(o+e.substring(l)+d()).replace(/^\n+|\n+$/g,"")}const Gn="fb-markdown-styles";function Zo(){if(typeof document=="undefined"||document.getElementById(Gn))return;const e=document.createElement("style");e.id=Gn,e.setAttribute("data-fb-markdown-styles","true"),e.textContent=`
940
+ .fb-markdown {
941
+ font-family: var(--fb-font-family, inherit);
942
+ font-size: var(--fb-font-size, 1rem);
943
+ color: var(--fb-text-color, #1f2937);
944
+ line-height: 1.6;
945
+ }
946
+ .fb-markdown h1,
947
+ .fb-markdown h2,
948
+ .fb-markdown h3,
949
+ .fb-markdown h4,
950
+ .fb-markdown h5,
951
+ .fb-markdown h6 {
952
+ font-weight: var(--fb-font-weight-medium, 600);
953
+ color: var(--fb-text-color, #1f2937);
954
+ margin-top: 0.75em;
955
+ margin-bottom: 0.25em;
956
+ }
957
+ .fb-markdown h1 { font-size: 1.5rem; }
958
+ .fb-markdown h2 { font-size: 1.25rem; }
959
+ .fb-markdown h3 { font-size: 1.1rem; }
960
+ .fb-markdown h4,
961
+ .fb-markdown h5,
962
+ .fb-markdown h6 { font-size: 1rem; }
963
+ .fb-markdown p {
964
+ margin-top: 0;
965
+ margin-bottom: 0.5em;
966
+ }
967
+ .fb-markdown ul,
968
+ .fb-markdown ol {
969
+ margin: 0.25em 0 0.5em 1.5em;
970
+ padding: 0;
971
+ }
972
+ .fb-markdown li {
973
+ margin-bottom: 0.15em;
974
+ }
975
+ .fb-markdown a {
976
+ color: var(--fb-primary-color, #2563eb);
977
+ text-decoration: underline;
978
+ }
979
+ .fb-markdown a:hover {
980
+ opacity: 0.8;
981
+ }
982
+ .fb-markdown code {
983
+ background: var(--fb-input-background-color, #f3f4f6);
984
+ border-radius: 3px;
985
+ padding: 0.1em 0.35em;
986
+ font-size: 0.9em;
987
+ font-family: monospace;
988
+ }
989
+ .fb-markdown pre {
990
+ background: var(--fb-input-background-color, #f3f4f6);
991
+ border-radius: var(--fb-border-radius, 0.375rem);
992
+ padding: 0.75em 1em;
993
+ overflow-x: auto;
994
+ margin: 0.5em 0;
995
+ }
996
+ .fb-markdown pre code {
997
+ background: none;
998
+ padding: 0;
999
+ border-radius: 0;
1000
+ font-size: inherit;
1001
+ }
1002
+ .fb-markdown blockquote {
1003
+ border-left: 3px solid var(--fb-border-color, #d1d5db);
1004
+ margin: 0.5em 0;
1005
+ padding-left: 1em;
1006
+ color: var(--fb-text-secondary-color, #6b7280);
1007
+ }
1008
+ .fb-markdown hr {
1009
+ border: none;
1010
+ border-top: 1px solid var(--fb-border-color, #d1d5db);
1011
+ margin: 0.75em 0;
1012
+ }
1013
+ .fb-markdown strong { font-weight: var(--fb-font-weight-medium, 600); }
1014
+ .fb-markdown em { font-style: italic; }
1015
+ .fb-markdown s { text-decoration: line-through; }
1016
+ `,document.head.appendChild(e)}const Qo=["javascript:","data:","vbscript:","blob:"],el=["javascript:","vbscript:","blob:"];function tl(e){return!!(el.some(t=>e.startsWith(t))||e.startsWith("data:")&&!e.startsWith("data:image/"))}function nl(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function rl(e){e.querySelectorAll("a[href]").forEach(t=>{var n;const r=((n=t.getAttribute("href"))!=null?n:"").trim().toLowerCase();Qo.some(o=>r.startsWith(o))&&t.setAttribute("href","#"),t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer")}),e.querySelectorAll("img[src]").forEach(t=>{var n;const r=((n=t.getAttribute("src"))!=null?n:"").trim().toLowerCase();tl(r)&&t.setAttribute("src","")})}function ol(e,t,n){if(typeof e.content!="string")throw new Error(`renderMarkdown: markdown element${e.key?` "${e.key}"`:""} requires "content" to be a string (got ${e.content===null?"null":typeof e.content})`);Zo();const r=document.createElement("div");r.className="fb-markdown";const o=nl(e.content);return r.innerHTML=Ht(o),rl(r),n.appendChild(r),r}function ll(e,t,n){return{value:void 0,errors:[],skip:!0}}function il(e,t,n,r){}function al(e,t){const n=document.getElementById(e);if(!n)return;const r=!n.classList.contains("hidden");if(document.querySelectorAll('[id^="tooltip-"]').forEach(p=>{p.classList.add("hidden")}),r)return;const o=t.getBoundingClientRect(),i=window.innerWidth,l=window.innerHeight;n&&n.parentElement!==document.body&&document.body.appendChild(n),n.style.visibility="hidden",n.style.position="fixed",n.classList.remove("hidden");const a=n.getBoundingClientRect();n.classList.add("hidden"),n.style.visibility="visible";let c=o.left,s=o.bottom+5;c+a.width>i&&(c=o.right-a.width),s+a.height>l&&(s=o.top-a.height-5),c<10&&(c=10),s<10&&(s=o.bottom+5),n.style.left=`${c}px`,n.style.top=`${s}px`,n.classList.remove("hidden"),setTimeout(()=>{n.classList.add("hidden")},25e3)}typeof document!="undefined"&&document.addEventListener("click",e=>{const t=e.target,n=t.closest("button")&&t.closest("button").onclick,r=t.closest('[id^="tooltip-"]');!n&&!r&&document.querySelectorAll('[id^="tooltip-"]').forEach(o=>{o.classList.add("hidden")})});function Zn(e,t){var n,r,o;if(!e.enableIf)return!1;try{const i=(r=(n=t.formData)!=null?n:t.prefill)!=null?r:{},l=((o=e.enableIf.scope)!=null?o:"relative")==="relative"&&t.path?t.prefill:void 0;return!ze(e.enableIf,i,l)}catch(i){console.error(`Error evaluating enableIf for field "${e.key}":`,i)}return!1}function sl(e,t){const n=t.querySelector(`[name="${e}"]`);if(n){if(n instanceof HTMLSelectElement)return n.value;if(n instanceof HTMLInputElement){if(n.type==="checkbox")return n.checked;if(n.type==="radio"){const r=t.querySelector(`[name="${e}"]:checked`);return r?r.value:void 0}else return n.value}else if(n instanceof HTMLTextAreaElement)return n.value}}function pt(e,t,n){var r,o;if(!t.enableIf)return;const i=n.state.formRoot;if(!i){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const l=t.enableIf,a=(r=l.scope)!=null?r:"relative";let c={};const s={};if((!n.path||n.path===""?"absolute":a)==="relative"&&n.path){const p=n.path.match(/^(.+)\[(\d+)\]$/);if(p){const u=p[1],f=parseInt(p[2],10),d=i.querySelector(`[data-container-item="${u}[${f}]"]`);d&&d.querySelectorAll("input, select, textarea").forEach(m=>{const v=m.getAttribute("name");if(v){const y=v.match(/\.([^.[\]]+)$/);if(y){const C=y[1];m instanceof HTMLSelectElement?s[C]=m.value:m instanceof HTMLInputElement?m.type==="checkbox"?s[C]=m.checked:m.type==="radio"?m.checked&&(s[C]=m.value):s[C]=m.value:m instanceof HTMLTextAreaElement&&(s[C]=m.value)}}})}}else{const p=l.key,u=sl(p,i);u!==void 0?c[p]=u:c=(o=n.formData)!=null?o:n.prefill}try{ze(l,c,s)?(e.style.display="",e.classList.remove("fb-field-wrapper-disabled"),e.removeAttribute("data-conditionally-disabled")):(e.style.display="none",e.classList.add("fb-field-wrapper-disabled"),e.setAttribute("data-conditionally-disabled","true"))}catch(p){console.error(`Error re-evaluating enableIf for field "${t.key}":`,p)}}function Qn(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot setup enableIf listeners: formRoot is null");return}const i=t.enableIf,l=(r=i.scope)!=null?r:"relative",a=i.key;let c;l==="relative"&&n.path?c=`${n.path}.${a}`:c=a;const s=o.querySelector(`[name="${c}"]`);if(!s){const p=new MutationObserver(()=>{const u=o.querySelector(`[name="${c}"]`);u&&(u.addEventListener("change",()=>{pt(e,t,n)}),u.addEventListener("input",()=>{pt(e,t,n)}),p.disconnect())});p.observe(o,{childList:!0,subtree:!0});return}s.addEventListener("change",()=>{pt(e,t,n)}),s.addEventListener("input",()=>{pt(e,t,n)})}function cl(e){var t,n;const r=document.createElement("label");if(r.className="text-sm font-medium text-gray-900",r.textContent=(n=(t=e.label)!=null?t:e.key)!=null?n:"",e.required){const o=document.createElement("span");o.className="text-red-500 ml-1",o.textContent="*",r.appendChild(o)}return r}function ul(e){const t=document.createElement("button");t.type="button",t.className="ml-2 text-gray-400 hover:text-gray-600",t.innerHTML='<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>';const n=`tooltip-${e.key}-${Math.random().toString(36).substr(2,9)}`,r=document.createElement("div");return r.id=n,r.className="hidden absolute z-50 bg-gray-200 text-gray-900 text-sm rounded-lg p-3 max-w-sm border border-gray-300 shadow-lg",r.style.position="fixed",r.textContent=e.description||e.hint||"Field information",document.body.appendChild(r),t.onclick=o=>{o.preventDefault(),o.stopPropagation(),al(n,t)},t}function dl(e){const t=document.createElement("div");t.className="flex items-center mb-2";const n=cl(e);if(t.appendChild(n),e.description||e.hint){const r=ul(e);t.appendChild(r)}return t}function fl(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?dr(e,t,n,r):ur(e,t,n,r);break;case"textarea":o?pr(e,t,n,r):fr(e,t,n,r);break;case"number":o?vr(e,t,n,r):br(e,t,n,r);break;case"select":o?Er(e,t,n,r):xr(e,t,n,r);break;case"switcher":o?$r(e,t,n,r):kr(e,t,n,r);break;case"file":o?bo(e,t,n,r):mo(e,t,n,r);break;case"files":ho(e,t,n,r);break;case"colour":o?go(e,t,n,r):vo(e,t,n,r);break;case"slider":o?wo(e,t,n,r):Eo(e,t,n,r);break;case"group":So(e,t,n,r);break;case"container":o?Nn(e,t,n):zn(e,t,n,r);break;case"table":Do(e,t,n,r);break;case"richinput":Jo(e,t,n,r);break;default:{const i=document.createElement("div");i.className="text-red-500 text-sm",i.textContent=$("unsupportedFieldType",t.state,{type:e.type}),n.appendChild(i)}}}function Bt(e,t){if(e.type==="markdown"){if(e.hidden===!0){const c=document.createElement("div");return c.style.display="none",c.setAttribute("data-fb-hidden-markdown","true"),c}const l=Zn(e,t),a=document.createElement("div");return a.className="mb-6 fb-field-wrapper fb-markdown-wrapper",a.setAttribute("data-field-key",vt(e,t.state)),ol(e,t,a),l&&(a.style.display="none",a.classList.add("fb-field-wrapper-disabled"),a.setAttribute("data-conditionally-disabled","true")),Qn(a,e,t),a}const n=Zn(e,t),r=document.createElement("div");r.className="mb-6 fb-field-wrapper",r.setAttribute("data-field-key",e.key);const o=dl(e);r.appendChild(o);const i=xe(t.path,e.key);return fl(e,t,r,i),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),Qn(r,e,t),r}$o(Bt);const Dt={uploadFile:null,downloadFile:null,getThumbnail:null,getDownloadUrl:null,actionHandler:null,onChange:null,onFieldChange:null,onThumbnailError:null,onUploadError:null,onDownloadError:null,debounceMs:300,verboseErrors:!1,enableFilePreview:!0,maxPreviewSize:"200px",readonly:!1,pickExistingFiles:null,parseTableFile:null,locale:"en",translations:{en:{removeElement:"Remove",clickDragText:"Click or drag file",clickDragTextMultiple:"Click or drag files",noFileSelected:"No file selected",noFilesSelected:"No files selected",downloadButton:"Download",downloadFile:"Download",openInNewTab:"Open in new tab",changeButton:"Change",placeholderText:"Enter text",previewAlt:"Preview",previewUnavailable:"Preview unavailable",previewError:"Preview error",videoNotSupported:"Your browser does not support the video tag.",hintLengthRange:"{min}-{max} chars",hintMaxLength:"\u2264{max} chars",hintMinLength:"\u2265{min} chars",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}MB",hintFormats:"{formats}",hintRequired:"Required",hintOptional:"Optional",hintPattern:"Format: {pattern}",fileCountSingle:"{count} file",fileCountPlural:"{count} files",fileCountRange:"({min}-{max})",uploadingFile:"Uploading\u2026",filesCounter:"{count}/{max}",fromLibrary:"From library",libraryEmpty:"Library is empty",libraryHint:"Choose from previously uploaded files",pickerError:"Failed to load files from library",required:"Required",minItems:"Minimum {min} items required",maxItems:"Maximum {max} items allowed",minLength:"Minimum {min} characters",maxLength:"Maximum {max} characters",minValue:"Must be at least {min}",maxValue:"Must be at most {max}",patternMismatch:"Invalid format",invalidPattern:"Invalid pattern in schema",notANumber:"Must be a number",invalidHexColour:"Invalid hex color",minFiles:"Minimum {min} files required",maxFiles:"Maximum {max} files allowed",invalidFileExtension:'File "{name}" has unsupported format. Allowed: {formats}',invalidFileMime:'File "{name}": file type {type} not allowed (allowed: {mimes})',fileTooLarge:'File "{name}" exceeds maximum size of {maxSize}MB',filesLimitExceeded:"{skipped} file(s) skipped: maximum {max} files allowed",unsupportedFieldType:"Unsupported field type: {type}",invalidOption:"Invalid option",tableAddRow:"Add row",tableAddColumn:"Add column",tableRemoveRow:"Remove row",tableRemoveColumn:"Remove column",tableMergeCells:"Merge cells (Ctrl+M)",tableSplitCell:"Split cell (Ctrl+Shift+M)",tableImportFile:"Import",tableImporting:"Importing...",tableImportError:"Import failed: {error}",richinputPlaceholder:"Type text...",richinputAttachFile:"Attach file",richinputMention:"Mention",richinputRemoveFile:"Remove"},ru:{removeElement:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C",clickDragText:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B",clickDragTextMultiple:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B\u044B",noFileSelected:"\u0424\u0430\u0439\u043B \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D",noFilesSelected:"\u041D\u0435\u0442 \u0444\u0430\u0439\u043B\u043E\u0432",downloadButton:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",downloadFile:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",openInNewTab:"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432 \u043D\u043E\u0432\u043E\u0439 \u0432\u043A\u043B\u0430\u0434\u043A\u0435",changeButton:"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C",placeholderText:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",previewAlt:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440",previewUnavailable:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D",previewError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0430",videoNotSupported:"\u0412\u0430\u0448 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u0438\u0434\u0435\u043E.",hintLengthRange:"{min}-{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMaxLength:"\u2264{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMinLength:"\u2265{min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}\u041C\u0411",hintFormats:"{formats}",hintRequired:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintOptional:"\u041D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintPattern:"\u0424\u043E\u0440\u043C\u0430\u0442: {pattern}",fileCountSingle:"{count} \u0444\u0430\u0439\u043B",fileCountPlural:"{count} \u0444\u0430\u0439\u043B\u043E\u0432",fileCountRange:"({min}-{max})",uploadingFile:"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026",filesCounter:"{count}/{max}",fromLibrary:"\u0418\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",libraryEmpty:"\u0411\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0430 \u043F\u0443\u0441\u0442\u0430",libraryHint:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0438\u0437 \u0440\u0430\u043D\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0445 \u0444\u0430\u0439\u043B\u043E\u0432",pickerError:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u0430\u0439\u043B\u044B \u0438\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",required:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u043F\u043E\u043B\u0435",minItems:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",maxItems:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",minLength:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",maxLength:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",minValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {min}",maxValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {max}",patternMismatch:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442",invalidPattern:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043F\u0430\u0442\u0442\u0435\u0440\u043D \u0432 \u0441\u0445\u0435\u043C\u0435",notANumber:"\u0414\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0447\u0438\u0441\u043B\u043E\u043C",invalidHexColour:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 \u0446\u0432\u0435\u0442\u0430",minFiles:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0444\u0430\u0439\u043B\u043E\u0432",maxFiles:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",invalidFileExtension:'\u0424\u0430\u0439\u043B "{name}" \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442. \u0414\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0435: {formats}',invalidFileMime:'\u0424\u0430\u0439\u043B "{name}": \u0442\u0438\u043F \u0444\u0430\u0439\u043B\u0430 {type} \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u044B: {mimes})',fileTooLarge:'\u0424\u0430\u0439\u043B "{name}" \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440 {maxSize}\u041C\u0411',filesLimitExceeded:"{skipped} \u0444\u0430\u0439\u043B(\u043E\u0432) \u043F\u0440\u043E\u043F\u0443\u0449\u0435\u043D\u043E: \u043C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",unsupportedFieldType:"\u041D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \u043F\u043E\u043B\u044F: {type}",invalidOption:"\u041D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435",tableAddRow:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableAddColumn:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableRemoveRow:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableRemoveColumn:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableMergeCells:"\u041E\u0431\u044A\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0438 (Ctrl+M)",tableSplitCell:"\u0420\u0430\u0437\u0434\u0435\u043B\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0443 (Ctrl+Shift+M)",tableImportFile:"\u0418\u043C\u043F\u043E\u0440\u0442",tableImporting:"\u0418\u043C\u043F\u043E\u0440\u0442...",tableImportError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u0438\u043C\u043F\u043E\u0440\u0442\u0430: {error}",richinputPlaceholder:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442...",richinputAttachFile:"\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0444\u0430\u0439\u043B",richinputMention:"\u0423\u043F\u043E\u043C\u044F\u043D\u0443\u0442\u044C",richinputRemoveFile:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C"}},theme:{}};function pl(e){const t={...Dt.translations};if(e!=null&&e.translations)for(const[n,r]of Object.entries(e.translations))t[n]={...Dt.translations[n]||{},...r};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...Dt,...e,translations:t},debounceTimer:null,prefill:{},syntheticElementIds:new WeakMap,syntheticElementIdCounter:0}}function ml(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const We={primaryColor:"#3b82f6",primaryHoverColor:"#2563eb",errorColor:"#ef4444",errorHoverColor:"#dc2626",successColor:"#10b981",borderColor:"#d1d5db",borderHoverColor:"#9ca3af",borderFocusColor:"#3b82f6",backgroundColor:"#ffffff",backgroundHoverColor:"#f9fafb",backgroundReadonlyColor:"#f3f4f6",textColor:"#1f2937",textSecondaryColor:"#6b7280",textPlaceholderColor:"#9ca3af",textDisabledColor:"#d1d5db",buttonBgColor:"#3b82f6",buttonTextColor:"#ffffff",buttonBorderColor:"#2563eb",buttonHoverBgColor:"#2563eb",buttonHoverBorderColor:"#1d4ed8",actionBgColor:"#ffffff",actionTextColor:"#374151",actionBorderColor:"#e5e7eb",actionHoverBgColor:"#f9fafb",actionHoverBorderColor:"#d1d5db",fileUploadBgColor:"#f3f4f6",fileUploadBorderColor:"#d1d5db",fileUploadTextColor:"#9ca3af",fileUploadHoverBorderColor:"#3b82f6",inputPaddingX:"0.75rem",inputPaddingY:"0.5rem",borderRadius:"0.5rem",borderWidth:"1px",fontSize:"0.875rem",fontSizeSmall:"0.75rem",fontSizeExtraSmall:"0.625rem",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontWeightNormal:"400",fontWeightMedium:"500",focusRingWidth:"2px",focusRingColor:"#3b82f6",focusRingOpacity:"0.5",transitionDuration:"200ms"};function hl(e){const t={...We,...e},n=[];return Object.entries(t).forEach(([r,o])=>{const i=r.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(` --fb-${i}: ${o};`)}),n.join(`
1017
+ `)}function bl(e,t){const n=hl(t);let r=e.querySelector("style[data-fb-theme]");r||(r=document.createElement("style"),r.setAttribute("data-fb-theme","true"),e.appendChild(r)),r.textContent=`
941
1018
  [data-fb-root="true"] {
942
1019
  ${n}
943
1020
  }
944
- `}const nl={default:Ve,dark:{...Ve,primaryColor:"#60a5fa",primaryHoverColor:"#3b82f6",borderColor:"#4b5563",borderHoverColor:"#6b7280",borderFocusColor:"#60a5fa",backgroundColor:"#1f2937",backgroundHoverColor:"#374151",backgroundReadonlyColor:"#111827",textColor:"#f9fafb",textSecondaryColor:"#9ca3af",textPlaceholderColor:"#6b7280",fileUploadBgColor:"#374151",fileUploadBorderColor:"#4b5563",fileUploadTextColor:"#9ca3af"},klein:{...Ve,primaryColor:"#0066cc",primaryHoverColor:"#0052a3",errorColor:"#d32f2f",errorHoverColor:"#c62828",successColor:"#388e3c",borderColor:"#e0e0e0",borderHoverColor:"#bdbdbd",borderFocusColor:"#0066cc",borderRadius:"4px",fontSize:"16px",fontSizeSmall:"14px",fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif'}};function _n(e,t=!1){e.style.cssText=`
1021
+ `}const vl={default:We,dark:{...We,primaryColor:"#60a5fa",primaryHoverColor:"#3b82f6",borderColor:"#4b5563",borderHoverColor:"#6b7280",borderFocusColor:"#60a5fa",backgroundColor:"#1f2937",backgroundHoverColor:"#374151",backgroundReadonlyColor:"#111827",textColor:"#f9fafb",textSecondaryColor:"#9ca3af",textPlaceholderColor:"#6b7280",fileUploadBgColor:"#374151",fileUploadBorderColor:"#4b5563",fileUploadTextColor:"#9ca3af"},klein:{...We,primaryColor:"#0066cc",primaryHoverColor:"#0052a3",errorColor:"#d32f2f",errorHoverColor:"#c62828",successColor:"#388e3c",borderColor:"#e0e0e0",borderHoverColor:"#bdbdbd",borderFocusColor:"#0066cc",borderRadius:"4px",fontSize:"16px",fontSizeSmall:"14px",fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif'}};function er(e,t=!1){e.style.cssText=`
945
1022
  background-color: var(--fb-action-bg-color);
946
1023
  color: var(--fb-action-text-color);
947
1024
  border: var(--fb-border-width) solid var(--fb-action-border-color);
@@ -951,6 +1028,6 @@ ${n}
951
1028
  border-radius: var(--fb-border-radius);
952
1029
  transition: all var(--fb-transition-duration);
953
1030
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
954
- `,e.addEventListener("mouseenter",()=>{e.style.backgroundColor="var(--fb-action-hover-bg-color)",e.style.borderColor="var(--fb-action-hover-border-color)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor="var(--fb-action-bg-color)",e.style.borderColor="var(--fb-action-border-color)"})}function rl(e,t,n){var r;const{scopeRoot:o}=n,i=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`),l=(r=i==null?void 0:i.value)!=null?r:"";if(l===""){const a="default"in e?e.default:null;return{value:a!==void 0?a:null,errors:[]}}return{value:Bt(l),errors:[]}}function ol(e,t,n,r){const{scopeRoot:o}=r,i=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);i&&(i.value=Ht(n))}const ll={text:{validate:Dt,update:jt},textarea:{validate:ar,update:sr},number:{validate:dr,update:fr},select:{validate:hr,update:vr},switcher:{validate:yr,update:xr},file:{validate:bn,update:xn},files:{validate:bn,update:xn},colour:{validate:fo,update:po},slider:{validate:vo,update:bo},container:{validate:Nn,update:zn},group:{validate:Eo,update:Co},table:{validate:zo,update:qo},richinput:{validate:Uo,update:Po},hidden:{validate:rl,update:ol}};function Jn(e){return ll[e]||null}function il(e,t,n){const r=Jn(e.type);return r&&r.validate?r.validate(e,t,n):null}function al(e,t,n,r){const o=Jn(e.type);return o&&o.update?(o.update(e,t,n,r),!0):!1}class pt{constructor(t){this.instanceId=Qo(),this.state=Zo(t),this.state.config.verboseErrors&&(globalThis.__formBuilderInstances||(globalThis.__formBuilderInstances=new Set),globalThis.__formBuilderInstances.add(this.instanceId),globalThis.__formBuilderInstances.size>10&&console.warn(`[form-builder] ${globalThis.__formBuilderInstances.size} instances active. Possible memory leak - ensure you call destroy() when done.`))}getInstanceId(){return this.instanceId}getState(){return this.state}setFormRoot(t){this.state.formRoot=t}configure(t){Object.assign(this.state.config,t)}setUploadHandler(t){this.state.config.uploadFile=t}setDownloadHandler(t){this.state.config.downloadFile=t}setThumbnailHandler(t){this.state.config.getThumbnail=t}setActionHandler(t){this.state.config.actionHandler=t}setMode(t){this.state.config.readonly=t==="readonly"}setLocale(t){this.state.config.translations[t]&&(this.state.config.locale=t)}triggerOnChange(t,n){this.state.config.readonly||(this.state.debounceTimer!==null&&clearTimeout(this.state.debounceTimer),this.state.debounceTimer=setTimeout(()=>{const r=this.validateForm(!0);this.reevaluateConditionalFields(),this.state.config.onChange&&this.state.config.onChange(r),this.state.config.onFieldChange&&t!==void 0&&n!==void 0&&this.state.config.onFieldChange(t,n,r),this.state.debounceTimer=null},this.state.config.debounceMs))}registerAction(t){if(!t||!t.value)throw new Error("Action must have a value property");this.state.externalActions||(this.state.externalActions=[]);const n=this.state.externalActions.findIndex(r=>r.value===t.value&&r.related_field===t.related_field);n>=0?this.state.externalActions[n]=t:this.state.externalActions.push(t)}findFormElementByFieldPath(t){if(!this.state.formRoot)return null;if(!this.state.config.readonly){let o=this.state.formRoot.querySelector(`[name="${t}"]`);if(o)return o;const i=[t,t.replace(/\[(\d+)\]/g,"[$1]"),t.replace(/\./g,"[")+"]".repeat((t.match(/\./g)||[]).length)];for(const l of i)if(o=this.state.formRoot.querySelector(`[name="${l}"]`),o)return o}const n=this.findSchemaElement(t);if(!n)return null;const r=this.state.formRoot.querySelectorAll(".fb-field-wrapper");for(const o of r){const i=n.label||n.key,l=o.querySelector("label");if(l&&(l.textContent===i||l.textContent===`${i}*`)){let a=o.querySelector(".field-placeholder");return a||(a=document.createElement("div"),a.className="field-placeholder",a.style.display="none",o.appendChild(a)),a}}return null}findSchemaElement(t){if(!this.state.schema||!this.state.schema.elements)return null;let n=this.state.schema.elements,r=null;const o=t.replace(/\[\d+\]/g,"").split(".").filter(Boolean);for(const i of o){if(r=n.find(l=>l.key===i)||null,!r)return null;"elements"in r&&r.elements&&(n=r.elements)}return r}resolveActionLabel(t,n,r,o=!1){if(r&&"actions"in r&&r.actions){const i=r.actions.find(l=>l.key===t);if(i&&i.label)return i.label}if(o&&this.state.schema&&"actions"in this.state.schema&&this.state.schema.actions){const i=this.state.schema.actions.find(l=>l.key===t);if(i&&i.label)return i.label}return n||t}renderFormLevelActions(t,n=[]){if(!this.state.formRoot)return;const r=this.state.formRoot.querySelector(".form-level-actions-container");r&&r.remove();const o=document.createElement("div");o.className="form-level-actions-container mt-6 pt-4 flex flex-wrap gap-3 justify-center",o.style.cssText=`
1031
+ `,e.addEventListener("mouseenter",()=>{e.style.backgroundColor="var(--fb-action-hover-bg-color)",e.style.borderColor="var(--fb-action-hover-border-color)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor="var(--fb-action-bg-color)",e.style.borderColor="var(--fb-action-border-color)"})}function gl(e,t,n){var r;const{scopeRoot:o}=n,i=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`),l=(r=i==null?void 0:i.value)!=null?r:"";if(l===""){const a="default"in e?e.default:null;return{value:a!==void 0?a:null,errors:[]}}return{value:Ot(l),errors:[]}}function yl(e,t,n,r){const{scopeRoot:o}=r,i=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);i&&(i.value=jt(n))}const xl={text:{validate:Ut,update:Pt},textarea:{validate:mr,update:hr},number:{validate:gr,update:yr},select:{validate:wr,update:Cr},switcher:{validate:Lr,update:Sr},file:{validate:xn,update:Cn},files:{validate:xn,update:Cn},colour:{validate:yo,update:xo},slider:{validate:Co,update:ko},container:{validate:qn,update:Rn},group:{validate:To,update:Ao},table:{validate:jo,update:Oo},richinput:{validate:Yo,update:Xo},hidden:{validate:gl,update:yl},markdown:{validate:ll,update:il}};function tr(e){return xl[e]||null}function El(e,t,n){const r=tr(e.type);return r&&r.validate?r.validate(e,t,n):null}function wl(e,t,n,r){const o=tr(e.type);return o&&o.update?(o.update(e,t,n,r),!0):!1}class mt{constructor(t){this.instanceId=ml(),this.state=pl(t),this.state.config.verboseErrors&&(globalThis.__formBuilderInstances||(globalThis.__formBuilderInstances=new Set),globalThis.__formBuilderInstances.add(this.instanceId),globalThis.__formBuilderInstances.size>10&&console.warn(`[form-builder] ${globalThis.__formBuilderInstances.size} instances active. Possible memory leak - ensure you call destroy() when done.`))}getInstanceId(){return this.instanceId}getState(){return this.state}setFormRoot(t){this.state.formRoot=t}configure(t){Object.assign(this.state.config,t)}setUploadHandler(t){this.state.config.uploadFile=t}setDownloadHandler(t){this.state.config.downloadFile=t}setThumbnailHandler(t){this.state.config.getThumbnail=t}setActionHandler(t){this.state.config.actionHandler=t}setMode(t){this.state.config.readonly=t==="readonly"}setLocale(t){this.state.config.translations[t]&&(this.state.config.locale=t)}triggerOnChange(t,n){this.state.config.readonly||(this.state.debounceTimer!==null&&clearTimeout(this.state.debounceTimer),this.state.debounceTimer=setTimeout(()=>{const r=this.validateForm(!0);this.reevaluateConditionalFields(),this.state.config.onChange&&this.state.config.onChange(r),this.state.config.onFieldChange&&t!==void 0&&n!==void 0&&this.state.config.onFieldChange(t,n,r),this.state.debounceTimer=null},this.state.config.debounceMs))}registerAction(t){if(!t||!t.value)throw new Error("Action must have a value property");this.state.externalActions||(this.state.externalActions=[]);const n=this.state.externalActions.findIndex(r=>r.value===t.value&&r.related_field===t.related_field);n>=0?this.state.externalActions[n]=t:this.state.externalActions.push(t)}findFormElementByFieldPath(t){if(!this.state.formRoot)return null;if(!this.state.config.readonly){let o=this.state.formRoot.querySelector(`[name="${t}"]`);if(o)return o;const i=[t,t.replace(/\[(\d+)\]/g,"[$1]"),t.replace(/\./g,"[")+"]".repeat((t.match(/\./g)||[]).length)];for(const l of i)if(o=this.state.formRoot.querySelector(`[name="${l}"]`),o)return o}const n=this.findSchemaElement(t);if(!n)return null;const r=this.state.formRoot.querySelectorAll(".fb-field-wrapper");for(const o of r){const i=n.label||n.key,l=o.querySelector("label");if(l&&(l.textContent===i||l.textContent===`${i}*`)){let a=o.querySelector(".field-placeholder");return a||(a=document.createElement("div"),a.className="field-placeholder",a.style.display="none",o.appendChild(a)),a}}return null}findSchemaElement(t){if(!this.state.schema||!this.state.schema.elements)return null;let n=this.state.schema.elements,r=null;const o=t.replace(/\[\d+\]/g,"").split(".").filter(Boolean);for(const i of o){if(r=n.find(l=>l.key===i)||null,!r)return null;"elements"in r&&r.elements&&(n=r.elements)}return r}resolveActionLabel(t,n,r,o=!1){if(r&&"actions"in r&&r.actions){const i=r.actions.find(l=>l.key===t);if(i&&i.label)return i.label}if(o&&this.state.schema&&"actions"in this.state.schema&&this.state.schema.actions){const i=this.state.schema.actions.find(l=>l.key===t);if(i&&i.label)return i.label}return n||t}renderFormLevelActions(t,n=[]){if(!this.state.formRoot)return;const r=this.state.formRoot.querySelector(".form-level-actions-container");r&&r.remove();const o=document.createElement("div");o.className="form-level-actions-container mt-6 pt-4 flex flex-wrap gap-3 justify-center",o.style.cssText=`
955
1032
  border-top: var(--fb-border-width) solid var(--fb-border-color);
956
- `,t.forEach(i=>{const l=document.createElement("button");l.type="button",_n(l,!0);const a=n.includes(i),s=this.resolveActionLabel(i.key,i.label,null,a);l.textContent=s,l.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(i.value,i.key,null)}),o.appendChild(l)}),this.state.formRoot.appendChild(o)}renderExternalActions(){if(!this.state.externalActions||!Array.isArray(this.state.externalActions))return;const t=new Map,n=[],r=[];this.state.externalActions.forEach(i=>{!i.key||!i.value||(i.related_field?(t.has(i.related_field)||t.set(i.related_field,[]),t.get(i.related_field).push(i)):n.push(i))}),t.forEach((i,l)=>{const a=this.findFormElementByFieldPath(l);if(!a){console.warn(`External action: Could not find form element for field "${l}", treating as form-level actions`),r.push(...i);return}let s=a.closest(".fb-field-wrapper");if(s||(s=a.parentElement),!s){console.warn(`External action: Could not find wrapper for field "${l}"`);return}const c=s.querySelector(".external-actions-container");c&&c.remove();const p=document.createElement("div");p.className="external-actions-container mt-3 flex flex-wrap gap-2";const u=this.findSchemaElement(l);i.forEach(d=>{const f=document.createElement("button");f.type="button",_n(f,!1);const m=this.resolveActionLabel(d.key,d.label,u);f.textContent=m,f.addEventListener("click",b=>{b.preventDefault(),b.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(d.value,d.key,d.related_field)}),p.appendChild(f)}),s.appendChild(p)});const o=[...n,...r];o.length>0&&this.renderFormLevelActions(o,n)}handlePrefillHintClick(t){const n=t.target;if(!n.classList.contains("fb-prefill-hint"))return;t.preventDefault(),t.stopPropagation();const r=n.getAttribute("data-hint-values"),o=n.getAttribute("data-root-hint")==="true",i=n.getAttribute("data-container-key");if(!r||!o&&!i){console.warn("Prefill hint missing required data attributes");return}try{const l=JSON.parse(r);for(const a in l){const s=o?a:`${i}.${a}`,c=l[a];this.updateField(s,c)}}catch(l){console.error("Error parsing prefill hint values:",l)}}createRootPrefillHints(t){const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-4",t.forEach(r=>{const o=document.createElement("button");o.type="button",o.className="fb-prefill-hint",r.icon?o.textContent=`${r.icon} ${r.label}`:o.textContent=r.label,o.setAttribute("data-hint-values",JSON.stringify(r.values)),o.setAttribute("data-root-hint","true"),n.appendChild(o)}),n}renderForm(t,n,r,o){const i=ht(n);if(i.length>0){console.error("Schema validation errors:",i);return}this.state.formRoot=t,this.state.schema=n,this.state.externalActions=o||null,this.state.prefill=r||{},be(t),t.setAttribute("data-fb-root","true"),tl(t,this.state.config.theme);const l=document.createElement("div");if(l.className="space-y-6",n.prefillHints&&!this.state.config.readonly){const c=this.createRootPrefillHints(n.prefillHints);l.appendChild(c)}const a=document.createElement("div"),s=n.columns||1;s===1?a.className="space-y-4":a.className=`grid grid-cols-${s} gap-4`,n.elements.forEach(c=>{var p,u;if(c.hidden||c.type==="hidden"){const f=(u=(p=r==null?void 0:r[c.key])!=null?p:c.default)!=null?u:null;a.appendChild(De(c.key,f));return}const d=It(c,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});a.appendChild(d)}),l.appendChild(a),t.appendChild(l),this.state.config.readonly||t.addEventListener("click",this.handlePrefillHintClick.bind(this)),this.state.config.readonly&&this.state.externalActions&&Array.isArray(this.state.externalActions)&&this.renderExternalActions()}validateForm(t=!1){if(!this.state.schema||!this.state.formRoot)return{valid:!0,errors:[],data:{}};const n=[],r={},o=(i,l,a=null)=>{const s=i.key,c={scopeRoot:a||this.state.formRoot,state:this.state,instance:this,path:l.path,skipValidation:t},p=il(i,s,c);return p!==null?(n.push(...p.errors),{value:p.value,spread:!!p.spread}):(console.warn(`Unknown field type "${i.type}" for key "${s}"`),{value:null,spread:!1})};return yo(o),this.state.schema.elements.forEach(i=>{var l;if(i.enableIf)try{if(!Ne(i.enableIf,r))return}catch(a){console.error(`Error evaluating enableIf for field "${i.key}" during validation:`,a)}if(i.hidden||i.type==="hidden"){const a=this.state.formRoot.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${i.key}"]`),s=(l=a==null?void 0:a.value)!=null?l:"";s!==""?r[i.key]=Bt(s):r[i.key]=i.default!==void 0?i.default:null}else{const a=o(i,{path:""});a.spread&&a.value!==null&&typeof a.value=="object"?Object.assign(r,a.value):r[i.key]=a.value}}),{valid:n.length===0,errors:n,data:r}}getFormData(){return this.validateForm(!1)}submitForm(){const t=this.validateForm(!1);return t.valid&&typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formSubmit",data:t.data,schema:this.state.schema},"*"),t}saveDraft(){const t=this.validateForm(!0);return typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formDraft",data:t.data,schema:this.state.schema},"*"),t}clearForm(){if(!this.state.schema||!this.state.formRoot){console.warn("clearForm: Form not initialized. Call renderForm() first.");return}const t=this.state.schema,n=this.state.formRoot,r=this.state.externalActions,o=this.buildHiddenFieldsData(t.elements);this.renderForm(n,t,o,r||void 0)}buildHiddenFieldsData(t){const n={};for(const r of t){const o=r.key;if(r.hidden&&r.default!==void 0&&(n[o]=r.default),r.type==="container"||r.type==="group"){const i=r,l=this.buildHiddenFieldsData(i.elements);Object.keys(l).length>0&&(o in n?typeof n[o]=="object"&&n[o]!==null&&!Array.isArray(n[o])&&(n[o]={...n[o],...l}):n[o]=l)}}return n}buildFlatKeyMap(t){var n,r;const o=new Map;for(const i of t)if(i.type==="richinput"&&i.flatOutput){const l=i,a=(n=l.textKey)!=null?n:"text",s=(r=l.filesKey)!=null?r:"files";o.set(a,{schemaKey:i.key,role:"text"}),o.set(s,{schemaKey:i.key,role:"files"})}return o}setFormData(t){if(!this.state.schema||!this.state.formRoot){console.warn("setFormData: Form not initialized. Call renderForm() first.");return}const n=this.buildFlatKeyMap(this.state.schema.elements),r=new Map;for(const o in t){const i=n.get(o);i?(r.has(i.schemaKey)||r.set(i.schemaKey,{}),r.get(i.schemaKey)[o]=t[o]):this.updateField(o,t[o])}for(const[o,i]of r)this.updateField(o,i)}updateField(t,n){if(!this.state.schema||!this.state.formRoot){console.warn("updateField: Form not initialized. Call renderForm() first.");return}const r=this.findSchemaElement(t);if(!r){console.warn(`updateField: Schema element not found for path "${t}"`);return}const o=this.findFormElementByFieldPath(t);if(!o){console.warn(`updateField: DOM element not found for path "${t}"`);return}this.updateFieldValue(o,r,t,n),this.reevaluateConditionalFields(),(this.state.config.onChange||this.state.config.onFieldChange)&&this.triggerOnChange(t,n)}updateFieldValue(t,n,r,o){const i={scopeRoot:this.state.formRoot,state:this.state,instance:this,path:""};al(n,r,o,i)||console.warn(`updateField: No updater found for field type "${n.type}" at path "${r}"`)}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(r,o)=>{r.forEach(i=>{var l,a,s;const c=o?`${o}.${i.key}`:i.key;if(i.enableIf){let p=null;if(o){const u=o.match(/^(.+)\[(\d+)\]$/);if(u){const d=u[1],f=u[2],m=this.state.formRoot.querySelector(`[data-container-item="${d}[${f}]"]`);m&&(p=m.querySelector(`[data-field-key="${i.key}"]`))}else{const d=this.state.formRoot.querySelector(`[data-container="${o}"]`);d&&(p=d.querySelector(`[data-field-key="${i.key}"]`))}}else p=this.state.formRoot.querySelector(`[data-field-key="${i.key}"]`);if(p){const u=p;try{let d;((l=i.enableIf.scope)!=null?l:"relative")==="relative"&&o&&(d=vt(t,o));const f=Ne(i.enableIf,t,d),m=u.getAttribute("data-conditionally-disabled")==="true";if(f&&m){const b=o?vt(t,o):t,y=It(i,{path:o,prefill:b&&typeof b=="object"?b:{},formData:t,state:this.state,instance:this});(a=u.parentNode)==null||a.replaceChild(y,u)}else if(!f&&!m){const b=document.createElement("div");b.className="fb-field-wrapper-disabled",b.style.display="none",b.setAttribute("data-field-key",i.key),b.setAttribute("data-conditionally-disabled","true"),(s=u.parentNode)==null||s.replaceChild(b,u)}}catch(d){console.error(`Error re-evaluating enableIf for field "${i.key}" at path "${c}":`,d)}}}if((i.type==="container"||i.type==="group")&&"elements"in i&&i.elements){const p=t==null?void 0:t[i.key];if(Array.isArray(p)){const u=this.state.formRoot.querySelectorAll("[data-container-item]");Array.from(u).filter(d=>{const f=d.getAttribute("data-container-item")||"";if(!f.startsWith(`${c}[`))return!1;const m=f.slice(c.length);return/^\[\d+\]$/.test(m)}).forEach(d=>{const f=d.getAttribute("data-container-item")||"";n(i.elements,f)})}else n(i.elements,c)}})};n(this.state.schema.elements,"")}destroy(){var t;this.state.debounceTimer!==null&&(clearTimeout(this.state.debounceTimer),this.state.debounceTimer=null),this.state.resourceIndex.clear(),this.state.formRoot&&be(this.state.formRoot),this.state.formRoot=null,this.state.schema=null,this.state.externalActions=null,this.state.config.verboseErrors&&((t=globalThis.__formBuilderInstances)==null||t.delete(this.instanceId))}}function Yn(e){return new pt(e)}return typeof window!="undefined"&&(window.FormBuilder=pt,window.createFormBuilder=Yn,window.validateSchema=ht),we.FormBuilderInstance=pt,we.createFormBuilder=Yn,we.default=pt,we.defaultTheme=Ve,we.exampleThemes=nl,we.validateSchema=ht,Object.defineProperty(we,"__esModule",{value:!0}),we})({});
1033
+ `,t.forEach(i=>{const l=document.createElement("button");l.type="button",er(l,!0);const a=n.includes(i),c=this.resolveActionLabel(i.key,i.label,null,a);l.textContent=c,l.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(i.value,i.key,null)}),o.appendChild(l)}),this.state.formRoot.appendChild(o)}renderExternalActions(){if(!this.state.externalActions||!Array.isArray(this.state.externalActions))return;const t=new Map,n=[],r=[];this.state.externalActions.forEach(i=>{!i.key||!i.value||(i.related_field?(t.has(i.related_field)||t.set(i.related_field,[]),t.get(i.related_field).push(i)):n.push(i))}),t.forEach((i,l)=>{const a=this.findFormElementByFieldPath(l);if(!a){console.warn(`External action: Could not find form element for field "${l}", treating as form-level actions`),r.push(...i);return}let c=a.closest(".fb-field-wrapper");if(c||(c=a.parentElement),!c){console.warn(`External action: Could not find wrapper for field "${l}"`);return}const s=c.querySelector(".external-actions-container");s&&s.remove();const p=document.createElement("div");p.className="external-actions-container mt-3 flex flex-wrap gap-2";const u=this.findSchemaElement(l);i.forEach(f=>{const d=document.createElement("button");d.type="button",er(d,!1);const m=this.resolveActionLabel(f.key,f.label,u);d.textContent=m,d.addEventListener("click",v=>{v.preventDefault(),v.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(f.value,f.key,f.related_field)}),p.appendChild(d)}),c.appendChild(p)});const o=[...n,...r];o.length>0&&this.renderFormLevelActions(o,n)}handlePrefillHintClick(t){const n=t.target;if(!n.classList.contains("fb-prefill-hint"))return;t.preventDefault(),t.stopPropagation();const r=n.getAttribute("data-hint-values"),o=n.getAttribute("data-root-hint")==="true",i=n.getAttribute("data-container-key");if(!r||!o&&!i){console.warn("Prefill hint missing required data attributes");return}try{const l=JSON.parse(r);for(const a in l){const c=o?a:`${i}.${a}`,s=l[a];this.updateField(c,s)}}catch(l){console.error("Error parsing prefill hint values:",l)}}createRootPrefillHints(t){const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-4",t.forEach(r=>{const o=document.createElement("button");o.type="button",o.className="fb-prefill-hint",r.icon?o.textContent=`${r.icon} ${r.label}`:o.textContent=r.label,o.setAttribute("data-hint-values",JSON.stringify(r.values)),o.setAttribute("data-root-hint","true"),n.appendChild(o)}),n}renderForm(t,n,r,o){const i=bt(n);if(i.length>0){console.error("Schema validation errors:",i);return}this.state.formRoot=t,this.state.schema=n,this.state.externalActions=o||null,this.state.prefill=r||{},ve(t),t.setAttribute("data-fb-root","true"),bl(t,this.state.config.theme);const l=document.createElement("div");if(l.className="space-y-6",n.prefillHints&&!this.state.config.readonly){const s=this.createRootPrefillHints(n.prefillHints);l.appendChild(s)}const a=document.createElement("div"),c=n.columns||1;c===1?a.className="space-y-4":a.className=`grid grid-cols-${c} gap-4`,n.elements.forEach(s=>{var p,u;if(s.type!=="markdown"&&(s.hidden||s.type==="hidden")){const d=(u=(p=r==null?void 0:r[s.key])!=null?p:s.default)!=null?u:null;a.appendChild(De(s.key,d));return}const f=Bt(s,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});a.appendChild(f)}),l.appendChild(a),t.appendChild(l),this.state.config.readonly||t.addEventListener("click",this.handlePrefillHintClick.bind(this)),this.state.config.readonly&&this.state.externalActions&&Array.isArray(this.state.externalActions)&&this.renderExternalActions()}validateForm(t=!1){if(!this.state.schema||!this.state.formRoot)return{valid:!0,errors:[],data:{}};const n=[],r={},o=(i,l,a=null)=>{var c;const s=(c=i.key)!=null?c:"",p={scopeRoot:a||this.state.formRoot,state:this.state,instance:this,path:l.path,skipValidation:t},u=El(i,s,p);return u!==null?(n.push(...u.errors),{value:u.value,spread:!!u.spread,skip:!!u.skip}):(console.warn(`Unknown field type "${i.type}" for key "${s}"`),{value:null,spread:!1})};return Lo(o),this.state.schema.elements.forEach(i=>{var l;if(i.enableIf)try{if(!ze(i.enableIf,r))return}catch(a){console.error(`Error evaluating enableIf for field "${i.key}" during validation:`,a)}if(i.type!=="markdown")if(i.hidden||i.type==="hidden"){const a=this.state.formRoot.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${i.key}"]`),c=(l=a==null?void 0:a.value)!=null?l:"";c!==""?r[i.key]=Ot(c):r[i.key]=i.default!==void 0?i.default:null}else{const a=o(i,{path:""});if(a.skip)return;a.spread&&a.value!==null&&typeof a.value=="object"?Object.assign(r,a.value):i.key&&(r[i.key]=a.value)}}),{valid:n.length===0,errors:n,data:r}}getFormData(){return this.validateForm(!1)}submitForm(){const t=this.validateForm(!1);return t.valid&&typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formSubmit",data:t.data,schema:this.state.schema},"*"),t}saveDraft(){const t=this.validateForm(!0);return typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formDraft",data:t.data,schema:this.state.schema},"*"),t}clearForm(){if(!this.state.schema||!this.state.formRoot){console.warn("clearForm: Form not initialized. Call renderForm() first.");return}const t=this.state.schema,n=this.state.formRoot,r=this.state.externalActions,o=this.buildHiddenFieldsData(t.elements);this.renderForm(n,t,o,r||void 0)}buildHiddenFieldsData(t){const n={};for(const r of t){if(r.type==="markdown"||!r.key)continue;const o=r.key;if(r.hidden&&r.default!==void 0&&(n[o]=r.default),r.type==="container"||r.type==="group"){const i=r,l=this.buildHiddenFieldsData(i.elements);Object.keys(l).length>0&&(o in n?typeof n[o]=="object"&&n[o]!==null&&!Array.isArray(n[o])&&(n[o]={...n[o],...l}):n[o]=l)}}return n}buildFlatKeyMap(t){var n,r;const o=new Map;for(const i of t)if(i.type==="richinput"&&i.flatOutput){const l=i,a=(n=l.textKey)!=null?n:"text",c=(r=l.filesKey)!=null?r:"files";o.set(a,{schemaKey:i.key,role:"text"}),o.set(c,{schemaKey:i.key,role:"files"})}return o}setFormData(t){if(!this.state.schema||!this.state.formRoot){console.warn("setFormData: Form not initialized. Call renderForm() first.");return}const n=this.buildFlatKeyMap(this.state.schema.elements),r=new Map;for(const o in t){const i=n.get(o);i?(r.has(i.schemaKey)||r.set(i.schemaKey,{}),r.get(i.schemaKey)[o]=t[o]):this.updateField(o,t[o])}for(const[o,i]of r)this.updateField(o,i)}updateField(t,n){if(!this.state.schema||!this.state.formRoot){console.warn("updateField: Form not initialized. Call renderForm() first.");return}const r=this.findSchemaElement(t);if(!r){console.warn(`updateField: Schema element not found for path "${t}"`);return}const o=this.findFormElementByFieldPath(t);if(!o){console.warn(`updateField: DOM element not found for path "${t}"`);return}this.updateFieldValue(o,r,t,n),this.reevaluateConditionalFields(),(this.state.config.onChange||this.state.config.onFieldChange)&&this.triggerOnChange(t,n)}updateFieldValue(t,n,r,o){const i={scopeRoot:this.state.formRoot,state:this.state,instance:this,path:""};wl(n,r,o,i)||console.warn(`updateField: No updater found for field type "${n.type}" at path "${r}"`)}findFieldWrapper(t,n){const r=this.state.formRoot,o=vt(t,this.state);if(!n)return r.querySelector(`[data-field-key="${o}"]`);const i=n.match(/^(.+)\[(\d+)\]$/);if(i){const a=r.querySelector(`[data-container-item="${i[1]}[${i[2]}]"]`);return a?a.querySelector(`[data-field-key="${o}"]`):null}const l=r.querySelector(`[data-container="${n}"]`);return l?l.querySelector(`[data-field-key="${o}"]`):null}applyEnableIfVisibility(t,n,r,o,i){var l,a,c,s;try{const p=((l=t.enableIf.scope)!=null?l:"relative")==="relative"&&r?gt(i,r):void 0,u=ze(t.enableIf,i,p),f=n.getAttribute("data-conditionally-disabled")==="true";if(u&&f){const d=r?gt(i,r):i,m=Bt(t,{path:r,prefill:d&&typeof d=="object"?d:{},formData:i,state:this.state,instance:this});(a=n.parentNode)==null||a.replaceChild(m,n)}else if(!u&&!f){const d=document.createElement("div");d.className="fb-field-wrapper-disabled",d.style.display="none",d.setAttribute("data-field-key",vt(t,this.state)),d.setAttribute("data-conditionally-disabled","true"),(c=n.parentNode)==null||c.replaceChild(d,n)}}catch(p){console.error(`Error re-evaluating enableIf for field "${(s=t.key)!=null?s:"<no key>"}" at path "${o}":`,p)}}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(r,o)=>{r.forEach(i=>{var l,a;const c=o?`${o}.${(l=i.key)!=null?l:""}`:(a=i.key)!=null?a:"";if(i.enableIf){const s=this.findFieldWrapper(i,o);s&&this.applyEnableIfVisibility(i,s,o,c,t)}if((i.type==="container"||i.type==="group")&&"elements"in i&&i.elements){const s=i.key?t==null?void 0:t[i.key]:void 0;if(Array.isArray(s)){const p=this.state.formRoot.querySelectorAll("[data-container-item]");(c?Array.from(p).filter(u=>{const f=u.getAttribute("data-container-item")||"";if(!f.startsWith(`${c}[`))return!1;const d=f.slice(c.length);return/^\[\d+\]$/.test(d)}):[]).forEach(u=>{const f=u.getAttribute("data-container-item")||"";n(i.elements,f)})}else n(i.elements,c)}})};n(this.state.schema.elements,"")}destroy(){var t;this.state.debounceTimer!==null&&(clearTimeout(this.state.debounceTimer),this.state.debounceTimer=null),this.state.resourceIndex.clear(),this.state.formRoot&&ve(this.state.formRoot),this.state.formRoot=null,this.state.schema=null,this.state.externalActions=null,this.state.config.verboseErrors&&((t=globalThis.__formBuilderInstances)==null||t.delete(this.instanceId))}}function nr(e){return new mt(e)}return typeof window!="undefined"&&(window.FormBuilder=mt,window.createFormBuilder=nr,window.validateSchema=bt),Ce.FormBuilderInstance=mt,Ce.createFormBuilder=nr,Ce.default=mt,Ce.defaultTheme=We,Ce.exampleThemes=vl,Ce.validateSchema=bt,Object.defineProperty(Ce,"__esModule",{value:!0}),Ce})({});