firstly 0.0.1 → 0.0.2
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 +8 -0
- package/LICENSE +18 -0
- package/README.md +12 -0
- package/esm/KitBaseEnum.d.ts +35 -0
- package/esm/KitBaseEnum.js +32 -0
- package/esm/KitEntity.d.ts +2 -0
- package/esm/KitEntity.js +24 -0
- package/esm/KitFields.d.ts +10 -0
- package/esm/KitFields.js +196 -0
- package/esm/ROUTES.d.ts +88 -0
- package/esm/ROUTES.js +98 -0
- package/esm/SqlDatabase/LogToConsoleCustom.d.ts +1 -0
- package/esm/SqlDatabase/LogToConsoleCustom.js +102 -0
- package/esm/api/index.d.ts +42 -0
- package/esm/api/index.js +97 -0
- package/esm/auth/Adapter.d.ts +10 -0
- package/esm/auth/Adapter.js +54 -0
- package/esm/auth/AuthController.d.ts +59 -0
- package/esm/auth/AuthController.js +434 -0
- package/esm/auth/Entities.d.ts +39 -0
- package/esm/auth/Entities.js +154 -0
- package/esm/auth/RoleController.d.ts +14 -0
- package/esm/auth/RoleController.js +57 -0
- package/esm/auth/helper.d.ts +1 -0
- package/esm/auth/helper.js +7 -0
- package/esm/auth/index.d.ts +153 -0
- package/esm/auth/index.js +279 -0
- package/esm/auth/providers/github.d.ts +25 -0
- package/esm/auth/providers/github.js +51 -0
- package/esm/auth/providers/index.d.ts +3 -0
- package/esm/auth/providers/index.js +26 -0
- package/esm/auth/providers/strava.d.ts +25 -0
- package/esm/auth/providers/strava.js +51 -0
- package/esm/auth/static/assets/Page-BMFREPjF.d.ts +5 -0
- package/esm/auth/static/assets/Page-BMFREPjF.js +18 -0
- package/esm/auth/static/assets/Page-BMOLAIFx.d.ts +5 -0
- package/esm/auth/static/assets/Page-BMOLAIFx.js +1 -0
- package/esm/auth/static/assets/Page-BwHye0GW.d.ts +5 -0
- package/esm/auth/static/assets/Page-BwHye0GW.js +1 -0
- package/esm/auth/static/assets/Page-gV58jf2r.css +1 -0
- package/esm/auth/static/assets/index-CKmKKRRL.d.ts +53 -0
- package/esm/auth/static/assets/index-CKmKKRRL.js +2 -0
- package/esm/auth/static/assets/index-R27C_TlP.css +4 -0
- package/esm/auth/static/favicon.svg +79 -0
- package/esm/auth/static/index.html +14 -0
- package/esm/auth/types.d.ts +33 -0
- package/esm/auth/types.js +1 -0
- package/esm/bin/cmd.d.ts +1 -0
- package/esm/bin/cmd.js +408 -0
- package/esm/changeLog/index.d.ts +55 -0
- package/esm/changeLog/index.js +179 -0
- package/esm/cron/index.d.ts +60 -0
- package/esm/cron/index.js +102 -0
- package/esm/feedback/FeedbackController.d.ts +30 -0
- package/esm/feedback/FeedbackController.js +313 -0
- package/esm/feedback/index.d.ts +18 -0
- package/esm/feedback/index.js +14 -0
- package/esm/feedback/ui/DialogIssue.svelte +102 -0
- package/esm/feedback/ui/DialogIssue.svelte.d.ts +20 -0
- package/esm/feedback/ui/DialogIssues.svelte +91 -0
- package/esm/feedback/ui/DialogIssues.svelte.d.ts +20 -0
- package/esm/feedback/ui/DialogMilestones.svelte +38 -0
- package/esm/feedback/ui/DialogMilestones.svelte.d.ts +18 -0
- package/esm/feedback/ui/Feedback.svelte +12 -0
- package/esm/feedback/ui/Feedback.svelte.d.ts +16 -0
- package/esm/formats/dates.d.ts +18 -0
- package/esm/formats/dates.js +35 -0
- package/esm/formats/index.d.ts +4 -0
- package/esm/formats/index.js +3 -0
- package/esm/formats/numbers.d.ts +4 -0
- package/esm/formats/numbers.js +34 -0
- package/esm/formats/strings.d.ts +11 -0
- package/esm/formats/strings.js +109 -0
- package/esm/handle/index.d.ts +7 -0
- package/esm/handle/index.js +40 -0
- package/esm/helper.d.ts +50 -0
- package/esm/helper.js +118 -0
- package/esm/index.d.ts +103 -0
- package/esm/index.js +42 -0
- package/esm/kitCellsBuildor.d.ts +45 -0
- package/esm/kitCellsBuildor.js +105 -0
- package/esm/kitStoreItem.d.ts +28 -0
- package/esm/kitStoreItem.js +170 -0
- package/esm/kitStoreList.d.ts +33 -0
- package/esm/kitStoreList.js +98 -0
- package/esm/mail/index.d.ts +11 -0
- package/esm/mail/index.js +51 -0
- package/esm/theme.d.ts +4 -0
- package/esm/theme.js +4 -0
- package/esm/ui/Button.svelte +102 -0
- package/esm/ui/Button.svelte.d.ts +27 -0
- package/esm/ui/Clipboardable.svelte +19 -0
- package/esm/ui/Clipboardable.svelte.d.ts +25 -0
- package/esm/ui/Field.svelte +288 -0
- package/esm/ui/Field.svelte.d.ts +29 -0
- package/esm/ui/FieldGroup.svelte +91 -0
- package/esm/ui/FieldGroup.svelte.d.ts +30 -0
- package/esm/ui/Grid.svelte +246 -0
- package/esm/ui/Grid.svelte.d.ts +46 -0
- package/esm/ui/GridLoading.svelte +32 -0
- package/esm/ui/GridLoading.svelte.d.ts +20 -0
- package/esm/ui/GridPaginate.svelte +66 -0
- package/esm/ui/GridPaginate.svelte.d.ts +22 -0
- package/esm/ui/Icon.svelte +86 -0
- package/esm/ui/Icon.svelte.d.ts +46 -0
- package/esm/ui/LibIcon.d.ts +23 -0
- package/esm/ui/LibIcon.js +28 -0
- package/esm/ui/Loading.svelte +11 -0
- package/esm/ui/Loading.svelte.d.ts +20 -0
- package/esm/ui/Tooltip.svelte +42 -0
- package/esm/ui/Tooltip.svelte.d.ts +22 -0
- package/esm/ui/dialog/DialogForm.svelte +70 -0
- package/esm/ui/dialog/DialogForm.svelte.d.ts +19 -0
- package/esm/ui/dialog/DialogManagement.svelte +87 -0
- package/esm/ui/dialog/DialogManagement.svelte.d.ts +25 -0
- package/esm/ui/dialog/DialogPrimitive.svelte +89 -0
- package/esm/ui/dialog/DialogPrimitive.svelte.d.ts +28 -0
- package/esm/ui/dialog/FormEditAction.svelte +54 -0
- package/esm/ui/dialog/FormEditAction.svelte.d.ts +24 -0
- package/esm/ui/dialog/dialog.d.ts +51 -0
- package/esm/ui/dialog/dialog.js +98 -0
- package/esm/ui/index.d.ts +5 -0
- package/esm/ui/index.js +19 -0
- package/esm/ui/internals/FieldContainer.svelte +22 -0
- package/esm/ui/internals/FieldContainer.svelte.d.ts +30 -0
- package/esm/ui/internals/Input.svelte +98 -0
- package/esm/ui/internals/Input.svelte.d.ts +35 -0
- package/esm/ui/internals/Textarea.svelte +61 -0
- package/esm/ui/internals/Textarea.svelte.d.ts +30 -0
- package/esm/ui/internals/select/MultiSelectMelt.svelte +217 -0
- package/esm/ui/internals/select/MultiSelectMelt.svelte.d.ts +30 -0
- package/esm/ui/internals/select/SelectMelt.svelte +238 -0
- package/esm/ui/internals/select/SelectMelt.svelte.d.ts +35 -0
- package/esm/ui/internals/select/SelectRadio.svelte +37 -0
- package/esm/ui/internals/select/SelectRadio.svelte.d.ts +25 -0
- package/esm/ui/link/Link.svelte +28 -0
- package/esm/ui/link/Link.svelte.d.ts +25 -0
- package/esm/ui/link/LinkPlus.svelte +44 -0
- package/esm/ui/link/LinkPlus.svelte.d.ts +21 -0
- package/esm/utils/tailwind.d.ts +2 -0
- package/esm/utils/tailwind.js +3 -0
- package/esm/utils/transition.d.ts +10 -0
- package/esm/utils/transition.js +33 -0
- package/esm/utils/types.d.ts +17 -0
- package/esm/utils/types.js +17 -0
- package/esm/virtual/Customer.d.ts +4 -0
- package/esm/virtual/Customer.js +24 -0
- package/esm/virtual/FilterEntity.d.ts +7 -0
- package/esm/virtual/FilterEntity.js +34 -0
- package/esm/virtual/StateDemoEnum.d.ts +9 -0
- package/esm/virtual/StateDemoEnum.js +42 -0
- package/esm/virtual/UIEntity.d.ts +16 -0
- package/esm/virtual/UIEntity.js +84 -0
- package/esm/vite/index.d.ts +8 -0
- package/esm/vite/index.js +47 -0
- package/package.json +94 -10
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Strava } from 'arctic';
|
|
2
|
+
import { remult } from 'remult';
|
|
3
|
+
import { checkOAuthConfig } from '.';
|
|
4
|
+
import { logAuth } from '../';
|
|
5
|
+
/**
|
|
6
|
+
* Strava OAuth2 provider
|
|
7
|
+
*
|
|
8
|
+
* In Strava, set your callback url to
|
|
9
|
+
* - dev: `http://localhost:5173/api/auth_callback`
|
|
10
|
+
* - prod: `https://MY_SUPER_SITE/api/auth_callback`
|
|
11
|
+
*
|
|
12
|
+
* In your project add a `.env` file with the following:
|
|
13
|
+
*
|
|
14
|
+
* ```env
|
|
15
|
+
* STRAVA_CLIENT_ID= 'your-client-id'
|
|
16
|
+
* STRAVA_CLIENT_SECRET= 'your-client-secret'
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* _FYI: STRAVA_REDIRECT_URI is optional as auth module will default to "${origin}/api/auth_callback"._
|
|
20
|
+
*/
|
|
21
|
+
export function strava(options) {
|
|
22
|
+
const name = 'strava';
|
|
23
|
+
const clientID = options?.STRAVA_CLIENT_ID ?? '';
|
|
24
|
+
const secret = options?.STRAVA_CLIENT_SECRET ?? '';
|
|
25
|
+
const urlForKeys = 'https://www.strava.com/settings/api';
|
|
26
|
+
checkOAuthConfig(name, clientID, secret, urlForKeys, false);
|
|
27
|
+
return {
|
|
28
|
+
name,
|
|
29
|
+
isPKCE: false,
|
|
30
|
+
getArcticProvider: () => {
|
|
31
|
+
const redirectURI = options?.STRAVA_REDIRECT_URI || `${remult.context.url.origin}/api/auth_callback`;
|
|
32
|
+
checkOAuthConfig(name, clientID, secret, urlForKeys, true);
|
|
33
|
+
return new Strava(clientID, secret, redirectURI);
|
|
34
|
+
},
|
|
35
|
+
authorizationURLOptions: () => {
|
|
36
|
+
return options?.authorizationURLOptions ?? { scopes: [] };
|
|
37
|
+
},
|
|
38
|
+
getUserInfo: async (tokens) => {
|
|
39
|
+
const res = await fetch('https://www.strava.com/api/v3/athlete', {
|
|
40
|
+
headers: {
|
|
41
|
+
Authorization: `Bearer ${tokens.accessToken}`,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
const user = await res.json();
|
|
45
|
+
if (options?.log) {
|
|
46
|
+
logAuth.info(`user`, user);
|
|
47
|
+
}
|
|
48
|
+
return { raw: user, providerUserId: String(user.id), nameOptions: [user.login] };
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var Cn=Object.defineProperty;var En=(n,e,t)=>e in n?Cn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var c=(n,e,t)=>(En(n,typeof e!="symbol"?e+"":e,t),t);import{n as ne,s as Tn,r as ze,a as Ke,i as Sn,g as An,S as Je,b as je,c as ii,e as ir,d as U,t as G,f as Fn,h as Z,j as Pn,k as V,l as tt,m as Dn,o as Or,p as Mn,q as Cr,u as Rn,v as ni,w as si,x as ai,y as oi,z as Qt,A as $,B as Er,C as Pt,D as Ie,E as Tr,F as Nn,G as Ln,H as ee,I as H,J as j,K as De,L as C,M as ge,N as Dt,O as de,P as he,Q as pe,R as ye,T as nr,U as sr,V as ar}from"./index-CKmKKRRL.js";function $n(n,e){const t={},r={},i={$$scope:1};let s=n.length;for(;s--;){const a=n[s],o=e[s];if(o){for(const u in a)u in o||(r[u]=1);for(const u in o)i[u]||(t[u]=o[u],i[u]=1);n[s]=o}else for(const u in a)i[u]=1}for(const a in r)a in t||(t[a]=void 0);return t}const Ve=[];function or(n,e){return{subscribe:Mt(n,e).subscribe}}function Mt(n,e=ne){let t;const r=new Set;function i(o){if(Ke(n,o)&&(n=o,t)){const u=!Ve.length;for(const f of r)f[1](),Ve.push(f,n);if(u){for(let f=0;f<Ve.length;f+=2)Ve[f][0](Ve[f+1]);Ve.length=0}}}function s(o){i(o(n))}function a(o,u=ne){const f=[o,u];return r.add(f),r.size===1&&(t=e(i,s)||ne),o(n),()=>{r.delete(f),r.size===0&&t&&(t(),t=null)}}return{set:i,update:s,subscribe:a}}function lt(n,e,t){const r=!Array.isArray(n),i=r?[n]:n;if(!i.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const s=e.length<2;return or(t,(a,o)=>{let u=!1;const f=[];let l=0,d=ne;const h=()=>{if(l)return;d();const m=e(r?f[0]:f,a,o);s?a(m):d=Sn(m)?m:ne},y=i.map((m,b)=>Tn(m,_=>{f[b]=_,l&=~(1<<b),u&&h()},()=>{l|=1<<b}));return u=!0,h(),function(){ze(y),d(),u=!1}})}const qn=n=>{const{subscribe:e,update:t}=Mt(n);return{subscribe:e,set:(r={})=>{t(i=>Object.assign(i,r))}}},Rt=qn({mode:"window",basePath:null}),Jt=(n=An(Rt).mode)=>{let e="popstate";n==="window"&&(e="popstate"),n==="hash"&&(e="hashchange"),window.dispatchEvent(new Event(e))},Sr={go:(n=0)=>{history.go(n),Jt()},push:(n,e=null)=>{history.pushState(e,"",n),Jt()},replace:(n,e=null)=>{history.replaceState(e,"",n),Jt()}},Bn=(n,e)=>e===null?n:n.startsWith(e)?n.slice(e.length):n,Jn=n=>{const e=n.match(/^(\/[^?#]*)?/),t=n.match(/\?([^#]*)?/),r=n.match(/#(.*)?/);return{path:(e==null?void 0:e[1])||"/",query:t!=null&&t[1]?`?${t==null?void 0:t[1]}`:"",hash:r!=null&&r[1]?`#${r==null?void 0:r[1]}`:""}},Ar=()=>{const{pathname:n,search:e,hash:t}=document.location;return{path:n,query:e,hash:t}},Fr=()=>{let n=document.location.hash.substring(1);return n[0]!=="/"&&(n="/"+n),Jn(n)},jn=or(Ar(),n=>{const e=()=>n(Ar());return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),Un=or(Fr(),n=>{const e=()=>n(Fr());return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}),lr=lt([Rt,jn,Un],([n,e,t],r)=>{n.mode==="window"&&r(e),n.mode==="hash"&&r(t)}),Vn=lt(lr,n=>n.path);lt(lr,n=>n.query);lt(lr,n=>n.hash);const Hn=lt([Rt,Vn],([n,e])=>Bn(e,n.basePath)),vt=n=>n.split(/(?=\/)/),Wn=()=>{let n=0;return()=>n++};function Pr(n){let e;const t=n[10].default,r=ni(t,n,n[9],null);return{c(){r&&r.c()},m(i,s){r&&r.m(i,s),e=!0},p(i,s){r&&r.p&&(!e||s&512)&&si(r,t,i,i[9],e?oi(t,i[9],s,null):ai(i[9]),null)},i(i){e||(G(r,i),e=!0)},o(i){Z(r,i),e=!1},d(i){r&&r.d(i)}}}function xn(n){let e=Dr(n[1],n[0],n[2]),t,r,i=e&&Pr(n);return{c(){i&&i.c(),t=ir()},m(s,a){i&&i.m(s,a),U(s,t,a),r=!0},p(s,[a]){a&7&&(e=Dr(s[1],s[0],s[2])),e?i?(i.p(s,a),a&7&&G(i,1)):(i=Pr(s),i.c(),G(i,1),i.m(t.parentNode,t)):i&&(Fn(),Z(i,1,1,()=>{i=null}),Pn())},i(s){r||(G(i),r=!0)},o(s){Z(i),r=!1},d(s){s&&V(t),i&&i.d(s)}}}const Qn=(n,e,t,r,i)=>{const s=(f,l,d)=>{const h=vt(l).filter(y=>y!=="/").length;return(d??0)+(f?1:h)},a=(f,l)=>{const d={invalidPath:`<Route path="${f==null?void 0:f.path}" /> has invalid path. Path must start with '/'`,fallbackOutsideRoot:"<Route fallback /> cannot be outside root <Route />",pathOutsideRoot:`<Route path="${f==null?void 0:f.path}" /> cannot be outside root <Route />`,fallbackInsideFallback:"<Route fallback /> cannot be inside <Route fallback>",pathInsideFallback:`<Route path="${f==null?void 0:f.path}" /> cannot be inside <Route fallback>`};if(f.path[0]!=="/")throw new Error(d.invalidPath);if(f.root&&f.fallback)throw new Error(d.fallbackOutsideRoot);if(f.root&&f.path!=="/")throw new Error(d.pathOutsideRoot);if(l!=null&&l.fallback&&f.fallback)throw new Error(d.fallbackInsideFallback);if(l!=null&&l.fallback&&!f.fallback)throw new Error(d.pathInsideFallback)},o=s(t,r,i==null?void 0:i.depth),u={id:n,root:e,fallback:t,path:r,depth:o};return a(u,i),u},Gn=()=>{const{subscribe:n,update:e}=Mt([]);return{subscribe:n,update:t=>e(r=>[...r.filter(i=>t.id!==i.id),t]),remove:t=>e(r=>r.filter(i=>t.id!==i.id))}},Dr=(n,e,t)=>{const r=(f,l,d,h)=>{let y=vt(f).filter(_=>_!=="/"),m=vt(d).filter(_=>_!=="/"),b="";if(d==="/")return l||y.length===h;for(let _=h-m.length;_<h;_++)b=b+y[_];return d===b},i=(f,l,d)=>{var m,b,_,I;let h=vt(f).filter(P=>P!=="/"),y=!1;for(let P=0;P<(d==null?void 0:d.length)&&!y;P++)(m=d[P])!=null&&m.fallback||(y=r(f,((b=d[P])==null?void 0:b.root)??!1,((_=d[P])==null?void 0:_.path)??"",((I=d[P])==null?void 0:I.depth)??0));return h.length>=l&&!y},{root:s,fallback:a,path:o,depth:u}=e;return a?i(n,u,t):r(n,s,o,u)},zn=Wn(),jt={},Mr={};function Kn(n,e,t){let r,i,s,a;tt(n,Hn,I=>t(1,s=I));let{$$slots:o={},$$scope:u}=e;const f=zn(),l=!Dn(jt);let{fallback:d=!1}=e,{path:h="/"}=e;const y=Mt();tt(n,y,I=>t(0,r=I));const m=Or(jt);tt(n,m,I=>t(8,i=I));const b=Gn(),_=Or(Mr);return tt(n,_,I=>t(2,a=I)),Mn(()=>_==null?void 0:_.remove(r)),Cr(jt,y),Cr(Mr,b),n.$$set=I=>{"fallback"in I&&t(6,d=I.fallback),"path"in I&&t(7,h=I.path),"$$scope"in I&&t(9,u=I.$$scope)},n.$$.update=()=>{n.$$.dirty&448&&Rn(y,r=Qn(f,l,d,h,i),r),n.$$.dirty&1&&(_==null||_.update(r))},[r,s,a,y,m,_,d,h,i,u,o]}class xe extends Je{constructor(e){super(),je(this,e,Kn,xn,ii,{fallback:6,path:7})}}const Rr=n=>{var o;const e=(o=n.target)==null?void 0:o.closest("a[href]"),t=e==null?void 0:e.href;if(e===null||t===null)return!0;const r=["","true"].includes(e.getAttribute("data-handle-ignore")??"false"),i=(e.getAttribute("target")??"_self")!=="_self",s=n.metaKey||n.ctrlKey||n.altKey||n.shiftKey,a=new URL(t).origin!==document.location.origin;if(r||i||s||a)return!0;t===document.location.href?Sr.replace(t):Sr.push(t),n.preventDefault()},Xn=n=>(n.addEventListener("click",Rr),{destroy:()=>{n.removeEventListener("click",Rr)}});function Zn(n){let e,t,r,i;const s=n[5].default,a=ni(s,n,n[4],null);let o=[{href:n[0]},n[1]],u={};for(let f=0;f<o.length;f+=1)u=Qt(u,o[f]);return{c(){e=$("a"),a&&a.c(),Er(e,u)},m(f,l){U(f,e,l),a&&a.m(e,null),t=!0,r||(i=[Pt(Xn.call(null,e)),Ie(e,"click",n[6])],r=!0)},p(f,[l]){a&&a.p&&(!t||l&16)&&si(a,s,f,f[4],t?oi(s,f[4],l,null):ai(f[4]),null),Er(e,u=$n(o,[(!t||l&1)&&{href:f[0]},l&2&&f[1]]))},i(f){t||(G(a,f),t=!0)},o(f){Z(a,f),t=!1},d(f){f&&V(e),a&&a.d(f),r=!1,ze(i)}}}const Yn=(n,e,t)=>(n==="hash"?"#":"")+(e??"")+t;function es(n,e,t){let r;const i=["href"];let s=Tr(e,i),a;tt(n,Rt,d=>t(3,a=d));let{$$slots:o={},$$scope:u}=e,{href:f}=e;function l(d){Ln.call(this,n,d)}return n.$$set=d=>{e=Qt(Qt({},e),Nn(d)),t(1,s=Tr(e,i)),"href"in d&&t(2,f=d.href),"$$scope"in d&&t(4,u=d.$$scope)},n.$$.update=()=>{n.$$.dirty&12&&t(0,r=Yn(a.mode,a.basePath,f))},[r,s,f,a,u,o,l]}class ut extends Je{constructor(e){super(),je(this,e,es,Zn,ii,{href:2})}}class Le{constructor(...e){c(this,"fields");c(this,"options");c(this,"target");c(this,"readonly");c(this,"allowNull");c(this,"dbReadOnly");c(this,"isServerExpression");c(this,"key");c(this,"caption");c(this,"inputType");c(this,"dbName");c(this,"valueType");this.fields=e}apiUpdateAllowed(e){throw new Error("Method not implemented.")}displayValue(e){throw new Error("Method not implemented.")}includedInApi(e){throw new Error("Method not implemented.")}toInput(e,t){throw new Error("Method not implemented.")}fromInput(e,t){throw new Error("Method not implemented.")}getDbName(){return Promise.resolve("")}getId(e){let t=i=>e[i.key];typeof e=="function"&&(t=e);let r="";return this.fields.forEach(i=>{r.length>0&&(r+=","),r+=i.valueConverter.toJson(t(i))}),r}get valueConverter(){throw new Error("cant get value converter of compound id")}isEqualTo(e){let t={},i=e.toString().split(",");return this.fields.forEach((s,a)=>{t[s.key]=s.valueConverter.fromJson(i[a])}),t}}function X(n,e=!0){var r;let t=n[Ne];if(!t&&e)throw new Error("item "+(((r=n.constructor)==null?void 0:r.name)||n)+" was not initialized using a context");return t}const Ne=Symbol.for("entityMember"),ts=Symbol.for("entityInfo"),rs=Symbol.for("entityInfo_key");function _e(n,e=!0){if(n===void 0){if(e)throw new Error("Undefined is not an entity :)");return}let t=n[ts];if(!t&&e)throw new Error(n.prototype.constructor.name+" is not a known entity, did you forget to set @Entity() or did you forget to add the '@' before the call to Entity?");return t}function is(n){return n[rs]}const ns=Symbol.for("relationInfo");function ss(n){return n==null?void 0:n[ns]}const Gt=Symbol.for("fieldRelationInfo");function Y(n){return n[Gt]}function as(n,e,t){for(const r of n.fields.toArray()){const i=ss(r.options);if(i&&!r[Gt]){const s=i.toType(),a=e.repo(s,t),o=r.options;r[Gt]={type:i.type,toEntity:s,options:o,toRepo:a,getFields:()=>{let u=o.field,f={fields:o.fields,compoundIdField:void 0};function l(y){return Error(`Error for relation: "${r.key}" to "${a.metadata.key}": `+y)}let d=()=>u||f.fields;if(i.type==="toMany"&&!d()){for(const y of a.fields.toArray())if(!d()){const m=Y(y),b=y.options;if(m&&m.toEntity===n.metadata.entityType){if(m.type==="reference")u=y.key;else if(m.type==="toOne"){if(b.field)u=b.field;else if(b.fields){let _={};for(const I in b.fields)if(Object.prototype.hasOwnProperty.call(b.fields,I)){const P=b.fields[I];_[P]=I}f.fields=_}}}}if(!d())throw l("No matching field found on target. Please specify field/fields")}function h(y,m){const b=m.fields.find(y);if(!b)throw l(`Field "${y}" was not found in "${m.key}".`);return b}i.type==="reference"&&(u=r.key),u&&(i.type==="toOne"||i.type==="reference"?a.metadata.idMetadata.field instanceof Le?f.compoundIdField=u:f.fields={[a.metadata.idMetadata.field.key]:u}:n.metadata.idMetadata.field instanceof Le?f.compoundIdField=u:f.fields={[u]:n.metadata.idMetadata.field.key});for(const y in f.fields)Object.prototype.hasOwnProperty.call(f.fields,y)&&(h(y,a.metadata),h(f.fields[y],n.metadata));return f}}}}}class F{constructor(e){c(this,"apply");this.apply=e}static throwErrorIfFilterIsEmpty(e,t){if(F.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(!F.isFilterEmpty(t))return!1}if(e.$or){for(const t of e.$or)if(F.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 Ct;return await F.fromEntityFilter(e,t).__applyToConsumer(r),r.preciseValues}async getPreciseValues(){const e=new Ct;return await this.__applyToConsumer(e),e.preciseValues}static createCustom(e,t=""){let r={key:t,rawFilterTranslator:e};return Object.assign(i=>{if(i==null&&(i={}),!r.key)throw"Usage of custom filter before a key was assigned to it";return{[qe+r.key]:i}},{rawFilterInfo:r})}static entityFilterToJson(e,t){return F.fromEntityFilter(e,t).toJson()}static entityFilterFromJson(e,t){return ui(e,{get:r=>t[r]})}static fromEntityFilter(e,t){let r=[];for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){let s=t[i];if(i=="$or")r.push(new us(...s.map(a=>F.fromEntityFilter(e,a))));else if(i=="$and")r.push(new Nr(...s.map(a=>F.fromEntityFilter(e,a))));else if(i.startsWith(qe))r.push(new F(a=>{a.custom(i.substring(qe.length),s)}));else if(i==li)r.push(new F(a=>a.databaseCustom(s)));else{const a=e.fields[i],o=Y(a),u=a.options;let f=(o==null?void 0:o.type)==="toOne"?u.fields?new ls(a,e.fields,u):new os(e.fields[u.field]):new Ot(a),l=!1;if(s!==void 0&&s!=null){s.$id!==void 0&&(s=s.$id);for(const d in s)if(Object.prototype.hasOwnProperty.call(s,d)){const h=s[d];switch(d){case"$gte":case">=":r.push(f.isGreaterOrEqualTo(h)),l=!0;break;case"$gt":case">":r.push(f.isGreaterThan(h)),l=!0;break;case"$lte":case"<=":r.push(f.isLessOrEqualTo(h)),l=!0;break;case"$lt":case"<":r.push(f.isLessThan(h)),l=!0;break;case"$ne":case"!=":case"$nin":l=!0,Array.isArray(h)?r.push(f.isNotIn(h)):r.push(f.isDifferentFrom(h));break;case"$in":l=!0,r.push(f.isIn(h));break;case"$contains":l=!0,r.push(f.contains(h));break;case"$notContains":l=!0,r.push(f.notContains(h));break}}Array.isArray(s)&&(l=!0,r.push(f.isIn(s)))}!l&&s!==void 0&&r.push(f.isEqualTo(s))}}return new Nr(...r)}__applyToConsumer(e){this.apply(e)}static async resolve(e){return typeof e=="function"?await e():e}toJson(){let e=new ur;return this.__applyToConsumer(e),e.result}static async translateCustomWhere(e,t,r){let i=new fr(async(s,a)=>{let o=[];for(const u in t.entityType){const f=t.entityType[u];f&&f.rawFilterInfo&&f.rawFilterInfo.rawFilterTranslator&&f.rawFilterInfo.key==s&&o.push(await F.fromEntityFilter(t,await f.rawFilterInfo.rawFilterTranslator(a,r)))}return o});return e.__applyToConsumer(i),await i.resolve(),e=new F(s=>i.applyTo(s)),e}}class Ot{constructor(e){c(this,"metadata");this.metadata=e}processVal(e){if(_e(this.metadata.valueType,!1)){if(e==null){if(e===null&&!this.metadata.allowNull){const r=Y(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:X(e).getId()}return e}contains(e){return new F(t=>t.containsCaseInsensitive(this.metadata,e))}notContains(e){return new F(t=>t.notContainsCaseInsensitive(this.metadata,e))}isLessThan(e){return e=this.processVal(e),new F(t=>t.isLessThan(this.metadata,e))}isGreaterOrEqualTo(e){return e=this.processVal(e),new F(t=>t.isGreaterOrEqualTo(this.metadata,e))}isNotIn(e){return new F(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 F(t=>t.isNotNull(this.metadata)):new F(t=>t.isDifferentFrom(this.metadata,e))}isLessOrEqualTo(e){return e=this.processVal(e),new F(t=>t.isLessOrEqualTo(this.metadata,e))}isGreaterThan(e){return e=this.processVal(e),new F(t=>t.isGreaterThan(this.metadata,e))}isEqualTo(e){return e=this.processVal(e),e==null&&this.metadata.allowNull?new F(t=>t.isNull(this.metadata)):new F(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 F(t=>t.isEqualTo(this.metadata,e[0])):new F(t=>t.isIn(this.metadata,e))}}class os extends Ot{processVal(e){return e?typeof e=="string"||typeof e=="number"?e:X(e).getId():null}}class ls{constructor(e,t,r){c(this,"metadata");c(this,"fields");c(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")}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 F(t=>{e.forEach(r=>this.isDifferentFrom(r).__applyToConsumer(t))})}isDifferentFrom(e){return new F(t=>{const r=[];for(const i in this.relationOptions.fields)if(Object.prototype.hasOwnProperty.call(this.relationOptions.fields,i)){const s=this.relationOptions.fields[i];r.push(new F(a=>new Ot(this.fields.find(s)).isDifferentFrom(e[i]).__applyToConsumer(a)))}t.or(r)})}isLessOrEqualTo(e){throw new Error("Invalid for Many To One Relation Field")}isGreaterThan(e){throw new Error("Invalid for Many To One Relation Field")}isEqualTo(e){return new F(t=>{for(const r in this.relationOptions.fields)if(Object.prototype.hasOwnProperty.call(this.relationOptions.fields,r)){const i=this.relationOptions.fields[r];new Ot(this.fields.find(i)).isEqualTo(e[r]).__applyToConsumer(t)}})}isIn(e){return new F(t=>{t.or(e.map(r=>this.isEqualTo(r)))})}}class Nr extends F{constructor(...t){super(r=>{for(const i of this.filters)i&&i.__applyToConsumer(r)});c(this,"filters");this.filters=t}add(t){this.filters.push(t)}}class us extends F{constructor(...t){super(r=>{let i=this.filters.filter(s=>s!==void 0);i.length>1?r.or(i):i.length==1&&i[0].__applyToConsumer(r)});c(this,"filters");this.filters=t}}const qe="$custom$",li="$db$",zt="$an array";class ur{constructor(){c(this,"result",{});c(this,"hasUndefined",!1)}databaseCustom(e){throw new Error("database custom is not allowed with api calls.")}custom(e,t){Array.isArray(t)&&(t={[zt]:t}),this.add(qe+e,t)}add(e,t){t===void 0&&(this.hasUndefined=!0);let r=this.result;if(!r[e]){r[e]=t;return}let i=r[e];i instanceof Array?i.push(t):i=[i,t],r[e]=i}or(e){this.add("OR",e.map(t=>{let r=new ur;return t.__applyToConsumer(r),r.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)}}function ui(n,e){let t={};function r(o){t.$and||(t.$and=[]),t.$and.push(o)}function i(o,u){t[o]===void 0?t[o]=u:r({[o]:u})}[...n.fields].forEach(o=>{function u(l,d,h=!1,y=!1){let m=e.get(o.key+l);if(m!==void 0){let b=_=>{let I=_;if(h){let z;typeof _=="string"?z=JSON.parse(_):z=_,I=z.map(D=>y?D:o.valueConverter.fromJson(D))}else I=y?I:o.valueConverter.fromJson(I);let P=d(I);P!==void 0&&i(o.key,P)};if(!h&&m instanceof Array)m.forEach(_=>{b(_)});else{h&&typeof m=="string"&&(m=JSON.parse(m));const _=a(m);for(const I of _)b(I)}}}u("",l=>l),u(".gt",l=>({$gt:l})),u(".gte",l=>({$gte:l})),u(".lt",l=>({$lt:l})),u(".lte",l=>({$lte:l})),u(".ne",l=>({$ne:l})),u(".in",l=>l,!0);var f=e.get(o.key+".null");if(f)switch(f=f.toString().trim().toLowerCase(),f){case"y":case"true":case"yes":i(o.key,null);break;default:i(o.key,{$ne:null});break}u(".contains",l=>({$contains:l}),!1,!0),u(".notContains",l=>({$notContains:l}),!1,!0)});let s=e.get("OR");if(s){const u=a(s).map(f=>({$or:f.map(l=>ui(n,{get:d=>l[d]}))}));u.length==1?t.$or?t.$or.push(u[0].$or):t.$or=u[0].$or:r({$and:u})}for(const o in n.entityType){const u=n.entityType[o];if(u&&u.rawFilterInfo&&u.rawFilterInfo.rawFilterTranslator){let f=e.get(qe+o);if(f!==void 0){const l=d=>{d[zt]!=null&&(d=d[zt]),i(qe+o,d)};Array.isArray(f)?f.forEach(d=>l(d)):l(f)}}}return t;function a(o){if(!Array.isArray(o))return[o];const u=[],f=[];for(const l of o)Array.isArray(l)?f.push(l):u.push(l);return f.push(u),f}}class fr{constructor(e){c(this,"translateCustom");c(this,"commands",[]);c(this,"promises",[]);this.translateCustom=e}applyTo(e){this.commands.forEach(t=>t(e))}or(e){let t;this.promises.push(Promise.all(e.map(async r=>{let i=new fr(this.translateCustom);return r.__applyToConsumer(i),await i.resolve(),new F(s=>i.applyTo(s))})).then(r=>{t=r})),this.commands.push(r=>r.or(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))}isIn(e,t){this.commands.push(r=>r.isIn(e,t))}custom(e,t){this.promises.push((async()=>{let r=await this.translateCustom(e,t);r&&(Array.isArray(r)?r.forEach(i=>i.__applyToConsumer(this)):r.__applyToConsumer(this))})())}databaseCustom(e){this.commands.push(t=>t.databaseCustom(e))}async resolve(){for(;this.promises.length>0;){let e=this.promises;this.promises=[],await Promise.all(e)}}}class Ct{constructor(){c(this,"rawValues",{});c(this,"preciseValues",new Proxy(this.rawValues,{get:(e,t)=>{if(t in e){let r=e[t];if(r.bad)return;if(r.values.length>0){const i=Y(r.field);if(i){if(i.type==="reference")return r.values.map(s=>i.toRepo.metadata.idMetadata.getIdFilter(s));throw new Error("Only relations toOne without field are supported.")}return r.values}}}}))}ok(e,...t){let r=this.rawValues[e.key];r?r.values.push(...t.filter(i=>!r.values.includes(i))):this.rawValues[e.key]={field:e,bad:!1,values:[...t]}}notOk(e){let t=this.rawValues[e.key];t?t.bad=!0:this.rawValues[e.key]={field:e,bad:!0,values:[]}}or(e){const t=e.map(r=>{let i=new Ct;return r.__applyToConsumer(i),i});for(const r of t)for(const i in r.rawValues)if(Object.prototype.hasOwnProperty.call(r.rawValues,i)){const s=r.rawValues[i];s&&(s.bad?this.notOk(s.field):this.ok(s.field,...s.values))}for(const r in this.rawValues)if(Object.prototype.hasOwnProperty.call(this.rawValues,r))for(const i of t)i.rawValues[r]||this.notOk(this.rawValues[r].field)}isEqualTo(e,t){this.ok(e,t)}isDifferentFrom(e,t){this.notOk(e)}isNull(e){this.ok(e,null)}isNotNull(e){this.notOk(e)}isGreaterOrEqualTo(e,t){this.notOk(e)}isGreaterThan(e,t){this.notOk(e)}isLessOrEqualTo(e,t){this.notOk(e)}isLessThan(e,t){this.notOk(e)}containsCaseInsensitive(e,t){this.notOk(e)}notContainsCaseInsensitive(e,t){this.notOk(e)}isIn(e,t){this.ok(e,...t)}custom(e,t){}databaseCustom(e){}}var fs={};const Ut=Symbol.for("remult-static1");let bt={defaultRemultFactory:void 0,remultFactory:void 0,defaultRemult:void 0,asyncContext:void 0,columnsOfType:new Map,allEntities:[],classHelpers:new Map,actionInfo:{allActions:[],runningOnServer:!1,runActionWithoutBlockingUI:n=>n(),startBusyWithProgress:()=>({progress:n=>{},close:()=>{}})},captionTransformer:void 0,defaultDataProvider:()=>{}};typeof process<"u"&&fs.IGNORE_GLOBAL_REMULT_IN_TESTS||typeof globalThis[Ut]>"u"?(globalThis[Ut]=bt,bt.remultFactory=()=>fi()):bt=globalThis[Ut];const O=bt;function fi(){return O.defaultRemult||(O.defaultRemult=O.defaultRemultFactory()),O.defaultRemult}function ds(){O.remultFactory=()=>fi()}function Be(n){const e=n;if(typeof e[st]=="function")return e[st]();throw Error("Error getting repository internal from "+n)}const st=Symbol.for("getInternal");class cs{constructor(){c(this,"iAmRemultProxy",!0);c(this,"repoCache",new Map);c(this,"repo",(...e)=>{let t=O,r=this.repoCache.get(e[0]);r||this.repoCache.set(e[0],r=new Map);let i=r.get(e[1]);return i||(i={get fields(){return O.remultFactory().repo(...e).metadata.fields},[st](){return t.remultFactory().repo(...e)[st]()},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),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 O.remultFactory().repo(...e).metadata},query:(...s)=>t.remultFactory().repo(...e).query(...s),save:s=>t.remultFactory().repo(...e).save(s),update:(s,a)=>t.remultFactory().repo(...e).update(s,a)},r.set(e[1],i),i)})}get liveQuerySubscriber(){return O.remultFactory().liveQuerySubscriber}set liveQuerySubscriber(e){O.remultFactory().liveQuerySubscriber=e}get liveQueryStorage(){return O.remultFactory().liveQueryStorage}set liveQueryStorage(e){O.remultFactory().liveQueryStorage=e}get liveQueryPublisher(){return O.remultFactory().liveQueryPublisher}set liveQueryPublisher(e){O.remultFactory().liveQueryPublisher=e}call(e,t,...r){return O.remultFactory().call(e,t,...r)}get context(){return O.remultFactory().context}get dataProvider(){return O.remultFactory().dataProvider}set dataProvider(e){O.remultFactory().dataProvider=e}get repCache(){return O.remultFactory().repCache}authenticated(){return O.remultFactory().authenticated()}isAllowed(e){return O.remultFactory().isAllowed(e)}isAllowedForInstance(e,t){return O.remultFactory().isAllowedForInstance(e,t)}clearAllCache(){return O.remultFactory().clearAllCache()}get user(){return O.remultFactory().user}set user(e){O.remultFactory().user=e}get apiClient(){return O.remultFactory().apiClient}set apiClient(e){O.remultFactory().apiClient=e}get subscriptionServer(){return O.remultFactory().subscriptionServer}set subscriptionServer(e){O.remultFactory().subscriptionServer=e}}const ke=new cs;function hs(n){return n.replace(/([A-Z])/g," $1").replace(/^./,e=>e.toUpperCase()).replace("Email","eMail").replace(" I D"," ID")}class ps{constructor(e,t,r){c(this,"repository");c(this,"isReferenceRelation");c(this,"allowNull");c(this,"storedItem");c(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:Be(this.repository)._getCachedByIdAsync(e,!1)}get(e){if(e==null)return null;const t=Be(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=X(e,!1);t&&!this.isReferenceRelation?(Be(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 Lr{constructor(e){c(this,"url");this.url=e}add(e,t){this.url.indexOf("?")>=0?this.url+="&":this.url+="?",this.url+=encodeURIComponent(e)+"="+encodeURIComponent(t)}addObject(e,t=""){if(e!=null)for(var r in e){let i=e[r];this.add(r+t,i)}}}const di={error500RetryCount:4};function ft(n){if(!n)return new $r;let e;return e||ci(n)&&(e=new ys(n)),e||typeof n=="function"&&(e=new $r(n)),e}function ci(n){let e=n;return!!(e&&e.get&&e.put&&e.post&&e.delete)}class ys{constructor(e){c(this,"http");this.http=e}async post(e,t){return await Et(()=>pt(this.http.post(e,t)))}delete(e){return pt(this.http.delete(e))}put(e,t){return pt(this.http.put(e,t))}async get(e){return await Et(()=>pt(this.http.get(e)))}}async function Et(n){var t,r,i,s;let e=0;for(;;)try{return await n()}catch(a){if(((t=a.message)!=null&&t.startsWith("Error occurred while trying to proxy")||(r=a.message)!=null&&r.startsWith("Error occured while trying to proxy")||(i=a.message)!=null&&i.includes("http proxy error")||(s=a.message)!=null&&s.startsWith("Gateway Timeout")||a.status==500)&&e++<di.error500RetryCount){await new Promise((o,u)=>{setTimeout(()=>{o({})},500)});continue}throw a}}function pt(n){let e;return n.toPromise!==void 0?e=n.toPromise():e=n,e.then(t=>t&&(t.status==200||t.status==201)&&t.headers&&t.request&&t.data?t.data:t).catch(async t=>{throw await ms(t)})}async function ms(n){var s,a,o;let e=await n;var t;e.error?t=e.error:e.isAxiosError&&(typeof((s=e.response)==null?void 0:s.data)=="string"?t=e.response.data:t=(a=e==null?void 0:e.response)==null?void 0:a.data),t||(t=e.message),e.status==0&&e.error.isTrusted&&(t="Network Error"),typeof t=="string"&&(t={message:t}),e.modelState&&(t.modelState=e.modelState);let r=e.status;r===void 0&&(r=(o=e.response)==null?void 0:o.status),r!=null&&(t.httpStatusCode=r);var i=Object.assign(t,{});return i}class hi{constructor(e){c(this,"apiProvider");c(this,"isProxy",!0);this.apiProvider=e}getEntityDataProvider(e){return new ws(()=>{var r;let t=(r=this.apiProvider())==null?void 0:r.url;return t==null&&(t="/api"),t+"/"+e.key},()=>ft(this.apiProvider().httpClient),e)}async transaction(e){throw new Error("Method not implemented.")}}function dr(n,e){if(n.include){let t={};for(const r in n.include)if(Object.prototype.hasOwnProperty.call(n.include,r)){let i=n.include[r];if(typeof i=="object"){const s=Y(e.fields.find(r));s&&(i=dr(i,s.toRepo.metadata))}t[r]=i}n={...n,include:t}}return n.where&&(n={...n,where:F.entityFilterToJson(e,n.where)}),n.load&&(n={...n,load:n.load(e.fields).map(t=>t.key)}),n}class ws{constructor(e,t,r){c(this,"url");c(this,"http");c(this,"entity");this.url=e,this.http=t,this.entity=r}translateFromJson(e){let t={};for(const r of this.entity.fields)t[r.key]=r.valueConverter.fromJson(e[r.key]);return t}translateToJson(e){let t={};for(const r of this.entity.fields)t[r.key]=r.valueConverter.toJson(e[r.key]);return t}async count(e){const{run:t}=this.buildFindRequest({where:e});return t("count").then(r=>+r.count)}async deleteMany(e){const{run:t}=this.buildFindRequest({where:e},"delete");return t("deleteMany").then(r=>+r.deleted)}async updateMany(e,t){const{run:r}=this.buildFindRequest({where:e},"put");return r("updateMany",this.toJsonOfIncludedKeys(t)).then(i=>+i.updated)}find(e){let{run:t}=this.buildFindRequest(e);return t().then(r=>r.map(i=>this.translateFromJson(i)))}buildFindRequest(e,t){t||(t="get");let r=new Lr(this.url()),i;if(e){if(e.where&&(i=e.where.toJson(),vs(i,r)&&(i=void 0)),e.orderBy&&e.orderBy.Segments){let a="",o="",u=!1;e.orderBy.Segments.forEach(f=>{a.length>0&&(a+=",",o+=","),a+=f.field.key,o+=f.isDescending?"desc":"asc",f.isDescending&&(u=!0)}),a&&r.add("_sort",a),u&&r.add("_order",o)}e.limit&&r.add("_limit",e.limit),e.page&&r.add("_page",e.page)}const s=(a,o)=>{let u=new Lr(r.url);return!a&&i&&(a="get"),a&&u.add("__action",a),i?(o={set:o,where:i},this.http().post(u.url,o)):this.http()[t](u.url,o)};return{createKey:()=>JSON.stringify({url:r,filterObject:i}),run:s,subscribe:async a=>({result:await s(bs+a),unsubscribe:async()=>O.actionInfo.runActionWithoutBlockingUI(()=>this.http().post(this.url()+"?__action=endLiveQuery",{id:a}))})}}update(e,t){return this.http().put(this.url()+(e!=""?"/"+encodeURIComponent(e):"?__action=emptyId"),this.toJsonOfIncludedKeys(t)).then(r=>this.translateFromJson(r))}toJsonOfIncludedKeys(e){let t={},r=Object.keys(e);for(const i of this.entity.fields)r.includes(i.key)&&(t[i.key]=i.valueConverter.toJson(e[i.key]));return t}async delete(e){if(e=="")await this.deleteMany(F.fromEntityFilter(this.entity,this.entity.idMetadata.getIdFilter(e)));else return this.http().delete(this.url()+"/"+encodeURIComponent(e))}insert(e){return this.http().post(this.url(),this.translateToJson(e)).then(t=>this.translateFromJson(t))}insertMany(e){return this.http().post(this.url(),e.map(t=>this.translateToJson(t))).then(t=>t.map(r=>this.translateFromJson(r)))}}class $r{constructor(e){c(this,"fetch");this.fetch=e}async get(e){return await Et(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 Et(()=>this.myFetch(e,{method:"post",body:JSON.stringify(t)}))}myFetch(e,t){const r={};if(t!=null&&t.body&&(r["Content-type"]="application/json"),typeof window<"u"&&typeof window.document<"u"&&typeof(window.document.cookie!=="undefined"))for(const i of window.document.cookie.split(";"))i.trim().startsWith("XSRF-TOKEN=")&&(r["X-XSRF-TOKEN"]=i.split("=")[1]);return(this.fetch||fetch)(e,{credentials:"include",method:t==null?void 0:t.method,body:t==null?void 0:t.body,headers:r}).then(i=>gs(i)).catch(async i=>{throw await i})}}function gs(n){if(n.status!=204){if(n.status>=200&&n.status<300)return n.json();throw n.json().then(e=>({...e,message:e.message||n.statusText,url:n.url,status:n.status})).catch(()=>{throw{message:n.statusText,url:n.url,status:n.status}})}}function vs(n,e){for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)){const r=n[t];if(Array.isArray(r)&&(r.length>0&&typeof r[0]=="object"||r.length>10))return!1}for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)){const r=n[t];Array.isArray(r)?t.endsWith(".in")?e.add(t,JSON.stringify(r)):r.forEach(i=>e.add(t,i)):t.startsWith(qe)?e.add(t,JSON.stringify(r)):e.add(t,r)}return!0}const bs="liveQuery-";var yt,_s=new Uint8Array(16);function ks(){if(!yt&&(yt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!yt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return yt(_s)}const Is=/^(?:[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 Os(n){return typeof n=="string"&&Is.test(n)}var ae=[];for(var Vt=0;Vt<256;++Vt)ae.push((Vt+256).toString(16).substr(1));function Cs(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(ae[n[e+0]]+ae[n[e+1]]+ae[n[e+2]]+ae[n[e+3]]+"-"+ae[n[e+4]]+ae[n[e+5]]+"-"+ae[n[e+6]]+ae[n[e+7]]+"-"+ae[n[e+8]]+ae[n[e+9]]+"-"+ae[n[e+10]]+ae[n[e+11]]+ae[n[e+12]]+ae[n[e+13]]+ae[n[e+14]]+ae[n[e+15]]).toLowerCase();if(!Os(t))throw TypeError("Stringified UUID is invalid");return t}function Kt(n,e,t){n=n||{};var r=n.random||(n.rng||ks)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,Cs(r)}class ve{constructor(...e){c(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 ve;for(const t of this.Segments)e.Segments.push({field:t.field,isDescending:!t.isDescending});return e}compare(e,t,r){r||(r=s=>s.key);let i=0;for(let s=0;s<this.Segments.length;s++){let a=this.Segments[s],o=qr(e[r(a.field)]),u=qr(t[r(a.field)]);if(o>u?i=1:o<u&&(i=-1),i!=0)return a.isDescending&&(i*=-1),i}return i}static translateOrderByToSort(e,t){if(!t)return;let r=new ve;if(t){for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const s=t[i];let a=e.fields.find(i);const o=u=>{switch(s){case"desc":r.Segments.push({field:u,isDescending:!0});break;case"asc":r.Segments.push({field:u})}};if(a){const u=Y(a);if((u==null?void 0:u.type)==="toOne"){const f=u.options;if(typeof f.field=="string")o(e.fields.find(f.field));else if(f.fields){for(const l in f.fields)if(Object.prototype.hasOwnProperty.call(f.fields,l)){const d=f.fields[l];o(e.fields.find(d.toString()))}}}else o(a)}}}return r}static createUniqueSort(e,t){(!t||Object.keys(t).length===0)&&e.options.defaultOrderBy&&(t=ve.translateOrderByToSort(e,e.options.defaultOrderBy)),t||(t=new ve);for(const r of e.idMetadata.fields)t.Segments.find(i=>i.field==r)||t.Segments.push({field:r});return t}static createUniqueEntityOrderBy(e,t){(!t||Object.keys(t).length===0)&&(t=e.options.defaultOrderBy),t?t={...t}:t={};for(const r of e.idMetadata.fields)t[r.key]||(t[r.key]="asc");return t}}function qr(n){return n==null||n==null?n:n.id!==void 0?n.id:n}const Ht="stream";class Es{constructor(e,t,r){c(this,"repo");c(this,"query");c(this,"queryChannel");c(this,"subscribeCode");c(this,"unsubscribe",()=>{});c(this,"defaultQueryState",[]);c(this,"listeners",[]);c(this,"id",Kt());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 Be(this.repo)._fromJsonArray(e,this.query.options);this.forListeners(r=>{r(()=>t)},this.allItemsMessage(t))}allItemsMessage(e){return[{type:"all",data:e}]}forListeners(e,t){e(r=>{if(this.defaultQueryState=r(this.defaultQueryState),t.find(i=>i.type==="add"||i.type==="replace")&&this.query.options.orderBy){const i=ve.translateOrderByToSort(this.repo.metadata,this.query.options.orderBy);this.defaultQueryState.sort((s,a)=>i.compare(s,a))}});for(const r of this.listeners)e(i=>{r.next(this.createReducerType(i,t))})}createReducerType(e,t){return{applyChanges:e,changes:t,items:this.defaultQueryState}}async handle(e){{let t=e.filter(({type:i})=>i=="add"||i=="replace"),r=await Be(this.repo)._fromJsonArray(t.map(i=>i.data.item),this.query.options);for(let i=0;i<t.length;i++){const s=t[i];s.data.item=r[i]}}this.forListeners(t=>{t(r=>{r||(r=[]);for(const i of e)switch(i.type){case"all":this.setAllItems(i.data);break;case"replace":{r=r.map(s=>this.repo.metadata.idMetadata.getId(s)===i.data.oldId?i.data.item:s);break}case"add":r=r.filter(s=>this.repo.metadata.idMetadata.getId(s)!==this.repo.metadata.idMetadata.getId(i.data.item)),r.push(i.data.item);break;case"remove":r=r.filter(s=>this.repo.metadata.idMetadata.getId(s)!==i.data.id);break}return r})},e)}}const Ts="_liveQueryKeepAlive";class Ss{constructor(e,t){c(this,"apiProvider");c(this,"getUserId");c(this,"queries",new Map);c(this,"channels",new Map);c(this,"client");c(this,"interval");this.apiProvider=e,this.getUserId=t}wrapMessageHandling(e){var t=this.apiProvider().wrapMessageHandling;t?t(e):e()}hasQueriesForTesting(){return this.queries.size>0}runPromise(e){return e}close(){this.queries.clear(),this.channels.clear(),this.closeIfNoListeners()}async subscribeChannel(e,t){let r=()=>{};const i=await this.openIfNoOpened();try{let s=this.channels.get(e);if(!s){this.channels.set(e,s=new As);try{s.unsubscribe=await i.subscribe(e,a=>this.wrapMessageHandling(()=>s.handle(a)),a=>{t.error(a)})}catch(a){throw t.error(a),a}}s.listeners.push(t),r=()=>{s.listeners.splice(s.listeners.indexOf(t),1),s.listeners.length==0&&(this.channels.delete(e),s.unsubscribe()),this.closeIfNoListeners()}}catch(s){throw t.error(s),s}return()=>{r(),r=()=>{}}}closeIfNoListeners(){this.client&&this.queries.size===0&&this.channels.size===0&&(this.runPromise(this.client.then(e=>e.close())),this.client=void 0,clearInterval(this.interval),this.interval=void 0)}subscribe(e,t,r){let i=!0,s=()=>{i=!1};return this.runPromise(Be(e)._buildEntityDataProviderFindOptions(t).then(a=>{if(!i)return;const{createKey:o,subscribe:u}=new hi(this.apiProvider).getEntityDataProvider(e.metadata).buildFindRequest(a),f=o();let l=this.queries.get(f);l?l.sendDefaultState(r.next):(this.queries.set(f,l=new Es(e,{entityKey:e.metadata.key,options:t},this.getUserId())),l.subscribeCode=()=>{l.unsubscribe&&(l.unsubscribe(),l.unsubscribe=()=>{}),this.runPromise(this.subscribeChannel(l.queryChannel,{next:d=>this.runPromise(l.handle(d)),complete:()=>{},error:d=>{l.listeners.forEach(h=>h.error(d))}}).then(d=>{if(l.listeners.length==0){d();return}this.runPromise(u(l.queryChannel).then(h=>{if(l.listeners.length===0){h.unsubscribe(),d();return}this.runPromise(l.setAllItems(h.result)),l.unsubscribe=()=>{l.unsubscribe=()=>{},d(),this.runPromise(h.unsubscribe())}}).catch(h=>{l.listeners.forEach(y=>y.error(h)),d(),this.queries.delete(f)}))})).catch(d=>{l.listeners.forEach(h=>h.error(d))})},l.subscribeCode()),l.listeners.push(r),s=()=>{l.listeners.splice(l.listeners.indexOf(r),1),r.complete(),l.listeners.length==0&&(this.queries.delete(f),l.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 O.actionInfo.runActionWithoutBlockingUI(()=>ft(t.httpClient).post(t.url+"/"+Ts,e)));for(const i of r)for(const s of this.queries.values())s.queryChannel===i&&s.subscribeCode()}},3e4),this.runPromise(this.client=this.apiProvider().subscriptionClient.openConnection(()=>{for(const e of this.queries.values())e.subscribeCode()})))}}class As{constructor(){c(this,"id");c(this,"unsubscribe",()=>{});c(this,"listeners",[])}async handle(e){for(const t of this.listeners)t.next(e)}}class cr{openConnection(e){let t;const r=new Map,i=ft(ke.apiClient.httpClient);let s=!1,a;const o={close(){a.close()},async subscribe(l,d){let h=r.get(l);return h||(r.set(l,h=[]),await f(l)),h.push(d),()=>{h.splice(h.indexOf(d,1)),h.length==0&&(O.actionInfo.runActionWithoutBlockingUI(()=>i.post(ke.apiClient.url+"/"+Ht+"/unsubscribe",{channel:l,clientId:t})),r.delete(l))}}},u=()=>new Promise(l=>{h();let d=0;function h(){a&&a.close(),a=cr.createEventSource(ke.apiClient.url+"/"+Ht),a.onmessage=y=>{let m=JSON.parse(y.data);const b=r.get(m.channel);b&&b.forEach(_=>_(m.data))},a.onerror=y=>{console.error("Live Query Event Source Error",y),a.close(),d++<di.error500RetryCount&&setTimeout(()=>{h()},500)},a.addEventListener("connectionId",async y=>{if(t=y.data,s){for(const m of r.keys())await f(m);e()}else s=!0,l(o)})}});return u();async function f(l){await O.actionInfo.runActionWithoutBlockingUI(()=>i.post(ke.apiClient.url+"/"+Ht+"/subscribe",{channel:l,clientId:t}))===Fs&&await u()}}static createEventSource(e){return new EventSource(e,{withCredentials:!0})}}const Fs="client connection not found",Xt=Symbol.for("serverActionField");class Ps{constructor(e){c(this,"remultObjectStorage");this.remultObjectStorage=e}static enable(){O.remultFactory=()=>{const e=O.asyncContext.getStore();if(e)return e.remult;throw new Error("remult object was requested outside of a valid context, try running it within initApi or a remult request cycle")}}static disable(){ds()}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;const t=(r=this.remultObjectStorage)==null?void 0:r.getStore();t&&(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()}}O.asyncContext||(O.asyncContext=new Ps(void 0));function Zt(){return O.actionInfo.runningOnServer||!ke.dataProvider.isProxy}class Oe{constructor(e){c(this,"repo",(e,t)=>{t===void 0&&(t=this.dataProvider);let r=this.repCache.get(t);r||this.repCache.set(t,r=new Map);let i=r.get(e);return i||(r.set(e,i=new hr(e,this,t,Bs(e,this))),as(i,this,t)),i});c(this,"user");c(this,"dataProvider",new hi(()=>this.apiClient));c(this,"repCache",new Map);c(this,"liveQueryStorage");c(this,"subscriptionServer");c(this,"liveQueryPublisher",{itemChanged:async()=>{}});c(this,"liveQuerySubscriber",new Ss(()=>this.apiClient,()=>{var e;return(e=this.user)==null?void 0:e.id}));c(this,"context",{});c(this,"apiClient",{url:"/api",subscriptionClient:new cr});if(e&&e.getEntityDataProvider){this.dataProvider=e;return}if(ci(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)}}authenticated(){var e;return((e=this.user)==null?void 0:e.id)!==void 0}isAllowed(e){var t,r;if(e!=null){if(e instanceof Array){for(const i of e)if(this.isAllowed(i)===!0)return!0;return!1}return typeof e=="function"?e(this):typeof e=="boolean"?e:!!(typeof e=="string"&&(r=(t=this.user)==null?void 0:t.roles)!=null&&r.includes(e.toString()))}}isAllowedForInstance(e,t){if(Array.isArray(t)){for(const r of t)if(this.isAllowedForInstance(e,r))return!0}else return typeof t=="function"?t(e,this):this.isAllowed(t)}call(e,t,...r){const i=e[Xt];if(!i.doWork)throw Error("The method received is not a valid backend method");return i.doWork(r,t,this.apiClient.url,ft(this.apiClient.httpClient))}clearAllCache(){this.repCache.clear()}}c(Oe,"onFind",(e,t)=>{}),c(Oe,"entityRefInit");O.defaultRemultFactory=()=>new Oe;class Ds{constructor(){c(this,"classes",new Map)}}const Ms={defaultPageSize:200};async function pi(n,e){const t=new Rs(n.liveQueryPublisher);let r=!0;const i=n.dataProvider;try{await n.dataProvider.transaction(async s=>{n.dataProvider=s,n.liveQueryPublisher=t,await e(s),r=!0}),r&&await t.flush()}finally{n.dataProvider=i}}class Rs{constructor(e){c(this,"orig");c(this,"transactionItems",new Map);this.orig=e}async itemChanged(e,t){let r=this.transactionItems.get(e);r||this.transactionItems.set(e,r=[]);for(const i of t)if(i.oldId!==void 0){const s=r.find(a=>a.id===i.oldId);s!==void 0?(i.deleted&&(s.deleted=!0),i.id!=s.id&&(s.id=i.id)):r.push(i)}else r.push(i)}async flush(){for(const e of this.transactionItems.keys())await this.orig.itemChanged(e,this.transactionItems.get(e))}}function Yt(n,e){return e&&Object.assign(n,e),n}class Ce{}c(Ce,"number","number"),c(Ce,"date","date"),c(Ce,"checkbox","checkbox"),c(Ce,"password","password"),c(Ce,"email","email"),c(Ce,"tel","tel"),c(Ce,"time","time");const R=class R{};c(R,"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=>R.Date.fromJson(e),toInput:e=>R.Date.toJson(e),displayValue:e=>e?e.toLocaleString():""}),c(R,"DateOnly",{fromInput:e=>R.DateOnly.fromJson(e),toInput:e=>R.DateOnly.toJson(e),toJson:e=>{var t=e;return(typeof t=="string"||typeof t=="number")&&(t=new Date(t)),!t||t==null?null:t.getHours()==0?new Date(t.valueOf()-t.getTimezoneOffset()*6e4).toISOString().substring(0,10):t.toISOString().substring(0,10)},fromJson:e=>{if(!e||e==""||e=="0000-00-00")return null;let t=new Date(Date.parse(e));return t.setMinutes(t.getMinutes()+t.getTimezoneOffset()),t},inputType:Ce.date,toDb:e=>e?R.DateOnly.fromJson(R.DateOnly.toJson(e)):null,fromDb:e=>R.Date.fromDb(e),fieldTypeInDb:"date",displayValue:e=>e?e.toLocaleDateString(void 0):""}),c(R,"DateOnlyString",{...R.DateOnly,toDb:e=>{let t=R.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))}}),c(R,"Boolean",{toDb:e=>e,inputType:Ce.checkbox,fromDb:e=>R.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=>R.Boolean.fromJson(e),toInput:e=>R.Boolean.toJson(e)}),c(R,"Number",{fromDb:e=>{if(e===null)return null;if(e!==void 0)return+e},toDb:e=>e,fromJson:e=>R.Number.fromDb(e),toJson:e=>R.Number.toDb(e),fromInput:(e,t)=>{let r=+e;if(e!=null)return r},toInput:(e,t)=>e==null?void 0:e.toString(),inputType:Ce.number}),c(R,"String",{fromDb:He,toDb:He,fromJson:He,toJson:He,fromInput:He,toInput:He}),c(R,"Integer",{...R.Number,toJson:e=>{let t=R.Number.toDb(e);return t&&+(+t).toFixed(0)},toDb:e=>R.Integer.toJson(e),fieldTypeInDb:"integer"}),c(R,"Default",{fromJson:e=>e,toJson:e=>e,fromDb:e=>R.JsonString.fromDb(e),toDb:e=>R.JsonString.toDb(e),fromInput:e=>R.Default.fromJson(e),toInput:e=>R.Default.toJson(e),displayValue:e=>e+"",fieldTypeInDb:"",inputType:"text"}),c(R,"JsonString",{fromJson:e=>e,toJson:e=>e,fromDb:e=>e==null?null:e?JSON.parse(R.JsonString.fromJson(e)):void 0,toDb:e=>e!==void 0?e===null?null:JSON.stringify(R.JsonString.toJson(e)):void 0,fromInput:e=>R.JsonString.fromJson(e),toInput:e=>R.JsonString.toJson(e)}),c(R,"JsonValue",{fromJson:e=>e,toJson:e=>e,fromDb:e=>e,toDb:e=>e,fromInput:e=>R.JsonString.fromJson(e),toInput:e=>R.JsonString.toJson(e),fieldTypeInDb:"json"});let fe=R;function He(n){return n==null?n:typeof n!="string"?n.toString():n}function Br(n,e,t){let r=F.fromEntityFilter(n,e);const i=()=>{};r&&r.__applyToConsumer({custom:i,databaseCustom:i,containsCaseInsensitive:i,notContainsCaseInsensitive:i,isDifferentFrom:i,isEqualTo:(s,a)=>{t[s.key]=a},isGreaterOrEqualTo:i,isGreaterThan:i,isIn:i,isLessOrEqualTo:i,isLessThan:i,isNotNull:i,isNull:i,or:i})}class Jr{constructor(){c(this,"entityLoaders",new Map);c(this,"promises",[])}load(e,t){let r=this.entityLoaders.get(e.entityType);r||this.entityLoaders.set(e.entityType,r=new Ns(e));const i=r.find(t);return this.promises.push(i),i}async resolveAll(){for(const t of this.entityLoaders.values())for(const r of t.queries.values())r.resolve();if(this.promises.length===0)return;const e=this.promises;this.promises=[],await Promise.all(e),await this.resolveAll()}}class Ns{constructor(e){c(this,"rel");c(this,"queries",new Map);this.rel=e}find(e){const{where:t,...r}=dr(e,this.rel.metadata),i=JSON.stringify(r);let s=this.queries.get(i);return s||this.queries.set(i,s=new Ls(this.rel)),s.find(e,t)}}class Ls{constructor(e){c(this,"rel");c(this,"pendingInStatements",new Map);c(this,"whereVariations",new Map);this.rel=e}find(e,t){const r=JSON.stringify(t);let i=this.whereVariations.get(r);if(!i){const s=Object.keys(t);if(s.length===1&&typeof t[s[0]]!="object"&&!e.limit){let a=this.pendingInStatements.get(s[0]);a||this.pendingInStatements.set(s[0],a=new $s(this.rel,s[0],e)),this.whereVariations.set(r,i={result:a.find(t)})}else this.whereVariations.set(r,i={result:this.rel.find(e)})}return i.result}resolve(){const e=[...this.pendingInStatements.values()];this.pendingInStatements.clear();for(const t of e)t.resolve()}}class $s{constructor(e,t,r){c(this,"rel");c(this,"key");c(this,"options");c(this,"values",new Map);this.rel=e,this.key=t,this.options=r}async resolve(){const e=[...this.values.values()];if(e.length==1){this.rel.find(this.options).then(e[0].resolve,e[0].reject);return}var t={...this.options};t.where={[this.key]:e.map(i=>i.value)},t.limit=1e3,t.page=1;let r=[];try{for(;;){const i=await this.rel.find(t);if(r.push(...i),i.length<t.limit)break;t.page++}for(const i of this.values.values())i.resolve(r.filter(s=>{const o=X(s).fields.find(this.key),u=Y(o.metadata),f=(u==null?void 0:u.type)==="reference"?o.getId():s[this.key];return i.value==f}))}catch(i){for(const s of this.values.values())s.reject(i)}}find(e){const t=e[this.key];let r=this.values.get(t);if(!r){let i,s,a=new Promise((o,u)=>{i=o,s=u});this.values.set(t,r={value:t,resolve:i,reject:s,result:a})}return r.result}}const ue=class ue{};c(ue,"required",rt(async(e,t)=>t.value!=null&&t.value!=null&&t.value!=="","Should not be empty")),c(ue,"unique",rt(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")),c(ue,"uniqueOnBackend",rt(async(e,t)=>t.isBackend()&&(t.isNew||t.valueChanged())?await t.entityRef.repository.count({[t.metadata.key]:t.value})==0:!0,ue.unique.defaultMessage)),c(ue,"regex",Ye((e,t)=>t.test(e))),c(ue,"email",_t(e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),"Invalid Email")),c(ue,"url",_t(e=>!!new URL(e),"Invalid Url")),c(ue,"in",Ye((e,t)=>t.includes(e),e=>`Value must be one of: ${e.map(t=>typeof t=="object"?t.id!==void 0?t.id:t.toString():t).join(", ")}`)),c(ue,"notNull",_t(e=>e!=null,"Should not be null")),c(ue,"enum",Ye((e,t)=>Object.values(t).includes(e),e=>`Value must be one of ${kt(e).join(", ")}`)),c(ue,"relationExists",rt(async(e,t)=>t.valueIsNull()||!t.isBackend()?!0:!!await t.load(),"Relation value does not exist")),c(ue,"maxLength",Ye((e,t)=>e.length<=t,e=>`Value must be at most ${e} characters`)),c(ue,"minLength",Ye((e,t)=>e.length>=t,e=>`Value must be at least ${e} characters`)),c(ue,"defaultMessage","Invalid value");let Fe=ue;function rt(n,e){const t=async(i,s,a)=>{const o=await n(i,s);typeof o=="string"&&o.length>0?s.error=o:o||(s.error=typeof a=="function"&&a(i,s,void 0)||a||typeof e=="function"&&e(i,s,void 0)||e||Fe.defaultMessage)},r=(i,s,a)=>typeof i=="string"||i==="function"||i===void 0&&s===void 0?async(o,u,f)=>await t(o,u,i||f):t(i,s,a);return Object.defineProperty(r,"defaultMessage",{get:()=>e,set:i=>{e=i},enumerable:!0}),Object.assign(r,{withMessage:i=>async(s,a)=>r(s,a,i)})}function _t(n,e){return rt((t,r)=>r.value===void 0||r.value===null?!0:n(r.value),e)}function Ye(n,e){const t=qs((r,i,s)=>i.value===void 0||i.value===null?!0:n(i.value,s),(r,i,s)=>typeof e=="function"&&e(s)||e,!0);return Object.assign((r,i)=>t(r,i),{get defaultMessage(){return e},set defaultMessage(r){e=r}})}function qs(n,e,t=!1){return Object.assign((i,s)=>async(a,o)=>{const u=await n(a,o,i);typeof u=="string"?o.error=u:u||(o.error=s?typeof s=="function"?t?s(i):s(a,o,i):s:e?typeof e=="function"?e(a,o,i):e:Fe.defaultMessage)},{get defaultMessage(){return e},set defaultMessage(i){e=i}})}function kt(n){return Object.values(n).filter(e=>typeof n[e]!="number")}function It(n,e,t=!1){if(!e)return n;const r=Array.isArray(e)?e:[e],i=Array.isArray(n)?n:n?[n]:[];return t?[...r,...i]:[...i,...r]}function Wt(n,e){return typeof n[e]<"u"}class hr{constructor(e,t,r,i,s){c(this,"_entity");c(this,"_remult");c(this,"_dataProvider");c(this,"_info");c(this,"_defaultFindOptions");c(this,"__edp");c(this,"_idCache",new Map);c(this,"listeners");c(this,"_cache",new Map);this._entity=e,this._remult=t,this._dataProvider=r,this._info=i,this._defaultFindOptions=s}_notFoundError(e){return{message:`id ${e} not found in entity ${this.metadata.key}`,httpStatusCode:404}}[st](){return this}async _createAfterFilter(e,t){let r=new Map;for(const a of ve.translateOrderByToSort(this.metadata,e).Segments){let o=t[a.field.key];r.set(a.field.key,o)}let i={$or:[]},s=[];for(const a of ve.translateOrderByToSort(this.metadata,e).Segments){let o={};for(const u of s)o[u.key]=r.get(u.key);s.push(a.field),a.isDescending?o[a.field.key]={$lt:r.get(a.field.key)}:o[a.field.key]={$gt:r.get(a.field.key)},i.$or.push(o)}return i}relations(e){return new Proxy({},{get:(t,r)=>{const i=this.fields.find(r),s=Y(i);if(!s)throw Error(r+" is not a relation");const{toRepo:a,returnNull:o,returnUndefined:u}=this._getFocusedRelationRepo(i,e);return s.type==="toMany"?a:{findOne:f=>o?Promise.resolve(null):u?Promise.resolve(void 0):a.findFirst({},f)}}})}_getFocusedRelationRepo(e,t){const r=Y(e);let i=r.toRepo,{findOptions:s,returnNull:a,returnUndefined:o}=this._findOptionsBasedOnRelation(r,e,void 0,t,i);return{toRepo:new hr(i._entity,i._remult,i._dataProvider,i._info,s),returnNull:a,returnUndefined:o}}get _edp(){return this.__edp?this.__edp:this.__edp=this._dataProvider.getEntityDataProvider(this.metadata)}_getCachedById(e,t){e=e+"",this._getCachedByIdAsync(e,t);let r=this._idCache.get(e);if(!(r instanceof Promise))return r}async _getCachedByIdAsync(e,t){e=e+"";let r=this._idCache.get(e);if(r instanceof Promise)return await r;if(this._idCache.has(e))return r;if(t)return;this._idCache.set(e,void 0);let i=this.findId(e).then(s=>(s===void 0?r=null:r=s,this._idCache.set(e,r),r));return this._idCache.set(e,i),await i}_addToCache(e){e&&this._idCache.set(this.getEntityRef(e).getId()+"",e)}get metadata(){return this._info}addEventListener(e){return this.listeners||(this.listeners=[]),this.listeners.push(e),()=>{this.listeners.splice(this.listeners.indexOf(e),1)}}query(e){return new xs(e,this)}getEntityRef(e){let t=e[Ne];return t||(this._fixTypes(e),t=new mt(this._info,e,this,this._edp,this._remult,!0),Object.defineProperty(e,Ne,{get:()=>t}),t.saveOriginalData()),t}async delete(e){const t=X(e,!1);if(t)return t.delete();if(typeof e=="string"||typeof e=="number"){if(this._dataProvider.isProxy)return this._edp.delete(e);{let i=await this.findId(e);if(!i)throw this._notFoundError(e);return await X(i).delete()}}let r=this._getRefForExistingRow(e,void 0);return this._dataProvider.isProxy||await r.reload(),r.delete()}async insert(e){if(Array.isArray(e))if(this._dataProvider.isProxy){let t=[],r=[];for(const i of e){let s=X(e,!1);if(s){if(!s.isNew())throw"Item is not new"}else s=await this.getEntityRef(this.create(i));t.push(s),r.push(await s.buildDtoForInsert())}return it(await this._edp.insertMany(r),(i,s)=>t[s].processInsertResponseDto(i))}else{let t=[];for(const r of e)t.push(await this.insert(r));return t}else{let t=X(e,!1);if(t){if(!t.isNew())throw"Item is not new";return await t.save()}else return await this.getEntityRef(this.create(e)).save()}}get fields(){return this.metadata.fields}async validate(e,...t){{let r=X(e,!1);if(r||(r=this.getEntityRef({...e})),!t||t.length===0)return await r.validate();{r.__clearErrorsAndReportChanged();let i=!1;for(const s of t)await r.fields.find(s).validate()||(i=!0);return i?r.buildErrorInfoObject():void 0}}}async updateMany({where:e,set:t}){if(F.throwErrorIfFilterIsEmpty(e,"updateMany"),this._dataProvider.isProxy)return this._edp.updateMany(await this._translateWhereToFilter(e),t);{let r=0;for await(const i of this.query({where:e}))Yt(i,t),await X(i).save(),r++;return r}}async update(e,t){{let i=X(t,!1);if(i)return await i.save()}{let i=X(e,!1);if(i)return Yt(e,t),i.save()}let r;if(typeof e=="object"?(r=this._getRefForExistingRow(e,this.metadata.idMetadata.getId(e)),Object.assign(r.instance,t)):r=this._getRefForExistingRow(t,e),this._dataProvider.isProxy)return await r.save(Object.keys(t));{const i=await r.reload();if(!i)throw this._notFoundError(r.id);for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){let a=r.fields[s];if(t[s]===void 0&&Y(a.metadata))continue;a&&(i[s]=t[s])}return await this._fixTypes(i),await r.save()}}_getRefForExistingRow(e,t){let r=X(e,!1);if(!r){const i=new this._entity(this._remult);for(const a of this._fieldsOf(e))i[a.key]=e[a.key];this._fixTypes(i);let s=new mt(this._info,i,this,this._edp,this._remult,!1);typeof t=="object"&&(t=this.metadata.idMetadata.getId(t)),t?(s.id=t,s.originalId=t):s.id=s.getId(),r=s,Object.defineProperty(i,Ne,{get:()=>s})}return r}async save(e){if(Array.isArray(e))return it(e,t=>this.save(t));{let t=X(e,!1);if(t)return await t.save();if(e instanceof bi)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){e||(e={}),this._defaultFindOptions&&(e={...this._defaultFindOptions,...e});let i=await this._buildEntityDataProviderFindOptions(e);t&&(delete i.orderBy,delete i.limit),Oe.onFind(this._info,e);const s=await this._edp.find(i);return await this._loadManyToOneForManyRows(s,e,r)}async find(e,t=!1){const r=new Jr,i=await this._rawFind(e,t,r);return await r.resolveAll(),i}async _buildEntityDataProviderFindOptions(e){let t={};return t={},(!e.orderBy||Object.keys(e.orderBy).length===0)&&(e.orderBy=this._info.entityInfo.defaultOrderBy),t.where=await this._translateWhereToFilter(e.where),e.orderBy!==void 0&&(t.orderBy=ve.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 Jr,i=await this._loadManyToOneForManyRows(e.map(s=>{let a={};for(const o of this.metadata.fields.toArray())a[o.key]=o.valueConverter.fromJson(s[o.key]);return a}),t,r);return await r.resolveAll(),i}async _loadManyToOneForManyRows(e,t,r){var o;let i;t!=null&&t.load&&(i=t.load(this.metadata.fields));for(const u of this.metadata.fields)if(_e(u.valueType,!1)&&!Y(u)){let d=!u.options.lazy;if(i!==void 0&&(d=i.includes(u)),d){let h=this._remult.repo(u.valueType),y=[];for(const m of e){let b=m[u.key];b!=null&&!y.includes(b)&&!h._idCache.has(b+"")&&y.push(b)}y.length>0&&await s(h,y)}}async function s(u,f){let l=await u.find({where:u.metadata.idMetadata.getIdFilter(...f)},!0);for(const d of l)u._addToCache(d)}let a=await it(e,async u=>await this._mapRawDataToResult(u,i));for(const u of this.metadata.fields){let f=Y(u),l=u.options.defaultIncluded;if(((o=t==null?void 0:t.include)==null?void 0:o[u.key])!==void 0&&(l=t.include[u.key]),f&&l){const d=f.toRepo;for(const h of a){let{findOptions:y,returnNull:m}=this._findOptionsBasedOnRelation(f,u,l,h,d);if(m)h[u.key]=null;else{const b=f.toEntity,_=d;r.load({entityType:b,find:I=>_._rawFind(I,!1,r),metadata:_.metadata},y).then(I=>{I.length==0&&f.type=="toOne"||(h[u.key]=f.type!=="toMany"?I.length==0?null:I[0]:I)})}}}}return a}_findOptionsBasedOnRelation(e,t,r,i,s){let a=!1,o=!1,u=[],f={},l=[];typeof e.options.findOptions=="function"?l.push(e.options.findOptions(i)):typeof e.options.findOptions=="object"&&l.push(e.options.findOptions),typeof r=="object"&&l.push(r);for(const y of l){y.where&&u.push(y.where);for(const m of["limit","include","orderBy"])y[m]&&(f[m]=y[m])}const d=e.getFields(),h=y=>{let m=e.type==="reference"?X(i).fields.find(t.key).getId():i[y];return(e.type==="toOne"||e.type==="reference")&&(m===null?a=!0:m===void 0?o=!0:e.type==="reference"&&typeof m=="object"&&(m=s.metadata.idMetadata.getId(m))),m};d.compoundIdField&&(e.type==="toMany"?u.push({[d.compoundIdField]:this.metadata.idMetadata.getId(i)}):u.push(s.metadata.idMetadata.getIdFilter(h(d.compoundIdField))));for(const y in d.fields)Object.prototype.hasOwnProperty.call(d.fields,y)&&u.push({[y]:h(d.fields[y])});return f.where={$and:u},(e.type==="toOne"||e.type==="reference")&&f.orderBy&&(f.limit=1),{findOptions:f,returnNull:a,returnUndefined:o}}async _mapRawDataToResult(e,t){if(!e)return;let r=new this._entity(this._remult),i=new mt(this._info,r,this,this._edp,this._remult,!1);return Object.defineProperty(r,Ne,{get:()=>i}),await i.loadDataFrom(e,t),i.saveOriginalData(),r}toJson(e){return e==null?e:Array.isArray(e)?e.map(t=>this.toJson(t)):typeof e.then=="function"?e.then(t=>this.toJson(t)):this.getEntityRef(e).toApiJson(!0)}fromJson(e,t){if(e==null)return e;if(Array.isArray(e))return e.map(i=>this.fromJson(i,t));let r=new this._entity(this._remult);for(const i of this._fieldsOf(e))if(_e(i.valueType,!1)){let a=e[i.key];typeof a=="string"||typeof a=="number"?r[i.key]=a:r[i.key]=this._remult.repo(i.valueType).fromJson(a)}else e[i.key]!==void 0&&(r[i.key]=i.valueConverter.fromJson(e[i.key]));if(this._fixTypes(r),t)return this.create(r);{let i=new mt(this._info,r,this,this._edp,this._remult,!1);return Object.defineProperty(r,Ne,{get:()=>i}),i.saveOriginalData(),r}}async count(e){return this._edp.count(await this._translateWhereToFilter(e))}async deleteMany({where:e}){if(F.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}))await X(r).delete(),t++;return t}}async findOne(e,t=!1){let r,i;if(e||(e={}),e.useCache){let s=dr(e,this.metadata),a=JSON.stringify(s);if(i=this._cache.get(a),i!==void 0)if(i.value&&this.getEntityRef(i.value).wasDeleted())i=void 0,this._cache.delete(a);else return this._cache.get(a).promise;else i={value:void 0,promise:void 0},this._cache.set(a,i)}return r=this.find({...e,limit:1},t).then(async s=>{let a;return s.length>0&&(a=s[0]),!a&&e.createIfNotFound&&(a=this.create(),e.where&&await Br(this.metadata,e.where,a)),a}),i&&(i.promise=r=r.then(s=>(i.value=s,s))),r}async findFirst(e,t,r=!1){if(t||(t={}),e)if(t.where){let i=t.where;t.where={$and:[i,e]}}else t.where=e;return this.findOne(t,r)}_fieldsOf(e){let t=Object.keys(e);return this.metadata.fields.toArray().filter(r=>t.includes(r.key))}create(e){var r;let t=new this._entity(this._remult);if(e){for(const i of this._fieldsOf(e))t[i.key]=e[i.key];this._fixTypes(t)}return(r=this._defaultFindOptions)!=null&&r.where&&(Br(this.metadata,this._defaultFindOptions.where,t),this._fixTypes(t)),this.getEntityRef(t),t}async _fixTypes(e){for(const t of this._fieldsOf(e)){const r=e[t.key];if(r!=null)if(t.valueType===Date&&!(r instanceof Date))e[t.key]=t.valueConverter.fromJson(t.valueConverter.toJson(r));else for(const[i,s]of[[String,"string"],[Number,"number"],[Boolean,"boolean"]])t.valueType===i&&typeof r!==s&&(e[t.key]=t.valueConverter.fromJson(t.valueConverter.toJson(r)))}return e}findId(e,t){if(e==null)return 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 r,i;e||(e={}),(r=this._defaultFindOptions)!=null&&r.where&&(e={$and:[e,(i=this._defaultFindOptions)==null?void 0:i.where]}),this._dataProvider.isProxy||(this.metadata.options.backendPreprocessFilter&&(e=await this.metadata.options.backendPreprocessFilter(e,{metadata:this.metadata,getFilterPreciseValues:s=>F.getPreciseValues(this.metadata,s||e)})),this.metadata.options.backendPrefilter&&(e={$and:[e,await F.resolve(this.metadata.options.backendPrefilter)]}));let t=await F.fromEntityFilter(this.metadata,e);return t&&!this._dataProvider.isProxy&&(t=await F.translateCustomWhere(t,this.metadata,this._remult)),t}}function Bs(n,e){let t=O.columnsOfType.get(n);t||O.columnsOfType.set(n,t=[]);let r=_e(n)(e),i=is(n),s=Object.getPrototypeOf(n);for(;s!=null;){let a=O.columnsOfType.get(s);a&&t.unshift(...a.filter(u=>!t.find(f=>f.key==u.key)));let o=_e(s,!1);if(o){let u=o(e);r={...u,...r};let f=["saving","saved","deleting","deleted","validation"];for(const l of f)if(u[l]&&u[l]!==r[l]){let d=r[l];r[l]=async(h,y)=>{await d(h,y),await u[l](h,y)}}}s=Object.getPrototypeOf(s)}return new Vs(mi(t,e),r,e,n,i)}class yi{constructor(e,t,r,i){c(this,"fieldsMetadata");c(this,"instance");c(this,"remult");c(this,"isNewRow");c(this,"_error");c(this,"_subscribers");c(this,"_isLoading",!1);c(this,"lookups",new Map);c(this,"errors");c(this,"originalValues",{});var s;this.fieldsMetadata=e,this.instance=t,this.remult=r,this.isNewRow=i;{let a=r;a!=null&&a.iAmRemultProxy&&(r=O.remultFactory())}for(const a of e)if(_e(a.valueType,!1)&&r){let u=new ps(r.repo(a.valueType),!!Y(a),a.allowNull);this.lookups.set(a.key,u);let f=t[a.key],l;Object.defineProperty(t,a.key,{get:()=>(this._subscribers&&(this._subscribers.reportObserved(),l||(l=this.fields.find(a.key),l._subscribers||(l._subscribers=new wt)),l._subscribers.reportObserved()),u.item),set:d=>{var h;u.set(d),(h=this._subscribers)==null||h.reportChanged(),l||(l=this.fields.find(a.key),l._subscribers||(l._subscribers=new wt)),l._subscribers.reportChanged()},enumerable:!0}),u.set(f)}else if(((s=Y(a))==null?void 0:s.type)==="toOne"){let u=t.hasOwnProperty(a.key),f=t[a.key];i&&!f&&(u=!1),Object.defineProperty(t,a.key,{get:()=>f,set:l=>{if(f=l,l===void 0)return;const d=a.options;if(d.field&&(this.instance[d.field]=Y(a).toRepo.metadata.idMetadata.getId(l)),d.fields){for(const h in d.fields)if(Object.prototype.hasOwnProperty.call(d.fields,h)){const y=d.fields[h];this.instance[y]=l==null?null:l[h]}}},enumerable:!0}),u&&(t[a.key]=f)}}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 wt;for(const e of this.fieldsMetadata){let t=_e(e.valueType,!1),r=this.fields.find(e.key);if(r._subscribers=new wt,!(t&&this.remult)){let i=this.instance[e.key];Object.defineProperty(this.instance,e.key,{get:()=>(this._subscribers.reportObserved(),r._subscribers.reportObserved(),i),set:s=>{i=s,this._subscribers.reportChanged(),r._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 it([...this.lookups.values()],e=>e.waitLoad())}__assertValidity(){if(!this.hasErrors())throw this.buildErrorInfoObject()}buildErrorInfoObject(){let e={modelState:Object.assign({},this.errors),message:this.error};if(!e.message){for(const t of this.fieldsMetadata)if(this.errors[t.key]){e.message=this.fields[t.key].metadata.caption+": "+this.errors[t.key],this.error=e.message;break}}return e}catchSaveErrors(e){let t=e;if(t instanceof Promise)return t.then(i=>this.catchSaveErrors(i));t.error&&(t=t.error),t.message?this.error=t.message:t.Message?this.error=t.Message:this.error=t;let r=t.modelState;throw r||(r=t.ModelState),r&&(this.errors=r),e}__clearErrorsAndReportChanged(){this.errors=void 0,this.error=void 0,this._reportChangedToEntityAndFields()}_reportChangedToEntityAndFields(){if(this._subscribers){this._subscribers.reportChanged();for(const e of this.fields)e._subscribers.reportChanged()}}hasErrors(){var e;return(e=this._subscribers)==null||e.reportObserved(),!this.error&&this.errors==null}copyDataToObject(e=!1){let t={};for(const r of this.fieldsMetadata){let i=this.lookups.get(r.key),s;const a=Y(r);i?s=i.id:s=this.instance[r.key],a&&e&&!r.allowNull&&s==null&&(a.toRepo.metadata.idMetadata.field.valueType===Number?s=0:s=""),(!a||a.type==="reference")&&(s!==void 0&&(s=r.valueConverter.toJson(s),s!=null&&(s=r.valueConverter.fromJson(JSON.parse(JSON.stringify(s))))),t[r.key]=s)}return t}saveOriginalData(){this.originalValues=this.copyDataToObject(),this.saveMoreOriginalData()}saveMoreOriginalData(){}async validate(){if(this.__clearErrorsAndReportChanged(),await this.__performColumnAndEntityValidations(),this.hasErrors(),!this.hasErrors())return this.buildErrorInfoObject()}async __validateEntity(){this.__clearErrorsAndReportChanged(),await this.__performColumnAndEntityValidations(),this.__assertValidity()}async __performColumnAndEntityValidations(){}toApiJson(e=!1,t=!1){let r={};for(const i of this.fieldsMetadata)if(t||!this.remult||i.includedInApi(this.instance)){let s,a=this.lookups.get(i.key),o=!1;a?e?(s=a.toJson(),o=!0,r[i.key]=s):s=a.id:Y(i)&&!e?o=!0:(s=this.instance[i.key],this.remult||s&&_e(s.constructor,!1)&&(s=X(s).getId())),o||(r[i.key]=i.valueConverter.toJson(s))}return r}async _updateEntityBasedOnApi(e,t=!1){let r=Object.keys(e);for(const i of this.fieldsMetadata)if(r.includes(i.key)&&i.includedInApi(this.instance)&&(!this.remult||t||i.apiUpdateAllowed(this.instance))){let s=this.lookups.get(i.key);s?s.id=e[i.key]:this.instance[i.key]=i.valueConverter.fromJson(e[i.key])}await it([...this.fields].filter(i=>!Y(i.metadata)),i=>i.load())}}class mt extends yi{constructor(t,r,i,s,a,o){super(t.fieldsMetadata,r,a,o);c(this,"info");c(this,"repository");c(this,"edp");c(this,"_isNew");c(this,"metadata");c(this,"_wasDeleted",!1);c(this,"_columns");c(this,"_saving",!1);c(this,"id");c(this,"originalId");if(this.info=t,this.repository=i,this.edp=s,this._isNew=o,this.metadata=t,o)for(const u of t.fieldsMetadata)u.options.defaultValue&&r[u.key]===void 0&&(typeof u.options.defaultValue=="function"?r[u.key]=u.options.defaultValue(r):r[u.key]||(r[u.key]=u.options.defaultValue));this.info.options.entityRefInit&&this.info.options.entityRefInit(this,r),Oe.entityRefInit&&Oe.entityRefInit(this,r)}clone(){const t=this.toApiJson(!0,!0);return this.repository.fromJson(t,this.isNew())}get relations(){return this.repository.relations(this.instance)}get apiUpdateAllowed(){return this.remult.isAllowedForInstance(this.instance,this.metadata.options.allowApiUpdate)}get apiDeleteAllowed(){return this.remult.isAllowedForInstance(this.instance,this.metadata.options.allowApiDelete)}get apiInsertAllowed(){return this.remult.isAllowedForInstance(this.instance,this.metadata.options.allowApiInsert)}getId(){const t=r=>{let i=this.lookups.get(r.key);return i?i.id:this.instance[r.key]};return this.metadata.idMetadata.field instanceof Le?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.repository._notFoundError(this.id);await this.loadDataFrom(t[0]),this.saveOriginalData()}),this._reportChangedToEntityAndFields(),this.instance}get fields(){if(!this._columns){let t=[],r={find:i=>r[typeof i=="string"?i:i.key],[Symbol.iterator]:()=>t[Symbol.iterator](),toArray:()=>t};for(const i of this.info.fieldsMetadata)t.push(r[i.key]=new Tt(i.options,i,this.instance,this,this));this._columns=r}return this._columns}async save(t){var r;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 i=!1,s=this.buildLifeCycleEvent(()=>i=!0);if(!this.repository._dataProvider.isProxy){for(const l of this.fields)l.metadata.options.saving&&await l.metadata.options.saving(this.instance,l,s);this.info.entityInfo.saving&&await this.info.entityInfo.saving(this.instance,s)}this.__assertValidity();let a=this.copyDataToObject(this.isNew()),o=[];for(const l of this.metadata.fields)if(l.dbReadOnly||t!==void 0&&!t.includes(l.key)){a[l.key]=void 0,o.push(l.key);let d=this.fields.find(l);d.value=d.originalValue}let u,f=this.isNew();try{if((r=this._subscribers)==null||r.reportChanged(),this.isNew())u=await this.edp.insert(a);else{let l={},d=!1;for(const h in a)if(Object.prototype.hasOwnProperty.call(a,h)){const y=a[h];this.fields.find(h).valueChanged()&&!o.includes(h)&&(l[h]=y,d=!0)}if(!d)return this.instance;i?u=(await this.edp.find({where:await this.getIdFilter()}))[0]:u=await this.edp.update(this.id,l)}if(await this.loadDataFrom(u),s.id=this.getId(),!this.repository._dataProvider.isProxy&&(this.info.entityInfo.saved&&await this.info.entityInfo.saved(this.instance,s),this.repository.listeners))for(const l of this.repository.listeners.filter(d=>d.saved))await l.saved(this.instance,f);return await this.repository._remult.liveQueryPublisher.itemChanged(this.repository.metadata.key,[{id:this.getId(),oldId:this.getOriginalId(),deleted:!1}]),this.saveOriginalData(),this._isNew=!1,this.instance}catch(l){await this.catchSaveErrors(l)}}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()),r=[];for(const i of this.metadata.fields)if(i.dbReadOnly){t[i.key]=void 0,r.push(i.key);let s=this.fields.find(i);s.value=s.originalValue}return t}buildLifeCycleEvent(t=()=>{}){const r=this;return{isNew:r.isNew(),fields:r.fields,id:r.getId(),originalId:r.getOriginalId(),metadata:r.repository.metadata,repository:r.repository,preventDefault:()=>t(),relations:r.repository.relations(r.instance)}}async getIdFilter(){return await this.repository._translateWhereToFilter(this.repository.metadata.idMetadata.getIdFilter(this.id))}async delete(){this.__clearErrorsAndReportChanged();let t=!0,r=this.buildLifeCycleEvent(()=>t=!1);this.repository._dataProvider.isProxy||this.info.entityInfo.deleting&&await this.info.entityInfo.deleting(this.instance,r),this.__assertValidity();try{if(t&&await this.edp.delete(this.id),this.repository._dataProvider.isProxy||this.info.entityInfo.deleted&&await this.info.entityInfo.deleted(this.instance,r),this.repository.listeners)for(const i of this.repository.listeners.filter(s=>s.deleted))await i.deleted(this.instance);await this.repository._remult.liveQueryPublisher.itemChanged(this.repository.metadata.key,[{id:this.getId(),oldId:this.getOriginalId(),deleted:!0}]),this._wasDeleted=!0}catch(i){await this.catchSaveErrors(i)}}async loadDataFrom(t,r){for(const i of this.info.fields){let s=this.lookups.get(i.key);s?(s.id=t[i.key],r===void 0?!i.options.lazy&&!Y(i)&&await s.waitLoad():r.includes(i)&&await s.waitLoad()):Y(i)||(this.instance[i.key]=t[i.key])}await this.calcServerExpression(),this.id=this.getId()}getOriginalId(){return this.originalId}async calcServerExpression(){if(Zt())for(const t of this.info.fieldsMetadata)t.options.serverExpression&&(this.instance[t.key]=await t.options.serverExpression(this.instance))}isNew(){var t;return(t=this._subscribers)==null||t.reportObserved(),this._isNew}wasChanged(){var t;(t=this._subscribers)==null||t.reportObserved();for(const r of this.fields){const i=Y(r.metadata);if((!i||i.type=="reference")&&r.valueChanged())return!0}return!1}async __performColumnAndEntityValidations(){for(const t of this.fieldsMetadata)t.options.validate&&await new Tt(t.options,t,this.instance,this,this).__performValidation();if(this.info.entityInfo.validation){let t=this.buildLifeCycleEvent(()=>{});await this.info.entityInfo.validation(this.instance,t)}if(this.repository.listeners)for(const t of this.repository.listeners.filter(r=>r.validating))await t.validating(this.instance)}}const jr=Symbol.for("controllerColumns");function mi(n,e){return n.map(t=>pr(t.settings(e),e))}function Ur(n,e){const t=e||ke;let r=n[jr];if(r||(r=n[Ne]),!r){let i=O.columnsOfType.get(n.constructor);i||O.columnsOfType.set(n.constructor,i=[]);let s=Object.getPrototypeOf(n.constructor);for(;s!=null;){let a=O.columnsOfType.get(s);a&&i.unshift(...a.filter(o=>!i.find(u=>u.key==o.key))),s=Object.getPrototypeOf(s)}n[jr]=r=new Js(mi(i,t).map(a=>new gi(a,void 0,t)),n,t)}return r}class Js extends yi{constructor(t,r,i){super(t,r,i,!1);c(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 Tt(o.options,o,r,void 0,this));this.fields=a}async __performColumnAndEntityValidations(){for(const t of this.fields)t instanceof Tt&&await t.__performValidation()}}class Tt{constructor(e,t,r,i,s){c(this,"settings");c(this,"metadata");c(this,"container");c(this,"helper");c(this,"rowBase");c(this,"_subscribers");c(this,"target");c(this,"entityRef");this.settings=e,this.metadata=t,this.container=r,this.helper=i,this.rowBase=s,this.target=this.settings.target,this.entityRef=this.helper}subscribe(e){return this._subscribers||this.rowBase.initSubscribers(),this._subscribers.subscribe(e)}valueIsNull(){this.reportObserved();let e=this.rowBase.lookups.get(this.metadata.key);return e?e.id===void 0||e.id===null:this.value===null}originalValueIsNull(){return this.reportObserved(),this.rowBase.lookups.get(this.metadata.key),this.rawOriginalValue()===null}async load(){let e=this.rowBase.lookups.get(this.metadata.key),t=Y(this.metadata);if(t){if(t.type==="toMany")return this.container[this.metadata.key]=await this.helper.repository.relations(this.container)[this.metadata.key].find();{let r=await this.helper.repository.relations(this.container)[this.metadata.key].findOne();if(r)this.container[this.metadata.key]=r;else return null}}else if(e)return this.valueChanged()&&await e.waitLoadOf(this.rawOriginalValue()),await e.waitLoad();return this.value}reportObserved(){var e,t;(e=this._subscribers)==null||e.reportObserved(),(t=this.rowBase._subscribers)==null||t.reportObserved()}reportChanged(){var e,t;(e=this._subscribers)==null||e.reportChanged(),(t=this.rowBase._subscribers)==null||t.reportChanged()}get error(){if(this.reportObserved(),!!this.rowBase.errors)return this.rowBase.errors[this.metadata.key]}set error(e){this.rowBase.errors||(this.rowBase.errors={}),this.rowBase.errors[this.metadata.key]=e,this.reportChanged()}get displayValue(){return this.reportObserved(),this.value!=null?this.settings.displayValue?this.settings.displayValue(this.container,this.value):this.metadata.valueConverter.displayValue?this.metadata.valueConverter.displayValue(this.value):this.value.toString():""}get value(){return this.container[this.metadata.key]}set value(e){this.container[this.metadata.key]=e}get originalValue(){this.reportObserved();let e=this.rowBase.lookups.get(this.metadata.key);return e?e.get(this.rawOriginalValue()):this.rowBase.originalValues[this.metadata.key]}rawOriginalValue(){return this.rowBase.originalValues[this.metadata.key]}setId(e){this.value=e}getId(){let e=this.rowBase.lookups.get(this.metadata.key);return e?e.id!=null?e.id:null:this.value}get inputValue(){this.reportObserved();let e=this.rowBase.lookups.get(this.metadata.key);return e?e.id!=null?e.id.toString():null:this.metadata.valueConverter.toInput(this.value,this.settings.inputType)}set inputValue(e){let t=this.rowBase.lookups.get(this.metadata.key);t?t.setId(e):this.value=this.metadata.valueConverter.fromInput(e,this.settings.inputType)}valueChanged(){this.reportObserved();let e=this.value,t=this.rowBase.lookups.get(this.metadata.key);return t&&(e=t.id),JSON.stringify(this.metadata.valueConverter.toJson(this.rowBase.originalValues[this.metadata.key]))!=JSON.stringify(this.metadata.valueConverter.toJson(e))}async __performValidation(){var e;try{const t=r=>{r!==!0&&r!==void 0&&!this.error&&(typeof r=="string"&&r.length>0?this.error=r:this.error="invalid value")};if(this.settings.validate){let r=this,i={entityRef:this.entityRef,get error(){return r.error},set error(s){r.error=s},isNew:(e=this.entityRef)==null?void 0:e.isNew(),load:()=>r.load(),metadata:r.metadata,originalValue:r.originalValue,value:r.value,valueChanged:()=>r.valueChanged(),originalValueIsNull:()=>r.originalValueIsNull(),valueIsNull:()=>r.valueIsNull(),isBackend:()=>{var s,a,o;return!((o=(a=(s=r.rowBase)==null?void 0:s.remult)==null?void 0:a.dataProvider)!=null&&o.isProxy)}};if(Array.isArray(this.settings.validate))for(const s of this.settings.validate)t(await s(this.container,i));else typeof this.settings.validate=="function"&&t(await this.settings.validate(this.container,i))}}catch(t){typeof t=="string"?this.error=t:this.error=t.message}}async validate(){return await this.__performValidation(),!this.error}}let js={transformCaption:(n,e,t,r)=>t};const Us=O.captionTransformer||(O.captionTransformer=js);function wi(n,e,t,r){let i;return typeof n=="function"?t&&(i=n(t)):n&&(i=n),i=Us.transformCaption(t,e,i,r),i||(e?hs(e):"")}class gi{constructor(e,t,r){c(this,"settings");c(this,"entityDefs");c(this,"remult");c(this,"options");c(this,"target");c(this,"readonly");c(this,"valueConverter");c(this,"allowNull");c(this,"caption");c(this,"dbName");c(this,"inputType");c(this,"key");c(this,"isServerExpression");c(this,"valueType");this.settings=e,this.entityDefs=t,this.remult=r,this.options=this.settings,this.target=this.settings.target,this.valueConverter=new Proxy(this.settings.valueConverter,{get:(i,s)=>{let a=i[s];return typeof a=="function"?(...o)=>{try{return i[s](...o)}catch(u){const f=`${String(s)} failed for value ${o==null?void 0:o[0]}. Error: ${typeof u=="string"?u:u.message}`;throw{message:this.caption+": "+f,modelState:{[this.key]:f}}}}:a}}),this.allowNull=!!this.settings.allowNull,this.valueType=this.settings.valueType,this.key=this.settings.key,this.inputType=this.settings.inputType,e.serverExpression&&(this.isServerExpression=!0),typeof this.settings.allowApiUpdate=="boolean"&&(this.readonly=this.settings.allowApiUpdate),this.inputType||(this.inputType=this.valueConverter.inputType),this.dbName=e.dbName,this.dbName==null&&(this.dbName=e.key),this.caption=wi(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 yr(this,this.entityDefs)}get dbReadOnly(){return this.settings.dbReadOnly}}class Vs{constructor(e,t,r,i,s){c(this,"entityInfo");c(this,"remult");c(this,"entityType");c(this,"key");c(this,"options");c(this,"fieldsMetadata",[]);c(this,"idMetadata",{getId:e=>{if(e==null)return e;const t=X(e,!1);return t?t.getId():this.idMetadata.field instanceof Le?this.idMetadata.field.getId(e):e[this.idMetadata.field.key]},field:void 0,get fields(){return this.field instanceof Le?this.field.fields:[this.field]},createIdInFilter:e=>{if(e.length>0)return{$or:e.map(t=>this.idMetadata.getIdFilter(X(t).getId()))}},isIdField:e=>e.key==this.idMetadata.field.key,getIdFilter:(...e)=>{if(this.idMetadata.field instanceof Le){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}}});c(this,"fields");c(this,"dbName");c(this,"caption");if(this.entityInfo=t,this.remult=r,this.entityType=i,this.key=s,this.options=t,this.options.allowApiCrud!==void 0){let o;typeof this.options.allowApiCrud=="function"?o=(u,f)=>this.options.allowApiCrud(f):o=this.options.allowApiCrud,this.options.allowApiDelete===void 0&&(this.options.allowApiDelete=o),this.options.allowApiInsert===void 0&&(this.options.allowApiInsert=o),this.options.allowApiUpdate===void 0&&(this.options.allowApiUpdate=o),this.options.allowApiRead===void 0&&(this.options.allowApiRead=this.options.allowApiCrud)}this.options.allowApiRead===void 0&&(this.options.allowApiRead=!0),this.key||(this.key=i.name),t.dbName||(t.dbName=this.key),this.dbName=t.dbName;let a={find:o=>a[typeof o=="string"?o:o.key],[Symbol.iterator]:()=>this.fieldsMetadata[Symbol.iterator](),toArray:()=>this.fieldsMetadata};for(const o of e)this.fieldsMetadata.push(a[o.key]=new gi(o,this,r));if(this.fields=a,this.caption=wi(t.caption,this.key,r,this),t.id){let o=typeof t.id=="function"?t.id(this.fields):Object.keys(t.id).map(u=>this.fields.find(u));Array.isArray(o)?o.length>1?this.idMetadata.field=new Le(...o):o.length==1&&(this.idMetadata.field=o[0]):this.idMetadata.field=o}this.idMetadata.field||(this.fields.id?this.idMetadata.field=this.fields.id: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=X(e,!1);return t||this.remult.repo(this.entityType).getEntityRef({...e})}getDbName(){return Ii(this)}}function Hs(n){var e,t;return((t=(e=n.options)==null?void 0:e.valueConverter)==null?void 0:t.fieldTypeInDb)==="autoincrement"}const Ws=Symbol.for("storableMember"),xt=Symbol.for("fieldOptionalValues");function vi(n,e){let t={};for(const r of n)if(r)if(typeof r=="function")r(t,e);else{const{validate:i,...s}=r;t.validate=It(t.validate,i),Object.assign(t,s)}return t}function pr(n,e){if(n.valueType){let t=n.valueType[Ws];t&&(n=vi([...t,n],e))}if(n.valueType==String){let t=n;n.valueConverter||(t.valueConverter=fe.String)}if(n.valueType==Number){let t=n;n.valueConverter||(t.valueConverter=fe.Number)}if(n.valueType==Date){let t=n;n.valueConverter||(t.valueConverter=fe.Date)}if(n.valueType==Boolean){let t=n;t.valueConverter||(t.valueConverter=fe.Boolean)}if(!n.valueConverter){if(_e(n.valueType,!1)){let r;n.valueConverter={toDb:i=>i,fromDb:i=>i},n.valueConverter=new Proxy(n.valueConverter,{get(i,s){if(i[s]===void 0&&r===void 0){if(s==="inputType")return"";r=e.repo(n.valueType).metadata.idMetadata.field.valueType===Number;for(const a of["fieldTypeInDb","toJson","fromJson","toDb","fromDb"])i[a]=r?fe.Integer[a]:fe.String[a]}return i[s]},set(i,s,a,o){return i[s]=a,!0}})}else n.valueConverter=fe.Default;return n}return n.valueConverter.toJson||(n.valueConverter.toJson=t=>t),n.valueConverter.fromJson||(n.valueConverter.fromJson=t=>t),n.valueConverter.toDb||(n.valueConverter.toDb=t=>n.valueConverter.toJson(t)),n.valueConverter.fromDb||(n.valueConverter.fromDb=t=>n.valueConverter.fromJson(t)),n.valueConverter.toInput||(n.valueConverter.toInput=t=>n.valueConverter.toJson(t)),n.valueConverter.fromInput||(n.valueConverter.fromInput=t=>n.valueConverter.fromJson(t)),n}class bi{get _(){return X(this)}save(){return X(this).save()}assign(e){return Yt(this,e),this}delete(){return this._.delete()}isNew(){return this._.isNew()}get $(){return this._.fields}}class xs{constructor(e,t){c(this,"options");c(this,"repo");c(this,"_count");this.options=e,this.repo=t,this.options||(this.options={}),this.options.pageSize||(this.options.pageSize=Ms.defaultPageSize)}async getPage(e){return e<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=ve.createUniqueEntityOrderBy(this.repo.metadata,this.options.orderBy);let t=await this.repo.find({where:{$and:[this.options.where,e]},orderBy:this.options.orderBy,limit:this.options.pageSize,load:this.options.load,include:this.options.include}),r,i=t.length==this.options.pageSize;if(i){let s=await this.repo._createAfterFilter(this.options.orderBy,t[t.length-1]);r=()=>this.paginator(s)}return{count:()=>this.count(),hasNextPage:i,items:t,nextPage:r}}[Symbol.asyncIterator](){this.options.where||(this.options.where={});let e=this.options.orderBy;this.options.orderBy=ve.createUniqueEntityOrderBy(this.repo.metadata,e);let t=-1,r,i,s=0;return i=async()=>{if(this.options.progress&&this.options.progress.progress(s++/await this.count()),r===void 0||t==r.items.length){if(r&&!r.hasNextPage)return{value:void 0,done:!0};let a=r;if(r?r=await r.nextPage():r=await this.paginator(),t=0,r.items.length==0)return{value:void 0,done:!0};if((a==null?void 0:a.items.length)>0&&this.repo.getEntityRef(a.items[0]).getId()==this.repo.getEntityRef(r.items[0]).getId())throw new Error("pagination failure, returned same first row")}if(t<r.items.length)return{value:r.items[t++],done:!1}},{next:async()=>i()}}}class wt{constructor(){c(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)}}function Qs(n){return n.metadata?n.metadata:_e(n,!1)?ke.repo(n).metadata:n}function Gs(n){return _e(n,!1)?ke.repo(n):n}async function it(n,e){const t=[];for(let r=0;r<n.length;r++){const i=n[r];t.push(await e(i,r))}return t}const Qe=class Qe{constructor(e){c(this,"sql");c(this,"wrapIdentifier",e=>e);c(this,"provideMigrationBuilder");c(this,"createdEntities",[]);c(this,"end");this.sql=e,e.wrapIdentifier&&(this.wrapIdentifier=t=>e.wrapIdentifier(t)),Wt(e,"provideMigrationBuilder")&&(this.provideMigrationBuilder=t=>e.provideMigrationBuilder(t)),Wt(e,"end")&&(this.end=()=>e.end())}static getDb(e){const t=e||ke.dataProvider;if(Wt(t,"createCommand"))return t;throw"the data provider is not an SqlCommandFactory"}createCommand(){return new Ks(this.sql.createCommand(),Qe.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:fe.JsonString.toDb,fromDb:fe.JsonString.fromDb});return new _i(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 Qe({createCommand:()=>{let i=t.createCommand();return{addParameterAndReturnSqlToken:s=>i.param(s),param:s=>i.param(s),execute:async s=>{if(r)throw"can't run a command after the transaction was completed";return i.execute(s)}}},getLimitSqlSyntax:this.sql.getLimitSqlSyntax,entityIsUsedForTheFirstTime:i=>t.entityIsUsedForTheFirstTime(i),transaction:i=>t.transaction(i),supportsJsonColumnType:this.sql.supportsJsonColumnType,wrapIdentifier:this.wrapIdentifier,end:this.end}))}finally{r=!0}})}static rawFilter(e){return{[li]:{buildSql:e}}}static async filterToRaw(e,t,r,i,s){r||(r=new Xs);const a=Gs(e);var o=new $e(r,i||await ki(a.metadata,s));return o._addWhere=!1,await(await Be(a)._translateWhereToFilter(t)).__applyToConsumer(o),await o.resolveWhere()}};c(Qe,"LogToConsole",!1),c(Qe,"durationThreshold",0);let Ge=Qe;const zs=new Map([["INSERT","⚪"],["SELECT","🔵"],["UPDATE","🟣"],["DELETE","🟤"],["CREATE","🟩"],["ALTER","🟨"],["DROP","🟥"],["TRUNCATE","⬛"],["GRANT","🟪"],["REVOKE","🟫"]]);class Ks{constructor(e,t){c(this,"origin");c(this,"logToConsole");c(this,"args",{});this.origin=e,this.logToConsole=t}addParameterAndReturnSqlToken(e){return this.param(e)}param(e,t){let r=this.origin.param(e);return this.args[r]=e,r}async execute(e){try{let r=new Date,i=await this.origin.execute(e);if(this.logToConsole!==!1){var t=new Date().valueOf()-r.valueOf();if(t>Ge.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(`${zs.get(o)||"💢"} (${s.toFixed(3)}) ${a} ${JSON.stringify(this.args)}`)}else typeof this.logToConsole=="function"?this.logToConsole(s,e,this.args):console.info(e+`
|
|
2
|
+
`,{arguments:this.args,duration:s})}}return i}catch(r){throw console.error((r.message||"Sql Error")+`:
|
|
3
|
+
`,e,{arguments:this.args,error:r}),r}}}class _i{constructor(e,t,r,i){c(this,"entity");c(this,"sql");c(this,"iAmUsed");c(this,"strategy");this.entity=e,this.sql=t,this.iAmUsed=r,this.strategy=i}async init(){let e=await ki(this.entity,t=>this.sql.wrapIdentifier(t));return await this.iAmUsed(e),e}async count(e){let t=await this.init(),r="select count(*) count from "+t.$entityName,i=this.sql.createCommand();if(e){let s=new $e(i,t);e.__applyToConsumer(s),r+=await s.resolveWhere()}return i.execute(r).then(s=>Number(s.rows[0].count))}async find(e){let t=await this.init(),{colKeys:r,select:i}=this.buildSelect(t);i="select "+i,i+=`
|
|
4
|
+
from `+t.$entityName;let s=this.sql.createCommand();if(e){if(e.where){let a=new $e(s,t);e.where.__applyToConsumer(a),i+=await a.resolveWhere()}if(e.limit&&(e.orderBy=ve.createUniqueSort(this.entity,e.orderBy)),e.orderBy||(e.orderBy=ve.createUniqueSort(this.entity,new ve)),e.orderBy){let a=!0,o=[];for(const u of e.orderBy.Segments)o.push(u);for(const u of o)a?(i+=" Order By ",a=!1):i+=", ",i+=t.$dbNameOf(u.field),u.isDescending&&(i+=" desc"),this.sql._getSourceSql().orderByNullsFirst&&(u.isDescending?i+=" nulls last":i+=" nulls first")}if(e.limit){let a=1;e.page&&(a=e.page),a<1&&(a=1),i+=" "+this.strategy.getLimitSqlSyntax(e.limit,(a-1)*e.limit)}}return s.execute(i).then(a=>a.rows.map(o=>this.buildResultRow(r,o,a)))}buildResultRow(e,t,r){let i={};for(let s=0;s<e.length;s++){const a=e[s];try{i[a.key]=a.valueConverter.fromDb(t[r.getColumnKeyInResultForIndexInSelect(s)])}catch(o){throw new Error("Failed to load from db:"+a.key+`\r
|
|
5
|
+
`+o)}}return i}buildSelect(e){let t="",r=[];for(const i of this.entity.fields)i.isServerExpression||(r.length>0&&(t+=", "),t+=e.$dbNameOf(i),r.push(i));return{colKeys:r,select:t}}async update(e,t){let r=await this.init(),i=this.sql.createCommand(),s="update "+r.$entityName+" set ",a=!1;for(const d of this.entity.fields)if(!Hr(d,r)){if(t[d.key]!==void 0){let h=d.valueConverter.toDb(t[d.key]);h!==void 0&&(a?s+=", ":a=!0,s+=r.$dbNameOf(d)+" = "+i.param(h))}}const o=this.entity.idMetadata.getIdFilter(e);let u=new $e(i,r);F.fromEntityFilter(this.entity,o).__applyToConsumer(u),s+=await u.resolveWhere();let{colKeys:f,select:l}=this.buildSelect(r);return this.sql._getSourceSql().doesNotSupportReturningSyntax||(s+=" returning "+l),i.execute(s).then(d=>{var h,y;if((y=(h=this.sql._getSourceSql()).afterMutation)==null||y.call(h),this.sql._getSourceSql().doesNotSupportReturningSyntax)return Vr(this.entity,this,t,e,"update");if(d.rows.length!=1)throw new Error("Failed to update row with id "+e+", rows updated: "+d.rows.length);return this.buildResultRow(f,d.rows[0],d)})}async delete(e){let t=await this.init(),r=this.sql.createCommand(),i=new $e(r,t);F.fromEntityFilter(this.entity,this.entity.idMetadata.getIdFilter(e)).__applyToConsumer(i);let s="delete from "+t.$entityName;return s+=await i.resolveWhere(),r.execute(s).then(()=>{var a,o;(o=(a=this.sql._getSourceSql()).afterMutation)==null||o.call(a)})}async insert(e){let t=await this.init(),r=this.sql.createCommand(),i="",s="",a=!1;for(const l of this.entity.fields)if(!Hr(l,t)){let d=l.valueConverter.toDb(e[l.key]);d!=null&&(a?(i+=", ",s+=", "):a=!0,i+=t.$dbNameOf(l),s+=r.param(d))}let o=`insert into ${t.$entityName} (${i}) values (${s})`,{colKeys:u,select:f}=this.buildSelect(t);return this.sql._getSourceSql().doesNotSupportReturningSyntax||(o+=" returning "+f),await r.execute(o).then(l=>{var d,h;if((h=(d=this.sql._getSourceSql()).afterMutation)==null||h.call(d),this.sql._getSourceSql().doesNotSupportReturningSyntax)if(Hs(this.entity.idMetadata.field)){const y=l.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 F(m=>m.isEqualTo(this.entity.idMetadata.field,y))}).then(m=>m[0])}else return Vr(this.entity,this,e,void 0,"insert");return this.buildResultRow(u,l.rows[0],l)})}}c(_i,"LogToConsole",!1);class Xs{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 Vr(n,e,t,r,i){const s=r!==void 0?n.idMetadata.getIdFilter(r):{};return e.find({where:new F(a=>{for(const o of n.idMetadata.fields)a.isEqualTo(o,t[o.key]??s[o.key])})}).then(a=>{if(a.length!=1)throw new Error(`Failed to ${i} row - result contained ${a.length} rows`);return a[0]})}class $e{constructor(e,t){c(this,"r");c(this,"nameProvider");c(this,"where","");c(this,"_addWhere",!0);c(this,"promises",[]);this.r=e,this.nameProvider=t}async resolveWhere(){for(;this.promises.length>0;){let e=this.promises;this.promises=[];for(const t of e)await t}return this.where}custom(e,t){throw new Error("Custom filter should be translated before it gets here")}or(e){let t="";this.promises.push((async()=>{for(const r of e){let i=new $e(this.r,this.nameProvider);i._addWhere=!1,r.__applyToConsumer(i);let s=await i.resolveWhere();if(!s)return;s.length>0&&(t.length>0&&(t+=" or "),e.length>1?t+="("+s+")":t+=s)}this.addToWhere("("+t+")")})())}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,"''")+"%')")})())}add(e,t,r){this.promises.push((async()=>{let i=this.nameProvider.$dbNameOf(e)+" "+r+" "+this.r.param(e.valueConverter.toDb(t));this.addToWhere(i)})())}addToWhere(e){this.where.length==0?this._addWhere&&(this.where+=" where "):this.where+=" and ",this.where+=e}databaseCustom(e){this.promises.push((async()=>{if(e!=null&&e.buildSql){let t=new Zs(this.r,this.nameProvider.wrapIdentifier),r=await e.buildSql(t);typeof r!="string"&&(r=t.sql),r&&this.addToWhere("("+r+")")}})())}}class Zs{constructor(e,t){c(this,"r");c(this,"wrapIdentifier");c(this,"sql","");c(this,"param",(e,t)=>(typeof t=="object"&&t.valueConverter.toDb&&(e=t.valueConverter.toDb(e)),this.r.param(e)));c(this,"filterToRaw",async(e,t)=>Ge.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 Hr(n,e){return n.dbReadOnly||n.isServerExpression||n.options.sqlExpression&&n.dbName!=e.$dbNameOf(n)}async function ki(n,e){let t=typeof e=="function"?{wrapIdentifier:e}:e||{};var r=Qs(n);t.wrapIdentifier||(t.wrapIdentifier=ke.dataProvider.wrapIdentifier),t.wrapIdentifier||(t.wrapIdentifier=s=>s);const i={$entityName:await Ii(r,t.wrapIdentifier),toString:()=>i.$entityName,$dbNameOf:s=>{var a;return typeof s=="string"?a=s:a=s.key,i[a]},wrapIdentifier:t.wrapIdentifier};for(const s of r.fields){let a=await yr(s,r,t.wrapIdentifier);s.options.sqlExpression||(typeof t.tableName=="string"?a=t.wrapIdentifier(t.tableName)+"."+a:t.tableName===!0&&(a=i.$entityName+"."+a)),i[s.key]=a}return i}async function Ii(n,e=t=>t){if(n.options.sqlExpression){if(typeof n.options.sqlExpression=="string")return n.options.sqlExpression;if(typeof n.options.sqlExpression=="function"){const t=n.options.sqlExpression;try{return n.options.sqlExpression="recursive sqlExpression call for entity '"+n.key+"'. ",await t(n)}finally{n.options.sqlExpression=t}}}return e(n.dbName)}async function yr(n,e,t=r=>r){try{if(n.options.sqlExpression){let s;if(typeof n.options.sqlExpression=="function"){const a=n.options.sqlExpression;try{n.options.sqlExpression="recursive sqlExpression call for field '"+n.key+"'. ",s=await a(e),n.options.sqlExpression=()=>s}finally{}}else s=n.options.sqlExpression;return s||n.dbName}const r=Y(n);let i=(r==null?void 0:r.type)==="toOne"&&n.options.field;if(i){let s=e.fields.find(i);if(s)return yr(s,e,t)}return t(n.dbName)}finally{}}var St=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Me={},Q={},se={};Object.defineProperty(se,"__esModule",{value:!0});se.output=se.exists=se.hash=se.bytes=se.bool=se.number=se.isBytes=void 0;function At(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`positive integer expected, not ${n}`)}se.number=At;function Oi(n){if(typeof n!="boolean")throw new Error(`boolean expected, not ${n}`)}se.bool=Oi;function Ci(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}se.isBytes=Ci;function mr(n,...e){if(!Ci(n))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(n.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${n.length}`)}se.bytes=mr;function Ei(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");At(n.outputLen),At(n.blockLen)}se.hash=Ei;function Ti(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}se.exists=Ti;function Si(n,e){mr(n);const t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}se.output=Si;const Ys={number:At,bool:Oi,bytes:mr,hash:Ei,exists:Ti,output:Si};se.default=Ys;var S={};Object.defineProperty(S,"__esModule",{value:!0});S.add5L=S.add5H=S.add4H=S.add4L=S.add3H=S.add3L=S.add=S.rotlBL=S.rotlBH=S.rotlSL=S.rotlSH=S.rotr32L=S.rotr32H=S.rotrBL=S.rotrBH=S.rotrSL=S.rotrSH=S.shrSL=S.shrSH=S.toBig=S.split=S.fromBig=void 0;const gt=BigInt(2**32-1),er=BigInt(32);function wr(n,e=!1){return e?{h:Number(n>),l:Number(n>>er>)}:{h:Number(n>>er>)|0,l:Number(n>)|0}}S.fromBig=wr;function Ai(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let i=0;i<n.length;i++){const{h:s,l:a}=wr(n[i],e);[t[i],r[i]]=[s,a]}return[t,r]}S.split=Ai;const Fi=(n,e)=>BigInt(n>>>0)<<er|BigInt(e>>>0);S.toBig=Fi;const Pi=(n,e,t)=>n>>>t;S.shrSH=Pi;const Di=(n,e,t)=>n<<32-t|e>>>t;S.shrSL=Di;const Mi=(n,e,t)=>n>>>t|e<<32-t;S.rotrSH=Mi;const Ri=(n,e,t)=>n<<32-t|e>>>t;S.rotrSL=Ri;const Ni=(n,e,t)=>n<<64-t|e>>>t-32;S.rotrBH=Ni;const Li=(n,e,t)=>n>>>t-32|e<<64-t;S.rotrBL=Li;const $i=(n,e)=>e;S.rotr32H=$i;const qi=(n,e)=>n;S.rotr32L=qi;const Bi=(n,e,t)=>n<<t|e>>>32-t;S.rotlSH=Bi;const Ji=(n,e,t)=>e<<t|n>>>32-t;S.rotlSL=Ji;const ji=(n,e,t)=>e<<t-32|n>>>64-t;S.rotlBH=ji;const Ui=(n,e,t)=>n<<t-32|e>>>64-t;S.rotlBL=Ui;function Vi(n,e,t,r){const i=(e>>>0)+(r>>>0);return{h:n+t+(i/2**32|0)|0,l:i|0}}S.add=Vi;const Hi=(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0);S.add3L=Hi;const Wi=(n,e,t,r)=>e+t+r+(n/2**32|0)|0;S.add3H=Wi;const xi=(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0);S.add4L=xi;const Qi=(n,e,t,r,i)=>e+t+r+i+(n/2**32|0)|0;S.add4H=Qi;const Gi=(n,e,t,r,i)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0);S.add5L=Gi;const zi=(n,e,t,r,i,s)=>e+t+r+i+s+(n/2**32|0)|0;S.add5H=zi;const ea={fromBig:wr,split:Ai,toBig:Fi,shrSH:Pi,shrSL:Di,rotrSH:Mi,rotrSL:Ri,rotrBH:Ni,rotrBL:Li,rotr32H:$i,rotr32L:qi,rotlSH:Bi,rotlSL:Ji,rotlBH:ji,rotlBL:Ui,add:Vi,add3L:Hi,add3H:Wi,add4L:xi,add4H:Qi,add5H:zi,add5L:Gi};S.default=ea;var Ki={},Nt={};Object.defineProperty(Nt,"__esModule",{value:!0});Nt.crypto=void 0;Nt.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;(function(n){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(n,"__esModule",{value:!0}),n.randomBytes=n.wrapXOFConstructorWithOpts=n.wrapConstructorWithOpts=n.wrapConstructor=n.checkOpts=n.Hash=n.concatBytes=n.toBytes=n.utf8ToBytes=n.asyncLoop=n.nextTick=n.hexToBytes=n.bytesToHex=n.byteSwap32=n.byteSwapIfBE=n.byteSwap=n.isLE=n.rotl=n.rotr=n.createView=n.u32=n.u8=n.isBytes=void 0;const e=Nt,t=se;function r(g){return g instanceof Uint8Array||g!=null&&typeof g=="object"&&g.constructor.name==="Uint8Array"}n.isBytes=r;const i=g=>new Uint8Array(g.buffer,g.byteOffset,g.byteLength);n.u8=i;const s=g=>new Uint32Array(g.buffer,g.byteOffset,Math.floor(g.byteLength/4));n.u32=s;const a=g=>new DataView(g.buffer,g.byteOffset,g.byteLength);n.createView=a;const o=(g,A)=>g<<32-A|g>>>A;n.rotr=o;const u=(g,A)=>g<<A|g>>>32-A>>>0;n.rotl=u,n.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const f=g=>g<<24&4278190080|g<<8&16711680|g>>>8&65280|g>>>24&255;n.byteSwap=f,n.byteSwapIfBE=n.isLE?g=>g:g=>(0,n.byteSwap)(g);function l(g){for(let A=0;A<g.length;A++)g[A]=(0,n.byteSwap)(g[A])}n.byteSwap32=l;const d=Array.from({length:256},(g,A)=>A.toString(16).padStart(2,"0"));function h(g){(0,t.bytes)(g);let A="";for(let K=0;K<g.length;K++)A+=d[g[K]];return A}n.bytesToHex=h;const y={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function m(g){if(g>=y._0&&g<=y._9)return g-y._0;if(g>=y._A&&g<=y._F)return g-(y._A-10);if(g>=y._a&&g<=y._f)return g-(y._a-10)}function b(g){if(typeof g!="string")throw new Error("hex string expected, got "+typeof g);const A=g.length,K=A/2;if(A%2)throw new Error("padded hex string expected, got unpadded hex of length "+A);const x=new Uint8Array(K);for(let re=0,oe=0;re<K;re++,oe+=2){const Xe=m(g.charCodeAt(oe)),Ze=m(g.charCodeAt(oe+1));if(Xe===void 0||Ze===void 0){const ct=g[oe]+g[oe+1];throw new Error('hex string expected, got non-hex character "'+ct+'" at index '+oe)}x[re]=Xe*16+Ze}return x}n.hexToBytes=b;const _=async()=>{};n.nextTick=_;async function I(g,A,K){let x=Date.now();for(let re=0;re<g;re++){K(re);const oe=Date.now()-x;oe>=0&&oe<A||(await(0,n.nextTick)(),x+=oe)}}n.asyncLoop=I;function P(g){if(typeof g!="string")throw new Error(`utf8ToBytes expected string, got ${typeof g}`);return new Uint8Array(new TextEncoder().encode(g))}n.utf8ToBytes=P;function z(g){return typeof g=="string"&&(g=P(g)),(0,t.bytes)(g),g}n.toBytes=z;function D(...g){let A=0;for(let x=0;x<g.length;x++){const re=g[x];(0,t.bytes)(re),A+=re.length}const K=new Uint8Array(A);for(let x=0,re=0;x<g.length;x++){const oe=g[x];K.set(oe,re),re+=oe.length}return K}n.concatBytes=D;class q{clone(){return this._cloneInto()}}n.Hash=q;const te={}.toString;function ce(g,A){if(A!==void 0&&te.call(A)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(g,A)}n.checkOpts=ce;function L(g){const A=x=>g().update(z(x)).digest(),K=g();return A.outputLen=K.outputLen,A.blockLen=K.blockLen,A.create=()=>g(),A}n.wrapConstructor=L;function W(g){const A=(x,re)=>g(re).update(z(x)).digest(),K=g({});return A.outputLen=K.outputLen,A.blockLen=K.blockLen,A.create=x=>g(x),A}n.wrapConstructorWithOpts=W;function Lt(g){const A=(x,re)=>g(re).update(z(x)).digest(),K=g({});return A.outputLen=K.outputLen,A.blockLen=K.blockLen,A.create=x=>g(x),A}n.wrapXOFConstructorWithOpts=Lt;function $t(g=32){if(e.crypto&&typeof e.crypto.getRandomValues=="function")return e.crypto.getRandomValues(new Uint8Array(g));throw new Error("crypto.getRandomValues must be defined")}n.randomBytes=$t})(Ki);Object.defineProperty(Q,"__esModule",{value:!0});Q.shake256=Q.shake128=Q.keccak_512=Q.keccak_384=Q.keccak_256=Q.keccak_224=Q.sha3_512=Q.sha3_384=Q.sha3_256=Q.sha3_224=Q.Keccak=Q.keccakP=void 0;const We=se,at=S,Ae=Ki,Xi=[],Zi=[],Yi=[],ta=BigInt(0),et=BigInt(1),ra=BigInt(2),ia=BigInt(7),na=BigInt(256),sa=BigInt(113);for(let n=0,e=et,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],Xi.push(2*(5*r+t)),Zi.push((n+1)*(n+2)/2%64);let i=ta;for(let s=0;s<7;s++)e=(e<<et^(e>>ia)*sa)%na,e&ra&&(i^=et<<(et<<BigInt(s))-et);Yi.push(i)}const[aa,oa]=(0,at.split)(Yi,!0),Wr=(n,e,t)=>t>32?(0,at.rotlBH)(n,e,t):(0,at.rotlSH)(n,e,t),xr=(n,e,t)=>t>32?(0,at.rotlBL)(n,e,t):(0,at.rotlSL)(n,e,t);function en(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let a=0;a<10;a++)t[a]=n[a]^n[a+10]^n[a+20]^n[a+30]^n[a+40];for(let a=0;a<10;a+=2){const o=(a+8)%10,u=(a+2)%10,f=t[u],l=t[u+1],d=Wr(f,l,1)^t[o],h=xr(f,l,1)^t[o+1];for(let y=0;y<50;y+=10)n[a+y]^=d,n[a+y+1]^=h}let i=n[2],s=n[3];for(let a=0;a<24;a++){const o=Zi[a],u=Wr(i,s,o),f=xr(i,s,o),l=Xi[a];i=n[l],s=n[l+1],n[l]=u,n[l+1]=f}for(let a=0;a<50;a+=10){for(let o=0;o<10;o++)t[o]=n[a+o];for(let o=0;o<10;o++)n[a+o]^=~t[(o+2)%10]&t[(o+4)%10]}n[0]^=aa[r],n[1]^=oa[r]}t.fill(0)}Q.keccakP=en;class dt extends Ae.Hash{constructor(e,t,r,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,We.number)(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,Ae.u32)(this.state)}keccak(){Ae.isLE||(0,Ae.byteSwap32)(this.state32),en(this.state32,this.rounds),Ae.isLE||(0,Ae.byteSwap32)(this.state32),this.posOut=0,this.pos=0}update(e){(0,We.exists)(this);const{blockLen:t,state:r}=this;e=(0,Ae.toBytes)(e);const i=e.length;for(let s=0;s<i;){const a=Math.min(t-this.pos,i-s);for(let o=0;o<a;o++)r[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:i}=this;e[r]^=t,t&128&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){(0,We.exists)(this,!1),(0,We.bytes)(e),this.finish();const t=this.state,{blockLen:r}=this;for(let i=0,s=e.length;i<s;){this.posOut>=r&&this.keccak();const a=Math.min(r-this.posOut,s-i);e.set(t.subarray(this.posOut,this.posOut+a),i),this.posOut+=a,i+=a}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return(0,We.number)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,We.output)(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:i,rounds:s,enableXOF:a}=this;return e||(e=new dt(t,r,i,a,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=r,e.outputLen=i,e.enableXOF=a,e.destroyed=this.destroyed,e}}Q.Keccak=dt;const Re=(n,e,t)=>(0,Ae.wrapConstructor)(()=>new dt(e,n,t));Q.sha3_224=Re(6,144,224/8);Q.sha3_256=Re(6,136,256/8);Q.sha3_384=Re(6,104,384/8);Q.sha3_512=Re(6,72,512/8);Q.keccak_224=Re(1,144,224/8);Q.keccak_256=Re(1,136,256/8);Q.keccak_384=Re(1,104,384/8);Q.keccak_512=Re(1,72,512/8);const tn=(n,e,t)=>(0,Ae.wrapXOFConstructorWithOpts)((r={})=>new dt(e,n,r.dkLen===void 0?t:r.dkLen,!0));Q.shake128=tn(31,168,128/8);Q.shake256=tn(31,136,256/8);const{sha3_512:la}=Q,rn=24,nt=32,tr=(n=4,e=Math.random)=>{let t="";for(;t.length<n;)t=t+Math.floor(e()*36).toString(36);return t};function nn(n){let e=8n,t=0n;for(const r of n.values()){const i=BigInt(r);t=(t<<e)+i}return t}const sn=(n="")=>nn(la(n)).toString(36).slice(1),Qr=Array.from({length:26},(n,e)=>String.fromCharCode(e+97)),ua=n=>Qr[Math.floor(n()*Qr.length)],an=({globalObj:n=typeof St<"u"?St:typeof window<"u"?window:{},random:e=Math.random}={})=>{const t=Object.keys(n).toString(),r=t.length?t+tr(nt,e):tr(nt,e);return sn(r).substring(0,nt)},on=n=>()=>n++,fa=476782367,ln=({random:n=Math.random,counter:e=on(Math.floor(n()*fa)),length:t=rn,fingerprint:r=an({random:n})}={})=>function(){const s=ua(n),a=Date.now().toString(36),o=e().toString(36),u=tr(t,n),f=`${a+u+o+r}`;return`${s+sn(f).substring(1,t)}`},da=ln(),ca=(n,{minLength:e=2,maxLength:t=nt}={})=>{const r=n.length,i=/^[0-9a-z]+$/;try{if(typeof n=="string"&&r>=e&&r<=t&&i.test(n))return!0}finally{}return!1};Me.getConstants=()=>({defaultLength:rn,bigLength:nt});Me.init=ln;Me.createId=da;Me.bufToBigInt=nn;Me.createCounter=on;Me.createFingerprint=an;Me.isCuid=ca;const{createId:ha,init:to,getConstants:ro,isCuid:io}=Me;var Gr=ha;const zr=_t(n=>!isNaN(n)&&isFinite(n));class gr{static object(...e){return we(void 0,...e)}static json(...e){let t=e;return t.valueConverter&&!t.valueConverter.fieldTypeInDb&&(t.valueConverter.fieldTypeInDb="json"),we(void 0,{valueConverter:{fieldTypeInDb:"json"}},...e)}static dateOnly(...e){return we(()=>Date,{valueConverter:fe.DateOnly},...e)}static date(...e){return we(()=>Date,...e)}static integer(...e){return we(()=>Number,{valueConverter:fe.Integer,validate:zr},...e)}static autoIncrement(...e){return we(()=>Number,{allowApiUpdate:!1,dbReadOnly:!0,valueConverter:{...fe.Integer,fieldTypeInDb:"autoincrement"}},...e)}static number(...e){return we(()=>Number,{validate:zr},...e)}static createdAt(...e){return we(()=>Date,{allowApiUpdate:!1,saving:(t,r,{isNew:i})=>{i&&(r.value=new Date)}},...e)}static updatedAt(...e){return we(()=>Date,{allowApiUpdate:!1,saving:(t,r)=>{r.value=new Date}},...e)}static uuid(...e){return we(()=>String,{allowApiUpdate:!1,defaultValue:()=>Kt(),saving:(t,r)=>{r.value||(r.value=Kt())}},...e)}static cuid(...e){return we(()=>String,{allowApiUpdate:!1,defaultValue:()=>Gr(),saving:(t,r)=>{r.value||(r.value=Gr())}},...e)}static literal(e,...t){return gr.string({validate:(r,i)=>Fe.in(e())(r,i),[xt]:e},...t)}static enum(e,...t){let r;return we(()=>e(),{validate:(i,s)=>Fe.enum(e())(i,s),[xt]:()=>kt(e())},...t,i=>{if(i[xt]=()=>kt(e()),r===void 0){let s=e();r=kt(s).find(o=>typeof o=="string")?fe.String:fe.Integer}i.valueConverter?i.valueConverter.fieldTypeInDb||(i.valueConverter.fieldTypeInDb=r.fieldTypeInDb):i.valueConverter=r})}static string(...e){return we(()=>String,...e)}static boolean(...e){return we(()=>Boolean,...e)}}function we(n,...e){return(t,r,i)=>{const s=typeof r=="string"?r:r.name.toString();let a=f=>{let l=vi(e,f);l.required&&(l.validate=It(l.validate,Fe.required,!0)),l.maxLength&&(l.validate=It(l.validate,Fe.maxLength(l.maxLength))),l.minLength&&(l.validate=It(l.validate,Fe.minLength(l.minLength))),!l.valueType&&n&&(l.valueType=n()),l.key||(l.key=s),l.dbName||(l.dbName=l.key);let d=l.valueType;return d||(d=typeof Reflect.getMetadata=="function"?Reflect.getMetadata("design:type",t,s):[],l.valueType=d),l.target||(l.target=t),l};un(t);let o=O.columnsOfType.get(t.constructor);o||(o=[],O.columnsOfType.set(t.constructor,o));let u=o.find(f=>f.key==s);if(!u)o.push({key:s,settings:a});else{let f=u.settings;u.settings=l=>{let d=f(l),h=a(l);return Object.assign(d,h)}}}}function un(n){if(!n)throw new Error("Set the 'experimentalDecorators:true' option in your 'tsconfig' or 'jsconfig' (target undefined)")}function pa(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var o=n.length-1;o>=0;o--)(a=n[o])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}function ya(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)}class ma extends bi{constructor(){super(...arguments);c(this,"id")}}pa([gr.uuid(),ya("design:type",String)],ma.prototype,"id",void 0);/*! *****************************************************************************
|
|
6
|
+
Copyright (C) Microsoft. All rights reserved.
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
8
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
9
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
12
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
13
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
14
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
15
|
+
|
|
16
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
17
|
+
and limitations under the License.
|
|
18
|
+
***************************************************************************** */var Kr;(function(n){(function(e){var t=typeof St=="object"?St:typeof self=="object"?self:typeof this=="object"?this:Function("return this;")(),r=i(n);typeof t.Reflect>"u"?t.Reflect=n:r=i(t.Reflect,r),e(r);function i(s,a){return function(o,u){typeof s[o]!="function"&&Object.defineProperty(s,o,{configurable:!0,writable:!0,value:u}),a&&a(o,u)}}})(function(e){var t=Object.prototype.hasOwnProperty,r=typeof Symbol=="function",i=r&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",s=r&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",a=typeof Object.create=="function",o={__proto__:[]}instanceof Array,u=!a&&!o,f={create:a?function(){return Bt(Object.create(null))}:o?function(){return Bt({__proto__:null})}:function(){return Bt({})},has:u?function(p,w){return t.call(p,w)}:function(p,w){return w in p},get:u?function(p,w){return t.call(p,w)?p[w]:void 0}:function(p,w){return p[w]}},l=Object.getPrototypeOf(Function),d=typeof process=="object"&&process.env&&process.env.REFLECT_METADATA_USE_MAP_POLYFILL==="true",h=!d&&typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:kn(),y=!d&&typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:In(),m=!d&&typeof WeakMap=="function"?WeakMap:On(),b=new m;function _(p,w,v,k){if(ie(v)){if(!br(p))throw new TypeError;if(!_r(w))throw new TypeError;return Lt(p,w)}else{if(!br(p))throw new TypeError;if(!le(w))throw new TypeError;if(!le(k)&&!ie(k)&&!Ue(k))throw new TypeError;return Ue(k)&&(k=void 0),v=Se(v),$t(p,w,v,k)}}e("decorate",_);function I(p,w){function v(k,E){if(!le(k))throw new TypeError;if(!ie(E)&&!wn(E))throw new TypeError;oe(p,w,k,E)}return v}e("metadata",I);function P(p,w,v,k){if(!le(v))throw new TypeError;return ie(k)||(k=Se(k)),oe(p,w,v,k)}e("defineMetadata",P);function z(p,w,v){if(!le(w))throw new TypeError;return ie(v)||(v=Se(v)),A(p,w,v)}e("hasMetadata",z);function D(p,w,v){if(!le(w))throw new TypeError;return ie(v)||(v=Se(v)),K(p,w,v)}e("hasOwnMetadata",D);function q(p,w,v){if(!le(w))throw new TypeError;return ie(v)||(v=Se(v)),x(p,w,v)}e("getMetadata",q);function te(p,w,v){if(!le(w))throw new TypeError;return ie(v)||(v=Se(v)),re(p,w,v)}e("getOwnMetadata",te);function ce(p,w){if(!le(p))throw new TypeError;return ie(w)||(w=Se(w)),Xe(p,w)}e("getMetadataKeys",ce);function L(p,w){if(!le(p))throw new TypeError;return ie(w)||(w=Se(w)),Ze(p,w)}e("getOwnMetadataKeys",L);function W(p,w,v){if(!le(w))throw new TypeError;ie(v)||(v=Se(v));var k=g(w,v,!1);if(ie(k)||!k.delete(p))return!1;if(k.size>0)return!0;var E=b.get(w);return E.delete(v),E.size>0||b.delete(w),!0}e("deleteMetadata",W);function Lt(p,w){for(var v=p.length-1;v>=0;--v){var k=p[v],E=k(w);if(!ie(E)&&!Ue(E)){if(!_r(E))throw new TypeError;w=E}}return w}function $t(p,w,v,k){for(var E=p.length-1;E>=0;--E){var me=p[E],M=me(w,v,k);if(!ie(M)&&!Ue(M)){if(!le(M))throw new TypeError;k=M}}return k}function g(p,w,v){var k=b.get(p);if(ie(k)){if(!v)return;k=new h,b.set(p,k)}var E=k.get(w);if(ie(E)){if(!v)return;E=new h,k.set(w,E)}return E}function A(p,w,v){var k=K(p,w,v);if(k)return!0;var E=qt(w);return Ue(E)?!1:A(p,E,v)}function K(p,w,v){var k=g(w,v,!1);return ie(k)?!1:yn(k.has(p))}function x(p,w,v){var k=K(p,w,v);if(k)return re(p,w,v);var E=qt(w);if(!Ue(E))return x(p,E,v)}function re(p,w,v){var k=g(w,v,!1);if(!ie(k))return k.get(p)}function oe(p,w,v,k){var E=g(v,k,!0);E.set(p,w)}function Xe(p,w){var v=Ze(p,w),k=qt(p);if(k===null)return v;var E=Xe(k,w);if(E.length<=0)return v;if(v.length<=0)return E;for(var me=new y,M=[],N=0,T=v;N<T.length;N++){var B=T[N],J=me.has(B);J||(me.add(B),M.push(B))}for(var Pe=0,Ir=E;Pe<Ir.length;Pe++){var B=Ir[Pe],J=me.has(B);J||(me.add(B),M.push(B))}return M}function Ze(p,w){var v=[],k=g(p,w,!1);if(ie(k))return v;for(var E=k.keys(),me=gn(E),M=0;;){var N=bn(me);if(!N)return v.length=M,v;var T=vn(N);try{v[M]=T}catch(B){try{_n(me)}finally{throw B}}M++}}function ct(p){if(p===null)return 1;switch(typeof p){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return p===null?1:6;default:return 6}}function ie(p){return p===void 0}function Ue(p){return p===null}function cn(p){return typeof p=="symbol"}function le(p){return typeof p=="object"?p!==null:typeof p=="function"}function hn(p,w){switch(ct(p)){case 0:return p;case 1:return p;case 2:return p;case 3:return p;case 4:return p;case 5:return p}var v="string",k=kr(p,i);if(k!==void 0){var E=k.call(p,v);if(le(E))throw new TypeError;return E}return pn(p)}function pn(p,w){var v,k;{var E=p.toString;if(ht(E)){var k=E.call(p);if(!le(k))return k}var v=p.valueOf;if(ht(v)){var k=v.call(p);if(!le(k))return k}}throw new TypeError}function yn(p){return!!p}function mn(p){return""+p}function Se(p){var w=hn(p);return cn(w)?w:mn(w)}function br(p){return Array.isArray?Array.isArray(p):p instanceof Object?p instanceof Array:Object.prototype.toString.call(p)==="[object Array]"}function ht(p){return typeof p=="function"}function _r(p){return typeof p=="function"}function wn(p){switch(ct(p)){case 3:return!0;case 4:return!0;default:return!1}}function kr(p,w){var v=p[w];if(v!=null){if(!ht(v))throw new TypeError;return v}}function gn(p){var w=kr(p,s);if(!ht(w))throw new TypeError;var v=w.call(p);if(!le(v))throw new TypeError;return v}function vn(p){return p.value}function bn(p){var w=p.next();return w.done?!1:w}function _n(p){var w=p.return;w&&w.call(p)}function qt(p){var w=Object.getPrototypeOf(p);if(typeof p!="function"||p===l||w!==l)return w;var v=p.prototype,k=v&&Object.getPrototypeOf(v);if(k==null||k===Object.prototype)return w;var E=k.constructor;return typeof E!="function"||E===p?w:E}function kn(){var p={},w=[],v=function(){function M(N,T,B){this._index=0,this._keys=N,this._values=T,this._selector=B}return M.prototype["@@iterator"]=function(){return this},M.prototype[s]=function(){return this},M.prototype.next=function(){var N=this._index;if(N>=0&&N<this._keys.length){var T=this._selector(this._keys[N],this._values[N]);return N+1>=this._keys.length?(this._index=-1,this._keys=w,this._values=w):this._index++,{value:T,done:!1}}return{value:void 0,done:!0}},M.prototype.throw=function(N){throw this._index>=0&&(this._index=-1,this._keys=w,this._values=w),N},M.prototype.return=function(N){return this._index>=0&&(this._index=-1,this._keys=w,this._values=w),{value:N,done:!0}},M}();return function(){function M(){this._keys=[],this._values=[],this._cacheKey=p,this._cacheIndex=-2}return Object.defineProperty(M.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),M.prototype.has=function(N){return this._find(N,!1)>=0},M.prototype.get=function(N){var T=this._find(N,!1);return T>=0?this._values[T]:void 0},M.prototype.set=function(N,T){var B=this._find(N,!0);return this._values[B]=T,this},M.prototype.delete=function(N){var T=this._find(N,!1);if(T>=0){for(var B=this._keys.length,J=T+1;J<B;J++)this._keys[J-1]=this._keys[J],this._values[J-1]=this._values[J];return this._keys.length--,this._values.length--,N===this._cacheKey&&(this._cacheKey=p,this._cacheIndex=-2),!0}return!1},M.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=p,this._cacheIndex=-2},M.prototype.keys=function(){return new v(this._keys,this._values,k)},M.prototype.values=function(){return new v(this._keys,this._values,E)},M.prototype.entries=function(){return new v(this._keys,this._values,me)},M.prototype["@@iterator"]=function(){return this.entries()},M.prototype[s]=function(){return this.entries()},M.prototype._find=function(N,T){return this._cacheKey!==N&&(this._cacheIndex=this._keys.indexOf(this._cacheKey=N)),this._cacheIndex<0&&T&&(this._cacheIndex=this._keys.length,this._keys.push(N),this._values.push(void 0)),this._cacheIndex},M}();function k(M,N){return M}function E(M,N){return N}function me(M,N){return[M,N]}}function In(){return function(){function p(){this._map=new h}return Object.defineProperty(p.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),p.prototype.has=function(w){return this._map.has(w)},p.prototype.add=function(w){return this._map.set(w,w),this},p.prototype.delete=function(w){return this._map.delete(w)},p.prototype.clear=function(){this._map.clear()},p.prototype.keys=function(){return this._map.keys()},p.prototype.values=function(){return this._map.values()},p.prototype.entries=function(){return this._map.entries()},p.prototype["@@iterator"]=function(){return this.keys()},p.prototype[s]=function(){return this.keys()},p}()}function On(){var p=16,w=f.create(),v=k();return function(){function T(){this._key=k()}return T.prototype.has=function(B){var J=E(B,!1);return J!==void 0?f.has(J,this._key):!1},T.prototype.get=function(B){var J=E(B,!1);return J!==void 0?f.get(J,this._key):void 0},T.prototype.set=function(B,J){var Pe=E(B,!0);return Pe[this._key]=J,this},T.prototype.delete=function(B){var J=E(B,!1);return J!==void 0?delete J[this._key]:!1},T.prototype.clear=function(){this._key=k()},T}();function k(){var T;do T="@@WeakMap@@"+N();while(f.has(w,T));return w[T]=!0,T}function E(T,B){if(!t.call(T,v)){if(!B)return;Object.defineProperty(T,v,{value:f.create()})}return T[v]}function me(T,B){for(var J=0;J<B;++J)T[J]=Math.random()*255|0;return T}function M(T){return typeof Uint8Array=="function"?typeof crypto<"u"?crypto.getRandomValues(new Uint8Array(T)):typeof msCrypto<"u"?msCrypto.getRandomValues(new Uint8Array(T)):me(new Uint8Array(T),T):me(new Array(T),T)}function N(){var T=M(p);T[6]=T[6]&79|64,T[8]=T[8]&191|128;for(var B="",J=0;J<p;++J){var Pe=T[J];(J===4||J===6||J===8)&&(B+="-"),Pe<16&&(B+="0"),B+=Pe.toString(16).toLowerCase()}return B}}function Bt(p){return p.__=void 0,delete p.__,p}})})(Kr||(Kr={}));const Ft=class Ft{constructor(e,t,r){c(this,"actionUrl");c(this,"queue");c(this,"allowed");c(this,"doWork");this.actionUrl=e,this.queue=t,this.allowed=r}async run(e,t,r){t===void 0&&(t=ke.apiClient.url),r||(r=ft(ke.apiClient.httpClient));let i=await r.post(t+"/"+this.actionUrl,e),s=i;if(s&&s.queuedJobId){let a=O.actionInfo.startBusyWithProgress();try{let o;if(await O.actionInfo.runActionWithoutBlockingUI(async()=>{for(;!o||!o.done;)o&&await new Promise(u=>setTimeout(()=>{u(void 0)},200)),o=await r.post(t+"/"+Ft.apiUrlForJobStatus,{queuedJobId:i.queuedJobId}),o.progress&&a.progress(o.progress)}),o.error)throw o.error;return a.progress(1),o.result}finally{a.close()}}else return i}__register(e){e(this.actionUrl,this.queue,this.allowed,async(t,r,i)=>{try{var s=await this.execute(t,r,i);i.success(s)}catch(a){a.isForbiddenError?i.forbidden():i.error(a,void 0)}})}};c(Ft,"apiUrlForJobStatus","jobStatusInQueue");let ot=Ft;class rr extends Error{constructor(t="Forbidden"){super(t);c(this,"isForbiddenError",!0)}}class wa extends ot{constructor(t,r,i,s){super(t,i.queue,i.allowed);c(this,"types");c(this,"options");c(this,"originalMethod");this.types=r,this.options=i,this.originalMethod=s}async execute(t,r,i){let s={data:{}},a=r.dataProvider;return await pi(r,async()=>{if(!r.isAllowedForInstance(void 0,this.options.allowed))throw new rr;t.args=await dn(this.types(),t.args,r,a,i);try{s.data=await this.originalMethod(t.args)}catch(o){throw o}}),s}}function Ee(n){return(e,t,r)=>{const i=typeof t=="string"?t:t.name.toString(),s=r?r.value:e;let a=s;un(e);function o(){var l=typeof Reflect.getMetadata=="function"?Reflect.getMetadata("design:paramtypes",e,i):[];return n.paramTypes&&(l=typeof n.paramTypes=="function"?n.paramTypes():n.paramTypes),l}if(e.prototype!==void 0){let l=new wa((n!=null&&n.apiPrefix?n.apiPrefix+"/":"")+i,()=>o(),n,d=>s.apply(void 0,d));return l.doWork=async(d,h,y,m)=>(d=Yr(o(),d),n.blockUser===!1?await O.actionInfo.runActionWithoutBlockingUI(async()=>(await l.run({args:d},y,m)).data):(await l.run({args:d},y,m)).data),a=async function(...d){return Zt()?await s.apply(this,d):await l.doWork(d,void 0)},Xr(e,a),a[Xt]=l,r?(r.value=a,r):a}let u=O.classHelpers.get(e.constructor);u||(u=new Ds,O.classHelpers.set(e.constructor,u));let f={__register(l){let d=new Oe;for(const h of u.classes.keys()){let y=u.classes.get(h);y.key||(y.key=d.repo(h).metadata.key),l(y.key+"/"+(n!=null&&n.apiPrefix?n.apiPrefix+"/":"")+i,n?n.queue:!1,n.allowed,async(m,b,_)=>{m.args=m.args.map(P=>fn(P)?void 0:P);let I=n.allowed;try{let P=b,z;await pi(P,async()=>{if(m.args=await dn(o(),m.args,P,P.dataProvider,_),O.allEntities.includes(h)){let D=P.repo(h),q;if(m.rowInfo.isNewRow)q=D.create(),await D.getEntityRef(q)._updateEntityBasedOnApi(m.rowInfo.data);else{let ce=await D.find({where:{...D.metadata.idMetadata.getIdFilter(m.rowInfo.id),$and:[D.metadata.options.apiPrefilter]}});if(ce.length!=1)throw new Error("not found or too many matches");q=ce[0],await D.getEntityRef(q)._updateEntityBasedOnApi(m.rowInfo.data)}if(!P.isAllowedForInstance(q,I))throw new rr;let te=X(q);await te.__validateEntity();try{z={result:await s.apply(q,m.args),rowInfo:{data:await te.toApiJson(),isNewRow:te.isNew(),wasChanged:te.wasChanged(),id:te.getOriginalId()}}}catch(ce){throw te.catchSaveErrors(ce)}}else{let D=new h(P,P.dataProvider),q=Ur(D,P);if(await q._updateEntityBasedOnApi(m.fields),!P.isAllowedForInstance(D,I))throw new rr;await q.__validateEntity();try{z={result:await s.apply(D,m.args),fields:await q.toApiJson()}}catch(te){throw q.catchSaveErrors(te)}}}),_.success(z)}catch(P){P.isForbiddenError?_.forbidden():_.error(P,void 0)}})}},doWork:async function(l,d,h,y){if(l=Yr(o(),l),O.allEntities.includes(e.constructor)){let m=X(d);await m.__validateEntity();let b=u.classes.get(d.constructor);b.key||(b.key=m.repository.metadata.key+"_methods");try{let _=await new class extends ot{constructor(){super(...arguments);c(this,"execute")}}(b.key+"/"+(n!=null&&n.apiPrefix?n.apiPrefix+"/":"")+i,n?n.queue:!1,n.allowed).run({args:l,rowInfo:{data:await m.toApiJson(),isNewRow:m.isNew(),wasChanged:m.wasChanged(),id:m.getOriginalId()}},h,y);return await m._updateEntityBasedOnApi(_.rowInfo.data,!0),_.result}catch(_){throw m.catchSaveErrors(_)}}else{let m=Ur(d,void 0);try{await m.__validateEntity();let b=await new class extends ot{constructor(){super(...arguments);c(this,"execute")}}(u.classes.get(d.constructor).key+"/"+(n!=null&&n.apiPrefix?n.apiPrefix+"/":"")+i,n?n.queue:!1,n.allowed).run({args:l,fields:await m.toApiJson()},h,y);return await m._updateEntityBasedOnApi(b.fields),b.result}catch(b){throw m.catchSaveErrors(b)}}}};return a=async function(...l){if(Zt())return await s.apply(this,l);{let d=this;return f.doWork(l,d)}},Xr(e.constructor,a),a[Xt]=f,r?(r.value=a,r):a}}const ga={_isUndefined:!0};function Xr(n,e){(n[ei]||(n[ei]=[])).push(e),O.actionInfo.allActions.push(e)}function fn(n){return n&&n._isUndefined}class Zr{constructor(e){c(this,"res");this.res=e}progress(e){this.res.progress(e)}}function Yr(n,e){if(n)for(let t=0;t<n.length;t++){const r=n[t];for(const i of[Oe,Ge])(e[t]instanceof i||r==i)&&(e[t]=void 0);if(e[t]!=null){let i={valueType:r};if(i=pr(i,new Oe),_e(r,!1)!=null){let a=X(e[t]);e[t]=a.getId()}i.valueConverter&&(e[t]=i.valueConverter.toJson(e[t]))}}return e.map(t=>t!==void 0?t:ga)}async function dn(n,e,t,r,i){for(let s=0;s<e.length;s++){const a=e[s];fn(a)&&(e[s]=void 0)}if(n)for(let s=0;s<n.length;s++)if(e.length<s&&e.push(void 0),n[s]==Oe||n[s]==Oe)e[s]=t;else if(n[s]==Ge&&r)e[s]=r;else if(n[s]==Zr)e[s]=new Zr(i);else{let a={valueType:n[s]};a=pr(a,t),a.valueConverter&&(e[s]=a.valueConverter.fromJson(e[s])),_e(n[s],!1)!=null&&(e[s]===null||e[s]===void 0||(e[s]=await t.repo(n[s]).findId(e[s])))}return e}const ei=Symbol.for("classBackendMethodsArray");O.actionInfo;var va=Object.defineProperty,ba=Object.getOwnPropertyDescriptor,Te=(n,e,t,r)=>{for(var i=ba(e,t),s=n.length-1,a;s>=0;s--)(a=n[s])&&(i=a(e,t,i)||i);return i&&va(e,t,i),i};class be{static async signOut(){}static async signInDemo(){}static async invite(){}static async signUpPassword(){}static async signInPassword(){}static async forgotPassword(){}static async resetPassword(){}static async signInOTP(){}static async verifyOtp(){}static async signInOAuthGetUrl(){}}Te([Ee({})],be,"signOut");Te([Ee({})],be,"signInDemo");Te([Ee({})],be,"invite");Te([Ee({})],be,"signUpPassword");Te([Ee({})],be,"signInPassword");Te([Ee({})],be,"forgotPassword");Te([Ee({})],be,"resetPassword");Te([Ee({})],be,"signInOTP");Te([Ee({})],be,"verifyOtp");Te([Ee({})],be,"signInOAuthGetUrl");function vr(n){n.focus()}function _a(n){let e,t,r,i,s,a,o,u,f,l,d=n[1].ui.providers.password.dico.send_password_reset_instructions+"",h,y,m;return{c(){e=$("div"),t=$("p"),r=ee(n[2]),i=ee(ka),s=H(),a=$("form"),o=$("input"),f=H(),l=$("button"),h=ee(d),j(t,"class","message"),De(t,"error",n[2]),j(o,"type","text"),j(o,"placeholder",u=n[1].ui.providers.password.dico.email_placeholder),j(a,"class","svelte-wa5ykb"),j(e,"class","login")},m(b,_){U(b,e,_),C(e,t),C(t,r),C(t,i),C(e,s),C(e,a),C(a,o),ge(o,n[0]),C(a,f),C(a,l),C(l,h),y||(m=[Pt(vr.call(null,o)),Ie(o,"input",n[4]),Ie(a,"submit",Dt(n[3]))],y=!0)},p(b,[_]){_&4&&de(r,b[2]),_&4&&De(t,"error",b[2]),_&2&&u!==(u=b[1].ui.providers.password.dico.email_placeholder)&&j(o,"placeholder",u),_&1&&o.value!==b[0]&&ge(o,b[0]),_&2&&d!==(d=b[1].ui.providers.password.dico.send_password_reset_instructions+"")&&de(h,d)},i:ne,o:ne,d(b){b&&V(e),y=!1,ze(m)}}}let ka="";function Ia(n,e,t){let{firstlyDataAuth:r}=e,{email:i=""}=e,s="";async function a(){try{await be.forgotPassword(i),window.location.href="/kit/auth/sign-in"}catch(u){u&&t(2,s=u.message??"")}}function o(){i=this.value,t(0,i)}return n.$$set=u=>{"firstlyDataAuth"in u&&t(1,r=u.firstlyDataAuth),"email"in u&&t(0,i=u.email)},[i,r,s,a,o]}class Oa extends Je{constructor(e){super(),je(this,e,Ia,_a,Ke,{firstlyDataAuth:1,email:0})}}function Ca(n){let e,t,r,i,s,a,o=n[2].ui.providers.password.dico.password+"",u,f,l,d,h=n[2].ui.providers.password.dico.password+"",y,m,b,_,I,P,z;return{c(){e=$("div"),t=$("p"),r=ee(n[3]),i=ee(n[4]),s=H(),a=$("form"),u=ee(o),f=H(),l=$("input"),d=H(),y=ee(h),m=H(),b=$("input"),_=H(),I=$("button"),I.textContent="reset",j(t,"class","message"),De(t,"error",n[3]),j(l,"type","password"),j(b,"type","password"),j(a,"class","svelte-wa5ykb"),j(e,"class","login")},m(D,q){U(D,e,q),C(e,t),C(t,r),C(t,i),C(e,s),C(e,a),C(a,u),C(a,f),C(a,l),ge(l,n[0]),C(a,d),C(a,y),C(a,m),C(a,b),ge(b,n[1]),C(a,_),C(a,I),P||(z=[Ie(l,"input",n[6]),Ie(b,"input",n[7]),Ie(a,"submit",Dt(n[5]))],P=!0)},p(D,[q]){q&8&&de(r,D[3]),q&16&&de(i,D[4]),q&8&&De(t,"error",D[3]),q&4&&o!==(o=D[2].ui.providers.password.dico.password+"")&&de(u,o),q&1&&l.value!==D[0]&&ge(l,D[0]),q&4&&h!==(h=D[2].ui.providers.password.dico.password+"")&&de(y,h),q&2&&b.value!==D[1]&&ge(b,D[1])},i:ne,o:ne,d(D){D&&V(e),P=!1,ze(z)}}}function Ea(n,e,t){let{firstlyDataAuth:r}=e,{password1:i=""}=e,{password2:s=""}=e,a="",o="";async function u(){t(3,a=""),t(4,o="");const d=new URL(location.href).searchParams.get("token");try{await be.resetPassword(d??"",i),window.location.href="/"}catch(h){h&&t(3,a=h.message??"")}}function f(){i=this.value,t(0,i)}function l(){s=this.value,t(1,s)}return n.$$set=d=>{"firstlyDataAuth"in d&&t(2,r=d.firstlyDataAuth),"password1"in d&&t(0,i=d.password1),"password2"in d&&t(1,s=d.password2)},[i,s,r,a,o,u,f,l]}class Ta extends Je{constructor(e){super(),je(this,e,Ea,Ca,Ke,{firstlyDataAuth:2,password1:0,password2:1})}}function ti(n){let e,t,r,i,s,a,o=n[1].ui.providers.password.dico.email+"",u,f,l,d,h,y,m=n[1].ui.providers.password.dico.password+"",b,_,I,P,z,D=n[1].ui.providers.password.dico.btn_sign_in+"",q,te,ce;return{c(){e=$("form"),t=$("p"),r=ee(n[3]),i=ee(n[4]),s=H(),a=$("label"),u=ee(o),f=H(),l=$("input"),h=H(),y=$("label"),b=ee(m),_=H(),I=$("input"),P=H(),z=$("button"),q=ee(D),j(t,"class","message svelte-1rtdg09"),De(t,"error",n[3]),j(l,"type","text"),j(l,"placeholder",d=n[1].ui.providers.password.dico.email_placeholder),j(I,"type","password"),j(e,"class","svelte-1rtdg09")},m(L,W){U(L,e,W),C(e,t),C(t,r),C(t,i),C(e,s),C(e,a),C(a,u),C(a,f),C(a,l),ge(l,n[0]),C(e,h),C(e,y),C(y,b),C(y,_),C(y,I),ge(I,n[5]),C(e,P),C(e,z),C(z,q),te||(ce=[Ie(l,"input",n[7]),Pt(vr.call(null,l)),Ie(I,"input",n[8]),Ie(e,"submit",Dt(n[6]))],te=!0)},p(L,W){W&8&&de(r,L[3]),W&16&&de(i,L[4]),W&8&&De(t,"error",L[3]),W&2&&o!==(o=L[1].ui.providers.password.dico.email+"")&&de(u,o),W&2&&d!==(d=L[1].ui.providers.password.dico.email_placeholder)&&j(l,"placeholder",d),W&1&&l.value!==L[0]&&ge(l,L[0]),W&2&&m!==(m=L[1].ui.providers.password.dico.password+"")&&de(b,m),W&32&&I.value!==L[5]&&ge(I,L[5]),W&2&&D!==(D=L[1].ui.providers.password.dico.btn_sign_in+"")&&de(q,D)},d(L){L&&V(e),te=!1,ze(ce)}}}function Sa(n){let e,t=n[2]=="login"&&ti(n);return{c(){t&&t.c(),e=ir()},m(r,i){t&&t.m(r,i),U(r,e,i)},p(r,[i]){r[2]=="login"?t?t.p(r,i):(t=ti(r),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},i:ne,o:ne,d(r){r&&V(e),t&&t.d(r)}}}function Aa(n,e,t){let{firstlyDataAuth:r}=e,{view:i="login"}=e,{email:s=""}=e,a="",o="",u;async function f(){t(3,a=""),t(4,o="");try{await be.signInPassword(s,u),window.location.href="/"}catch(h){h&&t(3,a=h.message??"")}}function l(){s=this.value,t(0,s)}function d(){u=this.value,t(5,u)}return n.$$set=h=>{"firstlyDataAuth"in h&&t(1,r=h.firstlyDataAuth),"view"in h&&t(2,i=h.view),"email"in h&&t(0,s=h.email)},[s,r,i,a,o,u,f,l,d]}class Fa extends Je{constructor(e){super(),je(this,e,Aa,Sa,Ke,{firstlyDataAuth:1,view:2,email:0})}}function ri(n){let e,t,r,i,s,a,o=n[1].ui.providers.password.dico.email+"",u,f,l,d,h,y,m=n[1].ui.providers.password.dico.password+"",b,_,I,P,z,D=n[1].ui.providers.password.dico.btn_sign_up+"",q,te,ce;return{c(){e=$("form"),t=$("p"),r=ee(n[3]),i=ee(n[4]),s=H(),a=$("label"),u=ee(o),f=H(),l=$("input"),h=H(),y=$("label"),b=ee(m),_=H(),I=$("input"),P=H(),z=$("button"),q=ee(D),j(t,"class","message svelte-1rtdg09"),De(t,"error",n[3]),j(l,"type","text"),j(l,"placeholder",d=n[1].ui.providers.password.dico.email_placeholder),j(I,"type","password"),j(e,"class","svelte-1rtdg09")},m(L,W){U(L,e,W),C(e,t),C(t,r),C(t,i),C(e,s),C(e,a),C(a,u),C(a,f),C(a,l),ge(l,n[0]),C(e,h),C(e,y),C(y,b),C(y,_),C(y,I),ge(I,n[5]),C(e,P),C(e,z),C(z,q),te||(ce=[Ie(l,"input",n[7]),Pt(vr.call(null,l)),Ie(I,"input",n[8]),Ie(e,"submit",Dt(n[6]))],te=!0)},p(L,W){W&8&&de(r,L[3]),W&16&&de(i,L[4]),W&8&&De(t,"error",L[3]),W&2&&o!==(o=L[1].ui.providers.password.dico.email+"")&&de(u,o),W&2&&d!==(d=L[1].ui.providers.password.dico.email_placeholder)&&j(l,"placeholder",d),W&1&&l.value!==L[0]&&ge(l,L[0]),W&2&&m!==(m=L[1].ui.providers.password.dico.password+"")&&de(b,m),W&32&&I.value!==L[5]&&ge(I,L[5]),W&2&&D!==(D=L[1].ui.providers.password.dico.btn_sign_up+"")&&de(q,D)},d(L){L&&V(e),te=!1,ze(ce)}}}function Pa(n){let e,t=n[2]=="login"&&ri(n);return{c(){t&&t.c(),e=ir()},m(r,i){t&&t.m(r,i),U(r,e,i)},p(r,[i]){r[2]=="login"?t?t.p(r,i):(t=ri(r),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},i:ne,o:ne,d(r){r&&V(e),t&&t.d(r)}}}function Da(n,e,t){let{firstlyDataAuth:r}=e,{view:i="login"}=e,{email:s=""}=e,a="",o="",u;async function f(){t(3,a=""),t(4,o="");try{await be.signUpPassword(s,u),window.location.href="/"}catch(h){h&&t(3,a=h.message??"")}}function l(){s=this.value,t(0,s)}function d(){u=this.value,t(5,u)}return n.$$set=h=>{"firstlyDataAuth"in h&&t(1,r=h.firstlyDataAuth),"view"in h&&t(2,i=h.view),"email"in h&&t(0,s=h.email)},[s,r,i,a,o,u,f,l,d]}class Ma extends Je{constructor(e){super(),je(this,e,Da,Pa,Ke,{firstlyDataAuth:1,view:2,email:0})}}function Ra(n){let e,t;return e=new xe({props:{path:n[1].ui.providers.password.paths.sign_up,$$slots:{default:[$a]},$$scope:{ctx:n}}}),{c(){he(e.$$.fragment)},m(r,i){pe(e,r,i),t=!0},p(r,i){const s={};i&65&&(s.$$scope={dirty:i,ctx:r}),e.$set(s)},i(r){t||(G(e.$$.fragment,r),t=!0)},o(r){Z(e.$$.fragment,r),t=!1},d(r){ye(e,r)}}}function Na(n){let e,t;return e=new ut({props:{href:n[1].ui.providers.password.paths.sign_in,$$slots:{default:[La]},$$scope:{ctx:n}}}),{c(){he(e.$$.fragment)},m(r,i){pe(e,r,i),t=!0},p(r,i){const s={};i&64&&(s.$$scope={dirty:i,ctx:r}),e.$set(s)},i(r){t||(G(e.$$.fragment,r),t=!0)},o(r){Z(e.$$.fragment,r),t=!1},d(r){ye(e,r)}}}function La(n){let e=n[1].ui.providers.password.dico.back_to_sign_in+"",t;return{c(){t=ee(e)},m(r,i){U(r,t,i)},p:ne,d(r){r&&V(t)}}}function $a(n){let e,t,r,i,s;function a(f){n[3](f)}let o={firstlyDataAuth:n[1]};n[0]!==void 0&&(o.email=n[0]),e=new Ma({props:o}),nr.push(()=>sr(e,"email",a));let u=n[1].ui.providers.password.paths.sign_in&&Na(n);return{c(){he(e.$$.fragment),r=H(),i=$("div"),u&&u.c(),j(i,"class","form-footer svelte-15iffyp")},m(f,l){pe(e,f,l),U(f,r,l),U(f,i,l),u&&u.m(i,null),s=!0},p(f,l){const d={};!t&&l&1&&(t=!0,d.email=f[0],ar(()=>t=!1)),e.$set(d),f[1].ui.providers.password.paths.sign_in&&u.p(f,l)},i(f){s||(G(e.$$.fragment,f),G(u),s=!0)},o(f){Z(e.$$.fragment,f),Z(u),s=!1},d(f){f&&(V(r),V(i)),ye(e,f),u&&u.d()}}}function qa(n){let e,t;return e=new ut({props:{href:n[1].ui.providers.password.paths.forgot_password,$$slots:{default:[Ba]},$$scope:{ctx:n}}}),{c(){he(e.$$.fragment)},m(r,i){pe(e,r,i),t=!0},p(r,i){const s={};i&64&&(s.$$scope={dirty:i,ctx:r}),e.$set(s)},i(r){t||(G(e.$$.fragment,r),t=!0)},o(r){Z(e.$$.fragment,r),t=!1},d(r){ye(e,r)}}}function Ba(n){let e=n[1].ui.providers.password.dico.forgot_password+"",t;return{c(){t=ee(e)},m(r,i){U(r,t,i)},p:ne,d(r){r&&V(t)}}}function Ja(n){let e,t;return e=new ut({props:{href:n[1].ui.providers.password.paths.sign_up,$$slots:{default:[ja]},$$scope:{ctx:n}}}),{c(){he(e.$$.fragment)},m(r,i){pe(e,r,i),t=!0},p(r,i){const s={};i&64&&(s.$$scope={dirty:i,ctx:r}),e.$set(s)},i(r){t||(G(e.$$.fragment,r),t=!0)},o(r){Z(e.$$.fragment,r),t=!1},d(r){ye(e,r)}}}function ja(n){let e=n[1].ui.providers.password.dico.btn_sign_up+"",t;return{c(){t=ee(e)},m(r,i){U(r,t,i)},p:ne,d(r){r&&V(t)}}}function Ua(n){let e,t,r,i,s,a,o,u;function f(y){n[4](y)}let l={firstlyDataAuth:n[1]};n[0]!==void 0&&(l.email=n[0]),e=new Fa({props:l}),nr.push(()=>sr(e,"email",f));let d=n[1].ui.providers.password.paths.forgot_password&&qa(n),h=n[1].ui.providers.password.paths.sign_up&&Ja(n);return{c(){he(e.$$.fragment),r=H(),i=$("div"),d&&d.c(),s=H(),a=$("hr"),o=H(),h&&h.c(),j(i,"class","form-footer svelte-15iffyp")},m(y,m){pe(e,y,m),U(y,r,m),U(y,i,m),d&&d.m(i,null),C(i,s),C(i,a),C(i,o),h&&h.m(i,null),u=!0},p(y,m){const b={};!t&&m&1&&(t=!0,b.email=y[0],ar(()=>t=!1)),e.$set(b),y[1].ui.providers.password.paths.forgot_password&&d.p(y,m),y[1].ui.providers.password.paths.sign_up&&h.p(y,m)},i(y){u||(G(e.$$.fragment,y),G(d),G(h),u=!0)},o(y){Z(e.$$.fragment,y),Z(d),Z(h),u=!1},d(y){y&&(V(r),V(i)),ye(e,y),d&&d.d(),h&&h.d()}}}function Va(n){let e,t;return e=new ut({props:{href:n[1].ui.providers.password.paths.sign_in,$$slots:{default:[Ha]},$$scope:{ctx:n}}}),{c(){he(e.$$.fragment)},m(r,i){pe(e,r,i),t=!0},p(r,i){const s={};i&64&&(s.$$scope={dirty:i,ctx:r}),e.$set(s)},i(r){t||(G(e.$$.fragment,r),t=!0)},o(r){Z(e.$$.fragment,r),t=!1},d(r){ye(e,r)}}}function Ha(n){let e=n[1].ui.providers.password.dico.back_to_sign_in+"",t;return{c(){t=ee(e)},m(r,i){U(r,t,i)},p:ne,d(r){r&&V(t)}}}function Wa(n){let e,t,r,i,s;function a(f){n[5](f)}let o={firstlyDataAuth:n[1]};n[0]!==void 0&&(o.email=n[0]),e=new Oa({props:o}),nr.push(()=>sr(e,"email",a));let u=n[1].ui.providers.password.paths.sign_in&&Va(n);return{c(){he(e.$$.fragment),r=H(),i=$("div"),u&&u.c(),j(i,"class","form-footer svelte-15iffyp")},m(f,l){pe(e,f,l),U(f,r,l),U(f,i,l),u&&u.m(i,null),s=!0},p(f,l){const d={};!t&&l&1&&(t=!0,d.email=f[0],ar(()=>t=!1)),e.$set(d),f[1].ui.providers.password.paths.sign_in&&u.p(f,l)},i(f){s||(G(e.$$.fragment,f),G(u),s=!0)},o(f){Z(e.$$.fragment,f),Z(u),s=!1},d(f){f&&(V(r),V(i)),ye(e,f),u&&u.d()}}}function xa(n){let e,t;return e=new ut({props:{href:n[1].ui.providers.password.paths.sign_in,$$slots:{default:[Qa]},$$scope:{ctx:n}}}),{c(){he(e.$$.fragment)},m(r,i){pe(e,r,i),t=!0},p(r,i){const s={};i&64&&(s.$$scope={dirty:i,ctx:r}),e.$set(s)},i(r){t||(G(e.$$.fragment,r),t=!0)},o(r){Z(e.$$.fragment,r),t=!1},d(r){ye(e,r)}}}function Qa(n){let e=n[1].ui.providers.password.dico.back_to_sign_in+"",t;return{c(){t=ee(e)},m(r,i){U(r,t,i)},p:ne,d(r){r&&V(t)}}}function Ga(n){let e,t,r,i;e=new Ta({props:{firstlyDataAuth:n[1]}});let s=n[1].ui.providers.password.paths.sign_in&&xa(n);return{c(){he(e.$$.fragment),t=H(),r=$("div"),s&&s.c(),j(r,"class","form-footer svelte-15iffyp")},m(a,o){pe(e,a,o),U(a,t,o),U(a,r,o),s&&s.m(r,null),i=!0},p(a,o){a[1].ui.providers.password.paths.sign_in&&s.p(a,o)},i(a){i||(G(e.$$.fragment,a),G(s),i=!0)},o(a){Z(e.$$.fragment,a),Z(s),i=!1},d(a){a&&(V(t),V(r)),ye(e,a),s&&s.d()}}}function za(n){let e,t,r;return{c(){e=$("div"),e.innerHTML="<small>- 404 -</small>",t=H(),r=$("div"),r.innerHTML="<small>Nothing to see here</small>",j(e,"class","fallback svelte-15iffyp"),j(r,"class","fallback svelte-15iffyp")},m(i,s){U(i,e,s),U(i,t,s),U(i,r,s)},p:ne,d(i){i&&(V(e),V(t),V(r))}}}function Ka(n){let e,t,r,i,s,a,o,u,f,l=n[1].ui.providers.password.paths.sign_up&&Ra(n);return t=new xe({props:{path:n[1].ui.providers.password.paths.sign_in,$$slots:{default:[Ua]},$$scope:{ctx:n}}}),i=new xe({props:{path:n[1].ui.providers.password.paths.forgot_password,$$slots:{default:[Wa]},$$scope:{ctx:n}}}),a=new xe({props:{path:n[1].ui.providers.password.paths.reset_password,$$slots:{default:[Ga]},$$scope:{ctx:n}}}),u=new xe({props:{fallback:!0,$$slots:{default:[za]},$$scope:{ctx:n}}}),{c(){l&&l.c(),e=H(),he(t.$$.fragment),r=H(),he(i.$$.fragment),s=H(),he(a.$$.fragment),o=H(),he(u.$$.fragment)},m(d,h){l&&l.m(d,h),U(d,e,h),pe(t,d,h),U(d,r,h),pe(i,d,h),U(d,s,h),pe(a,d,h),U(d,o,h),pe(u,d,h),f=!0},p(d,h){d[1].ui.providers.password.paths.sign_up&&l.p(d,h);const y={};h&65&&(y.$$scope={dirty:h,ctx:d}),t.$set(y);const m={};h&65&&(m.$$scope={dirty:h,ctx:d}),i.$set(m);const b={};h&64&&(b.$$scope={dirty:h,ctx:d}),a.$set(b);const _={};h&64&&(_.$$scope={dirty:h,ctx:d}),u.$set(_)},i(d){f||(G(l),G(t.$$.fragment,d),G(i.$$.fragment,d),G(a.$$.fragment,d),G(u.$$.fragment,d),f=!0)},o(d){Z(l),Z(t.$$.fragment,d),Z(i.$$.fragment,d),Z(a.$$.fragment,d),Z(u.$$.fragment,d),f=!1},d(d){d&&(V(e),V(r),V(s),V(o)),l&&l.d(d),ye(t,d),ye(i,d),ye(a,d),ye(u,d)}}}function Xa(n){let e,t,r,i;return r=new xe({props:{$$slots:{default:[Ka]},$$scope:{ctx:n}}}),{c(){e=$("div"),t=$("div"),he(r.$$.fragment),j(t,"class","form svelte-15iffyp"),j(e,"class","wrapper svelte-15iffyp")},m(s,a){U(s,e,a),C(e,t),pe(r,t,null),i=!0},p(s,[a]){const o={};a&65&&(o.$$scope={dirty:a,ctx:s}),r.$set(o)},i(s){i||(G(r.$$.fragment,s),i=!0)},o(s){Z(r.$$.fragment,s),i=!1},d(s){s&&V(e),ye(r)}}}function Za(n,e,t){let{firstlyData:r}=e,i=r.props,s="";function a(f){s=f,t(0,s)}function o(f){s=f,t(0,s)}function u(f){s=f,t(0,s)}return n.$$set=f=>{"firstlyData"in f&&t(2,r=f.firstlyData)},[s,i,r,a,o,u]}class no extends Je{constructor(e){super(),je(this,e,Za,Xa,Ke,{firstlyData:2})}}export{no as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as o,b as r,a as l,H as i,d as c,n as a,k as f}from"./index-CKmKKRRL.js";function u(s){let t;return{c(){t=i("Hello from files")},m(e,n){c(e,t,n)},p:a,i:a,o:a,d(e){e&&f(t)}}}class p extends o{constructor(t){super(),r(this,t,null,u,l,{})}}export{p as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as o,b as r,a as i,H as l,d as c,n as a,k as f}from"./index-CKmKKRRL.js";function m(s){let t;return{c(){t=l("Hello from admin")},m(e,n){c(e,t,n)},p:a,i:a,o:a,d(e){e&&f(t)}}}class d extends o{constructor(t){super(),r(this,t,null,m,i,{})}}export{d as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
form.svelte-wa5ykb,form.svelte-1rtdg09{display:flex;flex-direction:column}form.svelte-1rtdg09{display:flex;flex-direction:column}.message.svelte-1rtdg09:empty{display:none}.message.svelte-1rtdg09{background:var(--pico-muted-border-color);padding:var(--pico-form-element-spacing-vertical) var(--pico-form-element-spacing-horizontal);border-radius:var(--pico-border-radius);margin-bottom:calc(var(--pico-typography-spacing-vertical) * 2)}.message.error.svelte-1rtdg09{background:var(--pico-del-color);color:#4c1513}.wrapper.svelte-15iffyp{min-height:100vh;display:flex;justify-content:center;align-items:center;margin:0 auto}.form.svelte-15iffyp{padding:1rem;max-width:360px;width:100%}.form-footer.svelte-15iffyp{margin-top:1rem;display:flex;flex-direction:column;justify-content:center;align-items:center}.fallback.svelte-15iffyp{display:flex;justify-content:center;align-items:center}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
declare function C(t: any): any;
|
|
2
|
+
declare function Ht(t: any, e: any): void;
|
|
3
|
+
declare function Ft(t: any): any;
|
|
4
|
+
declare function ht(t: any, e: any, n: any, r: any): () => any;
|
|
5
|
+
declare function Vt(t: any, e: any): {};
|
|
6
|
+
declare function Ut(t: any): {};
|
|
7
|
+
declare function ee(t: any, e: any): void;
|
|
8
|
+
declare function X(t: any): Text;
|
|
9
|
+
declare function at(): Text;
|
|
10
|
+
declare function I(t: any, e: any, n: any): void;
|
|
11
|
+
declare function Wt(t: any, e: any, n: any): void;
|
|
12
|
+
declare function Kt(t: any, e: any): void;
|
|
13
|
+
declare function Qt(t: any, e: any): void;
|
|
14
|
+
declare function Gt(t: any): (e: any) => any;
|
|
15
|
+
declare function Jt(t: any, e: any): void;
|
|
16
|
+
declare function kt(t: any): void;
|
|
17
|
+
declare function tt(t: any, e: any, n: any): void;
|
|
18
|
+
declare function et(t: any, e: any): void;
|
|
19
|
+
declare class xt {
|
|
20
|
+
$destroy(): void;
|
|
21
|
+
$on(e: any, n: any): typeof d;
|
|
22
|
+
$set(e: any): void;
|
|
23
|
+
}
|
|
24
|
+
declare const U: any[];
|
|
25
|
+
declare function re(t: any, e: any, n: any): void;
|
|
26
|
+
declare function ne(t: any): void;
|
|
27
|
+
declare function lt(t: any, e: any): any;
|
|
28
|
+
declare function Et(t: any, e: any, n: any, r: any, s: any, o: any, c?: null, i?: number[]): void;
|
|
29
|
+
declare function Nt(t: any, e: any): boolean;
|
|
30
|
+
declare function k(t: any, e: any, n: any): void;
|
|
31
|
+
declare function dt(): Text;
|
|
32
|
+
declare function Y(): void;
|
|
33
|
+
declare function It(t: any): undefined;
|
|
34
|
+
declare function E(t: any, e: any, n: any, r: any): void;
|
|
35
|
+
declare function N(t: any): boolean;
|
|
36
|
+
declare function Z(): void;
|
|
37
|
+
declare function y(t: any): void;
|
|
38
|
+
declare function Rt(t: any, e: any, n: any): void;
|
|
39
|
+
declare function te(t: any): any;
|
|
40
|
+
declare function d(): void;
|
|
41
|
+
declare function Zt(t: any): any;
|
|
42
|
+
declare function Xt(t: any): void;
|
|
43
|
+
declare function Yt(t: any, e: any): any;
|
|
44
|
+
declare function x(t: any): void;
|
|
45
|
+
declare function Q(t: any, ...e: any[]): any;
|
|
46
|
+
declare function m(t: any, e: any): void;
|
|
47
|
+
declare function Mt(t: any, e: any, n: any): any;
|
|
48
|
+
declare function Tt(t: any, e: any, n: any, r: any): any;
|
|
49
|
+
declare function qt(t: any, e: any, n: any, r: any, s: any, o: any): void;
|
|
50
|
+
declare function Bt(t: any): -1 | number[];
|
|
51
|
+
declare function zt(t: any, e: any, n: any, r: any): any;
|
|
52
|
+
declare function ct(t: any, e: any): any;
|
|
53
|
+
export { C as A, Ht as B, Ft as C, ht as D, Vt as E, Ut as F, ee as G, X as H, at as I, I as J, Wt as K, Kt as L, Qt as M, Gt as N, Jt as O, kt as P, tt as Q, et as R, xt as S, U as T, re as U, ne as V, lt as a, Et as b, Nt as c, k as d, dt as e, Y as f, It as g, E as h, N as i, Z as j, y as k, Rt as l, te as m, d as n, Zt as o, Xt as p, Yt as q, x as r, Q as s, m as t, Mt as u, Tt as v, qt as w, Bt as x, zt as y, ct as z };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__fileDeps=["assets/Page-BMFREPjF.js","assets/Page-gV58jf2r.css"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
|
|
2
|
+
var nt=Object.defineProperty;var rt=(t,e,n)=>e in t?nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var L=(t,e,n)=>(rt(t,typeof e!="symbol"?e+"":e,n),n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const ot="modulepreload",st=function(t){return"/api/static/"+t},q={},P=function(e,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),c=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));s=Promise.all(n.map(i=>{if(i=st(i),i in q)return;q[i]=!0;const u=i.endsWith(".css"),l=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${i}"]${l}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":ot,u||(f.as="script",f.crossOrigin=""),f.href=i,c&&f.setAttribute("nonce",c),document.head.appendChild(f),u)return new Promise((a,_)=>{f.addEventListener("load",a),f.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${i}`)))})}))}return s.then(()=>e()).catch(o=>{const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=o,window.dispatchEvent(c),!c.defaultPrevented)throw o})};function d(){}function ct(t,e){for(const n in e)t[n]=e[n];return t}function ut(t){return!!t&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function J(t){return t()}function B(){return Object.create(null)}function x(t){t.forEach(J)}function N(t){return typeof t=="function"}function lt(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function Nt(t,e){return t!=t?e==e:t!==e}function it(t){return Object.keys(t).length===0}function Q(t,...e){if(t==null){for(const r of e)r(void 0);return d}const n=t.subscribe(...e);return n.unsubscribe?()=>n.unsubscribe():n}function It(t){let e;return Q(t,n=>e=n)(),e}function Rt(t,e,n){t.$$.on_destroy.push(Q(e,n))}function Tt(t,e,n,r){if(t){const s=W(t,e,n,r);return t[0](s)}}function W(t,e,n,r){return t[1]&&r?ct(n.ctx.slice(),t[1](r(e))):n.ctx}function zt(t,e,n,r){if(t[2]&&r){const s=t[2](r(n));if(e.dirty===void 0)return s;if(typeof s=="object"){const o=[],c=Math.max(e.dirty.length,s.length);for(let i=0;i<c;i+=1)o[i]=e.dirty[i]|s[i];return o}return e.dirty|s}return e.dirty}function qt(t,e,n,r,s,o){if(s){const c=W(e,n,r,o);t.p(c,s)}}function Bt(t){if(t.ctx.length>32){const e=[],n=t.ctx.length/32;for(let r=0;r<n;r++)e[r]=-1;return e}return-1}function Ut(t){const e={};for(const n in t)n[0]!=="$"&&(e[n]=t[n]);return e}function Vt(t,e){const n={};e=new Set(e);for(const r in t)!e.has(r)&&r[0]!=="$"&&(n[r]=t[r]);return n}function Mt(t,e,n){return t.set(n),e}function Ft(t){return t&&N(t.destroy)?t.destroy:d}function Kt(t,e){t.appendChild(e)}function k(t,e,n){t.insertBefore(e,n||null)}function y(t){t.parentNode&&t.parentNode.removeChild(t)}function ft(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}function C(t){return document.createElement(t)}function X(t){return document.createTextNode(t)}function at(){return X(" ")}function dt(){return X("")}function ht(t,e,n,r){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n,r)}function Gt(t){return function(e){return e.preventDefault(),t.call(this,e)}}function I(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}const _t=["width","height"];function Ht(t,e){const n=Object.getOwnPropertyDescriptors(t.__proto__);for(const r in e)e[r]==null?t.removeAttribute(r):r==="style"?t.style.cssText=e[r]:r==="__value"?t.value=t[r]=e[r]:n[r]&&n[r].set&&_t.indexOf(r)===-1?t[r]=e[r]:I(t,r,e[r])}function pt(t){return Array.from(t.childNodes)}function Jt(t,e){e=""+e,t.data!==e&&(t.data=e)}function Qt(t,e){t.value=e??""}function Wt(t,e,n){t.classList.toggle(e,!!n)}let w;function h(t){w=t}function v(){if(!w)throw new Error("Function called outside component initialization");return w}function mt(t){v().$$.on_mount.push(t)}function Xt(t){v().$$.on_destroy.push(t)}function Yt(t,e){return v().$$.context.set(t,e),e}function Zt(t){return v().$$.context.get(t)}function te(t){return v().$$.context.has(t)}function ee(t,e){const n=t.$$.callbacks[e.type];n&&n.slice().forEach(r=>r.call(this,e))}const b=[],U=[];let $=[];const D=[],gt=Promise.resolve();let S=!1;function bt(){S||(S=!0,gt.then(R))}function j(t){$.push(t)}function ne(t){D.push(t)}const A=new Set;let g=0;function R(){if(g!==0)return;const t=w;do{try{for(;g<b.length;){const e=b[g];g++,h(e),yt(e.$$)}}catch(e){throw b.length=0,g=0,e}for(h(null),b.length=0,g=0;U.length;)U.pop()();for(let e=0;e<$.length;e+=1){const n=$[e];A.has(n)||(A.add(n),n())}$.length=0}while(b.length);for(;D.length;)D.pop()();S=!1,A.clear(),h(t)}function yt(t){if(t.fragment!==null){t.update(),x(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(j)}}function $t(t){const e=[],n=[];$.forEach(r=>t.indexOf(r)===-1?e.push(r):n.push(r)),n.forEach(r=>r()),$=e}const O=new Set;let p;function Y(){p={r:0,c:[],p}}function Z(){p.r||x(p.c),p=p.p}function m(t,e){t&&t.i&&(O.delete(t),t.i(e))}function E(t,e,n,r){if(t&&t.o){if(O.has(t))return;O.add(t),p.c.push(()=>{O.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}else r&&r()}function V(t,e){const n=e.token={};function r(s,o,c,i){if(e.token!==n)return;e.resolved=i;let u=e.ctx;c!==void 0&&(u=u.slice(),u[c]=i);const l=s&&(e.current=s)(u);let f=!1;e.block&&(e.blocks?e.blocks.forEach((a,_)=>{_!==o&&a&&(Y(),E(a,1,1,()=>{e.blocks[_]===a&&(e.blocks[_]=null)}),Z())}):e.block.d(1),l.c(),m(l,1),l.m(e.mount(),e.anchor),f=!0),e.block=l,e.blocks&&(e.blocks[o]=l),f&&R()}if(ut(t)){const s=v();if(t.then(o=>{h(s),r(e.then,1,e.value,o),h(null)},o=>{if(h(s),r(e.catch,2,e.error,o),h(null),!e.hasCatch)throw o}),e.current!==e.pending)return r(e.pending,0),!0}else{if(e.current!==e.then)return r(e.then,1,e.value,t),!0;e.resolved=t}}function vt(t,e,n){const r=e.slice(),{resolved:s}=t;t.current===t.then&&(r[t.value]=s),t.current===t.catch&&(r[t.error]=s),t.block.p(r,n)}function M(t){return(t==null?void 0:t.length)!==void 0?t:Array.from(t)}function re(t,e,n){const r=t.$$.props[e];r!==void 0&&(t.$$.bound[r]=n,n(t.$$.ctx[r]))}function kt(t){t&&t.c()}function tt(t,e,n){const{fragment:r,after_update:s}=t.$$;r&&r.m(e,n),j(()=>{const o=t.$$.on_mount.map(J).filter(N);t.$$.on_destroy?t.$$.on_destroy.push(...o):x(o),t.$$.on_mount=[]}),s.forEach(j)}function et(t,e){const n=t.$$;n.fragment!==null&&($t(n.after_update),x(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function wt(t,e){t.$$.dirty[0]===-1&&(b.push(t),bt(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function Et(t,e,n,r,s,o,c=null,i=[-1]){const u=w;h(t);const l=t.$$={fragment:null,ctx:[],props:o,update:d,not_equal:s,bound:B(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(u?u.$$.context:[])),callbacks:B(),dirty:i,skip_bound:!1,root:e.target||u.$$.root};c&&c(l.root);let f=!1;if(l.ctx=n?n(t,e.props||{},(a,_,...T)=>{const z=T.length?T[0]:_;return l.ctx&&s(l.ctx[a],l.ctx[a]=z)&&(!l.skip_bound&&l.bound[a]&&l.bound[a](z),f&&wt(t,a)),_}):[],l.update(),f=!0,x(l.before_update),l.fragment=r?r(l.ctx):!1,e.target){if(e.hydrate){const a=pt(e.target);l.fragment&&l.fragment.l(a),a.forEach(y)}else l.fragment&&l.fragment.c();e.intro&&m(t.$$.fragment),tt(t,e.target,e.anchor),R()}h(u)}class xt{constructor(){L(this,"$$");L(this,"$$set")}$destroy(){et(this,1),this.$destroy=d}$on(e,n){if(!N(n))return d;const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(e){this.$$set&&!it(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Ot="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Ot);function F(t,e,n){const r=t.slice();return r[6]=e[n],r}function K(t){t[9]=t[10].default}function G(t){let e,n,r,s={ctx:t,current:null,token:null,hasCatch:!1,pending:At,then:Pt,catch:Lt,value:10,blocks:[,,,]};return V(n=t[1],s),{c(){e=dt(),s.block.c()},m(o,c){k(o,e,c),s.block.m(o,s.anchor=c),s.mount=()=>e.parentNode,s.anchor=e,r=!0},p(o,c){t=o,s.ctx=t,c&2&&n!==(n=t[1])&&V(n,s)||vt(s,t,c)},i(o){r||(m(s.block),r=!0)},o(o){for(let c=0;c<3;c+=1){const i=s.blocks[c];E(i)}r=!1},d(o){o&&y(e),s.block.d(o),s.token=null,s=null}}}function Lt(t){return{c:d,m:d,p:d,i:d,o:d,d}}function Pt(t){K(t);let e,n;return e=new t[9]({props:{firstlyData:t[0]}}),{c(){kt(e.$$.fragment)},m(r,s){tt(e,r,s),n=!0},p(r,s){K(r);const o={};s&1&&(o.firstlyData=r[0]),e.$set(o)},i(r){n||(m(e.$$.fragment,r),n=!0)},o(r){E(e.$$.fragment,r),n=!1},d(r){et(e,r)}}}function At(t){return{c:d,m:d,p:d,i:d,o:d,d}}function H(t){let e,n,r;function s(){return t[4](t[6])}return{c(){e=C("button"),e.textContent=`Load ${t[6]}`,I(e,"class","svelte-4ze7zl")},m(o,c){k(o,e,c),n||(r=ht(e,"click",s),n=!0)},p(o,c){t=o},d(o){o&&y(e),n=!1,r()}}}function Ct(t){let e,n,r,s,o=t[1]&&G(t),c=M(t[3]()),i=[];for(let u=0;u<c.length;u+=1)i[u]=H(F(t,c,u));return{c(){e=C("main"),o&&o.c(),n=at(),r=C("div");for(let u=0;u<i.length;u+=1)i[u].c();I(r,"class","debug svelte-4ze7zl")},m(u,l){k(u,e,l),o&&o.m(e,null),k(u,n,l),k(u,r,l);for(let f=0;f<i.length;f+=1)i[f]&&i[f].m(r,null);s=!0},p(u,[l]){if(u[1]?o?(o.p(u,l),l&2&&m(o,1)):(o=G(u),o.c(),m(o,1),o.m(e,null)):o&&(Y(),E(o,1,1,()=>{o=null}),Z()),l&12){c=M(u[3]());let f;for(f=0;f<c.length;f+=1){const a=F(u,c,f);i[f]?i[f].p(a,l):(i[f]=H(a),i[f].c(),i[f].m(r,null))}for(;f<i.length;f+=1)i[f].d(1);i.length=c.length}},i(u){s||(m(o),s=!0)},o(u){E(o),s=!1},d(u){u&&(y(e),y(n),y(r)),o&&o.d(),ft(i,u)}}}function Dt(t,e,n){let{firstlyData:r}=e;const s={auth:P(()=>import("./Page-BMFREPjF.js"),__vite__mapDeps([0,1])),admin:P(()=>import("./Page-BwHye0GW.js"),[]),storage:P(()=>import("./Page-BMOLAIFx.js"),[])};let o;function c(l){n(1,o=s[l])}const i=()=>Object.keys(s);mt(()=>{c(r.module)});const u=l=>c(l);return t.$$set=l=>{"firstlyData"in l&&n(0,r=l.firstlyData)},[r,o,c,i,u]}class St extends xt{constructor(e){super(),Et(this,e,Dt,Ct,lt,{firstlyData:0})}}new St({target:document.getElementById("app"),props:{firstlyData}});export{C as A,Ht as B,Ft as C,ht as D,Vt as E,Ut as F,ee as G,X as H,at as I,I as J,Wt as K,Kt as L,Qt as M,Gt as N,Jt as O,kt as P,tt as Q,et as R,xt as S,U as T,re as U,ne as V,lt as a,Et as b,Nt as c,k as d,dt as e,Y as f,It as g,E as h,N as i,Z as j,y as k,Rt as l,te as m,d as n,Zt as o,Xt as p,Yt as q,x as r,Q as s,m as t,Mt as u,Tt as v,qt as w,Bt as x,zt as y,ct as z};
|