import{b as I,c as l,d,e as b,a as m,h as v,j as A,k as g,l as O,m as P,n as T,o as p,g as q,p as w}from"./manifest--hA2W8VB.js";const C=250,E=10,V=["string","array","boolean","integer","null","number","object"];function j(a){const{type:e}=a;return!!(e&&V.includes(e))}function _(a){switch(a){case"date":case"date-time":case"time":return p().toISOString();case"email":return T();case"uri":return"https://www.example.com";case"regex":return"/.*/";case"text-area":return P();case"lookup":return m()}return q()}function x(a){return["date","time","date-time"].includes(a)?p().getTime():w()}function B(a){var e;const{items:t,dataSchema:r,format:n}=a;let s={type:"string"};n==="file"&&(s={type:"object",format:"file"}),n==="multilookup"&&(s={type:"string",format:"lookup"});const i=(e=t??r)!=null?e:s;if(f(i)!==void 0)return Array(E).fill(0).map(()=>f(i))}function y(a){const{properties:e={},format:t}=a;return t==="file"?O():t==="localized-text"?{en:_()}:Object.entries(e).reduce((r,[n,s])=>{const i=f(s);return i===void 0?r:{...r,[n]:i}},{})}function f(a){const{type:e,format:t}=a;if(j(a))switch(e){case"string":return _(t);case"integer":case"number":return x();case"boolean":return Math.random()<.5;case"array":return B(a);case"object":return y(a);case"null":return null}}class L extends Array{constructor(e={type:"object",properties:{}}){super(),this.push(...Array(C).fill(0).map(()=>({...y(e),...I()})))}getAll(e){var t;const{searchParams:r}=e,n=[...this],s=l((t=r.get("_st"))!=null?t:"PUBLIC"),i=n.filter(({__STATE__:h})=>s.includes(h)),o=d(r.get("_q")),u=i.filter(o),{skip:c,limit:S}=b(r.get("_l"),r.get("_sk"));return u.slice(c,c+S)}export(e){var t;const{searchParams:r}=e,n=[...this],s=l((t=r.get("_st"))!=null?t:"PUBLIC"),i=n.filter(({__STATE__:c})=>s.includes(c)),o=d(r.get("_q"));return i.filter(o)}count(e){var t;const{searchParams:r}=e,n=[...this],s=l((t=r.get("_st"))!=null?t:"PUBLIC"),i=n.filter(({__STATE__:c})=>s.includes(c)),o=d(r.get("_q"));return i.filter(o).length}addNew(e){const t=m(),r=m(),n=new Date().toISOString(),s=v(e.__STATE__)?e.__STATE__:A.PUBLIC;return this.unshift({...e,_id:t,creatorId:r,createdAt:n,updaterId:r,updatedAt:n,__STATE__:s}),t}patchOne(e,t={},r={}){const n=this.find(g(e));if(!(!n||!n._id))return Object.entries(t).forEach(([s,i])=>{n[s]=i}),Object.entries(r).forEach(([s,i])=>{i&&delete n[s]}),n.updatedAt=new Date().toISOString(),n}deleteOne(e){const t=this.findIndex(g(e));if(t<0)throw new TypeError("Not found");this.slice(t,1)}}export{L as C};
