@arudovwen/form-builder-react 1.2.1 → 1.2.2
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.
package/dist/form-builder.es.js
CHANGED
|
@@ -37040,7 +37040,7 @@ function lN({
|
|
|
37040
37040
|
return /* @__PURE__ */ T.jsxs("div", { className: "px-[30px] py-3 flex justify-between items-center bg-[#F9F9FB] top_bar", children: [
|
|
37041
37041
|
/* @__PURE__ */ T.jsxs("span", { className: "flex items-center gap-x-[6px]", children: [
|
|
37042
37042
|
" ",
|
|
37043
|
-
|
|
37043
|
+
r && /* @__PURE__ */ T.jsx(
|
|
37044
37044
|
"button",
|
|
37045
37045
|
{
|
|
37046
37046
|
type: "button",
|
package/dist/form-builder.umd.js
CHANGED
|
@@ -120,4 +120,4 @@ License: MIT
|
|
|
120
120
|
* @license MIT
|
|
121
121
|
*/function Rt(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function dn(e,r){if(!e){typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}function Mf({pathname:e="/",search:r="",hash:t=""}){return r&&r!=="?"&&(e+=r.charAt(0)==="?"?r:"?"+r),t&&t!=="#"&&(e+=t.charAt(0)==="#"?t:"#"+t),e}function Bf(e){let r={};if(e){let t=e.indexOf("#");t>=0&&(r.hash=e.substring(t),e=e.substring(0,t));let n=e.indexOf("?");n>=0&&(r.search=e.substring(n),e=e.substring(0,n)),e&&(r.pathname=e)}return r}function Mm(e,r,t="/"){return m5(e,r,t,!1)}function m5(e,r,t,n){let a=typeof r=="string"?Bf(r):r,i=da(a.pathname||"/",t);if(i==null)return null;let s=Bm(e);g5(s);let o=null;for(let l=0;o==null&&l<s.length;++l){let c=C5(i);o=S5(s[l],c,n)}return o}function Bm(e,r=[],t=[],n=""){let a=(i,s,o)=>{let l={relativePath:o===void 0?i.path||"":o,caseSensitive:i.caseSensitive===!0,childrenIndex:s,route:i};l.relativePath.startsWith("/")&&(Rt(l.relativePath.startsWith(n),`Absolute route path "${l.relativePath}" nested under path "${n}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),l.relativePath=l.relativePath.slice(n.length));let c=hn([n,l.relativePath]),f=t.concat(l);i.children&&i.children.length>0&&(Rt(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${c}".`),Bm(i.children,r,f,c)),!(i.path==null&&!i.index)&&r.push({path:c,score:T5(c,i.index),routesMeta:f})};return e.forEach((i,s)=>{var o;if(i.path===""||!((o=i.path)!=null&&o.includes("?")))a(i,s);else for(let l of jm(i.path))a(i,s,l)}),r}function jm(e){let r=e.split("/");if(r.length===0)return[];let[t,...n]=r,a=t.endsWith("?"),i=t.replace(/\?$/,"");if(n.length===0)return a?[i,""]:[i];let s=jm(n.join("/")),o=[];return o.push(...s.map(l=>l===""?i:[i,l].join("/"))),a&&o.push(...s),o.map(l=>e.startsWith("/")&&l===""?"/":l)}function g5(e){e.sort((r,t)=>r.score!==t.score?t.score-r.score:k5(r.routesMeta.map(n=>n.childrenIndex),t.routesMeta.map(n=>n.childrenIndex)))}var v5=/^:[\w-]+$/,y5=3,w5=2,b5=1,_5=10,E5=-2,$m=e=>e==="*";function T5(e,r){let t=e.split("/"),n=t.length;return t.some($m)&&(n+=E5),r&&(n+=w5),t.filter(a=>!$m(a)).reduce((a,i)=>a+(v5.test(i)?y5:i===""?b5:_5),n)}function k5(e,r){return e.length===r.length&&e.slice(0,-1).every((n,a)=>n===r[a])?e[e.length-1]-r[r.length-1]:0}function S5(e,r,t=!1){let{routesMeta:n}=e,a={},i="/",s=[];for(let o=0;o<n.length;++o){let l=n[o],c=o===n.length-1,f=i==="/"?r:r.slice(i.length)||"/",u=No({path:l.relativePath,caseSensitive:l.caseSensitive,end:c},f),d=l.route;if(!u&&c&&t&&!n[n.length-1].route.index&&(u=No({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},f)),!u)return null;Object.assign(a,u.params),s.push({params:a,pathname:hn([i,u.pathname]),pathnameBase:N5(hn([i,u.pathnameBase])),route:d}),u.pathnameBase!=="/"&&(i=hn([i,u.pathnameBase]))}return s}function No(e,r){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[t,n]=F5(e.path,e.caseSensitive,e.end),a=r.match(t);if(!a)return null;let i=a[0],s=i.replace(/(.)\/+$/,"$1"),o=a.slice(1);return{params:n.reduce((c,{paramName:f,isOptional:u},d)=>{if(f==="*"){let h=o[d]||"";s=i.slice(0,i.length-h.length).replace(/(.)\/+$/,"$1")}const p=o[d];return u&&!p?c[f]=void 0:c[f]=(p||"").replace(/%2F/g,"/"),c},{}),pathname:i,pathnameBase:s,pattern:e}}function F5(e,r=!1,t=!0){dn(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let n=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(s,o,l)=>(n.push({paramName:o,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(n.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):t?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,r?void 0:"i"),n]}function C5(e){try{return e.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return dn(!1,`The URL path "${e}" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent encoding (${r}).`),e}}function da(e,r){if(r==="/")return e;if(!e.toLowerCase().startsWith(r.toLowerCase()))return null;let t=r.endsWith("/")?r.length-1:r.length,n=e.charAt(t);return n&&n!=="/"?null:e.slice(t)||"/"}function A5(e,r="/"){let{pathname:t,search:n="",hash:a=""}=typeof e=="string"?Bf(e):e;return{pathname:t?t.startsWith("/")?t:O5(t,r):r,search:I5(n),hash:P5(a)}}function O5(e,r){let t=r.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?t.length>1&&t.pop():a!=="."&&t.push(a)}),t.length>1?t.join("/"):"/"}function jf(e,r,t,n){return`Cannot include a '${e}' character in a manually specified \`to.${r}\` field [${JSON.stringify(n)}]. Please separate it out to the \`to.${t}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function D5(e){return e.filter((r,t)=>t===0||r.route.path&&r.route.path.length>0)}function Um(e){let r=D5(e);return r.map((t,n)=>n===r.length-1?t.pathname:t.pathnameBase)}function Vm(e,r,t,n=!1){let a;typeof e=="string"?a=Bf(e):(a={...e},Rt(!a.pathname||!a.pathname.includes("?"),jf("?","pathname","search",a)),Rt(!a.pathname||!a.pathname.includes("#"),jf("#","pathname","hash",a)),Rt(!a.search||!a.search.includes("#"),jf("#","search","hash",a)));let i=e===""||a.pathname==="",s=i?"/":a.pathname,o;if(s==null)o=t;else{let u=r.length-1;if(!n&&s.startsWith("..")){let d=s.split("/");for(;d[0]==="..";)d.shift(),u-=1;a.pathname=d.join("/")}o=u>=0?r[u]:"/"}let l=A5(a,o),c=s&&s!=="/"&&s.endsWith("/"),f=(i||s===".")&&t.endsWith("/");return!l.pathname.endsWith("/")&&(c||f)&&(l.pathname+="/"),l}var hn=e=>e.join("/").replace(/\/\/+/g,"/"),N5=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),I5=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,P5=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function R5(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var Hm=["POST","PUT","PATCH","DELETE"];new Set(Hm);var L5=["GET",...Hm];new Set(L5);var Va=ee.createContext(null);Va.displayName="DataRouter";var Io=ee.createContext(null);Io.displayName="DataRouterState";var Wm=ee.createContext({isTransitioning:!1});Wm.displayName="ViewTransition";var M5=ee.createContext(new Map);M5.displayName="Fetchers";var B5=ee.createContext(null);B5.displayName="Await";var pn=ee.createContext(null);pn.displayName="Navigation";var $f=ee.createContext(null);$f.displayName="Location";var xn=ee.createContext({outlet:null,matches:[],isDataRoute:!1});xn.displayName="Route";var Uf=ee.createContext(null);Uf.displayName="RouteError";function j5(e,{relative:r}={}){Rt(Po(),"useHref() may be used only in the context of a <Router> component.");let{basename:t,navigator:n}=ee.useContext(pn),{hash:a,pathname:i,search:s}=Zi(e,{relative:r}),o=i;return t!=="/"&&(o=i==="/"?t:hn([t,i])),n.createHref({pathname:o,search:s,hash:a})}function Po(){return ee.useContext($f)!=null}function ha(){return Rt(Po(),"useLocation() may be used only in the context of a <Router> component."),ee.useContext($f).location}var zm="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Gm(e){ee.useContext(pn).static||ee.useLayoutEffect(e)}function $5(){let{isDataRoute:e}=ee.useContext(xn);return e?Q5():U5()}function U5(){Rt(Po(),"useNavigate() may be used only in the context of a <Router> component.");let e=ee.useContext(Va),{basename:r,navigator:t}=ee.useContext(pn),{matches:n}=ee.useContext(xn),{pathname:a}=ha(),i=JSON.stringify(Um(n)),s=ee.useRef(!1);return Gm(()=>{s.current=!0}),ee.useCallback((l,c={})=>{if(dn(s.current,zm),!s.current)return;if(typeof l=="number"){t.go(l);return}let f=Vm(l,JSON.parse(i),a,c.relative==="path");e==null&&r!=="/"&&(f.pathname=f.pathname==="/"?r:hn([r,f.pathname])),(c.replace?t.replace:t.push)(f,c.state,c)},[r,t,i,a,e])}ee.createContext(null);function Zi(e,{relative:r}={}){let{matches:t}=ee.useContext(xn),{pathname:n}=ha(),a=JSON.stringify(Um(t));return ee.useMemo(()=>Vm(e,JSON.parse(a),n,r==="path"),[e,a,n,r])}function V5(e,r,t,n){Rt(Po(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=ee.useContext(pn),{matches:i}=ee.useContext(xn),s=i[i.length-1],o=s?s.params:{},l=s?s.pathname:"/",c=s?s.pathnameBase:"/",f=s&&s.route;{let v=f&&f.path||"";Xm(l,!f||v.endsWith("*")||v.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${v}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
122
122
|
|
|
123
|
-
Please change the parent <Route path="${v}"> to <Route path="${v==="/"?"*":`${v}/*`}">.`)}let u=ha(),d;d=u;let p=d.pathname||"/",h=p;if(c!=="/"){let v=c.replace(/^\//,"").split("/");h="/"+p.replace(/^\//,"").split("/").slice(v.length).join("/")}let x=Mm(e,{pathname:h});return dn(f||x!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),dn(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),q5(x&&x.map(v=>Object.assign({},v,{params:Object.assign({},o,v.params),pathname:hn([c,a.encodeLocation?a.encodeLocation(v.pathname).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?c:hn([c,a.encodeLocation?a.encodeLocation(v.pathnameBase).pathname:v.pathnameBase])})),i,t,n)}function H5(){let e=Z5(),r=R5(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),t=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:n},i={padding:"2px 4px",backgroundColor:n},s=null;return console.error("Error handled by React Router default ErrorBoundary:",e),s=ee.createElement(ee.Fragment,null,ee.createElement("p",null,"💿 Hey developer 👋"),ee.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",ee.createElement("code",{style:i},"ErrorBoundary")," or"," ",ee.createElement("code",{style:i},"errorElement")," prop on your route.")),ee.createElement(ee.Fragment,null,ee.createElement("h2",null,"Unexpected Application Error!"),ee.createElement("h3",{style:{fontStyle:"italic"}},r),t?ee.createElement("pre",{style:a},t):null,s)}var W5=ee.createElement(H5,null),z5=class extends ee.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,r){return r.location!==e.location||r.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:r.error,location:r.location,revalidation:e.revalidation||r.revalidation}}componentDidCatch(e,r){console.error("React Router caught the following error during render",e,r)}render(){return this.state.error!==void 0?ee.createElement(xn.Provider,{value:this.props.routeContext},ee.createElement(Uf.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function G5({routeContext:e,match:r,children:t}){let n=ee.useContext(Va);return n&&n.static&&n.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=r.route.id),ee.createElement(xn.Provider,{value:e},t)}function q5(e,r=[],t=null,n=null){if(e==null){if(!t)return null;if(t.errors)e=t.matches;else if(r.length===0&&!t.initialized&&t.matches.length>0)e=t.matches;else return null}let a=e,i=t==null?void 0:t.errors;if(i!=null){let l=a.findIndex(c=>c.route.id&&(i==null?void 0:i[c.route.id])!==void 0);Rt(l>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,l+1))}let s=!1,o=-1;if(t)for(let l=0;l<a.length;l++){let c=a[l];if((c.route.HydrateFallback||c.route.hydrateFallbackElement)&&(o=l),c.route.id){let{loaderData:f,errors:u}=t,d=c.route.loader&&!f.hasOwnProperty(c.route.id)&&(!u||u[c.route.id]===void 0);if(c.route.lazy||d){s=!0,o>=0?a=a.slice(0,o+1):a=[a[0]];break}}}return a.reduceRight((l,c,f)=>{let u,d=!1,p=null,h=null;t&&(u=i&&c.route.id?i[c.route.id]:void 0,p=c.route.errorElement||W5,s&&(o<0&&f===0?(Xm("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,h=null):o===f&&(d=!0,h=c.route.hydrateFallbackElement||null)));let x=r.concat(a.slice(0,f+1)),m=()=>{let v;return u?v=p:d?v=h:c.route.Component?v=ee.createElement(c.route.Component,null):c.route.element?v=c.route.element:v=l,ee.createElement(G5,{match:c,routeContext:{outlet:l,matches:x,isDataRoute:t!=null},children:v})};return t&&(c.route.ErrorBoundary||c.route.errorElement||f===0)?ee.createElement(z5,{location:t.location,revalidation:t.revalidation,component:p,error:u,children:m(),routeContext:{outlet:null,matches:x,isDataRoute:!0}}):m()},null)}function Vf(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function X5(e){let r=ee.useContext(Va);return Rt(r,Vf(e)),r}function K5(e){let r=ee.useContext(Io);return Rt(r,Vf(e)),r}function Y5(e){let r=ee.useContext(xn);return Rt(r,Vf(e)),r}function Hf(e){let r=Y5(e),t=r.matches[r.matches.length-1];return Rt(t.route.id,`${e} can only be used on routes that contain a unique "id"`),t.route.id}function J5(){return Hf("useRouteId")}function Z5(){var n;let e=ee.useContext(Uf),r=K5("useRouteError"),t=Hf("useRouteError");return e!==void 0?e:(n=r.errors)==null?void 0:n[t]}function Q5(){let{router:e}=X5("useNavigate"),r=Hf("useNavigate"),t=ee.useRef(!1);return Gm(()=>{t.current=!0}),ee.useCallback(async(a,i={})=>{dn(t.current,zm),t.current&&(typeof a=="number"?e.navigate(a):await e.navigate(a,{fromRouteId:r,...i}))},[e,r])}var qm={};function Xm(e,r,t){!r&&!qm[e]&&(qm[e]=!0,dn(!1,t))}ee.memo(e6);function e6({routes:e,future:r,state:t}){return V5(e,void 0,t,r)}var Ro="get",Lo="application/x-www-form-urlencoded";function Mo(e){return e!=null&&typeof e.tagName=="string"}function t6(e){return Mo(e)&&e.tagName.toLowerCase()==="button"}function r6(e){return Mo(e)&&e.tagName.toLowerCase()==="form"}function n6(e){return Mo(e)&&e.tagName.toLowerCase()==="input"}function a6(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function i6(e,r){return e.button===0&&(!r||r==="_self")&&!a6(e)}var Bo=null;function s6(){if(Bo===null)try{new FormData(document.createElement("form"),0),Bo=!1}catch{Bo=!0}return Bo}var o6=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Wf(e){return e!=null&&!o6.has(e)?(dn(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Lo}"`),null):e}function l6(e,r){let t,n,a,i,s;if(r6(e)){let o=e.getAttribute("action");n=o?da(o,r):null,t=e.getAttribute("method")||Ro,a=Wf(e.getAttribute("enctype"))||Lo,i=new FormData(e)}else if(t6(e)||n6(e)&&(e.type==="submit"||e.type==="image")){let o=e.form;if(o==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=e.getAttribute("formaction")||o.getAttribute("action");if(n=l?da(l,r):null,t=e.getAttribute("formmethod")||o.getAttribute("method")||Ro,a=Wf(e.getAttribute("formenctype"))||Wf(o.getAttribute("enctype"))||Lo,i=new FormData(o,e),!s6()){let{name:c,type:f,value:u}=e;if(f==="image"){let d=c?`${c}.`:"";i.append(`${d}x`,"0"),i.append(`${d}y`,"0")}else c&&i.append(c,u)}}else{if(Mo(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');t=Ro,n=null,a=Lo,s=e}return i&&a==="text/plain"&&(s=i,i=void 0),{action:n,method:t.toLowerCase(),encType:a,formData:i,body:s}}function zf(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}async function c6(e,r){if(e.id in r)return r[e.id];try{let t=await import(e.module);return r[e.id]=t,t}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function f6(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function u6(e,r,t){let n=await Promise.all(e.map(async a=>{let i=r.routes[a.route.id];if(i){let s=await c6(i,t);return s.links?s.links():[]}return[]}));return x6(n.flat(1).filter(f6).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function Km(e,r,t,n,a,i){let s=(l,c)=>t[c]?l.route.id!==t[c].route.id:!0,o=(l,c)=>{var f;return t[c].pathname!==l.pathname||((f=t[c].route.path)==null?void 0:f.endsWith("*"))&&t[c].params["*"]!==l.params["*"]};return i==="assets"?r.filter((l,c)=>s(l,c)||o(l,c)):i==="data"?r.filter((l,c)=>{var u;let f=n.routes[l.route.id];if(!f||!f.hasLoader)return!1;if(s(l,c)||o(l,c))return!0;if(l.route.shouldRevalidate){let d=l.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((u=t[0])==null?void 0:u.params)||{},nextUrl:new URL(e,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof d=="boolean")return d}return!0}):[]}function d6(e,r){return h6(e.map(t=>{let n=r.routes[t.route.id];if(!n)return[];let a=[n.module];return n.imports&&(a=a.concat(n.imports)),a}).flat(1))}function h6(e){return[...new Set(e)]}function p6(e){let r={},t=Object.keys(e).sort();for(let n of t)r[n]=e[n];return r}function x6(e,r){let t=new Set;return new Set(r),e.reduce((n,a)=>{let i=JSON.stringify(p6(a));return t.has(i)||(t.add(i),n.push({key:i,link:a})),n},[])}function m6(e){let r=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return r.pathname==="/"?r.pathname="_root.data":r.pathname=`${r.pathname.replace(/\/$/,"")}.data`,r}function g6(){let e=ee.useContext(Va);return zf(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function v6(){let e=ee.useContext(Io);return zf(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Gf=ee.createContext(void 0);Gf.displayName="FrameworkContext";function Ym(){let e=ee.useContext(Gf);return zf(e,"You must render this element inside a <HydratedRouter> element"),e}function y6(e,r){let t=ee.useContext(Gf),[n,a]=ee.useState(!1),[i,s]=ee.useState(!1),{onFocus:o,onBlur:l,onMouseEnter:c,onMouseLeave:f,onTouchStart:u}=r,d=ee.useRef(null);ee.useEffect(()=>{if(e==="render"&&s(!0),e==="viewport"){let x=v=>{v.forEach(y=>{s(y.isIntersecting)})},m=new IntersectionObserver(x,{threshold:.5});return d.current&&m.observe(d.current),()=>{m.disconnect()}}},[e]),ee.useEffect(()=>{if(n){let x=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(x)}}},[n]);let p=()=>{a(!0)},h=()=>{a(!1),s(!1)};return t?e!=="intent"?[i,d,{}]:[i,d,{onFocus:Qi(o,p),onBlur:Qi(l,h),onMouseEnter:Qi(c,p),onMouseLeave:Qi(f,h),onTouchStart:Qi(u,p)}]:[!1,d,{}]}function Qi(e,r){return t=>{e&&e(t),t.defaultPrevented||r(t)}}function w6({page:e,...r}){let{router:t}=g6(),n=ee.useMemo(()=>Mm(t.routes,e,t.basename),[t.routes,e,t.basename]);return n?ee.createElement(_6,{page:e,matches:n,...r}):null}function b6(e){let{manifest:r,routeModules:t}=Ym(),[n,a]=ee.useState([]);return ee.useEffect(()=>{let i=!1;return u6(e,r,t).then(s=>{i||a(s)}),()=>{i=!0}},[e,r,t]),n}function _6({page:e,matches:r,...t}){let n=ha(),{manifest:a,routeModules:i}=Ym(),{loaderData:s,matches:o}=v6(),l=ee.useMemo(()=>Km(e,r,o,a,n,"data"),[e,r,o,a,n]),c=ee.useMemo(()=>Km(e,r,o,a,n,"assets"),[e,r,o,a,n]),f=ee.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let p=new Set,h=!1;if(r.forEach(m=>{var y;let v=a.routes[m.route.id];!v||!v.hasLoader||(!l.some(g=>g.route.id===m.route.id)&&m.route.id in s&&((y=i[m.route.id])!=null&&y.shouldRevalidate)||v.hasClientLoader?h=!0:p.add(m.route.id))}),p.size===0)return[];let x=m6(e);return h&&p.size>0&&x.searchParams.set("_routes",r.filter(m=>p.has(m.route.id)).map(m=>m.route.id).join(",")),[x.pathname+x.search]},[s,n,a,l,r,e,i]),u=ee.useMemo(()=>d6(c,a),[c,a]),d=b6(c);return ee.createElement(ee.Fragment,null,f.map(p=>ee.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...t})),u.map(p=>ee.createElement("link",{key:p,rel:"modulepreload",href:p,...t})),d.map(({key:p,link:h})=>ee.createElement("link",{key:p,...h})))}function E6(...e){return r=>{e.forEach(t=>{typeof t=="function"?t(r):t!=null&&(t.current=r)})}}var Jm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Jm&&(window.__reactRouterVersion="7.1.1")}catch{}var Zm=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,qf=ee.forwardRef(function({onClick:r,discover:t="render",prefetch:n="none",relative:a,reloadDocument:i,replace:s,state:o,target:l,to:c,preventScrollReset:f,viewTransition:u,...d},p){let{basename:h}=ee.useContext(pn),x=typeof c=="string"&&Zm.test(c),m,v=!1;if(typeof c=="string"&&x&&(m=c,Jm))try{let b=new URL(window.location.href),O=c.startsWith("//")?new URL(b.protocol+c):new URL(c),I=da(O.pathname,h);O.origin===b.origin&&I!=null?c=I+O.search+O.hash:v=!0}catch{dn(!1,`<Link to="${c}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let y=j5(c,{relative:a}),[g,F,D]=y6(n,d),S=F6(c,{replace:s,state:o,target:l,preventScrollReset:f,relative:a,viewTransition:u});function E(b){r&&r(b),b.defaultPrevented||S(b)}let _=ee.createElement("a",{...d,...D,href:m||y,onClick:v||i?r:E,ref:E6(p,F),target:l,"data-discover":!x&&t==="render"?"true":void 0});return g&&!x?ee.createElement(ee.Fragment,null,_,ee.createElement(w6,{page:y})):_});qf.displayName="Link";var T6=ee.forwardRef(function({"aria-current":r="page",caseSensitive:t=!1,className:n="",end:a=!1,style:i,to:s,viewTransition:o,children:l,...c},f){let u=Zi(s,{relative:c.relative}),d=ha(),p=ee.useContext(Io),{navigator:h,basename:x}=ee.useContext(pn),m=p!=null&&N6(u)&&o===!0,v=h.encodeLocation?h.encodeLocation(u).pathname:u.pathname,y=d.pathname,g=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;t||(y=y.toLowerCase(),g=g?g.toLowerCase():null,v=v.toLowerCase()),g&&x&&(g=da(g,x)||g);const F=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let D=y===v||!a&&y.startsWith(v)&&y.charAt(F)==="/",S=g!=null&&(g===v||!a&&g.startsWith(v)&&g.charAt(v.length)==="/"),E={isActive:D,isPending:S,isTransitioning:m},_=D?r:void 0,b;typeof n=="function"?b=n(E):b=[n,D?"active":null,S?"pending":null,m?"transitioning":null].filter(Boolean).join(" ");let O=typeof i=="function"?i(E):i;return ee.createElement(qf,{...c,"aria-current":_,className:b,ref:f,style:O,to:s,viewTransition:o},typeof l=="function"?l(E):l)});T6.displayName="NavLink";var k6=ee.forwardRef(({discover:e="render",fetcherKey:r,navigate:t,reloadDocument:n,replace:a,state:i,method:s=Ro,action:o,onSubmit:l,relative:c,preventScrollReset:f,viewTransition:u,...d},p)=>{let h=O6(),x=D6(o,{relative:c}),m=s.toLowerCase()==="get"?"get":"post",v=typeof o=="string"&&Zm.test(o),y=g=>{if(l&&l(g),g.defaultPrevented)return;g.preventDefault();let F=g.nativeEvent.submitter,D=(F==null?void 0:F.getAttribute("formmethod"))||s;h(F||g.currentTarget,{fetcherKey:r,method:D,navigate:t,replace:a,state:i,relative:c,preventScrollReset:f,viewTransition:u})};return ee.createElement("form",{ref:p,method:m,action:x,onSubmit:n?l:y,...d,"data-discover":!v&&e==="render"?"true":void 0})});k6.displayName="Form";function S6(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Qm(e){let r=ee.useContext(Va);return Rt(r,S6(e)),r}function F6(e,{target:r,replace:t,state:n,preventScrollReset:a,relative:i,viewTransition:s}={}){let o=$5(),l=ha(),c=Zi(e,{relative:i});return ee.useCallback(f=>{if(i6(f,r)){f.preventDefault();let u=t!==void 0?t:Mf(l)===Mf(c);o(e,{replace:u,state:n,preventScrollReset:a,relative:i,viewTransition:s})}},[l,o,c,t,n,r,e,a,i,s])}var C6=0,A6=()=>`__${String(++C6)}__`;function O6(){let{router:e}=Qm("useSubmit"),{basename:r}=ee.useContext(pn),t=J5();return ee.useCallback(async(n,a={})=>{let{action:i,method:s,encType:o,formData:l,body:c}=l6(n,r);if(a.navigate===!1){let f=a.fetcherKey||A6();await e.fetch(f,t,a.action||i,{preventScrollReset:a.preventScrollReset,formData:l,body:c,formMethod:a.method||s,formEncType:a.encType||o,flushSync:a.flushSync})}else await e.navigate(a.action||i,{preventScrollReset:a.preventScrollReset,formData:l,body:c,formMethod:a.method||s,formEncType:a.encType||o,replace:a.replace,state:a.state,fromRouteId:t,flushSync:a.flushSync,viewTransition:a.viewTransition})},[e,r,t])}function D6(e,{relative:r}={}){let{basename:t}=ee.useContext(pn),n=ee.useContext(xn);Rt(n,"useFormAction must be used inside a RouteContext");let[a]=n.matches.slice(-1),i={...Zi(e||".",{relative:r})},s=ha();if(e==null){i.search=s.search;let o=new URLSearchParams(i.search),l=o.getAll("index");if(l.some(f=>f==="")){o.delete("index"),l.filter(u=>u).forEach(u=>o.append("index",u));let f=o.toString();i.search=f?`?${f}`:""}}return(!e||e===".")&&a.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),t!=="/"&&(i.pathname=i.pathname==="/"?t:hn([t,i.pathname])),Mf(i)}function N6(e,r={}){let t=ee.useContext(Wm);Rt(t!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=Qm("useViewTransitionState"),a=Zi(e,{relative:r.relative});if(!t.isTransitioning)return!1;let i=da(t.currentLocation.pathname,n)||t.currentLocation.pathname,s=da(t.nextLocation.pathname,n)||t.nextLocation.pathname;return No(a.pathname,s)!=null||No(a.pathname,i)!=null}new TextEncoder;const pa=({text:e="",isDisabled:r=!1,isLoading:t=!1,btnClass:n="bg-primary-500 text-white",icon:a="",iconPosition:i="left",iconClass:s="text-[20px]",loadingClass:o="",link:l="",div:c=!1,type:f="button",style:u,onClick:d})=>{const p=qe("btn inline-flex justify-center",{"pointer-events-none":t,"opacity-40 cursor-not-allowed":r},n),h=()=>t?T.jsxs(T.Fragment,{children:[T.jsxs("svg",{className:`animate-spin -ml-1 mr-3 h-5 w-5 ${o}`,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[T.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),T.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"})]}),"Loading..."]}):T.jsxs("span",{className:"flex items-center",children:[a&&i==="left"&&T.jsx("span",{className:`mr-[6px] ${s}`,children:T.jsx(ct,{icon:a})}),e&&T.jsx("span",{children:e}),a&&i==="right"&&T.jsx("span",{className:`ml-[6px] ${s}`,children:T.jsx(ct,{icon:a})})]});return c?T.jsx("div",{className:p,children:h()}):l?T.jsx(qf,{to:l,className:p,children:h()}):T.jsx("button",{disabled:r,type:f,className:p,"data-testid":"btn",onClick:d,style:u,children:h()})},I6=({isOpen:e,onClose:r})=>{const{formData:t}=k.useContext(Fr);if(!e)return null;const n=Kn("config");return T.jsx("div",{className:"fixed inset-0 bg-black/30 flex items-center justify-center z-[999] cursor-default no-drag select-none",children:T.jsxs("div",{className:"max-w-[80vw] bg-white rounded-xl shadow-xl relative flex flex-col items-center w-full py-6 ",children:[T.jsx("button",{type:"button",onClick:r,className:"absolute top-3 right-4 text-sm",children:"Close"}),T.jsx("div",{className:"max-h-[90vh] overflow-y-auto h-full min-h-[600px] w-full",children:T.jsx(t1,{form_data:t,ignoreValidation:!0,config:n})})]})})},tr=Kn("config");function P6({title:e,goBackUrl:r,onSubmit:t,onPublish:n}){const{addSection:a,formData:i}=k.useContext(Fr),[s,o]=k.useState(!1);function l(){localStorage.setItem("formData",JSON.stringify(i)),t==null||t(i)}function c(){localStorage.setItem("formData",JSON.stringify(i)),n==null||n(i)}return T.jsxs("div",{className:"px-[30px] py-3 flex justify-between items-center bg-[#F9F9FB] top_bar",children:[T.jsxs("span",{className:"flex items-center gap-x-[6px]",children:[" ",!r&&T.jsx("button",{type:"button",onClick:()=>r(),style:{color:(tr==null?void 0:tr.buttonColor)||"#333"},children:T.jsx(ct,{icon:"bxs:chevron-left-square",iconClass:"text-2xl"})})," ",T.jsx("h1",{className:"text-base font-semibold form_title",children:e||""})]}),s&&T.jsx(I6,{isOpen:s,onClose:()=>o(!1),element:void 0}),T.jsxs("div",{className:"flex justify-end text-xs gap-x-3",children:[T.jsx(pa,{onClick:()=>a(),text:"Add section",btnClass:" !px-2 !font-medium bg-transparent !text-sm form_section !normal-case",icon:"icon-park-outline:plus",iconClass:"text-base",style:{color:(tr==null?void 0:tr.buttonColor)||"#333"}}),T.jsx(pa,{onClick:()=>o(!0),text:"Preview",btnClass:"!px-2 bg-transparent !font-medium !text-sm form_preview",icon:"solar:eye-bold-duotone",iconClass:"text-base",style:{color:(tr==null?void 0:tr.buttonColor)||"#333"}}),T.jsx(pa,{onClick:()=>l(),text:"Save",btnClass:"!px-2 bg-transparent !font-medium !text-sm form_save__btn",icon:"lets-icons:save-duotone",iconClass:"text-base",style:{color:(tr==null?void 0:tr.buttonColor)||"#333"}}),T.jsx(pa,{onClick:()=>c(),text:"Publish",style:{background:(tr==null?void 0:tr.buttonColor)||"#333"},btnClass:"border-[#98A2B3] !font-medium !text-sm !py-[8px] px-6 text-white rounded-lg form_publish__btn"})]})]})}const e1=({loadingClass:e})=>{const r=qe("h-full w-full min-h-[300px] flex justify-center items-center",e);return k.useEffect(()=>{const t=Kn("config"),n=(t==null?void 0:t.loaderColor)||"#333";document.documentElement.style.setProperty("--loader-color",n)},[]),T.jsx("div",{className:r,children:T.jsx("span",{className:"loader"})})};function R6({onSubmit:e,questionData:r,title:t,goBackUrl:n,loading:a,onPublish:i}){return T.jsx(m0,{children:T.jsxs("div",{className:"w-full h-full bg-[#F5F5F5] flex flex-col",children:[T.jsx(j1,{}),T.jsx("div",{className:"border-b bg-white border-[#E4E7EC]",children:T.jsx(P6,{title:t,goBackUrl:n,onSubmit:e,onPublish:i})}),T.jsxs("div",{className:"flex flex-1 p-4 gap-x-4",children:[T.jsx("div",{children:T.jsx("div",{className:"w-[270px] border border-[#E4E7EC] bg-white max-h-[calc(100vh-100px)] overflow-y-auto side_shadow rounded-lg no-scrollbar",children:T.jsx(p5,{})})}),T.jsx("div",{className:"flex-1 h-full max-h-full z-[1] ",children:a?T.jsx(e1,{loadingClass:"!w-full !h-[800px]"}):T.jsx(d5,{questionData:r})})]})]})})}const L6=({onSubmit:e,questionData:r,isReadOnly:t,config:n={buttonColor:"#333"},title:a,loading:i,goBackUrl:s,onPublish:o})=>(k.useEffect(()=>{n&&uh("config",n)},[n]),T.jsx(R6,{onSubmit:e,onPublish:o,questionData:r,isReadOnly:t,title:a,goBackUrl:s,loading:i})),xa={required:"This field is required",email:"Invalid email format",minLength:e=>`Minimum length is ${e}`,maxLength:e=>`Maximum length is ${e}`,minAmount:e=>`Minimum amount is ${e}`,maxAmount:e=>`Maximum amount is ${e}`},M6=e=>({textField:Ze().nullable(),longText:Ze().nullable(),numberField:Ca().nullable().transform(t=>isNaN(t)?null:t),amountField:Ca().nullable().transform(t=>isNaN(t)?null:t),selectField:Ze().nullable(),checkbox:Fa().nullable(),radio:Fa().nullable(),email:Ze().nullable().email(xa.email),date:Ec().typeError("Invalid date").nullable()})[e]||Fa().nullable(),B6=(e,r,t)=>r?e.type==="boolean"?e.oneOf([!0],t||xa.required):e.required(t||xa.required):e,j6=(e,{minLength:r,maxLength:t,minLengthMessage:n,maxLengthMessage:a})=>{let i=e;return r&&(i=i.min(r,n||xa.minLength(r))),t&&(i=i.max(t,a||xa.maxLength(t))),i},$6=(e,{minAmount:r,maxAmount:t,minAmountMessage:n,maxAmountMessage:a})=>{let i=e;return r&&(i=i.min(parseFloat(String(r)),n||xa.minAmount(r))),t&&(i=i.max(parseFloat(String(t)),a||xa.maxAmount(t))),i};function U6(e){const r={};return e.forEach(({questionData:t})=>{t.forEach(n=>{const{id:a,type:i,isRequired:s,requiredMessage:o}=n;let l=M6(i);l=B6(l,s,o),i==="textField"||i==="longText"||i==="email"?l=j6(l,n):(i==="numberField"||i==="amountField")&&(l=$6(l,n)),r[a]=l})}),yi().shape(r)}function V6(e){return e.reduce((r,t)=>(r[t.id]=t.value,r),{})}const jo=(e,r)=>{const t=Im[e.type];return t?T.jsxs("div",{children:[e.inputLabel&&T.jsx("label",{className:"block text-sm font-medium mb-[5px]",children:e.inputLabel}),T.jsx(t,{element:e,state:"edit",validationData:r})]}):null};function H6({form_data:e,options:r}){return T.jsx("div",{className:"grid gap-y-6",children:e.flatMap(t=>{var n;return(n=t.questionData)==null?void 0:n.map(a=>{var i,s;if(a.type==="grid"){const o=t.questionData.filter(l=>l.gridId===a.id);return T.jsx(Rf,{element:a,customClass:"p-0 min-h-[60px] border-none",children:o.map(l=>{var c;return T.jsx(Pf,{col:(c=l.gridPosition)==null?void 0:c.col,customClass:"p-0",children:jo(l,r)},l.id)})},a.id)}return a.gridId?null:T.jsxs("div",{className:qe("group relative grid gap-y-[6px]",a.elementClass),children:[jo(a,r),T.jsx("div",{className:"text-xs text-red-600 mt-1",children:(s=(i=r==null?void 0:r.errors)==null?void 0:i[a.id])==null?void 0:s.message})]},a.id)})})})}function W6({form_data:e,options:r,current:t}){var n;return T.jsx("div",{className:"grid gap-y-6",children:(n=e[t].questionData)==null?void 0:n.map(a=>{var i,s;if(a.type==="grid"){const o=e[t].questionData.filter(l=>l.gridId===a.id);return T.jsx(Rf,{element:a,customClass:"p-0 min-h-[60px] border-none",children:o.map(l=>{var c;return T.jsx(Pf,{col:(c=l.gridPosition)==null?void 0:c.col,customClass:"p-0",children:jo(l,r)},l.id)})},a.id)}return a.gridId?null:T.jsxs("div",{className:qe("group relative grid gap-y-[6px]",a.elementClass),children:[jo(a,r),T.jsx("div",{className:"text-xs text-red-600 mt-1",children:(s=(i=r==null?void 0:r.errors)==null?void 0:i[a.id])==null?void 0:s.message})]},a.id)})})}const z6=({form_data:e,answerData:r,ignoreValidation:t,onSubmitData:n,isReadOnly:a,renderType:i="multi"})=>{const[s,o]=k.useState(0),l=k.useMemo(()=>e.length,[e]),c=U6(e),f=xc({resolver:mc(c),mode:"onSubmit",defaultValues:{}}),{register:u,setValue:d,watch:p,handleSubmit:h,reset:x,getValues:m,formState:{errors:v,isSubmitting:y},trigger:g}=f,F=Kn("config"),D=_=>{const b=e.flatMap(O=>O.questionData.map(I=>({id:I.id,value:_[I.id],sectionId:O.id,type:I.type})));n==null||n(b)};k.useEffect(()=>{if(r!=null&&r.length){const _=V6(r);x(_)}},[r,x]);async function S(){var _;!t&&!await g((_=e==null?void 0:e[s].questionData)==null?void 0:_.map(O=>O.id))||o(b=>b+1)}function E(){o(_=>_-1)}return T.jsx(m0,{children:T.jsx(f2,{...f,children:T.jsxs("form",{onSubmit:h(D),className:"container mx-auto p-6 h-full",children:[T.jsx("div",{className:"relative w-full flex flex-col gap-y-12 py-4",children:T.jsxs("div",{children:[T.jsxs("div",{className:"mb-4",children:[(e==null?void 0:e[s].title)&&T.jsx("h2",{className:"text-lg font-semibold mb-[6px]",children:e[s].title}),(e==null?void 0:e[s].description)&&T.jsx("p",{className:"text-sm",children:e[s].description})]}),i==="multi"?T.jsx(W6,{form_data:e,options:{register:u,setValue:d,watch:p,errors:v,trigger:g,isSubmitting:y,isReadOnly:a,getValues:m},current:s}):T.jsx(H6,{form_data:e,options:{register:u,setValue:d,watch:p,errors:v,trigger:g,isSubmitting:y,isReadOnly:a,getValues:m}})]},e==null?void 0:e[s].id)}),T.jsxs("div",{className:"pt-8 flex justify-end items-center gap-4",children:[s!==0&&T.jsx(pa,{type:"button",text:"Back",onClick:E,btnClass:"text-gray-700 border-[#98A2B3] !font-medium !py-[10px] px-10 bg-gray-200 rounded-lg"}),s!==l-1?T.jsx(pa,{type:"button",text:"Continue",onClick:S,style:{background:(F==null?void 0:F.buttonColor)||"#333"},btnClass:"text-gray-700 border-[#98A2B3] !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg"}):!t&&T.jsx(pa,{isDisabled:y,isLoading:y,type:"submit",text:"Submit",style:{background:(F==null?void 0:F.buttonColor)||"#333"},btnClass:"text-gray-700 border-[#98A2B3] !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg"})]})]})})})};function t1({answerData:e,form_data:r,ignoreValidation:t,onSubmit:n,isReadOnly:a=!1,loading:i=!1,config:s={buttonColor:"#333"},renderType:o}){return k.useEffect(()=>{s&&uh("config",s)},[s]),i?T.jsx(e1,{}):r?T.jsx("div",{className:"w-full h-full",children:T.jsx(z6,{form_data:r,answerData:e,ignoreValidation:t,onSubmitData:n,isReadOnly:a,renderType:o})}):T.jsx("div",{children:T.jsx("p",{children:"Error: No form data available. Please ensure the form data is saved correctly."})})}en.FormBuilder=L6,en.FormViewer=t1,Object.defineProperty(en,Symbol.toStringTag,{value:"Module"})});
|
|
123
|
+
Please change the parent <Route path="${v}"> to <Route path="${v==="/"?"*":`${v}/*`}">.`)}let u=ha(),d;d=u;let p=d.pathname||"/",h=p;if(c!=="/"){let v=c.replace(/^\//,"").split("/");h="/"+p.replace(/^\//,"").split("/").slice(v.length).join("/")}let x=Mm(e,{pathname:h});return dn(f||x!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),dn(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),q5(x&&x.map(v=>Object.assign({},v,{params:Object.assign({},o,v.params),pathname:hn([c,a.encodeLocation?a.encodeLocation(v.pathname).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?c:hn([c,a.encodeLocation?a.encodeLocation(v.pathnameBase).pathname:v.pathnameBase])})),i,t,n)}function H5(){let e=Z5(),r=R5(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),t=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:n},i={padding:"2px 4px",backgroundColor:n},s=null;return console.error("Error handled by React Router default ErrorBoundary:",e),s=ee.createElement(ee.Fragment,null,ee.createElement("p",null,"💿 Hey developer 👋"),ee.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",ee.createElement("code",{style:i},"ErrorBoundary")," or"," ",ee.createElement("code",{style:i},"errorElement")," prop on your route.")),ee.createElement(ee.Fragment,null,ee.createElement("h2",null,"Unexpected Application Error!"),ee.createElement("h3",{style:{fontStyle:"italic"}},r),t?ee.createElement("pre",{style:a},t):null,s)}var W5=ee.createElement(H5,null),z5=class extends ee.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,r){return r.location!==e.location||r.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:r.error,location:r.location,revalidation:e.revalidation||r.revalidation}}componentDidCatch(e,r){console.error("React Router caught the following error during render",e,r)}render(){return this.state.error!==void 0?ee.createElement(xn.Provider,{value:this.props.routeContext},ee.createElement(Uf.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function G5({routeContext:e,match:r,children:t}){let n=ee.useContext(Va);return n&&n.static&&n.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=r.route.id),ee.createElement(xn.Provider,{value:e},t)}function q5(e,r=[],t=null,n=null){if(e==null){if(!t)return null;if(t.errors)e=t.matches;else if(r.length===0&&!t.initialized&&t.matches.length>0)e=t.matches;else return null}let a=e,i=t==null?void 0:t.errors;if(i!=null){let l=a.findIndex(c=>c.route.id&&(i==null?void 0:i[c.route.id])!==void 0);Rt(l>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,l+1))}let s=!1,o=-1;if(t)for(let l=0;l<a.length;l++){let c=a[l];if((c.route.HydrateFallback||c.route.hydrateFallbackElement)&&(o=l),c.route.id){let{loaderData:f,errors:u}=t,d=c.route.loader&&!f.hasOwnProperty(c.route.id)&&(!u||u[c.route.id]===void 0);if(c.route.lazy||d){s=!0,o>=0?a=a.slice(0,o+1):a=[a[0]];break}}}return a.reduceRight((l,c,f)=>{let u,d=!1,p=null,h=null;t&&(u=i&&c.route.id?i[c.route.id]:void 0,p=c.route.errorElement||W5,s&&(o<0&&f===0?(Xm("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,h=null):o===f&&(d=!0,h=c.route.hydrateFallbackElement||null)));let x=r.concat(a.slice(0,f+1)),m=()=>{let v;return u?v=p:d?v=h:c.route.Component?v=ee.createElement(c.route.Component,null):c.route.element?v=c.route.element:v=l,ee.createElement(G5,{match:c,routeContext:{outlet:l,matches:x,isDataRoute:t!=null},children:v})};return t&&(c.route.ErrorBoundary||c.route.errorElement||f===0)?ee.createElement(z5,{location:t.location,revalidation:t.revalidation,component:p,error:u,children:m(),routeContext:{outlet:null,matches:x,isDataRoute:!0}}):m()},null)}function Vf(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function X5(e){let r=ee.useContext(Va);return Rt(r,Vf(e)),r}function K5(e){let r=ee.useContext(Io);return Rt(r,Vf(e)),r}function Y5(e){let r=ee.useContext(xn);return Rt(r,Vf(e)),r}function Hf(e){let r=Y5(e),t=r.matches[r.matches.length-1];return Rt(t.route.id,`${e} can only be used on routes that contain a unique "id"`),t.route.id}function J5(){return Hf("useRouteId")}function Z5(){var n;let e=ee.useContext(Uf),r=K5("useRouteError"),t=Hf("useRouteError");return e!==void 0?e:(n=r.errors)==null?void 0:n[t]}function Q5(){let{router:e}=X5("useNavigate"),r=Hf("useNavigate"),t=ee.useRef(!1);return Gm(()=>{t.current=!0}),ee.useCallback(async(a,i={})=>{dn(t.current,zm),t.current&&(typeof a=="number"?e.navigate(a):await e.navigate(a,{fromRouteId:r,...i}))},[e,r])}var qm={};function Xm(e,r,t){!r&&!qm[e]&&(qm[e]=!0,dn(!1,t))}ee.memo(e6);function e6({routes:e,future:r,state:t}){return V5(e,void 0,t,r)}var Ro="get",Lo="application/x-www-form-urlencoded";function Mo(e){return e!=null&&typeof e.tagName=="string"}function t6(e){return Mo(e)&&e.tagName.toLowerCase()==="button"}function r6(e){return Mo(e)&&e.tagName.toLowerCase()==="form"}function n6(e){return Mo(e)&&e.tagName.toLowerCase()==="input"}function a6(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function i6(e,r){return e.button===0&&(!r||r==="_self")&&!a6(e)}var Bo=null;function s6(){if(Bo===null)try{new FormData(document.createElement("form"),0),Bo=!1}catch{Bo=!0}return Bo}var o6=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Wf(e){return e!=null&&!o6.has(e)?(dn(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Lo}"`),null):e}function l6(e,r){let t,n,a,i,s;if(r6(e)){let o=e.getAttribute("action");n=o?da(o,r):null,t=e.getAttribute("method")||Ro,a=Wf(e.getAttribute("enctype"))||Lo,i=new FormData(e)}else if(t6(e)||n6(e)&&(e.type==="submit"||e.type==="image")){let o=e.form;if(o==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=e.getAttribute("formaction")||o.getAttribute("action");if(n=l?da(l,r):null,t=e.getAttribute("formmethod")||o.getAttribute("method")||Ro,a=Wf(e.getAttribute("formenctype"))||Wf(o.getAttribute("enctype"))||Lo,i=new FormData(o,e),!s6()){let{name:c,type:f,value:u}=e;if(f==="image"){let d=c?`${c}.`:"";i.append(`${d}x`,"0"),i.append(`${d}y`,"0")}else c&&i.append(c,u)}}else{if(Mo(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');t=Ro,n=null,a=Lo,s=e}return i&&a==="text/plain"&&(s=i,i=void 0),{action:n,method:t.toLowerCase(),encType:a,formData:i,body:s}}function zf(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}async function c6(e,r){if(e.id in r)return r[e.id];try{let t=await import(e.module);return r[e.id]=t,t}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function f6(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function u6(e,r,t){let n=await Promise.all(e.map(async a=>{let i=r.routes[a.route.id];if(i){let s=await c6(i,t);return s.links?s.links():[]}return[]}));return x6(n.flat(1).filter(f6).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function Km(e,r,t,n,a,i){let s=(l,c)=>t[c]?l.route.id!==t[c].route.id:!0,o=(l,c)=>{var f;return t[c].pathname!==l.pathname||((f=t[c].route.path)==null?void 0:f.endsWith("*"))&&t[c].params["*"]!==l.params["*"]};return i==="assets"?r.filter((l,c)=>s(l,c)||o(l,c)):i==="data"?r.filter((l,c)=>{var u;let f=n.routes[l.route.id];if(!f||!f.hasLoader)return!1;if(s(l,c)||o(l,c))return!0;if(l.route.shouldRevalidate){let d=l.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((u=t[0])==null?void 0:u.params)||{},nextUrl:new URL(e,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof d=="boolean")return d}return!0}):[]}function d6(e,r){return h6(e.map(t=>{let n=r.routes[t.route.id];if(!n)return[];let a=[n.module];return n.imports&&(a=a.concat(n.imports)),a}).flat(1))}function h6(e){return[...new Set(e)]}function p6(e){let r={},t=Object.keys(e).sort();for(let n of t)r[n]=e[n];return r}function x6(e,r){let t=new Set;return new Set(r),e.reduce((n,a)=>{let i=JSON.stringify(p6(a));return t.has(i)||(t.add(i),n.push({key:i,link:a})),n},[])}function m6(e){let r=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return r.pathname==="/"?r.pathname="_root.data":r.pathname=`${r.pathname.replace(/\/$/,"")}.data`,r}function g6(){let e=ee.useContext(Va);return zf(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function v6(){let e=ee.useContext(Io);return zf(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Gf=ee.createContext(void 0);Gf.displayName="FrameworkContext";function Ym(){let e=ee.useContext(Gf);return zf(e,"You must render this element inside a <HydratedRouter> element"),e}function y6(e,r){let t=ee.useContext(Gf),[n,a]=ee.useState(!1),[i,s]=ee.useState(!1),{onFocus:o,onBlur:l,onMouseEnter:c,onMouseLeave:f,onTouchStart:u}=r,d=ee.useRef(null);ee.useEffect(()=>{if(e==="render"&&s(!0),e==="viewport"){let x=v=>{v.forEach(y=>{s(y.isIntersecting)})},m=new IntersectionObserver(x,{threshold:.5});return d.current&&m.observe(d.current),()=>{m.disconnect()}}},[e]),ee.useEffect(()=>{if(n){let x=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(x)}}},[n]);let p=()=>{a(!0)},h=()=>{a(!1),s(!1)};return t?e!=="intent"?[i,d,{}]:[i,d,{onFocus:Qi(o,p),onBlur:Qi(l,h),onMouseEnter:Qi(c,p),onMouseLeave:Qi(f,h),onTouchStart:Qi(u,p)}]:[!1,d,{}]}function Qi(e,r){return t=>{e&&e(t),t.defaultPrevented||r(t)}}function w6({page:e,...r}){let{router:t}=g6(),n=ee.useMemo(()=>Mm(t.routes,e,t.basename),[t.routes,e,t.basename]);return n?ee.createElement(_6,{page:e,matches:n,...r}):null}function b6(e){let{manifest:r,routeModules:t}=Ym(),[n,a]=ee.useState([]);return ee.useEffect(()=>{let i=!1;return u6(e,r,t).then(s=>{i||a(s)}),()=>{i=!0}},[e,r,t]),n}function _6({page:e,matches:r,...t}){let n=ha(),{manifest:a,routeModules:i}=Ym(),{loaderData:s,matches:o}=v6(),l=ee.useMemo(()=>Km(e,r,o,a,n,"data"),[e,r,o,a,n]),c=ee.useMemo(()=>Km(e,r,o,a,n,"assets"),[e,r,o,a,n]),f=ee.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let p=new Set,h=!1;if(r.forEach(m=>{var y;let v=a.routes[m.route.id];!v||!v.hasLoader||(!l.some(g=>g.route.id===m.route.id)&&m.route.id in s&&((y=i[m.route.id])!=null&&y.shouldRevalidate)||v.hasClientLoader?h=!0:p.add(m.route.id))}),p.size===0)return[];let x=m6(e);return h&&p.size>0&&x.searchParams.set("_routes",r.filter(m=>p.has(m.route.id)).map(m=>m.route.id).join(",")),[x.pathname+x.search]},[s,n,a,l,r,e,i]),u=ee.useMemo(()=>d6(c,a),[c,a]),d=b6(c);return ee.createElement(ee.Fragment,null,f.map(p=>ee.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...t})),u.map(p=>ee.createElement("link",{key:p,rel:"modulepreload",href:p,...t})),d.map(({key:p,link:h})=>ee.createElement("link",{key:p,...h})))}function E6(...e){return r=>{e.forEach(t=>{typeof t=="function"?t(r):t!=null&&(t.current=r)})}}var Jm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Jm&&(window.__reactRouterVersion="7.1.1")}catch{}var Zm=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,qf=ee.forwardRef(function({onClick:r,discover:t="render",prefetch:n="none",relative:a,reloadDocument:i,replace:s,state:o,target:l,to:c,preventScrollReset:f,viewTransition:u,...d},p){let{basename:h}=ee.useContext(pn),x=typeof c=="string"&&Zm.test(c),m,v=!1;if(typeof c=="string"&&x&&(m=c,Jm))try{let b=new URL(window.location.href),O=c.startsWith("//")?new URL(b.protocol+c):new URL(c),I=da(O.pathname,h);O.origin===b.origin&&I!=null?c=I+O.search+O.hash:v=!0}catch{dn(!1,`<Link to="${c}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let y=j5(c,{relative:a}),[g,F,D]=y6(n,d),S=F6(c,{replace:s,state:o,target:l,preventScrollReset:f,relative:a,viewTransition:u});function E(b){r&&r(b),b.defaultPrevented||S(b)}let _=ee.createElement("a",{...d,...D,href:m||y,onClick:v||i?r:E,ref:E6(p,F),target:l,"data-discover":!x&&t==="render"?"true":void 0});return g&&!x?ee.createElement(ee.Fragment,null,_,ee.createElement(w6,{page:y})):_});qf.displayName="Link";var T6=ee.forwardRef(function({"aria-current":r="page",caseSensitive:t=!1,className:n="",end:a=!1,style:i,to:s,viewTransition:o,children:l,...c},f){let u=Zi(s,{relative:c.relative}),d=ha(),p=ee.useContext(Io),{navigator:h,basename:x}=ee.useContext(pn),m=p!=null&&N6(u)&&o===!0,v=h.encodeLocation?h.encodeLocation(u).pathname:u.pathname,y=d.pathname,g=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;t||(y=y.toLowerCase(),g=g?g.toLowerCase():null,v=v.toLowerCase()),g&&x&&(g=da(g,x)||g);const F=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let D=y===v||!a&&y.startsWith(v)&&y.charAt(F)==="/",S=g!=null&&(g===v||!a&&g.startsWith(v)&&g.charAt(v.length)==="/"),E={isActive:D,isPending:S,isTransitioning:m},_=D?r:void 0,b;typeof n=="function"?b=n(E):b=[n,D?"active":null,S?"pending":null,m?"transitioning":null].filter(Boolean).join(" ");let O=typeof i=="function"?i(E):i;return ee.createElement(qf,{...c,"aria-current":_,className:b,ref:f,style:O,to:s,viewTransition:o},typeof l=="function"?l(E):l)});T6.displayName="NavLink";var k6=ee.forwardRef(({discover:e="render",fetcherKey:r,navigate:t,reloadDocument:n,replace:a,state:i,method:s=Ro,action:o,onSubmit:l,relative:c,preventScrollReset:f,viewTransition:u,...d},p)=>{let h=O6(),x=D6(o,{relative:c}),m=s.toLowerCase()==="get"?"get":"post",v=typeof o=="string"&&Zm.test(o),y=g=>{if(l&&l(g),g.defaultPrevented)return;g.preventDefault();let F=g.nativeEvent.submitter,D=(F==null?void 0:F.getAttribute("formmethod"))||s;h(F||g.currentTarget,{fetcherKey:r,method:D,navigate:t,replace:a,state:i,relative:c,preventScrollReset:f,viewTransition:u})};return ee.createElement("form",{ref:p,method:m,action:x,onSubmit:n?l:y,...d,"data-discover":!v&&e==="render"?"true":void 0})});k6.displayName="Form";function S6(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Qm(e){let r=ee.useContext(Va);return Rt(r,S6(e)),r}function F6(e,{target:r,replace:t,state:n,preventScrollReset:a,relative:i,viewTransition:s}={}){let o=$5(),l=ha(),c=Zi(e,{relative:i});return ee.useCallback(f=>{if(i6(f,r)){f.preventDefault();let u=t!==void 0?t:Mf(l)===Mf(c);o(e,{replace:u,state:n,preventScrollReset:a,relative:i,viewTransition:s})}},[l,o,c,t,n,r,e,a,i,s])}var C6=0,A6=()=>`__${String(++C6)}__`;function O6(){let{router:e}=Qm("useSubmit"),{basename:r}=ee.useContext(pn),t=J5();return ee.useCallback(async(n,a={})=>{let{action:i,method:s,encType:o,formData:l,body:c}=l6(n,r);if(a.navigate===!1){let f=a.fetcherKey||A6();await e.fetch(f,t,a.action||i,{preventScrollReset:a.preventScrollReset,formData:l,body:c,formMethod:a.method||s,formEncType:a.encType||o,flushSync:a.flushSync})}else await e.navigate(a.action||i,{preventScrollReset:a.preventScrollReset,formData:l,body:c,formMethod:a.method||s,formEncType:a.encType||o,replace:a.replace,state:a.state,fromRouteId:t,flushSync:a.flushSync,viewTransition:a.viewTransition})},[e,r,t])}function D6(e,{relative:r}={}){let{basename:t}=ee.useContext(pn),n=ee.useContext(xn);Rt(n,"useFormAction must be used inside a RouteContext");let[a]=n.matches.slice(-1),i={...Zi(e||".",{relative:r})},s=ha();if(e==null){i.search=s.search;let o=new URLSearchParams(i.search),l=o.getAll("index");if(l.some(f=>f==="")){o.delete("index"),l.filter(u=>u).forEach(u=>o.append("index",u));let f=o.toString();i.search=f?`?${f}`:""}}return(!e||e===".")&&a.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),t!=="/"&&(i.pathname=i.pathname==="/"?t:hn([t,i.pathname])),Mf(i)}function N6(e,r={}){let t=ee.useContext(Wm);Rt(t!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=Qm("useViewTransitionState"),a=Zi(e,{relative:r.relative});if(!t.isTransitioning)return!1;let i=da(t.currentLocation.pathname,n)||t.currentLocation.pathname,s=da(t.nextLocation.pathname,n)||t.nextLocation.pathname;return No(a.pathname,s)!=null||No(a.pathname,i)!=null}new TextEncoder;const pa=({text:e="",isDisabled:r=!1,isLoading:t=!1,btnClass:n="bg-primary-500 text-white",icon:a="",iconPosition:i="left",iconClass:s="text-[20px]",loadingClass:o="",link:l="",div:c=!1,type:f="button",style:u,onClick:d})=>{const p=qe("btn inline-flex justify-center",{"pointer-events-none":t,"opacity-40 cursor-not-allowed":r},n),h=()=>t?T.jsxs(T.Fragment,{children:[T.jsxs("svg",{className:`animate-spin -ml-1 mr-3 h-5 w-5 ${o}`,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[T.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),T.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"})]}),"Loading..."]}):T.jsxs("span",{className:"flex items-center",children:[a&&i==="left"&&T.jsx("span",{className:`mr-[6px] ${s}`,children:T.jsx(ct,{icon:a})}),e&&T.jsx("span",{children:e}),a&&i==="right"&&T.jsx("span",{className:`ml-[6px] ${s}`,children:T.jsx(ct,{icon:a})})]});return c?T.jsx("div",{className:p,children:h()}):l?T.jsx(qf,{to:l,className:p,children:h()}):T.jsx("button",{disabled:r,type:f,className:p,"data-testid":"btn",onClick:d,style:u,children:h()})},I6=({isOpen:e,onClose:r})=>{const{formData:t}=k.useContext(Fr);if(!e)return null;const n=Kn("config");return T.jsx("div",{className:"fixed inset-0 bg-black/30 flex items-center justify-center z-[999] cursor-default no-drag select-none",children:T.jsxs("div",{className:"max-w-[80vw] bg-white rounded-xl shadow-xl relative flex flex-col items-center w-full py-6 ",children:[T.jsx("button",{type:"button",onClick:r,className:"absolute top-3 right-4 text-sm",children:"Close"}),T.jsx("div",{className:"max-h-[90vh] overflow-y-auto h-full min-h-[600px] w-full",children:T.jsx(t1,{form_data:t,ignoreValidation:!0,config:n})})]})})},tr=Kn("config");function P6({title:e,goBackUrl:r,onSubmit:t,onPublish:n}){const{addSection:a,formData:i}=k.useContext(Fr),[s,o]=k.useState(!1);function l(){localStorage.setItem("formData",JSON.stringify(i)),t==null||t(i)}function c(){localStorage.setItem("formData",JSON.stringify(i)),n==null||n(i)}return T.jsxs("div",{className:"px-[30px] py-3 flex justify-between items-center bg-[#F9F9FB] top_bar",children:[T.jsxs("span",{className:"flex items-center gap-x-[6px]",children:[" ",r&&T.jsx("button",{type:"button",onClick:()=>r(),style:{color:(tr==null?void 0:tr.buttonColor)||"#333"},children:T.jsx(ct,{icon:"bxs:chevron-left-square",iconClass:"text-2xl"})})," ",T.jsx("h1",{className:"text-base font-semibold form_title",children:e||""})]}),s&&T.jsx(I6,{isOpen:s,onClose:()=>o(!1),element:void 0}),T.jsxs("div",{className:"flex justify-end text-xs gap-x-3",children:[T.jsx(pa,{onClick:()=>a(),text:"Add section",btnClass:" !px-2 !font-medium bg-transparent !text-sm form_section !normal-case",icon:"icon-park-outline:plus",iconClass:"text-base",style:{color:(tr==null?void 0:tr.buttonColor)||"#333"}}),T.jsx(pa,{onClick:()=>o(!0),text:"Preview",btnClass:"!px-2 bg-transparent !font-medium !text-sm form_preview",icon:"solar:eye-bold-duotone",iconClass:"text-base",style:{color:(tr==null?void 0:tr.buttonColor)||"#333"}}),T.jsx(pa,{onClick:()=>l(),text:"Save",btnClass:"!px-2 bg-transparent !font-medium !text-sm form_save__btn",icon:"lets-icons:save-duotone",iconClass:"text-base",style:{color:(tr==null?void 0:tr.buttonColor)||"#333"}}),T.jsx(pa,{onClick:()=>c(),text:"Publish",style:{background:(tr==null?void 0:tr.buttonColor)||"#333"},btnClass:"border-[#98A2B3] !font-medium !text-sm !py-[8px] px-6 text-white rounded-lg form_publish__btn"})]})]})}const e1=({loadingClass:e})=>{const r=qe("h-full w-full min-h-[300px] flex justify-center items-center",e);return k.useEffect(()=>{const t=Kn("config"),n=(t==null?void 0:t.loaderColor)||"#333";document.documentElement.style.setProperty("--loader-color",n)},[]),T.jsx("div",{className:r,children:T.jsx("span",{className:"loader"})})};function R6({onSubmit:e,questionData:r,title:t,goBackUrl:n,loading:a,onPublish:i}){return T.jsx(m0,{children:T.jsxs("div",{className:"w-full h-full bg-[#F5F5F5] flex flex-col",children:[T.jsx(j1,{}),T.jsx("div",{className:"border-b bg-white border-[#E4E7EC]",children:T.jsx(P6,{title:t,goBackUrl:n,onSubmit:e,onPublish:i})}),T.jsxs("div",{className:"flex flex-1 p-4 gap-x-4",children:[T.jsx("div",{children:T.jsx("div",{className:"w-[270px] border border-[#E4E7EC] bg-white max-h-[calc(100vh-100px)] overflow-y-auto side_shadow rounded-lg no-scrollbar",children:T.jsx(p5,{})})}),T.jsx("div",{className:"flex-1 h-full max-h-full z-[1] ",children:a?T.jsx(e1,{loadingClass:"!w-full !h-[800px]"}):T.jsx(d5,{questionData:r})})]})]})})}const L6=({onSubmit:e,questionData:r,isReadOnly:t,config:n={buttonColor:"#333"},title:a,loading:i,goBackUrl:s,onPublish:o})=>(k.useEffect(()=>{n&&uh("config",n)},[n]),T.jsx(R6,{onSubmit:e,onPublish:o,questionData:r,isReadOnly:t,title:a,goBackUrl:s,loading:i})),xa={required:"This field is required",email:"Invalid email format",minLength:e=>`Minimum length is ${e}`,maxLength:e=>`Maximum length is ${e}`,minAmount:e=>`Minimum amount is ${e}`,maxAmount:e=>`Maximum amount is ${e}`},M6=e=>({textField:Ze().nullable(),longText:Ze().nullable(),numberField:Ca().nullable().transform(t=>isNaN(t)?null:t),amountField:Ca().nullable().transform(t=>isNaN(t)?null:t),selectField:Ze().nullable(),checkbox:Fa().nullable(),radio:Fa().nullable(),email:Ze().nullable().email(xa.email),date:Ec().typeError("Invalid date").nullable()})[e]||Fa().nullable(),B6=(e,r,t)=>r?e.type==="boolean"?e.oneOf([!0],t||xa.required):e.required(t||xa.required):e,j6=(e,{minLength:r,maxLength:t,minLengthMessage:n,maxLengthMessage:a})=>{let i=e;return r&&(i=i.min(r,n||xa.minLength(r))),t&&(i=i.max(t,a||xa.maxLength(t))),i},$6=(e,{minAmount:r,maxAmount:t,minAmountMessage:n,maxAmountMessage:a})=>{let i=e;return r&&(i=i.min(parseFloat(String(r)),n||xa.minAmount(r))),t&&(i=i.max(parseFloat(String(t)),a||xa.maxAmount(t))),i};function U6(e){const r={};return e.forEach(({questionData:t})=>{t.forEach(n=>{const{id:a,type:i,isRequired:s,requiredMessage:o}=n;let l=M6(i);l=B6(l,s,o),i==="textField"||i==="longText"||i==="email"?l=j6(l,n):(i==="numberField"||i==="amountField")&&(l=$6(l,n)),r[a]=l})}),yi().shape(r)}function V6(e){return e.reduce((r,t)=>(r[t.id]=t.value,r),{})}const jo=(e,r)=>{const t=Im[e.type];return t?T.jsxs("div",{children:[e.inputLabel&&T.jsx("label",{className:"block text-sm font-medium mb-[5px]",children:e.inputLabel}),T.jsx(t,{element:e,state:"edit",validationData:r})]}):null};function H6({form_data:e,options:r}){return T.jsx("div",{className:"grid gap-y-6",children:e.flatMap(t=>{var n;return(n=t.questionData)==null?void 0:n.map(a=>{var i,s;if(a.type==="grid"){const o=t.questionData.filter(l=>l.gridId===a.id);return T.jsx(Rf,{element:a,customClass:"p-0 min-h-[60px] border-none",children:o.map(l=>{var c;return T.jsx(Pf,{col:(c=l.gridPosition)==null?void 0:c.col,customClass:"p-0",children:jo(l,r)},l.id)})},a.id)}return a.gridId?null:T.jsxs("div",{className:qe("group relative grid gap-y-[6px]",a.elementClass),children:[jo(a,r),T.jsx("div",{className:"text-xs text-red-600 mt-1",children:(s=(i=r==null?void 0:r.errors)==null?void 0:i[a.id])==null?void 0:s.message})]},a.id)})})})}function W6({form_data:e,options:r,current:t}){var n;return T.jsx("div",{className:"grid gap-y-6",children:(n=e[t].questionData)==null?void 0:n.map(a=>{var i,s;if(a.type==="grid"){const o=e[t].questionData.filter(l=>l.gridId===a.id);return T.jsx(Rf,{element:a,customClass:"p-0 min-h-[60px] border-none",children:o.map(l=>{var c;return T.jsx(Pf,{col:(c=l.gridPosition)==null?void 0:c.col,customClass:"p-0",children:jo(l,r)},l.id)})},a.id)}return a.gridId?null:T.jsxs("div",{className:qe("group relative grid gap-y-[6px]",a.elementClass),children:[jo(a,r),T.jsx("div",{className:"text-xs text-red-600 mt-1",children:(s=(i=r==null?void 0:r.errors)==null?void 0:i[a.id])==null?void 0:s.message})]},a.id)})})}const z6=({form_data:e,answerData:r,ignoreValidation:t,onSubmitData:n,isReadOnly:a,renderType:i="multi"})=>{const[s,o]=k.useState(0),l=k.useMemo(()=>e.length,[e]),c=U6(e),f=xc({resolver:mc(c),mode:"onSubmit",defaultValues:{}}),{register:u,setValue:d,watch:p,handleSubmit:h,reset:x,getValues:m,formState:{errors:v,isSubmitting:y},trigger:g}=f,F=Kn("config"),D=_=>{const b=e.flatMap(O=>O.questionData.map(I=>({id:I.id,value:_[I.id],sectionId:O.id,type:I.type})));n==null||n(b)};k.useEffect(()=>{if(r!=null&&r.length){const _=V6(r);x(_)}},[r,x]);async function S(){var _;!t&&!await g((_=e==null?void 0:e[s].questionData)==null?void 0:_.map(O=>O.id))||o(b=>b+1)}function E(){o(_=>_-1)}return T.jsx(m0,{children:T.jsx(f2,{...f,children:T.jsxs("form",{onSubmit:h(D),className:"container mx-auto p-6 h-full",children:[T.jsx("div",{className:"relative w-full flex flex-col gap-y-12 py-4",children:T.jsxs("div",{children:[T.jsxs("div",{className:"mb-4",children:[(e==null?void 0:e[s].title)&&T.jsx("h2",{className:"text-lg font-semibold mb-[6px]",children:e[s].title}),(e==null?void 0:e[s].description)&&T.jsx("p",{className:"text-sm",children:e[s].description})]}),i==="multi"?T.jsx(W6,{form_data:e,options:{register:u,setValue:d,watch:p,errors:v,trigger:g,isSubmitting:y,isReadOnly:a,getValues:m},current:s}):T.jsx(H6,{form_data:e,options:{register:u,setValue:d,watch:p,errors:v,trigger:g,isSubmitting:y,isReadOnly:a,getValues:m}})]},e==null?void 0:e[s].id)}),T.jsxs("div",{className:"pt-8 flex justify-end items-center gap-4",children:[s!==0&&T.jsx(pa,{type:"button",text:"Back",onClick:E,btnClass:"text-gray-700 border-[#98A2B3] !font-medium !py-[10px] px-10 bg-gray-200 rounded-lg"}),s!==l-1?T.jsx(pa,{type:"button",text:"Continue",onClick:S,style:{background:(F==null?void 0:F.buttonColor)||"#333"},btnClass:"text-gray-700 border-[#98A2B3] !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg"}):!t&&T.jsx(pa,{isDisabled:y,isLoading:y,type:"submit",text:"Submit",style:{background:(F==null?void 0:F.buttonColor)||"#333"},btnClass:"text-gray-700 border-[#98A2B3] !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg"})]})]})})})};function t1({answerData:e,form_data:r,ignoreValidation:t,onSubmit:n,isReadOnly:a=!1,loading:i=!1,config:s={buttonColor:"#333"},renderType:o}){return k.useEffect(()=>{s&&uh("config",s)},[s]),i?T.jsx(e1,{}):r?T.jsx("div",{className:"w-full h-full",children:T.jsx(z6,{form_data:r,answerData:e,ignoreValidation:t,onSubmitData:n,isReadOnly:a,renderType:o})}):T.jsx("div",{children:T.jsx("p",{children:"Error: No form data available. Please ensure the form data is saved correctly."})})}en.FormBuilder=L6,en.FormViewer=t1,Object.defineProperty(en,Symbol.toStringTag,{value:"Module"})});
|