sera-components 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -53,7 +53,7 @@ var he = {};
53
53
  */
54
54
  var ct;
55
55
  function Fn() {
56
- return ct || (ct = 1, process.env.NODE_ENV !== "production" && function() {
56
+ return ct || (ct = 1, process.env.NODE_ENV !== "production" && (function() {
57
57
  function e(m) {
58
58
  if (m == null) return null;
59
59
  if (typeof m == "function")
@@ -282,7 +282,7 @@ React keys must be passed directly to JSX without using spread:
282
282
  M ? _e(a(m)) : ot
283
283
  );
284
284
  };
285
- }()), he;
285
+ })()), he;
286
286
  }
287
287
  var dt;
288
288
  function _n() {
@@ -1,4 +1,4 @@
1
- (function(y,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("@mantine/core"),require("@tabler/icons-react"),require("mobx-react-lite"),require("sera-db"),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","react-imask","@tanstack/react-table"],w):(y=typeof globalThis<"u"?globalThis:y||self,w(y["sera-components"]={},y.React,y["@mantine/core"],y["@tabler/icons-react"],y["mobx-react-lite"],y["sera-db"],y.ReactIMask,y["@tanstack/react-table"]))})(this,function(y,w,u,M,U,G,Gt,Y){"use strict";var ha=Object.defineProperty;var ma=(y,w,u)=>w in y?ha(y,w,{enumerable:!0,configurable:!0,writable:!0,value:u}):y[w]=u;var H=(y,w,u)=>ma(y,typeof w!="symbol"?w+"":w,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 m=Wt(w);var ce={exports:{}},oe={};/**
1
+ (function(y,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("@mantine/core"),require("@tabler/icons-react"),require("mobx-react-lite"),require("sera-db"),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","react-imask","@tanstack/react-table"],w):(y=typeof globalThis<"u"?globalThis:y||self,w(y["sera-components"]={},y.React,y["@mantine/core"],y["@tabler/icons-react"],y["mobx-react-lite"],y["sera-db"],y.ReactIMask,y["@tanstack/react-table"]))})(this,(function(y,w,u,M,U,G,Gt,Y){"use strict";var ha=Object.defineProperty;var ma=(y,w,u)=>w in y?ha(y,w,{enumerable:!0,configurable:!0,writable:!0,value:u}):y[w]=u;var H=(y,w,u)=>ma(y,typeof w!="symbol"?w+"":w,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 m=Wt(w);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(g){if(g==null)return null;if(typeof g=="function")return g.$$typeof===K?null:g.displayName||g.name||null;if(typeof g=="string")return g;switch(g){case S:return"Fragment";case C:return"Profiler";case E:return"StrictMode";case P:return"Suspense";case ne:return"SuspenseList";case A:return"Activity"}if(typeof g=="object")switch(typeof g.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),g.$$typeof){case v:return"Portal";case b:return(g.displayName||"Context")+".Provider";case j:return(g._context.displayName||"Context")+".Consumer";case T:var k=g.render;return g=g.displayName,g||(g=k.displayName||k.name||"",g=g!==""?"ForwardRef("+g+")":"ForwardRef"),g;case X:return k=g.displayName||null,k!==null?k:e(g.type)||"Memo";case Z:k=g._payload,g=g._init;try{return e(g(k))}catch{}}return null}function n(g){return""+g}function t(g){try{n(g);var k=!1}catch{k=!0}if(k){k=console;var N=k.error,F=typeof Symbol=="function"&&Symbol.toStringTag&&g[Symbol.toStringTag]||g.constructor.name||"Object";return N.call(k,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",F),n(g)}}function a(g){if(g===S)return"<>";if(typeof g=="object"&&g!==null&&g.$$typeof===Z)return"<...>";try{var k=e(g);return k?"<"+k+">":"<...>"}catch{return"<...>"}}function r(){var g=re.A;return g===null?null:g.getOwner()}function o(){return Error("react-stack-top-frame")}function l(g){if(_t.call(g,"key")){var k=Object.getOwnPropertyDescriptor(g,"key").get;if(k&&k.isReactWarning)return!1}return g.key!==void 0}function s(g,k){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)",k))}N.isReactWarning=!0,Object.defineProperty(g,"key",{get:N,configurable:!0})}function d(){var g=e(this.type);return zt[g]||(zt[g]=!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.")),g=this.props.ref,g!==void 0?g:null}function c(g,k,N,F,V,D,Ue,Ge){return N=D.ref,g={$$typeof:h,type:g,key:k,props:D,_owner:V},(N!==void 0?N:null)!==null?Object.defineProperty(g,"ref",{enumerable:!1,get:d}):Object.defineProperty(g,"ref",{enumerable:!1,value:null}),g._store={},Object.defineProperty(g._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(g,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(g,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Ue}),Object.defineProperty(g,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Ge}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g}function f(g,k,N,F,V,D,Ue,Ge){var L=k.children;if(L!==void 0)if(F)if(ca(L)){for(F=0;F<L.length;F++)p(L[F]);Object.freeze&&Object.freeze(L)}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(L);if(_t.call(k,"key")){L=e(g);var ae=Object.keys(k).filter(function(fa){return fa!=="key"});F=0<ae.length?"{key: someKey, "+ae.join(": ..., ")+": ...}":"{key: someKey}",Ut[L+F]||(ae=0<ae.length?"{"+ae.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var Ve;function Vt(){return Ve||(Ve=1,process.env.NODE_ENV!=="production"&&(function(){function e(g){if(g==null)return null;if(typeof g=="function")return g.$$typeof===K?null:g.displayName||g.name||null;if(typeof g=="string")return g;switch(g){case S:return"Fragment";case C:return"Profiler";case E:return"StrictMode";case P:return"Suspense";case ne:return"SuspenseList";case A:return"Activity"}if(typeof g=="object")switch(typeof g.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),g.$$typeof){case v:return"Portal";case b:return(g.displayName||"Context")+".Provider";case j:return(g._context.displayName||"Context")+".Consumer";case T:var k=g.render;return g=g.displayName,g||(g=k.displayName||k.name||"",g=g!==""?"ForwardRef("+g+")":"ForwardRef"),g;case X:return k=g.displayName||null,k!==null?k:e(g.type)||"Memo";case Z:k=g._payload,g=g._init;try{return e(g(k))}catch{}}return null}function n(g){return""+g}function t(g){try{n(g);var k=!1}catch{k=!0}if(k){k=console;var N=k.error,F=typeof Symbol=="function"&&Symbol.toStringTag&&g[Symbol.toStringTag]||g.constructor.name||"Object";return N.call(k,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",F),n(g)}}function a(g){if(g===S)return"<>";if(typeof g=="object"&&g!==null&&g.$$typeof===Z)return"<...>";try{var k=e(g);return k?"<"+k+">":"<...>"}catch{return"<...>"}}function r(){var g=re.A;return g===null?null:g.getOwner()}function o(){return Error("react-stack-top-frame")}function l(g){if(_t.call(g,"key")){var k=Object.getOwnPropertyDescriptor(g,"key").get;if(k&&k.isReactWarning)return!1}return g.key!==void 0}function s(g,k){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)",k))}N.isReactWarning=!0,Object.defineProperty(g,"key",{get:N,configurable:!0})}function d(){var g=e(this.type);return zt[g]||(zt[g]=!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.")),g=this.props.ref,g!==void 0?g:null}function c(g,k,N,F,V,D,Ue,Ge){return N=D.ref,g={$$typeof:h,type:g,key:k,props:D,_owner:V},(N!==void 0?N:null)!==null?Object.defineProperty(g,"ref",{enumerable:!1,get:d}):Object.defineProperty(g,"ref",{enumerable:!1,value:null}),g._store={},Object.defineProperty(g._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(g,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(g,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Ue}),Object.defineProperty(g,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Ge}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g}function f(g,k,N,F,V,D,Ue,Ge){var L=k.children;if(L!==void 0)if(F)if(ca(L)){for(F=0;F<L.length;F++)p(L[F]);Object.freeze&&Object.freeze(L)}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(L);if(_t.call(k,"key")){L=e(g);var ae=Object.keys(k).filter(function(fa){return fa!=="key"});F=0<ae.length?"{key: someKey, "+ae.join(": ..., ")+": ...}":"{key: someKey}",Ut[L+F]||(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,L,ae,L),Ut[L+F]=!0)}if(L=null,N!==void 0&&(t(N),L=""+N),l(k)&&(t(k.key),L=""+k.key),"key"in k){N={};for(var We in k)We!=="key"&&(N[We]=k[We])}else N=k;return L&&s(N,typeof g=="function"?g.displayName||g.name||"Unknown":g),c(g,L,D,V,r(),N,Ue,Ge)}function p(g){typeof g=="object"&&g!==null&&g.$$typeof===h&&g._store&&(g._store.validated=1)}var x=w,h=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),j=Symbol.for("react.consumer"),b=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),ne=Symbol.for("react.suspense_list"),X=Symbol.for("react.memo"),Z=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),K=Symbol.for("react.client.reference"),re=x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_t=Object.prototype.hasOwnProperty,ca=Array.isArray,qe=console.createTask?console.createTask:function(){return null};x={react_stack_bottom_frame:function(g){return g()}};var $t,zt={},Bt=x.react_stack_bottom_frame.bind(x,o)(),qt=qe(a(o)),Ut={};ie.Fragment=S,ie.jsx=function(g,k,N,F,V){var D=1e4>re.recentlyCreatedOwnerStacks++;return f(g,k,N,!1,F,V,D?Error("react-stack-top-frame"):Bt,D?qe(a(g)):qt)},ie.jsxs=function(g,k,N,F,V){var D=1e4>re.recentlyCreatedOwnerStacks++;return f(g,k,N,!0,F,V,D?Error("react-stack-top-frame"):Bt,D?qe(a(g)):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 R={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,Q=w.createContext(new Intl.Locale("en-US")),Yt=U.observer(({value:e,children:n})=>i.jsx(Q.Provider,{value:e.locale,children:n})),Jt={lang2value:{en:"Choose Language",vi:"Chọn ngôn ngữ"}},he={en:{name:"English",flag:R.US,locale:new Intl.Locale("en-US")},vi:{name:"Tiếng Việt",flag:R.VN,locale:new Intl.Locale("vi-VN")}},Xt=({locale:e,setLocale:n})=>{const t=w.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]})]})},O=({value:e})=>{const n=w.useContext(Q);return e.lang2value[n.language]||e.lang2value[e.lang]};/**
22
+ <%s key={someKey} {...props} />`,F,L,ae,L),Ut[L+F]=!0)}if(L=null,N!==void 0&&(t(N),L=""+N),l(k)&&(t(k.key),L=""+k.key),"key"in k){N={};for(var We in k)We!=="key"&&(N[We]=k[We])}else N=k;return L&&s(N,typeof g=="function"?g.displayName||g.name||"Unknown":g),c(g,L,D,V,r(),N,Ue,Ge)}function p(g){typeof g=="object"&&g!==null&&g.$$typeof===h&&g._store&&(g._store.validated=1)}var x=w,h=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),j=Symbol.for("react.consumer"),b=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),ne=Symbol.for("react.suspense_list"),X=Symbol.for("react.memo"),Z=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),K=Symbol.for("react.client.reference"),re=x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_t=Object.prototype.hasOwnProperty,ca=Array.isArray,qe=console.createTask?console.createTask:function(){return null};x={react_stack_bottom_frame:function(g){return g()}};var $t,zt={},Bt=x.react_stack_bottom_frame.bind(x,o)(),qt=qe(a(o)),Ut={};ie.Fragment=S,ie.jsx=function(g,k,N,F,V){var D=1e4>re.recentlyCreatedOwnerStacks++;return f(g,k,N,!1,F,V,D?Error("react-stack-top-frame"):Bt,D?qe(a(g)):qt)},ie.jsxs=function(g,k,N,F,V){var D=1e4>re.recentlyCreatedOwnerStacks++;return f(g,k,N,!0,F,V,D?Error("react-stack-top-frame"):Bt,D?qe(a(g)):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 R={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,Q=w.createContext(new Intl.Locale("en-US")),Yt=U.observer(({value:e,children:n})=>i.jsx(Q.Provider,{value:e.locale,children:n})),Jt={lang2value:{en:"Choose Language",vi:"Chọn ngôn ngữ"}},he={en:{name:"English",flag:R.US,locale:new Intl.Locale("en-US")},vi:{name:"Tiếng Việt",flag:R.VN,locale:new Intl.Locale("vi-VN")}},Xt=({locale:e,setLocale:n})=>{const t=w.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]})]})},O=({value:e})=>{const n=w.useContext(Q);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.
@@ -30,4 +30,4 @@ React keys must be passed directly to JSX without using spread:
30
30
  * @license MIT
31
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 Ce({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 Ee(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"?Ee(n):n,o=W(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=$([a,f.relativePath]),x=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,x,p,d)),!(l.path==null&&!l.index)&&n.push({path:p,score:ln(p,l.index),routesMeta:x})};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),x=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:$([o,p.pathname]),pathnameBase:gn($([o,p.pathnameBase])),route:x}),p.pathnameBase!=="/"&&(o=$([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},x)=>{if(f==="*"){let v=s[x]||"";l=o.slice(0,o.length-v.length).replace(/(.)\/+$/,"$1")}const h=s[x];return p&&!h?c[f]=void 0:c[f]=(h||"").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 W(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"?Ee(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 ke(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=Ee(e):(r={...e},I(!r.pathname||!r.pathname.includes("?"),ke("?","pathname","search",r)),I(!r.pathname||!r.pathname.includes("#"),ke("#","pathname","hash",r)),I(!r.search||!r.search.includes("#"),ke("#","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 x=l.split("/");for(;x[0]==="..";)x.shift(),p-=1;r.pathname=x.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 $=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 ee=m.createContext(null);ee.displayName="DataRouter";var ge=m.createContext(null);ge.displayName="DataRouterState",m.createContext(!1);var at=m.createContext({isTransitioning:!1});at.displayName="ViewTransition";var bn=m.createContext(new Map);bn.displayName="Fetchers";var wn=m.createContext(null);wn.displayName="Await";var z=m.createContext(null);z.displayName="Navigation";var Te=m.createContext(null);Te.displayName="Location";var B=m.createContext({outlet:null,matches:[],isDataRoute:!1});B.displayName="Route";var Ne=m.createContext(null);Ne.displayName="RouteError";function jn(e,{relative:n}={}){I(pe(),"useHref() may be used only in the context of a <Router> component.");let{basename:t,navigator:a}=m.useContext(z),{hash:r,pathname:o,search:l}=le(e,{relative:n}),s=o;return t!=="/"&&(s=o==="/"?t:$([t,o])),a.createHref({pathname:s,search:l,hash:r})}function pe(){return m.useContext(Te)!=null}function J(){return I(pe(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(Te).location}var ot="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function it(e){m.useContext(z).static||m.useLayoutEffect(e)}function lt(){let{isDataRoute:e}=m.useContext(B);return e?On():Sn()}function Sn(){I(pe(),"useNavigate() may be used only in the context of a <Router> component.");let e=m.useContext(ee),{basename:n,navigator:t}=m.useContext(z),{matches:a}=m.useContext(B),{pathname:r}=J(),o=JSON.stringify(tt(a)),l=m.useRef(!1);return it(()=>{l.current=!0}),m.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:$([n,f.pathname])),(c.replace?t.replace:t.push)(f,c.state,c)},[n,t,o,r,e])}m.createContext(null);function le(e,{relative:n}={}){let{matches:t}=m.useContext(B),{pathname:a}=J(),r=JSON.stringify(tt(t));return m.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}=m.useContext(z),{matches:l}=m.useContext(B),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||"";ut(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 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"})}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sera-components",
3
3
  "private": false,
4
- "version": "1.2.1",
4
+ "version": "1.2.2",
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
- "dependencies": {
35
+ "peerDependencies": {
36
36
  "@mantine/core": "^8.1.0",
37
37
  "@mantine/form": "^8.1.0",
38
38
  "react": "^19.0.0",