import{r as t,j as e,c as k}from"./index-CqA6gR2S.js";import{B as v}from"./Back-DqqFM7zR.js";import{u as N,g as C,E}from"./index-D--7QZ50.js";import{E as R}from"./EquipmentStatus-Dc9l4IYg.js";import{g as j}from"./index-B_OQWaA6.js";import{B as m}from"./button-TbaXZ62K.js";import{G as u}from"./index-BHXSJXsU.js";import{R as p}from"./result-BUVG2gsM.js";import{S as f}from"./space-TOaHzrjG.js";import{u as y,U}from"./Users-GtImotos.js";import"./tslib.es6-e2qAPn_M.js";import"./attach-properties-to-component-CxYBDbn1.js";import"./to-css-length-qRJH4nmz.js";import"./config-provider-EPidMSot.js";const _="_page_1p41n_1",b="_clock-in_1p41n_12",i={page:_,clockIn:b},B=j("apply"),P=j("cancel");function S(){const s=N(),{subscribeEvent:x}=C(),[g,l]=t.useState(!1),c=t.useRef([]),[,h]=t.useReducer(r=>!r,!1),n=y(),a=t.useMemo(()=>{var r;return!!(s&&(n!=null&&n.id)&&((r=s.admins)!=null&&r.includes(n.id)))},[s,n]);return t.useEffect(()=>a?x("CardReader.discoverTag",({id:o})=>{const d=parseInt(o,16);c.current.some(I=>I.card===d)||(c.current.push({card:d}),h())}):void 0,[a]),a?e.jsxs("div",{className:i.clockIn,children:[e.jsxs("div",{className:"top-bar",children:[e.jsx("div",{className:"title",children:s==null?void 0:s.name}),e.jsx(R,{})]}),e.jsxs("div",{className:"content",children:[e.jsx("div",{className:"sidebar",children:g?e.jsx(m,{onClick:()=>{l(!1)},children:e.jsxs(f,{align:"center",justify:"center",style:{lineHeight:1},children:[e.jsx(P,{})," 停止签到"]})}):e.jsx(m,{onClick:()=>{c.current=[],l(!0)},children:e.jsxs(f,{align:"center",justify:"center",style:{lineHeight:1},children:[e.jsx(B,{})," 开始签到"]})})}),e.jsx("div",{className:"content",children:e.jsx(u,{columns:4,gap:16,children:c.current.map((r,o)=>e.jsx(u.Item,{className:"clock-in-user",children:r.user?r.user.name:`用户${o+1}`},r.card))})})]})]}):n?e.jsx("div",{className:i.clockIn,children:e.jsx(p,{status:"error",title:"该用户无权限",description:"只有仪器的机主才能有权限操作该功能"})}):n===null?e.jsx("div",{className:i.clockIn,children:e.jsx(p,{status:"warning",title:"无法识别的用户",description:"只有仪器的机主才能有权限操作该功能"})}):null}function O(){const{equipmentId:s}=k();return s?e.jsxs(e.Fragment,{children:[e.jsx(v,{}),e.jsxs("div",{className:i.page,children:[e.jsx("div",{className:"page-title",children:"培训签到"}),e.jsx(E,{equipmentId:s,children:e.jsx(U,{children:e.jsx(S,{})})})]})]}):null}export{O as default};
