proje-react-panel 1.0.14-test-3 → 1.0.15

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.
Files changed (149) hide show
  1. package/.cursor/rules.md +122 -0
  2. package/.cursor/settings.json +57 -0
  3. package/.eslintrc.js +5 -0
  4. package/.eslintrc.json +26 -0
  5. package/.prettierrc +10 -0
  6. package/.vscode/launch.json +17 -0
  7. package/.vscode/settings.json +8 -0
  8. package/PTD.md +234 -0
  9. package/README.md +62 -28
  10. package/dist/api/CrudApi.d.ts +12 -0
  11. package/dist/components/Panel.d.ts +2 -2
  12. package/dist/components/components/Checkbox.d.ts +6 -0
  13. package/dist/components/components/Counter.d.ts +9 -0
  14. package/dist/components/components/FormField.d.ts +12 -0
  15. package/dist/components/components/ImageUploader.d.ts +15 -0
  16. package/dist/components/components/InnerForm.d.ts +12 -0
  17. package/dist/components/components/LoadingScreen.d.ts +2 -0
  18. package/dist/components/components/index.d.ts +8 -0
  19. package/dist/components/layout/Layout.d.ts +2 -1
  20. package/dist/components/layout/SideBar.d.ts +4 -3
  21. package/dist/components/layout/index.d.ts +2 -0
  22. package/dist/components/list/Datagrid.d.ts +8 -0
  23. package/dist/components/list/Pagination.d.ts +11 -0
  24. package/dist/components/list/index.d.ts +0 -0
  25. package/dist/{src/screens → components/pages}/ControllerDetails.d.ts +1 -1
  26. package/dist/components/pages/FormPage.d.ts +11 -0
  27. package/dist/components/pages/ListPage.d.ts +17 -0
  28. package/dist/components/pages/Login.d.ts +13 -0
  29. package/dist/decorators/form/Form.d.ts +6 -0
  30. package/dist/decorators/form/FormOptions.d.ts +7 -0
  31. package/dist/decorators/form/Input.d.ts +13 -0
  32. package/dist/decorators/form/getFormFields.d.ts +3 -0
  33. package/dist/decorators/{Cell.d.ts → list/Cell.d.ts} +2 -2
  34. package/dist/decorators/list/GetCellFields.d.ts +2 -0
  35. package/dist/decorators/list/ImageCell.d.ts +6 -0
  36. package/dist/decorators/list/List.d.ts +5 -0
  37. package/dist/decorators/list/ListData.d.ts +6 -0
  38. package/dist/decorators/list/getListFields.d.ts +2 -0
  39. package/dist/index.cjs.js +1 -1
  40. package/dist/index.d.ts +19 -10
  41. package/dist/index.esm.js +1 -1
  42. package/dist/initPanel.d.ts +2 -2
  43. package/dist/store/store.d.ts +1 -5
  44. package/dist/types/AnyClass.d.ts +1 -0
  45. package/dist/types/ScreenCreatorData.d.ts +5 -3
  46. package/dist/types/initPanelOptions.d.ts +0 -6
  47. package/dist/utils/format.d.ts +1 -0
  48. package/dist/utils/getFields.d.ts +2 -1
  49. package/package.json +5 -4
  50. package/src/api/CrudApi.ts +30 -11
  51. package/src/components/Panel.tsx +11 -11
  52. package/src/components/components/Checkbox.tsx +9 -0
  53. package/src/components/components/Counter.tsx +51 -0
  54. package/src/components/components/FormField.tsx +60 -0
  55. package/src/components/components/ImageUploader.tsx +301 -0
  56. package/src/components/components/InnerForm.tsx +75 -0
  57. package/src/components/components/LoadingScreen.tsx +12 -0
  58. package/src/components/components/index.ts +8 -0
  59. package/src/components/layout/Layout.tsx +7 -3
  60. package/src/components/layout/SideBar.tsx +103 -31
  61. package/src/components/layout/index.ts +2 -0
  62. package/src/components/list/Datagrid.tsx +101 -0
  63. package/src/components/list/Pagination.tsx +110 -0
  64. package/src/components/list/index.ts +1 -0
  65. package/src/components/pages/ControllerDetails.tsx +37 -0
  66. package/src/components/pages/FormPage.tsx +32 -0
  67. package/src/components/pages/ListPage.tsx +85 -0
  68. package/src/components/pages/Login.tsx +79 -0
  69. package/src/decorators/form/Form.ts +18 -0
  70. package/src/decorators/form/FormOptions.ts +8 -0
  71. package/src/decorators/form/Input.ts +52 -0
  72. package/src/decorators/form/getFormFields.ts +13 -0
  73. package/src/decorators/{Cell.ts → list/Cell.ts} +2 -14
  74. package/src/decorators/list/GetCellFields.ts +13 -0
  75. package/src/decorators/list/ImageCell.ts +13 -0
  76. package/src/decorators/list/List.ts +17 -0
  77. package/src/decorators/list/ListData.ts +7 -0
  78. package/src/decorators/list/getListFields.ts +10 -0
  79. package/src/index.ts +23 -10
  80. package/src/initPanel.ts +4 -12
  81. package/src/store/store.ts +23 -28
  82. package/src/styles/_scrollbar.scss +19 -0
  83. package/src/styles/counter.scss +42 -0
  84. package/src/styles/image-uploader.scss +94 -0
  85. package/src/styles/index.scss +30 -7
  86. package/src/styles/layout.scss +1 -6
  87. package/src/styles/list.scss +32 -5
  88. package/src/styles/loading-screen.scss +42 -0
  89. package/src/styles/pagination.scss +66 -0
  90. package/src/styles/sidebar.scss +64 -0
  91. package/src/types/AnyClass.ts +1 -0
  92. package/src/types/ScreenCreatorData.ts +5 -3
  93. package/src/types/initPanelOptions.ts +1 -7
  94. package/src/utils/format.ts +7 -0
  95. package/src/utils/getFields.ts +11 -9
  96. package/dist/api/crudApi.d.ts +0 -17
  97. package/dist/components/Form.d.ts +0 -6
  98. package/dist/components/FormField.d.ts +0 -13
  99. package/dist/components/list/List.d.ts +0 -10
  100. package/dist/components/screens/ControllerCreate.d.ts +0 -5
  101. package/dist/components/screens/ControllerDetails.d.ts +0 -5
  102. package/dist/components/screens/ControllerEdit.d.ts +0 -5
  103. package/dist/components/screens/ControllerList.d.ts +0 -5
  104. package/dist/components/screens/Login.d.ts +0 -2
  105. package/dist/decorators/Input.d.ts +0 -13
  106. package/dist/hooks/useScreens.d.ts +0 -2
  107. package/dist/initPanelOptions.d.ts +0 -8
  108. package/dist/screens/ControllerCreate.d.ts +0 -5
  109. package/dist/screens/ControllerDetails.d.ts +0 -5
  110. package/dist/screens/ControllerEdit.d.ts +0 -5
  111. package/dist/screens/ControllerList.d.ts +0 -5
  112. package/dist/screens/Form.d.ts +0 -6
  113. package/dist/src/api/crudApi.d.ts +0 -6
  114. package/dist/src/components/Panel.d.ts +0 -9
  115. package/dist/src/components/layout/Layout.d.ts +0 -11
  116. package/dist/src/components/layout/SideBar.d.ts +0 -10
  117. package/dist/src/components/list/List.d.ts +0 -10
  118. package/dist/src/decorators/Cell.d.ts +0 -10
  119. package/dist/src/decorators/Crud.d.ts +0 -6
  120. package/dist/src/index.d.ts +0 -8
  121. package/dist/src/screens/ControllerCreate.d.ts +0 -5
  122. package/dist/src/screens/ControllerEdit.d.ts +0 -5
  123. package/dist/src/screens/ControllerList.d.ts +0 -5
  124. package/dist/src/screens/Form.d.ts +0 -6
  125. package/dist/src/store/store.d.ts +0 -19
  126. package/dist/src/types/Screen.d.ts +0 -4
  127. package/dist/src/types/ScreenCreatorData.d.ts +0 -8
  128. package/dist/src/utils/createScreens.d.ts +0 -1
  129. package/dist/src/utils/getFields.d.ts +0 -2
  130. package/dist/src/utils/getScreens.d.ts +0 -2
  131. package/dist/utils/crudScreens.d.ts +0 -2
  132. package/dist/utils/getScreens.d.ts +0 -2
  133. package/src/api/AuthApi.ts +0 -14
  134. package/src/components/Form.tsx +0 -80
  135. package/src/components/FormField.tsx +0 -60
  136. package/src/components/list/List.tsx +0 -81
  137. package/src/components/screens/ControllerCreate.tsx +0 -7
  138. package/src/components/screens/ControllerDetails.tsx +0 -40
  139. package/src/components/screens/ControllerEdit.tsx +0 -35
  140. package/src/components/screens/ControllerList.tsx +0 -45
  141. package/src/components/screens/Login.tsx +0 -68
  142. package/src/decorators/Input.ts +0 -50
  143. package/src/hooks/useScreens.tsx +0 -36
  144. /package/dist/components/{ErrorBoundary.d.ts → components/ErrorBoundary.d.ts} +0 -0
  145. /package/dist/components/{ErrorComponent.d.ts → components/ErrorComponent.d.ts} +0 -0
  146. /package/dist/components/{Label.d.ts → components/Label.d.ts} +0 -0
  147. /package/src/components/{ErrorBoundary.tsx → components/ErrorBoundary.tsx} +0 -0
  148. /package/src/components/{ErrorComponent.tsx → components/ErrorComponent.tsx} +0 -0
  149. /package/src/components/{Label.tsx → components/Label.tsx} +0 -0
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { ScreenCreatorData } from "../../types/ScreenCreatorData";
3
- export declare function Layout<IconType>({ children, menu, getIcons, }: {
3
+ export declare function Layout<IconType>({ children, menu, getIcons, logout, }: {
4
4
  children?: React.ReactNode;
5
5
  menu?: (screens: Record<string, ScreenCreatorData>) => {
6
6
  name: string;
@@ -8,4 +8,5 @@ export declare function Layout<IconType>({ children, menu, getIcons, }: {
8
8
  iconType: IconType;
9
9
  }[];
10
10
  getIcons?: (iconType: IconType) => React.ReactNode;
11
+ logout?: () => void;
11
12
  }): React.JSX.Element;
@@ -1,13 +1,14 @@
1
- import React from "react";
2
- import { ScreenCreatorData } from "../../types/ScreenCreatorData";
1
+ import React from 'react';
2
+ import { ScreenCreatorData } from '../../types/ScreenCreatorData';
3
3
  type GetMenuFunction<IconType> = (screens: Record<string, ScreenCreatorData>) => {
4
4
  name: string;
5
5
  path: string;
6
6
  iconType: IconType;
7
7
  }[];
8
8
  type GetIconsFunction<IconType> = (iconType: IconType) => React.ReactNode;
9
- export declare function SideBar<IconType>({ menu, getIcons, }: {
9
+ export declare function SideBar<IconType>({ menu, getIcons, onLogout, }: {
10
10
  menu?: GetMenuFunction<IconType>;
11
11
  getIcons?: GetIconsFunction<IconType>;
12
+ onLogout?: () => void;
12
13
  }): React.JSX.Element;
13
14
  export {};
@@ -0,0 +1,2 @@
1
+ export { SideBar } from './SideBar';
2
+ export { Layout } from './Layout';
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { CellOptions } from '../../decorators/list/Cell';
3
+ interface ListProps<T> {
4
+ data: T[];
5
+ cells: CellOptions[];
6
+ }
7
+ export declare function Datagrid<T>({ data, cells }: ListProps<T>): React.JSX.Element;
8
+ export {};
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ interface PaginationProps {
3
+ pagination: {
4
+ total: number;
5
+ page: number;
6
+ limit: number;
7
+ };
8
+ onPageChange: (page: number) => void;
9
+ }
10
+ export declare function Pagination({ pagination, onPageChange }: PaginationProps): React.JSX.Element | null;
11
+ export {};
File without changes
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Screen } from '../types/Screen';
2
+ import { Screen } from '../../types/Screen';
3
3
  export declare function ControllerDetails({ screen }: {
4
4
  screen: Screen;
5
5
  }): React.JSX.Element;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { AnyClass } from '../../types/AnyClass';
3
+ export type GetDetailsDataFN<T> = (param: string) => Promise<T>;
4
+ export type OnSubmitFN<T> = (data: T) => Promise<T>;
5
+ export interface FormPageProps<T extends AnyClass> {
6
+ model: T;
7
+ getDetailsData?: GetDetailsDataFN<T>;
8
+ redirect?: string;
9
+ onSubmit: OnSubmitFN<T>;
10
+ }
11
+ export declare function FormPage<T extends AnyClass>({ model, getDetailsData, onSubmit, redirect, ...rest }: FormPageProps<T>): React.JSX.Element;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { AnyClass } from '../../types/AnyClass';
3
+ export interface PaginationParams {
4
+ page?: number;
5
+ limit?: number;
6
+ }
7
+ export interface PaginatedResponse<T> {
8
+ data: T[];
9
+ total: number;
10
+ page: number;
11
+ limit: number;
12
+ }
13
+ export type GetDataForList<T> = ({ page, }: PaginationParams) => PaginatedResponse<T> | Promise<PaginatedResponse<T>>;
14
+ export declare function ListPage<T extends AnyClass>({ model, getData, }: {
15
+ model: T;
16
+ getData: GetDataForList<T>;
17
+ }): React.JSX.Element;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ export type OnLogin = {
3
+ login: (username: string, password: string) => Promise<LoginResponse>;
4
+ };
5
+ interface LoginResponse {
6
+ user: any;
7
+ token: string;
8
+ }
9
+ interface LoginProps {
10
+ onLogin: OnLogin;
11
+ }
12
+ export declare function Login({ onLogin }: LoginProps): React.JSX.Element;
13
+ export {};
@@ -0,0 +1,6 @@
1
+ import "reflect-metadata";
2
+ import { AnyClass } from "../../types/AnyClass";
3
+ export interface FormConfiguration {
4
+ }
5
+ export declare function FormDecorator(options?: FormConfiguration): ClassDecorator;
6
+ export declare function getFormConfiguration(entityClass: AnyClass): FormConfiguration | undefined;
@@ -0,0 +1,7 @@
1
+ import { FormConfiguration } from "./Form";
2
+ import { InputOptions } from "./Input";
3
+ export interface FormOptions {
4
+ resolver: any;
5
+ form?: FormConfiguration;
6
+ inputs?: InputOptions[];
7
+ }
@@ -0,0 +1,13 @@
1
+ import 'reflect-metadata';
2
+ import { AnyClass } from '../../types/AnyClass';
3
+ export interface InputOptions {
4
+ name?: string;
5
+ label?: string;
6
+ placeholder?: string;
7
+ inputType?: 'text' | 'email' | 'tel' | 'password' | 'number' | 'date';
8
+ type?: 'input' | 'select' | 'textarea' | 'file-upload' | 'checkbox' | 'hidden';
9
+ selectOptions?: string[];
10
+ cancelPasswordValidationOnEdit?: boolean;
11
+ }
12
+ export declare function Input(options?: InputOptions): PropertyDecorator;
13
+ export declare function getInputFields<T extends AnyClass>(entityClass: T): InputOptions[];
@@ -0,0 +1,3 @@
1
+ import { AnyClass } from "../../types/AnyClass";
2
+ import { FormOptions } from "./FormOptions";
3
+ export declare function getFormFields<T extends AnyClass>(entityClass: T): FormOptions;
@@ -1,9 +1,9 @@
1
1
  import "reflect-metadata";
2
+ export declare const CELL_KEY: unique symbol;
2
3
  export interface CellOptions {
3
4
  name?: string;
4
5
  title?: string;
5
- type?: "string" | "number" | "date";
6
+ type?: "string" | "date" | "image";
6
7
  placeHolder?: string;
7
8
  }
8
9
  export declare function Cell(options?: CellOptions): PropertyDecorator;
9
- export declare function getCellFields(entityClass: any): CellOptions[];
@@ -0,0 +1,2 @@
1
+ import { CellOptions } from "./Cell";
2
+ export declare function getCellFields(entityClass: any): CellOptions[];
@@ -0,0 +1,6 @@
1
+ import "reflect-metadata";
2
+ import { CellOptions } from "./Cell";
3
+ export interface ImageCellOptions extends CellOptions {
4
+ baseUrl: string;
5
+ }
6
+ export declare function ImageCell(options?: ImageCellOptions): PropertyDecorator;
@@ -0,0 +1,5 @@
1
+ import "reflect-metadata";
2
+ export interface ListOptions {
3
+ }
4
+ export declare function List(options?: ListOptions): ClassDecorator;
5
+ export declare function getClassListData(entityClass: any): ListOptions | undefined;
@@ -0,0 +1,6 @@
1
+ import { ListOptions } from "./List";
2
+ import { CellOptions } from "./Cell";
3
+ export interface ListData {
4
+ list?: ListOptions;
5
+ cells: CellOptions[];
6
+ }
@@ -0,0 +1,2 @@
1
+ import { ListData } from "./ListData";
2
+ export declare function getListFields<T>(entityClass: T): ListData;
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("react"),e=require("react-hook-form"),r=require("zustand/middleware"),n=require("zustand/traditional"),o=require("zustand/vanilla/shallow"),a=require("react-router");function i({htmlFor:e,label:r,fieldName:n}){return t.createElement("label",{htmlFor:e},r??n.charAt(0).toUpperCase()+n.slice(1))}function s({input:e,register:r,isEditForm:n,error:o}){const a=e.name||"";return t.createElement("div",{className:"form-field"},t.createElement(i,{htmlFor:a,label:e.label,fieldName:a}),(()=>{switch(e.type){case"textarea":return t.createElement("textarea",{...r(a),placeholder:e.placeholder,id:a,disabled:n&&!1===e.editable});case"select":return t.createElement("select",{...r(a),id:a,disabled:n&&!1===e.editable},t.createElement("option",{value:""},"Select ",a),e.selectOptions?.map((e=>t.createElement("option",{key:e,value:e},e))));default:return t.createElement("input",{type:e.inputType,...r(a),placeholder:e.placeholder,id:a,disabled:n&&!1===e.editable})}})(),o&&t.createElement("span",{className:"error-message"},o.message))}const c=(t,e,r)=>fetch(`${t.baseUrl}/auth/login`,{method:"POST",body:JSON.stringify({username:e,password:r}),headers:{"Content-Type":"application/json"}}).then((t=>{if(t.ok)return t.json();throw t})),u=n.createWithEqualityFn()(r.persist((t=>({screens:null,user:null,fetchSettings:null,screenPaths:{},token:null})),{name:"app-store-1",storage:r.createJSONStorage((()=>localStorage)),partialize:t=>({user:t.user,token:t.token})}),o.shallow);function l(t){u.setState({screens:t})}const p=(t,e)=>fetch(`${t.baseUrl}/${e}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.token}`}}).then((t=>{if(t.ok)return t.json();throw t})),f=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then((t=>t.json())),d=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}/${r}`,{method:"GET",headers:{"Content-Type":"application/json"}}).then((t=>t.json())),h=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}/${r.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then((t=>t.json()));function y({data:r,screen:n}){const{screens:o,fetchSettings:i}=u((t=>({screens:t.screens??{},fetchSettings:t.fetchSettings})));console.log("form started");const c=!!r,{register:l,handleSubmit:p,reset:d,formState:{errors:y}}=e.useForm({resolver:o[n.controller].resolver,defaultValues:{...r,__formEdit:c}}),v=a.useNavigate(),m=o[n.controller].inputs;return t.useEffect((()=>{d({...r,__formEdit:c})}),[c,r,d]),t.createElement("div",{className:"form-wrapper"},t.createElement("form",{onSubmit:p((t=>{console.log("fetch started"),i?(delete t.__formEdit,c?(console.log("CrudApi.edit called"),h(i,n.controller,t).then((()=>{v("/"+n.controller,{replace:!0})}))):(console.log("CrudApi.create called"),f(i,n.controller,t).then((()=>{v("/"+n.controller,{replace:!0})})))):console.log("cancelled due to fetchSettings null")}),((t,e)=>{console.log("error creating creation",t,e)}))},m.map((e=>t.createElement(s,{key:e.name||"",input:e,register:l,isEditForm:c,error:y[e.name||""]}))),t.createElement("button",{type:"submit",className:"submit-button"},"Submit")))}function v({screen:e}){return t.createElement(y,{screen:e})}function m({error:e}){return t.createElement("div",{className:"error-container"},t.createElement("div",{className:"error-icon"},t.createElement("i",{className:"fa fa-exclamation-circle"})),t.createElement("div",{className:"error-content"},t.createElement("h3",null,"Error Occurred"),t.createElement("p",null,(t=>{if(t instanceof Response)switch(t.status){case 400:return"Bad Request: The request was invalid or malformed.";case 401:return"Unauthorized: Please log in to access this resource.";case 404:return"Not Found: The requested resource could not be found.";case 403:return"Forbidden: You don't have permission to access this resource.";case 500:return"Internal Server Error: Something went wrong on our end.";default:return`Error ${t.status}: ${t.statusText||"Something went wrong."}`}return t?.message||"Something went wrong. Please try again later."})(e))))}function g({screen:e}){const{fetchSettings:r}=u((t=>({fetchSettings:t.fetchSettings}))),{id:n}=a.useParams(),[o,i]=t.useState(null),[s,c]=t.useState(null);return t.useEffect((()=>{r&&e.controller&&n&&d(r,e.controller,n).then((t=>{i(t)})).catch((t=>{c(t),console.error(t)}))}),[r,n,e]),s?t.createElement(m,{error:s}):t.createElement("p",{dangerouslySetInnerHTML:{__html:JSON.stringify(o,null," <br/>")}})}function S({screen:e}){const{fetchSettings:r}=u((t=>({fetchSettings:t.fetchSettings}))),{id:n}=a.useParams(),[o,i]=t.useState(null),[s,c]=t.useState(null);return t.useEffect((()=>{r&&e.controller&&n&&d(r,e.controller,n).then((t=>{i(t)})).catch((t=>{c(t),console.error(t)}))}),[r,n,e]),s?t.createElement(m,{error:s}):t.createElement(y,{data:o,screen:e})}function _({data:e,cells:r}){return e&&0!==e.length?t.createElement("div",{className:"list-wrapper"},t.createElement("div",{className:"header"},"List"),t.createElement("table",{className:"list-table"},t.createElement("thead",null,t.createElement("tr",null,r.map((e=>t.createElement("th",{key:e.name},e.title??e.name))),t.createElement("th",null))),t.createElement("tbody",null,e.map(((e,n)=>t.createElement("tr",{key:n},r.map((r=>{const n=e[r.name];let o=n??"-";if("date"===r.type){if(n){const t=new Date(n);o=`${t.getDate().toString().padStart(2,"0")}/${(t.getMonth()+1).toString().padStart(2,"0")}/${t.getFullYear()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}}else o=n?n.toString():r?.placeHolder??"-";let a=o;return t.createElement("td",{key:r.name},a)})),t.createElement("td",null,t.createElement(a.Link,{to:"edit/"+(e?.id??"-")},"Edit"),t.createElement(a.Link,{to:"details/"+(e?.id??"-")},"Details")))))))):t.createElement("div",null,"No items available")}function E({screen:e}){const{screens:r,fetchSettings:n,token:o}=u((t=>({screens:t.screens??{},fetchSettings:t.fetchSettings,token:t.token}))),[i,s]=t.useState(0),[c,l]=t.useState(null),[f,d]=t.useState(null);return t.useEffect((()=>{e.controller&&n&&o&&p({...n,token:o},e.controller).then((t=>{l(t)})).catch((t=>{d(t),console.error(t)}))}),[i,e.controller,n]),f?t.createElement(m,{error:f}):t.createElement("div",null,t.createElement(a.Link,{to:"create"},"Create"),t.createElement(_,{screen:e,cells:r[e.key].cells,data:c}))}var O,w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},b={};!function(){return O||(O=1,function(t){!function(){var e="object"==typeof globalThis?globalThis:"object"==typeof w?w:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(t){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(t){}}(),r=n(t);function n(t,e){return function(r,n){Object.defineProperty(t,r,{configurable:!0,writable:!0,value:n}),e&&e(r,n)}}void 0!==e.Reflect&&(r=n(e.Reflect,r)),function(t,e){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,o=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",a=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",i="function"==typeof Object.create,s={__proto__:[]}instanceof Array,c=!i&&!s,u={create:i?function(){return pt(Object.create(null))}:s?function(){return pt({__proto__:null})}:function(){return pt({})},has:c?function(t,e){return r.call(t,e)}:function(t,e){return e in t},get:c?function(t,e){return r.call(t,e)?t[e]:void 0}:function(t,e){return t[e]}},l=Object.getPrototypeOf(Function),p="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ct(),f="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:ut(),d="function"==typeof WeakMap?WeakMap:lt(),h=n?Symbol.for("@reflect-metadata:registry"):void 0,y=ot(),v=at(y);function m(t,e,r,n){if(D(r)){if(!G(t))throw new TypeError;if(!H(e))throw new TypeError;return A(t,e)}if(!G(t))throw new TypeError;if(!$(e))throw new TypeError;if(!$(n)&&!D(n)&&!F(n))throw new TypeError;return F(n)&&(n=void 0),x(t,e,r=q(r),n)}function g(t,e){function r(r,n){if(!$(r))throw new TypeError;if(!D(n)&&!J(n))throw new TypeError;L(t,e,r,n)}return r}function S(t,e,r,n){if(!$(r))throw new TypeError;return D(n)||(n=q(n)),L(t,e,r,n)}function _(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=q(r)),N(t,e,r)}function E(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=q(r)),C(t,e,r)}function O(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=q(r)),k(t,e,r)}function w(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=q(r)),P(t,e,r)}function b(t,e){if(!$(t))throw new TypeError;return D(e)||(e=q(e)),I(t,e)}function T(t,e){if(!$(t))throw new TypeError;return D(e)||(e=q(e)),j(t,e)}function M(t,e,r){if(!$(e))throw new TypeError;if(D(r)||(r=q(r)),!$(e))throw new TypeError;D(r)||(r=q(r));var n=st(e,r,!1);return!D(n)&&n.OrdinaryDeleteMetadata(t,e,r)}function A(t,e){for(var r=t.length-1;r>=0;--r){var n=(0,t[r])(e);if(!D(n)&&!F(n)){if(!H(n))throw new TypeError;e=n}}return e}function x(t,e,r,n){for(var o=t.length-1;o>=0;--o){var a=(0,t[o])(e,r,n);if(!D(a)&&!F(a)){if(!$(a))throw new TypeError;n=a}}return n}function N(t,e,r){if(C(t,e,r))return!0;var n=rt(e);return!F(n)&&N(t,n,r)}function C(t,e,r){var n=st(e,r,!1);return!D(n)&&B(n.OrdinaryHasOwnMetadata(t,e,r))}function k(t,e,r){if(C(t,e,r))return P(t,e,r);var n=rt(e);return F(n)?void 0:k(t,n,r)}function P(t,e,r){var n=st(e,r,!1);if(!D(n))return n.OrdinaryGetOwnMetadata(t,e,r)}function L(t,e,r,n){st(r,n,!0).OrdinaryDefineOwnMetadata(t,e,r,n)}function I(t,e){var r=j(t,e),n=rt(t);if(null===n)return r;var o=I(n,e);if(o.length<=0)return r;if(r.length<=0)return o;for(var a=new f,i=[],s=0,c=r;s<c.length;s++){var u=c[s];a.has(u)||(a.add(u),i.push(u))}for(var l=0,p=o;l<p.length;l++){u=p[l];a.has(u)||(a.add(u),i.push(u))}return i}function j(t,e){var r=st(t,e,!1);return r?r.OrdinaryOwnMetadataKeys(t,e):[]}function V(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}function D(t){return void 0===t}function F(t){return null===t}function R(t){return"symbol"==typeof t}function $(t){return"object"==typeof t?null!==t:"function"==typeof t}function U(t,e){switch(V(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var r="string",n=Q(t,o);if(void 0!==n){var a=n.call(t,r);if($(a))throw new TypeError;return a}return z(t)}function z(t,e){var r,n,o=t.toString;if(W(o)&&!$(n=o.call(t)))return n;if(W(r=t.valueOf)&&!$(n=r.call(t)))return n;throw new TypeError}function B(t){return!!t}function K(t){return""+t}function q(t){var e=U(t);return R(e)?e:K(e)}function G(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function W(t){return"function"==typeof t}function H(t){return"function"==typeof t}function J(t){switch(V(t)){case 3:case 4:return!0;default:return!1}}function Y(t,e){return t===e||t!=t&&e!=e}function Q(t,e){var r=t[e];if(null!=r){if(!W(r))throw new TypeError;return r}}function X(t){var e=Q(t,a);if(!W(e))throw new TypeError;var r=e.call(t);if(!$(r))throw new TypeError;return r}function Z(t){return t.value}function tt(t){var e=t.next();return!e.done&&e}function et(t){var e=t.return;e&&e.call(t)}function rt(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===l)return e;if(e!==l)return e;var r=t.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return e;var o=n.constructor;return"function"!=typeof o||o===t?e:o}function nt(){var t,r,n,o;D(h)||void 0===e.Reflect||h in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=it(e.Reflect));var a=new d,i={registerProvider:s,getProvider:u,setProvider:y};return i;function s(e){if(!Object.isExtensible(i))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case t===e:break;case D(r):r=e;break;case r===e:break;case D(n):n=e;break;case n===e:break;default:void 0===o&&(o=new f),o.add(e)}}function c(e,a){if(!D(r)){if(r.isProviderFor(e,a))return r;if(!D(n)){if(n.isProviderFor(e,a))return r;if(!D(o))for(var i=X(o);;){var s=tt(i);if(!s)return;var c=Z(s);if(c.isProviderFor(e,a))return et(i),c}}}if(!D(t)&&t.isProviderFor(e,a))return t}function u(t,e){var r,n=a.get(t);return D(n)||(r=n.get(e)),D(r)?(D(r=c(t,e))||(D(n)&&(n=new p,a.set(t,n)),n.set(e,r)),r):r}function l(t){if(D(t))throw new TypeError;return r===t||n===t||!D(o)&&o.has(t)}function y(t,e,r){if(!l(r))throw new Error("Metadata provider not registered.");var n=u(t,e);if(n!==r){if(!D(n))return!1;var o=a.get(t);D(o)&&(o=new p,a.set(t,o)),o.set(e,r)}return!0}}function ot(){var t;return!D(h)&&$(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[h]),D(t)&&(t=nt()),!D(h)&&$(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}function at(t){var e=new d,r={isProviderFor:function(t,r){var n=e.get(t);return!D(n)&&n.has(r)},OrdinaryDefineOwnMetadata:i,OrdinaryHasOwnMetadata:o,OrdinaryGetOwnMetadata:a,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return y.registerProvider(r),r;function n(n,o,a){var i=e.get(n),s=!1;if(D(i)){if(!a)return;i=new p,e.set(n,i),s=!0}var c=i.get(o);if(D(c)){if(!a)return;if(c=new p,i.set(o,c),!t.setProvider(n,o,r))throw i.delete(o),s&&e.delete(n),new Error("Wrong provider for target.")}return c}function o(t,e,r){var o=n(e,r,!1);return!D(o)&&B(o.has(t))}function a(t,e,r){var o=n(e,r,!1);if(!D(o))return o.get(t)}function i(t,e,r,o){n(r,o,!0).set(t,e)}function s(t,e){var r=[],o=n(t,e,!1);if(D(o))return r;for(var a=X(o.keys()),i=0;;){var s=tt(a);if(!s)return r.length=i,r;var c=Z(s);try{r[i]=c}catch(t){try{et(a)}finally{throw t}}i++}}function c(t,r,o){var a=n(r,o,!1);if(D(a))return!1;if(!a.delete(t))return!1;if(0===a.size){var i=e.get(r);D(i)||(i.delete(o),0===i.size&&e.delete(i))}return!0}}function it(t){var e=t.defineMetadata,r=t.hasOwnMetadata,n=t.getOwnMetadata,o=t.getOwnMetadataKeys,a=t.deleteMetadata,i=new d;return{isProviderFor:function(t,e){var r=i.get(t);return!(D(r)||!r.has(e))||!!o(t,e).length&&(D(r)&&(r=new f,i.set(t,r)),r.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:o,OrdinaryDeleteMetadata:a}}function st(t,e,r){var n=y.getProvider(t,e);if(!D(n))return n;if(r){if(y.setProvider(t,e,v))return v;throw new Error("Illegal state.")}}function ct(){var t={},e=[],r=function(){function t(t,e,r){this._index=0,this._keys=t,this._values=e,this._selector=r}return t.prototype["@@iterator"]=function(){return this},t.prototype[a]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var r=this._selector(this._keys[t],this._values[t]);return t+1>=this._keys.length?(this._index=-1,this._keys=e,this._values=e):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},t.prototype.throw=function(t){throw this._index>=0&&(this._index=-1,this._keys=e,this._values=e),t},t.prototype.return=function(t){return this._index>=0&&(this._index=-1,this._keys=e,this._values=e),{value:t,done:!0}},t}(),n=function(){function e(){this._keys=[],this._values=[],this._cacheKey=t,this._cacheIndex=-2}return Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this._find(t,!1)>=0},e.prototype.get=function(t){var e=this._find(t,!1);return e>=0?this._values[e]:void 0},e.prototype.set=function(t,e){var r=this._find(t,!0);return this._values[r]=e,this},e.prototype.delete=function(e){var r=this._find(e,!1);if(r>=0){for(var n=this._keys.length,o=r+1;o<n;o++)this._keys[o-1]=this._keys[o],this._values[o-1]=this._values[o];return this._keys.length--,this._values.length--,Y(e,this._cacheKey)&&(this._cacheKey=t,this._cacheIndex=-2),!0}return!1},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=t,this._cacheIndex=-2},e.prototype.keys=function(){return new r(this._keys,this._values,o)},e.prototype.values=function(){return new r(this._keys,this._values,i)},e.prototype.entries=function(){return new r(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[a]=function(){return this.entries()},e.prototype._find=function(t,e){if(!Y(this._cacheKey,t)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(Y(this._keys[r],t)){this._cacheIndex=r;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();return n;function o(t,e){return t}function i(t,e){return e}function s(t,e){return[t,e]}}function ut(){return function(){function t(){this._map=new p}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(t){return this._map.has(t)},t.prototype.add=function(t){return this._map.set(t,t),this},t.prototype.delete=function(t){return this._map.delete(t)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.keys()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[a]=function(){return this.keys()},t}()}function lt(){var t=16,e=u.create(),n=o();return function(){function t(){this._key=o()}return t.prototype.has=function(t){var e=a(t,!1);return void 0!==e&&u.has(e,this._key)},t.prototype.get=function(t){var e=a(t,!1);return void 0!==e?u.get(e,this._key):void 0},t.prototype.set=function(t,e){return a(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=a(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=o()},t}();function o(){var t;do{t="@@WeakMap@@"+c()}while(u.has(e,t));return e[t]=!0,t}function a(t,e){if(!r.call(t,n)){if(!e)return;Object.defineProperty(t,n,{value:u.create()})}return t[n]}function i(t,e){for(var r=0;r<e;++r)t[r]=255*Math.random()|0;return t}function s(t){if("function"==typeof Uint8Array){var e=new Uint8Array(t);return"undefined"!=typeof crypto?crypto.getRandomValues(e):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(e):i(e,t),e}return i(new Array(t),t)}function c(){var e=s(t);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var r="",n=0;n<t;++n){var o=e[n];4!==n&&6!==n&&8!==n||(r+="-"),o<16&&(r+="0"),r+=o.toString(16).toLowerCase()}return r}}function pt(t){return t.__=void 0,delete t.__,t}t("decorate",m),t("metadata",g),t("defineMetadata",S),t("hasMetadata",_),t("hasOwnMetadata",E),t("getMetadata",O),t("getOwnMetadata",w),t("getMetadataKeys",b),t("getOwnMetadataKeys",T),t("deleteMetadata",M)}(r,e),void 0===e.Reflect&&(e.Reflect=t)}()}(t||(t={}))),b;var t}();const T="Crud";const M=Symbol("cell");function A(t){const e=t.prototype;return(Reflect.getMetadata(M,e)||[]).map((t=>{const r=Reflect.getMetadata(`${M.toString()}:${t}:options`,e)||{};return{...r,name:r?.name??t}}))}const x=Symbol("input");function N(t){const e=t.prototype;return(Reflect.getMetadata(x,e)||[]).map((t=>{const r=Reflect.getMetadata(`${x.toString()}:${t}:options`,e)||{},n=r?.inputType??(o=t,["password"].some((t=>o.toLowerCase().includes(t)))?"password":"text");var o;return{...r,editable:r.editable??!0,sensitive:r.sensitive,name:r?.name??t,label:r?.label??t,placeholder:r?.placeholder??t,inputType:n,selectOptions:r?.selectOptions??[],cancelPasswordValidationOnEdit:r?.cancelPasswordValidationOnEdit??"password"===n}}))}function C({menu:e,getIcons:r}){const n=u((t=>t.screens??{})),[o,i]=t.useState(!0);return t.createElement("div",{className:"sidebar "+(o?"open":"closed")},t.createElement("button",{className:"toggle-button",onClick:()=>i(!o)},o?"<":">"),t.createElement("nav",{className:"nav-links"},e?.(n).map(((e,n)=>t.createElement(a.Link,{key:n,to:e.path,className:"nav-link"},t.createElement("span",{className:"nav-links-icon"},r?.(e.iconType)),o?t.createElement("span",null,e.name):null)))))}class k extends t.Component{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(t){return{hasError:!0,error:t,errorInfo:null}}componentDidCatch(t,e){this.setState({error:t,errorInfo:e})}render(){return this.state.hasError?t.createElement("div",{className:"error-boundary"},t.createElement("div",{className:"error-boundary__content"},t.createElement("div",{className:"error-boundary__icon"},t.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},t.createElement("circle",{cx:"12",cy:"12",r:"10"}),t.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),t.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"16"}))),t.createElement("h1",null,"Oops! Something went wrong"),t.createElement("p",{className:"error-boundary__message"},this.state.error?.message||"An unexpected error occurred"),t.createElement("button",{className:"error-boundary__button",onClick:()=>window.location.reload()},"Refresh Page"),"development"===process.env.NODE_ENV&&t.createElement("details",{className:"error-boundary__details"},t.createElement("summary",null,"Error Details"),t.createElement("pre",null,this.state.error?.toString()),t.createElement("pre",null,this.state.errorInfo?.componentStack)))):this.props.children}}var P=function(t){this.groups=[],this.each=!1,this.context=void 0,this.type=t.type,this.name=t.name,this.target=t.target,this.propertyName=t.propertyName,this.constraints=null==t?void 0:t.constraints,this.constraintCls=t.constraintCls,this.validationTypeOptions=t.validationTypeOptions,t.validationOptions&&(this.message=t.validationOptions.message,this.groups=t.validationOptions.groups,this.always=t.validationOptions.always,this.each=t.validationOptions.each,this.context=t.validationOptions.context)},L=function(){function t(){}return t.prototype.transform=function(t){var e=[];return Object.keys(t.properties).forEach((function(r){t.properties[r].forEach((function(n){var o={message:n.message,groups:n.groups,always:n.always,each:n.each},a={type:n.type,name:n.name,target:t.name,propertyName:r,constraints:n.constraints,validationTypeOptions:n.options,validationOptions:o};e.push(new P(a))}))})),e},t}();function I(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function j(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var V=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},D=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},F=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,a=e.length;o<a;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},R=function(){function t(){this.validationMetadatas=new Map,this.constraintMetadatas=new Map}return Object.defineProperty(t.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.size},enumerable:!1,configurable:!0}),t.prototype.addValidationSchema=function(t){var e=this;(new L).transform(t).forEach((function(t){return e.addValidationMetadata(t)}))},t.prototype.addValidationMetadata=function(t){var e=this.validationMetadatas.get(t.target);e?e.push(t):this.validationMetadatas.set(t.target,[t])},t.prototype.addConstraintMetadata=function(t){var e=this.constraintMetadatas.get(t.target);e?e.push(t):this.constraintMetadatas.set(t.target,[t])},t.prototype.groupByPropertyName=function(t){var e={};return t.forEach((function(t){e[t.propertyName]||(e[t.propertyName]=[]),e[t.propertyName].push(t)})),e},t.prototype.getTargetValidationMetadatas=function(t,e,r,n,o){var a,i,s=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&r},c=function(t){return!(!n||o&&o.length||!t.groups||!t.groups.length)},u=(this.validationMetadatas.get(t)||[]).filter((function(r){return(r.target===t||r.target===e)&&(!!s(r)||!c(r)&&(!(o&&o.length>0)||r.groups&&!!r.groups.find((function(t){return-1!==o.indexOf(t)}))))})),l=[];try{for(var p=V(this.validationMetadatas.entries()),f=p.next();!f.done;f=p.next()){var d=D(f.value,2),h=d[0],y=d[1];t.prototype instanceof h&&l.push.apply(l,F([],D(y),!1))}}catch(t){a={error:t}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(a)throw a.error}}var v=l.filter((function(e){return"string"!=typeof e.target&&(e.target!==t&&((!(e.target instanceof Function)||t.prototype instanceof e.target)&&(!!s(e)||!c(e)&&(!(o&&o.length>0)||e.groups&&!!e.groups.find((function(t){return-1!==o.indexOf(t)}))))))})).filter((function(t){return!u.find((function(e){return e.propertyName===t.propertyName&&e.type===t.type}))}));return u.concat(v)},t.prototype.getTargetValidatorConstraints=function(t){return this.constraintMetadatas.get(t)||[]},t}();function $(){var t=I();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new R),t.classValidatorMetadataStorage}var U=function(){function t(){}return t.prototype.toString=function(t,e,r,n){var o=this;void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===r&&(r=""),void 0===n&&(n=!1);var a=t?"":"",i=t?"":"",s=function(t){return" - property ".concat(a).concat(r).concat(t).concat(i," has failed the following constraints: ").concat(a).concat((n?Object.values:Object.keys)(null!==(e=o.constraints)&&void 0!==e?e:{}).join(", ")).concat(i," \n");var e};if(e){var c=Number.isInteger(+this.property)?"[".concat(this.property,"]"):"".concat(r?".":"").concat(this.property);return this.constraints?s(c):this.children?this.children.map((function(e){return e.toString(t,!0,"".concat(r).concat(c),n)})).join(""):""}return"An instance of ".concat(a).concat(this.target?this.target.constructor.name:"an object").concat(i," has failed the validation:\n")+(this.constraints?s(this.property):"")+(this.children?this.children.map((function(e){return e.toString(t,!0,o.property,n)})).join(""):"")},t}(),z=function(){function t(){}return t.isValid=function(t){var e=this;return"isValid"!==t&&"getMessage"!==t&&-1!==Object.keys(this).map((function(t){return e[t]})).indexOf(t)},t.CUSTOM_VALIDATION="customValidation",t.NESTED_VALIDATION="nestedValidation",t.PROMISE_VALIDATION="promiseValidation",t.CONDITIONAL_VALIDATION="conditionalValidation",t.WHITELIST="whitelistValidation",t.IS_DEFINED="isDefined",t}();var B=function(){function t(){}return t.replaceMessageSpecialTokens=function(t,e){var r;return t instanceof Function?r=t(e):"string"==typeof t&&(r=t),r&&Array.isArray(e.constraints)&&e.constraints.forEach((function(t,e){r=r.replace(new RegExp("\\$constraint".concat(e+1),"g"),function(t){return Array.isArray(t)?t.join(", "):("symbol"==typeof t&&(t=t.description),"".concat(t))}(t))})),r&&void 0!==e.value&&null!==e.value&&["string","boolean","number"].includes(typeof e.value)&&(r=r.replace(/\$value/g,e.value)),r&&(r=r.replace(/\$property/g,e.property)),r&&(r=r.replace(/\$target/g,e.targetName)),r},t}(),K=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},q=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=$()}return t.prototype.execute=function(t,e,r){var n,o,a=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(n=this.validatorOptions)||void 0===n?void 0:n.enableDebugMessages)||console.warn("No validation metadata found. No validation will be performed. There are multiple possible reasons:\n - There may be multiple class-validator versions installed. You will need to flatten your dependencies to fix the issue.\n - This validation runs before any file with validation decorator was parsed by NodeJS.");var i=this.validatorOptions?this.validatorOptions.groups:void 0,s=this.validatorOptions&&this.validatorOptions.strictGroups||!1,c=this.validatorOptions&&this.validatorOptions.always||!1,u=void 0===(null===(o=this.validatorOptions)||void 0===o?void 0:o.forbidUnknownValues)||!1!==this.validatorOptions.forbidUnknownValues,l=this.metadataStorage.getTargetValidationMetadatas(t.constructor,e,c,s,i),p=this.metadataStorage.groupByPropertyName(l);if(this.validatorOptions&&u&&!l.length){var f=new U;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(f.target=t),f.value=void 0,f.property=void 0,f.children=[],f.constraints={unknownValue:"an unknown value was passed to the validate function"},void r.push(f)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(t,p,r),Object.keys(p).forEach((function(e){var n=t[e],o=p[e].filter((function(t){return t.type===z.IS_DEFINED})),i=p[e].filter((function(t){return t.type!==z.IS_DEFINED&&t.type!==z.WHITELIST}));n instanceof Promise&&i.find((function(t){return t.type===z.PROMISE_VALIDATION}))?a.awaitingPromises.push(n.then((function(n){a.performValidations(t,n,e,o,i,r)}))):a.performValidations(t,n,e,o,i,r)}))},t.prototype.whitelist=function(t,e,r){var n=this,o=[];Object.keys(t).forEach((function(t){e[t]&&0!==e[t].length||o.push(t)})),o.length>0&&(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?o.forEach((function(e){var o,a=n.generateValidationError(t,t[e],e);a.constraints=((o={})[z.WHITELIST]="property ".concat(e," should not exist"),o),a.children=void 0,r.push(a)})):o.forEach((function(e){return delete t[e]})))},t.prototype.stripEmptyErrors=function(t){var e=this;return t.filter((function(t){if(t.children&&(t.children=e.stripEmptyErrors(t.children)),0===Object.keys(t.constraints).length){if(0===t.children.length)return!1;delete t.constraints}return!0}))},t.prototype.performValidations=function(t,e,r,n,o,a){var i=o.filter((function(t){return t.type===z.CUSTOM_VALIDATION})),s=o.filter((function(t){return t.type===z.NESTED_VALIDATION})),c=o.filter((function(t){return t.type===z.CONDITIONAL_VALIDATION})),u=this.generateValidationError(t,e,r);a.push(u),this.conditionalValidations(t,e,c)&&(this.customValidations(t,e,n,u),this.mapContexts(t,e,n,u),void 0===e&&this.validatorOptions&&!0===this.validatorOptions.skipUndefinedProperties||null===e&&this.validatorOptions&&!0===this.validatorOptions.skipNullProperties||null==e&&this.validatorOptions&&!0===this.validatorOptions.skipMissingProperties||(this.customValidations(t,e,i,u),this.nestedValidations(e,s,u),this.mapContexts(t,e,o,u),this.mapContexts(t,e,i,u)))},t.prototype.generateValidationError=function(t,e,r){var n=new U;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(n.target=t),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(n.value=e),n.property=r,n.children=[],n.constraints={},n},t.prototype.conditionalValidations=function(t,e,r){return r.map((function(r){return r.constraints[0](t,e)})).reduce((function(t,e){return t&&e}),!0)},t.prototype.customValidations=function(t,e,r,n){var o=this;r.forEach((function(r){o.metadataStorage.getTargetValidatorConstraints(r.constraintCls).forEach((function(a){if(!(a.async&&o.ignoreAsyncValidations||o.validatorOptions&&o.validatorOptions.stopAtFirstError&&Object.keys(n.constraints||{}).length>0)){var i={targetName:t.constructor?t.constructor.name:void 0,property:r.propertyName,object:t,value:e,constraints:r.constraints};if(r.each&&(Array.isArray(e)||e instanceof Set||e instanceof Map)){var s,c=((s=e)instanceof Map?Array.from(s.values()):Array.isArray(s)?s:Array.from(s)).map((function(t){return a.instance.validate(t,i)}));if(c.some((function(t){return j(t)}))){var u=c.map((function(t){return j(t)?t:Promise.resolve(t)})),l=Promise.all(u).then((function(i){if(!i.every((function(t){return t}))){var s=K(o.createValidationError(t,e,r,a),2),c=s[0],u=s[1];n.constraints[c]=u,r.context&&(n.contexts||(n.contexts={}),n.contexts[c]=Object.assign(n.contexts[c]||{},r.context))}}));o.awaitingPromises.push(l)}else{if(!c.every((function(t){return t}))){var p=K(o.createValidationError(t,e,r,a),2);y=p[0],v=p[1];n.constraints[y]=v}}}else{var f=a.instance.validate(e,i);if(j(f)){var d=f.then((function(i){if(!i){var s=K(o.createValidationError(t,e,r,a),2),c=s[0],u=s[1];n.constraints[c]=u,r.context&&(n.contexts||(n.contexts={}),n.contexts[c]=Object.assign(n.contexts[c]||{},r.context))}}));o.awaitingPromises.push(d)}else if(!f){var h=K(o.createValidationError(t,e,r,a),2),y=h[0],v=h[1];n.constraints[y]=v}}}}))}))},t.prototype.nestedValidations=function(t,e,r){var n=this;void 0!==t&&e.forEach((function(o){if((o.type===z.NESTED_VALIDATION||o.type===z.PROMISE_VALIDATION)&&!(n.validatorOptions&&n.validatorOptions.stopAtFirstError&&Object.keys(r.constraints||{}).length>0))if(Array.isArray(t)||t instanceof Set||t instanceof Map)(t instanceof Set?Array.from(t):t).forEach((function(o,a){n.performValidations(t,o,a.toString(),[],e,r.children)}));else if(t instanceof Object){var a="string"==typeof o.target?o.target:o.target.name;n.execute(t,a,r.children)}else{var i=K(n.createValidationError(o.target,t,o),2),s=i[0],c=i[1];r.constraints[s]=c}}))},t.prototype.mapContexts=function(t,e,r,n){var o=this;return r.forEach((function(t){if(t.context){var e=void 0;if(t.type===z.CUSTOM_VALIDATION)e=o.metadataStorage.getTargetValidatorConstraints(t.constraintCls)[0];var r=o.getConstraintType(t,e);n.constraints[r]&&(n.contexts||(n.contexts={}),n.contexts[r]=Object.assign(n.contexts[r]||{},t.context))}}))},t.prototype.createValidationError=function(t,e,r,n){var o=t.constructor?t.constructor.name:void 0,a=this.getConstraintType(r,n),i={targetName:o,property:r.propertyName,object:t,value:e,constraints:r.constraints},s=r.message||"";return r.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||n&&n.instance.defaultMessage instanceof Function&&(s=n.instance.defaultMessage(i)),[a,B.replaceMessageSpecialTokens(s,i)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),G=function(t,e,r,n){return new(r||(r=Promise))((function(o,a){function i(t){try{c(n.next(t))}catch(t){a(t)}}function s(t){try{c(n.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,s)}c((n=n.apply(t,e||[])).next())}))},W=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},H=function(){function t(){}return t.prototype.validate=function(t,e,r){return this.coreValidate(t,e,r)},t.prototype.validateOrReject=function(t,e,r){return G(this,void 0,void 0,(function(){var n;return W(this,(function(o){switch(o.label){case 0:return[4,this.coreValidate(t,e,r)];case 1:return(n=o.sent()).length?[2,Promise.reject(n)]:[2]}}))}))},t.prototype.validateSync=function(t,e,r){var n="string"==typeof t?e:t,o="string"==typeof t?t:void 0,a=new q(this,"string"==typeof t?r:e);a.ignoreAsyncValidations=!0;var i=[];return a.execute(n,o,i),a.stripEmptyErrors(i)},t.prototype.coreValidate=function(t,e,r){var n="string"==typeof t?e:t,o="string"==typeof t?t:void 0,a=new q(this,"string"==typeof t?r:e),i=[];return a.execute(n,o,i),Promise.all(a.awaitingPromises).then((function(){return a.stripEmptyErrors(i)}))},t}(),J=new(function(){function t(){this.instances=[]}return t.prototype.get=function(t){var e=this.instances.find((function(e){return e.type===t}));return e||(e={type:t,object:new t},this.instances.push(e)),e.object},t}());function Y(t){return J.get(t)}function Q(t,e,r){return"string"==typeof t?Y(H).validate(t,e,r):Y(H).validate(t,e)}function X(t,e,r){return"string"==typeof t?Y(H).validateSync(t,e,r):Y(H).validateSync(t,e)}const Z=(t,r,n)=>{if(t&&"reportValidity"in t){const o=e.get(n,r);t.setCustomValidity(o&&o.message||""),t.reportValidity()}},tt=(t,e)=>{for(const r in e.fields){const n=e.fields[r];n&&n.ref&&"reportValidity"in n.ref?Z(n.ref,r,t):n&&n.refs&&n.refs.forEach((e=>Z(e,r,t)))}},et=(t,r)=>{r.shouldUseNativeValidation&&tt(t,r);const n={};for(const o in t){const a=e.get(r.fields,o),i=Object.assign(t[o]||{},{ref:a&&a.ref});if(rt(r.names||Object.keys(t),o)){const t=Object.assign({},e.get(n,o));e.set(t,"root",i),e.set(n,o,t)}else e.set(n,o,i)}return n},rt=(t,e)=>{const r=nt(e);return t.some((t=>nt(t).match(`^${r}\\.\\d+`)))};function nt(t){return t.replace(/\]|\[/g,"")}var ot;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(ot||(ot={}));var at=new(function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,r){return this.findMetadatas(this._transformMetadatas,t,e).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?r===ot.CLASS_TO_CLASS||r===ot.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||r===ot.CLASS_TO_PLAIN))}))},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find((function(t){return t.options&&t.options.name===e}))},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),r=e&&e.get(void 0),n=this._exposeMetadatas.get(t),o=n&&n.get(void 0);return r&&o||!r&&!o?"none":r?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===ot.CLASS_TO_CLASS||e===ot.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===ot.CLASS_TO_PLAIN))})).map((function(t){return t.propertyName}))},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===ot.CLASS_TO_CLASS||e===ot.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===ot.CLASS_TO_PLAIN))})).map((function(t){return t.propertyName}))},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var r,n=t.get(e);n&&(r=Array.from(n.values()).filter((function(t){return void 0!==t.propertyName})));for(var o=[],a=0,i=this.getAncestors(e);a<i.length;a++){var s=i[a],c=t.get(s);if(c){var u=Array.from(c.values()).filter((function(t){return void 0!==t.propertyName}));o.push.apply(o,u)}}return o.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var n=t.get(e);if(n){var o=n.get(r);if(o)return o}for(var a=0,i=this.getAncestors(e);a<i.length;a++){var s=i[a],c=t.get(s);if(c){var u=c.get(r);if(u)return u}}},t.prototype.findMetadatas=function(t,e,r){var n,o=t.get(e);o&&(n=o.get(r));for(var a=[],i=0,s=this.getAncestors(e);i<s.length;i++){var c=s[i],u=t.get(c);u&&u.has(r)&&a.push.apply(a,u.get(r))}return a.slice().reverse().concat((n||[]).slice().reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],r=Object.getPrototypeOf(t.prototype.constructor);void 0!==r.prototype;r=Object.getPrototypeOf(r.prototype.constructor))e.push(r);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}());var it=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,a=e.length;o<a;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};var st=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,r,n,o,a){var i,s=this;if(void 0===a&&(a=0),Array.isArray(e)||e instanceof Set){var c=n&&this.transformationType===ot.PLAIN_TO_CLASS?function(t){var e=new t;return e instanceof Set||"push"in e?e:[]}(n):[];return e.forEach((function(e,n){var o=t?t[n]:void 0;if(s.options.enableCircularCheck&&s.isCircular(e))s.transformationType===ot.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var i=void 0;if("function"!=typeof r&&r&&r.options&&r.options.discriminator&&r.options.discriminator.property&&r.options.discriminator.subTypes){if(s.transformationType===ot.PLAIN_TO_CLASS){i=r.options.discriminator.subTypes.find((function(t){return t.name===e[r.options.discriminator.property]}));var u={newObject:c,object:e,property:void 0},l=r.typeFunction(u);i=void 0===i?l:i.value,r.options.keepDiscriminatorProperty||delete e[r.options.discriminator.property]}s.transformationType===ot.CLASS_TO_CLASS&&(i=e.constructor),s.transformationType===ot.CLASS_TO_PLAIN&&(e[r.options.discriminator.property]=r.options.discriminator.subTypes.find((function(t){return t.value===e.constructor})).name)}else i=r;var p=s.transform(o,e,i,void 0,e instanceof Map,a+1);c instanceof Set?c.add(p):c.push(p)}})),c}if(r!==String||o){if(r!==Number||o){if(r!==Boolean||o){if((r===Date||e instanceof Date)&&!o)return e instanceof Date?new Date(e.valueOf()):null==e?e:new Date(e);if(("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0).Buffer&&(r===Buffer||e instanceof Buffer)&&!o)return null==e?e:Buffer.from(e);if(null===(i=e)||"object"!=typeof i||"function"!=typeof i.then||o){if(o||null===e||"object"!=typeof e||"function"!=typeof e.then){if("object"==typeof e&&null!==e){r||e.constructor===Object||(Array.isArray(e)||e.constructor!==Array)&&(r=e.constructor),!r&&t&&(r=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var u=this.getKeys(r,e,o),l=t||{};t||this.transformationType!==ot.PLAIN_TO_CLASS&&this.transformationType!==ot.CLASS_TO_CLASS||(l=o?new Map:r?new r:{});for(var p=function(n){if("__proto__"===n||"constructor"===n)return"continue";var i=n,s=n,c=n;if(!f.options.ignoreDecorators&&r)if(f.transformationType===ot.PLAIN_TO_CLASS)(u=at.findExposeMetadataByCustomName(r,n))&&(c=u.propertyName,s=u.propertyName);else if(f.transformationType===ot.CLASS_TO_PLAIN||f.transformationType===ot.CLASS_TO_CLASS){var u;(u=at.findExposeMetadata(r,n))&&u.options&&u.options.name&&(s=u.options.name)}var p=void 0;p=f.transformationType===ot.PLAIN_TO_CLASS?e[i]:e instanceof Map?e.get(i):e[i]instanceof Function?e[i]():e[i];var d=void 0,h=p instanceof Map;if(r&&o)d=r;else if(r){var y=at.findTypeMetadata(r,c);if(y){var v={newObject:l,object:e,property:c},m=y.typeFunction?y.typeFunction(v):y.reflectedType;y.options&&y.options.discriminator&&y.options.discriminator.property&&y.options.discriminator.subTypes?e[i]instanceof Array?d=y:(f.transformationType===ot.PLAIN_TO_CLASS&&(d=void 0===(d=y.options.discriminator.subTypes.find((function(t){if(p&&p instanceof Object&&y.options.discriminator.property in p)return t.name===p[y.options.discriminator.property]})))?m:d.value,y.options.keepDiscriminatorProperty||p&&p instanceof Object&&y.options.discriminator.property in p&&delete p[y.options.discriminator.property]),f.transformationType===ot.CLASS_TO_CLASS&&(d=p.constructor),f.transformationType===ot.CLASS_TO_PLAIN&&p&&(p[y.options.discriminator.property]=y.options.discriminator.subTypes.find((function(t){return t.value===p.constructor})).name)):d=m,h=h||y.reflectedType===Map}else if(f.options.targetMaps)f.options.targetMaps.filter((function(t){return t.target===r&&!!t.properties[c]})).forEach((function(t){return d=t.properties[c]}));else if(f.options.enableImplicitConversion&&f.transformationType===ot.PLAIN_TO_CLASS){var g=Reflect.getMetadata("design:type",r.prototype,c);g&&(d=g)}}var S=Array.isArray(e[i])?f.getReflectedType(r,c):void 0,_=t?t[i]:void 0;if(l.constructor.prototype){var E=Object.getOwnPropertyDescriptor(l.constructor.prototype,s);if((f.transformationType===ot.PLAIN_TO_CLASS||f.transformationType===ot.CLASS_TO_CLASS)&&(E&&!E.set||l[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(p)){if(f.transformationType===ot.CLASS_TO_CLASS){w=p;(void 0!==(w=f.applyCustomTransformations(w,r,n,e,f.transformationType))||f.options.exposeUnsetFields)&&(l instanceof Map?l.set(s,w):l[s]=w)}}else{var O=f.transformationType===ot.PLAIN_TO_CLASS?s:n,w=void 0;f.transformationType===ot.CLASS_TO_PLAIN?(w=e[O],w=f.applyCustomTransformations(w,r,O,e,f.transformationType),w=e[O]===w?p:w,w=f.transform(_,w,d,S,h,a+1)):void 0===p&&f.options.exposeDefaultValues?w=l[s]:(w=f.transform(_,p,d,S,h,a+1),w=f.applyCustomTransformations(w,r,O,e,f.transformationType)),(void 0!==w||f.options.exposeUnsetFields)&&(l instanceof Map?l.set(s,w):l[s]=w)}},f=this,d=0,h=u;d<h.length;d++){p(h[d])}return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}return e}return e}return new Promise((function(t,n){e.then((function(e){return t(s.transform(void 0,e,r,void 0,void 0,a+1))}),n)}))}return null==e?e:Boolean(e)}return null==e?e:Number(e)}return null==e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,r,n,o){var a=this,i=at.findTransformMetadatas(e,r,this.transformationType);return void 0!==this.options.version&&(i=i.filter((function(t){return!t.options||a.checkVersion(t.options.since,t.options.until)}))),(i=this.options.groups&&this.options.groups.length?i.filter((function(t){return!t.options||a.checkGroups(t.options.groups)})):i.filter((function(t){return!t.options||!t.options.groups||!t.options.groups.length}))).forEach((function(e){t=e.transformFn({value:t,key:r,obj:n,type:o,options:a.options})})),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var r=at.findTypeMetadata(t,e);return r?r.reflectedType:void 0}},t.prototype.getKeys=function(t,e,r){var n=this,o=at.getStrategy(t);"none"===o&&(o=this.options.strategy||"exposeAll");var a=[];if(("exposeAll"===o||r)&&(a=e instanceof Map?Array.from(e.keys()):Object.keys(e)),r)return a;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&t){var i=at.getExposedProperties(t,this.transformationType),s=at.getExcludedProperties(t,this.transformationType);a=it(it([],i,!0),s,!0)}if(!this.options.ignoreDecorators&&t){i=at.getExposedProperties(t,this.transformationType);this.transformationType===ot.PLAIN_TO_CLASS&&(i=i.map((function(e){var r=at.findExposeMetadata(t,e);return r&&r.options&&r.options.name?r.options.name:e}))),a=this.options.excludeExtraneousValues?i:a.concat(i);var c=at.getExcludedProperties(t,this.transformationType);c.length>0&&(a=a.filter((function(t){return!c.includes(t)}))),void 0!==this.options.version&&(a=a.filter((function(e){var r=at.findExposeMetadata(t,e);return!r||!r.options||n.checkVersion(r.options.since,r.options.until)}))),a=this.options.groups&&this.options.groups.length?a.filter((function(e){var r=at.findExposeMetadata(t,e);return!r||!r.options||n.checkGroups(r.options.groups)})):a.filter((function(e){var r=at.findExposeMetadata(t,e);return!(r&&r.options&&r.options.groups&&r.options.groups.length)}))}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(a=a.filter((function(t){return n.options.excludePrefixes.every((function(e){return t.substr(0,e.length)!==e}))}))),a=a.filter((function(t,e,r){return r.indexOf(t)===e}))},t.prototype.checkVersion=function(t,e){var r=!0;return r&&t&&(r=this.options.version>=t),r&&e&&(r=this.options.version<e),r},t.prototype.checkGroups=function(t){return!t||this.options.groups.some((function(e){return t.includes(e)}))},t}(),ct={enableCircularCheck:!1,enableImplicitConversion:!1,excludeExtraneousValues:!1,excludePrefixes:void 0,exposeDefaultValues:!1,exposeUnsetFields:!0,groups:void 0,ignoreDecorators:!1,strategy:void 0,targetMaps:void 0,version:void 0},ut=function(){return ut=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ut.apply(this,arguments)},lt=new(function(){function t(){}return t.prototype.instanceToPlain=function(t,e){return new st(ot.CLASS_TO_PLAIN,ut(ut({},ct),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,r){return new st(ot.CLASS_TO_PLAIN,ut(ut({},ct),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToInstance=function(t,e,r){return new st(ot.PLAIN_TO_CLASS,ut(ut({},ct),r)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,r){return new st(ot.PLAIN_TO_CLASS,ut(ut({},ct),r)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.instanceToInstance=function(t,e){return new st(ot.CLASS_TO_CLASS,ut(ut({},ct),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,r){return new st(ot.CLASS_TO_CLASS,ut(ut({},ct),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.instanceToPlain(t,e))},t.prototype.deserialize=function(t,e,r){var n=JSON.parse(e);return this.plainToInstance(t,n,r)},t.prototype.deserializeArray=function(t,e,r){var n=JSON.parse(e);return this.plainToInstance(t,n,r)},t}());function pt(t,e,r,n){return void 0===r&&(r={}),void 0===n&&(n=""),t.reduce((function(t,r){var o=n?n+"."+r.property:r.property;if(r.constraints){var a=Object.keys(r.constraints)[0];t[o]={type:a,message:r.constraints[a]};var i=t[o];e&&i&&Object.assign(i,{types:r.constraints})}return r.children&&r.children.length&&pt(r.children,e,t,o),t}),r)}function ft(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),function(n,o,a){try{var i=e.validator,s=(c=t,u=n,l=e.transformer,lt.plainToInstance(c,u,l));return Promise.resolve(("sync"===r.mode?X:Q)(s,i)).then((function(t){return t.length?{values:{},errors:et(pt(t,!a.shouldUseNativeValidation&&"all"===a.criteriaMode),a)}:(a.shouldUseNativeValidation&&tt({},a),{values:r.raw?Object.assign({},n):s,errors:{}})}))}catch(t){return Promise.reject(t)}var c,u,l}}function dt(t,e){const r=$().getTargetValidationMetadatas(e,"",!1,!1),n=function(t){return Reflect.getMetadata(T,t)}(e);return{resolver:ft(e),fields:Array.from(new Set(r.map((t=>t.propertyName)))),inputs:N(e),cells:A(e),crud:n,path:"/"+(n?.controller??t)}}exports.Cell=function(t){return(e,r)=>{const n=Reflect.getMetadata(M,e)||[];if(Reflect.defineMetadata(M,[...n,r.toString()],e),t){const n=`${M.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}},exports.Crud=function(t){return e=>{t&&Reflect.defineMetadata(T,t,e)}},exports.Input=function(t){return(e,r)=>{const n=Reflect.getMetadata(x,e)||[];if(Reflect.defineMetadata(x,[...n,r.toString()],e),t){const n=`${x.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}},exports.Layout=function({children:e,menu:r,getIcons:n}){const{user:o,screenPaths:i}=u((t=>({user:t.user,screenPaths:t.screenPaths}))),s=u();console.log("-----\x3e"),console.log(s);const c=a.useNavigate();return o||c(i.login),t.createElement("div",{className:"layout"},t.createElement(C,{menu:r,getIcons:n}),t.createElement("main",{className:"content"},e))},exports.Login=function(){const{register:r,handleSubmit:n,formState:{errors:o}}=e.useForm(),{fetchSettings:i}=u((t=>({fetchSettings:t.fetchSettings}))),l=a.useNavigate();return t.createElement("div",{className:"login-container"},t.createElement("div",{className:"login-panel"},t.createElement("div",{className:"login-header"},t.createElement("h1",null,"Welcome Back"),t.createElement("p",null,"Please sign in to continue")),t.createElement("form",{onSubmit:n((async t=>{c(i,t.username,t.password).then((t=>{const{access_token:e,admin:r}=t;u.setState({user:r,token:e}),l("/")}))})),className:"login-form"},t.createElement(s,{input:{name:"username",label:"Username",inputType:"text",placeholder:"Enter your username"},register:r,isEditForm:!1,error:o.username}),t.createElement(s,{input:{name:"password",label:"Password",inputType:"password",placeholder:"Enter your password"},register:r,isEditForm:!1,error:o.password}),t.createElement("div",{className:"form-actions"},t.createElement("button",{type:"submit",className:"submit-button"},"Sign In")))))},exports.Panel=function({children:e,init:r}){return t.useEffect((()=>{!function({crud:t,fetch:e,screenPaths:r}){const n={};Object.entries(t).forEach((([t,e])=>{n[t]=dt(t,e)})),l(n),u.setState({fetchSettings:{baseUrl:e.baseURL},screenPaths:r})}(r())}),[r]),t.createElement(k,null,e)},exports.createScreens=l,exports.useScreens=function(){const e=u((t=>t.screens??{}));return t.useMemo((()=>t.createElement(t.Fragment,null,Object.entries(e).map((([e,r])=>{const n=r.crud?.controller??e;let o=`${r.path}`;const i={key:e,controller:n};return t.createElement(t.Fragment,{key:"index"},t.createElement(a.Route,{path:o+"/create",element:t.createElement(v,{screen:i})}),t.createElement(a.Route,{path:o+"/details/:id",element:t.createElement(g,{screen:i})}),t.createElement(a.Route,{path:o+"/edit/:id",element:t.createElement(S,{screen:i})}),t.createElement(a.Route,{path:o,element:t.createElement(E,{screen:i})}))})),t.createElement(a.Route,{path:"*",element:t.createElement("div",null,"404 - Not Found")}))),[e])};
1
+ "use strict";var t=require("react"),e=require("react-router"),r=require("react-hook-form"),n=require("zustand/middleware"),o=require("zustand/traditional"),a=require("zustand/vanilla/shallow");function i({data:r,cells:n}){return r&&0!==r.length?t.createElement("div",{className:"datagrid"},t.createElement("table",{className:"datagrid-table"},t.createElement("thead",null,t.createElement("tr",null,n.map((e=>t.createElement("th",{key:e.name},e.title??e.name))),t.createElement("th",null),t.createElement("th",null,"Delete"))),t.createElement("tbody",null,r.map(((r,o)=>t.createElement("tr",{key:o},n.map((e=>{const n=r[e.name];let o=n??"-";switch(e.type){case"date":if(n){const t=new Date(n);o=`${t.getDate().toString().padStart(2,"0")}/${(t.getMonth()+1).toString().padStart(2,"0")}/${t.getFullYear()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}break;case"image":{const r=e;o=t.createElement("img",{width:100,height:100,src:r.baseUrl+n,style:{objectFit:"contain"}});break}default:o=n?n.toString():e?.placeHolder??"-"}return t.createElement("td",{key:e.name},o)})),t.createElement("td",null,t.createElement(e.Link,{to:"edit/"+(r?.id??"-")},"Edit"),t.createElement(e.Link,{to:"details/"+(r?.id??"-")},"Details")),t.createElement("td",null,t.createElement("button",{onClick:()=>{}},"Delete")))))))):t.createElement("div",null,"No items available")}function s({error:e}){return t.createElement("div",{className:"error-container"},t.createElement("div",{className:"error-icon"},t.createElement("i",{className:"fa fa-exclamation-circle"})),t.createElement("div",{className:"error-content"},t.createElement("h3",null,"Error Occurred"),t.createElement("p",null,(t=>{if(t instanceof Response)switch(t.status){case 400:return"Bad Request: The request was invalid or malformed.";case 401:return"Unauthorized: Please log in to access this resource.";case 404:return"Not Found: The requested resource could not be found.";case 403:return"Forbidden: You don't have permission to access this resource.";case 500:return"Internal Server Error: Something went wrong on our end.";default:return`Error ${t.status}: ${t.statusText||"Something went wrong."}`}return t?.message||"Something went wrong. Please try again later."})(e))))}function c(){return t.createElement("div",{className:"loading-screen"},t.createElement("div",{className:"loading-container"},t.createElement("div",{className:"loading-spinner"}),t.createElement("div",{className:"loading-text"},"Loading...")))}var l,u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},p={};!function(){return l||(l=1,function(t){!function(){var e="object"==typeof globalThis?globalThis:"object"==typeof u?u:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(t){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(t){}}(),r=n(t);function n(t,e){return function(r,n){Object.defineProperty(t,r,{configurable:!0,writable:!0,value:n}),e&&e(r,n)}}void 0!==e.Reflect&&(r=n(e.Reflect,r)),function(t,e){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,o=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",a=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",i="function"==typeof Object.create,s={__proto__:[]}instanceof Array,c=!i&&!s,l={create:i?function(){return pt(Object.create(null))}:s?function(){return pt({__proto__:null})}:function(){return pt({})},has:c?function(t,e){return r.call(t,e)}:function(t,e){return e in t},get:c?function(t,e){return r.call(t,e)?t[e]:void 0}:function(t,e){return t[e]}},u=Object.getPrototypeOf(Function),p="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ct(),f="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:lt(),d="function"==typeof WeakMap?WeakMap:ut(),h=n?Symbol.for("@reflect-metadata:registry"):void 0,y=ot(),m=at(y);function v(t,e,r,n){if(D(r)){if(!H(t))throw new TypeError;if(!G(e))throw new TypeError;return A(t,e)}if(!H(t))throw new TypeError;if(!B(e))throw new TypeError;if(!B(n)&&!D(n)&&!F(n))throw new TypeError;return F(n)&&(n=void 0),x(t,e,r=K(r),n)}function g(t,e){function r(r,n){if(!B(r))throw new TypeError;if(!D(n)&&!J(n))throw new TypeError;P(t,e,r,n)}return r}function E(t,e,r,n){if(!B(r))throw new TypeError;return D(n)||(n=K(n)),P(t,e,r,n)}function b(t,e,r){if(!B(e))throw new TypeError;return D(r)||(r=K(r)),N(t,e,r)}function S(t,e,r){if(!B(e))throw new TypeError;return D(r)||(r=K(r)),C(t,e,r)}function w(t,e,r){if(!B(e))throw new TypeError;return D(r)||(r=K(r)),k(t,e,r)}function _(t,e,r){if(!B(e))throw new TypeError;return D(r)||(r=K(r)),L(t,e,r)}function O(t,e){if(!B(t))throw new TypeError;return D(e)||(e=K(e)),I(t,e)}function M(t,e){if(!B(t))throw new TypeError;return D(e)||(e=K(e)),V(t,e)}function T(t,e,r){if(!B(e))throw new TypeError;if(D(r)||(r=K(r)),!B(e))throw new TypeError;D(r)||(r=K(r));var n=st(e,r,!1);return!D(n)&&n.OrdinaryDeleteMetadata(t,e,r)}function A(t,e){for(var r=t.length-1;r>=0;--r){var n=(0,t[r])(e);if(!D(n)&&!F(n)){if(!G(n))throw new TypeError;e=n}}return e}function x(t,e,r,n){for(var o=t.length-1;o>=0;--o){var a=(0,t[o])(e,r,n);if(!D(a)&&!F(a)){if(!B(a))throw new TypeError;n=a}}return n}function N(t,e,r){if(C(t,e,r))return!0;var n=rt(e);return!F(n)&&N(t,n,r)}function C(t,e,r){var n=st(e,r,!1);return!D(n)&&U(n.OrdinaryHasOwnMetadata(t,e,r))}function k(t,e,r){if(C(t,e,r))return L(t,e,r);var n=rt(e);return F(n)?void 0:k(t,n,r)}function L(t,e,r){var n=st(e,r,!1);if(!D(n))return n.OrdinaryGetOwnMetadata(t,e,r)}function P(t,e,r,n){st(r,n,!0).OrdinaryDefineOwnMetadata(t,e,r,n)}function I(t,e){var r=V(t,e),n=rt(t);if(null===n)return r;var o=I(n,e);if(o.length<=0)return r;if(r.length<=0)return o;for(var a=new f,i=[],s=0,c=r;s<c.length;s++){var l=c[s];a.has(l)||(a.add(l),i.push(l))}for(var u=0,p=o;u<p.length;u++){l=p[u];a.has(l)||(a.add(l),i.push(l))}return i}function V(t,e){var r=st(t,e,!1);return r?r.OrdinaryOwnMetadataKeys(t,e):[]}function j(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}function D(t){return void 0===t}function F(t){return null===t}function R(t){return"symbol"==typeof t}function B(t){return"object"==typeof t?null!==t:"function"==typeof t}function $(t,e){switch(j(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var r="string",n=Q(t,o);if(void 0!==n){var a=n.call(t,r);if(B(a))throw new TypeError;return a}return z(t)}function z(t,e){var r,n,o=t.toString;if(W(o)&&!B(n=o.call(t)))return n;if(W(r=t.valueOf)&&!B(n=r.call(t)))return n;throw new TypeError}function U(t){return!!t}function q(t){return""+t}function K(t){var e=$(t);return R(e)?e:q(e)}function H(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function W(t){return"function"==typeof t}function G(t){return"function"==typeof t}function J(t){switch(j(t)){case 3:case 4:return!0;default:return!1}}function Y(t,e){return t===e||t!=t&&e!=e}function Q(t,e){var r=t[e];if(null!=r){if(!W(r))throw new TypeError;return r}}function X(t){var e=Q(t,a);if(!W(e))throw new TypeError;var r=e.call(t);if(!B(r))throw new TypeError;return r}function Z(t){return t.value}function tt(t){var e=t.next();return!e.done&&e}function et(t){var e=t.return;e&&e.call(t)}function rt(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===u)return e;if(e!==u)return e;var r=t.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return e;var o=n.constructor;return"function"!=typeof o||o===t?e:o}function nt(){var t,r,n,o;D(h)||void 0===e.Reflect||h in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=it(e.Reflect));var a=new d,i={registerProvider:s,getProvider:l,setProvider:y};return i;function s(e){if(!Object.isExtensible(i))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case t===e:break;case D(r):r=e;break;case r===e:break;case D(n):n=e;break;case n===e:break;default:void 0===o&&(o=new f),o.add(e)}}function c(e,a){if(!D(r)){if(r.isProviderFor(e,a))return r;if(!D(n)){if(n.isProviderFor(e,a))return r;if(!D(o))for(var i=X(o);;){var s=tt(i);if(!s)return;var c=Z(s);if(c.isProviderFor(e,a))return et(i),c}}}if(!D(t)&&t.isProviderFor(e,a))return t}function l(t,e){var r,n=a.get(t);return D(n)||(r=n.get(e)),D(r)?(D(r=c(t,e))||(D(n)&&(n=new p,a.set(t,n)),n.set(e,r)),r):r}function u(t){if(D(t))throw new TypeError;return r===t||n===t||!D(o)&&o.has(t)}function y(t,e,r){if(!u(r))throw new Error("Metadata provider not registered.");var n=l(t,e);if(n!==r){if(!D(n))return!1;var o=a.get(t);D(o)&&(o=new p,a.set(t,o)),o.set(e,r)}return!0}}function ot(){var t;return!D(h)&&B(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[h]),D(t)&&(t=nt()),!D(h)&&B(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}function at(t){var e=new d,r={isProviderFor:function(t,r){var n=e.get(t);return!D(n)&&n.has(r)},OrdinaryDefineOwnMetadata:i,OrdinaryHasOwnMetadata:o,OrdinaryGetOwnMetadata:a,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return y.registerProvider(r),r;function n(n,o,a){var i=e.get(n),s=!1;if(D(i)){if(!a)return;i=new p,e.set(n,i),s=!0}var c=i.get(o);if(D(c)){if(!a)return;if(c=new p,i.set(o,c),!t.setProvider(n,o,r))throw i.delete(o),s&&e.delete(n),new Error("Wrong provider for target.")}return c}function o(t,e,r){var o=n(e,r,!1);return!D(o)&&U(o.has(t))}function a(t,e,r){var o=n(e,r,!1);if(!D(o))return o.get(t)}function i(t,e,r,o){n(r,o,!0).set(t,e)}function s(t,e){var r=[],o=n(t,e,!1);if(D(o))return r;for(var a=X(o.keys()),i=0;;){var s=tt(a);if(!s)return r.length=i,r;var c=Z(s);try{r[i]=c}catch(t){try{et(a)}finally{throw t}}i++}}function c(t,r,o){var a=n(r,o,!1);if(D(a))return!1;if(!a.delete(t))return!1;if(0===a.size){var i=e.get(r);D(i)||(i.delete(o),0===i.size&&e.delete(i))}return!0}}function it(t){var e=t.defineMetadata,r=t.hasOwnMetadata,n=t.getOwnMetadata,o=t.getOwnMetadataKeys,a=t.deleteMetadata,i=new d;return{isProviderFor:function(t,e){var r=i.get(t);return!(D(r)||!r.has(e))||!!o(t,e).length&&(D(r)&&(r=new f,i.set(t,r)),r.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:o,OrdinaryDeleteMetadata:a}}function st(t,e,r){var n=y.getProvider(t,e);if(!D(n))return n;if(r){if(y.setProvider(t,e,m))return m;throw new Error("Illegal state.")}}function ct(){var t={},e=[],r=function(){function t(t,e,r){this._index=0,this._keys=t,this._values=e,this._selector=r}return t.prototype["@@iterator"]=function(){return this},t.prototype[a]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var r=this._selector(this._keys[t],this._values[t]);return t+1>=this._keys.length?(this._index=-1,this._keys=e,this._values=e):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},t.prototype.throw=function(t){throw this._index>=0&&(this._index=-1,this._keys=e,this._values=e),t},t.prototype.return=function(t){return this._index>=0&&(this._index=-1,this._keys=e,this._values=e),{value:t,done:!0}},t}(),n=function(){function e(){this._keys=[],this._values=[],this._cacheKey=t,this._cacheIndex=-2}return Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this._find(t,!1)>=0},e.prototype.get=function(t){var e=this._find(t,!1);return e>=0?this._values[e]:void 0},e.prototype.set=function(t,e){var r=this._find(t,!0);return this._values[r]=e,this},e.prototype.delete=function(e){var r=this._find(e,!1);if(r>=0){for(var n=this._keys.length,o=r+1;o<n;o++)this._keys[o-1]=this._keys[o],this._values[o-1]=this._values[o];return this._keys.length--,this._values.length--,Y(e,this._cacheKey)&&(this._cacheKey=t,this._cacheIndex=-2),!0}return!1},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=t,this._cacheIndex=-2},e.prototype.keys=function(){return new r(this._keys,this._values,o)},e.prototype.values=function(){return new r(this._keys,this._values,i)},e.prototype.entries=function(){return new r(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[a]=function(){return this.entries()},e.prototype._find=function(t,e){if(!Y(this._cacheKey,t)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(Y(this._keys[r],t)){this._cacheIndex=r;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();return n;function o(t,e){return t}function i(t,e){return e}function s(t,e){return[t,e]}}function lt(){return function(){function t(){this._map=new p}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(t){return this._map.has(t)},t.prototype.add=function(t){return this._map.set(t,t),this},t.prototype.delete=function(t){return this._map.delete(t)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.keys()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[a]=function(){return this.keys()},t}()}function ut(){var t=16,e=l.create(),n=o();return function(){function t(){this._key=o()}return t.prototype.has=function(t){var e=a(t,!1);return void 0!==e&&l.has(e,this._key)},t.prototype.get=function(t){var e=a(t,!1);return void 0!==e?l.get(e,this._key):void 0},t.prototype.set=function(t,e){return a(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=a(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=o()},t}();function o(){var t;do{t="@@WeakMap@@"+c()}while(l.has(e,t));return e[t]=!0,t}function a(t,e){if(!r.call(t,n)){if(!e)return;Object.defineProperty(t,n,{value:l.create()})}return t[n]}function i(t,e){for(var r=0;r<e;++r)t[r]=255*Math.random()|0;return t}function s(t){if("function"==typeof Uint8Array){var e=new Uint8Array(t);return"undefined"!=typeof crypto?crypto.getRandomValues(e):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(e):i(e,t),e}return i(new Array(t),t)}function c(){var e=s(t);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var r="",n=0;n<t;++n){var o=e[n];4!==n&&6!==n&&8!==n||(r+="-"),o<16&&(r+="0"),r+=o.toString(16).toLowerCase()}return r}}function pt(t){return t.__=void 0,delete t.__,t}t("decorate",v),t("metadata",g),t("defineMetadata",E),t("hasMetadata",b),t("hasOwnMetadata",S),t("getMetadata",w),t("getOwnMetadata",_),t("getMetadataKeys",O),t("getOwnMetadataKeys",M),t("deleteMetadata",T)}(r,e),void 0===e.Reflect&&(e.Reflect=t)}()}(t||(t={}))),p;var t}();const f="List";function d(t){return Reflect.getMetadata(f,t)}const h=Symbol("cell");function y(t){return(e,r)=>{const n=Reflect.getMetadata(h,e)||[];if(Reflect.defineMetadata(h,[...n,r.toString()],e),t){const n=`${h.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}}function m(t){const e=t.prototype;return(Reflect.getMetadata(h,e)||[]).map((t=>{const r=Reflect.getMetadata(`${h.toString()}:${t}:options`,e)||{};return{...r,name:r?.name??t}}))}function v({pagination:e,onPageChange:r}){const{total:n,page:o,limit:a}=e,i=Math.floor(n/a);if(i<=1)return null;return t.createElement("div",{className:"pagination"},t.createElement("button",{onClick:()=>r(o-1),className:"pagination-item "+(1===o?"disabled":""),disabled:1===o,"aria-disabled":1===o},"Previous"),(()=>{const e=[];for(let n=1;n<=Math.min(2,i);n++)e.push(t.createElement("button",{key:n,onClick:()=>r(n),className:"pagination-item "+(o===n?"active":""),disabled:o===n},n));o-2>3&&e.push(t.createElement("span",{key:"ellipsis1",className:"pagination-ellipsis"},"..."));for(let n=Math.max(3,o-2);n<=Math.min(i-2,o+2);n++)n>2&&n<i-1&&e.push(t.createElement("button",{key:n,onClick:()=>r(n),className:"pagination-item "+(o===n?"active":""),disabled:o===n},n));o+2<i-2&&e.push(t.createElement("span",{key:"ellipsis2",className:"pagination-ellipsis"},"..."));for(let n=Math.max(i-1,3);n<=i;n++)n>2&&e.push(t.createElement("button",{key:n,onClick:()=>r(n),className:"pagination-item "+(o===n?"active":""),disabled:o===n},n));return e})(),t.createElement("button",{onClick:()=>r(o+1),className:"pagination-item "+(o===i?"disabled":""),disabled:o===i,"aria-disabled":o===i},"Next"))}function g({htmlFor:e,label:r,fieldName:n}){return t.createElement("label",{htmlFor:e},r??n.charAt(0).toUpperCase()+n.slice(1))}const E=Object.freeze({BEFORE:"before",HOVER:"hover",AFTER:"after"});function b(e){return t.createElement("div",null,t.createElement("img",{...e,style:{width:100}}),t.createElement("p",null,e.name," ",t.createElement("span",{style:{whiteSpace:"none"}},"(",(t=>{if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(1024));return parseFloat((t/Math.pow(1024,e)).toFixed(2))+" "+["Bytes","KB","MB","GB","TB"][e]})(e.size),")")))}function S(){const{register:e,formState:{errors:n},watch:o,setValue:a,clearErrors:i,setError:s}=r.useFormContext(),c=o("uploader");return t.useEffect((()=>{e("uploader",{required:!0})}),[e]),t.createElement("div",null,t.createElement("span",{className:"form-error",style:{bottom:2,top:"unset"}},"required"===n.uploader?.type&&"At least 1 image is required!","custom"===n.uploader?.type&&n.uploader.message?.toString()),t.createElement(w,{reset:c,onError:t=>{t?s("uploader",{type:"custom",message:t}):(a("uploader",{files:[]}),i("uploader"))},onClear:()=>{a("uploader",{files:[]}),i("uploader")},onFilesChange:t=>{a("uploader",{files:t})}}))}function w(e){const[r,n]=t.useState(E.BEFORE),[o,a]=t.useState(e.value||[]),[i,s]=t.useState([]),[c,l]=t.useState(0);console.log("files",i);const u=t.useRef(null),p=t.useRef(null);t.useEffect((()=>{const t=u.current;if(!t)return;const r=t=>{t.preventDefault(),t.stopPropagation(),f()},o=t=>{t.preventDefault(),t.stopPropagation(),d()},a=t=>{t.preventDefault(),t.stopPropagation()},c=t=>{t.preventDefault(),t.stopPropagation(),l(0);const r=t.dataTransfer?.files;if(!r)return;s([]),n(E.AFTER);const o=[];for(let t=0;t<r.length;t++){const n=new FileReader;n.onload=n=>{if(!n.target)return;h([...i,{file:r[t],image:n.target.result}])&&(o.push(r[t]),p.current&&(p.current.files=r),s([])),e.onFilesChange&&e.onFilesChange(o)},n.readAsDataURL(r[t])}p.current&&(p.current.files=r)};return t.addEventListener("dragenter",r,!1),t.addEventListener("dragleave",o,!1),t.addEventListener("dragover",a,!1),t.addEventListener("drop",c,!1),()=>{t.removeEventListener("dragenter",r),t.removeEventListener("dragleave",o),t.removeEventListener("dragover",a),t.removeEventListener("drop",c)}}),[i]);const f=()=>{l((t=>t+1)),n(E.HOVER)},d=()=>{l((t=>t-1==0?(n(E.BEFORE),0):t-1))},h=t=>{const r=(t=>{if(!t)return null;if(t.length>=10)return"you can't send more than 10 images";for(let e=0;e<t.length;e++){const r=t[e].file,n=r.name.split(".");if(!["png","jpg","jpeg"].includes(n[n.length-1]))return'Extension of the file can only be "png", "jpg" or "jpeg" ';if(r&&r.size>1048576)return`Size of "${r.name}" can't be bigger than 1mb`}return null})(t);return r||s(t),e.onError?.(r),r};return t.createElement("div",{ref:u,className:"multi-image form-element dropzone "+r},t.createElement("input",{ref:p,type:"file",style:{display:"none"},className:"target",name:"file"}),t.createElement("div",{className:"container"},t.createElement("button",{className:"trash",onClick:()=>{s([]),p.current&&(p.current.value=""),e.onClear?.()},type:"button"},"Delete All"),(()=>{const e=[];if(i){console.log("----\x3e",i);for(let r=0;r<i.length;r++){let n="image";e.push(t.createElement("div",{key:r,className:"image-container"},t.createElement("div",{className:n},t.createElement(b,{name:i[r].file.name,src:i[r].image,size:i[r].file.size}))))}}return e})(),t.createElement("div",null,t.createElement("button",{type:"button",onClick:()=>{const t=document.getElementById("file__");t&&t.click()},className:"plus"},t.createElement("span",null,"+ Add Image",t.createElement("p",null,"Drag image here or Select Image")))),t.createElement("input",{hidden:!0,id:"file__",multiple:!0,type:"file",onChange:t=>{const e=t.target.files;if(e){s([]),n(E.AFTER);for(let t=0;t<e.length;t++){const r=new FileReader;r.onload=r=>{r.target&&h([...i,{file:e[t],image:r.target.result}])},r.readAsDataURL(e[t])}p.current&&(p.current.files=e)}}})))}function _({id:e,...r}){return t.createElement("input",{type:"checkbox",id:e,className:"checkbox",...r})}function O({input:e,register:r,error:n}){const o=e.name||"";return t.createElement("div",{className:"form-field"},t.createElement(g,{htmlFor:o,label:e.label,fieldName:o}),(()=>{switch(e.type){case"textarea":return t.createElement("textarea",{...r(o),placeholder:e.placeholder,id:o});case"select":return t.createElement("select",{...r(o),id:o},t.createElement("option",{value:""},"Select ",o),e.selectOptions?.map((e=>t.createElement("option",{key:e,value:e},e))));case"input":return t.createElement("input",{type:e.inputType,...r(o),placeholder:e.placeholder,id:o});case"file-upload":return t.createElement(S,null);case"checkbox":return t.createElement(_,{...r(o),id:o});case"hidden":return t.createElement("input",{type:"hidden",...r(o),id:o})}})(),n&&t.createElement("span",{className:"error-message"},n.message))}function M({formOptions:n,onSubmit:o,redirect:a,getDetailsData:i}){const s=e.useParams(),c=r.useForm({resolver:n.resolver}),l=n.inputs;return t.useEffect((()=>{i&&i(s.id).then((t=>{c.reset({...t})}))}),[,c.reset]),t.createElement("div",{className:"form-wrapper"},t.createElement(r.FormProvider,{...c},t.createElement("form",{onSubmit:c.handleSubmit((async t=>{await o(t),a&&(window.location.href=a)}),((t,e)=>{console.log("error creating creation",t,e)}))},t.createElement("div",null,l?.map((e=>t.createElement(O,{key:e.name||"",input:e,register:c.register,error:e.name?{message:c.formState.errors[e.name]?.message}:void 0}))),t.createElement("button",{type:"submit",className:"submit-button"},"Submit")))))}class T extends t.Component{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(t){return{hasError:!0,error:t,errorInfo:null}}componentDidCatch(t,e){this.setState({error:t,errorInfo:e})}render(){return this.state.hasError?t.createElement("div",{className:"error-boundary"},t.createElement("div",{className:"error-boundary__content"},t.createElement("div",{className:"error-boundary__icon"},t.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},t.createElement("circle",{cx:"12",cy:"12",r:"10"}),t.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),t.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"16"}))),t.createElement("h1",null,"Oops! Something went wrong"),t.createElement("p",{className:"error-boundary__message"},this.state.error?.message||"An unexpected error occurred"),t.createElement("button",{className:"error-boundary__button",onClick:()=>window.location.reload()},"Refresh Page"),"development"===process.env.NODE_ENV&&t.createElement("details",{className:"error-boundary__details"},t.createElement("summary",null,"Error Details"),t.createElement("pre",null,this.state.error?.toString()),t.createElement("pre",null,this.state.errorInfo?.componentStack)))):this.props.children}}const A=Symbol("input");function x(t){const e=t.prototype;return(Reflect.getMetadata(A,e)||[]).map((t=>{const r=Reflect.getMetadata(`${A.toString()}:${t}:options`,e)||{},n=r?.inputType??(o=t,["password"].some((t=>o.toLowerCase().includes(t)))?"password":"text");var o;return{...r,editable:r.editable??!0,sensitive:r.sensitive,name:r?.name??t,label:r?.label??t,placeholder:r?.placeholder??t,inputType:n,type:r?.type??"input",selectOptions:r?.selectOptions??[],cancelPasswordValidationOnEdit:r?.cancelPasswordValidationOnEdit??"password"===n}}))}function N(t){return Reflect.getMetadata("FormMetadata",t)}const C=(t,e,n)=>{if(t&&"reportValidity"in t){const o=r.get(n,e);t.setCustomValidity(o&&o.message||""),t.reportValidity()}},k=(t,e)=>{for(const r in e.fields){const n=e.fields[r];n&&n.ref&&"reportValidity"in n.ref?C(n.ref,r,t):n&&n.refs&&n.refs.forEach((e=>C(e,r,t)))}},L=(t,e)=>{e.shouldUseNativeValidation&&k(t,e);const n={};for(const o in t){const a=r.get(e.fields,o),i=Object.assign(t[o]||{},{ref:a&&a.ref});if(P(e.names||Object.keys(t),o)){const t=Object.assign({},r.get(n,o));r.set(t,"root",i),r.set(n,o,t)}else r.set(n,o,i)}return n},P=(t,e)=>{const r=I(e);return t.some((t=>I(t).match(`^${r}\\.\\d+`)))};function I(t){return t.replace(/\]|\[/g,"")}var V;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(V||(V={}));var j=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,r){return this.findMetadatas(this._transformMetadatas,t,e).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?r===V.CLASS_TO_CLASS||r===V.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||r===V.CLASS_TO_PLAIN))}))},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find((function(t){return t.options&&t.options.name===e}))},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),r=e&&e.get(void 0),n=this._exposeMetadatas.get(t),o=n&&n.get(void 0);return r&&o||!r&&!o?"none":r?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===V.CLASS_TO_CLASS||e===V.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===V.CLASS_TO_PLAIN))})).map((function(t){return t.propertyName}))},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===V.CLASS_TO_CLASS||e===V.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===V.CLASS_TO_PLAIN))})).map((function(t){return t.propertyName}))},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var r,n=t.get(e);n&&(r=Array.from(n.values()).filter((function(t){return void 0!==t.propertyName})));for(var o=[],a=0,i=this.getAncestors(e);a<i.length;a++){var s=i[a],c=t.get(s);if(c){var l=Array.from(c.values()).filter((function(t){return void 0!==t.propertyName}));o.push.apply(o,l)}}return o.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var n=t.get(e);if(n){var o=n.get(r);if(o)return o}for(var a=0,i=this.getAncestors(e);a<i.length;a++){var s=i[a],c=t.get(s);if(c){var l=c.get(r);if(l)return l}}},t.prototype.findMetadatas=function(t,e,r){var n,o=t.get(e);o&&(n=o.get(r));for(var a=[],i=0,s=this.getAncestors(e);i<s.length;i++){var c=s[i],l=t.get(c);l&&l.has(r)&&a.push.apply(a,l.get(r))}return a.slice().reverse().concat((n||[]).slice().reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],r=Object.getPrototypeOf(t.prototype.constructor);void 0!==r.prototype;r=Object.getPrototypeOf(r.prototype.constructor))e.push(r);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}(),D=new j;var F=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,a=e.length;o<a;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};var R=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,r,n,o,a){var i,s=this;if(void 0===a&&(a=0),Array.isArray(e)||e instanceof Set){var c=n&&this.transformationType===V.PLAIN_TO_CLASS?function(t){var e=new t;return e instanceof Set||"push"in e?e:[]}(n):[];return e.forEach((function(e,n){var o=t?t[n]:void 0;if(s.options.enableCircularCheck&&s.isCircular(e))s.transformationType===V.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var i=void 0;if("function"!=typeof r&&r&&r.options&&r.options.discriminator&&r.options.discriminator.property&&r.options.discriminator.subTypes){if(s.transformationType===V.PLAIN_TO_CLASS){i=r.options.discriminator.subTypes.find((function(t){return t.name===e[r.options.discriminator.property]}));var l={newObject:c,object:e,property:void 0},u=r.typeFunction(l);i=void 0===i?u:i.value,r.options.keepDiscriminatorProperty||delete e[r.options.discriminator.property]}s.transformationType===V.CLASS_TO_CLASS&&(i=e.constructor),s.transformationType===V.CLASS_TO_PLAIN&&(e[r.options.discriminator.property]=r.options.discriminator.subTypes.find((function(t){return t.value===e.constructor})).name)}else i=r;var p=s.transform(o,e,i,void 0,e instanceof Map,a+1);c instanceof Set?c.add(p):c.push(p)}})),c}if(r!==String||o){if(r!==Number||o){if(r!==Boolean||o){if((r===Date||e instanceof Date)&&!o)return e instanceof Date?new Date(e.valueOf()):null==e?e:new Date(e);if(("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0).Buffer&&(r===Buffer||e instanceof Buffer)&&!o)return null==e?e:Buffer.from(e);if(null===(i=e)||"object"!=typeof i||"function"!=typeof i.then||o){if(o||null===e||"object"!=typeof e||"function"!=typeof e.then){if("object"==typeof e&&null!==e){r||e.constructor===Object||(Array.isArray(e)||e.constructor!==Array)&&(r=e.constructor),!r&&t&&(r=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var l=this.getKeys(r,e,o),u=t||{};t||this.transformationType!==V.PLAIN_TO_CLASS&&this.transformationType!==V.CLASS_TO_CLASS||(u=o?new Map:r?new r:{});for(var p=function(n){if("__proto__"===n||"constructor"===n)return"continue";var i=n,s=n,c=n;if(!f.options.ignoreDecorators&&r)if(f.transformationType===V.PLAIN_TO_CLASS)(l=D.findExposeMetadataByCustomName(r,n))&&(c=l.propertyName,s=l.propertyName);else if(f.transformationType===V.CLASS_TO_PLAIN||f.transformationType===V.CLASS_TO_CLASS){var l;(l=D.findExposeMetadata(r,n))&&l.options&&l.options.name&&(s=l.options.name)}var p=void 0;p=f.transformationType===V.PLAIN_TO_CLASS?e[i]:e instanceof Map?e.get(i):e[i]instanceof Function?e[i]():e[i];var d=void 0,h=p instanceof Map;if(r&&o)d=r;else if(r){var y=D.findTypeMetadata(r,c);if(y){var m={newObject:u,object:e,property:c},v=y.typeFunction?y.typeFunction(m):y.reflectedType;y.options&&y.options.discriminator&&y.options.discriminator.property&&y.options.discriminator.subTypes?e[i]instanceof Array?d=y:(f.transformationType===V.PLAIN_TO_CLASS&&(d=void 0===(d=y.options.discriminator.subTypes.find((function(t){if(p&&p instanceof Object&&y.options.discriminator.property in p)return t.name===p[y.options.discriminator.property]})))?v:d.value,y.options.keepDiscriminatorProperty||p&&p instanceof Object&&y.options.discriminator.property in p&&delete p[y.options.discriminator.property]),f.transformationType===V.CLASS_TO_CLASS&&(d=p.constructor),f.transformationType===V.CLASS_TO_PLAIN&&p&&(p[y.options.discriminator.property]=y.options.discriminator.subTypes.find((function(t){return t.value===p.constructor})).name)):d=v,h=h||y.reflectedType===Map}else if(f.options.targetMaps)f.options.targetMaps.filter((function(t){return t.target===r&&!!t.properties[c]})).forEach((function(t){return d=t.properties[c]}));else if(f.options.enableImplicitConversion&&f.transformationType===V.PLAIN_TO_CLASS){var g=Reflect.getMetadata("design:type",r.prototype,c);g&&(d=g)}}var E=Array.isArray(e[i])?f.getReflectedType(r,c):void 0,b=t?t[i]:void 0;if(u.constructor.prototype){var S=Object.getOwnPropertyDescriptor(u.constructor.prototype,s);if((f.transformationType===V.PLAIN_TO_CLASS||f.transformationType===V.CLASS_TO_CLASS)&&(S&&!S.set||u[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(p)){if(f.transformationType===V.CLASS_TO_CLASS){_=p;(void 0!==(_=f.applyCustomTransformations(_,r,n,e,f.transformationType))||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,_):u[s]=_)}}else{var w=f.transformationType===V.PLAIN_TO_CLASS?s:n,_=void 0;f.transformationType===V.CLASS_TO_PLAIN?(_=e[w],_=f.applyCustomTransformations(_,r,w,e,f.transformationType),_=e[w]===_?p:_,_=f.transform(b,_,d,E,h,a+1)):void 0===p&&f.options.exposeDefaultValues?_=u[s]:(_=f.transform(b,p,d,E,h,a+1),_=f.applyCustomTransformations(_,r,w,e,f.transformationType)),(void 0!==_||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,_):u[s]=_)}},f=this,d=0,h=l;d<h.length;d++){p(h[d])}return this.options.enableCircularCheck&&this.recursionStack.delete(e),u}return e}return e}return new Promise((function(t,n){e.then((function(e){return t(s.transform(void 0,e,r,void 0,void 0,a+1))}),n)}))}return null==e?e:Boolean(e)}return null==e?e:Number(e)}return null==e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,r,n,o){var a=this,i=D.findTransformMetadatas(e,r,this.transformationType);return void 0!==this.options.version&&(i=i.filter((function(t){return!t.options||a.checkVersion(t.options.since,t.options.until)}))),(i=this.options.groups&&this.options.groups.length?i.filter((function(t){return!t.options||a.checkGroups(t.options.groups)})):i.filter((function(t){return!t.options||!t.options.groups||!t.options.groups.length}))).forEach((function(e){t=e.transformFn({value:t,key:r,obj:n,type:o,options:a.options})})),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var r=D.findTypeMetadata(t,e);return r?r.reflectedType:void 0}},t.prototype.getKeys=function(t,e,r){var n=this,o=D.getStrategy(t);"none"===o&&(o=this.options.strategy||"exposeAll");var a=[];if(("exposeAll"===o||r)&&(a=e instanceof Map?Array.from(e.keys()):Object.keys(e)),r)return a;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&t){var i=D.getExposedProperties(t,this.transformationType),s=D.getExcludedProperties(t,this.transformationType);a=F(F([],i,!0),s,!0)}if(!this.options.ignoreDecorators&&t){i=D.getExposedProperties(t,this.transformationType);this.transformationType===V.PLAIN_TO_CLASS&&(i=i.map((function(e){var r=D.findExposeMetadata(t,e);return r&&r.options&&r.options.name?r.options.name:e}))),a=this.options.excludeExtraneousValues?i:a.concat(i);var c=D.getExcludedProperties(t,this.transformationType);c.length>0&&(a=a.filter((function(t){return!c.includes(t)}))),void 0!==this.options.version&&(a=a.filter((function(e){var r=D.findExposeMetadata(t,e);return!r||!r.options||n.checkVersion(r.options.since,r.options.until)}))),a=this.options.groups&&this.options.groups.length?a.filter((function(e){var r=D.findExposeMetadata(t,e);return!r||!r.options||n.checkGroups(r.options.groups)})):a.filter((function(e){var r=D.findExposeMetadata(t,e);return!(r&&r.options&&r.options.groups&&r.options.groups.length)}))}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(a=a.filter((function(t){return n.options.excludePrefixes.every((function(e){return t.substr(0,e.length)!==e}))}))),a=a.filter((function(t,e,r){return r.indexOf(t)===e}))},t.prototype.checkVersion=function(t,e){var r=!0;return r&&t&&(r=this.options.version>=t),r&&e&&(r=this.options.version<e),r},t.prototype.checkGroups=function(t){return!t||this.options.groups.some((function(e){return t.includes(e)}))},t}(),B={enableCircularCheck:!1,enableImplicitConversion:!1,excludeExtraneousValues:!1,excludePrefixes:void 0,exposeDefaultValues:!1,exposeUnsetFields:!0,groups:void 0,ignoreDecorators:!1,strategy:void 0,targetMaps:void 0,version:void 0},$=function(){return $=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},$.apply(this,arguments)},z=new(function(){function t(){}return t.prototype.instanceToPlain=function(t,e){return new R(V.CLASS_TO_PLAIN,$($({},B),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,r){return new R(V.CLASS_TO_PLAIN,$($({},B),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToInstance=function(t,e,r){return new R(V.PLAIN_TO_CLASS,$($({},B),r)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,r){return new R(V.PLAIN_TO_CLASS,$($({},B),r)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.instanceToInstance=function(t,e){return new R(V.CLASS_TO_CLASS,$($({},B),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,r){return new R(V.CLASS_TO_CLASS,$($({},B),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.instanceToPlain(t,e))},t.prototype.deserialize=function(t,e,r){var n=JSON.parse(e);return this.plainToInstance(t,n,r)},t.prototype.deserializeArray=function(t,e,r){var n=JSON.parse(e);return this.plainToInstance(t,n,r)},t}());var U=function(t){this.groups=[],this.each=!1,this.context=void 0,this.type=t.type,this.name=t.name,this.target=t.target,this.propertyName=t.propertyName,this.constraints=null==t?void 0:t.constraints,this.constraintCls=t.constraintCls,this.validationTypeOptions=t.validationTypeOptions,t.validationOptions&&(this.message=t.validationOptions.message,this.groups=t.validationOptions.groups,this.always=t.validationOptions.always,this.each=t.validationOptions.each,this.context=t.validationOptions.context)},q=function(){function t(){}return t.prototype.transform=function(t){var e=[];return Object.keys(t.properties).forEach((function(r){t.properties[r].forEach((function(n){var o={message:n.message,groups:n.groups,always:n.always,each:n.each},a={type:n.type,name:n.name,target:t.name,propertyName:r,constraints:n.constraints,validationTypeOptions:n.options,validationOptions:o};e.push(new U(a))}))})),e},t}();function K(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function H(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var W=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},G=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},J=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,a=e.length;o<a;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},Y=function(){function t(){this.validationMetadatas=new Map,this.constraintMetadatas=new Map}return Object.defineProperty(t.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.size},enumerable:!1,configurable:!0}),t.prototype.addValidationSchema=function(t){var e=this;(new q).transform(t).forEach((function(t){return e.addValidationMetadata(t)}))},t.prototype.addValidationMetadata=function(t){var e=this.validationMetadatas.get(t.target);e?e.push(t):this.validationMetadatas.set(t.target,[t])},t.prototype.addConstraintMetadata=function(t){var e=this.constraintMetadatas.get(t.target);e?e.push(t):this.constraintMetadatas.set(t.target,[t])},t.prototype.groupByPropertyName=function(t){var e={};return t.forEach((function(t){e[t.propertyName]||(e[t.propertyName]=[]),e[t.propertyName].push(t)})),e},t.prototype.getTargetValidationMetadatas=function(t,e,r,n,o){var a,i,s=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&r},c=function(t){return!(!n||o&&o.length||!t.groups||!t.groups.length)},l=(this.validationMetadatas.get(t)||[]).filter((function(r){return(r.target===t||r.target===e)&&(!!s(r)||!c(r)&&(!(o&&o.length>0)||r.groups&&!!r.groups.find((function(t){return-1!==o.indexOf(t)}))))})),u=[];try{for(var p=W(this.validationMetadatas.entries()),f=p.next();!f.done;f=p.next()){var d=G(f.value,2),h=d[0],y=d[1];t.prototype instanceof h&&u.push.apply(u,J([],G(y),!1))}}catch(t){a={error:t}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(a)throw a.error}}var m=u.filter((function(e){return"string"!=typeof e.target&&(e.target!==t&&((!(e.target instanceof Function)||t.prototype instanceof e.target)&&(!!s(e)||!c(e)&&(!(o&&o.length>0)||e.groups&&!!e.groups.find((function(t){return-1!==o.indexOf(t)}))))))})).filter((function(t){return!l.find((function(e){return e.propertyName===t.propertyName&&e.type===t.type}))}));return l.concat(m)},t.prototype.getTargetValidatorConstraints=function(t){return this.constraintMetadatas.get(t)||[]},t}();var Q=function(){function t(){}return t.prototype.toString=function(t,e,r,n){var o=this;void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===r&&(r=""),void 0===n&&(n=!1);var a=t?"":"",i=t?"":"",s=function(t){return" - property ".concat(a).concat(r).concat(t).concat(i," has failed the following constraints: ").concat(a).concat((n?Object.values:Object.keys)(null!==(e=o.constraints)&&void 0!==e?e:{}).join(", ")).concat(i," \n");var e};if(e){var c=Number.isInteger(+this.property)?"[".concat(this.property,"]"):"".concat(r?".":"").concat(this.property);return this.constraints?s(c):this.children?this.children.map((function(e){return e.toString(t,!0,"".concat(r).concat(c),n)})).join(""):""}return"An instance of ".concat(a).concat(this.target?this.target.constructor.name:"an object").concat(i," has failed the validation:\n")+(this.constraints?s(this.property):"")+(this.children?this.children.map((function(e){return e.toString(t,!0,o.property,n)})).join(""):"")},t}(),X=function(){function t(){}return t.isValid=function(t){var e=this;return"isValid"!==t&&"getMessage"!==t&&-1!==Object.keys(this).map((function(t){return e[t]})).indexOf(t)},t.CUSTOM_VALIDATION="customValidation",t.NESTED_VALIDATION="nestedValidation",t.PROMISE_VALIDATION="promiseValidation",t.CONDITIONAL_VALIDATION="conditionalValidation",t.WHITELIST="whitelistValidation",t.IS_DEFINED="isDefined",t}();var Z=function(){function t(){}return t.replaceMessageSpecialTokens=function(t,e){var r;return t instanceof Function?r=t(e):"string"==typeof t&&(r=t),r&&Array.isArray(e.constraints)&&e.constraints.forEach((function(t,e){r=r.replace(new RegExp("\\$constraint".concat(e+1),"g"),function(t){return Array.isArray(t)?t.join(", "):("symbol"==typeof t&&(t=t.description),"".concat(t))}(t))})),r&&void 0!==e.value&&null!==e.value&&["string","boolean","number"].includes(typeof e.value)&&(r=r.replace(/\$value/g,e.value)),r&&(r=r.replace(/\$property/g,e.property)),r&&(r=r.replace(/\$target/g,e.targetName)),r},t}(),tt=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},et=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=function(){var t=K();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new Y),t.classValidatorMetadataStorage}()}return t.prototype.execute=function(t,e,r){var n,o,a=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(n=this.validatorOptions)||void 0===n?void 0:n.enableDebugMessages)||console.warn("No validation metadata found. No validation will be performed. There are multiple possible reasons:\n - There may be multiple class-validator versions installed. You will need to flatten your dependencies to fix the issue.\n - This validation runs before any file with validation decorator was parsed by NodeJS.");var i=this.validatorOptions?this.validatorOptions.groups:void 0,s=this.validatorOptions&&this.validatorOptions.strictGroups||!1,c=this.validatorOptions&&this.validatorOptions.always||!1,l=void 0===(null===(o=this.validatorOptions)||void 0===o?void 0:o.forbidUnknownValues)||!1!==this.validatorOptions.forbidUnknownValues,u=this.metadataStorage.getTargetValidationMetadatas(t.constructor,e,c,s,i),p=this.metadataStorage.groupByPropertyName(u);if(this.validatorOptions&&l&&!u.length){var f=new Q;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(f.target=t),f.value=void 0,f.property=void 0,f.children=[],f.constraints={unknownValue:"an unknown value was passed to the validate function"},void r.push(f)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(t,p,r),Object.keys(p).forEach((function(e){var n=t[e],o=p[e].filter((function(t){return t.type===X.IS_DEFINED})),i=p[e].filter((function(t){return t.type!==X.IS_DEFINED&&t.type!==X.WHITELIST}));n instanceof Promise&&i.find((function(t){return t.type===X.PROMISE_VALIDATION}))?a.awaitingPromises.push(n.then((function(n){a.performValidations(t,n,e,o,i,r)}))):a.performValidations(t,n,e,o,i,r)}))},t.prototype.whitelist=function(t,e,r){var n=this,o=[];Object.keys(t).forEach((function(t){e[t]&&0!==e[t].length||o.push(t)})),o.length>0&&(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?o.forEach((function(e){var o,a=n.generateValidationError(t,t[e],e);a.constraints=((o={})[X.WHITELIST]="property ".concat(e," should not exist"),o),a.children=void 0,r.push(a)})):o.forEach((function(e){return delete t[e]})))},t.prototype.stripEmptyErrors=function(t){var e=this;return t.filter((function(t){if(t.children&&(t.children=e.stripEmptyErrors(t.children)),0===Object.keys(t.constraints).length){if(0===t.children.length)return!1;delete t.constraints}return!0}))},t.prototype.performValidations=function(t,e,r,n,o,a){var i=o.filter((function(t){return t.type===X.CUSTOM_VALIDATION})),s=o.filter((function(t){return t.type===X.NESTED_VALIDATION})),c=o.filter((function(t){return t.type===X.CONDITIONAL_VALIDATION})),l=this.generateValidationError(t,e,r);a.push(l),this.conditionalValidations(t,e,c)&&(this.customValidations(t,e,n,l),this.mapContexts(t,e,n,l),void 0===e&&this.validatorOptions&&!0===this.validatorOptions.skipUndefinedProperties||null===e&&this.validatorOptions&&!0===this.validatorOptions.skipNullProperties||null==e&&this.validatorOptions&&!0===this.validatorOptions.skipMissingProperties||(this.customValidations(t,e,i,l),this.nestedValidations(e,s,l),this.mapContexts(t,e,o,l),this.mapContexts(t,e,i,l)))},t.prototype.generateValidationError=function(t,e,r){var n=new Q;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(n.target=t),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(n.value=e),n.property=r,n.children=[],n.constraints={},n},t.prototype.conditionalValidations=function(t,e,r){return r.map((function(r){return r.constraints[0](t,e)})).reduce((function(t,e){return t&&e}),!0)},t.prototype.customValidations=function(t,e,r,n){var o=this;r.forEach((function(r){o.metadataStorage.getTargetValidatorConstraints(r.constraintCls).forEach((function(a){if(!(a.async&&o.ignoreAsyncValidations||o.validatorOptions&&o.validatorOptions.stopAtFirstError&&Object.keys(n.constraints||{}).length>0)){var i={targetName:t.constructor?t.constructor.name:void 0,property:r.propertyName,object:t,value:e,constraints:r.constraints};if(r.each&&(Array.isArray(e)||e instanceof Set||e instanceof Map)){var s,c=((s=e)instanceof Map?Array.from(s.values()):Array.isArray(s)?s:Array.from(s)).map((function(t){return a.instance.validate(t,i)}));if(c.some((function(t){return H(t)}))){var l=c.map((function(t){return H(t)?t:Promise.resolve(t)})),u=Promise.all(l).then((function(i){if(!i.every((function(t){return t}))){var s=tt(o.createValidationError(t,e,r,a),2),c=s[0],l=s[1];n.constraints[c]=l,r.context&&(n.contexts||(n.contexts={}),n.contexts[c]=Object.assign(n.contexts[c]||{},r.context))}}));o.awaitingPromises.push(u)}else{if(!c.every((function(t){return t}))){var p=tt(o.createValidationError(t,e,r,a),2);y=p[0],m=p[1];n.constraints[y]=m}}}else{var f=a.instance.validate(e,i);if(H(f)){var d=f.then((function(i){if(!i){var s=tt(o.createValidationError(t,e,r,a),2),c=s[0],l=s[1];n.constraints[c]=l,r.context&&(n.contexts||(n.contexts={}),n.contexts[c]=Object.assign(n.contexts[c]||{},r.context))}}));o.awaitingPromises.push(d)}else if(!f){var h=tt(o.createValidationError(t,e,r,a),2),y=h[0],m=h[1];n.constraints[y]=m}}}}))}))},t.prototype.nestedValidations=function(t,e,r){var n=this;void 0!==t&&e.forEach((function(o){if((o.type===X.NESTED_VALIDATION||o.type===X.PROMISE_VALIDATION)&&!(n.validatorOptions&&n.validatorOptions.stopAtFirstError&&Object.keys(r.constraints||{}).length>0))if(Array.isArray(t)||t instanceof Set||t instanceof Map)(t instanceof Set?Array.from(t):t).forEach((function(o,a){n.performValidations(t,o,a.toString(),[],e,r.children)}));else if(t instanceof Object){var a="string"==typeof o.target?o.target:o.target.name;n.execute(t,a,r.children)}else{var i=tt(n.createValidationError(o.target,t,o),2),s=i[0],c=i[1];r.constraints[s]=c}}))},t.prototype.mapContexts=function(t,e,r,n){var o=this;return r.forEach((function(t){if(t.context){var e=void 0;if(t.type===X.CUSTOM_VALIDATION)e=o.metadataStorage.getTargetValidatorConstraints(t.constraintCls)[0];var r=o.getConstraintType(t,e);n.constraints[r]&&(n.contexts||(n.contexts={}),n.contexts[r]=Object.assign(n.contexts[r]||{},t.context))}}))},t.prototype.createValidationError=function(t,e,r,n){var o=t.constructor?t.constructor.name:void 0,a=this.getConstraintType(r,n),i={targetName:o,property:r.propertyName,object:t,value:e,constraints:r.constraints},s=r.message||"";return r.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||n&&n.instance.defaultMessage instanceof Function&&(s=n.instance.defaultMessage(i)),[a,Z.replaceMessageSpecialTokens(s,i)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),rt=function(t,e,r,n){return new(r||(r=Promise))((function(o,a){function i(t){try{c(n.next(t))}catch(t){a(t)}}function s(t){try{c(n.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,s)}c((n=n.apply(t,e||[])).next())}))},nt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},ot=function(){function t(){}return t.prototype.validate=function(t,e,r){return this.coreValidate(t,e,r)},t.prototype.validateOrReject=function(t,e,r){return rt(this,void 0,void 0,(function(){var n;return nt(this,(function(o){switch(o.label){case 0:return[4,this.coreValidate(t,e,r)];case 1:return(n=o.sent()).length?[2,Promise.reject(n)]:[2]}}))}))},t.prototype.validateSync=function(t,e,r){var n="string"==typeof t?e:t,o="string"==typeof t?t:void 0,a=new et(this,"string"==typeof t?r:e);a.ignoreAsyncValidations=!0;var i=[];return a.execute(n,o,i),a.stripEmptyErrors(i)},t.prototype.coreValidate=function(t,e,r){var n="string"==typeof t?e:t,o="string"==typeof t?t:void 0,a=new et(this,"string"==typeof t?r:e),i=[];return a.execute(n,o,i),Promise.all(a.awaitingPromises).then((function(){return a.stripEmptyErrors(i)}))},t}(),at=new(function(){function t(){this.instances=[]}return t.prototype.get=function(t){var e=this.instances.find((function(e){return e.type===t}));return e||(e={type:t,object:new t},this.instances.push(e)),e.object},t}());function it(t){return at.get(t)}function st(t,e,r){return"string"==typeof t?it(ot).validate(t,e,r):it(ot).validate(t,e)}function ct(t,e,r){return"string"==typeof t?it(ot).validateSync(t,e,r):it(ot).validateSync(t,e)}function lt(t,e,r,n){return void 0===r&&(r={}),void 0===n&&(n=""),t.reduce((function(t,r){var o=n?n+"."+r.property:r.property;if(r.constraints){var a=Object.keys(r.constraints)[0];t[o]={type:a,message:r.constraints[a]};var i=t[o];e&&i&&Object.assign(i,{types:r.constraints})}return r.children&&r.children.length&&lt(r.children,e,t,o),t}),r)}function ut(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),function(n,o,a){try{var i=e.validator,s=(c=t,l=n,u=e.transformer,z.plainToInstance(c,l,u));return Promise.resolve(("sync"===r.mode?ct:st)(s,i)).then((function(t){return t.length?{values:{},errors:L(lt(t,!a.shouldUseNativeValidation&&"all"===a.criteriaMode),a)}:(a.shouldUseNativeValidation&&k({},a),{values:r.raw?Object.assign({},n):s,errors:{}})}))}catch(t){return Promise.reject(t)}var c,l,u}}const pt=o.createWithEqualityFn()(n.persist((t=>({screens:null,user:null,screenPaths:{}})),{name:"app-store-1",storage:n.createJSONStorage((()=>localStorage)),partialize:t=>({user:t.user})}),a.shallow);function ft({menu:r,getIcons:n,onLogout:o}){const{screens:a,screenPaths:i}=pt((t=>({screens:t.screens??{},screenPaths:t.screenPaths??{}}))),[s,c]=t.useState(!0),l=e.useLocation(),u=e.useNavigate(),p=t=>{if("/"===t)return l.pathname===t;const e=t.replace(/^\/+|\/+$/g,""),r=l.pathname.replace(/^\/+|\/+$/g,"");return r===e||r.startsWith(`${e}/`)};return t.createElement("div",{className:"sidebar "+(s?"open":"closed")},t.createElement("button",{className:"toggle-button",onClick:()=>c(!s),"aria-label":s?"Collapse sidebar":"Expand sidebar","aria-expanded":s},s?"<":">"),t.createElement("nav",{className:"nav-links"},r?.(a).map(((r,o)=>t.createElement(e.Link,{key:o,to:r.path,className:"nav-link "+(p(r.path)?"active":""),"aria-current":p(r.path)?"page":void 0},t.createElement("span",{className:"nav-links-icon"},n?.(r.iconType)),s?t.createElement("span",null,r.name):null)))),o&&t.createElement("div",{className:"sidebar-footer"},t.createElement("button",{className:"logout-button",onClick:()=>{o&&(o(),u(i.login))},"aria-label":"Logout"},t.createElement("span",{className:"nav-links-icon"},t.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t.createElement("path",{d:"M6 12H2V4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{d:"M10 8L14 4M14 4L10 0M14 4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))),s?t.createElement("span",null,"Logout"):null)))}exports.Cell=y,exports.Counter=function({image:e,text:r,targetNumber:n,duration:o=2e3}){const[a,i]=t.useState(0);return t.useEffect((()=>{let t,e;const r=a=>{t||(t=a);const s=a-t,c=Math.min(s/o,1);i(Math.floor(c*n)),c<1&&(e=requestAnimationFrame(r))};return e=requestAnimationFrame(r),()=>{e&&cancelAnimationFrame(e)}}),[n,o]),t.createElement("div",{className:"counter-container"},t.createElement("div",{className:"counter-image"},e),t.createElement("div",{className:"counter-text"},r),t.createElement("div",{className:"counter-value"},a))},exports.Crud=function(t){return e=>{t&&Reflect.defineMetadata("Crud",t,e)}},exports.FormPage=function({model:e,getDetailsData:r,onSubmit:n,redirect:o,...a}){const i=t.useMemo((()=>{return{resolver:ut(t=e),form:N(t),inputs:x(t)};var t}),[e]);return t.createElement(M,{getDetailsData:r,redirect:o,onSubmit:n,formOptions:i})},exports.ImageCell=function(t){return y({...t,type:"image"})},exports.Input=function(t){return(e,r)=>{const n=Reflect.getMetadata(A,e)||[];if(Reflect.defineMetadata(A,[...n,r.toString()],e),t){const n=`${A.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}},exports.Layout=function({children:r,menu:n,getIcons:o,logout:a}){const{user:i,screenPaths:s}=pt((t=>({user:t.user,screenPaths:t.screenPaths})));pt();const c=e.useNavigate();return i||c(s.login),t.createElement("div",{className:"layout"},t.createElement(ft,{onLogout:()=>{a&&a()},menu:n,getIcons:o}),t.createElement("main",{className:"content"},r))},exports.List=function(t){return e=>{t&&Reflect.defineMetadata(f,t,e)}},exports.ListPage=function({model:r,getData:n}){const[o,a]=t.useState(!0),[l,u]=t.useState({total:0,page:0,limit:0}),[p,f]=t.useState(null),[h,y]=t.useState(null),g=t.useMemo((()=>{return{list:d(t=r),cells:m(t)};var t}),[r]),E=e.useParams(),b=t.useCallback((async t=>{a(!0);try{const e=await n({page:t});f(e.data),u({total:e.total,page:e.page,limit:e.limit})}catch(t){y(t),console.error(t)}finally{a(!1)}}),[n]);return t.useEffect((()=>{b(parseInt(E.page)||1)}),[b,E.page]),o?t.createElement(c,null):h?t.createElement(s,{error:h}):t.createElement("div",{className:"list"},t.createElement("div",{className:"list-header"},t.createElement(e.Link,{to:"create"},"Create")),t.createElement(i,{cells:g.cells,data:p}),t.createElement("div",{className:"list-footer"},t.createElement(v,{pagination:l,onPageChange:t=>{b(t)}})))},exports.Login=function({onLogin:n}){const{register:o,handleSubmit:a,formState:{errors:i}}=r.useForm(),s=e.useNavigate();return t.createElement("div",{className:"login-container"},t.createElement("div",{className:"login-panel"},t.createElement("div",{className:"login-header"},t.createElement("h1",null,"Welcome Back"),t.createElement("p",null,"Please sign in to continue")),t.createElement("form",{onSubmit:a((async t=>{n.login(t.username,t.password).then((t=>{const{user:e,token:r}=t;localStorage.setItem("token",r),pt.setState({user:e}),s("/")}))})),className:"login-form"},t.createElement(O,{input:{name:"username",label:"Username",placeholder:"Enter your username",type:"input"},register:o,error:i.username}),t.createElement(O,{input:{name:"password",label:"Password",inputType:"password",placeholder:"Enter your password",type:"input"},register:o,error:i.password}),t.createElement("div",{className:"form-actions"},t.createElement("button",{type:"submit",className:"submit-button"},"Sign In")))))},exports.Panel=function({children:e,init:r}){return t.useEffect((()=>{!function({screenPaths:t}){pt.setState({screenPaths:t})}(r())}),[r]),t.createElement(T,null,e)};
package/dist/index.d.ts CHANGED
@@ -1,10 +1,19 @@
1
- export { Login } from "./components/screens/Login";
2
- export { type InitPanelOptions } from "./types/initPanelOptions";
3
- export { type ScreenCreatorData } from "./types/ScreenCreatorData";
4
- export { createScreens } from "./utils/createScreens";
5
- export { useScreens } from "./hooks/useScreens";
6
- export { Crud } from "./decorators/Crud";
7
- export { Cell } from "./decorators/Cell";
8
- export { Input } from "./decorators/Input";
9
- export { Layout } from "./components/layout/Layout";
10
- export { Panel } from "./components/Panel";
1
+ export type { OnSubmitFN, GetDetailsDataFN } from './components/pages/FormPage';
2
+ export type { GetDataForList } from './components/pages/ListPage';
3
+ export type { PaginatedResponse, PaginationParams } from './components/pages/ListPage';
4
+ export type { InitPanelOptions } from './types/initPanelOptions';
5
+ export type { ScreenCreatorData } from './types/ScreenCreatorData';
6
+ export type { OnLogin } from './components/pages/Login';
7
+ export type { AnyClass } from './types/AnyClass';
8
+ export { ListPage } from './components/pages/ListPage';
9
+ export { FormPage } from './components/pages/FormPage';
10
+ export type { FormPageProps } from './components/pages/FormPage';
11
+ export { Login } from './components/pages/Login';
12
+ export { Layout } from './components/layout/Layout';
13
+ export { Panel } from './components/Panel';
14
+ export { Counter } from './components/components/Counter';
15
+ export { List } from './decorators/list/List';
16
+ export { ImageCell } from './decorators/list/ImageCell';
17
+ export { Crud } from './decorators/Crud';
18
+ export { Cell } from './decorators/list/Cell';
19
+ export { Input } from './decorators/form/Input';