1import{a as it}from"./chunk-2MNF3WWB.js";import{a as et}from"./chunk-ELIKXOTN.js";import{a as Z,b as tt}from"./chunk-EVZINLVO.js";import"./chunk-32QSFOQM.js";import{a as G,h as J,i as Q,j as X,k as Y}from"./chunk-NBRZTU7Q.js";import"./chunk-GSRVRFSH.js";import"./chunk-7RFGD2RP.js";import{d as z}from"./chunk-7UXDOSNG.js";import"./chunk-HDRR6XTY.js";import{c as $}from"./chunk-LWZBMSKX.js";import{a as H}from"./chunk-SFWUWG6U.js";import{a as K,b as q}from"./chunk-4OCSZR72.js";import"./chunk-DEV4X36W.js";import"./chunk-HBROS4VW.js";import{b as j,c as U}from"./chunk-BOQGUSCV.js";import{b as L,j as R,k as W}from"./chunk-POFSDJDP.js";import"./chunk-KLB75TKW.js";import"./chunk-QNGR7PAY.js";import{Ab as D,Bb as V,Ca as I,Fb as A,Gb as w,Hb as N,Lb as F,Nb as E,Pb as M,R as S,Ra as x,Sa as f,Tb as v,V as p,Va as b,W as _,Wa as k,Xa as c,Ya as n,Za as i,_a as h,ea as m,fb as y,fc as B,hb as g,jb as d,ra as r,wc as O,xb as o,yb as C,zb as T}from"./chunk-MCLGSJRL.js";import"./chunk-2NFLSA4Y.js";var at=e=>["/admin/tickets",e],nt=(e,a)=>a.id;function ot(e,a){e&1&&h(0,"ui-empty-state",1)}function rt(e,a){if(e&1&&(n(0,"mat-option",8),o(1),i()),e&2){let t=a.$implicit;c("value",t.id),r(),C(t.name)}}function lt(e,a){if(e&1){let t=y();n(0,"mat-form-field",12)(1,"mat-label"),o(2,"Sales point"),i(),n(3,"mat-select",7),g("selectionChange",function(s){p(t);let u=d(2);return _(u.salesPointId.set(s.value))}),n(4,"mat-option",8),o(5,"All sales points"),i(),b(6,rt,2,2,"mat-option",8,nt),i()()}if(e&2){let t=d(2);r(3),c("value",t.salesPointId()),r(),c("value",null),r(2),k(t.salesPoints())}}function st(e,a){if(e&1){let t=y();n(0,"button",18),g("click",function(){p(t);let s=d(2);return _(s.clear())}),o(1," Clear "),i()}}function dt(e,a){e&1&&h(0,"ui-empty-state",15),e&2&&c("loading",!0)}function ct(e,a){e&1&&h(0,"ui-empty-state",16),e&2&&c("description",a)}function mt(e,a){if(e&1&&h(0,"ui-empty-state",17),e&2){let t=d(2);c("title",t.filtering()?"Nothing matches":"No tickets yet")("description",t.filtering()?"Widen the dates, clear the search, or try another reference.":"A ticket appears here when an operator\u2019s system issues one for a purchase. Nothing in SKAFA issues one of its own yet.")}}function ut(e,a){if(e&1&&(o(0," \xB7 "),n(1,"span",39),o(2),i()),e&2){let t=d().$implicit;r(2),C(t.subjectRef)}}function pt(e,a){e&1&&(n(0,"ui-badge",30),o(1,"Erased"),i())}function _t(e,a){if(e&1&&(n(0,"span",31),o(1),i()),e&2){let t=d().$implicit;r(),C(t.customer)}}function xt(e,a){if(e&1&&(n(0,"span",34),o(1),i()),e&2){let t=d().$implicit;r(),C(t.externalRef)}}function ft(e,a){e&1&&(n(0,"span",35),o(1,"\u2014"),i())}function gt(e,a){if(e&1&&(o(0),E(1,"date")),e&2){let t=d().$implicit;T(" ",M(1,1,t.deliveredAtUtc,"dd.MM. HH:mm")," ")}}function ht(e,a){e&1&&(n(0,"span",35),o(1,"\u2014"),i())}function Ct(e,a){if(e&1&&(n(0,"tr",23)(1,"td",27),o(2),E(3,"date"),i(),n(4,"td",22)(5,"div",28),o(6),i(),n(7,"div",29),o(8),x(9,ut,3,1),i()(),n(10,"td",22),x(11,pt,2,0,"ui-badge",30)(12,_t,2,1,"span",31),i(),n(13,"td",22)(14,"ui-badge",32),o(15),i()(),n(16,"td",33),o(17),i(),n(18,"td",22),x(19,xt,2,1,"span",34)(20,ft,2,0,"span",35),i(),n(21,"td",36),x(22,gt,2,4)(23,ht,2,0,"span",35),i(),n(24,"td",37)(25,"a",38),o(26," Open "),i()()()),e&2){let t=a.$implicit,l=d(3);r(2),T(" ",M(3,12,t.createdAtUtc,"dd.MM.yyyy HH:mm")," "),r(4),C(t.productName),r(2),D(" ",t.description," \xB7 ",t.salesPointName," "),r(),f(t.
1subjectRef?9:-1),r(2),f(t.customerErased?11:12),r(3),c("tone",l.statusTone(t.status)),r(),C(l.statusLabel(t.status)),r(2),T(" ",l.documentLabel(t.document)," "),r(2),f(t.externalRef?19:20),r(3),f(t.deliveredAtUtc?22:23),r(3),c("routerLink",F(15,at,t.id))}}function yt(e,a){if(e&1){let t=y();n(0,"div",19)(1,"table",20)(2,"thead",21)(3,"tr")(4,"th",22),o(5,"When"),i(),n(6,"th",22),o(7,"For"),i(),n(8,"th",22),o(9,"Customer"),i(),n(10,"th",22),o(11,"State"),i(),n(12,"th",22),o(13,"Document"),i(),n(14,"th",22),o(15,"Reference"),i(),n(16,"th",22),o(17,"Sent"),i(),h(18,"th",22),i()(),n(19,"tbody"),b(20,Ct,27,17,"tr",23,nt),i()()(),n(22,"div",24)(23,"div"),o(24),i(),n(25,"div",25)(26,"button",26),g("click",function(){p(t);let s=d(2);return _(s.go(s.page()-1))}),o(27," Previous "),i(),n(28,"button",26),g("click",function(){p(t);let s=d(2);return _(s.go(s.page()+1))}),o(29," Next "),i()()()}if(e&2){let t=d(2);r(20),k(t.rows()),r(4),V("",t.firstOnPage(),"\u2013",t.lastOnPage()," of ",t.total()),r(2),c("disabled",t.page()<=1),r(2),c("disabled",t.lastOnPage()>=t.total())}}function St(e,a){if(e&1){let t=y();n(0,"div",2)(1,"mat-form-field",3)(2,"mat-label"),o(3,"Search"),i(),n(4,"input",4),g("input",function(s){p(t);let u=d();return _(u.search.set(s.target.value))})("keyup.enter",function(){p(t);let s=d();return _(s.apply())}),i()(),n(5,"ui-date-range",5),N("fromChange",function(s){p(t);let u=d();return w(u.from,s)||(u.from=s),_(s)})("toChange",function(s){p(t);let u=d();return w(u.to,s)||(u.to=s),_(s)}),i(),n(6,"mat-form-field",6)(7,"mat-label"),o(8,"State"),i(),n(9,"mat-select",7),g("selectionChange",function(s){p(t);let u=d();return _(u.status.set(s.value))}),n(10,"mat-option",8),o(11,"Any state"),i(),n(12,"mat-option",9),o(13,"Issued"),i(),n(14,"mat-option",10),o(15,"Waiting for one"),i(),n(16,"mat-option",11),o(17,"There will not be one"),i()()(),x(18,lt,8,2,"mat-form-field",12),n(19,"button",13),g("click",function(){p(t);let s=d();return _(s.apply())}
1),o(20," Apply "),i(),x(21,st,2,0,"button",14),i(),x(22,dt,1,1,"ui-empty-state",15)(23,ct,1,1,"ui-empty-state",16)(24,mt,1,2,"ui-empty-state",17)(25,yt,30,5)}if(e&2){let t,l=d();r(4),c("value",l.search()),r(),A("from",l.from)("to",l.to),r(4),c("value",l.status()),r(),c("value",null),r(8),f(l.salesPoints().length>1?18:-1),r(3),f(l.filtering()?21:-1),r(),f(l.loading()?22:(t=l.loadError())?23:l.rows().length===0?24:25,t)}}var P=class e{ticketsApi=S(it);catalogueApi=S(et);auth=S(H);isAdmin=this.auth.isAdmin;loading=m(!0);loadError=m(null);rows=m([]);total=m(0);page=m(1);salesPoints=m([]);search=m("");from=m("");to=m("");status=m(null);salesPointId=m(null);pageSize=25;filtering=v(()=>this.search().trim().length>0||this.from().length>0||this.to().length>0||this.status()!==null||this.salesPointId()!==null);firstOnPage=v(()=>this.total()===0?0:(this.page()-1)*this.pageSize+1);lastOnPage=v(()=>Math.min(this.page()*this.pageSize,this.total()));constructor(){this.isAdmin()?this.load():this.loading.set(!1)}apply(){this.page.set(1),this.load()}clear(){this.search.set(""),this.from.set(""),this.to.set(""),this.status.set(null),this.salesPointId.set(null),this.apply()}go(a){this.page.set(Math.max(1,a)),this.load()}statusLabel(a){switch(a){case"Issued":return"Issued";case"Pending":return"Waiting for one";default:return"There will not be one"}}statusTone(a){switch(a){case"Issued":return"success";case"Pending":return"warning";default:return"neutral"}}documentLabel(a){switch(a){case"Stored":return"Held here";case"Proxied":return"Fetched from the operator";default:return"\u2014"}}static dayAfter(a){let t=new Date(`${a}T00:00:00`);return t.setDate(t.getDate()+1),t.toISOString()}async load(){this.loading.set(!0),this.loadError.set(null);try{let[a,t]=await Promise.all([this.ticketsApi.list({search:this.search().trim()||null,from:this.from()?new Date(`${this.from()}T00:00:00`).toISOString():null,to:this.to()?e.dayAfter(this.to()):null,status:this.status(),salesPointId:this.salesPointId(),page:this.page(),pageSize:this.pageSize}),this.catalogueApi.listSalesPoints().catch(()=>[])]);this.rows.set(a.rows),this.total.set(a.total),this.salesPoints.set(t)}catch{this.loadError.set("Try again, or narrow the dates if this organization has a lot of them.")}finally{this.loading.set(!1)}}static \u0275fac=function(t){return new(t||e)};static \u0275cmp=I({type:e,selectors:[["admin-tickets"]],decls:4,vars:1,consts:[["title","Tickets","subtitle","What an operator issued for a purchase, and whether it reached the customer."],["icon","lock","title","Admins only","description","Tickets are visible to an organization's administrators.",1,"mt-8"],[1,"mt-6","mb-8","flex","flex-wrap","items-end","gap-3"],["subscriptSizing","dynamic",1,"w-72"],["matInput","","placeholder","Reference, printed words, plate, order id",3,"input","keyup.enter","value"],[3,"fromChange","toChange","from","to"],["subscriptSizing","dynamic",1,"w-52"],[3,"selectionChange","value"],[3,"value"],["value","Issued"],["value","Pending"],["value","None"],["subscriptSizing","dynamic",1,"w-56"],["matButton","filled",3,"click"],["matButton",""],["title","Loading\u2026",3,"loading"],["icon","triangle-alert","title","Tickets could not be loaded",3,"description"],["icon","ticket",3,"title","description"],["matButton","",3,"click"],[1,"overflow-x-auto"],[1,"w-full","min-w-[52rem]","text-sm"],[1,"text-left","text-xs","text-neutral-500"],[1,"py-2"],[1,"border-t","border-neutral-200","dark:border-neutral-800"],[1,"mt-4","flex","items-center","justify-between","text-sm","text-neutral-500"],[1,"flex","items-center","gap-2"],["matButton","outlined",3,"click","disabled"],[1,"py-2","whitespace-nowrap","tabular-nums"],[1,"font-medium"],[1,"text-xs","text-neutral-500"],["tone","neutral"],[1,"text-xs"],[3,"tone"],[1,"py-2","text-xs","text-neutral-500"],[1,"font-mono","text-xs"],[1,"text-neutral-400"],[1,"py-2","text-xs","whitespace-nowrap","tabular-nums"],[1,"py-2","text-right"],["matButton","",3,"routerLink"],[1,"font-mono"]],template:function(t,l){t&1&&(n(0,"ui-page-container"),h(1,"ui-page-header",0),x(2,ot,1,0,"ui-empty-state",1)(3,St,26,8),i()),t&2&&(r(2),f(l.isAdmin()?3:2))},dependencies:[G,J,Q,U,j,W,R,L,$,q,K,tt,Z,z,X,Y,O,B],encapsulation:2})};export{P as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.