firstly 0.1.0-next.3 → 0.1.0-next.4
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 +9 -0
- package/esm/auth/Entities.d.ts +2 -2
- package/esm/auth/Entities.js +1 -1
- package/esm/auth/static/assets/Page-5iUUg7GN.d.ts +2 -0
- package/esm/auth/static/assets/Page-5iUUg7GN.js +1 -0
- package/esm/auth/static/assets/Page-BcSzu3xq.d.ts +2 -0
- package/esm/auth/static/assets/Page-BcSzu3xq.js +20 -0
- package/esm/auth/static/assets/Page-sEK21EQB.d.ts +2 -0
- package/esm/auth/static/assets/Page-sEK21EQB.js +1 -0
- package/esm/auth/static/assets/index-RpcgeXPm.d.ts +232 -0
- package/esm/auth/static/assets/index-RpcgeXPm.js +2 -0
- package/esm/auth/static/index.html +1 -1
- package/esm/bin/cmd.js +5 -5
- package/esm/feedback/ui/DialogIssue.svelte +8 -1
- package/esm/feedback/ui/DialogIssues.svelte +1 -1
- package/esm/feedback/ui/DialogMilestones.svelte +2 -3
- package/esm/feedback/ui/Feedback.svelte +1 -1
- package/esm/formats/dates.js +1 -1
- package/esm/index.d.ts +3 -83
- package/esm/index.js +3 -45
- package/esm/{FF_Entity.js → internals/FF_Entity.js} +1 -1
- package/esm/{FF_Fields.js → internals/FF_Fields.js} +1 -1
- package/esm/{cellsBuildor.d.ts → internals/cellsBuildor.d.ts} +1 -1
- package/esm/{common.d.ts → internals/common.d.ts} +0 -2
- package/esm/internals/common.js +3 -0
- package/esm/{helper.js → internals/helper.js} +1 -1
- package/esm/internals/index.d.ts +83 -0
- package/esm/internals/index.js +45 -0
- package/esm/{storeItem.js → internals/storeItem.js} +2 -2
- package/esm/svelte/dialog/DialogPrimitive.svelte +1 -1
- package/esm/svelte/dialog/DialogPrimitive.svelte.d.ts +1 -1
- package/esm/svelte/dialog/dialog.d.ts +1 -1
- package/esm/svelte/dialog/dialog.js +1 -1
- package/esm/ui/Button.svelte +1 -1
- package/esm/ui/Button.svelte.d.ts +1 -1
- package/esm/ui/Field.svelte +2 -2
- package/esm/ui/Field.svelte.d.ts +1 -1
- package/esm/ui/FieldGroup.svelte +2 -2
- package/esm/ui/FieldGroup.svelte.d.ts +3 -3
- package/esm/ui/Grid.svelte +3 -3
- package/esm/ui/Grid.svelte.d.ts +2 -2
- package/esm/ui/Grid2.svelte +3 -3
- package/esm/ui/Grid2.svelte.d.ts +1 -1
- package/esm/ui/dialog/DialogForm.svelte +2 -2
- package/esm/ui/dialog/DialogPrimitive.svelte +1 -1
- package/esm/ui/dialog/DialogPrimitive.svelte.d.ts +1 -1
- package/esm/ui/dialog/FormEditAction.svelte +1 -1
- package/esm/ui/dialog/FormEditAction.svelte.d.ts +1 -1
- package/esm/ui/dialog/dialog.d.ts +1 -1
- package/esm/ui/dialog/dialog.js +1 -1
- package/esm/ui/index.d.ts +1 -1
- package/esm/ui/internals/Textarea.svelte +1 -1
- package/esm/ui/internals/select/MultiSelectMelt.svelte +1 -1
- package/esm/ui/internals/select/MultiSelectMelt.svelte.d.ts +1 -1
- package/esm/ui/internals/select/SelectMelt.svelte +1 -1
- package/esm/ui/internals/select/SelectMelt.svelte.d.ts +1 -1
- package/esm/ui/internals/select/SelectRadio.svelte +1 -1
- package/esm/ui/internals/select/SelectRadio.svelte.d.ts +1 -1
- package/esm/ui/link/LinkPlus.svelte +1 -1
- package/esm/ui/link/LinkPlus.svelte.d.ts +1 -1
- package/esm/virtual/Customer.js +1 -1
- package/esm/virtual/StateDemoEnum.d.ts +2 -2
- package/esm/virtual/StateDemoEnum.js +1 -1
- package/esm/virtual/UIEntity.js +1 -1
- package/package.json +5 -1
- package/esm/ROUTES.d.ts +0 -102
- package/esm/ROUTES.js +0 -106
- package/esm/auth/static/assets/Page-CTZPxniP.d.ts +0 -6
- package/esm/auth/static/assets/Page-CTZPxniP.js +0 -1
- package/esm/auth/static/assets/Page-D0d9iZO-.d.ts +0 -6
- package/esm/auth/static/assets/Page-D0d9iZO-.js +0 -1
- package/esm/auth/static/assets/Page-DXshwJi7.d.ts +0 -6
- package/esm/auth/static/assets/Page-DXshwJi7.js +0 -20
- package/esm/auth/static/assets/index-LRDptjak.d.ts +0 -217
- package/esm/auth/static/assets/index-LRDptjak.js +0 -44
- package/esm/common.js +0 -8
- /package/esm/{BaseEnum.d.ts → internals/BaseEnum.d.ts} +0 -0
- /package/esm/{BaseEnum.js → internals/BaseEnum.js} +0 -0
- /package/esm/{FF_Entity.d.ts → internals/FF_Entity.d.ts} +0 -0
- /package/esm/{FF_Fields.d.ts → internals/FF_Fields.d.ts} +0 -0
- /package/esm/{cellsBuildor.js → internals/cellsBuildor.js} +0 -0
- /package/esm/{helper.d.ts → internals/helper.d.ts} +0 -0
- /package/esm/{storeItem.d.ts → internals/storeItem.d.ts} +0 -0
- /package/esm/{storeList.d.ts → internals/storeList.d.ts} +0 -0
- /package/esm/{storeList.js → internals/storeList.js} +0 -0
- /package/esm/{theme.d.ts → internals/theme.d.ts} +0 -0
- /package/esm/{theme.js → internals/theme.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# firstly
|
|
2
2
|
|
|
3
|
+
## 0.1.0-next.4
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#153](https://github.com/jycouet/firstly/pull/153)
|
|
8
|
+
[`f8ca698`](https://github.com/jycouet/firstly/commit/f8ca698aa2b4ec7cfe77f6e63486c0bf9a124946)
|
|
9
|
+
Thanks [@jycouet](https://github.com/jycouet)! - all root import ... from `firstly` moved to
|
|
10
|
+
`firstly/internals` (we will gradually add them back when needed
|
|
11
|
+
|
|
3
12
|
## 0.1.0-next.3
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/esm/auth/Entities.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from 'arctic';
|
|
2
|
-
import { BaseEnum } from '
|
|
3
|
-
import type { BaseEnumOptions } from '
|
|
2
|
+
import { BaseEnum } from '../internals';
|
|
3
|
+
import type { BaseEnumOptions } from '../internals';
|
|
4
4
|
import type { OAuth2UserInfo } from './types';
|
|
5
5
|
export declare const FF_Role_Auth: {
|
|
6
6
|
readonly FF_Role_Auth_Admin: "FF_Role_Auth.Admin";
|
package/esm/auth/Entities.js
CHANGED
|
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
var FFAuthProvider_1;
|
|
8
8
|
import { Fields, Relations, Validators, ValueListFieldType } from 'remult';
|
|
9
|
-
import { BaseEnum, FF_Entity, FF_Role } from '
|
|
9
|
+
import { BaseEnum, FF_Entity, FF_Role } from '../internals';
|
|
10
10
|
export const FF_Role_Auth = {
|
|
11
11
|
FF_Role_Auth_Admin: 'FF_Role_Auth.Admin',
|
|
12
12
|
FF_Role_Auth_Invite: 'FF_Role_Auth.Invite',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{aa as t,U as o}from"./index-RpcgeXPm.js";function r(a){var e=t("Hello from files");o(a,e)}export{r as default};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var jn=Object.defineProperty;var Kr=i=>{throw TypeError(i)};var Jn=(i,e,t)=>e in i?jn(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var f=(i,e,t)=>Jn(i,typeof e!="symbol"?e+"":e,t),Xr=(i,e,t)=>e.has(i)||Kr("Cannot "+t);var Re=(i,e,t)=>(Xr(i,e,"read from private field"),t?t.call(i):e.get(i)),Yr=(i,e,t)=>e.has(i)?Kr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),Zr=(i,e,t,r)=>(Xr(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t);import{t as Ce,a as Un,r as Vn,c as Wn,b as Hn,g as Lt,e as it,u as le,d as xi,f as Tr,h as Bi,i as ji,j as Gn,k as Qn,l as zn,m as V,A as Kn,L as Xn,n as Yn,o as Zn,p as Ji,q as es,s as ts,N as rs,v as is,w as ns,x as ss,y as as,z as os,B as ls,C as $r,D as us,E as Ui,F as rr,G as ze,H as fs,I as Ee,J as ei,K as ds,M as ti,O as Sr,P as Vi,Q as pt,R as St,S as Se,T as me,U as X,V as Ke,W as Wi,X as ut,Y as ae,Z as cs,_ as ri,$ as Z,a0 as Ie,a1 as ue,a2 as Q,a3 as Dt,a4 as G,a5 as ir,a6 as oe,a7 as hs,a8 as wt,a9 as ys,aa as vt}from"./index-RpcgeXPm.js";function ps(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function ms(i,e,t=!1,r=!1,n=!1){var s=i,a="";Ce(()=>{var o=Un;if(a!==(a=e()??"")&&(o.nodes_start!==null&&(Vn(o.nodes_start,o.nodes_end),o.nodes_start=o.nodes_end=null),a!=="")){var l=a+"";t?l=`<svg>${l}</svg>`:r&&(l=`<math>${l}</math>`);var u=Wn(l);if((t||r)&&(u=Lt(u)),Hn(Lt(u),u.lastChild),t||r)for(;Lt(u);)s.before(Lt(u));else s.before(u)}})}function Hi(i,e,t,r,n){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(i,a?()=>r:r)}function nr(i,e,t){it(()=>{var r=le(()=>e(i,t==null?void 0:t())||{});if(r!=null&&r.destroy)return()=>r.destroy()})}function gs(i,e){var t=void 0,r;xi(()=>{t!==(t=e())&&(r&&(Tr(r),r=null),t&&(r=Bi(()=>{it(()=>t(i))})))})}function Gi(i){var e,t,r="";if(typeof i=="string"||typeof i=="number")r+=i;else if(typeof i=="object")if(Array.isArray(i)){var n=i.length;for(e=0;e<n;e++)i[e]&&(t=Gi(i[e]))&&(r&&(r+=" "),r+=t)}else for(t in i)i[t]&&(r&&(r+=" "),r+=t);return r}function ws(){for(var i,e,t=0,r="",n=arguments.length;t<n;t++)(i=arguments[t])&&(e=Gi(i))&&(r&&(r+=" "),r+=e);return r}function vs(i){return typeof i=="object"?ws(i):i??""}const ii=[...`
|
|
2
|
+
\r\f \v\uFEFF`];function bs(i,e,t){var r=i==null?"":""+i;if(e&&(r=r?r+" "+e:e),t){for(var n in t)if(t[n])r=r?r+" "+n:n;else if(r.length)for(var s=n.length,a=0;(a=r.indexOf(n,a))>=0;){var o=a+s;(a===0||ii.includes(r[a-1]))&&(o===r.length||ii.includes(r[o]))?r=(a===0?"":r.substring(0,a))+r.substring(o+1):a=o}}return r===""?null:r}function ni(i,e=!1){var t=e?" !important;":";",r="";for(var n in i){var s=i[n];s!=null&&s!==""&&(r+=" "+n+": "+s+t)}return r}function cr(i){return i[0]!=="-"||i[1]!=="-"?i.toLowerCase():i}function _s(i,e){if(e){var t="",r,n;if(Array.isArray(e)?(r=e[0],n=e[1]):r=e,i){i=String(i).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var s=!1,a=0,o=!1,l=[];r&&l.push(...Object.keys(r).map(cr)),n&&l.push(...Object.keys(n).map(cr));var u=0,d=-1;const b=i.length;for(var c=0;c<b;c++){var h=i[c];if(o?h==="/"&&i[c-1]==="*"&&(o=!1):s?s===h&&(s=!1):h==="/"&&i[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 y=cr(i.substring(u,d).trim());if(!l.includes(y)){h!==";"&&c++;var p=i.substring(u,c).trim();t+=" "+p+";"}}u=c+1,d=-1}}}}return r&&(t+=ni(r)),n&&(t+=ni(n,!0)),t=t.trim(),t===""?null:t}return i==null?null:String(i)}function mt(i,e,t,r,n,s){var a=i.__className;if(a!==t||a===void 0){var o=bs(t,r,s);o==null?i.removeAttribute("class"):e?i.className=o:i.setAttribute("class",o),i.__className=t}else if(s&&n!==s)for(var l in s){var u=!!s[l];(n==null||u!==!!n[l])&&i.classList.toggle(l,u)}return s}function hr(i,e={},t,r){for(var n in t){var s=t[n];e[n]!==s&&(t[n]==null?i.style.removeProperty(n):i.style.setProperty(n,s,r))}}function Is(i,e,t,r){var n=i.__style;if(n!==e){var s=_s(e,r);s==null?i.removeAttribute("style"):i.style.cssText=s,i.__style=e}else r&&(Array.isArray(r)?(hr(i,t==null?void 0:t[0],r[0]),hr(i,t==null?void 0:t[1],r[1],"important")):hr(i,t,r));return r}function Fr(i,e,t){if(i.multiple){if(e==null)return;if(!ji(e))return ps();for(var r of i.options)r.selected=e.includes(si(r));return}for(r of i.options){var n=si(r);if(Gn(n,e)){r.selected=!0;return}}(!t||e!==void 0)&&(i.selectedIndex=-1)}function Os(i){var e=new MutationObserver(()=>{Fr(i,i.__value)});e.observe(i,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Qn(()=>{e.disconnect()})}function si(i){return"__value"in i?i.__value:i.value}const bt=Symbol("class"),_t=Symbol("style"),Qi=Symbol("is custom element"),zi=Symbol("is html");function ks(i,e){e?i.hasAttribute("selected")||i.setAttribute("selected",""):i.removeAttribute("selected")}function $e(i,e,t,r){var n=Ki(i);n[e]!==(n[e]=t)&&(e==="loading"&&(i[Xn]=t),t==null?i.removeAttribute(e):typeof t!="string"&&Xi(i).includes(e)?i[e]=t:i.setAttribute(e,t))}function Cs(i,e,t,r,n=!1){var s=Ki(i),a=s[Qi],o=!s[zi],l=e||{},u=i.tagName==="OPTION";for(var d in e)d in t||(t[d]=null);t.class?t.class=vs(t.class):t[bt]&&(t.class=null),t[_t]&&(t.style??(t.style=null));var c=Xi(i);for(const k in t){let M=t[k];if(u&&k==="value"&&M==null){i.value=i.__value="",l[k]=M;continue}if(k==="class"){var h=i.namespaceURI==="http://www.w3.org/1999/xhtml";mt(i,h,M,r,e==null?void 0:e[bt],t[bt]),l[k]=M,l[bt]=t[bt];continue}if(k==="style"){Is(i,M,e==null?void 0:e[_t],t[_t]),l[k]=M,l[_t]=t[_t];continue}var y=l[k];if(!(M===y&&!(M===void 0&&i.hasAttribute(k)))){l[k]=M;var p=k[0]+k[1];if(p!=="$$")if(p==="on"){const T={},g="$$"+k;let O=k.slice(2);var b=ns(O);if(Yn(O)&&(O=O.slice(0,-7),T.capture=!0),!b&&y){if(M!=null)continue;i.removeEventListener(O,l[g],T),l[g]=null}if(M!=null)if(b)i[`__${O}`]=M,Ji([O]);else{let F=function(N){l[k].call(this,N)};l[g]=Zn(O,i,F,T)}else b&&(i[`__${O}`]=void 0)}else if(k==="style")$e(i,k,M);else if(k==="autofocus")es(i,!!M);else if(!a&&(k==="__value"||k==="value"&&M!=null))i.value=i.__value=M;else if(k==="selected"&&u)ks(i,M);else{var w=k;o||(w=ts(w));var P=w==="defaultValue"||w==="defaultChecked";if(M==null&&!a&&!P)if(s[k]=null,w==="value"||w==="checked"){let T=i;const g=e===void 0;if(w==="value"){let O=T.defaultValue;T.removeAttribute(w),T.defaultValue=O,T.value=T.__value=g?O:null}else{let O=T.defaultChecked;T.removeAttribute(w),T.defaultChecked=O,T.checked=g?O:!1}}else i.removeAttribute(k);else P||c.includes(w)&&(a||typeof M!="string")?i[w]=M:typeof M!="function"&&$e(i,w,M)}}}return l}function As(i,e,t=[],r,n=!1,s=zn){const a=t.map(s);var o=void 0,l={},u=i.nodeName==="SELECT",d=!1;if(xi(()=>{var h=e(...a.map(V)),y=Cs(i,o,h,r,n);d&&u&&"value"in h&&Fr(i,h.value,!1);for(let b of Object.getOwnPropertySymbols(l))h[b]||Tr(l[b]);for(let b of Object.getOwnPropertySymbols(h)){var p=h[b];b.description===Kn&&(!o||p!==o[b])&&(l[b]&&Tr(l[b]),l[b]=Bi(()=>gs(i,()=>p))),y[b]=p}o=y}),u){var c=i;it(()=>{Fr(c,o.value),Os(c)})}d=!0}function Ki(i){return i.__attributes??(i.__attributes={[Qi]:i.nodeName.includes("-"),[zi]:i.namespaceURI===rs})}var ai=new Map;function Xi(i){var e=ai.get(i.nodeName);if(e)return e;ai.set(i.nodeName,e=[]);for(var t,r=i,n=Element.prototype;n!==r;){t=ss(r);for(var s in t)t[s].set&&e.push(s);r=is(r)}return e}function tt(i,e,t=e){var r=as();os(i,"input",n=>{var s=n?i.defaultValue:i.value;if(s=yr(i)?pr(s):s,t(s),r&&s!==(s=e())){var a=i.selectionStart,o=i.selectionEnd;i.value=s??"",o!==null&&(i.selectionStart=a,i.selectionEnd=Math.min(o,i.value.length))}}),le(e)==null&&i.value&&t(yr(i)?pr(i.value):i.value),ls(()=>{var n=e();yr(i)&&n===pr(i.value)||i.type==="date"&&!n&&!i.value||n!==i.value&&(i.value=n??"")})}function yr(i){var e=i.type;return e==="number"||e==="range"}function pr(i){return i===""?null:+i}function sr(i){return function(...e){var t=e[0];return t.preventDefault(),i==null?void 0:i.apply(this,e)}}function Es(i,e){var s;var t=(s=i.$$events)==null?void 0:s[e.type],r=ji(t)?t.slice():t==null?[]:[t];for(var n of r)n.call(this,e)}const Ts=i=>{const{subscribe:e,update:t}=$r(i);return{subscribe:e,set:(r={})=>{t(n=>Object.assign(n,r))}}},ar=Ts({mode:"window",basePath:null}),mr=(i=us(ar).mode)=>{let e="popstate";i==="window"&&(e="popstate"),i==="hash"&&(e="hashchange"),window.dispatchEvent(new Event(e))},oi={go:(i=0)=>{history.go(i),mr()},push:(i,e=null)=>{history.pushState(e,"",i),mr()},replace:(i,e=null)=>{history.replaceState(e,"",i),mr()}},Ss=i=>{const e=i.match(/^(\/[^?#]*)?/),t=i.match(/\?([^#]*)?/),r=i.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]}`:""}},li=()=>{const{pathname:i,search:e,hash:t}=document.location;return{path:i,query:e,hash:t}},ui=()=>{let i=document.location.hash.substring(1);return i[0]!=="/"&&(i="/"+i),Ss(i)},Fs=Ui(li(),i=>{const e=()=>i(li());return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),Ps=Ui(ui(),i=>{const e=()=>i(ui());return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}),qr=rr([ar,Fs,Ps],([i,e,t],r)=>{i.mode==="window"&&r(e),i.mode==="hash"&&r(t)}),Rs=rr(qr,i=>i.path);rr(qr,i=>i.query);rr(qr,i=>i.hash);const Ds=()=>{let i=0;return()=>i++},Bt=i=>i.split(/(?=\/)/),fi=(i,e)=>e===null?i:i.startsWith(e)?i.slice(e.length):i,Ms=(i,e,t,r,n)=>{const s=(u,d,c)=>{const h=Bt(d).filter(y=>y!=="/").length;return(c??0)+(u?1:h)},a=(u,d)=>{const c={invalidPath:`<Route path="${u==null?void 0:u.path}" /> has invalid path. Path must start with '/'`,fallbackOutsideRoot:"<Route fallback /> cannot be outside root <Route />",pathOutsideRoot:`<Route path="${u==null?void 0:u.path}" /> cannot be outside root <Route />`,fallbackInsideFallback:"<Route fallback /> cannot be inside <Route fallback>",pathInsideFallback:`<Route path="${u==null?void 0:u.path}" /> cannot be inside <Route fallback>`};if(u.path[0]!=="/")throw new Error(c.invalidPath);if(u.root&&u.fallback)throw new Error(c.fallbackOutsideRoot);if(u.root&&u.path!=="/")throw new Error(c.pathOutsideRoot);if(d!=null&&d.fallback&&u.fallback)throw new Error(c.fallbackInsideFallback);if(d!=null&&d.fallback&&!u.fallback)throw new Error(c.pathInsideFallback)},o=s(t,r,n==null?void 0:n.depth),l={id:i,root:e,fallback:t,path:r,depth:o};return a(l,n),l},Ns=()=>{const{subscribe:i,update:e}=$r([]);return{subscribe:i,update:t=>e(r=>[...r.filter(n=>t.id!==n.id),t]),remove:t=>e(r=>r.filter(n=>t.id!==n.id))}},Ls=(i,e,t)=>{const r=(u,d,c,h)=>{let y=Bt(u).filter(w=>w!=="/"),p=Bt(c).filter(w=>w!=="/"),b="";if(c==="/")return d||y.length===h;for(let w=h-p.length;w<h;w++)b=b+y[w];return c===b},n=(u,d,c)=>{var p,b,w,P;let h=Bt(u).filter(k=>k!=="/"),y=!1;for(let k=0;k<(c==null?void 0:c.length)&&!y;k++)(p=c[k])!=null&&p.fallback||(y=r(u,((b=c[k])==null?void 0:b.root)??!1,((w=c[k])==null?void 0:w.path)??"",((P=c[k])==null?void 0:P.depth)??0));return h.length>=d&&!y},{root:s,fallback:a,path:o,depth:l}=e;return a?n(i,l,t):r(i,s,o,l)},$s=Ds(),gr={},di={};function at(i,e){ze(e,!1);const[t,r]=Wi(),n=()=>ut(y,"$route",t),s=()=>ut(p,"$contextRoute",t),a=()=>ut(Rs,"$globalPath",t),o=()=>ut(ar,"$options",t),l=()=>ut(w,"$contextChildRoutes",t),u=$s(),d=!fs(gr);let c=Ee(e,"fallback",9,!1),h=Ee(e,"path",9,"/");const y=$r(),p=ei(gr),b=Ns(),w=ei(di);ds(()=>w==null?void 0:w.remove(n())),ti(gr,y),ti(di,b),Sr(()=>(ae(c()),ae(h()),s()),()=>{cs(y,Ms(u,d,c(),h(),s()))}),Sr(()=>n(),()=>{w==null||w.update(n())}),Vi(),pt(!0);var P=St(),k=Se(P);{var M=T=>{var g=St(),O=Se(g);Hi(O,e,"default",{}),X(T,g)};me(k,T=>{ae(fi),a(),o(),n(),l(),le(()=>Ls(fi(a(),o().basePath),n(),l()))&&T(M)})}X(i,P),Ke(),r()}const ci=i=>{var o;const e=(o=i.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"),n=(e.getAttribute("target")??"_self")!=="_self",s=i.metaKey||i.ctrlKey||i.altKey||i.shiftKey,a=new URL(t).origin!==document.location.origin;if(r||n||s||a)return!0;t===document.location.href?oi.replace(t):oi.push(t),i.preventDefault()},wr=i=>(i.addEventListener("click",ci),{destroy:()=>{i.removeEventListener("click",ci)}}),qs=(i,e,t)=>(i==="hash"?"#":"")+(e??"")+t;var xs=ue("<a><!></a>");function It(i,e){const t=ri(e,["children","$$slots","$$events","$$legacy"]),r=ri(t,["href"]);ze(e,!1);const[n,s]=Wi(),a=()=>ut(ar,"$options",n),o=Ie(void 0,!0);let l=Ee(e,"href",9);Sr(()=>(a(),ae(l())),()=>{Z(o,qs(a().mode,a().basePath,l()))}),Vi(),pt(!0);var u=xs();As(u,()=>({href:V(o),...r}));var d=Q(u);Hi(d,e,"default",{}),nr(u,c=>wr==null?void 0:wr(c)),it(()=>Dt("click",u,function(c){Es.call(this,e,c)})),X(i,u),Ke(),s()}class Ye{constructor(...e){f(this,"fields");f(this,"options",{});f(this,"target");f(this,"readonly",!0);f(this,"allowNull",!1);f(this,"dbReadOnly",!1);f(this,"isServerExpression",!1);f(this,"key","");f(this,"label","");f(this,"caption","");f(this,"inputType","");f(this,"dbName","");f(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=n=>e[n.key];typeof e=="function"&&(t=e);let r="";return this.fields.forEach(n=>{r.length>0&&(r+=","),r+=n.valueConverter.toJson(t(n))}),r}get valueConverter(){throw new Error("cant get value converter of compound id")}isEqualTo(e){let t={},n=e.toString().split(",");return this.fields.forEach((s,a)=>{t[s.key]=s.valueConverter.fromJson(n[a])}),t}}function ie(i,e=!0){var r;if(i===void 0)throw new Error("entity is undefined");let t=i[Xe];if(!t&&e)throw new Error("item "+(((r=i.constructor)==null?void 0:r.name)||i)+" was not initialized using a context");return t}const Xe=Symbol.for("entityMember"),Yi=Symbol.for("entityInfo"),Zi=Symbol.for("entityInfo_key");function Oe(i,e=!0){if(i===void 0){if(e)throw new Error("Undefined is not an entity :)");return}let t=i[Yi];if(!t&&e)throw new Error(i.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 Bs(i){return i[Zi]}function vr(i,e){return{[en]:{toType:i,type:e}}}const en=Symbol.for("relationInfo");function js(i){return i==null?void 0:i[en]}const Pr=Symbol.for("fieldRelationInfo");function ne(i){if(i)return i[Pr]}function Js(i,e,t){for(const r of i.fields.toArray()){const n=js(r.options);if(n&&!r[Pr]){const s=n.toType(),a=e.repo(s,t),o=r.options;r[Pr]={type:n.type,toEntity:s,options:o,toRepo:a,getFields:()=>{let l=o.field,u={fields:o.fields,compoundIdField:void 0};function d(y){return Error(`Error for relation: "${i.metadata.key}.${r.key}", `+y)}let c=()=>l||u.fields;if(n.type==="toMany"&&!c()){for(const y of a.fields.toArray())if(!c()){const p=ne(y),b=y.options;if(p&&p.toEntity===i.metadata.entityType){if(p.type==="reference")l=y.key;else if(p.type==="toOne"){if(b.field)l=b.field;else if(b.fields){let w={};for(const P in b.fields)if(Object.prototype.hasOwnProperty.call(b.fields,P)){const k=b.fields[P];w[k]=P}u.fields=w}}}}if(!c())throw d(`No matching field found on target "${a.metadata.key}". Please specify field/fields`)}function h(y,p){const b=p.fields.find(y);if(!b)throw d(`Field "${y}" was not found in "${p.key}".`);return b}n.type==="reference"&&(l=r.key),l&&(n.type==="toOne"||n.type==="reference"?a.metadata.idMetadata.field instanceof Ye?u.compoundIdField=l:u.fields={[a.metadata.idMetadata.field.key]:l}:i.metadata.idMetadata.field instanceof Ye?u.compoundIdField=l:u.fields={[l]:i.metadata.idMetadata.field.key});for(const y in u.fields)Object.prototype.hasOwnProperty.call(u.fields,y)&&(h(y,a.metadata),h(u.fields[y],i.metadata));return u}}}}}class L{constructor(e){f(this,"apply");this.apply=e}static throwErrorIfFilterIsEmpty(e,t){if(L.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(!L.isFilterEmpty(t))return!1}if(e.$or){for(const t of e.$or)if(L.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 zt;return await L.fromEntityFilter(e,t).__applyToConsumer(r),r.preciseValues}async getPreciseValues(){const e=new zt;return await this.__applyToConsumer(e),e.preciseValues}static createCustom(e,t=""){let r={key:t,rawFilterTranslator:e};return Object.assign(n=>{if(n==null&&(n={}),!r.key)throw"Usage of custom filter before a key was assigned to it";return{[Ze+r.key]:n}},{rawFilterInfo:r})}static entityFilterToJson(e,t){return L.fromEntityFilter(e,t).toJson()}static entityFilterFromJson(e,t){return jt(e,{get:r=>t[r]})}static fromEntityFilter(e,t){let r=[];for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let s=t[n];if(n=="$or")r.push(new Ws(...s.map(a=>L.fromEntityFilter(e,a))));else if(n=="$not")r.push(new Hs(L.fromEntityFilter(e,s)));else if(n=="$and")r.push(new hi(...s.map(a=>L.fromEntityFilter(e,a))));else if(n.startsWith(Ze))r.push(new L(a=>{a.custom(n.substring(Ze.length),s)}));else if(n==tn)r.push(new L(a=>a.databaseCustom(s)));else{const a=e.fields[n],o=ne(a),l=a.options;let u=(o==null?void 0:o.type)==="toOne"?l.fields?new Vs(a,e.fields,l):new Us(e.fields[l.field]):new Ht(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(u.isGreaterOrEqualTo(h)),d=!0;break;case"$gt":case">":r.push(u.isGreaterThan(h)),d=!0;break;case"$lte":case"<=":r.push(u.isLessOrEqualTo(h)),d=!0;break;case"$lt":case"<":r.push(u.isLessThan(h)),d=!0;break;case"$ne":case"$not":case"!=":case"$nin":d=!0,Array.isArray(h)?r.push(u.isNotIn(h)):r.push(u.isDifferentFrom(h));break;case"$in":d=!0,r.push(u.isIn(h));break;case"$contains":d=!0,r.push(u.contains(h));break;case"$startsWith":d=!0,r.push(u.startsWith(h));break;case"$endsWith":d=!0,r.push(u.endsWith(h));break;case"$notContains":d=!0,r.push(u.notContains(h));break}}Array.isArray(s)&&(d=!0,r.push(u.isIn(s)))}!d&&s!==void 0&&r.push(u.isEqualTo(s))}}return new hi(...r)}__applyToConsumer(e){this.apply(e)}static async resolve(e){return typeof e=="function"?await e():e}toJson(){let e=new Gt;return this.__applyToConsumer(e),e.result}static async translateCustomWhere(e,t,r){let n=new Qt(async(s,a)=>{let o=[];for(const l in t.entityType){const u=t.entityType[l];u&&u.rawFilterInfo&&u.rawFilterInfo.rawFilterTranslator&&u.rawFilterInfo.key==s&&o.push(await L.fromEntityFilter(t,await u.rawFilterInfo.rawFilterTranslator(a,r)))}return o});return e.__applyToConsumer(n),await n.resolve(),e=new L(s=>n.applyTo(s)),e}}class Ht{constructor(e){f(this,"metadata");this.metadata=e}processVal(e){if(Oe(this.metadata.valueType,!1)){if(e==null){if(e===null&&!this.metadata.allowNull){const r=ne(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:ie(e).getId()}return e}contains(e){return new L(t=>t.containsCaseInsensitive(this.metadata,e))}notContains(e){return new L(t=>t.notContainsCaseInsensitive(this.metadata,e))}startsWith(e){return new L(t=>t.startsWithCaseInsensitive(this.metadata,e))}endsWith(e){return new L(t=>t.endsWithCaseInsensitive(this.metadata,e))}isLessThan(e){return e=this.processVal(e),new L(t=>t.isLessThan(this.metadata,e))}isGreaterOrEqualTo(e){return e=this.processVal(e),new L(t=>t.isGreaterOrEqualTo(this.metadata,e))}isNotIn(e){return new L(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 L(t=>t.isNotNull(this.metadata)):new L(t=>t.isDifferentFrom(this.metadata,e))}isLessOrEqualTo(e){return e=this.processVal(e),new L(t=>t.isLessOrEqualTo(this.metadata,e))}isGreaterThan(e){return e=this.processVal(e),new L(t=>t.isGreaterThan(this.metadata,e))}isEqualTo(e){return e=this.processVal(e),e==null&&this.metadata.allowNull?new L(t=>t.isNull(this.metadata)):new L(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 L(t=>t.isEqualTo(this.metadata,e[0])):new L(t=>t.isIn(this.metadata,e))}}class Us extends Ht{processVal(e){return e?typeof e=="string"||typeof e=="number"?e:ie(e).getId():null}}class Vs{constructor(e,t,r){f(this,"metadata");f(this,"fields");f(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 L(t=>{e.forEach(r=>this.isDifferentFrom(r).__applyToConsumer(t))})}isDifferentFrom(e){return new L(t=>{const r=[];for(const n in this.relationOptions.fields)if(Object.prototype.hasOwnProperty.call(this.relationOptions.fields,n)){const s=this.relationOptions.fields[n];r.push(new L(a=>new Ht(this.fields.find(s)).isDifferentFrom(e[n]).__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 L(t=>{for(const r in this.relationOptions.fields)if(Object.prototype.hasOwnProperty.call(this.relationOptions.fields,r)){const n=this.relationOptions.fields[r];new Ht(this.fields.find(n)).isEqualTo(e[r]).__applyToConsumer(t)}})}isIn(e){return new L(t=>{t.or(e.map(r=>this.isEqualTo(r)))})}}class hi extends L{constructor(...t){super(r=>{for(const n of this.filters)n&&n.__applyToConsumer(r)});f(this,"filters");this.filters=t}add(t){this.filters.push(t)}}class Ws extends L{constructor(...t){super(r=>{let n=this.filters.filter(s=>s!==void 0);n.length>1?r.or(n):n.length==1&&n[0].__applyToConsumer(r)});f(this,"filters");this.filters=t}}class Hs extends L{constructor(t){super(r=>{r.not(t)});f(this,"filter");this.filter=t}}const Ze="$custom$",tn="$db$",Rr="$an array";class Gt{constructor(){f(this,"result",{});f(this,"hasUndefined",!1)}databaseCustom(e){throw new Error("database custom is not allowed with api calls.")}custom(e,t){Array.isArray(t)&&(t={[Rr]:t}),this.add(Ze+e,t)}add(e,t){t===void 0&&(this.hasUndefined=!0);let r=this.result;if(r[e]===void 0){r[e]=t;return}let n=r[e];n instanceof Array?n.push(t):n=[n,t],r[e]=n}or(e){this.add("OR",e.map(t=>{let r=new Gt;return t.__applyToConsumer(r),r.result}))}not(e){let t=new Gt;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 jt(i,e){let t={};function r(o){t.$and||(t.$and=[]),t.$and.push(o)}function n(o,l){t[o]===void 0?t[o]=l:r({[o]:l})}[...i.fields].forEach(o=>{function l(d,c,h=!1,y=!1){let p=e.get(o.key+d);if(p!==void 0){let b=w=>{let P=w;if(h){let M;typeof w=="string"?M=JSON.parse(w):M=w,P=M.map(T=>y?T:o.valueConverter.fromJson(T))}else P=y?P:o.valueConverter.fromJson(P);let k=c(P);k!==void 0&&n(o.key,k)};if(!h&&p instanceof Array)p.forEach(w=>{b(w)});else{h&&typeof p=="string"&&(p=JSON.parse(p));const w=a(p);for(const P of w)b(P)}}}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 u=e.get(o.key+".null");if(u)switch(u=u.toString().trim().toLowerCase(),u){case"y":case"true":case"yes":n(o.key,null);break;default:n(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(u=>({$or:u.map(d=>jt(i,{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 u of o)if(Array.isArray(u))for(const d of u)l.push({$not:jt(i,{get:c=>d[c]})});else l.push({$not:jt(i,{get:d=>u[d]})});l.length==1?t.$not?t.$not.push(l[0].$not):t.$not=l[0].$not:r({$and:l})}for(const o in i.entityType){const l=i.entityType[o];if(l&&l.rawFilterInfo&&l.rawFilterInfo.rawFilterTranslator){let u=e.get(Ze+o);if(u!==void 0){const d=c=>{c[Rr]!=null&&(c=c[Rr]),n(Ze+o,c)};Array.isArray(u)?u.forEach(c=>d(c)):d(u)}}}return t;function a(o){if(!Array.isArray(o))return[o];const l=[],u=[];for(const d of o)Array.isArray(d)?u.push(d):l.push(d);return u.push(l),u}}class Qt{constructor(e){f(this,"translateCustom");f(this,"commands",[]);f(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 n=new Qt(this.translateCustom);return r.__applyToConsumer(n),await n.resolve(),new L(s=>n.applyTo(s))})).then(r=>{t=r})),this.commands.push(r=>r.or(t))}not(e){let t;this.promises.push((async()=>{let r=new Qt(this.translateCustom);e.__applyToConsumer(r),await r.resolve(),t=new L(n=>r.applyTo(n))})()),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(n=>n.__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 zt{constructor(){f(this,"rawValues",{});f(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 n=ne(r.field);if(n){if(n.type==="reference")return r.values.map(s=>n.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(n=>!r.values.includes(n))):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 n=new zt;return r.__applyToConsumer(n),n});for(const r of t)for(const n in r.rawValues)if(Object.prototype.hasOwnProperty.call(r.rawValues,n)){const s=r.rawValues[n];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 n of t)n.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 Gs={};const br=Symbol.for("remult-static1");let Jt={defaultRemultFactory:void 0,remultFactory:void 0,defaultRemult:void 0,asyncContext:void 0,columnsOfType:new Map,allEntities:[],classHelpers:new Map,actionInfo:{allActions:[],runningOnServer:!1,runActionWithoutBlockingUI:i=>i(),startBusyWithProgress:()=>({progress:i=>{},close:()=>{}})},fieldOptionsEnricher:void 0,labelTransformer:void 0,defaultDataProvider:()=>{}};typeof process<"u"&&Gs.IGNORE_GLOBAL_REMULT_IN_TESTS||typeof globalThis[br]>"u"?(globalThis[br]=Jt,Jt.remultFactory=()=>rn()):Jt=globalThis[br];const D=Jt;function rn(){return D.defaultRemult||(D.defaultRemult=D.defaultRemultFactory()),D.defaultRemult}function Qs(){D.remultFactory=()=>rn()}function et(i){const e=i;if(typeof e[Ft]=="function")return e[Ft]();throw Error("Error getting repository internal from "+i)}const Ft=Symbol.for("getInternal");class zs{constructor(){f(this,"iAmRemultProxy",!0);f(this,"repoCache",new Map);f(this,"repo",(...e)=>{let t=D,r=this.repoCache.get(e[0]);r||this.repoCache.set(e[0],r=new Map);let n=r.get(e[1]);return n||(n={get fields(){return D.remultFactory().repo(...e).metadata.fields},[Ft](){return t.remultFactory().repo(...e)[Ft]()},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 D.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],n),n)})}get liveQuerySubscriber(){return D.remultFactory().liveQuerySubscriber}set liveQuerySubscriber(e){D.remultFactory().liveQuerySubscriber=e}get liveQueryStorage(){return D.remultFactory().liveQueryStorage}set liveQueryStorage(e){D.remultFactory().liveQueryStorage=e}get liveQueryPublisher(){return D.remultFactory().liveQueryPublisher}set liveQueryPublisher(e){D.remultFactory().liveQueryPublisher=e}subscribeAuth(e){return D.remultFactory().subscribeAuth(e)}initUser(){return D.remultFactory().initUser()}call(e,t,...r){return D.remultFactory().call(e,t,...r)}get context(){return D.remultFactory().context}get dataProvider(){return D.remultFactory().dataProvider}set dataProvider(e){D.remultFactory().dataProvider=e}get repCache(){return D.remultFactory().repCache}authenticated(){return D.remultFactory().authenticated()}isAllowed(e){return D.remultFactory().isAllowed(e)}isAllowedForInstance(e,t){return D.remultFactory().isAllowedForInstance(e,t)}clearAllCache(){return D.remultFactory().clearAllCache()}useFetch(e){return D.remultFactory().useFetch(e)}get user(){return D.remultFactory().user}set user(e){D.remultFactory().user=e}get apiClient(){return D.remultFactory().apiClient}set apiClient(e){D.remultFactory().apiClient=e}get subscriptionServer(){return D.remultFactory().subscriptionServer}set subscriptionServer(e){D.remultFactory().subscriptionServer=e}}const be=new zs,Ks="$count",Xs=Symbol.for("GroupByForApiKey"),Ys=["sum","avg","min","max","distinctCount"],nn={error500RetryCount:4};function sn(i){return i.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()).replace("Email","eMail")}class Zs{constructor(e,t,r){f(this,"repository");f(this,"isReferenceRelation");f(this,"allowNull");f(this,"storedItem");f(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:et(this.repository)._getCachedByIdAsync(e,!1)}get(e){if(e==null)return null;const t=et(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=ie(e,!1);t&&!this.isReferenceRelation?(et(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 Ae{constructor(...e){f(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 Ae;for(const t of this.Segments)e.Segments.push({field:t.field,isDescending:!t.isDescending});return e}compare(e,t,r){r||(r=n=>n.key);for(let n=0;n<this.Segments.length;n++){let s=this.Segments[n],a=e[r(s.field)],o=t[r(s.field)],l=s.isDescending,u=ea(a,o,l);if(u!=0)return u}return 0}static translateOrderByToSort(e,t){let r=new Ae;if(t){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const s=t[n];let a=e.fields.find(n);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=ne(a);if((l==null?void 0:l.type)==="toOne"){const u=l.options;if(typeof u.field=="string")o(e.fields.find(u.field));else if(u.fields){for(const d in u.fields)if(Object.prototype.hasOwnProperty.call(u.fields,d)){const c=u.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=Ae.translateOrderByToSort(e,e.options.defaultOrderBy)),t||(t=new Ae);for(const r of e.idMetadata.fields)t.Segments.find(n=>n.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 ea(i,e,t){i=yi(i),e=yi(e);let r=0;return i>e?r=1:i<e&&(r=-1),t&&(r*=-1),r}function yi(i){return i==null||i==null?i:i.id!==void 0?i.id:i}class an extends Error{constructor(t){super(t.message);f(this,"modelState");f(this,"stack");f(this,"exception");f(this,"httpStatusCode");Object.assign(this,t)}}class ta{constructor(e){f(this,"dataProvider");f(this,"isProxy");this.dataProvider=e}getEntityDataProvider(e){return new ra(this.dataProvider.then(t=>t.getEntityDataProvider(e)))}transaction(e){return this.dataProvider.then(t=>t.transaction(e))}ensureSchema(e){return this.dataProvider.then(t=>{var r;return(r=t.ensureSchema)==null?void 0:r.call(t,e)})}}class ra{constructor(e){f(this,"dataProvider");this.dataProvider=e}delete(e){return this.dataProvider.then(t=>t.delete(e))}insert(e){return this.dataProvider.then(t=>t.insert(e))}count(e){return this.dataProvider.then(t=>t.count(e))}find(e){return this.dataProvider.then(t=>t.find(e))}groupBy(e){return this.dataProvider.then(t=>t.groupBy(e))}update(e,t){return this.dataProvider.then(r=>r.update(e,t))}}class pi{constructor(e){f(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 n=e[r];this.add(r+t,n)}}}async function Kt(i){var t,r,n,s;let e=0;for(;;)try{return await i()}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")||(n=a.message)!=null&&n.includes("http proxy error")||(s=a.message)!=null&&s.startsWith("Gateway Timeout")||a.status==500)&&e++<nn.error500RetryCount){await new Promise((o,l)=>{setTimeout(()=>{o({})},500)});continue}throw a}}class mi{constructor(e){f(this,"fetch");this.fetch=e}async get(e){return await Kt(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 Kt(()=>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 n of window.document.cookie.split(";"))n.trim().startsWith("XSRF-TOKEN=")&&(r["X-XSRF-TOKEN"]=n.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(n=>ia(n)).catch(async n=>{throw await n})}}function ia(i){if(i.status!=204){if(i.status>=200&&i.status<300)return i.json();throw i.json().then(e=>({...e,message:e.message||i.statusText,url:i.url,status:i.status})).catch(()=>{throw{message:i.statusText,url:i.url,status:i.status}})}}function ht(i){if(!i)return new mi;let e;return e||on(i)&&(e=new na(i)),e||typeof i=="function"&&(e=new mi(i)),e}function on(i){let e=i;return!!(e&&e.get&&e.put&&e.post&&e.delete)}class na{constructor(e){f(this,"http");this.http=e}async post(e,t){return await Kt(()=>$t(this.http.post(e,t)))}delete(e){return $t(this.http.delete(e))}put(e,t){return $t(this.http.put(e,t))}async get(e){return await Kt(()=>$t(this.http.get(e)))}}function $t(i){let e;return i.toPromise!==void 0?e=i.toPromise():e=i,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 sa(t)})}async function sa(i){var s,a,o;let e=await i;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 n=Object.assign(t??{},{});return n}class Dr{constructor(e,t){f(this,"apiProvider");f(this,"entityRequested");f(this,"isProxy",!0);this.apiProvider=e,this.entityRequested=t}getEntityDataProvider(e){var t;return(t=this.entityRequested)==null||t.call(this,e),new aa(()=>{var r;return ln((r=this.apiProvider())==null?void 0:r.url,e.key)},()=>ht(this.apiProvider().httpClient),e)}async transaction(e){throw new Error("Method not implemented.")}}function ln(i,e){return i==null&&(i="/api"),i+"/"+e}function xr(i,e){if(i.include){let t={};for(const r in i.include)if(Object.prototype.hasOwnProperty.call(i.include,r)){let n=i.include[r];if(typeof n=="object"){const s=ne(e.fields.find(r));s&&(n=xr(n,s.toRepo.metadata))}t[r]=n}i={...i,include:t}}return i.where&&(i={...i,where:L.entityFilterToJson(e,i.where)}),i.load&&(i={...i,load:i.load(e.fields).map(t=>t.key)}),i}class aa{constructor(e,t,r){f(this,"url");f(this,"http");f(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:n,aggregates:s})=>({items:n.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),n=await t("groupBy",Object.keys(r).length>0?r:void 0);return e!=null&&e.group&&n.forEach(s=>{for(const a of e.group)s[a.key]=a.valueConverter.fromJson(s[a.key])}),n}buildAggregateOptions(e){var t,r,n,s,a,o,l;return{groupBy:(t=e==null?void 0:e.group)==null?void 0:t.map(u=>u.key),sum:(r=e==null?void 0:e.sum)==null?void 0:r.map(u=>u.key),avg:(n=e==null?void 0:e.avg)==null?void 0:n.map(u=>u.key),min:(s=e==null?void 0:e.min)==null?void 0:s.map(u=>u.key),max:(a=e==null?void 0:e.max)==null?void 0:a.map(u=>u.key),distinctCount:(o=e==null?void 0:e.distinctCount)==null?void 0:o.map(u=>u.key),orderBy:(l=e==null?void 0:e.orderBy)==null?void 0:l.map(u=>{var d;return{...u,field:(d=u.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(n=>+n.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(n=>this.translateFromJson(n)))}find(e){let{run:t}=this.buildFindRequest(e);return t().then(r=>r.map(n=>this.translateFromJson(n)))}buildFindRequest(e,t){t||(t="get");let r=new pi(this.url()),n;if(e){if(e.where&&(n=e.where.toJson(),oa(n,r)&&(n=void 0)),e.orderBy&&e.orderBy.Segments){let a="",o="",l=!1;e.orderBy.Segments.forEach(u=>{a.length>0&&(a+=",",o+=","),a+=u.field.key,o+=u.isDescending?"desc":"asc",u.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 pi(r.url);if(!a&&n&&(a="get"),a&&l.add("__action",a),n){if(t==="put")return this.http().post(l.url,{set:o,where:n});o={...o,where:n}}return o&&t!="put"?this.http().post(l.url,o):this.http()[t](l.url,o)};return{createKey:()=>JSON.stringify({url:r,filterObject:n}),run:s,subscribe:async a=>({result:await s(la+a),unsubscribe:async()=>D.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 n of this.entity.fields)r.includes(n.key)&&(t[n.key]=n.valueConverter.toJson(e[n.key]));return t}async delete(e){if(e=="")await this.deleteMany(L.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)))}}function oa(i,e){for(const t in i)if(Object.prototype.hasOwnProperty.call(i,t)){const r=i[t];if(Array.isArray(r)&&(r.length>0&&typeof r[0]=="object"||r.length>10)||t==="NOT")return!1}for(const t in i)if(Object.prototype.hasOwnProperty.call(i,t)){const r=i[t];Array.isArray(r)?t.endsWith(".in")?e.add(t,JSON.stringify(r)):r.forEach(n=>e.add(t,n)):t.startsWith(Ze)?e.add(t,JSON.stringify(r)):e.add(t,r)}return!0}const la="liveQuery-";var qt,ua=new Uint8Array(16);function fa(){if(!qt&&(qt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!qt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return qt(ua)}const da=/^(?:[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 ca(i){return typeof i=="string"&&da.test(i)}var ye=[];for(var _r=0;_r<256;++_r)ye.push((_r+256).toString(16).substr(1));function ha(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(ye[i[e+0]]+ye[i[e+1]]+ye[i[e+2]]+ye[i[e+3]]+"-"+ye[i[e+4]]+ye[i[e+5]]+"-"+ye[i[e+6]]+ye[i[e+7]]+"-"+ye[i[e+8]]+ye[i[e+9]]+"-"+ye[i[e+10]]+ye[i[e+11]]+ye[i[e+12]]+ye[i[e+13]]+ye[i[e+14]]+ye[i[e+15]]).toLowerCase();if(!ca(t))throw TypeError("Stringified UUID is invalid");return t}function Mr(i,e,t){i=i||{};var r=i.random||(i.rng||fa)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,ha(r)}const Ir="stream";class ya{constructor(e,t,r){f(this,"repo");f(this,"query");f(this,"queryChannel");f(this,"subscribeCode");f(this,"unsubscribe",()=>{});f(this,"defaultQueryState",[]);f(this,"listeners",[]);f(this,"id",Mr());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 et(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(n=>n.type==="add"||n.type==="replace")&&this.query.options.orderBy){const n=Ae.translateOrderByToSort(this.repo.metadata,this.query.options.orderBy);this.defaultQueryState.sort((s,a)=>n.compare(s,a))}});for(const r of this.listeners)e(n=>{r.next(this.createReducerType(n,t))})}createReducerType(e,t){return{applyChanges:e,changes:t,items:this.defaultQueryState}}async handle(e){{let t=e.filter(({type:n})=>n=="add"||n=="replace"),r=await et(this.repo)._fromJsonArray(t.map(n=>n.data.item),this.query.options);for(let n=0;n<t.length;n++){const s=t[n];s.data.item=r[n]}}this.forListeners(t=>{t(r=>{r||(r=[]);for(const n of e)switch(n.type){case"all":this.setAllItems(n.data);break;case"replace":{r=r.map(s=>this.repo.metadata.idMetadata.getId(s)===n.data.oldId?n.data.item:s);break}case"add":r=r.filter(s=>this.repo.metadata.idMetadata.getId(s)!==this.repo.metadata.idMetadata.getId(n.data.item)),r.push(n.data.item);break;case"remove":r=r.filter(s=>this.repo.metadata.idMetadata.getId(s)!==n.data.id);break}return r})},e)}}const pa="_liveQueryKeepAlive";class ma{constructor(e,t){f(this,"apiProvider");f(this,"getUserId");f(this,"queries",new Map);f(this,"channels",new Map);f(this,"client");f(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 n=await this.openIfNoOpened();try{let s=this.channels.get(e);if(!s){this.channels.set(e,s=new ga);try{s.unsubscribe=await n.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 n=!0,s=()=>{n=!1};return this.runPromise(et(e)._buildEntityDataProviderFindOptions(t).then(a=>{if(!n)return;const{createKey:o,subscribe:l}=new Dr(this.apiProvider).getEntityDataProvider(e.metadata).buildFindRequest(a),u=o();let d=this.queries.get(u);d?d.sendDefaultState(r.next):(this.queries.set(u,d=new ya(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(y=>y.error(h)),c(),this.queries.delete(u)}))})).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(u),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 D.actionInfo.runActionWithoutBlockingUI(()=>ht(t.httpClient).post(t.url+"/"+pa,e)));for(const n of r)for(const s of this.queries.values())s.queryChannel===n&&s.subscribeCode()}},3e4),this.runPromise(this.client=this.apiProvider().subscriptionClient.openConnection(()=>{for(const e of this.queries.values())e.subscribeCode()})))}}class ga{constructor(){f(this,"unsubscribe",()=>{});f(this,"listeners",[])}async handle(e){for(const t of this.listeners)t.next(e)}}class Br{openConnection(e){let t;const r=new Map,n=ht(be.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 u(d)),h.push(c),()=>{h.splice(h.indexOf(c,1)),h.length==0&&(D.actionInfo.runActionWithoutBlockingUI(()=>n.post(be.apiClient.url+"/"+Ir+"/unsubscribe",{channel:d,clientId:t})),r.delete(d))}}},l=()=>new Promise(d=>{h();let c=0;function h(){a&&a.close(),a=Br.createEventSource(be.apiClient.url+"/"+Ir),a.onmessage=y=>{let p=JSON.parse(y.data);const b=r.get(p.channel);b&&b.forEach(w=>w(p.data))},a.onerror=y=>{console.error("Live Query Event Source Error",y),a.close(),c++<nn.error500RetryCount&&setTimeout(()=>{h()},500)},a.addEventListener("connectionId",async y=>{if(t=y.data,s){for(const p of r.keys())await u(p);e()}else s=!0,d(o)})}});return l();async function u(d){await D.actionInfo.runActionWithoutBlockingUI(()=>n.post(be.apiClient.url+"/"+Ir+"/subscribe",{channel:d,clientId:t}))===wa&&await l()}}static createEventSource(e){return new EventSource(e,{withCredentials:!0})}}const wa="client connection not found",Nr=Symbol.for("serverActionField");class Ct{constructor(){f(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 va{constructor(e){f(this,"remultObjectStorage");this.remultObjectStorage=e}static enable(){D.remultFactory=()=>{const e=D.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(){Qs()}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,n;const t=(r=this.remultObjectStorage)==null?void 0:r.getStore();t&&(e||(n=this.remultObjectStorage)!=null&&n.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()}}D.asyncContext||(D.asyncContext=new va(void 0));function Pt(){return D.actionInfo.runningOnServer||!be.dataProvider.isProxy}class De{constructor(e){f(this,"repo",(e,t)=>{let r=Oe(e)(be);if(t===void 0&&r!=null&&r.dataProvider){const a=r.dataProvider(this.dataProvider);a instanceof Promise?t=new ta(a):t=a??void 0}t||(t=this.dataProvider);let n=this.repCache.get(t);n||this.repCache.set(t,n=new Map);let s=n.get(e);return s||(n.set(e,s=new Jr(e,this,t,Sa(e,this))),Js(s,this,t)),s});f(this,"_subscribers");f(this,"__user");f(this,"dataProvider",new Dr(()=>this.apiClient));f(this,"repCache",new Map);f(this,"liveQueryStorage");f(this,"subscriptionServer");f(this,"liveQueryPublisher",{itemChanged:async()=>{}});f(this,"liveQuerySubscriber",new ma(()=>this.apiClient,()=>{var e;return(e=this.user)==null?void 0:e.id}));f(this,"context",{});f(this,"apiClient",{url:"/api",subscriptionClient:new Br});if(e&&e.getEntityDataProvider){this.dataProvider=e;return}if(on(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 Ct),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 ht(this.apiClient.httpClient).get(ln(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 n of e)if(this.isAllowed(n)===!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 Dr(()=>({httpClient:e}))}call(e,t,...r){const n=e[Nr];if(!n.doWork)throw Error("The method received is not a valid backend method");return n.doWork(r,t,this.apiClient.url,ht(this.apiClient.httpClient))}clearAllCache(){this.repCache.clear()}}f(De,"onFind",(e,t)=>{}),f(De,"entityRefInit");D.defaultRemultFactory=()=>new De;class un{constructor(){f(this,"classes",new Map)}}function ba(i,e){let t=i;for(;;){let r=D.classHelpers.get(t);r||D.classHelpers.set(t,r=new un),r.classes.set(i,e);let n=Object.getPrototypeOf(t.prototype);if(n==null)break;t=n.constructor}}const _a={defaultPageSize:200};async function Ia(i,e){const t=new Oa(i.liveQueryPublisher);let r=!0;const n=i.dataProvider;try{await i.dataProvider.transaction(async s=>{i.dataProvider=s,i.liveQueryPublisher=t,await e(s),r=!0}),r&&await t.flush()}finally{i.dataProvider=n}}class Oa{constructor(e){f(this,"orig");f(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 n of t)if(n.oldId!==void 0){const s=r.find(a=>a.id===n.oldId);s!==void 0?(n.deleted&&(s.deleted=!0),n.id!=s.id&&(s.id=n.id)):r.push(n)}else r.push(n)}async flush(){for(const e of this.transactionItems.keys())await this.orig.itemChanged(e,this.transactionItems.get(e))}}function At(i,e){return e&&Object.assign(i,e),i}class Te{}f(Te,"number","number"),f(Te,"date","date"),f(Te,"checkbox","checkbox"),f(Te,"password","password"),f(Te,"email","email"),f(Te,"tel","tel"),f(Te,"time","time"),f(Te,"json","json");const U=class U{};f(U,"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=>U.Date.fromJson(e),toInput:e=>U.Date.toJson(e),displayValue:e=>e?e.toLocaleString():""}),f(U,"DateOnly",{fromInput:e=>U.DateOnly.fromJson(e),toInput:e=>U.DateOnly.toJson(e),toJson:e=>{var t=e;if((typeof t=="string"||typeof t=="number")&&(t=new Date(t)),t!==void 0)return!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:Te.date,toDb:e=>e?U.DateOnly.fromJson(U.DateOnly.toJson(e)):null,fromDb:e=>U.Date.fromDb(e),fieldTypeInDb:"date",displayValue:e=>e?e.toLocaleDateString(void 0):""}),f(U,"DateOnlyString",{...U.DateOnly,toDb:e=>{let t=U.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))}}),f(U,"Boolean",{toDb:e=>e,inputType:Te.checkbox,fromDb:e=>U.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=>U.Boolean.fromJson(e),toInput:e=>U.Boolean.toJson(e)}),f(U,"Number",{fromDb:e=>{if(e===null)return null;if(e!==void 0)return+e},toDb:e=>e,fromJson:e=>U.Number.fromDb(e),toJson:e=>U.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:Te.number}),f(U,"String",{fromDb:ot,toDb:ot,fromJson:ot,toJson:ot,fromInput:ot,toInput:ot}),f(U,"Integer",{...U.Number,toJson:e=>{let t=U.Number.toDb(e);return t&&+(+t).toFixed(0)},toDb:e=>U.Integer.toJson(e),fieldTypeInDb:"integer"}),f(U,"Default",{fromJson:e=>e,toJson:e=>e,fromDb:e=>U.JsonString.fromDb(e),toDb:e=>U.JsonString.toDb(e),fromInput:e=>U.Default.fromJson(e),toInput:e=>U.Default.toJson(e),displayValue:e=>e+"",fieldTypeInDb:"",inputType:"text"}),f(U,"JsonString",{fromJson:e=>e,toJson:e=>e,fromDb:e=>e==null?null:e?JSON.parse(U.JsonString.fromJson(e)):void 0,toDb:e=>e!==void 0?e===null?null:JSON.stringify(U.JsonString.toJson(e)):void 0,fromInput:e=>U.JsonString.fromJson(e),toInput:e=>U.JsonString.toJson(e)}),f(U,"JsonValue",{fromJson:e=>e,toJson:e=>e,fromDb:e=>e,toDb:e=>e,fromInput:e=>U.JsonString.fromJson(e),toInput:e=>U.JsonString.toJson(e),fieldTypeInDb:"json"});let ve=U;function ot(i){return i==null?i:typeof i!="string"?i.toString():i}function Or(i,e,t){let r=L.fromEntityFilter(i,e);const n=()=>{};r&&r.__applyToConsumer({custom:n,databaseCustom:n,containsCaseInsensitive:n,notContainsCaseInsensitive:n,startsWithCaseInsensitive:n,endsWithCaseInsensitive:n,isDifferentFrom:n,isEqualTo:(s,a)=>{t[s.key]=a},isGreaterOrEqualTo:n,isGreaterThan:n,isIn:n,isLessOrEqualTo:n,isLessThan:n,isNotNull:n,isNull:n,not:n,or:n})}class Et{constructor(){f(this,"entityLoaders",new Map);f(this,"promises",[])}load(e,t){let r=this.entityLoaders.get(e.entityType);r||this.entityLoaders.set(e.entityType,r=new ka(e));const n=r.find(t);return this.promises.push(n),n}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 ka{constructor(e){f(this,"rel");f(this,"queries",new Map);this.rel=e}find(e){const{where:t,...r}=xr(e,this.rel.metadata),n=JSON.stringify(r);let s=this.queries.get(n);return s||this.queries.set(n,s=new Ca(this.rel)),s.find(e,t)}}class Ca{constructor(e){f(this,"rel");f(this,"pendingInStatements",new Map);f(this,"whereVariations",new Map);this.rel=e}find(e,t){const r=JSON.stringify(t);let n=this.whereVariations.get(r);if(!n){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 Aa(this.rel,s[0],e)),this.whereVariations.set(r,n={result:a.find(t)})}else this.whereVariations.set(r,n={result:this.rel.find(e)})}return n.result}resolve(){const e=[...this.pendingInStatements.values()];this.pendingInStatements.clear();for(const t of e)t.resolve()}}class Aa{constructor(e,t,r){f(this,"rel");f(this,"key");f(this,"options");f(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(n=>n.value)},t.limit=1e3,t.page=1;let r=[];try{for(;;){const n=await this.rel.find(t);if(r.push(...n),n.length<t.limit)break;t.page++}for(const n of this.values.values())n.resolve(r.filter(s=>{const o=ie(s).fields.find(this.key),l=ne(o.metadata),u=(l==null?void 0:l.type)==="reference"?o.getId():s[this.key];return n.value==u}))}catch(n){for(const s of this.values.values())s.reject(n)}}find(e){const t=e[this.key];let r=this.values.get(t);if(!r){let n,s,a=new Promise((o,l)=>{n=o,s=l});this.values.set(t,r={value:t,resolve:n,reject:s,result:a})}return r.result}}async function fn(i,e=t=>t){if(i.options.sqlExpression){if(typeof i.options.sqlExpression=="string")return i.options.sqlExpression;if(typeof i.options.sqlExpression=="function"){const t=i.options.sqlExpression;try{return i.options.sqlExpression="recursive sqlExpression call for entity '"+i.key+"'. ",await t(i)}finally{i.options.sqlExpression=t}}}return e(i.dbName)}const kr=Symbol.for("sqlExpressionInProgressKey");async function jr(i,e,t=n=>n,r=!1){try{if(i.options.sqlExpression){let a;if(typeof i.options.sqlExpression=="function"){if(i[kr]&&!r)return"recursive sqlExpression call for field '"+i.key+"'. \0";try{i[kr]=!0,a=await i.options.sqlExpression(e),a.includes("\0")||(i.options.sqlExpression=()=>a)}finally{delete i[kr]}}else a=i.options.sqlExpression;return a||i.dbName}const n=ne(i);let s=(n==null?void 0:n.type)==="toOne"&&i.options.field;if(s){let a=e.fields.find(s);if(a)return jr(a,e,t,r)}return t(i.dbName)}finally{}}const de=class de{};f(de,"required",Tt(async(e,t)=>!t.valueIsNull()&&t.value!==""&&(t.value!==void 0||ne(t.metadata)!==void 0),"Should not be empty")),f(de,"unique",Tt(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")),f(de,"uniqueOnBackend",Tt(async(e,t)=>t.isBackend()&&(t.isNew||t.valueChanged())?await t.entityRef.repository.count({[t.metadata.key]:t.value})==0:!0,de.unique.defaultMessage)),f(de,"regex",Qe((e,t)=>t.test(e))),f(de,"email",Ut(e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),"Invalid Email")),f(de,"url",Ut(e=>!!new URL(e),"Invalid Url")),f(de,"in",Qe((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(", ")}`)),f(de,"notNull",Ut(e=>e!=null,"Should not be null")),f(de,"enum",Qe((e,t)=>Object.values(t).includes(e),e=>`Value must be one of ${Vt(e).join(", ")}`)),f(de,"relationExists",Tt(async(e,t)=>t.valueIsNull()||!t.isBackend()?!0:!!await t.load(),"Relation value does not exist")),f(de,"min",Qe((e,t)=>e>=t,e=>`Value must be bigger than or equal to ${e}`)),f(de,"max",Qe((e,t)=>e<=t,e=>`Value must be smaller than or equal to ${e}`)),f(de,"maxLength",Qe((e,t)=>e.length<=t,e=>`Value must be at most ${e} characters`)),f(de,"minLength",Qe((e,t)=>e.length>=t,e=>`Value must be at least ${e} characters`)),f(de,"range",Qe((e,[t,r])=>e>=t&&e<=r,([e,t])=>`Value must be between ${e} and ${t}`)),f(de,"defaultMessage","Invalid value");let Fe=de;function Tt(i,e){const t=async(n,s,a)=>{const o=await i(n,s);typeof o=="string"&&o.length>0?s.error=o:o||(s.error=typeof a=="function"&&a(n,s,void 0)||a||typeof e=="function"&&e(n,s,void 0)||e||Fe.defaultMessage)},r=(n,s,a)=>typeof n=="string"||n==="function"||n===void 0&&s===void 0?async(o,l,u)=>await t(o,l,n||u):t(n,s,a);return Object.defineProperty(r,"defaultMessage",{get:()=>e,set:n=>{e=n},enumerable:!0}),Object.assign(r,{withMessage:n=>async(s,a)=>r(s,a,n)})}function Ut(i,e){return Tt((t,r)=>r.value===void 0||r.value===null?!0:i(r.value),e)}function Qe(i,e){const t=Ea((r,n,s)=>n.value===void 0||n.value===null?!0:i(n.value,s),(r,n,s)=>typeof e=="function"&&e(s)||e,!0);return Object.assign((r,n)=>t(r,n),{get defaultMessage(){return e},set defaultMessage(r){e=r}})}function Ea(i,e,t=!1){return Object.assign((n,s)=>async(a,o)=>{const l=await i(a,o,n);typeof l=="string"?o.error=l:l||(o.error=s?typeof s=="function"?t?s(n):s(a,o,n):s:e?typeof e=="function"?e(a,o,n):e:Fe.defaultMessage)},{get defaultMessage(){return e},set defaultMessage(n){e=n}})}function Vt(i){return Object.values(i).filter(e=>typeof i[e]!="number")}function Wt(i,e,t=!1){if(!e)return i;const r=Array.isArray(e)?e:[e],n=Array.isArray(i)?i:i?[i]:[];return t?[...r,...n]:[...n,...r]}function ct(i,e){return typeof i[e]<"u"}class Ta{constructor(e,t){f(this,"options");f(this,"repo");f(this,"_count");f(this,"_aggregates");this.options=e,this.repo=t,this.options||(this.options={}),this.options.pageSize||(this.options.pageSize=_a.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=Ae.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&&ct(this.options,"aggregate")){let o=this.options.aggregate;if(this.repo._dataProvider.isProxy){const l=new Et;r=()=>this.repo._rawFind(t,!1,l,async u=>{const d=await this.repo._edp.query(u,await this.repo.__buildGroupByOptions(o));return this._aggregates=d.aggregates,d.items}).then(async u=>(await l.resolveAll(),u))}else{let l=r();r=async()=>(this._aggregates=await this.repo.aggregate({...o,where:this.options.where}),this._count=this._aggregates.$count,l)}}let n=await r(),s=()=>{throw new Error("no more pages")},a=n.length==this.options.pageSize;if(a){let o=await this.repo._createAfterFilter(this.options.orderBy,n[n.length-1]);s=()=>this.paginator(o)}return{count:()=>this.count(),hasNextPage:a,items:n,nextPage:s,aggregates:this._aggregates}}[Symbol.asyncIterator](){this.options.where||(this.options.where={});let e=this.options.orderBy;this.options.orderBy=Ae.createUniqueEntityOrderBy(this.repo.metadata,e);let t=-1,r,n,s=0;return n=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()=>n()}}}class Jr{constructor(e,t,r,n,s){f(this,"_entity");f(this,"_remult");f(this,"_dataProvider");f(this,"_info");f(this,"_defaultFindOptions");f(this,"__edp");f(this,"_idCache",new Map);f(this,"listeners");f(this,"_cache",new Map);this._entity=e,this._remult=t,this._dataProvider=r,this._info=n,this._defaultFindOptions=s}_notFoundError(e){return{message:`id ${e} not found in entity ${this.metadata.key}`,httpStatusCode:404}}[Ft](){return this}async _createAfterFilter(e,t){let r=new Map;for(const a of Ae.translateOrderByToSort(this.metadata,e).Segments){let o=t[a.field.key];r.set(a.field.key,o)}let n={$or:[]},s=[];for(const a of Ae.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)},n.$or.push(o)}return n}relations(e){return new Proxy({},{get:(t,r)=>{const n=this.fields.find(r),s=ne(n);if(!s)throw Error(r+" is not a relation");const{toRepo:a,returnNull:o,returnUndefined:l}=this._getFocusedRelationRepo(n,e);return s.type==="toMany"?a:{findOne:u=>o?Promise.resolve(null):l?Promise.resolve(void 0):a.findFirst({},u)}}})}_getFocusedRelationRepo(e,t){const r=ne(e);let n=r.toRepo,{findOptions:s,returnNull:a,returnUndefined:o}=this._findOptionsBasedOnRelation(r,e,void 0,t,n);return{toRepo:new Jr(n._entity,n._remult,n._dataProvider,n._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[Xs])&&e.group){const n={include:{}};for(const a of e.group)n.include[a]=!0;const s=new Et;await this._populateRelationsForFields(t.group,n,r,s),await s.resolveAll()}return r}async __buildGroupByOptions(e){var a,o,l,u,d,c;let t=await this._buildEntityDataProviderFindOptions({...e});const r=h=>{const y=this.metadata.fields.find(h);if(y===void 0)throw Error(`key "${h}" not found in entity`);return y},n=h=>{var y;if((y=e==null?void 0:e.group)!=null&&y.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(n),avg:(l=e==null?void 0:e.avg)==null?void 0:l.map(n),min:(u=e==null?void 0:e.min)==null?void 0:u.map(n),max:(d=e==null?void 0:e.max)==null?void 0:d.map(n),distinctCount:(c=e==null?void 0:e.distinctCount)==null?void 0:c.map(n)};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 y=e.orderBy[h];if(y){if(typeof y=="string")s.orderBy.push({field:h==="$count"?void 0:r(h),isDescending:y==="desc",operation:h==="$count"?"count":void 0});else for(const p in y)if(Object.prototype.hasOwnProperty.call(y,p)){const b=y[p];s.orderBy.push({field:this.metadata.fields.find(h),isDescending:b==="desc",operation:p})}}}}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 n=this.findId(e).then(s=>(s===void 0?r=null:r=s,this._idCache.set(e,r),r));return this._idCache.set(e,n),await n}_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 Ta(e,this)}getEntityRef(e){let t=e[Xe];return t||(this._fixTypes(e),t=new xt(this._info,e,this,this._edp,this._remult,!0),Object.defineProperty(e,Xe,{get:()=>t}),t.saveOriginalData()),t}async delete(e){const t=ie(e,!1);if(t)return t.delete();if(typeof e=="string"||typeof e=="number"){if(this._dataProvider.isProxy)return this._edp.delete(e);{let n=await this.findId(e);if(!n)throw this._notFoundError(e);return await ie(n).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 n=t[r],s=this.fields[n];if(s){const a=ne(s);a&&a.type==="toOne"&&a.options.field&&t.indexOf(a.options.field)>r&&a.toRepo.getEntityRef(e[n]).getId()!==e[a.options.field]&&delete e[n]}}for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r],ne(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 n of e){this.__cleanupPartialObject(n);let s=ie(e,!1);if(s){if(!s.isNew())throw"Item is not new"}else s=await this.getEntityRef(this.create(n));t.push(s),r.push(await s.buildDtoForInsert())}return ft(await this._edp.insertMany(r),(n,s)=>t[s].processInsertResponseDto(n))}else{let t=[];for(const r of e)t.push(await this.insert(r));return t}else{let t=ie(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=ie(e,!1);if(r||(r=this.getEntityRef({...e})),!t||t.length===0)return await r.validate();{r.__clearErrorsAndReportChanged();let n=!1;for(const s of t)await r.fields.find(s).validate()||(n=!0);return n?r.buildErrorInfoObject():void 0}}}__createDto(e){this.__cleanupPartialObject(e);const r=this.getEntityRef({...e}).copyDataToObject(!1),n=Object.keys(e);for(const s of this.fields)(s.dbReadOnly||!n.includes(s.key))&&delete r[s.key];return r}async updateMany({where:e,set:t}){if(this.__cleanupPartialObject(t),L.throwErrorIfFilterIsEmpty(e,"updateMany"),this._dataProvider.isProxy)return this._edp.updateMany(await this._translateWhereToFilter(e),this.__createDto({...t}));{let r=0;for await(const n of this.query({where:e,aggregate:void 0}))At(n,t),await ie(n).save(),r++;return r}}async update(e,t){{let n=ie(t,!1);if(n)return await n.save()}{let n=ie(e,!1);if(n)return At(e,t),n.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 n=await r.reload();if(!n)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&&ne(a.metadata))continue;a&&(n[s]=t[s])}return await this._fixTypes(n),await r.save()}}async upsert(e){if(this._dataProvider.isProxy){let s=await this._edp.upsertMany((Array.isArray(e)?e:[e]).map(l=>{var u;return(u=this._defaultFindOptions)!=null&&u.where&&(Or(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 Et,o=await this._loadManyToOneForManyRows(s,{},a);return await a.resolveAll(),Array.isArray(e)?o:o[0]}if(Array.isArray(e))return ft(e,s=>this.upsert(s));let t=e;var r=await this.findFirst(t.where,{createIfNotFound:!0}),n=ie(r,!1);return n.isNew()?(t.set&&At(r,t.set),await n.save()):t.set?(At(r,t.set),await n.save()):r}_getRefForExistingRow(e,t){let r=ie(e,!1);if(!r){const n=new this._entity(this._remult);for(const a of this._fieldsOf(e)){const o=a.key;n[o]=e[o]}this._fixTypes(n);let s=new xt(this._info,n,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(n,Xe,{get:()=>s})}return r}async save(e){if(Array.isArray(e))return ft(e,t=>this.save(t));{let t=ie(e,!1);if(t)return await t.save();if(e instanceof mn)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,n){e||(e={}),this._defaultFindOptions&&(e={...this._defaultFindOptions,...e});let s=await this._buildEntityDataProviderFindOptions(e);t&&(delete s.orderBy,delete s.limit),De.onFind(this._info,e);const a=await n(s);return await this._loadManyToOneForManyRows(a,e,r)}async find(e,t=!1){const r=new Et,n=await this._rawFind(e,t,r,s=>this._edp.find(s));return await r.resolveAll(),n}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=Ae.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 Et,n=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(),n}async _loadManyToOneForManyRows(e,t,r){let n;t!=null&&t.load&&(n=t.load(this.metadata.fields));for(const u of this.metadata.fields)if(Oe(u.valueType,!1)&&!ne(u)){let h=!u.options.lazy;if(n!==void 0&&(h=n.includes(u)),h){let y=this._remult.repo(u.valueType),p=[];for(const b of e){let w=b[u.key];w!=null&&!p.includes(w)&&!y._idCache.has(w+"")&&p.push(w)}p.length>0&&await s(y,p)}}async function s(u,d){let c=await u.find({where:u.metadata.idMetadata.getIdFilter(...d)},!0);for(const h of c)u._addToCache(h)}const a=new Set(this.fields.toArray().map(u=>{const d=this.__getRelationAndInclude(u,t);if(d.rel&&!d.incl)return u.key}).filter(u=>u!==void 0));let o=await ft(e,async u=>await this._mapRawDataToResult(u,n,a));const l=this.metadata.fields.toArray();return this._populateRelationsForFields(l,t,o,r),o}_populateRelationsForFields(e,t,r,n){for(const s of e){let{rel:a,incl:o}=this.__getRelationAndInclude(s,t);if(a)if(o){const l=a.toRepo;for(const u of r){let{findOptions:d,returnNull:c}=this._findOptionsBasedOnRelation(a,s,o,u,l);const h=s.key;if(c)u[h]=null;else{const y=a.toEntity,p=l;n.load({entityType:y,find:b=>p._rawFind(b,!1,n,w=>p._edp.find(w)),metadata:p.metadata},d).then(b=>{b.length==0&&a.type=="toOne"||(u[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=ne(e),n=e.options.defaultIncluded;const s=(a=t==null?void 0:t.include)==null?void 0:a[e.key];return s!==void 0&&(n=s),{rel:r,incl:n}}_findOptionsBasedOnRelation(e,t,r,n,s){let a=!1,o=!1,l=[],u={},d=[];typeof e.options.findOptions=="function"?d.push(e.options.findOptions(n)):typeof e.options.findOptions=="object"&&d.push(e.options.findOptions),typeof r=="object"&&d.push(r);for(const y of d){y.where&&l.push(y.where);for(const p of["limit","include","orderBy"])y[p]&&(u[p]=y[p])}const c=e.getFields(),h=y=>{const p=ie(n,!1);let b=e.type==="reference"&&p?p.fields.find(t.key).getId():n[y];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(n)}):l.push(s.metadata.idMetadata.getIdFilter(h(c.compoundIdField))));for(const y in c.fields)Object.prototype.hasOwnProperty.call(c.fields,y)&&l.push({[y]:h(c.fields[y])});return u.where={$and:l},(e.type==="toOne"||e.type==="reference")&&u.orderBy&&(u.limit=1),{findOptions:u,returnNull:a,returnUndefined:o}}async _mapRawDataToResult(e,t,r){let n=new this._entity(this._remult),s=new xt(this._info,n,this,this._edp,this._remult,!1,r);return Object.defineProperty(n,Xe,{get:()=>s}),await s.loadDataFrom(e,t),s.saveOriginalData(),n}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(n=>this.fromJson(n,t));let r=new this._entity(this._remult);for(const n of this._fieldsOf(e)){const s=n.key;if(Oe(n.valueType,!1)){let o=e[n.key];typeof o=="string"||typeof o=="number"?r[s]=o:r[s]=this._remult.repo(n.valueType).fromJson(o)}else e[s]!==void 0&&(r[s]=n.valueConverter.fromJson(e[n.key]))}if(this._fixTypes(r),t)return this.create(r);{let n=new xt(this._info,r,this,this._edp,this._remult,!1);return Object.defineProperty(r,Xe,{get:()=>n}),n.id=n.getId(),n.saveOriginalData(),n.originalId=n.id,r}}async count(e){return this._edp.count(await this._translateWhereToFilter(e))}async deleteMany({where:e}){if(L.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 ie(r).delete(),t++;return t}}async findOne(e,t=!1){let r,n,s=e??{};if(s.useCache){let a=xr(s,this.metadata),o=JSON.stringify(a);if(n=this._cache.get(o),n!==void 0)if(n.value&&this.getEntityRef(n.value).wasDeleted())n=void 0,this._cache.delete(o);else return n.promise;else n={value:void 0,promise:void 0},this._cache.set(o,n)}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 Or(this.metadata,s.where,o)),o}),n&&(n.promise=r=r.then(a=>(n.value=a,a))),r}async findFirst(e,t,r=!1){if(t||(t={}),e)if(t.where){let n=t.where;t.where={$and:[n,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 n of this._fieldsOf(e)){const s=n.key;t[s]=e[s]}this._fixTypes(t)}return(r=this._defaultFindOptions)!=null&&r.where&&(Or(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[n,s]of[[String,"string"],[Number,"number"],[Boolean,"boolean"]])t.valueType===n&&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 n,s;let t=e??{};(n=this._defaultFindOptions)!=null&&n.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=>L.getPreciseValues(this.metadata,a||t)})),this.metadata.options.backendPrefilter&&(t={$and:[t,await L.resolve(this.metadata.options.backendPrefilter)]}));let r=await L.fromEntityFilter(this.metadata,t);return r&&!this._dataProvider.isProxy&&(r=await L.translateCustomWhere(r,this.metadata,this._remult)),r}}function Sa(i,e){let t=D.columnsOfType.get(i);t||D.columnsOfType.set(i,t=[]);let r=Oe(i)(e),n=Bs(i),s=Object.getPrototypeOf(i);for(;s!=null;){let a=D.columnsOfType.get(s);a&&t.unshift(...a.filter(l=>!t.find(u=>u.key==l.key)));let o=Oe(s,!1);if(o){let l=o(e);r={...l,...r};let u=["saving","saved","deleting","deleted","validation"];for(const d of u)if(l[d]&&l[d]!==r[d]){let c=r[d];r[d]=async(h,y)=>{await c(h,y),await l[d](h,y)}}}s=Object.getPrototypeOf(s)}return new Da(cn(t,e),r,e,i,n)}class dn{constructor(e,t,r,n,s){f(this,"fieldsMetadata");f(this,"instance");f(this,"remult");f(this,"isNewRow");f(this,"_error");f(this,"_subscribers");f(this,"_isLoading",!1);f(this,"lookups",new Map);f(this,"errors");f(this,"originalValues",{});this.fieldsMetadata=e,this.instance=t,this.remult=r,this.isNewRow=n;{let a=r;a!=null&&a.iAmRemultProxy&&(r=D.remultFactory())}for(const a of e)if(Oe(a.valueType,!1)&&r){let l=new Zs(r.repo(a.valueType),!!ne(a),a.allowNull);this.lookups.set(a.key,l);let u=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 Ct)),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 Ct)),d._subscribers.reportChanged()},enumerable:!(s!=null&&s.has(a.key))}),l.set(u)}else{const l=ne(a);if((l==null?void 0:l.type)==="toOne"){let u=t.hasOwnProperty(a.key),d=t[a.key];n&&!d&&(u=!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 y in h.fields)if(Object.prototype.hasOwnProperty.call(h.fields,y)){const p=h.fields[y];this.instance[p]=c==null?null:c[y]}}},enumerable:!(s!=null&&s.has(a.key))}),u&&(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 Ct;const e=this._subscribers;for(const t of this.fieldsMetadata){let r=Oe(t.valueType,!1),n=this.fields.find(t.key);if(n._subscribers=new Ct,!(r&&this.remult||ne(t))){let s=this.instance[t.key];Object.defineProperty(this.instance,t.key,{get:()=>(e.reportObserved(),n._subscribers.reportObserved(),s),set:a=>{s=a,e.reportChanged(),n._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 ft([...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.label+": "+this.errors[r.key],this.error=e.message;break}}return new an(e)}catchSaveErrors(e){let t=e;if(t instanceof Promise)return t.then(n=>this.catchSaveErrors(n));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 n=this.lookups.get(r.key),s;const a=ne(r);n?s=n.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 n of this.fieldsMetadata)if(t||!this.remult||n.includedInApi(this.instance)){let s,a=this.lookups.get(n.key),o=!1;a?e?(s=a.toJson(),o=!0,r[n.key]=s):s=a.id:ne(n)&&!e?o=!0:(s=this.instance[n.key],this.remult||s&&Oe(s.constructor,!1)&&(s=ie(s).getId())),o||(r[n.key]=n.valueConverter.toJson(s))}return r}async _updateEntityBasedOnApi(e,t=!1){let r=Object.keys(e);for(const n of this.fieldsMetadata)if(r.includes(n.key)&&n.includedInApi(this.instance)&&(!this.remult||t||n.apiUpdateAllowed(this.instance))){let s=this.lookups.get(n.key);s?s.id=e[n.key]:this.instance[n.key]=n.valueConverter.fromJson(e[n.key])}await ft([...this.fields].filter(n=>!ne(n.metadata)),n=>n.load())}}class xt extends dn{constructor(t,r,n,s,a,o,l){super(t.fieldsMetadata,r,a,o,l);f(this,"info");f(this,"repo");f(this,"edp");f(this,"_isNew");f(this,"repository");f(this,"metadata");f(this,"_wasDeleted",!1);f(this,"_columns");f(this,"_saving",!1);f(this,"id");f(this,"originalId");if(this.info=t,this.repo=n,this.edp=s,this._isNew=o,this.repository=n,this.metadata=t,o)for(const u of t.fieldsMetadata){const d=u.key;u.options.defaultValue&&r[d]===void 0&&(typeof u.options.defaultValue=="function"?r[d]=u.options.defaultValue(r):r[d]||(r[d]=u.options.defaultValue))}this.info.entityInfo.entityRefInit&&this.info.entityInfo.entityRefInit(this,r),De.entityRefInit&&De.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 n=this.lookups.get(r.key);return n?n.id:this.instance[r.key]};return this.metadata.idMetadata.field instanceof Ye?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:n=>r[typeof n=="string"?n:n.key],[Symbol.iterator]:()=>t[Symbol.iterator](),toArray:()=>t};for(const n of this.info.fieldsMetadata)t.push(r[n.key]=new Xt(n.options,n,this.instance,this,this));this._columns=r}return this._columns}async save(t){var r,n;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 u,d=this.isNew();try{if((r=this._subscribers)==null||r.reportChanged(),this.isNew())s?u=(u=await this.edp.find({where:await this.getIdFilter()}))[0]:u=await this.edp.insert(o);else{let c={},h=!1;for(const y in o)if(Object.prototype.hasOwnProperty.call(o,y)){const p=o[y];this.fields.find(y).valueChanged()&&!l.includes(y)&&p!==void 0&&(c[y]=p,h=!0)}if(!h)return this.instance;if(s)u=(await this.edp.find({where:await this.getIdFilter()}))[0];else{if(this.id===void 0)throw new Error("Invalid operation, id is undefined");u=await this.edp.update(this.id,c)}}if(u&&await this.loadDataFrom(u),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((n=c.saved)==null?void 0:n.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 n=this.fields.find(r);n.value=n.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 n;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((n=s.deleted)==null?void 0:n.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 n of this.info.fields){let s=this.lookups.get(n.key);s?(s.id=t[n.key],r===void 0?!n.options.lazy&&!ne(n)&&await s.waitLoad():r.includes(n)&&await s.waitLoad()):ne(n)||(t[n.key]===void 0?delete this.instance[n.key]:this.instance[n.key]=t[n.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 n=ne(r.metadata);if((!n||n.type=="reference")&&r.valueChanged())return!0}return!1}async __performColumnAndEntityValidations(){var t;for(const r of this.fieldsMetadata)r.options.validate&&await new Xt(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 gi=Symbol.for("controllerColumns");function cn(i,e){return i.map(t=>Vr(t.settings(e),e))}function wi(i,e){const t=e||be;let r=i[gi];if(r||(r=i[Xe]),!r){let n=D.columnsOfType.get(i.constructor);n||D.columnsOfType.set(i.constructor,n=[]);let s=Object.getPrototypeOf(i.constructor);for(;s!=null;){let a=D.columnsOfType.get(s);a&&n.unshift(...a.filter(o=>!n.find(l=>l.key==o.key))),s=Object.getPrototypeOf(s)}i[gi]=r=new Fa(cn(n,t).map(a=>new yn(a,void 0,t)),i,t)}return r}class Fa extends dn{constructor(t,r,n){super(t,r,n,!1);f(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 Xt(o.options,o,r,void 0,this));this.fields=a}async __performColumnAndEntityValidations(){for(const t of this.fields)t instanceof Xt&&await t.__performValidation()}}class Xt{constructor(e,t,r,n,s){f(this,"settings");f(this,"metadata");f(this,"container");f(this,"helper");f(this,"rowBase");f(this,"_subscribers");f(this,"target");f(this,"entityRef");this.settings=e,this.metadata=t,this.container=r,this.helper=n,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=ne(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,n={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,n));else typeof this.settings.validate=="function"&&t(await this.settings.validate(this.container,n))}}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 Pa={transformLabel:(i,e,t,r)=>t,set transformCaption(i){this.transformLabel=i}};const Cr=D.fieldOptionsEnricher||{enrichFieldOptions:i=>i},Ra=D.labelTransformer||(D.labelTransformer=Pa);function hn(i,e,t,r){let n;return typeof i=="function"?t&&(n=i(t)):i&&(n=i),n=Ra.transformLabel(t,e,n??"",r),n||(e?sn(e):"")}class yn{constructor(e,t,r){f(this,"settings");f(this,"entityDefs");f(this,"remult");f(this,"options");f(this,"target");f(this,"readonly",!1);f(this,"valueConverter");f(this,"allowNull");f(this,"label");f(this,"dbName");f(this,"inputType");f(this,"key");f(this,"isServerExpression",!1);f(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:(n,s)=>{let a=n[s];return typeof a=="function"?(...o)=>{try{return n[s](...o)}catch(l){const u=`${String(s)} failed for value ${o==null?void 0:o[0]}. Error: ${typeof l=="string"?l:l.message}`;throw new an({message:this.label+": "+u,modelState:{[this.key]:u}})}}: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.label=hn(e.label??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 jr(this,this.entityDefs)}get caption(){return this.label}get dbReadOnly(){return!!this.settings.dbReadOnly}}class Da{constructor(e,t,r,n,s){f(this,"entityInfo");f(this,"remult");f(this,"entityType");f(this,"key");f(this,"options");f(this,"fieldsMetadata",[]);f(this,"idMetadata",{getId:e=>{if(e==null)return e;const t=ie(e,!1);return t?t.getId():this.idMetadata.field instanceof Ye?this.idMetadata.field.getId(e):e[this.idMetadata.field.key]},field:void 0,get fields(){return this.field instanceof Ye?this.field.fields:[this.field]},createIdInFilter:e=>e.length>0?{$or:e.map(t=>this.idMetadata.getIdFilter(ie(t).getId()))}:{[this.fields.toArray()[0].key]:[]},isIdField:e=>e.key==this.idMetadata.field.key,getIdFilter:(...e)=>{if(this.idMetadata.field instanceof Ye){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}}});f(this,"fields");f(this,"dbName");f(this,"label");if(this.entityInfo=t,this.remult=r,this.entityType=n,this.key=s,this.options=t,this.options.allowApiCrud!==void 0){let o;typeof this.options.allowApiCrud=="function"?o=(l,u)=>this.options.allowApiCrud(u):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=n.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 yn(o,this,r));if(this.fields=a,this.label=hn(t.label??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 Ye(...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=ie(e,!1);return t||this.remult.repo(this.entityType).getEntityRef({...e})}getDbName(){return fn(this)}get caption(){return this.label}}function Ma(...i){return(e,t)=>(i||(i=[]),i.splice(0,0,{valueType:e}),e[Ur]=i,e)}function Na(i){var e,t;return((t=(e=i.options)==null?void 0:e.valueConverter)==null?void 0:t.fieldTypeInDb)==="autoincrement"}function La(...i){return(e,t)=>{Ma(r=>{r.valueConverter=Yt.get(e),r.displayValue=(n,s)=>(s==null?void 0:s.label)??(s==null?void 0:s.caption),r.validate=(n,s)=>{const a=Yt.get(e).getValues();return s.value&&!a.find(o=>o===s.value)&&(s.value=a.find(o=>o.id===s.value.id)||s.value),Fe.in(a)(n,s)}},...i)(e)}}class Yt{constructor(e){f(this,"valueListType");f(this,"byIdMap",new Map);f(this,"values",[]);f(this,"isNumeric",!1);f(this,"fieldTypeInDb");f(this,"inputType");this.valueListType=e;for(let r in this.valueListType){let n=this.valueListType[r];n instanceof this.valueListType&&(n.id===void 0&&(n.id=r),typeof n.id=="number"&&(this.isNumeric=!0),bi(n,r),this.byIdMap.set(n.id,n),this.values.push(n))}this.isNumeric&&(this.fieldTypeInDb="integer");var t=this.valueListType[Ur];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(n=>{bi(n,""),this.byIdMap.set(n.id,n)}));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=vi.get(e);return t||(t=new Yt(e),vi.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 vi=new Map;function bi(i,e){let t=i.label??i.caption;t===void 0&&(t=sn(i.id!==void 0?i.id.toString():e)),i.label===void 0&&(i.label=t),i.caption===void 0&&(i.caption=t)}const Ur=Symbol.for("storableMember"),Ar=Symbol.for("fieldOptionalValues");function pn(i,e){var r;let t={};for(const n of i)if(n)if(typeof n=="function")n(t,e);else{const{validate:s,...a}=n;t.validate=Wt(t.validate,s),Object.assign(t,a)}return(r=Cr.enrichFieldOptions)==null||r.call(Cr,t),t}function Vr(i,e){if(i.valueType){let n=i.valueType[Ur];n&&(i=pn([...n,i],e))}if(i.valueType==String){let n=i;i.valueConverter||(n.valueConverter=ve.String)}if(i.valueType==Number){let n=i;i.valueConverter||(n.valueConverter=ve.Number)}if(i.valueType==Date){let n=i;i.valueConverter||(n.valueConverter=ve.Date)}if(i.valueType==Boolean){let n=i;n.valueConverter||(n.valueConverter=ve.Boolean)}if(!i.valueConverter){if(Oe(i.valueType,!1)){let s;i.valueConverter={toDb:a=>a,fromDb:a=>a},i.valueConverter=new Proxy(i.valueConverter,{get(a,o){if(a[o]===void 0&&s===void 0){if(o==="inputType")return"";s=e.repo(i.valueType).metadata.idMetadata.field.valueType===Number;for(const l of["fieldTypeInDb","toJson","fromJson","toDb","fromDb"])a[l]=s?ve.Integer[l]:ve.String[l]}return a[o]},set(a,o,l,u){return a[o]=l,!0}})}else i.valueConverter=ve.Default;return i}i.valueConverter.toJson||(i.valueConverter.toJson=n=>n),i.valueConverter.fromJson||(i.valueConverter.fromJson=n=>n);const t=i.valueConverter.fromJson,r=i.valueConverter.toJson;return i.valueConverter.toDb||(i.valueConverter.toDb=n=>r(n)),i.valueConverter.fromDb||(i.valueConverter.fromDb=n=>t(n)),i.valueConverter.toInput||(i.valueConverter.toInput=n=>r(n)),i.valueConverter.fromInput||(i.valueConverter.fromInput=n=>t(n)),i}class mn{get _(){return ie(this)}save(){return ie(this).save()}assign(e){return At(this,e),this}delete(){return this._.delete()}isNew(){return this._.isNew()}get $(){return this._.fields}}function $a(i){return i.metadata?i.metadata:Oe(i,!1)?be.repo(i).metadata:i}function qa(i){return Oe(i,!1)?be.repo(i):i}async function ft(i,e){const t=[];for(let r=0;r<i.length;r++){const n=i[r];t.push(await e(n,r))}return t}const dt=class dt{constructor(e){f(this,"sql");f(this,"wrapIdentifier",e=>e);f(this,"provideMigrationBuilder");f(this,"createdEntities",[]);f(this,"end");this.sql=e,e.wrapIdentifier&&(this.wrapIdentifier=t=>e.wrapIdentifier(t)),ct(e,"provideMigrationBuilder")&&(this.provideMigrationBuilder=t=>e.provideMigrationBuilder(t)),ct(e,"end")&&(this.end=()=>e.end())}static getDb(e){const t=e||be.dataProvider;if(ct(t,"createCommand"))return t;throw"the data provider is not an SqlCommandFactory"}createCommand(){return new Ba(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:ve.JsonString.toDb,fromDb:ve.JsonString.fromDb});return new gn(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 n=t.createCommand();return{addParameterAndReturnSqlToken:s=>n.param(s),param:s=>n.param(s),execute:async s=>{if(r)throw"can't run a command after the transaction was completed";return n.execute(s)}}},getLimitSqlSyntax:this.sql.getLimitSqlSyntax,entityIsUsedForTheFirstTime:n=>t.entityIsUsedForTheFirstTime(n),transaction:n=>t.transaction(n),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{[tn]:{buildSql:e}}}static async filterToRaw(e,t,r,n,s){r||(r=new ja);const a=qa(e);var o=new Ue(r,n||await wn(a.metadata,s));return o._addWhere=!1,await(await et(a)._translateWhereToFilter(t)).__applyToConsumer(o),await o.resolveWhere()}};f(dt,"LogToConsole",!1),f(dt,"durationThreshold",0);let yt=dt;const xa=new Map([["INSERT","⚪"],["SELECT","🔵"],["UPDATE","🟣"],["DELETE","🟤"],["CREATE","🟩"],["ALTER","🟨"],["DROP","🟥"],["TRUNCATE","⬛"],["GRANT","🟪"],["REVOKE","🟫"]]);class Ba{constructor(e,t){f(this,"origin");f(this,"logToConsole");f(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,n=await this.origin.execute(e);if(this.logToConsole!==!1){var t=new Date().valueOf()-r.valueOf();if(t>=yt.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(`${xa.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 n}catch(r){throw console.error((r.message||"Sql Error")+`:
|
|
4
|
+
`,e,{arguments:this.args,error:r}),r}}}class gn{constructor(e,t,r,n){f(this,"entity");f(this,"sql");f(this,"iAmUsed");f(this,"strategy");this.entity=e,this.sql=t,this.iAmUsed=r,this.strategy=n}async init(){let e=await wn(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,n=this.sql.createCommand();if(e){let s=new Ue(n,t);e.__applyToConsumer(s),r+=await s.resolveWhere()}return n.execute(r).then(s=>Number(s.rows[0].count))}async groupBy(e){return await Ja(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:n}=this.buildSelect(t);n="select "+n,n+=`
|
|
5
|
+
from `+t.$entityName;let s=this.sql.createCommand();if(e){if(e.where){let a=new Ue(s,t);e.where.__applyToConsumer(a),n+=await a.resolveWhere()}if(e.limit&&(e.orderBy=Ae.createUniqueSort(this.entity,e.orderBy)),e.orderBy||(e.orderBy=Ae.createUniqueSort(this.entity,new Ae)),e.orderBy){let a=!0,o=[];for(const l of e.orderBy.Segments)o.push(l);for(const l of o)a?(n+=" Order By ",a=!1):n+=", ",n+=t.$dbNameOf(l.field),l.isDescending&&(n+=" desc"),this.sql._getSourceSql().orderByNullsFirst&&(l.isDescending?n+=" nulls last":n+=" nulls first")}if(e.limit){let a=1;e.page&&(a=e.page),a<1&&(a=1),n+=" "+this.strategy.getLimitSqlSyntax(e.limit,(a-1)*e.limit)}}return s.execute(n).then(a=>a.rows.map(o=>this.buildResultRow(r,o,a)))}buildResultRow(e,t,r){let n={};for(let s=0;s<e.length;s++){const a=e[s];try{n[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 n}buildSelect(e){let t="",r=[];for(const n of this.entity.fields)n.isServerExpression||(r.length>0&&(t+=", "),t+=e.$dbNameOf(n),n.options.sqlExpression&&(t+=" as "+n.key),r.push(n));return{colKeys:r,select:t}}async update(e,t){let r=await this.init(),n=this.sql.createCommand(),s="update "+r.$entityName+" set ",a=!1;for(const h of this.entity.fields)if(!Ii(h,r)){if(t[h.key]!==void 0){let y=h.valueConverter.toDb(t[h.key]);y!==void 0&&(a?s+=", ":a=!0,s+=r.$dbNameOf(h)+" = "+n.param(y))}}const o=this.entity.idMetadata.getIdFilter(e);let l=new Ue(n,r);L.fromEntityFilter(this.entity,o).__applyToConsumer(l),s+=await l.resolveWhere();let{colKeys:u,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),n.execute(s).then(h=>{var y,p;if((p=(y=this.sql._getSourceSql()).afterMutation)==null||p.call(y),!c)return _i(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(u,h.rows[0],h)})}async delete(e){let t=await this.init(),r=this.sql.createCommand(),n=new Ue(r,t);L.fromEntityFilter(this.entity,this.entity.idMetadata.getIdFilter(e)).__applyToConsumer(n);let s="delete from "+t.$entityName;return s+=await n.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(),n="",s="",a=!1;for(const d of this.entity.fields)if(!Ii(d,t)){let c=d.valueConverter.toDb(e[d.key]);c!=null&&(a?(n+=", ",s+=", "):a=!0,n+=t.$dbNameOf(d),s+=r.param(c))}let o=`insert into ${t.$entityName} (${n}) values (${s})`,{colKeys:l,select:u}=this.buildSelect(t);return this.sql._getSourceSql().doesNotSupportReturningSyntax||(o+=" returning "+u),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(Na(this.entity.idMetadata.field)){const y=d.rows[0];if(typeof y!="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(y));return this.find({where:new L(p=>p.isEqualTo(this.entity.idMetadata.field,y))}).then(p=>p[0])}else return _i(this.entity,this,e,void 0,"insert");return this.buildResultRow(l,d.rows[0],d)})}}f(gn,"LogToConsole",!1);class ja{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 _i(i,e,t,r,n){const s=r!==void 0?i.idMetadata.getIdFilter(r):{};return e.find({where:new L(a=>{for(const o of i.idMetadata.fields)a.isEqualTo(o,t[o.key]??s[o.key])})}).then(a=>{if(a.length!=1)throw new Error(`Failed to ${n} row - result contained ${a.length} rows`);return a[0]})}async function Ja(i,e,t,r,n){let s="select count(*) as count",a="";const o=[];if(o.push((c,h)=>{h[Ks]=Number(c)}),i!=null&&i.group)for(const c of i==null?void 0:i.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,y)=>{y[c.key]=c.valueConverter.fromDb(h)});for(const c of Ys){const h=i==null?void 0:i[c];if(h)for(const y of h){if(!y.isServerExpression){const b=await e.$dbNameOf(y);s+=`, ${d(c,b)} as ${y.key}_${c}`}const p=y.valueType===Number||c=="distinctCount";o.push((b,w)=>{p&&(b=Number(b)),w[y.key]={...w[y.key],[c]:b}})}}if(s+=`
|
|
7
|
+
from `+e.$entityName,i!=null&&i.where){let c=new Ue(t,e);i==null||i.where.__applyToConsumer(c),s+=await c.resolveWhere()}a&&(s+=a);let l="";if(i!=null&&i.orderBy){for(const c of i==null?void 0:i.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(i!=null&&i.limit){let c=1;i.page&&(c=i.page),c<1&&(c=1),s+=" "+n(i.limit,(c-1)*i.limit)}const u=await t.execute(s);return u.rows.map(c=>{let h={};return o.forEach((y,p)=>y(c[u.getColumnKeyInResultForIndexInSelect(p)],h)),h});function d(c,h){return c==="distinctCount"?`count (distinct ${h})`:`${c}( ${h} )`}}class Ue{constructor(e,t){f(this,"r");f(this,"nameProvider");f(this,"where","");f(this,"_addWhere",!0);f(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 n=new Ue(this.r,this.nameProvider);n._addWhere=!1,r.__applyToConsumer(n);let s=await n.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 Ue(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 n=this.nameProvider.$dbNameOf(e)+" "+r+" "+this.r.param(e.valueConverter.toDb(t));this.addToWhere(n)})())}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 Ua(this.r,this.nameProvider.wrapIdentifier),r=await e.buildSql(t);typeof r!="string"&&(r=t.sql),r&&this.addToWhere("("+r+")")}})())}}class Ua{constructor(e,t){f(this,"r");f(this,"wrapIdentifier");f(this,"sql","");f(this,"param",(e,t)=>(typeof t=="object"&&t.valueConverter.toDb&&(e=t.valueConverter.toDb(e)),this.r.param(e)));f(this,"filterToRaw",async(e,t)=>yt.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 Ii(i,e){return i.dbReadOnly||i.isServerExpression||i.options.sqlExpression&&i.dbName!=e.$dbNameOf(i)}async function wn(i,e){return Va(i,e,!0)}async function Va(i,e,t=!1){let r=typeof e=="function"?{wrapIdentifier:e}:e||{};var n=$a(i);r.wrapIdentifier||(r.wrapIdentifier=be.dataProvider.wrapIdentifier),r.wrapIdentifier||(r.wrapIdentifier=a=>a);const s={$entityName:await fn(n,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 n.fields){let o=await jr(a,n,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}function vn(i,...e){return(t,r)=>{let n=t;for(;n!=null;){for(const a in n)if(Object.prototype.hasOwnProperty.call(n,a)){const o=t[a];o!=null&&o.rawFilterInfo&&(o.rawFilterInfo.key||(o.rawFilterInfo.key=a))}n=Object.getPrototypeOf(n)}let s=a=>{let o={};for(const u of e)u&&(typeof u=="function"?u(o,a):Object.assign(o,u));let l=Object.getPrototypeOf(t);if(l){let u=Oe(l,!1);if(u){let d=u(a);d&&(o={...d,...o})}}return o};return D.allEntities.push(t),ba(t,{key:i}),t[Yi]=s,t[Zi]=i,t}}var Zt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},lt={},Je={},re={},ce={},Oi;function bn(){if(Oi)return ce;Oi=1,Object.defineProperty(ce,"__esModule",{value:!0}),ce.output=ce.exists=ce.hash=ce.bytes=ce.bool=ce.number=ce.isBytes=void 0;function i(l){if(!Number.isSafeInteger(l)||l<0)throw new Error(`positive integer expected, not ${l}`)}ce.number=i;function e(l){if(typeof l!="boolean")throw new Error(`boolean expected, not ${l}`)}ce.bool=e;function t(l){return l instanceof Uint8Array||l!=null&&typeof l=="object"&&l.constructor.name==="Uint8Array"}ce.isBytes=t;function r(l,...u){if(!t(l))throw new Error("Uint8Array expected");if(u.length>0&&!u.includes(l.length))throw new Error(`Uint8Array expected of length ${u}, not of length=${l.length}`)}ce.bytes=r;function n(l){if(typeof l!="function"||typeof l.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");i(l.outputLen),i(l.blockLen)}ce.hash=n;function s(l,u=!0){if(l.destroyed)throw new Error("Hash instance has been destroyed");if(u&&l.finished)throw new Error("Hash#digest() has already been called")}ce.exists=s;function a(l,u){r(l);const d=u.outputLen;if(l.length<d)throw new Error(`digestInto() expects output buffer of length at least ${d}`)}ce.output=a;const o={number:i,bool:e,bytes:r,hash:n,exists:s,output:a};return ce.default=o,ce}var j={},ki;function Wa(){if(ki)return j;ki=1,Object.defineProperty(j,"__esModule",{value:!0}),j.add5L=j.add5H=j.add4H=j.add4L=j.add3H=j.add3L=j.add=j.rotlBL=j.rotlBH=j.rotlSL=j.rotlSH=j.rotr32L=j.rotr32H=j.rotrBL=j.rotrBH=j.rotrSL=j.rotrSH=j.shrSL=j.shrSH=j.toBig=j.split=j.fromBig=void 0;const i=BigInt(2**32-1),e=BigInt(32);function t(E,C=!1){return C?{h:Number(E&i),l:Number(E>>e&i)}:{h:Number(E>>e&i)|0,l:Number(E&i)|0}}j.fromBig=t;function r(E,C=!1){let I=new Uint32Array(E.length),v=new Uint32Array(E.length);for(let S=0;S<E.length;S++){const{h:$,l:x}=t(E[S],C);[I[S],v[S]]=[$,x]}return[I,v]}j.split=r;const n=(E,C)=>BigInt(E>>>0)<<e|BigInt(C>>>0);j.toBig=n;const s=(E,C,I)=>E>>>I;j.shrSH=s;const a=(E,C,I)=>E<<32-I|C>>>I;j.shrSL=a;const o=(E,C,I)=>E>>>I|C<<32-I;j.rotrSH=o;const l=(E,C,I)=>E<<32-I|C>>>I;j.rotrSL=l;const u=(E,C,I)=>E<<64-I|C>>>I-32;j.rotrBH=u;const d=(E,C,I)=>E>>>I-32|C<<64-I;j.rotrBL=d;const c=(E,C)=>C;j.rotr32H=c;const h=(E,C)=>E;j.rotr32L=h;const y=(E,C,I)=>E<<I|C>>>32-I;j.rotlSH=y;const p=(E,C,I)=>C<<I|E>>>32-I;j.rotlSL=p;const b=(E,C,I)=>C<<I-32|E>>>64-I;j.rotlBH=b;const w=(E,C,I)=>E<<I-32|C>>>64-I;j.rotlBL=w;function P(E,C,I,v){const S=(C>>>0)+(v>>>0);return{h:E+I+(S/2**32|0)|0,l:S|0}}j.add=P;const k=(E,C,I)=>(E>>>0)+(C>>>0)+(I>>>0);j.add3L=k;const M=(E,C,I,v)=>C+I+v+(E/2**32|0)|0;j.add3H=M;const T=(E,C,I,v)=>(E>>>0)+(C>>>0)+(I>>>0)+(v>>>0);j.add4L=T;const g=(E,C,I,v,S)=>C+I+v+S+(E/2**32|0)|0;j.add4H=g;const O=(E,C,I,v,S)=>(E>>>0)+(C>>>0)+(I>>>0)+(v>>>0)+(S>>>0);j.add5L=O;const F=(E,C,I,v,S,$)=>C+I+v+S+$+(E/2**32|0)|0;j.add5H=F;const N={fromBig:t,split:r,toBig:n,shrSH:s,shrSL:a,rotrSH:o,rotrSL:l,rotrBH:u,rotrBL:d,rotr32H:c,rotr32L:h,rotlSH:y,rotlSL:p,rotlBH:b,rotlBL:w,add:P,add3L:k,add3H:M,add4L:T,add4H:g,add5H:F,add5L:O};return j.default=N,j}var Er={},Ot={},Ci;function Ha(){return Ci||(Ci=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.crypto=void 0,Ot.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0),Ot}var Ai;function Ga(){return Ai||(Ai=1,function(i){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(i,"__esModule",{value:!0}),i.randomBytes=i.wrapXOFConstructorWithOpts=i.wrapConstructorWithOpts=i.wrapConstructor=i.checkOpts=i.Hash=i.concatBytes=i.toBytes=i.utf8ToBytes=i.asyncLoop=i.nextTick=i.hexToBytes=i.bytesToHex=i.byteSwap32=i.byteSwapIfBE=i.byteSwap=i.isLE=i.rotl=i.rotr=i.createView=i.u32=i.u8=i.isBytes=void 0;const e=Ha(),t=bn();function r(v){return v instanceof Uint8Array||v!=null&&typeof v=="object"&&v.constructor.name==="Uint8Array"}i.isBytes=r;const n=v=>new Uint8Array(v.buffer,v.byteOffset,v.byteLength);i.u8=n;const s=v=>new Uint32Array(v.buffer,v.byteOffset,Math.floor(v.byteLength/4));i.u32=s;const a=v=>new DataView(v.buffer,v.byteOffset,v.byteLength);i.createView=a;const o=(v,S)=>v<<32-S|v>>>S;i.rotr=o;const l=(v,S)=>v<<S|v>>>32-S>>>0;i.rotl=l,i.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const u=v=>v<<24&4278190080|v<<8&16711680|v>>>8&65280|v>>>24&255;i.byteSwap=u,i.byteSwapIfBE=i.isLE?v=>v:v=>(0,i.byteSwap)(v);function d(v){for(let S=0;S<v.length;S++)v[S]=(0,i.byteSwap)(v[S])}i.byteSwap32=d;const c=Array.from({length:256},(v,S)=>S.toString(16).padStart(2,"0"));function h(v){(0,t.bytes)(v);let S="";for(let $=0;$<v.length;$++)S+=c[v[$]];return S}i.bytesToHex=h;const y={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function p(v){if(v>=y._0&&v<=y._9)return v-y._0;if(v>=y._A&&v<=y._F)return v-(y._A-10);if(v>=y._a&&v<=y._f)return v-(y._a-10)}function b(v){if(typeof v!="string")throw new Error("hex string expected, got "+typeof v);const S=v.length,$=S/2;if(S%2)throw new Error("padded hex string expected, got unpadded hex of length "+S);const x=new Uint8Array($);for(let ee=0,W=0;ee<$;ee++,W+=2){const fe=p(v.charCodeAt(W)),He=p(v.charCodeAt(W+1));if(fe===void 0||He===void 0){const Be=v[W]+v[W+1];throw new Error('hex string expected, got non-hex character "'+Be+'" at index '+W)}x[ee]=fe*16+He}return x}i.hexToBytes=b;const w=async()=>{};i.nextTick=w;async function P(v,S,$){let x=Date.now();for(let ee=0;ee<v;ee++){$(ee);const W=Date.now()-x;W>=0&&W<S||(await(0,i.nextTick)(),x+=W)}}i.asyncLoop=P;function k(v){if(typeof v!="string")throw new Error(`utf8ToBytes expected string, got ${typeof v}`);return new Uint8Array(new TextEncoder().encode(v))}i.utf8ToBytes=k;function M(v){return typeof v=="string"&&(v=k(v)),(0,t.bytes)(v),v}i.toBytes=M;function T(...v){let S=0;for(let x=0;x<v.length;x++){const ee=v[x];(0,t.bytes)(ee),S+=ee.length}const $=new Uint8Array(S);for(let x=0,ee=0;x<v.length;x++){const W=v[x];$.set(W,ee),ee+=W.length}return $}i.concatBytes=T;class g{clone(){return this._cloneInto()}}i.Hash=g;const O={}.toString;function F(v,S){if(S!==void 0&&O.call(S)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(v,S)}i.checkOpts=F;function N(v){const S=x=>v().update(M(x)).digest(),$=v();return S.outputLen=$.outputLen,S.blockLen=$.blockLen,S.create=()=>v(),S}i.wrapConstructor=N;function E(v){const S=(x,ee)=>v(ee).update(M(x)).digest(),$=v({});return S.outputLen=$.outputLen,S.blockLen=$.blockLen,S.create=x=>v(x),S}i.wrapConstructorWithOpts=E;function C(v){const S=(x,ee)=>v(ee).update(M(x)).digest(),$=v({});return S.outputLen=$.outputLen,S.blockLen=$.blockLen,S.create=x=>v(x),S}i.wrapXOFConstructorWithOpts=C;function I(v=32){if(e.crypto&&typeof e.crypto.getRandomValues=="function")return e.crypto.getRandomValues(new Uint8Array(v));throw new Error("crypto.getRandomValues must be defined")}i.randomBytes=I}(Er)),Er}var Ei;function Qa(){if(Ei)return re;Ei=1,Object.defineProperty(re,"__esModule",{value:!0}),re.shake256=re.shake128=re.keccak_512=re.keccak_384=re.keccak_256=re.keccak_224=re.sha3_512=re.sha3_384=re.sha3_256=re.sha3_224=re.Keccak=re.keccakP=void 0;const i=bn(),e=Wa(),t=Ga(),r=[],n=[],s=[],a=BigInt(0),o=BigInt(1),l=BigInt(2),u=BigInt(7),d=BigInt(256),c=BigInt(113);for(let T=0,g=o,O=1,F=0;T<24;T++){[O,F]=[F,(2*O+3*F)%5],r.push(2*(5*F+O)),n.push((T+1)*(T+2)/2%64);let N=a;for(let E=0;E<7;E++)g=(g<<o^(g>>u)*c)%d,g&l&&(N^=o<<(o<<BigInt(E))-o);s.push(N)}const[h,y]=(0,e.split)(s,!0),p=(T,g,O)=>O>32?(0,e.rotlBH)(T,g,O):(0,e.rotlSH)(T,g,O),b=(T,g,O)=>O>32?(0,e.rotlBL)(T,g,O):(0,e.rotlSL)(T,g,O);function w(T,g=24){const O=new Uint32Array(10);for(let F=24-g;F<24;F++){for(let C=0;C<10;C++)O[C]=T[C]^T[C+10]^T[C+20]^T[C+30]^T[C+40];for(let C=0;C<10;C+=2){const I=(C+8)%10,v=(C+2)%10,S=O[v],$=O[v+1],x=p(S,$,1)^O[I],ee=b(S,$,1)^O[I+1];for(let W=0;W<50;W+=10)T[C+W]^=x,T[C+W+1]^=ee}let N=T[2],E=T[3];for(let C=0;C<24;C++){const I=n[C],v=p(N,E,I),S=b(N,E,I),$=r[C];N=T[$],E=T[$+1],T[$]=v,T[$+1]=S}for(let C=0;C<50;C+=10){for(let I=0;I<10;I++)O[I]=T[C+I];for(let I=0;I<10;I++)T[C+I]^=~O[(I+2)%10]&O[(I+4)%10]}T[0]^=h[F],T[1]^=y[F]}O.fill(0)}re.keccakP=w;class P extends t.Hash{constructor(g,O,F,N=!1,E=24){if(super(),this.blockLen=g,this.suffix=O,this.outputLen=F,this.enableXOF=N,this.rounds=E,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,i.number)(F),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(g){(0,i.exists)(this);const{blockLen:O,state:F}=this;g=(0,t.toBytes)(g);const N=g.length;for(let E=0;E<N;){const C=Math.min(O-this.pos,N-E);for(let I=0;I<C;I++)F[this.pos++]^=g[E++];this.pos===O&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:g,suffix:O,pos:F,blockLen:N}=this;g[F]^=O,(O&128)!==0&&F===N-1&&this.keccak(),g[N-1]^=128,this.keccak()}writeInto(g){(0,i.exists)(this,!1),(0,i.bytes)(g),this.finish();const O=this.state,{blockLen:F}=this;for(let N=0,E=g.length;N<E;){this.posOut>=F&&this.keccak();const C=Math.min(F-this.posOut,E-N);g.set(O.subarray(this.posOut,this.posOut+C),N),this.posOut+=C,N+=C}return g}xofInto(g){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(g)}xof(g){return(0,i.number)(g),this.xofInto(new Uint8Array(g))}digestInto(g){if((0,i.output)(g,this),this.finished)throw new Error("digest() was already called");return this.writeInto(g),this.destroy(),g}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(g){const{blockLen:O,suffix:F,outputLen:N,rounds:E,enableXOF:C}=this;return g||(g=new P(O,F,N,C,E)),g.state32.set(this.state32),g.pos=this.pos,g.posOut=this.posOut,g.finished=this.finished,g.rounds=E,g.suffix=F,g.outputLen=N,g.enableXOF=C,g.destroyed=this.destroyed,g}}re.Keccak=P;const k=(T,g,O)=>(0,t.wrapConstructor)(()=>new P(g,T,O));re.sha3_224=k(6,144,224/8),re.sha3_256=k(6,136,256/8),re.sha3_384=k(6,104,384/8),re.sha3_512=k(6,72,512/8),re.keccak_224=k(1,144,224/8),re.keccak_256=k(1,136,256/8),re.keccak_384=k(1,104,384/8),re.keccak_512=k(1,72,512/8);const M=(T,g,O)=>(0,t.wrapXOFConstructorWithOpts)((F={})=>new P(g,T,F.dkLen===void 0?O:F.dkLen,!0));return re.shake128=M(31,168,128/8),re.shake256=M(31,136,256/8),re}var Ti;function za(){if(Ti)return Je;Ti=1;const{sha3_512:i}=Qa(),e=24,t=32,r=(p=4,b=Math.random)=>{let w="";for(;w.length<p;)w=w+Math.floor(b()*36).toString(36);return w};function n(p){let b=8n,w=0n;for(const P of p.values()){const k=BigInt(P);w=(w<<b)+k}return w}const s=(p="")=>n(i(p)).toString(36).slice(1),a=Array.from({length:26},(p,b)=>String.fromCharCode(b+97)),o=p=>a[Math.floor(p()*a.length)],l=({globalObj:p=typeof Zt<"u"?Zt:typeof window<"u"?window:{},random:b=Math.random}={})=>{const w=Object.keys(p).toString(),P=w.length?w+r(t,b):r(t,b);return s(P).substring(0,t)},u=p=>()=>p++,d=476782367,c=({random:p=Math.random,counter:b=u(Math.floor(p()*d)),length:w=e,fingerprint:P=l({random:p})}={})=>function(){const M=o(p),T=Date.now().toString(36),g=b().toString(36),O=r(w,p),F=`${T+O+g+P}`;return`${M+s(F).substring(1,w)}`},h=c(),y=(p,{minLength:b=2,maxLength:w=t}={})=>{const P=p.length,k=/^[0-9a-z]+$/;try{if(typeof p=="string"&&P>=b&&P<=w&&k.test(p))return!0}finally{}return!1};return Je.getConstants=()=>({defaultLength:e,bigLength:t}),Je.init=c,Je.createId=h,Je.bufToBigInt=n,Je.createCounter=u,Je.createFingerprint=l,Je.isCuid=y,Je}var Si;function Ka(){if(Si)return lt;Si=1;const{createId:i,init:e,getConstants:t,isCuid:r}=za();return lt.createId=i,lt.init=e,lt.getConstants=t,lt.isCuid=r,lt}var Fi=Ka();const Pi=Ut(i=>!isNaN(i)&&isFinite(i));class Y{static object(...e){return pe(void 0,...e)}static json(...e){let t=e;return t.valueConverter&&!t.valueConverter.fieldTypeInDb&&(t.valueConverter.fieldTypeInDb="json"),t.valueType&&!t.valueType.inputType&&(t.valueType.inputType=Te.json),pe(void 0,{valueConverter:{fieldTypeInDb:"json",inputType:Te.json}},...e)}static dateOnly(...e){return pe(()=>Date,{valueConverter:ve.DateOnly},...e)}static date(...e){return pe(()=>Date,...e)}static integer(...e){return pe(()=>Number,{valueConverter:ve.Integer,validate:Pi},...e)}static autoIncrement(...e){return pe(()=>Number,{allowApiUpdate:!1,dbReadOnly:!0,valueConverter:{...ve.Integer,fieldTypeInDb:"autoincrement"}},...e)}static number(...e){return pe(()=>Number,{validate:Pi},...e)}static createdAt(...e){return pe(()=>Date,{allowApiUpdate:!1,saving:(t,r,{isNew:n})=>{n&&(r.value=new Date)}},...e)}static updatedAt(...e){return pe(()=>Date,{allowApiUpdate:!1,saving:(t,r)=>{r.value=new Date}},...e)}static uuid(...e){return pe(()=>String,{allowApiUpdate:!1,defaultValue:()=>Mr(),saving:(t,r)=>{r.value||(r.value=Mr())}},...e)}static cuid(...e){return pe(()=>String,{allowApiUpdate:!1,defaultValue:()=>Fi.createId(),saving:(t,r)=>{r.value||(r.value=Fi.createId())}},...e)}static literal(e,...t){return Y.string({validate:(r,n)=>Fe.in(e())(r,n),[Ar]:e},...t)}static enum(e,...t){let r;return pe(()=>e(),{validate:(n,s)=>Fe.enum(e())(n,s),[Ar]:()=>Vt(e())},...t,n=>{if(n[Ar]=()=>Vt(e()),r===void 0){let s=e();r=Vt(s).find(o=>typeof o=="string")?ve.String:ve.Integer}n.valueConverter?n.valueConverter.fieldTypeInDb||(n.valueConverter.fieldTypeInDb=r.fieldTypeInDb):n.valueConverter=r})}static string(...e){return pe(()=>String,...e)}static boolean(...e){return pe(()=>Boolean,...e)}}class or{static toOne(e,t){let r=typeof t=="string"?{field:t}:t||{};return!r.field&&!r.fields&&!r.findOptions?pe(e,{...r,...vr(e,"reference")}):pe(()=>{},{...r,serverExpression:()=>{},...vr(e,"toOne")})}static toMany(e,t){return pe(()=>{},{...typeof t=="string"?{field:t}:t,serverExpression:()=>{},...vr(e,"toMany")})}}function pe(i,...e){return(t,r,n)=>{const s=typeof r=="string"?r:r.name.toString();let a=u=>{let d=pn(e,u);if(d.required&&(d.validate=Wt(d.validate,Fe.required,!0)),ct(d,"maxLength")){let h=d;h.maxLength&&(h.validate=Wt(h.validate,Fe.maxLength(h.maxLength)))}if(ct(d,"minLength")){let h=d;h.minLength&&(h.validate=Wt(h.validate,Fe.minLength(h.minLength)))}!d.valueType&&i&&(d.valueType=i()),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};_n(t);let o=D.columnsOfType.get(t.constructor);o||(o=[],D.columnsOfType.set(t.constructor,o));let l=o.find(u=>u.key==s);if(!l)o.push({key:s,settings:a});else{let u=l.settings;l.settings=d=>{let c=u(d),h=a(d);return Object.assign(c,h)}}}}function _n(i){if(!i)throw new Error("Set the 'experimentalDecorators:true' option in your 'tsconfig' or 'jsconfig' (target undefined)")}function Xa(i,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(a=i[o])&&(s=(n<3?a(s):n>3?a(e,t,s):a(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function Ya(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)}class er extends mn{constructor(){super(...arguments);f(this,"id")}}Xa([Y.uuid(),Ya("design:type",String)],er.prototype,"id",void 0);var Ri={};/*! *****************************************************************************
|
|
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 Di;function Za(){if(Di)return Ri;Di=1;var i;return function(e){(function(t){var r=typeof Zt=="object"?Zt:typeof self=="object"?self:typeof this=="object"?this:Function("return this;")(),n=s(e);typeof r.Reflect>"u"?r.Reflect=e:n=s(r.Reflect,n),t(n);function s(a,o){return function(l,u){typeof a[l]!="function"&&Object.defineProperty(a,l,{configurable:!0,writable:!0,value:u}),o&&o(l,u)}}})(function(t){var r=Object.prototype.hasOwnProperty,n=typeof Symbol=="function",s=n&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=n&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",o=typeof Object.create=="function",l={__proto__:[]}instanceof Array,u=!o&&!l,d={create:o?function(){return dr(Object.create(null))}:l?function(){return dr({__proto__:null})}:function(){return dr({})},has:u?function(m,_){return r.call(m,_)}:function(m,_){return _ in m},get:u?function(m,_){return r.call(m,_)?m[_]:void 0}:function(m,_){return m[_]}},c=Object.getPrototypeOf(Function),h=typeof process=="object"&&process.env&&process.env.REFLECT_METADATA_USE_MAP_POLYFILL==="true",y=!h&&typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:qn(),p=!h&&typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:xn(),b=!h&&typeof WeakMap=="function"?WeakMap:Bn(),w=new b;function P(m,_,A,R){if(se(A)){if(!Hr(m))throw new TypeError;if(!Gr(_))throw new TypeError;return I(m,_)}else{if(!Hr(m))throw new TypeError;if(!ge(_))throw new TypeError;if(!ge(R)&&!se(R)&&!st(R))throw new TypeError;return st(R)&&(R=void 0),A=je(A),v(m,_,A,R)}}t("decorate",P);function k(m,_){function A(R,B){if(!ge(R))throw new TypeError;if(!se(B)&&!Dn(B))throw new TypeError;fe(m,_,R,B)}return A}t("metadata",k);function M(m,_,A,R){if(!ge(A))throw new TypeError;return se(R)||(R=je(R)),fe(m,_,A,R)}t("defineMetadata",M);function T(m,_,A){if(!ge(_))throw new TypeError;return se(A)||(A=je(A)),$(m,_,A)}t("hasMetadata",T);function g(m,_,A){if(!ge(_))throw new TypeError;return se(A)||(A=je(A)),x(m,_,A)}t("hasOwnMetadata",g);function O(m,_,A){if(!ge(_))throw new TypeError;return se(A)||(A=je(A)),ee(m,_,A)}t("getMetadata",O);function F(m,_,A){if(!ge(_))throw new TypeError;return se(A)||(A=je(A)),W(m,_,A)}t("getOwnMetadata",F);function N(m,_){if(!ge(m))throw new TypeError;return se(_)||(_=je(_)),He(m,_)}t("getMetadataKeys",N);function E(m,_){if(!ge(m))throw new TypeError;return se(_)||(_=je(_)),Be(m,_)}t("getOwnMetadataKeys",E);function C(m,_,A){if(!ge(_))throw new TypeError;se(A)||(A=je(A));var R=S(_,A,!1);if(se(R)||!R.delete(m))return!1;if(R.size>0)return!0;var B=w.get(_);return B.delete(A),B.size>0||w.delete(_),!0}t("deleteMetadata",C);function I(m,_){for(var A=m.length-1;A>=0;--A){var R=m[A],B=R(_);if(!se(B)&&!st(B)){if(!Gr(B))throw new TypeError;_=B}}return _}function v(m,_,A,R){for(var B=m.length-1;B>=0;--B){var he=m[B],J=he(_,A,R);if(!se(J)&&!st(J)){if(!ge(J))throw new TypeError;R=J}}return R}function S(m,_,A){var R=w.get(m);if(se(R)){if(!A)return;R=new y,w.set(m,R)}var B=R.get(_);if(se(B)){if(!A)return;B=new y,R.set(_,B)}return B}function $(m,_,A){var R=x(m,_,A);if(R)return!0;var B=fr(_);return st(B)?!1:$(m,B,A)}function x(m,_,A){var R=S(_,A,!1);return se(R)?!1:Pn(R.has(m))}function ee(m,_,A){var R=x(m,_,A);if(R)return W(m,_,A);var B=fr(_);if(!st(B))return ee(m,B,A)}function W(m,_,A){var R=S(_,A,!1);if(!se(R))return R.get(m)}function fe(m,_,A,R){var B=S(A,R,!0);B.set(m,_)}function He(m,_){var A=Be(m,_),R=fr(m);if(R===null)return A;var B=He(R,_);if(B.length<=0)return A;if(A.length<=0)return B;for(var he=new p,J=[],H=0,q=A;H<q.length;H++){var z=q[H],K=he.has(z);K||(he.add(z),J.push(z))}for(var Ge=0,zr=B;Ge<zr.length;Ge++){var z=zr[Ge],K=he.has(z);K||(he.add(z),J.push(z))}return J}function Be(m,_){var A=[],R=S(m,_,!1);if(se(R))return A;for(var B=R.keys(),he=Mn(B),J=0;;){var H=Ln(he);if(!H)return A.length=J,A;var q=Nn(H);try{A[J]=q}catch(z){try{$n(he)}finally{throw z}}J++}}function ur(m){if(m===null)return 1;switch(typeof m){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return m===null?1:6;default:return 6}}function se(m){return m===void 0}function st(m){return m===null}function Tn(m){return typeof m=="symbol"}function ge(m){return typeof m=="object"?m!==null:typeof m=="function"}function Sn(m,_){switch(ur(m)){case 0:return m;case 1:return m;case 2:return m;case 3:return m;case 4:return m;case 5:return m}var A="string",R=Qr(m,s);if(R!==void 0){var B=R.call(m,A);if(ge(B))throw new TypeError;return B}return Fn(m)}function Fn(m,_){var A,R,B;{var he=m.toString;if(Nt(he)){var R=he.call(m);if(!ge(R))return R}var A=m.valueOf;if(Nt(A)){var R=A.call(m);if(!ge(R))return R}}throw new TypeError}function Pn(m){return!!m}function Rn(m){return""+m}function je(m){var _=Sn(m);return Tn(_)?_:Rn(_)}function Hr(m){return Array.isArray?Array.isArray(m):m instanceof Object?m instanceof Array:Object.prototype.toString.call(m)==="[object Array]"}function Nt(m){return typeof m=="function"}function Gr(m){return typeof m=="function"}function Dn(m){switch(ur(m)){case 3:return!0;case 4:return!0;default:return!1}}function Qr(m,_){var A=m[_];if(A!=null){if(!Nt(A))throw new TypeError;return A}}function Mn(m){var _=Qr(m,a);if(!Nt(_))throw new TypeError;var A=_.call(m);if(!ge(A))throw new TypeError;return A}function Nn(m){return m.value}function Ln(m){var _=m.next();return _.done?!1:_}function $n(m){var _=m.return;_&&_.call(m)}function fr(m){var _=Object.getPrototypeOf(m);if(typeof m!="function"||m===c||_!==c)return _;var A=m.prototype,R=A&&Object.getPrototypeOf(A);if(R==null||R===Object.prototype)return _;var B=R.constructor;return typeof B!="function"||B===m?_:B}function qn(){var m={},_=[],A=function(){function J(H,q,z){this._index=0,this._keys=H,this._values=q,this._selector=z}return J.prototype["@@iterator"]=function(){return this},J.prototype[a]=function(){return this},J.prototype.next=function(){var H=this._index;if(H>=0&&H<this._keys.length){var q=this._selector(this._keys[H],this._values[H]);return H+1>=this._keys.length?(this._index=-1,this._keys=_,this._values=_):this._index++,{value:q,done:!1}}return{value:void 0,done:!0}},J.prototype.throw=function(H){throw this._index>=0&&(this._index=-1,this._keys=_,this._values=_),H},J.prototype.return=function(H){return this._index>=0&&(this._index=-1,this._keys=_,this._values=_),{value:H,done:!0}},J}();return function(){function J(){this._keys=[],this._values=[],this._cacheKey=m,this._cacheIndex=-2}return Object.defineProperty(J.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),J.prototype.has=function(H){return this._find(H,!1)>=0},J.prototype.get=function(H){var q=this._find(H,!1);return q>=0?this._values[q]:void 0},J.prototype.set=function(H,q){var z=this._find(H,!0);return this._values[z]=q,this},J.prototype.delete=function(H){var q=this._find(H,!1);if(q>=0){for(var z=this._keys.length,K=q+1;K<z;K++)this._keys[K-1]=this._keys[K],this._values[K-1]=this._values[K];return this._keys.length--,this._values.length--,H===this._cacheKey&&(this._cacheKey=m,this._cacheIndex=-2),!0}return!1},J.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=m,this._cacheIndex=-2},J.prototype.keys=function(){return new A(this._keys,this._values,R)},J.prototype.values=function(){return new A(this._keys,this._values,B)},J.prototype.entries=function(){return new A(this._keys,this._values,he)},J.prototype["@@iterator"]=function(){return this.entries()},J.prototype[a]=function(){return this.entries()},J.prototype._find=function(H,q){return this._cacheKey!==H&&(this._cacheIndex=this._keys.indexOf(this._cacheKey=H)),this._cacheIndex<0&&q&&(this._cacheIndex=this._keys.length,this._keys.push(H),this._values.push(void 0)),this._cacheIndex},J}();function R(J,H){return J}function B(J,H){return H}function he(J,H){return[J,H]}}function xn(){return function(){function m(){this._map=new y}return Object.defineProperty(m.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),m.prototype.has=function(_){return this._map.has(_)},m.prototype.add=function(_){return this._map.set(_,_),this},m.prototype.delete=function(_){return this._map.delete(_)},m.prototype.clear=function(){this._map.clear()},m.prototype.keys=function(){return this._map.keys()},m.prototype.values=function(){return this._map.values()},m.prototype.entries=function(){return this._map.entries()},m.prototype["@@iterator"]=function(){return this.keys()},m.prototype[a]=function(){return this.keys()},m}()}function Bn(){var m=16,_=d.create(),A=R();return function(){function q(){this._key=R()}return q.prototype.has=function(z){var K=B(z,!1);return K!==void 0?d.has(K,this._key):!1},q.prototype.get=function(z){var K=B(z,!1);return K!==void 0?d.get(K,this._key):void 0},q.prototype.set=function(z,K){var Ge=B(z,!0);return Ge[this._key]=K,this},q.prototype.delete=function(z){var K=B(z,!1);return K!==void 0?delete K[this._key]:!1},q.prototype.clear=function(){this._key=R()},q}();function R(){var q;do q="@@WeakMap@@"+H();while(d.has(_,q));return _[q]=!0,q}function B(q,z){if(!r.call(q,A)){if(!z)return;Object.defineProperty(q,A,{value:d.create()})}return q[A]}function he(q,z){for(var K=0;K<z;++K)q[K]=Math.random()*255|0;return q}function J(q){return typeof Uint8Array=="function"?typeof crypto<"u"?crypto.getRandomValues(new Uint8Array(q)):typeof msCrypto<"u"?msCrypto.getRandomValues(new Uint8Array(q)):he(new Uint8Array(q),q):he(new Array(q),q)}function H(){var q=J(m);q[6]=q[6]&79|64,q[8]=q[8]&191|128;for(var z="",K=0;K<m;++K){var Ge=q[K];(K===4||K===6||K===8)&&(z+="-"),Ge<16&&(z+="0"),z+=Ge.toString(16).toLowerCase()}return z}}function dr(m){return m.__=void 0,delete m.__,m}})}(i||(i={})),Ri}Za();const tr=class tr{constructor(e,t,r){f(this,"actionUrl");f(this,"queue");f(this,"allowed");f(this,"doWork");this.actionUrl=e,this.queue=t,this.allowed=r}async run(e,t,r){t===void 0&&(t=be.apiClient.url),r||(r=ht(be.apiClient.httpClient));let n=await r.post(t+"/"+this.actionUrl,e),s=n;if(s&&s.queuedJobId){let a=D.actionInfo.startBusyWithProgress();try{let o;if(await D.actionInfo.runActionWithoutBlockingUI(async()=>{for(;!o||!o.done;)o&&await new Promise(l=>setTimeout(()=>{l(void 0)},200)),o=await r.post(t+"/"+tr.apiUrlForJobStatus,{queuedJobId:n.queuedJobId}),o.progress&&a.progress(o.progress)}),o.error)throw o.error;return a.progress(1),o.result}finally{a.close()}}else return n}__register(e){e(this.actionUrl,this.queue,this.allowed,async(t,r,n)=>{try{var s=await this.execute(t,r,n);n.success(s)}catch(a){a.isForbiddenError?n.forbidden():n.error(a,void 0)}})}};f(tr,"apiUrlForJobStatus","jobStatusInQueue");let Rt=tr;class Lr extends Error{constructor(t="Forbidden"){super(t);f(this,"isForbiddenError",!0)}}class eo extends Rt{constructor(t,r,n,s){super(t,n.queue??!1,n.allowed);f(this,"types");f(this,"options");f(this,"originalMethod");this.types=r,this.options=n,this.originalMethod=s}async execute(t,r,n){let s={data:{}},a=r.dataProvider;return await kn(r,this.options,async()=>{if(!r.isAllowedForInstance(void 0,this.options.allowed))throw new Lr;t.args=await On(this.types(),t.args,r,a,n);try{s.data=await this.originalMethod(t.args)}catch(o){throw o}}),s}}function qe(i){return(e,t,r)=>{const n=typeof t=="string"?t:t.name.toString(),s=r?r.value:e;let a=s;_n(e);function o(){var d=typeof Reflect.getMetadata=="function"?Reflect.getMetadata("design:paramtypes",e,n):[];return i.paramTypes&&(d=typeof i.paramTypes=="function"?i.paramTypes():i.paramTypes),d}if(e.prototype!==void 0){let d=new eo((i!=null&&i.apiPrefix?i.apiPrefix+"/":"")+n,()=>o(),i,c=>s.apply(void 0,c));return d.doWork=async(c,h,y,p)=>(c=Li(o(),c),i.blockUser===!1?await D.actionInfo.runActionWithoutBlockingUI(async()=>(await d.run({args:c},y,p)).data):(await d.run({args:c},y,p)).data),a=async function(...c){return Pt()?await s.apply(this,c):await d.doWork(c,void 0)},Mi(e,a),a[Nr]=d,r?(r.value=a,r):a}let l=D.classHelpers.get(e.constructor);l||(l=new un,D.classHelpers.set(e.constructor,l));let u={__register(d){let c=new De;for(const h of l.classes.keys()){let y=l.classes.get(h);y.key||(y.key=c.repo(h).metadata.key),d(y.key+"/"+(i!=null&&i.apiPrefix?i.apiPrefix+"/":"")+n,i?i.queue??!1:!1,i.allowed,async(p,b,w)=>{p.args=p.args.map(k=>In(k)?void 0:k);let P=i.allowed;try{let k=b,M;await kn(k,i,async()=>{if(p.args=await On(o(),p.args,k,k.dataProvider,w),D.allEntities.includes(h)){let T=k.repo(h),g;const O=p.rowInfo;if(O.isNewRow)g=T.create(),await T.getEntityRef(g)._updateEntityBasedOnApi(O.data);else{let N=await T.find({where:{...T.metadata.idMetadata.getIdFilter(O.id),$and:[T.metadata.options.apiPrefilter??{}]}});if(N.length!=1)throw new Error("not found or too many matches");g=N[0],await T.getEntityRef(g)._updateEntityBasedOnApi(O.data)}if(!k.isAllowedForInstance(g,P))throw new Lr;let F=ie(g);await F.__validateEntity();try{M={result:await s.apply(g,p.args),rowInfo:{data:await F.toApiJson(),isNewRow:F.isNew(),wasChanged:F.wasChanged(),id:F.getOriginalId()}}}catch(N){throw F.catchSaveErrors(N)}}else{let T=new h(k,k.dataProvider),g=wi(T,k);if(await g._updateEntityBasedOnApi(p.fields),!k.isAllowedForInstance(T,P))throw new Lr;await g.__validateEntity();try{M={result:await s.apply(T,p.args),fields:await g.toApiJson()}}catch(O){throw g.catchSaveErrors(O)}}}),w.success(M)}catch(k){k.isForbiddenError?w.forbidden():w.error(k,void 0)}})}},doWork:async function(d,c,h,y){if(d=Li(o(),d),D.allEntities.includes(e.constructor)){let p=ie(c);await p.__validateEntity();let b=l.classes.get(c.constructor);b.key||(b.key=p.repository.metadata.key+"_methods");try{let w=await new class extends Rt{constructor(){super(...arguments);f(this,"execute")}}(b.key+"/"+(i!=null&&i.apiPrefix?i.apiPrefix+"/":"")+n,(i==null?void 0:i.queue)??!1,i.allowed).run({args:d,rowInfo:{data:await p.toApiJson(),isNewRow:p.isNew(),wasChanged:p.wasChanged(),id:p.getOriginalId()}},h,y);return await p._updateEntityBasedOnApi(w.rowInfo.data,!0),w.result}catch(w){throw p.catchSaveErrors(w)}}else{let p=wi(c,void 0);try{await p.__validateEntity();let b=await new class extends Rt{constructor(){super(...arguments);f(this,"execute")}}(l.classes.get(c.constructor).key+"/"+(i!=null&&i.apiPrefix?i.apiPrefix+"/":"")+n,(i==null?void 0:i.queue)??!1,i.allowed).run({args:d,fields:await p.toApiJson()},h,y);return await p._updateEntityBasedOnApi(b.fields),b.result}catch(b){throw p.catchSaveErrors(b)}}}};return a=async function(...d){let c=this;return Pt()?await s.apply(c,d):u.doWork(d,c)},Mi(e.constructor,a),a[Nr]=u,r?(r.value=a,r):a}}const to={_isUndefined:!0};function Mi(i,e){(i[$i]||(i[$i]=[])).push(e),D.actionInfo.allActions.push(e)}function In(i){return i&&i._isUndefined}class Ni{constructor(e){f(this,"res");this.res=e}progress(e){this.res.progress(e)}}function Li(i,e){if(i)for(let t=0;t<i.length;t++){const r=i[t];for(const n of[De,yt])(e[t]instanceof n||r==n)&&(e[t]=void 0);if(e[t]!=null){let n={valueType:r};if(n=Vr(n,new De),Oe(r,!1)!=null){let a=ie(e[t]);e[t]=a.getId()}n.valueConverter&&(e[t]=n.valueConverter.toJson(e[t]))}}return e.map(t=>t!==void 0?t:to)}async function On(i,e,t,r,n){for(let s=0;s<e.length;s++){const a=e[s];In(a)&&(e[s]=void 0)}if(i)for(let s=0;s<i.length;s++)if(e.length<s&&e.push(void 0),i[s]==De||i[s]==De)e[s]=t;else if(i[s]==yt&&r)e[s]=r;else if(i[s]==Ni)e[s]=new Ni(n);else{let a={valueType:i[s]};a=Vr(a,t),a.valueConverter&&(e[s]=a.valueConverter.fromJson(e[s])),Oe(i[s],!1)!=null&&(e[s]===null||e[s]===void 0||(e[s]=await t.repo(i[s]).findId(e[s])))}return e}const $i=Symbol.for("classBackendMethodsArray");async function kn(i,e,t){if(e.transactional===void 0||e.transactional===!0)return await Ia(i,t);await t(i.dataProvider)}function Cn(i,e){return be.repo(i,e)}D.actionInfo;class ro{constructor(e,t){f(this,"id");f(this,"caption");f(this,"icon");f(this,"where");f(this,"class");f(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)}}const gt={FF_Role_Admin:"FF_Role.Admin"};var io=Object.defineProperty,no=Object.getOwnPropertyDescriptor,We=(i,e,t,r)=>{for(var n=r>1?void 0:r?no(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(n=(r?a(e,t,n):a(n))||n);return r&&n&&io(e,t,n),n};const so={ChangeLog__Admin:"changeLog__admin"};let Pe=class{constructor(){f(this,"id","");f(this,"entity","");f(this,"entityId","");f(this,"changeDate",new Date);f(this,"userId","");f(this,"changes",[]);f(this,"newRow",!1);f(this,"deleted",!1)}};We([Y.cuid()],Pe.prototype,"id",2);We([Y.string()],Pe.prototype,"entity",2);We([Y.string()],Pe.prototype,"entityId",2);We([Y.date()],Pe.prototype,"changeDate",2);We([Y.string()],Pe.prototype,"userId",2);We([Y.json({dbName:"changesJson"})],Pe.prototype,"changes",2);We([Y.boolean()],Pe.prototype,"newRow",2);We([Y.boolean()],Pe.prototype,"deleted",2);Pe=We([vn("_ff_change_logs",{caption:"FF Change Logs",allowApiCrud:so.ChangeLog__Admin,defaultOrderBy:{changeDate:"desc"}})],Pe);async function ao(i,e,t){var r;if(Pt()){const n=[],s=new An(i,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(u=>u.valueChanged()||a&&u.value))try{const u=s.excludedValues.includes(l);n.push({key:l.metadata.key,newValue:u?"***":l.value instanceof er?l.value.id:l.metadata.options.valueConverter.toJson(l.value),oldValue:e.isNew?"---":u?"***":l.originalValue instanceof er?l.originalValue.id:l.metadata.options.valueConverter.toJson(l.originalValue)})}catch(u){throw console.error(l),u}n.length>0&&await Cn(Pe).insert({changeDate:o,changes:n,entity:e.metadata.key,entityId:e.metadata.idMetadata.getId(i),userId:((r=be.user)==null?void 0:r.id)||"",newRow:a})}}async function oo(i,e,t){var a;const r=[],n=new An(i,t),s=(t==null?void 0:t.forceDate)||new Date;for(const o of n.fields)try{const l=n.excludedValues.includes(o);r.push({key:o.metadata.key,newValue:l?"***":"---",oldValue:l?"***":o.originalValue instanceof er?o.originalValue.id:o.metadata.options.valueConverter.toJson(o.originalValue)})}catch(l){throw console.error(o),l}await Cn(Pe).insert({changeDate:s,changes:r,entity:e.metadata.key,entityId:e.metadata.idMetadata.getId(i),userId:((a=be.user)==null?void 0:a.id)||"",deleted:!0})}class An{constructor(e,t){f(this,"fields");f(this,"excludedFields");f(this,"excludedValues");const r=ie(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(n=>n.metadata.options.serverExpression)),this.excludedFields.push(...r.fields.toArray().filter(n=>n.metadata.options.sqlExpression)),this.fields=r.fields.toArray().filter(n=>!this.excludedFields.includes(n))}}const kt=i=>{if(i)return Array.isArray(i)?i.map(e=>e.id):i.id};function Wr(i,e){return vn(i,{...e,allowApiCrud:(e==null?void 0:e.allowApiCrud)??kt(e==null?void 0:e.permissionApiCrud),allowApiDelete:(e==null?void 0:e.allowApiDelete)??kt(e==null?void 0:e.permissionApiDelete),allowApiInsert:(e==null?void 0:e.allowApiInsert)??kt(e==null?void 0:e.permissionApiInsert),allowApiRead:(e==null?void 0:e.allowApiRead)??kt(e==null?void 0:e.permissionApiRead),allowApiUpdate:(e==null?void 0:e.allowApiUpdate)??kt(e==null?void 0:e.permissionApiUpdate),saved:async(t,r)=>{var n;await((n=e==null?void 0:e.saved)==null?void 0:n.call(e,t,r)),(e==null?void 0:e.changeLog)===!1||Pt()&&await ao(t,r,e==null?void 0:e.changeLog)},deleted:async(t,r)=>{var n;await((n=e==null?void 0:e.deleted)==null?void 0:n.call(e,t,r)),(e==null?void 0:e.changeLog)===!1||Pt()&&await oo(t,r,e==null?void 0:e.changeLog)}})}var En=Object.defineProperty,lo=Object.getOwnPropertyDescriptor,uo=(i,e,t)=>e in i?En(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,te=(i,e,t,r)=>{for(var n=r>1?void 0:r?lo(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(n=(r?a(e,t,n):a(n))||n);return r&&n&&En(e,t,n),n},lr=(i,e,t)=>uo(i,typeof e!="symbol"?e+"":e,t);const nt={FF_Role_Auth_Admin:"FF_Role_Auth.Admin",FF_Role_Auth_Invite:"FF_Role_Auth.Invite"};let Me=class{constructor(){f(this,"id");f(this,"createdAt");f(this,"updatedAt");f(this,"name");f(this,"roles",[]);f(this,"accounts");f(this,"sessions")}};te([Y.cuid()],Me.prototype,"id",2);te([Y.createdAt({includeInApi:[nt.FF_Role_Auth_Admin,gt.FF_Role_Admin]})],Me.prototype,"createdAt",2);te([Y.updatedAt({includeInApi:[nt.FF_Role_Auth_Admin,gt.FF_Role_Admin]})],Me.prototype,"updatedAt",2);te([Y.string({required:!0,validate:[Fe.unique(),Fe.required()]})],Me.prototype,"name",2);te([Y.json(()=>[],{includeInApi:[nt.FF_Role_Auth_Admin,gt.FF_Role_Admin],inputType:"selectEnum",valueConverter:{toDb:i=>i===null?null:Array.isArray(i)?i.join(","):i,fromDb:i=>i?i.split(",").map(e=>e.replace("{","").replace("}","")).filter(e=>e!==""):[]}})],Me.prototype,"roles",2);te([or.toMany(()=>_e,"userId")],Me.prototype,"accounts",2);te([or.toMany(()=>rt,"userId")],Me.prototype,"sessions",2);Me=te([Wr("ff_auth.users",{allowApiCrud:[nt.FF_Role_Auth_Admin,gt.FF_Role_Admin],caption:"FF Auth - Users"})],Me);let _e=class{constructor(){f(this,"id");f(this,"createdAt");f(this,"updatedAt");f(this,"userId");f(this,"user");f(this,"provider",Ne.PASSWORD.id);f(this,"providerUserId","");f(this,"email",null);f(this,"hashPassword");f(this,"token");f(this,"expiresAt");f(this,"lastVerifiedAt");f(this,"metadata")}};te([Y.cuid()],_e.prototype,"id",2);te([Y.createdAt()],_e.prototype,"createdAt",2);te([Y.updatedAt()],_e.prototype,"updatedAt",2);te([Y.string()],_e.prototype,"userId",2);te([or.toOne(()=>Me,"userId")],_e.prototype,"user",2);te([Y.string()],_e.prototype,"provider",2);te([Y.string()],_e.prototype,"providerUserId",2);te([Y.string({allowNull:!0})],_e.prototype,"email",2);te([Y.string({includeInApi:!1,allowNull:!0})],_e.prototype,"hashPassword",2);te([Y.string({includeInApi:!1,allowNull:!0})],_e.prototype,"token",2);te([Y.date({includeInApi:!1,allowNull:!0})],_e.prototype,"expiresAt",2);te([Y.date({includeInApi:!1,allowNull:!0})],_e.prototype,"lastVerifiedAt",2);te([Y.json({includeInApi:!1,allowNull:!0})],_e.prototype,"metadata",2);_e=te([Wr("ff_auth.accounts",{allowApiCrud:[nt.FF_Role_Auth_Admin,gt.FF_Role_Admin],caption:"FF Auth - Accounts",changeLog:{excludeColumns:i=>[i.hashPassword,i.token]}})],_e);let rt=class{constructor(){f(this,"id");f(this,"expiresAt");f(this,"userId");f(this,"user")}};te([Y.string()],rt.prototype,"id",2);te([Y.date()],rt.prototype,"expiresAt",2);te([Y.string()],rt.prototype,"userId",2);te([or.toOne(()=>Me,"userId")],rt.prototype,"user",2);rt=te([Wr("ff_auth.users_sessions",{allowApiCrud:[nt.FF_Role_Auth_Admin,gt.FF_Role_Admin],caption:"FF Auth - Users sessions",changeLog:!1})],rt);let Ne=class extends ro{constructor(i,e){super(i,{...e})}};lr(Ne,"DEMO",new Ne("DEMO",{caption:"Demo"}));lr(Ne,"PASSWORD",new Ne("PASSWORD",{caption:"Password"}));lr(Ne,"OTP",new Ne("OTP",{caption:"TOTP"}));lr(Ne,"OAUTH",new Ne("OAUTH",{caption:"OAUTH"}));Ne=te([La()],Ne);var fo=Object.defineProperty,co=Object.getOwnPropertyDescriptor,xe=(i,e,t,r)=>{for(var n=co(e,t),s=i.length-1,a;s>=0;s--)(a=i[s])&&(n=a(e,t,n)||n);return n&&fo(e,t,n),n},we,ke;const Le=(we=class{static _setAbstraction(e){Zr(this,ke,e)}static async signOut(){return await Re(we,ke).signOut()}static async signInDemo(e){return await Re(we,ke).signInDemo(e)}static async invite(e){return await Re(we,ke).invite(e)}static async signUpPassword(e,t){return await Re(we,ke).signUpPassword(e,t)}static async signInPassword(e,t){return await Re(we,ke).signInPassword(e,t)}static async forgotPassword(e){return await Re(we,ke).forgotPassword(e)}static async resetPassword(e,t){return await Re(we,ke).resetPassword(e,t)}static async signInOTP(e){return await Re(we,ke).signInOTP(e)}static async verifyOtp(e,t){return await Re(we,ke).verifyOtp(e,t)}static async signInOAuthGetUrl(e){return await Re(we,ke).signInOAuthGetUrl(e)}},ke=new WeakMap,Yr(we,ke),we);xe([qe({allowed:!0})],Le,"signOut");xe([qe({allowed:!0})],Le,"signInDemo");xe([qe({allowed:nt.FF_Role_Auth_Invite})],Le,"invite");xe([qe({allowed:!0})],Le,"signUpPassword");xe([qe({allowed:!0})],Le,"signInPassword");xe([qe({allowed:!0})],Le,"forgotPassword");xe([qe({allowed:!0})],Le,"resetPassword");xe([qe({allowed:!0})],Le,"signInOTP");xe([qe({allowed:!0})],Le,"verifyOtp");xe([qe({allowed:!0})],Le,"signInOAuthGetUrl");let Mt=Le;function Ve(i){i.focus()}var ho=ue('<div class="login"><p> </p> <form class="svelte-skcj83"><input required type="email"/> <button> </button></form></div>');function yo(i,e){ze(e,!1);let t=Ee(e,"firstlyDataAuth",8),r=Ee(e,"email",12,""),n=Ie(""),s=Ie(""),a=Ie(!1);async function o(){Z(n,""),Z(s,""),Z(a,!0);try{const w=await Mt.forgotPassword(r());Z(s,w.message??"")}catch(w){w&&Z(n,w.message??""),Z(a,!1)}}pt();var l=ho(),u=Q(l);let d;var c=Q(u),h=G(u,2),y=Q(h);nr(y,w=>Ve==null?void 0:Ve(w)),it(()=>tt(y,r));var p=G(y,2),b=Q(p);Ce((w,P)=>{d=mt(u,1,"message",null,d,w),oe(c,`${V(n)??""}${V(s)??""}`),$e(y,"placeholder",(ae(t()),le(()=>{var k;return(k=t().ui)==null?void 0:k.strings.email_placeholder}))),p.disabled=P,oe(b,(ae(t()),le(()=>{var k;return(k=t().ui)==null?void 0:k.strings.send_password_reset_instructions})))},[()=>({error:V(n),success:V(s)}),()=>(ae(r()),V(a),le(()=>!r()||!r().includes("@")||!r().includes(".")||V(a)))],ir),Dt("submit",h,sr(o)),X(i,l),Ke()}var po=(i,e,t)=>e(V(t).name),mo=ue('<div class="oauth-button-icon svelte-1dwkktf"><!></div>'),go=ue('<button class="oauth-button svelte-1dwkktf"><!> <span> </span></button>'),wo=ue('<hr style="margin: 1rem"/> <div class="oauth-container svelte-1dwkktf"></div>',1);function qi(i,e){ze(e,!0);const t=async a=>{const o=await Mt.signInOAuthGetUrl({provider:a,redirect:new URL(window.location.href).searchParams.get("redirect")??"/"});window.location.href=o};var r=St(),n=Se(r);{var s=a=>{var o=wo(),l=G(Se(o),2);hs(l,21,()=>{var u;return((u=e.firstlyDataAuth)==null?void 0:u.providers)??[]},u=>u.name,(u,d)=>{var c=go();c.__click=[po,t,d];var h=Q(c);{var y=w=>{var P=mo(),k=Q(P);ms(k,()=>V(d).raw_svg),X(w,P)};me(h,w=>{V(d).raw_svg&&w(y)})}var p=G(h,2),b=Q(p);Ce(()=>oe(b,V(d).label)),X(u,c)}),X(a,o)};me(n,a=>{var o;(((o=e.firstlyDataAuth)==null?void 0:o.providers)??[].length!==0)&&a(s)})}X(i,r),Ke()}Ji(["click"]);var vo=ue('<div class="login"><p> </p> <form class="svelte-skcj83"> <input type="password" required/> <input type="password" required/> <button> </button></form></div>');function bo(i,e){ze(e,!1);let t=Ee(e,"firstlyDataAuth",8),r=Ee(e,"password1",12,""),n=Ee(e,"password2",12,""),s=Ie(""),a=Ie(""),o=Ie(!1);async function l(){Z(s,""),Z(a,""),Z(o,!0);const T=new URL(location.href).searchParams.get("token");try{const g=await Mt.resetPassword(T??"",r());Z(a,g.message??""),window.location.href="/"}catch(g){g&&Z(s,g.message??""),Z(o,!1)}}pt();var u=vo(),d=Q(u);let c;var h=Q(d),y=G(d,2),p=Q(y),b=G(p),w=G(b),P=G(w),k=G(P,2),M=Q(k);Ce(T=>{c=mt(d,1,"message",null,c,T),oe(h,`${V(s)??""}${V(a)??""}`),oe(p,`${ae(t()),le(()=>{var g;return(g=t().ui)==null?void 0:g.strings.password})??""} `),$e(b,"placeholder",(ae(t()),le(()=>{var g;return(g=t().ui)==null?void 0:g.strings.password_placeholder}))),oe(w,` ${ae(t()),le(()=>{var g;return(g=t().ui)==null?void 0:g.strings.confirm})??""} `),$e(P,"placeholder",(ae(t()),le(()=>{var g;return(g=t().ui)==null?void 0:g.strings.password_placeholder}))),k.disabled=!r()||!n()||V(o),oe(M,(ae(t()),le(()=>{var g;return(g=t().ui)==null?void 0:g.strings.reset})))},[()=>({error:V(s)})],ir),tt(b,r),tt(P,n),Dt("submit",y,sr(l)),X(i,u),Ke()}var _o=ue('<form class="svelte-skcj83"><p> </p> <label> <input required type="email"/></label> <label> <input required type="password"/></label> <button> </button></form>');function Io(i,e){ze(e,!1);let t=Ee(e,"firstlyDataAuth",8),r=Ee(e,"view",8,"login"),n=Ee(e,"email",12,""),s=Ie(""),a=Ie(""),o=Ie(),l=Ie(!1);async function u(){Z(s,""),Z(a,""),Z(l,!0);try{await Mt.signInPassword(n(),V(o)),window.location.href=new URL(window.location.href).searchParams.get("redirect")??"/"}catch(y){y&&Z(s,y.message??""),Z(l,!1)}}pt();var d=St(),c=Se(d);{var h=y=>{var p=_o(),b=Q(p);let w;var P=Q(b),k=G(b,2),M=Q(k),T=G(M);it(()=>tt(T,n)),nr(T,C=>Ve==null?void 0:Ve(C));var g=G(k,2),O=Q(g),F=G(O),N=G(g,2),E=Q(N);Ce(C=>{w=mt(b,1,"message",null,w,C),oe(P,`${V(s)??""}${V(a)??""}`),oe(M,`${ae(t()),le(()=>{var I;return(I=t().ui)==null?void 0:I.strings.email})??""} `),$e(T,"placeholder",(ae(t()),le(()=>{var I;return(I=t().ui)==null?void 0:I.strings.email_placeholder}))),oe(O,`${ae(t()),le(()=>{var I;return(I=t().ui)==null?void 0:I.strings.password})??""} `),$e(F,"placeholder",(ae(t()),le(()=>{var I;return(I=t().ui)==null?void 0:I.strings.password_placeholder}))),N.disabled=!n()||!V(o)||V(l),oe(E,(ae(t()),le(()=>{var I;return(I=t().ui)==null?void 0:I.strings.btn_sign_in})))},[()=>({error:V(s)})],ir),tt(F,()=>V(o),C=>Z(o,C)),Dt("submit",p,sr(u)),X(y,p)};me(c,y=>{r()=="login"&&y(h)})}X(i,d),Ke()}var Oo=ue('<form class="svelte-skcj83"><p> </p> <label> <input required type="email"/></label> <label> <input required type="password"/></label> <button> </button></form>');function ko(i,e){ze(e,!1);let t=Ee(e,"firstlyDataAuth",8),r=Ee(e,"view",8,"login"),n=Ee(e,"email",12,""),s=Ie(""),a=Ie(""),o=Ie(),l=Ie(!1);async function u(){Z(s,""),Z(a,""),Z(l,!0);try{const y=await Mt.signUpPassword(n(),V(o));Z(a,y.message??""),await new Promise(p=>setTimeout(p,5e3)),window.location.href=new URL(window.location.href).searchParams.get("redirect")??"/"}catch(y){y&&Z(s,y.message??""),Z(l,!1)}}pt();var d=St(),c=Se(d);{var h=y=>{var p=Oo(),b=Q(p);let w;var P=Q(b),k=G(b,2),M=Q(k),T=G(M);it(()=>tt(T,n)),nr(T,C=>Ve==null?void 0:Ve(C));var g=G(k,2),O=Q(g),F=G(O),N=G(g,2),E=Q(N);Ce(C=>{w=mt(b,1,"message",null,w,C),oe(P,`${V(s)??""}${V(a)??""}`),oe(M,`${ae(t()),le(()=>{var I;return(I=t().ui)==null?void 0:I.strings.email})??""} `),$e(T,"placeholder",(ae(t()),le(()=>{var I;return(I=t().ui)==null?void 0:I.strings.email_placeholder}))),oe(O,`${ae(t()),le(()=>{var I;return(I=t().ui)==null?void 0:I.strings.password})??""} `),$e(F,"placeholder",(ae(t()),le(()=>{var I;return(I=t().ui)==null?void 0:I.strings.password_placeholder}))),N.disabled=!n()||!V(o)||V(l),oe(E,(ae(t()),le(()=>{var I;return(I=t().ui)==null?void 0:I.strings.btn_sign_up})))},[()=>({error:V(s)})],ir),tt(F,()=>V(o),C=>Z(o,C)),Dt("submit",p,sr(u)),X(y,p)};me(c,y=>{r()=="login"&&y(h)})}X(i,d),Ke()}var Co=ue('<h1 class="svelte-1jjivcr"> </h1>'),Ao=ue('<!> <div class="form-footer svelte-1jjivcr"><!></div> <!>',1),Eo=ue("<hr/> <!>",1),To=ue('<!> <div class="form-footer svelte-1jjivcr"><!> <!></div> <!>',1),So=ue('<!> <div class="form-footer svelte-1jjivcr"><!></div>',1),Fo=ue('<!> <div class="form-footer svelte-1jjivcr"><!></div>',1),Po=ue('<div class="form svelte-1jjivcr"><!> <!> <!> <!> <!></div>'),Ro=ue('<img alt="Authentication" class="svelte-1jjivcr"/>'),Do=ue('<div class="split-layout svelte-1jjivcr"><div class="form-side svelte-1jjivcr"><!></div> <div class="image-side svelte-1jjivcr"><!></div></div>'),Mo=ue('<div class="centered-layout svelte-1jjivcr"><!></div>'),No=ue('<div class="fallback svelte-1jjivcr"><small>- 404 -</small></div> <div class="fallback svelte-1jjivcr"><small>Nothing to see here</small></div>',1),Lo=ue("<!> <!>",1),$o=ue("<div><!></div>");function Bo(i,e){ze(e,!0);const t=u=>{var d=Po(),c=Q(d);{var h=g=>{var O=Co(),F=Q(O);Ce(()=>oe(F,r.ui.strings.app_name)),X(g,O)};me(c,g=>{var O;(O=r.ui)!=null&&O.strings.app_name&&g(h)})}var y=G(c,2);{var p=g=>{const O=wt(()=>{var F;return(F=r.ui)==null?void 0:F.paths.sign_up});at(g,{get path(){return V(O)},children:(F,N)=>{var E=Ao(),C=Se(E);ko(C,{get firstlyDataAuth(){return r},get email(){return V(n)},set email(x){Z(n,x,!0)}});var I=G(C,2),v=Q(I);{var S=x=>{It(x,{get href(){return r.ui.paths.sign_in},children:(ee,W)=>{var fe=vt();Ce(()=>oe(fe,r.ui.strings.back_to_sign_in)),X(ee,fe)},$$slots:{default:!0}})};me(v,x=>{r.ui.paths.sign_in&&x(S)})}var $=G(I,2);qi($,{get firstlyDataAuth(){return r}}),X(F,E)},$$slots:{default:!0}})};me(y,g=>{var O;(O=r.ui)!=null&&O.paths.sign_up&&g(p)})}var b=G(y,2);{var w=g=>{const O=wt(()=>{var F;return(F=r.ui)==null?void 0:F.paths.sign_in});at(g,{get path(){return V(O)},children:(F,N)=>{var E=To(),C=Se(E);Io(C,{get firstlyDataAuth(){return r},get email(){return V(n)},set email(W){Z(n,W,!0)}});var I=G(C,2),v=Q(I);{var S=W=>{It(W,{get href(){return r.ui.paths.forgot_password},children:(fe,He)=>{var Be=vt();Ce(()=>oe(Be,r.ui.strings.forgot_password)),X(fe,Be)},$$slots:{default:!0}})};me(v,W=>{var fe;(fe=r.ui)!=null&&fe.paths.forgot_password&&W(S)})}var $=G(v,2);{var x=W=>{var fe=Eo(),He=G(Se(fe),2);It(He,{get href(){return r.ui.paths.sign_up},children:(Be,ur)=>{var se=vt();Ce(()=>oe(se,r.ui.strings.btn_sign_up)),X(Be,se)},$$slots:{default:!0}}),X(W,fe)};me($,W=>{var fe;(fe=r.ui)!=null&&fe.paths.sign_up&&W(x)})}var ee=G(I,2);qi(ee,{get firstlyDataAuth(){return r}}),X(F,E)},$$slots:{default:!0}})};me(b,g=>{var O;(O=r.ui)!=null&&O.paths.sign_in&&g(w)})}var P=G(b,2);{var k=g=>{const O=wt(()=>{var F;return(F=r.ui)==null?void 0:F.paths.forgot_password});at(g,{get path(){return V(O)},children:(F,N)=>{var E=So(),C=Se(E);yo(C,{get firstlyDataAuth(){return r},get email(){return V(n)},set email($){Z(n,$,!0)}});var I=G(C,2),v=Q(I);{var S=$=>{It($,{get href(){return r.ui.paths.sign_in},children:(x,ee)=>{var W=vt();Ce(()=>oe(W,r.ui.strings.back_to_sign_in)),X(x,W)},$$slots:{default:!0}})};me(v,$=>{var x;(x=r.ui)!=null&&x.paths.sign_in&&$(S)})}X(F,E)},$$slots:{default:!0}})};me(P,g=>{var O;(O=r.ui)!=null&&O.paths.forgot_password&&g(k)})}var M=G(P,2);{var T=g=>{const O=wt(()=>{var F;return(F=r.ui)==null?void 0:F.paths.reset_password});at(g,{get path(){return V(O)},children:(F,N)=>{var E=Fo(),C=Se(E);bo(C,{get firstlyDataAuth(){return r}});var I=G(C,2),v=Q(I);{var S=$=>{It($,{get href(){return r.ui.paths.sign_in},children:(x,ee)=>{var W=vt();Ce(()=>oe(W,r.ui.strings.back_to_sign_in)),X(x,W)},$$slots:{default:!0}})};me(v,$=>{var x;(x=r.ui)!=null&&x.paths.sign_in&&$(S)})}X(F,E)},$$slots:{default:!0}})};me(M,g=>{var O;(O=r.ui)!=null&&O.paths.reset_password&&g(T)})}X(u,d)};let r=e.firstlyData.props,n=ys(""),s=wt(()=>{var u,d;return!!((d=(u=r.ui)==null?void 0:u.images)!=null&&d.main)});var a=$o();let o;var l=Q(a);at(l,{children:(u,d)=>{var c=Lo(),h=Se(c);{var y=w=>{var P=Do(),k=Q(P),M=Q(k);t(M);var T=G(k,2),g=Q(T);{var O=F=>{var N=Ro();Ce(()=>$e(N,"src",r.ui.images.main)),X(F,N)};me(g,F=>{var N,E;(E=(N=r.ui)==null?void 0:N.images)!=null&&E.main&&F(O)})}X(w,P)},p=w=>{var P=Mo(),k=Q(P);t(k),X(w,P)};me(h,w=>{V(s)?w(y):w(p,!1)})}var b=G(h,2);at(b,{fallback:!0,children:(w,P)=>{var k=No();X(w,k)},$$slots:{default:!0}}),X(u,c)},$$slots:{default:!0}}),Ce(u=>o=mt(a,1,"wrapper svelte-1jjivcr",null,o,u),[()=>({"with-image":V(s)})]),X(i,a),Ke()}export{Bo as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{aa as e,U as o}from"./index-RpcgeXPm.js";function f(a){var t=e("Hello from admin");o(a,t)}export{f as default};
|