@dmitryvim/form-builder 0.2.34 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/formbuilder.min.js +453 -174
- package/dist/browser/formbuilder.v0.3.1.min.js +1441 -0
- package/dist/cjs/index.cjs +1331 -505
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +1317 -502
- package/dist/esm/index.js.map +1 -1
- package/dist/form-builder.js +453 -174
- package/dist/types/components/boolean.d.ts +4 -0
- package/dist/types/components/file/library.d.ts +40 -16
- package/dist/types/components/file/upload.d.ts +111 -2
- package/dist/types/components/text.d.ts +12 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/instance/FormBuilderInstance.d.ts +14 -1
- package/dist/types/styles/theme.d.ts +47 -0
- package/dist/types/types/component-operations.d.ts +7 -0
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/types/schema.d.ts +40 -1
- package/dist/types/utils/styles.d.ts +47 -0
- package/package.json +1 -1
- package/dist/browser/formbuilder.v0.2.34.min.js +0 -1162
package/dist/form-builder.js
CHANGED
|
@@ -1,4 +1,58 @@
|
|
|
1
|
-
var FormBuilder=(function(
|
|
1
|
+
var FormBuilder=(function(Ae){"use strict";function k(e,t,n){const r=t.config.locale||"en",o=t.config.translations[r],i=t.config.translations.en;let a=(o==null?void 0:o[e])||(i==null?void 0:i[e])||e;if(n)for(const[l,s]of Object.entries(n))a=a.replace(new RegExp(`\\{${l}\\}`,"g"),String(s));return a}function mr(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 hr(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 br(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 gr(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 vr(e,t,n){e.pattern&&t.push(k("hintPattern",n,{pattern:e.pattern}))}function Le(e,t){const n=[];return mr(e,n,t),e.type!=="slider"&&hr(e,n,t),br(e,n,t),gr(e,n,t),vr(e,n,t),n.join(" \u2022 ")}function xt(e){const t=[];if(!e||typeof e!="object")return t.push("Schema must be an object"),t;if(!Array.isArray(e.elements))return t.push("Schema missing elements array"),t;if("columns"in e&&e.columns!==void 0){const i=e.columns,a=[1,2,3,4];(!Number.isInteger(i)||!a.includes(i))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${i})`)}if("prefillHints"in e&&e.prefillHints){const i=e.prefillHints;Array.isArray(i)&&i.forEach((a,l)=>{if((!a.label||typeof a.label!="string")&&t.push(`schema.prefillHints[${l}] must have a 'label' property of type string`),!a.values||typeof a.values!="object")t.push(`schema.prefillHints[${l}] must have a 'values' property of type object`);else for(const s in a.values)e.elements.some(c=>c.key===s)||t.push(`schema.prefillHints[${l}] references non-existent field "${s}"`)})}function n(i,a,l){if("columns"in i&&i.columns!==void 0){const s=i.columns,c=[1,2,3,4];(!Number.isInteger(s)||!c.includes(s))&&l.push(`${a}: columns must be 1, 2, 3, or 4 (got ${s})`)}if("displayMode"in i&&i.displayMode!==void 0){const s=i.displayMode;s!=="stack"&&s!=="slides"&&l.push(`${a}: displayMode must be "stack" or "slides" (got ${JSON.stringify(s)})`)}}function r(i,a){var l,s;const c=new Set;for(const u of i)if(u.type==="richinput"&&u.flatOutput){const d=u,f=(l=d.textKey)!=null?l:"text",p=(s=d.filesKey)!=null?s:"files";for(const m of i)m!==u&&(m.key===f&&t.push(`${a}: RichInput "${u.key}" flatOutput textKey "${f}" collides with element key "${m.key}"`),m.key===p&&t.push(`${a}: RichInput "${u.key}" flatOutput filesKey "${p}" collides with element key "${m.key}"`));c.has(f)&&t.push(`${a}: RichInput "${u.key}" flatOutput textKey "${f}" collides with another flatOutput key`),c.has(p)&&t.push(`${a}: RichInput "${u.key}" flatOutput filesKey "${p}" collides with another flatOutput key`),c.add(f),c.add(p)}else u.key&&(c.has(u.key)&&t.push(`${a}: Element key "${u.key}" collides with a flatOutput richinput key`),c.add(u.key))}function o(i,a){i.forEach((l,s)=>{const c=`${a}[${s}]`;if(l.type||t.push(`${c}: missing type`),!l.key&&l.type!=="markdown"&&t.push(`${c}: missing key`),l.type==="markdown"){const u=l.content;typeof u!="string"&&t.push(`${c}: markdown element requires "content" to be a string (got ${u===null?"null":typeof u})`)}if(l.enableIf){const u=l.enableIf;(!u.key||typeof u.key!="string")&&t.push(`${c}: enableIf must have a 'key' property of type string`),"equals"in u||t.push(`${c}: enableIf must have at least one operator (equals, etc.)`)}if(l.type==="group"&&"elements"in l&&l.elements&&o(l.elements,`${c}.elements`),l.type==="container"&&l.elements){if(n(l,c,t),"prefillHints"in l&&l.prefillHints){const u=l.prefillHints;Array.isArray(u)&&u.forEach((d,f)=>{if((!d.label||typeof d.label!="string")&&t.push(`${c}: prefillHints[${f}] must have a 'label' property of type string`),!d.values||typeof d.values!="object")t.push(`${c}: prefillHints[${f}] must have a 'values' property of type object`);else for(const p in d.values)l.elements.some(m=>m.key===p)||t.push(`container "${l.key}": prefillHints[${f}] references non-existent field "${p}"`)})}o(l.elements,`${c}.elements`),r(l.elements,`${c}.elements`)}if(l.type==="select"&&l.options){const u=l.default;u!=null&&u!==""&&(l.options.some(d=>d.value===u)||t.push(`${c}: default "${u}" not in options`))}})}return Array.isArray(e.elements)&&(o(e.elements,"elements"),r(e.elements,"elements")),t}function ae(e,t,n){return e.readonly===!0||t.config.readonly===!0||(n==null?void 0:n.inheritedReadonly)===!0}function nt(e){return e&&typeof e=="object"&&e.constructor===Object}function se(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function wt(e,t){if(e.key)return e.key;const n=t.syntheticElementIds.get(e);if(n!==void 0)return n;const r=`fb-synthetic-${t.syntheticElementIdCounter++}`;return t.syntheticElementIds.set(e,r),r}function ke(e,t){return e?`${e}.${t}`:t}function ye(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function yr(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Gt(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Zt(e){if(e==="")return null;try{return JSON.parse(e)}catch(t){return e}}function _e(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.setAttribute("data-hidden-field","true"),n.value=Gt(t),n}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 i=parseInt(o.slice(1,-1),10);if(!Array.isArray(r)||isNaN(i))return;r=r[i]}else r=r[o]}return r}function He(e,t,n){var r;if(!e||!e.key)throw new Error("Invalid enableIf condition: must have a 'key' property");const o=(r=e.scope)!=null?r:"relative";let i;if(o==="relative")i=n!=null?n:t;else if(o==="absolute")i=t;else throw new Error(`Invalid enableIf scope: must be "relative" or "absolute" (got "${o}")`);const a=Ct(i,e.key);if("equals"in e)return xr(a,e.equals);throw new Error("Invalid enableIf condition: no recognized operator (equals, etc.)")}function xr(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 xe(e){const t=e.getAttribute("name");if(!t)return;const n=(e.ownerDocument||document).getElementById(`error-${t}`);n&&n.remove()}const Qt='<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 wr(e){if(e.head.querySelector("[data-fb-theming-hooks]"))return;const t=e.createElement("style");t.setAttribute("data-fb-theming-hooks",""),t.textContent=`
|
|
2
|
+
[data-fb-slide-card] {
|
|
3
|
+
background: var(--fb-slide-card-bg);
|
|
4
|
+
box-shadow: var(--fb-slide-card-shadow);
|
|
5
|
+
border-radius: var(--fb-slide-card-radius);
|
|
6
|
+
min-height: var(--fb-slide-card-min-height);
|
|
7
|
+
padding: var(--fb-slide-card-padding);
|
|
8
|
+
}
|
|
9
|
+
[data-fb-label-row] > label {
|
|
10
|
+
font-size: var(--fb-label-section-font-size);
|
|
11
|
+
letter-spacing: var(--fb-label-section-letter-spacing);
|
|
12
|
+
text-transform: var(--fb-label-section-text-transform);
|
|
13
|
+
}
|
|
14
|
+
/* Per-item remove (trash) button used by multi-container items. Shares the
|
|
15
|
+
same faint-on-rest, error-on-hover palette as .fb-chip-remove. */
|
|
16
|
+
.fb-item-remove {
|
|
17
|
+
color: var(--fb-text-faint-color, #94a3b8);
|
|
18
|
+
background-color: transparent;
|
|
19
|
+
transition: color var(--fb-transition-duration), background-color var(--fb-transition-duration);
|
|
20
|
+
}
|
|
21
|
+
.fb-item-remove:hover {
|
|
22
|
+
color: var(--fb-error-color);
|
|
23
|
+
background-color: var(--fb-background-hover-color);
|
|
24
|
+
}
|
|
25
|
+
/* Prefill-suggestion pills rendered by createPrefillHints. Outline pill at rest,
|
|
26
|
+
soft-fill on hover, solid-fill when selected. All colors flow from the active
|
|
27
|
+
theme \u2014 consumers don't need to ship their own CSS. */
|
|
28
|
+
.fb-prefill-hint {
|
|
29
|
+
padding: 0.25rem 0.625rem;
|
|
30
|
+
border: var(--fb-border-width) solid var(--fb-primary-color);
|
|
31
|
+
border-radius: 9999px;
|
|
32
|
+
background: var(--fb-background-color);
|
|
33
|
+
color: var(--fb-primary-color);
|
|
34
|
+
font-size: var(--fb-font-size-small);
|
|
35
|
+
font-weight: var(--fb-font-weight-medium);
|
|
36
|
+
font-family: var(--fb-font-family);
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
transition: background-color var(--fb-transition-duration), border-color var(--fb-transition-duration), color var(--fb-transition-duration);
|
|
39
|
+
}
|
|
40
|
+
.fb-prefill-hint:hover {
|
|
41
|
+
background: var(--fb-primary-soft-color);
|
|
42
|
+
border-color: var(--fb-primary-hover-color);
|
|
43
|
+
color: var(--fb-primary-hover-color);
|
|
44
|
+
}
|
|
45
|
+
.fb-prefill-hint:focus-visible {
|
|
46
|
+
outline: var(--fb-focus-ring-width) solid var(--fb-focus-ring-color);
|
|
47
|
+
outline-offset: 2px;
|
|
48
|
+
}
|
|
49
|
+
.fb-prefill-hint[aria-pressed="true"],
|
|
50
|
+
.fb-prefill-hint.active {
|
|
51
|
+
background: var(--fb-primary-color);
|
|
52
|
+
color: #ffffff;
|
|
53
|
+
border-color: var(--fb-primary-color);
|
|
54
|
+
}
|
|
55
|
+
`,e.head.appendChild(t)}function Et(e){e.style.overflow="hidden",e.style.resize="none";const t=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(1,t);const n=()=>{if(!e.isConnected)return;e.style.height="0";const r=getComputedStyle(e),o=parseFloat(r.borderTopWidth||"0")+parseFloat(r.borderBottomWidth||"0");e.style.height=`${e.scrollHeight+o}px`};e.addEventListener("input",n),setTimeout(()=>{e.isConnected&&n()},0)}function Cr(e){e.addEventListener("keydown",t=>{t.key==="Enter"&&t.preventDefault()}),e.addEventListener("paste",t=>{var n,r,o,i;const a=(r=(n=t.clipboardData)==null?void 0:n.getData("text"))!=null?r:"";if(!/[\r\n]/.test(a))return;t.preventDefault();const l=a.replace(/[\r\n]+/g," "),s=(o=e.selectionStart)!=null?o:e.value.length,c=(i=e.selectionEnd)!=null?i:e.value.length,u=e.value.slice(0,s),d=e.value.slice(c);e.value=u+l+d;const f=s+l.length;e.setSelectionRange(f,f),e.dispatchEvent(new Event("input",{bubbles:!0}))})}function Te(e,t){const n=e.querySelector(":scope > [data-fb-label-row]");n&&n.appendChild(t)}function Fe(e,t,n={}){var r;const o=(r=n.label)!=null?r:"",i=n.showCounter!==!1,a=document.createElement("div");a.className="fb-add-row mt-2",a.style.cssText="display:flex;align-items:stretch;width:100%;";const l=document.createElement("button");l.type="button",l.className=`add-${e}-btn`,l.style.cssText=`
|
|
2
56
|
flex: 1 1 auto;
|
|
3
57
|
display: inline-flex;
|
|
4
58
|
align-items: center;
|
|
@@ -19,7 +73,7 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
19
73
|
font-size: var(--fb-font-size-small, 0.875rem);
|
|
20
74
|
color: var(--fb-text-secondary-color);
|
|
21
75
|
font-weight: 400;
|
|
22
|
-
`,
|
|
76
|
+
`,i||(s.style.display="none"),a.appendChild(l),{row:a,button:l,counter:s,update:(c,u)=>{const d=c>=u;a.style.display=d?"none":"flex",l.style.display=d?"none":"inline-flex",l.disabled=d,i&&(s.textContent=`${c}/${u===1/0?"\u221E":u}`)}}}function Er(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=`
|
|
23
77
|
display: flex;
|
|
24
78
|
flex-direction: column;
|
|
25
79
|
align-items: center;
|
|
@@ -38,7 +92,7 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
38
92
|
font-family: var(--fb-font-family);
|
|
39
93
|
cursor: pointer;
|
|
40
94
|
transition: border-color var(--fb-transition-duration), color var(--fb-transition-duration), background-color var(--fb-transition-duration);
|
|
41
|
-
`;const
|
|
95
|
+
`;const i=document.createElement("span");if(i.className="fb-slide-add-circle",i.style.cssText=`
|
|
42
96
|
display: inline-flex;
|
|
43
97
|
align-items: center;
|
|
44
98
|
justify-content: center;
|
|
@@ -51,12 +105,12 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
51
105
|
line-height: 1;
|
|
52
106
|
color: inherit;
|
|
53
107
|
transition: inherit;
|
|
54
|
-
`,
|
|
108
|
+
`,i.textContent="+",o.appendChild(i),r){const l=document.createElement("span");l.textContent=r,o.appendChild(l)}o.addEventListener("mouseenter",()=>{o.disabled||(o.style.borderStyle="solid",o.style.backgroundColor="var(--fb-background-hover-color)")}),o.addEventListener("mouseleave",()=>{o.style.borderStyle="dashed",o.style.backgroundColor="transparent"}),o.onclick=e;const a=document.createElement("span");return a.className="fb-add-counter",a.style.cssText=`
|
|
55
109
|
margin-left: auto;
|
|
56
110
|
font-size: var(--fb-font-size-small, 0.875rem);
|
|
57
111
|
color: var(--fb-text-secondary-color);
|
|
58
112
|
font-weight: 400;
|
|
59
|
-
`,{tile:o,counter:
|
|
113
|
+
`,{tile:o,counter:a,update:(l,s)=>{const c=l>=s;o.style.display=c?"none":"flex",o.disabled=c,a.textContent=`${l}/${s===1/0?"\u221E":s}`}}}function en(e,t=!1){e.style.cssText=`
|
|
60
114
|
background-color: var(--fb-action-bg-color);
|
|
61
115
|
color: var(--fb-action-text-color);
|
|
62
116
|
border: var(--fb-border-width) solid var(--fb-action-border-color);
|
|
@@ -66,56 +120,139 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
66
120
|
border-radius: var(--fb-border-radius);
|
|
67
121
|
transition: all var(--fb-transition-duration);
|
|
68
122
|
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
69
|
-
`,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
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
123
|
+
`,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 kr(e){if(e.head.querySelector("[data-fb-chip-styles]"))return;const t=e.createElement("style");t.setAttribute("data-fb-chip-styles",""),t.textContent=`
|
|
124
|
+
.fb-chip-list { display: flex; flex-direction: column; gap: 4px; }
|
|
125
|
+
.fb-chip {
|
|
126
|
+
display: flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
gap: 8px;
|
|
129
|
+
padding: 5px 6px 5px 10px;
|
|
130
|
+
background: var(--fb-chip-bg, var(--fb-background-color, #fff));
|
|
131
|
+
border: 1px solid var(--fb-chip-border, var(--fb-border-color, #e2e8f0));
|
|
132
|
+
border-radius: 6px;
|
|
133
|
+
position: relative;
|
|
134
|
+
transition: border-color var(--fb-transition-duration, 0.15s);
|
|
135
|
+
}
|
|
136
|
+
.fb-chip:hover { border-color: var(--fb-border-hover-color, var(--fb-border-color, #cbd5e1)); }
|
|
137
|
+
.fb-chip:focus-within { border-color: var(--fb-border-focus-color, var(--fb-primary-color, #2f5bea)); }
|
|
138
|
+
.fb-chip-dot {
|
|
139
|
+
flex: 0 0 6px;
|
|
140
|
+
width: 6px;
|
|
141
|
+
height: 6px;
|
|
142
|
+
border-radius: 50%;
|
|
143
|
+
background: var(--fb-chip-dot, var(--fb-primary-color, #2f5bea));
|
|
144
|
+
}
|
|
145
|
+
.fb-chip-input {
|
|
146
|
+
flex: 1;
|
|
147
|
+
min-width: 0;
|
|
148
|
+
padding: 2px 0;
|
|
149
|
+
border: 0;
|
|
150
|
+
outline: none;
|
|
151
|
+
background: transparent;
|
|
152
|
+
color: var(--fb-chip-text, var(--fb-text-color, inherit));
|
|
153
|
+
font-size: var(--fb-font-size, 14px);
|
|
154
|
+
font-family: var(--fb-font-family, inherit);
|
|
155
|
+
line-height: 1.4;
|
|
156
|
+
}
|
|
157
|
+
.fb-chip-input::placeholder { color: var(--fb-text-placeholder-color, #94a3b8); }
|
|
158
|
+
.fb-chip-input:read-only { color: var(--fb-text-secondary-color, #475569); }
|
|
159
|
+
.fb-chip-remove {
|
|
160
|
+
flex: 0 0 auto;
|
|
161
|
+
width: 22px;
|
|
162
|
+
height: 22px;
|
|
163
|
+
display: inline-flex;
|
|
164
|
+
align-items: center;
|
|
165
|
+
justify-content: center;
|
|
166
|
+
padding: 0;
|
|
167
|
+
border: 0;
|
|
168
|
+
border-radius: 4px;
|
|
169
|
+
background: transparent;
|
|
170
|
+
color: var(--fb-text-faint-color, #94a3b8);
|
|
171
|
+
cursor: pointer;
|
|
172
|
+
opacity: 0;
|
|
173
|
+
transition: opacity 0.12s, color 0.12s, background-color 0.12s;
|
|
174
|
+
}
|
|
175
|
+
.fb-chip:hover .fb-chip-remove,
|
|
176
|
+
.fb-chip-remove:focus-visible { opacity: 1; }
|
|
177
|
+
.fb-chip-remove:hover {
|
|
178
|
+
color: var(--fb-error-color, #dc2626);
|
|
179
|
+
background: var(--fb-background-hover-color, #f1f5f9);
|
|
180
|
+
}
|
|
181
|
+
.fb-chip-remove:disabled { opacity: 0 !important; pointer-events: none; }
|
|
182
|
+
`,e.head.appendChild(t)}function rt(e,t){const n=document.createElement("span");n.className="char-counter",n.style.cssText=`
|
|
183
|
+
margin-top: 4px;
|
|
184
|
+
padding-right: 12px;
|
|
185
|
+
text-align: right;
|
|
73
186
|
font-size: var(--fb-font-size-small);
|
|
74
|
-
|
|
187
|
+
line-height: 1;
|
|
188
|
+
color: var(--fb-error-color);
|
|
75
189
|
pointer-events: none;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
`;const o=()=>{const a=t.value.length,i=e.minLength,l=e.maxLength;if(i==null&&l==null){r.textContent="";return}a===0||i!=null&&a<i?(i!=null&&l!=null?r.textContent=`${i}-${l}`:l!=null?r.textContent=`\u2264${l}`:i!=null&&(r.textContent=`\u2265${i}`),r.style.color="var(--fb-text-secondary-color)"):l!=null&&a>l?(r.textContent=`${a}/${l}`,r.style.color="var(--fb-error-color)"):(l!=null?r.textContent=`${a}/${l}`:r.textContent=`${a}`,r.style.color="var(--fb-text-secondary-color)")};return t.addEventListener("input",o),o(),r}function vr(e,t,n,r){const o=t.state,a=oe(e,o,t),i=document.createElement("div");i.style.cssText="position: relative;";const l=!a&&(e.minLength!=null||e.maxLength!=null),s=document.createElement("input");if(s.type="text",s.className="w-full rounded-lg",s.style.cssText=`
|
|
190
|
+
display: none;
|
|
191
|
+
`;const r=()=>{const o=t.value.length,i=e.maxLength;i!=null&&o>i?(n.textContent=`${o}/${i}`,n.style.display="block"):(n.textContent="",n.style.display="none")};return t.addEventListener("input",r),r(),n}function $r(e,t,n,r){const o=t.state,i=ae(e,o,t),a=document.createElement("div");a.style.cssText="position: relative;";const l=!i&&(e.minLength!=null||e.maxLength!=null),s=document.createElement("textarea");if(s.rows=1,s.className="w-full rounded-lg",s.style.cssText=`
|
|
79
192
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
80
|
-
${l?"padding-right: 60px;":""}
|
|
81
193
|
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
82
194
|
border-radius: var(--fb-border-radius);
|
|
83
|
-
background-color: ${
|
|
195
|
+
background-color: ${i?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
|
|
84
196
|
color: var(--fb-text-color);
|
|
85
197
|
font-size: var(--fb-font-size);
|
|
86
198
|
font-family: var(--fb-font-family);
|
|
199
|
+
line-height: var(--fb-line-height, 1.5);
|
|
87
200
|
transition: all var(--fb-transition-duration) ease-in-out;
|
|
88
201
|
width: 100%;
|
|
89
202
|
box-sizing: border-box;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
background-color: ${l?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
|
|
96
|
-
color: var(--fb-text-color);
|
|
97
|
-
font-size: var(--fb-font-size);
|
|
98
|
-
font-family: var(--fb-font-family);
|
|
99
|
-
transition: all var(--fb-transition-duration) ease-in-out;
|
|
100
|
-
width: 100%;
|
|
101
|
-
box-sizing: border-box;
|
|
102
|
-
`,y.placeholder=e.placeholder||k("placeholderText",i),y.value=x,y.readOnly=l,l||(y.addEventListener("focus",()=>{y.style.borderColor="var(--fb-border-focus-color)",y.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",y.style.outlineOffset="0"}),y.addEventListener("blur",()=>{y.style.borderColor="var(--fb-border-color)",y.style.outline="none"}),y.addEventListener("mouseenter",()=>{document.activeElement!==y&&(y.style.borderColor="var(--fb-border-hover-color)")}),y.addEventListener("mouseleave",()=>{document.activeElement!==y&&(y.style.borderColor="var(--fb-border-color)")})),!l&&t.instance){const L=()=>{const R=y.value===""?null:y.value;t.instance.triggerOnChange(y.name,R)};y.addEventListener("blur",L),y.addEventListener("input",L)}if(C.appendChild(y),d){const L=Ve(e,y,!1);C.appendChild(L)}return w.appendChild(C),v===-1?f.appendChild(w):f.insertBefore(w,f.children[v]),m(),w}function g(){if(l)return;const x=f.querySelectorAll(".multiple-text-item"),v=x.length;x.forEach(w=>{let C=w.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn px-2 py-1 rounded",C.style.cssText=`
|
|
103
|
-
color: var(--fb-error-color);
|
|
104
|
-
background-color: transparent;
|
|
105
|
-
transition: background-color var(--fb-transition-duration);
|
|
106
|
-
`,C.innerHTML="\u2715",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{const L=Array.from(f.children).indexOf(w);f.children.length>c&&(u.splice(L,1),w.remove(),m(),h(),g())},w.appendChild(C));const y=v<=c;C.disabled=y,C.style.opacity=y?"0.5":"1",C.style.pointerEvents=y?"none":"auto"})}let E=null;if(!l){const x=Te("text",()=>{u.push(e.default||""),b(e.default||""),h(),g()},{label:e.addLabel});E=x.update,Le(n,x.counter),n.appendChild(x.row)}function h(){E&&E(u.length,p)}u.forEach(x=>b(x)),h(),g()}function _t(e,t,n){var r,o,a;const i=[],{scopeRoot:l,skipValidation:s}=n,u=(c,p)=>{var f,m;if(!c)return;const b=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(b);p?(c.classList.add("invalid"),c.title=p,g||(g=document.createElement("div"),g.id=b,g.className="error-message",g.style.cssText=`
|
|
203
|
+
resize: none;
|
|
204
|
+
overflow: hidden;
|
|
205
|
+
word-break: break-word;
|
|
206
|
+
overflow-wrap: anywhere;
|
|
207
|
+
`,s.name=r,s.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",s.value=t.prefill[e.key]||e.default||"",s.readOnly=i,Cr(s),Et(s),i||(s.addEventListener("focus",()=>{s.style.borderColor="var(--fb-border-focus-color)",s.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",s.style.outlineOffset="0"}),s.addEventListener("blur",()=>{s.style.borderColor="var(--fb-border-color)",s.style.outline="none"}),s.addEventListener("mouseenter",()=>{document.activeElement!==s&&(s.style.borderColor="var(--fb-border-hover-color)")}),s.addEventListener("mouseleave",()=>{document.activeElement!==s&&(s.style.borderColor="var(--fb-border-color)")})),!i&&t.instance){const c=()=>{const u=s.value===""?null:s.value;t.instance.triggerOnChange(r,u)};s.addEventListener("blur",c),s.addEventListener("input",c)}if(a.appendChild(s),l){const c=rt(e,s);a.appendChild(c)}n.appendChild(a)}function Sr(e,t,n,r){var o,i;const a=t.state,l=ae(e,a,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],u=(o=e.minCount)!=null?o:1,d=(i=e.maxCount)!=null?i:1/0;for(;c.length<u;)c.push(e.default||"");kr(document);const f=document.createElement("div");f.className="fb-chip-list",n.appendChild(f);function p(){f.querySelectorAll(".fb-chip-input").forEach((h,y)=>{h.name=`${r}[${y}]`;const g=h.closest(".fb-chip"),C=g==null?void 0:g.nextElementSibling;C&&C.classList.contains("error-message")&&(C.id=`error-${h.name}`)})}function m(h=""){const y=document.createElement("div");y.className="fb-chip";const g=document.createElement("span");g.className="fb-chip-dot",g.setAttribute("aria-hidden","true"),y.appendChild(g);const C=document.createElement("input");if(C.type="text",C.className="fb-chip-input",C.value=h,C.placeholder=e.placeholder||k("placeholderText",a),C.readOnly=l,y.appendChild(C),!l&&t.instance){const E=()=>{t.instance.triggerOnChange(C.name,C.value===""?null:C.value)};C.addEventListener("blur",E),C.addEventListener("input",E)}if(!l){const E=document.createElement("button");E.type="button",E.className="fb-chip-remove",E.setAttribute("aria-label",k("removeElement",a)),E.innerHTML=Qt,E.onclick=()=>{const x=f.querySelectorAll(".fb-chip"),$=Array.prototype.indexOf.call(x,y);if($<0||x.length<=u)return;c.splice($,1);const z=y.nextElementSibling;z&&z.classList.contains("error-message")&&z.remove(),y.remove(),p(),w(),b()},y.appendChild(E)}return f.appendChild(y),p(),y}function b(){if(l)return;const h=f.querySelectorAll(".fb-chip").length<=u;f.querySelectorAll(".fb-chip-remove").forEach(y=>{y.disabled=h})}let v=null;if(!l){const h=Fe("text",()=>{c.push(e.default||""),m(e.default||""),w(),b()},{label:e.addLabel});v=h.update,Te(n,h.counter),n.appendChild(h.row)}function w(){v&&v(c.length,d)}c.forEach(h=>m(h)),w(),b()}function tn(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:s}=n,c=(d,f)=>{var p,m,b;if(!d)return;const v=`error-${d.getAttribute("name")||Math.random().toString(36).substring(7)}`;let w=document.getElementById(v);if(f){if(d.classList.add("invalid"),d.title=f,!w){w=document.createElement("div"),w.id=v,w.className="error-message",w.style.cssText=`
|
|
107
208
|
color: var(--fb-error-color);
|
|
108
209
|
font-size: var(--fb-font-size-small);
|
|
109
210
|
margin-top: 0.25rem;
|
|
110
|
-
|
|
211
|
+
`;const h=((p=d.closest)==null?void 0:p.call(d,".fb-chip"))||d;h.nextSibling?(m=h.parentNode)==null||m.insertBefore(w,h.nextSibling):(b=h.parentNode)==null||b.appendChild(w)}w.textContent=f,w.style.display="block"}else d.classList.remove("invalid"),d.title="",w&&w.remove()},u=(d,f,p)=>{let m=!1;const{state:b}=n;if(!s&&f){if(e.minLength!==void 0&&e.minLength!==null&&f.length<e.minLength){const v=k("minLength",b,{min:e.minLength});a.push(`${p}: ${v}`),c(d,v),m=!0}else if(e.maxLength!==void 0&&e.maxLength!==null&&f.length>e.maxLength){const v=k("maxLength",b,{max:e.maxLength});a.push(`${p}: ${v}`),c(d,v),m=!0}else if(e.pattern)try{if(!new RegExp(e.pattern).test(f)){const v=k("patternMismatch",b);a.push(`${p}: ${v}`),c(d,v),m=!0}}catch(v){const w=k("invalidPattern",b);a.push(`${p}: ${w}`),c(d,w),m=!0}}m||c(d,null)};if(e.multiple){const d=l.querySelectorAll(`[name^="${t}\\["]`),f=[],p=[];if(d.forEach((m,b)=>{var v;const w=(v=m==null?void 0:m.value)!=null?v:"";p.push(w),f.push(w===""?null:w),u(m,w,`${t}[${b}]`)}),!s){const{state:m}=n,b=(r=e.minCount)!=null?r:1,v=(o=e.maxCount)!=null?o:1/0,w=p.filter(h=>h.trim()!=="");e.required&&w.length===0&&a.push(`${t}: ${k("required",m)}`),w.length<b&&a.push(`${t}: ${k("minItems",m,{min:b})}`),w.length>v&&a.push(`${t}: ${k("maxItems",m,{max:v})}`)}return{value:f,errors:a}}else{const d=l.querySelector(`[name$="${t}"]`),f=(i=d==null?void 0:d.value)!=null?i:"";if(!s&&e.required&&f===""){const p=k("required",n.state);return a.push(`${t}: ${p}`),c(d,p),{value:null,errors:a}}return d&&u(d,f,t),{value:f===""?null:f,errors:a}}}function nn(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateTextField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["]`);i.forEach((a,l)=>{l<n.length&&(a.value=n[l]!=null?String(n[l]):"",a.classList.remove("invalid"),a.title="",xe(a),a.dispatchEvent(new Event("input",{bubbles:!0})))}),n.length!==i.length&&console.warn(`updateTextField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.classList.remove("invalid"),i.title="",xe(i),i instanceof HTMLTextAreaElement&&i.dispatchEvent(new Event("input",{bubbles:!0})))}}function Lr(e,t,n,r){const o=t.state,i=ae(e,o,t),a=document.createElement("div");a.style.cssText="position: relative;";const l=document.createElement("textarea");if(l.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",l.style.cssText=`
|
|
111
212
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x) 24px var(--fb-input-padding-x);
|
|
112
213
|
font-size: var(--fb-font-size);
|
|
113
214
|
font-family: var(--fb-font-family);
|
|
114
|
-
`,l.name=r,l.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",l.rows=e.rows||4,l.value=t.prefill[e.key]||e.default||"",l.readOnly=
|
|
215
|
+
`,l.name=r,l.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",l.rows=e.rows||4,l.value=t.prefill[e.key]||e.default||"",l.readOnly=i,!i&&t.instance){const s=()=>{const c=l.value===""?null:l.value;t.instance.triggerOnChange(r,c)};l.addEventListener("blur",s),l.addEventListener("input",s)}if((e.autoExpand||i)&&Et(l),a.appendChild(l),!i&&(e.minLength!=null||e.maxLength!=null)){const s=rt(e,l);a.appendChild(s)}n.appendChild(a)}function Tr(e,t,n,r){var o,i;const a=t.state,l=ae(e,a,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],u=(o=e.minCount)!=null?o:1,d=(i=e.maxCount)!=null?i:1/0;for(;c.length<u;)c.push(e.default||"");const f=document.createElement("div");f.className="space-y-2",n.appendChild(f);function p(){f.querySelectorAll(".multiple-textarea-item").forEach((h,y)=>{const g=h.querySelector("textarea");g&&(g.name=`${r}[${y}]`)})}function m(h="",y=-1){const g=document.createElement("div");g.className="multiple-textarea-item";const C=document.createElement("div");C.style.cssText="position: relative;";const E=document.createElement("textarea");if(E.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",E.style.cssText=`
|
|
115
216
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x) 24px var(--fb-input-padding-x);
|
|
116
217
|
font-size: var(--fb-font-size);
|
|
117
218
|
font-family: var(--fb-font-family);
|
|
118
|
-
`,
|
|
219
|
+
`,E.placeholder=e.placeholder||k("placeholderText",a),E.rows=e.rows||4,E.value=h,E.readOnly=l,!l&&t.instance){const x=()=>{const $=E.value===""?null:E.value;t.instance.triggerOnChange(E.name,$)};E.addEventListener("blur",x),E.addEventListener("input",x)}if((e.autoExpand||l)&&Et(E),C.appendChild(E),!l&&(e.minLength!=null||e.maxLength!=null)){const x=rt(e,E);C.appendChild(x)}return g.appendChild(C),y===-1?f.appendChild(g):f.insertBefore(g,f.children[y]),p(),g}function b(){if(l)return;const h=f.querySelectorAll(".multiple-textarea-item"),y=h.length;h.forEach(g=>{let C=g.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn mt-1 px-2 py-1 text-red-600 hover:bg-red-50 rounded text-sm",C.innerHTML="\u2715",C.onclick=()=>{const x=Array.from(f.children).indexOf(g);f.children.length>u&&(c.splice(x,1),g.remove(),p(),w(),b())},g.appendChild(C));const E=y<=u;C.disabled=E,C.style.opacity=E?"0.5":"1",C.style.pointerEvents=E?"none":"auto"})}let v=null;if(!l){const h=Fe("textarea",()=>{c.push(e.default||""),m(e.default||""),w(),b()},{label:e.addLabel});v=h.update,Te(n,h.counter),n.appendChild(h.row)}function w(){v&&v(c.length,d)}c.forEach(h=>m(h)),w(),b()}function Ar(e,t,n){return tn(e,t,n)}function Fr(e,t,n,r){nn(e,t,n,r);const{scopeRoot:o,state:i}=r;if(e.autoExpand||ae(e,i))if(e.multiple)o.querySelectorAll(`textarea[name^="${t}["]`).forEach(a=>{a.dispatchEvent(new Event("input"))});else{const a=o.querySelector(`textarea[name="${t}"]`);a&&a.dispatchEvent(new Event("input"))}}function Mr(e){const t="fb-number-stepper-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
|
|
220
|
+
.fb-stepper-input::-webkit-outer-spin-button,
|
|
221
|
+
.fb-stepper-input::-webkit-inner-spin-button {
|
|
222
|
+
-webkit-appearance: none;
|
|
223
|
+
margin: 0;
|
|
224
|
+
}
|
|
225
|
+
.fb-stepper-input { -moz-appearance: textfield; }
|
|
226
|
+
`,e.head.appendChild(n)}function zr(e,t,n){var r;Mr(e.ownerDocument);const o=(r=t.step)!=null?r:1,i=t.min,a=t.max,l=document.createElement("div");l.className="fb-stepper",l.style.cssText=`
|
|
227
|
+
display: inline-flex;
|
|
228
|
+
align-items: stretch;
|
|
229
|
+
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
230
|
+
border-radius: var(--fb-border-radius);
|
|
231
|
+
overflow: hidden;
|
|
232
|
+
background: var(--fb-background-color);
|
|
233
|
+
`;const s=(c,u)=>{const d=document.createElement("button");return d.type="button",d.textContent=c,d.tabIndex=-1,d.style.cssText=`
|
|
234
|
+
width: 32px;
|
|
235
|
+
border: none;
|
|
236
|
+
background: transparent;
|
|
237
|
+
color: var(--fb-text-color);
|
|
238
|
+
font-size: var(--fb-font-size);
|
|
239
|
+
font-family: var(--fb-font-family);
|
|
240
|
+
cursor: ${n?"default":"pointer"};
|
|
241
|
+
user-select: none;
|
|
242
|
+
`,n?(d.disabled=!0,d.style.opacity="0.5"):d.addEventListener("click",f=>{var p;f.preventDefault();const m=parseFloat(e.value),b=Number.isFinite(m)?m:(p=i!=null?i:t.default)!=null?p:0;let v=parseFloat((b+u*o).toPrecision(12));i!=null&&(v=Math.max(i,v)),a!=null&&(v=Math.min(a,v)),e.value=String(v),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}),d};return e.classList.add("fb-stepper-input"),e.style.cssText=`
|
|
243
|
+
width: 56px;
|
|
244
|
+
border: none;
|
|
245
|
+
border-left: var(--fb-border-width) solid var(--fb-border-color);
|
|
246
|
+
border-right: var(--fb-border-width) solid var(--fb-border-color);
|
|
247
|
+
padding: var(--fb-input-padding-y) 0;
|
|
248
|
+
font-size: var(--fb-font-size);
|
|
249
|
+
font-family: var(--fb-font-family);
|
|
250
|
+
text-align: center;
|
|
251
|
+
background: transparent;
|
|
252
|
+
color: var(--fb-text-color);
|
|
253
|
+
-moz-appearance: textfield;
|
|
254
|
+
box-sizing: border-box;
|
|
255
|
+
`,l.appendChild(s("\u2212",-1)),l.appendChild(e),l.appendChild(s("+",1)),l}function rn(e,t){const n=document.createElement("span");n.className="number-range-hint",n.style.cssText=`
|
|
119
256
|
position: absolute;
|
|
120
257
|
top: 50%;
|
|
121
258
|
transform: translateY(-50%);
|
|
@@ -125,57 +262,167 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
125
262
|
pointer-events: none;
|
|
126
263
|
background: var(--fb-background-color);
|
|
127
264
|
padding: 0 4px;
|
|
128
|
-
`;const r=e.min,o=e.max;let
|
|
129
|
-
padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
130
|
-
font-size: var(--fb-font-size);
|
|
131
|
-
font-family: var(--fb-font-family);
|
|
132
|
-
width: 100%;
|
|
133
|
-
box-sizing: border-box;
|
|
134
|
-
`,l.name=r,l.placeholder=e.placeholder||"0",e.min!==void 0&&(l.min=e.min.toString()),e.max!==void 0&&(l.max=e.max.toString()),e.step!==void 0&&(l.step=e.step.toString()),l.value=t.prefill[e.key]||e.default||"",l.readOnly=a,!a&&t.instance){const s=()=>{const u=l.value?parseFloat(l.value):null;t.instance.triggerOnChange(r,u)};l.addEventListener("blur",s),l.addEventListener("input",s)}if(i.appendChild(l),!a&&(e.min!=null||e.max!=null)){const s=Yt(e,l);i.appendChild(s)}n.appendChild(i)}function kr(e,t,n,r){var o,a;const i=t.state,l=oe(e,i,t),s=t.prefill[e.key]||[],u=Array.isArray(s)?[...s]:[],d=(o=e.minCount)!=null?o:1,c=(a=e.maxCount)!=null?a:1/0;for(;u.length<d;)u.push(e.default||"");const p=document.createElement("div");p.className="space-y-2",n.appendChild(p);function f(){p.querySelectorAll(".multiple-number-item").forEach((h,x)=>{const v=h.querySelector("input");v&&(v.name=`${r}[${x}]`)})}function m(h="",x=-1){const v=document.createElement("div");v.className="multiple-number-item flex items-center gap-2";const w=document.createElement("div");w.style.cssText="position: relative; flex: 1;";const C=document.createElement("input");if(C.type="number",C.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",C.style.cssText=`
|
|
265
|
+
`;const r=e.min,o=e.max;let i="";r!=null&&o!=null?i=`${r} \u2013 ${o}`:o!=null?i=`\u2264${o}`:r!=null&&(i=`\u2265${r}`),n.textContent=i;const a=()=>{const l=t.value?parseFloat(t.value):null;if(l!=null){const s=r!=null&&l<r,c=o!=null&&l>o;n.style.color=s||c?"var(--fb-error-color)":"var(--fb-text-secondary-color)"}else n.style.color="var(--fb-text-secondary-color)"};return t.addEventListener("input",a),a(),n}function Nr(e,t,n,r){const o=t.state,i=ae(e,o,t),a=document.createElement("div");a.style.cssText="position: relative;";const l=document.createElement("input");if(l.type="number",l.name=r,l.placeholder=e.placeholder||"0",e.min!==void 0&&(l.min=e.min.toString()),e.max!==void 0&&(l.max=e.max.toString()),e.step!==void 0&&(l.step=e.step.toString()),l.value=t.prefill[e.key]||e.default||"",l.readOnly=i,e.stepper||(l.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",l.style.cssText=`
|
|
135
266
|
padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
136
267
|
font-size: var(--fb-font-size);
|
|
137
268
|
font-family: var(--fb-font-family);
|
|
138
269
|
width: 100%;
|
|
139
270
|
box-sizing: border-box;
|
|
140
|
-
|
|
271
|
+
`),!i&&t.instance){const s=()=>{const c=l.value?parseFloat(l.value):null;t.instance.triggerOnChange(r,c)};l.addEventListener("blur",s),l.addEventListener("input",s)}if(e.stepper)a.appendChild(zr(l,e,i));else if(a.appendChild(l),!i&&(e.min!=null||e.max!=null)){const s=rn(e,l);a.appendChild(s)}n.appendChild(a)}function Ir(e,t,n,r){var o,i;const a=t.state,l=ae(e,a,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],u=(o=e.minCount)!=null?o:1,d=(i=e.maxCount)!=null?i:1/0;for(;c.length<u;)c.push(e.default||"");const f=document.createElement("div");f.className="space-y-2",n.appendChild(f);function p(){f.querySelectorAll(".multiple-number-item").forEach((h,y)=>{const g=h.querySelector("input");g&&(g.name=`${r}[${y}]`)})}function m(h="",y=-1){const g=document.createElement("div");g.className="multiple-number-item flex items-center gap-2";const C=document.createElement("div");C.style.cssText="position: relative; flex: 1;";const E=document.createElement("input");if(E.type="number",E.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",E.style.cssText=`
|
|
272
|
+
padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
273
|
+
font-size: var(--fb-font-size);
|
|
274
|
+
font-family: var(--fb-font-family);
|
|
275
|
+
width: 100%;
|
|
276
|
+
box-sizing: border-box;
|
|
277
|
+
`,E.placeholder=e.placeholder||"0",e.min!==void 0&&(E.min=e.min.toString()),e.max!==void 0&&(E.max=e.max.toString()),e.step!==void 0&&(E.step=e.step.toString()),E.value=h.toString(),E.readOnly=l,!l&&t.instance){const x=()=>{const $=E.value?parseFloat(E.value):null;t.instance.triggerOnChange(E.name,$)};E.addEventListener("blur",x),E.addEventListener("input",x)}if(C.appendChild(E),!l&&(e.min!=null||e.max!=null)){const x=rn(e,E);C.appendChild(x)}return g.appendChild(C),y===-1?f.appendChild(g):f.insertBefore(g,f.children[y]),p(),g}function b(){if(l)return;const h=f.querySelectorAll(".multiple-number-item"),y=h.length;h.forEach(g=>{let C=g.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",C.innerHTML="\u2715",C.onclick=()=>{const x=Array.from(f.children).indexOf(g);f.children.length>u&&(c.splice(x,1),g.remove(),p(),w(),b())},g.appendChild(C));const E=y<=u;C.disabled=E,C.style.opacity=E?"0.5":"1",C.style.pointerEvents=E?"none":"auto"})}let v=null;if(!l){const h=Fe("number",()=>{c.push(e.default||""),m(e.default||""),w(),b()},{label:e.addLabel});v=h.update,Te(n,h.counter),n.appendChild(h.row)}function w(){v&&v(c.length,d)}c.forEach(h=>m(h)),w(),b()}function qr(e,t,n){var r,o,i,a,l;const s=[],{scopeRoot:c,skipValidation:u}=n,d=(p,m)=>{var b,v;if(!p)return;const w=`error-${p.getAttribute("name")||Math.random().toString(36).substring(7)}`;let h=document.getElementById(w);m?(p.classList.add("invalid"),p.title=m,h||(h=document.createElement("div"),h.id=w,h.className="error-message",h.style.cssText=`
|
|
141
278
|
color: var(--fb-error-color);
|
|
142
279
|
font-size: var(--fb-font-size-small);
|
|
143
280
|
margin-top: 0.25rem;
|
|
144
|
-
`,
|
|
281
|
+
`,p.nextSibling?(b=p.parentNode)==null||b.insertBefore(h,p.nextSibling):(v=p.parentNode)==null||v.appendChild(h)),h.textContent=m,h.style.display="block"):(p.classList.remove("invalid"),p.title="",h&&h.remove())},f=(p,m,b)=>{let v=!1;const{state:w}=n;if(!u&&e.min!==void 0&&e.min!==null&&m<e.min){const h=k("minValue",w,{min:e.min});s.push(`${b}: ${h}`),d(p,h),v=!0}else if(!u&&e.max!==void 0&&e.max!==null&&m>e.max){const h=k("maxValue",w,{max:e.max});s.push(`${b}: ${h}`),d(p,h),v=!0}v||d(p,null)};if(e.multiple){const p=c.querySelectorAll(`[name^="${t}["]`),m=[];if(p.forEach((b,v)=>{var w,h,y;const g=(w=b==null?void 0:b.value)!=null?w:"";if(g===""){m.push(null),d(b,null);return}const C=parseFloat(g);if(!u&&!Number.isFinite(C)){const x=k("notANumber",n.state);s.push(`${t}[${v}]: ${x}`),d(b,x),m.push(null);return}f(b,C,`${t}[${v}]`);const E=Number.isInteger((h=e.decimals)!=null?h:0)&&(y=e.decimals)!=null?y:0;m.push(Number(C.toFixed(E)))}),!u){const{state:b}=n,v=(r=e.minCount)!=null?r:1,w=(o=e.maxCount)!=null?o:1/0,h=m.filter(y=>y!==null);e.required&&h.length===0&&s.push(`${t}: ${k("required",b)}`),h.length<v&&s.push(`${t}: ${k("minItems",b,{min:v})}`),h.length>w&&s.push(`${t}: ${k("maxItems",b,{max:w})}`)}return{value:m,errors:s}}else{const p=c.querySelector(`[name$="${t}"]`),m=(i=p==null?void 0:p.value)!=null?i:"",{state:b}=n;if(!u&&e.required&&m===""){const h=k("required",b);return s.push(`${t}: ${h}`),d(p,h),{value:null,errors:s}}if(m==="")return d(p,null),{value:null,errors:s};const v=parseFloat(m);if(!u&&!Number.isFinite(v)){const h=k("notANumber",b);return s.push(`${t}: ${h}`),d(p,h),{value:null,errors:s}}f(p,v,t);const w=Number.isInteger((a=e.decimals)!=null?a:0)&&(l=e.decimals)!=null?l:0;return{value:Number(v.toFixed(w)),errors:s}}}function Rr(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateNumberField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["]`);i.forEach((a,l)=>{l<n.length&&(a.value=n[l]!=null?String(n[l]):"",a.classList.remove("invalid"),a.title="",xe(a))}),n.length!==i.length&&console.warn(`updateNumberField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.classList.remove("invalid"),i.title="",xe(i))}}function Br(e,t,n,r){const o=t.state,i=ae(e,o,t),a=document.createElement("select");if(a.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",a.style.cssText=`
|
|
145
282
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
146
283
|
font-size: var(--fb-font-size);
|
|
147
284
|
font-family: var(--fb-font-family);
|
|
148
|
-
`,
|
|
285
|
+
`,a.name=r,a.disabled=i,(e.options||[]).forEach(l=>{const s=document.createElement("option");s.value=l.value,s.textContent=l.label,(t.prefill[e.key]||e.default)===l.value&&(s.selected=!0),a.appendChild(s)}),!i&&t.instance){const l=()=>{t.instance.triggerOnChange(r,a.value)};a.addEventListener("change",l)}if(n.appendChild(a),!i){const l=document.createElement("p");l.className="text-xs text-gray-500 mt-1",l.textContent=Le(e,o),n.appendChild(l)}}function Hr(e,t,n,r){var o,i,a,l;const s=t.state,c=ae(e,s,t),u=t.prefill[e.key]||[],d=Array.isArray(u)?[...u]:[],f=(o=e.minCount)!=null?o:1,p=(i=e.maxCount)!=null?i:1/0;for(;d.length<f;)d.push(e.default||((l=(a=e.options)==null?void 0:a[0])==null?void 0:l.value)||"");const m=document.createElement("div");m.className="space-y-2",n.appendChild(m);function b(){m.querySelectorAll(".multiple-select-item").forEach((g,C)=>{const E=g.querySelector("select");E&&(E.name=`${r}[${C}]`)})}function v(g="",C=-1){const E=document.createElement("div");E.className="multiple-select-item flex items-center gap-2";const x=document.createElement("select");if(x.className="flex-1 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",x.style.cssText=`
|
|
149
286
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
150
287
|
font-size: var(--fb-font-size);
|
|
151
288
|
font-family: var(--fb-font-family);
|
|
152
|
-
`,
|
|
289
|
+
`,x.disabled=c,(e.options||[]).forEach($=>{const z=document.createElement("option");z.value=$.value,z.textContent=$.label,g===$.value&&(z.selected=!0),x.appendChild(z)}),!c&&t.instance){const $=()=>{t.instance.triggerOnChange(x.name,x.value)};x.addEventListener("change",$)}return E.appendChild(x),C===-1?m.appendChild(E):m.insertBefore(E,m.children[C]),b(),E}function w(){if(c)return;const g=m.querySelectorAll(".multiple-select-item"),C=g.length;g.forEach(E=>{let x=E.querySelector(".remove-item-btn");x||(x=document.createElement("button"),x.type="button",x.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",x.innerHTML="\u2715",x.onclick=()=>{const z=Array.from(m.children).indexOf(E);m.children.length>f&&(d.splice(z,1),E.remove(),b(),y(),w())},E.appendChild(x));const $=C<=f;x.disabled=$,x.style.opacity=$?"0.5":"1",x.style.pointerEvents=$?"none":"auto"})}let h=null;if(!c){const g=Fe("select",()=>{var C,E;const x=e.default||((E=(C=e.options)==null?void 0:C[0])==null?void 0:E.value)||"";d.push(x),v(x),y(),w()},{label:e.addLabel});h=g.update,Te(n,g.counter),n.appendChild(g.row)}function y(){h&&h(d.length,p)}if(d.forEach(g=>v(g)),y(),w(),!c){const g=document.createElement("p");g.className="text-xs text-gray-500 mt-1",g.textContent=Le(e,s),n.appendChild(g)}}function Dr(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:a}=n,l=(c,u)=>{var d,f;if(!c)return;const p=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let m=document.getElementById(p);u?(c.classList.add("invalid"),c.title=u,m||(m=document.createElement("div"),m.id=p,m.className="error-message",m.style.cssText=`
|
|
153
290
|
color: var(--fb-error-color);
|
|
154
291
|
font-size: var(--fb-font-size-small);
|
|
155
292
|
margin-top: 0.25rem;
|
|
156
|
-
`,
|
|
293
|
+
`,c.nextSibling?(d=c.parentNode)==null||d.insertBefore(m,c.nextSibling):(f=c.parentNode)==null||f.appendChild(m)),m.textContent=u,m.style.display="block"):(c.classList.remove("invalid"),c.title="",m&&m.remove())},s=(c,u,d,f)=>{var p,m;if(a)return;const{state:b}=n,v=u.filter(f),w="minCount"in d&&(p=d.minCount)!=null?p:1,h="maxCount"in d&&(m=d.maxCount)!=null?m:1/0;d.required&&v.length===0&&o.push(`${c}: ${k("required",b)}`),v.length<w&&o.push(`${c}: ${k("minItems",b,{min:w})}`),v.length>h&&o.push(`${c}: ${k("maxItems",b,{max:h})}`)};if("multiple"in e&&e.multiple){const c=i.querySelectorAll(`[name^="${t}\\["]`),u=[];return c.forEach(d=>{var f;const p=(f=d==null?void 0:d.value)!=null?f:"";u.push(p),l(d,null)}),s(t,u,e,d=>d!==""),{value:u,errors:o}}else{const c=i.querySelector(`[name$="${t}"]`),u=(r=c==null?void 0:c.value)!=null?r:"";if(!a&&e.required&&u===""){const d=k("required",n.state);return o.push(`${t}: ${d}`),l(c,d),{value:null,errors:o}}else l(c,null);return{value:u===""?null:u,errors:o}}}function jr(e,t,n,r){const{scopeRoot:o}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSelectField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["]`);i.forEach((a,l)=>{l<n.length&&(a.value=n[l]!=null?String(n[l]):"",a.querySelectorAll("option").forEach(s=>{s.selected=s.value===String(n[l])}),a.classList.remove("invalid"),a.title="",xe(a))}),n.length!==i.length&&console.warn(`updateSelectField: Multiple field "${t}" has ${i.length} selects but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.querySelectorAll("option").forEach(a=>{a.selected=a.value===String(n)}),i.classList.remove("invalid"),i.title="",xe(i))}}function ot(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 lt(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 on(e){return e.classList.contains("fb-switcher-preset")}function Or(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=`
|
|
157
294
|
display: inline-flex;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
295
|
+
align-items: center;
|
|
296
|
+
gap: 8px;
|
|
297
|
+
padding: 7px 12px 7px 10px;
|
|
298
|
+
border-width: var(--fb-border-width);
|
|
299
|
+
border-style: solid;
|
|
300
|
+
border-radius: 999px;
|
|
301
|
+
background: var(--fb-background-color);
|
|
302
|
+
font-size: var(--fb-font-size);
|
|
303
|
+
font-family: var(--fb-font-family);
|
|
304
|
+
line-height: 1.25;
|
|
305
|
+
cursor: ${t?"default":"pointer"};
|
|
306
|
+
transition: background-color var(--fb-transition-duration), color var(--fb-transition-duration), border-color var(--fb-transition-duration);
|
|
307
|
+
outline: none;
|
|
308
|
+
`,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=`
|
|
309
|
+
display: block;
|
|
310
|
+
flex: 0 0 auto;
|
|
311
|
+
width: 20px;
|
|
312
|
+
height: 20px;
|
|
313
|
+
object-fit: contain;
|
|
314
|
+
`,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=`
|
|
315
|
+
font-size: var(--fb-font-size-small);
|
|
316
|
+
opacity: 0.7;
|
|
317
|
+
font-variant-numeric: tabular-nums;
|
|
318
|
+
`,n.appendChild(o)}return n}function ln(e,t,n,r,o){const i=e.options||[],a=i.some(c=>c.subtitle||c.iconUrl),l=document.createElement("div");l.className="fb-switcher-group",l.style.cssText=a?`
|
|
319
|
+
display: flex;
|
|
320
|
+
flex-direction: row;
|
|
321
|
+
flex-wrap: wrap;
|
|
322
|
+
gap: 6px;
|
|
323
|
+
`:`
|
|
324
|
+
display: inline-flex;
|
|
325
|
+
flex-direction: row;
|
|
326
|
+
flex-wrap: nowrap;
|
|
327
|
+
`;const s=[];return i.forEach((c,u)=>{let d;a?d=Or(c,r):(d=document.createElement("button"),d.type="button",d.className="fb-switcher-btn",d.dataset.value=c.value,d.textContent=c.label,d.style.cssText=`
|
|
328
|
+
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
329
|
+
font-size: var(--fb-font-size);
|
|
330
|
+
border-width: var(--fb-border-width);
|
|
331
|
+
border-style: solid;
|
|
332
|
+
cursor: ${r?"default":"pointer"};
|
|
333
|
+
transition: background-color var(--fb-transition-duration), color var(--fb-transition-duration), border-color var(--fb-transition-duration);
|
|
334
|
+
white-space: nowrap;
|
|
335
|
+
line-height: 1.25;
|
|
336
|
+
outline: none;
|
|
337
|
+
`,i.length===1?d.style.borderRadius="var(--fb-border-radius)":u===0?(d.style.borderRadius="var(--fb-border-radius) 0 0 var(--fb-border-radius)",d.style.borderRightWidth="0"):u===i.length-1?d.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(d.style.borderRadius="0",d.style.borderRightWidth="0")),c.value===t?ot(d,a):lt(d,a),r||(d.addEventListener("click",()=>{n.value=c.value,s.forEach(f=>{f.dataset.value===c.value?ot(f,a):lt(f,a)}),o&&o(c.value)}),d.addEventListener("mouseenter",()=>{n.value!==c.value&&(d.style.backgroundColor="var(--fb-background-hover-color)")}),d.addEventListener("mouseleave",()=>{n.value!==c.value&&(d.style.backgroundColor=a?"var(--fb-background-color)":"transparent")})),s.push(d),l.appendChild(d)}),l}function Ur(e,t,n,r){var o,i;const a=t.state,l=String((i=(o=t.prefill[e.key])!=null?o:e.default)!=null?i:""),s=document.createElement("input");s.type="hidden",s.name=r,s.value=l;const c=ae(e,a,t),u=!c&&t.instance?f=>{t.instance.triggerOnChange(r,f)}:null,d=ln(e,l,s,c,u);if(n.appendChild(s),n.appendChild(d),!c){const f=document.createElement("p");f.className="text-xs text-gray-500 mt-1",f.textContent=Le(e,a),n.appendChild(f)}}function Pr(e,t,n,r){var o,i,a,l;const s=t.state,c=t.prefill[e.key]||[],u=Array.isArray(c)?[...c]:[],d=(o=e.minCount)!=null?o:1,f=(i=e.maxCount)!=null?i:1/0;for(;u.length<d;)u.push(e.default||((l=(a=e.options)==null?void 0:a[0])==null?void 0:l.value)||"");const p=ae(e,s,t),m=document.createElement("div");m.className="space-y-2",n.appendChild(m);function b(){m.querySelectorAll(".multiple-switcher-item").forEach((g,C)=>{const E=g.querySelector("input[type=hidden]");E&&(E.name=`${r}[${C}]`)})}function v(g="",C=-1){const E=C===-1?m.children.length:C,x=`${r}[${E}]`,$=document.createElement("div");$.className="multiple-switcher-item flex items-center gap-2";const z=document.createElement("input");z.type="hidden",z.name=x,z.value=g,$.appendChild(z);const q=!p&&t.instance?B=>{t.instance.triggerOnChange(z.name,B)}:null,K=ln(e,g,z,p,q);return $.appendChild(K),C===-1?m.appendChild($):m.insertBefore($,m.children[C]),b(),$}function w(){if(p)return;const g=m.querySelectorAll(".multiple-switcher-item"),C=g.length;g.forEach(E=>{let x=E.querySelector(".remove-item-btn");x||(x=document.createElement("button"),x.type="button",x.className="remove-item-btn px-2 py-1 rounded",x.style.cssText=`
|
|
171
338
|
color: var(--fb-error-color);
|
|
172
339
|
background-color: transparent;
|
|
173
340
|
transition: background-color var(--fb-transition-duration);
|
|
174
|
-
`,
|
|
341
|
+
`,x.innerHTML="\u2715",x.addEventListener("mouseenter",()=>{x.style.backgroundColor="var(--fb-background-hover-color)"}),x.addEventListener("mouseleave",()=>{x.style.backgroundColor="transparent"}),x.onclick=()=>{const z=Array.from(m.children).indexOf(E);m.children.length>d&&(u.splice(z,1),E.remove(),b(),y(),w())},E.appendChild(x));const $=C<=d;x.disabled=$,x.style.opacity=$?"0.5":"1",x.style.pointerEvents=$?"none":"auto"})}let h=null;if(!p){const g=Fe("switcher",()=>{var C,E;const x=e.default||((E=(C=e.options)==null?void 0:C[0])==null?void 0:E.value)||"";u.push(x),v(x),y(),w()},{label:e.addLabel});h=g.update,Te(n,g.counter),n.appendChild(g.row)}function y(){h&&h(u.length,f)}if(u.forEach(g=>v(g)),y(),w(),!p){const g=document.createElement("p");g.className="text-xs text-gray-500 mt-1",g.textContent=Le(e,s),n.appendChild(g)}}function Wr(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:a}=n,l=(u,d)=>{var f,p;if(!u)return;const m=`error-${u.getAttribute("name")||Math.random().toString(36).substring(7)}`;let b=document.getElementById(m);d?(u.classList.add("invalid"),u.title=d,b||(b=document.createElement("div"),b.id=m,b.className="error-message",b.style.cssText=`
|
|
175
342
|
color: var(--fb-error-color);
|
|
176
343
|
font-size: var(--fb-font-size-small);
|
|
177
344
|
margin-top: 0.25rem;
|
|
178
|
-
`,
|
|
345
|
+
`,u.nextSibling?(f=u.parentNode)==null||f.insertBefore(b,u.nextSibling):(p=u.parentNode)==null||p.appendChild(b)),b.textContent=d,b.style.display="block"):(u.classList.remove("invalid"),u.title="",b&&b.remove())},s=(u,d,f,p)=>{var m,b;if(a)return;const{state:v}=n,w=d.filter(p),h="minCount"in f&&(m=f.minCount)!=null?m:1,y="maxCount"in f&&(b=f.maxCount)!=null?b:1/0;f.required&&w.length===0&&o.push(`${u}: ${k("required",v)}`),w.length<h&&o.push(`${u}: ${k("minItems",v,{min:h})}`),w.length>y&&o.push(`${u}: ${k("maxItems",v,{max:y})}`)},c=new Set("options"in e?e.options.map(u=>u.value):[]);if("multiple"in e&&e.multiple){const u=i.querySelectorAll(`input[type="hidden"][name^="${t}\\["]`),d=[];return u.forEach(f=>{var p;const m=(p=f==null?void 0:f.value)!=null?p:"";if(d.push(m),!a&&m!==""&&!c.has(m)){const b=k("invalidOption",n.state);l(f,b),o.push(`${t}: ${b}`)}else l(f,null)}),s(t,d,e,f=>f!==""),{value:d,errors:o}}else{const u=i.querySelector(`input[type="hidden"][name$="${t}"]`),d=(r=u==null?void 0:u.value)!=null?r:"";if(!a&&e.required&&d===""){const f=k("required",n.state);return o.push(`${t}: ${f}`),l(u,f),{value:null,errors:o}}if(!a&&d!==""&&!c.has(d)){const f=k("invalidOption",n.state);return o.push(`${t}: ${f}`),l(u,f),{value:null,errors:o}}return l(u,null),{value:d===""?null:d,errors:o}}}function Vr(e,t,n,r){var o;const{scopeRoot:i}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSwitcherField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=i.querySelectorAll(`input[type="hidden"][name^="${t}\\["]`);a.forEach((l,s)=>{var c;if(s<n.length){const u=n[s]!=null?String(n[s]):"";l.value=u;const d=(c=l.parentElement)==null?void 0:c.querySelector(".fb-switcher-group");d&&d.querySelectorAll(".fb-switcher-btn").forEach(f=>{const p=on(f);f.dataset.value===u?ot(f,p):lt(f,p)}),l.classList.remove("invalid"),l.title="",xe(l)}}),n.length!==a.length&&console.warn(`updateSwitcherField: Multiple field "${t}" has ${a.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=i.querySelector(`input[type="hidden"][name="${t}"]`);if(a){const l=n!=null?String(n):"";a.value=l;const s=(o=a.parentElement)==null?void 0:o.querySelector(".fb-switcher-group");s&&s.querySelectorAll(".fb-switcher-btn").forEach(c=>{const u=on(c);c.dataset.value===l?ot(c,u):lt(c,u)}),a.classList.remove("invalid"),a.title="",xe(a)}}}const an=36,Je=20,De=16;function Kr(e){const t="fb-boolean-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
|
|
346
|
+
.fb-toggle {
|
|
347
|
+
position: relative;
|
|
348
|
+
display: inline-block;
|
|
349
|
+
width: ${an}px;
|
|
350
|
+
height: ${Je}px;
|
|
351
|
+
border-radius: ${Je}px;
|
|
352
|
+
background: var(--fb-border-color);
|
|
353
|
+
transition: background-color var(--fb-transition-duration);
|
|
354
|
+
flex-shrink: 0;
|
|
355
|
+
}
|
|
356
|
+
.fb-toggle::after {
|
|
357
|
+
content: "";
|
|
358
|
+
position: absolute;
|
|
359
|
+
top: ${(Je-De)/2}px;
|
|
360
|
+
left: ${(Je-De)/2}px;
|
|
361
|
+
width: ${De}px;
|
|
362
|
+
height: ${De}px;
|
|
363
|
+
border-radius: 50%;
|
|
364
|
+
background: #ffffff;
|
|
365
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
|
|
366
|
+
transition: transform var(--fb-transition-duration);
|
|
367
|
+
}
|
|
368
|
+
.fb-toggle.fb-on {
|
|
369
|
+
background: var(--fb-primary-color);
|
|
370
|
+
}
|
|
371
|
+
.fb-toggle.fb-on::after {
|
|
372
|
+
transform: translateX(${an-De-(Je-De)}px);
|
|
373
|
+
}
|
|
374
|
+
.fb-toggle-row {
|
|
375
|
+
display: flex;
|
|
376
|
+
align-items: center;
|
|
377
|
+
gap: 12px;
|
|
378
|
+
padding: 12px 14px;
|
|
379
|
+
background: var(--fb-surface-soft-color);
|
|
380
|
+
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
381
|
+
border-radius: var(--fb-border-radius);
|
|
382
|
+
cursor: pointer;
|
|
383
|
+
user-select: none;
|
|
384
|
+
}
|
|
385
|
+
.fb-toggle-row[aria-disabled="true"] {
|
|
386
|
+
cursor: default;
|
|
387
|
+
opacity: 0.7;
|
|
388
|
+
}
|
|
389
|
+
.fb-toggle-row:focus-visible {
|
|
390
|
+
outline: var(--fb-focus-ring-width) solid var(--fb-focus-ring-color);
|
|
391
|
+
outline-offset: var(--fb-focus-ring-offset);
|
|
392
|
+
}
|
|
393
|
+
.fb-toggle-text { flex: 1; min-width: 0; }
|
|
394
|
+
.fb-toggle-title {
|
|
395
|
+
display: flex;
|
|
396
|
+
align-items: center;
|
|
397
|
+
gap: 4px;
|
|
398
|
+
font-size: var(--fb-font-size);
|
|
399
|
+
font-weight: 500;
|
|
400
|
+
color: var(--fb-text-color);
|
|
401
|
+
line-height: 1.3;
|
|
402
|
+
}
|
|
403
|
+
.fb-toggle-subtitle {
|
|
404
|
+
font-size: var(--fb-font-size-small);
|
|
405
|
+
color: var(--fb-text-secondary-color);
|
|
406
|
+
margin-top: 2px;
|
|
407
|
+
line-height: 1.35;
|
|
408
|
+
}
|
|
409
|
+
.fb-toggle-info {
|
|
410
|
+
flex: 0 0 14px;
|
|
411
|
+
display: inline-flex;
|
|
412
|
+
align-items: center;
|
|
413
|
+
justify-content: center;
|
|
414
|
+
width: 14px;
|
|
415
|
+
height: 14px;
|
|
416
|
+
border-radius: 50%;
|
|
417
|
+
background: var(--fb-border-color);
|
|
418
|
+
color: #fff;
|
|
419
|
+
font-size: 10px;
|
|
420
|
+
font-weight: 700;
|
|
421
|
+
font-style: italic;
|
|
422
|
+
font-family: serif;
|
|
423
|
+
cursor: help;
|
|
424
|
+
}
|
|
425
|
+
`,e.head.appendChild(n)}function kt(e){return typeof e=="boolean"?e:typeof e=="string"?e==="true"||e==="on"||e==="1":!1}function _r(e,t,n,r){var o;Kr(document);const i=t.state,a=ae(e,i,t),l=t.prefill[e.key],s=kt(l!==void 0?l:e.default),c=document.createElement("input");c.type="hidden",c.name=r,c.value=s?"true":"false";const u=document.createElement("div");u.className="fb-toggle-row",u.setAttribute("role","switch"),u.setAttribute("aria-checked",s?"true":"false"),a?u.setAttribute("aria-disabled","true"):u.tabIndex=0;const d=document.createElement("span");d.className="fb-toggle"+(s?" fb-on":""),d.setAttribute("aria-hidden","true"),u.appendChild(d);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(u.appendChild(f),!a){const m=()=>{const b=c.value!=="true";c.value=b?"true":"false",d.classList.toggle("fb-on",b),u.setAttribute("aria-checked",b?"true":"false"),t.instance&&t.instance.triggerOnChange(r,b)};u.addEventListener("click",b=>{var v;(v=b.target)!=null&&v.classList.contains("fb-toggle-info")||m()}),u.addEventListener("keydown",b=>{(b.key===" "||b.key==="Enter")&&(b.preventDefault(),m())})}n.appendChild(c),n.appendChild(u)}function Jr(e,t,n){var r;const{scopeRoot:o}=n,i=o.querySelector(`input[type="hidden"][name="${t}"]`),a=(r=i==null?void 0:i.value)!=null?r:"";return{value:kt(a),errors:[]}}function Yr(e,t,n,r){var o;const{scopeRoot:i}=r,a=i.querySelector(`input[type="hidden"][name="${t}"]`);if(!a)return;const l=kt(n);a.value=l?"true":"false";const s=(o=a.parentElement)==null?void 0:o.querySelector(".fb-toggle-row");if(s){s.setAttribute("aria-checked",l?"true":"false");const c=s.querySelector(".fb-toggle");c&&c.classList.toggle("fb-on",l)}}function Me(e){return e?typeof e=="object"&&Array.isArray(e.extensions)?e.extensions.map(t=>t.toLowerCase()):typeof e=="string"?e.split(",").map(t=>t.trim()).filter(t=>t.startsWith(".")).map(t=>t.substring(1).toLowerCase()):[]:[]}function je(e,t){var n,r;if(t.length===0)return!0;const o=(r=(n=e.split(".").pop())==null?void 0:n.toLowerCase())!=null?r:"";return t.includes(o)}function sn(e,t){return t===1/0?!0:e<=t*1024*1024}function it(e,t){return sn(e.size,t)}function Ye(e){return e?typeof e=="string"?[]:Array.isArray(e.mime)?e.mime.map(t=>t.toLowerCase()):[]:[]}function Xe(e,t){if(t.length===0)return!0;const n=e.toLowerCase();return t.some(r=>{if(r.endsWith("/*")){const o=r.slice(0,-1);return n.startsWith(o)}return n===r})}function Xr(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 at(e,t){if(t.has(e))return;const n=e.split("/").pop()||"file";t.set(e,{name:n,type:Xr(e),size:0,uploadedAt:new Date,file:void 0,inferredFromExtension:!0})}function $t(e,t){for(const n of e)at(n,t)}const cn="fb-file-styles";function $e(){if(typeof document=="undefined"||document.getElementById(cn))return;const e=document.createElement("style");if(e.id=cn,e.setAttribute("data-fb-file-styles","true"),e.textContent=`
|
|
179
426
|
@keyframes fb-spin { to { transform: rotate(360deg); } }
|
|
180
427
|
|
|
181
428
|
/* \u2500\u2500\u2500 Checker background utility \u2500\u2500\u2500 */
|
|
@@ -196,14 +443,20 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
196
443
|
}
|
|
197
444
|
|
|
198
445
|
/* \u2500\u2500\u2500 Wide single-file add tile (empty state) \u2500\u2500\u2500 */
|
|
446
|
+
/* Flex-wraps: side-by-side when wide enough, stacks upload/library
|
|
447
|
+
vertically when narrow (e.g. inside a 50/50 container column). */
|
|
199
448
|
.fb-wide-tile {
|
|
200
449
|
width: 100%;
|
|
450
|
+
box-sizing: border-box;
|
|
201
451
|
border-radius: 0.75rem;
|
|
202
452
|
border: 1px dashed #60a5fa;
|
|
203
453
|
background: rgba(239,246,255,0.5);
|
|
204
454
|
display: flex;
|
|
455
|
+
flex-wrap: wrap;
|
|
456
|
+
align-items: stretch;
|
|
457
|
+
gap: 0;
|
|
205
458
|
overflow: hidden;
|
|
206
|
-
height: 180px;
|
|
459
|
+
min-height: 180px;
|
|
207
460
|
transition: border-color 150ms, background 150ms, box-shadow 150ms;
|
|
208
461
|
cursor: pointer;
|
|
209
462
|
}
|
|
@@ -217,9 +470,12 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
217
470
|
box-shadow: 0 0 0 4px rgba(191,219,254,0.7);
|
|
218
471
|
}
|
|
219
472
|
|
|
220
|
-
/* Upload zone inside wide tile
|
|
473
|
+
/* Upload zone inside wide tile.
|
|
474
|
+
flex: 1 1 220px \u2014 wants at least 220px; if the container can't fit
|
|
475
|
+
upload + library on one row (~220 + 176), library wraps below. */
|
|
221
476
|
.fb-wide-tile-upload {
|
|
222
|
-
flex: 1;
|
|
477
|
+
flex: 1 1 220px;
|
|
478
|
+
min-height: 140px;
|
|
223
479
|
display: flex;
|
|
224
480
|
flex-direction: column;
|
|
225
481
|
align-items: center;
|
|
@@ -232,24 +488,21 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
232
488
|
background: transparent;
|
|
233
489
|
border: none;
|
|
234
490
|
font-family: inherit;
|
|
491
|
+
/* Dashed separator from library: right side when in a row, bottom when
|
|
492
|
+
wrapped (the line then sits between the two stacked cards). */
|
|
493
|
+
border-right: 1px dashed rgba(96,165,250,0.5);
|
|
235
494
|
}
|
|
236
495
|
.fb-wide-tile-upload:hover {
|
|
237
496
|
background: rgba(191,219,254,0.25);
|
|
238
497
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
.
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
border-left: 1px dashed rgba(96,165,250,0.5);
|
|
245
|
-
background: transparent;
|
|
246
|
-
flex-shrink: 0;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/* Library zone inside wide tile */
|
|
498
|
+
/* Library zone inside wide tile.
|
|
499
|
+
flex: 0 0 176px \u2014 fixed 176px, never grows. Upload fills the rest in
|
|
500
|
+
row layout. When the tile wraps to two rows on narrow containers,
|
|
501
|
+
library stays 176px wide on its own row (left-aligned), preserving the
|
|
502
|
+
visual hierarchy "upload > library" in both layouts. */
|
|
250
503
|
.fb-wide-tile-library {
|
|
251
|
-
|
|
252
|
-
|
|
504
|
+
flex: 0 0 176px;
|
|
505
|
+
min-height: 120px;
|
|
253
506
|
display: flex;
|
|
254
507
|
flex-direction: column;
|
|
255
508
|
align-items: center;
|
|
@@ -266,6 +519,10 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
266
519
|
.fb-wide-tile-library:hover {
|
|
267
520
|
background: rgba(191,219,254,0.25);
|
|
268
521
|
}
|
|
522
|
+
/* Narrow-tile mode lives in a separate <style> tag (see below) \u2014 the
|
|
523
|
+
@container rule is appended only when the runtime actually supports
|
|
524
|
+
container queries, so jsdom (which doesn't) never sees it and stays
|
|
525
|
+
quiet in test logs. */
|
|
269
526
|
|
|
270
527
|
/* \u2500\u2500\u2500 Multi-file outer grid container \u2500\u2500\u2500 */
|
|
271
528
|
.fb-multi-outer {
|
|
@@ -642,90 +899,117 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
642
899
|
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
|
|
643
900
|
gap: 10px;
|
|
644
901
|
}
|
|
645
|
-
`,document.head.appendChild(e)
|
|
902
|
+
`,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=`
|
|
903
|
+
.fb-wide-tile { container-type: inline-size; }
|
|
904
|
+
@container (max-width: 408px) {
|
|
905
|
+
.fb-wide-tile-upload {
|
|
906
|
+
border-right: none;
|
|
907
|
+
border-bottom: 1px dashed rgba(96,165,250,0.5);
|
|
908
|
+
}
|
|
909
|
+
.fb-wide-tile-library {
|
|
910
|
+
flex: 1 0 100%;
|
|
911
|
+
min-height: 0;
|
|
912
|
+
flex-direction: row;
|
|
913
|
+
gap: 6px;
|
|
914
|
+
padding: 8px 12px;
|
|
915
|
+
font-size: 12px;
|
|
916
|
+
}
|
|
917
|
+
.fb-wide-tile-library .fb-wide-tile-library-icon {
|
|
918
|
+
width: 16px;
|
|
919
|
+
height: 16px;
|
|
920
|
+
}
|
|
921
|
+
.fb-wide-tile-library .fb-wide-tile-library-label {
|
|
922
|
+
font-size: 12px;
|
|
923
|
+
font-weight: 500;
|
|
924
|
+
}
|
|
925
|
+
.fb-wide-tile-library .fb-wide-tile-library-hint {
|
|
926
|
+
display: none;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
`,document.head.appendChild(t)}}function dn(){$e();const e=document.createElement("div");return e.className="fb-tile",e}function Se(e,t){var n,r;const o=(n=e.closest("[data-files-wrapper]"))==null?void 0:n.querySelector(".file-error-message");o&&o.remove();const i=document.createElement("div");i.className="file-error-message error-message",i.style.cssText=`
|
|
646
930
|
color: var(--fb-error-color);
|
|
647
931
|
font-size: var(--fb-font-size-small);
|
|
648
932
|
margin-top: 0.25rem;
|
|
649
|
-
`,
|
|
933
|
+
`,i.textContent=t,(r=e.closest("[data-files-wrapper]"))==null||r.appendChild(i)}function Ge(e){var t;const n=(t=e.closest("[data-files-wrapper]"))==null?void 0:t.querySelector(".file-error-message");n&&n.remove()}function Gr(e,t,n){const r=e.querySelector(".delete-overlay");r&&r.remove();const o=document.createElement("div");o.className="delete-overlay absolute inset-0 bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center";const i=document.createElement("button");i.className="bg-red-600 text-white px-3 py-1 rounded text-sm hover:bg-red-700 transition-colors",i.textContent=k("removeElement",t),i.onclick=a=>{a.stopPropagation(),n()},o.appendChild(i),e.appendChild(o)}function Zr(e,t){$e();const n=dn();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=`
|
|
650
934
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:4px;">
|
|
651
935
|
<div class="fb-spinner"></div>
|
|
652
|
-
<div class="fb-tile-label">${
|
|
653
|
-
<div class="fb-tile-uploading-text">${
|
|
654
|
-
</div>`,n}function
|
|
936
|
+
<div class="fb-tile-label">${se(r)}</div>
|
|
937
|
+
<div class="fb-tile-uploading-text">${se(k("uploadingFile",t))}</div>
|
|
938
|
+
</div>`,n}function St(e){var t,n,r;const o=e.querySelector(".fb-multi-grid");if(o)return o;const i=e.querySelector(".fb-tiles-wrap");if(i)return i;(t=e.querySelector(".fb-file-dropzone"))==null||t.remove(),(n=e.querySelector(".fb-wide-tile"))==null||n.remove(),(r=e.querySelector(".fb-multi-outer"))==null||r.remove();const a=document.createElement("div");a.className="fb-tiles-wrap",a.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";const l=document.createElement("div");return l.className="fb-tile fb-tile-add",l.innerHTML="+",a.appendChild(l),e.appendChild(a),a}function Lt(e,t,n){e.innerHTML=`
|
|
655
939
|
<div class="flex flex-col items-center justify-center h-full text-gray-400">
|
|
656
940
|
<svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
|
|
657
941
|
<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"/>
|
|
658
942
|
</svg>
|
|
659
|
-
<div class="text-sm text-center">${
|
|
943
|
+
<div class="text-sm text-center">${se(k("clickDragText",t))}</div>
|
|
660
944
|
|
|
661
945
|
</div>
|
|
662
|
-
`}const
|
|
946
|
+
`}const un=new WeakMap;function st(e,t){const n=un.get(e);n&&(e.removeEventListener("dragover",n.dragover),e.removeEventListener("dragleave",n.dragleave),e.removeEventListener("drop",n.drop));const r=a=>{a.preventDefault(),e.classList.add("border-blue-500","bg-blue-50")},o=a=>{a.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50")},i=a=>{var l;a.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50");const s=(l=a.dataTransfer)==null?void 0:l.files;s&&t(s)};e.addEventListener("dragover",r),e.addEventListener("dragleave",o),e.addEventListener("drop",i),un.set(e,{dragover:r,dragleave:o,drop:i})}const Qr='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="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>',eo='<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>',to='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><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>',no='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',ro='<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 oo(e,t){return!!(e.config.downloadFile||e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function lo(e,t){return!!(e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function Tt(e){const{canRemove:t,removeHandler:n,state:r,resourceId:o,fileName:i,meta:a,replaceHandler:l,libraryHandler:s}=e,c=document.createElement("div");c.className="fb-tile-actions";const u=(d,f,p)=>{const m=document.createElement("button");return m.type="button",m.className=`fb-tile-action-btn ${p}`,m.innerHTML=d,m.title=f,m.setAttribute("aria-label",f),m.addEventListener("click",b=>{b.stopPropagation()}),m};if(l){const d=u(no,k("replaceFile",r),"fb-tile-action-replace");d.addEventListener("click",()=>l()),c.appendChild(d)}if(s){const d=u(ro,k("fromLibrary",r),"fb-tile-action-library");d.addEventListener("click",()=>s()),c.appendChild(d)}if(oo(r,a)){const d=u(Qr,k("downloadFile",r),"fb-tile-action-download");d.addEventListener("click",()=>{io(o,i,r,a)}),c.appendChild(d)}if(lo(r,a)){const d=u(eo,k("openInNewTab",r),"fb-tile-action-open");d.addEventListener("click",()=>{ao(o,r,a).catch(f=>{console.error("Open failed:",f)})}),c.appendChild(d)}if(t&&n){const d=u(to,k("removeElement",r),"fb-tile-action-remove");d.addEventListener("click",()=>{n()}),c.appendChild(d)}return c}const ct=new WeakMap;function At(e){let t=ct.get(e);return t||(t=URL.createObjectURL(e),ct.set(e,t)),t}function qe(e){if(!e)return;const t=ct.get(e);t&&(URL.revokeObjectURL(t),ct.delete(e))}function io(e,t,n,r){if(n.config.downloadFile){n.config.downloadFile(e,t);return}if((r==null?void 0:r.file)instanceof File){vn(r.file,t||r.file.name);return}gn(e,t,n).catch(o=>{console.error("Download failed:",o)})}async function ao(e,t,n){let r=null;t.config.getDownloadUrl?r=t.config.getDownloadUrl(e):t.config.getThumbnail?r=await t.config.getThumbnail(e):(n==null?void 0:n.file)instanceof File&&(r=At(n.file)),r&&window.open(r,"_blank")}let we=null,ze=null,Re=null,dt=null;function so(){if(!we){we=document.createElement("div"),we.className="fb-tile-zoom-preview";const e=document.createElement("img");e.className="fb-tile-zoom-preview-img",we.appendChild(e),we.addEventListener("mouseenter",pn),we.addEventListener("mouseleave",fn)}return we}function co(e,t){const n=t.getBoundingClientRect(),r=350,o=6,i=8;let a;n.top-r-o>=i?a=n.top-r-o:n.bottom+o+r+i<=window.innerHeight?a=n.bottom+o:a=Math.max(i,Math.min(window.innerHeight-r-i,n.top));let l=n.left+n.width/2-r/2;l=Math.max(i,Math.min(window.innerWidth-r-i,l)),e.style.top=`${a}px`,e.style.left=`${l}px`}function fn(){Re!==null&&clearTimeout(Re),Re=setTimeout(()=>{Re=null,mn()},100)}function pn(){Re!==null&&(clearTimeout(Re),Re=null)}function mn(){ze!==null&&(clearTimeout(ze),ze=null),we&&we.parentNode&&(we.classList.remove("fb-tile-zoom-preview--visible"),we.parentNode.removeChild(we)),dt=null}function Ft(e,t,n,r){e.dataset.zoomSrc=t,e.dataset.zoomAlt=n,e.addEventListener("mouseenter",()=>{pn(),dt!==e&&mn(),dt=e,ze=setTimeout(()=>{ze=null;const o=so(),i=o.querySelector(".fb-tile-actions");i&&i.remove();const a=o.querySelector(".fb-tile-zoom-preview-img");a.src=t,a.alt=n,r&&(o.appendChild(r.cloneNode(!0)),uo(o.querySelector(".fb-tile-actions"),r)),o.style.pointerEvents="auto",co(o,e),document.body.appendChild(o),o.getBoundingClientRect(),o.classList.add("fb-tile-zoom-preview--visible")},200)}),e.addEventListener("mouseleave",()=>{ze!==null?(clearTimeout(ze),ze=null,dt=null):fn()})}function uo(e,t){const n=Array.from(t.querySelectorAll(".fb-tile-action-btn"));Array.from(e.querySelectorAll(".fb-tile-action-btn")).forEach((r,o)=>{const i=n[o];i&&r.addEventListener("click",a=>{a.stopPropagation(),i.click()})})}function fo(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 i=new FileReader;i.onload=a=>{var l;o.src=((l=a.target)==null?void 0:l.result)||""},i.readAsDataURL(t),e.appendChild(o)}function po(e,t){e.onclick=null;const n=e.cloneNode(!1);return e.parentNode&&e.parentNode.replaceChild(n,e),n}function mo(e,t,n,r,o,i){const a=URL.createObjectURL(t),l=po(e);return l.innerHTML=`
|
|
663
947
|
<div class="fb-video-preview-wrap">
|
|
664
|
-
<video style="width:100%;height:100%;object-fit:contain;" controls preload="auto" muted src="${
|
|
665
|
-
${
|
|
948
|
+
<video style="width:100%;height:100%;object-fit:contain;" controls preload="auto" muted src="${a}">
|
|
949
|
+
${se(k("videoNotSupported",o))}
|
|
666
950
|
</video>
|
|
667
951
|
<div class="fb-video-btn-overlay">
|
|
668
952
|
<button class="fb-video-btn fb-video-btn-delete delete-file-btn">
|
|
669
|
-
${
|
|
953
|
+
${se(k("removeElement",o))}
|
|
670
954
|
</button>
|
|
671
955
|
<button class="fb-video-btn fb-video-btn-change change-file-btn">
|
|
672
|
-
${
|
|
956
|
+
${se(k("changeButton",o))}
|
|
673
957
|
</button>
|
|
674
958
|
</div>
|
|
675
959
|
</div>
|
|
676
|
-
`,
|
|
960
|
+
`,ho(l,r,o,i),l}function ho(e,t,n,r){const o=e.querySelector(".change-file-btn");o&&(o.onclick=a=>{var l;a.stopPropagation(),(l=r==null?void 0:r.picker)==null||l.click()});const i=e.querySelector(".delete-file-btn");i&&(i.onclick=a=>{a.stopPropagation(),bo(e,t,n,r)})}function bo(e,t,n,r){var o;n.resourceIndex.delete(t);const i=(o=e.parentElement)==null?void 0:o.querySelector('input[type="hidden"]');i&&(i.value=""),r!=null&&r.fileUploadHandler&&(e.onclick=r.fileUploadHandler),e.innerHTML=`
|
|
677
961
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
|
|
678
962
|
<svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
|
|
679
963
|
<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"/>
|
|
680
964
|
</svg>
|
|
681
|
-
<div style="font-size:0.875rem;text-align:center;">${
|
|
965
|
+
<div style="font-size:0.875rem;text-align:center;">${se(k("clickDragText",n))}</div>
|
|
682
966
|
</div>
|
|
683
|
-
`,r!=null&&r.setupDrop&&r.setupDrop(e)}function
|
|
967
|
+
`,r!=null&&r.setupDrop&&r.setupDrop(e)}function hn(e,t,n){Gr(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=`
|
|
684
968
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
|
|
685
969
|
<svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
|
|
686
970
|
<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"/>
|
|
687
971
|
</svg>
|
|
688
|
-
<div style="font-size:0.875rem;text-align:center;">${
|
|
972
|
+
<div style="font-size:0.875rem;text-align:center;">${se(k("clickDragText",n))}</div>
|
|
689
973
|
</div>
|
|
690
|
-
`})}async function
|
|
974
|
+
`})}async function go(e,t,n,r,o,i,a){var l,s,c;!t.file||!(t.file instanceof File)||((l=t.type)!=null&&l.startsWith("image/")?fo(e,t.file,n,i):(s=t.type)!=null&&s.startsWith("video/")?e=mo(e,t.file,t.type,r,i,a):e.innerHTML=`<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);"><div style="font-size:36px;margin-bottom:0.5rem;">\u{1F4C1}</div><div style="font-size:0.875rem;">${se(n)}</div></div>`,!o&&!((c=t.type)!=null&&c.startsWith("video/"))&&hn(e,r,i))}function vo(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 yo(e,t,n,r,o){var i;if(!o.config.getThumbnail){Lt(e,o);return}try{const a=await o.config.getThumbnail(t);if(a)if(ye(e),(i=r==null?void 0:r.type)!=null&&i.startsWith("video/"))vo(e,a,o);else{const l=document.createElement("img");l.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",l.alt=n||k("previewAlt",o),l.src=a,e.appendChild(l)}else Lt(e,o)}catch(a){console.error("Failed to get thumbnail:",a),e.innerHTML=`
|
|
691
975
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
|
|
692
976
|
<svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
|
|
693
977
|
<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"/>
|
|
694
978
|
</svg>
|
|
695
|
-
<div style="font-size:0.875rem;text-align:center;">${
|
|
979
|
+
<div style="font-size:0.875rem;text-align:center;">${se(n||k("previewUnavailable",o))}</div>
|
|
696
980
|
</div>
|
|
697
|
-
`}}async function
|
|
698
|
-
<img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${
|
|
981
|
+
`}}async function Mt(e,t,n,r={}){var o;const{fileName:i="",isReadonly:a=!1,deps:l=null}=r;if(!a&&l&&(!l.picker||!l.fileUploadHandler||!l.dragHandler))throw new Error("renderFilePreview: missing deps {picker, fileUploadHandler, dragHandler}");ye(e);const s=n.resourceIndex.get(t);if(s&&s.file&&s.file instanceof File)await go(e,s,i,t,a,n,l);else{await yo(e,t,i,s,n);const c=(o=s==null?void 0:s.type)==null?void 0:o.startsWith("video/");!a&&!c&&hn(e,t,n)}}function xo(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 zt(e,t,n,r={}){var o,i;const a=t.resourceIndex.get(e),l=xo(e,a,n),{canRemove:s=!1,removeHandler:c=null}=r,u=((o=a==null?void 0:a.type)==null?void 0:o.startsWith("image/"))||!!l.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/),d=((i=a==null?void 0:a.type)==null?void 0:i.startsWith("video/"))||!!l.toLowerCase().match(/\.(mp4|webm|avi|mov)$/),f=dn();f.classList.add("fb-tile-resource"),f.style.cursor="pointer",l&&(f.title=l);const p=(a==null?void 0:a.file)instanceof File?At(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,l):gn(e,l,t).catch(y=>{console.error("Download failed:",y)})};const b=Tt({canRemove:s,removeHandler:c,state:t,resourceId:e,fileName:l,meta:a}),v=async()=>{if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);if(h)return h}catch(h){}return p},w=()=>{f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>',f.appendChild(b)};if(u){const h=await v();if(h){const y=document.createElement("img");y.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",y.alt=l,y.src=h,f.appendChild(y),f.appendChild(b),Ft(f,h,l,b)}else w()}else if(d)if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);h?(f.innerHTML=`
|
|
982
|
+
<img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${se(l)}" src="${h}">
|
|
699
983
|
<div class="fb-video-overlay">
|
|
700
984
|
<div class="fb-play-btn" style="width:22px;height:22px;">
|
|
701
985
|
<svg width="10" height="12" viewBox="0 0 10 12" fill="currentColor"><path d="M0 0l10 6-10 6z"/></svg>
|
|
702
986
|
</div>
|
|
703
|
-
</div>`,
|
|
704
|
-
<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>`:"";
|
|
987
|
+
</div>`,f.appendChild(b)):(f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',f.appendChild(b))}catch(h){f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',f.appendChild(b)}else f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',f.appendChild(b);else{if(t.config.getThumbnail)try{const y=await t.config.getThumbnail(e);if(y){const g=document.createElement("img");return g.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",g.alt=l||e,g.src=y,f.appendChild(g),f.appendChild(b),f}}catch(y){}const h=l?`<div class="fb-tile-label">${se(l.length>10?l.substring(0,8)+"\u2026":l)}</div>
|
|
988
|
+
<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=`
|
|
705
989
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
|
|
706
990
|
<div style="font-size:36px;">\u{1F4C1}</div>
|
|
707
991
|
${h}
|
|
708
|
-
</div>`,
|
|
992
|
+
</div>`,f.appendChild(b)}return f}async function wo(e,t,n,r){var o,i,a;const l=n.resourceIndex.get(t),s=(i=(o=l==null?void 0:l.name)!=null?o:t.split("/").pop())!=null?i:"",c=(a=r.onRemove)!=null?a:null,u=await zt(t,n,s,{canRemove:!0,removeHandler:c});e.className="file-preview-container",e.removeAttribute("style"),ye(e),e.appendChild(u)}async function bn(e,t,n,r,o){var i,a;if((i=n==null?void 0:n.type)!=null&&i.startsWith("image/")){if(n.file&&n.file instanceof File){const l=document.createElement("img");l.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",l.alt=n.name,l.src=At(n.file),e.appendChild(l),Ft(e,l.src,n.name,o!=null?o:null)}else if(r.config.getThumbnail)try{const l=await r.config.getThumbnail(t);if(l){const s=document.createElement("img");s.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",s.alt=n.name,s.src=l,e.appendChild(s),Ft(e,l,n.name,o!=null?o:null)}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>'}catch(l){const s=l instanceof Error?l:new Error(String(l));r.config.onThumbnailError&&r.config.onThumbnailError(s,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>';o&&e.appendChild(o)}else if((a=n==null?void 0:n.type)!=null&&a.startsWith("video/")){if(n.file&&n.file instanceof File){const l=URL.createObjectURL(n.file);e.innerHTML=`
|
|
709
993
|
<video style="width:100%;height:100%;" preload="metadata" muted src="${l}"></video>
|
|
710
994
|
<div class="fb-video-overlay">
|
|
711
995
|
<div class="fb-play-btn" style="width:20px;height:20px;">
|
|
712
996
|
<svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
|
|
713
997
|
</div>
|
|
714
998
|
</div>`}else if(r.config.getThumbnail)try{const l=await r.config.getThumbnail(t);l?e.innerHTML=`
|
|
715
|
-
<img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${
|
|
999
|
+
<img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${se(n.name)}" src="${l}">
|
|
716
1000
|
<div class="fb-video-overlay">
|
|
717
1001
|
<div class="fb-play-btn" style="width:20px;height:20px;">
|
|
718
1002
|
<svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
|
|
719
1003
|
</div>
|
|
720
|
-
</div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(l){const s=l instanceof Error?l:new Error(String(l));r.config.onThumbnailError&&r.config.onThumbnailError(s,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>';o&&e.appendChild(o)}else
|
|
1004
|
+
</div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(l){const s=l instanceof Error?l:new Error(String(l));r.config.onThumbnailError&&r.config.onThumbnailError(s,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>';o&&e.appendChild(o)}else Co(e,t,n,o)}function Co(e,t,n,r){var o,i;const a=(i=(o=n==null?void 0:n.name)!=null?o:t.split("/").pop())!=null?i:"";a&&(e.title=a);const l=a?`<div style="font-size:11px;line-height:1.2;text-align:center;color:var(--fb-text-secondary-color,#6b7280);max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${se(a)}</div>`:"";e.innerHTML=`
|
|
721
1005
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
|
|
722
1006
|
<div style="font-size:36px;">\u{1F4C1}</div>
|
|
723
1007
|
${l}
|
|
724
|
-
</div>`,r&&e.appendChild(r)}async function
|
|
1008
|
+
</div>`,r&&e.appendChild(r)}async function gn(e,t,n){try{let r=null;if(n.config.getDownloadUrl?r=n.config.getDownloadUrl(e):n.config.getThumbnail&&(r=await n.config.getThumbnail(e)),r){const o=r.startsWith("http")?r:new URL(r,window.location.href).href,i=await fetch(o);if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const a=await i.blob();vn(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 vn(e,t){try{const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>{URL.revokeObjectURL(n)},100)}catch(n){throw new Error(`Blob download failed: ${n.message}`)}}async function yn(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 Eo(e){var t,n,r;const{file:o,container:i,fieldName:a,state:l,deps:s=null,instance:c=null,allowedExtensions:u=[],allowedMimes:d=[],maxSizeMB:f=1/0}=e;if(!je(o.name,u)){const h=u.join(", ");Se(i,k("invalidFileExtension",l,{name:o.name,formats:h}));return}if(!Xe(o.type,d)){const h=d.join(", ");Se(i,k("invalidFileMime",l,{name:o.name,type:o.type,mimes:h}));return}if(!it(o,f)){Se(i,k("fileTooLarge",l,{name:o.name,maxSize:f}));return}Ge(i);const p=(t=i.parentElement)==null?void 0:t.querySelector('input[type="hidden"]'),m=(p==null?void 0:p.value)||null;$e(),i.innerHTML=`
|
|
725
1009
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:6px;">
|
|
726
1010
|
<div class="fb-spinner"></div>
|
|
727
|
-
<div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${
|
|
728
|
-
</div>`;let b;try{b=await cn(o,l)}catch(h){throw m&&s!=null&&s.onAfterUpload?s.onAfterUpload(a,m):s!=null&&s.onRemove?s.onRemove():xt(a,l),h}l.resourceIndex.set(b,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:o}),m&&m!==b&<((n=l.resourceIndex.get(m))==null?void 0:n.file);let g=f;g||(g=document.createElement("input"),g.type="hidden",g.name=i,(r=a.parentElement)==null||r.appendChild(g)),g.value=b;const E=o.type.startsWith("video/");!E&&s!=null&&s.onAfterUpload?s.onAfterUpload(a,b):!E&&s?lo(a,b,l,s).catch(console.error):kt(a,b,l,{fileName:o.name,isReadonly:!1,deps:s}).catch(console.error),u&&!l.config.readonly&&u.triggerOnChange(i,b)}function dn(e,t,n,r){const o=e.filter(m=>!Be(m.name,n.allowedExtensions)),a=e.filter(m=>Be(m.name,n.allowedExtensions)),i=a.filter(m=>!Ke(m.type,n.allowedMimes)),l=a.filter(m=>Ke(m.type,n.allowedMimes)),s=l.filter(m=>!tt(m,n.maxSize)),u=l.filter(m=>tt(m,n.maxSize)),d=n.maxCount===1/0?u.length:Math.max(0,n.maxCount-t),c=u.slice(0,d),p=u.length-c.length,f=[];if(o.length>0){const m=n.allowedExtensions.join(", "),b=o.map(g=>g.name).join(", ");f.push(k("invalidFileExtension",r,{name:b,formats:m}))}if(i.length>0){const m=n.allowedMimes.join(", "),b=i.map(g=>g.name).join(", ");f.push(k("invalidFileMime",r,{name:b,type:i.map(g=>g.type).join(", "),mimes:m}))}if(s.length>0){const m=s.map(b=>b.name).join(", ");f.push(k("fileTooLarge",r,{name:m,maxSize:n.maxSize}))}return p>0&&f.push(k("filesLimitExceeded",r,{skipped:p,max:n.maxCount})),{accepted:c,errorMessage:f.join(" \u2022 ")}}async function fn(e,t,n,r){var o;if(n){const i=en(n),l=(o=i.querySelector(".fb-multi-add-tile-js"))!=null?o:i.querySelector(".fb-tile-add");l&&(l.style.display="none")}const a=[];return await Promise.allSettled(e.map(async i=>{const l=Hr(i.name,r);n&&en(n).appendChild(l);try{const s=await cn(i,r);r.resourceIndex.set(s,{name:i.name,type:i.type,size:i.size,uploadedAt:new Date,file:void 0}),t.push(s)}catch(s){const u=s instanceof Error?s:new Error(String(s)),d=u.cause,c=d instanceof Error?d:d!==void 0?new Error(String(d)):u;a.push({file:i,error:c})}finally{l.remove()}})),{failures:a}}function pn(e,t,n){if(t.length===0)return e;const r=t.map(o=>k("uploadFailed",n,{name:o.file.name,error:o.error.message})).join(" \u2022 ");return e?`${e} \u2022 ${r}`:r}function so(e,t,n,r,o,a,i){rt(e,async l=>{var s;const{accepted:u,errorMessage:d}=dn(Array.from(l),t.length,o,n);d?Ee(e,d):qe(e);const c=(s=e.querySelector(".files-list"))!=null?s:e,{failures:p}=await fn(u,t,c,n),f=pn(d,p,n);f?Ee(e,f):qe(e),r(),i&&a&&!n.config.readonly&&i.triggerOnChange(a,t)})}function uo(e,t,n,r,o,a,i){e.onchange=async()=>{if(!e.files)return;const l=e.closest("[data-files-wrapper]")||e.parentElement,{accepted:s,errorMessage:u}=dn(Array.from(e.files),t.length,o,n);u&&l?Ee(l,u):l&&qe(l);const d=l==null?void 0:l.querySelector(".files-list"),{failures:c}=await fn(s,t,d!=null?d:null,n);if(l){const p=pn(u,c,n);p?Ee(l,p):qe(l)}r(),e.value="",i&&a&&!n.config.readonly&&i.triggerOnChange(a,t)}}function mn(e){var t,n;if(!e.accept)return;if(typeof e.accept=="string"){const l=Ae(e.accept);return l.length>0?{extensions:l}:void 0}const r=(t=e.accept.extensions)!=null?t:[],o=(n=e.accept.mime)!=null?n:[],a=r.map(l=>l.toLowerCase());if(a.length===0&&o.length===0)return;const i={};return a.length>0&&(i.extensions=a),o.length>0&&(i.mime=o),i}function hn(e,t,n,r,o){if(!Be(e.name,t)){const a=t.join(", ");return k("invalidFileExtension",o,{name:e.name,formats:a})}if(!Ke(e.type,n)){const a=n.join(", ");return k("invalidFileMime",o,{name:e.name,type:e.type,mimes:a})}return Xt(e.size,r)?null:k("fileTooLarge",o,{name:e.name,maxSize:r})}function co(e){const t=e.dataset.resourceIds;if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n:[]}catch(n){return[]}}function bn(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 vn(e,t){return e instanceof Error&&e.message?e.message:k("pickerError",t)}async function fo(e,t,n,r,o,a,i,l){var s;if(!e.config.pickExistingFiles)return;const u=Ae(t.accept),d=_e(t.accept),c=(s=t.maxSize)!=null?s:1/0,p=co(n),f=a===1/0?1/0:Math.max(0,a-p.length);let m;try{m=await e.config.pickExistingFiles({fieldPath:r,mode:"multiple",accept:mn(t),maxSizeMB:c===1/0?void 0:c,remainingSlots:f===1/0?void 0:f,selectedResourceIds:[...p]})}catch(w){Ee(n,vn(w,e));return}if(m.length===0)return;const b=new Set(p),g=new Set,E=m.filter(w=>b.has(w.resourceId)||g.has(w.resourceId)?!1:(g.add(w.resourceId),!0)).filter(w=>hn(w,u,d,c,e)===null),h=a===1/0?E.length:Math.max(0,a-o.length),x=E.slice(0,h),v=E.length-x.length;if(x.length!==0){qe(n),v>0&&Ee(n,k("filesLimitExceeded",e,{skipped:v,max:a}));for(const w of x)bn(w,e),o.push(w.resourceId);n.dataset.resourceIds=JSON.stringify(o),i(),e.config.readonly||l.triggerOnChange(r,o)}}async function po(e,t,n,r,o,a,i,l){var s,u;if(!e.config.pickExistingFiles)return;const d=Ae(t.accept),c=_e(t.accept),p=(s=t.maxSize)!=null?s:1/0;let f;try{f=await e.config.pickExistingFiles({fieldPath:a,mode:"single",accept:mn(t),maxSizeMB:p===1/0?void 0:p,selectedResourceIds:[]})}catch(h){Ee(n,vn(h,e));return}if(f.length===0)return;const m=f[0],b=hn(m,d,c,p,e);if(b!==null){Ee(n,b);return}qe(n),bn(m,e);let g=r.querySelector('input[type="hidden"]');g||(g=document.createElement("input"),g.type="hidden",g.name=o,r.appendChild(g));const E=g.value||null;E&&E!==m.resourceId&<((u=e.resourceIndex.get(E))==null?void 0:u.file),g.value=m.resourceId,await i(m.resourceId),e.config.readonly||l.triggerOnChange(a,m.resourceId)}const gn='<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>',yn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function mo(e,t,n,r,o,a,i){var l;nt(e,o.resourceIndex);const s=o.resourceIndex.get(e);(l=s==null?void 0:s.type)!=null&&l.startsWith("video/")?kt(t,e,o,{fileName:e,isReadonly:!1,deps:a}).catch(console.error):Lt(t,e,o,a,i);const u=document.createElement("input");u.type="hidden",u.name=n,u.value=e,r.appendChild(u)}function ho(e,t,n,r,o=!1,a=""){ke();const i=document.createElement("div");i.className=`fb-wide-tile${t?" fb-file-card-row":""}${o?" fb-drag-over":""}`;const l=document.createElement("button");l.type="button",l.className="fb-wide-tile-upload fb-file-dropzone";const s=document.createElement("span");s.style.cssText="width:36px;height:36px;display:block;flex-shrink:0;",s.innerHTML=gn,l.appendChild(s);const u=document.createElement("div");if(u.className="fb-wide-tile-label",u.style.cssText="font-size:14px;font-weight:600;",u.textContent=k(o?"dropToUpload":"clickDragText",e),l.appendChild(u),a){const d=document.createElement("div");d.style.cssText="font-size:11px;opacity:0.65;margin-top:2px;",d.textContent=a,l.appendChild(d)}if(l.onclick=d=>{d.stopPropagation(),n()},i.appendChild(l),t&&r){const d=document.createElement("div");d.className="fb-wide-tile-divider",i.appendChild(d);const c=document.createElement("button");c.type="button",c.className="fb-wide-tile-library fb-file-library-card";const p=document.createElement("span");p.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",p.innerHTML=yn,c.appendChild(p);const f=document.createElement("div");f.style.cssText="font-size:13px;font-weight:600;text-align:center;",f.textContent=k("fromLibrary",e),c.appendChild(f);const m=document.createElement("div");m.style.cssText="font-size:11px;opacity:0.75;text-align:center;",m.textContent=k("libraryHint",e),c.appendChild(m),c.onclick=b=>{b.stopPropagation(),r()},i.appendChild(c)}return xn(i,{onEnter:()=>{const d=i.querySelector(".fb-wide-tile-label");d&&(d.textContent=k("dropToUpload",e))},onLeave:()=>{const d=i.querySelector(".fb-wide-tile-label");d&&(d.textContent=k("clickDragText",e))},activeClass:"fb-drag-over"}),i}function xn(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 Lt(e,t,n,r,o){var a,i;const l=n.resourceIndex.get(t);if((a=l==null?void 0:l.type)!=null&&a.startsWith("video/")){kt(e,t,n,{fileName:(i=l==null?void 0:l.name)!=null?i:"",isReadonly:!1,deps:r}).catch(console.error);return}ke();const s=document.createElement("div");s.className="fb-multi-outer fb-multi-has-files";const u=document.createElement("div");u.className="fb-multi-grid fb-tiles-wrap",s.appendChild(u);const d=wn(t,n,!!r.onRemove,r.onRemove?()=>{var c;return(c=r.onRemove)==null?void 0:c.call(r)}:null,o);for(u.appendChild(d),e.className="file-preview-container",e.removeAttribute("style");e.firstChild;)e.removeChild(e.firstChild);e.appendChild(s)}function bo(e,t,n,r,o=!1){const a=document.createElement("div");a.className=`fb-multi-add-tile fb-multi-add-tile-js${o?" fb-drag-over-tile":""}`;const i=document.createElement("button");i.type="button",i.className="fb-multi-add-upload fb-tile-add fb-file-dropzone";const l=document.createElement("span");l.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",l.innerHTML=gn,i.appendChild(l);const s=document.createElement("span");if(s.className="fb-multi-add-label",s.style.cssText="font-size:11px;font-weight:600;",s.textContent=k(o?"dropToUpload":"clickDragTextMultiple",e),i.appendChild(s),i.onclick=u=>{u.stopPropagation(),n()},a.appendChild(i),t&&r){const u=document.createElement("div");u.className="fb-multi-add-divider",a.appendChild(u);const d=document.createElement("button");d.type="button",d.className="fb-multi-add-library fb-tile-add-library fb-file-library-card",d.setAttribute("aria-label",k("fromLibrary",e));const c=document.createElement("span");c.style.cssText="width:14px;height:14px;display:block;flex-shrink:0;",c.innerHTML=yn,d.appendChild(c),d.appendChild(document.createTextNode(k("fromLibrary",e))),d.onclick=p=>{p.stopPropagation(),r()},a.appendChild(d)}return a}function wn(e,t,n,r,o){var a,i,l;ke();const s=t.resourceIndex.get(e),u=document.createElement("div");u.className="fb-preview-tile fb-checker fb-tile-resource resource-pill",u.dataset.resourceId=e;const d=wt({canRemove:n&&r!==null,removeHandler:r,state:t,resourceId:e,fileName:(a=s==null?void 0:s.name)!=null?a:"",meta:s,replaceHandler:(i=o==null?void 0:o.replaceHandler)!=null?i:null,libraryHandler:(l=o==null?void 0:o.libraryHandler)!=null?l:null});return an(u,e,s,t,d).catch(c=>{console.error("Failed to render tile:",c)}),u}function En(e=!1){const t=document.createElement("div");return t.className=`fb-multi-placeholder fb-checker${e?" fb-drag-over":""}`,t}function vo(e,t,n,r,o,a){const i=document.createElement("div");i.className="fb-meta-line";const l=document.createElement("div");if(l.className="fb-meta-text",t.maxSize&&t.maxSize!==1/0){const d=document.createElement("span");d.textContent=k("hintMaxSize",e,{size:t.maxSize}),l.appendChild(d),l.appendChild(Cn())}const s=Ae(t.accept);if(s.length>0){const d=document.createElement("span");d.className="fb-meta-mono",d.textContent=s.map(c=>c.toUpperCase()).join(", "),l.appendChild(d),l.appendChild(Cn())}const u=document.createElement("span");if(r<1/0)u.textContent=k("fileCountWithMax",e,{count:n,max:r});else{const d=n===1?"fileCountSingle":"fileCountPlural";u.textContent=k(d,e,{count:n})}if(l.appendChild(u),i.appendChild(l),o&&n>1){const d=document.createElement("button");d.type="button",d.className="fb-clear-all-btn",d.textContent=k("clearAll",e),d.onclick=c=>{c.stopPropagation(),window.confirm(k("clearAll",e)+"?")&&a()},i.appendChild(d)}return i}function Cn(){const e=document.createElement("span");return e.className="fb-meta-dot",e}const St=new WeakMap;function go(e){var t;const{container:n,rids:r,state:o,onRemove:a,maxCount:i,isReadonly:l=!1,onLibraryPick:s,element:u,onClearAll:d,openPicker:c}=e;ke();const p=n.closest("[data-files-wrapper]");p&&(p.dataset.resourceIds=JSON.stringify(r!=null?r:[]));const f=St.get(n);for(f&&(f.disconnect(),St.delete(n));n.firstChild;)n.removeChild(n.firstChild);const m=r!=null?r:[],b=i!=null?i:1/0,g=b!==1/0&&m.length>=b,E=!l&&typeof s=="function",h=c!=null?c:(()=>{var y;const L=(y=n.closest("[data-files-wrapper]"))==null?void 0:y.querySelector('input[type="file"]');L&&L.click()});if(l){if(m.length===0){const y=document.createElement("div");y.className="fb-tile-empty-text",y.textContent=k("noFilesSelected",o),n.appendChild(y)}else{const y=document.createElement("div");y.className="fb-multi-readonly-grid",n.appendChild(y);for(const L of m){const R=o.resourceIndex.get(L),q=document.createElement("div");q.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",q.dataset.resourceId=L;const W=wt({canRemove:!1,removeHandler:null,state:o,resourceId:L,fileName:(t=R==null?void 0:R.name)!=null?t:"",meta:R});an(q,L,R,o,W).catch(console.error),q.onclick=async()=>{var K;let Y=null;o.config.getDownloadUrl?Y=o.config.getDownloadUrl(L):o.config.getThumbnail?Y=await o.config.getThumbnail(L):(R==null?void 0:R.file)instanceof File&&(Y=URL.createObjectURL(R.file)),Y?window.open(Y,"_blank"):o.config.downloadFile&&o.config.downloadFile(L,(K=R==null?void 0:R.name)!=null?K:"")},y.appendChild(q)}}return}const x=document.createElement("div");x.className=`fb-multi-outer${m.length>0?" fb-multi-has-files":""}`;const v=document.createElement("div");v.className="fb-multi-grid fb-tiles-wrap",x.appendChild(v),n.appendChild(x);for(let y=0;y<m.length;y++){const L=m[y],R=wn(L,o,a!==null,a?()=>a(L):null);v.appendChild(R)}if(!g){const y=bo(o,E,h,s!=null?s:null);v.appendChild(y)}const w=m.length+(g?0:1),C=()=>{const y=getComputedStyle(v).gridTemplateColumns,L=y?y.split(" ").filter(Boolean).length:0;if(!L)return;const R=w%L,q=R===0?0:L-R,W=b===1/0?q:Math.max(0,b-w),K=Math.min(q,W),Y=v.querySelectorAll(".fb-multi-placeholder");if(Y.length>K)for(let Q=Y.length-1;Q>=K;Q--)Y[Q].remove();else if(Y.length<K)for(let Q=Y.length;Q<K;Q++)v.appendChild(En())};if((b===1/0||b>w)&&v.appendChild(En()),requestAnimationFrame(C),typeof ResizeObserver!="undefined"){const y=new ResizeObserver(()=>C());y.observe(v),St.set(n,y)}if(xn(x,{activeClass:"fb-drag-over",onEnter:()=>{v.querySelectorAll(".fb-multi-placeholder").forEach(L=>{L.classList.add("fb-drag-over")});const y=v.querySelector(".fb-multi-add-tile-js");if(y){y.classList.add("fb-drag-over-tile");const L=y.querySelector(".fb-multi-add-label");L&&(L.textContent=k("dropToUpload",o))}},onLeave:()=>{v.querySelectorAll(".fb-multi-placeholder").forEach(L=>{L.classList.remove("fb-drag-over")});const y=v.querySelector(".fb-multi-add-tile-js");if(y){y.classList.remove("fb-drag-over-tile");const L=y.querySelector(".fb-multi-add-label");L&&(L.textContent=k("clickDragTextMultiple",o))}}}),u){const y=vo(o,u,m.length,b,!!d,d!=null?d:(()=>{}));n.appendChild(y)}}function yo(e,t,n,r){var o,a;const i=t.state,l=document.createElement("div");l.className="space-y-2",l.dataset.filesWrapper=r;const s=document.createElement("input");s.type="file",s.name=r,s.style.display="none",s.accept=kn(e.accept);const u=document.createElement("div");u.className="file-preview-container";const d=t.prefill[e.key],c=Ae(e.accept),p=_e(e.accept),f=(o=e.maxSize)!=null?o:1/0,m={fileUploadHandler(){s.click()},dragHandler(h){h.length>0&&ao({file:h[0],container:u,fieldName:r,state:i,deps:g(),instance:t.instance,allowedExtensions:c,allowedMimes:p,maxSizeMB:f})},setupDrop(h){rt(h,m.dragHandler)},onRemove(){var h;const x=l.querySelector('input[type="hidden"]'),v=x==null?void 0:x.value;v&<((h=i.resourceIndex.get(v))==null?void 0:h.file),x&&(x.value=""),E()}},b=()=>{const h=!!(i.config.pickExistingFiles&&!e.disableLibrary);return{replaceHandler:i.config.uploadFile?()=>s.click():null,libraryHandler:h?()=>{po(i,e,u,l,r,r,async x=>{Lt(u,x,i,g(),b())},t.instance).catch(x=>{console.error("Library pick failed:",x)})}:null}},g=()=>({picker:s,fileUploadHandler:m.fileUploadHandler,dragHandler:m.dragHandler,setupDrop:m.setupDrop,onRemove:m.onRemove,onAfterUpload:(h,x)=>{Lt(h,x,i,g(),b())}}),E=()=>{for(ke(),u.className="file-preview-container",u.removeAttribute("style");u.firstChild;)u.removeChild(u.firstChild);const h=b().libraryHandler,x=ho(i,h!==null,m.fileUploadHandler,h,!1,$e(e,i));u.appendChild(x),rt(u,m.dragHandler)};if(d){mo(d,u,r,l,i,g(),b());const h=i.resourceIndex.get(d);(a=h==null?void 0:h.type)!=null&&a.startsWith("video/")&&rt(u,m.dragHandler)}else E();s.onchange=()=>{s.files&&s.files.length>0&&m.dragHandler(s.files)},l.appendChild(u),l.appendChild(s),n.appendChild(l)}function kn(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 $n(e,t,n,r,o){var a,i;const l=t.state,s=document.createElement("div");s.className="space-y-2",s.dataset.filesWrapper=r;const u=document.createElement("input");u.type="file",u.name=r,u.multiple=!0,u.style.display="none",u.accept=kn(e.accept);const d=document.createElement("div");d.className="files-list-wrapper";const c=document.createElement("div");c.className="files-list",s.appendChild(u),s.appendChild(d),d.appendChild(c);const p=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];yt(p,l.resourceIndex),s.dataset.resourceIds=JSON.stringify(p);const f={maxCount:o,allowedExtensions:Ae(e.accept),allowedMimes:_e(e.accept),maxSize:(i=(a=e.maxSize)!=null?a:e.maxSizeMB)!=null?i:1/0},m=()=>{u.click()},b=l.config.pickExistingFiles&&!e.disableLibrary?()=>{fo(l,e,s,r,p,o,g,t.instance).catch(E=>{console.error("Library pick failed:",E)})}:null;function g(){const E=oe(e,l);go({container:c,rids:p,state:l,onRemove:E?null:h=>{var x;lt((x=l.resourceIndex.get(h))==null?void 0:x.file);const v=p.indexOf(h);v>-1&&p.splice(v,1),g()},maxCount:o<1/0?o:void 0,isReadonly:E,onLibraryPick:E?null:b,element:e,onClearAll:E?void 0:()=>{p.splice(0),g()},openPicker:m})}so(d,p,l,g,f,r,t.instance),uo(u,p,l,g,f,r,t.instance),g(),n.appendChild(s)}function xo(e,t,n,r){$n(e,t,n,r,1/0)}function wo(e,t,n,r){var o;$n(e,t,n,r,(o=e.maxCount)!=null?o:1/0)}function Eo(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 Co(e,t,n,r,o){var a,i;const l="minCount"in n&&(a=n.minCount)!=null?a:0,s="maxCount"in n&&(i=n.maxCount)!=null?i:1/0;n.required&&t.length===0&&o.push(`${e}: ${k("required",r)}`),t.length<l&&o.push(`${e}: ${k("minFiles",r,{min:l})}`),t.length>s&&o.push(`${e}: ${k("maxFiles",r,{max:s})}`)}function Ln(e,t,n,r,o){var a,i;const l="accept"in n?n.accept:void 0,s=Ae(l),u=_e(l);if(s.length===0&&u.length===0)return;const d=s.join(", "),c=u.join(", ");for(const p of t){const f=r.resourceIndex.get(p),m=(a=f==null?void 0:f.name)!=null?a:p;if(s.length>0&&!Be(m,s)){o.push(`${e}: ${k("invalidFileExtension",r,{name:m,formats:d})}`);continue}if(u.length>0&&!(f!=null&&f.inferredFromExtension)){const b=(i=f==null?void 0:f.type)!=null?i:"";Ke(b,u)||o.push(`${e}: ${k("invalidFileMime",r,{name:m,type:b,mimes:c})}`)}}}function Sn(e,t,n,r,o){var a;const i="maxSize"in n&&(a=n.maxSize)!=null?a:1/0;if(i!==1/0)for(const l of t){const s=r.resourceIndex.get(l);s&&s.size>i*1024*1024&&o.push(`${e}: ${k("fileTooLarge",r,{name:s.name,maxSize:i})}`)}}function ko(e,t,n){const{scopeRoot:r,skipValidation:o,path:a,state:i}=n,l=[],s=Ce(a,t),u=Eo(r,s);return o||(Co(t,u,e,i,l),Ln(t,u,e,i,l),Sn(t,u,e,i,l)),{value:u,errors:l}}function $o(e,t,n){var r;const{scopeRoot:o,skipValidation:a,state:i}=n,l=[],s=o.querySelector(`input[name$="${t}"][type="hidden"]`),u=(r=s==null?void 0:s.value)!=null?r:"";return!a&&e.required&&u===""?(l.push(`${t}: ${k("required",i)}`),{value:null,errors:l}):(!a&&u!==""&&(Ln(t,[u],e,i,l),Sn(t,[u],e,i,l)),{value:u||null,errors:l})}function Tn(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?ko(e,t,n):$o(e,t,n)}function Lo(e,t,n,r){const o=t.state,a=t.prefill[e.key],i=typeof a=="string"?a:"";if(i){yt([i],o.resourceIndex);const l=document.createElement("input");l.type="hidden",l.name=r,l.value=i,n.appendChild(l),$t(i,o).then(s=>{s.classList.add("fb-single-readonly-filled","fb-readonly-tile","fb-checker"),n.appendChild(s)}).catch(console.error)}else n.appendChild(So(o))}function So(e){ke();const t=document.createElement("div");return t.style.cssText=`
|
|
1011
|
+
<div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${se(k("uploadingFile",l))}</div>
|
|
1012
|
+
</div>`;let b;try{b=await yn(o,l)}catch(h){throw m&&s!=null&&s.onAfterUpload?s.onAfterUpload(i,m):s!=null&&s.onRemove?s.onRemove():Lt(i,l),h}l.resourceIndex.set(b,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:o}),m&&m!==b&&qe((n=l.resourceIndex.get(m))==null?void 0:n.file);let v=p;v||(v=document.createElement("input"),v.type="hidden",v.name=a,(r=i.parentElement)==null||r.appendChild(v)),v.value=b;const w=o.type.startsWith("video/");!w&&s!=null&&s.onAfterUpload?s.onAfterUpload(i,b):!w&&s?wo(i,b,l,s).catch(console.error):Mt(i,b,l,{fileName:o.name,isReadonly:!1,deps:s}).catch(console.error),c&&!l.config.readonly&&c.triggerOnChange(a,b)}function ko(e,t,n,r){const o=e.filter(m=>!je(m.name,n.allowedExtensions)),i=e.filter(m=>je(m.name,n.allowedExtensions)),a=i.filter(m=>!Xe(m.type,n.allowedMimes)),l=i.filter(m=>Xe(m.type,n.allowedMimes)),s=l.filter(m=>!it(m,n.maxSize)),c=l.filter(m=>it(m,n.maxSize)),u=n.maxCount===1/0?c.length:Math.max(0,n.maxCount-t),d=c.slice(0,u),f=c.length-d.length,p=[];if(o.length>0){const m=n.allowedExtensions.join(", "),b=o.map(v=>v.name).join(", ");p.push(k("invalidFileExtension",r,{name:b,formats:m}))}if(a.length>0){const m=n.allowedMimes.join(", "),b=a.map(v=>v.name).join(", ");p.push(k("invalidFileMime",r,{name:b,type:a.map(v=>v.type).join(", "),mimes:m}))}if(s.length>0){const m=s.map(b=>b.name).join(", ");p.push(k("fileTooLarge",r,{name:m,maxSize:n.maxSize}))}return f>0&&p.push(k("filesLimitExceeded",r,{skipped:f,max:n.maxCount})),{accepted:d,errorMessage:p.join(" \u2022 ")}}async function $o(e){var t;const{accepted:n,listEl:r,state:o,shouldHideAddTile:i,buildSuccessTile:a,prepareForUpload:l}=e;if(r&&i){const u=St(r),d=(t=u.querySelector(".fb-multi-add-tile-js"))!=null?t:u.querySelector(".fb-tile-add");d&&(d.style.display="none")}l==null||l();const s=new Array(n.length).fill(null),c=[];return await Promise.allSettled(n.map(async(u,d)=>{const f=Zr(u.name,o);r&&St(r).appendChild(f);try{const p=await yn(u,o);o.resourceIndex.set(p,{name:u.name,type:u.type,size:u.size,uploadedAt:new Date,file:u}),s[d]=p,a&&f.parentNode?f.replaceWith(a(p)):f.remove()}catch(p){const m=p instanceof Error?p:new Error(String(p)),b=m.cause,v=b instanceof Error?b:b!==void 0?new Error(String(b)):m;c.push({file:u,error:v}),f.remove()}})),{failures:c,orderedIds:s}}function So(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 xn(e,t,n,r){const{resourceIds:o,state:i,updateCallback:a,constraints:l,pathKey:s,instance:c,buildSuccessTile:u,prepareForUpload:d,coordinator:f}=e,{accepted:p,errorMessage:m}=ko(t,f.getOccupiedCount(),l,i);r&&(m?Se(r,m):Ge(r));const b=f.beginBatch(p.length),v=f.getOccupiedCount()>=l.maxCount,{failures:w,orderedIds:h}=await $o({accepted:p,listEl:n,state:i,shouldHideAddTile:v,buildSuccessTile:u,prepareForUpload:d});b.setResults(h),c&&s&&!i.config.readonly&&c.triggerOnChange(s,o);const{wasLast:y}=b.end();if(y&&a(),r){const g=So(m,w,i);g?Se(r,g):Ge(r)}}function Lo(e){const{filesContainer:t}=e;st(t,async n=>{var r;const o=(r=t.querySelector(".files-list"))!=null?r:t;await xn(e,Array.from(n),o,t)})}function To(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,i=(r=o==null?void 0:o.querySelector(".files-list"))!=null?r:null;await xn(e,Array.from(t.files),i,o),t.value=""}}function wn(e){var t,n;if(!e.accept)return;if(typeof e.accept=="string"){const l=Me(e.accept);return l.length>0?{extensions:l}:void 0}const r=(t=e.accept.extensions)!=null?t:[],o=(n=e.accept.mime)!=null?n:[],i=r.map(l=>l.toLowerCase());if(i.length===0&&o.length===0)return;const a={};return i.length>0&&(a.extensions=i),o.length>0&&(a.mime=o),a}function Cn(e,t,n,r,o){if(!je(e.name,t)){const i=t.join(", ");return k("invalidFileExtension",o,{name:e.name,formats:i})}if(!Xe(e.type,n)){const i=n.join(", ");return k("invalidFileMime",o,{name:e.name,type:e.type,mimes:i})}return sn(e.size,r)?null:k("fileTooLarge",o,{name:e.name,maxSize:r})}function En(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 kn(e,t){return e instanceof Error&&e.message?e.message:k("pickerError",t)}async function Ao(e){var t;const{state:n,element:r,wrapper:o,fieldPath:i,resourceIds:a,maxCount:l,updateCallback:s,instance:c,coordinator:u,list:d,buildSuccessTile:f}=e;if(!n.config.pickExistingFiles)return;const p=Me(r.accept),m=Ye(r.accept),b=(t=r.maxSize)!=null?t:1/0,v=u.getAllKnownRids(),w=new Set(v),h=l===1/0?1/0:Math.max(0,l-u.getOccupiedCount());let y;try{y=await n.config.pickExistingFiles({fieldPath:i,mode:"multiple",accept:wn(r),maxSizeMB:b===1/0?void 0:b,remainingSlots:h===1/0?void 0:h,selectedResourceIds:v})}catch(B){Se(o,kn(B,n));return}if(y.length===0)return;const g=new Set,C=y.filter(B=>w.has(B.resourceId)||g.has(B.resourceId)?!1:(g.add(B.resourceId),!0)).filter(B=>Cn(B,p,m,b,n)===null),E=l===1/0?C.length:Math.max(0,l-u.getOccupiedCount()),x=C.slice(0,E),$=C.length-x.length;if(x.length===0){$>0&&Se(o,k("filesLimitExceeded",n,{skipped:$,max:l}));return}Ge(o),$>0&&Se(o,k("filesLimitExceeded",n,{skipped:$,max:l}));for(const B of x)En(B,n);const z=x.map(B=>B.resourceId),q=u.beginBatch(x.length);q.setResults(z),n.config.readonly||c.triggerOnChange(i,a);const{wasLast:K}=q.end();if(K)s();else{const B=St(d);for(const M of z)B.appendChild(f(M))}}async function Fo(e,t,n,r,o,i,a,l){var s,c;if(!e.config.pickExistingFiles)return;const u=Me(t.accept),d=Ye(t.accept),f=(s=t.maxSize)!=null?s:1/0;let p;try{p=await e.config.pickExistingFiles({fieldPath:i,mode:"single",accept:wn(t),maxSizeMB:f===1/0?void 0:f,selectedResourceIds:[]})}catch(h){Se(n,kn(h,e));return}if(p.length===0)return;const m=p[0],b=Cn(m,u,d,f,e);if(b!==null){Se(n,b);return}Ge(n),En(m,e);let v=r.querySelector('input[type="hidden"]');v||(v=document.createElement("input"),v.type="hidden",v.name=o,r.appendChild(v));const w=v.value||null;w&&w!==m.resourceId&&qe((c=e.resourceIndex.get(w))==null?void 0:c.file),v.value=m.resourceId,await a(m.resourceId),e.config.readonly||l.triggerOnChange(i,m.resourceId)}const $n='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',Sn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function Mo(e,t,n,r,o,i,a){var l;at(e,o.resourceIndex);const s=o.resourceIndex.get(e);(l=s==null?void 0:s.type)!=null&&l.startsWith("video/")?Mt(t,e,o,{fileName:e,isReadonly:!1,deps:i}).catch(console.error):Nt(t,e,o,i,a);const c=document.createElement("input");c.type="hidden",c.name=n,c.value=e,r.appendChild(c)}function zo(e,t,n,r,o=!1,i=""){$e();const a=document.createElement("div");a.className=`fb-wide-tile${t?" fb-file-card-row":""}${o?" fb-drag-over":""}`;const l=document.createElement("button");l.type="button",l.className="fb-wide-tile-upload fb-file-dropzone";const s=document.createElement("span");s.style.cssText="width:36px;height:36px;display:block;flex-shrink:0;",s.innerHTML=$n,l.appendChild(s);const c=document.createElement("div");if(c.className="fb-wide-tile-label",c.style.cssText="font-size:14px;font-weight:600;",c.textContent=k(o?"dropToUpload":"clickDragText",e),l.appendChild(c),i){const u=document.createElement("div");u.style.cssText="font-size:11px;opacity:0.65;margin-top:2px;",u.textContent=i,l.appendChild(u)}if(l.onclick=u=>{u.stopPropagation(),n()},a.appendChild(l),t&&r){const u=document.createElement("button");u.type="button",u.className="fb-wide-tile-library fb-file-library-card";const d=document.createElement("span");d.className="fb-wide-tile-library-icon",d.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",d.innerHTML=Sn,u.appendChild(d);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),u.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),u.appendChild(p),u.onclick=m=>{m.stopPropagation(),r()},a.appendChild(u)}return Ln(a,{onEnter:()=>{const u=a.querySelector(".fb-wide-tile-label");u&&(u.textContent=k("dropToUpload",e))},onLeave:()=>{const u=a.querySelector(".fb-wide-tile-label");u&&(u.textContent=k("clickDragText",e))},activeClass:"fb-drag-over"}),a}function Ln(e,t){let n=0;e.addEventListener("dragover",r=>{r.preventDefault()}),e.addEventListener("dragenter",r=>{r.preventDefault(),n++,n===1&&(e.classList.add(t.activeClass),t.onEnter())}),e.addEventListener("dragleave",r=>{r.preventDefault(),n=Math.max(0,n-1),n===0&&(e.classList.remove(t.activeClass),t.onLeave())}),e.addEventListener("drop",()=>{n=0,e.classList.remove(t.activeClass),t.onLeave()})}function Nt(e,t,n,r,o){var i,a;const l=n.resourceIndex.get(t);if((i=l==null?void 0:l.type)!=null&&i.startsWith("video/")){Mt(e,t,n,{fileName:(a=l==null?void 0:l.name)!=null?a:"",isReadonly:!1,deps:r}).catch(console.error);return}$e();const s=document.createElement("div");s.className="fb-multi-outer fb-multi-has-files";const c=document.createElement("div");c.className="fb-multi-grid fb-tiles-wrap",s.appendChild(c);const u=It(t,n,!!r.onRemove,r.onRemove?()=>{var d;return(d=r.onRemove)==null?void 0:d.call(r)}:null,o);for(c.appendChild(u),e.className="file-preview-container",e.removeAttribute("style");e.firstChild;)e.removeChild(e.firstChild);e.appendChild(s)}function No(e,t,n,r,o=!1){const i=document.createElement("div");i.className=`fb-multi-add-tile fb-multi-add-tile-js${o?" fb-drag-over-tile":""}`;const a=document.createElement("button");a.type="button",a.className="fb-multi-add-upload fb-tile-add fb-file-dropzone";const l=document.createElement("span");l.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",l.innerHTML=$n,a.appendChild(l);const s=document.createElement("span");if(s.className="fb-multi-add-label",s.style.cssText="font-size:11px;font-weight:600;",s.textContent=k(o?"dropToUpload":"clickDragTextMultiple",e),a.appendChild(s),a.onclick=c=>{c.stopPropagation(),n()},i.appendChild(a),t&&r){const c=document.createElement("div");c.className="fb-multi-add-divider",i.appendChild(c);const u=document.createElement("button");u.type="button",u.className="fb-multi-add-library fb-tile-add-library fb-file-library-card",u.setAttribute("aria-label",k("fromLibrary",e));const d=document.createElement("span");d.style.cssText="width:14px;height:14px;display:block;flex-shrink:0;",d.innerHTML=Sn,u.appendChild(d),u.appendChild(document.createTextNode(k("fromLibrary",e))),u.onclick=f=>{f.stopPropagation(),r()},i.appendChild(u)}return i}function It(e,t,n,r,o){var i,a,l;$e();const s=t.resourceIndex.get(e),c=document.createElement("div");c.className="fb-preview-tile fb-checker fb-tile-resource resource-pill",c.dataset.resourceId=e;const u=Tt({canRemove:n&&r!==null,removeHandler:r,state:t,resourceId:e,fileName:(i=s==null?void 0:s.name)!=null?i:"",meta:s,replaceHandler:(a=o==null?void 0:o.replaceHandler)!=null?a:null,libraryHandler:(l=o==null?void 0:o.libraryHandler)!=null?l:null});return bn(c,e,s,t,u).catch(d=>{console.error("Failed to render tile:",d)}),c}function Tn(e=!1){const t=document.createElement("div");return t.className=`fb-multi-placeholder fb-checker${e?" fb-drag-over":""}`,t}function Io(e,t,n,r,o,i){const a=document.createElement("div");a.className="fb-meta-line";const l=document.createElement("div");if(l.className="fb-meta-text",t.maxSize&&t.maxSize!==1/0){const u=document.createElement("span");u.textContent=k("hintMaxSize",e,{size:t.maxSize}),l.appendChild(u),l.appendChild(An())}const s=Me(t.accept);if(s.length>0){const u=document.createElement("span");u.className="fb-meta-mono",u.textContent=s.map(d=>d.toUpperCase()).join(", "),l.appendChild(u),l.appendChild(An())}const c=document.createElement("span");if(r<1/0)c.textContent=k("fileCountWithMax",e,{count:n,max:r});else{const u=n===1?"fileCountSingle":"fileCountPlural";c.textContent=k(u,e,{count:n})}if(l.appendChild(c),a.appendChild(l),o&&n>1){const u=document.createElement("button");u.type="button",u.className="fb-clear-all-btn",u.textContent=k("clearAll",e),u.onclick=d=>{d.stopPropagation(),window.confirm(k("clearAll",e)+"?")&&i()},a.appendChild(u)}return a}function An(){const e=document.createElement("span");return e.className="fb-meta-dot",e}const Ze=new WeakMap;function qo(e){const t=Ze.get(e);t&&(t.disconnect(),Ze.delete(e)),e.querySelectorAll(".fb-multi-placeholder").forEach(n=>n.remove())}function Ro(e){var t;const{container:n,rids:r,state:o,onRemove:i,maxCount:a,isReadonly:l=!1,onLibraryPick:s,element:c,onClearAll:u,openPicker:d}=e;$e();const f=n.closest("[data-files-wrapper]");f&&(f.dataset.resourceIds=JSON.stringify(r!=null?r:[]));const p=Ze.get(n);for(p&&(p.disconnect(),Ze.delete(n));n.firstChild;)n.removeChild(n.firstChild);const m=r!=null?r:[],b=a!=null?a:1/0,v=b!==1/0&&m.length>=b,w=!l&&typeof s=="function",h=d!=null?d:(()=>{var x;const $=(x=n.closest("[data-files-wrapper]"))==null?void 0:x.querySelector('input[type="file"]');$&&$.click()});if(l){if(m.length===0){const x=document.createElement("div");x.className="fb-tile-empty-text",x.textContent=k("noFilesSelected",o),n.appendChild(x)}else{const x=document.createElement("div");x.className="fb-multi-readonly-grid",n.appendChild(x);for(const $ of m){const z=o.resourceIndex.get($),q=document.createElement("div");q.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",q.dataset.resourceId=$;const K=Tt({canRemove:!1,removeHandler:null,state:o,resourceId:$,fileName:(t=z==null?void 0:z.name)!=null?t:"",meta:z});bn(q,$,z,o,K).catch(console.error),q.onclick=async()=>{var B;let M=null;o.config.getDownloadUrl?M=o.config.getDownloadUrl($):o.config.getThumbnail?M=await o.config.getThumbnail($):(z==null?void 0:z.file)instanceof File&&(M=URL.createObjectURL(z.file)),M?window.open(M,"_blank"):o.config.downloadFile&&o.config.downloadFile($,(B=z==null?void 0:z.name)!=null?B:"")},x.appendChild(q)}}return}const y=document.createElement("div");y.className=`fb-multi-outer${m.length>0?" fb-multi-has-files":""}`;const g=document.createElement("div");g.className="fb-multi-grid fb-tiles-wrap",y.appendChild(g),n.appendChild(y);for(let x=0;x<m.length;x++){const $=m[x],z=It($,o,i!==null,i?()=>i($):null);g.appendChild(z)}if(!v){const x=No(o,w,h,s!=null?s:null);g.appendChild(x)}const C=m.length+(v?0:1),E=()=>{const x=getComputedStyle(g).gridTemplateColumns,$=x?x.split(" ").filter(Boolean).length:0;if(!$)return;const z=C%$,q=z===0?0:$-z,K=b===1/0?q:Math.max(0,b-C),B=Math.min(q,K),M=g.querySelectorAll(".fb-multi-placeholder");if(M.length>B)for(let D=M.length-1;D>=B;D--)M[D].remove();else if(M.length<B)for(let D=M.length;D<B;D++)g.appendChild(Tn())};if((b===1/0||b>C)&&g.appendChild(Tn()),requestAnimationFrame(E),typeof ResizeObserver!="undefined"){const x=new ResizeObserver(()=>E());x.observe(g),Ze.set(n,x)}if(Ln(y,{activeClass:"fb-drag-over",onEnter:()=>{g.querySelectorAll(".fb-multi-placeholder").forEach($=>{$.classList.add("fb-drag-over")});const x=g.querySelector(".fb-multi-add-tile-js");if(x){x.classList.add("fb-drag-over-tile");const $=x.querySelector(".fb-multi-add-label");$&&($.textContent=k("dropToUpload",o))}},onLeave:()=>{g.querySelectorAll(".fb-multi-placeholder").forEach($=>{$.classList.remove("fb-drag-over")});const x=g.querySelector(".fb-multi-add-tile-js");if(x){x.classList.remove("fb-drag-over-tile");const $=x.querySelector(".fb-multi-add-label");$&&($.textContent=k("clickDragTextMultiple",o))}}}),c){const x=Io(o,c,m.length,b,!!u,u!=null?u:(()=>{}));n.appendChild(x)}}function Bo(e,t,n,r){var o,i;const a=t.state,l=document.createElement("div");l.className="space-y-2",l.dataset.filesWrapper=r;const s=document.createElement("input");s.type="file",s.name=r,s.style.display="none",s.accept=Fn(e.accept);const c=document.createElement("div");c.className="file-preview-container";const u=t.prefill[e.key],d=Me(e.accept),f=Ye(e.accept),p=(o=e.maxSize)!=null?o:1/0,m={fileUploadHandler(){s.click()},dragHandler(h){h.length>0&&Eo({file:h[0],container:c,fieldName:r,state:a,deps:v(),instance:t.instance,allowedExtensions:d,allowedMimes:f,maxSizeMB:p})},setupDrop(h){st(h,m.dragHandler)},onRemove(){var h;const y=l.querySelector('input[type="hidden"]'),g=y==null?void 0:y.value;g&&qe((h=a.resourceIndex.get(g))==null?void 0:h.file),y&&(y.value=""),w()}},b=()=>{const h=!!(a.config.pickExistingFiles&&!e.disableLibrary);return{replaceHandler:a.config.uploadFile?()=>s.click():null,libraryHandler:h?()=>{Fo(a,e,c,l,r,r,async y=>{Nt(c,y,a,v(),b())},t.instance).catch(y=>{console.error("Library pick failed:",y)})}:null}},v=()=>({picker:s,fileUploadHandler:m.fileUploadHandler,dragHandler:m.dragHandler,setupDrop:m.setupDrop,onRemove:m.onRemove,onAfterUpload:(h,y)=>{Nt(h,y,a,v(),b())}}),w=()=>{for($e(),c.className="file-preview-container",c.removeAttribute("style");c.firstChild;)c.removeChild(c.firstChild);const h=b().libraryHandler,y=zo(a,h!==null,m.fileUploadHandler,h,!1,Le(e,a));c.appendChild(y),st(c,m.dragHandler)};if(u){Mo(u,c,r,l,a,v(),b());const h=a.resourceIndex.get(u);(i=h==null?void 0:h.type)!=null&&i.startsWith("video/")&&st(c,m.dragHandler)}else w();s.onchange=()=>{s.files&&s.files.length>0&&m.dragHandler(s.files)},l.appendChild(c),l.appendChild(s),n.appendChild(l)}function Fn(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 Mn(e,t,n,r,o){var i,a;const l=t.state,s=document.createElement("div");s.className="space-y-2",s.dataset.filesWrapper=r;const c=document.createElement("input");c.type="file",c.name=r,c.multiple=!0,c.style.display="none",c.accept=Fn(e.accept);const u=document.createElement("div");u.className="files-list-wrapper";const d=document.createElement("div");d.className="files-list",s.appendChild(c),s.appendChild(u),u.appendChild(d);const f=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];$t(f,l.resourceIndex),s.dataset.resourceIds=JSON.stringify(f);const p={maxCount:o,allowedExtensions:Me(e.accept),allowedMimes:Ye(e.accept),maxSize:(a=(i=e.maxSize)!=null?i:e.maxSizeMB)!=null?a:1/0},m=()=>{c.click()},b=l.config.pickExistingFiles&&!e.disableLibrary?()=>{Ao({state:l,element:e,wrapper:s,fieldPath:r,resourceIds:f,maxCount:o,updateCallback:v,instance:t.instance,coordinator:z,list:d,buildSuccessTile:q}).catch(M=>{console.error("Library pick failed:",M)})}:null;function v(){const M=ae(e,l);Ro({container:d,rids:f,state:l,onRemove:M?null:D=>{var J,Q;qe((J=l.resourceIndex.get(D))==null?void 0:J.file);const ne=f.indexOf(D);ne>-1&&f.splice(ne,1),z.hasInFlightBatches()?(x.add(D),(Q=d.querySelector(`[data-resource-id="${D}"]`))==null||Q.remove(),s.dataset.resourceIds=JSON.stringify(f)):v(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f)},maxCount:o<1/0?o:void 0,isReadonly:M,onLibraryPick:M?null:b,element:e,onClearAll:M?void 0:()=>{var D,J;for(const Q of f)qe((D=l.resourceIndex.get(Q))==null?void 0:D.file);if(f.splice(0),z.hasInFlightBatches()){const Q=d.querySelectorAll("[data-resource-id]");for(const ne of Q){const he=ne.dataset.resourceId;he&&(qe((J=l.resourceIndex.get(he))==null?void 0:J.file),x.add(he)),ne.remove()}s.dataset.resourceIds=JSON.stringify(f)}else v();t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f)},openPicker:m})}let w=0,h=0,y=0,g=0;const C=new Map,E=new Map,x=new Set,$=()=>{for(var M;C.has(g);){const D=g,J=C.get(D);C.delete(D),g+=1;const Q=(M=E.get(D))!=null?M:0;E.delete(D),w-=Q;for(const ne of J)if(ne!==null){if(x.has(ne)){x.delete(ne);continue}f.push(ne)}}s.dataset.resourceIds=JSON.stringify(f)},z={getOccupiedCount:()=>f.length+w,getAllKnownRids:()=>{const M=[...f];for(const D of C.values())for(const J of D)J!==null&&M.push(J);return M},hasInFlightBatches:()=>h>0||E.size>0,wasRemovedDuringBatch:M=>x.has(M),beginBatch:M=>{w+=M,h+=1;const D=y++;return E.set(D,M),{setResults:J=>{C.set(D,J),$()},end:()=>{h-=1;const J=h===0&&E.size===0;return J&&x.clear(),{wasLast:J}}}}},q=M=>{const D=ae(e,l);return It(M,l,!D,D?null:()=>{var J,Q,ne;qe((J=l.resourceIndex.get(M))==null?void 0:J.file);const he=f.indexOf(M);if(he>-1){f.splice(he,1),z.hasInFlightBatches()?(x.add(M),(Q=d.querySelector(`[data-resource-id="${M}"]`))==null||Q.remove(),s.dataset.resourceIds=JSON.stringify(f)):v(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f);return}x.add(M),(ne=d.querySelector(`[data-resource-id="${M}"]`))==null||ne.remove(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f)})},K=()=>qo(d),B={resourceIds:f,state:l,updateCallback:v,constraints:p,pathKey:r,instance:t.instance,buildSuccessTile:q,prepareForUpload:K,coordinator:z};Lo({...B,filesContainer:u}),To({...B,filesPicker:c}),v(),n.appendChild(s)}function Ho(e,t,n,r){Mn(e,t,n,r,1/0)}function Do(e,t,n,r){var o;Mn(e,t,n,r,(o=e.maxCount)!=null?o:1/0)}function jo(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 Oo(e,t,n,r,o){var i,a;const l="minCount"in n&&(i=n.minCount)!=null?i:0,s="maxCount"in n&&(a=n.maxCount)!=null?a:1/0;n.required&&t.length===0&&o.push(`${e}: ${k("required",r)}`),t.length<l&&o.push(`${e}: ${k("minFiles",r,{min:l})}`),t.length>s&&o.push(`${e}: ${k("maxFiles",r,{max:s})}`)}function zn(e,t,n,r,o){var i,a;const l="accept"in n?n.accept:void 0,s=Me(l),c=Ye(l);if(s.length===0&&c.length===0)return;const u=s.join(", "),d=c.join(", ");for(const f of t){const p=r.resourceIndex.get(f),m=(i=p==null?void 0:p.name)!=null?i:f;if(s.length>0&&!je(m,s)){o.push(`${e}: ${k("invalidFileExtension",r,{name:m,formats:u})}`);continue}if(c.length>0&&!(p!=null&&p.inferredFromExtension)){const b=(a=p==null?void 0:p.type)!=null?a:"";Xe(b,c)||o.push(`${e}: ${k("invalidFileMime",r,{name:m,type:b,mimes:d})}`)}}}function Nn(e,t,n,r,o){var i;const a="maxSize"in n&&(i=n.maxSize)!=null?i:1/0;if(a!==1/0)for(const l of t){const s=r.resourceIndex.get(l);s&&s.size>a*1024*1024&&o.push(`${e}: ${k("fileTooLarge",r,{name:s.name,maxSize:a})}`)}}function Uo(e,t,n){const{scopeRoot:r,skipValidation:o,path:i,state:a}=n,l=[],s=ke(i,t),c=jo(r,s);return o||(Oo(t,c,e,a,l),zn(t,c,e,a,l),Nn(t,c,e,a,l)),{value:c,errors:l}}function Po(e,t,n){var r;const{scopeRoot:o,skipValidation:i,state:a}=n,l=[],s=o.querySelector(`input[name$="${t}"][type="hidden"]`),c=(r=s==null?void 0:s.value)!=null?r:"";return!i&&e.required&&c===""?(l.push(`${t}: ${k("required",a)}`),{value:null,errors:l}):(!i&&c!==""&&(zn(t,[c],e,a,l),Nn(t,[c],e,a,l)),{value:c||null,errors:l})}function In(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?Uo(e,t,n):Po(e,t,n)}function Wo(e,t,n,r){const o=t.state,i=t.prefill[e.key],a=typeof i=="string"?i:"";if(a){$t([a],o.resourceIndex);const l=document.createElement("input");l.type="hidden",l.name=r,l.value=a,n.appendChild(l),zt(a,o).then(s=>{s.classList.add("fb-single-readonly-filled","fb-readonly-tile","fb-checker"),n.appendChild(s)}).catch(console.error)}else n.appendChild(Vo(o))}function Vo(e){$e();const t=document.createElement("div");return t.style.cssText=`
|
|
729
1013
|
height: 220px;
|
|
730
1014
|
display:flex;
|
|
731
1015
|
align-items:center;
|
|
@@ -733,7 +1017,7 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
733
1017
|
background: repeating-linear-gradient(45deg, #fafafa 0 6px, #f3f4f6 6px 12px);
|
|
734
1018
|
border-radius:0.75rem;
|
|
735
1019
|
border:1px solid #e2e8f0;
|
|
736
|
-
`,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${
|
|
1020
|
+
`,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${se(k("noFileSelected",e))}</div>`,t}function qn(e,t,n,r,o){$t(e,t.resourceIndex),$e();const i=document.createElement("div");if(i.dataset.filesWrapper=r,i.dataset.resourceIds=JSON.stringify(e),n.appendChild(i),e.length===0){const s=document.createElement("div");s.className="fb-tile-empty-text",s.textContent=k("noFilesSelected",t),i.appendChild(s);return}const a=document.createElement("div");a.className="fb-multi-readonly-grid",i.appendChild(a);const l=e.map(()=>{const s=document.createElement("div");return s.className="fb-readonly-tile fb-checker fb-tile",a.appendChild(s),s});for(let s=0;s<e.length;s++){const c=e[s],u=l[s],d=t.resourceIndex.get(c);zt(c,t,d==null?void 0:d.name).then(f=>{f.classList.add("fb-readonly-tile","fb-checker","fb-tile-resource"),f.dataset.resourceId=c,u.replaceWith(f)}).catch(()=>{const f=document.createElement("div");f.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",f.dataset.resourceId=c,u.replaceWith(f)})}}function Ko(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];qn(i,t.state,n,r)}function _o(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];qn(i,t.state,n,r)}function Jo(e,t,n,r){ae(e,t.state,t)?Wo(e,t,n,r):Bo(e,t,n,r)}function Yo(e,t,n,r){ae(e,t.state,t)?Ko(e,t,n,r):Ho(e,t,n,r)}function Xo(e,t,n,r){ae(e,t.state,t)?_o(e,t,n,r):Do(e,t,n,r)}function Rn(e,t,n,r){const{scopeRoot:o,state:i}=r;if(e.type==="files"||"multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateFileField: Expected array for multiple file field "${t}", got ${typeof n}`);return}n.forEach(l=>{l&&typeof l=="string"&&at(l,i.resourceIndex)});const a=o.querySelector(`[data-files-wrapper="${t}"]`);a?a.dataset.resourceIds=JSON.stringify(n):console.warn(`updateFileField: [data-files-wrapper="${t}"] not found in DOM; data-resource-ids not updated`)}else{const a=o.querySelector(`input[name="${t}"][type="hidden"]`);if(!a){console.warn(`updateFileField: Hidden input not found for file field "${t}"`);return}a.value=n!=null?String(n):"",n&&typeof n=="string"&&(at(n,i.resourceIndex),console.info(`updateFileField: File field "${t}" updated. Preview update requires re-render.`))}}function Oe(e){return e?e.toUpperCase():"#000000"}function qt(e){return/^#[0-9A-F]{6}$/i.test(e)||/^#[0-9A-F]{3}$/i.test(e)}function Bn(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 Hn(e){const t=document.createElement("div");t.className="flex items-center gap-2";const n=Oe(e),r=document.createElement("div");r.style.cssText=`
|
|
737
1021
|
width: 32px;
|
|
738
1022
|
height: 32px;
|
|
739
1023
|
border-radius: var(--fb-border-radius);
|
|
@@ -743,11 +1027,11 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
743
1027
|
font-size: var(--fb-font-size);
|
|
744
1028
|
color: var(--fb-text-color);
|
|
745
1029
|
font-family: var(--fb-font-family-mono, monospace);
|
|
746
|
-
`,o.textContent=n,t.appendChild(r),t.appendChild(o),t}function
|
|
1030
|
+
`,o.textContent=n,t.appendChild(r),t.appendChild(o),t}function Dn(e,t,n){const r=Oe(e),o=document.createElement("div");o.className="colour-picker-wrapper",o.style.cssText=`
|
|
747
1031
|
display: flex;
|
|
748
1032
|
align-items: center;
|
|
749
1033
|
gap: 8px;
|
|
750
|
-
`;const
|
|
1034
|
+
`;const i=document.createElement("div");i.className="colour-swatch",i.style.cssText=`
|
|
751
1035
|
width: 40px;
|
|
752
1036
|
height: 40px;
|
|
753
1037
|
border-radius: var(--fb-border-radius);
|
|
@@ -756,7 +1040,7 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
756
1040
|
cursor: pointer;
|
|
757
1041
|
transition: border-color var(--fb-transition-duration) ease-in-out;
|
|
758
1042
|
flex-shrink: 0;
|
|
759
|
-
`;const
|
|
1043
|
+
`;const a=document.createElement("input");a.type="text",a.className="colour-hex-input",a.name=t,a.value=r,a.placeholder="#000000",a.style.cssText=`
|
|
760
1044
|
width: 100px;
|
|
761
1045
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
762
1046
|
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
@@ -770,39 +1054,39 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
770
1054
|
position: absolute;
|
|
771
1055
|
opacity: 0;
|
|
772
1056
|
pointer-events: none;
|
|
773
|
-
`,
|
|
1057
|
+
`,a.addEventListener("input",()=>{const s=a.value.trim();if(qt(s)){const c=Bn(s);i.style.backgroundColor=c,l.value=c.toLowerCase(),a.classList.remove("invalid"),n.instance&&n.instance.triggerOnChange(t,c)}else a.classList.add("invalid")}),a.addEventListener("blur",()=>{const s=a.value.trim();if(qt(s)){const c=Bn(s);a.value=c,i.style.backgroundColor=c,l.value=c.toLowerCase(),a.classList.remove("invalid")}}),l.addEventListener("change",()=>{const s=Oe(l.value);a.value=s,i.style.backgroundColor=s,n.instance&&n.instance.triggerOnChange(t,s)}),i.addEventListener("click",()=>{l.click()}),i.addEventListener("mouseenter",()=>{i.style.borderColor="var(--fb-border-hover-color)"}),i.addEventListener("mouseleave",()=>{i.style.borderColor="var(--fb-border-color)"}),a.addEventListener("focus",()=>{a.style.borderColor="var(--fb-border-focus-color)",a.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",a.style.outlineOffset="0"}),a.addEventListener("blur",()=>{a.style.borderColor="var(--fb-border-color)",a.style.outline="none"}),a.addEventListener("mouseenter",()=>{document.activeElement!==a&&(a.style.borderColor="var(--fb-border-hover-color)")}),a.addEventListener("mouseleave",()=>{document.activeElement!==a&&(a.style.borderColor="var(--fb-border-color)")}),o.appendChild(i),o.appendChild(a),o.appendChild(l),o}function Go(e,t,n,r){const o=t.state,i=ae(e,o,t),a=t.prefill[e.key]||e.default||"#000000";if(i){const l=Hn(a);n.appendChild(l)}else{const l=Dn(a,r,t);n.appendChild(l)}if(!i){const l=document.createElement("p");l.className="mt-1",l.style.cssText=`
|
|
774
1058
|
font-size: var(--fb-font-size-small);
|
|
775
1059
|
color: var(--fb-text-secondary-color);
|
|
776
|
-
`,l.textContent
|
|
1060
|
+
`,l.textContent=Le(e,o),n.appendChild(l)}}function Zo(e,t,n,r){var o,i;const a=t.state,l=ae(e,a,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],u=(o=e.minCount)!=null?o:1,d=(i=e.maxCount)!=null?i:1/0;for(;c.length<u;)c.push(e.default||"#000000");const f=document.createElement("div");f.className="space-y-2",n.appendChild(f);function p(){f.querySelectorAll(".multiple-colour-item").forEach((h,y)=>{const g=h.querySelector("input");g&&(g.name=`${r}[${y}]`)})}function m(h="#000000",y=-1){const g=document.createElement("div");if(g.className="multiple-colour-item flex items-center gap-2",l){const C=Hn(h);for(;C.firstChild;)g.appendChild(C.firstChild)}else{const C=`${r}[${f.children.length}]`,E=Dn(h,C,t);E.style.flex="1",g.appendChild(E)}return y===-1?f.appendChild(g):f.insertBefore(g,f.children[y]),p(),g}function b(){if(l)return;const h=f.querySelectorAll(".multiple-colour-item"),y=h.length;h.forEach(g=>{let C=g.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn px-2 py-1 rounded",C.style.cssText=`
|
|
777
1061
|
color: var(--fb-error-color);
|
|
778
1062
|
background-color: transparent;
|
|
779
1063
|
transition: background-color var(--fb-transition-duration);
|
|
780
|
-
`,
|
|
1064
|
+
`,C.innerHTML="\u2715",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{const x=Array.from(f.children).indexOf(g);f.children.length>u&&(c.splice(x,1),g.remove(),p(),w(),b())},g.appendChild(C));const E=y<=u;C.disabled=E,C.style.opacity=E?"0.5":"1",C.style.pointerEvents=E?"none":"auto"})}let v=null;if(!l){const h=Fe("colour",()=>{const y=e.default||"#000000";c.push(y),m(y),w(),b()},{label:e.addLabel});v=h.update,Te(n,h.counter),n.appendChild(h.row)}function w(){v&&v(c.length,d)}if(c.forEach(h=>m(h)),w(),b(),!l){const h=document.createElement("p");h.className="mt-1",h.style.cssText=`
|
|
781
1065
|
font-size: var(--fb-font-size-small);
|
|
782
1066
|
color: var(--fb-text-secondary-color);
|
|
783
|
-
`,h.textContent
|
|
1067
|
+
`,h.textContent=Le(e,a),n.appendChild(h)}}function Qo(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:s}=n,c=(d,f)=>{var p,m;if(!d)return;const b=`error-${d.getAttribute("name")||Math.random().toString(36).substring(7)}`;let v=document.getElementById(b);f?(d.classList.add("invalid"),d.title=f,v||(v=document.createElement("div"),v.id=b,v.className="error-message",v.style.cssText=`
|
|
784
1068
|
color: var(--fb-error-color);
|
|
785
1069
|
font-size: var(--fb-font-size-small);
|
|
786
1070
|
margin-top: 0.25rem;
|
|
787
|
-
`,
|
|
1071
|
+
`,d.nextSibling?(p=d.parentNode)==null||p.insertBefore(v,d.nextSibling):(m=d.parentNode)==null||m.appendChild(v)),v.textContent=f,v.style.display="block"):(d.classList.remove("invalid"),d.title="",v&&v.remove())},u=(d,f,p)=>{const{state:m}=n;if(!f){if(!s&&e.required){const v=k("required",m);return a.push(`${p}: ${v}`),c(d,v),""}return c(d,null),""}const b=Oe(f);if(!s&&!qt(b)){const v=k("invalidHexColour",m);return a.push(`${p}: ${v}`),c(d,v),f}return c(d,null),b};if(e.multiple){const d=l.querySelectorAll(`[name^="${t}\\["].colour-hex-input`),f=[];if(d.forEach((p,m)=>{var b;const v=(b=p==null?void 0:p.value)!=null?b:"",w=u(p,v,`${t}[${m}]`);f.push(w)}),!s){const{state:p}=n,m=(r=e.minCount)!=null?r:1,b=(o=e.maxCount)!=null?o:1/0,v=f.filter(w=>w!=="");e.required&&v.length===0&&a.push(`${t}: ${k("required",p)}`),v.length<m&&a.push(`${t}: ${k("minItems",p,{min:m})}`),v.length>b&&a.push(`${t}: ${k("maxItems",p,{max:b})}`)}return{value:f,errors:a}}else{const d=l.querySelector(`[name="${t}"].colour-hex-input`),f=(i=d==null?void 0:d.value)!=null?i:"";if(!s&&e.required&&f===""){const p=k("required",n.state);return a.push(`${t}: ${p}`),c(d,p),{value:"",errors:a}}return{value:u(d,f,t),errors:a}}}function el(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateColourField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["].colour-hex-input`);i.forEach((a,l)=>{if(l<n.length){const s=Oe(n[l]);a.value=s,a.classList.remove("invalid"),a.title="",xe(a);const c=a.closest(".colour-picker-wrapper");if(c){const u=c.querySelector(".colour-swatch"),d=c.querySelector(".colour-picker-hidden");u&&(u.style.backgroundColor=s),d&&(d.value=s.toLowerCase())}}}),n.length!==i.length&&console.warn(`updateColourField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"].colour-hex-input`);if(i){const a=Oe(n);i.value=a,i.classList.remove("invalid"),i.title="",xe(i);const l=i.closest(".colour-picker-wrapper");if(l){const s=l.querySelector(".colour-swatch"),c=l.querySelector(".colour-picker-hidden");s&&(s.style.backgroundColor=a),c&&(c.value=a.toLowerCase())}}}}function jn(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 Rt(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return(Math.log(e)-r)/(o-r)}function ut(e,t){return Math.round(e/t)*t}function On(e,t,n,r,o){var i;const a=document.createElement("div");a.className="slider-container";const l=document.createElement("div");l.className="flex items-start gap-3";const s=document.createElement("div");s.className="flex-1";const c=document.createElement("input");c.type="range",c.name=t,c.className="slider-input w-full",c.disabled=o;const u=n.scale||"linear",d=n.min,f=n.max,p=(i=n.step)!=null?i:1;if(u==="exponential"){if(d<=0)throw new Error(`Slider "${n.key}": exponential scale requires min > 0 (got ${d})`);c.min="0",c.max="1000",c.step="1";const h=Rt(e,d,f);c.value=(h*1e3).toString()}else c.min=d.toString(),c.max=f.toString(),c.step=p.toString(),c.value=e.toString();c.style.cssText=`
|
|
788
1072
|
height: 6px;
|
|
789
1073
|
border-radius: 3px;
|
|
790
1074
|
background: linear-gradient(
|
|
791
1075
|
to right,
|
|
792
1076
|
var(--fb-primary-color) 0%,
|
|
793
|
-
var(--fb-primary-color) ${(e-
|
|
794
|
-
var(--fb-border-color) ${(e-
|
|
1077
|
+
var(--fb-primary-color) ${(e-d)/(f-d)*100}%,
|
|
1078
|
+
var(--fb-border-color) ${(e-d)/(f-d)*100}%,
|
|
795
1079
|
var(--fb-border-color) 100%
|
|
796
1080
|
);
|
|
797
1081
|
outline: none;
|
|
798
1082
|
transition: background 0.1s ease-in-out;
|
|
799
1083
|
cursor: ${o?"not-allowed":"pointer"};
|
|
800
1084
|
opacity: ${o?"0.6":"1"};
|
|
801
|
-
`,s.appendChild(
|
|
1085
|
+
`,s.appendChild(c);const m=document.createElement("div");m.className="flex justify-between",m.style.cssText=`
|
|
802
1086
|
font-size: var(--fb-font-size-small);
|
|
803
1087
|
color: var(--fb-text-secondary-color);
|
|
804
1088
|
margin-top: 4px;
|
|
805
|
-
`;const b=document.createElement("span");b.textContent=
|
|
1089
|
+
`;const b=document.createElement("span");b.textContent=d.toString();const v=document.createElement("span");v.textContent=f.toString(),m.appendChild(b),m.appendChild(v),s.appendChild(m);const w=document.createElement("span");if(w.className="slider-value",w.style.cssText=`
|
|
806
1090
|
min-width: 60px;
|
|
807
1091
|
text-align: right;
|
|
808
1092
|
font-size: var(--fb-font-size);
|
|
@@ -810,56 +1094,51 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
810
1094
|
font-family: var(--fb-font-family-mono, monospace);
|
|
811
1095
|
font-weight: 500;
|
|
812
1096
|
padding-top: 2px;
|
|
813
|
-
`,
|
|
1097
|
+
`,w.textContent=e.toFixed(p<1?2:0),l.appendChild(s),l.appendChild(w),a.appendChild(l),!o){const h=()=>{let y;if(u==="exponential"){const C=parseFloat(c.value)/1e3;y=jn(C,d,f),y=ut(y,p),y=Math.max(d,Math.min(f,y))}else y=parseFloat(c.value),y=ut(y,p);w.textContent=y.toFixed(p<1?2:0);const g=(y-d)/(f-d)*100;c.style.background=`linear-gradient(
|
|
814
1098
|
to right,
|
|
815
1099
|
var(--fb-primary-color) 0%,
|
|
816
|
-
var(--fb-primary-color) ${
|
|
817
|
-
var(--fb-border-color) ${
|
|
1100
|
+
var(--fb-primary-color) ${g}%,
|
|
1101
|
+
var(--fb-border-color) ${g}%,
|
|
818
1102
|
var(--fb-border-color) 100%
|
|
819
|
-
)`,r.instance&&r.instance.triggerOnChange(t,
|
|
1103
|
+
)`,r.instance&&r.instance.triggerOnChange(t,y)};c.addEventListener("input",h),c.addEventListener("change",h)}return a}function tl(e,t,n,r){var o;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const i=t.state,a=ae(e,i,t),l=e.default!==void 0?e.default:(e.min+e.max)/2,s=(o=t.prefill[e.key])!=null?o:l,c=On(s,r,e,t,a);if(n.appendChild(c),!a){const u=document.createElement("p");u.className="mt-1",u.style.cssText=`
|
|
820
1104
|
font-size: var(--fb-font-size-small);
|
|
821
1105
|
color: var(--fb-text-secondary-color);
|
|
822
|
-
`,
|
|
1106
|
+
`,u.textContent=Le(e,i),n.appendChild(u)}}function nl(e,t,n,r){var o,i;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const a=t.state,l=ae(e,a,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],u=(o=e.minCount)!=null?o:1,d=(i=e.maxCount)!=null?i:1/0,f=e.default!==void 0?e.default:(e.min+e.max)/2;for(;c.length<u;)c.push(f);const p=document.createElement("div");p.className="space-y-3",n.appendChild(p);function m(){p.querySelectorAll(".multiple-slider-item").forEach((y,g)=>{const C=y.querySelector("input[type=range]");C&&C.setAttribute("name",`${r}[${g}]`)})}function b(y=f,g=-1){const C=document.createElement("div");C.className="multiple-slider-item flex items-start gap-2";const E=`${r}[${p.children.length}]`,x=On(y,E,e,t,l);return x.style.flex="1",C.appendChild(x),g===-1?p.appendChild(C):p.insertBefore(C,p.children[g]),m(),C}function v(){if(l)return;const y=p.querySelectorAll(".multiple-slider-item"),g=y.length;y.forEach(C=>{let E=C.querySelector(".remove-item-btn");E||(E=document.createElement("button"),E.type="button",E.className="remove-item-btn px-2 py-1 rounded",E.style.cssText=`
|
|
823
1107
|
color: var(--fb-error-color);
|
|
824
1108
|
background-color: transparent;
|
|
825
1109
|
transition: background-color var(--fb-transition-duration);
|
|
826
1110
|
margin-top: 8px;
|
|
827
|
-
`,
|
|
1111
|
+
`,E.innerHTML="\u2715",E.addEventListener("mouseenter",()=>{E.style.backgroundColor="var(--fb-background-hover-color)"}),E.addEventListener("mouseleave",()=>{E.style.backgroundColor="transparent"}),E.onclick=()=>{const $=Array.from(p.children).indexOf(C);p.children.length>u&&(c.splice($,1),C.remove(),m(),h(),v())},C.appendChild(E));const x=g<=u;E.disabled=x,E.style.opacity=x?"0.5":"1",E.style.pointerEvents=x?"none":"auto"})}let w=null;if(!l){const y=Fe("slider",()=>{c.push(f),b(f),h(),v()},{label:e.addLabel});w=y.update,Te(n,y.counter),n.appendChild(y.row)}function h(){w&&w(c.length,d)}if(c.forEach(y=>b(y)),h(),v(),!l){const y=document.createElement("p");y.className="mt-1",y.style.cssText=`
|
|
828
1112
|
font-size: var(--fb-font-size-small);
|
|
829
1113
|
color: var(--fb-text-secondary-color);
|
|
830
|
-
`,
|
|
1114
|
+
`,y.textContent=Le(e,a),n.appendChild(y)}}function rl(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:s}=n;if(e.min===void 0||e.min===null)throw new Error(`Slider validation: field "${t}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider validation: field "${t}" requires "max" property`);const c=e.min,u=e.max,d=(r=e.step)!=null?r:1,f=e.scale||"linear",p=(b,v)=>{var w,h;if(!b)return;const y=`error-${b.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(y);if(v){if(b.classList.add("invalid"),b.title=v,!g){g=document.createElement("div"),g.id=y,g.className="error-message",g.style.cssText=`
|
|
831
1115
|
color: var(--fb-error-color);
|
|
832
1116
|
font-size: var(--fb-font-size-small);
|
|
833
1117
|
margin-top: 0.25rem;
|
|
834
|
-
`;const
|
|
1118
|
+
`;const C=b.closest(".slider-container");C&&C.nextSibling?(w=C.parentNode)==null||w.insertBefore(g,C.nextSibling):C&&((h=C.parentNode)==null||h.appendChild(g))}g.textContent=v,g.style.display="block"}else b.classList.remove("invalid"),b.title="",g&&g.remove()},m=(b,v)=>{const{state:w}=n,h=b.value;if(!h){if(!s&&e.required){const g=k("required",w);return a.push(`${v}: ${g}`),p(b,g),null}return p(b,null),null}let y;if(f==="exponential"){const g=parseFloat(h)/1e3;y=jn(g,c,u),y=ut(y,d)}else y=parseFloat(h),y=ut(y,d);if(!s){if(y<c){const g=k("minValue",w,{min:c});return a.push(`${v}: ${g}`),p(b,g),y}if(y>u){const g=k("maxValue",w,{max:u});return a.push(`${v}: ${g}`),p(b,g),y}}return p(b,null),y};if(e.multiple){const b=l.querySelectorAll(`input[type="range"][name^="${t}\\["]`),v=[];if(b.forEach((w,h)=>{const y=m(w,`${t}[${h}]`);v.push(y)}),!s){const{state:w}=n,h=(o=e.minCount)!=null?o:1,y=(i=e.maxCount)!=null?i:1/0,g=v.filter(C=>C!==null);e.required&&g.length===0&&a.push(`${t}: ${k("required",w)}`),g.length<h&&a.push(`${t}: ${k("minItems",w,{min:h})}`),g.length>y&&a.push(`${t}: ${k("maxItems",w,{max:y})}`)}return{value:v,errors:a}}else{const b=l.querySelector(`input[type="range"][name="${t}"]`);return b?{value:m(b,t),errors:a}:(!s&&e.required&&a.push(`${t}: ${k("required",n.state)}`),{value:null,errors:a})}}function ol(e,t,n,r){var o;const{scopeRoot:i}=r,a=e.min,l=e.max,s=(o=e.step)!=null?o:1,c=e.scale||"linear";if(e.multiple){if(!Array.isArray(n)){console.warn(`updateSliderField: Expected array for multiple field "${t}", got ${typeof n}`);return}const u=i.querySelectorAll(`input[type="range"][name^="${t}\\["]`);u.forEach((d,f)=>{if(f<n.length&&n[f]!==null){const p=Number(n[f]);if(c==="exponential"){const b=Rt(p,a,l);d.value=(b*1e3).toString()}else d.value=p.toString();const m=d.closest(".slider-container");if(m){const b=m.querySelector(".slider-value");b&&(b.textContent=p.toFixed(s<1?2:0));const v=(p-a)/(l-a)*100;d.style.background=`linear-gradient(
|
|
835
1119
|
to right,
|
|
836
1120
|
var(--fb-primary-color) 0%,
|
|
837
|
-
var(--fb-primary-color) ${
|
|
838
|
-
var(--fb-border-color) ${
|
|
1121
|
+
var(--fb-primary-color) ${v}%,
|
|
1122
|
+
var(--fb-border-color) ${v}%,
|
|
839
1123
|
var(--fb-border-color) 100%
|
|
840
|
-
)`}
|
|
1124
|
+
)`}d.classList.remove("invalid"),d.title="",xe(d)}}),n.length!==u.length&&console.warn(`updateSliderField: Multiple field "${t}" has ${u.length} sliders but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const u=i.querySelector(`input[type="range"][name="${t}"]`);if(u&&n!==null&&n!==void 0){const d=Number(n);if(c==="exponential"){const p=Rt(d,a,l);u.value=(p*1e3).toString()}else u.value=d.toString();const f=u.closest(".slider-container");if(f){const p=f.querySelector(".slider-value");p&&(p.textContent=d.toFixed(s<1?2:0));const m=(d-a)/(l-a)*100;u.style.background=`linear-gradient(
|
|
841
1125
|
to right,
|
|
842
1126
|
var(--fb-primary-color) 0%,
|
|
843
1127
|
var(--fb-primary-color) ${m}%,
|
|
844
1128
|
var(--fb-border-color) ${m}%,
|
|
845
1129
|
var(--fb-border-color) 100%
|
|
846
|
-
)`}
|
|
847
|
-
width:
|
|
848
|
-
height:
|
|
1130
|
+
)`}u.classList.remove("invalid"),u.title="",xe(u)}}}function Un(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 Pn(e,t){return{...t,...e}}function Bt(e){const t={};return e.querySelectorAll("input, select, textarea").forEach(n=>{const r=n.getAttribute("name");r&&!r.includes("[")&&!r.includes(".")&&(n instanceof HTMLSelectElement?t[r]=n.value:n instanceof HTMLInputElement?n.type==="checkbox"?t[r]=n.checked:n.type==="radio"?n.checked&&(t[r]=n.value):t[r]=n.value:n instanceof HTMLTextAreaElement&&(t[r]=n.value))}),t}let Ht=null;function ll(e){Ht=e}function ft(e,t){if(!Ht)throw new Error("renderElement not initialized. Import from components/index.ts");return Ht(e,t)}function Wn(e,t){if(!e.prefillHints||e.prefillHints.length===0)return null;const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-2",e.prefillHints.forEach((r,o)=>{const i=document.createElement("button");i.type="button",i.className="fb-prefill-hint",i.textContent=r.label,i.setAttribute("data-hint-values",JSON.stringify(r.values)),i.setAttribute("data-container-key",t),i.setAttribute("data-hint-index",String(o)),n.appendChild(i)}),n}function Vn(e,t,n,r){var o,i;const a=document.createElement("div");a.className="border border-gray-200 rounded-lg p-2 bg-gray-50",a.setAttribute("data-container",r);const l=document.createElement("div"),s=e.columns||1;s===1?l.className="space-y-2":l.className=`grid grid-cols-${s} gap-2`;const c=ae(e,t.state,t);if(!c){const m=Wn(e,r);m&&a.appendChild(m)}const u=Un(e.elements),d=((o=t.prefill)==null?void 0:o[e.key])||{},f=Pn(d,u),p={path:ke(t.path,e.key),prefill:f,formData:(i=t.formData)!=null?i:t.prefill,state:t.state,inheritedReadonly:c||t.inheritedReadonly};e.elements.forEach(m=>{var b,v;if(m.type!=="markdown"&&(m.hidden||m.type==="hidden")){const w=(v=(b=d[m.key])!=null?b:"default"in m?m.default:null)!=null?v:null;l.appendChild(_e(ke(p.path,m.key),w))}else l.appendChild(ft(m,p))}),a.appendChild(l),n.appendChild(a)}function il(e,t){if(e)return"space-y-2";const n=t||1;return n===1?"space-y-2":`grid grid-cols-${n} gap-2`}function Dt(e,t,n){const r=document.createElement("button");r.type="button",r.className="fb-item-remove",r.setAttribute("aria-label",k("removeElement",n)),r.style.cssText=`
|
|
1131
|
+
width: 24px;
|
|
1132
|
+
height: 24px;
|
|
849
1133
|
display: inline-flex;
|
|
850
1134
|
align-items: center;
|
|
851
1135
|
justify-content: center;
|
|
852
1136
|
padding: 0;
|
|
853
|
-
line-height: 1;
|
|
854
|
-
font-size: 14px;
|
|
855
|
-
color: var(--fb-error-color);
|
|
856
|
-
background-color: transparent;
|
|
857
1137
|
border: 0;
|
|
858
1138
|
border-radius: 4px;
|
|
859
1139
|
cursor: pointer;
|
|
860
1140
|
flex-shrink: 0;
|
|
861
|
-
transition: background-color var(--fb-transition-duration);
|
|
862
|
-
`,n.textContent="\u2715",n.addEventListener("mouseenter",()=>{n.style.backgroundColor="var(--fb-background-hover-color)"}),n.addEventListener("mouseleave",()=>{n.style.backgroundColor="transparent"}),n.onclick=t;const r=e.querySelector("[data-fb-label-row]");if(r){n.style.marginLeft="auto",r.appendChild(n);return}n.style.position="absolute",n.style.top="8px",n.style.right="8px",e.style.position="relative",e.appendChild(n)}function jn(e,t,n,r){var o,a,i,l;const s=t.state,u=oe(e,s,t),d=u||t.inheritedReadonly,c=document.createElement("div");c.className="border border-gray-200 rounded-lg p-2 bg-gray-50";const p=document.createElement("div"),f=e.displayMode==="slides";if(f){p.className="fb-container-slides";const q=e.columns,W=typeof q=="number"&&q>0?`repeat(${q}, 1fr)`:"repeat(auto-fit, minmax(280px, 1fr))";p.style.cssText=`display:grid;grid-template-columns:${W};gap:8px;align-items:start;`}else p.className="space-y-2";if(!u){const q=Bn(e,e.key);q&&c.appendChild(q)}const m=(o=e.minCount)!=null?o:0,b=(a=e.maxCount)!=null?a:1/0,g=Array.isArray((i=t.prefill)==null?void 0:i[e.key])?t.prefill[e.key]:null,E=Rn(e.elements),h=()=>p.querySelectorAll(":scope > .containerItem").length,x=()=>{if(h()>=b)return;const q=h(),W=s.formRoot?Ft(s.formRoot):{},K={state:t.state,path:Ce(t.path,`${e.key}[${q}]`),prefill:E,formData:W,inheritedReadonly:d},Y=document.createElement("div");Y.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",Y.setAttribute("data-container-item",`${e.key}[${q}]`);const Q=document.createElement("div");Q.className=Uo(f,e.columns),e.elements.forEach(ie=>{var ae;ie.type!=="markdown"&&(ie.hidden||ie.type==="hidden")?Q.appendChild(We(Ce(K.path,ie.key),(ae="default"in ie?ie.default:null)!=null?ae:null)):Q.appendChild(st(ie,K))}),Y.appendChild(Q),u||zt(Y,()=>R(Y)),v&&v.parentElement===p?p.insertBefore(Y,v):p.appendChild(Y),L()};let v=null,w=null,C=null;const y=()=>{if(!v)return;const q=p.querySelector(":scope > .containerItem");q&&q.offsetHeight>0&&(v.style.minHeight=`${q.offsetHeight}px`)},L=()=>{const q=h();w&&w(q,b),C&&C(q,b),v&&y()},R=q=>{q.remove(),L()};if(g&&Array.isArray(g)&&g.forEach((q,W)=>{var K;const Y=Hn(q||{},E),Q={state:t.state,path:Ce(t.path,`${e.key}[${W}]`),prefill:Y,formData:(K=t.formData)!=null?K:t.prefill,inheritedReadonly:d},ie=document.createElement("div");ie.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",ie.setAttribute("data-container-item",`${e.key}[${W}]`);const ae=document.createElement("div");if(f)ae.className="space-y-2";else{const fe=e.columns||1;fe===1?ae.className="space-y-2":ae.className=`grid grid-cols-${fe} gap-2`}e.elements.forEach(fe=>{var ze,xe;if(fe.type!=="markdown"&&(fe.hidden||fe.type==="hidden")){const Pe=(xe=(ze=q==null?void 0:q[fe.key])!=null?ze:"default"in fe?fe.default:null)!=null?xe:null;ae.appendChild(We(Ce(Q.path,fe.key),Pe))}else ae.appendChild(st(fe,Q))}),ie.appendChild(ae),u||zt(ie,()=>R(ie)),p.appendChild(ie)}),!u)for(;h()<m;){const q=h(),W={state:t.state,path:Ce(t.path,`${e.key}[${q}]`),prefill:E,formData:(l=t.formData)!=null?l:t.prefill,inheritedReadonly:d},K=document.createElement("div");K.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",K.setAttribute("data-container-item",`${e.key}[${q}]`);const Y=document.createElement("div");if(f)Y.className="space-y-2";else{const Q=e.columns||1;Q===1?Y.className="space-y-2":Y.className=`grid grid-cols-${Q} gap-2`}e.elements.forEach(Q=>{var ie;Q.type!=="markdown"&&(Q.hidden||Q.type==="hidden")?Y.appendChild(We(Ce(W.path,Q.key),(ie="default"in Q?Q.default:null)!=null?ie:null)):Y.appendChild(st(Q,W))}),K.appendChild(Y),zt(K,()=>{h()>m&&R(K)}),p.appendChild(K)}if(c.appendChild(p),!u)if(f){p.style.alignItems="stretch";const q=br(x,{label:e.addLabel});v=q.tile,w=q.update,Le(n,q.counter),p.appendChild(q.tile)}else{const q=Te("container",x,{label:e.addLabel});C=q.update,Le(n,q.counter),c.appendChild(q.row)}L(),n.appendChild(c),v&&(typeof requestAnimationFrame=="function"?requestAnimationFrame(y):y())}let Nt=null;function Po(e){Nt=e}function On(e,t,n){if(!Nt)throw new Error("validateElement not initialized. Should be set from FormBuilderInstance");return Nt(e,t,n)}function Un(e,t,n){const r=[],{scopeRoot:o,skipValidation:a,path:i}=n;if(!("elements"in e))return{value:null,errors:r};const l=(s,u,d)=>{var c,p;if(a)return;const{state:f}=n,m="minCount"in d&&(c=d.minCount)!=null?c:0,b="maxCount"in d&&(p=d.maxCount)!=null?p:1/0;d.required&&u.length===0&&r.push(`${s}: ${k("required",f)}`),u.length<m&&r.push(`${s}: ${k("minItems",f,{min:m})}`),u.length>b&&r.push(`${s}: ${k("maxItems",f,{max:b})}`)};if("multiple"in e&&e.multiple){const s=[],u=o.querySelectorAll("[data-container-item]");return Array.from(u).filter(d=>{const c=d.getAttribute("data-container-item")||"";if(!c.startsWith(`${t}[`))return!1;const p=c.slice(t.length);return/^\[\d+\]$/.test(p)}).forEach(d=>{const c={},p=(d.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),f=p?parseInt(p[1],10):0;e.elements.forEach(m=>{var b;if(m.enableIf)try{const h=(b=n.instance)!=null&&b.getState().formRoot?Ft(n.instance.getState().formRoot):{};if(!He(m.enableIf,h,c))return}catch(h){console.error(`Error evaluating enableIf for field "${m.key}" in container "${t}[${f}]":`,h)}const g=`${t}[${f}].${m.key}`,E=On({...m,key:g},{path:i},d);E.spread&&E.value!==null&&typeof E.value=="object"?Object.assign(c,E.value):c[m.key]=E.value}),s.push(c)}),l(t,s,e),{value:s,errors:r}}else{const s={},u=o.querySelector(`[data-container="${t}"]`)||o;return e.elements.forEach(d=>{var c;if(d.enableIf)try{const p=(c=n.instance)!=null&&c.getState().formRoot?Ft(n.instance.getState().formRoot):{};if(!He(d.enableIf,p,s))return}catch(p){console.error(`Error evaluating enableIf for field "${d.key}" in container "${t}":`,p)}{const p=`${t}.${d.key}`,f=On({...d,key:p},{path:i},u);f.spread&&f.value!==null&&typeof f.value=="object"?Object.assign(s,f.value):s[d.key]=f.value}}),{value:s,errors:r}}}function Pn(e,t,n,r){const{instance:o,scopeRoot:a}=r;if("elements"in e)if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateContainerField: Expected array for multiple container field "${t}", got ${typeof n}`);return}n.forEach((l,s)=>{Ze(l)&&e.elements.forEach(u=>{var d,c;if(u.type==="markdown"||!u.key)return;const p=`${t}[${s}].${u.key}`;if(u.type==="richinput"&&u.flatOutput){const f=u,m=(d=f.textKey)!=null?d:"text",b=(c=f.filesKey)!=null?c:"files",g=l,E={};m in g&&(E[m]=g[m]),b in g&&(E[b]=g[b]),Object.keys(E).length>0&&o.updateField(p,E)}else{const f=l[u.key];f!==void 0&&o.updateField(p,f)}})});const i=a.querySelectorAll(`[data-container-item^="${t}["]`);n.length!==i.length&&console.warn(`updateContainerField: Multiple container field "${t}" item count mismatch. Consider re-rendering for add/remove.`)}else{if(!Ze(n)){console.warn(`updateContainerField: Expected object for container field "${t}", got ${typeof n}`);return}e.elements.forEach(i=>{var l,s;if(i.type==="markdown"||!i.key)return;const u=`${t}.${i.key}`;if(i.type==="richinput"&&i.flatOutput){const d=i,c=(l=d.textKey)!=null?l:"text",p=(s=d.filesKey)!=null?s:"files",f=n,m={};c in f&&(m[c]=f[c]),p in f&&(m[p]=f[p]),Object.keys(m).length>0&&o.updateField(u,m)}else{const d=n[i.key];d!==void 0&&o.updateField(u,d)}})}}function Wo(e,t,n,r){var o,a;typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated and will be removed in a future version. Please use type: "container" with multiple: true instead. Field key: "${e.key}"`);const i={key:e.key,label:e.label,description:e.description,hint:e.hint,required:e.required,hidden:e.hidden,default:e.default,actions:e.actions,elements:e.elements,multiple:!!(e.repeat&&Ze(e.repeat)),minCount:(o=e.repeat)==null?void 0:o.min,maxCount:(a=e.repeat)==null?void 0:a.max};i.multiple?jn(i,t,n):Dn(i,t,n,r)}function Wn(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&&Ze(r.repeat)),minCount:(t=r.repeat)==null?void 0:t.min,maxCount:(n=r.repeat)==null?void 0:n.max}}function Vo(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=Wn(e);return Un(r,t,n)}function _o(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=Wn(e);return Pn(o,t,n,r)}function Ko(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function Jo(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 Yo(e){return Ko(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:Jo(e)?e:null}function je(e){return e.map(Yo).filter(t=>t!==null)}function Vn(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 a=r+1;a<e.length;a++){const i=e[a];if(o.top<=i.bottom&&o.bottom>=i.top&&o.left<=i.right&&o.right>=i.left)return`Merges ${r} and ${a} overlap`}}return null}function _n(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 ut(e,t,n){var r;return(r=n.find(o=>o.top===e&&o.left===t))!=null?r:null}function Me(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 Oe(e){const t=document.createElement("button");return t.type="button",t.textContent=e.label,t.title=e.title,t.style.cssText=`
|
|
1141
|
+
`,r.innerHTML=Qt,r.onclick=t;const o=e.querySelector("[data-fb-label-row]");if(o){r.style.marginLeft="auto",o.appendChild(r);return}r.style.position="absolute",r.style.top="8px",r.style.right="8px",e.style.position="relative",e.appendChild(r)}function Kn(e,t,n,r){var o,i,a,l;const s=t.state,c=ae(e,s,t),u=c||t.inheritedReadonly,d=document.createElement("div");d.className="border border-gray-200 rounded-lg p-2 bg-gray-50";const f=document.createElement("div"),p=e.displayMode==="slides";if(p){f.className="fb-container-slides";const q=e.columns,K=typeof q=="number"&&q>0?`repeat(${q}, 1fr)`:"repeat(auto-fit, minmax(280px, 1fr))";f.style.cssText=`display:grid;grid-template-columns:${K};gap:var(--fb-slides-gap, 14px);align-items:start;`}else f.className="space-y-2";if(!c){const q=Wn(e,e.key);q&&d.appendChild(q)}const m=(o=e.minCount)!=null?o:0,b=(i=e.maxCount)!=null?i:1/0,v=Array.isArray((a=t.prefill)==null?void 0:a[e.key])?t.prefill[e.key]:null,w=Un(e.elements),h=()=>f.querySelectorAll(":scope > .containerItem").length,y=()=>{if(h()>=b)return;const q=h(),K=s.formRoot?Bt(s.formRoot):{},B={state:t.state,path:ke(t.path,`${e.key}[${q}]`),prefill:w,formData:K,inheritedReadonly:u},M=document.createElement("div");M.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",M.setAttribute("data-container-item",`${e.key}[${q}]`),p&&M.setAttribute("data-fb-slide-card","");const D=document.createElement("div");D.className=il(p,e.columns),e.elements.forEach(J=>{var Q;J.type!=="markdown"&&(J.hidden||J.type==="hidden")?D.appendChild(_e(ke(B.path,J.key),(Q="default"in J?J.default:null)!=null?Q:null)):D.appendChild(ft(J,B))}),M.appendChild(D),c||Dt(M,()=>z(M),s),g&&g.parentElement===f?f.insertBefore(M,g):f.appendChild(M),$()};let g=null,C=null,E=null;const x=()=>{if(!g)return;const q=f.querySelector(":scope > .containerItem");q&&q.offsetHeight>0&&(g.style.minHeight=`${q.offsetHeight}px`)},$=()=>{const q=h();C&&C(q,b),E&&E(q,b),g&&x()},z=q=>{q.remove(),$()};if(v&&Array.isArray(v)&&v.forEach((q,K)=>{var B;const M=Pn(q||{},w),D={state:t.state,path:ke(t.path,`${e.key}[${K}]`),prefill:M,formData:(B=t.formData)!=null?B:t.prefill,inheritedReadonly:u},J=document.createElement("div");J.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",J.setAttribute("data-container-item",`${e.key}[${K}]`),p&&J.setAttribute("data-fb-slide-card","");const Q=document.createElement("div");if(p)Q.className="space-y-2";else{const ne=e.columns||1;ne===1?Q.className="space-y-2":Q.className=`grid grid-cols-${ne} gap-2`}e.elements.forEach(ne=>{var he,Ce;if(ne.type!=="markdown"&&(ne.hidden||ne.type==="hidden")){const Ke=(Ce=(he=q==null?void 0:q[ne.key])!=null?he:"default"in ne?ne.default:null)!=null?Ce:null;Q.appendChild(_e(ke(D.path,ne.key),Ke))}else Q.appendChild(ft(ne,D))}),J.appendChild(Q),c||Dt(J,()=>z(J),t.state),f.appendChild(J)}),!c)for(;h()<m;){const q=h(),K={state:t.state,path:ke(t.path,`${e.key}[${q}]`),prefill:w,formData:(l=t.formData)!=null?l:t.prefill,inheritedReadonly:u},B=document.createElement("div");B.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",B.setAttribute("data-container-item",`${e.key}[${q}]`),p&&B.setAttribute("data-fb-slide-card","");const M=document.createElement("div");if(p)M.className="space-y-2";else{const D=e.columns||1;D===1?M.className="space-y-2":M.className=`grid grid-cols-${D} gap-2`}e.elements.forEach(D=>{var J;D.type!=="markdown"&&(D.hidden||D.type==="hidden")?M.appendChild(_e(ke(K.path,D.key),(J="default"in D?D.default:null)!=null?J:null)):M.appendChild(ft(D,K))}),B.appendChild(M),Dt(B,()=>{h()>m&&z(B)},t.state),f.appendChild(B)}if(d.appendChild(f),!c)if(p){f.style.alignItems="stretch";const q=Er(y,{label:e.addLabel});g=q.tile,C=q.update,Te(n,q.counter),f.appendChild(q.tile)}else{const q=Fe("container",y,{label:e.addLabel});E=q.update,Te(n,q.counter),d.appendChild(q.row)}$(),n.appendChild(d),g&&(typeof requestAnimationFrame=="function"?requestAnimationFrame(x):x())}let jt=null;function al(e){jt=e}function _n(e,t,n){if(!jt)throw new Error("validateElement not initialized. Should be set from FormBuilderInstance");return jt(e,t,n)}function Jn(e,t,n){const r=[],{scopeRoot:o,skipValidation:i,path:a}=n;if(!("elements"in e))return{value:null,errors:r};const l=(s,c,u)=>{var d,f;if(i)return;const{state:p}=n,m="minCount"in u&&(d=u.minCount)!=null?d:0,b="maxCount"in u&&(f=u.maxCount)!=null?f:1/0;u.required&&c.length===0&&r.push(`${s}: ${k("required",p)}`),c.length<m&&r.push(`${s}: ${k("minItems",p,{min:m})}`),c.length>b&&r.push(`${s}: ${k("maxItems",p,{max:b})}`)};if("multiple"in e&&e.multiple){const s=[],c=o.querySelectorAll("[data-container-item]");return Array.from(c).filter(u=>{const d=u.getAttribute("data-container-item")||"";if(!d.startsWith(`${t}[`))return!1;const f=d.slice(t.length);return/^\[\d+\]$/.test(f)}).forEach(u=>{const d={},f=(u.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),p=f?parseInt(f[1],10):0;e.elements.forEach(m=>{var b;if(m.enableIf)try{const h=(b=n.instance)!=null&&b.getState().formRoot?Bt(n.instance.getState().formRoot):{};if(!He(m.enableIf,h,d))return}catch(h){console.error(`Error evaluating enableIf for field "${m.key}" in container "${t}[${p}]":`,h)}const v=`${t}[${p}].${m.key}`,w=_n({...m,key:v},{path:a},u);w.spread&&w.value!==null&&typeof w.value=="object"?Object.assign(d,w.value):d[m.key]=w.value}),s.push(d)}),l(t,s,e),{value:s,errors:r}}else{const s={},c=o.querySelector(`[data-container="${t}"]`)||o;return e.elements.forEach(u=>{var d;if(u.enableIf)try{const f=(d=n.instance)!=null&&d.getState().formRoot?Bt(n.instance.getState().formRoot):{};if(!He(u.enableIf,f,s))return}catch(f){console.error(`Error evaluating enableIf for field "${u.key}" in container "${t}":`,f)}{const f=`${t}.${u.key}`,p=_n({...u,key:f},{path:a},c);p.spread&&p.value!==null&&typeof p.value=="object"?Object.assign(s,p.value):s[u.key]=p.value}}),{value:s,errors:r}}}function Yn(e,t,n,r){const{instance:o,scopeRoot:i}=r;if("elements"in e)if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateContainerField: Expected array for multiple container field "${t}", got ${typeof n}`);return}n.forEach((l,s)=>{nt(l)&&e.elements.forEach(c=>{var u,d;if(c.type==="markdown"||!c.key)return;const f=`${t}[${s}].${c.key}`;if(c.type==="richinput"&&c.flatOutput){const p=c,m=(u=p.textKey)!=null?u:"text",b=(d=p.filesKey)!=null?d:"files",v=l,w={};m in v&&(w[m]=v[m]),b in v&&(w[b]=v[b]),Object.keys(w).length>0&&o.updateField(f,w)}else{const p=l[c.key];p!==void 0&&o.updateField(f,p)}})});const a=i.querySelectorAll(`[data-container-item^="${t}["]`);n.length!==a.length&&console.warn(`updateContainerField: Multiple container field "${t}" item count mismatch. Consider re-rendering for add/remove.`)}else{if(!nt(n)){console.warn(`updateContainerField: Expected object for container field "${t}", got ${typeof n}`);return}e.elements.forEach(a=>{var l,s;if(a.type==="markdown"||!a.key)return;const c=`${t}.${a.key}`;if(a.type==="richinput"&&a.flatOutput){const u=a,d=(l=u.textKey)!=null?l:"text",f=(s=u.filesKey)!=null?s:"files",p=n,m={};d in p&&(m[d]=p[d]),f in p&&(m[f]=p[f]),Object.keys(m).length>0&&o.updateField(c,m)}else{const u=n[a.key];u!==void 0&&o.updateField(c,u)}})}}function sl(e,t,n,r){var o,i;typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated and will be removed in a future version. Please use type: "container" with multiple: true instead. Field key: "${e.key}"`);const a={key:e.key,label:e.label,description:e.description,hint:e.hint,required:e.required,hidden:e.hidden,default:e.default,actions:e.actions,elements:e.elements,multiple:!!(e.repeat&&nt(e.repeat)),minCount:(o=e.repeat)==null?void 0:o.min,maxCount:(i=e.repeat)==null?void 0:i.max};a.multiple?Kn(a,t,n):Vn(a,t,n,r)}function Xn(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&&nt(r.repeat)),minCount:(t=r.repeat)==null?void 0:t.min,maxCount:(n=r.repeat)==null?void 0:n.max}}function cl(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=Xn(e);return Jn(r,t,n)}function dl(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=Xn(e);return Yn(o,t,n,r)}function ul(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function fl(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 pl(e){return ul(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:fl(e)?e:null}function Ue(e){return e.map(pl).filter(t=>t!==null)}function Gn(e,t){return Array.from({length:e},()=>Array.from({length:t},()=>""))}function Ot(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(o.top<0||o.left<0||o.bottom>=t||o.right>=n||o.top>o.bottom||o.left>o.right)return`Merge ${r} out of bounds`;for(let i=r+1;i<e.length;i++){const a=e[i];if(o.top<=a.bottom&&o.bottom>=a.top&&o.left<=a.right&&o.right>=a.left)return`Merges ${r} and ${i} overlap`}}return null}function Zn(e,t,n){for(const r of n){if(r.top===e&&r.left===t)return null;if(e>=r.top&&e<=r.bottom&&t>=r.left&&t<=r.right)return r}return null}function pt(e,t,n){var r;return(r=n.find(o=>o.top===e&&o.left===t))!=null?r:null}function Ne(e){var t;if(!e.anchor)return null;const n=(t=e.focus)!=null?t:e.anchor;return{r1:Math.min(e.anchor.row,n.row),c1:Math.min(e.anchor.col,n.col),r2:Math.max(e.anchor.row,n.row),c2:Math.max(e.anchor.col,n.col)}}function Pe(e){const t=document.createElement("button");return t.type="button",t.textContent=e.label,t.title=e.title,t.style.cssText=`
|
|
863
1142
|
position: absolute;
|
|
864
1143
|
width: ${e.size}px;
|
|
865
1144
|
height: ${e.size}px;
|
|
@@ -879,7 +1158,7 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
879
1158
|
box-shadow: 0 1px 4px rgba(0,0,0,0.2);
|
|
880
1159
|
transition: transform 0.1s, opacity 0.1s;
|
|
881
1160
|
pointer-events: all;
|
|
882
|
-
`,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
|
|
1161
|
+
`,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 ml(e,t){const{cells:n,merges:r=[]}=e;if(n.length===0)return;const o=n[0].length,i=document.createElement("table");i.style.cssText=`
|
|
883
1162
|
width: 100%;
|
|
884
1163
|
border-collapse: collapse;
|
|
885
1164
|
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
@@ -887,13 +1166,13 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
887
1166
|
font-size: var(--fb-font-size);
|
|
888
1167
|
font-family: var(--fb-font-family);
|
|
889
1168
|
color: var(--fb-text-color);
|
|
890
|
-
`,n.forEach((l,s)=>{var u
|
|
1169
|
+
`,n.forEach((l,s)=>{var c,u;const d=(s===0?i.createTHead():(c=i.tBodies[0])!=null?c:i.createTBody()).insertRow();for(let f=0;f<o;f++){if(Zn(s,f,r))continue;const p=pt(s,f,r),m=document.createElement(s===0?"th":"td");if(p){const b=p.bottom-p.top+1,v=p.right-p.left+1;b>1&&(m.rowSpan=b),v>1&&(m.colSpan=v)}m.textContent=(u=l[f])!=null?u:"",m.style.cssText=`
|
|
891
1170
|
padding: 6px 10px;
|
|
892
1171
|
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
893
1172
|
text-align: left;
|
|
894
1173
|
vertical-align: top;
|
|
895
1174
|
${s===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":""}
|
|
896
|
-
`,
|
|
1175
|
+
`,d.appendChild(m)}});const a=document.createElement("div");a.style.cssText="overflow-x: auto; max-width: 100%;",a.appendChild(i),t.appendChild(a)}function hl(e,t,n,r,o,i){if(e.contentEditable==="true")return;e.contentEditable="true",e.focus();const a=document.createRange(),l=window.getSelection();a.selectNodeContents(e),a.collapse(!1),l==null||l.removeAllRanges(),l==null||l.addRange(a);function s(){var d;e.contentEditable="inherit";const f=r();f[t]&&(f[t][n]=(d=e.textContent)!=null?d:""),o()}function c(d){var f,p,m,b;const v=r(),w=(p=(f=v[0])==null?void 0:f.length)!=null?p:0;if(d.key==="Escape"){e.contentEditable="inherit",e.textContent=(b=(m=v[t])==null?void 0:m[n])!=null?b:"",e.removeEventListener("keydown",c),e.removeEventListener("blur",u);return}if(d.key==="Enter"&&!d.shiftKey){d.preventDefault(),d.stopPropagation(),s(),e.removeEventListener("keydown",c),e.removeEventListener("blur",u);const h=t+1<v.length?t+1:t;i(h,n);return}if(d.key==="Tab"){d.preventDefault(),d.stopPropagation(),s(),e.removeEventListener("keydown",c),e.removeEventListener("blur",u);let h=t,y=d.shiftKey?n-1:n+1;y<0&&(y=w-1,h=Math.max(0,t-1)),y>=w&&(y=0,h=Math.min(v.length-1,t+1)),i(h,y)}}function u(){e.contentEditable==="true"&&(s(),e.removeEventListener("keydown",c),e.removeEventListener("blur",u))}e.addEventListener("keydown",c),e.addEventListener("blur",u)}function bl(){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 gl(e,t){bl();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
|
|
897
1176
|
position: absolute; top: 0; left: 0; right: 0; bottom: 0;
|
|
898
1177
|
background: rgba(255,255,255,0.8); display: flex;
|
|
899
1178
|
align-items: center; justify-content: center; flex-direction: column;
|
|
@@ -902,13 +1181,13 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
902
1181
|
width: 24px; height: 24px; border: 3px solid var(--fb-border-color, #ccc);
|
|
903
1182
|
border-top-color: var(--fb-primary-color, #0066cc); border-radius: 50%;
|
|
904
1183
|
animation: fb-spin 0.8s linear infinite;
|
|
905
|
-
`;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
|
|
1184
|
+
`;const o=document.createElement("span");return o.textContent=t,o.style.cssText="font-size: var(--fb-font-size-small, 12px); color: var(--fb-text-color, #333);",n.appendChild(r),n.appendChild(o),e.appendChild(n),n}function vl(e,t,n,r,o){var i,a,l,s,c,u,d,f;const p=r.state,m=r.instance,b=e.mergeAllowed!==!1,v=(a=(i=e.fieldNames)==null?void 0:i.cells)!=null?a:"cells",w=(s=(l=e.fieldNames)==null?void 0:l.merges)!=null?s:"merges",h=t.cells.length>0?t.cells.map(A=>[...A]):Gn((c=e.rows)!=null?c:3,(u=e.columns)!=null?u:3);let y=t.merges?[...t.merges]:[];const g={anchor:null,focus:null,dragging:!1},C=document.createElement("input");C.type="hidden",C.name=n,C.value=JSON.stringify({[v]:h,[w]:y}),o.appendChild(C);function E(){C.value=JSON.stringify({[v]:h,[w]:y}),m&&m.triggerOnChange(n,{[v]:h,[w]:y})}C._applyExternalUpdate=A=>{h.length=0,A.cells.forEach(T=>h.push([...T])),y.length=0,A.merges&&A.merges.forEach(T=>y.push({...T})),g.anchor=null,g.focus=null,E(),N()};const x=document.createElement("div");x.style.cssText="position: relative; padding: 20px 20px 20px 24px; overflow-x: auto; max-width: 100%;";const $=document.createElement("table");$.style.cssText=`
|
|
906
1185
|
border-collapse: collapse;
|
|
907
1186
|
font-size: var(--fb-font-size);
|
|
908
1187
|
font-family: var(--fb-font-family);
|
|
909
1188
|
color: var(--fb-text-color);
|
|
910
1189
|
table-layout: fixed;
|
|
911
|
-
`,
|
|
1190
|
+
`,x.appendChild($);const z=(f=(d=e.importAccept)==null?void 0:d.map(A=>`.${A.toLowerCase()}`))!=null?f:[];async function q(A){var T,L,O;if(!p.config.parseTableFile)return;if(z.length>0){const F=A.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!z.includes(F))return}const U=gl(x,k("tableImporting",p));try{const F=await p.config.parseTableFile(A),re=F.cells,W=(T=F.merges)!=null?T:[];if(W.length>0){const V=Ot(W,re.length,(O=(L=re[0])==null?void 0:L.length)!=null?O:0);if(V)throw new Error(V)}h.length=0,re.forEach(V=>h.push([...V])),y.length=0,W.forEach(V=>y.push({...V})),g.anchor=null,g.focus=null,E(),N()}catch(F){const re=F instanceof Error?F.message:String(F);console.error(k("tableImportError",p).replace("{error}",re))}finally{U.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=`
|
|
912
1191
|
position: absolute; top: 2px; left: 2px;
|
|
913
1192
|
width: 20px; height: 20px;
|
|
914
1193
|
padding: 0;
|
|
@@ -918,7 +1197,7 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
918
1197
|
background: transparent;
|
|
919
1198
|
cursor: pointer;
|
|
920
1199
|
z-index: 2;
|
|
921
|
-
`,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=
|
|
1200
|
+
`,A.addEventListener("mouseenter",()=>{A.style.color="var(--fb-primary-color, #0066cc)"}),A.addEventListener("mouseleave",()=>{A.style.color="var(--fb-text-color, #999)"});const T=document.createElement("input");T.type="file",T.accept=z.join(","),T.style.display="none",x.appendChild(T),A.addEventListener("click",()=>{T.click()}),T.addEventListener("change",()=>{var O;const U=(O=T.files)==null?void 0:O[0];U&&q(U),T.value=""}),x.appendChild(A);let L=0;x.addEventListener("dragenter",O=>{O.preventDefault(),L++,L===1&&(x.style.outline="2px dashed var(--fb-primary-color, #0066cc)",x.style.outlineOffset="-2px")}),x.addEventListener("dragover",O=>{O.preventDefault(),O.dataTransfer&&(O.dataTransfer.dropEffect="copy")}),x.addEventListener("dragleave",O=>{O.preventDefault(),L--,L<=0&&(L=0,x.style.outline="",x.style.outlineOffset="")}),x.addEventListener("drop",O=>{var U,F;O.preventDefault(),L=0,x.style.outline="",x.style.outlineOffset="";const re=(F=(U=O.dataTransfer)==null?void 0:U.files)==null?void 0:F[0];re&&q(re)})}o.appendChild(x);const K=document.createElement("div");K.style.cssText=`
|
|
922
1201
|
position: fixed;
|
|
923
1202
|
display: none;
|
|
924
1203
|
background: white;
|
|
@@ -929,7 +1208,7 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
929
1208
|
z-index: 1000;
|
|
930
1209
|
gap: 4px;
|
|
931
1210
|
flex-direction: column;
|
|
932
|
-
`,o.appendChild(
|
|
1211
|
+
`,o.appendChild(K);function B(A,T){const L=document.createElement("button");return L.type="button",L.textContent=A,L.style.cssText=`
|
|
933
1212
|
padding: 4px 10px;
|
|
934
1213
|
font-size: var(--fb-font-size-small);
|
|
935
1214
|
color: var(--fb-text-color);
|
|
@@ -939,8 +1218,8 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
939
1218
|
cursor: pointer;
|
|
940
1219
|
white-space: nowrap;
|
|
941
1220
|
text-align: left;
|
|
942
|
-
`,
|
|
943
|
-
`),de=`<table>${_.join("")}</table>`;(U=F.clipboardData)==null||U.setData("text/plain",pe),(V=F.clipboardData)==null||V.setData("text/html",de)},L.onpaste=F=>{var ee,O,U,V,G,j,X,J,re;const Z=v.anchor;if(!Z)return;const _=(O=(ee=F.clipboardData)==null?void 0:ee.getData("text/plain"))!=null?O:"",pe=_.includes(" ")||_.split(/\r?\n/).filter(me=>me).length>1,de=L.querySelector("[contenteditable='true']");if(de&&!pe)return;if(F.preventDefault(),de){de.contentEditable="inherit";const me=parseInt((V=(U=de.closest("td"))==null?void 0:U.getAttribute("data-row"))!=null?V:"0",10),Ne=parseInt((j=(G=de.closest("td"))==null?void 0:G.getAttribute("data-col"))!=null?j:"0",10);h[me]&&(h[me][Ne]=(X=de.textContent)!=null?X:"")}if(!_.trim())return;const P=_.split(/\r?\n/).map(me=>me.split(" "));P.length>1&&P[P.length-1].length===1&&P[P.length-1][0]===""&&P.pop();const ce=Z.row,be=Z.col,ve=ce+P.length;for(;h.length<ve;)h.push(Array((re=(J=h[0])==null?void 0:J.length)!=null?re:1).fill(""));const we=Math.max(...P.map(me=>me.length)),Re=be+we;if(h[0]&&Re>h[0].length){const me=Re-h[0].length;h.forEach(Ne=>{for(let Xe=0;Xe<me;Xe++)Ne.push("")})}for(let me=0;me<P.length;me++)for(let Ne=0;Ne<P[me].length;Ne++){const Xe=ce+me,jl=be+Ne;h[Xe]&&(h[Xe][jl]=P[me][Ne])}C(),M()}}const I=Oe({label:"+",title:k("tableAddColumn",f),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=I.dataset.afterCol)!=null?A:"0",10);Ge(T)}});I.style.position="absolute",I.style.display="none",y.appendChild(I);const H=Oe({label:"+",title:k("tableAddRow",f),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=H.dataset.afterRow)!=null?A:"0",10);xe(T)}});H.style.position="absolute",H.style.display="none",y.appendChild(H);let te=[],ne=[];const ue=Oe({label:"+",title:k("tableAddColumn",f),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>Ge()});ue.style.position="absolute",ue.style.display="none",y.appendChild(ue);const se=Oe({label:"+",title:k("tableAddRow",f),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>xe()});se.style.position="absolute",se.style.display="none",y.appendChild(se);function he(){var A,T;te.forEach(O=>O.remove()),te=[],ne.forEach(O=>O.remove()),ne=[];const S=h.length>0?h[0].length:0,B=h.length;if(S>1){const O=Array.from(L.querySelectorAll("thead td[data-col]"));for(const U of O){const V=parseInt((A=U.getAttribute("data-col"))!=null?A:"0",10),G=Oe({label:"\xD7",title:k("tableRemoveColumn",f),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>$(V)});G.setAttribute("data-action","remove-col"),G.setAttribute("data-col",String(V)),G.style.position="absolute",G.style.display="none",y.appendChild(G),te.push(G)}}if(B>1){const O=[...L.tHead?Array.from(L.tHead.rows):[],...L.tBodies[0]?Array.from(L.tBodies[0].rows):[]].filter(U=>U.querySelector("td[data-row]"));for(const U of O){const V=U.querySelector("td[data-row]");if(!V)continue;const G=parseInt((T=V.getAttribute("data-row"))!=null?T:"0",10),j=Oe({label:"\xD7",title:k("tableRemoveRow",f),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>Pe(G)});j.setAttribute("data-action","remove-row"),j.setAttribute("data-row",String(G)),j.style.position="absolute",j.style.display="none",y.appendChild(j),ne.push(j)}}function D(O,U,V,G,j){var X;const J=j?Array.from(L.querySelectorAll("thead td[data-col]")):[];let re=-1,Z=1/0,_=-1,pe=-1,de=1/0;for(let P=0;P<J.length;P++){const ce=J[P].getBoundingClientRect(),be=(ce.left+ce.right)/2,ve=Math.abs(O-be);ve<Z&&(Z=ve,re=P);const we=Math.abs(O-ce.right);we<de&&we<20&&(de=we,_=ce.right-U.left+G,pe=parseInt((X=J[P].getAttribute("data-col"))!=null?X:"0",10))}te.forEach((P,ce)=>{if(!j||ce!==re){P.style.display="none";return}const be=J[ce].getBoundingClientRect(),ve=(be.left+be.right)/2-U.left+G;P.style.left=`${ve-8}px`,P.style.top="2px",P.style.display="flex"}),j&&pe>=0?(I.style.display="flex",I.style.left=`${_-10}px`,I.style.top=`${V.top-U.top-10}px`,I.dataset.afterCol=String(pe)):I.style.display="none"}function F(O,U,V,G,j){var X;const J=[];if(j){if(L.tHead)for(const P of Array.from(L.tHead.rows))P.querySelector("td[data-row]")&&J.push(P);if(L.tBodies[0])for(const P of Array.from(L.tBodies[0].rows))P.querySelector("td[data-row]")&&J.push(P)}let re=-1,Z=1/0,_=-1,pe=-1,de=1/0;for(let P=0;P<J.length;P++){const ce=J[P].getBoundingClientRect(),be=(ce.top+ce.bottom)/2,ve=Math.abs(O-be);ve<Z&&(Z=ve,re=P);const we=Math.abs(O-ce.bottom);if(we<de&&we<14){de=we,_=ce.bottom-U.top;const Re=J[P].querySelector("td[data-row]");pe=parseInt((X=Re==null?void 0:Re.getAttribute("data-row"))!=null?X:"0",10)}}ne.forEach((P,ce)=>{if(!j||ce!==re){P.style.display="none";return}const be=J[ce].getBoundingClientRect(),ve=(be.top+be.bottom)/2-U.top;P.style.left="4px",P.style.top=`${ve-8}px`,P.style.display="flex"}),j&&pe>=0?(H.style.display="flex",H.style.top=`${_-10}px`,H.style.left=`${V.left-U.left+G-10}px`,H.dataset.afterRow=String(pe)):H.style.display="none"}let ee=!1;y.onmousemove=O=>{const U=O.target;if(U.tagName==="BUTTON"&&U.parentElement===y||ee)return;ee=!0;const V=O.clientX,G=O.clientY;requestAnimationFrame(()=>{ee=!1;const j=y.getBoundingClientRect(),X=L.getBoundingClientRect(),J=y.scrollLeft,re=G>=j.top&&G<X.top+4,Z=V>=j.left&&V<X.left+4,_=Math.min(X.right,j.right),pe=V>_-20&&V<=j.right,de=G>X.bottom-4&&G<=j.bottom+20;if(D(V,j,X,J,re),F(G,j,X,J,Z),ue.style.display=pe?"flex":"none",pe&&(ue.style.left=`${j.right-j.left+J-20}px`,ue.style.top=`${(X.top+X.bottom)/2-j.top-10}px`),se.style.display=de?"flex":"none",de){const P=(j.left+j.right)/2-j.left+J;se.style.left=`${P-10}px`,se.style.top=`${X.bottom-j.top-10}px`}})},y.onmouseleave=()=>{te.forEach(O=>{O.style.display="none"}),ne.forEach(O=>{O.style.display="none"}),I.style.display="none",H.style.display="none",ue.style.display="none",se.style.display="none"}}M()}function tl(e){var t,n;return{cells:Vn((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function It(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function Rt(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function nl(e,t,n,r){var o,a,i,l;const s=t.state,u=oe(e,s,t),d=t.prefill[e.key],c=(a=(o=e.fieldNames)==null?void 0:o.cells)!=null?a:"cells",p=(l=(i=e.fieldNames)==null?void 0:i.merges)!=null?l:"merges";let f;if(It(d))f={cells:d.cells,merges:d.merges?je(d.merges):[]};else if(d&&Rt(d,c)){const m=d[p];f={cells:d[c],merges:m?je(m):[]}}else if(It(e.default))f={cells:e.default.cells,merges:e.default.merges?je(e.default.merges):[]};else if(e.default&&Rt(e.default,c)){const m=e.default[p];f={cells:e.default[c],merges:m?je(m):[]}}else f=tl(e);if(f.merges&&f.merges.length>0){const m=f.cells.length,b=m>0?f.cells[0].length:0,g=qt(f.merges,m,b);g&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${g})`),f={...f,merges:[]})}u?Go(f,n):el(e,f,r,t,n)}function rl(e,t,n){var r,o;const{scopeRoot:a,skipValidation:i}=n,l=[],s=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",u=a.querySelector(`[name="${t}"]`);if(!u)return{value:null,errors:l};let d=null;try{d=JSON.parse(u.value)}catch(c){return l.push(`${t}: invalid table data`),{value:null,errors:l}}if(!i&&e.required){const c=d[s];c!=null&&c.some(p=>p.some(f=>f.trim()!==""))||l.push(`${t}: ${k("required",n.state)}`)}return{value:d,errors:l}}function ol(e,t,n,r){var o,a,i,l;const{scopeRoot:s}=r,u=(a=(o=e.fieldNames)==null?void 0:o.cells)!=null?a:"cells",d=(l=(i=e.fieldNames)==null?void 0:i.merges)!=null?l:"merges",c=s.querySelector(`[name="${t}"]`);if(!c){console.warn(`updateTableField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let p=null;if(It(n))p={cells:n.cells,merges:n.merges?je(n.merges):[]};else if(n&&Rt(n,u)){const f=n[d];p={cells:n[u],merges:f?je(f):[]}}p&&c._applyExternalUpdate?c._applyExternalUpdate(p):c.value=JSON.stringify(n)}function ll(e,t){e.style.overflow="hidden",e.style.resize="none";const n=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(3,n);const r=()=>{e.isConnected&&(e.style.height="0",e.style.height=`${e.scrollHeight}px`,t&&(t.style.height=`${e.scrollHeight}px`))};e.addEventListener("input",r),setTimeout(()=>{e.isConnected&&r()},0)}function Ht(e,t){var n,r,o,a;const i=new Map,l=new Map;for(const s of e){const u=t.resourceIndex.get(s),d=(n=u==null?void 0:u.name)!=null?n:s;l.set(d,((r=l.get(d))!=null?r:0)+1)}for(const s of e){const u=t.resourceIndex.get(s),d=(o=u==null?void 0:u.name)!=null?o:s;((a=l.get(d))!=null?a:1)>1&&u?i.set(s,`${d} (${mr(u.size)})`):i.set(s,d)}return i}function Bt(e){return e?e.type.startsWith("image/"):!1}function Kn(e,t){const n=Ht(e,t),r=new Map;for(const o of e){const a=n.get(o);a&&r.set(a,o)}return r}function Dt(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function ct(e){const t=[],n=e.length;let r=0;for(;r<n;)if(e[r]==="@"){if(r>0&&!/\s/.test(e[r-1])){r++;continue}const o=r;if(r++,r<n&&e[r]==='"'){r++;let a="";for(;r<n&&e[r]!=='"';)e[r]==="\\"&&r+1<n?(a+=e[r+1],r+=2):(a+=e[r],r++);r<n&&e[r]==='"'&&(r++,(r>=n||/\s/.test(e[r]))&&t.push({start:o,end:r,raw:e.slice(o,r),name:a}))}else if(r<n&&!/\s/.test(e[r])){const a=r;for(;r<n&&!/\s/.test(e[r]);)r++;const i=e.slice(a,r);t.push({start:o,end:r,raw:e.slice(o,r),name:i})}}else r++;return t}function il(e,t){if(t.size===0)return[];const n=ct(e),r=[];for(const o of n){const a=t.get(o.name);a&&r.push({start:o.start,end:o.end,name:o.name,rid:a})}return r}function al(e,t){const n=il(e,t);if(n.length===0)return e;let r="",o=0;for(const a of n)r+=e.slice(o,a.start),r+=`@${a.rid}`,o=a.end;return r+=e.slice(o),r}function Jn(e,t,n){const r=Ht(t,n),o=new Map;for(const s of t){const u=r.get(s);u&&o.set(s,u)}const a=ct(e);if(a.length===0)return e;let i="",l=0;for(const s of a){i+=e.slice(l,s.start);const u=o.get(s.name);u?i+=Dt(u):i+=s.raw,l=s.end}return i+=e.slice(l),i}function Yn(e,t,n,r){if(ge(e),n!=null&&n.file&&Bt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const a=new FileReader;a.onload=i=>{var l;o.src=((l=i.target)==null?void 0:l.result)||""},a.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(a=>{var i;if(!a||!e.isConnected)return;const l=document.createElement("img");l.alt=(i=n==null?void 0:n.name)!=null?i:t,l.src=a,l.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",ge(e),e.appendChild(l)}).catch(a=>{var i,l;(l=(i=r.config).onThumbnailError)==null||l.call(i,a,t)});const o=document.createElement("div");o.style.cssText="width: 100%; height: 100%; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',e.appendChild(o)}else{const o=document.createElement("div");if(o.style.cssText="width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px; box-sizing: border-box;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>',n!=null&&n.name){const a=document.createElement("span");a.style.cssText="font-size: 9px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 44px; color: var(--fb-text-color, #111827);",a.textContent=n.name,o.appendChild(a)}e.appendChild(o)}}function Gn(e,t,n,r){if(ge(e),n!=null&&n.file&&Bt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;";const a=new FileReader;a.onload=i=>{var l;o.src=((l=i.target)==null?void 0:l.result)||""},a.readAsDataURL(n.file),e.appendChild(o)}else r.config.getThumbnail&&r.config.getThumbnail(t).then(o=>{var a;if(!o||!e.isConnected)return;const i=document.createElement("img");i.alt=(a=n==null?void 0:n.name)!=null?a:t,i.src=o,i.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",ge(e),e.appendChild(i)}).catch(o=>{var a,i;(i=(a=r.config).onThumbnailError)==null||i.call(a,o,t)})}function Xn(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=Math.max(4,Math.min(n.left+n.width/2-r.width/2,window.innerWidth-r.width-4)),a=n.top-r.height-8,i=n.bottom+8,l=a>=4?a:i;e.style.left=`${o}px`,e.style.top=`${Math.max(4,l)}px`}function Zn(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=`
|
|
1221
|
+
`,L.addEventListener("mouseenter",()=>{L.style.background="var(--fb-background-hover-color)"}),L.addEventListener("mouseleave",()=>{L.style.background="transparent"}),L.addEventListener("click",()=>{D(),T()}),L}function M(A,T){if(!b)return;K.innerHTML="",K.style.display="flex";const L=Ne(g),O=L&&(L.r1!==L.r2||L.c1!==L.c2),U=g.anchor&&pt(g.anchor.row,g.anchor.col,y);if(O&&K.appendChild(B(k("tableMergeCells",p),R)),U&&K.appendChild(B(k("tableSplitCell",p),I)),!K.firstChild){D();return}const F=140,re=K.children.length*32+8,W=window.innerWidth,V=window.innerHeight,Y=A+F>W?A-F:A,Z=T+re>V?T-re:T;K.style.left=`${Y}px`,K.style.top=`${Z}px`}function D(){K.style.display="none"}const J=new AbortController;document.addEventListener("mousedown",A=>{if(!o.isConnected){J.abort();return}K.contains(A.target)||D()},{signal:J.signal});function Q(){const A=Ne(g);$.querySelectorAll("td[data-row]").forEach(T=>{const L=parseInt(T.getAttribute("data-row")||"0",10),O=parseInt(T.getAttribute("data-col")||"0",10),U=g.anchor!==null&&g.anchor.row===L&&g.anchor.col===O,F=A!==null&&L>=A.r1&&L<=A.r2&&O>=A.c1&&O<=A.c2;T.style.outline=U?"2px solid var(--fb-primary-color, #0066cc)":"",T.style.outlineOffset=U?"-2px":"",L===0?T.style.backgroundColor="var(--fb-background-hover-color)":T.style.backgroundColor=F&&!U?"rgba(0,102,204,0.08)":""})}function ne(A,T){g.anchor={row:A,col:T},g.focus=null,Q(),$.focus()}function he(A,T){const L=$.querySelector(`td[data-row="${A}"][data-col="${T}"]`);if(!L)return;const O=L.querySelector("span");O&&(g.anchor={row:A,col:T},g.focus=null,Q(),hl(O,A,T,()=>h,E,ne))}function Ce(A){var T;const L=h.length>0?h[0].length:(T=e.columns)!=null?T:3,O=Array(L).fill(""),U=A!==void 0?A+1:h.length;h.splice(U,0,O),y=y.map(F=>F.top>=U?{...F,top:F.top+1,bottom:F.bottom+1}:F.top<U&&F.bottom>=U?{...F,bottom:F.bottom+1}:F),E(),N()}function Ke(A){if(h.length<=1)return;const T=A!==void 0?A:g.anchor?g.anchor.row:h.length-1;y=y.map(L=>L.top===T&&L.bottom===T?null:L.top===T?{...L,bottom:L.bottom-1}:L.bottom===T?{...L,bottom:L.bottom-1}:L.top<T&&L.bottom>T?{...L,bottom:L.bottom-1}:L.top>T?{...L,top:L.top-1,bottom:L.bottom-1}:L).filter(L=>L!==null),h.splice(T,1),g.anchor&&g.anchor.row>=h.length&&(g.anchor={row:h.length-1,col:g.anchor.col}),E(),N()}function et(A){var T,L;const O=A!==void 0?A+1:(L=(T=h[0])==null?void 0:T.length)!=null?L:0;h.forEach(U=>U.splice(O,0,"")),y=y.map(U=>U.left>=O?{...U,left:U.left+1,right:U.right+1}:U.left<O&&U.right>=O?{...U,right:U.right+1}:U),E(),N()}function S(A){if(h.length===0||h[0].length<=1)return;const T=A!==void 0?A:g.anchor?g.anchor.col:h[0].length-1;y=y.map(L=>L.left===T&&L.right===T?null:L.left===T?{...L,right:L.right-1}:L.right===T?{...L,right:L.right-1}:L.left<T&&L.right>T?{...L,right:L.right-1}:L.left>T?{...L,left:L.left-1,right:L.right-1}:L).filter(L=>L!==null),h.forEach(L=>L.splice(T,1)),g.anchor&&g.anchor.col>=h[0].length&&(g.anchor={row:g.anchor.row,col:h[0].length-1}),E(),N()}function R(){var A,T;if(!b)return;const L=Ne(g);if(!L)return;const{r1:O,c1:U,r2:F,c2:re}=L;if(O===F&&U===re)return;y=y.filter(P=>!(P.top<=F&&P.bottom>=O&&P.left<=re&&P.right>=U));const W=h[O][U];for(let P=O;P<=F;P++)for(let ee=U;ee<=re;ee++)(P!==O||ee!==U)&&(h[P][ee]="");h[O][U]=W;const V={top:O,left:U,bottom:F,right:re},Y=[...y,V],Z=Ot(Y,h.length,(T=(A=h[0])==null?void 0:A.length)!=null?T:0);if(Z){console.warn("Merge validation failed:",Z);return}y.push(V),g.anchor={row:O,col:U},g.focus=null,E(),N()}function I(){if(!b||!g.anchor)return;const{row:A,col:T}=g.anchor,L=y.findIndex(O=>O.top===A&&O.left===T);L!==-1&&(y.splice(L,1),g.focus=null,E(),N())}function N(){var A,T;$.innerHTML="";const L=h.length,O=L>0?h[0].length:0,U=Ne(g);for(let F=0;F<L;F++){const re=(F===0?(A=$.tHead)!=null?A:$.createTHead():(T=$.tBodies[0])!=null?T:$.createTBody()).insertRow();for(let W=0;W<O;W++){if(Zn(F,W,y))continue;const V=pt(F,W,y),Y=document.createElement("td");if(Y.setAttribute("data-row",String(F)),Y.setAttribute("data-col",String(W)),V){const te=V.bottom-V.top+1,X=V.right-V.left+1;te>1&&(Y.rowSpan=te),X>1&&(Y.colSpan=X)}const Z=U!==null&&F>=U.r1&&F<=U.r2&&W>=U.c1&&W<=U.c2,P=g.anchor!==null&&g.anchor.row===F&&g.anchor.col===W;Y.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&&!P?"background-color: rgba(0,102,204,0.08);":"",P?"outline: 2px solid var(--fb-primary-color, #0066cc); outline-offset: -2px;":""].join(" ");const ee=document.createElement("span");ee.textContent=h[F][W],ee.style.cssText="display: block; min-height: 1.4em; white-space: pre-wrap; word-break: break-word; outline: none;",Y.appendChild(ee);const G=F,ie=W;Y.addEventListener("mousedown",te=>{if(te.target.tagName!=="BUTTON"&&te.target.contentEditable!=="true"){if(te.button===2){const X=Ne(g);if(X&&G>=X.r1&&G<=X.r2&&ie>=X.c1&&ie<=X.c2)return}te.shiftKey&&g.anchor?(te.preventDefault(),g.focus={row:G,col:ie},g.dragging=!1,Q()):(g.anchor={row:G,col:ie},g.focus=null,g.dragging=!0,Q())}}),Y.addEventListener("mouseup",te=>{if(te.target.tagName!=="BUTTON"&&g.dragging){g.dragging=!1;const X=Ne(g);(!X||X.r1===X.r2&&X.c1===X.c2)&&he(G,ie)}}),Y.addEventListener("mousemove",te=>{if(g.dragging&&te.buttons===1){const X=g.anchor;X&&(X.row!==G||X.col!==ie)&&(g.focus={row:G,col:ie},Q())}}),Y.addEventListener("contextmenu",te=>{if(!b)return;const X=Ne(g),pe=X&&(X.r1!==X.r2||X.c1!==X.c2),fe=g.anchor&&pt(g.anchor.row,g.anchor.col,y);(pe||fe)&&(te.preventDefault(),M(te.clientX,te.clientY))}),re.appendChild(Y)}}be(),$.setAttribute("tabindex","0"),$.onkeydown=F=>{var re,W;if($.querySelector("[contenteditable='true']"))return;const V=g.anchor;if(!V)return;const Y=h.length,Z=Y>0?h[0].length:0,P={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]};if(P[F.key]){F.preventDefault();const[ee,G]=P[F.key],ie=Math.max(0,Math.min(Y-1,V.row+ee)),te=Math.max(0,Math.min(Z-1,V.col+G));F.shiftKey?(g.focus={row:ie,col:te},Q()):ne(ie,te);return}if(F.key==="Enter"){F.preventDefault(),he(V.row,V.col);return}if(F.key==="Tab"){F.preventDefault();const ee=(W=(re=h[0])==null?void 0:re.length)!=null?W:0;let G=V.row,ie=F.shiftKey?V.col-1:V.col+1;ie<0&&(ie=ee-1,G=Math.max(0,G-1)),ie>=ee&&(ie=0,G=Math.min(h.length-1,G+1)),ne(G,ie);return}if(b&&F.key==="m"&&F.ctrlKey&&!F.shiftKey){F.preventDefault(),R();return}b&&F.key==="M"&&F.ctrlKey&&F.shiftKey&&(F.preventDefault(),I())},$.oncopy=F=>{var re,W,V,Y;const Z=Ne(g);if(!Z)return;F.preventDefault();const{r1:P,c1:ee,r2:G,c2:ie}=Z,te=[],X=[];for(let _=P;_<=G;_++){const ue=[],ge=[];for(let ve=ee;ve<=ie;ve++){const Ee=(W=(re=h[_])==null?void 0:re[ve])!=null?W:"";ue.push(Ee);const Be=Ee.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");ge.push(`<td>${Be}</td>`)}te.push(ue.join(" ")),X.push(`<tr>${ge.join("")}</tr>`)}const pe=te.join(`
|
|
1222
|
+
`),fe=`<table>${X.join("")}</table>`;(V=F.clipboardData)==null||V.setData("text/plain",pe),(Y=F.clipboardData)==null||Y.setData("text/html",fe)},$.onpaste=F=>{var re,W,V,Y,Z,P,ee,G,ie;const te=g.anchor;if(!te)return;const X=(W=(re=F.clipboardData)==null?void 0:re.getData("text/plain"))!=null?W:"",pe=X.includes(" ")||X.split(/\r?\n/).filter(me=>me).length>1,fe=$.querySelector("[contenteditable='true']");if(fe&&!pe)return;if(F.preventDefault(),fe){fe.contentEditable="inherit";const me=parseInt((Y=(V=fe.closest("td"))==null?void 0:V.getAttribute("data-row"))!=null?Y:"0",10),Ie=parseInt((P=(Z=fe.closest("td"))==null?void 0:Z.getAttribute("data-col"))!=null?P:"0",10);h[me]&&(h[me][Ie]=(ee=fe.textContent)!=null?ee:"")}if(!X.trim())return;const _=X.split(/\r?\n/).map(me=>me.split(" "));_.length>1&&_[_.length-1].length===1&&_[_.length-1][0]===""&&_.pop();const ue=te.row,ge=te.col,ve=ue+_.length;for(;h.length<ve;)h.push(Array((ie=(G=h[0])==null?void 0:G.length)!=null?ie:1).fill(""));const Ee=Math.max(..._.map(me=>me.length)),Be=ge+Ee;if(h[0]&&Be>h[0].length){const me=Be-h[0].length;h.forEach(Ie=>{for(let tt=0;tt<me;tt++)Ie.push("")})}for(let me=0;me<_.length;me++)for(let Ie=0;Ie<_[me].length;Ie++){const tt=ue+me,oi=ge+Ie;h[tt]&&(h[tt][oi]=_[me][Ie])}E(),N()}}const H=Pe({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=H.dataset.afterCol)!=null?A:"0",10);et(T)}});H.style.position="absolute",H.style.display="none",x.appendChild(H);const j=Pe({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=j.dataset.afterRow)!=null?A:"0",10);Ce(T)}});j.style.position="absolute",j.style.display="none",x.appendChild(j);let oe=[],le=[];const de=Pe({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>et()});de.style.position="absolute",de.style.display="none",x.appendChild(de);const ce=Pe({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>Ce()});ce.style.position="absolute",ce.style.display="none",x.appendChild(ce);function be(){var A,T;oe.forEach(W=>W.remove()),oe=[],le.forEach(W=>W.remove()),le=[];const L=h.length>0?h[0].length:0,O=h.length;if(L>1){const W=Array.from($.querySelectorAll("thead td[data-col]"));for(const V of W){const Y=parseInt((A=V.getAttribute("data-col"))!=null?A:"0",10),Z=Pe({label:"\xD7",title:k("tableRemoveColumn",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>S(Y)});Z.setAttribute("data-action","remove-col"),Z.setAttribute("data-col",String(Y)),Z.style.position="absolute",Z.style.display="none",x.appendChild(Z),oe.push(Z)}}if(O>1){const W=[...$.tHead?Array.from($.tHead.rows):[],...$.tBodies[0]?Array.from($.tBodies[0].rows):[]].filter(V=>V.querySelector("td[data-row]"));for(const V of W){const Y=V.querySelector("td[data-row]");if(!Y)continue;const Z=parseInt((T=Y.getAttribute("data-row"))!=null?T:"0",10),P=Pe({label:"\xD7",title:k("tableRemoveRow",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>Ke(Z)});P.setAttribute("data-action","remove-row"),P.setAttribute("data-row",String(Z)),P.style.position="absolute",P.style.display="none",x.appendChild(P),le.push(P)}}function U(W,V,Y,Z,P){var ee;const G=P?Array.from($.querySelectorAll("thead td[data-col]")):[];let ie=-1,te=1/0,X=-1,pe=-1,fe=1/0;for(let _=0;_<G.length;_++){const ue=G[_].getBoundingClientRect(),ge=(ue.left+ue.right)/2,ve=Math.abs(W-ge);ve<te&&(te=ve,ie=_);const Ee=Math.abs(W-ue.right);Ee<fe&&Ee<20&&(fe=Ee,X=ue.right-V.left+Z,pe=parseInt((ee=G[_].getAttribute("data-col"))!=null?ee:"0",10))}oe.forEach((_,ue)=>{if(!P||ue!==ie){_.style.display="none";return}const ge=G[ue].getBoundingClientRect(),ve=(ge.left+ge.right)/2-V.left+Z;_.style.left=`${ve-8}px`,_.style.top="2px",_.style.display="flex"}),P&&pe>=0?(H.style.display="flex",H.style.left=`${X-10}px`,H.style.top=`${Y.top-V.top-10}px`,H.dataset.afterCol=String(pe)):H.style.display="none"}function F(W,V,Y,Z,P){var ee;const G=[];if(P){if($.tHead)for(const _ of Array.from($.tHead.rows))_.querySelector("td[data-row]")&&G.push(_);if($.tBodies[0])for(const _ of Array.from($.tBodies[0].rows))_.querySelector("td[data-row]")&&G.push(_)}let ie=-1,te=1/0,X=-1,pe=-1,fe=1/0;for(let _=0;_<G.length;_++){const ue=G[_].getBoundingClientRect(),ge=(ue.top+ue.bottom)/2,ve=Math.abs(W-ge);ve<te&&(te=ve,ie=_);const Ee=Math.abs(W-ue.bottom);if(Ee<fe&&Ee<14){fe=Ee,X=ue.bottom-V.top;const Be=G[_].querySelector("td[data-row]");pe=parseInt((ee=Be==null?void 0:Be.getAttribute("data-row"))!=null?ee:"0",10)}}le.forEach((_,ue)=>{if(!P||ue!==ie){_.style.display="none";return}const ge=G[ue].getBoundingClientRect(),ve=(ge.top+ge.bottom)/2-V.top;_.style.left="4px",_.style.top=`${ve-8}px`,_.style.display="flex"}),P&&pe>=0?(j.style.display="flex",j.style.top=`${X-10}px`,j.style.left=`${Y.left-V.left+Z-10}px`,j.dataset.afterRow=String(pe)):j.style.display="none"}let re=!1;x.onmousemove=W=>{const V=W.target;if(V.tagName==="BUTTON"&&V.parentElement===x||re)return;re=!0;const Y=W.clientX,Z=W.clientY;requestAnimationFrame(()=>{re=!1;const P=x.getBoundingClientRect(),ee=$.getBoundingClientRect(),G=x.scrollLeft,ie=Z>=P.top&&Z<ee.top+4,te=Y>=P.left&&Y<ee.left+4,X=Math.min(ee.right,P.right),pe=Y>X-20&&Y<=P.right,fe=Z>ee.bottom-4&&Z<=P.bottom+20;if(U(Y,P,ee,G,ie),F(Z,P,ee,G,te),de.style.display=pe?"flex":"none",pe&&(de.style.left=`${P.right-P.left+G-20}px`,de.style.top=`${(ee.top+ee.bottom)/2-P.top-10}px`),ce.style.display=fe?"flex":"none",fe){const _=(P.left+P.right)/2-P.left+G;ce.style.left=`${_-10}px`,ce.style.top=`${ee.bottom-P.top-10}px`}})},x.onmouseleave=()=>{oe.forEach(W=>{W.style.display="none"}),le.forEach(W=>{W.style.display="none"}),H.style.display="none",j.style.display="none",de.style.display="none",ce.style.display="none"}}N()}function yl(e){var t,n;return{cells:Gn((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function Ut(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function Pt(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function xl(e,t,n,r){var o,i,a,l;const s=t.state,c=ae(e,s,t),u=t.prefill[e.key],d=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",f=(l=(a=e.fieldNames)==null?void 0:a.merges)!=null?l:"merges";let p;if(Ut(u))p={cells:u.cells,merges:u.merges?Ue(u.merges):[]};else if(u&&Pt(u,d)){const m=u[f];p={cells:u[d],merges:m?Ue(m):[]}}else if(Ut(e.default))p={cells:e.default.cells,merges:e.default.merges?Ue(e.default.merges):[]};else if(e.default&&Pt(e.default,d)){const m=e.default[f];p={cells:e.default[d],merges:m?Ue(m):[]}}else p=yl(e);if(p.merges&&p.merges.length>0){const m=p.cells.length,b=m>0?p.cells[0].length:0,v=Ot(p.merges,m,b);v&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${v})`),p={...p,merges:[]})}c?ml(p,n):vl(e,p,r,t,n)}function wl(e,t,n){var r,o;const{scopeRoot:i,skipValidation:a}=n,l=[],s=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",c=i.querySelector(`[name="${t}"]`);if(!c)return{value:null,errors:l};let u=null;try{u=JSON.parse(c.value)}catch(d){return l.push(`${t}: invalid table data`),{value:null,errors:l}}if(!a&&e.required){const d=u[s];d!=null&&d.some(f=>f.some(p=>p.trim()!==""))||l.push(`${t}: ${k("required",n.state)}`)}return{value:u,errors:l}}function Cl(e,t,n,r){var o,i,a,l;const{scopeRoot:s}=r,c=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",u=(l=(a=e.fieldNames)==null?void 0:a.merges)!=null?l:"merges",d=s.querySelector(`[name="${t}"]`);if(!d){console.warn(`updateTableField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let f=null;if(Ut(n))f={cells:n.cells,merges:n.merges?Ue(n.merges):[]};else if(n&&Pt(n,c)){const p=n[u];f={cells:n[c],merges:p?Ue(p):[]}}f&&d._applyExternalUpdate?d._applyExternalUpdate(f):d.value=JSON.stringify(n)}function El(e,t){e.style.overflow="hidden",e.style.resize="none";const n=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(3,n);const r=()=>{e.isConnected&&(e.style.height="0",e.style.height=`${e.scrollHeight}px`,t&&(t.style.height=`${e.scrollHeight}px`))};e.addEventListener("input",r),setTimeout(()=>{e.isConnected&&r()},0)}function Wt(e,t){var n,r,o,i;const a=new Map,l=new Map;for(const s of e){const c=t.resourceIndex.get(s),u=(n=c==null?void 0:c.name)!=null?n:s;l.set(u,((r=l.get(u))!=null?r:0)+1)}for(const s of e){const c=t.resourceIndex.get(s),u=(o=c==null?void 0:c.name)!=null?o:s;((i=l.get(u))!=null?i:1)>1&&c?a.set(s,`${u} (${yr(c.size)})`):a.set(s,u)}return a}function Vt(e){return e?e.type.startsWith("image/"):!1}function Qn(e,t){const n=Wt(e,t),r=new Map;for(const o of e){const i=n.get(o);i&&r.set(i,o)}return r}function Kt(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function mt(e){const t=[],n=e.length;let r=0;for(;r<n;)if(e[r]==="@"){if(r>0&&!/\s/.test(e[r-1])){r++;continue}const o=r;if(r++,r<n&&e[r]==='"'){r++;let i="";for(;r<n&&e[r]!=='"';)e[r]==="\\"&&r+1<n?(i+=e[r+1],r+=2):(i+=e[r],r++);r<n&&e[r]==='"'&&(r++,(r>=n||/\s/.test(e[r]))&&t.push({start:o,end:r,raw:e.slice(o,r),name:i}))}else if(r<n&&!/\s/.test(e[r])){const i=r;for(;r<n&&!/\s/.test(e[r]);)r++;const a=e.slice(i,r);t.push({start:o,end:r,raw:e.slice(o,r),name:a})}}else r++;return t}function kl(e,t){if(t.size===0)return[];const n=mt(e),r=[];for(const o of n){const i=t.get(o.name);i&&r.push({start:o.start,end:o.end,name:o.name,rid:i})}return r}function $l(e,t){const n=kl(e,t);if(n.length===0)return e;let r="",o=0;for(const i of n)r+=e.slice(o,i.start),r+=`@${i.rid}`,o=i.end;return r+=e.slice(o),r}function er(e,t,n){const r=Wt(t,n),o=new Map;for(const s of t){const c=r.get(s);c&&o.set(s,c)}const i=mt(e);if(i.length===0)return e;let a="",l=0;for(const s of i){a+=e.slice(l,s.start);const c=o.get(s.name);c?a+=Kt(c):a+=s.raw,l=s.end}return a+=e.slice(l),a}function tr(e,t,n,r){if(ye(e),n!=null&&n.file&&Vt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const i=new FileReader;i.onload=a=>{var l;o.src=((l=a.target)==null?void 0:l.result)||""},i.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(i=>{var a;if(!i||!e.isConnected)return;const l=document.createElement("img");l.alt=(a=n==null?void 0:n.name)!=null?a:t,l.src=i,l.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",ye(e),e.appendChild(l)}).catch(i=>{var a,l;(l=(a=r.config).onThumbnailError)==null||l.call(a,i,t)});const o=document.createElement("div");o.style.cssText="width: 100%; height: 100%; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',e.appendChild(o)}else{const o=document.createElement("div");if(o.style.cssText="width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px; box-sizing: border-box;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>',n!=null&&n.name){const i=document.createElement("span");i.style.cssText="font-size: 9px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 44px; color: var(--fb-text-color, #111827);",i.textContent=n.name,o.appendChild(i)}e.appendChild(o)}}function nr(e,t,n,r){if(ye(e),n!=null&&n.file&&Vt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;";const i=new FileReader;i.onload=a=>{var l;o.src=((l=a.target)==null?void 0:l.result)||""},i.readAsDataURL(n.file),e.appendChild(o)}else r.config.getThumbnail&&r.config.getThumbnail(t).then(o=>{var i;if(!o||!e.isConnected)return;const a=document.createElement("img");a.alt=(i=n==null?void 0:n.name)!=null?i:t,a.src=o,a.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",ye(e),e.appendChild(a)}).catch(o=>{var i,a;(a=(i=r.config).onThumbnailError)==null||a.call(i,o,t)})}function rr(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=Math.max(4,Math.min(n.left+n.width/2-r.width/2,window.innerWidth-r.width-4)),i=n.top-r.height-8,a=n.bottom+8,l=i>=4?i:a;e.style.left=`${o}px`,e.style.top=`${Math.max(4,l)}px`}function or(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=`
|
|
944
1223
|
position: fixed;
|
|
945
1224
|
z-index: 99999;
|
|
946
1225
|
background: #fff;
|
|
@@ -951,7 +1230,7 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
951
1230
|
pointer-events: none;
|
|
952
1231
|
min-width: 60px;
|
|
953
1232
|
max-width: 140px;
|
|
954
|
-
`;const
|
|
1233
|
+
`;const i=document.createElement("div");return i.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",nr(i,t,r,n),o.appendChild(i),document.body.appendChild(o),rr(o,e),o}function lr(e,t){var n,r;const{rid:o,state:i,isReadonly:a,onMention:l,onRemove:s}=t,c=i.resourceIndex.get(o),u=(n=c==null?void 0:c.name)!=null?n:o,d=document.createElement("div");d.className="fb-richinput-portal-tooltip fb-richinput-file-tooltip",d.style.cssText=`
|
|
955
1234
|
position: fixed;
|
|
956
1235
|
z-index: 99999;
|
|
957
1236
|
background: #fff;
|
|
@@ -962,17 +1241,17 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
962
1241
|
pointer-events: auto;
|
|
963
1242
|
min-width: 80px;
|
|
964
1243
|
max-width: 260px;
|
|
965
|
-
`;const
|
|
1244
|
+
`;const f=document.createElement("div");f.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",nr(f,o,c,i),d.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=u,d.appendChild(p);const m=document.createElement("div");m.style.cssText="display: flex; align-items: center; gap: 2px; padding: 3px 4px 2px; border-top: 1px solid var(--fb-border-color, #d1d5db); justify-content: center;";const b="background: none; border: none; cursor: pointer; padding: 3px 5px; border-radius: 4px; color: var(--fb-text-muted-color, #6b7280); display: flex; align-items: center; transition: background 0.1s, color 0.1s;",v=h=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-text-color, #111827)"},w=h=>{h.style.background="none",h.style.color="var(--fb-text-muted-color, #6b7280)"};if(!a&&l){const h=document.createElement("button");h.type="button",h.title="Mention",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"/></svg>',h.addEventListener("mouseenter",()=>v(h)),h.addEventListener("mouseleave",()=>w(h)),h.addEventListener("click",y=>{y.stopPropagation(),l(),d.remove()}),m.appendChild(h)}if(i.config.downloadFile){const h=document.createElement("button");h.type="button",h.title="Download",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',h.addEventListener("mouseenter",()=>v(h)),h.addEventListener("mouseleave",()=>w(h)),h.addEventListener("click",y=>{var g,C;y.stopPropagation(),(C=(g=i.config).downloadFile)==null||C.call(g,o,u)}),m.appendChild(h)}if((r=i.config.getDownloadUrl)!=null?r:i.config.getThumbnail){const h=document.createElement("button");h.type="button",h.title="Open in new window",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',h.addEventListener("mouseenter",()=>v(h)),h.addEventListener("mouseleave",()=>w(h)),h.addEventListener("click",y=>{var g,C,E,x;if(y.stopPropagation(),i.config.getDownloadUrl){const $=i.config.getDownloadUrl(o);$?window.open($,"_blank"):(C=(g=i.config).getThumbnail)==null||C.call(g,o).then(z=>{z&&window.open(z,"_blank")}).catch(()=>{})}else(x=(E=i.config).getThumbnail)==null||x.call(E,o).then($=>{$&&window.open($,"_blank")}).catch(()=>{})}),m.appendChild(h)}if(!a&&s){const h=document.createElement("button");h.type="button",h.title="Remove",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',h.addEventListener("mouseenter",()=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-error-color, #ef4444)"}),h.addEventListener("mouseleave",()=>w(h)),h.addEventListener("click",y=>{y.stopPropagation(),d.remove(),s()}),m.appendChild(h)}return m.children.length>0&&d.appendChild(m),document.body.appendChild(d),rr(d,e),d}function ir(){return{element:null,hideTimer:null}}function ht(e,t=150){e.hideTimer===null&&(e.hideTimer=setTimeout(()=>{e.hideTimer=null,e.element&&(e.element.remove(),e.element=null)},t))}function bt(e){e.hideTimer!==null&&(clearTimeout(e.hideTimer),e.hideTimer=null)}function We(e){return e&&e.remove(),null}function Sl(e){var t;const n=(t=e.selectionStart)!=null?t:0,r=e.value.slice(0,n);for(let o=r.length-1;o>=0;o--)if(r[o]==="@"){if(o===0||/\s/.test(r[o-1])){let i=r.slice(o+1);return i.startsWith('"')&&(i=i.slice(1)),{query:i,pos:o}}return null}return null}function ar(e,t,n){const r=e.toLowerCase();return t.filter(o=>{var i;return((i=n.get(o))!=null?i:o).toLowerCase().includes(r)})}const gt="font-size: var(--fb-font-size, 14px); font-family: var(--fb-font-family, inherit); line-height: 1.6;",sr="padding: 8px 40px 8px 10px;";function Ll(e,t,n,r,o){var i;const a=t.state,l=[...o.files],s={open:!1,query:"",triggerPos:-1,selectedIndex:0},c=new AbortController,u=document.createElement("input");u.type="hidden",u.name=r;function d(){var S,R;const I=x.value,N=Qn(l,a),H=I?$l(I,N):null,j=(S=e.textKey)!=null?S:"text",oe=(R=e.filesKey)!=null?R:"files";return{[j]:I===""?null:H,[oe]:[...l]}}function f(){u.value=JSON.stringify(d())}const p=document.createElement("div");p.className="fb-richinput-wrapper",p.style.cssText=`
|
|
966
1245
|
position: relative;
|
|
967
1246
|
border: 1px solid var(--fb-border-color, #d1d5db);
|
|
968
1247
|
border-radius: 16px;
|
|
969
1248
|
background: var(--fb-background-color, #f9fafb);
|
|
970
1249
|
transition: box-shadow 0.15s, border-color 0.15s;
|
|
971
|
-
`,
|
|
1250
|
+
`,p.addEventListener("focusin",()=>{p.style.borderColor="var(--fb-primary-color, #0066cc)",p.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),p.addEventListener("focusout",()=>{p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none"});const m=document.createElement("div");m.className="fb-richinput-error",m.style.cssText="display: none; color: var(--fb-error-color, #ef4444); font-size: var(--fb-font-size-small, 12px); padding: 4px 10px 6px;";let b=null;function v(S){m.textContent=S,m.style.display="block",b&&clearTimeout(b),b=setTimeout(()=>{m.style.display="none",m.textContent="",b=null},5e3)}function w(S){var R;const I=Me(e.accept);if(!je(S.name,I)){const H=I.join(", ");return v(k("invalidFileExtension",a,{name:S.name,formats:H})),!1}const N=(R=e.maxSize)!=null?R:1/0;return it(S,N)?!0:(v(k("fileTooLarge",a,{name:S.name,maxSize:N})),!1)}let h=0;p.addEventListener("dragenter",S=>{S.preventDefault(),h++,p.style.borderColor="var(--fb-primary-color, #0066cc)",p.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),p.addEventListener("dragover",S=>{S.preventDefault()}),p.addEventListener("dragleave",S=>{S.preventDefault(),h--,h<=0&&(h=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none")}),p.addEventListener("drop",S=>{var R,I;S.preventDefault(),h=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none";const N=(R=S.dataTransfer)==null?void 0:R.files;if(!N||!a.config.uploadFile)return;const H=(I=e.maxFiles)!=null?I:1/0;for(let j=0;j<N.length;j++){if(l.length>=H){v(k("filesLimitExceeded",a,{skipped:N.length-j,max:H}));break}w(N[j])&&Ke(N[j])}});const y=document.createElement("div");y.className="fb-richinput-files",y.style.cssText="display: none; flex-wrap: wrap; gap: 4px; padding: 6px 10px 0; align-items: center;";const g=document.createElement("input");g.type="file",g.multiple=!0,g.style.display="none",e.accept&&(typeof e.accept=="string"?g.accept=e.accept:g.accept=e.accept.extensions.map(S=>S.startsWith(".")?S:`.${S}`).join(","));const C=document.createElement("div");C.style.cssText="position: relative;";const E=document.createElement("div");E.className="fb-richinput-backdrop",E.style.cssText=`
|
|
972
1251
|
position: absolute;
|
|
973
1252
|
top: 0; left: 0; right: 0; bottom: 0;
|
|
974
|
-
${
|
|
975
|
-
${
|
|
1253
|
+
${sr}
|
|
1254
|
+
${gt}
|
|
976
1255
|
white-space: pre-wrap;
|
|
977
1256
|
word-break: break-word;
|
|
978
1257
|
color: transparent;
|
|
@@ -981,10 +1260,10 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
981
1260
|
border-radius: inherit;
|
|
982
1261
|
box-sizing: border-box;
|
|
983
1262
|
z-index: 2;
|
|
984
|
-
`;const
|
|
1263
|
+
`;const x=document.createElement("textarea");x.name=`${r}__text`,x.placeholder=e.placeholder||k("richinputPlaceholder",a);const $=(i=o.text)!=null?i:"";x.value=$?er($,l,a):"",x.style.cssText=`
|
|
985
1264
|
width: 100%;
|
|
986
|
-
${
|
|
987
|
-
${
|
|
1265
|
+
${sr}
|
|
1266
|
+
${gt}
|
|
988
1267
|
background: transparent;
|
|
989
1268
|
border: none;
|
|
990
1269
|
outline: none;
|
|
@@ -994,9 +1273,9 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
994
1273
|
position: relative;
|
|
995
1274
|
z-index: 1;
|
|
996
1275
|
caret-color: var(--fb-text-color, #111827);
|
|
997
|
-
`,
|
|
998
|
-
`;return}let
|
|
999
|
-
`}const
|
|
1276
|
+
`,El(x,E),x.addEventListener("scroll",()=>{E.scrollTop=x.scrollTop});let z=null;E.addEventListener("mouseover",S=>{var R,I;const N=(I=(R=S.target).closest)==null?void 0:I.call(R,"mark");N!=null&&N.dataset.rid&&(z=We(z),z=or(N,N.dataset.rid,a))}),E.addEventListener("mouseout",S=>{var R,I,N;if(!((I=(R=S.target).closest)!=null&&I.call(R,"mark")))return;const H=S.relatedTarget;(N=H==null?void 0:H.closest)!=null&&N.call(H,"mark")||(z=We(z))}),E.addEventListener("mousedown",S=>{var R,I;if(!((I=(R=S.target).closest)!=null&&I.call(R,"mark")))return;z=We(z);const N=E.querySelectorAll("mark");N.forEach(j=>j.style.pointerEvents="none");const H=document.elementFromPoint(S.clientX,S.clientY);H&&H.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,clientX:S.clientX,clientY:S.clientY,button:S.button,buttons:S.buttons,detail:S.detail})),document.addEventListener("mouseup",()=>{N.forEach(j=>j.style.pointerEvents="auto")},{once:!0})});function q(){const S=x.value,R=Qn(l,a),I=mt(S);if(I.length===0){E.innerHTML=se(S)+`
|
|
1277
|
+
`;return}let N="",H=0;for(const j of I){N+=se(S.slice(H,j.start));const oe=R.get(j.name);oe?N+=`<mark data-rid="${se(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;">${se(S.slice(j.start,j.end))}</mark>`:N+=`<mark style="color: transparent; background: none; padding: 0; border: none; text-decoration-line: underline; text-decoration-style: wavy; text-decoration-color: rgba(239, 68, 68, 0.45); text-underline-offset: 2px;">${se(S.slice(j.start,j.end))}</mark>`,H=j.end}N+=se(S.slice(H)),E.innerHTML=N+`
|
|
1278
|
+
`}const K=document.createElement("button");K.type="button",K.title=k("richinputAttachFile",a),K.style.cssText=`
|
|
1000
1279
|
position: absolute;
|
|
1001
1280
|
right: 6px;
|
|
1002
1281
|
bottom: 6px;
|
|
@@ -1012,7 +1291,7 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1012
1291
|
justify-content: center;
|
|
1013
1292
|
color: var(--fb-text-muted-color, #9ca3af);
|
|
1014
1293
|
transition: color 0.15s, background 0.15s;
|
|
1015
|
-
`,
|
|
1294
|
+
`,K.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>',K.addEventListener("mouseenter",()=>{K.style.color="var(--fb-primary-color, #0066cc)",K.style.background="var(--fb-background-hover-color, #f3f4f6)"}),K.addEventListener("mouseleave",()=>{K.style.color="var(--fb-text-muted-color, #9ca3af)",K.style.background="transparent"}),K.addEventListener("click",()=>{var S;const R=(S=e.maxFiles)!=null?S:1/0;if(l.length>=R){v(k("filesLimitExceeded",a,{skipped:1,max:R}));return}g.click()});const B=document.createElement("div");B.className="fb-richinput-dropdown",B.style.cssText=`
|
|
1016
1295
|
display: none;
|
|
1017
1296
|
position: absolute;
|
|
1018
1297
|
bottom: 100%;
|
|
@@ -1027,16 +1306,16 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1027
1306
|
max-height: 200px;
|
|
1028
1307
|
overflow-y: auto;
|
|
1029
1308
|
margin-bottom: 4px;
|
|
1030
|
-
${
|
|
1031
|
-
`;function
|
|
1309
|
+
${gt}
|
|
1310
|
+
`;function M(){return Wt(l,a)}function D(S){ye(B);const R=M();if(S.length===0){B.style.display="none",s.open=!1;return}S.forEach((I,N)=>{var H;const j=a.resourceIndex.get(I),oe=document.createElement("div");oe.className="fb-richinput-dropdown-item",oe.dataset.rid=I,oe.style.cssText=`
|
|
1032
1311
|
padding: 5px 10px;
|
|
1033
1312
|
cursor: pointer;
|
|
1034
1313
|
color: var(--fb-text-color, #111827);
|
|
1035
|
-
background: ${
|
|
1314
|
+
background: ${N===s.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
|
|
1036
1315
|
display: flex;
|
|
1037
1316
|
align-items: center;
|
|
1038
1317
|
gap: 8px;
|
|
1039
|
-
`;const
|
|
1318
|
+
`;const le=document.createElement("div");if(le.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;",j!=null&&j.file&&Vt(j)){const ce=document.createElement("img");ce.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const be=new FileReader;be.onload=A=>{var T;ce.src=((T=A.target)==null?void 0:T.result)||""},be.readAsDataURL(j.file),le.appendChild(ce)}else a.config.getThumbnail&&a.config.getThumbnail(I).then(ce=>{if(!ce||!le.isConnected)return;const be=document.createElement("img");be.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",be.src=ce,ye(le),le.appendChild(be)}).catch(()=>{}),le.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(le);const de=document.createElement("span");de.style.cssText="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",de.textContent=(H=R.get(I))!=null?H:I,oe.appendChild(de),B.appendChild(oe)}),B.onmousemove=I=>{var N,H,j;const oe=(H=(N=I.target).closest)==null?void 0:H.call(N,".fb-richinput-dropdown-item");if(!oe)return;const le=S.indexOf((j=oe.dataset.rid)!=null?j:"");le===-1||le===s.selectedIndex||(B.querySelectorAll(".fb-richinput-dropdown-item").forEach((de,ce)=>{de.style.background=ce===le?"var(--fb-background-hover-color, #f3f4f6)":"transparent"}),s.selectedIndex=le)},B.onmousedown=I=>{var N,H;I.preventDefault(),I.stopPropagation();const j=(H=(N=I.target).closest)==null?void 0:H.call(N,".fb-richinput-dropdown-item");j!=null&&j.dataset.rid&&ne(j.dataset.rid)},B.style.display="block",s.open=!0}function J(){const S=Sl(x);if(!S){Q();return}s.query=S.query,s.triggerPos=S.pos,s.selectedIndex=0;const R=M(),I=ar(S.query,l,R);D(I)}function Q(){B.style.display="none",s.open=!1}function ne(S){var R,I,N,H;const j=(N=(I=M().get(S))!=null?I:(R=a.resourceIndex.get(S))==null?void 0:R.name)!=null?N:S,oe=(H=x.selectionStart)!=null?H:0,le=x.value.slice(0,s.triggerPos),de=x.value.slice(oe),ce=`${Kt(j)} `;x.value=`${le}${ce}${de}`;const be=le.length+ce.length;x.setSelectionRange(be,be),x.dispatchEvent(new Event("input")),Q()}x.addEventListener("input",()=>{var S;q(),f(),(S=t.instance)==null||S.triggerOnChange(r,d()),l.length>0?J():Q()});function he(){B.querySelectorAll(".fb-richinput-dropdown-item").forEach((S,R)=>{S.style.background=R===s.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}x.addEventListener("keydown",S=>{if(!s.open)return;const R=M(),I=ar(s.query,l,R);S.key==="ArrowDown"?(S.preventDefault(),s.selectedIndex=Math.min(s.selectedIndex+1,I.length-1),he()):S.key==="ArrowUp"?(S.preventDefault(),s.selectedIndex=Math.max(s.selectedIndex-1,0),he()):S.key==="Enter"&&I.length>0?(S.preventDefault(),ne(I[s.selectedIndex])):S.key==="Escape"&&Q()}),document.addEventListener("click",S=>{!p.contains(S.target)&&!B.contains(S.target)&&Q()},{signal:c.signal});function Ce(){if(ye(y),l.length===0){y.style.display="none";return}y.style.display="flex",l.forEach(S=>{const R=a.resourceIndex.get(S),I=document.createElement("div");I.className="fb-richinput-file-thumb",I.style.cssText=`
|
|
1040
1319
|
position: relative;
|
|
1041
1320
|
width: 48px;
|
|
1042
1321
|
height: 48px;
|
|
@@ -1046,14 +1325,14 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1046
1325
|
flex-shrink: 0;
|
|
1047
1326
|
cursor: pointer;
|
|
1048
1327
|
background: #fff;
|
|
1049
|
-
`;const
|
|
1050
|
-
`:""}${
|
|
1328
|
+
`;const N=document.createElement("div");N.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",tr(N,S,R,a),I.appendChild(N);const H=ir(),j=()=>{var le,de,ce;const be=(le=x.selectionStart)!=null?le:x.value.length,A=(ce=(de=M().get(S))!=null?de:R==null?void 0:R.name)!=null?ce:S,T=x.value.slice(0,be),L=x.value.slice(be),O=`${T.length>0&&!/[\s\n]$/.test(T)?`
|
|
1329
|
+
`:""}${Kt(A)} `;x.value=`${T}${O}${L}`;const U=be+O.length;x.setSelectionRange(U,U),x.focus(),x.dispatchEvent(new Event("input"))},oe=()=>{var le;const de=l.indexOf(S);de!==-1&&l.splice(de,1),Ce(),q(),f(),(le=t.instance)==null||le.triggerOnChange(r,d())};I.addEventListener("mouseenter",()=>{bt(H),H.element||(H.element=lr(I,{rid:S,state:a,isReadonly:!1,onMention:j,onRemove:oe}),H.element.addEventListener("mouseenter",()=>{bt(H)}),H.element.addEventListener("mouseleave",()=>{ht(H)}))}),I.addEventListener("mouseleave",()=>{ht(H)}),y.appendChild(I)})}function Ke(S){if(!a.config.uploadFile)return;const R=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;a.resourceIndex.set(R,{name:S.name,type:S.type,size:S.size,uploadedAt:new Date,file:S}),l.push(R),Ce();const I=y.querySelectorAll(".fb-richinput-file-thumb"),N=I[I.length-1];N&&(N.style.opacity="0.5"),a.config.uploadFile(S).then(H=>{var j;const oe=l.indexOf(R);oe!==-1&&(l[oe]=H),a.resourceIndex.delete(R),a.resourceIndex.set(H,{name:S.name,type:S.type,size:S.size,uploadedAt:new Date,file:S}),Ce(),q(),f(),(j=t.instance)==null||j.triggerOnChange(r,d())}).catch(H=>{var j,oe;const le=l.indexOf(R);le!==-1&&l.splice(le,1),a.resourceIndex.delete(R),Ce(),(oe=(j=a.config).onUploadError)==null||oe.call(j,H,S)})}if(g.addEventListener("change",()=>{var S;const R=g.files;if(!R||R.length===0)return;const I=(S=e.maxFiles)!=null?S:1/0;for(let N=0;N<R.length;N++){if(l.length>=I){v(k("filesLimitExceeded",a,{skipped:R.length-N,max:I}));break}w(R[N])&&Ke(R[N])}g.value=""}),C.appendChild(E),C.appendChild(x),C.appendChild(K),C.appendChild(B),p.appendChild(y),p.appendChild(C),p.appendChild(m),e.minLength!=null||e.maxLength!=null){const S=document.createElement("div");S.style.cssText="position: relative; padding: 2px 10px 4px; text-align: right;";const R=rt(e,x);R.style.cssText=`
|
|
1051
1330
|
position: static;
|
|
1052
1331
|
display: inline-block;
|
|
1053
1332
|
font-size: var(--fb-font-size-small);
|
|
1054
1333
|
color: var(--fb-text-secondary-color);
|
|
1055
1334
|
pointer-events: none;
|
|
1056
|
-
|
|
1335
|
+
`,S.appendChild(R),p.appendChild(S)}p.appendChild(u),p.appendChild(g),f(),q(),u._applyExternalUpdate=S=>{var R;const I=(R=S.text)!=null?R:"";x.value=I?er(I,l,a):"",x.dispatchEvent(new Event("input")),l.length=0;for(const N of S.files)l.push(N);Ce(),q(),f()},n.appendChild(p),Ce();const et=new MutationObserver(()=>{p.isConnected||(c.abort(),z=We(z),et.disconnect())});p.parentElement&&et.observe(p.parentElement,{childList:!0})}function Tl(e,t,n,r,o){var i,a;const l=t.state,{text:s,files:c}=o,u=new Map;for(const d of c){const f=l.resourceIndex.get(d);f!=null&&f.name&&u.set(d,f.name)}if(c.length>0){const d=document.createElement("div");d.style.cssText="display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px;",c.forEach(f=>{const p=l.resourceIndex.get(f),m=document.createElement("div");m.style.cssText=`
|
|
1057
1336
|
position: relative;
|
|
1058
1337
|
width: 48px; height: 48px;
|
|
1059
1338
|
border: 1px solid var(--fb-border-color, #d1d5db);
|
|
@@ -1062,12 +1341,12 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1062
1341
|
flex-shrink: 0;
|
|
1063
1342
|
background: #fff;
|
|
1064
1343
|
cursor: default;
|
|
1065
|
-
`;const b=document.createElement("div");b.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",
|
|
1066
|
-
${
|
|
1344
|
+
`;const b=document.createElement("div");b.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",tr(b,f,p,l),m.appendChild(b);const v=ir();m.addEventListener("mouseenter",()=>{bt(v),v.element||(v.element=lr(m,{rid:f,state:l,isReadonly:!0}),v.element.addEventListener("mouseenter",()=>{bt(v)}),v.element.addEventListener("mouseleave",()=>{ht(v)}))}),m.addEventListener("mouseleave",()=>{ht(v)}),d.appendChild(m)}),n.appendChild(d)}if(s){const d=document.createElement("div");d.style.cssText=`
|
|
1345
|
+
${gt}
|
|
1067
1346
|
color: var(--fb-text-color, #111827);
|
|
1068
1347
|
white-space: pre-wrap;
|
|
1069
1348
|
word-break: break-word;
|
|
1070
|
-
`;const
|
|
1349
|
+
`;const f=mt(s).filter(p=>u.has(p.name)||[...u.values()].includes(p.name));if(f.length===0)d.textContent=s;else{let p=0;for(const m of f){m.start>p&&d.appendChild(document.createTextNode(s.slice(p,m.start)));const b=document.createElement("span");b.style.cssText=`
|
|
1071
1350
|
display: inline;
|
|
1072
1351
|
background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent);
|
|
1073
1352
|
color: var(--fb-primary-color, #0066cc);
|
|
@@ -1075,7 +1354,7 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1075
1354
|
padding: 1px 6px;
|
|
1076
1355
|
font-weight: 500;
|
|
1077
1356
|
cursor: default;
|
|
1078
|
-
`;const
|
|
1357
|
+
`;const v=u.has(m.name)?m.name:(i=[...u.entries()].find(([,h])=>h===m.name))==null?void 0:i[0],w=(a=u.get(m.name))!=null?a:m.name;if(b.textContent=`@${w}`,v){let h=null;const y=v;b.addEventListener("mouseenter",()=>{h=We(h),h=or(b,y,l)}),b.addEventListener("mouseleave",()=>{h=We(h)})}d.appendChild(b),p=m.end}p<s.length&&d.appendChild(document.createTextNode(s.slice(p)))}n.appendChild(d)}if(!s&&c.length===0){const d=document.createElement("div");d.style.cssText="color: var(--fb-text-muted-color, #6b7280); font-size: var(--fb-font-size, 14px);",d.textContent="\u2014",n.appendChild(d)}}function Al(e,t,n,r){var o,i,a,l;const s=t.state,c=ae(e,s,t),u=(o=e.textKey)!=null?o:"text",d=(i=e.filesKey)!=null?i:"files";let f;if(e.flatOutput){const p=t.prefill[u],m=t.prefill[d];f={text:typeof p=="string"?p:null,files:Array.isArray(m)?m:[]}}else{const p=t.prefill[e.key];if(p&&typeof p=="object"&&!Array.isArray(p)){const m=p,b=(a=m[u])!=null?a:m.text,v=(l=m[d])!=null?l:m.files;f={text:typeof b=="string"?b:null,files:Array.isArray(v)?v:[]}}else typeof p=="string"?f={text:p||null,files:[]}:f={text:null,files:[]}}for(const p of f.files)s.resourceIndex.has(p)||s.resourceIndex.set(p,{name:p,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(c)Tl(e,t,n,r,f);else{if(!s.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);Ll(e,t,n,r,f)}}function Fl(e,t,n){var r,o;const{scopeRoot:i,state:a,skipValidation:l}=n,s=[],c=(r=e.textKey)!=null?r:"text",u=(o=e.filesKey)!=null?o:"files",d=i.querySelector(`[name="${t}"]`);if(!d)return{value:null,errors:s};let f={};try{const h=JSON.parse(d.value);if(h&&typeof h=="object"&&!Array.isArray(h))f=h;else return s.push(`${t}: invalid richinput data`),{value:null,errors:s}}catch(h){return s.push(`${t}: invalid richinput data`),{value:null,errors:s}}const p=f[c],m=f[u],b=p===null||typeof p=="string"?p:null,v=Array.isArray(m)?m:[],w={[c]:b!=null?b:null,[u]:v};if(!l){const h=!b||b.trim()==="",y=v.length===0;e.required&&h&&y&&s.push(`${t}: ${k("required",a)}`),!h&&b&&(e.minLength!=null&&b.length<e.minLength&&s.push(`${t}: ${k("minLength",a,{min:e.minLength})}`),e.maxLength!=null&&b.length>e.maxLength&&s.push(`${t}: ${k("maxLength",a,{max:e.maxLength})}`)),e.maxFiles!=null&&v.length>e.maxFiles&&s.push(`${t}: ${k("maxFiles",a,{max:e.maxFiles})}`)}return{value:w,errors:s,spread:!!e.flatOutput}}function Ml(e,t,n,r){var o,i,a,l;const{scopeRoot:s}=r,c=s.querySelector(`[name="${t}"]`);if(!c){console.warn(`updateRichInputField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let u=null;if(n&&typeof n=="object"&&!Array.isArray(n)){const d=n,f=(o=e.textKey)!=null?o:"text",p=(i=e.filesKey)!=null?i:"files",m=(a=d[f])!=null?a:d.text,b=(l=d[p])!=null?l:d.files;(m!==void 0||b!==void 0)&&(u={text:typeof m=="string"?m:null,files:Array.isArray(b)?b:[]})}u&&c._applyExternalUpdate?c._applyExternalUpdate(u):u&&(c.value=JSON.stringify(u))}const zl={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function cr(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function Qe(e){return(e+"").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function _t(e,t){const n=/((?:^|\n+)(?:\n---+|\*[ ]\*(?:[ ]\*)+)\n)|(?:^```[ ]*(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t|[ ]{2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|([ ]{2}\n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,r=[];let o="";const i=t||{};let a=0,l,s,c,u,d;function f(m){const b=zl[m[1]||""],v=r[r.length-1]===m;return b?b[1]?(v?r.pop():r.push(m),b[v?1:0]):b[0]:m}function p(){let m="";for(;r.length;)m+=f(r[r.length-1]);return m}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,(m,b,v)=>(i[b.toLowerCase()]=v,"")).replace(/^\n+|\n+$/g,"");c=n.exec(e);)s=e.substring(a,c.index),a=n.lastIndex,l=c[0],s.match(/[^\\](\\\\)*\\$/)||((d=c[3]||c[4])?l='<pre class="code '+(c[4]?"poetry":c[2].toLowerCase())+'"><code'+(c[2]?` class="language-${c[2].toLowerCase()}"`:"")+">"+cr(Qe(d).replace(/^\n+|\n+$/g,""))+"</code></pre>":(d=c[6])?(d.match(/\./)&&(c[5]=c[5].replace(/^\d+/gm,"")),u=_t(cr(c[5].replace(/^\s*[>*+.-]/gm,""))),d===">"?d="blockquote":(d=d.match(/\./)?"ol":"ul",u=u.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),l="<"+d+">"+u+"</"+d+">"):c[8]?l=`<img src="${Qe(c[8])}" alt="${Qe(c[7])}">`:c[10]?(o=o.replace("<a>",`<a href="${Qe(c[11]||i[s.toLowerCase()])}">`),l=p()+"</a>"):c[9]?l="<a>":c[12]||c[14]?(d="h"+(c[14]?c[14].length:c[13]>"="?1:2),l="<"+d+">"+_t(c[12]||c[15],i)+"</"+d+">"):c[16]?l="<code>"+Qe(c[16])+"</code>":(c[17]||c[1])&&(l=f(c[17]||"--"))),o+=s,o+=l;return(o+e.substring(a)+p()).replace(/^\n+|\n+$/g,"")}const dr="fb-markdown-styles";function Nl(){if(typeof document=="undefined"||document.getElementById(dr))return;const e=document.createElement("style");e.id=dr,e.setAttribute("data-fb-markdown-styles","true"),e.textContent=`
|
|
1079
1358
|
.fb-markdown {
|
|
1080
1359
|
font-family: var(--fb-font-family, inherit);
|
|
1081
1360
|
font-size: var(--fb-font-size, 1rem);
|
|
@@ -1152,11 +1431,11 @@ var FormBuilder=(function(Se){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1152
1431
|
.fb-markdown strong { font-weight: var(--fb-font-weight-medium, 600); }
|
|
1153
1432
|
.fb-markdown em { font-style: italic; }
|
|
1154
1433
|
.fb-markdown s { text-decoration: line-through; }
|
|
1155
|
-
`,document.head.appendChild(e)}const bl=["javascript:","data:","vbscript:","blob:"],vl=["javascript:","vbscript:","blob:"];function gl(e){return!!(vl.some(t=>e.startsWith(t))||e.startsWith("data:")&&!e.startsWith("data:image/"))}function yl(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function xl(e){e.querySelectorAll("a[href]").forEach(t=>{var n;const r=((n=t.getAttribute("href"))!=null?n:"").trim().toLowerCase();bl.some(o=>r.startsWith(o))&&t.setAttribute("href","#"),t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer")}),e.querySelectorAll("img[src]").forEach(t=>{var n;const r=((n=t.getAttribute("src"))!=null?n:"").trim().toLowerCase();gl(r)&&t.setAttribute("src","")})}function wl(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})`);hl();const r=document.createElement("div");r.className="fb-markdown";const o=yl(e.content);return r.innerHTML=jt(o),xl(r),n.appendChild(r),r}function El(e,t,n){return{value:void 0,errors:[],skip:!0}}function Cl(e,t,n,r){}function kl(e,t){const n=document.getElementById(e);if(!n)return;const r=!n.classList.contains("hidden");if(document.querySelectorAll('[id^="tooltip-"]').forEach(d=>{d.classList.add("hidden")}),r)return;const o=t.getBoundingClientRect(),a=window.innerWidth,i=window.innerHeight;n&&n.parentElement!==document.body&&document.body.appendChild(n),n.style.visibility="hidden",n.style.position="fixed",n.classList.remove("hidden");const l=n.getBoundingClientRect();n.classList.add("hidden"),n.style.visibility="visible";let s=o.left,u=o.bottom+5;s+l.width>a&&(s=o.right-l.width),u+l.height>i&&(u=o.top-l.height-5),s<10&&(s=10),u<10&&(u=o.bottom+5),n.style.left=`${s}px`,n.style.top=`${u}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 lr(e,t){var n,r,o;if(!e.enableIf)return!1;try{const a=(r=(n=t.formData)!=null?n:t.prefill)!=null?r:{},i=((o=e.enableIf.scope)!=null?o:"relative")==="relative"&&t.path?t.prefill:void 0;return!He(e.enableIf,a,i)}catch(a){console.error(`Error evaluating enableIf for field "${e.key}":`,a)}return!1}function $l(e,t){const n=t.querySelector(`[name="${e}"]`);if(n){if(n instanceof HTMLSelectElement)return n.value;if(n instanceof HTMLInputElement){if(n.type==="checkbox")return n.checked;if(n.type==="radio"){const r=t.querySelector(`[name="${e}"]:checked`);return r?r.value:void 0}else return n.value}else if(n instanceof HTMLTextAreaElement)return n.value}}function mt(e,t,n){var r,o;if(!t.enableIf)return;const a=n.state.formRoot;if(!a){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const i=t.enableIf,l=(r=i.scope)!=null?r:"relative";let s={};const u={};if((!n.path||n.path===""?"absolute":l)==="relative"&&n.path){const d=n.path.match(/^(.+)\[(\d+)\]$/);if(d){const c=d[1],p=parseInt(d[2],10),f=a.querySelector(`[data-container-item="${c}[${p}]"]`);f&&f.querySelectorAll("input, select, textarea").forEach(m=>{const b=m.getAttribute("name");if(b){const g=b.match(/\.([^.[\]]+)$/);if(g){const E=g[1];m instanceof HTMLSelectElement?u[E]=m.value:m instanceof HTMLInputElement?m.type==="checkbox"?u[E]=m.checked:m.type==="radio"?m.checked&&(u[E]=m.value):u[E]=m.value:m instanceof HTMLTextAreaElement&&(u[E]=m.value)}}})}}else{const d=i.key,c=$l(d,a);c!==void 0?s[d]=c:s=(o=n.formData)!=null?o:n.prefill}try{He(i,s,u)?(e.style.display="",e.classList.remove("fb-field-wrapper-disabled"),e.removeAttribute("data-conditionally-disabled")):(e.style.display="none",e.classList.add("fb-field-wrapper-disabled"),e.setAttribute("data-conditionally-disabled","true"))}catch(d){console.error(`Error re-evaluating enableIf for field "${t.key}":`,d)}}function ir(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot setup enableIf listeners: formRoot is null");return}const a=t.enableIf,i=(r=a.scope)!=null?r:"relative",l=a.key;let s;i==="relative"&&n.path?s=`${n.path}.${l}`:s=l;const u=o.querySelector(`[name="${s}"]`);if(!u){const d=new MutationObserver(()=>{const c=o.querySelector(`[name="${s}"]`);c&&(c.addEventListener("change",()=>{mt(e,t,n)}),c.addEventListener("input",()=>{mt(e,t,n)}),d.disconnect())});d.observe(o,{childList:!0,subtree:!0});return}u.addEventListener("change",()=>{mt(e,t,n)}),u.addEventListener("input",()=>{mt(e,t,n)})}function Ll(e){var t,n;const r=document.createElement("label");if(r.className="text-sm font-medium text-gray-900",r.textContent=(n=(t=e.label)!=null?t:e.key)!=null?n:"",e.required){const o=document.createElement("span");o.className="text-red-500 ml-1",o.textContent="*",r.appendChild(o)}return r}function Sl(e){const t=document.createElement("button");t.type="button",t.className="ml-2 text-gray-400 hover:text-gray-600",t.innerHTML='<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>';const n=`tooltip-${e.key}-${Math.random().toString(36).substr(2,9)}`,r=document.createElement("div");return r.id=n,r.className="hidden absolute z-50 bg-gray-200 text-gray-900 text-sm rounded-lg p-3 max-w-sm border border-gray-300 shadow-lg",r.style.position="fixed",r.textContent=e.description||e.hint||"Field information",document.body.appendChild(r),t.onclick=o=>{o.preventDefault(),o.stopPropagation(),kl(n,t)},t}function Tl(e){const t=document.createElement("div");t.className="flex items-center mb-1",t.dataset.fbLabelRow="";const n=Ll(e);if(t.appendChild(n),e.description||e.hint){const r=Sl(e);t.appendChild(r)}return t}function Al(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?gr(e,t,n,r):vr(e,t,n,r);break;case"textarea":o?xr(e,t,n,r):yr(e,t,n,r);break;case"number":o?kr(e,t,n,r):Cr(e,t,n,r);break;case"select":o?Tr(e,t,n,r):Sr(e,t,n,r);break;case"switcher":o?zr(e,t,n,r):Mr(e,t,n,r);break;case"file":o?zo(e,t,n,r):Fo(e,t,n,r);break;case"files":Mo(e,t,n,r);break;case"colour":o?qo(e,t,n,r):No(e,t,n,r);break;case"slider":o?Bo(e,t,n,r):Ho(e,t,n,r);break;case"group":Wo(e,t,n,r);break;case"container":o?jn(e,t,n):Dn(e,t,n,r);break;case"table":nl(e,t,n,r);break;case"richinput":dl(e,t,n,r);break;default:{const a=document.createElement("div");a.className="text-red-500 text-sm",a.textContent=k("unsupportedFieldType",t.state,{type:e.type}),n.appendChild(a)}}}function Ot(e,t){if(e.type==="markdown"){if(e.hidden===!0){const s=document.createElement("div");return s.style.display="none",s.setAttribute("data-fb-hidden-markdown","true"),s}const i=lr(e,t),l=document.createElement("div");return l.className="mb-2 fb-field-wrapper fb-markdown-wrapper",l.setAttribute("data-field-key",vt(e,t.state)),wl(e,t,l),i&&(l.style.display="none",l.classList.add("fb-field-wrapper-disabled"),l.setAttribute("data-conditionally-disabled","true")),ir(l,e,t),l}const n=lr(e,t),r=document.createElement("div");r.className="mb-2 fb-field-wrapper",r.setAttribute("data-field-key",e.key);const o=Tl(e);r.appendChild(o);const a=Ce(t.path,e.key);return Al(e,t,r,a),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),ir(r,e,t),r}Oo(Ot);const Ut={uploadFile:null,downloadFile:null,getThumbnail:null,getDownloadUrl:null,actionHandler:null,onChange:null,onFieldChange:null,onThumbnailError:null,onUploadError:null,onDownloadError:null,debounceMs:300,verboseErrors:!1,enableFilePreview:!0,maxPreviewSize:"200px",readonly:!1,pickExistingFiles:null,parseTableFile:null,locale:"en",translations:{en:{removeElement:"Remove",clickDragText:"Click or drag file",clickDragTextMultiple:"Click or drag files",noFileSelected:"No file selected",noFilesSelected:"No files selected",downloadButton:"Download",downloadFile:"Download",openInNewTab:"Open in new tab",changeButton:"Change",placeholderText:"Enter text",previewAlt:"Preview",previewUnavailable:"Preview unavailable",previewError:"Preview error",videoNotSupported:"Your browser does not support the video tag.",hintLengthRange:"{min}-{max} chars",hintMaxLength:"\u2264{max} chars",hintMinLength:"\u2265{min} chars",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}MB",hintFormats:"{formats}",hintRequired:"Required",hintOptional:"Optional",hintPattern:"Format: {pattern}",fileCountSingle:"{count} file",fileCountPlural:"{count} files",fileCountWithMax:"{count} / {max} files",fileCountRange:"({min}-{max})",uploadingFile:"Uploading\u2026",filesCounter:"{count}/{max}",fromLibrary:"From library",libraryEmpty:"Library is empty",libraryHint:"Choose from previously uploaded files",dropToUpload:"Release to upload",replaceFile:"Replace",clearAll:"Clear all",pickerError:"Failed to load files from library",required:"Required",minItems:"Minimum {min} items required",maxItems:"Maximum {max} items allowed",minLength:"Minimum {min} characters",maxLength:"Maximum {max} characters",minValue:"Must be at least {min}",maxValue:"Must be at most {max}",patternMismatch:"Invalid format",invalidPattern:"Invalid pattern in schema",notANumber:"Must be a number",invalidHexColour:"Invalid hex color",minFiles:"Minimum {min} files required",maxFiles:"Maximum {max} files allowed",invalidFileExtension:'File "{name}" has unsupported format. Allowed: {formats}',invalidFileMime:'File "{name}": file type {type} not allowed (allowed: {mimes})',fileTooLarge:'File "{name}" exceeds maximum size of {maxSize}MB',uploadFailed:'Failed to upload "{name}": {error}',filesLimitExceeded:"{skipped} file(s) skipped: maximum {max} files allowed",unsupportedFieldType:"Unsupported field type: {type}",invalidOption:"Invalid option",tableAddRow:"Add row",tableAddColumn:"Add column",tableRemoveRow:"Remove row",tableRemoveColumn:"Remove column",tableMergeCells:"Merge cells (Ctrl+M)",tableSplitCell:"Split cell (Ctrl+Shift+M)",tableImportFile:"Import",tableImporting:"Importing...",tableImportError:"Import failed: {error}",richinputPlaceholder:"Type text...",richinputAttachFile:"Attach file",richinputMention:"Mention",richinputRemoveFile:"Remove"},ru:{removeElement:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C",clickDragText:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B",clickDragTextMultiple:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B\u044B",noFileSelected:"\u0424\u0430\u0439\u043B \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D",noFilesSelected:"\u041D\u0435\u0442 \u0444\u0430\u0439\u043B\u043E\u0432",downloadButton:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",downloadFile:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",openInNewTab:"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432 \u043D\u043E\u0432\u043E\u0439 \u0432\u043A\u043B\u0430\u0434\u043A\u0435",changeButton:"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C",placeholderText:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",previewAlt:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440",previewUnavailable:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D",previewError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0430",videoNotSupported:"\u0412\u0430\u0448 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u0438\u0434\u0435\u043E.",hintLengthRange:"{min}-{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMaxLength:"\u2264{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMinLength:"\u2265{min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}\u041C\u0411",hintFormats:"{formats}",hintRequired:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintOptional:"\u041D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintPattern:"\u0424\u043E\u0440\u043C\u0430\u0442: {pattern}",fileCountSingle:"{count} \u0444\u0430\u0439\u043B",fileCountPlural:"{count} \u0444\u0430\u0439\u043B\u043E\u0432",fileCountWithMax:"{count} / {max} \u0444\u0430\u0439\u043B\u043E\u0432",fileCountRange:"({min}-{max})",uploadingFile:"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026",filesCounter:"{count}/{max}",fromLibrary:"\u0418\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",libraryEmpty:"\u0411\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0430 \u043F\u0443\u0441\u0442\u0430",libraryHint:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0438\u0437 \u0440\u0430\u043D\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0445 \u0444\u0430\u0439\u043B\u043E\u0432",dropToUpload:"\u041E\u0442\u043F\u0443\u0441\u0442\u0438\u0442\u0435, \u0447\u0442\u043E\u0431\u044B \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C",replaceFile:"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C",clearAll:"\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0432\u0441\u0435",pickerError:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u0430\u0439\u043B\u044B \u0438\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",required:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u043F\u043E\u043B\u0435",minItems:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",maxItems:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",minLength:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",maxLength:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",minValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {min}",maxValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {max}",patternMismatch:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442",invalidPattern:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043F\u0430\u0442\u0442\u0435\u0440\u043D \u0432 \u0441\u0445\u0435\u043C\u0435",notANumber:"\u0414\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0447\u0438\u0441\u043B\u043E\u043C",invalidHexColour:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 \u0446\u0432\u0435\u0442\u0430",minFiles:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0444\u0430\u0439\u043B\u043E\u0432",maxFiles:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",invalidFileExtension:'\u0424\u0430\u0439\u043B "{name}" \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442. \u0414\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0435: {formats}',invalidFileMime:'\u0424\u0430\u0439\u043B "{name}": \u0442\u0438\u043F \u0444\u0430\u0439\u043B\u0430 {type} \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u044B: {mimes})',fileTooLarge:'\u0424\u0430\u0439\u043B "{name}" \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440 {maxSize}\u041C\u0411',uploadFailed:'\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C "{name}": {error}',filesLimitExceeded:"{skipped} \u0444\u0430\u0439\u043B(\u043E\u0432) \u043F\u0440\u043E\u043F\u0443\u0449\u0435\u043D\u043E: \u043C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",unsupportedFieldType:"\u041D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \u043F\u043E\u043B\u044F: {type}",invalidOption:"\u041D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435",tableAddRow:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableAddColumn:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableRemoveRow:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableRemoveColumn:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableMergeCells:"\u041E\u0431\u044A\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0438 (Ctrl+M)",tableSplitCell:"\u0420\u0430\u0437\u0434\u0435\u043B\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0443 (Ctrl+Shift+M)",tableImportFile:"\u0418\u043C\u043F\u043E\u0440\u0442",tableImporting:"\u0418\u043C\u043F\u043E\u0440\u0442...",tableImportError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u0438\u043C\u043F\u043E\u0440\u0442\u0430: {error}",richinputPlaceholder:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442...",richinputAttachFile:"\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0444\u0430\u0439\u043B",richinputMention:"\u0423\u043F\u043E\u043C\u044F\u043D\u0443\u0442\u044C",richinputRemoveFile:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C"}},theme:{}};function Fl(e){const t={...Ut.translations};if(e!=null&&e.translations)for(const[n,r]of Object.entries(e.translations))t[n]={...Ut.translations[n]||{},...r};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...Ut,...e,translations:t},debounceTimer:null,prefill:{},syntheticElementIds:new WeakMap,syntheticElementIdCounter:0}}function Ml(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const Ye={primaryColor:"#3b82f6",primaryHoverColor:"#2563eb",errorColor:"#ef4444",errorHoverColor:"#dc2626",successColor:"#10b981",borderColor:"#d1d5db",borderHoverColor:"#9ca3af",borderFocusColor:"#3b82f6",backgroundColor:"#ffffff",backgroundHoverColor:"#f9fafb",backgroundReadonlyColor:"#f3f4f6",textColor:"#1f2937",textSecondaryColor:"#6b7280",textPlaceholderColor:"#9ca3af",textDisabledColor:"#d1d5db",buttonBgColor:"#3b82f6",buttonTextColor:"#ffffff",buttonBorderColor:"#2563eb",buttonHoverBgColor:"#2563eb",buttonHoverBorderColor:"#1d4ed8",actionBgColor:"#ffffff",actionTextColor:"#374151",actionBorderColor:"#e5e7eb",actionHoverBgColor:"#f9fafb",actionHoverBorderColor:"#d1d5db",fileUploadBgColor:"#f3f4f6",fileUploadBorderColor:"#d1d5db",fileUploadTextColor:"#9ca3af",fileUploadHoverBorderColor:"#3b82f6",inputPaddingX:"0.5rem",inputPaddingY:"0.25rem",borderRadius:"0.5rem",borderWidth:"1px",fontSize:"0.875rem",fontSizeSmall:"0.75rem",fontSizeExtraSmall:"0.625rem",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontWeightNormal:"400",fontWeightMedium:"500",focusRingWidth:"2px",focusRingColor:"#3b82f6",focusRingOpacity:"0.5",transitionDuration:"200ms"};function zl(e){const t={...Ye,...e},n=[];return Object.entries(t).forEach(([r,o])=>{const a=r.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(` --fb-${a}: ${o};`)}),n.join(`
|
|
1156
|
-
`)}function
|
|
1434
|
+
`,document.head.appendChild(e)}const Il=["javascript:","data:","vbscript:","blob:"],ql=["javascript:","vbscript:","blob:"];function Rl(e){return!!(ql.some(t=>e.startsWith(t))||e.startsWith("data:")&&!e.startsWith("data:image/"))}function Bl(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Hl(e){e.querySelectorAll("a[href]").forEach(t=>{var n;const r=((n=t.getAttribute("href"))!=null?n:"").trim().toLowerCase();Il.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();Rl(r)&&t.setAttribute("src","")})}function Dl(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})`);Nl();const r=document.createElement("div");r.className="fb-markdown";const o=Bl(e.content);return r.innerHTML=_t(o),Hl(r),n.appendChild(r),r}function jl(e,t,n){return{value:void 0,errors:[],skip:!0}}function Ol(e,t,n,r){}function Ul(e,t,n){var r;const{scopeRoot:o}=n,i=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`),a=(r=i==null?void 0:i.value)!=null?r:"";if(a===""){const l="default"in e?e.default:null;return{value:l!==void 0?l:null,errors:[]}}return{value:Zt(a),errors:[]}}function Pl(e,t,n,r){const{scopeRoot:o}=r,i=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);i&&(i.value=Gt(n))}const Wl={text:{validate:tn,update:nn},textarea:{validate:Ar,update:Fr},number:{validate:qr,update:Rr},select:{validate:Dr,update:jr},switcher:{validate:Wr,update:Vr},boolean:{validate:Jr,update:Yr,ownsLabel:!0},file:{validate:In,update:Rn},files:{validate:In,update:Rn},colour:{validate:Qo,update:el},slider:{validate:rl,update:ol},container:{validate:Jn,update:Yn},group:{validate:cl,update:dl},table:{validate:wl,update:Cl},richinput:{validate:Fl,update:Ml},hidden:{validate:Ul,update:Pl},markdown:{validate:jl,update:Ol}};function Jt(e){return Wl[e]||null}function Vl(e,t,n){const r=Jt(e.type);return r&&r.validate?r.validate(e,t,n):null}function Kl(e,t,n,r){const o=Jt(e.type);return o&&o.update?(o.update(e,t,n,r),!0):!1}function _l(e,t){const n=document.getElementById(e);if(!n)return;const r=!n.classList.contains("hidden");if(document.querySelectorAll('[id^="tooltip-"]').forEach(u=>{u.classList.add("hidden")}),r)return;const o=t.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight;n&&n.parentElement!==document.body&&document.body.appendChild(n),n.style.visibility="hidden",n.style.position="fixed",n.classList.remove("hidden");const l=n.getBoundingClientRect();n.classList.add("hidden"),n.style.visibility="visible";let s=o.left,c=o.bottom+5;s+l.width>i&&(s=o.right-l.width),c+l.height>a&&(c=o.top-l.height-5),s<10&&(s=10),c<10&&(c=o.bottom+5),n.style.left=`${s}px`,n.style.top=`${c}px`,n.classList.remove("hidden"),setTimeout(()=>{n.classList.add("hidden")},25e3)}typeof document!="undefined"&&document.addEventListener("click",e=>{const t=e.target,n=t.closest("button")&&t.closest("button").onclick,r=t.closest('[id^="tooltip-"]');!n&&!r&&document.querySelectorAll('[id^="tooltip-"]').forEach(o=>{o.classList.add("hidden")})});function ur(e,t){var n,r,o;if(!e.enableIf)return!1;try{const i=(r=(n=t.formData)!=null?n:t.prefill)!=null?r:{},a=((o=e.enableIf.scope)!=null?o:"relative")==="relative"&&t.path?t.prefill:void 0;return!He(e.enableIf,i,a)}catch(i){console.error(`Error evaluating enableIf for field "${e.key}":`,i)}return!1}function Jl(e,t){const n=t.querySelector(`[name="${e}"]`);if(n){if(n instanceof HTMLSelectElement)return n.value;if(n instanceof HTMLInputElement){if(n.type==="checkbox")return n.checked;if(n.type==="radio"){const r=t.querySelector(`[name="${e}"]:checked`);return r?r.value:void 0}else return n.value}else if(n instanceof HTMLTextAreaElement)return n.value}}function vt(e,t,n){var r,o;if(!t.enableIf)return;const i=n.state.formRoot;if(!i){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const a=t.enableIf,l=(r=a.scope)!=null?r:"relative";let s={};const c={};if((!n.path||n.path===""?"absolute":l)==="relative"&&n.path){const u=n.path.match(/^(.+)\[(\d+)\]$/);if(u){const d=u[1],f=parseInt(u[2],10),p=i.querySelector(`[data-container-item="${d}[${f}]"]`);p&&p.querySelectorAll("input, select, textarea").forEach(m=>{const b=m.getAttribute("name");if(b){const v=b.match(/\.([^.[\]]+)$/);if(v){const w=v[1];m instanceof HTMLSelectElement?c[w]=m.value:m instanceof HTMLInputElement?m.type==="checkbox"?c[w]=m.checked:m.type==="radio"?m.checked&&(c[w]=m.value):c[w]=m.value:m instanceof HTMLTextAreaElement&&(c[w]=m.value)}}})}}else{const u=a.key,d=Jl(u,i);d!==void 0?s[u]=d:s=(o=n.formData)!=null?o:n.prefill}try{He(a,s,c)?(e.style.display="",e.classList.remove("fb-field-wrapper-disabled"),e.removeAttribute("data-conditionally-disabled")):(e.style.display="none",e.classList.add("fb-field-wrapper-disabled"),e.setAttribute("data-conditionally-disabled","true"))}catch(u){console.error(`Error re-evaluating enableIf for field "${t.key}":`,u)}}function fr(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot setup enableIf listeners: formRoot is null");return}const i=t.enableIf,a=(r=i.scope)!=null?r:"relative",l=i.key;let s;a==="relative"&&n.path?s=`${n.path}.${l}`:s=l;const c=o.querySelector(`[name="${s}"]`);if(!c){const u=new MutationObserver(()=>{const d=o.querySelector(`[name="${s}"]`);d&&(d.addEventListener("change",()=>{vt(e,t,n)}),d.addEventListener("input",()=>{vt(e,t,n)}),u.disconnect())});u.observe(o,{childList:!0,subtree:!0});return}c.addEventListener("change",()=>{vt(e,t,n)}),c.addEventListener("input",()=>{vt(e,t,n)})}function Yl(e){var t,n;const r=document.createElement("label");if(r.className="text-sm font-medium text-gray-900",r.textContent=(n=(t=e.label)!=null?t:e.key)!=null?n:"",e.required){const o=document.createElement("span");o.className="text-red-500 ml-1",o.textContent="*",r.appendChild(o)}return r}function Xl(e){const t=document.createElement("button");t.type="button",t.className="ml-2 text-gray-400 hover:text-gray-600",t.innerHTML='<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>';const n=`tooltip-${e.key}-${Math.random().toString(36).substr(2,9)}`,r=document.createElement("div");return r.id=n,r.className="hidden absolute z-50 bg-gray-200 text-gray-900 text-sm rounded-lg p-3 max-w-sm border border-gray-300 shadow-lg",r.style.position="fixed",r.textContent=e.description||e.hint||"Field information",document.body.appendChild(r),t.onclick=o=>{o.preventDefault(),o.stopPropagation(),_l(n,t)},t}function Gl(e){const t=document.createElement("div");t.className="flex items-center mb-1",t.dataset.fbLabelRow="";const n=Yl(e);if(t.appendChild(n),e.description||e.hint){const r=Xl(e);t.appendChild(r)}return t}function Zl(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?Sr(e,t,n,r):$r(e,t,n,r);break;case"textarea":o?Tr(e,t,n,r):Lr(e,t,n,r);break;case"number":o?Ir(e,t,n,r):Nr(e,t,n,r);break;case"select":o?Hr(e,t,n,r):Br(e,t,n,r);break;case"switcher":o?Pr(e,t,n,r):Ur(e,t,n,r);break;case"boolean":_r(e,t,n,r);break;case"file":o?Xo(e,t,n,r):Jo(e,t,n,r);break;case"files":Yo(e,t,n,r);break;case"colour":o?Zo(e,t,n,r):Go(e,t,n,r);break;case"slider":o?nl(e,t,n,r):tl(e,t,n,r);break;case"group":sl(e,t,n,r);break;case"container":o?Kn(e,t,n):Vn(e,t,n,r);break;case"table":xl(e,t,n,r);break;case"richinput":Al(e,t,n,r);break;default:{const i=document.createElement("div");i.className="text-red-500 text-sm",i.textContent=k("unsupportedFieldType",t.state,{type:e.type}),n.appendChild(i)}}}function Yt(e,t){if(e.type==="markdown"){if(e.hidden===!0){const s=document.createElement("div");return s.style.display="none",s.setAttribute("data-fb-hidden-markdown","true"),s}const a=ur(e,t),l=document.createElement("div");return l.className="mb-2 fb-field-wrapper fb-markdown-wrapper",l.setAttribute("data-field-key",wt(e,t.state)),Dl(e,t,l),a&&(l.style.display="none",l.classList.add("fb-field-wrapper-disabled"),l.setAttribute("data-conditionally-disabled","true")),fr(l,e,t),l}const n=ur(e,t),r=document.createElement("div");r.className="mb-2 fb-field-wrapper",r.setAttribute("data-field-key",e.key);const o=Jt(e.type);if(!(o!=null&&o.ownsLabel)){const a=Gl(e);r.appendChild(a)}const i=ke(t.path,e.key);return Zl(e,t,r,i),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),fr(r,e,t),r}ll(Yt);const Xt={uploadFile:null,downloadFile:null,getThumbnail:null,getDownloadUrl:null,actionHandler:null,onChange:null,onFieldChange:null,onThumbnailError:null,onUploadError:null,onDownloadError:null,debounceMs:300,verboseErrors:!1,enableFilePreview:!0,maxPreviewSize:"200px",readonly:!1,pickExistingFiles:null,parseTableFile:null,locale:"en",translations:{en:{removeElement:"Remove",clickDragText:"Click or drag file",clickDragTextMultiple:"Click or drag files",noFileSelected:"No file selected",noFilesSelected:"No files selected",downloadButton:"Download",downloadFile:"Download",openInNewTab:"Open in new tab",changeButton:"Change",placeholderText:"Enter text",previewAlt:"Preview",previewUnavailable:"Preview unavailable",previewError:"Preview error",videoNotSupported:"Your browser does not support the video tag.",hintLengthRange:"{min}-{max} chars",hintMaxLength:"\u2264{max} chars",hintMinLength:"\u2265{min} chars",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}MB",hintFormats:"{formats}",hintRequired:"Required",hintOptional:"Optional",hintPattern:"Format: {pattern}",fileCountSingle:"{count} file",fileCountPlural:"{count} files",fileCountWithMax:"{count} / {max} files",fileCountRange:"({min}-{max})",uploadingFile:"Uploading\u2026",filesCounter:"{count}/{max}",fromLibrary:"From library",libraryEmpty:"Library is empty",libraryHint:"Choose from previously uploaded files",dropToUpload:"Release to upload",replaceFile:"Replace",clearAll:"Clear all",pickerError:"Failed to load files from library",required:"Required",minItems:"Minimum {min} items required",maxItems:"Maximum {max} items allowed",minLength:"Minimum {min} characters",maxLength:"Maximum {max} characters",minValue:"Must be at least {min}",maxValue:"Must be at most {max}",patternMismatch:"Invalid format",invalidPattern:"Invalid pattern in schema",notANumber:"Must be a number",invalidHexColour:"Invalid hex color",minFiles:"Minimum {min} files required",maxFiles:"Maximum {max} files allowed",invalidFileExtension:'File "{name}" has unsupported format. Allowed: {formats}',invalidFileMime:'File "{name}": file type {type} not allowed (allowed: {mimes})',fileTooLarge:'File "{name}" exceeds maximum size of {maxSize}MB',uploadFailed:'Failed to upload "{name}": {error}',filesLimitExceeded:"{skipped} file(s) skipped: maximum {max} files allowed",unsupportedFieldType:"Unsupported field type: {type}",invalidOption:"Invalid option",tableAddRow:"Add row",tableAddColumn:"Add column",tableRemoveRow:"Remove row",tableRemoveColumn:"Remove column",tableMergeCells:"Merge cells (Ctrl+M)",tableSplitCell:"Split cell (Ctrl+Shift+M)",tableImportFile:"Import",tableImporting:"Importing...",tableImportError:"Import failed: {error}",richinputPlaceholder:"Type text...",richinputAttachFile:"Attach file",richinputMention:"Mention",richinputRemoveFile:"Remove"},ru:{removeElement:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C",clickDragText:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B",clickDragTextMultiple:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B\u044B",noFileSelected:"\u0424\u0430\u0439\u043B \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D",noFilesSelected:"\u041D\u0435\u0442 \u0444\u0430\u0439\u043B\u043E\u0432",downloadButton:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",downloadFile:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",openInNewTab:"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432 \u043D\u043E\u0432\u043E\u0439 \u0432\u043A\u043B\u0430\u0434\u043A\u0435",changeButton:"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C",placeholderText:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",previewAlt:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440",previewUnavailable:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D",previewError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0430",videoNotSupported:"\u0412\u0430\u0448 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u0438\u0434\u0435\u043E.",hintLengthRange:"{min}-{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMaxLength:"\u2264{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMinLength:"\u2265{min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}\u041C\u0411",hintFormats:"{formats}",hintRequired:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintOptional:"\u041D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintPattern:"\u0424\u043E\u0440\u043C\u0430\u0442: {pattern}",fileCountSingle:"{count} \u0444\u0430\u0439\u043B",fileCountPlural:"{count} \u0444\u0430\u0439\u043B\u043E\u0432",fileCountWithMax:"{count} / {max} \u0444\u0430\u0439\u043B\u043E\u0432",fileCountRange:"({min}-{max})",uploadingFile:"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026",filesCounter:"{count}/{max}",fromLibrary:"\u0418\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",libraryEmpty:"\u0411\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0430 \u043F\u0443\u0441\u0442\u0430",libraryHint:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0438\u0437 \u0440\u0430\u043D\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0445 \u0444\u0430\u0439\u043B\u043E\u0432",dropToUpload:"\u041E\u0442\u043F\u0443\u0441\u0442\u0438\u0442\u0435, \u0447\u0442\u043E\u0431\u044B \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C",replaceFile:"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C",clearAll:"\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0432\u0441\u0435",pickerError:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u0430\u0439\u043B\u044B \u0438\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",required:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u043F\u043E\u043B\u0435",minItems:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",maxItems:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",minLength:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",maxLength:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",minValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {min}",maxValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {max}",patternMismatch:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442",invalidPattern:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043F\u0430\u0442\u0442\u0435\u0440\u043D \u0432 \u0441\u0445\u0435\u043C\u0435",notANumber:"\u0414\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0447\u0438\u0441\u043B\u043E\u043C",invalidHexColour:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 \u0446\u0432\u0435\u0442\u0430",minFiles:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0444\u0430\u0439\u043B\u043E\u0432",maxFiles:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",invalidFileExtension:'\u0424\u0430\u0439\u043B "{name}" \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442. \u0414\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0435: {formats}',invalidFileMime:'\u0424\u0430\u0439\u043B "{name}": \u0442\u0438\u043F \u0444\u0430\u0439\u043B\u0430 {type} \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u044B: {mimes})',fileTooLarge:'\u0424\u0430\u0439\u043B "{name}" \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440 {maxSize}\u041C\u0411',uploadFailed:'\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C "{name}": {error}',filesLimitExceeded:"{skipped} \u0444\u0430\u0439\u043B(\u043E\u0432) \u043F\u0440\u043E\u043F\u0443\u0449\u0435\u043D\u043E: \u043C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",unsupportedFieldType:"\u041D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \u043F\u043E\u043B\u044F: {type}",invalidOption:"\u041D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435",tableAddRow:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableAddColumn:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableRemoveRow:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableRemoveColumn:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableMergeCells:"\u041E\u0431\u044A\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0438 (Ctrl+M)",tableSplitCell:"\u0420\u0430\u0437\u0434\u0435\u043B\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0443 (Ctrl+Shift+M)",tableImportFile:"\u0418\u043C\u043F\u043E\u0440\u0442",tableImporting:"\u0418\u043C\u043F\u043E\u0440\u0442...",tableImportError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u0438\u043C\u043F\u043E\u0440\u0442\u0430: {error}",richinputPlaceholder:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442...",richinputAttachFile:"\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0444\u0430\u0439\u043B",richinputMention:"\u0423\u043F\u043E\u043C\u044F\u043D\u0443\u0442\u044C",richinputRemoveFile:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C"}},theme:{}};function Ql(e){const t={...Xt.translations};if(e!=null&&e.translations)for(const[n,r]of Object.entries(e.translations))t[n]={...Xt.translations[n]||{},...r};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...Xt,...e,translations:t},debounceTimer:null,prefill:{},syntheticElementIds:new WeakMap,syntheticElementIdCounter:0}}function ei(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const Ve={primaryColor:"#3b82f6",primaryHoverColor:"#2563eb",primarySoftColor:"#dbeafe",primarySoftHoverColor:"#bfdbfe",errorColor:"#ef4444",errorHoverColor:"#dc2626",successColor:"#10b981",accentColor:"#f59e0b",accentSoftColor:"#fef3c7",accentBorderColor:"#fde68a",accentTextColor:"#92400e",borderColor:"#d1d5db",borderHoverColor:"#9ca3af",borderFocusColor:"#3b82f6",borderStrongColor:"#9ca3af",backgroundColor:"#ffffff",backgroundHoverColor:"#f9fafb",backgroundReadonlyColor:"#f3f4f6",pageBackgroundColor:"#f9fafb",surfaceSoftColor:"#eff6ff",surfaceTintColor:"#f8fafc",textColor:"#1f2937",textSecondaryColor:"#6b7280",textMutedColor:"#9ca3af",textFaintColor:"#cbd5e1",textPlaceholderColor:"#9ca3af",textDisabledColor:"#d1d5db",buttonBgColor:"#3b82f6",buttonTextColor:"#ffffff",buttonBorderColor:"#2563eb",buttonHoverBgColor:"#2563eb",buttonHoverBorderColor:"#1d4ed8",actionBgColor:"#ffffff",actionTextColor:"#374151",actionBorderColor:"#e5e7eb",actionHoverBgColor:"#f9fafb",actionHoverBorderColor:"#d1d5db",fileUploadBgColor:"#f3f4f6",fileUploadBorderColor:"#d1d5db",fileUploadTextColor:"#9ca3af",fileUploadHoverBorderColor:"#3b82f6",inputPaddingX:"0.5rem",inputPaddingY:"0.25rem",borderRadius:"0.5rem",borderRadiusSmall:"0.375rem",borderRadiusLarge:"0.75rem",borderRadiusXLarge:"1rem",borderWidth:"1px",fontSize:"0.875rem",fontSizeSmall:"0.75rem",fontSizeExtraSmall:"0.625rem",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontWeightNormal:"400",fontWeightMedium:"500",lineHeight:"1.5",shadowCard:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",shadowPopover:"0 12px 32px -12px rgba(15,23,42,.18), 0 4px 12px -6px rgba(15,23,42,.08)",focusRingWidth:"2px",focusRingColor:"#3b82f6",focusRingOpacity:"0.5",transitionDuration:"200ms",slideCardBg:"#ffffff",slideCardShadow:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",slideCardRadius:"0.5rem",slideCardMinHeight:"0",slideCardPadding:"12px",labelSectionFontSize:"0.875rem",labelSectionLetterSpacing:"normal",labelSectionTextTransform:"none"};function ti(e){const t={...Ve,...e},n=[];return Object.entries(t).forEach(([r,o])=>{const i=r.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(` --fb-${i}: ${o};`)}),n.join(`
|
|
1435
|
+
`)}function ni(e,t){wr(e.ownerDocument||document);const n=ti(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=`
|
|
1157
1436
|
[data-fb-root="true"] {
|
|
1158
1437
|
${n}
|
|
1159
1438
|
}
|
|
1160
|
-
`}const
|
|
1439
|
+
`}const ri={default:Ve,dark:{...Ve,primaryColor:"#60a5fa",primaryHoverColor:"#3b82f6",borderColor:"#4b5563",borderHoverColor:"#6b7280",borderFocusColor:"#60a5fa",backgroundColor:"#1f2937",backgroundHoverColor:"#374151",backgroundReadonlyColor:"#111827",textColor:"#f9fafb",textSecondaryColor:"#9ca3af",textPlaceholderColor:"#6b7280",fileUploadBgColor:"#374151",fileUploadBorderColor:"#4b5563",fileUploadTextColor:"#9ca3af"},klein:{...Ve,primaryColor:"#0066cc",primaryHoverColor:"#0052a3",errorColor:"#d32f2f",errorHoverColor:"#c62828",successColor:"#388e3c",borderColor:"#e0e0e0",borderHoverColor:"#bdbdbd",borderFocusColor:"#0066cc",borderRadius:"4px",fontSize:"16px",fontSizeSmall:"14px",fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif'},picaz:{...Ve,primaryColor:"#2f5bea",primaryHoverColor:"#2349c8",primarySoftColor:"#eaf0ff",primarySoftHoverColor:"#d6e0ff",errorColor:"#ef4444",successColor:"#16a34a",accentColor:"#ffb020",accentSoftColor:"#fff7e6",accentBorderColor:"#fde7b5",accentTextColor:"#92400e",borderColor:"#e3e8f0",borderHoverColor:"#cdd6e3",borderFocusColor:"#2f5bea",borderStrongColor:"#cdd6e3",backgroundColor:"#ffffff",backgroundHoverColor:"#f3f7ff",pageBackgroundColor:"#f6f8fb",surfaceSoftColor:"#eef4ff",surfaceTintColor:"#f3f7ff",textColor:"#0f172a",textSecondaryColor:"#334155",textMutedColor:"#64748b",textFaintColor:"#94a3b8",textPlaceholderColor:"#94a3b8",buttonBgColor:"#2f5bea",buttonHoverBgColor:"#2349c8",fileUploadBgColor:"#fafcff",fileUploadBorderColor:"#cdd6e3",fileUploadHoverBorderColor:"#2f5bea",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"}};class yt{constructor(t){this.instanceId=ei(),this.state=Ql(t),this.state.config.verboseErrors&&(globalThis.__formBuilderInstances||(globalThis.__formBuilderInstances=new Set),globalThis.__formBuilderInstances.add(this.instanceId),globalThis.__formBuilderInstances.size>10&&console.warn(`[form-builder] ${globalThis.__formBuilderInstances.size} instances active. Possible memory leak - ensure you call destroy() when done.`))}getInstanceId(){return this.instanceId}getState(){return this.state}setFormRoot(t){this.state.formRoot=t}configure(t){Object.assign(this.state.config,t)}setUploadHandler(t){this.state.config.uploadFile=t}setDownloadHandler(t){this.state.config.downloadFile=t}setThumbnailHandler(t){this.state.config.getThumbnail=t}setActionHandler(t){this.state.config.actionHandler=t}setMode(t){this.state.config.readonly=t==="readonly"}setLocale(t){this.state.config.translations[t]&&(this.state.config.locale=t)}triggerOnChange(t,n){this.state.config.readonly||(this.state.debounceTimer!==null&&clearTimeout(this.state.debounceTimer),this.state.debounceTimer=setTimeout(()=>{const r=this.validateForm(!0);this.reevaluateConditionalFields(),this.state.config.onChange&&this.state.config.onChange(r),this.state.config.onFieldChange&&t!==void 0&&n!==void 0&&this.state.config.onFieldChange(t,n,r),this.state.debounceTimer=null},this.state.config.debounceMs))}registerAction(t){if(!t||!t.value)throw new Error("Action must have a value property");this.state.externalActions||(this.state.externalActions=[]);const n=this.state.externalActions.findIndex(r=>r.value===t.value&&r.related_field===t.related_field);n>=0?this.state.externalActions[n]=t:this.state.externalActions.push(t)}findFormElementByFieldPath(t){if(!this.state.formRoot)return null;let n=this.state.formRoot.querySelector(`[name="${t}"]`);if(n)return n;const r=[t,t.replace(/\[(\d+)\]/g,"[$1]"),t.replace(/\./g,"[")+"]".repeat((t.match(/\./g)||[]).length)];for(const a of r)if(n=this.state.formRoot.querySelector(`[name="${a}"]`),n)return n;const o=this.findSchemaElement(t);if(!o)return null;const i=this.state.formRoot.querySelectorAll(".fb-field-wrapper");for(const a of i){const l=o.label||o.key,s=a.querySelector("label");if(s&&(s.textContent===l||s.textContent===`${l}*`)){let c=a.querySelector(".field-placeholder");return c||(c=document.createElement("div"),c.className="field-placeholder",c.style.display="none",a.appendChild(c)),c}}return null}findSchemaElement(t){if(!this.state.schema||!this.state.schema.elements)return null;let n=this.state.schema.elements,r=null;const o=t.replace(/\[\d+\]/g,"").split(".").filter(Boolean);for(const i of o){if(r=n.find(a=>a.key===i)||null,!r)return null;"elements"in r&&r.elements&&(n=r.elements)}return r}resolveActionLabel(t,n,r,o=!1){if(r&&"actions"in r&&r.actions){const i=r.actions.find(a=>a.key===t);if(i&&i.label)return i.label}if(o&&this.state.schema&&"actions"in this.state.schema&&this.state.schema.actions){const i=this.state.schema.actions.find(a=>a.key===t);if(i&&i.label)return i.label}return n||t}renderFormLevelActions(t,n=[]){if(!this.state.formRoot)return;const r=this.state.formRoot.querySelector(".form-level-actions-container");r&&r.remove();const o=document.createElement("div");o.className="form-level-actions-container mt-3 pt-2 flex flex-wrap gap-2 justify-center",o.style.cssText=`
|
|
1161
1440
|
border-top: var(--fb-border-width) solid var(--fb-border-color);
|
|
1162
|
-
`,t.forEach(a=>{const i=document.createElement("button");i.type="button",Vt(i,!0);const l=n.includes(a),s=this.resolveActionLabel(a.key,a.label,null,l);i.textContent=s,i.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(a.value,a.key,null)}),o.appendChild(i)}),this.state.formRoot.appendChild(o)}renderExternalActions(){if(!this.state.externalActions||!Array.isArray(this.state.externalActions))return;const t=new Map,n=[],r=[];this.state.externalActions.forEach(a=>{!a.key||!a.value||(a.related_field?(t.has(a.related_field)||t.set(a.related_field,[]),t.get(a.related_field).push(a)):n.push(a))}),t.forEach((a,i)=>{const l=this.findFormElementByFieldPath(i);if(!l){console.warn(`External action: Could not find form element for field "${i}", treating as form-level actions`),r.push(...a);return}let s=l.closest(".fb-field-wrapper");if(s||(s=l.parentElement),!s){console.warn(`External action: Could not find wrapper for field "${i}"`);return}const u=s.querySelector(".external-actions-container");u&&u.remove();const d=document.createElement("div");d.className="external-actions-container mt-3 flex flex-wrap gap-2";const c=this.findSchemaElement(i);a.forEach(p=>{const f=document.createElement("button");f.type="button",Vt(f,!1);const m=this.resolveActionLabel(p.key,p.label,c);f.textContent=m,f.addEventListener("click",b=>{b.preventDefault(),b.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(p.value,p.key,p.related_field)}),d.appendChild(f)}),s.appendChild(d)});const o=[...n,...r];o.length>0&&this.renderFormLevelActions(o,n)}handlePrefillHintClick(t){const n=t.target;if(!n.classList.contains("fb-prefill-hint"))return;t.preventDefault(),t.stopPropagation();const r=n.getAttribute("data-hint-values"),o=n.getAttribute("data-root-hint")==="true",a=n.getAttribute("data-container-key");if(!r||!o&&!a){console.warn("Prefill hint missing required data attributes");return}try{const i=JSON.parse(r);for(const l in i){const s=o?l:`${a}.${l}`,u=i[l];this.updateField(s,u)}}catch(i){console.error("Error parsing prefill hint values:",i)}}createRootPrefillHints(t){const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-2",t.forEach(r=>{const o=document.createElement("button");o.type="button",o.className="fb-prefill-hint",r.icon?o.textContent=`${r.icon} ${r.label}`:o.textContent=r.label,o.setAttribute("data-hint-values",JSON.stringify(r.values)),o.setAttribute("data-root-hint","true"),n.appendChild(o)}),n}renderForm(t,n,r,o){const a=bt(n);if(a.length>0){console.error("Schema validation errors:",a);return}this.state.formRoot=t,this.state.schema=n,this.state.externalActions=o||null,this.state.prefill=r||{},ge(t),t.setAttribute("data-fb-root","true"),Nl(t,this.state.config.theme);const i=document.createElement("div");if(i.className="space-y-2",n.prefillHints&&!this.state.config.readonly){const u=this.createRootPrefillHints(n.prefillHints);i.appendChild(u)}const l=document.createElement("div"),s=n.columns||1;s===1?l.className="space-y-2":l.className=`grid grid-cols-${s} gap-2`,n.elements.forEach(u=>{var d,c;if(u.type!=="markdown"&&(u.hidden||u.type==="hidden")){const f=(c=(d=r==null?void 0:r[u.key])!=null?d:u.default)!=null?c:null;l.appendChild(We(u.key,f));return}const p=Ot(u,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});l.appendChild(p)}),i.appendChild(l),t.appendChild(i),this.state.config.readonly||t.addEventListener("click",this.handlePrefillHintClick.bind(this)),this.state.config.readonly&&this.state.externalActions&&Array.isArray(this.state.externalActions)&&this.renderExternalActions()}validateForm(t=!1){if(!this.state.schema||!this.state.formRoot)return{valid:!0,errors:[],data:{}};const n=[],r={},o=(a,i,l=null)=>{var s;const u=(s=a.key)!=null?s:"",d={scopeRoot:l||this.state.formRoot,state:this.state,instance:this,path:i.path,skipValidation:t},c=Bl(a,u,d);return c!==null?(n.push(...c.errors),{value:c.value,spread:!!c.spread,skip:!!c.skip}):(console.warn(`Unknown field type "${a.type}" for key "${u}"`),{value:null,spread:!1})};return Po(o),this.state.schema.elements.forEach(a=>{var i;if(a.enableIf)try{if(!He(a.enableIf,r))return}catch(l){console.error(`Error evaluating enableIf for field "${a.key}" during validation:`,l)}if(a.type!=="markdown")if(a.hidden||a.type==="hidden"){const l=this.state.formRoot.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${a.key}"]`),s=(i=l==null?void 0:l.value)!=null?i:"";s!==""?r[a.key]=Wt(s):r[a.key]=a.default!==void 0?a.default:null}else{const l=o(a,{path:""});if(l.skip)return;l.spread&&l.value!==null&&typeof l.value=="object"?Object.assign(r,l.value):a.key&&(r[a.key]=l.value)}}),{valid:n.length===0,errors:n,data:r}}getFormData(){return this.validateForm(!1)}submitForm(){const t=this.validateForm(!1);return t.valid&&typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formSubmit",data:t.data,schema:this.state.schema},"*"),t}saveDraft(){const t=this.validateForm(!0);return typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formDraft",data:t.data,schema:this.state.schema},"*"),t}clearForm(){if(!this.state.schema||!this.state.formRoot){console.warn("clearForm: Form not initialized. Call renderForm() first.");return}const t=this.state.schema,n=this.state.formRoot,r=this.state.externalActions,o=this.buildHiddenFieldsData(t.elements);this.renderForm(n,t,o,r||void 0)}buildHiddenFieldsData(t){const n={};for(const r of t){if(r.type==="markdown"||!r.key)continue;const o=r.key;if(r.hidden&&r.default!==void 0&&(n[o]=r.default),r.type==="container"||r.type==="group"){const a=r,i=this.buildHiddenFieldsData(a.elements);Object.keys(i).length>0&&(o in n?typeof n[o]=="object"&&n[o]!==null&&!Array.isArray(n[o])&&(n[o]={...n[o],...i}):n[o]=i)}}return n}buildFlatKeyMap(t){var n,r;const o=new Map;for(const a of t)if(a.type==="richinput"&&a.flatOutput){const i=a,l=(n=i.textKey)!=null?n:"text",s=(r=i.filesKey)!=null?r:"files";o.set(l,{schemaKey:a.key,role:"text"}),o.set(s,{schemaKey:a.key,role:"files"})}return o}setFormData(t){if(!this.state.schema||!this.state.formRoot){console.warn("setFormData: Form not initialized. Call renderForm() first.");return}const n=this.buildFlatKeyMap(this.state.schema.elements),r=new Map;for(const o in t){const a=n.get(o);a?(r.has(a.schemaKey)||r.set(a.schemaKey,{}),r.get(a.schemaKey)[o]=t[o]):this.updateField(o,t[o])}for(const[o,a]of r)this.updateField(o,a)}updateField(t,n){if(!this.state.schema||!this.state.formRoot){console.warn("updateField: Form not initialized. Call renderForm() first.");return}const r=this.findSchemaElement(t);if(!r){console.warn(`updateField: Schema element not found for path "${t}"`);return}const o=this.findFormElementByFieldPath(t);if(!o){console.warn(`updateField: DOM element not found for path "${t}"`);return}this.updateFieldValue(o,r,t,n),this.reevaluateConditionalFields(),(this.state.config.onChange||this.state.config.onFieldChange)&&this.triggerOnChange(t,n)}updateFieldValue(t,n,r,o){const a={scopeRoot:this.state.formRoot,state:this.state,instance:this,path:""};Dl(n,r,o,a)||console.warn(`updateField: No updater found for field type "${n.type}" at path "${r}"`)}findFieldWrapper(t,n){const r=this.state.formRoot,o=vt(t,this.state);if(!n)return r.querySelector(`[data-field-key="${o}"]`);const a=n.match(/^(.+)\[(\d+)\]$/);if(a){const l=r.querySelector(`[data-container-item="${a[1]}[${a[2]}]"]`);return l?l.querySelector(`[data-field-key="${o}"]`):null}const i=r.querySelector(`[data-container="${n}"]`);return i?i.querySelector(`[data-field-key="${o}"]`):null}applyEnableIfVisibility(t,n,r,o,a){var i,l,s,u;try{const d=((i=t.enableIf.scope)!=null?i:"relative")==="relative"&&r?gt(a,r):void 0,c=He(t.enableIf,a,d),p=n.getAttribute("data-conditionally-disabled")==="true";if(c&&p){const f=r?gt(a,r):a,m=Ot(t,{path:r,prefill:f&&typeof f=="object"?f:{},formData:a,state:this.state,instance:this});(l=n.parentNode)==null||l.replaceChild(m,n)}else if(!c&&!p){const f=document.createElement("div");f.className="fb-field-wrapper-disabled",f.style.display="none",f.setAttribute("data-field-key",vt(t,this.state)),f.setAttribute("data-conditionally-disabled","true"),(s=n.parentNode)==null||s.replaceChild(f,n)}}catch(d){console.error(`Error re-evaluating enableIf for field "${(u=t.key)!=null?u:"<no key>"}" at path "${o}":`,d)}}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(r,o)=>{r.forEach(a=>{var i,l;const s=o?`${o}.${(i=a.key)!=null?i:""}`:(l=a.key)!=null?l:"";if(a.enableIf){const u=this.findFieldWrapper(a,o);u&&this.applyEnableIfVisibility(a,u,o,s,t)}if((a.type==="container"||a.type==="group")&&"elements"in a&&a.elements){const u=a.key?t==null?void 0:t[a.key]:void 0;if(Array.isArray(u)){const d=this.state.formRoot.querySelectorAll("[data-container-item]");(s?Array.from(d).filter(c=>{const p=c.getAttribute("data-container-item")||"";if(!p.startsWith(`${s}[`))return!1;const f=p.slice(s.length);return/^\[\d+\]$/.test(f)}):[]).forEach(c=>{const p=c.getAttribute("data-container-item")||"";n(a.elements,p)})}else n(a.elements,s)}})};n(this.state.schema.elements,"")}destroy(){var t;this.state.debounceTimer!==null&&(clearTimeout(this.state.debounceTimer),this.state.debounceTimer=null),this.state.resourceIndex.clear(),this.state.formRoot&&ge(this.state.formRoot),this.state.formRoot=null,this.state.schema=null,this.state.externalActions=null,this.state.config.verboseErrors&&((t=globalThis.__formBuilderInstances)==null||t.delete(this.instanceId))}}function sr(e){return new ht(e)}return typeof window!="undefined"&&(window.FormBuilder=ht,window.createFormBuilder=sr,window.validateSchema=bt),Se.FormBuilderInstance=ht,Se.createFormBuilder=sr,Se.default=ht,Se.defaultTheme=Ye,Se.exampleThemes=ql,Se.validateSchema=bt,Object.defineProperty(Se,"__esModule",{value:!0}),Se})({});
|
|
1441
|
+
`,t.forEach(i=>{const a=document.createElement("button");a.type="button",en(a,!0);const l=n.includes(i),s=this.resolveActionLabel(i.key,i.label,null,l);a.textContent=s,a.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(i.value,i.key,null)}),o.appendChild(a)}),this.state.formRoot.appendChild(o)}renderExternalActions(){if(!this.state.externalActions||!Array.isArray(this.state.externalActions))return;const t=new Map,n=[],r=[];this.state.externalActions.forEach(i=>{!i.key||!i.value||(i.related_field?(t.has(i.related_field)||t.set(i.related_field,[]),t.get(i.related_field).push(i)):n.push(i))}),t.forEach((i,a)=>{const l=this.findFormElementByFieldPath(a);if(!l){console.warn(`External action: Could not find form element for field "${a}", treating as form-level actions`),r.push(...i);return}let s=l.closest(".fb-field-wrapper");if(s||(s=l.parentElement),!s){console.warn(`External action: Could not find wrapper for field "${a}"`);return}const c=s.querySelector(".external-actions-container");c&&c.remove();const u=document.createElement("div");u.className="external-actions-container mt-3 flex flex-wrap gap-2";const d=this.findSchemaElement(a);i.forEach(f=>{const p=document.createElement("button");p.type="button",en(p,!1);const m=this.resolveActionLabel(f.key,f.label,d);p.textContent=m,p.addEventListener("click",b=>{b.preventDefault(),b.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(f.value,f.key,f.related_field)}),u.appendChild(p)}),s.appendChild(u)});const o=[...n,...r];o.length>0&&this.renderFormLevelActions(o,n)}handlePrefillHintClick(t){const n=t.target;if(!n.classList.contains("fb-prefill-hint"))return;t.preventDefault(),t.stopPropagation();const r=n.getAttribute("data-hint-values"),o=n.getAttribute("data-root-hint")==="true",i=n.getAttribute("data-container-key");if(!r||!o&&!i){console.warn("Prefill hint missing required data attributes");return}try{const a=JSON.parse(r);for(const s in a){const c=o?s:`${i}.${s}`,u=a[s];this.updateField(c,u)}const l=n.closest(".fb-prefill-hints");l&&l.querySelectorAll('.fb-prefill-hint[aria-pressed="true"]').forEach(s=>s.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 i=xt(n);if(i.length>0){console.error("Schema validation errors:",i);return}this.state.formRoot=t,this.state.schema=n,this.state.externalActions=o||null,this.state.prefill=r||{},ye(t),t.setAttribute("data-fb-root","true"),ni(t,this.state.config.theme);const a=document.createElement("div");if(a.className="space-y-2",n.prefillHints&&!this.state.config.readonly){const c=this.createRootPrefillHints(n.prefillHints);a.appendChild(c)}const l=document.createElement("div"),s=n.columns||1;s===1?l.className="space-y-2":l.className=`grid grid-cols-${s} gap-2`,n.elements.forEach(c=>{var u,d;if(c.type!=="markdown"&&(c.hidden||c.type==="hidden")){const p=(d=(u=r==null?void 0:r[c.key])!=null?u:c.default)!=null?d:null;l.appendChild(_e(c.key,p));return}const f=Yt(c,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});l.appendChild(f)}),a.appendChild(l),t.appendChild(a),this.state.config.readonly||t.addEventListener("click",this.handlePrefillHintClick.bind(this)),this.state.config.readonly&&this.state.externalActions&&Array.isArray(this.state.externalActions)&&this.renderExternalActions()}validateForm(t=!1){if(!this.state.schema||!this.state.formRoot)return{valid:!0,errors:[],data:{}};const n=[],r={},o=(i,a,l=null)=>{var s;const c=(s=i.key)!=null?s:"",u={scopeRoot:l||this.state.formRoot,state:this.state,instance:this,path:a.path,skipValidation:t},d=Vl(i,c,u);return d!==null?(n.push(...d.errors),{value:d.value,spread:!!d.spread,skip:!!d.skip}):(console.warn(`Unknown field type "${i.type}" for key "${c}"`),{value:null,spread:!1})};return al(o),this.state.schema.elements.forEach(i=>{var a;if(i.enableIf)try{if(!He(i.enableIf,r))return}catch(l){console.error(`Error evaluating enableIf for field "${i.key}" during validation:`,l)}if(i.type!=="markdown")if(i.hidden||i.type==="hidden"){const l=this.state.formRoot.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${i.key}"]`),s=(a=l==null?void 0:l.value)!=null?a:"";s!==""?r[i.key]=Zt(s):r[i.key]=i.default!==void 0?i.default:null}else{const l=o(i,{path:""});if(l.skip)return;l.spread&&l.value!==null&&typeof l.value=="object"?Object.assign(r,l.value):i.key&&(r[i.key]=l.value)}}),{valid:n.length===0,errors:n,data:r}}getFormData(){return this.validateForm(!1)}submitForm(){const t=this.validateForm(!1);return t.valid&&typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formSubmit",data:t.data,schema:this.state.schema},"*"),t}saveDraft(){const t=this.validateForm(!0);return typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formDraft",data:t.data,schema:this.state.schema},"*"),t}clearForm(){if(!this.state.schema||!this.state.formRoot){console.warn("clearForm: Form not initialized. Call renderForm() first.");return}const t=this.state.schema,n=this.state.formRoot,r=this.state.externalActions,o=this.buildHiddenFieldsData(t.elements);this.renderForm(n,t,o,r||void 0)}buildHiddenFieldsData(t){const n={};for(const r of t){if(r.type==="markdown"||!r.key)continue;const o=r.key;if(r.hidden&&r.default!==void 0&&(n[o]=r.default),r.type==="container"||r.type==="group"){const i=r,a=this.buildHiddenFieldsData(i.elements);Object.keys(a).length>0&&(o in n?typeof n[o]=="object"&&n[o]!==null&&!Array.isArray(n[o])&&(n[o]={...n[o],...a}):n[o]=a)}}return n}buildFlatKeyMap(t){var n,r;const o=new Map;for(const i of t)if(i.type==="richinput"&&i.flatOutput){const a=i,l=(n=a.textKey)!=null?n:"text",s=(r=a.filesKey)!=null?r:"files";o.set(l,{schemaKey:i.key,role:"text"}),o.set(s,{schemaKey:i.key,role:"files"})}return o}setFormData(t){if(!this.state.schema||!this.state.formRoot){console.warn("setFormData: Form not initialized. Call renderForm() first.");return}const n=this.buildFlatKeyMap(this.state.schema.elements),r=new Map;for(const o in t){const i=n.get(o);i?(r.has(i.schemaKey)||r.set(i.schemaKey,{}),r.get(i.schemaKey)[o]=t[o]):this.updateField(o,t[o])}for(const[o,i]of r)this.updateField(o,i)}updateField(t,n){if(!this.state.schema||!this.state.formRoot){console.warn("updateField: Form not initialized. Call renderForm() first.");return}const r=this.findSchemaElement(t);if(!r){console.warn(`updateField: Schema element not found for path "${t}"`);return}const o=this.findFormElementByFieldPath(t);if(!o){console.warn(`updateField: DOM element not found for path "${t}"`);return}this.updateFieldValue(o,r,t,n),this.reevaluateConditionalFields(),(this.state.config.onChange||this.state.config.onFieldChange)&&this.triggerOnChange(t,n)}updateFieldValue(t,n,r,o){const i={scopeRoot:this.state.formRoot,state:this.state,instance:this,path:""};Kl(n,r,o,i)||console.warn(`updateField: No updater found for field type "${n.type}" at path "${r}"`)}findFieldWrapper(t,n){const r=this.state.formRoot,o=wt(t,this.state);if(!n)return r.querySelector(`[data-field-key="${o}"]`);const i=n.match(/^(.+)\[(\d+)\]$/);if(i){const l=r.querySelector(`[data-container-item="${i[1]}[${i[2]}]"]`);return l?l.querySelector(`[data-field-key="${o}"]`):null}const a=r.querySelector(`[data-container="${n}"]`);return a?a.querySelector(`[data-field-key="${o}"]`):null}applyEnableIfVisibility(t,n,r,o,i){var a,l,s,c;try{const u=((a=t.enableIf.scope)!=null?a:"relative")==="relative"&&r?Ct(i,r):void 0,d=He(t.enableIf,i,u),f=n.getAttribute("data-conditionally-disabled")==="true";if(d&&f){const p=r?Ct(i,r):i,m=Yt(t,{path:r,prefill:p&&typeof p=="object"?p:{},formData:i,state:this.state,instance:this});(l=n.parentNode)==null||l.replaceChild(m,n)}else if(!d&&!f){const p=document.createElement("div");p.className="fb-field-wrapper-disabled",p.style.display="none",p.setAttribute("data-field-key",wt(t,this.state)),p.setAttribute("data-conditionally-disabled","true"),(s=n.parentNode)==null||s.replaceChild(p,n)}}catch(u){console.error(`Error re-evaluating enableIf for field "${(c=t.key)!=null?c:"<no key>"}" at path "${o}":`,u)}}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(r,o)=>{r.forEach(i=>{var a,l;const s=o?`${o}.${(a=i.key)!=null?a:""}`:(l=i.key)!=null?l:"";if(i.enableIf){const c=this.findFieldWrapper(i,o);c&&this.applyEnableIfVisibility(i,c,o,s,t)}if((i.type==="container"||i.type==="group")&&"elements"in i&&i.elements){const c=i.key?t==null?void 0:t[i.key]:void 0;if(Array.isArray(c)){const u=this.state.formRoot.querySelectorAll("[data-container-item]");(s?Array.from(u).filter(d=>{const f=d.getAttribute("data-container-item")||"";if(!f.startsWith(`${s}[`))return!1;const p=f.slice(s.length);return/^\[\d+\]$/.test(p)}):[]).forEach(d=>{const f=d.getAttribute("data-container-item")||"";n(i.elements,f)})}else n(i.elements,s)}})};n(this.state.schema.elements,"")}destroy(){var t;this.state.debounceTimer!==null&&(clearTimeout(this.state.debounceTimer),this.state.debounceTimer=null),this.state.resourceIndex.clear(),this.state.formRoot&&ye(this.state.formRoot),this.state.formRoot=null,this.state.schema=null,this.state.externalActions=null,this.state.config.verboseErrors&&((t=globalThis.__formBuilderInstances)==null||t.delete(this.instanceId))}}function pr(e){return new yt(e)}return typeof window!="undefined"&&(window.FormBuilder=yt,window.createFormBuilder=pr,window.validateSchema=xt),Ae.FormBuilderInstance=yt,Ae.createFormBuilder=pr,Ae.default=yt,Ae.defaultTheme=Ve,Ae.exampleThemes=ri,Ae.validateSchema=xt,Object.defineProperty(Ae,"__esModule",{value:!0}),Ae})({});
|