@arudovwen/form-builder-react 1.8.2 → 1.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { H as o, V as m } from "./index-prA6eLNT.js";
1
+ import { H as o, V as m } from "./index-C-OcZsA3.js";
2
2
  export {
3
3
  o as FormBuilder,
4
4
  m as FormViewer
@@ -1,4 +1,4 @@
1
- (function(ge,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react/jsx-runtime"),require("react"),require("uuid"),require("react-datepicker"),require("@headlessui/react"),require("sonner"),require("axios"),require("react-currency-input-field"),require("react-dom"),require("react-hook-form"),require("@hookform/resolvers"),require("yup"),require("papaparse"),require("xlsx"),require("react-router-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","uuid","react-datepicker","@headlessui/react","sonner","axios","react-currency-input-field","react-dom","react-hook-form","@hookform/resolvers","yup","papaparse","xlsx","react-router-dom"],t):(ge=typeof globalThis!="undefined"?globalThis:ge||self,t(ge.FormBuilder={},ge.jsxRuntime,ge.React,ge.uuid,ge.DatePicker,ge.react,ge.sonner,ge.axios,ge.CurrencyInput,ge.ReactDOM,ge.reactHookForm,ge.resolvers,ge.yup,ge.Papa,ge.XLSX,ge.reactRouterDom))})(this,function(ge,t,x,Ce,dr,re,Ee,Xe,ei,ur,Ve,fs,cr,mr,br,vr){"use strict";function ps(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const i in e)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:()=>e[i]})}}return n.default=e,Object.freeze(n)}const ne=ps(cr),gs=ps(br),Ae=x.createContext(void 0),ys={title:"",description:"",id:Ce.v4(),questionData:[],disabled:!1,isHidden:!1},xs=({children:e,onChange:n,onLogAction:i})=>{const[o,s]=x.useState(!0),[a,l]=x.useState({}),[r,d]=x.useState({}),[u,m]=x.useState([ys]),[c,b]=x.useState(()=>{try{const V=sessionStorage.getItem("editor_past");return V?JSON.parse(V):[]}catch(V){return[]}}),[v,h]=x.useState(()=>{try{const V=sessionStorage.getItem("editor_future");return V?JSON.parse(V):[]}catch(V){return[]}});x.useEffect(()=>{n&&n(u)},[u,n]),x.useEffect(()=>{try{sessionStorage.setItem("editor_past",JSON.stringify(c))}catch(V){console.warn("Could not save editor_past to sessionStorage",V)}},[c]),x.useEffect(()=>{try{sessionStorage.setItem("editor_future",JSON.stringify(v))}catch(V){console.warn("Could not save editor_future to sessionStorage",V)}},[v]);const p=x.useRef(Date.now()),g=x.useCallback(V=>{m(G=>{const H=typeof V=="function"?V(G):V;if(JSON.stringify(G)!==JSON.stringify(H)){const $=Date.now();b(F=>{if(F.length>0&&JSON.stringify(F[F.length-1])===JSON.stringify(G))return F;if($-p.current<800&&F.length>0)return p.current=$,F;p.current=$;const q=[...F,G];return q.length>20?q.slice(q.length-20):q}),h([])}return H})},[]),f=x.useCallback(()=>{if(c.length===0)return;const V=c[c.length-1],G=c.slice(0,c.length-1);b(G),h([u,...v]),m(V),i==null||i("UNDO",null)},[c,v,u,i]),N=x.useCallback(()=>{if(v.length===0)return;const V=v[0],G=v.slice(1);h(G),b([...c,u]),m(V),i==null||i("REDO",null)},[c,v,u,i]),y=u,S=c.length>0,w=v.length>0,[A,C]=x.useState(!1),[E,k]=x.useState(null),[I,P]=x.useState([0]),[T,O]=x.useState(""),[M,_]=x.useState(0),B=x.useCallback(()=>{},[]),K=x.useCallback(()=>{const V=Ce.v4();g(G=>[...G,{...ys,id:V}]),k(V),P([y.length]),i==null||i("ADD_SECTION",{sectionId:V})},[y,i,g]),D=x.useCallback(V=>{g(G=>G.filter(H=>H.id!==V)),k(null),i==null||i("REMOVE_SECTION",{sectionId:V})},[i,g]),L=x.useCallback((V,G)=>{const H=y.find(F=>F.id===G),$=H==null?void 0:H.questionData.find(F=>F.id===V);$&&(g(F=>F==null?void 0:F.map(q=>q.id===G?{...q,questionData:q==null?void 0:q.questionData.filter(R=>$.type==="grid"?R.gridId!==$.id&&R.id!==$.id:R.id!==V)}:q)),i==null||i("REMOVE_ELEMENT",{sectionId:G,elementId:V}))},[y,g,i]),z=x.useCallback((V,G)=>{const H=y.find(R=>R.id===G);if(!H)return;const $=H==null?void 0:H.questionData.findIndex(R=>R.id===V);if($===-1)return;const F=H==null?void 0:H.questionData[$],q=(R,Z={})=>({...JSON.parse(JSON.stringify(R)),id:Ce.v4(),...Z});g(R=>R==null?void 0:R.map(Z=>{var ee;if(Z.id!==G)return Z;const J=[...Z.questionData];if(F.type==="grid"){const ae=(ee=J==null?void 0:J.map((pe,Ne)=>({e:pe,i:Ne})).filter(({e:pe})=>pe.id===F.id||pe.gridId===F.id))==null?void 0:ee.map(({i:pe})=>pe),ue=ae.length?Math.max(...ae)+1:$+1,me=Ce.v4(),ye=q(F,{});ye.id=me;const be=J.filter(pe=>pe.gridId===F.id),we=be==null?void 0:be.map(pe=>q(pe,{gridId:me})),Me=[...J.slice(0,ue),ye,...we,...J.slice(ue)];return{...Z,questionData:Me}}else if(F.gridId){const{gridId:ae,gridPosition:ue,...me}=F,ye=q(me,{}),be=J.reduce((Me,pe,Ne)=>pe.id===F.gridId||pe.gridId===F.gridId?Ne:Me,$),we=[...J.slice(0,be+1),ye,...J.slice(be+1)];return{...Z,questionData:we}}else{const ae=q(F,{}),ue=[...J.slice(0,$+1),ae,...J.slice($+1)];return{...Z,questionData:ue}}})),i==null||i("DUPLICATE_ELEMENT",{sectionId:G,elementId:V})},[y,g,i]),U=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>$.id===G?{...$,questionData:V}:$)),i==null||i("UPDATE_ELEMENT_POSITION",{sectionId:G})},[g,i]),W=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>$.id===G?{...$,questionData:[...$==null?void 0:$.questionData,V]}:$)),i==null||i("ADD_ELEMENT",{sectionId:G,element:V})},[g,i]),Y=x.useCallback((V,G,H)=>{g($=>$==null?void 0:$.map(F=>F.id===G?{...F,questionData:[...F==null?void 0:F.questionData.slice(0,H),V,...F==null?void 0:F.questionData.slice(H)]}:F)),i==null||i("ADD_ELEMENT_IN_POSITION",{sectionId:G,element:V,index:H})},[g,i]),X=x.useCallback((V,G,H)=>{g($=>$==null?void 0:$.map(F=>{var q;return F.id===H?{...F,questionData:(q=F==null?void 0:F.questionData)==null?void 0:q.map(R=>{var Z;return R.type==="grid"&&R.gridData?{...R,gridData:(Z=R.gridData)==null?void 0:Z.map((J,ee)=>ee===V?{...J,...G}:J).concat(V>=R.gridData.length?{...G}:[])}:R})}:F})),i==null||i("UPDATE_GRID_ELEMENT",{sectionId:H,gridIndex:V,element:G})},[g,i]),ie=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>{var F;return $.id===G?{...$,questionData:(F=$==null?void 0:$.questionData)==null?void 0:F.map(q=>q.id===V.id?{...q,...V}:q)}:$})),i==null||i("UPDATE_ELEMENT",{sectionId:G,value:V})},[g,i]),se=x.useCallback(V=>{const{draggedId:G,sectionId:H,targetIndex:$,targetId:F,targetGridId:q,targetCol:R}=V;g(Z=>Z.map(J=>{if(J.id!==H)return J;const ee=[...J==null?void 0:J.questionData],ae=ee.findIndex(me=>me.id===G);if(ae===-1)return J;const ue={...ee[ae]};if(q!==void 0&&R!==void 0){if(ue.type==="grid")return J;const me=ee.findIndex(be=>{var we;return be.id!==G&&be.gridId===q&&((we=be.gridPosition)==null?void 0:we.col)===R});let ye=ee.map(be=>be.id===G?{...be,gridId:q,gridPosition:{col:R}}:be);return me!==-1&&(ye=ye.map((be,we)=>{if(we!==me)return be;const Me={...be};return delete Me.gridId,delete Me.gridPosition,Me})),{...J,questionData:ye}}if(ue.gridId&&$!==void 0&&q===void 0){const me={...ue};delete me.gridId,delete me.gridPosition;const ye=ee.filter(we=>we.id!==G),be=Math.min($,ye.length);return ye.splice(be,0,me),{...J,questionData:ye}}if(!ue.gridId&&$!==void 0&&q===void 0&&!F){ee.splice(ae,1);const me=Math.min($,ee.length);return ee.splice(me,0,ue),{...J,questionData:ee}}if(F){const me=ee.findIndex(ye=>ye.id===F);return me===-1?J:(ee.splice(ae,1),ee.splice(me,0,ue),{...J,questionData:ee})}return J})),i==null||i("MOVE_ELEMENT",V)},[g,i]),Q=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>$.id===G?{...$,...V}:$)),i==null||i("UPDATE_SECTION",{sectionId:G,value:V})},[g,i]),j=x.useMemo(()=>({formData:y,setFormData:g,handleDragStop:B,removeElement:L,elementData:r,setElementData:d,updateElementPosition:U,addElement:W,addElementInPosition:Y,updateElement:ie,addSection:K,removeSection:D,updateSection:Q,isDragging:A,setIsDragging:C,selectedSection:E,setSelectedSection:k,activeSections:I,setActiveSections:P,updateGridElement:X,answerData:a,setAnswerData:l,uploadUrl:T,setUploadUrl:O,apiActivityCount:M,setApiActivityCount:_,duplicateElement:z,moveElement:se,showPreview:o,setShowPreview:s,undo:f,redo:N,canUndo:S,canRedo:w}),[y,B,L,r,U,W,Y,ie,K,D,Q,A,E,I,X,a,T,M,z,se,o,f,N,S,w]);return t.jsx(Ae.Provider,{value:j,children:e})};function Ss(e){var n,i,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(n=0;n<s;n++)e[n]&&(i=Ss(e[n]))&&(o&&(o+=" "),o+=i)}else for(i in e)e[i]&&(o&&(o+=" "),o+=i);return o}function de(){for(var e,n,i=0,o="",s=arguments.length;i<s;i++)(e=arguments[i])&&(n=Ss(e))&&(o&&(o+=" "),o+=n);return o}function hr({type:e="calendar",className:n}){return t.jsx(t.Fragment,{children:e==="calendar"?t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[t.jsx("path",{d:"M6.66406 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M13.3359 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2.91406 7.57495H17.0807",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M17.5 7.08341V14.1667C17.5 16.6667 16.25 18.3334 13.3333 18.3334H6.66667C3.75 18.3334 2.5 16.6667 2.5 14.1667V7.08341C2.5 4.58341 3.75 2.91675 6.66667 2.91675H13.3333C16.25 2.91675 17.5 4.58341 17.5 7.08341Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M13.0762 11.4167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M13.0762 13.9167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M9.99803 11.4167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M9.99803 13.9167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M6.91209 11.4167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M6.91209 13.9167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[t.jsx("path",{d:"M10 6.66663V10.8333",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M10.0026 18.3333C5.9776 18.3333 2.71094 15.0667 2.71094 11.0417C2.71094 7.01667 5.9776 3.75 10.0026 3.75C14.0276 3.75 17.2943 7.01667 17.2943 11.0417",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M7.5 1.66663H12.5",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M12.4141 15.4167V14.4501C12.4141 13.2584 13.2641 12.7667 14.2974 13.3667L15.1307 13.8501L15.9641 14.3334C16.9974 14.9334 16.9974 15.9084 15.9641 16.5084L15.1307 16.9917L14.2974 17.4751C13.2641 18.0751 12.4141 17.5834 12.4141 16.3917V15.4167Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const Ji=({value:e=null,onGetValue:n,readOnly:i=!1,dateFormat:o="dd/MM/yyyy",name:s,placeholder:a="Select date",minDate:l,maxDate:r,showYearDropdown:d})=>{const u=e?new Date(e):null,[m,c]=x.useState(u);x.useEffect(()=>{const v=e?new Date(e):null;(v&&m&&v.getTime()!==m.getTime()||!v&&m||v&&!m)&&c(v)},[e]),x.useEffect(()=>{n&&n(s,m)},[m,n,s]);const b=v=>{c(v)};return t.jsx("div",{className:"builder_date__picker",children:t.jsx(dr,{showIcon:!0,icon:t.jsx(hr,{className:"react-datepicker__calendar-icon"}),showPopperArrow:!1,dateFormat:o,disabled:i,selected:m,onChange:b,className:"field-control",portalId:"root-portal",placeholderText:a,minDate:l,maxDate:r,showYearDropdown:d,scrollableYearDropdown:!0,yearDropdownItemNumber:40})})};function fr({element:e,validationData:n}){const{register:i=()=>({}),setValue:o,watch:s}=n||{};let a;return s&&(a=s()[e.id]),x.useEffect(()=>{i(e.id)},[e.id]),t.jsx(Ji,{name:e.id,value:a,onGetValue:o,readOnly:n==null?void 0:n.isReadOnly,dateFormat:(e==null?void 0:e.dateFormat)||"dd/MM/yyyy",minDate:e==null?void 0:e.minDate,maxDate:e==null?void 0:e.maxDate,showYearDropdown:e==null?void 0:e.allowYearPicker})}function Zi({element:e,validationData:n}){var o;const{register:i=()=>({})}=n||{};return t.jsx("div",{children:t.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"",type:(e==null?void 0:e.inputType)||"text",className:de("field-control",e==null?void 0:e.customClass),...i(e==null?void 0:e.id),disabled:n==null?void 0:n.isReadOnly,inputMode:(e==null?void 0:e.inputMode)||void 0,"aria-invalid":!!((o=n==null?void 0:n.errors)!=null&&o[e==null?void 0:e.id]),pattern:(e==null?void 0:e.pattern)||void 0})})}function pr(e,n){const i=e.icons,o=e.aliases||Object.create(null),s=Object.create(null);function a(l){if(i[l])return s[l]=[];if(!(l in s)){s[l]=null;const r=o[l]&&o[l].parent,d=r&&a(r);d&&(s[l]=[r].concat(d))}return s[l]}return Object.keys(i).concat(Object.keys(o)).forEach(a),s}const ws=Object.freeze({left:0,top:0,width:16,height:16}),ni=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Xi=Object.freeze({...ws,...ni}),Qi=Object.freeze({...Xi,body:"",hidden:!1});function gr(e,n){const i={};!e.hFlip!=!n.hFlip&&(i.hFlip=!0),!e.vFlip!=!n.vFlip&&(i.vFlip=!0);const o=((e.rotate||0)+(n.rotate||0))%4;return o&&(i.rotate=o),i}function Ns(e,n){const i=gr(e,n);for(const o in Qi)o in ni?o in e&&!(o in i)&&(i[o]=ni[o]):o in n?i[o]=n[o]:o in e&&(i[o]=e[o]);return i}function yr(e,n,i){const o=e.icons,s=e.aliases||Object.create(null);let a={};function l(r){a=Ns(o[r]||s[r],a)}return l(n),i.forEach(l),Ns(e,a)}function As(e,n){const i=[];if(typeof e!="object"||typeof e.icons!="object")return i;e.not_found instanceof Array&&e.not_found.forEach(s=>{n(s,null),i.push(s)});const o=pr(e);for(const s in o){const a=o[s];a&&(n(s,yr(e,s,a)),i.push(s))}return i}const xr={provider:"",aliases:{},not_found:{},...ws};function Ri(e,n){for(const i in n)if(i in e&&typeof e[i]!=typeof n[i])return!1;return!0}function Cs(e){if(typeof e!="object"||e===null)return null;const n=e;if(typeof n.prefix!="string"||!e.icons||typeof e.icons!="object"||!Ri(e,xr))return null;const i=n.icons;for(const s in i){const a=i[s];if(!s||typeof a.body!="string"||!Ri(a,Qi))return null}const o=n.aliases||Object.create(null);for(const s in o){const a=o[s],l=a.parent;if(!s||typeof l!="string"||!i[l]&&!o[l]||!Ri(a,Qi))return null}return n}const ks=Object.create(null);function Sr(e,n){return{provider:e,prefix:n,icons:Object.create(null),missing:new Set}}function dn(e,n){const i=ks[e]||(ks[e]=Object.create(null));return i[n]||(i[n]=Sr(e,n))}function Ms(e,n){return Cs(n)?As(n,(i,o)=>{o?e.icons[i]=o:e.missing.add(i)}):[]}function wr(e,n,i){try{if(typeof i.body=="string")return e.icons[n]={...i},!0}catch(o){}return!1}const Es=/^[a-z0-9]+(-[a-z0-9]+)*$/,ii=(e,n,i,o="")=>{const s=e.split(":");if(e.slice(0,1)==="@"){if(s.length<2||s.length>3)return null;o=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const r=s.pop(),d=s.pop(),u={provider:s.length>0?s[0]:o,prefix:d,name:r};return n&&!oi(u)?null:u}const a=s[0],l=a.split("-");if(l.length>1){const r={provider:o,prefix:l.shift(),name:l.join("-")};return n&&!oi(r)?null:r}if(i&&o===""){const r={provider:o,prefix:"",name:a};return n&&!oi(r,i)?null:r}return null},oi=(e,n)=>e?!!((n&&e.prefix===""||e.prefix)&&e.name):!1;let En=!1;function Ts(e){return typeof e=="boolean"&&(En=e),En}function Ps(e){const n=typeof e=="string"?ii(e,!0,En):e;if(n){const i=dn(n.provider,n.prefix),o=n.name;return i.icons[o]||(i.missing.has(o)?null:void 0)}}function Nr(e,n){const i=ii(e,!0,En);if(!i)return!1;const o=dn(i.provider,i.prefix);return n?wr(o,i.name,n):(o.missing.add(i.name),!0)}function Ar(e,n){if(typeof e!="object")return!1;if(typeof n!="string"&&(n=e.provider||""),En&&!n&&!e.prefix){let s=!1;return Cs(e)&&(e.prefix="",As(e,(a,l)=>{Nr(a,l)&&(s=!0)})),s}const i=e.prefix;if(!oi({prefix:i,name:"a"}))return!1;const o=dn(n,i);return!!Ms(o,e)}const Ls=Object.freeze({width:null,height:null}),Bs=Object.freeze({...Ls,...ni}),Cr=/(-?[0-9.]*[0-9]+[0-9.]*)/g,kr=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Is(e,n,i){if(n===1)return e;if(i=i||100,typeof e=="number")return Math.ceil(e*n*i)/i;if(typeof e!="string")return e;const o=e.split(Cr);if(o===null||!o.length)return e;const s=[];let a=o.shift(),l=kr.test(a);for(;;){if(l){const r=parseFloat(a);isNaN(r)?s.push(a):s.push(Math.ceil(r*n*i)/i)}else s.push(a);if(a=o.shift(),a===void 0)return s.join("");l=!l}}function Mr(e,n="defs"){let i="";const o=e.indexOf("<"+n);for(;o>=0;){const s=e.indexOf(">",o),a=e.indexOf("</"+n);if(s===-1||a===-1)break;const l=e.indexOf(">",a);if(l===-1)break;i+=e.slice(s+1,a).trim(),e=e.slice(0,o).trim()+e.slice(l+1)}return{defs:i,content:e}}function Er(e,n){return e?"<defs>"+e+"</defs>"+n:n}function Tr(e,n,i){const o=Mr(e);return Er(o.defs,n+o.content+i)}const Pr=e=>e==="unset"||e==="undefined"||e==="none";function Lr(e,n){const i={...Xi,...e},o={...Bs,...n},s={left:i.left,top:i.top,width:i.width,height:i.height};let a=i.body;[i,o].forEach(p=>{const g=[],f=p.hFlip,N=p.vFlip;let y=p.rotate;f?N?y+=2:(g.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),g.push("scale(-1 1)"),s.top=s.left=0):N&&(g.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),g.push("scale(1 -1)"),s.top=s.left=0);let S;switch(y<0&&(y-=Math.floor(y/4)*4),y=y%4,y){case 1:S=s.height/2+s.top,g.unshift("rotate(90 "+S.toString()+" "+S.toString()+")");break;case 2:g.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:S=s.width/2+s.left,g.unshift("rotate(-90 "+S.toString()+" "+S.toString()+")");break}y%2===1&&(s.left!==s.top&&(S=s.left,s.left=s.top,s.top=S),s.width!==s.height&&(S=s.width,s.width=s.height,s.height=S)),g.length&&(a=Tr(a,'<g transform="'+g.join(" ")+'">',"</g>"))});const l=o.width,r=o.height,d=s.width,u=s.height;let m,c;l===null?(c=r===null?"1em":r==="auto"?u:r,m=Is(c,d/u)):(m=l==="auto"?d:l,c=r===null?Is(m,u/d):r==="auto"?u:r);const b={},v=(p,g)=>{Pr(g)||(b[p]=g.toString())};v("width",m),v("height",c);const h=[s.left,s.top,d,u];return b.viewBox=h.join(" "),{attributes:b,viewBox:h,body:a}}const Br=/\sid="(\S+)"/g,Ir="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Dr=0;function _r(e,n=Ir){const i=[];let o;for(;o=Br.exec(e);)i.push(o[1]);if(!i.length)return e;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return i.forEach(a=>{const l=typeof n=="function"?n(a):n+(Dr++).toString(),r=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+r+')([")]|\\.[a-z])',"g"),"$1"+l+s+"$3")}),e=e.replace(new RegExp(s,"g"),""),e}const eo=Object.create(null);function Or(e,n){eo[e]=n}function no(e){return eo[e]||eo[""]}function io(e){let n;if(typeof e.resources=="string")n=[e.resources];else if(n=e.resources,!(n instanceof Array)||!n.length)return null;return{resources:n,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const oo=Object.create(null),Tn=["https://api.simplesvg.com","https://api.unisvg.com"],si=[];for(;Tn.length>0;)Tn.length===1||Math.random()>.5?si.push(Tn.shift()):si.push(Tn.pop());oo[""]=io({resources:["https://api.iconify.design"].concat(si)});function Kr(e,n){const i=io(n);return i===null?!1:(oo[e]=i,!0)}function so(e){return oo[e]}let Ds=(()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch(n){}})();function Hr(e,n){const i=so(e);if(!i)return 0;let o;if(!i.maxURL)o=0;else{let s=0;i.resources.forEach(l=>{s=Math.max(s,l.length)});const a=n+".json?icons=";o=i.maxURL-s-i.path.length-a.length}return o}function Gr(e){return e===404}const Fr=(e,n,i)=>{const o=[],s=Hr(e,n),a="icons";let l={type:a,provider:e,prefix:n,icons:[]},r=0;return i.forEach((d,u)=>{r+=d.length+1,r>=s&&u>0&&(o.push(l),l={type:a,provider:e,prefix:n,icons:[]},r=d.length),l.icons.push(d)}),o.push(l),o};function Vr(e){if(typeof e=="string"){const n=so(e);if(n)return n.path}return"/"}const zr={prepare:Fr,send:(e,n,i)=>{if(!Ds){i("abort",424);return}let o=Vr(n.provider);switch(n.type){case"icons":{const a=n.prefix,r=n.icons.join(","),d=new URLSearchParams({icons:r});o+=a+".json?"+d.toString();break}case"custom":{const a=n.uri;o+=a.slice(0,1)==="/"?a.slice(1):a;break}default:i("abort",400);return}let s=503;Ds(e+o).then(a=>{const l=a.status;if(l!==200){setTimeout(()=>{i(Gr(l)?"abort":"next",l)});return}return s=501,a.json()}).then(a=>{if(typeof a!="object"||a===null){setTimeout(()=>{a===404?i("abort",a):i("next",s)});return}setTimeout(()=>{i("success",a)})}).catch(()=>{i("next",s)})}};function _s(e,n){e.forEach(i=>{const o=i.loaderCallbacks;o&&(i.loaderCallbacks=o.filter(s=>s.id!==n))})}function Wr(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const n=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!n.length)return;let i=!1;const o=e.provider,s=e.prefix;n.forEach(a=>{const l=a.icons,r=l.pending.length;l.pending=l.pending.filter(d=>{if(d.prefix!==s)return!0;const u=d.name;if(e.icons[u])l.loaded.push({provider:o,prefix:s,name:u});else if(e.missing.has(u))l.missing.push({provider:o,prefix:s,name:u});else return i=!0,!0;return!1}),l.pending.length!==r&&(i||_s([e],a.id),a.callback(l.loaded.slice(0),l.missing.slice(0),l.pending.slice(0),a.abort))})}))}let $r=0;function jr(e,n,i){const o=$r++,s=_s.bind(null,i,o);if(!n.pending.length)return s;const a={id:o,icons:n,callback:e,abort:s};return i.forEach(l=>{(l.loaderCallbacks||(l.loaderCallbacks=[])).push(a)}),s}function Ur(e){const n={loaded:[],missing:[],pending:[]},i=Object.create(null);e.sort((s,a)=>s.provider!==a.provider?s.provider.localeCompare(a.provider):s.prefix!==a.prefix?s.prefix.localeCompare(a.prefix):s.name.localeCompare(a.name));let o={provider:"",prefix:"",name:""};return e.forEach(s=>{if(o.name===s.name&&o.prefix===s.prefix&&o.provider===s.provider)return;o=s;const a=s.provider,l=s.prefix,r=s.name,d=i[a]||(i[a]=Object.create(null)),u=d[l]||(d[l]=dn(a,l));let m;r in u.icons?m=n.loaded:l===""||u.missing.has(r)?m=n.missing:m=n.pending;const c={provider:a,prefix:l,name:r};m.push(c)}),n}function qr(e,n=!0,i=!1){const o=[];return e.forEach(s=>{const a=typeof s=="string"?ii(s,n,i):s;a&&o.push(a)}),o}const Yr={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Jr(e,n,i,o){const s=e.resources.length,a=e.random?Math.floor(Math.random()*s):e.index;let l;if(e.random){let A=e.resources.slice(0);for(l=[];A.length>1;){const C=Math.floor(Math.random()*A.length);l.push(A[C]),A=A.slice(0,C).concat(A.slice(C+1))}l=l.concat(A)}else l=e.resources.slice(a).concat(e.resources.slice(0,a));const r=Date.now();let d="pending",u=0,m,c=null,b=[],v=[];typeof o=="function"&&v.push(o);function h(){c&&(clearTimeout(c),c=null)}function p(){d==="pending"&&(d="aborted"),h(),b.forEach(A=>{A.status==="pending"&&(A.status="aborted")}),b=[]}function g(A,C){C&&(v=[]),typeof A=="function"&&v.push(A)}function f(){return{startTime:r,payload:n,status:d,queriesSent:u,queriesPending:b.length,subscribe:g,abort:p}}function N(){d="failed",v.forEach(A=>{A(void 0,m)})}function y(){b.forEach(A=>{A.status==="pending"&&(A.status="aborted")}),b=[]}function S(A,C,E){const k=C!=="success";switch(b=b.filter(I=>I!==A),d){case"pending":break;case"failed":if(k||!e.dataAfterTimeout)return;break;default:return}if(C==="abort"){m=E,N();return}if(k){m=E,b.length||(l.length?w():N());return}if(h(),y(),!e.random){const I=e.resources.indexOf(A.resource);I!==-1&&I!==e.index&&(e.index=I)}d="completed",v.forEach(I=>{I(E)})}function w(){if(d!=="pending")return;h();const A=l.shift();if(A===void 0){if(b.length){c=setTimeout(()=>{h(),d==="pending"&&(y(),N())},e.timeout);return}N();return}const C={status:"pending",resource:A,callback:(E,k)=>{S(C,E,k)}};b.push(C),u++,c=setTimeout(w,e.rotate),i(A,n,C.callback)}return setTimeout(w),f}function Os(e){const n={...Yr,...e};let i=[];function o(){i=i.filter(r=>r().status==="pending")}function s(r,d,u){const m=Jr(n,r,d,(c,b)=>{o(),u&&u(c,b)});return i.push(m),m}function a(r){return i.find(d=>r(d))||null}return{query:s,find:a,setIndex:r=>{n.index=r},getIndex:()=>n.index,cleanup:o}}function Ks(){}const ao=Object.create(null);function Zr(e){if(!ao[e]){const n=so(e);if(!n)return;const i=Os(n),o={config:n,redundancy:i};ao[e]=o}return ao[e]}function Xr(e,n,i){let o,s;if(typeof e=="string"){const a=no(e);if(!a)return i(void 0,424),Ks;s=a.send;const l=Zr(e);l&&(o=l.redundancy)}else{const a=io(e);if(a){o=Os(a);const l=e.resources?e.resources[0]:"",r=no(l);r&&(s=r.send)}}return!o||!s?(i(void 0,424),Ks):o.query(n,s,i)().abort}function Hs(){}function Qr(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,Wr(e)}))}function Rr(e){const n=[],i=[];return e.forEach(o=>{(o.match(Es)?n:i).push(o)}),{valid:n,invalid:i}}function Pn(e,n,i){function o(){const s=e.pendingIcons;n.forEach(a=>{s&&s.delete(a),e.icons[a]||e.missing.add(a)})}if(i&&typeof i=="object")try{if(!Ms(e,i).length){o();return}}catch(s){console.error(s)}o(),Qr(e)}function Gs(e,n){e instanceof Promise?e.then(i=>{n(i)}).catch(()=>{n(null)}):n(e)}function ed(e,n){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(n).sort():e.iconsToLoad=n,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:i,prefix:o}=e,s=e.iconsToLoad;if(delete e.iconsToLoad,!s||!s.length)return;const a=e.loadIcon;if(e.loadIcons&&(s.length>1||!a)){Gs(e.loadIcons(s,o,i),m=>{Pn(e,s,m)});return}if(a){s.forEach(m=>{const c=a(m,o,i);Gs(c,b=>{const v=b?{prefix:o,icons:{[m]:b}}:null;Pn(e,[m],v)})});return}const{valid:l,invalid:r}=Rr(s);if(r.length&&Pn(e,r,null),!l.length)return;const d=o.match(Es)?no(i):null;if(!d){Pn(e,l,null);return}d.prepare(i,o,l).forEach(m=>{Xr(i,m,c=>{Pn(e,m.icons,c)})})}))}const nd=(e,n)=>{const i=qr(e,!0,Ts()),o=Ur(i);if(!o.pending.length){let d=!0;return n&&setTimeout(()=>{d&&n(o.loaded,o.missing,o.pending,Hs)}),()=>{d=!1}}const s=Object.create(null),a=[];let l,r;return o.pending.forEach(d=>{const{provider:u,prefix:m}=d;if(m===r&&u===l)return;l=u,r=m,a.push(dn(u,m));const c=s[u]||(s[u]=Object.create(null));c[m]||(c[m]=[])}),o.pending.forEach(d=>{const{provider:u,prefix:m,name:c}=d,b=dn(u,m),v=b.pendingIcons||(b.pendingIcons=new Set);v.has(c)||(v.add(c),s[u][m].push(c))}),a.forEach(d=>{const u=s[d.provider][d.prefix];u.length&&ed(d,u)}),n?jr(n,o,a):Hs};function id(e,n){const i={...e};for(const o in n){const s=n[o],a=typeof s;o in Ls?(s===null||s&&(a==="string"||a==="number"))&&(i[o]=s):a===typeof i[o]&&(i[o]=o==="rotate"?s%4:s)}return i}const od=/[\s,]+/;function sd(e,n){n.split(od).forEach(i=>{switch(i.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function ad(e,n=0){const i=e.replace(/^-?[0-9.]*/,"");function o(s){for(;s<0;)s+=4;return s%4}if(i===""){const s=parseInt(e);return isNaN(s)?0:o(s)}else if(i!==e){let s=0;switch(i){case"%":s=25;break;case"deg":s=90}if(s){let a=parseFloat(e.slice(0,e.length-i.length));return isNaN(a)?0:(a=a/s,a%1===0?o(a):0)}}return n}function td(e,n){let i=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const o in n)i+=" "+o+'="'+n[o]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+i+">"+e+"</svg>"}function ld(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function rd(e){return"data:image/svg+xml,"+ld(e)}function dd(e){return'url("'+rd(e)+'")'}let Ln;function ud(){try{Ln=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch(e){Ln=null}}function cd(e){return Ln===void 0&&ud(),Ln?Ln.createHTML(e):e}const Fs={...Bs,inline:!1},md={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},bd={display:"inline-block"},to={backgroundColor:"currentColor"},Vs={backgroundColor:"transparent"},zs={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Ws={WebkitMask:to,mask:to,background:Vs};for(const e in Ws){const n=Ws[e];for(const i in zs)n[e+i]=zs[i]}const vd={...Fs,inline:!0};function $s(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const hd=(e,n,i)=>{const o=n.inline?vd:Fs,s=id(o,n),a=n.mode||"svg",l={},r=n.style||{},d={...a==="svg"?md:{}};if(i){const g=ii(i,!1,!0);if(g){const f=["iconify"],N=["provider","prefix"];for(const y of N)g[y]&&f.push("iconify--"+g[y]);d.className=f.join(" ")}}for(let g in n){const f=n[g];if(f!==void 0)switch(g){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":d.ref=f;break;case"className":d[g]=(d[g]?d[g]+" ":"")+f;break;case"inline":case"hFlip":case"vFlip":s[g]=f===!0||f==="true"||f===1;break;case"flip":typeof f=="string"&&sd(s,f);break;case"color":l.color=f;break;case"rotate":typeof f=="string"?s[g]=ad(f):typeof f=="number"&&(s[g]=f);break;case"ariaHidden":case"aria-hidden":f!==!0&&f!=="true"&&delete d["aria-hidden"];break;default:o[g]===void 0&&(d[g]=f)}}const u=Lr(e,s),m=u.attributes;if(s.inline&&(l.verticalAlign="-0.125em"),a==="svg"){d.style={...l,...r},Object.assign(d,m);let g=0,f=n.id;return typeof f=="string"&&(f=f.replace(/-/g,"_")),d.dangerouslySetInnerHTML={__html:cd(_r(u.body,f?()=>f+"ID"+g++:"iconifyReact"))},x.createElement("svg",d)}const{body:c,width:b,height:v}=e,h=a==="mask"||(a==="bg"?!1:c.indexOf("currentColor")!==-1),p=td(c,{...m,width:b+"",height:v+""});return d.style={...l,"--svg":dd(p),width:$s(m.width),height:$s(m.height),...bd,...h?to:Vs,...r},x.createElement("span",d)};if(Ts(!0),Or("",zr),typeof document!="undefined"&&typeof window!="undefined"){const e=window;if(e.IconifyPreload!==void 0){const n=e.IconifyPreload,i="Invalid IconifyPreload syntax.";typeof n=="object"&&n!==null&&(n instanceof Array?n:[n]).forEach(o=>{try{(typeof o!="object"||o===null||o instanceof Array||typeof o.icons!="object"||typeof o.prefix!="string"||!Ar(o))&&console.error(i)}catch(s){console.error(i)}})}if(e.IconifyProviders!==void 0){const n=e.IconifyProviders;if(typeof n=="object"&&n!==null)for(let i in n){const o="IconifyProviders["+i+"] is invalid.";try{const s=n[i];if(typeof s!="object"||!s||s.resources===void 0)continue;Kr(i,s)||console.error(o)}catch(s){console.error(o)}}}}function js(e){const[n,i]=x.useState(!!e.ssr),[o,s]=x.useState({});function a(v){if(v){const h=e.icon;if(typeof h=="object")return{name:"",data:h};const p=Ps(h);if(p)return{name:h,data:p}}return{name:""}}const[l,r]=x.useState(a(!!e.ssr));function d(){const v=o.callback;v&&(v(),s({}))}function u(v){if(JSON.stringify(l)!==JSON.stringify(v))return d(),r(v),!0}function m(){var v;const h=e.icon;if(typeof h=="object"){u({name:"",data:h});return}const p=Ps(h);if(u({name:h,data:p}))if(p===void 0){const g=nd([h],m);s({callback:g})}else p&&((v=e.onLoad)===null||v===void 0||v.call(e,h))}x.useEffect(()=>(i(!0),d),[]),x.useEffect(()=>{n&&m()},[e.icon,n]);const{name:c,data:b}=l;return b?hd({...Xi,...b},e,c):e.children?e.children:e.fallback?e.fallback:x.createElement("span",{})}const Us=x.forwardRef((e,n)=>js({...e,_ref:n}));x.forwardRef((e,n)=>js({inline:!0,...e,_ref:n}));function te({icon:e,iconClass:n}){return t.jsx(t.Fragment,{children:t.jsx(Us,{icon:e,className:n})})}function lo({element:e,validationData:n,placeholder:i}){var c;const{register:o=()=>({}),setValue:s,isReadOnly:a,watch:l,getValues:r}=n||{},[d,u]=x.useState(()=>{const b=r==null?void 0:r(e.id);return Array.isArray(b)?b:[]}),m=x.useMemo(()=>d==null?void 0:d.map(b=>b.label).join(", "),[d]);return x.useEffect(()=>{o(e.id)},[e.id,o]),x.useEffect(()=>{if(!l)return;const b=l(v=>{const h=v[e.id];h!==void 0&&u(Array.isArray(h)?h:[])});return()=>{var v;return(v=b.unsubscribe)==null?void 0:v.call(b)}},[l,e.id]),t.jsx("div",{className:"custom-select",children:t.jsx(re.Listbox,{value:d||[],onChange:b=>{u(b),s==null||s(e.id,b)},multiple:!0,disabled:a,by:"value",children:t.jsxs("div",{className:"custom-select__wrapper",children:[t.jsxs(re.Listbox.Button,{className:"custom-select__control field-control",disabled:a,children:[t.jsx("span",{className:"custom-select__value",children:(d==null?void 0:d.length)>0?m:t.jsx("span",{className:"custom-select__placeholder",children:i!=null?i:" Select options"})}),t.jsx("span",{className:"custom-select__icon",children:t.jsx(te,{icon:"lucide:chevron-down"})})]}),t.jsx(re.Transition,{as:x.Fragment,leave:"custom-select__transition",children:t.jsx(re.Listbox.Options,{anchor:"bottom start",className:"custom-select__options",children:(c=e==null?void 0:e.options)==null?void 0:c.map((b,v)=>t.jsx(re.Listbox.Option,{value:b,className:({active:h})=>`custom-select__option ${h?"custom-select__option--active":""}`,children:({selected:h})=>t.jsxs("div",{className:"custom-select__option-row",children:[t.jsx("span",{className:`custom-select__option-label ${h?"custom-select__option--selected":""}`,children:b.label}),h&&t.jsx("span",{className:"custom-select__check",children:"✓"})]})},v))})})]})})})}const fd=["jpg","jpeg","png","gif","bmp","webp","svg","image"],pd=(e="")=>{var i;const n=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return fd.includes(n)||e.startsWith("data:image/")?"image":n==="pdf"||e.startsWith("data:application/pdf")?"pdf":["doc","docx"].includes(n)?"word":["xls","xlsx","csv"].includes(n)?"excel":["ppt","pptx"].includes(n)?"powerpoint":"other"},gd={pdf:"vscode-icons:file-type-pdf2",word:"vscode-icons:file-type-word",excel:"vscode-icons:file-type-excel",powerpoint:"vscode-icons:file-type-powerpoint2"};function qs({fileUrl:e,fileName:n,removeFile:i}){const[o,s]=x.useState(!1),[a,l]=x.useState("unknown"),[r,d]=x.useState(null);x.useEffect(()=>{e&&l(pd(e))},[e]),x.useEffect(()=>{if(a==="pdf"&&(e!=null&&e.startsWith("data:")))try{const v=atob(e.split(",")[1]),h=new ArrayBuffer(v.length),p=new Uint8Array(h);for(let N=0;N<v.length;N++)p[N]=v.charCodeAt(N);const g=new Blob([h],{type:"application/pdf"}),f=URL.createObjectURL(g);return d(f),()=>URL.revokeObjectURL(f)}catch(v){console.error("Error creating blob URL:",v)}else d(null)},[e,a]);const u=()=>{a==="image"||a==="pdf"?s(!0):window.open(r||e,"_blank")},m=()=>s(!1),c=n||(e==null?void 0:e.split("/").pop())||"Unknown file";function b(v,h="download"){if(!v)return;if(v.startsWith("data:")){const g=document.createElement("a");g.href=v,g.download=h,document.body.appendChild(g),g.click(),document.body.removeChild(g);return}const p=document.createElement("a");p.href=v,p.setAttribute("download",h),document.body.appendChild(p),p.click(),document.body.removeChild(p)}return t.jsxs("div",{className:"mt-2 field-control !py-1 !bg-gray-50 !flex justify-between gap-x-8 items-center",children:[t.jsxs("div",{onClick:u,className:"!flex items-center rounded cursor-pointer gap-x-3",title:`Click to preview ${c}`,children:[a==="image"&&t.jsx("div",{className:"flex items-center justify-center ",children:t.jsx(te,{iconClass:"text-4xl",icon:"fluent-color:image-48"})}),a!=="image"&&t.jsx(te,{icon:gd[a],iconClass:"text-4xl"}),t.jsx("span",{className:"text-sm font-semibold text-center text-gray-700 truncate max-w-[300px]",children:c})]}),t.jsxs("div",{className:"flex gap-x-1 items-center",children:[t.jsx("button",{type:"button",className:"p-2",onClick:()=>b(r||e,n),title:`Download ${c}`,children:t.jsx(te,{icon:"streamline-flex:download-tray-solid"})}),i&&t.jsx("button",{type:"button",className:"p-2 text-lg text-red-500",onClick:i,children:t.jsx(te,{icon:"lets-icons:trash-duotone"})})]}),o&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",onClick:m,children:t.jsxs("div",{className:"relative bg-white p-8 rounded-lg w-full max-w-[90vw] max-h-[90vh] overflow-auto",onClick:v=>v.stopPropagation(),children:[t.jsx("button",{onClick:m,className:"absolute text-2xl font-bold text-gray-700 top-2 right-2","aria-label":"Close preview",children:"×"}),a==="image"?t.jsx("img",{src:e,alt:c,className:"max-w-full max-h-[80vh] mx-auto object-contain",crossOrigin:"anonymous"}):a==="pdf"?t.jsx("iframe",{src:r||e,title:c,className:"w-full h-[80vh] rounded border"}):null]})})]})}const xe=e=>{const n=typeof window!="undefined"?localStorage.getItem(e):"";try{return JSON.parse(n)}catch(i){return n}},Ys=(e,n)=>{const i=typeof n!="string"?JSON.stringify(n):n;return localStorage.setItem(e,i)},yd=5*1024*1024;function xd({onFileLoaded:e,disabled:n=!1,handleDeleteFile:i,multiple:o=!1,list:s=null,accept:a=[]}){const{uploadUrl:l,setApiActivityCount:r}=x.useContext(Ae),d=x.useRef(null),[u,m]=x.useState(s),[c,b]=x.useState(!1);x.useEffect(()=>{m(s)},[s]);const v=x.useMemo(()=>a==null?void 0:a.map(w=>w.value).join(", "),[a]),h=x.useMemo(()=>a==null?void 0:a.map(w=>w.label).join(", "),[a]),p=x.useCallback(async w=>{var E,k;const A=xe("token"),C=((E=xe("orgData"))==null?void 0:E.id)||xe("organizationId");try{const{data:I}=await Xe.post(l,{...w,service:"FORM",organizationId:C||""},{headers:{Authorization:`Bearer ${A}`}});return(k=I==null?void 0:I.data)==null?void 0:k.url}catch(I){throw console.error("File upload error:",I),new Error("Failed to upload file to server")}},[l]),g=x.useCallback(w=>new Promise((A,C)=>{const E=new FileReader;E.onloadend=async()=>{try{const k=E.result.replace(/^data:.*;base64,/,""),I=l?await p({base64:k,ext:`.${w.name.split(".").pop()}`,fileName:w.name}):E.result;A({base64:I,type:w.type,name:w.name})}catch(k){C(k)}},E.onerror=()=>C(new Error("File read failed")),E.readAsDataURL(w)}),[l,p]),f=x.useCallback(w=>{var C;const A=v?(C=v.split(","))==null?void 0:C.map(E=>E.trim()):[];for(const E of w){if(E.size>yd)return Ee.toast.error(`File "${E.name}" exceeds 5MB limit (${(E.size/1024/1024).toFixed(2)}MB)`),!1;if(A.length&&!A.some(k=>E.type===k||E.name.toLowerCase().endsWith(k.replace("*",""))))return Ee.toast.error(`File "${E.name}" is not an allowed type. Allowed: ${h||"any"}`),!1}return!0},[v,h]),N=x.useCallback(async w=>{const A=Array.from(w.target.files||[]);if(!(!A.length||c)){if(!f(A)){d.current&&(d.current.value="");return}try{b(!0),r==null||r(k=>k+1);const C=await Promise.all(A==null?void 0:A.map(g)),E=o&&u?[...u,...C]:C;m(E),e(E),Ee.toast.success(`Successfully uploaded ${A.length} file(s)`)}catch(C){console.error("Upload error:",C),Ee.toast.error("Failed to upload file(s). Please try again.")}finally{b(!1),r==null||r(C=>Math.max(0,C-1)),d.current&&(d.current.value="")}}},[c,f,g,e,o,u,r]),y=x.useCallback(w=>{c||(d.current&&(d.current.value=""),m(A=>{const C=w===void 0?null:(A==null?void 0:A.filter((E,k)=>k!==w))||null;return e(C),C}),i==null||i())},[i,e,c]),S=u&&u.length>0;return t.jsxs("div",{className:"flex flex-col items-start gap-2",children:[!n&&t.jsxs("div",{className:"!flex field-control !py-0 !px-0 relative",children:[t.jsx("input",{ref:d,type:"file",onChange:N,disabled:n||c,multiple:o,accept:v||"",className:`w-full text-sm text-gray-500 file:mr-4 flex-1 file:px-4 !py-1 !pl-1\r
1
+ (function(ge,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react/jsx-runtime"),require("react"),require("uuid"),require("react-datepicker"),require("@headlessui/react"),require("sonner"),require("axios"),require("react-currency-input-field"),require("react-dom"),require("react-hook-form"),require("@hookform/resolvers"),require("yup"),require("papaparse"),require("xlsx"),require("react-router-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","uuid","react-datepicker","@headlessui/react","sonner","axios","react-currency-input-field","react-dom","react-hook-form","@hookform/resolvers","yup","papaparse","xlsx","react-router-dom"],t):(ge=typeof globalThis!="undefined"?globalThis:ge||self,t(ge.FormBuilder={},ge.jsxRuntime,ge.React,ge.uuid,ge.DatePicker,ge.react,ge.sonner,ge.axios,ge.CurrencyInput,ge.ReactDOM,ge.reactHookForm,ge.resolvers,ge.yup,ge.Papa,ge.XLSX,ge.reactRouterDom))})(this,function(ge,t,x,Ce,dr,re,Ee,Xe,ei,ur,Ve,fs,cr,mr,br,vr){"use strict";function ps(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const i in e)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:()=>e[i]})}}return n.default=e,Object.freeze(n)}const ne=ps(cr),gs=ps(br),Ae=x.createContext(void 0),ys={title:"",description:"",id:Ce.v4(),questionData:[],disabled:!1,isHidden:!1},xs=({children:e,onChange:n,onLogAction:i})=>{const[o,s]=x.useState(!0),[a,l]=x.useState({}),[r,d]=x.useState({}),[u,m]=x.useState([ys]),[c,b]=x.useState(()=>{try{const V=sessionStorage.getItem("editor_past");return V?JSON.parse(V):[]}catch(V){return[]}}),[v,h]=x.useState(()=>{try{const V=sessionStorage.getItem("editor_future");return V?JSON.parse(V):[]}catch(V){return[]}});x.useEffect(()=>{n&&n(u)},[u,n]),x.useEffect(()=>{try{sessionStorage.setItem("editor_past",JSON.stringify(c))}catch(V){console.warn("Could not save editor_past to sessionStorage",V)}},[c]),x.useEffect(()=>{try{sessionStorage.setItem("editor_future",JSON.stringify(v))}catch(V){console.warn("Could not save editor_future to sessionStorage",V)}},[v]);const p=x.useRef(Date.now()),g=x.useCallback(V=>{m(G=>{const H=typeof V=="function"?V(G):V;if(JSON.stringify(G)!==JSON.stringify(H)){const $=Date.now();b(F=>{if(F.length>0&&JSON.stringify(F[F.length-1])===JSON.stringify(G))return F;if($-p.current<800&&F.length>0)return p.current=$,F;p.current=$;const q=[...F,G];return q.length>20?q.slice(q.length-20):q}),h([])}return H})},[]),f=x.useCallback(()=>{if(c.length===0)return;const V=c[c.length-1],G=c.slice(0,c.length-1);b(G),h([u,...v]),m(V),i==null||i("UNDO",null)},[c,v,u,i]),N=x.useCallback(()=>{if(v.length===0)return;const V=v[0],G=v.slice(1);h(G),b([...c,u]),m(V),i==null||i("REDO",null)},[c,v,u,i]),y=u,S=c.length>0,w=v.length>0,[A,C]=x.useState(!1),[E,k]=x.useState(null),[I,P]=x.useState([0]),[T,O]=x.useState(""),[M,_]=x.useState(0),B=x.useCallback(()=>{},[]),K=x.useCallback(()=>{const V=Ce.v4();g(G=>[...G,{...ys,id:V}]),k(V),P([y.length]),i==null||i("ADD_SECTION",{sectionId:V})},[y,i,g]),D=x.useCallback(V=>{g(G=>G.filter(H=>H.id!==V)),k(null),i==null||i("REMOVE_SECTION",{sectionId:V})},[i,g]),L=x.useCallback((V,G)=>{const H=y.find(F=>F.id===G),$=H==null?void 0:H.questionData.find(F=>F.id===V);$&&(g(F=>F==null?void 0:F.map(q=>q.id===G?{...q,questionData:q==null?void 0:q.questionData.filter(R=>$.type==="grid"?R.gridId!==$.id&&R.id!==$.id:R.id!==V)}:q)),i==null||i("REMOVE_ELEMENT",{sectionId:G,elementId:V}))},[y,g,i]),z=x.useCallback((V,G)=>{const H=y.find(R=>R.id===G);if(!H)return;const $=H==null?void 0:H.questionData.findIndex(R=>R.id===V);if($===-1)return;const F=H==null?void 0:H.questionData[$],q=(R,Z={})=>({...JSON.parse(JSON.stringify(R)),id:Ce.v4(),...Z});g(R=>R==null?void 0:R.map(Z=>{var ee;if(Z.id!==G)return Z;const J=[...Z.questionData];if(F.type==="grid"){const ae=(ee=J==null?void 0:J.map((pe,Ne)=>({e:pe,i:Ne})).filter(({e:pe})=>pe.id===F.id||pe.gridId===F.id))==null?void 0:ee.map(({i:pe})=>pe),ue=ae.length?Math.max(...ae)+1:$+1,me=Ce.v4(),ye=q(F,{});ye.id=me;const be=J.filter(pe=>pe.gridId===F.id),we=be==null?void 0:be.map(pe=>q(pe,{gridId:me})),Me=[...J.slice(0,ue),ye,...we,...J.slice(ue)];return{...Z,questionData:Me}}else if(F.gridId){const{gridId:ae,gridPosition:ue,...me}=F,ye=q(me,{}),be=J.reduce((Me,pe,Ne)=>pe.id===F.gridId||pe.gridId===F.gridId?Ne:Me,$),we=[...J.slice(0,be+1),ye,...J.slice(be+1)];return{...Z,questionData:we}}else{const ae=q(F,{}),ue=[...J.slice(0,$+1),ae,...J.slice($+1)];return{...Z,questionData:ue}}})),i==null||i("DUPLICATE_ELEMENT",{sectionId:G,elementId:V})},[y,g,i]),U=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>$.id===G?{...$,questionData:V}:$)),i==null||i("UPDATE_ELEMENT_POSITION",{sectionId:G})},[g,i]),W=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>$.id===G?{...$,questionData:[...$==null?void 0:$.questionData,V]}:$)),i==null||i("ADD_ELEMENT",{sectionId:G,element:V})},[g,i]),Y=x.useCallback((V,G,H)=>{g($=>$==null?void 0:$.map(F=>F.id===G?{...F,questionData:[...F==null?void 0:F.questionData.slice(0,H),V,...F==null?void 0:F.questionData.slice(H)]}:F)),i==null||i("ADD_ELEMENT_IN_POSITION",{sectionId:G,element:V,index:H})},[g,i]),X=x.useCallback((V,G,H)=>{g($=>$==null?void 0:$.map(F=>{var q;return F.id===H?{...F,questionData:(q=F==null?void 0:F.questionData)==null?void 0:q.map(R=>{var Z;return R.type==="grid"&&R.gridData?{...R,gridData:(Z=R.gridData)==null?void 0:Z.map((J,ee)=>ee===V?{...J,...G}:J).concat(V>=R.gridData.length?{...G}:[])}:R})}:F})),i==null||i("UPDATE_GRID_ELEMENT",{sectionId:H,gridIndex:V,element:G})},[g,i]),ie=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>{var F;return $.id===G?{...$,questionData:(F=$==null?void 0:$.questionData)==null?void 0:F.map(q=>q.id===V.id?{...q,...V}:q)}:$})),i==null||i("UPDATE_ELEMENT",{sectionId:G,value:V})},[g,i]),se=x.useCallback(V=>{const{draggedId:G,sectionId:H,targetIndex:$,targetId:F,targetGridId:q,targetCol:R}=V;g(Z=>Z.map(J=>{if(J.id!==H)return J;const ee=[...J==null?void 0:J.questionData],ae=ee.findIndex(me=>me.id===G);if(ae===-1)return J;const ue={...ee[ae]};if(q!==void 0&&R!==void 0){if(ue.type==="grid")return J;const me=ee.findIndex(be=>{var we;return be.id!==G&&be.gridId===q&&((we=be.gridPosition)==null?void 0:we.col)===R});let ye=ee.map(be=>be.id===G?{...be,gridId:q,gridPosition:{col:R}}:be);return me!==-1&&(ye=ye.map((be,we)=>{if(we!==me)return be;const Me={...be};return delete Me.gridId,delete Me.gridPosition,Me})),{...J,questionData:ye}}if(ue.gridId&&$!==void 0&&q===void 0){const me={...ue};delete me.gridId,delete me.gridPosition;const ye=ee.filter(we=>we.id!==G),be=Math.min($,ye.length);return ye.splice(be,0,me),{...J,questionData:ye}}if(!ue.gridId&&$!==void 0&&q===void 0&&!F){ee.splice(ae,1);const me=Math.min($,ee.length);return ee.splice(me,0,ue),{...J,questionData:ee}}if(F){const me=ee.findIndex(ye=>ye.id===F);return me===-1?J:(ee.splice(ae,1),ee.splice(me,0,ue),{...J,questionData:ee})}return J})),i==null||i("MOVE_ELEMENT",V)},[g,i]),Q=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>$.id===G?{...$,...V}:$)),i==null||i("UPDATE_SECTION",{sectionId:G,value:V})},[g,i]),j=x.useMemo(()=>({formData:y,setFormData:g,handleDragStop:B,removeElement:L,elementData:r,setElementData:d,updateElementPosition:U,addElement:W,addElementInPosition:Y,updateElement:ie,addSection:K,removeSection:D,updateSection:Q,isDragging:A,setIsDragging:C,selectedSection:E,setSelectedSection:k,activeSections:I,setActiveSections:P,updateGridElement:X,answerData:a,setAnswerData:l,uploadUrl:T,setUploadUrl:O,apiActivityCount:M,setApiActivityCount:_,duplicateElement:z,moveElement:se,showPreview:o,setShowPreview:s,undo:f,redo:N,canUndo:S,canRedo:w}),[y,B,L,r,U,W,Y,ie,K,D,Q,A,E,I,X,a,T,M,z,se,o,f,N,S,w]);return t.jsx(Ae.Provider,{value:j,children:e})};function Ss(e){var n,i,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(n=0;n<s;n++)e[n]&&(i=Ss(e[n]))&&(o&&(o+=" "),o+=i)}else for(i in e)e[i]&&(o&&(o+=" "),o+=i);return o}function de(){for(var e,n,i=0,o="",s=arguments.length;i<s;i++)(e=arguments[i])&&(n=Ss(e))&&(o&&(o+=" "),o+=n);return o}function hr({type:e="calendar",className:n}){return t.jsx(t.Fragment,{children:e==="calendar"?t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[t.jsx("path",{d:"M6.66406 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M13.3359 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2.91406 7.57495H17.0807",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M17.5 7.08341V14.1667C17.5 16.6667 16.25 18.3334 13.3333 18.3334H6.66667C3.75 18.3334 2.5 16.6667 2.5 14.1667V7.08341C2.5 4.58341 3.75 2.91675 6.66667 2.91675H13.3333C16.25 2.91675 17.5 4.58341 17.5 7.08341Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M13.0762 11.4167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M13.0762 13.9167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M9.99803 11.4167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M9.99803 13.9167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M6.91209 11.4167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M6.91209 13.9167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[t.jsx("path",{d:"M10 6.66663V10.8333",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M10.0026 18.3333C5.9776 18.3333 2.71094 15.0667 2.71094 11.0417C2.71094 7.01667 5.9776 3.75 10.0026 3.75C14.0276 3.75 17.2943 7.01667 17.2943 11.0417",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M7.5 1.66663H12.5",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M12.4141 15.4167V14.4501C12.4141 13.2584 13.2641 12.7667 14.2974 13.3667L15.1307 13.8501L15.9641 14.3334C16.9974 14.9334 16.9974 15.9084 15.9641 16.5084L15.1307 16.9917L14.2974 17.4751C13.2641 18.0751 12.4141 17.5834 12.4141 16.3917V15.4167Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const Ji=({value:e=null,onGetValue:n,readOnly:i=!1,dateFormat:o="dd/MM/yyyy",name:s,placeholder:a="Select date",minDate:l,maxDate:r,showYearDropdown:d})=>{const u=h=>{if(!h)return null;const p=new Date(h);return isNaN(p.getTime())?null:p},m=u(e),[c,b]=x.useState(m);x.useEffect(()=>{const h=u(e);(h&&c&&h.getTime()!==c.getTime()||!h&&c||h&&!c)&&b(h)},[e]),x.useEffect(()=>{n&&n(s,c)},[c,n,s]);const v=h=>{b(h)};return t.jsx("div",{className:"builder_date__picker",children:t.jsx(dr,{showIcon:!0,icon:t.jsx(hr,{className:"react-datepicker__calendar-icon"}),showPopperArrow:!1,dateFormat:o,disabled:i,selected:c,onChange:v,className:"field-control",portalId:"root-portal",placeholderText:a,minDate:l,maxDate:r,showYearDropdown:d,scrollableYearDropdown:!0,yearDropdownItemNumber:40})})};function fr({element:e,validationData:n}){const{register:i=()=>({}),setValue:o,watch:s}=n||{};let a;return s&&(a=s()[e.id]),x.useEffect(()=>{i(e.id)},[e.id]),t.jsx(Ji,{name:e.id,value:a,onGetValue:o,readOnly:n==null?void 0:n.isReadOnly,dateFormat:(e==null?void 0:e.dateFormat)||"dd/MM/yyyy",minDate:e==null?void 0:e.minDate,maxDate:e==null?void 0:e.maxDate,showYearDropdown:e==null?void 0:e.allowYearPicker})}function Zi({element:e,validationData:n}){var o;const{register:i=()=>({})}=n||{};return t.jsx("div",{children:t.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"",type:(e==null?void 0:e.inputType)||"text",className:de("field-control",e==null?void 0:e.customClass),...i(e==null?void 0:e.id),disabled:n==null?void 0:n.isReadOnly,inputMode:(e==null?void 0:e.inputMode)||void 0,"aria-invalid":!!((o=n==null?void 0:n.errors)!=null&&o[e==null?void 0:e.id]),pattern:(e==null?void 0:e.pattern)||void 0})})}function pr(e,n){const i=e.icons,o=e.aliases||Object.create(null),s=Object.create(null);function a(l){if(i[l])return s[l]=[];if(!(l in s)){s[l]=null;const r=o[l]&&o[l].parent,d=r&&a(r);d&&(s[l]=[r].concat(d))}return s[l]}return Object.keys(i).concat(Object.keys(o)).forEach(a),s}const ws=Object.freeze({left:0,top:0,width:16,height:16}),ni=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Xi=Object.freeze({...ws,...ni}),Qi=Object.freeze({...Xi,body:"",hidden:!1});function gr(e,n){const i={};!e.hFlip!=!n.hFlip&&(i.hFlip=!0),!e.vFlip!=!n.vFlip&&(i.vFlip=!0);const o=((e.rotate||0)+(n.rotate||0))%4;return o&&(i.rotate=o),i}function Ns(e,n){const i=gr(e,n);for(const o in Qi)o in ni?o in e&&!(o in i)&&(i[o]=ni[o]):o in n?i[o]=n[o]:o in e&&(i[o]=e[o]);return i}function yr(e,n,i){const o=e.icons,s=e.aliases||Object.create(null);let a={};function l(r){a=Ns(o[r]||s[r],a)}return l(n),i.forEach(l),Ns(e,a)}function As(e,n){const i=[];if(typeof e!="object"||typeof e.icons!="object")return i;e.not_found instanceof Array&&e.not_found.forEach(s=>{n(s,null),i.push(s)});const o=pr(e);for(const s in o){const a=o[s];a&&(n(s,yr(e,s,a)),i.push(s))}return i}const xr={provider:"",aliases:{},not_found:{},...ws};function Ri(e,n){for(const i in n)if(i in e&&typeof e[i]!=typeof n[i])return!1;return!0}function Cs(e){if(typeof e!="object"||e===null)return null;const n=e;if(typeof n.prefix!="string"||!e.icons||typeof e.icons!="object"||!Ri(e,xr))return null;const i=n.icons;for(const s in i){const a=i[s];if(!s||typeof a.body!="string"||!Ri(a,Qi))return null}const o=n.aliases||Object.create(null);for(const s in o){const a=o[s],l=a.parent;if(!s||typeof l!="string"||!i[l]&&!o[l]||!Ri(a,Qi))return null}return n}const ks=Object.create(null);function Sr(e,n){return{provider:e,prefix:n,icons:Object.create(null),missing:new Set}}function dn(e,n){const i=ks[e]||(ks[e]=Object.create(null));return i[n]||(i[n]=Sr(e,n))}function Ms(e,n){return Cs(n)?As(n,(i,o)=>{o?e.icons[i]=o:e.missing.add(i)}):[]}function wr(e,n,i){try{if(typeof i.body=="string")return e.icons[n]={...i},!0}catch(o){}return!1}const Es=/^[a-z0-9]+(-[a-z0-9]+)*$/,ii=(e,n,i,o="")=>{const s=e.split(":");if(e.slice(0,1)==="@"){if(s.length<2||s.length>3)return null;o=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const r=s.pop(),d=s.pop(),u={provider:s.length>0?s[0]:o,prefix:d,name:r};return n&&!oi(u)?null:u}const a=s[0],l=a.split("-");if(l.length>1){const r={provider:o,prefix:l.shift(),name:l.join("-")};return n&&!oi(r)?null:r}if(i&&o===""){const r={provider:o,prefix:"",name:a};return n&&!oi(r,i)?null:r}return null},oi=(e,n)=>e?!!((n&&e.prefix===""||e.prefix)&&e.name):!1;let En=!1;function Ts(e){return typeof e=="boolean"&&(En=e),En}function Ps(e){const n=typeof e=="string"?ii(e,!0,En):e;if(n){const i=dn(n.provider,n.prefix),o=n.name;return i.icons[o]||(i.missing.has(o)?null:void 0)}}function Nr(e,n){const i=ii(e,!0,En);if(!i)return!1;const o=dn(i.provider,i.prefix);return n?wr(o,i.name,n):(o.missing.add(i.name),!0)}function Ar(e,n){if(typeof e!="object")return!1;if(typeof n!="string"&&(n=e.provider||""),En&&!n&&!e.prefix){let s=!1;return Cs(e)&&(e.prefix="",As(e,(a,l)=>{Nr(a,l)&&(s=!0)})),s}const i=e.prefix;if(!oi({prefix:i,name:"a"}))return!1;const o=dn(n,i);return!!Ms(o,e)}const Ls=Object.freeze({width:null,height:null}),Bs=Object.freeze({...Ls,...ni}),Cr=/(-?[0-9.]*[0-9]+[0-9.]*)/g,kr=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Is(e,n,i){if(n===1)return e;if(i=i||100,typeof e=="number")return Math.ceil(e*n*i)/i;if(typeof e!="string")return e;const o=e.split(Cr);if(o===null||!o.length)return e;const s=[];let a=o.shift(),l=kr.test(a);for(;;){if(l){const r=parseFloat(a);isNaN(r)?s.push(a):s.push(Math.ceil(r*n*i)/i)}else s.push(a);if(a=o.shift(),a===void 0)return s.join("");l=!l}}function Mr(e,n="defs"){let i="";const o=e.indexOf("<"+n);for(;o>=0;){const s=e.indexOf(">",o),a=e.indexOf("</"+n);if(s===-1||a===-1)break;const l=e.indexOf(">",a);if(l===-1)break;i+=e.slice(s+1,a).trim(),e=e.slice(0,o).trim()+e.slice(l+1)}return{defs:i,content:e}}function Er(e,n){return e?"<defs>"+e+"</defs>"+n:n}function Tr(e,n,i){const o=Mr(e);return Er(o.defs,n+o.content+i)}const Pr=e=>e==="unset"||e==="undefined"||e==="none";function Lr(e,n){const i={...Xi,...e},o={...Bs,...n},s={left:i.left,top:i.top,width:i.width,height:i.height};let a=i.body;[i,o].forEach(p=>{const g=[],f=p.hFlip,N=p.vFlip;let y=p.rotate;f?N?y+=2:(g.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),g.push("scale(-1 1)"),s.top=s.left=0):N&&(g.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),g.push("scale(1 -1)"),s.top=s.left=0);let S;switch(y<0&&(y-=Math.floor(y/4)*4),y=y%4,y){case 1:S=s.height/2+s.top,g.unshift("rotate(90 "+S.toString()+" "+S.toString()+")");break;case 2:g.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:S=s.width/2+s.left,g.unshift("rotate(-90 "+S.toString()+" "+S.toString()+")");break}y%2===1&&(s.left!==s.top&&(S=s.left,s.left=s.top,s.top=S),s.width!==s.height&&(S=s.width,s.width=s.height,s.height=S)),g.length&&(a=Tr(a,'<g transform="'+g.join(" ")+'">',"</g>"))});const l=o.width,r=o.height,d=s.width,u=s.height;let m,c;l===null?(c=r===null?"1em":r==="auto"?u:r,m=Is(c,d/u)):(m=l==="auto"?d:l,c=r===null?Is(m,u/d):r==="auto"?u:r);const b={},v=(p,g)=>{Pr(g)||(b[p]=g.toString())};v("width",m),v("height",c);const h=[s.left,s.top,d,u];return b.viewBox=h.join(" "),{attributes:b,viewBox:h,body:a}}const Br=/\sid="(\S+)"/g,Ir="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Dr=0;function _r(e,n=Ir){const i=[];let o;for(;o=Br.exec(e);)i.push(o[1]);if(!i.length)return e;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return i.forEach(a=>{const l=typeof n=="function"?n(a):n+(Dr++).toString(),r=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+r+')([")]|\\.[a-z])',"g"),"$1"+l+s+"$3")}),e=e.replace(new RegExp(s,"g"),""),e}const eo=Object.create(null);function Or(e,n){eo[e]=n}function no(e){return eo[e]||eo[""]}function io(e){let n;if(typeof e.resources=="string")n=[e.resources];else if(n=e.resources,!(n instanceof Array)||!n.length)return null;return{resources:n,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const oo=Object.create(null),Tn=["https://api.simplesvg.com","https://api.unisvg.com"],si=[];for(;Tn.length>0;)Tn.length===1||Math.random()>.5?si.push(Tn.shift()):si.push(Tn.pop());oo[""]=io({resources:["https://api.iconify.design"].concat(si)});function Kr(e,n){const i=io(n);return i===null?!1:(oo[e]=i,!0)}function so(e){return oo[e]}let Ds=(()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch(n){}})();function Hr(e,n){const i=so(e);if(!i)return 0;let o;if(!i.maxURL)o=0;else{let s=0;i.resources.forEach(l=>{s=Math.max(s,l.length)});const a=n+".json?icons=";o=i.maxURL-s-i.path.length-a.length}return o}function Gr(e){return e===404}const Fr=(e,n,i)=>{const o=[],s=Hr(e,n),a="icons";let l={type:a,provider:e,prefix:n,icons:[]},r=0;return i.forEach((d,u)=>{r+=d.length+1,r>=s&&u>0&&(o.push(l),l={type:a,provider:e,prefix:n,icons:[]},r=d.length),l.icons.push(d)}),o.push(l),o};function Vr(e){if(typeof e=="string"){const n=so(e);if(n)return n.path}return"/"}const zr={prepare:Fr,send:(e,n,i)=>{if(!Ds){i("abort",424);return}let o=Vr(n.provider);switch(n.type){case"icons":{const a=n.prefix,r=n.icons.join(","),d=new URLSearchParams({icons:r});o+=a+".json?"+d.toString();break}case"custom":{const a=n.uri;o+=a.slice(0,1)==="/"?a.slice(1):a;break}default:i("abort",400);return}let s=503;Ds(e+o).then(a=>{const l=a.status;if(l!==200){setTimeout(()=>{i(Gr(l)?"abort":"next",l)});return}return s=501,a.json()}).then(a=>{if(typeof a!="object"||a===null){setTimeout(()=>{a===404?i("abort",a):i("next",s)});return}setTimeout(()=>{i("success",a)})}).catch(()=>{i("next",s)})}};function _s(e,n){e.forEach(i=>{const o=i.loaderCallbacks;o&&(i.loaderCallbacks=o.filter(s=>s.id!==n))})}function Wr(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const n=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!n.length)return;let i=!1;const o=e.provider,s=e.prefix;n.forEach(a=>{const l=a.icons,r=l.pending.length;l.pending=l.pending.filter(d=>{if(d.prefix!==s)return!0;const u=d.name;if(e.icons[u])l.loaded.push({provider:o,prefix:s,name:u});else if(e.missing.has(u))l.missing.push({provider:o,prefix:s,name:u});else return i=!0,!0;return!1}),l.pending.length!==r&&(i||_s([e],a.id),a.callback(l.loaded.slice(0),l.missing.slice(0),l.pending.slice(0),a.abort))})}))}let $r=0;function jr(e,n,i){const o=$r++,s=_s.bind(null,i,o);if(!n.pending.length)return s;const a={id:o,icons:n,callback:e,abort:s};return i.forEach(l=>{(l.loaderCallbacks||(l.loaderCallbacks=[])).push(a)}),s}function Ur(e){const n={loaded:[],missing:[],pending:[]},i=Object.create(null);e.sort((s,a)=>s.provider!==a.provider?s.provider.localeCompare(a.provider):s.prefix!==a.prefix?s.prefix.localeCompare(a.prefix):s.name.localeCompare(a.name));let o={provider:"",prefix:"",name:""};return e.forEach(s=>{if(o.name===s.name&&o.prefix===s.prefix&&o.provider===s.provider)return;o=s;const a=s.provider,l=s.prefix,r=s.name,d=i[a]||(i[a]=Object.create(null)),u=d[l]||(d[l]=dn(a,l));let m;r in u.icons?m=n.loaded:l===""||u.missing.has(r)?m=n.missing:m=n.pending;const c={provider:a,prefix:l,name:r};m.push(c)}),n}function qr(e,n=!0,i=!1){const o=[];return e.forEach(s=>{const a=typeof s=="string"?ii(s,n,i):s;a&&o.push(a)}),o}const Yr={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Jr(e,n,i,o){const s=e.resources.length,a=e.random?Math.floor(Math.random()*s):e.index;let l;if(e.random){let A=e.resources.slice(0);for(l=[];A.length>1;){const C=Math.floor(Math.random()*A.length);l.push(A[C]),A=A.slice(0,C).concat(A.slice(C+1))}l=l.concat(A)}else l=e.resources.slice(a).concat(e.resources.slice(0,a));const r=Date.now();let d="pending",u=0,m,c=null,b=[],v=[];typeof o=="function"&&v.push(o);function h(){c&&(clearTimeout(c),c=null)}function p(){d==="pending"&&(d="aborted"),h(),b.forEach(A=>{A.status==="pending"&&(A.status="aborted")}),b=[]}function g(A,C){C&&(v=[]),typeof A=="function"&&v.push(A)}function f(){return{startTime:r,payload:n,status:d,queriesSent:u,queriesPending:b.length,subscribe:g,abort:p}}function N(){d="failed",v.forEach(A=>{A(void 0,m)})}function y(){b.forEach(A=>{A.status==="pending"&&(A.status="aborted")}),b=[]}function S(A,C,E){const k=C!=="success";switch(b=b.filter(I=>I!==A),d){case"pending":break;case"failed":if(k||!e.dataAfterTimeout)return;break;default:return}if(C==="abort"){m=E,N();return}if(k){m=E,b.length||(l.length?w():N());return}if(h(),y(),!e.random){const I=e.resources.indexOf(A.resource);I!==-1&&I!==e.index&&(e.index=I)}d="completed",v.forEach(I=>{I(E)})}function w(){if(d!=="pending")return;h();const A=l.shift();if(A===void 0){if(b.length){c=setTimeout(()=>{h(),d==="pending"&&(y(),N())},e.timeout);return}N();return}const C={status:"pending",resource:A,callback:(E,k)=>{S(C,E,k)}};b.push(C),u++,c=setTimeout(w,e.rotate),i(A,n,C.callback)}return setTimeout(w),f}function Os(e){const n={...Yr,...e};let i=[];function o(){i=i.filter(r=>r().status==="pending")}function s(r,d,u){const m=Jr(n,r,d,(c,b)=>{o(),u&&u(c,b)});return i.push(m),m}function a(r){return i.find(d=>r(d))||null}return{query:s,find:a,setIndex:r=>{n.index=r},getIndex:()=>n.index,cleanup:o}}function Ks(){}const ao=Object.create(null);function Zr(e){if(!ao[e]){const n=so(e);if(!n)return;const i=Os(n),o={config:n,redundancy:i};ao[e]=o}return ao[e]}function Xr(e,n,i){let o,s;if(typeof e=="string"){const a=no(e);if(!a)return i(void 0,424),Ks;s=a.send;const l=Zr(e);l&&(o=l.redundancy)}else{const a=io(e);if(a){o=Os(a);const l=e.resources?e.resources[0]:"",r=no(l);r&&(s=r.send)}}return!o||!s?(i(void 0,424),Ks):o.query(n,s,i)().abort}function Hs(){}function Qr(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,Wr(e)}))}function Rr(e){const n=[],i=[];return e.forEach(o=>{(o.match(Es)?n:i).push(o)}),{valid:n,invalid:i}}function Pn(e,n,i){function o(){const s=e.pendingIcons;n.forEach(a=>{s&&s.delete(a),e.icons[a]||e.missing.add(a)})}if(i&&typeof i=="object")try{if(!Ms(e,i).length){o();return}}catch(s){console.error(s)}o(),Qr(e)}function Gs(e,n){e instanceof Promise?e.then(i=>{n(i)}).catch(()=>{n(null)}):n(e)}function ed(e,n){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(n).sort():e.iconsToLoad=n,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:i,prefix:o}=e,s=e.iconsToLoad;if(delete e.iconsToLoad,!s||!s.length)return;const a=e.loadIcon;if(e.loadIcons&&(s.length>1||!a)){Gs(e.loadIcons(s,o,i),m=>{Pn(e,s,m)});return}if(a){s.forEach(m=>{const c=a(m,o,i);Gs(c,b=>{const v=b?{prefix:o,icons:{[m]:b}}:null;Pn(e,[m],v)})});return}const{valid:l,invalid:r}=Rr(s);if(r.length&&Pn(e,r,null),!l.length)return;const d=o.match(Es)?no(i):null;if(!d){Pn(e,l,null);return}d.prepare(i,o,l).forEach(m=>{Xr(i,m,c=>{Pn(e,m.icons,c)})})}))}const nd=(e,n)=>{const i=qr(e,!0,Ts()),o=Ur(i);if(!o.pending.length){let d=!0;return n&&setTimeout(()=>{d&&n(o.loaded,o.missing,o.pending,Hs)}),()=>{d=!1}}const s=Object.create(null),a=[];let l,r;return o.pending.forEach(d=>{const{provider:u,prefix:m}=d;if(m===r&&u===l)return;l=u,r=m,a.push(dn(u,m));const c=s[u]||(s[u]=Object.create(null));c[m]||(c[m]=[])}),o.pending.forEach(d=>{const{provider:u,prefix:m,name:c}=d,b=dn(u,m),v=b.pendingIcons||(b.pendingIcons=new Set);v.has(c)||(v.add(c),s[u][m].push(c))}),a.forEach(d=>{const u=s[d.provider][d.prefix];u.length&&ed(d,u)}),n?jr(n,o,a):Hs};function id(e,n){const i={...e};for(const o in n){const s=n[o],a=typeof s;o in Ls?(s===null||s&&(a==="string"||a==="number"))&&(i[o]=s):a===typeof i[o]&&(i[o]=o==="rotate"?s%4:s)}return i}const od=/[\s,]+/;function sd(e,n){n.split(od).forEach(i=>{switch(i.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function ad(e,n=0){const i=e.replace(/^-?[0-9.]*/,"");function o(s){for(;s<0;)s+=4;return s%4}if(i===""){const s=parseInt(e);return isNaN(s)?0:o(s)}else if(i!==e){let s=0;switch(i){case"%":s=25;break;case"deg":s=90}if(s){let a=parseFloat(e.slice(0,e.length-i.length));return isNaN(a)?0:(a=a/s,a%1===0?o(a):0)}}return n}function td(e,n){let i=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const o in n)i+=" "+o+'="'+n[o]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+i+">"+e+"</svg>"}function ld(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function rd(e){return"data:image/svg+xml,"+ld(e)}function dd(e){return'url("'+rd(e)+'")'}let Ln;function ud(){try{Ln=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch(e){Ln=null}}function cd(e){return Ln===void 0&&ud(),Ln?Ln.createHTML(e):e}const Fs={...Bs,inline:!1},md={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},bd={display:"inline-block"},to={backgroundColor:"currentColor"},Vs={backgroundColor:"transparent"},zs={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Ws={WebkitMask:to,mask:to,background:Vs};for(const e in Ws){const n=Ws[e];for(const i in zs)n[e+i]=zs[i]}const vd={...Fs,inline:!0};function $s(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const hd=(e,n,i)=>{const o=n.inline?vd:Fs,s=id(o,n),a=n.mode||"svg",l={},r=n.style||{},d={...a==="svg"?md:{}};if(i){const g=ii(i,!1,!0);if(g){const f=["iconify"],N=["provider","prefix"];for(const y of N)g[y]&&f.push("iconify--"+g[y]);d.className=f.join(" ")}}for(let g in n){const f=n[g];if(f!==void 0)switch(g){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":d.ref=f;break;case"className":d[g]=(d[g]?d[g]+" ":"")+f;break;case"inline":case"hFlip":case"vFlip":s[g]=f===!0||f==="true"||f===1;break;case"flip":typeof f=="string"&&sd(s,f);break;case"color":l.color=f;break;case"rotate":typeof f=="string"?s[g]=ad(f):typeof f=="number"&&(s[g]=f);break;case"ariaHidden":case"aria-hidden":f!==!0&&f!=="true"&&delete d["aria-hidden"];break;default:o[g]===void 0&&(d[g]=f)}}const u=Lr(e,s),m=u.attributes;if(s.inline&&(l.verticalAlign="-0.125em"),a==="svg"){d.style={...l,...r},Object.assign(d,m);let g=0,f=n.id;return typeof f=="string"&&(f=f.replace(/-/g,"_")),d.dangerouslySetInnerHTML={__html:cd(_r(u.body,f?()=>f+"ID"+g++:"iconifyReact"))},x.createElement("svg",d)}const{body:c,width:b,height:v}=e,h=a==="mask"||(a==="bg"?!1:c.indexOf("currentColor")!==-1),p=td(c,{...m,width:b+"",height:v+""});return d.style={...l,"--svg":dd(p),width:$s(m.width),height:$s(m.height),...bd,...h?to:Vs,...r},x.createElement("span",d)};if(Ts(!0),Or("",zr),typeof document!="undefined"&&typeof window!="undefined"){const e=window;if(e.IconifyPreload!==void 0){const n=e.IconifyPreload,i="Invalid IconifyPreload syntax.";typeof n=="object"&&n!==null&&(n instanceof Array?n:[n]).forEach(o=>{try{(typeof o!="object"||o===null||o instanceof Array||typeof o.icons!="object"||typeof o.prefix!="string"||!Ar(o))&&console.error(i)}catch(s){console.error(i)}})}if(e.IconifyProviders!==void 0){const n=e.IconifyProviders;if(typeof n=="object"&&n!==null)for(let i in n){const o="IconifyProviders["+i+"] is invalid.";try{const s=n[i];if(typeof s!="object"||!s||s.resources===void 0)continue;Kr(i,s)||console.error(o)}catch(s){console.error(o)}}}}function js(e){const[n,i]=x.useState(!!e.ssr),[o,s]=x.useState({});function a(v){if(v){const h=e.icon;if(typeof h=="object")return{name:"",data:h};const p=Ps(h);if(p)return{name:h,data:p}}return{name:""}}const[l,r]=x.useState(a(!!e.ssr));function d(){const v=o.callback;v&&(v(),s({}))}function u(v){if(JSON.stringify(l)!==JSON.stringify(v))return d(),r(v),!0}function m(){var v;const h=e.icon;if(typeof h=="object"){u({name:"",data:h});return}const p=Ps(h);if(u({name:h,data:p}))if(p===void 0){const g=nd([h],m);s({callback:g})}else p&&((v=e.onLoad)===null||v===void 0||v.call(e,h))}x.useEffect(()=>(i(!0),d),[]),x.useEffect(()=>{n&&m()},[e.icon,n]);const{name:c,data:b}=l;return b?hd({...Xi,...b},e,c):e.children?e.children:e.fallback?e.fallback:x.createElement("span",{})}const Us=x.forwardRef((e,n)=>js({...e,_ref:n}));x.forwardRef((e,n)=>js({inline:!0,...e,_ref:n}));function te({icon:e,iconClass:n}){return t.jsx(t.Fragment,{children:t.jsx(Us,{icon:e,className:n})})}function lo({element:e,validationData:n,placeholder:i}){var c;const{register:o=()=>({}),setValue:s,isReadOnly:a,watch:l,getValues:r}=n||{},[d,u]=x.useState(()=>{const b=r==null?void 0:r(e.id);return Array.isArray(b)?b:[]}),m=x.useMemo(()=>d==null?void 0:d.map(b=>b.label).join(", "),[d]);return x.useEffect(()=>{o(e.id)},[e.id,o]),x.useEffect(()=>{if(!l)return;const b=l(v=>{const h=v[e.id];h!==void 0&&u(Array.isArray(h)?h:[])});return()=>{var v;return(v=b.unsubscribe)==null?void 0:v.call(b)}},[l,e.id]),t.jsx("div",{className:"custom-select",children:t.jsx(re.Listbox,{value:d||[],onChange:b=>{u(b),s==null||s(e.id,b)},multiple:!0,disabled:a,by:"value",children:t.jsxs("div",{className:"custom-select__wrapper",children:[t.jsxs(re.Listbox.Button,{className:"custom-select__control field-control",disabled:a,children:[t.jsx("span",{className:"custom-select__value",children:(d==null?void 0:d.length)>0?m:t.jsx("span",{className:"custom-select__placeholder",children:i!=null?i:" Select options"})}),t.jsx("span",{className:"custom-select__icon",children:t.jsx(te,{icon:"lucide:chevron-down"})})]}),t.jsx(re.Transition,{as:x.Fragment,leave:"custom-select__transition",children:t.jsx(re.Listbox.Options,{anchor:"bottom start",className:"custom-select__options",children:(c=e==null?void 0:e.options)==null?void 0:c.map((b,v)=>t.jsx(re.Listbox.Option,{value:b,className:({active:h})=>`custom-select__option ${h?"custom-select__option--active":""}`,children:({selected:h})=>t.jsxs("div",{className:"custom-select__option-row",children:[t.jsx("span",{className:`custom-select__option-label ${h?"custom-select__option--selected":""}`,children:b.label}),h&&t.jsx("span",{className:"custom-select__check",children:"✓"})]})},v))})})]})})})}const fd=["jpg","jpeg","png","gif","bmp","webp","svg","image"],pd=(e="")=>{var i;const n=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return fd.includes(n)||e.startsWith("data:image/")?"image":n==="pdf"||e.startsWith("data:application/pdf")?"pdf":["doc","docx"].includes(n)?"word":["xls","xlsx","csv"].includes(n)?"excel":["ppt","pptx"].includes(n)?"powerpoint":"other"},gd={pdf:"vscode-icons:file-type-pdf2",word:"vscode-icons:file-type-word",excel:"vscode-icons:file-type-excel",powerpoint:"vscode-icons:file-type-powerpoint2"};function qs({fileUrl:e,fileName:n,removeFile:i}){const[o,s]=x.useState(!1),[a,l]=x.useState("unknown"),[r,d]=x.useState(null);x.useEffect(()=>{e&&l(pd(e))},[e]),x.useEffect(()=>{if(a==="pdf"&&(e!=null&&e.startsWith("data:")))try{const v=atob(e.split(",")[1]),h=new ArrayBuffer(v.length),p=new Uint8Array(h);for(let N=0;N<v.length;N++)p[N]=v.charCodeAt(N);const g=new Blob([h],{type:"application/pdf"}),f=URL.createObjectURL(g);return d(f),()=>URL.revokeObjectURL(f)}catch(v){console.error("Error creating blob URL:",v)}else d(null)},[e,a]);const u=()=>{a==="image"||a==="pdf"?s(!0):window.open(r||e,"_blank")},m=()=>s(!1),c=n||(e==null?void 0:e.split("/").pop())||"Unknown file";function b(v,h="download"){if(!v)return;if(v.startsWith("data:")){const g=document.createElement("a");g.href=v,g.download=h,document.body.appendChild(g),g.click(),document.body.removeChild(g);return}const p=document.createElement("a");p.href=v,p.setAttribute("download",h),document.body.appendChild(p),p.click(),document.body.removeChild(p)}return t.jsxs("div",{className:"mt-2 field-control !py-1 !bg-gray-50 !flex justify-between gap-x-8 items-center",children:[t.jsxs("div",{onClick:u,className:"!flex items-center rounded cursor-pointer gap-x-3",title:`Click to preview ${c}`,children:[a==="image"&&t.jsx("div",{className:"flex items-center justify-center ",children:t.jsx(te,{iconClass:"text-4xl",icon:"fluent-color:image-48"})}),a!=="image"&&t.jsx(te,{icon:gd[a],iconClass:"text-4xl"}),t.jsx("span",{className:"text-sm font-semibold text-center text-gray-700 truncate max-w-[300px]",children:c})]}),t.jsxs("div",{className:"flex gap-x-1 items-center",children:[t.jsx("button",{type:"button",className:"p-2",onClick:()=>b(r||e,n),title:`Download ${c}`,children:t.jsx(te,{icon:"streamline-flex:download-tray-solid"})}),i&&t.jsx("button",{type:"button",className:"p-2 text-lg text-red-500",onClick:i,children:t.jsx(te,{icon:"lets-icons:trash-duotone"})})]}),o&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",onClick:m,children:t.jsxs("div",{className:"relative bg-white p-8 rounded-lg w-full max-w-[90vw] max-h-[90vh] overflow-auto",onClick:v=>v.stopPropagation(),children:[t.jsx("button",{onClick:m,className:"absolute text-2xl font-bold text-gray-700 top-2 right-2","aria-label":"Close preview",children:"×"}),a==="image"?t.jsx("img",{src:e,alt:c,className:"max-w-full max-h-[80vh] mx-auto object-contain",crossOrigin:"anonymous"}):a==="pdf"?t.jsx("iframe",{src:r||e,title:c,className:"w-full h-[80vh] rounded border"}):null]})})]})}const xe=e=>{const n=typeof window!="undefined"?localStorage.getItem(e):"";try{return JSON.parse(n)}catch(i){return n}},Ys=(e,n)=>{const i=typeof n!="string"?JSON.stringify(n):n;return localStorage.setItem(e,i)},yd=5*1024*1024;function xd({onFileLoaded:e,disabled:n=!1,handleDeleteFile:i,multiple:o=!1,list:s=null,accept:a=[]}){const{uploadUrl:l,setApiActivityCount:r}=x.useContext(Ae),d=x.useRef(null),[u,m]=x.useState(s),[c,b]=x.useState(!1);x.useEffect(()=>{m(s)},[s]);const v=x.useMemo(()=>a==null?void 0:a.map(w=>w.value).join(", "),[a]),h=x.useMemo(()=>a==null?void 0:a.map(w=>w.label).join(", "),[a]),p=x.useCallback(async w=>{var E,k;const A=xe("token"),C=((E=xe("orgData"))==null?void 0:E.id)||xe("organizationId");try{const{data:I}=await Xe.post(l,{...w,service:"FORM",organizationId:C||""},{headers:{Authorization:`Bearer ${A}`}});return(k=I==null?void 0:I.data)==null?void 0:k.url}catch(I){throw console.error("File upload error:",I),new Error("Failed to upload file to server")}},[l]),g=x.useCallback(w=>new Promise((A,C)=>{const E=new FileReader;E.onloadend=async()=>{try{const k=E.result.replace(/^data:.*;base64,/,""),I=l?await p({base64:k,ext:`.${w.name.split(".").pop()}`,fileName:w.name}):E.result;A({base64:I,type:w.type,name:w.name})}catch(k){C(k)}},E.onerror=()=>C(new Error("File read failed")),E.readAsDataURL(w)}),[l,p]),f=x.useCallback(w=>{var C;const A=v?(C=v.split(","))==null?void 0:C.map(E=>E.trim()):[];for(const E of w){if(E.size>yd)return Ee.toast.error(`File "${E.name}" exceeds 5MB limit (${(E.size/1024/1024).toFixed(2)}MB)`),!1;if(A.length&&!A.some(k=>E.type===k||E.name.toLowerCase().endsWith(k.replace("*",""))))return Ee.toast.error(`File "${E.name}" is not an allowed type. Allowed: ${h||"any"}`),!1}return!0},[v,h]),N=x.useCallback(async w=>{const A=Array.from(w.target.files||[]);if(!(!A.length||c)){if(!f(A)){d.current&&(d.current.value="");return}try{b(!0),r==null||r(k=>k+1);const C=await Promise.all(A==null?void 0:A.map(g)),E=o&&u?[...u,...C]:C;m(E),e(E),Ee.toast.success(`Successfully uploaded ${A.length} file(s)`)}catch(C){console.error("Upload error:",C),Ee.toast.error("Failed to upload file(s). Please try again.")}finally{b(!1),r==null||r(C=>Math.max(0,C-1)),d.current&&(d.current.value="")}}},[c,f,g,e,o,u,r]),y=x.useCallback(w=>{c||(d.current&&(d.current.value=""),m(A=>{const C=w===void 0?null:(A==null?void 0:A.filter((E,k)=>k!==w))||null;return e(C),C}),i==null||i())},[i,e,c]),S=u&&u.length>0;return t.jsxs("div",{className:"flex flex-col items-start gap-2",children:[!n&&t.jsxs("div",{className:"!flex field-control !py-0 !px-0 relative",children:[t.jsx("input",{ref:d,type:"file",onChange:N,disabled:n||c,multiple:o,accept:v||"",className:`w-full text-sm text-gray-500 file:mr-4 flex-1 file:px-4 !py-1 !pl-1\r
2
2
  file:rounded-[6px] file:py-[6px] file:border-0\r
3
3
  file:text-sm file:font-semibold\r
4
4
  file:bg-blue-50 file:text-blue-700\r