@arudovwen/form-builder-react 1.3.4 → 1.3.5

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.
@@ -43403,7 +43403,7 @@ function c8({
43403
43403
  watch: a,
43404
43404
  isReadOnly: s
43405
43405
  } = t || {};
43406
- let o = "+234-4141452353";
43406
+ let o;
43407
43407
  return Re(() => {
43408
43408
  n(e.id);
43409
43409
  }, [e.id, n]), a && (o = a()[e.id]), /* @__PURE__ */ y.jsx(
@@ -116,7 +116,7 @@ License: MIT
116
116
  "data": [
117
117
  { "name": "Document Name", "id": "documentMainId", ...restObject },
118
118
  ]
119
- }`})})]})})}),s6=()=>w.jsx("blockquote",{className:"p-4 text-gray-700 bg-gray-100 rounded-md",children:w.jsxs("ul",{children:[w.jsxs("li",{className:"text-xs",children:["Method: GET ",w.jsx("br",{}),"URL format:"," ",w.jsx("code",{children:"https://example.com/validation/{documentId}"})]}),w.jsxs("li",{className:"text-xs",children:[w.jsx("span",{className:"block mb-1",children:" Response example format:"}),w.jsx("pre",{className:"p-2 bg-white rounded-md",children:w.jsxs("code",{children:["{ ",w.jsx("br",{}),'  "data": { ',w.jsx("br",{}),'    "status": true, ',w.jsx("br",{}),'    "isSigned": true ',w.jsx("br",{}),"  } ",w.jsx("br",{}),"}"]})})]})]})}),l6=Ra().shape({inputLabel:qe().nullable(),placeholder:qe().nullable(),description:qe().nullable(),isReadOnly:Wl(),isDisabled:Wl(),isRequired:Wl(),requiredMessage:qe().nullable(),minLengthMessage:qe().nullable(),maxLengthMessage:qe().nullable(),maxLength:La().typeError("Expecting a number").nullable(),minLength:La().typeError("Expecting a number").nullable(),inputType:qe().nullable(),maxAmountMessage:qe().nullable(),maxAmount:qe().nullable(),options:Zd().of(Ra().shape({label:qe().nullable(),value:qe().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:Zd().of(Ra().shape({label:qe().nullable(),value:qe().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:qe().nullable(),url:qe().nullable(),method:qe().nullable(),denominators:Ia().nullable(),responseType:qe().nullable(),minAmount:qe().nullable(),heading:qe().nullable(),minAmountMessage:qe().nullable(),columns:La().nullable(),value:Ia().nullable(),customClass:qe().nullable(),elementClass:qe().nullable(),apiUrl:qe().nullable(),selectType:qe().default("list"),dateType:qe().default("basic"),validationUrl:qe(),signatureLink:qe()}),c6=[{title:"Configurations",key:"basic"},{title:"Validations",key:"validation"}],u6=({isOpen:e,onClose:n,element:t})=>{const r=c6.filter(U=>!Gl.includes(t.inputType)||U.key!=="validation"),{updateElement:i}=g.useContext(nr),[a,o]=g.useState("basic"),[s,l]=g.useState(!1),[c,u]=g.useState("manual"),d=Yn("config"),{register:f,handleSubmit:m,control:h,setValue:p,watch:v,trigger:b,formState:{errors:y,isSubmitting:x,isValid:A},reset:D}=Wd({resolver:Kd(l6),defaultValues:{...t,options:t.options||[]}}),T=v(),{fields:k,append:E,remove:_}=jd({control:h,name:"options"}),{fields:C,append:M,remove:F}=jd({control:h,name:"options1"}),{fields:V,append:G,remove:X}=jd({control:h,name:"dataColumns"});g.useEffect(()=>{e||D()},[e,D]);const te=U=>{i(U,t.sectionId),n()},re={headers:{Authorization:`Bearer ${Yn("token")}`}},W=g.useCallback(async()=>{var U,q,le;if(!T.apiUrl||!/^https?:\/\//.test(T.apiUrl)){Qe.info("Please provide a valid API URL");return}try{l(!0);const{status:ie,data:se}=await xt.get(T.apiUrl,re);if(ie!==200||!se){Qe.error("Unexpected response from server.");return}const ue=se.data||se.record||se.result;if(!Array.isArray(ue)){Qe.error("Expected an array in response (data, record, or result).");return}((U=t.type)==null?void 0:U.toLowerCase())==="datagrid"?p("dataColumns",ue):p("options",ue)}catch(ie){const se=((le=(q=ie==null?void 0:ie.response)==null?void 0:q.data)==null?void 0:le.message)||(ie==null?void 0:ie.message)||"Unable to load options";Qe.error(se)}finally{l(!1)}},[t.type,p,T.apiUrl]),me=["manual","api","sheet"];function de(){c==="api"&&W()}const I=()=>w.jsxs("div",{className:"flex flex-col justify-start gap-y-1",children:[w.jsx("div",{className:"flex items-center mb-4 gap-x-5",children:me.map(U=>w.jsxs("label",{className:"items-center text-base capitalize gap-x-3",children:[w.jsx("input",{type:"radio",name:"optionType",onChange:q=>u(q.target.value),value:U})," ",w.jsxs("span",{children:[U," options"]})]},U))}),c==="api"&&w.jsxs("div",{className:"mb-4",children:[w.jsxs("div",{className:"flex items-center gap-x-2",children:[w.jsxs("div",{className:"relative flex items-center w-full mb-2",children:[w.jsx(Ye,{label:"Load Options from Api",name:"apiUrl",errors:y,register:f,className:"!w-full",placeholder:"https://example.com/options",isFloating:!0}),s&&w.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"})]}),w.jsx("button",{onClick:de,className:"px-3 py-1 text-xs text-white bg-gray-600 rounded",type:"button",children:"Load"})]}),w.jsx(Q4,{})]}),c==="sheet"&&w.jsx("div",{className:"mb-4",children:w.jsx(B1,{isFloating:!0,label:"Load options form sheet (csv, xlsx)",setValue:p,name:"options"})}),w.jsxs("div",{children:[w.jsx("h3",{className:"mb-4 text-sm text-gray-500",children:"Parent Options "}),k.map((U,q)=>w.jsxs("div",{className:"flex items-center mb-1 gap-x-4 last:mb-0",children:[w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Label",name:`options.${q}.label`,register:f,errors:y,element:t,placeholder:"Label",isFloating:!0})}),w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Value",name:`options.${q}.value`,register:f,errors:y,element:t,placeholder:"Value",isFloating:!0})}),w.jsx("button",{disabled:k.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>_(q),children:w.jsx(ut,{icon:"iconamoon:sign-times-fill"})})]},U.id))," ",w.jsxs("div",{children:[" ",w.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>E({label:"",value:"",id:gn()}),children:[w.jsx(ut,{icon:"qlementine-icons:plus-16"})," Add Option"]})]})]}),t.type.toLowerCase()==="cascadeselect"&&w.jsxs(w.Fragment,{children:[w.jsx("hr",{className:"my-5"}),w.jsxs("div",{children:[" ",w.jsx("h3",{className:"mb-4 text-sm text-gray-500",children:"Child Options "}),C==null?void 0:C.map((U,q)=>w.jsxs("div",{className:"flex items-center mb-1 gap-x-4 last:mb-0",children:[w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Label",name:`options1.${q}.label`,register:f,errors:y,element:t,placeholder:"Label",isFloating:!0})}),w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Value",name:`options1.${q}.value`,register:f,errors:y,element:t,placeholder:"Value",isFloating:!0})}),w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Key",name:`options1.${q}.key`,register:f,errors:y,element:t,placeholder:"Key",isFloating:!0})}),w.jsx("button",{disabled:C.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>F(q),children:w.jsx(ut,{icon:"iconamoon:sign-times-fill"})})]},U.id)),w.jsxs("div",{children:[" ",w.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>M({label:"",value:"",key:"",id:gn()}),children:[w.jsx(ut,{icon:"qlementine-icons:plus-16"})," Add Option"]})]})]})]})]}),L=()=>w.jsxs("div",{className:"flex flex-col justify-start gap-y-1",children:[w.jsx("div",{className:"flex items-center mb-4 gap-x-5",children:me.map(U=>w.jsxs("label",{className:"items-center text-base capitalize gap-x-3",children:[w.jsx("input",{type:"radio",name:"optionType",onChange:q=>u(q.target.value),value:U,checked:U===c})," ",w.jsxs("span",{children:[U," options"]})]},U))}),c==="api"&&w.jsxs("div",{className:"mb-4",children:[w.jsxs("div",{className:"flex items-center gap-x-2",children:[w.jsxs("div",{className:"relative flex items-center w-full mb-2",children:[w.jsx(Ye,{label:"Load Columns from Api",name:"apiUrl",errors:y,register:f,className:"!w-full",placeholder:"https://example.com/columns",isFloating:!0}),s&&w.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"})]})," ",w.jsx("button",{onClick:de,className:"px-3 py-1 text-xs text-white bg-gray-600 rounded",type:"button",children:"Load"})]}),w.jsx(a6,{})]}),c==="sheet"&&w.jsx("div",{className:"mb-4",children:w.jsx(B1,{isFloating:!0,label:"Load columns form sheet (csv, xlsx)",setValue:p,name:"dataColumns"})}),V.map((U,q)=>w.jsxs("div",{className:"flex items-center gap-x-4 ",children:[w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Field key",name:`dataColumns.${q}.field`,register:f,errors:y,element:t,placeholder:"Field",isFloating:!0})}),w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Header Name",name:`dataColumns.${q}.headerName`,register:f,errors:y,element:t,placeholder:"headerName",isFloating:!0})}),w.jsx("button",{disabled:V.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>X(q),children:w.jsx(ut,{icon:"iconamoon:sign-times-fill"})})]},U.id)),w.jsxs("div",{children:[" ",w.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>G({headerName:"",field:"",editable:!0,id:gn()}),children:[w.jsx(ut,{icon:"qlementine-icons:plus-16"})," Add column"]})]})]}),K=g.useCallback(async()=>{const U=Yn("token"),{status:q,data:le}=await xt.get(T.url,{headers:{Authorization:`Bearer ${U}`}});q===200&&(console.log({data:le}),p("options",(le==null?void 0:le.data)||le))},[p,T.url]);return g.useEffect(()=>{t.type==="document"&&T.url&&K()},[T.url,t.type,K]),w.jsx("div",{className:"fixed inset-0 bg-black/30 flex items-center justify-center z-[999] cursor-default select-none ",draggable:"true",onDragStart:U=>U.preventDefault(),children:w.jsxs("div",{className:"min-w-[600px] bg-white rounded-xl shadow-xl relative flex flex-col pb-4 items-center max-h-[80vh] overflow-y-auto no-scrollbar select-",draggable:"true",onDragStart:U=>U.preventDefault(),children:[w.jsx("div",{className:"z-10 flex flex-col items-start w-full gap-4 px-6 pt-4 pb-5 mb-3",children:w.jsx("button",{onClick:n,type:"button","aria-label":"close",className:"absolute right-4 top-4 p-2 text-[#98A2B3] hover:bg-gray-50 rounded-lg",children:w.jsx(ut,{icon:"tabler:x"})})}),w.jsx("div",{className:"w-full",children:w.jsx(v3,{tabs:r,setActiveTab:o,activeTab:a,className:"justify-start !text-left",btnClass:" !text-left"})}),w.jsxs("form",{onSubmit:m(te),className:"w-full",children:[w.jsxs("div",{className:" max-h-[800px] overflow-y-auto",children:[a==="basic"&&w.jsxs("div",{className:"z-10 flex flex-col w-full gap-5 px-6",children:[ef.includes(t.inputType)&&w.jsx(w.Fragment,{children:w.jsx(Ye,{label:"Value",name:"value",register:f,errors:y,element:t})}),!ef.includes(t.inputType)&&!Gl.includes(t.inputType)&&w.jsxs(w.Fragment,{children:[w.jsx(Ye,{label:"Label",name:"inputLabel",register:f,errors:y,element:t})," ",t.type.toLowerCase()==="cascadeselect"&&w.jsx(Ye,{label:"Child Label",name:"childLabel",register:f,errors:y,element:t})]}),_3.includes(t.inputType)&&w.jsx(Ye,{label:"Placeholder",name:"placeholder",register:f,errors:y,element:t}),y3.includes(t.inputType)&&w.jsx(Ye,{label:"Prefix",name:"prefix",register:f,errors:y,element:t}),S3.includes(t.inputType)&&w.jsxs("div",{className:"grid gap-y-4",children:[w.jsx(D3,{}),w.jsx(Ye,{label:"Api Url",name:"url",register:f,errors:y,element:t}),w.jsx(Fa,{label:"Api Method",options:[{label:"GET",value:"GET"},{label:"POST",value:"POST"}],register:f,name:"method",setValue:p,trigger:b,value:v("method")}),w.jsx(Fa,{label:"Api Response type",options:[{label:"String",value:"string"},{label:"Object",value:"object"}],register:f,name:"responseType",setValue:p,trigger:b,value:v("responseType")})]}),T3.includes(t.inputType)&&w.jsx(C3,{onChange:U=>{p("denominators",U)},value:v("denominators")}),!ef.includes(t.inputType)&&!Gl.includes(t.inputType)&&w.jsx(Ye,{label:"Short Description",name:"description",register:f,errors:y,element:t}),t.type.toLowerCase()==="date"&&w.jsxs(w.Fragment,{children:[w.jsx(Fa,{label:"Date Type",options:[{label:"Basic",value:"basic"},{label:"Custom",value:"custom"}],register:f,name:"dateType",setValue:p,trigger:b,value:v("dateType")}),v("dateType")==="custom"&&w.jsx(Fa,{label:"Date Format",options:A3,register:f,name:"dateFormat",setValue:p,trigger:b,value:v("dateFormat")})]}),t.type.toLowerCase()==="selectfield"&&w.jsx(Fa,{label:"Select Type",options:[{label:"List",value:"list"},{label:"Combobox",value:"Combobox"}],register:f,name:"selectType",setValue:p,trigger:b,value:v("selectType")}),t.type.toLowerCase()==="grid"&&w.jsx(Ye,{label:"Number of columns",name:"columns",register:f,errors:y,element:t}),t.type.toLowerCase()==="document"&&w.jsxs("div",{className:"grid gap-y-6",children:[w.jsxs("div",{className:"grid gap-y-1",children:[w.jsx(Ye,{label:"Document Options Url",name:"url",register:f,errors:y,element:t})," ",w.jsx(o6,{})]}),w.jsxs("div",{className:"grid gap-y-1",children:[w.jsx(Ye,{label:"Document Validation Url",name:"validationUrl",register:f,errors:y,element:t}),w.jsx(s6,{})]}),w.jsx("div",{className:"grid gap-y-1",children:w.jsx(Ye,{label:"Signature Page Url",name:"signatureLink",register:f,errors:y,element:t})})]}),t.type.toLowerCase()==="datagrid"&&L(),E3.includes(t.inputType)&&I()]}),!Gl.includes(t.type.toLowerCase())&&a==="validation"&&w.jsxs("div",{className:"z-10 flex flex-col w-full gap-5 px-6",children:[w.jsxs("div",{className:"flex items-center gap-x-6",children:[w.jsx("div",{className:"w-[150px]",children:w.jsx(Ye,{label:"Required",name:"isRequired",register:f,errors:y,element:t,type:"checkbox"})})," ",w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Error message text",name:"requiredMessage",register:f,errors:y,element:t})})]}),w3.includes(t.inputType)&&w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"flex items-center gap-x-6",children:[w.jsx("div",{className:"w-[150px]",children:w.jsx(Ye,{label:"Min Length",name:"minLength",register:f,errors:y,element:t,type:"number"})})," ",w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Error message text",name:"minLengthMessage",register:f,errors:y,element:t})})]}),w.jsxs("div",{className:"flex items-center gap-x-6",children:[w.jsx("div",{className:"w-[150px]",children:w.jsx(Ye,{label:"Max Length",name:"maxLength",register:f,errors:y,element:t,type:"number"})})," ",w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Error message text",name:"maxLengthMessage",register:f,errors:y,element:t})})]})]}),k3.includes(t.inputType)&&w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"flex items-center gap-x-6",children:[w.jsx("div",{className:"w-[150px]",children:w.jsx(Ye,{label:"Min Amount",name:"minAmount",register:f,errors:y,element:t,type:"amount"})})," ",w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Error message text",name:"minAmountMessage",register:f,errors:y,element:t})})]}),w.jsxs("div",{className:"flex items-center gap-x-6",children:[w.jsx("div",{className:"w-[150px]",children:w.jsx(Ye,{label:"Max Amount",name:"maxAmount",register:f,errors:y,element:t,type:"amount"})})," ",w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Error message text",name:"maxAmountMessage",register:f,errors:y,element:t})})]})]})]})]}),w.jsxs("div",{className:"flex w-full gap-3 px-6 pt-8 pb-6 mt-4",children:[w.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"}),w.jsx("button",{type:"submit",disabled:!A||x,style:{background:(d==null?void 0:d.buttonColor)||"#333"},className:`flex-1 px-4 py-2.5 ${!A||x?"bg-[#F2F4F7]":"bg-[#2563EB]"} ${!A||x?"text-[#98A2B3]":"text-white"} rounded-lg shadow-xs font-semibold font-onest disabled:opacity-50 editor_option__save`,children:x?"Saving...":"Save"})]})]})]})})},c0=g.memo(({state:e,element:n,children:t})=>{const[r,i]=g.useState(!1),{removeElement:a}=g.useContext(nr),o=g.useCallback(()=>{a(n.id,n.sectionId)},[n.id,n.sectionId,a]);return w.jsxs("div",{className:"w-full",children:[r&&w.jsx(u6,{isOpen:r,onClose:()=>i(!1),element:n}),w.jsxs("div",{className:"flex justify-between items-center mb-2",children:[w.jsxs("span",{children:[" ",n.inputLabel&&w.jsx("label",{className:"text-sm font-medium",children:n.inputLabel})]}),e==="edit"&&w.jsxs("span",{className:"flex gap-x-3 items-center",children:[w.jsx("button",{type:"button",className:"outline-none hover:opacity-80 text-sm",onClick:()=>i(!0),children:w.jsx(ut,{icon:"circum:edit"})}),w.jsx("button",{type:"button",className:"outline-none hover:opacity-80 text-sm",onClick:o,children:w.jsx(ut,{icon:"iconamoon:sign-times-fill"})})]})]}),t]})});c0.displayName="ElementContainer";function d6(e){if(!e)return!1;const n=/^data:image\/(jpeg|png|gif|bmp|webp);base64,/i,t=/\.(jpeg|jpg|png|gif|bmp|webp)$/i;return n.test(e)||t.test(e)}const f6=({imageUrl:e})=>{const[n,t]=g.useState(!1),r=()=>{t(!0)},i=()=>{t(!1)};return w.jsxs("div",{children:[w.jsx("img",{alt:"Thumbnail",style:{cursor:"pointer",width:"120px",height:"130px",objectFit:"cover"},onClick:r,src:e||"/place.png","data-toggle":"tooltip","data-placement":"top",title:"Click to view"}),n&&w.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:i,children:w.jsxs("div",{className:"modal-content",style:{position:"relative",backgroundColor:"white",padding:"20px",borderRadius:"8px",width:"90vw"},onClick:a=>a.stopPropagation(),children:[w.jsx("span",{className:"close",onClick:i,style:{position:"absolute",top:"10px",right:"10px",fontSize:"24px",cursor:"pointer"},children:"×"}),w.jsx("img",{src:e||"/place.png",alt:"Full Image",style:{maxWidth:"90%",maxHeight:"90vh",objectFit:"contain"}})]})})]})};function m6({element:e,validationData:n}){const{register:t=()=>({}),setValue:r,watch:i}=n||{},[a,o]=g.useState(),[s,l]=g.useState(!1),[c,u]=g.useState(!1),[d,f]=g.useState(""),m=i&&i(e==null?void 0:e.id);g.useEffect(()=>{o(m)},[m]);const[h,p]=g.useState("");g.useEffect(()=>{t(e.id)},[e.id,t]);const{url:v,method:b,responseType:y}=e||{},A={headers:{Authorization:`Bearer ${Yn("token")}`}},D=g.useCallback(async T=>{var k,E,_,C,M,F,V,G,X,te,z;if(!(!v||!b)){l(!0);try{let re;if(b.toLowerCase()==="get"){const W=`${v}?value=${T}`;re=await xt.get(W,A)}else if(b.toLowerCase()==="post")re=await xt.post(v,{value:T},A);else throw new Error("Unsupported HTTP method");re.status===200&&((((E=(k=re==null?void 0:re.data)==null?void 0:k.data)==null?void 0:E.status)||((_=re==null?void 0:re.data)==null?void 0:_.status))===!0?(u(!0),y==="string"?f(((M=(C=re==null?void 0:re.data)==null?void 0:C.data)==null?void 0:M.description)||((F=re==null?void 0:re.data)==null?void 0:F.description)||"Validation successful"):p(((G=(V=re==null?void 0:re.data)==null?void 0:V.data)==null?void 0:G.description)||((X=re==null?void 0:re.data)==null?void 0:X.description)||{})):(console.error("Invalid input:",T),f("Unable to validate input"),u(!1)))}catch(re){console.error("Error validating input:",re),f(((z=(te=re==null?void 0:re.response)==null?void 0:te.data)==null?void 0:z.message)||"Unable to validate input"),u(!1)}finally{l(!1)}}},[b,y,v]);return g.useEffect(()=>{if(a){const T=setTimeout(()=>{D(a)},700);return()=>clearTimeout(T)}},[D,a]),w.jsxs("div",{children:[w.jsxs("div",{className:"relative flex items-center",children:[w.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"",type:(e==null?void 0:e.inputType)||"text",className:Ie("field-control",e==null?void 0:e.customClass),...t(e==null?void 0:e.id),onChange:T=>{o(T.target.value),r(e==null?void 0:e.id,T.target.value)},disabled:n==null?void 0:n.isReadOnly}),w.jsxs("span",{className:"absolute right-0",children:[s&&w.jsxs("span",{children:[" ",w.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:[w.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),w.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&&!s&&w.jsx("span",{className:"block pr-3 text-lg text-green-600",children:w.jsx(ut,{icon:"gg:check-o"})})]})]}),d&&y==="string"&&w.jsx("span",{className:`${c?"text-green-600":"text-red-600"} text-sm`,children:d}),y==="object"&&w.jsx("div",{className:"grid grid-cols-2 gap-6 mt-2 text-sm text-gray-600",children:Object.entries(h).map(([T,k])=>w.jsxs("div",{className:"flex items-center gap-x-2",children:[w.jsxs("span",{className:"font-semibold",children:[T,":"]}),d6(k)?w.jsx(f6,{imageUrl:k}):w.jsx("span",{children:String(k)})]},T))})]})}function h6({onGetTotal:e,readOnly:n,defaultValue:t,denominators:r}){const[i,a]=g.useState([...t]);function o(c,u){a(d=>{const f=[...d];return f[u]={...f[u],value:c},f})}function s(c,u){return parseFloat(c)*parseFloat(u)||0}const l=g.useMemo(()=>i.reduce((c,u)=>{const d=s(u.key,u.value);return c+d},0),[i]);return g.useEffect(()=>{e&&e(i)},[i]),g.useEffect(()=>{if(r!=null&&r.length){const c=r.map((u,d)=>({key:u.value,value:Array.isArray(t)&&t[d]?t[d].value:""}));a(c)}},[t,r]),w.jsx("div",{className:"mt-2",children:w.jsxs("div",{className:"border border-gray-200 rounded-lg overflow-hidden text-gray-700",children:[w.jsxs("div",{className:"grid grid-cols-3 text-sm font-bold border-b border-gray-100 bg-gray-50",children:[w.jsx("div",{className:"border-r px-4 py-2",children:w.jsx("span",{className:"",children:"Denomination"})}),w.jsx("div",{className:"border-r px-4 py-2",children:w.jsx("span",{children:"Quantity"})}),w.jsx("div",{className:"px-4 py-2",children:w.jsx("span",{children:"Sub total"})})]}),i.map((c,u)=>{var d,f;return w.jsxs("div",{className:"grid grid-cols-3 text-sm border-b border-gray-100",children:[w.jsx("div",{className:"border-r px-4 py-2 flex items-center",children:w.jsx("span",{className:"",children:(d=parseFloat(c.key))==null?void 0:d.toLocaleString()})}),w.jsx("div",{className:"border-r px-4 py-1",children:w.jsx("span",{children:w.jsx(Ro,{id:"input-example",className:"border border-gray-100 rounded w-full px-3 py-1 outline-none",decimalsLimit:6,value:c.value,onValueChange:m=>o(m,u),disabled:n,allowNegativeValue:!1})})}),w.jsx("div",{className:"px-4 py-2 flex justify-between items-center",children:w.jsx("span",{children:(f=s(c.key,c.value))==null?void 0:f.toLocaleString()})})]},u+"index")}),w.jsxs("div",{className:"grid grid-cols-3 text-sm font-bold bg-gray-50",children:[w.jsx("div",{className:"border-r px-4 py-3 col-span-2 text-right",children:"Total"}),w.jsx("div",{className:"px-4 py-3",children:l==null?void 0:l.toLocaleString()})]})]})})}function p6({element:e,validationData:n}){const{register:t=()=>({}),setValue:r,getValues:i}=n||{},a=i&&i(e==null?void 0:e.id)||[];return g.useEffect(()=>{t(e.id)},[e.id,t]),w.jsx("div",{children:w.jsx(h6,{onGetTotal:o=>{r&&r(e.id,o)},denominators:(e==null?void 0:e.denominators)||[],defaultValue:a,readOnly:e==null?void 0:e.isReadOnly})})}function v6({element:e}){return w.jsx("div",{className:Ie("py-6",e==null?void 0:e.customClass)})}function b6({element:e}){return w.jsx("div",{children:w.jsx("hr",{className:Ie("border-gray-200 my-4",e==null?void 0:e.customClass)})})}function g6({element:e,validationData:n}){const{register:t=()=>({})}=n||{};return w.jsx("div",{children:w.jsx("input",{placeholder:"Enter text",type:"text",className:"field-control",...t(e==null?void 0:e.id)})})}function x6({element:e,state:n}){return w.jsx(w.Fragment,{children:w.jsx("div",{className:e==null?void 0:e.customClass,children:(e==null?void 0:e.value)||n==="edit"&&w.jsx("span",{className:"text-gray-400",children:"Provide text"})})})}function y6({value:e=[],onChange:n,isReadOnly:t,columns:r=[]}){const[i,a]=g.useState(e),[o,s]=g.useState(null);g.useEffect(()=>{a(e)},[]);const l=(f,m,h)=>{const p=i.map((v,b)=>b===m?{...v,[h]:f}:v);a(p),n&&n(p)},c=()=>{const f=i.length>0?Math.max(...i.map(p=>Number(p.id)||0))+1:1,m=r.reduce((p,v)=>({...p,[v.field]:v.field==="id"?f:""}),{}),h=[...i,m];a(h),n&&n(h)},u=f=>{const m=i.filter((h,p)=>p!==f);a(m),n&&n(m)},d=(f,m)=>(o==null?void 0:o.rowIndex)===f&&(o==null?void 0:o.field)===m;return w.jsxs("div",{className:"mt-4 rounded",children:[w.jsx("div",{className:"flex justify-end",children:(r==null?void 0:r.length)>0&&!t&&w.jsx("button",{onClick:c,type:"button",className:"px-2 py-1 mb-3 text-xs text-white bg-gray-600 rounded hover:bg-gray-700",children:"Add Row"})}),w.jsxs("table",{className:"w-full text-sm border-collapse rounded table-auto bg-gray-50",children:[w.jsx("thead",{children:w.jsxs("tr",{className:"bg-gray-100",children:[r.map(f=>w.jsx("th",{className:"px-3 py-2 text-xs font-semibold text-left text-gray-600 border",children:f.headerName||f.field},f.field)),!t&&w.jsx("th",{className:"w-10 px-2 py-2 border"})]})}),w.jsx("tbody",{children:i.length>0?i.map((f,m)=>w.jsxs("tr",{children:[r.map(h=>w.jsx("td",{className:"px-2 py-1 border",onDoubleClick:()=>h.editable&&!t&&s({rowIndex:m,field:h.field}),children:h.editable&&d(m,h.field)&&!t?w.jsx(w.Fragment,{children:h.type==="number"?w.jsx(Ro,{value:f[h.field]??"",onValueChange:p=>l(p,m,h.field),decimalsLimit:6,allowNegativeValue:!1,placeholder:"",className:"w-full px-2 py-1 border rounded outline-none"}):w.jsx("input",{autoFocus:!0,type:"text",value:f[h.field]??"",onChange:p=>l(p.target.value,m,h.field),onBlur:()=>s(null),className:"w-full px-2 py-1 text-gray-600 border rounded outline-none"})}):w.jsx("span",{className:"block py-1 text-gray-700 cursor-pointer",children:f[h.field]})},h.field)),!t&&w.jsx("td",{className:"px-2 py-1 text-center border",children:w.jsx("button",{onClick:()=>u(m),className:"text-red-500 hover:text-red-700","aria-label":"Delete row",children:w.jsx(ut,{icon:"lets-icons:trash-duotone",iconClass:"text-xl"})})})]},f.id??m)):w.jsx("tr",{children:w.jsx("td",{colSpan:r.length+(t?0:1),className:"p-2 text-xs text-center text-gray-400",children:"No data available"})})})]})]})}function w6({element:e,validationData:n}){const{register:t=()=>({}),setValue:r,watch:i}=n||{},a=i&&i(e==null?void 0:e.id)||[];return g.useEffect(()=>{t(e.id)},[e.id,t]),console.log(e),w.jsx(y6,{value:a,onChange:o=>{r(e.id,o)},columns:e==null?void 0:e.dataColumns,isReadOnly:e==null?void 0:e.isReadOnly})}const j1=({className:e="",options:n=[],placeholder:t="Select",errors:r,register:i,setValue:a,name:o,label:s,value:l,trigger:c,isMultiple:u=!1,isFloatingLabel:d=!1,subText:f,labelClass:m="text-[10px]",loading:h,disabled:p})=>{const[v,b]=g.useState(u?[]:null),y=Ie("field-control",e),x=g.useMemo(()=>n,[n]);g.useEffect(()=>{const D=n==null?void 0:n.find(T=>typeof T.value=="string"&&typeof l=="string"?T.value.toLowerCase()===l.toLowerCase():typeof T.value=="object"&&typeof l=="object"?T.value.id===(l==null?void 0:l.id):T.value===l);b(D||null)},[l,n]),g.useEffect(()=>{v&&a&&i&&(a(o,v==null?void 0:v.value),i(o),c==null||c(o))},[o,v]);const A=D=>b(D);return w.jsxs("div",{className:"relative",children:[s&&!d&&w.jsx("label",{className:"block text-sm text-[#686878] darks:!text-white/70 mb-2",children:s}),d&&s&&w.jsx("label",{className:`z-[40] absolute block text-[#667085] bg-white py-[2px] px-1 -top-[10px] left-3 ${m}`,children:s}),w.jsx(Gn,{value:v,onChange:A,multiple:u,disabled:p,children:w.jsxs("div",{className:"relative",children:[w.jsxs(Gn.Button,{className:y,disabled:p,children:[h?w.jsx("span",{className:"block text-sm text-left opacity-60",children:"Fetching data..."}):w.jsx("span",{className:"block text-sm text-left truncate",children:(v==null?void 0:v.label)||w.jsx("span",{className:"opacity-60",children:t})}),w.jsx("span",{className:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none",children:w.jsx(ut,{icon:"lucide:chevron-down"})})]}),w.jsx(ad,{as:g.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:w.jsx(Gn.Options,{className:"z-[77] absolute mt-1 max-h-60 w-full overflow-auto rounded-md bg-white darks:bg-gray-800 text-gray-900 darks:text-white/80 py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm",children:x==null?void 0:x.map((D,T)=>w.jsx(Gn.Option,{className:({active:k})=>Ie("relative cursor-default select-none py-2 pl-4 pr-4 text-sm",k?"bg-gray-100 darks:bg-gray-700 text-gray-900 darks:text-white/80":"text-gray-900 darks:text-white/70"),value:D,children:({selected:k})=>w.jsx("div",{className:`block truncate text-sm ${k?"font-medium":"font-normal"}`,children:D.label})},T))})})]})}),f&&!r&&w.jsx("p",{className:"text-[10px] text-[#98A2B3] leading-normal mt-[6px]",children:f}),r&&w.jsx("span",{className:"text-sm text-red-500",children:r.message})]})},_6=({element:e,validationData:n})=>{const{register:t=()=>({}),trigger:r,setValue:i,watch:a,isReadOnly:o}=n||{},s=(e==null?void 0:e.id)??"cascadeValue",[l,c]=g.useState(""),[u,d]=g.useState(""),f=(p,v)=>{const b=p&&v?`${p}_${v}`:"";i==null||i(s,b),r==null||r(s)},m=(p,v)=>{p==="first"?(c(v),d(""),f(v,"")):(d(v),f(l,v))};g.useEffect(()=>{if(a){const p=a(s);if(p!=null&&p.includes("_")){const[v,b]=p.split("_");c(v),d(b)}}},[a,s]);const h=g.useMemo(()=>{var p;return(p=e.options1)==null?void 0:p.filter(v=>v.key===l)},[e.options1,l]);return!e.options||!e.options1?null:w.jsxs("div",{children:[w.jsx("input",{type:"hidden",...t(s)}),w.jsx("div",{className:"relative",children:w.jsx(j1,{setValue:(p,v)=>m("first",v),options:e.options,name:`${s}`,register:t,value:l})}),l&&w.jsxs("div",{className:"mt-4",children:[(e==null?void 0:e.childLabel)&&w.jsx("label",{className:"block text-sm text-[#686878] darks:!text-white/70 mb-2",children:e==null?void 0:e.childLabel}),w.jsx(j1,{setValue:(p,v)=>m("second",v),options:h,name:`${s}`,register:t,value:u})]})]})},k6=({value:e=0,max:n=5,readOnly:t=!1,onChange:r,size:i=24,className:a="",element:o,validationData:s})=>{const{register:l=()=>({}),trigger:c,setValue:u,watch:d,isReadOnly:f}=s||{},m=(d==null?void 0:d(o.id))??0,[h,p]=g.useState(null);g.useEffect(()=>{m==null&&(u==null||u(o.id,e))},[]);const v=b=>{if(!t&&!f){const y=b+1;u==null||u(o.id,y),c==null||c(o.id),r==null||r(y)}};return w.jsxs("div",{className:`flex gap-1 ${a}`,children:[w.jsx("input",{type:"hidden",...l(o.id)}),Array.from({length:n},(b,y)=>{const x=h!==null?y<=h:y<m;return w.jsx(kv,{icon:x?"mdi:star":"mdi:star-outline",className:`cursor-pointer transition-colors ${x?"text-yellow-400":"text-gray-300"}`,width:i,height:i,onMouseEnter:()=>!(t||f)&&p(y),onMouseLeave:()=>!(t||f)&&p(null),onClick:()=>v(y)},y)})]})};function U1({element:e,validationData:n}){const{register:t=()=>({}),setValue:r,trigger:i,isReadOnly:a,watch:o}=n||{};let s;const l=(c,u)=>{r==null||r(c,u==null?void 0:u.value),i==null||i(c)};return o&&(s=o()[e.id]),w.jsxs("div",{children:[w.jsx("input",{type:"hidden",...t(e.id)}),w.jsx(Av,{options:e.options,onGetValue:l,name:e.id,readOnly:a,defaultValue:s})]})}function E6({element:e,validationData:n}){const{register:t=()=>({}),isReadOnly:r}=n||{},{validationUrl:i,documentObj:a,signatureLink:o}=e,s=g.useMemo(()=>Yn("config"),[]),[l,c]=g.useState(!1),[u,d]=g.useState(!1),f=g.useCallback(async()=>{var m;if(!(!i||!a))try{d(!0);const p={headers:{Authorization:`Bearer ${Yn("token")}`}},{data:v}=await xt.get(`${i}/${a}`,p),b=!!(((m=v==null?void 0:v.data)==null?void 0:m.isSigned)??(v==null?void 0:v.isSigned));return c(b),b}catch(h){console.error("Failed to check sign status",h)}finally{d(!1)}},[i,a]);return g.useEffect(()=>{let m=null;return!l&&a&&i&&(async()=>{await f()||(m=setInterval(async()=>{await f()&&m&&clearInterval(m)},2e3))})(),()=>{m&&clearInterval(m)}},[f,l,a,i]),w.jsxs("div",{className:"flex items-center gap-x-2",children:[w.jsx("input",{placeholder:e.placeholder,type:e.inputType,className:Ie("field-control",e.customClass),...t(e.id),disabled:r}),w.jsx("a",{href:l?"#":o,children:w.jsxs("button",{type:"button",onClick:f,disabled:u||l,style:{background:(s==null?void 0:s.buttonColor)||"#333"},className:Ie("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:[w.jsx(ut,{icon:u?"solar:refresh-outline":l?"solar:check-circle-bold":"solar:pen-2-line-duotone",iconClass:u?"animate-spin":""}),u?"Checking...":l?"Signed":"Sign"]})})]})}const S6=[{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 T6({label:e,placeholder:n,classLabel:t,isRequired:r,isOptional:i,name:a,value:o,error:s,disabled:l,readOnly:c,horizontal:u,description:d,validate:f,onChange:m,onError:h}){const[p,v]=g.useState(""),[b,y]=g.useState(null),[x,A]=g.useState(""),D=g.useMemo(()=>S6.map(F=>({...F,phone:`+${F.phone}`})),[]),T=g.useMemo(()=>p?D.filter(F=>`${F.label} ${F.phone}`.toLowerCase().includes(p.toLowerCase())):D,[p,D]),k=(b==null?void 0:b.min)||10,E=(b==null?void 0:b.max)||10,_=()=>x?`${(b==null?void 0:b.phone)||"+234"}-${x}`:"",C=F=>{if(!F)return{code:"+234",number:""};const V=F.split(/[-\s]/);return{code:V[0],number:V.slice(1).join(" ")}};g.useEffect(()=>{if(o){const F=C(o);y(D.find(V=>V.phone===F.code)||D[0]),A(F.number)}},[o,D]);const M=g.useMemo(()=>{if(s)return s;const F=x.length;return r&&F===0?"Phone number is required":F>0&&F<k?`Minimum length is ${k}`:F>E?`Maximum length is ${E}`:""},[s,x,k,E,r]);return g.useEffect(()=>{m==null||m(_()),h==null||h(M||null)},[x,b,M]),w.jsxs("div",{className:`relative formGroup ${M?"has-error":""} ${u?"flex":""} ${!M&&x.length>0?"is-valid":""}`,children:[e&&w.jsxs("label",{htmlFor:a,className:`${t} ${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," ",r&&w.jsx("span",{className:"text-red-500",children:"*"}),i&&w.jsx("span",{className:"text-[#98A2B3]",children:"(Optional)"})]}),w.jsxs("div",{className:"relative !flex items-center input-control text-[#667085] !py-0 field-control",children:[w.jsx(ut,{icon:"lucide:phone-call"}),w.jsx(Da,{value:b,onChange:y,children:w.jsxs("div",{className:"relative",children:[w.jsx(Da.Input,{className:"pl-3 pr-4 mr-1 text-sm bg-white border-r py-[10px] outline-none whitespace-nowrap max-w-[70px]",displayValue:F=>(F==null?void 0:F.phone)||"+234",placeholder:"+234",onChange:F=>v(F.target.value)}),w.jsx(Da.Button,{className:"absolute inset-y-0 right-0 flex items-center pr-2",children:w.jsx(ut,{icon:"lucide:chevron-down"})}),w.jsx(Da.Options,{className:"absolute z-10 w-[250px] left-0 bg-white border rounded-md shadow-lg max-h-[400px] overflow-y-auto",children:T.map((F,V)=>w.jsxs(Da.Option,{value:F,className:"px-4 py-2 cursor-pointer hover:bg-gray-100",children:[F.phone," - ",F.label]},`${F.code}+ ${V}`))})]})}),w.jsxs("div",{className:"relative flex items-center flex-1 z-[1]",children:[w.jsx("input",{type:"tel",inputMode:"numeric",value:x,disabled:l,readOnly:c,onChange:F=>A(F.target.value.slice(0,E)),placeholder:n,className:"w-full px-3 outline-none"}),w.jsx("div",{className:"absolute flex text-xl -translate-y-1/2 top-1/2 right-4",children:!M&&x.length>0&&w.jsx("span",{className:"text-green-500",children:w.jsx(ut,{icon:"bi:check-lg"})})})]})]}),M?w.jsx("span",{className:"block mt-1 text-sm text-red-500",children:M}):x.length>0&&f&&w.jsx("span",{className:"block mt-1 text-sm text-green-500",children:f}),d&&w.jsx("span",{className:"block text-[#475467] font-light leading-4 text-xs mt-2",children:d})]})}function A6({element:e,validationData:n}){const{register:t=()=>({}),trigger:r,setValue:i,watch:a,isReadOnly:o}=n||{};let s="+234-4141452353";return g.useEffect(()=>{t(e.id)},[e.id,t]),a&&(s=a()[e.id]),w.jsx(T6,{placeholder:e.placeholder,label:"",name:e.id,value:s,readOnly:o,disabled:o,onChange:l=>{l&&(i==null||i(e.id,l),r==null||r(e.id))}})}const H1={textField:ml,longText:bD,selectField:vD,multiSelect:$A,numberField:ml,amountField:ml,date:NE,password:eD,checkbox:pD,radio:mD,email:ml,file:ZC,dataGrid:w6,section:hD,validateInput:m6,tableInput:p6,spacer:v6,divider:b6,header:g6,basicText:x6,phoneField:A6,cascadeSelect:_6,rating:k6,country:U1,bank:U1,document:E6},V1="edit",$1=(e,n)=>{const t=H1[e.type];return t?w.jsx(c0,{element:e,state:V1,children:w.jsxs("div",{className:"relative w-full",children:[e.type.toLowerCase()!=="grid"&&w.jsx("div",{className:"absolute top-0 left-0 z-20 w-full h-full"}),w.jsx(t,{element:e,state:V1,sectionId:n})]})}):null},u0=({col:e,children:n,customClass:t})=>w.jsx("div",{className:Ie("w-full bg-white",t),style:{gridColumn:e},children:n}),C6=({element:e,sectionId:n,children:t,customClass:r,state:i})=>{const{formData:a,addElement:o,setIsDragging:s}=g.useContext(nr),l=g.useMemo(()=>Array.from({length:e.columns}),[e.columns]),c=g.useCallback(f=>{f.preventDefault(),f.stopPropagation(),f.dataTransfer.dropEffect="move"},[]),u=g.useCallback((f,m)=>{var h,p;f.preventDefault(),s(!1);try{const v=f.dataTransfer.getData("properties");if(!v)return;const b=JSON.parse(v);if((b==null?void 0:b.type)==="grid")return;const y=m+1;if((p=(h=a.find(D=>D.id===n))==null?void 0:h.questionData)==null?void 0:p.some(D=>{var T;return D.gridId===e.id&&((T=D.gridPosition)==null?void 0:T.col)===y}))return;const A={...b,id:gn(),sectionId:n,gridId:e.id,gridPosition:{col:y}};o(A,n)}catch(v){console.error("Drop failed in grid:",v),s(!1)}},[o,e.id,a,n,s]),d=(f,m,h)=>{const p=Array.isArray(t)&&t.find(v=>{var b;return((b=v==null?void 0:v.props)==null?void 0:b.col)===f+1});return w.jsx("div",{children:w.jsx("div",{id:f.toString(),onDrop:v=>u(v,f),onDragOver:c,className:Ie("border rounded-lg min-h-[110px] bg-white ","flex items-center justify-center text-gray-400 transition-colors",`${h==="edit"?"p-3":""}`,m),children:p||w.jsx("span",{children:h==="edit"&&w.jsx(ut,{icon:"ph:plus-bold"})})})},f)};return w.jsx("div",{className:"relative w-full",children:w.jsx("div",{className:"grid w-full gap-3",style:{gridTemplateColumns:`repeat(${e.columns}, 1fr)`},children:l.map((f,m)=>d(m,r,i))})})},d0=g.memo(C6),D6="edit";function F6({elementData:e,sectionId:n}){const{formData:t,updateElementPosition:r,isDragging:i,setIsDragging:a,addElementInPosition:o}=g.useContext(nr),[s,l]=g.useState(null),[c,u]=g.useState(null),d=g.useMemo(()=>{var x;return((x=t.find(A=>A.id===n))==null?void 0:x.questionData)||[]},[t,n]),f=g.useCallback((x,A)=>{x.dataTransfer.setData("properties",A),l(A)},[]),m=g.useCallback((x,A)=>{x.preventDefault(),x.stopPropagation(),u(A)},[]),h=g.useCallback(x=>{x.preventDefault(),x.stopPropagation();const A=x.dataTransfer.getData("properties"),D=x.currentTarget.id;if(!D||A===D)return;const T=d.findIndex(C=>C.id===A),k=d.findIndex(C=>C.id===D);if(T===-1||k===-1)return;const E=[...d],[_]=E.splice(T,1);E.splice(k,0,_),r(E,n),l(null)},[d,n,r]),p=g.useCallback((x,A)=>{x.preventDefault(),a(!1);try{const D=JSON.parse(x.dataTransfer.getData("properties"));if(console.log({data:D}),(D==null?void 0:D.type)==="section")return;const T={...D,id:gn(),sectionId:n};o(T,n,A)}catch(D){console.error("Drop error:",D)}},[o,n,a]),v=g.useCallback(x=>w.jsx("div",{className:"transition rounded hover:bg-blue-300",onDragOver:A=>A.preventDefault(),onDrop:A=>p(A,x),onDragEnd:()=>a(!1),children:w.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:w.jsx(ut,{icon:"octicon:plus-16"})})},`drop-${x}`),[p,a]),b=g.useCallback(x=>w.jsx("div",{id:x.id,className:Ie("cursor-move border p-4 w-full rounded-lg transition-colors bg-white",{"bg-gray-100":s===x.id,"border-dashed border-blue-300":s&&s!==x.id}),draggable:!0,onDragStart:A=>f(A,x.id),onDragOver:A=>m(A,x.id),onDrop:h,onDragEnd:()=>l(null),children:$1(x,n)},x.id),[s,h,m,n,f]),y=g.useMemo(()=>(e==null?void 0:e.reduce((x,A)=>(A.gridId&&(x[A.gridId]=x[A.gridId]||[],x[A.gridId].push(A)),x),{}))||{},[e]);return e!=null&&e.length?w.jsx("div",{className:"relative grid w-full h-full grid-cols-1 gap-4",children:e.map((x,A)=>{if(x.type==="grid"){const D=y[x.id]||[];return w.jsx("div",{draggable:!0,onDragStart:T=>f(T,x.id),onDragOver:T=>m(T,x.id),onDrop:h,onDragEnd:()=>l(null),className:"w-full p-4 transition-colors bg-white border rounded-lg cursor-move",children:w.jsx(c0,{element:x,state:"edit",children:w.jsx(d0,{element:x,sectionId:n,state:D6,children:D.map(T=>{var k;return w.jsx(u0,{col:(k=T.gridPosition)==null?void 0:k.col,children:$1(T,n)},T.id)})})})},x.id)}return x.gridId?null:w.jsxs("div",{className:Ie("group relative grid gap-y-[6px]",x.elementClass),children:[i&&c===x.id&&v(A),w.jsx("div",{className:"group",children:b(x)}),i&&c===x.id&&v(A+1)]},x.id)})}):w.jsx("div",{onDragOver:x=>x.preventDefault(),onDrop:x=>p(x,0),onDragEnd:()=>a(!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 O6=g.memo(F6),M6=Ra({title:qe(),description:qe()}).required(),f0=Yn("config"),N6=({isOpen:e,onClose:n,section:t})=>{const{updateSection:r}=g.useContext(nr),{register:i,handleSubmit:a,formState:{errors:o,isSubmitting:s,isValid:l},reset:c}=Wd({resolver:Kd(M6),defaultValues:t});if(g.useEffect(()=>{e||c()},[e,c]),!e)return null;const u=d=>{r(d,t.id),n()};return w.jsx("div",{className:"fixed inset-0 bg-black/30 flex items-center justify-center z-[999] cursor-default no-drag select-none",children:w.jsxs("div",{className:"min-w-[600px] bg-white rounded-xl shadow-xl relative flex flex-col items-center",children:[w.jsxs("div",{className:"w-full px-6 pt-6 pb-5 flex flex-col items-start gap-4 z-10 mb-6",children:[w.jsx("h2",{className:"text-lg font-semibold text-[#475467] font-onest",children:"Update Section Information"}),w.jsx("button",{onClick:n,className:"absolute right-4 top-4 p-2 text-[#98A2B3] hover:bg-gray-50 rounded-lg",children:w.jsx(ut,{icon:"tabler:x"})})]}),w.jsxs("form",{onSubmit:a(u),className:"w-full",children:[w.jsxs("div",{className:"w-full px-6 flex flex-col gap-5 z-10",children:[w.jsx(Ye,{label:"Title",name:"title",register:i,errors:o}),w.jsx(Ye,{label:"Description",name:"description",register:i,errors:o})]}),w.jsxs("div",{className:"w-full px-6 pt-8 pb-6 flex gap-3 mt-4",children:[w.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"}),w.jsx("button",{type:"submit",disabled:!l||s,style:{background:(f0==null?void 0:f0.buttonColor)||"#333"},className:`flex-1 px-4 py-2.5 ${!l||s?"bg-[#F2F4F7]":"bg-[#2563EB]"} ${!l||s?"text-[#98A2B3]":"text-white"} rounded-lg shadow-xs font-semibold font-onest disabled:opacity-50`,children:s?"Saving...":"Save"})]})]})]})})},P6=()=>{const[e,n]=g.useState(!1),t=g.useRef(null),r=g.useRef(null),{removeSection:i,formData:a,setIsDragging:o,setSelectedSection:s,selectedSection:l,activeSections:c,setActiveSections:u}=g.useContext(nr);g.useEffect(()=>{var h;s(((h=a[0])==null?void 0:h.id)||null)},[]);const d=g.useCallback(h=>{h.preventDefault(),h.dataTransfer.dropEffect="move",r.current&&(r.current.scrollTop=r.current.scrollHeight)},[]);function f(h){c.includes(h)?u(p=>p.filter(v=>v!==h)):u(p=>[...p,h])}function m(h){t.current=h,n(!0)}return w.jsxs("div",{ref:r,className:"relative flex flex-col h-full px-6 pb-5 mx-auto gap-x-4",children:[e&&w.jsx(N6,{isOpen:e,onClose:()=>n(!1),section:t.current}),w.jsx("div",{className:"relative flex flex-col flex-1 w-full py-4 gap-y-6",children:a.map((h,p)=>w.jsxs("div",{className:"group cursor-pointer rounded ",children:[w.jsxs("div",{className:`border border-gray-100 rounded px-4 shadow-[rgba(149,157,165,0.2)_0px_2px_4px] transition-colors duration-200
119
+ }`})})]})})}),s6=()=>w.jsx("blockquote",{className:"p-4 text-gray-700 bg-gray-100 rounded-md",children:w.jsxs("ul",{children:[w.jsxs("li",{className:"text-xs",children:["Method: GET ",w.jsx("br",{}),"URL format:"," ",w.jsx("code",{children:"https://example.com/validation/{documentId}"})]}),w.jsxs("li",{className:"text-xs",children:[w.jsx("span",{className:"block mb-1",children:" Response example format:"}),w.jsx("pre",{className:"p-2 bg-white rounded-md",children:w.jsxs("code",{children:["{ ",w.jsx("br",{}),'  "data": { ',w.jsx("br",{}),'    "status": true, ',w.jsx("br",{}),'    "isSigned": true ',w.jsx("br",{}),"  } ",w.jsx("br",{}),"}"]})})]})]})}),l6=Ra().shape({inputLabel:qe().nullable(),placeholder:qe().nullable(),description:qe().nullable(),isReadOnly:Wl(),isDisabled:Wl(),isRequired:Wl(),requiredMessage:qe().nullable(),minLengthMessage:qe().nullable(),maxLengthMessage:qe().nullable(),maxLength:La().typeError("Expecting a number").nullable(),minLength:La().typeError("Expecting a number").nullable(),inputType:qe().nullable(),maxAmountMessage:qe().nullable(),maxAmount:qe().nullable(),options:Zd().of(Ra().shape({label:qe().nullable(),value:qe().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:Zd().of(Ra().shape({label:qe().nullable(),value:qe().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:qe().nullable(),url:qe().nullable(),method:qe().nullable(),denominators:Ia().nullable(),responseType:qe().nullable(),minAmount:qe().nullable(),heading:qe().nullable(),minAmountMessage:qe().nullable(),columns:La().nullable(),value:Ia().nullable(),customClass:qe().nullable(),elementClass:qe().nullable(),apiUrl:qe().nullable(),selectType:qe().default("list"),dateType:qe().default("basic"),validationUrl:qe(),signatureLink:qe()}),c6=[{title:"Configurations",key:"basic"},{title:"Validations",key:"validation"}],u6=({isOpen:e,onClose:n,element:t})=>{const r=c6.filter(U=>!Gl.includes(t.inputType)||U.key!=="validation"),{updateElement:i}=g.useContext(nr),[a,o]=g.useState("basic"),[s,l]=g.useState(!1),[c,u]=g.useState("manual"),d=Yn("config"),{register:f,handleSubmit:m,control:h,setValue:p,watch:v,trigger:b,formState:{errors:y,isSubmitting:x,isValid:A},reset:D}=Wd({resolver:Kd(l6),defaultValues:{...t,options:t.options||[]}}),T=v(),{fields:k,append:E,remove:_}=jd({control:h,name:"options"}),{fields:C,append:M,remove:F}=jd({control:h,name:"options1"}),{fields:V,append:G,remove:X}=jd({control:h,name:"dataColumns"});g.useEffect(()=>{e||D()},[e,D]);const te=U=>{i(U,t.sectionId),n()},re={headers:{Authorization:`Bearer ${Yn("token")}`}},W=g.useCallback(async()=>{var U,q,le;if(!T.apiUrl||!/^https?:\/\//.test(T.apiUrl)){Qe.info("Please provide a valid API URL");return}try{l(!0);const{status:ie,data:se}=await xt.get(T.apiUrl,re);if(ie!==200||!se){Qe.error("Unexpected response from server.");return}const ue=se.data||se.record||se.result;if(!Array.isArray(ue)){Qe.error("Expected an array in response (data, record, or result).");return}((U=t.type)==null?void 0:U.toLowerCase())==="datagrid"?p("dataColumns",ue):p("options",ue)}catch(ie){const se=((le=(q=ie==null?void 0:ie.response)==null?void 0:q.data)==null?void 0:le.message)||(ie==null?void 0:ie.message)||"Unable to load options";Qe.error(se)}finally{l(!1)}},[t.type,p,T.apiUrl]),me=["manual","api","sheet"];function de(){c==="api"&&W()}const I=()=>w.jsxs("div",{className:"flex flex-col justify-start gap-y-1",children:[w.jsx("div",{className:"flex items-center mb-4 gap-x-5",children:me.map(U=>w.jsxs("label",{className:"items-center text-base capitalize gap-x-3",children:[w.jsx("input",{type:"radio",name:"optionType",onChange:q=>u(q.target.value),value:U})," ",w.jsxs("span",{children:[U," options"]})]},U))}),c==="api"&&w.jsxs("div",{className:"mb-4",children:[w.jsxs("div",{className:"flex items-center gap-x-2",children:[w.jsxs("div",{className:"relative flex items-center w-full mb-2",children:[w.jsx(Ye,{label:"Load Options from Api",name:"apiUrl",errors:y,register:f,className:"!w-full",placeholder:"https://example.com/options",isFloating:!0}),s&&w.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"})]}),w.jsx("button",{onClick:de,className:"px-3 py-1 text-xs text-white bg-gray-600 rounded",type:"button",children:"Load"})]}),w.jsx(Q4,{})]}),c==="sheet"&&w.jsx("div",{className:"mb-4",children:w.jsx(B1,{isFloating:!0,label:"Load options form sheet (csv, xlsx)",setValue:p,name:"options"})}),w.jsxs("div",{children:[w.jsx("h3",{className:"mb-4 text-sm text-gray-500",children:"Parent Options "}),k.map((U,q)=>w.jsxs("div",{className:"flex items-center mb-1 gap-x-4 last:mb-0",children:[w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Label",name:`options.${q}.label`,register:f,errors:y,element:t,placeholder:"Label",isFloating:!0})}),w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Value",name:`options.${q}.value`,register:f,errors:y,element:t,placeholder:"Value",isFloating:!0})}),w.jsx("button",{disabled:k.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>_(q),children:w.jsx(ut,{icon:"iconamoon:sign-times-fill"})})]},U.id))," ",w.jsxs("div",{children:[" ",w.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>E({label:"",value:"",id:gn()}),children:[w.jsx(ut,{icon:"qlementine-icons:plus-16"})," Add Option"]})]})]}),t.type.toLowerCase()==="cascadeselect"&&w.jsxs(w.Fragment,{children:[w.jsx("hr",{className:"my-5"}),w.jsxs("div",{children:[" ",w.jsx("h3",{className:"mb-4 text-sm text-gray-500",children:"Child Options "}),C==null?void 0:C.map((U,q)=>w.jsxs("div",{className:"flex items-center mb-1 gap-x-4 last:mb-0",children:[w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Label",name:`options1.${q}.label`,register:f,errors:y,element:t,placeholder:"Label",isFloating:!0})}),w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Value",name:`options1.${q}.value`,register:f,errors:y,element:t,placeholder:"Value",isFloating:!0})}),w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Key",name:`options1.${q}.key`,register:f,errors:y,element:t,placeholder:"Key",isFloating:!0})}),w.jsx("button",{disabled:C.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>F(q),children:w.jsx(ut,{icon:"iconamoon:sign-times-fill"})})]},U.id)),w.jsxs("div",{children:[" ",w.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>M({label:"",value:"",key:"",id:gn()}),children:[w.jsx(ut,{icon:"qlementine-icons:plus-16"})," Add Option"]})]})]})]})]}),L=()=>w.jsxs("div",{className:"flex flex-col justify-start gap-y-1",children:[w.jsx("div",{className:"flex items-center mb-4 gap-x-5",children:me.map(U=>w.jsxs("label",{className:"items-center text-base capitalize gap-x-3",children:[w.jsx("input",{type:"radio",name:"optionType",onChange:q=>u(q.target.value),value:U,checked:U===c})," ",w.jsxs("span",{children:[U," options"]})]},U))}),c==="api"&&w.jsxs("div",{className:"mb-4",children:[w.jsxs("div",{className:"flex items-center gap-x-2",children:[w.jsxs("div",{className:"relative flex items-center w-full mb-2",children:[w.jsx(Ye,{label:"Load Columns from Api",name:"apiUrl",errors:y,register:f,className:"!w-full",placeholder:"https://example.com/columns",isFloating:!0}),s&&w.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"})]})," ",w.jsx("button",{onClick:de,className:"px-3 py-1 text-xs text-white bg-gray-600 rounded",type:"button",children:"Load"})]}),w.jsx(a6,{})]}),c==="sheet"&&w.jsx("div",{className:"mb-4",children:w.jsx(B1,{isFloating:!0,label:"Load columns form sheet (csv, xlsx)",setValue:p,name:"dataColumns"})}),V.map((U,q)=>w.jsxs("div",{className:"flex items-center gap-x-4 ",children:[w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Field key",name:`dataColumns.${q}.field`,register:f,errors:y,element:t,placeholder:"Field",isFloating:!0})}),w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Header Name",name:`dataColumns.${q}.headerName`,register:f,errors:y,element:t,placeholder:"headerName",isFloating:!0})}),w.jsx("button",{disabled:V.length===1,type:"button",className:"outline-none hover:opacity-80 disabled:opacity-40 disabled:cursor-not-allowed",onClick:()=>X(q),children:w.jsx(ut,{icon:"iconamoon:sign-times-fill"})})]},U.id)),w.jsxs("div",{children:[" ",w.jsxs("button",{type:"button",className:"flex items-center mt-2 text-sm font-medium text-gray-700 gap-x-1",onClick:()=>G({headerName:"",field:"",editable:!0,id:gn()}),children:[w.jsx(ut,{icon:"qlementine-icons:plus-16"})," Add column"]})]})]}),K=g.useCallback(async()=>{const U=Yn("token"),{status:q,data:le}=await xt.get(T.url,{headers:{Authorization:`Bearer ${U}`}});q===200&&(console.log({data:le}),p("options",(le==null?void 0:le.data)||le))},[p,T.url]);return g.useEffect(()=>{t.type==="document"&&T.url&&K()},[T.url,t.type,K]),w.jsx("div",{className:"fixed inset-0 bg-black/30 flex items-center justify-center z-[999] cursor-default select-none ",draggable:"true",onDragStart:U=>U.preventDefault(),children:w.jsxs("div",{className:"min-w-[600px] bg-white rounded-xl shadow-xl relative flex flex-col pb-4 items-center max-h-[80vh] overflow-y-auto no-scrollbar select-",draggable:"true",onDragStart:U=>U.preventDefault(),children:[w.jsx("div",{className:"z-10 flex flex-col items-start w-full gap-4 px-6 pt-4 pb-5 mb-3",children:w.jsx("button",{onClick:n,type:"button","aria-label":"close",className:"absolute right-4 top-4 p-2 text-[#98A2B3] hover:bg-gray-50 rounded-lg",children:w.jsx(ut,{icon:"tabler:x"})})}),w.jsx("div",{className:"w-full",children:w.jsx(v3,{tabs:r,setActiveTab:o,activeTab:a,className:"justify-start !text-left",btnClass:" !text-left"})}),w.jsxs("form",{onSubmit:m(te),className:"w-full",children:[w.jsxs("div",{className:" max-h-[800px] overflow-y-auto",children:[a==="basic"&&w.jsxs("div",{className:"z-10 flex flex-col w-full gap-5 px-6",children:[ef.includes(t.inputType)&&w.jsx(w.Fragment,{children:w.jsx(Ye,{label:"Value",name:"value",register:f,errors:y,element:t})}),!ef.includes(t.inputType)&&!Gl.includes(t.inputType)&&w.jsxs(w.Fragment,{children:[w.jsx(Ye,{label:"Label",name:"inputLabel",register:f,errors:y,element:t})," ",t.type.toLowerCase()==="cascadeselect"&&w.jsx(Ye,{label:"Child Label",name:"childLabel",register:f,errors:y,element:t})]}),_3.includes(t.inputType)&&w.jsx(Ye,{label:"Placeholder",name:"placeholder",register:f,errors:y,element:t}),y3.includes(t.inputType)&&w.jsx(Ye,{label:"Prefix",name:"prefix",register:f,errors:y,element:t}),S3.includes(t.inputType)&&w.jsxs("div",{className:"grid gap-y-4",children:[w.jsx(D3,{}),w.jsx(Ye,{label:"Api Url",name:"url",register:f,errors:y,element:t}),w.jsx(Fa,{label:"Api Method",options:[{label:"GET",value:"GET"},{label:"POST",value:"POST"}],register:f,name:"method",setValue:p,trigger:b,value:v("method")}),w.jsx(Fa,{label:"Api Response type",options:[{label:"String",value:"string"},{label:"Object",value:"object"}],register:f,name:"responseType",setValue:p,trigger:b,value:v("responseType")})]}),T3.includes(t.inputType)&&w.jsx(C3,{onChange:U=>{p("denominators",U)},value:v("denominators")}),!ef.includes(t.inputType)&&!Gl.includes(t.inputType)&&w.jsx(Ye,{label:"Short Description",name:"description",register:f,errors:y,element:t}),t.type.toLowerCase()==="date"&&w.jsxs(w.Fragment,{children:[w.jsx(Fa,{label:"Date Type",options:[{label:"Basic",value:"basic"},{label:"Custom",value:"custom"}],register:f,name:"dateType",setValue:p,trigger:b,value:v("dateType")}),v("dateType")==="custom"&&w.jsx(Fa,{label:"Date Format",options:A3,register:f,name:"dateFormat",setValue:p,trigger:b,value:v("dateFormat")})]}),t.type.toLowerCase()==="selectfield"&&w.jsx(Fa,{label:"Select Type",options:[{label:"List",value:"list"},{label:"Combobox",value:"Combobox"}],register:f,name:"selectType",setValue:p,trigger:b,value:v("selectType")}),t.type.toLowerCase()==="grid"&&w.jsx(Ye,{label:"Number of columns",name:"columns",register:f,errors:y,element:t}),t.type.toLowerCase()==="document"&&w.jsxs("div",{className:"grid gap-y-6",children:[w.jsxs("div",{className:"grid gap-y-1",children:[w.jsx(Ye,{label:"Document Options Url",name:"url",register:f,errors:y,element:t})," ",w.jsx(o6,{})]}),w.jsxs("div",{className:"grid gap-y-1",children:[w.jsx(Ye,{label:"Document Validation Url",name:"validationUrl",register:f,errors:y,element:t}),w.jsx(s6,{})]}),w.jsx("div",{className:"grid gap-y-1",children:w.jsx(Ye,{label:"Signature Page Url",name:"signatureLink",register:f,errors:y,element:t})})]}),t.type.toLowerCase()==="datagrid"&&L(),E3.includes(t.inputType)&&I()]}),!Gl.includes(t.type.toLowerCase())&&a==="validation"&&w.jsxs("div",{className:"z-10 flex flex-col w-full gap-5 px-6",children:[w.jsxs("div",{className:"flex items-center gap-x-6",children:[w.jsx("div",{className:"w-[150px]",children:w.jsx(Ye,{label:"Required",name:"isRequired",register:f,errors:y,element:t,type:"checkbox"})})," ",w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Error message text",name:"requiredMessage",register:f,errors:y,element:t})})]}),w3.includes(t.inputType)&&w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"flex items-center gap-x-6",children:[w.jsx("div",{className:"w-[150px]",children:w.jsx(Ye,{label:"Min Length",name:"minLength",register:f,errors:y,element:t,type:"number"})})," ",w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Error message text",name:"minLengthMessage",register:f,errors:y,element:t})})]}),w.jsxs("div",{className:"flex items-center gap-x-6",children:[w.jsx("div",{className:"w-[150px]",children:w.jsx(Ye,{label:"Max Length",name:"maxLength",register:f,errors:y,element:t,type:"number"})})," ",w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Error message text",name:"maxLengthMessage",register:f,errors:y,element:t})})]})]}),k3.includes(t.inputType)&&w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"flex items-center gap-x-6",children:[w.jsx("div",{className:"w-[150px]",children:w.jsx(Ye,{label:"Min Amount",name:"minAmount",register:f,errors:y,element:t,type:"amount"})})," ",w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Error message text",name:"minAmountMessage",register:f,errors:y,element:t})})]}),w.jsxs("div",{className:"flex items-center gap-x-6",children:[w.jsx("div",{className:"w-[150px]",children:w.jsx(Ye,{label:"Max Amount",name:"maxAmount",register:f,errors:y,element:t,type:"amount"})})," ",w.jsx("div",{className:"flex-1",children:w.jsx(Ye,{label:"Error message text",name:"maxAmountMessage",register:f,errors:y,element:t})})]})]})]})]}),w.jsxs("div",{className:"flex w-full gap-3 px-6 pt-8 pb-6 mt-4",children:[w.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"}),w.jsx("button",{type:"submit",disabled:!A||x,style:{background:(d==null?void 0:d.buttonColor)||"#333"},className:`flex-1 px-4 py-2.5 ${!A||x?"bg-[#F2F4F7]":"bg-[#2563EB]"} ${!A||x?"text-[#98A2B3]":"text-white"} rounded-lg shadow-xs font-semibold font-onest disabled:opacity-50 editor_option__save`,children:x?"Saving...":"Save"})]})]})]})})},c0=g.memo(({state:e,element:n,children:t})=>{const[r,i]=g.useState(!1),{removeElement:a}=g.useContext(nr),o=g.useCallback(()=>{a(n.id,n.sectionId)},[n.id,n.sectionId,a]);return w.jsxs("div",{className:"w-full",children:[r&&w.jsx(u6,{isOpen:r,onClose:()=>i(!1),element:n}),w.jsxs("div",{className:"flex justify-between items-center mb-2",children:[w.jsxs("span",{children:[" ",n.inputLabel&&w.jsx("label",{className:"text-sm font-medium",children:n.inputLabel})]}),e==="edit"&&w.jsxs("span",{className:"flex gap-x-3 items-center",children:[w.jsx("button",{type:"button",className:"outline-none hover:opacity-80 text-sm",onClick:()=>i(!0),children:w.jsx(ut,{icon:"circum:edit"})}),w.jsx("button",{type:"button",className:"outline-none hover:opacity-80 text-sm",onClick:o,children:w.jsx(ut,{icon:"iconamoon:sign-times-fill"})})]})]}),t]})});c0.displayName="ElementContainer";function d6(e){if(!e)return!1;const n=/^data:image\/(jpeg|png|gif|bmp|webp);base64,/i,t=/\.(jpeg|jpg|png|gif|bmp|webp)$/i;return n.test(e)||t.test(e)}const f6=({imageUrl:e})=>{const[n,t]=g.useState(!1),r=()=>{t(!0)},i=()=>{t(!1)};return w.jsxs("div",{children:[w.jsx("img",{alt:"Thumbnail",style:{cursor:"pointer",width:"120px",height:"130px",objectFit:"cover"},onClick:r,src:e||"/place.png","data-toggle":"tooltip","data-placement":"top",title:"Click to view"}),n&&w.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:i,children:w.jsxs("div",{className:"modal-content",style:{position:"relative",backgroundColor:"white",padding:"20px",borderRadius:"8px",width:"90vw"},onClick:a=>a.stopPropagation(),children:[w.jsx("span",{className:"close",onClick:i,style:{position:"absolute",top:"10px",right:"10px",fontSize:"24px",cursor:"pointer"},children:"×"}),w.jsx("img",{src:e||"/place.png",alt:"Full Image",style:{maxWidth:"90%",maxHeight:"90vh",objectFit:"contain"}})]})})]})};function m6({element:e,validationData:n}){const{register:t=()=>({}),setValue:r,watch:i}=n||{},[a,o]=g.useState(),[s,l]=g.useState(!1),[c,u]=g.useState(!1),[d,f]=g.useState(""),m=i&&i(e==null?void 0:e.id);g.useEffect(()=>{o(m)},[m]);const[h,p]=g.useState("");g.useEffect(()=>{t(e.id)},[e.id,t]);const{url:v,method:b,responseType:y}=e||{},A={headers:{Authorization:`Bearer ${Yn("token")}`}},D=g.useCallback(async T=>{var k,E,_,C,M,F,V,G,X,te,z;if(!(!v||!b)){l(!0);try{let re;if(b.toLowerCase()==="get"){const W=`${v}?value=${T}`;re=await xt.get(W,A)}else if(b.toLowerCase()==="post")re=await xt.post(v,{value:T},A);else throw new Error("Unsupported HTTP method");re.status===200&&((((E=(k=re==null?void 0:re.data)==null?void 0:k.data)==null?void 0:E.status)||((_=re==null?void 0:re.data)==null?void 0:_.status))===!0?(u(!0),y==="string"?f(((M=(C=re==null?void 0:re.data)==null?void 0:C.data)==null?void 0:M.description)||((F=re==null?void 0:re.data)==null?void 0:F.description)||"Validation successful"):p(((G=(V=re==null?void 0:re.data)==null?void 0:V.data)==null?void 0:G.description)||((X=re==null?void 0:re.data)==null?void 0:X.description)||{})):(console.error("Invalid input:",T),f("Unable to validate input"),u(!1)))}catch(re){console.error("Error validating input:",re),f(((z=(te=re==null?void 0:re.response)==null?void 0:te.data)==null?void 0:z.message)||"Unable to validate input"),u(!1)}finally{l(!1)}}},[b,y,v]);return g.useEffect(()=>{if(a){const T=setTimeout(()=>{D(a)},700);return()=>clearTimeout(T)}},[D,a]),w.jsxs("div",{children:[w.jsxs("div",{className:"relative flex items-center",children:[w.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"",type:(e==null?void 0:e.inputType)||"text",className:Ie("field-control",e==null?void 0:e.customClass),...t(e==null?void 0:e.id),onChange:T=>{o(T.target.value),r(e==null?void 0:e.id,T.target.value)},disabled:n==null?void 0:n.isReadOnly}),w.jsxs("span",{className:"absolute right-0",children:[s&&w.jsxs("span",{children:[" ",w.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:[w.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),w.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&&!s&&w.jsx("span",{className:"block pr-3 text-lg text-green-600",children:w.jsx(ut,{icon:"gg:check-o"})})]})]}),d&&y==="string"&&w.jsx("span",{className:`${c?"text-green-600":"text-red-600"} text-sm`,children:d}),y==="object"&&w.jsx("div",{className:"grid grid-cols-2 gap-6 mt-2 text-sm text-gray-600",children:Object.entries(h).map(([T,k])=>w.jsxs("div",{className:"flex items-center gap-x-2",children:[w.jsxs("span",{className:"font-semibold",children:[T,":"]}),d6(k)?w.jsx(f6,{imageUrl:k}):w.jsx("span",{children:String(k)})]},T))})]})}function h6({onGetTotal:e,readOnly:n,defaultValue:t,denominators:r}){const[i,a]=g.useState([...t]);function o(c,u){a(d=>{const f=[...d];return f[u]={...f[u],value:c},f})}function s(c,u){return parseFloat(c)*parseFloat(u)||0}const l=g.useMemo(()=>i.reduce((c,u)=>{const d=s(u.key,u.value);return c+d},0),[i]);return g.useEffect(()=>{e&&e(i)},[i]),g.useEffect(()=>{if(r!=null&&r.length){const c=r.map((u,d)=>({key:u.value,value:Array.isArray(t)&&t[d]?t[d].value:""}));a(c)}},[t,r]),w.jsx("div",{className:"mt-2",children:w.jsxs("div",{className:"border border-gray-200 rounded-lg overflow-hidden text-gray-700",children:[w.jsxs("div",{className:"grid grid-cols-3 text-sm font-bold border-b border-gray-100 bg-gray-50",children:[w.jsx("div",{className:"border-r px-4 py-2",children:w.jsx("span",{className:"",children:"Denomination"})}),w.jsx("div",{className:"border-r px-4 py-2",children:w.jsx("span",{children:"Quantity"})}),w.jsx("div",{className:"px-4 py-2",children:w.jsx("span",{children:"Sub total"})})]}),i.map((c,u)=>{var d,f;return w.jsxs("div",{className:"grid grid-cols-3 text-sm border-b border-gray-100",children:[w.jsx("div",{className:"border-r px-4 py-2 flex items-center",children:w.jsx("span",{className:"",children:(d=parseFloat(c.key))==null?void 0:d.toLocaleString()})}),w.jsx("div",{className:"border-r px-4 py-1",children:w.jsx("span",{children:w.jsx(Ro,{id:"input-example",className:"border border-gray-100 rounded w-full px-3 py-1 outline-none",decimalsLimit:6,value:c.value,onValueChange:m=>o(m,u),disabled:n,allowNegativeValue:!1})})}),w.jsx("div",{className:"px-4 py-2 flex justify-between items-center",children:w.jsx("span",{children:(f=s(c.key,c.value))==null?void 0:f.toLocaleString()})})]},u+"index")}),w.jsxs("div",{className:"grid grid-cols-3 text-sm font-bold bg-gray-50",children:[w.jsx("div",{className:"border-r px-4 py-3 col-span-2 text-right",children:"Total"}),w.jsx("div",{className:"px-4 py-3",children:l==null?void 0:l.toLocaleString()})]})]})})}function p6({element:e,validationData:n}){const{register:t=()=>({}),setValue:r,getValues:i}=n||{},a=i&&i(e==null?void 0:e.id)||[];return g.useEffect(()=>{t(e.id)},[e.id,t]),w.jsx("div",{children:w.jsx(h6,{onGetTotal:o=>{r&&r(e.id,o)},denominators:(e==null?void 0:e.denominators)||[],defaultValue:a,readOnly:e==null?void 0:e.isReadOnly})})}function v6({element:e}){return w.jsx("div",{className:Ie("py-6",e==null?void 0:e.customClass)})}function b6({element:e}){return w.jsx("div",{children:w.jsx("hr",{className:Ie("border-gray-200 my-4",e==null?void 0:e.customClass)})})}function g6({element:e,validationData:n}){const{register:t=()=>({})}=n||{};return w.jsx("div",{children:w.jsx("input",{placeholder:"Enter text",type:"text",className:"field-control",...t(e==null?void 0:e.id)})})}function x6({element:e,state:n}){return w.jsx(w.Fragment,{children:w.jsx("div",{className:e==null?void 0:e.customClass,children:(e==null?void 0:e.value)||n==="edit"&&w.jsx("span",{className:"text-gray-400",children:"Provide text"})})})}function y6({value:e=[],onChange:n,isReadOnly:t,columns:r=[]}){const[i,a]=g.useState(e),[o,s]=g.useState(null);g.useEffect(()=>{a(e)},[]);const l=(f,m,h)=>{const p=i.map((v,b)=>b===m?{...v,[h]:f}:v);a(p),n&&n(p)},c=()=>{const f=i.length>0?Math.max(...i.map(p=>Number(p.id)||0))+1:1,m=r.reduce((p,v)=>({...p,[v.field]:v.field==="id"?f:""}),{}),h=[...i,m];a(h),n&&n(h)},u=f=>{const m=i.filter((h,p)=>p!==f);a(m),n&&n(m)},d=(f,m)=>(o==null?void 0:o.rowIndex)===f&&(o==null?void 0:o.field)===m;return w.jsxs("div",{className:"mt-4 rounded",children:[w.jsx("div",{className:"flex justify-end",children:(r==null?void 0:r.length)>0&&!t&&w.jsx("button",{onClick:c,type:"button",className:"px-2 py-1 mb-3 text-xs text-white bg-gray-600 rounded hover:bg-gray-700",children:"Add Row"})}),w.jsxs("table",{className:"w-full text-sm border-collapse rounded table-auto bg-gray-50",children:[w.jsx("thead",{children:w.jsxs("tr",{className:"bg-gray-100",children:[r.map(f=>w.jsx("th",{className:"px-3 py-2 text-xs font-semibold text-left text-gray-600 border",children:f.headerName||f.field},f.field)),!t&&w.jsx("th",{className:"w-10 px-2 py-2 border"})]})}),w.jsx("tbody",{children:i.length>0?i.map((f,m)=>w.jsxs("tr",{children:[r.map(h=>w.jsx("td",{className:"px-2 py-1 border",onDoubleClick:()=>h.editable&&!t&&s({rowIndex:m,field:h.field}),children:h.editable&&d(m,h.field)&&!t?w.jsx(w.Fragment,{children:h.type==="number"?w.jsx(Ro,{value:f[h.field]??"",onValueChange:p=>l(p,m,h.field),decimalsLimit:6,allowNegativeValue:!1,placeholder:"",className:"w-full px-2 py-1 border rounded outline-none"}):w.jsx("input",{autoFocus:!0,type:"text",value:f[h.field]??"",onChange:p=>l(p.target.value,m,h.field),onBlur:()=>s(null),className:"w-full px-2 py-1 text-gray-600 border rounded outline-none"})}):w.jsx("span",{className:"block py-1 text-gray-700 cursor-pointer",children:f[h.field]})},h.field)),!t&&w.jsx("td",{className:"px-2 py-1 text-center border",children:w.jsx("button",{onClick:()=>u(m),className:"text-red-500 hover:text-red-700","aria-label":"Delete row",children:w.jsx(ut,{icon:"lets-icons:trash-duotone",iconClass:"text-xl"})})})]},f.id??m)):w.jsx("tr",{children:w.jsx("td",{colSpan:r.length+(t?0:1),className:"p-2 text-xs text-center text-gray-400",children:"No data available"})})})]})]})}function w6({element:e,validationData:n}){const{register:t=()=>({}),setValue:r,watch:i}=n||{},a=i&&i(e==null?void 0:e.id)||[];return g.useEffect(()=>{t(e.id)},[e.id,t]),console.log(e),w.jsx(y6,{value:a,onChange:o=>{r(e.id,o)},columns:e==null?void 0:e.dataColumns,isReadOnly:e==null?void 0:e.isReadOnly})}const j1=({className:e="",options:n=[],placeholder:t="Select",errors:r,register:i,setValue:a,name:o,label:s,value:l,trigger:c,isMultiple:u=!1,isFloatingLabel:d=!1,subText:f,labelClass:m="text-[10px]",loading:h,disabled:p})=>{const[v,b]=g.useState(u?[]:null),y=Ie("field-control",e),x=g.useMemo(()=>n,[n]);g.useEffect(()=>{const D=n==null?void 0:n.find(T=>typeof T.value=="string"&&typeof l=="string"?T.value.toLowerCase()===l.toLowerCase():typeof T.value=="object"&&typeof l=="object"?T.value.id===(l==null?void 0:l.id):T.value===l);b(D||null)},[l,n]),g.useEffect(()=>{v&&a&&i&&(a(o,v==null?void 0:v.value),i(o),c==null||c(o))},[o,v]);const A=D=>b(D);return w.jsxs("div",{className:"relative",children:[s&&!d&&w.jsx("label",{className:"block text-sm text-[#686878] darks:!text-white/70 mb-2",children:s}),d&&s&&w.jsx("label",{className:`z-[40] absolute block text-[#667085] bg-white py-[2px] px-1 -top-[10px] left-3 ${m}`,children:s}),w.jsx(Gn,{value:v,onChange:A,multiple:u,disabled:p,children:w.jsxs("div",{className:"relative",children:[w.jsxs(Gn.Button,{className:y,disabled:p,children:[h?w.jsx("span",{className:"block text-sm text-left opacity-60",children:"Fetching data..."}):w.jsx("span",{className:"block text-sm text-left truncate",children:(v==null?void 0:v.label)||w.jsx("span",{className:"opacity-60",children:t})}),w.jsx("span",{className:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none",children:w.jsx(ut,{icon:"lucide:chevron-down"})})]}),w.jsx(ad,{as:g.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:w.jsx(Gn.Options,{className:"z-[77] absolute mt-1 max-h-60 w-full overflow-auto rounded-md bg-white darks:bg-gray-800 text-gray-900 darks:text-white/80 py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm",children:x==null?void 0:x.map((D,T)=>w.jsx(Gn.Option,{className:({active:k})=>Ie("relative cursor-default select-none py-2 pl-4 pr-4 text-sm",k?"bg-gray-100 darks:bg-gray-700 text-gray-900 darks:text-white/80":"text-gray-900 darks:text-white/70"),value:D,children:({selected:k})=>w.jsx("div",{className:`block truncate text-sm ${k?"font-medium":"font-normal"}`,children:D.label})},T))})})]})}),f&&!r&&w.jsx("p",{className:"text-[10px] text-[#98A2B3] leading-normal mt-[6px]",children:f}),r&&w.jsx("span",{className:"text-sm text-red-500",children:r.message})]})},_6=({element:e,validationData:n})=>{const{register:t=()=>({}),trigger:r,setValue:i,watch:a,isReadOnly:o}=n||{},s=(e==null?void 0:e.id)??"cascadeValue",[l,c]=g.useState(""),[u,d]=g.useState(""),f=(p,v)=>{const b=p&&v?`${p}_${v}`:"";i==null||i(s,b),r==null||r(s)},m=(p,v)=>{p==="first"?(c(v),d(""),f(v,"")):(d(v),f(l,v))};g.useEffect(()=>{if(a){const p=a(s);if(p!=null&&p.includes("_")){const[v,b]=p.split("_");c(v),d(b)}}},[a,s]);const h=g.useMemo(()=>{var p;return(p=e.options1)==null?void 0:p.filter(v=>v.key===l)},[e.options1,l]);return!e.options||!e.options1?null:w.jsxs("div",{children:[w.jsx("input",{type:"hidden",...t(s)}),w.jsx("div",{className:"relative",children:w.jsx(j1,{setValue:(p,v)=>m("first",v),options:e.options,name:`${s}`,register:t,value:l})}),l&&w.jsxs("div",{className:"mt-4",children:[(e==null?void 0:e.childLabel)&&w.jsx("label",{className:"block text-sm text-[#686878] darks:!text-white/70 mb-2",children:e==null?void 0:e.childLabel}),w.jsx(j1,{setValue:(p,v)=>m("second",v),options:h,name:`${s}`,register:t,value:u})]})]})},k6=({value:e=0,max:n=5,readOnly:t=!1,onChange:r,size:i=24,className:a="",element:o,validationData:s})=>{const{register:l=()=>({}),trigger:c,setValue:u,watch:d,isReadOnly:f}=s||{},m=(d==null?void 0:d(o.id))??0,[h,p]=g.useState(null);g.useEffect(()=>{m==null&&(u==null||u(o.id,e))},[]);const v=b=>{if(!t&&!f){const y=b+1;u==null||u(o.id,y),c==null||c(o.id),r==null||r(y)}};return w.jsxs("div",{className:`flex gap-1 ${a}`,children:[w.jsx("input",{type:"hidden",...l(o.id)}),Array.from({length:n},(b,y)=>{const x=h!==null?y<=h:y<m;return w.jsx(kv,{icon:x?"mdi:star":"mdi:star-outline",className:`cursor-pointer transition-colors ${x?"text-yellow-400":"text-gray-300"}`,width:i,height:i,onMouseEnter:()=>!(t||f)&&p(y),onMouseLeave:()=>!(t||f)&&p(null),onClick:()=>v(y)},y)})]})};function U1({element:e,validationData:n}){const{register:t=()=>({}),setValue:r,trigger:i,isReadOnly:a,watch:o}=n||{};let s;const l=(c,u)=>{r==null||r(c,u==null?void 0:u.value),i==null||i(c)};return o&&(s=o()[e.id]),w.jsxs("div",{children:[w.jsx("input",{type:"hidden",...t(e.id)}),w.jsx(Av,{options:e.options,onGetValue:l,name:e.id,readOnly:a,defaultValue:s})]})}function E6({element:e,validationData:n}){const{register:t=()=>({}),isReadOnly:r}=n||{},{validationUrl:i,documentObj:a,signatureLink:o}=e,s=g.useMemo(()=>Yn("config"),[]),[l,c]=g.useState(!1),[u,d]=g.useState(!1),f=g.useCallback(async()=>{var m;if(!(!i||!a))try{d(!0);const p={headers:{Authorization:`Bearer ${Yn("token")}`}},{data:v}=await xt.get(`${i}/${a}`,p),b=!!(((m=v==null?void 0:v.data)==null?void 0:m.isSigned)??(v==null?void 0:v.isSigned));return c(b),b}catch(h){console.error("Failed to check sign status",h)}finally{d(!1)}},[i,a]);return g.useEffect(()=>{let m=null;return!l&&a&&i&&(async()=>{await f()||(m=setInterval(async()=>{await f()&&m&&clearInterval(m)},2e3))})(),()=>{m&&clearInterval(m)}},[f,l,a,i]),w.jsxs("div",{className:"flex items-center gap-x-2",children:[w.jsx("input",{placeholder:e.placeholder,type:e.inputType,className:Ie("field-control",e.customClass),...t(e.id),disabled:r}),w.jsx("a",{href:l?"#":o,children:w.jsxs("button",{type:"button",onClick:f,disabled:u||l,style:{background:(s==null?void 0:s.buttonColor)||"#333"},className:Ie("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:[w.jsx(ut,{icon:u?"solar:refresh-outline":l?"solar:check-circle-bold":"solar:pen-2-line-duotone",iconClass:u?"animate-spin":""}),u?"Checking...":l?"Signed":"Sign"]})})]})}const S6=[{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 T6({label:e,placeholder:n,classLabel:t,isRequired:r,isOptional:i,name:a,value:o,error:s,disabled:l,readOnly:c,horizontal:u,description:d,validate:f,onChange:m,onError:h}){const[p,v]=g.useState(""),[b,y]=g.useState(null),[x,A]=g.useState(""),D=g.useMemo(()=>S6.map(F=>({...F,phone:`+${F.phone}`})),[]),T=g.useMemo(()=>p?D.filter(F=>`${F.label} ${F.phone}`.toLowerCase().includes(p.toLowerCase())):D,[p,D]),k=(b==null?void 0:b.min)||10,E=(b==null?void 0:b.max)||10,_=()=>x?`${(b==null?void 0:b.phone)||"+234"}-${x}`:"",C=F=>{if(!F)return{code:"+234",number:""};const V=F.split(/[-\s]/);return{code:V[0],number:V.slice(1).join(" ")}};g.useEffect(()=>{if(o){const F=C(o);y(D.find(V=>V.phone===F.code)||D[0]),A(F.number)}},[o,D]);const M=g.useMemo(()=>{if(s)return s;const F=x.length;return r&&F===0?"Phone number is required":F>0&&F<k?`Minimum length is ${k}`:F>E?`Maximum length is ${E}`:""},[s,x,k,E,r]);return g.useEffect(()=>{m==null||m(_()),h==null||h(M||null)},[x,b,M]),w.jsxs("div",{className:`relative formGroup ${M?"has-error":""} ${u?"flex":""} ${!M&&x.length>0?"is-valid":""}`,children:[e&&w.jsxs("label",{htmlFor:a,className:`${t} ${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," ",r&&w.jsx("span",{className:"text-red-500",children:"*"}),i&&w.jsx("span",{className:"text-[#98A2B3]",children:"(Optional)"})]}),w.jsxs("div",{className:"relative !flex items-center input-control text-[#667085] !py-0 field-control",children:[w.jsx(ut,{icon:"lucide:phone-call"}),w.jsx(Da,{value:b,onChange:y,children:w.jsxs("div",{className:"relative",children:[w.jsx(Da.Input,{className:"pl-3 pr-4 mr-1 text-sm bg-white border-r py-[10px] outline-none whitespace-nowrap max-w-[70px]",displayValue:F=>(F==null?void 0:F.phone)||"+234",placeholder:"+234",onChange:F=>v(F.target.value)}),w.jsx(Da.Button,{className:"absolute inset-y-0 right-0 flex items-center pr-2",children:w.jsx(ut,{icon:"lucide:chevron-down"})}),w.jsx(Da.Options,{className:"absolute z-10 w-[250px] left-0 bg-white border rounded-md shadow-lg max-h-[400px] overflow-y-auto",children:T.map((F,V)=>w.jsxs(Da.Option,{value:F,className:"px-4 py-2 cursor-pointer hover:bg-gray-100",children:[F.phone," - ",F.label]},`${F.code}+ ${V}`))})]})}),w.jsxs("div",{className:"relative flex items-center flex-1 z-[1]",children:[w.jsx("input",{type:"tel",inputMode:"numeric",value:x,disabled:l,readOnly:c,onChange:F=>A(F.target.value.slice(0,E)),placeholder:n,className:"w-full px-3 outline-none"}),w.jsx("div",{className:"absolute flex text-xl -translate-y-1/2 top-1/2 right-4",children:!M&&x.length>0&&w.jsx("span",{className:"text-green-500",children:w.jsx(ut,{icon:"bi:check-lg"})})})]})]}),M?w.jsx("span",{className:"block mt-1 text-sm text-red-500",children:M}):x.length>0&&f&&w.jsx("span",{className:"block mt-1 text-sm text-green-500",children:f}),d&&w.jsx("span",{className:"block text-[#475467] font-light leading-4 text-xs mt-2",children:d})]})}function A6({element:e,validationData:n}){const{register:t=()=>({}),trigger:r,setValue:i,watch:a,isReadOnly:o}=n||{};let s;return g.useEffect(()=>{t(e.id)},[e.id,t]),a&&(s=a()[e.id]),w.jsx(T6,{placeholder:e.placeholder,label:"",name:e.id,value:s,readOnly:o,disabled:o,onChange:l=>{l&&(i==null||i(e.id,l),r==null||r(e.id))}})}const H1={textField:ml,longText:bD,selectField:vD,multiSelect:$A,numberField:ml,amountField:ml,date:NE,password:eD,checkbox:pD,radio:mD,email:ml,file:ZC,dataGrid:w6,section:hD,validateInput:m6,tableInput:p6,spacer:v6,divider:b6,header:g6,basicText:x6,phoneField:A6,cascadeSelect:_6,rating:k6,country:U1,bank:U1,document:E6},V1="edit",$1=(e,n)=>{const t=H1[e.type];return t?w.jsx(c0,{element:e,state:V1,children:w.jsxs("div",{className:"relative w-full",children:[e.type.toLowerCase()!=="grid"&&w.jsx("div",{className:"absolute top-0 left-0 z-20 w-full h-full"}),w.jsx(t,{element:e,state:V1,sectionId:n})]})}):null},u0=({col:e,children:n,customClass:t})=>w.jsx("div",{className:Ie("w-full bg-white",t),style:{gridColumn:e},children:n}),C6=({element:e,sectionId:n,children:t,customClass:r,state:i})=>{const{formData:a,addElement:o,setIsDragging:s}=g.useContext(nr),l=g.useMemo(()=>Array.from({length:e.columns}),[e.columns]),c=g.useCallback(f=>{f.preventDefault(),f.stopPropagation(),f.dataTransfer.dropEffect="move"},[]),u=g.useCallback((f,m)=>{var h,p;f.preventDefault(),s(!1);try{const v=f.dataTransfer.getData("properties");if(!v)return;const b=JSON.parse(v);if((b==null?void 0:b.type)==="grid")return;const y=m+1;if((p=(h=a.find(D=>D.id===n))==null?void 0:h.questionData)==null?void 0:p.some(D=>{var T;return D.gridId===e.id&&((T=D.gridPosition)==null?void 0:T.col)===y}))return;const A={...b,id:gn(),sectionId:n,gridId:e.id,gridPosition:{col:y}};o(A,n)}catch(v){console.error("Drop failed in grid:",v),s(!1)}},[o,e.id,a,n,s]),d=(f,m,h)=>{const p=Array.isArray(t)&&t.find(v=>{var b;return((b=v==null?void 0:v.props)==null?void 0:b.col)===f+1});return w.jsx("div",{children:w.jsx("div",{id:f.toString(),onDrop:v=>u(v,f),onDragOver:c,className:Ie("border rounded-lg min-h-[110px] bg-white ","flex items-center justify-center text-gray-400 transition-colors",`${h==="edit"?"p-3":""}`,m),children:p||w.jsx("span",{children:h==="edit"&&w.jsx(ut,{icon:"ph:plus-bold"})})})},f)};return w.jsx("div",{className:"relative w-full",children:w.jsx("div",{className:"grid w-full gap-3",style:{gridTemplateColumns:`repeat(${e.columns}, 1fr)`},children:l.map((f,m)=>d(m,r,i))})})},d0=g.memo(C6),D6="edit";function F6({elementData:e,sectionId:n}){const{formData:t,updateElementPosition:r,isDragging:i,setIsDragging:a,addElementInPosition:o}=g.useContext(nr),[s,l]=g.useState(null),[c,u]=g.useState(null),d=g.useMemo(()=>{var x;return((x=t.find(A=>A.id===n))==null?void 0:x.questionData)||[]},[t,n]),f=g.useCallback((x,A)=>{x.dataTransfer.setData("properties",A),l(A)},[]),m=g.useCallback((x,A)=>{x.preventDefault(),x.stopPropagation(),u(A)},[]),h=g.useCallback(x=>{x.preventDefault(),x.stopPropagation();const A=x.dataTransfer.getData("properties"),D=x.currentTarget.id;if(!D||A===D)return;const T=d.findIndex(C=>C.id===A),k=d.findIndex(C=>C.id===D);if(T===-1||k===-1)return;const E=[...d],[_]=E.splice(T,1);E.splice(k,0,_),r(E,n),l(null)},[d,n,r]),p=g.useCallback((x,A)=>{x.preventDefault(),a(!1);try{const D=JSON.parse(x.dataTransfer.getData("properties"));if(console.log({data:D}),(D==null?void 0:D.type)==="section")return;const T={...D,id:gn(),sectionId:n};o(T,n,A)}catch(D){console.error("Drop error:",D)}},[o,n,a]),v=g.useCallback(x=>w.jsx("div",{className:"transition rounded hover:bg-blue-300",onDragOver:A=>A.preventDefault(),onDrop:A=>p(A,x),onDragEnd:()=>a(!1),children:w.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:w.jsx(ut,{icon:"octicon:plus-16"})})},`drop-${x}`),[p,a]),b=g.useCallback(x=>w.jsx("div",{id:x.id,className:Ie("cursor-move border p-4 w-full rounded-lg transition-colors bg-white",{"bg-gray-100":s===x.id,"border-dashed border-blue-300":s&&s!==x.id}),draggable:!0,onDragStart:A=>f(A,x.id),onDragOver:A=>m(A,x.id),onDrop:h,onDragEnd:()=>l(null),children:$1(x,n)},x.id),[s,h,m,n,f]),y=g.useMemo(()=>(e==null?void 0:e.reduce((x,A)=>(A.gridId&&(x[A.gridId]=x[A.gridId]||[],x[A.gridId].push(A)),x),{}))||{},[e]);return e!=null&&e.length?w.jsx("div",{className:"relative grid w-full h-full grid-cols-1 gap-4",children:e.map((x,A)=>{if(x.type==="grid"){const D=y[x.id]||[];return w.jsx("div",{draggable:!0,onDragStart:T=>f(T,x.id),onDragOver:T=>m(T,x.id),onDrop:h,onDragEnd:()=>l(null),className:"w-full p-4 transition-colors bg-white border rounded-lg cursor-move",children:w.jsx(c0,{element:x,state:"edit",children:w.jsx(d0,{element:x,sectionId:n,state:D6,children:D.map(T=>{var k;return w.jsx(u0,{col:(k=T.gridPosition)==null?void 0:k.col,children:$1(T,n)},T.id)})})})},x.id)}return x.gridId?null:w.jsxs("div",{className:Ie("group relative grid gap-y-[6px]",x.elementClass),children:[i&&c===x.id&&v(A),w.jsx("div",{className:"group",children:b(x)}),i&&c===x.id&&v(A+1)]},x.id)})}):w.jsx("div",{onDragOver:x=>x.preventDefault(),onDrop:x=>p(x,0),onDragEnd:()=>a(!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 O6=g.memo(F6),M6=Ra({title:qe(),description:qe()}).required(),f0=Yn("config"),N6=({isOpen:e,onClose:n,section:t})=>{const{updateSection:r}=g.useContext(nr),{register:i,handleSubmit:a,formState:{errors:o,isSubmitting:s,isValid:l},reset:c}=Wd({resolver:Kd(M6),defaultValues:t});if(g.useEffect(()=>{e||c()},[e,c]),!e)return null;const u=d=>{r(d,t.id),n()};return w.jsx("div",{className:"fixed inset-0 bg-black/30 flex items-center justify-center z-[999] cursor-default no-drag select-none",children:w.jsxs("div",{className:"min-w-[600px] bg-white rounded-xl shadow-xl relative flex flex-col items-center",children:[w.jsxs("div",{className:"w-full px-6 pt-6 pb-5 flex flex-col items-start gap-4 z-10 mb-6",children:[w.jsx("h2",{className:"text-lg font-semibold text-[#475467] font-onest",children:"Update Section Information"}),w.jsx("button",{onClick:n,className:"absolute right-4 top-4 p-2 text-[#98A2B3] hover:bg-gray-50 rounded-lg",children:w.jsx(ut,{icon:"tabler:x"})})]}),w.jsxs("form",{onSubmit:a(u),className:"w-full",children:[w.jsxs("div",{className:"w-full px-6 flex flex-col gap-5 z-10",children:[w.jsx(Ye,{label:"Title",name:"title",register:i,errors:o}),w.jsx(Ye,{label:"Description",name:"description",register:i,errors:o})]}),w.jsxs("div",{className:"w-full px-6 pt-8 pb-6 flex gap-3 mt-4",children:[w.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"}),w.jsx("button",{type:"submit",disabled:!l||s,style:{background:(f0==null?void 0:f0.buttonColor)||"#333"},className:`flex-1 px-4 py-2.5 ${!l||s?"bg-[#F2F4F7]":"bg-[#2563EB]"} ${!l||s?"text-[#98A2B3]":"text-white"} rounded-lg shadow-xs font-semibold font-onest disabled:opacity-50`,children:s?"Saving...":"Save"})]})]})]})})},P6=()=>{const[e,n]=g.useState(!1),t=g.useRef(null),r=g.useRef(null),{removeSection:i,formData:a,setIsDragging:o,setSelectedSection:s,selectedSection:l,activeSections:c,setActiveSections:u}=g.useContext(nr);g.useEffect(()=>{var h;s(((h=a[0])==null?void 0:h.id)||null)},[]);const d=g.useCallback(h=>{h.preventDefault(),h.dataTransfer.dropEffect="move",r.current&&(r.current.scrollTop=r.current.scrollHeight)},[]);function f(h){c.includes(h)?u(p=>p.filter(v=>v!==h)):u(p=>[...p,h])}function m(h){t.current=h,n(!0)}return w.jsxs("div",{ref:r,className:"relative flex flex-col h-full px-6 pb-5 mx-auto gap-x-4",children:[e&&w.jsx(N6,{isOpen:e,onClose:()=>n(!1),section:t.current}),w.jsx("div",{className:"relative flex flex-col flex-1 w-full py-4 gap-y-6",children:a.map((h,p)=>w.jsxs("div",{className:"group cursor-pointer rounded ",children:[w.jsxs("div",{className:`border border-gray-100 rounded px-4 shadow-[rgba(149,157,165,0.2)_0px_2px_4px] transition-colors duration-200
120
120
  ${l===h.id?"border-dashed border-blue-400 bg-[#f7f8fa]":""} ${c.includes(p)?"min-h-[300px] pb-6 ":""}`,children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsx("div",{onClick:()=>s(h.id),className:"flex-1 h-full py-4 cursor-pointer",children:w.jsx("h2",{className:"font-medium",children:h.title||"Section title"})}),w.jsxs("div",{className:"flex items-center gap-x-2",children:[w.jsx("button",{type:"button",className:"p-1 text-xs border rounded-lg",onClick:()=>m(h),children:w.jsx(ut,{icon:"fluent:edit-28-regular"})}),a.length>1&&w.jsx("button",{type:"button",className:"p-1 text-xs border rounded-lg",onClick:()=>i(h.id),children:w.jsx(ut,{icon:"lets-icons:trash-duotone-line"})}),w.jsx("button",{type:"button",className:"p-1 text-xs rounded-lg",onClick:()=>f(p),children:w.jsx(ut,{icon:c.includes(p)?"fa6-solid:chevron-up":"fa6-solid:chevron-down",iconClass:"text-base"})})]})]}),(h==null?void 0:h.description)&&c.includes(p)&&w.jsx("p",{className:"mt-2 text-sm text-gray-600 text-gray-60",children:h==null?void 0:h.description}),c.includes(p)&&w.jsxs("div",{className:"h-full mt-4 transition-all duration-200",id:h.id,onDragOver:d,onDragEnd:()=>o(!1),onClick:()=>s(h.id),children:[w.jsx("hr",{}),w.jsx("div",{className:"h-full mt-4 gap-y-6",children:w.jsx(O6,{elementData:h.questionData,sectionId:h.id})})]})]}),w.jsx("hr",{className:"mt-6 group-last:hidden"})]},h.id))})]})};function I6({questionData:e}){const{setFormData:n,addSection:t}=g.useContext(nr);g.useEffect(()=>{e&&e.length>0&&n(e)},[e,n]);const r=g.useCallback(i=>{i.preventDefault();try{const a=JSON.parse(i.dataTransfer.getData("properties"));if((a==null?void 0:a.type)==="section"){t();return}}catch(a){console.error("Drop error:",a)}},[]);return w.jsx("div",{onDragOver:i=>i.preventDefault(),onDrop:i=>r(i),className:"bg-white p-4 border border-[#E4E7EC] rounded-lg h-full overflow-y-auto no-scrollbar max-h-[calc(100vh-100px)]",children:w.jsx(P6,{})})}const L6=[{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"}],R6=()=>{const[e,n]=g.useState(""),{setIsDragging:t,addElement:r,selectedSection:i}=g.useContext(nr),a=g.useCallback((m,h)=>{m.dataTransfer.setData("properties",JSON.stringify(h)),m.dataTransfer.effectAllowed="move",t(!0)},[t]);function o(m){if(!i){Qe.error("Please select a section to add an element to.");return}const h={...m,id:gn(),sectionId:i};r(h,i)}const s=Yn("config")||{},l=s.elementColor,c=s.elementBgColor,u=s.elementBorderColor,d=g3.filter(m=>m.label.toLowerCase().includes(e.toLowerCase())),f=L6.map(m=>({title:m.title,elements:d.filter(h=>{var p;return(p=x3[m.key])==null?void 0:p.includes(h.type)})})).filter(m=>m.elements.length>0);return w.jsxs("div",{className:"pt-4 pb-6",children:[w.jsx("div",{className:"px-5 mb-4",children:w.jsx("input",{className:"field-control",placeholder:"Search",value:e,onChange:m=>n(m.target.value)})}),w.jsx("hr",{}),w.jsx("div",{children:w.jsx("ul",{className:"grid gap-y-5 mt-3 px-5 max-h-[80vh] overflow-y-auto no-scrollbar",children:f.map((m,h)=>w.jsxs("li",{children:[w.jsx("h4",{className:"mb-2 text-[11px] font-bold text-gray-500 uppercase",children:m.title}),w.jsx("ul",{className:"grid gap-y-[6px] mb-3",children:m.elements.map(p=>w.jsx("li",{onDragStart:v=>a(v,p),onDragEnd:()=>t(!1),onClick:()=>o(p),style:{borderColor:u,backgroundColor:c},className:`cursor-move text-[#475467] flex justify-between items-center h-11\r
121
121
  border-[1.5px] border-[#98A2B3] rounded-lg py-3 px-[14px] shadow-custom\r
122
122
  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.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "A React-based form builder component library.",
5
5
  "type": "module",
6
6
  "main": "./dist/form-builder.umd.js",