@arudovwen/form-builder-react 1.8.9 → 1.8.10

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.
@@ -1,4 +1,4 @@
1
- import { H as o, V as m } from "./index-BTXex7Qy.js";
1
+ import { H as o, V as m } from "./index-CwkZpEWq.js";
2
2
  export {
3
3
  o as FormBuilder,
4
4
  m as FormViewer
@@ -19,7 +19,7 @@
19
19
  "data": [
20
20
  { "name": "Document Name", "id": "documentMainId", ...restObject },
21
21
  ]
22
- }`})})]})})}),Hd=()=>a.jsx("blockquote",{className:"p-4 text-gray-700 bg-gray-100 rounded-md",children:a.jsxs("ul",{children:[a.jsxs("li",{className:"text-xs",children:["Method: GET ",a.jsx("br",{}),"URL format:"," ",a.jsx("code",{children:"https://example.com/validation/{documentId}"})]}),a.jsxs("li",{className:"text-xs",children:[a.jsx("span",{className:"block mb-1",children:" Response example format:"}),a.jsx("pre",{className:"p-2 bg-white rounded-md",children:a.jsxs("code",{children:["{ ",a.jsx("br",{}),'  "data": { ',a.jsx("br",{}),'    "status": true, ',a.jsx("br",{}),'    "isSigned": true ',a.jsx("br",{}),"  } ",a.jsx("br",{}),"}"]})})]})]})});function Gd({type:e="calendar",className:n}){return a.jsx(a.Fragment,{children:e==="calendar"?a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[a.jsx("path",{d:"M6.66406 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M13.3359 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M2.91406 7.57495H17.0807",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M17.5 7.08341V14.1667C17.5 16.6667 16.25 18.3334 13.3333 18.3334H6.66667C3.75 18.3334 2.5 16.6667 2.5 14.1667V7.08341C2.5 4.58341 3.75 2.91675 6.66667 2.91675H13.3333C16.25 2.91675 17.5 4.58341 17.5 7.08341Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M13.0762 11.4167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M13.0762 13.9167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M9.99803 11.4167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M9.99803 13.9167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M6.91209 11.4167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M6.91209 13.9167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[a.jsx("path",{d:"M10 6.66663V10.8333",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M10.0026 18.3333C5.9776 18.3333 2.71094 15.0667 2.71094 11.0417C2.71094 7.01667 5.9776 3.75 10.0026 3.75C14.0276 3.75 17.2943 7.01667 17.2943 11.0417",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M7.5 1.66663H12.5",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M12.4141 15.4167V14.4501C12.4141 13.2584 13.2641 12.7667 14.2974 13.3667L15.1307 13.8501L15.9641 14.3334C16.9974 14.9334 16.9974 15.9084 15.9641 16.5084L15.1307 16.9917L14.2974 17.4751C13.2641 18.0751 12.4141 17.5834 12.4141 16.3917V15.4167Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const vo=({value:e=null,onGetValue:n,readOnly:i=!1,dateFormat:o="dd/MM/yyyy",name:s,placeholder:t="Select date",minDate:l,maxDate:r,showYearDropdown:d})=>{const u=v=>{if(!v)return null;const p=new Date(v);return isNaN(p.getTime())?null:p},m=u(e),[c,b]=x.useState(m);x.useEffect(()=>{const v=u(e);(v&&c&&v.getTime()!==c.getTime()||!v&&c||v&&!c)&&b(v)},[e]),x.useEffect(()=>{n&&n(s,c)},[c,n,s]);const h=v=>{b(v)};return a.jsx("div",{className:"builder_date__picker",children:a.jsx(gr,{showIcon:!0,icon:a.jsx(Gd,{className:"react-datepicker__calendar-icon"}),showPopperArrow:!1,dateFormat:o,disabled:i,selected:c,onChange:h,className:"field-control",portalId:"root-portal",placeholderText:t,minDate:l,maxDate:r,showYearDropdown:d,scrollableYearDropdown:!0,yearDropdownItemNumber:40})})};function ea(e){return e.flatMap(n=>{var i;return(i=n==null?void 0:n.questionData)!=null?i:[]})}function ho({element:e,validationData:n,placeholder:i}){var c;const{register:o=()=>({}),setValue:s,isReadOnly:t,watch:l,getValues:r}=n||{},[d,u]=x.useState(()=>{const b=r==null?void 0:r(e.id);return Array.isArray(b)?b:[]}),m=x.useMemo(()=>d==null?void 0:d.map(b=>b.label).join(", "),[d]);return x.useEffect(()=>{o(e.id)},[e.id,o]),x.useEffect(()=>{if(!l)return;const b=l(h=>{const v=h[e.id];v!==void 0&&u(Array.isArray(v)?v:[])});return()=>{var h;return(h=b.unsubscribe)==null?void 0:h.call(b)}},[l,e.id]),a.jsx("div",{className:"custom-select",children:a.jsx(le.Listbox,{value:d||[],onChange:b=>{u(b),s==null||s(e.id,b)},multiple:!0,disabled:t,by:"value",children:a.jsxs("div",{className:"custom-select__wrapper",children:[a.jsxs(le.Listbox.Button,{className:"custom-select__control field-control",disabled:t,children:[a.jsx("span",{className:"custom-select__value",children:(d==null?void 0:d.length)>0?m:a.jsx("span",{className:"custom-select__placeholder",children:i!=null?i:" Select options"})}),a.jsx("span",{className:"custom-select__icon",children:a.jsx(te,{icon:"lucide:chevron-down"})})]}),a.jsx(le.Transition,{as:x.Fragment,leave:"custom-select__transition",children:a.jsx(le.Listbox.Options,{anchor:"bottom start",className:"custom-select__options",children:(c=e==null?void 0:e.options)==null?void 0:c.map((b,h)=>a.jsx(le.Listbox.Option,{value:b,className:({active:v})=>`custom-select__option ${v?"custom-select__option--active":""}`,children:({selected:v})=>a.jsxs("div",{className:"custom-select__option-row",children:[a.jsx("span",{className:`custom-select__option-label ${v?"custom-select__option--selected":""}`,children:b.label}),v&&a.jsx("span",{className:"custom-select__check",children:"✓"})]})},h))})})]})})})}const fo=["text","number","boolean"],na=["equals","not_equals","contains","not_contains"],Fd=["greater","less"];function Vd({register:e,setValue:n,trigger:i,watch:o,id:s}){const{formData:t}=x.useContext(Ie),l=o("visibilityDependentFields")||[],r=x.useMemo(()=>{var u;return(u=ea(t).filter(m=>m.id!==s))==null?void 0:u.map(m=>{const c=l.find(b=>b.id===m.id);return{id:m.id,value:m.id,label:m.inputLabel,sectionId:m.sectionId,fieldType:(c==null?void 0:c.fieldType)||"text",operator:(c==null?void 0:c.operator)||"equals",fieldValue:(c==null?void 0:c.fieldValue)!==void 0?c.fieldValue:""}})},[t,l,s]),d=(u,m,c)=>{const b=l==null?void 0:l.map((h,v)=>v===u?{...h,[m]:c}:h);n("visibilityDependentFields",b)};return a.jsxs("div",{className:"flex flex-col gap-4 w-full",children:[a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx("label",{className:"text-sm font-semibold text-slate-800",children:"Dependent Fields"}),a.jsx("p",{className:"text-xs text-slate-500 mb-1",children:"Choose which fields this element's visibility should depend on."}),a.jsx(ho,{element:{options:r,id:"visibilityDependentFields",value:o("visibilityDependentFields")},validationData:{register:e,setValue:n,trigger:i,watch:o}})]}),l.length>0&&a.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[a.jsxs("div",{className:"hidden sm:flex flex-wrap items-center gap-3 px-4 pt-2 pb-1",children:[a.jsx("div",{className:"flex-1 min-w-[120px]",children:a.jsx("span",{className:"block text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Field"})}),a.jsx("div",{className:"w-[110px]",children:a.jsx("span",{className:"block text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Type"})}),a.jsx("div",{className:"w-[140px]",children:a.jsx("span",{className:"block text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Operator"})}),a.jsx("div",{className:"flex-1 min-w-[140px]",children:a.jsx("span",{className:"block text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Value"})})]}),l==null?void 0:l.map((u,m)=>{var v,p,g,f;const c=ea(t).find(S=>S.id===u.id),b=["selectField","radio","checkbox","multiSelect","cascadeSelect"].includes(c==null?void 0:c.type),h=(c==null?void 0:c.options)||[];return a.jsxs("div",{className:"group relative flex flex-wrap items-center gap-2 p-2 bg-white/70 backdrop-blur-md border border-slate-200/80 rounded-lg shadow-[0_2px_10px_-4px_rgba(0,0,0,0.1)] hover:border-gray-300/60 transition-all duration-300 ease-out",children:[a.jsx("div",{className:"flex-1 min-w-[120px]",children:a.jsx("input",{type:"text",id:u.label,value:u.label,readOnly:!0,disabled:!0,className:"w-full px-3 py-2.5 bg-slate-100/50 border border-slate-200/80 rounded-lg text-sm text-slate-600 font-medium truncate cursor-not-allowed focus:outline-none"})}),a.jsx("div",{className:"w-[110px]",children:a.jsx("div",{className:"relative",children:a.jsxs(le.Listbox,{value:u.fieldType,onChange:S=>d(m,"fieldType",S),children:[a.jsxs(le.Listbox.Button,{className:"w-full flex items-center justify-between px-3 py-2 bg-white border border-slate-200/80 rounded-lg text-sm text-slate-700 font-medium hover:bg-slate-50 hover:border-slate-300 transition-colors focus:outline-none focus:ring-2 focus:ring-gray-500/20 focus:border-gray-500 shadow-sm",children:[a.jsx("span",{className:"block truncate capitalize",children:u.fieldType}),a.jsx(te,{icon:"lucide:chevron-down",iconClass:"w-4 h-4 text-slate-400"})]}),a.jsx(le.Transition,{as:x.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:a.jsx(le.Listbox.Options,{className:"absolute z-[9999] w-[var(--button-width)] min-w-[120px] mt-2 bg-white/95 backdrop-blur-xl border border-slate-200/80 rounded-lg shadow-lg max-h-60 overflow-auto focus:outline-none py-1",anchor:"bottom start",children:fo==null?void 0:fo.map(S=>a.jsx(le.Listbox.Option,{value:S,className:({active:y})=>`px-4 py-2 text-sm cursor-pointer capitalize transition-colors ${y?"bg-gray-50/80 text-gray-700 font-medium":"text-slate-700 hover:bg-slate-50"}`,children:S},S))})})]})})}),a.jsx("div",{className:"w-[140px]",children:a.jsx("div",{className:"relative",children:a.jsxs(le.Listbox,{value:u.operator,onChange:S=>d(m,"operator",S),children:[a.jsxs(le.Listbox.Button,{className:"w-full flex items-center justify-between px-3 py-2 bg-white border border-slate-200/80 rounded-lg text-sm text-slate-700 font-medium hover:bg-slate-50 hover:border-slate-300 transition-colors focus:outline-none focus:ring-2 focus:ring-gray-500/20 focus:border-gray-500 shadow-sm",children:[a.jsx("span",{className:"block truncate capitalize",children:u.operator.replace("_"," ")}),a.jsx(te,{icon:"lucide:chevron-down",iconClass:"w-4 h-4 text-slate-400"})]}),a.jsx(le.Transition,{as:x.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:a.jsx(le.Listbox.Options,{className:"absolute z-[9999] w-[var(--button-width)] min-w-[150px] mt-2 bg-white/95 backdrop-blur-xl border border-slate-200/80 rounded-lg shadow-lg max-h-60 overflow-auto focus:outline-none py-1",anchor:"bottom start",children:(v=u.fieldType==="number"?[...na,...Fd]:na)==null?void 0:v.map(S=>a.jsx(le.Listbox.Option,{value:S,className:({active:y})=>`px-4 py-2 text-sm cursor-pointer capitalize transition-colors ${y?"bg-gray-50/80 text-gray-700 font-medium":"text-slate-700 hover:bg-slate-50"}`,children:S.replace("_"," ")},S))})})]})})}),a.jsx("div",{className:"flex-1 min-w-[140px]",children:b&&h.length>0?a.jsx("div",{className:"relative",children:a.jsxs(le.Listbox,{value:(p=u.fieldValue)!=null?p:"",onChange:S=>d(m,"fieldValue",S),children:[a.jsxs(le.Listbox.Button,{className:"w-full flex items-center justify-between px-3 py-2 bg-white border border-slate-200/80 rounded-lg text-sm text-slate-700 font-medium hover:bg-slate-50 hover:border-slate-300 transition-colors focus:outline-none focus:ring-2 focus:ring-gray-500/20 focus:border-gray-500 shadow-sm",children:[a.jsx("span",{className:"block truncate pr-2",children:((g=h.find(S=>S.value===u.fieldValue))==null?void 0:g.label)||"Select value"}),a.jsx(te,{icon:"lucide:chevron-down",iconClass:"w-4 h-4 flex-shrink-0 text-slate-400"})]}),a.jsx(le.Transition,{as:x.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:a.jsx(le.Listbox.Options,{className:"absolute z-[9999] w-[var(--button-width)] min-w-[160px] mt-2 bg-white/95 backdrop-blur-xl border border-slate-200/80 rounded-lg max-h-60 overflow-auto focus:outline-none py-1",anchor:"bottom start",children:h.map((S,y)=>a.jsx(le.Listbox.Option,{value:S.value,className:({active:w})=>`px-4 py-2 text-sm cursor-pointer transition-colors ${w?"bg-gray-50/80 text-gray-700 font-medium":"text-slate-700 hover:bg-slate-50"}`,children:S.label},y))})})]})}):u.fieldType!=="boolean"?a.jsx("input",{type:u.fieldType,value:u.fieldValue||"",onChange:S=>d(m,"fieldValue",S.target.value),placeholder:"Enter value...",className:"w-full px-3 py-2 bg-white border border-slate-200/80 rounded-lg text-sm text-slate-700 font-medium focus:outline-none focus:ring-2 focus:ring-gray-500/20 focus:border-gray-500 transition-colors shadow-sm placeholder-slate-400"}):a.jsx("div",{className:"relative",children:a.jsxs(le.Listbox,{value:(f=u.fieldValue)!=null?f:"",onChange:S=>d(m,"fieldValue",S),children:[a.jsxs(le.Listbox.Button,{className:"w-full flex items-center justify-between px-3 py-2 bg-white border border-slate-200/80 rounded-lg text-sm text-slate-700 font-medium hover:bg-slate-50 hover:border-slate-300 transition-colors focus:outline-none focus:ring-2 focus:ring-gray-500/20 focus:border-gray-500 shadow-sm",children:[a.jsx("span",{className:"block truncate",children:u.fieldValue===!0?"True":u.fieldValue===!1?"False":"Select value"}),a.jsx(te,{icon:"lucide:chevron-down",iconClass:"w-4 h-4 text-slate-400"})]}),a.jsx(le.Transition,{as:x.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:a.jsxs(le.Listbox.Options,{className:"absolute z-[9999] w-[var(--button-width)] min-w-[150px] mt-2 bg-white/95 backdrop-blur-xl border border-slate-200/80 rounded-lg shadow-lg max-h-60 overflow-auto focus:outline-none py-1",anchor:"bottom start",children:[a.jsx(le.Listbox.Option,{value:!0,className:({active:S})=>`px-4 py-2 text-sm cursor-pointer transition-colors ${S?"bg-gray-50/80 text-gray-700 font-medium":"text-slate-700 hover:bg-slate-50"}`,children:"True"}),a.jsx(le.Listbox.Option,{value:!1,className:({active:S})=>`px-4 py-2 text-sm cursor-pointer transition-colors ${S?"bg-gray-50/80 text-gray-700 font-medium":"text-slate-700 hover:bg-slate-50"}`,children:"False"})]})})]})})})]},u.id)})]})]})}function ia(e){const n=[],i=/@\[([^\]]+)\]\(([^)]+)\)/g;let o=0,s;for(;(s=i.exec(e))!==null;){const l=e.slice(o,s.index);l&&n.push({type:"operator",value:l}),n.push({type:"field",id:s[2],display:s[1]}),o=s.index+s[0].length}const t=e.slice(o);return t&&n.push({type:"operator",value:t}),n}function zd(e){return e.map(n=>n.type==="field"?`@[${n.display}](${n.id})`:n.value).join("")}function Wd({value:e,onChange:n,fields:i,placeholder:o}){const[s,t]=x.useState(()=>ia(e)),[l,r]=x.useState(null),[d,u]=x.useState(!1),[m,c]=x.useState(""),[b,h]=x.useState(null),v=x.useRef(null),p=x.useRef(null),g=x.useRef(new Map);x.useEffect(()=>{const k=ia(e);t(k)},[]);const f=x.useCallback(k=>{n(zd(k))},[n]),S=(k,B)=>{const M=[...s];M[k]={type:"operator",value:B},t(M),f(M)},y=k=>{const B=s.filter((M,P)=>P!==k);t(B),f(B)},w=k=>{h(k),c(""),u(!0)},A=(k,B)=>{const M=B!==void 0?B:b!=null?b:s.length,P=[...s],K=P.slice(0,M),E=P.slice(M),_=[...K,{type:"field",id:k.id,display:k.display},...E],I=N(_);t(I),f(I),u(!1),h(null)};function N(k){const B=[];if(k.length===0)return[{type:"operator",value:""}];k[0].type==="field"&&B.push({type:"operator",value:""});for(let M=0;M<k.length;M++)B.push(k[M]),k[M].type==="field"&&(M+1>=k.length||k[M+1].type==="field")&&B.push({type:"operator",value:""});return B}const C=i.filter(k=>k.display.toLowerCase().includes(m.toLowerCase())),T=s.every(k=>k.type==="operator"&&k.value.trim()==="");return a.jsxs("div",{className:"relative",ref:p,children:[a.jsxs("div",{className:"field-control flex flex-wrap items-center gap-1 min-h-[44px] cursor-text",style:{padding:"6px 10px"},onClick:()=>{var B;const k=[...s].reverse().findIndex(M=>M.type==="operator");if(k!==-1){const M=s.length-1-k;(B=g.current.get(M))==null||B.focus()}},children:[T&&a.jsx("span",{className:"text-gray-400 text-sm pointer-events-none select-none",children:o||"Build your formula..."}),s.map((k,B)=>k.type==="field"?a.jsxs("span",{className:"inline-flex items-center gap-1 bg-blue-100 text-blue-800 text-sm px-2 py-0.5 rounded-full font-medium select-none",children:[k.display,a.jsx("button",{type:"button",onMouseDown:M=>{M.preventDefault(),y(B)},className:"text-blue-400 hover:text-blue-700 leading-none ml-0.5","aria-label":`Remove ${k.display}`,children:"×"})]},B):a.jsx("input",{ref:M=>{M?g.current.set(B,M):g.current.delete(B)},type:"text",value:k.value,onChange:M=>S(B,M.target.value),onFocus:()=>r(B),onBlur:()=>r(null),className:"border-none outline-none bg-transparent text-sm font-mono p-0 m-0",style:{width:`${Math.max(k.value.length*9+8,l===B?40:14)}px`,minWidth:"14px",maxWidth:"200px"},placeholder:"","aria-label":`Operator at position ${B}`},B)),a.jsx("button",{type:"button",onMouseDown:k=>{k.preventDefault(),w(s.length)},className:"inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 hover:bg-blue-50 px-1.5 py-0.5 rounded transition-colors",title:"Insert a field",children:a.jsx("span",{className:"text-base leading-none",children:"@"})})]}),!T&&a.jsxs("div",{className:"mt-2 text-xs bg-blue-50 text-blue-800 border border-blue-100 rounded px-2 py-1.5 font-mono break-words",children:[a.jsx("span",{className:"font-sans font-semibold text-blue-500 uppercase tracking-wide mr-1",children:"Preview:"}),s.map(k=>k.type==="field"?`[${k.display}]`:k.value).join("")]}),d&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-40",onMouseDown:()=>u(!1)}),a.jsxs("div",{ref:v,className:"absolute left-0 right-0 z-50 bg-white border border-gray-200 rounded-lg shadow-xl overflow-hidden",style:{top:"calc(100% + 4px)"},children:[a.jsx("div",{className:"p-2 border-b border-gray-100",children:a.jsx("input",{autoFocus:!0,type:"text",placeholder:"Search fields...",value:m,onChange:k=>c(k.target.value),className:"w-full text-sm px-2 py-1 border border-gray-200 rounded outline-none focus:border-blue-300",onKeyDown:k=>{k.key==="Escape"&&u(!1),k.key==="Enter"&&C.length>0&&A(C[0])}})}),a.jsxs("div",{className:"max-h-48 overflow-y-auto",children:[C.length===0&&a.jsx("p",{className:"text-xs text-gray-400 text-center py-3",children:"No matching fields"}),C.map(k=>a.jsxs("div",{onMouseDown:B=>{B.preventDefault(),A(k)},className:"px-3 py-2 text-sm cursor-pointer flex items-center justify-between hover:bg-blue-50 group",children:[a.jsx("span",{className:"font-medium text-gray-800",children:k.display}),a.jsxs("span",{className:"text-xs text-gray-400 font-mono group-hover:text-blue-400",children:[k.id.slice(0,8),"..."]})]},k.id))]})]})]}),i.length>0&&a.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:i.map(k=>a.jsxs("button",{type:"button",onMouseDown:B=>{B.preventDefault(),A(k,s.length)},className:"text-xs bg-gray-100 hover:bg-blue-50 hover:text-blue-700 border text-gray-600 px-2 py-0.5 rounded-full transition-colors",children:["+ ",k.display]},k.id))})]})}const $d=ne.object().shape({inputLabel:ne.string().nullable(),placeholder:ne.string().nullable(),description:ne.string().nullable(),isReadOnly:ne.boolean(),isDisabled:ne.boolean(),isRequired:ne.boolean(),requiredMessage:ne.string().nullable(),minLengthMessage:ne.string().nullable(),maxLengthMessage:ne.string().nullable(),maxLength:ne.number().transform((e,n)=>String(n).trim()===""?null:e).typeError("Expecting a number").nullable(),minLength:ne.number().transform((e,n)=>String(n).trim()===""?null:e).typeError("Expecting a number").nullable(),minChecked:ne.number().transform((e,n)=>String(n).trim()===""?null:e).typeError("Expecting a number").nullable(),requireAllChecked:ne.boolean(),inputType:ne.string().nullable(),maxAmountMessage:ne.string().nullable(),maxAmount:ne.string().nullable(),options:ne.array().of(ne.object().shape({label:ne.string().nullable(),value:ne.string().when("label",{is:e=>e&&e.length>0,then:e=>e.required("Value is required when label is present"),otherwise:e=>e.nullable()})})).when("inputType",{is:e=>["radio","checkbox"].includes(e),then:e=>e.required("Options are required for radio or checkbox inputs"),otherwise:e=>e.nullable()}),options1:ne.array().of(ne.object().shape({label:ne.string().nullable(),value:ne.string().when("label",{is:e=>e&&e.length>0,then:e=>e.required("Value is required when label is present"),otherwise:e=>e.nullable()})})).when("inputType",{is:e=>["radio","checkbox"].includes(e),then:e=>e.required("Options are required for radio or checkbox inputs"),otherwise:e=>e.nullable()}),prefix:ne.string().nullable(),url:ne.string().nullable(),method:ne.string().nullable(),denominators:ne.mixed().nullable(),responseType:ne.string().nullable(),minAmount:ne.string().nullable(),heading:ne.string().nullable(),minAmountMessage:ne.string().nullable(),columns:ne.number().nullable().max(4).min(2),value:ne.mixed().nullable(),customClass:ne.string().nullable(),elementClass:ne.string().nullable(),apiUrl:ne.string().nullable(),selectType:ne.string().default("list"),dateType:ne.string().default("basic"),validationUrl:ne.string(),signatureLink:ne.string(),minDate:ne.string().nullable(),maxDate:ne.string().nullable(),canHaveDateRange:ne.boolean(),allowYearPicker:ne.boolean(),isHidden:ne.boolean(),visibilityDependentFields:ne.array().nullable(),isMultiple:ne.boolean(),acceptedFiles:ne.array(),showState:ne.boolean(),formula:ne.string().nullable(),fetchExternalResults:ne.boolean(),externalApiUrl:ne.string().nullable()}),jd=[{title:"Configurations",key:"basic"},{title:"Validations",key:"validation"}],Ud=({isOpen:e,onClose:n,element:i})=>{var ee;const o=jd.filter(J=>!ci.includes(i.inputType)||J.key!=="validation"),{updateElement:s,formData:t}=x.useContext(Ie),[l,r]=x.useState("basic"),[d,u]=x.useState(!1),[m,c]=x.useState("manual"),b=((ee=t==null?void 0:t.flatMap(J=>(J==null?void 0:J.questionData)||[]))==null?void 0:ee.length)||0,h=x.useMemo(()=>(t==null?void 0:t.flatMap(J=>(J==null?void 0:J.questionData)||[]).filter(J=>{var O;return J.id!==(i==null?void 0:i.id)&&!["spacer","divider","section","grid"].includes((O=J.type)==null?void 0:O.toLowerCase())}).map(J=>({id:J.id,display:J.inputLabel||J.label||"Unnamed"})))||[],[b,i==null?void 0:i.id]),v=Ae("config"),{register:p,handleSubmit:g,control:f,setValue:S,watch:y,trigger:w,formState:{errors:A,isSubmitting:N,isValid:C},reset:T}=qe.useForm({resolver:uo($d),defaultValues:{...i,options:i.options||[]}}),k=y(),{fields:B,append:M,remove:P}=qe.useFieldArray({control:f,name:"options"}),{fields:K,append:E,remove:_}=qe.useFieldArray({control:f,name:"options1"}),{fields:I,append:H,remove:D}=qe.useFieldArray({control:f,name:"dataColumns"});x.useEffect(()=>{e||T()},[e,T]);const L=J=>{s(J,i.sectionId),n()},q={headers:{Authorization:`Bearer ${Ae("token")}`}},W=x.useCallback(async()=>{var J,O,$;if(!k.apiUrl||!/^https?:\/\//.test(k.apiUrl)){Ne.toast.info("Please provide a valid API URL");return}try{u(!0);const{status:G,data:F}=await an.get(k.apiUrl,q);if(G!==200||!F){Ne.toast.error("Unexpected response from server.");return}const V=F.data||F.record||F.result;if(!Array.isArray(V)){Ne.toast.error("Expected an array in response (data, record, or result).");return}((J=i.type)==null?void 0:J.toLowerCase())==="datagrid"?S("dataColumns",bo(V)):S("options",mo(V))}catch(G){const F=(($=(O=G==null?void 0:G.response)==null?void 0:O.data)==null?void 0:$.message)||(G==null?void 0:G.message)||"Unable to load options";Ne.toast.error(F)}finally{u(!1)}},[i.type,S,k.apiUrl]),Z=["manual","api","sheet"];function X(){m==="api"&&W()}const ie=()=>{var J,O;return a.jsxs("div",{className:"flex flex-col justify-start gap-y-1",children:[a.jsx("div",{className:"flex items-center mb-4 gap-x-5",children:Z==null?void 0:Z.map($=>a.jsxs("label",{className:"items-center text-base capitalize gap-x-3",children:[a.jsx("input",{type:"radio",name:"optionType",onChange:G=>c(G.target.value),value:$})," ",a.jsxs("span",{children:[$," options"]})]},$))}),m==="api"&&a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center gap-x-2",children:[a.jsxs("div",{className:"relative flex items-center w-full mb-2",children:[a.jsx(de,{watch:y,label:"Load Options from Api",name:"apiUrl",errors:A,register:p,className:"!w-full",placeholder:"https://example.com/options",isFloating:!0}),d&&a.jsx("div",{className:"absolute w-4 h-4 mt-1 border-2 border-blue-500 rounded-full border-t-transparent animate-spin right-3 top-1/2"})]}),a.jsx("button",{onClick:X,className:"px-3 py-1 text-xs text-white bg-gray-600 rounded",type:"button",children:"Load"})]}),a.jsx(_d,{})]}),m==="sheet"&&a.jsx("div",{className:"mb-4",children:a.jsx(Rs,{type:i.type,label:"Load options form sheet (csv, xlsx)",setValue:S,name:"options"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"mb-4 text-sm text-gray-500 font-semibold",children:((J=i==null?void 0:i.type)==null?void 0:J.toLowerCase())==="matrix"?"Rows Options":"Parent Options"}),B==null?void 0:B.map(($,G)=>a.jsxs("div",{className:"flex items-center mb-1 gap-x-4 last:mb-0",children:[a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:G===0?"Label":"",name:`options.${G}.label`,register:p,errors:A,element:i,placeholder:"Label",onChange:F=>{const U=F.target.value.toLowerCase().trim().replace(/[\s-]+/g,"_").replace(/[^a-z0-9_]/g,"");S(`options.${G}.value`,U,{shouldValidate:!0,shouldDirty:!0})}})}),a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:G===0?"Value":"",name:`options.${G}.value`,register:p,errors:A,element:i,placeholder:"Value"})}),a.jsx("button",{disabled:B.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>P(G),children:a.jsx(te,{icon:"iconamoon:sign-times-fill"})})]},$.id))," ",a.jsxs("div",{children:[" ",a.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>M({label:"",value:"",id:Le.v4()}),children:[a.jsx(te,{icon:"qlementine-icons:plus-16"})," Add Option"]})]})]}),["cascadeselect","matrix"].includes(i.type.toLowerCase())&&a.jsxs(a.Fragment,{children:[a.jsx("hr",{className:"my-5"}),a.jsxs("div",{children:[" ",a.jsx("h3",{className:"mb-4 text-sm text-gray-500 font-semibold",children:((O=i==null?void 0:i.type)==null?void 0:O.toLowerCase())==="matrix"?"Columns Options":"Child Options"}),K==null?void 0:K.map(($,G)=>a.jsxs("div",{className:"flex items-center mb-1 gap-x-4 last:mb-0",children:[a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:G===0?"Label":"",name:`options1.${G}.label`,register:p,errors:A,element:i,placeholder:"Label",onChange:F=>{const U=F.target.value.toLowerCase().trim().replace(/[\s-]+/g,"_").replace(/[^a-z0-9_]/g,"");S(`options1.${G}.value`,U,{shouldValidate:!0,shouldDirty:!0})}})}),a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:G===0?"Value":"",name:`options1.${G}.value`,register:p,errors:A,element:i,placeholder:"Value"})}),a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:G===0?"Key":"",name:`options1.${G}.key`,register:p,errors:A,element:i,placeholder:"Key"})}),a.jsx("button",{disabled:K.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>_(G),children:a.jsx(te,{icon:"iconamoon:sign-times-fill"})})]},$.id)),a.jsxs("div",{children:[" ",a.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>E({label:"",value:"",key:"",id:Le.v4()}),children:[a.jsx(te,{icon:"qlementine-icons:plus-16"})," Add Option"]})]})]})]})]})},ae=()=>a.jsxs("div",{className:"flex flex-col justify-start gap-y-1",children:[a.jsx("div",{className:"flex items-center mb-4 gap-x-5",children:Z==null?void 0:Z.map(J=>a.jsxs("label",{className:"items-center text-base capitalize gap-x-3",children:[a.jsx("input",{type:"radio",name:"optionType",onChange:O=>c(O.target.value),value:J,checked:J===m})," ",a.jsxs("span",{children:[J," options"]})]},J))}),m==="api"&&a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center gap-x-2",children:[a.jsxs("div",{className:"relative flex items-center w-full mb-2",children:[a.jsx(de,{watch:y,label:"Load Columns from Api",name:"apiUrl",errors:A,register:p,className:"!w-full",placeholder:"https://example.com/columns"}),d&&a.jsx("div",{className:"absolute w-4 h-4 mt-1 border-2 border-blue-500 rounded-full border-t-transparent animate-spin right-3 top-1/2"})]})," ",a.jsx("button",{onClick:X,className:"px-3 py-1 text-xs text-white bg-gray-600 rounded",type:"button",children:"Load"})]}),a.jsx(Od,{})]}),m==="sheet"&&a.jsx("div",{className:"mb-4",children:a.jsx(Rs,{type:i.type,label:"Load columns form sheet (csv, xlsx)",setValue:S,name:"dataColumns"})}),a.jsx("div",{className:"grid gap-y-3",children:I==null?void 0:I.map((J,O)=>{var $,G;return a.jsxs("div",{className:"flex flex-col gap-2 border-b border-gray-100 pb-2 mb-2 last:border-0 last:pb-0 last:mb-0",children:[a.jsxs("div",{className:"flex items-center gap-x-4",children:[a.jsx("div",{className:"min-w-[140px]",children:a.jsx(pn,{label:O===0?"Type":"",options:[{label:"Text",value:"text"},{label:"Number",value:"number"},{label:"Checkbox",value:"checkbox"},{label:"Select",value:"select"}],register:p,name:`dataColumns.${O}.type`,setValue:S,trigger:w,value:k.dataColumns[O].type})}),a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:O===0?"Display header":"",name:`dataColumns.${O}.headerName`,register:p,onChange:F=>{const U=F.target.value.toLowerCase().trim().replace(/[\s-]+/g,"_").replace(/[^a-z0-9_]/g,"");S(`dataColumns.${O}.field`,U,{shouldValidate:!0,shouldDirty:!0})},errors:A,element:i,placeholder:"header"})}),a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:O===0?"Field key":"",name:`dataColumns.${O}.field`,register:p,errors:A,element:i,placeholder:"fieldKey",disabled:!0})}),a.jsx("button",{disabled:I.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>D(O),children:a.jsx(te,{icon:"iconamoon:sign-times-fill"})})]}),((G=($=k.dataColumns)==null?void 0:$[O])==null?void 0:G.type)==="select"&&a.jsx("div",{className:"flex items-center gap-x-4",children:a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:"Options API URL",name:`dataColumns.${O}.optionsUrl`,register:p,errors:A,element:i,placeholder:"https://api.example.com/options"})})})]},J.id)})}),a.jsxs("div",{children:[" ",a.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>H({headerName:"",field:"",editable:!0,id:Le.v4(),type:"text",validate:!1}),children:[a.jsx(te,{icon:"qlementine-icons:plus-16"})," Add column"]})]})]}),R=x.useCallback(async()=>{const J=Ae("token"),{status:O,data:$}=await an.get(k.url,{headers:{Authorization:`Bearer ${J}`}});O===200&&S("options",($==null?void 0:$.data)||$)},[S,k.url]);x.useEffect(()=>{i.type==="document"&&k.url&&R()},[k.url,i.type,R]);const j=a.jsx("div",{className:"fixed inset-0 bg-gray-800/40 backdrop-blur-sm flex items-center justify-end z-[999] cursor-default",onMouseDown:J=>J.stopPropagation(),onPointerDown:J=>J.stopPropagation(),onDragStart:J=>{J.preventDefault(),J.stopPropagation()},children:a.jsxs("div",{className:"w-full lg:w-2/3 xl:w-2/5 bg-white h-screen shadow-xl relative flex flex-col items-center",children:[a.jsx("button",{className:"bg-white h-10 w-10 flex justify-center items-center absolute top-1 -left-12 rounded-lg hover:bg-gray-50",onClick:n,children:a.jsx(te,{icon:"tabler:x",iconClass:"text-xl"})}),a.jsx("div",{className:"w-full pt-4",children:a.jsx(yd,{tabs:o,setActiveTab:r,activeTab:l,className:"justify-start !text-left",btnClass:" !text-left"})}),a.jsxs("form",{onSubmit:g(L),className:"w-full flex-1 flex flex-col",autoComplete:"off",children:[a.jsxs("div",{className:"flex-1",children:[" ",a.jsxs("div",{className:" max-h-[83vh] overflow-y-auto flex-1",children:[l==="basic"&&a.jsxs("div",{className:"z-10 flex flex-col w-full gap-5 px-6",children:[co.includes(i.inputType)&&a.jsx(a.Fragment,{children:a.jsx(de,{watch:y,label:"Value",name:"value",register:p,errors:A,element:i})}),!co.includes(i.inputType)&&!ci.includes(i.inputType)&&a.jsxs(a.Fragment,{children:[a.jsx(de,{watch:y,label:"Label",name:"inputLabel",register:p,errors:A,element:i})," ",i.type.toLowerCase()==="cascadeselect"&&a.jsx(de,{watch:y,label:"Child Label",name:"childLabel",register:p,errors:A,element:i})]}),Md.includes(i.inputType)&&a.jsx(de,{watch:y,label:"Placeholder",name:"placeholder",register:p,errors:A,element:i}),Cd.includes(i.inputType)&&a.jsx(de,{watch:y,label:"Prefix",name:"prefix",register:p,errors:A,element:i}),Pd.includes(i.inputType)&&a.jsxs("div",{className:"grid gap-y-4",children:[a.jsx(Dd,{}),a.jsx(de,{watch:y,label:"Api Url",name:"url",register:p,errors:A,element:i}),a.jsx(pn,{label:"Api Method",options:[{label:"GET",value:"GET"},{label:"POST",value:"POST"}],register:p,name:"method",setValue:S,trigger:w,value:y("method")}),a.jsx(pn,{label:"Api Response type",options:[{label:"String",value:"string"},{label:"Object",value:"object"}],register:p,name:"responseType",setValue:S,trigger:w,value:y("responseType")})]}),Ld.includes(i.inputType)&&a.jsx(Id,{onChange:J=>{S("denominators",J)},value:y("denominators")}),!co.includes(i.inputType)&&!ci.includes(i.inputType)&&a.jsx(de,{watch:y,label:"Short Description",name:"description",register:p,errors:A,element:i}),i.type.toLowerCase()==="date"&&a.jsxs(a.Fragment,{children:[a.jsx(pn,{label:"Date Format",options:Ad,register:p,name:"dateFormat",setValue:S,trigger:w,value:y("dateFormat")}),a.jsx(de,{watch:y,label:"Allow Range",name:"canHaveDateRange",register:p,errors:A,element:i,type:"checkbox",value:k.canHaveDateRange}),(k==null?void 0:k.canHaveDateRange)&&a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(vo,{name:"minDate",value:k==null?void 0:k.minDate,onGetValue:S,placeholder:"Select min date"}),a.jsx(vo,{name:"maxDate",value:k==null?void 0:k.minDate,onGetValue:S,placeholder:"Select max date",minDate:k==null?void 0:k.minDate})]}),a.jsx(de,{watch:y,label:"Allow Year Picker",name:"allowYearPicker",register:p,errors:A,element:i,type:"checkbox",value:k.allowYearPicker})]}),i.type.toLowerCase()==="country"&&a.jsx(de,{watch:y,label:"Allow States",name:"showState",register:p,errors:A,element:i,type:"checkbox",value:k.showState}),i.type.toLowerCase()==="selectfield"&&a.jsx(pn,{label:"Select Type",options:[{label:"List",value:"list"},{label:"Combobox",value:"Combobox"}],register:p,name:"selectType",setValue:S,trigger:w,value:y("selectType")}),["multiselect","checkbox"].includes(i.type.toLowerCase())&&a.jsxs(a.Fragment,{children:[a.jsx(de,{watch:y,label:"Minimum Options Checked",name:"minChecked",register:p,errors:A,element:i,type:"number"}),a.jsx("div",{className:"w-[250px]",children:a.jsx(de,{watch:y,label:"Require All Checked",name:"requireAllChecked",register:p,errors:A,element:i,type:"checkbox",value:k.requireAllChecked})})]}),i.type.toLowerCase()==="grid"&&a.jsx(de,{watch:y,label:"Number of columns (max: 4)",name:"columns",register:p,errors:A,element:i,max:4,min:1}),i.type.toLowerCase()==="document"&&a.jsxs("div",{className:"grid gap-y-6",children:[a.jsxs("div",{className:"grid gap-y-1",children:[a.jsx(de,{watch:y,label:"Document Options Url",name:"url",register:p,errors:A,element:i})," ",a.jsx(Kd,{})]}),a.jsxs("div",{className:"grid gap-y-1",children:[a.jsx(de,{watch:y,label:"Document Validation Url",name:"validationUrl",register:p,errors:A,element:i}),a.jsx(Hd,{})]}),a.jsx("div",{className:"grid gap-y-1",children:a.jsx(de,{watch:y,label:"Signature Page Url",name:"signatureLink",register:p,errors:A,element:i})})]}),i.type.toLowerCase()==="datagrid"&&ae(),i.type.toLowerCase()==="file"&&a.jsxs(a.Fragment,{children:[a.jsx(de,{watch:y,label:"Allow Multiple Uploads",name:"isMultiple",register:p,errors:A,element:i,type:"checkbox",value:k.isMultiple}),a.jsx(ho,{element:{options:Bd,id:"acceptedFiles",value:k==null?void 0:k.acceptedFiles},validationData:{register:p,setValue:S,trigger:w,watch:y},placeholder:"Choose file types"})]}),Td.includes(i.inputType)&&ie(),a.jsxs("div",{children:[a.jsx("div",{className:"w-[150px] mb-4",children:a.jsx(de,{watch:y,label:"Toggle Visibility",name:"isHidden",register:p,errors:A,element:i,type:"checkbox",value:k.isHidden})})," ",k.isHidden&&a.jsx(Vd,{register:p,setValue:S,trigger:w,watch:y,id:i==null?void 0:i.id})]}),i.type.toLowerCase()==="calculatedfield"&&a.jsxs("div",{className:"grid gap-y-2 mb-4",children:[a.jsx("label",{className:"block text-sm font-medium text-[#344054] font-onest",children:"Formula"}),a.jsx(Wd,{value:y("formula")||"",onChange:J=>S("formula",J,{shouldValidate:!0,shouldDirty:!0}),fields:h,placeholder:"Build your formula..."})]}),i.type.toLowerCase()==="polling"&&a.jsxs("div",{className:"grid gap-y-4 mb-4 mt-2",children:[a.jsx(de,{watch:y,label:"Fetch results from external API",name:"fetchExternalResults",register:p,errors:A,element:i,type:"checkbox",value:k.fetchExternalResults}),k.fetchExternalResults&&a.jsx(de,{watch:y,label:"External API URL (returns options results)",name:"externalApiUrl",register:p,errors:A,element:i,placeholder:"https://api.example.com/poll/results"})]})]}),!ci.includes(i.type.toLowerCase())&&l==="validation"&&a.jsxs("div",{className:"z-10 flex flex-col w-full gap-5 px-6",children:[a.jsxs("div",{className:"flex items-center gap-x-6",children:[a.jsx("div",{className:"w-[150px]",children:a.jsx(de,{watch:y,label:"Required",name:"isRequired",register:p,errors:A,element:i,type:"checkbox",value:k.isRequired})})," ",a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:"Error message text",name:"requiredMessage",register:p,errors:A,element:i})})]}),kd.includes(i.inputType)&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-x-6",children:[a.jsx("div",{className:"w-[150px]",children:a.jsx(de,{watch:y,label:"Min Length",name:"minLength",register:p,errors:A,element:i,type:"number"})})," ",a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:"Error message text",name:"minLengthMessage",register:p,errors:A,element:i})})]}),a.jsxs("div",{className:"flex items-center gap-x-6",children:[a.jsx("div",{className:"w-[150px]",children:a.jsx(de,{watch:y,label:"Max Length",name:"maxLength",register:p,errors:A,element:i,type:"number"})})," ",a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:"Error message text",name:"maxLengthMessage",register:p,errors:A,element:i})})]})]}),Ed.includes(i.inputType)&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-x-6",children:[a.jsx("div",{className:"w-[150px]",children:a.jsx(de,{watch:y,label:"Min Amount",name:"minAmount",register:p,errors:A,element:i,type:"amount"})})," ",a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:"Error message text",name:"minAmountMessage",register:p,errors:A,element:i})})]}),a.jsxs("div",{className:"flex items-center gap-x-6",children:[a.jsx("div",{className:"w-[150px]",children:a.jsx(de,{watch:y,label:"Max Amount",name:"maxAmount",register:p,errors:A,element:i,type:"amount"})})," ",a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:"Error message text",name:"maxAmountMessage",register:p,errors:A,element:i})})]})]})]})]})]}),a.jsxs("div",{className:"sticky flex w-full gap-3 px-6 pt-8 pb-10 border-t",children:[a.jsx("button",{type:"button",onClick:n,className:"flex-1 px-4 py-2.5 bg-white border border-[#D0D5DD] rounded-lg shadow-xs font-semibold text-[#344054] font-onest editor_option__cancel",children:"Cancel"}),a.jsx("button",{type:"submit",disabled:!C||N,style:{background:(v==null?void 0:v.buttonColor)||"#333"},className:`flex-1 px-4 py-2.5 ${!C||N?"bg-[#F2F4F7]":"bg-[#2563EB]"} ${!C||N?"text-[#98A2B3]":"text-white"} rounded-lg shadow-xs font-semibold font-onest disabled:opacity-50 editor_option__save`,children:N?"Saving...":"Save"})]})]})]})});return document.body?vr.createPortal(j,document.body):j},po=x.memo(({state:e,element:n,children:i})=>{var c,b;const[o,s]=x.useState(!1),{removeElement:t,duplicateElement:l,updateElement:r,copyElement:d}=x.useContext(Ie),u=x.useMemo(()=>{var h;return(h=n==null?void 0:n.acceptedFiles)==null?void 0:h.map(v=>v.label).join(", ")},[n]),m=x.useCallback(()=>{t(n.id,n.sectionId)},[n.id,n.sectionId,t]);return a.jsxs("div",{className:"w-full min-w-0",children:[o&&a.jsx(Ud,{isOpen:o,onClose:()=>s(!1),element:n}),a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{children:[" ",n.inputLabel&&a.jsxs("label",{className:"text-sm font-medium input_label",children:[n.inputLabel," ",u&&a.jsxs("span",{className:"text-gray-400 text-xs",children:["(",u==null?void 0:u.toLowerCase(),")"]})]})]}),e==="edit"&&a.jsxs("span",{className:"flex items-center gap-x-3",children:[((c=n.type)==null?void 0:c.toLowerCase())!=="spacer"&&((b=n.type)==null?void 0:b.toLowerCase())!=="divider"&&a.jsxs("label",{className:"flex items-center gap-1 text-xs cursor-pointer text-gray-500 mr-2 hover:text-gray-700 select-none",children:[a.jsx("input",{type:"checkbox",checked:n.isRequired||!1,onChange:h=>r({...n,isRequired:h.target.checked},n.sectionId),className:"cursor-pointer"}),a.jsx("span",{className:"mt-0.5",children:"Required"})]}),a.jsx("button",{type:"button",className:"text-sm outline-none hover:opacity-80 py-1 text-gray-600",onClick:()=>{typeof l=="function"&&l(n==null?void 0:n.id,n.sectionId)},title:"Duplicate",children:a.jsx(te,{icon:"solar:copy-outline",iconClass:"text-base"})}),a.jsx("button",{type:"button",className:"text-sm outline-none hover:opacity-80 py-1 text-gray-600",onClick:()=>{typeof d=="function"&&d(n==null?void 0:n.id,n.sectionId)},title:"Copy to Clipboard",children:a.jsx(te,{icon:"lucide:clipboard-copy",iconClass:"text-base"})}),a.jsx("button",{type:"button",className:"text-sm outline-none hover:opacity-80 text-gray-600 py-1",onClick:()=>s(!0),title:"Edit",children:a.jsx(te,{icon:"circum:edit",iconClass:"text-base"})}),a.jsx("button",{type:"button",className:"text-sm outline-none hover:opacity-80 text-gray-600 py-1",onClick:m,title:"Remove",children:a.jsx(te,{icon:"iconamoon:trash",iconClass:"text-base"})})]})]}),i,n.description&&a.jsx("small",{className:"block text-gray-400 mt-1 text-xs",children:n.description})]})});po.displayName="ElementContainer";function qd({element:e,validationData:n}){const{register:i=()=>({}),setValue:o,watch:s}=n||{};let t;return s&&(t=s()[e.id]),x.useEffect(()=>{i(e.id)},[e.id,i]),a.jsx(vo,{name:e.id,value:t,onGetValue:o,readOnly:n==null?void 0:n.isReadOnly,dateFormat:(e==null?void 0:e.dateFormat)||"dd/MM/yyyy",minDate:e==null?void 0:e.minDate,maxDate:e==null?void 0:e.maxDate,showYearDropdown:e==null?void 0:e.allowYearPicker})}function go({element:e,validationData:n}){var o;const{register:i=()=>({})}=n||{};return a.jsx("div",{children:a.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"",type:(e==null?void 0:e.inputType)||"text",className:ue("field-control",e==null?void 0:e.customClass),...i(e==null?void 0:e.id),disabled:n==null?void 0:n.isReadOnly,inputMode:(e==null?void 0:e.inputMode)||void 0,"aria-invalid":!!((o=n==null?void 0:n.errors)!=null&&o[e==null?void 0:e.id]),pattern:(e==null?void 0:e.pattern)||void 0})})}const Yd=["jpg","jpeg","png","gif","bmp","webp","svg","image"],Jd=(e="")=>{var i;const n=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return Yd.includes(n)||e.startsWith("data:image/")?"image":n==="pdf"||e.startsWith("data:application/pdf")?"pdf":["doc","docx"].includes(n)?"word":["xls","xlsx","csv"].includes(n)?"excel":["ppt","pptx"].includes(n)?"powerpoint":"other"},Zd={pdf:"vscode-icons:file-type-pdf2",word:"vscode-icons:file-type-word",excel:"vscode-icons:file-type-excel",powerpoint:"vscode-icons:file-type-powerpoint2"};function oa({fileUrl:e,fileName:n,removeFile:i}){const[o,s]=x.useState(!1),[t,l]=x.useState("unknown"),[r,d]=x.useState(null);x.useEffect(()=>{e&&l(Jd(e))},[e]),x.useEffect(()=>{if(t==="pdf"&&(e!=null&&e.startsWith("data:")))try{const h=atob(e.split(",")[1]),v=new ArrayBuffer(h.length),p=new Uint8Array(v);for(let S=0;S<h.length;S++)p[S]=h.charCodeAt(S);const g=new Blob([v],{type:"application/pdf"}),f=URL.createObjectURL(g);return d(f),()=>URL.revokeObjectURL(f)}catch(h){console.error("Error creating blob URL:",h)}else d(null)},[e,t]);const u=()=>{t==="image"||t==="pdf"?s(!0):window.open(r||e,"_blank")},m=()=>s(!1),c=n||(e==null?void 0:e.split("/").pop())||"Unknown file";function b(h,v="download"){if(!h)return;if(h.startsWith("data:")){const g=document.createElement("a");g.href=h,g.download=v,document.body.appendChild(g),g.click(),document.body.removeChild(g);return}const p=document.createElement("a");p.href=h,p.setAttribute("download",v),document.body.appendChild(p),p.click(),document.body.removeChild(p)}return a.jsxs("div",{className:"mt-2 field-control !py-1 !bg-gray-50 !flex justify-between gap-x-8 items-center",children:[a.jsxs("div",{onClick:u,className:"!flex items-center rounded cursor-pointer gap-x-3",title:`Click to preview ${c}`,children:[t==="image"&&a.jsx("div",{className:"flex items-center justify-center ",children:a.jsx(te,{iconClass:"text-4xl",icon:"fluent-color:image-48"})}),t!=="image"&&a.jsx(te,{icon:Zd[t],iconClass:"text-4xl"}),a.jsx("span",{className:"text-sm font-semibold text-center text-gray-700 truncate max-w-[300px]",children:c})]}),a.jsxs("div",{className:"flex gap-x-1 items-center",children:[a.jsx("button",{type:"button",className:"p-2",onClick:()=>b(r||e,n),title:`Download ${c}`,children:a.jsx(te,{icon:"streamline-flex:download-tray-solid"})}),i&&a.jsx("button",{type:"button",className:"p-2 text-lg text-red-500",onClick:i,children:a.jsx(te,{icon:"lets-icons:trash-duotone"})})]}),o&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",onClick:m,children:a.jsxs("div",{className:"relative bg-white p-8 rounded-lg w-full max-w-[90vw] max-h-[90vh] overflow-auto",onClick:h=>h.stopPropagation(),children:[a.jsx("button",{onClick:m,className:"absolute text-2xl font-bold text-gray-700 top-2 right-2","aria-label":"Close preview",children:"×"}),t==="image"?a.jsx("img",{src:e,alt:c,className:"max-w-full max-h-[80vh] mx-auto object-contain",crossOrigin:"anonymous"}):t==="pdf"?a.jsx("iframe",{src:r||e,title:c,className:"w-full h-[80vh] rounded border"}):null]})})]})}const Xd=5*1024*1024;function Qd({onFileLoaded:e,disabled:n=!1,handleDeleteFile:i,multiple:o=!1,list:s=null,accept:t=[]}){const{uploadUrl:l,setApiActivityCount:r}=x.useContext(Ie),d=x.useRef(null),[u,m]=x.useState(s),[c,b]=x.useState(!1);x.useEffect(()=>{m(s)},[s]);const h=x.useMemo(()=>t==null?void 0:t.map(A=>A.value).join(", "),[t]),v=x.useMemo(()=>t==null?void 0:t.map(A=>A.label).join(", "),[t]),p=x.useCallback(async A=>{var T,k;const N=Ae("token"),C=((T=Ae("orgData"))==null?void 0:T.id)||Ae("organizationId");try{const{data:B}=await an.post(l,{...A,service:"FORM",organizationId:C||""},{headers:{Authorization:`Bearer ${N}`}});return(k=B==null?void 0:B.data)==null?void 0:k.url}catch(B){throw console.error("File upload error:",B),new Error("Failed to upload file to server")}},[l]),g=x.useCallback(A=>new Promise((N,C)=>{const T=new FileReader;T.onloadend=async()=>{try{const k=T.result.replace(/^data:.*;base64,/,""),B=l?await p({base64:k,ext:`.${A.name.split(".").pop()}`,fileName:A.name}):T.result;N({base64:B,type:A.type,name:A.name})}catch(k){C(k)}},T.onerror=()=>C(new Error("File read failed")),T.readAsDataURL(A)}),[l,p]),f=x.useCallback(A=>{var C;const N=h?(C=h.split(","))==null?void 0:C.map(T=>T.trim()):[];for(const T of A){if(T.size>Xd)return Ne.toast.error(`File "${T.name}" exceeds 5MB limit (${(T.size/1024/1024).toFixed(2)}MB)`),!1;if(N.length&&!N.some(k=>T.type===k||T.name.toLowerCase().endsWith(k.replace("*",""))))return Ne.toast.error(`File "${T.name}" is not an allowed type. Allowed: ${v||"any"}`),!1}return!0},[h,v]),S=x.useCallback(async A=>{const N=Array.from(A.target.files||[]);if(!(!N.length||c)){if(!f(N)){d.current&&(d.current.value="");return}try{b(!0),r==null||r(k=>k+1);const C=await Promise.all(N==null?void 0:N.map(g)),T=o&&u?[...u,...C]:C;m(T),e(T),Ne.toast.success(`Successfully uploaded ${N.length} file(s)`)}catch(C){console.error("Upload error:",C),Ne.toast.error("Failed to upload file(s). Please try again.")}finally{b(!1),r==null||r(C=>Math.max(0,C-1)),d.current&&(d.current.value="")}}},[c,f,g,e,o,u,r]),y=x.useCallback(A=>{c||(d.current&&(d.current.value=""),m(N=>{const C=A===void 0?null:(N==null?void 0:N.filter((T,k)=>k!==A))||null;return e(C),C}),i==null||i())},[i,e,c]),w=u&&u.length>0;return a.jsxs("div",{className:"flex flex-col items-start gap-2",children:[!n&&a.jsxs("div",{className:"!flex field-control !py-0 !px-0 relative",children:[a.jsx("input",{ref:d,type:"file",onChange:S,disabled:n||c,multiple:o,accept:h||"",className:`w-full text-sm text-gray-500 file:mr-4 flex-1 file:px-4 !py-1 !pl-1\r
22
+ }`})})]})})}),Hd=()=>a.jsx("blockquote",{className:"p-4 text-gray-700 bg-gray-100 rounded-md",children:a.jsxs("ul",{children:[a.jsxs("li",{className:"text-xs",children:["Method: GET ",a.jsx("br",{}),"URL format:"," ",a.jsx("code",{children:"https://example.com/validation/{documentId}"})]}),a.jsxs("li",{className:"text-xs",children:[a.jsx("span",{className:"block mb-1",children:" Response example format:"}),a.jsx("pre",{className:"p-2 bg-white rounded-md",children:a.jsxs("code",{children:["{ ",a.jsx("br",{}),'  "data": { ',a.jsx("br",{}),'    "status": true, ',a.jsx("br",{}),'    "isSigned": true ',a.jsx("br",{}),"  } ",a.jsx("br",{}),"}"]})})]})]})});function Gd({type:e="calendar",className:n}){return a.jsx(a.Fragment,{children:e==="calendar"?a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[a.jsx("path",{d:"M6.66406 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M13.3359 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M2.91406 7.57495H17.0807",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M17.5 7.08341V14.1667C17.5 16.6667 16.25 18.3334 13.3333 18.3334H6.66667C3.75 18.3334 2.5 16.6667 2.5 14.1667V7.08341C2.5 4.58341 3.75 2.91675 6.66667 2.91675H13.3333C16.25 2.91675 17.5 4.58341 17.5 7.08341Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M13.0762 11.4167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M13.0762 13.9167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M9.99803 11.4167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M9.99803 13.9167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M6.91209 11.4167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M6.91209 13.9167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[a.jsx("path",{d:"M10 6.66663V10.8333",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M10.0026 18.3333C5.9776 18.3333 2.71094 15.0667 2.71094 11.0417C2.71094 7.01667 5.9776 3.75 10.0026 3.75C14.0276 3.75 17.2943 7.01667 17.2943 11.0417",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M7.5 1.66663H12.5",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M12.4141 15.4167V14.4501C12.4141 13.2584 13.2641 12.7667 14.2974 13.3667L15.1307 13.8501L15.9641 14.3334C16.9974 14.9334 16.9974 15.9084 15.9641 16.5084L15.1307 16.9917L14.2974 17.4751C13.2641 18.0751 12.4141 17.5834 12.4141 16.3917V15.4167Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const vo=({value:e=null,onGetValue:n,readOnly:i=!1,dateFormat:o="dd/MM/yyyy",name:s,placeholder:t="Select date",minDate:l,maxDate:r,showYearDropdown:d})=>{const u=v=>{if(!v)return null;const p=new Date(v);return isNaN(p.getTime())?null:p},m=u(e),[c,b]=x.useState(m);x.useEffect(()=>{const v=u(e);(v&&c&&v.getTime()!==c.getTime()||!v&&c||v&&!c)&&b(v)},[e]),x.useEffect(()=>{n&&n(s,c)},[c,n,s]);const h=v=>{b(v)};return a.jsx("div",{className:"builder_date__picker",children:a.jsx(gr,{showIcon:!0,icon:a.jsx(Gd,{className:"react-datepicker__calendar-icon"}),showPopperArrow:!1,dateFormat:o,disabled:i,selected:c,onChange:h,className:"field-control",portalId:"root-portal",placeholderText:t,minDate:l,maxDate:r,showYearDropdown:d,scrollableYearDropdown:!0,yearDropdownItemNumber:40})})};function ea(e){return e.flatMap(n=>{var i;return(i=n==null?void 0:n.questionData)!=null?i:[]})}function ho({element:e,validationData:n,placeholder:i}){var c;const{register:o=()=>({}),setValue:s,isReadOnly:t,watch:l,getValues:r}=n||{},[d,u]=x.useState(()=>{const b=r==null?void 0:r(e.id);return Array.isArray(b)?b:[]}),m=x.useMemo(()=>d==null?void 0:d.map(b=>b.label).join(", "),[d]);return x.useEffect(()=>{o(e.id)},[e.id,o]),x.useEffect(()=>{if(!l)return;const b=l(h=>{const v=h[e.id];v!==void 0&&u(Array.isArray(v)?v:[])});return()=>{var h;return(h=b.unsubscribe)==null?void 0:h.call(b)}},[l,e.id]),a.jsx("div",{className:"custom-select",children:a.jsx(le.Listbox,{value:d||[],onChange:b=>{u(b),s==null||s(e.id,b)},multiple:!0,disabled:t,by:"value",children:a.jsxs("div",{className:"custom-select__wrapper",children:[a.jsxs(le.Listbox.Button,{className:"custom-select__control field-control",disabled:t,children:[a.jsx("span",{className:"custom-select__value",children:(d==null?void 0:d.length)>0?m:a.jsx("span",{className:"custom-select__placeholder",children:i!=null?i:" Select options"})}),a.jsx("span",{className:"custom-select__icon",children:a.jsx(te,{icon:"lucide:chevron-down"})})]}),a.jsx(le.Transition,{as:x.Fragment,leave:"custom-select__transition",children:a.jsx(le.Listbox.Options,{anchor:"bottom start",className:"custom-select__options",children:(c=e==null?void 0:e.options)==null?void 0:c.map((b,h)=>a.jsx(le.Listbox.Option,{value:b,className:({active:v})=>`custom-select__option ${v?"custom-select__option--active":""}`,children:({selected:v})=>a.jsxs("div",{className:"custom-select__option-row",children:[a.jsx("span",{className:`custom-select__option-label ${v?"custom-select__option--selected":""}`,children:b.label}),v&&a.jsx("span",{className:"custom-select__check",children:"✓"})]})},h))})})]})})})}const fo=["text","number","boolean"],na=["equals","not_equals","contains","not_contains"],Fd=["greater","less"];function Vd({register:e,setValue:n,trigger:i,watch:o,id:s}){const{formData:t}=x.useContext(Ie),l=o("visibilityDependentFields")||[],r=x.useMemo(()=>{var u;return(u=ea(t).filter(m=>m.id!==s))==null?void 0:u.map(m=>{const c=l.find(b=>b.id===m.id);return{id:m.id,value:m.id,label:m.inputLabel,sectionId:m.sectionId,fieldType:(c==null?void 0:c.fieldType)||"text",operator:(c==null?void 0:c.operator)||"equals",fieldValue:(c==null?void 0:c.fieldValue)!==void 0?c.fieldValue:""}})},[t,l,s]),d=(u,m,c)=>{const b=l==null?void 0:l.map((h,v)=>v===u?{...h,[m]:c}:h);n("visibilityDependentFields",b)};return a.jsxs("div",{className:"flex flex-col gap-4 w-full",children:[a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx("label",{className:"text-sm font-semibold text-slate-800",children:"Dependent Fields"}),a.jsx("p",{className:"text-xs text-slate-500 mb-1",children:"Choose which fields this element's visibility should depend on."}),a.jsx(ho,{element:{options:r,id:"visibilityDependentFields",value:o("visibilityDependentFields")},validationData:{register:e,setValue:n,trigger:i,watch:o}})]}),l.length>0&&a.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[a.jsxs("div",{className:"hidden sm:flex flex-wrap items-center gap-3 px-4 pt-2 pb-1",children:[a.jsx("div",{className:"flex-1 min-w-[120px]",children:a.jsx("span",{className:"block text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Field"})}),a.jsx("div",{className:"w-[110px]",children:a.jsx("span",{className:"block text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Type"})}),a.jsx("div",{className:"w-[140px]",children:a.jsx("span",{className:"block text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Operator"})}),a.jsx("div",{className:"flex-1 min-w-[140px]",children:a.jsx("span",{className:"block text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Value"})})]}),l==null?void 0:l.map((u,m)=>{var v,p,g,f;const c=ea(t).find(S=>S.id===u.id),b=["selectField","radio","checkbox","multiSelect","cascadeSelect"].includes(c==null?void 0:c.type),h=(c==null?void 0:c.options)||[];return a.jsxs("div",{className:"group relative flex flex-wrap items-center gap-2 p-2 bg-white/70 backdrop-blur-md border border-slate-200/80 rounded-lg shadow-[0_2px_10px_-4px_rgba(0,0,0,0.1)] hover:border-gray-300/60 transition-all duration-300 ease-out",children:[a.jsx("div",{className:"flex-1 min-w-[120px]",children:a.jsx("input",{type:"text",id:u.label,value:u.label,readOnly:!0,disabled:!0,className:"w-full px-3 py-2.5 bg-slate-100/50 border border-slate-200/80 rounded-lg text-sm text-slate-600 font-medium truncate cursor-not-allowed focus:outline-none"})}),a.jsx("div",{className:"w-[110px]",children:a.jsx("div",{className:"relative",children:a.jsxs(le.Listbox,{value:u.fieldType,onChange:S=>d(m,"fieldType",S),children:[a.jsxs(le.Listbox.Button,{className:"w-full flex items-center justify-between px-3 py-2 bg-white border border-slate-200/80 rounded-lg text-sm text-slate-700 font-medium hover:bg-slate-50 hover:border-slate-300 transition-colors focus:outline-none focus:ring-2 focus:ring-gray-500/20 focus:border-gray-500 shadow-sm",children:[a.jsx("span",{className:"block truncate capitalize",children:u.fieldType}),a.jsx(te,{icon:"lucide:chevron-down",iconClass:"w-4 h-4 text-slate-400"})]}),a.jsx(le.Transition,{as:x.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:a.jsx(le.Listbox.Options,{className:"absolute z-[9999] w-[var(--button-width)] min-w-[120px] mt-2 bg-white/95 backdrop-blur-xl border border-slate-200/80 rounded-lg shadow-lg max-h-60 overflow-auto focus:outline-none py-1",anchor:"bottom start",children:fo==null?void 0:fo.map(S=>a.jsx(le.Listbox.Option,{value:S,className:({active:y})=>`px-4 py-2 text-sm cursor-pointer capitalize transition-colors ${y?"bg-gray-50/80 text-gray-700 font-medium":"text-slate-700 hover:bg-slate-50"}`,children:S},S))})})]})})}),a.jsx("div",{className:"w-[140px]",children:a.jsx("div",{className:"relative",children:a.jsxs(le.Listbox,{value:u.operator,onChange:S=>d(m,"operator",S),children:[a.jsxs(le.Listbox.Button,{className:"w-full flex items-center justify-between px-3 py-2 bg-white border border-slate-200/80 rounded-lg text-sm text-slate-700 font-medium hover:bg-slate-50 hover:border-slate-300 transition-colors focus:outline-none focus:ring-2 focus:ring-gray-500/20 focus:border-gray-500 shadow-sm",children:[a.jsx("span",{className:"block truncate capitalize",children:u.operator.replace("_"," ")}),a.jsx(te,{icon:"lucide:chevron-down",iconClass:"w-4 h-4 text-slate-400"})]}),a.jsx(le.Transition,{as:x.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:a.jsx(le.Listbox.Options,{className:"absolute z-[9999] w-[var(--button-width)] min-w-[150px] mt-2 bg-white/95 backdrop-blur-xl border border-slate-200/80 rounded-lg shadow-lg max-h-60 overflow-auto focus:outline-none py-1",anchor:"bottom start",children:(v=u.fieldType==="number"?[...na,...Fd]:na)==null?void 0:v.map(S=>a.jsx(le.Listbox.Option,{value:S,className:({active:y})=>`px-4 py-2 text-sm cursor-pointer capitalize transition-colors ${y?"bg-gray-50/80 text-gray-700 font-medium":"text-slate-700 hover:bg-slate-50"}`,children:S.replace("_"," ")},S))})})]})})}),a.jsx("div",{className:"flex-1 min-w-[140px]",children:b&&h.length>0?a.jsx("div",{className:"relative",children:a.jsxs(le.Listbox,{value:(p=u.fieldValue)!=null?p:"",onChange:S=>d(m,"fieldValue",S),children:[a.jsxs(le.Listbox.Button,{className:"w-full flex items-center justify-between px-3 py-2 bg-white border border-slate-200/80 rounded-lg text-sm text-slate-700 font-medium hover:bg-slate-50 hover:border-slate-300 transition-colors focus:outline-none focus:ring-2 focus:ring-gray-500/20 focus:border-gray-500 shadow-sm",children:[a.jsx("span",{className:"block truncate pr-2",children:((g=h.find(S=>S.value===u.fieldValue))==null?void 0:g.label)||"Select value"}),a.jsx(te,{icon:"lucide:chevron-down",iconClass:"w-4 h-4 flex-shrink-0 text-slate-400"})]}),a.jsx(le.Transition,{as:x.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:a.jsx(le.Listbox.Options,{className:"absolute z-[9999] w-[var(--button-width)] min-w-[160px] mt-2 bg-white/95 backdrop-blur-xl border border-slate-200/80 rounded-lg max-h-60 overflow-auto focus:outline-none py-1",anchor:"bottom start",children:h.map((S,y)=>a.jsx(le.Listbox.Option,{value:S.value,className:({active:w})=>`px-4 py-2 text-sm cursor-pointer transition-colors ${w?"bg-gray-50/80 text-gray-700 font-medium":"text-slate-700 hover:bg-slate-50"}`,children:S.label},y))})})]})}):u.fieldType!=="boolean"?a.jsx("input",{type:u.fieldType,value:u.fieldValue||"",onChange:S=>d(m,"fieldValue",S.target.value),placeholder:"Enter value...",className:"w-full px-3 py-2 bg-white border border-slate-200/80 rounded-lg text-sm text-slate-700 font-medium focus:outline-none focus:ring-2 focus:ring-gray-500/20 focus:border-gray-500 transition-colors shadow-sm placeholder-slate-400"}):a.jsx("div",{className:"relative",children:a.jsxs(le.Listbox,{value:(f=u.fieldValue)!=null?f:"",onChange:S=>d(m,"fieldValue",S),children:[a.jsxs(le.Listbox.Button,{className:"w-full flex items-center justify-between px-3 py-2 bg-white border border-slate-200/80 rounded-lg text-sm text-slate-700 font-medium hover:bg-slate-50 hover:border-slate-300 transition-colors focus:outline-none focus:ring-2 focus:ring-gray-500/20 focus:border-gray-500 shadow-sm",children:[a.jsx("span",{className:"block truncate",children:u.fieldValue===!0?"True":u.fieldValue===!1?"False":"Select value"}),a.jsx(te,{icon:"lucide:chevron-down",iconClass:"w-4 h-4 text-slate-400"})]}),a.jsx(le.Transition,{as:x.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:a.jsxs(le.Listbox.Options,{className:"absolute z-[9999] w-[var(--button-width)] min-w-[150px] mt-2 bg-white/95 backdrop-blur-xl border border-slate-200/80 rounded-lg shadow-lg max-h-60 overflow-auto focus:outline-none py-1",anchor:"bottom start",children:[a.jsx(le.Listbox.Option,{value:!0,className:({active:S})=>`px-4 py-2 text-sm cursor-pointer transition-colors ${S?"bg-gray-50/80 text-gray-700 font-medium":"text-slate-700 hover:bg-slate-50"}`,children:"True"}),a.jsx(le.Listbox.Option,{value:!1,className:({active:S})=>`px-4 py-2 text-sm cursor-pointer transition-colors ${S?"bg-gray-50/80 text-gray-700 font-medium":"text-slate-700 hover:bg-slate-50"}`,children:"False"})]})})]})})})]},u.id)})]})]})}function ia(e){const n=[],i=/@\[([^\]]+)\]\(([^)]+)\)/g;let o=0,s;for(;(s=i.exec(e))!==null;){const l=e.slice(o,s.index);l&&n.push({type:"operator",value:l}),n.push({type:"field",id:s[2],display:s[1]}),o=s.index+s[0].length}const t=e.slice(o);return t&&n.push({type:"operator",value:t}),n}function zd(e){return e.map(n=>n.type==="field"?`@[${n.display}](${n.id})`:n.value).join("")}function Wd({value:e,onChange:n,fields:i,placeholder:o}){const[s,t]=x.useState(()=>ia(e)),[l,r]=x.useState(null),[d,u]=x.useState(!1),[m,c]=x.useState(""),[b,h]=x.useState(null),v=x.useRef(null),p=x.useRef(null),g=x.useRef(new Map);x.useEffect(()=>{const k=ia(e);t(k)},[]);const f=x.useCallback(k=>{n(zd(k))},[n]),S=(k,B)=>{const M=[...s];M[k]={type:"operator",value:B},t(M),f(M)},y=k=>{const B=s.filter((M,P)=>P!==k);t(B),f(B)},w=k=>{h(k),c(""),u(!0)},A=(k,B)=>{const M=B!==void 0?B:b!=null?b:s.length,P=[...s],K=P.slice(0,M),E=P.slice(M),_=[...K,{type:"field",id:k.id,display:k.display},...E],I=N(_);t(I),f(I),u(!1),h(null)};function N(k){const B=[];if(k.length===0)return[{type:"operator",value:""}];k[0].type==="field"&&B.push({type:"operator",value:""});for(let M=0;M<k.length;M++)B.push(k[M]),k[M].type==="field"&&(M+1>=k.length||k[M+1].type==="field")&&B.push({type:"operator",value:""});return B}const C=i.filter(k=>k.display.toLowerCase().includes(m.toLowerCase())),T=s.every(k=>k.type==="operator"&&k.value.trim()==="");return a.jsxs("div",{className:"relative",ref:p,children:[a.jsxs("div",{className:"field-control flex flex-wrap items-center gap-1 min-h-[44px] cursor-text",style:{padding:"6px 10px"},onClick:()=>{var B;const k=[...s].reverse().findIndex(M=>M.type==="operator");if(k!==-1){const M=s.length-1-k;(B=g.current.get(M))==null||B.focus()}},children:[T&&a.jsx("span",{className:"text-gray-400 text-sm pointer-events-none select-none",children:o||"Build your formula..."}),s.map((k,B)=>k.type==="field"?a.jsxs("span",{className:"inline-flex items-center gap-1 bg-blue-100 text-blue-800 text-sm px-2 py-0.5 rounded-full font-medium select-none",children:[k.display,a.jsx("button",{type:"button",onMouseDown:M=>{M.preventDefault(),y(B)},className:"text-blue-400 hover:text-blue-700 leading-none ml-0.5","aria-label":`Remove ${k.display}`,children:"×"})]},B):a.jsx("input",{ref:M=>{M?g.current.set(B,M):g.current.delete(B)},type:"text",value:k.value,onChange:M=>S(B,M.target.value),onFocus:()=>r(B),onBlur:()=>r(null),className:"border-none outline-none bg-transparent text-sm font-mono p-0 m-0",style:{width:`${Math.max(k.value.length*9+8,l===B?40:14)}px`,minWidth:"14px",maxWidth:"200px"},placeholder:"","aria-label":`Operator at position ${B}`},B)),a.jsx("button",{type:"button",onMouseDown:k=>{k.preventDefault(),w(s.length)},className:"inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 hover:bg-blue-50 px-1.5 py-0.5 rounded transition-colors",title:"Insert a field",children:a.jsx("span",{className:"text-base leading-none",children:"@"})})]}),!T&&a.jsxs("div",{className:"mt-2 text-xs bg-blue-50 text-blue-800 border border-blue-100 rounded px-2 py-1.5 font-mono break-words",children:[a.jsx("span",{className:"font-sans font-semibold text-blue-500 uppercase tracking-wide mr-1",children:"Preview:"}),s.map(k=>k.type==="field"?`[${k.display}]`:k.value).join("")]}),d&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-40",onMouseDown:()=>u(!1)}),a.jsxs("div",{ref:v,className:"absolute left-0 right-0 z-50 bg-white border border-gray-200 rounded-lg shadow-xl overflow-hidden",style:{top:"calc(100% + 4px)"},children:[a.jsx("div",{className:"p-2 border-b border-gray-100",children:a.jsx("input",{autoFocus:!0,type:"text",placeholder:"Search fields...",value:m,onChange:k=>c(k.target.value),className:"w-full text-sm px-2 py-1 border border-gray-200 rounded outline-none focus:border-blue-300",onKeyDown:k=>{k.key==="Escape"&&u(!1),k.key==="Enter"&&C.length>0&&A(C[0])}})}),a.jsxs("div",{className:"max-h-48 overflow-y-auto",children:[C.length===0&&a.jsx("p",{className:"text-xs text-gray-400 text-center py-3",children:"No matching fields"}),C.map(k=>a.jsxs("div",{onMouseDown:B=>{B.preventDefault(),A(k)},className:"px-3 py-2 text-sm cursor-pointer flex items-center justify-between hover:bg-blue-50 group",children:[a.jsx("span",{className:"font-medium text-gray-800",children:k.display}),a.jsxs("span",{className:"text-xs text-gray-400 font-mono group-hover:text-blue-400",children:[k.id.slice(0,8),"..."]})]},k.id))]})]})]}),i.length>0&&a.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:i.map(k=>a.jsxs("button",{type:"button",onMouseDown:B=>{B.preventDefault(),A(k,s.length)},className:"text-xs bg-gray-100 hover:bg-blue-50 hover:text-blue-700 border text-gray-600 px-2 py-0.5 rounded-full transition-colors",children:["+ ",k.display]},k.id))})]})}const $d=ne.object().shape({inputLabel:ne.string().nullable(),placeholder:ne.string().nullable(),description:ne.string().nullable(),isReadOnly:ne.boolean(),isDisabled:ne.boolean(),isRequired:ne.boolean(),requiredMessage:ne.string().nullable(),minLengthMessage:ne.string().nullable(),maxLengthMessage:ne.string().nullable(),maxLength:ne.number().transform((e,n)=>String(n).trim()===""?null:e).typeError("Expecting a number").nullable(),minLength:ne.number().transform((e,n)=>String(n).trim()===""?null:e).typeError("Expecting a number").nullable(),minChecked:ne.number().transform((e,n)=>String(n).trim()===""?null:e).typeError("Expecting a number").nullable(),requireAllChecked:ne.boolean(),inputType:ne.string().nullable(),maxAmountMessage:ne.string().nullable(),maxAmount:ne.string().nullable(),options:ne.array().of(ne.object().shape({label:ne.string().nullable(),value:ne.string().when("label",{is:e=>e&&e.length>0,then:e=>e.required("Value is required when label is present"),otherwise:e=>e.nullable()})})).when("inputType",{is:e=>["radio","checkbox"].includes(e),then:e=>e.required("Options are required for radio or checkbox inputs"),otherwise:e=>e.nullable()}),options1:ne.array().of(ne.object().shape({label:ne.string().nullable(),value:ne.string().when("label",{is:e=>e&&e.length>0,then:e=>e.required("Value is required when label is present"),otherwise:e=>e.nullable()})})).when("inputType",{is:e=>["radio","checkbox"].includes(e),then:e=>e.required("Options are required for radio or checkbox inputs"),otherwise:e=>e.nullable()}),prefix:ne.string().nullable(),url:ne.string().nullable(),method:ne.string().nullable(),denominators:ne.mixed().nullable(),responseType:ne.string().nullable(),minAmount:ne.string().nullable(),heading:ne.string().nullable(),minAmountMessage:ne.string().nullable(),columns:ne.number().nullable().max(4).min(2),value:ne.mixed().nullable(),customClass:ne.string().nullable(),elementClass:ne.string().nullable(),apiUrl:ne.string().nullable(),selectType:ne.string().default("list"),dateType:ne.string().default("basic"),validationUrl:ne.string(),signatureLink:ne.string(),minDate:ne.string().nullable(),maxDate:ne.string().nullable(),canHaveDateRange:ne.boolean(),allowYearPicker:ne.boolean(),isHidden:ne.boolean(),visibilityDependentFields:ne.array().nullable(),isMultiple:ne.boolean(),acceptedFiles:ne.array(),showState:ne.boolean(),formula:ne.string().nullable(),fetchExternalResults:ne.boolean(),externalApiUrl:ne.string().nullable()}),jd=[{title:"Configurations",key:"basic"},{title:"Validations",key:"validation"}],Ud=({isOpen:e,onClose:n,element:i})=>{var ee;const o=jd.filter(J=>!ci.includes(i.inputType)||J.key!=="validation"),{updateElement:s,formData:t}=x.useContext(Ie),[l,r]=x.useState("basic"),[d,u]=x.useState(!1),[m,c]=x.useState("manual"),b=((ee=t==null?void 0:t.flatMap(J=>(J==null?void 0:J.questionData)||[]))==null?void 0:ee.length)||0,h=x.useMemo(()=>(t==null?void 0:t.flatMap(J=>(J==null?void 0:J.questionData)||[]).filter(J=>{var O;return J.id!==(i==null?void 0:i.id)&&!["spacer","divider","section","grid"].includes((O=J.type)==null?void 0:O.toLowerCase())}).map(J=>({id:J.id,display:J.inputLabel||J.label||"Unnamed"})))||[],[b,i==null?void 0:i.id]),v=Ae("config"),{register:p,handleSubmit:g,control:f,setValue:S,watch:y,trigger:w,formState:{errors:A,isSubmitting:N,isValid:C},reset:T}=qe.useForm({resolver:uo($d),defaultValues:{...i,options:i.options||[]}}),k=y(),{fields:B,append:M,remove:P}=qe.useFieldArray({control:f,name:"options"}),{fields:K,append:E,remove:_}=qe.useFieldArray({control:f,name:"options1"}),{fields:I,append:H,remove:D}=qe.useFieldArray({control:f,name:"dataColumns"});x.useEffect(()=>{e||T()},[e,T]);const L=J=>{s(J,i.sectionId),n()},q={headers:{Authorization:`Bearer ${Ae("token")}`}},W=x.useCallback(async()=>{var J,O,$;if(!k.apiUrl||!/^https?:\/\//.test(k.apiUrl)){Ne.toast.info("Please provide a valid API URL");return}try{u(!0);const{status:G,data:F}=await an.get(k.apiUrl,q);if(G!==200||!F){Ne.toast.error("Unexpected response from server.");return}const V=F.data||F.record||F.result;if(!Array.isArray(V)){Ne.toast.error("Expected an array in response (data, record, or result).");return}((J=i.type)==null?void 0:J.toLowerCase())==="datagrid"?S("dataColumns",bo(V)):S("options",mo(V))}catch(G){const F=(($=(O=G==null?void 0:G.response)==null?void 0:O.data)==null?void 0:$.message)||(G==null?void 0:G.message)||"Unable to load options";Ne.toast.error(F)}finally{u(!1)}},[i.type,S,k.apiUrl]),Z=["manual","api","sheet"];function X(){m==="api"&&W()}const ie=()=>{var J,O;return a.jsxs("div",{className:"flex flex-col justify-start gap-y-1",children:[a.jsx("div",{className:"flex items-center mb-4 gap-x-5",children:Z==null?void 0:Z.map($=>a.jsxs("label",{className:"items-center text-base capitalize gap-x-3",children:[a.jsx("input",{type:"radio",name:"optionType",onChange:G=>c(G.target.value),value:$})," ",a.jsxs("span",{children:[$," options"]})]},$))}),m==="api"&&a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center gap-x-2",children:[a.jsxs("div",{className:"relative flex items-center w-full mb-2",children:[a.jsx(de,{watch:y,label:"Load Options from Api",name:"apiUrl",errors:A,register:p,className:"!w-full",placeholder:"https://example.com/options",isFloating:!0}),d&&a.jsx("div",{className:"absolute w-4 h-4 mt-1 border-2 border-blue-500 rounded-full border-t-transparent animate-spin right-3 top-1/2"})]}),a.jsx("button",{onClick:X,className:"px-3 py-1 text-xs text-white bg-gray-600 rounded",type:"button",children:"Load"})]}),a.jsx(_d,{})]}),m==="sheet"&&a.jsx("div",{className:"mb-4",children:a.jsx(Rs,{type:i.type,label:"Load options form sheet (csv, xlsx)",setValue:S,name:"options"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"mb-4 text-sm text-gray-500 font-semibold",children:((J=i==null?void 0:i.type)==null?void 0:J.toLowerCase())==="matrix"?"Rows Options":"Parent Options"}),B==null?void 0:B.map(($,G)=>a.jsxs("div",{className:"flex items-center mb-1 gap-x-4 last:mb-0",children:[a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:G===0?"Label":"",name:`options.${G}.label`,register:p,errors:A,element:i,placeholder:"Label",onChange:F=>{const U=F.target.value.toLowerCase().trim().replace(/[\s-]+/g,"_").replace(/[^a-z0-9_]/g,"");S(`options.${G}.value`,U,{shouldValidate:!0,shouldDirty:!0})}})}),a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:G===0?"Value":"",name:`options.${G}.value`,register:p,errors:A,element:i,placeholder:"Value"})}),a.jsx("button",{disabled:B.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>P(G),children:a.jsx(te,{icon:"iconamoon:sign-times-fill"})})]},$.id))," ",a.jsxs("div",{children:[" ",a.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>M({label:"",value:"",id:Le.v4()}),children:[a.jsx(te,{icon:"qlementine-icons:plus-16"})," Add Option"]})]})]}),["cascadeselect","matrix"].includes(i.type.toLowerCase())&&a.jsxs(a.Fragment,{children:[a.jsx("hr",{className:"my-5"}),a.jsxs("div",{children:[" ",a.jsx("h3",{className:"mb-4 text-sm text-gray-500 font-semibold",children:((O=i==null?void 0:i.type)==null?void 0:O.toLowerCase())==="matrix"?"Columns Options":"Child Options"}),K==null?void 0:K.map(($,G)=>a.jsxs("div",{className:"flex items-center mb-1 gap-x-4 last:mb-0",children:[a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:G===0?"Label":"",name:`options1.${G}.label`,register:p,errors:A,element:i,placeholder:"Label",onChange:F=>{const U=F.target.value.toLowerCase().trim().replace(/[\s-]+/g,"_").replace(/[^a-z0-9_]/g,"");S(`options1.${G}.value`,U,{shouldValidate:!0,shouldDirty:!0})}})}),a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:G===0?"Value":"",name:`options1.${G}.value`,register:p,errors:A,element:i,placeholder:"Value"})}),a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:G===0?"Key":"",name:`options1.${G}.key`,register:p,errors:A,element:i,placeholder:"Key"})}),a.jsx("button",{disabled:K.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>_(G),children:a.jsx(te,{icon:"iconamoon:sign-times-fill"})})]},$.id)),a.jsxs("div",{children:[" ",a.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>E({label:"",value:"",key:"",id:Le.v4()}),children:[a.jsx(te,{icon:"qlementine-icons:plus-16"})," Add Option"]})]})]})]})]})},ae=()=>a.jsxs("div",{className:"flex flex-col justify-start gap-y-1",children:[a.jsx("div",{className:"flex items-center mb-4 gap-x-5",children:Z==null?void 0:Z.map(J=>a.jsxs("label",{className:"items-center text-base capitalize gap-x-3",children:[a.jsx("input",{type:"radio",name:"optionType",onChange:O=>c(O.target.value),value:J,checked:J===m})," ",a.jsxs("span",{children:[J," options"]})]},J))}),m==="api"&&a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center gap-x-2",children:[a.jsxs("div",{className:"relative flex items-center w-full mb-2",children:[a.jsx(de,{watch:y,label:"Load Columns from Api",name:"apiUrl",errors:A,register:p,className:"!w-full",placeholder:"https://example.com/columns"}),d&&a.jsx("div",{className:"absolute w-4 h-4 mt-1 border-2 border-blue-500 rounded-full border-t-transparent animate-spin right-3 top-1/2"})]})," ",a.jsx("button",{onClick:X,className:"px-3 py-1 text-xs text-white bg-gray-600 rounded",type:"button",children:"Load"})]}),a.jsx(Od,{})]}),m==="sheet"&&a.jsx("div",{className:"mb-4",children:a.jsx(Rs,{type:i.type,label:"Load columns form sheet (csv, xlsx)",setValue:S,name:"dataColumns"})}),a.jsx("div",{className:"grid gap-y-3",children:I==null?void 0:I.map((J,O)=>{var $,G;return a.jsxs("div",{className:"flex flex-col gap-2 border-b border-gray-100 pb-2 mb-2 last:border-0 last:pb-0 last:mb-0",children:[a.jsxs("div",{className:"flex items-center gap-x-4",children:[a.jsx("div",{className:"min-w-[140px]",children:a.jsx(pn,{label:O===0?"Type":"",options:[{label:"Text",value:"text"},{label:"Number",value:"number"},{label:"Checkbox",value:"checkbox"},{label:"Select",value:"select"}],register:p,name:`dataColumns.${O}.type`,setValue:S,trigger:w,value:k.dataColumns[O].type})}),a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:O===0?"Display header":"",name:`dataColumns.${O}.headerName`,register:p,onChange:F=>{const U=F.target.value.toLowerCase().trim().replace(/[\s-]+/g,"_").replace(/[^a-z0-9_]/g,"");S(`dataColumns.${O}.field`,U,{shouldValidate:!0,shouldDirty:!0})},errors:A,element:i,placeholder:"header"})}),a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:O===0?"Field key":"",name:`dataColumns.${O}.field`,register:p,errors:A,element:i,placeholder:"fieldKey",disabled:!0})}),a.jsx("button",{disabled:I.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>D(O),children:a.jsx(te,{icon:"iconamoon:sign-times-fill"})})]}),((G=($=k.dataColumns)==null?void 0:$[O])==null?void 0:G.type)==="select"&&a.jsx("div",{className:"flex items-center gap-x-4",children:a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:"Options API URL",name:`dataColumns.${O}.optionsUrl`,register:p,errors:A,element:i,placeholder:"https://api.example.com/options"})})})]},J.id)})}),a.jsxs("div",{children:[" ",a.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>H({headerName:"",field:"",editable:!0,id:Le.v4(),type:"text",validate:!1}),children:[a.jsx(te,{icon:"qlementine-icons:plus-16"})," Add column"]})]})]}),R=x.useCallback(async()=>{const J=Ae("token"),{status:O,data:$}=await an.get(k.url,{headers:{Authorization:`Bearer ${J}`}});O===200&&S("options",($==null?void 0:$.data)||$)},[S,k.url]);x.useEffect(()=>{i.type==="document"&&k.url&&R()},[k.url,i.type,R]);const j=a.jsx("div",{className:"fixed inset-0 bg-gray-800/40 backdrop-blur-sm flex items-center justify-end z-[999] cursor-default",onMouseDown:J=>J.stopPropagation(),onPointerDown:J=>J.stopPropagation(),onDragStart:J=>{J.preventDefault(),J.stopPropagation()},children:a.jsxs("div",{className:"w-full lg:w-2/3 xl:w-2/5 bg-white h-screen shadow-xl relative flex flex-col items-center",children:[a.jsx("button",{className:"bg-white h-10 w-10 flex justify-center items-center absolute top-1 -left-12 rounded-lg hover:bg-gray-50",onClick:n,children:a.jsx(te,{icon:"tabler:x",iconClass:"text-xl"})}),a.jsx("div",{className:"w-full pt-4",children:a.jsx(yd,{tabs:o,setActiveTab:r,activeTab:l,className:"justify-start !text-left",btnClass:" !text-left"})}),a.jsxs("form",{onSubmit:g(L),className:"w-full flex-1 flex flex-col",autoComplete:"off",children:[a.jsxs("div",{className:"flex-1",children:[" ",a.jsxs("div",{className:"config_box max-h-[83vh] overflow-y-auto flex-1",children:[l==="basic"&&a.jsxs("div",{className:"z-10 flex flex-col w-full gap-5 px-6",children:[co.includes(i.inputType)&&a.jsx(a.Fragment,{children:a.jsx(de,{watch:y,label:"Value",name:"value",register:p,errors:A,element:i})}),!co.includes(i.inputType)&&!ci.includes(i.inputType)&&a.jsxs(a.Fragment,{children:[a.jsx(de,{watch:y,label:"Label",name:"inputLabel",register:p,errors:A,element:i})," ",i.type.toLowerCase()==="cascadeselect"&&a.jsx(de,{watch:y,label:"Child Label",name:"childLabel",register:p,errors:A,element:i})]}),Md.includes(i.inputType)&&a.jsx(de,{watch:y,label:"Placeholder",name:"placeholder",register:p,errors:A,element:i}),Cd.includes(i.inputType)&&a.jsx(de,{watch:y,label:"Prefix",name:"prefix",register:p,errors:A,element:i}),Pd.includes(i.inputType)&&a.jsxs("div",{className:"grid gap-y-4",children:[a.jsx(Dd,{}),a.jsx(de,{watch:y,label:"Api Url",name:"url",register:p,errors:A,element:i}),a.jsx(pn,{label:"Api Method",options:[{label:"GET",value:"GET"},{label:"POST",value:"POST"}],register:p,name:"method",setValue:S,trigger:w,value:y("method")}),a.jsx(pn,{label:"Api Response type",options:[{label:"String",value:"string"},{label:"Object",value:"object"}],register:p,name:"responseType",setValue:S,trigger:w,value:y("responseType")})]}),Ld.includes(i.inputType)&&a.jsx(Id,{onChange:J=>{S("denominators",J)},value:y("denominators")}),!co.includes(i.inputType)&&!ci.includes(i.inputType)&&a.jsx(de,{watch:y,label:"Short Description",name:"description",register:p,errors:A,element:i}),i.type.toLowerCase()==="date"&&a.jsxs(a.Fragment,{children:[a.jsx(pn,{label:"Date Format",options:Ad,register:p,name:"dateFormat",setValue:S,trigger:w,value:y("dateFormat")}),a.jsx(de,{watch:y,label:"Allow Range",name:"canHaveDateRange",register:p,errors:A,element:i,type:"checkbox",value:k.canHaveDateRange}),(k==null?void 0:k.canHaveDateRange)&&a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(vo,{name:"minDate",value:k==null?void 0:k.minDate,onGetValue:S,placeholder:"Select min date"}),a.jsx(vo,{name:"maxDate",value:k==null?void 0:k.minDate,onGetValue:S,placeholder:"Select max date",minDate:k==null?void 0:k.minDate})]}),a.jsx(de,{watch:y,label:"Allow Year Picker",name:"allowYearPicker",register:p,errors:A,element:i,type:"checkbox",value:k.allowYearPicker})]}),i.type.toLowerCase()==="country"&&a.jsx(de,{watch:y,label:"Allow States",name:"showState",register:p,errors:A,element:i,type:"checkbox",value:k.showState}),i.type.toLowerCase()==="selectfield"&&a.jsx(pn,{label:"Select Type",options:[{label:"List",value:"list"},{label:"Combobox",value:"Combobox"}],register:p,name:"selectType",setValue:S,trigger:w,value:y("selectType")}),["multiselect","checkbox"].includes(i.type.toLowerCase())&&a.jsxs(a.Fragment,{children:[a.jsx(de,{watch:y,label:"Minimum Options Checked",name:"minChecked",register:p,errors:A,element:i,type:"number"}),a.jsx("div",{className:"w-[250px]",children:a.jsx(de,{watch:y,label:"Require All Checked",name:"requireAllChecked",register:p,errors:A,element:i,type:"checkbox",value:k.requireAllChecked})})]}),i.type.toLowerCase()==="grid"&&a.jsx(de,{watch:y,label:"Number of columns (max: 4)",name:"columns",register:p,errors:A,element:i,max:4,min:1}),i.type.toLowerCase()==="document"&&a.jsxs("div",{className:"grid gap-y-6",children:[a.jsxs("div",{className:"grid gap-y-1",children:[a.jsx(de,{watch:y,label:"Document Options Url",name:"url",register:p,errors:A,element:i})," ",a.jsx(Kd,{})]}),a.jsxs("div",{className:"grid gap-y-1",children:[a.jsx(de,{watch:y,label:"Document Validation Url",name:"validationUrl",register:p,errors:A,element:i}),a.jsx(Hd,{})]}),a.jsx("div",{className:"grid gap-y-1",children:a.jsx(de,{watch:y,label:"Signature Page Url",name:"signatureLink",register:p,errors:A,element:i})})]}),i.type.toLowerCase()==="datagrid"&&ae(),i.type.toLowerCase()==="file"&&a.jsxs(a.Fragment,{children:[a.jsx(de,{watch:y,label:"Allow Multiple Uploads",name:"isMultiple",register:p,errors:A,element:i,type:"checkbox",value:k.isMultiple}),a.jsx(ho,{element:{options:Bd,id:"acceptedFiles",value:k==null?void 0:k.acceptedFiles},validationData:{register:p,setValue:S,trigger:w,watch:y},placeholder:"Choose file types"})]}),Td.includes(i.inputType)&&ie(),a.jsxs("div",{children:[a.jsx("div",{className:"w-[150px] mb-4",children:a.jsx(de,{watch:y,label:"Toggle Visibility",name:"isHidden",register:p,errors:A,element:i,type:"checkbox",value:k.isHidden})})," ",k.isHidden&&a.jsx(Vd,{register:p,setValue:S,trigger:w,watch:y,id:i==null?void 0:i.id})]}),i.type.toLowerCase()==="calculatedfield"&&a.jsxs("div",{className:"grid gap-y-2 mb-4",children:[a.jsx("label",{className:"block text-sm font-medium text-[#344054] font-onest",children:"Formula"}),a.jsx(Wd,{value:y("formula")||"",onChange:J=>S("formula",J,{shouldValidate:!0,shouldDirty:!0}),fields:h,placeholder:"Build your formula..."})]}),i.type.toLowerCase()==="polling"&&a.jsxs("div",{className:"grid gap-y-4 mb-4 mt-2",children:[a.jsx(de,{watch:y,label:"Fetch results from external API",name:"fetchExternalResults",register:p,errors:A,element:i,type:"checkbox",value:k.fetchExternalResults}),k.fetchExternalResults&&a.jsx(de,{watch:y,label:"External API URL (returns options results)",name:"externalApiUrl",register:p,errors:A,element:i,placeholder:"https://api.example.com/poll/results"})]})]}),!ci.includes(i.type.toLowerCase())&&l==="validation"&&a.jsxs("div",{className:"z-10 flex flex-col w-full gap-5 px-6",children:[a.jsxs("div",{className:"flex items-center gap-x-6",children:[a.jsx("div",{className:"w-[150px]",children:a.jsx(de,{watch:y,label:"Required",name:"isRequired",register:p,errors:A,element:i,type:"checkbox",value:k.isRequired})})," ",a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:"Error message text",name:"requiredMessage",register:p,errors:A,element:i})})]}),kd.includes(i.inputType)&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-x-6",children:[a.jsx("div",{className:"w-[150px]",children:a.jsx(de,{watch:y,label:"Min Length",name:"minLength",register:p,errors:A,element:i,type:"number"})})," ",a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:"Error message text",name:"minLengthMessage",register:p,errors:A,element:i})})]}),a.jsxs("div",{className:"flex items-center gap-x-6",children:[a.jsx("div",{className:"w-[150px]",children:a.jsx(de,{watch:y,label:"Max Length",name:"maxLength",register:p,errors:A,element:i,type:"number"})})," ",a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:"Error message text",name:"maxLengthMessage",register:p,errors:A,element:i})})]})]}),Ed.includes(i.inputType)&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-x-6",children:[a.jsx("div",{className:"w-[150px]",children:a.jsx(de,{watch:y,label:"Min Amount",name:"minAmount",register:p,errors:A,element:i,type:"amount"})})," ",a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:"Error message text",name:"minAmountMessage",register:p,errors:A,element:i})})]}),a.jsxs("div",{className:"flex items-center gap-x-6",children:[a.jsx("div",{className:"w-[150px]",children:a.jsx(de,{watch:y,label:"Max Amount",name:"maxAmount",register:p,errors:A,element:i,type:"amount"})})," ",a.jsx("div",{className:"flex-1",children:a.jsx(de,{watch:y,label:"Error message text",name:"maxAmountMessage",register:p,errors:A,element:i})})]})]})]})]})]}),a.jsxs("div",{className:"sticky flex w-full gap-3 px-6 pt-8 pb-10 border-t",children:[a.jsx("button",{type:"button",onClick:n,className:"flex-1 px-4 py-2.5 bg-white border border-[#D0D5DD] rounded-lg shadow-xs font-semibold text-[#344054] font-onest editor_option__cancel",children:"Cancel"}),a.jsx("button",{type:"submit",disabled:!C||N,style:{background:(v==null?void 0:v.buttonColor)||"#333"},className:`flex-1 px-4 py-2.5 ${!C||N?"bg-[#F2F4F7]":"bg-[#2563EB]"} ${!C||N?"text-[#98A2B3]":"text-white"} rounded-lg shadow-xs font-semibold font-onest disabled:opacity-50 editor_option__save`,children:N?"Saving...":"Save"})]})]})]})});return document.body?vr.createPortal(j,document.body):j},po=x.memo(({state:e,element:n,children:i})=>{var c,b;const[o,s]=x.useState(!1),{removeElement:t,duplicateElement:l,updateElement:r,copyElement:d}=x.useContext(Ie),u=x.useMemo(()=>{var h;return(h=n==null?void 0:n.acceptedFiles)==null?void 0:h.map(v=>v.label).join(", ")},[n]),m=x.useCallback(()=>{t(n.id,n.sectionId)},[n.id,n.sectionId,t]);return a.jsxs("div",{className:"w-full min-w-0",children:[o&&a.jsx(Ud,{isOpen:o,onClose:()=>s(!1),element:n}),a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{children:[" ",n.inputLabel&&a.jsxs("label",{className:"text-sm font-medium input_label",children:[n.inputLabel," ",u&&a.jsxs("span",{className:"text-gray-400 text-xs",children:["(",u==null?void 0:u.toLowerCase(),")"]})]})]}),e==="edit"&&a.jsxs("span",{className:"flex items-center gap-x-3",children:[((c=n.type)==null?void 0:c.toLowerCase())!=="spacer"&&((b=n.type)==null?void 0:b.toLowerCase())!=="divider"&&a.jsxs("label",{className:"flex items-center gap-1 text-xs cursor-pointer text-gray-500 mr-2 hover:text-gray-700 select-none",children:[a.jsx("input",{type:"checkbox",checked:n.isRequired||!1,onChange:h=>r({...n,isRequired:h.target.checked},n.sectionId),className:"cursor-pointer"}),a.jsx("span",{className:"mt-0.5",children:"Required"})]}),a.jsx("button",{type:"button",className:"text-sm outline-none hover:opacity-80 py-1 text-gray-600",onClick:()=>{typeof l=="function"&&l(n==null?void 0:n.id,n.sectionId)},title:"Duplicate",children:a.jsx(te,{icon:"solar:copy-outline",iconClass:"text-base"})}),a.jsx("button",{type:"button",className:"text-sm outline-none hover:opacity-80 py-1 text-gray-600",onClick:()=>{typeof d=="function"&&d(n==null?void 0:n.id,n.sectionId)},title:"Copy to Clipboard",children:a.jsx(te,{icon:"lucide:clipboard-copy",iconClass:"text-base"})}),a.jsx("button",{type:"button",className:"text-sm outline-none hover:opacity-80 text-gray-600 py-1",onClick:()=>s(!0),title:"Edit",children:a.jsx(te,{icon:"circum:edit",iconClass:"text-base"})}),a.jsx("button",{type:"button",className:"text-sm outline-none hover:opacity-80 text-gray-600 py-1",onClick:m,title:"Remove",children:a.jsx(te,{icon:"iconamoon:trash",iconClass:"text-base"})})]})]}),i,n.description&&a.jsx("small",{className:"block text-gray-400 mt-1 text-xs",children:n.description})]})});po.displayName="ElementContainer";function qd({element:e,validationData:n}){const{register:i=()=>({}),setValue:o,watch:s}=n||{};let t;return s&&(t=s()[e.id]),x.useEffect(()=>{i(e.id)},[e.id,i]),a.jsx(vo,{name:e.id,value:t,onGetValue:o,readOnly:n==null?void 0:n.isReadOnly,dateFormat:(e==null?void 0:e.dateFormat)||"dd/MM/yyyy",minDate:e==null?void 0:e.minDate,maxDate:e==null?void 0:e.maxDate,showYearDropdown:e==null?void 0:e.allowYearPicker})}function go({element:e,validationData:n}){var o;const{register:i=()=>({})}=n||{};return a.jsx("div",{children:a.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"",type:(e==null?void 0:e.inputType)||"text",className:ue("field-control",e==null?void 0:e.customClass),...i(e==null?void 0:e.id),disabled:n==null?void 0:n.isReadOnly,inputMode:(e==null?void 0:e.inputMode)||void 0,"aria-invalid":!!((o=n==null?void 0:n.errors)!=null&&o[e==null?void 0:e.id]),pattern:(e==null?void 0:e.pattern)||void 0})})}const Yd=["jpg","jpeg","png","gif","bmp","webp","svg","image"],Jd=(e="")=>{var i;const n=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return Yd.includes(n)||e.startsWith("data:image/")?"image":n==="pdf"||e.startsWith("data:application/pdf")?"pdf":["doc","docx"].includes(n)?"word":["xls","xlsx","csv"].includes(n)?"excel":["ppt","pptx"].includes(n)?"powerpoint":"other"},Zd={pdf:"vscode-icons:file-type-pdf2",word:"vscode-icons:file-type-word",excel:"vscode-icons:file-type-excel",powerpoint:"vscode-icons:file-type-powerpoint2"};function oa({fileUrl:e,fileName:n,removeFile:i}){const[o,s]=x.useState(!1),[t,l]=x.useState("unknown"),[r,d]=x.useState(null);x.useEffect(()=>{e&&l(Jd(e))},[e]),x.useEffect(()=>{if(t==="pdf"&&(e!=null&&e.startsWith("data:")))try{const h=atob(e.split(",")[1]),v=new ArrayBuffer(h.length),p=new Uint8Array(v);for(let S=0;S<h.length;S++)p[S]=h.charCodeAt(S);const g=new Blob([v],{type:"application/pdf"}),f=URL.createObjectURL(g);return d(f),()=>URL.revokeObjectURL(f)}catch(h){console.error("Error creating blob URL:",h)}else d(null)},[e,t]);const u=()=>{t==="image"||t==="pdf"?s(!0):window.open(r||e,"_blank")},m=()=>s(!1),c=n||(e==null?void 0:e.split("/").pop())||"Unknown file";function b(h,v="download"){if(!h)return;if(h.startsWith("data:")){const g=document.createElement("a");g.href=h,g.download=v,document.body.appendChild(g),g.click(),document.body.removeChild(g);return}const p=document.createElement("a");p.href=h,p.setAttribute("download",v),document.body.appendChild(p),p.click(),document.body.removeChild(p)}return a.jsxs("div",{className:"mt-2 field-control !py-1 !bg-gray-50 !flex justify-between gap-x-8 items-center",children:[a.jsxs("div",{onClick:u,className:"!flex items-center rounded cursor-pointer gap-x-3",title:`Click to preview ${c}`,children:[t==="image"&&a.jsx("div",{className:"flex items-center justify-center ",children:a.jsx(te,{iconClass:"text-4xl",icon:"fluent-color:image-48"})}),t!=="image"&&a.jsx(te,{icon:Zd[t],iconClass:"text-4xl"}),a.jsx("span",{className:"text-sm font-semibold text-center text-gray-700 truncate max-w-[300px]",children:c})]}),a.jsxs("div",{className:"flex gap-x-1 items-center",children:[a.jsx("button",{type:"button",className:"p-2",onClick:()=>b(r||e,n),title:`Download ${c}`,children:a.jsx(te,{icon:"streamline-flex:download-tray-solid"})}),i&&a.jsx("button",{type:"button",className:"p-2 text-lg text-red-500",onClick:i,children:a.jsx(te,{icon:"lets-icons:trash-duotone"})})]}),o&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",onClick:m,children:a.jsxs("div",{className:"relative bg-white p-8 rounded-lg w-full max-w-[90vw] max-h-[90vh] overflow-auto",onClick:h=>h.stopPropagation(),children:[a.jsx("button",{onClick:m,className:"absolute text-2xl font-bold text-gray-700 top-2 right-2","aria-label":"Close preview",children:"×"}),t==="image"?a.jsx("img",{src:e,alt:c,className:"max-w-full max-h-[80vh] mx-auto object-contain",crossOrigin:"anonymous"}):t==="pdf"?a.jsx("iframe",{src:r||e,title:c,className:"w-full h-[80vh] rounded border"}):null]})})]})}const Xd=5*1024*1024;function Qd({onFileLoaded:e,disabled:n=!1,handleDeleteFile:i,multiple:o=!1,list:s=null,accept:t=[]}){const{uploadUrl:l,setApiActivityCount:r}=x.useContext(Ie),d=x.useRef(null),[u,m]=x.useState(s),[c,b]=x.useState(!1);x.useEffect(()=>{m(s)},[s]);const h=x.useMemo(()=>t==null?void 0:t.map(A=>A.value).join(", "),[t]),v=x.useMemo(()=>t==null?void 0:t.map(A=>A.label).join(", "),[t]),p=x.useCallback(async A=>{var T,k;const N=Ae("token"),C=((T=Ae("orgData"))==null?void 0:T.id)||Ae("organizationId");try{const{data:B}=await an.post(l,{...A,service:"FORM",organizationId:C||""},{headers:{Authorization:`Bearer ${N}`}});return(k=B==null?void 0:B.data)==null?void 0:k.url}catch(B){throw console.error("File upload error:",B),new Error("Failed to upload file to server")}},[l]),g=x.useCallback(A=>new Promise((N,C)=>{const T=new FileReader;T.onloadend=async()=>{try{const k=T.result.replace(/^data:.*;base64,/,""),B=l?await p({base64:k,ext:`.${A.name.split(".").pop()}`,fileName:A.name}):T.result;N({base64:B,type:A.type,name:A.name})}catch(k){C(k)}},T.onerror=()=>C(new Error("File read failed")),T.readAsDataURL(A)}),[l,p]),f=x.useCallback(A=>{var C;const N=h?(C=h.split(","))==null?void 0:C.map(T=>T.trim()):[];for(const T of A){if(T.size>Xd)return Ne.toast.error(`File "${T.name}" exceeds 5MB limit (${(T.size/1024/1024).toFixed(2)}MB)`),!1;if(N.length&&!N.some(k=>T.type===k||T.name.toLowerCase().endsWith(k.replace("*",""))))return Ne.toast.error(`File "${T.name}" is not an allowed type. Allowed: ${v||"any"}`),!1}return!0},[h,v]),S=x.useCallback(async A=>{const N=Array.from(A.target.files||[]);if(!(!N.length||c)){if(!f(N)){d.current&&(d.current.value="");return}try{b(!0),r==null||r(k=>k+1);const C=await Promise.all(N==null?void 0:N.map(g)),T=o&&u?[...u,...C]:C;m(T),e(T),Ne.toast.success(`Successfully uploaded ${N.length} file(s)`)}catch(C){console.error("Upload error:",C),Ne.toast.error("Failed to upload file(s). Please try again.")}finally{b(!1),r==null||r(C=>Math.max(0,C-1)),d.current&&(d.current.value="")}}},[c,f,g,e,o,u,r]),y=x.useCallback(A=>{c||(d.current&&(d.current.value=""),m(N=>{const C=A===void 0?null:(N==null?void 0:N.filter((T,k)=>k!==A))||null;return e(C),C}),i==null||i())},[i,e,c]),w=u&&u.length>0;return a.jsxs("div",{className:"flex flex-col items-start gap-2",children:[!n&&a.jsxs("div",{className:"!flex field-control !py-0 !px-0 relative",children:[a.jsx("input",{ref:d,type:"file",onChange:S,disabled:n||c,multiple:o,accept:h||"",className:`w-full text-sm text-gray-500 file:mr-4 flex-1 file:px-4 !py-1 !pl-1\r
23
23
  file:rounded-[6px] file:py-[6px] file:border-0\r
