@dmitryvim/form-builder 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/formbuilder.min.js +2 -2
- package/dist/browser/{formbuilder.v0.3.2.min.js → formbuilder.v0.3.3.min.js} +2 -2
- package/dist/cjs/index.cjs +12 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +12 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/form-builder.js +2 -2
- package/dist/types/instance/FormBuilderInstance.d.ts +1 -0
- package/dist/types/types/state.d.ts +10 -0
- package/package.json +1 -1
|
@@ -1431,11 +1431,11 @@ var FormBuilder=(function(Ae){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1431
1431
|
.fb-markdown strong { font-weight: var(--fb-font-weight-medium, 600); }
|
|
1432
1432
|
.fb-markdown em { font-style: italic; }
|
|
1433
1433
|
.fb-markdown s { text-decoration: line-through; }
|
|
1434
|
-
`,document.head.appendChild(e)}const Il=["javascript:","data:","vbscript:","blob:"],Rl=["javascript:","vbscript:","blob:"];function ql(e){return!!(Rl.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();ql(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:Rr,update:qr},select:{validate:Dr,update:jr},switcher:{validate:Wr,update:Vr},boolean:{validate:Jr,update:Yr,ownsLabel:!0},file:{validate:In,update:qn},files:{validate:In,update:qn},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:zl},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 Yl(e,t){const n=e.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return{};const r={};let o=r;for(let a=0;a<n.length-1;a++){const l=n[a],s=n[a+1],c=s.startsWith("[")&&s.endsWith("]")?[]:{};if(l.startsWith("[")&&l.endsWith("]")){const u=parseInt(l.slice(1,-1),10);o[u]=c}else o[l]=c;o=c}const i=n[n.length-1];return i.startsWith("[")&&i.endsWith("]")?o[parseInt(i.slice(1,-1),10)]=t:o[i]=t,r}function gt(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const i=t.enableIf,a=(r=i.scope)!=null?r:"relative",l=!n.path||n.path===""?"absolute":a,s=i.key,c=l==="relative"&&n.path?`${n.path}.${s}`:s,u=Jl(c,o),d=Yl(s,u),f=l==="relative"?{}:d,p=l==="relative"?d:void 0;try{He(i,f,p)?(e.style.display="",e.classList.remove("fb-field-wrapper-disabled"),e.removeAttribute("data-conditionally-disabled")):(e.style.display="none",e.classList.add("fb-field-wrapper-disabled"),e.setAttribute("data-conditionally-disabled","true"))}catch(m){console.error(`Error re-evaluating enableIf for field "${t.key}":`,m)}}function 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",()=>{gt(e,t,n)}),d.addEventListener("input",()=>{gt(e,t,n)}),u.disconnect())});u.observe(o,{childList:!0,subtree:!0});return}c.addEventListener("change",()=>{gt(e,t,n)}),c.addEventListener("input",()=>{gt(e,t,n)})}function Xl(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 Gl(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 Zl(e){const t=document.createElement("div");t.className="flex items-center mb-1",t.dataset.fbLabelRow="";const n=Xl(e);if(t.appendChild(n),e.description||e.hint){const r=Gl(e);t.appendChild(r)}return t}function Ql(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=Zl(e);r.appendChild(a)}const i=ke(t.path,e.key);return Ql(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 ei(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 ti(){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 ni(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(`
|
|
1434
|
+
`,document.head.appendChild(e)}const Il=["javascript:","data:","vbscript:","blob:"],Rl=["javascript:","vbscript:","blob:"];function ql(e){return!!(Rl.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();ql(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:Rr,update:qr},select:{validate:Dr,update:jr},switcher:{validate:Wr,update:Vr},boolean:{validate:Jr,update:Yr,ownsLabel:!0},file:{validate:In,update:qn},files:{validate:In,update:qn},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:zl},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 Yl(e,t){const n=e.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return{};const r={};let o=r;for(let a=0;a<n.length-1;a++){const l=n[a],s=n[a+1],c=s.startsWith("[")&&s.endsWith("]")?[]:{};if(l.startsWith("[")&&l.endsWith("]")){const u=parseInt(l.slice(1,-1),10);o[u]=c}else o[l]=c;o=c}const i=n[n.length-1];return i.startsWith("[")&&i.endsWith("]")?o[parseInt(i.slice(1,-1),10)]=t:o[i]=t,r}function gt(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const i=t.enableIf,a=(r=i.scope)!=null?r:"relative",l=!n.path||n.path===""?"absolute":a,s=i.key,c=l==="relative"&&n.path?`${n.path}.${s}`:s,u=Jl(c,o),d=Yl(s,u),f=l==="relative"?{}:d,p=l==="relative"?d:void 0;try{He(i,f,p)?(e.style.display="",e.classList.remove("fb-field-wrapper-disabled"),e.removeAttribute("data-conditionally-disabled")):(e.style.display="none",e.classList.add("fb-field-wrapper-disabled"),e.setAttribute("data-conditionally-disabled","true"))}catch(m){console.error(`Error re-evaluating enableIf for field "${t.key}":`,m)}}function 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",()=>{gt(e,t,n)}),d.addEventListener("input",()=>{gt(e,t,n)}),u.disconnect(),n.state.enableIfObservers.delete(u))});n.state.enableIfObservers.add(u),u.observe(o,{childList:!0,subtree:!0});return}c.addEventListener("change",()=>{gt(e,t,n)}),c.addEventListener("input",()=>{gt(e,t,n)})}function Xl(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 Gl(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 Zl(e){const t=document.createElement("div");t.className="flex items-center mb-1",t.dataset.fbLabelRow="";const n=Xl(e);if(t.appendChild(n),e.description||e.hint){const r=Gl(e);t.appendChild(r)}return t}function Ql(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=Zl(e);r.appendChild(a)}const i=ke(t.path,e.key);return Ql(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 ei(e){const t={...Xt.translations};if(e!=null&&e.translations)for(const[n,r]of Object.entries(e.translations))t[n]={...Xt.translations[n]||{},...r};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...Xt,...e,translations:t},debounceTimer:null,prefill:{},syntheticElementIds:new WeakMap,syntheticElementIdCounter:0,enableIfObservers:new Set}}function ti(){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 ni(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
1435
|
`)}function ri(e,t){wr(e.ownerDocument||document);const n=ni(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=`
|
|
1436
1436
|
[data-fb-root="true"] {
|
|
1437
1437
|
${n}
|
|
1438
1438
|
}
|
|
1439
1439
|
`}const oi={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=ti(),this.state=ei(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=`
|
|
1440
1440
|
border-top: var(--fb-border-width) solid var(--fb-border-color);
|
|
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"),ri(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=oi,Ae.validateSchema=xt,Object.defineProperty(Ae,"__esModule",{value:!0}),Ae})({});
|
|
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.disconnectEnableIfObservers(),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"),ri(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.disconnectEnableIfObservers(),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))}disconnectEnableIfObservers(){for(const t of this.state.enableIfObservers)t.disconnect();this.state.enableIfObservers.clear()}}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=oi,Ae.validateSchema=xt,Object.defineProperty(Ae,"__esModule",{value:!0}),Ae})({});
|
|
@@ -1431,11 +1431,11 @@ var FormBuilder=(function(Ae){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1431
1431
|
.fb-markdown strong { font-weight: var(--fb-font-weight-medium, 600); }
|
|
1432
1432
|
.fb-markdown em { font-style: italic; }
|
|
1433
1433
|
.fb-markdown s { text-decoration: line-through; }
|
|
1434
|
-
`,document.head.appendChild(e)}const Il=["javascript:","data:","vbscript:","blob:"],Rl=["javascript:","vbscript:","blob:"];function ql(e){return!!(Rl.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();ql(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:Rr,update:qr},select:{validate:Dr,update:jr},switcher:{validate:Wr,update:Vr},boolean:{validate:Jr,update:Yr,ownsLabel:!0},file:{validate:In,update:qn},files:{validate:In,update:qn},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:zl},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 Yl(e,t){const n=e.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return{};const r={};let o=r;for(let a=0;a<n.length-1;a++){const l=n[a],s=n[a+1],c=s.startsWith("[")&&s.endsWith("]")?[]:{};if(l.startsWith("[")&&l.endsWith("]")){const u=parseInt(l.slice(1,-1),10);o[u]=c}else o[l]=c;o=c}const i=n[n.length-1];return i.startsWith("[")&&i.endsWith("]")?o[parseInt(i.slice(1,-1),10)]=t:o[i]=t,r}function gt(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const i=t.enableIf,a=(r=i.scope)!=null?r:"relative",l=!n.path||n.path===""?"absolute":a,s=i.key,c=l==="relative"&&n.path?`${n.path}.${s}`:s,u=Jl(c,o),d=Yl(s,u),f=l==="relative"?{}:d,p=l==="relative"?d:void 0;try{He(i,f,p)?(e.style.display="",e.classList.remove("fb-field-wrapper-disabled"),e.removeAttribute("data-conditionally-disabled")):(e.style.display="none",e.classList.add("fb-field-wrapper-disabled"),e.setAttribute("data-conditionally-disabled","true"))}catch(m){console.error(`Error re-evaluating enableIf for field "${t.key}":`,m)}}function 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",()=>{gt(e,t,n)}),d.addEventListener("input",()=>{gt(e,t,n)}),u.disconnect())});u.observe(o,{childList:!0,subtree:!0});return}c.addEventListener("change",()=>{gt(e,t,n)}),c.addEventListener("input",()=>{gt(e,t,n)})}function Xl(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 Gl(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 Zl(e){const t=document.createElement("div");t.className="flex items-center mb-1",t.dataset.fbLabelRow="";const n=Xl(e);if(t.appendChild(n),e.description||e.hint){const r=Gl(e);t.appendChild(r)}return t}function Ql(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=Zl(e);r.appendChild(a)}const i=ke(t.path,e.key);return Ql(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 ei(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 ti(){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 ni(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(`
|
|
1434
|
+
`,document.head.appendChild(e)}const Il=["javascript:","data:","vbscript:","blob:"],Rl=["javascript:","vbscript:","blob:"];function ql(e){return!!(Rl.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();ql(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:Rr,update:qr},select:{validate:Dr,update:jr},switcher:{validate:Wr,update:Vr},boolean:{validate:Jr,update:Yr,ownsLabel:!0},file:{validate:In,update:qn},files:{validate:In,update:qn},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:zl},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 Yl(e,t){const n=e.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return{};const r={};let o=r;for(let a=0;a<n.length-1;a++){const l=n[a],s=n[a+1],c=s.startsWith("[")&&s.endsWith("]")?[]:{};if(l.startsWith("[")&&l.endsWith("]")){const u=parseInt(l.slice(1,-1),10);o[u]=c}else o[l]=c;o=c}const i=n[n.length-1];return i.startsWith("[")&&i.endsWith("]")?o[parseInt(i.slice(1,-1),10)]=t:o[i]=t,r}function gt(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const i=t.enableIf,a=(r=i.scope)!=null?r:"relative",l=!n.path||n.path===""?"absolute":a,s=i.key,c=l==="relative"&&n.path?`${n.path}.${s}`:s,u=Jl(c,o),d=Yl(s,u),f=l==="relative"?{}:d,p=l==="relative"?d:void 0;try{He(i,f,p)?(e.style.display="",e.classList.remove("fb-field-wrapper-disabled"),e.removeAttribute("data-conditionally-disabled")):(e.style.display="none",e.classList.add("fb-field-wrapper-disabled"),e.setAttribute("data-conditionally-disabled","true"))}catch(m){console.error(`Error re-evaluating enableIf for field "${t.key}":`,m)}}function 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",()=>{gt(e,t,n)}),d.addEventListener("input",()=>{gt(e,t,n)}),u.disconnect(),n.state.enableIfObservers.delete(u))});n.state.enableIfObservers.add(u),u.observe(o,{childList:!0,subtree:!0});return}c.addEventListener("change",()=>{gt(e,t,n)}),c.addEventListener("input",()=>{gt(e,t,n)})}function Xl(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 Gl(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 Zl(e){const t=document.createElement("div");t.className="flex items-center mb-1",t.dataset.fbLabelRow="";const n=Xl(e);if(t.appendChild(n),e.description||e.hint){const r=Gl(e);t.appendChild(r)}return t}function Ql(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=Zl(e);r.appendChild(a)}const i=ke(t.path,e.key);return Ql(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 ei(e){const t={...Xt.translations};if(e!=null&&e.translations)for(const[n,r]of Object.entries(e.translations))t[n]={...Xt.translations[n]||{},...r};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...Xt,...e,translations:t},debounceTimer:null,prefill:{},syntheticElementIds:new WeakMap,syntheticElementIdCounter:0,enableIfObservers:new Set}}function ti(){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 ni(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
1435
|
`)}function ri(e,t){wr(e.ownerDocument||document);const n=ni(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=`
|
|
1436
1436
|
[data-fb-root="true"] {
|
|
1437
1437
|
${n}
|
|
1438
1438
|
}
|
|
1439
1439
|
`}const oi={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=ti(),this.state=ei(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=`
|
|
1440
1440
|
border-top: var(--fb-border-width) solid var(--fb-border-color);
|
|
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"),ri(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=oi,Ae.validateSchema=xt,Object.defineProperty(Ae,"__esModule",{value:!0}),Ae})({});
|
|
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.disconnectEnableIfObservers(),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"),ri(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.disconnectEnableIfObservers(),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))}disconnectEnableIfObservers(){for(const t of this.state.enableIfObservers)t.disconnect();this.state.enableIfObservers.clear()}}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=oi,Ae.validateSchema=xt,Object.defineProperty(Ae,"__esModule",{value:!0}),Ae})({});
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -10631,8 +10631,10 @@ function setupEnableIfListeners(wrapper, element, ctx) {
|
|
|
10631
10631
|
reevaluateEnableIf(wrapper, element, ctx);
|
|
10632
10632
|
});
|
|
10633
10633
|
observer.disconnect();
|
|
10634
|
+
ctx.state.enableIfObservers.delete(observer);
|
|
10634
10635
|
}
|
|
10635
10636
|
});
|
|
10637
|
+
ctx.state.enableIfObservers.add(observer);
|
|
10636
10638
|
observer.observe(formRoot, {
|
|
10637
10639
|
childList: true,
|
|
10638
10640
|
subtree: true
|
|
@@ -11030,7 +11032,8 @@ function createInstanceState(config) {
|
|
|
11030
11032
|
debounceTimer: null,
|
|
11031
11033
|
prefill: {},
|
|
11032
11034
|
syntheticElementIds: /* @__PURE__ */ new WeakMap(),
|
|
11033
|
-
syntheticElementIdCounter: 0
|
|
11035
|
+
syntheticElementIdCounter: 0,
|
|
11036
|
+
enableIfObservers: /* @__PURE__ */ new Set()
|
|
11034
11037
|
};
|
|
11035
11038
|
}
|
|
11036
11039
|
function generateInstanceId() {
|
|
@@ -11712,6 +11715,7 @@ var FormBuilderInstance = class {
|
|
|
11712
11715
|
console.error("Schema validation errors:", errors);
|
|
11713
11716
|
return;
|
|
11714
11717
|
}
|
|
11718
|
+
this.disconnectEnableIfObservers();
|
|
11715
11719
|
this.state.formRoot = root;
|
|
11716
11720
|
this.state.schema = schema;
|
|
11717
11721
|
this.state.externalActions = actions || null;
|
|
@@ -12149,6 +12153,7 @@ var FormBuilderInstance = class {
|
|
|
12149
12153
|
clearTimeout(this.state.debounceTimer);
|
|
12150
12154
|
this.state.debounceTimer = null;
|
|
12151
12155
|
}
|
|
12156
|
+
this.disconnectEnableIfObservers();
|
|
12152
12157
|
this.state.resourceIndex.clear();
|
|
12153
12158
|
if (this.state.formRoot) {
|
|
12154
12159
|
clear(this.state.formRoot);
|
|
@@ -12160,6 +12165,12 @@ var FormBuilderInstance = class {
|
|
|
12160
12165
|
(_a = globalThis.__formBuilderInstances) == null ? void 0 : _a.delete(this.instanceId);
|
|
12161
12166
|
}
|
|
12162
12167
|
}
|
|
12168
|
+
disconnectEnableIfObservers() {
|
|
12169
|
+
for (const observer of this.state.enableIfObservers) {
|
|
12170
|
+
observer.disconnect();
|
|
12171
|
+
}
|
|
12172
|
+
this.state.enableIfObservers.clear();
|
|
12173
|
+
}
|
|
12163
12174
|
};
|
|
12164
12175
|
|
|
12165
12176
|
// src/index.ts
|