import{j as e,T as i,cn as c,d,E as g,z as p,G as u,H as x,ab as f,I as h,J as j,b as D,bw as b,cV as y,r as m,t as S,ae as v,Q as w,cW as F}from"./main-D6SjkSWq.js";import{I as C}from"./Info-DJrDtfBN.js";import{D as T}from"./paginated-resources-C0CNliR6.js";import{u as E,a as I,G as L,D as P,b as Q,c as z}from"./use-datatable-query-Bmcm-zE1.js";import{D as M}from"./data-table-add-item-button-B07uqtxW.js";import{a as k,b as B,c as H}from"./datatable-page-with-header-layout-BuTOEIJh.js";import{T as q}from"./table-BI0jS7jz.js";import{S as A}from"./select-BkmhiFLy.js";import{F as N}from"./formatted-bytes-JG6JKlEC.js";import{D as R}from"./Download-w2QmFucW.js";import{C as W}from"./confirmation-dialog-E4zsogCz.js";import{S as G}from"./skeleton-3NNrk_-o.js";import"./form-normalized-model-chip-field-D_4zoyut.js";import"./use-normalized-models-D9FqQyBj.js";import"./form-chip-field-CRtNtvyR.js";import"./input-CalT3wzl.js";import"./chip-list-CvrJkGlz.js";import"./chevron-down-BqXy_cI5.js";import"./accordion-ClGroL7V.js";import"./checkbox-BOwiW7Rf.js";import"./CheckBoxOutlineBlank-Bq47EBBJ.js";import"./DateRange-BWH7VnrS.js";import"./use-base-date-picker-state-CdtiH2H_.js";import"./use-date-formatter-DZ85Tkvk.js";import"./DateFormatter-Dix9bfnP.js";import"./KeyboardArrowRight-Cz-JHdeb.js";import"./use-date-range-picker-state-BvwcI0ca.js";import"./list--2y4kqxI.js";import"./switch-CvotT3pn.js";import"./formatted-date-BIydE9wI.js";import"./dialog-footer-es-AfbvV.js";import"./is-tablet-media-query-B-Y_klfk.js";import"./use-current-date-time-jPIHAlBp.js";import"./normalized-model-field-BnOhtjjx.js";import"./Edit-Cysuqwzc.js";import"./Add-DqbkGfuM.js";import"./dashboard-layout-context-C1ErlVWg.js";import"./ArrowDownward-XP3ErQ5N.js";import"./useInteractOutside-B51FER0Z.js";import"./useEffectEvent-Bb2YhEEQ.js";import"./is-ctrl-or-shift-pressed-CY4knlcl.js";import"./use-pointer-events-gcsg7T42.js";import"./useGlobalListeners-DfpyJoKy.js";import"./combobox-end-adornment-Btuckat_.js";import"./pretty-bytes-bO14ePu9.js";const V=""+new URL("bug-fixing-BghMoLQY.svg",import.meta.url).href,K=[{key:"message",visibleInMode:"all",width:"flex-3 min-w-200",header:()=>e.jsx(i,{message:"Message"}),body:t=>t.message},{key:"datetime",header:()=>e.jsx(i,{message:"Date"}),body:t=>e.jsx(c,{date:t.datetime})},{key:"severity",header:()=>e.jsx(i,{message:"Severity"}),body:t=>e.jsxs("span",{className:d("flex items-center gap-6 text-xs capitalize",t.level==="error"?"text-danger":"text-primary"),children:[t.level==="error"?e.jsx(g,{size:"sm"}):e.jsx(C,{size:"sm"}),t.level]})}];function $(){const{trans:t}=p();return u({mutationFn:r=>J(r),onSuccess:async()=>{await f.invalidateQueries({queryKey:T("logs/error")}),h(t(j("Log file deleted")))},onError:r=>x(r)})}function J({identifier:t}){return D.delete(`logs/error/${t}`).then(r=>r.data)}function We(){const{searchParams:t,sortDescriptor:r,mergeIntoSearchParams:o,setSearchQuery:a,isFiltering:l}=E(y),n=I({...b.logs.error(t)});return e.jsxs(k,{children:[e.jsx(L,{query:n}),e.jsxs(B,{children:[e.jsx(P,{searchValue:t.query,onSearchChange:a,actions:e.jsx(O,{data:n.data,onParamsChange:o})}),e.jsxs(H,{children:[e.jsx(q,{columns:K,data:n.items,sortDescriptor:r,onSortChange:o,enableSelection:!1}),n.isEmpty&&e.jsx(Q,{isFiltering:l,image:V,title:e.jsx(i,{message:"No errors have been logged yet"}),filteringTitle:e.jsx(i,{message:"No matching error log entries"})}),e.jsx(z,{query:n,onPageChange:s=>o({page:s}),onPerPageChange:s=>o({perPage:s})})]})]})]})}function O({data:t,onParamsChange:r}){var n;const o=m.useRef(!1),[a,l]=m.useState(null);return m.useEffect(()=>{if(t.files.length&&!o.current){o.current=!0;const s=t.files[0].identifier;l(s),s!==t.selectedFile&&r({file:s})}},[t,r,o]),e.jsxs(m.Fragment,{children:[e.jsx(U,{files:t.files??null,selectedFile:a,onSelected:s=>{l(s.identifier),r({file:s.identifier})}}),e.jsx(S,{variant:"outline",color:"danger",disabled:!a,onClick:()=>v(Y,{identifier:a}),children:e.jsx(i,{message:"Delete"})}),a&&e.jsx(M,{elementType:"a",download:(n=t.files.find(s=>s.identifier===a))==null?void 0:n.name,href:`api/v1/logs/error/${a}/download`,icon:e.jsx(R,{}),children:e.jsx(i,{message:"Download log"})})]})}function U({files:t,selectedFile:r,onSelected:o}){return t?t.length?e.jsx(A,{appearance:"dropdown",selectionMode:"single",selectedValue:r,size:"sm",minWidth:"min-w-[210px]",children:t==null?void 0:t.map(a=>e.jsxs(w,{value:a.identifier,onSelected:()=>o(a),children:[a.name," (",e.jsx(N,{bytes:a.size}),")"]},a.identifier))}):null:e.jsx(G,{variant:"rect",className:"max-w-[210px]"})}function Y({identifier:t}){const r=$();return e.jsx(W,{title:e.jsx(i,{message:"Delete log file"}),body:e.jsx(i,{message:"Are you sure you want to delete this log file?"}),confirm:e.jsx(i,{message:"Delete"}),onConfirm:()=>r.mutate({identifier:t},{onSuccess:()=>F()}),isLoading:r.isPending,isDanger:!0})}export{We as Component};
