firstly 0.0.12 → 0.0.14
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/CHANGELOG.md +16 -0
- package/esm/ROUTES.d.ts +2 -0
- package/esm/ROUTES.js +1 -0
- package/esm/api/index.d.ts +9 -0
- package/esm/api/index.js +3 -1
- package/esm/auth/AuthController.d.ts +12 -23
- package/esm/auth/AuthController.js +12 -31
- package/esm/auth/server/AuthController.server.d.ts +11 -11
- package/esm/auth/server/AuthController.server.js +99 -34
- package/esm/auth/server/handleGuard.d.ts +16 -0
- package/esm/auth/server/handleGuard.js +67 -0
- package/esm/auth/server/helperFirstly.d.ts +1 -1
- package/esm/auth/server/helperFirstly.js +1 -0
- package/esm/auth/server/index.d.ts +3 -1
- package/esm/auth/server/index.js +3 -1
- package/esm/auth/server/module.d.ts +105 -89
- package/esm/auth/server/module.js +55 -42
- package/esm/auth/server/providers/github.d.ts +4 -2
- package/esm/auth/server/providers/github.js +2 -2
- package/esm/auth/static/assets/Page-B0XXxe0N.d.ts +6 -0
- package/esm/auth/static/assets/Page-B0XXxe0N.js +1 -0
- package/esm/auth/static/assets/Page-DdKMiUZn.d.ts +6 -0
- package/esm/auth/static/assets/Page-DdKMiUZn.js +20 -0
- package/esm/auth/static/assets/Page-UV_hqY7I.d.ts +6 -0
- package/esm/auth/static/assets/Page-UV_hqY7I.js +1 -0
- package/esm/auth/static/assets/Page-mK42zGEw.css +1 -0
- package/esm/auth/static/assets/index-C9jzxOBu.d.ts +151 -0
- package/esm/auth/static/assets/index-C9jzxOBu.js +42 -0
- package/esm/auth/static/assets/index-DKWpA6v7.css +4 -0
- package/esm/auth/static/index.html +11 -11
- package/esm/auth/types.d.ts +26 -3
- package/esm/bin/cmd.js +423 -152
- package/esm/cellsBuildor.js +1 -1
- package/esm/common.d.ts +5 -0
- package/esm/common.js +8 -0
- package/esm/cron/server/index.js +1 -1
- package/esm/feedback/FeedbackController.js +58 -53
- package/esm/feedback/server/index.d.ts +6 -15
- package/esm/feedback/server/index.js +4 -5
- package/esm/feedback/types.d.ts +14 -0
- package/esm/feedback/types.js +4 -0
- package/esm/feedback/ui/DialogIssue.svelte +131 -119
- package/esm/feedback/ui/DialogIssue.svelte.d.ts +20 -18
- package/esm/feedback/ui/DialogIssues.svelte +108 -99
- package/esm/feedback/ui/DialogIssues.svelte.d.ts +20 -18
- package/esm/feedback/ui/DialogMilestones.svelte +40 -34
- package/esm/feedback/ui/DialogMilestones.svelte.d.ts +18 -16
- package/esm/feedback/ui/Feedback.svelte +11 -9
- package/esm/feedback/ui/Feedback.svelte.d.ts +16 -14
- package/esm/index.d.ts +2 -5
- package/esm/index.js +2 -8
- package/esm/mail/server/index.d.ts +9 -2
- package/esm/mail/server/index.js +3 -1
- package/esm/mail/templates/DefaultMail.svelte +81 -61
- package/esm/mail/templates/DefaultMail.svelte.d.ts +28 -26
- package/esm/server/index.d.ts +0 -0
- package/esm/server/index.js +1 -0
- package/esm/storeItem.d.ts +1 -4
- package/esm/storeItem.js +1 -1
- package/esm/storeList.d.ts +1 -4
- package/esm/sveltekit/server/index.d.ts +3 -9
- package/esm/sveltekit/server/index.js +3 -0
- package/esm/ui/Button.svelte +112 -89
- package/esm/ui/Button.svelte.d.ts +34 -24
- package/esm/ui/Clipboardable.svelte +24 -17
- package/esm/ui/Clipboardable.svelte.d.ts +34 -23
- package/esm/ui/Field.svelte +328 -285
- package/esm/ui/Field.svelte.d.ts +15 -8
- package/esm/ui/FieldGroup.svelte +112 -91
- package/esm/ui/FieldGroup.svelte.d.ts +17 -6
- package/esm/ui/Grid.svelte +322 -308
- package/esm/ui/Grid.svelte.d.ts +17 -6
- package/esm/ui/GridLoading.svelte +28 -27
- package/esm/ui/GridLoading.svelte.d.ts +19 -17
- package/esm/ui/GridPaginate.svelte +68 -61
- package/esm/ui/GridPaginate.svelte.d.ts +21 -19
- package/esm/ui/Icon.svelte +116 -80
- package/esm/ui/Icon.svelte.d.ts +52 -43
- package/esm/ui/Loading.svelte +10 -8
- package/esm/ui/Loading.svelte.d.ts +29 -18
- package/esm/ui/Tooltip.svelte +38 -35
- package/esm/ui/Tooltip.svelte.d.ts +30 -20
- package/esm/ui/dialog/DialogForm.svelte +70 -63
- package/esm/ui/dialog/DialogForm.svelte.d.ts +18 -16
- package/esm/ui/dialog/DialogManagement.svelte +74 -74
- package/esm/ui/dialog/DialogManagement.svelte.d.ts +22 -21
- package/esm/ui/dialog/DialogPrimitive.svelte +82 -76
- package/esm/ui/dialog/DialogPrimitive.svelte.d.ts +35 -25
- package/esm/ui/dialog/FormEditAction.svelte +58 -50
- package/esm/ui/dialog/FormEditAction.svelte.d.ts +13 -6
- package/esm/ui/dialog/dialog.d.ts +1 -4
- package/esm/ui/internals/FieldContainer.svelte +24 -17
- package/esm/ui/internals/FieldContainer.svelte.d.ts +37 -28
- package/esm/ui/internals/Input.svelte +136 -102
- package/esm/ui/internals/Input.svelte.d.ts +34 -32
- package/esm/ui/internals/Textarea.svelte +60 -52
- package/esm/ui/internals/Textarea.svelte.d.ts +31 -28
- package/esm/ui/internals/select/MultiSelectMelt.svelte +243 -199
- package/esm/ui/internals/select/MultiSelectMelt.svelte.d.ts +29 -27
- package/esm/ui/internals/select/SelectMelt.svelte +254 -219
- package/esm/ui/internals/select/SelectMelt.svelte.d.ts +34 -32
- package/esm/ui/internals/select/SelectRadio.svelte +39 -33
- package/esm/ui/internals/select/SelectRadio.svelte.d.ts +24 -22
- package/esm/ui/link/Link.svelte +25 -20
- package/esm/ui/link/Link.svelte.d.ts +31 -23
- package/esm/ui/link/LinkPlus.svelte +52 -51
- package/esm/ui/link/LinkPlus.svelte.d.ts +20 -18
- package/esm/vite/index.d.ts +2 -3
- package/esm/vite/index.js +33 -26
- package/package.json +16 -20
- package/esm/auth/static/assets/Page-Bb8bFlrP.d.ts +0 -4
- package/esm/auth/static/assets/Page-Bb8bFlrP.js +0 -1
- package/esm/auth/static/assets/Page-BxomFlZ8.d.ts +0 -4
- package/esm/auth/static/assets/Page-BxomFlZ8.js +0 -1
- package/esm/auth/static/assets/Page-CaIYu0-y.d.ts +0 -6
- package/esm/auth/static/assets/Page-CaIYu0-y.js +0 -19
- package/esm/auth/static/assets/Page-MkYglNtu.css +0 -1
- package/esm/auth/static/assets/index-Bl0Bk5u0.d.ts +0 -64
- package/esm/auth/static/assets/index-Bl0Bk5u0.js +0 -2
- package/esm/auth/static/assets/index-R27C_TlP.css +0 -4
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var Kn=Object.defineProperty;var yi=n=>{throw TypeError(n)};var Xn=(n,e,t)=>e in n?Kn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var u=(n,e,t)=>Xn(n,typeof e!="symbol"?e+"":e,t),gi=(n,e,t)=>e.has(n)||yi("Cannot "+t);var Qe=(n,e,t)=>(gi(n,e,"read from private field"),t?t.call(n):e.get(n)),mi=(n,e,t)=>e.has(n)?yi("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),wi=(n,e,t,r)=>(gi(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t);import{s as vi,d as Yn,e as er,u as nn,N as Zn,g as es,L as ts,a as rs,i as is,c as ns,b as ss,f as as,n as os,h as ls,j as us,l as fs,r as ds,k as bi,m as cs,o as hs,w as ri,p as ps,q as sn,t as Or,v as _t,x as It,y as ys,z as Me,A as _i,B as gs,C as Ii,D as dr,E as ii,F as Ot,G as cr,H as $e,I as he,J as Z,K as kt,M as Ct,O as Et,P as se,Q as an,R as At,S as Pt,T as We,U as ms,V as Qr,W as ge,X as me,Y as Oi,Z as Oe,_ as tr,$ as te,a0 as ee,a1 as Te,a2 as W,a3 as Ue,a4 as fe,a5 as X,a6 as on,a7 as Se,a8 as Tt,a9 as ze,aa as et}from"./index-C9jzxOBu.js";function ln(n,e,t,r,i){var o;var s=(o=e.$$slots)==null?void 0:o[t],a=!1;s===!0&&(s=e.children,a=!0),s===void 0||s(n,a?()=>r:r)}function _e(n,e){return(t,...r)=>{var i=Yn;vi(n);try{return e(t,...r)}finally{vi(i)}}}function kr(n,e,t){er(()=>{var r=nn(()=>e(n,t==null?void 0:t())||{});if(r!=null&&r.destroy)return()=>r.destroy()})}function un(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=un(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function ws(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=un(n))&&(r&&(r+=" "),r+=e);return r}function vs(n){return typeof n=="object"?ws(n):n??""}const ki=[...`
|
|
2
|
+
\r\f \v\uFEFF`];function bs(n,e,t){var r=n==null?"":""+n;if(e&&(r=r?r+" "+e:e),t){for(var i in t)if(t[i])r=r?r+" "+i:i;else if(r.length)for(var s=i.length,a=0;(a=r.indexOf(i,a))>=0;){var o=a+s;(a===0||ki.includes(r[a-1]))&&(o===r.length||ki.includes(r[o]))?r=(a===0?"":r.substring(0,a))+r.substring(o+1):a=o}}return r===""?null:r}function Ci(n,e=!1){var t=e?" !important;":";",r="";for(var i in n){var s=n[i];s!=null&&s!==""&&(r+=" "+i+": "+s+t)}return r}function Rr(n){return n[0]!=="-"||n[1]!=="-"?n.toLowerCase():n}function _s(n,e){if(e){var t="",r,i;if(Array.isArray(e)?(r=e[0],i=e[1]):r=e,n){n=String(n).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var s=!1,a=0,o=!1,l=[];r&&l.push(...Object.keys(r).map(Rr)),i&&l.push(...Object.keys(i).map(Rr));var f=0,d=-1;const b=n.length;for(var c=0;c<b;c++){var h=n[c];if(o?h==="/"&&n[c-1]==="*"&&(o=!1):s?s===h&&(s=!1):h==="/"&&n[c+1]==="*"?o=!0:h==='"'||h==="'"?s=h:h==="("?a++:h===")"&&a--,!o&&s===!1&&a===0){if(h===":"&&d===-1)d=c;else if(h===";"||c===b-1){if(d!==-1){var p=Rr(n.substring(f,d).trim());if(!l.includes(p)){h!==";"&&c++;var g=n.substring(f,c).trim();t+=" "+g+";"}}f=c+1,d=-1}}}}return r&&(t+=Ci(r)),i&&(t+=Ci(i,!0)),t=t.trim(),t===""?null:t}return n==null?null:String(n)}function Bt(n,e,t,r,i,s){var a=n.__className;if(a!==t){var o=bs(t,r,s);o==null?n.removeAttribute("class"):e?n.className=o:n.setAttribute("class",o),n.__className=t}else if(s&&i!==s)for(var l in s){var f=!!s[l];(i==null||f!==!!i[l])&&n.classList.toggle(l,f)}return s}function $r(n,e={},t,r){for(var i in t){var s=t[i];e[i]!==s&&(t[i]==null?n.style.removeProperty(i):n.style.setProperty(i,s,r))}}function Is(n,e,t,r){var i=n.__style;if(i!==e){var s=_s(e,r);s==null?n.removeAttribute("style"):n.style.cssText=s,n.__style=e}else r&&(Array.isArray(r)?($r(n,t==null?void 0:t[0],r[0]),$r(n,t==null?void 0:t[1],r[1],"important")):$r(n,t,r));return r}const Ut=Symbol("class"),Vt=Symbol("style"),fn=Symbol("is custom element"),dn=Symbol("is html");function Os(n,e){e?n.hasAttribute("selected")||n.setAttribute("selected",""):n.removeAttribute("selected")}function rt(n,e,t,r){var i=cn(n);i[e]!==(i[e]=t)&&(e==="loading"&&(n[ts]=t),t==null?n.removeAttribute(e):typeof t!="string"&&hn(n).includes(e)?n[e]=t:n.setAttribute(e,t))}function ks(n,e,t,r,i=!1){var s=cn(n),a=s[fn],o=!s[dn],l=e||{},f=n.tagName==="OPTION";for(var d in e)d in t||(t[d]=null);t.class?t.class=vs(t.class):t[Ut]&&(t.class=null),t[Vt]&&(t.style??(t.style=null));var c=hn(n);for(const I in t){let D=t[I];if(f&&I==="value"&&D==null){n.value=n.__value="",l[I]=D;continue}if(I==="class"){var h=n.namespaceURI==="http://www.w3.org/1999/xhtml";Bt(n,h,D,r,e==null?void 0:e[Ut],t[Ut]),l[I]=D,l[Ut]=t[Ut];continue}if(I==="style"){Is(n,D,e==null?void 0:e[Vt],t[Vt]),l[I]=D,l[Vt]=t[Vt];continue}var p=l[I];if(D!==p){l[I]=D;var g=I[0]+I[1];if(g!=="$$")if(g==="on"){const E={},_="$$"+I;let A=I.slice(2);var b=ls(A);if(is(A)&&(A=A.slice(0,-7),E.capture=!0),!b&&p){if(D!=null)continue;n.removeEventListener(A,l[_],E),l[_]=null}if(D!=null)if(b)n[`__${A}`]=D,ss([A]);else{let N=function(B){l[I].call(this,B)};l[_]=ns(A,n,N,E)}else b&&(n[`__${A}`]=void 0)}else if(I==="style")rt(n,I,D);else if(I==="autofocus")as(n,!!D);else if(!a&&(I==="__value"||I==="value"&&D!=null))n.value=n.__value=D;else if(I==="selected"&&f)Os(n,D);else{var w=I;o||(w=os(w));var $=w==="defaultValue"||w==="defaultChecked";if(D==null&&!a&&!$)if(s[I]=null,w==="value"||w==="checked"){let E=n;const _=e===void 0;if(w==="value"){let A=E.defaultValue;E.removeAttribute(w),E.defaultValue=A,E.value=E.__value=_?A:null}else{let A=E.defaultChecked;E.removeAttribute(w),E.defaultChecked=A,E.checked=_?A:!1}}else n.removeAttribute(I);else $||c.includes(w)&&(a||typeof D!="string")?n[w]=D:typeof D!="function"&&rt(n,w,D)}}}return l}function cn(n){return n.__attributes??(n.__attributes={[fn]:n.nodeName.includes("-"),[dn]:n.namespaceURI===Zn})}var Ei=new Map;function hn(n){var e=Ei.get(n.nodeName);if(e)return e;Ei.set(n.nodeName,e=[]);for(var t,r=n,i=Element.prototype;i!==r;){t=rs(r);for(var s in t)t[s].set&&e.push(s);r=es(r)}return e}function vt(n,e,t=e){var r=us();fs(n,"input",i=>{n.type==="checkbox"&&bi();var s=i?n.defaultValue:n.value;if(s=Dr(n)?Mr(s):s,t(s),r&&s!==(s=e())){var a=n.selectionStart,o=n.selectionEnd;n.value=s??"",o!==null&&(n.selectionStart=a,n.selectionEnd=Math.min(o,n.value.length))}}),nn(e)==null&&n.value&&t(Dr(n)?Mr(n.value):n.value),ds(()=>{n.type==="checkbox"&&bi();var i=e();Dr(n)&&i===Mr(n.value)||n.type==="date"&&!i&&!n.value||i!==n.value&&(n.value=i??"")})}function Dr(n){var e=n.type;return e==="number"||e==="range"}function Mr(n){return n===""?null:+n}function Cr(n){return function(...e){var t=e[0];return t.preventDefault(),n==null?void 0:n.apply(this,e)}}function Cs(n,e){var s;var t=(s=n.$$events)==null?void 0:s[e.type],r=cs(t)?t.slice():t==null?[]:[t];for(var i of r)i.call(this,e)}function Rt(n,e){n!=null&&typeof n.subscribe!="function"&&hs(e)}const Es=n=>{const{subscribe:e,update:t}=ri(n);return{subscribe:e,set:(r={})=>{t(i=>Object.assign(i,r))}}},Nt=Es({mode:"window",basePath:null}),Nr=(n=ps(Nt).mode)=>{let e="popstate";n==="window"&&(e="popstate"),n==="hash"&&(e="hashchange"),window.dispatchEvent(new Event(e))},Ai={go:(n=0)=>{history.go(n),Nr()},push:(n,e=null)=>{history.pushState(e,"",n),Nr()},replace:(n,e=null)=>{history.replaceState(e,"",n),Nr()}},As=n=>{const e=n.match(/^(\/[^?#]*)?/),t=n.match(/\?([^#]*)?/),r=n.match(/#(.*)?/);return{path:(e==null?void 0:e[1])||"/",query:t!=null&&t[1]?`?${t==null?void 0:t[1]}`:"",hash:r!=null&&r[1]?`#${r==null?void 0:r[1]}`:""}},Ti=()=>{const{pathname:n,search:e,hash:t}=document.location;return{path:n,query:e,hash:t}},Si=()=>{let n=document.location.hash.substring(1);return n[0]!=="/"&&(n="/"+n),As(n)},Ts=sn(Ti(),n=>{const e=()=>n(Ti());return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),Ss=sn(Si(),n=>{const e=()=>n(Si());return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}),ni=Or([Nt,Ts,Ss],([n,e,t],r)=>{n.mode==="window"&&r(e),n.mode==="hash"&&r(t)}),Fi=Or(ni,n=>n.path);Or(ni,n=>n.query);Or(ni,n=>n.hash);const Fs=()=>{let n=0;return()=>n++},sr=n=>n.split(/(?=\/)/),Ps=(n,e)=>e===null?n:n.startsWith(e)?n.slice(e.length):n;Et();Je[se]="/home/jycouet/udev/gh/dp/my-minion-mr/firstly/node_modules/.pnpm/svelte-micro@2.5.7_svelte@5.23.0/node_modules/svelte-micro/dist/lib/components/Route.svelte";const Rs=(n,e,t,r,i)=>{const s=(f,d,c)=>{const h=sr(d).filter(p=>We(p,"/",!1)).length;return(c??0)+(f?1:h)},a=(f,d)=>{const c={invalidPath:`<Route path="${f==null?void 0:f.path}" /> has invalid path. Path must start with '/'`,fallbackOutsideRoot:"<Route fallback /> cannot be outside root <Route />",pathOutsideRoot:`<Route path="${f==null?void 0:f.path}" /> cannot be outside root <Route />`,fallbackInsideFallback:"<Route fallback /> cannot be inside <Route fallback>",pathInsideFallback:`<Route path="${f==null?void 0:f.path}" /> cannot be inside <Route fallback>`};if(We(f.path[0],"/",!1))throw new Error(c.invalidPath);if(f.root&&f.fallback)throw new Error(c.fallbackOutsideRoot);if(f.root&&We(f.path,"/",!1))throw new Error(c.pathOutsideRoot);if(d!=null&&d.fallback&&f.fallback)throw new Error(c.fallbackInsideFallback);if(d!=null&&d.fallback&&!f.fallback)throw new Error(c.pathInsideFallback)},o=s(t,r,i==null?void 0:i.depth),l={id:n,root:e,fallback:t,path:r,depth:o};return a(l,i),l},$s=()=>{const{subscribe:n,update:e}=ri([]);return{subscribe:n,update:t=>e(r=>[...r.filter(i=>We(t.id,i.id,!1)),t]),remove:t=>e(r=>r.filter(i=>We(t.id,i.id,!1)))}},Ds=(n,e,t)=>{const r=(f,d,c,h)=>{let p=sr(f).filter(w=>We(w,"/",!1)),g=sr(c).filter(w=>We(w,"/",!1)),b="";if(We(c,"/"))return d||We(p.length,h);for(let w=h-g.length;w<h;w++)b=b+p[w];return We(c,b)},i=(f,d,c)=>{var g,b,w,$;let h=sr(f).filter(I=>We(I,"/",!1)),p=!1;for(let I=0;I<(c==null?void 0:c.length)&&!p;I++)(g=c[I])!=null&&g.fallback||(p=r(f,((b=c[I])==null?void 0:b.root)??!1,((w=c[I])==null?void 0:w.path)??"",(($=c[I])==null?void 0:$.depth)??0));return h.length>=d&&!p},{root:s,fallback:a,path:o,depth:l}=e;return a?i(n,l,t):r(n,s,o,l)},Ms=Fs(),xr={},Pi={};function Je(n,e){_t(new.target),It(e,!1,Je);const[t,r]=an(),i=()=>(Rt(p,"route"),Pt(p,"$route",t)),s=()=>(Rt(g,"contextRoute"),Pt(g,"$contextRoute",t)),a=()=>(Rt(Fi,"globalPath"),Pt(Fi,"$globalPath",t)),o=()=>(Rt(Nt,"options"),Pt(Nt,"$options",t)),l=()=>(Rt(w,"contextChildRoutes"),Pt(w,"$contextChildRoutes",t)),f=Ms(),d=!ys(xr);let c=Me(e,"fallback",9,!1),h=Me(e,"path",9,"/");const p=ri(),g=_i(xr),b=$s(),w=_i(Pi);gs(()=>w==null?void 0:w.remove(i())),Ii(xr,p),Ii(Pi,b),dr(()=>(Qr(c()),Qr(h()),s()),()=>{ms(p,Rs(f,d,c(),h(),s()))}),dr(()=>i(),()=>{w==null||w.update(i())}),ii(),Ot(!0);var $=cr(),I=$e($);{var D=_=>{var A=cr(),N=$e(A);ln(N,e,"default",{}),Z(_,A)};he(I,_=>{Ds(Ps(a(),o().basePath),i(),l())&&_(D)})}Z(n,$);var E=kt({...Ct()});return r(),E}At(Je);const Ri=n=>{var o;const e=(o=n.target)==null?void 0:o.closest("a[href]"),t=e==null?void 0:e.href;if(e===null||t===null)return!0;const r=["","true"].includes(e.getAttribute("data-handle-ignore")??"false"),i=(e.getAttribute("target")??"_self")!=="_self",s=n.metaKey||n.ctrlKey||n.altKey||n.shiftKey,a=new URL(t).origin!==document.location.origin;if(r||i||s||a)return!0;t===document.location.href?Ai.replace(t):Ai.push(t),n.preventDefault()},Lr=n=>(n.addEventListener("click",Ri),{destroy:()=>{n.removeEventListener("click",Ri)}});Et();Le[se]="/home/jycouet/udev/gh/dp/my-minion-mr/firstly/node_modules/.pnpm/svelte-micro@2.5.7_svelte@5.23.0/node_modules/svelte-micro/dist/lib/components/Link.svelte";const Ns=(n,e,t)=>(We(n,"hash")?"#":"")+(e??"")+t;var xs=ge(me("<a><!></a>"),Le[se],[[16,0]]);function Le(n,e){_t(new.target);const t=Oi(e,["children","$$slots","$$events","$$legacy"]),r=Oi(t,["href"]);It(e,!1,Le);const[i,s]=an(),a=()=>(Rt(Nt,"options"),Pt(Nt,"$options",i)),o=Te(void 0,!0);let l=Me(e,"href",9);dr(()=>(a(),Qr(l())),()=>{te(o,Ns(a().mode,a().basePath,l()))}),ii(),Ot(!0);var f=xs();let d;var c=ee(f);ln(c,e,"default",{}),kr(f,p=>Lr==null?void 0:Lr(p)),er(()=>tr("click",f,function(p){Cs.call(this,e,p)})),Oe(()=>d=ks(f,d,{href:W(o),...r})),Z(n,f);var h=kt({...Ct()});return s(),h}At(Le);const si={FF_Role_Admin:"FF_Role.Admin"};class gt{constructor(...e){u(this,"fields");u(this,"options",{});u(this,"target");u(this,"readonly",!0);u(this,"allowNull",!1);u(this,"dbReadOnly",!1);u(this,"isServerExpression",!1);u(this,"key","");u(this,"caption","");u(this,"inputType","");u(this,"dbName","");u(this,"valueType");this.fields=e}apiUpdateAllowed(e){throw new Error("Method not implemented.")}displayValue(e){throw new Error("Method not implemented.")}includedInApi(e){throw new Error("Method not implemented.")}toInput(e,t){throw new Error("Method not implemented.")}fromInput(e,t){throw new Error("Method not implemented.")}getDbName(){return Promise.resolve("")}getId(e){let t=i=>e[i.key];typeof e=="function"&&(t=e);let r="";return this.fields.forEach(i=>{r.length>0&&(r+=","),r+=i.valueConverter.toJson(t(i))}),r}get valueConverter(){throw new Error("cant get value converter of compound id")}isEqualTo(e){let t={},i=e.toString().split(",");return this.fields.forEach((s,a)=>{t[s.key]=s.valueConverter.fromJson(i[a])}),t}}function ue(n,e=!0){var r;if(n===void 0)throw new Error("entity is undefined");let t=n[yt];if(!t&&e)throw new Error("item "+(((r=n.constructor)==null?void 0:r.name)||n)+" was not initialized using a context");return t}const yt=Symbol.for("entityMember"),pn=Symbol.for("entityInfo"),yn=Symbol.for("entityInfo_key");function Be(n,e=!0){if(n===void 0){if(e)throw new Error("Undefined is not an entity :)");return}let t=n[pn];if(!t&&e)throw new Error(n.prototype.constructor.name+" is not a known entity, did you forget to set @Entity() or did you forget to add the '@' before the call to Entity?");return t}function Ls(n){return n[yn]}function qr(n,e){return{[gn]:{toType:n,type:e}}}const gn=Symbol.for("relationInfo");function qs(n){return n==null?void 0:n[gn]}const zr=Symbol.for("fieldRelationInfo");function de(n){if(n)return n[zr]}function Bs(n,e,t){for(const r of n.fields.toArray()){const i=qs(r.options);if(i&&!r[zr]){const s=i.toType(),a=e.repo(s,t),o=r.options;r[zr]={type:i.type,toEntity:s,options:o,toRepo:a,getFields:()=>{let l=o.field,f={fields:o.fields,compoundIdField:void 0};function d(p){return Error(`Error for relation: "${n.metadata.key}.${r.key}", `+p)}let c=()=>l||f.fields;if(i.type==="toMany"&&!c()){for(const p of a.fields.toArray())if(!c()){const g=de(p),b=p.options;if(g&&g.toEntity===n.metadata.entityType){if(g.type==="reference")l=p.key;else if(g.type==="toOne"){if(b.field)l=b.field;else if(b.fields){let w={};for(const $ in b.fields)if(Object.prototype.hasOwnProperty.call(b.fields,$)){const I=b.fields[$];w[I]=$}f.fields=w}}}}if(!c())throw d(`No matching field found on target "${a.metadata.key}". Please specify field/fields`)}function h(p,g){const b=g.fields.find(p);if(!b)throw d(`Field "${p}" was not found in "${g.key}".`);return b}i.type==="reference"&&(l=r.key),l&&(i.type==="toOne"||i.type==="reference"?a.metadata.idMetadata.field instanceof gt?f.compoundIdField=l:f.fields={[a.metadata.idMetadata.field.key]:l}:n.metadata.idMetadata.field instanceof gt?f.compoundIdField=l:f.fields={[l]:n.metadata.idMetadata.field.key});for(const p in f.fields)Object.prototype.hasOwnProperty.call(f.fields,p)&&(h(p,a.metadata),h(f.fields[p],n.metadata));return f}}}}}class q{constructor(e){u(this,"apply");this.apply=e}static throwErrorIfFilterIsEmpty(e,t){if(q.isFilterEmpty(e))throw{message:`${t}: requires a filter to protect against accidental delete/update of all rows`,httpStatusCode:400}}static isFilterEmpty(e){if(e.$and){for(const t of e.$and)if(!q.isFilterEmpty(t))return!1}if(e.$or){for(const t of e.$or)if(q.isFilterEmpty(t))return!0;return!1}return Object.keys(e).filter(t=>!["$or","$and"].includes(t)).length==0}static async getPreciseValues(e,t){const r=new gr;return await q.fromEntityFilter(e,t).__applyToConsumer(r),r.preciseValues}async getPreciseValues(){const e=new gr;return await this.__applyToConsumer(e),e.preciseValues}static createCustom(e,t=""){let r={key:t,rawFilterTranslator:e};return Object.assign(i=>{if(i==null&&(i={}),!r.key)throw"Usage of custom filter before a key was assigned to it";return{[mt+r.key]:i}},{rawFilterInfo:r})}static entityFilterToJson(e,t){return q.fromEntityFilter(e,t).toJson()}static entityFilterFromJson(e,t){return ar(e,{get:r=>t[r]})}static fromEntityFilter(e,t){let r=[];for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){let s=t[i];if(i=="$or")r.push(new Us(...s.map(a=>q.fromEntityFilter(e,a))));else if(i=="$not")r.push(new Vs(q.fromEntityFilter(e,s)));else if(i=="$and")r.push(new $i(...s.map(a=>q.fromEntityFilter(e,a))));else if(i.startsWith(mt))r.push(new q(a=>{a.custom(i.substring(mt.length),s)}));else if(i==mn)r.push(new q(a=>a.databaseCustom(s)));else{const a=e.fields[i],o=de(a),l=a.options;let f=(o==null?void 0:o.type)==="toOne"?l.fields?new Js(a,e.fields,l):new js(e.fields[l.field]):new hr(a),d=!1;if(s!==void 0&&s!=null){s.$id!==void 0&&(s=s.$id);for(const c in s)if(Object.prototype.hasOwnProperty.call(s,c)){const h=s[c];switch(c){case"$gte":case">=":r.push(f.isGreaterOrEqualTo(h)),d=!0;break;case"$gt":case">":r.push(f.isGreaterThan(h)),d=!0;break;case"$lte":case"<=":r.push(f.isLessOrEqualTo(h)),d=!0;break;case"$lt":case"<":r.push(f.isLessThan(h)),d=!0;break;case"$ne":case"$not":case"!=":case"$nin":d=!0,Array.isArray(h)?r.push(f.isNotIn(h)):r.push(f.isDifferentFrom(h));break;case"$in":d=!0,r.push(f.isIn(h));break;case"$contains":d=!0,r.push(f.contains(h));break;case"$startsWith":d=!0,r.push(f.startsWith(h));break;case"$endsWith":d=!0,r.push(f.endsWith(h));break;case"$notContains":d=!0,r.push(f.notContains(h));break}}Array.isArray(s)&&(d=!0,r.push(f.isIn(s)))}!d&&s!==void 0&&r.push(f.isEqualTo(s))}}return new $i(...r)}__applyToConsumer(e){this.apply(e)}static async resolve(e){return typeof e=="function"?await e():e}toJson(){let e=new pr;return this.__applyToConsumer(e),e.result}static async translateCustomWhere(e,t,r){let i=new yr(async(s,a)=>{let o=[];for(const l in t.entityType){const f=t.entityType[l];f&&f.rawFilterInfo&&f.rawFilterInfo.rawFilterTranslator&&f.rawFilterInfo.key==s&&o.push(await q.fromEntityFilter(t,await f.rawFilterInfo.rawFilterTranslator(a,r)))}return o});return e.__applyToConsumer(i),await i.resolve(),e=new q(s=>i.applyTo(s)),e}}class hr{constructor(e){u(this,"metadata");this.metadata=e}processVal(e){if(Be(this.metadata.valueType,!1)){if(e==null){if(e===null&&!this.metadata.allowNull){const r=de(this.metadata);if((r==null?void 0:r.type)==="reference")return r.toRepo.metadata.idMetadata.field.options.valueType===Number?0:""}return null}return typeof e=="string"||typeof e=="number"?e:ue(e).getId()}return e}contains(e){return new q(t=>t.containsCaseInsensitive(this.metadata,e))}notContains(e){return new q(t=>t.notContainsCaseInsensitive(this.metadata,e))}startsWith(e){return new q(t=>t.startsWithCaseInsensitive(this.metadata,e))}endsWith(e){return new q(t=>t.endsWithCaseInsensitive(this.metadata,e))}isLessThan(e){return e=this.processVal(e),new q(t=>t.isLessThan(this.metadata,e))}isGreaterOrEqualTo(e){return e=this.processVal(e),new q(t=>t.isGreaterOrEqualTo(this.metadata,e))}isNotIn(e){return new q(t=>{for(const r of e)t.isDifferentFrom(this.metadata,this.processVal(r))})}isDifferentFrom(e){return e=this.processVal(e),e==null&&this.metadata.allowNull?new q(t=>t.isNotNull(this.metadata)):new q(t=>t.isDifferentFrom(this.metadata,e))}isLessOrEqualTo(e){return e=this.processVal(e),new q(t=>t.isLessOrEqualTo(this.metadata,e))}isGreaterThan(e){return e=this.processVal(e),new q(t=>t.isGreaterThan(this.metadata,e))}isEqualTo(e){return e=this.processVal(e),e==null&&this.metadata.allowNull?new q(t=>t.isNull(this.metadata)):new q(t=>t.isEqualTo(this.metadata,e))}isIn(e){return e=e.map(t=>this.processVal(t)),(e==null?void 0:e.length)==1&&e[0]!=null&&e[0]!==null?new q(t=>t.isEqualTo(this.metadata,e[0])):new q(t=>t.isIn(this.metadata,e))}}class js extends hr{processVal(e){return e?typeof e=="string"||typeof e=="number"?e:ue(e).getId():null}}class Js{constructor(e,t,r){u(this,"metadata");u(this,"fields");u(this,"relationOptions");this.metadata=e,this.fields=t,this.relationOptions=r}processVal(e){throw new Error("Invalid for Many To One Relation Field")}contains(e){throw new Error("Invalid for Many To One Relation Field")}notContains(e){throw new Error("Invalid for Many To One Relation Field")}endsWith(e){throw new Error("Invalid for Many To One Relation Field")}startsWith(e){throw new Error("Invalid for Many To One Relation Field")}isLessThan(e){throw new Error("Invalid for Many To One Relation Field")}isGreaterOrEqualTo(e){throw new Error("Invalid for Many To One Relation Field")}isNotIn(e){return new q(t=>{e.forEach(r=>this.isDifferentFrom(r).__applyToConsumer(t))})}isDifferentFrom(e){return new q(t=>{const r=[];for(const i in this.relationOptions.fields)if(Object.prototype.hasOwnProperty.call(this.relationOptions.fields,i)){const s=this.relationOptions.fields[i];r.push(new q(a=>new hr(this.fields.find(s)).isDifferentFrom(e[i]).__applyToConsumer(a)))}t.or(r)})}isLessOrEqualTo(e){throw new Error("Invalid for Many To One Relation Field")}isGreaterThan(e){throw new Error("Invalid for Many To One Relation Field")}isEqualTo(e){return new q(t=>{for(const r in this.relationOptions.fields)if(Object.prototype.hasOwnProperty.call(this.relationOptions.fields,r)){const i=this.relationOptions.fields[r];new hr(this.fields.find(i)).isEqualTo(e[r]).__applyToConsumer(t)}})}isIn(e){return new q(t=>{t.or(e.map(r=>this.isEqualTo(r)))})}}class $i extends q{constructor(...t){super(r=>{for(const i of this.filters)i&&i.__applyToConsumer(r)});u(this,"filters");this.filters=t}add(t){this.filters.push(t)}}class Us extends q{constructor(...t){super(r=>{let i=this.filters.filter(s=>s!==void 0);i.length>1?r.or(i):i.length==1&&i[0].__applyToConsumer(r)});u(this,"filters");this.filters=t}}class Vs extends q{constructor(t){super(r=>{r.not(t)});u(this,"filter");this.filter=t}}const mt="$custom$",mn="$db$",Kr="$an array";class pr{constructor(){u(this,"result",{});u(this,"hasUndefined",!1)}databaseCustom(e){throw new Error("database custom is not allowed with api calls.")}custom(e,t){Array.isArray(t)&&(t={[Kr]:t}),this.add(mt+e,t)}add(e,t){t===void 0&&(this.hasUndefined=!0);let r=this.result;if(!r[e]){r[e]=t;return}let i=r[e];i instanceof Array?i.push(t):i=[i,t],r[e]=i}or(e){this.add("OR",e.map(t=>{let r=new pr;return t.__applyToConsumer(r),r.result}))}not(e){let t=new pr;e.__applyToConsumer(t),this.add("NOT",t.result)}isNull(e){this.add(e.key+".null",!0)}isNotNull(e){this.add(e.key+".null",!1)}isIn(e,t){this.add(e.key+".in",t.map(r=>e.valueConverter.toJson(r)))}isEqualTo(e,t){this.add(e.key,e.valueConverter.toJson(t))}isDifferentFrom(e,t){this.add(e.key+".ne",e.valueConverter.toJson(t))}isGreaterOrEqualTo(e,t){this.add(e.key+".gte",e.valueConverter.toJson(t))}isGreaterThan(e,t){this.add(e.key+".gt",e.valueConverter.toJson(t))}isLessOrEqualTo(e,t){this.add(e.key+".lte",e.valueConverter.toJson(t))}isLessThan(e,t){this.add(e.key+".lt",e.valueConverter.toJson(t))}containsCaseInsensitive(e,t){this.add(e.key+".contains",t)}notContainsCaseInsensitive(e,t){this.add(e.key+".notContains",t)}startsWithCaseInsensitive(e,t){this.add(e.key+".startsWith",t)}endsWithCaseInsensitive(e,t){this.add(e.key+".endsWith",t)}}function ar(n,e){let t={};function r(o){t.$and||(t.$and=[]),t.$and.push(o)}function i(o,l){t[o]===void 0?t[o]=l:r({[o]:l})}[...n.fields].forEach(o=>{function l(d,c,h=!1,p=!1){let g=e.get(o.key+d);if(g!==void 0){let b=w=>{let $=w;if(h){let D;typeof w=="string"?D=JSON.parse(w):D=w,$=D.map(E=>p?E:o.valueConverter.fromJson(E))}else $=p?$:o.valueConverter.fromJson($);let I=c($);I!==void 0&&i(o.key,I)};if(!h&&g instanceof Array)g.forEach(w=>{b(w)});else{h&&typeof g=="string"&&(g=JSON.parse(g));const w=a(g);for(const $ of w)b($)}}}l("",d=>d),l(".gt",d=>({$gt:d})),l(".gte",d=>({$gte:d})),l(".lt",d=>({$lt:d})),l(".lte",d=>({$lte:d})),l(".ne",d=>({$ne:d})),l(".in",d=>d,!0);var f=e.get(o.key+".null");if(f)switch(f=f.toString().trim().toLowerCase(),f){case"y":case"true":case"yes":i(o.key,null);break;default:i(o.key,{$ne:null});break}l(".contains",d=>({$contains:d}),!1,!0),l(".notContains",d=>({$notContains:d}),!1,!0),l(".startsWith",d=>({$startsWith:d}),!1,!0),l(".endsWith",d=>({$endsWith:d}),!1,!0)});let s=e.get("OR");if(s){const l=a(s).map(f=>({$or:f.map(d=>ar(n,{get:c=>d[c]}))}));l.length==1?t.$or?t.$or.push(l[0].$or):t.$or=l[0].$or:r({$and:l})}if(s=e.get("NOT"),s){let o=a(s);const l=[];for(const f of o)if(Array.isArray(f))for(const d of f)l.push({$not:ar(n,{get:c=>d[c]})});else l.push({$not:ar(n,{get:d=>f[d]})});l.length==1?t.$not?t.$not.push(l[0].$not):t.$not=l[0].$not:r({$and:l})}for(const o in n.entityType){const l=n.entityType[o];if(l&&l.rawFilterInfo&&l.rawFilterInfo.rawFilterTranslator){let f=e.get(mt+o);if(f!==void 0){const d=c=>{c[Kr]!=null&&(c=c[Kr]),i(mt+o,c)};Array.isArray(f)?f.forEach(c=>d(c)):d(f)}}}return t;function a(o){if(!Array.isArray(o))return[o];const l=[],f=[];for(const d of o)Array.isArray(d)?f.push(d):l.push(d);return f.push(l),f}}class yr{constructor(e){u(this,"translateCustom");u(this,"commands",[]);u(this,"promises",[]);this.translateCustom=e}applyTo(e){this.commands.forEach(t=>t(e))}or(e){let t;this.promises.push(Promise.all(e.map(async r=>{let i=new yr(this.translateCustom);return r.__applyToConsumer(i),await i.resolve(),new q(s=>i.applyTo(s))})).then(r=>{t=r})),this.commands.push(r=>r.or(t))}not(e){let t;this.promises.push((async()=>{let r=new yr(this.translateCustom);e.__applyToConsumer(r),await r.resolve(),t=new q(i=>r.applyTo(i))})()),this.commands.push(r=>r.not(t))}isEqualTo(e,t){this.commands.push(r=>r.isEqualTo(e,t))}isDifferentFrom(e,t){this.commands.push(r=>r.isDifferentFrom(e,t))}isNull(e){this.commands.push(t=>t.isNull(e))}isNotNull(e){this.commands.push(t=>t.isNotNull(e))}isGreaterOrEqualTo(e,t){this.commands.push(r=>r.isGreaterOrEqualTo(e,t))}isGreaterThan(e,t){this.commands.push(r=>r.isGreaterThan(e,t))}isLessOrEqualTo(e,t){this.commands.push(r=>r.isLessOrEqualTo(e,t))}isLessThan(e,t){this.commands.push(r=>r.isLessThan(e,t))}containsCaseInsensitive(e,t){this.commands.push(r=>r.containsCaseInsensitive(e,t))}notContainsCaseInsensitive(e,t){this.commands.push(r=>r.notContainsCaseInsensitive(e,t))}startsWithCaseInsensitive(e,t){this.commands.push(r=>r.startsWithCaseInsensitive(e,t))}endsWithCaseInsensitive(e,t){this.commands.push(r=>r.endsWithCaseInsensitive(e,t))}isIn(e,t){this.commands.push(r=>r.isIn(e,t))}custom(e,t){this.promises.push((async()=>{let r=await this.translateCustom(e,t);r&&(Array.isArray(r)?r.forEach(i=>i.__applyToConsumer(this)):r.__applyToConsumer(this))})())}databaseCustom(e){this.commands.push(t=>t.databaseCustom(e))}async resolve(){for(;this.promises.length>0;){let e=this.promises;this.promises=[],await Promise.all(e)}}}class gr{constructor(){u(this,"rawValues",{});u(this,"preciseValues",new Proxy(this.rawValues,{get:(e,t)=>{if(t in e){let r=e[t];if(r.bad)return;if(r.values.length>0){const i=de(r.field);if(i){if(i.type==="reference")return r.values.map(s=>i.toRepo.metadata.idMetadata.getIdFilter(s));throw new Error("Only relations toOne without field are supported.")}return r.values}}}}))}ok(e,...t){let r=this.rawValues[e.key];r?r.values.push(...t.filter(i=>!r.values.includes(i))):this.rawValues[e.key]={field:e,bad:!1,values:[...t]}}notOk(e){let t=this.rawValues[e.key];t?t.bad=!0:this.rawValues[e.key]={field:e,bad:!0,values:[]}}not(e){}or(e){const t=e.map(r=>{let i=new gr;return r.__applyToConsumer(i),i});for(const r of t)for(const i in r.rawValues)if(Object.prototype.hasOwnProperty.call(r.rawValues,i)){const s=r.rawValues[i];s&&(s.bad?this.notOk(s.field):this.ok(s.field,...s.values))}for(const r in this.rawValues)if(Object.prototype.hasOwnProperty.call(this.rawValues,r))for(const i of t)i.rawValues[r]||this.notOk(this.rawValues[r].field)}isEqualTo(e,t){this.ok(e,t)}isDifferentFrom(e,t){this.notOk(e)}isNull(e){this.ok(e,null)}isNotNull(e){this.notOk(e)}isGreaterOrEqualTo(e,t){this.notOk(e)}isGreaterThan(e,t){this.notOk(e)}isLessOrEqualTo(e,t){this.notOk(e)}isLessThan(e,t){this.notOk(e)}containsCaseInsensitive(e,t){this.notOk(e)}notContainsCaseInsensitive(e,t){this.notOk(e)}startsWithCaseInsensitive(e,t){this.notOk(e)}endsWithCaseInsensitive(e,t){this.notOk(e)}isIn(e,t){this.ok(e,...t)}custom(e,t){}databaseCustom(e){}}var Ws={};const Br=Symbol.for("remult-static1");let or={defaultRemultFactory:void 0,remultFactory:void 0,defaultRemult:void 0,asyncContext:void 0,columnsOfType:new Map,allEntities:[],classHelpers:new Map,actionInfo:{allActions:[],runningOnServer:!1,runActionWithoutBlockingUI:n=>n(),startBusyWithProgress:()=>({progress:n=>{},close:()=>{}})},fieldOptionsEnricher:void 0,captionTransformer:void 0,defaultDataProvider:()=>{}};typeof process<"u"&&Ws.IGNORE_GLOBAL_REMULT_IN_TESTS||typeof globalThis[Br]>"u"?(globalThis[Br]=or,or.remultFactory=()=>wn()):or=globalThis[Br];const R=or;function wn(){return R.defaultRemult||(R.defaultRemult=R.defaultRemultFactory()),R.defaultRemult}function Hs(){R.remultFactory=()=>wn()}function wt(n){const e=n;if(typeof e[Xt]=="function")return e[Xt]();throw Error("Error getting repository internal from "+n)}const Xt=Symbol.for("getInternal");class Gs{constructor(){u(this,"iAmRemultProxy",!0);u(this,"repoCache",new Map);u(this,"repo",(...e)=>{let t=R,r=this.repoCache.get(e[0]);r||this.repoCache.set(e[0],r=new Map);let i=r.get(e[1]);return i||(i={get fields(){return R.remultFactory().repo(...e).metadata.fields},[Xt](){return t.remultFactory().repo(...e)[Xt]()},relations:s=>t.remultFactory().repo(...e).relations(s),validate:(s,...a)=>t.remultFactory().repo(...e).validate(s,...a),addEventListener:(...s)=>t.remultFactory().repo(...e).addEventListener(...s),count:(...s)=>t.remultFactory().repo(...e).count(...s),create:(...s)=>t.remultFactory().repo(...e).create(...s),delete:s=>t.remultFactory().repo(...e).delete(s),deleteMany:s=>t.remultFactory().repo(...e).deleteMany(s),updateMany:(...s)=>t.remultFactory().repo(...e).updateMany(...s),find:(...s)=>t.remultFactory().repo(...e).find(...s),groupBy:(...s)=>t.remultFactory().repo(...e).groupBy(...s),aggregate:(...s)=>t.remultFactory().repo(...e).aggregate(...s),findFirst:(...s)=>t.remultFactory().repo(...e).findFirst(...s),findOne:(...s)=>t.remultFactory().repo(...e).findOne(...s),findId:(s,a)=>t.remultFactory().repo(...e).findId(s,a),toJson:s=>t.remultFactory().repo(...e).toJson(s),fromJson:(s,a)=>t.remultFactory().repo(...e).fromJson(s,a),getEntityRef:(...s)=>t.remultFactory().repo(...e).getEntityRef(...s),insert:s=>t.remultFactory().repo(...e).insert(s),liveQuery:(...s)=>t.remultFactory().repo(...e).liveQuery(...s),get metadata(){return R.remultFactory().repo(...e).metadata},query:s=>t.remultFactory().repo(...e).query(s),save:s=>t.remultFactory().repo(...e).save(s),upsert:s=>t.remultFactory().repo(...e).upsert(s),update:(s,a)=>t.remultFactory().repo(...e).update(s,a)},r.set(e[1],i),i)})}get liveQuerySubscriber(){return R.remultFactory().liveQuerySubscriber}set liveQuerySubscriber(e){R.remultFactory().liveQuerySubscriber=e}get liveQueryStorage(){return R.remultFactory().liveQueryStorage}set liveQueryStorage(e){R.remultFactory().liveQueryStorage=e}get liveQueryPublisher(){return R.remultFactory().liveQueryPublisher}set liveQueryPublisher(e){R.remultFactory().liveQueryPublisher=e}subscribeAuth(e){return R.remultFactory().subscribeAuth(e)}initUser(){return R.remultFactory().initUser()}call(e,t,...r){return R.remultFactory().call(e,t,...r)}get context(){return R.remultFactory().context}get dataProvider(){return R.remultFactory().dataProvider}set dataProvider(e){R.remultFactory().dataProvider=e}get repCache(){return R.remultFactory().repCache}authenticated(){return R.remultFactory().authenticated()}isAllowed(e){return R.remultFactory().isAllowed(e)}isAllowedForInstance(e,t){return R.remultFactory().isAllowedForInstance(e,t)}clearAllCache(){return R.remultFactory().clearAllCache()}useFetch(e){return R.remultFactory().useFetch(e)}get user(){return R.remultFactory().user}set user(e){R.remultFactory().user=e}get apiClient(){return R.remultFactory().apiClient}set apiClient(e){R.remultFactory().apiClient=e}get subscriptionServer(){return R.remultFactory().subscriptionServer}set subscriptionServer(e){R.remultFactory().subscriptionServer=e}}const De=new Gs,Qs="$count",zs=Symbol.for("GroupByForApiKey"),Ks=["sum","avg","min","max","distinctCount"],vn={error500RetryCount:4};function Xr(n){return n.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()).replace("Email","eMail")}class Xs{constructor(e,t,r){u(this,"repository");u(this,"isReferenceRelation");u(this,"allowNull");u(this,"storedItem");u(this,"id");this.repository=e,this.isReferenceRelation=t,this.allowNull=r}toJson(){if(this.storedItem)return this.item===null?null:this.repository.toJson(this.item)}setId(e){this.repository.metadata.idMetadata.field.valueType==Number&&(e=+e),this.id=e}waitLoadOf(e){return e==null?null:wt(this.repository)._getCachedByIdAsync(e,!1)}get(e){if(e==null)return null;const t=wt(this.repository)._getCachedById(e,this.isReferenceRelation);return this.isReferenceRelation&&!this.storedItem?!this.allowNull&&(this.id===0||this.id==="")?null:void 0:t}set(e){if(e===null&&!this.allowNull&&this.isReferenceRelation&&(this.id==0||this.id=="")){this.storedItem={item:null};return}if(this.storedItem=void 0,e)if(typeof e=="string"||typeof e=="number")this.id=e;else{let t=ue(e,!1);t&&!this.isReferenceRelation?(wt(this.repository)._addToCache(e),this.id=t.getId()):(this.storedItem={item:e},this.id=e[this.repository.metadata.idMetadata.field.key])}else e===null?this.id=null:this.id=void 0}get item(){return this.storedItem?this.storedItem.item:this.get(this.id)}async waitLoad(){return this.waitLoadOf(this.id)}}class Di{constructor(e){u(this,"url");this.url=e}add(e,t){this.url.indexOf("?")>=0?this.url+="&":this.url+="?",this.url+=encodeURIComponent(e)+"="+encodeURIComponent(t)}addObject(e,t=""){if(e!=null)for(var r in e){let i=e[r];this.add(r+t,i)}}}function xt(n){if(!n)return new Mi;let e;return e||bn(n)&&(e=new Ys(n)),e||typeof n=="function"&&(e=new Mi(n)),e}function bn(n){let e=n;return!!(e&&e.get&&e.put&&e.post&&e.delete)}class Ys{constructor(e){u(this,"http");this.http=e}async post(e,t){return await mr(()=>rr(this.http.post(e,t)))}delete(e){return rr(this.http.delete(e))}put(e,t){return rr(this.http.put(e,t))}async get(e){return await mr(()=>rr(this.http.get(e)))}}async function mr(n){var t,r,i,s;let e=0;for(;;)try{return await n()}catch(a){if(((t=a.message)!=null&&t.startsWith("Error occurred while trying to proxy")||(r=a.message)!=null&&r.startsWith("Error occured while trying to proxy")||(i=a.message)!=null&&i.includes("http proxy error")||(s=a.message)!=null&&s.startsWith("Gateway Timeout")||a.status==500)&&e++<vn.error500RetryCount){await new Promise((o,l)=>{setTimeout(()=>{o({})},500)});continue}throw a}}function rr(n){let e;return n.toPromise!==void 0?e=n.toPromise():e=n,e.then(t=>t&&(t.status==200||t.status==201)&&t.headers&&t.request&&t.data!==void 0?t.data:t).catch(async t=>{throw await Zs(t)})}async function Zs(n){var s,a,o;let e=await n;var t;e.error?t=e.error:e.isAxiosError&&(typeof((s=e.response)==null?void 0:s.data)=="string"?t=e.response.data:t=(a=e==null?void 0:e.response)==null?void 0:a.data),t||(t=e.message),e.status==0&&e.error.isTrusted&&(t="Network Error"),typeof t=="string"&&(t={message:t}),e.modelState&&(t.modelState=e.modelState);let r=e.status;r===void 0&&(r=(o=e.response)==null?void 0:o.status),r!=null&&(t.httpStatusCode=r);var i=Object.assign(t??{},{});return i}class Yr{constructor(e,t){u(this,"apiProvider");u(this,"entityRequested");u(this,"isProxy",!0);this.apiProvider=e,this.entityRequested=t}getEntityDataProvider(e){var t;return(t=this.entityRequested)==null||t.call(this,e),new ea(()=>{var r;return _n((r=this.apiProvider())==null?void 0:r.url,e.key)},()=>xt(this.apiProvider().httpClient),e)}async transaction(e){throw new Error("Method not implemented.")}}function _n(n,e){return n==null&&(n="/api"),n+"/"+e}function ai(n,e){if(n.include){let t={};for(const r in n.include)if(Object.prototype.hasOwnProperty.call(n.include,r)){let i=n.include[r];if(typeof i=="object"){const s=de(e.fields.find(r));s&&(i=ai(i,s.toRepo.metadata))}t[r]=i}n={...n,include:t}}return n.where&&(n={...n,where:q.entityFilterToJson(e,n.where)}),n.load&&(n={...n,load:n.load(e.fields).map(t=>t.key)}),n}class ea{constructor(e,t,r){u(this,"url");u(this,"http");u(this,"entity");this.url=e,this.http=t,this.entity=r}query(e,t){return this.buildFindRequest(e).run("query",{aggregate:this.buildAggregateOptions(t)}).then(({items:i,aggregates:s})=>({items:i.map(a=>this.translateFromJson(a)),aggregates:s}))}async groupBy(e){const{run:t}=this.buildFindRequest({where:e==null?void 0:e.where,limit:e==null?void 0:e.limit,page:e==null?void 0:e.page}),r=this.buildAggregateOptions(e),i=await t("groupBy",Object.keys(r).length>0?r:void 0);return e!=null&&e.group&&i.forEach(s=>{for(const a of e.group)s[a.key]=a.valueConverter.fromJson(s[a.key])}),i}buildAggregateOptions(e){var t,r,i,s,a,o,l;return{groupBy:(t=e==null?void 0:e.group)==null?void 0:t.map(f=>f.key),sum:(r=e==null?void 0:e.sum)==null?void 0:r.map(f=>f.key),avg:(i=e==null?void 0:e.avg)==null?void 0:i.map(f=>f.key),min:(s=e==null?void 0:e.min)==null?void 0:s.map(f=>f.key),max:(a=e==null?void 0:e.max)==null?void 0:a.map(f=>f.key),distinctCount:(o=e==null?void 0:e.distinctCount)==null?void 0:o.map(f=>f.key),orderBy:(l=e==null?void 0:e.orderBy)==null?void 0:l.map(f=>{var d;return{...f,field:(d=f.field)==null?void 0:d.key}})}}translateFromJson(e){let t={};for(const r of this.entity.fields)t[r.key]=r.valueConverter.fromJson(e[r.key]);return t}translateToJson(e){let t={};for(const r of this.entity.fields)t[r.key]=r.valueConverter.toJson(e[r.key]);return t}async count(e){const{run:t}=this.buildFindRequest({where:e});return t("count").then(r=>+r.count)}async deleteMany(e){const{run:t}=this.buildFindRequest({where:e},"delete");return t("deleteMany").then(r=>+r.deleted)}async updateMany(e,t){const{run:r}=this.buildFindRequest({where:e},"put");return r("updateMany",this.toJsonOfIncludedKeys(t)).then(i=>+i.updated)}async upsertMany(e){const{run:t}=this.buildFindRequest(void 0);return t("upsertMany",e.map(r=>({where:this.toJsonOfIncludedKeys(r.where),set:r.set!==void 0?this.toJsonOfIncludedKeys(r.set):void 0}))).then(r=>r.map(i=>this.translateFromJson(i)))}find(e){let{run:t}=this.buildFindRequest(e);return t().then(r=>r.map(i=>this.translateFromJson(i)))}buildFindRequest(e,t){t||(t="get");let r=new Di(this.url()),i;if(e){if(e.where&&(i=e.where.toJson(),ra(i,r)&&(i=void 0)),e.orderBy&&e.orderBy.Segments){let a="",o="",l=!1;e.orderBy.Segments.forEach(f=>{a.length>0&&(a+=",",o+=","),a+=f.field.key,o+=f.isDescending?"desc":"asc",f.isDescending&&(l=!0)}),a&&r.add("_sort",a),l&&r.add("_order",o)}e.limit&&r.add("_limit",e.limit),e.page&&r.add("_page",e.page)}const s=(a,o)=>{let l=new Di(r.url);if(!a&&i&&(a="get"),a&&l.add("__action",a),i){if(t==="put")return this.http().post(l.url,{set:o,where:i});o={...o,where:i}}return o&&t!="put"?this.http().post(l.url,o):this.http()[t](l.url,o)};return{createKey:()=>JSON.stringify({url:r,filterObject:i}),run:s,subscribe:async a=>({result:await s(ia+a),unsubscribe:async()=>R.actionInfo.runActionWithoutBlockingUI(()=>this.http().post(this.url()+"?__action=endLiveQuery",{id:a}))})}}update(e,t){return this.http().put(this.url()+(e!=""?"/"+encodeURIComponent(e):"?__action=emptyId"),this.toJsonOfIncludedKeys(t)).then(r=>this.translateFromJson(r))}toJsonOfIncludedKeys(e){let t={},r=Object.keys(e);for(const i of this.entity.fields)r.includes(i.key)&&(t[i.key]=i.valueConverter.toJson(e[i.key]));return t}async delete(e){if(e=="")await this.deleteMany(q.fromEntityFilter(this.entity,this.entity.idMetadata.getIdFilter(e)));else return this.http().delete(this.url()+"/"+encodeURIComponent(e))}insert(e){return this.http().post(this.url(),this.translateToJson(e)).then(t=>this.translateFromJson(t))}insertMany(e){return this.http().post(this.url(),e.map(t=>this.translateToJson(t))).then(t=>t.map(r=>this.translateFromJson(r)))}}class Mi{constructor(e){u(this,"fetch");this.fetch=e}async get(e){return await mr(async()=>this.myFetch(e).then(t=>t))}put(e,t){return this.myFetch(e,{method:"put",body:JSON.stringify(t)})}delete(e){return this.myFetch(e,{method:"delete"})}async post(e,t){return await mr(()=>this.myFetch(e,{method:"post",body:JSON.stringify(t)}))}myFetch(e,t){const r={};if(t!=null&&t.body&&(r["Content-type"]="application/json"),typeof window<"u"&&typeof window.document<"u"&&typeof(window.document.cookie!=="undefined"))for(const i of window.document.cookie.split(";"))i.trim().startsWith("XSRF-TOKEN=")&&(r["X-XSRF-TOKEN"]=i.split("=")[1]);return(this.fetch||fetch)(e,{credentials:"include",method:t==null?void 0:t.method,body:t==null?void 0:t.body,headers:r}).then(i=>ta(i)).catch(async i=>{throw await i})}}function ta(n){if(n.status!=204){if(n.status>=200&&n.status<300)return n.json();throw n.json().then(e=>({...e,message:e.message||n.statusText,url:n.url,status:n.status})).catch(()=>{throw{message:n.statusText,url:n.url,status:n.status}})}}function ra(n,e){for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)){const r=n[t];if(Array.isArray(r)&&(r.length>0&&typeof r[0]=="object"||r.length>10)||t==="NOT")return!1}for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)){const r=n[t];Array.isArray(r)?t.endsWith(".in")?e.add(t,JSON.stringify(r)):r.forEach(i=>e.add(t,i)):t.startsWith(mt)?e.add(t,JSON.stringify(r)):e.add(t,r)}return!0}const ia="liveQuery-";var ir,na=new Uint8Array(16);function sa(){if(!ir&&(ir=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!ir))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ir(na)}const aa=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function oa(n){return typeof n=="string"&&aa.test(n)}var Ee=[];for(var jr=0;jr<256;++jr)Ee.push((jr+256).toString(16).substr(1));function la(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(Ee[n[e+0]]+Ee[n[e+1]]+Ee[n[e+2]]+Ee[n[e+3]]+"-"+Ee[n[e+4]]+Ee[n[e+5]]+"-"+Ee[n[e+6]]+Ee[n[e+7]]+"-"+Ee[n[e+8]]+Ee[n[e+9]]+"-"+Ee[n[e+10]]+Ee[n[e+11]]+Ee[n[e+12]]+Ee[n[e+13]]+Ee[n[e+14]]+Ee[n[e+15]]).toLowerCase();if(!oa(t))throw TypeError("Stringified UUID is invalid");return t}function Zr(n,e,t){n=n||{};var r=n.random||(n.rng||sa)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,la(r)}class qe{constructor(...e){u(this,"Segments");this.Segments=e}toEntityOrderBy(){let e={};for(const t of this.Segments)t.isDescending?e[t.field.key]="desc":e[t.field.key]="asc";return e}reverse(){let e=new qe;for(const t of this.Segments)e.Segments.push({field:t.field,isDescending:!t.isDescending});return e}compare(e,t,r){r||(r=i=>i.key);for(let i=0;i<this.Segments.length;i++){let s=this.Segments[i],a=e[r(s.field)],o=t[r(s.field)],l=s.isDescending,f=ua(a,o,l);if(f!=0)return f}return 0}static translateOrderByToSort(e,t){let r=new qe;if(t){for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const s=t[i];let a=e.fields.find(i);const o=l=>{switch(s){case"desc":r.Segments.push({field:l,isDescending:!0});break;case"asc":r.Segments.push({field:l})}};if(a){const l=de(a);if((l==null?void 0:l.type)==="toOne"){const f=l.options;if(typeof f.field=="string")o(e.fields.find(f.field));else if(f.fields){for(const d in f.fields)if(Object.prototype.hasOwnProperty.call(f.fields,d)){const c=f.fields[d];o(e.fields.find(c.toString()))}}}else o(a)}}}return r}static createUniqueSort(e,t){(!t||Object.keys(t).length===0)&&e.options.defaultOrderBy&&(t=qe.translateOrderByToSort(e,e.options.defaultOrderBy)),t||(t=new qe);for(const r of e.idMetadata.fields)t.Segments.find(i=>i.field==r)||t.Segments.push({field:r});return t}static createUniqueEntityOrderBy(e,t){(!t||Object.keys(t).length===0)&&(t=e.options.defaultOrderBy),t?t={...t}:t={};for(const r of e.idMetadata.fields)t[r.key]||(t[r.key]="asc");return t}}function ua(n,e,t){n=Ni(n),e=Ni(e);let r=0;return n>e?r=1:n<e&&(r=-1),t&&(r*=-1),r}function Ni(n){return n==null||n==null?n:n.id!==void 0?n.id:n}const Jr="stream";class fa{constructor(e,t,r){u(this,"repo");u(this,"query");u(this,"queryChannel");u(this,"subscribeCode");u(this,"unsubscribe",()=>{});u(this,"defaultQueryState",[]);u(this,"listeners",[]);u(this,"id",Zr());this.repo=e,this.query=t,this.queryChannel=`users:${r}:queries:${this.id}`,this.id=this.queryChannel}sendDefaultState(e){e(this.createReducerType(()=>[...this.defaultQueryState],this.allItemsMessage(this.defaultQueryState)))}async setAllItems(e){const t=await wt(this.repo)._fromJsonArray(e,this.query.options);this.forListeners(r=>{r(()=>t)},this.allItemsMessage(t))}allItemsMessage(e){return[{type:"all",data:e}]}forListeners(e,t){e(r=>{if(this.defaultQueryState=r(this.defaultQueryState),t.find(i=>i.type==="add"||i.type==="replace")&&this.query.options.orderBy){const i=qe.translateOrderByToSort(this.repo.metadata,this.query.options.orderBy);this.defaultQueryState.sort((s,a)=>i.compare(s,a))}});for(const r of this.listeners)e(i=>{r.next(this.createReducerType(i,t))})}createReducerType(e,t){return{applyChanges:e,changes:t,items:this.defaultQueryState}}async handle(e){{let t=e.filter(({type:i})=>i=="add"||i=="replace"),r=await wt(this.repo)._fromJsonArray(t.map(i=>i.data.item),this.query.options);for(let i=0;i<t.length;i++){const s=t[i];s.data.item=r[i]}}this.forListeners(t=>{t(r=>{r||(r=[]);for(const i of e)switch(i.type){case"all":this.setAllItems(i.data);break;case"replace":{r=r.map(s=>this.repo.metadata.idMetadata.getId(s)===i.data.oldId?i.data.item:s);break}case"add":r=r.filter(s=>this.repo.metadata.idMetadata.getId(s)!==this.repo.metadata.idMetadata.getId(i.data.item)),r.push(i.data.item);break;case"remove":r=r.filter(s=>this.repo.metadata.idMetadata.getId(s)!==i.data.id);break}return r})},e)}}const da="_liveQueryKeepAlive";class ca{constructor(e,t){u(this,"apiProvider");u(this,"getUserId");u(this,"queries",new Map);u(this,"channels",new Map);u(this,"client");u(this,"interval");this.apiProvider=e,this.getUserId=t}wrapMessageHandling(e){var t=this.apiProvider().wrapMessageHandling;t?t(e):e()}hasQueriesForTesting(){return this.queries.size>0}runPromise(e){return e}close(){this.queries.clear(),this.channels.clear(),this.closeIfNoListeners()}async subscribeChannel(e,t){let r=()=>{};const i=await this.openIfNoOpened();try{let s=this.channels.get(e);if(!s){this.channels.set(e,s=new ha);try{s.unsubscribe=await i.subscribe(e,a=>this.wrapMessageHandling(()=>s.handle(a)),a=>{t.error(a)})}catch(a){throw t.error(a),a}}s.listeners.push(t),r=()=>{s.listeners.splice(s.listeners.indexOf(t),1),s.listeners.length==0&&(this.channels.delete(e),s.unsubscribe()),this.closeIfNoListeners()}}catch(s){throw t.error(s),s}return()=>{r(),r=()=>{}}}closeIfNoListeners(){this.client&&this.queries.size===0&&this.channels.size===0&&(this.runPromise(this.client.then(e=>e.close())),this.client=void 0,clearInterval(this.interval),this.interval=void 0)}subscribe(e,t,r){let i=!0,s=()=>{i=!1};return this.runPromise(wt(e)._buildEntityDataProviderFindOptions(t).then(a=>{if(!i)return;const{createKey:o,subscribe:l}=new Yr(this.apiProvider).getEntityDataProvider(e.metadata).buildFindRequest(a),f=o();let d=this.queries.get(f);d?d.sendDefaultState(r.next):(this.queries.set(f,d=new fa(e,{entityKey:e.metadata.key,options:t},this.getUserId())),d.subscribeCode=()=>{d.unsubscribe&&(d.unsubscribe(),d.unsubscribe=()=>{}),this.runPromise(this.subscribeChannel(d.queryChannel,{next:c=>this.runPromise(d.handle(c)),complete:()=>{},error:c=>{d.listeners.forEach(h=>h.error(c))}}).then(c=>{if(d.listeners.length==0){c();return}this.runPromise(l(d.queryChannel).then(h=>{if(d.listeners.length===0){h.unsubscribe(),c();return}this.runPromise(d.setAllItems(h.result)),d.unsubscribe=()=>{d.unsubscribe=()=>{},c(),this.runPromise(h.unsubscribe())}}).catch(h=>{d.listeners.forEach(p=>p.error(h)),c(),this.queries.delete(f)}))})).catch(c=>{d.listeners.forEach(h=>h.error(c))})},d.subscribeCode()),d.listeners.push(r),s=()=>{d.listeners.splice(d.listeners.indexOf(r),1),r.complete(),d.listeners.length==0&&(this.queries.delete(f),d.unsubscribe()),this.closeIfNoListeners()}}).catch(a=>{r.error(a)})),()=>{s()}}openIfNoOpened(){return this.client?this.client:(this.interval=setInterval(async()=>{const e=[];for(const t of this.queries.values())e.push(t.queryChannel);if(e.length>0){let t=this.apiProvider();const r=await this.runPromise(await R.actionInfo.runActionWithoutBlockingUI(()=>xt(t.httpClient).post(t.url+"/"+da,e)));for(const i of r)for(const s of this.queries.values())s.queryChannel===i&&s.subscribeCode()}},3e4),this.runPromise(this.client=this.apiProvider().subscriptionClient.openConnection(()=>{for(const e of this.queries.values())e.subscribeCode()})))}}class ha{constructor(){u(this,"unsubscribe",()=>{});u(this,"listeners",[])}async handle(e){for(const t of this.listeners)t.next(e)}}class oi{openConnection(e){let t;const r=new Map,i=xt(De.apiClient.httpClient);let s=!1,a;const o={close(){a.close()},async subscribe(d,c){let h=r.get(d);return h||(r.set(d,h=[]),await f(d)),h.push(c),()=>{h.splice(h.indexOf(c,1)),h.length==0&&(R.actionInfo.runActionWithoutBlockingUI(()=>i.post(De.apiClient.url+"/"+Jr+"/unsubscribe",{channel:d,clientId:t})),r.delete(d))}}},l=()=>new Promise(d=>{h();let c=0;function h(){a&&a.close(),a=oi.createEventSource(De.apiClient.url+"/"+Jr),a.onmessage=p=>{let g=JSON.parse(p.data);const b=r.get(g.channel);b&&b.forEach(w=>w(g.data))},a.onerror=p=>{console.error("Live Query Event Source Error",p),a.close(),c++<vn.error500RetryCount&&setTimeout(()=>{h()},500)},a.addEventListener("connectionId",async p=>{if(t=p.data,s){for(const g of r.keys())await f(g);e()}else s=!0,d(o)})}});return l();async function f(d){await R.actionInfo.runActionWithoutBlockingUI(()=>i.post(De.apiClient.url+"/"+Jr+"/subscribe",{channel:d,clientId:t}))===pa&&await l()}}static createEventSource(e){return new EventSource(e,{withCredentials:!0})}}const pa="client connection not found",ei=Symbol.for("serverActionField");class Gt{constructor(){u(this,"_subscribers")}reportChanged(){this._subscribers&&this._subscribers.forEach(e=>e.reportChanged())}reportObserved(){this._subscribers&&this._subscribers.forEach(e=>e.reportObserved())}subscribe(e){let t;return typeof e=="function"?t={reportChanged:()=>e(),reportObserved:()=>{}}:t=e,this._subscribers||(this._subscribers=[]),this._subscribers.push(t),()=>this._subscribers=this._subscribers.filter(r=>r!=t)}}class ya{constructor(e){u(this,"remultObjectStorage");this.remultObjectStorage=e}static enable(){R.remultFactory=()=>{const e=R.asyncContext.getStore();if(e)return e.remult;throw new Error("remult object was requested outside of a valid request cycle.valid context, try running `withRemult` or run within initApi or a remult request cycle")}}static disable(){Hs()}async run(e,t){return this.remultObjectStorage?this.remultObjectStorage.run({remult:e},()=>t(e)):t(e)}isInInitRequest(){var e,t;return(t=(e=this.remultObjectStorage)==null?void 0:e.getStore())==null?void 0:t.inInitRequest}setInInitRequest(e){var r,i;const t=(r=this.remultObjectStorage)==null?void 0:r.getStore();t&&(e||(i=this.remultObjectStorage)!=null&&i.isStub)&&(t.inInitRequest=e)}getStore(){if(!this.remultObjectStorage)throw new Error("can't use static remult in this environment, `async_hooks` were not initialized");return this.remultObjectStorage.getStore()}}R.asyncContext||(R.asyncContext=new ya(void 0));function Yt(){return R.actionInfo.runningOnServer||!De.dataProvider.isProxy}class Ke{constructor(e){u(this,"repo",(e,t)=>{t===void 0&&(t=this.dataProvider);let r=this.repCache.get(t);r||this.repCache.set(t,r=new Map);let i=r.get(e);return i||(r.set(e,i=new li(e,this,t,Ca(e,this))),Bs(i,this,t)),i});u(this,"_subscribers");u(this,"__user");u(this,"dataProvider",new Yr(()=>this.apiClient));u(this,"repCache",new Map);u(this,"liveQueryStorage");u(this,"subscriptionServer");u(this,"liveQueryPublisher",{itemChanged:async()=>{}});u(this,"liveQuerySubscriber",new ca(()=>this.apiClient,()=>{var e;return(e=this.user)==null?void 0:e.id}));u(this,"context",{});u(this,"apiClient",{url:"/api",subscriptionClient:new oi});if(e&&e.getEntityDataProvider){this.dataProvider=e;return}if(bn(e))this.apiClient.httpClient=e;else if(typeof e=="function")this.apiClient.httpClient=e;else if(e){const t=e;t.httpClient&&(this.apiClient.httpClient=t.httpClient),t.url&&(this.apiClient.url=t.url),t.subscriptionClient&&(this.apiClient.subscriptionClient=t.subscriptionClient),t.wrapMessageHandling&&(this.apiClient.wrapMessageHandling=t.wrapMessageHandling)}}subscribeAuth(e){return this._subscribers||(this._subscribers=new Gt),this._subscribers.subscribe(e)}get user(){var e;return(e=this._subscribers)==null||e.reportObserved(),this.__user}set user(e){var t;this.__user=e,(t=this._subscribers)==null||t.reportChanged()}async initUser(){const t=await xt(this.apiClient.httpClient).get(_n(this.apiClient.url,"me"));return this.user=(t==null?void 0:t.id)!=null?t:void 0,this.user}authenticated(){var e;return((e=this.user)==null?void 0:e.id)!==void 0}isAllowed(e){var t,r;if(e!=null){if(e instanceof Array){for(const i of e)if(this.isAllowed(i)===!0)return!0;return!1}return typeof e=="function"?e(this):typeof e=="boolean"?e:!!(typeof e=="string"&&(r=(t=this.user)==null?void 0:t.roles)!=null&&r.includes(e.toString()))}}isAllowedForInstance(e,t){if(Array.isArray(t)){for(const r of t)if(this.isAllowedForInstance(e,r))return!0}else return typeof t=="function"?t(e,this):this.isAllowed(t)}useFetch(e){this.dataProvider=new Yr(()=>({httpClient:e}))}call(e,t,...r){const i=e[ei];if(!i.doWork)throw Error("The method received is not a valid backend method");return i.doWork(r,t,this.apiClient.url,xt(this.apiClient.httpClient))}clearAllCache(){this.repCache.clear()}}u(Ke,"onFind",(e,t)=>{}),u(Ke,"entityRefInit");R.defaultRemultFactory=()=>new Ke;class In{constructor(){u(this,"classes",new Map)}}function ga(n,e){let t=n;for(;;){let r=R.classHelpers.get(t);r||R.classHelpers.set(t,r=new In),r.classes.set(n,e);let i=Object.getPrototypeOf(t.prototype);if(i==null)break;t=i.constructor}}const ma={defaultPageSize:200};async function wa(n,e){const t=new va(n.liveQueryPublisher);let r=!0;const i=n.dataProvider;try{await n.dataProvider.transaction(async s=>{n.dataProvider=s,n.liveQueryPublisher=t,await e(s),r=!0}),r&&await t.flush()}finally{n.dataProvider=i}}class va{constructor(e){u(this,"orig");u(this,"transactionItems",new Map);this.orig=e}async itemChanged(e,t){let r=this.transactionItems.get(e);r||this.transactionItems.set(e,r=[]);for(const i of t)if(i.oldId!==void 0){const s=r.find(a=>a.id===i.oldId);s!==void 0?(i.deleted&&(s.deleted=!0),i.id!=s.id&&(s.id=i.id)):r.push(i)}else r.push(i)}async flush(){for(const e of this.transactionItems.keys())await this.orig.itemChanged(e,this.transactionItems.get(e))}}function Qt(n,e){return e&&Object.assign(n,e),n}class On extends Error{constructor(t){super(t.message);u(this,"modelState");u(this,"stack");u(this,"exception");u(this,"httpStatusCode");Object.assign(this,t)}}class tt{}u(tt,"number","number"),u(tt,"date","date"),u(tt,"checkbox","checkbox"),u(tt,"password","password"),u(tt,"email","email"),u(tt,"tel","tel"),u(tt,"time","time");const K=class K{};u(K,"Date",{toJson:e=>{if(e===null)return null;if(!e)return"";if(typeof e=="string"&&(e=new Date(e)),e instanceof Date)return e.toISOString();throw new Error("Expected date but got "+e)},fromJson:e=>{if(e===null)return null;if(e!=null&&e!=""&&!e.startsWith("0000-00-00"))return new Date(Date.parse(e))},toDb:e=>e,fromDb:e=>{if(typeof e=="number"&&(e=new Date(e)),typeof e=="string"&&(e=new Date(e)),e&&!(e instanceof Date))throw"expected date but got "+e;return e},fromInput:e=>K.Date.fromJson(e),toInput:e=>K.Date.toJson(e),displayValue:e=>e?e.toLocaleString():""}),u(K,"DateOnly",{fromInput:e=>K.DateOnly.fromJson(e),toInput:e=>K.DateOnly.toJson(e),toJson:e=>{var t=e;return(typeof t=="string"||typeof t=="number")&&(t=new Date(t)),!t||t==null?null:t.getHours()==0?new Date(t.valueOf()-t.getTimezoneOffset()*6e4).toISOString().substring(0,10):t.toISOString().substring(0,10)},fromJson:e=>{if(!e||e==""||e=="0000-00-00")return null;let t=new Date(Date.parse(e));return t.setMinutes(t.getMinutes()+t.getTimezoneOffset()),t},inputType:tt.date,toDb:e=>e?K.DateOnly.fromJson(K.DateOnly.toJson(e)):null,fromDb:e=>K.Date.fromDb(e),fieldTypeInDb:"date",displayValue:e=>e?e.toLocaleDateString(void 0):""}),u(K,"DateOnlyString",{...K.DateOnly,toDb:e=>{let t=K.DateOnly.toJson(e);if(t)return t.replace(/-/g,"")},fromDb:e=>{if(e===null)return null;if(e)return new Date(e.substring(0,4)+"-"+e.substring(4,6)+"-"+e.substring(6,8))}}),u(K,"Boolean",{toDb:e=>e,inputType:tt.checkbox,fromDb:e=>K.Boolean.fromJson(e),fromJson:e=>typeof e=="boolean"?e:e===1?!0:e!=null?e.toString().trim().toLowerCase()=="true":e,toJson:e=>e,fromInput:e=>K.Boolean.fromJson(e),toInput:e=>K.Boolean.toJson(e)}),u(K,"Number",{fromDb:e=>{if(e===null)return null;if(e!==void 0)return+e},toDb:e=>e,fromJson:e=>K.Number.fromDb(e),toJson:e=>K.Number.toDb(e),fromInput:(e,t)=>{let r=+e;if(e===null)return null;if(e!==void 0)return r},toInput:(e,t)=>(e==null?void 0:e.toString())??"",inputType:tt.number}),u(K,"String",{fromDb:St,toDb:St,fromJson:St,toJson:St,fromInput:St,toInput:St}),u(K,"Integer",{...K.Number,toJson:e=>{let t=K.Number.toDb(e);return t&&+(+t).toFixed(0)},toDb:e=>K.Integer.toJson(e),fieldTypeInDb:"integer"}),u(K,"Default",{fromJson:e=>e,toJson:e=>e,fromDb:e=>K.JsonString.fromDb(e),toDb:e=>K.JsonString.toDb(e),fromInput:e=>K.Default.fromJson(e),toInput:e=>K.Default.toJson(e),displayValue:e=>e+"",fieldTypeInDb:"",inputType:"text"}),u(K,"JsonString",{fromJson:e=>e,toJson:e=>e,fromDb:e=>e==null?null:e?JSON.parse(K.JsonString.fromJson(e)):void 0,toDb:e=>e!==void 0?e===null?null:JSON.stringify(K.JsonString.toJson(e)):void 0,fromInput:e=>K.JsonString.fromJson(e),toInput:e=>K.JsonString.toJson(e)}),u(K,"JsonValue",{fromJson:e=>e,toJson:e=>e,fromDb:e=>e,toDb:e=>e,fromInput:e=>K.JsonString.fromJson(e),toInput:e=>K.JsonString.toJson(e),fieldTypeInDb:"json"});let Pe=K;function St(n){return n==null?n:typeof n!="string"?n.toString():n}function Ur(n,e,t){let r=q.fromEntityFilter(n,e);const i=()=>{};r&&r.__applyToConsumer({custom:i,databaseCustom:i,containsCaseInsensitive:i,notContainsCaseInsensitive:i,startsWithCaseInsensitive:i,endsWithCaseInsensitive:i,isDifferentFrom:i,isEqualTo:(s,a)=>{t[s.key]=a},isGreaterOrEqualTo:i,isGreaterThan:i,isIn:i,isLessOrEqualTo:i,isLessThan:i,isNotNull:i,isNull:i,not:i,or:i})}class zt{constructor(){u(this,"entityLoaders",new Map);u(this,"promises",[])}load(e,t){let r=this.entityLoaders.get(e.entityType);r||this.entityLoaders.set(e.entityType,r=new ba(e));const i=r.find(t);return this.promises.push(i),i}async resolveAll(){for(const t of this.entityLoaders.values())for(const r of t.queries.values())r.resolve();if(this.promises.length===0)return;const e=this.promises;this.promises=[],await Promise.all(e),await this.resolveAll()}}class ba{constructor(e){u(this,"rel");u(this,"queries",new Map);this.rel=e}find(e){const{where:t,...r}=ai(e,this.rel.metadata),i=JSON.stringify(r);let s=this.queries.get(i);return s||this.queries.set(i,s=new _a(this.rel)),s.find(e,t)}}class _a{constructor(e){u(this,"rel");u(this,"pendingInStatements",new Map);u(this,"whereVariations",new Map);this.rel=e}find(e,t){const r=JSON.stringify(t);let i=this.whereVariations.get(r);if(!i){const s=Object.keys(t);if(s.length===1&&typeof t[s[0]]!="object"&&!e.limit){let a=this.pendingInStatements.get(s[0]);a||this.pendingInStatements.set(s[0],a=new Ia(this.rel,s[0],e)),this.whereVariations.set(r,i={result:a.find(t)})}else this.whereVariations.set(r,i={result:this.rel.find(e)})}return i.result}resolve(){const e=[...this.pendingInStatements.values()];this.pendingInStatements.clear();for(const t of e)t.resolve()}}class Ia{constructor(e,t,r){u(this,"rel");u(this,"key");u(this,"options");u(this,"values",new Map);this.rel=e,this.key=t,this.options=r}async resolve(){const e=[...this.values.values()];if(e.length==1){this.rel.find(this.options).then(e[0].resolve,e[0].reject);return}var t={...this.options};t.where={[this.key]:e.map(i=>i.value)},t.limit=1e3,t.page=1;let r=[];try{for(;;){const i=await this.rel.find(t);if(r.push(...i),i.length<t.limit)break;t.page++}for(const i of this.values.values())i.resolve(r.filter(s=>{const o=ue(s).fields.find(this.key),l=de(o.metadata),f=(l==null?void 0:l.type)==="reference"?o.getId():s[this.key];return i.value==f}))}catch(i){for(const s of this.values.values())s.reject(i)}}find(e){const t=e[this.key];let r=this.values.get(t);if(!r){let i,s,a=new Promise((o,l)=>{i=o,s=l});this.values.set(t,r={value:t,resolve:i,reject:s,result:a})}return r.result}}R.actionInfo;const Ie=class Ie{};u(Ie,"required",Kt(async(e,t)=>!t.valueIsNull()&&t.value!==""&&(t.value!==void 0||de(t.metadata)!==void 0),"Should not be empty")),u(Ie,"unique",Kt(async(e,t)=>{if(!t.entityRef)throw"unique validation may only work on columns that are attached to an entity";return t.isBackend()&&(t.isNew||t.valueChanged())?await t.entityRef.repository.count({[t.metadata.key]:t.value})==0:!0},"already exists")),u(Ie,"uniqueOnBackend",Kt(async(e,t)=>t.isBackend()&&(t.isNew||t.valueChanged())?await t.entityRef.repository.count({[t.metadata.key]:t.value})==0:!0,Ie.unique.defaultMessage)),u(Ie,"regex",ft((e,t)=>t.test(e))),u(Ie,"email",lr(e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),"Invalid Email")),u(Ie,"url",lr(e=>!!new URL(e),"Invalid Url")),u(Ie,"in",ft((e,t)=>t.includes(e),e=>`Value must be one of: ${e.map(t=>typeof t=="object"?(t==null?void 0:t.id)!==void 0?t==null?void 0:t.id:t==null?void 0:t.toString():t).join(", ")}`)),u(Ie,"notNull",lr(e=>e!=null,"Should not be null")),u(Ie,"enum",ft((e,t)=>Object.values(t).includes(e),e=>`Value must be one of ${ur(e).join(", ")}`)),u(Ie,"relationExists",Kt(async(e,t)=>t.valueIsNull()||!t.isBackend()?!0:!!await t.load(),"Relation value does not exist")),u(Ie,"min",ft((e,t)=>e>=t,e=>`Value must be bigger than or equal to ${e}`)),u(Ie,"max",ft((e,t)=>e<=t,e=>`Value must be smaller than or equal to ${e}`)),u(Ie,"maxLength",ft((e,t)=>e.length<=t,e=>`Value must be at most ${e} characters`)),u(Ie,"minLength",ft((e,t)=>e.length>=t,e=>`Value must be at least ${e} characters`)),u(Ie,"range",ft((e,[t,r])=>e>=t&&e<=r,([e,t])=>`Value must be between ${e} and ${t}`)),u(Ie,"defaultMessage","Invalid value");let He=Ie;function Kt(n,e){const t=async(i,s,a)=>{const o=await n(i,s);typeof o=="string"&&o.length>0?s.error=o:o||(s.error=typeof a=="function"&&a(i,s,void 0)||a||typeof e=="function"&&e(i,s,void 0)||e||He.defaultMessage)},r=(i,s,a)=>typeof i=="string"||i==="function"||i===void 0&&s===void 0?async(o,l,f)=>await t(o,l,i||f):t(i,s,a);return Object.defineProperty(r,"defaultMessage",{get:()=>e,set:i=>{e=i},enumerable:!0}),Object.assign(r,{withMessage:i=>async(s,a)=>r(s,a,i)})}function lr(n,e){return Kt((t,r)=>r.value===void 0||r.value===null?!0:n(r.value),e)}function ft(n,e){const t=Oa((r,i,s)=>i.value===void 0||i.value===null?!0:n(i.value,s),(r,i,s)=>typeof e=="function"&&e(s)||e,!0);return Object.assign((r,i)=>t(r,i),{get defaultMessage(){return e},set defaultMessage(r){e=r}})}function Oa(n,e,t=!1){return Object.assign((i,s)=>async(a,o)=>{const l=await n(a,o,i);typeof l=="string"?o.error=l:l||(o.error=s?typeof s=="function"?t?s(i):s(a,o,i):s:e?typeof e=="function"?e(a,o,i):e:He.defaultMessage)},{get defaultMessage(){return e},set defaultMessage(i){e=i}})}function ur(n){return Object.values(n).filter(e=>typeof n[e]!="number")}function fr(n,e,t=!1){if(!e)return n;const r=Array.isArray(e)?e:[e],i=Array.isArray(n)?n:n?[n]:[];return t?[...r,...i]:[...i,...r]}function Mt(n,e){return typeof n[e]<"u"}class ka{constructor(e,t){u(this,"options");u(this,"repo");u(this,"_count");u(this,"_aggregates");this.options=e,this.repo=t,this.options||(this.options={}),this.options.pageSize||(this.options.pageSize=ma.defaultPageSize)}async getPage(e){return(e??0)<1&&(e=1),this.repo.find({where:this.options.where,orderBy:this.options.orderBy,limit:this.options.pageSize,page:e,load:this.options.load,include:this.options.include})}async count(){return this._count===void 0&&(this._count=await this.repo.count(this.options.where)),this._count}async forEach(e){let t=0;for await(const r of this)await e(r),t++;return t}async paginator(e){this.options.orderBy=qe.createUniqueEntityOrderBy(this.repo.metadata,this.options.orderBy);let t={where:{$and:[this.options.where,e]},orderBy:this.options.orderBy,limit:this.options.pageSize,load:this.options.load,include:this.options.include},r=()=>this.repo.find(t);if(this._aggregates===void 0&&Mt(this.options,"aggregate")){let o=this.options.aggregate;if(this.repo._dataProvider.isProxy){const l=new zt;r=()=>this.repo._rawFind(t,!1,l,async f=>{const d=await this.repo._edp.query(f,await this.repo.__buildGroupByOptions(o));return this._aggregates=d.aggregates,d.items}).then(async f=>(await l.resolveAll(),f))}else{let l=r();r=async()=>(this._aggregates=await this.repo.aggregate({...o,where:this.options.where}),this._count=this._aggregates.$count,l)}}let i=await r(),s=()=>{throw new Error("no more pages")},a=i.length==this.options.pageSize;if(a){let o=await this.repo._createAfterFilter(this.options.orderBy,i[i.length-1]);s=()=>this.paginator(o)}return{count:()=>this.count(),hasNextPage:a,items:i,nextPage:s,aggregates:this._aggregates}}[Symbol.asyncIterator](){this.options.where||(this.options.where={});let e=this.options.orderBy;this.options.orderBy=qe.createUniqueEntityOrderBy(this.repo.metadata,e);let t=-1,r,i,s=0;return i=async()=>{if(this.options.progress&&this.options.progress.progress(s++/await this.count()),r===void 0||t==r.items.length){if(r&&!r.hasNextPage)return{value:void 0,done:!0};let a=r;if(r?r=await r.nextPage():r=await this.paginator(),t=0,r.items.length==0)return{value:void 0,done:!0};if(((a==null?void 0:a.items.length)??!1)&&this.repo.getEntityRef(a.items[0]).getId()==this.repo.getEntityRef(r.items[0]).getId())throw new Error("pagination failure, returned same first row")}return t<r.items.length?{value:r.items[t++],done:!1}:{done:!0,value:void 0}},{next:async()=>i()}}}class li{constructor(e,t,r,i,s){u(this,"_entity");u(this,"_remult");u(this,"_dataProvider");u(this,"_info");u(this,"_defaultFindOptions");u(this,"__edp");u(this,"_idCache",new Map);u(this,"listeners");u(this,"_cache",new Map);this._entity=e,this._remult=t,this._dataProvider=r,this._info=i,this._defaultFindOptions=s}_notFoundError(e){return{message:`id ${e} not found in entity ${this.metadata.key}`,httpStatusCode:404}}[Xt](){return this}async _createAfterFilter(e,t){let r=new Map;for(const a of qe.translateOrderByToSort(this.metadata,e).Segments){let o=t[a.field.key];r.set(a.field.key,o)}let i={$or:[]},s=[];for(const a of qe.translateOrderByToSort(this.metadata,e).Segments){let o={};for(const l of s)o[l.key]=r.get(l.key);s.push(a.field),a.isDescending?o[a.field.key]={$lt:r.get(a.field.key)}:o[a.field.key]={$gt:r.get(a.field.key)},i.$or.push(o)}return i}relations(e){return new Proxy({},{get:(t,r)=>{const i=this.fields.find(r),s=de(i);if(!s)throw Error(r+" is not a relation");const{toRepo:a,returnNull:o,returnUndefined:l}=this._getFocusedRelationRepo(i,e);return s.type==="toMany"?a:{findOne:f=>o?Promise.resolve(null):l?Promise.resolve(void 0):a.findFirst({},f)}}})}_getFocusedRelationRepo(e,t){const r=de(e);let i=r.toRepo,{findOptions:s,returnNull:a,returnUndefined:o}=this._findOptionsBasedOnRelation(r,e,void 0,t,i);return{toRepo:new li(i._entity,i._remult,i._dataProvider,i._info,s),returnNull:a,returnUndefined:o}}get _edp(){return this.__edp?this.__edp:this.__edp=this._dataProvider.getEntityDataProvider(this.metadata)}async aggregate(e){return(await this.groupBy(e))[0]}async groupBy(e){var t=await this.__buildGroupByOptions(e);const r=await this._edp.groupBy(t);if(!(e!=null&&e[zs])&&e.group){const i={include:{}};for(const a of e.group)i.include[a]=!0;const s=new zt;await this._populateRelationsForFields(t.group,i,r,s),await s.resolveAll()}return r}async __buildGroupByOptions(e){var a,o,l,f,d,c;let t=await this._buildEntityDataProviderFindOptions({...e});const r=h=>{const p=this.metadata.fields.find(h);if(p===void 0)throw Error(`key "${h}" not found in entity`);return p},i=h=>{var p;if((p=e==null?void 0:e.group)!=null&&p.includes(h))throw Error(`field "${h}" cannot be used both in an aggregate and in group by`);return r(h)};var s={where:t.where,limit:t.limit,page:t.page,group:(a=e==null?void 0:e.group)==null?void 0:a.map(r),sum:(o=e==null?void 0:e.sum)==null?void 0:o.map(i),avg:(l=e==null?void 0:e.avg)==null?void 0:l.map(i),min:(f=e==null?void 0:e.min)==null?void 0:f.map(i),max:(d=e==null?void 0:e.max)==null?void 0:d.map(i),distinctCount:(c=e==null?void 0:e.distinctCount)==null?void 0:c.map(i)};if(e!=null&&e.orderBy){s.orderBy=[];for(const h in e.orderBy)if(Object.prototype.hasOwnProperty.call(e==null?void 0:e.orderBy,h)){const p=e.orderBy[h];if(p){if(typeof p=="string")s.orderBy.push({field:h==="$count"?void 0:r(h),isDescending:p==="desc",operation:h==="$count"?"count":void 0});else for(const g in p)if(Object.prototype.hasOwnProperty.call(p,g)){const b=p[g];s.orderBy.push({field:this.metadata.fields.find(h),isDescending:b==="desc",operation:g})}}}}return s}_getCachedById(e,t){e=e+"",this._getCachedByIdAsync(e,t);let r=this._idCache.get(e);if(!(r instanceof Promise))return r}async _getCachedByIdAsync(e,t){e=e+"";let r=this._idCache.get(e);if(r instanceof Promise)return await r;if(this._idCache.has(e))return r;if(t)return;this._idCache.set(e,void 0);let i=this.findId(e).then(s=>(s===void 0?r=null:r=s,this._idCache.set(e,r),r));return this._idCache.set(e,i),await i}_addToCache(e){e&&this._idCache.set(this.getEntityRef(e).getId()+"",e)}get metadata(){return this._info}addEventListener(e){return this.listeners||(this.listeners=[]),this.listeners.push(e),()=>{this.listeners.splice(this.listeners.indexOf(e),1)}}query(e){return new ka(e,this)}getEntityRef(e){let t=e[yt];return t||(this._fixTypes(e),t=new nr(this._info,e,this,this._edp,this._remult,!0),Object.defineProperty(e,yt,{get:()=>t}),t.saveOriginalData()),t}async delete(e){const t=ue(e,!1);if(t)return t.delete();if(typeof e=="string"||typeof e=="number"){if(this._dataProvider.isProxy)return this._edp.delete(e);{let i=await this.findId(e);if(!i)throw this._notFoundError(e);return await ue(i).delete()}}let r=this._getRefForExistingRow(e,void 0);return this._dataProvider.isProxy||await r.reload(),r.delete()}__cleanupPartialObject(e){const t=Object.keys(e);for(let r=0;r<t.length;r++){const i=t[r],s=this.fields[i];if(s){const a=de(s);a&&a.type==="toOne"&&a.options.field&&t.indexOf(a.options.field)>r&&a.toRepo.getEntityRef(e[i]).getId()!==e[a.options.field]&&delete e[i]}}for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r],de(this.fields[r]));for(const r of this.fields);}async insert(e){if(Array.isArray(e))if(this._dataProvider.isProxy){let t=[],r=[];for(const i of e){this.__cleanupPartialObject(i);let s=ue(e,!1);if(s){if(!s.isNew())throw"Item is not new"}else s=await this.getEntityRef(this.create(i));t.push(s),r.push(await s.buildDtoForInsert())}return $t(await this._edp.insertMany(r),(i,s)=>t[s].processInsertResponseDto(i))}else{let t=[];for(const r of e)t.push(await this.insert(r));return t}else{let t=ue(e,!1);if(t){if(!t.isNew())throw"Item is not new";return await t.save()}else return this.__cleanupPartialObject(e),await this.getEntityRef(this.create(e)).save()}}get fields(){return this.metadata.fields}async validate(e,...t){{let r=ue(e,!1);if(r||(r=this.getEntityRef({...e})),!t||t.length===0)return await r.validate();{r.__clearErrorsAndReportChanged();let i=!1;for(const s of t)await r.fields.find(s).validate()||(i=!0);return i?r.buildErrorInfoObject():void 0}}}__createDto(e){this.__cleanupPartialObject(e);const r=this.getEntityRef({...e}).copyDataToObject(!1),i=Object.keys(e);for(const s of this.fields)(s.dbReadOnly||!i.includes(s.key))&&delete r[s.key];return r}async updateMany({where:e,set:t}){if(this.__cleanupPartialObject(t),q.throwErrorIfFilterIsEmpty(e,"updateMany"),this._dataProvider.isProxy)return this._edp.updateMany(await this._translateWhereToFilter(e),this.__createDto({...t}));{let r=0;for await(const i of this.query({where:e,aggregate:void 0}))Qt(i,t),await ue(i).save(),r++;return r}}async update(e,t){{let i=ue(t,!1);if(i)return await i.save()}{let i=ue(e,!1);if(i)return Qt(e,t),i.save()}this.__cleanupPartialObject(t);let r;if(typeof e=="object"?(r=this._getRefForExistingRow(e,this.metadata.idMetadata.getId(e)),Object.assign(r.instance,t)):r=this._getRefForExistingRow(t,e),this._dataProvider.isProxy)return await r.save(Object.keys(t));{const i=await r.reload();if(!i)throw this._notFoundError(r.id);for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){let a=r.fields[s];if(t[s]===void 0&&de(a.metadata))continue;a&&(i[s]=t[s])}return await this._fixTypes(i),await r.save()}}async upsert(e){if(this._dataProvider.isProxy){let s=await this._edp.upsertMany((Array.isArray(e)?e:[e]).map(l=>{var f;return(f=this._defaultFindOptions)!=null&&f.where&&(Ur(this.metadata,this._defaultFindOptions.where,l.where),this._fixTypes(l)),{where:this.__createDto(l.where),set:l.set?this.__createDto(l.set):void 0}}));const a=new zt,o=await this._loadManyToOneForManyRows(s,{},a);return await a.resolveAll(),Array.isArray(e)?o:o[0]}if(Array.isArray(e))return $t(e,s=>this.upsert(s));let t=e;var r=await this.findFirst(t.where,{createIfNotFound:!0}),i=ue(r,!1);return i.isNew()?(t.set&&Qt(r,t.set),await i.save()):t.set?(Qt(r,t.set),await i.save()):r}_getRefForExistingRow(e,t){let r=ue(e,!1);if(!r){const i=new this._entity(this._remult);for(const a of this._fieldsOf(e)){const o=a.key;i[o]=e[o]}this._fixTypes(i);let s=new nr(this._info,i,this,this._edp,this._remult,!1);typeof t=="object"&&(t=this.metadata.idMetadata.getId(t)),t?(s.id=t,s.originalId=t):s.id=s.getId(),r=s,Object.defineProperty(i,yt,{get:()=>s})}return r}async save(e){if(Array.isArray(e))return $t(e,t=>this.save(t));{let t=ue(e,!1);if(t)return await t.save();if(e instanceof Sn)return await this.getEntityRef(e).save();{let r=this.metadata.idMetadata.getId(e);return r===void 0?this.insert(e):this.update(r,e)}}}liveQuery(e){return e||(e={}),{subscribe:t=>{let r=t;return typeof t=="function"&&(r={next:t,complete:()=>{},error:()=>{}}),r.error??(r.error=()=>{}),r.complete??(r.complete=()=>{}),this._remult.liveQuerySubscriber.subscribe(this,e,r)}}}async _rawFind(e,t=!1,r,i){e||(e={}),this._defaultFindOptions&&(e={...this._defaultFindOptions,...e});let s=await this._buildEntityDataProviderFindOptions(e);t&&(delete s.orderBy,delete s.limit),Ke.onFind(this._info,e);const a=await i(s);return await this._loadManyToOneForManyRows(a,e,r)}async find(e,t=!1){const r=new zt,i=await this._rawFind(e,t,r,s=>this._edp.find(s));return await r.resolveAll(),i}async _buildEntityDataProviderFindOptions(e){e={...e};let t={};return t={},(!e.orderBy||Object.keys(e.orderBy).length===0)&&(this._dataProvider.isProxy||(e.orderBy=this._info.entityInfo.defaultOrderBy)),t.where=await this._translateWhereToFilter(e.where),e.orderBy!==void 0&&(t.orderBy=qe.translateOrderByToSort(this.metadata,e.orderBy)),e.limit!==void 0&&(t.limit=e.limit),e.page!==void 0&&(t.page=e.page),t}async _fromJsonArray(e,t){const r=new zt,i=await this._loadManyToOneForManyRows(e.map(s=>{let a={};for(const o of this.metadata.fields.toArray())a[o.key]=o.valueConverter.fromJson(s[o.key]);return a}),t,r);return await r.resolveAll(),i}async _loadManyToOneForManyRows(e,t,r){let i;t!=null&&t.load&&(i=t.load(this.metadata.fields));for(const f of this.metadata.fields)if(Be(f.valueType,!1)&&!de(f)){let h=!f.options.lazy;if(i!==void 0&&(h=i.includes(f)),h){let p=this._remult.repo(f.valueType),g=[];for(const b of e){let w=b[f.key];w!=null&&!g.includes(w)&&!p._idCache.has(w+"")&&g.push(w)}g.length>0&&await s(p,g)}}async function s(f,d){let c=await f.find({where:f.metadata.idMetadata.getIdFilter(...d)},!0);for(const h of c)f._addToCache(h)}const a=new Set(this.fields.toArray().map(f=>{const d=this.__getRelationAndInclude(f,t);if(d.rel&&!d.incl)return f.key}).filter(f=>f!==void 0));let o=await $t(e,async f=>await this._mapRawDataToResult(f,i,a));const l=this.metadata.fields.toArray();return this._populateRelationsForFields(l,t,o,r),o}_populateRelationsForFields(e,t,r,i){for(const s of e){let{rel:a,incl:o}=this.__getRelationAndInclude(s,t);if(a)if(o){const l=a.toRepo;for(const f of r){let{findOptions:d,returnNull:c}=this._findOptionsBasedOnRelation(a,s,o,f,l);const h=s.key;if(c)f[h]=null;else{const p=a.toEntity,g=l;i.load({entityType:p,find:b=>g._rawFind(b,!1,i,w=>g._edp.find(w)),metadata:g.metadata},d).then(b=>{b.length==0&&a.type=="toOne"||(f[h]=a.type!=="toMany"?b.length==0?null:b[0]:b)})}}}else for(const l of r)Reflect.deleteProperty(l,s.key)}}__getRelationAndInclude(e,t){var a;let r=de(e),i=e.options.defaultIncluded;const s=(a=t==null?void 0:t.include)==null?void 0:a[e.key];return s!==void 0&&(i=s),{rel:r,incl:i}}_findOptionsBasedOnRelation(e,t,r,i,s){let a=!1,o=!1,l=[],f={},d=[];typeof e.options.findOptions=="function"?d.push(e.options.findOptions(i)):typeof e.options.findOptions=="object"&&d.push(e.options.findOptions),typeof r=="object"&&d.push(r);for(const p of d){p.where&&l.push(p.where);for(const g of["limit","include","orderBy"])p[g]&&(f[g]=p[g])}const c=e.getFields(),h=p=>{const g=ue(i,!1);let b=e.type==="reference"&&g?g.fields.find(t.key).getId():i[p];return(e.type==="toOne"||e.type==="reference")&&(b===null?a=!0:b===void 0?o=!0:e.type==="reference"&&typeof b=="object"&&(b=s.metadata.idMetadata.getId(b))),b};c.compoundIdField&&(e.type==="toMany"?l.push({[c.compoundIdField]:this.metadata.idMetadata.getId(i)}):l.push(s.metadata.idMetadata.getIdFilter(h(c.compoundIdField))));for(const p in c.fields)Object.prototype.hasOwnProperty.call(c.fields,p)&&l.push({[p]:h(c.fields[p])});return f.where={$and:l},(e.type==="toOne"||e.type==="reference")&&f.orderBy&&(f.limit=1),{findOptions:f,returnNull:a,returnUndefined:o}}async _mapRawDataToResult(e,t,r){let i=new this._entity(this._remult),s=new nr(this._info,i,this,this._edp,this._remult,!1,r);return Object.defineProperty(i,yt,{get:()=>s}),await s.loadDataFrom(e,t),s.saveOriginalData(),i}toJson(e){return e==null?e:Array.isArray(e)?e.map(t=>this.toJson(t)):typeof e.then=="function"?e.then(t=>this.toJson(t)):this.getEntityRef(e).toApiJson(!0)}fromJson(e,t){if(e==null)return e;if(Array.isArray(e))return e.map(i=>this.fromJson(i,t));let r=new this._entity(this._remult);for(const i of this._fieldsOf(e)){const s=i.key;if(Be(i.valueType,!1)){let o=e[i.key];typeof o=="string"||typeof o=="number"?r[s]=o:r[s]=this._remult.repo(i.valueType).fromJson(o)}else e[s]!==void 0&&(r[s]=i.valueConverter.fromJson(e[i.key]))}if(this._fixTypes(r),t)return this.create(r);{let i=new nr(this._info,r,this,this._edp,this._remult,!1);return Object.defineProperty(r,yt,{get:()=>i}),i.id=i.getId(),i.saveOriginalData(),i.originalId=i.id,r}}async count(e){return this._edp.count(await this._translateWhereToFilter(e))}async deleteMany({where:e}){if(q.throwErrorIfFilterIsEmpty(e,"deleteMany"),this._dataProvider.isProxy)return this._edp.deleteMany(await this._translateWhereToFilter(e));{let t=0;for await(const r of this.query({where:e,aggregate:void 0}))await ue(r).delete(),t++;return t}}async findOne(e,t=!1){let r,i,s=e??{};if(s.useCache){let a=ai(s,this.metadata),o=JSON.stringify(a);if(i=this._cache.get(o),i!==void 0)if(i.value&&this.getEntityRef(i.value).wasDeleted())i=void 0,this._cache.delete(o);else return i.promise;else i={value:void 0,promise:void 0},this._cache.set(o,i)}return r=this.find({...s,limit:1},t).then(async a=>{let o;return a.length>0&&(o=a[0]),!o&&s.createIfNotFound&&(o=this.create(),s.where&&await Ur(this.metadata,s.where,o)),o}),i&&(i.promise=r=r.then(a=>(i.value=a,a))),r}async findFirst(e,t,r=!1){if(t||(t={}),e)if(t.where){let i=t.where;t.where={$and:[i,e]}}else t.where=e;return this.findOne(t,r)}_fieldsOf(e){let t=Object.keys(e);return this.metadata.fields.toArray().filter(r=>t.includes(r.key))}create(e){var r;let t=new this._entity(this._remult);if(e){for(const i of this._fieldsOf(e)){const s=i.key;t[s]=e[s]}this._fixTypes(t)}return(r=this._defaultFindOptions)!=null&&r.where&&(Ur(this.metadata,this._defaultFindOptions.where,t),this._fixTypes(t)),this.getEntityRef(t),t}async _fixTypes(e){for(const t of this._fieldsOf(e)){const r=e[t.key];if(r!=null)if(t.valueType===Date&&!(r instanceof Date))e[t.key]=t.valueConverter.fromJson(t.valueConverter.toJson(r));else for(const[i,s]of[[String,"string"],[Number,"number"],[Boolean,"boolean"]])t.valueType===i&&typeof r!==s&&(e[t.key]=t.valueConverter.fromJson(t.valueConverter.toJson(r)))}return e}findId(e,t){if(e==null)return Promise.resolve(null);if(typeof e!="string"&&typeof e!="number")throw new Error("id can be either number or string, but got: "+typeof e);return this.findFirst({},{...t,where:this.metadata.idMetadata.getIdFilter(e)},!0)}async _translateWhereToFilter(e){var i,s;let t=e??{};(i=this._defaultFindOptions)!=null&&i.where&&(t={$and:[t,(s=this._defaultFindOptions)==null?void 0:s.where]}),this._dataProvider.isProxy||(this.metadata.options.backendPreprocessFilter&&(t=await this.metadata.options.backendPreprocessFilter(t,{metadata:this.metadata,getFilterPreciseValues:a=>q.getPreciseValues(this.metadata,a||t)})),this.metadata.options.backendPrefilter&&(t={$and:[t,await q.resolve(this.metadata.options.backendPrefilter)]}));let r=await q.fromEntityFilter(this.metadata,t);return r&&!this._dataProvider.isProxy&&(r=await q.translateCustomWhere(r,this.metadata,this._remult)),r}}function Ca(n,e){let t=R.columnsOfType.get(n);t||R.columnsOfType.set(n,t=[]);let r=Be(n)(e),i=Ls(n),s=Object.getPrototypeOf(n);for(;s!=null;){let a=R.columnsOfType.get(s);a&&t.unshift(...a.filter(l=>!t.find(f=>f.key==l.key)));let o=Be(s,!1);if(o){let l=o(e);r={...l,...r};let f=["saving","saved","deleting","deleted","validation"];for(const d of f)if(l[d]&&l[d]!==r[d]){let c=r[d];r[d]=async(h,p)=>{await c(h,p),await l[d](h,p)}}}s=Object.getPrototypeOf(s)}return new Sa(Cn(t,e),r,e,n,i)}class kn{constructor(e,t,r,i,s){u(this,"fieldsMetadata");u(this,"instance");u(this,"remult");u(this,"isNewRow");u(this,"_error");u(this,"_subscribers");u(this,"_isLoading",!1);u(this,"lookups",new Map);u(this,"errors");u(this,"originalValues",{});this.fieldsMetadata=e,this.instance=t,this.remult=r,this.isNewRow=i;{let a=r;a!=null&&a.iAmRemultProxy&&(r=R.remultFactory())}for(const a of e)if(Be(a.valueType,!1)&&r){let l=new Xs(r.repo(a.valueType),!!de(a),a.allowNull);this.lookups.set(a.key,l);let f=t[a.key],d;Object.defineProperty(t,a.key,{get:()=>(this._subscribers&&(this._subscribers.reportObserved(),d||(d=this.fields.find(a.key),d._subscribers||(d._subscribers=new Gt)),d._subscribers.reportObserved()),l.item),set:c=>{var h;l.set(c),(h=this._subscribers)==null||h.reportChanged(),d||(d=this.fields.find(a.key),d._subscribers||(d._subscribers=new Gt)),d._subscribers.reportChanged()},enumerable:!(s!=null&&s.has(a.key))}),l.set(f)}else{const l=de(a);if((l==null?void 0:l.type)==="toOne"){let f=t.hasOwnProperty(a.key),d=t[a.key];i&&!d&&(f=!1),Object.defineProperty(t,a.key,{get:()=>d,set:c=>{if(d=c,c===void 0)return;const h=a.options;if(h.field&&(this.instance[h.field]=l.toRepo.metadata.idMetadata.getId(c)),h.fields){for(const p in h.fields)if(Object.prototype.hasOwnProperty.call(h.fields,p)){const g=h.fields[p];this.instance[g]=c==null?null:c[p]}}},enumerable:!(s!=null&&s.has(a.key))}),f&&(t[a.key]=d)}}}get error(){var e;return(e=this._subscribers)==null||e.reportObserved(),this._error}set error(e){var t;this._error=e,(t=this._subscribers)==null||t.reportChanged()}subscribe(e){return this.initSubscribers(),this._subscribers.subscribe(e)}initSubscribers(){if(!this._subscribers){this._subscribers=new Gt;const e=this._subscribers;for(const t of this.fieldsMetadata){let r=Be(t.valueType,!1),i=this.fields.find(t.key);if(i._subscribers=new Gt,!(r&&this.remult||de(t))){let s=this.instance[t.key];Object.defineProperty(this.instance,t.key,{get:()=>(e.reportObserved(),i._subscribers.reportObserved(),s),set:a=>{s=a,e.reportChanged(),i._subscribers.reportChanged()},enumerable:!0})}}}}get isLoading(){var e;return(e=this._subscribers)==null||e.reportObserved(),this._isLoading}set isLoading(e){var t;this._isLoading=e,(t=this._subscribers)==null||t.reportChanged()}async waitLoad(){await $t([...this.lookups.values()],e=>e.waitLoad())}__assertValidity(){if(!this.hasErrors())throw this.buildErrorInfoObject()}buildErrorInfoObject(){var t;let e={modelState:Object.assign({},this.errors),message:this.error};if(!e.message){for(const r of this.fieldsMetadata)if((t=this.errors)!=null&&t[r.key]){e.message=this.fields[r.key].metadata.caption+": "+this.errors[r.key],this.error=e.message;break}}return new On(e)}catchSaveErrors(e){let t=e;if(t instanceof Promise)return t.then(i=>this.catchSaveErrors(i));t.error&&(t=t.error),t.message?this.error=t.message:t.Message?this.error=t.Message:this.error=t;let r=t.modelState;throw r||(r=t.ModelState),r&&(this.errors=r),e}__clearErrorsAndReportChanged(){this.errors=void 0,this.error=void 0,this._reportChangedToEntityAndFields()}_reportChangedToEntityAndFields(){if(this._subscribers){this._subscribers.reportChanged();for(const e of this.fields)e._subscribers.reportChanged()}}hasErrors(){var e;return(e=this._subscribers)==null||e.reportObserved(),!this.error&&this.errors==null}copyDataToObject(e=!1){let t={};for(const r of this.fieldsMetadata){let i=this.lookups.get(r.key),s;const a=de(r);i?s=i.id:s=this.instance[r.key],a&&e&&!r.allowNull&&s==null&&(a.toRepo.metadata.idMetadata.field.valueType===Number?s=0:s=""),(!a||a.type==="reference")&&(s!==void 0&&(s=r.valueConverter.toJson(s),s!=null&&(s=r.valueConverter.fromJson(JSON.parse(JSON.stringify(s))))),t[r.key]=s)}return t}saveOriginalData(){this.originalValues=this.copyDataToObject(),this.saveMoreOriginalData()}saveMoreOriginalData(){}async validate(){if(this.__clearErrorsAndReportChanged(),await this.__performColumnAndEntityValidations(),this.hasErrors(),!this.hasErrors())return this.buildErrorInfoObject()}async __validateEntity(){this.__clearErrorsAndReportChanged(),await this.__performColumnAndEntityValidations(),this.__assertValidity()}async __performColumnAndEntityValidations(){}toApiJson(e=!1,t=!1){let r={};for(const i of this.fieldsMetadata)if(t||!this.remult||i.includedInApi(this.instance)){let s,a=this.lookups.get(i.key),o=!1;a?e?(s=a.toJson(),o=!0,r[i.key]=s):s=a.id:de(i)&&!e?o=!0:(s=this.instance[i.key],this.remult||s&&Be(s.constructor,!1)&&(s=ue(s).getId())),o||(r[i.key]=i.valueConverter.toJson(s))}return r}async _updateEntityBasedOnApi(e,t=!1){let r=Object.keys(e);for(const i of this.fieldsMetadata)if(r.includes(i.key)&&i.includedInApi(this.instance)&&(!this.remult||t||i.apiUpdateAllowed(this.instance))){let s=this.lookups.get(i.key);s?s.id=e[i.key]:this.instance[i.key]=i.valueConverter.fromJson(e[i.key])}await $t([...this.fields].filter(i=>!de(i.metadata)),i=>i.load())}}class nr extends kn{constructor(t,r,i,s,a,o,l){super(t.fieldsMetadata,r,a,o,l);u(this,"info");u(this,"repo");u(this,"edp");u(this,"_isNew");u(this,"repository");u(this,"metadata");u(this,"_wasDeleted",!1);u(this,"_columns");u(this,"_saving",!1);u(this,"id");u(this,"originalId");if(this.info=t,this.repo=i,this.edp=s,this._isNew=o,this.repository=i,this.metadata=t,o)for(const f of t.fieldsMetadata){const d=f.key;f.options.defaultValue&&r[d]===void 0&&(typeof f.options.defaultValue=="function"?r[d]=f.options.defaultValue(r):r[d]||(r[d]=f.options.defaultValue))}this.info.entityInfo.entityRefInit&&this.info.entityInfo.entityRefInit(this,r),Ke.entityRefInit&&Ke.entityRefInit(this,r)}clone(){const t=this.toApiJson(!0,!0);return this.repo.fromJson(t,this.isNew())}get relations(){return this.repo.relations(this.instance)}get apiUpdateAllowed(){return this.remult.isAllowedForInstance(this.instance,this.metadata.options.allowApiUpdate)}get apiDeleteAllowed(){return this.remult.isAllowedForInstance(this.instance,this.metadata.options.allowApiDelete)}get apiInsertAllowed(){return this.remult.isAllowedForInstance(this.instance,this.metadata.options.allowApiInsert)}getId(){const t=r=>{let i=this.lookups.get(r.key);return i?i.id:this.instance[r.key]};return this.metadata.idMetadata.field instanceof gt?this.metadata.idMetadata.field.getId(t):t(this.metadata.idMetadata.field)}saveMoreOriginalData(){this.originalId=this.getId()}wasDeleted(){var t;return(t=this._subscribers)==null||t.reportObserved(),this._wasDeleted}undoChanges(){this.loadDataFrom(this.originalValues),this.__clearErrorsAndReportChanged()}async reload(){return await this.edp.find({where:await this.getIdFilter()}).then(async t=>{if(t.length===0)throw this.repo._notFoundError(this.id);await this.loadDataFrom(t[0]),this.saveOriginalData()}),this._reportChangedToEntityAndFields(),this.instance}get fields(){if(!this._columns){let t=[],r={find:i=>r[typeof i=="string"?i:i.key],[Symbol.iterator]:()=>t[Symbol.iterator](),toArray:()=>t};for(const i of this.info.fieldsMetadata)t.push(r[i.key]=new wr(i.options,i,this.instance,this,this));this._columns=r}return this._columns}async save(t){var r,i;try{if(this._saving)throw new Error("cannot save while entity is already saving");if(this._saving=!0,this.wasDeleted())throw new Error("cannot save a deleted row");this.isLoading=!0,t===void 0&&await this.__validateEntity();let s=!1,a=this.buildLifeCycleEvent(()=>s=!0);if(!this.repo._dataProvider.isProxy){for(const c of this.fields)c.metadata.options.saving&&await c.metadata.options.saving(this.instance,c,a);this.info.entityInfo.saving&&await this.info.entityInfo.saving(this.instance,a)}this.__assertValidity();let o=this.copyDataToObject(this.isNew()),l=[];for(const c of this.metadata.fields)if(c.dbReadOnly||t!==void 0&&!t.includes(c.key)){o[c.key]=void 0,l.push(c.key);let h=this.fields.find(c);h.value=h.originalValue}let f,d=this.isNew();try{if((r=this._subscribers)==null||r.reportChanged(),this.isNew())s?f=(f=await this.edp.find({where:await this.getIdFilter()}))[0]:f=await this.edp.insert(o);else{let c={},h=!1;for(const p in o)if(Object.prototype.hasOwnProperty.call(o,p)){const g=o[p];this.fields.find(p).valueChanged()&&!l.includes(p)&&g!==void 0&&(c[p]=g,h=!0)}if(!h)return this.instance;if(s)f=(await this.edp.find({where:await this.getIdFilter()}))[0];else{if(this.id===void 0)throw new Error("Invalid operation, id is undefined");f=await this.edp.update(this.id,c)}}if(f&&await this.loadDataFrom(f),a.id=this.getId(),!this.repo._dataProvider.isProxy&&(this.info.entityInfo.saved&&await this.info.entityInfo.saved(this.instance,a),this.repo.listeners))for(const c of this.repo.listeners)await((i=c.saved)==null?void 0:i.call(c,this.instance,d));return this.repo._remult.liveQueryPublisher.itemChanged(this.repo.metadata.key,[{id:this.getId(),oldId:this.getOriginalId(),deleted:!1}]),this.saveOriginalData(),this._isNew=!1,this.instance}catch(c){throw await this.catchSaveErrors(c)}}finally{this.isLoading=!1,this._reportChangedToEntityAndFields(),this._saving=!1}}async processInsertResponseDto(t){return await this.loadDataFrom(t),this.saveOriginalData(),this._isNew=!1,this.instance}async buildDtoForInsert(){await this.__validateEntity(),this.__assertValidity();let t=this.copyDataToObject(this.isNew());for(const r of this.metadata.fields)if(r.dbReadOnly){t[r.key]=void 0;let i=this.fields.find(r);i.value=i.originalValue}return t}buildLifeCycleEvent(t=()=>{}){const r=this;return{isNew:r.isNew(),fields:r.fields,id:r.getId(),originalId:r.getOriginalId(),metadata:r.repo.metadata,repository:r.repo,preventDefault:()=>t(),relations:r.repo.relations(r.instance)}}async getIdFilter(){return await this.repo._translateWhereToFilter(this.repo.metadata.idMetadata.getIdFilter(this.id))}async delete(){var i;this.__clearErrorsAndReportChanged();let t=!0,r=this.buildLifeCycleEvent(()=>t=!1);this.repo._dataProvider.isProxy||this.info.entityInfo.deleting&&await this.info.entityInfo.deleting(this.instance,r),this.__assertValidity();try{if(t){if(this.id===void 0)throw new Error("Invalid operation, id is undefined");await this.edp.delete(this.id)}if(this.repo._dataProvider.isProxy||this.info.entityInfo.deleted&&await this.info.entityInfo.deleted(this.instance,r),this.repo.listeners)for(const s of this.repo.listeners)await((i=s.deleted)==null?void 0:i.call(s,this.instance));this.repo._remult.liveQueryPublisher.itemChanged(this.repo.metadata.key,[{id:this.getId(),oldId:this.getOriginalId(),deleted:!0}]),this._wasDeleted=!0}catch(s){throw await this.catchSaveErrors(s)}}async loadDataFrom(t,r){for(const i of this.info.fields){let s=this.lookups.get(i.key);s?(s.id=t[i.key],r===void 0?!i.options.lazy&&!de(i)&&await s.waitLoad():r.includes(i)&&await s.waitLoad()):de(i)||(t[i.key]===void 0?delete this.instance[i.key]:this.instance[i.key]=t[i.key])}await this.calcServerExpression(),this.id=this.getId()}getOriginalId(){return this.originalId}async calcServerExpression(){if(!this.repo._dataProvider.isProxy){for(const t of this.info.fieldsMetadata)if(t.options.serverExpression){const r=await t.options.serverExpression(this.instance);r!==void 0&&(this.instance[t.key]=r)}}}isNew(){var t;return(t=this._subscribers)==null||t.reportObserved(),this._isNew}wasChanged(){var t;(t=this._subscribers)==null||t.reportObserved();for(const r of this.fields){const i=de(r.metadata);if((!i||i.type=="reference")&&r.valueChanged())return!0}return!1}async __performColumnAndEntityValidations(){var t;for(const r of this.fieldsMetadata)r.options.validate&&await new wr(r.options,r,this.instance,this,this).__performValidation();if(this.info.entityInfo.validation){let r=this.buildLifeCycleEvent(()=>{});await this.info.entityInfo.validation(this.instance,r)}if(this.repo.listeners)for(const r of this.repo.listeners)await((t=r.validating)==null?void 0:t.call(r,this.instance))}}const xi=Symbol.for("controllerColumns");function Cn(n,e){return n.map(t=>fi(t.settings(e),e))}function Li(n,e){const t=e||De;let r=n[xi];if(r||(r=n[yt]),!r){let i=R.columnsOfType.get(n.constructor);i||R.columnsOfType.set(n.constructor,i=[]);let s=Object.getPrototypeOf(n.constructor);for(;s!=null;){let a=R.columnsOfType.get(s);a&&i.unshift(...a.filter(o=>!i.find(l=>l.key==o.key))),s=Object.getPrototypeOf(s)}n[xi]=r=new Ea(Cn(i,t).map(a=>new An(a,void 0,t)),n,t)}return r}class Ea extends kn{constructor(t,r,i){super(t,r,i,!1);u(this,"fields");let s=[],a={find:o=>a[typeof o=="string"?o:o.key],[Symbol.iterator]:()=>s[Symbol.iterator](),toArray:()=>s};for(const o of t)s.push(a[o.key]=new wr(o.options,o,r,void 0,this));this.fields=a}async __performColumnAndEntityValidations(){for(const t of this.fields)t instanceof wr&&await t.__performValidation()}}class wr{constructor(e,t,r,i,s){u(this,"settings");u(this,"metadata");u(this,"container");u(this,"helper");u(this,"rowBase");u(this,"_subscribers");u(this,"target");u(this,"entityRef");this.settings=e,this.metadata=t,this.container=r,this.helper=i,this.rowBase=s,this.target=this.settings.target,this.entityRef=this.helper}subscribe(e){return this._subscribers||this.rowBase.initSubscribers(),this._subscribers.subscribe(e)}valueIsNull(){this.reportObserved();let e=this.rowBase.lookups.get(this.metadata.key);return e?e.id===void 0||e.id===null:this.value===null}originalValueIsNull(){return this.reportObserved(),this.rowBase.lookups.get(this.metadata.key),this.rawOriginalValue()===null}get key(){return this.metadata.key}get repo(){var e;return(e=this.helper)==null?void 0:e.repository}async load(){let e=this.rowBase.lookups.get(this.metadata.key),t=de(this.metadata);if(t&&this.helper){if(t.type==="toMany")return this.container[this.metadata.key]=await this.repo.relations(this.container)[this.key].find();{let r=await this.repo.relations(this.container)[this.metadata.key].findOne();if(r)this.container[this.metadata.key]=r;else return null}}else if(e)return this.valueChanged()&&await e.waitLoadOf(this.rawOriginalValue()),await e.waitLoad();return this.value}reportObserved(){var e,t;(e=this._subscribers)==null||e.reportObserved(),(t=this.rowBase._subscribers)==null||t.reportObserved()}reportChanged(){var e,t;(e=this._subscribers)==null||e.reportChanged(),(t=this.rowBase._subscribers)==null||t.reportChanged()}get error(){if(this.reportObserved(),!!this.rowBase.errors)return this.rowBase.errors[this.metadata.key]}set error(e){this.rowBase.errors||(this.rowBase.errors={}),this.rowBase.errors[this.metadata.key]=e,this.reportChanged()}get displayValue(){return this.reportObserved(),this.value!=null?this.settings.displayValue?this.settings.displayValue(this.container,this.value):this.metadata.valueConverter.displayValue?this.metadata.valueConverter.displayValue(this.value):this.value.toString():""}get value(){return this.container[this.metadata.key]}set value(e){this.container[this.metadata.key]=e}get originalValue(){this.reportObserved();let e=this.rowBase.lookups.get(this.metadata.key);return e?e.get(this.rawOriginalValue()):this.rowBase.originalValues[this.metadata.key]}rawOriginalValue(){return this.rowBase.originalValues[this.metadata.key]}setId(e){this.value=e}getId(){let e=this.rowBase.lookups.get(this.metadata.key);return e?e.id!=null?e.id:null:this.value}get inputValue(){this.reportObserved();let e=this.rowBase.lookups.get(this.metadata.key);return e?e.id!=null?e.id.toString():null:this.metadata.valueConverter.toInput(this.value,this.settings.inputType)}set inputValue(e){let t=this.rowBase.lookups.get(this.metadata.key);t?t.setId(e):this.value=this.metadata.valueConverter.fromInput(e,this.settings.inputType)}valueChanged(){this.reportObserved();let e=this.value,t=this.rowBase.lookups.get(this.metadata.key);return t&&(e=t.id),JSON.stringify(this.metadata.valueConverter.toJson(this.rowBase.originalValues[this.metadata.key]))!=JSON.stringify(this.metadata.valueConverter.toJson(e))}async __performValidation(){var e;try{const t=r=>{r!==!0&&r!==void 0&&!this.error&&(typeof r=="string"&&r.length>0?this.error=r:this.error="invalid value")};if(this.settings.validate){let r=this,i={entityRef:this.entityRef,get error(){return r.error},set error(s){r.error=s},isNew:((e=this.entityRef)==null?void 0:e.isNew())??!1,load:()=>r.load(),metadata:r.metadata,originalValue:r.originalValue,value:r.value,valueChanged:()=>r.valueChanged(),originalValueIsNull:()=>r.originalValueIsNull(),valueIsNull:()=>r.valueIsNull(),isBackend:()=>{var s,a,o;return!((o=(a=(s=r.rowBase)==null?void 0:s.remult)==null?void 0:a.dataProvider)!=null&&o.isProxy)}};if(Array.isArray(this.settings.validate))for(const s of this.settings.validate)t(await s(this.container,i));else typeof this.settings.validate=="function"&&t(await this.settings.validate(this.container,i))}}catch(t){typeof t=="string"?this.error=t:this.error=t==null?void 0:t.message}}async validate(){return await this.__performValidation(),!this.error}}let Aa={transformCaption:(n,e,t,r)=>t};const Vr=R.fieldOptionsEnricher||{enrichFieldOptions:n=>n},Ta=R.captionTransformer||(R.captionTransformer=Aa);function En(n,e,t,r){let i;return typeof n=="function"?t&&(i=n(t)):n&&(i=n),i=Ta.transformCaption(t,e,i??"",r),i||(e?Xr(e):"")}class An{constructor(e,t,r){u(this,"settings");u(this,"entityDefs");u(this,"remult");u(this,"options");u(this,"target");u(this,"readonly",!1);u(this,"valueConverter");u(this,"allowNull");u(this,"caption");u(this,"dbName");u(this,"inputType");u(this,"key");u(this,"isServerExpression",!1);u(this,"valueType");this.settings=e,this.entityDefs=t,this.remult=r,this.options=this.settings,this.target=this.settings.target,this.valueConverter=new Proxy(this.settings.valueConverter??{},{get:(i,s)=>{let a=i[s];return typeof a=="function"?(...o)=>{try{return i[s](...o)}catch(l){const f=`${String(s)} failed for value ${o==null?void 0:o[0]}. Error: ${typeof l=="string"?l:l.message}`;throw new On({message:this.caption+": "+f,modelState:{[this.key]:f}})}}:a}}),this.allowNull=!!this.settings.allowNull,this.valueType=this.settings.valueType,this.key=this.settings.key,this.inputType=this.settings.inputType,e.serverExpression&&(this.isServerExpression=!0),typeof this.settings.allowApiUpdate=="boolean"&&(this.readonly=this.settings.allowApiUpdate),this.inputType||(this.inputType=this.valueConverter.inputType),this.dbName=e.dbName,this.dbName==null&&(this.dbName=e.key),this.caption=En(e.caption,e.key,r,t)}apiUpdateAllowed(e){return this.options.allowApiUpdate===void 0?!0:this.remult.isAllowedForInstance(e,this.options.allowApiUpdate)}displayValue(e){return this.entityDefs.getEntityMetadataWithoutBreakingTheEntity(e).fields.find(this.key).displayValue}includedInApi(e){return this.options.includeInApi===void 0?!0:this.remult.isAllowedForInstance(e,this.options.includeInApi)}toInput(e,t){return this.valueConverter.toInput(e,t)}fromInput(e,t){return this.valueConverter.fromInput(e,t)}async getDbName(){return di(this,this.entityDefs)}get dbReadOnly(){return!!this.settings.dbReadOnly}}class Sa{constructor(e,t,r,i,s){u(this,"entityInfo");u(this,"remult");u(this,"entityType");u(this,"key");u(this,"options");u(this,"fieldsMetadata",[]);u(this,"idMetadata",{getId:e=>{if(e==null)return e;const t=ue(e,!1);return t?t.getId():this.idMetadata.field instanceof gt?this.idMetadata.field.getId(e):e[this.idMetadata.field.key]},field:void 0,get fields(){return this.field instanceof gt?this.field.fields:[this.field]},createIdInFilter:e=>e.length>0?{$or:e.map(t=>this.idMetadata.getIdFilter(ue(t).getId()))}:{[this.fields.toArray()[0].key]:[]},isIdField:e=>e.key==this.idMetadata.field.key,getIdFilter:(...e)=>{if(this.idMetadata.field instanceof gt){let t=this.idMetadata.field;return e.length==1?t.isEqualTo(e[0]):{$or:e.map(r=>t.isEqualTo(r))}}return e.length==1?{[this.idMetadata.field.key]:e[0]}:{[this.idMetadata.field.key]:e}}});u(this,"fields");u(this,"dbName");u(this,"caption");if(this.entityInfo=t,this.remult=r,this.entityType=i,this.key=s,this.options=t,this.options.allowApiCrud!==void 0){let o;typeof this.options.allowApiCrud=="function"?o=(l,f)=>this.options.allowApiCrud(f):o=this.options.allowApiCrud,this.options.allowApiDelete===void 0&&(this.entityInfo.allowApiDelete=o),this.options.allowApiInsert===void 0&&(this.entityInfo.allowApiInsert=o),this.options.allowApiUpdate===void 0&&(this.entityInfo.allowApiUpdate=o),this.options.allowApiRead===void 0&&(this.options.allowApiRead=this.options.allowApiCrud)}this.options.allowApiRead===void 0&&(this.options.allowApiRead=!0),this.key||(this.key=i.name),t.dbName||(t.dbName=this.key),this.dbName=t.dbName;let a={find:o=>a[typeof o=="string"?o:o.key],[Symbol.iterator]:()=>this.fieldsMetadata[Symbol.iterator](),toArray:()=>this.fieldsMetadata};for(const o of e)this.fieldsMetadata.push(a[o.key]=new An(o,this,r));if(this.fields=a,this.caption=En(t.caption,this.key,r,this),t.id){let o=typeof t.id=="string"?this.fields.find(t.id):Array.isArray(t.id)?t.id.map(l=>this.fields.find(l)):typeof t.id=="function"?t.id(this.fields):Object.keys(t.id).map(l=>this.fields.find(l));Array.isArray(o)?o.length>1?this.idMetadata.field=new gt(...o):o.length==1&&(this.idMetadata.field=o[0]):this.idMetadata.field=o}if(!this.idMetadata.field){const o=this.fields.id;o?this.idMetadata.field=o:this.idMetadata.field=[...this.fields][0]}}apiUpdateAllowed(e){return this.options.allowApiUpdate===void 0?!1:e?this.getEntityMetadataWithoutBreakingTheEntity(e).apiUpdateAllowed:this.remult.isAllowedForInstance(void 0,this.options.allowApiUpdate)}get apiReadAllowed(){return this.options.allowApiRead===void 0?!0:this.remult.isAllowed(this.options.allowApiRead)}apiDeleteAllowed(e){return this.options.allowApiDelete===void 0?!1:e?this.getEntityMetadataWithoutBreakingTheEntity(e).apiDeleteAllowed:this.remult.isAllowedForInstance(void 0,this.options.allowApiDelete)}apiInsertAllowed(e){return this.options.allowApiUpdate===void 0?!1:e?this.getEntityMetadataWithoutBreakingTheEntity(e).apiInsertAllowed:this.remult.isAllowedForInstance(void 0,this.options.allowApiInsert)}getEntityMetadataWithoutBreakingTheEntity(e){let t=ue(e,!1);return t||this.remult.repo(this.entityType).getEntityRef({...e})}getDbName(){return Rn(this)}}function Fa(...n){return(e,t)=>(n||(n=[]),n.splice(0,0,{valueType:e}),e[ui]=n,e)}function Pa(n){var e,t;return((t=(e=n.options)==null?void 0:e.valueConverter)==null?void 0:t.fieldTypeInDb)==="autoincrement"}function Ra(...n){return(e,t)=>{Fa(r=>{r.valueConverter=vr.get(e),r.displayValue=(i,s)=>s==null?void 0:s.caption,r.validate=(i,s)=>{const a=vr.get(e).getValues();return s.value&&!a.find(o=>o===s.value)&&(s.value=a.find(o=>o.id===s.value.id)||s.value),He.in(a)(i,s)}},...n)(e)}}class vr{constructor(e){u(this,"valueListType");u(this,"byIdMap",new Map);u(this,"values",[]);u(this,"isNumeric",!1);u(this,"fieldTypeInDb");u(this,"inputType");this.valueListType=e;for(let r in this.valueListType){let i=this.valueListType[r];i instanceof this.valueListType&&(i.id===void 0&&(i.id=r),typeof i.id=="number"&&(this.isNumeric=!0),i.caption===void 0&&(i.caption=Xr(i.id!==void 0?i.id.toString():r)),this.byIdMap.set(i.id,i),this.values.push(i))}this.isNumeric&&(this.fieldTypeInDb="integer");var t=this.valueListType[ui];if(t){for(const r of t)r!=null&&r.getValues&&(this.values.splice(0,this.values.length,...r.getValues()),this.byIdMap.clear(),this.values.forEach(i=>{i.caption===void 0&&i.id!==void 0&&(i.caption=Xr(i.id)),this.byIdMap.set(i.id,i)}));if(this.values.find(r=>r.id===void 0))throw new Error(`ValueType ${this.valueListType} has values without an id`)}else throw new Error("ValueType not yet initialized, did you forget to call @ValueListFieldType on "+e)}static get(e){let t=qi.get(e);return t||(t=new vr(e),qi.set(e,t)),t}getValues(){return this.values}byId(e){return this.isNumeric&&(e=+e),this.byIdMap.get(e)}fromJson(e){return this.byId(e)}toJson(e){if(e)return e.id}fromDb(e){return this.fromJson(e)}toDb(e){return this.toJson(e)}toInput(e,t){return this.toJson(e)}fromInput(e,t){return this.fromJson(e)}displayValue(e){return e?e.caption:""}}const qi=new Map,ui=Symbol.for("storableMember"),Wr=Symbol.for("fieldOptionalValues");function Tn(n,e){var r;let t={};for(const i of n)if(i)if(typeof i=="function")i(t,e);else{const{validate:s,...a}=i;t.validate=fr(t.validate,s),Object.assign(t,a)}return(r=Vr.enrichFieldOptions)==null||r.call(Vr,t),t}function fi(n,e){if(n.valueType){let i=n.valueType[ui];i&&(n=Tn([...i,n],e))}if(n.valueType==String){let i=n;n.valueConverter||(i.valueConverter=Pe.String)}if(n.valueType==Number){let i=n;n.valueConverter||(i.valueConverter=Pe.Number)}if(n.valueType==Date){let i=n;n.valueConverter||(i.valueConverter=Pe.Date)}if(n.valueType==Boolean){let i=n;i.valueConverter||(i.valueConverter=Pe.Boolean)}if(!n.valueConverter){if(Be(n.valueType,!1)){let s;n.valueConverter={toDb:a=>a,fromDb:a=>a},n.valueConverter=new Proxy(n.valueConverter,{get(a,o){if(a[o]===void 0&&s===void 0){if(o==="inputType")return"";s=e.repo(n.valueType).metadata.idMetadata.field.valueType===Number;for(const l of["fieldTypeInDb","toJson","fromJson","toDb","fromDb"])a[l]=s?Pe.Integer[l]:Pe.String[l]}return a[o]},set(a,o,l,f){return a[o]=l,!0}})}else n.valueConverter=Pe.Default;return n}n.valueConverter.toJson||(n.valueConverter.toJson=i=>i),n.valueConverter.fromJson||(n.valueConverter.fromJson=i=>i);const t=n.valueConverter.fromJson,r=n.valueConverter.toJson;return n.valueConverter.toDb||(n.valueConverter.toDb=i=>r(i)),n.valueConverter.fromDb||(n.valueConverter.fromDb=i=>t(i)),n.valueConverter.toInput||(n.valueConverter.toInput=i=>r(i)),n.valueConverter.fromInput||(n.valueConverter.fromInput=i=>t(i)),n}class Sn{get _(){return ue(this)}save(){return ue(this).save()}assign(e){return Qt(this,e),this}delete(){return this._.delete()}isNew(){return this._.isNew()}get $(){return this._.fields}}function $a(n){return n.metadata?n.metadata:Be(n,!1)?De.repo(n).metadata:n}function Da(n){return Be(n,!1)?De.repo(n):n}async function $t(n,e){const t=[];for(let r=0;r<n.length;r++){const i=n[r];t.push(await e(i,r))}return t}const Dt=class Dt{constructor(e){u(this,"sql");u(this,"wrapIdentifier",e=>e);u(this,"provideMigrationBuilder");u(this,"createdEntities",[]);u(this,"end");this.sql=e,e.wrapIdentifier&&(this.wrapIdentifier=t=>e.wrapIdentifier(t)),Mt(e,"provideMigrationBuilder")&&(this.provideMigrationBuilder=t=>e.provideMigrationBuilder(t)),Mt(e,"end")&&(this.end=()=>e.end())}static getDb(e){const t=e||De.dataProvider;if(Mt(t,"createCommand"))return t;throw"the data provider is not an SqlCommandFactory"}createCommand(){return new Na(this.sql.createCommand(),Dt.LogToConsole)}async execute(e){return await this.createCommand().execute(e)}_getSourceSql(){return this.sql}async ensureSchema(e){this.sql.ensureSchema&&await this.sql.ensureSchema(e)}getEntityDataProvider(e){if(!this.sql.supportsJsonColumnType)for(const t of e.fields.toArray())t.valueConverter.fieldTypeInDb==="json"&&(t.valueConverter={...t.valueConverter,toDb:Pe.JsonString.toDb,fromDb:Pe.JsonString.fromDb});return new Fn(e,this,async t=>{this.createdEntities.indexOf(t.$entityName)<0&&(this.createdEntities.push(t.$entityName),await this.sql.entityIsUsedForTheFirstTime(e))},this.sql)}transaction(e){return this.sql.transaction(async t=>{let r=!1;try{await e(new Dt({createCommand:()=>{let i=t.createCommand();return{addParameterAndReturnSqlToken:s=>i.param(s),param:s=>i.param(s),execute:async s=>{if(r)throw"can't run a command after the transaction was completed";return i.execute(s)}}},getLimitSqlSyntax:this.sql.getLimitSqlSyntax,entityIsUsedForTheFirstTime:i=>t.entityIsUsedForTheFirstTime(i),transaction:i=>t.transaction(i),supportsJsonColumnType:this.sql.supportsJsonColumnType,wrapIdentifier:this.wrapIdentifier,end:this.end,doesNotSupportReturningSyntax:this.sql.doesNotSupportReturningSyntax,doesNotSupportReturningSyntaxOnlyForUpdate:this.sql.doesNotSupportReturningSyntaxOnlyForUpdate,orderByNullsFirst:this.sql.orderByNullsFirst}))}finally{r=!0}})}static rawFilter(e){return{[mn]:{buildSql:e}}}static async filterToRaw(e,t,r,i,s){r||(r=new xa);const a=Da(e);var o=new at(r,i||await Pn(a.metadata,s));return o._addWhere=!1,await(await wt(a)._translateWhereToFilter(t)).__applyToConsumer(o),await o.resolveWhere()}};u(Dt,"LogToConsole",!1),u(Dt,"durationThreshold",0);let Lt=Dt;const Ma=new Map([["INSERT","⚪"],["SELECT","🔵"],["UPDATE","🟣"],["DELETE","🟤"],["CREATE","🟩"],["ALTER","🟨"],["DROP","🟥"],["TRUNCATE","⬛"],["GRANT","🟪"],["REVOKE","🟫"]]);class Na{constructor(e,t){u(this,"origin");u(this,"logToConsole");u(this,"args",{});this.origin=e,this.logToConsole=t}addParameterAndReturnSqlToken(e){return this.param(e)}param(e,t){let r=this.origin.param(e);return this.args[r]=e,r}async execute(e){try{let r=new Date,i=await this.origin.execute(e);if(this.logToConsole!==!1){var t=new Date().valueOf()-r.valueOf();if(t>=Lt.durationThreshold){const s=t/1e3;if(this.logToConsole==="oneLiner"){const a=e.replace(/(\r\n|\n|\r|\t)/gm," ").replace(/ +/g," ").trim(),o=a.split(" ")[0].toUpperCase();console.info(`${Ma.get(o)||"💢"} (${s.toFixed(3)}) ${a} ${JSON.stringify(this.args)}`)}else typeof this.logToConsole=="function"?this.logToConsole(s,e,this.args):console.info(e+`
|
|
3
|
+
`,{arguments:this.args,duration:s})}}return i}catch(r){throw console.error((r.message||"Sql Error")+`:
|
|
4
|
+
`,e,{arguments:this.args,error:r}),r}}}class Fn{constructor(e,t,r,i){u(this,"entity");u(this,"sql");u(this,"iAmUsed");u(this,"strategy");this.entity=e,this.sql=t,this.iAmUsed=r,this.strategy=i}async init(){let e=await Pn(this.entity,t=>this.sql.wrapIdentifier(t));return await this.iAmUsed(e),e}async count(e){let t=await this.init(),r="select count(*) count from "+t.$entityName,i=this.sql.createCommand();if(e){let s=new at(i,t);e.__applyToConsumer(s),r+=await s.resolveWhere()}return i.execute(r).then(s=>Number(s.rows[0].count))}async groupBy(e){return await La(e,await this.init(),this.sql.createCommand(),this.sql._getSourceSql().orderByNullsFirst,this.sql._getSourceSql().getLimitSqlSyntax)}async find(e){let t=await this.init(),{colKeys:r,select:i}=this.buildSelect(t);i="select "+i,i+=`
|
|
5
|
+
from `+t.$entityName;let s=this.sql.createCommand();if(e){if(e.where){let a=new at(s,t);e.where.__applyToConsumer(a),i+=await a.resolveWhere()}if(e.limit&&(e.orderBy=qe.createUniqueSort(this.entity,e.orderBy)),e.orderBy||(e.orderBy=qe.createUniqueSort(this.entity,new qe)),e.orderBy){let a=!0,o=[];for(const l of e.orderBy.Segments)o.push(l);for(const l of o)a?(i+=" Order By ",a=!1):i+=", ",i+=t.$dbNameOf(l.field),l.isDescending&&(i+=" desc"),this.sql._getSourceSql().orderByNullsFirst&&(l.isDescending?i+=" nulls last":i+=" nulls first")}if(e.limit){let a=1;e.page&&(a=e.page),a<1&&(a=1),i+=" "+this.strategy.getLimitSqlSyntax(e.limit,(a-1)*e.limit)}}return s.execute(i).then(a=>a.rows.map(o=>this.buildResultRow(r,o,a)))}buildResultRow(e,t,r){let i={};for(let s=0;s<e.length;s++){const a=e[s];try{i[a.key]=a.valueConverter.fromDb(t[r.getColumnKeyInResultForIndexInSelect(s)])}catch(o){throw new Error("Failed to load from db:"+a.key+`\r
|
|
6
|
+
`+o)}}return i}buildSelect(e){let t="",r=[];for(const i of this.entity.fields)i.isServerExpression||(r.length>0&&(t+=", "),t+=e.$dbNameOf(i),i.options.sqlExpression&&(t+=" as "+i.key),r.push(i));return{colKeys:r,select:t}}async update(e,t){let r=await this.init(),i=this.sql.createCommand(),s="update "+r.$entityName+" set ",a=!1;for(const h of this.entity.fields)if(!ji(h,r)){if(t[h.key]!==void 0){let p=h.valueConverter.toDb(t[h.key]);p!==void 0&&(a?s+=", ":a=!0,s+=r.$dbNameOf(h)+" = "+i.param(p))}}const o=this.entity.idMetadata.getIdFilter(e);let l=new at(i,r);q.fromEntityFilter(this.entity,o).__applyToConsumer(l),s+=await l.resolveWhere();let{colKeys:f,select:d}=this.buildSelect(r),c=!0;return this.sql._getSourceSql().doesNotSupportReturningSyntax&&(c=!1),c&&this.sql._getSourceSql().doesNotSupportReturningSyntaxOnlyForUpdate&&(c=!1),c&&(s+=" returning "+d),i.execute(s).then(h=>{var p,g;if((g=(p=this.sql._getSourceSql()).afterMutation)==null||g.call(p),!c)return Bi(this.entity,this,t,e,"update");if(h.rows.length!=1)throw new Error("Failed to update row with id "+e+", rows updated: "+h.rows.length);return this.buildResultRow(f,h.rows[0],h)})}async delete(e){let t=await this.init(),r=this.sql.createCommand(),i=new at(r,t);q.fromEntityFilter(this.entity,this.entity.idMetadata.getIdFilter(e)).__applyToConsumer(i);let s="delete from "+t.$entityName;return s+=await i.resolveWhere(),r.execute(s).then(()=>{var a,o;(o=(a=this.sql._getSourceSql()).afterMutation)==null||o.call(a)})}async insert(e){let t=await this.init(),r=this.sql.createCommand(),i="",s="",a=!1;for(const d of this.entity.fields)if(!ji(d,t)){let c=d.valueConverter.toDb(e[d.key]);c!=null&&(a?(i+=", ",s+=", "):a=!0,i+=t.$dbNameOf(d),s+=r.param(c))}let o=`insert into ${t.$entityName} (${i}) values (${s})`,{colKeys:l,select:f}=this.buildSelect(t);return this.sql._getSourceSql().doesNotSupportReturningSyntax||(o+=" returning "+f),await r.execute(o).then(d=>{var c,h;if((h=(c=this.sql._getSourceSql()).afterMutation)==null||h.call(c),this.sql._getSourceSql().doesNotSupportReturningSyntax)if(Pa(this.entity.idMetadata.field)){const p=d.rows[0];if(typeof p!="number")throw new Error("Auto increment, for a database that is does not support returning syntax, should return an array with the single last added id. Instead it returned: "+JSON.stringify(p));return this.find({where:new q(g=>g.isEqualTo(this.entity.idMetadata.field,p))}).then(g=>g[0])}else return Bi(this.entity,this,e,void 0,"insert");return this.buildResultRow(l,d.rows[0],d)})}}u(Fn,"LogToConsole",!1);class xa{execute(e){throw new Error("Method not implemented.")}addParameterAndReturnSqlToken(e){return this.param(e)}param(e){return e===null?"null":(e instanceof Date&&(e=e.toISOString()),typeof e=="string"?(e==null&&(e=""),"'"+e.replace(/'/g,"''")+"'"):e.toString())}}function Bi(n,e,t,r,i){const s=r!==void 0?n.idMetadata.getIdFilter(r):{};return e.find({where:new q(a=>{for(const o of n.idMetadata.fields)a.isEqualTo(o,t[o.key]??s[o.key])})}).then(a=>{if(a.length!=1)throw new Error(`Failed to ${i} row - result contained ${a.length} rows`);return a[0]})}async function La(n,e,t,r,i){let s="select count(*) as count",a="";const o=[];if(o.push((c,h)=>{h[Qs]=Number(c)}),n!=null&&n.group)for(const c of n==null?void 0:n.group)c.isServerExpression||(s+=", "+e.$dbNameOf(c),c.options.sqlExpression&&(s+=" as "+c.key),a==""?a=" group by ":a+=", ",a+=e.$dbNameOf(c)),o.push((h,p)=>{p[c.key]=c.valueConverter.fromDb(h)});for(const c of Ks){const h=n==null?void 0:n[c];if(h)for(const p of h){if(!p.isServerExpression){const b=await e.$dbNameOf(p);s+=`, ${d(c,b)} as ${p.key}_${c}`}const g=p.valueType===Number||c=="distinctCount";o.push((b,w)=>{g&&(b=Number(b)),w[p.key]={...w[p.key],[c]:b}})}}if(s+=`
|
|
7
|
+
from `+e.$entityName,n!=null&&n.where){let c=new at(t,e);n==null||n.where.__applyToConsumer(c),s+=await c.resolveWhere()}a&&(s+=a);let l="";if(n!=null&&n.orderBy){for(const c of n==null?void 0:n.orderBy){l==""?l=" order by ":l+=", ";let h=c.field&&await e.$dbNameOf(c.field);switch(c.operation){case"count":h=c.operation+"(*)";break;case void 0:break;default:h=d(c.operation,h)}l+=h,c.isDescending&&(l+=" desc"),r&&(c.isDescending?l+=" nulls last":l+=" nulls first")}l&&(s+=l)}if(n!=null&&n.limit){let c=1;n.page&&(c=n.page),c<1&&(c=1),s+=" "+i(n.limit,(c-1)*n.limit)}const f=await t.execute(s);return f.rows.map(c=>{let h={};return o.forEach((p,g)=>p(c[f.getColumnKeyInResultForIndexInSelect(g)],h)),h});function d(c,h){return c==="distinctCount"?`count (distinct ${h})`:`${c}( ${h} )`}}class at{constructor(e,t){u(this,"r");u(this,"nameProvider");u(this,"where","");u(this,"_addWhere",!0);u(this,"promises",[]);this.r=e,this.nameProvider=t}async resolveWhere(){for(;this.promises.length>0;){let e=this.promises;this.promises=[];for(const t of e)await t}return this.where}custom(e,t){throw new Error("Custom filter should be translated before it gets here")}or(e){let t="";this.promises.push((async()=>{for(const r of e){let i=new at(this.r,this.nameProvider);i._addWhere=!1,r.__applyToConsumer(i);let s=await i.resolveWhere();if(!s)return;s.length>0&&(t.length>0&&(t+=" or "),e.length>1?t+="("+s+")":t+=s)}this.addToWhere("("+t+")")})())}not(e){this.promises.push((async()=>{let t=new at(this.r,this.nameProvider);t._addWhere=!1,e.__applyToConsumer(t);let r=await t.resolveWhere();r&&this.addToWhere("not ("+r+")")})())}isNull(e){this.promises.push((async()=>this.addToWhere(this.nameProvider.$dbNameOf(e)+" is null"))())}isNotNull(e){this.promises.push((async()=>this.addToWhere(this.nameProvider.$dbNameOf(e)+" is not null"))())}isIn(e,t){this.promises.push((async()=>{t&&t.length>0?this.addToWhere(this.nameProvider.$dbNameOf(e)+" in ("+t.map(r=>this.r.param(e.valueConverter.toDb(r))).join(",")+")"):this.addToWhere("1 = 0 /*isIn with no values*/")})())}isEqualTo(e,t){this.add(e,t,"=")}isDifferentFrom(e,t){this.add(e,t,"<>")}isGreaterOrEqualTo(e,t){this.add(e,t,">=")}isGreaterThan(e,t){this.add(e,t,">")}isLessOrEqualTo(e,t){this.add(e,t,"<=")}isLessThan(e,t){this.add(e,t,"<")}containsCaseInsensitive(e,t){this.promises.push((async()=>{this.addToWhere("lower ("+this.nameProvider.$dbNameOf(e)+") like lower ('%"+t.replace(/'/g,"''")+"%')")})())}notContainsCaseInsensitive(e,t){this.promises.push((async()=>{this.addToWhere("not lower ("+this.nameProvider.$dbNameOf(e)+") like lower ('%"+t.replace(/'/g,"''")+"%')")})())}startsWithCaseInsensitive(e,t){this.promises.push((async()=>{this.addToWhere("lower ("+this.nameProvider.$dbNameOf(e)+") like lower ('"+t.replace(/'/g,"''")+"%')")})())}endsWithCaseInsensitive(e,t){this.promises.push((async()=>{this.addToWhere("lower ("+this.nameProvider.$dbNameOf(e)+") like lower ('%"+t.replace(/'/g,"''")+"')")})())}add(e,t,r){this.promises.push((async()=>{let i=this.nameProvider.$dbNameOf(e)+" "+r+" "+this.r.param(e.valueConverter.toDb(t));this.addToWhere(i)})())}addToWhere(e){this.where.length==0?this._addWhere&&(this.where+=" where "):this.where+=" and ",this.where+=e}databaseCustom(e){this.promises.push((async()=>{if(e!=null&&e.buildSql){let t=new qa(this.r,this.nameProvider.wrapIdentifier),r=await e.buildSql(t);typeof r!="string"&&(r=t.sql),r&&this.addToWhere("("+r+")")}})())}}class qa{constructor(e,t){u(this,"r");u(this,"wrapIdentifier");u(this,"sql","");u(this,"param",(e,t)=>(typeof t=="object"&&t.valueConverter.toDb&&(e=t.valueConverter.toDb(e)),this.r.param(e)));u(this,"filterToRaw",async(e,t)=>Lt.filterToRaw(e,t,this,void 0,this.wrapIdentifier));this.r=e,this.wrapIdentifier=t,this.param.bind(this),this.filterToRaw.bind(this)}addParameterAndReturnSqlToken(e){return this.param(e)}}function ji(n,e){return n.dbReadOnly||n.isServerExpression||n.options.sqlExpression&&n.dbName!=e.$dbNameOf(n)}async function Pn(n,e){return Ba(n,e,!0)}async function Ba(n,e,t=!1){let r=typeof e=="function"?{wrapIdentifier:e}:e||{};var i=$a(n);r.wrapIdentifier||(r.wrapIdentifier=De.dataProvider.wrapIdentifier),r.wrapIdentifier||(r.wrapIdentifier=a=>a);const s={$entityName:await Rn(i,r.wrapIdentifier),toString:()=>s.$entityName,$dbNameOf:a=>{var o;return typeof a=="string"?o=a:o=a.key,s[o]},wrapIdentifier:r.wrapIdentifier};for(const a of i.fields){let o=await di(a,i,r.wrapIdentifier,t);a.options.sqlExpression||(typeof r.tableName=="string"?o=r.wrapIdentifier(r.tableName)+"."+o:r.tableName===!0&&(o=s.$entityName+"."+o)),s[a.key]=o}return s}async function Rn(n,e=t=>t){if(n.options.sqlExpression){if(typeof n.options.sqlExpression=="string")return n.options.sqlExpression;if(typeof n.options.sqlExpression=="function"){const t=n.options.sqlExpression;try{return n.options.sqlExpression="recursive sqlExpression call for entity '"+n.key+"'. ",await t(n)}finally{n.options.sqlExpression=t}}}return e(n.dbName)}const Hr=Symbol.for("sqlExpressionInProgressKey");async function di(n,e,t=i=>i,r=!1){try{if(n.options.sqlExpression){let a;if(typeof n.options.sqlExpression=="function"){if(n[Hr]&&!r)return"recursive sqlExpression call for field '"+n.key+"'. \0";try{n[Hr]=!0,a=await n.options.sqlExpression(e),a.includes("\0")||(n.options.sqlExpression=()=>a)}finally{delete n[Hr]}}else a=n.options.sqlExpression;return a||n.dbName}const i=de(n);let s=(i==null?void 0:i.type)==="toOne"&&n.options.field;if(s){let a=e.fields.find(s);if(a)return di(a,e,t,r)}return t(n.dbName)}finally{}}function $n(n,...e){return(t,r)=>{let i=t;for(;i!=null;){for(const a in i)if(Object.prototype.hasOwnProperty.call(i,a)){const o=t[a];o!=null&&o.rawFilterInfo&&(o.rawFilterInfo.key||(o.rawFilterInfo.key=a))}i=Object.getPrototypeOf(i)}let s=a=>{let o={};for(const f of e)f&&(typeof f=="function"?f(o,a):Object.assign(o,f));let l=Object.getPrototypeOf(t);if(l){let f=Be(l,!1);if(f){let d=f(a);d&&(o={...d,...o})}}return o};return R.allEntities.push(t),ga(t,{key:n}),t[pn]=s,t[yn]=n,t}}var br=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ft={},st={},le={},ke={},Ji;function Dn(){if(Ji)return ke;Ji=1,Object.defineProperty(ke,"__esModule",{value:!0}),ke.output=ke.exists=ke.hash=ke.bytes=ke.bool=ke.number=ke.isBytes=void 0;function n(l){if(!Number.isSafeInteger(l)||l<0)throw new Error(`positive integer expected, not ${l}`)}ke.number=n;function e(l){if(typeof l!="boolean")throw new Error(`boolean expected, not ${l}`)}ke.bool=e;function t(l){return l instanceof Uint8Array||l!=null&&typeof l=="object"&&l.constructor.name==="Uint8Array"}ke.isBytes=t;function r(l,...f){if(!t(l))throw new Error("Uint8Array expected");if(f.length>0&&!f.includes(l.length))throw new Error(`Uint8Array expected of length ${f}, not of length=${l.length}`)}ke.bytes=r;function i(l){if(typeof l!="function"||typeof l.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");n(l.outputLen),n(l.blockLen)}ke.hash=i;function s(l,f=!0){if(l.destroyed)throw new Error("Hash instance has been destroyed");if(f&&l.finished)throw new Error("Hash#digest() has already been called")}ke.exists=s;function a(l,f){r(l);const d=f.outputLen;if(l.length<d)throw new Error(`digestInto() expects output buffer of length at least ${d}`)}ke.output=a;const o={number:n,bool:e,bytes:r,hash:i,exists:s,output:a};return ke.default=o,ke}var V={},Ui;function ja(){if(Ui)return V;Ui=1,Object.defineProperty(V,"__esModule",{value:!0}),V.add5L=V.add5H=V.add4H=V.add4L=V.add3H=V.add3L=V.add=V.rotlBL=V.rotlBH=V.rotlSL=V.rotlSH=V.rotr32L=V.rotr32H=V.rotrBL=V.rotrBH=V.rotrSL=V.rotrSH=V.shrSL=V.shrSH=V.toBig=V.split=V.fromBig=void 0;const n=BigInt(2**32-1),e=BigInt(32);function t(T,O=!1){return O?{h:Number(T&n),l:Number(T>>e&n)}:{h:Number(T>>e&n)|0,l:Number(T&n)|0}}V.fromBig=t;function r(T,O=!1){let S=new Uint32Array(T.length),m=new Uint32Array(T.length);for(let k=0;k<T.length;k++){const{h:F,l:M}=t(T[k],O);[S[k],m[k]]=[F,M]}return[S,m]}V.split=r;const i=(T,O)=>BigInt(T>>>0)<<e|BigInt(O>>>0);V.toBig=i;const s=(T,O,S)=>T>>>S;V.shrSH=s;const a=(T,O,S)=>T<<32-S|O>>>S;V.shrSL=a;const o=(T,O,S)=>T>>>S|O<<32-S;V.rotrSH=o;const l=(T,O,S)=>T<<32-S|O>>>S;V.rotrSL=l;const f=(T,O,S)=>T<<64-S|O>>>S-32;V.rotrBH=f;const d=(T,O,S)=>T>>>S-32|O<<64-S;V.rotrBL=d;const c=(T,O)=>O;V.rotr32H=c;const h=(T,O)=>T;V.rotr32L=h;const p=(T,O,S)=>T<<S|O>>>32-S;V.rotlSH=p;const g=(T,O,S)=>O<<S|T>>>32-S;V.rotlSL=g;const b=(T,O,S)=>O<<S-32|T>>>64-S;V.rotlBH=b;const w=(T,O,S)=>T<<S-32|O>>>64-S;V.rotlBL=w;function $(T,O,S,m){const k=(O>>>0)+(m>>>0);return{h:T+S+(k/2**32|0)|0,l:k|0}}V.add=$;const I=(T,O,S)=>(T>>>0)+(O>>>0)+(S>>>0);V.add3L=I;const D=(T,O,S,m)=>O+S+m+(T/2**32|0)|0;V.add3H=D;const E=(T,O,S,m)=>(T>>>0)+(O>>>0)+(S>>>0)+(m>>>0);V.add4L=E;const _=(T,O,S,m,k)=>O+S+m+k+(T/2**32|0)|0;V.add4H=_;const A=(T,O,S,m,k)=>(T>>>0)+(O>>>0)+(S>>>0)+(m>>>0)+(k>>>0);V.add5L=A;const N=(T,O,S,m,k,F)=>O+S+m+k+F+(T/2**32|0)|0;V.add5H=N;const B={fromBig:t,split:r,toBig:i,shrSH:s,shrSL:a,rotrSH:o,rotrSL:l,rotrBH:f,rotrBL:d,rotr32H:c,rotr32L:h,rotlSH:p,rotlSL:g,rotlBH:b,rotlBL:w,add:$,add3L:I,add3H:D,add4L:E,add4H:_,add5H:N,add5L:A};return V.default=B,V}var Gr={},Wt={},Vi;function Ja(){return Vi||(Vi=1,Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.crypto=void 0,Wt.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0),Wt}var Wi;function Ua(){return Wi||(Wi=1,function(n){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(n,"__esModule",{value:!0}),n.randomBytes=n.wrapXOFConstructorWithOpts=n.wrapConstructorWithOpts=n.wrapConstructor=n.checkOpts=n.Hash=n.concatBytes=n.toBytes=n.utf8ToBytes=n.asyncLoop=n.nextTick=n.hexToBytes=n.bytesToHex=n.byteSwap32=n.byteSwapIfBE=n.byteSwap=n.isLE=n.rotl=n.rotr=n.createView=n.u32=n.u8=n.isBytes=void 0;const e=Ja(),t=Dn();function r(m){return m instanceof Uint8Array||m!=null&&typeof m=="object"&&m.constructor.name==="Uint8Array"}n.isBytes=r;const i=m=>new Uint8Array(m.buffer,m.byteOffset,m.byteLength);n.u8=i;const s=m=>new Uint32Array(m.buffer,m.byteOffset,Math.floor(m.byteLength/4));n.u32=s;const a=m=>new DataView(m.buffer,m.byteOffset,m.byteLength);n.createView=a;const o=(m,k)=>m<<32-k|m>>>k;n.rotr=o;const l=(m,k)=>m<<k|m>>>32-k>>>0;n.rotl=l,n.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const f=m=>m<<24&4278190080|m<<8&16711680|m>>>8&65280|m>>>24&255;n.byteSwap=f,n.byteSwapIfBE=n.isLE?m=>m:m=>(0,n.byteSwap)(m);function d(m){for(let k=0;k<m.length;k++)m[k]=(0,n.byteSwap)(m[k])}n.byteSwap32=d;const c=Array.from({length:256},(m,k)=>k.toString(16).padStart(2,"0"));function h(m){(0,t.bytes)(m);let k="";for(let F=0;F<m.length;F++)k+=c[m[F]];return k}n.bytesToHex=h;const p={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function g(m){if(m>=p._0&&m<=p._9)return m-p._0;if(m>=p._A&&m<=p._F)return m-(p._A-10);if(m>=p._a&&m<=p._f)return m-(p._a-10)}function b(m){if(typeof m!="string")throw new Error("hex string expected, got "+typeof m);const k=m.length,F=k/2;if(k%2)throw new Error("padded hex string expected, got unpadded hex of length "+k);const M=new Uint8Array(F);for(let oe=0,x=0;oe<F;oe++,x+=2){const j=g(m.charCodeAt(x)),G=g(m.charCodeAt(x+1));if(j===void 0||G===void 0){const Ce=m[x]+m[x+1];throw new Error('hex string expected, got non-hex character "'+Ce+'" at index '+x)}M[oe]=j*16+G}return M}n.hexToBytes=b;const w=async()=>{};n.nextTick=w;async function $(m,k,F){let M=Date.now();for(let oe=0;oe<m;oe++){F(oe);const x=Date.now()-M;x>=0&&x<k||(await(0,n.nextTick)(),M+=x)}}n.asyncLoop=$;function I(m){if(typeof m!="string")throw new Error(`utf8ToBytes expected string, got ${typeof m}`);return new Uint8Array(new TextEncoder().encode(m))}n.utf8ToBytes=I;function D(m){return typeof m=="string"&&(m=I(m)),(0,t.bytes)(m),m}n.toBytes=D;function E(...m){let k=0;for(let M=0;M<m.length;M++){const oe=m[M];(0,t.bytes)(oe),k+=oe.length}const F=new Uint8Array(k);for(let M=0,oe=0;M<m.length;M++){const x=m[M];F.set(x,oe),oe+=x.length}return F}n.concatBytes=E;class _{clone(){return this._cloneInto()}}n.Hash=_;const A={}.toString;function N(m,k){if(k!==void 0&&A.call(k)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(m,k)}n.checkOpts=N;function B(m){const k=M=>m().update(D(M)).digest(),F=m();return k.outputLen=F.outputLen,k.blockLen=F.blockLen,k.create=()=>m(),k}n.wrapConstructor=B;function T(m){const k=(M,oe)=>m(oe).update(D(M)).digest(),F=m({});return k.outputLen=F.outputLen,k.blockLen=F.blockLen,k.create=M=>m(M),k}n.wrapConstructorWithOpts=T;function O(m){const k=(M,oe)=>m(oe).update(D(M)).digest(),F=m({});return k.outputLen=F.outputLen,k.blockLen=F.blockLen,k.create=M=>m(M),k}n.wrapXOFConstructorWithOpts=O;function S(m=32){if(e.crypto&&typeof e.crypto.getRandomValues=="function")return e.crypto.getRandomValues(new Uint8Array(m));throw new Error("crypto.getRandomValues must be defined")}n.randomBytes=S}(Gr)),Gr}var Hi;function Va(){if(Hi)return le;Hi=1,Object.defineProperty(le,"__esModule",{value:!0}),le.shake256=le.shake128=le.keccak_512=le.keccak_384=le.keccak_256=le.keccak_224=le.sha3_512=le.sha3_384=le.sha3_256=le.sha3_224=le.Keccak=le.keccakP=void 0;const n=Dn(),e=ja(),t=Ua(),r=[],i=[],s=[],a=BigInt(0),o=BigInt(1),l=BigInt(2),f=BigInt(7),d=BigInt(256),c=BigInt(113);for(let E=0,_=o,A=1,N=0;E<24;E++){[A,N]=[N,(2*A+3*N)%5],r.push(2*(5*N+A)),i.push((E+1)*(E+2)/2%64);let B=a;for(let T=0;T<7;T++)_=(_<<o^(_>>f)*c)%d,_&l&&(B^=o<<(o<<BigInt(T))-o);s.push(B)}const[h,p]=(0,e.split)(s,!0),g=(E,_,A)=>A>32?(0,e.rotlBH)(E,_,A):(0,e.rotlSH)(E,_,A),b=(E,_,A)=>A>32?(0,e.rotlBL)(E,_,A):(0,e.rotlSL)(E,_,A);function w(E,_=24){const A=new Uint32Array(10);for(let N=24-_;N<24;N++){for(let O=0;O<10;O++)A[O]=E[O]^E[O+10]^E[O+20]^E[O+30]^E[O+40];for(let O=0;O<10;O+=2){const S=(O+8)%10,m=(O+2)%10,k=A[m],F=A[m+1],M=g(k,F,1)^A[S],oe=b(k,F,1)^A[S+1];for(let x=0;x<50;x+=10)E[O+x]^=M,E[O+x+1]^=oe}let B=E[2],T=E[3];for(let O=0;O<24;O++){const S=i[O],m=g(B,T,S),k=b(B,T,S),F=r[O];B=E[F],T=E[F+1],E[F]=m,E[F+1]=k}for(let O=0;O<50;O+=10){for(let S=0;S<10;S++)A[S]=E[O+S];for(let S=0;S<10;S++)E[O+S]^=~A[(S+2)%10]&A[(S+4)%10]}E[0]^=h[N],E[1]^=p[N]}A.fill(0)}le.keccakP=w;class $ extends t.Hash{constructor(_,A,N,B=!1,T=24){if(super(),this.blockLen=_,this.suffix=A,this.outputLen=N,this.enableXOF=B,this.rounds=T,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,n.number)(N),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,t.u32)(this.state)}keccak(){t.isLE||(0,t.byteSwap32)(this.state32),w(this.state32,this.rounds),t.isLE||(0,t.byteSwap32)(this.state32),this.posOut=0,this.pos=0}update(_){(0,n.exists)(this);const{blockLen:A,state:N}=this;_=(0,t.toBytes)(_);const B=_.length;for(let T=0;T<B;){const O=Math.min(A-this.pos,B-T);for(let S=0;S<O;S++)N[this.pos++]^=_[T++];this.pos===A&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:_,suffix:A,pos:N,blockLen:B}=this;_[N]^=A,(A&128)!==0&&N===B-1&&this.keccak(),_[B-1]^=128,this.keccak()}writeInto(_){(0,n.exists)(this,!1),(0,n.bytes)(_),this.finish();const A=this.state,{blockLen:N}=this;for(let B=0,T=_.length;B<T;){this.posOut>=N&&this.keccak();const O=Math.min(N-this.posOut,T-B);_.set(A.subarray(this.posOut,this.posOut+O),B),this.posOut+=O,B+=O}return _}xofInto(_){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(_)}xof(_){return(0,n.number)(_),this.xofInto(new Uint8Array(_))}digestInto(_){if((0,n.output)(_,this),this.finished)throw new Error("digest() was already called");return this.writeInto(_),this.destroy(),_}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(_){const{blockLen:A,suffix:N,outputLen:B,rounds:T,enableXOF:O}=this;return _||(_=new $(A,N,B,O,T)),_.state32.set(this.state32),_.pos=this.pos,_.posOut=this.posOut,_.finished=this.finished,_.rounds=T,_.suffix=N,_.outputLen=B,_.enableXOF=O,_.destroyed=this.destroyed,_}}le.Keccak=$;const I=(E,_,A)=>(0,t.wrapConstructor)(()=>new $(_,E,A));le.sha3_224=I(6,144,224/8),le.sha3_256=I(6,136,256/8),le.sha3_384=I(6,104,384/8),le.sha3_512=I(6,72,512/8),le.keccak_224=I(1,144,224/8),le.keccak_256=I(1,136,256/8),le.keccak_384=I(1,104,384/8),le.keccak_512=I(1,72,512/8);const D=(E,_,A)=>(0,t.wrapXOFConstructorWithOpts)((N={})=>new $(_,E,N.dkLen===void 0?A:N.dkLen,!0));return le.shake128=D(31,168,128/8),le.shake256=D(31,136,256/8),le}var Gi;function Wa(){if(Gi)return st;Gi=1;const{sha3_512:n}=Va(),e=24,t=32,r=(g=4,b=Math.random)=>{let w="";for(;w.length<g;)w=w+Math.floor(b()*36).toString(36);return w};function i(g){let b=8n,w=0n;for(const $ of g.values()){const I=BigInt($);w=(w<<b)+I}return w}const s=(g="")=>i(n(g)).toString(36).slice(1),a=Array.from({length:26},(g,b)=>String.fromCharCode(b+97)),o=g=>a[Math.floor(g()*a.length)],l=({globalObj:g=typeof br<"u"?br:typeof window<"u"?window:{},random:b=Math.random}={})=>{const w=Object.keys(g).toString(),$=w.length?w+r(t,b):r(t,b);return s($).substring(0,t)},f=g=>()=>g++,d=476782367,c=({random:g=Math.random,counter:b=f(Math.floor(g()*d)),length:w=e,fingerprint:$=l({random:g})}={})=>function(){const D=o(g),E=Date.now().toString(36),_=b().toString(36),A=r(w,g),N=`${E+A+_+$}`;return`${D+s(N).substring(1,w)}`},h=c(),p=(g,{minLength:b=2,maxLength:w=t}={})=>{const $=g.length,I=/^[0-9a-z]+$/;try{if(typeof g=="string"&&$>=b&&$<=w&&I.test(g))return!0}finally{}return!1};return st.getConstants=()=>({defaultLength:e,bigLength:t}),st.init=c,st.createId=h,st.bufToBigInt=i,st.createCounter=f,st.createFingerprint=l,st.isCuid=p,st}var Qi;function Ha(){if(Qi)return Ft;Qi=1;const{createId:n,init:e,getConstants:t,isCuid:r}=Wa();return Ft.createId=n,Ft.init=e,Ft.getConstants=t,Ft.isCuid=r,Ft}var zi=Ha();const Ki=lr(n=>!isNaN(n)&&isFinite(n));class ae{static object(...e){return Ae(void 0,...e)}static json(...e){let t=e;return t.valueConverter&&!t.valueConverter.fieldTypeInDb&&(t.valueConverter.fieldTypeInDb="json"),Ae(void 0,{valueConverter:{fieldTypeInDb:"json"}},...e)}static dateOnly(...e){return Ae(()=>Date,{valueConverter:Pe.DateOnly},...e)}static date(...e){return Ae(()=>Date,...e)}static integer(...e){return Ae(()=>Number,{valueConverter:Pe.Integer,validate:Ki},...e)}static autoIncrement(...e){return Ae(()=>Number,{allowApiUpdate:!1,dbReadOnly:!0,valueConverter:{...Pe.Integer,fieldTypeInDb:"autoincrement"}},...e)}static number(...e){return Ae(()=>Number,{validate:Ki},...e)}static createdAt(...e){return Ae(()=>Date,{allowApiUpdate:!1,saving:(t,r,{isNew:i})=>{i&&(r.value=new Date)}},...e)}static updatedAt(...e){return Ae(()=>Date,{allowApiUpdate:!1,saving:(t,r)=>{r.value=new Date}},...e)}static uuid(...e){return Ae(()=>String,{allowApiUpdate:!1,defaultValue:()=>Zr(),saving:(t,r)=>{r.value||(r.value=Zr())}},...e)}static cuid(...e){return Ae(()=>String,{allowApiUpdate:!1,defaultValue:()=>zi.createId(),saving:(t,r)=>{r.value||(r.value=zi.createId())}},...e)}static literal(e,...t){return ae.string({validate:(r,i)=>He.in(e())(r,i),[Wr]:e},...t)}static enum(e,...t){let r;return Ae(()=>e(),{validate:(i,s)=>He.enum(e())(i,s),[Wr]:()=>ur(e())},...t,i=>{if(i[Wr]=()=>ur(e()),r===void 0){let s=e();r=ur(s).find(o=>typeof o=="string")?Pe.String:Pe.Integer}i.valueConverter?i.valueConverter.fieldTypeInDb||(i.valueConverter.fieldTypeInDb=r.fieldTypeInDb):i.valueConverter=r})}static string(...e){return Ae(()=>String,...e)}static boolean(...e){return Ae(()=>Boolean,...e)}}class Er{static toOne(e,t){let r=typeof t=="string"?{field:t}:t||{};return!r.field&&!r.fields&&!r.findOptions?Ae(e,{...r,...qr(e,"reference")}):Ae(()=>{},{...r,serverExpression:()=>{},...qr(e,"toOne")})}static toMany(e,t){return Ae(()=>{},{...typeof t=="string"?{field:t}:t,serverExpression:()=>{},...qr(e,"toMany")})}}function Ae(n,...e){return(t,r,i)=>{const s=typeof r=="string"?r:r.name.toString();let a=f=>{let d=Tn(e,f);if(d.required&&(d.validate=fr(d.validate,He.required,!0)),Mt(d,"maxLength")){let h=d;h.maxLength&&(h.validate=fr(h.validate,He.maxLength(h.maxLength)))}if(Mt(d,"minLength")){let h=d;h.minLength&&(h.validate=fr(h.validate,He.minLength(h.minLength)))}!d.valueType&&n&&(d.valueType=n()),d.key||(d.key=s),d.dbName||(d.dbName=d.key);let c=d.valueType;return c||(c=typeof Reflect.getMetadata=="function"?Reflect.getMetadata("design:type",t,s):[],d.valueType=c),d.target||(d.target=t),d};Mn(t);let o=R.columnsOfType.get(t.constructor);o||(o=[],R.columnsOfType.set(t.constructor,o));let l=o.find(f=>f.key==s);if(!l)o.push({key:s,settings:a});else{let f=l.settings;l.settings=d=>{let c=f(d),h=a(d);return Object.assign(c,h)}}}}function Mn(n){if(!n)throw new Error("Set the 'experimentalDecorators:true' option in your 'tsconfig' or 'jsconfig' (target undefined)")}function Ga(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var o=n.length-1;o>=0;o--)(a=n[o])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}function Qa(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)}class _r extends Sn{constructor(){super(...arguments);u(this,"id")}}Ga([ae.uuid(),Qa("design:type",String)],_r.prototype,"id",void 0);var Xi={};/*! *****************************************************************************
|
|
8
|
+
Copyright (C) Microsoft. All rights reserved.
|
|
9
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
10
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
11
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
15
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
16
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
17
|
+
|
|
18
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
19
|
+
and limitations under the License.
|
|
20
|
+
***************************************************************************** */var Yi;function za(){if(Yi)return Xi;Yi=1;var n;return function(e){(function(t){var r=typeof br=="object"?br:typeof self=="object"?self:typeof this=="object"?this:Function("return this;")(),i=s(e);typeof r.Reflect>"u"?r.Reflect=e:i=s(r.Reflect,i),t(i);function s(a,o){return function(l,f){typeof a[l]!="function"&&Object.defineProperty(a,l,{configurable:!0,writable:!0,value:f}),o&&o(l,f)}}})(function(t){var r=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",o=typeof Object.create=="function",l={__proto__:[]}instanceof Array,f=!o&&!l,d={create:o?function(){return Pr(Object.create(null))}:l?function(){return Pr({__proto__:null})}:function(){return Pr({})},has:f?function(y,v){return r.call(y,v)}:function(y,v){return v in y},get:f?function(y,v){return r.call(y,v)?y[v]:void 0}:function(y,v){return y[v]}},c=Object.getPrototypeOf(Function),h=typeof process=="object"&&process.env&&process.env.REFLECT_METADATA_USE_MAP_POLYFILL==="true",p=!h&&typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Gn(),g=!h&&typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Qn(),b=!h&&typeof WeakMap=="function"?WeakMap:zn(),w=new b;function $(y,v,C,P){if(U(C)){if(!pt(y))throw new TypeError;if(!Jt(v))throw new TypeError;return S(y,v)}else{if(!pt(y))throw new TypeError;if(!H(v))throw new TypeError;if(!H(P)&&!U(P)&&!re(P))throw new TypeError;return re(P)&&(P=void 0),C=Ve(C),m(y,v,C,P)}}t("decorate",$);function I(y,v){function C(P,L){if(!H(P))throw new TypeError;if(!U(L)&&!Jn(L))throw new TypeError;j(y,v,P,L)}return C}t("metadata",I);function D(y,v,C,P){if(!H(C))throw new TypeError;return U(P)||(P=Ve(P)),j(y,v,C,P)}t("defineMetadata",D);function E(y,v,C){if(!H(v))throw new TypeError;return U(C)||(C=Ve(C)),F(y,v,C)}t("hasMetadata",E);function _(y,v,C){if(!H(v))throw new TypeError;return U(C)||(C=Ve(C)),M(y,v,C)}t("hasOwnMetadata",_);function A(y,v,C){if(!H(v))throw new TypeError;return U(C)||(C=Ve(C)),oe(y,v,C)}t("getMetadata",A);function N(y,v,C){if(!H(v))throw new TypeError;return U(C)||(C=Ve(C)),x(y,v,C)}t("getOwnMetadata",N);function B(y,v){if(!H(y))throw new TypeError;return U(v)||(v=Ve(v)),G(y,v)}t("getMetadataKeys",B);function T(y,v){if(!H(y))throw new TypeError;return U(v)||(v=Ve(v)),Ce(y,v)}t("getOwnMetadataKeys",T);function O(y,v,C){if(!H(v))throw new TypeError;U(C)||(C=Ve(C));var P=k(v,C,!1);if(U(P)||!P.delete(y))return!1;if(P.size>0)return!0;var L=w.get(v);return L.delete(C),L.size>0||w.delete(v),!0}t("deleteMetadata",O);function S(y,v){for(var C=y.length-1;C>=0;--C){var P=y[C],L=P(v);if(!U(L)&&!re(L)){if(!Jt(L))throw new TypeError;v=L}}return v}function m(y,v,C,P){for(var L=y.length-1;L>=0;--L){var Ne=y[L],z=Ne(v,C,P);if(!U(z)&&!re(z)){if(!H(z))throw new TypeError;P=z}}return P}function k(y,v,C){var P=w.get(y);if(U(P)){if(!C)return;P=new p,w.set(y,P)}var L=P.get(v);if(U(L)){if(!C)return;L=new p,P.set(v,L)}return L}function F(y,v,C){var P=M(y,v,C);if(P)return!0;var L=Fr(v);return re(L)?!1:F(y,L,C)}function M(y,v,C){var P=k(v,C,!1);return U(P)?!1:Re(P.has(y))}function oe(y,v,C){var P=M(y,v,C);if(P)return x(y,v,C);var L=Fr(v);if(!re(L))return oe(y,L,C)}function x(y,v,C){var P=k(v,C,!1);if(!U(P))return P.get(y)}function j(y,v,C,P){var L=k(C,P,!0);L.set(y,v)}function G(y,v){var C=Ce(y,v),P=Fr(y);if(P===null)return C;var L=G(P,v);if(L.length<=0)return C;if(C.length<=0)return L;for(var Ne=new g,z=[],Y=0,J=C;Y<J.length;Y++){var ie=J[Y],ne=Ne.has(ie);ne||(Ne.add(ie),z.push(ie))}for(var ut=0,pi=L;ut<pi.length;ut++){var ie=pi[ut],ne=Ne.has(ie);ne||(Ne.add(ie),z.push(ie))}return z}function Ce(y,v){var C=[],P=k(y,v,!1);if(U(P))return C;for(var L=P.keys(),Ne=Un(L),z=0;;){var Y=Wn(Ne);if(!Y)return C.length=z,C;var J=Vn(Y);try{C[z]=J}catch(ie){try{Hn(Ne)}finally{throw ie}}z++}}function we(y){if(y===null)return 1;switch(typeof y){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return y===null?1:6;default:return 6}}function U(y){return y===void 0}function re(y){return y===null}function ye(y){return typeof y=="symbol"}function H(y){return typeof y=="object"?y!==null:typeof y=="function"}function ve(y,v){switch(we(y)){case 0:return y;case 1:return y;case 2:return y;case 3:return y;case 4:return y;case 5:return y}var C="string",P=hi(y,s);if(P!==void 0){var L=P.call(y,C);if(H(L))throw new TypeError;return L}return be(y)}function be(y,v){var C,P;{var L=y.toString;if(jt(L)){var P=L.call(y);if(!H(P))return P}var C=y.valueOf;if(jt(C)){var P=C.call(y);if(!H(P))return P}}throw new TypeError}function Re(y){return!!y}function pe(y){return""+y}function Ve(y){var v=ve(y);return ye(v)?v:pe(v)}function pt(y){return Array.isArray?Array.isArray(y):y instanceof Object?y instanceof Array:Object.prototype.toString.call(y)==="[object Array]"}function jt(y){return typeof y=="function"}function Jt(y){return typeof y=="function"}function Jn(y){switch(we(y)){case 3:return!0;case 4:return!0;default:return!1}}function hi(y,v){var C=y[v];if(C!=null){if(!jt(C))throw new TypeError;return C}}function Un(y){var v=hi(y,a);if(!jt(v))throw new TypeError;var C=v.call(y);if(!H(C))throw new TypeError;return C}function Vn(y){return y.value}function Wn(y){var v=y.next();return v.done?!1:v}function Hn(y){var v=y.return;v&&v.call(y)}function Fr(y){var v=Object.getPrototypeOf(y);if(typeof y!="function"||y===c||v!==c)return v;var C=y.prototype,P=C&&Object.getPrototypeOf(C);if(P==null||P===Object.prototype)return v;var L=P.constructor;return typeof L!="function"||L===y?v:L}function Gn(){var y={},v=[],C=function(){function z(Y,J,ie){this._index=0,this._keys=Y,this._values=J,this._selector=ie}return z.prototype["@@iterator"]=function(){return this},z.prototype[a]=function(){return this},z.prototype.next=function(){var Y=this._index;if(Y>=0&&Y<this._keys.length){var J=this._selector(this._keys[Y],this._values[Y]);return Y+1>=this._keys.length?(this._index=-1,this._keys=v,this._values=v):this._index++,{value:J,done:!1}}return{value:void 0,done:!0}},z.prototype.throw=function(Y){throw this._index>=0&&(this._index=-1,this._keys=v,this._values=v),Y},z.prototype.return=function(Y){return this._index>=0&&(this._index=-1,this._keys=v,this._values=v),{value:Y,done:!0}},z}();return function(){function z(){this._keys=[],this._values=[],this._cacheKey=y,this._cacheIndex=-2}return Object.defineProperty(z.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),z.prototype.has=function(Y){return this._find(Y,!1)>=0},z.prototype.get=function(Y){var J=this._find(Y,!1);return J>=0?this._values[J]:void 0},z.prototype.set=function(Y,J){var ie=this._find(Y,!0);return this._values[ie]=J,this},z.prototype.delete=function(Y){var J=this._find(Y,!1);if(J>=0){for(var ie=this._keys.length,ne=J+1;ne<ie;ne++)this._keys[ne-1]=this._keys[ne],this._values[ne-1]=this._values[ne];return this._keys.length--,this._values.length--,Y===this._cacheKey&&(this._cacheKey=y,this._cacheIndex=-2),!0}return!1},z.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=y,this._cacheIndex=-2},z.prototype.keys=function(){return new C(this._keys,this._values,P)},z.prototype.values=function(){return new C(this._keys,this._values,L)},z.prototype.entries=function(){return new C(this._keys,this._values,Ne)},z.prototype["@@iterator"]=function(){return this.entries()},z.prototype[a]=function(){return this.entries()},z.prototype._find=function(Y,J){return this._cacheKey!==Y&&(this._cacheIndex=this._keys.indexOf(this._cacheKey=Y)),this._cacheIndex<0&&J&&(this._cacheIndex=this._keys.length,this._keys.push(Y),this._values.push(void 0)),this._cacheIndex},z}();function P(z,Y){return z}function L(z,Y){return Y}function Ne(z,Y){return[z,Y]}}function Qn(){return function(){function y(){this._map=new p}return Object.defineProperty(y.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),y.prototype.has=function(v){return this._map.has(v)},y.prototype.add=function(v){return this._map.set(v,v),this},y.prototype.delete=function(v){return this._map.delete(v)},y.prototype.clear=function(){this._map.clear()},y.prototype.keys=function(){return this._map.keys()},y.prototype.values=function(){return this._map.values()},y.prototype.entries=function(){return this._map.entries()},y.prototype["@@iterator"]=function(){return this.keys()},y.prototype[a]=function(){return this.keys()},y}()}function zn(){var y=16,v=d.create(),C=P();return function(){function J(){this._key=P()}return J.prototype.has=function(ie){var ne=L(ie,!1);return ne!==void 0?d.has(ne,this._key):!1},J.prototype.get=function(ie){var ne=L(ie,!1);return ne!==void 0?d.get(ne,this._key):void 0},J.prototype.set=function(ie,ne){var ut=L(ie,!0);return ut[this._key]=ne,this},J.prototype.delete=function(ie){var ne=L(ie,!1);return ne!==void 0?delete ne[this._key]:!1},J.prototype.clear=function(){this._key=P()},J}();function P(){var J;do J="@@WeakMap@@"+Y();while(d.has(v,J));return v[J]=!0,J}function L(J,ie){if(!r.call(J,C)){if(!ie)return;Object.defineProperty(J,C,{value:d.create()})}return J[C]}function Ne(J,ie){for(var ne=0;ne<ie;++ne)J[ne]=Math.random()*255|0;return J}function z(J){return typeof Uint8Array=="function"?typeof crypto<"u"?crypto.getRandomValues(new Uint8Array(J)):typeof msCrypto<"u"?msCrypto.getRandomValues(new Uint8Array(J)):Ne(new Uint8Array(J),J):Ne(new Array(J),J)}function Y(){var J=z(y);J[6]=J[6]&79|64,J[8]=J[8]&191|128;for(var ie="",ne=0;ne<y;++ne){var ut=J[ne];(ne===4||ne===6||ne===8)&&(ie+="-"),ut<16&&(ie+="0"),ie+=ut.toString(16).toLowerCase()}return ie}}function Pr(y){return y.__=void 0,delete y.__,y}})}(n||(n={})),Xi}za();const Ir=class Ir{constructor(e,t,r){u(this,"actionUrl");u(this,"queue");u(this,"allowed");u(this,"doWork");this.actionUrl=e,this.queue=t,this.allowed=r}async run(e,t,r){t===void 0&&(t=De.apiClient.url),r||(r=xt(De.apiClient.httpClient));let i=await r.post(t+"/"+this.actionUrl,e),s=i;if(s&&s.queuedJobId){let a=R.actionInfo.startBusyWithProgress();try{let o;if(await R.actionInfo.runActionWithoutBlockingUI(async()=>{for(;!o||!o.done;)o&&await new Promise(l=>setTimeout(()=>{l(void 0)},200)),o=await r.post(t+"/"+Ir.apiUrlForJobStatus,{queuedJobId:i.queuedJobId}),o.progress&&a.progress(o.progress)}),o.error)throw o.error;return a.progress(1),o.result}finally{a.close()}}else return i}__register(e){e(this.actionUrl,this.queue,this.allowed,async(t,r,i)=>{try{var s=await this.execute(t,r,i);i.success(s)}catch(a){a.isForbiddenError?i.forbidden():i.error(a,void 0)}})}};u(Ir,"apiUrlForJobStatus","jobStatusInQueue");let Zt=Ir;class ti extends Error{constructor(t="Forbidden"){super(t);u(this,"isForbiddenError",!0)}}class Ka extends Zt{constructor(t,r,i,s){super(t,i.queue??!1,i.allowed);u(this,"types");u(this,"options");u(this,"originalMethod");this.types=r,this.options=i,this.originalMethod=s}async execute(t,r,i){let s={data:{}},a=r.dataProvider;return await Ln(r,this.options,async()=>{if(!r.isAllowedForInstance(void 0,this.options.allowed))throw new ti;t.args=await xn(this.types(),t.args,r,a,i);try{s.data=await this.originalMethod(t.args)}catch(o){throw o}}),s}}function it(n){return(e,t,r)=>{const i=typeof t=="string"?t:t.name.toString(),s=r?r.value:e;let a=s;Mn(e);function o(){var d=typeof Reflect.getMetadata=="function"?Reflect.getMetadata("design:paramtypes",e,i):[];return n.paramTypes&&(d=typeof n.paramTypes=="function"?n.paramTypes():n.paramTypes),d}if(e.prototype!==void 0){let d=new Ka((n!=null&&n.apiPrefix?n.apiPrefix+"/":"")+i,()=>o(),n,c=>s.apply(void 0,c));return d.doWork=async(c,h,p,g)=>(c=tn(o(),c),n.blockUser===!1?await R.actionInfo.runActionWithoutBlockingUI(async()=>(await d.run({args:c},p,g)).data):(await d.run({args:c},p,g)).data),a=async function(...c){return Yt()?await s.apply(this,c):await d.doWork(c,void 0)},Zi(e,a),a[ei]=d,r?(r.value=a,r):a}let l=R.classHelpers.get(e.constructor);l||(l=new In,R.classHelpers.set(e.constructor,l));let f={__register(d){let c=new Ke;for(const h of l.classes.keys()){let p=l.classes.get(h);p.key||(p.key=c.repo(h).metadata.key),d(p.key+"/"+(n!=null&&n.apiPrefix?n.apiPrefix+"/":"")+i,n?n.queue??!1:!1,n.allowed,async(g,b,w)=>{g.args=g.args.map(I=>Nn(I)?void 0:I);let $=n.allowed;try{let I=b,D;await Ln(I,n,async()=>{if(g.args=await xn(o(),g.args,I,I.dataProvider,w),R.allEntities.includes(h)){let E=I.repo(h),_;const A=g.rowInfo;if(A.isNewRow)_=E.create(),await E.getEntityRef(_)._updateEntityBasedOnApi(A.data);else{let B=await E.find({where:{...E.metadata.idMetadata.getIdFilter(A.id),$and:[E.metadata.options.apiPrefilter??{}]}});if(B.length!=1)throw new Error("not found or too many matches");_=B[0],await E.getEntityRef(_)._updateEntityBasedOnApi(A.data)}if(!I.isAllowedForInstance(_,$))throw new ti;let N=ue(_);await N.__validateEntity();try{D={result:await s.apply(_,g.args),rowInfo:{data:await N.toApiJson(),isNewRow:N.isNew(),wasChanged:N.wasChanged(),id:N.getOriginalId()}}}catch(B){throw N.catchSaveErrors(B)}}else{let E=new h(I,I.dataProvider),_=Li(E,I);if(await _._updateEntityBasedOnApi(g.fields),!I.isAllowedForInstance(E,$))throw new ti;await _.__validateEntity();try{D={result:await s.apply(E,g.args),fields:await _.toApiJson()}}catch(A){throw _.catchSaveErrors(A)}}}),w.success(D)}catch(I){I.isForbiddenError?w.forbidden():w.error(I,void 0)}})}},doWork:async function(d,c,h,p){if(d=tn(o(),d),R.allEntities.includes(e.constructor)){let g=ue(c);await g.__validateEntity();let b=l.classes.get(c.constructor);b.key||(b.key=g.repository.metadata.key+"_methods");try{let w=await new class extends Zt{constructor(){super(...arguments);u(this,"execute")}}(b.key+"/"+(n!=null&&n.apiPrefix?n.apiPrefix+"/":"")+i,(n==null?void 0:n.queue)??!1,n.allowed).run({args:d,rowInfo:{data:await g.toApiJson(),isNewRow:g.isNew(),wasChanged:g.wasChanged(),id:g.getOriginalId()}},h,p);return await g._updateEntityBasedOnApi(w.rowInfo.data,!0),w.result}catch(w){throw g.catchSaveErrors(w)}}else{let g=Li(c,void 0);try{await g.__validateEntity();let b=await new class extends Zt{constructor(){super(...arguments);u(this,"execute")}}(l.classes.get(c.constructor).key+"/"+(n!=null&&n.apiPrefix?n.apiPrefix+"/":"")+i,(n==null?void 0:n.queue)??!1,n.allowed).run({args:d,fields:await g.toApiJson()},h,p);return await g._updateEntityBasedOnApi(b.fields),b.result}catch(b){throw g.catchSaveErrors(b)}}}};return a=async function(...d){let c=this;return Yt()?await s.apply(c,d):f.doWork(d,c)},Zi(e.constructor,a),a[ei]=f,r?(r.value=a,r):a}}const Xa={_isUndefined:!0};function Zi(n,e){(n[rn]||(n[rn]=[])).push(e),R.actionInfo.allActions.push(e)}function Nn(n){return n&&n._isUndefined}class en{constructor(e){u(this,"res");this.res=e}progress(e){this.res.progress(e)}}function tn(n,e){if(n)for(let t=0;t<n.length;t++){const r=n[t];for(const i of[Ke,Lt])(e[t]instanceof i||r==i)&&(e[t]=void 0);if(e[t]!=null){let i={valueType:r};if(i=fi(i,new Ke),Be(r,!1)!=null){let a=ue(e[t]);e[t]=a.getId()}i.valueConverter&&(e[t]=i.valueConverter.toJson(e[t]))}}return e.map(t=>t!==void 0?t:Xa)}async function xn(n,e,t,r,i){for(let s=0;s<e.length;s++){const a=e[s];Nn(a)&&(e[s]=void 0)}if(n)for(let s=0;s<n.length;s++)if(e.length<s&&e.push(void 0),n[s]==Ke||n[s]==Ke)e[s]=t;else if(n[s]==Lt&&r)e[s]=r;else if(n[s]==en)e[s]=new en(i);else{let a={valueType:n[s]};a=fi(a,t),a.valueConverter&&(e[s]=a.valueConverter.fromJson(e[s])),Be(n[s],!1)!=null&&(e[s]===null||e[s]===void 0||(e[s]=await t.repo(n[s]).findId(e[s])))}return e}const rn=Symbol.for("classBackendMethodsArray");async function Ln(n,e,t){if(e.transactional===void 0||e.transactional===!0)return await wa(n,t);await t(n.dataProvider)}function qn(n,e){return De.repo(n,e)}class Ya{constructor(e,t){u(this,"id");u(this,"caption");u(this,"icon");u(this,"where");u(this,"class");u(this,"hide");this.id=e.toString(),this.caption=(t==null?void 0:t.caption)??this.id,this.icon=t==null?void 0:t.icon,this.where=t==null?void 0:t.where,this.class=t==null?void 0:t.class,this.hide=t==null?void 0:t.hide,t!=null&&t.icon&&t.icon.caption===void 0&&(t.icon.caption=t==null?void 0:t.caption)}}var Za=Object.defineProperty,eo=Object.getOwnPropertyDescriptor,lt=(n,e,t,r)=>{for(var i=r>1?void 0:r?eo(e,t):e,s=n.length-1,a;s>=0;s--)(a=n[s])&&(i=(r?a(e,t,i):a(i))||i);return r&&i&&Za(e,t,i),i};let Ge=class{constructor(){u(this,"id","");u(this,"entity","");u(this,"entityId","");u(this,"changeDate",new Date);u(this,"userId","");u(this,"changes",[]);u(this,"newRow",!1);u(this,"deleted",!1)}};lt([ae.cuid()],Ge.prototype,"id",2);lt([ae.string()],Ge.prototype,"entity",2);lt([ae.string()],Ge.prototype,"entityId",2);lt([ae.date()],Ge.prototype,"changeDate",2);lt([ae.string()],Ge.prototype,"userId",2);lt([ae.json({dbName:"changesJson"})],Ge.prototype,"changes",2);lt([ae.boolean()],Ge.prototype,"newRow",2);lt([ae.boolean()],Ge.prototype,"deleted",2);Ge=lt([$n("_ff_change_logs",{caption:"FF Change Logs",allowApiCrud:!1,defaultOrderBy:{changeDate:"desc"}})],Ge);async function to(n,e,t){var r;if(Yt()){const i=[],s=new Bn(n,t),a=(t==null?void 0:t.forceNew)||e.isNew,o=(t==null?void 0:t.forceDate)||new Date;for(const l of s.fields.filter(f=>f.valueChanged()||a&&f.value))try{const f=s.excludedValues.includes(l);i.push({key:l.metadata.key,newValue:f?"***":l.value instanceof _r?l.value.id:l.metadata.options.valueConverter.toJson(l.value),oldValue:e.isNew?"---":f?"***":l.originalValue instanceof _r?l.originalValue.id:l.metadata.options.valueConverter.toJson(l.originalValue)})}catch(f){throw console.error(l),f}i.length>0&&await qn(Ge).insert({changeDate:o,changes:i,entity:e.metadata.key,entityId:e.metadata.idMetadata.getId(n),userId:((r=De.user)==null?void 0:r.id)||"",newRow:a})}}async function ro(n,e,t){var a;const r=[],i=new Bn(n,t),s=(t==null?void 0:t.forceDate)||new Date;for(const o of i.fields)try{const l=i.excludedValues.includes(o);r.push({key:o.metadata.key,newValue:l?"***":"---",oldValue:l?"***":o.originalValue instanceof _r?o.originalValue.id:o.metadata.options.valueConverter.toJson(o.originalValue)})}catch(l){throw console.error(o),l}await qn(Ge).insert({changeDate:s,changes:r,entity:e.metadata.key,entityId:e.metadata.idMetadata.getId(n),userId:((a=De.user)==null?void 0:a.id)||"",deleted:!0})}class Bn{constructor(e,t){u(this,"fields");u(this,"excludedFields");u(this,"excludedValues");const r=ue(e);t!=null&&t.excludeColumns?this.excludedFields=t.excludeColumns(r.fields):this.excludedFields=[],t!=null&&t.excludeValues?this.excludedValues=t.excludeValues(r.fields):this.excludedValues=[],this.excludedFields.push(...r.fields.toArray().filter(i=>i.metadata.options.serverExpression)),this.excludedFields.push(...r.fields.toArray().filter(i=>i.metadata.options.sqlExpression)),this.fields=r.fields.toArray().filter(i=>!this.excludedFields.includes(i))}}const Ht=n=>{if(n)return Array.isArray(n)?n.map(e=>e.id):n.id};function ci(n,e){return $n(n,{...e,allowApiCrud:e.allowApiCrud??Ht(e.permissionApiCrud),allowApiDelete:e.allowApiDelete??Ht(e.permissionApiDelete),allowApiInsert:e.allowApiInsert??Ht(e.permissionApiInsert),allowApiRead:e.allowApiRead??Ht(e.permissionApiRead),allowApiUpdate:e.allowApiUpdate??Ht(e.permissionApiUpdate),saved:async(t,r)=>{var i;await((i=e==null?void 0:e.saved)==null?void 0:i.call(e,t,r)),e.changeLog===!1||Yt()&&await to(t,r,e.changeLog)},deleted:async(t,r)=>{var i;await((i=e==null?void 0:e.deleted)==null?void 0:i.call(e,t,r)),e.changeLog===!1||Yt()&&await ro(t,r,e.changeLog)}})}var jn=Object.defineProperty,io=Object.getOwnPropertyDescriptor,no=(n,e,t)=>e in n?jn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ce=(n,e,t,r)=>{for(var i=r>1?void 0:r?io(e,t):e,s=n.length-1,a;s>=0;s--)(a=n[s])&&(i=(r?a(e,t,i):a(i))||i);return r&&i&&jn(e,t,i),i},Ar=(n,e,t)=>no(n,typeof e!="symbol"?e+"":e,t);const Tr={FF_Role_Auth_Admin:"FF_Role_Auth.Admin",FF_Role_Auth_Invite:"FF_Role_Auth.Invite"};let Xe=class{constructor(){u(this,"id");u(this,"createdAt");u(this,"updatedAt");u(this,"identifier");u(this,"roles",[]);u(this,"accounts");u(this,"sessions")}};ce([ae.cuid()],Xe.prototype,"id",2);ce([ae.createdAt()],Xe.prototype,"createdAt",2);ce([ae.updatedAt()],Xe.prototype,"updatedAt",2);ce([ae.string({validate:[He.unique(),He.required(),n=>{var e;if(((e=n.identifier)==null?void 0:e.length)<2)throw"Must be at least 2 characters long"}]})],Xe.prototype,"identifier",2);ce([ae.json(()=>[],{inputType:"selectEnum",valueConverter:{toDb:n=>n?n.join(","):[],fromDb:n=>n?n.split(",").map(e=>e.replace("{","").replace("}","")).filter(e=>e!==""):[]}})],Xe.prototype,"roles",2);ce([Er.toMany(()=>je,"userId")],Xe.prototype,"accounts",2);ce([Er.toMany(()=>bt,"userId")],Xe.prototype,"sessions",2);Xe=ce([ci("ff_auth.users",{allowApiCrud:[Tr.FF_Role_Auth_Admin,si.FF_Role_Admin],caption:"FF Auth - Users"})],Xe);let je=class{constructor(){u(this,"id");u(this,"createdAt");u(this,"updatedAt");u(this,"userId");u(this,"user");u(this,"provider",Ye.PASSWORD.id);u(this,"providerUserId","");u(this,"hashPassword");u(this,"token");u(this,"expiresAt");u(this,"lastVerifiedAt")}};ce([ae.cuid()],je.prototype,"id",2);ce([ae.createdAt()],je.prototype,"createdAt",2);ce([ae.updatedAt()],je.prototype,"updatedAt",2);ce([ae.string()],je.prototype,"userId",2);ce([Er.toOne(()=>Xe,"userId")],je.prototype,"user",2);ce([ae.string()],je.prototype,"provider",2);ce([ae.string()],je.prototype,"providerUserId",2);ce([ae.string({includeInApi:!1,allowNull:!0})],je.prototype,"hashPassword",2);ce([ae.string({includeInApi:!1,allowNull:!0})],je.prototype,"token",2);ce([ae.date({includeInApi:!1,allowNull:!0})],je.prototype,"expiresAt",2);ce([ae.date({includeInApi:!1,allowNull:!0})],je.prototype,"lastVerifiedAt",2);je=ce([ci("ff_auth.accounts",{allowApiCrud:[Tr.FF_Role_Auth_Admin,si.FF_Role_Admin],caption:"FF Auth - Accounts",changeLog:{excludeColumns:n=>[n.hashPassword,n.token]}})],je);let bt=class{constructor(){u(this,"id");u(this,"expiresAt");u(this,"userId");u(this,"user")}};ce([ae.string()],bt.prototype,"id",2);ce([ae.date()],bt.prototype,"expiresAt",2);ce([ae.string()],bt.prototype,"userId",2);ce([Er.toOne(()=>Xe,"userId")],bt.prototype,"user",2);bt=ce([ci("ff_auth.users_sessions",{allowApiCrud:[Tr.FF_Role_Auth_Admin,si.FF_Role_Admin],caption:"FF Auth - Users sessions",changeLog:!1})],bt);let Ye=class extends Ya{constructor(n,e){super(n,{...e})}};Ar(Ye,"DEMO",new Ye("DEMO",{caption:"Demo"}));Ar(Ye,"PASSWORD",new Ye("PASSWORD",{caption:"Password"}));Ar(Ye,"OTP",new Ye("OTP",{caption:"TOTP"}));Ar(Ye,"OAUTH",new Ye("OAUTH",{caption:"OAUTH"}));Ye=ce([Ra()],Ye);var so=Object.defineProperty,ao=Object.getOwnPropertyDescriptor,nt=(n,e,t,r)=>{for(var i=ao(e,t),s=n.length-1,a;s>=0;s--)(a=n[s])&&(i=a(e,t,i)||i);return i&&so(e,t,i),i},Fe,xe;const Ze=(Fe=class{static _setAbstraction(e){wi(this,xe,e)}static async signOut(){return await Qe(Fe,xe).signOut()}static async signInDemo(e){return await Qe(Fe,xe).signInDemo(e)}static async invite(e){return await Qe(Fe,xe).invite(e)}static async signUpPassword(e,t){return await Qe(Fe,xe).signUpPassword(e,t)}static async signInPassword(e,t){return await Qe(Fe,xe).signInPassword(e,t)}static async forgotPassword(e){return await Qe(Fe,xe).forgotPassword(e)}static async resetPassword(e,t){return await Qe(Fe,xe).resetPassword(e,t)}static async signInOTP(e){return await Qe(Fe,xe).signInOTP(e)}static async verifyOtp(e,t){return await Qe(Fe,xe).verifyOtp(e,t)}static async signInOAuthGetUrl(e){return await Qe(Fe,xe).signInOAuthGetUrl(e)}},xe=new WeakMap,mi(Fe,xe),Fe);nt([it({allowed:!0})],Ze,"signOut");nt([it({allowed:!0})],Ze,"signInDemo");nt([it({allowed:Tr.FF_Role_Auth_Invite})],Ze,"invite");nt([it({allowed:!0})],Ze,"signUpPassword");nt([it({allowed:!0})],Ze,"signInPassword");nt([it({allowed:!0})],Ze,"forgotPassword");nt([it({allowed:!0})],Ze,"resetPassword");nt([it({allowed:!0})],Ze,"signInOTP");nt([it({allowed:!0})],Ze,"verifyOtp");nt([it({allowed:!0})],Ze,"signInOAuthGetUrl");let Sr=Ze;function ot(n){n.focus()}Et();dt[se]="src/lib/modules/auth/components/ForgotPassword.svelte";var oo=ge(me('<div class="login"><p> </p> <form class="svelte-skcj83"><input required type="email"> <button> </button></form></div>'),dt[se],[[29,0,[[30,1],[31,1,[[32,2],[39,2]]]]]]);function dt(n,e){_t(new.target),It(e,!1,dt);let t=Me(e,"firstlyDataAuth",8),r=Me(e,"email",12,""),i=Te(""),s=Te(""),a=Te(!1);async function o(){te(i,""),te(s,""),te(a,!0);try{te(s,await Sr.forgotPassword(r()))}catch(w){w&&te(i,w.message??""),te(a,!1)}}Ot();var l=oo(),f=ee(l);let d;var c=ee(f),h=X(f,2),p=ee(h);kr(p,w=>ot==null?void 0:ot(w)),er(()=>vt(p,r));var g=X(p,2),b=ee(g);return Oe((w,$)=>{var I,D;d=Bt(f,1,"message",null,d,w),fe(c,`${W(i)??""}${W(s)??""}`),rt(p,"placeholder",(I=t().ui)==null?void 0:I.strings.email_placeholder),g.disabled=$,fe(b,(D=t().ui)==null?void 0:D.strings.send_password_reset_instructions)},[()=>({error:W(i),success:W(s)}),()=>!r()||!r().includes("@")||!r().includes(".")||W(a)],Ue),tr("submit",h,Cr(o)),Z(n,l),kt({...Ct()})}At(dt);Et();qt[se]="src/lib/modules/auth/components/ResetPassword.svelte";var lo=ge(me('<div class="login"><p> </p> <form class="svelte-skcj83"> <input type="password" required> <input type="password" required> <button> </button></form></div>'),qt[se],[[31,0,[[32,1],[33,1,[[35,2],[42,2],[48,2]]]]]]);function qt(n,e){_t(new.target),It(e,!1,qt);let t=Me(e,"firstlyDataAuth",8),r=Me(e,"password1",12,""),i=Me(e,"password2",12,""),s=Te(""),a=Te(""),o=Te(!1);async function l(){te(s,""),te(a,""),te(o,!0);const E=new URL(location.href).searchParams.get("token");try{te(a,await Sr.resetPassword(E??"",r())),window.location.href="/"}catch(_){_&&te(s,_.message??""),te(o,!1)}}Ot();var f=lo(),d=ee(f);let c;var h=ee(d),p=X(d,2),g=ee(p),b=X(g),w=X(b),$=X(w),I=X($,2),D=ee(I);return Oe(E=>{var _,A,N,B,T;c=Bt(d,1,"message",null,c,E),fe(h,`${W(s)??""}${W(a)??""}`),fe(g,`${((_=t().ui)==null?void 0:_.strings.password)??""} `),rt(b,"placeholder",(A=t().ui)==null?void 0:A.strings.password_placeholder),fe(w,` ${((N=t().ui)==null?void 0:N.strings.confirm)??""} `),rt($,"placeholder",(B=t().ui)==null?void 0:B.strings.password_placeholder),I.disabled=!r()||!i()||W(o),fe(D,(T=t().ui)==null?void 0:T.strings.reset)},[()=>({error:W(s)})],Ue),vt(b,r),vt($,i),tr("submit",p,Cr(l)),Z(n,f),kt({...Ct()})}At(qt);Et();ct[se]="src/lib/modules/auth/components/SignIn.svelte";var uo=ge(me('<form class="svelte-skcj83"><p> </p> <label> <input required type="email"></label> <label> <input required type="password"></label> <button> </button></form>'),ct[se],[[41,1,[[42,2],[43,2,[[45,3]]],[53,2,[[55,3]]],[62,2]]]]);function ct(n,e){_t(new.target),It(e,!1,ct);let t=Me(e,"firstlyDataAuth",8),r=Me(e,"view",8,"login"),i=Me(e,"email",12,""),s=Te(""),a=Te(""),o=Te(),l=Te(!1);async function f(){te(s,""),te(a,""),te(l,!0);try{await Sr.signInPassword(i(),W(o)),window.location.href=new URL(window.location.href).searchParams.get("redirect")??"/"}catch(p){p&&te(s,p.message??""),te(l,!1)}}Ot();var d=cr(),c=$e(d);{var h=p=>{var g=uo(),b=ee(g);let w;var $=ee(b),I=X(b,2),D=ee(I),E=X(D);er(()=>vt(E,i)),kr(E,O=>ot==null?void 0:ot(O));var _=X(I,2),A=ee(_),N=X(A),B=X(_,2),T=ee(B);Oe(O=>{var S,m,k,F,M;w=Bt(b,1,"message",null,w,O),fe($,`${W(s)??""}${W(a)??""}`),fe(D,`${((S=t().ui)==null?void 0:S.strings.email)??""} `),rt(E,"placeholder",(m=t().ui)==null?void 0:m.strings.email_placeholder),fe(A,`${((k=t().ui)==null?void 0:k.strings.password)??""} `),rt(N,"placeholder",(F=t().ui)==null?void 0:F.strings.password_placeholder),B.disabled=!i()||!W(o)||W(l),fe(T,(M=t().ui)==null?void 0:M.strings.btn_sign_in)},[()=>({error:W(s)})],Ue),vt(N,()=>W(o),O=>te(o,O)),tr("submit",g,Cr(f)),Z(p,g)};he(c,p=>{on(r(),"login")&&p(h)})}return Z(n,d),kt({...Ct()})}At(ct);Et();ht[se]="src/lib/modules/auth/components/SignUp.svelte";var fo=ge(me('<form class="svelte-skcj83"><p> </p> <label> <input required type="email"></label> <label> <input required type="password"></label> <button> </button></form>'),ht[se],[[40,1,[[41,2],[42,2,[[44,3]]],[52,2,[[54,3]]],[61,2]]]]);function ht(n,e){_t(new.target),It(e,!1,ht);let t=Me(e,"firstlyDataAuth",8),r=Me(e,"view",8,"login"),i=Me(e,"email",12,""),s=Te(""),a=Te(""),o=Te(),l=Te(!1);async function f(){te(s,""),te(a,""),te(l,!0);try{te(a,await Sr.signUpPassword(i(),W(o))),window.location.href="/"}catch(p){p&&te(s,p.message??""),te(l,!1)}}Ot();var d=cr(),c=$e(d);{var h=p=>{var g=fo(),b=ee(g);let w;var $=ee(b),I=X(b,2),D=ee(I),E=X(D);er(()=>vt(E,i)),kr(E,O=>ot==null?void 0:ot(O));var _=X(I,2),A=ee(_),N=X(A),B=X(_,2),T=ee(B);Oe(O=>{var S,m,k,F,M;w=Bt(b,1,"message",null,w,O),fe($,`${W(s)??""}${W(a)??""}`),fe(D,`${((S=t().ui)==null?void 0:S.strings.email)??""} `),rt(E,"placeholder",(m=t().ui)==null?void 0:m.strings.email_placeholder),fe(A,`${((k=t().ui)==null?void 0:k.strings.password)??""} `),rt(N,"placeholder",(F=t().ui)==null?void 0:F.strings.password_placeholder),B.disabled=!i()||!W(o)||W(l),fe(T,(M=t().ui)==null?void 0:M.strings.btn_sign_up)},[()=>({error:W(s)})],Ue),vt(N,()=>W(o),O=>te(o,O)),tr("submit",g,Cr(f)),Z(p,g)};he(c,p=>{on(r(),"login")&&p(h)})}return Z(n,d),kt({...Ct()})}At(ht);Et();Q[se]="src/lib/modules/auth/Page.svelte";var co=ge(me('<h1 class="svelte-1jjivcr"> </h1>'),Q[se],[[28,7]]),ho=ge(me('<!> <div class="form-footer svelte-1jjivcr"><!></div>',1),Q[se],[[35,8]]),po=ge(me("<hr> <!>",1),Q[se],[[56,10]]),yo=ge(me('<!> <div class="form-footer svelte-1jjivcr"><!> <!></div>',1),Q[se],[[49,8]]),go=ge(me('<!> <div class="form-footer svelte-1jjivcr"><!></div>',1),Q[se],[[69,8]]),mo=ge(me('<!> <div class="form-footer svelte-1jjivcr"><!></div>',1),Q[se],[[83,8]]),wo=ge(me('<img alt="Authentication" class="svelte-1jjivcr">'),Q[se],[[105,6]]),vo=ge(me('<div class="split-layout svelte-1jjivcr"><div class="form-side svelte-1jjivcr"><div class="form svelte-1jjivcr"><!> <!> <!> <!> <!></div></div> <div class="image-side svelte-1jjivcr"><!></div></div>'),Q[se],[[24,3,[[25,4,[[26,5]]],[103,4]]]]),bo=ge(me('<h1 class="svelte-1jjivcr"> </h1>'),Q[se],[[113,6]]),_o=ge(me('<!> <div class="form-footer svelte-1jjivcr"><!></div>',1),Q[se],[[120,7]]),Io=ge(me("<hr> <!>",1),Q[se],[[141,9]]),Oo=ge(me('<!> <div class="form-footer svelte-1jjivcr"><!> <!></div>',1),Q[se],[[134,7]]),ko=ge(me('<!> <div class="form-footer svelte-1jjivcr"><!></div>',1),Q[se],[[154,7]]),Co=ge(me('<!> <div class="form-footer svelte-1jjivcr"><!></div>',1),Q[se],[[168,7]]),Eo=ge(me('<div class="centered-layout svelte-1jjivcr"><div class="form svelte-1jjivcr"><!> <!> <!> <!> <!></div></div>'),Q[se],[[110,3,[[111,4]]]]),Ao=ge(me('<div class="fallback svelte-1jjivcr"><small>- 404 -</small></div> <div class="fallback svelte-1jjivcr"><small>Nothing to see here</small></div>',1),Q[se],[[190,3,[[191,4]]],[193,3,[[194,4]]]]),To=ge(me("<!> <!>",1),Q[se],[]),So=ge(me("<div><!></div>"),Q[se],[[21,0]]);function Q(n,e){_t(new.target),It(e,!1,Q);const t=Te();let i=Me(e,"firstlyData",8)().props,s=Te("");dr(()=>{},()=>{var f,d;te(t,!!((d=(f=i.ui)==null?void 0:f.images)!=null&&d.main))}),ii(),Ot();var a=So();let o;var l=ee(a);return Je(l,{children:_e(Q,(f,d)=>{var c=To(),h=$e(c);{var p=w=>{var $=vo(),I=ee($),D=ee(I),E=ee(D);{var _=x=>{var j=co(),G=ee(j,!0);Se(j),Oe(()=>fe(G,i.ui.strings.app_name)),Z(x,j)};he(E,x=>{var j;(j=i.ui)!=null&&j.strings.app_name&&x(_)})}var A=X(E,2);{var N=x=>{const j=Ue(()=>{var G;return(G=i.ui)==null?void 0:G.paths.sign_up});Je(x,{get path(){return W(j)},children:_e(Q,(G,Ce)=>{var we=ho(),U=$e(we);Tt(()=>W(s),ht),ht(U,{firstlyDataAuth:i,get email(){return W(s)},set email(ve){te(s,ve)},$$legacy:!0});var re=X(U,2),ye=ee(re);{var H=ve=>{Le(ve,{get href(){return i.ui.paths.sign_in},children:_e(Q,(be,Re)=>{ze();var pe=et();Oe(()=>fe(pe,i.ui.strings.back_to_sign_in)),Z(be,pe)}),$$slots:{default:!0}})};he(ye,ve=>{i.ui.paths.sign_in&&ve(H)})}Se(re),Z(G,we)}),$$slots:{default:!0}})};he(A,x=>{var j;(j=i.ui)!=null&&j.paths.sign_up&&x(N)})}var B=X(A,2);{var T=x=>{const j=Ue(()=>{var G;return(G=i.ui)==null?void 0:G.paths.sign_in});Je(x,{get path(){return W(j)},children:_e(Q,(G,Ce)=>{var we=yo(),U=$e(we);Tt(()=>W(s),ct),ct(U,{firstlyDataAuth:i,get email(){return W(s)},set email(Re){te(s,Re)},$$legacy:!0});var re=X(U,2),ye=ee(re);{var H=Re=>{Le(Re,{get href(){return i.ui.paths.forgot_password},children:_e(Q,(pe,Ve)=>{ze();var pt=et();Oe(()=>fe(pt,i.ui.strings.forgot_password)),Z(pe,pt)}),$$slots:{default:!0}})};he(ye,Re=>{var pe;(pe=i.ui)!=null&&pe.paths.forgot_password&&Re(H)})}var ve=X(ye,2);{var be=Re=>{var pe=po(),Ve=X($e(pe),2);Le(Ve,{get href(){return i.ui.paths.sign_up},children:_e(Q,(pt,jt)=>{ze();var Jt=et();Oe(()=>fe(Jt,i.ui.strings.btn_sign_up)),Z(pt,Jt)}),$$slots:{default:!0}}),Z(Re,pe)};he(ve,Re=>{var pe;(pe=i.ui)!=null&&pe.paths.sign_up&&Re(be)})}Se(re),Z(G,we)}),$$slots:{default:!0}})};he(B,x=>{var j;(j=i.ui)!=null&&j.paths.sign_in&&x(T)})}var O=X(B,2);{var S=x=>{const j=Ue(()=>{var G;return(G=i.ui)==null?void 0:G.paths.forgot_password});Je(x,{get path(){return W(j)},children:_e(Q,(G,Ce)=>{var we=go(),U=$e(we);Tt(()=>W(s),dt),dt(U,{firstlyDataAuth:i,get email(){return W(s)},set email(ve){te(s,ve)},$$legacy:!0});var re=X(U,2),ye=ee(re);{var H=ve=>{Le(ve,{get href(){return i.ui.paths.sign_in},children:_e(Q,(be,Re)=>{ze();var pe=et();Oe(()=>fe(pe,i.ui.strings.back_to_sign_in)),Z(be,pe)}),$$slots:{default:!0}})};he(ye,ve=>{var be;(be=i.ui)!=null&&be.paths.sign_in&&ve(H)})}Se(re),Z(G,we)}),$$slots:{default:!0}})};he(O,x=>{var j;(j=i.ui)!=null&&j.paths.forgot_password&&x(S)})}var m=X(O,2);{var k=x=>{const j=Ue(()=>{var G;return(G=i.ui)==null?void 0:G.paths.reset_password});Je(x,{get path(){return W(j)},children:_e(Q,(G,Ce)=>{var we=mo(),U=$e(we);qt(U,{firstlyDataAuth:i});var re=X(U,2),ye=ee(re);{var H=ve=>{Le(ve,{get href(){return i.ui.paths.sign_in},children:_e(Q,(be,Re)=>{ze();var pe=et();Oe(()=>fe(pe,i.ui.strings.back_to_sign_in)),Z(be,pe)}),$$slots:{default:!0}})};he(ye,ve=>{var be;(be=i.ui)!=null&&be.paths.sign_in&&ve(H)})}Se(re),Z(G,we)}),$$slots:{default:!0}})};he(m,x=>{var j;(j=i.ui)!=null&&j.paths.reset_password&&x(k)})}Se(D),Se(I);var F=X(I,2),M=ee(F);{var oe=x=>{var j=wo();Oe(()=>rt(j,"src",i.ui.images.main)),Z(x,j)};he(M,x=>{var j,G;(G=(j=i.ui)==null?void 0:j.images)!=null&&G.main&&x(oe)})}Se(F),Se($),Z(w,$)},g=w=>{var $=Eo(),I=ee($),D=ee(I);{var E=k=>{var F=bo(),M=ee(F,!0);Se(F),Oe(()=>fe(M,i.ui.strings.app_name)),Z(k,F)};he(D,k=>{var F;(F=i.ui)!=null&&F.strings.app_name&&k(E)})}var _=X(D,2);{var A=k=>{const F=Ue(()=>{var M;return(M=i.ui)==null?void 0:M.paths.sign_up});Je(k,{get path(){return W(F)},children:_e(Q,(M,oe)=>{var x=_o(),j=$e(x);Tt(()=>W(s),ht),ht(j,{firstlyDataAuth:i,get email(){return W(s)},set email(U){te(s,U)},$$legacy:!0});var G=X(j,2),Ce=ee(G);{var we=U=>{Le(U,{get href(){return i.ui.paths.sign_in},children:_e(Q,(re,ye)=>{ze();var H=et();Oe(()=>fe(H,i.ui.strings.back_to_sign_in)),Z(re,H)}),$$slots:{default:!0}})};he(Ce,U=>{i.ui.paths.sign_in&&U(we)})}Se(G),Z(M,x)}),$$slots:{default:!0}})};he(_,k=>{var F;(F=i.ui)!=null&&F.paths.sign_up&&k(A)})}var N=X(_,2);{var B=k=>{const F=Ue(()=>{var M;return(M=i.ui)==null?void 0:M.paths.sign_in});Je(k,{get path(){return W(F)},children:_e(Q,(M,oe)=>{var x=Oo(),j=$e(x);Tt(()=>W(s),ct),ct(j,{firstlyDataAuth:i,get email(){return W(s)},set email(ye){te(s,ye)},$$legacy:!0});var G=X(j,2),Ce=ee(G);{var we=ye=>{Le(ye,{get href(){return i.ui.paths.forgot_password},children:_e(Q,(H,ve)=>{ze();var be=et();Oe(()=>fe(be,i.ui.strings.forgot_password)),Z(H,be)}),$$slots:{default:!0}})};he(Ce,ye=>{var H;(H=i.ui)!=null&&H.paths.forgot_password&&ye(we)})}var U=X(Ce,2);{var re=ye=>{var H=Io(),ve=X($e(H),2);Le(ve,{get href(){return i.ui.paths.sign_up},children:_e(Q,(be,Re)=>{ze();var pe=et();Oe(()=>fe(pe,i.ui.strings.btn_sign_up)),Z(be,pe)}),$$slots:{default:!0}}),Z(ye,H)};he(U,ye=>{var H;(H=i.ui)!=null&&H.paths.sign_up&&ye(re)})}Se(G),Z(M,x)}),$$slots:{default:!0}})};he(N,k=>{var F;(F=i.ui)!=null&&F.paths.sign_in&&k(B)})}var T=X(N,2);{var O=k=>{const F=Ue(()=>{var M;return(M=i.ui)==null?void 0:M.paths.forgot_password});Je(k,{get path(){return W(F)},children:_e(Q,(M,oe)=>{var x=ko(),j=$e(x);Tt(()=>W(s),dt),dt(j,{firstlyDataAuth:i,get email(){return W(s)},set email(U){te(s,U)},$$legacy:!0});var G=X(j,2),Ce=ee(G);{var we=U=>{Le(U,{get href(){return i.ui.paths.sign_in},children:_e(Q,(re,ye)=>{ze();var H=et();Oe(()=>fe(H,i.ui.strings.back_to_sign_in)),Z(re,H)}),$$slots:{default:!0}})};he(Ce,U=>{var re;(re=i.ui)!=null&&re.paths.sign_in&&U(we)})}Se(G),Z(M,x)}),$$slots:{default:!0}})};he(T,k=>{var F;(F=i.ui)!=null&&F.paths.forgot_password&&k(O)})}var S=X(T,2);{var m=k=>{const F=Ue(()=>{var M;return(M=i.ui)==null?void 0:M.paths.reset_password});Je(k,{get path(){return W(F)},children:_e(Q,(M,oe)=>{var x=Co(),j=$e(x);qt(j,{firstlyDataAuth:i});var G=X(j,2),Ce=ee(G);{var we=U=>{Le(U,{get href(){return i.ui.paths.sign_in},children:_e(Q,(re,ye)=>{ze();var H=et();Oe(()=>fe(H,i.ui.strings.back_to_sign_in)),Z(re,H)}),$$slots:{default:!0}})};he(Ce,U=>{var re;(re=i.ui)!=null&&re.paths.sign_in&&U(we)})}Se(G),Z(M,x)}),$$slots:{default:!0}})};he(S,k=>{var F;(F=i.ui)!=null&&F.paths.reset_password&&k(m)})}Se(I),Se($),Z(w,$)};he(h,w=>{W(t)?w(p):w(g,!1)})}var b=X(h,2);Je(b,{fallback:!0,children:_e(Q,(w,$)=>{var I=Ao();ze(2),Z(w,I)}),$$slots:{default:!0}}),Z(f,c)}),$$slots:{default:!0}}),Oe(f=>o=Bt(a,1,"wrapper svelte-1jjivcr",null,o,f),[()=>({"with-image":W(t)})],Ue),Z(n,a),kt({...Ct()})}At(Q);export{Q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{v as r,x as l,aa as o,J as m,K as p,M as u,O as d,P as f,R as g}from"./index-C9jzxOBu.js";d();a[f]="src/lib/modules/storage/Page.svelte";function a(e,s){r(new.target),l(s,!1,a);var t=o("Hello from files");return m(e,t),p({...u()})}g(a);export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
form.svelte-skcj83{display:flex;flex-direction:column}h1.svelte-1jjivcr{text-align:center;margin-bottom:2rem}.wrapper.svelte-1jjivcr{min-height:100vh;display:flex;justify-content:center;align-items:center;margin:0 auto}.centered-layout.svelte-1jjivcr{display:flex;justify-content:center;align-items:center;width:100%}.split-layout.svelte-1jjivcr{display:flex;width:100%;min-height:100vh}.form-side.svelte-1jjivcr{width:50%;display:flex;justify-content:center;align-items:center}.image-side.svelte-1jjivcr{width:50%;height:100vh;overflow:hidden}.image-side.svelte-1jjivcr img:where(.svelte-1jjivcr){width:100%;height:100%;object-fit:cover}.form.svelte-1jjivcr{max-width:360px;width:100%;padding:1rem;display:flex;flex-direction:column}.form-footer.svelte-1jjivcr{margin-top:1rem;display:flex;flex-direction:column;justify-content:center;align-items:center}.fallback.svelte-1jjivcr{display:flex;justify-content:center;align-items:center}@media (max-width: 768px){.split-layout.svelte-1jjivcr{flex-direction:column}.form-side.svelte-1jjivcr{width:100%;order:2}.image-side.svelte-1jjivcr{width:100%;height:50vh;order:1}.form.svelte-1jjivcr{max-width:100%}}
|