@dmitryvim/form-builder 0.5.4 → 0.7.0

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