@dmitryvim/form-builder 0.5.1 → 0.5.3

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.
@@ -0,0 +1,1490 @@
1
+ var FormBuilder=(function(Fe){"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,d]of Object.entries(n))i=i.replace(new RegExp(`\\{${l}\\}`,"g"),String(d));return i}function ie(e,t,n){return e.readonly===!0||t.config.readonly===!0||(n==null?void 0:n.inheritedReadonly)===!0}function Je(e){return e&&typeof e=="object"&&e.constructor===Object}function se(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 De(e,t){return e?`${e}.${t}`:t}function wt(e,t){if(!t)return[];const n=e.querySelectorAll("[data-container-item]");return Array.from(n).filter(r=>{const o=r.getAttribute("data-container-item")||"";return o.startsWith(`${t}[`)?/^\[\d+\]$/.test(o.slice(t.length)):!1})}function we(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function vr(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Zt(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Qt(e){if(e==="")return null;try{return JSON.parse(e)}catch(t){return e}}function Ct(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.setAttribute("data-hidden-field","true"),n.value=Zt(t),n}function gr(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 yr(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 xr(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 wr(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 Cr(e,t,n){e.pattern&&t.push(k("hintPattern",n,{pattern:e.pattern}))}function Le(e,t){const n=[];return gr(e,n,t),e.type!=="slider"&&yr(e,n,t),xr(e,n,t),wr(e,n,t),Cr(e,n,t),n.join(" \u2022 ")}function Et(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 l=e.columns,d=[1,2,3,4];(!Number.isInteger(l)||!d.includes(l))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${l})`)}if("prefillHints"in e&&e.prefillHints){const l=e.prefillHints;Array.isArray(l)&&l.forEach((d,s)=>{if((!d.label||typeof d.label!="string")&&t.push(`schema.prefillHints[${s}] must have a 'label' property of type string`),!d.values||typeof d.values!="object")t.push(`schema.prefillHints[${s}] must have a 'values' property of type object`);else for(const f in d.values)e.elements.some(c=>c.key===f)||t.push(`schema.prefillHints[${s}] references non-existent field "${f}"`)})}function n(l,d,s){if("columns"in l&&l.columns!==void 0){const f=l.columns,c=[1,2,3,4];(!Number.isInteger(f)||!c.includes(f))&&s.push(`${d}: columns must be 1, 2, 3, or 4 (got ${f})`)}if("displayMode"in l&&l.displayMode!==void 0){const f=l.displayMode;f!=="stack"&&f!=="slides"&&s.push(`${d}: displayMode must be "stack" or "slides" (got ${JSON.stringify(f)})`)}}function r(l,d){var s,f;const c=new Set;for(const u of l)if(u.type==="richinput"&&u.flatOutput){const p=u,m=(s=p.textKey)!=null?s:"text",b=(f=p.filesKey)!=null?f:"files";for(const v of l)v!==u&&(v.key===m&&t.push(`${d}: RichInput "${u.key}" flatOutput textKey "${m}" collides with element key "${v.key}"`),v.key===b&&t.push(`${d}: RichInput "${u.key}" flatOutput filesKey "${b}" collides with element key "${v.key}"`));c.has(m)&&t.push(`${d}: RichInput "${u.key}" flatOutput textKey "${m}" collides with another flatOutput key`),c.has(b)&&t.push(`${d}: RichInput "${u.key}" flatOutput filesKey "${b}" collides with another flatOutput key`),c.add(m),c.add(b)}else u.key&&(c.has(u.key)&&t.push(`${d}: Element key "${u.key}" collides with a flatOutput richinput key`),c.add(u.key))}function o(l,d,s){var f,c;const u=l;if(u.type==="group"){if(!Je(u.repeat))return;a(d,(f=u.repeat)==null?void 0:f.min,(c=u.repeat)==null?void 0:c.max,"repeat.min","repeat.max",u.required===!0,s);return}(u.multiple===!0||u.type==="files")&&a(d,u.minCount,u.maxCount,"minCount","maxCount",u.required===!0,s)}function a(l,d,s,f,c,u,p){for(const[E,h]of[[f,d],[c,s]])h!==void 0&&typeof h!="number"&&p.push(`${l}: ${E} must be a number (got ${typeof h})`);const m=typeof d=="number"?d:void 0,b=typeof s=="number"?s:void 0;b!==void 0&&(b<0||Number.isNaN(b))&&p.push(`${l}: ${c} must be a non-negative number or Infinity (got ${b})`),m!==void 0&&(m<0||!Number.isFinite(m))&&p.push(`${l}: ${f} must be a finite non-negative number (got ${m})`);const v=m!=null?m:u?1:void 0;if(v!==void 0&&b!==void 0&&v>b){const E=m!==void 0?`${f} (${m})`:`required: true (implies ${f} 1)`;p.push(`${l}: ${E} cannot be greater than ${c} (${b})`)}}function i(l,d){l.forEach((s,f)=>{const c=`${d}[${f}]`;if(s.type||t.push(`${c}: missing type`),!s.key&&s.type!=="markdown"&&t.push(`${c}: missing key`),o(s,c,t),s.type==="markdown"){const u=s.content;typeof u!="string"&&t.push(`${c}: markdown element requires "content" to be a string (got ${u===null?"null":typeof u})`)}if(s.enableIf){const u=s.enableIf;(!u.key||typeof u.key!="string")&&t.push(`${c}: enableIf must have a 'key' property of type string`),"equals"in u||t.push(`${c}: enableIf must have at least one operator (equals, etc.)`)}if(s.type==="group"&&"elements"in s&&s.elements&&i(s.elements,`${c}.elements`),s.type==="container"&&s.elements){if(n(s,c,t),"prefillHints"in s&&s.prefillHints){const u=s.prefillHints;Array.isArray(u)&&u.forEach((p,m)=>{if((!p.label||typeof p.label!="string")&&t.push(`${c}: prefillHints[${m}] must have a 'label' property of type string`),!p.values||typeof p.values!="object")t.push(`${c}: prefillHints[${m}] must have a 'values' property of type object`);else for(const b in p.values)s.elements.some(v=>v.key===b)||t.push(`container "${s.key}": prefillHints[${m}] references non-existent field "${b}"`)})}i(s.elements,`${c}.elements`),r(s.elements,`${c}.elements`)}if(s.type==="select"&&s.options){const u=s.default;u!=null&&u!==""&&(s.options.some(p=>p.value===u)||t.push(`${c}: default "${u}" not in options`))}})}return Array.isArray(e.elements)&&(i(e.elements,"elements"),r(e.elements,"elements")),t}function nt(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 je(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=nt(a,e.key);if("equals"in e)return Er(i,e.equals);throw new Error("Invalid enableIf condition: no recognized operator (equals, etc.)")}function Er(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 Ce(e){const t=e.getAttribute("name");if(!t)return;const n=(e.ownerDocument||document).getElementById(`error-${t}`);n&&n.remove()}const en='<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 kr(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
+ /* Slides-mode outer grid. Responsive by design \u2014 column count derives from
10
+ container width and --fb-slide-min-width, not from a schema "columns" prop.
11
+ min(100%, ...) prevents the card from overflowing a narrow container.
12
+ Override per-form: set --fb-slide-min-width / --fb-slides-gap on any
13
+ ancestor (theme, host CSS, or the form root). */
14
+ .fb-container-slides {
15
+ display: grid;
16
+ gap: var(--fb-slides-gap, 14px);
17
+ align-items: stretch;
18
+ grid-template-columns: repeat(
19
+ auto-fit,
20
+ minmax(min(100%, var(--fb-slide-min-width, 280px)), 1fr)
21
+ );
22
+ }
23
+ [data-fb-label-row] > label {
24
+ font-size: var(--fb-label-section-font-size);
25
+ letter-spacing: var(--fb-label-section-letter-spacing);
26
+ text-transform: var(--fb-label-section-text-transform);
27
+ }
28
+ /* Per-item remove (trash) button used by multi-container items. Shares the
29
+ same faint-on-rest, error-on-hover palette as .fb-chip-remove. */
30
+ .fb-item-remove {
31
+ color: var(--fb-text-faint-color, #94a3b8);
32
+ background-color: transparent;
33
+ transition: color var(--fb-transition-duration), background-color var(--fb-transition-duration);
34
+ }
35
+ .fb-item-remove:hover {
36
+ color: var(--fb-error-color);
37
+ background-color: var(--fb-background-hover-color);
38
+ }
39
+ .fb-item-remove:disabled {
40
+ opacity: 0.35;
41
+ cursor: not-allowed;
42
+ }
43
+ /* Cards carrying a row-level remove button reserve a right-hand lane for it
44
+ (24px button + inset + gap) so it never sits on top of the first field's
45
+ control. A class rather than an inline style, so host CSS can override the
46
+ gutter without !important; the compound selector keeps it ahead of the
47
+ card's own p-2 utility regardless of stylesheet order. Its own token, not
48
+ --fb-slide-card-padding, which is slides-only and always resolves. */
49
+ .containerItem.fb-row-removable {
50
+ padding-right: var(--fb-row-remove-gutter, 40px);
51
+ }
52
+ /* Prefill-suggestion pills rendered by createPrefillHints. Outline pill at rest,
53
+ soft-fill on hover, solid-fill when selected. All colors flow from the active
54
+ theme \u2014 consumers don't need to ship their own CSS. */
55
+ .fb-prefill-hint {
56
+ padding: 0.25rem 0.625rem;
57
+ border: var(--fb-border-width) solid var(--fb-primary-color);
58
+ border-radius: 9999px;
59
+ background: var(--fb-background-color);
60
+ color: var(--fb-primary-color);
61
+ font-size: var(--fb-font-size-small);
62
+ font-weight: var(--fb-font-weight-medium);
63
+ font-family: var(--fb-font-family);
64
+ cursor: pointer;
65
+ transition: background-color var(--fb-transition-duration), border-color var(--fb-transition-duration), color var(--fb-transition-duration);
66
+ }
67
+ .fb-prefill-hint:hover {
68
+ background: var(--fb-primary-soft-color);
69
+ border-color: var(--fb-primary-hover-color);
70
+ color: var(--fb-primary-hover-color);
71
+ }
72
+ .fb-prefill-hint:focus-visible {
73
+ outline: var(--fb-focus-ring-width) solid var(--fb-focus-ring-color);
74
+ outline-offset: 2px;
75
+ }
76
+ .fb-prefill-hint[aria-pressed="true"],
77
+ .fb-prefill-hint.active {
78
+ background: var(--fb-primary-color);
79
+ color: #ffffff;
80
+ border-color: var(--fb-primary-color);
81
+ }
82
+ /* \u2500\u2500\u2500 Row layout: flex-wrap container with per-child width tokens \u2500\u2500\u2500
83
+ Replaces the older Tailwind \`space-y-2\` class. Children without
84
+ data-fb-width (or width="full") take 100% basis \u2192 forced wrap \u2192 behaves
85
+ like a vertical stack. Mixed widths sit side-by-side in the same row. */
86
+ .fb-row {
87
+ display: flex;
88
+ flex-wrap: wrap;
89
+ gap: var(--fb-row-gap, 0.25rem);
90
+ align-items: flex-start;
91
+ }
92
+ .fb-row > [data-fb-width="full"],
93
+ .fb-row > :not([data-fb-width]) { flex: 0 0 100%; min-width: 0; }
94
+ .fb-row > [data-fb-width="1/2"] { flex: 0 0 calc(50% - var(--fb-row-gap, 0.25rem) / 2); min-width: 0; }
95
+ .fb-row > [data-fb-width="1/3"] { flex: 0 0 calc(33.333% - var(--fb-row-gap, 0.25rem) * 2 / 3); min-width: 0; }
96
+ .fb-row > [data-fb-width="2/3"] { flex: 0 0 calc(66.666% - var(--fb-row-gap, 0.25rem) / 3); min-width: 0; }
97
+ /* \u2500\u2500\u2500 Density tokens: re-bind --fb-input-padding-* and --fb-font-size at
98
+ the wrapper level so every component that reads those vars (text, textarea,
99
+ select, number, colour, switcher, file) picks the size up via cascade. md
100
+ uses the defaults set in theme.ts (2px / 8px / 14px). The scale primarily
101
+ varies font-size; vertical padding stays close to md so an "lg" heading
102
+ field does not visually break the form's row rhythm \u2014 only the typography
103
+ announces "this is bigger". Picaz theme overrides padding directly for
104
+ its own density, independent of this scale. */
105
+ /* size-token side-effects on file tiles: --fb-file-wide-min controls the
106
+ single-file empty dropzone height, --fb-file-zone-min controls the inner
107
+ upload/library zones. Both read in src/components/file/styles.ts. */
108
+ .fb-size-xs { --fb-input-padding-y: 1px; --fb-input-padding-x: 6px; --fb-font-size: 12px; --fb-font-size-small: 10px; --fb-line-height: 1.25; --fb-file-wide-min: 64px; --fb-file-zone-min: 48px; --fb-file-zone-padding: 6px; }
109
+ .fb-size-sm { --fb-input-padding-y: 2px; --fb-input-padding-x: 6px; --fb-font-size: 13px; --fb-font-size-small: 11px; --fb-line-height: 1.35; --fb-file-wide-min: 80px; --fb-file-zone-min: 60px; --fb-file-zone-padding: 7px; }
110
+ /* .fb-size-md uses defaults \u2014 no override needed */
111
+ .fb-size-lg { --fb-input-padding-y: 2px; --fb-input-padding-x: 8px; --fb-font-size: 16px; --fb-font-size-small: 13px; --fb-file-wide-min: 128px; --fb-file-zone-min: 96px; --fb-file-zone-padding: 12px; }
112
+ .fb-size-xl { --fb-input-padding-y: 3px; --fb-input-padding-x: 8px; --fb-font-size: 18px; --fb-font-size-small: 14px; --fb-file-wide-min: 160px; --fb-file-zone-min: 120px; --fb-file-zone-padding: 14px; }
113
+ `,e.head.appendChild(t)}function rt(e,t={}){var n;e.style.overflow="hidden",e.style.resize="none";const r=Math.max(1,(n=t.minRows)!=null?n:1),o=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(r,o);const a=()=>{if(!e.isConnected)return;e.style.height="";const d=getComputedStyle(e),s=parseFloat(d.borderTopWidth||"0")+parseFloat(d.borderBottomWidth||"0"),f=parseFloat(d.lineHeight||"0")||parseFloat(d.fontSize||"0")*1.5||20,c=parseFloat(d.paddingTop||"0")+parseFloat(d.paddingBottom||"0"),u=f*r+c+s;if(e.value===""){e.style.height=`${u}px`;return}const p=e.scrollHeight+s;e.style.height=`${Math.max(p,u)}px`};if(e.addEventListener("input",a),setTimeout(()=>{e.isConnected&&a()},0),typeof ResizeObserver=="undefined")return;let i=-1;const l=new ResizeObserver(d=>{var s,f,c,u,p;if(!e.isConnected){l.disconnect();return}const m=d[0],b=(p=(u=(f=(s=m==null?void 0:m.contentBoxSize)==null?void 0:s[0])==null?void 0:f.inlineSize)!=null?u:(c=m==null?void 0:m.contentRect)==null?void 0:c.width)!=null?p:0;b!==i&&(i=b,a())});l.observe(e)}function tn(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," "),d=(o=e.selectionStart)!=null?o:e.value.length,s=(a=e.selectionEnd)!=null?a:e.value.length,f=e.value.slice(0,d),c=e.value.slice(s);e.value=f+l+c;const u=d+l.length;e.setSelectionRange(u,u),e.dispatchEvent(new Event("input",{bubbles:!0}))})}function Te(e,t){const n=e.querySelector(":scope > [data-fb-label-row]");n&&n.appendChild(t)}function ze(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",i.style.cssText="display:flex;align-items:stretch;width:100%;margin-top:4px;";const l=document.createElement("button");l.type="button",l.className=`add-${e}-btn`,l.style.cssText=`
114
+ flex: 1 1 auto;
115
+ display: inline-flex;
116
+ align-items: center;
117
+ justify-content: center;
118
+ gap: 4px;
119
+ padding: 3px 10px;
120
+ border: 1px dashed var(--fb-primary-color);
121
+ border-radius: var(--fb-border-radius);
122
+ background: transparent;
123
+ color: var(--fb-primary-color);
124
+ font-size: var(--fb-font-size-small, var(--fb-font-size));
125
+ font-weight: 500;
126
+ font-family: var(--fb-font-family);
127
+ cursor: pointer;
128
+ transition: border-color var(--fb-transition-duration), color var(--fb-transition-duration), background-color var(--fb-transition-duration);
129
+ `,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 d=document.createElement("span");return d.className="fb-add-counter",d.style.cssText=`
130
+ margin-left: auto;
131
+ font-size: var(--fb-font-size-small, 0.875rem);
132
+ color: var(--fb-text-secondary-color);
133
+ font-weight: 400;
134
+ `,a||(d.style.display="none"),i.appendChild(l),{row:i,button:l,counter:d,update:(s,f)=>{const c=s>=f;i.style.display=c?"none":"flex",l.style.display=c?"none":"inline-flex",l.disabled=c,a&&(d.textContent=`${s}/${f===1/0?"\u221E":f}`)}}}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=`
135
+ display: flex;
136
+ flex-direction: column;
137
+ align-items: center;
138
+ justify-content: center;
139
+ gap: 12px;
140
+ width: 100%;
141
+ min-height: 180px;
142
+ align-self: stretch;
143
+ padding: 24px 16px;
144
+ border: 1.5px dashed var(--fb-primary-color);
145
+ border-radius: var(--fb-border-radius);
146
+ background: transparent;
147
+ color: var(--fb-primary-color);
148
+ font-size: var(--fb-font-size-small, var(--fb-font-size));
149
+ font-weight: 500;
150
+ font-family: var(--fb-font-family);
151
+ cursor: pointer;
152
+ transition: border-color var(--fb-transition-duration), color var(--fb-transition-duration), background-color var(--fb-transition-duration);
153
+ `;const a=document.createElement("span");if(a.className="fb-slide-add-circle",a.style.cssText=`
154
+ display: inline-flex;
155
+ align-items: center;
156
+ justify-content: center;
157
+ width: 36px;
158
+ height: 36px;
159
+ border: 1px solid var(--fb-primary-color);
160
+ border-radius: 50%;
161
+ background: var(--fb-background-color);
162
+ font-size: 20px;
163
+ line-height: 1;
164
+ color: inherit;
165
+ transition: inherit;
166
+ `,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=`
167
+ margin-left: auto;
168
+ font-size: var(--fb-font-size-small, 0.875rem);
169
+ color: var(--fb-text-secondary-color);
170
+ font-weight: 400;
171
+ `,{tile:o,counter:i,update:(l,d)=>{const s=l>=d;o.style.display=s?"none":"flex",o.disabled=s,i.textContent=`${l}/${d===1/0?"\u221E":d}`}}}function nn(e,t=!1){e.style.cssText=`
172
+ background-color: var(--fb-action-bg-color);
173
+ color: var(--fb-action-text-color);
174
+ border: var(--fb-border-width) solid var(--fb-action-border-color);
175
+ padding: ${t?"0.5rem 1rem":"0.5rem 0.75rem"};
176
+ font-size: var(--fb-font-size);
177
+ font-weight: var(--fb-font-weight-medium);
178
+ border-radius: var(--fb-border-radius);
179
+ transition: all var(--fb-transition-duration);
180
+ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
181
+ `,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 Sr(e){if(e.head.querySelector("[data-fb-chip-styles]"))return;const t=e.createElement("style");t.setAttribute("data-fb-chip-styles",""),t.textContent=`
182
+ .fb-chip-list { display: flex; flex-direction: column; gap: 2px; }
183
+ .fb-chip {
184
+ display: flex;
185
+ align-items: center;
186
+ gap: 6px;
187
+ padding: 3px 6px 3px 8px;
188
+ background: var(--fb-chip-bg, var(--fb-background-color, #fff));
189
+ border: 1px solid var(--fb-chip-border, var(--fb-border-color, #e2e8f0));
190
+ border-radius: 6px;
191
+ position: relative;
192
+ transition: border-color var(--fb-transition-duration, 0.15s);
193
+ }
194
+ .fb-chip:hover { border-color: var(--fb-border-hover-color, var(--fb-border-color, #cbd5e1)); }
195
+ .fb-chip:focus-within { border-color: var(--fb-border-focus-color, var(--fb-primary-color, #2f5bea)); }
196
+ .fb-chip-dot {
197
+ flex: 0 0 6px;
198
+ width: 6px;
199
+ height: 6px;
200
+ border-radius: 50%;
201
+ background: var(--fb-chip-dot, var(--fb-primary-color, #2f5bea));
202
+ }
203
+ .fb-chip-input {
204
+ flex: 1;
205
+ min-width: 0;
206
+ padding: 2px 0;
207
+ border: 0;
208
+ outline: none;
209
+ background: transparent;
210
+ color: var(--fb-chip-text, var(--fb-text-color, inherit));
211
+ font-size: var(--fb-font-size, 14px);
212
+ font-family: var(--fb-font-family, inherit);
213
+ line-height: var(--fb-line-height, 1.4);
214
+ /* Soft-wrap support (v0.4.0): chip-input is now a <textarea rows=1> that
215
+ grows vertically when content overflows the chip width. */
216
+ resize: none;
217
+ overflow: hidden;
218
+ word-break: break-word;
219
+ overflow-wrap: anywhere;
220
+ }
221
+ .fb-chip-input::placeholder { color: var(--fb-text-placeholder-color, #94a3b8); }
222
+ .fb-chip-input:read-only { color: var(--fb-text-secondary-color, #475569); }
223
+ .fb-chip-remove {
224
+ flex: 0 0 auto;
225
+ width: 22px;
226
+ height: 22px;
227
+ display: inline-flex;
228
+ align-items: center;
229
+ justify-content: center;
230
+ padding: 0;
231
+ border: 0;
232
+ border-radius: 4px;
233
+ background: transparent;
234
+ color: var(--fb-text-faint-color, #94a3b8);
235
+ cursor: pointer;
236
+ opacity: 0;
237
+ transition: opacity 0.12s, color 0.12s, background-color 0.12s;
238
+ }
239
+ .fb-chip:hover .fb-chip-remove,
240
+ .fb-chip-remove:focus-visible { opacity: 1; }
241
+ .fb-chip-remove:hover {
242
+ color: var(--fb-error-color, #dc2626);
243
+ background: var(--fb-background-hover-color, #f1f5f9);
244
+ }
245
+ .fb-chip-remove:disabled { opacity: 0 !important; pointer-events: none; }
246
+ `,e.head.appendChild(t)}function ot(e,t){const n=document.createElement("span");n.className="char-counter",n.style.cssText=`
247
+ margin-top: 4px;
248
+ padding-right: 12px;
249
+ text-align: right;
250
+ font-size: var(--fb-font-size-small);
251
+ line-height: 1;
252
+ color: var(--fb-error-color);
253
+ pointer-events: none;
254
+ display: none;
255
+ `;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 Lr(e,t,n,r){var o;const a=t.state,i=ie(e,a,t),l=document.createElement("div");l.style.cssText="position: relative;";const d=!i&&(e.minLength!=null||e.maxLength!=null),s=document.createElement("textarea");if(s.rows=1,s.className="w-full rounded-lg",s.style.cssText=`
256
+ padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
257
+ border: var(--fb-border-width) solid var(--fb-border-color);
258
+ border-radius: var(--fb-border-radius);
259
+ background-color: ${i?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
260
+ color: var(--fb-text-color);
261
+ font-size: var(--fb-font-size);
262
+ font-family: var(--fb-font-family);
263
+ line-height: var(--fb-line-height, 1.5);
264
+ transition: all var(--fb-transition-duration) ease-in-out;
265
+ width: 100%;
266
+ box-sizing: border-box;
267
+ resize: none;
268
+ overflow: hidden;
269
+ word-break: break-word;
270
+ overflow-wrap: anywhere;
271
+ `,s.name=r,s.placeholder=(o=e.placeholder)!=null?o:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",s.value=t.prefill[e.key]||e.default||"",s.readOnly=i,tn(s),rt(s),i||(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)")})),!i&&t.instance){const f=()=>{const c=s.value===""?null:s.value;t.instance.triggerOnChange(r,c)};s.addEventListener("blur",f),s.addEventListener("input",f)}if(l.appendChild(s),d){const f=ot(e,s);l.appendChild(f)}n.appendChild(l)}function Tr(e,t,n,r){var o,a;const i=t.state,l=ie(e,i,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],f=(o=e.minCount)!=null?o:e.required?1:0,c=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"");Sr(document);const u=document.createElement("div");u.className="fb-chip-list",n.appendChild(u);function p(){u.querySelectorAll(".fb-chip-input").forEach((h,y)=>{h.name=`${r}[${y}]`;const g=h.closest(".fb-chip"),C=g==null?void 0:g.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 g=document.createElement("span");g.className="fb-chip-dot",g.setAttribute("aria-hidden","true"),y.appendChild(g);const C=document.createElement("textarea");if(C.rows=1,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 w=()=>{t.instance.triggerOnChange(C.name,C.value===""?null:C.value)};C.addEventListener("blur",w),C.addEventListener("input",w)}if(tn(C),rt(C),!l){const w=document.createElement("button");w.type="button",w.className="fb-chip-remove",w.setAttribute("aria-label",k("removeElement",i)),w.innerHTML=en,w.onclick=()=>{const x=u.querySelectorAll(".fb-chip"),S=Array.prototype.indexOf.call(x,y);if(S<0||x.length<=f)return;s.splice(S,1);const z=y.nextElementSibling;z&&z.classList.contains("error-message")&&z.remove(),y.remove(),p(),E(),b()},y.appendChild(w)}return u.appendChild(y),p(),y}function b(){if(l)return;const h=u.querySelectorAll(".fb-chip").length<=f;u.querySelectorAll(".fb-chip-remove").forEach(y=>{y.disabled=h})}let v=null;if(!l){const h=ze("text",()=>{s.push(e.default||""),m(e.default||""),E(),b()},{label:e.addLabel});v=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){v&&v(s.length,c)}s.forEach(h=>m(h)),E(),b()}function rn(e,t,n){var r,o,a;const i=[],{scopeRoot:l,skipValidation:d}=n,s=(c,u)=>{var p,m,b;if(!c)return;const v=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let E=document.getElementById(v);if(u){if(c.classList.add("invalid"),c.title=u,!E){E=document.createElement("div"),E.id=v,E.className="error-message",E.style.cssText=`
272
+ color: var(--fb-error-color);
273
+ font-size: var(--fb-font-size-small);
274
+ margin-top: 0.25rem;
275
+ `;const h=((p=c.closest)==null?void 0:p.call(c,".fb-chip"))||c;h.nextSibling?(m=h.parentNode)==null||m.insertBefore(E,h.nextSibling):(b=h.parentNode)==null||b.appendChild(E)}E.textContent=u,E.style.display="block"}else c.classList.remove("invalid"),c.title="",E&&E.remove()},f=(c,u,p)=>{let m=!1;const{state:b}=n;if(!d&&u){if(e.minLength!==void 0&&e.minLength!==null&&u.length<e.minLength){const v=k("minLength",b,{min:e.minLength});i.push(`${p}: ${v}`),s(c,v),m=!0}else if(e.maxLength!==void 0&&e.maxLength!==null&&u.length>e.maxLength){const v=k("maxLength",b,{max:e.maxLength});i.push(`${p}: ${v}`),s(c,v),m=!0}else if(e.pattern)try{if(!new RegExp(e.pattern).test(u)){const v=k("patternMismatch",b);i.push(`${p}: ${v}`),s(c,v),m=!0}}catch(v){const E=k("invalidPattern",b);i.push(`${p}: ${E}`),s(c,E),m=!0}}m||s(c,null)};if(e.multiple){const c=l.querySelectorAll(`[name^="${t}\\["]`),u=[],p=[];if(c.forEach((m,b)=>{var v;const E=(v=m==null?void 0:m.value)!=null?v:"";p.push(E),u.push(E===""?null:E),f(m,E,`${t}[${b}]`)}),!d){const{state:m}=n,b=(r=e.minCount)!=null?r:0,v=(o=e.maxCount)!=null?o:1/0,E=p.filter(h=>h.trim()!=="");e.required&&E.length===0&&i.push(`${t}: ${k("required",m)}`),E.length<b&&i.push(`${t}: ${k("minItems",m,{min:b})}`),E.length>v&&i.push(`${t}: ${k("maxItems",m,{max:v})}`)}return{value:u,errors:i}}else{const c=l.querySelector(`[name$="${t}"]`),u=(a=c==null?void 0:c.value)!=null?a:"";if(!d&&e.required&&u===""){const p=k("required",n.state);return i.push(`${t}: ${p}`),s(c,p),{value:null,errors:i}}return c&&f(c,u,t),{value:u===""?null:u,errors:i}}}function on(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="",Ce(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="",Ce(a),a instanceof HTMLTextAreaElement&&a.dispatchEvent(new Event("input",{bubbles:!0})))}}function Ar(e,t,n,r){var o,a;const i=t.state,l=ie(e,i,t),d=document.createElement("div");d.style.cssText="position: relative;";const s=document.createElement("textarea");if(s.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",s.style.cssText=`
276
+ padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
277
+ font-size: var(--fb-font-size);
278
+ font-family: var(--fb-font-family);
279
+ line-height: var(--fb-line-height, 1.5);
280
+ `,s.name=r,s.placeholder=(o=e.placeholder)!=null?o:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",s.value=t.prefill[e.key]||e.default||"",s.readOnly=l,!l&&t.instance){const f=()=>{const c=s.value===""?null:s.value;t.instance.triggerOnChange(r,c)};s.addEventListener("blur",f),s.addEventListener("input",f)}if(rt(s,{minRows:(a=e.rows)!=null?a:1}),d.appendChild(s),!l&&(e.minLength!=null||e.maxLength!=null)){const f=ot(e,s);d.appendChild(f)}n.appendChild(d)}function Fr(e,t,n,r){var o,a;const i=t.state,l=ie(e,i,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],f=(o=e.minCount)!=null?o:e.required?1:0,c=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"");const u=document.createElement("div");u.className="fb-row",n.appendChild(u);function p(){u.querySelectorAll(".multiple-textarea-item").forEach((h,y)=>{const g=h.querySelector("textarea");g&&(g.name=`${r}[${y}]`)})}function m(h="",y=-1){var g;const C=document.createElement("div");C.className="multiple-textarea-item";const w=document.createElement("div");w.style.cssText="position: relative;";const x=document.createElement("textarea");if(x.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",x.style.cssText=`
281
+ padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
282
+ font-size: var(--fb-font-size);
283
+ font-family: var(--fb-font-family);
284
+ line-height: var(--fb-line-height, 1.5);
285
+ `,x.placeholder=e.placeholder||k("placeholderText",i),x.value=h,x.readOnly=l,!l&&t.instance){const S=()=>{const z=x.value===""?null:x.value;t.instance.triggerOnChange(x.name,z)};x.addEventListener("blur",S),x.addEventListener("input",S)}if(rt(x,{minRows:(g=e.rows)!=null?g:1}),w.appendChild(x),!l&&(e.minLength!=null||e.maxLength!=null)){const S=ot(e,x);w.appendChild(S)}return C.appendChild(w),y===-1?u.appendChild(C):u.insertBefore(C,u.children[y]),p(),C}function b(){if(l)return;const h=u.querySelectorAll(".multiple-textarea-item"),y=h.length;h.forEach(g=>{let C=g.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(u.children).indexOf(g);u.children.length>f&&(s.splice(x,1),g.remove(),p(),E(),b())},g.appendChild(C));const w=y<=f;C.disabled=w,C.style.opacity=w?"0.5":"1",C.style.pointerEvents=w?"none":"auto"})}let v=null;if(!l){const h=ze("textarea",()=>{s.push(e.default||""),m(e.default||""),E(),b()},{label:e.addLabel});v=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){v&&v(s.length,c)}s.forEach(h=>m(h)),E(),b()}function zr(e,t,n){return rn(e,t,n)}function Mr(e,t,n,r){on(e,t,n,r);const{scopeRoot:o}=r;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 Nr(e){const t="fb-number-stepper-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
286
+ .fb-stepper-input::-webkit-outer-spin-button,
287
+ .fb-stepper-input::-webkit-inner-spin-button {
288
+ -webkit-appearance: none;
289
+ margin: 0;
290
+ }
291
+ .fb-stepper-input { -moz-appearance: textfield; }
292
+ `,e.head.appendChild(n)}function Ir(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=`
293
+ display: inline-flex;
294
+ align-items: stretch;
295
+ border: var(--fb-border-width) solid var(--fb-border-color);
296
+ border-radius: var(--fb-border-radius);
297
+ overflow: hidden;
298
+ background: var(--fb-background-color);
299
+ `;const d=(s,f)=>{const c=document.createElement("button");return c.type="button",c.textContent=s,c.tabIndex=-1,c.style.cssText=`
300
+ width: 32px;
301
+ border: none;
302
+ background: transparent;
303
+ color: var(--fb-text-color);
304
+ font-size: var(--fb-font-size);
305
+ font-family: var(--fb-font-family);
306
+ cursor: ${n?"default":"pointer"};
307
+ user-select: none;
308
+ `,n?(c.disabled=!0,c.style.opacity="0.5"):c.addEventListener("click",u=>{var p;u.preventDefault();const m=parseFloat(e.value),b=Number.isFinite(m)?m:(p=a!=null?a:t.default)!=null?p:0;let v=parseFloat((b+f*o).toPrecision(12));a!=null&&(v=Math.max(a,v)),i!=null&&(v=Math.min(i,v)),e.value=String(v),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}),c};return e.classList.add("fb-stepper-input"),e.style.cssText=`
309
+ width: 56px;
310
+ border: none;
311
+ border-left: var(--fb-border-width) solid var(--fb-border-color);
312
+ border-right: var(--fb-border-width) solid var(--fb-border-color);
313
+ padding: var(--fb-input-padding-y) 0;
314
+ font-size: var(--fb-font-size);
315
+ font-family: var(--fb-font-family);
316
+ text-align: center;
317
+ background: transparent;
318
+ color: var(--fb-text-color);
319
+ -moz-appearance: textfield;
320
+ box-sizing: border-box;
321
+ `,l.appendChild(d("\u2212",-1)),l.appendChild(e),l.appendChild(d("+",1)),l}function ln(e,t){const n=document.createElement("span");n.className="number-range-hint",n.style.cssText=`
322
+ position: absolute;
323
+ top: 50%;
324
+ transform: translateY(-50%);
325
+ right: 10px;
326
+ font-size: var(--fb-font-size-small);
327
+ color: var(--fb-text-secondary-color);
328
+ pointer-events: none;
329
+ background: var(--fb-background-color);
330
+ padding: 0 4px;
331
+ `;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 d=r!=null&&l<r,s=o!=null&&l>o;n.style.color=d||s?"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 Rr(e,t,n,r){const o=t.state,a=ie(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=`
332
+ padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
333
+ font-size: var(--fb-font-size);
334
+ font-family: var(--fb-font-family);
335
+ width: 100%;
336
+ box-sizing: border-box;
337
+ `),!a&&t.instance){const d=()=>{const s=l.value?parseFloat(l.value):null;t.instance.triggerOnChange(r,s)};l.addEventListener("blur",d),l.addEventListener("input",d)}if(e.stepper)i.appendChild(Ir(l,e,a));else if(i.appendChild(l),!a&&(e.min!=null||e.max!=null)){const d=ln(e,l);i.appendChild(d)}n.appendChild(i)}function qr(e,t,n,r){var o,a;const i=t.state,l=ie(e,i,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],f=(o=e.minCount)!=null?o:e.required?1:0,c=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"");const u=document.createElement("div");u.className="fb-row",n.appendChild(u);function p(){u.querySelectorAll(".multiple-number-item").forEach((h,y)=>{const g=h.querySelector("input");g&&(g.name=`${r}[${y}]`)})}function m(h="",y=-1){const g=document.createElement("div");g.className="multiple-number-item flex items-center gap-2";const C=document.createElement("div");C.style.cssText="position: relative; flex: 1;";const w=document.createElement("input");if(w.type="number",w.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",w.style.cssText=`
338
+ padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
339
+ font-size: var(--fb-font-size);
340
+ font-family: var(--fb-font-family);
341
+ width: 100%;
342
+ box-sizing: border-box;
343
+ `,w.placeholder=e.placeholder||"0",e.min!==void 0&&(w.min=e.min.toString()),e.max!==void 0&&(w.max=e.max.toString()),e.step!==void 0&&(w.step=e.step.toString()),w.value=h.toString(),w.readOnly=l,!l&&t.instance){const x=()=>{const S=w.value?parseFloat(w.value):null;t.instance.triggerOnChange(w.name,S)};w.addEventListener("blur",x),w.addEventListener("input",x)}if(C.appendChild(w),!l&&(e.min!=null||e.max!=null)){const x=ln(e,w);C.appendChild(x)}return g.appendChild(C),y===-1?u.appendChild(g):u.insertBefore(g,u.children[y]),p(),g}function b(){if(l)return;const h=u.querySelectorAll(".multiple-number-item"),y=h.length;h.forEach(g=>{let C=g.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(u.children).indexOf(g);u.children.length>f&&(s.splice(x,1),g.remove(),p(),E(),b())},g.appendChild(C));const w=y<=f;C.disabled=w,C.style.opacity=w?"0.5":"1",C.style.pointerEvents=w?"none":"auto"})}let v=null;if(!l){const h=ze("number",()=>{s.push(e.default||""),m(e.default||""),E(),b()},{label:e.addLabel});v=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){v&&v(s.length,c)}s.forEach(h=>m(h)),E(),b()}function Br(e,t,n){var r,o,a,i,l;const d=[],{scopeRoot:s,skipValidation:f}=n,c=(p,m)=>{var b,v;if(!p)return;const E=`error-${p.getAttribute("name")||Math.random().toString(36).substring(7)}`;let h=document.getElementById(E);m?(p.classList.add("invalid"),p.title=m,h||(h=document.createElement("div"),h.id=E,h.className="error-message",h.style.cssText=`
344
+ color: var(--fb-error-color);
345
+ font-size: var(--fb-font-size-small);
346
+ margin-top: 0.25rem;
347
+ `,p.nextSibling?(b=p.parentNode)==null||b.insertBefore(h,p.nextSibling):(v=p.parentNode)==null||v.appendChild(h)),h.textContent=m,h.style.display="block"):(p.classList.remove("invalid"),p.title="",h&&h.remove())},u=(p,m,b)=>{let v=!1;const{state:E}=n;if(!f&&e.min!==void 0&&e.min!==null&&m<e.min){const h=k("minValue",E,{min:e.min});d.push(`${b}: ${h}`),c(p,h),v=!0}else if(!f&&e.max!==void 0&&e.max!==null&&m>e.max){const h=k("maxValue",E,{max:e.max});d.push(`${b}: ${h}`),c(p,h),v=!0}v||c(p,null)};if(e.multiple){const p=s.querySelectorAll(`[name^="${t}\\["]`),m=[];if(p.forEach((b,v)=>{var E,h,y;const g=(E=b==null?void 0:b.value)!=null?E:"";if(g===""){m.push(null),c(b,null);return}const C=parseFloat(g);if(!f&&!Number.isFinite(C)){const x=k("notANumber",n.state);d.push(`${t}[${v}]: ${x}`),c(b,x),m.push(null);return}u(b,C,`${t}[${v}]`);const w=Number.isInteger((h=e.decimals)!=null?h:0)&&(y=e.decimals)!=null?y:0;m.push(Number(C.toFixed(w)))}),!f){const{state:b}=n,v=(r=e.minCount)!=null?r:0,E=(o=e.maxCount)!=null?o:1/0,h=m.filter(y=>y!==null);e.required&&h.length===0&&d.push(`${t}: ${k("required",b)}`),h.length<v&&d.push(`${t}: ${k("minItems",b,{min:v})}`),h.length>E&&d.push(`${t}: ${k("maxItems",b,{max:E})}`)}return{value:m,errors:d}}else{const p=s.querySelector(`[name$="${t}"]`),m=(a=p==null?void 0:p.value)!=null?a:"",{state:b}=n;if(!f&&e.required&&m===""){const h=k("required",b);return d.push(`${t}: ${h}`),c(p,h),{value:null,errors:d}}if(m==="")return c(p,null),{value:null,errors:d};const v=parseFloat(m);if(!f&&!Number.isFinite(v)){const h=k("notANumber",b);return d.push(`${t}: ${h}`),c(p,h),{value:null,errors:d}}u(p,v,t);const E=Number.isInteger((i=e.decimals)!=null?i:0)&&(l=e.decimals)!=null?l:0;return{value:Number(v.toFixed(E)),errors:d}}}function Hr(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="",Ce(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="",Ce(a))}}function Dr(e,t,n,r){const o=t.state,a=ie(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=`
348
+ padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
349
+ font-size: var(--fb-font-size);
350
+ font-family: var(--fb-font-family);
351
+ `,i.name=r,i.disabled=a,(e.options||[]).forEach(l=>{const d=document.createElement("option");d.value=l.value,d.textContent=l.label,(t.prefill[e.key]||e.default)===l.value&&(d.selected=!0),i.appendChild(d)}),!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 d=t.state,s=ie(e,d,t),f=t.prefill[e.key]||[],c=Array.isArray(f)?[...f]:[],u=(o=e.minCount)!=null?o:e.required?1:0,p=(a=e.maxCount)!=null?a:1/0;for(;c.length<u;)c.push(e.default||((l=(i=e.options)==null?void 0:i[0])==null?void 0:l.value)||"");const m=document.createElement("div");m.className="fb-row",n.appendChild(m);function b(){m.querySelectorAll(".multiple-select-item").forEach((g,C)=>{const w=g.querySelector("select");w&&(w.name=`${r}[${C}]`)})}function v(g="",C=-1){const w=document.createElement("div");w.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=`
352
+ padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
353
+ font-size: var(--fb-font-size);
354
+ font-family: var(--fb-font-family);
355
+ `,x.disabled=s,(e.options||[]).forEach(S=>{const z=document.createElement("option");z.value=S.value,z.textContent=S.label,g===S.value&&(z.selected=!0),x.appendChild(z)}),!s&&t.instance){const S=()=>{t.instance.triggerOnChange(x.name,x.value)};x.addEventListener("change",S)}return w.appendChild(x),C===-1?m.appendChild(w):m.insertBefore(w,m.children[C]),b(),w}function E(){if(s)return;const g=m.querySelectorAll(".multiple-select-item"),C=g.length;g.forEach(w=>{let x=w.querySelector(".remove-item-btn");x||(x=document.createElement("button"),x.type="button",x.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",x.innerHTML="\u2715",x.onclick=()=>{const z=Array.from(m.children).indexOf(w);m.children.length>u&&(c.splice(z,1),w.remove(),b(),y(),E())},w.appendChild(x));const S=C<=u;x.disabled=S,x.style.opacity=S?"0.5":"1",x.style.pointerEvents=S?"none":"auto"})}let h=null;if(!s){const g=ze("select",()=>{var C,w;const x=e.default||((w=(C=e.options)==null?void 0:C[0])==null?void 0:w.value)||"";c.push(x),v(x),y(),E()},{label:e.addLabel});h=g.update,Te(n,g.counter),n.appendChild(g.row)}function y(){h&&h(c.length,p)}if(c.forEach(g=>v(g)),y(),E(),!s){const g=document.createElement("p");g.className="text-xs text-gray-500 mt-1",g.textContent=Le(e,d),n.appendChild(g)}}function Or(e,t,n){var r;const o=[],{scopeRoot:a,skipValidation:i}=n,l=(s,f)=>{var c,u;if(!s)return;const p=`error-${s.getAttribute("name")||Math.random().toString(36).substring(7)}`;let m=document.getElementById(p);f?(s.classList.add("invalid"),s.title=f,m||(m=document.createElement("div"),m.id=p,m.className="error-message",m.style.cssText=`
356
+ color: var(--fb-error-color);
357
+ font-size: var(--fb-font-size-small);
358
+ margin-top: 0.25rem;
359
+ `,s.nextSibling?(c=s.parentNode)==null||c.insertBefore(m,s.nextSibling):(u=s.parentNode)==null||u.appendChild(m)),m.textContent=f,m.style.display="block"):(s.classList.remove("invalid"),s.title="",m&&m.remove())},d=(s,f,c,u)=>{var p,m;if(i)return;const{state:b}=n,v=f.filter(u),E="minCount"in c&&(p=c.minCount)!=null?p:0,h="maxCount"in c&&(m=c.maxCount)!=null?m:1/0;c.required&&v.length===0&&o.push(`${s}: ${k("required",b)}`),v.length<E&&o.push(`${s}: ${k("minItems",b,{min:E})}`),v.length>h&&o.push(`${s}: ${k("maxItems",b,{max:h})}`)};if("multiple"in e&&e.multiple){const s=a.querySelectorAll(`[name^="${t}\\["]`),f=[];return s.forEach(c=>{var u;const p=(u=c==null?void 0:c.value)!=null?u:"";f.push(p),l(c,null)}),d(t,f,e,c=>c!==""),{value:f,errors:o}}else{const s=a.querySelector(`[name$="${t}"]`),f=(r=s==null?void 0:s.value)!=null?r:"";if(!i&&e.required&&f===""){const c=k("required",n.state);return o.push(`${t}: ${c}`),l(s,c),{value:null,errors:o}}else l(s,null);return{value:f===""?null:f,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(d=>{d.selected=d.value===String(n[l])}),i.classList.remove("invalid"),i.title="",Ce(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="",Ce(a))}}function lt(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 it(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 an(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=`
360
+ display: inline-flex;
361
+ align-items: center;
362
+ gap: 8px;
363
+ padding: 7px 12px 7px 10px;
364
+ border-width: var(--fb-border-width);
365
+ border-style: solid;
366
+ border-radius: 999px;
367
+ background: var(--fb-background-color);
368
+ font-size: var(--fb-font-size);
369
+ font-family: var(--fb-font-family);
370
+ line-height: 1.25;
371
+ cursor: ${t?"default":"pointer"};
372
+ transition: background-color var(--fb-transition-duration), color var(--fb-transition-duration), border-color var(--fb-transition-duration);
373
+ outline: none;
374
+ `,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=`
375
+ display: block;
376
+ flex: 0 0 auto;
377
+ width: 20px;
378
+ height: 20px;
379
+ object-fit: contain;
380
+ `,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=`
381
+ font-size: var(--fb-font-size-small);
382
+ opacity: 0.7;
383
+ font-variant-numeric: tabular-nums;
384
+ `,n.appendChild(o)}return n}function sn(e,t,n,r,o){const a=e.options||[],i=a.some(s=>s.subtitle||s.iconUrl),l=document.createElement("div");l.className="fb-switcher-group",l.style.cssText=i?`
385
+ display: flex;
386
+ flex-direction: row;
387
+ flex-wrap: wrap;
388
+ gap: 6px;
389
+ `:`
390
+ display: inline-flex;
391
+ flex-direction: row;
392
+ flex-wrap: nowrap;
393
+ `;const d=[];return a.forEach((s,f)=>{let c;i?c=Pr(s,r):(c=document.createElement("button"),c.type="button",c.className="fb-switcher-btn",c.dataset.value=s.value,c.textContent=s.label,c.style.cssText=`
394
+ padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
395
+ font-size: var(--fb-font-size);
396
+ border-width: var(--fb-border-width);
397
+ border-style: solid;
398
+ cursor: ${r?"default":"pointer"};
399
+ transition: background-color var(--fb-transition-duration), color var(--fb-transition-duration), border-color var(--fb-transition-duration);
400
+ white-space: nowrap;
401
+ line-height: 1.25;
402
+ outline: none;
403
+ `,a.length===1?c.style.borderRadius="var(--fb-border-radius)":f===0?(c.style.borderRadius="var(--fb-border-radius) 0 0 var(--fb-border-radius)",c.style.borderRightWidth="0"):f===a.length-1?c.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(c.style.borderRadius="0",c.style.borderRightWidth="0")),s.value===t?lt(c,i):it(c,i),r||(c.addEventListener("click",()=>{n.value=s.value,d.forEach(u=>{u.dataset.value===s.value?lt(u,i):it(u,i)}),o&&o(s.value)}),c.addEventListener("mouseenter",()=>{n.value!==s.value&&(c.style.backgroundColor="var(--fb-background-hover-color)")}),c.addEventListener("mouseleave",()=>{n.value!==s.value&&(c.style.backgroundColor=i?"var(--fb-background-color)":"transparent")})),d.push(c),l.appendChild(c)}),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:""),d=document.createElement("input");d.type="hidden",d.name=r,d.value=l;const s=ie(e,i,t),f=!s&&t.instance?u=>{t.instance.triggerOnChange(r,u)}:null,c=sn(e,l,d,s,f);if(n.appendChild(d),n.appendChild(c),!s){const u=document.createElement("p");u.className="text-xs text-gray-500 mt-1",u.textContent=Le(e,i),n.appendChild(u)}}function Vr(e,t,n,r){var o,a,i,l;const d=t.state,s=t.prefill[e.key]||[],f=Array.isArray(s)?[...s]:[],c=(o=e.minCount)!=null?o:e.required?1:0,u=(a=e.maxCount)!=null?a:1/0;for(;f.length<c;)f.push(e.default||((l=(i=e.options)==null?void 0:i[0])==null?void 0:l.value)||"");const p=ie(e,d,t),m=document.createElement("div");m.className="fb-row",n.appendChild(m);function b(){m.querySelectorAll(".multiple-switcher-item").forEach((g,C)=>{const w=g.querySelector("input[type=hidden]");w&&(w.name=`${r}[${C}]`)})}function v(g="",C=-1){const w=C===-1?m.children.length:C,x=`${r}[${w}]`,S=document.createElement("div");S.className="multiple-switcher-item flex items-center gap-2";const z=document.createElement("input");z.type="hidden",z.name=x,z.value=g,S.appendChild(z);const ae=!p&&t.instance?H=>{t.instance.triggerOnChange(z.name,H)}:null,K=sn(e,g,z,p,ae);return S.appendChild(K),C===-1?m.appendChild(S):m.insertBefore(S,m.children[C]),b(),S}function E(){if(p)return;const g=m.querySelectorAll(".multiple-switcher-item"),C=g.length;g.forEach(w=>{let x=w.querySelector(".remove-item-btn");x||(x=document.createElement("button"),x.type="button",x.className="remove-item-btn px-2 py-1 rounded",x.style.cssText=`
404
+ color: var(--fb-error-color);
405
+ background-color: transparent;
406
+ transition: background-color var(--fb-transition-duration);
407
+ `,x.innerHTML="\u2715",x.addEventListener("mouseenter",()=>{x.style.backgroundColor="var(--fb-background-hover-color)"}),x.addEventListener("mouseleave",()=>{x.style.backgroundColor="transparent"}),x.onclick=()=>{const z=Array.from(m.children).indexOf(w);m.children.length>c&&(f.splice(z,1),w.remove(),b(),y(),E())},w.appendChild(x));const S=C<=c;x.disabled=S,x.style.opacity=S?"0.5":"1",x.style.pointerEvents=S?"none":"auto"})}let h=null;if(!p){const g=ze("switcher",()=>{var C,w;const x=e.default||((w=(C=e.options)==null?void 0:C[0])==null?void 0:w.value)||"";f.push(x),v(x),y(),E()},{label:e.addLabel});h=g.update,Te(n,g.counter),n.appendChild(g.row)}function y(){h&&h(f.length,u)}if(f.forEach(g=>v(g)),y(),E(),!p){const g=document.createElement("p");g.className="text-xs text-gray-500 mt-1",g.textContent=Le(e,d),n.appendChild(g)}}function Kr(e,t,n){var r;const o=[],{scopeRoot:a,skipValidation:i}=n,l=(f,c)=>{var u,p;if(!f)return;const m=`error-${f.getAttribute("name")||Math.random().toString(36).substring(7)}`;let b=document.getElementById(m);c?(f.classList.add("invalid"),f.title=c,b||(b=document.createElement("div"),b.id=m,b.className="error-message",b.style.cssText=`
408
+ color: var(--fb-error-color);
409
+ font-size: var(--fb-font-size-small);
410
+ margin-top: 0.25rem;
411
+ `,f.nextSibling?(u=f.parentNode)==null||u.insertBefore(b,f.nextSibling):(p=f.parentNode)==null||p.appendChild(b)),b.textContent=c,b.style.display="block"):(f.classList.remove("invalid"),f.title="",b&&b.remove())},d=(f,c,u,p)=>{var m,b;if(i)return;const{state:v}=n,E=c.filter(p),h="minCount"in u&&(m=u.minCount)!=null?m:0,y="maxCount"in u&&(b=u.maxCount)!=null?b:1/0;u.required&&E.length===0&&o.push(`${f}: ${k("required",v)}`),E.length<h&&o.push(`${f}: ${k("minItems",v,{min:h})}`),E.length>y&&o.push(`${f}: ${k("maxItems",v,{max:y})}`)},s=new Set("options"in e?e.options.map(f=>f.value):[]);if("multiple"in e&&e.multiple){const f=a.querySelectorAll(`input[type="hidden"][name^="${t}\\["]`),c=[];return f.forEach(u=>{var p;const m=(p=u==null?void 0:u.value)!=null?p:"";if(c.push(m),!i&&m!==""&&!s.has(m)){const b=k("invalidOption",n.state);l(u,b),o.push(`${t}: ${b}`)}else l(u,null)}),d(t,c,e,u=>u!==""),{value:c,errors:o}}else{const f=a.querySelector(`input[type="hidden"][name$="${t}"]`),c=(r=f==null?void 0:f.value)!=null?r:"";if(!i&&e.required&&c===""){const u=k("required",n.state);return o.push(`${t}: ${u}`),l(f,u),{value:null,errors:o}}if(!i&&c!==""&&!s.has(c)){const u=k("invalidOption",n.state);return o.push(`${t}: ${u}`),l(f,u),{value:null,errors:o}}return l(f,null),{value:c===""?null:c,errors:o}}}function _r(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,d)=>{var s;if(d<n.length){const f=n[d]!=null?String(n[d]):"";l.value=f;const c=(s=l.parentElement)==null?void 0:s.querySelector(".fb-switcher-group");c&&c.querySelectorAll(".fb-switcher-btn").forEach(u=>{const p=an(u);u.dataset.value===f?lt(u,p):it(u,p)}),l.classList.remove("invalid"),l.title="",Ce(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 d=(o=i.parentElement)==null?void 0:o.querySelector(".fb-switcher-group");d&&d.querySelectorAll(".fb-switcher-btn").forEach(s=>{const f=an(s);s.dataset.value===l?lt(s,f):it(s,f)}),i.classList.remove("invalid"),i.title="",Ce(i)}}}const dn=36,Ye=20,Oe=16;function Jr(e){const t="fb-boolean-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
412
+ .fb-toggle {
413
+ position: relative;
414
+ display: inline-block;
415
+ width: ${dn}px;
416
+ height: ${Ye}px;
417
+ border-radius: ${Ye}px;
418
+ background: var(--fb-border-color);
419
+ transition: background-color var(--fb-transition-duration);
420
+ flex-shrink: 0;
421
+ }
422
+ .fb-toggle::after {
423
+ content: "";
424
+ position: absolute;
425
+ top: ${(Ye-Oe)/2}px;
426
+ left: ${(Ye-Oe)/2}px;
427
+ width: ${Oe}px;
428
+ height: ${Oe}px;
429
+ border-radius: 50%;
430
+ background: #ffffff;
431
+ box-shadow: 0 1px 3px rgba(0,0,0,0.2);
432
+ transition: transform var(--fb-transition-duration);
433
+ }
434
+ .fb-toggle.fb-on {
435
+ background: var(--fb-primary-color);
436
+ }
437
+ .fb-toggle.fb-on::after {
438
+ transform: translateX(${dn-Oe-(Ye-Oe)}px);
439
+ }
440
+ .fb-toggle-row {
441
+ display: flex;
442
+ align-items: center;
443
+ gap: 12px;
444
+ padding: 12px 14px;
445
+ background: var(--fb-surface-soft-color);
446
+ border: var(--fb-border-width) solid var(--fb-border-color);
447
+ border-radius: var(--fb-border-radius);
448
+ cursor: pointer;
449
+ user-select: none;
450
+ }
451
+ .fb-toggle-row[aria-disabled="true"] {
452
+ cursor: default;
453
+ opacity: 0.7;
454
+ }
455
+ .fb-toggle-row:focus-visible {
456
+ outline: var(--fb-focus-ring-width) solid var(--fb-focus-ring-color);
457
+ outline-offset: var(--fb-focus-ring-offset);
458
+ }
459
+ .fb-toggle-text { flex: 1; min-width: 0; }
460
+ .fb-toggle-title {
461
+ display: flex;
462
+ align-items: center;
463
+ gap: 4px;
464
+ font-size: var(--fb-font-size);
465
+ font-weight: 500;
466
+ color: var(--fb-text-color);
467
+ line-height: 1.3;
468
+ }
469
+ .fb-toggle-subtitle {
470
+ font-size: var(--fb-font-size-small);
471
+ color: var(--fb-text-secondary-color);
472
+ margin-top: 2px;
473
+ line-height: 1.35;
474
+ }
475
+ .fb-toggle-info {
476
+ flex: 0 0 14px;
477
+ display: inline-flex;
478
+ align-items: center;
479
+ justify-content: center;
480
+ width: 14px;
481
+ height: 14px;
482
+ border-radius: 50%;
483
+ background: var(--fb-border-color);
484
+ color: #fff;
485
+ font-size: 10px;
486
+ font-weight: 700;
487
+ font-style: italic;
488
+ font-family: serif;
489
+ cursor: help;
490
+ }
491
+ `,e.head.appendChild(n)}function kt(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=ie(e,a,t),l=t.prefill[e.key],d=kt(l!==void 0?l:e.default),s=document.createElement("input");s.type="hidden",s.name=r,s.value=d?"true":"false";const f=document.createElement("div");f.className="fb-toggle-row",f.setAttribute("role","switch"),f.setAttribute("aria-checked",d?"true":"false"),i?f.setAttribute("aria-disabled","true"):f.tabIndex=0;const c=document.createElement("span");c.className="fb-toggle"+(d?" fb-on":""),c.setAttribute("aria-hidden","true"),f.appendChild(c);const u=document.createElement("div");u.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(u.appendChild(p),e.hint){const m=document.createElement("div");m.className="fb-toggle-subtitle",m.textContent=e.hint,u.appendChild(m)}if(f.appendChild(u),!i){const m=()=>{const b=s.value!=="true";s.value=b?"true":"false",c.classList.toggle("fb-on",b),f.setAttribute("aria-checked",b?"true":"false"),t.instance&&t.instance.triggerOnChange(r,b)};f.addEventListener("click",b=>{var v;(v=b.target)!=null&&v.classList.contains("fb-toggle-info")||m()}),f.addEventListener("keydown",b=>{(b.key===" "||b.key==="Enter")&&(b.preventDefault(),m())})}n.appendChild(s),n.appendChild(f)}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:kt(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=kt(n);i.value=l?"true":"false";const d=(o=i.parentElement)==null?void 0:o.querySelector(".fb-toggle-row");if(d){d.setAttribute("aria-checked",l?"true":"false");const s=d.querySelector(".fb-toggle");s&&s.classList.toggle("fb-on",l)}}function Re(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 Ue(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 cn(e,t){return t===1/0?!0:e<=t*1024*1024}function at(e,t){return cn(e.size,t)}function Xe(e){return e?typeof e=="string"?[]:Array.isArray(e.mime)?e.mime.map(t=>t.toLowerCase()):[]:[]}function Ge(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 st(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 $t(e,t){for(const n of e)st(n,t)}const un="fb-file-styles";function $e(){if(typeof document=="undefined"||document.getElementById(un))return;const e=document.createElement("style");if(e.id=un,e.setAttribute("data-fb-file-styles","true"),e.textContent=`
492
+ @keyframes fb-spin { to { transform: rotate(360deg); } }
493
+
494
+ /* \u2500\u2500\u2500 Checker background utility \u2500\u2500\u2500 */
495
+ /* Neutral diagonal-stripe background for image previews (never crops) */
496
+ .fb-checker {
497
+ background-image: repeating-linear-gradient(45deg, #fafafa 0 6px, #f3f4f6 6px 12px);
498
+ }
499
+
500
+ /* \u2500\u2500\u2500 Spinner \u2500\u2500\u2500 */
501
+ .fb-spinner {
502
+ width: 36px;
503
+ height: 36px;
504
+ border: 3px solid rgba(0,0,0,0.12);
505
+ border-top-color: var(--fb-text-secondary-color, #6b7280);
506
+ border-radius: 50%;
507
+ animation: fb-spin 0.7s linear infinite;
508
+ flex-shrink: 0;
509
+ }
510
+
511
+ /* \u2500\u2500\u2500 Wide single-file add tile (empty state) \u2500\u2500\u2500 */
512
+ /* Flex-wraps: side-by-side when wide enough, stacks upload/library
513
+ vertically when narrow (e.g. inside a 50/50 container column). */
514
+ .fb-wide-tile {
515
+ width: 100%;
516
+ box-sizing: border-box;
517
+ border-radius: 0.75rem;
518
+ border: 1px dashed #60a5fa;
519
+ background: rgba(239,246,255,0.5);
520
+ display: flex;
521
+ flex-wrap: wrap;
522
+ align-items: stretch;
523
+ gap: 0;
524
+ overflow: hidden;
525
+ /* min-height driven by --fb-file-wide-min so size-tokens (.fb-size-{xs|sm|lg|xl})
526
+ can override per-field. Default 96px matches v0.4.0 compact density. */
527
+ min-height: var(--fb-file-wide-min, 96px);
528
+ transition: border-color 150ms, background 150ms, box-shadow 150ms;
529
+ cursor: pointer;
530
+ }
531
+ .fb-wide-tile:hover {
532
+ background: #eff6ff;
533
+ }
534
+ .fb-wide-tile.fb-drag-over {
535
+ border-color: #3b82f6;
536
+ border-width: 2px;
537
+ background: #eff6ff;
538
+ box-shadow: 0 0 0 4px rgba(191,219,254,0.7);
539
+ }
540
+
541
+ /* Upload zone inside wide tile.
542
+ flex: 1 1 220px \u2014 wants at least 220px; if the container can't fit
543
+ upload + library on one row (~220 + 176), library wraps below. */
544
+ .fb-wide-tile-upload {
545
+ flex: 1 1 220px;
546
+ /* min-height theme-driven; default 72px matches v0.4.0 compact density. */
547
+ min-height: var(--fb-file-zone-min, 72px);
548
+ display: flex;
549
+ flex-direction: column;
550
+ align-items: center;
551
+ justify-content: center;
552
+ gap: 4px;
553
+ color: #2563eb;
554
+ padding: var(--fb-file-zone-padding, 8px);
555
+ transition: background 150ms;
556
+ cursor: pointer;
557
+ background: transparent;
558
+ border: none;
559
+ font-family: inherit;
560
+ /* Dashed separator from library: right side when in a row, bottom when
561
+ wrapped (the line then sits between the two stacked cards). */
562
+ border-right: 1px dashed rgba(96,165,250,0.5);
563
+ }
564
+ .fb-wide-tile-upload:hover {
565
+ background: rgba(191,219,254,0.25);
566
+ }
567
+ /* Library zone inside wide tile.
568
+ flex: 0 0 176px \u2014 fixed 176px, never grows. Upload fills the rest in
569
+ row layout. When the tile wraps to two rows on narrow containers,
570
+ library stays 176px wide on its own row (left-aligned), preserving the
571
+ visual hierarchy "upload > library" in both layouts. */
572
+ .fb-wide-tile-library {
573
+ flex: 0 0 176px;
574
+ /* Shares --fb-file-zone-min with the upload zone so size-tokens scale both
575
+ uniformly. Default 72px matches v0.4.0 compact density. */
576
+ min-height: var(--fb-file-zone-min, 72px);
577
+ display: flex;
578
+ flex-direction: column;
579
+ align-items: center;
580
+ justify-content: center;
581
+ gap: 4px;
582
+ color: #2563eb;
583
+ padding: var(--fb-file-zone-padding, 8px);
584
+ transition: background 150ms;
585
+ cursor: pointer;
586
+ background: transparent;
587
+ border: none;
588
+ font-family: inherit;
589
+ }
590
+ .fb-wide-tile-library:hover {
591
+ background: rgba(191,219,254,0.25);
592
+ }
593
+ /* Narrow-tile mode lives in a separate <style> tag (see below) \u2014 the
594
+ @container rule is appended only when the runtime actually supports
595
+ container queries, so jsdom (which doesn't) never sees it and stays
596
+ quiet in test logs. */
597
+
598
+ /* \u2500\u2500\u2500 Multi-file outer grid container \u2500\u2500\u2500 */
599
+ .fb-multi-outer {
600
+ border-radius: 0.75rem;
601
+ border: 1px dashed #cbd5e1;
602
+ background: rgba(248,250,252,0.4);
603
+ padding: 12px;
604
+ transition: border-color 150ms, background 150ms, box-shadow 150ms;
605
+ }
606
+ .fb-multi-outer.fb-drag-over {
607
+ border-width: 2px;
608
+ border-color: #3b82f6;
609
+ background: rgba(239,246,255,0.4);
610
+ box-shadow: 0 0 0 4px rgba(191,219,254,0.7);
611
+ }
612
+
613
+ /* With files present: white solid border */
614
+ .fb-multi-outer.fb-multi-has-files {
615
+ border-style: solid;
616
+ border-color: #e2e8f0;
617
+ background: #fff;
618
+ }
619
+
620
+ /* The CSS grid inside */
621
+ .fb-multi-grid {
622
+ display: grid;
623
+ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
624
+ gap: 10px;
625
+ }
626
+
627
+ /* \u2500\u2500\u2500 Multi square add-tile (combined upload + library) \u2500\u2500\u2500 */
628
+ .fb-multi-add-tile {
629
+ aspect-ratio: 1 / 1;
630
+ border-radius: 0.5rem;
631
+ border: 1px dashed #60a5fa;
632
+ background: rgba(239,246,255,0.5);
633
+ display: flex;
634
+ flex-direction: column;
635
+ overflow: hidden;
636
+ transition: background 150ms;
637
+ }
638
+ .fb-multi-add-tile:hover {
639
+ background: #eff6ff;
640
+ }
641
+ .fb-multi-add-tile.fb-drag-over-tile {
642
+ border-width: 2px;
643
+ border-color: #3b82f6;
644
+ background: rgba(255,255,255,0.8);
645
+ }
646
+
647
+ /* Upload half of add-tile */
648
+ .fb-multi-add-upload {
649
+ flex: 1;
650
+ display: flex;
651
+ flex-direction: column;
652
+ align-items: center;
653
+ justify-content: center;
654
+ gap: 4px;
655
+ color: #2563eb;
656
+ cursor: pointer;
657
+ background: transparent;
658
+ border: none;
659
+ font-family: inherit;
660
+ width: 100%;
661
+ transition: background 150ms;
662
+ }
663
+ .fb-multi-add-upload:hover {
664
+ background: rgba(191,219,254,0.35);
665
+ }
666
+
667
+ /* Horizontal dashed divider inside add-tile */
668
+ .fb-multi-add-divider {
669
+ border-top: 1px dashed rgba(96,165,250,0.5);
670
+ margin: 0;
671
+ flex-shrink: 0;
672
+ }
673
+
674
+ /* Library strip at bottom of add-tile */
675
+ .fb-multi-add-library {
676
+ padding: 6px 0;
677
+ display: flex;
678
+ align-items: center;
679
+ justify-content: center;
680
+ gap: 4px;
681
+ color: #2563eb;
682
+ font-size: 11px;
683
+ font-weight: 500;
684
+ cursor: pointer;
685
+ background: transparent;
686
+ border: none;
687
+ font-family: inherit;
688
+ width: 100%;
689
+ transition: background 150ms;
690
+ flex-shrink: 0;
691
+ }
692
+ .fb-multi-add-library:hover {
693
+ background: rgba(191,219,254,0.35);
694
+ }
695
+
696
+ /* \u2500\u2500\u2500 Capacity placeholder squares \u2500\u2500\u2500 */
697
+ .fb-multi-placeholder {
698
+ aspect-ratio: 1 / 1;
699
+ border-radius: 0.5rem;
700
+ border: 1px solid #e2e8f0;
701
+ }
702
+ .fb-multi-placeholder.fb-drag-over {
703
+ border-width: 2px;
704
+ border-style: dashed;
705
+ border-color: #93c5fd;
706
+ background: rgba(219,234,254,0.6);
707
+ }
708
+
709
+ /* \u2500\u2500\u2500 Filled preview tile \u2500\u2500\u2500 */
710
+ .fb-preview-tile {
711
+ aspect-ratio: 1 / 1;
712
+ border-radius: 0.5rem;
713
+ border: 1px solid #e2e8f0;
714
+ overflow: hidden;
715
+ position: relative;
716
+ cursor: pointer;
717
+ }
718
+ .fb-preview-tile img {
719
+ width: 100%;
720
+ height: 100%;
721
+ object-fit: contain;
722
+ display: block;
723
+ }
724
+
725
+ /* \u2500\u2500\u2500 Uploading placeholder tile \u2500\u2500\u2500 */
726
+ .fb-uploading-tile {
727
+ aspect-ratio: 1 / 1;
728
+ border-radius: 0.5rem;
729
+ border: 2px dashed #d1d5db;
730
+ display: flex;
731
+ flex-direction: column;
732
+ align-items: center;
733
+ justify-content: center;
734
+ gap: 6px;
735
+ padding: 6px;
736
+ }
737
+
738
+ /* \u2500\u2500\u2500 Clear-all row below multi grid \u2500\u2500\u2500 */
739
+ .fb-clear-all-row {
740
+ margin-top: 10px;
741
+ display: flex;
742
+ align-items: center;
743
+ justify-content: flex-end;
744
+ }
745
+ .fb-clear-all-btn {
746
+ font-size: 12px;
747
+ color: #94a3b8;
748
+ background: none;
749
+ border: none;
750
+ cursor: pointer;
751
+ padding: 0;
752
+ font-family: inherit;
753
+ transition: color 150ms;
754
+ white-space: nowrap;
755
+ flex-shrink: 0;
756
+ }
757
+ .fb-clear-all-btn:hover {
758
+ color: #dc2626;
759
+ }
760
+
761
+ /* \u2500\u2500\u2500 Empty text (readonly) \u2500\u2500\u2500 */
762
+ .fb-tile-empty-text {
763
+ font-size: 11px;
764
+ color: var(--fb-text-secondary-color, #6b7280);
765
+ padding: 4px 0;
766
+ }
767
+
768
+ /* \u2500\u2500\u2500 Tile action buttons (for zoom popup, compat) \u2500\u2500\u2500 */
769
+ .fb-tile-actions {
770
+ position: absolute;
771
+ top: 3px;
772
+ right: 3px;
773
+ display: flex;
774
+ flex-direction: row;
775
+ gap: 3px;
776
+ opacity: 0;
777
+ transition: opacity var(--fb-transition-duration, 200ms);
778
+ z-index: 10;
779
+ }
780
+ .fb-preview-tile:hover .fb-tile-actions {
781
+ opacity: 1;
782
+ }
783
+ .fb-tile-action-btn {
784
+ width: 24px;
785
+ height: 24px;
786
+ display: flex;
787
+ align-items: center;
788
+ justify-content: center;
789
+ border: 1px solid rgba(15,23,42,0.08);
790
+ border-radius: 0.375rem;
791
+ cursor: pointer;
792
+ background: rgba(255,255,255,0.92);
793
+ color: #374151;
794
+ padding: 0;
795
+ flex-shrink: 0;
796
+ box-shadow: 0 1px 2px rgba(0,0,0,0.06);
797
+ transition: background var(--fb-transition-duration, 200ms),
798
+ color var(--fb-transition-duration, 200ms);
799
+ }
800
+ .fb-tile-action-btn:hover {
801
+ background: #ffffff;
802
+ color: #0f172a;
803
+ }
804
+ .fb-tile-action-remove:hover {
805
+ color: #dc2626;
806
+ }
807
+
808
+ /* Zoom popup action buttons always visible */
809
+ .fb-tile-zoom-preview .fb-tile-actions {
810
+ position: absolute;
811
+ top: 6px;
812
+ right: 6px;
813
+ opacity: 1;
814
+ z-index: 10000;
815
+ }
816
+
817
+ /* \u2500\u2500\u2500 Hover zoom preview popup \u2500\u2500\u2500 */
818
+ .fb-tile-zoom-preview {
819
+ position: fixed;
820
+ z-index: 9999;
821
+ background: var(--fb-background-color, #fff);
822
+ border: 1px solid #e2e8f0;
823
+ border-radius: 0.5rem;
824
+ box-shadow: 0 4px 16px rgba(0,0,0,0.18);
825
+ padding: 4px;
826
+ width: 350px;
827
+ height: 350px;
828
+ pointer-events: none;
829
+ opacity: 0;
830
+ transition: opacity 150ms ease;
831
+ }
832
+ .fb-tile-zoom-preview.fb-tile-zoom-preview--visible {
833
+ opacity: 1;
834
+ }
835
+ .fb-tile-zoom-preview-img {
836
+ width: 100%;
837
+ height: 100%;
838
+ object-fit: contain;
839
+ display: block;
840
+ border-radius: calc(0.5rem - 2px);
841
+ }
842
+
843
+ /* \u2500\u2500\u2500 Single-file uploading state \u2500\u2500\u2500 */
844
+ .fb-single-uploading {
845
+ height: 180px;
846
+ border-radius: 0.75rem;
847
+ border: 1px dashed #60a5fa;
848
+ background: rgba(239,246,255,0.5);
849
+ display: flex;
850
+ flex-direction: column;
851
+ align-items: center;
852
+ justify-content: center;
853
+ gap: 8px;
854
+ }
855
+
856
+ /* \u2500\u2500\u2500 Video overlays \u2500\u2500\u2500 */
857
+ .fb-video-overlay {
858
+ position: absolute;
859
+ inset: 0;
860
+ display: flex;
861
+ align-items: center;
862
+ justify-content: center;
863
+ background: rgba(0,0,0,0.25);
864
+ }
865
+ .fb-play-btn {
866
+ background: rgba(255,255,255,0.9);
867
+ border-radius: 50%;
868
+ display: flex;
869
+ align-items: center;
870
+ justify-content: center;
871
+ }
872
+ .fb-video-preview-wrap {
873
+ position: relative;
874
+ width: 100%;
875
+ height: 100%;
876
+ }
877
+ .fb-video-btn-overlay {
878
+ position: absolute;
879
+ top: 8px;
880
+ right: 8px;
881
+ z-index: 10;
882
+ display: flex;
883
+ gap: 4px;
884
+ opacity: 0;
885
+ transition: opacity 150ms;
886
+ pointer-events: none;
887
+ }
888
+ .fb-video-preview-wrap:hover .fb-video-btn-overlay {
889
+ opacity: 1;
890
+ pointer-events: auto;
891
+ }
892
+ .fb-video-btn {
893
+ border: none;
894
+ border-radius: 4px;
895
+ font-size: 11px;
896
+ padding: 4px 8px;
897
+ cursor: pointer;
898
+ color: #fff;
899
+ line-height: 1.2;
900
+ }
901
+ .fb-video-btn-delete { background: rgba(220,38,38,0.85); }
902
+ .fb-video-btn-delete:hover { background: rgba(185,28,28,0.95); }
903
+ .fb-video-btn-change { background: rgba(31,41,55,0.85); }
904
+ .fb-video-btn-change:hover { background: rgba(17,24,39,0.95); }
905
+
906
+ /* \u2500\u2500\u2500 Readonly readonly tile \u2500\u2500\u2500 */
907
+ .fb-readonly-tile {
908
+ aspect-ratio: 1 / 1;
909
+ border-radius: 0.5rem;
910
+ border: 1px solid #e2e8f0;
911
+ overflow: hidden;
912
+ position: relative;
913
+ cursor: pointer;
914
+ }
915
+ .fb-readonly-tile img {
916
+ width: 100%;
917
+ height: 100%;
918
+ object-fit: contain;
919
+ display: block;
920
+ }
921
+ .fb-readonly-tile .fb-tile-actions {
922
+ opacity: 0;
923
+ }
924
+ .fb-readonly-tile:hover .fb-tile-actions {
925
+ opacity: 1;
926
+ }
927
+
928
+ /* \u2500\u2500\u2500 Readonly single-file filled \u2500\u2500\u2500 */
929
+ .fb-single-readonly-filled {
930
+ position: relative;
931
+ border-radius: 0.75rem;
932
+ border: 1px solid #e2e8f0;
933
+ overflow: hidden;
934
+ height: 220px;
935
+ display: block;
936
+ cursor: pointer;
937
+ }
938
+ .fb-single-readonly-filled img {
939
+ width: 100%;
940
+ height: 100%;
941
+ object-fit: contain;
942
+ display: block;
943
+ }
944
+
945
+ /* \u2500\u2500\u2500 Readonly multi grid \u2500\u2500\u2500 */
946
+ .fb-multi-readonly-grid {
947
+ display: grid;
948
+ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
949
+ gap: 10px;
950
+ }
951
+ `,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=`
952
+ .fb-wide-tile { container-type: inline-size; }
953
+ @container (max-width: 408px) {
954
+ .fb-wide-tile-upload {
955
+ border-right: none;
956
+ border-bottom: 1px dashed rgba(96,165,250,0.5);
957
+ }
958
+ .fb-wide-tile-library {
959
+ flex: 1 0 100%;
960
+ min-height: 0;
961
+ flex-direction: row;
962
+ gap: 6px;
963
+ padding: 8px 12px;
964
+ font-size: 12px;
965
+ }
966
+ .fb-wide-tile-library .fb-wide-tile-library-icon {
967
+ width: 16px;
968
+ height: 16px;
969
+ }
970
+ .fb-wide-tile-library .fb-wide-tile-library-label {
971
+ font-size: 12px;
972
+ font-weight: 500;
973
+ }
974
+ .fb-wide-tile-library .fb-wide-tile-library-hint {
975
+ display: none;
976
+ }
977
+ }
978
+ `,document.head.appendChild(t)}}function fn(){$e();const e=document.createElement("div");return e.className="fb-tile",e}function Se(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=`
979
+ color: var(--fb-error-color);
980
+ font-size: var(--fb-font-size-small);
981
+ margin-top: 0.25rem;
982
+ `,a.textContent=t,(r=e.closest("[data-files-wrapper]"))==null||r.appendChild(a)}function Ze(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=fn();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=`
983
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:4px;">
984
+ <div class="fb-spinner"></div>
985
+ <div class="fb-tile-label">${se(r)}</div>
986
+ <div class="fb-tile-uploading-text">${se(k("uploadingFile",t))}</div>
987
+ </div>`,n}function St(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 Lt(e,t,n){e.innerHTML=`
988
+ <div class="flex flex-col items-center justify-center h-full text-gray-400">
989
+ <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
990
+ <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"/>
991
+ </svg>
992
+ <div class="text-sm text-center">${se(k("clickDragText",t))}</div>
993
+
994
+ </div>
995
+ `}const pn=new WeakMap;function dt(e,t){const n=pn.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 d=(l=i.dataTransfer)==null?void 0:l.files;d&&t(d)};e.addEventListener("dragover",r),e.addEventListener("dragleave",o),e.addEventListener("drop",a),pn.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 Tt(e){const{canRemove:t,removeHandler:n,state:r,resourceId:o,fileName:a,meta:i,replaceHandler:l,libraryHandler:d}=e,s=document.createElement("div");s.className="fb-tile-actions";const f=(c,u,p)=>{const m=document.createElement("button");return m.type="button",m.className=`fb-tile-action-btn ${p}`,m.innerHTML=c,m.title=u,m.setAttribute("aria-label",u),m.addEventListener("click",b=>{b.stopPropagation()}),m};if(l){const c=f(oo,k("replaceFile",r),"fb-tile-action-replace");c.addEventListener("click",()=>l()),s.appendChild(c)}if(d){const c=f(lo,k("fromLibrary",r),"fb-tile-action-library");c.addEventListener("click",()=>d()),s.appendChild(c)}if(io(r,i)){const c=f(to,k("downloadFile",r),"fb-tile-action-download");c.addEventListener("click",()=>{so(o,a,r,i)}),s.appendChild(c)}if(ao(r,i)){const c=f(no,k("openInNewTab",r),"fb-tile-action-open");c.addEventListener("click",()=>{co(o,r,i).catch(u=>{console.error("Open failed:",u)})}),s.appendChild(c)}if(t&&n){const c=f(ro,k("removeElement",r),"fb-tile-action-remove");c.addEventListener("click",()=>{n()}),s.appendChild(c)}return s}const ct=new WeakMap;function At(e){let t=ct.get(e);return t||(t=URL.createObjectURL(e),ct.set(e,t)),t}function qe(e){if(!e)return;const t=ct.get(e);t&&(URL.revokeObjectURL(t),ct.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){xn(r.file,t||r.file.name);return}yn(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=At(n.file)),r&&window.open(r,"_blank")}let Ee=null,Me=null,Be=null,ut=null;function uo(){if(!Ee){Ee=document.createElement("div"),Ee.className="fb-tile-zoom-preview";const e=document.createElement("img");e.className="fb-tile-zoom-preview-img",Ee.appendChild(e),Ee.addEventListener("mouseenter",hn),Ee.addEventListener("mouseleave",mn)}return Ee}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 mn(){Be!==null&&clearTimeout(Be),Be=setTimeout(()=>{Be=null,bn()},100)}function hn(){Be!==null&&(clearTimeout(Be),Be=null)}function bn(){Me!==null&&(clearTimeout(Me),Me=null),Ee&&Ee.parentNode&&(Ee.classList.remove("fb-tile-zoom-preview--visible"),Ee.parentNode.removeChild(Ee)),ut=null}function Ft(e,t,n,r){e.dataset.zoomSrc=t,e.dataset.zoomAlt=n,e.addEventListener("mouseenter",()=>{hn(),ut!==e&&bn(),ut=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,ut=null):mn()})}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=`
996
+ <div class="fb-video-preview-wrap">
997
+ <video style="width:100%;height:100%;object-fit:contain;" controls preload="auto" muted src="${i}">
998
+ ${se(k("videoNotSupported",o))}
999
+ </video>
1000
+ <div class="fb-video-btn-overlay">
1001
+ <button class="fb-video-btn fb-video-btn-delete delete-file-btn">
1002
+ ${se(k("removeElement",o))}
1003
+ </button>
1004
+ <button class="fb-video-btn fb-video-btn-change change-file-btn">
1005
+ ${se(k("changeButton",o))}
1006
+ </button>
1007
+ </div>
1008
+ </div>
1009
+ `,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=`
1010
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
1011
+ <svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
1012
+ <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"/>
1013
+ </svg>
1014
+ <div style="font-size:0.875rem;text-align:center;">${se(k("clickDragText",n))}</div>
1015
+ </div>
1016
+ `,r!=null&&r.setupDrop&&r.setupDrop(e)}function vn(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=`
1017
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
1018
+ <svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
1019
+ <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"/>
1020
+ </svg>
1021
+ <div style="font-size:0.875rem;text-align:center;">${se(k("clickDragText",n))}</div>
1022
+ </div>
1023
+ `})}async function yo(e,t,n,r,o,a,i){var l,d,s;!t.file||!(t.file instanceof File)||((l=t.type)!=null&&l.startsWith("image/")?mo(e,t.file,n,a):(d=t.type)!=null&&d.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;">${se(n)}</div></div>`,!o&&!((s=t.type)!=null&&s.startsWith("video/"))&&vn(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){Lt(e,o);return}try{const i=await o.config.getThumbnail(t);if(i)if(we(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 Lt(e,o)}catch(i){console.error("Failed to get thumbnail:",i),e.innerHTML=`
1024
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
1025
+ <svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
1026
+ <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"/>
1027
+ </svg>
1028
+ <div style="font-size:0.875rem;text-align:center;">${se(n||k("previewUnavailable",o))}</div>
1029
+ </div>
1030
+ `}}async function zt(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}");we(e);const d=n.resourceIndex.get(t);if(d&&d.file&&d.file instanceof File)await yo(e,d,a,t,i,n,l);else{await wo(e,t,a,d,n);const s=(o=d==null?void 0:d.type)==null?void 0:o.startsWith("video/");!i&&!s&&vn(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 Mt(e,t,n,r={}){var o,a;const i=t.resourceIndex.get(e),l=Co(e,i,n),{canRemove:d=!1,removeHandler:s=null}=r,f=((o=i==null?void 0:i.type)==null?void 0:o.startsWith("image/"))||!!l.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/),c=((a=i==null?void 0:i.type)==null?void 0:a.startsWith("video/"))||!!l.toLowerCase().match(/\.(mp4|webm|avi|mov)$/),u=fn();u.classList.add("fb-tile-resource"),u.style.cursor="pointer",l&&(u.title=l);const p=(i==null?void 0:i.file)instanceof File?At(i.file):null,m=async()=>t.config.getDownloadUrl?t.config.getDownloadUrl(e):t.config.getThumbnail?t.config.getThumbnail(e):p;u.onclick=async()=>{const h=await m();h?window.open(h,"_blank"):t.config.downloadFile?t.config.downloadFile(e,l):yn(e,l,t).catch(y=>{console.error("Download failed:",y)})};const b=Tt({canRemove:d,removeHandler:s,state:t,resourceId:e,fileName:l,meta:i}),v=async()=>{if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);if(h)return h}catch(h){}return p},E=()=>{u.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>',u.appendChild(b)};if(f){const h=await v();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,u.appendChild(y),u.appendChild(b),Ft(u,h,l,b)}else E()}else if(c)if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);h?(u.innerHTML=`
1031
+ <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${se(l)}" src="${h}">
1032
+ <div class="fb-video-overlay">
1033
+ <div class="fb-play-btn" style="width:22px;height:22px;">
1034
+ <svg width="10" height="12" viewBox="0 0 10 12" fill="currentColor"><path d="M0 0l10 6-10 6z"/></svg>
1035
+ </div>
1036
+ </div>`,u.appendChild(b)):(u.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',u.appendChild(b))}catch(h){u.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',u.appendChild(b)}else u.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',u.appendChild(b);else{if(t.config.getThumbnail)try{const y=await t.config.getThumbnail(e);if(y){const g=document.createElement("img");return g.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",g.alt=l||e,g.src=y,u.appendChild(g),u.appendChild(b),u}}catch(y){}const h=l?`<div class="fb-tile-label">${se(l.length>10?l.substring(0,8)+"\u2026":l)}</div>
1037
+ <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>`:"";u.innerHTML=`
1038
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
1039
+ <div style="font-size:36px;">\u{1F4C1}</div>
1040
+ ${h}
1041
+ </div>`,u.appendChild(b)}return u}async function Eo(e,t,n,r){var o,a,i;const l=n.resourceIndex.get(t),d=(a=(o=l==null?void 0:l.name)!=null?o:t.split("/").pop())!=null?a:"",s=(i=r.onRemove)!=null?i:null,f=await Mt(t,n,d,{canRemove:!0,removeHandler:s});e.className="file-preview-container",e.removeAttribute("style"),we(e),e.appendChild(f)}async function gn(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=At(n.file),e.appendChild(l),Ft(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 d=document.createElement("img");d.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",d.alt=n.name,d.src=l,e.appendChild(d),Ft(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 d=l instanceof Error?l:new Error(String(l));r.config.onThumbnailError&&r.config.onThumbnailError(d,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=`
1042
+ <video style="width:100%;height:100%;" preload="metadata" muted src="${l}"></video>
1043
+ <div class="fb-video-overlay">
1044
+ <div class="fb-play-btn" style="width:20px;height:20px;">
1045
+ <svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
1046
+ </div>
1047
+ </div>`}else if(r.config.getThumbnail)try{const l=await r.config.getThumbnail(t);l?e.innerHTML=`
1048
+ <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${se(n.name)}" src="${l}">
1049
+ <div class="fb-video-overlay">
1050
+ <div class="fb-play-btn" style="width:20px;height:20px;">
1051
+ <svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
1052
+ </div>
1053
+ </div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(l){const d=l instanceof Error?l:new Error(String(l));r.config.onThumbnailError&&r.config.onThumbnailError(d,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;">${se(i)}</div>`:"";e.innerHTML=`
1054
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
1055
+ <div style="font-size:36px;">\u{1F4C1}</div>
1056
+ ${l}
1057
+ </div>`,r&&e.appendChild(r)}async function yn(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();xn(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 xn(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}`,{cause:n})}}async function wn(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:d=null,instance:s=null,allowedExtensions:f=[],allowedMimes:c=[],maxSizeMB:u=1/0}=e;if(!Ue(o.name,f)){const h=f.join(", ");Se(a,k("invalidFileExtension",l,{name:o.name,formats:h}));return}if(!Ge(o.type,c)){const h=c.join(", ");Se(a,k("invalidFileMime",l,{name:o.name,type:o.type,mimes:h}));return}if(!at(o,u)){Se(a,k("fileTooLarge",l,{name:o.name,maxSize:u}));return}Ze(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=`
1058
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:6px;">
1059
+ <div class="fb-spinner"></div>
1060
+ <div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${se(k("uploadingFile",l))}</div>
1061
+ </div>`;let b;try{b=await wn(o,l)}catch(h){throw m&&d!=null&&d.onAfterUpload?d.onAfterUpload(a,m):d!=null&&d.onRemove?d.onRemove():Lt(a,l),h}l.resourceIndex.set(b,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:o}),m&&m!==b&&qe((n=l.resourceIndex.get(m))==null?void 0:n.file);let v=p;v||(v=document.createElement("input"),v.type="hidden",v.name=i,(r=a.parentElement)==null||r.appendChild(v)),v.value=b;const E=o.type.startsWith("video/");!E&&d!=null&&d.onAfterUpload?d.onAfterUpload(a,b):!E&&d?Eo(a,b,l,d).catch(console.error):zt(a,b,l,{fileName:o.name,isReadonly:!1,deps:d}).catch(console.error),s&&!l.config.readonly&&s.triggerOnChange(i,b)}function So(e,t,n,r){const o=e.filter(m=>!Ue(m.name,n.allowedExtensions)),a=e.filter(m=>Ue(m.name,n.allowedExtensions)),i=a.filter(m=>!Ge(m.type,n.allowedMimes)),l=a.filter(m=>Ge(m.type,n.allowedMimes)),d=l.filter(m=>!at(m,n.maxSize)),s=l.filter(m=>at(m,n.maxSize)),f=n.maxCount===1/0?s.length:Math.max(0,n.maxCount-t),c=s.slice(0,f),u=s.length-c.length,p=[];if(o.length>0){const m=n.allowedExtensions.join(", "),b=o.map(v=>v.name).join(", ");p.push(k("invalidFileExtension",r,{name:b,formats:m}))}if(i.length>0){const m=n.allowedMimes.join(", "),b=i.map(v=>v.name).join(", ");p.push(k("invalidFileMime",r,{name:b,type:i.map(v=>v.type).join(", "),mimes:m}))}if(d.length>0){const m=d.map(b=>b.name).join(", ");p.push(k("fileTooLarge",r,{name:m,maxSize:n.maxSize}))}return u>0&&p.push(k("filesLimitExceeded",r,{skipped:u,max:n.maxCount})),{accepted:c,errorMessage:p.join(" \u2022 ")}}async function Lo(e){var t;const{accepted:n,listEl:r,state:o,shouldHideAddTile:a,buildSuccessTile:i,prepareForUpload:l}=e;if(r&&a){const f=St(r),c=(t=f.querySelector(".fb-multi-add-tile-js"))!=null?t:f.querySelector(".fb-tile-add");c&&(c.style.display="none")}l==null||l();const d=new Array(n.length).fill(null),s=[];return await Promise.allSettled(n.map(async(f,c)=>{const u=eo(f.name,o);r&&St(r).appendChild(u);try{const p=await wn(f,o);o.resourceIndex.set(p,{name:f.name,type:f.type,size:f.size,uploadedAt:new Date,file:f}),d[c]=p,i&&u.parentNode?u.replaceWith(i(p)):u.remove()}catch(p){const m=p instanceof Error?p:new Error(String(p)),b=m.cause,v=b instanceof Error?b:b!==void 0?new Error(String(b)):m;s.push({file:f,error:v}),u.remove()}})),{failures:s,orderedIds:d}}function To(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}async function Cn(e,t,n,r){const{resourceIds:o,state:a,updateCallback:i,constraints:l,pathKey:d,instance:s,buildSuccessTile:f,prepareForUpload:c,coordinator:u}=e,{accepted:p,errorMessage:m}=So(t,u.getOccupiedCount(),l,a);r&&(m?Se(r,m):Ze(r));const b=u.beginBatch(p.length),v=u.getOccupiedCount()>=l.maxCount,{failures:E,orderedIds:h}=await Lo({accepted:p,listEl:n,state:a,shouldHideAddTile:v,buildSuccessTile:f,prepareForUpload:c});b.setResults(h),s&&d&&!a.config.readonly&&s.triggerOnChange(d,o);const{wasLast:y}=b.end();if(y&&i(),r){const g=To(m,E,a);g?Se(r,g):Ze(r)}}function Ao(e){const{filesContainer:t}=e;dt(t,async n=>{var r;const o=(r=t.querySelector(".files-list"))!=null?r:t;await Cn(e,Array.from(n),o,t)})}function Fo(e){const{filesPicker:t}=e;t.onchange=async()=>{var n,r;if(!t.files)return;const o=(n=t.closest("[data-files-wrapper]"))!=null?n:t.parentElement,a=(r=o==null?void 0:o.querySelector(".files-list"))!=null?r:null;await Cn(e,Array.from(t.files),a,o),t.value=""}}function En(e){var t,n;if(!e.accept)return;if(typeof e.accept=="string"){const l=Re(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 kn(e,t,n,r,o){if(!Ue(e.name,t)){const a=t.join(", ");return k("invalidFileExtension",o,{name:e.name,formats:a})}if(!Ge(e.type,n)){const a=n.join(", ");return k("invalidFileMime",o,{name:e.name,type:e.type,mimes:a})}return cn(e.size,r)?null:k("fileTooLarge",o,{name:e.name,maxSize:r})}function $n(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 Sn(e,t){return e instanceof Error&&e.message?e.message:k("pickerError",t)}async function zo(e){var t;const{state:n,element:r,wrapper:o,fieldPath:a,resourceIds:i,maxCount:l,updateCallback:d,instance:s,coordinator:f,list:c,buildSuccessTile:u}=e;if(!n.config.pickExistingFiles)return;const p=Re(r.accept),m=Xe(r.accept),b=(t=r.maxSize)!=null?t:1/0,v=f.getAllKnownRids(),E=new Set(v),h=l===1/0?1/0:Math.max(0,l-f.getOccupiedCount());let y;try{y=await n.config.pickExistingFiles({fieldPath:a,mode:"multiple",accept:En(r),maxSizeMB:b===1/0?void 0:b,remainingSlots:h===1/0?void 0:h,selectedResourceIds:v})}catch(H){Se(o,Sn(H,n));return}if(y.length===0)return;const g=new Set,C=y.filter(H=>E.has(H.resourceId)||g.has(H.resourceId)?!1:(g.add(H.resourceId),!0)).filter(H=>kn(H,p,m,b,n)===null),w=l===1/0?C.length:Math.max(0,l-f.getOccupiedCount()),x=C.slice(0,w),S=C.length-x.length;if(x.length===0){S>0&&Se(o,k("filesLimitExceeded",n,{skipped:S,max:l}));return}Ze(o),S>0&&Se(o,k("filesLimitExceeded",n,{skipped:S,max:l}));for(const H of x)$n(H,n);const z=x.map(H=>H.resourceId),ae=f.beginBatch(x.length);ae.setResults(z),n.config.readonly||s.triggerOnChange(a,i);const{wasLast:K}=ae.end();if(K)d();else{const H=St(c);for(const V of z)H.appendChild(u(V))}}async function Mo(e,t,n,r,o,a,i,l){var d,s;if(!e.config.pickExistingFiles)return;const f=Re(t.accept),c=Xe(t.accept),u=(d=t.maxSize)!=null?d:1/0;let p;try{p=await e.config.pickExistingFiles({fieldPath:a,mode:"single",accept:En(t),maxSizeMB:u===1/0?void 0:u,selectedResourceIds:[]})}catch(h){Se(n,Sn(h,e));return}if(p.length===0)return;const m=p[0],b=kn(m,f,c,u,e);if(b!==null){Se(n,b);return}Ze(n),$n(m,e);let v=r.querySelector('input[type="hidden"]');v||(v=document.createElement("input"),v.type="hidden",v.name=o,r.appendChild(v));const E=v.value||null;E&&E!==m.resourceId&&qe((s=e.resourceIndex.get(E))==null?void 0:s.file),v.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>',Tn='<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 No(e,t,n,r,o,a,i){var l;st(e,o.resourceIndex);const d=o.resourceIndex.get(e);(l=d==null?void 0:d.type)!=null&&l.startsWith("video/")?zt(t,e,o,{fileName:e,isReadonly:!1,deps:a}).catch(console.error):Nt(t,e,o,a,i);const s=document.createElement("input");s.type="hidden",s.name=n,s.value=e,r.appendChild(s)}function Io(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 d=document.createElement("span");d.style.cssText="width:36px;height:36px;display:block;flex-shrink:0;",d.innerHTML=Ln,l.appendChild(d);const s=document.createElement("div");if(s.className="fb-wide-tile-label",s.style.cssText="font-size:14px;font-weight:600;",s.textContent=k(o?"dropToUpload":"clickDragText",e),l.appendChild(s),a){const f=document.createElement("div");f.style.cssText="font-size:11px;opacity:0.65;margin-top:2px;",f.textContent=a,l.appendChild(f)}if(l.onclick=f=>{f.stopPropagation(),n()},i.appendChild(l),t&&r){const f=document.createElement("button");f.type="button",f.className="fb-wide-tile-library fb-file-library-card";const c=document.createElement("span");c.className="fb-wide-tile-library-icon",c.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",c.innerHTML=Tn,f.appendChild(c);const u=document.createElement("div");u.className="fb-wide-tile-library-label",u.style.cssText="font-size:13px;font-weight:600;text-align:center;",u.textContent=k("fromLibrary",e),f.appendChild(u);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),f.appendChild(p),f.onclick=m=>{m.stopPropagation(),r()},i.appendChild(f)}return An(i,{onEnter:()=>{const f=i.querySelector(".fb-wide-tile-label");f&&(f.textContent=k("dropToUpload",e))},onLeave:()=>{const f=i.querySelector(".fb-wide-tile-label");f&&(f.textContent=k("clickDragText",e))},activeClass:"fb-drag-over"}),i}function An(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 Nt(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/")){zt(e,t,n,{fileName:(i=l==null?void 0:l.name)!=null?i:"",isReadonly:!1,deps:r}).catch(console.error);return}$e();const d=document.createElement("div");d.className="fb-multi-outer fb-multi-has-files";const s=document.createElement("div");s.className="fb-multi-grid fb-tiles-wrap",d.appendChild(s);const f=It(t,n,!!r.onRemove,r.onRemove?()=>{var c;return(c=r.onRemove)==null?void 0:c.call(r)}:null,o);for(s.appendChild(f),e.className="file-preview-container",e.removeAttribute("style");e.firstChild;)e.removeChild(e.firstChild);e.appendChild(d)}function Ro(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 d=document.createElement("span");if(d.className="fb-multi-add-label",d.style.cssText="font-size:11px;font-weight:600;",d.textContent=k(o?"dropToUpload":"clickDragTextMultiple",e),i.appendChild(d),i.onclick=s=>{s.stopPropagation(),n()},a.appendChild(i),t&&r){const s=document.createElement("div");s.className="fb-multi-add-divider",a.appendChild(s);const f=document.createElement("button");f.type="button",f.className="fb-multi-add-library fb-tile-add-library fb-file-library-card",f.setAttribute("aria-label",k("fromLibrary",e));const c=document.createElement("span");c.style.cssText="width:14px;height:14px;display:block;flex-shrink:0;",c.innerHTML=Tn,f.appendChild(c),f.appendChild(document.createTextNode(k("fromLibrary",e))),f.onclick=u=>{u.stopPropagation(),r()},a.appendChild(f)}return a}function It(e,t,n,r,o){var a,i,l;$e();const d=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 f=Tt({canRemove:n&&r!==null,removeHandler:r,state:t,resourceId:e,fileName:(a=d==null?void 0:d.name)!=null?a:"",meta:d,replaceHandler:(i=o==null?void 0:o.replaceHandler)!=null?i:null,libraryHandler:(l=o==null?void 0:o.libraryHandler)!=null?l:null});return gn(s,e,d,t,f).catch(c=>{console.error("Failed to render tile:",c)}),s}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){if(t<=1)return null;const r=document.createElement("div");r.className="fb-clear-all-row";const o=document.createElement("button");return o.type="button",o.className="fb-clear-all-btn",o.textContent=k("clearAll",e),o.onclick=a=>{a.stopPropagation(),window.confirm(k("clearAll",e)+"?")&&n()},r.appendChild(o),r}const Qe=new WeakMap,Rt=new WeakMap;function zn(e){const t=Rt.get(e);t!==void 0&&(cancelAnimationFrame(t),Rt.delete(e))}function Bo(e){const t=Qe.get(e);t&&(t.disconnect(),Qe.delete(e)),zn(e),e.querySelectorAll(".fb-multi-placeholder").forEach(n=>n.remove())}function Ho(e){var t;const{container:n,rids:r,state:o,onRemove:a,maxCount:i,isReadonly:l=!1,onLibraryPick:d,onClearAll:s,openPicker:f}=e;$e();const c=n.closest("[data-files-wrapper]");c&&(c.dataset.resourceIds=JSON.stringify(r!=null?r:[]));const u=Qe.get(n);for(u&&(u.disconnect(),Qe.delete(n)),zn(n);n.firstChild;)n.removeChild(n.firstChild);const p=r!=null?r:[],m=i!=null?i:1/0,b=m!==1/0&&p.length>=m,v=!l&&typeof d=="function",E=f!=null?f:(()=>{var w;const x=(w=n.closest("[data-files-wrapper]"))==null?void 0:w.querySelector('input[type="file"]');x&&x.click()});if(l){if(p.length===0){const w=document.createElement("div");w.className="fb-tile-empty-text",w.textContent=k("noFilesSelected",o),n.appendChild(w)}else{const w=document.createElement("div");w.className="fb-multi-readonly-grid",n.appendChild(w);for(const x of p){const S=o.resourceIndex.get(x),z=document.createElement("div");z.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",z.dataset.resourceId=x;const ae=Tt({canRemove:!1,removeHandler:null,state:o,resourceId:x,fileName:(t=S==null?void 0:S.name)!=null?t:"",meta:S});gn(z,x,S,o,ae).catch(console.error),z.onclick=async()=>{var K;let H=null;o.config.getDownloadUrl?H=o.config.getDownloadUrl(x):o.config.getThumbnail?H=await o.config.getThumbnail(x):(S==null?void 0:S.file)instanceof File&&(H=URL.createObjectURL(S.file)),H?window.open(H,"_blank"):o.config.downloadFile&&o.config.downloadFile(x,(K=S==null?void 0:S.name)!=null?K:"")},w.appendChild(z)}}return}const h=document.createElement("div");h.className=`fb-multi-outer${p.length>0?" fb-multi-has-files":""}`;const y=document.createElement("div");y.className="fb-multi-grid fb-tiles-wrap",h.appendChild(y),n.appendChild(h);for(let w=0;w<p.length;w++){const x=p[w],S=It(x,o,a!==null,a?()=>a(x):null);y.appendChild(S)}if(!b){const w=Ro(o,v,E,d!=null?d:null);y.appendChild(w)}const g=p.length+(b?0:1),C=()=>{const w=getComputedStyle(y).gridTemplateColumns,x=w?w.split(" ").filter(Boolean).length:0;if(!x)return;const S=g%x,z=S===0?0:x-S,ae=m===1/0?z:Math.max(0,m-g),K=Math.min(z,ae),H=y.querySelectorAll(".fb-multi-placeholder");if(H.length>K)for(let V=H.length-1;V>=K;V--)H[V].remove();else if(H.length<K)for(let V=H.length;V<K;V++)y.appendChild(Fn())};if((m===1/0||m>g)&&y.appendChild(Fn()),Rt.set(n,requestAnimationFrame(C)),typeof ResizeObserver!="undefined"){const w=new ResizeObserver(()=>C());w.observe(y),Qe.set(n,w)}if(An(h,{activeClass:"fb-drag-over",onEnter:()=>{y.querySelectorAll(".fb-multi-placeholder").forEach(x=>{x.classList.add("fb-drag-over")});const w=y.querySelector(".fb-multi-add-tile-js");if(w){w.classList.add("fb-drag-over-tile");const x=w.querySelector(".fb-multi-add-label");x&&(x.textContent=k("dropToUpload",o))}},onLeave:()=>{y.querySelectorAll(".fb-multi-placeholder").forEach(x=>{x.classList.remove("fb-drag-over")});const w=y.querySelector(".fb-multi-add-tile-js");if(w){w.classList.remove("fb-drag-over-tile");const x=w.querySelector(".fb-multi-add-label");x&&(x.textContent=k("clickDragTextMultiple",o))}}}),s){const w=qo(o,p.length,s);w&&n.appendChild(w)}}function Do(e,t,n,r){var o,a;const i=t.state,l=document.createElement("div");l.className="fb-row",l.dataset.filesWrapper=r;const d=document.createElement("input");d.type="file",d.name=r,d.style.display="none",d.accept=Mn(e.accept);const s=document.createElement("div");s.className="file-preview-container";const f=t.prefill[e.key],c=Re(e.accept),u=Xe(e.accept),p=(o=e.maxSize)!=null?o:1/0,m={fileUploadHandler(){d.click()},dragHandler(h){h.length>0&&$o({file:h[0],container:s,fieldName:r,state:i,deps:v(),instance:t.instance,allowedExtensions:c,allowedMimes:u,maxSizeMB:p})},setupDrop(h){dt(h,m.dragHandler)},onRemove(){var h;const y=l.querySelector('input[type="hidden"]'),g=y==null?void 0:y.value;g&&qe((h=i.resourceIndex.get(g))==null?void 0:h.file),y&&(y.value=""),E()}},b=()=>{const h=!!(i.config.pickExistingFiles&&!e.disableLibrary);return{replaceHandler:i.config.uploadFile?()=>d.click():null,libraryHandler:h?()=>{Mo(i,e,s,l,r,r,async y=>{Nt(s,y,i,v(),b())},t.instance).catch(y=>{console.error("Library pick failed:",y)})}:null}},v=()=>({picker:d,fileUploadHandler:m.fileUploadHandler,dragHandler:m.dragHandler,setupDrop:m.setupDrop,onRemove:m.onRemove,onAfterUpload:(h,y)=>{Nt(h,y,i,v(),b())}}),E=()=>{for($e(),s.className="file-preview-container",s.removeAttribute("style");s.firstChild;)s.removeChild(s.firstChild);const h=b().libraryHandler,y=Io(i,h!==null,m.fileUploadHandler,h,!1,Le(e,i));s.appendChild(y),dt(s,m.dragHandler)};if(f){No(f,s,r,l,i,v(),b());const h=i.resourceIndex.get(f);(a=h==null?void 0:h.type)!=null&&a.startsWith("video/")&&dt(s,m.dragHandler)}else E();d.onchange=()=>{d.files&&d.files.length>0&&m.dragHandler(d.files)},l.appendChild(s),l.appendChild(d),n.appendChild(l)}function Mn(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,d=document.createElement("div");d.className="fb-row",d.dataset.filesWrapper=r;const s=document.createElement("input");s.type="file",s.name=r,s.multiple=!0,s.style.display="none",s.accept=Mn(e.accept);const f=document.createElement("div");f.className="files-list-wrapper";const c=document.createElement("div");c.className="files-list",d.appendChild(s),d.appendChild(f),f.appendChild(c);const u=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];$t(u,l.resourceIndex),d.dataset.resourceIds=JSON.stringify(u);const p={maxCount:o,allowedExtensions:Re(e.accept),allowedMimes:Xe(e.accept),maxSize:(i=(a=e.maxSize)!=null?a:e.maxSizeMB)!=null?i:1/0},m=()=>{s.click()},b=l.config.pickExistingFiles&&!e.disableLibrary?()=>{zo({state:l,element:e,wrapper:d,fieldPath:r,resourceIds:u,maxCount:o,updateCallback:v,instance:t.instance,coordinator:z,list:c,buildSuccessTile:ae}).catch(V=>{console.error("Library pick failed:",V)})}:null;function v(){const V=ie(e,l);Ho({container:c,rids:u,state:l,onRemove:V?null:te=>{var R,G;qe((R=l.resourceIndex.get(te))==null?void 0:R.file);const le=u.indexOf(te);le>-1&&u.splice(le,1),z.hasInFlightBatches()?(x.add(te),(G=c.querySelector(`[data-resource-id="${te}"]`))==null||G.remove(),d.dataset.resourceIds=JSON.stringify(u)):v(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,u)},maxCount:o<1/0?o:void 0,isReadonly:V,onLibraryPick:V?null:b,onClearAll:V?void 0:()=>{var te,R;for(const G of u)qe((te=l.resourceIndex.get(G))==null?void 0:te.file);if(u.splice(0),z.hasInFlightBatches()){const G=c.querySelectorAll("[data-resource-id]");for(const le of G){const pe=le.dataset.resourceId;pe&&(qe((R=l.resourceIndex.get(pe))==null?void 0:R.file),x.add(pe)),le.remove()}d.dataset.resourceIds=JSON.stringify(u)}else v();t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,u)},openPicker:m})}let E=0,h=0,y=0,g=0;const C=new Map,w=new Map,x=new Set,S=()=>{for(var V;C.has(g);){const te=g,R=C.get(te);C.delete(te),g+=1;const G=(V=w.get(te))!=null?V:0;w.delete(te),E-=G;for(const le of R)if(le!==null){if(x.has(le)){x.delete(le);continue}u.push(le)}}d.dataset.resourceIds=JSON.stringify(u)},z={getOccupiedCount:()=>u.length+E,getAllKnownRids:()=>{const V=[...u];for(const te of C.values())for(const R of te)R!==null&&V.push(R);return V},hasInFlightBatches:()=>h>0||w.size>0,wasRemovedDuringBatch:V=>x.has(V),beginBatch:V=>{E+=V,h+=1;const te=y++;return w.set(te,V),{setResults:R=>{C.set(te,R),S()},end:()=>{h-=1;const R=h===0&&w.size===0;return R&&x.clear(),{wasLast:R}}}}},ae=V=>{const te=ie(e,l);return It(V,l,!te,te?null:()=>{var R,G,le;qe((R=l.resourceIndex.get(V))==null?void 0:R.file);const pe=u.indexOf(V);if(pe>-1){u.splice(pe,1),z.hasInFlightBatches()?(x.add(V),(G=c.querySelector(`[data-resource-id="${V}"]`))==null||G.remove(),d.dataset.resourceIds=JSON.stringify(u)):v(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,u);return}x.add(V),(le=c.querySelector(`[data-resource-id="${V}"]`))==null||le.remove(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,u)})},K=()=>Bo(c),H={resourceIds:u,state:l,updateCallback:v,constraints:p,pathKey:r,instance:t.instance,buildSuccessTile:ae,prepareForUpload:K,coordinator:z};Ao({...H,filesContainer:f}),Fo({...H,filesPicker:s}),v(),n.appendChild(d)}function jo(e,t,n,r){Nn(e,t,n,r,1/0)}function Oo(e,t,n,r){var o;Nn(e,t,n,r,(o=e.maxCount)!=null?o:1/0)}function Uo(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 Po(e,t,n,r,o){var a,i;const l="minCount"in n&&(a=n.minCount)!=null?a:0,d="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>d&&o.push(`${e}: ${k("maxFiles",r,{max:d})}`)}function In(e,t,n,r,o){var a,i;const l="accept"in n?n.accept:void 0,d=Re(l),s=Xe(l);if(d.length===0&&s.length===0)return;const f=d.join(", "),c=s.join(", ");for(const u of t){const p=r.resourceIndex.get(u),m=(a=p==null?void 0:p.name)!=null?a:u;if(d.length>0&&!Ue(m,d)){o.push(`${e}: ${k("invalidFileExtension",r,{name:m,formats:f})}`);continue}if(s.length>0&&!(p!=null&&p.inferredFromExtension)){const b=(i=p==null?void 0:p.type)!=null?i:"";Ge(b,s)||o.push(`${e}: ${k("invalidFileMime",r,{name:m,type:b,mimes:c})}`)}}}function Rn(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 d=r.resourceIndex.get(l);d&&d.size>i*1024*1024&&o.push(`${e}: ${k("fileTooLarge",r,{name:d.name,maxSize:i})}`)}}function Wo(e,t,n){const{scopeRoot:r,skipValidation:o,path:a,state:i}=n,l=[],d=De(a,t),s=Uo(r,d);return o||(Po(t,s,e,i,l),In(t,s,e,i,l),Rn(t,s,e,i,l)),{value:s,errors:l}}function Vo(e,t,n){var r;const{scopeRoot:o,skipValidation:a,state:i}=n,l=[],d=o.querySelector(`input[name$="${t}"][type="hidden"]`),s=(r=d==null?void 0:d.value)!=null?r:"";return!a&&e.required&&s===""?(l.push(`${t}: ${k("required",i)}`),{value:null,errors:l}):(!a&&s!==""&&(In(t,[s],e,i,l),Rn(t,[s],e,i,l)),{value:s||null,errors:l})}function qn(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?Wo(e,t,n):Vo(e,t,n)}function Ko(e,t,n,r){const o=t.state,a=t.prefill[e.key],i=typeof a=="string"?a:"";if(i){$t([i],o.resourceIndex);const l=document.createElement("input");l.type="hidden",l.name=r,l.value=i,n.appendChild(l),Mt(i,o).then(d=>{d.classList.add("fb-single-readonly-filled","fb-readonly-tile","fb-checker"),n.appendChild(d)}).catch(console.error)}else n.appendChild(_o(o))}function _o(e){$e();const t=document.createElement("div");return t.style.cssText=`
1062
+ height: 220px;
1063
+ display:flex;
1064
+ align-items:center;
1065
+ justify-content:center;
1066
+ background: repeating-linear-gradient(45deg, #fafafa 0 6px, #f3f4f6 6px 12px);
1067
+ border-radius:0.75rem;
1068
+ border:1px solid #e2e8f0;
1069
+ `,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${se(k("noFileSelected",e))}</div>`,t}function Bn(e,t,n,r,o){$t(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 d=document.createElement("div");d.className="fb-tile-empty-text",d.textContent=k("noFilesSelected",t),a.appendChild(d);return}const i=document.createElement("div");i.className="fb-multi-readonly-grid",a.appendChild(i);const l=e.map(()=>{const d=document.createElement("div");return d.className="fb-readonly-tile fb-checker fb-tile",i.appendChild(d),d});for(let d=0;d<e.length;d++){const s=e[d],f=l[d],c=t.resourceIndex.get(s);Mt(s,t,c==null?void 0:c.name).then(u=>{u.classList.add("fb-readonly-tile","fb-checker","fb-tile-resource"),u.dataset.resourceId=s,f.replaceWith(u)}).catch(()=>{const u=document.createElement("div");u.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",u.dataset.resourceId=s,f.replaceWith(u)})}}function Jo(e,t,n,r){const o=t.prefill[e.key],a=Array.isArray(o)?o:[];Bn(a,t.state,n,r)}function Yo(e,t,n,r){const o=t.prefill[e.key],a=Array.isArray(o)?o:[];Bn(a,t.state,n,r)}function Xo(e,t,n,r){ie(e,t.state,t)?Ko(e,t,n,r):Do(e,t,n,r)}function Go(e,t,n,r){ie(e,t.state,t)?Jo(e,t,n,r):jo(e,t,n,r)}function Zo(e,t,n,r){ie(e,t.state,t)?Yo(e,t,n,r):Oo(e,t,n,r)}function Hn(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"&&st(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"&&(st(n,a.resourceIndex),console.info(`updateFileField: File field "${t}" updated. Preview update requires re-render.`))}}function Pe(e){return e?e.toUpperCase():"#000000"}function qt(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=Pe(e),r=document.createElement("div");r.style.cssText=`
1070
+ width: 32px;
1071
+ height: 32px;
1072
+ border-radius: var(--fb-border-radius);
1073
+ border: var(--fb-border-width) solid var(--fb-border-color);
1074
+ background-color: ${n};
1075
+ `;const o=document.createElement("span");return o.style.cssText=`
1076
+ font-size: var(--fb-font-size);
1077
+ color: var(--fb-text-color);
1078
+ font-family: var(--fb-font-family-mono, monospace);
1079
+ `,o.textContent=n,t.appendChild(r),t.appendChild(o),t}function On(e,t,n){const r=Pe(e),o=document.createElement("div");o.className="colour-picker-wrapper",o.style.cssText=`
1080
+ display: flex;
1081
+ align-items: center;
1082
+ gap: 8px;
1083
+ `;const a=document.createElement("div");a.className="colour-swatch",a.style.cssText=`
1084
+ width: 40px;
1085
+ height: 40px;
1086
+ border-radius: var(--fb-border-radius);
1087
+ border: var(--fb-border-width) solid var(--fb-border-color);
1088
+ background-color: ${r};
1089
+ cursor: pointer;
1090
+ transition: border-color var(--fb-transition-duration) ease-in-out;
1091
+ flex-shrink: 0;
1092
+ `;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=`
1093
+ width: 100px;
1094
+ padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
1095
+ border: var(--fb-border-width) solid var(--fb-border-color);
1096
+ border-radius: var(--fb-border-radius);
1097
+ background-color: var(--fb-background-color);
1098
+ color: var(--fb-text-color);
1099
+ font-size: var(--fb-font-size);
1100
+ font-family: var(--fb-font-family-mono, monospace);
1101
+ transition: all var(--fb-transition-duration) ease-in-out;
1102
+ `;const l=document.createElement("input");return l.type="color",l.className="colour-picker-hidden",l.value=r.toLowerCase(),l.style.cssText=`
1103
+ position: absolute;
1104
+ opacity: 0;
1105
+ pointer-events: none;
1106
+ `,i.addEventListener("input",()=>{const d=i.value.trim();if(qt(d)){const s=Dn(d);a.style.backgroundColor=s,l.value=s.toLowerCase(),i.classList.remove("invalid"),n.instance&&n.instance.triggerOnChange(t,s)}else i.classList.add("invalid")}),i.addEventListener("blur",()=>{const d=i.value.trim();if(qt(d)){const s=Dn(d);i.value=s,a.style.backgroundColor=s,l.value=s.toLowerCase(),i.classList.remove("invalid")}}),l.addEventListener("change",()=>{const d=Pe(l.value);i.value=d,a.style.backgroundColor=d,n.instance&&n.instance.triggerOnChange(t,d)}),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 Qo(e,t,n,r){const o=t.state,a=ie(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=`
1107
+ font-size: var(--fb-font-size-small);
1108
+ color: var(--fb-text-secondary-color);
1109
+ `,l.textContent=Le(e,o),n.appendChild(l)}}function el(e,t,n,r){var o,a;const i=t.state,l=ie(e,i,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],f=(o=e.minCount)!=null?o:e.required?1:0,c=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"#000000");const u=document.createElement("div");u.className="fb-row",n.appendChild(u);function p(){u.querySelectorAll(".multiple-colour-item").forEach((h,y)=>{const g=h.querySelector("input");g&&(g.name=`${r}[${y}]`)})}function m(h="#000000",y=-1){const g=document.createElement("div");if(g.className="multiple-colour-item flex items-center gap-2",l){const C=jn(h);for(;C.firstChild;)g.appendChild(C.firstChild)}else{const C=`${r}[${u.children.length}]`,w=On(h,C,t);w.style.flex="1",g.appendChild(w)}return y===-1?u.appendChild(g):u.insertBefore(g,u.children[y]),p(),g}function b(){if(l)return;const h=u.querySelectorAll(".multiple-colour-item"),y=h.length;h.forEach(g=>{let C=g.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=`
1110
+ color: var(--fb-error-color);
1111
+ background-color: transparent;
1112
+ transition: background-color var(--fb-transition-duration);
1113
+ `,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(u.children).indexOf(g);u.children.length>f&&(s.splice(x,1),g.remove(),p(),E(),b())},g.appendChild(C));const w=y<=f;C.disabled=w,C.style.opacity=w?"0.5":"1",C.style.pointerEvents=w?"none":"auto"})}let v=null;if(!l){const h=ze("colour",()=>{const y=e.default||"#000000";s.push(y),m(y),E(),b()},{label:e.addLabel});v=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){v&&v(s.length,c)}if(s.forEach(h=>m(h)),E(),b(),!l){const h=document.createElement("p");h.className="mt-1",h.style.cssText=`
1114
+ font-size: var(--fb-font-size-small);
1115
+ color: var(--fb-text-secondary-color);
1116
+ `,h.textContent=Le(e,i),n.appendChild(h)}}function tl(e,t,n){var r,o,a;const i=[],{scopeRoot:l,skipValidation:d}=n,s=(c,u)=>{var p,m;if(!c)return;const b=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let v=document.getElementById(b);u?(c.classList.add("invalid"),c.title=u,v||(v=document.createElement("div"),v.id=b,v.className="error-message",v.style.cssText=`
1117
+ color: var(--fb-error-color);
1118
+ font-size: var(--fb-font-size-small);
1119
+ margin-top: 0.25rem;
1120
+ `,c.nextSibling?(p=c.parentNode)==null||p.insertBefore(v,c.nextSibling):(m=c.parentNode)==null||m.appendChild(v)),v.textContent=u,v.style.display="block"):(c.classList.remove("invalid"),c.title="",v&&v.remove())},f=(c,u,p)=>{const{state:m}=n;if(!u){if(!d&&e.required){const v=k("required",m);return i.push(`${p}: ${v}`),s(c,v),""}return s(c,null),""}const b=Pe(u);if(!d&&!qt(b)){const v=k("invalidHexColour",m);return i.push(`${p}: ${v}`),s(c,v),u}return s(c,null),b};if(e.multiple){const c=l.querySelectorAll(`[name^="${t}\\["].colour-hex-input`),u=[];if(c.forEach((p,m)=>{var b;const v=(b=p==null?void 0:p.value)!=null?b:"",E=f(p,v,`${t}[${m}]`);u.push(E)}),!d){const{state:p}=n,m=(r=e.minCount)!=null?r:0,b=(o=e.maxCount)!=null?o:1/0,v=u.filter(E=>E!=="");e.required&&v.length===0&&i.push(`${t}: ${k("required",p)}`),v.length<m&&i.push(`${t}: ${k("minItems",p,{min:m})}`),v.length>b&&i.push(`${t}: ${k("maxItems",p,{max:b})}`)}return{value:u,errors:i}}else{const c=l.querySelector(`[name="${t}"].colour-hex-input`),u=(a=c==null?void 0:c.value)!=null?a:"";if(!d&&e.required&&u===""){const p=k("required",n.state);return i.push(`${t}: ${p}`),s(c,p),{value:"",errors:i}}return{value:f(c,u,t),errors:i}}}function nl(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 d=Pe(n[l]);i.value=d,i.classList.remove("invalid"),i.title="",Ce(i);const s=i.closest(".colour-picker-wrapper");if(s){const f=s.querySelector(".colour-swatch"),c=s.querySelector(".colour-picker-hidden");f&&(f.style.backgroundColor=d),c&&(c.value=d.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=Pe(n);a.value=i,a.classList.remove("invalid"),a.title="",Ce(a);const l=a.closest(".colour-picker-wrapper");if(l){const d=l.querySelector(".colour-swatch"),s=l.querySelector(".colour-picker-hidden");d&&(d.style.backgroundColor=i),s&&(s.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 Bt(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 ft(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 d=document.createElement("div");d.className="flex-1";const s=document.createElement("input");s.type="range",s.name=t,s.className="slider-input w-full",s.disabled=o;const f=n.scale||"linear",c=n.min,u=n.max,p=(a=n.step)!=null?a:1;if(f==="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=Bt(e,c,u);s.value=(h*1e3).toString()}else s.min=c.toString(),s.max=u.toString(),s.step=p.toString(),s.value=e.toString();s.style.cssText=`
1121
+ height: 6px;
1122
+ border-radius: 3px;
1123
+ background: linear-gradient(
1124
+ to right,
1125
+ var(--fb-primary-color) 0%,
1126
+ var(--fb-primary-color) ${(e-c)/(u-c)*100}%,
1127
+ var(--fb-border-color) ${(e-c)/(u-c)*100}%,
1128
+ var(--fb-border-color) 100%
1129
+ );
1130
+ outline: none;
1131
+ transition: background 0.1s ease-in-out;
1132
+ cursor: ${o?"not-allowed":"pointer"};
1133
+ opacity: ${o?"0.6":"1"};
1134
+ `,d.appendChild(s);const m=document.createElement("div");m.className="flex justify-between",m.style.cssText=`
1135
+ font-size: var(--fb-font-size-small);
1136
+ color: var(--fb-text-secondary-color);
1137
+ margin-top: 4px;
1138
+ `;const b=document.createElement("span");b.textContent=c.toString();const v=document.createElement("span");v.textContent=u.toString(),m.appendChild(b),m.appendChild(v),d.appendChild(m);const E=document.createElement("span");if(E.className="slider-value",E.style.cssText=`
1139
+ min-width: 60px;
1140
+ text-align: right;
1141
+ font-size: var(--fb-font-size);
1142
+ color: var(--fb-text-color);
1143
+ font-family: var(--fb-font-family-mono, monospace);
1144
+ font-weight: 500;
1145
+ padding-top: 2px;
1146
+ `,E.textContent=e.toFixed(p<1?2:0),l.appendChild(d),l.appendChild(E),i.appendChild(l),!o){const h=()=>{let y;if(f==="exponential"){const C=parseFloat(s.value)/1e3;y=Un(C,c,u),y=ft(y,p),y=Math.max(c,Math.min(u,y))}else y=parseFloat(s.value),y=ft(y,p);E.textContent=y.toFixed(p<1?2:0);const g=(y-c)/(u-c)*100;s.style.background=`linear-gradient(
1147
+ to right,
1148
+ var(--fb-primary-color) 0%,
1149
+ var(--fb-primary-color) ${g}%,
1150
+ var(--fb-border-color) ${g}%,
1151
+ var(--fb-border-color) 100%
1152
+ )`,r.instance&&r.instance.triggerOnChange(t,y)};s.addEventListener("input",h),s.addEventListener("change",h)}return i}function rl(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=ie(e,a,t),l=e.default!==void 0?e.default:(e.min+e.max)/2,d=(o=t.prefill[e.key])!=null?o:l,s=Pn(d,r,e,t,i);if(n.appendChild(s),!i){const f=document.createElement("p");f.className="mt-1",f.style.cssText=`
1153
+ font-size: var(--fb-font-size-small);
1154
+ color: var(--fb-text-secondary-color);
1155
+ `,f.textContent=Le(e,a),n.appendChild(f)}}function ol(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=ie(e,i,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],f=(o=e.minCount)!=null?o:e.required?1:0,c=(a=e.maxCount)!=null?a:1/0,u=e.default!==void 0?e.default:(e.min+e.max)/2;for(;s.length<f;)s.push(u);const p=document.createElement("div");p.className="space-y-3",n.appendChild(p);function m(){p.querySelectorAll(".multiple-slider-item").forEach((y,g)=>{const C=y.querySelector("input[type=range]");C&&C.setAttribute("name",`${r}[${g}]`)})}function b(y=u,g=-1){const C=document.createElement("div");C.className="multiple-slider-item flex items-start gap-2";const w=`${r}[${p.children.length}]`,x=Pn(y,w,e,t,l);return x.style.flex="1",C.appendChild(x),g===-1?p.appendChild(C):p.insertBefore(C,p.children[g]),m(),C}function v(){if(l)return;const y=p.querySelectorAll(".multiple-slider-item"),g=y.length;y.forEach(C=>{let w=C.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=`
1156
+ color: var(--fb-error-color);
1157
+ background-color: transparent;
1158
+ transition: background-color var(--fb-transition-duration);
1159
+ margin-top: 8px;
1160
+ `,w.innerHTML="\u2715",w.addEventListener("mouseenter",()=>{w.style.backgroundColor="var(--fb-background-hover-color)"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="transparent"}),w.onclick=()=>{const S=Array.from(p.children).indexOf(C);p.children.length>f&&(s.splice(S,1),C.remove(),m(),h(),v())},C.appendChild(w));const x=g<=f;w.disabled=x,w.style.opacity=x?"0.5":"1",w.style.pointerEvents=x?"none":"auto"})}let E=null;if(!l){const y=ze("slider",()=>{s.push(u),b(u),h(),v()},{label:e.addLabel});E=y.update,Te(n,y.counter),n.appendChild(y.row)}function h(){E&&E(s.length,c)}if(s.forEach(y=>b(y)),h(),v(),!l){const y=document.createElement("p");y.className="mt-1",y.style.cssText=`
1161
+ font-size: var(--fb-font-size-small);
1162
+ color: var(--fb-text-secondary-color);
1163
+ `,y.textContent=Le(e,i),n.appendChild(y)}}function ll(e,t,n){var r,o,a;const i=[],{scopeRoot:l,skipValidation:d}=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,f=e.max,c=(r=e.step)!=null?r:1,u=e.scale||"linear",p=(b,v)=>{var E,h;if(!b)return;const y=`error-${b.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(y);if(v){if(b.classList.add("invalid"),b.title=v,!g){g=document.createElement("div"),g.id=y,g.className="error-message",g.style.cssText=`
1164
+ color: var(--fb-error-color);
1165
+ font-size: var(--fb-font-size-small);
1166
+ margin-top: 0.25rem;
1167
+ `;const C=b.closest(".slider-container");C&&C.nextSibling?(E=C.parentNode)==null||E.insertBefore(g,C.nextSibling):C&&((h=C.parentNode)==null||h.appendChild(g))}g.textContent=v,g.style.display="block"}else b.classList.remove("invalid"),b.title="",g&&g.remove()},m=(b,v)=>{const{state:E}=n,h=b.value;if(!h){if(!d&&e.required){const g=k("required",E);return i.push(`${v}: ${g}`),p(b,g),null}return p(b,null),null}let y;if(u==="exponential"){const g=parseFloat(h)/1e3;y=Un(g,s,f),y=ft(y,c)}else y=parseFloat(h),y=ft(y,c);if(!d){if(y<s){const g=k("minValue",E,{min:s});return i.push(`${v}: ${g}`),p(b,g),y}if(y>f){const g=k("maxValue",E,{max:f});return i.push(`${v}: ${g}`),p(b,g),y}}return p(b,null),y};if(e.multiple){const b=l.querySelectorAll(`input[type="range"][name^="${t}\\["]`),v=[];if(b.forEach((E,h)=>{const y=m(E,`${t}[${h}]`);v.push(y)}),!d){const{state:E}=n,h=(o=e.minCount)!=null?o:0,y=(a=e.maxCount)!=null?a:1/0,g=v.filter(C=>C!==null);e.required&&g.length===0&&i.push(`${t}: ${k("required",E)}`),g.length<h&&i.push(`${t}: ${k("minItems",E,{min:h})}`),g.length>y&&i.push(`${t}: ${k("maxItems",E,{max:y})}`)}return{value:v,errors:i}}else{const b=l.querySelector(`input[type="range"][name="${t}"]`);return b?{value:m(b,t),errors:i}:(!d&&e.required&&i.push(`${t}: ${k("required",n.state)}`),{value:null,errors:i})}}function il(e,t,n,r){var o;const{scopeRoot:a}=r,i=e.min,l=e.max,d=(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 f=a.querySelectorAll(`input[type="range"][name^="${t}\\["]`);f.forEach((c,u)=>{if(u<n.length&&n[u]!==null){const p=Number(n[u]);if(s==="exponential"){const b=Bt(p,i,l);c.value=(b*1e3).toString()}else c.value=p.toString();const m=c.closest(".slider-container");if(m){const b=m.querySelector(".slider-value");b&&(b.textContent=p.toFixed(d<1?2:0));const v=(p-i)/(l-i)*100;c.style.background=`linear-gradient(
1168
+ to right,
1169
+ var(--fb-primary-color) 0%,
1170
+ var(--fb-primary-color) ${v}%,
1171
+ var(--fb-border-color) ${v}%,
1172
+ var(--fb-border-color) 100%
1173
+ )`}c.classList.remove("invalid"),c.title="",Ce(c)}}),n.length!==f.length&&console.warn(`updateSliderField: Multiple field "${t}" has ${f.length} sliders but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const f=a.querySelector(`input[type="range"][name="${t}"]`);if(f&&n!==null&&n!==void 0){const c=Number(n);if(s==="exponential"){const p=Bt(c,i,l);f.value=(p*1e3).toString()}else f.value=c.toString();const u=f.closest(".slider-container");if(u){const p=u.querySelector(".slider-value");p&&(p.textContent=c.toFixed(d<1?2:0));const m=(c-i)/(l-i)*100;f.style.background=`linear-gradient(
1174
+ to right,
1175
+ var(--fb-primary-color) 0%,
1176
+ var(--fb-primary-color) ${m}%,
1177
+ var(--fb-border-color) ${m}%,
1178
+ var(--fb-border-color) 100%
1179
+ )`}f.classList.remove("invalid"),f.title="",Ce(f)}}}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 Ht(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 Dt=null;function al(e){Dt=e}function Kn(e,t){if(!Dt)throw new Error("renderElement not initialized. Import from components/index.ts");return Dt(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 Jn(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"),d=e.columns||1;d===1?l.className="fb-row":l.className=`grid grid-cols-${d} gap-2`;const s=ie(e,t.state,t);if(!s){const m=_n(e,r);m&&i.appendChild(m)}const f=Wn(e.elements),c=((o=t.prefill)==null?void 0:o[e.key])||{},u=Vn(c,f),p={path:De(t.path,e.key),prefill:u,formData:(a=t.formData)!=null?a:t.prefill,state:t.state,instance:t.instance,inheritedReadonly:s||t.inheritedReadonly};e.elements.forEach(m=>{var b,v;if(m.type!=="markdown"&&(m.hidden||m.type==="hidden")){const E=(v=(b=c[m.key])!=null?b:"default"in m?m.default:null)!=null?v:null;l.appendChild(Ct(De(p.path,m.key),E))}else l.appendChild(Kn(m,p))}),i.appendChild(l),n.appendChild(i)}function sl(e){const t=e||1;return t===1?"fb-row":`grid grid-cols-${t} gap-2`}function dl(e,t,n,r){const o=document.createElement("button");o.type="button",o.className="fb-item-remove",o.setAttribute("aria-label",r?k("removeRowFrom",n,{label:r}):k("removeRow",n)),o.style.cssText=`
1180
+ width: 24px;
1181
+ height: 24px;
1182
+ display: inline-flex;
1183
+ align-items: center;
1184
+ justify-content: center;
1185
+ padding: 0;
1186
+ border: 0;
1187
+ border-radius: 4px;
1188
+ cursor: pointer;
1189
+ flex-shrink: 0;
1190
+ `,o.innerHTML=en,o.onclick=t,o.style.position="absolute",o.style.top="var(--fb-row-remove-inset, 8px)",o.style.right="var(--fb-row-remove-inset, 8px)",o.style.zIndex="1",e.style.position="relative",e.classList.add("fb-row-removable"),e.insertBefore(o,e.firstChild)}function Yn(e,t,n,r){var o,a,i,l;const d=t.state,s=ie(e,d,t),f=s||t.inheritedReadonly,c=document.createElement("div");c.className="border border-gray-200 rounded-lg p-2 bg-gray-50";const u=document.createElement("div"),p=e.displayMode==="slides";if(p?u.className="fb-container-slides":u.className="fb-row",!s){const R=_n(e,e.key);R&&c.appendChild(R)}const m=(o=e.minCount)!=null?o:0,b=(a=e.maxCount)!=null?a:1/0,v=Array.isArray((i=t.prefill)==null?void 0:i[e.key])?t.prefill[e.key]:null,E=Wn(e.elements);let h=0;const y=()=>h++,g=()=>Array.from(u.children).filter(R=>R.classList.contains("containerItem")),C=()=>g().length,w=R=>{C()<=m||(R.remove(),te())},x=(R,G,le)=>{const pe={state:d,instance:t.instance,path:De(t.path,`${e.key}[${R}]`),prefill:Vn(G!=null?G:{},E),formData:le,inheritedReadonly:f},me=document.createElement("div");me.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",me.setAttribute("data-container-item",pe.path),p&&me.setAttribute("data-fb-slide-card","");const Ae=document.createElement("div");return Ae.className=sl(p?void 0:e.columns),e.elements.forEach(xe=>{var $,I;if(xe.type!=="markdown"&&(xe.hidden||xe.type==="hidden")){const M=(I=($=G==null?void 0:G[xe.key])!=null?$:"default"in xe?xe.default:null)!=null?I:null;Ae.appendChild(Ct(De(pe.path,xe.key),M))}else Ae.appendChild(Kn(xe,pe))}),me.appendChild(Ae),s||dl(me,()=>w(me),d,e.label),me},S=()=>{if(C()>=b)return;const R=x(y(),null,d.formRoot?Ht(d.formRoot):{});z&&z.parentElement===u?u.insertBefore(R,z):u.appendChild(R),te()};let z=null,ae=null,K=null;const H=()=>{if(!z)return;const R=g()[0];R&&R.offsetHeight>0&&(z.style.minHeight=`${R.offsetHeight}px`)},V=()=>{const R=C()<=m;g().forEach(G=>{const le=Array.from(G.children).find(pe=>pe.classList.contains("fb-item-remove"));le&&(le.disabled=R)})},te=()=>{const R=C();ae&&ae(R,b),K&&K(R,b),z&&H(),V()};if(v&&v.forEach(R=>{var G;u.appendChild(x(y(),R!=null?R:{},(G=t.formData)!=null?G:t.prefill))}),!s)for(;C()<m;)u.appendChild(x(y(),null,(l=t.formData)!=null?l:t.prefill));if(c.appendChild(u),!s)if(p){const R=$r(S,{label:e.addLabel});z=R.tile,ae=R.update,Te(n,R.counter),u.appendChild(R.tile)}else{const R=ze("container",S,{label:e.addLabel});K=R.update,Te(n,R.counter),c.appendChild(R.row)}te(),n.appendChild(c),z&&(typeof requestAnimationFrame=="function"?requestAnimationFrame(H):H())}let jt=null;function cl(e){jt=e}function Xn(e,t,n){if(!jt)throw new Error("validateElement not initialized. Should be set from FormBuilderInstance");return jt(e,t,n)}function Gn(e,t,n){const r=[],{scopeRoot:o,skipValidation:a,path:i}=n;if(!("elements"in e))return{value:null,errors:r};const l=(d,s,f)=>{var c,u;if(a)return;const{state:p}=n,m="minCount"in f&&(c=f.minCount)!=null?c:0,b="maxCount"in f&&(u=f.maxCount)!=null?u:1/0;f.required&&s.length===0&&r.push(`${d}: ${k("required",p)}`),s.length<m&&r.push(`${d}: ${k("minItems",p,{min:m})}`),s.length>b&&r.push(`${d}: ${k("maxItems",p,{max:b})}`)};if("multiple"in e&&e.multiple){const d=[];return wt(o,t).forEach(s=>{const f={},c=(s.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),u=c?parseInt(c[1],10):0;e.elements.forEach(p=>{var m;if(p.enableIf)try{const E=(m=n.instance)!=null&&m.getState().formRoot?Ht(n.instance.getState().formRoot):{};if(!je(p.enableIf,E,f))return}catch(E){console.error(`Error evaluating enableIf for field "${p.key}" in container "${t}[${u}]":`,E)}const b=`${t}[${u}].${p.key}`,v=Xn({...p,key:b},{path:i},s);v.spread&&v.value!==null&&typeof v.value=="object"?Object.assign(f,v.value):!v.skip&&p.key&&(f[p.key]=v.value)}),d.push(f)}),l(t,d,e),{value:d,errors:r}}else{const d={},s=o.querySelector(`[data-container="${t}"]`)||o;return e.elements.forEach(f=>{var c;if(f.enableIf)try{const u=(c=n.instance)!=null&&c.getState().formRoot?Ht(n.instance.getState().formRoot):{};if(!je(f.enableIf,u,d))return}catch(u){console.error(`Error evaluating enableIf for field "${f.key}" in container "${t}":`,u)}{const u=`${t}.${f.key}`,p=Xn({...f,key:u},{path:i},s);p.spread&&p.value!==null&&typeof p.value=="object"?Object.assign(d,p.value):!p.skip&&f.key&&(d[f.key]=p.value)}}),{value:d,errors:r}}}function Zn(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}const i=wt(a,t);n.forEach((l,d)=>{var s;const f=(s=i[d])==null?void 0:s.getAttribute("data-container-item");Je(l)&&f&&e.elements.forEach(c=>{var u,p;if(c.type==="markdown"||!c.key)return;const m=`${f}.${c.key}`;if(c.type==="richinput"&&c.flatOutput){const b=c,v=(u=b.textKey)!=null?u:"text",E=(p=b.filesKey)!=null?p:"files",h=l,y={};v in h&&(y[v]=h[v]),E in h&&(y[E]=h[E]),Object.keys(y).length>0&&o.updateField(m,y)}else{const b=l[c.key];b!==void 0&&o.updateField(m,b)}})}),n.length!==i.length&&console.warn(`updateContainerField: Multiple container field "${t}" received ${n.length} items for ${i.length} rendered rows. Rows are not added or removed here \u2014 re-render for add/remove.`)}else{if(!Je(n)){console.warn(`updateContainerField: Expected object for container field "${t}", got ${typeof n}`);return}e.elements.forEach(i=>{var l,d;if(i.type==="markdown"||!i.key)return;const s=`${t}.${i.key}`;if(i.type==="richinput"&&i.flatOutput){const f=i,c=(l=f.textKey)!=null?l:"text",u=(d=f.filesKey)!=null?d:"files",p=n,m={};c in p&&(m[c]=p[c]),u in p&&(m[u]=p[u]),Object.keys(m).length>0&&o.updateField(s,m)}else{const f=n[i.key];f!==void 0&&o.updateField(s,f)}})}}function ul(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&&Je(e.repeat)),minCount:(o=e.repeat)==null?void 0:o.min,maxCount:(a=e.repeat)==null?void 0:a.max};i.multiple?Yn(i,t,n):Jn(i,t,n,r)}function Qn(e){var t,n;const r=e;return{type:"container",key:r.key,label:r.label,description:r.description,hint:r.hint,required:r.required,hidden:r.hidden,default:r.default,actions:r.actions,elements:r.elements,multiple:!!(r.repeat&&Je(r.repeat)),minCount:(t=r.repeat)==null?void 0:t.min,maxCount:(n=r.repeat)==null?void 0:n.max}}function fl(e,t,n){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field key: "${t}"`);const r=Qn(e);return Gn(r,t,n)}function pl(e,t,n,r){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field path: "${t}"`);const o=Qn(e);return Zn(o,t,n,r)}function ml(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function hl(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 bl(e){return ml(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:hl(e)?e:null}function We(e){return e.map(bl).filter(t=>t!==null)}function er(e,t){return Array.from({length:e},()=>Array.from({length:t},()=>""))}function Ot(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 tr(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 pt(e,t,n){var r;return(r=n.find(o=>o.top===e&&o.left===t))!=null?r:null}function Ne(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 Ve(e){const t=document.createElement("button");return t.type="button",t.textContent=e.label,t.title=e.title,t.style.cssText=`
1191
+ position: absolute;
1192
+ width: ${e.size}px;
1193
+ height: ${e.size}px;
1194
+ border-radius: 50%;
1195
+ border: none;
1196
+ background: ${e.color};
1197
+ color: ${e.textColor};
1198
+ font-size: ${Math.floor(e.size*.6)}px;
1199
+ line-height: ${e.size}px;
1200
+ text-align: center;
1201
+ cursor: pointer;
1202
+ z-index: 10;
1203
+ padding: 0;
1204
+ display: flex;
1205
+ align-items: center;
1206
+ justify-content: center;
1207
+ box-shadow: 0 1px 4px rgba(0,0,0,0.2);
1208
+ transition: transform 0.1s, opacity 0.1s;
1209
+ pointer-events: all;
1210
+ `,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 vl(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=`
1211
+ width: 100%;
1212
+ border-collapse: collapse;
1213
+ border: var(--fb-border-width) solid var(--fb-border-color);
1214
+ border-radius: var(--fb-border-radius);
1215
+ font-size: var(--fb-font-size);
1216
+ font-family: var(--fb-font-family);
1217
+ color: var(--fb-text-color);
1218
+ `,n.forEach((l,d)=>{var s,f;const c=(d===0?a.createTHead():(s=a.tBodies[0])!=null?s:a.createTBody()).insertRow();for(let u=0;u<o;u++){if(tr(d,u,r))continue;const p=pt(d,u,r),m=document.createElement(d===0?"th":"td");if(p){const b=p.bottom-p.top+1,v=p.right-p.left+1;b>1&&(m.rowSpan=b),v>1&&(m.colSpan=v)}m.textContent=(f=l[u])!=null?f:"",m.style.cssText=`
1219
+ padding: 6px 10px;
1220
+ border: var(--fb-border-width) solid var(--fb-border-color);
1221
+ text-align: left;
1222
+ vertical-align: top;
1223
+ ${d===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":""}
1224
+ `,c.appendChild(m)}});const i=document.createElement("div");i.style.cssText="overflow-x: auto; max-width: 100%;",i.appendChild(a),t.appendChild(i)}function gl(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 d(){var c;e.contentEditable="inherit";const u=r();u[t]&&(u[t][n]=(c=e.textContent)!=null?c:""),o()}function s(c){var u,p,m,b;const v=r(),E=(p=(u=v[0])==null?void 0:u.length)!=null?p:0;if(c.key==="Escape"){e.contentEditable="inherit",e.textContent=(b=(m=v[t])==null?void 0:m[n])!=null?b:"",e.removeEventListener("keydown",s),e.removeEventListener("blur",f);return}if(c.key==="Enter"&&!c.shiftKey){c.preventDefault(),c.stopPropagation(),d(),e.removeEventListener("keydown",s),e.removeEventListener("blur",f);const h=t+1<v.length?t+1:t;a(h,n);return}if(c.key==="Tab"){c.preventDefault(),c.stopPropagation(),d(),e.removeEventListener("keydown",s),e.removeEventListener("blur",f);let h=t,y=c.shiftKey?n-1:n+1;y<0&&(y=E-1,h=Math.max(0,t-1)),y>=E&&(y=0,h=Math.min(v.length-1,t+1)),a(h,y)}}function f(){e.contentEditable==="true"&&(d(),e.removeEventListener("keydown",s),e.removeEventListener("blur",f))}e.addEventListener("keydown",s),e.addEventListener("blur",f)}function yl(){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 xl(e,t){yl();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
1225
+ position: absolute; top: 0; left: 0; right: 0; bottom: 0;
1226
+ background: rgba(255,255,255,0.8); display: flex;
1227
+ align-items: center; justify-content: center; flex-direction: column;
1228
+ gap: 8px; z-index: 100;
1229
+ `;const r=document.createElement("div");r.style.cssText=`
1230
+ width: 24px; height: 24px; border: 3px solid var(--fb-border-color, #ccc);
1231
+ border-top-color: var(--fb-primary-color, #0066cc); border-radius: 50%;
1232
+ animation: fb-spin 0.8s linear infinite;
1233
+ `;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 wl(e,t,n,r,o){var a,i,l,d,s,f,c,u;const p=r.state,m=r.instance,b=e.mergeAllowed!==!1,v=(i=(a=e.fieldNames)==null?void 0:a.cells)!=null?i:"cells",E=(d=(l=e.fieldNames)==null?void 0:l.merges)!=null?d:"merges",h=t.cells.length>0?t.cells.map(A=>[...A]):er((s=e.rows)!=null?s:3,(f=e.columns)!=null?f:3);let y=t.merges?[...t.merges]:[];const g={anchor:null,focus:null,dragging:!1},C=document.createElement("input");C.type="hidden",C.name=n,C.value=JSON.stringify({[v]:h,[E]:y}),o.appendChild(C);function w(){C.value=JSON.stringify({[v]:h,[E]:y}),m&&m.triggerOnChange(n,{[v]:h,[E]: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})),g.anchor=null,g.focus=null,w(),N()};const x=document.createElement("div");x.style.cssText="position: relative; padding: 20px 20px 20px 24px; overflow-x: auto; max-width: 100%;";const S=document.createElement("table");S.style.cssText=`
1234
+ border-collapse: collapse;
1235
+ font-size: var(--fb-font-size);
1236
+ font-family: var(--fb-font-family);
1237
+ color: var(--fb-text-color);
1238
+ table-layout: fixed;
1239
+ `,x.appendChild(S);const z=(u=(c=e.importAccept)==null?void 0:c.map(A=>`.${A.toLowerCase()}`))!=null?u:[];async function ae(A){var T,L,D;if(!p.config.parseTableFile)return;if(z.length>0){const F=A.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!z.includes(F))return}const j=xl(x,k("tableImporting",p));try{const F=await p.config.parseTableFile(A),ee=F.cells,U=(T=F.merges)!=null?T:[];if(U.length>0){const P=Ot(U,ee.length,(D=(L=ee[0])==null?void 0:L.length)!=null?D:0);if(P)throw new Error(P)}h.length=0,ee.forEach(P=>h.push([...P])),y.length=0,U.forEach(P=>y.push({...P})),g.anchor=null,g.focus=null,w(),N()}catch(F){const ee=F instanceof Error?F.message:String(F);console.error(k("tableImportError",p).replace("{error}",ee))}finally{j.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=`
1240
+ position: absolute; top: 2px; left: 2px;
1241
+ width: 20px; height: 20px;
1242
+ padding: 0;
1243
+ display: flex; align-items: center; justify-content: center;
1244
+ color: var(--fb-text-color, #999);
1245
+ border: none;
1246
+ background: transparent;
1247
+ cursor: pointer;
1248
+ z-index: 2;
1249
+ `,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=z.join(","),T.style.display="none",x.appendChild(T),A.addEventListener("click",()=>{T.click()}),T.addEventListener("change",()=>{var D;const j=(D=T.files)==null?void 0:D[0];j&&ae(j),T.value=""}),x.appendChild(A);let L=0;x.addEventListener("dragenter",D=>{D.preventDefault(),L++,L===1&&(x.style.outline="2px dashed var(--fb-primary-color, #0066cc)",x.style.outlineOffset="-2px")}),x.addEventListener("dragover",D=>{D.preventDefault(),D.dataTransfer&&(D.dataTransfer.dropEffect="copy")}),x.addEventListener("dragleave",D=>{D.preventDefault(),L--,L<=0&&(L=0,x.style.outline="",x.style.outlineOffset="")}),x.addEventListener("drop",D=>{var j,F;D.preventDefault(),L=0,x.style.outline="",x.style.outlineOffset="";const ee=(F=(j=D.dataTransfer)==null?void 0:j.files)==null?void 0:F[0];ee&&ae(ee)})}o.appendChild(x);const K=document.createElement("div");K.style.cssText=`
1250
+ position: fixed;
1251
+ display: none;
1252
+ background: white;
1253
+ border: 1px solid var(--fb-border-color);
1254
+ border-radius: var(--fb-border-radius);
1255
+ box-shadow: 0 2px 8px rgba(0,0,0,0.15);
1256
+ padding: 4px;
1257
+ z-index: 1000;
1258
+ gap: 4px;
1259
+ flex-direction: column;
1260
+ `,o.appendChild(K);function H(A,T){const L=document.createElement("button");return L.type="button",L.textContent=A,L.style.cssText=`
1261
+ padding: 4px 10px;
1262
+ font-size: var(--fb-font-size-small);
1263
+ color: var(--fb-text-color);
1264
+ border: 1px solid var(--fb-border-color);
1265
+ border-radius: var(--fb-border-radius);
1266
+ background: transparent;
1267
+ cursor: pointer;
1268
+ white-space: nowrap;
1269
+ text-align: left;
1270
+ `,L.addEventListener("mouseenter",()=>{L.style.background="var(--fb-background-hover-color)"}),L.addEventListener("mouseleave",()=>{L.style.background="transparent"}),L.addEventListener("click",()=>{te(),T()}),L}function V(A,T){if(!b)return;K.innerHTML="",K.style.display="flex";const L=Ne(g),D=L&&(L.r1!==L.r2||L.c1!==L.c2),j=g.anchor&&pt(g.anchor.row,g.anchor.col,y);if(D&&K.appendChild(H(k("tableMergeCells",p),I)),j&&K.appendChild(H(k("tableSplitCell",p),M)),!K.firstChild){te();return}const F=140,ee=K.children.length*32+8,U=window.innerWidth,P=window.innerHeight,_=A+F>U?A-F:A,X=T+ee>P?T-ee:T;K.style.left=`${_}px`,K.style.top=`${X}px`}function te(){K.style.display="none"}const R=new AbortController;document.addEventListener("mousedown",A=>{if(!o.isConnected){R.abort();return}K.contains(A.target)||te()},{signal:R.signal});function G(){const A=Ne(g);S.querySelectorAll("td[data-row]").forEach(T=>{const L=parseInt(T.getAttribute("data-row")||"0",10),D=parseInt(T.getAttribute("data-col")||"0",10),j=g.anchor!==null&&g.anchor.row===L&&g.anchor.col===D,F=A!==null&&L>=A.r1&&L<=A.r2&&D>=A.c1&&D<=A.c2;T.style.outline=j?"2px solid var(--fb-primary-color, #0066cc)":"",T.style.outlineOffset=j?"-2px":"",L===0?T.style.backgroundColor="var(--fb-background-hover-color)":T.style.backgroundColor=F&&!j?"rgba(0,102,204,0.08)":""})}function le(A,T){g.anchor={row:A,col:T},g.focus=null,G(),S.focus()}function pe(A,T){const L=S.querySelector(`td[data-row="${A}"][data-col="${T}"]`);if(!L)return;const D=L.querySelector("span");D&&(g.anchor={row:A,col:T},g.focus=null,G(),gl(D,A,T,()=>h,w,le))}function me(A){var T;const L=h.length>0?h[0].length:(T=e.columns)!=null?T:3,D=Array(L).fill(""),j=A!==void 0?A+1:h.length;h.splice(j,0,D),y=y.map(F=>F.top>=j?{...F,top:F.top+1,bottom:F.bottom+1}:F.top<j&&F.bottom>=j?{...F,bottom:F.bottom+1}:F),w(),N()}function Ae(A){if(h.length<=1)return;const T=A!==void 0?A:g.anchor?g.anchor.row:h.length-1;y=y.map(L=>L.top===T&&L.bottom===T?null:L.top===T?{...L,bottom:L.bottom-1}:L.bottom===T?{...L,bottom:L.bottom-1}:L.top<T&&L.bottom>T?{...L,bottom:L.bottom-1}:L.top>T?{...L,top:L.top-1,bottom:L.bottom-1}:L).filter(L=>L!==null),h.splice(T,1),g.anchor&&g.anchor.row>=h.length&&(g.anchor={row:h.length-1,col:g.anchor.col}),w(),N()}function xe(A){var T,L;const D=A!==void 0?A+1:(L=(T=h[0])==null?void 0:T.length)!=null?L:0;h.forEach(j=>j.splice(D,0,"")),y=y.map(j=>j.left>=D?{...j,left:j.left+1,right:j.right+1}:j.left<D&&j.right>=D?{...j,right:j.right+1}:j),w(),N()}function $(A){if(h.length===0||h[0].length<=1)return;const T=A!==void 0?A:g.anchor?g.anchor.col:h[0].length-1;y=y.map(L=>L.left===T&&L.right===T?null:L.left===T?{...L,right:L.right-1}:L.right===T?{...L,right:L.right-1}:L.left<T&&L.right>T?{...L,right:L.right-1}:L.left>T?{...L,left:L.left-1,right:L.right-1}:L).filter(L=>L!==null),h.forEach(L=>L.splice(T,1)),g.anchor&&g.anchor.col>=h[0].length&&(g.anchor={row:g.anchor.row,col:h[0].length-1}),w(),N()}function I(){var A,T;if(!b)return;const L=Ne(g);if(!L)return;const{r1:D,c1:j,r2:F,c2:ee}=L;if(D===F&&j===ee)return;y=y.filter(O=>!(O.top<=F&&O.bottom>=D&&O.left<=ee&&O.right>=j));const U=h[D][j];for(let O=D;O<=F;O++)for(let Z=j;Z<=ee;Z++)(O!==D||Z!==j)&&(h[O][Z]="");h[D][j]=U;const P={top:D,left:j,bottom:F,right:ee},_=[...y,P],X=Ot(_,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(P),g.anchor={row:D,col:j},g.focus=null,w(),N()}function M(){if(!b||!g.anchor)return;const{row:A,col:T}=g.anchor,L=y.findIndex(D=>D.top===A&&D.left===T);L!==-1&&(y.splice(L,1),g.focus=null,w(),N())}function N(){var A,T;S.innerHTML="";const L=h.length,D=L>0?h[0].length:0,j=Ne(g);for(let F=0;F<L;F++){const ee=(F===0?(A=S.tHead)!=null?A:S.createTHead():(T=S.tBodies[0])!=null?T:S.createTBody()).insertRow();for(let U=0;U<D;U++){if(tr(F,U,y))continue;const P=pt(F,U,y),_=document.createElement("td");if(_.setAttribute("data-row",String(F)),_.setAttribute("data-col",String(U)),P){const Q=P.bottom-P.top+1,J=P.right-P.left+1;Q>1&&(_.rowSpan=Q),J>1&&(_.colSpan=J)}const X=j!==null&&F>=j.r1&&F<=j.r2&&U>=j.c1&&U<=j.c2,O=g.anchor!==null&&g.anchor.row===F&&g.anchor.col===U;_.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&&!O?"background-color: rgba(0,102,204,0.08);":"",O?"outline: 2px solid var(--fb-primary-color, #0066cc); outline-offset: -2px;":""].join(" ");const Z=document.createElement("span");Z.textContent=h[F][U],Z.style.cssText="display: block; min-height: 1.4em; white-space: pre-wrap; word-break: break-word; outline: none;",_.appendChild(Z);const Y=F,oe=U;_.addEventListener("mousedown",Q=>{if(Q.target.tagName!=="BUTTON"&&Q.target.contentEditable!=="true"){if(Q.button===2){const J=Ne(g);if(J&&Y>=J.r1&&Y<=J.r2&&oe>=J.c1&&oe<=J.c2)return}Q.shiftKey&&g.anchor?(Q.preventDefault(),g.focus={row:Y,col:oe},g.dragging=!1,G()):(g.anchor={row:Y,col:oe},g.focus=null,g.dragging=!0,G())}}),_.addEventListener("mouseup",Q=>{if(Q.target.tagName!=="BUTTON"&&g.dragging){g.dragging=!1;const J=Ne(g);(!J||J.r1===J.r2&&J.c1===J.c2)&&pe(Y,oe)}}),_.addEventListener("mousemove",Q=>{if(g.dragging&&Q.buttons===1){const J=g.anchor;J&&(J.row!==Y||J.col!==oe)&&(g.focus={row:Y,col:oe},G())}}),_.addEventListener("contextmenu",Q=>{if(!b)return;const J=Ne(g),he=J&&(J.r1!==J.r2||J.c1!==J.c2),fe=g.anchor&&pt(g.anchor.row,g.anchor.col,y);(he||fe)&&(Q.preventDefault(),V(Q.clientX,Q.clientY))}),ee.appendChild(_)}}ve(),S.setAttribute("tabindex","0"),S.onkeydown=F=>{var ee,U;if(S.querySelector("[contenteditable='true']"))return;const P=g.anchor;if(!P)return;const _=h.length,X=_>0?h[0].length:0,O={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]};if(O[F.key]){F.preventDefault();const[Z,Y]=O[F.key],oe=Math.max(0,Math.min(_-1,P.row+Z)),Q=Math.max(0,Math.min(X-1,P.col+Y));F.shiftKey?(g.focus={row:oe,col:Q},G()):le(oe,Q);return}if(F.key==="Enter"){F.preventDefault(),pe(P.row,P.col);return}if(F.key==="Tab"){F.preventDefault();const Z=(U=(ee=h[0])==null?void 0:ee.length)!=null?U:0;let Y=P.row,oe=F.shiftKey?P.col-1:P.col+1;oe<0&&(oe=Z-1,Y=Math.max(0,Y-1)),oe>=Z&&(oe=0,Y=Math.min(h.length-1,Y+1)),le(Y,oe);return}if(b&&F.key==="m"&&F.ctrlKey&&!F.shiftKey){F.preventDefault(),I();return}b&&F.key==="M"&&F.ctrlKey&&F.shiftKey&&(F.preventDefault(),M())},S.oncopy=F=>{var ee,U,P,_;const X=Ne(g);if(!X)return;F.preventDefault();const{r1:O,c1:Z,r2:Y,c2:oe}=X,Q=[],J=[];for(let W=O;W<=Y;W++){const ue=[],ge=[];for(let ye=Z;ye<=oe;ye++){const ke=(U=(ee=h[W])==null?void 0:ee[ye])!=null?U:"";ue.push(ke);const He=ke.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");ge.push(`<td>${He}</td>`)}Q.push(ue.join(" ")),J.push(`<tr>${ge.join("")}</tr>`)}const he=Q.join(`
1271
+ `),fe=`<table>${J.join("")}</table>`;(P=F.clipboardData)==null||P.setData("text/plain",he),(_=F.clipboardData)==null||_.setData("text/html",fe)},S.onpaste=F=>{var ee,U,P,_,X,O,Z,Y,oe;const Q=g.anchor;if(!Q)return;const J=(U=(ee=F.clipboardData)==null?void 0:ee.getData("text/plain"))!=null?U:"",he=J.includes(" ")||J.split(/\r?\n/).filter(be=>be).length>1,fe=S.querySelector("[contenteditable='true']");if(fe&&!he)return;if(F.preventDefault(),fe){fe.contentEditable="inherit";const be=parseInt((_=(P=fe.closest("td"))==null?void 0:P.getAttribute("data-row"))!=null?_:"0",10),Ie=parseInt((O=(X=fe.closest("td"))==null?void 0:X.getAttribute("data-col"))!=null?O:"0",10);h[be]&&(h[be][Ie]=(Z=fe.textContent)!=null?Z:"")}if(!J.trim())return;const W=J.split(/\r?\n/).map(be=>be.split(" "));W.length>1&&W[W.length-1].length===1&&W[W.length-1][0]===""&&W.pop();const ue=Q.row,ge=Q.col,ye=ue+W.length;for(;h.length<ye;)h.push(Array((oe=(Y=h[0])==null?void 0:Y.length)!=null?oe:1).fill(""));const ke=Math.max(...W.map(be=>be.length)),He=ge+ke;if(h[0]&&He>h[0].length){const be=He-h[0].length;h.forEach(Ie=>{for(let tt=0;tt<be;tt++)Ie.push("")})}for(let be=0;be<W.length;be++)for(let Ie=0;Ie<W[be].length;Ie++){const tt=ue+be,si=ge+Ie;h[tt]&&(h[tt][si]=W[be][Ie])}w(),N()}}const q=Ve({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=q.dataset.afterCol)!=null?A:"0",10);xe(T)}});q.style.position="absolute",q.style.display="none",x.appendChild(q);const B=Ve({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=B.dataset.afterRow)!=null?A:"0",10);me(T)}});B.style.position="absolute",B.style.display="none",x.appendChild(B);let ne=[],re=[];const ce=Ve({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>xe()});ce.style.position="absolute",ce.style.display="none",x.appendChild(ce);const de=Ve({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>me()});de.style.position="absolute",de.style.display="none",x.appendChild(de);function ve(){var A,T;ne.forEach(U=>U.remove()),ne=[],re.forEach(U=>U.remove()),re=[];const L=h.length>0?h[0].length:0,D=h.length;if(L>1){const U=Array.from(S.querySelectorAll("thead td[data-col]"));for(const P of U){const _=parseInt((A=P.getAttribute("data-col"))!=null?A:"0",10),X=Ve({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),ne.push(X)}}if(D>1){const U=[...S.tHead?Array.from(S.tHead.rows):[],...S.tBodies[0]?Array.from(S.tBodies[0].rows):[]].filter(P=>P.querySelector("td[data-row]"));for(const P of U){const _=P.querySelector("td[data-row]");if(!_)continue;const X=parseInt((T=_.getAttribute("data-row"))!=null?T:"0",10),O=Ve({label:"\xD7",title:k("tableRemoveRow",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>Ae(X)});O.setAttribute("data-action","remove-row"),O.setAttribute("data-row",String(X)),O.style.position="absolute",O.style.display="none",x.appendChild(O),re.push(O)}}function j(U,P,_,X,O){var Z;const Y=O?Array.from(S.querySelectorAll("thead td[data-col]")):[];let oe=-1,Q=1/0,J=-1,he=-1,fe=1/0;for(let W=0;W<Y.length;W++){const ue=Y[W].getBoundingClientRect(),ge=(ue.left+ue.right)/2,ye=Math.abs(U-ge);ye<Q&&(Q=ye,oe=W);const ke=Math.abs(U-ue.right);ke<fe&&ke<20&&(fe=ke,J=ue.right-P.left+X,he=parseInt((Z=Y[W].getAttribute("data-col"))!=null?Z:"0",10))}ne.forEach((W,ue)=>{if(!O||ue!==oe){W.style.display="none";return}const ge=Y[ue].getBoundingClientRect(),ye=(ge.left+ge.right)/2-P.left+X;W.style.left=`${ye-8}px`,W.style.top="2px",W.style.display="flex"}),O&&he>=0?(q.style.display="flex",q.style.left=`${J-10}px`,q.style.top=`${_.top-P.top-10}px`,q.dataset.afterCol=String(he)):q.style.display="none"}function F(U,P,_,X,O){var Z;const Y=[];if(O){if(S.tHead)for(const W of Array.from(S.tHead.rows))W.querySelector("td[data-row]")&&Y.push(W);if(S.tBodies[0])for(const W of Array.from(S.tBodies[0].rows))W.querySelector("td[data-row]")&&Y.push(W)}let oe=-1,Q=1/0,J=-1,he=-1,fe=1/0;for(let W=0;W<Y.length;W++){const ue=Y[W].getBoundingClientRect(),ge=(ue.top+ue.bottom)/2,ye=Math.abs(U-ge);ye<Q&&(Q=ye,oe=W);const ke=Math.abs(U-ue.bottom);if(ke<fe&&ke<14){fe=ke,J=ue.bottom-P.top;const He=Y[W].querySelector("td[data-row]");he=parseInt((Z=He==null?void 0:He.getAttribute("data-row"))!=null?Z:"0",10)}}re.forEach((W,ue)=>{if(!O||ue!==oe){W.style.display="none";return}const ge=Y[ue].getBoundingClientRect(),ye=(ge.top+ge.bottom)/2-P.top;W.style.left="4px",W.style.top=`${ye-8}px`,W.style.display="flex"}),O&&he>=0?(B.style.display="flex",B.style.top=`${J-10}px`,B.style.left=`${_.left-P.left+X-10}px`,B.dataset.afterRow=String(he)):B.style.display="none"}let ee=!1;x.onmousemove=U=>{const P=U.target;if(P.tagName==="BUTTON"&&P.parentElement===x||ee)return;ee=!0;const _=U.clientX,X=U.clientY;requestAnimationFrame(()=>{ee=!1;const O=x.getBoundingClientRect(),Z=S.getBoundingClientRect(),Y=x.scrollLeft,oe=X>=O.top&&X<Z.top+4,Q=_>=O.left&&_<Z.left+4,J=Math.min(Z.right,O.right),he=_>J-20&&_<=O.right,fe=X>Z.bottom-4&&X<=O.bottom+20;if(j(_,O,Z,Y,oe),F(X,O,Z,Y,Q),ce.style.display=he?"flex":"none",he&&(ce.style.left=`${O.right-O.left+Y-20}px`,ce.style.top=`${(Z.top+Z.bottom)/2-O.top-10}px`),de.style.display=fe?"flex":"none",fe){const W=(O.left+O.right)/2-O.left+Y;de.style.left=`${W-10}px`,de.style.top=`${Z.bottom-O.top-10}px`}})},x.onmouseleave=()=>{ne.forEach(U=>{U.style.display="none"}),re.forEach(U=>{U.style.display="none"}),q.style.display="none",B.style.display="none",ce.style.display="none",de.style.display="none"}}N()}function Cl(e){var t,n;return{cells:er((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function Ut(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function Pt(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function El(e,t,n,r){var o,a,i,l;const d=t.state,s=ie(e,d,t),f=t.prefill[e.key],c=(a=(o=e.fieldNames)==null?void 0:o.cells)!=null?a:"cells",u=(l=(i=e.fieldNames)==null?void 0:i.merges)!=null?l:"merges";let p;if(Ut(f))p={cells:f.cells,merges:f.merges?We(f.merges):[]};else if(f&&Pt(f,c)){const m=f[u];p={cells:f[c],merges:m?We(m):[]}}else if(Ut(e.default))p={cells:e.default.cells,merges:e.default.merges?We(e.default.merges):[]};else if(e.default&&Pt(e.default,c)){const m=e.default[u];p={cells:e.default[c],merges:m?We(m):[]}}else p=Cl(e);if(p.merges&&p.merges.length>0){const m=p.cells.length,b=m>0?p.cells[0].length:0,v=Ot(p.merges,m,b);v&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${v})`),p={...p,merges:[]})}s?vl(p,n):wl(e,p,r,t,n)}function kl(e,t,n){var r,o;const{scopeRoot:a,skipValidation:i}=n,l=[],d=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",s=a.querySelector(`[name="${t}"]`);if(!s)return{value:null,errors:l};let f;try{f=JSON.parse(s.value)}catch(c){return l.push(`${t}: invalid table data`),{value:null,errors:l}}if(!i&&e.required){const c=f[d];c!=null&&c.some(u=>u.some(p=>p.trim()!==""))||l.push(`${t}: ${k("required",n.state)}`)}return{value:f,errors:l}}function $l(e,t,n,r){var o,a,i,l;const{scopeRoot:d}=r,s=(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",c=d.querySelector(`[name="${t}"]`);if(!c){console.warn(`updateTableField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let u=null;if(Ut(n))u={cells:n.cells,merges:n.merges?We(n.merges):[]};else if(n&&Pt(n,s)){const p=n[f];u={cells:n[s],merges:p?We(p):[]}}u&&c._applyExternalUpdate?c._applyExternalUpdate(u):c.value=JSON.stringify(n)}function Sl(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`))};if(e.addEventListener("input",r),setTimeout(()=>{e.isConnected&&r()},0),typeof ResizeObserver=="undefined")return;let o=-1;const a=new ResizeObserver(i=>{var l,d,s,f,c;if(!e.isConnected){a.disconnect();return}const u=i[0],p=(c=(f=(d=(l=u==null?void 0:u.contentBoxSize)==null?void 0:l[0])==null?void 0:d.inlineSize)!=null?f:(s=u==null?void 0:u.contentRect)==null?void 0:s.width)!=null?c:0;p!==o&&(o=p,r())});a.observe(e)}function Wt(e,t){var n,r,o,a;const i=new Map,l=new Map;for(const d of e){const s=t.resourceIndex.get(d),f=(n=s==null?void 0:s.name)!=null?n:d;l.set(f,((r=l.get(f))!=null?r:0)+1)}for(const d of e){const s=t.resourceIndex.get(d),f=(o=s==null?void 0:s.name)!=null?o:d;((a=l.get(f))!=null?a:1)>1&&s?i.set(d,`${f} (${vr(s.size)})`):i.set(d,f)}return i}function Vt(e){return e?e.type.startsWith("image/"):!1}function nr(e,t){const n=Wt(e,t),r=new Map;for(const o of e){const a=n.get(o);a&&r.set(a,o)}return r}function Kt(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function mt(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 Ll(e,t){if(t.size===0)return[];const n=mt(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 Tl(e,t){const n=Ll(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 rr(e,t,n){const r=Wt(t,n),o=new Map;for(const d of t){const s=r.get(d);s&&o.set(d,s)}const a=mt(e);if(a.length===0)return e;let i="",l=0;for(const d of a){i+=e.slice(l,d.start);const s=o.get(d.name);s?i+=Kt(s):i+=d.raw,l=d.end}return i+=e.slice(l),i}function or(e,t,n,r){if(we(e),n!=null&&n.file&&Vt(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;",we(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 lr(e,t,n,r){if(we(e),n!=null&&n.file&&Vt(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;",we(e),e.appendChild(i)}).catch(o=>{var a,i;(i=(a=r.config).onThumbnailError)==null||i.call(a,o,t)})}function ir(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 ar(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=`
1272
+ position: fixed;
1273
+ z-index: 99999;
1274
+ background: #fff;
1275
+ border: 1px solid var(--fb-border-color, #d1d5db);
1276
+ border-radius: 8px;
1277
+ box-shadow: 0 4px 12px rgba(0,0,0,0.15);
1278
+ padding: 4px;
1279
+ pointer-events: none;
1280
+ min-width: 60px;
1281
+ max-width: 140px;
1282
+ `;const a=document.createElement("div");return a.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",lr(a,t,r,n),o.appendChild(a),document.body.appendChild(o),ir(o,e),o}function sr(e,t){var n,r;const{rid:o,state:a,isReadonly:i,onMention:l,onRemove:d}=t,s=a.resourceIndex.get(o),f=(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=`
1283
+ position: fixed;
1284
+ z-index: 99999;
1285
+ background: #fff;
1286
+ border: 1px solid var(--fb-border-color, #d1d5db);
1287
+ border-radius: 8px;
1288
+ box-shadow: 0 4px 12px rgba(0,0,0,0.15);
1289
+ padding: 4px;
1290
+ pointer-events: auto;
1291
+ min-width: 80px;
1292
+ max-width: 260px;
1293
+ `;const u=document.createElement("div");u.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",lr(u,o,s,a),c.appendChild(u);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=f,c.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;",v=h=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-text-color, #111827)"},E=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",()=>v(h)),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",y=>{y.stopPropagation(),l(),c.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",()=>v(h)),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",y=>{var g,C;y.stopPropagation(),(C=(g=a.config).downloadFile)==null||C.call(g,o,f)}),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",()=>v(h)),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",y=>{var g,C,w,x;if(y.stopPropagation(),a.config.getDownloadUrl){const S=a.config.getDownloadUrl(o);S?window.open(S,"_blank"):(C=(g=a.config).getThumbnail)==null||C.call(g,o).then(z=>{z&&window.open(z,"_blank")}).catch(()=>{})}else(x=(w=a.config).getThumbnail)==null||x.call(w,o).then(S=>{S&&window.open(S,"_blank")}).catch(()=>{})}),m.appendChild(h)}if(!i&&d){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",()=>E(h)),h.addEventListener("click",y=>{y.stopPropagation(),c.remove(),d()}),m.appendChild(h)}return m.children.length>0&&c.appendChild(m),document.body.appendChild(c),ir(c,e),c}function dr(){return{element:null,hideTimer:null}}function ht(e,t=150){e.hideTimer===null&&(e.hideTimer=setTimeout(()=>{e.hideTimer=null,e.element&&(e.element.remove(),e.element=null)},t))}function bt(e){e.hideTimer!==null&&(clearTimeout(e.hideTimer),e.hideTimer=null)}function Ke(e){return e&&e.remove(),null}function Al(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 vt="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 Fl(e,t,n,r,o){var a;const i=t.state,l=[...o.files],d={open:!1,query:"",triggerPos:-1,selectedIndex:0},s=new AbortController,f=document.createElement("input");f.type="hidden",f.name=r;function c(){var $,I;const M=x.value,N=nr(l,i),q=M?Tl(M,N):null,B=($=e.textKey)!=null?$:"text",ne=(I=e.filesKey)!=null?I:"files";return{[B]:M===""?null:q,[ne]:[...l]}}function u(){f.value=JSON.stringify(c())}const p=document.createElement("div");p.className="fb-richinput-wrapper",p.style.cssText=`
1294
+ position: relative;
1295
+ border: 1px solid var(--fb-border-color, #d1d5db);
1296
+ border-radius: 16px;
1297
+ background: var(--fb-background-color, #f9fafb);
1298
+ transition: box-shadow 0.15s, border-color 0.15s;
1299
+ `,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 v($){m.textContent=$,m.style.display="block",b&&clearTimeout(b),b=setTimeout(()=>{m.style.display="none",m.textContent="",b=null},5e3)}function E($){var I;const M=Re(e.accept);if(!Ue($.name,M)){const q=M.join(", ");return v(k("invalidFileExtension",i,{name:$.name,formats:q})),!1}const N=(I=e.maxSize)!=null?I:1/0;return at($,N)?!0:(v(k("fileTooLarge",i,{name:$.name,maxSize:N})),!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 I,M;$.preventDefault(),h=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none";const N=(I=$.dataTransfer)==null?void 0:I.files;if(!N||!i.config.uploadFile)return;const q=(M=e.maxFiles)!=null?M:1/0;for(let B=0;B<N.length;B++){if(l.length>=q){v(k("filesLimitExceeded",i,{skipped:N.length-B,max:q}));break}E(N[B])&&Ae(N[B])}});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 g=document.createElement("input");g.type="file",g.multiple=!0,g.style.display="none",e.accept&&(typeof e.accept=="string"?g.accept=e.accept:g.accept=e.accept.extensions.map($=>$.startsWith(".")?$:`.${$}`).join(","));const C=document.createElement("div");C.style.cssText="position: relative;";const w=document.createElement("div");w.className="fb-richinput-backdrop",w.style.cssText=`
1300
+ position: absolute;
1301
+ top: 0; left: 0; right: 0; bottom: 0;
1302
+ ${ur}
1303
+ ${vt}
1304
+ white-space: pre-wrap;
1305
+ word-break: break-word;
1306
+ color: transparent;
1307
+ pointer-events: none;
1308
+ overflow: hidden;
1309
+ border-radius: inherit;
1310
+ box-sizing: border-box;
1311
+ z-index: 2;
1312
+ `;const x=document.createElement("textarea");x.name=`${r}__text`,x.placeholder=e.placeholder||k("richinputPlaceholder",i);const S=(a=o.text)!=null?a:"";x.value=S?rr(S,l,i):"",x.style.cssText=`
1313
+ width: 100%;
1314
+ ${ur}
1315
+ ${vt}
1316
+ background: transparent;
1317
+ border: none;
1318
+ outline: none;
1319
+ resize: none;
1320
+ color: var(--fb-text-color, #111827);
1321
+ box-sizing: border-box;
1322
+ position: relative;
1323
+ z-index: 1;
1324
+ caret-color: var(--fb-text-color, #111827);
1325
+ `,Sl(x,w),x.addEventListener("scroll",()=>{w.scrollTop=x.scrollTop});let z=null;w.addEventListener("mouseover",$=>{var I,M;const N=(M=(I=$.target).closest)==null?void 0:M.call(I,"mark");N!=null&&N.dataset.rid&&(z=Ke(z),z=ar(N,N.dataset.rid,i))}),w.addEventListener("mouseout",$=>{var I,M,N;if(!((M=(I=$.target).closest)!=null&&M.call(I,"mark")))return;const q=$.relatedTarget;(N=q==null?void 0:q.closest)!=null&&N.call(q,"mark")||(z=Ke(z))}),w.addEventListener("mousedown",$=>{var I,M;if(!((M=(I=$.target).closest)!=null&&M.call(I,"mark")))return;z=Ke(z);const N=w.querySelectorAll("mark");N.forEach(B=>B.style.pointerEvents="none");const q=document.elementFromPoint($.clientX,$.clientY);q&&q.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,clientX:$.clientX,clientY:$.clientY,button:$.button,buttons:$.buttons,detail:$.detail})),document.addEventListener("mouseup",()=>{N.forEach(B=>B.style.pointerEvents="auto")},{once:!0})});function ae(){const $=x.value,I=nr(l,i),M=mt($);if(M.length===0){w.innerHTML=se($)+`
1326
+ `;return}let N="",q=0;for(const B of M){N+=se($.slice(q,B.start));const ne=I.get(B.name);ne?N+=`<mark data-rid="${se(ne)}" 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;">${se($.slice(B.start,B.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;">${se($.slice(B.start,B.end))}</mark>`,q=B.end}N+=se($.slice(q)),w.innerHTML=N+`
1327
+ `}const K=document.createElement("button");K.type="button",K.title=k("richinputAttachFile",i),K.style.cssText=`
1328
+ position: absolute;
1329
+ right: 6px;
1330
+ bottom: 6px;
1331
+ z-index: 2;
1332
+ width: 28px;
1333
+ height: 28px;
1334
+ border: none;
1335
+ border-radius: 6px;
1336
+ background: transparent;
1337
+ cursor: pointer;
1338
+ display: flex;
1339
+ align-items: center;
1340
+ justify-content: center;
1341
+ color: var(--fb-text-muted-color, #9ca3af);
1342
+ transition: color 0.15s, background 0.15s;
1343
+ `,K.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>',K.addEventListener("mouseenter",()=>{K.style.color="var(--fb-primary-color, #0066cc)",K.style.background="var(--fb-background-hover-color, #f3f4f6)"}),K.addEventListener("mouseleave",()=>{K.style.color="var(--fb-text-muted-color, #9ca3af)",K.style.background="transparent"}),K.addEventListener("click",()=>{var $;const I=($=e.maxFiles)!=null?$:1/0;if(l.length>=I){v(k("filesLimitExceeded",i,{skipped:1,max:I}));return}g.click()});const H=document.createElement("div");H.className="fb-richinput-dropdown",H.style.cssText=`
1344
+ display: none;
1345
+ position: absolute;
1346
+ bottom: 100%;
1347
+ left: 0;
1348
+ z-index: 1000;
1349
+ background: #fff;
1350
+ border: 1px solid var(--fb-border-color, #d1d5db);
1351
+ border-radius: var(--fb-border-radius, 6px);
1352
+ box-shadow: 0 4px 12px rgba(0,0,0,0.12);
1353
+ min-width: 180px;
1354
+ max-width: 320px;
1355
+ max-height: 200px;
1356
+ overflow-y: auto;
1357
+ margin-bottom: 4px;
1358
+ ${vt}
1359
+ `;function V(){return Wt(l,i)}function te($){we(H);const I=V();if($.length===0){H.style.display="none",d.open=!1;return}$.forEach((M,N)=>{var q;const B=i.resourceIndex.get(M),ne=document.createElement("div");ne.className="fb-richinput-dropdown-item",ne.dataset.rid=M,ne.style.cssText=`
1360
+ padding: 5px 10px;
1361
+ cursor: pointer;
1362
+ color: var(--fb-text-color, #111827);
1363
+ background: ${N===d.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
1364
+ display: flex;
1365
+ align-items: center;
1366
+ gap: 8px;
1367
+ `;const re=document.createElement("div");if(re.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;",B!=null&&B.file&&Vt(B)){const de=document.createElement("img");de.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const ve=new FileReader;ve.onload=A=>{var T;de.src=((T=A.target)==null?void 0:T.result)||""},ve.readAsDataURL(B.file),re.appendChild(de)}else i.config.getThumbnail&&i.config.getThumbnail(M).then(de=>{if(!de||!re.isConnected)return;const ve=document.createElement("img");ve.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",ve.src=de,we(re),re.appendChild(ve)}).catch(()=>{}),re.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>';ne.appendChild(re);const ce=document.createElement("span");ce.style.cssText="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",ce.textContent=(q=I.get(M))!=null?q:M,ne.appendChild(ce),H.appendChild(ne)}),H.onmousemove=M=>{var N,q,B;const ne=(q=(N=M.target).closest)==null?void 0:q.call(N,".fb-richinput-dropdown-item");if(!ne)return;const re=$.indexOf((B=ne.dataset.rid)!=null?B:"");re===-1||re===d.selectedIndex||(H.querySelectorAll(".fb-richinput-dropdown-item").forEach((ce,de)=>{ce.style.background=de===re?"var(--fb-background-hover-color, #f3f4f6)":"transparent"}),d.selectedIndex=re)},H.onmousedown=M=>{var N,q;M.preventDefault(),M.stopPropagation();const B=(q=(N=M.target).closest)==null?void 0:q.call(N,".fb-richinput-dropdown-item");B!=null&&B.dataset.rid&&le(B.dataset.rid)},H.style.display="block",d.open=!0}function R(){const $=Al(x);if(!$){G();return}d.query=$.query,d.triggerPos=$.pos,d.selectedIndex=0;const I=V(),M=cr($.query,l,I);te(M)}function G(){H.style.display="none",d.open=!1}function le($){var I,M,N,q;const B=(N=(M=V().get($))!=null?M:(I=i.resourceIndex.get($))==null?void 0:I.name)!=null?N:$,ne=(q=x.selectionStart)!=null?q:0,re=x.value.slice(0,d.triggerPos),ce=x.value.slice(ne),de=`${Kt(B)} `;x.value=`${re}${de}${ce}`;const ve=re.length+de.length;x.setSelectionRange(ve,ve),x.dispatchEvent(new Event("input")),G()}x.addEventListener("input",()=>{var $;ae(),u(),($=t.instance)==null||$.triggerOnChange(r,c()),l.length>0?R():G()});function pe(){H.querySelectorAll(".fb-richinput-dropdown-item").forEach(($,I)=>{$.style.background=I===d.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}x.addEventListener("keydown",$=>{if(!d.open)return;const I=V(),M=cr(d.query,l,I);$.key==="ArrowDown"?($.preventDefault(),d.selectedIndex=Math.min(d.selectedIndex+1,M.length-1),pe()):$.key==="ArrowUp"?($.preventDefault(),d.selectedIndex=Math.max(d.selectedIndex-1,0),pe()):$.key==="Enter"&&M.length>0?($.preventDefault(),le(M[d.selectedIndex])):$.key==="Escape"&&G()}),document.addEventListener("click",$=>{!p.contains($.target)&&!H.contains($.target)&&G()},{signal:s.signal});function me(){if(we(y),l.length===0){y.style.display="none";return}y.style.display="flex",l.forEach($=>{const I=i.resourceIndex.get($),M=document.createElement("div");M.className="fb-richinput-file-thumb",M.style.cssText=`
1368
+ position: relative;
1369
+ width: 48px;
1370
+ height: 48px;
1371
+ border: 1px solid var(--fb-border-color, #d1d5db);
1372
+ border-radius: 8px;
1373
+ overflow: hidden;
1374
+ flex-shrink: 0;
1375
+ cursor: pointer;
1376
+ background: #fff;
1377
+ `;const N=document.createElement("div");N.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",or(N,$,I,i),M.appendChild(N);const q=dr(),B=()=>{var re,ce,de;const ve=(re=x.selectionStart)!=null?re:x.value.length,A=(de=(ce=V().get($))!=null?ce:I==null?void 0:I.name)!=null?de:$,T=x.value.slice(0,ve),L=x.value.slice(ve),D=`${T.length>0&&!/[\s\n]$/.test(T)?`
1378
+ `:""}${Kt(A)} `;x.value=`${T}${D}${L}`;const j=ve+D.length;x.setSelectionRange(j,j),x.focus(),x.dispatchEvent(new Event("input"))},ne=()=>{var re;const ce=l.indexOf($);ce!==-1&&l.splice(ce,1),me(),ae(),u(),(re=t.instance)==null||re.triggerOnChange(r,c())};M.addEventListener("mouseenter",()=>{bt(q),q.element||(q.element=sr(M,{rid:$,state:i,isReadonly:!1,onMention:B,onRemove:ne}),q.element.addEventListener("mouseenter",()=>{bt(q)}),q.element.addEventListener("mouseleave",()=>{ht(q)}))}),M.addEventListener("mouseleave",()=>{ht(q)}),y.appendChild(M)})}function Ae($){if(!i.config.uploadFile)return;const I=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;i.resourceIndex.set(I,{name:$.name,type:$.type,size:$.size,uploadedAt:new Date,file:$}),l.push(I),me();const M=y.querySelectorAll(".fb-richinput-file-thumb"),N=M[M.length-1];N&&(N.style.opacity="0.5"),i.config.uploadFile($).then(q=>{var B;const ne=l.indexOf(I);ne!==-1&&(l[ne]=q),i.resourceIndex.delete(I),i.resourceIndex.set(q,{name:$.name,type:$.type,size:$.size,uploadedAt:new Date,file:$}),me(),ae(),u(),(B=t.instance)==null||B.triggerOnChange(r,c())}).catch(q=>{var B,ne;const re=l.indexOf(I);re!==-1&&l.splice(re,1),i.resourceIndex.delete(I),me(),(ne=(B=i.config).onUploadError)==null||ne.call(B,q,$)})}if(g.addEventListener("change",()=>{var $;const I=g.files;if(!I||I.length===0)return;const M=($=e.maxFiles)!=null?$:1/0;for(let N=0;N<I.length;N++){if(l.length>=M){v(k("filesLimitExceeded",i,{skipped:I.length-N,max:M}));break}E(I[N])&&Ae(I[N])}g.value=""}),C.appendChild(w),C.appendChild(x),C.appendChild(K),C.appendChild(H),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 I=ot(e,x);I.style.cssText=`
1379
+ position: static;
1380
+ display: inline-block;
1381
+ font-size: var(--fb-font-size-small);
1382
+ color: var(--fb-text-secondary-color);
1383
+ pointer-events: none;
1384
+ `,$.appendChild(I),p.appendChild($)}p.appendChild(f),p.appendChild(g),u(),ae(),f._applyExternalUpdate=$=>{var I;const M=(I=$.text)!=null?I:"";x.value=M?rr(M,l,i):"",x.dispatchEvent(new Event("input")),l.length=0;for(const N of $.files)l.push(N);me(),ae(),u()},n.appendChild(p),me();const xe=new MutationObserver(()=>{p.isConnected||(s.abort(),z=Ke(z),xe.disconnect())});p.parentElement&&xe.observe(p.parentElement,{childList:!0})}function zl(e,t,n,r,o){var a,i;const l=t.state,{text:d,files:s}=o,f=new Map;for(const c of s){const u=l.resourceIndex.get(c);u!=null&&u.name&&f.set(c,u.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(u=>{const p=l.resourceIndex.get(u),m=document.createElement("div");m.style.cssText=`
1385
+ position: relative;
1386
+ width: 48px; height: 48px;
1387
+ border: 1px solid var(--fb-border-color, #d1d5db);
1388
+ border-radius: 8px;
1389
+ overflow: hidden;
1390
+ flex-shrink: 0;
1391
+ background: #fff;
1392
+ cursor: default;
1393
+ `;const b=document.createElement("div");b.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",or(b,u,p,l),m.appendChild(b);const v=dr();m.addEventListener("mouseenter",()=>{bt(v),v.element||(v.element=sr(m,{rid:u,state:l,isReadonly:!0}),v.element.addEventListener("mouseenter",()=>{bt(v)}),v.element.addEventListener("mouseleave",()=>{ht(v)}))}),m.addEventListener("mouseleave",()=>{ht(v)}),c.appendChild(m)}),n.appendChild(c)}if(d){const c=document.createElement("div");c.style.cssText=`
1394
+ ${vt}
1395
+ color: var(--fb-text-color, #111827);
1396
+ white-space: pre-wrap;
1397
+ word-break: break-word;
1398
+ `;const u=mt(d).filter(p=>f.has(p.name)||[...f.values()].includes(p.name));if(u.length===0)c.textContent=d;else{let p=0;for(const m of u){m.start>p&&c.appendChild(document.createTextNode(d.slice(p,m.start)));const b=document.createElement("span");b.style.cssText=`
1399
+ display: inline;
1400
+ background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent);
1401
+ color: var(--fb-primary-color, #0066cc);
1402
+ border-radius: 8px;
1403
+ padding: 1px 6px;
1404
+ font-weight: 500;
1405
+ cursor: default;
1406
+ `;const v=f.has(m.name)?m.name:(a=[...f.entries()].find(([,h])=>h===m.name))==null?void 0:a[0],E=(i=f.get(m.name))!=null?i:m.name;if(b.textContent=`@${E}`,v){let h=null;const y=v;b.addEventListener("mouseenter",()=>{h=Ke(h),h=ar(b,y,l)}),b.addEventListener("mouseleave",()=>{h=Ke(h)})}c.appendChild(b),p=m.end}p<d.length&&c.appendChild(document.createTextNode(d.slice(p)))}n.appendChild(c)}if(!d&&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 Ml(e,t,n,r){var o,a,i,l;const d=t.state,s=ie(e,d,t),f=(o=e.textKey)!=null?o:"text",c=(a=e.filesKey)!=null?a:"files";let u;if(e.flatOutput){const p=t.prefill[f],m=t.prefill[c];u={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[f])!=null?i:m.text,v=(l=m[c])!=null?l:m.files;u={text:typeof b=="string"?b:null,files:Array.isArray(v)?v:[]}}else typeof p=="string"?u={text:p||null,files:[]}:u={text:null,files:[]}}for(const p of u.files)d.resourceIndex.has(p)||d.resourceIndex.set(p,{name:p,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(s)zl(e,t,n,r,u);else{if(!d.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);Fl(e,t,n,r,u)}}function Nl(e,t,n){var r,o;const{scopeRoot:a,state:i,skipValidation:l}=n,d=[],s=(r=e.textKey)!=null?r:"text",f=(o=e.filesKey)!=null?o:"files",c=a.querySelector(`[name="${t}"]`);if(!c)return{value:null,errors:d};let u;try{const h=JSON.parse(c.value);if(h&&typeof h=="object"&&!Array.isArray(h))u=h;else return d.push(`${t}: invalid richinput data`),{value:null,errors:d}}catch(h){return d.push(`${t}: invalid richinput data`),{value:null,errors:d}}const p=u[s],m=u[f],b=p===null||typeof p=="string"?p:null,v=Array.isArray(m)?m:[],E={[s]:b!=null?b:null,[f]:v};if(!l){const h=!b||b.trim()==="",y=v.length===0;e.required&&h&&y&&d.push(`${t}: ${k("required",i)}`),!h&&b&&(e.minLength!=null&&b.length<e.minLength&&d.push(`${t}: ${k("minLength",i,{min:e.minLength})}`),e.maxLength!=null&&b.length>e.maxLength&&d.push(`${t}: ${k("maxLength",i,{max:e.maxLength})}`)),e.maxFiles!=null&&v.length>e.maxFiles&&d.push(`${t}: ${k("maxFiles",i,{max:e.maxFiles})}`)}return{value:E,errors:d,spread:!!e.flatOutput}}function Il(e,t,n,r){var o,a,i,l;const{scopeRoot:d}=r,s=d.querySelector(`[name="${t}"]`);if(!s){console.warn(`updateRichInputField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let f=null;if(n&&typeof n=="object"&&!Array.isArray(n)){const c=n,u=(o=e.textKey)!=null?o:"text",p=(a=e.filesKey)!=null?a:"files",m=(i=c[u])!=null?i:c.text,b=(l=c[p])!=null?l:c.files;(m!==void 0||b!==void 0)&&(f={text:typeof m=="string"?m:null,files:Array.isArray(b)?b:[]})}f&&s._applyExternalUpdate?s._applyExternalUpdate(f):f&&(s.value=JSON.stringify(f))}const Rl={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function fr(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function et(e){return(e+"").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function _t(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,d,s,f,c;function u(m){const b=Rl[m[1]||""],v=r[r.length-1]===m;return b?b[1]?(v?r.pop():r.push(m),b[v?1:0]):b[0]:m}function p(){let m="";for(;r.length;)m+=u(r[r.length-1]);return m}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,(m,b,v)=>(a[b.toLowerCase()]=v,"")).replace(/^\n+|\n+$/g,"");s=n.exec(e);)d=e.substring(i,s.index),i=n.lastIndex,l=s[0],d.match(/[^\\](\\\\)*\\$/)||((c=s[3]||s[4])?l='<pre class="code '+(s[4]?"poetry":s[2].toLowerCase())+'"><code'+(s[2]?` class="language-${s[2].toLowerCase()}"`:"")+">"+fr(et(c).replace(/^\n+|\n+$/g,""))+"</code></pre>":(c=s[6])?(c.match(/\./)&&(s[5]=s[5].replace(/^\d+/gm,"")),f=_t(fr(s[5].replace(/^\s*[>*+.-]/gm,""))),c===">"?c="blockquote":(c=c.match(/\./)?"ol":"ul",f=f.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),l="<"+c+">"+f+"</"+c+">"):s[8]?l=`<img src="${et(s[8])}" alt="${et(s[7])}">`:s[10]?(o=o.replace("<a>",`<a href="${et(s[11]||a[d.toLowerCase()])}">`),l=p()+"</a>"):s[9]?l="<a>":s[12]||s[14]?(c="h"+(s[14]?s[14].length:s[13]>"="?1:2),l="<"+c+">"+_t(s[12]||s[15],a)+"</"+c+">"):s[16]?l="<code>"+et(s[16])+"</code>":(s[17]||s[1])&&(l=u(s[17]||"--"))),o+=d,o+=l;return(o+e.substring(i)+p()).replace(/^\n+|\n+$/g,"")}const pr="fb-markdown-styles";function ql(){if(typeof document=="undefined"||document.getElementById(pr))return;const e=document.createElement("style");e.id=pr,e.setAttribute("data-fb-markdown-styles","true"),e.textContent=`
1407
+ .fb-markdown {
1408
+ font-family: var(--fb-font-family, inherit);
1409
+ font-size: var(--fb-font-size, 1rem);
1410
+ color: var(--fb-text-color, #1f2937);
1411
+ line-height: 1.6;
1412
+ }
1413
+ .fb-markdown h1,
1414
+ .fb-markdown h2,
1415
+ .fb-markdown h3,
1416
+ .fb-markdown h4,
1417
+ .fb-markdown h5,
1418
+ .fb-markdown h6 {
1419
+ font-weight: var(--fb-font-weight-medium, 600);
1420
+ color: var(--fb-text-color, #1f2937);
1421
+ margin-top: 0.75em;
1422
+ margin-bottom: 0.25em;
1423
+ }
1424
+ .fb-markdown h1 { font-size: 1.5rem; }
1425
+ .fb-markdown h2 { font-size: 1.25rem; }
1426
+ .fb-markdown h3 { font-size: 1.1rem; }
1427
+ .fb-markdown h4,
1428
+ .fb-markdown h5,
1429
+ .fb-markdown h6 { font-size: 1rem; }
1430
+ .fb-markdown p {
1431
+ margin-top: 0;
1432
+ margin-bottom: 0.5em;
1433
+ }
1434
+ .fb-markdown ul,
1435
+ .fb-markdown ol {
1436
+ margin: 0.25em 0 0.5em 1.5em;
1437
+ padding: 0;
1438
+ }
1439
+ .fb-markdown li {
1440
+ margin-bottom: 0.15em;
1441
+ }
1442
+ .fb-markdown a {
1443
+ color: var(--fb-primary-color, #2563eb);
1444
+ text-decoration: underline;
1445
+ }
1446
+ .fb-markdown a:hover {
1447
+ opacity: 0.8;
1448
+ }
1449
+ .fb-markdown code {
1450
+ background: var(--fb-input-background-color, #f3f4f6);
1451
+ border-radius: 3px;
1452
+ padding: 0.1em 0.35em;
1453
+ font-size: 0.9em;
1454
+ font-family: monospace;
1455
+ }
1456
+ .fb-markdown pre {
1457
+ background: var(--fb-input-background-color, #f3f4f6);
1458
+ border-radius: var(--fb-border-radius, 0.375rem);
1459
+ padding: 0.75em 1em;
1460
+ overflow-x: auto;
1461
+ margin: 0.5em 0;
1462
+ }
1463
+ .fb-markdown pre code {
1464
+ background: none;
1465
+ padding: 0;
1466
+ border-radius: 0;
1467
+ font-size: inherit;
1468
+ }
1469
+ .fb-markdown blockquote {
1470
+ border-left: 3px solid var(--fb-border-color, #d1d5db);
1471
+ margin: 0.5em 0;
1472
+ padding-left: 1em;
1473
+ color: var(--fb-text-secondary-color, #6b7280);
1474
+ }
1475
+ .fb-markdown hr {
1476
+ border: none;
1477
+ border-top: 1px solid var(--fb-border-color, #d1d5db);
1478
+ margin: 0.75em 0;
1479
+ }
1480
+ .fb-markdown strong { font-weight: var(--fb-font-weight-medium, 600); }
1481
+ .fb-markdown em { font-style: italic; }
1482
+ .fb-markdown s { text-decoration: line-through; }
1483
+ `,document.head.appendChild(e)}const Bl=["javascript:","data:","vbscript:","blob:"],Hl=["javascript:","vbscript:","blob:"];function Dl(e){return!!(Hl.some(t=>e.startsWith(t))||e.startsWith("data:")&&!e.startsWith("data:image/"))}function jl(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ol(e){e.querySelectorAll("a[href]").forEach(t=>{var n;const r=((n=t.getAttribute("href"))!=null?n:"").trim().toLowerCase();Bl.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();Dl(r)&&t.setAttribute("src","")})}function Ul(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})`);ql();const r=document.createElement("div");r.className="fb-markdown";const o=jl(e.content);return r.innerHTML=_t(o),Ol(r),n.appendChild(r),r}function Pl(e,t,n){return{value:void 0,errors:[],skip:!0}}function Wl(e,t,n,r){}function Vl(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:Qt(i),errors:[]}}function Kl(e,t,n,r){const{scopeRoot:o}=r,a=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);a&&(a.value=Zt(n))}const _l={text:{validate:rn,update:on},textarea:{validate:zr,update:Mr},number:{validate:Br,update:Hr},select:{validate:Or,update:Ur},switcher:{validate:Kr,update:_r},boolean:{validate:Xr,update:Gr,ownsLabel:!0},file:{validate:qn,update:Hn},files:{validate:qn,update:Hn},colour:{validate:tl,update:nl},slider:{validate:ll,update:il},container:{validate:Gn,update:Zn},group:{validate:fl,update:pl},table:{validate:kl,update:$l},richinput:{validate:Nl,update:Il},hidden:{validate:Vl,update:Kl},markdown:{validate:Pl,update:Wl}};function Jt(e){return _l[e]||null}function Jl(e,t,n){const r=Jt(e.type);return r&&r.validate?r.validate(e,t,n):null}function Yl(e,t,n,r){const o=Jt(e.type);return o&&o.update?(o.update(e,t,n,r),!0):!1}function Xl(e,t){const n=document.getElementById(e);if(!n)return;const r=!n.classList.contains("hidden");if(document.querySelectorAll('[id^="tooltip-"]').forEach(f=>{f.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 d=o.left,s=o.bottom+5;d+l.width>a&&(d=o.right-l.width),s+l.height>i&&(s=o.top-l.height-5),d<10&&(d=10),s<10&&(s=o.bottom+5),n.style.left=`${d}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 mr(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!je(e.enableIf,a,i)}catch(a){console.error(`Error evaluating enableIf for field "${e.key}":`,a)}return!1}function Gl(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 Zl(e,t){const n=e.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return{};const r={};let o=r;for(let i=0;i<n.length-1;i++){const l=n[i],d=n[i+1],s=d.startsWith("[")&&d.endsWith("]")?[]:{};if(l.startsWith("[")&&l.endsWith("]")){const f=parseInt(l.slice(1,-1),10);o[f]=s}else o[l]=s;o=s}const a=n[n.length-1];return a.startsWith("[")&&a.endsWith("]")?o[parseInt(a.slice(1,-1),10)]=t:o[a]=t,r}function gt(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const a=t.enableIf,i=(r=a.scope)!=null?r:"relative",l=!n.path||n.path===""?"absolute":i,d=a.key,s=l==="relative"&&n.path?`${n.path}.${d}`:d,f=Gl(s,o),c=Zl(d,f),u=l==="relative"?{}:c,p=l==="relative"?c:void 0;try{je(a,u,p)?(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(m){console.error(`Error re-evaluating enableIf for field "${t.key}":`,m)}}function hr(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 d;i==="relative"&&n.path?d=`${n.path}.${l}`:d=l;const s=o.querySelector(`[name="${d}"]`);if(!s){const f=new MutationObserver(()=>{const c=o.querySelector(`[name="${d}"]`);c&&(c.addEventListener("change",()=>{gt(e,t,n)}),c.addEventListener("input",()=>{gt(e,t,n)}),f.disconnect(),n.state.enableIfObservers.delete(f))});n.state.enableIfObservers.add(f),f.observe(o,{childList:!0,subtree:!0});return}s.addEventListener("change",()=>{gt(e,t,n)}),s.addEventListener("input",()=>{gt(e,t,n)})}function Ql(e){var t,n;const r=document.createElement("label");if(r.className="font-medium text-gray-900",r.style.cssText="font-size: var(--fb-label-font-size, 0.75rem); line-height: var(--fb-label-line-height, 1.2);",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 ei(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(),Xl(n,t)},t}function ti(e){const t=document.createElement("div");t.className="flex items-center",t.style.marginBottom="var(--fb-label-margin-bottom, 2px)",t.dataset.fbLabelRow="";const n=Ql(e);if(t.appendChild(n),e.description||e.hint){const r=ei(e);t.appendChild(r)}return t}function ni(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?Tr(e,t,n,r):Lr(e,t,n,r);break;case"textarea":o?Fr(e,t,n,r):Ar(e,t,n,r);break;case"number":o?qr(e,t,n,r):Rr(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?Zo(e,t,n,r):Xo(e,t,n,r);break;case"files":Go(e,t,n,r);break;case"colour":o?el(e,t,n,r):Qo(e,t,n,r);break;case"slider":o?ol(e,t,n,r):rl(e,t,n,r);break;case"group":ul(e,t,n,r);break;case"container":o?Yn(e,t,n):Jn(e,t,n,r);break;case"table":El(e,t,n,r);break;case"richinput":Ml(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 Yt(e,t){if(e.type==="markdown"){if(e.hidden===!0){const d=document.createElement("div");return d.style.display="none",d.setAttribute("data-fb-hidden-markdown","true"),d}const i=mr(e,t),l=document.createElement("div");return l.className=`fb-field-wrapper fb-markdown-wrapper fb-size-${e.size||"md"}`,l.setAttribute("data-field-key",xt(e,t.state)),l.setAttribute("data-fb-width",e.width||"full"),Ul(e,t,l),i&&(l.style.display="none",l.classList.add("fb-field-wrapper-disabled"),l.setAttribute("data-conditionally-disabled","true")),hr(l,e,t),l}const n=mr(e,t),r=document.createElement("div");r.className=`fb-field-wrapper fb-size-${e.size||"md"}`,r.setAttribute("data-field-key",e.key),r.setAttribute("data-fb-width",e.width||"full");const o=Jt(e.type);if(!(o!=null&&o.ownsLabel)){const i=ti(e);r.appendChild(i)}const a=De(t.path,e.key);return ni(e,t,r,a),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),hr(r,e,t),r}al(Yt);const Xt={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",removeRow:"Remove row",removeRowFrom:"Remove row from {label}",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}",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",removeRow:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",removeRowFrom:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443 \u0438\u0437 \xAB{label}\xBB",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}",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 ri(e){const t={...Xt.translations};if(e!=null&&e.translations)for(const[n,r]of Object.entries(e.translations))t[n]={...Xt.translations[n]||{},...r};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...Xt,...e,translations:t},debounceTimer:null,prefill:{},syntheticElementIds:new WeakMap,syntheticElementIdCounter:0,enableIfObservers:new Set}}function oi(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const _e={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.125rem",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:"8px",labelSectionFontSize:"0.875rem",labelSectionLetterSpacing:"normal",labelSectionTextTransform:"none",labelFontSize:"0.75rem",labelLineHeight:"1.2",labelMarginBottom:"2px"};function li(e){const t={..._e,...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(`
1484
+ `)}function ii(e,t){kr(e.ownerDocument||document);const n=li(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=`
1485
+ [data-fb-root="true"] {
1486
+ ${n}
1487
+ }
1488
+ `}const ai={default:_e,dark:{..._e,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:{..._e,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:{..._e,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",inputPaddingX:"14px",inputPaddingY:"11px",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",slideCardBg:"linear-gradient(180deg, #f7f9fc 0%, #dde3ee 100%)",slideCardShadow:"none",slideCardRadius:"16px",labelSectionFontSize:"0.625rem",labelSectionLetterSpacing:"0.07em",labelSectionTextTransform:"uppercase"}};function Gt(e,t,n){const r=e.querySelectorAll(`[data-field-key="${t}"]`);for(const o of Array.from(r))if(o.closest("[data-container-item], [data-container]")===n)return o;return null}class yt{constructor(t){this.instanceId=oi(),this.state=ri(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,d=i.querySelector("label");if(d&&(d.textContent===l||d.textContent===`${l}*`)){let s=i.querySelector(".field-placeholder");return s||(s=document.createElement("div"),s.className="field-placeholder",s.style.display="none",i.appendChild(s)),s}}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=`
1489
+ border-top: var(--fb-border-width) solid var(--fb-border-color);
1490
+ `,t.forEach(a=>{const i=document.createElement("button");i.type="button",nn(i,!0);const l=n.includes(a),d=this.resolveActionLabel(a.key,a.label,null,l);i.textContent=d,i.addEventListener("click",s=>{s.preventDefault(),s.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 d=l.closest(".fb-field-wrapper");if(d||(d=l.parentElement),!d){console.warn(`External action: Could not find wrapper for field "${i}"`);return}const s=d.querySelector(".external-actions-container");s&&s.remove();const f=document.createElement("div");f.className="external-actions-container mt-3 flex flex-wrap gap-2";const c=this.findSchemaElement(i);a.forEach(u=>{const p=document.createElement("button");p.type="button",nn(p,!1);const m=this.resolveActionLabel(u.key,u.label,c);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(u.value,u.key,u.related_field)}),f.appendChild(p)}),d.appendChild(f)});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 d in i){const s=o?d:`${a}.${d}`,f=i[d];this.updateField(s,f)}const l=n.closest(".fb-prefill-hints");l&&l.querySelectorAll('.fb-prefill-hint[aria-pressed="true"]').forEach(d=>d.removeAttribute("aria-pressed")),n.setAttribute("aria-pressed","true")}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=Et(n);if(a.length>0){console.error("Schema validation errors:",a);return}this.disconnectEnableIfObservers(),this.state.formRoot=t,this.state.schema=n,this.state.externalActions=o||null,this.state.prefill=r||{},we(t),t.setAttribute("data-fb-root","true"),ii(t,this.state.config.theme);const i=document.createElement("div");if(i.className="fb-row",n.prefillHints&&!this.state.config.readonly){const s=this.createRootPrefillHints(n.prefillHints);i.appendChild(s)}const l=document.createElement("div"),d=n.columns||1;d===1?l.className="fb-row":l.className=`grid grid-cols-${d} gap-2`,n.elements.forEach(s=>{var f,c;if(s.type!=="markdown"&&(s.hidden||s.type==="hidden")){const p=(c=(f=r==null?void 0:r[s.key])!=null?f:s.default)!=null?c:null;l.appendChild(Ct(s.key,p));return}const u=Yt(s,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});l.appendChild(u)}),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 d;const s=(d=a.key)!=null?d:"",f={scopeRoot:l||this.state.formRoot,state:this.state,instance:this,path:i.path,skipValidation:t},c=Jl(a,s,f);return c!==null?(n.push(...c.errors),{value:c.value,spread:!!c.spread,skip:!!c.skip}):(console.warn(`Unknown field type "${a.type}" for key "${s}"`),{value:null,spread:!1})};return cl(o),this.state.schema.elements.forEach(a=>{var i;if(a.enableIf)try{if(!je(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}"]`),d=(i=l==null?void 0:l.value)!=null?i:"";d!==""?r[a.key]=Qt(d):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",d=(r=i.filesKey)!=null?r:"files";o.set(l,{schemaKey:a.key,role:"text"}),o.set(d,{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:""};Yl(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 Gt(r,o,null);const a=n.match(/^(.+)\[(\d+)\]$/);if(a){const l=r.querySelector(`[data-container-item="${a[1]}[${a[2]}]"]`);return l?Gt(l,o,l):null}const i=r.querySelector(`[data-container="${n}"]`);return i?Gt(i,o,i):null}applyEnableIfVisibility(t,n,r,o,a,i){var l,d,s,f;try{const c=((l=t.enableIf.scope)!=null?l:"relative")==="relative"&&o?nt(i,o):void 0,u=je(t.enableIf,i,c),p=n.getAttribute("data-conditionally-disabled")==="true";if(u&&p){const m=o?nt(i,o):i,b=Yt(t,{path:r,prefill:m&&typeof m=="object"?m:{},formData:i,state:this.state,instance:this});(d=n.parentNode)==null||d.replaceChild(b,n)}else if(!u&&!p){const m=document.createElement("div");m.className="fb-field-wrapper-disabled",m.style.display="none",m.setAttribute("data-field-key",xt(t,this.state)),m.setAttribute("data-conditionally-disabled","true"),(s=n.parentNode)==null||s.replaceChild(m,n)}}catch(c){console.error(`Error re-evaluating enableIf for field "${(f=t.key)!=null?f:"<no key>"}" at path "${a}":`,c)}}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(r,o,a)=>{r.forEach(i=>{var l;const d=(l=i.key)!=null?l:"",s=o?`${o}.${d}`:d,f=a?`${a}.${d}`:d;if(i.enableIf){const c=this.findFieldWrapper(i,o);c&&this.applyEnableIfVisibility(i,c,o,a,s,t)}if((i.type==="container"||i.type==="group")&&"elements"in i&&i.elements){const c=i.key?nt(t,f):void 0;Array.isArray(c)?wt(this.state.formRoot,s).forEach((u,p)=>{const m=u.getAttribute("data-container-item")||"";n(i.elements,m,`${f}[${p}]`)}):n(i.elements,s,f)}})};n(this.state.schema.elements,"","")}destroy(){var t;this.state.debounceTimer!==null&&(clearTimeout(this.state.debounceTimer),this.state.debounceTimer=null),this.disconnectEnableIfObservers(),this.state.resourceIndex.clear(),this.state.formRoot&&we(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))}disconnectEnableIfObservers(){for(const t of this.state.enableIfObservers)t.disconnect();this.state.enableIfObservers.clear()}}function br(e){return new yt(e)}return typeof window!="undefined"&&(window.FormBuilder=yt,window.createFormBuilder=br,window.validateSchema=Et),Fe.FormBuilderInstance=yt,Fe.createFormBuilder=br,Fe.default=yt,Fe.defaultTheme=_e,Fe.exampleThemes=ai,Fe.validateSchema=Et,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe})({});