import{j as o}from"./vendor-query-B2UbickB.js";import{j as P,t as L,p as w,r as R}from"./index-_BRA9uFL.js";import{f as $}from"./useEventHooks-XNNzwADV.js";import{u as _}from"./roles-D-LhJ82d.js";import{u as T}from"./useFilterParams-x-Dg0Vgz.js";import{D as k}from"./DataTable-D9yuBv0w.js";import{P as F}from"./PageHeader-BuJpMxyu.js";import{S as N}from"./StickyPagination-BWhFSr2d.js";import{R as z,a as O}from"./RowActions-Dg-Fsm5O.js";import{a as A,T as M,E as I}from"./escalation-columns-CHQEJU1j.js";import{L as U}from"./ListToolbar-jrVba7QN.js";import{a8 as q}from"./vendor-icons-Doy0g69_.js";import{c as B}from"./vendor-react-CXumBFUA.js";import"./EmptyState-BcsfPq9T.js";import"./FilterBar-Ck4K4rzu.js";import"./PriorityBadge-DfQY9St9.js";import"./RolePill-SasQKc_B.js";import"./WorkflowPill-Z-zHRKOK.js";import"./TimestampCell-DL6zMNEQ.js";import"./escalation-B7ysVToF.js";function pt(){$();const y=B(),{user:i}=P(),{filters:e,setFilter:x,pagination:s,sort:n,setSort:h}=T({filters:{role:"",type:"",priority:"",search:""}}),S=L(),{data:l}=_(),{data:p}=w(),{data:a,isLoading:b,error:r,refetch:j,isFetching:E}=R({assigned_to:i==null?void 0:i.userId,status:"pending",role:e.role||void 0,type:e.type||void 0,priority:e.priority?parseInt(e.priority):void 0,limit:s.pageSize,offset:s.offset,sort_by:n.sort_by||"created_at",order:n.order||"desc"}),m=(a==null?void 0:a.escalations)??[],c=(e.search??"").toLowerCase(),d=c?m.filter(t=>{const u=[t.id,t.type,t.subtype,t.description,t.workflow_id,t.origin_id,t.role];return t.metadata&&u.push(...Object.values(t.metadata).map(String)),u.some(f=>f&&String(f).toLowerCase().includes(c))}):m,g=c?d.length:(a==null?void 0:a.total)??0,v={key:"actions",label:"",render:t=>o.jsx(z,{children:o.jsx(O,{icon:q,title:"Release escalation",onClick:()=>S.mutate(t.id),colorClass:"text-text-tertiary hover:text-status-warning"})}),className:"w-16 text-right"},C=[M,...I,v];return o.jsxs("div",{children:[o.jsx(F,{title:"My Escalations"}),o.jsx(A,{filters:e,setFilter:x,roles:(l==null?void 0:l.roles)??[],types:(p==null?void 0:p.types)??[],actions:o.jsx(U,{onRefresh:()=>j(),isFetching:E,apiPath:`/escalations?status=claimed&limit=${s.pageSize}&offset=${s.offset}${e.role?`&role=${e.role}`:""}${e.type?`&type=${e.type}`:""}${e.priority?`&priority=${e.priority}`:""}`})}),r&&o.jsx("div",{className:"mb-4 px-4 py-3 rounded-md bg-status-error/10 border border-status-error/20 text-xs text-status-error",children:r.message==="Session expired"?"Your session has expired. Please log in again.":`Failed to load escalations: ${r.message}`}),o.jsx(k,{columns:C,data:d,keyFn:t=>t.id,onRowClick:t=>y(`/escalations/detail/${t.id}`,{state:{from:"/escalations/queue"}}),isLoading:b,emptyMessage:r?"Unable to load data":"No assigned escalations",sort:n,onSort:h}),o.jsx(N,{page:s.page,totalPages:s.totalPages(g),onPageChange:s.setPage,total:g,pageSize:s.pageSize,onPageSizeChange:s.setPageSize})]})}export{pt as OperatorDashboard};
//# sourceMappingURL=OperatorDashboard-Cy7ySMXj.js.map
