firstly 0.0.6 → 0.0.8
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 +26 -0
- package/esm/FF_Entity.js +20 -4
- package/esm/ROUTES.d.ts +11 -11
- package/esm/ROUTES.js +5 -5
- package/esm/SqlDatabase/FF_LogToConsole.d.ts +4 -1
- package/esm/SqlDatabase/FF_LogToConsole.js +15 -8
- package/esm/api/index.d.ts +2 -2
- package/esm/api/index.js +9 -9
- package/esm/auth/Adapter.js +1 -7
- package/esm/auth/AuthController.server.d.ts +1 -2
- package/esm/auth/AuthController.server.js +96 -65
- package/esm/auth/RoleHelpers.d.ts +1 -1
- package/esm/auth/RoleHelpers.js +9 -9
- package/esm/auth/client/Auth.d.ts +11 -4
- package/esm/auth/client/Auth.js +13 -5
- package/esm/auth/{Entities.d.ts → client/Entities.d.ts} +3 -3
- package/esm/auth/{Entities.js → client/Entities.js} +30 -14
- package/esm/auth/client/index.d.ts +5 -0
- package/esm/auth/client/index.js +5 -0
- package/esm/auth/helper.d.ts +6 -1
- package/esm/auth/helper.js +11 -4
- package/esm/auth/index.d.ts +9 -11
- package/esm/auth/index.js +74 -70
- package/esm/auth/providers/github.js +2 -1
- package/esm/auth/providers/index.js +1 -1
- package/esm/auth/providers/strava.js +2 -1
- package/esm/auth/static/assets/{Page-RIbXHuZG.d.ts → Page-BEFYPjis.d.ts} +1 -1
- package/esm/auth/static/assets/{Page-RIbXHuZG.js → Page-BEFYPjis.js} +1 -1
- package/esm/auth/static/assets/Page-Cfysx_UV.d.ts +6 -0
- package/esm/auth/static/assets/Page-Cfysx_UV.js +18 -0
- package/esm/auth/static/assets/{Page-DBWJjlEQ.d.ts → Page-DtgkOCJs.d.ts} +1 -1
- package/esm/auth/static/assets/{Page-DBWJjlEQ.js → Page-DtgkOCJs.js} +1 -1
- package/esm/auth/static/assets/index-QypqCYwC.d.ts +63 -0
- package/esm/auth/static/assets/index-QypqCYwC.js +2 -0
- package/esm/auth/static/index.html +1 -1
- package/esm/auth/types.d.ts +7 -5
- package/esm/bin/cmd.js +28 -14
- package/esm/cellsBuildor.d.ts +1 -0
- package/esm/cellsBuildor.js +24 -12
- package/esm/changeLog/index.d.ts +23 -7
- package/esm/changeLog/index.js +24 -18
- package/esm/feedback/FeedbackController.d.ts +12 -3
- package/esm/feedback/FeedbackController.js +62 -11
- package/esm/feedback/index.d.ts +1 -0
- package/esm/feedback/ui/DialogIssue.svelte +28 -9
- package/esm/feedback/ui/DialogIssues.svelte +7 -2
- package/esm/handle/index.d.ts +1 -1
- package/esm/index.d.ts +4 -2
- package/esm/index.js +1 -1
- package/esm/mail/index.js +1 -1
- package/esm/mail/templates/DefaultMail.svelte +1 -1
- package/esm/ui/Field.svelte +2 -10
- package/esm/ui/GridPaginate.svelte +7 -7
- package/esm/ui/GridPaginate.svelte.d.ts +1 -1
- package/esm/vite/index.js +4 -1
- package/package.json +8 -8
- package/esm/auth/static/assets/Page-apb_xgZT.d.ts +0 -6
- package/esm/auth/static/assets/Page-apb_xgZT.js +0 -18
- package/esm/auth/static/assets/index-qfq98Nyd.d.ts +0 -63
- package/esm/auth/static/assets/index-qfq98Nyd.js +0 -2
|
@@ -4,23 +4,23 @@ import "./LibIcon";
|
|
|
4
4
|
import { LibIcon_ChevronLeft, LibIcon_ChevronRight } from "./LibIcon";
|
|
5
5
|
import Loading from "./Loading.svelte";
|
|
6
6
|
export let label = "Pagination";
|
|
7
|
-
export let
|
|
7
|
+
export let pageDisplayed;
|
|
8
8
|
export let totalCount = void 0;
|
|
9
9
|
export let pageSize = 25;
|
|
10
10
|
const update = (op) => {
|
|
11
11
|
if (op === "+") {
|
|
12
12
|
if (canGoNext) {
|
|
13
|
-
|
|
13
|
+
pageDisplayed = pageDisplayed + 1;
|
|
14
14
|
}
|
|
15
15
|
} else {
|
|
16
|
-
if (
|
|
17
|
-
|
|
16
|
+
if (pageDisplayed > 1) {
|
|
17
|
+
pageDisplayed = pageDisplayed - 1;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
$: isValidValue = totalCount !== void 0 && totalCount !== null;
|
|
22
22
|
$: needPaginate = isValidValue && (totalCount ?? 0) > pageSize;
|
|
23
|
-
$: canGoNext = isValidValue && needPaginate &&
|
|
23
|
+
$: canGoNext = isValidValue && needPaginate && pageDisplayed < Math.ceil((totalCount ?? 0) / pageSize);
|
|
24
24
|
</script>
|
|
25
25
|
|
|
26
26
|
<FieldContainer {label} forId="paginate" classes={{ label: 'justify-end' }}>
|
|
@@ -36,7 +36,7 @@ $: canGoNext = isValidValue && needPaginate && page < Math.ceil((totalCount ?? 0
|
|
|
36
36
|
<button
|
|
37
37
|
aria-label="left"
|
|
38
38
|
on:click={() => update('-')}
|
|
39
|
-
class="btn join-item {
|
|
39
|
+
class="btn join-item {pageDisplayed === 1 ? 'btn-disabled' : ''}"
|
|
40
40
|
>
|
|
41
41
|
<Icon data={LibIcon_ChevronLeft} />
|
|
42
42
|
</button>
|
|
@@ -44,7 +44,7 @@ $: canGoNext = isValidValue && needPaginate && page < Math.ceil((totalCount ?? 0
|
|
|
44
44
|
<button aria-label="current" class="btn join-item px-0">
|
|
45
45
|
<span class="text-primary font-bold">{totalCount}</span>
|
|
46
46
|
<span class="text-[0.55rem] italic"
|
|
47
|
-
>({
|
|
47
|
+
>({pageDisplayed} / {Math.ceil((totalCount ?? 0) / pageSize)})</span
|
|
48
48
|
>
|
|
49
49
|
</button>
|
|
50
50
|
{:else}
|
package/esm/vite/index.js
CHANGED
|
@@ -2,9 +2,12 @@ import { mergeConfig } from 'vite';
|
|
|
2
2
|
import { kitRoutes } from 'vite-plugin-kit-routes';
|
|
3
3
|
import { stripper } from 'vite-plugin-stripper';
|
|
4
4
|
// import { Log } from '@kitql/helpers'
|
|
5
|
+
// const toRemove = ['oslo/password', 'oslo', '@node-rs/argon2', '@node-rs/bcrypt']
|
|
6
|
+
// oslo needs to be in the dependencies (not devDependencies) !!
|
|
5
7
|
const toRemove = ['oslo/password', 'oslo'];
|
|
6
8
|
export function firstly(options) {
|
|
7
9
|
// const log = new Log('firstly')
|
|
10
|
+
// console.log(`toRemove`, toRemove)
|
|
8
11
|
return [
|
|
9
12
|
{
|
|
10
13
|
name: 'vite-plugin-firstly',
|
|
@@ -13,7 +16,7 @@ export function firstly(options) {
|
|
|
13
16
|
return mergeConfig(a, {
|
|
14
17
|
build: {
|
|
15
18
|
// THE ERROR:
|
|
16
|
-
// RollupError: Unexpected character '�'
|
|
19
|
+
// RollupError: Unexpected character '�' or Unexpected character '\u{7f}'
|
|
17
20
|
// This code (A) is to fix in `build` mode
|
|
18
21
|
rollupOptions: {
|
|
19
22
|
external: toRemove,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firstly",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Firstly, an opinionated Remult setup!",
|
|
6
6
|
"repository": {
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@sveltejs/kit": ">=1.0.0 <3.0.0",
|
|
17
|
-
"remult": "0.27.
|
|
17
|
+
"remult": "0.27.7",
|
|
18
18
|
"svelte": ">=4.2.18"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@clack/prompts": "^0.7.0",
|
|
22
|
-
"@kitql/internals": "0.9.
|
|
22
|
+
"@kitql/internals": "0.9.9",
|
|
23
23
|
"@mdi/js": "^7.4.47",
|
|
24
|
-
"@melt-ui/svelte": "^0.
|
|
24
|
+
"@melt-ui/svelte": "^0.83.0",
|
|
25
25
|
"@types/nodemailer": "^6.4.15",
|
|
26
26
|
"arctic": "^1.8.0",
|
|
27
27
|
"clsx": "^2.1.1",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"esm-env": "^1.0.0",
|
|
31
31
|
"lucia": "^3.2.0",
|
|
32
32
|
"nodemailer": "^6.9.13",
|
|
33
|
-
"oslo": "
|
|
34
|
-
"
|
|
33
|
+
"oslo": "1.2.1",
|
|
34
|
+
"svelty-email": "^0.0.11",
|
|
35
35
|
"tailwind-merge": "^2.3.0",
|
|
36
36
|
"tailwindcss": "^3.4.3",
|
|
37
37
|
"vite": "^5.4.1",
|
|
38
|
-
"vite-plugin-kit-routes": "^0.6.
|
|
39
|
-
"vite-plugin-stripper": "^0.5.
|
|
38
|
+
"vite-plugin-kit-routes": "^0.6.10",
|
|
39
|
+
"vite-plugin-stripper": "^0.5.4"
|
|
40
40
|
},
|
|
41
41
|
"sideEffects": false,
|
|
42
42
|
"bin": "./esm/bin/cmd.js",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var Cs=Object.defineProperty;var Ts=(i,e,t)=>e in i?Cs(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var d=(i,e,t)=>Ts(i,typeof e!="symbol"?e+"":e,t);import{n as ue,s as As,r as dt,a as ht,i as Ps,g as Fs,S as et,b as tt,c as qi,d as U,e as Jn,v as lt,f as ut,h as nt,j as si,k as ln,o as oi,l as un,m as Ds,p as ji,q as Un,t as G,u as Z,w as Rs,x as te,y as Ms,z as x,A as Ji,B as Ui,C as Wi,D as gn,E as ai,F as Ns,G as q,H as li,I as j,J as en,K as Ce,L as Ls,M as se,N as X,O as Q,P as Ue,Q as C,R as _e,T as tn,U as ye,V as me,W as we,X as ge,Y as Wn,Z as Vn,_ as Hn}from"./index-qfq98Nyd.js";function Bs(i,e){const t={},n={},r={$$scope:1};let s=i.length;for(;s--;){const o=i[s],a=e[s];if(a){for(const l in o)l in a||(n[l]=1);for(const l in a)r[l]||(t[l]=a[l],r[l]=1);i[s]=a}else for(const l in o)r[l]=1}for(const o in n)o in t||(t[o]=void 0);return t}const rt=[];function Qn(i,e){return{subscribe:St(i,e).subscribe}}function St(i,e=ue){let t;const n=new Set;function r(a){if(ht(i,a)&&(i=a,t)){const l=!rt.length;for(const f of n)f[1](),rt.push(f,i);if(l){for(let f=0;f<rt.length;f+=2)rt[f][0](rt[f+1]);rt.length=0}}}function s(a){r(a(i))}function o(a,l=ue){const f=[a,l];return n.add(f),n.size===1&&(t=e(r,s)||ue),a(i),()=>{n.delete(f),n.size===0&&t&&(t(),t=null)}}return{set:r,update:s,subscribe:o}}function nn(i,e,t){const n=!Array.isArray(i),r=n?[i]:i;if(!r.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const s=e.length<2;return Qn(t,(o,a)=>{let l=!1;const f=[];let u=0,c=ue;const h=()=>{if(u)return;c();const y=e(n?f[0]:f,o,a);s?o(y):c=Ps(y)?y:ue},p=r.map((y,_)=>As(y,w=>{f[_]=w,u&=~(1<<_),l&&h()},()=>{u|=1<<_}));return l=!0,h(),function(){dt(p),c(),l=!1}})}const qs=i=>{const{subscribe:e,update:t}=St(i);return{subscribe:e,set:(n={})=>{t(r=>Object.assign(r,n))}}},Je=qs({mode:"window",basePath:null}),fn=(i=Fs(Je).mode)=>{let e="popstate";i==="window"&&(e="popstate"),i==="hash"&&(e="hashchange"),window.dispatchEvent(new Event(e))},ui={go:(i=0)=>{history.go(i),fn()},push:(i,e=null)=>{history.pushState(e,"",i),fn()},replace:(i,e=null)=>{history.replaceState(e,"",i),fn()}},js=i=>{const e=i.match(/^(\/[^?#]*)?/),t=i.match(/\?([^#]*)?/),n=i.match(/#(.*)?/);return{path:(e==null?void 0:e[1])||"/",query:t!=null&&t[1]?`?${t==null?void 0:t[1]}`:"",hash:n!=null&&n[1]?`#${n==null?void 0:n[1]}`:""}},fi=()=>{const{pathname:i,search:e,hash:t}=document.location;return{path:i,query:e,hash:t}},ci=()=>{let i=document.location.hash.substring(1);return i[0]!=="/"&&(i="/"+i),js(i)},Js=Qn(fi(),i=>{const e=()=>i(fi());return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),Us=Qn(ci(),i=>{const e=()=>i(ci());return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}),$n=nn([Je,Js,Us],([i,e,t],n)=>{i.mode==="window"&&n(e),i.mode==="hash"&&n(t)}),cn=nn($n,i=>i.path);nn($n,i=>i.query);nn($n,i=>i.hash);const kt=i=>i.split(/(?=\/)/),Vi=()=>{let i=0;return()=>i++},bn=(i,e)=>e===null?i:i.startsWith(e)?i.slice(e.length):i,{Error:vt}=Jn;function vn(i){let e;const t=i[11].default,n=ji(t,i,i[10],null),r={c:function(){n&&n.c()},m:function(o,a){n&&n.m(o,a),e=!0},p:function(o,a){n&&n.p&&(!e||a&1024)&&Ji(n,t,o,o[10],e?Wi(t,o[10],a,null):Ui(o[10]),null)},i:function(o){e||(Z(n,o),e=!0)},o:function(o){te(n,o),e=!1},d:function(o){n&&n.d(o)}};return U("SvelteRegisterBlock",{block:r,id:vn.name,type:"if",source:"(98:0) {#if isRouteActive(getPathWithoutBase($globalPath, $options.basePath), $route, $contextChildRoutes)}",ctx:i}),r}function _n(i){let e=kn(bn(i[1],i[2].basePath),i[0],i[3]),t,n,r=e&&vn(i);const s={c:function(){r&&r.c(),t=Un()},l:function(a){throw new vt("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(a,l){r&&r.m(a,l),G(a,t,l),n=!0},p:function(a,[l]){l&15&&(e=kn(bn(a[1],a[2].basePath),a[0],a[3])),e?r?(r.p(a,l),l&15&&Z(r,1)):(r=vn(a),r.c(),Z(r,1),r.m(t.parentNode,t)):r&&(Rs(),te(r,1,1,()=>{r=null}),Ms())},i:function(a){n||(Z(r),n=!0)},o:function(a){te(r),n=!1},d:function(a){a&&x(t),r&&r.d(a)}};return U("SvelteRegisterBlock",{block:s,id:_n.name,type:"component",source:"",ctx:i}),s}const di=(i,e,t,n,r)=>{const s=(f,u,c)=>{const h=kt(u).filter(p=>p!=="/").length;return(c??0)+(f?1:h)},o=(f,u)=>{const c={invalidPath:`<Route path="${f==null?void 0:f.path}" /> has invalid path. Path must start with '/'`,fallbackOutsideRoot:"<Route fallback /> cannot be outside root <Route />",pathOutsideRoot:`<Route path="${f==null?void 0:f.path}" /> cannot be outside root <Route />`,fallbackInsideFallback:"<Route fallback /> cannot be inside <Route fallback>",pathInsideFallback:`<Route path="${f==null?void 0:f.path}" /> cannot be inside <Route fallback>`};if(f.path[0]!=="/")throw new Error(c.invalidPath);if(f.root&&f.fallback)throw new Error(c.fallbackOutsideRoot);if(f.root&&f.path!=="/")throw new Error(c.pathOutsideRoot);if(u!=null&&u.fallback&&f.fallback)throw new Error(c.fallbackInsideFallback);if(u!=null&&u.fallback&&!f.fallback)throw new Error(c.pathInsideFallback)},a=s(t,n,r==null?void 0:r.depth),l={id:i,root:e,fallback:t,path:n,depth:a};return o(l,r),l},hi=()=>{const{subscribe:i,update:e}=St([]);return{subscribe:i,update:t=>e(n=>[...n.filter(r=>t.id!==r.id),t]),remove:t=>e(n=>n.filter(r=>t.id!==r.id))}},kn=(i,e,t)=>{const n=(f,u,c,h)=>{let p=kt(f).filter(w=>w!=="/"),y=kt(c).filter(w=>w!=="/"),_="";if(c==="/")return u||p.length===h;for(let w=h-y.length;w<h;w++)_=_+p[w];return c===_},r=(f,u,c)=>{var y,_,w,g;let h=kt(f).filter(k=>k!=="/"),p=!1;for(let k=0;k<(c==null?void 0:c.length)&&!p;k++)(y=c[k])!=null&&y.fallback||(p=n(f,((_=c[k])==null?void 0:_.root)??!1,((w=c[k])==null?void 0:w.path)??"",((g=c[k])==null?void 0:g.depth)??0));return h.length>=u&&!p},{root:s,fallback:o,path:a,depth:l}=e;return o?r(i,l,t):n(i,s,a,l)},pi=Vi(),Mt={},dn={};function Ws(i,e,t){let n,r,s,o,a;lt(cn,"globalPath"),ut(i,cn,E=>t(1,s=E)),lt(Je,"options"),ut(i,Je,E=>t(2,o=E));let{$$slots:l={},$$scope:f}=e;nt("Route",l,["default"]);const u=pi(),c=!si(Mt);let{fallback:h=!1}=e,{path:p="/"}=e;const y=St();lt(y,"route"),ut(i,y,E=>t(0,n=E));const _=ln(Mt);lt(_,"contextRoute"),ut(i,_,E=>t(9,r=E));const w=hi(),g=ln(dn);lt(g,"contextChildRoutes"),ut(i,g,E=>t(3,a=E)),oi(()=>g==null?void 0:g.remove(n)),un(Mt,y),un(dn,w);const k=["fallback","path"];return Object.keys(e).forEach(E=>{!~k.indexOf(E)&&E.slice(0,2)!=="$$"&&E!=="slot"&&console.warn(`<Route> was created with unknown prop '${E}'`)}),i.$$set=E=>{"fallback"in E&&t(7,h=E.fallback),"path"in E&&t(8,p=E.path),"$$scope"in E&&t(10,f=E.$$scope)},i.$capture_state=()=>({writable:St,createIdIssuer:Vi,getPathSegments:kt,getRoute:di,createChildRoutes:hi,isRouteActive:kn,getId:pi,routeContextKey:Mt,childRoutesContextKey:dn,onDestroy:oi,getContext:ln,setContext:un,hasContext:si,globalPath:cn,options:Je,getPathWithoutBase:bn,id:u,root:c,fallback:h,path:p,route:y,contextRoute:_,childRoutes:w,contextChildRoutes:g,$route:n,$contextRoute:r,$globalPath:s,$options:o,$contextChildRoutes:a}),i.$inject_state=E=>{"fallback"in E&&t(7,h=E.fallback),"path"in E&&t(8,p=E.path)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),i.$$.update=()=>{i.$$.dirty&896&&Ds(y,n=di(u,c,h,p,r),n),i.$$.dirty&1&&(g==null||g.update(n))},[n,s,o,a,y,_,g,h,p,r,f,l]}class ze extends et{constructor(e){super(e),tt(this,e,Ws,_n,qi,{fallback:7,path:8}),U("SvelteRegisterComponent",{component:this,tagName:"Route",options:e,id:_n.name})}get fallback(){throw new vt("<Route>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set fallback(e){throw new vt("<Route>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get path(){throw new vt("<Route>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set path(e){throw new vt("<Route>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}const yi=i=>{var a;const e=(a=i.target)==null?void 0:a.closest("a[href]"),t=e==null?void 0:e.href;if(e===null||t===null)return!0;const n=["","true"].includes(e.getAttribute("data-handle-ignore")??"false"),r=(e.getAttribute("target")??"_self")!=="_self",s=i.metaKey||i.ctrlKey||i.altKey||i.shiftKey,o=new URL(t).origin!==document.location.origin;if(n||r||s||o)return!0;t===document.location.href?ui.replace(t):ui.push(t),i.preventDefault()},Hi=i=>(i.addEventListener("click",yi),{destroy:()=>{i.removeEventListener("click",yi)}}),Vs="home/jycouet/udev/gh/dp/my-minion-mr/node_modules/.pnpm/svelte-micro@2.5.7_svelte@4.2.18/node_modules/svelte-micro/dist/lib/components/Link.svelte";function In(i){let e,t,n,r;const s=i[5].default,o=ji(s,i,i[4],null);let a=[{href:i[0]},i[1]],l={};for(let u=0;u<a.length;u+=1)l=gn(l,a[u]);const f={c:function(){e=q("a"),o&&o.c(),li(e,l),j(e,Vs,15,0,417)},l:function(c){throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(c,h){G(c,e,h),o&&o.m(e,null),t=!0,n||(r=[en(Hi.call(null,e)),Ce(e,"click",i[6],!1,!1,!1,!1)],n=!0)},p:function(c,[h]){o&&o.p&&(!t||h&16)&&Ji(o,s,c,c[4],t?Wi(s,c[4],h,null):Ui(c[4]),null),li(e,l=Bs(a,[(!t||h&1)&&{href:c[0]},h&2&&c[1]]))},i:function(c){t||(Z(o,c),t=!0)},o:function(c){te(o,c),t=!1},d:function(c){c&&x(e),o&&o.d(c),n=!1,dt(r)}};return U("SvelteRegisterBlock",{block:f,id:In.name,type:"component",source:"",ctx:i}),f}const mi=(i,e,t)=>(i==="hash"?"#":"")+(e??"")+t;function Hs(i,e,t){let n;const r=["href"];let s=ai(e,r),o;lt(Je,"options"),ut(i,Je,c=>t(3,o=c));let{$$slots:a={},$$scope:l}=e;nt("Link",a,["default"]);let{href:f}=e;i.$$.on_mount.push(function(){f===void 0&&!("href"in e||i.$$.bound[i.$$.props.href])&&console.warn("<Link> was created without expected prop 'href'")});function u(c){Ls.call(this,i,c)}return i.$$set=c=>{e=gn(gn({},e),Ns(c)),t(1,s=ai(e,r)),"href"in c&&t(2,f=c.href),"$$scope"in c&&t(4,l=c.$$scope)},i.$capture_state=()=>({getFormatedHref:mi,options:Je,linkHandle:Hi,href:f,formatedHref:n,$options:o}),i.$inject_state=c=>{"href"in e&&t(2,f=c.href),"formatedHref"in e&&t(0,n=c.formatedHref)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),i.$$.update=()=>{i.$$.dirty&12&&t(0,n=mi(o.mode,o.basePath,f))},[n,s,f,o,l,a,u]}class pt extends et{constructor(e){super(e),tt(this,e,Hs,In,qi,{href:2}),U("SvelteRegisterComponent",{component:this,tagName:"Link",options:e,id:In.name})}get href(){throw new Error("<Link>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set href(e){throw new Error("<Link>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}class Ke{constructor(...e){d(this,"fields");d(this,"options",{});d(this,"target");d(this,"readonly",!0);d(this,"allowNull",!1);d(this,"dbReadOnly",!1);d(this,"isServerExpression",!1);d(this,"key","");d(this,"caption","");d(this,"inputType","");d(this,"dbName","");d(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=r=>e[r.key];typeof e=="function"&&(t=e);let n="";return this.fields.forEach(r=>{n.length>0&&(n+=","),n+=r.valueConverter.toJson(t(r))}),n}get valueConverter(){throw new Error("cant get value converter of compound id")}isEqualTo(e){let t={},r=e.toString().split(",");return this.fields.forEach((s,o)=>{t[s.key]=s.valueConverter.fromJson(r[o])}),t}}function ee(i,e=!0){var n;let t=i[Xe];if(!t&&e)throw new Error("item "+(((n=i.constructor)==null?void 0:n.name)||i)+" was not initialized using a context");return t}const Xe=Symbol.for("entityMember"),Qs=Symbol.for("entityInfo"),$s=Symbol.for("entityInfo_key");function Ie(i,e=!0){if(i===void 0){if(e)throw new Error("Undefined is not an entity :)");return}let t=i[Qs];if(!t&&e)throw new Error(i.prototype.constructor.name+" is not a known entity, did you forget to set @Entity() or did you forget to add the '@' before the call to Entity?");return t}function Gs(i){return i[$s]}const xs=Symbol.for("relationInfo");function Xs(i){return i==null?void 0:i[xs]}const On=Symbol.for("fieldRelationInfo");function oe(i){return i[On]}function zs(i,e,t){for(const n of i.fields.toArray()){const r=Xs(n.options);if(r&&!n[On]){const s=r.toType(),o=e.repo(s,t),a=n.options;n[On]={type:r.type,toEntity:s,options:a,toRepo:o,getFields:()=>{let l=a.field,f={fields:a.fields,compoundIdField:void 0};function u(p){return Error(`Error for relation: "${n.key}" to "${o.metadata.key}": `+p)}let c=()=>l||f.fields;if(r.type==="toMany"&&!c()){for(const p of o.fields.toArray())if(!c()){const y=oe(p),_=p.options;if(y&&y.toEntity===i.metadata.entityType){if(y.type==="reference")l=p.key;else if(y.type==="toOne"){if(_.field)l=_.field;else if(_.fields){let w={};for(const g in _.fields)if(Object.prototype.hasOwnProperty.call(_.fields,g)){const k=_.fields[g];w[k]=g}f.fields=w}}}}if(!c())throw u("No matching field found on target. Please specify field/fields")}function h(p,y){const _=y.fields.find(p);if(!_)throw u(`Field "${p}" was not found in "${y.key}".`);return _}r.type==="reference"&&(l=n.key),l&&(r.type==="toOne"||r.type==="reference"?o.metadata.idMetadata.field instanceof Ke?f.compoundIdField=l:f.fields={[o.metadata.idMetadata.field.key]:l}:i.metadata.idMetadata.field instanceof Ke?f.compoundIdField=l:f.fields={[l]:i.metadata.idMetadata.field.key});for(const p in f.fields)Object.prototype.hasOwnProperty.call(f.fields,p)&&(h(p,o.metadata),h(f.fields[p],i.metadata));return f}}}}}class P{constructor(e){d(this,"apply");this.apply=e}static throwErrorIfFilterIsEmpty(e,t){if(P.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(!P.isFilterEmpty(t))return!1}if(e.$or){for(const t of e.$or)if(P.isFilterEmpty(t))return!0;return!1}return Object.keys(e).filter(t=>!["$or","$and"].includes(t)).length==0}static async getPreciseValues(e,t){const n=new xt;return await P.fromEntityFilter(e,t).__applyToConsumer(n),n.preciseValues}async getPreciseValues(){const e=new xt;return await this.__applyToConsumer(e),e.preciseValues}static createCustom(e,t=""){let n={key:t,rawFilterTranslator:e};return Object.assign(r=>{if(r==null&&(r={}),!n.key)throw"Usage of custom filter before a key was assigned to it";return{[Ze+n.key]:r}},{rawFilterInfo:n})}static entityFilterToJson(e,t){return P.fromEntityFilter(e,t).toJson()}static entityFilterFromJson(e,t){return Jt(e,{get:n=>t[n]})}static fromEntityFilter(e,t){let n=[];for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let s=t[r];if(r=="$or")n.push(new Ys(...s.map(o=>P.fromEntityFilter(e,o))));else if(r=="$not")n.push(new eo(P.fromEntityFilter(e,s)));else if(r=="$and")n.push(new wi(...s.map(o=>P.fromEntityFilter(e,o))));else if(r.startsWith(Ze))n.push(new P(o=>{o.custom(r.substring(Ze.length),s)}));else if(r==Qi)n.push(new P(o=>o.databaseCustom(s)));else{const o=e.fields[r],a=oe(o),l=o.options;let f=(a==null?void 0:a.type)==="toOne"?l.fields?new Zs(o,e.fields,l):new Ks(e.fields[l.field]):new Qt(o),u=!1;if(s!==void 0&&s!=null){s.$id!==void 0&&(s=s.$id);for(const c in s)if(Object.prototype.hasOwnProperty.call(s,c)){const h=s[c];switch(c){case"$gte":case">=":n.push(f.isGreaterOrEqualTo(h)),u=!0;break;case"$gt":case">":n.push(f.isGreaterThan(h)),u=!0;break;case"$lte":case"<=":n.push(f.isLessOrEqualTo(h)),u=!0;break;case"$lt":case"<":n.push(f.isLessThan(h)),u=!0;break;case"$ne":case"!=":case"$nin":u=!0,Array.isArray(h)?n.push(f.isNotIn(h)):n.push(f.isDifferentFrom(h));break;case"$in":u=!0,n.push(f.isIn(h));break;case"$contains":u=!0,n.push(f.contains(h));break;case"$startsWith":u=!0,n.push(f.startsWith(h));break;case"$endsWith":u=!0,n.push(f.endsWith(h));break;case"$notContains":u=!0,n.push(f.notContains(h));break}}Array.isArray(s)&&(u=!0,n.push(f.isIn(s)))}!u&&s!==void 0&&n.push(f.isEqualTo(s))}}return new wi(...n)}__applyToConsumer(e){this.apply(e)}static async resolve(e){return typeof e=="function"?await e():e}toJson(){let e=new $t;return this.__applyToConsumer(e),e.result}static async translateCustomWhere(e,t,n){let r=new Gt(async(s,o)=>{let a=[];for(const l in t.entityType){const f=t.entityType[l];f&&f.rawFilterInfo&&f.rawFilterInfo.rawFilterTranslator&&f.rawFilterInfo.key==s&&a.push(await P.fromEntityFilter(t,await f.rawFilterInfo.rawFilterTranslator(o,n)))}return a});return e.__applyToConsumer(r),await r.resolve(),e=new P(s=>r.applyTo(s)),e}}class Qt{constructor(e){d(this,"metadata");this.metadata=e}processVal(e){if(Ie(this.metadata.valueType,!1)){if(e==null){if(e===null&&!this.metadata.allowNull){const n=oe(this.metadata);if((n==null?void 0:n.type)==="reference")return n.toRepo.metadata.idMetadata.field.options.valueType===Number?0:""}return null}return typeof e=="string"||typeof e=="number"?e:ee(e).getId()}return e}contains(e){return new P(t=>t.containsCaseInsensitive(this.metadata,e))}notContains(e){return new P(t=>t.notContainsCaseInsensitive(this.metadata,e))}startsWith(e){return new P(t=>t.startsWithCaseInsensitive(this.metadata,e))}endsWith(e){return new P(t=>t.endsWithCaseInsensitive(this.metadata,e))}isLessThan(e){return e=this.processVal(e),new P(t=>t.isLessThan(this.metadata,e))}isGreaterOrEqualTo(e){return e=this.processVal(e),new P(t=>t.isGreaterOrEqualTo(this.metadata,e))}isNotIn(e){return new P(t=>{for(const n of e)t.isDifferentFrom(this.metadata,this.processVal(n))})}isDifferentFrom(e){return e=this.processVal(e),e==null&&this.metadata.allowNull?new P(t=>t.isNotNull(this.metadata)):new P(t=>t.isDifferentFrom(this.metadata,e))}isLessOrEqualTo(e){return e=this.processVal(e),new P(t=>t.isLessOrEqualTo(this.metadata,e))}isGreaterThan(e){return e=this.processVal(e),new P(t=>t.isGreaterThan(this.metadata,e))}isEqualTo(e){return e=this.processVal(e),e==null&&this.metadata.allowNull?new P(t=>t.isNull(this.metadata)):new P(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 P(t=>t.isEqualTo(this.metadata,e[0])):new P(t=>t.isIn(this.metadata,e))}}class Ks extends Qt{processVal(e){return e?typeof e=="string"||typeof e=="number"?e:ee(e).getId():null}}class Zs{constructor(e,t,n){d(this,"metadata");d(this,"fields");d(this,"relationOptions");this.metadata=e,this.fields=t,this.relationOptions=n}processVal(e){throw new Error("Invalid for Many To One Relation Field")}contains(e){throw new Error("Invalid for Many To One Relation Field")}notContains(e){throw new Error("Invalid for Many To One Relation Field")}endsWith(e){throw new Error("Invalid for Many To One Relation Field")}startsWith(e){throw new Error("Invalid for Many To One Relation Field")}isLessThan(e){throw new Error("Invalid for Many To One Relation Field")}isGreaterOrEqualTo(e){throw new Error("Invalid for Many To One Relation Field")}isNotIn(e){return new P(t=>{e.forEach(n=>this.isDifferentFrom(n).__applyToConsumer(t))})}isDifferentFrom(e){return new P(t=>{const n=[];for(const r in this.relationOptions.fields)if(Object.prototype.hasOwnProperty.call(this.relationOptions.fields,r)){const s=this.relationOptions.fields[r];n.push(new P(o=>new Qt(this.fields.find(s)).isDifferentFrom(e[r]).__applyToConsumer(o)))}t.or(n)})}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 P(t=>{for(const n in this.relationOptions.fields)if(Object.prototype.hasOwnProperty.call(this.relationOptions.fields,n)){const r=this.relationOptions.fields[n];new Qt(this.fields.find(r)).isEqualTo(e[n]).__applyToConsumer(t)}})}isIn(e){return new P(t=>{t.or(e.map(n=>this.isEqualTo(n)))})}}class wi extends P{constructor(...t){super(n=>{for(const r of this.filters)r&&r.__applyToConsumer(n)});d(this,"filters");this.filters=t}add(t){this.filters.push(t)}}class Ys extends P{constructor(...t){super(n=>{let r=this.filters.filter(s=>s!==void 0);r.length>1?n.or(r):r.length==1&&r[0].__applyToConsumer(n)});d(this,"filters");this.filters=t}}class eo extends P{constructor(t){super(n=>{n.not(t)});d(this,"filter");this.filter=t}}const Ze="$custom$",Qi="$db$",En="$an array";class $t{constructor(){d(this,"result",{});d(this,"hasUndefined",!1)}databaseCustom(e){throw new Error("database custom is not allowed with api calls.")}custom(e,t){Array.isArray(t)&&(t={[En]:t}),this.add(Ze+e,t)}add(e,t){t===void 0&&(this.hasUndefined=!0);let n=this.result;if(!n[e]){n[e]=t;return}let r=n[e];r instanceof Array?r.push(t):r=[r,t],n[e]=r}or(e){this.add("OR",e.map(t=>{let n=new $t;return t.__applyToConsumer(n),n.result}))}not(e){let t=new $t;e.__applyToConsumer(t),this.add("NOT",t.result)}isNull(e){this.add(e.key+".null",!0)}isNotNull(e){this.add(e.key+".null",!1)}isIn(e,t){this.add(e.key+".in",t.map(n=>e.valueConverter.toJson(n)))}isEqualTo(e,t){this.add(e.key,e.valueConverter.toJson(t))}isDifferentFrom(e,t){this.add(e.key+".ne",e.valueConverter.toJson(t))}isGreaterOrEqualTo(e,t){this.add(e.key+".gte",e.valueConverter.toJson(t))}isGreaterThan(e,t){this.add(e.key+".gt",e.valueConverter.toJson(t))}isLessOrEqualTo(e,t){this.add(e.key+".lte",e.valueConverter.toJson(t))}isLessThan(e,t){this.add(e.key+".lt",e.valueConverter.toJson(t))}containsCaseInsensitive(e,t){this.add(e.key+".contains",t)}notContainsCaseInsensitive(e,t){this.add(e.key+".notContains",t)}startsWithCaseInsensitive(e,t){this.add(e.key+".startsWith",t)}endsWithCaseInsensitive(e,t){this.add(e.key+".endsWith",t)}}function Jt(i,e){let t={};function n(a){t.$and||(t.$and=[]),t.$and.push(a)}function r(a,l){t[a]===void 0?t[a]=l:n({[a]:l})}[...i.fields].forEach(a=>{function l(u,c,h=!1,p=!1){let y=e.get(a.key+u);if(y!==void 0){let _=w=>{let g=w;if(h){let E;typeof w=="string"?E=JSON.parse(w):E=w,g=E.map(N=>p?N:a.valueConverter.fromJson(N))}else g=p?g:a.valueConverter.fromJson(g);let k=c(g);k!==void 0&&r(a.key,k)};if(!h&&y instanceof Array)y.forEach(w=>{_(w)});else{h&&typeof y=="string"&&(y=JSON.parse(y));const w=o(y);for(const g of w)_(g)}}}l("",u=>u),l(".gt",u=>({$gt:u})),l(".gte",u=>({$gte:u})),l(".lt",u=>({$lt:u})),l(".lte",u=>({$lte:u})),l(".ne",u=>({$ne:u})),l(".in",u=>u,!0);var f=e.get(a.key+".null");if(f)switch(f=f.toString().trim().toLowerCase(),f){case"y":case"true":case"yes":r(a.key,null);break;default:r(a.key,{$ne:null});break}l(".contains",u=>({$contains:u}),!1,!0),l(".notContains",u=>({$notContains:u}),!1,!0),l(".startsWith",u=>({$startsWith:u}),!1,!0),l(".endsWith",u=>({$endsWith:u}),!1,!0)});let s=e.get("OR");if(s){const l=o(s).map(f=>({$or:f.map(u=>Jt(i,{get:c=>u[c]}))}));l.length==1?t.$or?t.$or.push(l[0].$or):t.$or=l[0].$or:n({$and:l})}if(s=e.get("NOT"),s){let a=o(s);const l=[];for(const f of a)if(Array.isArray(f))for(const u of f)l.push({$not:Jt(i,{get:c=>u[c]})});else l.push({$not:Jt(i,{get:u=>f[u]})});l.length==1&&!t.$not?t=l[0]:n({$and:l})}for(const a in i.entityType){const l=i.entityType[a];if(l&&l.rawFilterInfo&&l.rawFilterInfo.rawFilterTranslator){let f=e.get(Ze+a);if(f!==void 0){const u=c=>{c[En]!=null&&(c=c[En]),r(Ze+a,c)};Array.isArray(f)?f.forEach(c=>u(c)):u(f)}}}return t;function o(a){if(!Array.isArray(a))return[a];const l=[],f=[];for(const u of a)Array.isArray(u)?f.push(u):l.push(u);return f.push(l),f}}class Gt{constructor(e){d(this,"translateCustom");d(this,"commands",[]);d(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 n=>{let r=new Gt(this.translateCustom);return n.__applyToConsumer(r),await r.resolve(),new P(s=>r.applyTo(s))})).then(n=>{t=n})),this.commands.push(n=>n.or(t))}not(e){let t;this.promises.push((async()=>{let n=new Gt(this.translateCustom);e.__applyToConsumer(n),await n.resolve(),t=new P(r=>n.applyTo(r))})()),this.commands.push(n=>n.not(t))}isEqualTo(e,t){this.commands.push(n=>n.isEqualTo(e,t))}isDifferentFrom(e,t){this.commands.push(n=>n.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(n=>n.isGreaterOrEqualTo(e,t))}isGreaterThan(e,t){this.commands.push(n=>n.isGreaterThan(e,t))}isLessOrEqualTo(e,t){this.commands.push(n=>n.isLessOrEqualTo(e,t))}isLessThan(e,t){this.commands.push(n=>n.isLessThan(e,t))}containsCaseInsensitive(e,t){this.commands.push(n=>n.containsCaseInsensitive(e,t))}notContainsCaseInsensitive(e,t){this.commands.push(n=>n.notContainsCaseInsensitive(e,t))}startsWithCaseInsensitive(e,t){this.commands.push(n=>n.startsWithCaseInsensitive(e,t))}endsWithCaseInsensitive(e,t){this.commands.push(n=>n.endsWithCaseInsensitive(e,t))}isIn(e,t){this.commands.push(n=>n.isIn(e,t))}custom(e,t){this.promises.push((async()=>{let n=await this.translateCustom(e,t);n&&(Array.isArray(n)?n.forEach(r=>r.__applyToConsumer(this)):n.__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 xt{constructor(){d(this,"rawValues",{});d(this,"preciseValues",new Proxy(this.rawValues,{get:(e,t)=>{if(t in e){let n=e[t];if(n.bad)return;if(n.values.length>0){const r=oe(n.field);if(r){if(r.type==="reference")return n.values.map(s=>r.toRepo.metadata.idMetadata.getIdFilter(s));throw new Error("Only relations toOne without field are supported.")}return n.values}}}}))}ok(e,...t){let n=this.rawValues[e.key];n?n.values.push(...t.filter(r=>!n.values.includes(r))):this.rawValues[e.key]={field:e,bad:!1,values:[...t]}}notOk(e){let t=this.rawValues[e.key];t?t.bad=!0:this.rawValues[e.key]={field:e,bad:!0,values:[]}}not(e){}or(e){const t=e.map(n=>{let r=new xt;return n.__applyToConsumer(r),r});for(const n of t)for(const r in n.rawValues)if(Object.prototype.hasOwnProperty.call(n.rawValues,r)){const s=n.rawValues[r];s&&(s.bad?this.notOk(s.field):this.ok(s.field,...s.values))}for(const n in this.rawValues)if(Object.prototype.hasOwnProperty.call(this.rawValues,n))for(const r of t)r.rawValues[n]||this.notOk(this.rawValues[n].field)}isEqualTo(e,t){this.ok(e,t)}isDifferentFrom(e,t){this.notOk(e)}isNull(e){this.ok(e,null)}isNotNull(e){this.notOk(e)}isGreaterOrEqualTo(e,t){this.notOk(e)}isGreaterThan(e,t){this.notOk(e)}isLessOrEqualTo(e,t){this.notOk(e)}isLessThan(e,t){this.notOk(e)}containsCaseInsensitive(e,t){this.notOk(e)}notContainsCaseInsensitive(e,t){this.notOk(e)}startsWithCaseInsensitive(e,t){this.notOk(e)}endsWithCaseInsensitive(e,t){this.notOk(e)}isIn(e,t){this.ok(e,...t)}custom(e,t){}databaseCustom(e){}}var to={};const hn=Symbol.for("remult-static1");let Ut={defaultRemultFactory:void 0,remultFactory:void 0,defaultRemult:void 0,asyncContext:void 0,columnsOfType:new Map,allEntities:[],classHelpers:new Map,actionInfo:{allActions:[],runningOnServer:!1,runActionWithoutBlockingUI:i=>i(),startBusyWithProgress:()=>({progress:i=>{},close:()=>{}})},captionTransformer:void 0,defaultDataProvider:()=>{}};typeof process<"u"&&to.IGNORE_GLOBAL_REMULT_IN_TESTS||typeof globalThis[hn]>"u"?(globalThis[hn]=Ut,Ut.remultFactory=()=>$i()):Ut=globalThis[hn];const T=Ut;function $i(){return T.defaultRemult||(T.defaultRemult=T.defaultRemultFactory()),T.defaultRemult}function no(){T.remultFactory=()=>$i()}function Ye(i){const e=i;if(typeof e[Ct]=="function")return e[Ct]();throw Error("Error getting repository internal from "+i)}const Ct=Symbol.for("getInternal");class io{constructor(){d(this,"iAmRemultProxy",!0);d(this,"repoCache",new Map);d(this,"repo",(...e)=>{let t=T,n=this.repoCache.get(e[0]);n||this.repoCache.set(e[0],n=new Map);let r=n.get(e[1]);return r||(r={get fields(){return T.remultFactory().repo(...e).metadata.fields},[Ct](){return t.remultFactory().repo(...e)[Ct]()},relations:s=>t.remultFactory().repo(...e).relations(s),validate:(s,...o)=>t.remultFactory().repo(...e).validate(s,...o),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,o)=>t.remultFactory().repo(...e).findId(s,o),toJson:s=>t.remultFactory().repo(...e).toJson(s),fromJson:(s,o)=>t.remultFactory().repo(...e).fromJson(s,o),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 T.remultFactory().repo(...e).metadata},query:(...s)=>t.remultFactory().repo(...e).query(...s),save:s=>t.remultFactory().repo(...e).save(s),update:(s,o)=>t.remultFactory().repo(...e).update(s,o)},n.set(e[1],r),r)})}get liveQuerySubscriber(){return T.remultFactory().liveQuerySubscriber}set liveQuerySubscriber(e){T.remultFactory().liveQuerySubscriber=e}get liveQueryStorage(){return T.remultFactory().liveQueryStorage}set liveQueryStorage(e){T.remultFactory().liveQueryStorage=e}get liveQueryPublisher(){return T.remultFactory().liveQueryPublisher}set liveQueryPublisher(e){T.remultFactory().liveQueryPublisher=e}call(e,t,...n){return T.remultFactory().call(e,t,...n)}get context(){return T.remultFactory().context}get dataProvider(){return T.remultFactory().dataProvider}set dataProvider(e){T.remultFactory().dataProvider=e}get repCache(){return T.remultFactory().repCache}authenticated(){return T.remultFactory().authenticated()}isAllowed(e){return T.remultFactory().isAllowed(e)}isAllowedForInstance(e,t){return T.remultFactory().isAllowedForInstance(e,t)}clearAllCache(){return T.remultFactory().clearAllCache()}get user(){return T.remultFactory().user}set user(e){T.remultFactory().user=e}get apiClient(){return T.remultFactory().apiClient}set apiClient(e){T.remultFactory().apiClient=e}get subscriptionServer(){return T.remultFactory().subscriptionServer}set subscriptionServer(e){T.remultFactory().subscriptionServer=e}}const Se=new io;function ro(i){return i.replace(/([A-Z])/g," $1").replace(/^./,e=>e.toUpperCase()).replace("Email","eMail").replace(" I D"," ID")}class so{constructor(e,t,n){d(this,"repository");d(this,"isReferenceRelation");d(this,"allowNull");d(this,"storedItem");d(this,"id");this.repository=e,this.isReferenceRelation=t,this.allowNull=n}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:Ye(this.repository)._getCachedByIdAsync(e,!1)}get(e){if(e==null)return null;const t=Ye(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=ee(e,!1);t&&!this.isReferenceRelation?(Ye(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 gi{constructor(e){d(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 n in e){let r=e[n];this.add(n+t,r)}}}const Gi={error500RetryCount:4};function Pt(i){if(!i)return new bi;let e;return e||xi(i)&&(e=new oo(i)),e||typeof i=="function"&&(e=new bi(i)),e}function xi(i){let e=i;return!!(e&&e.get&&e.put&&e.post&&e.delete)}class oo{constructor(e){d(this,"http");this.http=e}async post(e,t){return await Xt(()=>Nt(this.http.post(e,t)))}delete(e){return Nt(this.http.delete(e))}put(e,t){return Nt(this.http.put(e,t))}async get(e){return await Xt(()=>Nt(this.http.get(e)))}}async function Xt(i){var t,n,r,s;let e=0;for(;;)try{return await i()}catch(o){if(((t=o.message)!=null&&t.startsWith("Error occurred while trying to proxy")||(n=o.message)!=null&&n.startsWith("Error occured while trying to proxy")||(r=o.message)!=null&&r.includes("http proxy error")||(s=o.message)!=null&&s.startsWith("Gateway Timeout")||o.status==500)&&e++<Gi.error500RetryCount){await new Promise((a,l)=>{setTimeout(()=>{a({})},500)});continue}throw o}}function Nt(i){let e;return i.toPromise!==void 0?e=i.toPromise():e=i,e.then(t=>t&&(t.status==200||t.status==201)&&t.headers&&t.request&&t.data?t.data:t).catch(async t=>{throw await ao(t)})}async function ao(i){var s,o,a;let e=await i;var t;e.error?t=e.error:e.isAxiosError&&(typeof((s=e.response)==null?void 0:s.data)=="string"?t=e.response.data:t=(o=e==null?void 0:e.response)==null?void 0:o.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 n=e.status;n===void 0&&(n=(a=e.response)==null?void 0:a.status),n!=null&&(t.httpStatusCode=n);var r=Object.assign(t,{});return r}class Xi{constructor(e){d(this,"apiProvider");d(this,"isProxy",!0);this.apiProvider=e}getEntityDataProvider(e){return new lo(()=>{var n;let t=(n=this.apiProvider())==null?void 0:n.url;return t==null&&(t="/api"),t+"/"+e.key},()=>Pt(this.apiProvider().httpClient),e)}async transaction(e){throw new Error("Method not implemented.")}}function Gn(i,e){if(i.include){let t={};for(const n in i.include)if(Object.prototype.hasOwnProperty.call(i.include,n)){let r=i.include[n];if(typeof r=="object"){const s=oe(e.fields.find(n));s&&(r=Gn(r,s.toRepo.metadata))}t[n]=r}i={...i,include:t}}return i.where&&(i={...i,where:P.entityFilterToJson(e,i.where)}),i.load&&(i={...i,load:i.load(e.fields).map(t=>t.key)}),i}class lo{constructor(e,t,n){d(this,"url");d(this,"http");d(this,"entity");this.url=e,this.http=t,this.entity=n}translateFromJson(e){let t={};for(const n of this.entity.fields)t[n.key]=n.valueConverter.fromJson(e[n.key]);return t}translateToJson(e){let t={};for(const n of this.entity.fields)t[n.key]=n.valueConverter.toJson(e[n.key]);return t}async count(e){const{run:t}=this.buildFindRequest({where:e});return t("count").then(n=>+n.count)}async deleteMany(e){const{run:t}=this.buildFindRequest({where:e},"delete");return t("deleteMany").then(n=>+n.deleted)}async updateMany(e,t){const{run:n}=this.buildFindRequest({where:e},"put");return n("updateMany",this.toJsonOfIncludedKeys(t)).then(r=>+r.updated)}find(e){let{run:t}=this.buildFindRequest(e);return t().then(n=>n.map(r=>this.translateFromJson(r)))}buildFindRequest(e,t){t||(t="get");let n=new gi(this.url()),r;if(e){if(e.where&&(r=e.where.toJson(),fo(r,n)&&(r=void 0)),e.orderBy&&e.orderBy.Segments){let o="",a="",l=!1;e.orderBy.Segments.forEach(f=>{o.length>0&&(o+=",",a+=","),o+=f.field.key,a+=f.isDescending?"desc":"asc",f.isDescending&&(l=!0)}),o&&n.add("_sort",o),l&&n.add("_order",a)}e.limit&&n.add("_limit",e.limit),e.page&&n.add("_page",e.page)}const s=(o,a)=>{let l=new gi(n.url);return!o&&r&&(o="get"),o&&l.add("__action",o),r?(a={set:a,where:r},this.http().post(l.url,a)):this.http()[t](l.url,a)};return{createKey:()=>JSON.stringify({url:n,filterObject:r}),run:s,subscribe:async o=>({result:await s(co+o),unsubscribe:async()=>T.actionInfo.runActionWithoutBlockingUI(()=>this.http().post(this.url()+"?__action=endLiveQuery",{id:o}))})}}update(e,t){return this.http().put(this.url()+(e!=""?"/"+encodeURIComponent(e):"?__action=emptyId"),this.toJsonOfIncludedKeys(t)).then(n=>this.translateFromJson(n))}toJsonOfIncludedKeys(e){let t={},n=Object.keys(e);for(const r of this.entity.fields)n.includes(r.key)&&(t[r.key]=r.valueConverter.toJson(e[r.key]));return t}async delete(e){if(e=="")await this.deleteMany(P.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(n=>this.translateFromJson(n)))}}class bi{constructor(e){d(this,"fetch");this.fetch=e}async get(e){return await Xt(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 Xt(()=>this.myFetch(e,{method:"post",body:JSON.stringify(t)}))}myFetch(e,t){const n={};if(t!=null&&t.body&&(n["Content-type"]="application/json"),typeof window<"u"&&typeof window.document<"u"&&typeof(window.document.cookie!=="undefined"))for(const r of window.document.cookie.split(";"))r.trim().startsWith("XSRF-TOKEN=")&&(n["X-XSRF-TOKEN"]=r.split("=")[1]);return(this.fetch||fetch)(e,{credentials:"include",method:t==null?void 0:t.method,body:t==null?void 0:t.body,headers:n}).then(r=>uo(r)).catch(async r=>{throw await r})}}function uo(i){if(i.status!=204){if(i.status>=200&&i.status<300)return i.json();throw i.json().then(e=>({...e,message:e.message||i.statusText,url:i.url,status:i.status})).catch(()=>{throw{message:i.statusText,url:i.url,status:i.status}})}}function fo(i,e){for(const t in i)if(Object.prototype.hasOwnProperty.call(i,t)){const n=i[t];if(Array.isArray(n)&&(n.length>0&&typeof n[0]=="object"||n.length>10)||t==="NOT")return!1}for(const t in i)if(Object.prototype.hasOwnProperty.call(i,t)){const n=i[t];Array.isArray(n)?t.endsWith(".in")?e.add(t,JSON.stringify(n)):n.forEach(r=>e.add(t,r)):t.startsWith(Ze)?e.add(t,JSON.stringify(n)):e.add(t,n)}return!0}const co="liveQuery-";var Lt,ho=new Uint8Array(16);function po(){if(!Lt&&(Lt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Lt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Lt(ho)}const yo=/^(?:[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 mo(i){return typeof i=="string"&&yo.test(i)}var ce=[];for(var pn=0;pn<256;++pn)ce.push((pn+256).toString(16).substr(1));function wo(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(ce[i[e+0]]+ce[i[e+1]]+ce[i[e+2]]+ce[i[e+3]]+"-"+ce[i[e+4]]+ce[i[e+5]]+"-"+ce[i[e+6]]+ce[i[e+7]]+"-"+ce[i[e+8]]+ce[i[e+9]]+"-"+ce[i[e+10]]+ce[i[e+11]]+ce[i[e+12]]+ce[i[e+13]]+ce[i[e+14]]+ce[i[e+15]]).toLowerCase();if(!mo(t))throw TypeError("Stringified UUID is invalid");return t}function Sn(i,e,t){i=i||{};var n=i.random||(i.rng||po)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,wo(n)}class ke{constructor(...e){d(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 ke;for(const t of this.Segments)e.Segments.push({field:t.field,isDescending:!t.isDescending});return e}compare(e,t,n){n||(n=s=>s.key);let r=0;for(let s=0;s<this.Segments.length;s++){let o=this.Segments[s],a=vi(e[n(o.field)]),l=vi(t[n(o.field)]);if(a>l?r=1:a<l&&(r=-1),r!=0)return o.isDescending&&(r*=-1),r}return r}static translateOrderByToSort(e,t){let n=new ke;if(t){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const s=t[r];let o=e.fields.find(r);const a=l=>{switch(s){case"desc":n.Segments.push({field:l,isDescending:!0});break;case"asc":n.Segments.push({field:l})}};if(o){const l=oe(o);if((l==null?void 0:l.type)==="toOne"){const f=l.options;if(typeof f.field=="string")a(e.fields.find(f.field));else if(f.fields){for(const u in f.fields)if(Object.prototype.hasOwnProperty.call(f.fields,u)){const c=f.fields[u];a(e.fields.find(c.toString()))}}}else a(o)}}}return n}static createUniqueSort(e,t){(!t||Object.keys(t).length===0)&&e.options.defaultOrderBy&&(t=ke.translateOrderByToSort(e,e.options.defaultOrderBy)),t||(t=new ke);for(const n of e.idMetadata.fields)t.Segments.find(r=>r.field==n)||t.Segments.push({field:n});return t}static createUniqueEntityOrderBy(e,t){(!t||Object.keys(t).length===0)&&(t=e.options.defaultOrderBy),t?t={...t}:t={};for(const n of e.idMetadata.fields)t[n.key]||(t[n.key]="asc");return t}}function vi(i){return i==null||i==null?i:i.id!==void 0?i.id:i}const yn="stream";class go{constructor(e,t,n){d(this,"repo");d(this,"query");d(this,"queryChannel");d(this,"subscribeCode");d(this,"unsubscribe",()=>{});d(this,"defaultQueryState",[]);d(this,"listeners",[]);d(this,"id",Sn());this.repo=e,this.query=t,this.queryChannel=`users:${n}:queries:${this.id}`,this.id=this.queryChannel}sendDefaultState(e){e(this.createReducerType(()=>[...this.defaultQueryState],this.allItemsMessage(this.defaultQueryState)))}async setAllItems(e){const t=await Ye(this.repo)._fromJsonArray(e,this.query.options);this.forListeners(n=>{n(()=>t)},this.allItemsMessage(t))}allItemsMessage(e){return[{type:"all",data:e}]}forListeners(e,t){e(n=>{if(this.defaultQueryState=n(this.defaultQueryState),t.find(r=>r.type==="add"||r.type==="replace")&&this.query.options.orderBy){const r=ke.translateOrderByToSort(this.repo.metadata,this.query.options.orderBy);this.defaultQueryState.sort((s,o)=>r.compare(s,o))}});for(const n of this.listeners)e(r=>{n.next(this.createReducerType(r,t))})}createReducerType(e,t){return{applyChanges:e,changes:t,items:this.defaultQueryState}}async handle(e){{let t=e.filter(({type:r})=>r=="add"||r=="replace"),n=await Ye(this.repo)._fromJsonArray(t.map(r=>r.data.item),this.query.options);for(let r=0;r<t.length;r++){const s=t[r];s.data.item=n[r]}}this.forListeners(t=>{t(n=>{n||(n=[]);for(const r of e)switch(r.type){case"all":this.setAllItems(r.data);break;case"replace":{n=n.map(s=>this.repo.metadata.idMetadata.getId(s)===r.data.oldId?r.data.item:s);break}case"add":n=n.filter(s=>this.repo.metadata.idMetadata.getId(s)!==this.repo.metadata.idMetadata.getId(r.data.item)),n.push(r.data.item);break;case"remove":n=n.filter(s=>this.repo.metadata.idMetadata.getId(s)!==r.data.id);break}return n})},e)}}const bo="_liveQueryKeepAlive";class vo{constructor(e,t){d(this,"apiProvider");d(this,"getUserId");d(this,"queries",new Map);d(this,"channels",new Map);d(this,"client");d(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 n=()=>{};const r=await this.openIfNoOpened();try{let s=this.channels.get(e);if(!s){this.channels.set(e,s=new _o);try{s.unsubscribe=await r.subscribe(e,o=>this.wrapMessageHandling(()=>s.handle(o)),o=>{t.error(o)})}catch(o){throw t.error(o),o}}s.listeners.push(t),n=()=>{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()=>{n(),n=()=>{}}}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,n){let r=!0,s=()=>{r=!1};return this.runPromise(Ye(e)._buildEntityDataProviderFindOptions(t).then(o=>{if(!r)return;const{createKey:a,subscribe:l}=new Xi(this.apiProvider).getEntityDataProvider(e.metadata).buildFindRequest(o),f=a();let u=this.queries.get(f);u?u.sendDefaultState(n.next):(this.queries.set(f,u=new go(e,{entityKey:e.metadata.key,options:t},this.getUserId())),u.subscribeCode=()=>{u.unsubscribe&&(u.unsubscribe(),u.unsubscribe=()=>{}),this.runPromise(this.subscribeChannel(u.queryChannel,{next:c=>this.runPromise(u.handle(c)),complete:()=>{},error:c=>{u.listeners.forEach(h=>h.error(c))}}).then(c=>{if(u.listeners.length==0){c();return}this.runPromise(l(u.queryChannel).then(h=>{if(u.listeners.length===0){h.unsubscribe(),c();return}this.runPromise(u.setAllItems(h.result)),u.unsubscribe=()=>{u.unsubscribe=()=>{},c(),this.runPromise(h.unsubscribe())}}).catch(h=>{u.listeners.forEach(p=>p.error(h)),c(),this.queries.delete(f)}))})).catch(c=>{u.listeners.forEach(h=>h.error(c))})},u.subscribeCode()),u.listeners.push(n),s=()=>{u.listeners.splice(u.listeners.indexOf(n),1),n.complete(),u.listeners.length==0&&(this.queries.delete(f),u.unsubscribe()),this.closeIfNoListeners()}}).catch(o=>{n.error(o)})),()=>{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 n=await this.runPromise(await T.actionInfo.runActionWithoutBlockingUI(()=>Pt(t.httpClient).post(t.url+"/"+bo,e)));for(const r of n)for(const s of this.queries.values())s.queryChannel===r&&s.subscribeCode()}},3e4),this.runPromise(this.client=this.apiProvider().subscriptionClient.openConnection(()=>{for(const e of this.queries.values())e.subscribeCode()})))}}class _o{constructor(){d(this,"unsubscribe",()=>{});d(this,"listeners",[])}async handle(e){for(const t of this.listeners)t.next(e)}}class xn{openConnection(e){let t;const n=new Map,r=Pt(Se.apiClient.httpClient);let s=!1,o;const a={close(){o.close()},async subscribe(u,c){let h=n.get(u);return h||(n.set(u,h=[]),await f(u)),h.push(c),()=>{h.splice(h.indexOf(c,1)),h.length==0&&(T.actionInfo.runActionWithoutBlockingUI(()=>r.post(Se.apiClient.url+"/"+yn+"/unsubscribe",{channel:u,clientId:t})),n.delete(u))}}},l=()=>new Promise(u=>{h();let c=0;function h(){o&&o.close(),o=xn.createEventSource(Se.apiClient.url+"/"+yn),o.onmessage=p=>{let y=JSON.parse(p.data);const _=n.get(y.channel);_&&_.forEach(w=>w(y.data))},o.onerror=p=>{console.error("Live Query Event Source Error",p),o.close(),c++<Gi.error500RetryCount&&setTimeout(()=>{h()},500)},o.addEventListener("connectionId",async p=>{if(t=p.data,s){for(const y of n.keys())await f(y);e()}else s=!0,u(a)})}});return l();async function f(u){await T.actionInfo.runActionWithoutBlockingUI(()=>r.post(Se.apiClient.url+"/"+yn+"/subscribe",{channel:u,clientId:t}))===ko&&await l()}}static createEventSource(e){return new EventSource(e,{withCredentials:!0})}}const ko="client connection not found",Cn=Symbol.for("serverActionField");class Io{constructor(e){d(this,"remultObjectStorage");this.remultObjectStorage=e}static enable(){T.remultFactory=()=>{const e=T.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(){no()}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 n;const t=(n=this.remultObjectStorage)==null?void 0:n.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()}}T.asyncContext||(T.asyncContext=new Io(void 0));function Tn(){return T.actionInfo.runningOnServer||!Se.dataProvider.isProxy}class Pe{constructor(e){d(this,"repo",(e,t)=>{t===void 0&&(t=this.dataProvider);let n=this.repCache.get(t);n||this.repCache.set(t,n=new Map);let r=n.get(e);return r||(n.set(e,r=new Xn(e,this,t,Fo(e,this))),zs(r,this,t)),r});d(this,"user");d(this,"dataProvider",new Xi(()=>this.apiClient));d(this,"repCache",new Map);d(this,"liveQueryStorage");d(this,"subscriptionServer");d(this,"liveQueryPublisher",{itemChanged:async()=>{}});d(this,"liveQuerySubscriber",new vo(()=>this.apiClient,()=>{var e;return(e=this.user)==null?void 0:e.id}));d(this,"context",{});d(this,"apiClient",{url:"/api",subscriptionClient:new xn});if(e&&e.getEntityDataProvider){this.dataProvider=e;return}if(xi(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,n;if(e!=null){if(e instanceof Array){for(const r of e)if(this.isAllowed(r)===!0)return!0;return!1}return typeof e=="function"?e(this):typeof e=="boolean"?e:!!(typeof e=="string"&&(n=(t=this.user)==null?void 0:t.roles)!=null&&n.includes(e.toString()))}}isAllowedForInstance(e,t){if(Array.isArray(t)){for(const n of t)if(this.isAllowedForInstance(e,n))return!0}else return typeof t=="function"?t(e,this):this.isAllowed(t)}call(e,t,...n){const r=e[Cn];if(!r.doWork)throw Error("The method received is not a valid backend method");return r.doWork(n,t,this.apiClient.url,Pt(this.apiClient.httpClient))}clearAllCache(){this.repCache.clear()}}d(Pe,"onFind",(e,t)=>{}),d(Pe,"entityRefInit");T.defaultRemultFactory=()=>new Pe;class Oo{constructor(){d(this,"classes",new Map)}}const Eo={defaultPageSize:200};async function zi(i,e){const t=new So(i.liveQueryPublisher);let n=!0;const r=i.dataProvider;try{await i.dataProvider.transaction(async s=>{i.dataProvider=s,i.liveQueryPublisher=t,await e(s),n=!0}),n&&await t.flush()}finally{i.dataProvider=r}}class So{constructor(e){d(this,"orig");d(this,"transactionItems",new Map);this.orig=e}async itemChanged(e,t){let n=this.transactionItems.get(e);n||this.transactionItems.set(e,n=[]);for(const r of t)if(r.oldId!==void 0){const s=n.find(o=>o.id===r.oldId);s!==void 0?(r.deleted&&(s.deleted=!0),r.id!=s.id&&(s.id=r.id)):n.push(r)}else n.push(r)}async flush(){for(const e of this.transactionItems.keys())await this.orig.itemChanged(e,this.transactionItems.get(e))}}function An(i,e){return e&&Object.assign(i,e),i}class De{}d(De,"number","number"),d(De,"date","date"),d(De,"checkbox","checkbox"),d(De,"password","password"),d(De,"email","email"),d(De,"tel","tel"),d(De,"time","time");const L=class L{};d(L,"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=>L.Date.fromJson(e),toInput:e=>L.Date.toJson(e),displayValue:e=>e?e.toLocaleString():""}),d(L,"DateOnly",{fromInput:e=>L.DateOnly.fromJson(e),toInput:e=>L.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:De.date,toDb:e=>e?L.DateOnly.fromJson(L.DateOnly.toJson(e)):null,fromDb:e=>L.Date.fromDb(e),fieldTypeInDb:"date",displayValue:e=>e?e.toLocaleDateString(void 0):""}),d(L,"DateOnlyString",{...L.DateOnly,toDb:e=>{let t=L.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))}}),d(L,"Boolean",{toDb:e=>e,inputType:De.checkbox,fromDb:e=>L.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=>L.Boolean.fromJson(e),toInput:e=>L.Boolean.toJson(e)}),d(L,"Number",{fromDb:e=>{if(e===null)return null;if(e!==void 0)return+e},toDb:e=>e,fromJson:e=>L.Number.fromDb(e),toJson:e=>L.Number.toDb(e),fromInput:(e,t)=>{let n=+e;if(e!=null)return n},toInput:(e,t)=>(e==null?void 0:e.toString())??"",inputType:De.number}),d(L,"String",{fromDb:st,toDb:st,fromJson:st,toJson:st,fromInput:st,toInput:st}),d(L,"Integer",{...L.Number,toJson:e=>{let t=L.Number.toDb(e);return t&&+(+t).toFixed(0)},toDb:e=>L.Integer.toJson(e),fieldTypeInDb:"integer"}),d(L,"Default",{fromJson:e=>e,toJson:e=>e,fromDb:e=>L.JsonString.fromDb(e),toDb:e=>L.JsonString.toDb(e),fromInput:e=>L.Default.fromJson(e),toInput:e=>L.Default.toJson(e),displayValue:e=>e+"",fieldTypeInDb:"",inputType:"text"}),d(L,"JsonString",{fromJson:e=>e,toJson:e=>e,fromDb:e=>e==null?null:e?JSON.parse(L.JsonString.fromJson(e)):void 0,toDb:e=>e!==void 0?e===null?null:JSON.stringify(L.JsonString.toJson(e)):void 0,fromInput:e=>L.JsonString.fromJson(e),toInput:e=>L.JsonString.toJson(e)}),d(L,"JsonValue",{fromJson:e=>e,toJson:e=>e,fromDb:e=>e,toDb:e=>e,fromInput:e=>L.JsonString.fromJson(e),toInput:e=>L.JsonString.toJson(e),fieldTypeInDb:"json"});let pe=L;function st(i){return i==null?i:typeof i!="string"?i.toString():i}function _i(i,e,t){let n=P.fromEntityFilter(i,e);const r=()=>{};n&&n.__applyToConsumer({custom:r,databaseCustom:r,containsCaseInsensitive:r,notContainsCaseInsensitive:r,startsWithCaseInsensitive:r,endsWithCaseInsensitive:r,isDifferentFrom:r,isEqualTo:(s,o)=>{t[s.key]=o},isGreaterOrEqualTo:r,isGreaterThan:r,isIn:r,isLessOrEqualTo:r,isLessThan:r,isNotNull:r,isNull:r,not:r,or:r})}class ki{constructor(){d(this,"entityLoaders",new Map);d(this,"promises",[])}load(e,t){let n=this.entityLoaders.get(e.entityType);n||this.entityLoaders.set(e.entityType,n=new Co(e));const r=n.find(t);return this.promises.push(r),r}async resolveAll(){for(const t of this.entityLoaders.values())for(const n of t.queries.values())n.resolve();if(this.promises.length===0)return;const e=this.promises;this.promises=[],await Promise.all(e),await this.resolveAll()}}class Co{constructor(e){d(this,"rel");d(this,"queries",new Map);this.rel=e}find(e){const{where:t,...n}=Gn(e,this.rel.metadata),r=JSON.stringify(n);let s=this.queries.get(r);return s||this.queries.set(r,s=new To(this.rel)),s.find(e,t)}}class To{constructor(e){d(this,"rel");d(this,"pendingInStatements",new Map);d(this,"whereVariations",new Map);this.rel=e}find(e,t){const n=JSON.stringify(t);let r=this.whereVariations.get(n);if(!r){const s=Object.keys(t);if(s.length===1&&typeof t[s[0]]!="object"&&!e.limit){let o=this.pendingInStatements.get(s[0]);o||this.pendingInStatements.set(s[0],o=new Ao(this.rel,s[0],e)),this.whereVariations.set(n,r={result:o.find(t)})}else this.whereVariations.set(n,r={result:this.rel.find(e)})}return r.result}resolve(){const e=[...this.pendingInStatements.values()];this.pendingInStatements.clear();for(const t of e)t.resolve()}}class Ao{constructor(e,t,n){d(this,"rel");d(this,"key");d(this,"options");d(this,"values",new Map);this.rel=e,this.key=t,this.options=n}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(r=>r.value)},t.limit=1e3,t.page=1;let n=[];try{for(;;){const r=await this.rel.find(t);if(n.push(...r),r.length<t.limit)break;t.page++}for(const r of this.values.values())r.resolve(n.filter(s=>{const a=ee(s).fields.find(this.key),l=oe(a.metadata),f=(l==null?void 0:l.type)==="reference"?a.getId():s[this.key];return r.value==f}))}catch(r){for(const s of this.values.values())s.reject(r)}}find(e){const t=e[this.key];let n=this.values.get(t);if(!n){let r,s,o=new Promise((a,l)=>{r=a,s=l});this.values.set(t,n={value:t,resolve:r,reject:s,result:o})}return n.result}}const he=class he{};d(he,"required",_t(async(e,t)=>t.value!=null&&t.value!=null&&t.value!=="","Should not be empty")),d(he,"unique",_t(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")),d(he,"uniqueOnBackend",_t(async(e,t)=>t.isBackend()&&(t.isNew||t.valueChanged())?await t.entityRef.repository.count({[t.metadata.key]:t.value})==0:!0,he.unique.defaultMessage)),d(he,"regex",wt((e,t)=>t.test(e))),d(he,"email",Wt(e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),"Invalid Email")),d(he,"url",Wt(e=>!!new URL(e),"Invalid Url")),d(he,"in",wt((e,t)=>t.includes(e),e=>`Value must be one of: ${e.map(t=>typeof t=="object"?(t==null?void 0:t.id)!==void 0?t==null?void 0:t.id:t==null?void 0:t.toString():t).join(", ")}`)),d(he,"notNull",Wt(e=>e!=null,"Should not be null")),d(he,"enum",wt((e,t)=>Object.values(t).includes(e),e=>`Value must be one of ${Vt(e).join(", ")}`)),d(he,"relationExists",_t(async(e,t)=>t.valueIsNull()||!t.isBackend()?!0:!!await t.load(),"Relation value does not exist")),d(he,"maxLength",wt((e,t)=>e.length<=t,e=>`Value must be at most ${e} characters`)),d(he,"minLength",wt((e,t)=>e.length>=t,e=>`Value must be at least ${e} characters`)),d(he,"defaultMessage","Invalid value");let Be=he;function _t(i,e){const t=async(r,s,o)=>{const a=await i(r,s);typeof a=="string"&&a.length>0?s.error=a:a||(s.error=typeof o=="function"&&o(r,s,void 0)||o||typeof e=="function"&&e(r,s,void 0)||e||Be.defaultMessage)},n=(r,s,o)=>typeof r=="string"||r==="function"||r===void 0&&s===void 0?async(a,l,f)=>await t(a,l,r||f):t(r,s,o);return Object.defineProperty(n,"defaultMessage",{get:()=>e,set:r=>{e=r},enumerable:!0}),Object.assign(n,{withMessage:r=>async(s,o)=>n(s,o,r)})}function Wt(i,e){return _t((t,n)=>n.value===void 0||n.value===null?!0:i(n.value),e)}function wt(i,e){const t=Po((n,r,s)=>r.value===void 0||r.value===null?!0:i(r.value,s),(n,r,s)=>typeof e=="function"&&e(s)||e,!0);return Object.assign((n,r)=>t(n,r),{get defaultMessage(){return e},set defaultMessage(n){e=n}})}function Po(i,e,t=!1){return Object.assign((r,s)=>async(o,a)=>{const l=await i(o,a,r);typeof l=="string"?a.error=l:l||(a.error=s?typeof s=="function"?t?s(r):s(o,a,r):s:e?typeof e=="function"?e(o,a,r):e:Be.defaultMessage)},{get defaultMessage(){return e},set defaultMessage(r){e=r}})}function Vt(i){return Object.values(i).filter(e=>typeof i[e]!="number")}function Ht(i,e,t=!1){if(!e)return i;const n=Array.isArray(e)?e:[e],r=Array.isArray(i)?i:i?[i]:[];return t?[...n,...r]:[...r,...n]}function It(i,e){return typeof i[e]<"u"}class Xn{constructor(e,t,n,r,s){d(this,"_entity");d(this,"_remult");d(this,"_dataProvider");d(this,"_info");d(this,"_defaultFindOptions");d(this,"__edp");d(this,"_idCache",new Map);d(this,"listeners");d(this,"_cache",new Map);this._entity=e,this._remult=t,this._dataProvider=n,this._info=r,this._defaultFindOptions=s}_notFoundError(e){return{message:`id ${e} not found in entity ${this.metadata.key}`,httpStatusCode:404}}[Ct](){return this}async _createAfterFilter(e,t){let n=new Map;for(const o of ke.translateOrderByToSort(this.metadata,e).Segments){let a=t[o.field.key];n.set(o.field.key,a)}let r={$or:[]},s=[];for(const o of ke.translateOrderByToSort(this.metadata,e).Segments){let a={};for(const l of s)a[l.key]=n.get(l.key);s.push(o.field),o.isDescending?a[o.field.key]={$lt:n.get(o.field.key)}:a[o.field.key]={$gt:n.get(o.field.key)},r.$or.push(a)}return r}relations(e){return new Proxy({},{get:(t,n)=>{const r=this.fields.find(n),s=oe(r);if(!s)throw Error(n+" is not a relation");const{toRepo:o,returnNull:a,returnUndefined:l}=this._getFocusedRelationRepo(r,e);return s.type==="toMany"?o:{findOne:f=>a?Promise.resolve(null):l?Promise.resolve(void 0):o.findFirst({},f)}}})}_getFocusedRelationRepo(e,t){const n=oe(e);let r=n.toRepo,{findOptions:s,returnNull:o,returnUndefined:a}=this._findOptionsBasedOnRelation(n,e,void 0,t,r);return{toRepo:new Xn(r._entity,r._remult,r._dataProvider,r._info,s),returnNull:o,returnUndefined:a}}get _edp(){return this.__edp?this.__edp:this.__edp=this._dataProvider.getEntityDataProvider(this.metadata)}_getCachedById(e,t){e=e+"",this._getCachedByIdAsync(e,t);let n=this._idCache.get(e);if(!(n instanceof Promise))return n}async _getCachedByIdAsync(e,t){e=e+"";let n=this._idCache.get(e);if(n instanceof Promise)return await n;if(this._idCache.has(e))return n;if(t)return;this._idCache.set(e,void 0);let r=this.findId(e).then(s=>(s===void 0?n=null:n=s,this._idCache.set(e,n),n));return this._idCache.set(e,r),await r}_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 qo(e,this)}getEntityRef(e){let t=e[Xe];return t||(this._fixTypes(e),t=new Bt(this._info,e,this,this._edp,this._remult,!0),Object.defineProperty(e,Xe,{get:()=>t}),t.saveOriginalData()),t}async delete(e){const t=ee(e,!1);if(t)return t.delete();if(typeof e=="string"||typeof e=="number"){if(this._dataProvider.isProxy)return this._edp.delete(e);{let r=await this.findId(e);if(!r)throw this._notFoundError(e);return await ee(r).delete()}}let n=this._getRefForExistingRow(e,void 0);return this._dataProvider.isProxy||await n.reload(),n.delete()}async insert(e){if(Array.isArray(e))if(this._dataProvider.isProxy){let t=[],n=[];for(const r of e){let s=ee(e,!1);if(s){if(!s.isNew())throw"Item is not new"}else s=await this.getEntityRef(this.create(r));t.push(s),n.push(await s.buildDtoForInsert())}return Ot(await this._edp.insertMany(n),(r,s)=>t[s].processInsertResponseDto(r))}else{let t=[];for(const n of e)t.push(await this.insert(n));return t}else{let t=ee(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 n=ee(e,!1);if(n||(n=this.getEntityRef({...e})),!t||t.length===0)return await n.validate();{n.__clearErrorsAndReportChanged();let r=!1;for(const s of t)await n.fields.find(s).validate()||(r=!0);return r?n.buildErrorInfoObject():void 0}}}async updateMany({where:e,set:t}){if(P.throwErrorIfFilterIsEmpty(e,"updateMany"),this._dataProvider.isProxy)return this._edp.updateMany(await this._translateWhereToFilter(e),t);{let n=0;for await(const r of this.query({where:e}))An(r,t),await ee(r).save(),n++;return n}}async update(e,t){{let r=ee(t,!1);if(r)return await r.save()}{let r=ee(e,!1);if(r)return An(e,t),r.save()}let n;if(typeof e=="object"?(n=this._getRefForExistingRow(e,this.metadata.idMetadata.getId(e)),Object.assign(n.instance,t)):n=this._getRefForExistingRow(t,e),this._dataProvider.isProxy)return await n.save(Object.keys(t));{const r=await n.reload();if(!r)throw this._notFoundError(n.id);for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){let o=n.fields[s];if(t[s]===void 0&&oe(o.metadata))continue;o&&(r[s]=t[s])}return await this._fixTypes(r),await n.save()}}_getRefForExistingRow(e,t){let n=ee(e,!1);if(!n){const r=new this._entity(this._remult);for(const o of this._fieldsOf(e)){const a=o.key;r[a]=e[a]}this._fixTypes(r);let s=new Bt(this._info,r,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(),n=s,Object.defineProperty(r,Xe,{get:()=>s})}return n}async save(e){if(Array.isArray(e))return Ot(e,t=>this.save(t));{let t=ee(e,!1);if(t)return await t.save();if(e instanceof nr)return await this.getEntityRef(e).save();{let n=this.metadata.idMetadata.getId(e);return n===void 0?this.insert(e):this.update(n,e)}}}liveQuery(e){return e||(e={}),{subscribe:t=>{let n=t;return typeof t=="function"&&(n={next:t,complete:()=>{},error:()=>{}}),n.error??(n.error=()=>{}),n.complete??(n.complete=()=>{}),this._remult.liveQuerySubscriber.subscribe(this,e,n)}}}async _rawFind(e,t=!1,n){e||(e={}),this._defaultFindOptions&&(e={...this._defaultFindOptions,...e});let r=await this._buildEntityDataProviderFindOptions(e);t&&(delete r.orderBy,delete r.limit),Pe.onFind(this._info,e);const s=await this._edp.find(r);return await this._loadManyToOneForManyRows(s,e,n)}async find(e,t=!1){const n=new ki,r=await this._rawFind(e,t,n);return await n.resolveAll(),r}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=ke.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 n=new ki,r=await this._loadManyToOneForManyRows(e.map(s=>{let o={};for(const a of this.metadata.fields.toArray())o[a.key]=a.valueConverter.fromJson(s[a.key]);return o}),t,n);return await n.resolveAll(),r}async _loadManyToOneForManyRows(e,t,n){var a;let r;t!=null&&t.load&&(r=t.load(this.metadata.fields));for(const l of this.metadata.fields)if(Ie(l.valueType,!1)&&!oe(l)){let c=!l.options.lazy;if(r!==void 0&&(c=r.includes(l)),c){let h=this._remult.repo(l.valueType),p=[];for(const y of e){let _=y[l.key];_!=null&&!p.includes(_)&&!h._idCache.has(_+"")&&p.push(_)}p.length>0&&await s(h,p)}}async function s(l,f){let u=await l.find({where:l.metadata.idMetadata.getIdFilter(...f)},!0);for(const c of u)l._addToCache(c)}let o=await Ot(e,async l=>await this._mapRawDataToResult(l,r));for(const l of this.metadata.fields){let f=oe(l),u=l.options.defaultIncluded;const c=(a=t==null?void 0:t.include)==null?void 0:a[l.key];if(c!==void 0&&(u=c),f&&u){const h=f.toRepo;for(const p of o){let{findOptions:y,returnNull:_}=this._findOptionsBasedOnRelation(f,l,u,p,h);const w=l.key;if(_)p[w]=null;else{const g=f.toEntity,k=h;n.load({entityType:g,find:E=>k._rawFind(E,!1,n),metadata:k.metadata},y).then(E=>{E.length==0&&f.type=="toOne"||(p[w]=f.type!=="toMany"?E.length==0?null:E[0]:E)})}}}}return o}_findOptionsBasedOnRelation(e,t,n,r,s){let o=!1,a=!1,l=[],f={},u=[];typeof e.options.findOptions=="function"?u.push(e.options.findOptions(r)):typeof e.options.findOptions=="object"&&u.push(e.options.findOptions),typeof n=="object"&&u.push(n);for(const p of u){p.where&&l.push(p.where);for(const y of["limit","include","orderBy"])p[y]&&(f[y]=p[y])}const c=e.getFields(),h=p=>{let y=e.type==="reference"?ee(r).fields.find(t.key).getId():r[p];return(e.type==="toOne"||e.type==="reference")&&(y===null?o=!0:y===void 0?a=!0:e.type==="reference"&&typeof y=="object"&&(y=s.metadata.idMetadata.getId(y))),y};c.compoundIdField&&(e.type==="toMany"?l.push({[c.compoundIdField]:this.metadata.idMetadata.getId(r)}):l.push(s.metadata.idMetadata.getIdFilter(h(c.compoundIdField))));for(const p in c.fields)Object.prototype.hasOwnProperty.call(c.fields,p)&&l.push({[p]:h(c.fields[p])});return f.where={$and:l},(e.type==="toOne"||e.type==="reference")&&f.orderBy&&(f.limit=1),{findOptions:f,returnNull:o,returnUndefined:a}}async _mapRawDataToResult(e,t){let n=new this._entity(this._remult),r=new Bt(this._info,n,this,this._edp,this._remult,!1);return Object.defineProperty(n,Xe,{get:()=>r}),await r.loadDataFrom(e,t),r.saveOriginalData(),n}toJson(e){return e==null?e:Array.isArray(e)?e.map(t=>this.toJson(t)):typeof e.then=="function"?e.then(t=>this.toJson(t)):this.getEntityRef(e).toApiJson(!0)}fromJson(e,t){if(e==null)return e;if(Array.isArray(e))return e.map(r=>this.fromJson(r,t));let n=new this._entity(this._remult);for(const r of this._fieldsOf(e)){const s=r.key;if(Ie(r.valueType,!1)){let a=e[r.key];typeof a=="string"||typeof a=="number"?n[s]=a:n[s]=this._remult.repo(r.valueType).fromJson(a)}else e[s]!==void 0&&(n[s]=r.valueConverter.fromJson(e[r.key]))}if(this._fixTypes(n),t)return this.create(n);{let r=new Bt(this._info,n,this,this._edp,this._remult,!1);return Object.defineProperty(n,Xe,{get:()=>r}),r.saveOriginalData(),n}}async count(e){return this._edp.count(await this._translateWhereToFilter(e))}async deleteMany({where:e}){if(P.throwErrorIfFilterIsEmpty(e,"deleteMany"),this._dataProvider.isProxy)return this._edp.deleteMany(await this._translateWhereToFilter(e));{let t=0;for await(const n of this.query({where:e}))await ee(n).delete(),t++;return t}}async findOne(e,t=!1){let n,r,s=e??{};if(s.useCache){let o=Gn(s,this.metadata),a=JSON.stringify(o);if(r=this._cache.get(a),r!==void 0)if(r.value&&this.getEntityRef(r.value).wasDeleted())r=void 0,this._cache.delete(a);else return r.promise;else r={value:void 0,promise:void 0},this._cache.set(a,r)}return n=this.find({...s,limit:1},t).then(async o=>{let a;return o.length>0&&(a=o[0]),!a&&s.createIfNotFound&&(a=this.create(),s.where&&await _i(this.metadata,s.where,a)),a}),r&&(r.promise=n=n.then(o=>(r.value=o,o))),n}async findFirst(e,t,n=!1){if(t||(t={}),e)if(t.where){let r=t.where;t.where={$and:[r,e]}}else t.where=e;return this.findOne(t,n)}_fieldsOf(e){let t=Object.keys(e);return this.metadata.fields.toArray().filter(n=>t.includes(n.key))}create(e){var n;let t=new this._entity(this._remult);if(e){for(const r of this._fieldsOf(e)){const s=r.key;t[s]=e[s]}this._fixTypes(t)}return(n=this._defaultFindOptions)!=null&&n.where&&(_i(this.metadata,this._defaultFindOptions.where,t),this._fixTypes(t)),this.getEntityRef(t),t}async _fixTypes(e){for(const t of this._fieldsOf(e)){const n=e[t.key];if(n!=null)if(t.valueType===Date&&!(n instanceof Date))e[t.key]=t.valueConverter.fromJson(t.valueConverter.toJson(n));else for(const[r,s]of[[String,"string"],[Number,"number"],[Boolean,"boolean"]])t.valueType===r&&typeof n!==s&&(e[t.key]=t.valueConverter.fromJson(t.valueConverter.toJson(n)))}return e}findId(e,t){if(e==null)return Promise.resolve(null);if(typeof e!="string"&&typeof e!="number")throw new Error("id can be either number or string, but got: "+typeof e);return this.findFirst({},{...t,where:this.metadata.idMetadata.getIdFilter(e)},!0)}async _translateWhereToFilter(e){var r,s;let t=e??{};(r=this._defaultFindOptions)!=null&&r.where&&(t={$and:[t,(s=this._defaultFindOptions)==null?void 0:s.where]}),this._dataProvider.isProxy||(this.metadata.options.backendPreprocessFilter&&(t=await this.metadata.options.backendPreprocessFilter(t,{metadata:this.metadata,getFilterPreciseValues:o=>P.getPreciseValues(this.metadata,o||t)})),this.metadata.options.backendPrefilter&&(t={$and:[t,await P.resolve(this.metadata.options.backendPrefilter)]}));let n=await P.fromEntityFilter(this.metadata,t);return n&&!this._dataProvider.isProxy&&(n=await P.translateCustomWhere(n,this.metadata,this._remult)),n}}function Fo(i,e){let t=T.columnsOfType.get(i);t||T.columnsOfType.set(i,t=[]);let n=Ie(i)(e),r=Gs(i),s=Object.getPrototypeOf(i);for(;s!=null;){let o=T.columnsOfType.get(s);o&&t.unshift(...o.filter(l=>!t.find(f=>f.key==l.key)));let a=Ie(s,!1);if(a){let l=a(e);n={...l,...n};let f=["saving","saved","deleting","deleted","validation"];for(const u of f)if(l[u]&&l[u]!==n[u]){let c=n[u];n[u]=async(h,p)=>{await c(h,p),await l[u](h,p)}}}s=Object.getPrototypeOf(s)}return new No(Zi(t,e),n,e,i,r)}class Ki{constructor(e,t,n,r){d(this,"fieldsMetadata");d(this,"instance");d(this,"remult");d(this,"isNewRow");d(this,"_error");d(this,"_subscribers");d(this,"_isLoading",!1);d(this,"lookups",new Map);d(this,"errors");d(this,"originalValues",{});this.fieldsMetadata=e,this.instance=t,this.remult=n,this.isNewRow=r;{let s=n;s!=null&&s.iAmRemultProxy&&(n=T.remultFactory())}for(const s of e)if(Ie(s.valueType,!1)&&n){let a=new so(n.repo(s.valueType),!!oe(s),s.allowNull);this.lookups.set(s.key,a);let l=t[s.key],f;Object.defineProperty(t,s.key,{get:()=>(this._subscribers&&(this._subscribers.reportObserved(),f||(f=this.fields.find(s.key),f._subscribers||(f._subscribers=new qt)),f._subscribers.reportObserved()),a.item),set:u=>{var c;a.set(u),(c=this._subscribers)==null||c.reportChanged(),f||(f=this.fields.find(s.key),f._subscribers||(f._subscribers=new qt)),f._subscribers.reportChanged()},enumerable:!0}),a.set(l)}else{const a=oe(s);if((a==null?void 0:a.type)==="toOne"){let l=t.hasOwnProperty(s.key),f=t[s.key];r&&!f&&(l=!1),Object.defineProperty(t,s.key,{get:()=>f,set:u=>{if(f=u,u===void 0)return;const c=s.options;if(c.field&&(this.instance[c.field]=a.toRepo.metadata.idMetadata.getId(u)),c.fields){for(const h in c.fields)if(Object.prototype.hasOwnProperty.call(c.fields,h)){const p=c.fields[h];this.instance[p]=u==null?null:u[h]}}},enumerable:!0}),l&&(t[s.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 qt;const e=this._subscribers;for(const t of this.fieldsMetadata){let n=Ie(t.valueType,!1),r=this.fields.find(t.key);if(r._subscribers=new qt,!(n&&this.remult)){let s=this.instance[t.key];Object.defineProperty(this.instance,t.key,{get:()=>(e.reportObserved(),r._subscribers.reportObserved(),s),set:o=>{s=o,e.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 Ot([...this.lookups.values()],e=>e.waitLoad())}__assertValidity(){if(!this.hasErrors())throw this.buildErrorInfoObject()}buildErrorInfoObject(){var t;let e={modelState:Object.assign({},this.errors),message:this.error};if(!e.message){for(const n of this.fieldsMetadata)if((t=this.errors)!=null&&t[n.key]){e.message=this.fields[n.key].metadata.caption+": "+this.errors[n.key],this.error=e.message;break}}return e}catchSaveErrors(e){let t=e;if(t instanceof Promise)return t.then(r=>this.catchSaveErrors(r));t.error&&(t=t.error),t.message?this.error=t.message:t.Message?this.error=t.Message:this.error=t;let n=t.modelState;throw n||(n=t.ModelState),n&&(this.errors=n),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 n of this.fieldsMetadata){let r=this.lookups.get(n.key),s;const o=oe(n);r?s=r.id:s=this.instance[n.key],o&&e&&!n.allowNull&&s==null&&(o.toRepo.metadata.idMetadata.field.valueType===Number?s=0:s=""),(!o||o.type==="reference")&&(s!==void 0&&(s=n.valueConverter.toJson(s),s!=null&&(s=n.valueConverter.fromJson(JSON.parse(JSON.stringify(s))))),t[n.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 n={};for(const r of this.fieldsMetadata)if(t||!this.remult||r.includedInApi(this.instance)){let s,o=this.lookups.get(r.key),a=!1;o?e?(s=o.toJson(),a=!0,n[r.key]=s):s=o.id:oe(r)&&!e?a=!0:(s=this.instance[r.key],this.remult||s&&Ie(s.constructor,!1)&&(s=ee(s).getId())),a||(n[r.key]=r.valueConverter.toJson(s))}return n}async _updateEntityBasedOnApi(e,t=!1){let n=Object.keys(e);for(const r of this.fieldsMetadata)if(n.includes(r.key)&&r.includedInApi(this.instance)&&(!this.remult||t||r.apiUpdateAllowed(this.instance))){let s=this.lookups.get(r.key);s?s.id=e[r.key]:this.instance[r.key]=r.valueConverter.fromJson(e[r.key])}await Ot([...this.fields].filter(r=>!oe(r.metadata)),r=>r.load())}}class Bt extends Ki{constructor(t,n,r,s,o,a){super(t.fieldsMetadata,n,o,a);d(this,"info");d(this,"repo");d(this,"edp");d(this,"_isNew");d(this,"repository");d(this,"metadata");d(this,"_wasDeleted",!1);d(this,"_columns");d(this,"_saving",!1);d(this,"id");d(this,"originalId");if(this.info=t,this.repo=r,this.edp=s,this._isNew=a,this.repository=r,this.metadata=t,a)for(const l of t.fieldsMetadata){const f=l.key;l.options.defaultValue&&n[f]===void 0&&(typeof l.options.defaultValue=="function"?n[f]=l.options.defaultValue(n):n[f]||(n[f]=l.options.defaultValue))}this.info.entityInfo.entityRefInit&&this.info.entityInfo.entityRefInit(this,n),Pe.entityRefInit&&Pe.entityRefInit(this,n)}clone(){const t=this.toApiJson(!0,!0);return this.repo.fromJson(t,this.isNew())}get relations(){return this.repo.relations(this.instance)}get apiUpdateAllowed(){return this.remult.isAllowedForInstance(this.instance,this.metadata.options.allowApiUpdate)}get apiDeleteAllowed(){return this.remult.isAllowedForInstance(this.instance,this.metadata.options.allowApiDelete)}get apiInsertAllowed(){return this.remult.isAllowedForInstance(this.instance,this.metadata.options.allowApiInsert)}getId(){const t=n=>{let r=this.lookups.get(n.key);return r?r.id:this.instance[n.key]};return this.metadata.idMetadata.field instanceof Ke?this.metadata.idMetadata.field.getId(t):t(this.metadata.idMetadata.field)}saveMoreOriginalData(){this.originalId=this.getId()}wasDeleted(){var t;return(t=this._subscribers)==null||t.reportObserved(),this._wasDeleted}undoChanges(){this.loadDataFrom(this.originalValues),this.__clearErrorsAndReportChanged()}async reload(){return await this.edp.find({where:await this.getIdFilter()}).then(async t=>{if(t.length===0)throw this.repo._notFoundError(this.id);await this.loadDataFrom(t[0]),this.saveOriginalData()}),this._reportChangedToEntityAndFields(),this.instance}get fields(){if(!this._columns){let t=[],n={find:r=>n[typeof r=="string"?r:r.key],[Symbol.iterator]:()=>t[Symbol.iterator](),toArray:()=>t};for(const r of this.info.fieldsMetadata)t.push(n[r.key]=new zt(r.options,r,this.instance,this,this));this._columns=n}return this._columns}async save(t){var n,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 s=!1,o=this.buildLifeCycleEvent(()=>s=!0);if(!this.repo._dataProvider.isProxy){for(const c of this.fields)c.metadata.options.saving&&await c.metadata.options.saving(this.instance,c,o);this.info.entityInfo.saving&&await this.info.entityInfo.saving(this.instance,o)}this.__assertValidity();let a=this.copyDataToObject(this.isNew()),l=[];for(const c of this.metadata.fields)if(c.dbReadOnly||t!==void 0&&!t.includes(c.key)){a[c.key]=void 0,l.push(c.key);let h=this.fields.find(c);h.value=h.originalValue}let f,u=this.isNew();try{if((n=this._subscribers)==null||n.reportChanged(),this.isNew())s?f=(f=await this.edp.find({where:await this.getIdFilter()}))[0]:f=await this.edp.insert(a);else{let c={},h=!1;for(const p in a)if(Object.prototype.hasOwnProperty.call(a,p)){const y=a[p];this.fields.find(p).valueChanged()&&!l.includes(p)&&(c[p]=y,h=!0)}if(!h)return this.instance;s?f=(await this.edp.find({where:await this.getIdFilter()}))[0]:f=await this.edp.update(this.id,c)}if(f&&await this.loadDataFrom(f),o.id=this.getId(),!this.repo._dataProvider.isProxy&&(this.info.entityInfo.saved&&await this.info.entityInfo.saved(this.instance,o),this.repo.listeners))for(const c of this.repo.listeners)await((r=c.saved)==null?void 0:r.call(c,this.instance,u));return await this.repo._remult.liveQueryPublisher.itemChanged(this.repo.metadata.key,[{id:this.getId(),oldId:this.getOriginalId(),deleted:!1}]),this.saveOriginalData(),this._isNew=!1,this.instance}catch(c){throw await this.catchSaveErrors(c)}}finally{this.isLoading=!1,this._reportChangedToEntityAndFields(),this._saving=!1}}async processInsertResponseDto(t){return await this.loadDataFrom(t),this.saveOriginalData(),this._isNew=!1,this.instance}async buildDtoForInsert(){await this.__validateEntity(),this.__assertValidity();let t=this.copyDataToObject(this.isNew()),n=[];for(const r of this.metadata.fields)if(r.dbReadOnly){t[r.key]=void 0,n.push(r.key);let s=this.fields.find(r);s.value=s.originalValue}return t}buildLifeCycleEvent(t=()=>{}){const n=this;return{isNew:n.isNew(),fields:n.fields,id:n.getId(),originalId:n.getOriginalId(),metadata:n.repo.metadata,repository:n.repo,preventDefault:()=>t(),relations:n.repo.relations(n.instance)}}async getIdFilter(){return await this.repo._translateWhereToFilter(this.repo.metadata.idMetadata.getIdFilter(this.id))}async delete(){var r;this.__clearErrorsAndReportChanged();let t=!0,n=this.buildLifeCycleEvent(()=>t=!1);this.repo._dataProvider.isProxy||this.info.entityInfo.deleting&&await this.info.entityInfo.deleting(this.instance,n),this.__assertValidity();try{if(t&&await this.edp.delete(this.id),this.repo._dataProvider.isProxy||this.info.entityInfo.deleted&&await this.info.entityInfo.deleted(this.instance,n),this.repo.listeners)for(const s of this.repo.listeners)await((r=s.deleted)==null?void 0:r.call(s,this.instance));await this.repo._remult.liveQueryPublisher.itemChanged(this.repo.metadata.key,[{id:this.getId(),oldId:this.getOriginalId(),deleted:!0}]),this._wasDeleted=!0}catch(s){throw await this.catchSaveErrors(s)}}async loadDataFrom(t,n){for(const r of this.info.fields){let s=this.lookups.get(r.key);s?(s.id=t[r.key],n===void 0?!r.options.lazy&&!oe(r)&&await s.waitLoad():n.includes(r)&&await s.waitLoad()):oe(r)||(this.instance[r.key]=t[r.key])}await this.calcServerExpression(),this.id=this.getId()}getOriginalId(){return this.originalId}async calcServerExpression(){if(Tn())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 n of this.fields){const r=oe(n.metadata);if((!r||r.type=="reference")&&n.valueChanged())return!0}return!1}async __performColumnAndEntityValidations(){var t;for(const n of this.fieldsMetadata)n.options.validate&&await new zt(n.options,n,this.instance,this,this).__performValidation();if(this.info.entityInfo.validation){let n=this.buildLifeCycleEvent(()=>{});await this.info.entityInfo.validation(this.instance,n)}if(this.repo.listeners)for(const n of this.repo.listeners)await((t=n.validating)==null?void 0:t.call(n,this.instance))}}const Ii=Symbol.for("controllerColumns");function Zi(i,e){return i.map(t=>zn(t.settings(e),e))}function Oi(i,e){const t=e||Se;let n=i[Ii];if(n||(n=i[Xe]),!n){let r=T.columnsOfType.get(i.constructor);r||T.columnsOfType.set(i.constructor,r=[]);let s=Object.getPrototypeOf(i.constructor);for(;s!=null;){let o=T.columnsOfType.get(s);o&&r.unshift(...o.filter(a=>!r.find(l=>l.key==a.key))),s=Object.getPrototypeOf(s)}i[Ii]=n=new Do(Zi(r,t).map(o=>new er(o,void 0,t)),i,t)}return n}class Do extends Ki{constructor(t,n,r){super(t,n,r,!1);d(this,"fields");let s=[],o={find:a=>o[typeof a=="string"?a:a.key],[Symbol.iterator]:()=>s[Symbol.iterator](),toArray:()=>s};for(const a of t)s.push(o[a.key]=new zt(a.options,a,n,void 0,this));this.fields=o}async __performColumnAndEntityValidations(){for(const t of this.fields)t instanceof zt&&await t.__performValidation()}}class zt{constructor(e,t,n,r,s){d(this,"settings");d(this,"metadata");d(this,"container");d(this,"helper");d(this,"rowBase");d(this,"_subscribers");d(this,"target");d(this,"entityRef");this.settings=e,this.metadata=t,this.container=n,this.helper=r,this.rowBase=s,this.target=this.settings.target,this.entityRef=this.helper}subscribe(e){return this._subscribers||this.rowBase.initSubscribers(),this._subscribers.subscribe(e)}valueIsNull(){this.reportObserved();let e=this.rowBase.lookups.get(this.metadata.key);return e?e.id===void 0||e.id===null:this.value===null}originalValueIsNull(){return this.reportObserved(),this.rowBase.lookups.get(this.metadata.key),this.rawOriginalValue()===null}get key(){return this.metadata.key}get repo(){var e;return(e=this.helper)==null?void 0:e.repository}async load(){let e=this.rowBase.lookups.get(this.metadata.key),t=oe(this.metadata);if(t&&this.helper){if(t.type==="toMany")return this.container[this.metadata.key]=await this.repo.relations(this.container)[this.key].find();{let n=await this.repo.relations(this.container)[this.metadata.key].findOne();if(n)this.container[this.metadata.key]=n;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=n=>{n!==!0&&n!==void 0&&!this.error&&(typeof n=="string"&&n.length>0?this.error=n:this.error="invalid value")};if(this.settings.validate){let n=this,r={entityRef:this.entityRef,get error(){return n.error},set error(s){n.error=s},isNew:((e=this.entityRef)==null?void 0:e.isNew())??!1,load:()=>n.load(),metadata:n.metadata,originalValue:n.originalValue,value:n.value,valueChanged:()=>n.valueChanged(),originalValueIsNull:()=>n.originalValueIsNull(),valueIsNull:()=>n.valueIsNull(),isBackend:()=>{var s,o,a;return!((a=(o=(s=n.rowBase)==null?void 0:s.remult)==null?void 0:o.dataProvider)!=null&&a.isProxy)}};if(Array.isArray(this.settings.validate))for(const s of this.settings.validate)t(await s(this.container,r));else typeof this.settings.validate=="function"&&t(await this.settings.validate(this.container,r))}}catch(t){typeof t=="string"?this.error=t:this.error=t==null?void 0:t.message}}async validate(){return await this.__performValidation(),!this.error}}let Ro={transformCaption:(i,e,t,n)=>t};const Mo=T.captionTransformer||(T.captionTransformer=Ro);function Yi(i,e,t,n){let r;return typeof i=="function"?t&&(r=i(t)):i&&(r=i),r=Mo.transformCaption(t,e,r??"",n),r||(e?ro(e):"")}class er{constructor(e,t,n){d(this,"settings");d(this,"entityDefs");d(this,"remult");d(this,"options");d(this,"target");d(this,"readonly",!1);d(this,"valueConverter");d(this,"allowNull");d(this,"caption");d(this,"dbName");d(this,"inputType");d(this,"key");d(this,"isServerExpression",!1);d(this,"valueType");this.settings=e,this.entityDefs=t,this.remult=n,this.options=this.settings,this.target=this.settings.target,this.valueConverter=new Proxy(this.settings.valueConverter??{},{get:(r,s)=>{let o=r[s];return typeof o=="function"?(...a)=>{try{return r[s](...a)}catch(l){const f=`${String(s)} failed for value ${a==null?void 0:a[0]}. Error: ${typeof l=="string"?l:l.message}`;throw{message:this.caption+": "+f,modelState:{[this.key]:f}}}}:o}}),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=Yi(e.caption,e.key,n,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 Kn(this,this.entityDefs)}get dbReadOnly(){return!!this.settings.dbReadOnly}}class No{constructor(e,t,n,r,s){d(this,"entityInfo");d(this,"remult");d(this,"entityType");d(this,"key");d(this,"options");d(this,"fieldsMetadata",[]);d(this,"idMetadata",{getId:e=>{if(e==null)return e;const t=ee(e,!1);return t?t.getId():this.idMetadata.field instanceof Ke?this.idMetadata.field.getId(e):e[this.idMetadata.field.key]},field:void 0,get fields(){return this.field instanceof Ke?this.field.fields:[this.field]},createIdInFilter:e=>e.length>0?{$or:e.map(t=>this.idMetadata.getIdFilter(ee(t).getId()))}:{[this.fields.toArray()[0].key]:[]},isIdField:e=>e.key==this.idMetadata.field.key,getIdFilter:(...e)=>{if(this.idMetadata.field instanceof Ke){let t=this.idMetadata.field;return e.length==1?t.isEqualTo(e[0]):{$or:e.map(n=>t.isEqualTo(n))}}return e.length==1?{[this.idMetadata.field.key]:e[0]}:{[this.idMetadata.field.key]:e}}});d(this,"fields");d(this,"dbName");d(this,"caption");if(this.entityInfo=t,this.remult=n,this.entityType=r,this.key=s,this.options=t,this.options.allowApiCrud!==void 0){let a;typeof this.options.allowApiCrud=="function"?a=(l,f)=>this.options.allowApiCrud(f):a=this.options.allowApiCrud,this.options.allowApiDelete===void 0&&(this.entityInfo.allowApiDelete=a),this.options.allowApiInsert===void 0&&(this.entityInfo.allowApiInsert=a),this.options.allowApiUpdate===void 0&&(this.entityInfo.allowApiUpdate=a),this.options.allowApiRead===void 0&&(this.options.allowApiRead=this.options.allowApiCrud)}this.options.allowApiRead===void 0&&(this.options.allowApiRead=!0),this.key||(this.key=r.name),t.dbName||(t.dbName=this.key),this.dbName=t.dbName;let o={find:a=>o[typeof a=="string"?a:a.key],[Symbol.iterator]:()=>this.fieldsMetadata[Symbol.iterator](),toArray:()=>this.fieldsMetadata};for(const a of e)this.fieldsMetadata.push(o[a.key]=new er(a,this,n));if(this.fields=o,this.caption=Yi(t.caption,this.key,n,this),t.id){let a=typeof t.id=="function"?t.id(this.fields):Object.keys(t.id).map(l=>this.fields.find(l));Array.isArray(a)?a.length>1?this.idMetadata.field=new Ke(...a):a.length==1&&(this.idMetadata.field=a[0]):this.idMetadata.field=a}if(!this.idMetadata.field){const a=this.fields.id;a?this.idMetadata.field=a: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=ee(e,!1);return t||this.remult.repo(this.entityType).getEntityRef({...e})}getDbName(){return sr(this)}}function Lo(i){var e,t;return((t=(e=i.options)==null?void 0:e.valueConverter)==null?void 0:t.fieldTypeInDb)==="autoincrement"}const Bo=Symbol.for("storableMember"),mn=Symbol.for("fieldOptionalValues");function tr(i,e){let t={};for(const n of i)if(n)if(typeof n=="function")n(t,e);else{const{validate:r,...s}=n;t.validate=Ht(t.validate,r),Object.assign(t,s)}return t}function zn(i,e){if(i.valueType){let r=i.valueType[Bo];r&&(i=tr([...r,i],e))}if(i.valueType==String){let r=i;i.valueConverter||(r.valueConverter=pe.String)}if(i.valueType==Number){let r=i;i.valueConverter||(r.valueConverter=pe.Number)}if(i.valueType==Date){let r=i;i.valueConverter||(r.valueConverter=pe.Date)}if(i.valueType==Boolean){let r=i;r.valueConverter||(r.valueConverter=pe.Boolean)}if(!i.valueConverter){if(Ie(i.valueType,!1)){let s;i.valueConverter={toDb:o=>o,fromDb:o=>o},i.valueConverter=new Proxy(i.valueConverter,{get(o,a){if(o[a]===void 0&&s===void 0){if(a==="inputType")return"";s=e.repo(i.valueType).metadata.idMetadata.field.valueType===Number;for(const l of["fieldTypeInDb","toJson","fromJson","toDb","fromDb"])o[l]=s?pe.Integer[l]:pe.String[l]}return o[a]},set(o,a,l,f){return o[a]=l,!0}})}else i.valueConverter=pe.Default;return i}i.valueConverter.toJson||(i.valueConverter.toJson=r=>r),i.valueConverter.fromJson||(i.valueConverter.fromJson=r=>r);const t=i.valueConverter.fromJson,n=i.valueConverter.toJson;return i.valueConverter.toDb||(i.valueConverter.toDb=r=>n(r)),i.valueConverter.fromDb||(i.valueConverter.fromDb=r=>t(r)),i.valueConverter.toInput||(i.valueConverter.toInput=r=>n(r)),i.valueConverter.fromInput||(i.valueConverter.fromInput=r=>t(r)),i}class nr{get _(){return ee(this)}save(){return ee(this).save()}assign(e){return An(this,e),this}delete(){return this._.delete()}isNew(){return this._.isNew()}get $(){return this._.fields}}class qo{constructor(e,t){d(this,"options");d(this,"repo");d(this,"_count");this.options=e,this.repo=t,this.options||(this.options={}),this.options.pageSize||(this.options.pageSize=Eo.defaultPageSize)}async getPage(e){return(e??0)<1&&(e=1),this.repo.find({where:this.options.where,orderBy:this.options.orderBy,limit:this.options.pageSize,page:e,load:this.options.load,include:this.options.include})}async count(){return this._count===void 0&&(this._count=await this.repo.count(this.options.where)),this._count}async forEach(e){let t=0;for await(const n of this)await e(n),t++;return t}async paginator(e){this.options.orderBy=ke.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}),n=()=>{throw new Error("no more pages")},r=t.length==this.options.pageSize;if(r){let s=await this.repo._createAfterFilter(this.options.orderBy,t[t.length-1]);n=()=>this.paginator(s)}return{count:()=>this.count(),hasNextPage:r,items:t,nextPage:n}}[Symbol.asyncIterator](){this.options.where||(this.options.where={});let e=this.options.orderBy;this.options.orderBy=ke.createUniqueEntityOrderBy(this.repo.metadata,e);let t=-1,n,r,s=0;return r=async()=>{if(this.options.progress&&this.options.progress.progress(s++/await this.count()),n===void 0||t==n.items.length){if(n&&!n.hasNextPage)return{value:void 0,done:!0};let o=n;if(n?n=await n.nextPage():n=await this.paginator(),t=0,n.items.length==0)return{value:void 0,done:!0};if(((o==null?void 0:o.items.length)??!1)&&this.repo.getEntityRef(o.items[0]).getId()==this.repo.getEntityRef(n.items[0]).getId())throw new Error("pagination failure, returned same first row")}return t<n.items.length?{value:n.items[t++],done:!1}:{done:!0,value:void 0}},{next:async()=>r()}}}class qt{constructor(){d(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(n=>n!=t)}}function jo(i){return i.metadata?i.metadata:Ie(i,!1)?Se.repo(i).metadata:i}function Jo(i){return Ie(i,!1)?Se.repo(i):i}async function Ot(i,e){const t=[];for(let n=0;n<i.length;n++){const r=i[n];t.push(await e(r,n))}return t}const ft=class ft{constructor(e){d(this,"sql");d(this,"wrapIdentifier",e=>e);d(this,"provideMigrationBuilder");d(this,"createdEntities",[]);d(this,"end");this.sql=e,e.wrapIdentifier&&(this.wrapIdentifier=t=>e.wrapIdentifier(t)),It(e,"provideMigrationBuilder")&&(this.provideMigrationBuilder=t=>e.provideMigrationBuilder(t)),It(e,"end")&&(this.end=()=>e.end())}static getDb(e){const t=e||Se.dataProvider;if(It(t,"createCommand"))return t;throw"the data provider is not an SqlCommandFactory"}createCommand(){return new Wo(this.sql.createCommand(),ft.LogToConsole)}async execute(e){return await this.createCommand().execute(e)}_getSourceSql(){return this.sql}async ensureSchema(e){this.sql.ensureSchema&&await this.sql.ensureSchema(e)}getEntityDataProvider(e){if(!this.sql.supportsJsonColumnType)for(const t of e.fields.toArray())t.valueConverter.fieldTypeInDb==="json"&&(t.valueConverter={...t.valueConverter,toDb:pe.JsonString.toDb,fromDb:pe.JsonString.fromDb});return new ir(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 n=!1;try{await e(new ft({createCommand:()=>{let r=t.createCommand();return{addParameterAndReturnSqlToken:s=>r.param(s),param:s=>r.param(s),execute:async s=>{if(n)throw"can't run a command after the transaction was completed";return r.execute(s)}}},getLimitSqlSyntax:this.sql.getLimitSqlSyntax,entityIsUsedForTheFirstTime:r=>t.entityIsUsedForTheFirstTime(r),transaction:r=>t.transaction(r),supportsJsonColumnType:this.sql.supportsJsonColumnType,wrapIdentifier:this.wrapIdentifier,end:this.end,doesNotSupportReturningSyntax:this.sql.doesNotSupportReturningSyntax,doesNotSupportReturningSyntaxOnlyForUpdate:this.sql.doesNotSupportReturningSyntaxOnlyForUpdate,orderByNullsFirst:this.sql.orderByNullsFirst}))}finally{n=!0}})}static rawFilter(e){return{[Qi]:{buildSql:e}}}static async filterToRaw(e,t,n,r,s){n||(n=new Vo);const o=Jo(e);var a=new je(n,r||await rr(o.metadata,s));return a._addWhere=!1,await(await Ye(o)._translateWhereToFilter(t)).__applyToConsumer(a),await a.resolveWhere()}};d(ft,"LogToConsole",!1),d(ft,"durationThreshold",0);let ct=ft;const Uo=new Map([["INSERT","⚪"],["SELECT","🔵"],["UPDATE","🟣"],["DELETE","🟤"],["CREATE","🟩"],["ALTER","🟨"],["DROP","🟥"],["TRUNCATE","⬛"],["GRANT","🟪"],["REVOKE","🟫"]]);class Wo{constructor(e,t){d(this,"origin");d(this,"logToConsole");d(this,"args",{});this.origin=e,this.logToConsole=t}addParameterAndReturnSqlToken(e){return this.param(e)}param(e,t){let n=this.origin.param(e);return this.args[n]=e,n}async execute(e){try{let n=new Date,r=await this.origin.execute(e);if(this.logToConsole!==!1){var t=new Date().valueOf()-n.valueOf();if(t>ct.durationThreshold){const s=t/1e3;if(this.logToConsole==="oneLiner"){const o=e.replace(/(\r\n|\n|\r|\t)/gm," ").replace(/ +/g," ").trim(),a=o.split(" ")[0].toUpperCase();console.info(`${Uo.get(a)||"💢"} (${s.toFixed(3)}) ${o} ${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 r}catch(n){throw console.error((n.message||"Sql Error")+`:
|
|
3
|
-
`,e,{arguments:this.args,error:n}),n}}}class ir{constructor(e,t,n,r){d(this,"entity");d(this,"sql");d(this,"iAmUsed");d(this,"strategy");this.entity=e,this.sql=t,this.iAmUsed=n,this.strategy=r}async init(){let e=await rr(this.entity,t=>this.sql.wrapIdentifier(t));return await this.iAmUsed(e),e}async count(e){let t=await this.init(),n="select count(*) count from "+t.$entityName,r=this.sql.createCommand();if(e){let s=new je(r,t);e.__applyToConsumer(s),n+=await s.resolveWhere()}return r.execute(n).then(s=>Number(s.rows[0].count))}async find(e){let t=await this.init(),{colKeys:n,select:r}=this.buildSelect(t);r="select "+r,r+=`
|
|
4
|
-
from `+t.$entityName;let s=this.sql.createCommand();if(e){if(e.where){let o=new je(s,t);e.where.__applyToConsumer(o),r+=await o.resolveWhere()}if(e.limit&&(e.orderBy=ke.createUniqueSort(this.entity,e.orderBy)),e.orderBy||(e.orderBy=ke.createUniqueSort(this.entity,new ke)),e.orderBy){let o=!0,a=[];for(const l of e.orderBy.Segments)a.push(l);for(const l of a)o?(r+=" Order By ",o=!1):r+=", ",r+=t.$dbNameOf(l.field),l.isDescending&&(r+=" desc"),this.sql._getSourceSql().orderByNullsFirst&&(l.isDescending?r+=" nulls last":r+=" nulls first")}if(e.limit){let o=1;e.page&&(o=e.page),o<1&&(o=1),r+=" "+this.strategy.getLimitSqlSyntax(e.limit,(o-1)*e.limit)}}return s.execute(r).then(o=>o.rows.map(a=>this.buildResultRow(n,a,o)))}buildResultRow(e,t,n){let r={};for(let s=0;s<e.length;s++){const o=e[s];try{r[o.key]=o.valueConverter.fromDb(t[n.getColumnKeyInResultForIndexInSelect(s)])}catch(a){throw new Error("Failed to load from db:"+o.key+`\r
|
|
5
|
-
`+a)}}return r}buildSelect(e){let t="",n=[];for(const r of this.entity.fields)r.isServerExpression||(n.length>0&&(t+=", "),t+=e.$dbNameOf(r),r.options.sqlExpression&&(t+=" as "+r.key),n.push(r));return{colKeys:n,select:t}}async update(e,t){let n=await this.init(),r=this.sql.createCommand(),s="update "+n.$entityName+" set ",o=!1;for(const h of this.entity.fields)if(!Si(h,n)){if(t[h.key]!==void 0){let p=h.valueConverter.toDb(t[h.key]);p!==void 0&&(o?s+=", ":o=!0,s+=n.$dbNameOf(h)+" = "+r.param(p))}}const a=this.entity.idMetadata.getIdFilter(e);let l=new je(r,n);P.fromEntityFilter(this.entity,a).__applyToConsumer(l),s+=await l.resolveWhere();let{colKeys:f,select:u}=this.buildSelect(n),c=!0;return this.sql._getSourceSql().doesNotSupportReturningSyntax&&(c=!1),c&&this.sql._getSourceSql().doesNotSupportReturningSyntaxOnlyForUpdate&&(c=!1),c&&(s+=" returning "+u),r.execute(s).then(h=>{var p,y;if((y=(p=this.sql._getSourceSql()).afterMutation)==null||y.call(p),!c)return Ei(this.entity,this,t,e,"update");if(h.rows.length!=1)throw new Error("Failed to update row with id "+e+", rows updated: "+h.rows.length);return this.buildResultRow(f,h.rows[0],h)})}async delete(e){let t=await this.init(),n=this.sql.createCommand(),r=new je(n,t);P.fromEntityFilter(this.entity,this.entity.idMetadata.getIdFilter(e)).__applyToConsumer(r);let s="delete from "+t.$entityName;return s+=await r.resolveWhere(),n.execute(s).then(()=>{var o,a;(a=(o=this.sql._getSourceSql()).afterMutation)==null||a.call(o)})}async insert(e){let t=await this.init(),n=this.sql.createCommand(),r="",s="",o=!1;for(const u of this.entity.fields)if(!Si(u,t)){let c=u.valueConverter.toDb(e[u.key]);c!=null&&(o?(r+=", ",s+=", "):o=!0,r+=t.$dbNameOf(u),s+=n.param(c))}let a=`insert into ${t.$entityName} (${r}) values (${s})`,{colKeys:l,select:f}=this.buildSelect(t);return this.sql._getSourceSql().doesNotSupportReturningSyntax||(a+=" returning "+f),await n.execute(a).then(u=>{var c,h;if((h=(c=this.sql._getSourceSql()).afterMutation)==null||h.call(c),this.sql._getSourceSql().doesNotSupportReturningSyntax)if(Lo(this.entity.idMetadata.field)){const p=u.rows[0];if(typeof p!="number")throw new Error("Auto increment, for a database that is does not support returning syntax, should return an array with the single last added id. Instead it returned: "+JSON.stringify(p));return this.find({where:new P(y=>y.isEqualTo(this.entity.idMetadata.field,p))}).then(y=>y[0])}else return Ei(this.entity,this,e,void 0,"insert");return this.buildResultRow(l,u.rows[0],u)})}}d(ir,"LogToConsole",!1);class Vo{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 Ei(i,e,t,n,r){const s=n!==void 0?i.idMetadata.getIdFilter(n):{};return e.find({where:new P(o=>{for(const a of i.idMetadata.fields)o.isEqualTo(a,t[a.key]??s[a.key])})}).then(o=>{if(o.length!=1)throw new Error(`Failed to ${r} row - result contained ${o.length} rows`);return o[0]})}class je{constructor(e,t){d(this,"r");d(this,"nameProvider");d(this,"where","");d(this,"_addWhere",!0);d(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 n of e){let r=new je(this.r,this.nameProvider);r._addWhere=!1,n.__applyToConsumer(r);let s=await r.resolveWhere();if(!s)return;s.length>0&&(t.length>0&&(t+=" or "),e.length>1?t+="("+s+")":t+=s)}this.addToWhere("("+t+")")})())}not(e){this.promises.push((async()=>{let t=new je(this.r,this.nameProvider);t._addWhere=!1,e.__applyToConsumer(t);let n=await t.resolveWhere();n&&this.addToWhere("not ("+n+")")})())}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(n=>this.r.param(e.valueConverter.toDb(n))).join(",")+")"):this.addToWhere("1 = 0 /*isIn with no values*/")})())}isEqualTo(e,t){this.add(e,t,"=")}isDifferentFrom(e,t){this.add(e,t,"<>")}isGreaterOrEqualTo(e,t){this.add(e,t,">=")}isGreaterThan(e,t){this.add(e,t,">")}isLessOrEqualTo(e,t){this.add(e,t,"<=")}isLessThan(e,t){this.add(e,t,"<")}containsCaseInsensitive(e,t){this.promises.push((async()=>{this.addToWhere("lower ("+this.nameProvider.$dbNameOf(e)+") like lower ('%"+t.replace(/'/g,"''")+"%')")})())}notContainsCaseInsensitive(e,t){this.promises.push((async()=>{this.addToWhere("not lower ("+this.nameProvider.$dbNameOf(e)+") like lower ('%"+t.replace(/'/g,"''")+"%')")})())}startsWithCaseInsensitive(e,t){this.promises.push((async()=>{this.addToWhere("lower ("+this.nameProvider.$dbNameOf(e)+") like lower ('"+t.replace(/'/g,"''")+"%')")})())}endsWithCaseInsensitive(e,t){this.promises.push((async()=>{this.addToWhere("lower ("+this.nameProvider.$dbNameOf(e)+") like lower ('%"+t.replace(/'/g,"''")+"')")})())}add(e,t,n){this.promises.push((async()=>{let r=this.nameProvider.$dbNameOf(e)+" "+n+" "+this.r.param(e.valueConverter.toDb(t));this.addToWhere(r)})())}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 Ho(this.r,this.nameProvider.wrapIdentifier),n=await e.buildSql(t);typeof n!="string"&&(n=t.sql),n&&this.addToWhere("("+n+")")}})())}}class Ho{constructor(e,t){d(this,"r");d(this,"wrapIdentifier");d(this,"sql","");d(this,"param",(e,t)=>(typeof t=="object"&&t.valueConverter.toDb&&(e=t.valueConverter.toDb(e)),this.r.param(e)));d(this,"filterToRaw",async(e,t)=>ct.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 Si(i,e){return i.dbReadOnly||i.isServerExpression||i.options.sqlExpression&&i.dbName!=e.$dbNameOf(i)}async function rr(i,e){return Qo(i,e,!0)}async function Qo(i,e,t=!1){let n=typeof e=="function"?{wrapIdentifier:e}:e||{};var r=jo(i);n.wrapIdentifier||(n.wrapIdentifier=Se.dataProvider.wrapIdentifier),n.wrapIdentifier||(n.wrapIdentifier=o=>o);const s={$entityName:await sr(r,n.wrapIdentifier),toString:()=>s.$entityName,$dbNameOf:o=>{var a;return typeof o=="string"?a=o:a=o.key,s[a]},wrapIdentifier:n.wrapIdentifier};for(const o of r.fields){let a=await Kn(o,r,n.wrapIdentifier,t);o.options.sqlExpression||(typeof n.tableName=="string"?a=n.wrapIdentifier(n.tableName)+"."+a:n.tableName===!0&&(a=s.$entityName+"."+a)),s[o.key]=a}return s}async function sr(i,e=t=>t){if(i.options.sqlExpression){if(typeof i.options.sqlExpression=="string")return i.options.sqlExpression;if(typeof i.options.sqlExpression=="function"){const t=i.options.sqlExpression;try{return i.options.sqlExpression="recursive sqlExpression call for entity '"+i.key+"'. ",await t(i)}finally{i.options.sqlExpression=t}}}return e(i.dbName)}const wn=Symbol.for("sqlExpressionInProgressKey");async function Kn(i,e,t=r=>r,n=!1){try{if(i.options.sqlExpression){let o;if(typeof i.options.sqlExpression=="function"){if(i[wn]&&!n)return"recursive sqlExpression call for field '"+i.key+"'. ";try{i[wn]=!0,o=await i.options.sqlExpression(e),i.options.sqlExpression=()=>o}finally{delete i[wn]}}else o=i.options.sqlExpression;return o||i.dbName}const r=oe(i);let s=(r==null?void 0:r.type)==="toOne"&&i.options.field;if(s){let o=e.fields.find(s);if(o)return Kn(o,e,t,n)}return t(i.dbName)}finally{}}var Kt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ve={},K={},fe={};Object.defineProperty(fe,"__esModule",{value:!0});fe.output=fe.exists=fe.hash=fe.bytes=fe.bool=fe.number=fe.isBytes=void 0;function Zt(i){if(!Number.isSafeInteger(i)||i<0)throw new Error(`positive integer expected, not ${i}`)}fe.number=Zt;function or(i){if(typeof i!="boolean")throw new Error(`boolean expected, not ${i}`)}fe.bool=or;function ar(i){return i instanceof Uint8Array||i!=null&&typeof i=="object"&&i.constructor.name==="Uint8Array"}fe.isBytes=ar;function Zn(i,...e){if(!ar(i))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(i.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${i.length}`)}fe.bytes=Zn;function lr(i){if(typeof i!="function"||typeof i.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Zt(i.outputLen),Zt(i.blockLen)}fe.hash=lr;function ur(i,e=!0){if(i.destroyed)throw new Error("Hash instance has been destroyed");if(e&&i.finished)throw new Error("Hash#digest() has already been called")}fe.exists=ur;function fr(i,e){Zn(i);const t=e.outputLen;if(i.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}fe.output=fr;const $o={number:Zt,bool:or,bytes:Zn,hash:lr,exists:ur,output:fr};fe.default=$o;var R={};Object.defineProperty(R,"__esModule",{value:!0});R.add5L=R.add5H=R.add4H=R.add4L=R.add3H=R.add3L=R.add=R.rotlBL=R.rotlBH=R.rotlSL=R.rotlSH=R.rotr32L=R.rotr32H=R.rotrBL=R.rotrBH=R.rotrSL=R.rotrSH=R.shrSL=R.shrSH=R.toBig=R.split=R.fromBig=void 0;const jt=BigInt(2**32-1),Pn=BigInt(32);function Yn(i,e=!1){return e?{h:Number(i&jt),l:Number(i>>Pn&jt)}:{h:Number(i>>Pn&jt)|0,l:Number(i&jt)|0}}R.fromBig=Yn;function cr(i,e=!1){let t=new Uint32Array(i.length),n=new Uint32Array(i.length);for(let r=0;r<i.length;r++){const{h:s,l:o}=Yn(i[r],e);[t[r],n[r]]=[s,o]}return[t,n]}R.split=cr;const dr=(i,e)=>BigInt(i>>>0)<<Pn|BigInt(e>>>0);R.toBig=dr;const hr=(i,e,t)=>i>>>t;R.shrSH=hr;const pr=(i,e,t)=>i<<32-t|e>>>t;R.shrSL=pr;const yr=(i,e,t)=>i>>>t|e<<32-t;R.rotrSH=yr;const mr=(i,e,t)=>i<<32-t|e>>>t;R.rotrSL=mr;const wr=(i,e,t)=>i<<64-t|e>>>t-32;R.rotrBH=wr;const gr=(i,e,t)=>i>>>t-32|e<<64-t;R.rotrBL=gr;const br=(i,e)=>e;R.rotr32H=br;const vr=(i,e)=>i;R.rotr32L=vr;const _r=(i,e,t)=>i<<t|e>>>32-t;R.rotlSH=_r;const kr=(i,e,t)=>e<<t|i>>>32-t;R.rotlSL=kr;const Ir=(i,e,t)=>e<<t-32|i>>>64-t;R.rotlBH=Ir;const Or=(i,e,t)=>i<<t-32|e>>>64-t;R.rotlBL=Or;function Er(i,e,t,n){const r=(e>>>0)+(n>>>0);return{h:i+t+(r/2**32|0)|0,l:r|0}}R.add=Er;const Sr=(i,e,t)=>(i>>>0)+(e>>>0)+(t>>>0);R.add3L=Sr;const Cr=(i,e,t,n)=>e+t+n+(i/2**32|0)|0;R.add3H=Cr;const Tr=(i,e,t,n)=>(i>>>0)+(e>>>0)+(t>>>0)+(n>>>0);R.add4L=Tr;const Ar=(i,e,t,n,r)=>e+t+n+r+(i/2**32|0)|0;R.add4H=Ar;const Pr=(i,e,t,n,r)=>(i>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);R.add5L=Pr;const Fr=(i,e,t,n,r,s)=>e+t+n+r+s+(i/2**32|0)|0;R.add5H=Fr;const Go={fromBig:Yn,split:cr,toBig:dr,shrSH:hr,shrSL:pr,rotrSH:yr,rotrSL:mr,rotrBH:wr,rotrBL:gr,rotr32H:br,rotr32L:vr,rotlSH:_r,rotlSL:kr,rotlBH:Ir,rotlBL:Or,add:Er,add3L:Sr,add3H:Cr,add4L:Tr,add4H:Ar,add5H:Fr,add5L:Pr};R.default=Go;var Dr={},rn={};Object.defineProperty(rn,"__esModule",{value:!0});rn.crypto=void 0;rn.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;(function(i){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(i,"__esModule",{value:!0}),i.randomBytes=i.wrapXOFConstructorWithOpts=i.wrapConstructorWithOpts=i.wrapConstructor=i.checkOpts=i.Hash=i.concatBytes=i.toBytes=i.utf8ToBytes=i.asyncLoop=i.nextTick=i.hexToBytes=i.bytesToHex=i.byteSwap32=i.byteSwapIfBE=i.byteSwap=i.isLE=i.rotl=i.rotr=i.createView=i.u32=i.u8=i.isBytes=void 0;const e=rn,t=fe;function n(v){return v instanceof Uint8Array||v!=null&&typeof v=="object"&&v.constructor.name==="Uint8Array"}i.isBytes=n;const r=v=>new Uint8Array(v.buffer,v.byteOffset,v.byteLength);i.u8=r;const s=v=>new Uint32Array(v.buffer,v.byteOffset,Math.floor(v.byteLength/4));i.u32=s;const o=v=>new DataView(v.buffer,v.byteOffset,v.byteLength);i.createView=o;const a=(v,O)=>v<<32-O|v>>>O;i.rotr=a;const l=(v,O)=>v<<O|v>>>32-O>>>0;i.rotl=l,i.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const f=v=>v<<24&4278190080|v<<8&16711680|v>>>8&65280|v>>>24&255;i.byteSwap=f,i.byteSwapIfBE=i.isLE?v=>v:v=>(0,i.byteSwap)(v);function u(v){for(let O=0;O<v.length;O++)v[O]=(0,i.byteSwap)(v[O])}i.byteSwap32=u;const c=Array.from({length:256},(v,O)=>O.toString(16).padStart(2,"0"));function h(v){(0,t.bytes)(v);let O="";for(let D=0;D<v.length;D++)O+=c[v[D]];return O}i.bytesToHex=h;const p={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function y(v){if(v>=p._0&&v<=p._9)return v-p._0;if(v>=p._A&&v<=p._F)return v-(p._A-10);if(v>=p._a&&v<=p._f)return v-(p._a-10)}function _(v){if(typeof v!="string")throw new Error("hex string expected, got "+typeof v);const O=v.length,D=O/2;if(O%2)throw new Error("padded hex string expected, got unpadded hex of length "+O);const W=new Uint8Array(D);for(let z=0,re=0;z<D;z++,re+=2){const Te=y(v.charCodeAt(re)),mt=y(v.charCodeAt(re+1));if(Te===void 0||mt===void 0){const Dt=v[re]+v[re+1];throw new Error('hex string expected, got non-hex character "'+Dt+'" at index '+re)}W[z]=Te*16+mt}return W}i.hexToBytes=_;const w=async()=>{};i.nextTick=w;async function g(v,O,D){let W=Date.now();for(let z=0;z<v;z++){D(z);const re=Date.now()-W;re>=0&&re<O||(await(0,i.nextTick)(),W+=re)}}i.asyncLoop=g;function k(v){if(typeof v!="string")throw new Error(`utf8ToBytes expected string, got ${typeof v}`);return new Uint8Array(new TextEncoder().encode(v))}i.utf8ToBytes=k;function E(v){return typeof v=="string"&&(v=k(v)),(0,t.bytes)(v),v}i.toBytes=E;function N(...v){let O=0;for(let W=0;W<v.length;W++){const z=v[W];(0,t.bytes)(z),O+=z.length}const D=new Uint8Array(O);for(let W=0,z=0;W<v.length;W++){const re=v[W];D.set(re,z),z+=re.length}return D}i.concatBytes=N;class J{clone(){return this._cloneInto()}}i.Hash=J;const ne={}.toString;function ie(v,O){if(O!==void 0&&ne.call(O)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(v,O)}i.checkOpts=ie;function $(v){const O=W=>v().update(E(W)).digest(),D=v();return O.outputLen=D.outputLen,O.blockLen=D.blockLen,O.create=()=>v(),O}i.wrapConstructor=$;function ae(v){const O=(W,z)=>v(z).update(E(W)).digest(),D=v({});return O.outputLen=D.outputLen,O.blockLen=D.blockLen,O.create=W=>v(W),O}i.wrapConstructorWithOpts=ae;function Oe(v){const O=(W,z)=>v(z).update(E(W)).digest(),D=v({});return O.outputLen=D.outputLen,O.blockLen=D.blockLen,O.create=W=>v(W),O}i.wrapXOFConstructorWithOpts=Oe;function Ee(v=32){if(e.crypto&&typeof e.crypto.getRandomValues=="function")return e.crypto.getRandomValues(new Uint8Array(v));throw new Error("crypto.getRandomValues must be defined")}i.randomBytes=Ee})(Dr);Object.defineProperty(K,"__esModule",{value:!0});K.shake256=K.shake128=K.keccak_512=K.keccak_384=K.keccak_256=K.keccak_224=K.sha3_512=K.sha3_384=K.sha3_256=K.sha3_224=K.Keccak=K.keccakP=void 0;const ot=fe,Tt=R,Le=Dr,Rr=[],Mr=[],Nr=[],xo=BigInt(0),gt=BigInt(1),Xo=BigInt(2),zo=BigInt(7),Ko=BigInt(256),Zo=BigInt(113);for(let i=0,e=gt,t=1,n=0;i<24;i++){[t,n]=[n,(2*t+3*n)%5],Rr.push(2*(5*n+t)),Mr.push((i+1)*(i+2)/2%64);let r=xo;for(let s=0;s<7;s++)e=(e<<gt^(e>>zo)*Zo)%Ko,e&Xo&&(r^=gt<<(gt<<BigInt(s))-gt);Nr.push(r)}const[Yo,ea]=(0,Tt.split)(Nr,!0),Ci=(i,e,t)=>t>32?(0,Tt.rotlBH)(i,e,t):(0,Tt.rotlSH)(i,e,t),Ti=(i,e,t)=>t>32?(0,Tt.rotlBL)(i,e,t):(0,Tt.rotlSL)(i,e,t);function Lr(i,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)t[o]=i[o]^i[o+10]^i[o+20]^i[o+30]^i[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,f=t[l],u=t[l+1],c=Ci(f,u,1)^t[a],h=Ti(f,u,1)^t[a+1];for(let p=0;p<50;p+=10)i[o+p]^=c,i[o+p+1]^=h}let r=i[2],s=i[3];for(let o=0;o<24;o++){const a=Mr[o],l=Ci(r,s,a),f=Ti(r,s,a),u=Rr[o];r=i[u],s=i[u+1],i[u]=l,i[u+1]=f}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=i[o+a];for(let a=0;a<10;a++)i[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}i[0]^=Yo[n],i[1]^=ea[n]}t.fill(0)}K.keccakP=Lr;class Ft extends Le.Hash{constructor(e,t,n,r=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,ot.number)(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,Le.u32)(this.state)}keccak(){Le.isLE||(0,Le.byteSwap32)(this.state32),Lr(this.state32,this.rounds),Le.isLE||(0,Le.byteSwap32)(this.state32),this.posOut=0,this.pos=0}update(e){(0,ot.exists)(this);const{blockLen:t,state:n}=this;e=(0,Le.toBytes)(e);const r=e.length;for(let s=0;s<r;){const o=Math.min(t-this.pos,r-s);for(let a=0;a<o;a++)n[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:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){(0,ot.exists)(this,!1),(0,ot.bytes)(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,s=e.length;r<s;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,s-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}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,ot.number)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,ot.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:n,outputLen:r,rounds:s,enableXOF:o}=this;return e||(e=new Ft(t,n,r,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}}K.Keccak=Ft;const He=(i,e,t)=>(0,Le.wrapConstructor)(()=>new Ft(e,i,t));K.sha3_224=He(6,144,224/8);K.sha3_256=He(6,136,256/8);K.sha3_384=He(6,104,384/8);K.sha3_512=He(6,72,512/8);K.keccak_224=He(1,144,224/8);K.keccak_256=He(1,136,256/8);K.keccak_384=He(1,104,384/8);K.keccak_512=He(1,72,512/8);const Br=(i,e,t)=>(0,Le.wrapXOFConstructorWithOpts)((n={})=>new Ft(e,i,n.dkLen===void 0?t:n.dkLen,!0));K.shake128=Br(31,168,128/8);K.shake256=Br(31,136,256/8);const{sha3_512:ta}=K,qr=24,Et=32,Fn=(i=4,e=Math.random)=>{let t="";for(;t.length<i;)t=t+Math.floor(e()*36).toString(36);return t};function jr(i){let e=8n,t=0n;for(const n of i.values()){const r=BigInt(n);t=(t<<e)+r}return t}const Jr=(i="")=>jr(ta(i)).toString(36).slice(1),Ai=Array.from({length:26},(i,e)=>String.fromCharCode(e+97)),na=i=>Ai[Math.floor(i()*Ai.length)],Ur=({globalObj:i=typeof Kt<"u"?Kt:typeof window<"u"?window:{},random:e=Math.random}={})=>{const t=Object.keys(i).toString(),n=t.length?t+Fn(Et,e):Fn(Et,e);return Jr(n).substring(0,Et)},Wr=i=>()=>i++,ia=476782367,Vr=({random:i=Math.random,counter:e=Wr(Math.floor(i()*ia)),length:t=qr,fingerprint:n=Ur({random:i})}={})=>function(){const s=na(i),o=Date.now().toString(36),a=e().toString(36),l=Fn(t,i),f=`${o+l+a+n}`;return`${s+Jr(f).substring(1,t)}`},ra=Vr(),sa=(i,{minLength:e=2,maxLength:t=Et}={})=>{const n=i.length,r=/^[0-9a-z]+$/;try{if(typeof i=="string"&&n>=e&&n<=t&&r.test(i))return!0}finally{}return!1};Ve.getConstants=()=>({defaultLength:qr,bigLength:Et});Ve.init=Vr;Ve.createId=ra;Ve.bufToBigInt=jr;Ve.createCounter=Wr;Ve.createFingerprint=Ur;Ve.isCuid=sa;const{createId:oa,init:_a,getConstants:ka,isCuid:Ia}=Ve;var Pi=oa;const Fi=Wt(i=>!isNaN(i)&&isFinite(i));class ei{static object(...e){return ve(void 0,...e)}static json(...e){let t=e;return t.valueConverter&&!t.valueConverter.fieldTypeInDb&&(t.valueConverter.fieldTypeInDb="json"),ve(void 0,{valueConverter:{fieldTypeInDb:"json"}},...e)}static dateOnly(...e){return ve(()=>Date,{valueConverter:pe.DateOnly},...e)}static date(...e){return ve(()=>Date,...e)}static integer(...e){return ve(()=>Number,{valueConverter:pe.Integer,validate:Fi},...e)}static autoIncrement(...e){return ve(()=>Number,{allowApiUpdate:!1,dbReadOnly:!0,valueConverter:{...pe.Integer,fieldTypeInDb:"autoincrement"}},...e)}static number(...e){return ve(()=>Number,{validate:Fi},...e)}static createdAt(...e){return ve(()=>Date,{allowApiUpdate:!1,saving:(t,n,{isNew:r})=>{r&&(n.value=new Date)}},...e)}static updatedAt(...e){return ve(()=>Date,{allowApiUpdate:!1,saving:(t,n)=>{n.value=new Date}},...e)}static uuid(...e){return ve(()=>String,{allowApiUpdate:!1,defaultValue:()=>Sn(),saving:(t,n)=>{n.value||(n.value=Sn())}},...e)}static cuid(...e){return ve(()=>String,{allowApiUpdate:!1,defaultValue:()=>Pi(),saving:(t,n)=>{n.value||(n.value=Pi())}},...e)}static literal(e,...t){return ei.string({validate:(n,r)=>Be.in(e())(n,r),[mn]:e},...t)}static enum(e,...t){let n;return ve(()=>e(),{validate:(r,s)=>Be.enum(e())(r,s),[mn]:()=>Vt(e())},...t,r=>{if(r[mn]=()=>Vt(e()),n===void 0){let s=e();n=Vt(s).find(a=>typeof a=="string")?pe.String:pe.Integer}r.valueConverter?r.valueConverter.fieldTypeInDb||(r.valueConverter.fieldTypeInDb=n.fieldTypeInDb):r.valueConverter=n})}static string(...e){return ve(()=>String,...e)}static boolean(...e){return ve(()=>Boolean,...e)}}function ve(i,...e){return(t,n,r)=>{const s=typeof n=="string"?n:n.name.toString();let o=f=>{let u=tr(e,f);if(u.required&&(u.validate=Ht(u.validate,Be.required,!0)),It(u,"maxLength")){let h=u;h.maxLength&&(h.validate=Ht(h.validate,Be.maxLength(h.maxLength)))}if(It(u,"minLength")){let h=u;h.minLength&&(h.validate=Ht(h.validate,Be.minLength(h.minLength)))}!u.valueType&&i&&(u.valueType=i()),u.key||(u.key=s),u.dbName||(u.dbName=u.key);let c=u.valueType;return c||(c=typeof Reflect.getMetadata=="function"?Reflect.getMetadata("design:type",t,s):[],u.valueType=c),u.target||(u.target=t),u};Hr(t);let a=T.columnsOfType.get(t.constructor);a||(a=[],T.columnsOfType.set(t.constructor,a));let l=a.find(f=>f.key==s);if(!l)a.push({key:s,settings:o});else{let f=l.settings;l.settings=u=>{let c=f(u),h=o(u);return Object.assign(c,h)}}}}function Hr(i){if(!i)throw new Error("Set the 'experimentalDecorators:true' option in your 'tsconfig' or 'jsconfig' (target undefined)")}function aa(i,e,t,n){var r=arguments.length,s=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(i,e,t,n);else for(var a=i.length-1;a>=0;a--)(o=i[a])&&(s=(r<3?o(s):r>3?o(e,t,s):o(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s}function la(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)}class ua extends nr{constructor(){super(...arguments);d(this,"id")}}aa([ei.uuid(),la("design:type",String)],ua.prototype,"id",void 0);var Di={};/*! *****************************************************************************
|
|
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 Ri;(function(i){(function(e){var t=typeof Kt=="object"?Kt:typeof self=="object"?self:typeof this=="object"?this:Function("return this;")(),n=r(i);typeof t.Reflect>"u"?t.Reflect=i:n=r(t.Reflect,n),e(n);function r(s,o){return function(a,l){typeof s[a]!="function"&&Object.defineProperty(s,a,{configurable:!0,writable:!0,value:l}),o&&o(a,l)}}})(function(e){var t=Object.prototype.hasOwnProperty,n=typeof Symbol=="function",r=n&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",s=n&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",o=typeof Object.create=="function",a={__proto__:[]}instanceof Array,l=!o&&!a,f={create:o?function(){return an(Object.create(null))}:a?function(){return an({__proto__:null})}:function(){return an({})},has:l?function(m,b){return t.call(m,b)}:function(m,b){return b in m},get:l?function(m,b){return t.call(m,b)?m[b]:void 0}:function(m,b){return m[b]}},u=Object.getPrototypeOf(Function),c=typeof process=="object"&&Di&&Di.REFLECT_METADATA_USE_MAP_POLYFILL==="true",h=!c&&typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Os(),p=!c&&typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Es(),y=!c&&typeof WeakMap=="function"?WeakMap:Ss(),_=new y;function w(m,b,I,S){if(le(I)){if(!ti(m))throw new TypeError;if(!ni(b))throw new TypeError;return Oe(m,b)}else{if(!ti(m))throw new TypeError;if(!de(b))throw new TypeError;if(!de(S)&&!le(S)&&!it(S))throw new TypeError;return it(S)&&(S=void 0),I=Ne(I),Ee(m,b,I,S)}}e("decorate",w);function g(m,b){function I(S,A){if(!de(S))throw new TypeError;if(!le(A)&&!bs(A))throw new TypeError;re(m,b,S,A)}return I}e("metadata",g);function k(m,b,I,S){if(!de(I))throw new TypeError;return le(S)||(S=Ne(S)),re(m,b,I,S)}e("defineMetadata",k);function E(m,b,I){if(!de(b))throw new TypeError;return le(I)||(I=Ne(I)),O(m,b,I)}e("hasMetadata",E);function N(m,b,I){if(!de(b))throw new TypeError;return le(I)||(I=Ne(I)),D(m,b,I)}e("hasOwnMetadata",N);function J(m,b,I){if(!de(b))throw new TypeError;return le(I)||(I=Ne(I)),W(m,b,I)}e("getMetadata",J);function ne(m,b,I){if(!de(b))throw new TypeError;return le(I)||(I=Ne(I)),z(m,b,I)}e("getOwnMetadata",ne);function ie(m,b){if(!de(m))throw new TypeError;return le(b)||(b=Ne(b)),Te(m,b)}e("getMetadataKeys",ie);function $(m,b){if(!de(m))throw new TypeError;return le(b)||(b=Ne(b)),mt(m,b)}e("getOwnMetadataKeys",$);function ae(m,b,I){if(!de(b))throw new TypeError;le(I)||(I=Ne(I));var S=v(b,I,!1);if(le(S)||!S.delete(m))return!1;if(S.size>0)return!0;var A=_.get(b);return A.delete(I),A.size>0||_.delete(b),!0}e("deleteMetadata",ae);function Oe(m,b){for(var I=m.length-1;I>=0;--I){var S=m[I],A=S(b);if(!le(A)&&!it(A)){if(!ni(A))throw new TypeError;b=A}}return b}function Ee(m,b,I,S){for(var A=m.length-1;A>=0;--A){var be=m[A],M=be(b,I,S);if(!le(M)&&!it(M)){if(!de(M))throw new TypeError;S=M}}return S}function v(m,b,I){var S=_.get(m);if(le(S)){if(!I)return;S=new h,_.set(m,S)}var A=S.get(b);if(le(A)){if(!I)return;A=new h,S.set(b,A)}return A}function O(m,b,I){var S=D(m,b,I);if(S)return!0;var A=on(b);return it(A)?!1:O(m,A,I)}function D(m,b,I){var S=v(b,I,!1);return le(S)?!1:ws(S.has(m))}function W(m,b,I){var S=D(m,b,I);if(S)return z(m,b,I);var A=on(b);if(!it(A))return W(m,A,I)}function z(m,b,I){var S=v(b,I,!1);if(!le(S))return S.get(m)}function re(m,b,I,S){var A=v(I,S,!0);A.set(m,b)}function Te(m,b){var I=mt(m,b),S=on(m);if(S===null)return I;var A=Te(S,b);if(A.length<=0)return I;if(I.length<=0)return A;for(var be=new p,M=[],B=0,F=I;B<F.length;B++){var V=F[B],H=be.has(V);H||(be.add(V),M.push(V))}for(var qe=0,ri=A;qe<ri.length;qe++){var V=ri[qe],H=be.has(V);H||(be.add(V),M.push(V))}return M}function mt(m,b){var I=[],S=v(m,b,!1);if(le(S))return I;for(var A=S.keys(),be=vs(A),M=0;;){var B=ks(be);if(!B)return I.length=M,I;var F=_s(B);try{I[M]=F}catch(V){try{Is(be)}finally{throw V}}M++}}function Dt(m){if(m===null)return 1;switch(typeof m){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return m===null?1:6;default:return 6}}function le(m){return m===void 0}function it(m){return m===null}function ps(m){return typeof m=="symbol"}function de(m){return typeof m=="object"?m!==null:typeof m=="function"}function ys(m,b){switch(Dt(m)){case 0:return m;case 1:return m;case 2:return m;case 3:return m;case 4:return m;case 5:return m}var I="string",S=ii(m,r);if(S!==void 0){var A=S.call(m,I);if(de(A))throw new TypeError;return A}return ms(m)}function ms(m,b){var I,S;{var A=m.toString;if(Rt(A)){var S=A.call(m);if(!de(S))return S}var I=m.valueOf;if(Rt(I)){var S=I.call(m);if(!de(S))return S}}throw new TypeError}function ws(m){return!!m}function gs(m){return""+m}function Ne(m){var b=ys(m);return ps(b)?b:gs(b)}function ti(m){return Array.isArray?Array.isArray(m):m instanceof Object?m instanceof Array:Object.prototype.toString.call(m)==="[object Array]"}function Rt(m){return typeof m=="function"}function ni(m){return typeof m=="function"}function bs(m){switch(Dt(m)){case 3:return!0;case 4:return!0;default:return!1}}function ii(m,b){var I=m[b];if(I!=null){if(!Rt(I))throw new TypeError;return I}}function vs(m){var b=ii(m,s);if(!Rt(b))throw new TypeError;var I=b.call(m);if(!de(I))throw new TypeError;return I}function _s(m){return m.value}function ks(m){var b=m.next();return b.done?!1:b}function Is(m){var b=m.return;b&&b.call(m)}function on(m){var b=Object.getPrototypeOf(m);if(typeof m!="function"||m===u||b!==u)return b;var I=m.prototype,S=I&&Object.getPrototypeOf(I);if(S==null||S===Object.prototype)return b;var A=S.constructor;return typeof A!="function"||A===m?b:A}function Os(){var m={},b=[],I=function(){function M(B,F,V){this._index=0,this._keys=B,this._values=F,this._selector=V}return M.prototype["@@iterator"]=function(){return this},M.prototype[s]=function(){return this},M.prototype.next=function(){var B=this._index;if(B>=0&&B<this._keys.length){var F=this._selector(this._keys[B],this._values[B]);return B+1>=this._keys.length?(this._index=-1,this._keys=b,this._values=b):this._index++,{value:F,done:!1}}return{value:void 0,done:!0}},M.prototype.throw=function(B){throw this._index>=0&&(this._index=-1,this._keys=b,this._values=b),B},M.prototype.return=function(B){return this._index>=0&&(this._index=-1,this._keys=b,this._values=b),{value:B,done:!0}},M}();return function(){function M(){this._keys=[],this._values=[],this._cacheKey=m,this._cacheIndex=-2}return Object.defineProperty(M.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),M.prototype.has=function(B){return this._find(B,!1)>=0},M.prototype.get=function(B){var F=this._find(B,!1);return F>=0?this._values[F]:void 0},M.prototype.set=function(B,F){var V=this._find(B,!0);return this._values[V]=F,this},M.prototype.delete=function(B){var F=this._find(B,!1);if(F>=0){for(var V=this._keys.length,H=F+1;H<V;H++)this._keys[H-1]=this._keys[H],this._values[H-1]=this._values[H];return this._keys.length--,this._values.length--,B===this._cacheKey&&(this._cacheKey=m,this._cacheIndex=-2),!0}return!1},M.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=m,this._cacheIndex=-2},M.prototype.keys=function(){return new I(this._keys,this._values,S)},M.prototype.values=function(){return new I(this._keys,this._values,A)},M.prototype.entries=function(){return new I(this._keys,this._values,be)},M.prototype["@@iterator"]=function(){return this.entries()},M.prototype[s]=function(){return this.entries()},M.prototype._find=function(B,F){return this._cacheKey!==B&&(this._cacheIndex=this._keys.indexOf(this._cacheKey=B)),this._cacheIndex<0&&F&&(this._cacheIndex=this._keys.length,this._keys.push(B),this._values.push(void 0)),this._cacheIndex},M}();function S(M,B){return M}function A(M,B){return B}function be(M,B){return[M,B]}}function Es(){return function(){function m(){this._map=new h}return Object.defineProperty(m.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),m.prototype.has=function(b){return this._map.has(b)},m.prototype.add=function(b){return this._map.set(b,b),this},m.prototype.delete=function(b){return this._map.delete(b)},m.prototype.clear=function(){this._map.clear()},m.prototype.keys=function(){return this._map.keys()},m.prototype.values=function(){return this._map.values()},m.prototype.entries=function(){return this._map.entries()},m.prototype["@@iterator"]=function(){return this.keys()},m.prototype[s]=function(){return this.keys()},m}()}function Ss(){var m=16,b=f.create(),I=S();return function(){function F(){this._key=S()}return F.prototype.has=function(V){var H=A(V,!1);return H!==void 0?f.has(H,this._key):!1},F.prototype.get=function(V){var H=A(V,!1);return H!==void 0?f.get(H,this._key):void 0},F.prototype.set=function(V,H){var qe=A(V,!0);return qe[this._key]=H,this},F.prototype.delete=function(V){var H=A(V,!1);return H!==void 0?delete H[this._key]:!1},F.prototype.clear=function(){this._key=S()},F}();function S(){var F;do F="@@WeakMap@@"+B();while(f.has(b,F));return b[F]=!0,F}function A(F,V){if(!t.call(F,I)){if(!V)return;Object.defineProperty(F,I,{value:f.create()})}return F[I]}function be(F,V){for(var H=0;H<V;++H)F[H]=Math.random()*255|0;return F}function M(F){return typeof Uint8Array=="function"?typeof crypto<"u"?crypto.getRandomValues(new Uint8Array(F)):typeof msCrypto<"u"?msCrypto.getRandomValues(new Uint8Array(F)):be(new Uint8Array(F),F):be(new Array(F),F)}function B(){var F=M(m);F[6]=F[6]&79|64,F[8]=F[8]&191|128;for(var V="",H=0;H<m;++H){var qe=F[H];(H===4||H===6||H===8)&&(V+="-"),qe<16&&(V+="0"),V+=qe.toString(16).toLowerCase()}return V}}function an(m){return m.__=void 0,delete m.__,m}})})(Ri||(Ri={}));const Yt=class Yt{constructor(e,t,n){d(this,"actionUrl");d(this,"queue");d(this,"allowed");d(this,"doWork");this.actionUrl=e,this.queue=t,this.allowed=n}async run(e,t,n){t===void 0&&(t=Se.apiClient.url),n||(n=Pt(Se.apiClient.httpClient));let r=await n.post(t+"/"+this.actionUrl,e),s=r;if(s&&s.queuedJobId){let o=T.actionInfo.startBusyWithProgress();try{let a;if(await T.actionInfo.runActionWithoutBlockingUI(async()=>{for(;!a||!a.done;)a&&await new Promise(l=>setTimeout(()=>{l(void 0)},200)),a=await n.post(t+"/"+Yt.apiUrlForJobStatus,{queuedJobId:r.queuedJobId}),a.progress&&o.progress(a.progress)}),a.error)throw a.error;return o.progress(1),a.result}finally{o.close()}}else return r}__register(e){e(this.actionUrl,this.queue,this.allowed,async(t,n,r)=>{try{var s=await this.execute(t,n,r);r.success(s)}catch(o){o.isForbiddenError?r.forbidden():r.error(o,void 0)}})}};d(Yt,"apiUrlForJobStatus","jobStatusInQueue");let At=Yt;class Dn extends Error{constructor(t="Forbidden"){super(t);d(this,"isForbiddenError",!0)}}class fa extends At{constructor(t,n,r,s){super(t,r.queue??!1,r.allowed);d(this,"types");d(this,"options");d(this,"originalMethod");this.types=n,this.options=r,this.originalMethod=s}async execute(t,n,r){let s={data:{}},o=n.dataProvider;return await zi(n,async()=>{if(!n.isAllowedForInstance(void 0,this.options.allowed))throw new Dn;t.args=await $r(this.types(),t.args,n,o,r);try{s.data=await this.originalMethod(t.args)}catch(a){throw a}}),s}}function Re(i){return(e,t,n)=>{const r=typeof t=="string"?t:t.name.toString(),s=n?n.value:e;let o=s;Hr(e);function a(){var u=typeof Reflect.getMetadata=="function"?Reflect.getMetadata("design:paramtypes",e,r):[];return i.paramTypes&&(u=typeof i.paramTypes=="function"?i.paramTypes():i.paramTypes),u}if(e.prototype!==void 0){let u=new fa((i!=null&&i.apiPrefix?i.apiPrefix+"/":"")+r,()=>a(),i,c=>s.apply(void 0,c));return u.doWork=async(c,h,p,y)=>(c=Li(a(),c),i.blockUser===!1?await T.actionInfo.runActionWithoutBlockingUI(async()=>(await u.run({args:c},p,y)).data):(await u.run({args:c},p,y)).data),o=async function(...c){return Tn()?await s.apply(this,c):await u.doWork(c,void 0)},Mi(e,o),o[Cn]=u,n?(n.value=o,n):o}let l=T.classHelpers.get(e.constructor);l||(l=new Oo,T.classHelpers.set(e.constructor,l));let f={__register(u){let c=new Pe;for(const h of l.classes.keys()){let p=l.classes.get(h);p.key||(p.key=c.repo(h).metadata.key),u(p.key+"/"+(i!=null&&i.apiPrefix?i.apiPrefix+"/":"")+r,i?i.queue??!1:!1,i.allowed,async(y,_,w)=>{y.args=y.args.map(k=>Qr(k)?void 0:k);let g=i.allowed;try{let k=_,E;await zi(k,async()=>{if(y.args=await $r(a(),y.args,k,k.dataProvider,w),T.allEntities.includes(h)){let N=k.repo(h),J;const ne=y.rowInfo;if(ne.isNewRow)J=N.create(),await N.getEntityRef(J)._updateEntityBasedOnApi(ne.data);else{let $=await N.find({where:{...N.metadata.idMetadata.getIdFilter(ne.id),$and:[N.metadata.options.apiPrefilter??{}]}});if($.length!=1)throw new Error("not found or too many matches");J=$[0],await N.getEntityRef(J)._updateEntityBasedOnApi(ne.data)}if(!k.isAllowedForInstance(J,g))throw new Dn;let ie=ee(J);await ie.__validateEntity();try{E={result:await s.apply(J,y.args),rowInfo:{data:await ie.toApiJson(),isNewRow:ie.isNew(),wasChanged:ie.wasChanged(),id:ie.getOriginalId()}}}catch($){throw ie.catchSaveErrors($)}}else{let N=new h(k,k.dataProvider),J=Oi(N,k);if(await J._updateEntityBasedOnApi(y.fields),!k.isAllowedForInstance(N,g))throw new Dn;await J.__validateEntity();try{E={result:await s.apply(N,y.args),fields:await J.toApiJson()}}catch(ne){throw J.catchSaveErrors(ne)}}}),w.success(E)}catch(k){k.isForbiddenError?w.forbidden():w.error(k,void 0)}})}},doWork:async function(u,c,h,p){if(u=Li(a(),u),T.allEntities.includes(e.constructor)){let y=ee(c);await y.__validateEntity();let _=l.classes.get(c.constructor);_.key||(_.key=y.repository.metadata.key+"_methods");try{let w=await new class extends At{constructor(){super(...arguments);d(this,"execute")}}(_.key+"/"+(i!=null&&i.apiPrefix?i.apiPrefix+"/":"")+r,(i==null?void 0:i.queue)??!1,i.allowed).run({args:u,rowInfo:{data:await y.toApiJson(),isNewRow:y.isNew(),wasChanged:y.wasChanged(),id:y.getOriginalId()}},h,p);return await y._updateEntityBasedOnApi(w.rowInfo.data,!0),w.result}catch(w){throw y.catchSaveErrors(w)}}else{let y=Oi(c,void 0);try{await y.__validateEntity();let _=await new class extends At{constructor(){super(...arguments);d(this,"execute")}}(l.classes.get(c.constructor).key+"/"+(i!=null&&i.apiPrefix?i.apiPrefix+"/":"")+r,(i==null?void 0:i.queue)??!1,i.allowed).run({args:u,fields:await y.toApiJson()},h,p);return await y._updateEntityBasedOnApi(_.fields),_.result}catch(_){throw y.catchSaveErrors(_)}}}};return o=async function(...u){let c=this;return Tn()?await s.apply(c,u):f.doWork(u,c)},Mi(e.constructor,o),o[Cn]=f,n?(n.value=o,n):o}}const ca={_isUndefined:!0};function Mi(i,e){(i[Bi]||(i[Bi]=[])).push(e),T.actionInfo.allActions.push(e)}function Qr(i){return i&&i._isUndefined}class Ni{constructor(e){d(this,"res");this.res=e}progress(e){this.res.progress(e)}}function Li(i,e){if(i)for(let t=0;t<i.length;t++){const n=i[t];for(const r of[Pe,ct])(e[t]instanceof r||n==r)&&(e[t]=void 0);if(e[t]!=null){let r={valueType:n};if(r=zn(r,new Pe),Ie(n,!1)!=null){let o=ee(e[t]);e[t]=o.getId()}r.valueConverter&&(e[t]=r.valueConverter.toJson(e[t]))}}return e.map(t=>t!==void 0?t:ca)}async function $r(i,e,t,n,r){for(let s=0;s<e.length;s++){const o=e[s];Qr(o)&&(e[s]=void 0)}if(i)for(let s=0;s<i.length;s++)if(e.length<s&&e.push(void 0),i[s]==Pe||i[s]==Pe)e[s]=t;else if(i[s]==ct&&n)e[s]=n;else if(i[s]==Ni)e[s]=new Ni(r);else{let o={valueType:i[s]};o=zn(o,t),o.valueConverter&&(e[s]=o.valueConverter.fromJson(e[s])),Ie(i[s],!1)!=null&&(e[s]===null||e[s]===void 0||(e[s]=await t.repo(i[s]).findId(e[s])))}return e}const Bi=Symbol.for("classBackendMethodsArray");T.actionInfo;function sn(i){return i}var da=Object.defineProperty,ha=Object.getOwnPropertyDescriptor,Me=(i,e,t,n)=>{for(var r=ha(e,t),s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(e,t,r)||r);return r&&da(e,t,r),r},Y;const Fe=(Y=class{static async signOut(){return await Y.signOutFn()}static async signInDemo(e){return await Y.signInDemoFn(e)}static async invite(e){return await Y.inviteFn(e)}static async signUpPassword(e,t){return await Y.signUpPasswordFn(e,t)}static async signInPassword(e,t){return await Y.signInPasswordFn(e,t)}static async forgotPassword(e){return await Y.forgotPasswordFn(e)}static async resetPassword(e,t){return await Y.resetPasswordFn(e,t)}static async signInOTP(e){return await Y.signInOTPFn(e)}static async verifyOtp(e,t){return await Y.verifyOtpFn(e,t)}static async signInOAuthGetUrl(e){return await Y.signInOAuthGetUrlFn(e)}},d(Y,"signOutFn"),d(Y,"signInDemoFn"),d(Y,"inviteFn"),d(Y,"signUpPasswordFn"),d(Y,"signInPasswordFn"),d(Y,"forgotPasswordFn"),d(Y,"resetPasswordFn"),d(Y,"signInOTPFn"),d(Y,"verifyOtpFn"),d(Y,"signInOAuthGetUrlFn"),Y);Me([Re({allowed:!0})],Fe,"signOut");Me([Re({allowed:!0})],Fe,"signInDemo");Me([Re({allowed:!1})],Fe,"invite");Me([Re({allowed:!0})],Fe,"signUpPassword");Me([Re({allowed:!0})],Fe,"signInPassword");Me([Re({allowed:!0})],Fe,"forgotPassword");Me([Re({allowed:!0})],Fe,"resetPassword");Me([Re({allowed:!0})],Fe,"signInOTP");Me([Re({allowed:!0})],Fe,"verifyOtp");Me([Re({allowed:!0})],Fe,"signInOAuthGetUrl");let We=Fe;function yt(i){i.focus()}const bt="src/lib/modules/auth/components/ForgotPassword.svelte";function Rn(i){var w;let e,t,n,r,s,o,a,l,f,u,c=((w=i[1].ui)==null?void 0:w.strings.send_password_reset_instructions)+"",h,p,y;const _={c:function(){var k;e=q("div"),t=q("p"),n=se(i[2]),r=se(i[3]),s=X(),o=q("form"),a=q("input"),f=X(),u=q("button"),h=se(c),Q(t,"class","message"),Ue(t,"error",i[2]),j(t,bt,27,2,528),Q(a,"type","text"),Q(a,"placeholder",l=(k=i[1].ui)==null?void 0:k.strings.email_placeholder),j(a,bt,29,4,644),j(u,bt,35,4,791),Q(o,"class","s-KT008SdmQprk"),j(o,bt,28,2,599),Q(e,"class","login"),j(e,bt,26,0,506)},l:function(k){throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(k,E){G(k,e,E),C(e,t),C(t,n),C(t,r),C(e,s),C(e,o),C(o,a),_e(a,i[0]),C(o,f),C(o,u),C(u,h),p||(y=[en(yt.call(null,a)),Ce(a,"input",i[5]),Ce(o,"submit",tn(i[4]),!1,!0,!1,!1)],p=!0)},p:function(k,[E]){var N,J;E&4&&ye(n,k[2]),E&4&&Ue(t,"error",k[2]),E&2&&l!==(l=(N=k[1].ui)==null?void 0:N.strings.email_placeholder)&&Q(a,"placeholder",l),E&1&&a.value!==k[0]&&_e(a,k[0]),E&2&&c!==(c=((J=k[1].ui)==null?void 0:J.strings.send_password_reset_instructions)+"")&&ye(h,c)},i:ue,o:ue,d:function(k){k&&x(e),p=!1,dt(y)}};return U("SvelteRegisterBlock",{block:_,id:Rn.name,type:"component",source:"",ctx:i}),_}function pa(i,e,t){let{$$slots:n={},$$scope:r}=e;nt("ForgotPassword",n,[]);let{firstlyDataAuth:s}=e,{email:o=""}=e,a="",l="";async function f(){try{await We.forgotPassword(o),window.location.href="/ff/auth/sign-in"}catch(h){h&&t(2,a=h.message??"")}}i.$$.on_mount.push(function(){s===void 0&&!("firstlyDataAuth"in e||i.$$.bound[i.$$.props.firstlyDataAuth])&&console.warn("<ForgotPassword> was created without expected prop 'firstlyDataAuth'")});const u=["firstlyDataAuth","email"];Object.keys(e).forEach(h=>{!~u.indexOf(h)&&h.slice(0,2)!=="$$"&&h!=="slot"&&console.warn(`<ForgotPassword> was created with unknown prop '${h}'`)});function c(){o=this.value,t(0,o)}return i.$$set=h=>{"firstlyDataAuth"in h&&t(1,s=h.firstlyDataAuth),"email"in h&&t(0,o=h.email)},i.$capture_state=()=>({isError:sn,Auth:We,autofocus:yt,firstlyDataAuth:s,email:o,msgError:a,msgSuccess:l,forgot:f}),i.$inject_state=h=>{"firstlyDataAuth"in h&&t(1,s=h.firstlyDataAuth),"email"in h&&t(0,o=h.email),"msgError"in h&&t(2,a=h.msgError),"msgSuccess"in h&&t(3,l=h.msgSuccess)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),[o,s,a,l,f,c]}class Gr extends et{constructor(e){super(e),tt(this,e,pa,Rn,ht,{firstlyDataAuth:1,email:0}),U("SvelteRegisterComponent",{component:this,tagName:"ForgotPassword",options:e,id:Rn.name})}get firstlyDataAuth(){throw new Error("<ForgotPassword>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set firstlyDataAuth(e){throw new Error("<ForgotPassword>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get email(){throw new Error("<ForgotPassword>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set email(e){throw new Error("<ForgotPassword>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}const at="src/lib/modules/auth/components/ResetPassword.svelte";function Mn(i){var J,ne;let e,t,n,r,s,o,a=((J=i[2].ui)==null?void 0:J.strings.password)+"",l,f,u,c,h=((ne=i[2].ui)==null?void 0:ne.strings.password)+"",p,y,_,w,g,k,E;const N={c:function(){e=q("div"),t=q("p"),n=se(i[3]),r=se(i[4]),s=X(),o=q("form"),l=se(a),f=X(),u=q("input"),c=X(),p=se(h),y=X(),_=q("input"),w=X(),g=q("button"),g.textContent="reset",Q(t,"class","message"),Ue(t,"error",i[3]),j(t,at,28,2,621),Q(u,"type","password"),j(u,at,31,4,779),Q(_,"type","password"),j(_,at,33,4,875),j(g,at,34,4,928),Q(o,"class","s-N0DaQgJ_T5_C"),j(o,at,29,2,692),Q(e,"class","login"),j(e,at,27,0,599)},l:function($){throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function($,ae){G($,e,ae),C(e,t),C(t,n),C(t,r),C(e,s),C(e,o),C(o,l),C(o,f),C(o,u),_e(u,i[0]),C(o,c),C(o,p),C(o,y),C(o,_),_e(_,i[1]),C(o,w),C(o,g),k||(E=[Ce(u,"input",i[6]),Ce(_,"input",i[7]),Ce(o,"submit",tn(i[5]),!1,!0,!1,!1)],k=!0)},p:function($,[ae]){var Oe,Ee;ae&8&&ye(n,$[3]),ae&16&&ye(r,$[4]),ae&8&&Ue(t,"error",$[3]),ae&4&&a!==(a=((Oe=$[2].ui)==null?void 0:Oe.strings.password)+"")&&ye(l,a),ae&1&&u.value!==$[0]&&_e(u,$[0]),ae&4&&h!==(h=((Ee=$[2].ui)==null?void 0:Ee.strings.password)+"")&&ye(p,h),ae&2&&_.value!==$[1]&&_e(_,$[1])},i:ue,o:ue,d:function($){$&&x(e),k=!1,dt(E)}};return U("SvelteRegisterBlock",{block:N,id:Mn.name,type:"component",source:"",ctx:i}),N}function ya(i,e,t){let{$$slots:n={},$$scope:r}=e;nt("ResetPassword",n,[]);let{firstlyDataAuth:s}=e,{password1:o=""}=e,{password2:a=""}=e,l="",f="";async function u(){t(3,l=""),t(4,f="");const y=new URL(location.href).searchParams.get("token");try{await We.resetPassword(y??"",o),window.location.href="/"}catch(_){_&&t(3,l=_.message??"")}}i.$$.on_mount.push(function(){s===void 0&&!("firstlyDataAuth"in e||i.$$.bound[i.$$.props.firstlyDataAuth])&&console.warn("<ResetPassword> was created without expected prop 'firstlyDataAuth'")});const c=["firstlyDataAuth","password1","password2"];Object.keys(e).forEach(y=>{!~c.indexOf(y)&&y.slice(0,2)!=="$$"&&y!=="slot"&&console.warn(`<ResetPassword> was created with unknown prop '${y}'`)});function h(){o=this.value,t(0,o)}function p(){a=this.value,t(1,a)}return i.$$set=y=>{"firstlyDataAuth"in y&&t(2,s=y.firstlyDataAuth),"password1"in y&&t(0,o=y.password1),"password2"in y&&t(1,a=y.password2)},i.$capture_state=()=>({isError:sn,Auth:We,firstlyDataAuth:s,password1:o,password2:a,msgError:l,msgSuccess:f,reset:u}),i.$inject_state=y=>{"firstlyDataAuth"in y&&t(2,s=y.firstlyDataAuth),"password1"in y&&t(0,o=y.password1),"password2"in y&&t(1,a=y.password2),"msgError"in y&&t(3,l=y.msgError),"msgSuccess"in y&&t(4,f=y.msgSuccess)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),[o,a,s,l,f,u,h,p]}class xr extends et{constructor(e){super(e),tt(this,e,ya,Mn,ht,{firstlyDataAuth:2,password1:0,password2:1}),U("SvelteRegisterComponent",{component:this,tagName:"ResetPassword",options:e,id:Mn.name})}get firstlyDataAuth(){throw new Error("<ResetPassword>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set firstlyDataAuth(e){throw new Error("<ResetPassword>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get password1(){throw new Error("<ResetPassword>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set password1(e){throw new Error("<ResetPassword>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get password2(){throw new Error("<ResetPassword>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set password2(e){throw new Error("<ResetPassword>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}const{Error:Ge}=Jn,Qe="src/lib/modules/auth/components/SignIn.svelte";function Nn(i){var ae,Oe,Ee;let e,t,n,r,s,o,a=((ae=i[1].ui)==null?void 0:ae.strings.email)+"",l,f,u,c,h,p,y=((Oe=i[1].ui)==null?void 0:Oe.strings.password)+"",_,w,g,k,E,N=((Ee=i[1].ui)==null?void 0:Ee.strings.btn_sign_in)+"",J,ne,ie;const $={c:function(){var O;e=q("form"),t=q("p"),n=se(i[3]),r=se(i[4]),s=X(),o=q("label"),l=se(a),f=X(),u=q("input"),h=X(),p=q("label"),_=se(y),w=X(),g=q("input"),k=X(),E=q("button"),J=se(N),Q(t,"class","message s-85Tmcm64bnMI"),Ue(t,"error",i[3]),j(t,Qe,37,4,718),Q(u,"type","text"),Q(u,"placeholder",c=(O=i[1].ui)==null?void 0:O.strings.email_placeholder),j(u,Qe,40,6,847),j(o,Qe,38,4,791),Q(g,"type","password"),j(g,Qe,49,6,1076),j(p,Qe,47,4,1017),j(E,Qe,51,4,1141),Q(e,"class","s-85Tmcm64bnMI"),j(e,Qe,36,2,673)},m:function(O,D){G(O,e,D),C(e,t),C(t,n),C(t,r),C(e,s),C(e,o),C(o,l),C(o,f),C(o,u),_e(u,i[0]),C(e,h),C(e,p),C(p,_),C(p,w),C(p,g),_e(g,i[5]),C(e,k),C(e,E),C(E,J),ne||(ie=[Ce(u,"input",i[7]),en(yt.call(null,u)),Ce(g,"input",i[8]),Ce(e,"submit",tn(i[6]),!1,!0,!1,!1)],ne=!0)},p:function(O,D){var W,z,re,Te;D&8&&ye(n,O[3]),D&16&&ye(r,O[4]),D&8&&Ue(t,"error",O[3]),D&2&&a!==(a=((W=O[1].ui)==null?void 0:W.strings.email)+"")&&ye(l,a),D&2&&c!==(c=(z=O[1].ui)==null?void 0:z.strings.email_placeholder)&&Q(u,"placeholder",c),D&1&&u.value!==O[0]&&_e(u,O[0]),D&2&&y!==(y=((re=O[1].ui)==null?void 0:re.strings.password)+"")&&ye(_,y),D&32&&g.value!==O[5]&&_e(g,O[5]),D&2&&N!==(N=((Te=O[1].ui)==null?void 0:Te.strings.btn_sign_in)+"")&&ye(J,N)},d:function(O){O&&x(e),ne=!1,dt(ie)}};return U("SvelteRegisterBlock",{block:$,id:Nn.name,type:"if",source:"(27:0) {#if view == 'login'}",ctx:i}),$}function Ln(i){let e,t=i[2]=="login"&&Nn(i);const n={c:function(){t&&t.c(),e=Un()},l:function(s){throw new Ge("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(s,o){t&&t.m(s,o),G(s,e,o)},p:function(s,[o]){s[2]=="login"?t?t.p(s,o):(t=Nn(s),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},i:ue,o:ue,d:function(s){s&&x(e),t&&t.d(s)}};return U("SvelteRegisterBlock",{block:n,id:Ln.name,type:"component",source:"",ctx:i}),n}function ma(i,e,t){let{$$slots:n={},$$scope:r}=e;nt("SignIn",n,[]);let{firstlyDataAuth:s}=e,{view:o="login"}=e,{email:a=""}=e,l="",f="",u;async function c(){t(3,l=""),t(4,f="");try{await We.signInPassword(a,u),window.location.href="/"}catch(w){w&&t(3,l=w.message??"")}}const h=()=>{throw new Error("Not impl yet")};i.$$.on_mount.push(function(){s===void 0&&!("firstlyDataAuth"in e||i.$$.bound[i.$$.props.firstlyDataAuth])&&console.warn("<SignIn> was created without expected prop 'firstlyDataAuth'")});const p=["firstlyDataAuth","view","email"];Object.keys(e).forEach(w=>{!~p.indexOf(w)&&w.slice(0,2)!=="$$"&&w!=="slot"&&console.warn(`<SignIn> was created with unknown prop '${w}'`)});function y(){a=this.value,t(0,a)}function _(){u=this.value,t(5,u)}return i.$$set=w=>{"firstlyDataAuth"in w&&t(1,s=w.firstlyDataAuth),"view"in w&&t(2,o=w.view),"email"in w&&t(0,a=w.email)},i.$capture_state=()=>({Auth:We,isError:sn,autofocus:yt,firstlyDataAuth:s,view:o,email:a,msgError:l,msgSuccess:f,password:u,signIn:c,handlePin:h}),i.$inject_state=w=>{"firstlyDataAuth"in w&&t(1,s=w.firstlyDataAuth),"view"in w&&t(2,o=w.view),"email"in w&&t(0,a=w.email),"msgError"in w&&t(3,l=w.msgError),"msgSuccess"in w&&t(4,f=w.msgSuccess),"password"in w&&t(5,u=w.password)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),[a,s,o,l,f,u,c,y,_]}class Xr extends et{constructor(e){super(e),tt(this,e,ma,Ln,ht,{firstlyDataAuth:1,view:2,email:0}),U("SvelteRegisterComponent",{component:this,tagName:"SignIn",options:e,id:Ln.name})}get firstlyDataAuth(){throw new Ge("<SignIn>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set firstlyDataAuth(e){throw new Ge("<SignIn>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get view(){throw new Ge("<SignIn>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set view(e){throw new Ge("<SignIn>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get email(){throw new Ge("<SignIn>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set email(e){throw new Ge("<SignIn>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}const{Error:xe}=Jn,$e="src/lib/modules/auth/components/SignUp.svelte";function Bn(i){var ae,Oe,Ee;let e,t,n,r,s,o,a=((ae=i[1].ui)==null?void 0:ae.strings.email)+"",l,f,u,c,h,p,y=((Oe=i[1].ui)==null?void 0:Oe.strings.password)+"",_,w,g,k,E,N=((Ee=i[1].ui)==null?void 0:Ee.strings.btn_sign_up)+"",J,ne,ie;const $={c:function(){var O;e=q("form"),t=q("p"),n=se(i[3]),r=se(i[4]),s=X(),o=q("label"),l=se(a),f=X(),u=q("input"),h=X(),p=q("label"),_=se(y),w=X(),g=q("input"),k=X(),E=q("button"),J=se(N),Q(t,"class","message s-FRwn6sVlvC6z"),Ue(t,"error",i[3]),j(t,$e,37,4,718),Q(u,"type","text"),Q(u,"placeholder",c=(O=i[1].ui)==null?void 0:O.strings.email_placeholder),j(u,$e,40,6,847),j(o,$e,38,4,791),Q(g,"type","password"),j(g,$e,49,6,1076),j(p,$e,47,4,1017),j(E,$e,51,4,1141),Q(e,"class","s-FRwn6sVlvC6z"),j(e,$e,36,2,673)},m:function(O,D){G(O,e,D),C(e,t),C(t,n),C(t,r),C(e,s),C(e,o),C(o,l),C(o,f),C(o,u),_e(u,i[0]),C(e,h),C(e,p),C(p,_),C(p,w),C(p,g),_e(g,i[5]),C(e,k),C(e,E),C(E,J),ne||(ie=[Ce(u,"input",i[7]),en(yt.call(null,u)),Ce(g,"input",i[8]),Ce(e,"submit",tn(i[6]),!1,!0,!1,!1)],ne=!0)},p:function(O,D){var W,z,re,Te;D&8&&ye(n,O[3]),D&16&&ye(r,O[4]),D&8&&Ue(t,"error",O[3]),D&2&&a!==(a=((W=O[1].ui)==null?void 0:W.strings.email)+"")&&ye(l,a),D&2&&c!==(c=(z=O[1].ui)==null?void 0:z.strings.email_placeholder)&&Q(u,"placeholder",c),D&1&&u.value!==O[0]&&_e(u,O[0]),D&2&&y!==(y=((re=O[1].ui)==null?void 0:re.strings.password)+"")&&ye(_,y),D&32&&g.value!==O[5]&&_e(g,O[5]),D&2&&N!==(N=((Te=O[1].ui)==null?void 0:Te.strings.btn_sign_up)+"")&&ye(J,N)},d:function(O){O&&x(e),ne=!1,dt(ie)}};return U("SvelteRegisterBlock",{block:$,id:Bn.name,type:"if",source:"(27:0) {#if view == 'login'}",ctx:i}),$}function qn(i){let e,t=i[2]=="login"&&Bn(i);const n={c:function(){t&&t.c(),e=Un()},l:function(s){throw new xe("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(s,o){t&&t.m(s,o),G(s,e,o)},p:function(s,[o]){s[2]=="login"?t?t.p(s,o):(t=Bn(s),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},i:ue,o:ue,d:function(s){s&&x(e),t&&t.d(s)}};return U("SvelteRegisterBlock",{block:n,id:qn.name,type:"component",source:"",ctx:i}),n}function wa(i,e,t){let{$$slots:n={},$$scope:r}=e;nt("SignUp",n,[]);let{firstlyDataAuth:s}=e,{view:o="login"}=e,{email:a=""}=e,l="",f="",u;async function c(){t(3,l=""),t(4,f="");try{await We.signUpPassword(a,u),window.location.href="/"}catch(w){w&&t(3,l=w.message??"")}}const h=()=>{throw new Error("Not impl yet")};i.$$.on_mount.push(function(){s===void 0&&!("firstlyDataAuth"in e||i.$$.bound[i.$$.props.firstlyDataAuth])&&console.warn("<SignUp> was created without expected prop 'firstlyDataAuth'")});const p=["firstlyDataAuth","view","email"];Object.keys(e).forEach(w=>{!~p.indexOf(w)&&w.slice(0,2)!=="$$"&&w!=="slot"&&console.warn(`<SignUp> was created with unknown prop '${w}'`)});function y(){a=this.value,t(0,a)}function _(){u=this.value,t(5,u)}return i.$$set=w=>{"firstlyDataAuth"in w&&t(1,s=w.firstlyDataAuth),"view"in w&&t(2,o=w.view),"email"in w&&t(0,a=w.email)},i.$capture_state=()=>({Auth:We,isError:sn,autofocus:yt,firstlyDataAuth:s,view:o,email:a,msgError:l,msgSuccess:f,password:u,signIn:c,handlePin:h}),i.$inject_state=w=>{"firstlyDataAuth"in w&&t(1,s=w.firstlyDataAuth),"view"in w&&t(2,o=w.view),"email"in w&&t(0,a=w.email),"msgError"in w&&t(3,l=w.msgError),"msgSuccess"in w&&t(4,f=w.msgSuccess),"password"in w&&t(5,u=w.password)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),[a,s,o,l,f,u,c,y,_]}class zr extends et{constructor(e){super(e),tt(this,e,wa,qn,ht,{firstlyDataAuth:1,view:2,email:0}),U("SvelteRegisterComponent",{component:this,tagName:"SignUp",options:e,id:qn.name})}get firstlyDataAuth(){throw new xe("<SignUp>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set firstlyDataAuth(e){throw new xe("<SignUp>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get view(){throw new xe("<SignUp>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set view(e){throw new xe("<SignUp>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get email(){throw new xe("<SignUp>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set email(e){throw new xe("<SignUp>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}const Ae="src/lib/modules/auth/Page.svelte";function Kr(i){var r;let e,t;e=new ze({props:{path:(r=i[1].ui)==null?void 0:r.paths.sign_up,$$slots:{default:[es]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){me(e.$$.fragment)},m:function(o,a){we(e,o,a),t=!0},p:function(o,a){const l={};a&65&&(l.$$scope={dirty:a,ctx:o}),e.$set(l)},i:function(o){t||(Z(e.$$.fragment,o),t=!0)},o:function(o){te(e.$$.fragment,o),t=!1},d:function(o){ge(e,o)}};return U("SvelteRegisterBlock",{block:n,id:Kr.name,type:"if",source:"(14:6) {#if firstlyDataAuth.ui?.paths.sign_up}",ctx:i}),n}function Zr(i){let e,t;e=new pt({props:{href:i[1].ui.paths.sign_in,$$slots:{default:[Yr]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){me(e.$$.fragment)},m:function(s,o){we(e,s,o),t=!0},p:function(s,o){const a={};o&64&&(a.$$scope={dirty:o,ctx:s}),e.$set(a)},i:function(s){t||(Z(e.$$.fragment,s),t=!0)},o:function(s){te(e.$$.fragment,s),t=!1},d:function(s){ge(e,s)}};return U("SvelteRegisterBlock",{block:n,id:Zr.name,type:"if",source:"(19:12) {#if firstlyDataAuth.ui.paths.sign_in}",ctx:i}),n}function Yr(i){let e=i[1].ui.strings.back_to_sign_in+"",t;const n={c:function(){t=se(e)},m:function(s,o){G(s,t,o)},p:ue,d:function(s){s&&x(t)}};return U("SvelteRegisterBlock",{block:n,id:Yr.name,type:"slot",source:"(20:14) <Link href={firstlyDataAuth.ui.paths.sign_in}>",ctx:i}),n}function es(i){let e,t,n,r,s;function o(u){i[3](u)}let a={firstlyDataAuth:i[1]};i[0]!==void 0&&(a.email=i[0]),e=new zr({props:a,$$inline:!0}),Wn.push(()=>Vn(e,"email",o));let l=i[1].ui.paths.sign_in&&Zr(i);const f={c:function(){me(e.$$.fragment),n=X(),r=q("div"),l&&l.c(),Q(r,"class","form-footer s-NO-a_LAEXXH5"),j(r,Ae,22,10,599)},m:function(c,h){we(e,c,h),G(c,n,h),G(c,r,h),l&&l.m(r,null),s=!0},p:function(c,h){const p={};!t&&h&1&&(t=!0,p.email=c[0],Hn(()=>t=!1)),e.$set(p),c[1].ui.paths.sign_in&&l.p(c,h)},i:function(c){s||(Z(e.$$.fragment,c),Z(l),s=!0)},o:function(c){te(e.$$.fragment,c),te(l),s=!1},d:function(c){c&&(x(n),x(r)),ge(e,c),l&&l.d()}};return U("SvelteRegisterBlock",{block:f,id:es.name,type:"slot",source:"(15:8) <Route path={firstlyDataAuth.ui?.paths.sign_up}>",ctx:i}),f}function ts(i){let e,t;e=new pt({props:{href:i[1].ui.paths.forgot_password,$$slots:{default:[ns]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){me(e.$$.fragment)},m:function(s,o){we(e,s,o),t=!0},p:function(s,o){const a={};o&64&&(a.$$scope={dirty:o,ctx:s}),e.$set(a)},i:function(s){t||(Z(e.$$.fragment,s),t=!0)},o:function(s){te(e.$$.fragment,s),t=!1},d:function(s){ge(e,s)}};return U("SvelteRegisterBlock",{block:n,id:ts.name,type:"if",source:"(32:10) {#if firstlyDataAuth.ui?.paths.forgot_password}",ctx:i}),n}function ns(i){let e=i[1].ui.strings.forgot_password+"",t;const n={c:function(){t=se(e)},m:function(s,o){G(s,t,o)},p:ue,d:function(s){s&&x(t)}};return U("SvelteRegisterBlock",{block:n,id:ns.name,type:"slot",source:"(33:12) <Link href={firstlyDataAuth.ui.paths.forgot_password}>",ctx:i}),n}function is(i){let e,t;e=new pt({props:{href:i[1].ui.paths.sign_up,$$slots:{default:[rs]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){me(e.$$.fragment)},m:function(s,o){we(e,s,o),t=!0},p:function(s,o){const a={};o&64&&(a.$$scope={dirty:o,ctx:s}),e.$set(a)},i:function(s){t||(Z(e.$$.fragment,s),t=!0)},o:function(s){te(e.$$.fragment,s),t=!1},d:function(s){ge(e,s)}};return U("SvelteRegisterBlock",{block:n,id:is.name,type:"if",source:"(38:10) {#if firstlyDataAuth.ui?.paths.sign_up}",ctx:i}),n}function rs(i){let e=i[1].ui.strings.btn_sign_up+"",t;const n={c:function(){t=se(e)},m:function(s,o){G(s,t,o)},p:ue,d:function(s){s&&x(t)}};return U("SvelteRegisterBlock",{block:n,id:rs.name,type:"slot",source:"(39:12) <Link href={firstlyDataAuth.ui.paths.sign_up}>",ctx:i}),n}function ss(i){var y,_;let e,t,n,r,s,o,a,l;function f(w){i[4](w)}let u={firstlyDataAuth:i[1]};i[0]!==void 0&&(u.email=i[0]),e=new Xr({props:u,$$inline:!0}),Wn.push(()=>Vn(e,"email",f));let c=((y=i[1].ui)==null?void 0:y.paths.forgot_password)&&ts(i),h=((_=i[1].ui)==null?void 0:_.paths.sign_up)&&is(i);const p={c:function(){me(e.$$.fragment),n=X(),r=q("div"),c&&c.c(),s=X(),o=q("hr"),a=X(),h&&h.c(),j(o,Ae,41,10,1253),Q(r,"class","form-footer s-NO-a_LAEXXH5"),j(r,Ae,35,8,997)},m:function(g,k){we(e,g,k),G(g,n,k),G(g,r,k),c&&c.m(r,null),C(r,s),C(r,o),C(r,a),h&&h.m(r,null),l=!0},p:function(g,k){var N,J;const E={};!t&&k&1&&(t=!0,E.email=g[0],Hn(()=>t=!1)),e.$set(E),(N=g[1].ui)!=null&&N.paths.forgot_password&&c.p(g,k),(J=g[1].ui)!=null&&J.paths.sign_up&&h.p(g,k)},i:function(g){l||(Z(e.$$.fragment,g),Z(c),Z(h),l=!0)},o:function(g){te(e.$$.fragment,g),te(c),te(h),l=!1},d:function(g){g&&(x(n),x(r)),ge(e,g),c&&c.d(),h&&h.d()}};return U("SvelteRegisterBlock",{block:p,id:ss.name,type:"slot",source:"(28:6) <Route path={firstlyDataAuth.ui?.paths.sign_in}>",ctx:i}),p}function os(i){let e,t;e=new pt({props:{href:i[1].ui.paths.sign_in,$$slots:{default:[as]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){me(e.$$.fragment)},m:function(s,o){we(e,s,o),t=!0},p:function(s,o){const a={};o&64&&(a.$$scope={dirty:o,ctx:s}),e.$set(a)},i:function(s){t||(Z(e.$$.fragment,s),t=!0)},o:function(s){te(e.$$.fragment,s),t=!1},d:function(s){ge(e,s)}};return U("SvelteRegisterBlock",{block:n,id:os.name,type:"if",source:"(50:10) {#if firstlyDataAuth.ui?.paths.sign_in}",ctx:i}),n}function as(i){let e=i[1].ui.strings.back_to_sign_in+"",t;const n={c:function(){t=se(e)},m:function(s,o){G(s,t,o)},p:ue,d:function(s){s&&x(t)}};return U("SvelteRegisterBlock",{block:n,id:as.name,type:"slot",source:"(51:12) <Link href={firstlyDataAuth.ui.paths.sign_in}>",ctx:i}),n}function ls(i){var u;let e,t,n,r,s;function o(c){i[5](c)}let a={firstlyDataAuth:i[1]};i[0]!==void 0&&(a.email=i[0]),e=new Gr({props:a,$$inline:!0}),Wn.push(()=>Vn(e,"email",o));let l=((u=i[1].ui)==null?void 0:u.paths.sign_in)&&os(i);const f={c:function(){me(e.$$.fragment),n=X(),r=q("div"),l&&l.c(),Q(r,"class","form-footer s-NO-a_LAEXXH5"),j(r,Ae,53,8,1619)},m:function(h,p){we(e,h,p),G(h,n,p),G(h,r,p),l&&l.m(r,null),s=!0},p:function(h,p){var _;const y={};!t&&p&1&&(t=!0,y.email=h[0],Hn(()=>t=!1)),e.$set(y),(_=h[1].ui)!=null&&_.paths.sign_in&&l.p(h,p)},i:function(h){s||(Z(e.$$.fragment,h),Z(l),s=!0)},o:function(h){te(e.$$.fragment,h),te(l),s=!1},d:function(h){h&&(x(n),x(r)),ge(e,h),l&&l.d()}};return U("SvelteRegisterBlock",{block:f,id:ls.name,type:"slot",source:"(46:6) <Route path={firstlyDataAuth.ui?.paths.forgot_password}>",ctx:i}),f}function us(i){let e,t;e=new pt({props:{href:i[1].ui.paths.sign_in,$$slots:{default:[fs]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){me(e.$$.fragment)},m:function(s,o){we(e,s,o),t=!0},p:function(s,o){const a={};o&64&&(a.$$scope={dirty:o,ctx:s}),e.$set(a)},i:function(s){t||(Z(e.$$.fragment,s),t=!0)},o:function(s){te(e.$$.fragment,s),t=!1},d:function(s){ge(e,s)}};return U("SvelteRegisterBlock",{block:n,id:us.name,type:"if",source:"(62:10) {#if firstlyDataAuth.ui?.paths.sign_in}",ctx:i}),n}function fs(i){let e=i[1].ui.strings.back_to_sign_in+"",t;const n={c:function(){t=se(e)},m:function(s,o){G(s,t,o)},p:ue,d:function(s){s&&x(t)}};return U("SvelteRegisterBlock",{block:n,id:fs.name,type:"slot",source:"(63:12) <Link href={firstlyDataAuth.ui.paths.sign_in}>",ctx:i}),n}function cs(i){var a;let e,t,n,r;e=new xr({props:{firstlyDataAuth:i[1]},$$inline:!0});let s=((a=i[1].ui)==null?void 0:a.paths.sign_in)&&us(i);const o={c:function(){me(e.$$.fragment),t=X(),n=q("div"),s&&s.c(),Q(n,"class","form-footer s-NO-a_LAEXXH5"),j(n,Ae,65,8,1995)},m:function(f,u){we(e,f,u),G(f,t,u),G(f,n,u),s&&s.m(n,null),r=!0},p:function(f,u){var c;(c=f[1].ui)!=null&&c.paths.sign_in&&s.p(f,u)},i:function(f){r||(Z(e.$$.fragment,f),Z(s),r=!0)},o:function(f){te(e.$$.fragment,f),te(s),r=!1},d:function(f){f&&(x(t),x(n)),ge(e,f),s&&s.d()}};return U("SvelteRegisterBlock",{block:o,id:cs.name,type:"slot",source:"(58:6) <Route path={firstlyDataAuth.ui?.paths.reset_password}>",ctx:i}),o}function ds(i){let e,t,n,r,s;const o={c:function(){e=q("div"),t=q("small"),t.textContent="- 404 -",n=X(),r=q("div"),s=q("small"),s.textContent="Nothing to see here",j(t,Ae,76,10,2320),Q(e,"class","fallback s-NO-a_LAEXXH5"),j(e,Ae,75,8,2287),j(s,Ae,79,10,2399),Q(r,"class","fallback s-NO-a_LAEXXH5"),j(r,Ae,78,8,2366)},m:function(l,f){G(l,e,f),C(e,t),G(l,n,f),G(l,r,f),C(r,s)},p:ue,d:function(l){l&&(x(e),x(n),x(r))}};return U("SvelteRegisterBlock",{block:o,id:ds.name,type:"slot",source:"(70:6) <Route fallback>",ctx:i}),o}function hs(i){var h,p,y,_;let e,t,n,r,s,o,a,l,f,u=((h=i[1].ui)==null?void 0:h.paths.sign_up)&&Kr(i);t=new ze({props:{path:(p=i[1].ui)==null?void 0:p.paths.sign_in,$$slots:{default:[ss]},$$scope:{ctx:i}},$$inline:!0}),r=new ze({props:{path:(y=i[1].ui)==null?void 0:y.paths.forgot_password,$$slots:{default:[ls]},$$scope:{ctx:i}},$$inline:!0}),o=new ze({props:{path:(_=i[1].ui)==null?void 0:_.paths.reset_password,$$slots:{default:[cs]},$$scope:{ctx:i}},$$inline:!0}),l=new ze({props:{fallback:!0,$$slots:{default:[ds]},$$scope:{ctx:i}},$$inline:!0});const c={c:function(){u&&u.c(),e=X(),me(t.$$.fragment),n=X(),me(r.$$.fragment),s=X(),me(o.$$.fragment),a=X(),me(l.$$.fragment)},m:function(g,k){u&&u.m(g,k),G(g,e,k),we(t,g,k),G(g,n,k),we(r,g,k),G(g,s,k),we(o,g,k),G(g,a,k),we(l,g,k),f=!0},p:function(g,k){var ie;(ie=g[1].ui)!=null&&ie.paths.sign_up&&u.p(g,k);const E={};k&65&&(E.$$scope={dirty:k,ctx:g}),t.$set(E);const N={};k&65&&(N.$$scope={dirty:k,ctx:g}),r.$set(N);const J={};k&64&&(J.$$scope={dirty:k,ctx:g}),o.$set(J);const ne={};k&64&&(ne.$$scope={dirty:k,ctx:g}),l.$set(ne)},i:function(g){f||(Z(u),Z(t.$$.fragment,g),Z(r.$$.fragment,g),Z(o.$$.fragment,g),Z(l.$$.fragment,g),f=!0)},o:function(g){te(u),te(t.$$.fragment,g),te(r.$$.fragment,g),te(o.$$.fragment,g),te(l.$$.fragment,g),f=!1},d:function(g){g&&(x(e),x(n),x(s),x(a)),u&&u.d(g),ge(t,g),ge(r,g),ge(o,g),ge(l,g)}};return U("SvelteRegisterBlock",{block:c,id:hs.name,type:"slot",source:"(13:4) <Route>",ctx:i}),c}function jn(i){let e,t,n,r;n=new ze({props:{$$slots:{default:[hs]},$$scope:{ctx:i}},$$inline:!0});const s={c:function(){e=q("div"),t=q("div"),me(n.$$.fragment),Q(t,"class","form s-NO-a_LAEXXH5"),j(t,Ae,16,2,404),Q(e,"class","wrapper s-NO-a_LAEXXH5"),j(e,Ae,15,0,380)},l:function(a){throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(a,l){G(a,e,l),C(e,t),we(n,t,null),r=!0},p:function(a,[l]){const f={};l&65&&(f.$$scope={dirty:l,ctx:a}),n.$set(f)},i:function(a){r||(Z(n.$$.fragment,a),r=!0)},o:function(a){te(n.$$.fragment,a),r=!1},d:function(a){a&&x(e),ge(n)}};return U("SvelteRegisterBlock",{block:s,id:jn.name,type:"component",source:"",ctx:i}),s}function ga(i,e,t){let{$$slots:n={},$$scope:r}=e;nt("Page",n,[]);let{firstlyData:s}=e,o=s.props,a="";i.$$.on_mount.push(function(){s===void 0&&!("firstlyData"in e||i.$$.bound[i.$$.props.firstlyData])&&console.warn("<Page> was created without expected prop 'firstlyData'")});const l=["firstlyData"];Object.keys(e).forEach(h=>{!~l.indexOf(h)&&h.slice(0,2)!=="$$"&&h!=="slot"&&console.warn(`<Page> was created with unknown prop '${h}'`)});function f(h){a=h,t(0,a)}function u(h){a=h,t(0,a)}function c(h){a=h,t(0,a)}return i.$$set=h=>{"firstlyData"in h&&t(2,s=h.firstlyData)},i.$capture_state=()=>({Link:pt,Route:ze,ForgotPassword:Gr,ResetPassword:xr,SignIn:Xr,SignUp:zr,firstlyData:s,firstlyDataAuth:o,email:a}),i.$inject_state=h=>{"firstlyData"in h&&t(2,s=h.firstlyData),"firstlyDataAuth"in h&&t(1,o=h.firstlyDataAuth),"email"in h&&t(0,a=h.email)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),[a,o,s,f,u,c]}class Oa extends et{constructor(e){super(e),tt(this,e,ga,jn,ht,{firstlyData:2}),U("SvelteRegisterComponent",{component:this,tagName:"Page",options:e,id:jn.name})}get firstlyData(){throw new Error("<Page>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set firstlyData(e){throw new Error("<Page>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}export{Oa as default};
|