24
24
  file:text-sm file:font-semibold\r
25
25
  file:bg-blue-50 file:text-blue-700\r
@@ -3995,7 +3995,7 @@ const go = K.object().shape({
3995
3995
  children: [
3996
3996
  /* @__PURE__ */ m("div", { className: "flex-1", children: [
3997
3997
  " ",
3998
- /* @__PURE__ */ m("div", { className: " max-h-[83vh] overflow-y-auto flex-1", children: [
3998
+ /* @__PURE__ */ m("div", { className: "config_box max-h-[83vh] overflow-y-auto flex-1", children: [
3999
3999
  d === "basic" && /* @__PURE__ */ m("div", { className: "z-10 flex flex-col w-full gap-5 px-6", children: [
4000
4000
  mi.includes(a.inputType) && /* @__PURE__ */ i(ye, { children: /* @__PURE__ */ i(
4001
4001
  W,
@@ -7924,7 +7924,7 @@ const ls = oi(ss), ds = K.object({
7924
7924
  const a = te("config"), s = (a == null ? void 0 : a.loaderColor) || "#333";
7925
7925
  document.documentElement.style.setProperty("--loader-color", s);
7926
7926
  }, []), /* @__PURE__ */ i("div", { className: n, children: /* @__PURE__ */ i("span", { className: "loader" }) });
7927
- }, vs = se.lazy(() => import("./logic-flow-DBxBRGuu.js"));
7927
+ }, vs = se.lazy(() => import("./logic-flow-BdHSNbsy.js"));
7928
7928
  function ps({
7929
7929
  questionData: e,
7930
7930
  uploadUrl: n,
@@ -1,7 +1,7 @@
1
1
  import { jsxs as ce, jsx as D, Fragment as De } from "react/jsx-runtime";
2
2
  import ht, { memo as le, useState as xe, useCallback as we, forwardRef as Oo, useRef as ne, useEffect as ie, useContext as gt, createContext as fn, useMemo as be, useLayoutEffect as Aa } from "react";
3
3
  import "react-dom";
4
- import { A as Ia } from "./index-BTXex7Qy.js";
4
+ import { A as Ia } from "./index-CwkZpEWq.js";
5
5
  function ue(e) {
6
6
  if (typeof e == "string" || typeof e == "number") return "" + e;
7
7
  let t = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arudovwen/form-builder-react",
3
- "version": "1.8.9",
3
+ "version": "1.8.10",
4
4
  "description": "A React-based form builder component library.",
5
5
  "type": "module",
6
6
  "main": "./dist/form-builder.umd.js",