import{u as b,a as h,j as i}from"./index-b983ad9b.js";import{r as o}from"./react-b0e0d18a.js";/* empty css                *//* empty css              *//* empty css              *//* empty css              *//* empty css              */import{B as v}from"./Room-7ae51b0a.js";/* empty css              */import{o as N,n as g,p as u,q as x}from"./antd-8ca2e36c.js";import{T as I}from"./TimeoutItem-6cca4419.js";const S="_list_1d4tq_1",j={list:S};function O({all:m=!0,value:n,onChange:t,permissions:l}){const[r,f]=o.useState(),{accessToken:c}=b(),[d,p]=o.useState();o.useEffect(()=>{if(!c)return;let e=!0;return(async()=>{try{const s={pp:-1};l&&(s.room_permission$=`{${l.join(",")}}`),r&&r!==""&&(s.keywords=r);const k=await v.findAll(s);e&&p(k)}catch(s){console.error(s)}})(),()=>{e=!1}},[r,l,c]);const y=e=>{e||t&&t(void 0),f(e)};let a=[];return d&&(m&&a.push({key:"@",label:"所有楼宇"}),a.push(...d.map(e=>({key:e.id,label:e.fullName})))),h("div",{className:j.list,children:[i("div",{className:"search",children:i(I,{onChange:y,value:r,children:i(N,{suffix:i(g,{}),allowClear:!0})})}),i(u,{dataSource:a,renderItem:e=>i(u.Item,{className:x((n===e.key||n===void 0&&e.key==="@")&&"selected"),onClick:()=>{if(t)if(e.key==="@")t(void 0,"building");else{const s=e.key==="@"?void 0:Number(e.key);t(s,"building")}},children:i("div",{className:"label",children:e.label})},e.key)})]})}export{O as default};
