import{_ as N}from"./DPQgZEES.js";import{D as z,r as U}from"./9jHEIiRU.js";import{u as I}from"./DIRTgmGz.js";import{u as P,V as S,D as R,a as X}from"./vRc2BJuY.js";import{d as $,r as u,k as C,o as Z,x as p,y as r,B as e,T as v,X as g,af as o,aa as j,C as t,a4 as w,Z as D,aM as q,a1 as G,V as b,U as H,aN as J,D as x,A as _,aL as K,z as O}from"#entry";import"./DlAUqK2U.js";import"./CiZyL2M5.js";import"./D2lCyhx0.js";const Q=$({__name:"ScannersList",setup(B){const i=I(),d=P(),y=u(!0),n=u(!1),c=u(!1),a=u(null),F=[{title:"Name",value:"name",align:"left",width:"10%"},{title:"Endpoint",value:"endpoint",align:"left"},{title:"Actions",value:"actions",align:"center",width:"5%"}],V=[{title:"Edit",action:l=>T(l),icon:"mdi-pencil-outline",color:"primary",divider:!0},{title:"Delete",action:l=>E(l),icon:"mdi-delete",color:"red"}],L=C(()=>i.scanners),h=C(()=>a.value===null?"Are you sure you would like to delete this scanner?":`Are you sure you would like to delete the '${a.value.name}' scanner?`),T=l=>{a.value=l,c.value=!0},A=()=>{c.value=!1,a.value=null},E=l=>{a.value=l,n.value=!0},M=()=>{if(a.value!==null)try{i.deleteScanner(a.value.endpoint),d.reportSuccess("Scanner deleted successfully.")}catch{d.reportError("Failed to delete scanner. Please try again.")}finally{a.value=null}};return Z(()=>{y.value=!1}),(l,m)=>(r(),p("div",null,[e(o(z),{"model-value":o(n),"onUpdate:modelValue":m[0]||(m[0]=s=>j(n)?n.value=s:null),title:o(h),"cancel-button-text":"Cancel","confirm-button-text":"Delete","cancel-icon":"mdi-close","confirm-icon":"mdi-check","confirm-button-color":"secondary","card-icon":"mdi-trash-can-outline",onConfirm:M,onCancel:m[1]||(m[1]=s=>a.value=null)},null,8,["model-value","title"]),o(c)===!0?(r(),v(S,{key:0,variant:"outlined",class:"pa-4 mb-4"},{default:t(()=>[e(N,{scanner:o(a),"is-edit-mode":!0,onCloseForm:A},null,8,["scanner"])]),_:1})):g("",!0),e(S,{variant:"outlined"},{default:t(()=>[e(U,{loading:o(y),headers:F,items:o(L),"items-per-page":-1,"hide-default-footer":"","loading-text":"Loading scanners...","no-data-text":"No scanners added",density:"compact"},{"item.name":t(({item:s})=>[x(_(s.name),1)]),"item.endpoint":t(({item:s})=>[O("code",null,_(s.endpoint),1)]),"item.actions":t(({item:s})=>[e(w,{variant:"text",size:"small",icon:!0},{default:t(()=>[e(D,{icon:"mdi-dots-vertical"}),e(q,{activator:"parent",location:"bottom"},{default:t(()=>[e(G,{density:"compact",class:"py-0"},{default:t(()=>[(r(),p(b,null,H(V,(f,k)=>(r(),p(b,{key:`item-${f.title}-${k}`},[e(J,{onClick:W=>f.action(s)},{default:t(()=>[e(D,{start:"",size:"small",icon:f.icon},null,8,["icon"]),x(" "+_(f.title),1)]),_:2},1032,["onClick"]),k!==V.length-1?(r(),v(K,{key:0})):g("",!0)],64))),64))]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:2},1032,["loading","items"])]),_:1})]))}}),re=$({__name:"index",setup(B){const i=u(!1),d=[{text:"Scanners",disabled:!0,to:"/scanners",exact:!0}];return(y,n)=>(r(),p("div",null,[e(o(R),{breadcrumbs:d,class:"mb-5"}),e(S,{variant:"outlined",class:"my-4"},{default:t(()=>[e(X,null,{default:t(()=>[o(i)===!1?(r(),v(w,{key:0,color:"accent","prepend-icon":"mdi-plus",onClick:n[0]||(n[0]=c=>i.value=!o(i))},{default:t(()=>[...n[2]||(n[2]=[x(" New ",-1)])]),_:1})):(r(),v(N,{key:1,onCloseForm:n[1]||(n[1]=c=>i.value=!1)}))]),_:1})]),_:1}),e(Q)]))}});export{re as default};
