proje-react-panel 1.0.14 → 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.
- package/.cursor/rules.md +122 -0
- package/.cursor/settings.json +57 -0
- package/.eslintrc.js +5 -0
- package/.eslintrc.json +26 -0
- package/.prettierrc +10 -0
- package/.vscode/launch.json +17 -0
- package/.vscode/settings.json +8 -0
- package/PTD.md +234 -0
- package/README.md +62 -28
- package/dist/api/CrudApi.d.ts +12 -0
- package/dist/components/Panel.d.ts +2 -2
- package/dist/components/components/Checkbox.d.ts +6 -0
- package/dist/components/components/Counter.d.ts +9 -0
- package/dist/components/components/FormField.d.ts +12 -0
- package/dist/components/components/ImageUploader.d.ts +15 -0
- package/dist/components/components/InnerForm.d.ts +12 -0
- package/dist/components/components/LoadingScreen.d.ts +2 -0
- package/dist/components/components/index.d.ts +8 -0
- package/dist/components/layout/Layout.d.ts +2 -1
- package/dist/components/layout/SideBar.d.ts +4 -3
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/list/Datagrid.d.ts +8 -0
- package/dist/components/list/Pagination.d.ts +11 -0
- package/dist/components/list/index.d.ts +0 -0
- package/dist/{src/screens → components/pages}/ControllerDetails.d.ts +1 -1
- package/dist/components/pages/FormPage.d.ts +11 -0
- package/dist/components/pages/ListPage.d.ts +17 -0
- package/dist/components/pages/Login.d.ts +13 -0
- package/dist/decorators/form/Form.d.ts +6 -0
- package/dist/decorators/form/FormOptions.d.ts +7 -0
- package/dist/decorators/form/Input.d.ts +13 -0
- package/dist/decorators/form/getFormFields.d.ts +3 -0
- package/dist/decorators/{Cell.d.ts → list/Cell.d.ts} +2 -2
- package/dist/decorators/list/GetCellFields.d.ts +2 -0
- package/dist/decorators/list/ImageCell.d.ts +6 -0
- package/dist/decorators/list/List.d.ts +5 -0
- package/dist/decorators/list/ListData.d.ts +6 -0
- package/dist/decorators/list/getListFields.d.ts +2 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +19 -10
- package/dist/index.esm.js +1 -1
- package/dist/initPanel.d.ts +2 -2
- package/dist/store/store.d.ts +1 -5
- package/dist/types/AnyClass.d.ts +1 -0
- package/dist/types/ScreenCreatorData.d.ts +5 -3
- package/dist/types/initPanelOptions.d.ts +0 -6
- package/dist/utils/format.d.ts +1 -0
- package/dist/utils/getFields.d.ts +2 -1
- package/package.json +5 -4
- package/src/api/CrudApi.ts +30 -11
- package/src/components/Panel.tsx +11 -11
- package/src/components/components/Checkbox.tsx +9 -0
- package/src/components/components/Counter.tsx +51 -0
- package/src/components/components/FormField.tsx +60 -0
- package/src/components/components/ImageUploader.tsx +301 -0
- package/src/components/components/InnerForm.tsx +75 -0
- package/src/components/components/LoadingScreen.tsx +12 -0
- package/src/components/components/index.ts +8 -0
- package/src/components/layout/Layout.tsx +8 -1
- package/src/components/layout/SideBar.tsx +103 -31
- package/src/components/layout/index.ts +2 -0
- package/src/components/list/Datagrid.tsx +101 -0
- package/src/components/list/Pagination.tsx +110 -0
- package/src/components/list/index.ts +1 -0
- package/src/components/pages/ControllerDetails.tsx +37 -0
- package/src/components/pages/FormPage.tsx +32 -0
- package/src/components/pages/ListPage.tsx +85 -0
- package/src/components/pages/Login.tsx +79 -0
- package/src/decorators/form/Form.ts +18 -0
- package/src/decorators/form/FormOptions.ts +8 -0
- package/src/decorators/form/Input.ts +52 -0
- package/src/decorators/form/getFormFields.ts +13 -0
- package/src/decorators/{Cell.ts → list/Cell.ts} +2 -14
- package/src/decorators/list/GetCellFields.ts +13 -0
- package/src/decorators/list/ImageCell.ts +13 -0
- package/src/decorators/list/List.ts +17 -0
- package/src/decorators/list/ListData.ts +7 -0
- package/src/decorators/list/getListFields.ts +10 -0
- package/src/index.ts +23 -10
- package/src/initPanel.ts +4 -12
- package/src/store/store.ts +23 -28
- package/src/styles/_scrollbar.scss +19 -0
- package/src/styles/counter.scss +42 -0
- package/src/styles/image-uploader.scss +94 -0
- package/src/styles/index.scss +30 -7
- package/src/styles/layout.scss +1 -6
- package/src/styles/list.scss +32 -5
- package/src/styles/loading-screen.scss +42 -0
- package/src/styles/pagination.scss +66 -0
- package/src/styles/sidebar.scss +64 -0
- package/src/types/AnyClass.ts +1 -0
- package/src/types/ScreenCreatorData.ts +5 -3
- package/src/types/initPanelOptions.ts +1 -7
- package/src/utils/format.ts +7 -0
- package/src/utils/getFields.ts +11 -9
- package/dist/api/crudApi.d.ts +0 -17
- package/dist/components/Form.d.ts +0 -6
- package/dist/components/FormField.d.ts +0 -13
- package/dist/components/list/List.d.ts +0 -10
- package/dist/components/screens/ControllerCreate.d.ts +0 -5
- package/dist/components/screens/ControllerDetails.d.ts +0 -5
- package/dist/components/screens/ControllerEdit.d.ts +0 -5
- package/dist/components/screens/ControllerList.d.ts +0 -5
- package/dist/components/screens/Login.d.ts +0 -2
- package/dist/decorators/Input.d.ts +0 -13
- package/dist/hooks/useScreens.d.ts +0 -2
- package/dist/initPanelOptions.d.ts +0 -8
- package/dist/screens/ControllerCreate.d.ts +0 -5
- package/dist/screens/ControllerDetails.d.ts +0 -5
- package/dist/screens/ControllerEdit.d.ts +0 -5
- package/dist/screens/ControllerList.d.ts +0 -5
- package/dist/screens/Form.d.ts +0 -6
- package/dist/src/api/crudApi.d.ts +0 -6
- package/dist/src/components/Panel.d.ts +0 -9
- package/dist/src/components/layout/Layout.d.ts +0 -11
- package/dist/src/components/layout/SideBar.d.ts +0 -10
- package/dist/src/components/list/List.d.ts +0 -10
- package/dist/src/decorators/Cell.d.ts +0 -10
- package/dist/src/decorators/Crud.d.ts +0 -6
- package/dist/src/index.d.ts +0 -8
- package/dist/src/screens/ControllerCreate.d.ts +0 -5
- package/dist/src/screens/ControllerEdit.d.ts +0 -5
- package/dist/src/screens/ControllerList.d.ts +0 -5
- package/dist/src/screens/Form.d.ts +0 -6
- package/dist/src/store/store.d.ts +0 -19
- package/dist/src/types/Screen.d.ts +0 -4
- package/dist/src/types/ScreenCreatorData.d.ts +0 -8
- package/dist/src/utils/createScreens.d.ts +0 -1
- package/dist/src/utils/getFields.d.ts +0 -2
- package/dist/src/utils/getScreens.d.ts +0 -2
- package/dist/utils/crudScreens.d.ts +0 -2
- package/dist/utils/getScreens.d.ts +0 -2
- package/src/api/AuthApi.ts +0 -14
- package/src/components/Form.tsx +0 -70
- package/src/components/FormField.tsx +0 -60
- package/src/components/list/List.tsx +0 -81
- package/src/components/screens/ControllerCreate.tsx +0 -7
- package/src/components/screens/ControllerDetails.tsx +0 -40
- package/src/components/screens/ControllerEdit.tsx +0 -35
- package/src/components/screens/ControllerList.tsx +0 -45
- package/src/components/screens/Login.tsx +0 -68
- package/src/decorators/Input.ts +0 -50
- package/src/hooks/useScreens.tsx +0 -36
- /package/dist/components/{ErrorBoundary.d.ts → components/ErrorBoundary.d.ts} +0 -0
- /package/dist/components/{ErrorComponent.d.ts → components/ErrorComponent.d.ts} +0 -0
- /package/dist/components/{Label.d.ts → components/Label.d.ts} +0 -0
- /package/src/components/{ErrorBoundary.tsx → components/ErrorBoundary.tsx} +0 -0
- /package/src/components/{ErrorComponent.tsx → components/ErrorComponent.tsx} +0 -0
- /package/src/components/{Label.tsx → components/Label.tsx} +0 -0
package/dist/index.esm.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import t,{useEffect as e,useState as r,useMemo as n,Component as o}from"react";import{useForm as a,get as i,set as s}from"react-hook-form";import{persist as c,createJSONStorage as u}from"zustand/middleware";import{createWithEqualityFn as l}from"zustand/traditional";import{shallow as p}from"zustand/vanilla/shallow";import{useNavigate as f,useParams as d,Link as h,Route as y}from"react-router";function v({htmlFor:e,label:r,fieldName:n}){return t.createElement("label",{htmlFor:e},r??n.charAt(0).toUpperCase()+n.slice(1))}function m({input:e,register:r,isEditForm:n,error:o}){const a=e.name||"";return t.createElement("div",{className:"form-field"},t.createElement(v,{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 g=(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})),S=l()(c((t=>({screens:null,user:null,fetchSettings:null,screenPaths:{},token:null})),{name:"app-store-1",storage:u((()=>localStorage)),partialize:t=>({user:t.user,token:t.token})}),p);function _(){const{register:e,handleSubmit:r,formState:{errors:n}}=a(),{fetchSettings:o}=S((t=>({fetchSettings:t.fetchSettings}))),i=f();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:r((async t=>{g(o,t.username,t.password).then((t=>{const{access_token:e,admin:r}=t;S.setState({user:r,token:e}),i("/")}))})),className:"login-form"},t.createElement(m,{input:{name:"username",label:"Username",inputType:"text",placeholder:"Enter your username"},register:e,isEditForm:!1,error:n.username}),t.createElement(m,{input:{name:"password",label:"Password",inputType:"password",placeholder:"Enter your password"},register:e,isEditForm:!1,error:n.password}),t.createElement("div",{className:"form-actions"},t.createElement("button",{type:"submit",className:"submit-button"},"Sign In")))))}function O(t){S.setState({screens:t})}const E=(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})),w=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then((t=>t.json())),b=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}/${r}`,{method:"GET",headers:{"Content-Type":"application/json"}}).then((t=>t.json())),T=(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 M({data:r,screen:n}){const{screens:o,fetchSettings:i}=S((t=>({screens:t.screens??{},fetchSettings:t.fetchSettings}))),s=!!r,{register:c,handleSubmit:u,reset:l,formState:{errors:p}}=a({resolver:o[n.controller].resolver,defaultValues:{...r,__formEdit:s}}),d=f(),h=o[n.controller].inputs;return e((()=>{l({...r,__formEdit:s})}),[s,r,l]),t.createElement("div",{className:"form-wrapper"},t.createElement("form",{onSubmit:u((t=>{i&&(delete t.__formEdit,s?T(i,n.controller,t).then((()=>{d("/"+n.controller,{replace:!0})})):w(i,n.controller,t).then((()=>{d("/"+n.controller,{replace:!0})})))}))},h.map((e=>t.createElement(m,{key:e.name||"",input:e,register:c,isEditForm:s,error:p[e.name||""]}))),t.createElement("button",{type:"submit",className:"submit-button"},"Submit")))}function A({screen:e}){return t.createElement(M,{screen:e})}function x({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 N({screen:n}){const{fetchSettings:o}=S((t=>({fetchSettings:t.fetchSettings}))),{id:a}=d(),[i,s]=r(null),[c,u]=r(null);return e((()=>{o&&n.controller&&a&&b(o,n.controller,a).then((t=>{s(t)})).catch((t=>{u(t),console.error(t)}))}),[o,a,n]),c?t.createElement(x,{error:c}):t.createElement("p",{dangerouslySetInnerHTML:{__html:JSON.stringify(i,null," <br/>")}})}function C({screen:n}){const{fetchSettings:o}=S((t=>({fetchSettings:t.fetchSettings}))),{id:a}=d(),[i,s]=r(null),[c,u]=r(null);return e((()=>{o&&n.controller&&a&&b(o,n.controller,a).then((t=>{s(t)})).catch((t=>{u(t),console.error(t)}))}),[o,a,n]),c?t.createElement(x,{error:c}):t.createElement(M,{data:i,screen:n})}function P({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(h,{to:"edit/"+(e?.id??"-")},"Edit"),t.createElement(h,{to:"details/"+(e?.id??"-")},"Details")))))))):t.createElement("div",null,"No items available")}function k({screen:n}){const{screens:o,fetchSettings:a,token:i}=S((t=>({screens:t.screens??{},fetchSettings:t.fetchSettings,token:t.token}))),[s,c]=r(0),[u,l]=r(null),[p,f]=r(null);return e((()=>{n.controller&&a&&i&&E({...a,token:i},n.controller).then((t=>{l(t)})).catch((t=>{f(t),console.error(t)}))}),[s,n.controller,a]),p?t.createElement(x,{error:p}):t.createElement("div",null,t.createElement(h,{to:"create"},"Create"),t.createElement(P,{screen:n,cells:o[n.key].cells,data:u}))}function L(){const e=S((t=>t.screens??{}));return n((()=>t.createElement(t.Fragment,null,Object.entries(e).map((([e,r])=>{const n=r.crud?.controller??e;let o=`${r.path}`;const a={key:e,controller:n};return t.createElement(t.Fragment,{key:"index"},t.createElement(y,{path:o+"/create",element:t.createElement(A,{screen:a})}),t.createElement(y,{path:o+"/details/:id",element:t.createElement(N,{screen:a})}),t.createElement(y,{path:o+"/edit/:id",element:t.createElement(C,{screen:a})}),t.createElement(y,{path:o,element:t.createElement(k,{screen:a})}))})),t.createElement(y,{path:"*",element:t.createElement("div",null,"404 - Not Found")}))),[e])}var I,j="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},V={};!function(){return I||(I=1,function(t){!function(){var e="object"==typeof globalThis?globalThis:"object"==typeof j?j:"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(!H(t))throw new TypeError;if(!J(e))throw new TypeError;return A(t,e)}if(!H(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=G(r),n)}function g(t,e){function r(r,n){if(!$(r))throw new TypeError;if(!D(n)&&!q(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=G(n)),L(t,e,r,n)}function _(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),N(t,e,r)}function O(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),C(t,e,r)}function E(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),P(t,e,r)}function w(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),k(t,e,r)}function b(t,e){if(!$(t))throw new TypeError;return D(e)||(e=G(e)),I(t,e)}function T(t,e){if(!$(t))throw new TypeError;return D(e)||(e=G(e)),j(t,e)}function M(t,e,r){if(!$(e))throw new TypeError;if(D(r)||(r=G(r)),!$(e))throw new TypeError;D(r)||(r=G(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(!J(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 P(t,e,r){if(C(t,e,r))return k(t,e,r);var n=rt(e);return F(n)?void 0:P(t,n,r)}function k(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 G(t){var e=U(t);return R(e)?e:K(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 J(t){return"function"==typeof t}function q(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",O),t("getMetadata",E),t("getOwnMetadata",w),t("getMetadataKeys",b),t("getOwnMetadataKeys",T),t("deleteMetadata",M)}(r,e),void 0===e.Reflect&&(e.Reflect=t)}()}(t||(t={}))),V;var t}();const D="Crud";function F(t){return e=>{t&&Reflect.defineMetadata(D,t,e)}}const R=Symbol("cell");function $(t){return(e,r)=>{const n=Reflect.getMetadata(R,e)||[];if(Reflect.defineMetadata(R,[...n,r.toString()],e),t){const n=`${R.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}}function U(t){const e=t.prototype;return(Reflect.getMetadata(R,e)||[]).map((t=>{const r=Reflect.getMetadata(`${R.toString()}:${t}:options`,e)||{};return{...r,name:r?.name??t}}))}const z=Symbol("input");function B(t){return(e,r)=>{const n=Reflect.getMetadata(z,e)||[];if(Reflect.defineMetadata(z,[...n,r.toString()],e),t){const n=`${z.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}}function K(t){const e=t.prototype;return(Reflect.getMetadata(z,e)||[]).map((t=>{const r=Reflect.getMetadata(`${z.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 G({menu:e,getIcons:n}){const o=S((t=>t.screens??{})),[a,i]=r(!0);return t.createElement("div",{className:"sidebar "+(a?"open":"closed")},t.createElement("button",{className:"toggle-button",onClick:()=>i(!a)},a?"<":">"),t.createElement("nav",{className:"nav-links"},e?.(o).map(((e,r)=>t.createElement(h,{key:r,to:e.path,className:"nav-link"},t.createElement("span",{className:"nav-links-icon"},n?.(e.iconType)),a?t.createElement("span",null,e.name):null)))))}function H({children:e,menu:r,getIcons:n}){const{user:o,screenPaths:a}=S((t=>({user:t.user,screenPaths:t.screenPaths}))),i=f();return o||i(a.login),t.createElement("div",{className:"layout"},t.createElement(G,{menu:r,getIcons:n}),t.createElement("main",{className:"content"},e))}class W extends o{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 J=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 J(a))}))})),e},t}();function Y(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function Q(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var X=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.")},Z=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},tt=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))},et=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)},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=X(this.validationMetadatas.entries()),f=p.next();!f.done;f=p.next()){var d=Z(f.value,2),h=d[0],y=d[1];t.prototype instanceof h&&l.push.apply(l,tt([],Z(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 rt(){var t=Y();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new et),t.classValidatorMetadataStorage}var nt=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?"[1m":"",i=t?"[22m":"",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}(),ot=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 at=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}(),it=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},st=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=rt()}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 nt;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===ot.IS_DEFINED})),i=p[e].filter((function(t){return t.type!==ot.IS_DEFINED&&t.type!==ot.WHITELIST}));n instanceof Promise&&i.find((function(t){return t.type===ot.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={})[ot.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===ot.CUSTOM_VALIDATION})),s=o.filter((function(t){return t.type===ot.NESTED_VALIDATION})),c=o.filter((function(t){return t.type===ot.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 nt;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 Q(t)}))){var u=c.map((function(t){return Q(t)?t:Promise.resolve(t)})),l=Promise.all(u).then((function(i){if(!i.every((function(t){return t}))){var s=it(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=it(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(Q(f)){var d=f.then((function(i){if(!i){var s=it(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=it(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===ot.NESTED_VALIDATION||o.type===ot.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=it(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===ot.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,at.replaceMessageSpecialTokens(s,i)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),ct=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())}))},ut=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])}}},lt=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 ct(this,void 0,void 0,(function(){var n;return ut(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 st(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 st(this,"string"==typeof t?r:e),i=[];return a.execute(n,o,i),Promise.all(a.awaitingPromises).then((function(){return a.stripEmptyErrors(i)}))},t}(),pt=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 ft(t){return pt.get(t)}function dt(t,e,r){return"string"==typeof t?ft(lt).validate(t,e,r):ft(lt).validate(t,e)}function ht(t,e,r){return"string"==typeof t?ft(lt).validateSync(t,e,r):ft(lt).validateSync(t,e)}const yt=(t,e,r)=>{if(t&&"reportValidity"in t){const n=i(r,e);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},vt=(t,e)=>{for(const r in e.fields){const n=e.fields[r];n&&n.ref&&"reportValidity"in n.ref?yt(n.ref,r,t):n&&n.refs&&n.refs.forEach((e=>yt(e,r,t)))}},mt=(t,e)=>{e.shouldUseNativeValidation&&vt(t,e);const r={};for(const n in t){const o=i(e.fields,n),a=Object.assign(t[n]||{},{ref:o&&o.ref});if(gt(e.names||Object.keys(t),n)){const t=Object.assign({},i(r,n));s(t,"root",a),s(r,n,t)}else s(r,n,a)}return r},gt=(t,e)=>{const r=St(e);return t.some((t=>St(t).match(`^${r}\\.\\d+`)))};function St(t){return t.replace(/\]|\[/g,"")}var _t;!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"}(_t||(_t={}));var Ot=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===_t.CLASS_TO_CLASS||r===_t.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||r===_t.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===_t.CLASS_TO_CLASS||e===_t.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===_t.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===_t.CLASS_TO_CLASS||e===_t.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===_t.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 Et=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 wt=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===_t.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===_t.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===_t.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===_t.CLASS_TO_CLASS&&(i=e.constructor),s.transformationType===_t.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!==_t.PLAIN_TO_CLASS&&this.transformationType!==_t.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===_t.PLAIN_TO_CLASS)(u=Ot.findExposeMetadataByCustomName(r,n))&&(c=u.propertyName,s=u.propertyName);else if(f.transformationType===_t.CLASS_TO_PLAIN||f.transformationType===_t.CLASS_TO_CLASS){var u;(u=Ot.findExposeMetadata(r,n))&&u.options&&u.options.name&&(s=u.options.name)}var p=void 0;p=f.transformationType===_t.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=Ot.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===_t.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===_t.CLASS_TO_CLASS&&(d=p.constructor),f.transformationType===_t.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===_t.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 O=Object.getOwnPropertyDescriptor(l.constructor.prototype,s);if((f.transformationType===_t.PLAIN_TO_CLASS||f.transformationType===_t.CLASS_TO_CLASS)&&(O&&!O.set||l[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(p)){if(f.transformationType===_t.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 E=f.transformationType===_t.PLAIN_TO_CLASS?s:n,w=void 0;f.transformationType===_t.CLASS_TO_PLAIN?(w=e[E],w=f.applyCustomTransformations(w,r,E,e,f.transformationType),w=e[E]===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,E,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=Ot.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=Ot.findTypeMetadata(t,e);return r?r.reflectedType:void 0}},t.prototype.getKeys=function(t,e,r){var n=this,o=Ot.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=Ot.getExposedProperties(t,this.transformationType),s=Ot.getExcludedProperties(t,this.transformationType);a=Et(Et([],i,!0),s,!0)}if(!this.options.ignoreDecorators&&t){i=Ot.getExposedProperties(t,this.transformationType);this.transformationType===_t.PLAIN_TO_CLASS&&(i=i.map((function(e){var r=Ot.findExposeMetadata(t,e);return r&&r.options&&r.options.name?r.options.name:e}))),a=this.options.excludeExtraneousValues?i:a.concat(i);var c=Ot.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=Ot.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=Ot.findExposeMetadata(t,e);return!r||!r.options||n.checkGroups(r.options.groups)})):a.filter((function(e){var r=Ot.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}(),bt={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},Tt=function(){return Tt=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},Tt.apply(this,arguments)},Mt=new(function(){function t(){}return t.prototype.instanceToPlain=function(t,e){return new wt(_t.CLASS_TO_PLAIN,Tt(Tt({},bt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,r){return new wt(_t.CLASS_TO_PLAIN,Tt(Tt({},bt),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToInstance=function(t,e,r){return new wt(_t.PLAIN_TO_CLASS,Tt(Tt({},bt),r)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,r){return new wt(_t.PLAIN_TO_CLASS,Tt(Tt({},bt),r)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.instanceToInstance=function(t,e){return new wt(_t.CLASS_TO_CLASS,Tt(Tt({},bt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,r){return new wt(_t.CLASS_TO_CLASS,Tt(Tt({},bt),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 At(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&&At(r.children,e,t,o),t}),r)}function xt(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,Mt.plainToInstance(c,u,l));return Promise.resolve(("sync"===r.mode?ht:dt)(s,i)).then((function(t){return t.length?{values:{},errors:mt(At(t,!a.shouldUseNativeValidation&&"all"===a.criteriaMode),a)}:(a.shouldUseNativeValidation&&vt({},a),{values:r.raw?Object.assign({},n):s,errors:{}})}))}catch(t){return Promise.reject(t)}var c,u,l}}function Nt(t,e){const r=rt().getTargetValidationMetadatas(e,"",!1,!1),n=function(t){return Reflect.getMetadata(D,t)}(e);return{resolver:xt(e),fields:Array.from(new Set(r.map((t=>t.propertyName)))),inputs:K(e),cells:U(e),crud:n,path:"/"+(n?.controller??t)}}function Ct({children:r,init:n}){return e((()=>{!function({crud:t,fetch:e,screenPaths:r}){const n={};Object.entries(t).forEach((([t,e])=>{n[t]=Nt(t,e)})),O(n),S.setState({fetchSettings:{baseUrl:e.baseURL},screenPaths:r})}(n())}),[n]),t.createElement(W,null,r)}export{$ as Cell,F as Crud,B as Input,H as Layout,_ as Login,Ct as Panel,O as createScreens,L as useScreens};
|
1
|
+
import t,{useState as e,useMemo as r,useCallback as n,useEffect as o,Component as a}from"react";import{Link as i,useParams as s,useNavigate as c,useLocation as l}from"react-router";import{useFormContext as u,useForm as p,FormProvider as f,get as d,set as h}from"react-hook-form";import{persist as y,createJSONStorage as m}from"zustand/middleware";import{createWithEqualityFn as v}from"zustand/traditional";import{shallow as g}from"zustand/vanilla/shallow";function E({data:e,cells:r}){return e&&0!==e.length?t.createElement("div",{className:"datagrid"},t.createElement("table",{className:"datagrid-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("th",null,"Delete"))),t.createElement("tbody",null,e.map(((e,n)=>t.createElement("tr",{key:n},r.map((r=>{const n=e[r.name];let o=n??"-";switch(r.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 e=r;o=t.createElement("img",{width:100,height:100,src:e.baseUrl+n,style:{objectFit:"contain"}});break}default:o=n?n.toString():r?.placeHolder??"-"}return t.createElement("td",{key:r.name},o)})),t.createElement("td",null,t.createElement(i,{to:"edit/"+(e?.id??"-")},"Edit"),t.createElement(i,{to:"details/"+(e?.id??"-")},"Details")),t.createElement("td",null,t.createElement("button",{onClick:()=>{}},"Delete")))))))):t.createElement("div",null,"No items available")}function b({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 w(){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 _,O="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},S={};!function(){return _||(_=1,function(t){!function(){var e="object"==typeof globalThis?globalThis:"object"==typeof O?O:"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(!W(t))throw new TypeError;if(!q(e))throw new TypeError;return A(t,e)}if(!W(t))throw new TypeError;if(!B(e))throw new TypeError;if(!B(n)&&!D(n)&&!R(n))throw new TypeError;return R(n)&&(n=void 0),x(t,e,r=H(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=H(n)),P(t,e,r,n)}function b(t,e,r){if(!B(e))throw new TypeError;return D(r)||(r=H(r)),N(t,e,r)}function w(t,e,r){if(!B(e))throw new TypeError;return D(r)||(r=H(r)),C(t,e,r)}function _(t,e,r){if(!B(e))throw new TypeError;return D(r)||(r=H(r)),k(t,e,r)}function O(t,e,r){if(!B(e))throw new TypeError;return D(r)||(r=H(r)),L(t,e,r)}function S(t,e){if(!B(t))throw new TypeError;return D(e)||(e=H(e)),I(t,e)}function M(t,e){if(!B(t))throw new TypeError;return D(e)||(e=H(e)),V(t,e)}function T(t,e,r){if(!B(e))throw new TypeError;if(D(r)||(r=H(r)),!B(e))throw new TypeError;D(r)||(r=H(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)&&!R(n)){if(!q(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)&&!R(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!R(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 R(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 R(t){return null===t}function F(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(G(o)&&!B(n=o.call(t)))return n;if(G(r=t.valueOf)&&!B(n=r.call(t)))return n;throw new TypeError}function U(t){return!!t}function K(t){return""+t}function H(t){var e=$(t);return F(e)?e:K(e)}function W(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function G(t){return"function"==typeof t}function q(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(!G(r))throw new TypeError;return r}}function X(t){var e=Q(t,a);if(!G(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",w),t("getMetadata",_),t("getOwnMetadata",O),t("getMetadataKeys",S),t("getOwnMetadataKeys",M),t("deleteMetadata",T)}(r,e),void 0===e.Reflect&&(e.Reflect=t)}()}(t||(t={}))),S;var t}();const M="List";function T(t){return e=>{t&&Reflect.defineMetadata(M,t,e)}}function A(t){return Reflect.getMetadata(M,t)}const x=Symbol("cell");function N(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)}}}function C(t){const e=t.prototype;return(Reflect.getMetadata(x,e)||[]).map((t=>{const r=Reflect.getMetadata(`${x.toString()}:${t}:options`,e)||{};return{...r,name:r?.name??t}}))}function k({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 L({model:a,getData:c}){const[l,u]=e(!0),[p,f]=e({total:0,page:0,limit:0}),[d,h]=e(null),[y,m]=e(null),v=r((()=>{return{list:A(t=a),cells:C(t)};var t}),[a]),g=s(),_=n((async t=>{u(!0);try{const e=await c({page:t});h(e.data),f({total:e.total,page:e.page,limit:e.limit})}catch(t){m(t),console.error(t)}finally{u(!1)}}),[c]);return o((()=>{_(parseInt(g.page)||1)}),[_,g.page]),l?t.createElement(w,null):y?t.createElement(b,{error:y}):t.createElement("div",{className:"list"},t.createElement("div",{className:"list-header"},t.createElement(i,{to:"create"},"Create")),t.createElement(E,{cells:v.cells,data:d}),t.createElement("div",{className:"list-footer"},t.createElement(k,{pagination:p,onPageChange:t=>{_(t)}})))}function P({htmlFor:e,label:r,fieldName:n}){return t.createElement("label",{htmlFor:e},r??n.charAt(0).toUpperCase()+n.slice(1))}const I=Object.freeze({BEFORE:"before",HOVER:"hover",AFTER:"after"});function V(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 j(){const{register:e,formState:{errors:r},watch:n,setValue:a,clearErrors:i,setError:s}=u(),c=n("uploader");return o((()=>{e("uploader",{required:!0})}),[e]),t.createElement("div",null,t.createElement("span",{className:"form-error",style:{bottom:2,top:"unset"}},"required"===r.uploader?.type&&"At least 1 image is required!","custom"===r.uploader?.type&&r.uploader.message?.toString()),t.createElement(D,{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 D(e){const[r,n]=t.useState(I.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(I.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(I.HOVER)},d=()=>{l((t=>t-1==0?(n(I.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(V,{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(I.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 R({id:e,...r}){return t.createElement("input",{type:"checkbox",id:e,className:"checkbox",...r})}function F({input:e,register:r,error:n}){const o=e.name||"";return t.createElement("div",{className:"form-field"},t.createElement(P,{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(j,null);case"checkbox":return t.createElement(R,{...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 B({formOptions:e,onSubmit:r,redirect:n,getDetailsData:a}){const i=s(),c=p({resolver:e.resolver}),l=e.inputs;return o((()=>{a&&a(i.id).then((t=>{c.reset({...t})}))}),[,c.reset]),t.createElement("div",{className:"form-wrapper"},t.createElement(f,{...c},t.createElement("form",{onSubmit:c.handleSubmit((async t=>{await r(t),n&&(window.location.href=n)}),((t,e)=>{console.log("error creating creation",t,e)}))},t.createElement("div",null,l?.map((e=>t.createElement(F,{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")))))}function $({image:r,text:n,targetNumber:a,duration:i=2e3}){const[s,c]=e(0);return o((()=>{let t,e;const r=n=>{t||(t=n);const o=n-t,s=Math.min(o/i,1);c(Math.floor(s*a)),s<1&&(e=requestAnimationFrame(r))};return e=requestAnimationFrame(r),()=>{e&&cancelAnimationFrame(e)}}),[a,i]),t.createElement("div",{className:"counter-container"},t.createElement("div",{className:"counter-image"},r),t.createElement("div",{className:"counter-text"},n),t.createElement("div",{className:"counter-value"},s))}class z extends a{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 U=Symbol("input");function K(t){return(e,r)=>{const n=Reflect.getMetadata(U,e)||[];if(Reflect.defineMetadata(U,[...n,r.toString()],e),t){const n=`${U.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}}function H(t){const e=t.prototype;return(Reflect.getMetadata(U,e)||[]).map((t=>{const r=Reflect.getMetadata(`${U.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 W(t){return Reflect.getMetadata("FormMetadata",t)}const G=(t,e,r)=>{if(t&&"reportValidity"in t){const n=d(r,e);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},q=(t,e)=>{for(const r in e.fields){const n=e.fields[r];n&&n.ref&&"reportValidity"in n.ref?G(n.ref,r,t):n&&n.refs&&n.refs.forEach((e=>G(e,r,t)))}},J=(t,e)=>{e.shouldUseNativeValidation&&q(t,e);const r={};for(const n in t){const o=d(e.fields,n),a=Object.assign(t[n]||{},{ref:o&&o.ref});if(Y(e.names||Object.keys(t),n)){const t=Object.assign({},d(r,n));h(t,"root",a),h(r,n,t)}else h(r,n,a)}return r},Y=(t,e)=>{const r=Q(e);return t.some((t=>Q(t).match(`^${r}\\.\\d+`)))};function Q(t){return t.replace(/\]|\[/g,"")}var X;!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"}(X||(X={}));var Z=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===X.CLASS_TO_CLASS||r===X.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||r===X.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===X.CLASS_TO_CLASS||e===X.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===X.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===X.CLASS_TO_CLASS||e===X.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===X.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}(),tt=new Z;var et=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 rt=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===X.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===X.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===X.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===X.CLASS_TO_CLASS&&(i=e.constructor),s.transformationType===X.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!==X.PLAIN_TO_CLASS&&this.transformationType!==X.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===X.PLAIN_TO_CLASS)(l=tt.findExposeMetadataByCustomName(r,n))&&(c=l.propertyName,s=l.propertyName);else if(f.transformationType===X.CLASS_TO_PLAIN||f.transformationType===X.CLASS_TO_CLASS){var l;(l=tt.findExposeMetadata(r,n))&&l.options&&l.options.name&&(s=l.options.name)}var p=void 0;p=f.transformationType===X.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=tt.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===X.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===X.CLASS_TO_CLASS&&(d=p.constructor),f.transformationType===X.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===X.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 w=Object.getOwnPropertyDescriptor(u.constructor.prototype,s);if((f.transformationType===X.PLAIN_TO_CLASS||f.transformationType===X.CLASS_TO_CLASS)&&(w&&!w.set||u[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(p)){if(f.transformationType===X.CLASS_TO_CLASS){O=p;(void 0!==(O=f.applyCustomTransformations(O,r,n,e,f.transformationType))||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,O):u[s]=O)}}else{var _=f.transformationType===X.PLAIN_TO_CLASS?s:n,O=void 0;f.transformationType===X.CLASS_TO_PLAIN?(O=e[_],O=f.applyCustomTransformations(O,r,_,e,f.transformationType),O=e[_]===O?p:O,O=f.transform(b,O,d,E,h,a+1)):void 0===p&&f.options.exposeDefaultValues?O=u[s]:(O=f.transform(b,p,d,E,h,a+1),O=f.applyCustomTransformations(O,r,_,e,f.transformationType)),(void 0!==O||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,O):u[s]=O)}},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=tt.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=tt.findTypeMetadata(t,e);return r?r.reflectedType:void 0}},t.prototype.getKeys=function(t,e,r){var n=this,o=tt.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=tt.getExposedProperties(t,this.transformationType),s=tt.getExcludedProperties(t,this.transformationType);a=et(et([],i,!0),s,!0)}if(!this.options.ignoreDecorators&&t){i=tt.getExposedProperties(t,this.transformationType);this.transformationType===X.PLAIN_TO_CLASS&&(i=i.map((function(e){var r=tt.findExposeMetadata(t,e);return r&&r.options&&r.options.name?r.options.name:e}))),a=this.options.excludeExtraneousValues?i:a.concat(i);var c=tt.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=tt.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=tt.findExposeMetadata(t,e);return!r||!r.options||n.checkGroups(r.options.groups)})):a.filter((function(e){var r=tt.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}(),nt={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},ot=function(){return ot=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},ot.apply(this,arguments)},at=new(function(){function t(){}return t.prototype.instanceToPlain=function(t,e){return new rt(X.CLASS_TO_PLAIN,ot(ot({},nt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,r){return new rt(X.CLASS_TO_PLAIN,ot(ot({},nt),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToInstance=function(t,e,r){return new rt(X.PLAIN_TO_CLASS,ot(ot({},nt),r)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,r){return new rt(X.PLAIN_TO_CLASS,ot(ot({},nt),r)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.instanceToInstance=function(t,e){return new rt(X.CLASS_TO_CLASS,ot(ot({},nt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,r){return new rt(X.CLASS_TO_CLASS,ot(ot({},nt),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 it=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)},st=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 it(a))}))})),e},t}();function ct(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function lt(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var ut=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.")},pt=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},ft=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))},dt=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 st).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=ut(this.validationMetadatas.entries()),f=p.next();!f.done;f=p.next()){var d=pt(f.value,2),h=d[0],y=d[1];t.prototype instanceof h&&u.push.apply(u,ft([],pt(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 ht=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?"[1m":"",i=t?"[22m":"",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}(),yt=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 mt=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}(),vt=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},gt=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=function(){var t=ct();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new dt),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 ht;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===yt.IS_DEFINED})),i=p[e].filter((function(t){return t.type!==yt.IS_DEFINED&&t.type!==yt.WHITELIST}));n instanceof Promise&&i.find((function(t){return t.type===yt.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={})[yt.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===yt.CUSTOM_VALIDATION})),s=o.filter((function(t){return t.type===yt.NESTED_VALIDATION})),c=o.filter((function(t){return t.type===yt.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 ht;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 lt(t)}))){var l=c.map((function(t){return lt(t)?t:Promise.resolve(t)})),u=Promise.all(l).then((function(i){if(!i.every((function(t){return t}))){var s=vt(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=vt(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(lt(f)){var d=f.then((function(i){if(!i){var s=vt(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=vt(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===yt.NESTED_VALIDATION||o.type===yt.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=vt(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===yt.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,mt.replaceMessageSpecialTokens(s,i)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),Et=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())}))},bt=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])}}},wt=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 Et(this,void 0,void 0,(function(){var n;return bt(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 gt(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 gt(this,"string"==typeof t?r:e),i=[];return a.execute(n,o,i),Promise.all(a.awaitingPromises).then((function(){return a.stripEmptyErrors(i)}))},t}(),_t=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 Ot(t){return _t.get(t)}function St(t,e,r){return"string"==typeof t?Ot(wt).validate(t,e,r):Ot(wt).validate(t,e)}function Mt(t,e,r){return"string"==typeof t?Ot(wt).validateSync(t,e,r):Ot(wt).validateSync(t,e)}function Tt(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&&Tt(r.children,e,t,o),t}),r)}function At(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,at.plainToInstance(c,l,u));return Promise.resolve(("sync"===r.mode?Mt:St)(s,i)).then((function(t){return t.length?{values:{},errors:J(Tt(t,!a.shouldUseNativeValidation&&"all"===a.criteriaMode),a)}:(a.shouldUseNativeValidation&&q({},a),{values:r.raw?Object.assign({},n):s,errors:{}})}))}catch(t){return Promise.reject(t)}var c,l,u}}function xt({model:e,getDetailsData:n,onSubmit:o,redirect:a,...i}){const s=r((()=>{return{resolver:At(t=e),form:W(t),inputs:H(t)};var t}),[e]);return t.createElement(B,{getDetailsData:n,redirect:a,onSubmit:o,formOptions:s})}const Nt=v()(y((t=>({screens:null,user:null,screenPaths:{}})),{name:"app-store-1",storage:m((()=>localStorage)),partialize:t=>({user:t.user})}),g);function Ct({onLogin:e}){const{register:r,handleSubmit:n,formState:{errors:o}}=p(),a=c();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=>{e.login(t.username,t.password).then((t=>{const{user:e,token:r}=t;localStorage.setItem("token",r),Nt.setState({user:e}),a("/")}))})),className:"login-form"},t.createElement(F,{input:{name:"username",label:"Username",placeholder:"Enter your username",type:"input"},register:r,error:o.username}),t.createElement(F,{input:{name:"password",label:"Password",inputType:"password",placeholder:"Enter your password",type:"input"},register:r,error:o.password}),t.createElement("div",{className:"form-actions"},t.createElement("button",{type:"submit",className:"submit-button"},"Sign In")))))}function kt({menu:r,getIcons:n,onLogout:o}){const{screens:a,screenPaths:s}=Nt((t=>({screens:t.screens??{},screenPaths:t.screenPaths??{}}))),[u,p]=e(!0),f=l(),d=c(),h=t=>{if("/"===t)return f.pathname===t;const e=t.replace(/^\/+|\/+$/g,""),r=f.pathname.replace(/^\/+|\/+$/g,"");return r===e||r.startsWith(`${e}/`)};return t.createElement("div",{className:"sidebar "+(u?"open":"closed")},t.createElement("button",{className:"toggle-button",onClick:()=>p(!u),"aria-label":u?"Collapse sidebar":"Expand sidebar","aria-expanded":u},u?"<":">"),t.createElement("nav",{className:"nav-links"},r?.(a).map(((e,r)=>t.createElement(i,{key:r,to:e.path,className:"nav-link "+(h(e.path)?"active":""),"aria-current":h(e.path)?"page":void 0},t.createElement("span",{className:"nav-links-icon"},n?.(e.iconType)),u?t.createElement("span",null,e.name):null)))),o&&t.createElement("div",{className:"sidebar-footer"},t.createElement("button",{className:"logout-button",onClick:()=>{o&&(o(),d(s.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"}))),u?t.createElement("span",null,"Logout"):null)))}function Lt({children:e,menu:r,getIcons:n,logout:o}){const{user:a,screenPaths:i}=Nt((t=>({user:t.user,screenPaths:t.screenPaths})));Nt();const s=c();return a||s(i.login),t.createElement("div",{className:"layout"},t.createElement(kt,{onLogout:()=>{o&&o()},menu:r,getIcons:n}),t.createElement("main",{className:"content"},e))}function Pt({children:e,init:r}){return o((()=>{!function({screenPaths:t}){Nt.setState({screenPaths:t})}(r())}),[r]),t.createElement(z,null,e)}function It(t){return N({...t,type:"image"})}function Vt(t){return e=>{t&&Reflect.defineMetadata("Crud",t,e)}}export{N as Cell,$ as Counter,Vt as Crud,xt as FormPage,It as ImageCell,K as Input,Lt as Layout,T as List,L as ListPage,Ct as Login,Pt as Panel};
|
package/dist/initPanel.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import { InitPanelOptions } from
|
2
|
-
export declare function initPanel({
|
1
|
+
import { InitPanelOptions } from './types/initPanelOptions';
|
2
|
+
export declare function initPanel({ screenPaths }: InitPanelOptions): void;
|
package/dist/store/store.d.ts
CHANGED
@@ -1,15 +1,11 @@
|
|
1
|
-
import { ScreenCreatorData } from
|
1
|
+
import { ScreenCreatorData } from '../types/ScreenCreatorData';
|
2
2
|
interface User {
|
3
3
|
username: string;
|
4
4
|
}
|
5
5
|
interface AppState {
|
6
6
|
user: User | null;
|
7
7
|
screens: Record<string, ScreenCreatorData> | null;
|
8
|
-
fetchSettings: {
|
9
|
-
baseUrl: string;
|
10
|
-
} | null;
|
11
8
|
screenPaths: Record<string, string>;
|
12
|
-
token: string | null;
|
13
9
|
}
|
14
10
|
export declare const useAppStore: import("zustand/traditional").UseBoundStoreWithEqualityFn<Omit<import("zustand/vanilla").StoreApi<AppState>, "persist"> & {
|
15
11
|
persist: {
|
@@ -0,0 +1 @@
|
|
1
|
+
export type AnyClass = abstract new (...args: any[]) => any;
|
@@ -1,11 +1,13 @@
|
|
1
|
-
import { CellOptions } from "../decorators/Cell";
|
1
|
+
import { CellOptions } from "../decorators/list/Cell";
|
2
2
|
import { CrudOptions } from "../decorators/Crud";
|
3
|
-
import { InputOptions } from "../decorators/Input";
|
3
|
+
import { InputOptions } from "../decorators/form/Input";
|
4
|
+
import { ListOptions } from "../decorators/list/List";
|
4
5
|
export interface ScreenCreatorData {
|
5
6
|
resolver: any;
|
6
7
|
fields: string[];
|
7
|
-
cells: CellOptions[];
|
8
8
|
inputs: InputOptions[];
|
9
9
|
crud?: CrudOptions;
|
10
10
|
path: string;
|
11
|
+
list?: ListOptions;
|
12
|
+
cells: CellOptions[];
|
11
13
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const bytesToSize: (bytes: number) => string;
|
@@ -1,2 +1,3 @@
|
|
1
1
|
import { ScreenCreatorData } from "../types/ScreenCreatorData";
|
2
|
-
|
2
|
+
import { AnyClass } from "../types/AnyClass";
|
3
|
+
export declare function getFields<T extends AnyClass>(key: string, entityClass: T): ScreenCreatorData;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "proje-react-panel",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.15",
|
4
4
|
"description": "",
|
5
5
|
"author": "SEFA DEMİR",
|
6
6
|
"license": "ISC",
|
@@ -29,12 +29,13 @@
|
|
29
29
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
30
30
|
"@types/react": "^19.0.10",
|
31
31
|
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
32
|
-
"@typescript-eslint/parser": "^8.
|
32
|
+
"@typescript-eslint/parser": "^8.29.1",
|
33
33
|
"class-transformer": "^0.5.1",
|
34
34
|
"class-validator": "^0.14.1",
|
35
|
-
"eslint": "^
|
35
|
+
"eslint": "^9.24.0",
|
36
36
|
"eslint-plugin-react": "^7.37.4",
|
37
37
|
"prettier": "^3.5.3",
|
38
|
+
"prettier-eslint": "^16.3.0",
|
38
39
|
"react": "^19.0.0",
|
39
40
|
"react-hook-form": "^7.54.2",
|
40
41
|
"react-router": "^7.3.0",
|
@@ -44,7 +45,7 @@
|
|
44
45
|
"rollup-plugin-serve": "^3.0.0",
|
45
46
|
"rollup-plugin-terser": "^7.0.2",
|
46
47
|
"rollup-plugin-typescript2": "^0.36.0",
|
47
|
-
"typescript": "^5.8.
|
48
|
+
"typescript": "^5.8.3",
|
48
49
|
"use-sync-external-store": "^1.4.0",
|
49
50
|
"zustand": "^5.0.3"
|
50
51
|
},
|
package/src/api/CrudApi.ts
CHANGED
@@ -15,26 +15,45 @@ export const CrudApi = {
|
|
15
15
|
throw res;
|
16
16
|
});
|
17
17
|
},
|
18
|
-
create: (
|
19
|
-
|
18
|
+
create: (options: FetchOptions, api: string, data: any) => {
|
19
|
+
const headers: HeadersInit = { Authorization: `Bearer ${options.token}` };
|
20
|
+
// Don't set Content-Type for FormData
|
21
|
+
if (!(data instanceof FormData)) {
|
22
|
+
headers["Content-Type"] = "application/json";
|
23
|
+
}
|
24
|
+
|
25
|
+
return fetch(`${options?.baseUrl ?? ""}/${api}`, {
|
20
26
|
method: "POST",
|
21
|
-
headers
|
22
|
-
body: JSON.stringify(data),
|
27
|
+
headers,
|
28
|
+
body: data instanceof FormData ? data : JSON.stringify(data),
|
23
29
|
}).then((res) => res.json());
|
24
30
|
},
|
25
|
-
details: (
|
26
|
-
return fetch(`${
|
31
|
+
details: (options: FetchOptions, api: string, id: any) => {
|
32
|
+
return fetch(`${options?.baseUrl ?? ""}/${api}/${id}`, {
|
27
33
|
method: "GET",
|
28
|
-
headers: { "Content-Type": "application/json" },
|
34
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${options.token}` },
|
29
35
|
}).then((res) => {
|
30
36
|
return res.json();
|
31
37
|
});
|
32
38
|
},
|
33
|
-
edit: (
|
34
|
-
|
39
|
+
edit: (options: FetchOptions, api: string, data: any) => {
|
40
|
+
const headers: HeadersInit = { Authorization: `Bearer ${options.token}` };
|
41
|
+
// Don't set Content-Type for FormData
|
42
|
+
if (!(data instanceof FormData)) {
|
43
|
+
headers["Content-Type"] = "application/json";
|
44
|
+
}
|
45
|
+
return fetch(`${options?.baseUrl ?? ""}/${api}/${data.id}`, {
|
35
46
|
method: "PUT",
|
36
|
-
headers
|
37
|
-
body: JSON.stringify(data),
|
47
|
+
headers,
|
48
|
+
body: data instanceof FormData ? data : JSON.stringify(data),
|
38
49
|
}).then((res) => res.json());
|
39
50
|
},
|
51
|
+
delete: (options: FetchOptions, api: string, id: string) => {
|
52
|
+
return fetch(`${options?.baseUrl ?? ""}/${api}/${id}`, {
|
53
|
+
method: "DELETE",
|
54
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${options.token}` },
|
55
|
+
}).then((res) => {
|
56
|
+
return res.clone().json();
|
57
|
+
});
|
58
|
+
},
|
40
59
|
};
|
package/src/components/Panel.tsx
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
import React, { useEffect } from
|
2
|
-
import { ErrorBoundary } from
|
3
|
-
import { initPanel } from
|
4
|
-
import { InitPanelOptions } from
|
1
|
+
import React, { useEffect } from 'react';
|
2
|
+
import { ErrorBoundary } from './components';
|
3
|
+
import { initPanel } from '../initPanel';
|
4
|
+
import { InitPanelOptions } from '../types/initPanelOptions';
|
5
5
|
|
6
6
|
type AppProps = {
|
7
|
-
|
8
|
-
|
7
|
+
children: React.ReactNode;
|
8
|
+
init: () => InitPanelOptions;
|
9
9
|
};
|
10
10
|
|
11
11
|
export function Panel({ children, init }: AppProps) {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
useEffect(() => {
|
13
|
+
const options = init();
|
14
|
+
initPanel(options);
|
15
|
+
}, [init]);
|
16
16
|
|
17
|
-
|
17
|
+
return <ErrorBoundary>{children}</ErrorBoundary>;
|
18
18
|
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
|
3
|
+
interface CheckboxProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
4
|
+
id: string;
|
5
|
+
}
|
6
|
+
|
7
|
+
export function Checkbox({ id, ...props }: CheckboxProps) {
|
8
|
+
return <input type="checkbox" id={id} className="checkbox" {...props} />;
|
9
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
2
|
+
|
3
|
+
interface CounterProps {
|
4
|
+
image: React.ReactNode;
|
5
|
+
text: string;
|
6
|
+
targetNumber: number;
|
7
|
+
duration?: number;
|
8
|
+
}
|
9
|
+
|
10
|
+
export function Counter({ image, text, targetNumber, duration = 2000 }: CounterProps) {
|
11
|
+
const [count, setCount] = useState<number>(0);
|
12
|
+
|
13
|
+
useEffect(() => {
|
14
|
+
let startTime: number;
|
15
|
+
let animationFrameId: number;
|
16
|
+
|
17
|
+
const animate = (timestamp: number) => {
|
18
|
+
if (!startTime) startTime = timestamp;
|
19
|
+
const progress = timestamp - startTime;
|
20
|
+
const percentage = Math.min(progress / duration, 1);
|
21
|
+
|
22
|
+
setCount(Math.floor(percentage * targetNumber));
|
23
|
+
|
24
|
+
if (percentage < 1) {
|
25
|
+
animationFrameId = requestAnimationFrame(animate);
|
26
|
+
}
|
27
|
+
};
|
28
|
+
|
29
|
+
animationFrameId = requestAnimationFrame(animate);
|
30
|
+
|
31
|
+
return () => {
|
32
|
+
if (animationFrameId) {
|
33
|
+
cancelAnimationFrame(animationFrameId);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
}, [targetNumber, duration]);
|
37
|
+
|
38
|
+
return (
|
39
|
+
<div className="counter-container">
|
40
|
+
<div className="counter-image">
|
41
|
+
{image}
|
42
|
+
</div>
|
43
|
+
<div className="counter-text">
|
44
|
+
{text}
|
45
|
+
</div>
|
46
|
+
<div className="counter-value">
|
47
|
+
{count}
|
48
|
+
</div>
|
49
|
+
</div>
|
50
|
+
);
|
51
|
+
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { InputOptions } from '../../decorators/form/Input';
|
3
|
+
import { Label } from './Label';
|
4
|
+
import { UseFormRegister } from 'react-hook-form';
|
5
|
+
import { ImageUploader } from './ImageUploader';
|
6
|
+
import { Checkbox } from './Checkbox';
|
7
|
+
|
8
|
+
interface FormFieldProps {
|
9
|
+
input: InputOptions;
|
10
|
+
register: UseFormRegister<any>;
|
11
|
+
error?: { message?: string };
|
12
|
+
}
|
13
|
+
|
14
|
+
export function FormField({ input, register, error }: FormFieldProps) {
|
15
|
+
const fieldName = input.name || '';
|
16
|
+
|
17
|
+
const renderField = () => {
|
18
|
+
switch (input.type) {
|
19
|
+
case 'textarea':
|
20
|
+
return <textarea {...register(fieldName)} placeholder={input.placeholder} id={fieldName} />;
|
21
|
+
case 'select':
|
22
|
+
return (
|
23
|
+
<select {...register(fieldName)} id={fieldName}>
|
24
|
+
<option value="">Select {fieldName}</option>
|
25
|
+
{input.selectOptions?.map(option => (
|
26
|
+
<option key={option} value={option}>
|
27
|
+
{option}
|
28
|
+
</option>
|
29
|
+
))}
|
30
|
+
</select>
|
31
|
+
);
|
32
|
+
case 'input': {
|
33
|
+
return (
|
34
|
+
<input
|
35
|
+
type={input.inputType}
|
36
|
+
{...register(fieldName)}
|
37
|
+
placeholder={input.placeholder}
|
38
|
+
id={fieldName}
|
39
|
+
/>
|
40
|
+
);
|
41
|
+
}
|
42
|
+
case 'file-upload':
|
43
|
+
return <ImageUploader />;
|
44
|
+
case 'checkbox':
|
45
|
+
return <Checkbox {...register(fieldName)} id={fieldName} />;
|
46
|
+
case 'hidden':
|
47
|
+
return <input type="hidden" {...register(fieldName)} id={fieldName} />;
|
48
|
+
default:
|
49
|
+
null;
|
50
|
+
}
|
51
|
+
};
|
52
|
+
|
53
|
+
return (
|
54
|
+
<div className="form-field">
|
55
|
+
<Label htmlFor={fieldName} label={input.label} fieldName={fieldName} />
|
56
|
+
{renderField()}
|
57
|
+
{error && <span className="error-message">{error.message}</span>}
|
58
|
+
</div>
|
59
|
+
);
|
60
|
+
}
|