@dmitryvim/form-builder 0.2.32 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,65 +1,228 @@
1
- var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.locale||"en",o=t.config.translations[r],i=t.config.translations.en;let a=(o==null?void 0:o[e])||(i==null?void 0:i[e])||e;if(n)for(const[l,u]of Object.entries(n))a=a.replace(new RegExp(`\\{${l}\\}`,"g"),String(u));return a}function lr(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 ir(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 ar(e,t,n){var r;const o=(r=e.maxSize)!=null?r:e.maxSizeMB;o&&o!==1/0&&t.push($("hintMaxSize",n,{size:o}))}function sr(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 ur(e,t,n){e.pattern&&t.push($("hintPattern",n,{pattern:e.pattern}))}function Ee(e,t){const n=[];return lr(e,n,t),e.type!=="slider"&&ir(e,n,t),ar(e,n,t),sr(e,n,t),ur(e,n,t),n.join(" \u2022 ")}function mt(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 i=e.columns,a=[1,2,3,4];(!Number.isInteger(i)||!a.includes(i))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${i})`)}if("prefillHints"in e&&e.prefillHints){const i=e.prefillHints;Array.isArray(i)&&i.forEach((a,l)=>{if((!a.label||typeof a.label!="string")&&t.push(`schema.prefillHints[${l}] must have a 'label' property of type string`),!a.values||typeof a.values!="object")t.push(`schema.prefillHints[${l}] must have a 'values' property of type object`);else for(const u in a.values)e.elements.some(s=>s.key===u)||t.push(`schema.prefillHints[${l}] references non-existent field "${u}"`)})}function n(i,a,l){if("columns"in i&&i.columns!==void 0){const u=i.columns,s=[1,2,3,4];(!Number.isInteger(u)||!s.includes(u))&&l.push(`${a}: columns must be 1, 2, 3, or 4 (got ${u})`)}if("displayMode"in i&&i.displayMode!==void 0){const u=i.displayMode;u!=="stack"&&u!=="slides"&&l.push(`${a}: displayMode must be "stack" or "slides" (got ${JSON.stringify(u)})`)}}function r(i,a){var l,u;const s=new Set;for(const d of i)if(d.type==="richinput"&&d.flatOutput){const c=d,p=(l=c.textKey)!=null?l:"text",f=(u=c.filesKey)!=null?u:"files";for(const m of i)m!==d&&(m.key===p&&t.push(`${a}: RichInput "${d.key}" flatOutput textKey "${p}" collides with element key "${m.key}"`),m.key===f&&t.push(`${a}: RichInput "${d.key}" flatOutput filesKey "${f}" collides with element key "${m.key}"`));s.has(p)&&t.push(`${a}: RichInput "${d.key}" flatOutput textKey "${p}" collides with another flatOutput key`),s.has(f)&&t.push(`${a}: RichInput "${d.key}" flatOutput filesKey "${f}" collides with another flatOutput key`),s.add(p),s.add(f)}else d.key&&(s.has(d.key)&&t.push(`${a}: Element key "${d.key}" collides with a flatOutput richinput key`),s.add(d.key))}function o(i,a){i.forEach((l,u)=>{const s=`${a}[${u}]`;if(l.type||t.push(`${s}: missing type`),!l.key&&l.type!=="markdown"&&t.push(`${s}: missing key`),l.type==="markdown"){const d=l.content;typeof d!="string"&&t.push(`${s}: markdown element requires "content" to be a string (got ${d===null?"null":typeof d})`)}if(l.enableIf){const d=l.enableIf;(!d.key||typeof d.key!="string")&&t.push(`${s}: enableIf must have a 'key' property of type string`),"equals"in d||t.push(`${s}: enableIf must have at least one operator (equals, etc.)`)}if(l.type==="group"&&"elements"in l&&l.elements&&o(l.elements,`${s}.elements`),l.type==="container"&&l.elements){if(n(l,s,t),"prefillHints"in l&&l.prefillHints){const d=l.prefillHints;Array.isArray(d)&&d.forEach((c,p)=>{if((!c.label||typeof c.label!="string")&&t.push(`${s}: prefillHints[${p}] must have a 'label' property of type string`),!c.values||typeof c.values!="object")t.push(`${s}: prefillHints[${p}] must have a 'values' property of type object`);else for(const f in c.values)l.elements.some(m=>m.key===f)||t.push(`container "${l.key}": prefillHints[${p}] references non-existent field "${f}"`)})}o(l.elements,`${s}.elements`),r(l.elements,`${s}.elements`)}if(l.type==="select"&&l.options){const d=l.default;d!=null&&d!==""&&(l.options.some(c=>c.value===d)||t.push(`${s}: default "${d}" not in options`))}})}return Array.isArray(e.elements)&&(o(e.elements,"elements"),r(e.elements,"elements")),t}function oe(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 le(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function ht(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 ye(e,t){return e?`${e}.${t}`:t}function be(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function cr(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 bt(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 a=bt(i,e.key);if("equals"in e)return dr(a,e.equals);throw new Error("Invalid enableIf condition: no recognized operator (equals, etc.)")}function dr(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
- position: absolute;
3
- ${n?"bottom: 8px":"top: 50%; transform: translateY(-50%)"};
4
- right: 10px;
5
- font-size: var(--fb-font-size-small);
1
+ var FormBuilder=(function(Te){"use strict";function k(e,t,n){const r=t.config.locale||"en",o=t.config.translations[r],a=t.config.translations.en;let i=(o==null?void 0:o[e])||(a==null?void 0:a[e])||e;if(n)for(const[l,s]of Object.entries(n))i=i.replace(new RegExp(`\\{${l}\\}`,"g"),String(s));return i}function br(e,t,n){(e.minLength!=null||e.maxLength!=null)&&(e.minLength!=null&&e.maxLength!=null?t.push(k("hintLengthRange",n,{min:e.minLength,max:e.maxLength})):e.maxLength!=null?t.push(k("hintMaxLength",n,{max:e.maxLength})):e.minLength!=null&&t.push(k("hintMinLength",n,{min:e.minLength})))}function vr(e,t,n){(e.min!=null||e.max!=null)&&(e.min!=null&&e.max!=null?t.push(k("hintValueRange",n,{min:e.min,max:e.max})):e.max!=null?t.push(k("hintMaxValue",n,{max:e.max})):e.min!=null&&t.push(k("hintMinValue",n,{min:e.min})))}function gr(e,t,n){var r;const o=(r=e.maxSize)!=null?r:e.maxSizeMB;o&&o!==1/0&&t.push(k("hintMaxSize",n,{size:o}))}function yr(e,t,n){var r;(r=e.accept)!=null&&r.extensions&&t.push(k("hintFormats",n,{formats:e.accept.extensions.map(o=>o.toUpperCase()).join(",")}))}function xr(e,t,n){e.pattern&&t.push(k("hintPattern",n,{pattern:e.pattern}))}function Le(e,t){const n=[];return br(e,n,t),e.type!=="slider"&&vr(e,n,t),gr(e,n,t),yr(e,n,t),xr(e,n,t),n.join(" \u2022 ")}function yt(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 a=e.columns,i=[1,2,3,4];(!Number.isInteger(a)||!i.includes(a))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${a})`)}if("prefillHints"in e&&e.prefillHints){const a=e.prefillHints;Array.isArray(a)&&a.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 s in i.values)e.elements.some(c=>c.key===s)||t.push(`schema.prefillHints[${l}] references non-existent field "${s}"`)})}function n(a,i,l){if("columns"in a&&a.columns!==void 0){const s=a.columns,c=[1,2,3,4];(!Number.isInteger(s)||!c.includes(s))&&l.push(`${i}: columns must be 1, 2, 3, or 4 (got ${s})`)}if("displayMode"in a&&a.displayMode!==void 0){const s=a.displayMode;s!=="stack"&&s!=="slides"&&l.push(`${i}: displayMode must be "stack" or "slides" (got ${JSON.stringify(s)})`)}}function r(a,i){var l,s;const c=new Set;for(const d of a)if(d.type==="richinput"&&d.flatOutput){const u=d,f=(l=u.textKey)!=null?l:"text",p=(s=u.filesKey)!=null?s:"files";for(const m of a)m!==d&&(m.key===f&&t.push(`${i}: RichInput "${d.key}" flatOutput textKey "${f}" collides with element key "${m.key}"`),m.key===p&&t.push(`${i}: RichInput "${d.key}" flatOutput filesKey "${p}" collides with element key "${m.key}"`));c.has(f)&&t.push(`${i}: RichInput "${d.key}" flatOutput textKey "${f}" collides with another flatOutput key`),c.has(p)&&t.push(`${i}: RichInput "${d.key}" flatOutput filesKey "${p}" collides with another flatOutput key`),c.add(f),c.add(p)}else d.key&&(c.has(d.key)&&t.push(`${i}: Element key "${d.key}" collides with a flatOutput richinput key`),c.add(d.key))}function o(a,i){a.forEach((l,s)=>{const c=`${i}[${s}]`;if(l.type||t.push(`${c}: missing type`),!l.key&&l.type!=="markdown"&&t.push(`${c}: missing key`),l.type==="markdown"){const d=l.content;typeof d!="string"&&t.push(`${c}: markdown element requires "content" to be a string (got ${d===null?"null":typeof d})`)}if(l.enableIf){const d=l.enableIf;(!d.key||typeof d.key!="string")&&t.push(`${c}: enableIf must have a 'key' property of type string`),"equals"in d||t.push(`${c}: enableIf must have at least one operator (equals, etc.)`)}if(l.type==="group"&&"elements"in l&&l.elements&&o(l.elements,`${c}.elements`),l.type==="container"&&l.elements){if(n(l,c,t),"prefillHints"in l&&l.prefillHints){const d=l.prefillHints;Array.isArray(d)&&d.forEach((u,f)=>{if((!u.label||typeof u.label!="string")&&t.push(`${c}: prefillHints[${f}] must have a 'label' property of type string`),!u.values||typeof u.values!="object")t.push(`${c}: prefillHints[${f}] must have a 'values' property of type object`);else for(const p in u.values)l.elements.some(m=>m.key===p)||t.push(`container "${l.key}": prefillHints[${f}] references non-existent field "${p}"`)})}o(l.elements,`${c}.elements`),r(l.elements,`${c}.elements`)}if(l.type==="select"&&l.options){const d=l.default;d!=null&&d!==""&&(l.options.some(u=>u.value===d)||t.push(`${c}: default "${d}" not in options`))}})}return Array.isArray(e.elements)&&(o(e.elements,"elements"),r(e.elements,"elements")),t}function oe(e,t,n){return e.readonly===!0||t.config.readonly===!0||(n==null?void 0:n.inheritedReadonly)===!0}function et(e){return e&&typeof e=="object"&&e.constructor===Object}function ie(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function xt(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 ke(e,t){return e?`${e}.${t}`:t}function ge(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function wr(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Yt(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Xt(e){if(e==="")return null;try{return JSON.parse(e)}catch(t){return e}}function Ke(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.setAttribute("data-hidden-field","true"),n.value=Yt(t),n}function wt(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 a=parseInt(o.slice(1,-1),10);if(!Array.isArray(r)||isNaN(a))return;r=r[a]}else r=r[o]}return r}function Be(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 a;if(o==="relative")a=n!=null?n:t;else if(o==="absolute")a=t;else throw new Error(`Invalid enableIf scope: must be "relative" or "absolute" (got "${o}")`);const i=wt(a,e.key);if("equals"in e)return Cr(i,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 ye(e){const t=e.getAttribute("name");if(!t)return;const n=(e.ownerDocument||document).getElementById(`error-${t}`);n&&n.remove()}const Gt='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M10 11v6"/><path d="M14 11v6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>';function Er(e){if(e.head.querySelector("[data-fb-theming-hooks]"))return;const t=e.createElement("style");t.setAttribute("data-fb-theming-hooks",""),t.textContent=`
2
+ [data-fb-slide-card] {
3
+ background: var(--fb-slide-card-bg);
4
+ box-shadow: var(--fb-slide-card-shadow);
5
+ border-radius: var(--fb-slide-card-radius);
6
+ min-height: var(--fb-slide-card-min-height);
7
+ padding: var(--fb-slide-card-padding);
8
+ }
9
+ [data-fb-label-row] > label {
10
+ font-size: var(--fb-label-section-font-size);
11
+ letter-spacing: var(--fb-label-section-letter-spacing);
12
+ text-transform: var(--fb-label-section-text-transform);
13
+ }
14
+ /* Per-item remove (trash) button used by multi-container items. Shares the
15
+ same faint-on-rest, error-on-hover palette as .fb-chip-remove. */
16
+ .fb-item-remove {
17
+ color: var(--fb-text-faint-color, #94a3b8);
18
+ background-color: transparent;
19
+ transition: color var(--fb-transition-duration), background-color var(--fb-transition-duration);
20
+ }
21
+ .fb-item-remove:hover {
22
+ color: var(--fb-error-color);
23
+ background-color: var(--fb-background-hover-color);
24
+ }
25
+ `,e.head.appendChild(t)}function Ct(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 kr(e){e.addEventListener("keydown",t=>{t.key==="Enter"&&t.preventDefault()}),e.addEventListener("paste",t=>{var n,r,o,a;const i=(r=(n=t.clipboardData)==null?void 0:n.getData("text"))!=null?r:"";if(!/[\r\n]/.test(i))return;t.preventDefault();const l=i.replace(/[\r\n]+/g," "),s=(o=e.selectionStart)!=null?o:e.value.length,c=(a=e.selectionEnd)!=null?a:e.value.length,d=e.value.slice(0,s),u=e.value.slice(c);e.value=d+l+u;const f=s+l.length;e.setSelectionRange(f,f),e.dispatchEvent(new Event("input",{bubbles:!0}))})}function Se(e,t){const n=e.querySelector(":scope > [data-fb-label-row]");n&&n.appendChild(t)}function Ae(e,t,n={}){var r;const o=(r=n.label)!=null?r:"",a=n.showCounter!==!1,i=document.createElement("div");i.className="fb-add-row mt-2",i.style.cssText="display:flex;align-items:stretch;width:100%;";const l=document.createElement("button");l.type="button",l.className=`add-${e}-btn`,l.style.cssText=`
26
+ flex: 1 1 auto;
27
+ display: inline-flex;
28
+ align-items: center;
29
+ justify-content: center;
30
+ gap: 6px;
31
+ padding: 6px 10px;
32
+ border: 1px dashed var(--fb-primary-color);
33
+ border-radius: var(--fb-border-radius);
34
+ background: transparent;
35
+ color: var(--fb-primary-color);
36
+ font-size: var(--fb-font-size-small, var(--fb-font-size));
37
+ font-weight: 500;
38
+ font-family: var(--fb-font-family);
39
+ cursor: pointer;
40
+ transition: border-color var(--fb-transition-duration), color var(--fb-transition-duration), background-color var(--fb-transition-duration);
41
+ `,l.textContent=o?`+ ${o}`:"+",l.addEventListener("mouseenter",()=>{l.disabled||(l.style.borderStyle="solid",l.style.backgroundColor="var(--fb-background-hover-color)")}),l.addEventListener("mouseleave",()=>{l.style.borderStyle="dashed",l.style.backgroundColor="transparent"}),l.onclick=t;const s=document.createElement("span");return s.className="fb-add-counter",s.style.cssText=`
42
+ margin-left: auto;
43
+ font-size: var(--fb-font-size-small, 0.875rem);
6
44
  color: var(--fb-text-secondary-color);
7
- pointer-events: none;
45
+ font-weight: 400;
46
+ `,a||(s.style.display="none"),i.appendChild(l),{row:i,button:l,counter:s,update:(c,d)=>{const u=c>=d;i.style.display=u?"none":"flex",l.style.display=u?"none":"inline-flex",l.disabled=u,a&&(s.textContent=`${c}/${d===1/0?"\u221E":d}`)}}}function $r(e,t={}){var n;const r=(n=t.label)!=null?n:"",o=document.createElement("button");o.type="button",o.className="add-container-btn fb-slide-add",o.style.cssText=`
47
+ display: flex;
48
+ flex-direction: column;
49
+ align-items: center;
50
+ justify-content: center;
51
+ gap: 12px;
52
+ width: 100%;
53
+ min-height: 180px;
54
+ align-self: stretch;
55
+ padding: 24px 16px;
56
+ border: 1.5px dashed var(--fb-primary-color);
57
+ border-radius: var(--fb-border-radius);
58
+ background: transparent;
59
+ color: var(--fb-primary-color);
60
+ font-size: var(--fb-font-size-small, var(--fb-font-size));
61
+ font-weight: 500;
62
+ font-family: var(--fb-font-family);
63
+ cursor: pointer;
64
+ transition: border-color var(--fb-transition-duration), color var(--fb-transition-duration), background-color var(--fb-transition-duration);
65
+ `;const a=document.createElement("span");if(a.className="fb-slide-add-circle",a.style.cssText=`
66
+ display: inline-flex;
67
+ align-items: center;
68
+ justify-content: center;
69
+ width: 36px;
70
+ height: 36px;
71
+ border: 1px solid var(--fb-primary-color);
72
+ border-radius: 50%;
8
73
  background: var(--fb-background-color);
9
- padding: 0 4px;
10
- `;const o=()=>{const i=t.value.length,a=e.minLength,l=e.maxLength;if(a==null&&l==null){r.textContent="";return}i===0||a!=null&&i<a?(a!=null&&l!=null?r.textContent=`${a}-${l}`:l!=null?r.textContent=`\u2264${l}`:a!=null&&(r.textContent=`\u2265${a}`),r.style.color="var(--fb-text-secondary-color)"):l!=null&&i>l?(r.textContent=`${i}/${l}`,r.style.color="var(--fb-error-color)"):(l!=null?r.textContent=`${i}/${l}`:r.textContent=`${i}`,r.style.color="var(--fb-text-secondary-color)")};return t.addEventListener("input",o),o(),r}function fr(e,t,n,r){const o=t.state,i=oe(e,o,t),a=document.createElement("div");a.style.cssText="position: relative;";const l=document.createElement("input");if(l.type="text",l.className="w-full rounded-lg",l.style.cssText=`
74
+ font-size: 20px;
75
+ line-height: 1;
76
+ color: inherit;
77
+ transition: inherit;
78
+ `,a.textContent="+",o.appendChild(a),r){const l=document.createElement("span");l.textContent=r,o.appendChild(l)}o.addEventListener("mouseenter",()=>{o.disabled||(o.style.borderStyle="solid",o.style.backgroundColor="var(--fb-background-hover-color)")}),o.addEventListener("mouseleave",()=>{o.style.borderStyle="dashed",o.style.backgroundColor="transparent"}),o.onclick=e;const i=document.createElement("span");return i.className="fb-add-counter",i.style.cssText=`
79
+ margin-left: auto;
80
+ font-size: var(--fb-font-size-small, 0.875rem);
81
+ color: var(--fb-text-secondary-color);
82
+ font-weight: 400;
83
+ `,{tile:o,counter:i,update:(l,s)=>{const c=l>=s;o.style.display=c?"none":"flex",o.disabled=c,i.textContent=`${l}/${s===1/0?"\u221E":s}`}}}function Zt(e,t=!1){e.style.cssText=`
84
+ background-color: var(--fb-action-bg-color);
85
+ color: var(--fb-action-text-color);
86
+ border: var(--fb-border-width) solid var(--fb-action-border-color);
87
+ padding: ${t?"0.5rem 1rem":"0.5rem 0.75rem"};
88
+ font-size: var(--fb-font-size);
89
+ font-weight: var(--fb-font-weight-medium);
90
+ border-radius: var(--fb-border-radius);
91
+ transition: all var(--fb-transition-duration);
92
+ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
93
+ `,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 Lr(e){if(e.head.querySelector("[data-fb-chip-styles]"))return;const t=e.createElement("style");t.setAttribute("data-fb-chip-styles",""),t.textContent=`
94
+ .fb-chip-list { display: flex; flex-direction: column; gap: 4px; }
95
+ .fb-chip {
96
+ display: flex;
97
+ align-items: center;
98
+ gap: 8px;
99
+ padding: 5px 6px 5px 10px;
100
+ background: var(--fb-chip-bg, var(--fb-background-color, #fff));
101
+ border: 1px solid var(--fb-chip-border, var(--fb-border-color, #e2e8f0));
102
+ border-radius: 6px;
103
+ position: relative;
104
+ transition: border-color var(--fb-transition-duration, 0.15s);
105
+ }
106
+ .fb-chip:hover { border-color: var(--fb-border-hover-color, var(--fb-border-color, #cbd5e1)); }
107
+ .fb-chip:focus-within { border-color: var(--fb-border-focus-color, var(--fb-primary-color, #2f5bea)); }
108
+ .fb-chip-dot {
109
+ flex: 0 0 6px;
110
+ width: 6px;
111
+ height: 6px;
112
+ border-radius: 50%;
113
+ background: var(--fb-chip-dot, var(--fb-primary-color, #2f5bea));
114
+ }
115
+ .fb-chip-input {
116
+ flex: 1;
117
+ min-width: 0;
118
+ padding: 2px 0;
119
+ border: 0;
120
+ outline: none;
121
+ background: transparent;
122
+ color: var(--fb-chip-text, var(--fb-text-color, inherit));
123
+ font-size: var(--fb-font-size, 14px);
124
+ font-family: var(--fb-font-family, inherit);
125
+ line-height: 1.4;
126
+ }
127
+ .fb-chip-input::placeholder { color: var(--fb-text-placeholder-color, #94a3b8); }
128
+ .fb-chip-input:read-only { color: var(--fb-text-secondary-color, #475569); }
129
+ .fb-chip-remove {
130
+ flex: 0 0 auto;
131
+ width: 22px;
132
+ height: 22px;
133
+ display: inline-flex;
134
+ align-items: center;
135
+ justify-content: center;
136
+ padding: 0;
137
+ border: 0;
138
+ border-radius: 4px;
139
+ background: transparent;
140
+ color: var(--fb-text-faint-color, #94a3b8);
141
+ cursor: pointer;
142
+ opacity: 0;
143
+ transition: opacity 0.12s, color 0.12s, background-color 0.12s;
144
+ }
145
+ .fb-chip:hover .fb-chip-remove,
146
+ .fb-chip-remove:focus-visible { opacity: 1; }
147
+ .fb-chip-remove:hover {
148
+ color: var(--fb-error-color, #dc2626);
149
+ background: var(--fb-background-hover-color, #f1f5f9);
150
+ }
151
+ .fb-chip-remove:disabled { opacity: 0 !important; pointer-events: none; }
152
+ `,e.head.appendChild(t)}function tt(e,t){const n=document.createElement("span");n.className="char-counter",n.style.cssText=`
153
+ margin-top: 4px;
154
+ padding-right: 12px;
155
+ text-align: right;
156
+ font-size: var(--fb-font-size-small);
157
+ line-height: 1;
158
+ color: var(--fb-error-color);
159
+ pointer-events: none;
160
+ display: none;
161
+ `;const r=()=>{const o=t.value.length,a=e.maxLength;a!=null&&o>a?(n.textContent=`${o}/${a}`,n.style.display="block"):(n.textContent="",n.style.display="none")};return t.addEventListener("input",r),r(),n}function Sr(e,t,n,r){const o=t.state,a=oe(e,o,t),i=document.createElement("div");i.style.cssText="position: relative;";const l=!a&&(e.minLength!=null||e.maxLength!=null),s=document.createElement("textarea");if(s.rows=1,s.className="w-full rounded-lg",s.style.cssText=`
11
162
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
12
- padding-right: 60px;
13
163
  border: var(--fb-border-width) solid var(--fb-border-color);
14
164
  border-radius: var(--fb-border-radius);
15
- background-color: ${i?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
165
+ background-color: ${a?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
16
166
  color: var(--fb-text-color);
17
167
  font-size: var(--fb-font-size);
18
168
  font-family: var(--fb-font-family);
169
+ line-height: var(--fb-line-height, 1.5);
19
170
  transition: all var(--fb-transition-duration) ease-in-out;
20
171
  width: 100%;
21
172
  box-sizing: border-box;
22
- `,l.name=r,l.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",l.value=t.prefill[e.key]||e.default||"",l.readOnly=i,i||(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)")})),!i&&t.instance){const u=()=>{const s=l.value===""?null:l.value;t.instance.triggerOnChange(r,s)};l.addEventListener("blur",u),l.addEventListener("input",u)}if(a.appendChild(l),!i&&(e.minLength!=null||e.maxLength!=null)){const u=je(e,l,!1);a.appendChild(u)}n.appendChild(a)}function pr(e,t,n,r){var o,i;const a=t.state,l=oe(e,a,t),u=t.prefill[e.key]||[],s=Array.isArray(u)?[...u]:[],d=(o=e.minCount)!=null?o:1,c=(i=e.maxCount)!=null?i:1/0;for(;s.length<d;)s.push(e.default||"");const p=document.createElement("div");p.className="space-y-2",n.appendChild(p);function f(){p.querySelectorAll(".multiple-text-item").forEach((v,x)=>{const E=v.querySelector("input");E&&(E.name=`${r}[${x}]`)})}function m(v="",x=-1){const E=document.createElement("div");E.className="multiple-text-item flex items-center gap-2";const k=document.createElement("div");k.style.cssText="position: relative; flex: 1;";const b=document.createElement("input");if(b.type="text",b.style.cssText=`
23
- padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
24
- padding-right: 60px;
25
- border: var(--fb-border-width) solid var(--fb-border-color);
26
- border-radius: var(--fb-border-radius);
27
- background-color: ${l?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
28
- color: var(--fb-text-color);
29
- font-size: var(--fb-font-size);
30
- font-family: var(--fb-font-family);
31
- transition: all var(--fb-transition-duration) ease-in-out;
32
- width: 100%;
33
- box-sizing: border-box;
34
- `,b.placeholder=e.placeholder||$("placeholderText",a),b.value=v,b.readOnly=l,l||(b.addEventListener("focus",()=>{b.style.borderColor="var(--fb-border-focus-color)",b.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",b.style.outlineOffset="0"}),b.addEventListener("blur",()=>{b.style.borderColor="var(--fb-border-color)",b.style.outline="none"}),b.addEventListener("mouseenter",()=>{document.activeElement!==b&&(b.style.borderColor="var(--fb-border-hover-color)")}),b.addEventListener("mouseleave",()=>{document.activeElement!==b&&(b.style.borderColor="var(--fb-border-color)")})),!l&&t.instance){const w=()=>{const F=b.value===""?null:b.value;t.instance.triggerOnChange(b.name,F)};b.addEventListener("blur",w),b.addEventListener("input",w)}if(k.appendChild(b),!l&&(e.minLength!=null||e.maxLength!=null)){const w=je(e,b,!1);k.appendChild(w)}return E.appendChild(k),x===-1?p.appendChild(E):p.insertBefore(E,p.children[x]),f(),E}function g(){if(l)return;const v=p.querySelectorAll(".multiple-text-item"),x=v.length;v.forEach(E=>{let k=E.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=`
35
- color: var(--fb-error-color);
36
- background-color: transparent;
37
- transition: background-color var(--fb-transition-duration);
38
- `,k.innerHTML="\u2715",k.addEventListener("mouseenter",()=>{k.style.backgroundColor="var(--fb-background-hover-color)"}),k.addEventListener("mouseleave",()=>{k.style.backgroundColor="transparent"}),k.onclick=()=>{const w=Array.from(p.children).indexOf(E);p.children.length>d&&(s.splice(w,1),E.remove(),f(),h(),g())},E.appendChild(k));const b=x<=d;k.disabled=b,k.style.opacity=b?"0.5":"1",k.style.pointerEvents=b?"none":"auto"})}let y=null,C=null;if(!l){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const v=document.createElement("button");v.type="button",v.className="add-text-btn px-3 py-1 rounded",v.style.cssText=`
39
- color: var(--fb-primary-color);
40
- border: var(--fb-border-width) solid var(--fb-primary-color);
41
- background-color: transparent;
42
- font-size: var(--fb-font-size);
43
- transition: all var(--fb-transition-duration);
44
- `,v.textContent="+",v.addEventListener("mouseenter",()=>{v.style.backgroundColor="var(--fb-background-hover-color)"}),v.addEventListener("mouseleave",()=>{v.style.backgroundColor="transparent"}),v.onclick=()=>{s.push(e.default||""),m(e.default||""),h(),g()},C=document.createElement("span"),C.className="text-sm text-gray-500",y.appendChild(v),y.appendChild(C),n.appendChild(y)}function h(){if(!y||!C)return;const v=y.querySelector(".add-text-btn");if(v){const x=s.length>=c;v.disabled=x,v.style.opacity=x?"0.5":"1",v.style.pointerEvents=x?"none":"auto"}C.textContent=`${s.length}/${c===1/0?"\u221E":c}`}s.forEach(v=>m(v)),h(),g()}function Ut(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:u}=n,s=(c,p)=>{var f,m;if(!c)return;const g=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let y=document.getElementById(g);p?(c.classList.add("invalid"),c.title=p,y||(y=document.createElement("div"),y.id=g,y.className="error-message",y.style.cssText=`
173
+ resize: none;
174
+ overflow: hidden;
175
+ word-break: break-word;
176
+ overflow-wrap: anywhere;
177
+ `,s.name=r,s.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",s.value=t.prefill[e.key]||e.default||"",s.readOnly=a,kr(s),Ct(s),a||(s.addEventListener("focus",()=>{s.style.borderColor="var(--fb-border-focus-color)",s.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",s.style.outlineOffset="0"}),s.addEventListener("blur",()=>{s.style.borderColor="var(--fb-border-color)",s.style.outline="none"}),s.addEventListener("mouseenter",()=>{document.activeElement!==s&&(s.style.borderColor="var(--fb-border-hover-color)")}),s.addEventListener("mouseleave",()=>{document.activeElement!==s&&(s.style.borderColor="var(--fb-border-color)")})),!a&&t.instance){const c=()=>{const d=s.value===""?null:s.value;t.instance.triggerOnChange(r,d)};s.addEventListener("blur",c),s.addEventListener("input",c)}if(i.appendChild(s),l){const c=tt(e,s);i.appendChild(c)}n.appendChild(i)}function Tr(e,t,n,r){var o,a;const i=t.state,l=oe(e,i,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],d=(o=e.minCount)!=null?o:1,u=(a=e.maxCount)!=null?a:1/0;for(;c.length<d;)c.push(e.default||"");Lr(document);const f=document.createElement("div");f.className="fb-chip-list",n.appendChild(f);function p(){f.querySelectorAll(".fb-chip-input").forEach((h,y)=>{h.name=`${r}[${y}]`;const v=h.closest(".fb-chip"),C=v==null?void 0:v.nextElementSibling;C&&C.classList.contains("error-message")&&(C.id=`error-${h.name}`)})}function m(h=""){const y=document.createElement("div");y.className="fb-chip";const v=document.createElement("span");v.className="fb-chip-dot",v.setAttribute("aria-hidden","true"),y.appendChild(v);const C=document.createElement("input");if(C.type="text",C.className="fb-chip-input",C.value=h,C.placeholder=e.placeholder||k("placeholderText",i),C.readOnly=l,y.appendChild(C),!l&&t.instance){const E=()=>{t.instance.triggerOnChange(C.name,C.value===""?null:C.value)};C.addEventListener("blur",E),C.addEventListener("input",E)}if(!l){const E=document.createElement("button");E.type="button",E.className="fb-chip-remove",E.setAttribute("aria-label",k("removeElement",i)),E.innerHTML=Gt,E.onclick=()=>{const x=f.querySelectorAll(".fb-chip"),L=Array.prototype.indexOf.call(x,y);if(L<0||x.length<=d)return;c.splice(L,1);const q=y.nextElementSibling;q&&q.classList.contains("error-message")&&q.remove(),y.remove(),p(),w(),b()},y.appendChild(E)}return f.appendChild(y),p(),y}function b(){if(l)return;const h=f.querySelectorAll(".fb-chip").length<=d;f.querySelectorAll(".fb-chip-remove").forEach(y=>{y.disabled=h})}let g=null;if(!l){const h=Ae("text",()=>{c.push(e.default||""),m(e.default||""),w(),b()},{label:e.addLabel});g=h.update,Se(n,h.counter),n.appendChild(h.row)}function w(){g&&g(c.length,u)}c.forEach(h=>m(h)),w(),b()}function Qt(e,t,n){var r,o,a;const i=[],{scopeRoot:l,skipValidation:s}=n,c=(u,f)=>{var p,m,b;if(!u)return;const g=`error-${u.getAttribute("name")||Math.random().toString(36).substring(7)}`;let w=document.getElementById(g);if(f){if(u.classList.add("invalid"),u.title=f,!w){w=document.createElement("div"),w.id=g,w.className="error-message",w.style.cssText=`
45
178
  color: var(--fb-error-color);
46
179
  font-size: var(--fb-font-size-small);
47
180
  margin-top: 0.25rem;
48
- `,c.nextSibling?(f=c.parentNode)==null||f.insertBefore(y,c.nextSibling):(m=c.parentNode)==null||m.appendChild(y)),y.textContent=p,y.style.display="block"):(c.classList.remove("invalid"),c.title="",y&&y.remove())},d=(c,p,f)=>{let m=!1;const{state:g}=n;if(!u&&p){if(e.minLength!==void 0&&e.minLength!==null&&p.length<e.minLength){const y=$("minLength",g,{min:e.minLength});a.push(`${f}: ${y}`),s(c,y),m=!0}else if(e.maxLength!==void 0&&e.maxLength!==null&&p.length>e.maxLength){const y=$("maxLength",g,{max:e.maxLength});a.push(`${f}: ${y}`),s(c,y),m=!0}else if(e.pattern)try{if(!new RegExp(e.pattern).test(p)){const y=$("patternMismatch",g);a.push(`${f}: ${y}`),s(c,y),m=!0}}catch(y){const C=$("invalidPattern",g);a.push(`${f}: ${C}`),s(c,C),m=!0}}m||s(c,null)};if(e.multiple){const c=l.querySelectorAll(`[name^="${t}["]`),p=[],f=[];if(c.forEach((m,g)=>{var y;const C=(y=m==null?void 0:m.value)!=null?y:"";f.push(C),p.push(C===""?null:C),d(m,C,`${t}[${g}]`)}),!u){const{state:m}=n,g=(r=e.minCount)!=null?r:1,y=(o=e.maxCount)!=null?o:1/0,C=f.filter(h=>h.trim()!=="");e.required&&C.length===0&&a.push(`${t}: ${$("required",m)}`),C.length<g&&a.push(`${t}: ${$("minItems",m,{min:g})}`),C.length>y&&a.push(`${t}: ${$("maxItems",m,{max:y})}`)}return{value:p,errors:a}}else{const c=l.querySelector(`[name$="${t}"]`),p=(i=c==null?void 0:c.value)!=null?i:"";if(!u&&e.required&&p===""){const f=$("required",n.state);return a.push(`${t}: ${f}`),s(c,f),{value:null,errors:a}}return c&&d(c,p,t),{value:p===""?null:p,errors:a}}}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((a,l)=>{l<n.length&&(a.value=n[l]!=null?String(n[l]):"",a.classList.remove("invalid"),a.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 Wt(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 mr(e,t,n,r){const o=t.state,i=oe(e,o,t),a=document.createElement("div");a.style.cssText="position: relative;";const l=document.createElement("textarea");if(l.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",l.style.cssText=`
181
+ `;const h=((p=u.closest)==null?void 0:p.call(u,".fb-chip"))||u;h.nextSibling?(m=h.parentNode)==null||m.insertBefore(w,h.nextSibling):(b=h.parentNode)==null||b.appendChild(w)}w.textContent=f,w.style.display="block"}else u.classList.remove("invalid"),u.title="",w&&w.remove()},d=(u,f,p)=>{let m=!1;const{state:b}=n;if(!s&&f){if(e.minLength!==void 0&&e.minLength!==null&&f.length<e.minLength){const g=k("minLength",b,{min:e.minLength});i.push(`${p}: ${g}`),c(u,g),m=!0}else if(e.maxLength!==void 0&&e.maxLength!==null&&f.length>e.maxLength){const g=k("maxLength",b,{max:e.maxLength});i.push(`${p}: ${g}`),c(u,g),m=!0}else if(e.pattern)try{if(!new RegExp(e.pattern).test(f)){const g=k("patternMismatch",b);i.push(`${p}: ${g}`),c(u,g),m=!0}}catch(g){const w=k("invalidPattern",b);i.push(`${p}: ${w}`),c(u,w),m=!0}}m||c(u,null)};if(e.multiple){const u=l.querySelectorAll(`[name^="${t}\\["]`),f=[],p=[];if(u.forEach((m,b)=>{var g;const w=(g=m==null?void 0:m.value)!=null?g:"";p.push(w),f.push(w===""?null:w),d(m,w,`${t}[${b}]`)}),!s){const{state:m}=n,b=(r=e.minCount)!=null?r:1,g=(o=e.maxCount)!=null?o:1/0,w=p.filter(h=>h.trim()!=="");e.required&&w.length===0&&i.push(`${t}: ${k("required",m)}`),w.length<b&&i.push(`${t}: ${k("minItems",m,{min:b})}`),w.length>g&&i.push(`${t}: ${k("maxItems",m,{max:g})}`)}return{value:f,errors:i}}else{const u=l.querySelector(`[name$="${t}"]`),f=(a=u==null?void 0:u.value)!=null?a:"";if(!s&&e.required&&f===""){const p=k("required",n.state);return i.push(`${t}: ${p}`),c(u,p),{value:null,errors:i}}return u&&d(u,f,t),{value:f===""?null:f,errors:i}}}function en(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 a=o.querySelectorAll(`[name^="${t}\\["]`);a.forEach((i,l)=>{l<n.length&&(i.value=n[l]!=null?String(n[l]):"",i.classList.remove("invalid"),i.title="",ye(i),i.dispatchEvent(new Event("input",{bubbles:!0})))}),n.length!==a.length&&console.warn(`updateTextField: Multiple field "${t}" has ${a.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=o.querySelector(`[name="${t}"]`);a&&(a.value=n!=null?String(n):"",a.classList.remove("invalid"),a.title="",ye(a),a instanceof HTMLTextAreaElement&&a.dispatchEvent(new Event("input",{bubbles:!0})))}}function Ar(e,t,n,r){const o=t.state,a=oe(e,o,t),i=document.createElement("div");i.style.cssText="position: relative;";const l=document.createElement("textarea");if(l.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",l.style.cssText=`
49
182
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x) 24px var(--fb-input-padding-x);
50
183
  font-size: var(--fb-font-size);
51
184
  font-family: var(--fb-font-family);
52
- `,l.name=r,l.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",l.rows=e.rows||4,l.value=t.prefill[e.key]||e.default||"",l.readOnly=i,!i&&t.instance){const u=()=>{const s=l.value===""?null:l.value;t.instance.triggerOnChange(r,s)};l.addEventListener("blur",u),l.addEventListener("input",u)}if((e.autoExpand||i)&&Wt(l),a.appendChild(l),!i&&(e.minLength!=null||e.maxLength!=null)){const u=je(e,l,!0);a.appendChild(u)}n.appendChild(a)}function hr(e,t,n,r){var o,i;const a=t.state,l=oe(e,a,t),u=t.prefill[e.key]||[],s=Array.isArray(u)?[...u]:[],d=(o=e.minCount)!=null?o:1,c=(i=e.maxCount)!=null?i:1/0;for(;s.length<d;)s.push(e.default||"");const p=document.createElement("div");p.className="space-y-2",n.appendChild(p);function f(){p.querySelectorAll(".multiple-textarea-item").forEach((v,x)=>{const E=v.querySelector("textarea");E&&(E.name=`${r}[${x}]`)})}function m(v="",x=-1){const E=document.createElement("div");E.className="multiple-textarea-item";const k=document.createElement("div");k.style.cssText="position: relative;";const b=document.createElement("textarea");if(b.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",b.style.cssText=`
185
+ `,l.name=r,l.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",l.rows=e.rows||4,l.value=t.prefill[e.key]||e.default||"",l.readOnly=a,!a&&t.instance){const s=()=>{const c=l.value===""?null:l.value;t.instance.triggerOnChange(r,c)};l.addEventListener("blur",s),l.addEventListener("input",s)}if((e.autoExpand||a)&&Ct(l),i.appendChild(l),!a&&(e.minLength!=null||e.maxLength!=null)){const s=tt(e,l);i.appendChild(s)}n.appendChild(i)}function Fr(e,t,n,r){var o,a;const i=t.state,l=oe(e,i,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],d=(o=e.minCount)!=null?o:1,u=(a=e.maxCount)!=null?a:1/0;for(;c.length<d;)c.push(e.default||"");const f=document.createElement("div");f.className="space-y-2",n.appendChild(f);function p(){f.querySelectorAll(".multiple-textarea-item").forEach((h,y)=>{const v=h.querySelector("textarea");v&&(v.name=`${r}[${y}]`)})}function m(h="",y=-1){const v=document.createElement("div");v.className="multiple-textarea-item";const C=document.createElement("div");C.style.cssText="position: relative;";const E=document.createElement("textarea");if(E.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",E.style.cssText=`
53
186
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x) 24px var(--fb-input-padding-x);
54
187
  font-size: var(--fb-font-size);
55
188
  font-family: var(--fb-font-family);
56
- `,b.placeholder=e.placeholder||$("placeholderText",a),b.rows=e.rows||4,b.value=v,b.readOnly=l,!l&&t.instance){const w=()=>{const F=b.value===""?null:b.value;t.instance.triggerOnChange(b.name,F)};b.addEventListener("blur",w),b.addEventListener("input",w)}if((e.autoExpand||l)&&Wt(b),k.appendChild(b),!l&&(e.minLength!=null||e.maxLength!=null)){const w=je(e,b,!0);k.appendChild(w)}return E.appendChild(k),x===-1?p.appendChild(E):p.insertBefore(E,p.children[x]),f(),E}function g(){if(l)return;const v=p.querySelectorAll(".multiple-textarea-item"),x=v.length;v.forEach(E=>{let k=E.querySelector(".remove-item-btn");k||(k=document.createElement("button"),k.type="button",k.className="remove-item-btn mt-1 px-2 py-1 text-red-600 hover:bg-red-50 rounded text-sm",k.innerHTML="\u2715",k.onclick=()=>{const w=Array.from(p.children).indexOf(E);p.children.length>d&&(s.splice(w,1),E.remove(),f(),h(),g())},E.appendChild(k));const b=x<=d;k.disabled=b,k.style.opacity=b?"0.5":"1",k.style.pointerEvents=b?"none":"auto"})}let y=null,C=null;if(!l){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const v=document.createElement("button");v.type="button",v.className="add-textarea-btn px-3 py-1 rounded",v.style.cssText=`
57
- color: var(--fb-primary-color);
58
- border: var(--fb-border-width) solid var(--fb-primary-color);
59
- background-color: transparent;
189
+ `,E.placeholder=e.placeholder||k("placeholderText",i),E.rows=e.rows||4,E.value=h,E.readOnly=l,!l&&t.instance){const x=()=>{const L=E.value===""?null:E.value;t.instance.triggerOnChange(E.name,L)};E.addEventListener("blur",x),E.addEventListener("input",x)}if((e.autoExpand||l)&&Ct(E),C.appendChild(E),!l&&(e.minLength!=null||e.maxLength!=null)){const x=tt(e,E);C.appendChild(x)}return v.appendChild(C),y===-1?f.appendChild(v):f.insertBefore(v,f.children[y]),p(),v}function b(){if(l)return;const h=f.querySelectorAll(".multiple-textarea-item"),y=h.length;h.forEach(v=>{let C=v.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 x=Array.from(f.children).indexOf(v);f.children.length>d&&(c.splice(x,1),v.remove(),p(),w(),b())},v.appendChild(C));const E=y<=d;C.disabled=E,C.style.opacity=E?"0.5":"1",C.style.pointerEvents=E?"none":"auto"})}let g=null;if(!l){const h=Ae("textarea",()=>{c.push(e.default||""),m(e.default||""),w(),b()},{label:e.addLabel});g=h.update,Se(n,h.counter),n.appendChild(h.row)}function w(){g&&g(c.length,u)}c.forEach(h=>m(h)),w(),b()}function Mr(e,t,n){return Qt(e,t,n)}function zr(e,t,n,r){en(e,t,n,r);const{scopeRoot:o,state:a}=r;if(e.autoExpand||oe(e,a))if(e.multiple)o.querySelectorAll(`textarea[name^="${t}["]`).forEach(i=>{i.dispatchEvent(new Event("input"))});else{const i=o.querySelector(`textarea[name="${t}"]`);i&&i.dispatchEvent(new Event("input"))}}function Nr(e){const t="fb-number-stepper-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
190
+ .fb-stepper-input::-webkit-outer-spin-button,
191
+ .fb-stepper-input::-webkit-inner-spin-button {
192
+ -webkit-appearance: none;
193
+ margin: 0;
194
+ }
195
+ .fb-stepper-input { -moz-appearance: textfield; }
196
+ `,e.head.appendChild(n)}function qr(e,t,n){var r;Nr(e.ownerDocument);const o=(r=t.step)!=null?r:1,a=t.min,i=t.max,l=document.createElement("div");l.className="fb-stepper",l.style.cssText=`
197
+ display: inline-flex;
198
+ align-items: stretch;
199
+ border: var(--fb-border-width) solid var(--fb-border-color);
200
+ border-radius: var(--fb-border-radius);
201
+ overflow: hidden;
202
+ background: var(--fb-background-color);
203
+ `;const s=(c,d)=>{const u=document.createElement("button");return u.type="button",u.textContent=c,u.tabIndex=-1,u.style.cssText=`
204
+ width: 32px;
205
+ border: none;
206
+ background: transparent;
207
+ color: var(--fb-text-color);
60
208
  font-size: var(--fb-font-size);
61
- transition: all var(--fb-transition-duration);
62
- `,v.textContent="+",v.addEventListener("mouseenter",()=>{v.style.backgroundColor="var(--fb-background-hover-color)"}),v.addEventListener("mouseleave",()=>{v.style.backgroundColor="transparent"}),v.onclick=()=>{s.push(e.default||""),m(e.default||""),h(),g()},C=document.createElement("span"),C.className="text-sm text-gray-500",y.appendChild(v),y.appendChild(C),n.appendChild(y)}function h(){if(!y||!C)return;const v=y.querySelector(".add-textarea-btn");if(v){const x=s.length>=c;v.disabled=x,v.style.opacity=x?"0.5":"1",v.style.pointerEvents=x?"none":"auto"}C.textContent=`${s.length}/${c===1/0?"\u221E":c}`}s.forEach(v=>m(v)),h(),g()}function br(e,t,n){return Ut(e,t,n)}function vr(e,t,n,r){Pt(e,t,n,r);const{scopeRoot:o,state:i}=r;if(e.autoExpand||oe(e,i))if(e.multiple)o.querySelectorAll(`textarea[name^="${t}["]`).forEach(a=>{a.dispatchEvent(new Event("input"))});else{const a=o.querySelector(`textarea[name="${t}"]`);a&&a.dispatchEvent(new Event("input"))}}function Vt(e,t){const n=document.createElement("span");n.className="number-range-hint",n.style.cssText=`
209
+ font-family: var(--fb-font-family);
210
+ cursor: ${n?"default":"pointer"};
211
+ user-select: none;
212
+ `,n?(u.disabled=!0,u.style.opacity="0.5"):u.addEventListener("click",f=>{var p;f.preventDefault();const m=parseFloat(e.value),b=Number.isFinite(m)?m:(p=a!=null?a:t.default)!=null?p:0;let g=parseFloat((b+d*o).toPrecision(12));a!=null&&(g=Math.max(a,g)),i!=null&&(g=Math.min(i,g)),e.value=String(g),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}),u};return e.classList.add("fb-stepper-input"),e.style.cssText=`
213
+ width: 56px;
214
+ border: none;
215
+ border-left: var(--fb-border-width) solid var(--fb-border-color);
216
+ border-right: var(--fb-border-width) solid var(--fb-border-color);
217
+ padding: var(--fb-input-padding-y) 0;
218
+ font-size: var(--fb-font-size);
219
+ font-family: var(--fb-font-family);
220
+ text-align: center;
221
+ background: transparent;
222
+ color: var(--fb-text-color);
223
+ -moz-appearance: textfield;
224
+ box-sizing: border-box;
225
+ `,l.appendChild(s("\u2212",-1)),l.appendChild(e),l.appendChild(s("+",1)),l}function tn(e,t){const n=document.createElement("span");n.className="number-range-hint",n.style.cssText=`
63
226
  position: absolute;
64
227
  top: 50%;
65
228
  transform: translateY(-50%);
@@ -69,75 +232,167 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
69
232
  pointer-events: none;
70
233
  background: var(--fb-background-color);
71
234
  padding: 0 4px;
72
- `;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 a=()=>{const l=t.value?parseFloat(t.value):null;if(l!=null){const u=r!=null&&l<r,s=o!=null&&l>o;n.style.color=u||s?"var(--fb-error-color)":"var(--fb-text-secondary-color)"}else n.style.color="var(--fb-text-secondary-color)"};return t.addEventListener("input",a),a(),n}function gr(e,t,n,r){const o=t.state,i=oe(e,o,t),a=document.createElement("div");a.style.cssText="position: relative;";const l=document.createElement("input");if(l.type="number",l.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",l.style.cssText=`
73
- padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
74
- font-size: var(--fb-font-size);
75
- font-family: var(--fb-font-family);
76
- width: 100%;
77
- box-sizing: border-box;
78
- `,l.name=r,l.placeholder=e.placeholder||"0",e.min!==void 0&&(l.min=e.min.toString()),e.max!==void 0&&(l.max=e.max.toString()),e.step!==void 0&&(l.step=e.step.toString()),l.value=t.prefill[e.key]||e.default||"",l.readOnly=i,!i&&t.instance){const u=()=>{const s=l.value?parseFloat(l.value):null;t.instance.triggerOnChange(r,s)};l.addEventListener("blur",u),l.addEventListener("input",u)}if(a.appendChild(l),!i&&(e.min!=null||e.max!=null)){const u=Vt(e,l);a.appendChild(u)}n.appendChild(a)}function yr(e,t,n,r){var o,i;const a=t.state,l=oe(e,a,t),u=t.prefill[e.key]||[],s=Array.isArray(u)?[...u]:[],d=(o=e.minCount)!=null?o:1,c=(i=e.maxCount)!=null?i:1/0;for(;s.length<d;)s.push(e.default||"");const p=document.createElement("div");p.className="space-y-2",n.appendChild(p);function f(){p.querySelectorAll(".multiple-number-item").forEach((v,x)=>{const E=v.querySelector("input");E&&(E.name=`${r}[${x}]`)})}function m(v="",x=-1){const E=document.createElement("div");E.className="multiple-number-item flex items-center gap-2";const k=document.createElement("div");k.style.cssText="position: relative; flex: 1;";const b=document.createElement("input");if(b.type="number",b.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",b.style.cssText=`
235
+ `;const r=e.min,o=e.max;let a="";r!=null&&o!=null?a=`${r} \u2013 ${o}`:o!=null?a=`\u2264${o}`:r!=null&&(a=`\u2265${r}`),n.textContent=a;const i=()=>{const l=t.value?parseFloat(t.value):null;if(l!=null){const s=r!=null&&l<r,c=o!=null&&l>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",i),i(),n}function Ir(e,t,n,r){const o=t.state,a=oe(e,o,t),i=document.createElement("div");i.style.cssText="position: relative;";const l=document.createElement("input");if(l.type="number",l.name=r,l.placeholder=e.placeholder||"0",e.min!==void 0&&(l.min=e.min.toString()),e.max!==void 0&&(l.max=e.max.toString()),e.step!==void 0&&(l.step=e.step.toString()),l.value=t.prefill[e.key]||e.default||"",l.readOnly=a,e.stepper||(l.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",l.style.cssText=`
79
236
  padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
80
237
  font-size: var(--fb-font-size);
81
238
  font-family: var(--fb-font-family);
82
239
  width: 100%;
83
240
  box-sizing: border-box;
84
- `,b.placeholder=e.placeholder||"0",e.min!==void 0&&(b.min=e.min.toString()),e.max!==void 0&&(b.max=e.max.toString()),e.step!==void 0&&(b.step=e.step.toString()),b.value=v.toString(),b.readOnly=l,!l&&t.instance){const w=()=>{const F=b.value?parseFloat(b.value):null;t.instance.triggerOnChange(b.name,F)};b.addEventListener("blur",w),b.addEventListener("input",w)}if(k.appendChild(b),!l&&(e.min!=null||e.max!=null)){const w=Vt(e,b);k.appendChild(w)}return E.appendChild(k),x===-1?p.appendChild(E):p.insertBefore(E,p.children[x]),f(),E}function g(){if(l)return;const v=p.querySelectorAll(".multiple-number-item"),x=v.length;v.forEach(E=>{let k=E.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 w=Array.from(p.children).indexOf(E);p.children.length>d&&(s.splice(w,1),E.remove(),f(),h(),g())},E.appendChild(k));const b=x<=d;k.disabled=b,k.style.opacity=b?"0.5":"1",k.style.pointerEvents=b?"none":"auto"})}let y=null,C=null;if(!l){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const v=document.createElement("button");v.type="button",v.className="add-number-btn px-3 py-1 rounded",v.style.cssText=`
85
- color: var(--fb-primary-color);
86
- border: var(--fb-border-width) solid var(--fb-primary-color);
87
- background-color: transparent;
241
+ `),!a&&t.instance){const s=()=>{const c=l.value?parseFloat(l.value):null;t.instance.triggerOnChange(r,c)};l.addEventListener("blur",s),l.addEventListener("input",s)}if(e.stepper)i.appendChild(qr(l,e,a));else if(i.appendChild(l),!a&&(e.min!=null||e.max!=null)){const s=tn(e,l);i.appendChild(s)}n.appendChild(i)}function Rr(e,t,n,r){var o,a;const i=t.state,l=oe(e,i,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],d=(o=e.minCount)!=null?o:1,u=(a=e.maxCount)!=null?a:1/0;for(;c.length<d;)c.push(e.default||"");const f=document.createElement("div");f.className="space-y-2",n.appendChild(f);function p(){f.querySelectorAll(".multiple-number-item").forEach((h,y)=>{const v=h.querySelector("input");v&&(v.name=`${r}[${y}]`)})}function m(h="",y=-1){const v=document.createElement("div");v.className="multiple-number-item flex items-center gap-2";const C=document.createElement("div");C.style.cssText="position: relative; flex: 1;";const E=document.createElement("input");if(E.type="number",E.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",E.style.cssText=`
242
+ padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
88
243
  font-size: var(--fb-font-size);
89
- transition: all var(--fb-transition-duration);
90
- `,v.textContent="+",v.addEventListener("mouseenter",()=>{v.style.backgroundColor="var(--fb-background-hover-color)"}),v.addEventListener("mouseleave",()=>{v.style.backgroundColor="transparent"}),v.onclick=()=>{s.push(e.default||""),m(e.default||""),h(),g()},C=document.createElement("span"),C.className="text-sm text-gray-500",y.appendChild(v),y.appendChild(C),n.appendChild(y)}function h(){if(!y||!C)return;const v=y.querySelector(".add-number-btn");if(v){const x=s.length>=c;v.disabled=x,v.style.opacity=x?"0.5":"1",v.style.pointerEvents=x?"none":"auto"}C.textContent=`${s.length}/${c===1/0?"\u221E":c}`}s.forEach(v=>m(v)),h(),g()}function xr(e,t,n){var r,o,i,a,l;const u=[],{scopeRoot:s,skipValidation:d}=n,c=(f,m)=>{var g,y;if(!f)return;const C=`error-${f.getAttribute("name")||Math.random().toString(36).substring(7)}`;let h=document.getElementById(C);m?(f.classList.add("invalid"),f.title=m,h||(h=document.createElement("div"),h.id=C,h.className="error-message",h.style.cssText=`
244
+ font-family: var(--fb-font-family);
245
+ width: 100%;
246
+ box-sizing: border-box;
247
+ `,E.placeholder=e.placeholder||"0",e.min!==void 0&&(E.min=e.min.toString()),e.max!==void 0&&(E.max=e.max.toString()),e.step!==void 0&&(E.step=e.step.toString()),E.value=h.toString(),E.readOnly=l,!l&&t.instance){const x=()=>{const L=E.value?parseFloat(E.value):null;t.instance.triggerOnChange(E.name,L)};E.addEventListener("blur",x),E.addEventListener("input",x)}if(C.appendChild(E),!l&&(e.min!=null||e.max!=null)){const x=tn(e,E);C.appendChild(x)}return v.appendChild(C),y===-1?f.appendChild(v):f.insertBefore(v,f.children[y]),p(),v}function b(){if(l)return;const h=f.querySelectorAll(".multiple-number-item"),y=h.length;h.forEach(v=>{let C=v.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 x=Array.from(f.children).indexOf(v);f.children.length>d&&(c.splice(x,1),v.remove(),p(),w(),b())},v.appendChild(C));const E=y<=d;C.disabled=E,C.style.opacity=E?"0.5":"1",C.style.pointerEvents=E?"none":"auto"})}let g=null;if(!l){const h=Ae("number",()=>{c.push(e.default||""),m(e.default||""),w(),b()},{label:e.addLabel});g=h.update,Se(n,h.counter),n.appendChild(h.row)}function w(){g&&g(c.length,u)}c.forEach(h=>m(h)),w(),b()}function Hr(e,t,n){var r,o,a,i,l;const s=[],{scopeRoot:c,skipValidation:d}=n,u=(p,m)=>{var b,g;if(!p)return;const w=`error-${p.getAttribute("name")||Math.random().toString(36).substring(7)}`;let h=document.getElementById(w);m?(p.classList.add("invalid"),p.title=m,h||(h=document.createElement("div"),h.id=w,h.className="error-message",h.style.cssText=`
91
248
  color: var(--fb-error-color);
92
249
  font-size: var(--fb-font-size-small);
93
250
  margin-top: 0.25rem;
94
- `,f.nextSibling?(g=f.parentNode)==null||g.insertBefore(h,f.nextSibling):(y=f.parentNode)==null||y.appendChild(h)),h.textContent=m,h.style.display="block"):(f.classList.remove("invalid"),f.title="",h&&h.remove())},p=(f,m,g)=>{let y=!1;const{state:C}=n;if(!d&&e.min!==void 0&&e.min!==null&&m<e.min){const h=$("minValue",C,{min:e.min});u.push(`${g}: ${h}`),c(f,h),y=!0}else if(!d&&e.max!==void 0&&e.max!==null&&m>e.max){const h=$("maxValue",C,{max:e.max});u.push(`${g}: ${h}`),c(f,h),y=!0}y||c(f,null)};if(e.multiple){const f=s.querySelectorAll(`[name^="${t}["]`),m=[];if(f.forEach((g,y)=>{var C,h,v;const x=(C=g==null?void 0:g.value)!=null?C:"";if(x===""){m.push(null),c(g,null);return}const E=parseFloat(x);if(!d&&!Number.isFinite(E)){const b=$("notANumber",n.state);u.push(`${t}[${y}]: ${b}`),c(g,b),m.push(null);return}p(g,E,`${t}[${y}]`);const k=Number.isInteger((h=e.decimals)!=null?h:0)&&(v=e.decimals)!=null?v:0;m.push(Number(E.toFixed(k)))}),!d){const{state:g}=n,y=(r=e.minCount)!=null?r:1,C=(o=e.maxCount)!=null?o:1/0,h=m.filter(v=>v!==null);e.required&&h.length===0&&u.push(`${t}: ${$("required",g)}`),h.length<y&&u.push(`${t}: ${$("minItems",g,{min:y})}`),h.length>C&&u.push(`${t}: ${$("maxItems",g,{max:C})}`)}return{value:m,errors:u}}else{const f=s.querySelector(`[name$="${t}"]`),m=(i=f==null?void 0:f.value)!=null?i:"",{state:g}=n;if(!d&&e.required&&m===""){const h=$("required",g);return u.push(`${t}: ${h}`),c(f,h),{value:null,errors:u}}if(m==="")return c(f,null),{value:null,errors:u};const y=parseFloat(m);if(!d&&!Number.isFinite(y)){const h=$("notANumber",g);return u.push(`${t}: ${h}`),c(f,h),{value:null,errors:u}}p(f,y,t);const C=Number.isInteger((a=e.decimals)!=null?a:0)&&(l=e.decimals)!=null?l:0;return{value:Number(y.toFixed(C)),errors:u}}}function Er(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((a,l)=>{l<n.length&&(a.value=n[l]!=null?String(n[l]):"",a.classList.remove("invalid"),a.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 Cr(e,t,n,r){const o=t.state,i=oe(e,o,t),a=document.createElement("select");if(a.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",a.style.cssText=`
251
+ `,p.nextSibling?(b=p.parentNode)==null||b.insertBefore(h,p.nextSibling):(g=p.parentNode)==null||g.appendChild(h)),h.textContent=m,h.style.display="block"):(p.classList.remove("invalid"),p.title="",h&&h.remove())},f=(p,m,b)=>{let g=!1;const{state:w}=n;if(!d&&e.min!==void 0&&e.min!==null&&m<e.min){const h=k("minValue",w,{min:e.min});s.push(`${b}: ${h}`),u(p,h),g=!0}else if(!d&&e.max!==void 0&&e.max!==null&&m>e.max){const h=k("maxValue",w,{max:e.max});s.push(`${b}: ${h}`),u(p,h),g=!0}g||u(p,null)};if(e.multiple){const p=c.querySelectorAll(`[name^="${t}["]`),m=[];if(p.forEach((b,g)=>{var w,h,y;const v=(w=b==null?void 0:b.value)!=null?w:"";if(v===""){m.push(null),u(b,null);return}const C=parseFloat(v);if(!d&&!Number.isFinite(C)){const x=k("notANumber",n.state);s.push(`${t}[${g}]: ${x}`),u(b,x),m.push(null);return}f(b,C,`${t}[${g}]`);const E=Number.isInteger((h=e.decimals)!=null?h:0)&&(y=e.decimals)!=null?y:0;m.push(Number(C.toFixed(E)))}),!d){const{state:b}=n,g=(r=e.minCount)!=null?r:1,w=(o=e.maxCount)!=null?o:1/0,h=m.filter(y=>y!==null);e.required&&h.length===0&&s.push(`${t}: ${k("required",b)}`),h.length<g&&s.push(`${t}: ${k("minItems",b,{min:g})}`),h.length>w&&s.push(`${t}: ${k("maxItems",b,{max:w})}`)}return{value:m,errors:s}}else{const p=c.querySelector(`[name$="${t}"]`),m=(a=p==null?void 0:p.value)!=null?a:"",{state:b}=n;if(!d&&e.required&&m===""){const h=k("required",b);return s.push(`${t}: ${h}`),u(p,h),{value:null,errors:s}}if(m==="")return u(p,null),{value:null,errors:s};const g=parseFloat(m);if(!d&&!Number.isFinite(g)){const h=k("notANumber",b);return s.push(`${t}: ${h}`),u(p,h),{value:null,errors:s}}f(p,g,t);const w=Number.isInteger((i=e.decimals)!=null?i:0)&&(l=e.decimals)!=null?l:0;return{value:Number(g.toFixed(w)),errors:s}}}function Br(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 a=o.querySelectorAll(`[name^="${t}\\["]`);a.forEach((i,l)=>{l<n.length&&(i.value=n[l]!=null?String(n[l]):"",i.classList.remove("invalid"),i.title="",ye(i))}),n.length!==a.length&&console.warn(`updateNumberField: Multiple field "${t}" has ${a.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=o.querySelector(`[name="${t}"]`);a&&(a.value=n!=null?String(n):"",a.classList.remove("invalid"),a.title="",ye(a))}}function Dr(e,t,n,r){const o=t.state,a=oe(e,o,t),i=document.createElement("select");if(i.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",i.style.cssText=`
95
252
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
96
253
  font-size: var(--fb-font-size);
97
254
  font-family: var(--fb-font-family);
98
- `,a.name=r,a.disabled=i,(e.options||[]).forEach(l=>{const u=document.createElement("option");u.value=l.value,u.textContent=l.label,(t.prefill[e.key]||e.default)===l.value&&(u.selected=!0),a.appendChild(u)}),!i&&t.instance){const l=()=>{t.instance.triggerOnChange(r,a.value)};a.addEventListener("change",l)}if(n.appendChild(a),!i){const l=document.createElement("p");l.className="text-xs text-gray-500 mt-1",l.textContent=Ee(e,o),n.appendChild(l)}}function wr(e,t,n,r){var o,i,a,l;const u=t.state,s=oe(e,u,t),d=t.prefill[e.key]||[],c=Array.isArray(d)?[...d]:[],p=(o=e.minCount)!=null?o:1,f=(i=e.maxCount)!=null?i:1/0;for(;c.length<p;)c.push(e.default||((l=(a=e.options)==null?void 0:a[0])==null?void 0:l.value)||"");const m=document.createElement("div");m.className="space-y-2",n.appendChild(m);function g(){m.querySelectorAll(".multiple-select-item").forEach((E,k)=>{const b=E.querySelector("select");b&&(b.name=`${r}[${k}]`)})}function y(E="",k=-1){const b=document.createElement("div");b.className="multiple-select-item flex items-center gap-2";const w=document.createElement("select");if(w.className="flex-1 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",w.style.cssText=`
255
+ `,i.name=r,i.disabled=a,(e.options||[]).forEach(l=>{const s=document.createElement("option");s.value=l.value,s.textContent=l.label,(t.prefill[e.key]||e.default)===l.value&&(s.selected=!0),i.appendChild(s)}),!a&&t.instance){const l=()=>{t.instance.triggerOnChange(r,i.value)};i.addEventListener("change",l)}if(n.appendChild(i),!a){const l=document.createElement("p");l.className="text-xs text-gray-500 mt-1",l.textContent=Le(e,o),n.appendChild(l)}}function jr(e,t,n,r){var o,a,i,l;const s=t.state,c=oe(e,s,t),d=t.prefill[e.key]||[],u=Array.isArray(d)?[...d]:[],f=(o=e.minCount)!=null?o:1,p=(a=e.maxCount)!=null?a:1/0;for(;u.length<f;)u.push(e.default||((l=(i=e.options)==null?void 0:i[0])==null?void 0:l.value)||"");const m=document.createElement("div");m.className="space-y-2",n.appendChild(m);function b(){m.querySelectorAll(".multiple-select-item").forEach((v,C)=>{const E=v.querySelector("select");E&&(E.name=`${r}[${C}]`)})}function g(v="",C=-1){const E=document.createElement("div");E.className="multiple-select-item flex items-center gap-2";const x=document.createElement("select");if(x.className="flex-1 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",x.style.cssText=`
99
256
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
100
257
  font-size: var(--fb-font-size);
101
258
  font-family: var(--fb-font-family);
102
- `,w.disabled=s,(e.options||[]).forEach(F=>{const V=document.createElement("option");V.value=F.value,V.textContent=F.label,E===F.value&&(V.selected=!0),w.appendChild(V)}),!s&&t.instance){const F=()=>{t.instance.triggerOnChange(w.name,w.value)};w.addEventListener("change",F)}return b.appendChild(w),k===-1?m.appendChild(b):m.insertBefore(b,m.children[k]),g(),b}function C(){if(s)return;const E=m.querySelectorAll(".multiple-select-item"),k=E.length;E.forEach(b=>{let w=b.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 V=Array.from(m.children).indexOf(b);m.children.length>p&&(c.splice(V,1),b.remove(),g(),x(),C())},b.appendChild(w));const F=k<=p;w.disabled=F,w.style.opacity=F?"0.5":"1",w.style.pointerEvents=F?"none":"auto"})}let h=null,v=null;if(!s){h=document.createElement("div"),h.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=`
103
- color: var(--fb-primary-color);
104
- border: var(--fb-border-width) solid var(--fb-primary-color);
105
- background-color: transparent;
106
- font-size: var(--fb-font-size);
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 k,b;const w=e.default||((b=(k=e.options)==null?void 0:k[0])==null?void 0:b.value)||"";c.push(w),y(w),x(),C()},v=document.createElement("span"),v.className="text-sm text-gray-500",h.appendChild(E),h.appendChild(v),n.appendChild(h)}function x(){if(!h||!v)return;const E=h.querySelector(".add-select-btn");if(E){const k=c.length>=f;E.disabled=k,E.style.opacity=k?"0.5":"1",E.style.pointerEvents=k?"none":"auto"}v.textContent=`${c.length}/${f===1/0?"\u221E":f}`}if(c.forEach(E=>y(E)),x(),C(),!s){const E=document.createElement("p");E.className="text-xs text-gray-500 mt-1",E.textContent=Ee(e,u),n.appendChild(E)}}function kr(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:a}=n,l=(s,d)=>{var c,p;if(!s)return;const f=`error-${s.getAttribute("name")||Math.random().toString(36).substring(7)}`;let m=document.getElementById(f);d?(s.classList.add("invalid"),s.title=d,m||(m=document.createElement("div"),m.id=f,m.className="error-message",m.style.cssText=`
259
+ `,x.disabled=c,(e.options||[]).forEach(L=>{const q=document.createElement("option");q.value=L.value,q.textContent=L.label,v===L.value&&(q.selected=!0),x.appendChild(q)}),!c&&t.instance){const L=()=>{t.instance.triggerOnChange(x.name,x.value)};x.addEventListener("change",L)}return E.appendChild(x),C===-1?m.appendChild(E):m.insertBefore(E,m.children[C]),b(),E}function w(){if(c)return;const v=m.querySelectorAll(".multiple-select-item"),C=v.length;v.forEach(E=>{let x=E.querySelector(".remove-item-btn");x||(x=document.createElement("button"),x.type="button",x.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",x.innerHTML="\u2715",x.onclick=()=>{const q=Array.from(m.children).indexOf(E);m.children.length>f&&(u.splice(q,1),E.remove(),b(),y(),w())},E.appendChild(x));const L=C<=f;x.disabled=L,x.style.opacity=L?"0.5":"1",x.style.pointerEvents=L?"none":"auto"})}let h=null;if(!c){const v=Ae("select",()=>{var C,E;const x=e.default||((E=(C=e.options)==null?void 0:C[0])==null?void 0:E.value)||"";u.push(x),g(x),y(),w()},{label:e.addLabel});h=v.update,Se(n,v.counter),n.appendChild(v.row)}function y(){h&&h(u.length,p)}if(u.forEach(v=>g(v)),y(),w(),!c){const v=document.createElement("p");v.className="text-xs text-gray-500 mt-1",v.textContent=Le(e,s),n.appendChild(v)}}function Or(e,t,n){var r;const o=[],{scopeRoot:a,skipValidation:i}=n,l=(c,d)=>{var u,f;if(!c)return;const p=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let m=document.getElementById(p);d?(c.classList.add("invalid"),c.title=d,m||(m=document.createElement("div"),m.id=p,m.className="error-message",m.style.cssText=`
109
260
  color: var(--fb-error-color);
110
261
  font-size: var(--fb-font-size-small);
111
262
  margin-top: 0.25rem;
112
- `,s.nextSibling?(c=s.parentNode)==null||c.insertBefore(m,s.nextSibling):(p=s.parentNode)==null||p.appendChild(m)),m.textContent=d,m.style.display="block"):(s.classList.remove("invalid"),s.title="",m&&m.remove())},u=(s,d,c,p)=>{var f,m;if(a)return;const{state:g}=n,y=d.filter(p),C="minCount"in c&&(f=c.minCount)!=null?f:1,h="maxCount"in c&&(m=c.maxCount)!=null?m:1/0;c.required&&y.length===0&&o.push(`${s}: ${$("required",g)}`),y.length<C&&o.push(`${s}: ${$("minItems",g,{min:C})}`),y.length>h&&o.push(`${s}: ${$("maxItems",g,{max:h})}`)};if("multiple"in e&&e.multiple){const s=i.querySelectorAll(`[name^="${t}["]`),d=[];return s.forEach(c=>{var p;const f=(p=c==null?void 0:c.value)!=null?p:"";d.push(f),l(c,null)}),u(t,d,e,c=>c!==""),{value:d,errors:o}}else{const s=i.querySelector(`[name$="${t}"]`),d=(r=s==null?void 0:s.value)!=null?r:"";if(!a&&e.required&&d===""){const c=$("required",n.state);return o.push(`${t}: ${c}`),l(s,c),{value:null,errors:o}}else l(s,null);return{value:d===""?null:d,errors:o}}}function $r(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((a,l)=>{l<n.length&&(a.value=n[l]!=null?String(n[l]):"",a.querySelectorAll("option").forEach(u=>{u.selected=u.value===String(n[l])}),a.classList.remove("invalid"),a.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(a=>{a.selected=a.value===String(n)}),i.classList.remove("invalid"),i.title="")}}function Ge(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 _t(e,t,n,r,o){const i=e.options||[],a=document.createElement("div");a.className="fb-switcher-group",a.style.cssText=`
263
+ `,c.nextSibling?(u=c.parentNode)==null||u.insertBefore(m,c.nextSibling):(f=c.parentNode)==null||f.appendChild(m)),m.textContent=d,m.style.display="block"):(c.classList.remove("invalid"),c.title="",m&&m.remove())},s=(c,d,u,f)=>{var p,m;if(i)return;const{state:b}=n,g=d.filter(f),w="minCount"in u&&(p=u.minCount)!=null?p:1,h="maxCount"in u&&(m=u.maxCount)!=null?m:1/0;u.required&&g.length===0&&o.push(`${c}: ${k("required",b)}`),g.length<w&&o.push(`${c}: ${k("minItems",b,{min:w})}`),g.length>h&&o.push(`${c}: ${k("maxItems",b,{max:h})}`)};if("multiple"in e&&e.multiple){const c=a.querySelectorAll(`[name^="${t}\\["]`),d=[];return c.forEach(u=>{var f;const p=(f=u==null?void 0:u.value)!=null?f:"";d.push(p),l(u,null)}),s(t,d,e,u=>u!==""),{value:d,errors:o}}else{const c=a.querySelector(`[name$="${t}"]`),d=(r=c==null?void 0:c.value)!=null?r:"";if(!i&&e.required&&d===""){const u=k("required",n.state);return o.push(`${t}: ${u}`),l(c,u),{value:null,errors:o}}else l(c,null);return{value:d===""?null:d,errors:o}}}function Ur(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 a=o.querySelectorAll(`[name^="${t}\\["]`);a.forEach((i,l)=>{l<n.length&&(i.value=n[l]!=null?String(n[l]):"",i.querySelectorAll("option").forEach(s=>{s.selected=s.value===String(n[l])}),i.classList.remove("invalid"),i.title="",ye(i))}),n.length!==a.length&&console.warn(`updateSelectField: Multiple field "${t}" has ${a.length} selects but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=o.querySelector(`[name="${t}"]`);a&&(a.value=n!=null?String(n):"",a.querySelectorAll("option").forEach(i=>{i.selected=i.value===String(n)}),a.classList.remove("invalid"),a.title="",ye(a))}}function nt(e,t){t?(e.style.backgroundColor="var(--fb-primary-soft-color)",e.style.color="var(--fb-primary-color)",e.style.borderColor="var(--fb-primary-color)"):(e.style.backgroundColor="var(--fb-primary-color)",e.style.color="#ffffff",e.style.borderColor="var(--fb-primary-color)")}function rt(e,t){e.style.backgroundColor=t?"var(--fb-background-color)":"transparent",e.style.color="var(--fb-text-color)",e.style.borderColor="var(--fb-border-color)"}function nn(e){return e.classList.contains("fb-switcher-preset")}function Pr(e,t){const n=document.createElement("button");if(n.type="button",n.className="fb-switcher-btn fb-switcher-preset",n.dataset.value=e.value,n.style.cssText=`
113
264
  display: inline-flex;
114
- flex-direction: row;
115
- flex-wrap: nowrap;
116
- `;const l=[];return i.forEach((u,s)=>{const d=document.createElement("button");d.type="button",d.className="fb-switcher-btn",d.dataset.value=u.value,d.textContent=u.label,d.style.cssText=`
117
- padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
118
- font-size: var(--fb-font-size);
119
- border-width: var(--fb-border-width);
120
- border-style: solid;
121
- cursor: ${r?"default":"pointer"};
122
- transition: background-color var(--fb-transition-duration), color var(--fb-transition-duration), border-color var(--fb-transition-duration);
123
- white-space: nowrap;
124
- line-height: 1.25;
125
- outline: none;
126
- `,i.length===1?d.style.borderRadius="var(--fb-border-radius)":s===0?(d.style.borderRadius="var(--fb-border-radius) 0 0 var(--fb-border-radius)",d.style.borderRightWidth="0"):s===i.length-1?d.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(d.style.borderRadius="0",d.style.borderRightWidth="0"),u.value===t?Ge(d):Xe(d),r||(d.addEventListener("click",()=>{n.value=u.value,l.forEach(c=>{c.dataset.value===u.value?Ge(c):Xe(c)}),o&&o(u.value)}),d.addEventListener("mouseenter",()=>{n.value!==u.value&&(d.style.backgroundColor="var(--fb-background-hover-color)")}),d.addEventListener("mouseleave",()=>{n.value!==u.value&&(d.style.backgroundColor="transparent")})),l.push(d),a.appendChild(d)}),a}function Lr(e,t,n,r){var o,i;const a=t.state,l=String((i=(o=t.prefill[e.key])!=null?o:e.default)!=null?i:""),u=document.createElement("input");u.type="hidden",u.name=r,u.value=l;const s=oe(e,a,t),d=!s&&t.instance?p=>{t.instance.triggerOnChange(r,p)}:null,c=_t(e,l,u,s,d);if(n.appendChild(u),n.appendChild(c),!s){const p=document.createElement("p");p.className="text-xs text-gray-500 mt-1",p.textContent=Ee(e,a),n.appendChild(p)}}function Sr(e,t,n,r){var o,i,a,l;const u=t.state,s=t.prefill[e.key]||[],d=Array.isArray(s)?[...s]:[],c=(o=e.minCount)!=null?o:1,p=(i=e.maxCount)!=null?i:1/0;for(;d.length<c;)d.push(e.default||((l=(a=e.options)==null?void 0:a[0])==null?void 0:l.value)||"");const f=oe(e,u,t),m=document.createElement("div");m.className="space-y-2",n.appendChild(m);function g(){m.querySelectorAll(".multiple-switcher-item").forEach((E,k)=>{const b=E.querySelector("input[type=hidden]");b&&(b.name=`${r}[${k}]`)})}function y(E="",k=-1){const b=k===-1?m.children.length:k,w=`${r}[${b}]`,F=document.createElement("div");F.className="multiple-switcher-item flex items-center gap-2";const V=document.createElement("input");V.type="hidden",V.name=w,V.value=E,F.appendChild(V);const R=!f&&t.instance?j=>{t.instance.triggerOnChange(V.name,j)}:null,D=_t(e,E,V,f,R);return F.appendChild(D),k===-1?m.appendChild(F):m.insertBefore(F,m.children[k]),g(),F}function C(){if(f)return;const E=m.querySelectorAll(".multiple-switcher-item"),k=E.length;E.forEach(b=>{let w=b.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=`
265
+ align-items: center;
266
+ gap: 8px;
267
+ padding: 7px 12px 7px 10px;
268
+ border-width: var(--fb-border-width);
269
+ border-style: solid;
270
+ border-radius: 999px;
271
+ background: var(--fb-background-color);
272
+ font-size: var(--fb-font-size);
273
+ font-family: var(--fb-font-family);
274
+ line-height: 1.25;
275
+ cursor: ${t?"default":"pointer"};
276
+ transition: background-color var(--fb-transition-duration), color var(--fb-transition-duration), border-color var(--fb-transition-duration);
277
+ outline: none;
278
+ `,e.iconUrl){const o=document.createElement("img");o.className="fb-switcher-icon",o.src=e.iconUrl,o.alt="",o.setAttribute("aria-hidden","true"),o.style.cssText=`
279
+ display: block;
280
+ flex: 0 0 auto;
281
+ width: 20px;
282
+ height: 20px;
283
+ object-fit: contain;
284
+ `,n.appendChild(o)}const r=document.createElement("span");if(r.className="fb-switcher-name",r.textContent=e.label,r.style.cssText="font-weight: 600;",n.appendChild(r),e.subtitle){const o=document.createElement("span");o.className="fb-switcher-subtitle",o.textContent=e.subtitle,o.style.cssText=`
285
+ font-size: var(--fb-font-size-small);
286
+ opacity: 0.7;
287
+ font-variant-numeric: tabular-nums;
288
+ `,n.appendChild(o)}return n}function rn(e,t,n,r,o){const a=e.options||[],i=a.some(c=>c.subtitle||c.iconUrl),l=document.createElement("div");l.className="fb-switcher-group",l.style.cssText=i?`
289
+ display: flex;
290
+ flex-direction: row;
291
+ flex-wrap: wrap;
292
+ gap: 6px;
293
+ `:`
294
+ display: inline-flex;
295
+ flex-direction: row;
296
+ flex-wrap: nowrap;
297
+ `;const s=[];return a.forEach((c,d)=>{let u;i?u=Pr(c,r):(u=document.createElement("button"),u.type="button",u.className="fb-switcher-btn",u.dataset.value=c.value,u.textContent=c.label,u.style.cssText=`
298
+ padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
299
+ font-size: var(--fb-font-size);
300
+ border-width: var(--fb-border-width);
301
+ border-style: solid;
302
+ cursor: ${r?"default":"pointer"};
303
+ transition: background-color var(--fb-transition-duration), color var(--fb-transition-duration), border-color var(--fb-transition-duration);
304
+ white-space: nowrap;
305
+ line-height: 1.25;
306
+ outline: none;
307
+ `,a.length===1?u.style.borderRadius="var(--fb-border-radius)":d===0?(u.style.borderRadius="var(--fb-border-radius) 0 0 var(--fb-border-radius)",u.style.borderRightWidth="0"):d===a.length-1?u.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(u.style.borderRadius="0",u.style.borderRightWidth="0")),c.value===t?nt(u,i):rt(u,i),r||(u.addEventListener("click",()=>{n.value=c.value,s.forEach(f=>{f.dataset.value===c.value?nt(f,i):rt(f,i)}),o&&o(c.value)}),u.addEventListener("mouseenter",()=>{n.value!==c.value&&(u.style.backgroundColor="var(--fb-background-hover-color)")}),u.addEventListener("mouseleave",()=>{n.value!==c.value&&(u.style.backgroundColor=i?"var(--fb-background-color)":"transparent")})),s.push(u),l.appendChild(u)}),l}function Wr(e,t,n,r){var o,a;const i=t.state,l=String((a=(o=t.prefill[e.key])!=null?o:e.default)!=null?a:""),s=document.createElement("input");s.type="hidden",s.name=r,s.value=l;const c=oe(e,i,t),d=!c&&t.instance?f=>{t.instance.triggerOnChange(r,f)}:null,u=rn(e,l,s,c,d);if(n.appendChild(s),n.appendChild(u),!c){const f=document.createElement("p");f.className="text-xs text-gray-500 mt-1",f.textContent=Le(e,i),n.appendChild(f)}}function Vr(e,t,n,r){var o,a,i,l;const s=t.state,c=t.prefill[e.key]||[],d=Array.isArray(c)?[...c]:[],u=(o=e.minCount)!=null?o:1,f=(a=e.maxCount)!=null?a:1/0;for(;d.length<u;)d.push(e.default||((l=(i=e.options)==null?void 0:i[0])==null?void 0:l.value)||"");const p=oe(e,s,t),m=document.createElement("div");m.className="space-y-2",n.appendChild(m);function b(){m.querySelectorAll(".multiple-switcher-item").forEach((v,C)=>{const E=v.querySelector("input[type=hidden]");E&&(E.name=`${r}[${C}]`)})}function g(v="",C=-1){const E=C===-1?m.children.length:C,x=`${r}[${E}]`,L=document.createElement("div");L.className="multiple-switcher-item flex items-center gap-2";const q=document.createElement("input");q.type="hidden",q.name=x,q.value=v,L.appendChild(q);const I=!p&&t.instance?V=>{t.instance.triggerOnChange(q.name,V)}:null,W=rn(e,v,q,p,I);return L.appendChild(W),C===-1?m.appendChild(L):m.insertBefore(L,m.children[C]),b(),L}function w(){if(p)return;const v=m.querySelectorAll(".multiple-switcher-item"),C=v.length;v.forEach(E=>{let x=E.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=`
127
308
  color: var(--fb-error-color);
128
309
  background-color: transparent;
129
310
  transition: background-color var(--fb-transition-duration);
130
- `,w.innerHTML="\u2715",w.addEventListener("mouseenter",()=>{w.style.backgroundColor="var(--fb-background-hover-color)"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="transparent"}),w.onclick=()=>{const V=Array.from(m.children).indexOf(b);m.children.length>c&&(d.splice(V,1),b.remove(),g(),x(),C())},b.appendChild(w));const F=k<=c;w.disabled=F,w.style.opacity=F?"0.5":"1",w.style.pointerEvents=F?"none":"auto"})}let h=null,v=null;if(!f){h=document.createElement("div"),h.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=`
131
- color: var(--fb-primary-color);
132
- border: var(--fb-border-width) solid var(--fb-primary-color);
133
- background-color: transparent;
134
- font-size: var(--fb-font-size);
135
- transition: all var(--fb-transition-duration);
136
- `,E.textContent="+",E.addEventListener("mouseenter",()=>{E.style.backgroundColor="var(--fb-background-hover-color)"}),E.addEventListener("mouseleave",()=>{E.style.backgroundColor="transparent"}),E.onclick=()=>{var k,b;const w=e.default||((b=(k=e.options)==null?void 0:k[0])==null?void 0:b.value)||"";d.push(w),y(w),x(),C()},v=document.createElement("span"),v.className="text-sm text-gray-500",h.appendChild(E),h.appendChild(v),n.appendChild(h)}function x(){if(!h||!v)return;const E=h.querySelector(".add-switcher-btn");if(E){const k=d.length>=p;E.disabled=k,E.style.opacity=k?"0.5":"1",E.style.pointerEvents=k?"none":"auto"}v.textContent=`${d.length}/${p===1/0?"\u221E":p}`}if(d.forEach(E=>y(E)),x(),C(),!f){const E=document.createElement("p");E.className="text-xs text-gray-500 mt-1",E.textContent=Ee(e,u),n.appendChild(E)}}function Tr(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:a}=n,l=(d,c)=>{var p,f;if(!d)return;const m=`error-${d.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(m);c?(d.classList.add("invalid"),d.title=c,g||(g=document.createElement("div"),g.id=m,g.className="error-message",g.style.cssText=`
311
+ `,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(m.children).indexOf(E);m.children.length>u&&(d.splice(q,1),E.remove(),b(),y(),w())},E.appendChild(x));const L=C<=u;x.disabled=L,x.style.opacity=L?"0.5":"1",x.style.pointerEvents=L?"none":"auto"})}let h=null;if(!p){const v=Ae("switcher",()=>{var C,E;const x=e.default||((E=(C=e.options)==null?void 0:C[0])==null?void 0:E.value)||"";d.push(x),g(x),y(),w()},{label:e.addLabel});h=v.update,Se(n,v.counter),n.appendChild(v.row)}function y(){h&&h(d.length,f)}if(d.forEach(v=>g(v)),y(),w(),!p){const v=document.createElement("p");v.className="text-xs text-gray-500 mt-1",v.textContent=Le(e,s),n.appendChild(v)}}function _r(e,t,n){var r;const o=[],{scopeRoot:a,skipValidation:i}=n,l=(d,u)=>{var f,p;if(!d)return;const m=`error-${d.getAttribute("name")||Math.random().toString(36).substring(7)}`;let b=document.getElementById(m);u?(d.classList.add("invalid"),d.title=u,b||(b=document.createElement("div"),b.id=m,b.className="error-message",b.style.cssText=`
137
312
  color: var(--fb-error-color);
138
313
  font-size: var(--fb-font-size-small);
139
314
  margin-top: 0.25rem;
140
- `,d.nextSibling?(p=d.parentNode)==null||p.insertBefore(g,d.nextSibling):(f=d.parentNode)==null||f.appendChild(g)),g.textContent=c,g.style.display="block"):(d.classList.remove("invalid"),d.title="",g&&g.remove())},u=(d,c,p,f)=>{var m,g;if(a)return;const{state:y}=n,C=c.filter(f),h="minCount"in p&&(m=p.minCount)!=null?m:1,v="maxCount"in p&&(g=p.maxCount)!=null?g:1/0;p.required&&C.length===0&&o.push(`${d}: ${$("required",y)}`),C.length<h&&o.push(`${d}: ${$("minItems",y,{min:h})}`),C.length>v&&o.push(`${d}: ${$("maxItems",y,{max:v})}`)},s=new Set("options"in e?e.options.map(d=>d.value):[]);if("multiple"in e&&e.multiple){const d=i.querySelectorAll(`input[type="hidden"][name^="${t}["]`),c=[];return d.forEach(p=>{var f;const m=(f=p==null?void 0:p.value)!=null?f:"";if(c.push(m),!a&&m!==""&&!s.has(m)){const g=$("invalidOption",n.state);l(p,g),o.push(`${t}: ${g}`)}else l(p,null)}),u(t,c,e,p=>p!==""),{value:c,errors:o}}else{const d=i.querySelector(`input[type="hidden"][name$="${t}"]`),c=(r=d==null?void 0:d.value)!=null?r:"";if(!a&&e.required&&c===""){const p=$("required",n.state);return o.push(`${t}: ${p}`),l(d,p),{value:null,errors:o}}if(!a&&c!==""&&!s.has(c)){const p=$("invalidOption",n.state);return o.push(`${t}: ${p}`),l(d,p),{value:null,errors:o}}return l(d,null),{value:c===""?null:c,errors:o}}}function Ar(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 a=i.querySelectorAll(`input[type="hidden"][name^="${t}["]`);a.forEach((l,u)=>{var s;if(u<n.length){const d=n[u]!=null?String(n[u]):"";l.value=d;const c=(s=l.parentElement)==null?void 0:s.querySelector(".fb-switcher-group");c&&c.querySelectorAll(".fb-switcher-btn").forEach(p=>{p.dataset.value===d?Ge(p):Xe(p)}),l.classList.remove("invalid"),l.title=""}}),n.length!==a.length&&console.warn(`updateSwitcherField: Multiple field "${t}" has ${a.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=i.querySelector(`input[type="hidden"][name="${t}"]`);if(a){const l=n!=null?String(n):"";a.value=l;const u=(o=a.parentElement)==null?void 0:o.querySelector(".fb-switcher-group");u&&u.querySelectorAll(".fb-switcher-btn").forEach(s=>{s.dataset.value===l?Ge(s):Xe(s)}),a.classList.remove("invalid"),a.title=""}}}function $e(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 qe(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 Kt(e,t){return t===1/0?!0:e<=t*1024*1024}function Ze(e,t){return Kt(e.size,t)}function Oe(e){return e?typeof e=="string"?[]:Array.isArray(e.mime)?e.mime.map(t=>t.toLowerCase()):[]:[]}function Ue(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 Fr(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:Fr(e),size:0,uploadedAt:new Date,file:void 0,inferredFromExtension:!0})}function vt(e,t){for(const n of e)Qe(n,t)}const Jt="fb-file-styles";function xe(){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=`
315
+ `,d.nextSibling?(f=d.parentNode)==null||f.insertBefore(b,d.nextSibling):(p=d.parentNode)==null||p.appendChild(b)),b.textContent=u,b.style.display="block"):(d.classList.remove("invalid"),d.title="",b&&b.remove())},s=(d,u,f,p)=>{var m,b;if(i)return;const{state:g}=n,w=u.filter(p),h="minCount"in f&&(m=f.minCount)!=null?m:1,y="maxCount"in f&&(b=f.maxCount)!=null?b:1/0;f.required&&w.length===0&&o.push(`${d}: ${k("required",g)}`),w.length<h&&o.push(`${d}: ${k("minItems",g,{min:h})}`),w.length>y&&o.push(`${d}: ${k("maxItems",g,{max:y})}`)},c=new Set("options"in e?e.options.map(d=>d.value):[]);if("multiple"in e&&e.multiple){const d=a.querySelectorAll(`input[type="hidden"][name^="${t}\\["]`),u=[];return d.forEach(f=>{var p;const m=(p=f==null?void 0:f.value)!=null?p:"";if(u.push(m),!i&&m!==""&&!c.has(m)){const b=k("invalidOption",n.state);l(f,b),o.push(`${t}: ${b}`)}else l(f,null)}),s(t,u,e,f=>f!==""),{value:u,errors:o}}else{const d=a.querySelector(`input[type="hidden"][name$="${t}"]`),u=(r=d==null?void 0:d.value)!=null?r:"";if(!i&&e.required&&u===""){const f=k("required",n.state);return o.push(`${t}: ${f}`),l(d,f),{value:null,errors:o}}if(!i&&u!==""&&!c.has(u)){const f=k("invalidOption",n.state);return o.push(`${t}: ${f}`),l(d,f),{value:null,errors:o}}return l(d,null),{value:u===""?null:u,errors:o}}}function Kr(e,t,n,r){var o;const{scopeRoot:a}=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 i=a.querySelectorAll(`input[type="hidden"][name^="${t}\\["]`);i.forEach((l,s)=>{var c;if(s<n.length){const d=n[s]!=null?String(n[s]):"";l.value=d;const u=(c=l.parentElement)==null?void 0:c.querySelector(".fb-switcher-group");u&&u.querySelectorAll(".fb-switcher-btn").forEach(f=>{const p=nn(f);f.dataset.value===d?nt(f,p):rt(f,p)}),l.classList.remove("invalid"),l.title="",ye(l)}}),n.length!==i.length&&console.warn(`updateSwitcherField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=a.querySelector(`input[type="hidden"][name="${t}"]`);if(i){const l=n!=null?String(n):"";i.value=l;const s=(o=i.parentElement)==null?void 0:o.querySelector(".fb-switcher-group");s&&s.querySelectorAll(".fb-switcher-btn").forEach(c=>{const d=nn(c);c.dataset.value===l?nt(c,d):rt(c,d)}),i.classList.remove("invalid"),i.title="",ye(i)}}}const on=36,Je=20,De=16;function Jr(e){const t="fb-boolean-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
316
+ .fb-toggle {
317
+ position: relative;
318
+ display: inline-block;
319
+ width: ${on}px;
320
+ height: ${Je}px;
321
+ border-radius: ${Je}px;
322
+ background: var(--fb-border-color);
323
+ transition: background-color var(--fb-transition-duration);
324
+ flex-shrink: 0;
325
+ }
326
+ .fb-toggle::after {
327
+ content: "";
328
+ position: absolute;
329
+ top: ${(Je-De)/2}px;
330
+ left: ${(Je-De)/2}px;
331
+ width: ${De}px;
332
+ height: ${De}px;
333
+ border-radius: 50%;
334
+ background: #ffffff;
335
+ box-shadow: 0 1px 3px rgba(0,0,0,0.2);
336
+ transition: transform var(--fb-transition-duration);
337
+ }
338
+ .fb-toggle.fb-on {
339
+ background: var(--fb-primary-color);
340
+ }
341
+ .fb-toggle.fb-on::after {
342
+ transform: translateX(${on-De-(Je-De)}px);
343
+ }
344
+ .fb-toggle-row {
345
+ display: flex;
346
+ align-items: center;
347
+ gap: 12px;
348
+ padding: 12px 14px;
349
+ background: var(--fb-surface-soft-color);
350
+ border: var(--fb-border-width) solid var(--fb-border-color);
351
+ border-radius: var(--fb-border-radius);
352
+ cursor: pointer;
353
+ user-select: none;
354
+ }
355
+ .fb-toggle-row[aria-disabled="true"] {
356
+ cursor: default;
357
+ opacity: 0.7;
358
+ }
359
+ .fb-toggle-row:focus-visible {
360
+ outline: var(--fb-focus-ring-width) solid var(--fb-focus-ring-color);
361
+ outline-offset: var(--fb-focus-ring-offset);
362
+ }
363
+ .fb-toggle-text { flex: 1; min-width: 0; }
364
+ .fb-toggle-title {
365
+ display: flex;
366
+ align-items: center;
367
+ gap: 4px;
368
+ font-size: var(--fb-font-size);
369
+ font-weight: 500;
370
+ color: var(--fb-text-color);
371
+ line-height: 1.3;
372
+ }
373
+ .fb-toggle-subtitle {
374
+ font-size: var(--fb-font-size-small);
375
+ color: var(--fb-text-secondary-color);
376
+ margin-top: 2px;
377
+ line-height: 1.35;
378
+ }
379
+ .fb-toggle-info {
380
+ flex: 0 0 14px;
381
+ display: inline-flex;
382
+ align-items: center;
383
+ justify-content: center;
384
+ width: 14px;
385
+ height: 14px;
386
+ border-radius: 50%;
387
+ background: var(--fb-border-color);
388
+ color: #fff;
389
+ font-size: 10px;
390
+ font-weight: 700;
391
+ font-style: italic;
392
+ font-family: serif;
393
+ cursor: help;
394
+ }
395
+ `,e.head.appendChild(n)}function Et(e){return typeof e=="boolean"?e:typeof e=="string"?e==="true"||e==="on"||e==="1":!1}function Yr(e,t,n,r){var o;Jr(document);const a=t.state,i=oe(e,a,t),l=t.prefill[e.key],s=Et(l!==void 0?l:e.default),c=document.createElement("input");c.type="hidden",c.name=r,c.value=s?"true":"false";const d=document.createElement("div");d.className="fb-toggle-row",d.setAttribute("role","switch"),d.setAttribute("aria-checked",s?"true":"false"),i?d.setAttribute("aria-disabled","true"):d.tabIndex=0;const u=document.createElement("span");u.className="fb-toggle"+(s?" fb-on":""),u.setAttribute("aria-hidden","true"),d.appendChild(u);const f=document.createElement("div");f.className="fb-toggle-text";const p=document.createElement("div");if(p.className="fb-toggle-title",p.appendChild(document.createTextNode((o=e.label)!=null?o:"")),e.description){const m=document.createElement("span");m.className="fb-toggle-info",m.textContent="i",m.title=e.description,p.appendChild(m)}if(f.appendChild(p),e.hint){const m=document.createElement("div");m.className="fb-toggle-subtitle",m.textContent=e.hint,f.appendChild(m)}if(d.appendChild(f),!i){const m=()=>{const b=c.value!=="true";c.value=b?"true":"false",u.classList.toggle("fb-on",b),d.setAttribute("aria-checked",b?"true":"false"),t.instance&&t.instance.triggerOnChange(r,b)};d.addEventListener("click",b=>{var g;(g=b.target)!=null&&g.classList.contains("fb-toggle-info")||m()}),d.addEventListener("keydown",b=>{(b.key===" "||b.key==="Enter")&&(b.preventDefault(),m())})}n.appendChild(c),n.appendChild(d)}function Xr(e,t,n){var r;const{scopeRoot:o}=n,a=o.querySelector(`input[type="hidden"][name="${t}"]`),i=(r=a==null?void 0:a.value)!=null?r:"";return{value:Et(i),errors:[]}}function Gr(e,t,n,r){var o;const{scopeRoot:a}=r,i=a.querySelector(`input[type="hidden"][name="${t}"]`);if(!i)return;const l=Et(n);i.value=l?"true":"false";const s=(o=i.parentElement)==null?void 0:o.querySelector(".fb-toggle-row");if(s){s.setAttribute("aria-checked",l?"true":"false");const c=s.querySelector(".fb-toggle");c&&c.classList.toggle("fb-on",l)}}function Fe(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 je(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 ln(e,t){return t===1/0?!0:e<=t*1024*1024}function ot(e,t){return ln(e.size,t)}function Ye(e){return e?typeof e=="string"?[]:Array.isArray(e.mime)?e.mime.map(t=>t.toLowerCase()):[]:[]}function Xe(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 Zr(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 lt(e,t){if(t.has(e))return;const n=e.split("/").pop()||"file";t.set(e,{name:n,type:Zr(e),size:0,uploadedAt:new Date,file:void 0,inferredFromExtension:!0})}function kt(e,t){for(const n of e)lt(n,t)}const an="fb-file-styles";function $e(){if(typeof document=="undefined"||document.getElementById(an))return;const e=document.createElement("style");if(e.id=an,e.setAttribute("data-fb-file-styles","true"),e.textContent=`
141
396
  @keyframes fb-spin { to { transform: rotate(360deg); } }
142
397
 
143
398
  /* \u2500\u2500\u2500 Checker background utility \u2500\u2500\u2500 */
@@ -158,14 +413,20 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
158
413
  }
159
414
 
160
415
  /* \u2500\u2500\u2500 Wide single-file add tile (empty state) \u2500\u2500\u2500 */
416
+ /* Flex-wraps: side-by-side when wide enough, stacks upload/library
417
+ vertically when narrow (e.g. inside a 50/50 container column). */
161
418
  .fb-wide-tile {
162
419
  width: 100%;
420
+ box-sizing: border-box;
163
421
  border-radius: 0.75rem;
164
422
  border: 1px dashed #60a5fa;
165
423
  background: rgba(239,246,255,0.5);
166
424
  display: flex;
425
+ flex-wrap: wrap;
426
+ align-items: stretch;
427
+ gap: 0;
167
428
  overflow: hidden;
168
- height: 180px;
429
+ min-height: 180px;
169
430
  transition: border-color 150ms, background 150ms, box-shadow 150ms;
170
431
  cursor: pointer;
171
432
  }
@@ -179,9 +440,12 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
179
440
  box-shadow: 0 0 0 4px rgba(191,219,254,0.7);
180
441
  }
181
442
 
182
- /* Upload zone inside wide tile */
443
+ /* Upload zone inside wide tile.
444
+ flex: 1 1 220px \u2014 wants at least 220px; if the container can't fit
445
+ upload + library on one row (~220 + 176), library wraps below. */
183
446
  .fb-wide-tile-upload {
184
- flex: 1;
447
+ flex: 1 1 220px;
448
+ min-height: 140px;
185
449
  display: flex;
186
450
  flex-direction: column;
187
451
  align-items: center;
@@ -194,24 +458,21 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
194
458
  background: transparent;
195
459
  border: none;
196
460
  font-family: inherit;
461
+ /* Dashed separator from library: right side when in a row, bottom when
462
+ wrapped (the line then sits between the two stacked cards). */
463
+ border-right: 1px dashed rgba(96,165,250,0.5);
197
464
  }
198
465
  .fb-wide-tile-upload:hover {
199
466
  background: rgba(191,219,254,0.25);
200
467
  }
201
-
202
- /* Vertical dashed divider between upload and library zones */
203
- .fb-wide-tile-divider {
204
- width: 1px;
205
- margin: 16px 0;
206
- border-left: 1px dashed rgba(96,165,250,0.5);
207
- background: transparent;
208
- flex-shrink: 0;
209
- }
210
-
211
- /* Library zone inside wide tile */
468
+ /* Library zone inside wide tile.
469
+ flex: 0 0 176px \u2014 fixed 176px, never grows. Upload fills the rest in
470
+ row layout. When the tile wraps to two rows on narrow containers,
471
+ library stays 176px wide on its own row (left-aligned), preserving the
472
+ visual hierarchy "upload > library" in both layouts. */
212
473
  .fb-wide-tile-library {
213
- width: 176px;
214
- flex-shrink: 0;
474
+ flex: 0 0 176px;
475
+ min-height: 120px;
215
476
  display: flex;
216
477
  flex-direction: column;
217
478
  align-items: center;
@@ -228,6 +489,10 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
228
489
  .fb-wide-tile-library:hover {
229
490
  background: rgba(191,219,254,0.25);
230
491
  }
492
+ /* Narrow-tile mode lives in a separate <style> tag (see below) \u2014 the
493
+ @container rule is appended only when the runtime actually supports
494
+ container queries, so jsdom (which doesn't) never sees it and stays
495
+ quiet in test logs. */
231
496
 
232
497
  /* \u2500\u2500\u2500 Multi-file outer grid container \u2500\u2500\u2500 */
233
498
  .fb-multi-outer {
@@ -604,90 +869,117 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
604
869
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
605
870
  gap: 10px;
606
871
  }
607
- `,document.head.appendChild(e)}function Yt(){xe();const e=document.createElement("div");return e.className="fb-tile",e}function Ce(e,t){var n,r;const o=(n=e.closest("[data-files-wrapper]"))==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=`
872
+ `,document.head.appendChild(e),typeof CSS!="undefined"&&typeof CSS.supports=="function"&&CSS.supports("container-type","inline-size")){const t=document.createElement("style");t.setAttribute("data-fb-file-styles-cq","true"),t.textContent=`
873
+ .fb-wide-tile { container-type: inline-size; }
874
+ @container (max-width: 408px) {
875
+ .fb-wide-tile-upload {
876
+ border-right: none;
877
+ border-bottom: 1px dashed rgba(96,165,250,0.5);
878
+ }
879
+ .fb-wide-tile-library {
880
+ flex: 1 0 100%;
881
+ min-height: 0;
882
+ flex-direction: row;
883
+ gap: 6px;
884
+ padding: 8px 12px;
885
+ font-size: 12px;
886
+ }
887
+ .fb-wide-tile-library .fb-wide-tile-library-icon {
888
+ width: 16px;
889
+ height: 16px;
890
+ }
891
+ .fb-wide-tile-library .fb-wide-tile-library-label {
892
+ font-size: 12px;
893
+ font-weight: 500;
894
+ }
895
+ .fb-wide-tile-library .fb-wide-tile-library-hint {
896
+ display: none;
897
+ }
898
+ }
899
+ `,document.head.appendChild(t)}}function sn(){$e();const e=document.createElement("div");return e.className="fb-tile",e}function Ee(e,t){var n,r;const o=(n=e.closest("[data-files-wrapper]"))==null?void 0:n.querySelector(".file-error-message");o&&o.remove();const a=document.createElement("div");a.className="file-error-message error-message",a.style.cssText=`
608
900
  color: var(--fb-error-color);
609
901
  font-size: var(--fb-font-size-small);
610
902
  margin-top: 0.25rem;
611
- `,i.textContent=t,(r=e.closest("[data-files-wrapper]"))==null||r.appendChild(i)}function Pe(e){var t;const n=(t=e.closest("[data-files-wrapper]"))==null?void 0:t.querySelector(".file-error-message");n&&n.remove()}function Mr(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=a=>{a.stopPropagation(),n()},o.appendChild(i),e.appendChild(o)}function Nr(e,t){xe();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=`
903
+ `,a.textContent=t,(r=e.closest("[data-files-wrapper]"))==null||r.appendChild(a)}function Ie(e){var t;const n=(t=e.closest("[data-files-wrapper]"))==null?void 0:t.querySelector(".file-error-message");n&&n.remove()}function Qr(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 a=document.createElement("button");a.className="bg-red-600 text-white px-3 py-1 rounded text-sm hover:bg-red-700 transition-colors",a.textContent=k("removeElement",t),a.onclick=i=>{i.stopPropagation(),n()},o.appendChild(a),e.appendChild(o)}function eo(e,t){$e();const n=sn();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=`
612
904
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:4px;">
613
905
  <div class="fb-spinner"></div>
614
- <div class="fb-tile-label">${le(r)}</div>
615
- <div class="fb-tile-uploading-text">${le($("uploadingFile",t))}</div>
616
- </div>`,n}function Gt(e){var t,n,r;const o=e.querySelector(".fb-multi-grid");if(o)return o;const i=e.querySelector(".fb-tiles-wrap");if(i)return i;(t=e.querySelector(".fb-file-dropzone"))==null||t.remove(),(n=e.querySelector(".fb-wide-tile"))==null||n.remove(),(r=e.querySelector(".fb-multi-outer"))==null||r.remove();const a=document.createElement("div");a.className="fb-tiles-wrap",a.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";const l=document.createElement("div");return l.className="fb-tile fb-tile-add",l.innerHTML="+",a.appendChild(l),e.appendChild(a),a}function gt(e,t,n){e.innerHTML=`
906
+ <div class="fb-tile-label">${ie(r)}</div>
907
+ <div class="fb-tile-uploading-text">${ie(k("uploadingFile",t))}</div>
908
+ </div>`,n}function cn(e){var t,n,r;const o=e.querySelector(".fb-multi-grid");if(o)return o;const a=e.querySelector(".fb-tiles-wrap");if(a)return a;(t=e.querySelector(".fb-file-dropzone"))==null||t.remove(),(n=e.querySelector(".fb-wide-tile"))==null||n.remove(),(r=e.querySelector(".fb-multi-outer"))==null||r.remove();const i=document.createElement("div");i.className="fb-tiles-wrap",i.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";const l=document.createElement("div");return l.className="fb-tile fb-tile-add",l.innerHTML="+",i.appendChild(l),e.appendChild(i),i}function $t(e,t,n){e.innerHTML=`
617
909
  <div class="flex flex-col items-center justify-center h-full text-gray-400">
618
910
  <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
619
911
  <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"/>
620
912
  </svg>
621
- <div class="text-sm text-center">${le($("clickDragText",t))}</div>
913
+ <div class="text-sm text-center">${ie(k("clickDragText",t))}</div>
622
914
 
623
915
  </div>
624
- `}const Xt=new WeakMap;function et(e,t){const n=Xt.get(e);n&&(e.removeEventListener("dragover",n.dragover),e.removeEventListener("dragleave",n.dragleave),e.removeEventListener("drop",n.drop));const r=a=>{a.preventDefault(),e.classList.add("border-blue-500","bg-blue-50")},o=a=>{a.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50")},i=a=>{var l;a.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50");const u=(l=a.dataTransfer)==null?void 0:l.files;u&&t(u)};e.addEventListener("dragover",r),e.addEventListener("dragleave",o),e.addEventListener("drop",i),Xt.set(e,{dragover:r,dragleave:o,drop:i})}const zr='<svg width="16" height="16" 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>',qr='<svg width="16" height="16" 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>',Ir='<svg width="16" height="16" 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>',Rr='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',Hr='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function Br(e,t){return!!(e.config.downloadFile||e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function Dr(e,t){return!!(e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function yt(e){const{canRemove:t,removeHandler:n,state:r,resourceId:o,fileName:i,meta:a,replaceHandler:l,libraryHandler:u}=e,s=document.createElement("div");s.className="fb-tile-actions";const d=(c,p,f)=>{const m=document.createElement("button");return m.type="button",m.className=`fb-tile-action-btn ${f}`,m.innerHTML=c,m.title=p,m.setAttribute("aria-label",p),m.addEventListener("click",g=>{g.stopPropagation()}),m};if(l){const c=d(Rr,$("replaceFile",r),"fb-tile-action-replace");c.addEventListener("click",()=>l()),s.appendChild(c)}if(u){const c=d(Hr,$("fromLibrary",r),"fb-tile-action-library");c.addEventListener("click",()=>u()),s.appendChild(c)}if(Br(r,a)){const c=d(zr,$("downloadFile",r),"fb-tile-action-download");c.addEventListener("click",()=>{jr(o,i,r,a)}),s.appendChild(c)}if(Dr(r,a)){const c=d(qr,$("openInNewTab",r),"fb-tile-action-open");c.addEventListener("click",()=>{Or(o,r,a).catch(p=>{console.error("Open failed:",p)})}),s.appendChild(c)}if(t&&n){const c=d(Ir,$("removeElement",r),"fb-tile-action-remove");c.addEventListener("click",()=>{n()}),s.appendChild(c)}return s}const tt=new WeakMap;function xt(e){let t=tt.get(e);return t||(t=URL.createObjectURL(e),tt.set(e,t)),t}function nt(e){if(!e)return;const t=tt.get(e);t&&(URL.revokeObjectURL(t),tt.delete(e))}function jr(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 Or(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=xt(n.file)),r&&window.open(r,"_blank")}let ve=null,Le=null,Fe=null,rt=null;function Ur(){if(!ve){ve=document.createElement("div"),ve.className="fb-tile-zoom-preview";const e=document.createElement("img");e.className="fb-tile-zoom-preview-img",ve.appendChild(e),ve.addEventListener("mouseenter",Qt),ve.addEventListener("mouseleave",Zt)}return ve}function Pr(e,t){const n=t.getBoundingClientRect(),r=350,o=6,i=8;let a;n.top-r-o>=i?a=n.top-r-o:n.bottom+o+r+i<=window.innerHeight?a=n.bottom+o:a=Math.max(i,Math.min(window.innerHeight-r-i,n.top));let l=n.left+n.width/2-r/2;l=Math.max(i,Math.min(window.innerWidth-r-i,l)),e.style.top=`${a}px`,e.style.left=`${l}px`}function Zt(){Fe!==null&&clearTimeout(Fe),Fe=setTimeout(()=>{Fe=null,en()},100)}function Qt(){Fe!==null&&(clearTimeout(Fe),Fe=null)}function en(){Le!==null&&(clearTimeout(Le),Le=null),ve&&ve.parentNode&&(ve.classList.remove("fb-tile-zoom-preview--visible"),ve.parentNode.removeChild(ve)),rt=null}function Et(e,t,n,r){e.dataset.zoomSrc=t,e.dataset.zoomAlt=n,e.addEventListener("mouseenter",()=>{Qt(),rt!==e&&en(),rt=e,Le=setTimeout(()=>{Le=null;const o=Ur(),i=o.querySelector(".fb-tile-actions");i&&i.remove();const a=o.querySelector(".fb-tile-zoom-preview-img");a.src=t,a.alt=n,r&&(o.appendChild(r.cloneNode(!0)),Wr(o.querySelector(".fb-tile-actions"),r)),o.style.pointerEvents="auto",Pr(o,e),document.body.appendChild(o),o.getBoundingClientRect(),o.classList.add("fb-tile-zoom-preview--visible")},200)}),e.addEventListener("mouseleave",()=>{Le!==null?(clearTimeout(Le),Le=null,rt=null):Zt()})}function Wr(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",a=>{a.stopPropagation(),i.click()})})}function Vr(e,t,n,r){const o=document.createElement("img");o.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",o.alt=n||$("previewAlt",r);const i=new FileReader;i.onload=a=>{var l;o.src=((l=a.target)==null?void 0:l.result)||""},i.readAsDataURL(t),e.appendChild(o)}function _r(e,t){e.onclick=null;const n=e.cloneNode(!1);return e.parentNode&&e.parentNode.replaceChild(n,e),n}function Kr(e,t,n,r,o,i){const a=URL.createObjectURL(t),l=_r(e);return l.innerHTML=`
916
+ `}const un=new WeakMap;function it(e,t){const n=un.get(e);n&&(e.removeEventListener("dragover",n.dragover),e.removeEventListener("dragleave",n.dragleave),e.removeEventListener("drop",n.drop));const r=i=>{i.preventDefault(),e.classList.add("border-blue-500","bg-blue-50")},o=i=>{i.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50")},a=i=>{var l;i.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50");const s=(l=i.dataTransfer)==null?void 0:l.files;s&&t(s)};e.addEventListener("dragover",r),e.addEventListener("dragleave",o),e.addEventListener("drop",a),un.set(e,{dragover:r,dragleave:o,drop:a})}const to='<svg width="16" height="16" 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>',no='<svg width="16" height="16" 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>',ro='<svg width="16" height="16" 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>',oo='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',lo='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function io(e,t){return!!(e.config.downloadFile||e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function ao(e,t){return!!(e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function Lt(e){const{canRemove:t,removeHandler:n,state:r,resourceId:o,fileName:a,meta:i,replaceHandler:l,libraryHandler:s}=e,c=document.createElement("div");c.className="fb-tile-actions";const d=(u,f,p)=>{const m=document.createElement("button");return m.type="button",m.className=`fb-tile-action-btn ${p}`,m.innerHTML=u,m.title=f,m.setAttribute("aria-label",f),m.addEventListener("click",b=>{b.stopPropagation()}),m};if(l){const u=d(oo,k("replaceFile",r),"fb-tile-action-replace");u.addEventListener("click",()=>l()),c.appendChild(u)}if(s){const u=d(lo,k("fromLibrary",r),"fb-tile-action-library");u.addEventListener("click",()=>s()),c.appendChild(u)}if(io(r,i)){const u=d(to,k("downloadFile",r),"fb-tile-action-download");u.addEventListener("click",()=>{so(o,a,r,i)}),c.appendChild(u)}if(ao(r,i)){const u=d(no,k("openInNewTab",r),"fb-tile-action-open");u.addEventListener("click",()=>{co(o,r,i).catch(f=>{console.error("Open failed:",f)})}),c.appendChild(u)}if(t&&n){const u=d(ro,k("removeElement",r),"fb-tile-action-remove");u.addEventListener("click",()=>{n()}),c.appendChild(u)}return c}const at=new WeakMap;function St(e){let t=at.get(e);return t||(t=URL.createObjectURL(e),at.set(e,t)),t}function st(e){if(!e)return;const t=at.get(e);t&&(URL.revokeObjectURL(t),at.delete(e))}function so(e,t,n,r){if(n.config.downloadFile){n.config.downloadFile(e,t);return}if((r==null?void 0:r.file)instanceof File){vn(r.file,t||r.file.name);return}bn(e,t,n).catch(o=>{console.error("Download failed:",o)})}async function co(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=St(n.file)),r&&window.open(r,"_blank")}let xe=null,Me=null,Re=null,ct=null;function uo(){if(!xe){xe=document.createElement("div"),xe.className="fb-tile-zoom-preview";const e=document.createElement("img");e.className="fb-tile-zoom-preview-img",xe.appendChild(e),xe.addEventListener("mouseenter",fn),xe.addEventListener("mouseleave",dn)}return xe}function fo(e,t){const n=t.getBoundingClientRect(),r=350,o=6,a=8;let i;n.top-r-o>=a?i=n.top-r-o:n.bottom+o+r+a<=window.innerHeight?i=n.bottom+o:i=Math.max(a,Math.min(window.innerHeight-r-a,n.top));let l=n.left+n.width/2-r/2;l=Math.max(a,Math.min(window.innerWidth-r-a,l)),e.style.top=`${i}px`,e.style.left=`${l}px`}function dn(){Re!==null&&clearTimeout(Re),Re=setTimeout(()=>{Re=null,pn()},100)}function fn(){Re!==null&&(clearTimeout(Re),Re=null)}function pn(){Me!==null&&(clearTimeout(Me),Me=null),xe&&xe.parentNode&&(xe.classList.remove("fb-tile-zoom-preview--visible"),xe.parentNode.removeChild(xe)),ct=null}function Tt(e,t,n,r){e.dataset.zoomSrc=t,e.dataset.zoomAlt=n,e.addEventListener("mouseenter",()=>{fn(),ct!==e&&pn(),ct=e,Me=setTimeout(()=>{Me=null;const o=uo(),a=o.querySelector(".fb-tile-actions");a&&a.remove();const i=o.querySelector(".fb-tile-zoom-preview-img");i.src=t,i.alt=n,r&&(o.appendChild(r.cloneNode(!0)),po(o.querySelector(".fb-tile-actions"),r)),o.style.pointerEvents="auto",fo(o,e),document.body.appendChild(o),o.getBoundingClientRect(),o.classList.add("fb-tile-zoom-preview--visible")},200)}),e.addEventListener("mouseleave",()=>{Me!==null?(clearTimeout(Me),Me=null,ct=null):dn()})}function po(e,t){const n=Array.from(t.querySelectorAll(".fb-tile-action-btn"));Array.from(e.querySelectorAll(".fb-tile-action-btn")).forEach((r,o)=>{const a=n[o];a&&r.addEventListener("click",i=>{i.stopPropagation(),a.click()})})}function mo(e,t,n,r){const o=document.createElement("img");o.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",o.alt=n||k("previewAlt",r);const a=new FileReader;a.onload=i=>{var l;o.src=((l=i.target)==null?void 0:l.result)||""},a.readAsDataURL(t),e.appendChild(o)}function ho(e,t){e.onclick=null;const n=e.cloneNode(!1);return e.parentNode&&e.parentNode.replaceChild(n,e),n}function bo(e,t,n,r,o,a){const i=URL.createObjectURL(t),l=ho(e);return l.innerHTML=`
625
917
  <div class="fb-video-preview-wrap">
626
- <video style="width:100%;height:100%;object-fit:contain;" controls preload="auto" muted src="${a}">
627
- ${le($("videoNotSupported",o))}
918
+ <video style="width:100%;height:100%;object-fit:contain;" controls preload="auto" muted src="${i}">
919
+ ${ie(k("videoNotSupported",o))}
628
920
  </video>
629
921
  <div class="fb-video-btn-overlay">
630
922
  <button class="fb-video-btn fb-video-btn-delete delete-file-btn">
631
- ${le($("removeElement",o))}
923
+ ${ie(k("removeElement",o))}
632
924
  </button>
633
925
  <button class="fb-video-btn fb-video-btn-change change-file-btn">
634
- ${le($("changeButton",o))}
926
+ ${ie(k("changeButton",o))}
635
927
  </button>
636
928
  </div>
637
929
  </div>
638
- `,Jr(l,r,o,i),l}function Jr(e,t,n,r){const o=e.querySelector(".change-file-btn");o&&(o.onclick=a=>{var l;a.stopPropagation(),(l=r==null?void 0:r.picker)==null||l.click()});const i=e.querySelector(".delete-file-btn");i&&(i.onclick=a=>{a.stopPropagation(),Yr(e,t,n,r)})}function Yr(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=`
930
+ `,vo(l,r,o,a),l}function vo(e,t,n,r){const o=e.querySelector(".change-file-btn");o&&(o.onclick=i=>{var l;i.stopPropagation(),(l=r==null?void 0:r.picker)==null||l.click()});const a=e.querySelector(".delete-file-btn");a&&(a.onclick=i=>{i.stopPropagation(),go(e,t,n,r)})}function go(e,t,n,r){var o;n.resourceIndex.delete(t);const a=(o=e.parentElement)==null?void 0:o.querySelector('input[type="hidden"]');a&&(a.value=""),r!=null&&r.fileUploadHandler&&(e.onclick=r.fileUploadHandler),e.innerHTML=`
639
931
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
640
932
  <svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
641
933
  <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"/>
642
934
  </svg>
643
- <div style="font-size:0.875rem;text-align:center;">${le($("clickDragText",n))}</div>
935
+ <div style="font-size:0.875rem;text-align:center;">${ie(k("clickDragText",n))}</div>
644
936
  </div>
645
- `,r!=null&&r.setupDrop&&r.setupDrop(e)}function tn(e,t,n){Mr(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=`
937
+ `,r!=null&&r.setupDrop&&r.setupDrop(e)}function mn(e,t,n){Qr(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=`
646
938
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
647
939
  <svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
648
940
  <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"/>
649
941
  </svg>
650
- <div style="font-size:0.875rem;text-align:center;">${le($("clickDragText",n))}</div>
942
+ <div style="font-size:0.875rem;text-align:center;">${ie(k("clickDragText",n))}</div>
651
943
  </div>
652
- `})}async function Gr(e,t,n,r,o,i,a){var l,u,s;!t.file||!(t.file instanceof File)||((l=t.type)!=null&&l.startsWith("image/")?Vr(e,t.file,n,i):(u=t.type)!=null&&u.startsWith("video/")?e=Kr(e,t.file,t.type,r,i,a):e.innerHTML=`<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);"><div style="font-size:36px;margin-bottom:0.5rem;">\u{1F4C1}</div><div style="font-size:0.875rem;">${le(n)}</div></div>`,!o&&!((s=t.type)!=null&&s.startsWith("video/"))&&tn(e,r,i))}function Xr(e,t,n){const r=document.createElement("video");r.style.cssText="width:100%;height:100%;object-fit:contain;",r.controls=!0,r.preload="metadata",r.muted=!0,r.src=t,r.appendChild(document.createTextNode($("videoNotSupported",n))),e.appendChild(r)}async function Zr(e,t,n,r,o){var i;if(!o.config.getThumbnail){gt(e,o);return}try{const a=await o.config.getThumbnail(t);if(a)if(be(e),(i=r==null?void 0:r.type)!=null&&i.startsWith("video/"))Xr(e,a,o);else{const l=document.createElement("img");l.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",l.alt=n||$("previewAlt",o),l.src=a,e.appendChild(l)}else gt(e,o)}catch(a){console.error("Failed to get thumbnail:",a),e.innerHTML=`
944
+ `})}async function yo(e,t,n,r,o,a,i){var l,s,c;!t.file||!(t.file instanceof File)||((l=t.type)!=null&&l.startsWith("image/")?mo(e,t.file,n,a):(s=t.type)!=null&&s.startsWith("video/")?e=bo(e,t.file,t.type,r,a,i):e.innerHTML=`<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);"><div style="font-size:36px;margin-bottom:0.5rem;">\u{1F4C1}</div><div style="font-size:0.875rem;">${ie(n)}</div></div>`,!o&&!((c=t.type)!=null&&c.startsWith("video/"))&&mn(e,r,a))}function xo(e,t,n){const r=document.createElement("video");r.style.cssText="width:100%;height:100%;object-fit:contain;",r.controls=!0,r.preload="metadata",r.muted=!0,r.src=t,r.appendChild(document.createTextNode(k("videoNotSupported",n))),e.appendChild(r)}async function wo(e,t,n,r,o){var a;if(!o.config.getThumbnail){$t(e,o);return}try{const i=await o.config.getThumbnail(t);if(i)if(ge(e),(a=r==null?void 0:r.type)!=null&&a.startsWith("video/"))xo(e,i,o);else{const l=document.createElement("img");l.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",l.alt=n||k("previewAlt",o),l.src=i,e.appendChild(l)}else $t(e,o)}catch(i){console.error("Failed to get thumbnail:",i),e.innerHTML=`
653
945
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
654
946
  <svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
655
947
  <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"/>
656
948
  </svg>
657
- <div style="font-size:0.875rem;text-align:center;">${le(n||$("previewUnavailable",o))}</div>
949
+ <div style="font-size:0.875rem;text-align:center;">${ie(n||k("previewUnavailable",o))}</div>
658
950
  </div>
659
- `}}async function Ct(e,t,n,r={}){var o;const{fileName:i="",isReadonly:a=!1,deps:l=null}=r;if(!a&&l&&(!l.picker||!l.fileUploadHandler||!l.dragHandler))throw new Error("renderFilePreview: missing deps {picker, fileUploadHandler, dragHandler}");be(e);const u=n.resourceIndex.get(t);if(u&&u.file&&u.file instanceof File)await Gr(e,u,i,t,a,n,l);else{await Zr(e,t,i,u,n);const s=(o=u==null?void 0:u.type)==null?void 0:o.startsWith("video/");!a&&!s&&tn(e,t,n)}}function Qr(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 a=t.resourceIndex.get(e),l=Qr(e,a,n),{canRemove:u=!1,removeHandler:s=null}=r,d=((o=a==null?void 0:a.type)==null?void 0:o.startsWith("image/"))||!!l.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/),c=((i=a==null?void 0:a.type)==null?void 0:i.startsWith("video/"))||!!l.toLowerCase().match(/\.(mp4|webm|avi|mov)$/),p=Yt();p.classList.add("fb-tile-resource"),p.style.cursor="pointer",l&&(p.title=l);const f=(a==null?void 0:a.file)instanceof File?xt(a.file):null,m=async()=>t.config.getDownloadUrl?t.config.getDownloadUrl(e):t.config.getThumbnail?t.config.getThumbnail(e):f;p.onclick=async()=>{const h=await m();h?window.open(h,"_blank"):t.config.downloadFile?t.config.downloadFile(e,l):rn(e,l,t).catch(v=>{console.error("Download failed:",v)})};const g=yt({canRemove:u,removeHandler:s,state:t,resourceId:e,fileName:l,meta:a}),y=async()=>{if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);if(h)return h}catch(h){}return f},C=()=>{p.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>',p.appendChild(g)};if(d){const h=await y();if(h){const v=document.createElement("img");v.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",v.alt=l,v.src=h,p.appendChild(v),p.appendChild(g),Et(p,h,l,g)}else C()}else if(c)if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);h?(p.innerHTML=`
660
- <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${le(l)}" src="${h}">
951
+ `}}async function At(e,t,n,r={}){var o;const{fileName:a="",isReadonly:i=!1,deps:l=null}=r;if(!i&&l&&(!l.picker||!l.fileUploadHandler||!l.dragHandler))throw new Error("renderFilePreview: missing deps {picker, fileUploadHandler, dragHandler}");ge(e);const s=n.resourceIndex.get(t);if(s&&s.file&&s.file instanceof File)await yo(e,s,a,t,i,n,l);else{await wo(e,t,a,s,n);const c=(o=s==null?void 0:s.type)==null?void 0:o.startsWith("video/");!i&&!c&&mn(e,t,n)}}function Co(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 Ft(e,t,n,r={}){var o,a;const i=t.resourceIndex.get(e),l=Co(e,i,n),{canRemove:s=!1,removeHandler:c=null}=r,d=((o=i==null?void 0:i.type)==null?void 0:o.startsWith("image/"))||!!l.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/),u=((a=i==null?void 0:i.type)==null?void 0:a.startsWith("video/"))||!!l.toLowerCase().match(/\.(mp4|webm|avi|mov)$/),f=sn();f.classList.add("fb-tile-resource"),f.style.cursor="pointer",l&&(f.title=l);const p=(i==null?void 0:i.file)instanceof File?St(i.file):null,m=async()=>t.config.getDownloadUrl?t.config.getDownloadUrl(e):t.config.getThumbnail?t.config.getThumbnail(e):p;f.onclick=async()=>{const h=await m();h?window.open(h,"_blank"):t.config.downloadFile?t.config.downloadFile(e,l):bn(e,l,t).catch(y=>{console.error("Download failed:",y)})};const b=Lt({canRemove:s,removeHandler:c,state:t,resourceId:e,fileName:l,meta:i}),g=async()=>{if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);if(h)return h}catch(h){}return p},w=()=>{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(b)};if(d){const h=await g();if(h){const y=document.createElement("img");y.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",y.alt=l,y.src=h,f.appendChild(y),f.appendChild(b),Tt(f,h,l,b)}else w()}else if(u)if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);h?(f.innerHTML=`
952
+ <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${ie(l)}" src="${h}">
661
953
  <div class="fb-video-overlay">
662
954
  <div class="fb-play-btn" style="width:22px;height:22px;">
663
955
  <svg width="10" height="12" viewBox="0 0 10 12" fill="currentColor"><path d="M0 0l10 6-10 6z"/></svg>
664
956
  </div>
665
- </div>`,p.appendChild(g)):(p.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',p.appendChild(g))}catch(h){p.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',p.appendChild(g)}else p.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',p.appendChild(g);else{if(t.config.getThumbnail)try{const v=await t.config.getThumbnail(e);if(v){const x=document.createElement("img");return x.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",x.alt=l||e,x.src=v,p.appendChild(x),p.appendChild(g),p}}catch(v){}const h=l?`<div class="fb-tile-label">${le(l.length>10?l.substring(0,8)+"\u2026":l)}</div>
666
- <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>`:"";p.innerHTML=`
957
+ </div>`,f.appendChild(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(b))}catch(h){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(b)}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(b);else{if(t.config.getThumbnail)try{const y=await t.config.getThumbnail(e);if(y){const v=document.createElement("img");return v.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",v.alt=l||e,v.src=y,f.appendChild(v),f.appendChild(b),f}}catch(y){}const h=l?`<div class="fb-tile-label">${ie(l.length>10?l.substring(0,8)+"\u2026":l)}</div>
958
+ <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=`
667
959
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
668
960
  <div style="font-size:36px;">\u{1F4C1}</div>
669
961
  ${h}
670
- </div>`,p.appendChild(g)}return p}async function eo(e,t,n,r){var o,i,a;const l=n.resourceIndex.get(t),u=(i=(o=l==null?void 0:l.name)!=null?o:t.split("/").pop())!=null?i:"",s=(a=r.onRemove)!=null?a:null,d=await wt(t,n,u,{canRemove:!0,removeHandler:s});e.className="file-preview-container",e.removeAttribute("style"),be(e),e.appendChild(d)}async function nn(e,t,n,r,o){var i,a;if((i=n==null?void 0:n.type)!=null&&i.startsWith("image/")){if(n.file&&n.file instanceof File){const l=document.createElement("img");l.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",l.alt=n.name,l.src=xt(n.file),e.appendChild(l),Et(e,l.src,n.name,o!=null?o:null)}else if(r.config.getThumbnail)try{const l=await r.config.getThumbnail(t);if(l){const u=document.createElement("img");u.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",u.alt=n.name,u.src=l,e.appendChild(u),Et(e,l,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(l){const u=l instanceof Error?l:new Error(String(l));r.config.onThumbnailError&&r.config.onThumbnailError(u,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((a=n==null?void 0:n.type)!=null&&a.startsWith("video/")){if(n.file&&n.file instanceof File){const l=URL.createObjectURL(n.file);e.innerHTML=`
962
+ </div>`,f.appendChild(b)}return f}async function Eo(e,t,n,r){var o,a,i;const l=n.resourceIndex.get(t),s=(a=(o=l==null?void 0:l.name)!=null?o:t.split("/").pop())!=null?a:"",c=(i=r.onRemove)!=null?i:null,d=await Ft(t,n,s,{canRemove:!0,removeHandler:c});e.className="file-preview-container",e.removeAttribute("style"),ge(e),e.appendChild(d)}async function hn(e,t,n,r,o){var a,i;if((a=n==null?void 0:n.type)!=null&&a.startsWith("image/")){if(n.file&&n.file instanceof File){const l=document.createElement("img");l.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",l.alt=n.name,l.src=St(n.file),e.appendChild(l),Tt(e,l.src,n.name,o!=null?o:null)}else if(r.config.getThumbnail)try{const l=await r.config.getThumbnail(t);if(l){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=l,e.appendChild(s),Tt(e,l,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(l){const s=l instanceof Error?l:new Error(String(l));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((i=n==null?void 0:n.type)!=null&&i.startsWith("video/")){if(n.file&&n.file instanceof File){const l=URL.createObjectURL(n.file);e.innerHTML=`
671
963
  <video style="width:100%;height:100%;" preload="metadata" muted src="${l}"></video>
672
964
  <div class="fb-video-overlay">
673
965
  <div class="fb-play-btn" style="width:20px;height:20px;">
674
966
  <svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
675
967
  </div>
676
968
  </div>`}else if(r.config.getThumbnail)try{const l=await r.config.getThumbnail(t);l?e.innerHTML=`
677
- <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${le(n.name)}" src="${l}">
969
+ <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${ie(n.name)}" src="${l}">
678
970
  <div class="fb-video-overlay">
679
971
  <div class="fb-play-btn" style="width:20px;height:20px;">
680
972
  <svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
681
973
  </div>
682
- </div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(l){const u=l instanceof Error?l:new Error(String(l));r.config.onThumbnailError&&r.config.onThumbnailError(u,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 to(e,t,n,o)}function to(e,t,n,r){var o,i;const a=(i=(o=n==null?void 0:n.name)!=null?o:t.split("/").pop())!=null?i:"";a&&(e.title=a);const l=a?`<div style="font-size:11px;line-height:1.2;text-align:center;color:var(--fb-text-secondary-color,#6b7280);max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${le(a)}</div>`:"";e.innerHTML=`
974
+ </div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(l){const s=l instanceof Error?l:new Error(String(l));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 ko(e,t,n,o)}function ko(e,t,n,r){var o,a;const i=(a=(o=n==null?void 0:n.name)!=null?o:t.split("/").pop())!=null?a:"";i&&(e.title=i);const l=i?`<div style="font-size:11px;line-height:1.2;text-align:center;color:var(--fb-text-secondary-color,#6b7280);max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${ie(i)}</div>`:"";e.innerHTML=`
683
975
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
684
976
  <div style="font-size:36px;">\u{1F4C1}</div>
685
977
  ${l}
686
- </div>`,r&&e.appendChild(r)}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 a=await i.blob();on(a,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 no(e){var t,n,r;const{file:o,container:i,fieldName:a,state:l,deps:u=null,instance:s=null,allowedExtensions:d=[],allowedMimes:c=[],maxSizeMB:p=1/0}=e;if(!qe(o.name,d)){const h=d.join(", ");Ce(i,$("invalidFileExtension",l,{name:o.name,formats:h}));return}if(!Ue(o.type,c)){const h=c.join(", ");Ce(i,$("invalidFileMime",l,{name:o.name,type:o.type,mimes:h}));return}if(!Ze(o,p)){Ce(i,$("fileTooLarge",l,{name:o.name,maxSize:p}));return}Pe(i);const f=(t=i.parentElement)==null?void 0:t.querySelector('input[type="hidden"]'),m=(f==null?void 0:f.value)||null;xe(),i.innerHTML=`
978
+ </div>`,r&&e.appendChild(r)}async function bn(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,a=await fetch(o);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);const i=await a.blob();vn(i,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 vn(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 gn(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));t.config.onUploadError&&t.config.onUploadError(r,e);const o=new Error(`File upload failed: ${r.message}`);throw o.cause=r,o}}async function $o(e){var t,n,r;const{file:o,container:a,fieldName:i,state:l,deps:s=null,instance:c=null,allowedExtensions:d=[],allowedMimes:u=[],maxSizeMB:f=1/0}=e;if(!je(o.name,d)){const h=d.join(", ");Ee(a,k("invalidFileExtension",l,{name:o.name,formats:h}));return}if(!Xe(o.type,u)){const h=u.join(", ");Ee(a,k("invalidFileMime",l,{name:o.name,type:o.type,mimes:h}));return}if(!ot(o,f)){Ee(a,k("fileTooLarge",l,{name:o.name,maxSize:f}));return}Ie(a);const p=(t=a.parentElement)==null?void 0:t.querySelector('input[type="hidden"]'),m=(p==null?void 0:p.value)||null;$e(),a.innerHTML=`
687
979
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:6px;">
688
980
  <div class="fb-spinner"></div>
689
- <div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${le($("uploadingFile",l))}</div>
690
- </div>`;let g;try{g=await ln(o,l)}catch(h){throw m&&u!=null&&u.onAfterUpload?u.onAfterUpload(i,m):u!=null&&u.onRemove?u.onRemove():gt(i,l),h}l.resourceIndex.set(g,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:o}),m&&m!==g&&nt((n=l.resourceIndex.get(m))==null?void 0:n.file);let y=f;y||(y=document.createElement("input"),y.type="hidden",y.name=a,(r=i.parentElement)==null||r.appendChild(y)),y.value=g;const C=o.type.startsWith("video/");!C&&u!=null&&u.onAfterUpload?u.onAfterUpload(i,g):!C&&u?eo(i,g,l,u).catch(console.error):Ct(i,g,l,{fileName:o.name,isReadonly:!1,deps:u}).catch(console.error),s&&!l.config.readonly&&s.triggerOnChange(a,g)}function an(e,t,n,r){const o=e.filter(m=>!qe(m.name,n.allowedExtensions)),i=e.filter(m=>qe(m.name,n.allowedExtensions)),a=i.filter(m=>!Ue(m.type,n.allowedMimes)),l=i.filter(m=>Ue(m.type,n.allowedMimes)),u=l.filter(m=>!Ze(m,n.maxSize)),s=l.filter(m=>Ze(m,n.maxSize)),d=n.maxCount===1/0?s.length:Math.max(0,n.maxCount-t),c=s.slice(0,d),p=s.length-c.length,f=[];if(o.length>0){const m=n.allowedExtensions.join(", "),g=o.map(y=>y.name).join(", ");f.push($("invalidFileExtension",r,{name:g,formats:m}))}if(a.length>0){const m=n.allowedMimes.join(", "),g=a.map(y=>y.name).join(", ");f.push($("invalidFileMime",r,{name:g,type:a.map(y=>y.type).join(", "),mimes:m}))}if(u.length>0){const m=u.map(g=>g.name).join(", ");f.push($("fileTooLarge",r,{name:m,maxSize:n.maxSize}))}return p>0&&f.push($("filesLimitExceeded",r,{skipped:p,max:n.maxCount})),{accepted:c,errorMessage:f.join(" \u2022 ")}}async function sn(e,t,n,r){var o;if(n){const i=Gt(n),a=(o=i.querySelector(".fb-multi-add-tile-js"))!=null?o:i.querySelector(".fb-tile-add");a&&(a.style.display="none")}await Promise.all(e.map(async i=>{const a=Nr(i.name,r);n&&Gt(n).appendChild(a);try{const l=await ln(i,r);r.resourceIndex.set(l,{name:i.name,type:i.type,size:i.size,uploadedAt:new Date,file:void 0}),t.push(l)}finally{a.remove()}}))}function ro(e,t,n,r,o,i,a){et(e,async l=>{var u;const{accepted:s,errorMessage:d}=an(Array.from(l),t.length,o,n);d?Ce(e,d):Pe(e);const c=(u=e.querySelector(".files-list"))!=null?u:e;await sn(s,t,c,n),r(),a&&i&&!n.config.readonly&&a.triggerOnChange(i,t)})}function oo(e,t,n,r,o,i,a){e.onchange=async()=>{if(!e.files)return;const l=e.closest("[data-files-wrapper]")||e.parentElement,{accepted:u,errorMessage:s}=an(Array.from(e.files),t.length,o,n);s&&l?Ce(l,s):l&&Pe(l);const d=l==null?void 0:l.querySelector(".files-list");await sn(u,t,d!=null?d:null,n),r(),e.value="",a&&i&&!n.config.readonly&&a.triggerOnChange(i,t)}}function un(e){var t,n;if(!e.accept)return;if(typeof e.accept=="string"){const l=$e(e.accept);return l.length>0?{extensions:l}:void 0}const r=(t=e.accept.extensions)!=null?t:[],o=(n=e.accept.mime)!=null?n:[],i=r.map(l=>l.toLowerCase());if(i.length===0&&o.length===0)return;const a={};return i.length>0&&(a.extensions=i),o.length>0&&(a.mime=o),a}function cn(e,t,n,r,o){if(!qe(e.name,t)){const i=t.join(", ");return $("invalidFileExtension",o,{name:e.name,formats:i})}if(!Ue(e.type,n)){const i=n.join(", ");return $("invalidFileMime",o,{name:e.name,type:e.type,mimes:i})}return Kt(e.size,r)?null:$("fileTooLarge",o,{name:e.name,maxSize:r})}function lo(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 io(e,t,n,r,o,i,a,l){var u;if(!e.config.pickExistingFiles)return;const s=$e(t.accept),d=Oe(t.accept),c=(u=t.maxSize)!=null?u:1/0,p=lo(n),f=i===1/0?1/0:Math.max(0,i-p.length);let m;try{m=await e.config.pickExistingFiles({fieldPath:r,mode:"multiple",accept:un(t),maxSizeMB:c===1/0?void 0:c,remainingSlots:f===1/0?void 0:f,selectedResourceIds:[...p]})}catch(E){Ce(n,fn(E,e));return}if(m.length===0)return;const g=new Set(p),y=new Set,C=m.filter(E=>g.has(E.resourceId)||y.has(E.resourceId)?!1:(y.add(E.resourceId),!0)).filter(E=>cn(E,s,d,c,e)===null),h=i===1/0?C.length:Math.max(0,i-o.length),v=C.slice(0,h),x=C.length-v.length;if(v.length!==0){Pe(n),x>0&&Ce(n,$("filesLimitExceeded",e,{skipped:x,max:i}));for(const E of v)dn(E,e),o.push(E.resourceId);n.dataset.resourceIds=JSON.stringify(o),a(),e.config.readonly||l.triggerOnChange(r,o)}}async function ao(e,t,n,r,o,i,a,l){var u,s;if(!e.config.pickExistingFiles)return;const d=$e(t.accept),c=Oe(t.accept),p=(u=t.maxSize)!=null?u:1/0;let f;try{f=await e.config.pickExistingFiles({fieldPath:i,mode:"single",accept:un(t),maxSizeMB:p===1/0?void 0:p,selectedResourceIds:[]})}catch(h){Ce(n,fn(h,e));return}if(f.length===0)return;const m=f[0],g=cn(m,d,c,p,e);if(g!==null){Ce(n,g);return}Pe(n),dn(m,e);let y=r.querySelector('input[type="hidden"]');y||(y=document.createElement("input"),y.type="hidden",y.name=o,r.appendChild(y));const C=y.value||null;C&&C!==m.resourceId&&nt((s=e.resourceIndex.get(C))==null?void 0:s.file),y.value=m.resourceId,await a(m.resourceId),e.config.readonly||l.triggerOnChange(i,m.resourceId)}const pn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',mn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function so(e,t,n,r,o,i,a){var l;Qe(e,o.resourceIndex);const u=o.resourceIndex.get(e);(l=u==null?void 0:u.type)!=null&&l.startsWith("video/")?Ct(t,e,o,{fileName:e,isReadonly:!1,deps:i}).catch(console.error):kt(t,e,o,i,a);const s=document.createElement("input");s.type="hidden",s.name=n,s.value=e,r.appendChild(s)}function uo(e,t,n,r,o=!1,i=""){xe();const a=document.createElement("div");a.className=`fb-wide-tile${t?" fb-file-card-row":""}${o?" fb-drag-over":""}`;const l=document.createElement("button");l.type="button",l.className="fb-wide-tile-upload fb-file-dropzone";const u=document.createElement("span");u.style.cssText="width:36px;height:36px;display:block;flex-shrink:0;",u.innerHTML=pn,l.appendChild(u);const s=document.createElement("div");if(s.className="fb-wide-tile-label",s.style.cssText="font-size:14px;font-weight:600;",s.textContent=$(o?"dropToUpload":"clickDragText",e),l.appendChild(s),i){const d=document.createElement("div");d.style.cssText="font-size:11px;opacity:0.65;margin-top:2px;",d.textContent=i,l.appendChild(d)}if(l.onclick=d=>{d.stopPropagation(),n()},a.appendChild(l),t&&r){const d=document.createElement("div");d.className="fb-wide-tile-divider",a.appendChild(d);const c=document.createElement("button");c.type="button",c.className="fb-wide-tile-library fb-file-library-card";const p=document.createElement("span");p.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",p.innerHTML=mn,c.appendChild(p);const f=document.createElement("div");f.style.cssText="font-size:13px;font-weight:600;text-align:center;",f.textContent=$("fromLibrary",e),c.appendChild(f);const m=document.createElement("div");m.style.cssText="font-size:11px;opacity:0.75;text-align:center;",m.textContent=$("libraryHint",e),c.appendChild(m),c.onclick=g=>{g.stopPropagation(),r()},a.appendChild(c)}return hn(a,{onEnter:()=>{const d=a.querySelector(".fb-wide-tile-label");d&&(d.textContent=$("dropToUpload",e))},onLeave:()=>{const d=a.querySelector(".fb-wide-tile-label");d&&(d.textContent=$("clickDragText",e))},activeClass:"fb-drag-over"}),a}function hn(e,t){let n=0;e.addEventListener("dragover",r=>{r.preventDefault()}),e.addEventListener("dragenter",r=>{r.preventDefault(),n++,n===1&&(e.classList.add(t.activeClass),t.onEnter())}),e.addEventListener("dragleave",r=>{r.preventDefault(),n=Math.max(0,n-1),n===0&&(e.classList.remove(t.activeClass),t.onLeave())}),e.addEventListener("drop",()=>{n=0,e.classList.remove(t.activeClass),t.onLeave()})}function kt(e,t,n,r,o){var i,a;const l=n.resourceIndex.get(t);if((i=l==null?void 0:l.type)!=null&&i.startsWith("video/")){Ct(e,t,n,{fileName:(a=l==null?void 0:l.name)!=null?a:"",isReadonly:!1,deps:r}).catch(console.error);return}xe();const u=document.createElement("div");u.className="fb-multi-outer fb-multi-has-files";const s=document.createElement("div");s.className="fb-multi-grid fb-tiles-wrap",u.appendChild(s);const d=bn(t,n,!!r.onRemove,r.onRemove?()=>{var c;return(c=r.onRemove)==null?void 0:c.call(r)}:null,o);for(s.appendChild(d),e.className="file-preview-container",e.removeAttribute("style");e.firstChild;)e.removeChild(e.firstChild);e.appendChild(u)}function co(e,t,n,r,o=!1){const i=document.createElement("div");i.className=`fb-multi-add-tile fb-multi-add-tile-js${o?" fb-drag-over-tile":""}`;const a=document.createElement("button");a.type="button",a.className="fb-multi-add-upload fb-tile-add fb-file-dropzone";const l=document.createElement("span");l.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",l.innerHTML=pn,a.appendChild(l);const u=document.createElement("span");if(u.className="fb-multi-add-label",u.style.cssText="font-size:11px;font-weight:600;",u.textContent=$(o?"dropToUpload":"clickDragTextMultiple",e),a.appendChild(u),a.onclick=s=>{s.stopPropagation(),n()},i.appendChild(a),t&&r){const s=document.createElement("div");s.className="fb-multi-add-divider",i.appendChild(s);const d=document.createElement("button");d.type="button",d.className="fb-multi-add-library fb-tile-add-library fb-file-library-card",d.setAttribute("aria-label",$("fromLibrary",e));const c=document.createElement("span");c.style.cssText="width:14px;height:14px;display:block;flex-shrink:0;",c.innerHTML=mn,d.appendChild(c),d.appendChild(document.createTextNode($("fromLibrary",e))),d.onclick=p=>{p.stopPropagation(),r()},i.appendChild(d)}return i}function bn(e,t,n,r,o){var i,a,l;xe();const u=t.resourceIndex.get(e),s=document.createElement("div");s.className="fb-preview-tile fb-checker fb-tile-resource resource-pill",s.dataset.resourceId=e;const d=yt({canRemove:n&&r!==null,removeHandler:r,state:t,resourceId:e,fileName:(i=u==null?void 0:u.name)!=null?i:"",meta:u,replaceHandler:(a=o==null?void 0:o.replaceHandler)!=null?a:null,libraryHandler:(l=o==null?void 0:o.libraryHandler)!=null?l:null});return nn(s,e,u,t,d).catch(c=>{console.error("Failed to render tile:",c)}),s}function vn(e=!1){const t=document.createElement("div");return t.className=`fb-multi-placeholder fb-checker${e?" fb-drag-over":""}`,t}function fo(e,t,n,r,o,i){const a=document.createElement("div");a.className="fb-meta-line";const l=document.createElement("div");if(l.className="fb-meta-text",t.maxSize&&t.maxSize!==1/0){const d=document.createElement("span");d.textContent=$("hintMaxSize",e,{size:t.maxSize}),l.appendChild(d),l.appendChild(gn())}const u=$e(t.accept);if(u.length>0){const d=document.createElement("span");d.className="fb-meta-mono",d.textContent=u.map(c=>c.toUpperCase()).join(", "),l.appendChild(d),l.appendChild(gn())}const s=document.createElement("span");if(r<1/0)s.textContent=$("fileCountWithMax",e,{count:n,max:r});else{const d=n===1?"fileCountSingle":"fileCountPlural";s.textContent=$(d,e,{count:n})}if(l.appendChild(s),a.appendChild(l),o&&n>1){const d=document.createElement("button");d.type="button",d.className="fb-clear-all-btn",d.textContent=$("clearAll",e),d.onclick=c=>{c.stopPropagation(),window.confirm($("clearAll",e)+"?")&&i()},a.appendChild(d)}return a}function gn(){const e=document.createElement("span");return e.className="fb-meta-dot",e}const $t=new WeakMap;function po(e){var t;const{container:n,rids:r,state:o,onRemove:i,maxCount:a,isReadonly:l=!1,onLibraryPick:u,element:s,onClearAll:d,openPicker:c}=e;xe();const p=n.closest("[data-files-wrapper]");p&&(p.dataset.resourceIds=JSON.stringify(r!=null?r:[]));const f=$t.get(n);for(f&&(f.disconnect(),$t.delete(n));n.firstChild;)n.removeChild(n.firstChild);const m=r!=null?r:[],g=a!=null?a:1/0,y=g!==1/0&&m.length>=g,C=!l&&typeof u=="function",h=c!=null?c:(()=>{var b;const w=(b=n.closest("[data-files-wrapper]"))==null?void 0:b.querySelector('input[type="file"]');w&&w.click()});if(l){if(m.length===0){const b=document.createElement("div");b.className="fb-tile-empty-text",b.textContent=$("noFilesSelected",o),n.appendChild(b)}else{const b=document.createElement("div");b.className="fb-multi-readonly-grid",n.appendChild(b);for(const w of m){const F=o.resourceIndex.get(w),V=document.createElement("div");V.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",V.dataset.resourceId=w;const R=yt({canRemove:!1,removeHandler:null,state:o,resourceId:w,fileName:(t=F==null?void 0:F.name)!=null?t:"",meta:F});nn(V,w,F,o,R).catch(console.error),V.onclick=async()=>{var D;let j=null;o.config.getDownloadUrl?j=o.config.getDownloadUrl(w):o.config.getThumbnail?j=await o.config.getThumbnail(w):(F==null?void 0:F.file)instanceof File&&(j=URL.createObjectURL(F.file)),j?window.open(j,"_blank"):o.config.downloadFile&&o.config.downloadFile(w,(D=F==null?void 0:F.name)!=null?D:"")},b.appendChild(V)}}return}const v=document.createElement("div");v.className=`fb-multi-outer${m.length>0?" fb-multi-has-files":""}`;const x=document.createElement("div");x.className="fb-multi-grid fb-tiles-wrap",v.appendChild(x),n.appendChild(v);for(let b=0;b<m.length;b++){const w=m[b],F=bn(w,o,i!==null,i?()=>i(w):null);x.appendChild(F)}if(!y){const b=co(o,C,h,u!=null?u:null);x.appendChild(b)}const E=m.length+(y?0:1),k=()=>{const b=getComputedStyle(x).gridTemplateColumns,w=b?b.split(" ").filter(Boolean).length:0;if(!w)return;const F=E%w,V=F===0?0:w-F,R=g===1/0?V:Math.max(0,g-E),D=Math.min(V,R),j=x.querySelectorAll(".fb-multi-placeholder");if(j.length>D)for(let Y=j.length-1;Y>=D;Y--)j[Y].remove();else if(j.length<D)for(let Y=j.length;Y<D;Y++)x.appendChild(vn())};if((g===1/0||g>E)&&x.appendChild(vn()),requestAnimationFrame(k),typeof ResizeObserver!="undefined"){const b=new ResizeObserver(()=>k());b.observe(x),$t.set(n,b)}if(hn(v,{activeClass:"fb-drag-over",onEnter:()=>{x.querySelectorAll(".fb-multi-placeholder").forEach(w=>{w.classList.add("fb-drag-over")});const b=x.querySelector(".fb-multi-add-tile-js");if(b){b.classList.add("fb-drag-over-tile");const w=b.querySelector(".fb-multi-add-label");w&&(w.textContent=$("dropToUpload",o))}},onLeave:()=>{x.querySelectorAll(".fb-multi-placeholder").forEach(w=>{w.classList.remove("fb-drag-over")});const b=x.querySelector(".fb-multi-add-tile-js");if(b){b.classList.remove("fb-drag-over-tile");const w=b.querySelector(".fb-multi-add-label");w&&(w.textContent=$("clickDragTextMultiple",o))}}}),s){const b=fo(o,s,m.length,g,!!d,d!=null?d:(()=>{}));n.appendChild(b)}}function mo(e,t,n,r){var o,i;const a=t.state,l=document.createElement("div");l.className="space-y-2",l.dataset.filesWrapper=r;const u=document.createElement("input");u.type="file",u.name=r,u.style.display="none",u.accept=yn(e.accept);const s=document.createElement("div");s.className="file-preview-container";const d=t.prefill[e.key],c=$e(e.accept),p=Oe(e.accept),f=(o=e.maxSize)!=null?o:1/0,m={fileUploadHandler(){u.click()},dragHandler(h){h.length>0&&no({file:h[0],container:s,fieldName:r,state:a,deps:y(),instance:t.instance,allowedExtensions:c,allowedMimes:p,maxSizeMB:f})},setupDrop(h){et(h,m.dragHandler)},onRemove(){var h;const v=l.querySelector('input[type="hidden"]'),x=v==null?void 0:v.value;x&&nt((h=a.resourceIndex.get(x))==null?void 0:h.file),v&&(v.value=""),C()}},g=()=>{const h=!!(a.config.pickExistingFiles&&!e.disableLibrary);return{replaceHandler:a.config.uploadFile?()=>u.click():null,libraryHandler:h?()=>{ao(a,e,s,l,r,r,async v=>{kt(s,v,a,y(),g())},t.instance).catch(v=>{console.error("Library pick failed:",v)})}:null}},y=()=>({picker:u,fileUploadHandler:m.fileUploadHandler,dragHandler:m.dragHandler,setupDrop:m.setupDrop,onRemove:m.onRemove,onAfterUpload:(h,v)=>{kt(h,v,a,y(),g())}}),C=()=>{for(xe(),s.className="file-preview-container",s.removeAttribute("style");s.firstChild;)s.removeChild(s.firstChild);const h=g().libraryHandler,v=uo(a,h!==null,m.fileUploadHandler,h,!1,Ee(e,a));s.appendChild(v),et(s,m.dragHandler)};if(d){so(d,s,r,l,a,y(),g());const h=a.resourceIndex.get(d);(i=h==null?void 0:h.type)!=null&&i.startsWith("video/")&&et(s,m.dragHandler)}else C();u.onchange=()=>{u.files&&u.files.length>0&&m.dragHandler(u.files)},l.appendChild(s),l.appendChild(u),n.appendChild(l)}function yn(e){var t,n,r;return e?typeof e=="string"?e:[...(n=(t=e.extensions)==null?void 0:t.map(o=>`.${o}`))!=null?n:[],...(r=e.mime)!=null?r:[]].join(","):""}function xn(e,t,n,r,o){var i,a;const l=t.state,u=document.createElement("div");u.className="space-y-2",u.dataset.filesWrapper=r;const s=document.createElement("input");s.type="file",s.name=r,s.multiple=!0,s.style.display="none",s.accept=yn(e.accept);const d=document.createElement("div");d.className="files-list-wrapper";const c=document.createElement("div");c.className="files-list",u.appendChild(s),u.appendChild(d),d.appendChild(c);const p=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];vt(p,l.resourceIndex),u.dataset.resourceIds=JSON.stringify(p);const f={maxCount:o,allowedExtensions:$e(e.accept),allowedMimes:Oe(e.accept),maxSize:(a=(i=e.maxSize)!=null?i:e.maxSizeMB)!=null?a:1/0},m=()=>{s.click()},g=l.config.pickExistingFiles&&!e.disableLibrary?()=>{io(l,e,u,r,p,o,y,t.instance).catch(C=>{console.error("Library pick failed:",C)})}:null;function y(){const C=oe(e,l);po({container:c,rids:p,state:l,onRemove:C?null:h=>{var v;nt((v=l.resourceIndex.get(h))==null?void 0:v.file);const x=p.indexOf(h);x>-1&&p.splice(x,1),y()},maxCount:o<1/0?o:void 0,isReadonly:C,onLibraryPick:C?null:g,element:e,onClearAll:C?void 0:()=>{p.splice(0),y()},openPicker:m})}ro(d,p,l,y,f,r,t.instance),oo(s,p,l,y,f,r,t.instance),y(),n.appendChild(u)}function ho(e,t,n,r){xn(e,t,n,r,1/0)}function bo(e,t,n,r){var o;xn(e,t,n,r,(o=e.maxCount)!=null?o:1/0)}function vo(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 go(e,t,n,r,o){var i,a;const l="minCount"in n&&(i=n.minCount)!=null?i:0,u="maxCount"in n&&(a=n.maxCount)!=null?a:1/0;n.required&&t.length===0&&o.push(`${e}: ${$("required",r)}`),t.length<l&&o.push(`${e}: ${$("minFiles",r,{min:l})}`),t.length>u&&o.push(`${e}: ${$("maxFiles",r,{max:u})}`)}function En(e,t,n,r,o){var i,a;const l="accept"in n?n.accept:void 0,u=$e(l),s=Oe(l);if(u.length===0&&s.length===0)return;const d=u.join(", "),c=s.join(", ");for(const p of t){const f=r.resourceIndex.get(p),m=(i=f==null?void 0:f.name)!=null?i:p;if(u.length>0&&!qe(m,u)){o.push(`${e}: ${$("invalidFileExtension",r,{name:m,formats:d})}`);continue}if(s.length>0&&!(f!=null&&f.inferredFromExtension)){const g=(a=f==null?void 0:f.type)!=null?a:"";Ue(g,s)||o.push(`${e}: ${$("invalidFileMime",r,{name:m,type:g,mimes:c})}`)}}}function Cn(e,t,n,r,o){var i;const a="maxSize"in n&&(i=n.maxSize)!=null?i:1/0;if(a!==1/0)for(const l of t){const u=r.resourceIndex.get(l);u&&u.size>a*1024*1024&&o.push(`${e}: ${$("fileTooLarge",r,{name:u.name,maxSize:a})}`)}}function yo(e,t,n){const{scopeRoot:r,skipValidation:o,path:i,state:a}=n,l=[],u=ye(i,t),s=vo(r,u);return o||(go(t,s,e,a,l),En(t,s,e,a,l),Cn(t,s,e,a,l)),{value:s,errors:l}}function xo(e,t,n){var r;const{scopeRoot:o,skipValidation:i,state:a}=n,l=[],u=o.querySelector(`input[name$="${t}"][type="hidden"]`),s=(r=u==null?void 0:u.value)!=null?r:"";return!i&&e.required&&s===""?(l.push(`${t}: ${$("required",a)}`),{value:null,errors:l}):(!i&&s!==""&&(En(t,[s],e,a,l),Cn(t,[s],e,a,l)),{value:s||null,errors:l})}function wn(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?yo(e,t,n):xo(e,t,n)}function Eo(e,t,n,r){const o=t.state,i=t.prefill[e.key],a=typeof i=="string"?i:"";if(a){vt([a],o.resourceIndex);const l=document.createElement("input");l.type="hidden",l.name=r,l.value=a,n.appendChild(l),wt(a,o).then(u=>{u.classList.add("fb-single-readonly-filled","fb-readonly-tile","fb-checker"),n.appendChild(u)}).catch(console.error)}else n.appendChild(Co(o))}function Co(e){xe();const t=document.createElement("div");return t.style.cssText=`
981
+ <div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${ie(k("uploadingFile",l))}</div>
982
+ </div>`;let b;try{b=await gn(o,l)}catch(h){throw m&&s!=null&&s.onAfterUpload?s.onAfterUpload(a,m):s!=null&&s.onRemove?s.onRemove():$t(a,l),h}l.resourceIndex.set(b,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:o}),m&&m!==b&&st((n=l.resourceIndex.get(m))==null?void 0:n.file);let g=p;g||(g=document.createElement("input"),g.type="hidden",g.name=i,(r=a.parentElement)==null||r.appendChild(g)),g.value=b;const w=o.type.startsWith("video/");!w&&s!=null&&s.onAfterUpload?s.onAfterUpload(a,b):!w&&s?Eo(a,b,l,s).catch(console.error):At(a,b,l,{fileName:o.name,isReadonly:!1,deps:s}).catch(console.error),c&&!l.config.readonly&&c.triggerOnChange(i,b)}function yn(e,t,n,r){const o=e.filter(m=>!je(m.name,n.allowedExtensions)),a=e.filter(m=>je(m.name,n.allowedExtensions)),i=a.filter(m=>!Xe(m.type,n.allowedMimes)),l=a.filter(m=>Xe(m.type,n.allowedMimes)),s=l.filter(m=>!ot(m,n.maxSize)),c=l.filter(m=>ot(m,n.maxSize)),d=n.maxCount===1/0?c.length:Math.max(0,n.maxCount-t),u=c.slice(0,d),f=c.length-u.length,p=[];if(o.length>0){const m=n.allowedExtensions.join(", "),b=o.map(g=>g.name).join(", ");p.push(k("invalidFileExtension",r,{name:b,formats:m}))}if(i.length>0){const m=n.allowedMimes.join(", "),b=i.map(g=>g.name).join(", ");p.push(k("invalidFileMime",r,{name:b,type:i.map(g=>g.type).join(", "),mimes:m}))}if(s.length>0){const m=s.map(b=>b.name).join(", ");p.push(k("fileTooLarge",r,{name:m,maxSize:n.maxSize}))}return f>0&&p.push(k("filesLimitExceeded",r,{skipped:f,max:n.maxCount})),{accepted:u,errorMessage:p.join(" \u2022 ")}}async function xn(e,t,n,r){var o;if(n){const i=cn(n),l=(o=i.querySelector(".fb-multi-add-tile-js"))!=null?o:i.querySelector(".fb-tile-add");l&&(l.style.display="none")}const a=[];return await Promise.allSettled(e.map(async i=>{const l=eo(i.name,r);n&&cn(n).appendChild(l);try{const s=await gn(i,r);r.resourceIndex.set(s,{name:i.name,type:i.type,size:i.size,uploadedAt:new Date,file:void 0}),t.push(s)}catch(s){const c=s instanceof Error?s:new Error(String(s)),d=c.cause,u=d instanceof Error?d:d!==void 0?new Error(String(d)):c;a.push({file:i,error:u})}finally{l.remove()}})),{failures:a}}function wn(e,t,n){if(t.length===0)return e;const r=t.map(o=>k("uploadFailed",n,{name:o.file.name,error:o.error.message})).join(" \u2022 ");return e?`${e} \u2022 ${r}`:r}function Lo(e,t,n,r,o,a,i){it(e,async l=>{var s;const{accepted:c,errorMessage:d}=yn(Array.from(l),t.length,o,n);d?Ee(e,d):Ie(e);const u=(s=e.querySelector(".files-list"))!=null?s:e,{failures:f}=await xn(c,t,u,n),p=wn(d,f,n);p?Ee(e,p):Ie(e),r(),i&&a&&!n.config.readonly&&i.triggerOnChange(a,t)})}function So(e,t,n,r,o,a,i){e.onchange=async()=>{if(!e.files)return;const l=e.closest("[data-files-wrapper]")||e.parentElement,{accepted:s,errorMessage:c}=yn(Array.from(e.files),t.length,o,n);c&&l?Ee(l,c):l&&Ie(l);const d=l==null?void 0:l.querySelector(".files-list"),{failures:u}=await xn(s,t,d!=null?d:null,n);if(l){const f=wn(c,u,n);f?Ee(l,f):Ie(l)}r(),e.value="",i&&a&&!n.config.readonly&&i.triggerOnChange(a,t)}}function Cn(e){var t,n;if(!e.accept)return;if(typeof e.accept=="string"){const l=Fe(e.accept);return l.length>0?{extensions:l}:void 0}const r=(t=e.accept.extensions)!=null?t:[],o=(n=e.accept.mime)!=null?n:[],a=r.map(l=>l.toLowerCase());if(a.length===0&&o.length===0)return;const i={};return a.length>0&&(i.extensions=a),o.length>0&&(i.mime=o),i}function En(e,t,n,r,o){if(!je(e.name,t)){const a=t.join(", ");return k("invalidFileExtension",o,{name:e.name,formats:a})}if(!Xe(e.type,n)){const a=n.join(", ");return k("invalidFileMime",o,{name:e.name,type:e.type,mimes:a})}return ln(e.size,r)?null:k("fileTooLarge",o,{name:e.name,maxSize:r})}function To(e){const t=e.dataset.resourceIds;if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n:[]}catch(n){return[]}}function kn(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 $n(e,t){return e instanceof Error&&e.message?e.message:k("pickerError",t)}async function Ao(e,t,n,r,o,a,i,l){var s;if(!e.config.pickExistingFiles)return;const c=Fe(t.accept),d=Ye(t.accept),u=(s=t.maxSize)!=null?s:1/0,f=To(n),p=a===1/0?1/0:Math.max(0,a-f.length);let m;try{m=await e.config.pickExistingFiles({fieldPath:r,mode:"multiple",accept:Cn(t),maxSizeMB:u===1/0?void 0:u,remainingSlots:p===1/0?void 0:p,selectedResourceIds:[...f]})}catch(C){Ee(n,$n(C,e));return}if(m.length===0)return;const b=new Set(f),g=new Set,w=m.filter(C=>b.has(C.resourceId)||g.has(C.resourceId)?!1:(g.add(C.resourceId),!0)).filter(C=>En(C,c,d,u,e)===null),h=a===1/0?w.length:Math.max(0,a-o.length),y=w.slice(0,h),v=w.length-y.length;if(y.length!==0){Ie(n),v>0&&Ee(n,k("filesLimitExceeded",e,{skipped:v,max:a}));for(const C of y)kn(C,e),o.push(C.resourceId);n.dataset.resourceIds=JSON.stringify(o),i(),e.config.readonly||l.triggerOnChange(r,o)}}async function Fo(e,t,n,r,o,a,i,l){var s,c;if(!e.config.pickExistingFiles)return;const d=Fe(t.accept),u=Ye(t.accept),f=(s=t.maxSize)!=null?s:1/0;let p;try{p=await e.config.pickExistingFiles({fieldPath:a,mode:"single",accept:Cn(t),maxSizeMB:f===1/0?void 0:f,selectedResourceIds:[]})}catch(h){Ee(n,$n(h,e));return}if(p.length===0)return;const m=p[0],b=En(m,d,u,f,e);if(b!==null){Ee(n,b);return}Ie(n),kn(m,e);let g=r.querySelector('input[type="hidden"]');g||(g=document.createElement("input"),g.type="hidden",g.name=o,r.appendChild(g));const w=g.value||null;w&&w!==m.resourceId&&st((c=e.resourceIndex.get(w))==null?void 0:c.file),g.value=m.resourceId,await i(m.resourceId),e.config.readonly||l.triggerOnChange(a,m.resourceId)}const Ln='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',Sn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function Mo(e,t,n,r,o,a,i){var l;lt(e,o.resourceIndex);const s=o.resourceIndex.get(e);(l=s==null?void 0:s.type)!=null&&l.startsWith("video/")?At(t,e,o,{fileName:e,isReadonly:!1,deps:a}).catch(console.error):Mt(t,e,o,a,i);const c=document.createElement("input");c.type="hidden",c.name=n,c.value=e,r.appendChild(c)}function zo(e,t,n,r,o=!1,a=""){$e();const i=document.createElement("div");i.className=`fb-wide-tile${t?" fb-file-card-row":""}${o?" fb-drag-over":""}`;const l=document.createElement("button");l.type="button",l.className="fb-wide-tile-upload fb-file-dropzone";const s=document.createElement("span");s.style.cssText="width:36px;height:36px;display:block;flex-shrink:0;",s.innerHTML=Ln,l.appendChild(s);const c=document.createElement("div");if(c.className="fb-wide-tile-label",c.style.cssText="font-size:14px;font-weight:600;",c.textContent=k(o?"dropToUpload":"clickDragText",e),l.appendChild(c),a){const d=document.createElement("div");d.style.cssText="font-size:11px;opacity:0.65;margin-top:2px;",d.textContent=a,l.appendChild(d)}if(l.onclick=d=>{d.stopPropagation(),n()},i.appendChild(l),t&&r){const d=document.createElement("button");d.type="button",d.className="fb-wide-tile-library fb-file-library-card";const u=document.createElement("span");u.className="fb-wide-tile-library-icon",u.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",u.innerHTML=Sn,d.appendChild(u);const f=document.createElement("div");f.className="fb-wide-tile-library-label",f.style.cssText="font-size:13px;font-weight:600;text-align:center;",f.textContent=k("fromLibrary",e),d.appendChild(f);const p=document.createElement("div");p.className="fb-wide-tile-library-hint",p.style.cssText="font-size:11px;opacity:0.75;text-align:center;",p.textContent=k("libraryHint",e),d.appendChild(p),d.onclick=m=>{m.stopPropagation(),r()},i.appendChild(d)}return Tn(i,{onEnter:()=>{const d=i.querySelector(".fb-wide-tile-label");d&&(d.textContent=k("dropToUpload",e))},onLeave:()=>{const d=i.querySelector(".fb-wide-tile-label");d&&(d.textContent=k("clickDragText",e))},activeClass:"fb-drag-over"}),i}function Tn(e,t){let n=0;e.addEventListener("dragover",r=>{r.preventDefault()}),e.addEventListener("dragenter",r=>{r.preventDefault(),n++,n===1&&(e.classList.add(t.activeClass),t.onEnter())}),e.addEventListener("dragleave",r=>{r.preventDefault(),n=Math.max(0,n-1),n===0&&(e.classList.remove(t.activeClass),t.onLeave())}),e.addEventListener("drop",()=>{n=0,e.classList.remove(t.activeClass),t.onLeave()})}function Mt(e,t,n,r,o){var a,i;const l=n.resourceIndex.get(t);if((a=l==null?void 0:l.type)!=null&&a.startsWith("video/")){At(e,t,n,{fileName:(i=l==null?void 0:l.name)!=null?i:"",isReadonly:!1,deps:r}).catch(console.error);return}$e();const s=document.createElement("div");s.className="fb-multi-outer fb-multi-has-files";const c=document.createElement("div");c.className="fb-multi-grid fb-tiles-wrap",s.appendChild(c);const d=An(t,n,!!r.onRemove,r.onRemove?()=>{var u;return(u=r.onRemove)==null?void 0:u.call(r)}:null,o);for(c.appendChild(d),e.className="file-preview-container",e.removeAttribute("style");e.firstChild;)e.removeChild(e.firstChild);e.appendChild(s)}function No(e,t,n,r,o=!1){const a=document.createElement("div");a.className=`fb-multi-add-tile fb-multi-add-tile-js${o?" fb-drag-over-tile":""}`;const i=document.createElement("button");i.type="button",i.className="fb-multi-add-upload fb-tile-add fb-file-dropzone";const l=document.createElement("span");l.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",l.innerHTML=Ln,i.appendChild(l);const s=document.createElement("span");if(s.className="fb-multi-add-label",s.style.cssText="font-size:11px;font-weight:600;",s.textContent=k(o?"dropToUpload":"clickDragTextMultiple",e),i.appendChild(s),i.onclick=c=>{c.stopPropagation(),n()},a.appendChild(i),t&&r){const c=document.createElement("div");c.className="fb-multi-add-divider",a.appendChild(c);const d=document.createElement("button");d.type="button",d.className="fb-multi-add-library fb-tile-add-library fb-file-library-card",d.setAttribute("aria-label",k("fromLibrary",e));const u=document.createElement("span");u.style.cssText="width:14px;height:14px;display:block;flex-shrink:0;",u.innerHTML=Sn,d.appendChild(u),d.appendChild(document.createTextNode(k("fromLibrary",e))),d.onclick=f=>{f.stopPropagation(),r()},a.appendChild(d)}return a}function An(e,t,n,r,o){var a,i,l;$e();const s=t.resourceIndex.get(e),c=document.createElement("div");c.className="fb-preview-tile fb-checker fb-tile-resource resource-pill",c.dataset.resourceId=e;const d=Lt({canRemove:n&&r!==null,removeHandler:r,state:t,resourceId:e,fileName:(a=s==null?void 0:s.name)!=null?a:"",meta:s,replaceHandler:(i=o==null?void 0:o.replaceHandler)!=null?i:null,libraryHandler:(l=o==null?void 0:o.libraryHandler)!=null?l:null});return hn(c,e,s,t,d).catch(u=>{console.error("Failed to render tile:",u)}),c}function Fn(e=!1){const t=document.createElement("div");return t.className=`fb-multi-placeholder fb-checker${e?" fb-drag-over":""}`,t}function qo(e,t,n,r,o,a){const i=document.createElement("div");i.className="fb-meta-line";const l=document.createElement("div");if(l.className="fb-meta-text",t.maxSize&&t.maxSize!==1/0){const d=document.createElement("span");d.textContent=k("hintMaxSize",e,{size:t.maxSize}),l.appendChild(d),l.appendChild(Mn())}const s=Fe(t.accept);if(s.length>0){const d=document.createElement("span");d.className="fb-meta-mono",d.textContent=s.map(u=>u.toUpperCase()).join(", "),l.appendChild(d),l.appendChild(Mn())}const c=document.createElement("span");if(r<1/0)c.textContent=k("fileCountWithMax",e,{count:n,max:r});else{const d=n===1?"fileCountSingle":"fileCountPlural";c.textContent=k(d,e,{count:n})}if(l.appendChild(c),i.appendChild(l),o&&n>1){const d=document.createElement("button");d.type="button",d.className="fb-clear-all-btn",d.textContent=k("clearAll",e),d.onclick=u=>{u.stopPropagation(),window.confirm(k("clearAll",e)+"?")&&a()},i.appendChild(d)}return i}function Mn(){const e=document.createElement("span");return e.className="fb-meta-dot",e}const zt=new WeakMap;function Io(e){var t;const{container:n,rids:r,state:o,onRemove:a,maxCount:i,isReadonly:l=!1,onLibraryPick:s,element:c,onClearAll:d,openPicker:u}=e;$e();const f=n.closest("[data-files-wrapper]");f&&(f.dataset.resourceIds=JSON.stringify(r!=null?r:[]));const p=zt.get(n);for(p&&(p.disconnect(),zt.delete(n));n.firstChild;)n.removeChild(n.firstChild);const m=r!=null?r:[],b=i!=null?i:1/0,g=b!==1/0&&m.length>=b,w=!l&&typeof s=="function",h=u!=null?u:(()=>{var x;const L=(x=n.closest("[data-files-wrapper]"))==null?void 0:x.querySelector('input[type="file"]');L&&L.click()});if(l){if(m.length===0){const x=document.createElement("div");x.className="fb-tile-empty-text",x.textContent=k("noFilesSelected",o),n.appendChild(x)}else{const x=document.createElement("div");x.className="fb-multi-readonly-grid",n.appendChild(x);for(const L of m){const q=o.resourceIndex.get(L),I=document.createElement("div");I.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",I.dataset.resourceId=L;const W=Lt({canRemove:!1,removeHandler:null,state:o,resourceId:L,fileName:(t=q==null?void 0:q.name)!=null?t:"",meta:q});hn(I,L,q,o,W).catch(console.error),I.onclick=async()=>{var V;let J=null;o.config.getDownloadUrl?J=o.config.getDownloadUrl(L):o.config.getThumbnail?J=await o.config.getThumbnail(L):(q==null?void 0:q.file)instanceof File&&(J=URL.createObjectURL(q.file)),J?window.open(J,"_blank"):o.config.downloadFile&&o.config.downloadFile(L,(V=q==null?void 0:q.name)!=null?V:"")},x.appendChild(I)}}return}const y=document.createElement("div");y.className=`fb-multi-outer${m.length>0?" fb-multi-has-files":""}`;const v=document.createElement("div");v.className="fb-multi-grid fb-tiles-wrap",y.appendChild(v),n.appendChild(y);for(let x=0;x<m.length;x++){const L=m[x],q=An(L,o,a!==null,a?()=>a(L):null);v.appendChild(q)}if(!g){const x=No(o,w,h,s!=null?s:null);v.appendChild(x)}const C=m.length+(g?0:1),E=()=>{const x=getComputedStyle(v).gridTemplateColumns,L=x?x.split(" ").filter(Boolean).length:0;if(!L)return;const q=C%L,I=q===0?0:L-q,W=b===1/0?I:Math.max(0,b-C),V=Math.min(I,W),J=v.querySelectorAll(".fb-multi-placeholder");if(J.length>V)for(let Q=J.length-1;Q>=V;Q--)J[Q].remove();else if(J.length<V)for(let Q=J.length;Q<V;Q++)v.appendChild(Fn())};if((b===1/0||b>C)&&v.appendChild(Fn()),requestAnimationFrame(E),typeof ResizeObserver!="undefined"){const x=new ResizeObserver(()=>E());x.observe(v),zt.set(n,x)}if(Tn(y,{activeClass:"fb-drag-over",onEnter:()=>{v.querySelectorAll(".fb-multi-placeholder").forEach(L=>{L.classList.add("fb-drag-over")});const x=v.querySelector(".fb-multi-add-tile-js");if(x){x.classList.add("fb-drag-over-tile");const L=x.querySelector(".fb-multi-add-label");L&&(L.textContent=k("dropToUpload",o))}},onLeave:()=>{v.querySelectorAll(".fb-multi-placeholder").forEach(L=>{L.classList.remove("fb-drag-over")});const x=v.querySelector(".fb-multi-add-tile-js");if(x){x.classList.remove("fb-drag-over-tile");const L=x.querySelector(".fb-multi-add-label");L&&(L.textContent=k("clickDragTextMultiple",o))}}}),c){const x=qo(o,c,m.length,b,!!d,d!=null?d:(()=>{}));n.appendChild(x)}}function Ro(e,t,n,r){var o,a;const i=t.state,l=document.createElement("div");l.className="space-y-2",l.dataset.filesWrapper=r;const s=document.createElement("input");s.type="file",s.name=r,s.style.display="none",s.accept=zn(e.accept);const c=document.createElement("div");c.className="file-preview-container";const d=t.prefill[e.key],u=Fe(e.accept),f=Ye(e.accept),p=(o=e.maxSize)!=null?o:1/0,m={fileUploadHandler(){s.click()},dragHandler(h){h.length>0&&$o({file:h[0],container:c,fieldName:r,state:i,deps:g(),instance:t.instance,allowedExtensions:u,allowedMimes:f,maxSizeMB:p})},setupDrop(h){it(h,m.dragHandler)},onRemove(){var h;const y=l.querySelector('input[type="hidden"]'),v=y==null?void 0:y.value;v&&st((h=i.resourceIndex.get(v))==null?void 0:h.file),y&&(y.value=""),w()}},b=()=>{const h=!!(i.config.pickExistingFiles&&!e.disableLibrary);return{replaceHandler:i.config.uploadFile?()=>s.click():null,libraryHandler:h?()=>{Fo(i,e,c,l,r,r,async y=>{Mt(c,y,i,g(),b())},t.instance).catch(y=>{console.error("Library pick failed:",y)})}:null}},g=()=>({picker:s,fileUploadHandler:m.fileUploadHandler,dragHandler:m.dragHandler,setupDrop:m.setupDrop,onRemove:m.onRemove,onAfterUpload:(h,y)=>{Mt(h,y,i,g(),b())}}),w=()=>{for($e(),c.className="file-preview-container",c.removeAttribute("style");c.firstChild;)c.removeChild(c.firstChild);const h=b().libraryHandler,y=zo(i,h!==null,m.fileUploadHandler,h,!1,Le(e,i));c.appendChild(y),it(c,m.dragHandler)};if(d){Mo(d,c,r,l,i,g(),b());const h=i.resourceIndex.get(d);(a=h==null?void 0:h.type)!=null&&a.startsWith("video/")&&it(c,m.dragHandler)}else w();s.onchange=()=>{s.files&&s.files.length>0&&m.dragHandler(s.files)},l.appendChild(c),l.appendChild(s),n.appendChild(l)}function zn(e){var t,n,r;return e?typeof e=="string"?e:[...(n=(t=e.extensions)==null?void 0:t.map(o=>`.${o}`))!=null?n:[],...(r=e.mime)!=null?r:[]].join(","):""}function Nn(e,t,n,r,o){var a,i;const l=t.state,s=document.createElement("div");s.className="space-y-2",s.dataset.filesWrapper=r;const c=document.createElement("input");c.type="file",c.name=r,c.multiple=!0,c.style.display="none",c.accept=zn(e.accept);const d=document.createElement("div");d.className="files-list-wrapper";const u=document.createElement("div");u.className="files-list",s.appendChild(c),s.appendChild(d),d.appendChild(u);const f=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];kt(f,l.resourceIndex),s.dataset.resourceIds=JSON.stringify(f);const p={maxCount:o,allowedExtensions:Fe(e.accept),allowedMimes:Ye(e.accept),maxSize:(i=(a=e.maxSize)!=null?a:e.maxSizeMB)!=null?i:1/0},m=()=>{c.click()},b=l.config.pickExistingFiles&&!e.disableLibrary?()=>{Ao(l,e,s,r,f,o,g,t.instance).catch(w=>{console.error("Library pick failed:",w)})}:null;function g(){const w=oe(e,l);Io({container:u,rids:f,state:l,onRemove:w?null:h=>{var y;st((y=l.resourceIndex.get(h))==null?void 0:y.file);const v=f.indexOf(h);v>-1&&f.splice(v,1),g()},maxCount:o<1/0?o:void 0,isReadonly:w,onLibraryPick:w?null:b,element:e,onClearAll:w?void 0:()=>{f.splice(0),g()},openPicker:m})}Lo(d,f,l,g,p,r,t.instance),So(c,f,l,g,p,r,t.instance),g(),n.appendChild(s)}function Ho(e,t,n,r){Nn(e,t,n,r,1/0)}function Bo(e,t,n,r){var o;Nn(e,t,n,r,(o=e.maxCount)!=null?o:1/0)}function Do(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 jo(e,t,n,r,o){var a,i;const l="minCount"in n&&(a=n.minCount)!=null?a:0,s="maxCount"in n&&(i=n.maxCount)!=null?i:1/0;n.required&&t.length===0&&o.push(`${e}: ${k("required",r)}`),t.length<l&&o.push(`${e}: ${k("minFiles",r,{min:l})}`),t.length>s&&o.push(`${e}: ${k("maxFiles",r,{max:s})}`)}function qn(e,t,n,r,o){var a,i;const l="accept"in n?n.accept:void 0,s=Fe(l),c=Ye(l);if(s.length===0&&c.length===0)return;const d=s.join(", "),u=c.join(", ");for(const f of t){const p=r.resourceIndex.get(f),m=(a=p==null?void 0:p.name)!=null?a:f;if(s.length>0&&!je(m,s)){o.push(`${e}: ${k("invalidFileExtension",r,{name:m,formats:d})}`);continue}if(c.length>0&&!(p!=null&&p.inferredFromExtension)){const b=(i=p==null?void 0:p.type)!=null?i:"";Xe(b,c)||o.push(`${e}: ${k("invalidFileMime",r,{name:m,type:b,mimes:u})}`)}}}function In(e,t,n,r,o){var a;const i="maxSize"in n&&(a=n.maxSize)!=null?a:1/0;if(i!==1/0)for(const l of t){const s=r.resourceIndex.get(l);s&&s.size>i*1024*1024&&o.push(`${e}: ${k("fileTooLarge",r,{name:s.name,maxSize:i})}`)}}function Oo(e,t,n){const{scopeRoot:r,skipValidation:o,path:a,state:i}=n,l=[],s=ke(a,t),c=Do(r,s);return o||(jo(t,c,e,i,l),qn(t,c,e,i,l),In(t,c,e,i,l)),{value:c,errors:l}}function Uo(e,t,n){var r;const{scopeRoot:o,skipValidation:a,state:i}=n,l=[],s=o.querySelector(`input[name$="${t}"][type="hidden"]`),c=(r=s==null?void 0:s.value)!=null?r:"";return!a&&e.required&&c===""?(l.push(`${t}: ${k("required",i)}`),{value:null,errors:l}):(!a&&c!==""&&(qn(t,[c],e,i,l),In(t,[c],e,i,l)),{value:c||null,errors:l})}function Rn(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?Oo(e,t,n):Uo(e,t,n)}function Po(e,t,n,r){const o=t.state,a=t.prefill[e.key],i=typeof a=="string"?a:"";if(i){kt([i],o.resourceIndex);const l=document.createElement("input");l.type="hidden",l.name=r,l.value=i,n.appendChild(l),Ft(i,o).then(s=>{s.classList.add("fb-single-readonly-filled","fb-readonly-tile","fb-checker"),n.appendChild(s)}).catch(console.error)}else n.appendChild(Wo(o))}function Wo(e){$e();const t=document.createElement("div");return t.style.cssText=`
691
983
  height: 220px;
692
984
  display:flex;
693
985
  align-items:center;
@@ -695,7 +987,7 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
695
987
  background: repeating-linear-gradient(45deg, #fafafa 0 6px, #f3f4f6 6px 12px);
696
988
  border-radius:0.75rem;
697
989
  border:1px solid #e2e8f0;
698
- `,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${le($("noFileSelected",e))}</div>`,t}function kn(e,t,n,r,o){vt(e,t.resourceIndex),xe();const i=document.createElement("div");if(i.dataset.filesWrapper=r,i.dataset.resourceIds=JSON.stringify(e),n.appendChild(i),e.length===0){const u=document.createElement("div");u.className="fb-tile-empty-text",u.textContent=$("noFilesSelected",t),i.appendChild(u);return}const a=document.createElement("div");a.className="fb-multi-readonly-grid",i.appendChild(a);const l=e.map(()=>{const u=document.createElement("div");return u.className="fb-readonly-tile fb-checker fb-tile",a.appendChild(u),u});for(let u=0;u<e.length;u++){const s=e[u],d=l[u],c=t.resourceIndex.get(s);wt(s,t,c==null?void 0:c.name).then(p=>{p.classList.add("fb-readonly-tile","fb-checker","fb-tile-resource"),p.dataset.resourceId=s,d.replaceWith(p)}).catch(()=>{const p=document.createElement("div");p.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",p.dataset.resourceId=s,d.replaceWith(p)})}}function wo(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];kn(i,t.state,n,r)}function ko(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];kn(i,t.state,n,r)}function $o(e,t,n,r){oe(e,t.state,t)?Eo(e,t,n,r):mo(e,t,n,r)}function Lo(e,t,n,r){oe(e,t.state,t)?wo(e,t,n,r):ho(e,t,n,r)}function So(e,t,n,r){oe(e,t.state,t)?ko(e,t,n,r):bo(e,t,n,r)}function $n(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(l=>{l&&typeof l=="string"&&Qe(l,i.resourceIndex)});const a=o.querySelector(`[data-files-wrapper="${t}"]`);a?a.dataset.resourceIds=JSON.stringify(n):console.warn(`updateFileField: [data-files-wrapper="${t}"] not found in DOM; data-resource-ids not updated`)}else{const a=o.querySelector(`input[name="${t}"][type="hidden"]`);if(!a){console.warn(`updateFileField: Hidden input not found for file field "${t}"`);return}a.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 Ie(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 Ln(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 Sn(e){const t=document.createElement("div");t.className="flex items-center gap-2";const n=Ie(e),r=document.createElement("div");r.style.cssText=`
990
+ `,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${ie(k("noFileSelected",e))}</div>`,t}function Hn(e,t,n,r,o){kt(e,t.resourceIndex),$e();const a=document.createElement("div");if(a.dataset.filesWrapper=r,a.dataset.resourceIds=JSON.stringify(e),n.appendChild(a),e.length===0){const s=document.createElement("div");s.className="fb-tile-empty-text",s.textContent=k("noFilesSelected",t),a.appendChild(s);return}const i=document.createElement("div");i.className="fb-multi-readonly-grid",a.appendChild(i);const l=e.map(()=>{const s=document.createElement("div");return s.className="fb-readonly-tile fb-checker fb-tile",i.appendChild(s),s});for(let s=0;s<e.length;s++){const c=e[s],d=l[s],u=t.resourceIndex.get(c);Ft(c,t,u==null?void 0:u.name).then(f=>{f.classList.add("fb-readonly-tile","fb-checker","fb-tile-resource"),f.dataset.resourceId=c,d.replaceWith(f)}).catch(()=>{const f=document.createElement("div");f.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",f.dataset.resourceId=c,d.replaceWith(f)})}}function Vo(e,t,n,r){const o=t.prefill[e.key],a=Array.isArray(o)?o:[];Hn(a,t.state,n,r)}function _o(e,t,n,r){const o=t.prefill[e.key],a=Array.isArray(o)?o:[];Hn(a,t.state,n,r)}function Ko(e,t,n,r){oe(e,t.state,t)?Po(e,t,n,r):Ro(e,t,n,r)}function Jo(e,t,n,r){oe(e,t.state,t)?Vo(e,t,n,r):Ho(e,t,n,r)}function Yo(e,t,n,r){oe(e,t.state,t)?_o(e,t,n,r):Bo(e,t,n,r)}function Bn(e,t,n,r){const{scopeRoot:o,state:a}=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(l=>{l&&typeof l=="string"&&lt(l,a.resourceIndex)});const i=o.querySelector(`[data-files-wrapper="${t}"]`);i?i.dataset.resourceIds=JSON.stringify(n):console.warn(`updateFileField: [data-files-wrapper="${t}"] not found in DOM; data-resource-ids not updated`)}else{const i=o.querySelector(`input[name="${t}"][type="hidden"]`);if(!i){console.warn(`updateFileField: Hidden input not found for file field "${t}"`);return}i.value=n!=null?String(n):"",n&&typeof n=="string"&&(lt(n,a.resourceIndex),console.info(`updateFileField: File field "${t}" updated. Preview update requires re-render.`))}}function Oe(e){return e?e.toUpperCase():"#000000"}function Nt(e){return/^#[0-9A-F]{6}$/i.test(e)||/^#[0-9A-F]{3}$/i.test(e)}function Dn(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 jn(e){const t=document.createElement("div");t.className="flex items-center gap-2";const n=Oe(e),r=document.createElement("div");r.style.cssText=`
699
991
  width: 32px;
700
992
  height: 32px;
701
993
  border-radius: var(--fb-border-radius);
@@ -705,11 +997,11 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
705
997
  font-size: var(--fb-font-size);
706
998
  color: var(--fb-text-color);
707
999
  font-family: var(--fb-font-family-mono, monospace);
708
- `,o.textContent=n,t.appendChild(r),t.appendChild(o),t}function Tn(e,t,n){const r=Ie(e),o=document.createElement("div");o.className="colour-picker-wrapper",o.style.cssText=`
1000
+ `,o.textContent=n,t.appendChild(r),t.appendChild(o),t}function On(e,t,n){const r=Oe(e),o=document.createElement("div");o.className="colour-picker-wrapper",o.style.cssText=`
709
1001
  display: flex;
710
1002
  align-items: center;
711
1003
  gap: 8px;
712
- `;const i=document.createElement("div");i.className="colour-swatch",i.style.cssText=`
1004
+ `;const a=document.createElement("div");a.className="colour-swatch",a.style.cssText=`
713
1005
  width: 40px;
714
1006
  height: 40px;
715
1007
  border-radius: var(--fb-border-radius);
@@ -718,7 +1010,7 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
718
1010
  cursor: pointer;
719
1011
  transition: border-color var(--fb-transition-duration) ease-in-out;
720
1012
  flex-shrink: 0;
721
- `;const a=document.createElement("input");a.type="text",a.className="colour-hex-input",a.name=t,a.value=r,a.placeholder="#000000",a.style.cssText=`
1013
+ `;const i=document.createElement("input");i.type="text",i.className="colour-hex-input",i.name=t,i.value=r,i.placeholder="#000000",i.style.cssText=`
722
1014
  width: 100px;
723
1015
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
724
1016
  border: var(--fb-border-width) solid var(--fb-border-color);
@@ -732,45 +1024,39 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
732
1024
  position: absolute;
733
1025
  opacity: 0;
734
1026
  pointer-events: none;
735
- `,a.addEventListener("input",()=>{const u=a.value.trim();if(Lt(u)){const s=Ln(u);i.style.backgroundColor=s,l.value=s.toLowerCase(),a.classList.remove("invalid"),n.instance&&n.instance.triggerOnChange(t,s)}else a.classList.add("invalid")}),a.addEventListener("blur",()=>{const u=a.value.trim();if(Lt(u)){const s=Ln(u);a.value=s,i.style.backgroundColor=s,l.value=s.toLowerCase(),a.classList.remove("invalid")}}),l.addEventListener("change",()=>{const u=Ie(l.value);a.value=u,i.style.backgroundColor=u,n.instance&&n.instance.triggerOnChange(t,u)}),i.addEventListener("click",()=>{l.click()}),i.addEventListener("mouseenter",()=>{i.style.borderColor="var(--fb-border-hover-color)"}),i.addEventListener("mouseleave",()=>{i.style.borderColor="var(--fb-border-color)"}),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)")}),o.appendChild(i),o.appendChild(a),o.appendChild(l),o}function To(e,t,n,r){const o=t.state,i=oe(e,o,t),a=t.prefill[e.key]||e.default||"#000000";if(i){const l=Sn(a);n.appendChild(l)}else{const l=Tn(a,r,t);n.appendChild(l)}if(!i){const l=document.createElement("p");l.className="mt-1",l.style.cssText=`
1027
+ `,i.addEventListener("input",()=>{const s=i.value.trim();if(Nt(s)){const c=Dn(s);a.style.backgroundColor=c,l.value=c.toLowerCase(),i.classList.remove("invalid"),n.instance&&n.instance.triggerOnChange(t,c)}else i.classList.add("invalid")}),i.addEventListener("blur",()=>{const s=i.value.trim();if(Nt(s)){const c=Dn(s);i.value=c,a.style.backgroundColor=c,l.value=c.toLowerCase(),i.classList.remove("invalid")}}),l.addEventListener("change",()=>{const s=Oe(l.value);i.value=s,a.style.backgroundColor=s,n.instance&&n.instance.triggerOnChange(t,s)}),a.addEventListener("click",()=>{l.click()}),a.addEventListener("mouseenter",()=>{a.style.borderColor="var(--fb-border-hover-color)"}),a.addEventListener("mouseleave",()=>{a.style.borderColor="var(--fb-border-color)"}),i.addEventListener("focus",()=>{i.style.borderColor="var(--fb-border-focus-color)",i.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",i.style.outlineOffset="0"}),i.addEventListener("blur",()=>{i.style.borderColor="var(--fb-border-color)",i.style.outline="none"}),i.addEventListener("mouseenter",()=>{document.activeElement!==i&&(i.style.borderColor="var(--fb-border-hover-color)")}),i.addEventListener("mouseleave",()=>{document.activeElement!==i&&(i.style.borderColor="var(--fb-border-color)")}),o.appendChild(a),o.appendChild(i),o.appendChild(l),o}function Xo(e,t,n,r){const o=t.state,a=oe(e,o,t),i=t.prefill[e.key]||e.default||"#000000";if(a){const l=jn(i);n.appendChild(l)}else{const l=On(i,r,t);n.appendChild(l)}if(!a){const l=document.createElement("p");l.className="mt-1",l.style.cssText=`
736
1028
  font-size: var(--fb-font-size-small);
737
1029
  color: var(--fb-text-secondary-color);
738
- `,l.textContent=Ee(e,o),n.appendChild(l)}}function Ao(e,t,n,r){var o,i;const a=t.state,l=oe(e,a,t),u=t.prefill[e.key]||[],s=Array.isArray(u)?[...u]:[],d=(o=e.minCount)!=null?o:1,c=(i=e.maxCount)!=null?i:1/0;for(;s.length<d;)s.push(e.default||"#000000");const p=document.createElement("div");p.className="space-y-2",n.appendChild(p);function f(){p.querySelectorAll(".multiple-colour-item").forEach((v,x)=>{const E=v.querySelector("input");E&&(E.name=`${r}[${x}]`)})}function m(v="#000000",x=-1){const E=document.createElement("div");if(E.className="multiple-colour-item flex items-center gap-2",l){const k=Sn(v);for(;k.firstChild;)E.appendChild(k.firstChild)}else{const k=`${r}[${p.children.length}]`,b=Tn(v,k,t);b.style.flex="1",E.appendChild(b)}return x===-1?p.appendChild(E):p.insertBefore(E,p.children[x]),f(),E}function g(){if(l)return;const v=p.querySelectorAll(".multiple-colour-item"),x=v.length;v.forEach(E=>{let k=E.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=`
1030
+ `,l.textContent=Le(e,o),n.appendChild(l)}}function Go(e,t,n,r){var o,a;const i=t.state,l=oe(e,i,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],d=(o=e.minCount)!=null?o:1,u=(a=e.maxCount)!=null?a:1/0;for(;c.length<d;)c.push(e.default||"#000000");const f=document.createElement("div");f.className="space-y-2",n.appendChild(f);function p(){f.querySelectorAll(".multiple-colour-item").forEach((h,y)=>{const v=h.querySelector("input");v&&(v.name=`${r}[${y}]`)})}function m(h="#000000",y=-1){const v=document.createElement("div");if(v.className="multiple-colour-item flex items-center gap-2",l){const C=jn(h);for(;C.firstChild;)v.appendChild(C.firstChild)}else{const C=`${r}[${f.children.length}]`,E=On(h,C,t);E.style.flex="1",v.appendChild(E)}return y===-1?f.appendChild(v):f.insertBefore(v,f.children[y]),p(),v}function b(){if(l)return;const h=f.querySelectorAll(".multiple-colour-item"),y=h.length;h.forEach(v=>{let C=v.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=`
739
1031
  color: var(--fb-error-color);
740
1032
  background-color: transparent;
741
1033
  transition: background-color var(--fb-transition-duration);
742
- `,k.innerHTML="\u2715",k.addEventListener("mouseenter",()=>{k.style.backgroundColor="var(--fb-background-hover-color)"}),k.addEventListener("mouseleave",()=>{k.style.backgroundColor="transparent"}),k.onclick=()=>{const w=Array.from(p.children).indexOf(E);p.children.length>d&&(s.splice(w,1),E.remove(),f(),h(),g())},E.appendChild(k));const b=x<=d;k.disabled=b,k.style.opacity=b?"0.5":"1",k.style.pointerEvents=b?"none":"auto"})}let y=null,C=null;if(!l){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const v=document.createElement("button");v.type="button",v.className="add-colour-btn px-3 py-1 rounded",v.style.cssText=`
743
- color: var(--fb-primary-color);
744
- border: var(--fb-border-width) solid var(--fb-primary-color);
745
- background-color: transparent;
746
- font-size: var(--fb-font-size);
747
- transition: all var(--fb-transition-duration);
748
- `,v.textContent="+",v.addEventListener("mouseenter",()=>{v.style.backgroundColor="var(--fb-background-hover-color)"}),v.addEventListener("mouseleave",()=>{v.style.backgroundColor="transparent"}),v.onclick=()=>{const x=e.default||"#000000";s.push(x),m(x),h(),g()},C=document.createElement("span"),C.className="text-sm text-gray-500",y.appendChild(v),y.appendChild(C),n.appendChild(y)}function h(){if(!y||!C)return;const v=y.querySelector(".add-colour-btn");if(v){const x=s.length>=c;v.disabled=x,v.style.opacity=x?"0.5":"1",v.style.pointerEvents=x?"none":"auto"}C.textContent=`${s.length}/${c===1/0?"\u221E":c}`}if(s.forEach(v=>m(v)),h(),g(),!l){const v=document.createElement("p");v.className="mt-1",v.style.cssText=`
1034
+ `,C.innerHTML="\u2715",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{const x=Array.from(f.children).indexOf(v);f.children.length>d&&(c.splice(x,1),v.remove(),p(),w(),b())},v.appendChild(C));const E=y<=d;C.disabled=E,C.style.opacity=E?"0.5":"1",C.style.pointerEvents=E?"none":"auto"})}let g=null;if(!l){const h=Ae("colour",()=>{const y=e.default||"#000000";c.push(y),m(y),w(),b()},{label:e.addLabel});g=h.update,Se(n,h.counter),n.appendChild(h.row)}function w(){g&&g(c.length,u)}if(c.forEach(h=>m(h)),w(),b(),!l){const h=document.createElement("p");h.className="mt-1",h.style.cssText=`
749
1035
  font-size: var(--fb-font-size-small);
750
1036
  color: var(--fb-text-secondary-color);
751
- `,v.textContent=Ee(e,a),n.appendChild(v)}}function Fo(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:u}=n,s=(c,p)=>{var f,m;if(!c)return;const g=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let y=document.getElementById(g);p?(c.classList.add("invalid"),c.title=p,y||(y=document.createElement("div"),y.id=g,y.className="error-message",y.style.cssText=`
1037
+ `,h.textContent=Le(e,i),n.appendChild(h)}}function Zo(e,t,n){var r,o,a;const i=[],{scopeRoot:l,skipValidation:s}=n,c=(u,f)=>{var p,m;if(!u)return;const b=`error-${u.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(b);f?(u.classList.add("invalid"),u.title=f,g||(g=document.createElement("div"),g.id=b,g.className="error-message",g.style.cssText=`
752
1038
  color: var(--fb-error-color);
753
1039
  font-size: var(--fb-font-size-small);
754
1040
  margin-top: 0.25rem;
755
- `,c.nextSibling?(f=c.parentNode)==null||f.insertBefore(y,c.nextSibling):(m=c.parentNode)==null||m.appendChild(y)),y.textContent=p,y.style.display="block"):(c.classList.remove("invalid"),c.title="",y&&y.remove())},d=(c,p,f)=>{const{state:m}=n;if(!p){if(!u&&e.required){const y=$("required",m);return a.push(`${f}: ${y}`),s(c,y),""}return s(c,null),""}const g=Ie(p);if(!u&&!Lt(g)){const y=$("invalidHexColour",m);return a.push(`${f}: ${y}`),s(c,y),p}return s(c,null),g};if(e.multiple){const c=l.querySelectorAll(`[name^="${t}["].colour-hex-input`),p=[];if(c.forEach((f,m)=>{var g;const y=(g=f==null?void 0:f.value)!=null?g:"",C=d(f,y,`${t}[${m}]`);p.push(C)}),!u){const{state:f}=n,m=(r=e.minCount)!=null?r:1,g=(o=e.maxCount)!=null?o:1/0,y=p.filter(C=>C!=="");e.required&&y.length===0&&a.push(`${t}: ${$("required",f)}`),y.length<m&&a.push(`${t}: ${$("minItems",f,{min:m})}`),y.length>g&&a.push(`${t}: ${$("maxItems",f,{max:g})}`)}return{value:p,errors:a}}else{const c=l.querySelector(`[name="${t}"].colour-hex-input`),p=(i=c==null?void 0:c.value)!=null?i:"";if(!u&&e.required&&p===""){const f=$("required",n.state);return a.push(`${t}: ${f}`),s(c,f),{value:"",errors:a}}return{value:d(c,p,t),errors:a}}}function Mo(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((a,l)=>{if(l<n.length){const u=Ie(n[l]);a.value=u,a.classList.remove("invalid"),a.title="";const s=a.closest(".colour-picker-wrapper");if(s){const d=s.querySelector(".colour-swatch"),c=s.querySelector(".colour-picker-hidden");d&&(d.style.backgroundColor=u),c&&(c.value=u.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 a=Ie(n);i.value=a,i.classList.remove("invalid"),i.title="";const l=i.closest(".colour-picker-wrapper");if(l){const u=l.querySelector(".colour-swatch"),s=l.querySelector(".colour-picker-hidden");u&&(u.style.backgroundColor=a),s&&(s.value=a.toLowerCase())}}}}function An(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 ot(e,t){return Math.round(e/t)*t}function Fn(e,t,n,r,o){var i;const a=document.createElement("div");a.className="slider-container";const l=document.createElement("div");l.className="flex items-start gap-3";const u=document.createElement("div");u.className="flex-1";const s=document.createElement("input");s.type="range",s.name=t,s.className="slider-input w-full",s.disabled=o;const d=n.scale||"linear",c=n.min,p=n.max,f=(i=n.step)!=null?i:1;if(d==="exponential"){if(c<=0)throw new Error(`Slider "${n.key}": exponential scale requires min > 0 (got ${c})`);s.min="0",s.max="1000",s.step="1";const h=St(e,c,p);s.value=(h*1e3).toString()}else s.min=c.toString(),s.max=p.toString(),s.step=f.toString(),s.value=e.toString();s.style.cssText=`
1041
+ `,u.nextSibling?(p=u.parentNode)==null||p.insertBefore(g,u.nextSibling):(m=u.parentNode)==null||m.appendChild(g)),g.textContent=f,g.style.display="block"):(u.classList.remove("invalid"),u.title="",g&&g.remove())},d=(u,f,p)=>{const{state:m}=n;if(!f){if(!s&&e.required){const g=k("required",m);return i.push(`${p}: ${g}`),c(u,g),""}return c(u,null),""}const b=Oe(f);if(!s&&!Nt(b)){const g=k("invalidHexColour",m);return i.push(`${p}: ${g}`),c(u,g),f}return c(u,null),b};if(e.multiple){const u=l.querySelectorAll(`[name^="${t}\\["].colour-hex-input`),f=[];if(u.forEach((p,m)=>{var b;const g=(b=p==null?void 0:p.value)!=null?b:"",w=d(p,g,`${t}[${m}]`);f.push(w)}),!s){const{state:p}=n,m=(r=e.minCount)!=null?r:1,b=(o=e.maxCount)!=null?o:1/0,g=f.filter(w=>w!=="");e.required&&g.length===0&&i.push(`${t}: ${k("required",p)}`),g.length<m&&i.push(`${t}: ${k("minItems",p,{min:m})}`),g.length>b&&i.push(`${t}: ${k("maxItems",p,{max:b})}`)}return{value:f,errors:i}}else{const u=l.querySelector(`[name="${t}"].colour-hex-input`),f=(a=u==null?void 0:u.value)!=null?a:"";if(!s&&e.required&&f===""){const p=k("required",n.state);return i.push(`${t}: ${p}`),c(u,p),{value:"",errors:i}}return{value:d(u,f,t),errors:i}}}function Qo(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 a=o.querySelectorAll(`[name^="${t}\\["].colour-hex-input`);a.forEach((i,l)=>{if(l<n.length){const s=Oe(n[l]);i.value=s,i.classList.remove("invalid"),i.title="",ye(i);const c=i.closest(".colour-picker-wrapper");if(c){const d=c.querySelector(".colour-swatch"),u=c.querySelector(".colour-picker-hidden");d&&(d.style.backgroundColor=s),u&&(u.value=s.toLowerCase())}}}),n.length!==a.length&&console.warn(`updateColourField: Multiple field "${t}" has ${a.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=o.querySelector(`[name="${t}"].colour-hex-input`);if(a){const i=Oe(n);a.value=i,a.classList.remove("invalid"),a.title="",ye(a);const l=a.closest(".colour-picker-wrapper");if(l){const s=l.querySelector(".colour-swatch"),c=l.querySelector(".colour-picker-hidden");s&&(s.style.backgroundColor=i),c&&(c.value=i.toLowerCase())}}}}function Un(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 qt(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 ut(e,t){return Math.round(e/t)*t}function Pn(e,t,n,r,o){var a;const i=document.createElement("div");i.className="slider-container";const l=document.createElement("div");l.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 d=n.scale||"linear",u=n.min,f=n.max,p=(a=n.step)!=null?a:1;if(d==="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 h=qt(e,u,f);c.value=(h*1e3).toString()}else c.min=u.toString(),c.max=f.toString(),c.step=p.toString(),c.value=e.toString();c.style.cssText=`
756
1042
  height: 6px;
757
1043
  border-radius: 3px;
758
1044
  background: linear-gradient(
759
1045
  to right,
760
1046
  var(--fb-primary-color) 0%,
761
- var(--fb-primary-color) ${(e-c)/(p-c)*100}%,
762
- var(--fb-border-color) ${(e-c)/(p-c)*100}%,
1047
+ var(--fb-primary-color) ${(e-u)/(f-u)*100}%,
1048
+ var(--fb-border-color) ${(e-u)/(f-u)*100}%,
763
1049
  var(--fb-border-color) 100%
764
1050
  );
765
1051
  outline: none;
766
1052
  transition: background 0.1s ease-in-out;
767
1053
  cursor: ${o?"not-allowed":"pointer"};
768
1054
  opacity: ${o?"0.6":"1"};
769
- `,u.appendChild(s);const m=document.createElement("div");m.className="flex justify-between",m.style.cssText=`
1055
+ `,s.appendChild(c);const m=document.createElement("div");m.className="flex justify-between",m.style.cssText=`
770
1056
  font-size: var(--fb-font-size-small);
771
1057
  color: var(--fb-text-secondary-color);
772
1058
  margin-top: 4px;
773
- `;const g=document.createElement("span");g.textContent=c.toString();const y=document.createElement("span");y.textContent=p.toString(),m.appendChild(g),m.appendChild(y),u.appendChild(m);const C=document.createElement("span");if(C.className="slider-value",C.style.cssText=`
1059
+ `;const b=document.createElement("span");b.textContent=u.toString();const g=document.createElement("span");g.textContent=f.toString(),m.appendChild(b),m.appendChild(g),s.appendChild(m);const w=document.createElement("span");if(w.className="slider-value",w.style.cssText=`
774
1060
  min-width: 60px;
775
1061
  text-align: right;
776
1062
  font-size: var(--fb-font-size);
@@ -778,64 +1064,51 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
778
1064
  font-family: var(--fb-font-family-mono, monospace);
779
1065
  font-weight: 500;
780
1066
  padding-top: 2px;
781
- `,C.textContent=e.toFixed(f<1?2:0),l.appendChild(u),l.appendChild(C),a.appendChild(l),!o){const h=()=>{let v;if(d==="exponential"){const E=parseFloat(s.value)/1e3;v=An(E,c,p),v=ot(v,f),v=Math.max(c,Math.min(p,v))}else v=parseFloat(s.value),v=ot(v,f);C.textContent=v.toFixed(f<1?2:0);const x=(v-c)/(p-c)*100;s.style.background=`linear-gradient(
1067
+ `,w.textContent=e.toFixed(p<1?2:0),l.appendChild(s),l.appendChild(w),i.appendChild(l),!o){const h=()=>{let y;if(d==="exponential"){const C=parseFloat(c.value)/1e3;y=Un(C,u,f),y=ut(y,p),y=Math.max(u,Math.min(f,y))}else y=parseFloat(c.value),y=ut(y,p);w.textContent=y.toFixed(p<1?2:0);const v=(y-u)/(f-u)*100;c.style.background=`linear-gradient(
782
1068
  to right,
783
1069
  var(--fb-primary-color) 0%,
784
- var(--fb-primary-color) ${x}%,
785
- var(--fb-border-color) ${x}%,
1070
+ var(--fb-primary-color) ${v}%,
1071
+ var(--fb-border-color) ${v}%,
786
1072
  var(--fb-border-color) 100%
787
- )`,r.instance&&r.instance.triggerOnChange(t,v)};s.addEventListener("input",h),s.addEventListener("change",h)}return a}function No(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,a=oe(e,i,t),l=e.default!==void 0?e.default:(e.min+e.max)/2,u=(o=t.prefill[e.key])!=null?o:l,s=Fn(u,r,e,t,a);if(n.appendChild(s),!a){const d=document.createElement("p");d.className="mt-1",d.style.cssText=`
1073
+ )`,r.instance&&r.instance.triggerOnChange(t,y)};c.addEventListener("input",h),c.addEventListener("change",h)}return i}function el(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 a=t.state,i=oe(e,a,t),l=e.default!==void 0?e.default:(e.min+e.max)/2,s=(o=t.prefill[e.key])!=null?o:l,c=Pn(s,r,e,t,i);if(n.appendChild(c),!i){const d=document.createElement("p");d.className="mt-1",d.style.cssText=`
788
1074
  font-size: var(--fb-font-size-small);
789
1075
  color: var(--fb-text-secondary-color);
790
- `,d.textContent=Ee(e,i),n.appendChild(d)}}function zo(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 a=t.state,l=oe(e,a,t),u=t.prefill[e.key]||[],s=Array.isArray(u)?[...u]:[],d=(o=e.minCount)!=null?o:1,c=(i=e.maxCount)!=null?i:1/0,p=e.default!==void 0?e.default:(e.min+e.max)/2;for(;s.length<d;)s.push(p);const f=document.createElement("div");f.className="space-y-3",n.appendChild(f);function m(){f.querySelectorAll(".multiple-slider-item").forEach((x,E)=>{const k=x.querySelector("input[type=range]");k&&k.setAttribute("name",`${r}[${E}]`)})}function g(x=p,E=-1){const k=document.createElement("div");k.className="multiple-slider-item flex items-start gap-2";const b=`${r}[${f.children.length}]`,w=Fn(x,b,e,t,l);return w.style.flex="1",k.appendChild(w),E===-1?f.appendChild(k):f.insertBefore(k,f.children[E]),m(),k}function y(){if(l)return;const x=f.querySelectorAll(".multiple-slider-item"),E=x.length;x.forEach(k=>{let b=k.querySelector(".remove-item-btn");b||(b=document.createElement("button"),b.type="button",b.className="remove-item-btn px-2 py-1 rounded",b.style.cssText=`
1076
+ `,d.textContent=Le(e,a),n.appendChild(d)}}function tl(e,t,n,r){var o,a;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=oe(e,i,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],d=(o=e.minCount)!=null?o:1,u=(a=e.maxCount)!=null?a:1/0,f=e.default!==void 0?e.default:(e.min+e.max)/2;for(;c.length<d;)c.push(f);const p=document.createElement("div");p.className="space-y-3",n.appendChild(p);function m(){p.querySelectorAll(".multiple-slider-item").forEach((y,v)=>{const C=y.querySelector("input[type=range]");C&&C.setAttribute("name",`${r}[${v}]`)})}function b(y=f,v=-1){const C=document.createElement("div");C.className="multiple-slider-item flex items-start gap-2";const E=`${r}[${p.children.length}]`,x=Pn(y,E,e,t,l);return x.style.flex="1",C.appendChild(x),v===-1?p.appendChild(C):p.insertBefore(C,p.children[v]),m(),C}function g(){if(l)return;const y=p.querySelectorAll(".multiple-slider-item"),v=y.length;y.forEach(C=>{let E=C.querySelector(".remove-item-btn");E||(E=document.createElement("button"),E.type="button",E.className="remove-item-btn px-2 py-1 rounded",E.style.cssText=`
791
1077
  color: var(--fb-error-color);
792
1078
  background-color: transparent;
793
1079
  transition: background-color var(--fb-transition-duration);
794
1080
  margin-top: 8px;
795
- `,b.innerHTML="\u2715",b.addEventListener("mouseenter",()=>{b.style.backgroundColor="var(--fb-background-hover-color)"}),b.addEventListener("mouseleave",()=>{b.style.backgroundColor="transparent"}),b.onclick=()=>{const F=Array.from(f.children).indexOf(k);f.children.length>d&&(s.splice(F,1),k.remove(),m(),v(),y())},k.appendChild(b));const w=E<=d;b.disabled=w,b.style.opacity=w?"0.5":"1",b.style.pointerEvents=w?"none":"auto"})}let C=null,h=null;if(!l){C=document.createElement("div"),C.className="flex items-center gap-3 mt-2";const x=document.createElement("button");x.type="button",x.className="add-slider-btn px-3 py-1 rounded",x.style.cssText=`
796
- color: var(--fb-primary-color);
797
- border: var(--fb-border-width) solid var(--fb-primary-color);
798
- background-color: transparent;
799
- font-size: var(--fb-font-size);
800
- transition: all var(--fb-transition-duration);
801
- `,x.textContent="+",x.addEventListener("mouseenter",()=>{x.style.backgroundColor="var(--fb-background-hover-color)"}),x.addEventListener("mouseleave",()=>{x.style.backgroundColor="transparent"}),x.onclick=()=>{s.push(p),g(p),v(),y()},h=document.createElement("span"),h.className="text-sm text-gray-500",C.appendChild(x),C.appendChild(h),n.appendChild(C)}function v(){if(!C||!h)return;const x=C.querySelector(".add-slider-btn");if(x){const E=s.length>=c;x.disabled=E,x.style.opacity=E?"0.5":"1",x.style.pointerEvents=E?"none":"auto"}h.textContent=`${s.length}/${c===1/0?"\u221E":c}`}if(s.forEach(x=>g(x)),v(),y(),!l){const x=document.createElement("p");x.className="mt-1",x.style.cssText=`
1081
+ `,E.innerHTML="\u2715",E.addEventListener("mouseenter",()=>{E.style.backgroundColor="var(--fb-background-hover-color)"}),E.addEventListener("mouseleave",()=>{E.style.backgroundColor="transparent"}),E.onclick=()=>{const L=Array.from(p.children).indexOf(C);p.children.length>d&&(c.splice(L,1),C.remove(),m(),h(),g())},C.appendChild(E));const x=v<=d;E.disabled=x,E.style.opacity=x?"0.5":"1",E.style.pointerEvents=x?"none":"auto"})}let w=null;if(!l){const y=Ae("slider",()=>{c.push(f),b(f),h(),g()},{label:e.addLabel});w=y.update,Se(n,y.counter),n.appendChild(y.row)}function h(){w&&w(c.length,u)}if(c.forEach(y=>b(y)),h(),g(),!l){const y=document.createElement("p");y.className="mt-1",y.style.cssText=`
802
1082
  font-size: var(--fb-font-size-small);
803
1083
  color: var(--fb-text-secondary-color);
804
- `,x.textContent=Ee(e,a),n.appendChild(x)}}function qo(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:u}=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,d=e.max,c=(r=e.step)!=null?r:1,p=e.scale||"linear",f=(g,y)=>{var C,h;if(!g)return;const v=`error-${g.getAttribute("name")||Math.random().toString(36).substring(7)}`;let x=document.getElementById(v);if(y){if(g.classList.add("invalid"),g.title=y,!x){x=document.createElement("div"),x.id=v,x.className="error-message",x.style.cssText=`
1084
+ `,y.textContent=Le(e,i),n.appendChild(y)}}function nl(e,t,n){var r,o,a;const i=[],{scopeRoot:l,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,d=e.max,u=(r=e.step)!=null?r:1,f=e.scale||"linear",p=(b,g)=>{var w,h;if(!b)return;const y=`error-${b.getAttribute("name")||Math.random().toString(36).substring(7)}`;let v=document.getElementById(y);if(g){if(b.classList.add("invalid"),b.title=g,!v){v=document.createElement("div"),v.id=y,v.className="error-message",v.style.cssText=`
805
1085
  color: var(--fb-error-color);
806
1086
  font-size: var(--fb-font-size-small);
807
1087
  margin-top: 0.25rem;
808
- `;const E=g.closest(".slider-container");E&&E.nextSibling?(C=E.parentNode)==null||C.insertBefore(x,E.nextSibling):E&&((h=E.parentNode)==null||h.appendChild(x))}x.textContent=y,x.style.display="block"}else g.classList.remove("invalid"),g.title="",x&&x.remove()},m=(g,y)=>{const{state:C}=n,h=g.value;if(!h){if(!u&&e.required){const x=$("required",C);return a.push(`${y}: ${x}`),f(g,x),null}return f(g,null),null}let v;if(p==="exponential"){const x=parseFloat(h)/1e3;v=An(x,s,d),v=ot(v,c)}else v=parseFloat(h),v=ot(v,c);if(!u){if(v<s){const x=$("minValue",C,{min:s});return a.push(`${y}: ${x}`),f(g,x),v}if(v>d){const x=$("maxValue",C,{max:d});return a.push(`${y}: ${x}`),f(g,x),v}}return f(g,null),v};if(e.multiple){const g=l.querySelectorAll(`input[type="range"][name^="${t}["]`),y=[];if(g.forEach((C,h)=>{const v=m(C,`${t}[${h}]`);y.push(v)}),!u){const{state:C}=n,h=(o=e.minCount)!=null?o:1,v=(i=e.maxCount)!=null?i:1/0,x=y.filter(E=>E!==null);e.required&&x.length===0&&a.push(`${t}: ${$("required",C)}`),x.length<h&&a.push(`${t}: ${$("minItems",C,{min:h})}`),x.length>v&&a.push(`${t}: ${$("maxItems",C,{max:v})}`)}return{value:y,errors:a}}else{const g=l.querySelector(`input[type="range"][name="${t}"]`);return g?{value:m(g,t),errors:a}:(!u&&e.required&&a.push(`${t}: ${$("required",n.state)}`),{value:null,errors:a})}}function Io(e,t,n,r){var o;const{scopeRoot:i}=r,a=e.min,l=e.max,u=(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 d=i.querySelectorAll(`input[type="range"][name^="${t}["]`);d.forEach((c,p)=>{if(p<n.length&&n[p]!==null){const f=Number(n[p]);if(s==="exponential"){const g=St(f,a,l);c.value=(g*1e3).toString()}else c.value=f.toString();const m=c.closest(".slider-container");if(m){const g=m.querySelector(".slider-value");g&&(g.textContent=f.toFixed(u<1?2:0));const y=(f-a)/(l-a)*100;c.style.background=`linear-gradient(
1088
+ `;const C=b.closest(".slider-container");C&&C.nextSibling?(w=C.parentNode)==null||w.insertBefore(v,C.nextSibling):C&&((h=C.parentNode)==null||h.appendChild(v))}v.textContent=g,v.style.display="block"}else b.classList.remove("invalid"),b.title="",v&&v.remove()},m=(b,g)=>{const{state:w}=n,h=b.value;if(!h){if(!s&&e.required){const v=k("required",w);return i.push(`${g}: ${v}`),p(b,v),null}return p(b,null),null}let y;if(f==="exponential"){const v=parseFloat(h)/1e3;y=Un(v,c,d),y=ut(y,u)}else y=parseFloat(h),y=ut(y,u);if(!s){if(y<c){const v=k("minValue",w,{min:c});return i.push(`${g}: ${v}`),p(b,v),y}if(y>d){const v=k("maxValue",w,{max:d});return i.push(`${g}: ${v}`),p(b,v),y}}return p(b,null),y};if(e.multiple){const b=l.querySelectorAll(`input[type="range"][name^="${t}\\["]`),g=[];if(b.forEach((w,h)=>{const y=m(w,`${t}[${h}]`);g.push(y)}),!s){const{state:w}=n,h=(o=e.minCount)!=null?o:1,y=(a=e.maxCount)!=null?a:1/0,v=g.filter(C=>C!==null);e.required&&v.length===0&&i.push(`${t}: ${k("required",w)}`),v.length<h&&i.push(`${t}: ${k("minItems",w,{min:h})}`),v.length>y&&i.push(`${t}: ${k("maxItems",w,{max:y})}`)}return{value:g,errors:i}}else{const b=l.querySelector(`input[type="range"][name="${t}"]`);return b?{value:m(b,t),errors:i}:(!s&&e.required&&i.push(`${t}: ${k("required",n.state)}`),{value:null,errors:i})}}function rl(e,t,n,r){var o;const{scopeRoot:a}=r,i=e.min,l=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 d=a.querySelectorAll(`input[type="range"][name^="${t}\\["]`);d.forEach((u,f)=>{if(f<n.length&&n[f]!==null){const p=Number(n[f]);if(c==="exponential"){const b=qt(p,i,l);u.value=(b*1e3).toString()}else u.value=p.toString();const m=u.closest(".slider-container");if(m){const b=m.querySelector(".slider-value");b&&(b.textContent=p.toFixed(s<1?2:0));const g=(p-i)/(l-i)*100;u.style.background=`linear-gradient(
809
1089
  to right,
810
1090
  var(--fb-primary-color) 0%,
811
- var(--fb-primary-color) ${y}%,
812
- var(--fb-border-color) ${y}%,
1091
+ var(--fb-primary-color) ${g}%,
1092
+ var(--fb-border-color) ${g}%,
813
1093
  var(--fb-border-color) 100%
814
- )`}c.classList.remove("invalid"),c.title=""}}),n.length!==d.length&&console.warn(`updateSliderField: Multiple field "${t}" has ${d.length} sliders but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const d=i.querySelector(`input[type="range"][name="${t}"]`);if(d&&n!==null&&n!==void 0){const c=Number(n);if(s==="exponential"){const f=St(c,a,l);d.value=(f*1e3).toString()}else d.value=c.toString();const p=d.closest(".slider-container");if(p){const f=p.querySelector(".slider-value");f&&(f.textContent=c.toFixed(u<1?2:0));const m=(c-a)/(l-a)*100;d.style.background=`linear-gradient(
1094
+ )`}u.classList.remove("invalid"),u.title="",ye(u)}}),n.length!==d.length&&console.warn(`updateSliderField: Multiple field "${t}" has ${d.length} sliders but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const d=a.querySelector(`input[type="range"][name="${t}"]`);if(d&&n!==null&&n!==void 0){const u=Number(n);if(c==="exponential"){const p=qt(u,i,l);d.value=(p*1e3).toString()}else d.value=u.toString();const f=d.closest(".slider-container");if(f){const p=f.querySelector(".slider-value");p&&(p.textContent=u.toFixed(s<1?2:0));const m=(u-i)/(l-i)*100;d.style.background=`linear-gradient(
815
1095
  to right,
816
1096
  var(--fb-primary-color) 0%,
817
1097
  var(--fb-primary-color) ${m}%,
818
1098
  var(--fb-border-color) ${m}%,
819
1099
  var(--fb-border-color) 100%
820
- )`}d.classList.remove("invalid"),d.title=""}}}function Mn(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 Nn(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 Ro(e){At=e}function lt(e,t){if(!At)throw new Error("renderElement not initialized. Import from components/index.ts");return At(e,t)}function zn(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-2",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 qn(e,t,n,r){var o,i;const a=document.createElement("div");a.className="border border-gray-200 rounded-lg p-2 bg-gray-50",a.setAttribute("data-container",r);const l=document.createElement("div"),u=e.columns||1;u===1?l.className="space-y-2":l.className=`grid grid-cols-${u} gap-2`;const s=oe(e,t.state,t);if(!s){const m=zn(e,r);m&&a.appendChild(m)}const d=Mn(e.elements),c=((o=t.prefill)==null?void 0:o[e.key])||{},p=Nn(c,d),f={path:ye(t.path,e.key),prefill:p,formData:(i=t.formData)!=null?i:t.prefill,state:t.state,inheritedReadonly:s||t.inheritedReadonly};e.elements.forEach(m=>{var g,y;if(m.type!=="markdown"&&(m.hidden||m.type==="hidden")){const C=(y=(g=c[m.key])!=null?g:"default"in m?m.default:null)!=null?y:null;l.appendChild(De(ye(f.path,m.key),C))}else l.appendChild(lt(m,f))}),a.appendChild(l),n.appendChild(a)}function Ho(e,t){if(e)return"space-y-2";const n=t||1;return n===1?"space-y-2":`grid grid-cols-${n} gap-2`}function In(e,t,n,r){var o,i,a,l;const u=t.state,s=oe(e,u,t),d=s||t.inheritedReadonly,c=document.createElement("div");c.className="border border-gray-200 rounded-lg p-2 bg-gray-50";const p=document.createElement("span");p.className="text-sm text-gray-500";const f=document.createElement("div"),m=e.displayMode==="slides";if(m){f.className="fb-container-slides";const b=e.columns,w=typeof b=="number"&&b>0?`repeat(${b}, 1fr)`:"repeat(auto-fit, minmax(280px, 1fr))";f.style.cssText=`display:grid;grid-template-columns:${w};gap:8px;align-items:start;`}else f.className="space-y-2";if(!s){const b=zn(e,e.key);b&&c.appendChild(b)}const g=(o=e.minCount)!=null?o:0,y=(i=e.maxCount)!=null?i:1/0,C=Array.isArray((a=t.prefill)==null?void 0:a[e.key])?t.prefill[e.key]:null,h=Mn(e.elements),v=()=>f.querySelectorAll(":scope > .containerItem").length,x=()=>{const b=document.createElement("button");return b.type="button",b.className="add-container-btn px-3 py-1 rounded",b.style.cssText=`
821
- color: var(--fb-primary-color);
822
- border: var(--fb-border-width) solid var(--fb-primary-color);
823
- background-color: transparent;
824
- font-size: var(--fb-font-size);
825
- transition: all var(--fb-transition-duration);
826
- `,b.textContent="+",b.addEventListener("mouseenter",()=>{b.style.backgroundColor="var(--fb-background-hover-color)"}),b.addEventListener("mouseleave",()=>{b.style.backgroundColor="transparent"}),b.onclick=()=>{if(v()<y){const w=v(),F=u.formRoot?Tt(u.formRoot):{},V={state:t.state,path:ye(t.path,`${e.key}[${w}]`),prefill:h,formData:F,inheritedReadonly:d},R=document.createElement("div");R.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",R.setAttribute("data-container-item",`${e.key}[${w}]`);const D=document.createElement("div");if(D.className=Ho(m,e.columns),e.elements.forEach(j=>{var Y;j.type!=="markdown"&&(j.hidden||j.type==="hidden")?D.appendChild(De(ye(V.path,j.key),(Y="default"in j?j.default:null)!=null?Y:null)):D.appendChild(lt(j,V))}),R.appendChild(D),!s){const j=document.createElement("button");j.type="button",j.className="absolute top-2 right-2 px-2 py-1 rounded",j.style.cssText=`
827
- color: var(--fb-error-color);
828
- background-color: transparent;
829
- transition: background-color var(--fb-transition-duration);
830
- `,j.textContent="\u2715",j.addEventListener("mouseenter",()=>{j.style.backgroundColor="var(--fb-background-hover-color)"}),j.addEventListener("mouseleave",()=>{j.style.backgroundColor="transparent"}),j.onclick=()=>k(R),R.style.position="relative",R.appendChild(j)}f.appendChild(R),E()}},b},E=()=>{const b=v(),w=c.querySelector(".add-container-btn");w&&(w.disabled=b>=y,w.style.opacity=b>=y?"0.5":"1",w.style.pointerEvents=b>=y?"none":"auto"),p.textContent=`${b}/${y===1/0?"\u221E":y}`},k=b=>{b.remove(),E()};if(C&&Array.isArray(C)&&C.forEach((b,w)=>{var F;const V=Nn(b||{},h),R={state:t.state,path:ye(t.path,`${e.key}[${w}]`),prefill:V,formData:(F=t.formData)!=null?F:t.prefill,inheritedReadonly:d},D=document.createElement("div");D.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",D.setAttribute("data-container-item",`${e.key}[${w}]`);const j=document.createElement("div");if(m)j.className="space-y-2";else{const Y=e.columns||1;Y===1?j.className="space-y-2":j.className=`grid grid-cols-${Y} gap-2`}if(e.elements.forEach(Y=>{var Me,fe;if(Y.type!=="markdown"&&(Y.hidden||Y.type==="hidden")){const Te=(fe=(Me=b==null?void 0:b[Y.key])!=null?Me:"default"in Y?Y.default:null)!=null?fe:null;j.appendChild(De(ye(R.path,Y.key),Te))}else j.appendChild(lt(Y,R))}),D.appendChild(j),!s){const Y=document.createElement("button");Y.type="button",Y.className="absolute top-2 right-2 px-2 py-1 rounded",Y.style.cssText=`
831
- color: var(--fb-error-color);
832
- background-color: transparent;
833
- transition: background-color var(--fb-transition-duration);
834
- `,Y.textContent="\u2715",Y.addEventListener("mouseenter",()=>{Y.style.backgroundColor="var(--fb-background-hover-color)"}),Y.addEventListener("mouseleave",()=>{Y.style.backgroundColor="transparent"}),Y.onclick=()=>k(D),D.style.position="relative",D.appendChild(Y)}f.appendChild(D)}),!s)for(;v()<g;){const b=v(),w={state:t.state,path:ye(t.path,`${e.key}[${b}]`),prefill:h,formData:(l=t.formData)!=null?l:t.prefill,inheritedReadonly:d},F=document.createElement("div");F.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",F.setAttribute("data-container-item",`${e.key}[${b}]`);const V=document.createElement("div");if(m)V.className="space-y-2";else{const D=e.columns||1;D===1?V.className="space-y-2":V.className=`grid grid-cols-${D} gap-2`}e.elements.forEach(D=>{var j;D.type!=="markdown"&&(D.hidden||D.type==="hidden")?V.appendChild(De(ye(w.path,D.key),(j="default"in D?D.default:null)!=null?j:null)):V.appendChild(lt(D,w))}),F.appendChild(V);const R=document.createElement("button");R.type="button",R.className="absolute top-2 right-2 px-2 py-1 rounded",R.style.cssText=`
835
- color: var(--fb-error-color);
836
- background-color: transparent;
837
- transition: background-color var(--fb-transition-duration);
838
- `,R.textContent="\u2715",R.addEventListener("mouseenter",()=>{R.style.backgroundColor="var(--fb-background-hover-color)"}),R.addEventListener("mouseleave",()=>{R.style.backgroundColor="transparent"}),R.onclick=()=>{v()>g&&k(F)},F.style.position="relative",F.appendChild(R),f.appendChild(F)}if(c.appendChild(f),!s){const b=document.createElement("div");b.className="flex items-center gap-3 mt-2",b.appendChild(x()),b.appendChild(p),c.appendChild(b)}E(),n.appendChild(c)}let Ft=null;function Bo(e){Ft=e}function Rn(e,t,n){if(!Ft)throw new Error("validateElement not initialized. Should be set from FormBuilderInstance");return Ft(e,t,n)}function Hn(e,t,n){const r=[],{scopeRoot:o,skipValidation:i,path:a}=n;if(!("elements"in e))return{value:null,errors:r};const l=(u,s,d)=>{var c,p;if(i)return;const{state:f}=n,m="minCount"in d&&(c=d.minCount)!=null?c:0,g="maxCount"in d&&(p=d.maxCount)!=null?p:1/0;d.required&&s.length===0&&r.push(`${u}: ${$("required",f)}`),s.length<m&&r.push(`${u}: ${$("minItems",f,{min:m})}`),s.length>g&&r.push(`${u}: ${$("maxItems",f,{max:g})}`)};if("multiple"in e&&e.multiple){const u=[],s=o.querySelectorAll("[data-container-item]");return Array.from(s).filter(d=>{const c=d.getAttribute("data-container-item")||"";if(!c.startsWith(`${t}[`))return!1;const p=c.slice(t.length);return/^\[\d+\]$/.test(p)}).forEach(d=>{const c={},p=(d.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),f=p?parseInt(p[1],10):0;e.elements.forEach(m=>{var g;if(m.enableIf)try{const h=(g=n.instance)!=null&&g.getState().formRoot?Tt(n.instance.getState().formRoot):{};if(!ze(m.enableIf,h,c))return}catch(h){console.error(`Error evaluating enableIf for field "${m.key}" in container "${t}[${f}]":`,h)}const y=`${t}[${f}].${m.key}`,C=Rn({...m,key:y},{path:a},d);C.spread&&C.value!==null&&typeof C.value=="object"?Object.assign(c,C.value):c[m.key]=C.value}),u.push(c)}),l(t,u,e),{value:u,errors:r}}else{const u={},s=o.querySelector(`[data-container="${t}"]`)||o;return e.elements.forEach(d=>{var c;if(d.enableIf)try{const p=(c=n.instance)!=null&&c.getState().formRoot?Tt(n.instance.getState().formRoot):{};if(!ze(d.enableIf,p,u))return}catch(p){console.error(`Error evaluating enableIf for field "${d.key}" in container "${t}":`,p)}{const p=`${t}.${d.key}`,f=Rn({...d,key:p},{path:a},s);f.spread&&f.value!==null&&typeof f.value=="object"?Object.assign(u,f.value):u[d.key]=f.value}}),{value:u,errors:r}}}function Bn(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((l,u)=>{Ye(l)&&e.elements.forEach(s=>{var d,c;if(s.type==="markdown"||!s.key)return;const p=`${t}[${u}].${s.key}`;if(s.type==="richinput"&&s.flatOutput){const f=s,m=(d=f.textKey)!=null?d:"text",g=(c=f.filesKey)!=null?c:"files",y=l,C={};m in y&&(C[m]=y[m]),g in y&&(C[g]=y[g]),Object.keys(C).length>0&&o.updateField(p,C)}else{const f=l[s.key];f!==void 0&&o.updateField(p,f)}})});const a=i.querySelectorAll(`[data-container-item^="${t}["]`);n.length!==a.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(a=>{var l,u;if(a.type==="markdown"||!a.key)return;const s=`${t}.${a.key}`;if(a.type==="richinput"&&a.flatOutput){const d=a,c=(l=d.textKey)!=null?l:"text",p=(u=d.filesKey)!=null?u:"files",f=n,m={};c in f&&(m[c]=f[c]),p in f&&(m[p]=f[p]),Object.keys(m).length>0&&o.updateField(s,m)}else{const d=n[a.key];d!==void 0&&o.updateField(s,d)}})}}function Do(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 a={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};a.multiple?In(a,t,n):qn(a,t,n,r)}function Dn(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 jo(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=Dn(e);return Hn(r,t,n)}function Oo(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=Dn(e);return Bn(o,t,n,r)}function Uo(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function Po(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 Wo(e){return Uo(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:Po(e)?e:null}function Re(e){return e.map(Wo).filter(t=>t!==null)}function jn(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 a=e[i];if(o.top<=a.bottom&&o.bottom>=a.top&&o.left<=a.right&&o.right>=a.left)return`Merges ${r} and ${i} overlap`}}return null}function On(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 it(e,t,n){var r;return(r=n.find(o=>o.top===e&&o.left===t))!=null?r:null}function Se(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=`
1100
+ )`}d.classList.remove("invalid"),d.title="",ye(d)}}}function Wn(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 Vn(e,t){return{...t,...e}}function It(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 Rt=null;function ol(e){Rt=e}function dt(e,t){if(!Rt)throw new Error("renderElement not initialized. Import from components/index.ts");return Rt(e,t)}function _n(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-2",e.prefillHints.forEach((r,o)=>{const a=document.createElement("button");a.type="button",a.className="fb-prefill-hint",a.textContent=r.label,a.setAttribute("data-hint-values",JSON.stringify(r.values)),a.setAttribute("data-container-key",t),a.setAttribute("data-hint-index",String(o)),n.appendChild(a)}),n}function Kn(e,t,n,r){var o,a;const i=document.createElement("div");i.className="border border-gray-200 rounded-lg p-2 bg-gray-50",i.setAttribute("data-container",r);const l=document.createElement("div"),s=e.columns||1;s===1?l.className="space-y-2":l.className=`grid grid-cols-${s} gap-2`;const c=oe(e,t.state,t);if(!c){const m=_n(e,r);m&&i.appendChild(m)}const d=Wn(e.elements),u=((o=t.prefill)==null?void 0:o[e.key])||{},f=Vn(u,d),p={path:ke(t.path,e.key),prefill:f,formData:(a=t.formData)!=null?a:t.prefill,state:t.state,inheritedReadonly:c||t.inheritedReadonly};e.elements.forEach(m=>{var b,g;if(m.type!=="markdown"&&(m.hidden||m.type==="hidden")){const w=(g=(b=u[m.key])!=null?b:"default"in m?m.default:null)!=null?g:null;l.appendChild(Ke(ke(p.path,m.key),w))}else l.appendChild(dt(m,p))}),i.appendChild(l),n.appendChild(i)}function ll(e,t){if(e)return"space-y-2";const n=t||1;return n===1?"space-y-2":`grid grid-cols-${n} gap-2`}function Ht(e,t,n){const r=document.createElement("button");r.type="button",r.className="fb-item-remove",r.setAttribute("aria-label",k("removeElement",n)),r.style.cssText=`
1101
+ width: 24px;
1102
+ height: 24px;
1103
+ display: inline-flex;
1104
+ align-items: center;
1105
+ justify-content: center;
1106
+ padding: 0;
1107
+ border: 0;
1108
+ border-radius: 4px;
1109
+ cursor: pointer;
1110
+ flex-shrink: 0;
1111
+ `,r.innerHTML=Gt,r.onclick=t;const o=e.querySelector("[data-fb-label-row]");if(o){r.style.marginLeft="auto",o.appendChild(r);return}r.style.position="absolute",r.style.top="8px",r.style.right="8px",e.style.position="relative",e.appendChild(r)}function Jn(e,t,n,r){var o,a,i,l;const s=t.state,c=oe(e,s,t),d=c||t.inheritedReadonly,u=document.createElement("div");u.className="border border-gray-200 rounded-lg p-2 bg-gray-50";const f=document.createElement("div"),p=e.displayMode==="slides";if(p){f.className="fb-container-slides";const I=e.columns,W=typeof I=="number"&&I>0?`repeat(${I}, 1fr)`:"repeat(auto-fit, minmax(280px, 1fr))";f.style.cssText=`display:grid;grid-template-columns:${W};gap:var(--fb-slides-gap, 14px);align-items:start;`}else f.className="space-y-2";if(!c){const I=_n(e,e.key);I&&u.appendChild(I)}const m=(o=e.minCount)!=null?o:0,b=(a=e.maxCount)!=null?a:1/0,g=Array.isArray((i=t.prefill)==null?void 0:i[e.key])?t.prefill[e.key]:null,w=Wn(e.elements),h=()=>f.querySelectorAll(":scope > .containerItem").length,y=()=>{if(h()>=b)return;const I=h(),W=s.formRoot?It(s.formRoot):{},V={state:t.state,path:ke(t.path,`${e.key}[${I}]`),prefill:w,formData:W,inheritedReadonly:d},J=document.createElement("div");J.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",J.setAttribute("data-container-item",`${e.key}[${I}]`),p&&J.setAttribute("data-fb-slide-card","");const Q=document.createElement("div");Q.className=ll(p,e.columns),e.elements.forEach(le=>{var ae;le.type!=="markdown"&&(le.hidden||le.type==="hidden")?Q.appendChild(Ke(ke(V.path,le.key),(ae="default"in le?le.default:null)!=null?ae:null)):Q.appendChild(dt(le,V))}),J.appendChild(Q),c||Ht(J,()=>q(J),s),v&&v.parentElement===f?f.insertBefore(J,v):f.appendChild(J),L()};let v=null,C=null,E=null;const x=()=>{if(!v)return;const I=f.querySelector(":scope > .containerItem");I&&I.offsetHeight>0&&(v.style.minHeight=`${I.offsetHeight}px`)},L=()=>{const I=h();C&&C(I,b),E&&E(I,b),v&&x()},q=I=>{I.remove(),L()};if(g&&Array.isArray(g)&&g.forEach((I,W)=>{var V;const J=Vn(I||{},w),Q={state:t.state,path:ke(t.path,`${e.key}[${W}]`),prefill:J,formData:(V=t.formData)!=null?V:t.prefill,inheritedReadonly:d},le=document.createElement("div");le.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",le.setAttribute("data-container-item",`${e.key}[${W}]`),p&&le.setAttribute("data-fb-slide-card","");const ae=document.createElement("div");if(p)ae.className="space-y-2";else{const fe=e.columns||1;fe===1?ae.className="space-y-2":ae.className=`grid grid-cols-${fe} gap-2`}e.elements.forEach(fe=>{var Ne,we;if(fe.type!=="markdown"&&(fe.hidden||fe.type==="hidden")){const _e=(we=(Ne=I==null?void 0:I[fe.key])!=null?Ne:"default"in fe?fe.default:null)!=null?we:null;ae.appendChild(Ke(ke(Q.path,fe.key),_e))}else ae.appendChild(dt(fe,Q))}),le.appendChild(ae),c||Ht(le,()=>q(le),t.state),f.appendChild(le)}),!c)for(;h()<m;){const I=h(),W={state:t.state,path:ke(t.path,`${e.key}[${I}]`),prefill:w,formData:(l=t.formData)!=null?l:t.prefill,inheritedReadonly:d},V=document.createElement("div");V.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",V.setAttribute("data-container-item",`${e.key}[${I}]`),p&&V.setAttribute("data-fb-slide-card","");const J=document.createElement("div");if(p)J.className="space-y-2";else{const Q=e.columns||1;Q===1?J.className="space-y-2":J.className=`grid grid-cols-${Q} gap-2`}e.elements.forEach(Q=>{var le;Q.type!=="markdown"&&(Q.hidden||Q.type==="hidden")?J.appendChild(Ke(ke(W.path,Q.key),(le="default"in Q?Q.default:null)!=null?le:null)):J.appendChild(dt(Q,W))}),V.appendChild(J),Ht(V,()=>{h()>m&&q(V)},t.state),f.appendChild(V)}if(u.appendChild(f),!c)if(p){f.style.alignItems="stretch";const I=$r(y,{label:e.addLabel});v=I.tile,C=I.update,Se(n,I.counter),f.appendChild(I.tile)}else{const I=Ae("container",y,{label:e.addLabel});E=I.update,Se(n,I.counter),u.appendChild(I.row)}L(),n.appendChild(u),v&&(typeof requestAnimationFrame=="function"?requestAnimationFrame(x):x())}let Bt=null;function il(e){Bt=e}function Yn(e,t,n){if(!Bt)throw new Error("validateElement not initialized. Should be set from FormBuilderInstance");return Bt(e,t,n)}function Xn(e,t,n){const r=[],{scopeRoot:o,skipValidation:a,path:i}=n;if(!("elements"in e))return{value:null,errors:r};const l=(s,c,d)=>{var u,f;if(a)return;const{state:p}=n,m="minCount"in d&&(u=d.minCount)!=null?u:0,b="maxCount"in d&&(f=d.maxCount)!=null?f:1/0;d.required&&c.length===0&&r.push(`${s}: ${k("required",p)}`),c.length<m&&r.push(`${s}: ${k("minItems",p,{min:m})}`),c.length>b&&r.push(`${s}: ${k("maxItems",p,{max:b})}`)};if("multiple"in e&&e.multiple){const s=[],c=o.querySelectorAll("[data-container-item]");return Array.from(c).filter(d=>{const u=d.getAttribute("data-container-item")||"";if(!u.startsWith(`${t}[`))return!1;const f=u.slice(t.length);return/^\[\d+\]$/.test(f)}).forEach(d=>{const u={},f=(d.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),p=f?parseInt(f[1],10):0;e.elements.forEach(m=>{var b;if(m.enableIf)try{const h=(b=n.instance)!=null&&b.getState().formRoot?It(n.instance.getState().formRoot):{};if(!Be(m.enableIf,h,u))return}catch(h){console.error(`Error evaluating enableIf for field "${m.key}" in container "${t}[${p}]":`,h)}const g=`${t}[${p}].${m.key}`,w=Yn({...m,key:g},{path:i},d);w.spread&&w.value!==null&&typeof w.value=="object"?Object.assign(u,w.value):u[m.key]=w.value}),s.push(u)}),l(t,s,e),{value:s,errors:r}}else{const s={},c=o.querySelector(`[data-container="${t}"]`)||o;return e.elements.forEach(d=>{var u;if(d.enableIf)try{const f=(u=n.instance)!=null&&u.getState().formRoot?It(n.instance.getState().formRoot):{};if(!Be(d.enableIf,f,s))return}catch(f){console.error(`Error evaluating enableIf for field "${d.key}" in container "${t}":`,f)}{const f=`${t}.${d.key}`,p=Yn({...d,key:f},{path:i},c);p.spread&&p.value!==null&&typeof p.value=="object"?Object.assign(s,p.value):s[d.key]=p.value}}),{value:s,errors:r}}}function Gn(e,t,n,r){const{instance:o,scopeRoot:a}=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((l,s)=>{et(l)&&e.elements.forEach(c=>{var d,u;if(c.type==="markdown"||!c.key)return;const f=`${t}[${s}].${c.key}`;if(c.type==="richinput"&&c.flatOutput){const p=c,m=(d=p.textKey)!=null?d:"text",b=(u=p.filesKey)!=null?u:"files",g=l,w={};m in g&&(w[m]=g[m]),b in g&&(w[b]=g[b]),Object.keys(w).length>0&&o.updateField(f,w)}else{const p=l[c.key];p!==void 0&&o.updateField(f,p)}})});const i=a.querySelectorAll(`[data-container-item^="${t}["]`);n.length!==i.length&&console.warn(`updateContainerField: Multiple container field "${t}" item count mismatch. Consider re-rendering for add/remove.`)}else{if(!et(n)){console.warn(`updateContainerField: Expected object for container field "${t}", got ${typeof n}`);return}e.elements.forEach(i=>{var l,s;if(i.type==="markdown"||!i.key)return;const c=`${t}.${i.key}`;if(i.type==="richinput"&&i.flatOutput){const d=i,u=(l=d.textKey)!=null?l:"text",f=(s=d.filesKey)!=null?s:"files",p=n,m={};u in p&&(m[u]=p[u]),f in p&&(m[f]=p[f]),Object.keys(m).length>0&&o.updateField(c,m)}else{const d=n[i.key];d!==void 0&&o.updateField(c,d)}})}}function al(e,t,n,r){var o,a;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 i={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&&et(e.repeat)),minCount:(o=e.repeat)==null?void 0:o.min,maxCount:(a=e.repeat)==null?void 0:a.max};i.multiple?Jn(i,t,n):Kn(i,t,n,r)}function Zn(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&&et(r.repeat)),minCount:(t=r.repeat)==null?void 0:t.min,maxCount:(n=r.repeat)==null?void 0:n.max}}function sl(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=Zn(e);return Xn(r,t,n)}function cl(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=Zn(e);return Gn(o,t,n,r)}function ul(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function dl(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 fl(e){return ul(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:dl(e)?e:null}function Ue(e){return e.map(fl).filter(t=>t!==null)}function Qn(e,t){return Array.from({length:e},()=>Array.from({length:t},()=>""))}function Dt(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 a=r+1;a<e.length;a++){const i=e[a];if(o.top<=i.bottom&&o.bottom>=i.top&&o.left<=i.right&&o.right>=i.left)return`Merges ${r} and ${a} overlap`}}return null}function er(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 ft(e,t,n){var r;return(r=n.find(o=>o.top===e&&o.left===t))!=null?r:null}function ze(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 Pe(e){const t=document.createElement("button");return t.type="button",t.textContent=e.label,t.title=e.title,t.style.cssText=`
839
1112
  position: absolute;
840
1113
  width: ${e.size}px;
841
1114
  height: ${e.size}px;
@@ -855,7 +1128,7 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
855
1128
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
856
1129
  transition: transform 0.1s, opacity 0.1s;
857
1130
  pointer-events: all;
858
- `,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 Vo(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=`
1131
+ `,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 pl(e,t){const{cells:n,merges:r=[]}=e;if(n.length===0)return;const o=n[0].length,a=document.createElement("table");a.style.cssText=`
859
1132
  width: 100%;
860
1133
  border-collapse: collapse;
861
1134
  border: var(--fb-border-width) solid var(--fb-border-color);
@@ -863,13 +1136,13 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
863
1136
  font-size: var(--fb-font-size);
864
1137
  font-family: var(--fb-font-family);
865
1138
  color: var(--fb-text-color);
866
- `,n.forEach((l,u)=>{var s,d;const c=(u===0?i.createTHead():(s=i.tBodies[0])!=null?s:i.createTBody()).insertRow();for(let p=0;p<o;p++){if(On(u,p,r))continue;const f=it(u,p,r),m=document.createElement(u===0?"th":"td");if(f){const g=f.bottom-f.top+1,y=f.right-f.left+1;g>1&&(m.rowSpan=g),y>1&&(m.colSpan=y)}m.textContent=(d=l[p])!=null?d:"",m.style.cssText=`
1139
+ `,n.forEach((l,s)=>{var c,d;const u=(s===0?a.createTHead():(c=a.tBodies[0])!=null?c:a.createTBody()).insertRow();for(let f=0;f<o;f++){if(er(s,f,r))continue;const p=ft(s,f,r),m=document.createElement(s===0?"th":"td");if(p){const b=p.bottom-p.top+1,g=p.right-p.left+1;b>1&&(m.rowSpan=b),g>1&&(m.colSpan=g)}m.textContent=(d=l[f])!=null?d:"",m.style.cssText=`
867
1140
  padding: 6px 10px;
868
1141
  border: var(--fb-border-width) solid var(--fb-border-color);
869
1142
  text-align: left;
870
1143
  vertical-align: top;
871
- ${u===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":""}
872
- `,c.appendChild(m)}});const a=document.createElement("div");a.style.cssText="overflow-x: auto; max-width: 100%;",a.appendChild(i),t.appendChild(a)}function _o(e,t,n,r,o,i){if(e.contentEditable==="true")return;e.contentEditable="true",e.focus();const a=document.createRange(),l=window.getSelection();a.selectNodeContents(e),a.collapse(!1),l==null||l.removeAllRanges(),l==null||l.addRange(a);function u(){var c;e.contentEditable="inherit";const p=r();p[t]&&(p[t][n]=(c=e.textContent)!=null?c:""),o()}function s(c){var p,f,m,g;const y=r(),C=(f=(p=y[0])==null?void 0:p.length)!=null?f:0;if(c.key==="Escape"){e.contentEditable="inherit",e.textContent=(g=(m=y[t])==null?void 0:m[n])!=null?g:"",e.removeEventListener("keydown",s),e.removeEventListener("blur",d);return}if(c.key==="Enter"&&!c.shiftKey){c.preventDefault(),c.stopPropagation(),u(),e.removeEventListener("keydown",s),e.removeEventListener("blur",d);const h=t+1<y.length?t+1:t;i(h,n);return}if(c.key==="Tab"){c.preventDefault(),c.stopPropagation(),u(),e.removeEventListener("keydown",s),e.removeEventListener("blur",d);let h=t,v=c.shiftKey?n-1:n+1;v<0&&(v=C-1,h=Math.max(0,t-1)),v>=C&&(v=0,h=Math.min(y.length-1,t+1)),i(h,v)}}function d(){e.contentEditable==="true"&&(u(),e.removeEventListener("keydown",s),e.removeEventListener("blur",d))}e.addEventListener("keydown",s),e.addEventListener("blur",d)}function Ko(){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 Jo(e,t){Ko();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
1144
+ ${s===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":""}
1145
+ `,u.appendChild(m)}});const i=document.createElement("div");i.style.cssText="overflow-x: auto; max-width: 100%;",i.appendChild(a),t.appendChild(i)}function ml(e,t,n,r,o,a){if(e.contentEditable==="true")return;e.contentEditable="true",e.focus();const i=document.createRange(),l=window.getSelection();i.selectNodeContents(e),i.collapse(!1),l==null||l.removeAllRanges(),l==null||l.addRange(i);function s(){var u;e.contentEditable="inherit";const f=r();f[t]&&(f[t][n]=(u=e.textContent)!=null?u:""),o()}function c(u){var f,p,m,b;const g=r(),w=(p=(f=g[0])==null?void 0:f.length)!=null?p:0;if(u.key==="Escape"){e.contentEditable="inherit",e.textContent=(b=(m=g[t])==null?void 0:m[n])!=null?b:"",e.removeEventListener("keydown",c),e.removeEventListener("blur",d);return}if(u.key==="Enter"&&!u.shiftKey){u.preventDefault(),u.stopPropagation(),s(),e.removeEventListener("keydown",c),e.removeEventListener("blur",d);const h=t+1<g.length?t+1:t;a(h,n);return}if(u.key==="Tab"){u.preventDefault(),u.stopPropagation(),s(),e.removeEventListener("keydown",c),e.removeEventListener("blur",d);let h=t,y=u.shiftKey?n-1:n+1;y<0&&(y=w-1,h=Math.max(0,t-1)),y>=w&&(y=0,h=Math.min(g.length-1,t+1)),a(h,y)}}function d(){e.contentEditable==="true"&&(s(),e.removeEventListener("keydown",c),e.removeEventListener("blur",d))}e.addEventListener("keydown",c),e.addEventListener("blur",d)}function hl(){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 bl(e,t){hl();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
873
1146
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
874
1147
  background: rgba(255,255,255,0.8); display: flex;
875
1148
  align-items: center; justify-content: center; flex-direction: column;
@@ -878,13 +1151,13 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
878
1151
  width: 24px; height: 24px; border: 3px solid var(--fb-border-color, #ccc);
879
1152
  border-top-color: var(--fb-primary-color, #0066cc); border-radius: 50%;
880
1153
  animation: fb-spin 0.8s linear infinite;
881
- `;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 Yo(e,t,n,r,o){var i,a,l,u,s,d,c,p;const f=r.state,m=r.instance,g=e.mergeAllowed!==!1,y=(a=(i=e.fieldNames)==null?void 0:i.cells)!=null?a:"cells",C=(u=(l=e.fieldNames)==null?void 0:l.merges)!=null?u:"merges",h=t.cells.length>0?t.cells.map(A=>[...A]):jn((s=e.rows)!=null?s:3,(d=e.columns)!=null?d:3);let v=t.merges?[...t.merges]:[];const x={anchor:null,focus:null,dragging:!1},E=document.createElement("input");E.type="hidden",E.name=n,E.value=JSON.stringify({[y]:h,[C]:v}),o.appendChild(E);function k(){E.value=JSON.stringify({[y]:h,[C]:v}),m&&m.triggerOnChange(n,{[y]:h,[C]:v})}E._applyExternalUpdate=A=>{h.length=0,A.cells.forEach(T=>h.push([...T])),v.length=0,A.merges&&A.merges.forEach(T=>v.push({...T})),x.anchor=null,x.focus=null,k(),N()};const b=document.createElement("div");b.style.cssText="position: relative; padding: 20px 20px 20px 24px; overflow-x: auto; max-width: 100%;";const w=document.createElement("table");w.style.cssText=`
1154
+ `;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 vl(e,t,n,r,o){var a,i,l,s,c,d,u,f;const p=r.state,m=r.instance,b=e.mergeAllowed!==!1,g=(i=(a=e.fieldNames)==null?void 0:a.cells)!=null?i:"cells",w=(s=(l=e.fieldNames)==null?void 0:l.merges)!=null?s:"merges",h=t.cells.length>0?t.cells.map(A=>[...A]):Qn((c=e.rows)!=null?c:3,(d=e.columns)!=null?d:3);let y=t.merges?[...t.merges]:[];const v={anchor:null,focus:null,dragging:!1},C=document.createElement("input");C.type="hidden",C.name=n,C.value=JSON.stringify({[g]:h,[w]:y}),o.appendChild(C);function E(){C.value=JSON.stringify({[g]:h,[w]:y}),m&&m.triggerOnChange(n,{[g]:h,[w]:y})}C._applyExternalUpdate=A=>{h.length=0,A.cells.forEach(T=>h.push([...T])),y.length=0,A.merges&&A.merges.forEach(T=>y.push({...T})),v.anchor=null,v.focus=null,E(),M()};const x=document.createElement("div");x.style.cssText="position: relative; padding: 20px 20px 20px 24px; overflow-x: auto; max-width: 100%;";const L=document.createElement("table");L.style.cssText=`
882
1155
  border-collapse: collapse;
883
1156
  font-size: var(--fb-font-size);
884
1157
  font-family: var(--fb-font-family);
885
1158
  color: var(--fb-text-color);
886
1159
  table-layout: fixed;
887
- `,b.appendChild(w);const F=(p=(c=e.importAccept)==null?void 0:c.map(A=>`.${A.toLowerCase()}`))!=null?p:[];async function V(A){var T,S,B;if(!f.config.parseTableFile)return;if(F.length>0){const M=A.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!F.includes(M))return}const O=Jo(b,$("tableImporting",f));try{const M=await f.config.parseTableFile(A),ee=M.cells,P=(T=M.merges)!=null?T:[];if(P.length>0){const W=Mt(P,ee.length,(B=(S=ee[0])==null?void 0:S.length)!=null?B:0);if(W)throw new Error(W)}h.length=0,ee.forEach(W=>h.push([...W])),v.length=0,P.forEach(W=>v.push({...W})),x.anchor=null,x.focus=null,k(),N()}catch(M){const ee=M instanceof Error?M.message:String(M);console.error($("tableImportError",f).replace("{error}",ee))}finally{O.remove()}}if(e.importAccept&&f.config.parseTableFile){const A=document.createElement("button");A.type="button",A.title=$("tableImportFile",f),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=`
1160
+ `,x.appendChild(L);const q=(f=(u=e.importAccept)==null?void 0:u.map(A=>`.${A.toLowerCase()}`))!=null?f:[];async function I(A){var T,S,B;if(!p.config.parseTableFile)return;if(q.length>0){const F=A.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!q.includes(F))return}const D=bl(x,k("tableImporting",p));try{const F=await p.config.parseTableFile(A),ee=F.cells,O=(T=F.merges)!=null?T:[];if(O.length>0){const U=Dt(O,ee.length,(B=(S=ee[0])==null?void 0:S.length)!=null?B:0);if(U)throw new Error(U)}h.length=0,ee.forEach(U=>h.push([...U])),y.length=0,O.forEach(U=>y.push({...U})),v.anchor=null,v.focus=null,E(),M()}catch(F){const ee=F instanceof Error?F.message:String(F);console.error(k("tableImportError",p).replace("{error}",ee))}finally{D.remove()}}if(e.importAccept&&p.config.parseTableFile){const A=document.createElement("button");A.type="button",A.title=k("tableImportFile",p),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=`
888
1161
  position: absolute; top: 2px; left: 2px;
889
1162
  width: 20px; height: 20px;
890
1163
  padding: 0;
@@ -894,7 +1167,7 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
894
1167
  background: transparent;
895
1168
  cursor: pointer;
896
1169
  z-index: 2;
897
- `,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=F.join(","),T.style.display="none",b.appendChild(T),A.addEventListener("click",()=>{T.click()}),T.addEventListener("change",()=>{var B;const O=(B=T.files)==null?void 0:B[0];O&&V(O),T.value=""}),b.appendChild(A);let S=0;b.addEventListener("dragenter",B=>{B.preventDefault(),S++,S===1&&(b.style.outline="2px dashed var(--fb-primary-color, #0066cc)",b.style.outlineOffset="-2px")}),b.addEventListener("dragover",B=>{B.preventDefault(),B.dataTransfer&&(B.dataTransfer.dropEffect="copy")}),b.addEventListener("dragleave",B=>{B.preventDefault(),S--,S<=0&&(S=0,b.style.outline="",b.style.outlineOffset="")}),b.addEventListener("drop",B=>{var O,M;B.preventDefault(),S=0,b.style.outline="",b.style.outlineOffset="";const ee=(M=(O=B.dataTransfer)==null?void 0:O.files)==null?void 0:M[0];ee&&V(ee)})}o.appendChild(b);const R=document.createElement("div");R.style.cssText=`
1170
+ `,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=q.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&&I(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 ee=(F=(D=B.dataTransfer)==null?void 0:D.files)==null?void 0:F[0];ee&&I(ee)})}o.appendChild(x);const W=document.createElement("div");W.style.cssText=`
898
1171
  position: fixed;
899
1172
  display: none;
900
1173
  background: white;
@@ -905,7 +1178,7 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
905
1178
  z-index: 1000;
906
1179
  gap: 4px;
907
1180
  flex-direction: column;
908
- `,o.appendChild(R);function D(A,T){const S=document.createElement("button");return S.type="button",S.textContent=A,S.style.cssText=`
1181
+ `,o.appendChild(W);function V(A,T){const S=document.createElement("button");return S.type="button",S.textContent=A,S.style.cssText=`
909
1182
  padding: 4px 10px;
910
1183
  font-size: var(--fb-font-size-small);
911
1184
  color: var(--fb-text-color);
@@ -915,8 +1188,8 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
915
1188
  cursor: pointer;
916
1189
  white-space: nowrap;
917
1190
  text-align: left;
918
- `,S.addEventListener("mouseenter",()=>{S.style.background="var(--fb-background-hover-color)"}),S.addEventListener("mouseleave",()=>{S.style.background="transparent"}),S.addEventListener("click",()=>{Y(),T()}),S}function j(A,T){if(!g)return;R.innerHTML="",R.style.display="flex";const S=Se(x),B=S&&(S.r1!==S.r2||S.c1!==S.c2),O=x.anchor&&it(x.anchor.row,x.anchor.col,v);if(B&&R.appendChild(D($("tableMergeCells",f),q)),O&&R.appendChild(D($("tableSplitCell",f),z)),!R.firstChild){Y();return}const M=140,ee=R.children.length*32+8,P=window.innerWidth,W=window.innerHeight,K=A+M>P?A-M:A,X=T+ee>W?T-ee:T;R.style.left=`${K}px`,R.style.top=`${X}px`}function Y(){R.style.display="none"}const Me=new AbortController;document.addEventListener("mousedown",A=>{if(!o.isConnected){Me.abort();return}R.contains(A.target)||Y()},{signal:Me.signal});function fe(){const A=Se(x);w.querySelectorAll("td[data-row]").forEach(T=>{const S=parseInt(T.getAttribute("data-row")||"0",10),B=parseInt(T.getAttribute("data-col")||"0",10),O=x.anchor!==null&&x.anchor.row===S&&x.anchor.col===B,M=A!==null&&S>=A.r1&&S<=A.r2&&B>=A.c1&&B<=A.c2;T.style.outline=O?"2px solid var(--fb-primary-color, #0066cc)":"",T.style.outlineOffset=O?"-2px":"",S===0?T.style.backgroundColor="var(--fb-background-hover-color)":T.style.backgroundColor=M&&!O?"rgba(0,102,204,0.08)":""})}function Te(A,T){x.anchor={row:A,col:T},x.focus=null,fe(),w.focus()}function _e(A,T){const S=w.querySelector(`td[data-row="${A}"][data-col="${T}"]`);if(!S)return;const B=S.querySelector("span");B&&(x.anchor={row:A,col:T},x.focus=null,fe(),_o(B,A,T,()=>h,k,Te))}function we(A){var T;const S=h.length>0?h[0].length:(T=e.columns)!=null?T:3,B=Array(S).fill(""),O=A!==void 0?A+1:h.length;h.splice(O,0,B),v=v.map(M=>M.top>=O?{...M,top:M.top+1,bottom:M.bottom+1}:M.top<O&&M.bottom>=O?{...M,bottom:M.bottom+1}:M),k(),N()}function pt(A){if(h.length<=1)return;const T=A!==void 0?A:x.anchor?x.anchor.row:h.length-1;v=v.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),h.splice(T,1),x.anchor&&x.anchor.row>=h.length&&(x.anchor={row:h.length-1,col:x.anchor.col}),k(),N()}function Ke(A){var T,S;const B=A!==void 0?A+1:(S=(T=h[0])==null?void 0:T.length)!=null?S:0;h.forEach(O=>O.splice(B,0,"")),v=v.map(O=>O.left>=B?{...O,left:O.left+1,right:O.right+1}:O.left<B&&O.right>=B?{...O,right:O.right+1}:O),k(),N()}function L(A){if(h.length===0||h[0].length<=1)return;const T=A!==void 0?A:x.anchor?x.anchor.col:h[0].length-1;v=v.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),h.forEach(S=>S.splice(T,1)),x.anchor&&x.anchor.col>=h[0].length&&(x.anchor={row:x.anchor.row,col:h[0].length-1}),k(),N()}function q(){var A,T;if(!g)return;const S=Se(x);if(!S)return;const{r1:B,c1:O,r2:M,c2:ee}=S;if(B===M&&O===ee)return;v=v.filter(U=>!(U.top<=M&&U.bottom>=B&&U.left<=ee&&U.right>=O));const P=h[B][O];for(let U=B;U<=M;U++)for(let Z=O;Z<=ee;Z++)(U!==B||Z!==O)&&(h[U][Z]="");h[B][O]=P;const W={top:B,left:O,bottom:M,right:ee},K=[...v,W],X=Mt(K,h.length,(T=(A=h[0])==null?void 0:A.length)!=null?T:0);if(X){console.warn("Merge validation failed:",X);return}v.push(W),x.anchor={row:B,col:O},x.focus=null,k(),N()}function z(){if(!g||!x.anchor)return;const{row:A,col:T}=x.anchor,S=v.findIndex(B=>B.top===A&&B.left===T);S!==-1&&(v.splice(S,1),x.focus=null,k(),N())}function N(){var A,T;w.innerHTML="";const S=h.length,B=S>0?h[0].length:0,O=Se(x);for(let M=0;M<S;M++){const ee=(M===0?(A=w.tHead)!=null?A:w.createTHead():(T=w.tBodies[0])!=null?T:w.createTBody()).insertRow();for(let P=0;P<B;P++){if(On(M,P,v))continue;const W=it(M,P,v),K=document.createElement("td");if(K.setAttribute("data-row",String(M)),K.setAttribute("data-col",String(P)),W){const Q=W.bottom-W.top+1,J=W.right-W.left+1;Q>1&&(K.rowSpan=Q),J>1&&(K.colSpan=J)}const X=O!==null&&M>=O.r1&&M<=O.r2&&P>=O.c1&&P<=O.c2,U=x.anchor!==null&&x.anchor.row===M&&x.anchor.col===P;K.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;",M===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":"",X&&!U?"background-color: rgba(0,102,204,0.08);":"",U?"outline: 2px solid var(--fb-primary-color, #0066cc); outline-offset: -2px;":""].join(" ");const Z=document.createElement("span");Z.textContent=h[M][P],Z.style.cssText="display: block; min-height: 1.4em; white-space: pre-wrap; word-break: break-word; outline: none;",K.appendChild(Z);const G=M,re=P;K.addEventListener("mousedown",Q=>{if(Q.target.tagName!=="BUTTON"&&Q.target.contentEditable!=="true"){if(Q.button===2){const J=Se(x);if(J&&G>=J.r1&&G<=J.r2&&re>=J.c1&&re<=J.c2)return}Q.shiftKey&&x.anchor?(Q.preventDefault(),x.focus={row:G,col:re},x.dragging=!1,fe()):(x.anchor={row:G,col:re},x.focus=null,x.dragging=!0,fe())}}),K.addEventListener("mouseup",Q=>{if(Q.target.tagName!=="BUTTON"&&x.dragging){x.dragging=!1;const J=Se(x);(!J||J.r1===J.r2&&J.c1===J.c2)&&_e(G,re)}}),K.addEventListener("mousemove",Q=>{if(x.dragging&&Q.buttons===1){const J=x.anchor;J&&(J.row!==G||J.col!==re)&&(x.focus={row:G,col:re},fe())}}),K.addEventListener("contextmenu",Q=>{if(!g)return;const J=Se(x),ce=J&&(J.r1!==J.r2||J.c1!==J.c2),ue=x.anchor&&it(x.anchor.row,x.anchor.col,v);(ce||ue)&&(Q.preventDefault(),j(Q.clientX,Q.clientY))}),ee.appendChild(K)}}pe(),w.setAttribute("tabindex","0"),w.onkeydown=M=>{var ee,P;if(w.querySelector("[contenteditable='true']"))return;const W=x.anchor;if(!W)return;const K=h.length,X=K>0?h[0].length:0,U={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]};if(U[M.key]){M.preventDefault();const[Z,G]=U[M.key],re=Math.max(0,Math.min(K-1,W.row+Z)),Q=Math.max(0,Math.min(X-1,W.col+G));M.shiftKey?(x.focus={row:re,col:Q},fe()):Te(re,Q);return}if(M.key==="Enter"){M.preventDefault(),_e(W.row,W.col);return}if(M.key==="Tab"){M.preventDefault();const Z=(P=(ee=h[0])==null?void 0:ee.length)!=null?P:0;let G=W.row,re=M.shiftKey?W.col-1:W.col+1;re<0&&(re=Z-1,G=Math.max(0,G-1)),re>=Z&&(re=0,G=Math.min(h.length-1,G+1)),Te(G,re);return}if(g&&M.key==="m"&&M.ctrlKey&&!M.shiftKey){M.preventDefault(),q();return}g&&M.key==="M"&&M.ctrlKey&&M.shiftKey&&(M.preventDefault(),z())},w.oncopy=M=>{var ee,P,W,K;const X=Se(x);if(!X)return;M.preventDefault();const{r1:U,c1:Z,r2:G,c2:re}=X,Q=[],J=[];for(let _=U;_<=G;_++){const se=[],me=[];for(let he=Z;he<=re;he++){const ge=(P=(ee=h[_])==null?void 0:ee[he])!=null?P:"";se.push(ge);const Ne=ge.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");me.push(`<td>${Ne}</td>`)}Q.push(se.join(" ")),J.push(`<tr>${me.join("")}</tr>`)}const ce=Q.join(`
919
- `),ue=`<table>${J.join("")}</table>`;(W=M.clipboardData)==null||W.setData("text/plain",ce),(K=M.clipboardData)==null||K.setData("text/html",ue)},w.onpaste=M=>{var ee,P,W,K,X,U,Z,G,re;const Q=x.anchor;if(!Q)return;const J=(P=(ee=M.clipboardData)==null?void 0:ee.getData("text/plain"))!=null?P:"",ce=J.includes(" ")||J.split(/\r?\n/).filter(de=>de).length>1,ue=w.querySelector("[contenteditable='true']");if(ue&&!ce)return;if(M.preventDefault(),ue){ue.contentEditable="inherit";const de=parseInt((K=(W=ue.closest("td"))==null?void 0:W.getAttribute("data-row"))!=null?K:"0",10),Ae=parseInt((U=(X=ue.closest("td"))==null?void 0:X.getAttribute("data-col"))!=null?U:"0",10);h[de]&&(h[de][Ae]=(Z=ue.textContent)!=null?Z:"")}if(!J.trim())return;const _=J.split(/\r?\n/).map(de=>de.split(" "));_.length>1&&_[_.length-1].length===1&&_[_.length-1][0]===""&&_.pop();const se=Q.row,me=Q.col,he=se+_.length;for(;h.length<he;)h.push(Array((re=(G=h[0])==null?void 0:G.length)!=null?re:1).fill(""));const ge=Math.max(..._.map(de=>de.length)),Ne=me+ge;if(h[0]&&Ne>h[0].length){const de=Ne-h[0].length;h.forEach(Ae=>{for(let Je=0;Je<de;Je++)Ae.push("")})}for(let de=0;de<_.length;de++)for(let Ae=0;Ae<_[de].length;Ae++){const Je=se+de,Il=me+Ae;h[Je]&&(h[Je][Il]=_[de][Ae])}k(),N()}}const I=He({label:"+",title:$("tableAddColumn",f),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=I.dataset.afterCol)!=null?A:"0",10);Ke(T)}});I.style.position="absolute",I.style.display="none",b.appendChild(I);const H=He({label:"+",title:$("tableAddRow",f),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",b.appendChild(H);let te=[],ne=[];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",b.appendChild(ae);const ie=He({label:"+",title:$("tableAddRow",f),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>we()});ie.style.position="absolute",ie.style.display="none",b.appendChild(ie);function pe(){var A,T;te.forEach(P=>P.remove()),te=[],ne.forEach(P=>P.remove()),ne=[];const S=h.length>0?h[0].length:0,B=h.length;if(S>1){const P=Array.from(w.querySelectorAll("thead td[data-col]"));for(const W of P){const K=parseInt((A=W.getAttribute("data-col"))!=null?A:"0",10),X=He({label:"\xD7",title:$("tableRemoveColumn",f),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>L(K)});X.setAttribute("data-action","remove-col"),X.setAttribute("data-col",String(K)),X.style.position="absolute",X.style.display="none",b.appendChild(X),te.push(X)}}if(B>1){const P=[...w.tHead?Array.from(w.tHead.rows):[],...w.tBodies[0]?Array.from(w.tBodies[0].rows):[]].filter(W=>W.querySelector("td[data-row]"));for(const W of P){const K=W.querySelector("td[data-row]");if(!K)continue;const X=parseInt((T=K.getAttribute("data-row"))!=null?T:"0",10),U=He({label:"\xD7",title:$("tableRemoveRow",f),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>pt(X)});U.setAttribute("data-action","remove-row"),U.setAttribute("data-row",String(X)),U.style.position="absolute",U.style.display="none",b.appendChild(U),ne.push(U)}}function O(P,W,K,X,U){var Z;const G=U?Array.from(w.querySelectorAll("thead td[data-col]")):[];let re=-1,Q=1/0,J=-1,ce=-1,ue=1/0;for(let _=0;_<G.length;_++){const se=G[_].getBoundingClientRect(),me=(se.left+se.right)/2,he=Math.abs(P-me);he<Q&&(Q=he,re=_);const ge=Math.abs(P-se.right);ge<ue&&ge<20&&(ue=ge,J=se.right-W.left+X,ce=parseInt((Z=G[_].getAttribute("data-col"))!=null?Z:"0",10))}te.forEach((_,se)=>{if(!U||se!==re){_.style.display="none";return}const me=G[se].getBoundingClientRect(),he=(me.left+me.right)/2-W.left+X;_.style.left=`${he-8}px`,_.style.top="2px",_.style.display="flex"}),U&&ce>=0?(I.style.display="flex",I.style.left=`${J-10}px`,I.style.top=`${K.top-W.top-10}px`,I.dataset.afterCol=String(ce)):I.style.display="none"}function M(P,W,K,X,U){var Z;const G=[];if(U){if(w.tHead)for(const _ of Array.from(w.tHead.rows))_.querySelector("td[data-row]")&&G.push(_);if(w.tBodies[0])for(const _ of Array.from(w.tBodies[0].rows))_.querySelector("td[data-row]")&&G.push(_)}let re=-1,Q=1/0,J=-1,ce=-1,ue=1/0;for(let _=0;_<G.length;_++){const se=G[_].getBoundingClientRect(),me=(se.top+se.bottom)/2,he=Math.abs(P-me);he<Q&&(Q=he,re=_);const ge=Math.abs(P-se.bottom);if(ge<ue&&ge<14){ue=ge,J=se.bottom-W.top;const Ne=G[_].querySelector("td[data-row]");ce=parseInt((Z=Ne==null?void 0:Ne.getAttribute("data-row"))!=null?Z:"0",10)}}ne.forEach((_,se)=>{if(!U||se!==re){_.style.display="none";return}const me=G[se].getBoundingClientRect(),he=(me.top+me.bottom)/2-W.top;_.style.left="4px",_.style.top=`${he-8}px`,_.style.display="flex"}),U&&ce>=0?(H.style.display="flex",H.style.top=`${J-10}px`,H.style.left=`${K.left-W.left+X-10}px`,H.dataset.afterRow=String(ce)):H.style.display="none"}let ee=!1;b.onmousemove=P=>{const W=P.target;if(W.tagName==="BUTTON"&&W.parentElement===b||ee)return;ee=!0;const K=P.clientX,X=P.clientY;requestAnimationFrame(()=>{ee=!1;const U=b.getBoundingClientRect(),Z=w.getBoundingClientRect(),G=b.scrollLeft,re=X>=U.top&&X<Z.top+4,Q=K>=U.left&&K<Z.left+4,J=Math.min(Z.right,U.right),ce=K>J-20&&K<=U.right,ue=X>Z.bottom-4&&X<=U.bottom+20;if(O(K,U,Z,G,re),M(X,U,Z,G,Q),ae.style.display=ce?"flex":"none",ce&&(ae.style.left=`${U.right-U.left+G-20}px`,ae.style.top=`${(Z.top+Z.bottom)/2-U.top-10}px`),ie.style.display=ue?"flex":"none",ue){const _=(U.left+U.right)/2-U.left+G;ie.style.left=`${_-10}px`,ie.style.top=`${Z.bottom-U.top-10}px`}})},b.onmouseleave=()=>{te.forEach(P=>{P.style.display="none"}),ne.forEach(P=>{P.style.display="none"}),I.style.display="none",H.style.display="none",ae.style.display="none",ie.style.display="none"}}N()}function Go(e){var t,n;return{cells:jn((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function Nt(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function zt(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function Xo(e,t,n,r){var o,i,a,l;const u=t.state,s=oe(e,u,t),d=t.prefill[e.key],c=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",p=(l=(a=e.fieldNames)==null?void 0:a.merges)!=null?l:"merges";let f;if(Nt(d))f={cells:d.cells,merges:d.merges?Re(d.merges):[]};else if(d&&zt(d,c)){const m=d[p];f={cells:d[c],merges:m?Re(m):[]}}else if(Nt(e.default))f={cells:e.default.cells,merges:e.default.merges?Re(e.default.merges):[]};else if(e.default&&zt(e.default,c)){const m=e.default[p];f={cells:e.default[c],merges:m?Re(m):[]}}else f=Go(e);if(f.merges&&f.merges.length>0){const m=f.cells.length,g=m>0?f.cells[0].length:0,y=Mt(f.merges,m,g);y&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${y})`),f={...f,merges:[]})}s?Vo(f,n):Yo(e,f,r,t,n)}function Zo(e,t,n){var r,o;const{scopeRoot:i,skipValidation:a}=n,l=[],u=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",s=i.querySelector(`[name="${t}"]`);if(!s)return{value:null,errors:l};let d=null;try{d=JSON.parse(s.value)}catch(c){return l.push(`${t}: invalid table data`),{value:null,errors:l}}if(!a&&e.required){const c=d[u];c!=null&&c.some(p=>p.some(f=>f.trim()!==""))||l.push(`${t}: ${$("required",n.state)}`)}return{value:d,errors:l}}function Qo(e,t,n,r){var o,i,a,l;const{scopeRoot:u}=r,s=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",d=(l=(a=e.fieldNames)==null?void 0:a.merges)!=null?l:"merges",c=u.querySelector(`[name="${t}"]`);if(!c){console.warn(`updateTableField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let p=null;if(Nt(n))p={cells:n.cells,merges:n.merges?Re(n.merges):[]};else if(n&&zt(n,s)){const f=n[d];p={cells:n[s],merges:f?Re(f):[]}}p&&c._applyExternalUpdate?c._applyExternalUpdate(p):c.value=JSON.stringify(n)}function el(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 qt(e,t){var n,r,o,i;const a=new Map,l=new Map;for(const u of e){const s=t.resourceIndex.get(u),d=(n=s==null?void 0:s.name)!=null?n:u;l.set(d,((r=l.get(d))!=null?r:0)+1)}for(const u of e){const s=t.resourceIndex.get(u),d=(o=s==null?void 0:s.name)!=null?o:u;((i=l.get(d))!=null?i:1)>1&&s?a.set(u,`${d} (${cr(s.size)})`):a.set(u,d)}return a}function It(e){return e?e.type.startsWith("image/"):!1}function Un(e,t){const n=qt(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 at(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 a=e.slice(i,r);t.push({start:o,end:r,raw:e.slice(o,r),name:a})}}else r++;return t}function tl(e,t){if(t.size===0)return[];const n=at(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 nl(e,t){const n=tl(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 Pn(e,t,n){const r=qt(t,n),o=new Map;for(const u of t){const s=r.get(u);s&&o.set(u,s)}const i=at(e);if(i.length===0)return e;let a="",l=0;for(const u of i){a+=e.slice(l,u.start);const s=o.get(u.name);s?a+=Rt(s):a+=u.raw,l=u.end}return a+=e.slice(l),a}function Wn(e,t,n,r){if(be(e),n!=null&&n.file&&It(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=a=>{var l;o.src=((l=a.target)==null?void 0:l.result)||""},i.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(i=>{var a;if(!i||!e.isConnected)return;const l=document.createElement("img");l.alt=(a=n==null?void 0:n.name)!=null?a:t,l.src=i,l.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",be(e),e.appendChild(l)}).catch(i=>{var a,l;(l=(a=r.config).onThumbnailError)==null||l.call(a,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 Vn(e,t,n,r){if(be(e),n!=null&&n.file&&It(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=a=>{var l;o.src=((l=a.target)==null?void 0:l.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 a=document.createElement("img");a.alt=(i=n==null?void 0:n.name)!=null?i:t,a.src=o,a.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",be(e),e.appendChild(a)}).catch(o=>{var i,a;(a=(i=r.config).onThumbnailError)==null||a.call(i,o,t)})}function _n(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,a=n.bottom+8,l=i>=4?i:a;e.style.left=`${o}px`,e.style.top=`${Math.max(4,l)}px`}function Kn(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=`
1191
+ `,S.addEventListener("mouseenter",()=>{S.style.background="var(--fb-background-hover-color)"}),S.addEventListener("mouseleave",()=>{S.style.background="transparent"}),S.addEventListener("click",()=>{Q(),T()}),S}function J(A,T){if(!b)return;W.innerHTML="",W.style.display="flex";const S=ze(v),B=S&&(S.r1!==S.r2||S.c1!==S.c2),D=v.anchor&&ft(v.anchor.row,v.anchor.col,y);if(B&&W.appendChild(V(k("tableMergeCells",p),N)),D&&W.appendChild(V(k("tableSplitCell",p),z)),!W.firstChild){Q();return}const F=140,ee=W.children.length*32+8,O=window.innerWidth,U=window.innerHeight,_=A+F>O?A-F:A,X=T+ee>U?T-ee:T;W.style.left=`${_}px`,W.style.top=`${X}px`}function Q(){W.style.display="none"}const le=new AbortController;document.addEventListener("mousedown",A=>{if(!o.isConnected){le.abort();return}W.contains(A.target)||Q()},{signal:le.signal});function ae(){const A=ze(v);L.querySelectorAll("td[data-row]").forEach(T=>{const S=parseInt(T.getAttribute("data-row")||"0",10),B=parseInt(T.getAttribute("data-col")||"0",10),D=v.anchor!==null&&v.anchor.row===S&&v.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 fe(A,T){v.anchor={row:A,col:T},v.focus=null,ae(),L.focus()}function Ne(A,T){const S=L.querySelector(`td[data-row="${A}"][data-col="${T}"]`);if(!S)return;const B=S.querySelector("span");B&&(v.anchor={row:A,col:T},v.focus=null,ae(),ml(B,A,T,()=>h,E,fe))}function we(A){var T;const S=h.length>0?h[0].length:(T=e.columns)!=null?T:3,B=Array(S).fill(""),D=A!==void 0?A+1:h.length;h.splice(D,0,B),y=y.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),E(),M()}function _e(A){if(h.length<=1)return;const T=A!==void 0?A:v.anchor?v.anchor.row:h.length-1;y=y.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),h.splice(T,1),v.anchor&&v.anchor.row>=h.length&&(v.anchor={row:h.length-1,col:v.anchor.col}),E(),M()}function Ze(A){var T,S;const B=A!==void 0?A+1:(S=(T=h[0])==null?void 0:T.length)!=null?S:0;h.forEach(D=>D.splice(B,0,"")),y=y.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),E(),M()}function $(A){if(h.length===0||h[0].length<=1)return;const T=A!==void 0?A:v.anchor?v.anchor.col:h[0].length-1;y=y.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),h.forEach(S=>S.splice(T,1)),v.anchor&&v.anchor.col>=h[0].length&&(v.anchor={row:v.anchor.row,col:h[0].length-1}),E(),M()}function N(){var A,T;if(!b)return;const S=ze(v);if(!S)return;const{r1:B,c1:D,r2:F,c2:ee}=S;if(B===F&&D===ee)return;y=y.filter(j=>!(j.top<=F&&j.bottom>=B&&j.left<=ee&&j.right>=D));const O=h[B][D];for(let j=B;j<=F;j++)for(let G=D;G<=ee;G++)(j!==B||G!==D)&&(h[j][G]="");h[B][D]=O;const U={top:B,left:D,bottom:F,right:ee},_=[...y,U],X=Dt(_,h.length,(T=(A=h[0])==null?void 0:A.length)!=null?T:0);if(X){console.warn("Merge validation failed:",X);return}y.push(U),v.anchor={row:B,col:D},v.focus=null,E(),M()}function z(){if(!b||!v.anchor)return;const{row:A,col:T}=v.anchor,S=y.findIndex(B=>B.top===A&&B.left===T);S!==-1&&(y.splice(S,1),v.focus=null,E(),M())}function M(){var A,T;L.innerHTML="";const S=h.length,B=S>0?h[0].length:0,D=ze(v);for(let F=0;F<S;F++){const ee=(F===0?(A=L.tHead)!=null?A:L.createTHead():(T=L.tBodies[0])!=null?T:L.createTBody()).insertRow();for(let O=0;O<B;O++){if(er(F,O,y))continue;const U=ft(F,O,y),_=document.createElement("td");if(_.setAttribute("data-row",String(F)),_.setAttribute("data-col",String(O)),U){const Z=U.bottom-U.top+1,K=U.right-U.left+1;Z>1&&(_.rowSpan=Z),K>1&&(_.colSpan=K)}const X=D!==null&&F>=D.r1&&F<=D.r2&&O>=D.c1&&O<=D.c2,j=v.anchor!==null&&v.anchor.row===F&&v.anchor.col===O;_.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;":"",X&&!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=h[F][O],G.style.cssText="display: block; min-height: 1.4em; white-space: pre-wrap; word-break: break-word; outline: none;",_.appendChild(G);const Y=F,re=O;_.addEventListener("mousedown",Z=>{if(Z.target.tagName!=="BUTTON"&&Z.target.contentEditable!=="true"){if(Z.button===2){const K=ze(v);if(K&&Y>=K.r1&&Y<=K.r2&&re>=K.c1&&re<=K.c2)return}Z.shiftKey&&v.anchor?(Z.preventDefault(),v.focus={row:Y,col:re},v.dragging=!1,ae()):(v.anchor={row:Y,col:re},v.focus=null,v.dragging=!0,ae())}}),_.addEventListener("mouseup",Z=>{if(Z.target.tagName!=="BUTTON"&&v.dragging){v.dragging=!1;const K=ze(v);(!K||K.r1===K.r2&&K.c1===K.c2)&&Ne(Y,re)}}),_.addEventListener("mousemove",Z=>{if(v.dragging&&Z.buttons===1){const K=v.anchor;K&&(K.row!==Y||K.col!==re)&&(v.focus={row:Y,col:re},ae())}}),_.addEventListener("contextmenu",Z=>{if(!b)return;const K=ze(v),pe=K&&(K.r1!==K.r2||K.c1!==K.c2),de=v.anchor&&ft(v.anchor.row,v.anchor.col,y);(pe||de)&&(Z.preventDefault(),J(Z.clientX,Z.clientY))}),ee.appendChild(_)}}he(),L.setAttribute("tabindex","0"),L.onkeydown=F=>{var ee,O;if(L.querySelector("[contenteditable='true']"))return;const U=v.anchor;if(!U)return;const _=h.length,X=_>0?h[0].length:0,j={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]};if(j[F.key]){F.preventDefault();const[G,Y]=j[F.key],re=Math.max(0,Math.min(_-1,U.row+G)),Z=Math.max(0,Math.min(X-1,U.col+Y));F.shiftKey?(v.focus={row:re,col:Z},ae()):fe(re,Z);return}if(F.key==="Enter"){F.preventDefault(),Ne(U.row,U.col);return}if(F.key==="Tab"){F.preventDefault();const G=(O=(ee=h[0])==null?void 0:ee.length)!=null?O:0;let Y=U.row,re=F.shiftKey?U.col-1:U.col+1;re<0&&(re=G-1,Y=Math.max(0,Y-1)),re>=G&&(re=0,Y=Math.min(h.length-1,Y+1)),fe(Y,re);return}if(b&&F.key==="m"&&F.ctrlKey&&!F.shiftKey){F.preventDefault(),N();return}b&&F.key==="M"&&F.ctrlKey&&F.shiftKey&&(F.preventDefault(),z())},L.oncopy=F=>{var ee,O,U,_;const X=ze(v);if(!X)return;F.preventDefault();const{r1:j,c1:G,r2:Y,c2:re}=X,Z=[],K=[];for(let P=j;P<=Y;P++){const ue=[],be=[];for(let ve=G;ve<=re;ve++){const Ce=(O=(ee=h[P])==null?void 0:ee[ve])!=null?O:"";ue.push(Ce);const He=Ce.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");be.push(`<td>${He}</td>`)}Z.push(ue.join(" ")),K.push(`<tr>${be.join("")}</tr>`)}const pe=Z.join(`
1192
+ `),de=`<table>${K.join("")}</table>`;(U=F.clipboardData)==null||U.setData("text/plain",pe),(_=F.clipboardData)==null||_.setData("text/html",de)},L.onpaste=F=>{var ee,O,U,_,X,j,G,Y,re;const Z=v.anchor;if(!Z)return;const K=(O=(ee=F.clipboardData)==null?void 0:ee.getData("text/plain"))!=null?O:"",pe=K.includes(" ")||K.split(/\r?\n/).filter(me=>me).length>1,de=L.querySelector("[contenteditable='true']");if(de&&!pe)return;if(F.preventDefault(),de){de.contentEditable="inherit";const me=parseInt((_=(U=de.closest("td"))==null?void 0:U.getAttribute("data-row"))!=null?_:"0",10),qe=parseInt((j=(X=de.closest("td"))==null?void 0:X.getAttribute("data-col"))!=null?j:"0",10);h[me]&&(h[me][qe]=(G=de.textContent)!=null?G:"")}if(!K.trim())return;const P=K.split(/\r?\n/).map(me=>me.split(" "));P.length>1&&P[P.length-1].length===1&&P[P.length-1][0]===""&&P.pop();const ue=Z.row,be=Z.col,ve=ue+P.length;for(;h.length<ve;)h.push(Array((re=(Y=h[0])==null?void 0:Y.length)!=null?re:1).fill(""));const Ce=Math.max(...P.map(me=>me.length)),He=be+Ce;if(h[0]&&He>h[0].length){const me=He-h[0].length;h.forEach(qe=>{for(let Qe=0;Qe<me;Qe++)qe.push("")})}for(let me=0;me<P.length;me++)for(let qe=0;qe<P[me].length;qe++){const Qe=ue+me,ri=be+qe;h[Qe]&&(h[Qe][ri]=P[me][qe])}E(),M()}}const R=Pe({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=R.dataset.afterCol)!=null?A:"0",10);Ze(T)}});R.style.position="absolute",R.style.display="none",x.appendChild(R);const H=Pe({label:"+",title:k("tableAddRow",p),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 te=[],ne=[];const ce=Pe({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>Ze()});ce.style.position="absolute",ce.style.display="none",x.appendChild(ce);const se=Pe({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>we()});se.style.position="absolute",se.style.display="none",x.appendChild(se);function he(){var A,T;te.forEach(O=>O.remove()),te=[],ne.forEach(O=>O.remove()),ne=[];const S=h.length>0?h[0].length:0,B=h.length;if(S>1){const O=Array.from(L.querySelectorAll("thead td[data-col]"));for(const U of O){const _=parseInt((A=U.getAttribute("data-col"))!=null?A:"0",10),X=Pe({label:"\xD7",title:k("tableRemoveColumn",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>$(_)});X.setAttribute("data-action","remove-col"),X.setAttribute("data-col",String(_)),X.style.position="absolute",X.style.display="none",x.appendChild(X),te.push(X)}}if(B>1){const O=[...L.tHead?Array.from(L.tHead.rows):[],...L.tBodies[0]?Array.from(L.tBodies[0].rows):[]].filter(U=>U.querySelector("td[data-row]"));for(const U of O){const _=U.querySelector("td[data-row]");if(!_)continue;const X=parseInt((T=_.getAttribute("data-row"))!=null?T:"0",10),j=Pe({label:"\xD7",title:k("tableRemoveRow",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>_e(X)});j.setAttribute("data-action","remove-row"),j.setAttribute("data-row",String(X)),j.style.position="absolute",j.style.display="none",x.appendChild(j),ne.push(j)}}function D(O,U,_,X,j){var G;const Y=j?Array.from(L.querySelectorAll("thead td[data-col]")):[];let re=-1,Z=1/0,K=-1,pe=-1,de=1/0;for(let P=0;P<Y.length;P++){const ue=Y[P].getBoundingClientRect(),be=(ue.left+ue.right)/2,ve=Math.abs(O-be);ve<Z&&(Z=ve,re=P);const Ce=Math.abs(O-ue.right);Ce<de&&Ce<20&&(de=Ce,K=ue.right-U.left+X,pe=parseInt((G=Y[P].getAttribute("data-col"))!=null?G:"0",10))}te.forEach((P,ue)=>{if(!j||ue!==re){P.style.display="none";return}const be=Y[ue].getBoundingClientRect(),ve=(be.left+be.right)/2-U.left+X;P.style.left=`${ve-8}px`,P.style.top="2px",P.style.display="flex"}),j&&pe>=0?(R.style.display="flex",R.style.left=`${K-10}px`,R.style.top=`${_.top-U.top-10}px`,R.dataset.afterCol=String(pe)):R.style.display="none"}function F(O,U,_,X,j){var G;const Y=[];if(j){if(L.tHead)for(const P of Array.from(L.tHead.rows))P.querySelector("td[data-row]")&&Y.push(P);if(L.tBodies[0])for(const P of Array.from(L.tBodies[0].rows))P.querySelector("td[data-row]")&&Y.push(P)}let re=-1,Z=1/0,K=-1,pe=-1,de=1/0;for(let P=0;P<Y.length;P++){const ue=Y[P].getBoundingClientRect(),be=(ue.top+ue.bottom)/2,ve=Math.abs(O-be);ve<Z&&(Z=ve,re=P);const Ce=Math.abs(O-ue.bottom);if(Ce<de&&Ce<14){de=Ce,K=ue.bottom-U.top;const He=Y[P].querySelector("td[data-row]");pe=parseInt((G=He==null?void 0:He.getAttribute("data-row"))!=null?G:"0",10)}}ne.forEach((P,ue)=>{if(!j||ue!==re){P.style.display="none";return}const be=Y[ue].getBoundingClientRect(),ve=(be.top+be.bottom)/2-U.top;P.style.left="4px",P.style.top=`${ve-8}px`,P.style.display="flex"}),j&&pe>=0?(H.style.display="flex",H.style.top=`${K-10}px`,H.style.left=`${_.left-U.left+X-10}px`,H.dataset.afterRow=String(pe)):H.style.display="none"}let ee=!1;x.onmousemove=O=>{const U=O.target;if(U.tagName==="BUTTON"&&U.parentElement===x||ee)return;ee=!0;const _=O.clientX,X=O.clientY;requestAnimationFrame(()=>{ee=!1;const j=x.getBoundingClientRect(),G=L.getBoundingClientRect(),Y=x.scrollLeft,re=X>=j.top&&X<G.top+4,Z=_>=j.left&&_<G.left+4,K=Math.min(G.right,j.right),pe=_>K-20&&_<=j.right,de=X>G.bottom-4&&X<=j.bottom+20;if(D(_,j,G,Y,re),F(X,j,G,Y,Z),ce.style.display=pe?"flex":"none",pe&&(ce.style.left=`${j.right-j.left+Y-20}px`,ce.style.top=`${(G.top+G.bottom)/2-j.top-10}px`),se.style.display=de?"flex":"none",de){const P=(j.left+j.right)/2-j.left+Y;se.style.left=`${P-10}px`,se.style.top=`${G.bottom-j.top-10}px`}})},x.onmouseleave=()=>{te.forEach(O=>{O.style.display="none"}),ne.forEach(O=>{O.style.display="none"}),R.style.display="none",H.style.display="none",ce.style.display="none",se.style.display="none"}}M()}function gl(e){var t,n;return{cells:Qn((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function jt(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function Ot(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function yl(e,t,n,r){var o,a,i,l;const s=t.state,c=oe(e,s,t),d=t.prefill[e.key],u=(a=(o=e.fieldNames)==null?void 0:o.cells)!=null?a:"cells",f=(l=(i=e.fieldNames)==null?void 0:i.merges)!=null?l:"merges";let p;if(jt(d))p={cells:d.cells,merges:d.merges?Ue(d.merges):[]};else if(d&&Ot(d,u)){const m=d[f];p={cells:d[u],merges:m?Ue(m):[]}}else if(jt(e.default))p={cells:e.default.cells,merges:e.default.merges?Ue(e.default.merges):[]};else if(e.default&&Ot(e.default,u)){const m=e.default[f];p={cells:e.default[u],merges:m?Ue(m):[]}}else p=gl(e);if(p.merges&&p.merges.length>0){const m=p.cells.length,b=m>0?p.cells[0].length:0,g=Dt(p.merges,m,b);g&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${g})`),p={...p,merges:[]})}c?pl(p,n):vl(e,p,r,t,n)}function xl(e,t,n){var r,o;const{scopeRoot:a,skipValidation:i}=n,l=[],s=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",c=a.querySelector(`[name="${t}"]`);if(!c)return{value:null,errors:l};let d=null;try{d=JSON.parse(c.value)}catch(u){return l.push(`${t}: invalid table data`),{value:null,errors:l}}if(!i&&e.required){const u=d[s];u!=null&&u.some(f=>f.some(p=>p.trim()!==""))||l.push(`${t}: ${k("required",n.state)}`)}return{value:d,errors:l}}function wl(e,t,n,r){var o,a,i,l;const{scopeRoot:s}=r,c=(a=(o=e.fieldNames)==null?void 0:o.cells)!=null?a:"cells",d=(l=(i=e.fieldNames)==null?void 0:i.merges)!=null?l:"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 f=null;if(jt(n))f={cells:n.cells,merges:n.merges?Ue(n.merges):[]};else if(n&&Ot(n,c)){const p=n[d];f={cells:n[c],merges:p?Ue(p):[]}}f&&u._applyExternalUpdate?u._applyExternalUpdate(f):u.value=JSON.stringify(n)}function Cl(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 Ut(e,t){var n,r,o,a;const i=new Map,l=new Map;for(const s of e){const c=t.resourceIndex.get(s),d=(n=c==null?void 0:c.name)!=null?n:s;l.set(d,((r=l.get(d))!=null?r:0)+1)}for(const s of e){const c=t.resourceIndex.get(s),d=(o=c==null?void 0:c.name)!=null?o:s;((a=l.get(d))!=null?a:1)>1&&c?i.set(s,`${d} (${wr(c.size)})`):i.set(s,d)}return i}function Pt(e){return e?e.type.startsWith("image/"):!1}function tr(e,t){const n=Ut(e,t),r=new Map;for(const o of e){const a=n.get(o);a&&r.set(a,o)}return r}function Wt(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function pt(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 a="";for(;r<n&&e[r]!=='"';)e[r]==="\\"&&r+1<n?(a+=e[r+1],r+=2):(a+=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:a}))}else if(r<n&&!/\s/.test(e[r])){const a=r;for(;r<n&&!/\s/.test(e[r]);)r++;const i=e.slice(a,r);t.push({start:o,end:r,raw:e.slice(o,r),name:i})}}else r++;return t}function El(e,t){if(t.size===0)return[];const n=pt(e),r=[];for(const o of n){const a=t.get(o.name);a&&r.push({start:o.start,end:o.end,name:o.name,rid:a})}return r}function kl(e,t){const n=El(e,t);if(n.length===0)return e;let r="",o=0;for(const a of n)r+=e.slice(o,a.start),r+=`@${a.rid}`,o=a.end;return r+=e.slice(o),r}function nr(e,t,n){const r=Ut(t,n),o=new Map;for(const s of t){const c=r.get(s);c&&o.set(s,c)}const a=pt(e);if(a.length===0)return e;let i="",l=0;for(const s of a){i+=e.slice(l,s.start);const c=o.get(s.name);c?i+=Wt(c):i+=s.raw,l=s.end}return i+=e.slice(l),i}function rr(e,t,n,r){if(ge(e),n!=null&&n.file&&Pt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const a=new FileReader;a.onload=i=>{var l;o.src=((l=i.target)==null?void 0:l.result)||""},a.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(a=>{var i;if(!a||!e.isConnected)return;const l=document.createElement("img");l.alt=(i=n==null?void 0:n.name)!=null?i:t,l.src=a,l.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",ge(e),e.appendChild(l)}).catch(a=>{var i,l;(l=(i=r.config).onThumbnailError)==null||l.call(i,a,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 a=document.createElement("span");a.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);",a.textContent=n.name,o.appendChild(a)}e.appendChild(o)}}function or(e,t,n,r){if(ge(e),n!=null&&n.file&&Pt(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 a=new FileReader;a.onload=i=>{var l;o.src=((l=i.target)==null?void 0:l.result)||""},a.readAsDataURL(n.file),e.appendChild(o)}else r.config.getThumbnail&&r.config.getThumbnail(t).then(o=>{var a;if(!o||!e.isConnected)return;const i=document.createElement("img");i.alt=(a=n==null?void 0:n.name)!=null?a:t,i.src=o,i.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",ge(e),e.appendChild(i)}).catch(o=>{var a,i;(i=(a=r.config).onThumbnailError)==null||i.call(a,o,t)})}function lr(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)),a=n.top-r.height-8,i=n.bottom+8,l=a>=4?a:i;e.style.left=`${o}px`,e.style.top=`${Math.max(4,l)}px`}function ir(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=`
920
1193
  position: fixed;
921
1194
  z-index: 99999;
922
1195
  background: #fff;
@@ -927,7 +1200,7 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
927
1200
  pointer-events: none;
928
1201
  min-width: 60px;
929
1202
  max-width: 140px;
930
- `;const i=document.createElement("div");return i.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",Vn(i,t,r,n),o.appendChild(i),document.body.appendChild(o),_n(o,e),o}function Jn(e,t){var n,r;const{rid:o,state:i,isReadonly:a,onMention:l,onRemove:u}=t,s=i.resourceIndex.get(o),d=(n=s==null?void 0:s.name)!=null?n:o,c=document.createElement("div");c.className="fb-richinput-portal-tooltip fb-richinput-file-tooltip",c.style.cssText=`
1203
+ `;const a=document.createElement("div");return a.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",or(a,t,r,n),o.appendChild(a),document.body.appendChild(o),lr(o,e),o}function ar(e,t){var n,r;const{rid:o,state:a,isReadonly:i,onMention:l,onRemove:s}=t,c=a.resourceIndex.get(o),d=(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=`
931
1204
  position: fixed;
932
1205
  z-index: 99999;
933
1206
  background: #fff;
@@ -938,17 +1211,17 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
938
1211
  pointer-events: auto;
939
1212
  min-width: 80px;
940
1213
  max-width: 260px;
941
- `;const p=document.createElement("div");p.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",Vn(p,o,s,i),c.appendChild(p);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=d,c.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 g="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=h=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-text-color, #111827)"},C=h=>{h.style.background="none",h.style.color="var(--fb-text-muted-color, #6b7280)"};if(!a&&l){const h=document.createElement("button");h.type="button",h.title="Mention",h.style.cssText=g,h.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>',h.addEventListener("mouseenter",()=>y(h)),h.addEventListener("mouseleave",()=>C(h)),h.addEventListener("click",v=>{v.stopPropagation(),l(),c.remove()}),m.appendChild(h)}if(i.config.downloadFile){const h=document.createElement("button");h.type="button",h.title="Download",h.style.cssText=g,h.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>',h.addEventListener("mouseenter",()=>y(h)),h.addEventListener("mouseleave",()=>C(h)),h.addEventListener("click",v=>{var x,E;v.stopPropagation(),(E=(x=i.config).downloadFile)==null||E.call(x,o,d)}),m.appendChild(h)}if((r=i.config.getDownloadUrl)!=null?r:i.config.getThumbnail){const h=document.createElement("button");h.type="button",h.title="Open in new window",h.style.cssText=g,h.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>',h.addEventListener("mouseenter",()=>y(h)),h.addEventListener("mouseleave",()=>C(h)),h.addEventListener("click",v=>{var x,E,k,b;if(v.stopPropagation(),i.config.getDownloadUrl){const w=i.config.getDownloadUrl(o);w?window.open(w,"_blank"):(E=(x=i.config).getThumbnail)==null||E.call(x,o).then(F=>{F&&window.open(F,"_blank")}).catch(()=>{})}else(b=(k=i.config).getThumbnail)==null||b.call(k,o).then(w=>{w&&window.open(w,"_blank")}).catch(()=>{})}),m.appendChild(h)}if(!a&&u){const h=document.createElement("button");h.type="button",h.title="Remove",h.style.cssText=g,h.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>',h.addEventListener("mouseenter",()=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-error-color, #ef4444)"}),h.addEventListener("mouseleave",()=>C(h)),h.addEventListener("click",v=>{v.stopPropagation(),c.remove(),u()}),m.appendChild(h)}return m.children.length>0&&c.appendChild(m),document.body.appendChild(c),_n(c,e),c}function Yn(){return{element:null,hideTimer:null}}function st(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 rl(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 Gn(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 ct="font-size: var(--fb-font-size, 14px); font-family: var(--fb-font-family, inherit); line-height: 1.6;",Xn="padding: 8px 40px 8px 10px;";function ol(e,t,n,r,o){var i;const a=t.state,l=[...o.files],u={open:!1,query:"",triggerPos:-1,selectedIndex:0},s=new AbortController,d=document.createElement("input");d.type="hidden",d.name=r;function c(){var L,q;const z=b.value,N=Un(l,a),I=z?nl(z,N):null,H=(L=e.textKey)!=null?L:"text",te=(q=e.filesKey)!=null?q:"files";return{[H]:z===""?null:I,[te]:[...l]}}function p(){d.value=JSON.stringify(c())}const f=document.createElement("div");f.className="fb-richinput-wrapper",f.style.cssText=`
1214
+ `;const f=document.createElement("div");f.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",or(f,o,c,a),u.appendChild(f);const p=document.createElement("div");p.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);",p.textContent=d,u.appendChild(p);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;",g=h=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-text-color, #111827)"},w=h=>{h.style.background="none",h.style.color="var(--fb-text-muted-color, #6b7280)"};if(!i&&l){const h=document.createElement("button");h.type="button",h.title="Mention",h.style.cssText=b,h.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>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>w(h)),h.addEventListener("click",y=>{y.stopPropagation(),l(),u.remove()}),m.appendChild(h)}if(a.config.downloadFile){const h=document.createElement("button");h.type="button",h.title="Download",h.style.cssText=b,h.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>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>w(h)),h.addEventListener("click",y=>{var v,C;y.stopPropagation(),(C=(v=a.config).downloadFile)==null||C.call(v,o,d)}),m.appendChild(h)}if((r=a.config.getDownloadUrl)!=null?r:a.config.getThumbnail){const h=document.createElement("button");h.type="button",h.title="Open in new window",h.style.cssText=b,h.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>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>w(h)),h.addEventListener("click",y=>{var v,C,E,x;if(y.stopPropagation(),a.config.getDownloadUrl){const L=a.config.getDownloadUrl(o);L?window.open(L,"_blank"):(C=(v=a.config).getThumbnail)==null||C.call(v,o).then(q=>{q&&window.open(q,"_blank")}).catch(()=>{})}else(x=(E=a.config).getThumbnail)==null||x.call(E,o).then(L=>{L&&window.open(L,"_blank")}).catch(()=>{})}),m.appendChild(h)}if(!i&&s){const h=document.createElement("button");h.type="button",h.title="Remove",h.style.cssText=b,h.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>',h.addEventListener("mouseenter",()=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-error-color, #ef4444)"}),h.addEventListener("mouseleave",()=>w(h)),h.addEventListener("click",y=>{y.stopPropagation(),u.remove(),s()}),m.appendChild(h)}return m.children.length>0&&u.appendChild(m),document.body.appendChild(u),lr(u,e),u}function sr(){return{element:null,hideTimer:null}}function mt(e,t=150){e.hideTimer===null&&(e.hideTimer=setTimeout(()=>{e.hideTimer=null,e.element&&(e.element.remove(),e.element=null)},t))}function ht(e){e.hideTimer!==null&&(clearTimeout(e.hideTimer),e.hideTimer=null)}function We(e){return e&&e.remove(),null}function $l(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 a=r.slice(o+1);return a.startsWith('"')&&(a=a.slice(1)),{query:a,pos:o}}return null}return null}function cr(e,t,n){const r=e.toLowerCase();return t.filter(o=>{var a;return((a=n.get(o))!=null?a:o).toLowerCase().includes(r)})}const bt="font-size: var(--fb-font-size, 14px); font-family: var(--fb-font-family, inherit); line-height: 1.6;",ur="padding: 8px 40px 8px 10px;";function Ll(e,t,n,r,o){var a;const i=t.state,l=[...o.files],s={open:!1,query:"",triggerPos:-1,selectedIndex:0},c=new AbortController,d=document.createElement("input");d.type="hidden",d.name=r;function u(){var $,N;const z=x.value,M=tr(l,i),R=z?kl(z,M):null,H=($=e.textKey)!=null?$:"text",te=(N=e.filesKey)!=null?N:"files";return{[H]:z===""?null:R,[te]:[...l]}}function f(){d.value=JSON.stringify(u())}const p=document.createElement("div");p.className="fb-richinput-wrapper",p.style.cssText=`
942
1215
  position: relative;
943
1216
  border: 1px solid var(--fb-border-color, #d1d5db);
944
1217
  border-radius: 16px;
945
1218
  background: var(--fb-background-color, #f9fafb);
946
1219
  transition: box-shadow 0.15s, border-color 0.15s;
947
- `,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 10px 6px;";let g=null;function y(L){m.textContent=L,m.style.display="block",g&&clearTimeout(g),g=setTimeout(()=>{m.style.display="none",m.textContent="",g=null},5e3)}function C(L){var q;const z=$e(e.accept);if(!qe(L.name,z)){const I=z.join(", ");return y($("invalidFileExtension",a,{name:L.name,formats:I})),!1}const N=(q=e.maxSize)!=null?q:1/0;return Ze(L,N)?!0:(y($("fileTooLarge",a,{name:L.name,maxSize:N})),!1)}let h=0;f.addEventListener("dragenter",L=>{L.preventDefault(),h++,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(),h--,h<=0&&(h=0,f.style.borderColor="var(--fb-border-color, #d1d5db)",f.style.boxShadow="none")}),f.addEventListener("drop",L=>{var q,z;L.preventDefault(),h=0,f.style.borderColor="var(--fb-border-color, #d1d5db)",f.style.boxShadow="none";const N=(q=L.dataTransfer)==null?void 0:q.files;if(!N||!a.config.uploadFile)return;const I=(z=e.maxFiles)!=null?z:1/0;for(let H=0;H<N.length;H++){if(l.length>=I){y($("filesLimitExceeded",a,{skipped:N.length-H,max:I}));break}C(N[H])&&pt(N[H])}});const v=document.createElement("div");v.className="fb-richinput-files",v.style.cssText="display: none; flex-wrap: wrap; gap: 4px; padding: 6px 10px 0; align-items: center;";const x=document.createElement("input");x.type="file",x.multiple=!0,x.style.display="none",e.accept&&(typeof e.accept=="string"?x.accept=e.accept:x.accept=e.accept.extensions.map(L=>L.startsWith(".")?L:`.${L}`).join(","));const E=document.createElement("div");E.style.cssText="position: relative;";const k=document.createElement("div");k.className="fb-richinput-backdrop",k.style.cssText=`
1220
+ `,p.addEventListener("focusin",()=>{p.style.borderColor="var(--fb-primary-color, #0066cc)",p.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),p.addEventListener("focusout",()=>{p.style.borderColor="var(--fb-border-color, #d1d5db)",p.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 10px 6px;";let b=null;function g($){m.textContent=$,m.style.display="block",b&&clearTimeout(b),b=setTimeout(()=>{m.style.display="none",m.textContent="",b=null},5e3)}function w($){var N;const z=Fe(e.accept);if(!je($.name,z)){const R=z.join(", ");return g(k("invalidFileExtension",i,{name:$.name,formats:R})),!1}const M=(N=e.maxSize)!=null?N:1/0;return ot($,M)?!0:(g(k("fileTooLarge",i,{name:$.name,maxSize:M})),!1)}let h=0;p.addEventListener("dragenter",$=>{$.preventDefault(),h++,p.style.borderColor="var(--fb-primary-color, #0066cc)",p.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),p.addEventListener("dragover",$=>{$.preventDefault()}),p.addEventListener("dragleave",$=>{$.preventDefault(),h--,h<=0&&(h=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none")}),p.addEventListener("drop",$=>{var N,z;$.preventDefault(),h=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none";const M=(N=$.dataTransfer)==null?void 0:N.files;if(!M||!i.config.uploadFile)return;const R=(z=e.maxFiles)!=null?z:1/0;for(let H=0;H<M.length;H++){if(l.length>=R){g(k("filesLimitExceeded",i,{skipped:M.length-H,max:R}));break}w(M[H])&&_e(M[H])}});const y=document.createElement("div");y.className="fb-richinput-files",y.style.cssText="display: none; flex-wrap: wrap; gap: 4px; padding: 6px 10px 0; align-items: center;";const v=document.createElement("input");v.type="file",v.multiple=!0,v.style.display="none",e.accept&&(typeof e.accept=="string"?v.accept=e.accept:v.accept=e.accept.extensions.map($=>$.startsWith(".")?$:`.${$}`).join(","));const C=document.createElement("div");C.style.cssText="position: relative;";const E=document.createElement("div");E.className="fb-richinput-backdrop",E.style.cssText=`
948
1221
  position: absolute;
949
1222
  top: 0; left: 0; right: 0; bottom: 0;
950
- ${Xn}
951
- ${ct}
1223
+ ${ur}
1224
+ ${bt}
952
1225
  white-space: pre-wrap;
953
1226
  word-break: break-word;
954
1227
  color: transparent;
@@ -957,10 +1230,10 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
957
1230
  border-radius: inherit;
958
1231
  box-sizing: border-box;
959
1232
  z-index: 2;
960
- `;const b=document.createElement("textarea");b.name=`${r}__text`,b.placeholder=e.placeholder||$("richinputPlaceholder",a);const w=(i=o.text)!=null?i:"";b.value=w?Pn(w,l,a):"",b.style.cssText=`
1233
+ `;const x=document.createElement("textarea");x.name=`${r}__text`,x.placeholder=e.placeholder||k("richinputPlaceholder",i);const L=(a=o.text)!=null?a:"";x.value=L?nr(L,l,i):"",x.style.cssText=`
961
1234
  width: 100%;
962
- ${Xn}
963
- ${ct}
1235
+ ${ur}
1236
+ ${bt}
964
1237
  background: transparent;
965
1238
  border: none;
966
1239
  outline: none;
@@ -970,9 +1243,9 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
970
1243
  position: relative;
971
1244
  z-index: 1;
972
1245
  caret-color: var(--fb-text-color, #111827);
973
- `,el(b,k),b.addEventListener("scroll",()=>{k.scrollTop=b.scrollTop});let F=null;k.addEventListener("mouseover",L=>{var q,z;const N=(z=(q=L.target).closest)==null?void 0:z.call(q,"mark");N!=null&&N.dataset.rid&&(F=Be(F),F=Kn(N,N.dataset.rid,a))}),k.addEventListener("mouseout",L=>{var q,z,N;if(!((z=(q=L.target).closest)!=null&&z.call(q,"mark")))return;const I=L.relatedTarget;(N=I==null?void 0:I.closest)!=null&&N.call(I,"mark")||(F=Be(F))}),k.addEventListener("mousedown",L=>{var q,z;if(!((z=(q=L.target).closest)!=null&&z.call(q,"mark")))return;F=Be(F);const N=k.querySelectorAll("mark");N.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",()=>{N.forEach(H=>H.style.pointerEvents="auto")},{once:!0})});function V(){const L=b.value,q=Un(l,a),z=at(L);if(z.length===0){k.innerHTML=le(L)+`
974
- `;return}let N="",I=0;for(const H of z){N+=le(L.slice(I,H.start));const te=q.get(H.name);te?N+=`<mark data-rid="${le(te)}" 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;">${le(L.slice(H.start,H.end))}</mark>`:N+=`<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;">${le(L.slice(H.start,H.end))}</mark>`,I=H.end}N+=le(L.slice(I)),k.innerHTML=N+`
975
- `}const R=document.createElement("button");R.type="button",R.title=$("richinputAttachFile",a),R.style.cssText=`
1246
+ `,Cl(x,E),x.addEventListener("scroll",()=>{E.scrollTop=x.scrollTop});let q=null;E.addEventListener("mouseover",$=>{var N,z;const M=(z=(N=$.target).closest)==null?void 0:z.call(N,"mark");M!=null&&M.dataset.rid&&(q=We(q),q=ir(M,M.dataset.rid,i))}),E.addEventListener("mouseout",$=>{var N,z,M;if(!((z=(N=$.target).closest)!=null&&z.call(N,"mark")))return;const R=$.relatedTarget;(M=R==null?void 0:R.closest)!=null&&M.call(R,"mark")||(q=We(q))}),E.addEventListener("mousedown",$=>{var N,z;if(!((z=(N=$.target).closest)!=null&&z.call(N,"mark")))return;q=We(q);const M=E.querySelectorAll("mark");M.forEach(H=>H.style.pointerEvents="none");const R=document.elementFromPoint($.clientX,$.clientY);R&&R.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,clientX:$.clientX,clientY:$.clientY,button:$.button,buttons:$.buttons,detail:$.detail})),document.addEventListener("mouseup",()=>{M.forEach(H=>H.style.pointerEvents="auto")},{once:!0})});function I(){const $=x.value,N=tr(l,i),z=pt($);if(z.length===0){E.innerHTML=ie($)+`
1247
+ `;return}let M="",R=0;for(const H of z){M+=ie($.slice(R,H.start));const te=N.get(H.name);te?M+=`<mark data-rid="${ie(te)}" 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;">${ie($.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;">${ie($.slice(H.start,H.end))}</mark>`,R=H.end}M+=ie($.slice(R)),E.innerHTML=M+`
1248
+ `}const W=document.createElement("button");W.type="button",W.title=k("richinputAttachFile",i),W.style.cssText=`
976
1249
  position: absolute;
977
1250
  right: 6px;
978
1251
  bottom: 6px;
@@ -988,7 +1261,7 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
988
1261
  justify-content: center;
989
1262
  color: var(--fb-text-muted-color, #9ca3af);
990
1263
  transition: color 0.15s, background 0.15s;
991
- `,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 q=(L=e.maxFiles)!=null?L:1/0;if(l.length>=q){y($("filesLimitExceeded",a,{skipped:1,max:q}));return}x.click()});const D=document.createElement("div");D.className="fb-richinput-dropdown",D.style.cssText=`
1264
+ `,W.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>',W.addEventListener("mouseenter",()=>{W.style.color="var(--fb-primary-color, #0066cc)",W.style.background="var(--fb-background-hover-color, #f3f4f6)"}),W.addEventListener("mouseleave",()=>{W.style.color="var(--fb-text-muted-color, #9ca3af)",W.style.background="transparent"}),W.addEventListener("click",()=>{var $;const N=($=e.maxFiles)!=null?$:1/0;if(l.length>=N){g(k("filesLimitExceeded",i,{skipped:1,max:N}));return}v.click()});const V=document.createElement("div");V.className="fb-richinput-dropdown",V.style.cssText=`
992
1265
  display: none;
993
1266
  position: absolute;
994
1267
  bottom: 100%;
@@ -1003,16 +1276,16 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
1003
1276
  max-height: 200px;
1004
1277
  overflow-y: auto;
1005
1278
  margin-bottom: 4px;
1006
- ${ct}
1007
- `;function j(){return qt(l,a)}function Y(L){be(D);const q=j();if(L.length===0){D.style.display="none",u.open=!1;return}L.forEach((z,N)=>{var I;const H=a.resourceIndex.get(z),te=document.createElement("div");te.className="fb-richinput-dropdown-item",te.dataset.rid=z,te.style.cssText=`
1279
+ ${bt}
1280
+ `;function J(){return Ut(l,i)}function Q($){ge(V);const N=J();if($.length===0){V.style.display="none",s.open=!1;return}$.forEach((z,M)=>{var R;const H=i.resourceIndex.get(z),te=document.createElement("div");te.className="fb-richinput-dropdown-item",te.dataset.rid=z,te.style.cssText=`
1008
1281
  padding: 5px 10px;
1009
1282
  cursor: pointer;
1010
1283
  color: var(--fb-text-color, #111827);
1011
- background: ${N===u.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
1284
+ background: ${M===s.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
1012
1285
  display: flex;
1013
1286
  align-items: center;
1014
1287
  gap: 8px;
1015
- `;const ne=document.createElement("div");if(ne.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&&It(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),ne.appendChild(ie)}else a.config.getThumbnail&&a.config.getThumbnail(z).then(ie=>{if(!ie||!ne.isConnected)return;const pe=document.createElement("img");pe.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",pe.src=ie,be(ne),ne.appendChild(pe)}).catch(()=>{}),ne.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>';te.appendChild(ne);const ae=document.createElement("span");ae.style.cssText="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",ae.textContent=(I=q.get(z))!=null?I:z,te.appendChild(ae),D.appendChild(te)}),D.onmousemove=z=>{var N,I,H;const te=(I=(N=z.target).closest)==null?void 0:I.call(N,".fb-richinput-dropdown-item");if(!te)return;const ne=L.indexOf((H=te.dataset.rid)!=null?H:"");ne===-1||ne===u.selectedIndex||(D.querySelectorAll(".fb-richinput-dropdown-item").forEach((ae,ie)=>{ae.style.background=ie===ne?"var(--fb-background-hover-color, #f3f4f6)":"transparent"}),u.selectedIndex=ne)},D.onmousedown=z=>{var N,I;z.preventDefault(),z.stopPropagation();const H=(I=(N=z.target).closest)==null?void 0:I.call(N,".fb-richinput-dropdown-item");H!=null&&H.dataset.rid&&Te(H.dataset.rid)},D.style.display="block",u.open=!0}function Me(){const L=rl(b);if(!L){fe();return}u.query=L.query,u.triggerPos=L.pos,u.selectedIndex=0;const q=j(),z=Gn(L.query,l,q);Y(z)}function fe(){D.style.display="none",u.open=!1}function Te(L){var q,z,N,I;const H=(N=(z=j().get(L))!=null?z:(q=a.resourceIndex.get(L))==null?void 0:q.name)!=null?N:L,te=(I=b.selectionStart)!=null?I:0,ne=b.value.slice(0,u.triggerPos),ae=b.value.slice(te),ie=`${Rt(H)} `;b.value=`${ne}${ie}${ae}`;const pe=ne.length+ie.length;b.setSelectionRange(pe,pe),b.dispatchEvent(new Event("input")),fe()}b.addEventListener("input",()=>{var L;V(),p(),(L=t.instance)==null||L.triggerOnChange(r,c()),l.length>0?Me():fe()});function _e(){D.querySelectorAll(".fb-richinput-dropdown-item").forEach((L,q)=>{L.style.background=q===u.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}b.addEventListener("keydown",L=>{if(!u.open)return;const q=j(),z=Gn(u.query,l,q);L.key==="ArrowDown"?(L.preventDefault(),u.selectedIndex=Math.min(u.selectedIndex+1,z.length-1),_e()):L.key==="ArrowUp"?(L.preventDefault(),u.selectedIndex=Math.max(u.selectedIndex-1,0),_e()):L.key==="Enter"&&z.length>0?(L.preventDefault(),Te(z[u.selectedIndex])):L.key==="Escape"&&fe()}),document.addEventListener("click",L=>{!f.contains(L.target)&&!D.contains(L.target)&&fe()},{signal:s.signal});function we(){if(be(v),l.length===0){v.style.display="none";return}v.style.display="flex",l.forEach(L=>{const q=a.resourceIndex.get(L),z=document.createElement("div");z.className="fb-richinput-file-thumb",z.style.cssText=`
1288
+ `;const ne=document.createElement("div");if(ne.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&&Pt(H)){const se=document.createElement("img");se.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const he=new FileReader;he.onload=A=>{var T;se.src=((T=A.target)==null?void 0:T.result)||""},he.readAsDataURL(H.file),ne.appendChild(se)}else i.config.getThumbnail&&i.config.getThumbnail(z).then(se=>{if(!se||!ne.isConnected)return;const he=document.createElement("img");he.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",he.src=se,ge(ne),ne.appendChild(he)}).catch(()=>{}),ne.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>';te.appendChild(ne);const ce=document.createElement("span");ce.style.cssText="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",ce.textContent=(R=N.get(z))!=null?R:z,te.appendChild(ce),V.appendChild(te)}),V.onmousemove=z=>{var M,R,H;const te=(R=(M=z.target).closest)==null?void 0:R.call(M,".fb-richinput-dropdown-item");if(!te)return;const ne=$.indexOf((H=te.dataset.rid)!=null?H:"");ne===-1||ne===s.selectedIndex||(V.querySelectorAll(".fb-richinput-dropdown-item").forEach((ce,se)=>{ce.style.background=se===ne?"var(--fb-background-hover-color, #f3f4f6)":"transparent"}),s.selectedIndex=ne)},V.onmousedown=z=>{var M,R;z.preventDefault(),z.stopPropagation();const H=(R=(M=z.target).closest)==null?void 0:R.call(M,".fb-richinput-dropdown-item");H!=null&&H.dataset.rid&&fe(H.dataset.rid)},V.style.display="block",s.open=!0}function le(){const $=$l(x);if(!$){ae();return}s.query=$.query,s.triggerPos=$.pos,s.selectedIndex=0;const N=J(),z=cr($.query,l,N);Q(z)}function ae(){V.style.display="none",s.open=!1}function fe($){var N,z,M,R;const H=(M=(z=J().get($))!=null?z:(N=i.resourceIndex.get($))==null?void 0:N.name)!=null?M:$,te=(R=x.selectionStart)!=null?R:0,ne=x.value.slice(0,s.triggerPos),ce=x.value.slice(te),se=`${Wt(H)} `;x.value=`${ne}${se}${ce}`;const he=ne.length+se.length;x.setSelectionRange(he,he),x.dispatchEvent(new Event("input")),ae()}x.addEventListener("input",()=>{var $;I(),f(),($=t.instance)==null||$.triggerOnChange(r,u()),l.length>0?le():ae()});function Ne(){V.querySelectorAll(".fb-richinput-dropdown-item").forEach(($,N)=>{$.style.background=N===s.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}x.addEventListener("keydown",$=>{if(!s.open)return;const N=J(),z=cr(s.query,l,N);$.key==="ArrowDown"?($.preventDefault(),s.selectedIndex=Math.min(s.selectedIndex+1,z.length-1),Ne()):$.key==="ArrowUp"?($.preventDefault(),s.selectedIndex=Math.max(s.selectedIndex-1,0),Ne()):$.key==="Enter"&&z.length>0?($.preventDefault(),fe(z[s.selectedIndex])):$.key==="Escape"&&ae()}),document.addEventListener("click",$=>{!p.contains($.target)&&!V.contains($.target)&&ae()},{signal:c.signal});function we(){if(ge(y),l.length===0){y.style.display="none";return}y.style.display="flex",l.forEach($=>{const N=i.resourceIndex.get($),z=document.createElement("div");z.className="fb-richinput-file-thumb",z.style.cssText=`
1016
1289
  position: relative;
1017
1290
  width: 48px;
1018
1291
  height: 48px;
@@ -1022,14 +1295,14 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
1022
1295
  flex-shrink: 0;
1023
1296
  cursor: pointer;
1024
1297
  background: #fff;
1025
- `;const N=document.createElement("div");N.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",Wn(N,L,q,a),z.appendChild(N);const I=Yn(),H=()=>{var ne,ae,ie;const pe=(ne=b.selectionStart)!=null?ne:b.value.length,A=(ie=(ae=j().get(L))!=null?ae:q==null?void 0:q.name)!=null?ie:L,T=b.value.slice(0,pe),S=b.value.slice(pe),B=`${T.length>0&&!/[\s\n]$/.test(T)?`
1026
- `:""}${Rt(A)} `;b.value=`${T}${B}${S}`;const O=pe+B.length;b.setSelectionRange(O,O),b.focus(),b.dispatchEvent(new Event("input"))},te=()=>{var ne;const ae=l.indexOf(L);ae!==-1&&l.splice(ae,1),we(),V(),p(),(ne=t.instance)==null||ne.triggerOnChange(r,c())};z.addEventListener("mouseenter",()=>{ut(I),I.element||(I.element=Jn(z,{rid:L,state:a,isReadonly:!1,onMention:H,onRemove:te}),I.element.addEventListener("mouseenter",()=>{ut(I)}),I.element.addEventListener("mouseleave",()=>{st(I)}))}),z.addEventListener("mouseleave",()=>{st(I)}),v.appendChild(z)})}function pt(L){if(!a.config.uploadFile)return;const q=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;a.resourceIndex.set(q,{name:L.name,type:L.type,size:L.size,uploadedAt:new Date,file:L}),l.push(q),we();const z=v.querySelectorAll(".fb-richinput-file-thumb"),N=z[z.length-1];N&&(N.style.opacity="0.5"),a.config.uploadFile(L).then(I=>{var H;const te=l.indexOf(q);te!==-1&&(l[te]=I),a.resourceIndex.delete(q),a.resourceIndex.set(I,{name:L.name,type:L.type,size:L.size,uploadedAt:new Date,file:L}),we(),V(),p(),(H=t.instance)==null||H.triggerOnChange(r,c())}).catch(I=>{var H,te;const ne=l.indexOf(q);ne!==-1&&l.splice(ne,1),a.resourceIndex.delete(q),we(),(te=(H=a.config).onUploadError)==null||te.call(H,I,L)})}if(x.addEventListener("change",()=>{var L;const q=x.files;if(!q||q.length===0)return;const z=(L=e.maxFiles)!=null?L:1/0;for(let N=0;N<q.length;N++){if(l.length>=z){y($("filesLimitExceeded",a,{skipped:q.length-N,max:z}));break}C(q[N])&&pt(q[N])}x.value=""}),E.appendChild(k),E.appendChild(b),E.appendChild(R),E.appendChild(D),f.appendChild(v),f.appendChild(E),f.appendChild(m),e.minLength!=null||e.maxLength!=null){const L=document.createElement("div");L.style.cssText="position: relative; padding: 2px 10px 4px; text-align: right;";const q=je(e,b,!1);q.style.cssText=`
1298
+ `;const M=document.createElement("div");M.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",rr(M,$,N,i),z.appendChild(M);const R=sr(),H=()=>{var ne,ce,se;const he=(ne=x.selectionStart)!=null?ne:x.value.length,A=(se=(ce=J().get($))!=null?ce:N==null?void 0:N.name)!=null?se:$,T=x.value.slice(0,he),S=x.value.slice(he),B=`${T.length>0&&!/[\s\n]$/.test(T)?`
1299
+ `:""}${Wt(A)} `;x.value=`${T}${B}${S}`;const D=he+B.length;x.setSelectionRange(D,D),x.focus(),x.dispatchEvent(new Event("input"))},te=()=>{var ne;const ce=l.indexOf($);ce!==-1&&l.splice(ce,1),we(),I(),f(),(ne=t.instance)==null||ne.triggerOnChange(r,u())};z.addEventListener("mouseenter",()=>{ht(R),R.element||(R.element=ar(z,{rid:$,state:i,isReadonly:!1,onMention:H,onRemove:te}),R.element.addEventListener("mouseenter",()=>{ht(R)}),R.element.addEventListener("mouseleave",()=>{mt(R)}))}),z.addEventListener("mouseleave",()=>{mt(R)}),y.appendChild(z)})}function _e($){if(!i.config.uploadFile)return;const N=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;i.resourceIndex.set(N,{name:$.name,type:$.type,size:$.size,uploadedAt:new Date,file:$}),l.push(N),we();const z=y.querySelectorAll(".fb-richinput-file-thumb"),M=z[z.length-1];M&&(M.style.opacity="0.5"),i.config.uploadFile($).then(R=>{var H;const te=l.indexOf(N);te!==-1&&(l[te]=R),i.resourceIndex.delete(N),i.resourceIndex.set(R,{name:$.name,type:$.type,size:$.size,uploadedAt:new Date,file:$}),we(),I(),f(),(H=t.instance)==null||H.triggerOnChange(r,u())}).catch(R=>{var H,te;const ne=l.indexOf(N);ne!==-1&&l.splice(ne,1),i.resourceIndex.delete(N),we(),(te=(H=i.config).onUploadError)==null||te.call(H,R,$)})}if(v.addEventListener("change",()=>{var $;const N=v.files;if(!N||N.length===0)return;const z=($=e.maxFiles)!=null?$:1/0;for(let M=0;M<N.length;M++){if(l.length>=z){g(k("filesLimitExceeded",i,{skipped:N.length-M,max:z}));break}w(N[M])&&_e(N[M])}v.value=""}),C.appendChild(E),C.appendChild(x),C.appendChild(W),C.appendChild(V),p.appendChild(y),p.appendChild(C),p.appendChild(m),e.minLength!=null||e.maxLength!=null){const $=document.createElement("div");$.style.cssText="position: relative; padding: 2px 10px 4px; text-align: right;";const N=tt(e,x);N.style.cssText=`
1027
1300
  position: static;
1028
1301
  display: inline-block;
1029
1302
  font-size: var(--fb-font-size-small);
1030
1303
  color: var(--fb-text-secondary-color);
1031
1304
  pointer-events: none;
1032
- `,L.appendChild(q),f.appendChild(L)}f.appendChild(d),f.appendChild(x),p(),V(),d._applyExternalUpdate=L=>{var q;const z=(q=L.text)!=null?q:"";b.value=z?Pn(z,l,a):"",b.dispatchEvent(new Event("input")),l.length=0;for(const N of L.files)l.push(N);we(),V(),p()},n.appendChild(f),we();const Ke=new MutationObserver(()=>{f.isConnected||(s.abort(),F=Be(F),Ke.disconnect())});f.parentElement&&Ke.observe(f.parentElement,{childList:!0})}function ll(e,t,n,r,o){var i,a;const l=t.state,{text:u,files:s}=o,d=new Map;for(const c of s){const p=l.resourceIndex.get(c);p!=null&&p.name&&d.set(c,p.name)}if(s.length>0){const c=document.createElement("div");c.style.cssText="display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px;",s.forEach(p=>{const f=l.resourceIndex.get(p),m=document.createElement("div");m.style.cssText=`
1305
+ `,$.appendChild(N),p.appendChild($)}p.appendChild(d),p.appendChild(v),f(),I(),d._applyExternalUpdate=$=>{var N;const z=(N=$.text)!=null?N:"";x.value=z?nr(z,l,i):"",x.dispatchEvent(new Event("input")),l.length=0;for(const M of $.files)l.push(M);we(),I(),f()},n.appendChild(p),we();const Ze=new MutationObserver(()=>{p.isConnected||(c.abort(),q=We(q),Ze.disconnect())});p.parentElement&&Ze.observe(p.parentElement,{childList:!0})}function Sl(e,t,n,r,o){var a,i;const l=t.state,{text:s,files:c}=o,d=new Map;for(const u of c){const f=l.resourceIndex.get(u);f!=null&&f.name&&d.set(u,f.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(f=>{const p=l.resourceIndex.get(f),m=document.createElement("div");m.style.cssText=`
1033
1306
  position: relative;
1034
1307
  width: 48px; height: 48px;
1035
1308
  border: 1px solid var(--fb-border-color, #d1d5db);
@@ -1038,12 +1311,12 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
1038
1311
  flex-shrink: 0;
1039
1312
  background: #fff;
1040
1313
  cursor: default;
1041
- `;const g=document.createElement("div");g.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",Wn(g,p,f,l),m.appendChild(g);const y=Yn();m.addEventListener("mouseenter",()=>{ut(y),y.element||(y.element=Jn(m,{rid:p,state:l,isReadonly:!0}),y.element.addEventListener("mouseenter",()=>{ut(y)}),y.element.addEventListener("mouseleave",()=>{st(y)}))}),m.addEventListener("mouseleave",()=>{st(y)}),c.appendChild(m)}),n.appendChild(c)}if(u){const c=document.createElement("div");c.style.cssText=`
1042
- ${ct}
1314
+ `;const b=document.createElement("div");b.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",rr(b,f,p,l),m.appendChild(b);const g=sr();m.addEventListener("mouseenter",()=>{ht(g),g.element||(g.element=ar(m,{rid:f,state:l,isReadonly:!0}),g.element.addEventListener("mouseenter",()=>{ht(g)}),g.element.addEventListener("mouseleave",()=>{mt(g)}))}),m.addEventListener("mouseleave",()=>{mt(g)}),u.appendChild(m)}),n.appendChild(u)}if(s){const u=document.createElement("div");u.style.cssText=`
1315
+ ${bt}
1043
1316
  color: var(--fb-text-color, #111827);
1044
1317
  white-space: pre-wrap;
1045
1318
  word-break: break-word;
1046
- `;const p=at(u).filter(f=>d.has(f.name)||[...d.values()].includes(f.name));if(p.length===0)c.textContent=u;else{let f=0;for(const m of p){m.start>f&&c.appendChild(document.createTextNode(u.slice(f,m.start)));const g=document.createElement("span");g.style.cssText=`
1319
+ `;const f=pt(s).filter(p=>d.has(p.name)||[...d.values()].includes(p.name));if(f.length===0)u.textContent=s;else{let p=0;for(const m of f){m.start>p&&u.appendChild(document.createTextNode(s.slice(p,m.start)));const b=document.createElement("span");b.style.cssText=`
1047
1320
  display: inline;
1048
1321
  background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent);
1049
1322
  color: var(--fb-primary-color, #0066cc);
@@ -1051,7 +1324,7 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
1051
1324
  padding: 1px 6px;
1052
1325
  font-weight: 500;
1053
1326
  cursor: default;
1054
- `;const y=d.has(m.name)?m.name:(i=[...d.entries()].find(([,h])=>h===m.name))==null?void 0:i[0],C=(a=d.get(m.name))!=null?a:m.name;if(g.textContent=`@${C}`,y){let h=null;const v=y;g.addEventListener("mouseenter",()=>{h=Be(h),h=Kn(g,v,l)}),g.addEventListener("mouseleave",()=>{h=Be(h)})}c.appendChild(g),f=m.end}f<u.length&&c.appendChild(document.createTextNode(u.slice(f)))}n.appendChild(c)}if(!u&&s.length===0){const c=document.createElement("div");c.style.cssText="color: var(--fb-text-muted-color, #6b7280); font-size: var(--fb-font-size, 14px);",c.textContent="\u2014",n.appendChild(c)}}function il(e,t,n,r){var o,i,a,l;const u=t.state,s=oe(e,u,t),d=(o=e.textKey)!=null?o:"text",c=(i=e.filesKey)!=null?i:"files";let p;if(e.flatOutput){const f=t.prefill[d],m=t.prefill[c];p={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,g=(a=m[d])!=null?a:m.text,y=(l=m[c])!=null?l:m.files;p={text:typeof g=="string"?g:null,files:Array.isArray(y)?y:[]}}else typeof f=="string"?p={text:f||null,files:[]}:p={text:null,files:[]}}for(const f of p.files)u.resourceIndex.has(f)||u.resourceIndex.set(f,{name:f,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(s)ll(e,t,n,r,p);else{if(!u.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);ol(e,t,n,r,p)}}function al(e,t,n){var r,o;const{scopeRoot:i,state:a,skipValidation:l}=n,u=[],s=(r=e.textKey)!=null?r:"text",d=(o=e.filesKey)!=null?o:"files",c=i.querySelector(`[name="${t}"]`);if(!c)return{value:null,errors:u};let p={};try{const h=JSON.parse(c.value);if(h&&typeof h=="object"&&!Array.isArray(h))p=h;else return u.push(`${t}: invalid richinput data`),{value:null,errors:u}}catch(h){return u.push(`${t}: invalid richinput data`),{value:null,errors:u}}const f=p[s],m=p[d],g=f===null||typeof f=="string"?f:null,y=Array.isArray(m)?m:[],C={[s]:g!=null?g:null,[d]:y};if(!l){const h=!g||g.trim()==="",v=y.length===0;e.required&&h&&v&&u.push(`${t}: ${$("required",a)}`),!h&&g&&(e.minLength!=null&&g.length<e.minLength&&u.push(`${t}: ${$("minLength",a,{min:e.minLength})}`),e.maxLength!=null&&g.length>e.maxLength&&u.push(`${t}: ${$("maxLength",a,{max:e.maxLength})}`)),e.maxFiles!=null&&y.length>e.maxFiles&&u.push(`${t}: ${$("maxFiles",a,{max:e.maxFiles})}`)}return{value:C,errors:u,spread:!!e.flatOutput}}function sl(e,t,n,r){var o,i,a,l;const{scopeRoot:u}=r,s=u.querySelector(`[name="${t}"]`);if(!s){console.warn(`updateRichInputField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let d=null;if(n&&typeof n=="object"&&!Array.isArray(n)){const c=n,p=(o=e.textKey)!=null?o:"text",f=(i=e.filesKey)!=null?i:"files",m=(a=c[p])!=null?a:c.text,g=(l=c[f])!=null?l:c.files;(m!==void 0||g!==void 0)&&(d={text:typeof m=="string"?m:null,files:Array.isArray(g)?g:[]})}d&&s._applyExternalUpdate?s._applyExternalUpdate(d):d&&(s.value=JSON.stringify(d))}const ul={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function Zn(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function We(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 a=0,l,u,s,d,c;function p(m){const g=ul[m[1]||""],y=r[r.length-1]===m;return g?g[1]?(y?r.pop():r.push(m),g[y?1:0]):g[0]:m}function f(){let m="";for(;r.length;)m+=p(r[r.length-1]);return m}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,(m,g,y)=>(i[g.toLowerCase()]=y,"")).replace(/^\n+|\n+$/g,"");s=n.exec(e);)u=e.substring(a,s.index),a=n.lastIndex,l=s[0],u.match(/[^\\](\\\\)*\\$/)||((c=s[3]||s[4])?l='<pre class="code '+(s[4]?"poetry":s[2].toLowerCase())+'"><code'+(s[2]?` class="language-${s[2].toLowerCase()}"`:"")+">"+Zn(We(c).replace(/^\n+|\n+$/g,""))+"</code></pre>":(c=s[6])?(c.match(/\./)&&(s[5]=s[5].replace(/^\d+/gm,"")),d=Ht(Zn(s[5].replace(/^\s*[>*+.-]/gm,""))),c===">"?c="blockquote":(c=c.match(/\./)?"ol":"ul",d=d.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),l="<"+c+">"+d+"</"+c+">"):s[8]?l=`<img src="${We(s[8])}" alt="${We(s[7])}">`:s[10]?(o=o.replace("<a>",`<a href="${We(s[11]||i[u.toLowerCase()])}">`),l=f()+"</a>"):s[9]?l="<a>":s[12]||s[14]?(c="h"+(s[14]?s[14].length:s[13]>"="?1:2),l="<"+c+">"+Ht(s[12]||s[15],i)+"</"+c+">"):s[16]?l="<code>"+We(s[16])+"</code>":(s[17]||s[1])&&(l=p(s[17]||"--"))),o+=u,o+=l;return(o+e.substring(a)+f()).replace(/^\n+|\n+$/g,"")}const Qn="fb-markdown-styles";function cl(){if(typeof document=="undefined"||document.getElementById(Qn))return;const e=document.createElement("style");e.id=Qn,e.setAttribute("data-fb-markdown-styles","true"),e.textContent=`
1327
+ `;const g=d.has(m.name)?m.name:(a=[...d.entries()].find(([,h])=>h===m.name))==null?void 0:a[0],w=(i=d.get(m.name))!=null?i:m.name;if(b.textContent=`@${w}`,g){let h=null;const y=g;b.addEventListener("mouseenter",()=>{h=We(h),h=ir(b,y,l)}),b.addEventListener("mouseleave",()=>{h=We(h)})}u.appendChild(b),p=m.end}p<s.length&&u.appendChild(document.createTextNode(s.slice(p)))}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 Tl(e,t,n,r){var o,a,i,l;const s=t.state,c=oe(e,s,t),d=(o=e.textKey)!=null?o:"text",u=(a=e.filesKey)!=null?a:"files";let f;if(e.flatOutput){const p=t.prefill[d],m=t.prefill[u];f={text:typeof p=="string"?p:null,files:Array.isArray(m)?m:[]}}else{const p=t.prefill[e.key];if(p&&typeof p=="object"&&!Array.isArray(p)){const m=p,b=(i=m[d])!=null?i:m.text,g=(l=m[u])!=null?l:m.files;f={text:typeof b=="string"?b:null,files:Array.isArray(g)?g:[]}}else typeof p=="string"?f={text:p||null,files:[]}:f={text:null,files:[]}}for(const p of f.files)s.resourceIndex.has(p)||s.resourceIndex.set(p,{name:p,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(c)Sl(e,t,n,r,f);else{if(!s.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);Ll(e,t,n,r,f)}}function Al(e,t,n){var r,o;const{scopeRoot:a,state:i,skipValidation:l}=n,s=[],c=(r=e.textKey)!=null?r:"text",d=(o=e.filesKey)!=null?o:"files",u=a.querySelector(`[name="${t}"]`);if(!u)return{value:null,errors:s};let f={};try{const h=JSON.parse(u.value);if(h&&typeof h=="object"&&!Array.isArray(h))f=h;else return s.push(`${t}: invalid richinput data`),{value:null,errors:s}}catch(h){return s.push(`${t}: invalid richinput data`),{value:null,errors:s}}const p=f[c],m=f[d],b=p===null||typeof p=="string"?p:null,g=Array.isArray(m)?m:[],w={[c]:b!=null?b:null,[d]:g};if(!l){const h=!b||b.trim()==="",y=g.length===0;e.required&&h&&y&&s.push(`${t}: ${k("required",i)}`),!h&&b&&(e.minLength!=null&&b.length<e.minLength&&s.push(`${t}: ${k("minLength",i,{min:e.minLength})}`),e.maxLength!=null&&b.length>e.maxLength&&s.push(`${t}: ${k("maxLength",i,{max:e.maxLength})}`)),e.maxFiles!=null&&g.length>e.maxFiles&&s.push(`${t}: ${k("maxFiles",i,{max:e.maxFiles})}`)}return{value:w,errors:s,spread:!!e.flatOutput}}function Fl(e,t,n,r){var o,a,i,l;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 d=null;if(n&&typeof n=="object"&&!Array.isArray(n)){const u=n,f=(o=e.textKey)!=null?o:"text",p=(a=e.filesKey)!=null?a:"files",m=(i=u[f])!=null?i:u.text,b=(l=u[p])!=null?l:u.files;(m!==void 0||b!==void 0)&&(d={text:typeof m=="string"?m:null,files:Array.isArray(b)?b:[]})}d&&c._applyExternalUpdate?c._applyExternalUpdate(d):d&&(c.value=JSON.stringify(d))}const Ml={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function dr(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function Ge(e){return(e+"").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Vt(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 a=t||{};let i=0,l,s,c,d,u;function f(m){const b=Ml[m[1]||""],g=r[r.length-1]===m;return b?b[1]?(g?r.pop():r.push(m),b[g?1:0]):b[0]:m}function p(){let m="";for(;r.length;)m+=f(r[r.length-1]);return m}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,(m,b,g)=>(a[b.toLowerCase()]=g,"")).replace(/^\n+|\n+$/g,"");c=n.exec(e);)s=e.substring(i,c.index),i=n.lastIndex,l=c[0],s.match(/[^\\](\\\\)*\\$/)||((u=c[3]||c[4])?l='<pre class="code '+(c[4]?"poetry":c[2].toLowerCase())+'"><code'+(c[2]?` class="language-${c[2].toLowerCase()}"`:"")+">"+dr(Ge(u).replace(/^\n+|\n+$/g,""))+"</code></pre>":(u=c[6])?(u.match(/\./)&&(c[5]=c[5].replace(/^\d+/gm,"")),d=Vt(dr(c[5].replace(/^\s*[>*+.-]/gm,""))),u===">"?u="blockquote":(u=u.match(/\./)?"ol":"ul",d=d.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),l="<"+u+">"+d+"</"+u+">"):c[8]?l=`<img src="${Ge(c[8])}" alt="${Ge(c[7])}">`:c[10]?(o=o.replace("<a>",`<a href="${Ge(c[11]||a[s.toLowerCase()])}">`),l=p()+"</a>"):c[9]?l="<a>":c[12]||c[14]?(u="h"+(c[14]?c[14].length:c[13]>"="?1:2),l="<"+u+">"+Vt(c[12]||c[15],a)+"</"+u+">"):c[16]?l="<code>"+Ge(c[16])+"</code>":(c[17]||c[1])&&(l=f(c[17]||"--"))),o+=s,o+=l;return(o+e.substring(i)+p()).replace(/^\n+|\n+$/g,"")}const fr="fb-markdown-styles";function zl(){if(typeof document=="undefined"||document.getElementById(fr))return;const e=document.createElement("style");e.id=fr,e.setAttribute("data-fb-markdown-styles","true"),e.textContent=`
1055
1328
  .fb-markdown {
1056
1329
  font-family: var(--fb-font-family, inherit);
1057
1330
  font-size: var(--fb-font-size, 1rem);
@@ -1128,21 +1401,11 @@ var FormBuilder=(function(ke){"use strict";function $(e,t,n){const r=t.config.lo
1128
1401
  .fb-markdown strong { font-weight: var(--fb-font-weight-medium, 600); }
1129
1402
  .fb-markdown em { font-style: italic; }
1130
1403
  .fb-markdown s { text-decoration: line-through; }
1131
- `,document.head.appendChild(e)}const dl=["javascript:","data:","vbscript:","blob:"],fl=["javascript:","vbscript:","blob:"];function pl(e){return!!(fl.some(t=>e.startsWith(t))||e.startsWith("data:")&&!e.startsWith("data:image/"))}function ml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function hl(e){e.querySelectorAll("a[href]").forEach(t=>{var n;const r=((n=t.getAttribute("href"))!=null?n:"").trim().toLowerCase();dl.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();pl(r)&&t.setAttribute("src","")})}function bl(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})`);cl();const r=document.createElement("div");r.className="fb-markdown";const o=ml(e.content);return r.innerHTML=Ht(o),hl(r),n.appendChild(r),r}function vl(e,t,n){return{value:void 0,errors:[],skip:!0}}function gl(e,t,n,r){}function yl(e,t){const n=document.getElementById(e);if(!n)return;const r=!n.classList.contains("hidden");if(document.querySelectorAll('[id^="tooltip-"]').forEach(d=>{d.classList.add("hidden")}),r)return;const o=t.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight;n&&n.parentElement!==document.body&&document.body.appendChild(n),n.style.visibility="hidden",n.style.position="fixed",n.classList.remove("hidden");const l=n.getBoundingClientRect();n.classList.add("hidden"),n.style.visibility="visible";let u=o.left,s=o.bottom+5;u+l.width>i&&(u=o.right-l.width),s+l.height>a&&(s=o.top-l.height-5),u<10&&(u=10),s<10&&(s=o.bottom+5),n.style.left=`${u}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 er(e,t){var n,r,o;if(!e.enableIf)return!1;try{const i=(r=(n=t.formData)!=null?n:t.prefill)!=null?r:{},a=((o=e.enableIf.scope)!=null?o:"relative")==="relative"&&t.path?t.prefill:void 0;return!ze(e.enableIf,i,a)}catch(i){console.error(`Error evaluating enableIf for field "${e.key}":`,i)}return!1}function xl(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 dt(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 a=t.enableIf,l=(r=a.scope)!=null?r:"relative";let u={};const s={};if((!n.path||n.path===""?"absolute":l)==="relative"&&n.path){const d=n.path.match(/^(.+)\[(\d+)\]$/);if(d){const c=d[1],p=parseInt(d[2],10),f=i.querySelector(`[data-container-item="${c}[${p}]"]`);f&&f.querySelectorAll("input, select, textarea").forEach(m=>{const g=m.getAttribute("name");if(g){const y=g.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 d=a.key,c=xl(d,i);c!==void 0?u[d]=c:u=(o=n.formData)!=null?o:n.prefill}try{ze(a,u,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(d){console.error(`Error re-evaluating enableIf for field "${t.key}":`,d)}}function tr(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,a=(r=i.scope)!=null?r:"relative",l=i.key;let u;a==="relative"&&n.path?u=`${n.path}.${l}`:u=l;const s=o.querySelector(`[name="${u}"]`);if(!s){const d=new MutationObserver(()=>{const c=o.querySelector(`[name="${u}"]`);c&&(c.addEventListener("change",()=>{dt(e,t,n)}),c.addEventListener("input",()=>{dt(e,t,n)}),d.disconnect())});d.observe(o,{childList:!0,subtree:!0});return}s.addEventListener("change",()=>{dt(e,t,n)}),s.addEventListener("input",()=>{dt(e,t,n)})}function El(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 Cl(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(),yl(n,t)},t}function wl(e){const t=document.createElement("div");t.className="flex items-center mb-1";const n=El(e);if(t.appendChild(n),e.description||e.hint){const r=Cl(e);t.appendChild(r)}return t}function kl(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?pr(e,t,n,r):fr(e,t,n,r);break;case"textarea":o?hr(e,t,n,r):mr(e,t,n,r);break;case"number":o?yr(e,t,n,r):gr(e,t,n,r);break;case"select":o?wr(e,t,n,r):Cr(e,t,n,r);break;case"switcher":o?Sr(e,t,n,r):Lr(e,t,n,r);break;case"file":o?So(e,t,n,r):$o(e,t,n,r);break;case"files":Lo(e,t,n,r);break;case"colour":o?Ao(e,t,n,r):To(e,t,n,r);break;case"slider":o?zo(e,t,n,r):No(e,t,n,r);break;case"group":Do(e,t,n,r);break;case"container":o?In(e,t,n):qn(e,t,n,r);break;case"table":Xo(e,t,n,r);break;case"richinput":il(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 u=document.createElement("div");return u.style.display="none",u.setAttribute("data-fb-hidden-markdown","true"),u}const a=er(e,t),l=document.createElement("div");return l.className="mb-2 fb-field-wrapper fb-markdown-wrapper",l.setAttribute("data-field-key",ht(e,t.state)),bl(e,t,l),a&&(l.style.display="none",l.classList.add("fb-field-wrapper-disabled"),l.setAttribute("data-conditionally-disabled","true")),tr(l,e,t),l}const n=er(e,t),r=document.createElement("div");r.className="mb-2 fb-field-wrapper",r.setAttribute("data-field-key",e.key);const o=wl(e);r.appendChild(o);const i=ye(t.path,e.key);return kl(e,t,r,i),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),tr(r,e,t),r}Ro(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",fileCountWithMax:"{count} / {max} files",fileCountRange:"({min}-{max})",uploadingFile:"Uploading\u2026",filesCounter:"{count}/{max}",fromLibrary:"From library",libraryEmpty:"Library is empty",libraryHint:"Choose from previously uploaded files",dropToUpload:"Release to upload",replaceFile:"Replace",clearAll:"Clear all",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",fileCountWithMax:"{count} / {max} \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",dropToUpload:"\u041E\u0442\u043F\u0443\u0441\u0442\u0438\u0442\u0435, \u0447\u0442\u043E\u0431\u044B \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C",replaceFile:"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C",clearAll:"\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0432\u0441\u0435",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 $l(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 Ll(){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.5rem",inputPaddingY:"0.25rem",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 Sl(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(`
1132
- `)}function Tl(e,t){const n=Sl(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=`
1404
+ `,document.head.appendChild(e)}const Nl=["javascript:","data:","vbscript:","blob:"],ql=["javascript:","vbscript:","blob:"];function Il(e){return!!(ql.some(t=>e.startsWith(t))||e.startsWith("data:")&&!e.startsWith("data:image/"))}function Rl(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Hl(e){e.querySelectorAll("a[href]").forEach(t=>{var n;const r=((n=t.getAttribute("href"))!=null?n:"").trim().toLowerCase();Nl.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();Il(r)&&t.setAttribute("src","")})}function Bl(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})`);zl();const r=document.createElement("div");r.className="fb-markdown";const o=Rl(e.content);return r.innerHTML=Vt(o),Hl(r),n.appendChild(r),r}function Dl(e,t,n){return{value:void 0,errors:[],skip:!0}}function jl(e,t,n,r){}function Ol(e,t,n){var r;const{scopeRoot:o}=n,a=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`),i=(r=a==null?void 0:a.value)!=null?r:"";if(i===""){const l="default"in e?e.default:null;return{value:l!==void 0?l:null,errors:[]}}return{value:Xt(i),errors:[]}}function Ul(e,t,n,r){const{scopeRoot:o}=r,a=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);a&&(a.value=Yt(n))}const Pl={text:{validate:Qt,update:en},textarea:{validate:Mr,update:zr},number:{validate:Hr,update:Br},select:{validate:Or,update:Ur},switcher:{validate:_r,update:Kr},boolean:{validate:Xr,update:Gr,ownsLabel:!0},file:{validate:Rn,update:Bn},files:{validate:Rn,update:Bn},colour:{validate:Zo,update:Qo},slider:{validate:nl,update:rl},container:{validate:Xn,update:Gn},group:{validate:sl,update:cl},table:{validate:xl,update:wl},richinput:{validate:Al,update:Fl},hidden:{validate:Ol,update:Ul},markdown:{validate:Dl,update:jl}};function _t(e){return Pl[e]||null}function Wl(e,t,n){const r=_t(e.type);return r&&r.validate?r.validate(e,t,n):null}function Vl(e,t,n,r){const o=_t(e.type);return o&&o.update?(o.update(e,t,n,r),!0):!1}function _l(e,t){const n=document.getElementById(e);if(!n)return;const r=!n.classList.contains("hidden");if(document.querySelectorAll('[id^="tooltip-"]').forEach(d=>{d.classList.add("hidden")}),r)return;const o=t.getBoundingClientRect(),a=window.innerWidth,i=window.innerHeight;n&&n.parentElement!==document.body&&document.body.appendChild(n),n.style.visibility="hidden",n.style.position="fixed",n.classList.remove("hidden");const l=n.getBoundingClientRect();n.classList.add("hidden"),n.style.visibility="visible";let s=o.left,c=o.bottom+5;s+l.width>a&&(s=o.right-l.width),c+l.height>i&&(c=o.top-l.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 pr(e,t){var n,r,o;if(!e.enableIf)return!1;try{const a=(r=(n=t.formData)!=null?n:t.prefill)!=null?r:{},i=((o=e.enableIf.scope)!=null?o:"relative")==="relative"&&t.path?t.prefill:void 0;return!Be(e.enableIf,a,i)}catch(a){console.error(`Error evaluating enableIf for field "${e.key}":`,a)}return!1}function Kl(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 vt(e,t,n){var r,o;if(!t.enableIf)return;const a=n.state.formRoot;if(!a){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const i=t.enableIf,l=(r=i.scope)!=null?r:"relative";let s={};const c={};if((!n.path||n.path===""?"absolute":l)==="relative"&&n.path){const d=n.path.match(/^(.+)\[(\d+)\]$/);if(d){const u=d[1],f=parseInt(d[2],10),p=a.querySelector(`[data-container-item="${u}[${f}]"]`);p&&p.querySelectorAll("input, select, textarea").forEach(m=>{const b=m.getAttribute("name");if(b){const g=b.match(/\.([^.[\]]+)$/);if(g){const w=g[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 d=i.key,u=Kl(d,a);u!==void 0?s[d]=u:s=(o=n.formData)!=null?o:n.prefill}try{Be(i,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(d){console.error(`Error re-evaluating enableIf for field "${t.key}":`,d)}}function mr(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 a=t.enableIf,i=(r=a.scope)!=null?r:"relative",l=a.key;let s;i==="relative"&&n.path?s=`${n.path}.${l}`:s=l;const c=o.querySelector(`[name="${s}"]`);if(!c){const d=new MutationObserver(()=>{const u=o.querySelector(`[name="${s}"]`);u&&(u.addEventListener("change",()=>{vt(e,t,n)}),u.addEventListener("input",()=>{vt(e,t,n)}),d.disconnect())});d.observe(o,{childList:!0,subtree:!0});return}c.addEventListener("change",()=>{vt(e,t,n)}),c.addEventListener("input",()=>{vt(e,t,n)})}function Jl(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 Yl(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(),_l(n,t)},t}function Xl(e){const t=document.createElement("div");t.className="flex items-center mb-1",t.dataset.fbLabelRow="";const n=Jl(e);if(t.appendChild(n),e.description||e.hint){const r=Yl(e);t.appendChild(r)}return t}function Gl(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?Tr(e,t,n,r):Sr(e,t,n,r);break;case"textarea":o?Fr(e,t,n,r):Ar(e,t,n,r);break;case"number":o?Rr(e,t,n,r):Ir(e,t,n,r);break;case"select":o?jr(e,t,n,r):Dr(e,t,n,r);break;case"switcher":o?Vr(e,t,n,r):Wr(e,t,n,r);break;case"boolean":Yr(e,t,n,r);break;case"file":o?Yo(e,t,n,r):Ko(e,t,n,r);break;case"files":Jo(e,t,n,r);break;case"colour":o?Go(e,t,n,r):Xo(e,t,n,r);break;case"slider":o?tl(e,t,n,r):el(e,t,n,r);break;case"group":al(e,t,n,r);break;case"container":o?Jn(e,t,n):Kn(e,t,n,r);break;case"table":yl(e,t,n,r);break;case"richinput":Tl(e,t,n,r);break;default:{const a=document.createElement("div");a.className="text-red-500 text-sm",a.textContent=k("unsupportedFieldType",t.state,{type:e.type}),n.appendChild(a)}}}function Kt(e,t){if(e.type==="markdown"){if(e.hidden===!0){const s=document.createElement("div");return s.style.display="none",s.setAttribute("data-fb-hidden-markdown","true"),s}const i=pr(e,t),l=document.createElement("div");return l.className="mb-2 fb-field-wrapper fb-markdown-wrapper",l.setAttribute("data-field-key",xt(e,t.state)),Bl(e,t,l),i&&(l.style.display="none",l.classList.add("fb-field-wrapper-disabled"),l.setAttribute("data-conditionally-disabled","true")),mr(l,e,t),l}const n=pr(e,t),r=document.createElement("div");r.className="mb-2 fb-field-wrapper",r.setAttribute("data-field-key",e.key);const o=_t(e.type);if(!(o!=null&&o.ownsLabel)){const i=Xl(e);r.appendChild(i)}const a=ke(t.path,e.key);return Gl(e,t,r,a),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),mr(r,e,t),r}ol(Kt);const Jt={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",fileCountWithMax:"{count} / {max} files",fileCountRange:"({min}-{max})",uploadingFile:"Uploading\u2026",filesCounter:"{count}/{max}",fromLibrary:"From library",libraryEmpty:"Library is empty",libraryHint:"Choose from previously uploaded files",dropToUpload:"Release to upload",replaceFile:"Replace",clearAll:"Clear all",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',uploadFailed:'Failed to upload "{name}": {error}',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",fileCountWithMax:"{count} / {max} \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",dropToUpload:"\u041E\u0442\u043F\u0443\u0441\u0442\u0438\u0442\u0435, \u0447\u0442\u043E\u0431\u044B \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C",replaceFile:"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C",clearAll:"\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0432\u0441\u0435",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',uploadFailed:'\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C "{name}": {error}',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 Zl(e){const t={...Jt.translations};if(e!=null&&e.translations)for(const[n,r]of Object.entries(e.translations))t[n]={...Jt.translations[n]||{},...r};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...Jt,...e,translations:t},debounceTimer:null,prefill:{},syntheticElementIds:new WeakMap,syntheticElementIdCounter:0}}function Ql(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const Ve={primaryColor:"#3b82f6",primaryHoverColor:"#2563eb",primarySoftColor:"#dbeafe",primarySoftHoverColor:"#bfdbfe",errorColor:"#ef4444",errorHoverColor:"#dc2626",successColor:"#10b981",accentColor:"#f59e0b",accentSoftColor:"#fef3c7",accentBorderColor:"#fde68a",accentTextColor:"#92400e",borderColor:"#d1d5db",borderHoverColor:"#9ca3af",borderFocusColor:"#3b82f6",borderStrongColor:"#9ca3af",backgroundColor:"#ffffff",backgroundHoverColor:"#f9fafb",backgroundReadonlyColor:"#f3f4f6",pageBackgroundColor:"#f9fafb",surfaceSoftColor:"#eff6ff",surfaceTintColor:"#f8fafc",textColor:"#1f2937",textSecondaryColor:"#6b7280",textMutedColor:"#9ca3af",textFaintColor:"#cbd5e1",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.5rem",inputPaddingY:"0.25rem",borderRadius:"0.5rem",borderRadiusSmall:"0.375rem",borderRadiusLarge:"0.75rem",borderRadiusXLarge:"1rem",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",lineHeight:"1.5",shadowCard:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",shadowPopover:"0 12px 32px -12px rgba(15,23,42,.18), 0 4px 12px -6px rgba(15,23,42,.08)",focusRingWidth:"2px",focusRingColor:"#3b82f6",focusRingOpacity:"0.5",transitionDuration:"200ms",slideCardBg:"#ffffff",slideCardShadow:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",slideCardRadius:"0.5rem",slideCardMinHeight:"0",slideCardPadding:"12px",labelSectionFontSize:"0.875rem",labelSectionLetterSpacing:"normal",labelSectionTextTransform:"none"};function ei(e){const t={...Ve,...e},n=[];return Object.entries(t).forEach(([r,o])=>{const a=r.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(` --fb-${a}: ${o};`)}),n.join(`
1405
+ `)}function ti(e,t){Er(e.ownerDocument||document);const n=ei(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=`
1133
1406
  [data-fb-root="true"] {
1134
1407
  ${n}
1135
1408
  }
1136
- `}const Al={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 nr(e,t=!1){e.style.cssText=`
1137
- background-color: var(--fb-action-bg-color);
1138
- color: var(--fb-action-text-color);
1139
- border: var(--fb-border-width) solid var(--fb-action-border-color);
1140
- padding: ${t?"0.5rem 1rem":"0.5rem 0.75rem"};
1141
- font-size: var(--fb-font-size);
1142
- font-weight: var(--fb-font-weight-medium);
1143
- border-radius: var(--fb-border-radius);
1144
- transition: all var(--fb-transition-duration);
1145
- box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
1146
- `,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 Fl(e,t,n){var r;const{scopeRoot:o}=n,i=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`),a=(r=i==null?void 0:i.value)!=null?r:"";if(a===""){const l="default"in e?e.default:null;return{value:l!==void 0?l:null,errors:[]}}return{value:Ot(a),errors:[]}}function Ml(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 Nl={text:{validate:Ut,update:Pt},textarea:{validate:br,update:vr},number:{validate:xr,update:Er},select:{validate:kr,update:$r},switcher:{validate:Tr,update:Ar},file:{validate:wn,update:$n},files:{validate:wn,update:$n},colour:{validate:Fo,update:Mo},slider:{validate:qo,update:Io},container:{validate:Hn,update:Bn},group:{validate:jo,update:Oo},table:{validate:Zo,update:Qo},richinput:{validate:al,update:sl},hidden:{validate:Fl,update:Ml},markdown:{validate:vl,update:gl}};function rr(e){return Nl[e]||null}function zl(e,t,n){const r=rr(e.type);return r&&r.validate?r.validate(e,t,n):null}function ql(e,t,n,r){const o=rr(e.type);return o&&o.update?(o.update(e,t,n,r),!0):!1}class ft{constructor(t){this.instanceId=Ll(),this.state=$l(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 a of i)if(o=this.state.formRoot.querySelector(`[name="${a}"]`),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,a=o.querySelector("label");if(a&&(a.textContent===i||a.textContent===`${i}*`)){let l=o.querySelector(".field-placeholder");return l||(l=document.createElement("div"),l.className="field-placeholder",l.style.display="none",o.appendChild(l)),l}}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(a=>a.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(a=>a.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(a=>a.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-3 pt-2 flex flex-wrap gap-2 justify-center",o.style.cssText=`
1409
+ `}const ni={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'},picaz:{...Ve,primaryColor:"#2f5bea",primaryHoverColor:"#2349c8",primarySoftColor:"#eaf0ff",primarySoftHoverColor:"#d6e0ff",errorColor:"#ef4444",successColor:"#16a34a",accentColor:"#ffb020",accentSoftColor:"#fff7e6",accentBorderColor:"#fde7b5",accentTextColor:"#92400e",borderColor:"#e3e8f0",borderHoverColor:"#cdd6e3",borderFocusColor:"#2f5bea",borderStrongColor:"#cdd6e3",backgroundColor:"#ffffff",backgroundHoverColor:"#f3f7ff",pageBackgroundColor:"#f6f8fb",surfaceSoftColor:"#eef4ff",surfaceTintColor:"#f3f7ff",textColor:"#0f172a",textSecondaryColor:"#334155",textMutedColor:"#64748b",textFaintColor:"#94a3b8",textPlaceholderColor:"#94a3b8",buttonBgColor:"#2f5bea",buttonHoverBgColor:"#2349c8",fileUploadBgColor:"#fafcff",fileUploadBorderColor:"#cdd6e3",fileUploadHoverBorderColor:"#2f5bea",borderRadius:"12px",borderRadiusSmall:"8px",borderRadiusLarge:"16px",borderRadiusXLarge:"22px",fontFamily:'"Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',shadowCard:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",shadowPopover:"0 12px 32px -12px rgba(15,23,42,.18), 0 4px 12px -6px rgba(15,23,42,.08)",focusRingColor:"#2f5bea"}};class gt{constructor(t){this.instanceId=Ql(),this.state=Zl(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;let n=this.state.formRoot.querySelector(`[name="${t}"]`);if(n)return n;const r=[t,t.replace(/\[(\d+)\]/g,"[$1]"),t.replace(/\./g,"[")+"]".repeat((t.match(/\./g)||[]).length)];for(const i of r)if(n=this.state.formRoot.querySelector(`[name="${i}"]`),n)return n;const o=this.findSchemaElement(t);if(!o)return null;const a=this.state.formRoot.querySelectorAll(".fb-field-wrapper");for(const i of a){const l=o.label||o.key,s=i.querySelector("label");if(s&&(s.textContent===l||s.textContent===`${l}*`)){let c=i.querySelector(".field-placeholder");return c||(c=document.createElement("div"),c.className="field-placeholder",c.style.display="none",i.appendChild(c)),c}}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 a of o){if(r=n.find(i=>i.key===a)||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 a=r.actions.find(i=>i.key===t);if(a&&a.label)return a.label}if(o&&this.state.schema&&"actions"in this.state.schema&&this.state.schema.actions){const a=this.state.schema.actions.find(i=>i.key===t);if(a&&a.label)return a.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-3 pt-2 flex flex-wrap gap-2 justify-center",o.style.cssText=`
1147
1410
  border-top: var(--fb-border-width) solid var(--fb-border-color);
1148
- `,t.forEach(i=>{const a=document.createElement("button");a.type="button",nr(a,!0);const l=n.includes(i),u=this.resolveActionLabel(i.key,i.label,null,l);a.textContent=u,a.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(a)}),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,a)=>{const l=this.findFormElementByFieldPath(a);if(!l){console.warn(`External action: Could not find form element for field "${a}", treating as form-level actions`),r.push(...i);return}let u=l.closest(".fb-field-wrapper");if(u||(u=l.parentElement),!u){console.warn(`External action: Could not find wrapper for field "${a}"`);return}const s=u.querySelector(".external-actions-container");s&&s.remove();const d=document.createElement("div");d.className="external-actions-container mt-3 flex flex-wrap gap-2";const c=this.findSchemaElement(a);i.forEach(p=>{const f=document.createElement("button");f.type="button",nr(f,!1);const m=this.resolveActionLabel(p.key,p.label,c);f.textContent=m,f.addEventListener("click",g=>{g.preventDefault(),g.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(p.value,p.key,p.related_field)}),d.appendChild(f)}),u.appendChild(d)});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 a=JSON.parse(r);for(const l in a){const u=o?l:`${i}.${l}`,s=a[l];this.updateField(u,s)}}catch(a){console.error("Error parsing prefill hint values:",a)}}createRootPrefillHints(t){const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-2",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=mt(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 a=document.createElement("div");if(a.className="space-y-2",n.prefillHints&&!this.state.config.readonly){const s=this.createRootPrefillHints(n.prefillHints);a.appendChild(s)}const l=document.createElement("div"),u=n.columns||1;u===1?l.className="space-y-2":l.className=`grid grid-cols-${u} gap-2`,n.elements.forEach(s=>{var d,c;if(s.type!=="markdown"&&(s.hidden||s.type==="hidden")){const f=(c=(d=r==null?void 0:r[s.key])!=null?d:s.default)!=null?c:null;l.appendChild(De(s.key,f));return}const p=Bt(s,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});l.appendChild(p)}),a.appendChild(l),t.appendChild(a),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,a,l=null)=>{var u;const s=(u=i.key)!=null?u:"",d={scopeRoot:l||this.state.formRoot,state:this.state,instance:this,path:a.path,skipValidation:t},c=zl(i,s,d);return c!==null?(n.push(...c.errors),{value:c.value,spread:!!c.spread,skip:!!c.skip}):(console.warn(`Unknown field type "${i.type}" for key "${s}"`),{value:null,spread:!1})};return Bo(o),this.state.schema.elements.forEach(i=>{var a;if(i.enableIf)try{if(!ze(i.enableIf,r))return}catch(l){console.error(`Error evaluating enableIf for field "${i.key}" during validation:`,l)}if(i.type!=="markdown")if(i.hidden||i.type==="hidden"){const l=this.state.formRoot.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${i.key}"]`),u=(a=l==null?void 0:l.value)!=null?a:"";u!==""?r[i.key]=Ot(u):r[i.key]=i.default!==void 0?i.default:null}else{const l=o(i,{path:""});if(l.skip)return;l.spread&&l.value!==null&&typeof l.value=="object"?Object.assign(r,l.value):i.key&&(r[i.key]=l.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,a=this.buildHiddenFieldsData(i.elements);Object.keys(a).length>0&&(o in n?typeof n[o]=="object"&&n[o]!==null&&!Array.isArray(n[o])&&(n[o]={...n[o],...a}):n[o]=a)}}return n}buildFlatKeyMap(t){var n,r;const o=new Map;for(const i of t)if(i.type==="richinput"&&i.flatOutput){const a=i,l=(n=a.textKey)!=null?n:"text",u=(r=a.filesKey)!=null?r:"files";o.set(l,{schemaKey:i.key,role:"text"}),o.set(u,{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:""};ql(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=ht(t,this.state);if(!n)return r.querySelector(`[data-field-key="${o}"]`);const i=n.match(/^(.+)\[(\d+)\]$/);if(i){const l=r.querySelector(`[data-container-item="${i[1]}[${i[2]}]"]`);return l?l.querySelector(`[data-field-key="${o}"]`):null}const a=r.querySelector(`[data-container="${n}"]`);return a?a.querySelector(`[data-field-key="${o}"]`):null}applyEnableIfVisibility(t,n,r,o,i){var a,l,u,s;try{const d=((a=t.enableIf.scope)!=null?a:"relative")==="relative"&&r?bt(i,r):void 0,c=ze(t.enableIf,i,d),p=n.getAttribute("data-conditionally-disabled")==="true";if(c&&p){const f=r?bt(i,r):i,m=Bt(t,{path:r,prefill:f&&typeof f=="object"?f:{},formData:i,state:this.state,instance:this});(l=n.parentNode)==null||l.replaceChild(m,n)}else if(!c&&!p){const f=document.createElement("div");f.className="fb-field-wrapper-disabled",f.style.display="none",f.setAttribute("data-field-key",ht(t,this.state)),f.setAttribute("data-conditionally-disabled","true"),(u=n.parentNode)==null||u.replaceChild(f,n)}}catch(d){console.error(`Error re-evaluating enableIf for field "${(s=t.key)!=null?s:"<no key>"}" at path "${o}":`,d)}}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(r,o)=>{r.forEach(i=>{var a,l;const u=o?`${o}.${(a=i.key)!=null?a:""}`:(l=i.key)!=null?l:"";if(i.enableIf){const s=this.findFieldWrapper(i,o);s&&this.applyEnableIfVisibility(i,s,o,u,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 d=this.state.formRoot.querySelectorAll("[data-container-item]");(u?Array.from(d).filter(c=>{const p=c.getAttribute("data-container-item")||"";if(!p.startsWith(`${u}[`))return!1;const f=p.slice(u.length);return/^\[\d+\]$/.test(f)}):[]).forEach(c=>{const p=c.getAttribute("data-container-item")||"";n(i.elements,p)})}else n(i.elements,u)}})};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 or(e){return new ft(e)}return typeof window!="undefined"&&(window.FormBuilder=ft,window.createFormBuilder=or,window.validateSchema=mt),ke.FormBuilderInstance=ft,ke.createFormBuilder=or,ke.default=ft,ke.defaultTheme=Ve,ke.exampleThemes=Al,ke.validateSchema=mt,Object.defineProperty(ke,"__esModule",{value:!0}),ke})({});
1411
+ `,t.forEach(a=>{const i=document.createElement("button");i.type="button",Zt(i,!0);const l=n.includes(a),s=this.resolveActionLabel(a.key,a.label,null,l);i.textContent=s,i.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(a.value,a.key,null)}),o.appendChild(i)}),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(a=>{!a.key||!a.value||(a.related_field?(t.has(a.related_field)||t.set(a.related_field,[]),t.get(a.related_field).push(a)):n.push(a))}),t.forEach((a,i)=>{const l=this.findFormElementByFieldPath(i);if(!l){console.warn(`External action: Could not find form element for field "${i}", treating as form-level actions`),r.push(...a);return}let s=l.closest(".fb-field-wrapper");if(s||(s=l.parentElement),!s){console.warn(`External action: Could not find wrapper for field "${i}"`);return}const c=s.querySelector(".external-actions-container");c&&c.remove();const d=document.createElement("div");d.className="external-actions-container mt-3 flex flex-wrap gap-2";const u=this.findSchemaElement(i);a.forEach(f=>{const p=document.createElement("button");p.type="button",Zt(p,!1);const m=this.resolveActionLabel(f.key,f.label,u);p.textContent=m,p.addEventListener("click",b=>{b.preventDefault(),b.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(f.value,f.key,f.related_field)}),d.appendChild(p)}),s.appendChild(d)});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",a=n.getAttribute("data-container-key");if(!r||!o&&!a){console.warn("Prefill hint missing required data attributes");return}try{const i=JSON.parse(r);for(const l in i){const s=o?l:`${a}.${l}`,c=i[l];this.updateField(s,c)}}catch(i){console.error("Error parsing prefill hint values:",i)}}createRootPrefillHints(t){const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-2",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 a=yt(n);if(a.length>0){console.error("Schema validation errors:",a);return}this.state.formRoot=t,this.state.schema=n,this.state.externalActions=o||null,this.state.prefill=r||{},ge(t),t.setAttribute("data-fb-root","true"),ti(t,this.state.config.theme);const i=document.createElement("div");if(i.className="space-y-2",n.prefillHints&&!this.state.config.readonly){const c=this.createRootPrefillHints(n.prefillHints);i.appendChild(c)}const l=document.createElement("div"),s=n.columns||1;s===1?l.className="space-y-2":l.className=`grid grid-cols-${s} gap-2`,n.elements.forEach(c=>{var d,u;if(c.type!=="markdown"&&(c.hidden||c.type==="hidden")){const p=(u=(d=r==null?void 0:r[c.key])!=null?d:c.default)!=null?u:null;l.appendChild(Ke(c.key,p));return}const f=Kt(c,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});l.appendChild(f)}),i.appendChild(l),t.appendChild(i),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=(a,i,l=null)=>{var s;const c=(s=a.key)!=null?s:"",d={scopeRoot:l||this.state.formRoot,state:this.state,instance:this,path:i.path,skipValidation:t},u=Wl(a,c,d);return u!==null?(n.push(...u.errors),{value:u.value,spread:!!u.spread,skip:!!u.skip}):(console.warn(`Unknown field type "${a.type}" for key "${c}"`),{value:null,spread:!1})};return il(o),this.state.schema.elements.forEach(a=>{var i;if(a.enableIf)try{if(!Be(a.enableIf,r))return}catch(l){console.error(`Error evaluating enableIf for field "${a.key}" during validation:`,l)}if(a.type!=="markdown")if(a.hidden||a.type==="hidden"){const l=this.state.formRoot.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${a.key}"]`),s=(i=l==null?void 0:l.value)!=null?i:"";s!==""?r[a.key]=Xt(s):r[a.key]=a.default!==void 0?a.default:null}else{const l=o(a,{path:""});if(l.skip)return;l.spread&&l.value!==null&&typeof l.value=="object"?Object.assign(r,l.value):a.key&&(r[a.key]=l.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 a=r,i=this.buildHiddenFieldsData(a.elements);Object.keys(i).length>0&&(o in n?typeof n[o]=="object"&&n[o]!==null&&!Array.isArray(n[o])&&(n[o]={...n[o],...i}):n[o]=i)}}return n}buildFlatKeyMap(t){var n,r;const o=new Map;for(const a of t)if(a.type==="richinput"&&a.flatOutput){const i=a,l=(n=i.textKey)!=null?n:"text",s=(r=i.filesKey)!=null?r:"files";o.set(l,{schemaKey:a.key,role:"text"}),o.set(s,{schemaKey:a.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 a=n.get(o);a?(r.has(a.schemaKey)||r.set(a.schemaKey,{}),r.get(a.schemaKey)[o]=t[o]):this.updateField(o,t[o])}for(const[o,a]of r)this.updateField(o,a)}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 a={scopeRoot:this.state.formRoot,state:this.state,instance:this,path:""};Vl(n,r,o,a)||console.warn(`updateField: No updater found for field type "${n.type}" at path "${r}"`)}findFieldWrapper(t,n){const r=this.state.formRoot,o=xt(t,this.state);if(!n)return r.querySelector(`[data-field-key="${o}"]`);const a=n.match(/^(.+)\[(\d+)\]$/);if(a){const l=r.querySelector(`[data-container-item="${a[1]}[${a[2]}]"]`);return l?l.querySelector(`[data-field-key="${o}"]`):null}const i=r.querySelector(`[data-container="${n}"]`);return i?i.querySelector(`[data-field-key="${o}"]`):null}applyEnableIfVisibility(t,n,r,o,a){var i,l,s,c;try{const d=((i=t.enableIf.scope)!=null?i:"relative")==="relative"&&r?wt(a,r):void 0,u=Be(t.enableIf,a,d),f=n.getAttribute("data-conditionally-disabled")==="true";if(u&&f){const p=r?wt(a,r):a,m=Kt(t,{path:r,prefill:p&&typeof p=="object"?p:{},formData:a,state:this.state,instance:this});(l=n.parentNode)==null||l.replaceChild(m,n)}else if(!u&&!f){const p=document.createElement("div");p.className="fb-field-wrapper-disabled",p.style.display="none",p.setAttribute("data-field-key",xt(t,this.state)),p.setAttribute("data-conditionally-disabled","true"),(s=n.parentNode)==null||s.replaceChild(p,n)}}catch(d){console.error(`Error re-evaluating enableIf for field "${(c=t.key)!=null?c:"<no key>"}" at path "${o}":`,d)}}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(r,o)=>{r.forEach(a=>{var i,l;const s=o?`${o}.${(i=a.key)!=null?i:""}`:(l=a.key)!=null?l:"";if(a.enableIf){const c=this.findFieldWrapper(a,o);c&&this.applyEnableIfVisibility(a,c,o,s,t)}if((a.type==="container"||a.type==="group")&&"elements"in a&&a.elements){const c=a.key?t==null?void 0:t[a.key]:void 0;if(Array.isArray(c)){const d=this.state.formRoot.querySelectorAll("[data-container-item]");(s?Array.from(d).filter(u=>{const f=u.getAttribute("data-container-item")||"";if(!f.startsWith(`${s}[`))return!1;const p=f.slice(s.length);return/^\[\d+\]$/.test(p)}):[]).forEach(u=>{const f=u.getAttribute("data-container-item")||"";n(a.elements,f)})}else n(a.elements,s)}})};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&&ge(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 hr(e){return new gt(e)}return typeof window!="undefined"&&(window.FormBuilder=gt,window.createFormBuilder=hr,window.validateSchema=yt),Te.FormBuilderInstance=gt,Te.createFormBuilder=hr,Te.default=gt,Te.defaultTheme=Ve,Te.exampleThemes=ni,Te.validateSchema=yt,Object.defineProperty(Te,"__esModule",{value:!0}),Te})({});