proje-react-panel 1.0.17-test5 → 1.0.17-test7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- import*as t from"react";import e,{useRef as n,useMemo as r,useEffect as a,useState as o,useCallback as i,Component as s}from"react";import{Link as c,useParams as l,useNavigate as u,useLocation as p}from"react-router";import f from"react-select";import{useFormContext as d,useForm as h,FormProvider as m,get as y,set as v}from"react-hook-form";import{persist as g,createJSONStorage as E}from"zustand/middleware";import{createWithEqualityFn as b}from"zustand/traditional";import{shallow as w}from"zustand/vanilla/shallow";const O=()=>e.createElement("div",{className:"empty-list"},e.createElement("div",{className:"empty-list-content"},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),e.createElement("polyline",{points:"13 2 13 9 20 9"})),e.createElement("h3",null,"No Data Found"),e.createElement("p",null,"There are no items to display at the moment.")));var S,_;function M(){return M=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},M.apply(null,arguments)}var T,N,x=function(e){return t.createElement("svg",M({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),S||(S=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),_||(_=t.createElement("path",{d:"m21 19-5.154-5.154a7 7 0 1 0-2 2L19 21zM5 10c0-2.757 2.243-5 5-5s5 2.243 5 5-2.243 5-5 5-5-2.243-5-5"})))};function A(){return A=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},A.apply(null,arguments)}var C,k,L=function(e){return t.createElement("svg",A({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),T||(T=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),N||(N=t.createElement("path",{d:"m13 6 5 5-9.507 9.507a1.765 1.765 0 0 1-.012-2.485l-.002-.003c-.69.676-1.8.673-2.485-.013a1.763 1.763 0 0 1-.036-2.455l-.008-.008c-.694.65-1.78.64-2.456-.036zm7.586-.414-2.172-2.172a2 2 0 0 0-2.828 0L14 5l5 5 1.586-1.586c.78-.78.78-2.047 0-2.828M3 18v3h3a3 3 0 0 0-3-3"})))};function P(){return P=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},P.apply(null,arguments)}var I=function(e){return t.createElement("svg",P({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),C||(C=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),k||(k=t.createElement("path",{d:"M6.187 8h11.625l-.695 11.125A2 2 0 0 1 15.12 21H8.88a2 2 0 0 1-1.997-1.875zM19 5v2H5V5h3V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1zm-9 0h4V4h-4z"})))};function j({data:t,listData:n,onRemoveItem:r}){const a=n.cells,o=t?.[0]?"function"==typeof n.list?.cells?n.list?.cells?.(t[0]):n.list?.cells:null;return e.createElement("div",{className:"datagrid"},t&&0!==t.length?e.createElement("table",{className:"datagrid-table"},e.createElement("thead",null,e.createElement("tr",null,a.map((t=>e.createElement("th",{key:t.name},t.title??t.name))),o?.details&&e.createElement("th",null,"Details"),o?.edit&&e.createElement("th",null,"Edit"),o?.delete&&e.createElement("th",null,"Delete"))),e.createElement("tbody",null,t.map(((t,n)=>e.createElement("tr",{key:n},a.map((n=>{const r=t[n.name];let a=r??"-";switch(n.type){case"date":if(r){const t=new Date(r);a=`${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 t=n;a=e.createElement("img",{width:100,height:100,src:t.baseUrl+r,style:{objectFit:"contain"}});break}default:a=r?r.toString():n?.placeHolder??"-"}return e.createElement("td",{key:n.name},a)})),o?.details&&e.createElement("td",null,e.createElement(c,{to:o.details.path,className:"util-cell-link"},e.createElement(x,{className:"icon icon-search"}),e.createElement("span",{className:"util-cell-label"},o.details.label))),o?.edit&&e.createElement("td",null,e.createElement(c,{to:o.edit.path,className:"util-cell-link"},e.createElement(L,{className:"icon icon-pencil"}),e.createElement("span",{className:"util-cell-label"},o.edit.label))),o?.delete&&e.createElement("td",null,e.createElement("a",{onClick:()=>{r?.(t)},className:"util-cell-link"},e.createElement(I,{className:"icon icon-trash"}),e.createElement("span",{className:"util-cell-label"},o.delete.label)))))))):e.createElement(O,null))}function V({error:t}){return e.createElement("div",{className:"error-container"},e.createElement("div",{className:"error-icon"},e.createElement("i",{className:"fa fa-exclamation-circle"})),e.createElement("div",{className:"error-content"},e.createElement("h3",null,"Error Occurred"),e.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."})(t))))}function D(){return e.createElement("div",{className:"loading-screen"},e.createElement("div",{className:"loading-container"},e.createElement("div",{className:"loading-spinner"}),e.createElement("div",{className:"loading-text"},"Loading...")))}var F,R="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},z={};!function(){return F||(F=1,function(t){!function(){var e="object"==typeof globalThis?globalThis:"object"==typeof R?R:"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){}}(),n=r(t);function r(t,e){return function(n,r){Object.defineProperty(t,n,{configurable:!0,writable:!0,value:r}),e&&e(n,r)}}void 0!==e.Reflect&&(n=r(e.Reflect,n)),function(t,e){var n=Object.prototype.hasOwnProperty,r="function"==typeof Symbol,a=r&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=r&&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 n.call(t,e)}:function(t,e){return e in t},get:c?function(t,e){return n.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=r?Symbol.for("@reflect-metadata:registry"):void 0,m=at(),y=ot(m);function v(t,e,n,r){if(D(n)){if(!W(t))throw new TypeError;if(!q(e))throw new TypeError;return N(t,e)}if(!W(t))throw new TypeError;if(!z(e))throw new TypeError;if(!z(r)&&!D(r)&&!F(r))throw new TypeError;return F(r)&&(r=void 0),x(t,e,n=K(n),r)}function g(t,e){function n(n,r){if(!z(n))throw new TypeError;if(!D(r)&&!J(r))throw new TypeError;P(t,e,n,r)}return n}function E(t,e,n,r){if(!z(n))throw new TypeError;return D(r)||(r=K(r)),P(t,e,n,r)}function b(t,e,n){if(!z(e))throw new TypeError;return D(n)||(n=K(n)),A(t,e,n)}function w(t,e,n){if(!z(e))throw new TypeError;return D(n)||(n=K(n)),C(t,e,n)}function O(t,e,n){if(!z(e))throw new TypeError;return D(n)||(n=K(n)),k(t,e,n)}function S(t,e,n){if(!z(e))throw new TypeError;return D(n)||(n=K(n)),L(t,e,n)}function _(t,e){if(!z(t))throw new TypeError;return D(e)||(e=K(e)),I(t,e)}function M(t,e){if(!z(t))throw new TypeError;return D(e)||(e=K(e)),j(t,e)}function T(t,e,n){if(!z(e))throw new TypeError;if(D(n)||(n=K(n)),!z(e))throw new TypeError;D(n)||(n=K(n));var r=st(e,n,!1);return!D(r)&&r.OrdinaryDeleteMetadata(t,e,n)}function N(t,e){for(var n=t.length-1;n>=0;--n){var r=(0,t[n])(e);if(!D(r)&&!F(r)){if(!q(r))throw new TypeError;e=r}}return e}function x(t,e,n,r){for(var a=t.length-1;a>=0;--a){var o=(0,t[a])(e,n,r);if(!D(o)&&!F(o)){if(!z(o))throw new TypeError;r=o}}return r}function A(t,e,n){if(C(t,e,n))return!0;var r=nt(e);return!F(r)&&A(t,r,n)}function C(t,e,n){var r=st(e,n,!1);return!D(r)&&H(r.OrdinaryHasOwnMetadata(t,e,n))}function k(t,e,n){if(C(t,e,n))return L(t,e,n);var r=nt(e);return F(r)?void 0:k(t,r,n)}function L(t,e,n){var r=st(e,n,!1);if(!D(r))return r.OrdinaryGetOwnMetadata(t,e,n)}function P(t,e,n,r){st(n,r,!0).OrdinaryDefineOwnMetadata(t,e,n,r)}function I(t,e){var n=j(t,e),r=nt(t);if(null===r)return n;var a=I(r,e);if(a.length<=0)return n;if(n.length<=0)return a;for(var o=new f,i=[],s=0,c=n;s<c.length;s++){var l=c[s];o.has(l)||(o.add(l),i.push(l))}for(var u=0,p=a;u<p.length;u++){l=p[u];o.has(l)||(o.add(l),i.push(l))}return i}function j(t,e){var n=st(t,e,!1);return n?n.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 z(t){return"object"==typeof t?null!==t:"function"==typeof t}function B(t,e){switch(V(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var n="string",r=Q(t,a);if(void 0!==r){var o=r.call(t,n);if(z(o))throw new TypeError;return o}return $(t)}function $(t,e){var n,r,a=t.toString;if(G(a)&&!z(r=a.call(t)))return r;if(G(n=t.valueOf)&&!z(r=n.call(t)))return r;throw new TypeError}function H(t){return!!t}function U(t){return""+t}function K(t){var e=B(t);return R(e)?e:U(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(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 n=t[e];if(null!=n){if(!G(n))throw new TypeError;return n}}function X(t){var e=Q(t,o);if(!G(e))throw new TypeError;var n=e.call(t);if(!z(n))throw new TypeError;return n}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 nt(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===u)return e;if(e!==u)return e;var n=t.prototype,r=n&&Object.getPrototypeOf(n);if(null==r||r===Object.prototype)return e;var a=r.constructor;return"function"!=typeof a||a===t?e:a}function rt(){var t,n,r,a;D(h)||void 0===e.Reflect||h in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=it(e.Reflect));var o=new d,i={registerProvider:s,getProvider:l,setProvider:m};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(n):n=e;break;case n===e:break;case D(r):r=e;break;case r===e:break;default:void 0===a&&(a=new f),a.add(e)}}function c(e,o){if(!D(n)){if(n.isProviderFor(e,o))return n;if(!D(r)){if(r.isProviderFor(e,o))return n;if(!D(a))for(var i=X(a);;){var s=tt(i);if(!s)return;var c=Z(s);if(c.isProviderFor(e,o))return et(i),c}}}if(!D(t)&&t.isProviderFor(e,o))return t}function l(t,e){var n,r=o.get(t);return D(r)||(n=r.get(e)),D(n)?(D(n=c(t,e))||(D(r)&&(r=new p,o.set(t,r)),r.set(e,n)),n):n}function u(t){if(D(t))throw new TypeError;return n===t||r===t||!D(a)&&a.has(t)}function m(t,e,n){if(!u(n))throw new Error("Metadata provider not registered.");var r=l(t,e);if(r!==n){if(!D(r))return!1;var a=o.get(t);D(a)&&(a=new p,o.set(t,a)),a.set(e,n)}return!0}}function at(){var t;return!D(h)&&z(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[h]),D(t)&&(t=rt()),!D(h)&&z(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}function ot(t){var e=new d,n={isProviderFor:function(t,n){var r=e.get(t);return!D(r)&&r.has(n)},OrdinaryDefineOwnMetadata:i,OrdinaryHasOwnMetadata:a,OrdinaryGetOwnMetadata:o,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return m.registerProvider(n),n;function r(r,a,o){var i=e.get(r),s=!1;if(D(i)){if(!o)return;i=new p,e.set(r,i),s=!0}var c=i.get(a);if(D(c)){if(!o)return;if(c=new p,i.set(a,c),!t.setProvider(r,a,n))throw i.delete(a),s&&e.delete(r),new Error("Wrong provider for target.")}return c}function a(t,e,n){var a=r(e,n,!1);return!D(a)&&H(a.has(t))}function o(t,e,n){var a=r(e,n,!1);if(!D(a))return a.get(t)}function i(t,e,n,a){r(n,a,!0).set(t,e)}function s(t,e){var n=[],a=r(t,e,!1);if(D(a))return n;for(var o=X(a.keys()),i=0;;){var s=tt(o);if(!s)return n.length=i,n;var c=Z(s);try{n[i]=c}catch(t){try{et(o)}finally{throw t}}i++}}function c(t,n,a){var o=r(n,a,!1);if(D(o))return!1;if(!o.delete(t))return!1;if(0===o.size){var i=e.get(n);D(i)||(i.delete(a),0===i.size&&e.delete(i))}return!0}}function it(t){var e=t.defineMetadata,n=t.hasOwnMetadata,r=t.getOwnMetadata,a=t.getOwnMetadataKeys,o=t.deleteMetadata,i=new d;return{isProviderFor:function(t,e){var n=i.get(t);return!(D(n)||!n.has(e))||!!a(t,e).length&&(D(n)&&(n=new f,i.set(t,n)),n.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:r,OrdinaryOwnMetadataKeys:a,OrdinaryDeleteMetadata:o}}function st(t,e,n){var r=m.getProvider(t,e);if(!D(r))return r;if(n){if(m.setProvider(t,e,y))return y;throw new Error("Illegal state.")}}function ct(){var t={},e=[],n=function(){function t(t,e,n){this._index=0,this._keys=t,this._values=e,this._selector=n}return t.prototype["@@iterator"]=function(){return this},t.prototype[o]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var n=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:n,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}(),r=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 n=this._find(t,!0);return this._values[n]=e,this},e.prototype.delete=function(e){var n=this._find(e,!1);if(n>=0){for(var r=this._keys.length,a=n+1;a<r;a++)this._keys[a-1]=this._keys[a],this._values[a-1]=this._values[a];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 n(this._keys,this._values,a)},e.prototype.values=function(){return new n(this._keys,this._values,i)},e.prototype.entries=function(){return new n(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[o]=function(){return this.entries()},e.prototype._find=function(t,e){if(!Y(this._cacheKey,t)){this._cacheIndex=-1;for(var n=0;n<this._keys.length;n++)if(Y(this._keys[n],t)){this._cacheIndex=n;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();return r;function a(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[o]=function(){return this.keys()},t}()}function ut(){var t=16,e=l.create(),r=a();return function(){function t(){this._key=a()}return t.prototype.has=function(t){var e=o(t,!1);return void 0!==e&&l.has(e,this._key)},t.prototype.get=function(t){var e=o(t,!1);return void 0!==e?l.get(e,this._key):void 0},t.prototype.set=function(t,e){return o(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=o(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=a()},t}();function a(){var t;do{t="@@WeakMap@@"+c()}while(l.has(e,t));return e[t]=!0,t}function o(t,e){if(!n.call(t,r)){if(!e)return;Object.defineProperty(t,r,{value:l.create()})}return t[r]}function i(t,e){for(var n=0;n<e;++n)t[n]=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 n="",r=0;r<t;++r){var a=e[r];4!==r&&6!==r&&8!==r||(n+="-"),a<16&&(n+="0"),n+=a.toString(16).toLowerCase()}return n}}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",O),t("getOwnMetadata",S),t("getMetadataKeys",_),t("getOwnMetadataKeys",M),t("deleteMetadata",T)}(n,e),void 0===e.Reflect&&(e.Reflect=t)}()}(t||(t={}))),z;var t}();const B="List";function $(t){return e=>{t&&Reflect.defineMetadata(B,t,e)}}function H(t){return Reflect.getMetadata(B,t)}const U=Symbol("cell");function K(t){return(e,n)=>{const r=Reflect.getMetadata(U,e)||[];if(Reflect.defineMetadata(U,[...r,n.toString()],e),t){const r=`${U.toString()}:${n.toString()}:options`;Reflect.defineMetadata(r,t,e)}}}function W(t){const e=t.prototype;return(Reflect.getMetadata(U,e)||[]).map((t=>{const n=Reflect.getMetadata(`${U.toString()}:${t}:options`,e)||{};return{...n,name:n?.name??t}}))}function G({pagination:t,onPageChange:n}){const{total:r,page:a,limit:o}=t,i=Math.floor(r/o);if(i<=1)return null;return e.createElement("div",{className:"pagination"},e.createElement("button",{onClick:()=>n(a-1),className:"pagination-item "+(1===a?"disabled":""),disabled:1===a,"aria-disabled":1===a},"Previous"),(()=>{const t=[];for(let r=1;r<=Math.min(2,i);r++)t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));a-2>3&&t.push(e.createElement("span",{key:"ellipsis1",className:"pagination-ellipsis"},"..."));for(let r=Math.max(3,a-2);r<=Math.min(i-2,a+2);r++)r>2&&r<i-1&&t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));a+2<i-2&&t.push(e.createElement("span",{key:"ellipsis2",className:"pagination-ellipsis"},"..."));for(let r=Math.max(i-1,3);r<=i;r++)r>2&&t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));return t})(),e.createElement("button",{onClick:()=>n(a+1),className:"pagination-item "+(a===i?"disabled":""),disabled:a===i,"aria-disabled":a===i},"Next"))}var q,J,Y;function Q(){return Q=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Q.apply(null,arguments)}var X,Z=function(e){return t.createElement("svg",Q({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),q||(q=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),J||(J=t.createElement("path",{d:"M21 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5v2H5v14h14v-5z"})),Y||(Y=t.createElement("path",{d:"M21 7h-4V3h-2v4h-4v2h4v4h2V9h4"})))};function tt(){return tt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},tt.apply(null,arguments)}var et=function(e){return t.createElement("svg",tt({xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e),X||(X=t.createElement("path",{d:"M22 3H2l8 9.46V19l4 2v-8.54z"})))};function nt({field:t,value:n,onChange:r}){if("static-select"===t.filter?.type){const a=t.filter;return e.createElement(f,{id:t.name,menuPortalTarget:document.body,styles:{control:(t,e)=>({...t,backgroundColor:"#1f2937",borderColor:e.isFocused?"#6366f1":"#374151",boxShadow:e.isFocused?"0 0 0 1px #6366f1":"none","&:hover":{borderColor:"#6366f1"},borderRadius:"6px",padding:"2px",color:"white"}),option:(t,e)=>({...t,backgroundColor:e.isSelected?"#6366f1":e.isFocused?"#374151":"#1f2937",color:"white","&:active":{backgroundColor:"#6366f1"},"&:hover":{backgroundColor:"#374151"},cursor:"pointer"}),input:t=>({...t,color:"white"}),placeholder:t=>({...t,color:"#9ca3af"}),singleValue:t=>({...t,color:"white"}),menuPortal:t=>({...t,zIndex:9999}),menu:t=>({...t,backgroundColor:"#1f2937",border:"1px solid #374151",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"}),menuList:t=>({...t,padding:"4px"}),dropdownIndicator:t=>({...t,color:"#9ca3af","&:hover":{color:"#6366f1"}}),clearIndicator:t=>({...t,color:"#9ca3af","&:hover":{color:"#6366f1"}})},value:n?{value:n,label:a.options.find((t=>t.value===n))?.label||n}:null,onChange:t=>r(t?.value||""),options:a.options.map((t=>({value:t.value,label:t.label}))),placeholder:`Filter by ${t.title||t.name}`,isClearable:!0})}return e.createElement("input",{type:"number"===t.type?"number":"text",id:t.name,value:n||"",onChange:t=>r(t.target.value),placeholder:`Filter by ${t.title||t.name}`})}function rt({isOpen:t,onClose:o,onApplyFilters:i,listData:s,activeFilters:c}){const[l,u]=e.useState(c??{}),p=n(null),f=r((()=>s.cells.filter((t=>!!t.filter))),[s.cells]);if(a((()=>{const e=t=>{p.current&&!p.current.contains(t.target)&&o()};return t&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[t,o]),!t)return null;return e.createElement("div",{className:"filter-popup-overlay"},e.createElement("div",{ref:p,className:"filter-popup"},e.createElement("div",{className:"filter-popup-header"},e.createElement("h3",null,"Filter"),e.createElement("button",{onClick:o,className:"close-button"},"×")),e.createElement("div",{className:"filter-popup-content"},f.map((t=>e.createElement("div",{key:t.name,className:"filter-field"},e.createElement("label",{htmlFor:t.name},t.title||t.name),e.createElement(nt,{field:t,value:l[t.name||""],onChange:e=>((t,e)=>{u((n=>({...n,[t]:e})))})(t.name||"",e)}))))),e.createElement("div",{className:"filter-popup-footer"},e.createElement("button",{onClick:o,className:"cancel-button"},"Cancel"),e.createElement("button",{onClick:()=>{i(l),o()},className:"apply-button"},"Apply Filters"))))}const at=({listData:t,filtered:n,onFilterClick:a,customHeader:o})=>{const i=r((()=>t.cells.filter((t=>!!t.filter))),[t.cells]),s=t.list?.headers;return e.createElement("div",{className:"list-header"},e.createElement("div",{className:"header-title"},s?.title||"List"),o&&e.createElement("div",{className:"header-custom"},o),e.createElement("div",{className:"header-actions"},!!i.length&&e.createElement("button",{onClick:a,className:"filter-button"},e.createElement(et,{className:"icon icon-filter "+(n?"active":"")}),"Filter"),s?.create&&e.createElement(c,{to:s.create.path,className:"create-button"},e.createElement(Z,{className:"icon icon-create"}),s.create.label)))};function ot({model:t,getData:n,onRemoveItem:s,customHeader:c}){const[p,f]=o(!0),[d,h]=o({total:0,page:0,limit:0}),[m,y]=o(null),[v,g]=o(null),[E,b]=o(!1),[w,O]=o(),S=r((()=>{return{list:H(e=t),cells:W(e)};var e}),[t]),_=l(),M=u(),T=i((async(t,e)=>{f(!0);try{const r=await n({page:t,filters:e??w??{}});y(r.data),h({total:r.total,page:r.page,limit:r.limit})}catch(t){g(t),console.error(t)}finally{f(!1)}}),[n,w]);a((()=>{const t=new URLSearchParams(location.search),e={};t.forEach(((t,n)=>{e[n]=t})),O(e)}),[location.search]),a((()=>{w&&T(parseInt(_.page)||1,w)}),[T,_.page,w]);return p?e.createElement(D,null):v?e.createElement(V,{error:v}):e.createElement("div",{className:"list"},e.createElement(at,{listData:S,filtered:!(!w||!Object.keys(w).length),onFilterClick:()=>b(!0),customHeader:c}),e.createElement(j,{listData:S,data:m,onRemoveItem:async t=>{s&&alert({title:"Are you sure you want to delete this item?",message:"This action cannot be undone.",onConfirm:async()=>{await s(t),await T(d.page)}})}}),e.createElement("div",{className:"list-footer"},e.createElement(G,{pagination:d,onPageChange:T})),e.createElement(rt,{isOpen:E,activeFilters:w,onClose:()=>b(!1),onApplyFilters:t=>{O(t);const e=new URLSearchParams;Object.entries(t).forEach((([t,n])=>{null!=n&&""!==n&&e.append(t,String(n))}));const n=e.toString(),r=`${location.pathname}${n?`?${n}`:""}`;M(r),T(1,t)},listData:S}))}function it({htmlFor:t,label:n,fieldName:r}){return e.createElement("label",{htmlFor:t},n??r.charAt(0).toUpperCase()+r.slice(1))}const st=Object.freeze({BEFORE:"before",HOVER:"hover",AFTER:"after"});function ct(t){return e.createElement("div",null,e.createElement("img",{...t,style:{width:100}}),e.createElement("p",null,t.name," ",e.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]})(t.size),")")))}function lt(){const{register:t,formState:{errors:n},watch:r,setValue:o,clearErrors:i,setError:s}=d(),c=r("uploader");return a((()=>{t("uploader",{required:!0})}),[t]),e.createElement("div",null,e.createElement("span",{className:"form-error",style:{bottom:2,top:"unset"}},"required"===n.uploader?.type&&"At least 1 image is required!","custom"===n.uploader?.type&&n.uploader.message?.toString()),e.createElement(ut,{reset:c,onError:t=>{t?s("uploader",{type:"custom",message:t}):(o("uploader",{files:[]}),i("uploader"))},onClear:()=>{o("uploader",{files:[]}),i("uploader")},onFilesChange:t=>{o("uploader",{files:t})}}))}function ut(t){const[n,r]=e.useState(st.BEFORE),[a,o]=e.useState(t.value||[]),[i,s]=e.useState([]),[c,l]=e.useState(0);console.log("files",i);const u=e.useRef(null),p=e.useRef(null);e.useEffect((()=>{const e=u.current;if(!e)return;const n=t=>{t.preventDefault(),t.stopPropagation(),f()},a=t=>{t.preventDefault(),t.stopPropagation(),d()},o=t=>{t.preventDefault(),t.stopPropagation()},c=e=>{e.preventDefault(),e.stopPropagation(),l(0);const n=e.dataTransfer?.files;if(!n)return;s([]),r(st.AFTER);const a=[];for(let e=0;e<n.length;e++){const r=new FileReader;r.onload=r=>{if(!r.target)return;h([...i,{file:n[e],image:r.target.result}])&&(a.push(n[e]),p.current&&(p.current.files=n),s([])),t.onFilesChange&&t.onFilesChange(a)},r.readAsDataURL(n[e])}p.current&&(p.current.files=n)};return e.addEventListener("dragenter",n,!1),e.addEventListener("dragleave",a,!1),e.addEventListener("dragover",o,!1),e.addEventListener("drop",c,!1),()=>{e.removeEventListener("dragenter",n),e.removeEventListener("dragleave",a),e.removeEventListener("dragover",o),e.removeEventListener("drop",c)}}),[i]);const f=()=>{l((t=>t+1)),r(st.HOVER)},d=()=>{l((t=>t-1==0?(r(st.BEFORE),0):t-1))},h=e=>{const n=(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 n=t[e].file,r=n.name.split(".");if(!["png","jpg","jpeg"].includes(r[r.length-1]))return'Extension of the file can only be "png", "jpg" or "jpeg" ';if(n&&n.size>1048576)return`Size of "${n.name}" can't be bigger than 1mb`}return null})(e);return n||s(e),t.onError?.(n),n};return e.createElement("div",{ref:u,className:"multi-image form-element dropzone "+n},e.createElement("input",{ref:p,type:"file",style:{display:"none"},className:"target",name:"file"}),e.createElement("div",{className:"container"},e.createElement("button",{className:"trash",onClick:()=>{s([]),p.current&&(p.current.value=""),t.onClear?.()},type:"button"},"Delete All"),(()=>{const t=[];if(i){console.log("----\x3e",i);for(let n=0;n<i.length;n++){let r="image";t.push(e.createElement("div",{key:n,className:"image-container"},e.createElement("div",{className:r},e.createElement(ct,{name:i[n].file.name,src:i[n].image,size:i[n].file.size}))))}}return t})(),e.createElement("div",null,e.createElement("button",{type:"button",onClick:()=>{const t=document.getElementById("file__");t&&t.click()},className:"plus"},e.createElement("span",null,"+ Add Image",e.createElement("p",null,"Drag image here or Select Image")))),e.createElement("input",{hidden:!0,id:"file__",multiple:!0,type:"file",onChange:t=>{const e=t.target.files;if(e){s([]),r(st.AFTER);for(let t=0;t<e.length;t++){const n=new FileReader;n.onload=n=>{n.target&&h([...i,{file:e[t],image:n.target.result}])},n.readAsDataURL(e[t])}p.current&&(p.current.files=e)}}})))}function pt({id:t,...n}){return e.createElement("input",{type:"checkbox",id:t,className:"checkbox",...n})}function ft({input:t,register:n}){const r=d(),a=r.getValues(t.name);return e.createElement("div",null,a?.map(((a,o)=>e.createElement("div",{key:o},t.nestedFields?.map((a=>e.createElement(dt,{key:a.name?.toString()??"",baseName:t.name+"["+o+"]",input:a,register:n,error:t.name?{message:r.formState.errors[t.name]?.message}:void 0})))))))}function dt({input:t,register:n,error:r,baseName:a}){const o=(a?a.toString()+".":"")+t.name||"";return e.createElement("div",{className:"form-field"},e.createElement(it,{htmlFor:o,label:t.label,fieldName:o}),(()=>{switch(t.type){case"textarea":return e.createElement("textarea",{...n(o),placeholder:t.placeholder,id:o});case"select":return e.createElement("select",{...n(o),id:o},e.createElement("option",{value:""},"Select ",o),t.options?.map((t=>e.createElement("option",{key:t.value,value:t.value},t.label))));case"input":return e.createElement("input",{type:t.inputType,...n(o),placeholder:t.placeholder,id:o});case"file-upload":return e.createElement(lt,null);case"checkbox":return e.createElement(pt,{...n(o),id:o});case"hidden":return e.createElement("input",{type:"hidden",...n(o),id:o});case"nested":return e.createElement(ft,{input:t,register:n})}})(),r&&e.createElement("span",{className:"error-message"},r.message))}function ht({formOptions:t,onSubmit:n,getDetailsData:r,redirectBackOnSuccess:o}){const i=l(),s=h({resolver:t.resolver}),c=u(),p=t.inputs;return a((()=>{r&&r(i).then((t=>{s.reset({...t})}))}),[i,s.reset]),e.createElement("div",{className:"form-wrapper"},e.createElement(m,{...s},e.createElement("form",{onSubmit:s.handleSubmit((async t=>{await n(t),o&&c(-1)}),((t,e)=>{console.log("error creating creation",t,e)}))},e.createElement("div",null,p?.map((t=>e.createElement(dt,{key:t.name||"",input:t,register:s.register,error:t.name?{message:s.formState.errors[t.name]?.message}:void 0}))),e.createElement("button",{type:"submit",className:"submit-button"},"Submit")))))}function mt({image:t,text:n,targetNumber:r,duration:i=2e3}){const[s,c]=o(0);return a((()=>{let t,e;const n=a=>{t||(t=a);const o=a-t,s=Math.min(o/i,1);c(Math.floor(s*r)),s<1&&(e=requestAnimationFrame(n))};return e=requestAnimationFrame(n),()=>{e&&cancelAnimationFrame(e)}}),[r,i]),e.createElement("div",{className:"counter-container"},e.createElement("div",{className:"counter-image"},t),e.createElement("div",{className:"counter-text"},n),e.createElement("div",{className:"counter-value"},s))}class yt extends s{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?e.createElement("div",{className:"error-boundary"},e.createElement("div",{className:"error-boundary__content"},e.createElement("div",{className:"error-boundary__icon"},e.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},e.createElement("circle",{cx:"12",cy:"12",r:"10"}),e.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"16"}))),e.createElement("h1",null,"Oops! Something went wrong"),e.createElement("p",{className:"error-boundary__message"},this.state.error?.message||"An unexpected error occurred"),e.createElement("button",{className:"error-boundary__button",onClick:()=>window.location.reload()},"Refresh Page"),"development"===process.env.NODE_ENV&&e.createElement("details",{className:"error-boundary__details"},e.createElement("summary",null,"Error Details"),e.createElement("pre",null,this.state.error?.toString()),e.createElement("pre",null,this.state.errorInfo?.componentStack)))):this.props.children}}const vt=Symbol("input");function gt(t){return(e,n)=>{const r=Reflect.getMetadata(vt,e)||[];if(Reflect.defineMetadata(vt,[...r,n.toString()],e),t){const r=`${vt.toString()}:${n.toString()}:options`;Reflect.defineMetadata(r,t,e)}}}function Et(t){const e=t.prototype;return(Reflect.getMetadata(vt,e)||[]).map((t=>{const n=Reflect.getMetadata(`${vt.toString()}:${t}:options`,e)||{},r=n?.inputType??(a=t,["password"].some((t=>a.toLowerCase().includes(t)))?"password":"text");var a;return{...n,editable:n.editable??!0,sensitive:n.sensitive,name:n?.name??t,label:n?.label??t,placeholder:n?.placeholder??t,inputType:r,type:n?.type??"input",selectOptions:n?.selectOptions??[],cancelPasswordValidationOnEdit:n?.cancelPasswordValidationOnEdit??"password"===r}}))}function bt(t){return Reflect.getMetadata("FormMetadata",t)}const wt=(t,e,n)=>{if(t&&"reportValidity"in t){const r=y(n,e);t.setCustomValidity(r&&r.message||""),t.reportValidity()}},Ot=(t,e)=>{for(const n in e.fields){const r=e.fields[n];r&&r.ref&&"reportValidity"in r.ref?wt(r.ref,n,t):r&&r.refs&&r.refs.forEach((e=>wt(e,n,t)))}},St=(t,e)=>{e.shouldUseNativeValidation&&Ot(t,e);const n={};for(const r in t){const a=y(e.fields,r),o=Object.assign(t[r]||{},{ref:a&&a.ref});if(_t(e.names||Object.keys(t),r)){const t=Object.assign({},y(n,r));v(t,"root",o),v(n,r,t)}else v(n,r,o)}return n},_t=(t,e)=>{const n=Mt(e);return t.some((t=>Mt(t).match(`^${n}\\.\\d+`)))};function Mt(t){return t.replace(/\]|\[/g,"")}var Tt;!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"}(Tt||(Tt={}));var Nt=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,n){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?n===Tt.CLASS_TO_CLASS||n===Tt.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||n===Tt.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),n=e&&e.get(void 0),r=this._exposeMetadatas.get(t),a=r&&r.get(void 0);return n&&a||!n&&!a?"none":n?"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===Tt.CLASS_TO_CLASS||e===Tt.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===Tt.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===Tt.CLASS_TO_CLASS||e===Tt.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===Tt.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 n,r=t.get(e);r&&(n=Array.from(r.values()).filter((function(t){return void 0!==t.propertyName})));for(var a=[],o=0,i=this.getAncestors(e);o<i.length;o++){var s=i[o],c=t.get(s);if(c){var l=Array.from(c.values()).filter((function(t){return void 0!==t.propertyName}));a.push.apply(a,l)}}return a.concat(n||[])},t.prototype.findMetadata=function(t,e,n){var r=t.get(e);if(r){var a=r.get(n);if(a)return a}for(var o=0,i=this.getAncestors(e);o<i.length;o++){var s=i[o],c=t.get(s);if(c){var l=c.get(n);if(l)return l}}},t.prototype.findMetadatas=function(t,e,n){var r,a=t.get(e);a&&(r=a.get(n));for(var o=[],i=0,s=this.getAncestors(e);i<s.length;i++){var c=s[i],l=t.get(c);l&&l.has(n)&&o.push.apply(o,l.get(n))}return o.slice().reverse().concat((r||[]).slice().reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],n=Object.getPrototypeOf(t.prototype.constructor);void 0!==n.prototype;n=Object.getPrototypeOf(n.prototype.constructor))e.push(n);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}(),xt=new Nt;var At=function(t,e,n){if(n||2===arguments.length)for(var r,a=0,o=e.length;a<o;a++)!r&&a in e||(r||(r=Array.prototype.slice.call(e,0,a)),r[a]=e[a]);return t.concat(r||Array.prototype.slice.call(e))};var Ct=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,n,r,a,o){var i,s=this;if(void 0===o&&(o=0),Array.isArray(e)||e instanceof Set){var c=r&&this.transformationType===Tt.PLAIN_TO_CLASS?function(t){var e=new t;return e instanceof Set||"push"in e?e:[]}(r):[];return e.forEach((function(e,r){var a=t?t[r]:void 0;if(s.options.enableCircularCheck&&s.isCircular(e))s.transformationType===Tt.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var i=void 0;if("function"!=typeof n&&n&&n.options&&n.options.discriminator&&n.options.discriminator.property&&n.options.discriminator.subTypes){if(s.transformationType===Tt.PLAIN_TO_CLASS){i=n.options.discriminator.subTypes.find((function(t){return t.name===e[n.options.discriminator.property]}));var l={newObject:c,object:e,property:void 0},u=n.typeFunction(l);i=void 0===i?u:i.value,n.options.keepDiscriminatorProperty||delete e[n.options.discriminator.property]}s.transformationType===Tt.CLASS_TO_CLASS&&(i=e.constructor),s.transformationType===Tt.CLASS_TO_PLAIN&&(e[n.options.discriminator.property]=n.options.discriminator.subTypes.find((function(t){return t.value===e.constructor})).name)}else i=n;var p=s.transform(a,e,i,void 0,e instanceof Map,o+1);c instanceof Set?c.add(p):c.push(p)}})),c}if(n!==String||a){if(n!==Number||a){if(n!==Boolean||a){if((n===Date||e instanceof Date)&&!a)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&&(n===Buffer||e instanceof Buffer)&&!a)return null==e?e:Buffer.from(e);if(null===(i=e)||"object"!=typeof i||"function"!=typeof i.then||a){if(a||null===e||"object"!=typeof e||"function"!=typeof e.then){if("object"==typeof e&&null!==e){n||e.constructor===Object||(Array.isArray(e)||e.constructor!==Array)&&(n=e.constructor),!n&&t&&(n=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var l=this.getKeys(n,e,a),u=t||{};t||this.transformationType!==Tt.PLAIN_TO_CLASS&&this.transformationType!==Tt.CLASS_TO_CLASS||(u=a?new Map:n?new n:{});for(var p=function(r){if("__proto__"===r||"constructor"===r)return"continue";var i=r,s=r,c=r;if(!f.options.ignoreDecorators&&n)if(f.transformationType===Tt.PLAIN_TO_CLASS)(l=xt.findExposeMetadataByCustomName(n,r))&&(c=l.propertyName,s=l.propertyName);else if(f.transformationType===Tt.CLASS_TO_PLAIN||f.transformationType===Tt.CLASS_TO_CLASS){var l;(l=xt.findExposeMetadata(n,r))&&l.options&&l.options.name&&(s=l.options.name)}var p=void 0;p=f.transformationType===Tt.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(n&&a)d=n;else if(n){var m=xt.findTypeMetadata(n,c);if(m){var y={newObject:u,object:e,property:c},v=m.typeFunction?m.typeFunction(y):m.reflectedType;m.options&&m.options.discriminator&&m.options.discriminator.property&&m.options.discriminator.subTypes?e[i]instanceof Array?d=m:(f.transformationType===Tt.PLAIN_TO_CLASS&&(d=void 0===(d=m.options.discriminator.subTypes.find((function(t){if(p&&p instanceof Object&&m.options.discriminator.property in p)return t.name===p[m.options.discriminator.property]})))?v:d.value,m.options.keepDiscriminatorProperty||p&&p instanceof Object&&m.options.discriminator.property in p&&delete p[m.options.discriminator.property]),f.transformationType===Tt.CLASS_TO_CLASS&&(d=p.constructor),f.transformationType===Tt.CLASS_TO_PLAIN&&p&&(p[m.options.discriminator.property]=m.options.discriminator.subTypes.find((function(t){return t.value===p.constructor})).name)):d=v,h=h||m.reflectedType===Map}else if(f.options.targetMaps)f.options.targetMaps.filter((function(t){return t.target===n&&!!t.properties[c]})).forEach((function(t){return d=t.properties[c]}));else if(f.options.enableImplicitConversion&&f.transformationType===Tt.PLAIN_TO_CLASS){var g=Reflect.getMetadata("design:type",n.prototype,c);g&&(d=g)}}var E=Array.isArray(e[i])?f.getReflectedType(n,c):void 0,b=t?t[i]:void 0;if(u.constructor.prototype){var w=Object.getOwnPropertyDescriptor(u.constructor.prototype,s);if((f.transformationType===Tt.PLAIN_TO_CLASS||f.transformationType===Tt.CLASS_TO_CLASS)&&(w&&!w.set||u[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(p)){if(f.transformationType===Tt.CLASS_TO_CLASS){S=p;(void 0!==(S=f.applyCustomTransformations(S,n,r,e,f.transformationType))||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,S):u[s]=S)}}else{var O=f.transformationType===Tt.PLAIN_TO_CLASS?s:r,S=void 0;f.transformationType===Tt.CLASS_TO_PLAIN?(S=e[O],S=f.applyCustomTransformations(S,n,O,e,f.transformationType),S=e[O]===S?p:S,S=f.transform(b,S,d,E,h,o+1)):void 0===p&&f.options.exposeDefaultValues?S=u[s]:(S=f.transform(b,p,d,E,h,o+1),S=f.applyCustomTransformations(S,n,O,e,f.transformationType)),(void 0!==S||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,S):u[s]=S)}},f=this,d=0,h=l;d<h.length;d++){p(h[d])}return this.options.enableCircularCheck&&this.recursionStack.delete(e),u}return e}return e}return new Promise((function(t,r){e.then((function(e){return t(s.transform(void 0,e,n,void 0,void 0,o+1))}),r)}))}return null==e?e:Boolean(e)}return null==e?e:Number(e)}return null==e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,n,r,a){var o=this,i=xt.findTransformMetadatas(e,n,this.transformationType);return void 0!==this.options.version&&(i=i.filter((function(t){return!t.options||o.checkVersion(t.options.since,t.options.until)}))),(i=this.options.groups&&this.options.groups.length?i.filter((function(t){return!t.options||o.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:n,obj:r,type:a,options:o.options})})),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var n=xt.findTypeMetadata(t,e);return n?n.reflectedType:void 0}},t.prototype.getKeys=function(t,e,n){var r=this,a=xt.getStrategy(t);"none"===a&&(a=this.options.strategy||"exposeAll");var o=[];if(("exposeAll"===a||n)&&(o=e instanceof Map?Array.from(e.keys()):Object.keys(e)),n)return o;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&t){var i=xt.getExposedProperties(t,this.transformationType),s=xt.getExcludedProperties(t,this.transformationType);o=At(At([],i,!0),s,!0)}if(!this.options.ignoreDecorators&&t){i=xt.getExposedProperties(t,this.transformationType);this.transformationType===Tt.PLAIN_TO_CLASS&&(i=i.map((function(e){var n=xt.findExposeMetadata(t,e);return n&&n.options&&n.options.name?n.options.name:e}))),o=this.options.excludeExtraneousValues?i:o.concat(i);var c=xt.getExcludedProperties(t,this.transformationType);c.length>0&&(o=o.filter((function(t){return!c.includes(t)}))),void 0!==this.options.version&&(o=o.filter((function(e){var n=xt.findExposeMetadata(t,e);return!n||!n.options||r.checkVersion(n.options.since,n.options.until)}))),o=this.options.groups&&this.options.groups.length?o.filter((function(e){var n=xt.findExposeMetadata(t,e);return!n||!n.options||r.checkGroups(n.options.groups)})):o.filter((function(e){var n=xt.findExposeMetadata(t,e);return!(n&&n.options&&n.options.groups&&n.options.groups.length)}))}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(o=o.filter((function(t){return r.options.excludePrefixes.every((function(e){return t.substr(0,e.length)!==e}))}))),o=o.filter((function(t,e,n){return n.indexOf(t)===e}))},t.prototype.checkVersion=function(t,e){var n=!0;return n&&t&&(n=this.options.version>=t),n&&e&&(n=this.options.version<e),n},t.prototype.checkGroups=function(t){return!t||this.options.groups.some((function(e){return t.includes(e)}))},t}(),kt={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},Lt=function(){return Lt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var a in e=arguments[n])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},Lt.apply(this,arguments)},Pt=new(function(){function t(){}return t.prototype.instanceToPlain=function(t,e){return new Ct(Tt.CLASS_TO_PLAIN,Lt(Lt({},kt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,n){return new Ct(Tt.CLASS_TO_PLAIN,Lt(Lt({},kt),n)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToInstance=function(t,e,n){return new Ct(Tt.PLAIN_TO_CLASS,Lt(Lt({},kt),n)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,n){return new Ct(Tt.PLAIN_TO_CLASS,Lt(Lt({},kt),n)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.instanceToInstance=function(t,e){return new Ct(Tt.CLASS_TO_CLASS,Lt(Lt({},kt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,n){return new Ct(Tt.CLASS_TO_CLASS,Lt(Lt({},kt),n)).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,n){var r=JSON.parse(e);return this.plainToInstance(t,r,n)},t.prototype.deserializeArray=function(t,e,n){var r=JSON.parse(e);return this.plainToInstance(t,r,n)},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)},jt=function(){function t(){}return t.prototype.transform=function(t){var e=[];return Object.keys(t.properties).forEach((function(n){t.properties[n].forEach((function(r){var a={message:r.message,groups:r.groups,always:r.always,each:r.each},o={type:r.type,name:r.name,target:t.name,propertyName:n,constraints:r.constraints,validationTypeOptions:r.options,validationOptions:a};e.push(new It(o))}))})),e},t}();function Vt(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function Dt(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var Ft=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Rt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,a,o=n.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(t){a={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},zt=function(t,e,n){if(n||2===arguments.length)for(var r,a=0,o=e.length;a<o;a++)!r&&a in e||(r||(r=Array.prototype.slice.call(e,0,a)),r[a]=e[a]);return t.concat(r||Array.prototype.slice.call(e))},Bt=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 jt).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,n,r,a){var o,i,s=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&n},c=function(t){return!(!r||a&&a.length||!t.groups||!t.groups.length)},l=(this.validationMetadatas.get(t)||[]).filter((function(n){return(n.target===t||n.target===e)&&(!!s(n)||!c(n)&&(!(a&&a.length>0)||n.groups&&!!n.groups.find((function(t){return-1!==a.indexOf(t)}))))})),u=[];try{for(var p=Ft(this.validationMetadatas.entries()),f=p.next();!f.done;f=p.next()){var d=Rt(f.value,2),h=d[0],m=d[1];t.prototype instanceof h&&u.push.apply(u,zt([],Rt(m),!1))}}catch(t){o={error:t}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(o)throw o.error}}var y=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)&&(!(a&&a.length>0)||e.groups&&!!e.groups.find((function(t){return-1!==a.indexOf(t)}))))))})).filter((function(t){return!l.find((function(e){return e.propertyName===t.propertyName&&e.type===t.type}))}));return l.concat(y)},t.prototype.getTargetValidatorConstraints=function(t){return this.constraintMetadatas.get(t)||[]},t}();var $t=function(){function t(){}return t.prototype.toString=function(t,e,n,r){var a=this;void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===n&&(n=""),void 0===r&&(r=!1);var o=t?"":"",i=t?"":"",s=function(t){return" - property ".concat(o).concat(n).concat(t).concat(i," has failed the following constraints: ").concat(o).concat((r?Object.values:Object.keys)(null!==(e=a.constraints)&&void 0!==e?e:{}).join(", ")).concat(i," \n");var e};if(e){var c=Number.isInteger(+this.property)?"[".concat(this.property,"]"):"".concat(n?".":"").concat(this.property);return this.constraints?s(c):this.children?this.children.map((function(e){return e.toString(t,!0,"".concat(n).concat(c),r)})).join(""):""}return"An instance of ".concat(o).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,a.property,r)})).join(""):"")},t}(),Ht=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 Ut=function(){function t(){}return t.replaceMessageSpecialTokens=function(t,e){var n;return t instanceof Function?n=t(e):"string"==typeof t&&(n=t),n&&Array.isArray(e.constraints)&&e.constraints.forEach((function(t,e){n=n.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))})),n&&void 0!==e.value&&null!==e.value&&["string","boolean","number"].includes(typeof e.value)&&(n=n.replace(/\$value/g,e.value)),n&&(n=n.replace(/\$property/g,e.property)),n&&(n=n.replace(/\$target/g,e.targetName)),n},t}(),Kt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,a,o=n.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(t){a={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},Wt=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=function(){var t=Vt();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new Bt),t.classValidatorMetadataStorage}()}return t.prototype.execute=function(t,e,n){var r,a,o=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(r=this.validatorOptions)||void 0===r?void 0:r.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===(a=this.validatorOptions)||void 0===a?void 0:a.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 $t;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 n.push(f)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(t,p,n),Object.keys(p).forEach((function(e){var r=t[e],a=p[e].filter((function(t){return t.type===Ht.IS_DEFINED})),i=p[e].filter((function(t){return t.type!==Ht.IS_DEFINED&&t.type!==Ht.WHITELIST}));r instanceof Promise&&i.find((function(t){return t.type===Ht.PROMISE_VALIDATION}))?o.awaitingPromises.push(r.then((function(r){o.performValidations(t,r,e,a,i,n)}))):o.performValidations(t,r,e,a,i,n)}))},t.prototype.whitelist=function(t,e,n){var r=this,a=[];Object.keys(t).forEach((function(t){e[t]&&0!==e[t].length||a.push(t)})),a.length>0&&(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?a.forEach((function(e){var a,o=r.generateValidationError(t,t[e],e);o.constraints=((a={})[Ht.WHITELIST]="property ".concat(e," should not exist"),a),o.children=void 0,n.push(o)})):a.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,n,r,a,o){var i=a.filter((function(t){return t.type===Ht.CUSTOM_VALIDATION})),s=a.filter((function(t){return t.type===Ht.NESTED_VALIDATION})),c=a.filter((function(t){return t.type===Ht.CONDITIONAL_VALIDATION})),l=this.generateValidationError(t,e,n);o.push(l),this.conditionalValidations(t,e,c)&&(this.customValidations(t,e,r,l),this.mapContexts(t,e,r,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,a,l),this.mapContexts(t,e,i,l)))},t.prototype.generateValidationError=function(t,e,n){var r=new $t;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(r.target=t),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(r.value=e),r.property=n,r.children=[],r.constraints={},r},t.prototype.conditionalValidations=function(t,e,n){return n.map((function(n){return n.constraints[0](t,e)})).reduce((function(t,e){return t&&e}),!0)},t.prototype.customValidations=function(t,e,n,r){var a=this;n.forEach((function(n){a.metadataStorage.getTargetValidatorConstraints(n.constraintCls).forEach((function(o){if(!(o.async&&a.ignoreAsyncValidations||a.validatorOptions&&a.validatorOptions.stopAtFirstError&&Object.keys(r.constraints||{}).length>0)){var i={targetName:t.constructor?t.constructor.name:void 0,property:n.propertyName,object:t,value:e,constraints:n.constraints};if(n.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 o.instance.validate(t,i)}));if(c.some((function(t){return Dt(t)}))){var l=c.map((function(t){return Dt(t)?t:Promise.resolve(t)})),u=Promise.all(l).then((function(i){if(!i.every((function(t){return t}))){var s=Kt(a.createValidationError(t,e,n,o),2),c=s[0],l=s[1];r.constraints[c]=l,n.context&&(r.contexts||(r.contexts={}),r.contexts[c]=Object.assign(r.contexts[c]||{},n.context))}}));a.awaitingPromises.push(u)}else{if(!c.every((function(t){return t}))){var p=Kt(a.createValidationError(t,e,n,o),2);m=p[0],y=p[1];r.constraints[m]=y}}}else{var f=o.instance.validate(e,i);if(Dt(f)){var d=f.then((function(i){if(!i){var s=Kt(a.createValidationError(t,e,n,o),2),c=s[0],l=s[1];r.constraints[c]=l,n.context&&(r.contexts||(r.contexts={}),r.contexts[c]=Object.assign(r.contexts[c]||{},n.context))}}));a.awaitingPromises.push(d)}else if(!f){var h=Kt(a.createValidationError(t,e,n,o),2),m=h[0],y=h[1];r.constraints[m]=y}}}}))}))},t.prototype.nestedValidations=function(t,e,n){var r=this;void 0!==t&&e.forEach((function(a){if((a.type===Ht.NESTED_VALIDATION||a.type===Ht.PROMISE_VALIDATION)&&!(r.validatorOptions&&r.validatorOptions.stopAtFirstError&&Object.keys(n.constraints||{}).length>0))if(Array.isArray(t)||t instanceof Set||t instanceof Map)(t instanceof Set?Array.from(t):t).forEach((function(a,o){r.performValidations(t,a,o.toString(),[],e,n.children)}));else if(t instanceof Object){var o="string"==typeof a.target?a.target:a.target.name;r.execute(t,o,n.children)}else{var i=Kt(r.createValidationError(a.target,t,a),2),s=i[0],c=i[1];n.constraints[s]=c}}))},t.prototype.mapContexts=function(t,e,n,r){var a=this;return n.forEach((function(t){if(t.context){var e=void 0;if(t.type===Ht.CUSTOM_VALIDATION)e=a.metadataStorage.getTargetValidatorConstraints(t.constraintCls)[0];var n=a.getConstraintType(t,e);r.constraints[n]&&(r.contexts||(r.contexts={}),r.contexts[n]=Object.assign(r.contexts[n]||{},t.context))}}))},t.prototype.createValidationError=function(t,e,n,r){var a=t.constructor?t.constructor.name:void 0,o=this.getConstraintType(n,r),i={targetName:a,property:n.propertyName,object:t,value:e,constraints:n.constraints},s=n.message||"";return n.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||r&&r.instance.defaultMessage instanceof Function&&(s=r.instance.defaultMessage(i)),[o,Ut.replaceMessageSpecialTokens(s,i)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),Gt=function(t,e,n,r){return new(n||(n=Promise))((function(a,o){function i(t){try{c(r.next(t))}catch(t){o(t)}}function s(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,s)}c((r=r.apply(t,e||[])).next())}))},qt=function(t,e){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},Jt=function(){function t(){}return t.prototype.validate=function(t,e,n){return this.coreValidate(t,e,n)},t.prototype.validateOrReject=function(t,e,n){return Gt(this,void 0,void 0,(function(){var r;return qt(this,(function(a){switch(a.label){case 0:return[4,this.coreValidate(t,e,n)];case 1:return(r=a.sent()).length?[2,Promise.reject(r)]:[2]}}))}))},t.prototype.validateSync=function(t,e,n){var r="string"==typeof t?e:t,a="string"==typeof t?t:void 0,o=new Wt(this,"string"==typeof t?n:e);o.ignoreAsyncValidations=!0;var i=[];return o.execute(r,a,i),o.stripEmptyErrors(i)},t.prototype.coreValidate=function(t,e,n){var r="string"==typeof t?e:t,a="string"==typeof t?t:void 0,o=new Wt(this,"string"==typeof t?n:e),i=[];return o.execute(r,a,i),Promise.all(o.awaitingPromises).then((function(){return o.stripEmptyErrors(i)}))},t}(),Yt=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 Qt(t){return Yt.get(t)}function Xt(t,e,n){return"string"==typeof t?Qt(Jt).validate(t,e,n):Qt(Jt).validate(t,e)}function Zt(t,e,n){return"string"==typeof t?Qt(Jt).validateSync(t,e,n):Qt(Jt).validateSync(t,e)}function te(t,e,n,r){return void 0===n&&(n={}),void 0===r&&(r=""),t.reduce((function(t,n){var a=r?r+"."+n.property:n.property;if(n.constraints){var o=Object.keys(n.constraints)[0];t[a]={type:o,message:n.constraints[o]};var i=t[a];e&&i&&Object.assign(i,{types:n.constraints})}return n.children&&n.children.length&&te(n.children,e,t,a),t}),n)}function ee(t,e,n){return void 0===e&&(e={}),void 0===n&&(n={}),function(r,a,o){try{var i=e.validator,s=(c=t,l=r,u=e.transformer,Pt.plainToInstance(c,l,u));return Promise.resolve(("sync"===n.mode?Zt:Xt)(s,i)).then((function(t){return t.length?{values:{},errors:St(te(t,!o.shouldUseNativeValidation&&"all"===o.criteriaMode),o)}:(o.shouldUseNativeValidation&&Ot({},o),{values:n.raw?Object.assign({},r):s,errors:{}})}))}catch(t){return Promise.reject(t)}var c,l,u}}function ne(t){return{resolver:ee(t),form:bt(t),inputs:Et(t)}}function re({model:t,getDetailsData:n,onSubmit:a,redirect:o,redirectBackOnSuccess:i=!0,...s}){const c=r((()=>ne(t)),[t]);return e.createElement(ht,{getDetailsData:n,onSubmit:a,formOptions:c,redirectBackOnSuccess:i})}const ae=b()(g((t=>({screens:null,user:null,screenPaths:{}})),{name:"app-store-1",storage:E((()=>localStorage)),partialize:t=>({user:t.user})}),w);function oe({onLogin:t}){const{register:n,handleSubmit:r,formState:{errors:a}}=h(),o=u();return e.createElement("div",{className:"login-container"},e.createElement("div",{className:"login-panel"},e.createElement("div",{className:"login-header"},e.createElement("h1",null,"Welcome Back"),e.createElement("p",null,"Please sign in to continue")),e.createElement("form",{onSubmit:r((async e=>{t.login(e.username,e.password).then((t=>{const{user:e,token:n}=t;localStorage.setItem("token",n),ae.setState({user:e}),o("/")}))})),className:"login-form"},e.createElement(dt,{input:{name:"username",label:"Username",placeholder:"Enter your username",type:"input"},register:n,error:a.username}),e.createElement(dt,{input:{name:"password",label:"Password",inputType:"password",placeholder:"Enter your password",type:"input"},register:n,error:a.password}),e.createElement("div",{className:"form-actions"},e.createElement("button",{type:"submit",className:"submit-button"},"Sign In")))))}function ie({menu:t,getIcons:n,onLogout:r}){const{screens:a,screenPaths:i}=ae((t=>({screens:t.screens??{},screenPaths:t.screenPaths??{}}))),[s,l]=o(!0),f=p(),d=u(),h=t=>{if("/"===t)return f.pathname===t;const e=t.replace(/^\/+|\/+$/g,""),n=f.pathname.replace(/^\/+|\/+$/g,"");return n===e||n.startsWith(`${e}/`)};return e.createElement("div",{className:"sidebar "+(s?"open":"closed")},e.createElement("button",{className:"toggle-button",onClick:()=>l(!s),"aria-label":s?"Collapse sidebar":"Expand sidebar","aria-expanded":s},s?"<":">"),e.createElement("nav",{className:"nav-links"},t?.(a).map(((t,r)=>e.createElement(c,{key:r,to:t.path,className:"nav-link "+(h(t.path)?"active":""),"aria-current":h(t.path)?"page":void 0},e.createElement("span",{className:"nav-links-icon"},n?.(t.iconType)),s?e.createElement("span",null,t.name):null)))),r&&e.createElement("div",{className:"sidebar-footer"},e.createElement("button",{className:"logout-button",onClick:()=>{r&&(r(),d(i.login))},"aria-label":"Logout"},e.createElement("span",{className:"nav-links-icon"},e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M6 12H2V4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.createElement("path",{d:"M10 8L14 4M14 4L10 0M14 4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))),s?e.createElement("span",null,"Logout"):null)))}function se({children:t,menu:n,getIcons:r,logout:a}){const{user:o,screenPaths:i}=ae((t=>({user:t.user,screenPaths:t.screenPaths})));ae();const s=u();return o||s(i.login),e.createElement("div",{className:"layout"},e.createElement(ie,{onLogout:()=>{a&&a()},menu:n,getIcons:r}),e.createElement("main",{className:"content"},t))}function ce({children:t,init:n}){return a((()=>{!function({screenPaths:t}){ae.setState({screenPaths:t})}(n())}),[n]),e.createElement(yt,null,t)}function le(t){return K({...t,type:"image"})}function ue(t){return e=>{t&&Reflect.defineMetadata("Crud",t,e)}}export{K as Cell,mt as Counter,ue as Crud,re as FormPage,le as ImageCell,gt as Input,se as Layout,$ as List,ot as ListPage,oe as Login,ce as Panel,ne as getFormFields,Et as getInputFields};
1
+ import*as t from"react";import e,{useRef as n,useMemo as r,useEffect as a,useState as o,useCallback as i,Component as s}from"react";import{Link as c,useParams as l,useNavigate as u,useLocation as p}from"react-router";import f from"react-select";import{useFormContext as d,useForm as h,FormProvider as m,get as y,set as v}from"react-hook-form";import{persist as g,createJSONStorage as E}from"zustand/middleware";import{createWithEqualityFn as b}from"zustand/traditional";import{shallow as w}from"zustand/vanilla/shallow";const O=()=>e.createElement("div",{className:"empty-list"},e.createElement("div",{className:"empty-list-content"},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),e.createElement("polyline",{points:"13 2 13 9 20 9"})),e.createElement("h3",null,"No Data Found"),e.createElement("p",null,"There are no items to display at the moment.")));var S,_;function M(){return M=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},M.apply(null,arguments)}var T,N,x=function(e){return t.createElement("svg",M({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),S||(S=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),_||(_=t.createElement("path",{d:"m21 19-5.154-5.154a7 7 0 1 0-2 2L19 21zM5 10c0-2.757 2.243-5 5-5s5 2.243 5 5-2.243 5-5 5-5-2.243-5-5"})))};function A(){return A=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},A.apply(null,arguments)}var k,C,P=function(e){return t.createElement("svg",A({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),T||(T=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),N||(N=t.createElement("path",{d:"m13 6 5 5-9.507 9.507a1.765 1.765 0 0 1-.012-2.485l-.002-.003c-.69.676-1.8.673-2.485-.013a1.763 1.763 0 0 1-.036-2.455l-.008-.008c-.694.65-1.78.64-2.456-.036zm7.586-.414-2.172-2.172a2 2 0 0 0-2.828 0L14 5l5 5 1.586-1.586c.78-.78.78-2.047 0-2.828M3 18v3h3a3 3 0 0 0-3-3"})))};function L(){return L=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},L.apply(null,arguments)}var I=function(e){return t.createElement("svg",L({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),k||(k=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),C||(C=t.createElement("path",{d:"M6.187 8h11.625l-.695 11.125A2 2 0 0 1 15.12 21H8.88a2 2 0 0 1-1.997-1.875zM19 5v2H5V5h3V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1zm-9 0h4V4h-4z"})))};function j({data:t,listData:n,onRemoveItem:r}){const a=n.cells,o=t?.[0]?"function"==typeof n.list?.cells?n.list?.cells?.(t[0]):n.list?.cells:null;return e.createElement("div",{className:"datagrid"},t&&0!==t.length?e.createElement("table",{className:"datagrid-table"},e.createElement("thead",null,e.createElement("tr",null,a.map((t=>e.createElement("th",{key:t.name},t.title??t.name))),o?.details&&e.createElement("th",null,"Details"),o?.edit&&e.createElement("th",null,"Edit"),o?.delete&&e.createElement("th",null,"Delete"))),e.createElement("tbody",null,t.map(((t,o)=>{const i=t?"function"==typeof n.list?.cells?n.list?.cells?.(t):n.list?.cells:null;return e.createElement("tr",{key:o},a.map((n=>{const r=t[n.name];let a=r??"-";switch(n.type){case"date":if(r){const t=new Date(r);a=`${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 t=n;a=e.createElement("img",{width:100,height:100,src:t.baseUrl+r,style:{objectFit:"contain"}});break}default:a=r?r.toString():n?.placeHolder??"-"}return e.createElement("td",{key:n.name},a)})),i?.details&&e.createElement("td",null,e.createElement(c,{to:i.details.path,className:"util-cell-link"},e.createElement(x,{className:"icon icon-search"}),e.createElement("span",{className:"util-cell-label"},i.details.label))),i?.edit&&e.createElement("td",null,e.createElement(c,{to:i.edit.path,className:"util-cell-link"},e.createElement(P,{className:"icon icon-pencil"}),e.createElement("span",{className:"util-cell-label"},i.edit.label))),i?.delete&&e.createElement("td",null,e.createElement("a",{onClick:()=>{r?.(t)},className:"util-cell-link util-cell-link-remove"},e.createElement(I,{className:"icon icon-trash"}),e.createElement("span",{className:"util-cell-label"},i.delete.label))))})))):e.createElement(O,null))}function V({error:t}){return e.createElement("div",{className:"error-container"},e.createElement("div",{className:"error-icon"},e.createElement("i",{className:"fa fa-exclamation-circle"})),e.createElement("div",{className:"error-content"},e.createElement("h3",null,"Error Occurred"),e.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."})(t))))}function D(){return e.createElement("div",{className:"loading-screen"},e.createElement("div",{className:"loading-container"},e.createElement("div",{className:"loading-spinner"}),e.createElement("div",{className:"loading-text"},"Loading...")))}var F,R="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},$={};!function(){return F||(F=1,function(t){!function(){var e="object"==typeof globalThis?globalThis:"object"==typeof R?R:"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){}}(),n=r(t);function r(t,e){return function(n,r){Object.defineProperty(t,n,{configurable:!0,writable:!0,value:r}),e&&e(n,r)}}void 0!==e.Reflect&&(n=r(e.Reflect,n)),function(t,e){var n=Object.prototype.hasOwnProperty,r="function"==typeof Symbol,a=r&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=r&&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 n.call(t,e)}:function(t,e){return e in t},get:c?function(t,e){return n.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=r?Symbol.for("@reflect-metadata:registry"):void 0,m=at(),y=ot(m);function v(t,e,n,r){if(D(n)){if(!W(t))throw new TypeError;if(!q(e))throw new TypeError;return N(t,e)}if(!W(t))throw new TypeError;if(!$(e))throw new TypeError;if(!$(r)&&!D(r)&&!F(r))throw new TypeError;return F(r)&&(r=void 0),x(t,e,n=K(n),r)}function g(t,e){function n(n,r){if(!$(n))throw new TypeError;if(!D(r)&&!J(r))throw new TypeError;L(t,e,n,r)}return n}function E(t,e,n,r){if(!$(n))throw new TypeError;return D(r)||(r=K(r)),L(t,e,n,r)}function b(t,e,n){if(!$(e))throw new TypeError;return D(n)||(n=K(n)),A(t,e,n)}function w(t,e,n){if(!$(e))throw new TypeError;return D(n)||(n=K(n)),k(t,e,n)}function O(t,e,n){if(!$(e))throw new TypeError;return D(n)||(n=K(n)),C(t,e,n)}function S(t,e,n){if(!$(e))throw new TypeError;return D(n)||(n=K(n)),P(t,e,n)}function _(t,e){if(!$(t))throw new TypeError;return D(e)||(e=K(e)),I(t,e)}function M(t,e){if(!$(t))throw new TypeError;return D(e)||(e=K(e)),j(t,e)}function T(t,e,n){if(!$(e))throw new TypeError;if(D(n)||(n=K(n)),!$(e))throw new TypeError;D(n)||(n=K(n));var r=st(e,n,!1);return!D(r)&&r.OrdinaryDeleteMetadata(t,e,n)}function N(t,e){for(var n=t.length-1;n>=0;--n){var r=(0,t[n])(e);if(!D(r)&&!F(r)){if(!q(r))throw new TypeError;e=r}}return e}function x(t,e,n,r){for(var a=t.length-1;a>=0;--a){var o=(0,t[a])(e,n,r);if(!D(o)&&!F(o)){if(!$(o))throw new TypeError;r=o}}return r}function A(t,e,n){if(k(t,e,n))return!0;var r=nt(e);return!F(r)&&A(t,r,n)}function k(t,e,n){var r=st(e,n,!1);return!D(r)&&H(r.OrdinaryHasOwnMetadata(t,e,n))}function C(t,e,n){if(k(t,e,n))return P(t,e,n);var r=nt(e);return F(r)?void 0:C(t,r,n)}function P(t,e,n){var r=st(e,n,!1);if(!D(r))return r.OrdinaryGetOwnMetadata(t,e,n)}function L(t,e,n,r){st(n,r,!0).OrdinaryDefineOwnMetadata(t,e,n,r)}function I(t,e){var n=j(t,e),r=nt(t);if(null===r)return n;var a=I(r,e);if(a.length<=0)return n;if(n.length<=0)return a;for(var o=new f,i=[],s=0,c=n;s<c.length;s++){var l=c[s];o.has(l)||(o.add(l),i.push(l))}for(var u=0,p=a;u<p.length;u++){l=p[u];o.has(l)||(o.add(l),i.push(l))}return i}function j(t,e){var n=st(t,e,!1);return n?n.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 z(t,e){switch(V(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var n="string",r=Q(t,a);if(void 0!==r){var o=r.call(t,n);if($(o))throw new TypeError;return o}return B(t)}function B(t,e){var n,r,a=t.toString;if(G(a)&&!$(r=a.call(t)))return r;if(G(n=t.valueOf)&&!$(r=n.call(t)))return r;throw new TypeError}function H(t){return!!t}function U(t){return""+t}function K(t){var e=z(t);return R(e)?e:U(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(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 n=t[e];if(null!=n){if(!G(n))throw new TypeError;return n}}function X(t){var e=Q(t,o);if(!G(e))throw new TypeError;var n=e.call(t);if(!$(n))throw new TypeError;return n}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 nt(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===u)return e;if(e!==u)return e;var n=t.prototype,r=n&&Object.getPrototypeOf(n);if(null==r||r===Object.prototype)return e;var a=r.constructor;return"function"!=typeof a||a===t?e:a}function rt(){var t,n,r,a;D(h)||void 0===e.Reflect||h in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=it(e.Reflect));var o=new d,i={registerProvider:s,getProvider:l,setProvider:m};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(n):n=e;break;case n===e:break;case D(r):r=e;break;case r===e:break;default:void 0===a&&(a=new f),a.add(e)}}function c(e,o){if(!D(n)){if(n.isProviderFor(e,o))return n;if(!D(r)){if(r.isProviderFor(e,o))return n;if(!D(a))for(var i=X(a);;){var s=tt(i);if(!s)return;var c=Z(s);if(c.isProviderFor(e,o))return et(i),c}}}if(!D(t)&&t.isProviderFor(e,o))return t}function l(t,e){var n,r=o.get(t);return D(r)||(n=r.get(e)),D(n)?(D(n=c(t,e))||(D(r)&&(r=new p,o.set(t,r)),r.set(e,n)),n):n}function u(t){if(D(t))throw new TypeError;return n===t||r===t||!D(a)&&a.has(t)}function m(t,e,n){if(!u(n))throw new Error("Metadata provider not registered.");var r=l(t,e);if(r!==n){if(!D(r))return!1;var a=o.get(t);D(a)&&(a=new p,o.set(t,a)),a.set(e,n)}return!0}}function at(){var t;return!D(h)&&$(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[h]),D(t)&&(t=rt()),!D(h)&&$(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}function ot(t){var e=new d,n={isProviderFor:function(t,n){var r=e.get(t);return!D(r)&&r.has(n)},OrdinaryDefineOwnMetadata:i,OrdinaryHasOwnMetadata:a,OrdinaryGetOwnMetadata:o,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return m.registerProvider(n),n;function r(r,a,o){var i=e.get(r),s=!1;if(D(i)){if(!o)return;i=new p,e.set(r,i),s=!0}var c=i.get(a);if(D(c)){if(!o)return;if(c=new p,i.set(a,c),!t.setProvider(r,a,n))throw i.delete(a),s&&e.delete(r),new Error("Wrong provider for target.")}return c}function a(t,e,n){var a=r(e,n,!1);return!D(a)&&H(a.has(t))}function o(t,e,n){var a=r(e,n,!1);if(!D(a))return a.get(t)}function i(t,e,n,a){r(n,a,!0).set(t,e)}function s(t,e){var n=[],a=r(t,e,!1);if(D(a))return n;for(var o=X(a.keys()),i=0;;){var s=tt(o);if(!s)return n.length=i,n;var c=Z(s);try{n[i]=c}catch(t){try{et(o)}finally{throw t}}i++}}function c(t,n,a){var o=r(n,a,!1);if(D(o))return!1;if(!o.delete(t))return!1;if(0===o.size){var i=e.get(n);D(i)||(i.delete(a),0===i.size&&e.delete(i))}return!0}}function it(t){var e=t.defineMetadata,n=t.hasOwnMetadata,r=t.getOwnMetadata,a=t.getOwnMetadataKeys,o=t.deleteMetadata,i=new d;return{isProviderFor:function(t,e){var n=i.get(t);return!(D(n)||!n.has(e))||!!a(t,e).length&&(D(n)&&(n=new f,i.set(t,n)),n.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:r,OrdinaryOwnMetadataKeys:a,OrdinaryDeleteMetadata:o}}function st(t,e,n){var r=m.getProvider(t,e);if(!D(r))return r;if(n){if(m.setProvider(t,e,y))return y;throw new Error("Illegal state.")}}function ct(){var t={},e=[],n=function(){function t(t,e,n){this._index=0,this._keys=t,this._values=e,this._selector=n}return t.prototype["@@iterator"]=function(){return this},t.prototype[o]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var n=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:n,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}(),r=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 n=this._find(t,!0);return this._values[n]=e,this},e.prototype.delete=function(e){var n=this._find(e,!1);if(n>=0){for(var r=this._keys.length,a=n+1;a<r;a++)this._keys[a-1]=this._keys[a],this._values[a-1]=this._values[a];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 n(this._keys,this._values,a)},e.prototype.values=function(){return new n(this._keys,this._values,i)},e.prototype.entries=function(){return new n(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[o]=function(){return this.entries()},e.prototype._find=function(t,e){if(!Y(this._cacheKey,t)){this._cacheIndex=-1;for(var n=0;n<this._keys.length;n++)if(Y(this._keys[n],t)){this._cacheIndex=n;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();return r;function a(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[o]=function(){return this.keys()},t}()}function ut(){var t=16,e=l.create(),r=a();return function(){function t(){this._key=a()}return t.prototype.has=function(t){var e=o(t,!1);return void 0!==e&&l.has(e,this._key)},t.prototype.get=function(t){var e=o(t,!1);return void 0!==e?l.get(e,this._key):void 0},t.prototype.set=function(t,e){return o(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=o(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=a()},t}();function a(){var t;do{t="@@WeakMap@@"+c()}while(l.has(e,t));return e[t]=!0,t}function o(t,e){if(!n.call(t,r)){if(!e)return;Object.defineProperty(t,r,{value:l.create()})}return t[r]}function i(t,e){for(var n=0;n<e;++n)t[n]=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 n="",r=0;r<t;++r){var a=e[r];4!==r&&6!==r&&8!==r||(n+="-"),a<16&&(n+="0"),n+=a.toString(16).toLowerCase()}return n}}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",O),t("getOwnMetadata",S),t("getMetadataKeys",_),t("getOwnMetadataKeys",M),t("deleteMetadata",T)}(n,e),void 0===e.Reflect&&(e.Reflect=t)}()}(t||(t={}))),$;var t}();const z="List";function B(t){return e=>{t&&Reflect.defineMetadata(z,t,e)}}function H(t){return Reflect.getMetadata(z,t)}const U=Symbol("cell");function K(t){return(e,n)=>{const r=Reflect.getMetadata(U,e)||[];if(Reflect.defineMetadata(U,[...r,n.toString()],e),t){const r=`${U.toString()}:${n.toString()}:options`;Reflect.defineMetadata(r,t,e)}}}function W(t){const e=t.prototype;return(Reflect.getMetadata(U,e)||[]).map((t=>{const n=Reflect.getMetadata(`${U.toString()}:${t}:options`,e)||{};return{...n,name:n?.name??t}}))}function G({pagination:t,onPageChange:n}){const{total:r,page:a,limit:o}=t,i=Math.floor(r/o);if(i<=1)return null;return e.createElement("div",{className:"pagination"},e.createElement("button",{onClick:()=>n(a-1),className:"pagination-item "+(1===a?"disabled":""),disabled:1===a,"aria-disabled":1===a},"Previous"),(()=>{const t=[];for(let r=1;r<=Math.min(2,i);r++)t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));a-2>3&&t.push(e.createElement("span",{key:"ellipsis1",className:"pagination-ellipsis"},"..."));for(let r=Math.max(3,a-2);r<=Math.min(i-2,a+2);r++)r>2&&r<i-1&&t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));a+2<i-2&&t.push(e.createElement("span",{key:"ellipsis2",className:"pagination-ellipsis"},"..."));for(let r=Math.max(i-1,3);r<=i;r++)r>2&&t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));return t})(),e.createElement("button",{onClick:()=>n(a+1),className:"pagination-item "+(a===i?"disabled":""),disabled:a===i,"aria-disabled":a===i},"Next"))}var q,J,Y;function Q(){return Q=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Q.apply(null,arguments)}var X,Z=function(e){return t.createElement("svg",Q({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),q||(q=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),J||(J=t.createElement("path",{d:"M21 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5v2H5v14h14v-5z"})),Y||(Y=t.createElement("path",{d:"M21 7h-4V3h-2v4h-4v2h4v4h2V9h4"})))};function tt(){return tt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},tt.apply(null,arguments)}var et=function(e){return t.createElement("svg",tt({xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e),X||(X=t.createElement("path",{d:"M22 3H2l8 9.46V19l4 2v-8.54z"})))};function nt({field:t,value:n,onChange:r}){if("static-select"===t.filter?.type){const a=t.filter;return e.createElement(f,{id:t.name,menuPortalTarget:document.body,styles:{control:(t,e)=>({...t,backgroundColor:"#1f2937",borderColor:e.isFocused?"#6366f1":"#374151",boxShadow:e.isFocused?"0 0 0 1px #6366f1":"none","&:hover":{borderColor:"#6366f1"},borderRadius:"6px",padding:"2px",color:"white"}),option:(t,e)=>({...t,backgroundColor:e.isSelected?"#6366f1":e.isFocused?"#374151":"#1f2937",color:"white","&:active":{backgroundColor:"#6366f1"},"&:hover":{backgroundColor:"#374151"},cursor:"pointer"}),input:t=>({...t,color:"white"}),placeholder:t=>({...t,color:"#9ca3af"}),singleValue:t=>({...t,color:"white"}),menuPortal:t=>({...t,zIndex:9999}),menu:t=>({...t,backgroundColor:"#1f2937",border:"1px solid #374151",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"}),menuList:t=>({...t,padding:"4px"}),dropdownIndicator:t=>({...t,color:"#9ca3af","&:hover":{color:"#6366f1"}}),clearIndicator:t=>({...t,color:"#9ca3af","&:hover":{color:"#6366f1"}})},value:n?{value:n,label:a.options.find((t=>t.value===n))?.label||n}:null,onChange:t=>r(t?.value||""),options:a.options.map((t=>({value:t.value,label:t.label}))),placeholder:`Filter by ${t.title||t.name}`,isClearable:!0})}return e.createElement("input",{type:"number"===t.type?"number":"text",id:t.name,value:n||"",onChange:t=>r(t.target.value),placeholder:`Filter by ${t.title||t.name}`})}function rt({isOpen:t,onClose:o,onApplyFilters:i,listData:s,activeFilters:c}){const[l,u]=e.useState(c??{}),p=n(null),f=r((()=>s.cells.filter((t=>!!t.filter))),[s.cells]);if(a((()=>{const e=t=>{p.current&&!p.current.contains(t.target)&&o()};return t&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[t,o]),!t)return null;return e.createElement("div",{className:"filter-popup-overlay"},e.createElement("div",{ref:p,className:"filter-popup"},e.createElement("div",{className:"filter-popup-header"},e.createElement("h3",null,"Filter"),e.createElement("button",{onClick:o,className:"close-button"},"×")),e.createElement("div",{className:"filter-popup-content"},f.map((t=>e.createElement("div",{key:t.name,className:"filter-field"},e.createElement("label",{htmlFor:t.name},t.title||t.name),e.createElement(nt,{field:t,value:l[t.name||""],onChange:e=>((t,e)=>{u((n=>({...n,[t]:e})))})(t.name||"",e)}))))),e.createElement("div",{className:"filter-popup-footer"},e.createElement("button",{onClick:o,className:"cancel-button"},"Cancel"),e.createElement("button",{onClick:()=>{i(l),o()},className:"apply-button"},"Apply Filters"))))}function at({listData:t,filtered:n,onFilterClick:a,customHeader:o}){const i=r((()=>t.cells.filter((t=>!!t.filter))),[t.cells]),s=t.list?.headers;return e.createElement("div",{className:"list-header"},e.createElement("div",{className:"header-title"},s?.title||"List"),o&&e.createElement("div",{className:"header-custom"},o),e.createElement("div",{className:"header-actions"},!!i.length&&e.createElement("button",{onClick:a,className:"filter-button"},e.createElement(et,{className:"icon icon-filter "+(n?"active":"")}),"Filter"),s?.create&&e.createElement(c,{to:s.create.path,className:"create-button"},e.createElement(Z,{className:"icon icon-create"}),s.create.label)))}function ot({model:t,getData:n,onRemoveItem:s,customHeader:c}){const[p,f]=o(!0),[d,h]=o({total:0,page:0,limit:0}),[m,y]=o(null),[v,g]=o(null),[E,b]=o(!1),[w,O]=o(),S=r((()=>{return{list:H(e=t),cells:W(e)};var e}),[t]),_=l(),M=u(),T=i((async(t,e)=>{f(!0);try{const r=await n({page:t,filters:e??w??{}});y(r.data),h({total:r.total,page:r.page,limit:r.limit})}catch(t){g(t),console.error(t)}finally{f(!1)}}),[n,w]);a((()=>{const t=new URLSearchParams(location.search),e={};t.forEach(((t,n)=>{e[n]=t})),O(e)}),[location.search]),a((()=>{w&&T(parseInt(_.page)||1,w)}),[T,_.page,w]);return p?e.createElement(D,null):v?e.createElement(V,{error:v}):e.createElement("div",{className:"list"},e.createElement(at,{listData:S,filtered:!(!w||!Object.keys(w).length),onFilterClick:()=>b(!0),customHeader:c}),e.createElement(j,{listData:S,data:m,onRemoveItem:async t=>{s&&confirm("Are you sure you want to delete this item? This action cannot be undone.")&&(await s(t),await T(d.page))}}),e.createElement("div",{className:"list-footer"},e.createElement(G,{pagination:d,onPageChange:T})),e.createElement(rt,{isOpen:E,activeFilters:w,onClose:()=>b(!1),onApplyFilters:t=>{O(t);const e=new URLSearchParams;Object.entries(t).forEach((([t,n])=>{null!=n&&""!==n&&e.append(t,String(n))}));const n=e.toString(),r=`${location.pathname}${n?`?${n}`:""}`;M(r),T(1,t)},listData:S}))}function it({htmlFor:t,label:n,fieldName:r}){return e.createElement("label",{htmlFor:t},n??r.charAt(0).toUpperCase()+r.slice(1))}function st({input:t}){const n=d(),[r,i]=o([]),s=t.name;a((()=>{n.setValue(t.name+"_files",r.length>0)}),[r,n,t.name]);return e.createElement("div",{className:"uploader-container"},e.createElement("button",{type:"button",className:"uploader-button",onClick:()=>document.getElementById(s)?.click()},"Upload Files"),e.createElement("input",{id:s,hidden:!0,name:t.name,onChange:t=>{const e=t.target.files;if(e){const t=Array.from(e);i((e=>[...e,...t]))}},type:"file",multiple:!0}),r.length>0&&e.createElement("div",{className:"uploader-files"},r.map(((t,n)=>e.createElement("div",{key:`${t.name}-${n}`,className:"uploader-file"},e.createElement("p",null,t.name),e.createElement("p",null,(t.size/1024/1024).toFixed(2)," MB"),e.createElement("p",null,t.type||"Unknown type"),e.createElement("button",{onClick:()=>(t=>{i((e=>e.filter(((e,n)=>n!==t))))})(n),className:"remove-file-button",type:"button"},"Remove"))))))}function ct({id:t,...n}){return e.createElement("input",{type:"checkbox",id:t,className:"checkbox",...n})}function lt({input:t,register:n}){const r=d(),a=r.getValues(t.name);return e.createElement("div",null,a?.map(((a,o)=>e.createElement("div",{key:o},t.nestedFields?.map((a=>e.createElement(ut,{key:a.name?.toString()??"",baseName:t.name+"["+o+"]",input:a,register:n,error:t.name?{message:r.formState.errors[t.name]?.message}:void 0})))))))}function ut({input:t,register:n,error:r,baseName:i,onSelectPreloader:s}){const c=(i?i.toString()+".":"")+t.name||"",[l,u]=o(t.options||[]);a((()=>{t.optionsPreload&&s&&s(t).then((t=>{u(t)}))}),[t]);return e.createElement("div",{className:"form-field"},e.createElement(it,{htmlFor:c,label:t.label,fieldName:c}),(()=>{switch(t.type){case"textarea":return e.createElement("textarea",{...n(c),placeholder:t.placeholder,id:c});case"select":return e.createElement("select",{...n(c),id:c},e.createElement("option",{value:""},"Select ",c),l?.map((t=>e.createElement("option",{key:t.value,value:t.value},t.label))));case"input":return e.createElement("input",{type:t.inputType,...n(c),placeholder:t.placeholder,id:c});case"file-upload":return e.createElement(st,{input:t});case"checkbox":return e.createElement(ct,{...n(c),id:c});case"hidden":return e.createElement("input",{type:"hidden",...n(c),id:c});case"nested":return e.createElement(lt,{input:t,register:n})}})(),r&&e.createElement("span",{className:"error-message"},r.message))}function pt({formOptions:t,onSubmit:r,getDetailsData:i,redirectBackOnSuccess:s,onSelectPreloader:c,type:p}){const f=l(),[d,y]=o(null),v=h({resolver:t.resolver}),g=n(null),E=u(),b=t.inputs;return a((()=>{i&&i(f).then((t=>{v.reset({...t})}))}),[f,v.reset]),e.createElement("div",{className:"form-wrapper"},e.createElement(m,{...v},e.createElement("form",{ref:g,onSubmit:v.handleSubmit((async t=>{try{console.log("dataForm",t);const e="json"===p?t:(()=>{const e=new FormData(g.current);for(const n in t)e.get(n)||e.append(n,t[n]);return console.log("formData",e),e})();console.log("data",e),await r(e),y(null),s&&E(-1)}catch(t){const e=t?.response?.data?.message||(t instanceof Error?t.message:"An error occurred");y(e),console.error(t)}}),((t,e)=>{console.log("error creating creation",t,e)}))},e.createElement("div",null,d&&e.createElement("div",{className:"error-message",style:{color:"red",marginBottom:"1rem"}},d),b?.map((t=>e.createElement(ut,{key:t.name||"",input:t,register:v.register,onSelectPreloader:c,error:t.name?{message:v.formState.errors[t.name]?.message}:void 0}))),e.createElement("button",{type:"submit",className:"submit-button"},"Submit")))))}function ft({image:t,text:n,targetNumber:r,duration:i=2e3}){const[s,c]=o(0);return a((()=>{let t,e;const n=a=>{t||(t=a);const o=a-t,s=Math.min(o/i,1);c(Math.floor(s*r)),s<1&&(e=requestAnimationFrame(n))};return e=requestAnimationFrame(n),()=>{e&&cancelAnimationFrame(e)}}),[r,i]),e.createElement("div",{className:"counter-container"},e.createElement("div",{className:"counter-image"},t),e.createElement("div",{className:"counter-text"},n),e.createElement("div",{className:"counter-value"},s))}class dt extends s{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?e.createElement("div",{className:"error-boundary"},e.createElement("div",{className:"error-boundary__content"},e.createElement("div",{className:"error-boundary__icon"},e.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},e.createElement("circle",{cx:"12",cy:"12",r:"10"}),e.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"16"}))),e.createElement("h1",null,"Oops! Something went wrong"),e.createElement("p",{className:"error-boundary__message"},this.state.error?.message||"An unexpected error occurred"),e.createElement("button",{className:"error-boundary__button",onClick:()=>window.location.reload()},"Refresh Page"),"development"===process.env.NODE_ENV&&e.createElement("details",{className:"error-boundary__details"},e.createElement("summary",null,"Error Details"),e.createElement("pre",null,this.state.error?.toString()),e.createElement("pre",null,this.state.errorInfo?.componentStack)))):this.props.children}}const ht=Symbol("input");function mt(t){return(e,n)=>{const r=Reflect.getMetadata(ht,e)||[];if(Reflect.defineMetadata(ht,[...r,n.toString()],e),t){const r=`${ht.toString()}:${n.toString()}:options`;Reflect.defineMetadata(r,t,e)}}}function yt(t){const e=t.prototype;return(Reflect.getMetadata(ht,e)||[]).map((t=>{const n=Reflect.getMetadata(`${ht.toString()}:${t}:options`,e)||{},r=n?.inputType??(a=t,["password"].some((t=>a.toLowerCase().includes(t)))?"password":"text");var a;return{...n,editable:n.editable??!0,sensitive:n.sensitive,name:n?.name??t,label:n?.label??t,placeholder:n?.placeholder??t,inputType:r,type:n?.type??"input",selectOptions:n?.selectOptions??[],cancelPasswordValidationOnEdit:n?.cancelPasswordValidationOnEdit??"password"===r}}))}function vt(t){return Reflect.getMetadata("FormMetadata",t)}const gt=(t,e,n)=>{if(t&&"reportValidity"in t){const r=y(n,e);t.setCustomValidity(r&&r.message||""),t.reportValidity()}},Et=(t,e)=>{for(const n in e.fields){const r=e.fields[n];r&&r.ref&&"reportValidity"in r.ref?gt(r.ref,n,t):r&&r.refs&&r.refs.forEach((e=>gt(e,n,t)))}},bt=(t,e)=>{e.shouldUseNativeValidation&&Et(t,e);const n={};for(const r in t){const a=y(e.fields,r),o=Object.assign(t[r]||{},{ref:a&&a.ref});if(wt(e.names||Object.keys(t),r)){const t=Object.assign({},y(n,r));v(t,"root",o),v(n,r,t)}else v(n,r,o)}return n},wt=(t,e)=>{const n=Ot(e);return t.some((t=>Ot(t).match(`^${n}\\.\\d+`)))};function Ot(t){return t.replace(/\]|\[/g,"")}var St;!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"}(St||(St={}));var _t=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,n){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?n===St.CLASS_TO_CLASS||n===St.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||n===St.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),n=e&&e.get(void 0),r=this._exposeMetadatas.get(t),a=r&&r.get(void 0);return n&&a||!n&&!a?"none":n?"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===St.CLASS_TO_CLASS||e===St.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===St.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===St.CLASS_TO_CLASS||e===St.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===St.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 n,r=t.get(e);r&&(n=Array.from(r.values()).filter((function(t){return void 0!==t.propertyName})));for(var a=[],o=0,i=this.getAncestors(e);o<i.length;o++){var s=i[o],c=t.get(s);if(c){var l=Array.from(c.values()).filter((function(t){return void 0!==t.propertyName}));a.push.apply(a,l)}}return a.concat(n||[])},t.prototype.findMetadata=function(t,e,n){var r=t.get(e);if(r){var a=r.get(n);if(a)return a}for(var o=0,i=this.getAncestors(e);o<i.length;o++){var s=i[o],c=t.get(s);if(c){var l=c.get(n);if(l)return l}}},t.prototype.findMetadatas=function(t,e,n){var r,a=t.get(e);a&&(r=a.get(n));for(var o=[],i=0,s=this.getAncestors(e);i<s.length;i++){var c=s[i],l=t.get(c);l&&l.has(n)&&o.push.apply(o,l.get(n))}return o.slice().reverse().concat((r||[]).slice().reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],n=Object.getPrototypeOf(t.prototype.constructor);void 0!==n.prototype;n=Object.getPrototypeOf(n.prototype.constructor))e.push(n);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}(),Mt=new _t;var Tt=function(t,e,n){if(n||2===arguments.length)for(var r,a=0,o=e.length;a<o;a++)!r&&a in e||(r||(r=Array.prototype.slice.call(e,0,a)),r[a]=e[a]);return t.concat(r||Array.prototype.slice.call(e))};var Nt=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,n,r,a,o){var i,s=this;if(void 0===o&&(o=0),Array.isArray(e)||e instanceof Set){var c=r&&this.transformationType===St.PLAIN_TO_CLASS?function(t){var e=new t;return e instanceof Set||"push"in e?e:[]}(r):[];return e.forEach((function(e,r){var a=t?t[r]:void 0;if(s.options.enableCircularCheck&&s.isCircular(e))s.transformationType===St.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var i=void 0;if("function"!=typeof n&&n&&n.options&&n.options.discriminator&&n.options.discriminator.property&&n.options.discriminator.subTypes){if(s.transformationType===St.PLAIN_TO_CLASS){i=n.options.discriminator.subTypes.find((function(t){return t.name===e[n.options.discriminator.property]}));var l={newObject:c,object:e,property:void 0},u=n.typeFunction(l);i=void 0===i?u:i.value,n.options.keepDiscriminatorProperty||delete e[n.options.discriminator.property]}s.transformationType===St.CLASS_TO_CLASS&&(i=e.constructor),s.transformationType===St.CLASS_TO_PLAIN&&(e[n.options.discriminator.property]=n.options.discriminator.subTypes.find((function(t){return t.value===e.constructor})).name)}else i=n;var p=s.transform(a,e,i,void 0,e instanceof Map,o+1);c instanceof Set?c.add(p):c.push(p)}})),c}if(n!==String||a){if(n!==Number||a){if(n!==Boolean||a){if((n===Date||e instanceof Date)&&!a)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&&(n===Buffer||e instanceof Buffer)&&!a)return null==e?e:Buffer.from(e);if(null===(i=e)||"object"!=typeof i||"function"!=typeof i.then||a){if(a||null===e||"object"!=typeof e||"function"!=typeof e.then){if("object"==typeof e&&null!==e){n||e.constructor===Object||(Array.isArray(e)||e.constructor!==Array)&&(n=e.constructor),!n&&t&&(n=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var l=this.getKeys(n,e,a),u=t||{};t||this.transformationType!==St.PLAIN_TO_CLASS&&this.transformationType!==St.CLASS_TO_CLASS||(u=a?new Map:n?new n:{});for(var p=function(r){if("__proto__"===r||"constructor"===r)return"continue";var i=r,s=r,c=r;if(!f.options.ignoreDecorators&&n)if(f.transformationType===St.PLAIN_TO_CLASS)(l=Mt.findExposeMetadataByCustomName(n,r))&&(c=l.propertyName,s=l.propertyName);else if(f.transformationType===St.CLASS_TO_PLAIN||f.transformationType===St.CLASS_TO_CLASS){var l;(l=Mt.findExposeMetadata(n,r))&&l.options&&l.options.name&&(s=l.options.name)}var p=void 0;p=f.transformationType===St.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(n&&a)d=n;else if(n){var m=Mt.findTypeMetadata(n,c);if(m){var y={newObject:u,object:e,property:c},v=m.typeFunction?m.typeFunction(y):m.reflectedType;m.options&&m.options.discriminator&&m.options.discriminator.property&&m.options.discriminator.subTypes?e[i]instanceof Array?d=m:(f.transformationType===St.PLAIN_TO_CLASS&&(d=void 0===(d=m.options.discriminator.subTypes.find((function(t){if(p&&p instanceof Object&&m.options.discriminator.property in p)return t.name===p[m.options.discriminator.property]})))?v:d.value,m.options.keepDiscriminatorProperty||p&&p instanceof Object&&m.options.discriminator.property in p&&delete p[m.options.discriminator.property]),f.transformationType===St.CLASS_TO_CLASS&&(d=p.constructor),f.transformationType===St.CLASS_TO_PLAIN&&p&&(p[m.options.discriminator.property]=m.options.discriminator.subTypes.find((function(t){return t.value===p.constructor})).name)):d=v,h=h||m.reflectedType===Map}else if(f.options.targetMaps)f.options.targetMaps.filter((function(t){return t.target===n&&!!t.properties[c]})).forEach((function(t){return d=t.properties[c]}));else if(f.options.enableImplicitConversion&&f.transformationType===St.PLAIN_TO_CLASS){var g=Reflect.getMetadata("design:type",n.prototype,c);g&&(d=g)}}var E=Array.isArray(e[i])?f.getReflectedType(n,c):void 0,b=t?t[i]:void 0;if(u.constructor.prototype){var w=Object.getOwnPropertyDescriptor(u.constructor.prototype,s);if((f.transformationType===St.PLAIN_TO_CLASS||f.transformationType===St.CLASS_TO_CLASS)&&(w&&!w.set||u[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(p)){if(f.transformationType===St.CLASS_TO_CLASS){S=p;(void 0!==(S=f.applyCustomTransformations(S,n,r,e,f.transformationType))||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,S):u[s]=S)}}else{var O=f.transformationType===St.PLAIN_TO_CLASS?s:r,S=void 0;f.transformationType===St.CLASS_TO_PLAIN?(S=e[O],S=f.applyCustomTransformations(S,n,O,e,f.transformationType),S=e[O]===S?p:S,S=f.transform(b,S,d,E,h,o+1)):void 0===p&&f.options.exposeDefaultValues?S=u[s]:(S=f.transform(b,p,d,E,h,o+1),S=f.applyCustomTransformations(S,n,O,e,f.transformationType)),(void 0!==S||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,S):u[s]=S)}},f=this,d=0,h=l;d<h.length;d++){p(h[d])}return this.options.enableCircularCheck&&this.recursionStack.delete(e),u}return e}return e}return new Promise((function(t,r){e.then((function(e){return t(s.transform(void 0,e,n,void 0,void 0,o+1))}),r)}))}return null==e?e:Boolean(e)}return null==e?e:Number(e)}return null==e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,n,r,a){var o=this,i=Mt.findTransformMetadatas(e,n,this.transformationType);return void 0!==this.options.version&&(i=i.filter((function(t){return!t.options||o.checkVersion(t.options.since,t.options.until)}))),(i=this.options.groups&&this.options.groups.length?i.filter((function(t){return!t.options||o.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:n,obj:r,type:a,options:o.options})})),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var n=Mt.findTypeMetadata(t,e);return n?n.reflectedType:void 0}},t.prototype.getKeys=function(t,e,n){var r=this,a=Mt.getStrategy(t);"none"===a&&(a=this.options.strategy||"exposeAll");var o=[];if(("exposeAll"===a||n)&&(o=e instanceof Map?Array.from(e.keys()):Object.keys(e)),n)return o;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&t){var i=Mt.getExposedProperties(t,this.transformationType),s=Mt.getExcludedProperties(t,this.transformationType);o=Tt(Tt([],i,!0),s,!0)}if(!this.options.ignoreDecorators&&t){i=Mt.getExposedProperties(t,this.transformationType);this.transformationType===St.PLAIN_TO_CLASS&&(i=i.map((function(e){var n=Mt.findExposeMetadata(t,e);return n&&n.options&&n.options.name?n.options.name:e}))),o=this.options.excludeExtraneousValues?i:o.concat(i);var c=Mt.getExcludedProperties(t,this.transformationType);c.length>0&&(o=o.filter((function(t){return!c.includes(t)}))),void 0!==this.options.version&&(o=o.filter((function(e){var n=Mt.findExposeMetadata(t,e);return!n||!n.options||r.checkVersion(n.options.since,n.options.until)}))),o=this.options.groups&&this.options.groups.length?o.filter((function(e){var n=Mt.findExposeMetadata(t,e);return!n||!n.options||r.checkGroups(n.options.groups)})):o.filter((function(e){var n=Mt.findExposeMetadata(t,e);return!(n&&n.options&&n.options.groups&&n.options.groups.length)}))}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(o=o.filter((function(t){return r.options.excludePrefixes.every((function(e){return t.substr(0,e.length)!==e}))}))),o=o.filter((function(t,e,n){return n.indexOf(t)===e}))},t.prototype.checkVersion=function(t,e){var n=!0;return n&&t&&(n=this.options.version>=t),n&&e&&(n=this.options.version<e),n},t.prototype.checkGroups=function(t){return!t||this.options.groups.some((function(e){return t.includes(e)}))},t}(),xt={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},At=function(){return At=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var a in e=arguments[n])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},At.apply(this,arguments)},kt=new(function(){function t(){}return t.prototype.instanceToPlain=function(t,e){return new Nt(St.CLASS_TO_PLAIN,At(At({},xt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,n){return new Nt(St.CLASS_TO_PLAIN,At(At({},xt),n)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToInstance=function(t,e,n){return new Nt(St.PLAIN_TO_CLASS,At(At({},xt),n)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,n){return new Nt(St.PLAIN_TO_CLASS,At(At({},xt),n)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.instanceToInstance=function(t,e){return new Nt(St.CLASS_TO_CLASS,At(At({},xt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,n){return new Nt(St.CLASS_TO_CLASS,At(At({},xt),n)).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,n){var r=JSON.parse(e);return this.plainToInstance(t,r,n)},t.prototype.deserializeArray=function(t,e,n){var r=JSON.parse(e);return this.plainToInstance(t,r,n)},t}());var Ct=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)},Pt=function(){function t(){}return t.prototype.transform=function(t){var e=[];return Object.keys(t.properties).forEach((function(n){t.properties[n].forEach((function(r){var a={message:r.message,groups:r.groups,always:r.always,each:r.each},o={type:r.type,name:r.name,target:t.name,propertyName:n,constraints:r.constraints,validationTypeOptions:r.options,validationOptions:a};e.push(new Ct(o))}))})),e},t}();function Lt(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function It(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var jt=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Vt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,a,o=n.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(t){a={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},Dt=function(t,e,n){if(n||2===arguments.length)for(var r,a=0,o=e.length;a<o;a++)!r&&a in e||(r||(r=Array.prototype.slice.call(e,0,a)),r[a]=e[a]);return t.concat(r||Array.prototype.slice.call(e))},Ft=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 Pt).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,n,r,a){var o,i,s=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&n},c=function(t){return!(!r||a&&a.length||!t.groups||!t.groups.length)},l=(this.validationMetadatas.get(t)||[]).filter((function(n){return(n.target===t||n.target===e)&&(!!s(n)||!c(n)&&(!(a&&a.length>0)||n.groups&&!!n.groups.find((function(t){return-1!==a.indexOf(t)}))))})),u=[];try{for(var p=jt(this.validationMetadatas.entries()),f=p.next();!f.done;f=p.next()){var d=Vt(f.value,2),h=d[0],m=d[1];t.prototype instanceof h&&u.push.apply(u,Dt([],Vt(m),!1))}}catch(t){o={error:t}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(o)throw o.error}}var y=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)&&(!(a&&a.length>0)||e.groups&&!!e.groups.find((function(t){return-1!==a.indexOf(t)}))))))})).filter((function(t){return!l.find((function(e){return e.propertyName===t.propertyName&&e.type===t.type}))}));return l.concat(y)},t.prototype.getTargetValidatorConstraints=function(t){return this.constraintMetadatas.get(t)||[]},t}();var Rt=function(){function t(){}return t.prototype.toString=function(t,e,n,r){var a=this;void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===n&&(n=""),void 0===r&&(r=!1);var o=t?"":"",i=t?"":"",s=function(t){return" - property ".concat(o).concat(n).concat(t).concat(i," has failed the following constraints: ").concat(o).concat((r?Object.values:Object.keys)(null!==(e=a.constraints)&&void 0!==e?e:{}).join(", ")).concat(i," \n");var e};if(e){var c=Number.isInteger(+this.property)?"[".concat(this.property,"]"):"".concat(n?".":"").concat(this.property);return this.constraints?s(c):this.children?this.children.map((function(e){return e.toString(t,!0,"".concat(n).concat(c),r)})).join(""):""}return"An instance of ".concat(o).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,a.property,r)})).join(""):"")},t}(),$t=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 zt=function(){function t(){}return t.replaceMessageSpecialTokens=function(t,e){var n;return t instanceof Function?n=t(e):"string"==typeof t&&(n=t),n&&Array.isArray(e.constraints)&&e.constraints.forEach((function(t,e){n=n.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))})),n&&void 0!==e.value&&null!==e.value&&["string","boolean","number"].includes(typeof e.value)&&(n=n.replace(/\$value/g,e.value)),n&&(n=n.replace(/\$property/g,e.property)),n&&(n=n.replace(/\$target/g,e.targetName)),n},t}(),Bt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,a,o=n.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(t){a={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},Ht=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=function(){var t=Lt();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new Ft),t.classValidatorMetadataStorage}()}return t.prototype.execute=function(t,e,n){var r,a,o=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(r=this.validatorOptions)||void 0===r?void 0:r.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===(a=this.validatorOptions)||void 0===a?void 0:a.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 Rt;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 n.push(f)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(t,p,n),Object.keys(p).forEach((function(e){var r=t[e],a=p[e].filter((function(t){return t.type===$t.IS_DEFINED})),i=p[e].filter((function(t){return t.type!==$t.IS_DEFINED&&t.type!==$t.WHITELIST}));r instanceof Promise&&i.find((function(t){return t.type===$t.PROMISE_VALIDATION}))?o.awaitingPromises.push(r.then((function(r){o.performValidations(t,r,e,a,i,n)}))):o.performValidations(t,r,e,a,i,n)}))},t.prototype.whitelist=function(t,e,n){var r=this,a=[];Object.keys(t).forEach((function(t){e[t]&&0!==e[t].length||a.push(t)})),a.length>0&&(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?a.forEach((function(e){var a,o=r.generateValidationError(t,t[e],e);o.constraints=((a={})[$t.WHITELIST]="property ".concat(e," should not exist"),a),o.children=void 0,n.push(o)})):a.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,n,r,a,o){var i=a.filter((function(t){return t.type===$t.CUSTOM_VALIDATION})),s=a.filter((function(t){return t.type===$t.NESTED_VALIDATION})),c=a.filter((function(t){return t.type===$t.CONDITIONAL_VALIDATION})),l=this.generateValidationError(t,e,n);o.push(l),this.conditionalValidations(t,e,c)&&(this.customValidations(t,e,r,l),this.mapContexts(t,e,r,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,a,l),this.mapContexts(t,e,i,l)))},t.prototype.generateValidationError=function(t,e,n){var r=new Rt;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(r.target=t),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(r.value=e),r.property=n,r.children=[],r.constraints={},r},t.prototype.conditionalValidations=function(t,e,n){return n.map((function(n){return n.constraints[0](t,e)})).reduce((function(t,e){return t&&e}),!0)},t.prototype.customValidations=function(t,e,n,r){var a=this;n.forEach((function(n){a.metadataStorage.getTargetValidatorConstraints(n.constraintCls).forEach((function(o){if(!(o.async&&a.ignoreAsyncValidations||a.validatorOptions&&a.validatorOptions.stopAtFirstError&&Object.keys(r.constraints||{}).length>0)){var i={targetName:t.constructor?t.constructor.name:void 0,property:n.propertyName,object:t,value:e,constraints:n.constraints};if(n.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 o.instance.validate(t,i)}));if(c.some((function(t){return It(t)}))){var l=c.map((function(t){return It(t)?t:Promise.resolve(t)})),u=Promise.all(l).then((function(i){if(!i.every((function(t){return t}))){var s=Bt(a.createValidationError(t,e,n,o),2),c=s[0],l=s[1];r.constraints[c]=l,n.context&&(r.contexts||(r.contexts={}),r.contexts[c]=Object.assign(r.contexts[c]||{},n.context))}}));a.awaitingPromises.push(u)}else{if(!c.every((function(t){return t}))){var p=Bt(a.createValidationError(t,e,n,o),2);m=p[0],y=p[1];r.constraints[m]=y}}}else{var f=o.instance.validate(e,i);if(It(f)){var d=f.then((function(i){if(!i){var s=Bt(a.createValidationError(t,e,n,o),2),c=s[0],l=s[1];r.constraints[c]=l,n.context&&(r.contexts||(r.contexts={}),r.contexts[c]=Object.assign(r.contexts[c]||{},n.context))}}));a.awaitingPromises.push(d)}else if(!f){var h=Bt(a.createValidationError(t,e,n,o),2),m=h[0],y=h[1];r.constraints[m]=y}}}}))}))},t.prototype.nestedValidations=function(t,e,n){var r=this;void 0!==t&&e.forEach((function(a){if((a.type===$t.NESTED_VALIDATION||a.type===$t.PROMISE_VALIDATION)&&!(r.validatorOptions&&r.validatorOptions.stopAtFirstError&&Object.keys(n.constraints||{}).length>0))if(Array.isArray(t)||t instanceof Set||t instanceof Map)(t instanceof Set?Array.from(t):t).forEach((function(a,o){r.performValidations(t,a,o.toString(),[],e,n.children)}));else if(t instanceof Object){var o="string"==typeof a.target?a.target:a.target.name;r.execute(t,o,n.children)}else{var i=Bt(r.createValidationError(a.target,t,a),2),s=i[0],c=i[1];n.constraints[s]=c}}))},t.prototype.mapContexts=function(t,e,n,r){var a=this;return n.forEach((function(t){if(t.context){var e=void 0;if(t.type===$t.CUSTOM_VALIDATION)e=a.metadataStorage.getTargetValidatorConstraints(t.constraintCls)[0];var n=a.getConstraintType(t,e);r.constraints[n]&&(r.contexts||(r.contexts={}),r.contexts[n]=Object.assign(r.contexts[n]||{},t.context))}}))},t.prototype.createValidationError=function(t,e,n,r){var a=t.constructor?t.constructor.name:void 0,o=this.getConstraintType(n,r),i={targetName:a,property:n.propertyName,object:t,value:e,constraints:n.constraints},s=n.message||"";return n.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||r&&r.instance.defaultMessage instanceof Function&&(s=r.instance.defaultMessage(i)),[o,zt.replaceMessageSpecialTokens(s,i)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),Ut=function(t,e,n,r){return new(n||(n=Promise))((function(a,o){function i(t){try{c(r.next(t))}catch(t){o(t)}}function s(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,s)}c((r=r.apply(t,e||[])).next())}))},Kt=function(t,e){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=a=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,n){return this.coreValidate(t,e,n)},t.prototype.validateOrReject=function(t,e,n){return Ut(this,void 0,void 0,(function(){var r;return Kt(this,(function(a){switch(a.label){case 0:return[4,this.coreValidate(t,e,n)];case 1:return(r=a.sent()).length?[2,Promise.reject(r)]:[2]}}))}))},t.prototype.validateSync=function(t,e,n){var r="string"==typeof t?e:t,a="string"==typeof t?t:void 0,o=new Ht(this,"string"==typeof t?n:e);o.ignoreAsyncValidations=!0;var i=[];return o.execute(r,a,i),o.stripEmptyErrors(i)},t.prototype.coreValidate=function(t,e,n){var r="string"==typeof t?e:t,a="string"==typeof t?t:void 0,o=new Ht(this,"string"==typeof t?n:e),i=[];return o.execute(r,a,i),Promise.all(o.awaitingPromises).then((function(){return o.stripEmptyErrors(i)}))},t}(),Gt=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 qt(t){return Gt.get(t)}function Jt(t,e,n){return"string"==typeof t?qt(Wt).validate(t,e,n):qt(Wt).validate(t,e)}function Yt(t,e,n){return"string"==typeof t?qt(Wt).validateSync(t,e,n):qt(Wt).validateSync(t,e)}function Qt(t,e,n,r){return void 0===n&&(n={}),void 0===r&&(r=""),t.reduce((function(t,n){var a=r?r+"."+n.property:n.property;if(n.constraints){var o=Object.keys(n.constraints)[0];t[a]={type:o,message:n.constraints[o]};var i=t[a];e&&i&&Object.assign(i,{types:n.constraints})}return n.children&&n.children.length&&Qt(n.children,e,t,a),t}),n)}function Xt(t,e,n){return void 0===e&&(e={}),void 0===n&&(n={}),function(r,a,o){try{var i=e.validator,s=(c=t,l=r,u=e.transformer,kt.plainToInstance(c,l,u));return Promise.resolve(("sync"===n.mode?Yt:Jt)(s,i)).then((function(t){return t.length?{values:{},errors:bt(Qt(t,!o.shouldUseNativeValidation&&"all"===o.criteriaMode),o)}:(o.shouldUseNativeValidation&&Et({},o),{values:n.raw?Object.assign({},r):s,errors:{}})}))}catch(t){return Promise.reject(t)}var c,l,u}}function Zt(t){return console.log(t),{resolver:Xt(t),form:vt(t),inputs:yt(t)}}function te({model:t,getDetailsData:n,onSubmit:a,redirect:o,onSelectPreloader:i,redirectBackOnSuccess:s=!0,type:c="json",...l}){const u=r((()=>Zt(t)),[t]);return e.createElement(pt,{getDetailsData:n,onSubmit:a,formOptions:u,redirectBackOnSuccess:s,onSelectPreloader:i,type:c})}const ee=b()(g((t=>({screens:null,user:null,screenPaths:{}})),{name:"app-store-1",storage:E((()=>localStorage)),partialize:t=>({user:t.user})}),w);function ne({onLogin:t}){const{register:n,handleSubmit:r,formState:{errors:a}}=h(),o=u();return e.createElement("div",{className:"login-container"},e.createElement("div",{className:"login-panel"},e.createElement("div",{className:"login-header"},e.createElement("h1",null,"Welcome Back"),e.createElement("p",null,"Please sign in to continue")),e.createElement("form",{onSubmit:r((async e=>{t.login(e.username,e.password).then((t=>{const{user:e,token:n}=t;localStorage.setItem("token",n),ee.setState({user:e}),o("/")}))})),className:"login-form"},e.createElement(ut,{input:{name:"username",label:"Username",placeholder:"Enter your username",type:"input"},register:n,error:a.username}),e.createElement(ut,{input:{name:"password",label:"Password",inputType:"password",placeholder:"Enter your password",type:"input"},register:n,error:a.password}),e.createElement("div",{className:"form-actions"},e.createElement("button",{type:"submit",className:"submit-button"},"Sign In")))))}function re({menu:t,getIcons:n,onLogout:r}){const{screens:a,screenPaths:i}=ee((t=>({screens:t.screens??{},screenPaths:t.screenPaths??{}}))),[s,l]=o(!0),f=p(),d=u(),h=t=>{if("/"===t)return f.pathname===t;const e=t.replace(/^\/+|\/+$/g,""),n=f.pathname.replace(/^\/+|\/+$/g,"");return n===e||n.startsWith(`${e}/`)};return e.createElement("div",{className:"sidebar "+(s?"open":"closed")},e.createElement("button",{className:"toggle-button",onClick:()=>l(!s),"aria-label":s?"Collapse sidebar":"Expand sidebar","aria-expanded":s},s?"<":">"),e.createElement("nav",{className:"nav-links"},t?.(a).map(((t,r)=>e.createElement(c,{key:r,to:t.path,className:"nav-link "+(h(t.path)?"active":""),"aria-current":h(t.path)?"page":void 0},e.createElement("span",{className:"nav-links-icon"},n?.(t.iconType)),s?e.createElement("span",null,t.name):null)))),r&&e.createElement("div",{className:"sidebar-footer"},e.createElement("button",{className:"logout-button",onClick:()=>{r&&(r(),d(i.login))},"aria-label":"Logout"},e.createElement("span",{className:"nav-links-icon"},e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M6 12H2V4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.createElement("path",{d:"M10 8L14 4M14 4L10 0M14 4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))),s?e.createElement("span",null,"Logout"):null)))}function ae({children:t,menu:n,getIcons:r,logout:a}){const{user:o,screenPaths:i}=ee((t=>({user:t.user,screenPaths:t.screenPaths})));ee();const s=u();return o||s(i.login),e.createElement("div",{className:"layout"},e.createElement(re,{onLogout:()=>{a&&a()},menu:n,getIcons:r}),e.createElement("main",{className:"content"},t))}function oe({children:t,init:n}){return a((()=>{!function({screenPaths:t}){ee.setState({screenPaths:t})}(n())}),[n]),e.createElement(dt,null,t)}function ie(t){return K({...t,type:"image"})}function se(t){return e=>{t&&Reflect.defineMetadata("Crud",t,e)}}export{K as Cell,ft as Counter,se as Crud,te as FormPage,ie as ImageCell,mt as Input,ae as Layout,B as List,ot as ListPage,ne as Login,oe as Panel,Zt as getFormFields,yt as getInputFields};
@@ -1 +1 @@
1
- export type AnyClass = abstract new (...args: any[]) => any;
1
+ export type AnyClass = any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proje-react-panel",
3
- "version": "1.0.17-test5",
3
+ "version": "1.0.17-test7",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "author": "SEFA DEMİR",
@@ -1,8 +1,8 @@
1
- import React from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import { InputOptions } from '../../decorators/form/Input';
3
3
  import { Label } from './Label';
4
4
  import { useFormContext, UseFormRegister } from 'react-hook-form';
5
- import { ImageUploader } from './ImageUploader';
5
+ import { Uploader } from './Uploader';
6
6
  import { Checkbox } from './Checkbox';
7
7
 
8
8
  interface FormFieldProps {
@@ -10,6 +10,7 @@ interface FormFieldProps {
10
10
  register: UseFormRegister<any>;
11
11
  error?: { message?: string };
12
12
  baseName?: string;
13
+ onSelectPreloader?: (inputOptions: InputOptions) => Promise<{ label: string; value: string }[]>;
13
14
  }
14
15
 
15
16
  interface NestedFormFieldsProps {
@@ -44,8 +45,16 @@ function NestedFormFields({ input, register }: NestedFormFieldsProps) {
44
45
  );
45
46
  }
46
47
 
47
- export function FormField({ input, register, error, baseName }: FormFieldProps) {
48
+ export function FormField({ input, register, error, baseName, onSelectPreloader }: FormFieldProps) {
48
49
  const fieldName = (baseName ? baseName.toString() + '.' : '') + input.name || '';
50
+ const [options, setOptions] = useState<{ label: string; value: string }[]>(input.options || []);
51
+ useEffect(() => {
52
+ if (input.optionsPreload && onSelectPreloader) {
53
+ onSelectPreloader(input).then(option => {
54
+ setOptions(option);
55
+ });
56
+ }
57
+ }, [input]);
49
58
  const renderField = () => {
50
59
  switch (input.type) {
51
60
  case 'textarea':
@@ -54,14 +63,14 @@ export function FormField({ input, register, error, baseName }: FormFieldProps)
54
63
  return (
55
64
  <select {...register(fieldName)} id={fieldName}>
56
65
  <option value="">Select {fieldName}</option>
57
- {input.options?.map(option => (
66
+ {options?.map(option => (
58
67
  <option key={option.value} value={option.value}>
59
68
  {option.label}
60
69
  </option>
61
70
  ))}
62
71
  </select>
63
72
  );
64
- case 'input': {
73
+ case 'input': {
65
74
  return (
66
75
  <input
67
76
  type={input.inputType}
@@ -72,7 +81,7 @@ export function FormField({ input, register, error, baseName }: FormFieldProps)
72
81
  );
73
82
  }
74
83
  case 'file-upload':
75
- return <ImageUploader />;
84
+ return <Uploader input={input} />;
76
85
  case 'checkbox':
77
86
  return <Checkbox {...register(fieldName)} id={fieldName} />;
78
87
  case 'hidden':
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
2
  import { FormProvider, useForm } from 'react-hook-form';
3
3
  import { InputOptions } from '../../decorators/form/Input';
4
4
  import { FormField } from './FormField';
@@ -7,30 +7,37 @@ import { AnyClass } from '../../types/AnyClass';
7
7
  import { OnSubmitFN, GetDetailsDataFN } from '../pages/FormPage';
8
8
  import { useParams, useNavigate } from 'react-router';
9
9
 
10
- interface InnerFormProps<T extends AnyClass> {
10
+ interface InnerFormProps<T> {
11
11
  formOptions: FormOptions;
12
12
  onSubmit: OnSubmitFN<T>;
13
13
  getDetailsData?: GetDetailsDataFN<T>;
14
14
  redirectBackOnSuccess?: boolean;
15
+ onSelectPreloader?: (inputOptions: InputOptions) => Promise<{ label: string; value: string }[]>;
16
+ type?: 'json' | 'formData';
15
17
  }
16
18
 
17
- export function InnerForm<T extends AnyClass>({
19
+ export function InnerForm<T>({
18
20
  formOptions,
19
21
  onSubmit,
20
22
  getDetailsData,
21
23
  redirectBackOnSuccess,
24
+ onSelectPreloader,
25
+ type,
22
26
  }: InnerFormProps<T>) {
23
27
  const params = useParams();
24
- const form = useForm<T>({
28
+ const [errorMessage, setErrorMessage] = useState<string | null>(null);
29
+ //TODO: any is not a good solution, we need to find a better way to do this
30
+ const form = useForm<any>({
25
31
  resolver: formOptions.resolver,
26
32
  });
33
+ const formRef = useRef<HTMLFormElement>(null);
27
34
  const navigate = useNavigate();
28
35
  const inputs = formOptions.inputs;
29
36
  useEffect(() => {
30
37
  if (getDetailsData) {
31
38
  getDetailsData(params as Record<string, string>).then(data => {
32
39
  form.reset({ ...data });
33
- });
40
+ });
34
41
  }
35
42
  }, [params, form.reset]);
36
43
 
@@ -38,24 +45,56 @@ export function InnerForm<T extends AnyClass>({
38
45
  <div className="form-wrapper">
39
46
  <FormProvider {...form}>
40
47
  <form
48
+ ref={formRef}
41
49
  onSubmit={form.handleSubmit(
42
50
  async dataForm => {
43
- await onSubmit(dataForm);
44
- if (redirectBackOnSuccess) {
45
- navigate(-1);
51
+ try {
52
+ console.log('dataForm', dataForm);
53
+ const data =
54
+ type === 'json'
55
+ ? dataForm
56
+ : (() => {
57
+ const formData = new FormData(formRef.current!);
58
+ for (const key in dataForm) {
59
+ if (!formData.get(key)) {
60
+ formData.append(key, dataForm[key]);
61
+ }
62
+ }
63
+ console.log('formData', formData);
64
+ return formData;
65
+ })();
66
+ console.log('data', data);
67
+ await onSubmit(data);
68
+ setErrorMessage(null);
69
+ if (redirectBackOnSuccess) {
70
+ navigate(-1);
71
+ }
72
+ } catch (error: any) {
73
+ const message =
74
+ error?.response?.data?.message ||
75
+ (error instanceof Error ? error.message : 'An error occurred');
76
+ setErrorMessage(message);
77
+ console.error(error);
46
78
  }
47
79
  },
48
80
  (errors, event) => {
81
+ //TOOD: put error if useer choose global error
49
82
  console.log('error creating creation', errors, event);
50
83
  }
51
84
  )}
52
85
  >
53
86
  <div>
87
+ {errorMessage && (
88
+ <div className="error-message" style={{ color: 'red', marginBottom: '1rem' }}>
89
+ {errorMessage}
90
+ </div>
91
+ )}
54
92
  {inputs?.map((input: InputOptions) => (
55
93
  <FormField
56
94
  key={input.name || ''}
57
95
  input={input}
58
96
  register={form.register}
97
+ onSelectPreloader={onSelectPreloader}
59
98
  error={
60
99
  input.name
61
100
  ? { message: (form.formState.errors[input.name as keyof T] as any)?.message }
@@ -0,0 +1,66 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { useForm, Controller, useFormContext } from 'react-hook-form';
3
+ import { InputOptions } from '../../decorators/form/Input';
4
+
5
+ interface UploaderProps {
6
+ input: InputOptions;
7
+ maxLength?: number;
8
+ }
9
+
10
+ export function Uploader({ input, maxLength = 1 }: UploaderProps) {
11
+ const form = useFormContext();
12
+ const [files, setFiles] = useState<File[]>([]);
13
+ const id = input.name!;
14
+
15
+ useEffect(() => {
16
+ // Update form value whenever files change
17
+ form.setValue(input.name + '_files', files.length > 0);
18
+ }, [files, form, input.name]);
19
+
20
+ const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
21
+ if (maxLength > 1) {
22
+ throw new Error('TODO: Multiple file upload is not implemented yet');
23
+ }
24
+
25
+ const fileList = e.target.files;
26
+ if (fileList) {
27
+ const filesArray = Array.from(fileList);
28
+ setFiles(prevFiles => [...prevFiles, ...filesArray]);
29
+ }
30
+ };
31
+
32
+ const removeFile = (index: number) => {
33
+ setFiles(prevFiles => prevFiles.filter((_, i) => i !== index));
34
+ };
35
+
36
+ return (
37
+ <div className="uploader-container">
38
+ <button
39
+ type="button"
40
+ className="uploader-button"
41
+ onClick={() => document.getElementById(id)?.click()}
42
+ >
43
+ Upload Files
44
+ </button>
45
+ <input id={id} hidden name={input.name} onChange={onChange} type="file" multiple />
46
+ {files.length > 0 && (
47
+ <div className="uploader-files">
48
+ {files.map((file, index) => (
49
+ <div key={`${file.name}-${index}`} className="uploader-file">
50
+ <p>{file.name}</p>
51
+ <p>{(file.size / 1024 / 1024).toFixed(2)} MB</p>
52
+ <p>{file.type || 'Unknown type'}</p>
53
+ <button
54
+ onClick={() => removeFile(index)}
55
+ className="remove-file-button"
56
+ type="button"
57
+ >
58
+ Remove
59
+ </button>
60
+ </div>
61
+ ))}
62
+ </div>
63
+ )}
64
+ </div>
65
+ );
66
+ }
@@ -2,7 +2,7 @@ export { InnerForm } from './InnerForm';
2
2
  export { FormField } from './FormField';
3
3
  export { LoadingScreen } from './LoadingScreen';
4
4
  export { Counter } from './Counter';
5
- export { ImageUploader } from './ImageUploader';
5
+ export { Uploader } from './Uploader';
6
6
  export { ErrorComponent } from './ErrorComponent';
7
7
  export { Label } from './Label';
8
- export { ErrorBoundary } from './ErrorBoundary';
8
+ export { ErrorBoundary } from './ErrorBoundary';