@arudovwen/form-builder-react 1.4.30 → 1.4.32

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.
@@ -2237,7 +2237,7 @@ function wn({
2237
2237
  }, [u, i.id]), /* @__PURE__ */ n.jsx("div", { className: "custom-select", children: /* @__PURE__ */ n.jsx(
2238
2238
  ii,
2239
2239
  {
2240
- value: s,
2240
+ value: s || [],
2241
2241
  onChange: (h) => {
2242
2242
  a(h), d == null || d(i.id, h);
2243
2243
  },
@@ -2251,7 +2251,7 @@ function wn({
2251
2251
  className: "custom-select__control field-control",
2252
2252
  disabled: c,
2253
2253
  children: [
2254
- /* @__PURE__ */ n.jsx("span", { className: "custom-select__value", children: s.length > 0 ? r : /* @__PURE__ */ n.jsx("span", { className: "custom-select__placeholder", children: o != null ? o : " Select options" }) }),
2254
+ /* @__PURE__ */ n.jsx("span", { className: "custom-select__value", children: (s == null ? void 0 : s.length) > 0 ? r : /* @__PURE__ */ n.jsx("span", { className: "custom-select__placeholder", children: o != null ? o : " Select options" }) }),
2255
2255
  /* @__PURE__ */ n.jsx("span", { className: "custom-select__icon", children: /* @__PURE__ */ n.jsx(W, { icon: "lucide:chevron-down" }) })
2256
2256
  ]
2257
2257
  }
@@ -2689,16 +2689,16 @@ const G = ({
2689
2689
  (s == null ? void 0 : s[e]) && /* @__PURE__ */ n.jsx("p", { className: "mt-1 text-sm text-red-600", children: (g = s[e]) == null ? void 0 : g.message })
2690
2690
  ] });
2691
2691
  if (["checkbox", "radio"].includes(l)) {
2692
- const y = p == null ? void 0 : p(e);
2692
+ const y = (p == null ? void 0 : p(e)) || null;
2693
2693
  let j = !1;
2694
- return y && (l === "checkbox" ? j = y == null ? void 0 : y.includes(r) : j = y == r), /* @__PURE__ */ n.jsxs("div", { className: "space-y-1", children: [
2694
+ return y && (y != null && y.length && l === "checkbox" ? j = y == null ? void 0 : y.includes(r) : j = y == r), /* @__PURE__ */ n.jsxs("div", { className: "space-y-1", children: [
2695
2695
  /* @__PURE__ */ n.jsxs("label", { className: "flex items-center gap-3 cursor-pointer select-none", children: [
2696
2696
  /* @__PURE__ */ n.jsx(
2697
2697
  "input",
2698
2698
  {
2699
2699
  ...x,
2700
2700
  type: l,
2701
- value: r,
2701
+ value: r || "",
2702
2702
  disabled: v,
2703
2703
  className: "peer sr-only"
2704
2704
  }
@@ -6268,7 +6268,7 @@ function ws({
6268
6268
  readOnly: l,
6269
6269
  disabled: l,
6270
6270
  onError: (r) => {
6271
- r ? d == null || d(i.id, { type: "manual", message: r }) : c(i.id);
6271
+ r ? d == null || d(i.id, { type: "manual", message: r }) : c == null || c(i.id);
6272
6272
  },
6273
6273
  onChange: (r) => {
6274
6274
  r && (s == null || s(i.id, r));
@@ -28,11 +28,11 @@ Check the top-level render call using <`+C+">.")}return N}}function Mn(v,N){{if(
28
28
  <%s {...props} />
29
29
  React keys must be passed directly to JSX without using spread:
30
30
  let props = %s;
31
- <%s key={someKey} {...props} />`,Si,Ne,Gs,Ne),En[Ne+Si]=!0}}return v===s?Ps(ae):Ls(ae),ae}}function Os(v,N,C){return Bn(v,N,C,!0)}function Is(v,N,C){return Bn(v,N,C,!1)}var Ds=Is,Ks=Os;Le.Fragment=s,Le.jsx=Ds,Le.jsxs=Ks}()),Le}var Bi;function Rn(){return Bi||(Bi=1,process.env.NODE_ENV==="production"?Re.exports=Kn():Re.exports=Gn()),Re.exports}var i=Rn();const le=b.createContext(void 0),Li={title:"",description:"",id:be.v4(),questionData:[],disabled:!1},Pi=({children:e})=>{const[n,o]=b.useState({}),[s,a]=b.useState({}),[t,l]=b.useState([Li]),[r,d]=b.useState(!1),[c,u]=b.useState(null),[g,p]=b.useState([0]),[h,y]=b.useState(""),f=b.useCallback(()=>{},[]),m=b.useCallback(()=>{const D=be.v4();l(M=>[...M,{...Li,id:D}]),u(D),p([t.length])},[t]),x=b.useCallback(D=>{l(M=>M.filter(T=>T.id!==D)),u(null)},[]),w=b.useCallback((D,M)=>{const T=t.find(I=>I.id===M),B=T==null?void 0:T.questionData.find(I=>I.id===D);B&&l(I=>I==null?void 0:I.map(Y=>Y.id===M?{...Y,questionData:Y.questionData.filter(J=>B.type==="grid"?J.gridId!==B.id&&J.id!==B.id:J.id!==D)}:Y))},[t,l]),k=b.useCallback((D,M)=>{const T=t.find(J=>J.id===M);if(!T)return;const B=T.questionData.findIndex(J=>J.id===D);if(B===-1)return;const I=T.questionData[B],Y=(J,oe={})=>({...JSON.parse(JSON.stringify(J)),id:be.v4(),...oe});l(J=>J==null?void 0:J.map(oe=>{var se;if(oe.id!==M)return oe;const O=[...oe.questionData];if(I.type==="grid"){const ve=(se=O==null?void 0:O.map((Z,de)=>({e:Z,i:de})).filter(({e:Z})=>Z.id===I.id||Z.gridId===I.id))==null?void 0:se.map(({i:Z})=>Z),pe=ve.length?Math.max(...ve)+1:B+1,fe=be.v4(),xe=Y(I,{});xe.id=fe;const R=O.filter(Z=>Z.gridId===I.id),z=R==null?void 0:R.map(Z=>Y(Z,{gridId:fe})),te=[...O.slice(0,pe),xe,...z,...O.slice(pe)];return{...oe,questionData:te}}else{const ve=Y(I,I.gridId?{gridId:I.gridId}:{}),pe=[...O.slice(0,B+1),ve,...O.slice(B+1)];return{...oe,questionData:pe}}}))},[t,l]),S=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>B.id===M?{...B,questionData:D}:B))},[]),A=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>B.id===M?{...B,questionData:[...B.questionData,D]}:B))},[]),_=b.useCallback((D,M,T)=>{l(B=>B==null?void 0:B.map(I=>I.id===M?{...I,questionData:[...I.questionData.slice(0,T),D,...I.questionData.slice(T)]}:I))},[]),j=b.useCallback((D,M,T)=>{l(B=>B==null?void 0:B.map(I=>{var Y;return I.id===T?{...I,questionData:(Y=I.questionData)==null?void 0:Y.map(J=>{var oe;return J.type==="grid"&&J.gridData?{...J,gridData:(oe=J.gridData)==null?void 0:oe.map((O,se)=>se===D?{...O,...M}:O).concat(D>=J.gridData.length?{...M}:[])}:J})}:I}))},[]),L=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>{var I;return B.id===M?{...B,questionData:(I=B.questionData)==null?void 0:I.map(Y=>Y.id===D.id?{...Y,...D}:Y)}:B}))},[]),Q=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>B.id===M?{...B,...D}:B))},[]),W=b.useMemo(()=>({formData:t,setFormData:l,handleDragStop:f,removeElement:w,elementData:s,setElementData:a,updateElementPosition:S,addElement:A,addElementInPosition:_,updateElement:L,addSection:m,removeSection:x,updateSection:Q,isDragging:r,setIsDragging:d,selectedSection:c,setSelectedSection:u,activeSections:g,setActiveSections:p,updateGridElement:j,answerData:n,setAnswerData:o,uploadUrl:h,setUploadUrl:y,duplicateElement:k}),[t,f,w,s,S,A,_,L,m,x,Q,r,c,g,j,n,h,k]);return i.jsx(le.Provider,{value:W,children:e})};function Oi(e){var n,o,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(n=0;n<a;n++)e[n]&&(o=Oi(e[n]))&&(s&&(s+=" "),s+=o)}else for(o in e)e[o]&&(s&&(s+=" "),s+=o);return s}function V(){for(var e,n,o=0,s="",a=arguments.length;o<a;o++)(e=arguments[o])&&(n=Oi(e))&&(s&&(s+=" "),s+=n);return s}function zn({type:e="calendar",className:n}){return i.jsx(i.Fragment,{children:e==="calendar"?i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[i.jsx("path",{d:"M6.66406 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M13.3359 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M2.91406 7.57495H17.0807",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.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"}),i.jsx("path",{d:"M13.0762 11.4167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M13.0762 13.9167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M9.99803 11.4167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M9.99803 13.9167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M6.91209 11.4167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M6.91209 13.9167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[i.jsx("path",{d:"M10 6.66663V10.8333",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),i.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"}),i.jsx("path",{d:"M7.5 1.66663H12.5",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.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 Qe=({value:e=null,onGetValue:n,readOnly:o=!1,dateFormat:s="dd/MM/yyyy",name:a,placeholder:t="Select date",minDate:l,maxDate:r,showYearDropdown:d})=>{const c=e?new Date(e):null,[u,g]=b.useState(c);b.useEffect(()=>{const h=e?new Date(e):null;(h&&u&&h.getTime()!==u.getTime()||!h&&u||h&&!u)&&g(h)},[e]),b.useEffect(()=>{n&&n(a,u)},[u,n,a]);const p=h=>{g(h)};return i.jsx("div",{className:"builder_date__picker",children:i.jsx(Ln,{showIcon:!0,icon:i.jsx(zn,{className:"react-datepicker__calendar-icon"}),showPopperArrow:!1,dateFormat:s,disabled:o,selected:u,onChange:p,className:"field-control",portalId:"root-portal",placeholderText:t,minDate:l,maxDate:r,showYearDropdown:d,scrollableYearDropdown:!0,yearDropdownItemNumber:40})})};function Hn({element:e,validationData:n}){const{register:o=()=>({}),setValue:s,watch:a}=n||{};let t;return a&&(t=a()[e.id]),b.useEffect(()=>{o(e.id)},[e.id]),i.jsx(Qe,{name:e.id,value:t,onGetValue:s,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 Xe({element:e,validationData:n}){var s;const{register:o=()=>({})}=n||{};return i.jsx("div",{children:i.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"",type:(e==null?void 0:e.inputType)||"text",className:V("field-control",e==null?void 0:e.customClass),...o(e==null?void 0:e.id),disabled:n==null?void 0:n.isReadOnly,inputMode:(e==null?void 0:e.inputMode)||void 0,"aria-invalid":!!((s=n==null?void 0:n.errors)!=null&&s[e==null?void 0:e.id]),pattern:(e==null?void 0:e.pattern)||void 0})})}function Fn(e,n){const o=e.icons,s=e.aliases||Object.create(null),a=Object.create(null);function t(l){if(o[l])return a[l]=[];if(!(l in a)){a[l]=null;const r=s[l]&&s[l].parent,d=r&&t(r);d&&(a[l]=[r].concat(d))}return a[l]}return Object.keys(o).concat(Object.keys(s)).forEach(t),a}const Ii=Object.freeze({left:0,top:0,width:16,height:16}),ze=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),ei=Object.freeze({...Ii,...ze}),ii=Object.freeze({...ei,body:"",hidden:!1});function Vn(e,n){const o={};!e.hFlip!=!n.hFlip&&(o.hFlip=!0),!e.vFlip!=!n.vFlip&&(o.vFlip=!0);const s=((e.rotate||0)+(n.rotate||0))%4;return s&&(o.rotate=s),o}function Di(e,n){const o=Vn(e,n);for(const s in ii)s in ze?s in e&&!(s in o)&&(o[s]=ze[s]):s in n?o[s]=n[s]:s in e&&(o[s]=e[s]);return o}function Un(e,n,o){const s=e.icons,a=e.aliases||Object.create(null);let t={};function l(r){t=Di(s[r]||a[r],t)}return l(n),o.forEach(l),Di(e,t)}function Ki(e,n){const o=[];if(typeof e!="object"||typeof e.icons!="object")return o;e.not_found instanceof Array&&e.not_found.forEach(a=>{n(a,null),o.push(a)});const s=Fn(e);for(const a in s){const t=s[a];t&&(n(a,Un(e,a,t)),o.push(a))}return o}const Wn={provider:"",aliases:{},not_found:{},...Ii};function ni(e,n){for(const o in n)if(o in e&&typeof e[o]!=typeof n[o])return!1;return!0}function Gi(e){if(typeof e!="object"||e===null)return null;const n=e;if(typeof n.prefix!="string"||!e.icons||typeof e.icons!="object"||!ni(e,Wn))return null;const o=n.icons;for(const a in o){const t=o[a];if(!a||typeof t.body!="string"||!ni(t,ii))return null}const s=n.aliases||Object.create(null);for(const a in s){const t=s[a],l=t.parent;if(!a||typeof l!="string"||!o[l]&&!s[l]||!ni(t,ii))return null}return n}const Ri=Object.create(null);function Jn(e,n){return{provider:e,prefix:n,icons:Object.create(null),missing:new Set}}function Ce(e,n){const o=Ri[e]||(Ri[e]=Object.create(null));return o[n]||(o[n]=Jn(e,n))}function zi(e,n){return Gi(n)?Ki(n,(o,s)=>{s?e.icons[o]=s:e.missing.add(o)}):[]}function qn(e,n,o){try{if(typeof o.body=="string")return e.icons[n]={...o},!0}catch(s){}return!1}const Hi=/^[a-z0-9]+(-[a-z0-9]+)*$/,He=(e,n,o,s="")=>{const a=e.split(":");if(e.slice(0,1)==="@"){if(a.length<2||a.length>3)return null;s=a.shift().slice(1)}if(a.length>3||!a.length)return null;if(a.length>1){const r=a.pop(),d=a.pop(),c={provider:a.length>0?a[0]:s,prefix:d,name:r};return n&&!Fe(c)?null:c}const t=a[0],l=t.split("-");if(l.length>1){const r={provider:s,prefix:l.shift(),name:l.join("-")};return n&&!Fe(r)?null:r}if(o&&s===""){const r={provider:s,prefix:"",name:t};return n&&!Fe(r,o)?null:r}return null},Fe=(e,n)=>e?!!((n&&e.prefix===""||e.prefix)&&e.name):!1;let Pe=!1;function Fi(e){return typeof e=="boolean"&&(Pe=e),Pe}function Vi(e){const n=typeof e=="string"?He(e,!0,Pe):e;if(n){const o=Ce(n.provider,n.prefix),s=n.name;return o.icons[s]||(o.missing.has(s)?null:void 0)}}function Yn(e,n){const o=He(e,!0,Pe);if(!o)return!1;const s=Ce(o.provider,o.prefix);return n?qn(s,o.name,n):(s.missing.add(o.name),!0)}function Zn(e,n){if(typeof e!="object")return!1;if(typeof n!="string"&&(n=e.provider||""),Pe&&!n&&!e.prefix){let a=!1;return Gi(e)&&(e.prefix="",Ki(e,(t,l)=>{Yn(t,l)&&(a=!0)})),a}const o=e.prefix;if(!Fe({prefix:o,name:"a"}))return!1;const s=Ce(n,o);return!!zi(s,e)}const Ui=Object.freeze({width:null,height:null}),Wi=Object.freeze({...Ui,...ze}),$n=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Qn=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Ji(e,n,o){if(n===1)return e;if(o=o||100,typeof e=="number")return Math.ceil(e*n*o)/o;if(typeof e!="string")return e;const s=e.split($n);if(s===null||!s.length)return e;const a=[];let t=s.shift(),l=Qn.test(t);for(;;){if(l){const r=parseFloat(t);isNaN(r)?a.push(t):a.push(Math.ceil(r*n*o)/o)}else a.push(t);if(t=s.shift(),t===void 0)return a.join("");l=!l}}function Xn(e,n="defs"){let o="";const s=e.indexOf("<"+n);for(;s>=0;){const a=e.indexOf(">",s),t=e.indexOf("</"+n);if(a===-1||t===-1)break;const l=e.indexOf(">",t);if(l===-1)break;o+=e.slice(a+1,t).trim(),e=e.slice(0,s).trim()+e.slice(l+1)}return{defs:o,content:e}}function eo(e,n){return e?"<defs>"+e+"</defs>"+n:n}function io(e,n,o){const s=Xn(e);return eo(s.defs,n+s.content+o)}const no=e=>e==="unset"||e==="undefined"||e==="none";function oo(e,n){const o={...ei,...e},s={...Wi,...n},a={left:o.left,top:o.top,width:o.width,height:o.height};let t=o.body;[o,s].forEach(f=>{const m=[],x=f.hFlip,w=f.vFlip;let k=f.rotate;x?w?k+=2:(m.push("translate("+(a.width+a.left).toString()+" "+(0-a.top).toString()+")"),m.push("scale(-1 1)"),a.top=a.left=0):w&&(m.push("translate("+(0-a.left).toString()+" "+(a.height+a.top).toString()+")"),m.push("scale(1 -1)"),a.top=a.left=0);let S;switch(k<0&&(k-=Math.floor(k/4)*4),k=k%4,k){case 1:S=a.height/2+a.top,m.unshift("rotate(90 "+S.toString()+" "+S.toString()+")");break;case 2:m.unshift("rotate(180 "+(a.width/2+a.left).toString()+" "+(a.height/2+a.top).toString()+")");break;case 3:S=a.width/2+a.left,m.unshift("rotate(-90 "+S.toString()+" "+S.toString()+")");break}k%2===1&&(a.left!==a.top&&(S=a.left,a.left=a.top,a.top=S),a.width!==a.height&&(S=a.width,a.width=a.height,a.height=S)),m.length&&(t=io(t,'<g transform="'+m.join(" ")+'">',"</g>"))});const l=s.width,r=s.height,d=a.width,c=a.height;let u,g;l===null?(g=r===null?"1em":r==="auto"?c:r,u=Ji(g,d/c)):(u=l==="auto"?d:l,g=r===null?Ji(u,c/d):r==="auto"?c:r);const p={},h=(f,m)=>{no(m)||(p[f]=m.toString())};h("width",u),h("height",g);const y=[a.left,a.top,d,c];return p.viewBox=y.join(" "),{attributes:p,viewBox:y,body:t}}const ao=/\sid="(\S+)"/g,so="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let to=0;function lo(e,n=so){const o=[];let s;for(;s=ao.exec(e);)o.push(s[1]);if(!o.length)return e;const a="suffix"+(Math.random()*16777216|Date.now()).toString(16);return o.forEach(t=>{const l=typeof n=="function"?n(t):n+(to++).toString(),r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+r+')([")]|\\.[a-z])',"g"),"$1"+l+a+"$3")}),e=e.replace(new RegExp(a,"g"),""),e}const oi=Object.create(null);function ro(e,n){oi[e]=n}function ai(e){return oi[e]||oi[""]}function si(e){let n;if(typeof e.resources=="string")n=[e.resources];else if(n=e.resources,!(n instanceof Array)||!n.length)return null;return{resources:n,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const ti=Object.create(null),Oe=["https://api.simplesvg.com","https://api.unisvg.com"],Ve=[];for(;Oe.length>0;)Oe.length===1||Math.random()>.5?Ve.push(Oe.shift()):Ve.push(Oe.pop());ti[""]=si({resources:["https://api.iconify.design"].concat(Ve)});function uo(e,n){const o=si(n);return o===null?!1:(ti[e]=o,!0)}function li(e){return ti[e]}let qi=(()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch(n){}})();function co(e,n){const o=li(e);if(!o)return 0;let s;if(!o.maxURL)s=0;else{let a=0;o.resources.forEach(l=>{a=Math.max(a,l.length)});const t=n+".json?icons=";s=o.maxURL-a-o.path.length-t.length}return s}function mo(e){return e===404}const bo=(e,n,o)=>{const s=[],a=co(e,n),t="icons";let l={type:t,provider:e,prefix:n,icons:[]},r=0;return o.forEach((d,c)=>{r+=d.length+1,r>=a&&c>0&&(s.push(l),l={type:t,provider:e,prefix:n,icons:[]},r=d.length),l.icons.push(d)}),s.push(l),s};function vo(e){if(typeof e=="string"){const n=li(e);if(n)return n.path}return"/"}const po={prepare:bo,send:(e,n,o)=>{if(!qi){o("abort",424);return}let s=vo(n.provider);switch(n.type){case"icons":{const t=n.prefix,r=n.icons.join(","),d=new URLSearchParams({icons:r});s+=t+".json?"+d.toString();break}case"custom":{const t=n.uri;s+=t.slice(0,1)==="/"?t.slice(1):t;break}default:o("abort",400);return}let a=503;qi(e+s).then(t=>{const l=t.status;if(l!==200){setTimeout(()=>{o(mo(l)?"abort":"next",l)});return}return a=501,t.json()}).then(t=>{if(typeof t!="object"||t===null){setTimeout(()=>{t===404?o("abort",t):o("next",a)});return}setTimeout(()=>{o("success",t)})}).catch(()=>{o("next",a)})}};function Yi(e,n){e.forEach(o=>{const s=o.loaderCallbacks;s&&(o.loaderCallbacks=s.filter(a=>a.id!==n))})}function go(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const n=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!n.length)return;let o=!1;const s=e.provider,a=e.prefix;n.forEach(t=>{const l=t.icons,r=l.pending.length;l.pending=l.pending.filter(d=>{if(d.prefix!==a)return!0;const c=d.name;if(e.icons[c])l.loaded.push({provider:s,prefix:a,name:c});else if(e.missing.has(c))l.missing.push({provider:s,prefix:a,name:c});else return o=!0,!0;return!1}),l.pending.length!==r&&(o||Yi([e],t.id),t.callback(l.loaded.slice(0),l.missing.slice(0),l.pending.slice(0),t.abort))})}))}let ho=0;function fo(e,n,o){const s=ho++,a=Yi.bind(null,o,s);if(!n.pending.length)return a;const t={id:s,icons:n,callback:e,abort:a};return o.forEach(l=>{(l.loaderCallbacks||(l.loaderCallbacks=[])).push(t)}),a}function xo(e){const n={loaded:[],missing:[],pending:[]},o=Object.create(null);e.sort((a,t)=>a.provider!==t.provider?a.provider.localeCompare(t.provider):a.prefix!==t.prefix?a.prefix.localeCompare(t.prefix):a.name.localeCompare(t.name));let s={provider:"",prefix:"",name:""};return e.forEach(a=>{if(s.name===a.name&&s.prefix===a.prefix&&s.provider===a.provider)return;s=a;const t=a.provider,l=a.prefix,r=a.name,d=o[t]||(o[t]=Object.create(null)),c=d[l]||(d[l]=Ce(t,l));let u;r in c.icons?u=n.loaded:l===""||c.missing.has(r)?u=n.missing:u=n.pending;const g={provider:t,prefix:l,name:r};u.push(g)}),n}function yo(e,n=!0,o=!1){const s=[];return e.forEach(a=>{const t=typeof a=="string"?He(a,n,o):a;t&&s.push(t)}),s}const ko={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function wo(e,n,o,s){const a=e.resources.length,t=e.random?Math.floor(Math.random()*a):e.index;let l;if(e.random){let _=e.resources.slice(0);for(l=[];_.length>1;){const j=Math.floor(Math.random()*_.length);l.push(_[j]),_=_.slice(0,j).concat(_.slice(j+1))}l=l.concat(_)}else l=e.resources.slice(t).concat(e.resources.slice(0,t));const r=Date.now();let d="pending",c=0,u,g=null,p=[],h=[];typeof s=="function"&&h.push(s);function y(){g&&(clearTimeout(g),g=null)}function f(){d==="pending"&&(d="aborted"),y(),p.forEach(_=>{_.status==="pending"&&(_.status="aborted")}),p=[]}function m(_,j){j&&(h=[]),typeof _=="function"&&h.push(_)}function x(){return{startTime:r,payload:n,status:d,queriesSent:c,queriesPending:p.length,subscribe:m,abort:f}}function w(){d="failed",h.forEach(_=>{_(void 0,u)})}function k(){p.forEach(_=>{_.status==="pending"&&(_.status="aborted")}),p=[]}function S(_,j,L){const Q=j!=="success";switch(p=p.filter(W=>W!==_),d){case"pending":break;case"failed":if(Q||!e.dataAfterTimeout)return;break;default:return}if(j==="abort"){u=L,w();return}if(Q){u=L,p.length||(l.length?A():w());return}if(y(),k(),!e.random){const W=e.resources.indexOf(_.resource);W!==-1&&W!==e.index&&(e.index=W)}d="completed",h.forEach(W=>{W(L)})}function A(){if(d!=="pending")return;y();const _=l.shift();if(_===void 0){if(p.length){g=setTimeout(()=>{y(),d==="pending"&&(k(),w())},e.timeout);return}w();return}const j={status:"pending",resource:_,callback:(L,Q)=>{S(j,L,Q)}};p.push(j),c++,g=setTimeout(A,e.rotate),o(_,n,j.callback)}return setTimeout(A),x}function Zi(e){const n={...ko,...e};let o=[];function s(){o=o.filter(r=>r().status==="pending")}function a(r,d,c){const u=wo(n,r,d,(g,p)=>{s(),c&&c(g,p)});return o.push(u),u}function t(r){return o.find(d=>r(d))||null}return{query:a,find:t,setIndex:r=>{n.index=r},getIndex:()=>n.index,cleanup:s}}function $i(){}const di=Object.create(null);function _o(e){if(!di[e]){const n=li(e);if(!n)return;const o=Zi(n),s={config:n,redundancy:o};di[e]=s}return di[e]}function Ao(e,n,o){let s,a;if(typeof e=="string"){const t=ai(e);if(!t)return o(void 0,424),$i;a=t.send;const l=_o(e);l&&(s=l.redundancy)}else{const t=si(e);if(t){s=Zi(t);const l=e.resources?e.resources[0]:"",r=ai(l);r&&(a=r.send)}}return!s||!a?(o(void 0,424),$i):s.query(n,a,o)().abort}function Qi(){}function So(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,go(e)}))}function No(e){const n=[],o=[];return e.forEach(s=>{(s.match(Hi)?n:o).push(s)}),{valid:n,invalid:o}}function Ie(e,n,o){function s(){const a=e.pendingIcons;n.forEach(t=>{a&&a.delete(t),e.icons[t]||e.missing.add(t)})}if(o&&typeof o=="object")try{if(!zi(e,o).length){s();return}}catch(a){console.error(a)}s(),So(e)}function Xi(e,n){e instanceof Promise?e.then(o=>{n(o)}).catch(()=>{n(null)}):n(e)}function jo(e,n){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(n).sort():e.iconsToLoad=n,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:o,prefix:s}=e,a=e.iconsToLoad;if(delete e.iconsToLoad,!a||!a.length)return;const t=e.loadIcon;if(e.loadIcons&&(a.length>1||!t)){Xi(e.loadIcons(a,s,o),u=>{Ie(e,a,u)});return}if(t){a.forEach(u=>{const g=t(u,s,o);Xi(g,p=>{const h=p?{prefix:s,icons:{[u]:p}}:null;Ie(e,[u],h)})});return}const{valid:l,invalid:r}=No(a);if(r.length&&Ie(e,r,null),!l.length)return;const d=s.match(Hi)?ai(o):null;if(!d){Ie(e,l,null);return}d.prepare(o,s,l).forEach(u=>{Ao(o,u,g=>{Ie(e,u.icons,g)})})}))}const Co=(e,n)=>{const o=yo(e,!0,Fi()),s=xo(o);if(!s.pending.length){let d=!0;return n&&setTimeout(()=>{d&&n(s.loaded,s.missing,s.pending,Qi)}),()=>{d=!1}}const a=Object.create(null),t=[];let l,r;return s.pending.forEach(d=>{const{provider:c,prefix:u}=d;if(u===r&&c===l)return;l=c,r=u,t.push(Ce(c,u));const g=a[c]||(a[c]=Object.create(null));g[u]||(g[u]=[])}),s.pending.forEach(d=>{const{provider:c,prefix:u,name:g}=d,p=Ce(c,u),h=p.pendingIcons||(p.pendingIcons=new Set);h.has(g)||(h.add(g),a[c][u].push(g))}),t.forEach(d=>{const c=a[d.provider][d.prefix];c.length&&jo(d,c)}),n?fo(n,s,t):Qi};function Mo(e,n){const o={...e};for(const s in n){const a=n[s],t=typeof a;s in Ui?(a===null||a&&(t==="string"||t==="number"))&&(o[s]=a):t===typeof o[s]&&(o[s]=s==="rotate"?a%4:a)}return o}const To=/[\s,]+/;function Eo(e,n){n.split(To).forEach(o=>{switch(o.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function Bo(e,n=0){const o=e.replace(/^-?[0-9.]*/,"");function s(a){for(;a<0;)a+=4;return a%4}if(o===""){const a=parseInt(e);return isNaN(a)?0:s(a)}else if(o!==e){let a=0;switch(o){case"%":a=25;break;case"deg":a=90}if(a){let t=parseFloat(e.slice(0,e.length-o.length));return isNaN(t)?0:(t=t/a,t%1===0?s(t):0)}}return n}function Lo(e,n){let o=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const s in n)o+=" "+s+'="'+n[s]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+o+">"+e+"</svg>"}function Po(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Oo(e){return"data:image/svg+xml,"+Po(e)}function Io(e){return'url("'+Oo(e)+'")'}let De;function Do(){try{De=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch(e){De=null}}function Ko(e){return De===void 0&&Do(),De?De.createHTML(e):e}const en={...Wi,inline:!1},Go={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},Ro={display:"inline-block"},ri={backgroundColor:"currentColor"},nn={backgroundColor:"transparent"},on={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},an={WebkitMask:ri,mask:ri,background:nn};for(const e in an){const n=an[e];for(const o in on)n[e+o]=on[o]}const zo={...en,inline:!0};function sn(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const Ho=(e,n,o)=>{const s=n.inline?zo:en,a=Mo(s,n),t=n.mode||"svg",l={},r=n.style||{},d={...t==="svg"?Go:{}};if(o){const m=He(o,!1,!0);if(m){const x=["iconify"],w=["provider","prefix"];for(const k of w)m[k]&&x.push("iconify--"+m[k]);d.className=x.join(" ")}}for(let m in n){const x=n[m];if(x!==void 0)switch(m){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":d.ref=x;break;case"className":d[m]=(d[m]?d[m]+" ":"")+x;break;case"inline":case"hFlip":case"vFlip":a[m]=x===!0||x==="true"||x===1;break;case"flip":typeof x=="string"&&Eo(a,x);break;case"color":l.color=x;break;case"rotate":typeof x=="string"?a[m]=Bo(x):typeof x=="number"&&(a[m]=x);break;case"ariaHidden":case"aria-hidden":x!==!0&&x!=="true"&&delete d["aria-hidden"];break;default:s[m]===void 0&&(d[m]=x)}}const c=oo(e,a),u=c.attributes;if(a.inline&&(l.verticalAlign="-0.125em"),t==="svg"){d.style={...l,...r},Object.assign(d,u);let m=0,x=n.id;return typeof x=="string"&&(x=x.replace(/-/g,"_")),d.dangerouslySetInnerHTML={__html:Ko(lo(c.body,x?()=>x+"ID"+m++:"iconifyReact"))},b.createElement("svg",d)}const{body:g,width:p,height:h}=e,y=t==="mask"||(t==="bg"?!1:g.indexOf("currentColor")!==-1),f=Lo(g,{...u,width:p+"",height:h+""});return d.style={...l,"--svg":Io(f),width:sn(u.width),height:sn(u.height),...Ro,...y?ri:nn,...r},b.createElement("span",d)};if(Fi(!0),ro("",po),typeof document!="undefined"&&typeof window!="undefined"){const e=window;if(e.IconifyPreload!==void 0){const n=e.IconifyPreload,o="Invalid IconifyPreload syntax.";typeof n=="object"&&n!==null&&(n instanceof Array?n:[n]).forEach(s=>{try{(typeof s!="object"||s===null||s instanceof Array||typeof s.icons!="object"||typeof s.prefix!="string"||!Zn(s))&&console.error(o)}catch(a){console.error(o)}})}if(e.IconifyProviders!==void 0){const n=e.IconifyProviders;if(typeof n=="object"&&n!==null)for(let o in n){const s="IconifyProviders["+o+"] is invalid.";try{const a=n[o];if(typeof a!="object"||!a||a.resources===void 0)continue;uo(o,a)||console.error(s)}catch(a){console.error(s)}}}}function tn(e){const[n,o]=b.useState(!!e.ssr),[s,a]=b.useState({});function t(h){if(h){const y=e.icon;if(typeof y=="object")return{name:"",data:y};const f=Vi(y);if(f)return{name:y,data:f}}return{name:""}}const[l,r]=b.useState(t(!!e.ssr));function d(){const h=s.callback;h&&(h(),a({}))}function c(h){if(JSON.stringify(l)!==JSON.stringify(h))return d(),r(h),!0}function u(){var h;const y=e.icon;if(typeof y=="object"){c({name:"",data:y});return}const f=Vi(y);if(c({name:y,data:f}))if(f===void 0){const m=Co([y],u);a({callback:m})}else f&&((h=e.onLoad)===null||h===void 0||h.call(e,y))}b.useEffect(()=>(o(!0),d),[]),b.useEffect(()=>{n&&u()},[e.icon,n]);const{name:g,data:p}=l;return p?Ho({...ei,...p},e,g):e.children?e.children:e.fallback?e.fallback:b.createElement("span",{})}const ln=b.forwardRef((e,n)=>tn({...e,_ref:n}));b.forwardRef((e,n)=>tn({inline:!0,...e,_ref:n}));function F({icon:e,iconClass:n}){return i.jsx(i.Fragment,{children:i.jsx(ln,{icon:e,className:n})})}function ui({element:e,validationData:n,placeholder:o}){var u;const[s,a]=b.useState([]),{register:t=()=>({}),setValue:l,isReadOnly:r,watch:d}=n||{},c=b.useMemo(()=>s==null?void 0:s.map(g=>g.label).join(", "),[s]);return b.useEffect(()=>{t(e.id)},[e.id,t]),b.useEffect(()=>{if(d){const g=d(p=>{a(p[e.id])});return()=>{var p;return(p=g.unsubscribe)==null?void 0:p.call(g)}}},[d,e.id]),i.jsx("div",{className:"custom-select",children:i.jsx(K.Listbox,{value:s,onChange:g=>{a(g),l==null||l(e.id,g)},multiple:!0,disabled:r,by:"value",children:i.jsxs("div",{className:"custom-select__wrapper",children:[i.jsxs(K.Listbox.Button,{className:"custom-select__control field-control",disabled:r,children:[i.jsx("span",{className:"custom-select__value",children:s.length>0?c:i.jsx("span",{className:"custom-select__placeholder",children:o!=null?o:" Select options"})}),i.jsx("span",{className:"custom-select__icon",children:i.jsx(F,{icon:"lucide:chevron-down"})})]}),i.jsx(K.Transition,{as:b.Fragment,leave:"custom-select__transition",children:i.jsx(K.Listbox.Options,{anchor:"bottom start",className:"custom-select__options",children:(u=e==null?void 0:e.options)==null?void 0:u.map((g,p)=>i.jsx(K.Listbox.Option,{value:g,className:({active:h})=>`custom-select__option ${h?"custom-select__option--active":""}`,children:({selected:h})=>i.jsxs("div",{className:"custom-select__option-row",children:[i.jsx("span",{className:`custom-select__option-label ${h?"custom-select__option--selected":""}`,children:g.label}),h&&i.jsx("span",{className:"custom-select__check",children:"✓"})]})},p))})})]})})})}const Fo=["jpg","jpeg","png","gif","bmp","webp","svg","image"],Vo=(e="")=>{var o;const n=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return Fo.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"},Uo={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 dn({fileUrl:e,fileName:n,removeFile:o}){const[s,a]=b.useState(!1),[t,l]=b.useState("unknown"),[r,d]=b.useState(null);b.useEffect(()=>{e&&l(Vo(e))},[e]),b.useEffect(()=>{if(t==="pdf"&&(e!=null&&e.startsWith("data:")))try{const h=atob(e.split(",")[1]),y=new ArrayBuffer(h.length),f=new Uint8Array(y);for(let w=0;w<h.length;w++)f[w]=h.charCodeAt(w);const m=new Blob([y],{type:"application/pdf"}),x=URL.createObjectURL(m);return d(x),()=>URL.revokeObjectURL(x)}catch(h){console.error("Error creating blob URL:",h)}else d(null)},[e,t]);const c=()=>{t==="image"||t==="pdf"?a(!0):window.open(r||e,"_blank")},u=()=>a(!1),g=n||(e==null?void 0:e.split("/").pop())||"Unknown file";function p(h,y="download"){if(!h)return;if(h.startsWith("data:")){const m=document.createElement("a");m.href=h,m.download=y,document.body.appendChild(m),m.click(),document.body.removeChild(m);return}const f=document.createElement("a");f.href=h,f.setAttribute("download",y),document.body.appendChild(f),f.click(),document.body.removeChild(f)}return i.jsxs("div",{className:"mt-2 field-control !py-1 !bg-gray-50 !flex justify-between gap-x-8 items-center",children:[i.jsxs("div",{onClick:c,className:"!flex items-center rounded cursor-pointer gap-x-3",title:`Click to preview ${g}`,children:[t==="image"&&i.jsx("div",{className:"flex items-center justify-center ",children:i.jsx(F,{iconClass:"text-4xl",icon:"fluent-color:image-48"})}),t!=="image"&&i.jsx(F,{icon:Uo[t],iconClass:"text-4xl"}),i.jsx("span",{className:"text-sm font-semibold text-center text-gray-700 truncate max-w-[300px]",children:g})]}),i.jsxs("div",{className:"flex gap-x-1 items-center",children:[i.jsx("button",{type:"button",className:"p-2",onClick:()=>p(r||e,n),title:`Download ${g}`,children:i.jsx(F,{icon:"streamline-flex:download-tray-solid"})}),o&&i.jsx("button",{type:"button",className:"p-2 text-lg text-red-500",onClick:o,children:i.jsx(F,{icon:"lets-icons:trash-duotone"})})]}),s&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",onClick:u,children:i.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:[i.jsx("button",{onClick:u,className:"absolute text-2xl font-bold text-gray-700 top-2 right-2","aria-label":"Close preview",children:"×"}),t==="image"?i.jsx("img",{src:e,alt:g,className:"max-w-full max-h-[80vh] mx-auto object-contain"}):t==="pdf"?i.jsx("iframe",{src:r||e,title:g,className:"w-full h-[80vh] rounded border"}):null]})})]})}const ue=e=>{const n=typeof window!="undefined"?localStorage.getItem(e):"";try{return JSON.parse(n)}catch(o){return n}},rn=(e,n)=>{const o=typeof n!="string"?JSON.stringify(n):n;return localStorage.setItem(e,o)},Wo=5*1024*1024;function Jo({onFileLoaded:e,disabled:n=!1,handleDeleteFile:o,multiple:s=!1,list:a=null,accept:t=[]}){const{uploadUrl:l}=b.useContext(le),r=b.useRef(null),[d,c]=b.useState(a),[u,g]=b.useState(!1);b.useEffect(()=>{c(a)},[a]);const p=b.useMemo(()=>t==null?void 0:t.map(S=>S.value).join(", "),[t]),h=b.useMemo(()=>t==null?void 0:t.map(S=>S.label).join(", "),[t]),y=b.useCallback(async S=>{var _;const A=ue("token");try{const{data:j}=await je.post(l,S,{headers:{Authorization:`Bearer ${A}`}});return(_=j==null?void 0:j.data)==null?void 0:_.url}catch(j){throw console.error("File upload error:",j),new Error("Failed to upload file to server")}},[l]),f=b.useCallback(S=>new Promise((A,_)=>{const j=new FileReader;j.onloadend=async()=>{try{const L=j.result.replace(/^data:.*;base64,/,""),Q=l?await y({base64:L,ext:`.${S.name.split(".").pop()}`,fileName:S.name}):j.result;A({base64:Q,type:S.type,name:S.name})}catch(L){_(L)}},j.onerror=()=>_(new Error("File read failed")),j.readAsDataURL(S)}),[l,y]),m=b.useCallback(S=>{var _;const A=p?(_=p.split(","))==null?void 0:_.map(j=>j.trim()):[];for(const j of S){if(j.size>Wo)return me.toast.error(`File "${j.name}" exceeds 5MB limit (${(j.size/1024/1024).toFixed(2)}MB)`),!1;if(A.length&&!A.some(L=>j.type===L||j.name.toLowerCase().endsWith(L.replace("*",""))))return me.toast.error(`File "${j.name}" is not an allowed type. Allowed: ${h||"any"}`),!1}return!0},[p,h]),x=b.useCallback(async S=>{const A=Array.from(S.target.files||[]);if(!(!A.length||u)){if(!m(A)){r.current&&(r.current.value="");return}try{g(!0);const _=await Promise.all(A==null?void 0:A.map(f));c(j=>{const L=s&&j?[...j,..._]:_;return e(L),L}),me.toast.success(`Successfully uploaded ${A.length} file(s)`)}catch(_){console.error("Upload error:",_),me.toast.error("Failed to upload file(s). Please try again.")}finally{g(!1),r.current&&(r.current.value="")}}},[u,m,f,e,s]),w=b.useCallback(S=>{u||(r.current&&(r.current.value=""),c(A=>{const _=S===void 0?null:(A==null?void 0:A.filter((j,L)=>L!==S))||null;return e(_),_}),o==null||o())},[o,e,u]),k=d&&d.length>0;return i.jsxs("div",{className:"flex flex-col items-start gap-2",children:[!n&&i.jsxs("div",{className:"!flex field-control !py-0 !px-0 relative",children:[i.jsx("input",{ref:r,type:"file",onChange:x,disabled:n||u,multiple:s,accept:p||"",className:`w-full text-sm text-gray-500 file:mr-4 flex-1 file:px-4 !py-1 !pl-1\r
31
+ <%s key={someKey} {...props} />`,Si,Ne,Gs,Ne),En[Ne+Si]=!0}}return v===s?Ps(ae):Ls(ae),ae}}function Os(v,N,C){return Bn(v,N,C,!0)}function Is(v,N,C){return Bn(v,N,C,!1)}var Ds=Is,Ks=Os;Le.Fragment=s,Le.jsx=Ds,Le.jsxs=Ks}()),Le}var Bi;function Rn(){return Bi||(Bi=1,process.env.NODE_ENV==="production"?Re.exports=Kn():Re.exports=Gn()),Re.exports}var i=Rn();const le=b.createContext(void 0),Li={title:"",description:"",id:be.v4(),questionData:[],disabled:!1},Pi=({children:e})=>{const[n,o]=b.useState({}),[s,a]=b.useState({}),[t,l]=b.useState([Li]),[r,d]=b.useState(!1),[c,u]=b.useState(null),[g,p]=b.useState([0]),[h,y]=b.useState(""),f=b.useCallback(()=>{},[]),m=b.useCallback(()=>{const D=be.v4();l(M=>[...M,{...Li,id:D}]),u(D),p([t.length])},[t]),x=b.useCallback(D=>{l(M=>M.filter(T=>T.id!==D)),u(null)},[]),w=b.useCallback((D,M)=>{const T=t.find(I=>I.id===M),B=T==null?void 0:T.questionData.find(I=>I.id===D);B&&l(I=>I==null?void 0:I.map(Y=>Y.id===M?{...Y,questionData:Y.questionData.filter(J=>B.type==="grid"?J.gridId!==B.id&&J.id!==B.id:J.id!==D)}:Y))},[t,l]),k=b.useCallback((D,M)=>{const T=t.find(J=>J.id===M);if(!T)return;const B=T.questionData.findIndex(J=>J.id===D);if(B===-1)return;const I=T.questionData[B],Y=(J,oe={})=>({...JSON.parse(JSON.stringify(J)),id:be.v4(),...oe});l(J=>J==null?void 0:J.map(oe=>{var se;if(oe.id!==M)return oe;const O=[...oe.questionData];if(I.type==="grid"){const ve=(se=O==null?void 0:O.map((Z,de)=>({e:Z,i:de})).filter(({e:Z})=>Z.id===I.id||Z.gridId===I.id))==null?void 0:se.map(({i:Z})=>Z),pe=ve.length?Math.max(...ve)+1:B+1,fe=be.v4(),xe=Y(I,{});xe.id=fe;const R=O.filter(Z=>Z.gridId===I.id),z=R==null?void 0:R.map(Z=>Y(Z,{gridId:fe})),te=[...O.slice(0,pe),xe,...z,...O.slice(pe)];return{...oe,questionData:te}}else{const ve=Y(I,I.gridId?{gridId:I.gridId}:{}),pe=[...O.slice(0,B+1),ve,...O.slice(B+1)];return{...oe,questionData:pe}}}))},[t,l]),S=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>B.id===M?{...B,questionData:D}:B))},[]),A=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>B.id===M?{...B,questionData:[...B.questionData,D]}:B))},[]),_=b.useCallback((D,M,T)=>{l(B=>B==null?void 0:B.map(I=>I.id===M?{...I,questionData:[...I.questionData.slice(0,T),D,...I.questionData.slice(T)]}:I))},[]),j=b.useCallback((D,M,T)=>{l(B=>B==null?void 0:B.map(I=>{var Y;return I.id===T?{...I,questionData:(Y=I.questionData)==null?void 0:Y.map(J=>{var oe;return J.type==="grid"&&J.gridData?{...J,gridData:(oe=J.gridData)==null?void 0:oe.map((O,se)=>se===D?{...O,...M}:O).concat(D>=J.gridData.length?{...M}:[])}:J})}:I}))},[]),L=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>{var I;return B.id===M?{...B,questionData:(I=B.questionData)==null?void 0:I.map(Y=>Y.id===D.id?{...Y,...D}:Y)}:B}))},[]),Q=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>B.id===M?{...B,...D}:B))},[]),W=b.useMemo(()=>({formData:t,setFormData:l,handleDragStop:f,removeElement:w,elementData:s,setElementData:a,updateElementPosition:S,addElement:A,addElementInPosition:_,updateElement:L,addSection:m,removeSection:x,updateSection:Q,isDragging:r,setIsDragging:d,selectedSection:c,setSelectedSection:u,activeSections:g,setActiveSections:p,updateGridElement:j,answerData:n,setAnswerData:o,uploadUrl:h,setUploadUrl:y,duplicateElement:k}),[t,f,w,s,S,A,_,L,m,x,Q,r,c,g,j,n,h,k]);return i.jsx(le.Provider,{value:W,children:e})};function Oi(e){var n,o,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(n=0;n<a;n++)e[n]&&(o=Oi(e[n]))&&(s&&(s+=" "),s+=o)}else for(o in e)e[o]&&(s&&(s+=" "),s+=o);return s}function V(){for(var e,n,o=0,s="",a=arguments.length;o<a;o++)(e=arguments[o])&&(n=Oi(e))&&(s&&(s+=" "),s+=n);return s}function zn({type:e="calendar",className:n}){return i.jsx(i.Fragment,{children:e==="calendar"?i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[i.jsx("path",{d:"M6.66406 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M13.3359 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M2.91406 7.57495H17.0807",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.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"}),i.jsx("path",{d:"M13.0762 11.4167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M13.0762 13.9167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M9.99803 11.4167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M9.99803 13.9167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M6.91209 11.4167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M6.91209 13.9167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[i.jsx("path",{d:"M10 6.66663V10.8333",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),i.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"}),i.jsx("path",{d:"M7.5 1.66663H12.5",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.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 Qe=({value:e=null,onGetValue:n,readOnly:o=!1,dateFormat:s="dd/MM/yyyy",name:a,placeholder:t="Select date",minDate:l,maxDate:r,showYearDropdown:d})=>{const c=e?new Date(e):null,[u,g]=b.useState(c);b.useEffect(()=>{const h=e?new Date(e):null;(h&&u&&h.getTime()!==u.getTime()||!h&&u||h&&!u)&&g(h)},[e]),b.useEffect(()=>{n&&n(a,u)},[u,n,a]);const p=h=>{g(h)};return i.jsx("div",{className:"builder_date__picker",children:i.jsx(Ln,{showIcon:!0,icon:i.jsx(zn,{className:"react-datepicker__calendar-icon"}),showPopperArrow:!1,dateFormat:s,disabled:o,selected:u,onChange:p,className:"field-control",portalId:"root-portal",placeholderText:t,minDate:l,maxDate:r,showYearDropdown:d,scrollableYearDropdown:!0,yearDropdownItemNumber:40})})};function Hn({element:e,validationData:n}){const{register:o=()=>({}),setValue:s,watch:a}=n||{};let t;return a&&(t=a()[e.id]),b.useEffect(()=>{o(e.id)},[e.id]),i.jsx(Qe,{name:e.id,value:t,onGetValue:s,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 Xe({element:e,validationData:n}){var s;const{register:o=()=>({})}=n||{};return i.jsx("div",{children:i.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"",type:(e==null?void 0:e.inputType)||"text",className:V("field-control",e==null?void 0:e.customClass),...o(e==null?void 0:e.id),disabled:n==null?void 0:n.isReadOnly,inputMode:(e==null?void 0:e.inputMode)||void 0,"aria-invalid":!!((s=n==null?void 0:n.errors)!=null&&s[e==null?void 0:e.id]),pattern:(e==null?void 0:e.pattern)||void 0})})}function Fn(e,n){const o=e.icons,s=e.aliases||Object.create(null),a=Object.create(null);function t(l){if(o[l])return a[l]=[];if(!(l in a)){a[l]=null;const r=s[l]&&s[l].parent,d=r&&t(r);d&&(a[l]=[r].concat(d))}return a[l]}return Object.keys(o).concat(Object.keys(s)).forEach(t),a}const Ii=Object.freeze({left:0,top:0,width:16,height:16}),ze=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),ei=Object.freeze({...Ii,...ze}),ii=Object.freeze({...ei,body:"",hidden:!1});function Vn(e,n){const o={};!e.hFlip!=!n.hFlip&&(o.hFlip=!0),!e.vFlip!=!n.vFlip&&(o.vFlip=!0);const s=((e.rotate||0)+(n.rotate||0))%4;return s&&(o.rotate=s),o}function Di(e,n){const o=Vn(e,n);for(const s in ii)s in ze?s in e&&!(s in o)&&(o[s]=ze[s]):s in n?o[s]=n[s]:s in e&&(o[s]=e[s]);return o}function Un(e,n,o){const s=e.icons,a=e.aliases||Object.create(null);let t={};function l(r){t=Di(s[r]||a[r],t)}return l(n),o.forEach(l),Di(e,t)}function Ki(e,n){const o=[];if(typeof e!="object"||typeof e.icons!="object")return o;e.not_found instanceof Array&&e.not_found.forEach(a=>{n(a,null),o.push(a)});const s=Fn(e);for(const a in s){const t=s[a];t&&(n(a,Un(e,a,t)),o.push(a))}return o}const Wn={provider:"",aliases:{},not_found:{},...Ii};function ni(e,n){for(const o in n)if(o in e&&typeof e[o]!=typeof n[o])return!1;return!0}function Gi(e){if(typeof e!="object"||e===null)return null;const n=e;if(typeof n.prefix!="string"||!e.icons||typeof e.icons!="object"||!ni(e,Wn))return null;const o=n.icons;for(const a in o){const t=o[a];if(!a||typeof t.body!="string"||!ni(t,ii))return null}const s=n.aliases||Object.create(null);for(const a in s){const t=s[a],l=t.parent;if(!a||typeof l!="string"||!o[l]&&!s[l]||!ni(t,ii))return null}return n}const Ri=Object.create(null);function Jn(e,n){return{provider:e,prefix:n,icons:Object.create(null),missing:new Set}}function Ce(e,n){const o=Ri[e]||(Ri[e]=Object.create(null));return o[n]||(o[n]=Jn(e,n))}function zi(e,n){return Gi(n)?Ki(n,(o,s)=>{s?e.icons[o]=s:e.missing.add(o)}):[]}function qn(e,n,o){try{if(typeof o.body=="string")return e.icons[n]={...o},!0}catch(s){}return!1}const Hi=/^[a-z0-9]+(-[a-z0-9]+)*$/,He=(e,n,o,s="")=>{const a=e.split(":");if(e.slice(0,1)==="@"){if(a.length<2||a.length>3)return null;s=a.shift().slice(1)}if(a.length>3||!a.length)return null;if(a.length>1){const r=a.pop(),d=a.pop(),c={provider:a.length>0?a[0]:s,prefix:d,name:r};return n&&!Fe(c)?null:c}const t=a[0],l=t.split("-");if(l.length>1){const r={provider:s,prefix:l.shift(),name:l.join("-")};return n&&!Fe(r)?null:r}if(o&&s===""){const r={provider:s,prefix:"",name:t};return n&&!Fe(r,o)?null:r}return null},Fe=(e,n)=>e?!!((n&&e.prefix===""||e.prefix)&&e.name):!1;let Pe=!1;function Fi(e){return typeof e=="boolean"&&(Pe=e),Pe}function Vi(e){const n=typeof e=="string"?He(e,!0,Pe):e;if(n){const o=Ce(n.provider,n.prefix),s=n.name;return o.icons[s]||(o.missing.has(s)?null:void 0)}}function Yn(e,n){const o=He(e,!0,Pe);if(!o)return!1;const s=Ce(o.provider,o.prefix);return n?qn(s,o.name,n):(s.missing.add(o.name),!0)}function Zn(e,n){if(typeof e!="object")return!1;if(typeof n!="string"&&(n=e.provider||""),Pe&&!n&&!e.prefix){let a=!1;return Gi(e)&&(e.prefix="",Ki(e,(t,l)=>{Yn(t,l)&&(a=!0)})),a}const o=e.prefix;if(!Fe({prefix:o,name:"a"}))return!1;const s=Ce(n,o);return!!zi(s,e)}const Ui=Object.freeze({width:null,height:null}),Wi=Object.freeze({...Ui,...ze}),$n=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Qn=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Ji(e,n,o){if(n===1)return e;if(o=o||100,typeof e=="number")return Math.ceil(e*n*o)/o;if(typeof e!="string")return e;const s=e.split($n);if(s===null||!s.length)return e;const a=[];let t=s.shift(),l=Qn.test(t);for(;;){if(l){const r=parseFloat(t);isNaN(r)?a.push(t):a.push(Math.ceil(r*n*o)/o)}else a.push(t);if(t=s.shift(),t===void 0)return a.join("");l=!l}}function Xn(e,n="defs"){let o="";const s=e.indexOf("<"+n);for(;s>=0;){const a=e.indexOf(">",s),t=e.indexOf("</"+n);if(a===-1||t===-1)break;const l=e.indexOf(">",t);if(l===-1)break;o+=e.slice(a+1,t).trim(),e=e.slice(0,s).trim()+e.slice(l+1)}return{defs:o,content:e}}function eo(e,n){return e?"<defs>"+e+"</defs>"+n:n}function io(e,n,o){const s=Xn(e);return eo(s.defs,n+s.content+o)}const no=e=>e==="unset"||e==="undefined"||e==="none";function oo(e,n){const o={...ei,...e},s={...Wi,...n},a={left:o.left,top:o.top,width:o.width,height:o.height};let t=o.body;[o,s].forEach(f=>{const m=[],x=f.hFlip,w=f.vFlip;let k=f.rotate;x?w?k+=2:(m.push("translate("+(a.width+a.left).toString()+" "+(0-a.top).toString()+")"),m.push("scale(-1 1)"),a.top=a.left=0):w&&(m.push("translate("+(0-a.left).toString()+" "+(a.height+a.top).toString()+")"),m.push("scale(1 -1)"),a.top=a.left=0);let S;switch(k<0&&(k-=Math.floor(k/4)*4),k=k%4,k){case 1:S=a.height/2+a.top,m.unshift("rotate(90 "+S.toString()+" "+S.toString()+")");break;case 2:m.unshift("rotate(180 "+(a.width/2+a.left).toString()+" "+(a.height/2+a.top).toString()+")");break;case 3:S=a.width/2+a.left,m.unshift("rotate(-90 "+S.toString()+" "+S.toString()+")");break}k%2===1&&(a.left!==a.top&&(S=a.left,a.left=a.top,a.top=S),a.width!==a.height&&(S=a.width,a.width=a.height,a.height=S)),m.length&&(t=io(t,'<g transform="'+m.join(" ")+'">',"</g>"))});const l=s.width,r=s.height,d=a.width,c=a.height;let u,g;l===null?(g=r===null?"1em":r==="auto"?c:r,u=Ji(g,d/c)):(u=l==="auto"?d:l,g=r===null?Ji(u,c/d):r==="auto"?c:r);const p={},h=(f,m)=>{no(m)||(p[f]=m.toString())};h("width",u),h("height",g);const y=[a.left,a.top,d,c];return p.viewBox=y.join(" "),{attributes:p,viewBox:y,body:t}}const ao=/\sid="(\S+)"/g,so="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let to=0;function lo(e,n=so){const o=[];let s;for(;s=ao.exec(e);)o.push(s[1]);if(!o.length)return e;const a="suffix"+(Math.random()*16777216|Date.now()).toString(16);return o.forEach(t=>{const l=typeof n=="function"?n(t):n+(to++).toString(),r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+r+')([")]|\\.[a-z])',"g"),"$1"+l+a+"$3")}),e=e.replace(new RegExp(a,"g"),""),e}const oi=Object.create(null);function ro(e,n){oi[e]=n}function ai(e){return oi[e]||oi[""]}function si(e){let n;if(typeof e.resources=="string")n=[e.resources];else if(n=e.resources,!(n instanceof Array)||!n.length)return null;return{resources:n,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const ti=Object.create(null),Oe=["https://api.simplesvg.com","https://api.unisvg.com"],Ve=[];for(;Oe.length>0;)Oe.length===1||Math.random()>.5?Ve.push(Oe.shift()):Ve.push(Oe.pop());ti[""]=si({resources:["https://api.iconify.design"].concat(Ve)});function uo(e,n){const o=si(n);return o===null?!1:(ti[e]=o,!0)}function li(e){return ti[e]}let qi=(()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch(n){}})();function co(e,n){const o=li(e);if(!o)return 0;let s;if(!o.maxURL)s=0;else{let a=0;o.resources.forEach(l=>{a=Math.max(a,l.length)});const t=n+".json?icons=";s=o.maxURL-a-o.path.length-t.length}return s}function mo(e){return e===404}const bo=(e,n,o)=>{const s=[],a=co(e,n),t="icons";let l={type:t,provider:e,prefix:n,icons:[]},r=0;return o.forEach((d,c)=>{r+=d.length+1,r>=a&&c>0&&(s.push(l),l={type:t,provider:e,prefix:n,icons:[]},r=d.length),l.icons.push(d)}),s.push(l),s};function vo(e){if(typeof e=="string"){const n=li(e);if(n)return n.path}return"/"}const po={prepare:bo,send:(e,n,o)=>{if(!qi){o("abort",424);return}let s=vo(n.provider);switch(n.type){case"icons":{const t=n.prefix,r=n.icons.join(","),d=new URLSearchParams({icons:r});s+=t+".json?"+d.toString();break}case"custom":{const t=n.uri;s+=t.slice(0,1)==="/"?t.slice(1):t;break}default:o("abort",400);return}let a=503;qi(e+s).then(t=>{const l=t.status;if(l!==200){setTimeout(()=>{o(mo(l)?"abort":"next",l)});return}return a=501,t.json()}).then(t=>{if(typeof t!="object"||t===null){setTimeout(()=>{t===404?o("abort",t):o("next",a)});return}setTimeout(()=>{o("success",t)})}).catch(()=>{o("next",a)})}};function Yi(e,n){e.forEach(o=>{const s=o.loaderCallbacks;s&&(o.loaderCallbacks=s.filter(a=>a.id!==n))})}function go(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const n=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!n.length)return;let o=!1;const s=e.provider,a=e.prefix;n.forEach(t=>{const l=t.icons,r=l.pending.length;l.pending=l.pending.filter(d=>{if(d.prefix!==a)return!0;const c=d.name;if(e.icons[c])l.loaded.push({provider:s,prefix:a,name:c});else if(e.missing.has(c))l.missing.push({provider:s,prefix:a,name:c});else return o=!0,!0;return!1}),l.pending.length!==r&&(o||Yi([e],t.id),t.callback(l.loaded.slice(0),l.missing.slice(0),l.pending.slice(0),t.abort))})}))}let ho=0;function fo(e,n,o){const s=ho++,a=Yi.bind(null,o,s);if(!n.pending.length)return a;const t={id:s,icons:n,callback:e,abort:a};return o.forEach(l=>{(l.loaderCallbacks||(l.loaderCallbacks=[])).push(t)}),a}function xo(e){const n={loaded:[],missing:[],pending:[]},o=Object.create(null);e.sort((a,t)=>a.provider!==t.provider?a.provider.localeCompare(t.provider):a.prefix!==t.prefix?a.prefix.localeCompare(t.prefix):a.name.localeCompare(t.name));let s={provider:"",prefix:"",name:""};return e.forEach(a=>{if(s.name===a.name&&s.prefix===a.prefix&&s.provider===a.provider)return;s=a;const t=a.provider,l=a.prefix,r=a.name,d=o[t]||(o[t]=Object.create(null)),c=d[l]||(d[l]=Ce(t,l));let u;r in c.icons?u=n.loaded:l===""||c.missing.has(r)?u=n.missing:u=n.pending;const g={provider:t,prefix:l,name:r};u.push(g)}),n}function yo(e,n=!0,o=!1){const s=[];return e.forEach(a=>{const t=typeof a=="string"?He(a,n,o):a;t&&s.push(t)}),s}const ko={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function wo(e,n,o,s){const a=e.resources.length,t=e.random?Math.floor(Math.random()*a):e.index;let l;if(e.random){let _=e.resources.slice(0);for(l=[];_.length>1;){const j=Math.floor(Math.random()*_.length);l.push(_[j]),_=_.slice(0,j).concat(_.slice(j+1))}l=l.concat(_)}else l=e.resources.slice(t).concat(e.resources.slice(0,t));const r=Date.now();let d="pending",c=0,u,g=null,p=[],h=[];typeof s=="function"&&h.push(s);function y(){g&&(clearTimeout(g),g=null)}function f(){d==="pending"&&(d="aborted"),y(),p.forEach(_=>{_.status==="pending"&&(_.status="aborted")}),p=[]}function m(_,j){j&&(h=[]),typeof _=="function"&&h.push(_)}function x(){return{startTime:r,payload:n,status:d,queriesSent:c,queriesPending:p.length,subscribe:m,abort:f}}function w(){d="failed",h.forEach(_=>{_(void 0,u)})}function k(){p.forEach(_=>{_.status==="pending"&&(_.status="aborted")}),p=[]}function S(_,j,L){const Q=j!=="success";switch(p=p.filter(W=>W!==_),d){case"pending":break;case"failed":if(Q||!e.dataAfterTimeout)return;break;default:return}if(j==="abort"){u=L,w();return}if(Q){u=L,p.length||(l.length?A():w());return}if(y(),k(),!e.random){const W=e.resources.indexOf(_.resource);W!==-1&&W!==e.index&&(e.index=W)}d="completed",h.forEach(W=>{W(L)})}function A(){if(d!=="pending")return;y();const _=l.shift();if(_===void 0){if(p.length){g=setTimeout(()=>{y(),d==="pending"&&(k(),w())},e.timeout);return}w();return}const j={status:"pending",resource:_,callback:(L,Q)=>{S(j,L,Q)}};p.push(j),c++,g=setTimeout(A,e.rotate),o(_,n,j.callback)}return setTimeout(A),x}function Zi(e){const n={...ko,...e};let o=[];function s(){o=o.filter(r=>r().status==="pending")}function a(r,d,c){const u=wo(n,r,d,(g,p)=>{s(),c&&c(g,p)});return o.push(u),u}function t(r){return o.find(d=>r(d))||null}return{query:a,find:t,setIndex:r=>{n.index=r},getIndex:()=>n.index,cleanup:s}}function $i(){}const di=Object.create(null);function _o(e){if(!di[e]){const n=li(e);if(!n)return;const o=Zi(n),s={config:n,redundancy:o};di[e]=s}return di[e]}function Ao(e,n,o){let s,a;if(typeof e=="string"){const t=ai(e);if(!t)return o(void 0,424),$i;a=t.send;const l=_o(e);l&&(s=l.redundancy)}else{const t=si(e);if(t){s=Zi(t);const l=e.resources?e.resources[0]:"",r=ai(l);r&&(a=r.send)}}return!s||!a?(o(void 0,424),$i):s.query(n,a,o)().abort}function Qi(){}function So(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,go(e)}))}function No(e){const n=[],o=[];return e.forEach(s=>{(s.match(Hi)?n:o).push(s)}),{valid:n,invalid:o}}function Ie(e,n,o){function s(){const a=e.pendingIcons;n.forEach(t=>{a&&a.delete(t),e.icons[t]||e.missing.add(t)})}if(o&&typeof o=="object")try{if(!zi(e,o).length){s();return}}catch(a){console.error(a)}s(),So(e)}function Xi(e,n){e instanceof Promise?e.then(o=>{n(o)}).catch(()=>{n(null)}):n(e)}function jo(e,n){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(n).sort():e.iconsToLoad=n,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:o,prefix:s}=e,a=e.iconsToLoad;if(delete e.iconsToLoad,!a||!a.length)return;const t=e.loadIcon;if(e.loadIcons&&(a.length>1||!t)){Xi(e.loadIcons(a,s,o),u=>{Ie(e,a,u)});return}if(t){a.forEach(u=>{const g=t(u,s,o);Xi(g,p=>{const h=p?{prefix:s,icons:{[u]:p}}:null;Ie(e,[u],h)})});return}const{valid:l,invalid:r}=No(a);if(r.length&&Ie(e,r,null),!l.length)return;const d=s.match(Hi)?ai(o):null;if(!d){Ie(e,l,null);return}d.prepare(o,s,l).forEach(u=>{Ao(o,u,g=>{Ie(e,u.icons,g)})})}))}const Co=(e,n)=>{const o=yo(e,!0,Fi()),s=xo(o);if(!s.pending.length){let d=!0;return n&&setTimeout(()=>{d&&n(s.loaded,s.missing,s.pending,Qi)}),()=>{d=!1}}const a=Object.create(null),t=[];let l,r;return s.pending.forEach(d=>{const{provider:c,prefix:u}=d;if(u===r&&c===l)return;l=c,r=u,t.push(Ce(c,u));const g=a[c]||(a[c]=Object.create(null));g[u]||(g[u]=[])}),s.pending.forEach(d=>{const{provider:c,prefix:u,name:g}=d,p=Ce(c,u),h=p.pendingIcons||(p.pendingIcons=new Set);h.has(g)||(h.add(g),a[c][u].push(g))}),t.forEach(d=>{const c=a[d.provider][d.prefix];c.length&&jo(d,c)}),n?fo(n,s,t):Qi};function Mo(e,n){const o={...e};for(const s in n){const a=n[s],t=typeof a;s in Ui?(a===null||a&&(t==="string"||t==="number"))&&(o[s]=a):t===typeof o[s]&&(o[s]=s==="rotate"?a%4:a)}return o}const To=/[\s,]+/;function Eo(e,n){n.split(To).forEach(o=>{switch(o.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function Bo(e,n=0){const o=e.replace(/^-?[0-9.]*/,"");function s(a){for(;a<0;)a+=4;return a%4}if(o===""){const a=parseInt(e);return isNaN(a)?0:s(a)}else if(o!==e){let a=0;switch(o){case"%":a=25;break;case"deg":a=90}if(a){let t=parseFloat(e.slice(0,e.length-o.length));return isNaN(t)?0:(t=t/a,t%1===0?s(t):0)}}return n}function Lo(e,n){let o=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const s in n)o+=" "+s+'="'+n[s]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+o+">"+e+"</svg>"}function Po(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Oo(e){return"data:image/svg+xml,"+Po(e)}function Io(e){return'url("'+Oo(e)+'")'}let De;function Do(){try{De=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch(e){De=null}}function Ko(e){return De===void 0&&Do(),De?De.createHTML(e):e}const en={...Wi,inline:!1},Go={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},Ro={display:"inline-block"},ri={backgroundColor:"currentColor"},nn={backgroundColor:"transparent"},on={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},an={WebkitMask:ri,mask:ri,background:nn};for(const e in an){const n=an[e];for(const o in on)n[e+o]=on[o]}const zo={...en,inline:!0};function sn(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const Ho=(e,n,o)=>{const s=n.inline?zo:en,a=Mo(s,n),t=n.mode||"svg",l={},r=n.style||{},d={...t==="svg"?Go:{}};if(o){const m=He(o,!1,!0);if(m){const x=["iconify"],w=["provider","prefix"];for(const k of w)m[k]&&x.push("iconify--"+m[k]);d.className=x.join(" ")}}for(let m in n){const x=n[m];if(x!==void 0)switch(m){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":d.ref=x;break;case"className":d[m]=(d[m]?d[m]+" ":"")+x;break;case"inline":case"hFlip":case"vFlip":a[m]=x===!0||x==="true"||x===1;break;case"flip":typeof x=="string"&&Eo(a,x);break;case"color":l.color=x;break;case"rotate":typeof x=="string"?a[m]=Bo(x):typeof x=="number"&&(a[m]=x);break;case"ariaHidden":case"aria-hidden":x!==!0&&x!=="true"&&delete d["aria-hidden"];break;default:s[m]===void 0&&(d[m]=x)}}const c=oo(e,a),u=c.attributes;if(a.inline&&(l.verticalAlign="-0.125em"),t==="svg"){d.style={...l,...r},Object.assign(d,u);let m=0,x=n.id;return typeof x=="string"&&(x=x.replace(/-/g,"_")),d.dangerouslySetInnerHTML={__html:Ko(lo(c.body,x?()=>x+"ID"+m++:"iconifyReact"))},b.createElement("svg",d)}const{body:g,width:p,height:h}=e,y=t==="mask"||(t==="bg"?!1:g.indexOf("currentColor")!==-1),f=Lo(g,{...u,width:p+"",height:h+""});return d.style={...l,"--svg":Io(f),width:sn(u.width),height:sn(u.height),...Ro,...y?ri:nn,...r},b.createElement("span",d)};if(Fi(!0),ro("",po),typeof document!="undefined"&&typeof window!="undefined"){const e=window;if(e.IconifyPreload!==void 0){const n=e.IconifyPreload,o="Invalid IconifyPreload syntax.";typeof n=="object"&&n!==null&&(n instanceof Array?n:[n]).forEach(s=>{try{(typeof s!="object"||s===null||s instanceof Array||typeof s.icons!="object"||typeof s.prefix!="string"||!Zn(s))&&console.error(o)}catch(a){console.error(o)}})}if(e.IconifyProviders!==void 0){const n=e.IconifyProviders;if(typeof n=="object"&&n!==null)for(let o in n){const s="IconifyProviders["+o+"] is invalid.";try{const a=n[o];if(typeof a!="object"||!a||a.resources===void 0)continue;uo(o,a)||console.error(s)}catch(a){console.error(s)}}}}function tn(e){const[n,o]=b.useState(!!e.ssr),[s,a]=b.useState({});function t(h){if(h){const y=e.icon;if(typeof y=="object")return{name:"",data:y};const f=Vi(y);if(f)return{name:y,data:f}}return{name:""}}const[l,r]=b.useState(t(!!e.ssr));function d(){const h=s.callback;h&&(h(),a({}))}function c(h){if(JSON.stringify(l)!==JSON.stringify(h))return d(),r(h),!0}function u(){var h;const y=e.icon;if(typeof y=="object"){c({name:"",data:y});return}const f=Vi(y);if(c({name:y,data:f}))if(f===void 0){const m=Co([y],u);a({callback:m})}else f&&((h=e.onLoad)===null||h===void 0||h.call(e,y))}b.useEffect(()=>(o(!0),d),[]),b.useEffect(()=>{n&&u()},[e.icon,n]);const{name:g,data:p}=l;return p?Ho({...ei,...p},e,g):e.children?e.children:e.fallback?e.fallback:b.createElement("span",{})}const ln=b.forwardRef((e,n)=>tn({...e,_ref:n}));b.forwardRef((e,n)=>tn({inline:!0,...e,_ref:n}));function F({icon:e,iconClass:n}){return i.jsx(i.Fragment,{children:i.jsx(ln,{icon:e,className:n})})}function ui({element:e,validationData:n,placeholder:o}){var u;const[s,a]=b.useState([]),{register:t=()=>({}),setValue:l,isReadOnly:r,watch:d}=n||{},c=b.useMemo(()=>s==null?void 0:s.map(g=>g.label).join(", "),[s]);return b.useEffect(()=>{t(e.id)},[e.id,t]),b.useEffect(()=>{if(d){const g=d(p=>{a(p[e.id])});return()=>{var p;return(p=g.unsubscribe)==null?void 0:p.call(g)}}},[d,e.id]),i.jsx("div",{className:"custom-select",children:i.jsx(K.Listbox,{value:s||[],onChange:g=>{a(g),l==null||l(e.id,g)},multiple:!0,disabled:r,by:"value",children:i.jsxs("div",{className:"custom-select__wrapper",children:[i.jsxs(K.Listbox.Button,{className:"custom-select__control field-control",disabled:r,children:[i.jsx("span",{className:"custom-select__value",children:(s==null?void 0:s.length)>0?c:i.jsx("span",{className:"custom-select__placeholder",children:o!=null?o:" Select options"})}),i.jsx("span",{className:"custom-select__icon",children:i.jsx(F,{icon:"lucide:chevron-down"})})]}),i.jsx(K.Transition,{as:b.Fragment,leave:"custom-select__transition",children:i.jsx(K.Listbox.Options,{anchor:"bottom start",className:"custom-select__options",children:(u=e==null?void 0:e.options)==null?void 0:u.map((g,p)=>i.jsx(K.Listbox.Option,{value:g,className:({active:h})=>`custom-select__option ${h?"custom-select__option--active":""}`,children:({selected:h})=>i.jsxs("div",{className:"custom-select__option-row",children:[i.jsx("span",{className:`custom-select__option-label ${h?"custom-select__option--selected":""}`,children:g.label}),h&&i.jsx("span",{className:"custom-select__check",children:"✓"})]})},p))})})]})})})}const Fo=["jpg","jpeg","png","gif","bmp","webp","svg","image"],Vo=(e="")=>{var o;const n=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return Fo.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"},Uo={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 dn({fileUrl:e,fileName:n,removeFile:o}){const[s,a]=b.useState(!1),[t,l]=b.useState("unknown"),[r,d]=b.useState(null);b.useEffect(()=>{e&&l(Vo(e))},[e]),b.useEffect(()=>{if(t==="pdf"&&(e!=null&&e.startsWith("data:")))try{const h=atob(e.split(",")[1]),y=new ArrayBuffer(h.length),f=new Uint8Array(y);for(let w=0;w<h.length;w++)f[w]=h.charCodeAt(w);const m=new Blob([y],{type:"application/pdf"}),x=URL.createObjectURL(m);return d(x),()=>URL.revokeObjectURL(x)}catch(h){console.error("Error creating blob URL:",h)}else d(null)},[e,t]);const c=()=>{t==="image"||t==="pdf"?a(!0):window.open(r||e,"_blank")},u=()=>a(!1),g=n||(e==null?void 0:e.split("/").pop())||"Unknown file";function p(h,y="download"){if(!h)return;if(h.startsWith("data:")){const m=document.createElement("a");m.href=h,m.download=y,document.body.appendChild(m),m.click(),document.body.removeChild(m);return}const f=document.createElement("a");f.href=h,f.setAttribute("download",y),document.body.appendChild(f),f.click(),document.body.removeChild(f)}return i.jsxs("div",{className:"mt-2 field-control !py-1 !bg-gray-50 !flex justify-between gap-x-8 items-center",children:[i.jsxs("div",{onClick:c,className:"!flex items-center rounded cursor-pointer gap-x-3",title:`Click to preview ${g}`,children:[t==="image"&&i.jsx("div",{className:"flex items-center justify-center ",children:i.jsx(F,{iconClass:"text-4xl",icon:"fluent-color:image-48"})}),t!=="image"&&i.jsx(F,{icon:Uo[t],iconClass:"text-4xl"}),i.jsx("span",{className:"text-sm font-semibold text-center text-gray-700 truncate max-w-[300px]",children:g})]}),i.jsxs("div",{className:"flex gap-x-1 items-center",children:[i.jsx("button",{type:"button",className:"p-2",onClick:()=>p(r||e,n),title:`Download ${g}`,children:i.jsx(F,{icon:"streamline-flex:download-tray-solid"})}),o&&i.jsx("button",{type:"button",className:"p-2 text-lg text-red-500",onClick:o,children:i.jsx(F,{icon:"lets-icons:trash-duotone"})})]}),s&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",onClick:u,children:i.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:[i.jsx("button",{onClick:u,className:"absolute text-2xl font-bold text-gray-700 top-2 right-2","aria-label":"Close preview",children:"×"}),t==="image"?i.jsx("img",{src:e,alt:g,className:"max-w-full max-h-[80vh] mx-auto object-contain"}):t==="pdf"?i.jsx("iframe",{src:r||e,title:g,className:"w-full h-[80vh] rounded border"}):null]})})]})}const ue=e=>{const n=typeof window!="undefined"?localStorage.getItem(e):"";try{return JSON.parse(n)}catch(o){return n}},rn=(e,n)=>{const o=typeof n!="string"?JSON.stringify(n):n;return localStorage.setItem(e,o)},Wo=5*1024*1024;function Jo({onFileLoaded:e,disabled:n=!1,handleDeleteFile:o,multiple:s=!1,list:a=null,accept:t=[]}){const{uploadUrl:l}=b.useContext(le),r=b.useRef(null),[d,c]=b.useState(a),[u,g]=b.useState(!1);b.useEffect(()=>{c(a)},[a]);const p=b.useMemo(()=>t==null?void 0:t.map(S=>S.value).join(", "),[t]),h=b.useMemo(()=>t==null?void 0:t.map(S=>S.label).join(", "),[t]),y=b.useCallback(async S=>{var _;const A=ue("token");try{const{data:j}=await je.post(l,S,{headers:{Authorization:`Bearer ${A}`}});return(_=j==null?void 0:j.data)==null?void 0:_.url}catch(j){throw console.error("File upload error:",j),new Error("Failed to upload file to server")}},[l]),f=b.useCallback(S=>new Promise((A,_)=>{const j=new FileReader;j.onloadend=async()=>{try{const L=j.result.replace(/^data:.*;base64,/,""),Q=l?await y({base64:L,ext:`.${S.name.split(".").pop()}`,fileName:S.name}):j.result;A({base64:Q,type:S.type,name:S.name})}catch(L){_(L)}},j.onerror=()=>_(new Error("File read failed")),j.readAsDataURL(S)}),[l,y]),m=b.useCallback(S=>{var _;const A=p?(_=p.split(","))==null?void 0:_.map(j=>j.trim()):[];for(const j of S){if(j.size>Wo)return me.toast.error(`File "${j.name}" exceeds 5MB limit (${(j.size/1024/1024).toFixed(2)}MB)`),!1;if(A.length&&!A.some(L=>j.type===L||j.name.toLowerCase().endsWith(L.replace("*",""))))return me.toast.error(`File "${j.name}" is not an allowed type. Allowed: ${h||"any"}`),!1}return!0},[p,h]),x=b.useCallback(async S=>{const A=Array.from(S.target.files||[]);if(!(!A.length||u)){if(!m(A)){r.current&&(r.current.value="");return}try{g(!0);const _=await Promise.all(A==null?void 0:A.map(f));c(j=>{const L=s&&j?[...j,..._]:_;return e(L),L}),me.toast.success(`Successfully uploaded ${A.length} file(s)`)}catch(_){console.error("Upload error:",_),me.toast.error("Failed to upload file(s). Please try again.")}finally{g(!1),r.current&&(r.current.value="")}}},[u,m,f,e,s]),w=b.useCallback(S=>{u||(r.current&&(r.current.value=""),c(A=>{const _=S===void 0?null:(A==null?void 0:A.filter((j,L)=>L!==S))||null;return e(_),_}),o==null||o())},[o,e,u]),k=d&&d.length>0;return i.jsxs("div",{className:"flex flex-col items-start gap-2",children:[!n&&i.jsxs("div",{className:"!flex field-control !py-0 !px-0 relative",children:[i.jsx("input",{ref:r,type:"file",onChange:x,disabled:n||u,multiple:s,accept:p||"",className:`w-full text-sm text-gray-500 file:mr-4 flex-1 file:px-4 !py-1 !pl-1\r
32
32
  file:rounded-[6px] file:py-[6px] file:border-0\r
33
33
  file:text-sm file:font-semibold\r
34
34
  file:bg-blue-50 file:text-blue-700\r
35
- hover:file:bg-blue-100 disabled:opacity-50 disabled:cursor-not-allowed`}),k&&i.jsx("button",{type:"button",className:"p-2 text-lg text-red-500 hover:text-red-600 transition-colors disabled:opacity-50",onClick:()=>w(),disabled:u,"aria-label":"Remove all files",children:i.jsx(F,{icon:"lets-icons:trash-duotone"})})]}),k&&i.jsxs("div",{className:"relative grid gap-y-1 flex-1 w-full",children:[u&&i.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-white/60 rounded",children:i.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-600 font-medium",children:[i.jsx("span",{className:"animate-spin h-4 w-4 border-2 border-blue-500 border-t-transparent rounded-full"}),"Uploading..."]})}),typeof d=="object"&&(d==null?void 0:d.map((S,A)=>i.jsx(dn,{fileUrl:S.base64,fileName:S.name,removeFile:()=>w(A)},`${S.name}-${A}`)))]})]})}function qo({element:e,validationData:n}){var u;const[o,s]=b.useState((u=e==null?void 0:e.value)!=null?u:null),{register:a=()=>({}),setValue:t,isReadOnly:l,watch:r}=n||{};b.useEffect(()=>{a(e.id)},[e.id,a]),b.useEffect(()=>{if(r){const g=r(p=>{s(p[e.id])});return()=>{var p;return(p=g.unsubscribe)==null?void 0:p.call(g)}}},[r,e.id]);const d=b.useCallback(g=>{t==null||t(e.id,g),s(g)},[e.id,t]),c=()=>{t==null||t(e.id,null),s(null)};return i.jsxs("div",{children:[!l&&i.jsx(Jo,{onFileLoaded:d,disabled:l,multiple:e==null?void 0:e.isMultiple,handleDeleteFile:c,list:o,accept:e==null?void 0:e.acceptedFiles}),o&&l&&i.jsx("div",{className:"relative grid gap-y-1 flex-1 w-full",children:typeof o=="object"&&(o==null?void 0:o.map((g,p)=>i.jsx("div",{children:i.jsx(dn,{fileUrl:g.base64,fileName:g.name})},p)))})]})}function Yo({element:e,validationData:n}){const{register:o=()=>({})}=n||{};return i.jsx("input",{placeholder:e.placeholder,type:e.inputType,className:V("field-control",e==null?void 0:e.customClass),...o(e.id),disabled:n==null?void 0:n.isReadOnly})}const G=({label:e,name:n,register:o,errors:s,className:a,type:t="text",placeholder:l="",isFloating:r,setValue:d,value:c,trigger:u,prefix:g,disabled:p,watch:h})=>{var f,m,x,w;const y=o?{...o(n)}:{};if(t==="amount")return i.jsxs("div",{className:"space-y-1.5 relative",children:[i.jsx("label",{className:`block text-sm font-medium text-[#344054] font-onest ${r?"z-[40] absolute block text-[#667085] bg-white py-[2px] px-1 -top-[12px] left-3 ":"relative"}`,children:e}),i.jsx(Ge,{onValueChange:k=>{d(n,k),o&&o(n),u&&u(n)},placeholder:l,className:`field-control ${s!=null&&s[n]?"border-red-300":"border-[#D0D5DD]"}`,decimalsLimit:2,value:c,prefix:g,disabled:p}),(s==null?void 0:s[n])&&i.jsx("p",{className:"mt-1 text-sm text-red-600",children:(f=s[n])==null?void 0:f.message})]});if(["checkbox","radio"].includes(t)){const k=h==null?void 0:h(n);let S=!1;return k&&(t==="checkbox"?S=k==null?void 0:k.includes(c):S=k==c),i.jsxs("div",{className:"space-y-1",children:[i.jsxs("label",{className:"flex items-center gap-3 cursor-pointer select-none",children:[i.jsx("input",{...y,type:t,value:c,disabled:p,className:"peer sr-only"}),i.jsx("div",{className:`
35
+ hover:file:bg-blue-100 disabled:opacity-50 disabled:cursor-not-allowed`}),k&&i.jsx("button",{type:"button",className:"p-2 text-lg text-red-500 hover:text-red-600 transition-colors disabled:opacity-50",onClick:()=>w(),disabled:u,"aria-label":"Remove all files",children:i.jsx(F,{icon:"lets-icons:trash-duotone"})})]}),k&&i.jsxs("div",{className:"relative grid gap-y-1 flex-1 w-full",children:[u&&i.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-white/60 rounded",children:i.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-600 font-medium",children:[i.jsx("span",{className:"animate-spin h-4 w-4 border-2 border-blue-500 border-t-transparent rounded-full"}),"Uploading..."]})}),typeof d=="object"&&(d==null?void 0:d.map((S,A)=>i.jsx(dn,{fileUrl:S.base64,fileName:S.name,removeFile:()=>w(A)},`${S.name}-${A}`)))]})]})}function qo({element:e,validationData:n}){var u;const[o,s]=b.useState((u=e==null?void 0:e.value)!=null?u:null),{register:a=()=>({}),setValue:t,isReadOnly:l,watch:r}=n||{};b.useEffect(()=>{a(e.id)},[e.id,a]),b.useEffect(()=>{if(r){const g=r(p=>{s(p[e.id])});return()=>{var p;return(p=g.unsubscribe)==null?void 0:p.call(g)}}},[r,e.id]);const d=b.useCallback(g=>{t==null||t(e.id,g),s(g)},[e.id,t]),c=()=>{t==null||t(e.id,null),s(null)};return i.jsxs("div",{children:[!l&&i.jsx(Jo,{onFileLoaded:d,disabled:l,multiple:e==null?void 0:e.isMultiple,handleDeleteFile:c,list:o,accept:e==null?void 0:e.acceptedFiles}),o&&l&&i.jsx("div",{className:"relative grid gap-y-1 flex-1 w-full",children:typeof o=="object"&&(o==null?void 0:o.map((g,p)=>i.jsx("div",{children:i.jsx(dn,{fileUrl:g.base64,fileName:g.name})},p)))})]})}function Yo({element:e,validationData:n}){const{register:o=()=>({})}=n||{};return i.jsx("input",{placeholder:e.placeholder,type:e.inputType,className:V("field-control",e==null?void 0:e.customClass),...o(e.id),disabled:n==null?void 0:n.isReadOnly})}const G=({label:e,name:n,register:o,errors:s,className:a,type:t="text",placeholder:l="",isFloating:r,setValue:d,value:c,trigger:u,prefix:g,disabled:p,watch:h})=>{var f,m,x,w;const y=o?{...o(n)}:{};if(t==="amount")return i.jsxs("div",{className:"space-y-1.5 relative",children:[i.jsx("label",{className:`block text-sm font-medium text-[#344054] font-onest ${r?"z-[40] absolute block text-[#667085] bg-white py-[2px] px-1 -top-[12px] left-3 ":"relative"}`,children:e}),i.jsx(Ge,{onValueChange:k=>{d(n,k),o&&o(n),u&&u(n)},placeholder:l,className:`field-control ${s!=null&&s[n]?"border-red-300":"border-[#D0D5DD]"}`,decimalsLimit:2,value:c,prefix:g,disabled:p}),(s==null?void 0:s[n])&&i.jsx("p",{className:"mt-1 text-sm text-red-600",children:(f=s[n])==null?void 0:f.message})]});if(["checkbox","radio"].includes(t)){const k=(h==null?void 0:h(n))||null;let S=!1;return k&&(k!=null&&k.length&&t==="checkbox"?S=k==null?void 0:k.includes(c):S=k==c),i.jsxs("div",{className:"space-y-1",children:[i.jsxs("label",{className:"flex items-center gap-3 cursor-pointer select-none",children:[i.jsx("input",{...y,type:t,value:c||"",disabled:p,className:"peer sr-only"}),i.jsx("div",{className:`
36
36
  w-[18px] h-[18px] flex items-center justify-center
37
37
  border rounded-md transition-all duration-200
38
38
  ${s!=null&&s[n]?"border-red-300":"border-[#D0D5DD]"}
@@ -53,7 +53,7 @@ React keys must be passed directly to JSX without using spread:
53
53
  "data": [
54
54
  { "name": "Document Name", "id": "documentMainId", ...restObject },
55
55
  ]
56
- }`})})]})})}),ya=()=>i.jsx("blockquote",{className:"p-4 text-gray-700 bg-gray-100 rounded-md",children:i.jsxs("ul",{children:[i.jsxs("li",{className:"text-xs",children:["Method: GET ",i.jsx("br",{}),"URL format:"," ",i.jsx("code",{children:"https://example.com/validation/{documentId}"})]}),i.jsxs("li",{className:"text-xs",children:[i.jsx("span",{className:"block mb-1",children:" Response example format:"}),i.jsx("pre",{className:"p-2 bg-white rounded-md",children:i.jsxs("code",{children:["{ ",i.jsx("br",{}),'  "data": { ',i.jsx("br",{}),'    "status": true, ',i.jsx("br",{}),'    "isSigned": true ',i.jsx("br",{}),"  } ",i.jsx("br",{}),"}"]})})]})]})});function ka(e){return e.flatMap(n=>{var o;return(o=n.questionData)!=null?o:[]})}const vi=["text","number","boolean"],cn=["equals","not_equals","contains","not_contains"],wa=["greater","less"];function _a({register:e,setValue:n,trigger:o,watch:s,id:a}){const{formData:t}=b.useContext(le),l=s("visibilityDependentFields")||[],r=b.useMemo(()=>{var c;return(c=ka(t).filter(u=>u.id!==a))==null?void 0:c.map(u=>{const g=l.find(p=>p.id===u.id);return{id:u.id,value:u.id,label:u.inputLabel,sectionId:u.sectionId,fieldType:(g==null?void 0:g.fieldType)||"text",operator:(g==null?void 0:g.operator)||"equals",fieldValue:(g==null?void 0:g.fieldValue)!==void 0?g.fieldValue:""}})},[t,l,a]),d=(c,u,g)=>{const p=l==null?void 0:l.map((h,y)=>y===c?{...h,[u]:g}:h);n("visibilityDependentFields",p)};return i.jsxs("div",{className:"visibility-editor",children:[i.jsx("label",{className:"label",children:"Select Dependent Fields"}),i.jsx(ui,{element:{options:r,id:"visibilityDependentFields",value:s("visibilityDependentFields")},validationData:{register:e,setValue:n,trigger:o,watch:s}}),l.length>0&&i.jsx("div",{className:"py-1 bg-gray-100 rounded dependent-fields",children:l==null?void 0:l.map((c,u)=>{var g,p;return i.jsxs("div",{className:"dependent-field",children:[i.jsx("input",{type:"text",value:c.label,readOnly:!0,disabled:!0,className:"field-label"}),i.jsx("div",{className:"field-listbox min-w-[100px]",children:i.jsx(K.Listbox,{value:c.fieldType,onChange:h=>d(u,"fieldType",h),children:i.jsxs("div",{className:"listbox-wrapper",children:[i.jsx(K.Listbox.Button,{className:"listbox-button",children:c.fieldType}),i.jsx(K.Transition,{as:b.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:i.jsx(K.Listbox.Options,{className:"listbox-options ",anchor:"bottom",children:vi==null?void 0:vi.map(h=>i.jsx(K.Listbox.Option,{value:h,className:"listbox-option",children:h},h))})})]})})}),i.jsx("div",{className:"field-listbox min-w-[100px]",children:i.jsx(K.Listbox,{value:c.operator,onChange:h=>d(u,"operator",h),children:i.jsxs("div",{className:"listbox-wrapper",children:[i.jsx(K.Listbox.Button,{className:"listbox-button",children:c.operator.replace("_"," ")}),i.jsx(K.Transition,{as:b.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:i.jsx(K.Listbox.Options,{className:"listbox-options ",anchor:"bottom",children:(g=c.fieldType==="number"?[...cn,...wa]:cn)==null?void 0:g.map(h=>i.jsx(K.Listbox.Option,{value:h,className:"listbox-option",children:h.replace("_"," ")},h))})})]})})}),c.fieldType!=="boolean"?i.jsx("input",{type:c.fieldType,value:c.fieldValue||"",onChange:h=>d(u,"fieldValue",h.target.value),placeholder:"Value",className:"field-value"}):i.jsx("div",{className:"field-listbox",children:i.jsx(K.Listbox,{value:(p=c.fieldValue)!=null?p:"",onChange:h=>d(u,"fieldValue",h),children:i.jsxs("div",{className:"listbox-wrapper",children:[i.jsx(K.Listbox.Button,{className:"listbox-button",children:c.fieldValue===!0?"True":c.fieldValue===!1?"False":"Select value"}),i.jsx(K.Transition,{as:b.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:i.jsxs(K.Listbox.Options,{className:"listbox-options ",anchor:"bottom",children:[i.jsx(K.Listbox.Option,{value:!0,className:"listbox-option",children:"True"}),i.jsx(K.Listbox.Option,{value:!1,className:"listbox-option",children:"False"})]})})]})})})]},c.id)})})]})}const Aa=E.object().shape({inputLabel:E.string().nullable(),placeholder:E.string().nullable(),description:E.string().nullable(),isReadOnly:E.boolean(),isDisabled:E.boolean(),isRequired:E.boolean(),requiredMessage:E.string().nullable(),minLengthMessage:E.string().nullable(),maxLengthMessage:E.string().nullable(),maxLength:E.number().typeError("Expecting a number").nullable(),minLength:E.number().typeError("Expecting a number").nullable(),inputType:E.string().nullable(),maxAmountMessage:E.string().nullable(),maxAmount:E.string().nullable(),options:E.array().of(E.object().shape({label:E.string().nullable(),value:E.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:E.array().of(E.object().shape({label:E.string().nullable(),value:E.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:E.string().nullable(),url:E.string().nullable(),method:E.string().nullable(),denominators:E.mixed().nullable(),responseType:E.string().nullable(),minAmount:E.string().nullable(),heading:E.string().nullable(),minAmountMessage:E.string().nullable(),columns:E.number().nullable(),value:E.mixed().nullable(),customClass:E.string().nullable(),elementClass:E.string().nullable(),apiUrl:E.string().nullable(),selectType:E.string().default("list"),dateType:E.string().default("basic"),validationUrl:E.string(),signatureLink:E.string(),minDate:E.string().nullable(),maxDate:E.string().nullable(),canHaveDateRange:E.boolean(),allowYearPicker:E.boolean(),isHidden:E.boolean(),visibilityDependentFields:E.array().nullable(),isMultiple:E.boolean(),acceptedFiles:E.array(),showState:E.boolean()}),Sa=[{title:"Configurations",key:"basic"},{title:"Validations",key:"validation"}],Na=({isOpen:e,onClose:n,element:o})=>{const s=Sa.filter(R=>!Je.includes(o.inputType)||R.key!=="validation"),{updateElement:a}=b.useContext(le),[t,l]=b.useState("basic"),[r,d]=b.useState(!1),[c,u]=b.useState("manual"),g=ue("config"),{register:p,handleSubmit:h,control:y,setValue:f,watch:m,trigger:x,formState:{errors:w,isSubmitting:k,isValid:S},reset:A}=ye.useForm({resolver:mi(Aa),defaultValues:{...o,options:o.options||[]}}),_=m(),{fields:j,append:L,remove:Q}=ye.useFieldArray({control:y,name:"options"}),{fields:W,append:D,remove:M}=ye.useFieldArray({control:y,name:"options1"}),{fields:T,append:B,remove:I}=ye.useFieldArray({control:y,name:"dataColumns"});b.useEffect(()=>{e||A()},[e,A]);const Y=R=>{a(R,o.sectionId),n()},oe={headers:{Authorization:`Bearer ${ue("token")}`}},O=b.useCallback(async()=>{var R,z,te;if(!_.apiUrl||!/^https?:\/\//.test(_.apiUrl)){me.toast.info("Please provide a valid API URL");return}try{d(!0);const{status:Z,data:de}=await je.get(_.apiUrl,oe);if(Z!==200||!de){me.toast.error("Unexpected response from server.");return}const ee=de.data||de.record||de.result;if(!Array.isArray(ee)){me.toast.error("Expected an array in response (data, record, or result).");return}((R=o.type)==null?void 0:R.toLowerCase())==="datagrid"?f("dataColumns",ee):f("options",ee)}catch(Z){const de=((te=(z=Z==null?void 0:Z.response)==null?void 0:z.data)==null?void 0:te.message)||(Z==null?void 0:Z.message)||"Unable to load options";me.toast.error(de)}finally{d(!1)}},[o.type,f,_.apiUrl]),se=["manual","api","sheet"];function ve(){c==="api"&&O()}const pe=()=>i.jsxs("div",{className:"flex flex-col justify-start gap-y-1",children:[i.jsx("div",{className:"flex items-center mb-4 gap-x-5",children:se==null?void 0:se.map(R=>i.jsxs("label",{className:"items-center text-base capitalize gap-x-3",children:[i.jsx("input",{type:"radio",name:"optionType",onChange:z=>u(z.target.value),value:R})," ",i.jsxs("span",{children:[R," options"]})]},R))}),c==="api"&&i.jsxs("div",{className:"mb-4",children:[i.jsxs("div",{className:"flex items-center gap-x-2",children:[i.jsxs("div",{className:"relative flex items-center w-full mb-2",children:[i.jsx(G,{watch:m,label:"Load Options from Api",name:"apiUrl",errors:w,register:p,className:"!w-full",placeholder:"https://example.com/options",isFloating:!0}),r&&i.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"})]}),i.jsx("button",{onClick:ve,className:"px-3 py-1 text-xs text-white bg-gray-600 rounded",type:"button",children:"Load"})]}),i.jsx(ha,{})]}),c==="sheet"&&i.jsx("div",{className:"mb-4",children:i.jsx(un,{isFloating:!0,label:"Load options form sheet (csv, xlsx)",setValue:f,name:"options"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"mb-4 text-sm text-gray-500",children:"Parent Options "}),j==null?void 0:j.map((R,z)=>i.jsxs("div",{className:"flex items-center mb-1 gap-x-4 last:mb-0",children:[i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:z===0?"Label":"",name:`options.${z}.label`,register:p,errors:w,element:o,placeholder:"Label"})}),i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:z===0?"Value":"",name:`options.${z}.value`,register:p,errors:w,element:o,placeholder:"Value"})}),i.jsx("button",{disabled:j.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>Q(z),children:i.jsx(F,{icon:"iconamoon:sign-times-fill"})})]},R.id))," ",i.jsxs("div",{children:[" ",i.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>L({label:"",value:"",id:be.v4()}),children:[i.jsx(F,{icon:"qlementine-icons:plus-16"})," Add Option"]})]})]}),o.type.toLowerCase()==="cascadeselect"&&i.jsxs(i.Fragment,{children:[i.jsx("hr",{className:"my-5"}),i.jsxs("div",{children:[" ",i.jsx("h3",{className:"mb-4 text-sm text-gray-500",children:"Child Options "}),W==null?void 0:W.map((R,z)=>i.jsxs("div",{className:"flex items-center mb-1 gap-x-4 last:mb-0",children:[i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Label",name:`options1.${z}.label`,register:p,errors:w,element:o,placeholder:"Label",isFloating:!0})}),i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Value",name:`options1.${z}.value`,register:p,errors:w,element:o,placeholder:"Value",isFloating:!0})}),i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Key",name:`options1.${z}.key`,register:p,errors:w,element:o,placeholder:"Key",isFloating:!0})}),i.jsx("button",{disabled:W.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>M(z),children:i.jsx(F,{icon:"iconamoon:sign-times-fill"})})]},R.id)),i.jsxs("div",{children:[" ",i.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>D({label:"",value:"",key:"",id:be.v4()}),children:[i.jsx(F,{icon:"qlementine-icons:plus-16"})," Add Option"]})]})]})]})]}),fe=()=>i.jsxs("div",{className:"flex flex-col justify-start gap-y-1",children:[i.jsx("div",{className:"flex items-center mb-4 gap-x-5",children:se==null?void 0:se.map(R=>i.jsxs("label",{className:"items-center text-base capitalize gap-x-3",children:[i.jsx("input",{type:"radio",name:"optionType",onChange:z=>u(z.target.value),value:R,checked:R===c})," ",i.jsxs("span",{children:[R," options"]})]},R))}),c==="api"&&i.jsxs("div",{className:"mb-4",children:[i.jsxs("div",{className:"flex items-center gap-x-2",children:[i.jsxs("div",{className:"relative flex items-center w-full mb-2",children:[i.jsx(G,{watch:m,label:"Load Columns from Api",name:"apiUrl",errors:w,register:p,className:"!w-full",placeholder:"https://example.com/columns",isFloating:!0}),r&&i.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"})]})," ",i.jsx("button",{onClick:ve,className:"px-3 py-1 text-xs text-white bg-gray-600 rounded",type:"button",children:"Load"})]}),i.jsx(fa,{})]}),c==="sheet"&&i.jsx("div",{className:"mb-4",children:i.jsx(un,{isFloating:!0,label:"Load columns form sheet (csv, xlsx)",setValue:f,name:"dataColumns"})}),T==null?void 0:T.map((R,z)=>i.jsxs("div",{className:"flex items-center gap-x-4 ",children:[i.jsx("div",{className:"min-w-[140px]",children:i.jsx(Me,{label:z===0?"Type":"",options:[{label:"Text",value:"text"},{label:"Number",value:"number"},{label:"Checkbox",value:"checkbox"}],register:p,name:`dataColumns.${z}.type`,setValue:f,trigger:x,value:_.dataColumns[z].type})}),i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:z===0?"Field key":"",name:`dataColumns.${z}.field`,register:p,errors:w,element:o,placeholder:"fieldKey"})}),i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:z===0?"Display header":"",name:`dataColumns.${z}.headerName`,register:p,errors:w,element:o,placeholder:"header"})}),i.jsx("button",{disabled:T.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>I(z),children:i.jsx(F,{icon:"iconamoon:sign-times-fill"})})]},R.id)),i.jsxs("div",{children:[" ",i.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>B({headerName:"",field:"",editable:!0,id:be.v4(),type:"text",validate:!1}),children:[i.jsx(F,{icon:"qlementine-icons:plus-16"})," Add column"]})]})]}),xe=b.useCallback(async()=>{const R=ue("token"),{status:z,data:te}=await je.get(_.url,{headers:{Authorization:`Bearer ${R}`}});z===200&&f("options",(te==null?void 0:te.data)||te)},[f,_.url]);return b.useEffect(()=>{o.type==="document"&&_.url&&xe()},[_.url,o.type,xe]),i.jsx("div",{className:"fixed inset-0 bg-gray-800/40 backdrop-blur-sm flex items-center justify-end z-[999] cursor-default select-none ",draggable:"true",onDragStart:R=>R.preventDefault(),children:i.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 select-",draggable:"true",onDragStart:R=>R.preventDefault(),children:[i.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:i.jsx(F,{icon:"tabler:x",iconClass:"text-xl"})}),i.jsx("div",{className:"w-full pt-4",children:i.jsx(ia,{tabs:s,setActiveTab:l,activeTab:t,className:"justify-start !text-left",btnClass:" !text-left"})}),i.jsxs("form",{onSubmit:h(Y),className:"w-full flex-1 flex flex-col",children:[i.jsxs("div",{className:"flex-1",children:[" ",i.jsxs("div",{className:" max-h-[70vh] overflow-y-auto flex-1",children:[t==="basic"&&i.jsxs("div",{className:"z-10 flex flex-col w-full gap-5 px-6",children:[bi.includes(o.inputType)&&i.jsx(i.Fragment,{children:i.jsx(G,{watch:m,label:"Value",name:"value",register:p,errors:w,element:o})}),!bi.includes(o.inputType)&&!Je.includes(o.inputType)&&i.jsxs(i.Fragment,{children:[i.jsx(G,{watch:m,label:"Label",name:"inputLabel",register:p,errors:w,element:o})," ",o.type.toLowerCase()==="cascadeselect"&&i.jsx(G,{watch:m,label:"Child Label",name:"childLabel",register:p,errors:w,element:o})]}),ra.includes(o.inputType)&&i.jsx(G,{watch:m,label:"Placeholder",name:"placeholder",register:p,errors:w,element:o}),la.includes(o.inputType)&&i.jsx(G,{watch:m,label:"Prefix",name:"prefix",register:p,errors:w,element:o}),ma.includes(o.inputType)&&i.jsxs("div",{className:"grid gap-y-4",children:[i.jsx(ga,{}),i.jsx(G,{watch:m,label:"Api Url",name:"url",register:p,errors:w,element:o}),i.jsx(Me,{label:"Api Method",options:[{label:"GET",value:"GET"},{label:"POST",value:"POST"}],register:p,name:"method",setValue:f,trigger:x,value:m("method")}),i.jsx(Me,{label:"Api Response type",options:[{label:"String",value:"string"},{label:"Object",value:"object"}],register:p,name:"responseType",setValue:f,trigger:x,value:m("responseType")})]}),ba.includes(o.inputType)&&i.jsx(pa,{onChange:R=>{f("denominators",R)},value:m("denominators")}),!bi.includes(o.inputType)&&!Je.includes(o.inputType)&&i.jsx(G,{watch:m,label:"Short Description",name:"description",register:p,errors:w,element:o}),o.type.toLowerCase()==="date"&&i.jsxs(i.Fragment,{children:[i.jsx(Me,{label:"Date Format",options:ta,register:p,name:"dateFormat",setValue:f,trigger:x,value:m("dateFormat")}),i.jsx(G,{watch:m,label:"Allow Range",name:"canHaveDateRange",register:p,errors:w,element:o,type:"checkbox"}),(_==null?void 0:_.canHaveDateRange)&&i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(Qe,{name:"minDate",value:_==null?void 0:_.minDate,onGetValue:f,placeholder:"Select min date"}),i.jsx(Qe,{name:"maxDate",value:_==null?void 0:_.minDate,onGetValue:f,placeholder:"Select max date",minDate:_==null?void 0:_.minDate})]}),i.jsx(G,{watch:m,label:"Allow Year Picker",name:"allowYearPicker",register:p,errors:w,element:o,type:"checkbox"})]}),o.type.toLowerCase()==="country"&&i.jsx(G,{watch:m,label:"Allow States",name:"showState",register:p,errors:w,element:o,type:"checkbox"}),o.type.toLowerCase()==="selectfield"&&i.jsx(Me,{label:"Select Type",options:[{label:"List",value:"list"},{label:"Combobox",value:"Combobox"}],register:p,name:"selectType",setValue:f,trigger:x,value:m("selectType")}),o.type.toLowerCase()==="grid"&&i.jsx(G,{watch:m,label:"Number of columns",name:"columns",register:p,errors:w,element:o}),o.type.toLowerCase()==="document"&&i.jsxs("div",{className:"grid gap-y-6",children:[i.jsxs("div",{className:"grid gap-y-1",children:[i.jsx(G,{watch:m,label:"Document Options Url",name:"url",register:p,errors:w,element:o})," ",i.jsx(xa,{})]}),i.jsxs("div",{className:"grid gap-y-1",children:[i.jsx(G,{watch:m,label:"Document Validation Url",name:"validationUrl",register:p,errors:w,element:o}),i.jsx(ya,{})]}),i.jsx("div",{className:"grid gap-y-1",children:i.jsx(G,{watch:m,label:"Signature Page Url",name:"signatureLink",register:p,errors:w,element:o})})]}),o.type.toLowerCase()==="datagrid"&&fe(),o.type.toLowerCase()==="file"&&i.jsxs(i.Fragment,{children:[i.jsx(G,{watch:m,label:"Allow Multiple Uploads",name:"isMultiple",register:p,errors:w,element:o,type:"checkbox"}),i.jsx(ui,{element:{options:va,id:"acceptedFiles",value:_==null?void 0:_.acceptedFiles},validationData:{register:p,setValue:f,trigger:x,watch:m},placeholder:"Choose file types"})]}),ca.includes(o.inputType)&&pe(),i.jsxs("div",{children:[i.jsx("div",{className:"w-[150px] mb-4",children:i.jsx(G,{watch:m,label:"Toggle Visibility",name:"isHidden",register:p,errors:w,element:o,type:"checkbox"})})," ",_.isHidden&&i.jsx(_a,{register:p,setValue:f,trigger:x,watch:m,id:o==null?void 0:o.id})]})]}),!Je.includes(o.type.toLowerCase())&&t==="validation"&&i.jsxs("div",{className:"z-10 flex flex-col w-full gap-5 px-6",children:[i.jsxs("div",{className:"flex items-center gap-x-6",children:[i.jsx("div",{className:"w-[150px]",children:i.jsx(G,{watch:m,label:"Required",name:"isRequired",register:p,errors:w,element:o,type:"checkbox"})})," ",i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Error message text",name:"requiredMessage",register:p,errors:w,element:o})})]}),da.includes(o.inputType)&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-x-6",children:[i.jsx("div",{className:"w-[150px]",children:i.jsx(G,{watch:m,label:"Min Length",name:"minLength",register:p,errors:w,element:o,type:"number"})})," ",i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Error message text",name:"minLengthMessage",register:p,errors:w,element:o})})]}),i.jsxs("div",{className:"flex items-center gap-x-6",children:[i.jsx("div",{className:"w-[150px]",children:i.jsx(G,{watch:m,label:"Max Length",name:"maxLength",register:p,errors:w,element:o,type:"number"})})," ",i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Error message text",name:"maxLengthMessage",register:p,errors:w,element:o})})]})]}),ua.includes(o.inputType)&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-x-6",children:[i.jsx("div",{className:"w-[150px]",children:i.jsx(G,{watch:m,label:"Min Amount",name:"minAmount",register:p,errors:w,element:o,type:"amount"})})," ",i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Error message text",name:"minAmountMessage",register:p,errors:w,element:o})})]}),i.jsxs("div",{className:"flex items-center gap-x-6",children:[i.jsx("div",{className:"w-[150px]",children:i.jsx(G,{watch:m,label:"Max Amount",name:"maxAmount",register:p,errors:w,element:o,type:"amount"})})," ",i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Error message text",name:"maxAmountMessage",register:p,errors:w,element:o})})]})]})]})]})]}),i.jsxs("div",{className:"sticky flex w-full gap-3 px-6 pt-8 pb-10 mt-10 border-t",children:[i.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"}),i.jsx("button",{type:"submit",disabled:!S||k,style:{background:(g==null?void 0:g.buttonColor)||"#333"},className:`flex-1 px-4 py-2.5 ${!S||k?"bg-[#F2F4F7]":"bg-[#2563EB]"} ${!S||k?"text-[#98A2B3]":"text-white"} rounded-lg shadow-xs font-semibold font-onest disabled:opacity-50 editor_option__save`,children:k?"Saving...":"Save"})]})]})]})})},pi=b.memo(({state:e,element:n,children:o})=>{const[s,a]=b.useState(!1),{removeElement:t,duplicateElement:l}=b.useContext(le),r=b.useMemo(()=>{var c;return(c=n==null?void 0:n.acceptedFiles)==null?void 0:c.map(u=>u.label).join(", ")},[n]),d=b.useCallback(()=>{t(n.id,n.sectionId)},[n.id,n.sectionId,t]);return i.jsxs("div",{className:"w-full",children:[s&&i.jsx(Na,{isOpen:s,onClose:()=>a(!1),element:n}),i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("span",{children:[" ",n.inputLabel&&i.jsxs("label",{className:"text-sm font-medium input_label",children:[n.inputLabel," ",r&&i.jsxs("span",{className:"text-gray-400 text-xs",children:["(",r==null?void 0:r.toLowerCase(),")"]})]})]}),e==="edit"&&i.jsxs("span",{className:"flex items-center gap-x-3",children:[!n.gridPosition&&i.jsx("button",{type:"button",className:"text-sm outline-none hover:opacity-80",onClick:()=>l(n==null?void 0:n.id,n.sectionId),title:"Duplicate",children:i.jsx(F,{icon:"tabler:copy",iconClass:"text-base"})}),i.jsx("button",{type:"button",className:"text-sm outline-none hover:opacity-80",onClick:()=>a(!0),title:"Edit",children:i.jsx(F,{icon:"circum:edit",iconClass:"text-base"})}),i.jsx("button",{type:"button",className:"text-sm outline-none hover:opacity-80",onClick:d,title:"Remove",children:i.jsx(F,{icon:"iconamoon:trash",iconClass:"text-base"})})]})]}),o]})});pi.displayName="ElementContainer";function ja({element:e,validationData:n}){const{register:o=()=>({}),trigger:s,setValue:a,watch:t,isReadOnly:l}=n||{};let r;return t&&(r=t()[e.id]),i.jsx(G,{placeholder:e.placeholder,type:e.inputType,label:"",name:e.id,register:o,trigger:s,setValue:a,value:r,prefix:e.prefix,disabled:l,watch:t})}function Ca(e){if(!e)return!1;const n=/^data:image\/(jpeg|png|gif|bmp|webp);base64,/i,o=/\.(jpeg|jpg|png|gif|bmp|webp)$/i;return n.test(e)||o.test(e)}const Ma=({imageUrl:e})=>{const[n,o]=b.useState(!1),s=()=>{o(!0)},a=()=>{o(!1)};return i.jsxs("div",{children:[i.jsx("img",{alt:"Thumbnail",style:{cursor:"pointer",width:"120px",height:"130px",objectFit:"cover"},onClick:s,src:e||"/place.png","data-toggle":"tooltip","data-placement":"top",title:"Click to view"}),n&&i.jsx("div",{className:"modal",style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",justifyContent:"center",alignItems:"center"},onClick:a,children:i.jsxs("div",{className:"modal-content",style:{position:"relative",backgroundColor:"white",padding:"20px",borderRadius:"8px",width:"90vw"},onClick:t=>t.stopPropagation(),children:[i.jsx("span",{className:"close",onClick:a,style:{position:"absolute",top:"10px",right:"10px",fontSize:"24px",cursor:"pointer"},children:"×"}),i.jsx("img",{src:e||"/place.png",alt:"Full Image",style:{maxWidth:"90%",maxHeight:"90vh",objectFit:"contain"}})]})})]})};function Ta({element:e,validationData:n}){var _;const{register:o=()=>({}),setValue:s,watch:a}=n||{},[t,l]=b.useState(),[r,d]=b.useState(!1),[c,u]=b.useState(!1),[g,p]=b.useState(""),h=a&&a(e==null?void 0:e.id);b.useEffect(()=>{l(h)},[h]);const[y,f]=b.useState("");b.useEffect(()=>{o(e.id)},[e.id,o]);const{url:m,method:x,responseType:w}=e||{},S={headers:{Authorization:`Bearer ${ue("token")}`}},A=b.useCallback(async j=>{var L,Q,W,D,M,T,B,I,Y,J,oe;if(!(!m||!x)){d(!0);try{let O;if(x.toLowerCase()==="get"){const se=`${m}?value=${j}`;O=await je.get(se,S)}else if(x.toLowerCase()==="post")O=await je.post(m,{value:j},S);else throw new Error("Unsupported HTTP method");O.status===200&&((((Q=(L=O==null?void 0:O.data)==null?void 0:L.data)==null?void 0:Q.status)||((W=O==null?void 0:O.data)==null?void 0:W.status))===!0?(u(!0),w==="string"?p(((M=(D=O==null?void 0:O.data)==null?void 0:D.data)==null?void 0:M.description)||((T=O==null?void 0:O.data)==null?void 0:T.description)||"Validation successful"):f(((I=(B=O==null?void 0:O.data)==null?void 0:B.data)==null?void 0:I.description)||((Y=O==null?void 0:O.data)==null?void 0:Y.description)||{})):(console.error("Invalid input:",j),p("Unable to validate input"),u(!1)))}catch(O){console.error("Error validating input:",O),p(((oe=(J=O==null?void 0:O.response)==null?void 0:J.data)==null?void 0:oe.message)||"Unable to validate input"),u(!1)}finally{d(!1)}}},[x,w,m]);return b.useEffect(()=>{if(t){const j=setTimeout(()=>{A(t)},700);return()=>clearTimeout(j)}},[A,t]),i.jsxs("div",{children:[i.jsxs("div",{className:"relative flex items-center",children:[i.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"",type:(e==null?void 0:e.inputType)||"text",className:V("field-control",e==null?void 0:e.customClass),...o(e==null?void 0:e.id),onChange:j=>{l(j.target.value),s(e==null?void 0:e.id,j.target.value)},disabled:n==null?void 0:n.isReadOnly}),i.jsxs("span",{className:"absolute right-0",children:[r&&i.jsxs("span",{children:[" ",i.jsxs("svg",{className:"animate-spin -ml-1 mr-3 h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[i.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),i.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})]}),c&&!r&&i.jsx("span",{className:"block pr-3 text-lg text-green-600",children:i.jsx(F,{icon:"gg:check-o"})})]})]}),g&&w==="string"&&i.jsx("span",{className:`${c?"text-green-600":"text-red-600"} text-sm`,children:g}),w==="object"&&i.jsx("div",{className:"grid grid-cols-2 gap-6 mt-2 text-sm text-gray-600",children:(_=Object.entries(y))==null?void 0:_.map(([j,L])=>i.jsxs("div",{className:"flex items-center gap-x-2",children:[i.jsxs("span",{className:"font-semibold",children:[j,":"]}),Ca(L)?i.jsx(Ma,{imageUrl:L}):i.jsx("span",{children:String(L)})]},j))})]})}function Ea({onGetTotal:e,readOnly:n,defaultValue:o,denominators:s}){const[a,t]=b.useState([...o]);function l(c,u){t(g=>{const p=[...g];return p[u]={...p[u],value:c},p})}function r(c,u){return parseFloat(c)*parseFloat(u)||0}const d=b.useMemo(()=>a.reduce((c,u)=>{const g=r(u.key,u.value);return c+g},0),[a]);return b.useEffect(()=>{e&&e(a)},[a]),b.useEffect(()=>{if(s!=null&&s.length){const c=s==null?void 0:s.map((u,g)=>({key:u.value,value:Array.isArray(o)&&o[g]?o[g].value:""}));t(c)}},[o,s]),i.jsx("div",{className:"mt-2",children:i.jsxs("div",{className:"border border-gray-200 rounded-lg overflow-hidden text-gray-700",children:[i.jsxs("div",{className:"grid grid-cols-3 text-sm font-bold border-b border-gray-100 bg-gray-50",children:[i.jsx("div",{className:"border-r px-4 py-2",children:i.jsx("span",{className:"",children:"Denomination"})}),i.jsx("div",{className:"border-r px-4 py-2",children:i.jsx("span",{children:"Quantity"})}),i.jsx("div",{className:"px-4 py-2",children:i.jsx("span",{children:"Sub total"})})]}),a==null?void 0:a.map((c,u)=>{var g,p;return i.jsxs("div",{className:"grid grid-cols-3 text-sm border-b border-gray-100",children:[i.jsx("div",{className:"border-r px-4 py-2 flex items-center",children:i.jsx("span",{className:"",children:(g=parseFloat(c.key))==null?void 0:g.toLocaleString()})}),i.jsx("div",{className:"border-r px-4 py-1",children:i.jsx("span",{children:i.jsx(Ge,{id:"input-example",className:"border border-gray-100 rounded w-full px-3 py-1 outline-none",decimalsLimit:6,value:c.value,onValueChange:h=>l(h,u),disabled:n,allowNegativeValue:!1})})}),i.jsx("div",{className:"px-4 py-2 flex justify-between items-center",children:i.jsx("span",{children:(p=r(c.key,c.value))==null?void 0:p.toLocaleString()})})]},u+"index")}),i.jsxs("div",{className:"grid grid-cols-3 text-sm font-bold bg-gray-50",children:[i.jsx("div",{className:"border-r px-4 py-3 col-span-2 text-right",children:"Total"}),i.jsx("div",{className:"px-4 py-3",children:d==null?void 0:d.toLocaleString()})]})]})})}function Ba({element:e,validationData:n}){const{register:o=()=>({}),setValue:s,getValues:a}=n||{},t=a&&a(e==null?void 0:e.id)||[];return b.useEffect(()=>{o(e.id)},[e.id,o]),i.jsx("div",{children:i.jsx(Ea,{onGetTotal:l=>{s&&s(e.id,l)},denominators:(e==null?void 0:e.denominators)||[],defaultValue:t,readOnly:e==null?void 0:e.isReadOnly})})}function La({element:e}){return i.jsx("div",{className:V("py-6",e==null?void 0:e.customClass)})}function Pa({element:e}){return i.jsx("div",{children:i.jsx("hr",{className:V("border-gray-200 my-4",e==null?void 0:e.customClass)})})}function Oa({element:e,validationData:n}){const{register:o=()=>({})}=n||{};return i.jsx("div",{children:i.jsx("input",{placeholder:"Enter text",type:"text",className:"field-control",...o(e==null?void 0:e.id)})})}function Ia({element:e,state:n}){return i.jsx(i.Fragment,{children:i.jsx("div",{className:e==null?void 0:e.customClass,children:(e==null?void 0:e.value)||n==="edit"&&i.jsx("span",{className:"text-gray-400",children:"Provide text"})})})}function Da({row:e,columns:n,isReadOnly:o,editingCell:s,setEditingCell:a,handleCellChange:t,debouncedValidate:l,getValidationStatus:r,deleteRow:d}){const c=u=>(s==null?void 0:s.rowId)===e.id&&(s==null?void 0:s.field)===u;return i.jsxs("tr",{children:[n.map(u=>{var w;const g=e[u.field],p=u.editable&&!o,h=c(u.field),{isValidating:y,result:f}=r(e.id,u.field);let m="border-gray-300";u.validate&&((f==null?void 0:f.isValid)===!1?m="border-red-500 bg-red-50":(f==null?void 0:f.isValid)===!0&&(m="border-green-500 bg-green-50"));const x=`w-full px-2 py-1 border rounded outline-none ${m}`;return i.jsx("td",{title:o?"":"Double click to edit",className:"px-3 py-1 border",onDoubleClick:()=>p&&a({rowId:e.id,field:u.field}),children:p&&h?i.jsxs("div",{className:"relative",children:[u.type==="number"?i.jsx(Ge,{value:g,decimalsLimit:6,allowNegativeValue:!1,className:x,onValueChange:k=>t(k,e.id,u.field),onBlur:()=>{a(null),l(g,e.id,u.field,u)},autoFocus:!0}):u.type==="checkbox"?i.jsx("div",{className:"flex items-center gap-x-4",children:["yes","no"].map(k=>{const S=k==="yes",A=`radio-${e.id}-${String(u.field)}-${k}`;return i.jsxs("label",{htmlFor:A,className:"flex items-center gap-1 cursor-pointer",children:[i.jsx("input",{id:A,type:"radio",name:`boolean-${e.id}-${String(u.field)}`,checked:g===S,onChange:()=>t(S,e.id,u.field)}),i.jsx("span",{className:"text-sm",children:S?"Yes":"No"})]},k)})}):i.jsx("input",{type:"text",value:String(g!=null?g:""),onChange:k=>t(k.target.value,e.id,u.field),onBlur:()=>{a(null),l(g,e.id,u.field,u)},className:x,autoFocus:!0}),y&&i.jsx("div",{className:"absolute right-1 top-1",children:i.jsx("div",{className:"w-4 h-4 border-2 border-blue-500 rounded-full border-t-transparent animate-spin"})})]}):u.validate&&f?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{children:[String(g!=null?g:"")," ",f.data&&`[${f.data}]`]}),f.isValid?i.jsx("span",{className:"text-xs text-green-600",children:"✓"}):i.jsx("span",{className:"text-xs text-red-600 cursor-help",title:(w=f.error)!=null?w:"",children:"✗"})]}):u.type==="checkbox"?i.jsx("span",{className:"block py-1 text-gray-700",children:g===!0?"Yes":g===!1?"No":""}):i.jsx("span",{className:"block py-1 text-gray-700 cursor-pointer",children:String(g!=null?g:"")})},String(u.id))}),!o&&i.jsx("td",{className:"px-3 py-1 text-center border",children:i.jsx("button",{type:"button",onClick:()=>d(e.id),className:"text-red-500 hover:text-red-700","aria-label":"Delete row",children:i.jsx(F,{icon:"lets-icons:trash-duotone",iconClass:"text-xl"})})})]})}const Ka=b.memo(Da);function Ga({value:e=[],onChange:n,isReadOnly:o=!1,columns:s}){const[a,t]=b.useState(e),[l,r]=b.useState(null),d=b.useRef(null),c=document.getElementById("form"),u=b.useMemo(()=>{const f=(c==null?void 0:c.getBoundingClientRect().width)||0;return f&&f-48},[c]);b.useEffect(()=>{t(f=>JSON.stringify(f)!==JSON.stringify(e)?e:f)},[e]),b.useEffect(()=>{n==null||n(a)},[a,n]),b.useEffect(()=>{const f=m=>{d.current&&!d.current.contains(m.target)&&r(null)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const g=b.useCallback((f,m,x)=>{t(w=>w.map(k=>k.id===m?{...k,[x]:f}:k))},[]),p=b.useCallback(()=>{const f=be.v4(),m=s.reduce((x,w)=>(x[w.field]=w.field==="id"?f:"",x),{});t(x=>[...x,{id:f,...m}])},[s]),h=b.useCallback(f=>{t(m=>m.filter(x=>x.id!==f))},[]),y=b.useCallback(()=>({isValidating:!1,result:void 0}),[]);return i.jsxs("div",{className:"mt-3 rounded",ref:d,children:[i.jsx("div",{className:"flex justify-end",children:!o&&i.jsx("button",{onClick:p,type:"button",className:"px-2 py-1 mb-3 text-xs text-white bg-gray-600 rounded hover:bg-gray-700",children:"Add Row"})}),i.jsx("div",{className:"w-full max-w-full overflow-x-auto",style:{maxWidth:`${u}px`},children:i.jsxs("table",{className:"min-w-max w-full text-sm border-collapse rounded table-auto bg-gray-50",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-gray-100",children:[s.map((f,m)=>{var x;return i.jsxs("th",{className:"px-3 py-2 text-xs font-semibold text-left text-gray-600 border whitespace-nowrap",children:[(x=f.headerName)!=null?x:String(f.field),f.validate&&i.jsx("span",{className:"ml-1 text-blue-600",children:"*"})]},`${String(f.id)}-${m}`)}),!o&&i.jsx("th",{className:"w-10 px-2 py-2 border"})]})}),i.jsx("tbody",{children:a.length>0?a.map(f=>i.jsx(Ka,{row:f,columns:s,isReadOnly:o,editingCell:l,setEditingCell:r,handleCellChange:g,debouncedValidate:()=>{},getValidationStatus:y,deleteRow:h},f.id)):i.jsx("tr",{children:i.jsx("td",{colSpan:s.length+(o?0:1),className:"p-2 text-xs text-center text-gray-400",children:"No data available"})})})]})})]})}function Ra({element:e,validationData:n}){const{register:o=()=>({}),setValue:s,watch:a,isReadOnly:t}=n||{},l=a&&a(e==null?void 0:e.id)||[];b.useEffect(()=>{o(e.id)},[e.id,o]);const r=b.useCallback(d=>{s==null||s(e.id,d)},[e.id,s]);return i.jsx(Ga,{value:l,onChange:r,columns:e==null?void 0:e.dataColumns,isReadOnly:t})}const mn=({className:e="",options:n=[],placeholder:o="Select",errors:s,register:a,setValue:t,name:l,label:r,value:d,trigger:c,isMultiple:u=!1,isFloatingLabel:g=!1,subText:p,labelClass:h="",loading:y,disabled:f})=>{const[m,x]=b.useState(u?[]:null),w=V("custom-select__control",e),k=b.useMemo(()=>n,[n]);return b.useEffect(()=>{const S=n==null?void 0:n.find(A=>{var _;return typeof A.value=="string"&&typeof d=="string"?A.value.toLowerCase()===d.toLowerCase():typeof A.value=="object"&&typeof d=="object"?((_=A.value)==null?void 0:_.id)===(d==null?void 0:d.id):A.value===d});x(S||null)},[d,n]),b.useEffect(()=>{m&&t&&a&&(t(l,m==null?void 0:m.value),a(l),c==null||c(l))},[l,m]),i.jsxs("div",{className:"custom-select",children:[r&&!g&&i.jsx("label",{className:"custom-select__label",children:r}),g&&r&&i.jsx("label",{className:V("custom-select__floating-label",h),children:r}),i.jsx(K.Listbox,{value:m,onChange:x,multiple:u,disabled:f,children:i.jsxs("div",{className:"custom-select__wrapper",children:[i.jsxs(K.Listbox.Button,{className:w,disabled:f,children:[y?i.jsx("span",{className:"custom-select__loading",children:"Fetching data..."}):i.jsx("span",{className:"custom-select__value",children:(m==null?void 0:m.label)||i.jsx("span",{className:"custom-select__placeholder",children:o})}),i.jsx("span",{className:"custom-select__icon",children:i.jsx(F,{icon:"lucide:chevron-down"})})]}),i.jsx(K.Transition,{as:b.Fragment,leave:"custom-select__transition",children:i.jsx(K.Listbox.Options,{className:"custom-select__options",anchor:"bottom",children:k==null?void 0:k.map((S,A)=>i.jsx(K.Listbox.Option,{value:S,className:({active:_})=>V("custom-select__option",_&&"custom-select__option--active"),children:({selected:_})=>i.jsx("span",{className:V("custom-select__option-label",_&&"custom-select__option--selected"),children:S.label})},A))})})]})}),p&&!s&&i.jsx("p",{className:"custom-select__subtext",children:p}),s&&i.jsx("span",{className:"custom-select__error",children:s.message})]})},za=({element:e,validationData:n})=>{var f;const{register:o=()=>({}),trigger:s,setValue:a,watch:t,isReadOnly:l}=n||{},r=(f=e==null?void 0:e.id)!=null?f:"cascadeValue",[d,c]=b.useState(""),[u,g]=b.useState(""),p=(m,x)=>{const w=m&&x?`${m}_${x}`:"";a==null||a(r,w),s==null||s(r)},h=(m,x)=>{m==="first"?(c(x),g(""),p(x,"")):(g(x),p(d,x))};b.useEffect(()=>{if(t){const m=t(r);if(m!=null&&m.includes("_")){const[x,w]=m.split("_");c(x),g(w)}}},[t,r]);const y=b.useMemo(()=>{var m;return(m=e.options1)==null?void 0:m.filter(x=>x.key===d)},[e.options1,d]);return!e.options||!e.options1?null:i.jsxs("div",{children:[i.jsx("input",{type:"hidden",...o(r)}),i.jsx("div",{className:"relative",children:i.jsx(mn,{setValue:(m,x)=>h("first",x),options:e.options,name:`${r}`,register:o,value:d})}),d&&i.jsxs("div",{className:"mt-4",children:[(e==null?void 0:e.childLabel)&&i.jsx("label",{className:"block text-sm text-[#686878] darks:!text-white/70 mb-2",children:e==null?void 0:e.childLabel}),i.jsx(mn,{setValue:(m,x)=>h("second",x),options:y,name:`${r}`,register:o,value:u})]})]})},Ha=({value:e=0,max:n=5,readOnly:o=!1,onChange:s,size:a=24,className:t="",element:l,validationData:r})=>{var x;const{register:d=()=>({}),trigger:c,setValue:u,watch:g,isReadOnly:p}=r||{},h=(x=g==null?void 0:g(l.id))!=null?x:0,[y,f]=b.useState(null);b.useEffect(()=>{h==null&&(u==null||u(l.id,e))},[]);const m=w=>{if(!o&&!p){const k=w+1;u==null||u(l.id,k),c==null||c(l.id),s==null||s(k)}};return i.jsxs("div",{className:`flex gap-1 ${t}`,children:[i.jsx("input",{type:"hidden",...d(l.id)}),Array.from({length:n},(w,k)=>{const S=y!==null?k<=y:k<h;return i.jsx(ln,{icon:S?"mdi:star":"mdi:star-outline",className:`cursor-pointer transition-colors ${S?"text-yellow-400":"text-gray-300"}`,width:a,height:a,onMouseEnter:()=>!(o||p)&&f(k),onMouseLeave:()=>!(o||p)&&f(null),onClick:()=>m(k)},k)})]})};function bn({element:e,validationData:n}){const{register:o=()=>({}),setValue:s,trigger:a,isReadOnly:t,watch:l}=n||{},r=(l==null?void 0:l(e.id))||"",{country:d,state:c}=b.useMemo(()=>{var y;if(typeof r=="string"&&r.includes(",")){const[f,m]=(y=r.split(","))==null?void 0:y.map(x=>x.trim());return{country:m,state:f}}return{country:r,state:""}},[r]),u=b.useRef(r),g=b.useMemo(()=>{var y,f;return d?((f=(y=Ue.find(m=>m.name===d))==null?void 0:y.states)==null?void 0:f.map(m=>({label:m.name,value:m.name})))||[]:[]},[d]),p=(y,f)=>{const x=(f==null?void 0:f.value)||"";s&&x!==u.current&&(s(e.id,x),a==null||a(e.id),u.current=x)},h=(y,f)=>{const m=(f==null?void 0:f.value)||"",x=m?`${m}, ${d}`:d;s&&x!==u.current&&(s(e.id,x),a==null||a(e.id),u.current=x)};return b.useEffect(()=>{u.current=r},[r]),i.jsxs("div",{className:"grid gap-y-6",children:[i.jsx("input",{type:"hidden",...o(e.id)}),i.jsx(ci,{options:e.options,onGetValue:p,name:`${e.id}-country`,readOnly:t,defaultValue:d},`country-${d}`),g.length>0&&e.showState&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium mb-1.5 input_label",children:"State"}),i.jsx(ci,{options:g,onGetValue:h,name:`${e.id}-state`,readOnly:t,defaultValue:c},`state-${c}`)]})]})}function Fa({element:e,validationData:n}){const{register:o=()=>({}),isReadOnly:s}=n||{},{validationUrl:a,documentObj:t,signatureLink:l}=e,r=b.useMemo(()=>ue("config"),[]),[d,c]=b.useState(!1),[u,g]=b.useState(!1),p=b.useCallback(async()=>{var h,y;if(!(!a||!t))try{g(!0);const m={headers:{Authorization:`Bearer ${ue("token")}`}},{data:x}=await je.get(`${a}/${t}`,m),w=!!((y=(h=x==null?void 0:x.data)==null?void 0:h.isSigned)!=null?y:x!=null&&x.isSigned);return c(w),w}catch(f){console.error("Failed to check sign status",f)}finally{g(!1)}},[a,t]);return b.useEffect(()=>{let h=null;return!d&&t&&a&&(async()=>{await p()||(h=setInterval(async()=>{await p()&&h&&clearInterval(h)},2e3))})(),()=>{h&&clearInterval(h)}},[p,d,t,a]),i.jsxs("div",{className:"flex items-center gap-x-2",children:[i.jsx("input",{placeholder:e.placeholder,type:e.inputType,className:V("field-control",e.customClass),...o(e.id),disabled:s}),i.jsx("a",{href:d?"#":l,children:i.jsxs("button",{type:"button",onClick:p,disabled:u||d,style:{background:(r==null?void 0:r.buttonColor)||"#333"},className:V("flex items-center gap-x-1 rounded-lg border border-gray-200 bg-gray-200 px-3 py-[10px] text-sm text-white",{"!opacity-60":u}),children:[i.jsx(F,{icon:u?"solar:refresh-outline":d?"solar:check-circle-bold":"solar:pen-2-line-duotone",iconClass:u?"animate-spin":""}),u?"Checking...":d?"Signed":"Sign"]})})]})}const gi=[{code:"DZ",label:"Algeria",phone:"213",min:9,max:9},{code:"AO",label:"Angola",phone:"244",min:9,max:9},{code:"BJ",label:"Benin",phone:"229",min:8,max:8},{code:"BW",label:"Botswana",phone:"267",min:7,max:7},{code:"BF",label:"Burkina Faso",phone:"226",min:8,max:8},{code:"BI",label:"Burundi",phone:"257",min:8,max:8},{code:"CM",label:"Cameroon",phone:"237",min:9,max:9},{code:"CV",label:"Cape Verde",phone:"238",min:7,max:7},{code:"CF",label:"Central African Republic",phone:"236",min:8,max:8},{code:"TD",label:"Chad",phone:"235",min:8,max:8},{code:"KM",label:"Comoros",phone:"269",min:7,max:7},{code:"CG",label:"Congo",phone:"242",min:9,max:9},{code:"CD",label:"Democratic Republic of Congo",phone:"243",min:9,max:9},{code:"CI",label:"Cote d'Ivoire",phone:"225",min:8,max:8},{code:"DJ",label:"Djibouti",phone:"253",min:8,max:8},{code:"EG",label:"Egypt",phone:"20",min:10,max:10},{code:"GQ",label:"Equatorial Guinea",phone:"240",min:9,max:9},{code:"ER",label:"Eritrea",phone:"291",min:7,max:7},{code:"ET",label:"Ethiopia",phone:"251",min:9,max:9},{code:"GA",label:"Gabon",phone:"241",min:7,max:7},{code:"GM",label:"Gambia",phone:"220",min:7,max:7},{code:"GH",label:"Ghana",phone:"233",min:9,max:9},{code:"GN",label:"Guinea",phone:"224",min:9,max:9},{code:"GW",label:"Guinea-Bissau",phone:"245",min:9,max:9},{code:"KE",label:"Kenya",phone:"254",min:7,max:9},{code:"LS",label:"Lesotho",phone:"266",min:8,max:8},{code:"LR",label:"Liberia",phone:"231",min:8,max:9},{code:"LY",label:"Libya",phone:"218",min:9,max:10},{code:"MG",label:"Madagascar",phone:"261",min:9,max:9},{code:"MW",label:"Malawi",phone:"265",min:9,max:9},{code:"ML",label:"Mali",phone:"223",min:8,max:8},{code:"MR",label:"Mauritania",phone:"222",min:8,max:8},{code:"MU",label:"Mauritius",phone:"230",min:8,max:8},{code:"MA",label:"Morocco",phone:"212",min:9,max:9},{code:"MZ",label:"Mozambique",phone:"258",min:9,max:9},{code:"NA",label:"Namibia",phone:"264",min:9,max:9},{code:"NE",label:"Niger",phone:"227",min:8,max:8},{code:"NG",label:"Nigeria",phone:"234",min:10,max:10},{code:"RW",label:"Rwanda",phone:"250",min:9,max:9},{code:"ST",label:"Sao Tome and Principe",phone:"239",min:7,max:7},{code:"SN",label:"Senegal",phone:"221",min:9,max:9},{code:"SC",label:"Seychelles",phone:"248",min:7,max:7},{code:"SL",label:"Sierra Leone",phone:"232",min:8,max:8},{code:"SO",label:"Somalia",phone:"252",min:8,max:9},{code:"ZA",label:"South Africa",phone:"27",min:10,max:10},{code:"SS",label:"South Sudan",phone:"211",min:9,max:9},{code:"SD",label:"Sudan",phone:"249",min:9,max:9},{code:"TZ",label:"Tanzania",phone:"255",min:9,max:9},{code:"TG",label:"Togo",phone:"228",min:8,max:8},{code:"TN",label:"Tunisia",phone:"216",min:8,max:8},{code:"UG",label:"Uganda",phone:"256",min:9,max:9},{code:"ZM",label:"Zambia",phone:"260",min:9,max:9},{code:"ZW",label:"Zimbabwe",phone:"263",min:9,max:9},{code:"US",label:"United States",phone:"1",min:10,max:10},{code:"CA",label:"Canada",phone:"1",min:10,max:10},{code:"GB",label:"United Kingdom",phone:"44",min:9,max:10},{code:"FR",label:"France",phone:"33",min:9,max:9},{code:"DE",label:"Germany",phone:"49",min:10,max:11},{code:"IT",label:"Italy",phone:"39",min:9,max:10},{code:"ES",label:"Spain",phone:"34",min:9,max:9},{code:"NL",label:"Netherlands",phone:"31",min:9,max:9},{code:"RU",label:"Russia",phone:"7",min:10,max:10},{code:"CN",label:"China",phone:"86",min:11,max:11},{code:"IN",label:"India",phone:"91",min:10,max:10},{code:"JP",label:"Japan",phone:"81",min:10,max:10},{code:"KR",label:"South Korea",phone:"82",min:8,max:9},{code:"BR",label:"Brazil",phone:"55",min:10,max:11},{code:"MX",label:"Mexico",phone:"52",min:10,max:10},{code:"AR",label:"Argentina",phone:"54",min:10,max:10},{code:"CL",label:"Chile",phone:"56",min:9,max:9},{code:"AU",label:"Australia",phone:"61",min:9,max:9},{code:"NZ",label:"New Zealand",phone:"64",min:8,max:9},{code:"SA",label:"Saudi Arabia",phone:"966",min:9,max:9},{code:"AE",label:"United Arab Emirates",phone:"971",min:9,max:9},{code:"TR",label:"Turkey",phone:"90",min:10,max:11},{code:"IR",label:"Iran",phone:"98",min:7,max:10},{code:"PK",label:"Pakistan",phone:"92",min:10,max:10},{code:"BD",label:"Bangladesh",phone:"880",min:10,max:10},{code:"ID",label:"Indonesia",phone:"62",min:9,max:11},{code:"PH",label:"Philippines",phone:"63",min:10,max:10},{code:"CO",label:"Colombia",phone:"57",min:10,max:10},{code:"VE",label:"Venezuela",phone:"58",min:10,max:10},{code:"PE",label:"Peru",phone:"51",min:9,max:9},{code:"EC",label:"Ecuador",phone:"593",min:9,max:9},{code:"UY",label:"Uruguay",phone:"598",min:8,max:8},{code:"PY",label:"Paraguay",phone:"595",min:9,max:9},{code:"BO",label:"Bolivia",phone:"591",min:8,max:8},{code:"GT",label:"Guatemala",phone:"502",min:8,max:8},{code:"HN",label:"Honduras",phone:"504",min:8,max:8},{code:"SV",label:"El Salvador",phone:"503",min:8,max:8},{code:"NI",label:"Nicaragua",phone:"505",min:8,max:8},{code:"CR",label:"Costa Rica",phone:"506",min:8,max:8},{code:"PA",label:"Panama",phone:"507",min:8,max:8},{code:"JM",label:"Jamaica",phone:"1",min:10,max:10},{code:"TT",label:"Trinidad and Tobago",phone:"1",min:10,max:10},{code:"AD",label:"Andorra",phone:"376",min:6,max:6},{code:"AF",label:"Afghanistan",phone:"93",min:9,max:9},{code:"AG",label:"Antigua and Barbuda",phone:"1-268",min:7,max:7},{code:"AI",label:"Anguilla",phone:"1-264",min:7,max:7},{code:"AL",label:"Albania",phone:"355",min:8,max:8},{code:"AM",label:"Armenia",phone:"374",min:8,max:8},{code:"AS",label:"American Samoa",phone:"1-684",min:7,max:7},{code:"AT",label:"Austria",phone:"43",min:10,max:10},{code:"AW",label:"Aruba",phone:"297",min:7,max:7},{code:"AX",label:"Åland Islands",phone:"358",min:6,max:6},{code:"AZ",label:"Azerbaijan",phone:"994",min:9,max:9},{code:"BA",label:"Bosnia and Herzegovina",phone:"387",min:8,max:8},{code:"BB",label:"Barbados",phone:"1-246",min:7,max:7},{code:"BE",label:"Belgium",phone:"32",min:9,max:9},{code:"BG",label:"Bulgaria",phone:"359",min:9,max:9},{code:"BH",label:"Bahrain",phone:"973",min:8,max:8},{code:"BL",label:"Saint Barthélemy",phone:"590",min:9,max:9},{code:"BM",label:"Bermuda",phone:"1-441",min:7,max:7},{code:"BN",label:"Brunei Darussalam",phone:"673",min:7,max:7},{code:"BQ",label:"Bonaire, Sint Eustatius and Saba",phone:"599",min:7,max:7},{code:"BS",label:"Bahamas",phone:"1-242",min:7,max:7},{code:"BT",label:"Bhutan",phone:"975",min:8,max:8},{code:"BV",label:"Bouvet Island",phone:"47",min:8,max:8},{code:"BY",label:"Belarus",phone:"375",min:9,max:9},{code:"BZ",label:"Belize",phone:"501",min:7,max:7},{code:"CC",label:"Cocos (Keeling) Islands",phone:"61",min:7,max:7},{code:"CH",label:"Switzerland",phone:"41",min:9,max:9},{code:"CK",label:"Cook Islands",phone:"682",min:5,max:5},{code:"CU",label:"Cuba",phone:"53",min:8,max:8},{code:"CW",label:"Curaçao",phone:"599",min:7,max:7},{code:"CX",label:"Christmas Island",phone:"61",min:7,max:7},{code:"CY",label:"Cyprus",phone:"357",min:8,max:8},{code:"CZ",label:"Czechia",phone:"420",min:9,max:9},{code:"DK",label:"Denmark",phone:"45",min:8,max:8},{code:"DM",label:"Dominica",phone:"1-767",min:7,max:7},{code:"DO",label:"Dominican Republic",phone:"1-809",min:7,max:7},{code:"EE",label:"Estonia",phone:"372",min:8,max:8},{code:"EH",label:"Western Sahara",phone:"212",min:9,max:9},{code:"FI",label:"Finland",phone:"358",min:9,max:9},{code:"FJ",label:"Fiji",phone:"679",min:7,max:7},{code:"FM",label:"Micronesia (Federated States of)",phone:"691",min:7,max:7},{code:"FO",label:"Faroe Islands",phone:"298",min:6,max:6},{code:"GD",label:"Grenada",phone:"1-473",min:7,max:7},{code:"GE",label:"Georgia",phone:"995",min:9,max:9},{code:"GF",label:"French Guiana",phone:"594",min:9,max:9},{code:"GG",label:"Guernsey",phone:"44",min:9,max:9},{code:"GI",label:"Gibraltar",phone:"350",min:8,max:8},{code:"GL",label:"Greenland",phone:"299",min:6,max:6},{code:"GP",label:"Guadeloupe",phone:"590",min:9,max:9},{code:"GR",label:"Greece",phone:"30",min:10,max:10},{code:"GS",label:"South Georgia and the South Sandwich Islands",phone:"500",min:6,max:6},{code:"GU",label:"Guam",phone:"1-671",min:10,max:10},{code:"GY",label:"Guyana",phone:"592",min:7,max:7},{code:"HK",label:"Hong Kong",phone:"852",min:8,max:8},{code:"HM",label:"Heard Island and McDonald Islands",phone:"672",min:6,max:6},{code:"HR",label:"Croatia",phone:"385",min:9,max:9},{code:"HT",label:"Haiti",phone:"509",min:8,max:8},{code:"HU",label:"Hungary",phone:"36",min:9,max:9},{code:"IE",label:"Ireland",phone:"353",min:9,max:9},{code:"IM",label:"Isle of Man",phone:"44",min:9,max:9},{code:"IO",label:"British Indian Ocean Territory",phone:"246",min:7,max:7},{code:"IQ",label:"Iraq",phone:"964",min:10,max:10},{code:"IS",label:"Iceland",phone:"354",min:7,max:7},{code:"JE",label:"Jersey",phone:"44",min:9,max:9},{code:"JO",label:"Jordan",phone:"962",min:9,max:9},{code:"KG",label:"Kyrgyzstan",phone:"996",min:9,max:9},{code:"KH",label:"Cambodia",phone:"855",min:9,max:9},{code:"KI",label:"Kiribati",phone:"686",min:7,max:7},{code:"KN",label:"Saint Kitts and Nevis",phone:"1-869",min:10,max:10},{code:"KP",label:"North Korea",phone:"850",min:9,max:9},{code:"KW",label:"Kuwait",phone:"965",min:8,max:8},{code:"KY",label:"Cayman Islands",phone:"1-345",min:10,max:10},{code:"KZ",label:"Kazakhstan",phone:"7",min:10,max:10},{code:"MC",label:"Monaco",phone:"377",min:8,max:9},{code:"LI",label:"Liechtenstein",phone:"423",min:7,max:7},{code:"VA",label:"Vatican City",phone:"379",min:9,max:9},{code:"SM",label:"San Marino",phone:"378",min:10,max:10},{code:"ME",label:"Montenegro",phone:"382",min:8,max:8},{code:"RS",label:"Serbia",phone:"381",min:9,max:9},{code:"MK",label:"North Macedonia",phone:"389",min:8,max:8},{code:"SJ",label:"Svalbard and Jan Mayen",phone:"47",min:8,max:8},{code:"MF",label:"Saint Martin",phone:"590",min:9,max:9},{code:"PM",label:"Saint Pierre and Miquelon",phone:"508",min:6,max:6},{code:"WF",label:"Wallis and Futuna",phone:"681",min:6,max:6},{code:"TV",label:"Tuvalu",phone:"688",min:5,max:5},{code:"NR",label:"Nauru",phone:"674",min:7,max:7},{code:"TO",label:"Tonga",phone:"676",min:5,max:5},{code:"WS",label:"Samoa",phone:"685",min:7,max:7},{code:"VU",label:"Vanuatu",phone:"678",min:7,max:7},{code:"SB",label:"Solomon Islands",phone:"677",min:7,max:7},{code:"FM",label:"Micronesia",phone:"691",min:7,max:7},{code:"MH",label:"Marshall Islands",phone:"692",min:7,max:7},{code:"PW",label:"Palau",phone:"680",min:7,max:7}];function Va({label:e,placeholder:n,classLabel:o,isRequired:s,isOptional:a,name:t,value:l,error:r,disabled:d,readOnly:c,horizontal:u,description:g,validate:p,onChange:h,onError:y}){const[f,m]=b.useState(""),[x,w]=b.useState(null),[k,S]=b.useState(""),A=b.useMemo(()=>{var M;return(M=gi==null?void 0:gi.slice().sort((T,B)=>T.label.localeCompare(B.label)))==null?void 0:M.map(T=>({...T,phone:`+${T.phone}`}))},[]),_=b.useMemo(()=>f?A.filter(M=>`${M.label} ${M.phone}`.toLowerCase().includes(f.toLowerCase())):A,[f,A]),j=(x==null?void 0:x.min)||10,L=(x==null?void 0:x.max)||10,Q=()=>k?`${(x==null?void 0:x.phone)||"+234"}-${k}`:"",W=M=>{if(!M)return{code:"+234",number:""};const T=M.split(/[-\s]/);return{code:T[0],number:T.slice(1).join(" ")}};b.useEffect(()=>{if(l){const M=W(l);w(A.find(T=>T.phone===M.code)||A[0]),S(M.number)}},[l,A]);const D=b.useMemo(()=>{if(r)return r;const M=k.length;return s&&M===0?"Phone number is required":M>0&&!/^\d+$/.test(k)?"Phone number must contain only digits":M>0&&M<j?`Minimum length is ${j}`:M>L?`Maximum length is ${L}`:""},[r,k,j,L,s]);return b.useEffect(()=>{h==null||h(Q()),y==null||y(D||null)},[k,x,D]),i.jsxs("div",{className:`relative formGroup ${D&&!c?"has-error":""} ${u?"flex":""} ${!D&&k.length>0&&!c?"is-valid":""}`,children:[e&&i.jsxs("label",{htmlFor:t,className:`${o} ${u?"flex-0 mr-6 md:w-[100px] w-[60px] break-words":""} flex items-center gap-x-1 input-label text-sm text-[#1B2B41B8]`,children:[e," ",s&&i.jsx("span",{className:"text-red-500",children:"*"}),a&&i.jsx("span",{className:"text-[#98A2B3]",children:"(Optional)"})]}),i.jsxs("div",{className:"relative !flex items-center input-control text-[#667085] !py-0 field-control",children:[i.jsx(F,{icon:"lucide:phone-call"}),i.jsx(K.Combobox,{value:x,onChange:w,children:i.jsxs("div",{className:"relative",children:[i.jsx(K.Combobox.Input,{className:"pl-3 pr-4 mr-1 text-sm bg-white py-[10px] outline-none whitespace-nowrap max-w-[70px]",displayValue:M=>(M==null?void 0:M.phone)||"+234",placeholder:"+234",onChange:M=>m(M.target.value)}),i.jsx(K.Combobox.Button,{className:"absolute inset-y-0 right-0 flex items-center pr-2",children:i.jsx(F,{icon:"lucide:chevron-down"})}),i.jsx(K.Combobox.Options,{className:"absolute z-10 w-[250px] left-0 bg-white border rounded-md shadow-lg max-h-[400px] overflow-y-auto",children:_==null?void 0:_.map((M,T)=>i.jsxs(K.Combobox.Option,{value:M,className:"px-4 py-2 cursor-pointer hover:bg-gray-100",children:[M.phone," - ",M.label]},`${M.code}+ ${T}`))})]})}),i.jsxs("div",{className:"relative flex items-center flex-1 z-[1]",children:[i.jsx("input",{type:"tel",inputMode:"numeric",value:k,disabled:d,readOnly:c,onChange:M=>{const T=M.target.value.replace(/\D/g,"");S(T)},placeholder:n,className:"w-full px-3 outline-none"}),i.jsx("div",{className:"absolute flex text-xl -translate-y-1/2 top-1/2 right-4",children:!D&&k.length>0&&!c&&i.jsx("span",{className:"text-green-500",children:i.jsx(F,{icon:"bi:check-lg"})})})]})]}),g&&i.jsx("span",{className:"block text-[#475467] font-light leading-4 text-xs mt-2",children:g})]})}function Ua({element:e,validationData:n}){const{register:o=()=>({}),setValue:s,watch:a,isReadOnly:t,setError:l,clearErrors:r}=n||{};let d;return b.useEffect(()=>{o(e.id)},[e.id,o]),a&&(d=a()[e.id]),i.jsx(Va,{placeholder:e.placeholder,label:"",name:e.id,value:d,readOnly:t,disabled:t,onError:c=>{c?l==null||l(e.id,{type:"manual",message:c}):r(e.id)},onChange:c=>{c&&(s==null||s(e.id,c))}})}function Wa({element:e,validationData:n}){const{register:o=()=>({}),watch:s}=n||{};let a;return s&&(a=s()[e.id]),i.jsxs("div",{children:[!(n!=null&&n.isReadOnly)&&i.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"Enter Url link",className:V("field-control",e==null?void 0:e.customClass),...o(e==null?void 0:e.id),disabled:n==null?void 0:n.isReadOnly}),a&&i.jsx("div",{className:n!=null&&n.isReadOnly?"field-control !bg-gray-50 mt-1":"mt-1 text-xs",children:i.jsx("a",{title:"Visit link",target:"_blank",className:"hover:underline text-blue-700",href:a,children:a})})]})}const vn={textField:Xe,longText:ea,selectField:Xo,multiSelect:ui,numberField:Xe,amountField:ja,date:Hn,password:Yo,checkbox:Qo,radio:Zo,email:Xe,file:qo,dataGrid:Ra,section:$o,validateInput:Ta,tableInput:Ba,spacer:La,divider:Pa,header:Oa,basicText:Ia,phoneField:Ua,cascadeSelect:za,rating:Ha,country:bn,bank:bn,document:Fa,link:Wa},pn="edit",gn=(e,n)=>{const o=vn[e.type];return o?i.jsx(pi,{element:e,state:pn,children:i.jsxs("div",{className:"relative w-full",children:[e.type.toLowerCase()!=="grid"&&i.jsx("div",{className:"absolute top-0 left-0 z-20 w-full h-full"}),i.jsx(o,{element:e,state:pn,sectionId:n})]})}):null},hi=({col:e,children:n,customClass:o})=>i.jsx("div",{className:V("w-full bg-white",o),style:{gridColumn:e},children:n}),Ja=({element:e,sectionId:n,children:o,customClass:s,state:a})=>{const{formData:t,addElement:l,setIsDragging:r}=b.useContext(le),d=b.useMemo(()=>Array.from({length:e.columns}),[e.columns]),c=b.useCallback(p=>{p.preventDefault(),p.stopPropagation(),p.dataTransfer.dropEffect="move"},[]),u=b.useCallback((p,h)=>{var y,f;p.preventDefault(),r(!1);try{const m=p.dataTransfer.getData("properties");if(!m)return;const x=JSON.parse(m);if((x==null?void 0:x.type)==="grid")return;const w=h+1;if((f=(y=t.find(A=>A.id===n))==null?void 0:y.questionData)==null?void 0:f.some(A=>{var _;return A.gridId===e.id&&((_=A.gridPosition)==null?void 0:_.col)===w}))return;const S={...x,id:be.v4(),sectionId:n,gridId:e.id,gridPosition:{col:w}};l(S,n)}catch(m){console.error("Drop failed in grid:",m),r(!1)}},[l,e.id,t,n,r]),g=(p,h,y)=>{const f=Array.isArray(o)&&o.find(m=>{var x;return((x=m==null?void 0:m.props)==null?void 0:x.col)===p+1});return i.jsx("div",{children:i.jsx("div",{id:p.toString(),onDrop:m=>u(m,p),onDragOver:c,className:V("border rounded-lg min-h-[110px] bg-white ","flex items-center justify-center text-gray-400 transition-colors",`${y==="edit"?"p-3":""}`,h),children:f||i.jsx("span",{children:y==="edit"&&i.jsx(F,{icon:"ph:plus-bold"})})})},p)};return i.jsx("div",{className:"relative w-full",children:i.jsx("div",{className:"grid w-full gap-3",style:{gridTemplateColumns:`repeat(${e.columns}, 1fr)`},children:d==null?void 0:d.map((p,h)=>g(h,s,a))})})},fi=b.memo(Ja),qa="edit";function Ya({elementData:e,sectionId:n}){const{formData:o,updateElementPosition:s,isDragging:a,setIsDragging:t,addElementInPosition:l}=b.useContext(le),[r,d]=b.useState(null),[c,u]=b.useState(null),g=b.useMemo(()=>{var k;return((k=o.find(S=>S.id===n))==null?void 0:k.questionData)||[]},[o,n]),p=b.useCallback((k,S)=>{k.dataTransfer.setData("properties",S),d(S)},[]),h=b.useCallback((k,S)=>{k.preventDefault(),k.stopPropagation(),u(S)},[]),y=b.useCallback(k=>{k.preventDefault(),k.stopPropagation();const S=k.dataTransfer.getData("properties"),A=k.currentTarget.id;if(!A||S===A)return;const _=g.findIndex(W=>W.id===S),j=g.findIndex(W=>W.id===A);if(_===-1||j===-1)return;const L=[...g],[Q]=L.splice(_,1);L.splice(j,0,Q),s(L,n),d(null)},[g,n,s]),f=b.useCallback((k,S)=>{k.preventDefault(),t(!1);try{const A=JSON.parse(k.dataTransfer.getData("properties"));if((A==null?void 0:A.type)==="section")return;const _={...A,id:be.v4(),sectionId:n};l(_,n,S)}catch(A){console.error("Drop error:",A)}},[l,n,t]),m=b.useCallback(k=>i.jsx("div",{className:"transition rounded hover:bg-blue-300",onDragOver:S=>S.preventDefault(),onDrop:S=>f(S,k),onDragEnd:()=>t(!1),children:i.jsx("div",{className:"bg-blue-50 rounded p-6 h-[60px] border-2 border-blue-300 border-dashed flex items-center justify-center text-gray-400 opacity-70",children:i.jsx(F,{icon:"octicon:plus-16"})})},`drop-${k}`),[f,t]),x=b.useCallback(k=>i.jsx("div",{id:k.id,className:V("cursor-move border p-4 w-full rounded-lg transition-colors bg-white",{"bg-gray-100":r===k.id,"border-dashed border-blue-300":r&&r!==k.id}),draggable:!0,onDragStart:S=>p(S,k.id),onDragOver:S=>h(S,k.id),onDrop:y,onDragEnd:()=>d(null),children:gn(k,n)},k.id),[r,y,h,n,p]),w=b.useMemo(()=>(e==null?void 0:e.reduce((k,S)=>(S.gridId&&(k[S.gridId]=k[S.gridId]||[],k[S.gridId].push(S)),k),{}))||{},[e]);return e!=null&&e.length?i.jsx("div",{className:"relative grid w-full h-full grid-cols-1 gap-4",children:e==null?void 0:e.map((k,S)=>{if(k.type==="grid"){const A=w[k.id]||[];return i.jsx("div",{draggable:!0,onDragStart:_=>p(_,k.id),onDragOver:_=>h(_,k.id),onDrop:y,onDragEnd:()=>d(null),className:"w-full p-4 transition-colors bg-white border rounded-lg cursor-move",children:i.jsx(pi,{element:k,state:"edit",children:i.jsx(fi,{element:k,sectionId:n,state:qa,children:A==null?void 0:A.map(_=>{var j;return i.jsx(hi,{col:(j=_.gridPosition)==null?void 0:j.col,children:gn(_,n)},_.id)})})})},k.id)}return k.gridId?null:i.jsxs("div",{className:V("group relative grid gap-y-[6px]",k.elementClass),children:[a&&c===k.id&&m(S),i.jsx("div",{className:"group",children:x(k)}),a&&c===k.id&&m(S+1)]},k.id)})}):i.jsx("div",{onDragOver:k=>k.preventDefault(),onDrop:k=>f(k,0),onDragEnd:()=>t(!1),className:"w-full h-full flex items-center justify-center text-gray-400 min-h-[200px] p-10 col-span-2 border border-dashed border-gray-300 rounded-lg",children:"Drag or click an element to display"})}const Za=b.memo(Ya),$a=E.object({title:E.string(),description:E.string()}).required(),xi=ue("config"),Qa=({isOpen:e,onClose:n,section:o})=>{const{updateSection:s}=b.useContext(le),{register:a,handleSubmit:t,watch:l,formState:{errors:r,isSubmitting:d,isValid:c},reset:u}=ye.useForm({resolver:mi($a),defaultValues:o});if(b.useEffect(()=>{e||u()},[e,u]),!e)return null;const g=p=>{s(p,o.id),n()};return i.jsx("div",{className:"fixed inset-0 bg-black/30 flex items-center justify-center z-[999] cursor-default no-drag select-none",children:i.jsxs("div",{className:"min-w-[600px] bg-white rounded-xl shadow-xl relative flex flex-col items-center",children:[i.jsxs("div",{className:"w-full px-6 pt-6 pb-5 flex flex-col items-start gap-4 z-10 mb-6",children:[i.jsx("h2",{className:"text-lg font-semibold text-[#475467] font-onest",children:"Update Section Information"}),i.jsx("button",{onClick:n,className:"absolute right-4 top-4 p-2 text-[#98A2B3] hover:bg-gray-50 rounded-lg",children:i.jsx(F,{icon:"tabler:x"})})]}),i.jsxs("form",{onSubmit:t(g),className:"w-full",children:[i.jsxs("div",{className:"w-full px-6 flex flex-col gap-5 z-10",children:[i.jsx(G,{label:"Title",name:"title",register:a,errors:r,watch:l}),i.jsx(G,{label:"Description",name:"description",register:a,errors:r,watch:l})]}),i.jsxs("div",{className:"w-full px-6 pt-8 pb-6 flex gap-3 mt-4",children:[i.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",children:"Cancel"}),i.jsx("button",{type:"submit",disabled:!c||d,style:{background:(xi==null?void 0:xi.buttonColor)||"#333"},className:`flex-1 px-4 py-2.5 ${!c||d?"bg-[#F2F4F7]":"bg-[#2563EB]"} ${!c||d?"text-[#98A2B3]":"text-white"} rounded-lg shadow-xs font-semibold font-onest disabled:opacity-50`,children:d?"Saving...":"Save"})]})]})]})})},Xa=()=>{const[e,n]=b.useState(!1),o=b.useRef(null),s=b.useRef(null),{removeSection:a,addSection:t,formData:l,setIsDragging:r,setSelectedSection:d,selectedSection:c,activeSections:u,setActiveSections:g}=b.useContext(le);b.useEffect(()=>{var m;d(((m=l[0])==null?void 0:m.id)||null)},[]);const p=b.useCallback(m=>{m.preventDefault(),m.dataTransfer.dropEffect="move",s.current&&(s.current.scrollTop=s.current.scrollHeight)},[]);function h(m){u.includes(m)?g(x=>x.filter(w=>w!==m)):g(x=>[...x,m])}function y(m){o.current=m,n(!0)}const f=ue("config");return i.jsxs("div",{ref:s,className:"relative flex flex-col h-full px-6 pb-5 mx-auto gap-x-4",children:[e&&i.jsx(Qa,{isOpen:e,onClose:()=>n(!1),section:o.current}),i.jsxs("div",{className:"relative flex flex-col flex-1 w-full py-4 gap-y-6",children:[l==null?void 0:l.map((m,x)=>i.jsx("div",{className:"bg-white group cursor-pointer rounded ",children:i.jsxs("div",{className:`border border-gray-100 rounded px-4 shadow-[rgba(149,157,165,0.2)_0px_2px_4px] transition-colors duration-200
56
+ }`})})]})})}),ya=()=>i.jsx("blockquote",{className:"p-4 text-gray-700 bg-gray-100 rounded-md",children:i.jsxs("ul",{children:[i.jsxs("li",{className:"text-xs",children:["Method: GET ",i.jsx("br",{}),"URL format:"," ",i.jsx("code",{children:"https://example.com/validation/{documentId}"})]}),i.jsxs("li",{className:"text-xs",children:[i.jsx("span",{className:"block mb-1",children:" Response example format:"}),i.jsx("pre",{className:"p-2 bg-white rounded-md",children:i.jsxs("code",{children:["{ ",i.jsx("br",{}),'  "data": { ',i.jsx("br",{}),'    "status": true, ',i.jsx("br",{}),'    "isSigned": true ',i.jsx("br",{}),"  } ",i.jsx("br",{}),"}"]})})]})]})});function ka(e){return e.flatMap(n=>{var o;return(o=n.questionData)!=null?o:[]})}const vi=["text","number","boolean"],cn=["equals","not_equals","contains","not_contains"],wa=["greater","less"];function _a({register:e,setValue:n,trigger:o,watch:s,id:a}){const{formData:t}=b.useContext(le),l=s("visibilityDependentFields")||[],r=b.useMemo(()=>{var c;return(c=ka(t).filter(u=>u.id!==a))==null?void 0:c.map(u=>{const g=l.find(p=>p.id===u.id);return{id:u.id,value:u.id,label:u.inputLabel,sectionId:u.sectionId,fieldType:(g==null?void 0:g.fieldType)||"text",operator:(g==null?void 0:g.operator)||"equals",fieldValue:(g==null?void 0:g.fieldValue)!==void 0?g.fieldValue:""}})},[t,l,a]),d=(c,u,g)=>{const p=l==null?void 0:l.map((h,y)=>y===c?{...h,[u]:g}:h);n("visibilityDependentFields",p)};return i.jsxs("div",{className:"visibility-editor",children:[i.jsx("label",{className:"label",children:"Select Dependent Fields"}),i.jsx(ui,{element:{options:r,id:"visibilityDependentFields",value:s("visibilityDependentFields")},validationData:{register:e,setValue:n,trigger:o,watch:s}}),l.length>0&&i.jsx("div",{className:"py-1 bg-gray-100 rounded dependent-fields",children:l==null?void 0:l.map((c,u)=>{var g,p;return i.jsxs("div",{className:"dependent-field",children:[i.jsx("input",{type:"text",value:c.label,readOnly:!0,disabled:!0,className:"field-label"}),i.jsx("div",{className:"field-listbox min-w-[100px]",children:i.jsx(K.Listbox,{value:c.fieldType,onChange:h=>d(u,"fieldType",h),children:i.jsxs("div",{className:"listbox-wrapper",children:[i.jsx(K.Listbox.Button,{className:"listbox-button",children:c.fieldType}),i.jsx(K.Transition,{as:b.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:i.jsx(K.Listbox.Options,{className:"listbox-options ",anchor:"bottom",children:vi==null?void 0:vi.map(h=>i.jsx(K.Listbox.Option,{value:h,className:"listbox-option",children:h},h))})})]})})}),i.jsx("div",{className:"field-listbox min-w-[100px]",children:i.jsx(K.Listbox,{value:c.operator,onChange:h=>d(u,"operator",h),children:i.jsxs("div",{className:"listbox-wrapper",children:[i.jsx(K.Listbox.Button,{className:"listbox-button",children:c.operator.replace("_"," ")}),i.jsx(K.Transition,{as:b.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:i.jsx(K.Listbox.Options,{className:"listbox-options ",anchor:"bottom",children:(g=c.fieldType==="number"?[...cn,...wa]:cn)==null?void 0:g.map(h=>i.jsx(K.Listbox.Option,{value:h,className:"listbox-option",children:h.replace("_"," ")},h))})})]})})}),c.fieldType!=="boolean"?i.jsx("input",{type:c.fieldType,value:c.fieldValue||"",onChange:h=>d(u,"fieldValue",h.target.value),placeholder:"Value",className:"field-value"}):i.jsx("div",{className:"field-listbox",children:i.jsx(K.Listbox,{value:(p=c.fieldValue)!=null?p:"",onChange:h=>d(u,"fieldValue",h),children:i.jsxs("div",{className:"listbox-wrapper",children:[i.jsx(K.Listbox.Button,{className:"listbox-button",children:c.fieldValue===!0?"True":c.fieldValue===!1?"False":"Select value"}),i.jsx(K.Transition,{as:b.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:i.jsxs(K.Listbox.Options,{className:"listbox-options ",anchor:"bottom",children:[i.jsx(K.Listbox.Option,{value:!0,className:"listbox-option",children:"True"}),i.jsx(K.Listbox.Option,{value:!1,className:"listbox-option",children:"False"})]})})]})})})]},c.id)})})]})}const Aa=E.object().shape({inputLabel:E.string().nullable(),placeholder:E.string().nullable(),description:E.string().nullable(),isReadOnly:E.boolean(),isDisabled:E.boolean(),isRequired:E.boolean(),requiredMessage:E.string().nullable(),minLengthMessage:E.string().nullable(),maxLengthMessage:E.string().nullable(),maxLength:E.number().typeError("Expecting a number").nullable(),minLength:E.number().typeError("Expecting a number").nullable(),inputType:E.string().nullable(),maxAmountMessage:E.string().nullable(),maxAmount:E.string().nullable(),options:E.array().of(E.object().shape({label:E.string().nullable(),value:E.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:E.array().of(E.object().shape({label:E.string().nullable(),value:E.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:E.string().nullable(),url:E.string().nullable(),method:E.string().nullable(),denominators:E.mixed().nullable(),responseType:E.string().nullable(),minAmount:E.string().nullable(),heading:E.string().nullable(),minAmountMessage:E.string().nullable(),columns:E.number().nullable(),value:E.mixed().nullable(),customClass:E.string().nullable(),elementClass:E.string().nullable(),apiUrl:E.string().nullable(),selectType:E.string().default("list"),dateType:E.string().default("basic"),validationUrl:E.string(),signatureLink:E.string(),minDate:E.string().nullable(),maxDate:E.string().nullable(),canHaveDateRange:E.boolean(),allowYearPicker:E.boolean(),isHidden:E.boolean(),visibilityDependentFields:E.array().nullable(),isMultiple:E.boolean(),acceptedFiles:E.array(),showState:E.boolean()}),Sa=[{title:"Configurations",key:"basic"},{title:"Validations",key:"validation"}],Na=({isOpen:e,onClose:n,element:o})=>{const s=Sa.filter(R=>!Je.includes(o.inputType)||R.key!=="validation"),{updateElement:a}=b.useContext(le),[t,l]=b.useState("basic"),[r,d]=b.useState(!1),[c,u]=b.useState("manual"),g=ue("config"),{register:p,handleSubmit:h,control:y,setValue:f,watch:m,trigger:x,formState:{errors:w,isSubmitting:k,isValid:S},reset:A}=ye.useForm({resolver:mi(Aa),defaultValues:{...o,options:o.options||[]}}),_=m(),{fields:j,append:L,remove:Q}=ye.useFieldArray({control:y,name:"options"}),{fields:W,append:D,remove:M}=ye.useFieldArray({control:y,name:"options1"}),{fields:T,append:B,remove:I}=ye.useFieldArray({control:y,name:"dataColumns"});b.useEffect(()=>{e||A()},[e,A]);const Y=R=>{a(R,o.sectionId),n()},oe={headers:{Authorization:`Bearer ${ue("token")}`}},O=b.useCallback(async()=>{var R,z,te;if(!_.apiUrl||!/^https?:\/\//.test(_.apiUrl)){me.toast.info("Please provide a valid API URL");return}try{d(!0);const{status:Z,data:de}=await je.get(_.apiUrl,oe);if(Z!==200||!de){me.toast.error("Unexpected response from server.");return}const ee=de.data||de.record||de.result;if(!Array.isArray(ee)){me.toast.error("Expected an array in response (data, record, or result).");return}((R=o.type)==null?void 0:R.toLowerCase())==="datagrid"?f("dataColumns",ee):f("options",ee)}catch(Z){const de=((te=(z=Z==null?void 0:Z.response)==null?void 0:z.data)==null?void 0:te.message)||(Z==null?void 0:Z.message)||"Unable to load options";me.toast.error(de)}finally{d(!1)}},[o.type,f,_.apiUrl]),se=["manual","api","sheet"];function ve(){c==="api"&&O()}const pe=()=>i.jsxs("div",{className:"flex flex-col justify-start gap-y-1",children:[i.jsx("div",{className:"flex items-center mb-4 gap-x-5",children:se==null?void 0:se.map(R=>i.jsxs("label",{className:"items-center text-base capitalize gap-x-3",children:[i.jsx("input",{type:"radio",name:"optionType",onChange:z=>u(z.target.value),value:R})," ",i.jsxs("span",{children:[R," options"]})]},R))}),c==="api"&&i.jsxs("div",{className:"mb-4",children:[i.jsxs("div",{className:"flex items-center gap-x-2",children:[i.jsxs("div",{className:"relative flex items-center w-full mb-2",children:[i.jsx(G,{watch:m,label:"Load Options from Api",name:"apiUrl",errors:w,register:p,className:"!w-full",placeholder:"https://example.com/options",isFloating:!0}),r&&i.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"})]}),i.jsx("button",{onClick:ve,className:"px-3 py-1 text-xs text-white bg-gray-600 rounded",type:"button",children:"Load"})]}),i.jsx(ha,{})]}),c==="sheet"&&i.jsx("div",{className:"mb-4",children:i.jsx(un,{isFloating:!0,label:"Load options form sheet (csv, xlsx)",setValue:f,name:"options"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"mb-4 text-sm text-gray-500",children:"Parent Options "}),j==null?void 0:j.map((R,z)=>i.jsxs("div",{className:"flex items-center mb-1 gap-x-4 last:mb-0",children:[i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:z===0?"Label":"",name:`options.${z}.label`,register:p,errors:w,element:o,placeholder:"Label"})}),i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:z===0?"Value":"",name:`options.${z}.value`,register:p,errors:w,element:o,placeholder:"Value"})}),i.jsx("button",{disabled:j.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>Q(z),children:i.jsx(F,{icon:"iconamoon:sign-times-fill"})})]},R.id))," ",i.jsxs("div",{children:[" ",i.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>L({label:"",value:"",id:be.v4()}),children:[i.jsx(F,{icon:"qlementine-icons:plus-16"})," Add Option"]})]})]}),o.type.toLowerCase()==="cascadeselect"&&i.jsxs(i.Fragment,{children:[i.jsx("hr",{className:"my-5"}),i.jsxs("div",{children:[" ",i.jsx("h3",{className:"mb-4 text-sm text-gray-500",children:"Child Options "}),W==null?void 0:W.map((R,z)=>i.jsxs("div",{className:"flex items-center mb-1 gap-x-4 last:mb-0",children:[i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Label",name:`options1.${z}.label`,register:p,errors:w,element:o,placeholder:"Label",isFloating:!0})}),i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Value",name:`options1.${z}.value`,register:p,errors:w,element:o,placeholder:"Value",isFloating:!0})}),i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Key",name:`options1.${z}.key`,register:p,errors:w,element:o,placeholder:"Key",isFloating:!0})}),i.jsx("button",{disabled:W.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>M(z),children:i.jsx(F,{icon:"iconamoon:sign-times-fill"})})]},R.id)),i.jsxs("div",{children:[" ",i.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>D({label:"",value:"",key:"",id:be.v4()}),children:[i.jsx(F,{icon:"qlementine-icons:plus-16"})," Add Option"]})]})]})]})]}),fe=()=>i.jsxs("div",{className:"flex flex-col justify-start gap-y-1",children:[i.jsx("div",{className:"flex items-center mb-4 gap-x-5",children:se==null?void 0:se.map(R=>i.jsxs("label",{className:"items-center text-base capitalize gap-x-3",children:[i.jsx("input",{type:"radio",name:"optionType",onChange:z=>u(z.target.value),value:R,checked:R===c})," ",i.jsxs("span",{children:[R," options"]})]},R))}),c==="api"&&i.jsxs("div",{className:"mb-4",children:[i.jsxs("div",{className:"flex items-center gap-x-2",children:[i.jsxs("div",{className:"relative flex items-center w-full mb-2",children:[i.jsx(G,{watch:m,label:"Load Columns from Api",name:"apiUrl",errors:w,register:p,className:"!w-full",placeholder:"https://example.com/columns",isFloating:!0}),r&&i.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"})]})," ",i.jsx("button",{onClick:ve,className:"px-3 py-1 text-xs text-white bg-gray-600 rounded",type:"button",children:"Load"})]}),i.jsx(fa,{})]}),c==="sheet"&&i.jsx("div",{className:"mb-4",children:i.jsx(un,{isFloating:!0,label:"Load columns form sheet (csv, xlsx)",setValue:f,name:"dataColumns"})}),T==null?void 0:T.map((R,z)=>i.jsxs("div",{className:"flex items-center gap-x-4 ",children:[i.jsx("div",{className:"min-w-[140px]",children:i.jsx(Me,{label:z===0?"Type":"",options:[{label:"Text",value:"text"},{label:"Number",value:"number"},{label:"Checkbox",value:"checkbox"}],register:p,name:`dataColumns.${z}.type`,setValue:f,trigger:x,value:_.dataColumns[z].type})}),i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:z===0?"Field key":"",name:`dataColumns.${z}.field`,register:p,errors:w,element:o,placeholder:"fieldKey"})}),i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:z===0?"Display header":"",name:`dataColumns.${z}.headerName`,register:p,errors:w,element:o,placeholder:"header"})}),i.jsx("button",{disabled:T.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>I(z),children:i.jsx(F,{icon:"iconamoon:sign-times-fill"})})]},R.id)),i.jsxs("div",{children:[" ",i.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>B({headerName:"",field:"",editable:!0,id:be.v4(),type:"text",validate:!1}),children:[i.jsx(F,{icon:"qlementine-icons:plus-16"})," Add column"]})]})]}),xe=b.useCallback(async()=>{const R=ue("token"),{status:z,data:te}=await je.get(_.url,{headers:{Authorization:`Bearer ${R}`}});z===200&&f("options",(te==null?void 0:te.data)||te)},[f,_.url]);return b.useEffect(()=>{o.type==="document"&&_.url&&xe()},[_.url,o.type,xe]),i.jsx("div",{className:"fixed inset-0 bg-gray-800/40 backdrop-blur-sm flex items-center justify-end z-[999] cursor-default select-none ",draggable:"true",onDragStart:R=>R.preventDefault(),children:i.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 select-",draggable:"true",onDragStart:R=>R.preventDefault(),children:[i.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:i.jsx(F,{icon:"tabler:x",iconClass:"text-xl"})}),i.jsx("div",{className:"w-full pt-4",children:i.jsx(ia,{tabs:s,setActiveTab:l,activeTab:t,className:"justify-start !text-left",btnClass:" !text-left"})}),i.jsxs("form",{onSubmit:h(Y),className:"w-full flex-1 flex flex-col",children:[i.jsxs("div",{className:"flex-1",children:[" ",i.jsxs("div",{className:" max-h-[70vh] overflow-y-auto flex-1",children:[t==="basic"&&i.jsxs("div",{className:"z-10 flex flex-col w-full gap-5 px-6",children:[bi.includes(o.inputType)&&i.jsx(i.Fragment,{children:i.jsx(G,{watch:m,label:"Value",name:"value",register:p,errors:w,element:o})}),!bi.includes(o.inputType)&&!Je.includes(o.inputType)&&i.jsxs(i.Fragment,{children:[i.jsx(G,{watch:m,label:"Label",name:"inputLabel",register:p,errors:w,element:o})," ",o.type.toLowerCase()==="cascadeselect"&&i.jsx(G,{watch:m,label:"Child Label",name:"childLabel",register:p,errors:w,element:o})]}),ra.includes(o.inputType)&&i.jsx(G,{watch:m,label:"Placeholder",name:"placeholder",register:p,errors:w,element:o}),la.includes(o.inputType)&&i.jsx(G,{watch:m,label:"Prefix",name:"prefix",register:p,errors:w,element:o}),ma.includes(o.inputType)&&i.jsxs("div",{className:"grid gap-y-4",children:[i.jsx(ga,{}),i.jsx(G,{watch:m,label:"Api Url",name:"url",register:p,errors:w,element:o}),i.jsx(Me,{label:"Api Method",options:[{label:"GET",value:"GET"},{label:"POST",value:"POST"}],register:p,name:"method",setValue:f,trigger:x,value:m("method")}),i.jsx(Me,{label:"Api Response type",options:[{label:"String",value:"string"},{label:"Object",value:"object"}],register:p,name:"responseType",setValue:f,trigger:x,value:m("responseType")})]}),ba.includes(o.inputType)&&i.jsx(pa,{onChange:R=>{f("denominators",R)},value:m("denominators")}),!bi.includes(o.inputType)&&!Je.includes(o.inputType)&&i.jsx(G,{watch:m,label:"Short Description",name:"description",register:p,errors:w,element:o}),o.type.toLowerCase()==="date"&&i.jsxs(i.Fragment,{children:[i.jsx(Me,{label:"Date Format",options:ta,register:p,name:"dateFormat",setValue:f,trigger:x,value:m("dateFormat")}),i.jsx(G,{watch:m,label:"Allow Range",name:"canHaveDateRange",register:p,errors:w,element:o,type:"checkbox"}),(_==null?void 0:_.canHaveDateRange)&&i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(Qe,{name:"minDate",value:_==null?void 0:_.minDate,onGetValue:f,placeholder:"Select min date"}),i.jsx(Qe,{name:"maxDate",value:_==null?void 0:_.minDate,onGetValue:f,placeholder:"Select max date",minDate:_==null?void 0:_.minDate})]}),i.jsx(G,{watch:m,label:"Allow Year Picker",name:"allowYearPicker",register:p,errors:w,element:o,type:"checkbox"})]}),o.type.toLowerCase()==="country"&&i.jsx(G,{watch:m,label:"Allow States",name:"showState",register:p,errors:w,element:o,type:"checkbox"}),o.type.toLowerCase()==="selectfield"&&i.jsx(Me,{label:"Select Type",options:[{label:"List",value:"list"},{label:"Combobox",value:"Combobox"}],register:p,name:"selectType",setValue:f,trigger:x,value:m("selectType")}),o.type.toLowerCase()==="grid"&&i.jsx(G,{watch:m,label:"Number of columns",name:"columns",register:p,errors:w,element:o}),o.type.toLowerCase()==="document"&&i.jsxs("div",{className:"grid gap-y-6",children:[i.jsxs("div",{className:"grid gap-y-1",children:[i.jsx(G,{watch:m,label:"Document Options Url",name:"url",register:p,errors:w,element:o})," ",i.jsx(xa,{})]}),i.jsxs("div",{className:"grid gap-y-1",children:[i.jsx(G,{watch:m,label:"Document Validation Url",name:"validationUrl",register:p,errors:w,element:o}),i.jsx(ya,{})]}),i.jsx("div",{className:"grid gap-y-1",children:i.jsx(G,{watch:m,label:"Signature Page Url",name:"signatureLink",register:p,errors:w,element:o})})]}),o.type.toLowerCase()==="datagrid"&&fe(),o.type.toLowerCase()==="file"&&i.jsxs(i.Fragment,{children:[i.jsx(G,{watch:m,label:"Allow Multiple Uploads",name:"isMultiple",register:p,errors:w,element:o,type:"checkbox"}),i.jsx(ui,{element:{options:va,id:"acceptedFiles",value:_==null?void 0:_.acceptedFiles},validationData:{register:p,setValue:f,trigger:x,watch:m},placeholder:"Choose file types"})]}),ca.includes(o.inputType)&&pe(),i.jsxs("div",{children:[i.jsx("div",{className:"w-[150px] mb-4",children:i.jsx(G,{watch:m,label:"Toggle Visibility",name:"isHidden",register:p,errors:w,element:o,type:"checkbox"})})," ",_.isHidden&&i.jsx(_a,{register:p,setValue:f,trigger:x,watch:m,id:o==null?void 0:o.id})]})]}),!Je.includes(o.type.toLowerCase())&&t==="validation"&&i.jsxs("div",{className:"z-10 flex flex-col w-full gap-5 px-6",children:[i.jsxs("div",{className:"flex items-center gap-x-6",children:[i.jsx("div",{className:"w-[150px]",children:i.jsx(G,{watch:m,label:"Required",name:"isRequired",register:p,errors:w,element:o,type:"checkbox"})})," ",i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Error message text",name:"requiredMessage",register:p,errors:w,element:o})})]}),da.includes(o.inputType)&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-x-6",children:[i.jsx("div",{className:"w-[150px]",children:i.jsx(G,{watch:m,label:"Min Length",name:"minLength",register:p,errors:w,element:o,type:"number"})})," ",i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Error message text",name:"minLengthMessage",register:p,errors:w,element:o})})]}),i.jsxs("div",{className:"flex items-center gap-x-6",children:[i.jsx("div",{className:"w-[150px]",children:i.jsx(G,{watch:m,label:"Max Length",name:"maxLength",register:p,errors:w,element:o,type:"number"})})," ",i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Error message text",name:"maxLengthMessage",register:p,errors:w,element:o})})]})]}),ua.includes(o.inputType)&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-x-6",children:[i.jsx("div",{className:"w-[150px]",children:i.jsx(G,{watch:m,label:"Min Amount",name:"minAmount",register:p,errors:w,element:o,type:"amount"})})," ",i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Error message text",name:"minAmountMessage",register:p,errors:w,element:o})})]}),i.jsxs("div",{className:"flex items-center gap-x-6",children:[i.jsx("div",{className:"w-[150px]",children:i.jsx(G,{watch:m,label:"Max Amount",name:"maxAmount",register:p,errors:w,element:o,type:"amount"})})," ",i.jsx("div",{className:"flex-1",children:i.jsx(G,{watch:m,label:"Error message text",name:"maxAmountMessage",register:p,errors:w,element:o})})]})]})]})]})]}),i.jsxs("div",{className:"sticky flex w-full gap-3 px-6 pt-8 pb-10 mt-10 border-t",children:[i.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"}),i.jsx("button",{type:"submit",disabled:!S||k,style:{background:(g==null?void 0:g.buttonColor)||"#333"},className:`flex-1 px-4 py-2.5 ${!S||k?"bg-[#F2F4F7]":"bg-[#2563EB]"} ${!S||k?"text-[#98A2B3]":"text-white"} rounded-lg shadow-xs font-semibold font-onest disabled:opacity-50 editor_option__save`,children:k?"Saving...":"Save"})]})]})]})})},pi=b.memo(({state:e,element:n,children:o})=>{const[s,a]=b.useState(!1),{removeElement:t,duplicateElement:l}=b.useContext(le),r=b.useMemo(()=>{var c;return(c=n==null?void 0:n.acceptedFiles)==null?void 0:c.map(u=>u.label).join(", ")},[n]),d=b.useCallback(()=>{t(n.id,n.sectionId)},[n.id,n.sectionId,t]);return i.jsxs("div",{className:"w-full",children:[s&&i.jsx(Na,{isOpen:s,onClose:()=>a(!1),element:n}),i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("span",{children:[" ",n.inputLabel&&i.jsxs("label",{className:"text-sm font-medium input_label",children:[n.inputLabel," ",r&&i.jsxs("span",{className:"text-gray-400 text-xs",children:["(",r==null?void 0:r.toLowerCase(),")"]})]})]}),e==="edit"&&i.jsxs("span",{className:"flex items-center gap-x-3",children:[!n.gridPosition&&i.jsx("button",{type:"button",className:"text-sm outline-none hover:opacity-80",onClick:()=>l(n==null?void 0:n.id,n.sectionId),title:"Duplicate",children:i.jsx(F,{icon:"tabler:copy",iconClass:"text-base"})}),i.jsx("button",{type:"button",className:"text-sm outline-none hover:opacity-80",onClick:()=>a(!0),title:"Edit",children:i.jsx(F,{icon:"circum:edit",iconClass:"text-base"})}),i.jsx("button",{type:"button",className:"text-sm outline-none hover:opacity-80",onClick:d,title:"Remove",children:i.jsx(F,{icon:"iconamoon:trash",iconClass:"text-base"})})]})]}),o]})});pi.displayName="ElementContainer";function ja({element:e,validationData:n}){const{register:o=()=>({}),trigger:s,setValue:a,watch:t,isReadOnly:l}=n||{};let r;return t&&(r=t()[e.id]),i.jsx(G,{placeholder:e.placeholder,type:e.inputType,label:"",name:e.id,register:o,trigger:s,setValue:a,value:r,prefix:e.prefix,disabled:l,watch:t})}function Ca(e){if(!e)return!1;const n=/^data:image\/(jpeg|png|gif|bmp|webp);base64,/i,o=/\.(jpeg|jpg|png|gif|bmp|webp)$/i;return n.test(e)||o.test(e)}const Ma=({imageUrl:e})=>{const[n,o]=b.useState(!1),s=()=>{o(!0)},a=()=>{o(!1)};return i.jsxs("div",{children:[i.jsx("img",{alt:"Thumbnail",style:{cursor:"pointer",width:"120px",height:"130px",objectFit:"cover"},onClick:s,src:e||"/place.png","data-toggle":"tooltip","data-placement":"top",title:"Click to view"}),n&&i.jsx("div",{className:"modal",style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",justifyContent:"center",alignItems:"center"},onClick:a,children:i.jsxs("div",{className:"modal-content",style:{position:"relative",backgroundColor:"white",padding:"20px",borderRadius:"8px",width:"90vw"},onClick:t=>t.stopPropagation(),children:[i.jsx("span",{className:"close",onClick:a,style:{position:"absolute",top:"10px",right:"10px",fontSize:"24px",cursor:"pointer"},children:"×"}),i.jsx("img",{src:e||"/place.png",alt:"Full Image",style:{maxWidth:"90%",maxHeight:"90vh",objectFit:"contain"}})]})})]})};function Ta({element:e,validationData:n}){var _;const{register:o=()=>({}),setValue:s,watch:a}=n||{},[t,l]=b.useState(),[r,d]=b.useState(!1),[c,u]=b.useState(!1),[g,p]=b.useState(""),h=a&&a(e==null?void 0:e.id);b.useEffect(()=>{l(h)},[h]);const[y,f]=b.useState("");b.useEffect(()=>{o(e.id)},[e.id,o]);const{url:m,method:x,responseType:w}=e||{},S={headers:{Authorization:`Bearer ${ue("token")}`}},A=b.useCallback(async j=>{var L,Q,W,D,M,T,B,I,Y,J,oe;if(!(!m||!x)){d(!0);try{let O;if(x.toLowerCase()==="get"){const se=`${m}?value=${j}`;O=await je.get(se,S)}else if(x.toLowerCase()==="post")O=await je.post(m,{value:j},S);else throw new Error("Unsupported HTTP method");O.status===200&&((((Q=(L=O==null?void 0:O.data)==null?void 0:L.data)==null?void 0:Q.status)||((W=O==null?void 0:O.data)==null?void 0:W.status))===!0?(u(!0),w==="string"?p(((M=(D=O==null?void 0:O.data)==null?void 0:D.data)==null?void 0:M.description)||((T=O==null?void 0:O.data)==null?void 0:T.description)||"Validation successful"):f(((I=(B=O==null?void 0:O.data)==null?void 0:B.data)==null?void 0:I.description)||((Y=O==null?void 0:O.data)==null?void 0:Y.description)||{})):(console.error("Invalid input:",j),p("Unable to validate input"),u(!1)))}catch(O){console.error("Error validating input:",O),p(((oe=(J=O==null?void 0:O.response)==null?void 0:J.data)==null?void 0:oe.message)||"Unable to validate input"),u(!1)}finally{d(!1)}}},[x,w,m]);return b.useEffect(()=>{if(t){const j=setTimeout(()=>{A(t)},700);return()=>clearTimeout(j)}},[A,t]),i.jsxs("div",{children:[i.jsxs("div",{className:"relative flex items-center",children:[i.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"",type:(e==null?void 0:e.inputType)||"text",className:V("field-control",e==null?void 0:e.customClass),...o(e==null?void 0:e.id),onChange:j=>{l(j.target.value),s(e==null?void 0:e.id,j.target.value)},disabled:n==null?void 0:n.isReadOnly}),i.jsxs("span",{className:"absolute right-0",children:[r&&i.jsxs("span",{children:[" ",i.jsxs("svg",{className:"animate-spin -ml-1 mr-3 h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[i.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),i.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})]}),c&&!r&&i.jsx("span",{className:"block pr-3 text-lg text-green-600",children:i.jsx(F,{icon:"gg:check-o"})})]})]}),g&&w==="string"&&i.jsx("span",{className:`${c?"text-green-600":"text-red-600"} text-sm`,children:g}),w==="object"&&i.jsx("div",{className:"grid grid-cols-2 gap-6 mt-2 text-sm text-gray-600",children:(_=Object.entries(y))==null?void 0:_.map(([j,L])=>i.jsxs("div",{className:"flex items-center gap-x-2",children:[i.jsxs("span",{className:"font-semibold",children:[j,":"]}),Ca(L)?i.jsx(Ma,{imageUrl:L}):i.jsx("span",{children:String(L)})]},j))})]})}function Ea({onGetTotal:e,readOnly:n,defaultValue:o,denominators:s}){const[a,t]=b.useState([...o]);function l(c,u){t(g=>{const p=[...g];return p[u]={...p[u],value:c},p})}function r(c,u){return parseFloat(c)*parseFloat(u)||0}const d=b.useMemo(()=>a.reduce((c,u)=>{const g=r(u.key,u.value);return c+g},0),[a]);return b.useEffect(()=>{e&&e(a)},[a]),b.useEffect(()=>{if(s!=null&&s.length){const c=s==null?void 0:s.map((u,g)=>({key:u.value,value:Array.isArray(o)&&o[g]?o[g].value:""}));t(c)}},[o,s]),i.jsx("div",{className:"mt-2",children:i.jsxs("div",{className:"border border-gray-200 rounded-lg overflow-hidden text-gray-700",children:[i.jsxs("div",{className:"grid grid-cols-3 text-sm font-bold border-b border-gray-100 bg-gray-50",children:[i.jsx("div",{className:"border-r px-4 py-2",children:i.jsx("span",{className:"",children:"Denomination"})}),i.jsx("div",{className:"border-r px-4 py-2",children:i.jsx("span",{children:"Quantity"})}),i.jsx("div",{className:"px-4 py-2",children:i.jsx("span",{children:"Sub total"})})]}),a==null?void 0:a.map((c,u)=>{var g,p;return i.jsxs("div",{className:"grid grid-cols-3 text-sm border-b border-gray-100",children:[i.jsx("div",{className:"border-r px-4 py-2 flex items-center",children:i.jsx("span",{className:"",children:(g=parseFloat(c.key))==null?void 0:g.toLocaleString()})}),i.jsx("div",{className:"border-r px-4 py-1",children:i.jsx("span",{children:i.jsx(Ge,{id:"input-example",className:"border border-gray-100 rounded w-full px-3 py-1 outline-none",decimalsLimit:6,value:c.value,onValueChange:h=>l(h,u),disabled:n,allowNegativeValue:!1})})}),i.jsx("div",{className:"px-4 py-2 flex justify-between items-center",children:i.jsx("span",{children:(p=r(c.key,c.value))==null?void 0:p.toLocaleString()})})]},u+"index")}),i.jsxs("div",{className:"grid grid-cols-3 text-sm font-bold bg-gray-50",children:[i.jsx("div",{className:"border-r px-4 py-3 col-span-2 text-right",children:"Total"}),i.jsx("div",{className:"px-4 py-3",children:d==null?void 0:d.toLocaleString()})]})]})})}function Ba({element:e,validationData:n}){const{register:o=()=>({}),setValue:s,getValues:a}=n||{},t=a&&a(e==null?void 0:e.id)||[];return b.useEffect(()=>{o(e.id)},[e.id,o]),i.jsx("div",{children:i.jsx(Ea,{onGetTotal:l=>{s&&s(e.id,l)},denominators:(e==null?void 0:e.denominators)||[],defaultValue:t,readOnly:e==null?void 0:e.isReadOnly})})}function La({element:e}){return i.jsx("div",{className:V("py-6",e==null?void 0:e.customClass)})}function Pa({element:e}){return i.jsx("div",{children:i.jsx("hr",{className:V("border-gray-200 my-4",e==null?void 0:e.customClass)})})}function Oa({element:e,validationData:n}){const{register:o=()=>({})}=n||{};return i.jsx("div",{children:i.jsx("input",{placeholder:"Enter text",type:"text",className:"field-control",...o(e==null?void 0:e.id)})})}function Ia({element:e,state:n}){return i.jsx(i.Fragment,{children:i.jsx("div",{className:e==null?void 0:e.customClass,children:(e==null?void 0:e.value)||n==="edit"&&i.jsx("span",{className:"text-gray-400",children:"Provide text"})})})}function Da({row:e,columns:n,isReadOnly:o,editingCell:s,setEditingCell:a,handleCellChange:t,debouncedValidate:l,getValidationStatus:r,deleteRow:d}){const c=u=>(s==null?void 0:s.rowId)===e.id&&(s==null?void 0:s.field)===u;return i.jsxs("tr",{children:[n.map(u=>{var w;const g=e[u.field],p=u.editable&&!o,h=c(u.field),{isValidating:y,result:f}=r(e.id,u.field);let m="border-gray-300";u.validate&&((f==null?void 0:f.isValid)===!1?m="border-red-500 bg-red-50":(f==null?void 0:f.isValid)===!0&&(m="border-green-500 bg-green-50"));const x=`w-full px-2 py-1 border rounded outline-none ${m}`;return i.jsx("td",{title:o?"":"Double click to edit",className:"px-3 py-1 border",onDoubleClick:()=>p&&a({rowId:e.id,field:u.field}),children:p&&h?i.jsxs("div",{className:"relative",children:[u.type==="number"?i.jsx(Ge,{value:g,decimalsLimit:6,allowNegativeValue:!1,className:x,onValueChange:k=>t(k,e.id,u.field),onBlur:()=>{a(null),l(g,e.id,u.field,u)},autoFocus:!0}):u.type==="checkbox"?i.jsx("div",{className:"flex items-center gap-x-4",children:["yes","no"].map(k=>{const S=k==="yes",A=`radio-${e.id}-${String(u.field)}-${k}`;return i.jsxs("label",{htmlFor:A,className:"flex items-center gap-1 cursor-pointer",children:[i.jsx("input",{id:A,type:"radio",name:`boolean-${e.id}-${String(u.field)}`,checked:g===S,onChange:()=>t(S,e.id,u.field)}),i.jsx("span",{className:"text-sm",children:S?"Yes":"No"})]},k)})}):i.jsx("input",{type:"text",value:String(g!=null?g:""),onChange:k=>t(k.target.value,e.id,u.field),onBlur:()=>{a(null),l(g,e.id,u.field,u)},className:x,autoFocus:!0}),y&&i.jsx("div",{className:"absolute right-1 top-1",children:i.jsx("div",{className:"w-4 h-4 border-2 border-blue-500 rounded-full border-t-transparent animate-spin"})})]}):u.validate&&f?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{children:[String(g!=null?g:"")," ",f.data&&`[${f.data}]`]}),f.isValid?i.jsx("span",{className:"text-xs text-green-600",children:"✓"}):i.jsx("span",{className:"text-xs text-red-600 cursor-help",title:(w=f.error)!=null?w:"",children:"✗"})]}):u.type==="checkbox"?i.jsx("span",{className:"block py-1 text-gray-700",children:g===!0?"Yes":g===!1?"No":""}):i.jsx("span",{className:"block py-1 text-gray-700 cursor-pointer",children:String(g!=null?g:"")})},String(u.id))}),!o&&i.jsx("td",{className:"px-3 py-1 text-center border",children:i.jsx("button",{type:"button",onClick:()=>d(e.id),className:"text-red-500 hover:text-red-700","aria-label":"Delete row",children:i.jsx(F,{icon:"lets-icons:trash-duotone",iconClass:"text-xl"})})})]})}const Ka=b.memo(Da);function Ga({value:e=[],onChange:n,isReadOnly:o=!1,columns:s}){const[a,t]=b.useState(e),[l,r]=b.useState(null),d=b.useRef(null),c=document.getElementById("form"),u=b.useMemo(()=>{const f=(c==null?void 0:c.getBoundingClientRect().width)||0;return f&&f-48},[c]);b.useEffect(()=>{t(f=>JSON.stringify(f)!==JSON.stringify(e)?e:f)},[e]),b.useEffect(()=>{n==null||n(a)},[a,n]),b.useEffect(()=>{const f=m=>{d.current&&!d.current.contains(m.target)&&r(null)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const g=b.useCallback((f,m,x)=>{t(w=>w.map(k=>k.id===m?{...k,[x]:f}:k))},[]),p=b.useCallback(()=>{const f=be.v4(),m=s.reduce((x,w)=>(x[w.field]=w.field==="id"?f:"",x),{});t(x=>[...x,{id:f,...m}])},[s]),h=b.useCallback(f=>{t(m=>m.filter(x=>x.id!==f))},[]),y=b.useCallback(()=>({isValidating:!1,result:void 0}),[]);return i.jsxs("div",{className:"mt-3 rounded",ref:d,children:[i.jsx("div",{className:"flex justify-end",children:!o&&i.jsx("button",{onClick:p,type:"button",className:"px-2 py-1 mb-3 text-xs text-white bg-gray-600 rounded hover:bg-gray-700",children:"Add Row"})}),i.jsx("div",{className:"w-full max-w-full overflow-x-auto",style:{maxWidth:`${u}px`},children:i.jsxs("table",{className:"min-w-max w-full text-sm border-collapse rounded table-auto bg-gray-50",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-gray-100",children:[s.map((f,m)=>{var x;return i.jsxs("th",{className:"px-3 py-2 text-xs font-semibold text-left text-gray-600 border whitespace-nowrap",children:[(x=f.headerName)!=null?x:String(f.field),f.validate&&i.jsx("span",{className:"ml-1 text-blue-600",children:"*"})]},`${String(f.id)}-${m}`)}),!o&&i.jsx("th",{className:"w-10 px-2 py-2 border"})]})}),i.jsx("tbody",{children:a.length>0?a.map(f=>i.jsx(Ka,{row:f,columns:s,isReadOnly:o,editingCell:l,setEditingCell:r,handleCellChange:g,debouncedValidate:()=>{},getValidationStatus:y,deleteRow:h},f.id)):i.jsx("tr",{children:i.jsx("td",{colSpan:s.length+(o?0:1),className:"p-2 text-xs text-center text-gray-400",children:"No data available"})})})]})})]})}function Ra({element:e,validationData:n}){const{register:o=()=>({}),setValue:s,watch:a,isReadOnly:t}=n||{},l=a&&a(e==null?void 0:e.id)||[];b.useEffect(()=>{o(e.id)},[e.id,o]);const r=b.useCallback(d=>{s==null||s(e.id,d)},[e.id,s]);return i.jsx(Ga,{value:l,onChange:r,columns:e==null?void 0:e.dataColumns,isReadOnly:t})}const mn=({className:e="",options:n=[],placeholder:o="Select",errors:s,register:a,setValue:t,name:l,label:r,value:d,trigger:c,isMultiple:u=!1,isFloatingLabel:g=!1,subText:p,labelClass:h="",loading:y,disabled:f})=>{const[m,x]=b.useState(u?[]:null),w=V("custom-select__control",e),k=b.useMemo(()=>n,[n]);return b.useEffect(()=>{const S=n==null?void 0:n.find(A=>{var _;return typeof A.value=="string"&&typeof d=="string"?A.value.toLowerCase()===d.toLowerCase():typeof A.value=="object"&&typeof d=="object"?((_=A.value)==null?void 0:_.id)===(d==null?void 0:d.id):A.value===d});x(S||null)},[d,n]),b.useEffect(()=>{m&&t&&a&&(t(l,m==null?void 0:m.value),a(l),c==null||c(l))},[l,m]),i.jsxs("div",{className:"custom-select",children:[r&&!g&&i.jsx("label",{className:"custom-select__label",children:r}),g&&r&&i.jsx("label",{className:V("custom-select__floating-label",h),children:r}),i.jsx(K.Listbox,{value:m,onChange:x,multiple:u,disabled:f,children:i.jsxs("div",{className:"custom-select__wrapper",children:[i.jsxs(K.Listbox.Button,{className:w,disabled:f,children:[y?i.jsx("span",{className:"custom-select__loading",children:"Fetching data..."}):i.jsx("span",{className:"custom-select__value",children:(m==null?void 0:m.label)||i.jsx("span",{className:"custom-select__placeholder",children:o})}),i.jsx("span",{className:"custom-select__icon",children:i.jsx(F,{icon:"lucide:chevron-down"})})]}),i.jsx(K.Transition,{as:b.Fragment,leave:"custom-select__transition",children:i.jsx(K.Listbox.Options,{className:"custom-select__options",anchor:"bottom",children:k==null?void 0:k.map((S,A)=>i.jsx(K.Listbox.Option,{value:S,className:({active:_})=>V("custom-select__option",_&&"custom-select__option--active"),children:({selected:_})=>i.jsx("span",{className:V("custom-select__option-label",_&&"custom-select__option--selected"),children:S.label})},A))})})]})}),p&&!s&&i.jsx("p",{className:"custom-select__subtext",children:p}),s&&i.jsx("span",{className:"custom-select__error",children:s.message})]})},za=({element:e,validationData:n})=>{var f;const{register:o=()=>({}),trigger:s,setValue:a,watch:t,isReadOnly:l}=n||{},r=(f=e==null?void 0:e.id)!=null?f:"cascadeValue",[d,c]=b.useState(""),[u,g]=b.useState(""),p=(m,x)=>{const w=m&&x?`${m}_${x}`:"";a==null||a(r,w),s==null||s(r)},h=(m,x)=>{m==="first"?(c(x),g(""),p(x,"")):(g(x),p(d,x))};b.useEffect(()=>{if(t){const m=t(r);if(m!=null&&m.includes("_")){const[x,w]=m.split("_");c(x),g(w)}}},[t,r]);const y=b.useMemo(()=>{var m;return(m=e.options1)==null?void 0:m.filter(x=>x.key===d)},[e.options1,d]);return!e.options||!e.options1?null:i.jsxs("div",{children:[i.jsx("input",{type:"hidden",...o(r)}),i.jsx("div",{className:"relative",children:i.jsx(mn,{setValue:(m,x)=>h("first",x),options:e.options,name:`${r}`,register:o,value:d})}),d&&i.jsxs("div",{className:"mt-4",children:[(e==null?void 0:e.childLabel)&&i.jsx("label",{className:"block text-sm text-[#686878] darks:!text-white/70 mb-2",children:e==null?void 0:e.childLabel}),i.jsx(mn,{setValue:(m,x)=>h("second",x),options:y,name:`${r}`,register:o,value:u})]})]})},Ha=({value:e=0,max:n=5,readOnly:o=!1,onChange:s,size:a=24,className:t="",element:l,validationData:r})=>{var x;const{register:d=()=>({}),trigger:c,setValue:u,watch:g,isReadOnly:p}=r||{},h=(x=g==null?void 0:g(l.id))!=null?x:0,[y,f]=b.useState(null);b.useEffect(()=>{h==null&&(u==null||u(l.id,e))},[]);const m=w=>{if(!o&&!p){const k=w+1;u==null||u(l.id,k),c==null||c(l.id),s==null||s(k)}};return i.jsxs("div",{className:`flex gap-1 ${t}`,children:[i.jsx("input",{type:"hidden",...d(l.id)}),Array.from({length:n},(w,k)=>{const S=y!==null?k<=y:k<h;return i.jsx(ln,{icon:S?"mdi:star":"mdi:star-outline",className:`cursor-pointer transition-colors ${S?"text-yellow-400":"text-gray-300"}`,width:a,height:a,onMouseEnter:()=>!(o||p)&&f(k),onMouseLeave:()=>!(o||p)&&f(null),onClick:()=>m(k)},k)})]})};function bn({element:e,validationData:n}){const{register:o=()=>({}),setValue:s,trigger:a,isReadOnly:t,watch:l}=n||{},r=(l==null?void 0:l(e.id))||"",{country:d,state:c}=b.useMemo(()=>{var y;if(typeof r=="string"&&r.includes(",")){const[f,m]=(y=r.split(","))==null?void 0:y.map(x=>x.trim());return{country:m,state:f}}return{country:r,state:""}},[r]),u=b.useRef(r),g=b.useMemo(()=>{var y,f;return d?((f=(y=Ue.find(m=>m.name===d))==null?void 0:y.states)==null?void 0:f.map(m=>({label:m.name,value:m.name})))||[]:[]},[d]),p=(y,f)=>{const x=(f==null?void 0:f.value)||"";s&&x!==u.current&&(s(e.id,x),a==null||a(e.id),u.current=x)},h=(y,f)=>{const m=(f==null?void 0:f.value)||"",x=m?`${m}, ${d}`:d;s&&x!==u.current&&(s(e.id,x),a==null||a(e.id),u.current=x)};return b.useEffect(()=>{u.current=r},[r]),i.jsxs("div",{className:"grid gap-y-6",children:[i.jsx("input",{type:"hidden",...o(e.id)}),i.jsx(ci,{options:e.options,onGetValue:p,name:`${e.id}-country`,readOnly:t,defaultValue:d},`country-${d}`),g.length>0&&e.showState&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium mb-1.5 input_label",children:"State"}),i.jsx(ci,{options:g,onGetValue:h,name:`${e.id}-state`,readOnly:t,defaultValue:c},`state-${c}`)]})]})}function Fa({element:e,validationData:n}){const{register:o=()=>({}),isReadOnly:s}=n||{},{validationUrl:a,documentObj:t,signatureLink:l}=e,r=b.useMemo(()=>ue("config"),[]),[d,c]=b.useState(!1),[u,g]=b.useState(!1),p=b.useCallback(async()=>{var h,y;if(!(!a||!t))try{g(!0);const m={headers:{Authorization:`Bearer ${ue("token")}`}},{data:x}=await je.get(`${a}/${t}`,m),w=!!((y=(h=x==null?void 0:x.data)==null?void 0:h.isSigned)!=null?y:x!=null&&x.isSigned);return c(w),w}catch(f){console.error("Failed to check sign status",f)}finally{g(!1)}},[a,t]);return b.useEffect(()=>{let h=null;return!d&&t&&a&&(async()=>{await p()||(h=setInterval(async()=>{await p()&&h&&clearInterval(h)},2e3))})(),()=>{h&&clearInterval(h)}},[p,d,t,a]),i.jsxs("div",{className:"flex items-center gap-x-2",children:[i.jsx("input",{placeholder:e.placeholder,type:e.inputType,className:V("field-control",e.customClass),...o(e.id),disabled:s}),i.jsx("a",{href:d?"#":l,children:i.jsxs("button",{type:"button",onClick:p,disabled:u||d,style:{background:(r==null?void 0:r.buttonColor)||"#333"},className:V("flex items-center gap-x-1 rounded-lg border border-gray-200 bg-gray-200 px-3 py-[10px] text-sm text-white",{"!opacity-60":u}),children:[i.jsx(F,{icon:u?"solar:refresh-outline":d?"solar:check-circle-bold":"solar:pen-2-line-duotone",iconClass:u?"animate-spin":""}),u?"Checking...":d?"Signed":"Sign"]})})]})}const gi=[{code:"DZ",label:"Algeria",phone:"213",min:9,max:9},{code:"AO",label:"Angola",phone:"244",min:9,max:9},{code:"BJ",label:"Benin",phone:"229",min:8,max:8},{code:"BW",label:"Botswana",phone:"267",min:7,max:7},{code:"BF",label:"Burkina Faso",phone:"226",min:8,max:8},{code:"BI",label:"Burundi",phone:"257",min:8,max:8},{code:"CM",label:"Cameroon",phone:"237",min:9,max:9},{code:"CV",label:"Cape Verde",phone:"238",min:7,max:7},{code:"CF",label:"Central African Republic",phone:"236",min:8,max:8},{code:"TD",label:"Chad",phone:"235",min:8,max:8},{code:"KM",label:"Comoros",phone:"269",min:7,max:7},{code:"CG",label:"Congo",phone:"242",min:9,max:9},{code:"CD",label:"Democratic Republic of Congo",phone:"243",min:9,max:9},{code:"CI",label:"Cote d'Ivoire",phone:"225",min:8,max:8},{code:"DJ",label:"Djibouti",phone:"253",min:8,max:8},{code:"EG",label:"Egypt",phone:"20",min:10,max:10},{code:"GQ",label:"Equatorial Guinea",phone:"240",min:9,max:9},{code:"ER",label:"Eritrea",phone:"291",min:7,max:7},{code:"ET",label:"Ethiopia",phone:"251",min:9,max:9},{code:"GA",label:"Gabon",phone:"241",min:7,max:7},{code:"GM",label:"Gambia",phone:"220",min:7,max:7},{code:"GH",label:"Ghana",phone:"233",min:9,max:9},{code:"GN",label:"Guinea",phone:"224",min:9,max:9},{code:"GW",label:"Guinea-Bissau",phone:"245",min:9,max:9},{code:"KE",label:"Kenya",phone:"254",min:7,max:9},{code:"LS",label:"Lesotho",phone:"266",min:8,max:8},{code:"LR",label:"Liberia",phone:"231",min:8,max:9},{code:"LY",label:"Libya",phone:"218",min:9,max:10},{code:"MG",label:"Madagascar",phone:"261",min:9,max:9},{code:"MW",label:"Malawi",phone:"265",min:9,max:9},{code:"ML",label:"Mali",phone:"223",min:8,max:8},{code:"MR",label:"Mauritania",phone:"222",min:8,max:8},{code:"MU",label:"Mauritius",phone:"230",min:8,max:8},{code:"MA",label:"Morocco",phone:"212",min:9,max:9},{code:"MZ",label:"Mozambique",phone:"258",min:9,max:9},{code:"NA",label:"Namibia",phone:"264",min:9,max:9},{code:"NE",label:"Niger",phone:"227",min:8,max:8},{code:"NG",label:"Nigeria",phone:"234",min:10,max:10},{code:"RW",label:"Rwanda",phone:"250",min:9,max:9},{code:"ST",label:"Sao Tome and Principe",phone:"239",min:7,max:7},{code:"SN",label:"Senegal",phone:"221",min:9,max:9},{code:"SC",label:"Seychelles",phone:"248",min:7,max:7},{code:"SL",label:"Sierra Leone",phone:"232",min:8,max:8},{code:"SO",label:"Somalia",phone:"252",min:8,max:9},{code:"ZA",label:"South Africa",phone:"27",min:10,max:10},{code:"SS",label:"South Sudan",phone:"211",min:9,max:9},{code:"SD",label:"Sudan",phone:"249",min:9,max:9},{code:"TZ",label:"Tanzania",phone:"255",min:9,max:9},{code:"TG",label:"Togo",phone:"228",min:8,max:8},{code:"TN",label:"Tunisia",phone:"216",min:8,max:8},{code:"UG",label:"Uganda",phone:"256",min:9,max:9},{code:"ZM",label:"Zambia",phone:"260",min:9,max:9},{code:"ZW",label:"Zimbabwe",phone:"263",min:9,max:9},{code:"US",label:"United States",phone:"1",min:10,max:10},{code:"CA",label:"Canada",phone:"1",min:10,max:10},{code:"GB",label:"United Kingdom",phone:"44",min:9,max:10},{code:"FR",label:"France",phone:"33",min:9,max:9},{code:"DE",label:"Germany",phone:"49",min:10,max:11},{code:"IT",label:"Italy",phone:"39",min:9,max:10},{code:"ES",label:"Spain",phone:"34",min:9,max:9},{code:"NL",label:"Netherlands",phone:"31",min:9,max:9},{code:"RU",label:"Russia",phone:"7",min:10,max:10},{code:"CN",label:"China",phone:"86",min:11,max:11},{code:"IN",label:"India",phone:"91",min:10,max:10},{code:"JP",label:"Japan",phone:"81",min:10,max:10},{code:"KR",label:"South Korea",phone:"82",min:8,max:9},{code:"BR",label:"Brazil",phone:"55",min:10,max:11},{code:"MX",label:"Mexico",phone:"52",min:10,max:10},{code:"AR",label:"Argentina",phone:"54",min:10,max:10},{code:"CL",label:"Chile",phone:"56",min:9,max:9},{code:"AU",label:"Australia",phone:"61",min:9,max:9},{code:"NZ",label:"New Zealand",phone:"64",min:8,max:9},{code:"SA",label:"Saudi Arabia",phone:"966",min:9,max:9},{code:"AE",label:"United Arab Emirates",phone:"971",min:9,max:9},{code:"TR",label:"Turkey",phone:"90",min:10,max:11},{code:"IR",label:"Iran",phone:"98",min:7,max:10},{code:"PK",label:"Pakistan",phone:"92",min:10,max:10},{code:"BD",label:"Bangladesh",phone:"880",min:10,max:10},{code:"ID",label:"Indonesia",phone:"62",min:9,max:11},{code:"PH",label:"Philippines",phone:"63",min:10,max:10},{code:"CO",label:"Colombia",phone:"57",min:10,max:10},{code:"VE",label:"Venezuela",phone:"58",min:10,max:10},{code:"PE",label:"Peru",phone:"51",min:9,max:9},{code:"EC",label:"Ecuador",phone:"593",min:9,max:9},{code:"UY",label:"Uruguay",phone:"598",min:8,max:8},{code:"PY",label:"Paraguay",phone:"595",min:9,max:9},{code:"BO",label:"Bolivia",phone:"591",min:8,max:8},{code:"GT",label:"Guatemala",phone:"502",min:8,max:8},{code:"HN",label:"Honduras",phone:"504",min:8,max:8},{code:"SV",label:"El Salvador",phone:"503",min:8,max:8},{code:"NI",label:"Nicaragua",phone:"505",min:8,max:8},{code:"CR",label:"Costa Rica",phone:"506",min:8,max:8},{code:"PA",label:"Panama",phone:"507",min:8,max:8},{code:"JM",label:"Jamaica",phone:"1",min:10,max:10},{code:"TT",label:"Trinidad and Tobago",phone:"1",min:10,max:10},{code:"AD",label:"Andorra",phone:"376",min:6,max:6},{code:"AF",label:"Afghanistan",phone:"93",min:9,max:9},{code:"AG",label:"Antigua and Barbuda",phone:"1-268",min:7,max:7},{code:"AI",label:"Anguilla",phone:"1-264",min:7,max:7},{code:"AL",label:"Albania",phone:"355",min:8,max:8},{code:"AM",label:"Armenia",phone:"374",min:8,max:8},{code:"AS",label:"American Samoa",phone:"1-684",min:7,max:7},{code:"AT",label:"Austria",phone:"43",min:10,max:10},{code:"AW",label:"Aruba",phone:"297",min:7,max:7},{code:"AX",label:"Åland Islands",phone:"358",min:6,max:6},{code:"AZ",label:"Azerbaijan",phone:"994",min:9,max:9},{code:"BA",label:"Bosnia and Herzegovina",phone:"387",min:8,max:8},{code:"BB",label:"Barbados",phone:"1-246",min:7,max:7},{code:"BE",label:"Belgium",phone:"32",min:9,max:9},{code:"BG",label:"Bulgaria",phone:"359",min:9,max:9},{code:"BH",label:"Bahrain",phone:"973",min:8,max:8},{code:"BL",label:"Saint Barthélemy",phone:"590",min:9,max:9},{code:"BM",label:"Bermuda",phone:"1-441",min:7,max:7},{code:"BN",label:"Brunei Darussalam",phone:"673",min:7,max:7},{code:"BQ",label:"Bonaire, Sint Eustatius and Saba",phone:"599",min:7,max:7},{code:"BS",label:"Bahamas",phone:"1-242",min:7,max:7},{code:"BT",label:"Bhutan",phone:"975",min:8,max:8},{code:"BV",label:"Bouvet Island",phone:"47",min:8,max:8},{code:"BY",label:"Belarus",phone:"375",min:9,max:9},{code:"BZ",label:"Belize",phone:"501",min:7,max:7},{code:"CC",label:"Cocos (Keeling) Islands",phone:"61",min:7,max:7},{code:"CH",label:"Switzerland",phone:"41",min:9,max:9},{code:"CK",label:"Cook Islands",phone:"682",min:5,max:5},{code:"CU",label:"Cuba",phone:"53",min:8,max:8},{code:"CW",label:"Curaçao",phone:"599",min:7,max:7},{code:"CX",label:"Christmas Island",phone:"61",min:7,max:7},{code:"CY",label:"Cyprus",phone:"357",min:8,max:8},{code:"CZ",label:"Czechia",phone:"420",min:9,max:9},{code:"DK",label:"Denmark",phone:"45",min:8,max:8},{code:"DM",label:"Dominica",phone:"1-767",min:7,max:7},{code:"DO",label:"Dominican Republic",phone:"1-809",min:7,max:7},{code:"EE",label:"Estonia",phone:"372",min:8,max:8},{code:"EH",label:"Western Sahara",phone:"212",min:9,max:9},{code:"FI",label:"Finland",phone:"358",min:9,max:9},{code:"FJ",label:"Fiji",phone:"679",min:7,max:7},{code:"FM",label:"Micronesia (Federated States of)",phone:"691",min:7,max:7},{code:"FO",label:"Faroe Islands",phone:"298",min:6,max:6},{code:"GD",label:"Grenada",phone:"1-473",min:7,max:7},{code:"GE",label:"Georgia",phone:"995",min:9,max:9},{code:"GF",label:"French Guiana",phone:"594",min:9,max:9},{code:"GG",label:"Guernsey",phone:"44",min:9,max:9},{code:"GI",label:"Gibraltar",phone:"350",min:8,max:8},{code:"GL",label:"Greenland",phone:"299",min:6,max:6},{code:"GP",label:"Guadeloupe",phone:"590",min:9,max:9},{code:"GR",label:"Greece",phone:"30",min:10,max:10},{code:"GS",label:"South Georgia and the South Sandwich Islands",phone:"500",min:6,max:6},{code:"GU",label:"Guam",phone:"1-671",min:10,max:10},{code:"GY",label:"Guyana",phone:"592",min:7,max:7},{code:"HK",label:"Hong Kong",phone:"852",min:8,max:8},{code:"HM",label:"Heard Island and McDonald Islands",phone:"672",min:6,max:6},{code:"HR",label:"Croatia",phone:"385",min:9,max:9},{code:"HT",label:"Haiti",phone:"509",min:8,max:8},{code:"HU",label:"Hungary",phone:"36",min:9,max:9},{code:"IE",label:"Ireland",phone:"353",min:9,max:9},{code:"IM",label:"Isle of Man",phone:"44",min:9,max:9},{code:"IO",label:"British Indian Ocean Territory",phone:"246",min:7,max:7},{code:"IQ",label:"Iraq",phone:"964",min:10,max:10},{code:"IS",label:"Iceland",phone:"354",min:7,max:7},{code:"JE",label:"Jersey",phone:"44",min:9,max:9},{code:"JO",label:"Jordan",phone:"962",min:9,max:9},{code:"KG",label:"Kyrgyzstan",phone:"996",min:9,max:9},{code:"KH",label:"Cambodia",phone:"855",min:9,max:9},{code:"KI",label:"Kiribati",phone:"686",min:7,max:7},{code:"KN",label:"Saint Kitts and Nevis",phone:"1-869",min:10,max:10},{code:"KP",label:"North Korea",phone:"850",min:9,max:9},{code:"KW",label:"Kuwait",phone:"965",min:8,max:8},{code:"KY",label:"Cayman Islands",phone:"1-345",min:10,max:10},{code:"KZ",label:"Kazakhstan",phone:"7",min:10,max:10},{code:"MC",label:"Monaco",phone:"377",min:8,max:9},{code:"LI",label:"Liechtenstein",phone:"423",min:7,max:7},{code:"VA",label:"Vatican City",phone:"379",min:9,max:9},{code:"SM",label:"San Marino",phone:"378",min:10,max:10},{code:"ME",label:"Montenegro",phone:"382",min:8,max:8},{code:"RS",label:"Serbia",phone:"381",min:9,max:9},{code:"MK",label:"North Macedonia",phone:"389",min:8,max:8},{code:"SJ",label:"Svalbard and Jan Mayen",phone:"47",min:8,max:8},{code:"MF",label:"Saint Martin",phone:"590",min:9,max:9},{code:"PM",label:"Saint Pierre and Miquelon",phone:"508",min:6,max:6},{code:"WF",label:"Wallis and Futuna",phone:"681",min:6,max:6},{code:"TV",label:"Tuvalu",phone:"688",min:5,max:5},{code:"NR",label:"Nauru",phone:"674",min:7,max:7},{code:"TO",label:"Tonga",phone:"676",min:5,max:5},{code:"WS",label:"Samoa",phone:"685",min:7,max:7},{code:"VU",label:"Vanuatu",phone:"678",min:7,max:7},{code:"SB",label:"Solomon Islands",phone:"677",min:7,max:7},{code:"FM",label:"Micronesia",phone:"691",min:7,max:7},{code:"MH",label:"Marshall Islands",phone:"692",min:7,max:7},{code:"PW",label:"Palau",phone:"680",min:7,max:7}];function Va({label:e,placeholder:n,classLabel:o,isRequired:s,isOptional:a,name:t,value:l,error:r,disabled:d,readOnly:c,horizontal:u,description:g,validate:p,onChange:h,onError:y}){const[f,m]=b.useState(""),[x,w]=b.useState(null),[k,S]=b.useState(""),A=b.useMemo(()=>{var M;return(M=gi==null?void 0:gi.slice().sort((T,B)=>T.label.localeCompare(B.label)))==null?void 0:M.map(T=>({...T,phone:`+${T.phone}`}))},[]),_=b.useMemo(()=>f?A.filter(M=>`${M.label} ${M.phone}`.toLowerCase().includes(f.toLowerCase())):A,[f,A]),j=(x==null?void 0:x.min)||10,L=(x==null?void 0:x.max)||10,Q=()=>k?`${(x==null?void 0:x.phone)||"+234"}-${k}`:"",W=M=>{if(!M)return{code:"+234",number:""};const T=M.split(/[-\s]/);return{code:T[0],number:T.slice(1).join(" ")}};b.useEffect(()=>{if(l){const M=W(l);w(A.find(T=>T.phone===M.code)||A[0]),S(M.number)}},[l,A]);const D=b.useMemo(()=>{if(r)return r;const M=k.length;return s&&M===0?"Phone number is required":M>0&&!/^\d+$/.test(k)?"Phone number must contain only digits":M>0&&M<j?`Minimum length is ${j}`:M>L?`Maximum length is ${L}`:""},[r,k,j,L,s]);return b.useEffect(()=>{h==null||h(Q()),y==null||y(D||null)},[k,x,D]),i.jsxs("div",{className:`relative formGroup ${D&&!c?"has-error":""} ${u?"flex":""} ${!D&&k.length>0&&!c?"is-valid":""}`,children:[e&&i.jsxs("label",{htmlFor:t,className:`${o} ${u?"flex-0 mr-6 md:w-[100px] w-[60px] break-words":""} flex items-center gap-x-1 input-label text-sm text-[#1B2B41B8]`,children:[e," ",s&&i.jsx("span",{className:"text-red-500",children:"*"}),a&&i.jsx("span",{className:"text-[#98A2B3]",children:"(Optional)"})]}),i.jsxs("div",{className:"relative !flex items-center input-control text-[#667085] !py-0 field-control",children:[i.jsx(F,{icon:"lucide:phone-call"}),i.jsx(K.Combobox,{value:x,onChange:w,children:i.jsxs("div",{className:"relative",children:[i.jsx(K.Combobox.Input,{className:"pl-3 pr-4 mr-1 text-sm bg-white py-[10px] outline-none whitespace-nowrap max-w-[70px]",displayValue:M=>(M==null?void 0:M.phone)||"+234",placeholder:"+234",onChange:M=>m(M.target.value)}),i.jsx(K.Combobox.Button,{className:"absolute inset-y-0 right-0 flex items-center pr-2",children:i.jsx(F,{icon:"lucide:chevron-down"})}),i.jsx(K.Combobox.Options,{className:"absolute z-10 w-[250px] left-0 bg-white border rounded-md shadow-lg max-h-[400px] overflow-y-auto",children:_==null?void 0:_.map((M,T)=>i.jsxs(K.Combobox.Option,{value:M,className:"px-4 py-2 cursor-pointer hover:bg-gray-100",children:[M.phone," - ",M.label]},`${M.code}+ ${T}`))})]})}),i.jsxs("div",{className:"relative flex items-center flex-1 z-[1]",children:[i.jsx("input",{type:"tel",inputMode:"numeric",value:k,disabled:d,readOnly:c,onChange:M=>{const T=M.target.value.replace(/\D/g,"");S(T)},placeholder:n,className:"w-full px-3 outline-none"}),i.jsx("div",{className:"absolute flex text-xl -translate-y-1/2 top-1/2 right-4",children:!D&&k.length>0&&!c&&i.jsx("span",{className:"text-green-500",children:i.jsx(F,{icon:"bi:check-lg"})})})]})]}),g&&i.jsx("span",{className:"block text-[#475467] font-light leading-4 text-xs mt-2",children:g})]})}function Ua({element:e,validationData:n}){const{register:o=()=>({}),setValue:s,watch:a,isReadOnly:t,setError:l,clearErrors:r}=n||{};let d;return b.useEffect(()=>{o(e.id)},[e.id,o]),a&&(d=a()[e.id]),i.jsx(Va,{placeholder:e.placeholder,label:"",name:e.id,value:d,readOnly:t,disabled:t,onError:c=>{c?l==null||l(e.id,{type:"manual",message:c}):r==null||r(e.id)},onChange:c=>{c&&(s==null||s(e.id,c))}})}function Wa({element:e,validationData:n}){const{register:o=()=>({}),watch:s}=n||{};let a;return s&&(a=s()[e.id]),i.jsxs("div",{children:[!(n!=null&&n.isReadOnly)&&i.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"Enter Url link",className:V("field-control",e==null?void 0:e.customClass),...o(e==null?void 0:e.id),disabled:n==null?void 0:n.isReadOnly}),a&&i.jsx("div",{className:n!=null&&n.isReadOnly?"field-control !bg-gray-50 mt-1":"mt-1 text-xs",children:i.jsx("a",{title:"Visit link",target:"_blank",className:"hover:underline text-blue-700",href:a,children:a})})]})}const vn={textField:Xe,longText:ea,selectField:Xo,multiSelect:ui,numberField:Xe,amountField:ja,date:Hn,password:Yo,checkbox:Qo,radio:Zo,email:Xe,file:qo,dataGrid:Ra,section:$o,validateInput:Ta,tableInput:Ba,spacer:La,divider:Pa,header:Oa,basicText:Ia,phoneField:Ua,cascadeSelect:za,rating:Ha,country:bn,bank:bn,document:Fa,link:Wa},pn="edit",gn=(e,n)=>{const o=vn[e.type];return o?i.jsx(pi,{element:e,state:pn,children:i.jsxs("div",{className:"relative w-full",children:[e.type.toLowerCase()!=="grid"&&i.jsx("div",{className:"absolute top-0 left-0 z-20 w-full h-full"}),i.jsx(o,{element:e,state:pn,sectionId:n})]})}):null},hi=({col:e,children:n,customClass:o})=>i.jsx("div",{className:V("w-full bg-white",o),style:{gridColumn:e},children:n}),Ja=({element:e,sectionId:n,children:o,customClass:s,state:a})=>{const{formData:t,addElement:l,setIsDragging:r}=b.useContext(le),d=b.useMemo(()=>Array.from({length:e.columns}),[e.columns]),c=b.useCallback(p=>{p.preventDefault(),p.stopPropagation(),p.dataTransfer.dropEffect="move"},[]),u=b.useCallback((p,h)=>{var y,f;p.preventDefault(),r(!1);try{const m=p.dataTransfer.getData("properties");if(!m)return;const x=JSON.parse(m);if((x==null?void 0:x.type)==="grid")return;const w=h+1;if((f=(y=t.find(A=>A.id===n))==null?void 0:y.questionData)==null?void 0:f.some(A=>{var _;return A.gridId===e.id&&((_=A.gridPosition)==null?void 0:_.col)===w}))return;const S={...x,id:be.v4(),sectionId:n,gridId:e.id,gridPosition:{col:w}};l(S,n)}catch(m){console.error("Drop failed in grid:",m),r(!1)}},[l,e.id,t,n,r]),g=(p,h,y)=>{const f=Array.isArray(o)&&o.find(m=>{var x;return((x=m==null?void 0:m.props)==null?void 0:x.col)===p+1});return i.jsx("div",{children:i.jsx("div",{id:p.toString(),onDrop:m=>u(m,p),onDragOver:c,className:V("border rounded-lg min-h-[110px] bg-white ","flex items-center justify-center text-gray-400 transition-colors",`${y==="edit"?"p-3":""}`,h),children:f||i.jsx("span",{children:y==="edit"&&i.jsx(F,{icon:"ph:plus-bold"})})})},p)};return i.jsx("div",{className:"relative w-full",children:i.jsx("div",{className:"grid w-full gap-3",style:{gridTemplateColumns:`repeat(${e.columns}, 1fr)`},children:d==null?void 0:d.map((p,h)=>g(h,s,a))})})},fi=b.memo(Ja),qa="edit";function Ya({elementData:e,sectionId:n}){const{formData:o,updateElementPosition:s,isDragging:a,setIsDragging:t,addElementInPosition:l}=b.useContext(le),[r,d]=b.useState(null),[c,u]=b.useState(null),g=b.useMemo(()=>{var k;return((k=o.find(S=>S.id===n))==null?void 0:k.questionData)||[]},[o,n]),p=b.useCallback((k,S)=>{k.dataTransfer.setData("properties",S),d(S)},[]),h=b.useCallback((k,S)=>{k.preventDefault(),k.stopPropagation(),u(S)},[]),y=b.useCallback(k=>{k.preventDefault(),k.stopPropagation();const S=k.dataTransfer.getData("properties"),A=k.currentTarget.id;if(!A||S===A)return;const _=g.findIndex(W=>W.id===S),j=g.findIndex(W=>W.id===A);if(_===-1||j===-1)return;const L=[...g],[Q]=L.splice(_,1);L.splice(j,0,Q),s(L,n),d(null)},[g,n,s]),f=b.useCallback((k,S)=>{k.preventDefault(),t(!1);try{const A=JSON.parse(k.dataTransfer.getData("properties"));if((A==null?void 0:A.type)==="section")return;const _={...A,id:be.v4(),sectionId:n};l(_,n,S)}catch(A){console.error("Drop error:",A)}},[l,n,t]),m=b.useCallback(k=>i.jsx("div",{className:"transition rounded hover:bg-blue-300",onDragOver:S=>S.preventDefault(),onDrop:S=>f(S,k),onDragEnd:()=>t(!1),children:i.jsx("div",{className:"bg-blue-50 rounded p-6 h-[60px] border-2 border-blue-300 border-dashed flex items-center justify-center text-gray-400 opacity-70",children:i.jsx(F,{icon:"octicon:plus-16"})})},`drop-${k}`),[f,t]),x=b.useCallback(k=>i.jsx("div",{id:k.id,className:V("cursor-move border p-4 w-full rounded-lg transition-colors bg-white",{"bg-gray-100":r===k.id,"border-dashed border-blue-300":r&&r!==k.id}),draggable:!0,onDragStart:S=>p(S,k.id),onDragOver:S=>h(S,k.id),onDrop:y,onDragEnd:()=>d(null),children:gn(k,n)},k.id),[r,y,h,n,p]),w=b.useMemo(()=>(e==null?void 0:e.reduce((k,S)=>(S.gridId&&(k[S.gridId]=k[S.gridId]||[],k[S.gridId].push(S)),k),{}))||{},[e]);return e!=null&&e.length?i.jsx("div",{className:"relative grid w-full h-full grid-cols-1 gap-4",children:e==null?void 0:e.map((k,S)=>{if(k.type==="grid"){const A=w[k.id]||[];return i.jsx("div",{draggable:!0,onDragStart:_=>p(_,k.id),onDragOver:_=>h(_,k.id),onDrop:y,onDragEnd:()=>d(null),className:"w-full p-4 transition-colors bg-white border rounded-lg cursor-move",children:i.jsx(pi,{element:k,state:"edit",children:i.jsx(fi,{element:k,sectionId:n,state:qa,children:A==null?void 0:A.map(_=>{var j;return i.jsx(hi,{col:(j=_.gridPosition)==null?void 0:j.col,children:gn(_,n)},_.id)})})})},k.id)}return k.gridId?null:i.jsxs("div",{className:V("group relative grid gap-y-[6px]",k.elementClass),children:[a&&c===k.id&&m(S),i.jsx("div",{className:"group",children:x(k)}),a&&c===k.id&&m(S+1)]},k.id)})}):i.jsx("div",{onDragOver:k=>k.preventDefault(),onDrop:k=>f(k,0),onDragEnd:()=>t(!1),className:"w-full h-full flex items-center justify-center text-gray-400 min-h-[200px] p-10 col-span-2 border border-dashed border-gray-300 rounded-lg",children:"Drag or click an element to display"})}const Za=b.memo(Ya),$a=E.object({title:E.string(),description:E.string()}).required(),xi=ue("config"),Qa=({isOpen:e,onClose:n,section:o})=>{const{updateSection:s}=b.useContext(le),{register:a,handleSubmit:t,watch:l,formState:{errors:r,isSubmitting:d,isValid:c},reset:u}=ye.useForm({resolver:mi($a),defaultValues:o});if(b.useEffect(()=>{e||u()},[e,u]),!e)return null;const g=p=>{s(p,o.id),n()};return i.jsx("div",{className:"fixed inset-0 bg-black/30 flex items-center justify-center z-[999] cursor-default no-drag select-none",children:i.jsxs("div",{className:"min-w-[600px] bg-white rounded-xl shadow-xl relative flex flex-col items-center",children:[i.jsxs("div",{className:"w-full px-6 pt-6 pb-5 flex flex-col items-start gap-4 z-10 mb-6",children:[i.jsx("h2",{className:"text-lg font-semibold text-[#475467] font-onest",children:"Update Section Information"}),i.jsx("button",{onClick:n,className:"absolute right-4 top-4 p-2 text-[#98A2B3] hover:bg-gray-50 rounded-lg",children:i.jsx(F,{icon:"tabler:x"})})]}),i.jsxs("form",{onSubmit:t(g),className:"w-full",children:[i.jsxs("div",{className:"w-full px-6 flex flex-col gap-5 z-10",children:[i.jsx(G,{label:"Title",name:"title",register:a,errors:r,watch:l}),i.jsx(G,{label:"Description",name:"description",register:a,errors:r,watch:l})]}),i.jsxs("div",{className:"w-full px-6 pt-8 pb-6 flex gap-3 mt-4",children:[i.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",children:"Cancel"}),i.jsx("button",{type:"submit",disabled:!c||d,style:{background:(xi==null?void 0:xi.buttonColor)||"#333"},className:`flex-1 px-4 py-2.5 ${!c||d?"bg-[#F2F4F7]":"bg-[#2563EB]"} ${!c||d?"text-[#98A2B3]":"text-white"} rounded-lg shadow-xs font-semibold font-onest disabled:opacity-50`,children:d?"Saving...":"Save"})]})]})]})})},Xa=()=>{const[e,n]=b.useState(!1),o=b.useRef(null),s=b.useRef(null),{removeSection:a,addSection:t,formData:l,setIsDragging:r,setSelectedSection:d,selectedSection:c,activeSections:u,setActiveSections:g}=b.useContext(le);b.useEffect(()=>{var m;d(((m=l[0])==null?void 0:m.id)||null)},[]);const p=b.useCallback(m=>{m.preventDefault(),m.dataTransfer.dropEffect="move",s.current&&(s.current.scrollTop=s.current.scrollHeight)},[]);function h(m){u.includes(m)?g(x=>x.filter(w=>w!==m)):g(x=>[...x,m])}function y(m){o.current=m,n(!0)}const f=ue("config");return i.jsxs("div",{ref:s,className:"relative flex flex-col h-full px-6 pb-5 mx-auto gap-x-4",children:[e&&i.jsx(Qa,{isOpen:e,onClose:()=>n(!1),section:o.current}),i.jsxs("div",{className:"relative flex flex-col flex-1 w-full py-4 gap-y-6",children:[l==null?void 0:l.map((m,x)=>i.jsx("div",{className:"bg-white group cursor-pointer rounded ",children:i.jsxs("div",{className:`border border-gray-100 rounded px-4 shadow-[rgba(149,157,165,0.2)_0px_2px_4px] transition-colors duration-200
57
57
  ${c===m.id?"border-dashed border-blue-400 bg-[#f7f8fa]":""} ${u.includes(x)?"min-h-[300px] pb-6 ":""}`,children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{onClick:()=>d(m.id),className:"flex-1 h-full py-4 cursor-pointer",children:i.jsx("h2",{className:"font-medium",children:m.title||"Section title"})}),i.jsxs("div",{className:"flex items-center gap-x-2",children:[i.jsx("button",{type:"button",className:"p-1 text-xs border rounded-lg",onClick:()=>y(m),children:i.jsx(F,{icon:"fluent:edit-28-regular"})}),l.length>1&&i.jsx("button",{type:"button",className:"p-1 text-xs border rounded-lg",onClick:()=>a(m.id),children:i.jsx(F,{icon:"lets-icons:trash-duotone-line"})}),i.jsx("button",{type:"button",className:"p-1 text-xs rounded-lg",onClick:()=>h(x),children:i.jsx(F,{icon:u.includes(x)?"fa6-solid:chevron-up":"fa6-solid:chevron-down",iconClass:"text-base"})})]})]}),(m==null?void 0:m.description)&&u.includes(x)&&i.jsx("p",{className:"mt-2 text-sm text-gray-600 text-gray-60",children:m==null?void 0:m.description}),u.includes(x)&&i.jsxs("div",{className:"h-full mt-4 transition-all duration-200",id:m.id,onDragOver:p,onDragEnd:()=>r(!1),onClick:()=>d(m.id),children:[i.jsx("hr",{className:"group-last:hidden"}),i.jsx("div",{className:"h-full mt-4 gap-y-6",children:i.jsx(Za,{elementData:m.questionData,sectionId:m.id})})]})]})},m.id)),i.jsx("div",{className:"flex justify-center",children:i.jsxs("button",{type:"button",onClick:()=>t(),style:{color:(f==null?void 0:f.buttonColor)||"#333"},className:"text-sm font-medium",children:["+ Add section"," "]})})]})]})};function es({questionData:e,uploadUrl:n}){const{setFormData:o,addSection:s,setUploadUrl:a}=b.useContext(le);b.useEffect(()=>{e&&e.length>0&&o(e)},[e,o]),b.useEffect(()=>{a(n)},[n,a]);const t=b.useCallback(l=>{l.preventDefault();try{const r=JSON.parse(l.dataTransfer.getData("properties"));if((r==null?void 0:r.type)==="section"){s();return}}catch(r){console.error("Drop error:",r)}},[]);return i.jsx("div",{onDragOver:l=>l.preventDefault(),onDrop:l=>t(l),className:"bg-white p-4 border border-[#E4E7EC] h-full overflow-y-auto no-scrollbar max-h-[calc(100vh-60px)]",children:i.jsx(Xa,{})})}const yi=[{key:"textFields",title:"Text Fields"},{key:"selectionFields",title:"Selection Fields"},{key:"dateAndTime",title:"Date & Time"},{key:"fileAndMedia",title:"File & Media"},{key:"layoutAndDisplay",title:"Layout & Display"},{key:"advancedData",title:"Advanced / Data"}],is=()=>{const[e,n]=b.useState(""),{setIsDragging:o,addElement:s,selectedSection:a}=b.useContext(le),t=b.useCallback((h,y)=>{if(!a){me.toast.error("Please select a section to add an element.");return}h.dataTransfer.setData("properties",JSON.stringify(y)),h.dataTransfer.effectAllowed="move",o(!0)},[o,a]);function l(h){if(!a){me.toast.error("Please select a section to add an element.");return}const y={...h,id:be.v4(),sectionId:a};s(y,a)}const r=ue("config")||{},d=r.elementColor,c=r.elementBgColor,u=r.elementBorderColor,g=aa.filter(h=>h.label.toLowerCase().includes(e.toLowerCase())),p=yi==null?void 0:yi.map(h=>({title:h.title,elements:g.filter(y=>{var f;return(f=sa[h.key])==null?void 0:f.includes(y.type)})})).filter(h=>h.elements.length>0);return console.log({categorizedElements:p}),i.jsxs("div",{className:"pt-4 pb-6",children:[i.jsx(me.ToastContainer,{}),i.jsx("div",{className:"px-5 mb-4",children:i.jsx("input",{className:"field-control",placeholder:"Search",value:e,onChange:h=>n(h.target.value)})}),i.jsx("hr",{}),i.jsx("div",{children:i.jsx("ul",{className:"grid gap-y-5 mt-3 px-5 max-h-[80vh] overflow-y-auto no-scrollbar",children:p==null?void 0:p.map((h,y)=>{var f;return i.jsxs("li",{children:[i.jsx("h4",{className:"mb-2 text-[11px] font-bold text-gray-500 uppercase",children:h.title}),i.jsx("ul",{className:"grid gap-y-[6px] mb-3",children:(f=h.elements)==null?void 0:f.map(m=>i.jsx("li",{onDragStart:x=>t(x,m),onDragEnd:()=>o(!1),onClick:()=>l(m),style:{borderColor:u,backgroundColor:c},className:`cursor-move text-[#475467] flex justify-between items-center h-11\r
58
58
  border-[1.5px] border-[#98A2B3] rounded-lg py-3 px-[14px] shadow-custom\r
59
59
  hover:shadow-lg transition-all duration-200\r
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arudovwen/form-builder-react",
3
- "version": "1.4.30",
3
+ "version": "1.4.32",
4
4
  "description": "A React-based form builder component library.",
5
5
  "type": "module",
6
6
  "main": "./dist/form-builder.umd.js",