import{G as r}from"./index-021e2612.js";const c=new Map;class s{constructor(e){e&&this.setData(e)}setData(e){e.id&&(this.id=parseInt(e.id)),e.area_id&&(this.area_id=parseInt(e.area_id)),e.name&&(this.name=e.name),e.code&&(this.code=e.code),e.path&&(this.path=e.path),e.floors&&(this.floors=e.floors),e.group_id&&(this.group_id=e.group_id),e.owner&&(this.owner=e.owner),e.location&&(this.location=e.location),e.user_id&&(this.user_id=e.user_id),e.owner_id&&(this.owner_id=e.owner_id)}get fullName(){const e=[];this.path&&e.push(...this.path.split("/")),e.push(this.name);for(let t=0;t<e.length-1;t++)e[t].charCodeAt(e[t].length-1)>128||e[t+1].charCodeAt(0)>128||(e[t]+=" ");return e.join("")}static async findAll(e){const t=r(),{items:n}=await t.get({path:"api/v1/buildings",query:{st:0,pp:-1,...e}})||{};return(n||[]).map(o=>s.get(o))}static async findBuidings(e,t){const n=r(),{items:o,total:a}=await n.get({path:"api/v1/buildings",query:{pp:t,pg:e}})||{};return{items:(o||[]).map(l=>s.get(l)),total:a}}static async findByPk(e){const n=await r().get({path:`api/v1/building/${e}`,query:{includes:"floors,location"}})||{};return s.get(n)}static async getOrganization(e){const t=r(),n={type:"organization",tag:"school",pg:"1",pp:"100"};return e&&(n.name=e),(await t.get({path:"api/v1/group/1/descendants",query:n})||{}).items}static get(e){let t=c.get(e.id);return t||(t=new s(e),c.set(e.id,t)),t}static getBuildingCache(){return c}}const d=(i,e)=>{const t=document.createElement("a");t.download=e,t.style.display="none",typeof i=="string"?t.href=i:t.href=URL.createObjectURL(i),document.body.appendChild(t),t.click(),URL.revokeObjectURL(t.href),document.body.removeChild(t)},f=i=>[null,void 0].includes(i),g=i=>{let e=0,t=0;return i.forEach(n=>{n.indexOf("B")!==-1?e++:t++}),[t,e]},p={lab:"lab"},u={lab:"实验室成员"};Object.keys(p).map(i=>({value:i,label:u[i]}));const m=i=>i.split("_").map((e,t)=>t===0?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join("");export{s as B,p as M,d,f as i,m as s,g as t};
