sera-components 1.2.1 → 1.3.0
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/basic/Menu.d.ts +28 -29
- package/dist/basic/index.d.ts +0 -1
- package/dist/data/display/index.d.ts +4 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1030 -1020
- package/dist/index.umd.cjs +5 -5
- package/package.json +4 -3
- package/dist/basic/ExternalComponent.d.ts +0 -16
- package/dist/types.d.ts +0 -5
package/dist/index.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(b,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("react"),require("@mantine/core"),require("@tabler/icons-react"),require("mobx-react-lite"),require("sera-db"),require("sera-route"),require("react-imask"),require("@tanstack/react-table")):typeof define=="function"&&define.amd?define(["exports","react","@mantine/core","@tabler/icons-react","mobx-react-lite","sera-db","sera-route","react-imask","@tanstack/react-table"],S):(b=typeof globalThis<"u"?globalThis:b||self,S(b["sera-components"]={},b.React,b["@mantine/core"],b["@tabler/icons-react"],b["mobx-react-lite"],b["sera-db"],b["sera-route"],b.ReactIMask,b["@tanstack/react-table"]))})(this,(function(b,S,u,M,W,K,We,Gt,Z){"use strict";var fa=Object.defineProperty;var ha=(b,S,u)=>S in b?fa(b,S,{enumerable:!0,configurable:!0,writable:!0,value:u}):b[S]=u;var X=(b,S,u)=>ha(b,typeof S!="symbol"?S+"":S,u);function Wt(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const h=Wt(S);var ce={exports:{}},oe={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Ve;function Vt(){return Ve||(Ve=1,process.env.NODE_ENV!=="production"&&function(){function e(
|
|
17
|
+
*/var Ve;function Vt(){return Ve||(Ve=1,process.env.NODE_ENV!=="production"&&(function(){function e(m){if(m==null)return null;if(typeof m=="function")return m.$$typeof===Y?null:m.displayName||m.name||null;if(typeof m=="string")return m;switch(m){case x:return"Fragment";case k:return"Profiler";case C:return"StrictMode";case R:return"Suspense";case G:return"SuspenseList";case O:return"Activity"}if(typeof m=="object")switch(typeof m.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),m.$$typeof){case y:return"Portal";case w:return(m.displayName||"Context")+".Provider";case j:return(m._context.displayName||"Context")+".Consumer";case E:var T=m.render;return m=m.displayName,m||(m=T.displayName||T.name||"",m=m!==""?"ForwardRef("+m+")":"ForwardRef"),m;case D:return T=m.displayName||null,T!==null?T:e(m.type)||"Memo";case Q:T=m._payload,m=m._init;try{return e(m(T))}catch{}}return null}function n(m){return""+m}function t(m){try{n(m);var T=!1}catch{T=!0}if(T){T=console;var N=T.error,L=typeof Symbol=="function"&&Symbol.toStringTag&&m[Symbol.toStringTag]||m.constructor.name||"Object";return N.call(T,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",L),n(m)}}function a(m){if(m===x)return"<>";if(typeof m=="object"&&m!==null&&m.$$typeof===Q)return"<...>";try{var T=e(m);return T?"<"+T+">":"<...>"}catch{return"<...>"}}function r(){var m=re.A;return m===null?null:m.getOwner()}function o(){return Error("react-stack-top-frame")}function l(m){if(_t.call(m,"key")){var T=Object.getOwnPropertyDescriptor(m,"key").get;if(T&&T.isReactWarning)return!1}return m.key!==void 0}function s(m,T){function N(){$t||($t=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",T))}N.isReactWarning=!0,Object.defineProperty(m,"key",{get:N,configurable:!0})}function d(){var m=e(this.type);return zt[m]||(zt[m]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),m=this.props.ref,m!==void 0?m:null}function c(m,T,N,L,J,_,qe,Ue){return N=_.ref,m={$$typeof:g,type:m,key:T,props:_,_owner:J},(N!==void 0?N:null)!==null?Object.defineProperty(m,"ref",{enumerable:!1,get:d}):Object.defineProperty(m,"ref",{enumerable:!1,value:null}),m._store={},Object.defineProperty(m._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(m,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(m,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:qe}),Object.defineProperty(m,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Ue}),Object.freeze&&(Object.freeze(m.props),Object.freeze(m)),m}function f(m,T,N,L,J,_,qe,Ue){var F=T.children;if(F!==void 0)if(L)if(da(F)){for(L=0;L<F.length;L++)p(F[L]);Object.freeze&&Object.freeze(F)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p(F);if(_t.call(T,"key")){F=e(m);var ae=Object.keys(T).filter(function(ca){return ca!=="key"});L=0<ae.length?"{key: someKey, "+ae.join(": ..., ")+": ...}":"{key: someKey}",Ut[F+L]||(ae=0<ae.length?"{"+ae.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,F,
|
|
22
|
+
<%s key={someKey} {...props} />`,L,F,ae,F),Ut[F+L]=!0)}if(F=null,N!==void 0&&(t(N),F=""+N),l(T)&&(t(T.key),F=""+T.key),"key"in T){N={};for(var Ge in T)Ge!=="key"&&(N[Ge]=T[Ge])}else N=T;return F&&s(N,typeof m=="function"?m.displayName||m.name||"Unknown":m),c(m,F,_,J,r(),N,qe,Ue)}function p(m){typeof m=="object"&&m!==null&&m.$$typeof===g&&m._store&&(m._store.validated=1)}var v=S,g=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),j=Symbol.for("react.consumer"),w=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),G=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),Y=Symbol.for("react.client.reference"),re=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_t=Object.prototype.hasOwnProperty,da=Array.isArray,Be=console.createTask?console.createTask:function(){return null};v={react_stack_bottom_frame:function(m){return m()}};var $t,zt={},Bt=v.react_stack_bottom_frame.bind(v,o)(),qt=Be(a(o)),Ut={};ie.Fragment=x,ie.jsx=function(m,T,N,L,J){var _=1e4>re.recentlyCreatedOwnerStacks++;return f(m,T,N,!1,L,J,_?Error("react-stack-top-frame"):Bt,_?Be(a(m)):qt)},ie.jsxs=function(m,T,N,L,J){var _=1e4>re.recentlyCreatedOwnerStacks++;return f(m,T,N,!0,L,J,_?Error("react-stack-top-frame"):Bt,_?Be(a(m)):qt)}})()),ie}var He;function Ht(){return He||(He=1,process.env.NODE_ENV==="production"?ce.exports=Kt():ce.exports=Vt()),ce.exports}var i=Ht();const P={UK:{svgFlag:"https://flagcdn.com/gb.svg",emojiFlag:"🇬🇧"},VN:{svgFlag:"https://flagcdn.com/vn.svg",emojiFlag:"🇻🇳"},US:{svgFlag:"https://flagcdn.com/us.svg",emojiFlag:"🇺🇸"},CA:{svgFlag:"https://flagcdn.com/ca.svg",emojiFlag:"🇨🇦"},BR:{svgFlag:"https://flagcdn.com/br.svg",emojiFlag:"🇧🇷"},ES:{svgFlag:"https://flagcdn.com/es.svg",emojiFlag:"🇪🇸"},IT:{svgFlag:"https://flagcdn.com/it.svg",emojiFlag:"🇮🇹"},NZ:{svgFlag:"https://flagcdn.com/nz.svg",emojiFlag:"🇳🇿"},MX:{svgFlag:"https://flagcdn.com/mx.svg",emojiFlag:"🇲🇽"},CN:{svgFlag:"https://flagcdn.com/cn.svg",emojiFlag:"🇨🇳"},AU:{svgFlag:"https://flagcdn.com/au.svg",emojiFlag:"🇦🇺"},JP:{svgFlag:"https://flagcdn.com/jp.svg",emojiFlag:"🇯🇵"},FR:{svgFlag:"https://flagcdn.com/fr.svg",emojiFlag:"🇫🇷"},DE:{svgFlag:"https://flagcdn.com/de.svg",emojiFlag:"🇩🇪"},IN:{svgFlag:"https://flagcdn.com/in.svg",emojiFlag:"🇮🇳"}},Ye=({flag:e})=>i.jsx(u.Paper,{shadow:"xs",w:20,h:14,children:i.jsx(u.Image,{src:e.svgFlag,w:20,h:14,fit:"cover"})}),Je=({flag:e})=>i.jsx(u.Text,{component:"span",style:n=>({textShadow:n.shadows.xs}),children:e.emojiFlag}),fe=navigator.userAgent.includes("Windows")?Ye:Je,ee=S.createContext(new Intl.Locale("en-US")),Yt=W.observer(({value:e,children:n})=>i.jsx(ee.Provider,{value:e.locale,children:n})),Jt={lang2value:{en:"Choose Language",vi:"Chọn ngôn ngữ"}},he={en:{name:"English",flag:P.US,locale:new Intl.Locale("en-US")},vi:{name:"Tiếng Việt",flag:P.VN,locale:new Intl.Locale("vi-VN")}},Xt=({locale:e,setLocale:n})=>{const t=S.useMemo(()=>Object.entries(he).map(([a,{flag:r,name:o,locale:l}])=>i.jsx(u.Menu.Item,{onClick:()=>n(l),leftSection:i.jsx(fe,{flag:r}),rightSection:e.language===a&&i.jsx(M.IconCheck,{size:"15",color:"#2986cc",stroke:2}),children:i.jsx(u.Text,{size:"sm",children:o})},a)),[he,e]);return i.jsxs(u.Menu,{width:170,children:[i.jsx(u.Menu.Target,{children:i.jsx(u.Button,{variant:"subtle",size:"sm",leftSection:i.jsx(fe,{flag:he[e.language].flag}),children:i.jsx(u.Text,{size:"sm",children:he[e.language].name})})}),i.jsxs(u.Menu.Dropdown,{children:[i.jsx(u.Menu.Label,{children:i.jsx(u.Text,{size:"sm",children:Jt.lang2value[e.language]})}),t]})]})},A=({value:e})=>{const n=S.useContext(ee);return e.lang2value[n.language]||e.lang2value[e.lang]};/**
|
|
23
23
|
* react-router v7.8.2
|
|
24
24
|
*
|
|
25
25
|
* Copyright (c) Remix Software Inc.
|
|
@@ -28,6 +28,6 @@ React keys must be passed directly to JSX without using spread:
|
|
|
28
28
|
* LICENSE.md file in the root directory of this source tree.
|
|
29
29
|
*
|
|
30
30
|
* @license MIT
|
|
31
|
-
*/function I(e,n){if(e===!1||e===null||typeof e>"u")throw new Error(n)}function
|
|
31
|
+
*/function I(e,n){if(e===!1||e===null||typeof e>"u")throw new Error(n)}function $(e,n){if(!e){typeof console<"u"&&console.warn(n);try{throw new Error(n)}catch{}}}function Se({pathname:e="/",search:n="",hash:t=""}){return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),t&&t!=="#"&&(e+=t.charAt(0)==="#"?t:"#"+t),e}function je(e){let n={};if(e){let t=e.indexOf("#");t>=0&&(n.hash=e.substring(t),e=e.substring(0,t));let a=e.indexOf("?");a>=0&&(n.search=e.substring(a),e=e.substring(0,a)),e&&(n.pathname=e)}return n}function Xe(e,n,t="/"){return Zt(e,n,t,!1)}function Zt(e,n,t,a){let r=typeof n=="string"?je(n):n,o=V(r.pathname||"/",t);if(o==null)return null;let l=Ze(e);Qt(l);let s=null;for(let d=0;s==null&&d<l.length;++d){let c=cn(o);s=un(l[d],c,a)}return s}function Ze(e,n=[],t=[],a="",r=!1){let o=(l,s,d=r,c)=>{let f={relativePath:c===void 0?l.path||"":c,caseSensitive:l.caseSensitive===!0,childrenIndex:s,route:l};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(a)&&d)return;I(f.relativePath.startsWith(a),`Absolute route path "${f.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),f.relativePath=f.relativePath.slice(a.length)}let p=z([a,f.relativePath]),v=t.concat(f);l.children&&l.children.length>0&&(I(l.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${p}".`),Ze(l.children,n,v,p,d)),!(l.path==null&&!l.index)&&n.push({path:p,score:ln(p,l.index),routesMeta:v})};return e.forEach((l,s)=>{var d;if(l.path===""||!((d=l.path)!=null&&d.includes("?")))o(l,s);else for(let c of Qe(l.path))o(l,s,!0,c)}),n}function Qe(e){let n=e.split("/");if(n.length===0)return[];let[t,...a]=n,r=t.endsWith("?"),o=t.replace(/\?$/,"");if(a.length===0)return r?[o,""]:[o];let l=Qe(a.join("/")),s=[];return s.push(...l.map(d=>d===""?o:[o,d].join("/"))),r&&s.push(...l),s.map(d=>e.startsWith("/")&&d===""?"/":d)}function Qt(e){e.sort((n,t)=>n.score!==t.score?t.score-n.score:sn(n.routesMeta.map(a=>a.childrenIndex),t.routesMeta.map(a=>a.childrenIndex)))}var en=/^:[\w-]+$/,tn=3,nn=2,rn=1,an=10,on=-2,et=e=>e==="*";function ln(e,n){let t=e.split("/"),a=t.length;return t.some(et)&&(a+=on),n&&(a+=nn),t.filter(r=>!et(r)).reduce((r,o)=>r+(en.test(o)?tn:o===""?rn:an),a)}function sn(e,n){return e.length===n.length&&e.slice(0,-1).every((a,r)=>a===n[r])?e[e.length-1]-n[n.length-1]:0}function un(e,n,t=!1){let{routesMeta:a}=e,r={},o="/",l=[];for(let s=0;s<a.length;++s){let d=a[s],c=s===a.length-1,f=o==="/"?n:n.slice(o.length)||"/",p=me({path:d.relativePath,caseSensitive:d.caseSensitive,end:c},f),v=d.route;if(!p&&c&&t&&!a[a.length-1].route.index&&(p=me({path:d.relativePath,caseSensitive:d.caseSensitive,end:!1},f)),!p)return null;Object.assign(r,p.params),l.push({params:r,pathname:z([o,p.pathname]),pathnameBase:gn(z([o,p.pathnameBase])),route:v}),p.pathnameBase!=="/"&&(o=z([o,p.pathnameBase]))}return l}function me(e,n){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[t,a]=dn(e.path,e.caseSensitive,e.end),r=n.match(t);if(!r)return null;let o=r[0],l=o.replace(/(.)\/+$/,"$1"),s=r.slice(1);return{params:a.reduce((c,{paramName:f,isOptional:p},v)=>{if(f==="*"){let y=s[v]||"";l=o.slice(0,o.length-y.length).replace(/(.)\/+$/,"$1")}const g=s[v];return p&&!g?c[f]=void 0:c[f]=(g||"").replace(/%2F/g,"/"),c},{}),pathname:o,pathnameBase:l,pattern:e}}function dn(e,n=!1,t=!0){$(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 a=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,s,d)=>(a.push({paramName:s,isOptional:d!=null}),d?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(a.push({paramName:"*"}),r+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):t?r+="\\/*$":e!==""&&e!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,n?void 0:"i"),a]}function cn(e){try{return e.split("/").map(n=>decodeURIComponent(n).replace(/\//g,"%2F")).join("/")}catch(n){return $(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${n}).`),e}}function V(e,n){if(n==="/")return e;if(!e.toLowerCase().startsWith(n.toLowerCase()))return null;let t=n.endsWith("/")?n.length-1:n.length,a=e.charAt(t);return a&&a!=="/"?null:e.slice(t)||"/"}function fn(e,n="/"){let{pathname:t,search:a="",hash:r=""}=typeof e=="string"?je(e):e;return{pathname:t?t.startsWith("/")?t:hn(t,n):n,search:pn(a),hash:xn(r)}}function hn(e,n){let t=n.replace(/\/+$/,"").split("/");return e.split("/").forEach(r=>{r===".."?t.length>1&&t.pop():r!=="."&&t.push(r)}),t.length>1?t.join("/"):"/"}function Ce(e,n,t,a){return`Cannot include a '${e}' character in a manually specified \`to.${n}\` field [${JSON.stringify(a)}]. 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 mn(e){return e.filter((n,t)=>t===0||n.route.path&&n.route.path.length>0)}function tt(e){let n=mn(e);return n.map((t,a)=>a===n.length-1?t.pathname:t.pathnameBase)}function nt(e,n,t,a=!1){let r;typeof e=="string"?r=je(e):(r={...e},I(!r.pathname||!r.pathname.includes("?"),Ce("?","pathname","search",r)),I(!r.pathname||!r.pathname.includes("#"),Ce("#","pathname","hash",r)),I(!r.search||!r.search.includes("#"),Ce("#","search","hash",r)));let o=e===""||r.pathname==="",l=o?"/":r.pathname,s;if(l==null)s=t;else{let p=n.length-1;if(!a&&l.startsWith("..")){let v=l.split("/");for(;v[0]==="..";)v.shift(),p-=1;r.pathname=v.join("/")}s=p>=0?n[p]:"/"}let d=fn(r,s),c=l&&l!=="/"&&l.endsWith("/"),f=(o||l===".")&&t.endsWith("/");return!d.pathname.endsWith("/")&&(c||f)&&(d.pathname+="/"),d}var z=e=>e.join("/").replace(/\/\/+/g,"/"),gn=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),pn=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,xn=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function vn(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var rt=["POST","PUT","PATCH","DELETE"];new Set(rt);var yn=["GET",...rt];new Set(yn);var te=h.createContext(null);te.displayName="DataRouter";var ge=h.createContext(null);ge.displayName="DataRouterState",h.createContext(!1);var at=h.createContext({isTransitioning:!1});at.displayName="ViewTransition";var bn=h.createContext(new Map);bn.displayName="Fetchers";var wn=h.createContext(null);wn.displayName="Await";var B=h.createContext(null);B.displayName="Navigation";var Ee=h.createContext(null);Ee.displayName="Location";var q=h.createContext({outlet:null,matches:[],isDataRoute:!1});q.displayName="Route";var ke=h.createContext(null);ke.displayName="RouteError";function Sn(e,{relative:n}={}){I(pe(),"useHref() may be used only in the context of a <Router> component.");let{basename:t,navigator:a}=h.useContext(B),{hash:r,pathname:o,search:l}=le(e,{relative:n}),s=o;return t!=="/"&&(s=o==="/"?t:z([t,o])),a.createHref({pathname:s,search:l,hash:r})}function pe(){return h.useContext(Ee)!=null}function H(){return I(pe(),"useLocation() may be used only in the context of a <Router> component."),h.useContext(Ee).location}var ot="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function it(e){h.useContext(B).static||h.useLayoutEffect(e)}function Te(){let{isDataRoute:e}=h.useContext(q);return e?An():jn()}function jn(){I(pe(),"useNavigate() may be used only in the context of a <Router> component.");let e=h.useContext(te),{basename:n,navigator:t}=h.useContext(B),{matches:a}=h.useContext(q),{pathname:r}=H(),o=JSON.stringify(tt(a)),l=h.useRef(!1);return it(()=>{l.current=!0}),h.useCallback((d,c={})=>{if($(l.current,ot),!l.current)return;if(typeof d=="number"){t.go(d);return}let f=nt(d,JSON.parse(o),r,c.relative==="path");e==null&&n!=="/"&&(f.pathname=f.pathname==="/"?n:z([n,f.pathname])),(c.replace?t.replace:t.push)(f,c.state,c)},[n,t,o,r,e])}h.createContext(null);function le(e,{relative:n}={}){let{matches:t}=h.useContext(q),{pathname:a}=H(),r=JSON.stringify(tt(t));return h.useMemo(()=>nt(e,JSON.parse(r),a,n==="path"),[e,r,a,n])}function Cn(e,n,t,a,r){I(pe(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=h.useContext(B),{matches:l}=h.useContext(q),s=l[l.length-1],d=s?s.params:{},c=s?s.pathname:"/",f=s?s.pathnameBase:"/",p=s&&s.route;{let j=p&&p.path||"";st(c,!p||j.endsWith("*")||j.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${j}">) 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.
|
|
32
32
|
|
|
33
|
-
Please change the parent <Route path="${j}"> to <Route path="${j==="/"?"*":`${j}/*`}">.`)}let x=J(),h;h=x;let v=h.pathname||"/",S=v;if(f!=="/"){let j=f.replace(/^\//,"").split("/");S="/"+v.replace(/^\//,"").split("/").slice(j.length).join("/")}let E=Xe(e,{pathname:S});return _(p||E!=null,`No routes matched location "${h.pathname}${h.search}${h.hash}" `),_(E==null||E[E.length-1].route.element!==void 0||E[E.length-1].route.Component!==void 0||E[E.length-1].route.lazy!==void 0,`Matched leaf route at location "${h.pathname}${h.search}${h.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.`),Rn(E&&E.map(j=>Object.assign({},j,{params:Object.assign({},d,j.params),pathname:$([f,o.encodeLocation?o.encodeLocation(j.pathname).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?f:$([f,o.encodeLocation?o.encodeLocation(j.pathnameBase).pathname:j.pathnameBase])})),l,t,a,r)}function En(){let e=Mn(),n=vn(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),t=e instanceof Error?e.stack:null,a="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:a},o={padding:"2px 4px",backgroundColor:a},l=null;return console.error("Error handled by React Router default ErrorBoundary:",e),l=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:o},"ErrorBoundary")," or"," ",m.createElement("code",{style:o},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},n),t?m.createElement("pre",{style:r},t):null,l)}var kn=m.createElement(En,null),Tn=class extends m.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,n){return n.location!==e.location||n.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:n.error,location:n.location,revalidation:e.revalidation||n.revalidation}}componentDidCatch(e,n){this.props.unstable_onError?this.props.unstable_onError(e,n):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?m.createElement(B.Provider,{value:this.props.routeContext},m.createElement(Ne.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Nn({routeContext:e,match:n,children:t}){let a=m.useContext(ee);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),m.createElement(B.Provider,{value:e},t)}function Rn(e,n=[],t=null,a=null,r=null){if(e==null){if(!t)return null;if(t.errors)e=t.matches;else if(n.length===0&&!t.initialized&&t.matches.length>0)e=t.matches;else return null}let o=e,l=t==null?void 0:t.errors;if(l!=null){let c=o.findIndex(f=>f.route.id&&(l==null?void 0:l[f.route.id])!==void 0);I(c>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),o=o.slice(0,Math.min(o.length,c+1))}let s=!1,d=-1;if(t)for(let c=0;c<o.length;c++){let f=o[c];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(d=c),f.route.id){let{loaderData:p,errors:x}=t,h=f.route.loader&&!p.hasOwnProperty(f.route.id)&&(!x||x[f.route.id]===void 0);if(f.route.lazy||h){s=!0,d>=0?o=o.slice(0,d+1):o=[o[0]];break}}}return o.reduceRight((c,f,p)=>{let x,h=!1,v=null,S=null;t&&(x=l&&f.route.id?l[f.route.id]:void 0,v=f.route.errorElement||kn,s&&(d<0&&p===0?(ut("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),h=!0,S=null):d===p&&(h=!0,S=f.route.hydrateFallbackElement||null)));let E=n.concat(o.slice(0,p+1)),C=()=>{let j;return x?j=v:h?j=S:f.route.Component?j=m.createElement(f.route.Component,null):f.route.element?j=f.route.element:j=c,m.createElement(Nn,{match:f,routeContext:{outlet:c,matches:E,isDataRoute:t!=null},children:j})};return t&&(f.route.ErrorBoundary||f.route.errorElement||p===0)?m.createElement(Tn,{location:t.location,revalidation:t.revalidation,component:v,error:x,children:C(),routeContext:{outlet:null,matches:E,isDataRoute:!0},unstable_onError:a}):C()},null)}function Re(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Pn(e){let n=m.useContext(ee);return I(n,Re(e)),n}function In(e){let n=m.useContext(ge);return I(n,Re(e)),n}function Fn(e){let n=m.useContext(B);return I(n,Re(e)),n}function Pe(e){let n=Fn(e),t=n.matches[n.matches.length-1];return I(t.route.id,`${e} can only be used on routes that contain a unique "id"`),t.route.id}function Ln(){return Pe("useRouteId")}function Mn(){var a;let e=m.useContext(Ne),n=In("useRouteError"),t=Pe("useRouteError");return e!==void 0?e:(a=n.errors)==null?void 0:a[t]}function On(){let{router:e}=Pn("useNavigate"),n=Pe("useNavigate"),t=m.useRef(!1);return it(()=>{t.current=!0}),m.useCallback(async(r,o={})=>{_(t.current,ot),t.current&&(typeof r=="number"?e.navigate(r):await e.navigate(r,{fromRouteId:n,...o}))},[e,n])}var st={};function ut(e,n,t){!n&&!st[e]&&(st[e]=!0,_(!1,t))}m.memo(An);function An({routes:e,future:n,state:t,unstable_onError:a}){return Cn(e,void 0,t,a,n)}var xe="get",ve="application/x-www-form-urlencoded";function ye(e){return e!=null&&typeof e.tagName=="string"}function Dn(e){return ye(e)&&e.tagName.toLowerCase()==="button"}function _n(e){return ye(e)&&e.tagName.toLowerCase()==="form"}function $n(e){return ye(e)&&e.tagName.toLowerCase()==="input"}function zn(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Bn(e,n){return e.button===0&&(!n||n==="_self")&&!zn(e)}var be=null;function qn(){if(be===null)try{new FormData(document.createElement("form"),0),be=!1}catch{be=!0}return be}var Un=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ie(e){return e!=null&&!Un.has(e)?(_(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ve}"`),null):e}function Gn(e,n){let t,a,r,o,l;if(_n(e)){let s=e.getAttribute("action");a=s?W(s,n):null,t=e.getAttribute("method")||xe,r=Ie(e.getAttribute("enctype"))||ve,o=new FormData(e)}else if(Dn(e)||$n(e)&&(e.type==="submit"||e.type==="image")){let s=e.form;if(s==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let d=e.getAttribute("formaction")||s.getAttribute("action");if(a=d?W(d,n):null,t=e.getAttribute("formmethod")||s.getAttribute("method")||xe,r=Ie(e.getAttribute("formenctype"))||Ie(s.getAttribute("enctype"))||ve,o=new FormData(s,e),!qn()){let{name:c,type:f,value:p}=e;if(f==="image"){let x=c?`${c}.`:"";o.append(`${x}x`,"0"),o.append(`${x}y`,"0")}else c&&o.append(c,p)}}else{if(ye(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');t=xe,a=null,r=ve,l=e}return o&&r==="text/plain"&&(l=o,o=void 0),{action:a,method:t.toLowerCase(),encType:r,formData:o,body:l}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Fe(e,n){if(e===!1||e===null||typeof e>"u")throw new Error(n)}function Wn(e,n,t){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return a.pathname==="/"?a.pathname=`_root.${t}`:n&&W(a.pathname,n)==="/"?a.pathname=`${n.replace(/\/$/,"")}/_root.${t}`:a.pathname=`${a.pathname.replace(/\/$/,"")}.${t}`,a}async function Kn(e,n){if(e.id in n)return n[e.id];try{let t=await import(e.module);return n[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 Vn(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 Hn(e,n,t){let a=await Promise.all(e.map(async r=>{let o=n.routes[r.route.id];if(o){let l=await Kn(o,t);return l.links?l.links():[]}return[]}));return Zn(a.flat(1).filter(Vn).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function dt(e,n,t,a,r,o){let l=(d,c)=>t[c]?d.route.id!==t[c].route.id:!0,s=(d,c)=>{var f;return t[c].pathname!==d.pathname||((f=t[c].route.path)==null?void 0:f.endsWith("*"))&&t[c].params["*"]!==d.params["*"]};return o==="assets"?n.filter((d,c)=>l(d,c)||s(d,c)):o==="data"?n.filter((d,c)=>{var p;let f=a.routes[d.route.id];if(!f||!f.hasLoader)return!1;if(l(d,c)||s(d,c))return!0;if(d.route.shouldRevalidate){let x=d.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:((p=t[0])==null?void 0:p.params)||{},nextUrl:new URL(e,window.origin),nextParams:d.params,defaultShouldRevalidate:!0});if(typeof x=="boolean")return x}return!0}):[]}function Yn(e,n,{includeHydrateFallback:t}={}){return Jn(e.map(a=>{let r=n.routes[a.route.id];if(!r)return[];let o=[r.module];return r.clientActionModule&&(o=o.concat(r.clientActionModule)),r.clientLoaderModule&&(o=o.concat(r.clientLoaderModule)),t&&r.hydrateFallbackModule&&(o=o.concat(r.hydrateFallbackModule)),r.imports&&(o=o.concat(r.imports)),o}).flat(1))}function Jn(e){return[...new Set(e)]}function Xn(e){let n={},t=Object.keys(e).sort();for(let a of t)n[a]=e[a];return n}function Zn(e,n){let t=new Set;return new Set(n),e.reduce((a,r)=>{let o=JSON.stringify(Xn(r));return t.has(o)||(t.add(o),a.push({key:o,link:r})),a},[])}function ct(){let e=m.useContext(ee);return Fe(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Qn(){let e=m.useContext(ge);return Fe(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Le=m.createContext(void 0);Le.displayName="FrameworkContext";function ft(){let e=m.useContext(Le);return Fe(e,"You must render this element inside a <HydratedRouter> element"),e}function er(e,n){let t=m.useContext(Le),[a,r]=m.useState(!1),[o,l]=m.useState(!1),{onFocus:s,onBlur:d,onMouseEnter:c,onMouseLeave:f,onTouchStart:p}=n,x=m.useRef(null);m.useEffect(()=>{if(e==="render"&&l(!0),e==="viewport"){let S=C=>{C.forEach(j=>{l(j.isIntersecting)})},E=new IntersectionObserver(S,{threshold:.5});return x.current&&E.observe(x.current),()=>{E.disconnect()}}},[e]),m.useEffect(()=>{if(a){let S=setTimeout(()=>{l(!0)},100);return()=>{clearTimeout(S)}}},[a]);let h=()=>{r(!0)},v=()=>{r(!1),l(!1)};return t?e!=="intent"?[o,x,{}]:[o,x,{onFocus:se(s,h),onBlur:se(d,v),onMouseEnter:se(c,h),onMouseLeave:se(f,v),onTouchStart:se(p,h)}]:[!1,x,{}]}function se(e,n){return t=>{e&&e(t),t.defaultPrevented||n(t)}}function tr({page:e,...n}){let{router:t}=ct(),a=m.useMemo(()=>Xe(t.routes,e,t.basename),[t.routes,e,t.basename]);return a?m.createElement(rr,{page:e,matches:a,...n}):null}function nr(e){let{manifest:n,routeModules:t}=ft(),[a,r]=m.useState([]);return m.useEffect(()=>{let o=!1;return Hn(e,n,t).then(l=>{o||r(l)}),()=>{o=!0}},[e,n,t]),a}function rr({page:e,matches:n,...t}){let a=J(),{manifest:r,routeModules:o}=ft(),{basename:l}=ct(),{loaderData:s,matches:d}=Qn(),c=m.useMemo(()=>dt(e,n,d,r,a,"data"),[e,n,d,r,a]),f=m.useMemo(()=>dt(e,n,d,r,a,"assets"),[e,n,d,r,a]),p=m.useMemo(()=>{if(e===a.pathname+a.search+a.hash)return[];let v=new Set,S=!1;if(n.forEach(C=>{var b;let j=r.routes[C.route.id];!j||!j.hasLoader||(!c.some(T=>T.route.id===C.route.id)&&C.route.id in s&&((b=o[C.route.id])!=null&&b.shouldRevalidate)||j.hasClientLoader?S=!0:v.add(C.route.id))}),v.size===0)return[];let E=Wn(e,l,"data");return S&&v.size>0&&E.searchParams.set("_routes",n.filter(C=>v.has(C.route.id)).map(C=>C.route.id).join(",")),[E.pathname+E.search]},[l,s,a,r,c,n,e,o]),x=m.useMemo(()=>Yn(f,r),[f,r]),h=nr(f);return m.createElement(m.Fragment,null,p.map(v=>m.createElement("link",{key:v,rel:"prefetch",as:"fetch",href:v,...t})),x.map(v=>m.createElement("link",{key:v,rel:"modulepreload",href:v,...t})),h.map(({key:v,link:S})=>m.createElement("link",{key:v,nonce:t.nonce,...S})))}function ar(...e){return n=>{e.forEach(t=>{typeof t=="function"?t(n):t!=null&&(t.current=n)})}}var ht=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{ht&&(window.__reactRouterVersion="7.8.2")}catch{}var mt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,gt=m.forwardRef(function({onClick:n,discover:t="render",prefetch:a="none",relative:r,reloadDocument:o,replace:l,state:s,target:d,to:c,preventScrollReset:f,viewTransition:p,...x},h){let{basename:v}=m.useContext(z),S=typeof c=="string"&&mt.test(c),E,C=!1;if(typeof c=="string"&&S&&(E=c,ht))try{let A=new URL(window.location.href),K=c.startsWith("//")?new URL(A.protocol+c):new URL(c),re=W(K.pathname,v);K.origin===A.origin&&re!=null?c=re+K.search+K.hash:C=!0}catch{_(!1,`<Link to="${c}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let j=jn(c,{relative:r}),[b,T,P]=er(a,x),ne=sr(c,{replace:l,state:s,target:d,preventScrollReset:f,relative:r,viewTransition:p});function X(A){n&&n(A),A.defaultPrevented||ne(A)}let Z=m.createElement("a",{...x,...P,href:E||j,onClick:C||o?n:X,ref:ar(h,T),target:d,"data-discover":!S&&t==="render"?"true":void 0});return b&&!S?m.createElement(m.Fragment,null,Z,m.createElement(tr,{page:j})):Z});gt.displayName="Link";var or=m.forwardRef(function({"aria-current":n="page",caseSensitive:t=!1,className:a="",end:r=!1,style:o,to:l,viewTransition:s,children:d,...c},f){let p=le(l,{relative:c.relative}),x=J(),h=m.useContext(ge),{navigator:v,basename:S}=m.useContext(z),E=h!=null&&hr(p)&&s===!0,C=v.encodeLocation?v.encodeLocation(p).pathname:p.pathname,j=x.pathname,b=h&&h.navigation&&h.navigation.location?h.navigation.location.pathname:null;t||(j=j.toLowerCase(),b=b?b.toLowerCase():null,C=C.toLowerCase()),b&&S&&(b=W(b,S)||b);const T=C!=="/"&&C.endsWith("/")?C.length-1:C.length;let P=j===C||!r&&j.startsWith(C)&&j.charAt(T)==="/",ne=b!=null&&(b===C||!r&&b.startsWith(C)&&b.charAt(C.length)==="/"),X={isActive:P,isPending:ne,isTransitioning:E},Z=P?n:void 0,A;typeof a=="function"?A=a(X):A=[a,P?"active":null,ne?"pending":null,E?"transitioning":null].filter(Boolean).join(" ");let K=typeof o=="function"?o(X):o;return m.createElement(gt,{...c,"aria-current":Z,className:A,ref:f,style:K,to:l,viewTransition:s},typeof d=="function"?d(X):d)});or.displayName="NavLink";var ir=m.forwardRef(({discover:e="render",fetcherKey:n,navigate:t,reloadDocument:a,replace:r,state:o,method:l=xe,action:s,onSubmit:d,relative:c,preventScrollReset:f,viewTransition:p,...x},h)=>{let v=cr(),S=fr(s,{relative:c}),E=l.toLowerCase()==="get"?"get":"post",C=typeof s=="string"&&mt.test(s),j=b=>{if(d&&d(b),b.defaultPrevented)return;b.preventDefault();let T=b.nativeEvent.submitter,P=(T==null?void 0:T.getAttribute("formmethod"))||l;v(T||b.currentTarget,{fetcherKey:n,method:P,navigate:t,replace:r,state:o,relative:c,preventScrollReset:f,viewTransition:p})};return m.createElement("form",{ref:h,method:E,action:S,onSubmit:a?d:j,...x,"data-discover":!C&&e==="render"?"true":void 0})});ir.displayName="Form";function lr(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function pt(e){let n=m.useContext(ee);return I(n,lr(e)),n}function sr(e,{target:n,replace:t,state:a,preventScrollReset:r,relative:o,viewTransition:l}={}){let s=lt(),d=J(),c=le(e,{relative:o});return m.useCallback(f=>{if(Bn(f,n)){f.preventDefault();let p=t!==void 0?t:Ce(d)===Ce(c);s(e,{replace:p,state:a,preventScrollReset:r,relative:o,viewTransition:l})}},[d,s,c,t,a,n,e,r,o,l])}var ur=0,dr=()=>`__${String(++ur)}__`;function cr(){let{router:e}=pt("useSubmit"),{basename:n}=m.useContext(z),t=Ln();return m.useCallback(async(a,r={})=>{let{action:o,method:l,encType:s,formData:d,body:c}=Gn(a,n);if(r.navigate===!1){let f=r.fetcherKey||dr();await e.fetch(f,t,r.action||o,{preventScrollReset:r.preventScrollReset,formData:d,body:c,formMethod:r.method||l,formEncType:r.encType||s,flushSync:r.flushSync})}else await e.navigate(r.action||o,{preventScrollReset:r.preventScrollReset,formData:d,body:c,formMethod:r.method||l,formEncType:r.encType||s,replace:r.replace,state:r.state,fromRouteId:t,flushSync:r.flushSync,viewTransition:r.viewTransition})},[e,n,t])}function fr(e,{relative:n}={}){let{basename:t}=m.useContext(z),a=m.useContext(B);I(a,"useFormAction must be used inside a RouteContext");let[r]=a.matches.slice(-1),o={...le(e||".",{relative:n})},l=J();if(e==null){o.search=l.search;let s=new URLSearchParams(o.search),d=s.getAll("index");if(d.some(f=>f==="")){s.delete("index"),d.filter(p=>p).forEach(p=>s.append("index",p));let f=s.toString();o.search=f?`?${f}`:""}}return(!e||e===".")&&r.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),t!=="/"&&(o.pathname=o.pathname==="/"?t:$([t,o.pathname])),Ce(o)}function hr(e,{relative:n}={}){let t=m.useContext(at);I(t!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:a}=pt("useViewTransitionState"),r=le(e,{relative:n});if(!t.isTransitioning)return!1;let o=W(t.currentLocation.pathname,a)||t.currentLocation.pathname,l=W(t.nextLocation.pathname,a)||t.nextLocation.pathname;return me(r.pathname,l)!=null||me(r.pathname,o)!=null}const mr=({message:e})=>{const n=lt();return i.jsx(u.Container,{size:"xs",style:{height:"100vh",display:"flex",alignItems:"center",justifyContent:"center"},children:i.jsx(u.Alert,{color:"red",title:"Not Found",variant:"404 - Not Found",icon:i.jsx(M.IconInfoCircle,{size:12,stroke:1.5}),children:i.jsxs(u.Stack,{align:"flex-start",children:[e||"Sorry, the page you are looking for does not exist.",i.jsx(u.Button,{variant:"filled",onClick:()=>n("/"),size:"xs",children:"Back Home"})]})})})},gr=({message:e})=>i.jsx(u.Alert,{color:"red",title:"Not Found",variant:"404 - Not Found",icon:i.jsx(M.IconInfoCircle,{size:12,stroke:1.5}),children:e||"Sorry, the page you are looking for does not exist."}),Me=({message:e})=>i.jsx(u.Text,{c:"red",size:"sm",children:e||"Not Found"}),pr=({tip:e})=>e===void 0?i.jsx(u.Flex,{justify:"center",align:"center",children:i.jsx(u.Loader,{color:"blue",size:"md"})}):i.jsxs(u.Flex,{gap:"md",direction:"column",justify:"center",align:"center",style:{height:"100%"},children:[i.jsx(u.Loader,{color:"blue",size:"md"}),e]}),xr=({tip:e})=>e===void 0?i.jsx(u.Loader,{color:"blue",size:"xs"}):i.jsxs(u.Flex,{gap:"md",direction:"column",justify:"center",align:"center",children:[i.jsx(u.Loader,{color:"blue",size:"xs"}),e]}),vr=({message:e})=>i.jsx(u.Alert,{color:"red",title:"Not Found",variant:"403 - Not Authorized",icon:i.jsx(M.IconInfoCircle,{size:12,stroke:1.5}),children:e||"Sorry, you are not authorized to access this page."});function yr(e,n){return e.reduce((t,a)=>{const r=n(a);return t[r]||(t[r]=[]),t[r].push(a),t},{})}function br(e,n){const t=[];let a;return e.reduce((r,o)=>{const l=n(o);return l===void 0?(a===void 0&&(a=t.length,t.push([])),t[a].push(o)):(r[l]===void 0&&(r[l]=t.length,t.push([])),t[r[l]].push(o)),r},{}),t}function wr(e,n){const t=new Set;return e.filter(a=>{const r=n(a);return t.has(r)?!1:(t.add(r),!0)})}class jr{constructor(){H(this,"items",[]);H(this,"seen",new Set)}add(n,t){const a=t(n);this.seen.has(a)||(this.items.push(n),this.seen.add(a))}toArray(){return this.items}}class Oe{constructor(){H(this,"children",new Map);H(this,"isEndOfWord",!1);H(this,"value","")}}class Ae{constructor(){H(this,"root",new Oe)}insert(n){let t=this.root;for(const a of n){let r=t.children.get(a);r===void 0&&(r=new Oe,t.children.set(a,r)),t=r}t.isEndOfWord=!0,t.value=n}findLongestPrefix(n){let t=this.root,a={match:"",remaining:n};for(let r=0;r<n.length;r++){const o=n[r];if(!t.children.has(o))break;t=t.children.get(o),t.isEndOfWord&&(a={match:t.value,remaining:n.slice(r+1)})}return a}}var we=(e=>(e[e.Allow=0]="Allow",e[e.Denied=1]="Denied",e[e.Pending=2]="Pending",e))(we||{});function xt(e){const n={},t={},a={},r=(o,l=[])=>{o.forEach(s=>{const d=[...l,s.key];n[s.key]=s,t[s.key]=d,s.route!==void 0&&(a[s.key]=s.route),s.children!==void 0&&s.children.length>0&&r(s.children,d)})};return r(e),{key2item:n,key2fullpath:t,key2route:a}}function Sr(e){const n=new yt,t=a=>{a.forEach(r=>{r.route!==void 0&&n.insertRoute(r.route.route.fullPath,r.key),r.children!==void 0&&r.children.length>0&&t(r.children)})};return t(e),n}function vt(e,n){return e.map(t=>{if(t.route!==void 0)return n(t.route.role)===we.Allow?t:null;if(t.children!==void 0){const a=t.children.filter(r=>r.route!==void 0?n(r.route.role)===we.Allow:!0);return a.length>0?{...t,children:a}:null}return t}).filter(t=>t!==null)}const Cr=e=>{const[n,t]=w.useState(new Set),[a,r]=w.useState(new Set),[o,l]=w.useState(),s=w.useMemo(()=>vt(e.items,e.checkPermission),[e.items,e.checkPermission]),d=w.useMemo(()=>Sr(e.items),[e.items]),{key2fullpath:c,key2route:f}=w.useMemo(()=>xt(s),[s]);w.useEffect(()=>{const x=window.location.pathname,h=d.findMatchingKey(x);h!==void 0&&(r(new Set(c[h])),l(h))},[location,f]);const p=w.useMemo(()=>{function x(h,v){var E;const S=h.children!==void 0&&h.children.length>0;return S?i.jsxs("div",{onMouseEnter:()=>{a.has(h.key)||t(C=>{const j=new Set(C);return j.add(h.key),j})},onMouseLeave:()=>{a.has(h.key)||t(C=>{const j=new Set(C);return j.delete(h.key),j})},children:[i.jsx(u.NavLink,{active:o===h.key,label:h.label,leftSection:h.icon,styles:{label:{fontSize:"md"},root:{borderRadius:"var(--mantine-radius-sm)"}},ml:v===0?void 0:v===1?"md":`calc(var(--mantine-spacing-md) * ${v})`,w:"unset",rightSection:S?i.jsx(M.IconChevronRight,{size:12,stroke:1.5,className:"mantine-rotate-rtl"}):void 0,opened:n.has(h.key)||a.has(h.key),onClick:C=>{C.preventDefault(),r(j=>{const b=new Set(j);return j.has(h.key)?b.delete(h.key):b.add(h.key),b})}},h.key),(a.has(h.key)||n.has(h.key))&&h.children.map(C=>x(C,v+1))]},`container-${h.key}`):i.jsx(u.NavLink,{active:o===h.key,href:(E=h.route)==null?void 0:E.route.fullPath,label:h.label,leftSection:h.icon,styles:{label:{fontSize:"md"},root:{borderRadius:"var(--mantine-radius-sm)"}},ml:v===0?void 0:v===1?"md":`calc(var(--mantine-spacing-md) * ${v})`,w:"unset",onClick:C=>{C.ctrlKey||C.metaKey||(C.preventDefault(),h.route!=null&&e.navigate({to:h.route.route.to}))}},h.key)}return s.map(h=>x(h,0))},[s,o,a,n]);return i.jsx(i.Fragment,{children:p})};class yt extends Ae{constructor(){super(...arguments);H(this,"pathToKey",new Map)}normalizePath(t){return t==="/"?"/":t.replace(/\/$/,"")}insertRoute(t,a){const r=this.normalizePath(t);this.insert(r),this.pathToKey.set(r,a)}findMatchingKey(t){const a=this.normalizePath(t),r=this.findLongestPrefix(a);if(r.match&&this.pathToKey.has(r.match)&&(a===r.match||r.remaining.startsWith("/")||r.remaining===""))return this.pathToKey.get(r.match)}}const je=w.createContext({link:()=>null}),Er=({link:e,children:n})=>i.jsx(je.Provider,{value:{link:e},children:n}),Se=({value:e})=>i.jsx(u.Text,{size:"sm",children:e});function De(e,n){const t=n.getDate().toString().padStart(2,"0"),a=(n.getMonth()+1).toString().padStart(2,"0"),r=n.getFullYear();return e.baseName==="en-US"?`${a}/${t}/${r}`:e.baseName==="vi-VN"?`${t}/${a}/${r}`:`${a}/${t}/${r}`}const bt=({value:e})=>{const n=w.useContext(Q),t=w.useMemo(()=>{const a=e.getHours().toString().padStart(2,"0"),r=e.getMinutes().toString().padStart(2,"0"),o=e.getSeconds().toString().padStart(2,"0");return De(n,e)+`${a}:${r}:${o}`},[n,e]);return i.jsx(u.Text,{size:"sm",children:t})},wt=({value:e})=>{const n=w.useContext(Q),t=w.useMemo(()=>De(n,e),[n,e]);return i.jsx(u.Text,{size:"sm",children:t})},kr=({value:e})=>{const n=w.useContext(Q),[t,a]=w.useMemo(()=>{const r=De(n,e),o=e.getHours().toString().padStart(2,"0"),l=e.getMinutes().toString().padStart(2,"0"),s=e.getSeconds().toString().padStart(2,"0");return[r,`${o}:${l}:${s}`]},[n,e]);return i.jsx(u.Text,{size:"sm",title:a,children:t})},Tr={yes:{lang2value:{en:"Yes",vi:"Có"},lang:"en"},no:{lang2value:{en:"No",vi:"Không"},lang:"en"}},Nr=({value:e})=>i.jsx(u.Checkbox,{checked:e,label:i.jsx(O,{value:Tr[e?"yes":"no"]}),readOnly:!0}),Rr=({nestedProperty:e,property:n,value:t})=>{const a=e||n;if(G.isObjectProperty(a)||a.enumType===void 0)throw new Error("Invalid usage of EnumDisplay. Expect a property of type enum");return i.jsx(u.Text,{size:"sm",children:i.jsx(O,{value:a.enumType.label[t]})})};function jt(e,n,t,a){const r=e.getByName(n.targetClass),o=a[n.targetClass];w.useEffect(()=>{r.fetchByIds(t)},[t]);const l={};for(const s of t)l[s]=r.get(s);return[l,o]}const ue=U.observer(({db:e,property:n,value:t,entityRoutes:a})=>{const{link:r}=w.useContext(je),o=w.useMemo(()=>[t],[t]),[l,s]=jt(e,n,o,a),d=l[t];return d===void 0?i.jsx(u.Text,{size:"sm",children:t}):d===null?i.jsx(Me,{}):s===void 0?i.jsx(u.Text,{size:"sm",children:d.name}):i.jsx(r,{to:s.to,openInNewPage:!1,params:{id:d.id},children:d.name})}),de=U.observer(({db:e,property:n,value:t,entityRoutes:a})=>{const{link:r}=w.useContext(je),[o,l]=jt(e,n,t,a);return i.jsx(u.Group,{gap:"xs",children:t.map((s,d)=>{const c=o[s];return c===void 0?i.jsx(u.Text,{size:"sm",children:t},s):c===null?i.jsx(Me,{},s):l===void 0?i.jsx(u.Text,{size:"sm",children:c.name},d):i.jsx(r,{to:l.to,openInNewPage:!1,params:{id:c.id},children:c.name},d)})})}),q={string:Se,integer:Se,float:Se,boolean:Nr,"string[]":Se,enum:Rr,datetime:bt,date:wt},Pr=({property:e,value:n,onChange:t})=>i.jsx(u.Input,{id:e.name,type:"checkbox",checked:n,onChange:a=>{const r=a.target.checked;t(r)}}),St=({property:e,value:n,onChange:t})=>i.jsx(u.Input,{id:e.name,type:"number",value:n,onChange:a=>{const r=a.target.value;t(r===""?void 0:Number(r))}}),Ir={lang2value:{en:"The leading zero is not necessary in international phone number format. For example, if your phone number is 0123456789, you should enter it as 123-456-789.",vi:"Số 0 đầu tiên không cần thiết trong định dạng điện thoại quốc tế. Ví dụ, nếu số điện thoại của bạn là 0123456789, bạn nên nhập nó là 123-456-789."},lang:"en"},Fr={lang2value:{en:"No valid country code found.",vi:"Không tìm thấy mã quốc gia hợp lệ. "},lang:"en"},te={84:{name:"Vietnam",flags:[R.VN]},1:{name:"US, Canada",flags:[R.US,R.CA]},61:{name:"Australia",flags:[R.AU]},81:{name:"Japan",flags:[R.JP]},44:{name:"UK",flags:[R.UK]},33:{name:"France",flags:[R.FR]},49:{name:"Germany",flags:[R.DE]},91:{name:"India",flags:[R.IN]},55:{name:"Brazil",flags:[R.BR]},34:{name:"Spain",flags:[R.ES]},39:{name:"Italy",flags:[R.IT]},64:{name:"New Zealand",flags:[R.NZ]},52:{name:"Mexico",flags:[R.MX]},86:{name:"China",flags:[R.CN]}},Lr=(e,n)=>{if(e==="")return{match:"84",remaining:""};const t=e.replace(/[^\d]/g,""),a=n.findLongestPrefix(t);if(a.match==="")throw new Error(`No valid country code found for phone number: ${e}`);return a},Ct=({value:e})=>{const n=te[e];if(n!==void 0)return i.jsxs(u.Group,{gap:"sm",wrap:"nowrap",align:"center",children:[i.jsxs(u.Text,{size:"sm",children:["+",e]}),i.jsx(u.Group,{gap:4,wrap:"nowrap",children:n.flags.map((t,a)=>i.jsx(fe,{flag:t},a))})]})},Mr=({value:e,onChange:n,error:t,id:a})=>{const[r,o]=w.useState(""),[l,s]=w.useState(!1),[d,c]=w.useState(""),[f,p]=w.useState(!1),x=w.useMemo(()=>{const b=new Ae;return Object.keys(te).forEach(T=>{b.insert(T)}),b},[te]),{rawInput:h}=w.useMemo(()=>{try{const{match:b,remaining:T}=Lr(e,x);return c(b),p(!1),{rawInput:T}}catch{return p(!0),c(""),{rawInput:e}}},[e]),v=u.useCombobox({onDropdownClose:()=>{v.resetSelectedOption(),o("")},onDropdownOpen:()=>{v.updateSelectedOptionIndex("active")}}),S=w.useMemo(()=>Object.keys(te),[te]),E=(b,T)=>{const P=b.replace(/[^\d]/g,"");return P.length===0?`+${T}`:P.startsWith("0")?(s(!0),`+${T}${P}`):(s(!1),`+${T}${P}`)},C=w.useMemo(()=>S.filter(b=>te[b].name.toLowerCase().includes(r.toLowerCase())||b.includes(r)),[r,S]),j=w.useMemo(()=>C.map((b,T)=>i.jsx(u.Combobox.Option,{value:b,children:i.jsx(Ct,{value:b})},T)),[C]);return i.jsxs("div",{children:[i.jsx(u.Grid,{gutter:"xs",children:i.jsx(u.Grid.Col,{children:i.jsxs(u.Group,{gap:5,children:[i.jsxs(u.Combobox,{store:v,position:"top-start",onOptionSubmit:b=>{o(""),v.closeDropdown(),n({target:{value:E(h,b)}})},children:[i.jsx(u.Combobox.Target,{children:i.jsx(u.InputBase,{component:"button",type:"button",pointer:!0,rightSection:i.jsx(u.Combobox.Chevron,{}),onClick:()=>v.toggleDropdown(),rightSectionPointerEvents:"none",w:110,children:i.jsx(Ct,{value:d})})}),i.jsxs(u.Combobox.Dropdown,{children:[i.jsx(u.Combobox.Search,{leftSection:i.jsx(M.IconSearch,{size:14,stroke:1.5}),placeholder:".....",value:r,onChange:b=>o(b.currentTarget.value)}),i.jsx(u.Combobox.Options,{children:j.length>0?j:i.jsx(u.Combobox.Empty,{children:i.jsx(u.Text,{size:"sm",children:"Nothing found"})})})]})]}),d===""?i.jsx(u.Input,{id:a,value:h,type:"phone_number",onChange:b=>{n({target:{value:b.target.value}})},error:t,flex:1}):i.jsx(u.Input,{id:a,value:h,type:"phone_number",onAccept:b=>{const T=b.replace(/[^\d]/g,"");n({target:{value:E(T,d)}})},component:Gt.IMaskInput,mask:"000-000-0000",error:t,flex:1})]})})}),(l||f||t&&typeof t=="string")&&i.jsx(u.Grid,{gutter:"xs",children:i.jsx(u.Grid.Col,{children:i.jsx(u.Input.Error,{children:l?i.jsx(O,{value:Ir}):f?i.jsx(O,{value:Fr}):t})})})]})},_e=({property:e,error:n,value:t,onChange:a})=>{const[r,o]=w.useMemo(()=>e.constraints.includes("password")?["password",u.PasswordInput]:e.constraints.includes("phone_number")?["phone_number",Mr]:[e.constraints.includes("email")?"email":e.constraints.includes("url")?"url":"text",u.Input],[e.constraints]);return i.jsx(o,{id:e.name,value:t,type:r,onChange:l=>a(l.target.value),error:n})},$e={integer:St,float:St,string:_e,boolean:Pr,"string[]":_e,enum:_e};function Or(e,n){const[t,a]=w.useState(""),[r,o]=w.useState([]);return w.useEffect(()=>{e.getByName(n.targetClass).fetch({limit:100,offset:0}).then(s=>o(s.records))},[n.name]),{data:r,query:t,setQuery:s=>{a(s);const d=e.getByName(n.targetClass);o(d.filter(c=>c.name.toLowerCase().includes(s.toLowerCase())))},table:e.getByName(n.targetClass)}}const Ar=e=>e.name,Dr=e=>i.jsx(u.Text,{size:"sm",children:e.name}),_r=U.observer(e=>i.jsx("h1",{children:"SingleForeignKey"})),$r=U.observer(({db:e,property:n,value:t,onChange:a})=>{const{table:r,data:o,query:l,setQuery:s}=Or(e,n);return i.jsxs(u.Stack,{gap:"sm",children:[i.jsx(zr,{name:n.name,query:l,setQuery:s,data:o,onSelect:d=>{t.includes(d)||a([...t,d])},renderOption:Ar,isIdInteger:n.datatype==="integer"}),i.jsx(Br,{items:t.map(d=>r.get(d)),onDelete:d=>{a(t.filter(c=>c!==d.id))},render:Dr})]})}),zr=({name:e,data:n,onSelect:t,renderOption:a,isIdInteger:r,query:o,setQuery:l})=>{const s=u.useCombobox({onDropdownClose:()=>s.resetSelectedOption()}),d=w.useMemo(()=>n.map(c=>i.jsx(u.Combobox.Option,{value:c.id.toString(),children:a(c)},c.id)),[n]);return i.jsxs(u.Combobox,{store:s,onOptionSubmit:c=>{t(r?parseInt(c):c),l(""),s.closeDropdown()},offset:0,shadow:"sm",children:[i.jsx(u.Combobox.Target,{children:i.jsx(u.Input,{id:e,pointer:!0,rightSection:i.jsx(M.IconSearch,{size:16,stroke:1.5}),rightSectionPointerEvents:"none",onClick:()=>s.toggleDropdown(),placeholder:"Type to search...",value:o,onChange:c=>{l(c.currentTarget.value)}})}),i.jsx(u.Combobox.Dropdown,{children:i.jsx(u.Combobox.Options,{children:d.length===0?i.jsx(u.Combobox.Empty,{children:"Nothing found"}):d})})]})},Br=({items:e,onDelete:n,render:t})=>{const a=w.useMemo(()=>{const r=[];for(let o=0;o<e.length;o++){const l=e[o];r.push(i.jsxs(u.Group,{justify:"space-between",p:"sm",children:[t(l),i.jsx(u.CloseButton,{size:"sm",onClick:()=>n(l)})]},o)),o<e.length-1&&r.push(i.jsx(u.Divider,{},`divider-${o}`))}return r},[e]);if(a.length!==0)return i.jsx(u.Paper,{bd:"1px solid #ddd",children:a})},Et={requiredLabelLeft:"_requiredLabelLeft_l5p83_1",requiredLabelRight:"_requiredLabelRight_l5p83_11"},kt=({label:e,name:n,required:t=!1,tooltip:a,style:r,align:o="left"})=>{const l=t?o==="left"?Et.requiredLabelRight:Et.requiredLabelLeft:"";return i.jsx(u.Flex,{align:"center",h:36,children:i.jsx("label",{htmlFor:n,style:r,children:i.jsxs(u.Group,{gap:4,children:[i.jsx(u.Text,{size:"sm",className:l,children:e}),a!==void 0&&i.jsx(u.Tooltip,{label:a,withArrow:!0,children:i.jsx(M.IconHelpOctagonFilled,{size:16,stroke:1.5,style:{color:"var(--mantine-color-dimmed)"}})})]})})})},qr={type:"vertical",helpAlwaysVisible:!1},Tt=U.observer(({store:e,record:n,property:t,layout:a=qr,InputComponent:r,validator:o})=>{const[l,s]=w.useState(void 0),d=n[t.tsName],c=p=>{var h;if(G.isDraftRecord(n))n[t.updateFuncName](p);else{const v=n.toDraft();v[t.updateFuncName](p),e.setDraft(v)}const x=o(p);x.isValid?s(void 0):s((h=x.errorMessage)==null?void 0:h.t({args:{name:t.label}}))};if(Ur(a))return i.jsxs(u.Stack,{gap:5,children:[i.jsxs(u.Grid,{gutter:"sm",children:[i.jsx(u.Grid.Col,{span:a.labelCol,style:{display:"flex",justifyContent:a.align||"left"},children:i.jsx(kt,{label:i.jsx(O,{value:t.label}),name:t.name,required:t.isRequired,tooltip:t.description!==void 0?i.jsx(O,{value:t.description}):void 0,align:a.align})}),i.jsx(u.Grid.Col,{span:a.itemCol,children:i.jsx(r,{db:e.db,property:t,value:d,error:l!==void 0,onChange:c})})]}),l!==void 0&&i.jsxs(u.Grid,{gutter:"sm",children:[i.jsx(u.Grid.Col,{span:a.labelCol}),i.jsx(u.Grid.Col,{span:a.itemCol,children:i.jsx(u.Input.Error,{children:l})})]})]});let f=i.jsx(O,{value:t.label});return!a.helpAlwaysVisible&&t.description!==void 0&&(f=i.jsxs(u.Group,{gap:4,style:{display:"inline-flex"},children:[f,i.jsx(u.Tooltip,{label:i.jsx(O,{value:t.description}),withArrow:!0,children:i.jsx(M.IconHelpOctagonFilled,{size:16,stroke:1.5,style:{color:"var(--mantine-color-dimmed)"}})})]})),i.jsx(u.Input.Wrapper,{label:f,description:a.helpAlwaysVisible&&t.description!==void 0?i.jsx(O,{value:t.description}):void 0,required:t.isRequired,children:i.jsx(r,{db:e.db,property:t,value:d,error:l,onChange:c})})});function Ur(e){return e.type==="horizontal"}const Nt=12,Gr=e=>{const n=e.schema,t=w.useMemo(()=>{const a=Math.max(...e.fieldGroups.map(r=>Math.max(...r.fields.map(o=>o.length))));return e.fieldGroups.map((r,o)=>Wr(n,e.store,e.record,o,r,a,e.layout))},[n,e.store,e.record,e.fieldGroups,e.layout]);return i.jsx("form",{onSubmit:e.onSubmit===void 0?void 0:a=>{a.preventDefault(),e.onSubmit!==void 0&&G.isDraftRecord(e.record)&&e.onSubmit(e.record)},children:i.jsxs(u.Stack,{gap:"sm",className:e.className,style:e.styles,children:[t,i.jsx(u.Group,{gap:"sm",children:e.actions.map((a,r)=>i.jsx(u.Button,{variant:a.variant,onClick:()=>{a.onClick!==void 0&&a.onClick()},disabled:a.disabled,children:a.label},r))})]})})};function Wr(e,n,t,a,r,o,l){const s=r.fields,d=[];for(let f=0;f<s.length;f++){const p=Nt/s[f].length;if(!Number.isInteger(p))throw new Error(`Span must be an integer, but got ${p} for row ${f}`);let x;l!==void 0&&typeof l=="object"&&l.type==="horizontal"?x={...l,labelCol:Math.floor(l.labelCol*s[f].length/o),itemCol:Nt-Math.floor(l.labelCol*s[f].length/o)}:x=l;for(let h=0;h<s[f].length;h++){const v=s[f][h],S=e.allProperties[v];let E;if(G.isObjectProperty(S))E=S.cardinality==="N:N"||S.cardinality==="1:N"?$r:_r;else{if($e[S.datatype]===void 0)throw new Error(`No input component found for datatype ${S.datatype}`);E=$e[S.datatype]}d.push(i.jsx(u.Grid.Col,{span:p,children:i.jsx(Tt,{store:n,record:t,property:S,layout:x,InputComponent:E,validator:e.validators[v]})},`${f}-${h}`))}}const c=i.jsx(u.Grid,{gutter:"sm",children:d},a);return r.name!==void 0?i.jsx(u.Fieldset,{legend:r.name,children:c},a):c}const Rt=({actions:e,reloadData:n,selectedRowKeys:t,size:a="xs"})=>i.jsxs(u.Group,{gap:a,children:[(e==null?void 0:e.add)&&i.jsx(u.Button,{variant:"light",leftSection:i.jsx(M.IconPlus,{size:16,stroke:1.5}),size:a,onClick:e.add,children:"Add"}),(e==null?void 0:e.edit)&&i.jsx(u.Button,{leftSection:i.jsx(M.IconPencil,{size:16,stroke:1.5}),size:a,variant:"light",onClick:()=>e.edit!==void 0&&e.edit(t[0]),disabled:t.length!==1,children:"Edit"}),(e==null?void 0:e.reload)&&i.jsx(u.Button,{leftSection:i.jsx(M.IconReload,{size:16,stroke:1.5}),size:a,onClick:n,variant:"light",children:"Reload"}),(e==null?void 0:e.import)&&i.jsx(u.Button,{leftSection:i.jsx(M.IconDatabaseImport,{size:16,stroke:1.5}),size:a,variant:"light",onClick:e.import,children:"Import"}),(e==null?void 0:e.export)&&i.jsx(u.Button,{leftSection:i.jsx(M.IconDownload,{size:16,stroke:1.5}),size:a,variant:"light",onClick:e.export,children:"Export"})]}),Pt=e=>e!==void 0&&(e.add!==void 0||e.edit!==void 0||e.delete!==void 0||e.export!==void 0||e.reload===!0||e.import!==void 0),Kr="__selectcol__",{Thead:Vr,Tr:It,Th:Hr,Tbody:Yr,Td:Jr}=u.Table,Ft=e=>{const n=i.jsxs(u.Table,{striped:!0,highlightOnHover:!0,verticalSpacing:"xs",tabularNums:!0,children:[i.jsx(Vr,{children:e.table.getHeaderGroups().map(a=>i.jsx(It,{children:a.headers.map(r=>i.jsx(Hr,{w:r.id===Kr?"1%":void 0,children:r.isPlaceholder?null:Y.flexRender(r.column.columnDef.header,r.getContext())},r.id))},a.id))}),i.jsx(Yr,{pos:"relative",children:e.table.getRowModel().rows.map(a=>i.jsx(It,{bg:e.selectedRowKeys[a.id]?"var(--mantine-color-blue-light)":void 0,children:a.getVisibleCells().map(r=>i.jsx(Jr,{children:Y.flexRender(r.column.columnDef.cell,r.getContext())},r.id))},a.id))})]});if(!e.bordered)return n;const t={};return e.hasTopSection&&(t.borderTopLeftRadius=0,t.borderTopRightRadius=0),e.hasBottomSection&&(t.borderBottomLeftRadius=0,t.borderBottomRightRadius=0),i.jsx(u.Paper,{withBorder:!0,p:0,style:t,children:n})},Xr={pageSizeSelectorActive:"_pageSizeSelectorActive_1wv6j_1"},Lt=({total:e,pageIndex:n,pageSize:t,allowPageSizeChange:a=!0,onUpdatePagination:r})=>{const o=i.jsx(u.Pagination,{size:"sm",total:e,value:n+1,onChange:l=>r(l-1,t)});return a?i.jsxs(u.Group,{gap:"sm",children:[i.jsxs("div",{children:[i.jsx(u.Text,{size:"sm",component:"span",pr:"xs",c:"dimmed",children:"Records per page"}),i.jsx(Zr,{size:"sm",values:["10","20","50","100"],value:t.toString(),onChange:l=>{r(0,parseInt(l,10))}})]}),o]}):o},Mt={xs:u.rem(22),sm:u.rem(26),md:u.rem(32),lg:u.rem(38),xl:u.rem(44)};function Zr({size:e,values:n,value:t,onChange:a}){return i.jsxs(u.Menu,{withinPortal:!0,withArrow:!0,offset:2,children:[i.jsx(u.MenuTarget,{children:i.jsx(u.Button,{size:e,variant:"default",rightSection:i.jsx(M.IconSelector,{size:16,stroke:1.5}),style:[{fontWeight:"normal"},r=>({height:Mt[e],paddingLeft:r.spacing[e],paddingRight:r.spacing[e]})],styles:{section:{marginInlineStart:2}},children:t})}),i.jsx(u.MenuDropdown,{children:n.map(r=>{const o=r===t;return i.jsx(u.MenuItem,{className:o?Xr.pageSizeSelectorActive:void 0,style:[{height:Mt[e]}],disabled:o,onClick:()=>a(r),children:i.jsx(u.Text,{component:"div",size:e,children:r})},r)})})]})}const Ot=new Set(["topRight","bottomRight"]),Qr=e=>{var C,j;const[n,t]=w.useState({records:[],total:0}),[a,r]=w.useState(!1),[o,l]=w.useState({}),s=b=>{r(!0),e.getData(b).then(T=>{t(T),r(!1)})},d=(b,T)=>{const P={...e.query.query,limit:T,offset:b*T};e.query.update(P)},[c,f,p]=w.useMemo(()=>{const b=e.query.query.limit,T=Math.floor((e.query.query.offset||0)/e.query.query.limit),P=Math.ceil(n.total/e.query.query.limit);return[b,T,P]},[e.query.query.limit,e.query.query.offset,n.total]);w.useEffect(()=>(n.total==0&&s(e.query.query),e.query.subscribe(s)),[e.query]);const x=w.useMemo(()=>Object.keys(o).filter(b=>o[b]).map(b=>e.normalizeRowId(b)),[o]);let h,v;Pt(e.actions)&&(h=i.jsx(Rt,{actions:e.actions,reloadData:()=>s(e.query.query),selectedRowKeys:x}));const S=((C=e.pagination)==null?void 0:C.positions)||Ot;if(S.size>0){const b=i.jsx(Lt,{total:p,pageIndex:f,pageSize:c,onUpdatePagination:d,allowPageSizeChange:(j=e.pagination)==null?void 0:j.showSizeChanger});S.has("topRight")&&(h!==void 0?h=i.jsxs(u.Group,{justify:"space-between",gap:"sm",children:[h,b]}):h=i.jsx(u.Flex,{justify:"flex-end",children:b})),(S.has("bottomRight")||S.has("bottomLeft")||S.has("bottomCenter"))&&(S.has("bottomLeft")?v=i.jsxs(u.Flex,{justify:"space-between",align:"center",children:[b,i.jsxs(u.Text,{size:"sm",c:"dimmed",children:["Showing ",f*c+1," to"," ",Math.min((f+1)*c,n.total)," of ",n.total," ","records"]})]}):v=i.jsxs(u.Flex,{justify:"space-between",align:"center",children:[i.jsxs(u.Text,{size:"sm",c:"dimmed",children:["Showing ",f*c+1," to"," ",Math.min((f+1)*c,n.total)," of ",n.total," ","records"]}),b]}))}const E=w.useMemo(()=>i.jsx(ea,{data:n,loading:a,columns:e.columns,getRowId:e.getRowId,selectedRowKeys:o,setSelectedRowKeys:l,hasTopSection:h!==void 0,hasBottomSection:v!==void 0}),[n,a,e.columns,e.getRowId,o,l,h!==void 0,v!==void 0]);return h===void 0||v===void 0?E:i.jsxs("div",{children:[h!==void 0&&i.jsx(u.Paper,{withBorder:!0,p:"xs",style:{borderBottomLeftRadius:0,borderBottomRightRadius:0,borderBottom:"none"},children:h}),E,v!==void 0&&i.jsx(u.Paper,{withBorder:!0,p:"xs",style:{borderTopLeftRadius:0,borderTopRightRadius:0,borderTop:"none"},children:v})]})},ea=e=>{const n=w.useMemo(()=>{const a=[{id:"selection",header:({table:r})=>i.jsx(u.Checkbox,{checked:r.getIsAllRowsSelected(),indeterminate:r.getIsSomeRowsSelected(),onChange:r.getToggleAllRowsSelectedHandler()}),cell:({row:r})=>i.jsx(u.Checkbox,{checked:r.getIsSelected(),disabled:!r.getCanSelect(),onChange:r.getToggleSelectedHandler()})}];return e.columns.forEach(r=>{a.push({id:r.key,header:r.title,accessorFn:r.render,cell:({row:o})=>r.render(o.original)})}),a},[e.columns]),t=Y.useReactTable({data:e.data.records,columns:n,getCoreRowModel:Y.getCoreRowModel(),getRowId:a=>e.getRowId(a).toString(),state:{rowSelection:e.selectedRowKeys},onRowSelectionChange:e.setSelectedRowKeys,manualPagination:!0});return i.jsx(Ft,{table:t,selectedRowKeys:e.selectedRowKeys,bordered:!0,hasTopSection:e.hasTopSection,hasBottomSection:e.hasBottomSection})};function ze(e,n,t,{title:a,nestedKey:r,component:o}={}){let l;if(o!==void 0)l=o;else if(G.isObjectProperty(t))t.cardinality==="1:N"||t.cardinality==="N:N"?l=de:l=ue;else{if(q[t.datatype]===void 0)throw new Error(`No display component found for datatype ${t.datatype}`);l=q[t.datatype]}const s={key:t.name,title:a||i.jsx(O,{value:t.label}),accessorFn:d=>d[t.tsName],render:d=>{const c=d[t.tsName];return i.jsx(l,{db:e,property:t,value:c,entityRoutes:n})}};return r!==void 0&&(s.accessorFn=d=>d[r][t.tsName],s.render=d=>{const c=d[r][t.tsName];return i.jsx(l,{db:e,property:t,value:c,entityRoutes:n})}),s}function ta(e,n,t,a,{title:r,nestedKey:o,component:l}={}){let s;if(l!==void 0)s=l;else if(G.isObjectProperty(a))a.cardinality==="1:N"||a.cardinality==="N:N"?s=de:s=ue;else{if(q[a.datatype]===void 0)throw new Error(`No display component found for datatype ${a.datatype}`);s=q[a.datatype]}const d={key:t+"."+a.name,title:r||i.jsx(O,{value:a.label}),accessorFn:c=>c[t.tsName][a.tsName],render:c=>{const f=c[t.tsName][a.tsName];return i.jsx(s,{db:e,property:a,value:f,entityRoutes:n})}};return o!==void 0&&(d.accessorFn=c=>c[o][t.tsName][a.tsName],d.render=c=>{const f=c[o][t.tsName][a.tsName];return i.jsx(s,{db:e,property:a,value:f,entityRoutes:n})}),d}function na(e,n,t,a,r={}){return a.map(o=>Be(o)?o:ze(e,t,n.publicProperties[o],r))}function ra(e,n,t,a=[],r={}){return a.map(o=>Be(o)?o:ze(e,t,n.publicProperties[o],r))}function Be(e){return typeof e=="object"&&"key"in e&&"title"in e}const aa=new Set(["topRight","bottomRight"]),oa=e=>{var f,p;const[n,t]=w.useState({}),a=w.useMemo(()=>{const x=[{id:"selection",header:({table:h})=>i.jsx(u.Checkbox,{checked:h.getIsAllRowsSelected(),indeterminate:h.getIsSomeRowsSelected(),onChange:h.getToggleAllRowsSelectedHandler()}),cell:({row:h})=>i.jsx(u.Checkbox,{checked:h.getIsSelected(),disabled:!h.getCanSelect(),onChange:h.getToggleSelectedHandler()})}];return e.columns.forEach(h=>{x.push({id:h.key,header:h.title,accessorFn:h.render,cell:({row:v})=>h.render(v.original)})}),x},[e.columns]),r=Y.useReactTable({data:e.data,columns:a,getCoreRowModel:Y.getCoreRowModel(),getPaginationRowModel:Y.getPaginationRowModel(),state:{rowSelection:n},onRowSelectionChange:t}),o=w.useMemo(()=>Object.keys(n).filter(x=>n[x]).map(Number),[n]);let l,s;Pt(e.actions)&&(l=i.jsx(Rt,{actions:e.actions,selectedRowKeys:o}));const d=((f=e.pagination)==null?void 0:f.positions)||aa;if(d.size>0){const x=r.getState().pagination,h=i.jsx(Lt,{total:r.getPageCount(),pageIndex:x.pageIndex,pageSize:x.pageSize,onUpdatePagination:(v,S)=>r.setPagination({pageIndex:v,pageSize:S}),allowPageSizeChange:(p=e.pagination)==null?void 0:p.showSizeChanger});d.has("topRight")&&(l!==void 0?l=i.jsxs(u.Group,{justify:"space-between",gap:"sm",children:[l,h]}):l=i.jsx(u.Flex,{justify:"flex-end",children:h})),(d.has("bottomRight")||d.has("bottomLeft")||d.has("bottomCenter"))&&(d.has("bottomLeft")?s=i.jsxs(u.Flex,{justify:"space-between",align:"center",children:[h,i.jsxs(u.Text,{size:"sm",c:"dimmed",children:["Showing ",x.pageIndex*x.pageSize+1," to"," ",Math.min((x.pageIndex+1)*x.pageSize,e.data.length)," ","of ",e.data.length," records"]})]}):s=i.jsxs(u.Flex,{justify:"space-between",align:"center",children:[i.jsxs(u.Text,{size:"sm",c:"dimmed",children:["Showing ",x.pageIndex*x.pageSize+1," to"," ",Math.min((x.pageIndex+1)*x.pageSize,e.data.length)," ","of ",e.data.length," records"]}),h]}))}const c=i.jsx(Ft,{selectedRowKeys:n,table:r,bordered:!0,hasTopSection:l!==void 0,hasBottomSection:s!==void 0});return l===void 0&&s===void 0?c:i.jsxs("div",{children:[l!==void 0&&i.jsx(u.Paper,{withBorder:!0,p:"xs",style:{borderBottomLeftRadius:0,borderBottomRightRadius:0,borderBottom:"none"},children:l}),c,s!==void 0&&i.jsx(u.Paper,{withBorder:!0,p:"xs",style:{borderTopLeftRadius:0,borderTopRightRadius:0,borderTop:"none"},children:s})]})},At=U.observer(({store:e,record:n,property:t,DisplayComponent:a,entityRoutes:r})=>{const o=n[t.tsName];return i.jsxs("div",{children:[i.jsx(u.Text,{size:"sm",fw:550,children:i.jsx(O,{value:t.label})}),i.jsx(a,{db:e.db,entityRoutes:r,property:t,value:o})]})}),ia=U.observer(({store:e,record:n,properties:t,DisplayComponent:a,entityRoutes:r})=>{const o=t[t.length-1],l=t.reduce((s,d)=>{if(s!=null)return s[d.tsName]},n);return i.jsxs("div",{children:[i.jsx(u.Text,{size:"sm",fw:550,children:i.jsx(O,{value:o.label})}),l!==void 0&&i.jsx(a,{db:e.db,property:o,value:l,entityRoutes:r})]})}),la=12,Dt=e=>{const n=e.schema,t=w.useMemo(()=>e.fieldGroups.map((a,r)=>sa(n,e.store,e.record,r,a,e.entityRoutes)),[n,e.store,e.record,e.fieldGroups]);return i.jsx(u.Stack,{gap:"sm",className:e.className,style:e.styles,children:t})};function sa(e,n,t,a,r,o){const l=r.fields,s=[];for(let d=0;d<l.length;d++){const c=la/l[d].length;if(!Number.isInteger(c))throw new Error(`Span must be an integer, but got ${c} for row ${d}`);for(let f=0;f<l[d].length;f++){const p=l[d][f];let x;if(typeof p=="function")x=p(n,t);else if(typeof p=="object"&&"prop"in p){const h=e.allProperties[p.prop],v=p.display;x=i.jsx(At,{store:n,record:t,property:h,DisplayComponent:v,entityRoutes:o})}else{const h=e.allProperties[p];let v;if(G.isObjectProperty(h))v=h.cardinality==="N:N"||h.cardinality==="1:N"?de:ue;else{if(q[h.datatype]===void 0)throw new Error(`No display component found for datatype ${h.datatype}`);v=q[h.datatype]}x=i.jsx(At,{store:n,record:t,property:h,DisplayComponent:v,entityRoutes:o})}s.push(i.jsx(u.Grid.Col,{span:c,children:x},`${d}-${f}`))}}return i.jsx(u.Grid,{gutter:"sm",children:s},a)}function ua(e,n,t){const a=e[e.length-1];let r;if(t!==void 0)r=t;else if(G.isObjectProperty(a))r=a.cardinality==="N:N"||a.cardinality==="1:N"?de:ue;else{if(q[a.datatype]===void 0)throw new Error(`No display component found for datatype ${a.datatype}`);r=q[a.datatype]}return(o,l)=>i.jsx(ia,{store:o,record:l,properties:e,DisplayComponent:r,entityRoutes:n})}const da=e=>i.jsxs(u.Tabs,{defaultValue:e.fieldTabs[0].tabName,children:[i.jsx(u.Tabs.List,{children:e.fieldTabs.map((n,t)=>i.jsx(u.Tabs.Tab,{value:n.tabName,children:n.tabName},t))}),e.fieldTabs.map((n,t)=>i.jsx(u.Tabs.Panel,{value:n.tabName,pt:"sm",children:i.jsx(Dt,{schema:e.schema,store:e.store,record:e.record,fieldGroups:n.fieldGroups,styles:e.tabStyles,className:e.tabClassName,entityRoutes:e.entityRoutes})},t))]});y.CountryFlagComponent=fe,y.DEFAULT_PAGINATION_POSITIONS=Ot,y.DataType2Component=$e,y.DataType2DisplayComponent=q,y.DateDisplay=wt,y.DateTimeDisplay=bt,y.DateTimeHideTimeDisplay=kr,y.EmojiCountryFlag=Je,y.ExternalComponentContext=je,y.ExternalComponentProvider=Er,y.FormItem=Tt,y.FormItemLabel=kt,y.LanguageSelector=Xt,y.Loading=pr,y.LoadingInline=xr,y.LocaleContext=Q,y.LocaleProvider=Yt,y.MenuTrie=yt,y.MultiForeignKeyDisplay=de,y.MultiLingualString=O,y.NotAuthorized=vr,y.NotFound=mr,y.NotFoundInline=Me,y.NotFoundSubPage=gr,y.OrderedUniqueList=jr,y.Permission=we,y.SVGCountryFlag=Ye,y.SeraEmbeddedTable=oa,y.SeraForm=Gr,y.SeraTable=Qr,y.SeraVerticalMenu=Cr,y.SeraView=Dt,y.SeraViewTab=da,y.SingleForeignKeyDisplay=ue,y.Trie=Ae,y.TrieNode=Oe,y.buildMenuItemIndex=xt,y.countryFlags=R,y.filterAllowedItems=vt,y.groupBy=yr,y.groupByAsList=br,y.isSeraColumn=Be,y.makeEmbeddedTableColumns=ra,y.makeFieldDisplay=ua,y.makeTableColumn=ze,y.makeTableColumnFromNestedProperty=ta,y.makeTableColumns=na,y.uniqueList=wr,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|
|
33
|
+
Please change the parent <Route path="${j}"> to <Route path="${j==="/"?"*":`${j}/*`}">.`)}let v=H(),g;g=v;let y=g.pathname||"/",x=y;if(f!=="/"){let j=f.replace(/^\//,"").split("/");x="/"+y.replace(/^\//,"").split("/").slice(j.length).join("/")}let C=Xe(e,{pathname:x});return $(p||C!=null,`No routes matched location "${g.pathname}${g.search}${g.hash}" `),$(C==null||C[C.length-1].route.element!==void 0||C[C.length-1].route.Component!==void 0||C[C.length-1].route.lazy!==void 0,`Matched leaf route at location "${g.pathname}${g.search}${g.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.`),Nn(C&&C.map(j=>Object.assign({},j,{params:Object.assign({},d,j.params),pathname:z([f,o.encodeLocation?o.encodeLocation(j.pathname).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?f:z([f,o.encodeLocation?o.encodeLocation(j.pathnameBase).pathname:j.pathnameBase])})),l,t,a,r)}function En(){let e=Mn(),n=vn(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),t=e instanceof Error?e.stack:null,a="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:a},o={padding:"2px 4px",backgroundColor:a},l=null;return console.error("Error handled by React Router default ErrorBoundary:",e),l=h.createElement(h.Fragment,null,h.createElement("p",null,"💿 Hey developer 👋"),h.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",h.createElement("code",{style:o},"ErrorBoundary")," or"," ",h.createElement("code",{style:o},"errorElement")," prop on your route.")),h.createElement(h.Fragment,null,h.createElement("h2",null,"Unexpected Application Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},n),t?h.createElement("pre",{style:r},t):null,l)}var kn=h.createElement(En,null),Tn=class extends h.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,n){return n.location!==e.location||n.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:n.error,location:n.location,revalidation:e.revalidation||n.revalidation}}componentDidCatch(e,n){this.props.unstable_onError?this.props.unstable_onError(e,n):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?h.createElement(q.Provider,{value:this.props.routeContext},h.createElement(ke.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Rn({routeContext:e,match:n,children:t}){let a=h.useContext(te);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),h.createElement(q.Provider,{value:e},t)}function Nn(e,n=[],t=null,a=null,r=null){if(e==null){if(!t)return null;if(t.errors)e=t.matches;else if(n.length===0&&!t.initialized&&t.matches.length>0)e=t.matches;else return null}let o=e,l=t==null?void 0:t.errors;if(l!=null){let c=o.findIndex(f=>f.route.id&&(l==null?void 0:l[f.route.id])!==void 0);I(c>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),o=o.slice(0,Math.min(o.length,c+1))}let s=!1,d=-1;if(t)for(let c=0;c<o.length;c++){let f=o[c];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(d=c),f.route.id){let{loaderData:p,errors:v}=t,g=f.route.loader&&!p.hasOwnProperty(f.route.id)&&(!v||v[f.route.id]===void 0);if(f.route.lazy||g){s=!0,d>=0?o=o.slice(0,d+1):o=[o[0]];break}}}return o.reduceRight((c,f,p)=>{let v,g=!1,y=null,x=null;t&&(v=l&&f.route.id?l[f.route.id]:void 0,y=f.route.errorElement||kn,s&&(d<0&&p===0?(st("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,x=null):d===p&&(g=!0,x=f.route.hydrateFallbackElement||null)));let C=n.concat(o.slice(0,p+1)),k=()=>{let j;return v?j=y:g?j=x:f.route.Component?j=h.createElement(f.route.Component,null):f.route.element?j=f.route.element:j=c,h.createElement(Rn,{match:f,routeContext:{outlet:c,matches:C,isDataRoute:t!=null},children:j})};return t&&(f.route.ErrorBoundary||f.route.errorElement||p===0)?h.createElement(Tn,{location:t.location,revalidation:t.revalidation,component:y,error:v,children:k(),routeContext:{outlet:null,matches:C,isDataRoute:!0},unstable_onError:a}):k()},null)}function Re(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Pn(e){let n=h.useContext(te);return I(n,Re(e)),n}function In(e){let n=h.useContext(ge);return I(n,Re(e)),n}function Ln(e){let n=h.useContext(q);return I(n,Re(e)),n}function Ne(e){let n=Ln(e),t=n.matches[n.matches.length-1];return I(t.route.id,`${e} can only be used on routes that contain a unique "id"`),t.route.id}function Fn(){return Ne("useRouteId")}function Mn(){var a;let e=h.useContext(ke),n=In("useRouteError"),t=Ne("useRouteError");return e!==void 0?e:(a=n.errors)==null?void 0:a[t]}function An(){let{router:e}=Pn("useNavigate"),n=Ne("useNavigate"),t=h.useRef(!1);return it(()=>{t.current=!0}),h.useCallback(async(r,o={})=>{$(t.current,ot),t.current&&(typeof r=="number"?e.navigate(r):await e.navigate(r,{fromRouteId:n,...o}))},[e,n])}var lt={};function st(e,n,t){!n&&!lt[e]&&(lt[e]=!0,$(!1,t))}h.memo(On);function On({routes:e,future:n,state:t,unstable_onError:a}){return Cn(e,void 0,t,a,n)}var xe="get",ve="application/x-www-form-urlencoded";function ye(e){return e!=null&&typeof e.tagName=="string"}function Dn(e){return ye(e)&&e.tagName.toLowerCase()==="button"}function _n(e){return ye(e)&&e.tagName.toLowerCase()==="form"}function $n(e){return ye(e)&&e.tagName.toLowerCase()==="input"}function zn(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Bn(e,n){return e.button===0&&(!n||n==="_self")&&!zn(e)}var be=null;function qn(){if(be===null)try{new FormData(document.createElement("form"),0),be=!1}catch{be=!0}return be}var Un=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Pe(e){return e!=null&&!Un.has(e)?($(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ve}"`),null):e}function Gn(e,n){let t,a,r,o,l;if(_n(e)){let s=e.getAttribute("action");a=s?V(s,n):null,t=e.getAttribute("method")||xe,r=Pe(e.getAttribute("enctype"))||ve,o=new FormData(e)}else if(Dn(e)||$n(e)&&(e.type==="submit"||e.type==="image")){let s=e.form;if(s==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let d=e.getAttribute("formaction")||s.getAttribute("action");if(a=d?V(d,n):null,t=e.getAttribute("formmethod")||s.getAttribute("method")||xe,r=Pe(e.getAttribute("formenctype"))||Pe(s.getAttribute("enctype"))||ve,o=new FormData(s,e),!qn()){let{name:c,type:f,value:p}=e;if(f==="image"){let v=c?`${c}.`:"";o.append(`${v}x`,"0"),o.append(`${v}y`,"0")}else c&&o.append(c,p)}}else{if(ye(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');t=xe,a=null,r=ve,l=e}return o&&r==="text/plain"&&(l=o,o=void 0),{action:a,method:t.toLowerCase(),encType:r,formData:o,body:l}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Ie(e,n){if(e===!1||e===null||typeof e>"u")throw new Error(n)}function Wn(e,n,t){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return a.pathname==="/"?a.pathname=`_root.${t}`:n&&V(a.pathname,n)==="/"?a.pathname=`${n.replace(/\/$/,"")}/_root.${t}`:a.pathname=`${a.pathname.replace(/\/$/,"")}.${t}`,a}async function Kn(e,n){if(e.id in n)return n[e.id];try{let t=await import(e.module);return n[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 Vn(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 Hn(e,n,t){let a=await Promise.all(e.map(async r=>{let o=n.routes[r.route.id];if(o){let l=await Kn(o,t);return l.links?l.links():[]}return[]}));return Zn(a.flat(1).filter(Vn).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function ut(e,n,t,a,r,o){let l=(d,c)=>t[c]?d.route.id!==t[c].route.id:!0,s=(d,c)=>{var f;return t[c].pathname!==d.pathname||((f=t[c].route.path)==null?void 0:f.endsWith("*"))&&t[c].params["*"]!==d.params["*"]};return o==="assets"?n.filter((d,c)=>l(d,c)||s(d,c)):o==="data"?n.filter((d,c)=>{var p;let f=a.routes[d.route.id];if(!f||!f.hasLoader)return!1;if(l(d,c)||s(d,c))return!0;if(d.route.shouldRevalidate){let v=d.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:((p=t[0])==null?void 0:p.params)||{},nextUrl:new URL(e,window.origin),nextParams:d.params,defaultShouldRevalidate:!0});if(typeof v=="boolean")return v}return!0}):[]}function Yn(e,n,{includeHydrateFallback:t}={}){return Jn(e.map(a=>{let r=n.routes[a.route.id];if(!r)return[];let o=[r.module];return r.clientActionModule&&(o=o.concat(r.clientActionModule)),r.clientLoaderModule&&(o=o.concat(r.clientLoaderModule)),t&&r.hydrateFallbackModule&&(o=o.concat(r.hydrateFallbackModule)),r.imports&&(o=o.concat(r.imports)),o}).flat(1))}function Jn(e){return[...new Set(e)]}function Xn(e){let n={},t=Object.keys(e).sort();for(let a of t)n[a]=e[a];return n}function Zn(e,n){let t=new Set;return new Set(n),e.reduce((a,r)=>{let o=JSON.stringify(Xn(r));return t.has(o)||(t.add(o),a.push({key:o,link:r})),a},[])}function dt(){let e=h.useContext(te);return Ie(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Qn(){let e=h.useContext(ge);return Ie(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Le=h.createContext(void 0);Le.displayName="FrameworkContext";function ct(){let e=h.useContext(Le);return Ie(e,"You must render this element inside a <HydratedRouter> element"),e}function er(e,n){let t=h.useContext(Le),[a,r]=h.useState(!1),[o,l]=h.useState(!1),{onFocus:s,onBlur:d,onMouseEnter:c,onMouseLeave:f,onTouchStart:p}=n,v=h.useRef(null);h.useEffect(()=>{if(e==="render"&&l(!0),e==="viewport"){let x=k=>{k.forEach(j=>{l(j.isIntersecting)})},C=new IntersectionObserver(x,{threshold:.5});return v.current&&C.observe(v.current),()=>{C.disconnect()}}},[e]),h.useEffect(()=>{if(a){let x=setTimeout(()=>{l(!0)},100);return()=>{clearTimeout(x)}}},[a]);let g=()=>{r(!0)},y=()=>{r(!1),l(!1)};return t?e!=="intent"?[o,v,{}]:[o,v,{onFocus:se(s,g),onBlur:se(d,y),onMouseEnter:se(c,g),onMouseLeave:se(f,y),onTouchStart:se(p,g)}]:[!1,v,{}]}function se(e,n){return t=>{e&&e(t),t.defaultPrevented||n(t)}}function tr({page:e,...n}){let{router:t}=dt(),a=h.useMemo(()=>Xe(t.routes,e,t.basename),[t.routes,e,t.basename]);return a?h.createElement(rr,{page:e,matches:a,...n}):null}function nr(e){let{manifest:n,routeModules:t}=ct(),[a,r]=h.useState([]);return h.useEffect(()=>{let o=!1;return Hn(e,n,t).then(l=>{o||r(l)}),()=>{o=!0}},[e,n,t]),a}function rr({page:e,matches:n,...t}){let a=H(),{manifest:r,routeModules:o}=ct(),{basename:l}=dt(),{loaderData:s,matches:d}=Qn(),c=h.useMemo(()=>ut(e,n,d,r,a,"data"),[e,n,d,r,a]),f=h.useMemo(()=>ut(e,n,d,r,a,"assets"),[e,n,d,r,a]),p=h.useMemo(()=>{if(e===a.pathname+a.search+a.hash)return[];let y=new Set,x=!1;if(n.forEach(k=>{var w;let j=r.routes[k.route.id];!j||!j.hasLoader||(!c.some(E=>E.route.id===k.route.id)&&k.route.id in s&&((w=o[k.route.id])!=null&&w.shouldRevalidate)||j.hasClientLoader?x=!0:y.add(k.route.id))}),y.size===0)return[];let C=Wn(e,l,"data");return x&&y.size>0&&C.searchParams.set("_routes",n.filter(k=>y.has(k.route.id)).map(k=>k.route.id).join(",")),[C.pathname+C.search]},[l,s,a,r,c,n,e,o]),v=h.useMemo(()=>Yn(f,r),[f,r]),g=nr(f);return h.createElement(h.Fragment,null,p.map(y=>h.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...t})),v.map(y=>h.createElement("link",{key:y,rel:"modulepreload",href:y,...t})),g.map(({key:y,link:x})=>h.createElement("link",{key:y,nonce:t.nonce,...x})))}function ar(...e){return n=>{e.forEach(t=>{typeof t=="function"?t(n):t!=null&&(t.current=n)})}}var ft=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{ft&&(window.__reactRouterVersion="7.8.2")}catch{}var ht=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,mt=h.forwardRef(function({onClick:n,discover:t="render",prefetch:a="none",relative:r,reloadDocument:o,replace:l,state:s,target:d,to:c,preventScrollReset:f,viewTransition:p,...v},g){let{basename:y}=h.useContext(B),x=typeof c=="string"&&ht.test(c),C,k=!1;if(typeof c=="string"&&x&&(C=c,ft))try{let O=new URL(window.location.href),Y=c.startsWith("//")?new URL(O.protocol+c):new URL(c),re=V(Y.pathname,y);Y.origin===O.origin&&re!=null?c=re+Y.search+Y.hash:k=!0}catch{$(!1,`<Link to="${c}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let j=Sn(c,{relative:r}),[w,E,R]=er(a,v),G=sr(c,{replace:l,state:s,target:d,preventScrollReset:f,relative:r,viewTransition:p});function D(O){n&&n(O),O.defaultPrevented||G(O)}let Q=h.createElement("a",{...v,...R,href:C||j,onClick:k||o?n:D,ref:ar(g,E),target:d,"data-discover":!x&&t==="render"?"true":void 0});return w&&!x?h.createElement(h.Fragment,null,Q,h.createElement(tr,{page:j})):Q});mt.displayName="Link";var or=h.forwardRef(function({"aria-current":n="page",caseSensitive:t=!1,className:a="",end:r=!1,style:o,to:l,viewTransition:s,children:d,...c},f){let p=le(l,{relative:c.relative}),v=H(),g=h.useContext(ge),{navigator:y,basename:x}=h.useContext(B),C=g!=null&&hr(p)&&s===!0,k=y.encodeLocation?y.encodeLocation(p).pathname:p.pathname,j=v.pathname,w=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;t||(j=j.toLowerCase(),w=w?w.toLowerCase():null,k=k.toLowerCase()),w&&x&&(w=V(w,x)||w);const E=k!=="/"&&k.endsWith("/")?k.length-1:k.length;let R=j===k||!r&&j.startsWith(k)&&j.charAt(E)==="/",G=w!=null&&(w===k||!r&&w.startsWith(k)&&w.charAt(k.length)==="/"),D={isActive:R,isPending:G,isTransitioning:C},Q=R?n:void 0,O;typeof a=="function"?O=a(D):O=[a,R?"active":null,G?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let Y=typeof o=="function"?o(D):o;return h.createElement(mt,{...c,"aria-current":Q,className:O,ref:f,style:Y,to:l,viewTransition:s},typeof d=="function"?d(D):d)});or.displayName="NavLink";var ir=h.forwardRef(({discover:e="render",fetcherKey:n,navigate:t,reloadDocument:a,replace:r,state:o,method:l=xe,action:s,onSubmit:d,relative:c,preventScrollReset:f,viewTransition:p,...v},g)=>{let y=cr(),x=fr(s,{relative:c}),C=l.toLowerCase()==="get"?"get":"post",k=typeof s=="string"&&ht.test(s),j=w=>{if(d&&d(w),w.defaultPrevented)return;w.preventDefault();let E=w.nativeEvent.submitter,R=(E==null?void 0:E.getAttribute("formmethod"))||l;y(E||w.currentTarget,{fetcherKey:n,method:R,navigate:t,replace:r,state:o,relative:c,preventScrollReset:f,viewTransition:p})};return h.createElement("form",{ref:g,method:C,action:x,onSubmit:a?d:j,...v,"data-discover":!k&&e==="render"?"true":void 0})});ir.displayName="Form";function lr(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function gt(e){let n=h.useContext(te);return I(n,lr(e)),n}function sr(e,{target:n,replace:t,state:a,preventScrollReset:r,relative:o,viewTransition:l}={}){let s=Te(),d=H(),c=le(e,{relative:o});return h.useCallback(f=>{if(Bn(f,n)){f.preventDefault();let p=t!==void 0?t:Se(d)===Se(c);s(e,{replace:p,state:a,preventScrollReset:r,relative:o,viewTransition:l})}},[d,s,c,t,a,n,e,r,o,l])}var ur=0,dr=()=>`__${String(++ur)}__`;function cr(){let{router:e}=gt("useSubmit"),{basename:n}=h.useContext(B),t=Fn();return h.useCallback(async(a,r={})=>{let{action:o,method:l,encType:s,formData:d,body:c}=Gn(a,n);if(r.navigate===!1){let f=r.fetcherKey||dr();await e.fetch(f,t,r.action||o,{preventScrollReset:r.preventScrollReset,formData:d,body:c,formMethod:r.method||l,formEncType:r.encType||s,flushSync:r.flushSync})}else await e.navigate(r.action||o,{preventScrollReset:r.preventScrollReset,formData:d,body:c,formMethod:r.method||l,formEncType:r.encType||s,replace:r.replace,state:r.state,fromRouteId:t,flushSync:r.flushSync,viewTransition:r.viewTransition})},[e,n,t])}function fr(e,{relative:n}={}){let{basename:t}=h.useContext(B),a=h.useContext(q);I(a,"useFormAction must be used inside a RouteContext");let[r]=a.matches.slice(-1),o={...le(e||".",{relative:n})},l=H();if(e==null){o.search=l.search;let s=new URLSearchParams(o.search),d=s.getAll("index");if(d.some(f=>f==="")){s.delete("index"),d.filter(p=>p).forEach(p=>s.append("index",p));let f=s.toString();o.search=f?`?${f}`:""}}return(!e||e===".")&&r.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),t!=="/"&&(o.pathname=o.pathname==="/"?t:z([t,o.pathname])),Se(o)}function hr(e,{relative:n}={}){let t=h.useContext(at);I(t!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:a}=gt("useViewTransitionState"),r=le(e,{relative:n});if(!t.isTransitioning)return!1;let o=V(t.currentLocation.pathname,a)||t.currentLocation.pathname,l=V(t.nextLocation.pathname,a)||t.nextLocation.pathname;return me(r.pathname,l)!=null||me(r.pathname,o)!=null}const mr=({message:e})=>{const n=Te();return i.jsx(u.Container,{size:"xs",style:{height:"100vh",display:"flex",alignItems:"center",justifyContent:"center"},children:i.jsx(u.Alert,{color:"red",title:"Not Found",variant:"404 - Not Found",icon:i.jsx(M.IconInfoCircle,{size:12,stroke:1.5}),children:i.jsxs(u.Stack,{align:"flex-start",children:[e||"Sorry, the page you are looking for does not exist.",i.jsx(u.Button,{variant:"filled",onClick:()=>n("/"),size:"xs",children:"Back Home"})]})})})},gr=({message:e})=>i.jsx(u.Alert,{color:"red",title:"Not Found",variant:"404 - Not Found",icon:i.jsx(M.IconInfoCircle,{size:12,stroke:1.5}),children:e||"Sorry, the page you are looking for does not exist."}),Fe=({message:e})=>i.jsx(u.Text,{c:"red",size:"sm",children:e||"Not Found"}),pr=({tip:e})=>e===void 0?i.jsx(u.Flex,{justify:"center",align:"center",children:i.jsx(u.Loader,{color:"blue",size:"md"})}):i.jsxs(u.Flex,{gap:"md",direction:"column",justify:"center",align:"center",style:{height:"100%"},children:[i.jsx(u.Loader,{color:"blue",size:"md"}),e]}),xr=({tip:e})=>e===void 0?i.jsx(u.Loader,{color:"blue",size:"xs"}):i.jsxs(u.Flex,{gap:"md",direction:"column",justify:"center",align:"center",children:[i.jsx(u.Loader,{color:"blue",size:"xs"}),e]}),vr=({message:e})=>i.jsx(u.Alert,{color:"red",title:"Not Found",variant:"403 - Not Authorized",icon:i.jsx(M.IconInfoCircle,{size:12,stroke:1.5}),children:e||"Sorry, you are not authorized to access this page."});function yr(e,n){return e.reduce((t,a)=>{const r=n(a);return t[r]||(t[r]=[]),t[r].push(a),t},{})}function br(e,n){const t=[];let a;return e.reduce((r,o)=>{const l=n(o);return l===void 0?(a===void 0&&(a=t.length,t.push([])),t[a].push(o)):(r[l]===void 0&&(r[l]=t.length,t.push([])),t[r[l]].push(o)),r},{}),t}function wr(e,n){const t=new Set;return e.filter(a=>{const r=n(a);return t.has(r)?!1:(t.add(r),!0)})}class Sr{constructor(){X(this,"items",[]);X(this,"seen",new Set)}add(n,t){const a=t(n);this.seen.has(a)||(this.items.push(n),this.seen.add(a))}toArray(){return this.items}}class Me{constructor(){X(this,"children",new Map);X(this,"isEndOfWord",!1);X(this,"value","")}}class Ae{constructor(){X(this,"root",new Me)}insert(n){let t=this.root;for(const a of n){let r=t.children.get(a);r===void 0&&(r=new Me,t.children.set(a,r)),t=r}t.isEndOfWord=!0,t.value=n}findLongestPrefix(n){let t=this.root,a={match:"",remaining:n};for(let r=0;r<n.length;r++){const o=n[r];if(!t.children.has(o))break;t=t.children.get(o),t.isEndOfWord&&(a={match:t.value,remaining:n.slice(r+1)})}return a}}var pt=(e=>(e[e.Allow=0]="Allow",e[e.Denied=1]="Denied",e[e.Pending=2]="Pending",e))(pt||{});class xt extends Ae{constructor(){super(...arguments);X(this,"pathToKey",new Map)}normalizePath(t){return t==="/"?"/":t.replace(/\/$/,"")}insertRoute(t,a){const r=this.normalizePath(t);this.insert(r),this.pathToKey.set(r,a)}findMatchingKey(t){const a=this.normalizePath(t),r=this.findLongestPrefix(a);if(r.match&&this.pathToKey.has(r.match)&&(a===r.match||r.remaining.startsWith("/")||r.remaining===""))return this.pathToKey.get(r.match)}}function vt(e){const n={},t={},a={},r=(o,l=[])=>{o.forEach(s=>{const d=[...l,s.key];n[s.key]=s,t[s.key]=d,s.route!==void 0&&(a[s.key]=s.route),s.children!==void 0&&s.children.length>0&&r(s.children,d)})};return r(e),{key2item:n,key2fullpath:t,key2route:a}}function jr(e){const n=new xt,t=a=>{a.forEach(r=>{if(r.route!==void 0){const o=r.route.path.getURL();n.insertRoute(o,r.key)}r.children!==void 0&&r.children.length>0&&t(r.children)})};return t(e),n}function yt(e,n){return e.map(t=>{if(t.route!==void 0)return n(t.route.role)===0?t:null;if(t.children!==void 0){const a=t.children.filter(r=>r.route!==void 0?n(r.route.role)===0:!0);return a.length>0?{...t,children:a}:null}return t}).filter(t=>t!==null)}const Cr=e=>{const n=Te(),t=H(),[a,r]=S.useState(new Set),[o,l]=S.useState(new Set),[s,d]=S.useState(),c=S.useMemo(()=>yt(e.items,e.checkPermission),[e.items,e.checkPermission]),f=S.useMemo(()=>jr(e.items),[e.items]),{key2fullpath:p,key2route:v}=S.useMemo(()=>vt(c),[c]);S.useEffect(()=>{const y=t.pathname,x=f.findMatchingKey(y);x!==void 0&&(l(new Set(p[x])),d(x))},[t,v]);const g=S.useMemo(()=>{function y(x,C){var j,w;const k=x.children!==void 0&&x.children.length>0;return k?i.jsxs("div",{onMouseEnter:()=>{o.has(x.key)||r(E=>{const R=new Set(E);return R.add(x.key),R})},onMouseLeave:()=>{o.has(x.key)||r(E=>{const R=new Set(E);return R.delete(x.key),R})},children:[i.jsx(u.NavLink,{active:s===x.key,href:(j=x.route)==null?void 0:j.path.getURL(),label:x.label,leftSection:x.icon,styles:{label:{fontSize:"md"},root:{borderRadius:"var(--mantine-radius-sm)"}},ml:C===0?void 0:C===1?"md":`calc(var(--mantine-spacing-md) * ${C})`,w:"unset",rightSection:k?i.jsx(M.IconChevronRight,{size:12,stroke:1.5,className:"mantine-rotate-rtl"}):void 0,opened:a.has(x.key)||o.has(x.key),onClick:E=>{E.ctrlKey||E.metaKey||(E.preventDefault(),l(G=>{const D=new Set(G);return G.has(x.key)?D.delete(x.key):D.add(x.key),D}))}},x.key),(o.has(x.key)||a.has(x.key))&&x.children.map(E=>y(E,C+1))]},`container-${x.key}`):i.jsx(u.NavLink,{active:s===x.key,href:(w=x.route)==null?void 0:w.path.getURL(),label:x.label,leftSection:x.icon,styles:{label:{fontSize:"md"},root:{borderRadius:"var(--mantine-radius-sm)"}},ml:C===0?void 0:C===1?"md":`calc(var(--mantine-spacing-md) * ${C})`,w:"unset",onClick:E=>{E.ctrlKey||E.metaKey||(E.preventDefault(),x.route!=null&&x.route.path.path().open(n))}},x.key)}return c.map(x=>y(x,0))},[c,s,o,a,n]);return i.jsx(i.Fragment,{children:g})},we=({value:e})=>i.jsx(u.Text,{size:"sm",children:e});function Oe(e,n){const t=n.getDate().toString().padStart(2,"0"),a=(n.getMonth()+1).toString().padStart(2,"0"),r=n.getFullYear();return e.baseName==="en-US"?`${a}/${t}/${r}`:e.baseName==="vi-VN"?`${t}/${a}/${r}`:`${a}/${t}/${r}`}const bt=({value:e})=>{const n=S.useContext(ee),t=S.useMemo(()=>{const a=e.getHours().toString().padStart(2,"0"),r=e.getMinutes().toString().padStart(2,"0"),o=e.getSeconds().toString().padStart(2,"0");return Oe(n,e)+`${a}:${r}:${o}`},[n,e]);return i.jsx(u.Text,{size:"sm",children:t})},wt=({value:e})=>{const n=S.useContext(ee),t=S.useMemo(()=>Oe(n,e),[n,e]);return i.jsx(u.Text,{size:"sm",children:t})},Er=({value:e})=>{const n=S.useContext(ee),[t,a]=S.useMemo(()=>{const r=Oe(n,e),o=e.getHours().toString().padStart(2,"0"),l=e.getMinutes().toString().padStart(2,"0"),s=e.getSeconds().toString().padStart(2,"0");return[r,`${o}:${l}:${s}`]},[n,e]);return i.jsx(u.Text,{size:"sm",title:a,children:t})},kr={yes:{lang2value:{en:"Yes",vi:"Có"},lang:"en"},no:{lang2value:{en:"No",vi:"Không"},lang:"en"}},Tr=({value:e})=>i.jsx(u.Checkbox,{checked:e,label:i.jsx(A,{value:kr[e?"yes":"no"]}),readOnly:!0}),Rr=({nestedProperty:e,property:n,value:t})=>{const a=e||n;if(K.isObjectProperty(a)||a.enumType===void 0)throw new Error("Invalid usage of EnumDisplay. Expect a property of type enum");return i.jsx(u.Text,{size:"sm",children:i.jsx(A,{value:a.enumType.label[t]})})};function St(e,n,t,a){const r=e.getByName(n.targetClass),o=a[n.targetClass];S.useEffect(()=>{r.fetchByIds(t)},[t]);const l={};for(const s of t)l[s]=r.get(s);return[l,o]}const ue=W.observer(({db:e,property:n,value:t,entityRoutes:a})=>{const r=S.useMemo(()=>[t],[t]),[o,l]=St(e,n,r,a),s=o[t];return s===void 0?i.jsx(u.Text,{size:"sm",children:t}):s===null?i.jsx(Fe,{}):l===void 0?i.jsx(u.Text,{size:"sm",children:s.name}):i.jsx(We.InternalLink,{path:l,openInNewPage:!1,urlArgs:{id:s.id},queryArgs:{},children:s.name})}),de=W.observer(({db:e,property:n,value:t,entityRoutes:a})=>{const[r,o]=St(e,n,t,a);return i.jsx(u.Group,{gap:"xs",children:t.map((l,s)=>{const d=r[l];return d===void 0?i.jsx(u.Text,{size:"sm",children:t},l):d===null?i.jsx(Fe,{},l):o===void 0?i.jsx(u.Text,{size:"sm",children:d.name},s):i.jsx(We.InternalLink,{path:o,openInNewPage:!1,urlArgs:{id:d.id},queryArgs:{},children:d.name},s)})})}),U={string:we,integer:we,float:we,boolean:Tr,"string[]":we,enum:Rr,datetime:bt,date:wt},Nr=({property:e,value:n,onChange:t})=>i.jsx(u.Input,{id:e.name,type:"checkbox",checked:n,onChange:a=>{const r=a.target.checked;t(r)}}),jt=({property:e,value:n,onChange:t})=>i.jsx(u.Input,{id:e.name,type:"number",value:n,onChange:a=>{const r=a.target.value;t(r===""?void 0:Number(r))}}),Pr={lang2value:{en:"The leading zero is not necessary in international phone number format. For example, if your phone number is 0123456789, you should enter it as 123-456-789.",vi:"Số 0 đầu tiên không cần thiết trong định dạng điện thoại quốc tế. Ví dụ, nếu số điện thoại của bạn là 0123456789, bạn nên nhập nó là 123-456-789."},lang:"en"},Ir={lang2value:{en:"No valid country code found.",vi:"Không tìm thấy mã quốc gia hợp lệ. "},lang:"en"},ne={84:{name:"Vietnam",flags:[P.VN]},1:{name:"US, Canada",flags:[P.US,P.CA]},61:{name:"Australia",flags:[P.AU]},81:{name:"Japan",flags:[P.JP]},44:{name:"UK",flags:[P.UK]},33:{name:"France",flags:[P.FR]},49:{name:"Germany",flags:[P.DE]},91:{name:"India",flags:[P.IN]},55:{name:"Brazil",flags:[P.BR]},34:{name:"Spain",flags:[P.ES]},39:{name:"Italy",flags:[P.IT]},64:{name:"New Zealand",flags:[P.NZ]},52:{name:"Mexico",flags:[P.MX]},86:{name:"China",flags:[P.CN]}},Lr=(e,n)=>{if(e==="")return{match:"84",remaining:""};const t=e.replace(/[^\d]/g,""),a=n.findLongestPrefix(t);if(a.match==="")throw new Error(`No valid country code found for phone number: ${e}`);return a},Ct=({value:e})=>{const n=ne[e];if(n!==void 0)return i.jsxs(u.Group,{gap:"sm",wrap:"nowrap",align:"center",children:[i.jsxs(u.Text,{size:"sm",children:["+",e]}),i.jsx(u.Group,{gap:4,wrap:"nowrap",children:n.flags.map((t,a)=>i.jsx(fe,{flag:t},a))})]})},Fr=({value:e,onChange:n,error:t,id:a})=>{const[r,o]=S.useState(""),[l,s]=S.useState(!1),[d,c]=S.useState(""),[f,p]=S.useState(!1),v=S.useMemo(()=>{const w=new Ae;return Object.keys(ne).forEach(E=>{w.insert(E)}),w},[ne]),{rawInput:g}=S.useMemo(()=>{try{const{match:w,remaining:E}=Lr(e,v);return c(w),p(!1),{rawInput:E}}catch{return p(!0),c(""),{rawInput:e}}},[e]),y=u.useCombobox({onDropdownClose:()=>{y.resetSelectedOption(),o("")},onDropdownOpen:()=>{y.updateSelectedOptionIndex("active")}}),x=S.useMemo(()=>Object.keys(ne),[ne]),C=(w,E)=>{const R=w.replace(/[^\d]/g,"");return R.length===0?`+${E}`:R.startsWith("0")?(s(!0),`+${E}${R}`):(s(!1),`+${E}${R}`)},k=S.useMemo(()=>x.filter(w=>ne[w].name.toLowerCase().includes(r.toLowerCase())||w.includes(r)),[r,x]),j=S.useMemo(()=>k.map((w,E)=>i.jsx(u.Combobox.Option,{value:w,children:i.jsx(Ct,{value:w})},E)),[k]);return i.jsxs("div",{children:[i.jsx(u.Grid,{gutter:"xs",children:i.jsx(u.Grid.Col,{children:i.jsxs(u.Group,{gap:5,children:[i.jsxs(u.Combobox,{store:y,position:"top-start",onOptionSubmit:w=>{o(""),y.closeDropdown(),n({target:{value:C(g,w)}})},children:[i.jsx(u.Combobox.Target,{children:i.jsx(u.InputBase,{component:"button",type:"button",pointer:!0,rightSection:i.jsx(u.Combobox.Chevron,{}),onClick:()=>y.toggleDropdown(),rightSectionPointerEvents:"none",w:110,children:i.jsx(Ct,{value:d})})}),i.jsxs(u.Combobox.Dropdown,{children:[i.jsx(u.Combobox.Search,{leftSection:i.jsx(M.IconSearch,{size:14,stroke:1.5}),placeholder:".....",value:r,onChange:w=>o(w.currentTarget.value)}),i.jsx(u.Combobox.Options,{children:j.length>0?j:i.jsx(u.Combobox.Empty,{children:i.jsx(u.Text,{size:"sm",children:"Nothing found"})})})]})]}),d===""?i.jsx(u.Input,{id:a,value:g,type:"phone_number",onChange:w=>{n({target:{value:w.target.value}})},error:t,flex:1}):i.jsx(u.Input,{id:a,value:g,type:"phone_number",onAccept:w=>{const E=w.replace(/[^\d]/g,"");n({target:{value:C(E,d)}})},component:Gt.IMaskInput,mask:"000-000-0000",error:t,flex:1})]})})}),(l||f||t&&typeof t=="string")&&i.jsx(u.Grid,{gutter:"xs",children:i.jsx(u.Grid.Col,{children:i.jsx(u.Input.Error,{children:l?i.jsx(A,{value:Pr}):f?i.jsx(A,{value:Ir}):t})})})]})},De=({property:e,error:n,value:t,onChange:a})=>{const[r,o]=S.useMemo(()=>e.constraints.includes("password")?["password",u.PasswordInput]:e.constraints.includes("phone_number")?["phone_number",Fr]:[e.constraints.includes("email")?"email":e.constraints.includes("url")?"url":"text",u.Input],[e.constraints]);return i.jsx(o,{id:e.name,value:t,type:r,onChange:l=>a(l.target.value),error:n})},_e={integer:jt,float:jt,string:De,boolean:Nr,"string[]":De,enum:De};function Mr(e,n){const[t,a]=S.useState(""),[r,o]=S.useState([]);return S.useEffect(()=>{e.getByName(n.targetClass).fetch({limit:100,offset:0}).then(s=>o(s.records))},[n.name]),{data:r,query:t,setQuery:s=>{a(s);const d=e.getByName(n.targetClass);o(d.filter(c=>c.name.toLowerCase().includes(s.toLowerCase())))},table:e.getByName(n.targetClass)}}const Ar=e=>e.name,Or=e=>i.jsx(u.Text,{size:"sm",children:e.name}),Dr=W.observer(e=>i.jsx("h1",{children:"SingleForeignKey"})),_r=W.observer(({db:e,property:n,value:t,onChange:a})=>{const{table:r,data:o,query:l,setQuery:s}=Mr(e,n);return i.jsxs(u.Stack,{gap:"sm",children:[i.jsx($r,{name:n.name,query:l,setQuery:s,data:o,onSelect:d=>{t.includes(d)||a([...t,d])},renderOption:Ar,isIdInteger:n.datatype==="integer"}),i.jsx(zr,{items:t.map(d=>r.get(d)),onDelete:d=>{a(t.filter(c=>c!==d.id))},render:Or})]})}),$r=({name:e,data:n,onSelect:t,renderOption:a,isIdInteger:r,query:o,setQuery:l})=>{const s=u.useCombobox({onDropdownClose:()=>s.resetSelectedOption()}),d=S.useMemo(()=>n.map(c=>i.jsx(u.Combobox.Option,{value:c.id.toString(),children:a(c)},c.id)),[n]);return i.jsxs(u.Combobox,{store:s,onOptionSubmit:c=>{t(r?parseInt(c):c),l(""),s.closeDropdown()},offset:0,shadow:"sm",children:[i.jsx(u.Combobox.Target,{children:i.jsx(u.Input,{id:e,pointer:!0,rightSection:i.jsx(M.IconSearch,{size:16,stroke:1.5}),rightSectionPointerEvents:"none",onClick:()=>s.toggleDropdown(),placeholder:"Type to search...",value:o,onChange:c=>{l(c.currentTarget.value)}})}),i.jsx(u.Combobox.Dropdown,{children:i.jsx(u.Combobox.Options,{children:d.length===0?i.jsx(u.Combobox.Empty,{children:"Nothing found"}):d})})]})},zr=({items:e,onDelete:n,render:t})=>{const a=S.useMemo(()=>{const r=[];for(let o=0;o<e.length;o++){const l=e[o];r.push(i.jsxs(u.Group,{justify:"space-between",p:"sm",children:[t(l),i.jsx(u.CloseButton,{size:"sm",onClick:()=>n(l)})]},o)),o<e.length-1&&r.push(i.jsx(u.Divider,{},`divider-${o}`))}return r},[e]);if(a.length!==0)return i.jsx(u.Paper,{bd:"1px solid #ddd",children:a})},Et={requiredLabelLeft:"_requiredLabelLeft_l5p83_1",requiredLabelRight:"_requiredLabelRight_l5p83_11"},kt=({label:e,name:n,required:t=!1,tooltip:a,style:r,align:o="left"})=>{const l=t?o==="left"?Et.requiredLabelRight:Et.requiredLabelLeft:"";return i.jsx(u.Flex,{align:"center",h:36,children:i.jsx("label",{htmlFor:n,style:r,children:i.jsxs(u.Group,{gap:4,children:[i.jsx(u.Text,{size:"sm",className:l,children:e}),a!==void 0&&i.jsx(u.Tooltip,{label:a,withArrow:!0,children:i.jsx(M.IconHelpOctagonFilled,{size:16,stroke:1.5,style:{color:"var(--mantine-color-dimmed)"}})})]})})})},Br={type:"vertical",helpAlwaysVisible:!1},Tt=W.observer(({store:e,record:n,property:t,layout:a=Br,InputComponent:r,validator:o})=>{const[l,s]=S.useState(void 0),d=n[t.tsName],c=p=>{var g;if(K.isDraftRecord(n))n[t.updateFuncName](p);else{const y=n.toDraft();y[t.updateFuncName](p),e.setDraft(y)}const v=o(p);v.isValid?s(void 0):s((g=v.errorMessage)==null?void 0:g.t({args:{name:t.label}}))};if(qr(a))return i.jsxs(u.Stack,{gap:5,children:[i.jsxs(u.Grid,{gutter:"sm",children:[i.jsx(u.Grid.Col,{span:a.labelCol,style:{display:"flex",justifyContent:a.align||"left"},children:i.jsx(kt,{label:i.jsx(A,{value:t.label}),name:t.name,required:t.isRequired,tooltip:t.description!==void 0?i.jsx(A,{value:t.description}):void 0,align:a.align})}),i.jsx(u.Grid.Col,{span:a.itemCol,children:i.jsx(r,{db:e.db,property:t,value:d,error:l!==void 0,onChange:c})})]}),l!==void 0&&i.jsxs(u.Grid,{gutter:"sm",children:[i.jsx(u.Grid.Col,{span:a.labelCol}),i.jsx(u.Grid.Col,{span:a.itemCol,children:i.jsx(u.Input.Error,{children:l})})]})]});let f=i.jsx(A,{value:t.label});return!a.helpAlwaysVisible&&t.description!==void 0&&(f=i.jsxs(u.Group,{gap:4,style:{display:"inline-flex"},children:[f,i.jsx(u.Tooltip,{label:i.jsx(A,{value:t.description}),withArrow:!0,children:i.jsx(M.IconHelpOctagonFilled,{size:16,stroke:1.5,style:{color:"var(--mantine-color-dimmed)"}})})]})),i.jsx(u.Input.Wrapper,{label:f,description:a.helpAlwaysVisible&&t.description!==void 0?i.jsx(A,{value:t.description}):void 0,required:t.isRequired,children:i.jsx(r,{db:e.db,property:t,value:d,error:l,onChange:c})})});function qr(e){return e.type==="horizontal"}const Rt=12,Ur=e=>{const n=e.schema,t=S.useMemo(()=>{const a=Math.max(...e.fieldGroups.map(r=>Math.max(...r.fields.map(o=>o.length))));return e.fieldGroups.map((r,o)=>Gr(n,e.store,e.record,o,r,a,e.layout))},[n,e.store,e.record,e.fieldGroups,e.layout]);return i.jsx("form",{onSubmit:e.onSubmit===void 0?void 0:a=>{a.preventDefault(),e.onSubmit!==void 0&&K.isDraftRecord(e.record)&&e.onSubmit(e.record)},children:i.jsxs(u.Stack,{gap:"sm",className:e.className,style:e.styles,children:[t,i.jsx(u.Group,{gap:"sm",children:e.actions.map((a,r)=>i.jsx(u.Button,{variant:a.variant,onClick:()=>{a.onClick!==void 0&&a.onClick()},disabled:a.disabled,children:a.label},r))})]})})};function Gr(e,n,t,a,r,o,l){const s=r.fields,d=[];for(let f=0;f<s.length;f++){const p=Rt/s[f].length;if(!Number.isInteger(p))throw new Error(`Span must be an integer, but got ${p} for row ${f}`);let v;l!==void 0&&typeof l=="object"&&l.type==="horizontal"?v={...l,labelCol:Math.floor(l.labelCol*s[f].length/o),itemCol:Rt-Math.floor(l.labelCol*s[f].length/o)}:v=l;for(let g=0;g<s[f].length;g++){const y=s[f][g],x=e.allProperties[y];let C;if(K.isObjectProperty(x))C=x.cardinality==="N:N"||x.cardinality==="1:N"?_r:Dr;else{if(_e[x.datatype]===void 0)throw new Error(`No input component found for datatype ${x.datatype}`);C=_e[x.datatype]}d.push(i.jsx(u.Grid.Col,{span:p,children:i.jsx(Tt,{store:n,record:t,property:x,layout:v,InputComponent:C,validator:e.validators[y]})},`${f}-${g}`))}}const c=i.jsx(u.Grid,{gutter:"sm",children:d},a);return r.name!==void 0?i.jsx(u.Fieldset,{legend:r.name,children:c},a):c}const Nt=({actions:e,reloadData:n,selectedRowKeys:t,size:a="xs"})=>i.jsxs(u.Group,{gap:a,children:[(e==null?void 0:e.add)&&i.jsx(u.Button,{variant:"light",leftSection:i.jsx(M.IconPlus,{size:16,stroke:1.5}),size:a,onClick:e.add,children:"Add"}),(e==null?void 0:e.edit)&&i.jsx(u.Button,{leftSection:i.jsx(M.IconPencil,{size:16,stroke:1.5}),size:a,variant:"light",onClick:()=>e.edit!==void 0&&e.edit(t[0]),disabled:t.length!==1,children:"Edit"}),(e==null?void 0:e.reload)&&i.jsx(u.Button,{leftSection:i.jsx(M.IconReload,{size:16,stroke:1.5}),size:a,onClick:n,variant:"light",children:"Reload"}),(e==null?void 0:e.import)&&i.jsx(u.Button,{leftSection:i.jsx(M.IconDatabaseImport,{size:16,stroke:1.5}),size:a,variant:"light",onClick:e.import,children:"Import"}),(e==null?void 0:e.export)&&i.jsx(u.Button,{leftSection:i.jsx(M.IconDownload,{size:16,stroke:1.5}),size:a,variant:"light",onClick:e.export,children:"Export"})]}),Pt=e=>e!==void 0&&(e.add!==void 0||e.edit!==void 0||e.delete!==void 0||e.export!==void 0||e.reload===!0||e.import!==void 0),Wr="__selectcol__",{Thead:Kr,Tr:It,Th:Vr,Tbody:Hr,Td:Yr}=u.Table,Lt=e=>{const n=i.jsxs(u.Table,{striped:!0,highlightOnHover:!0,verticalSpacing:"xs",tabularNums:!0,children:[i.jsx(Kr,{children:e.table.getHeaderGroups().map(a=>i.jsx(It,{children:a.headers.map(r=>i.jsx(Vr,{w:r.id===Wr?"1%":void 0,children:r.isPlaceholder?null:Z.flexRender(r.column.columnDef.header,r.getContext())},r.id))},a.id))}),i.jsx(Hr,{pos:"relative",children:e.table.getRowModel().rows.map(a=>i.jsx(It,{bg:e.selectedRowKeys[a.id]?"var(--mantine-color-blue-light)":void 0,children:a.getVisibleCells().map(r=>i.jsx(Yr,{children:Z.flexRender(r.column.columnDef.cell,r.getContext())},r.id))},a.id))})]});if(!e.bordered)return n;const t={};return e.hasTopSection&&(t.borderTopLeftRadius=0,t.borderTopRightRadius=0),e.hasBottomSection&&(t.borderBottomLeftRadius=0,t.borderBottomRightRadius=0),i.jsx(u.Paper,{withBorder:!0,p:0,style:t,children:n})},Jr={pageSizeSelectorActive:"_pageSizeSelectorActive_1wv6j_1"},Ft=({total:e,pageIndex:n,pageSize:t,allowPageSizeChange:a=!0,onUpdatePagination:r})=>{const o=i.jsx(u.Pagination,{size:"sm",total:e,value:n+1,onChange:l=>r(l-1,t)});return a?i.jsxs(u.Group,{gap:"sm",children:[i.jsxs("div",{children:[i.jsx(u.Text,{size:"sm",component:"span",pr:"xs",c:"dimmed",children:"Records per page"}),i.jsx(Xr,{size:"sm",values:["10","20","50","100"],value:t.toString(),onChange:l=>{r(0,parseInt(l,10))}})]}),o]}):o},Mt={xs:u.rem(22),sm:u.rem(26),md:u.rem(32),lg:u.rem(38),xl:u.rem(44)};function Xr({size:e,values:n,value:t,onChange:a}){return i.jsxs(u.Menu,{withinPortal:!0,withArrow:!0,offset:2,children:[i.jsx(u.MenuTarget,{children:i.jsx(u.Button,{size:e,variant:"default",rightSection:i.jsx(M.IconSelector,{size:16,stroke:1.5}),style:[{fontWeight:"normal"},r=>({height:Mt[e],paddingLeft:r.spacing[e],paddingRight:r.spacing[e]})],styles:{section:{marginInlineStart:2}},children:t})}),i.jsx(u.MenuDropdown,{children:n.map(r=>{const o=r===t;return i.jsx(u.MenuItem,{className:o?Jr.pageSizeSelectorActive:void 0,style:[{height:Mt[e]}],disabled:o,onClick:()=>a(r),children:i.jsx(u.Text,{component:"div",size:e,children:r})},r)})})]})}const At=new Set(["topRight","bottomRight"]),Zr=e=>{var k,j;const[n,t]=S.useState({records:[],total:0}),[a,r]=S.useState(!1),[o,l]=S.useState({}),s=w=>{r(!0),e.getData(w).then(E=>{t(E),r(!1)})},d=(w,E)=>{const R={...e.query.query,limit:E,offset:w*E};e.query.update(R)},[c,f,p]=S.useMemo(()=>{const w=e.query.query.limit,E=Math.floor((e.query.query.offset||0)/e.query.query.limit),R=Math.ceil(n.total/e.query.query.limit);return[w,E,R]},[e.query.query.limit,e.query.query.offset,n.total]);S.useEffect(()=>(n.total==0&&s(e.query.query),e.query.subscribe(s)),[e.query]);const v=S.useMemo(()=>Object.keys(o).filter(w=>o[w]).map(w=>e.normalizeRowId(w)),[o]);let g,y;Pt(e.actions)&&(g=i.jsx(Nt,{actions:e.actions,reloadData:()=>s(e.query.query),selectedRowKeys:v}));const x=((k=e.pagination)==null?void 0:k.positions)||At;if(x.size>0){const w=i.jsx(Ft,{total:p,pageIndex:f,pageSize:c,onUpdatePagination:d,allowPageSizeChange:(j=e.pagination)==null?void 0:j.showSizeChanger});x.has("topRight")&&(g!==void 0?g=i.jsxs(u.Group,{justify:"space-between",gap:"sm",children:[g,w]}):g=i.jsx(u.Flex,{justify:"flex-end",children:w})),(x.has("bottomRight")||x.has("bottomLeft")||x.has("bottomCenter"))&&(x.has("bottomLeft")?y=i.jsxs(u.Flex,{justify:"space-between",align:"center",children:[w,i.jsxs(u.Text,{size:"sm",c:"dimmed",children:["Showing ",f*c+1," to"," ",Math.min((f+1)*c,n.total)," of ",n.total," ","records"]})]}):y=i.jsxs(u.Flex,{justify:"space-between",align:"center",children:[i.jsxs(u.Text,{size:"sm",c:"dimmed",children:["Showing ",f*c+1," to"," ",Math.min((f+1)*c,n.total)," of ",n.total," ","records"]}),w]}))}const C=S.useMemo(()=>i.jsx(Qr,{data:n,loading:a,columns:e.columns,getRowId:e.getRowId,selectedRowKeys:o,setSelectedRowKeys:l,hasTopSection:g!==void 0,hasBottomSection:y!==void 0}),[n,a,e.columns,e.getRowId,o,l,g!==void 0,y!==void 0]);return g===void 0||y===void 0?C:i.jsxs("div",{children:[g!==void 0&&i.jsx(u.Paper,{withBorder:!0,p:"xs",style:{borderBottomLeftRadius:0,borderBottomRightRadius:0,borderBottom:"none"},children:g}),C,y!==void 0&&i.jsx(u.Paper,{withBorder:!0,p:"xs",style:{borderTopLeftRadius:0,borderTopRightRadius:0,borderTop:"none"},children:y})]})},Qr=e=>{const n=S.useMemo(()=>{const a=[{id:"selection",header:({table:r})=>i.jsx(u.Checkbox,{checked:r.getIsAllRowsSelected(),indeterminate:r.getIsSomeRowsSelected(),onChange:r.getToggleAllRowsSelectedHandler()}),cell:({row:r})=>i.jsx(u.Checkbox,{checked:r.getIsSelected(),disabled:!r.getCanSelect(),onChange:r.getToggleSelectedHandler()})}];return e.columns.forEach(r=>{a.push({id:r.key,header:r.title,accessorFn:r.render,cell:({row:o})=>r.render(o.original)})}),a},[e.columns]),t=Z.useReactTable({data:e.data.records,columns:n,getCoreRowModel:Z.getCoreRowModel(),getRowId:a=>e.getRowId(a).toString(),state:{rowSelection:e.selectedRowKeys},onRowSelectionChange:e.setSelectedRowKeys,manualPagination:!0});return i.jsx(Lt,{table:t,selectedRowKeys:e.selectedRowKeys,bordered:!0,hasTopSection:e.hasTopSection,hasBottomSection:e.hasBottomSection})};function $e(e,n,t,{title:a,nestedKey:r,component:o}={}){let l;if(o!==void 0)l=o;else if(K.isObjectProperty(t))t.cardinality==="1:N"||t.cardinality==="N:N"?l=de:l=ue;else{if(U[t.datatype]===void 0)throw new Error(`No display component found for datatype ${t.datatype}`);l=U[t.datatype]}const s={key:t.name,title:a||i.jsx(A,{value:t.label}),accessorFn:d=>d[t.tsName],render:d=>{const c=d[t.tsName];return i.jsx(l,{db:e,property:t,value:c,entityRoutes:n})}};return r!==void 0&&(s.accessorFn=d=>d[r][t.tsName],s.render=d=>{const c=d[r][t.tsName];return i.jsx(l,{db:e,property:t,value:c,entityRoutes:n})}),s}function ea(e,n,t,a,{title:r,nestedKey:o,component:l}={}){let s;if(l!==void 0)s=l;else if(K.isObjectProperty(a))a.cardinality==="1:N"||a.cardinality==="N:N"?s=de:s=ue;else{if(U[a.datatype]===void 0)throw new Error(`No display component found for datatype ${a.datatype}`);s=U[a.datatype]}const d={key:t+"."+a.name,title:r||i.jsx(A,{value:a.label}),accessorFn:c=>c[t.tsName][a.tsName],render:c=>{const f=c[t.tsName][a.tsName];return i.jsx(s,{db:e,property:a,value:f,entityRoutes:n})}};return o!==void 0&&(d.accessorFn=c=>c[o][t.tsName][a.tsName],d.render=c=>{const f=c[o][t.tsName][a.tsName];return i.jsx(s,{db:e,property:a,value:f,entityRoutes:n})}),d}function ta(e,n,t,a,r={}){return a.map(o=>ze(o)?o:$e(e,t,n.publicProperties[o],r))}function na(e,n,t,a=[],r={}){return a.map(o=>ze(o)?o:$e(e,t,n.publicProperties[o],r))}function ze(e){return typeof e=="object"&&"key"in e&&"title"in e}const ra=new Set(["topRight","bottomRight"]),aa=e=>{var f,p;const[n,t]=S.useState({}),a=S.useMemo(()=>{const v=[{id:"selection",header:({table:g})=>i.jsx(u.Checkbox,{checked:g.getIsAllRowsSelected(),indeterminate:g.getIsSomeRowsSelected(),onChange:g.getToggleAllRowsSelectedHandler()}),cell:({row:g})=>i.jsx(u.Checkbox,{checked:g.getIsSelected(),disabled:!g.getCanSelect(),onChange:g.getToggleSelectedHandler()})}];return e.columns.forEach(g=>{v.push({id:g.key,header:g.title,accessorFn:g.render,cell:({row:y})=>g.render(y.original)})}),v},[e.columns]),r=Z.useReactTable({data:e.data,columns:a,getCoreRowModel:Z.getCoreRowModel(),getPaginationRowModel:Z.getPaginationRowModel(),state:{rowSelection:n},onRowSelectionChange:t}),o=S.useMemo(()=>Object.keys(n).filter(v=>n[v]).map(Number),[n]);let l,s;Pt(e.actions)&&(l=i.jsx(Nt,{actions:e.actions,selectedRowKeys:o}));const d=((f=e.pagination)==null?void 0:f.positions)||ra;if(d.size>0){const v=r.getState().pagination,g=i.jsx(Ft,{total:r.getPageCount(),pageIndex:v.pageIndex,pageSize:v.pageSize,onUpdatePagination:(y,x)=>r.setPagination({pageIndex:y,pageSize:x}),allowPageSizeChange:(p=e.pagination)==null?void 0:p.showSizeChanger});d.has("topRight")&&(l!==void 0?l=i.jsxs(u.Group,{justify:"space-between",gap:"sm",children:[l,g]}):l=i.jsx(u.Flex,{justify:"flex-end",children:g})),(d.has("bottomRight")||d.has("bottomLeft")||d.has("bottomCenter"))&&(d.has("bottomLeft")?s=i.jsxs(u.Flex,{justify:"space-between",align:"center",children:[g,i.jsxs(u.Text,{size:"sm",c:"dimmed",children:["Showing ",v.pageIndex*v.pageSize+1," to"," ",Math.min((v.pageIndex+1)*v.pageSize,e.data.length)," ","of ",e.data.length," records"]})]}):s=i.jsxs(u.Flex,{justify:"space-between",align:"center",children:[i.jsxs(u.Text,{size:"sm",c:"dimmed",children:["Showing ",v.pageIndex*v.pageSize+1," to"," ",Math.min((v.pageIndex+1)*v.pageSize,e.data.length)," ","of ",e.data.length," records"]}),g]}))}const c=i.jsx(Lt,{selectedRowKeys:n,table:r,bordered:!0,hasTopSection:l!==void 0,hasBottomSection:s!==void 0});return l===void 0&&s===void 0?c:i.jsxs("div",{children:[l!==void 0&&i.jsx(u.Paper,{withBorder:!0,p:"xs",style:{borderBottomLeftRadius:0,borderBottomRightRadius:0,borderBottom:"none"},children:l}),c,s!==void 0&&i.jsx(u.Paper,{withBorder:!0,p:"xs",style:{borderTopLeftRadius:0,borderTopRightRadius:0,borderTop:"none"},children:s})]})},Ot=W.observer(({store:e,record:n,property:t,DisplayComponent:a,entityRoutes:r})=>{const o=n[t.tsName];return i.jsxs("div",{children:[i.jsx(u.Text,{size:"sm",fw:550,children:i.jsx(A,{value:t.label})}),i.jsx(a,{db:e.db,entityRoutes:r,property:t,value:o})]})}),oa=W.observer(({store:e,record:n,properties:t,DisplayComponent:a,entityRoutes:r})=>{const o=t[t.length-1],l=t.reduce((s,d)=>{if(s!=null)return s[d.tsName]},n);return i.jsxs("div",{children:[i.jsx(u.Text,{size:"sm",fw:550,children:i.jsx(A,{value:o.label})}),l!==void 0&&i.jsx(a,{db:e.db,property:o,value:l,entityRoutes:r})]})}),ia=12,Dt=e=>{const n=e.schema,t=S.useMemo(()=>e.fieldGroups.map((a,r)=>la(n,e.store,e.record,r,a,e.entityRoutes)),[n,e.store,e.record,e.fieldGroups]);return i.jsx(u.Stack,{gap:"sm",className:e.className,style:e.styles,children:t})};function la(e,n,t,a,r,o){const l=r.fields,s=[];for(let d=0;d<l.length;d++){const c=ia/l[d].length;if(!Number.isInteger(c))throw new Error(`Span must be an integer, but got ${c} for row ${d}`);for(let f=0;f<l[d].length;f++){const p=l[d][f];let v;if(typeof p=="function")v=p(n,t);else if(typeof p=="object"&&"prop"in p){const g=e.allProperties[p.prop],y=p.display;v=i.jsx(Ot,{store:n,record:t,property:g,DisplayComponent:y,entityRoutes:o})}else{const g=e.allProperties[p];let y;if(K.isObjectProperty(g))y=g.cardinality==="N:N"||g.cardinality==="1:N"?de:ue;else{if(U[g.datatype]===void 0)throw new Error(`No display component found for datatype ${g.datatype}`);y=U[g.datatype]}v=i.jsx(Ot,{store:n,record:t,property:g,DisplayComponent:y,entityRoutes:o})}s.push(i.jsx(u.Grid.Col,{span:c,children:v},`${d}-${f}`))}}return i.jsx(u.Grid,{gutter:"sm",children:s},a)}function sa(e,n,t){const a=e[e.length-1];let r;if(t!==void 0)r=t;else if(K.isObjectProperty(a))r=a.cardinality==="N:N"||a.cardinality==="1:N"?de:ue;else{if(U[a.datatype]===void 0)throw new Error(`No display component found for datatype ${a.datatype}`);r=U[a.datatype]}return(o,l)=>i.jsx(oa,{store:o,record:l,properties:e,DisplayComponent:r,entityRoutes:n})}const ua=e=>i.jsxs(u.Tabs,{defaultValue:e.fieldTabs[0].tabName,children:[i.jsx(u.Tabs.List,{children:e.fieldTabs.map((n,t)=>i.jsx(u.Tabs.Tab,{value:n.tabName,children:n.tabName},t))}),e.fieldTabs.map((n,t)=>i.jsx(u.Tabs.Panel,{value:n.tabName,pt:"sm",children:i.jsx(Dt,{schema:e.schema,store:e.store,record:e.record,fieldGroups:n.fieldGroups,styles:e.tabStyles,className:e.tabClassName,entityRoutes:e.entityRoutes})},t))]});b.CountryFlagComponent=fe,b.DEFAULT_PAGINATION_POSITIONS=At,b.DataType2Component=_e,b.DataType2DisplayComponent=U,b.DateDisplay=wt,b.DateTimeDisplay=bt,b.DateTimeHideTimeDisplay=Er,b.EmojiCountryFlag=Je,b.FormItem=Tt,b.FormItemLabel=kt,b.LanguageSelector=Xt,b.Loading=pr,b.LoadingInline=xr,b.LocaleContext=ee,b.LocaleProvider=Yt,b.MenuTrie=xt,b.MultiForeignKeyDisplay=de,b.MultiLingualString=A,b.NotAuthorized=vr,b.NotFound=mr,b.NotFoundInline=Fe,b.NotFoundSubPage=gr,b.OrderedUniqueList=Sr,b.Permission=pt,b.SVGCountryFlag=Ye,b.SeraEmbeddedTable=aa,b.SeraForm=Ur,b.SeraTable=Zr,b.SeraVerticalMenu=Cr,b.SeraView=Dt,b.SeraViewTab=ua,b.SingleForeignKeyDisplay=ue,b.Trie=Ae,b.TrieNode=Me,b.buildMenuItemIndex=vt,b.countryFlags=P,b.filterAllowedItems=yt,b.groupBy=yr,b.groupByAsList=br,b.isSeraColumn=ze,b.makeEmbeddedTableColumns=na,b.makeFieldDisplay=sa,b.makeTableColumn=$e,b.makeTableColumnFromNestedProperty=ea,b.makeTableColumns=ta,b.uniqueList=wr,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sera-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@types/react-dom": "^19.0.4",
|
|
33
33
|
"rimraf": "^6.0.1"
|
|
34
34
|
},
|
|
35
|
-
"
|
|
35
|
+
"peerDependencies": {
|
|
36
36
|
"@mantine/core": "^8.1.0",
|
|
37
37
|
"@mantine/form": "^8.1.0",
|
|
38
38
|
"react": "^19.0.0",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"@tabler/icons-react": "^3.31.0",
|
|
43
43
|
"@tanstack/react-table": "^8.21.3",
|
|
44
44
|
"mobx-react-lite": "^4.1.0",
|
|
45
|
-
"sera-db": "^1.12.
|
|
45
|
+
"sera-db": "^1.12.2",
|
|
46
|
+
"sera-route": "^1.3.11"
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
type LinkComponent = React.FunctionComponent<{
|
|
2
|
-
to: any;
|
|
3
|
-
params: {
|
|
4
|
-
id: string | number;
|
|
5
|
-
};
|
|
6
|
-
openInNewPage?: boolean;
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
}>;
|
|
9
|
-
export declare const ExternalComponentContext: import('react').Context<{
|
|
10
|
-
link: LinkComponent;
|
|
11
|
-
}>;
|
|
12
|
-
export declare const ExternalComponentProvider: ({ link, children, }: {
|
|
13
|
-
link: LinkComponent;
|
|
14
|
-
children: React.ReactNode;
|
|
15
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export {};
|