var d=Object.defineProperty,K=Object.defineProperties;var O=Object.getOwnPropertyDescriptors;var f=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var b=(t,s,n)=>s in t?d(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n,h=(t,s)=>{for(var n in s||(s={}))_.call(s,n)&&b(t,n,s[n]);if(f)for(var n of f(s))x.call(s,n)&&b(t,n,s[n]);return t},k=(t,s)=>K(t,O(s));import{u as A,j,aZ as E}from"./main-634.js";function F(t,s={},n=[]){const y={form_fields:[]},i=Object.keys(s),r={form_fields:[]},p=[];i.forEach(e=>{const c=s[e].lg.map(o=>o.i);t.forEach(o=>{if(o.key===e){if(!n.includes(o.typ)){let a="";o.typ==="repeater"?a=`${o.adminLbl||o.lbl||o.key}_(Repeater)`:o.typ==="section"&&(a=`${o.adminLbl||o.lbl||o.key}_(Section)`),r[a]||(r[a]={flds:[],key:e}),r[a].flds=c}p.push(...c)}})});const u=Object.keys(r);return t.forEach(e=>{u.forEach(c=>{var m;const o=r[c].flds,a=r[c].key,$=((m=t.find(l=>l.key===a))==null?void 0:m.typ)||"";if(o&&o.includes(e.key)){y[c]||(y[c]=[]);const l=k(h({},e),{newKey:$==="section"?e.key:`${a}.${e.key}`});y[c].push(l)}}),!p.includes(e.key)&&!n.includes(e.typ)&&y.form_fields.push(e)}),y}function w({formFields:t,notAllowFieldType:s=[],shortCode:n=!1}){const y=A(E),i=F(t,y,s),r=Object.keys(i),p=e=>(e.charAt(0).toUpperCase()+e.slice(1)).replace(/_/g," "),u=e=>{const c=e.newKey?e.newKey:e.key;return n?`\${${c}}`:c};return r.map(e=>j.jsx("optgroup",{label:p(e),children:i[e].map(c=>j.jsx("option",{value:u(c),children:c.name},`ff-zhcrm-${c.key}`))},`fld-lbl-${e}`))}export{w as B};
