module.exports=[18146,e=>{"use strict";var s=e.i(5271),c=e.i(31585),t=e.i(22124);class a{async getAllSpecs(e){let a=e?s.db.select().from(c.schema.specs).where((0,t.eq)(c.schema.specs.projectId,e)):s.db.select().from(c.schema.specs);return await a.orderBy(c.schema.specs.specNumber)}async getSpec(e,a){if(!a)return null;let r=parseInt(e.split("-")[0],10);if(isNaN(r))return null;let l=await s.db.select().from(c.schema.specs).where((0,t.and)((0,t.eq)(c.schema.specs.projectId,a),(0,t.eq)(c.schema.specs.specNumber,r))).limit(1);return l.length>0?l[0]:null}async getSpecsByStatus(e,a){let r=[(0,t.eq)(c.schema.specs.status,e)];return a&&r.push((0,t.eq)(c.schema.specs.projectId,a)),await s.db.select().from(c.schema.specs).where((0,t.and)(...r)).orderBy(c.schema.specs.specNumber)}async searchSpecs(e,s){let c=await this.getAllSpecs(s),t=e.toLowerCase();return c.filter(e=>e.specName.toLowerCase().includes(t)||e.title?.toLowerCase().includes(t)||e.contentMd.toLowerCase().includes(t))}invalidateCache(){}}e.s(["DatabaseSource",()=>a])}];

//# sourceMappingURL=packages_ui_src_lib_specs_sources_database-source_ts_baa0160d._.js.map