PageSourceSearch

https://pricing.bytephase.com/chunk-NQ62W6YD.js

js bytephase.com collected 2026-10-02 00:06:46 UTC 224,085 bytes, 1 lines download raw bytes

1import{a as Ko}from"./chunk-ZF4BWBDX.js";import{a as ko}from"./chunk-BER4SKK6.js";import{a as Fo,b as Ho,c as $o}from"./chunk-O6XXBRCE.js";import{a as Fi,c as Bi,e as Ui,g as Yi,h as qo}from"./chunk-VZHJCHKX.js";import"./chunk-DQUZ3TAM.js";import{a as Wt,b as _o,c as uo,d as vo,e as Co,f as fo,g as ho,h as xo,j as To}from"./chunk-YPUPV3PR.js";import"./chunk-JVQG3VTE.js";import"./chunk-KKZOCMSP.js";import{a as Yo}from"./chunk-2S3V66RC.js";import"./chunk-5ZQ6NXY3.js";import"./chunk-UZN7GMG3.js";import"./chunk-JHNKYRVZ.js";import"./chunk-WNDPZO2Y.js";import{b as po}from"./chunk-KSFFYQCS.js";import"./chunk-FFAZLYZD.js";import{a as ro,b as lo}from"./chunk-7GS7FGZ4.js";import"./chunk-VCXRUVDZ.js";import"./chunk-2QKKZ624.js";import"./chunk-22X6IYU6.js";import"./chunk-7DNSHQFI.js";import{a as jt}from"./chunk-FZ3T72KF.js";import{a as Wo}from"./chunk-ZAL3X3MF.js";import{a as Qo}from"./chunk-YH7FTGHQ.js";import"./chunk-ZW3HR3DT.js";import{a as Ti,b as gi}from"./chunk-CPZFJYCU.js";import{a as pt}from"./chunk-7THL3Y32.js";import{a as Oi}from"./chunk-7RBD6MCS.js";import"./chunk-666WVUQE.js";import"./chunk-AQK7XEPI.js";import"./chunk-BTKARO6W.js";import{V as ee,b as Be,d as Ue,f as Ri,g as Ht,h as De,i as So,j as Do,q as Io}from"./chunk-WPRT4K6N.js";import{b as mt}from"./chunk-GNCYTUDV.js";import"./chunk-AQ7PSC44.js";import"./chunk-BZPCOA7E.js";import{a as Ai}from"./chunk-7DNSNCTX.js";import"./chunk-Y5QHNG76.js";import"./chunk-5DBVKRPS.js";import"./chunk-SV6HILEX.js";import"./chunk-AVG3WWNI.js";import"./chunk-4QTXSGWG.js";import"./chunk-ZE7JEIUT.js";import"./chunk-6MSUZAYQ.js";import{a as Jn}from"./chunk-4AF4NPQI.js";import"./chunk-IDRSVUWN.js";import"./chunk-ZXCVSQFM.js";import{a as no}from"./chunk-TL42QQNS.js";import"./chunk-LHZ4FS5T.js";import{f as Li}from"./chunk-HJPI7DRX.js";import{a as Vi,b as Pi,d as Oo,j as Uo}from"./chunk-QTN6CETX.js";import"./chunk-GBJZUMIE.js";import"./chunk-NDM5632L.js";import"./chunk-ERDG3YQD.js";import"./chunk-ALA2R7EV.js";import"./chunk-WDJ3CLAY.js";import"./chunk-JHTW4QMD.js";import{a as Go}from"./chunk-LW6Q6ZJO.js";import"./chunk-CMLSZFIY.js";import"./chunk-LKMSNKV5.js";import"./chunk-SIOLTKCO.js";import{a as jo}from"./chunk-BI2K4FRR.js";import{a as Bo}from"./chunk-B33GVRO2.js";import{a as ki}from"./chunk-TT7KELWJ.js";import"./chunk-3ULIYWL6.js";import"./chunk-Q4MQTTKL.js";import{a as bi,b as Si}from"./chunk-5MKJQMUB.js";import{b as co}from"./chunk-LKIAXD6G.js";import"./chunk-QAOKN53P.js";import{a as wi}from"./chunk-PRPUTN45.js";import{a as Ro}from"./chunk-7IAA4VLQ.js";import{b as wo,c as Mo}from"./chunk-NQRDUB2K.js";import"./chunk-VUUABU7N.js";import{a as Di}from"./chunk-AK2ZBIXB.js";import{a as No,b as Vo,d as Po,e as Lo}from"./chunk-OQM52AJA.js";import"./chunk-6YP7UPTG.js";import{a as Eo}from"./chunk-H7J47AIU.js";import"./chunk-QOOM4IJQ.js";import"./chunk-WERSRGK2.js";import"./chunk-MJAW66WA.js";import"./chunk-5V6CGZB6.js";import"./chunk-U42M2UDL.js";import"./chunk-KN727XMG.js";import{b as mo}from"./chunk-T7Z4AMLI.js";import"./chunk-5VFPQPYC.js";import"./chunk-JILTLMIZ.js";import"./chunk-DLZSNDPV.js";import"./chunk-FQ5Z4AI7.js";import{a as Ni}from"./chunk-ZQQTRF6E.js";import{m as Ut,n as lt,o as st,p as ct,q as dt,r as Ei,s as Yt,t as Jt,u as pn,z as _e}from"./chunk-AIJA2BLZ.js";import{a as yo}from"./chunk-SBWMP37V.js";import{a as oo,b as ao}from"./chunk-3LC6WUK4.js";import"./chunk-Y2SACVAR.js";import"./chunk-3VPO4ZKE.js";import"./chunk-RXKCASCS.js";import"./chunk-NUXDYLT4.js";import{a as Ao}from"./chunk-JIIZYIHB.js";import{c as bo}from"./chunk-GBMNCAKO.js";import"./chunk-PMV5UJBD.js";import{b as Mi}from"./chunk-EL7A36AS.js";import{a as Ii}from"./chunk-JOKOC2WT.js";import{b as Gt}from"./chunk-AIHLEMCN.js";import{c as so}from"./chunk-U4BPK6O4.js";import"./chunk-TJVD6GVN.js";import"./chunk-JMK6MVHG.js";import"./chunk-E2NUWJAL.js";import"./chunk-5SGE6NEO.js";import{a as go}from"./chunk-E6N4NTHZ.js";import"./chunk-TCOJAZWD.js";import"./chunk-K3Z54U74.js";import"./chunk-YAGWJNOX.js";import"./chunk-UJR3GWE3.js";import"./chunk-YUAEW6DN.js";import"./chunk-AU2RM2SR.js";import"./chunk-NSZJCKIU.js";import{a as to}from"./chunk-QHX2QRDK.js";import{a as dn}from"./chunk-WJ3W5OIV.js";import"./chunk-JZNF4MYL.js";import"./chunk-7REE6FCH.js";import"./chunk-PUZPIDVM.js";import{a as Xn}from"./chunk-FO6RSKI7.js";import{h as Zn}from"./chunk-SBOAMFMP.js";import"./chunk-FUSUZSLZ.js";import{a as hi,b as xi}from"./chunk-QH3HH3BG.js";import"./chunk-HOAY7V7Z.js";import"./chunk-J7BDNTS3.js";import"./chunk-F5MWH2WG.js";import{e as H}from"./chunk-FBL7G3LD.js";import"./chunk-LFCV52ZK.js";import{a as eo}from"./chunk-VDTICQXI.js";import"./chunk-NNVD6EWQ.js";import{a as kt}from"./chunk-UFSACXCI.js";import{a as Ee}from"./chunk-262EJ3PM.js";import"./chunk-KJSAPWO5.js";import"./chunk-Z3YKIM2G.js";import{a as Bt}from"./chunk-6LVG3AJL.js";import{a as yi}from"./chunk-HMWANN7P.js";import"./chunk-LLCQLQX7.js";import{a as be,b as Se}from"./chunk-MK5M43RY.js";import"./chunk-DFMU7OPD.js";import"./chunk-YU3UZ3YG.js";import"./chunk-VXDIBCKO.js";import"./chunk-3FMJ2IGL.js";import"./chunk-Z4N5M7GF.js";import"./chunk-GWCGR7FC.js";import"./chunk-KH6EL23Q.js";import{a as io}from"./chunk-77CBT5G6.js";import{b as at,c as rt}from"./chunk-D6XIV6DQ.js";import"./chunk-QFIH6JQW.js";import{a as Ft}from"./chunk-4WYIJOHJ.js";import"./chunk-53QJVJEJ.js";import"./chunk-3CNNJAIH.js";import"./chunk-PVZ5E6C4.js";import"./chunk-5OL2QAZ4.js";import"./chunk-AHHG7NNI.js";import{c as J}from"./chunk-V6HUKMMQ.js";import"./chunk-535XSUHN.js";import"./chunk-2OEDVHTN.js";import"./chunk-ZTJFEYA7.js";import"./chunk-L5KFH527.js";import"./chunk-63QLPR5K.js";import"./chunk-UU232UL2.js";import"./chunk-7MWVCLDY.js";import"./chunk-XWD65C7E.js";import"./chunk-MW5RTTXB.js";import"./chunk-Q5EBYCLM.js";import"./chunk-4QPQIRMU.js";import"./chunk-EOVJRDAN.js";import{a as Ot}from"./chunk-FILO7TIS.js";import{a as Fe}
1from"./chunk-75OA7QS4.js";import"./chunk-CSCP3ZTJ.js";import{a as pe,b as me}from"./chunk-MTSAZTVR.js";import"./chunk-ASETCLUR.js";import"./chunk-WNQ4N7RJ.js";import{b as k}from"./chunk-7MEILHIE.js";import"./chunk-Z2RJGNAZ.js";import{a as oe}from"./chunk-G4XKTR23.js";import"./chunk-ZWLUA43H.js";import{a as Mt}from"./chunk-HXDZ72GQ.js";import"./chunk-H2UYTWBE.js";import{a as jn}from"./chunk-32LAIJWW.js";import"./chunk-4XNLR73E.js";import{a as Lt}from"./chunk-NRJNLGPZ.js";import"./chunk-FJNY3YCS.js";import"./chunk-42KLYNQJ.js";import"./chunk-LMPIDVVC.js";import{a as Ci}from"./chunk-O4S5RAMO.js";import{k as zn,m as de}from"./chunk-7RIQHS27.js";import"./chunk-UVTFM2CB.js";import"./chunk-PD73N3RP.js";import"./chunk-3UUSYTLR.js";import"./chunk-KWU7YDJI.js";import"./chunk-KQNYRKYJ.js";import{a as ce}from"./chunk-FSFJIT6H.js";import"./chunk-RVYBXY7M.js";import{a as fi}from"./chunk-6CGN4C4Z.js";import"./chunk-SKOPRTU6.js";import{c as le,d as se}from"./chunk-SMTOFR4W.js";import{b as bt,c as ve,d as St}from"./chunk-7CA2QT7E.js";import"./chunk-VRQJEEON.js";import"./chunk-DJAISFD4.js";import{a as ae,b as re}from"./chunk-QBG2AFW3.js";import"./chunk-E3YEN5V4.js";import"./chunk-V6Z2JOJI.js";import"./chunk-GP2Y5EBK.js";import{a as Qn,b as Kn}from"./chunk-QWBQW4TP.js";import{a as $n}from"./chunk-2IY6D564.js";import{A as ua,B as qn,E as wt,d as V,f as Te,g as Pe,l as Nn,m as et,p as mi,s as Le,t as Oe,w as ge,x as Vn,y as ke}from"./chunk-BL5X7LEL.js";import"./chunk-USTFUPXV.js";import{Uc as vi,eh as Nt,fh as Vt,gh as Pt,jb as ie,kb as ne}from"./chunk-NCNN7TJ7.js";import{a as B}from"./chunk-BHJUQJ35.js";import"./chunk-555PDMZK.js";import"./chunk-TSCJWBEN.js";import{a as S,f as K}from"./chunk-WH7NK76V.js";import"./chunk-SGVLNALP.js";import{$h as g,Ai as Dt,Aj as Hn,Mb as d,Oi as Bn,R as te,Ti as Un,U as Je,V as Mn,Vi as b,X as sn,Yb as Pn,Zi as Zt,ed as _i,eh as A,f as pi,gh as cn,h as In,hh as Fn,i as An,ih as z,ij as It,j as Rn,jg as ui,jj as At,kj as Rt,lj as it,m as wn,mj as nt,nj as Yn,oi as q,oj as Gn,pi as ht,qi as tt,qj as $e,rd as qe,ri as Xt,rj as Z,sd as Ln,sj as Wn,td as On,tj as ot,u as j,ud as kn,xh as $,zh as D}from"./chunk-O3WROL2M.js";import{$b as ci,$c as di,Aa as Tt,Ac as p,Ba as we,Bc as u,Cc as R,Dc as U,Ec as Et,Hc as Y,Ic as G,Jc as W,Nc as Ct,Oc as ft,Pb as f,Rb as h,Sc as P,Tb as ut,Tc as ye,Ub as He,Uc as bn,Vb as je,Vc as Sn,W as xn,Wb as l,Xb as r,Xc as M,Yb as a,Yc as Dn,Zb as m,Zc as N,_a as gt,_b as si,aa as Xe,ac as yn,b as oi,ba as ri,bc as Ne,cc as Ve,dc as Tn,e as fn,ea as Ze,eb as n,f as hn,fa as x,gc as T,k as ai,ka as v,kc as y,la as C,mc as s,nb as X,qa as O,qc as fe,rc as he,sa as ln,sc as xe,tb as E,ub as li,wa as We,wc as gn,xb as Me,yb as I,yc as En,zc as vt}from"./chunk-WMRJX23E.js";import"./chunk-UIGZEDL5.js";import"./chunk-HNIQUNPL.js";import"./chunk-LJZ7ZJF4.js";import{a as Q,b as Ce,e as Cn,h as _a}from"./chunk-FBFWB55K.js";var Gi=(()=>{class t{get isMobileDevice(){return this.userDeviceService.isMobileDevice()}constructor(){this.formatMessage=d,this.moduleDataService=x(eo),this.router=x(Je),this.userSessionService=x(k),this.activatedRouter=x(te),this.guidedTourService=x(Go),this.userDeviceService=x(K),this.userPermissionList=this.userSessionService.userPermissionList(),this.ENTITIES=b,this.selectedTabIndex=0,this.rentalModuleTabs=[{id:0,text:d("contracts"),path:"/rentals/list",attrId:"rentalTabContracts",visible:this.userPermissionList.includes(g.RENTAL_CONTRACT_LIST)&&this.moduleDataService.isModuleActive(this.ENTITIES.RENTAL_CONTRACT.name)},{id:1,text:d("devices"),path:"/rentals/devices",attrId:"rentalTabDevices",visible:this.userPermissionList.includes(g.RENTAL_DEVICE_MANAGE)},{id:2,text:d("overview"),path:"/rentals/overview",attrId:"rentalTabOverview",visible:this.userPermissionList.includes(g.RENTAL_CONTRACT_LIST)},{id:3,text:d("reports"),path:"/rentals/reports",visible:!1},{id:4,text:d("settings"),path:"/rentals/settings",attrId:"rentalTabSettings",visible:this.userPermissionList.includes(g.RENTAL_SETTINGS)}],this.ENTITY_ICONS=$e,this.activatedRouter.firstChild?.data.pipe(S()).subscribe({next:e=>{this.selectedTabIndex=e.tab_index},error:e=>{console.error("failed to get selected tab index ",e)}}),this.startFirstVisitTour()}startFirstVisitTour(){this.isMobileDevice||!this.userSessionService.isEmployee()||this.guidedTourService.hasSeenTour("RENTAL")||(this.guidedTourService.markTourSeen("RENTAL"),setTimeout(()=>this.guidedTourService.startTour("RENTAL"),600))}selectTab(e){this.selectedTabIndex=e.itemIndex}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental"]],decls:2,vars:8,consts:[[1,"container-fluid"],["mode","route",3,"tabChange","tabs","selectedIndex","showNavButtons","scrollByContent","mobilePillTabs","hideContentHeader","mobileMenuTitle","mobileMenuIcon"]],template:function(o,i){o&1&&(r(0,"div",0)(1,"app-responsive-tabs",1),y("tabChange",function(L){return i.selectTab(L)}),a()()),o&2&&(n(),l("tabs",i.rentalModuleTabs)("selectedIndex",i.selectedTabIndex)("showNavButtons",!0)("scrollByContent",!0)("mobilePillTabs",!0)("hideContentHeader",!0)("mobileMenuTitle",i.formatMessage("rentals"))("mobileMenuIcon",i.ENTITY_ICONS.RENTAL_CONTRACT.solid))},dependencies:[Oi],encapsulation:2})}}return t})();var Ie=(()=>{class t extends it{constructor(e){super(e,Ln),this.api=e,this.uuidService=x(Fo)}createBarcode(e){return this.update({id:e.id,name:e.name,barcode_number:this.uuidService.generateRandomUniqueNumber()})}static{this.\u0275fac=function(o){return new(o||t)(Ze(nt))}}static{this.\u0275prov=Xe({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();function va(t,c){if(t&1&&(r(0,"span",4),p(1),a()),t&2){let e=s();n(),u(e.device.device_number)}}function Ca(t,c){if(t&1&&(r(0,"span"),p(1),a()),t&2){let e=s();vt(ft("badge rounded-pill flex-shrink-0 ",e.badgeClass(e.device.rental_status)," fs-10 app-rdo-font-weight-500")),n(),u(e.statusLabel(e.device.rental_status))}}var Ye=(()=>{class t{constructor(){this.formatMessage=d,this.monthlyPrice=null,this.iconClass=Ei,this.badgeClass=Ut,this.statusLabel=lt}get price(){return this.monthlyPrice??this.device?.rental_rate_monthly??null}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-device-option"]],inputs:{device:"device",monthlyPrice:"monthlyPrice"},decls:14,vars:10,consts:[[1,"d-flex","align-items-center","gap-3","w-100","py-1"],[1,"flex-fill","overflow-hidden"],[1,"d-flex","align-items-center","gap-2"],[1,"fw-semibold","text-truncate","app-rdo-c-primary-text",3,"title"],[1,"flex-shrink-0","text-nowrap","fs-11","app-rdo-letter-spacing-0-4px","app-rdo-c-text-muted"],[3,"class"],[1,"text-muted","text-truncate","d-block",3,"title"],[1,"text-end","flex-shrink-0"],[1,"fw-semibold","text-nowrap","app-rdo-c-primary-text"],["digits","1.0-2",3,"value"],[1,"text-muted","fw-normal","ms-1","fs-12"]],template:function(o,i){o&1&&(r(0,"div",0)(1,"div",1)(2,"div",2)(3,"span",3),p(4),a(),f(5,va,2,1,"span",4),f(6,Ca,2,4,"span",5),a(),r(7,"small",6),p(8),a()(),r(9,"div",7)(10,"div",8),m(11,"app-money",9),r(12,"span",10),p(13),a()()()()),o&2&&(n(3),l("title",i.device==null?null:i.device.name),n(),u(i.device==null?null:i.device.name),n(),h(i.device!=null&&i.device.device_number?5:-1),n(),h(i.device!=null&&i.device.rental_status&&i.device.rental_status.toLowerCase()!=="available"?6:-1),n(),l("title",((i.device==null||i.device.device_brand==null?null:i.device.device_brand.name)||"\u2014")+" \xB7 "+((i.device==null||i.device.device_model==null?null:i.device.device_model.name)||"\u2014")+(i.device!=null&&i.device.serial_number?" \xB7 "+i.device.serial_number:"")),n(),Et(" ",(i.device==null||i.device.device_brand==null?null:i.device.device_brand.name)||"\u2014"," \xB7 ",(i.device==null||i.device.device_model==null?null:i.device.device_model.name)||"\u2014","",i.device!=null&&i.device.serial_number?" \xB7 "+i.device.serial_number:""," "),n(3),l("value",i.price),n(2),u(i.formatMessage("per_month_short")))},dependencies:[j,H],styles:[".app-rdo-c-primary-text[_ngcontent-%COMP%]{color:var(--primary-text)}.app-rdo-letter-spacing-0-4px[_ngcontent-%COMP%]{letter-spacing:.4px}.app-rdo-c-text-muted[_ngcontent-%COMP%]{color:var(--bp-text-muted)}.app-rdo-font-weight-500[_ngcontent-%COMP%]{font-weight:500}"]})}}return t})();var Re=class{constructor(c){return Object.assign(this,c)}};var F=(()=>{class t extends it{constructor(e){super(e,qe),this.api=e,this.documentService=x(mt),this.currentContractSubject=ne
1w hn(null),this.currentContract$=this.currentContractSubject.asObservable(),this.depositsChangedSubject=new fn,this.depositsChanged$=this.depositsChangedSubject.asObservable()}setCurrentContract(e){this.currentContractSubject.next(e)}getCurrentContract(){return this.currentContractSubject.value}notifyDepositsChanged(){this.depositsChangedSubject.next()}updateStatus(e,o,i){let _={status:o};return i?.length&&(_.items=i),this.api.patch(`${qe}/updateStatus/${e}`,_)}updateAssignee(e,o){return this.api.patch(`${qe}/updateStatus/${e}`,{assignee_id:o})}getContractItems(e){return this.api.getWithParams("rentalContractItems",{rental_contract_id:e,status:"active"})}returnDevice(e){return this.api.patch(`rentalContractItems/${e}/return`,{})}assignDevice(e,o){return this.api.patch(`${qe}/${e}/assignDevice`,o)}getDeposits(e){return this.api.get(`${qe}/${e}/deposits`)}collectDeposit(e,o){return this.api.post(`${qe}/${e}/deposits`,o)}refundDeposit(e){return this.api.post(`rentalDeposits/${e}/refund`,{})}getOverview(){return this.api.get(`${qe}/overview`)}getDetailById(e){return this.api.get(`${qe}/${e}`)}refreshDetail(e){return this.documentService.invalidate(b.RENTAL_CONTRACT.name,e),this.getDetailById(e).pipe(xn(o=>this.setCurrentContract(o?new Re(o):null)))}static{this.\u0275fac=function(o){return new(o||t)(Ze(nt))}}static{this.\u0275prov=Xe({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var qt=(()=>{class t extends it{constructor(e){super(e,kn),this.api=e,this.rentalContractService=x(F)}getListByQuery(e={}){return e.rental_contract_id?this.rentalContractService.getDeposits(e.rental_contract_id):ai([])}static{this.\u0275fac=function(o){return new(o||t)(Ze(nt))}}static{this.\u0275prov=Xe({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();function ha(t,c){if(t&1&&(r(0,"div",0)(1,"div",2)(2,"div",3)(3,"div",4)(4,"span"),p(5),a(),r(6,"span",5),m(7,"app-money",6),a()(),r(8,"div",4)(9,"span"),p(10),a(),r(11,"span",5),m(12,"app-money",6),a()(),r(13,"div",7)(14,"span"),p(15),a(),r(16,"span",5),m(17,"app-money",6),a()()()()()),t&2){let e=s();n(5),R("",e.formatMessage("deposit_expected"),": "),n(2),l("value",e.expected),n(3),R("",e.formatMessage("deposit_received"),": "),n(2),l("value",e.collected),n(3),R("",e.formatMessage("deposit_outstanding"),": "),n(2),l("value",e.outstanding)}}function xa(t,c){if(t&1&&(r(0,"div",1)(1,"span")(2,"strong",8),p(3),a(),m(4,"app-money",6),a(),r(5,"span")(6,"strong",8),p(7),a(),m(8,"app-money",6),a(),r(9,"span")(10,"strong",8),p(11),a(),m(12,"app-money",6),a()()),t&2){let e=s();n(3),u(e.formatMessage("deposit_expected")),n(),l("value",e.expected),n(3),u(e.formatMessage("deposit_received")),n(),l("value",e.collected),n(3),u(e.formatMessage("deposit_outstanding")),n(),l("value",e.outstanding)}}var Wi=(()=>{class t{constructor(){this.formatMessage=d,this.expected=0,this.collected=0,this.outstanding=0,this.boxed=!1}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-deposit-summary"]],inputs:{expected:"expected",collected:"collected",outstanding:"outstanding",boxed:"boxed"},decls:2,vars:1,consts:[[1,"card","mb-3"],[1,"d-flex","flex-wrap","gap-5","px-2","py-2","mb-2"],[1,"card-body","py-2","px-3"],[1,"row","g-2"],[1,"col-6"],[1,"fw-bold"],[3,"value"],[1,"col-12"],[1,"me-2"]],template:function(o,i){o&1&&f(0,ha,18,6,"div",0)(1,xa,13,6,"div",1),o&2&&h(i.boxed?0:1)},dependencies:[H],encapsulation:2})}}return t})();var ya=()=>({type:"fixedPoint",precision:2});function Ta(t,c){if(t&1&&(r(0,"form",5)(1,"app-control-container",7),m(2,"dx-number-box",8),a(),r(3,"app-control-container",9),m(4,"app-payment-type-dropdown",10),a(),r(5,"app-control-container",11),m(6,"app-textarea",12),a()()),t&2){let e=s(2);l("formGroup",e.form),n(),l("errorMsg",Ct(e.formatMessage("common_amount_required")))("label",Ct(e.formatMessage(e.isEditMode?"common_amount":"collect_deposit"))),n(),l("format",P(18,ya))("min",0)("showClearButton",!0),n(),l("errorMsg",Ct(e.formatMessage("common_error_messages_payment_mode_required")))("label",Ct(e.formatMessage("common_payment_type"))),n(),l("allowCreate",!0)("isEditMode",!0),n(),l("errorMsg",Ct(e.formatMessage("common_error_messages_comment_required")))("label",Ct(e.formatMessage("common_comment")))}}function ga(t,c){if(t&1){let e=T();r(0,"div",2)(1,"dx-scroll-view",3),m(2,"app-rental-deposit-summary",4),f(3,Ta,7,19,"form",5),a(),r(4,"app-save-cancel-footer",6),y("cancelClick",function(){v(e);let i=s();return C(i.onClosing())})("saveClick",function(){v(e);let i=s();return C(i.collect())}),a()()}if(t&2){let e=s();n(2),l("boxed",!0)("collected",e.collectedAmount)("expected",e.expectedAmount)("outstanding",e.outstandingAmount),n(),h(e.form?3:-1),n(),l("isOnPopup",!0)("isSaving",e.isSaving)("useSubmitBehavior",!1)("saveText",e.isEditMode?"common_save":"collect_deposit")}}var Ae=(()=>{class t{constructor(){this.formatMessage=d,this.entityCreatedService=x(Pi),this.isVisiblePopup=!1,this.deposit=null,this.popupClose=new ln,this.depositChange=new ln,this.fb=x(ge),this.rentalContractService=x(F),this.rentalDepositService=x(qt),this.toastNotificationService=x(B),this.destroyRef=x(O),this.deposits=[],this.isLoading=!1,this.isSaving=!1}openEntityCreated(e){e&&this.entityCreatedService.show({config:Vi[b.RENTAL_DEPOSIT.name],entity
1Id:e,closeRoute:`/rentals/${this.rentalContract?.id}/deposits`,summary:[{label:d("contract_number"),value:this.rentalContract?.rental_number},{label:d("common_customer"),value:this.rentalContract?.user?.name}].filter(o=>!!o.value)})}get isEditMode(){return!!this.deposit?.id}get expectedAmount(){return+this.rentalContract?.deposit_amount||0}get collectedAmount(){return Yt({deposits:this.deposits})}get outstandingAmount(){return Math.max(0,this.expectedAmount-this.collectedAmount)}ngOnInit(){this.buildForm(),this.loadDeposits()}buildForm(){this.form=this.fb.group({amount:[this.deposit?.amount??0,[V.required,V.min(.01)]],payment_type_id:[this.deposit?.payment_type_id??null],comment:[this.deposit?.comment??null]})}loadDeposits(){this.isLoading=!0,this.rentalContractService.getDeposits(this.rentalContract.id).pipe(S(this.destroyRef)).subscribe({next:e=>{this.deposits=Array.isArray(e)?e:e?.data||[],this.isEditMode||this.form.patchValue({amount:this.outstandingAmount})},error:()=>{this.toastNotificationService.error(d("something_went_wrong"))}}).add(()=>{this.isLoading=!1})}collect(){if(this.form.invalid){this.form.markAllAsTouched();return}this.isSaving=!0,(this.isEditMode?this.rentalDepositService.update(Ce(Q({},this.form.value),{id:this.deposit.id})):this.rentalContractService.collectDeposit(this.rentalContract.id,this.form.value)).pipe(S(this.destroyRef)).subscribe({next:o=>{this.toastNotificationService.success(d(this.isEditMode?"notification_update_success":"collect_deposit_success")),this.depositChange.emit(),this.onClosing(),this.isEditMode||this.openEntityCreated(o?.id)},error:o=>{this.toastNotificationService.error(o?.error?.message||d("something_went_wrong"))}}).add(()=>{this.isSaving=!1})}onClosing(){this.isVisiblePopup=!1,this.popupClose.emit()}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-deposit-popup"]],inputs:{isVisiblePopup:"isVisiblePopup",rentalContract:"rentalContract",deposit:"deposit"},outputs:{popupClose:"popupClose",depositChange:"depositChange"},decls:2,vars:10,consts:[["appPhoneMode","","id","rental-deposit-popup",3,"onHidden","visibleChange","visible","dragEnabled","height","maxHeight","maxWidth","showCloseButton","showTitle","title","width"],["class","d-flex flex-column h-100",4,"dxTemplate","dxTemplateOf"],[1,"d-flex","flex-column","h-100"],[1,"flex-grow-1","min-height-0"],[3,"boxed","collected","expected","outstanding"],["id","rental-deposit-form",1,"row",3,"formGroup"],["cancelBtnId","rental-deposit-popup-cancel","saveBtnId","rental-deposit-popup-save",3,"cancelClick","
1saveClick","isOnPopup","isSaving","useSubmitBehavior","saveText"],["name","amount",1,"col-sm-6","col-md-6","col-lg-6",3,"errorMsg","label"],["formControlName","amount","id","rental-deposit-popup-amount",3,"format","min","showClearButton"],["name","payment_type_id",1,"col-sm-6","col-md-6","col-lg-6",3,"errorMsg","label"],["formControlName","payment_type_id",3,"allowCreate","isEditMode"],["name","comment",1,"col-sm-12","col-md-12","col-lg-12",3,"errorMsg","label"],["formControlName","comment","id","rental-deposit-popup-comment"]],template:function(o,i){o&1&&(r(0,"dx-popup",0),y("onHidden",function(){return i.onClosing()}),W("visibleChange",function(L){return G(i.isVisiblePopup,L)||(i.isVisiblePopup=L),L}),I(1,ga,5,9,"div",1),a()),o&2&&(Y("visible",i.isVisiblePopup),l("dragEnabled",!1)("height","auto")("maxHeight","90vh")("maxWidth",560)("showCloseButton",!0)("showTitle",!0)("title",i.formatMessage(i.isEditMode?"edit_deposit":"collect_deposit"))("width","95vw"),n(),l("dxTemplateOf","content"))},dependencies:[ce,se,le,ie,me,pe,Wi,de,Ee,Se,be,Ro,Ni,J,ke,et,Te,Pe,Oe,Le,ne],encapsulation:2})}}return t})();var Ea=()=>[],ba=()=>["name","device_number","serial_number","device_brand.name","device_model.name"];function Sa(t,c){if(t&1&&(r(0,"div",25)(1,"span",26),p(2),a(),r(3,"span",27),p(4),a()()),t&2){let e=s(2).$implicit,o=s();n(2),u(o.formatMessage("devices")),n(2),U("",e.items.length," \xB7 ",o.deviceNames(e))}}function Da(t,c){if(t&1&&(r(0,"div",25)(1,"span",26),p(2),a(),m(3,"app-money",19),a()),t&2){let e=s(2).$implicit,o=s();n(2),u(o.formatMessage("payment_received")),n(),l("value",e.payment_received)}}function Ia(t,c){if(t&1&&(r(0,"div",25)(1,"span",26),p(2),a(),m(3,"app-money",19),a()),t&2){let e=s(2).$implicit,o=s();n(2),u(o.formatMessage("deposit_amount")),n(),l("value",e.deposit_amount)}}function Aa(t,c){if(t&1&&(r(0,"div",25)(1,"span",26),p(2),a(),r(3,"span"),p(4),M(5,"dateFormat"),a()()),t&2){let e=s(2).$implicit,o=s();n(2),u(o.formatMessage("contract_start_on")),n(2),u(N(5,2,e.start_date,"dateOnly"))}}function Ra(t,c){if(t&1&&(r(0,"div",25)(1,"span",26),p(2),a(),r(3,"span"),p(4),M(5,"dateFormat"),a()()),t&2){let e=s(2).$implicit,o=s();n(2),u(o.formatMessage("contract_ends_at")),n(2),u(N(5,2,e.end_date,"dateOnly"))}}function wa(t,c){if(t&1&&(r(0,"div",25)(1,"span",26),p(2),a(),r(3,"span",27),p(4),a()()),t&2){let e=s(2).$implicit,o=s();n(2),u(o.formatMessage("renewal_type")),n(2),u(e.renewal_type)}}function Ma(t,c){if(t&1){let e=T();m(0,"hr",16),r(1,"div",24)(2,"div",25)(3,"span",26),p(4),a(),r(5,"app-inline-edit-field",8),y("changed",function(){v(e);let i=s(2);return C(i.dataGrid.getData())}),r(6,"span",27),p(7),a()()(),f(8,Sa,5,3,"div",25),f(9,Da,4,2,"div",25),f(10,Ia,4,2,"div",25),f(11,Aa,6,5,"div",25),f(12,Ra,6,5,"div",25),f(13,wa,5,2,"div",25),a(),m(14,"app-card-details",28)}if(t&2){let e=s().$implicit,o=s();n(4),u(o.formatMessage("common_assignee")),n(),l("field",o.inlineAssigneeField)("record",e),n(2),u((e.assigned_user==null?null:e.assigned_user.name)??o.formatMessage("select_assignee_placeholder")),n(),h(e.items!=null&&e.items.length?8:-1),n(),h(e.payment_received!=null?9:-1),n(),h(e.deposit_amount!=null?10:-1),n(),h(e.start_date?11:-1),n(),h(e.end_date?12:-1),n(),h(e.renewal_type?13:-1),n(),l("sections",o.contractDetailSections(e))}}function Na(t,c){if(t&1){let e=T();r(0,"div",5)(1,"div",6)(2,"span",7),p(3),a(),r(4,"app-inline-edit-field",8),y("changed",function(){v(e);let i=s();return C(i.dataGrid.getData())}),m(5,"app-status-badge",9),a()(),r(6,"div",10),m(7,"app-user-badge",11),r(8,"div",12)(9,"div",13),p(10),a(),r(11,"div",14),p(12),a()(),m(13,"app-contact-actions",15),a(),m(14,"hr",16),r(15,"div",14),p(16),M(17,"dateFormat"),a(),f(18,Ma,15,11),r(19,"div",17),y("click",function(i){return i.stopPropagation()}),r(20,"span",18),m(21,"app-money",19),a(),m(22,"app-status-badge",20),r(23,"app-card-expand-button",21),y("toggle",function(){let i=v(e).$implicit,_=s();return C(_.expanded.toggle(i.id))}),a(),r(24,"app-context-menu",22),y("contextMenuItemCancelClick",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())})("contextMenuItemClick",function(i){v(e);let _=s();return C(_.onContextMenuItemClick(i))}),r(25,"app-sheet-header",23),m(26,"app-status-badge",9),a()()()()}if(t&2){let e=c.$implicit,o=s();n(3),u(e.rental_number),n(),l("field",o.inlineStatusField)("record",e),n(),l("status",e.status),n(2),l("entity",o.ENTITIES.CUSTOMER)("iconOnly",!0)("isClickable",!1)("user",e.user),n(3),u(e.user==null?null:e.user.name),n(2),u(e.payment_frequency),n(),l("entity
1Id",e.id)("entityType",o.ENTITIES.RENTAL_CONTRACT.name)("user",e.user),n(3),u(N(17,28,e.next_billing_date,"dateOnly")),n(2),h(o.expanded.has(e.id)?18:-1),n(3),l("value",e.total_amount),n(),l("status",e.payment_status),n(),l("expanded",o.expanded.has(e.id)),n(),l("contextMenuItems",o.contractContextMenu)("entityName",o.entity.name)("entity",e)("mobileSheet",!0)("showDocuments",!0),n(),l("entity",o.ENTITIES.CUSTOMER)("subtitle",e.rental_number)("title",e.user==null?null:e.user.name)("user",e.user),n(),l("status",e.status)}}function Va(t,c){if(t&1){let e=T();r(0,"app-unified-payment-modal",29),y("paymentClose",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())})("paymentSuccess",function(i){v(e);let _=s();return C(_.onPaymentSuccess(i))}),a()}if(t&2){let e=s();l("isVisiblePopup",e.isVisibleUnifiedPaymentModal)("entity",e.selectedContract)("entityType",e.ENTITIES.RENTAL_CONTRACT.name)}}function Pa(t,c){if(t&1&&(r(0,"div")(1,"div",41)(2,"span"),p(3),a(),m(4,"div",42),a()()),t&2){let e=c.$implicit;n(3),U("",e.name,"",e.device_number?" \xB7 "+e.device_number:"")}}function La(t,c){if(t&1&&(r(0,"div"),m(1,"app-rental-device-option",43),a()),t&2){let e=c.$implicit;n(),l("device",e)}}function Oa(t,c){if(t&1){let e=T();r(0,"app-control-container",37)(1,"dx-tag-box",39),W("valueChange",function(i){v(e);let _=s(3);return G(_.selectedDeviceIds,i)||(_.selectedDeviceIds=i),C(i)}),I(2,Pa,5,2,"div",40)(3,La,2,1,"div",40),a()()}if(t&2){let e=s(3);l("label",e.formatMessage("assign_devices")),n(),Y("value",e.selectedDeviceIds),l("items",e.availableDevices)("searchEnabled",!0)("searchExpr",P(9,ba))("showSelectionControls",!0)("placeholder",e.formatMessage("select_devices_to_assign")),n(),l("dxTemplateOf","deviceTagTemplate"),n(),l("dxTemplateOf","deviceItemTemplate")}}function ka(t,c){if(t&1){let e=T();r(0,"div",32)(1,"dx-scroll-view",33)(2,"p",34),p(3),r(4,"strong"),p(5),a(),p(6,". "),a(),r(7,"app-control-container",35)(8,"dx-select-box",36),W("valueChange",function(i){v(e);let _=s(2);return G(_.selectedStatusValue,i)||(_.selectedStatusValue=i),C(i)}),a()(),f(9,Oa,4,10,"app-control-container",37),a(),r(10,"app-save-cancel-footer",38),y("cancelClick",function(){v(e);let i=s(2);return C(i.onCloseContextMenuOption())})("saveClick",function(){v(e);let i=s(2);return C(i.doUpdateStatus())}),a()()}if(t&2){let e=s(2);n(3),R(" ",e.formatMessage("update_status_description")," "),n(2),u(e.selectedContract==null?null:e.selectedContract.rental_number),n(2),l("label",e.formatMessage("common_status")),n(),Y("value",e.selectedStatusValue),l("items",e.allowedStatusList)("displayExpr",e.statusLabel),n(),h(e.showDevicePicker?9:-1),n(),l("isSaving",e.isSaving)("isOnPopup",!0)}}function Fa(t,c){if(t&1){let e=T();r(0,"dx-popup",30),W("visibleChange",function(i){v(e);let _=s();return G(_.isVisibleStatusUpdatePopup,i)||(_.isVisibleStatusUpdatePopup=i),C(i)}),y("onHidden",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())}),I(1,ka,11,9,"div",31),a()}if(t&2){let e=s();Y("visible",e.isVisibleStatusUpdatePopup),l("width","95vw")("maxWidth",480)("maxHeight","90vh")("showTitle",!0)("title",e.formatMessage("update_rental_status"))("dragEnabled",!1)("showCloseButton",!0),n(),l("dxTemplateOf","content")}}function Ba(t,c){if(t&1){let e=T();r(0,"app-rental-deposit-popup",44),y("depositChange",function(){v(e);let i=s();return C(i.dataGrid==null?null:i.dataGrid.getData())})("popupClose",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())}),a()}if(t&2){let e=s();l("isVisiblePopup",e.isVisibleDepositPopup)("rentalContract",e.selectedContract)}}var Hi=(()=>{class t{get isMobileDevice(){return this.userDeviceService.isMobileDevice()}get allowedStatusList(){return Jt(this.selectedContract?.status)}get showDevicePicker(){return pn(this.selectedContract,this.selectedStatusValue)}get hasTenantRentalContracts(){return this.isEmployee?(this.tenantService.config()?.entity_counts?.rental_contracts||0)>0:!0}constructor(e){this.service=e,this.SETTINGS_SURFACES=Io,this.formatMessage=d,this.statusLabel=lt,this.ENTITIES=b,this.router=x(Je),this.userSessionService=x(k),this.tenantService=x(wt),this.userDeviceService=x(K),this.isEmployee=this.userSessionService.isEmployee(),this.isAdmin=this.userSessionService.isAdmin(),this.userPermissionList=this.userSessionService.userPermissionList(),this.toastNotificationService=x(B),this.rentalDeviceService=x(Ie),this.destroyRef=x(O),this.expanded=new jt,this.detailSectionsCache=new WeakMap,this.currentContextMenuAction=null,this.isVisibleUnifiedPaymentModal=!1,this.isVisibleStatusUpdatePopup=!1,this.isVisibleDepositPopup=!1,this.selectedContract=null,this.contractContextMenu=[],this.entity=b.RENTAL_CONTRACT,this.selectedStatusValue=null,this.isSaving=!1,this.availableDevices=[],this.selectedDeviceIds=[],this.employeeService=x(Gn),this.canWriteRental=this.userPermissionList.includes(g.RENTAL_CONTRACT_WRITE),this.inlineStatusField={key:"status",kind:"status",title:"common_status",options:()=>ai(Do(Object.values(A))),filterOptions:(o,i)=>{let _=Jt(o?.status);return i.filter(L=>
1_.includes(L.id))},valueOf:o=>o?.status??null,save:(o,i)=>pn(o,i)?(this.openStatusPopup(o,i),null):this.service.updateStatus(o.id,i),canEdit:o=>this.canWriteRental&&Jt(o?.status).length>0},this.inlineAssigneeField={key:"assigned_user",kind:"assignee",title:"common_assignee",options:()=>So(this.employeeService),valueOf:o=>o?.assignee_id??null,save:(o,i)=>this.service.updateAssignee(o.id,i),canEdit:()=>this.canWriteRental},this.inlineEdit=[this.inlineStatusField,this.inlineAssigneeField],this.columns=[{dataField:"rental_number",allowSorting:!0,caption:d("contracts"),width:this.isMobileDevice?90:130,alignment:"center",cellTemplate:"idLinkTemplate"},{dataField:"user",caption:d("common_customer"),width:130,allowSorting:!1,cellTemplate:"userTemplate"},{dataField:"assigned_user",caption:d("common_assignee"),allowSorting:!1,alignment:"center",cellTemplate:"employeeTemplate",width:130},{dataField:"status",caption:d("common_status"),allowSorting:!0,cellTemplate:"statusTemplate",alignment:"center",width:110},{dataField:"payment_status",caption:d("payment_status"),allowSorting:!0,cellTemplate:"statusTemplate",alignment:"center",width:110},{dataField:"payment_frequency",caption:d("payment_frequency"),allowSorting:!1,alignment:"center"},{dataField:"start_date",caption:d("contract_start_on"),cellTemplate:"dateTemplate",allowSorting:!0,alignment:"center"},{dataField:"end_date",caption:d("contract_ends_at"),cellTemplate:"dateTemplate",allowSorting:!0,alignment:"center"},{dataField:"next_billing_date",caption:d("next_billing_date"),cellTemplate:"dateTemplate",allowSorting:!0,alignment:"center"},{dataField:"total_amount",caption:d("common_total_amount"),dataType:"number",allowSorting:!0,alignment:"center",cellTemplate:"currencyTemplate",format:{type:"fixedPoint",precision:2}},{dataField:"payment_received",caption:d("payment_received"),allowSorting:!1,alignment:"center",visible:!1,cellTemplate:"currencyTemplate",format:{type:"fixedPoint",precision:2}},{name:"actions",caption:"",alignment:"center",cssClass:"custom-action",cellTemplate:"actionTemplate",allowExporting:!1,allowSorting:!1,showInColumnChooser:!1}],this.RENTAL_CONTRACT_CONTEXT_MENU_LIST=q}ngOnInit(){this.contractContextMenu=[{name:q.ADD_PAYMENT,icon:$e.PAYMENT.light,visible:this.isEmployee&&this.userPermissionList.includes(g.PAYMENT_WRITE),isDisabled:e=>e?.status===A.CANCELLED,locale_key:d("common_add_payment")},{name:q.UPDATE_STATUS,icon:ot.CIRCLE.light,visible:this.isEmployee&&this.userPermissionList.includes(g.RENTAL_CONTRACT_WRITE),isDisabled:e=>!Jt(e?.status).length,locale_key:d("update_rental_status")},{name:q.RENEW,icon:Z.RENEW.light,visible:this.isEmployee&&this.userPermissionList.includes(g.RENTAL_CONTRACT_WRITE),isDisabled:e=>e?.status===A.CANCELLED,locale_key:d("renew_contract")},{name:q.DEPOSITS,icon:Z.DEPOSIT.light,visible:this.isEmployee&&this.userPermissionList.includes(g.RENTAL_CONTRACT_WRITE),isDisabled:e=>e?.status===A.CANCELLED,locale_key:d("collect_deposit")}]}deviceNames(e){return(e.items||[]).map(o=>o.rental_device?.name||o.device_name_snapshot).filter(Boolean).join(", ")}contractDetailSections(e){let o=this.detailSectionsCache.get(e);if(o)return o;let i=[{titleKey:"contract_details",rows:[{labelKey:"common_renewals",value:e.renew_count||null},{labelKey:"common_created_on",value:e.created_at,type:"datetime"},{labelKey:"common_updated_on",value:e.updated_at,type:"datetime"}]},{titleKey:"common_custom_fields",rows:Mt.toArray(e.custom_fields).map(_=>({label:_.label,value:_.field_value}))}];return this.detailSectionsCache.set(e,i),i}onContextMenuItemClick(e){this.currentContextMenuAction=e.action,this.selectedContract=e.entity,this.currentContextMenuAction===q.ADD_PAYMENT?this.isVisibleUnifiedPaymentModal=!0:this.currentContextMenuAction===q.UPDATE_STATUS?(this.selectedStatusValue=null,this.selectedDeviceIds=[],this.availableDevices=[],this.selectedContract.status===A.DRAFT&&this.loadAvailableDevices(),this.isVisibleStatusUpdatePopup=!0):this.currentContextMenuAction===q.RENEW?this.router.navigate(["/rentals/add"],{queryParams:{renewFrom:this.selectedContract.id}}):this.currentContextMenuAction===q.DEPOSITS&&(this.isVisibleDepositPopup=!0)}openStatusPopup(e,o){this.selectedContract=e,this.selectedStatusValue=o,this.selectedDeviceIds=[],this.availableDevices=[],this.loadAvailableDevices(),this.isVisibleStatusUpdatePopup=!0}loadAvailableDevices(){this.rentalDeviceService.getListByQuery({}).pipe(S(this.destroyRef)).subscribe({next:e=>{let o=Array.isArray(e)?e:e?.data||[];this.availableDevices=o.filter(i=>i.rental_status?.toLowerCase()===z.AVAILABLE)},error:()=>{this.toastNotificationService.error(d("something_went_wrong"))}})}doUpdateStatus(){if(!this.selectedStatusValue)return;this.isSaving=!0;let e=this.showDevicePicker&&this.selectedDeviceIds.length>0?this.selectedDeviceIds.map(o=>{let i=this.availableDevices.find(_=>_.id===o);return{rental_device_id:o,unit_price:i?.rental_rate_monthly??0}}):void 0;this.service.updateStatus(this.selectedContract.id,this.selectedStatusValue,e).subscribe({next:()=>{this.toastNotificationService.success(d("status_update_success")),this.isVisibleStatusUpdatePopup=!1,this.dataGrid?.getData()},error:()=>{this.toastNotificationService.error(d("status_update_error"))}}).add(()=>{this.isSaving=!1})}onCloseContextMenuOption(){this.currentContextMenuAction=null,this.isVisibleUnifiedPaymentModal=!1,this.isVisibleStatusUpdatePopup=!1,this.isVisibleDepositPopup=!1,this.availableDevices=[],this.selectedDeviceIds=[]}create(){this.router.navigate(["/rentals/add"])}onPaymentSuccess(e){this.dataGrid.getData(),this.onCloseContextMenuOption()}static{this.\u0275fac=function(o){return new(o||t)(X(F))}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-contract-list"]],viewQuery:function(o,i){if(o&1&&fe(ee,5),o&2){let _;he(_=xe())&&(i.dataGrid=_.first)}},decls:5,vars:16,consts:[[3,"contextMenuItemCancelClick","contextMenuItemClick","dataGridAddNewClick","settingsSurface","columns","contextMenuItems","dataGridId","entity","hasTenantData","isVisibleDeleteAction","isVisibleEditAction","isVisibleExportAction","searchPanelPlaceholderText","service","inline
1Edit"],["appCardTemplate",""],[3,"isVisiblePopup","entity","entityType"],["appPhoneMode","",3,"visible","width","maxWidth","maxHeight","showTitle","title","dragEnabled","showCloseButton"],[3,"isVisiblePopup","rentalContract"],[1,"app-card"],[1,"d-flex","align-items-center","justify-content-between","gap-2","mb-2"],[1,"fs-label","text-muted"],[3,"changed","field","record"],["kind","rental",3,"status"],[1,"d-flex","align-items-start","gap-2"],[3,"entity","iconOnly","isClickable","user"],[1,"flex-grow-1","min-width-0"],[1,"fs-subsection","fw-bold","text-truncate"],[1,"fs-label","text-muted","text-truncate"],[3,"entityId","entityType","user"],[1,"my-2"],[1,"d-flex","align-items-center","gap-2","mt-1",3,"click"],[1,"fs-label","fw-bold"],[3,"value"],["kind","rental","variant","outline",3,"status"],[1,"ms-auto",3,"toggle","expanded"],[3,"contextMenuItemCancelClick","contextMenuItemClick","contextMenuItems","entityName","entity","mobileSheet","showDocuments"],[3,"entity","subtitle","title","user"],[1,"d-flex","flex-column","gap-2"],[1,"d-flex","align-items-center","justify-content-between","gap-2","fs-body-sm"],[1,"text-muted","text-truncate"],[1,"text-truncate"],[3,"sections"],[3,"paymentClose","paymentSuccess","isVisiblePopup","entity","entityType"],["appPhoneMode","",3,"visibleChange","onHidden","visible","width","maxWidth","maxHeight","showTitle","title","dragEnabled","showCloseButton"],["class","d-flex flex-column h-100",4,"dxTemplate","dxTemplateOf"],[1,"d-flex","flex-column","h-100"],[1,"flex-grow-1","min-height-0"],[1,"text-muted","mb-3"],["name","status",3,"label"],["stylingMode","outlined",3,"valueChange","value","items","displayExpr"],["name","device_ids",1,"mt-3",3,"label"],[3,"cancelClick","
1saveClick","isSaving","isOnPopup"],["displayExpr","name","valueExpr","id","searchMode","contains","itemTemplate","deviceItemTemplate","tagTemplate","deviceTagTemplate",3,"valueChange","value","items","searchEnabled","searchExpr","showSelectionControls","placeholder"],[4,"dxTemplate","dxTemplateOf"],[1,"dx-tag-content"],[1,"dx-tag-remove-button"],[3,"device"],[3,"depositChange","popupClose","isVisiblePopup","rentalContract"]],template:function(o,i){o&1&&(r(0,"app-data-grid",0),y("contextMenuItemCancelClick",function(){return i.onCloseContextMenuOption()})("contextMenuItemClick",function(L){return i.onContextMenuItemClick(L)})("dataGridAddNewClick",function(){return i.create()}),I(1,Na,27,31,"ng-template",1),a(),f(2,Va,1,3,"app-unified-payment-modal",2),f(3,Fa,2,9,"dx-popup",3),f(4,Ba,1,2,"app-rental-deposit-popup",4)),o&2&&(l("settingsSurface",i.SETTINGS_SURFACES.RENTAL)("columns",i.columns)("contextMenuItems",i.contractContextMenu)("dataGridId","rentalContractGrid")("entity",i.entity)("hasTenantData",i.hasTenantRentalContracts)("isVisibleDeleteAction",!1)("isVisibleEditAction",!1)("isVisibleExportAction",!0)("searchPanelPlaceholderText","search_panel_rental_contracts_placeholder")("service",i.service)("inlineEdit",i.canWriteRental?i.inlineEdit:P(15,Ea)),n(2),h(i.selectedContract!=null&&i.selectedContract.id&&i.isVisibleUnifiedPaymentModal?2:-1),n(),h(i.isVisibleStatusUpdatePopup&&(i.selectedContract!=null&&i.selectedContract.id)?3:-1),n(),h(i.isVisibleDepositPopup&&(i.selectedContract!=null&&i.selectedContract.id)?4:-1))},dependencies:[ce,ee,_e,Gt,ki,H,gi,Ti,De,Ue,Li,se,le,ie,me,pe,de,re,ae,rt,at,Ye,J,Ae,ne,j,Be,Wo,oe],encapsulation:2})}}return t})();var Qe=class{constructor(c){return Object.assign(this,c)}static getForm(c){return new ge().group({id:[c.id||null],name:[c.name||null,[V.required]],device_brand_id:[c.device_brand_id||null],device_model_id:[c.device_model_id||null],serial_number:[c.serial_number||null],barcode_number:[c.barcode_number||null],tags:[(c.tags||[]).map(e=>typeof e=="string"?e:e.tag_name)],rental_rate_monthly:[c.rental_rate_monthly??0,[V.required,V.min(0)]],rental_deposit:[c.rental_deposit??0,[V.min(0)]],rental_status:[c.rental_status||z.AVAILABLE],storage_location_id:[c.storage_location_id||null],accessories:[c.accessories?.map(e=>e.id)||[]],comment:[c.latest_note?.content||null]})}};var Xo=()=>({type:"fixedPoint",precision:2}),Ya=t=>({name:t});function Ga(t,c){if(t&1&&(r(0,"app-control-container",10)(1,"dx-text-box",26),m(2,"dxi-button",27),a()()),t&2){let e=s(2);l("label",e.formatMessage("inventory_barcode_number_label")),n(),l("placeholder",e.formatMessage("inventory_barcode_number_placeholder")),n(),l("options",e.barcodeButtonOptions)}}function Wa(t,c){if(t&1&&m(0,"dxi-button",19),t&2){let e=s(2);l("options",e.addInlineOption)}}function Ha(t,c){if(t&1&&(r(0,"app-control-container",20),m(1,"app-tag-box-with-images",28),a()),t&2){let e=s(2);l("label",e.formatMessage("accessories")),n(),l("products",e.deviceTypeAccessoriesList)("isDxiButtonActive",!0)("hasUserPermissions",e.PERMISSION_LIST.ACCESSORY_WRITE)("buttonOptions",e.addAccessoryOption)("buttonId","rental-device-accessory")("buttonName","accessory")("isReadOnly",!e.form.get("name").value)("placeholder","device_accessories_placeholder")("imageCategory","accessory")}}function ja(t,c){if(t&1){let e=T();r(0,"app-control-container",21)(1,"dx-tag-box",29),y("onCustomItemCreating",function(i){v(e);let _=s(2);return C(_.createTag(i))}),a()()}if(t&2){let e=s(2);l("label",e.formatMessage("tags_label")),n(),l("items",e.tags)("acceptCustomValue",!0)("placeholder",e.formatMessage("tag_placeholder"))}}function qa(t,c){if(t&1&&(r(0,"app-control-container",22),m(1,"app-textarea",30),a()),t&2){let e=s(2);l("label",e.formatMessage("common_comment")),n(),l("formControl",e.form.controls.comment)("isEditMode",!0)}}function $a(t,c){if(t&1){let e=T();r(0,"app-device-brand",31),y("cancelClick",function(){v(e);let i=s(2);return C(i.isVisibleDeviceBrandPopup=!1)})("saveClick",function(i){v(e);let _=s(2);return C(_.onAddDeviceBrand(i))}),a()}if(t&2){let e=s(2);l("model",e.deviceBrand)("isCreate",!0)("isVisiblePopup",e.isVisibleDeviceBrandPopup)}}function Qa(t,c){if(t&1){let e=T();r(0,"app-device-model-popup",32),y("cancelClick",function(){v(e);let i=s(2);return C(i.isVisibleDeviceModelPopup=!1)})("saveClick",function(i){v(e);let _=s(2);return C(_.onAddDeviceModel(i))}),a()}if(t&2){let e=s(2);l("model",e.deviceModel)("isAddingFromJob",!!e.currentDeviceTypeId())("isCreate",!0)("isVisiblePopup",e.isVisibleDeviceModelPopup)}}function Ka(t,c){if(t&1){let e=T();r(0,"app-barcode",33),y("saveBarcodeNumber",function(i){v(e);let _=s(2);return C(_.addBarcodeNumber(i))})("scannerToClose",function(){v(e);let i=s(2);return C(i.isVisibleBarcodePopUp=!1)}),a()}if(t&2){let e=s(2);l("isViewBarcode",e.barcodeExists)("isVisiblePopup",e.isVisibleBarcodePopUp)("oldBarcodeNumber",e.form.get("barcode_number").value)("part",ye(4,Ya,e.form.get("name").value))}}function za(t,c){if(t&1){let e=T();r(0,"app-accessory",31),y("cancelClick",function(){v(e);let i=s(2);return C(i.isVisibleAccessoryPopUp=!1)})("saveClick",function(i){v(e);let _=s(2);return C(_.onAddAccessory(i))}),a()}if(t&2){let e=s(2);l("model",e.accessory)("isCreate",!0)("isVisiblePopup",e.isVisibleAccessoryPopUp)}}function Xa(t,c){if(t&1){let e=T();r(0,"div",0)(1,"div",1)(2,"app-control-container",2)(3,"dx-select-box",3),y("onValueChanged",function(){v(e);let i=s();return C(i.onDeviceTypeChange())}),a()(),r(4,"app-control-container",4)(5,"app-select-box-with-images",5),y("onChangeValue",function(){v(e);let i=s();return C(i.onBrandChange())}),a()(),r(6,"app-control-container",6),m(7,"app-select-box-with-images",7),a(),r(8,"app-control-container",8),m(9,"dx-text-box",9),a(),f(10,Ga,3,3,"app-control-container",10),r(11,"app-control-container",11),m(12,"dx-number-box",12),a(),r(13,"app-control-container",13),m(14,"dx-number-box",14),a(),r(15,"app-control-container",15),m(16,"dx-select-box",16),a(),r(17,"app-control-container",17)(18,"dx-select-box",18),f(19,Wa,1,1,"dxi-button",19),a()(),f(20,Ha,2,10,"app-control-container",20),f(21,ja,2,4,"app-control-container",21),f(22,qa,2,3,"app-control-container",22),a()(),f(23,$a,1,3,"app-device-brand",23),f(24,Qa,1,4,"app-device-model-popup",24),f(25,Ka,1,6,"app-barcode",25),f(26,za,1,3,"app-accessory",23)}if(t&2){let e=s();l("formGroup",e.form),n(2),l("label",e.formatMessage("device_type"))("errorMsg",e.formatMessage("device_type_required_error")),n(),l("items",e.deviceTypes)("searchEnabled",!0)("acceptCustomValue",!0)("placeholder",e.formatMessage("select_device_type"))("isValid",e.form.get("name").valid||!e.form.get("name").touched),n(),l("label",e.formatMessage("device_brand_name")),n(),l("dataSource",e.deviceBrandList)("isDxiButtonActive",!0)("hasUserPermissions",e.PERMISSION_LIST.DEVICE_BRAND_WRITE)("buttonOptions",e.addDeviceBrandOption)("buttonId","rental-device-brand")("buttonName","deviceBrand")("imageCategory","device-brand")("placeholder","device_brand_placeholder"),n(),l("label",e.formatMessage("device_model")),n(),l("dataSource",e.deviceModelList)("isDxiButtonActive",!0)("hasUserPermissions",e.PERMISSION_LIST.DEVICE_MODEL_WRITE)("buttonOptions",e.addDeviceModelOption)("buttonId","rental-device-model")("buttonName","deviceModel")("imageCategory","device-model")("placeholder","device_model_placeholder")("isDisabled",!e.form.get("device_brand_id").value)("isReadOnly",!e.form.get("device_brand_id").value),n(),l("label",e.formatMessage("serial_number")),n(),l("placeholder",e.formatMessage("serial_number_placeholder")),n(),h(e.form.get("barcode_number")?10:-1),n(),l("label",e.formatMessage("monthly_rent"))("errorMsg",e.formatMessage("monthly_rent_required"))("tooltipText","rental_device_monthly_rent_help"),n(),l("min",0)("format",P(58,Xo))("isValid",e.form.get("rental_rate_monthly").valid||!e.form.get("rental_rate_monthly").touched),n(),l("label",e.formatMessage("security_deposit"))("tooltipText","rental_device_deposit_help"),n(),l("min",0)("format",P(59,Xo)),n(),l("label",e.formatMessage("common_status"))("tooltipText","rental_device_status_help"),n(),l("items",e.DEVICE_STATUS_LIST),n(),l("label",e.formatMessage("device_storage_location")),n(),l("noDataText",e.formatMessage("common_no_options_add_new"))("items",e.storageLocations)("searchEnabled",!0)("showClearButton",!0)("placeholder",e.formatMessage("device_storage_location_placeholder")),n(),h(e.canInlineCreate(e.ENTITIES.STORAGE_LOCATION.name)?19:-1),n(),h(e.form.get("accessories")?20:-1),n(),h(e.form.get("tags")?21:-1),n(),h(e.form.get("comment")?22:-1),n(),h(e.isVisibleDeviceBrandPopup?23:-1),n(),h(e.isVisibleDeviceModelPopup?24:-1),n(),h(e.isVisibleBarcodePopUp?25:-1),n(),h(e.isVisibleAccessoryPopUp?26:-1)}}var Ge=(()=>{class t{constructor(){this.ENTITIES=b,this.inlineCreateService=x(go),this.addInlineOption=this.inl
1ineCreateService.buttonOptions({entity:b.STORAGE_LOCATION.name,onCreated:e=>{this.storageLocations=[e,...this.storageLocations??[]],this.form?.patchValue({storage_location_id:e.id})}}),this.formatMessage=d,this.PERMISSION_LIST=g,this.deviceTypeService=x(Xn),this.dataService=x(io),this.destroyRef=x(O),this.deviceTypes=[],this.storageLocations=[],this.tags=[],this.allDeviceBrandList=[],this.deviceBrandList=[],this.allDeviceModelList=[],this.deviceModelList=[],this.accessoriesList=[],this.deviceTypeAccessoriesList=[],this.isVisibleAccessoryPopUp=!1,this.isVisibleDeviceBrandPopup=!1,this.isVisibleDeviceModelPopup=!1,this.isVisibleBarcodePopUp=!1,this.barcodeButtonOptions={icon:ot.BARCODE_READ.light,type:"default",stylingMode:"text",hint:d("common_barcode"),elementAttr:{"aria-label":d("common_barcode")},onClick:()=>{this.isVisibleBarcodePopUp=!0}},this.DEVICE_STATUS_LIST=[{value:z.AVAILABLE,label:d("available")},{value:z.ON_RENT,label:d("on_rent")},{value:z.UNDER_REPAIR,label:d("under_repair")},{value:z.RETIRED,label:d("retired")}]}canInlineCreate(e){return this.inlineCreateService.canCreate(e)}ngOnInit(){this.addAccessoryOption={icon:"add",type:"default",stylingMode:"text",hint:d("add_device_accessory_label"),onClick:()=>{this.accessory=new wo({device_type_id:this.currentDeviceTypeId()}),this.isVisibleAccessoryPopUp=!0}},this.addDeviceBrandOption={icon:"add",type:"default",stylingMode:"text",hint:d("device_brand_add_new_device_brand"),onClick:()=>{this.deviceBrand=new No({device_type_id:this.currentDeviceTypeId()}),this.isVisibleDeviceBrandPopup=!0}},this.addDeviceModelOption={icon:"add",type:"default",stylingMode:"text",hint:d("device_model_add_new_device_model"),onClick:()=>{this.deviceModel=new Po({device_brand_id:this.form?.get("device_brand_id")?.value,device_type_id:this.currentDeviceTypeId()}),this.isVisibleDeviceModelPopup=!0}},this.loadLookups()}ngOnChanges(e){e.form&&!e.form.firstChange&&this.applyTypeFilter()}loadLookups(){this.deviceTypeService.getList().pipe(S(this.destroyRef)).subscribe({next:e=>{this.deviceTypes=Array.isArray(e)?e:[],this.applyTypeFilter()},error:()=>{}}),this.dataService.getLookups().pipe(S(this.destroyRef)).subscribe({next:e=>{this.storageLocations=e.storage_locations||[],this.allDeviceBrandList=e.device_brands||[],this.allDeviceModelList=e.device_models||[],this.accessoriesList=e.accessories||[],this.tags=(e.tags||[]).filter(o=>o.type===b.RENTAL_DEVICE.name).map(o=>o.tag_name),this.applyTypeFilter()},error:()=>{}})}applyTypeFilter(){if(!this.form){this.deviceBrandList=this.allDeviceBrandList,this.deviceModelList=this.allDeviceModelList,this.deviceTypeAccessoriesList=[];return}let e=this.deviceTypes.find(i=>i.name===this.form.get("name")?.value);this.deviceBrandList=e?this.allDeviceBrandList.filter(i=>i.device_type_id===e.id):this.allDeviceBrandList;let o=this.form.get("device_brand_id")?.value;this.deviceModelList=o?this.allDeviceModelList.filter(i=>i.device_brand_id===o&&(!e||i.device_type_id===e.id)):this.allDeviceModelList,this.deviceTypeAccessoriesList=e?this.accessoriesList.filter(i=>i.device_type_id===e.id):[]}createTag(e){e.customItem=e.text,this.tags.unshift(e.text)}get barcodeExists(){return!!this.form?.get("barcode_number")?.value}addBarcodeNumber(e){this.form?.patchValue({barcode_number:e}),this.isVisibleBarcodePopUp=!1}currentDeviceTypeId(){return this.deviceTypes.find(e=>e.name===this.form?.get("name")?.value)?.id??null}onDeviceTypeChange(){let e=this.deviceTypes.find(i=>i.name===this.form?.get("name")?.value);this.deviceBrandList=e?this.allDeviceBrandList.filter(i=>i.device_type_id===e.id):this.allDeviceBrandList,this.deviceTypeAccessoriesList=e?this.accessoriesList.filter(i=>i.device_type_id===e.id):[];let o=this.form?.get("device_brand_id")?.value;if(o&&this.deviceBrandList.some(i=>i.id===o)){this.onBrandChange();return}this.deviceModelList=[],this.form?.patchValue(Q({device_brand_id:null,device_model_id:null},this.form.get("accessories")?{accessories:[]}:{}))}onBrandChange(){let e=this.form?.get("device_brand_id")?.value,o=this.deviceTypes.find(_=>_.name===this.form?.get("name")?.value);this.deviceModelList=e?this.allDeviceModelList.filter(_=>_.device_brand_id===e&&(!o||_.device_type_id===o.id)):this.allDeviceModelList;let i=this.form?.get("device_model_id")?.value;i&&this.deviceModelList.some(_=>_.id===i)||this.form?.patchValue({device_model_id:null})}onAddDeviceBrand(e){this.isVisibleDeviceBrandPopup=!1,this.allDeviceBrandList=[...this.allDeviceBrandList,e],this.deviceBrandList=[...this.deviceBrandList,e],this.form?.patchValue({device_brand_id:e.id}),this.onBrandChange()}onAddDeviceModel(e){this.isVisibleDeviceModelPopup=!1,this.allDeviceModelList=[...this.allDeviceModelList,e],this.deviceModelList=[...this.deviceModelList,e],this.form?.patchValue({device_model_id:e.id})}onAddAccessory(e){this.isVisibleAccessoryPopUp=!1,this.accessoriesList=[...this.accessoriesList,e],this.deviceTypeAccessoriesList=[...this.deviceTypeAccessoriesList,e];let o=this.form?.get("accessories")?.value||[];this.form?.patchValue({accessories:[...o,e.id]})}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-device-form"]],inputs:{form:"form"},features:[Tt],decls:1,vars:1,consts:[[3,"formGroup"],[1,"row"],["name","name",1,"col-12",3,"label","errorMsg"],["formControlName","name","displayExpr","name","valueExpr","name","stylingMode","outlined",3,"onValueChanged","items","searchEnabled","acceptCustomValue","placeholder","isValid"],["name","device_brand_id",1,"col-sm-6",3,"label"],["formControlName","device_brand_id",3,"onChangeValue","dataSource","isDxiButtonActive","hasUserPermissions","buttonOptions","buttonId","buttonName","imageCategory","placeholder"],["name","device_model_id",1,"col-sm-6",3,"label"],["formControlName","device_model_id",3,"dataSource","isDxiButtonActive","hasUserPermissions","buttonOptions","buttonId","buttonName","imageCategory","placeholder","isDisabled","isReadOnly"],["name","serial_number",1,"col-sm-6",3,"label"],["formControlName","serial_number","stylingMode","outlined",3,"placeholder"],["name","barcode_number",1,"col-sm-6",3,"label"],["name","rental_rate_monthly",1,"col-sm-6",3,"label","errorMsg","tooltipText"],["formControlName","rental_rate_monthly","stylingMode","outlined",3,"min","format","isValid"],["name","rental_deposit",1,"col-sm-6",3,"label","tooltipText"],["formControlName","rental_deposit","stylingMode","outlined",3,"min","format"],["name","rental_status",1,"col-sm-6",3,"label","tooltipText"],["formControlName","rental_status","displayExpr","label","valueExpr","value","stylingMode","outlined",3,"items"],["name","storage_location_id",1,"col-sm-6",3,"label"],["formControlName","storage_location_id","displayExpr","name","valueExpr","id","stylingMode","outlined",3,"noDataText","items","searchEnabled","showClearButton","placeholder"],["location","after","name","inlineCreate",3,"options"],["name","accessories",1,"col-sm-6",3,"label"],["name","tags",1,"col-12",3,"label"],["name","comment",1,"col-12",3,"label"],[3,"model","isCreate","isVisiblePopup"],[3,"model","isAddingFromJob","isCreate","isVisiblePopup"],[3,"isViewBarcode","isVisiblePopup","oldBarcodeNumber","part"],["formControlName","barcode_number","stylingMode","outlined",3,"placeholder"],["name","barcode","location","after",3,"options"],["formControlName","accessories",3,"products","isDxiButtonActive","hasUserPermissions","buttonOptions","buttonId","buttonName","isReadOnly","placeholder","imageCategory"],["formControlName","tags","stylingMode","outlined",3,"onCustomItemCreating","items","acceptCustomValue","placeholder"],["placeholder","common_comment",3,"formControl","isEditMode"],[3,"cancelClick","
1saveClick","model","isCreate","isVisiblePopup"],[3,"cancelClick","saveClick","model","isAddingFromJob","isCreate","isVisiblePopup"],[3,"saveBarcodeNumber","scannerToClose","isViewBarcode","isVisiblePopup","oldBarcodeNumber","part"]],template:function(o,i){o&1&&f(0,Xa,27,60),o&2&&h(i.form?0:-1)},dependencies:[de,re,ae,vi,Eo,Kn,Qn,Ee,Se,be,rt,at,Jn,Ni,Vo,Lo,Mo,Ko,ke,Te,Pe,mi,Oe,Le],encapsulation:2})}}return t})();function Za(t,c){if(t&1&&(r(0,"div",6),p(1),a()),t&2){let e=s().$implicit;n(),Et(" ",e.device_brand==null?null:e.device_brand.name,"",e.device_brand!=null&&e.device_brand.name&&(e.device_model!=null&&e.device_model.name)?" \xB7 ":"","",e.device_model==null?null:e.device_model.name," ")}}function Ja(t,c){if(t&1&&(r(0,"div",18)(1,"span",20),p(2),a(),r(3,"span",21),p(4),a()()),t&2){let e=s(2).$implicit,o=s();n(2),u(o.formatMessage("current_contract")),n(2),U(" ",e.current_rental_contract.rental_number,"",e.current_rental_contract.user!=null&&e.current_rental_contract.user.name?" \xB7 "+(e.current_rental_contract.user==null?null:e.current_rental_contract.user.name):""," ")}}function er(t,c){if(t&1&&(r(0,"div",18)(1,"span",20),p(2),a(),r(3,"span",21),p(4),a()()),t&2){let e=s(2).$implicit,o=s();n(2),u(o.formatMessage("location")),n(2),u(e.storage_location==null?null:e.storage_location.name)}}function tr(t,c){if(t&1&&(r(0,"div",18)(1,"span",20),p(2),a(),r(3,"span",21),p(4),a()()),t&2){let e=s(2).$implicit,o=s();n(2),u(o.formatMessage("accessories")),n(2),u(o.accessoriesLabel(e))}}function ir(t,c){if(t&1&&(r(0,"div",18)(1,"span",20),p(2),a(),m(3,"span",22),M(4,"safe"),a()),t&2){let e=s(2).$implicit,o=s();n(2),u(o.formatMessage("note")),n(),l("innerHTML",N(4,2,e.latest_note==null?null:e.latest_note.content,"html"),gt)}}function nr(t,c){if(t&1&&(m(0,"hr",10),r(1,"div",17),f(2,Ja,5,3,"div",18),f(3,er,5,2,"div",18),f(4,tr,5,2,"div",18),f(5,ir,5,5,"div",18),a(),m(6,"app-card-details",19)),t&2){let e=s().$implicit,o=s();n(2),h(e.current_rental_contract?2:-1),n(),h(e.storage_location!=null&&e.storage_location.name?3:-1),n(),h(o.accessoriesLabel(e)?4:-1),n(),h(e.latest_note!=null&&e.latest_note.content?5:-1),n(),l("sections",o.deviceDetailSections(e))}}function or(t,c){if(t&1){let e=T();r(0,"div",4)(1,"div",5)(2,"span",6),p(3),a(),m(4,"app-status-badge",7),a(),r(5,"div",8)(6,"div",9),p(7),a(),f(8,Za,2,3,"div",6),a(),f(9,nr,7,5),m(10,"hr",10),r(11,"div",11),y("click",function(i){return i.stopPropagation()}),r(12,"span",6),p(13),a(),r(14,"span",12),m(15,"app-money",13),a(),r(16,"app-card-expand-button",14),y("toggle",function(){let i=v(e).$implicit,_=s();return C(_.expanded.toggle(i.id))}),a(),r(17,"app-context-menu",15),y("contextMenuItemCancelClick",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())})("contextMenuItemClick",function(i){v(e);let _=s();return C(_.onContextMenuItemClick(i))})("documentCreate",function(i){let _=v(e).$implicit,L=s();return C(L.onDocumentCreate(i,_))}),r(18,"app-sheet-header",16),m(19,"app-status-badge",7),a()()()()}if(t&2){let e=c.$implicit,o=s();n(3),u(e.device_number||e.serial_number),n(),l("status",e.rental_status),n(3),u(e.name),n(),h(e.device_brand!=null&&e.device_brand.name||e.device_model!=null&&e.device_model.name?8:-1),n(),h(o.expanded.has(e.id)?9:-1),n(4),u(o.formatMessage("monthly_rent")),n(2),l("value",e.rental_rate_monthly),n(),l("expanded",o.expanded.has(e.id)),n(),l("allowCreate",o.isEmployee)("contextMenuItems",o.deviceContextMenu)("entityName",o.entity.name)("entity",e)("mobileSheet",!0)("showDocuments",!0),n(),l("subtitle",e.device_number||e.serial_number)("title",e.name),n(),l("status",e.rental_status)}}function ar(t,c){if(t&1){let e=T();r(0,"div",25)(1,"dx-scroll-view",26),m(2,"app-rental-device-form",27),a(),r(3,"app-save-cancel-footer",28),y("saveClick",function(){v(e);let i=s(2);return C(i.saveDevice())})("cancelClick",function(){v(e);let i=s(2);return i.isAddDevicePopupVisible=!1,C(i.isEditMode=!1)}),a()()}if(t&2){let e=s(2);n(2),l("form",e.addDeviceForm),n(),l("isSaving",e.isSaving)("isOnPopup",!0)("isVisibleHr",!1)("useSubmitBehavior",!1)("saveText",e.isEditMode?"common_save":"common_create")}}function rr(t,c){if(t&1){let e=T();r(0,"dx-popup",23),W("visibleChange",function(i){v(e);let _=s();return G(_.isAddDevicePopupVisible,i)||(_.isAddDevicePopupVisible=i),C(i)}),I(1,ar,4,6,"div",24),a()}if(t&2){let e=s();Y("visible",e.isAddDevicePopupVisible),l("width",620)("maxWidth","95vw")("height","auto")("maxHeight","90vh")("showTitle",!0)("title",e.formatMessage(e.isEditMode?"edit_rental_device":"create_new_rental_device"))("dragEnabled",!1)("showCloseButton",!0),n(),l("dxTemplateOf","content")}}function lr(t,c){if(t&1){let e=T();r(0,"app-archive-delete-popup",29),W("isVisibleChange",function(i){v(e);let _=s();return G(_.isVisibleArchiveDeletePopup,i)||(_.isVisibleArchiveDeletePopup=i),C(i)}),y("onSuccess",function(){v(e);let i=s();return C(i.handleArchiveDeleteSuccess())})("onCancel",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())}),a()}if(t&2){let e=s();Y("isVisible",e.isVisibleArchiveDeletePopup),l("service",e.service)("entity",e.selectedDevice)("entityName",e.entity.name)("entityDisplayName",e.entity.displayName)("mode",e.archiveDeleteMode())}}var ji=(()=>{class t{get hasTenantRentalDevices(){return this.isEmployee?(this.tenantService.config()?.entity_counts?.rental_devices||0)>0:!0}constructor(e){this.service=e,this.formatMessage=d,this.ENTITIES=b,this.userSessionService=x(k),this.tenantService=x(wt),this.isEmployee=this.userSessionService.isEmployee(),this.userPermissionList=this.userSessionService.userPermissionList(),this.PERMISSION_LIST=g,this.toastNotificationService=x(B),this.documentService=x(mt),this.destroyRef=x(O),this.expanded=new jt,this.detailSectionsCache=new WeakMap,this.currentContextMenuAction=null,this.selectedDevice=null,this.deviceContextMenu=[],this.entity=b.RENTAL_DEVICE,this.isAddDevicePopupVisible=!1,this.isEditMode=!1,this.isVisibleArchiveDeletePopup=!1,this.archiveDeleteMode=We("delete"),this.isSaving=!1,this.columns=[{dataField:"device_number",caption:d("device_number"),allowSorting:!0,alignment:"center",width:110,cellTemplate:"idLinkTemplate"},{dataField:"name",caption:d("common_name"),allowSorting:!0},{dataField:"device_brand.name",caption:d("device_brand_name"),allowSorting:!1,alignment:"center"},{dataField:"device_model.name",caption:d("device_model"),allowSorting:!1,alignment:"center"},{dataField:"serial_number",caption:d("serial_number"),allowSorting:!1,alignment:"center"},{dataField:"barcode_number",caption:d("common_barcode"),allowSorting:!1,alignment:"center"},{dataField:"tags",caption:d("tags_label"),cellTemplate:"tagsTemplate",allowSorting:!1},{dataField:"rental_rate_monthly",caption:d("monthly_rent"),dataType:"number",allowSorting:!0,alignment:"center",format:{type:"fixedPoint",precision:2}},{dataField:"rental_deposit",caption:d("security_deposit"),dataType:"number",allowSorting:!0,alignment:"center",format:{type:"fixedPoint",precision:2}},{dataField:"rental_status",caption:d("common_status"),allowSorting:!1,cellTemplate:"statusTemplate",alignment:"center",width:120},{dataField:"current_rental_contract.rental_number",caption:d("current_contract"),allowSorting:!1,cellTemplate:"rentalContractLinkTemplate",alignment:"center"},{dataField:"storage_location.name",caption:d("location"),allowSorting:!1,alignment:"center"},{name:"accessories",caption:d("accessories"),calculateCellValue:o=>this.accessoriesLabel(o),visible:!1,allowSorting:!1},...Zn().map(o=>Ce(Q({},o),{visible:!1})),{name:"actions",caption:"",alignment:"center",cssClass:"custom-action",cellTemplate:"actionTemplate",allowExporting:!1,allowSorting:!1,showInColumnChooser:!1}],this.RENTAL_DEVICE_CONTEXT_MENU_LIST=ht}ngOnInit(){this.deviceContextMenu=[{name:ht.EDIT,icon:"fa-thin fa-edit",visible:this.isEmployee&&this.userPermissionList.includes(g.RENTAL_DEVICE_MANAGE),locale_key:d("common_edit")}
1,{name:ht.DELETE,icon:"fa-thin fa-trash",visible:this.isEmployee&&this.userPermissionList.includes(g.RENTAL_DEVICE_MANAGE),locale_key:d("common_delete"),destructive:!0}]}accessoriesLabel(e){return(e.accessories||[]).map(o=>o.name).filter(Boolean).join(", ")}deviceDetailSections(e){let o=this.detailSectionsCache.get(e);if(o)return o;let i=[{titleKey:"device_details",rows:[{labelKey:"device_number",value:e.device_number},{labelKey:"serial_number",value:e.serial_number},{labelKey:"inventory_barcode_number_label",value:e.barcode_number},{labelKey:"device_brand_name",value:e.device_brand?.name},{labelKey:"device_model",value:e.device_model?.name},{labelKey:"tags_label",value:(e.tags??[]).map(_=>_?.tag_name).filter(Boolean).join(", ")},{labelKey:"monthly_rent",value:e.rental_rate_monthly,type:"money"},{labelKey:"security_deposit",value:e.rental_deposit,type:"money"},{labelKey:"common_created_on",value:e.created_at,type:"datetime"},{labelKey:"common_updated_on",value:e.updated_at,type:"datetime"}]},{titleKey:"common_custom_fields",rows:Mt.toArray(e.custom_fields).map(_=>({label:_.label,value:_.field_value}))}];return this.detailSectionsCache.set(e,i),i}openAddDevicePopup(){this.isEditMode=!1,this.addDeviceForm=Qe.getForm(new Qe({})),this.isAddDevicePopupVisible=!0}
1saveDevice(){if(this.addDeviceForm.invalid){this.addDeviceForm.markAllAsTouched();return}this.isSaving=!0;let e=this.addDeviceForm.value;if(this.isEditMode){this.runDeviceSave(this.service.update(e),!0);return}this.runDeviceSave(this.service.create(e),!1)}runDeviceSave(e,o){e.pipe(S(this.destroyRef)).subscribe({next:()=>{this.toastNotificationService.success(d(o?"rental_device_updated":"rental_device_created_successfully")),this.isAddDevicePopupVisible=!1,this.isEditMode=!1,this.dataGrid?.getData()},error:()=>{this.toastNotificationService.error(d("something_went_wrong"))}}).add(()=>{this.isSaving=!1})}createBarcode(e){this.service.createBarcode(e).pipe(S(this.destroyRef)).subscribe({next:()=>{this.documentService.invalidate(b.RENTAL_DEVICE.name,e.id),this.dataGrid?.getData()},error:()=>this.toastNotificationService.error(d("something_went_wrong"))})}onDocumentCreate(e,o){e==="barcode"&&this.createBarcode(o)}onContextMenuItemClick(e){this.currentContextMenuAction=e.action,this.selectedDevice=e.entity,this.currentContextMenuAction===ht.CREATE_BARCODE&&this.createBarcode(this.selectedDevice),this.currentContextMenuAction===ht.EDIT&&this.edit(this.selectedDevice),this.currentContextMenuAction===ht.DELETE&&(this.archiveDeleteMode.set(this.selectedDevice.deleted_at?"archived-actions":"delete"),this.isVisibleArchiveDeletePopup=!0)}edit(e){this.isEditMode=!0,this.addDeviceForm=Qe.getForm(e),this.isAddDevicePopupVisible=!0}handleArchiveDeleteSuccess(){this.isVisibleArchiveDeletePopup=!1,this.currentContextMenuAction=null,this.selectedDevice=null,this.dataGrid.getData()}onCloseContextMenuOption(){this.currentContextMenuAction=null,this.selectedDevice=null,this.isVisibleArchiveDeletePopup=!1}static{this.\u0275fac=function(o){return new(o||t)(X(Ie))}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-device-list"]],viewQuery:function(o,i){if(o&1&&fe(ee,5),o&2){let _;he(_=xe())&&(i.dataGrid=_.first)}},decls:4,vars:13,consts:[[3,"contextMenuItemCancelClick","contextMenuItemClick","dataGridAddNewClick","columns","contextMenuItems","dataGridId","entity","searchPanelPlaceholderText","isVisibleDeleteAction","isVisibleEditAction","service","hasTenantData","writeAccessPermissionName","deleteAccessPermissionName"],["appCardTemplate",""],["appPhoneMode","fullscreen",3,"visible","width","maxWidth","height","maxHeight","showTitle","title","dragEnabled","showCloseButton"],[3,"isVisible","service","entity","entityName","entityDisplayName","mode"],[1,"app-card"],[1,"d-flex","align-items-center","justify-content-between","gap-2","mb-2"],[1,"fs-label","text-muted","text-truncate"],["kind","rental",3,"status"],[1,"min-width-0"],[1,"fs-subsection","fw-bold","text-truncate"],[1,"my-2"],[1,"d-flex","align-items-center","gap-2","mt-1",3,"click"],[1,"fs-label","fw-bold"],[3,"value"],[1,"ms-auto",3,"toggle","expanded"],[3,"contextMenuItemCancelClick","contextMenuItemClick","documentCreate","allowCreate","contextMenuItems","entityName","entity","mobileSheet","showDocuments"],[3,"subtitle","title"],[1,"d-flex","flex-column","gap-2"],[1,"d-flex","align-items-center","justify-content-between","gap-2","fs-body-sm"],[3,"sections"],[1,"text-muted","text-truncate"],[1,"text-truncate"],[1,"text-truncate",3,"innerHTML"],["appPhoneMode","fullscreen",3,"visibleChange","visible","width","maxWidth","height","maxHeight","showTitle","title","dragEnabled","showCloseButton"],["class","p-3 d-flex flex-column h-100",4,"dxTemplate","dxTemplateOf"],[1,"p-3","d-flex","flex-column","h-100"],[1,"flex-grow-1","min-height-0"],[3,"form"],[3,"saveClick","cancelClick","isSaving","isOnPopup","isVisibleHr","useSubmitBehavior","saveText"],[3,"isVisibleChange","onSuccess","onCancel","isVisible","service","entity","entityName","entityDisplayName","mode"]],template:function(o,i){o&1&&(r(0,"app-data-grid",0),y("contextMenuItemCancelClick",function(){return i.onCloseContextMenuOption()})("contextMenuItemClick",function(L){return i.onContextMenuItemClick(L)})("dataGridAddNewClick",function(){return i.openAddDevicePopup()}),I(1,or,20,17,"ng-template",1),a(),f(2,rr,2,10,"dx-popup",2),f(3,lr,1,6,"app-archive-delete-popup",3)),o&2&&(l("columns",i.columns)("contextMenuItems",i.deviceContextMenu)("dataGridId","rentalDeviceGrid")("entity",i.entity)("searchPanelPlaceholderText","search_panel_rental_device_placeholder")("isVisibleDeleteAction",!1)("isVisibleEditAction",!1)("service",i.service)("hasTenantData",i.hasTenantRentalDevices)("writeAccessPermissionName","rental_device.manage")("deleteAcce
1ssPermissionName","rental_device.manage"),n(2),h(i.isAddDevicePopupVisible&&i.addDeviceForm?2:-1),n(),h(i.isVisibleArchiveDeletePopup?3:-1))},dependencies:[ce,ee,_e,gi,H,Ti,De,Ue,se,le,ie,me,pe,Ge,J,Ft,ne,Be,Bt],encapsulation:2})}}return t})();var Zo=()=>["barcode"],Jo=t=>["/rentals",t,"overview"],sr=(t,c)=>c.label,cr=(t,c)=>c.id;function dr(t,c){t&1&&m(0,"app-skeleton-loader",0),t&2&&l("rows",4)("columns",4)}function pr(t,c){if(t&1&&(r(0,"span",26),p(1),a()),t&2){let e=c.$implicit;n(),u(e)}}function mr(t,c){if(t&1&&(r(0,"div",13),He(1,pr,2,1,"span",26,ut),a()),t&2){let e=s(2);n(),je(e.tagNames())}}function _r(t,c){t&1&&(r(0,"div",12),p(1,"\u2014"),a())}function ur(t,c){if(t&1&&(r(0,"div",10)(1,"div",11),p(2),a(),r(3,"div",12),p(4),a()()),t&2){let e=c.$implicit;n(2),u(e.label),n(2),u(e.field_value)}}function vr(t,c){if(t&1&&(r(0,"div",14)(1,"div",11),p(2),a(),m(3,"div",27),M(4,"safe"),a()),t&2){let e=s(2);n(2),u(e.formatMessage("common_comment")),n(),l("innerHTML",N(4,2,e.device.latest_note.content,"html"),gt)}}function Cr(t,c){if(t&1&&(r(0,"div",31),m(1,"app-user-badge",32),a()),t&2){let e=s(3);n(),l("iconOnly",!1)("user",e.device.current_rental_contract.user)("entity",e.ENTITIES.CUSTOMER)}}function fr(t,c){if(t&1&&(r(0,"div",28)(1,"a",29),p(2),a(),m(3,"app-status-badge",30),a(),f(4,Cr,2,3,"div",31)),t&2){let e=s(2);n(),l("routerLink",ye(4,Jo,e.device.current_rental_contract.id)),n(),u(e.device.current_rental_contract.rental_number),n(),l("status",e.device.current_rental_contract.status),n(),h(e.device.current_rental_contract.user?4:-1)}}function hr(t,c){if(t&1&&(r(0,"div",20),p(1),a()),t&2){let e=s(2);n(),u(e.formatMessage("available"))}}function xr(t,c){if(t&1&&m(0,"app-user-badge",32),t&2){let e=s().$implicit,o=s(3);l("iconOnly",!1)("user",e.rental_contract.user)("entity",o.ENTITIES.CUSTOMER)}}function yr(t,c){t&1&&p(0," \u2014 ")}function Tr(t,c){if(t&1&&(r(0,"tr")(1,"td")(2,"a",29),p(3),a()(),r(4,"td"),f(5,xr,1,3,"app-user-badge",32)(6,yr,1,0),a(),r(7,"td"),p(8),M(9,"dateFormat"),a(),r(10,"td"),p(11),M(12,"dateFormat"),a(),r(13,"td"),p(14),M(15,"dateFormat"),a(),r(16,"td",34),m(17,"app-money",19),a(),r(18,"td",35),m(19,"app-status-badge",30),a()()),t&2){let e=c.$implicit;n(2),l("routerLink",ye(17,Jo,e.rental_contract_id)),n(),u(e.rental_contract==null?null:e.rental_contract.rental_number),n(2),h(e.rental_contract!=null&&e.rental_contract.user?5:6),n(3),u(e.start_date?N(9,8,e.start_date,"dateOnly"):"\u2014"),n(3),u(e.end_date?N(12,11,e.end_date,"dateOnly"):"\u2014"),n(3),u(e.returned_at?N(15,14,e.returned_at,"dateOnly"):"\u2014"),n(3),l("value",e.unit_price),n(2),l("status",e.status)}}function gr(t,c){if(t&1&&(r(0,"div",25)(1,"table",33)(2,"thead")(3,"tr")(4,"th"),p(5),a(),r(6,"th"),p(7),a(),r(8,"th"),p(9),a(),r(10,"th"),p(11),a(),r(12,"th"),p(13),a(),r(14,"th",34),p(15),a(),r(16,"th",35),p(17),a()()(),r(18,"tbody"),He(19,Tr,20,19,"tr",null,cr),a()()()),t&2){let e=s(2);n(5),u(e.formatMessage("contract_number")),n(2),u(e.formatMessage("user_customer_name")),n(2),u(e.formatMessage("start_date")),n(2),u(e.formatMessage("end_date")),n(2),u(e.formatMessage("returned")),n(2),u(e.formatMessage("monthly_rent")),n(2),u(e.formatMessage("common_status")),n(2),je(e.rentalHistory)}}function Er(t,c){if(t&1&&(r(0,"div",20),p(1),a()),t&2){let e=s(2);n(),u(e.formatMessage("no_rental_history"))}}function br(t,c){if(t&1){let e=T();r(0,"app-page-header",2),y("editClick",function(){v(e);let i=s();return C(i.edit())}),m(1,"app-status-badge",3),r(2,"span",4),p(3),a(),r(4,"app-entity-documents-button",5),y("documentCreate",function(i){v(e);let _=s();return C(_.onDocumentCreate(i))}),a()(),r(5,"div",6)(6,"div",7)(7,"div",8)(8,"div",9),p(9),a(),r(10,"div",6)(11,"div",10)(12,"div",11),p(13),a(),r(14,"div",12),p(15),a()(),r(16,"div",10)(17,"div",11),p(18),a(),r(19,"div",12),p(20),a()(),r(21,"div",10)(22,"div",11),p(23),a(),r(24,"div",12),p(25),a()(),r(26,"div",10)(27,"div",11),p(28),a(),r(29,"div",12),p(30),a()(),r(31,"div",10)(32,"div",11),p(33),a(),r(34,"div",12),p(35),a()(),r(36,"div",10)(37,"div",11),p(38),a(),r(39,"div",12),p(40),a()(),r(41,"div",10)(42,"div",11),p(43),a(),r(44,"div",12),p(45),a()(),r(46,"div",10)(47,"div",11),p(48),a(),r(49,"div",12),p(50),a()(),r(51,"div",10)(52,"div",11),p(53),a(),f(54,mr,3,0,"div",13)(55,_r,2,0,"div",12),a(),He(56,ur,5,2,"div",10,sr),r(58,"div",10)(59,"div",11),p(60),a(),r(61,"div",12),p(62),M(63,"dateFormat"),a()(),r(64,"div",10)(65,"div",11),p(66),a(),r(67,"div",12),p(68),M(69,"dateFormat"),a()(),f(70,vr,5,5,"div",14),a()()(),r(71,"div",15)(72,"div",6)(73,"div",16)(74,"div",8)(75,"div",9),p(76),a(),r(77,"div",6)(78,"div",17)(79,"div",11),p(80),a(),r(81,"div",18),m(82,"app-money",19),a()(),r(83,"div",17)(84,"div",11),p(85),a(),r(86,"div",18),m(87,"app-money",19),a()()()()(),r(88,"div",16)(89,"div",8)(90,"div",9),p(91),a(),f(92,fr,5,6)(93,hr,2,1,"div",20),a()()(),r(94,"div",21)(95,"div",22),p(96),a(),r(97,"app-entity-document-list",23),y("documentCreate",function(i){v(e);let _=s();return C(_.onDocumentCreate(i))}),a()()(),r(98,"div",14)(99,"div",24)(100,"div",9),p(101),a(),f(102,gr,21,7,"div",25)(103,Er,2,1,"div",20),a()()()}if(t&2){let e=s();l("recordTitle",e.device.device_number)("canEdit",e.canManage),n(),l("status",e.device.rental_status),n(2),U("",e.device.device_number," \xB7 ",e.device.name),n(),l("allowCreate",e.canManage)("createTypes",P(55,Zo))("entityId",e.device.id)("entityType",e.ENTITIES.RENTAL_DEVICE.name)("isIconOnly",!0),n(5),u(e.formatMessage("device_details")),n(4),u(e.formatMessage("device_number")),n(2),u(e.device.device_number),n(3),u(e.formatMessage("device_type")),n(2),u(e.device.name),n(3),u(e.formatMessage("device_brand_name")),n(2),u((e.device.device_brand==null?null:e.device.device_brand.name)||"\u2014"),n(3),u(e.formatMessage("device_model")),n(2),u((e.device.device_model==null?null:e.device.device_model.name)||"\u2014"),n(3),u(e.formatMessage("serial_number")),n(2),u(e.device.serial_number||"\u2014"),n(3),u(e.formatMessage("inventory_barcode_number_label")),n(2),u(e.device.barcode_number||"\u2014"),n(3),u(e.formatMessage("device_storage_location")),n(2),u((e.device.storage_location==null?null:e.device.storage_location.name)||"\u2014"),n(3),u(e.formatMessage("accessories")),n(2),u(e.accessoriesLabel()||"\u2014"),n(3),u(e.formatMessage("tags_label")),n(),h(e.tagNames().length?54:55),n(2),je(e.customFields),n(4),u(e.formatMessage("common_created_on")),n(2),u(N(63,49,e.device.created_at,"dateOnly")),n(4),u(e.formatMessage("common_updated_on")),n(2),u(N(69,52,e.device.updated_at,"dateOnly")),n(2),h(e.device.latest_note!=null&&e.device.latest_note.content?70:-1),n(6),u(e.formatMessage("billing_and_terms")),n(4),u(e.formatMessage("monthly_rent")),n(2),l("value",e.device.rental_rate_monthly),n(3),u(e.formatMessage("security_deposit")),n(2),l("value",e.device.rental_deposit),n(4),u(e.formatMessage("current_contract")),n(),h(e.device.current_rental_contract?92:93),n(4),u(e.formatMessage("common_documents")),n(),l("entity
1Id",e.device.id)("entityType",e.ENTITIES.RENTAL_DEVICE.name)("allowCreate",e.canManage)("createTypes",P(56,Zo))("showHeader",!1),n(4),u(e.formatMessage("rental_history")),n(),h(e.rentalHistory.length?102:103)}}function Sr(t,c){if(t&1){let e=T();r(0,"div",38)(1,"dx-scroll-view",39),m(2,"app-rental-device-form",40),a(),r(3,"app-save-cancel-footer",41),y("saveClick",function(){v(e);let i=s(2);return C(i.saveDevice())})("cancelClick",function(){v(e);let i=s(2);return C(i.isEditPopupVisible=!1)}),a()()}if(t&2){let e=s(2);n(2),l("form",e.editForm),n(),l("isSaving",e.isSaving)("isOnPopup",!0)("isVisibleHr",!1)("useSubmitBehavior",!1)}}function Dr(t,c){if(t&1){let e=T();r(0,"dx-popup",36),W("visibleChange",function(i){v(e);let _=s();return G(_.isEditPopupVisible,i)||(_.isEditPopupVisible=i),C(i)}),I(1,Sr,4,5,"div",37),a()}if(t&2){let e=s();Y("visible",e.isEditPopupVisible),l("width",620)("maxWidth","95vw")("height","auto")("maxHeight","90vh")("showTitle",!0)("title",e.formatMessage("edit_rental_device"))("dragEnabled",!1)("showCloseButton",!0),n(),l("dxTemplateOf","content")}}var ea=(()=>{class t{constructor(){this.formatMessage=d,this.ENTITIES=b,this.route=x(te),this.destroyRef=x(O),this.service=x(Ie),this.documentService=x(mt),this.toastNotificationService=x(B),this.userSessionService=x(k),this.isEmployee=this.userSessionService.isEmployee(),this.canManage=this.isEmployee&&this.userSessionService.userPermissionList().includes(g.RENTAL_DEVICE_MANAGE),this.rentalDeviceId=null,this.device=null,this.customFields=[],this.isEditPopupVisible=!1,this.isSaving=!1}ngOnInit(){this.route.params.pipe(S(this.destroyRef)).subscribe({next:e=>{this.rentalDeviceId=+e.rental_device_id||null,this.rentalDeviceId&&this.load()}})}load(){this.service.getById(this.rentalDeviceId).pipe(S(this.destroyRef)).subscribe({next:e=>{this.device=new Qe(e),this.customFields=Mt.toArray(e.custom_fields).filter(o=>o.field_value)},error:()=>this.toastNotificationService.error(d("something_went_wrong"))})}tagNames(){return(this.device?.tags??[]).map(e=>typeof e=="string"?e:e?.tag_name).filter(Boolean)}accessoriesLabel(){return(this.device?.accessories||[]).map(e=>e.name).filter(Boolean).join(", ")}get rentalHistory(){return[...this.device?.contract_items??[]].sort((e,o)=>(o.id??0)-(e.id??0))}edit(){this.editForm=Qe.getForm(this.device),this.isEditPopupVisible=!0}saveDevice(){if(this.editForm.invalid){this.editForm.markAllAsTouched();return}this.isSaving=!0,this.service.update(this.editForm.value).pipe(S(this.destroyRef)).subscribe({next:()=>{this.toastNotificationService.success(d("rental_device_updated")),this.isEditPopupVisible=!1,this.refresh()},error:()=>this.toastNotificationService.error(d("something_went_wrong"))}).add(()=>this.isSaving=!1)}onDocumentCreate(e){e==="barcode"&&this.service.createBarcode(this.device).pipe(S(this.destroyRef)).subscribe({next:()=>this.refresh(),error:()=>this.toastNotificationService.error(d("something_went_wrong"))})}refresh(){this.documentService.invalidate(b.RENTAL_DEVICE.name,this.rentalDeviceId),this.load()}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-device-detail"]],decls:3,vars:3,consts:[["type","form",3,"rows","columns"],["appPhoneMode","fullscreen",3,"visible","width","maxWidth","height","maxHeight","showTitle","title","dragEnabled","showCloseButton"],["entityLabel","rental_device",3,"editClick","recordTitle","canEdit"],["status","","kind","rental",3,"status"],["heading","",1,"fs-page-title","fw-semibold","text-truncate"],["actions","",3,"documentCreate","allowCreate","createTypes","entityId","entityType","isIconOnly"],[1,"row","g-3"],[1,"col-lg-6"],[1,"app-card","h-100"],[1,"app-subgroup-label","mb-3"],[1,"col-6","col-md-3"],[1,"small","text-muted"],[1,"fw-semibold"],[1,"d-flex","flex-wrap","gap-1","mt-1"],[1,"col-12"],[1,"col-lg-6","d-flex","flex-column","gap-3"],[1,"col-md-6"],[1,"col-6"],[1,"fs-subsection","fw-bold"],[3,"value"],[1,"text-muted"],[1,"app-card","flex-grow-1"],[1,"app-subgroup-label","mb-2"],[3,"documentCreate","entityId","entityType","allowCreate","createTypes","showHeader"],[1,"app-card"],[1,"table-responsive"],[1,"badge","rounded-pill","theme-badge","fw-normal"],[3,"innerHTML"],[1,"d-flex","align-items-center","justify-content-between","gap-2"],[1,"fw-bold",3,"routerLink"],["kind","rental",3,"status"],[1,"mt-2"],[3,"iconOnly","user","entity"],[1,"table","table-sm","align-middle","mb-0"],[1,"text-end"],[1,"text-center"],["appPhoneMode","fullscreen",3,"visibleChange","visible","width","maxWidth","height","maxHeight","showTitle","title","dragEnabled","showCloseButton"],["class","p-3 d-flex flex-column h-100",4,"dxTemplate","dxTemplateOf"],[1,"p-3","d-flex","flex-column","h-100"],[1,"flex-grow-1","min-height-0"],[3,"form"],["saveText","common_save",3,"saveClick","cancelClick","isSaving","isOnPopup","isVisibleHr","useSubmitBehavior"]],template:function(o,i){o&1&&(f(0,dr,1,2,"app-skeleton-loader",0),f(1,br,104,57),f(2,Dr,2,10,"dx-popup",1)),o&2&&(h(!(i.device!=null&&i.device.id)&&i.rentalDeviceId?0:-1),n(),h(i.device!=null&&i.device.id?1:-1),n(),h(i.isEditPopupVisible&&i.editForm?2:-1))},dependencies:[ce,j,Mn,se,le,ie,me,pe,ne,pt,Fe,_e,Gt,H,Ht,Ri,J,Ge,oe,Bt],encapsulation:2})}}return t})();function Ir(t,c){if(t&1&&m(0,"app-metric-card",31)(1,"app-metric-card",32),t&2){let e=s();l("value",e.stats.under_repair),n(),l("value",e.stats.available_devices)}}var qi=(()=>{class t{constructor(e){this.rentalContractService=e,this.formatMessage=d,this.toastNotificationService=x(B),this.destroyRef=x(O),this.isCu
1stomer=x(k).isCustomer,this.stats={active_contracts:0,overdue_contracts:0,devices_on_rent:0,pending_outstanding:0,expiring_this_month:0,collected_this_month:0,deposit_held:0,under_repair:0,available_devices:0},this.isLoading=!0}ngOnInit(){this.loadOverview()}loadOverview(){this.isLoading=!0,this.rentalContractService.getOverview().pipe(S(this.destroyRef)).subscribe({next:e=>{e&&(this.stats=Q(Q({},this.stats),e))},error:()=>{this.toastNotificationService.error(d("something_went_wrong"))}}).add(()=>{this.isLoading=!1})}static{this.\u0275fac=function(o){return new(o||t)(X(F))}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-overview"]],decls:48,vars:19,consts:[[1,"p-3"],["id","rentalKpiCards",1,"app-metric-grid","app-metric-grid-5","mb-4"],["label","active_rentals","icon","fa-thin fa-file-contract","tone","success","help","rental_overview_active_rentals_help","helpTarget","rental_overview_active_rentals",3,"value"],["label","overdue","icon","fa-thin fa-triangle-exclamation","tone","danger","valueTone","danger","help","rental_overview_overdue_help","helpTarget","rental_overview_overdue",3,"value"],["label","devices_on_rent","icon","fa-thin fa-laptop","tone","info","help","rental_overview_devices_on_rent_help","helpTarget","rental_overview_devices_on_rent",3,"value"],["label","pending_outstanding","icon","fa-thin fa-money-bill-wave","tone","warning","help","rental_overview_outstanding_help","helpTarget","rental_overview_outstanding",3,"value","isCurrency"],["label","expiring_this_month","icon","fa-thin fa-calendar-xmark","tone","warning","help","rental_overview_expiring_this_month_help","helpTarget","rental_overview_expiring_this_month",3,"value"],["label","collected_this_month","icon","fa-thin fa-circle-check","tone","success","help","rental_overview_collected_this_month_help","helpTarget","rental_overview_collected_this_month",3,"value","isCurrency"],["label","deposit_held","icon","fa-thin fa-vault","tone","info","help","rental_overview_deposit_held_help","helpTarget","rental_overview_deposit_held",3,"value","isCurrency"],[1,"card","border-0","mb-4","bg-secondary","bg-opacity-10"],[1,"card-body","p-3"],[1,"d-flex","flex-wrap","align-items-center","gap-3"],[1,"fw-semibold","small","me-2"],[1,"fa-thin","fa-bolt","me-1"],[1,"badge","rounded-pill","bg-success","px-3","py-2"],[1,"fa-thin","fa-rotate","me-1"],[1,"badge","rounded-pill","bg-info","px-3","py-2"],[1,"fa-thin","fa-bell","me-1"],[1,"badge","rounded-pill","bg-warning","px-3","py-2"],[1,"fa-thin","fa-triangle-exclamation","me-1"],[1,"row","g-3"],[1,"col-12","col-md-6"],[1,"border-0","h-100"],[1,"app-subgroup-label","mb-2","border-0"],[1,"fw-semibold","mb-0"],[1,"fa-thin","fa-calendar-clock","me-2","text-muted"],[1,"text-center","text-muted","py-4"],[1,"fa-thin","fa-calendar-clock","fa-2x","mb-2","d-block","opacity-50"],[1,"fa-thin","fa-chart-line","me-2","text-muted"],[1,"d-flex","align-items-center","justify-content-center"],[1,"fa-thin","fa-chart-line","fa-2x","mb-2","d-block","opacity-50"],["label","under_repair","icon","fa-thin fa-screwdriver-wrench","tone","warning","help","rental_overview_under_repair_help","helpTarget","rental_overview_under_repair",3,"value"],["label","available_devices","icon","fa-thin fa-circle-check","tone","success","help","rental_overview_available_devices_help","helpTarget","rental_overview_available_devices",3,"value"]],template:function(o,i){o&1&&(r(0,"div",0)(1,"div",1),m(2,"app-metric-card",2)(3,"app-metric-card",3)(4,"app-metric-card",4)(5,"app-metric-card",5)(6,"app-metric-card",6)(7,"app-metric-card",7)(8,"app-metric-card",8),f(9,Ir,2,2),a(),r(10,"div",9)(11,"div",10)(12,"div",11)(13,"span",12),m(14,"i",13),p(15),a(),r(16,"span",14),m(17,"i",15),p(18),a(),r(19,"span",16),m(20,"i",17),p(21),a(),r(22,"span",18),m(23,"i",19),p(24),a()()()(),r(25,"div",20)(26,"div",21)(27,"div",22)(28,"div",23)(29,"h6",24),m(30,"i",25),p(31),a()(),r(32,"div")(33,"div",26),m(34,"i",27),r(35,"small"),p(36),a()()()()(),r(37,"div",21)(38,"div",22)(39,"div",23)(40,"h6",24),m(41,"i",28),p(42),a()(),r(43,"div",29)(44,"div",26),m(45,"i",30),r(46,"small"),p(47),a()()()()()()()),o&2&&(n(2),l("value",i.stats.active_contracts),n(),l("value",i.stats.overdue_contracts),n(),l("value",i.stats.devices_on_rent),n(),l("value",i.stats.pending_outstanding)("isCurrency",!0),n(),l("value",i.stats.expiring_this_month),n(),l("value",i.stats.collected_this_month)("isCurrency",!0),n(),l("value",i.stats.deposit_held)("isCurrency",!0),n(),h(i.isCustomer()?-1:9),n(6),R("",i.formatMessage("automations")," "),n(3),R("",i.formatMessage("auto_billing_enabled")," "),n(3),R("",i.formatMessage("renewal_reminders_on")," "),n(3),R("",i.formatMessage("overdue_alerts_on")," "),n(7),R("",i.formatMessage("upcoming_renewals")," "),n(5),u(i.formatMessage("no_upcoming_renewals_30_days")),n(6),R("",i.formatMessage("revenue_trend")," "),n(5),u(i.formatMessage("revenue_chart_coming_v2")))},dependencies:[Qo],encapsulation:2})}}return t})();var ta=(()=>{class t{constructor(){this.formatMessage=d}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-reports"]
1],decls:8,vars:2,consts:[[1,"d-flex","align-items-center","justify-content-center","p-5"],[1,"text-center","app-rr-max-width-380px"],[1,"mb-3"],[1,"fa-thin","fa-chart-line","fa-3x","text-muted","opacity-60"],[1,"fw-semibold","mb-2"],[1,"text-muted","small"]],template:function(o,i){o&1&&(si(0,"div",0)(1,"div",1)(2,"div",2),yn(3,"i",3),ci(),si(4,"h6",4),p(5),ci(),si(6,"p",5),p(7),ci()()()),o&2&&(n(5),u(i.formatMessage("rental_reports")),n(2),R(" ",i.formatMessage("rental_reports_coming_soon")," "))},styles:[".app-rr-max-width-380px[_ngcontent-%COMP%]{max-width:380px}"]})}}return t})();function Ar(t,c){if(t&1){let e=T();r(0,"app-save-cancel-footer",19),y("cancelClick",function(){v(e);let i=s(3);return C(i.cancel())}),a()}if(t&2){let e=s(3);l("isSaving",e.isSaving)("isVisibleHr",!1)}}function Rr(t,c){if(t&1){let e=T();r(0,"app-edit-back-btn",21),y("editClick",function(){v(e);let i=s(4);return C(i.setEditMode())}),a()}}function wr(t,c){if(t&1&&I(0,Rr,1,0,"app-edit-back-btn",20),t&2){let e=s(3);l("ngxPermissionsOnly",e.PERMISSION_LIST.RENTAL_CONTRACT_WRITE)}}function Mr(t,c){if(t&1&&f(0,Ar,1,2,"app-save-cancel-footer",18)(1,wr,1,1,"app-edit-back-btn"),t&2){let e=s(2);h(e.isEditMode?0:1)}}function Nr(t,c){if(t&1){let e=T();r(0,"a",23),y("click",function(){v(e);let i=s(3);return C(i.openExternal(i.RENTAL_VIDEO_URL))}),m(1,"i",24),p(2),a()}if(t&2){let e=s(3);n(2),R("",e.formatMessage("watch_tutorial_label")," ")}}function Vr(t,c){if(t&1){let e=T();r(0,"a",23),y("click",function(){v(e);let i=s(3);return C(i.openExternal(i.RENTAL_BLOG_URL))}),m(1,"i",25),p(2),a()}if(t&2){let e=s(3);n(2),R("",e.formatMessage("read_blog")," ")}}function Pr(t,c){if(t&1&&(r(0,"div",7),f(1,Nr,3,1,"a",22),f(2,Vr,3,1,"a",22),a()),t&2){let e=s(2);n(),h(e.RENTAL_VIDEO_URL?1:-1),n(),h(e.RENTAL_BLOG_URL?2:-1)}}function Lr(t,c){if(t&1){let e=T();r(0,"form",1),y("ngSubmit",function(){v(e);let i=s();return C(i.save())}),r(1,"div",2)(2,"div",3)(3,"app-form-layout"),I(4,Mr,2,1,"ng-template",4),a()()(),r(5,"div",5)(6,"div",3)(7,"app-alert-panel",6),f(8,Pr,3,2,"div",7),a()()(),m(9,"app-section-title",8),r(10,"div",9)(11,"app-control-container",10),m(12,"dx-select-box",11),a(),r(13,"app-control-container",12),m(14,"dx-select-box",13),a()(),m(15,"app-section-title",8),r(16,"div",9)(17,"app-control-container",14),m(18,"dx-number-box",15),a(),r(19,"app-control-container",16),m(20,"dx-number-box",17),a()()()}if(t&2){let e=s();l("formGroup",e.form),n(7),l("heading",e.formatMessage("how_rentals_work"))("message",e.formatMessage("rental_settings_overview_note"))("isVisibleCancelButton",!1),n(),h(e.RENTAL_VIDEO_URL||e.RENTAL_BLOG_URL?8:-1),n(),l("title","billing_defaults"),n(2),l("label",e.formatMessage("default_payment_frequency"))("tooltipText","rental_setting_default_payment_frequency_help"),n(),l("items",e.PAYMENT_FREQUENCY_LIST)("displayExpr",e.frequencyLabel),n(),l("label",e.formatMessage("default_renewal_type"))("tooltipText","rental_setting_default_renewal_type_help"),n(),l("items",e.RENEWAL_TYPES),n(),l("title","reminders_and_alerts"),n(2),l("label",e.formatMessage("renewal_reminder_days_before_end"))("tooltipText","rental_setting_renewal_reminder_help"),n(),l("min",1)("showSpinButtons",!0)("isValid",e.form.get("renewal_reminder_lead_days").valid||!e.form.get("renewal_reminder_lead_days").touched),n(),l("label",e.formatMessage("overdue_alert_days_after_due"))("tooltipText","rental_setting_overdue_alert_help"),n(),l("min",0)("showSpinButtons",!0)("isValid",e.form.get("grace_days").valid||!e.form.get("grace_days").touched)}}var $i=(()=>{class t{constructor(){this.nativeLinkService=x(jn),this.formatMessage=d,this.fb=x(ge),this.generalSettingsService=x(bo),this.generalSettingDataService=x(fi),this.toastNotificationService=x(B),this.isEditMode=!1,this.isSaving=!1,this.PAYMENT_FREQUENCY_LIST=It,this.BILLING_MODE_LIST=At.map(e=>({id:e.id,label:ct(e.id)})),this.RENEWAL_TYPES=Rt.map(e=>({id:e.id,label:dt(e.id)})),this.frequencyLabel=st,this.PERMISSION_LIST=g,this.RENTAL_VIDEO_URL="https://www.youtube.com/watch?v=E6pZ5WnMmXY",this.RENTAL_BLOG_URL=Pn("blog/rental-management-settings-guide/")}ngOnInit(){this.initForm(),this.loadSettings()}initForm(){this.form=this.fb.group({default_payment_frequency:["Monthly"],default_billing_generation_mode:["automatic"],default_renewal_type:["fixed"],renewal_reminder_lead_days:[7,[V.required,V.min(1)]],grace_days:[3,[V.required,V.min(0)]]}),this.form.disable()}loadSettings(){let e=this.generalSettingDataService.getGeneralSettingBySettingType(Zt.RENTAL_SETTINGS);if(!e)return;let o={};
1Object.keys(this.form.controls).forEach(i=>{e[i]!==void 0&&e[i]!==null&&(o[i]=e[i])}),this.form.patchValue(o)}setEditMode(){this.isEditMode=!0,this.form.enable()}cancel(){this.isEditMode=!1,this.form.disable(),this.loadSettings()}save(){if(this.form.invalid){this.form.markAllAsTouched();return}this.isSaving=!0;let e=this.form.value,o=Object.keys(e).map(i=>({setting_type:Zt.RENTAL_SETTINGS,key:i,value:e[i]}));this.generalSettingsService.generalSettings({general_settings:o}).subscribe({next:()=>{this.toastNotificationService.success(d("notification_settings_update_success")),this.isEditMode=!1,this.form.disable(),window.location.reload()},error:()=>{this.toastNotificationService.error(d("something_went_wrong"))}}).add(()=>{this.isSaving=!1})}openExternal(e){this.nativeLinkService.openExternal(e)}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-settings"]],decls:1,vars:1,consts:[[1,"app-workspace",3,"formGroup"],[1,"app-workspace",3,"ngSubmit","formGroup"],[1,"row","mt-2","mb-3"],[1,"col-12"],["appFormActions",""],[1,"row","mb-4"],["iconBeforeMessage","fa-solid fa-circle-info",3,"heading","message","isVisibleCancelButton"],[1,"d-flex","flex-wrap","gap-3","mt-2"],[1,"mb-3",3,"title"],[1,"row","mb-5"],["name","default_payment_frequency",1,"col-sm-12","col-md-6","col-lg-4",3,"label","tooltipText"],["formControlName","default_payment_frequency","stylingMode","outlined",3,"items","displayExpr"],["name","default_renewal_type",1,"col-sm-12","col-md-6","col-lg-4",3,"label","tooltipText"],["formControlName","default_renewal_type","displayExpr","label","valueExpr","id","stylingMode","outlined",3,"items"],["name","renewal_reminder_lead_days",1,"col-sm-12","col-md-6","col-lg-4",3,"label","tooltipText"],["formControlName","renewal_reminder_lead_days","stylingMode","outlined",3,"min","showSpinButtons","isValid"],["name","grace_days",1,"col-sm-12","col-md-6","col-lg-4",3,"label","tooltipText"],["formControlName","grace_days","stylingMode","outlined",3,"min","showSpinButtons","isValid"],[3,"isSaving","isVisibleHr"],[3,"cancelClick","isSaving","isVisibleHr"],[3,"editClick",4,"ngxPermissionsOnly"],[3,"editClick"],["appA11yClick","",1,"link-without-effect","fw-medium"],["appA11yClick","",1,"link-without-effect","fw-medium",3,"click"],["aria-hidden","true",1,"fab","fa-youtube","me-1"],["aria-hidden","true",1,"fa-solid","fa-book-open","me-1"]],template:function(o,i){o&1&&f(0,Lr,21,24,"form",0),o&2&&h(i.form?0:-1)},dependencies:[$n,Si,J,po,Di,kt,de,re,ae,Ee,Se,be,ke,et,Te,Pe,Oe,Le,St,bt,bi],encapsulation:2})}}return t})();var Or=()=>({standalone:!0});function kr(t,c){if(t&1&&(r(0,"span",8),p(1),M(2,"dateFormat"),a()),t&2){let e=s(2);n(),u(N(2,1,e.kycVerifiedAt,"datetime"))}}function Fr(t,c){if(t&1){let e=T();r(0,"div",1)(1,"div",3),m(2,"i",4),a(),r(3,"div",5)(4,"div",6)(5,"span",7),p(6),a(),f(7,kr,3,4,"span",8),a(),r(8,"div",8),p(9),a()(),r(10,"app-dx-outline-button",9),y("onClickEvent",function(){v(e);let i=s();return C(i.setVerified(!1))}),a()()}if(t&2){let e=s();n(6),u(e.formatMessage("kyc_verified_title")),n(),h(e.kycVerifiedAt?7:-1),n(2),u(e.formatMessage("kyc_verified_desc"))}}function Br(t,c){t&1&&m(0,"app-skeleton-loader",15),t&2&&l("rows",2)("columns",1)}function Ur(t,c){if(t&1){let e=T();r(0,"app-attachments",16),y("ngModelChange",function(i){v(e);let _=s(2);return _.stagedDocs=i,C(_.onDocStaged())})("afterSaving",function(){v(e);let i=s(2);return C(i.onKycUploaded())}),a(),r(1,"div",17)(2,"app-dx-outline-button",18),y("onClickEvent",function(){v(e);let i=s(2);return C(i.setVerified(!0))}),a()()}if(t&2){let e=s(2);l("entity",e.customer)("attachableType",e.attachableType)("isMultipleUploads",!0)("isEditMode",!0)("isVisibleLabel",!1)("accept",e.UPLOAD_ACCEPT.IMAGES_PDF)("ngModel",e.stagedDocs)("ngModelOptions",P(11,Or)),n(2),l("buttonType",e.hasDocument?"success":"default")("isVisibleIcon",!0)("disabled",!e.hasDocument)}}function Yr(t,c){if(t&1&&(r(0,"div",2)(1,"div",10)(2,"span",11),m(3,"i",12),a(),r(4,"div",5)(5,"div",13),p(6),a(),r(7,"div",14),p(8),a()()(),f(9,Br,1,2,"app-skeleton-loader",15)(10,Ur,3,12),a()),t&2){let e=s();n(6),u(e.formatMessage("kyc_upload_title")),n(2),u(e.formatMessage("kyc_upload_subtitle")),n(),h(e.isLoading?9:e.customer?10:-1)}}var Qi=(()=>{class t{constructor(){this.UPLOAD_ACCEPT=Hn,this.formatMessage=d,this.customerId=null,this.customerService=x(Yn
1),this.toastNotificationService=x(B),this.isLoading=!1,this.customer=null,this.stagedDocs=null,this.attachableType=b.USER.name}ngOnChanges(e){e.customerId&&(this.customerId?this.loadCustomer(this.customerId):this.customer=null)}get hasDocument(){return!!this.customer?.attachments?.length}get isVerified(){return!!this.customer?.is_kyc_verified}get kycDocument(){return this.customer?.attachments?.[0]??null}get kycVerifiedAt(){return this.kycDocument?.created_at??null}loadCustomer(e){this.isLoading=!0,this.customerService.getById(e).subscribe({next:o=>{this.customer=this.normalize(o?.data??o)},error:()=>{this.customer=null}}).add(()=>{this.isLoading=!1})}normalize(e){let o=e?.attachments;return Ce(Q({},e),{attachments:o?Array.isArray(o)?o:[o]:[]})}onDocStaged(){this.customerId&&this.customer&&this.stagedDocs?.length&&this.attachmentInstance?.syncNotes(this.customer)}onKycUploaded(){this.customerId&&this.loadCustomer(this.customerId)}setVerified(e){this.customerId&&this.customerService.updateKycStatus(this.customerId,e).subscribe({next:()=>{this.customer&&(this.customer.is_kyc_verified=e)},error:()=>{this.toastNotificationService.error(d("something_went_wrong"))}})}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-customer-kyc"]],viewQuery:function(o,i){if(o&1&&fe(dn,5),o&2){let _;he(_=xe())&&(i.attachmentInstance=_.first)}},inputs:{customerId:"customerId"},features:[Tt],decls:3,vars:1,consts:[[1,"card","border-0","rounded-3","overflow-hidden"],[1,"d-flex","align-items-center","gap-3","p-3","app-ck-bg-color-mixin-srgb-success-500-12-transparent"],[1,"card-body"],[1,"d-inline-flex","align-items-center","justify-content-center","rounded-circle","text-white","flex-shrink-0","app-ck-box-32","app-ck-bg-success-600"],[1,"fa-solid","fa-check"],[1,"flex-grow-1","app-ck-min-width-0"],[1,"d-flex","align-items-center","gap-2","flex-wrap"],[1,"fw-bold","app-ck-c-primary-text"],[1,"small","app-ck-c-text-secondary"],["buttonType","normal","text","kyc_reset","title","kyc_reset",1,"flex-shrink-0",3,"onClickEvent"],[1,"d-flex","align-items-center","gap-3","mb-4","pb-3","app-ck-border-bottom-1px-solid-theme-border-color"],[1,"d-inline-flex","align-items-center","justify-content-center","rounded-2","app-icon-medallion","flex-shrink-0","app-ck-box-48","app-ck-fs-1-375rem"],[1,"fa-thin","fa-id-card"],[1,"fw-bold","mb-1"],[1,"small","text-muted","lh-sm"],["type","form",3,"rows","columns"],[3,"ngModelChange","afterSaving","entity","attachableType","isMultipleUploads","isEditMode","isVisibleLabel","accept","ngModel","ngModelOptions"],[1,"d-flex","align-items-center","justify-content-end","flex-wrap","gap-2","mt-3"],["text","kyc_mark_verified_btn","title","kyc_mark_verified_btn","icon","fal fa-circle-check",3,"onClickEvent","buttonType","isVisibleIcon","disabled"]],template:function(o,i){o&1&&(r(0,"div",0),f(1,Fr,11,3,"div",1)(2,Yr,11,3,"div",2),a()),o&2&&(n(),h(i.isVerified?1:2))},dependencies:[Ci,Fe,dn,Vn,Te,Nn,j,oe],styles:[".app-ck-bg-color-mixin-srgb-success-500-12-transparent[_ngcontent-%COMP%]{background-color:color-mix(in srgb,var(--bp-success-500) 12%,transparent)}.app-ck-box-32[_ngcontent-%COMP%]{width:32px;height:32px}.app-ck-bg-success-600[_ngcontent-%COMP%]{background-color:var(--bp-success-600)}.app-ck-min-width-0[_ngcontent-%COMP%]{min-width:0}.app-ck-c-primary-text[_ngcontent-%COMP%]{color:var(--primary-text)}.app-ck-c-text-secondary[_ngcontent-%COMP%]{color:var(--bp-text-secondary)}.app-ck-border-bottom-1px-solid-theme-border-color[_ngcontent-%COMP%]{border-bottom:1px solid var(--theme-border-color)}.app-ck-box-48[_ngcontent-%COMP%]{width:48px;height:48px}.app-ck-fs-1-375rem[_ngcontent-%COMP%]{font-size:1.375rem}"]})}}return t})();var Wr=()=>["name","device_number","serial_number","device_brand.name","device_model.name"],Hr=()=>({maxHeight:360}),jr=()=>({type:"fixedPoint",precision:2});function qr(t,c){t&1&&m(0,"app-skeleton-loader",2),t&2&&l("rows",6)("columns",3)}function $r(t,c){t&1&&m(0,"app-business-context-banner",6)}function Qr(t,c){t&1&&Tn(0)}function Kr(t,c){if(t&1&&I(0,Qr,1,0,"ng-container",37),t&2){s();let e=gn(8);l("ngTemplateOutlet",e)}}function zr(t,c){if(t&1){let e=T();r(0,"dx-button",42),y("onClick",function(){v(e);let i=s(3);return C(i.save(!1))}),a()}if(t&2){let e=s(3);l("text",e.formatMessage("save_draft"))("disabled",e.isSaving)}}function Xr(t,c){if(t&1&&m(0,"dx-button",43),t&2){let e=s(3);l("text",e.formatMessage("create_and_activate"))("disabled",e.isSaving)("useSubmitBehavior",!0)}}function Zr(t,c){if(t&1){let e=T();r(0,"div",38)(1,"dx-button",39),y("onClick",function(){v(e);let i=s(2);return C(i.cancel())}),a(),I(2,zr,1,2,"dx-button",40)(3,Xr,1,3,"dx-button",41),a()}if(t&2){let e=s(2);n(),l("text",e.formatMessage("common_cancel")),n(),l("ngxPermissionsOnly",e.PERMISSION_LIST.RENTAL_CONTRACT_WRITE),n(),l("ngxPermissionsOnly",e.PERMISSION_LIST.RENTAL_CONTRACT_WRITE)}}function Jr(t,c){if(t&1&&m(0,"app-alert-panel",10),t&2){let e=s(2);l("message",e.formatMessage("renewal_prefill_note",e.sourceContract.rental_number))("isVisibleCancelButton",!1)}}function el(t,c){if(t&1&&(m(0,"app-section-title",11),r(1,"div",12)(2,"div",24),m(3,"app-customer-kyc",44),a()()),t&2){let e=s(2);l("title","customer_kyc"),n(3),l("customerId",e.form.get("user_id").value)}}function tl(t,c){if(t&1&&m(0,"dxi-button",45),t&2){let e=s(2);l("options",e.addDeviceOption)}}function il(t,c){if(t&1&&(r(0,"div",46),m(1,"i"),r(2,"span",47),p(3),a(),m(4,"div",48),a()),t&2){let e=c.$implicit,o=s(2);n(),vt(ft("fa-thin ",o.deviceIconClass(e))),n(),l("title",o.deviceTagLabel(e)),n(),u(o.deviceTagLabel(e))}}function nl(t,c){if(t&1&&(r(0,"div"),m(1,"app-rental-device-option",49),a()),t&2){let e=c.$implicit;n(),l("device",e)}}function ol(t,c){if(t&1&&(r(0,"div",24)(1,"div",50)(2,"span",51),p(3),a(),r(4,"span"),m(5,"app-money",52),a()()()),t&2){let e=s(2);n(3),R("",e.formatMessage("monthly_total"),":"),n(2),l("value",e.monthlyTotal)}}function al(t,c){if(t&1){let e=T();r(0,"div",36)(1,"app-save-cancel-footer",53),y("cancelClick",function(){v(e);let i=s(2);return C(i.cancel())})("secondarySaveClick",function(){v(e);let i=s(2);return C(i.save(!1))}),a()()}if(t&2){let e=s(2);n(),l("isOnPopup",!0)("isVisibleHr",!1)("isSaving",e.isSaving)("isVisibleSecondarySave",!0)}}function rl(t,c){if(t&1){let e=T();r(0,"form",5),y("ngSubmit",function(){v(e);let i=s();return C(i.save(!0))}),f(1,$r,1,0,"app-business-context-banner",6),r(2,"app-page-header",7)(3,"span",8),p(4),a(),Ne(5,9),f(6,Kr,1,1,"ng-container"),Ve(),a(),I(7,Zr,4,3,"ng-template",null,0,di),f(9,Jr,1,2,"app-alert-panel",10),m(10,"app-section-title",11),r(11,"div",12)(12,"app-control-container",13)(13,"app-party-selector",14),y("itemClick",function(i){v(e);let _=s();return C(_.onCustomerSelected(i))}),a()(),r(14,"app-control-container",15),m(15,"app-employee-dropdown",16),a(),r(16,"app-control-container",17),m(17,"dx-select-box",18),a()(),f(18,el,4,2),m(19,"app-section-title",11),r(20,"div",12)(21,"app-control-container",19)(22,"dx-tag-box",20),y("onValueChanged",function(i){v(e);let _=s();return C(_.onDevicesChanged(i))}),I(23,tl,1,1,"ng-template",21)(24,il,5,5,"div",22)(25,nl,2,1,"div",23),a()(),f(26,ol,6,2,"div",24),a(),m(27,"app-section-title",11),r(28,"div",12)(29,"app-control-container",25),m(30,"dx-date-box",26),a(),r(31,"app-control-container",27),m(32,"dx-date-box",28),a(),r(33,"app-control-container",29),m(34,"dx-select-box",30),a()(),m(35,"app-section-title",11),r(36,"div",12)(37,"app-control-container",31),m(38,"dx-select-box",32),a(),r(39,"app-control-container",33),m(40,"dx-number-box",34),a(),r(41,"div",24),m(42,"app-terms-field",35),a()(),f(43,al,2,4,"div",36),a()}if(t&2){let e=s();l("formGroup",e.form),n(),h(e.rentalContractId?-1:1),n(),l("recordTitle",e.pageTitle),n(2),u(e.pageTitle),n(2),h(e.isMobileDevice?-1:6),n(3),h(e.isRenewal?9:-1),n(),l("title","contract_information"),n(2),l("label",e.formatMessage("user_customer_name"))("errorMsg",e.formatMessage("common_error_messages_customer_required")),n(),l("entity",e.ENTITIES.RENTAL_CONTRACT.name)("isCardLayout",!0)("isEditMode",!0)("showCrateButton",!0),n(),l("label",e.formatMessage("common_assignee")),n(),l("isEditMode",!0),n(),l("label",e.formatMessage("source")),n(),l("items",e.leadSources)("placeholder",e.formatMessage("select_source"))("showClearButton",!0),n(),h(e.form.get("user_id").value?18:-1),n(),l("title","add_devices"),n(2),l("label",e.formatMessage("available_devices"))("tooltipText","rental_contract_devices_help"),n(),l("dataSource",e.pickerDevices)("value",e.selectedDeviceIds)("searchEnabled",!0)("searchExpr",P(63,Wr))("showSelectionControls",!0)("hideSelectedItems",!1)("multiline",!0)("placeholder",e.formatMessage("search_and_select_available_devices"))("noDataText",e.formatMessage("no_devices_available"))("dropDownOptions",P(64,Hr)),n(),l("ngxPermissionsOnly",e.PERMISSION_LIST.RENTAL_DEVICE_MANAGE),n(),l("dxTemplateOf","deviceTagTemplate"),n(),l("dxTemplateOf","deviceItemTemplate"),n(),h(e.monthlyTotal>0?26:-1),n(),l("title","dates_and_renewal"),n(2),l("label",e.formatMessage("contract_start_date"))("errorMsg",e.formatMessage("contract_start_date_required")),n(),l("dateSerializationFormat",e.DATETIME_SERIALIZATION_FORMAT)("isValid",e.form.get("start_date").valid||!e.form.get("start_date").touched),n(),l("label",e.formatMessage("contract_end_date"))("tooltipText","rental_contract_end_date_help"),n(),l("dateSerializationFormat",e.DATETIME_SERIALIZATION_FORMAT)("min",e.form.get("start_date").value),n(),l("label",e.formatMessage("renewal_type"))("tooltipText","rental_contract_renewal_type_help"),n(),l("items",e.RENEWAL_TYPES),n(),l("title","billing"),n(2),l("label",e.formatMessage("payment_frequency"))("errorMsg",e.formatMessage("payment_frequency_required"))("tooltipText","rental_contract_payment_frequency_help"),n(),l("items",e.PAYMENT_FREQUENCY_LIST)("displayExpr",e.frequencyLabel)("placeholder",e.formatMessage("select_frequency"))("isValid",e.form.get("payment_frequency").valid||!e.form.get("payment_frequency").touched),n(),l("label",e.formatMessage("deposit_amount"))("tooltipText","rental_contract_deposit_help"),n(),l("min",0)("format",P(65,jr)),n(2),l("defaultText",e.defaultTermAndCondition),n(),h(e.isMobileDevice?43:-1)}}function ll(t,c){if(t&1){let e=T();r(0,"div",56)(1,"dx-scroll-view",57),m(2,"app-rental-device-form",58),a(),r(3,"app-save-cancel-footer",59),y("saveClick",function(){v(e);let i=s(2);return C(i.saveNewDevice())})("cancelClick",function(){v(e);let i=s(2);return C(i.isVisibleAddDevicePopup=!1)}),a()()}if(t&2){let e=s(2);n(2),l("form",e.addDeviceForm),n(),l("isSaving",e.isSavingDevice)("isOnPopup",!0)("isVisibleHr",!1)("useSubmitBehavior",!1)("saveText","common_create")}}function sl(t,c){if(t&1){let e=T();r(0,"dx-popup",54),W("visibleChange",function(i){v(e);let _=s();return G(_.isVisibleAddDevicePopup,i)||(_.isVisibleAddDevicePopup=i),C(i)}),I(1,ll,4,6,"div",55),a()}if(t&2){let e=s();Y("visible",e.isVisibleAddDevicePopup),l("width",620)("maxWidth","95vw")("height","auto")("maxHeight","90vh")("showTitle",!0)("title",e.formatMessage("add_new_device"))("dragEnabled",!1)("showCloseButton",!0),n(),l("dxTemplateOf","content")}}var ii=(()=>{class t{get isMobileDevice(){return this.userDeviceService.isMobileDevice()}get pageTitle(){if(this.rentalContractId)return`${d("edit_rental")} ${this.rentalContract?.rental_number||""}`.trim();let e=this.form?.getRawValue().rental_number;return e?`${d("create_new_rental_contract")} - ${e}`:d("create_new_rental_contract")}get isRenewal(){return!this.rentalContractId&&!!this.sourceContract}get selectedDeviceIds(){return this.form?.get("device_ids")?.value||[]}get selectedDevices(){return this.selectedDeviceIds.map(e=>{let o=this.availableDevices.find(_=>_.id===e);if(o)return o;let i=(this.rentalContract||this.sourceContract)?.items?.find(_=>_.rental_device_id===e);return i?.rental_device||{id:e,name:i?.device_name_snapshot,device_number:i?.device_number_snapshot,rental_rate_monthly:i?.unit_price}}
1).filter(Boolean)}refreshPickerDevices(){let e=this.availableDevices.map(i=>i.id),o=this.selectedDevices.filter(i=>i&&!e.includes(i.id));this.pickerDevices=[...this.availableDevices,...o]}onDevicesChanged(e){this.form.patchValue({device_ids:e.value||[]}),this.syncDepositTotal()}syncDepositTotal(){this.form?.patchValue({deposit_amount:this.depositTotal})}get monthlyTotal(){return this.selectedDevices.reduce((e,o)=>e+(+o.rental_rate_monthly||0),0)}get depositTotal(){return this.selectedDevices.reduce((e,o)=>e+(+o.rental_deposit||0),0)}deviceTagLabel(e){let o=e?.device_number?`${e.device_number} \xB7 `:"",i=[e?.device_brand?.name,e?.device_model?.name].filter(Boolean).join(" ");return`${o}${i||e?.name||""}`}constructor(e,o,i){this.fb=e,this.rentalContractService=o,this.rentalDeviceService=i,this.defaultTermAndCondition=null,this.formatMessage=d,this.ENTITIES=b,this.entityCreatedService=x(Pi),this.router=x(Je),this.activatedRoute=x(te),this.toastNotificationService=x(B),this.loaderService=x(Ot),this.leadSourceService=x(wi),this.generalSettingDataService=x(fi),this.termAndConditionService=x(to),this.tableSequenceNumberService=x(Yo),this.userDeviceService=x(K),this.destroyRef=x(O),this.isSaving=!1,this.rentalContractId=null,this.rentalContract=null,this.createdRentalContract=null,this.renewFromId=null,this.sourceContract=null,this.availableDevices=[],this.isVisibleAddDevicePopup=!1,this.isSavingDevice=!1,this.addDeviceOption={icon:"add",type:"default",stylingMode:"text",hint:d("add_new_device"),onClick:()=>this.openAddDevicePopup()},this.PAYMENT_FREQUENCY_LIST=It,this.BILLING_MODE_LIST=At.map(_=>({id:_.id,label:ct(_.id)})),this.RENEWAL_TYPES=Rt.map(_=>({id:_.id,label:dt(_.id)})),this.leadSources=[],this.frequencyLabel=st,this.DATETIME_SERIALIZATION_FORMAT=_i,this.PERMISSION_LIST=g,this.pickerDevices=[],this.deviceIconClass=Ei}openAddDevicePopup(){this.addDeviceForm=this.fb.group({name:[null,[V.required]],device_brand_id:[null],device_model_id:[null],serial_number:[null],rental_rate_monthly:[0,[V.required,V.min(0)]],rental_deposit:[0,[V.min(0)]],rental_status:[z.AVAILABLE],storage_location_id:[null],accessories:[[]],comment:[null]}),this.isVisibleAddDevicePopup=!0}saveNewDevice(){if(!this.addDeviceForm||this.addDeviceForm.invali
1d){this.addDeviceForm?.markAllAsTouched();return}this.isSavingDevice=!0,this.rentalDeviceService.create(this.addDeviceForm.value).pipe(S(this.destroyRef)).subscribe({next:e=>{let o=e?.data??e;this.availableDevices=[o,...this.availableDevices],this.form.patchValue({device_ids:[...this.selectedDeviceIds,o.id]}),this.refreshPickerDevices(),this.syncDepositTotal(),this.toastNotificationService.success(d("rental_device_created_successfully")),this.isVisibleAddDevicePopup=!1},error:()=>{this.toastNotificationService.error(d("something_went_wrong"))}}).add(()=>{this.isSavingDevice=!1})}ngOnInit(){this.leadSourceService.getListByQuery().subscribe({next:e=>this.leadSources=e??[],error:e=>console.error(e)}),this.activatedRoute.params.pipe(S(this.destroyRef)).subscribe(e=>{this.rentalContractId=e.id?+e.id:null;let o=this.activatedRoute.snapshot.queryParamMap.get("renewFrom");this.renewFromId=!this.rentalContractId&&o?+o:null,this.initForm(),this.loadAvailableDevices()})}initForm(){this.form=this.fb.group({id:[null],rental_number:[null],user_id:[null,[V.required]],source_id:[null],assignee_id:[null],start_date:[new Date,[V.required]],end_date:[null],renewal_type:["fixed"],payment_frequency:["Monthly",[V.required]],billing_generation_mode:["automatic"],deposit_amount:[0],term_and_condition:[null],device_ids:[[]]}),this.rentalContractId?this.rentalContractService.getDetailById(this.rentalContractId).pipe(this.form?this.loaderService.withLoader():oi).subscribe({next:e=>{this.rentalContract=new Re(e),this.form.patchValue(Ce(Q({},this.rentalContract),{device_ids:this.rentalContract.items?.map(o=>o.rental_device_id).filter(Boolean)||[]})),this.refreshPickerDevices()},error:()=>{this.toastNotificationService.error(d("something_went_wrong")),this.router.navigate(["/rentals/list"])}}):(this.applyDefaultsFromSettings(),this.applyNextRentalNumber(),this.renewFromId?this.prefillFromRenewSource(this.renewFromId):this.applyDefaultTermAndCondition())}applyNextRentalNumber(){this.tableSequenceNumberService.getListByQuery({name:Bn.RENTAL_CONTRACT.name}).pipe(S(this.destroyRef)).subscribe({next:e=>this.form.patchValue({rental_number:e?.[0]?.current_value??null}),error:e=>console.error(e)})}applyDefaultTermAndCondition(){this.termAndConditionService.getByTypeId({type_id:Un.RENTAL_CONTRACT}).pipe(S(this.destroyRef)).subscribe({next:e=>{this.defaultTermAndCondition=e?.text??"",this.form.patchValue({term_and_condition:this.defaultTermAndCondition})},error:e=>console.error(e)})}prefillFromRenewSource(e){this.rentalContractService.getDetailById(e).pipe(this.loaderService.withLoader()).subscribe({next:o=>{let i=new Re(o);this.sourceContract=i,this.form.patchValue(Ce(Q({},i),{id:null,rental_number:this.form.getRawValue().rental_number,start_date:new Date,end_date:null,device_ids:i.items?.filter(_=>!_.returned_at).map(_=>_.rental_device_id).filter(Boolean)||[]})),this.refreshPickerDevices()},error:()=>{this.toastNotificationService.error(d("something_went_wrong"))}})}applyDefaultsFromSettings(){let e=this.generalSettingDataService.getGeneralSettingBySettingType(Zt.RENTAL_SETTINGS);if(!e)return;let o={};e.default_payment_frequency&&(o.payment_frequency=e.default_payment_frequency),e.default_renewal_type&&(o.renewal_type=e.default_renewal_type),this.form.patchValue(o)}loadAvailableDevices(){this.rentalDeviceService.getListByQuery({rental_status:z.AVAILABLE,per_page:500}).subscribe({next:e=>{let o=[];Array.isArray(e)?o=e:e?.data&&Array.isArray(e.data)&&(o=e.data),this.availableDevices=o.filter(i=>i.rental_status?.toLowerCase()===z.AVAILABLE),this.refreshPickerDevices()},error:()=>{this.toastNotificationService.error(d("something_went_wrong"))}})}onCustomerSelected(e){e?.id&&this.form.patchValue({user_id:e.id})}onAssigneeSelected(e){this.form.patchValue({assignee_id:e?.id||null})}save(e=!1){if(this.form.invalid){this.form.markAllAsTouched();return}if(e&&this.isRenewal&&this.selectedDeviceIds.filter(yt=>!this.availableDevices.some(ni=>ni.id===yt)).length){this.toastNotificationService.warning(d("renewal_return_devices_first",this.sourceContract.rental_number));return}this.isSaving=!0;let ze=this.form.value,{device_ids:o}=ze,i=Cn(ze,["device_ids"]),_=(o||[]).map(ue=>this.availableDevices.find(yt=>
1yt.id===ue)).filter(Boolean).map(ue=>({rental_device_id:ue.id,unit_price:ue.rental_rate_monthly??0})),L=!!this.rentalContractId,_t=L?e?A.ACTIVE:this.rentalContract?.status:e?A.ACTIVE:A.DRAFT,Ke=Q(Ce(Q({},i),{status:_t}),!L&&e?{items:_}:{});(this.rentalContractId?this.rentalContractService.update(Ke):this.rentalContractService.create(Ke)).subscribe({next:ue=>{this.rentalContractId&&this.toastNotificationService.success(d("contract_updated_successfully")),this.rentalContractId?this.router.navigate(["/rentals/list"]):(this.createdRentalContract=new Re(ue),this.openEntityCreated())},error:()=>{this.toastNotificationService.error(d("something_went_wrong"))}}).add(()=>{this.isSaving=!1})}openEntityCreated(){this.entityCreatedService.show({config:Vi[b.RENTAL_CONTRACT.name],entityId:this.createdRentalContract?.id,summary:[{label:d("contract_number"),value:this.createdRentalContract?.rental_number},{label:d("common_customer"),value:this.createdRentalContract?.user?.name}].filter(e=>!!e.value)})}cancel(){this.router.navigate(["/rentals/list"])}static{this.\u0275fac=function(o){return new(o||t)(X(ge),X(F),X(Ie))}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-contract-form"]],decls:4,vars:3,consts:[["rentalFormActions",""],[1,"form-container","d-flex","flex-column","h-100"],["type","form",3,"rows","columns"],[3,"formGroup"],["appPhoneMode","fullscreen",3,"visible","width","maxWidth","height","maxHeight","showTitle","title","dragEnabled","showCloseButton"],[3,"ngSubmit","formGroup"],["entity","route_title_rental_contract"],[3,"recordTitle"],["heading","",1,"fs-page-title","fw-semibold","text-truncate"],["ngProjectAs","[actions]",5,["","actions",""]],["iconBeforeMessage","fa-solid fa-circle-info",3,"message","isVisibleCancelButton"],[1,"mb-3",3,"title"],[1,"row","mb-5"],["name","user_id",1,"col-12","col-md-6",3,"label","errorMsg"],["formControlName","user_id",3,"itemClick","entity","isCardLayout","isEditMode","showCrateButton"],["name","assignee_id",1,"col-12","col-md-6",3,"label"],["formControlName","assignee_id",3,"isEditMode"],["name","source_id",1,"col-12","col-md-6",3,"label"],["formControlName","source_id","displayExpr","name","valueExpr","id","stylingMode","outlined",3,"items","placeholder","showClearButton"],["name","device_ids",1,"col-12","col-md-8","col-lg-6","col-xxl-5",3,"label","tooltipText"],["valueExpr","id","displayExpr","name","searchMode","contains","applyValueMode","instantly","stylingMode","outlined","itemTemplate","deviceItemTemplate","tagTemplate","deviceTagTemplate",1,"dx-tag-box-scroll",3,"onValueChanged","dataSource","value","searchEnabled","searchExpr","showSelectionControls","hideSelectedItems","multiline","placeholder","noDataText","dropDownOptions"],[3,"ngxPermissionsOnly"],["class","dx-tag-content d-flex align-items-center gap-2",4,"dxTemplate","dxTemplateOf"],[4,"dxTemplate","dxTemplateOf"],[1,"col-12"],["name","start_date",1,"col-sm-12","col-md-6","col-lg-4",3,"label","errorMsg"],["formControlName","start_date","type","date","stylingMode","outlined",3,"dateSerializationFormat","isValid"],["name","end_date",1,"col-sm-12","col-md-6","col-lg-4",3,"label","tooltipText"],["formControlName","end_date","type","date","stylingMode","outlined",3,"dateSerializationFormat","min"],["name","renewal_type",1,"col-sm-12","col-md-6","col-lg-4",3,"label","tooltipText"],["formControlName","renewal_type","displayExpr","label","valueExpr","id","stylingMode","outlined",3,"items"],["name","payment_frequency",1,"col-sm-12","col-md-6","col-lg-4",3,"label","errorMsg","tooltipText"],["formControlName","payment_frequency","stylingMode","outlined",3,"items","displayExpr","placeholder","isValid"],["name","deposit_amount",1,"col-sm-12","col-md-6","col-lg-4",3,"label","tooltipText"],["formControlName","deposit_amount","stylingMode","outlined",3,"min","format"],["formControlName","term_and_condition",3,"defaultText"],[1,"app-form-actions-sticky"],[4,"ngTemplateOutlet"],[1,"d-flex","flex-row","justify-content-end","gap-2"],["stylingMode","outlined","type","normal",3,"onClick","text"],["stylingMode","outlined","type","normal",3,"text","disabled","onClick",4,"ngxPermissionsOnly"],["type","default",3,"text","disabled","useSubmitBehavior",4,"ngxPermissionsOnly"],["stylingMode","outlined","type","normal",3,"onClick","text","disabled"],["type","default",3,"text","disabled","useSubmitBehavior"],[3,"customerId"],["location","after","name","addDevice",3,"options"],[1,"dx-tag-content","d-flex","align-items-center","gap-2"],[1,"text-truncate",3,"title"],[1,"dx-tag-remove-button"],[3,"device"],[1,"d-flex","justify-content-end","small","fw-semibold"],[1,"text-muted","me-2"],[3,"value"],["saveText","create_and_activate","secondarySaveText","save_draft",3,"cancelClick","
1secondarySaveClick","isOnPopup","isVisibleHr","isSaving","isVisibleSecondarySave"],["appPhoneMode","fullscreen",3,"visibleChange","visible","width","maxWidth","height","maxHeight","showTitle","title","dragEnabled","showCloseButton"],["class","p-3 d-flex flex-column h-100",4,"dxTemplate","dxTemplateOf"],[1,"p-3","d-flex","flex-column","h-100"],[1,"flex-grow-1","min-height-0"],[3,"form"],[3,"saveClick","cancelClick","isSaving","isOnPopup","isVisibleHr","useSubmitBehavior","saveText"]],template:function(o,i){o&1&&(r(0,"div",1),f(1,qr,1,2,"app-skeleton-loader",2),f(2,rl,44,66,"form",3),f(3,sl,2,10,"dx-popup",4),a()),o&2&&(n(),h(!i.form&&i.rentalContractId?1:-1),n(),h(i.form?2:-1),n(),h(i.isVisibleAddDevicePopup?3:-1))},dependencies:[ce,H,pt,Fe,co,Nt,Pt,Vt,ie,Di,kt,de,Mi,Ii,re,ae,vi,Qi,rt,at,Ye,xi,hi,Ee,Se,be,Oo,se,le,me,pe,Ge,J,ke,et,Te,Pe,Oe,Le,St,bt,ne,j,wn],encapsulation:2})}}return t})();var cl=()=>["name","device_number","serial_number","device_brand.name","device_model.name"];function dl(t,c){t&1&&m(0,"app-skeleton-loader",1)}function pl(t,c){if(t&1){let e=T();r(0,"app-page-header",10),y("editClick",function(){v(e);let i=s(3);return C(i.editContract())}),r(1,"span",11),p(2),a(),r(3,"span",12),p(4),a(),r(5,"app-context-menu",13),y("contextMenuItemCancelClick",function(){v(e);let i=s(3);return C(i.onCloseContextMenuOption())})("contextMenuItemClick",function(i){v(e);let _=s(3);return C(_.onContextMenuItemClick(i))}),a()()}if(t&2){let e=s(3);l("recordTitle",e.rentalContract.rental_number)("canEdit",e.userPermissionList.includes(e.PERMISSION_LIST.RENTAL_CONTRACT_WRITE)),n(),l("ngClass",e.getStatusClass(e.rentalContract.status)),n(),R(" ",e.statusLabel(e.rentalContract.status)," "),n(2),u(e.rentalContract.rental_number),n(),l("buttonText",e.formatMessage("rental_contract_actions"))("contextMenuItems",e.rentalContractContextMenu)("entityName",e.ENTITIES.RENTAL_CONTRACT.name)("entity",e.rentalContract)("isIconOnly",e.isMobileDevice)("isOnDetailPage",!0)("mobileSheet",!0)("showDocuments",!0)}}function ml(t,c){if(t&1&&f(0,pl,6,13,"app-page-header",9),t&2){let e=s(2);h(e.rentalContract&&e.rentalContract.id?0:-1)}}function _l(t,c){if(t&1){let e=T();r(0,"div",4)(1,"app-responsive-tabs",8),y("tabChange",function(i){v(e);let _=s();return C(_.selectTab(i))}),I(2,ml,1,1,"ng-template",null,0,di),a()()}if(t&2){let e=s();n(),l("tabs",e.tabs)("selectedIndex",e.selectedTabIndex)("mobilePillTabs",!0)("mobileMenuTitle",e.rentalContract==null?null:e.rentalContract.rental_number)("mobileMenuIcon",e.ENTITY_ICONS.RENTAL_CONTRACT.solid)}}function ul(t,c){if(t&1){let e=T();r(0,"app-unified-payment-modal",14),y("paymentClose",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())})("paymentSuccess",function(i){v(e);let _=s();return C(_.onPaymentSuccess(i))}),a()}if(t&2){let e=s();l("isVisiblePopup",e.isVisibleUnifiedPaymentModal)("entity",e.selectedContract)("entityType",e.ENTITIES.RENTAL_CONTRACT.name)}}function vl(t,c){if(t&1&&(r(0,"div")(1,"div",25)(2,"span"),p(3),a(),m(4,"div",26),a()()),t&2){let e=c.$implicit;n(3),U("",e.name,"",e.device_number?" \xB7 "+e.device_number:"")}}function Cl(t,c){if(t&1&&(r(0,"div"),m(1,"app-rental-device-option",27),a()),t&2){let e=c.$implicit;n(),l("device",e)}}function fl(t,c){if(t&1){let e=T();r(0,"app-control-container",21)(1,"dx-tag-box",23),W("valueChange",function(i){v(e);let _=s(3);return G(_.selectedDeviceIds,i)||(_.selectedDeviceIds=i),C(i)}),I(2,vl,5,2,"div",24)(3,Cl,2,1,"div",24),a()()}if(t&2){let e=s(3);l("label",e.formatMessage("assign_devices")),n(),Y("value",e.selectedDeviceIds),l("items",e.availableDevices)("searchEnabled",!0)("searchExpr",P(9,cl))("showSelectionControls",!0)("placeholder",e.formatMessage("select_devices_to_assign")),n(),l("dxTemplateOf","deviceTagTemplate"),n(),l("dxTemplateOf","deviceItemTemplate")}}function hl(t,c){if(t&1){let e=T();r(0,"div",17)(1,"dx-scroll-view",18)(2,"app-control-container",19)(3,"dx-select-box",20),W("valueChange",function(i){v(e);let _=s(2);return G(_.selectedStatusValue,i)||(_.selectedStatusValue=i),C(i)}),a()(),f(4,fl,4,10,"app-control-container",21),a(),r(5,"app-save-cancel-footer",22),y("cancelClick",function(){v(e);let i=s(2);return C(i.onCloseContextMenuOption())})("saveClick",function(){v(e);let i=s(2);return C(i.doUpdateStatus())}),a()()}if(t&2){let e=s(2);n(2),l("label",e.formatMessage("common_status")),n(),Y("value",e.selectedStatusValue),l("items",e.allowedStatusList)("displayExpr",e.statusLabel),n(),h(e.showDevicePicker?4
1:-1),n(),l("isSaving",e.isSaving)("isOnPopup",!0)}}function xl(t,c){if(t&1){let e=T();r(0,"dx-popup",15),W("visibleChange",function(i){v(e);let _=s();return G(_.isVisibleStatusUpdatePopup,i)||(_.isVisibleStatusUpdatePopup=i),C(i)}),y("onHidden",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())}),I(1,hl,6,7,"div",16),a()}if(t&2){let e=s();Y("visible",e.isVisibleStatusUpdatePopup),l("width","95vw")("maxWidth",480)("maxHeight","90vh")("showTitle",!0)("title",e.formatMessage("update_rental_status"))("dragEnabled",!1)("showCloseButton",!0),n(),l("dxTemplateOf","content")}}function yl(t,c){if(t&1){let e=T();r(0,"app-rental-deposit-popup",28),y("depositChange",function(){v(e);let i=s();return C(i.onDepositCollected())})("popupClose",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())}),a()}if(t&2){let e=s();l("isVisiblePopup",e.isVisibleDepositPopup)("rentalContract",e.selectedContract)}}var Ki=(()=>{class t{constructor(){this.formatMessage=d,this.statusLabel=lt,this.ENTITIES=b,this.router=x(Je),this.activatedRouter=x(te),this.userSessionService=x(k),this.userDeviceService=x(K),this.isEmployee=this.userSessionService.isEmployee(),this.userPermissionList=this.userSessionService.userPermissionList(),this.rentalContractService=x(F),this.rentalDeviceService=x(Ie),this.loaderService=x(Ot),this.toastNotificationService=x(B),this.destroyRef=x(O),this.rentalContract=null,this.rentalContractId=null,this.selectedTabIndex=null,this.tabs=[],this.ENTITY_ICONS=$e,this.PERMISSION_LIST=g,this.RENTAL_CONTRACT_CONTEXT_MENU_LIST=q,this.rentalContractContextMenu=[],this.currentContextMenuAction=null,this.selectedContract=null,this.isVisibleUnifiedPaymentModal=!1,this.isVisibleStatusUpdatePopup=!1,this.isVisibleDepositPopup=!1,this.selectedStatusValue=null,this.isSaving=!1,this.availableDevices=[],this.selectedDeviceIds=[],this.ALLOWED_TRANSITIONS={[A.DRAFT]:[A.CONFIRMED,A.CANCELLED],[A.CONFIRMED]:[A.ACTIVE,A.CANCELLED],[A.ACTIVE]:[A.PAUSED,A.OVERDUE,A.COMPLETED,A.CANCELLED],[A.PAUSED]:[A.ACTIVE,A.CANCELLED],[A.OVERDUE]:[A.ACTIVE,A.COMPLETED,A.CANCELLED]}}get isMobileDevice(){return this.userDeviceService.isMobileDevice()}get allowedStatusList(){return this.ALLOWED_TRANSITIONS[this.selectedContract?.status]||[]}get showDevicePicker(){return this.selectedContract?.status===A.DRAFT&&this.selectedStatusValue===A.CONFIRMED}editContract(){this.router.navigate([`/rentals/${this.rentalContractId}/details`],{queryParams:{edit:1}})}ngOnInit(){this.buildContextMenu(),this.activatedRouter.params.pipe(S(this.destroyRef)).subscribe({next:e=>{this.rentalContractId=+e.rental_contract_id||null,this.rentalContractId&&(this.activatedRouter.firstChild?.data.pipe(S(this.destroyRef)).subscribe({next:o=>{this.selectedTabIndex=o.tab_index},error:o=>console.error(o)}),this.tabs=[{id:0,text:d("overview"),path:`/rentals/${this.rentalContractId}/overview`,icon:ot.FOLDER_SEARCH.light,visible:!0},{id:1,text:d("common_details"),path:`/rentals/${this.rentalContractId}/details`,icon:Wn.INFO.light,visible:this.userPermissionList.includes(g.RENTAL_CONTRACT_LIST)},{id:2,text:d("devices"),path:`/rentals/${this.rentalContractId}/devices`,icon:ot.LAPTOP.light,visible:this.userPermissionList.includes(g.RENTAL_CONTRACT_LIST)},{id:3,text:d("payments"),path:`/rentals/${this.rentalContractId}/payments`,icon:$e.INVOICE.light,visible:this.userPermissionList.includes(g.RENTAL_CONTRACT_LIST)},{id:4,text:d("deposits"),path:`/rentals/${this.rentalContractId}/deposits`,icon:$e.PAYMENT.light,visible:this.userPermissionList.includes(g.RENTAL_CONTRACT_LIST)}],this.loadContractDetail())},error:e=>console.error("Can't load rental contract details ",e)}),this.rentalContractService.currentContract$.pipe(S(this.destroyRef)).subscribe({next:e=>{e?.id&&(this.rentalContract=e,this.buildContextMenu())},error:e=>console.error(e)})}loadContractDetail(){this.rentalContractService.refreshDetail(this.rentalContractId).pipe(this.loaderService.withLoader()).subscribe({next:()=>{},error:()=>{this.toastNotificationService.error(d("something_went_wrong")),this.router.navigate(["/rentals/list"])}})}getStatusClass(e){return Ut(e)}selectTab(e){this.selectedTabIndex=e.itemIndex}buildContextMenu(){this.rentalContractContextMenu=[{name:q.ADD_PAYMENT,icon:$e.PAYMENT.light,visible:this.isEmployee&&this.userPermissionList.includes(g.PAYMENT_WRITE),isDisabled:e=>e?.status===A.CANCELLED,locale_key:d("common_add_payment")},{name:q.UPDATE_STATUS,icon:ot.CIRCLE.light,visible:this.isEmployee&&this.userPermissionList.includes(g.RENTAL_CONTRACT_WRITE),isDisabled:e=>!this.ALLOWED_TRANSITIONS[e?.status]?.length,locale_key:d("update_rental_status")},{name:q.RENEW,icon:Z.RENEW.light,visible:this.isEmployee&&this.userPermissionList.includes(g.RENTAL_CONTRACT_WRITE),isDisabled:e=>e?.status===A.CANCELLED,locale_key:d("renew_contract")},{name:q.DEPOSITS,icon:Z.DEPOSIT.light,visible:this.isEmployee&&this.userPermissionList.includes(g.RENTAL_CONTRACT_WRITE),isDisabled:e=>e?.status===A.CANCELLED,locale_key:d("collect_deposit")}]}onContextMenuItemClick(e){this.currentContextMenuAction=e.action,this.selectedContract=e.entity||this.rentalContract,this.currentContextMenuAction===q.ADD_PAYMENT?this.isVisibleUnifiedPaymentModal=!0:this.currentContextMenuAction===q.UPDATE_STATUS?(this.selectedStatusValue=null,this.selectedDeviceIds=[],this.availableDevices=[],this.selectedContract.status===A.DRAFT&&this.loadAvailableDevices(),this.isVisibleStatusUpdatePopup=!0):this.currentContextMenuAction===q.RENEW?this.router.navigate(["/rentals/add"],{queryParams:{renewFrom:this.selectedContract.id}}):this.currentContextMenuAction===q.DEPOSITS&&(this.isVisibleDepositPopup=!0)}loadAvailableDevices(){this.rentalDeviceService.getListByQuery({}).pipe(S(this.destroyRef)).subscribe({next:e=>{let o=Array.isArray(e)?e:e?.data||[];this.availableDevices=o.filter(i=>i.rental_status?.toLowerCase()===z.AVAILABLE)},error:()=>{this.toastNotificationService.error(d("something_went_wrong"))}})}doUpdateStatus(){if(!this.selectedStatusValue)return;this.isSaving=!0;let e=this.showDevicePicker&&this.selectedDeviceIds.length>0?this.selectedDeviceIds.map(o=>{let i=this.availableDevices.find(_=>_.id===o);return{rental_device_id:o,unit_price:i?.rental_rate_monthly??0}}):void 0;this.rentalContractService.updateStatus(this.selectedContract.id,this.selectedStatusValue,e).subscribe({next:()=>{this.toastNotificationService.success(d("status_update_success")),this.isVisibleStatusUpdatePopup=!1,this.refreshAfterAction()},error:()=>{this.toastNotificationService.error(d("status_update_error"))}}).add(()=>{this.isSaving=!1})}onPaymentSuccess(e){this.refreshAfterAction(),this.onCloseContextMenuOption()}onCloseContextMenuOption(){this.currentContextMenuAction=null,this.isVisibleUnifiedPaymentModal=!1,this.isVisibleStatusUpdatePopup=!1,this.isVisibleDepositPopup=!1,this.availableDevices=[],this.selectedDeviceIds=[]}refreshAfterAction(){this.rentalContractId&&this.rentalContractService.refreshDetail(this.rentalContractId).subscribe()}onDepositCollected(){this.refreshAfterAction(),this.rentalContractService.n
vendor: 1,503 bytes, line 1
1otifyDepositsChanged()}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-detail"]],decls:7,vars:5,consts:[["subheader",""],["type","detail"],[1,"row"],[1,"col-sm-12","col-md-12","col-lg-12"],[1,"form-height-mobile-view"],[3,"isVisiblePopup","entity","entityType"],["appPhoneMode","",3,"visible","width","maxWidth","maxHeight","showTitle","title","dragEnabled","showCloseButton"],[3,"isVisiblePopup","rentalContract"],["mode","route",3,"tabChange","tabs","selectedIndex","mobilePillTabs","mobileMenuTitle","mobileMenuIcon"],["entityLabel","rental",3,"recordTitle","canEdit"],["entityLabel","rental",3,"editClick","recordTitle","canEdit"],["status","",1,"badge","badge-title",3,"ngClass"],["heading","",1,"fs-page-title","fw-semibold","text-truncate"],["actions","",3,"contextMenuItemCancelClick","contextMenuItemClick","buttonText","contextMenuItems","entityName","entity","isIconOnly","isOnDetailPage","mobileSheet","showDocuments"],[3,"paymentClose","paymentSuccess","isVisiblePopup","entity","entityType"],["appPhoneMode","",3,"visibleChange","onHidden","visible","width","maxWidth","maxHeight","showTitle","title","dragEnabled","showCloseButton"],["class","d-flex flex-column h-100",4,"dxTemplate","dxTemplateOf"],[1,"d-flex","flex-column","h-100"],[1,"flex-grow-1","min-height-0"],["name","status",3,"label"],["stylingMode","outlined",3,"valueChange","value","items","displayExpr"],["name","device_ids",1,"mt-3",3,"label"],[3,"cancelClick","
1saveClick","isSaving","isOnPopup"],["displayExpr","name","valueExpr","id","searchMode","contains","itemTemplate","deviceItemTemplate","tagTemplate","deviceTagTemplate",3,"valueChange","value","items","searchEnabled","searchExpr","showSelectionControls","placeholder"],[4,"dxTemplate","dxTemplateOf"],[1,"dx-tag-content"],[1,"dx-tag-remove-button"],[3,"device"],[3,"depositChange","popupClose","isVisiblePopup","rentalContract"]],template:function(o,i){o&1&&(f(0,dl,1,0,"app-skeleton-loader",1),r(1,"div",2)(2,"div",3),f(3,_l,4,5,"div",4),a()(),f(4,ul,1,3,"app-unified-payment-modal",5),f(5,xl,2,9,"dx-popup",6),f(6,yl,1,2,"app-rental-deposit-popup",7)),o&2&&(h(!(i.rentalContract!=null&&i.rentalContract.id)&&i.rentalContractId?0:-1),n(3),h(i.rentalContractId?3:-1),n(),h(i.selectedContract!=null&&i.selectedContract.id&&i.isVisibleUnifiedPaymentModal?4:-1),n(),h(i.isVisibleStatusUpdatePopup&&(i.selectedContract!=null&&i.selectedContract.id)?5:-1),n(),h(i.isVisibleDepositPopup&&(i.selectedContract!=null&&i.selectedContract.id)?6:-1))},dependencies:[ce,Fe,Oi,pt,De,Li,se,le,ie,me,pe,de,re,ae,rt,at,Ye,J,Ae,j,pi,ne],encapsulation:2})}}return t})();function Tl(t,c){if(t&1&&m(0,"app-status-badge",1),t&2){let e=s();l("status",e.activity.properties.old.status)}}function gl(t,c){t&1&&(r(0,"span",2),p(1,"\u2014"),a())}function El(t,c){if(t&1&&m(0,"app-status-badge",1),t&2){let e=s();l("status",e.activity.properties.attributes.status)}}function bl(t,c){t&1&&(r(0,"span",2),p(1,"\u2014"),a())}var aa=(()=>{class t extends Wt{loadFields(){}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=we(t)))(i||t)}})()}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-contract-status-activity"]],features:[Me],decls:6,vars:2,consts:[[1,"d-flex","align-items-center","my-2"],["kind","rental","size","xs",3,"status"],[1,"text-muted","small"],[1,"fa-thin","fa-arrow-right","mx-2","text-muted"]],template:function(o,i){o&1&&(r(0,"div",0),f(1,Tl,1,1,"app-status-badge",1)(2,gl,2,0,"span",2),m(3,"i",3),f(4,El,1,1,"app-status-badge",1)(5,bl,2,0,"span",2),a()),o&2&&(n(),h(!(i.activity.properties==null||i.activity.properties.old==null)&&i.activity.properties.old.status?1:2),n(3),h(!(i.activity.properties==null||i.activity.properties.attributes==null)&&i.activity.properties.attributes.status?4:5))},dependencies:[_e],encapsulation:2})}}return t})();function Sl(t,c){if(t&1&&(r(0,"span",3),p(1),a()),t&2){let e=s();n(),U(" \xB7 ",e.formatMessage("via")," ",e.activity.properties.attributes.payment_type.name)}}var ra=(()=>{class t extends Wt{constructor(){super(...arguments),this.formatMessage=d,this.RENTAL_ACTIVITY_EVENT_TYPES=D}loadFields(){}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=we(t)))(i||t)}})()}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-deposit-activity"]],features:[Me],decls:5,vars:3,consts:[[1,"small"],[1,"fw-semibold"],[3,"value"],[1,"text-muted"]],template:function(o,i){o&1&&(r(0,"div",0),p(1),r(2,"span",1),m(3,"app-money",2),a(),f(4,Sl,2,2,"span",3),a()),o&2&&(n(),R(" ",i.formatMessage("common_amount"),": "),n(2),l("value",i.activity.properties==null||i.activity.properties.attributes==null?null:i.activity.properties.attributes.amount),n(),h(!(i.activity.properties==null||i.activity.properties.attributes==null||i.activity.properties.attributes.payment_type==null)&&i.activity.properties.attributes.payment_type.name?4:-1))},dependencies:[j,H],encapsulation:2})}}return t})();function Dl(t,c){if(t&1&&(r(0,"span",2),p(1),a()),t&2){let e=s(2);n(),U(" \xB7 ",(e.activity.properties==null||e.activity.properties.attributes==null?null:e.activity.properties.attributes.device_brand)||"\u2014","",!(e.activity.properties==null||e.activity.properties.attributes==null)&&e.activity.properties.attributes.device_model?" "+e.activity.properties.attributes.device_model:"")}}function Il(t,c){if(t&1&&(r(0,"span",2),p(1," \xB7 "),m(2,"app-money",3),p(3),a()),t&2){let e=s(2);n(2),l("value",e.activity.properties.attributes.unit_price),n(),u(e.formatMessage("per_month_short"))}}function Al(t,c){if(t&1&&(f(0,Dl,2,2,"span",2),f(1,Il,4,2,"span",2)),t&2){let e=s();h(!(e.activity.properties==null||e.activity.properties.attributes==null)&&e.activity.properties.attributes.device_brand||!(e.activity.properties==null||e.activity.properties.attributes==null)&&e.activity.properties.attributes.device_model?0:-1),n(),h(!(e.activity.properties==null||e.activity.properties.attributes==null)&&e.activity.properties.attributes.unit_price?1:-1)}}function Rl(t,c){if(t&1&&(r(0,"span",2),p(1),M(2,"dateFormat"),a()),t&2){let e=s();n(),U(" \xB7 ",e.formatMessage("returned_on")," ",N(2,2,e.activity.properties.attributes.returned_at,"datetime"))}}var la=(()=>{class t extends Wt{constructor(){super(...arguments),this.formatMessage=d,this.RENTAL_ACTIVITY_EVENT_TYPES=D}loadFields(){}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=we(t)))(i||t)}})()}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-device-activity"]],features:[Me],decls:6,vars:5,consts:[[1,"small"],[1,"fw-semibold"],[1,"text-muted"],[3,"value"]],template:function(o,i){o&1&&(r(0,"div",0),p(1),r(2,"span",1),p(3),a(),f(4,Al,2,2),f(5,Rl,3,5,"span",2),a()),o&2&&(n(),R(" ",i.formatMessage("common_device"),": "),n(2),U("",i.activity.properties==null||i.activity.properties.attributes==null?null:i.activity.properties.attributes.device_name_snapshot,"",!(i.activity.properties==null||i.activity.properties.attributes==null)&&i.activity.properties.attributes.device_number_snapshot?" \xB7 "+i.activity.properties.attributes.device_number_snapshot:""),n(),h(i.activity.event===i.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_ITEM_CREATED?4:-1),n(),h(i.activity.event===i.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_ITEM_RETURNED&&(!(i.activity.properties==null||i.activity.properties.attributes==null)&&i.activity.properties.attributes.returned_at)?5:-1))},dependencies:[j,H,oe],encapsulation:2})}}return t})();function wl(t,c){t&1&&m(0,"div",15)}function Ml(t,c){if(t&1&&(r(0,"span",16),p(1),a()),t&2){let e=s(2);n(),U(" ",e.formatMessage("by")," ",e.activity.causer.display_name||e.activity.causer.name," ")}}function Nl(t,c){if(t&1&&(r(0,"span",17),m(1,"i",18),a()),t&2){let e=s(2);l("title",e.formatMessage("VISIBLE_TO_EMPLOYEES_ONLY"))}}function Vl(t,c){if(t&1&&(r(0,"div"),m(1,"app-assignee-activity",19)(2,"app-comment-activity",20),a()),t&2){let e=s(3);n(),l("activity",e.activity),n(),l("comment",e.activity.properties==null?null:e.activity.properties.comment)}}function Pl(t,c){if(t&1&&(Ne(0),I(1,Vl,3,2,"div",14),Ve()),t&2){let e=s(2);n(),l("ngSwitchCase",e.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_ASSIGNEE_UPDATED)}}function Ll(t,c){if(t&1&&(r(0,"div"),m(1,"app-rental-contract-status-activity",19)(2,"app-comment-activity",20),a()),t&2){let e=s(2);n(),l("activity",e.activity),n(),l("comment",e.activity.properties==null?null:e.activity.properties.comment)}}function Ol(t,c){if(t&1&&(r(0,"div"),m(1,"app-rental-contract-status-activity",19)(2,"app-assignee-activity",19)(3,"app-comment-activity",20),a()),t&2){let e=s(2);n(),l("activity",e.activity),n(),l("activity",e.activity),n(),l("comment",e.activity.properties==null?null:e.activity.properties.comment)}}function kl(t,c){if(t&1&&(r(0,"div"),m(1,"app-entity-updated-activity",19),a()),t&2){let e=s(2);n(),l("activity",e.activity)}}function Fl(t,c){if(t&1&&(r(0,"div"),m(1,"app-entity-created-activity",19),a()),t&2){let e=s(2);n(),l("activity",e.activity)}}function Bl(t,c){if(t&1&&(r(0,"div"),m(1,"app-rental-device-activity",19),a()),t&2){let e=s(2);n(),l("activity",e.activity)}}function Ul(t,c){if(t&1&&(r(0,"div"),m(1,"app-entity-updated-activity",19),a()),t&2){let e=s(2);n(),l("activity",e.activity)}}function Yl(t,c){if(t&1&&(r(0,"div"),m(1,"app-rental-device-activity",19),a()),t&2){let e=s(2);n(),l("activity",e.activity)}}function Gl(t,c){if(t&1&&(r(0,"div"),m(1,"app-entity-delete-activity",19),a()),t&2){let e=s(2);n(),l("activity",e.activity)}}function Wl(t,c){if(t&1&&(r(0,"div"),m(1,"app-rental-deposit-activity",19),a()),t&2){let e=s(2);n(),l("activity",e.activity)}}function Hl(t,c){if(t&1&&(r(0,"div"),m(1,"app-rental-deposit-activity",19),a()),t&2){let e=s(2);n(),l("activity",e.activity)}}function jl(t,c){if(t&1&&(r(0,"div"),m(1,"app-entity-created-activity",19),a()),t&2){let e=s(2);n(),l("activity",e.activity)}}function ql(t,c){if(t&1&&(r(0,"div"),m(1,"app-entity-created-activity",19),a()),t&2){let e=s(2);n(),l("activity",e.activity)}}function $l(t,c){if(t&1&&(r(0,"div"),m(1,"app-entity-created-activity",19),a()),t&2){let e=s(2);n(),l("activity",e.activity)}}function Ql(t,c){if(t&1&&(r(0,"div"),m(1,"app-attachment-activity",19),a()),t&2){let e=s(2);n(),l("activity",e.activity)}}function Kl(t,c){if(t&1&&(r(0,"div"),m(1,"app-attachment-activity",19),a()),t&2){let e=s(2);n(),l("activity",e.activity)}}function zl(t,c){if(t&1&&(r(0,"div",1)(1,"div",2)(2,"div"),m(3,"i"),a(),I(4,wl,1,0,"div",3),a(),r(5,"div",4)(6,"div",5)(7,"div",6)(8,"div",7)(9,"span",8),p(10),a(),I(11,Ml,2,2,"span",9)(12,Nl,2,1,"span",10),a()(),r(13,"div",11),p(14),M(15,"dateFormat"),a()(),r(16,"div",12),I(17,Pl,2,1,"ng-container",13)(18,Ll,3,2,"div",14)(19,Ol,4,3,"div",14)(20,kl,2,1,"div",14)(21,Fl,2,1,"div",14)(22,Bl,2,1,"div",14)(23,Ul,2,1,"div",14)(24,Yl,2,1,"div",14)(25,Gl,2,1,"div",14)(26,Wl,2,1,"div",14)(27,Hl,2,1,"div",14)(28,jl,2,1,"div",14)(29,ql,2,1,"div",14)(30,$l,2,1,"div",14)(31,Ql,2,1,"div",14)(32,Kl,2,1,"div",14),a()()()),t&2){let e=s();n(2),vt(ft("activity-icon ",e.getActivityIconColor()," rounded-circle d-flex align-items-center justify-content-center flex-shrink-0")),n(),vt(ft("fa-thin ",e.getActivityIcon()," text-white")),n(),l("ngIf",!e.isLast),n(6),u(e.getActivityTitle()),n(),l("ngIf",e.activity.causer),n(),l("ngIf",e.isVisibleToEmployeesOnly()),n(2),R(" ",N(15,28,e.activity.created_at,"datetime")," "),n(2),l("ngSwitch",e.activity.event),n(),l("ngIf",e.isEmployee),n(),l("ngSwitchCase",e.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_STATUS_UPDATED),n(),l("ngSwitchCase",e.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_ASSIGNEE_AND_STATUS_UPDATED),n(),l("ngSwitchCase",e.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_UPDATED),n(),l("ngSwitchCase",e.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_CREATED),n(),l("ngSwitchCase",e.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_ITEM_CREATED),n(),l("ngSwitchCase",e.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_ITEM_UPDATED),n(),l("ngSwitchCase",e.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_ITEM_RETURNED),n(),l("ngSwitchCase",e.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_ITEM_DELETED),n(),l("ngSwitchCase",e.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_DEPOSIT_CREATED),n(),l("ngSwitchCase",e.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_DEPOSIT_REFUNDED),n(),l("ngSwitchCase",e.ACTIVITY_EVENT_TYPES.PAYMENT_CREATED),n(),l("ngSwitchCase",e.ACTIVITY_EVENT_TYPES.PAYMENT_UPDATED),n(),l("ngSwitchCase",e.ACTIVITY_EVENT_TYPES.PAYMENT_DELETED),n(),l("ngSwitchCase",e.ACTIVITY_EVENT_TYPES.ATTACHMENT_CREATED),n(),l("ngSwitchCase",e.ACTIVITY_EVENT_TYPES.ATTACHMENT_DELETED)}}var sa=(()=>{class t{constructor(){this.formatMessage=d,this.isLast=!1,this.userSessionService=x(k),this.userDeviceService=x(K),this.isEmployee=this.userSessionService.isEmployee(),this.ACTIVITY_EVENT_TYPES=$,this.RENTAL_ACTIVITY_EVENT_TYPES=D,this.isVisibleTitle=!0}get isMobileDevice(){return this.userDeviceService.isMobileDevice()}ngOnInit(){[D.RENTAL_CONTRACT_ASSIGNEE_UPDATED,D.RENTAL_CONTRACT_ASSIGNEE_AND_STATUS_UPDATED].includes(this.activity.event)&&!this.isEmployee&&(this.isVisibleTitle=!1)}isPaymentRefund(){return this.activity.event===$.PAYMENT_CREATED&&+this.activity?.properties?.attributes?.amount<0}getActivityIcon(){return this.isPaymentRefund()?"fa-money-bill-transfer":{[D.RENTAL_CONTRACT_STATUS_UPDATED]:"fa-arrows-rotate",[D.RENTAL_CONTRACT_ASSIGNEE_UPDATED]:"fa-user-cog",[D.RENTAL_CONTRACT_ASSIGNEE_AND_STATUS_UPDATED]:"fa-arrows-rotate",[D.RENTAL_CONTRACT_UPDATED]:"fa-pen-to-square",[D.RENTAL_CONTRACT_CREATED]:"fa-plus-circle",[D.RENTAL_CONTRACT_ITEM_CREATED]:"fa-laptop",[D.RENTAL_CONTRACT_ITEM_UPDATED]:"fa-pen-to-square",[D.RENTAL_CONTRACT_ITEM_RETURNED]:"fa-rotate-left",[D.RENTAL_CONTRACT_ITEM_DELETED]:"fa-trash",[D.RENTAL_DEPOSIT_CREATED]:"fa-money-bill-transfer",[D.RENTAL_DEPOSIT_REFUNDED]:"fa-rotate-left",[$.PAYMENT_CREATED]:"fa-credit-card",[$.PAYMENT_UPDATED]:"fa-credit-card",[$.PAYMENT_DELETED]:"fa-credit-card",[$.ATTACHMENT_CREATED]:"fa-paperclip",[$.ATTACHMENT_DELETED]:"fa-paperclip"}[this.activity.event]||"fa-circle-info"}getActivityIconColor(){return this.isPaymentRefund()?"activity-icon-orange":xo(this.activity.event,{[$.PAYMENT_DELETED]:"activity-icon-red"})}getActivityTitle(){if(this.isPaymentRefund())return d("PAYMENT_REFUNDED");let e={[D.RENTAL_CONTRACT_STATUS_UPDATED]:"STATUS_CHANGED",[D.RENTAL_CONTRACT_ASSIGNEE_UPDATED]:"ASSIGNEE_CHANGED",[D.RENTAL_CONTRACT_ASSIGNEE_AND_STATUS_UPDATED]:"ASSIGNEE_STATUS_CHANGED",[D.RENTAL_CONTRACT_UPDATED]:"rental_contract_updated",[D.RENTAL_CONTRACT_CREATED]:"rental_contract_created",[D.RENTAL_CONTRACT_ITEM_CREATED]:"rental_device_assigned",[D.RENTAL_CONTRACT_ITEM_UPDATED]:"rental_device_updated",[D.RENTAL_CONTRACT_ITEM_RETURNED]:"rental_device_returned",[D.RENTAL_CONTRACT_ITEM_DELETED]:"rental_device_removed",[D.RENTAL_DEPOSIT_CREATED]:"rental_deposit_collected",[D.RENTAL_DEPOSIT_REFUNDED]:"rental_deposit_refunded",[$.PAYMENT_CREATED]:"PAYMENT_RECEIVED",[$.PAYMENT_UPDATED]:"PAYMENT_UPDATED",[$.PAYMENT_DELETED]:"PAYMENT_DELETED",[$.ATTACHMENT_CREATED]:"ATTACHMENT_ADDED",[$.ATTACHMENT_DELETED]:"ATTACHMENT_DELETED"};return d(e[this.activity.event]||"ACTIVITY")}isVisibleToEmployeesOnly(){return[D.RENTAL_CONTRACT_ASSIGNEE_UPDATED,D.RENTAL_CONTRACT_ASSIGNEE_AND_STATUS_UPDATED].includes(this.activity.event)&&!this.isEmployee}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-activity-list"]],inputs:{activity:"activity",isLast:"isLast"},decls:1,vars:1,consts:[["class","activity-card-wrapper d-flex gap-2 position-relative",4,"ngIf"],[1,"activity-card-wrapper","d-flex","gap-2","position-relative"],[1,"activity-icon-wrapper","position-relative","d-flex","flex-column","align-items-center"],["class","timeline-connector",4,"ngIf"],[1,"activity-content","flex-grow-1","pb-4"],[1,"activity-header","d-flex","justify-content-between","align-items-start","gap-2","mb-1"],[1,"flex-grow-1"],[1,"d-flex","align-items-center","gap-2","flex-wrap"],[1,"activity-title","fw-bold"],["class","activity-user text-muted",4,"ngIf"],["class","employee-only-badge",3,"title",4,"ngIf"],[1,"activity-timestamp","text-muted","small","text-nowrap"],[1,"activity-body",3,"ngSwitch"],[4,"ngIf"],[4,"ngSwitchCase"],[1,"timeline-connector"],[1,"activity-user","text-muted"],[1,"employee-only-badge",3,"title"],[1,"fa-thin","fa-eye","text-muted"],[3,"activity"],[3,"comment"]],template:function(o,i){o&1&&I(0,zl,33,31,"div",0),o&2&&l("ngIf",i.isVisibleTitle)},dependencies:[In,An,Rn,To,fo,uo,ho,vo,_o,Co,aa,la,ra,j,oe],styles:["[_nghost-%COMP%]   .activity-card-wrapper[_ngcontent-%COMP%]   .activity-icon-wrapper[_ngcontent-%COMP%]{width:36px}[_nghost-%COMP%]   .activity-card-wrapper[_ngcontent-%COMP%]   .activity-icon-wrapper[_ngcontent-%COMP%]   .activity-icon[_ngcontent-%COMP%]{width:32px;height:32px;z-index:10}[_nghost-%COMP%]   .activity-card-wrapper[_ngcontent-%COMP%]   .activity-icon-wrapper[_ngcontent-%COMP%]   .activity-icon[_ngcontent-%COMP%]   i[_ngcontent-%COMP%]{font-size:var(--font-body-sm)}[_nghost-%COMP%]   .activity-card-wrapper[_ngcontent-%COMP%]   .activity-icon-wrapper[_ngcontent-%COMP%]   .timeline-connector[_ngcontent-%COMP%]{position:absolute;top:42px;bottom:-16px;left:50%;transform:translate(-50%);width:1px;background-color:#e5e7eb}[_nghost-%COMP%]   .activity-card-wrapper[_ngcontent-%COMP%]   .activity-header[_ngcontent-%COMP%]   .activity-title[_ngcontent-%COMP%]{font-size:var(--font-label);color:var(--text-color)}[_nghost-%COMP%]   .activity-card-wrapper[_ngcontent-%COMP%]   .activity-header[_ngcontent-%COMP%]   .activity-user[_ngcontent-%COMP%]{font-size:var(--font-micro)}[_nghost-%COMP%]   .activity-card-wrapper[_ngcontent-%COMP%]   .activity-header[_ngcontent-%COMP%]   .activity-timestamp[_ngcontent-%COMP%]{font-size:var(--font-micro)}[_nghost-%COMP%]   .activity-card-wrapper[_ngcontent-%COMP%]   .activity-body[_ngcontent-%COMP%]{font-size:var(--font-label);color
1:var(--text-muted-color)}[_nghost-%COMP%]   .activity-icon-blue[_ngcontent-%COMP%]{background-color:#3b82f6}[_nghost-%COMP%]   .activity-icon-purple[_ngcontent-%COMP%]{background-color:#9333ea}[_nghost-%COMP%]   .activity-icon-orange[_ngcontent-%COMP%]{background-color:#f97316}[_nghost-%COMP%]   .activity-icon-green[_ngcontent-%COMP%]{background-color:#22c55e}[_nghost-%COMP%]   .activity-icon-red[_ngcontent-%COMP%]{background-color:#ef4444}[_nghost-%COMP%]   .activity-icon-indigo[_ngcontent-%COMP%]{background-color:#6366f1}[_nghost-%COMP%]   .activity-icon-emerald[_ngcontent-%COMP%]{background-color:#10b981}[_nghost-%COMP%]   .activity-icon-cyan[_ngcontent-%COMP%]{background-color:#06b6d4}[_nghost-%COMP%]   .activity-icon-gray[_ngcontent-%COMP%]{background-color:#6b7280}.dark-theme[_nghost-%COMP%]   .activity-card-wrapper[_ngcontent-%COMP%]   .activity-icon-wrapper[_ngcontent-%COMP%]   .timeline-connector[_ngcontent-%COMP%], .dark-theme   [_nghost-%COMP%]   .activity-card-wrapper[_ngcontent-%COMP%]   .activity-icon-wrapper[_ngcontent-%COMP%]   .timeline-connector[_ngcontent-%COMP%]{background-color:#374151}"]})}}return t})();function Xl(t,c){if(t&1){let e=T();r(0,"dx-button",2),y("onClick",function(){v(e);let i=s();return C(i.filterBy("Assignee",[i.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_ASSIGNEE_UPDATED,i.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_ASSIGNEE_AND_STATUS_UPDATED]))}),a()}if(t&2){let e=s();l("text",e.formatMessage("common_assignee"))("type",e.selectedFilter==="Assignee"?"default":"normal")("stylingMode",e.selectedFilter==="Assignee"?"contained":"outlined")}}function Zl(t,c){if(t&1&&(r(0,"div"),m(1,"app-rental-activity-list",10),a()),t&2){let e=c.$implicit,o=c.$index,i=c.$count;n(),l("activity",e)("isLast",o===i-1)}}var zi=(()=>{class t{constructor(){this.formatMessage=d,this.ENTITIES=b,this.userSessionService=x(k),this.userDeviceService=x(K),this.isEmployee=this.userSessionService.isEmployee(),this.userPermissionList=this.userSessionService.userPermissionList(),this.ACTIVITY_EVENT_TYPES=$,this.RENTAL_ACTIVITY_EVENT_TYPES=D,this.newOldFilter=!0,this.filterButtonName=d("newest_first"),this.selectedFilter="All",this.filterManu=[{text:d("common_all"),events:[],visible:!0},{text:d("payment"),events:[$.PAYMENT_CREATED,$.PAYMENT_UPDATED,$.PAYMENT_DELETED],visible:!0},{text:d("common_assignee"),events:[D.RENTAL_CONTRACT_ASSIGNEE_UPDATED,D.RENTAL_CONTRACT_ASSIGNEE_AND_STATUS_UPDATED],visible:this.isEmployee},{text:d("common_status"),events:[D.RENTAL_CONTRACT_STATUS_UPDATED,D.RENTAL_CONTRACT_ASSIGNEE_AND_STATUS_UPDATED],visible:!0},{text:d("devices"),events:[D.RENTAL_CONTRACT_ITEM_CREATED,D.RENTAL_CONTRACT_ITEM_UPDATED,D.RENTAL_CONTRACT_ITEM_RETURNED,D.RENTAL_CONTRACT_ITEM_DELETED],visible:!0}]}get isMobileDevice(){return this.userDeviceService.isMobileDevice()}ngOnInit(){this.filterActivities=this.activities}ngOnChanges(e){e.activities&&e.activities.previousValue!==e.activities.currentValue&&(this.filterActivities=e.activities.currentValue)}onAll(){return this.selectedFilter="All",this.filterActivities=this.activities,this.filterActivities}filterBy(e,o){this.selectedFilter=e,this.filterActivities=this.activities.filter(i=>o.includes(i.event))}onSort(){return this.newOldFilter=!this.newOldFilter,this.newOldFilter===!0?(this.filterButtonName=d("newest_first"),this.filterActivities.reverse()):(this.filterActivities.reverse(),this.filterButtonName=d("oldest_first"),this.filterActivities)}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-activity-filters-and-all-activities"]],inputs:{activities:"activities"},features:[Tt],decls:15,vars:20,consts:[[1,"activity-filters","mb-4"],[1,"d-none","d-md-flex","align-items-center","gap-2","flex-wrap"],[3,"onClick","text","type","stylingMode"],[3,"text","type","stylingMode"],["stylingMode","outlined","type","normal",1,"ms-auto",3,"onClick","icon","text"],[1,"d-flex","d-md-none","gap-2"],["stylingMode","outlined","type","normal","displayExpr","text",1,"flex-grow-1",3,"onItemClick","text","items","splitButton"],["stylingMode","outlined","type","normal",1,"app-icon-button",3,"onClick","icon","hint"],[1,"my-3"],[1,"activity-timeline"],[3,"activity","isLast"]],template:function(o,i){o&1&&(r(0,"div",0)(1,"div",1)(2,"dx-button",2),y("onClick",function(){return i.onAll()}),a(),r(3,"dx-button",2),y("onClick",function(){return i.filterBy("Payments",[i.ACTIVITY_EVENT_TYPES.PAYMENT_CREATED,i.ACTIVITY_EVENT_TYPES.PAYMENT_UPDATED,i.ACTIVITY_EVENT_TYPES.PAYMENT_DELETED])}),a(),f(4,Xl,1,3,"dx-button",3),r(5,"dx-button",2),y("onClick",function(){return i.filterBy("Status",[i.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_STATUS_UPDATED,i.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_ASSIGNEE_AND_STATUS_UPDATED])}),a(),r(6,"dx-button",2),y("onClick",function(){return i.filterBy("Devices",[i.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_ITEM_CREATED,i.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_ITEM_UPDATED,i.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_ITEM_RETURNED,i.RENTAL_ACTIVITY_EVENT_TYPES.RENTAL_CONTRACT_ITEM_DELETED])}),a(),r(7,"dx-button",4),y("onClick",function(){return i.onSort()}),a()(),r(8,"div",5)(9,"dx-drop-down-button",6),y("onItemClick",function(L){return L.itemData.text==="All"?i.onAll():i.filterBy(L.itemData.text,L.itemData.events)}),a(),r(10,"dx-button",7),y("onClick",function(){return i.onSort()}),a()()(),m(11,"hr",8),r(12,"div",9),He(13,Zl,2,2,"div",null,ut),a()),o&2&&(n(2),l("text",i.formatMessage("common_all"))("type",i.selectedFilter==="All"?"default":"normal")("stylingMode",i.selectedFilter==="All"?"contained":"outlined"),n(),l("text",i.formatMessage("payment"))("type",i.selectedFilter==="Payments"?"default":"normal")("stylingMode",i.selectedFilter==="Payments"?"contained":"outlined"),n(),h(i.isEmployee?4:-1),n(),l("text",i.formatMessage("common_status"))("type",i.selectedFilter==="Status"?"default":"normal")("stylingMode",i.selectedFilter==="Status"?"contained":"outlined"),n(),l("text",i.formatMessage("devices"))("type",i.selectedFilter==="Devices"?"default":"normal")("stylingMode",i.selectedFilter==="Devices"?"contained":"outlined"),n(),l("icon",i.newOldFilter?"fa-thin fa-arrow-down-1-9":"fa-thin fa-arrow-up-9-1")("text",i.newOldFilter?i.formatMessage("NEWEST_FIRST"):i.formatMessage("OLDEST_FIRST")),n(2),l("text",i.formatMessage("common_filters_all"))("items",i.filterManu)("splitButton",!1),n(),l("icon",i.newOldFilter?"fa-thin fa-arrow-down-1-9":"fa-thin fa-arrow-up-9-1")("hint",i.newOldFilter?i.formatMessage("NEWEST_FIRST"):i.formatMessage("OLDEST_FIRST")),n(3),je(i.filterActivities))},dependencies:[sa,Pt,Vt,Nt,yo,ao,oo],styles:[".activity-filters[_ngcontent-%COMP%]     .dx-button{height:28px!important;min-height:28px!important;max-height:28px!important}.activity-filters[_ngcontent-%COMP%]     .dx-button .dx-button-content{padding:2px 12px!important;line-height:1.5}.activity-filters[_ngcontent-%COMP%]     .dx-dropdownbutton{height:28px!important;min-height:28px!important;max-height:28px!important}.activity-filters[_ngcontent-%COMP%]     .dx-dropdownbutton .dx-button{height:28px!important;min-height:28px!important}.activity-filters[_ngcontent-%COMP%]     .dx-dropdownbutton .dx-button-content{padding:2px 12px!important;line-height:1.5}"]})}}return t})();function Jl(t,c){if(t&1&&m(0,"app-rental-activity-filters-and-all-activities",3),t&2){let e=s();l("activities",e.activities)}}function es(t,c){if(t&1&&(r(0,"div",4),m(1,"i",5),r(2,"small"),p(3),a()()),t&2){let e=s();n(3),u(e.formatMessage("no_activity_yet"))}}var Xi=(()=>{class t{constructor(){this.formatMessage=d,this.ENTITIES=b,this.activatedRouter=x(te),this.userDeviceService=x(K),this.activityService=x(ko),this.activities=[],this.rentalContractId=null}get isMobileDevice(){return this.userDeviceService.isMobileDevice()}ngOnInit(){this.activatedRouter.parent?.params.subscribe({next:e=>{this.rentalContractId=+e.rental_contract_id||null,this.rentalContractId&&this.loadActivities()},error:e=>console.error("error getting rental activity ",e)})}loadActivities(){this.activityService.getRentalActivityWithParams({rental_contract_id:this.rentalContractId,rental_contract_type:this.ENTITIES.RENTAL_CONTRACT.name}).subscribe({next:e=>{this.activities=e||[]},error:e=>console.error(e)})}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-activity"]],decls:6,vars:2,consts:[[1,"rental-activities"],[1,"d-flex","align-items-center","justify-content-between","mb-4"],[1,"title-text"],[3,"activities"],[1,"text-center","text-muted","py-4"],[1,"fa-thin","fa-timeline","fa-2x","mb-2","d-block","opacity-50"]],template:function(o,i){o&1&&(r(0,"div",0)(1,"div",1)(2,"span",2),p(3),a()(),f(4,Jl,1,1,"app-rental-activity-filters-and-all-activities",3)(5,es,4,1,"div",4),a()),o&2&&(n(3),u(i.formatMessage("activity_log")),n(),h(i.activities!=null&&i.activities.length?4:5))},dependencies:[zi],encapsulation:2})}}return t})();var vn=_a(ua());var ca=t=>[t],da=()=>["payment_receipt","deposit_receipt"];function ts(t,c){if(t&1&&(r(0,"span",6),m(1,"i",25),p(2),M(3,"dateFormat"),a()),t&2){let e=s(3);l("ngClass",e.daysToEnd<0?"bg-danger-subtle text-danger-emphasis":e.daysToEnd<=30?"bg-warning-subtle text-warning-emphasis":"bg-success-subtle text-success-emphasis"),n(2),U(" ",e.formatMessage(e.daysToEnd<0?"expired":"valid_until")," \xB7 ",N(3,3,e.rentalContract.end_date,"dateOnly")," ")}}function is(t,c){if(t&1&&m(0,"app-user-badge",13),t&2){let e=s(3);l("iconOnly",!1)("user",e.rentalContract.user)("entity",e.ENTITIES.CUSTOMER)}}function ns(t,c){if(t&1&&(r(0,"div")(1,"div",9),p(2),a(),m(3,"app-user-badge",26),a()),t&2){let e=s(3);n(2),u(e.formatMessage("current_assignee")),n(),l("iconOnly",!1)("user",e.rentalContract.assigned_user)}}function os(t,c){t&1&&m(0,"app-status-badge",21)}function as(t,c){if(t&1){let e=T();r(0,"app-entity-document-list",27),y("documentCreate",function(i){v(e);let _=s(3);return C(_.onDocumentCreate(i))}),a()}if(t&2){let e=s(3);
1l("entityId",e.rentalContract.id)("entityType",e.ENTITIES.RENTAL_CONTRACT.name)("allowCreate",e.isEmployee)("createTypes",P(6,da))("showHeader",!1)("compact",!0)}}function rs(t,c){if(t&1&&(r(0,"div",24)(1,"div",9),p(2),a(),r(3,"div",10),p(4),a()()),t&2){let e=s(3);n(2),u(e.formatMessage("renewal_type")),n(2),u(e.renewalTypeLabel(e.rentalContract.renewal_type))}}function ls(t,c){if(t&1&&(r(0,"div",24)(1,"div",9),p(2),a(),r(3,"div",10),p(4),a()()),t&2){let e=s(3);n(2),u(e.formatMessage("source")),n(2),u(e.rentalContract.source.name)}}function ss(t,c){if(t&1&&(r(0,"div",2)(1,"section",3)(2,"div",4)(3,"span",5),p(4),a(),f(5,ts,4,6,"span",6),a(),r(6,"div",7)(7,"div",8)(8,"div",9),p(9),a(),r(10,"div",10),p(11),M(12,"dateFormat"),a()(),r(13,"div",8)(14,"div",9),p(15),a(),r(16,"div",10),p(17),a()()(),r(18,"div",11)(19,"div",12)(20,"div",9),p(21),a(),f(22,is,1,3,"app-user-badge",13),a(),m(23,"app-contact-actions",14),a(),f(24,ns,4,3,"div"),a(),r(25,"section",15)(26,"div",7)(27,"div",16)(28,"div",9),p(29),a(),r(30,"div",10),m(31,"app-money",17),a()(),r(32,"div",18)(33,"div",9),p(34),a(),r(35,"div",10),m(36,"app-money",17),a()(),r(37,"div",18)(38,"div",9),p(39),a(),r(40,"div",10),m(41,"app-money",17),a()()(),m(42,"dx-progress-bar",19),r(43,"div",20)(44,"span"),p(45),m(46,"app-money",17),a(),f(47,os,1,0,"app-status-badge",21),a()(),r(48,"section",15),He(49,as,1,7,"app-entity-document-list",22,ut),a(),r(51,"details",15)(52,"summary",10),p(53),a(),r(54,"div",23)(55,"div",24)(56,"div",9),p(57),a(),r(58,"div",10),p(59),M(60,"dateFormat"),a()(),r(61,"div",24)(62,"div",9),p(63),a(),r(64,"div",10),p(65),a()(),f(66,rs,5,2,"div",24),f(67,ls,5,2,"div",24),a()(),r(68,"section",15),m(69,"app-rental-activity"),a()()),t&2){let e=s(2);n(3),l("ngClass",e.getStatusClass(e.rentalContract.status)),n(),u(e.statusLabel(e.rentalContract.status)),n(),h(e.daysToEnd!==null?5:-1),n(4),u(e.formatMessage("next_billing_date")),n(2),u(e.rentalContract.next_billing_date?N(12,33,e.rentalContract.next_billing_date,"dateOnly"):"\u2014"),n(4),u(e.formatMessage("frequency")),n(2),u(e.frequencyLabel(e.rentalContract.payment_frequency)||"\u2014"),n(4),u(e.formatMessage("common_customer")),n(),h(e.rentalContract.user?22:-1),n(),l("user",e.rentalContract.user),n(),h(e.isEmployee&&e.rentalContract.assigned_user?24:-1),n(5),u(e.formatMessage("common_total_amount")),n(2),l("value",e.rentalContract.total_amount||0),n(3),u(e.formatMessage("collected")),n(2),l("value",e.rentalContract.payment_received||0),n(3),u(e.formatMessage("common_due_amount")),n(),En("text-danger",e.dueAmount>0),n(),l("value",e.dueAmount),n(),l("min",0)("max",100)("value",e.getPaymentProgress())("showStatus",!1),n(3),R("",e.formatMessage("deposit"),": "),n(),l("value",e.rentalContract.deposit_amount),n(),h(e.depositReceived>0?47:-1),n(2),je(ye(39,ca,e.documentVersion())),n(4),u(e.formatMessage("common_more_details")),n(4),u(e.formatMessage("contract_start_date")),n(2),u(e.rentalContract.start_date?N(60,36,e.rentalContract.start_date,"dateOnly"):"\u2014"),n(4),u(e.formatMessage("billing_mode")),n(2),u(e.billingModeLabel(e.rentalContract.billing_generation_mode)||"\u2014"),n(),h(e.rentalContract.renewal_type?66:-1),n(),h(e.rentalContract.source!=null&&e.rentalContract.source.name?67:-1)}}function cs(t,c){if(t&1&&f(0,ss,70,41,"div",2),t&2){let e=s();h(e.rentalContract?0:-1)}}function ds(t,c){if(t&1&&m(0,"app-user-badge",37),t&2){let e=s(3);l("iconOnly",!1)("user",e.rentalContract.user)("entity",e.ENTITIES.CUSTOMER)}}function ps(t,c){if(t&1&&m(0,"app-user-badge",46),t&2){let e=s(4);l("iconOnly",!1)("user",e.rentalContract.assigned_user)}}function ms(t,c){if(t&1&&(r(0,"div",35)(1,"p")(2,"strong",45),p(3),a()(),f(4,ps,1,2,"app-user-badge",46),a()),t&2){let e=s(3);n(3),R("",e.formatMessage("current_assignee"),":"),n(),h(e.rentalContract.assigned_user?4:-1)}}function _s(t,c){if(t&1&&(r(0,"div",38)(1,"div",9),p(2),a(),r(3,"div",10),p(4),a()()),t&2){let e=s(3);n(2),u(e.formatMessage("source")),n(2),u(e.rentalContract.source.name)}}function us(t,c){if(t&1&&(r(0,"div",24)(1,"div",9),p(2),a(),r(3,"div",10),p(4),a()()),t&2){let e=s(3);n(2),u(e.formatMessage("renewal_type")),n(2),u(e.renewalTypeLabel(e.rentalContract.renewal_type))}}function vs(t,c){t&1&&m(0,"app-status-badge",41)}function Cs(t,c){if(t&1){let e=T();r(0,"app-entity-document-list",47),y("documentCreate",function(i){v(e);let _=s(3);return C(_.onDocumentCreate(i))}),a()}if(t&2){let e=s(3);
1l("entityId",e.rentalContract.id)("entityType",e.ENTITIES.RENTAL_CONTRACT.name)("allowCreate",e.isEmployee)("createTypes",P(5,da))("showHeader",!1)}}function fs(t,c){if(t&1&&(r(0,"div",29)(1,"div",30)(2,"h6",31),p(3),a()(),r(4,"div",32)(5,"div",33),p(6),a(),r(7,"p")(8,"strong"),p(9),a(),r(10,"span",34),p(11),a()(),r(12,"div",35)(13,"p")(14,"strong",36),p(15),a()(),f(16,ds,1,3,"app-user-badge",37),a(),f(17,ms,5,2,"div",35),f(18,_s,5,2,"div",38),r(19,"div",39),p(20),a(),r(21,"div",40)(22,"div",24)(23,"div",9),p(24),a(),r(25,"div",10),p(26),M(27,"dateFormat"),a()(),r(28,"div",24)(29,"div",9),p(30),a(),r(31,"div",10),p(32),M(33,"dateFormat"),a()(),r(34,"div",24)(35,"div",9),p(36),a(),r(37,"div",10),p(38),a()(),r(39,"div",24)(40,"div",9),p(41),a(),r(42,"div",10),p(43),M(44,"dateFormat"),a()(),r(45,"div",24)(46,"div",9),p(47),a(),r(48,"div",10),p(49),a()(),f(50,us,5,2,"div",24),a(),r(51,"div",39),p(52),a(),r(53,"div",40)(54,"div",24)(55,"div",9),p(56),a(),r(57,"div",10),m(58,"app-money",17),a()(),r(59,"div",24)(60,"div",9),p(61),a(),r(62,"div",10),m(63,"app-money",17),f(64,vs,1,0,"app-status-badge",41),a()()(),r(65,"div",9),m(66,"app-money",17),p(67),a(),m(68,"dx-progress-bar",42),r(69,"div",39),p(70),a(),He(71,Cs,1,6,"app-entity-document-list",43,ut),a()(),r(73,"div",44),m(74,"app-rental-activity"),a()),t&2){let e=s(2);n(3),u(e.formatMessage("contract_overview")),n(3),u(e.formatMessage("basic_information")),n(3),U("",e.formatMessage("contract_number"),": ",e.rentalContract.rental_number," "),n(),l("ngClass",e.getStatusClass(e.rentalContract.status)),n(),R(" ",e.statusLabel(e.rentalContract.status)," "),n(4),R("",e.formatMessage("customer_detail"),":"),n(),h(e.rentalContract.user?16:-1),n(),h(e.isEmployee?17:-1),n(),h(e.rentalContract.source!=null&&e.rentalContract.source.name?18:-1),n(2),u(e.formatMessage("billing_and_terms")),n(4),u(e.formatMessage("contract_start_date")),n(2),u(e.rentalContract.start_date?N(27,36,e.rentalContract.start_date,"dateOnly"):"\u2014"),n(4),u(e.formatMessage("contract_end_date")),n(2),u(e.rentalContract.end_date?N(33,39,e.rentalContract.end_date,"dateOnly"):"\u2014"),n(4),u(e.formatMessage("frequency")),n(2),u(e.frequencyLabel(e.rentalContract.payment_frequency)||"\u2014"),n(3),u(e.formatMessage("next_billing_date")),n(2),u(e.rentalContract.next_billing_date?N(44,42,e.rentalContract.next_billing_date,"dateOnly"):"\u2014"),n(4),u(e.formatMessage("billing_mode")),n(2),u(e.billingModeLabel(e.rentalContract.billing_generation_mode)||"\u2014"),n(),h(e.rentalContract.renewal_type?50:-1),n(2),u(e.formatMessage("payments")),n(4),u(e.formatMessage("common_total_amount")),n(2),l("value",e.rentalContract.total_amount),n(3),u(e.formatMessage("deposit")),n(2),l("value",e.rentalContract.deposit_amount),n(),h(e.depositReceived>0?64:-1),n(2),l("value",e.rentalContract.payment_received),n(),U(" ",e.formatMessage("collected")," \xB7 ",e.getPaymentProgress(),"% "),n(),l("min",0)("max",100)("value",e.getPaymentProgress())("showStatus",!1),n(2),u(e.formatMessage("common_documents")),n(),je(ye(45,ca,e.documentVersion()))}}function hs(t,c){if(t&1&&(r(0,"div",0)(1,"div",28),f(2,fs,75,47),a()()),t&2){let e=s();n(2),h(e.rentalContract?2:-1)}}function xs(t,c){if(t&1){let e=T();r(0,"app-rental-deposit-popup",48),y("depositChange",function(){v(e);let i=s();return C(i.onDepositChange())})("popupClose",function(){v(e);let i=s();return C(i.isVisibleDepositPopup.set(!1))}),a()}if(t&2){let e=s();l("isVisiblePopup",e.isVisibleDepositPopup())("rentalContract",e.rentalContract)}}var Zi=(()=>{class t{constructor(){this.formatMessage=d,this.statusLabel=lt,this.frequencyLabel=st,this.billingModeLabel=ct,this.renewalTypeLabel=dt,this.ENTITIES=b,this.rentalContractService=x(F),this.destroyRef=x(O),this.userSessionService=x(k),this.isEmployee=this.userSessionService.isEmployee(),this.userDeviceService=x(K),this.tenantService=x(wt),this.rentalContract=null,this.popupService=x(jo),this.documentService=x(mt),this.isVisibleDepositPopup=We(!1),this.documentVersion=We(0)}get isMobileDevice(){return this.userDeviceService.isMobileDevice()}onDocumentCreate(e){if(e==="payment_receipt"){this.popupService.open({kind:"document-payment",entityType:b.RENTAL_CONTRACT.name,record:this.rentalContract});return}e==="deposit_receipt"&&this.isVisibleDepositPopup.set(!0)}onDepositChange(){this.documentService.invalidate(b.RENTAL_CONTRACT.name,this.rentalContract.id),this.documentVersion.update(e=>e+1)}ngOnInit(){this.rentalContractService.currentContract$.pipe(S(this.destroyRef)).subscribe({next:e=>{this.rentalContract=e}})}getPaymentProgress(){return!this.rentalContract?.total_amount||this.rentalContract.total_amount===0?0:Math.min(Math.round(this.rentalContract.payment_received/this.rentalContract.total_amount*100),100)}get depositReceived(){return Yt(this.rentalContract)}get dueAmount(){return Math.max((this.rentalContract?.total_amount||0)-(this.rentalContract?.payment_received||0),0)}get daysToEnd(){if(!this.rentalContract?.end_date)return null;let e=qn(this.rentalContract.end_date,this.tenantService.timezone()).format(ui);return(0,vn.default)(e,ui).diff((0,vn.default)(this.tenantService.todayApi(),ui),"days")}getStatusClass(e){return Ut(e)}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-contract-overview"]],decls:3,vars:2,consts:[[1,"rental-contract-overview"],[3,"isVisiblePopup","rentalContract"],[1,"d-flex","flex-column","gap-3"],[1,"theme-secondary-bg","border","rounded-3","p-3","d-flex","flex-column","gap-3"],[1,"d-flex","flex-wrap","align-items-center","gap-2"],[1,"badge","rounded-pill","px-3","py-2",3,"ngClass"],[1,"badge","rounded-pill","px-3","py-2","d-inline-flex","align-items-center","gap-1",3,"ngClass"],[1,"row","g-0"],[1,"col-6"],[1,"small","text-muted"],[1,"fw-semibold"],[1,"d-flex","align-items-center","gap-2","border-top","pt-3"],[1,"flex-grow-1","min-width-0"],[1,"fw-bold",3,"iconOnly","user","entity"],[3,"user"],[1,"theme-secondary-bg","border","rounded-3","p-3"],[1,"col-4"],[3,"value"],[1,"col-4","border-start","ps-3"],[1,"d-block","mt-3",3,"min","max","value","showStatus"],[1,"d-flex","align-items-center","justify-content-between","small","text-muted","mt-2"],["kind","rental","variant","outline","status","paid"],[3,"entityId","entityType","allowCreate","createTypes","showHeader","compact"],[1,"row","g-0","mt-3"],[1,"col-6","mb-2"],[1,"fa-thin","fa-calendar"],[1,"fw-bold",3,"iconOnly","user"],[3,"documentCreate","entityId","entityType","allowCreate","createTypes","showHeader","compact"],[1,"row"],[1,"col-sm-5","col-md-5","col-lg-5","overview-divider"],[1,"mb-1"],[1,"fs-section-title","fw-semibold","mb-0"],[1,"overview-content"],[1,"app-subgroup-label","mt-3","mb-2"],[1,"badge","badge-extra-small",3,"ngClass"],[1,"d-flex"],[1,"me-3"],[1,"ms-2","fw-bold",3,"iconOnly","user","entity"],[1,"mb-2"],[1,"app-subgroup-label","mt-4","mb-2"],[1,"row","me-0"],["kind","rental","variant","outline","status","paid",1,"ms-1"],[1,"d-block","mt-1",3,"min","max","value","showStatus"],[3,"entityId","entityType","allowCreate","createTypes","showHeader"],[1,"col-sm-7","col-md-7","col-lg-7"],[1,"me-2"],[1,"ms-2","fw-bold",3,"iconOnly","user"],[3,"documentCreate","entityId","entityType","allowCreate","createTypes","showHeader"],[3,"depositChange","popupClose","isVisiblePopup","rentalContract"]],template:function(o,i){o&1&&(f(0,cs,1,1)(1,hs,3,1,"div",0),f(2,xs,1,2,"app-rental-deposit-popup",1)),o&2&&(h(i.isMobileDevice?0:1),n(2),h(i.isVisibleDepositPopup()&&i.rentalContract?2:-1))},dependencies:[ki,Gt,H,lo,ro,Ri,Xi,j,pi,_e,Ae,oe],styles:[".rental-contract-overview[_ngcontent-%COMP%]{height:calc(100vh - 280px);
1display:flex;flex-direction:column}.rental-contract-overview[_ngcontent-%COMP%]   strong[_ngcontent-%COMP%]{margin-right:2px}.rental-contract-overview[_ngcontent-%COMP%] > .row[_ngcontent-%COMP%]{flex:1;min-height:0}.rental-contract-overview[_ngcontent-%COMP%]   .overview-divider[_ngcontent-%COMP%]{border-right:1px solid var(--bp-border-subtle);height:100%;display:flex;flex-direction:column;min-height:0}.rental-contract-overview[_ngcontent-%COMP%]   .overview-divider[_ngcontent-%COMP%]   .overview-content[_ngcontent-%COMP%]{flex:1;overflow-x:hidden;overflow-y:auto;min-height:0}.rental-contract-overview[_ngcontent-%COMP%]   .col-sm-7[_ngcontent-%COMP%]{height:100%;overflow-y:auto;min-height:0}"]})}}return t})();var ys=()=>({type:"fixedPoint",precision:2});function Ts(t,c){t&1&&m(0,"app-skeleton-loader",2),t&2&&l("rows",3)("columns",3)}function gs(t,c){if(t&1){let e=T();r(0,"app-save-cancel-footer",30),y("cancelClick",function(){v(e);let i=s(4);return C(i.cancel())}),a()}if(t&2){let e=s(4);l("isSaving",e.isSaving)("isVisibleHr",!1)}}function Es(t,c){if(t&1&&I(0,gs,1,2,"app-save-cancel-footer",29),t&2){let e=s(3);l("ngxPermissionsOnly",e.PERMISSION_LIST.RENTAL_CONTRACT_WRITE)}}function bs(t,c){if(t&1){let e=T();r(0,"div",31),m(1,"app-location-back",33),r(2,"app-dx-outline-button",34),y("onClickEvent",function(){v(e);let i=s(4);return C(i.setEditMode())}),a()()}}function Ss(t,c){if(t&1){let e=T();r(0,"app-dx-outline-button",35),y("onClickEvent",function(){v(e);let i=s(4);return C(i.setEditMode())}),a()}}function Ds(t,c){if(t&1&&f(0,bs,3,0,"div",31)(1,Ss,1,0,"app-dx-outline-button",32),t&2){let e=s(3);h(e.isMobileDevice&&!e.hasHeaderEditAction?0:e.isMobileDevice?-1:1)}}function Is(t,c){if(t&1&&f(0,Es,1,1,"app-save-cancel-footer",28)(1,Ds,2,1),t&2){let e=s(2);h(e.isEditMode?0:e.userPermissionList.includes(e.PERMISSION_LIST.RENTAL_CONTRACT_WRITE)?1:-1)}}function As(t,c){if(t&1){let e=T();r(0,"form",4),y("ngSubmit",function(){v(e);let i=s();return C(i.save())}),r(1,"div",5)(2,"div",6)(3,"app-form-layout"),I(4,Is,2,1,"ng-template",7),a()()(),r(5,"div",8)(6,"div",6),m(7,"app-section-title",9),r(8,"div",10)(9,"app-control-container",11)(10,"app-customer-dropdown",12),y("itemClick",function(i){v(e);let _=s();return C(_.onCustomerSelected(i))}),a()(),r(11,"app-control-container",13),m(12,"dx-select-box",14),a(),r(13,"app-control-container",15),m(14,"app-employee-dropdown",16),a(),r(15,"app-control-container",17),m(16,"dx-date-box",18),a(),r(17,"app-control-container",19),m(18,"dx-date-box",20),a(),r(19,"app-control-container",21),m(20,"dx-select-box",22),a()(),m(21,"app-section-title",23),r(22,"div",10)(23,"app-control-container",24),m(24,"dx-select-box",25),a(),r(25,"app-control-container",26),m(26,"dx-number-box",27),a()()()()()}if(t&2){let e,o=s();l("formGroup",o.form),n(7),l("title","contract_information"),n(2),l("label",o.formatMessage("user_customer_name"))("errorMsg",o.formatMessage("common_error_messages_customer_required")),n(),l("formControl",o.form.controls.user_id)("customerId",(e=o.form.getRawValue())==null?null:e.user_id)("isEditMode",o.isEditMode)("showCrateButton",!0),n(),l("label",o.formatMessage("source")),n(),l("items",o.leadSources)("placeholder",o.formatMessage("select_source"))("showClearButton",!0),n(),l("label",o.formatMessage("common_assignee")),n(),l("formControl",o.form.controls.assignee_id)("isEditMode",o.isEditMode),n(),l("label",o.formatMessage("contract_start_date"))("errorMsg",o.formatMessage("contract_start_date_required")),n(),l("dateSerializationFormat",o.DATETIME_SERIALIZATION_FORMAT),n(),l("label",o.formatMessage("contract_end_date")),n(),l("dateSerializationFormat",o.DATETIME_SERIALIZATION_FORMAT)("min",o.form.get("start_date").value),n(),l("label",o.formatMessage("renewal_type")),n(),l("items",o.RENEWAL_TYPES),n(),l("title","billing"),n(2),l("label",o.formatMessage("payment_frequency"))("errorMsg",o.formatMessage("payment_frequency_required")),n(),l("items",o.PAYMENT_FREQUENCY_LIST)("displayExpr",o.frequencyLabel)("placeholder",o.formatMessage("select_frequency")),n(),l("label",o.formatMessage("deposit_amount")),n(),l("min",0)("format",P(32,ys))}}var Ji=(()=>{class t{constructor(){this.mobileHeaderService=x(mo),this.formatMessage=d,this.ENTITIES=b,this.fb=x(ge),this.rentalContractService=x(F),this.formService=x(zn),this.loaderService=x(Ot),this.toastNotificationService=x(B),this.userSessionService=x(k),this.activatedRouter=x(te),this.destroyRef=x(O),this.userDeviceService=x(K),this.userPermissionList=this.userSessionService.userPermissionList(),this.DATETIME_SERIALIZATION_FORMAT=_i,this.PAYMENT_FREQUENCY_LIST=It,this.BILLING_MODE_LIST=At.map(e=>({id:e.id,label:ct(e.id)})),this.RENEWAL_TYPES=Rt.map(e=>({id:e.id,label:dt(e.id)})),this.leadSources=[],this.leadSourceService=x(wi),this.frequencyLabel=st,this.PERMISSION_LIST=g,this.rentalContractId=null,this.rentalContract=null,this.form=null,this.isEditMode=!1,this.isEditRequested=!1,this.isSaving=!1}get hasHeaderEditAction(){return this.mobileHeaderService.hasEditAction()}get isMobileDevice(){return this.userDeviceService.isMobileDevice()}ngOnInit(){this.leadSourceService.getListByQuery().subscribe({next:e=>this.leadSources=e??[],error:e=>console.error(e)}),this.activatedRouter.parent.params.pipe(S(this.destroyRef)).subscribe({next:e=>{this.rentalContractId=+e.rental_contract_id||null,this.rentalContractId&&this.setForm()},error:e=>console.error(e)})}setForm(){this.rentalContractService.getDetailById(this.rentalContractId).pipe(!this.form&&this.rentalContractId?oi:this.loaderService.withLoader()).subscribe({next:e=>{this.rentalContract=new Re(e),this.buildForm(this.rentalContract),this.setReadOnlyMode()},error:()=>this.toastNotificationService.error(d("something_went_wrong"))})}buildForm(e){this.form=this.fb.group({id:[e.id],rental_number:[e.rental_number],user_id:[e.user_id,[V.required]],source_id:[e.source_id],assignee_id:[e.assignee_id],start_date:[e.start_date,[V.required]],end_date:[e.end_date],renewal_type:[e.renewal_type],payment_frequency:[e.payment_frequency,[V.required]],billing_generation_mode:[e.billing_generation_mode],deposit_amount:[e.deposit_amount]})}onCustomerSelected(e){this.form.patchValue({user_id:e?.id})}setEditMode(){if(!this.form){this.isEditRequested=!0;return}this.isEditRequested=!1,this.isEditMode=!0,this.form.enable()}setReadOnlyMode(){this.isSaving=!1,this.isEditMode=!1,this.form.disable(),this.isEditRequested&&this.setEditMode()}cancel(){this.buildForm(this.rentalContract),this.setReadOnlyMode()}save(){if(!this.form.valid){this.formService.validateFormFields(this.form);return}this.isSaving=!0;let e=Ce(Q({},this.form.getRawValue()),{status:this.rentalContract?.status});this.rentalContractService.update(e).subscribe({next:o=>{this.rentalContract=new Re(o),this.rentalContractService.setCurrentContract(this.rentalContract),this.toastNotificationService.success(d("contract_updated_successfully")),this.buildForm(this.rentalContract),this.setReadOnlyMode()},error:()=>this.toastNotificationService.error(d("something_went_wrong"))}).add(()=>{this.isSaving=!1})}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-contract-details"]],decls:4,vars:5,consts:[[3,"editClick","mobileHeaderOnly","isEditing","editOnQueryParam"],[1,"form-container"],["type","form",3,"rows","columns"],[3,"formGroup"],[3,"ngSubmit","formGroup"],[1,"row"],[1,"col-sm-12","col-md-12","col-lg-12"],["appFormActions",""],[1,"row","mt-4"],[1,"mb-3",3,"title"],[1,"row","mb-5"],["name","user_id",1,"col-sm-12","col-md-6","col-lg-4",3,"label","errorMsg"],[3,"itemClick","formControl","customerId","isEditMode","showCrateButton"],["name","source_id",1,"col-sm-12","col-md-6","col-lg-4",3,"label"],["formControlName","source_id","displayExpr","name","valueExpr","id","stylingMode","outlined",3,"items","placeholder","showClearButton"],["name","assignee_id",1,"col-sm-12","col-md-6","col-lg-4",3,"label"],[3,"formControl","isEditMode"],["name","start_date",1,"col-sm-12","col-md-6","col-lg-4",3,"label","errorMsg"],["formControlName","start_date","type","date","stylingMode","outlined",3,"dateSerializationFormat"],["name","end_date",1,"col-sm-12","col-md-6","col-lg-4",3,"label"],["formControlName","end_date","type","date","stylingMode","outlined",3,"dateSerializationFormat","min"],["name","renewal_type",1,"col-sm-12","col-md-6","col-lg-4",3,"label"],["formControlName","renewal_type","displayExpr","label","valueExpr","id","stylingMode","outlined",3,"items"],[1,"mt-3","mb-3",3,"title"],["name","payment_frequency",1,"col-sm-12","col-md-6","col-lg-4",3,"label","errorMsg"],["formControlName","payment_frequency","stylingMode","outlined",3,"items","displayExpr","placeholder"],["name","deposit_amount",1,"col-sm-12","col-md-6","col-lg-4",3,"label"],["formControlName","deposit_amount","stylingMode","outlined",3,"min","format"],["saveText","common_save",3,"isSaving","isVisibleHr"],["saveText","common_save",3,"isSaving","isVisibleHr","cancelClick",4,"ngxPermissionsOnly"],["saveText","common_save",3,"cancelClick","isSaving","isVisibleHr"],[1,"d-flex","mobile-action-buttons"],["buttonStyle","contained","buttonType","default","text","common_edit",1,"float-end","ms-1"],["id","rental-contract-details-back"],["buttonStyle","contained","buttonType","default","text","common_edit",3,"onClickEvent"],["buttonStyle","contained","buttonType","default","text","common_edit",1,"float-end","ms-1",3,"onClickEvent"]],template:function(o,i){o&1&&(r(0,"app-page-header",0),y("edit
1Click",function(){return i.setEditMode()}),a(),r(1,"div",1),f(2,Ts,1,2,"app-skeleton-loader",2),f(3,As,27,33,"form",3),a()),o&2&&(l("mobileHeaderOnly",!0)("isEditing",i.isEditMode&&!!i.rentalContractId)("editOnQueryParam",!0),n(2),h(!i.form&&i.rentalContractId?2:-1),n(),h(i.form?3:-1))},dependencies:[pt,Fe,Si,J,Lt,Ci,kt,de,Mi,re,ae,Ii,xi,hi,Ee,Se,be,ke,et,Te,Pe,mi,Oe,Le,St,bt,bi],encapsulation:2})}}return t})();var pa=(()=>{class t extends it{constructor(e){super(e,On),this.api=e}static{this.\u0275fac=function(o){return new(o||t)(Ze(nt))}}static{this.\u0275prov=Xe({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var ws=t=>({rental_contract_id:t}),Ms=(t,c,e)=>({icon:"dx-icon-movetofolder",title:t,description:c,primaryButtonText:"add_device",primaryButtonVisible:e}),Ns=()=>["name","device_number","serial_number","device_brand.name","device_model.name"],Vs=()=>({maxHeight:320});function Ps(t,c){if(t&1&&(r(0,"div",9),p(1),a()),t&2){let e=s().$implicit;n(),Et(" ",e.rental_device==null||e.rental_device.device_brand==null?null:e.rental_device.device_brand.name,"",!(e.rental_device==null||e.rental_device.device_brand==null)&&e.rental_device.device_brand.name&&(!(e.rental_device==null||e.rental_device.device_model==null)&&e.rental_device.device_model.name)?" \xB7 ":"","",e.rental_device==null||e.rental_device.device_model==null?null:e.rental_device.device_model.name," ")}}function Ls(t,c){if(t&1&&(r(0,"div",13)(1,"span",16),p(2),a(),r(3,"span",22),m(4,"app-money",19),a()()),t&2){let e=s().$implicit,o=s(2);n(2),u(o.formatMessage("security_deposit")),n(2),l("value",e.deposit_amount)}}function Os(t,c){if(t&1){let e=T();r(0,"div",7)(1,"div",8)(2,"span",9),p(3),a(),m(4,"app-status-badge",10),a(),r(5,"div",11)(6,"div",12),p(7),a(),f(8,Ps,2,3,"div",9),a(),f(9,Ls,5,2,"div",13),m(10,"hr",14),r(11,"div",15)(12,"span",16),p(13),a(),r(14,"div",17),y("click",function(i){return i.stopPropagation()}),r(15,"span",18),m(16,"app-money",19),a(),r(17,"app-context-menu",20),y("contextMenuItemCancelClick",function(){v(e);let i=s(2);return C(i.onCloseContextMenuOption())})("contextMenuItemClick",function(i){v(e);let _=s(2);return C(_.onContextMenuItemClick(i))}),r(18,"app-sheet-header",21),m(19,"app-status-badge",10),a()()()()()}if(t&2){let e=c.$implicit,o=s(2);n(3),R(" ",(e.rental_device==null?null:e.rental_device.serial_number)||(e.rental_device==null?null:e.rental_device.device_number)||e.device_number_snapshot," "),n(),l("status",e.status),n(3),R(" ",(e.rental_device==null?null:e.rental_device.name)||e.device_name_snapshot," "),n(),h(!(e.rental_device==null||e.rental_device.device_brand==null)&&e.rental_device.device_brand.name||!(e.rental_device==null||e.rental_device.device_model==null)&&e.rental_device.device_model.name?8:-1),n(),h(e.deposit_amount?9:-1),n(4),u(o.formatMessage("monthly_rent")),n(3),l("value",e.unit_price),n(),l("contextMenuItems",o.deviceContextMenu)("entityName",o.entity.name)("entity",e)("mobileSheet",!0),n(),l("subtitle",(e.rental_device==null?null:e.rental_device.serial_number)||(e.rental_device==null?null:e.rental_device.device_number)||e.device_number_snapshot)("title",(e.rental_device==null?null:e.rental_device.name)||e.device_name_snapshot),n(),l("status",e.status)}}function ks(t,c){if(t&1){let e=T();r(0,"app-data-grid",5),y("contextMenuItemCancelClick",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())})("contextMenuItemClick",function(i){v(e);let _=s();return C(_.onContextMenuItemClick(i))})("dataGridAddNewClick",function(){v(e);let i=s();return C(i.openAddDevice())}),I(1,Os,20,14,"ng-template",6),a()}if(t&2){let e=s();l("additionalParams",ye(15,ws,e.rentalContractId))("columns",e.columns)("contextMenuItems",e.deviceContextMenu)("dataGridId","rentalContractItemGrid")("entity",e.entity)("isVisibleAddAction",e.canWrite)("writeAccessPermissionName",e.PERMISSION_LIST.RENTAL_CONTRACT_WRITE)("isVisibleEditAction",!1)("isVisibleDeleteAction",!1)("deleteAccessPermissionName",e.PERMISSION_LIST.RENTAL_CONTRACT_DELETE)("isVisibleExportAction",!1)("isVisibleTitle",!e.isOnAside)("service",e.service)("showColumnLines",!0)("emptyStateConfig",Sn(17,Ms,e.formatMessage("no_devices_attached"),e.formatMessage("no_devices_attached"),e.canWrite))}}function Fs(t,c){if(t&1){let e=T();r(0,"app-archive-delete-popup",23),W("isVisibleChange",function(i){v(e);let _=s();return G(_.isVisibleArchiveDeletePopup,i)||(_.isVisibleArchiveDeletePopup=i),C(i)}),y("onSuccess",function(){v(e);let i=s();return C(i.handleArchiveDeleteSuccess())})("onCancel",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())}),a()}if(t&2){let e=s();Y("isVisible",e.isVisibleArchiveDeletePopup),l("service",e.service)("entity",e.selectedItem)("entityName",e.entity.name)("entityDisplayName",e.entity.displayName)("mode",e.archiveDeleteMode())}}function Bs(t,c){if(t&1){let e=T();r(0,"app-confirmation-popup",24),y("confirmActionCallback",function(){v(e);let i=s();return C(i.returnDevice())})("rejectActionCallback",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())}),a()}if(t&2){let e=s();l("confirmButtonText","return_device")("confirmationMessage",e.returnConfirmationMessage)("isSaving",e.isReturning)}}function Us(t,c){if(t&1&&(r(0,"div"),m(1,"app-rental-device-option",41),a()),t&2){let e=c.$implicit;n(),l("device",e)}}function Ys(t,c){if(t&1){let e=T();r(0,"div",33)(1,"label",30),p(2),a(),r(3,"dx-number-box",42),W("valueChange",function(i){v(e);let _=s(3);return G(_.deviceUnitPrice,i)||(_.deviceUnitPrice=i),C(i)}),a()()}if(t&2){let e=s(3);n(2),u(e.formatMessage("monthly_rent")),n(),Y("value",e.deviceUnitPrice),l("min",0)}}function Gs(t,c){if(t&1){let e=T();r(0,"div",27)(1,"dx-scroll-view",28)(2,"div",29)(3,"label",30),p(4),a(),r(5,"dx-select-box",31),W("valueChange",function(i){v(e);let _=s(2);return G(_.selectedDeviceId,i)||(_.selectedDeviceId=i),C(i)}),y("onValueChanged",function(i){v(e);let _=s(2);return C(_.onDeviceValueChanged(i))}),I(6,Us,2,1,"div",32),a()(),f(7,Ys,4,3,"div",33),r(8,"div",34),m(9,"hr",35),r(10,"span",36),p(11),a(),m(12,"hr",35),a(),m(13,"app-rental-device-form",37),a(),r(14,"div",38)(15,"dx-button",39),y("onClick",function(){v(e);let i=s(2);return C(i.closeAddDevice())}),a(),r(16,"dx-button",40),y("onClick",function(){v(e);let i=s(2);
1return C(i.saveDevice())}),a()()()}if(t&2){let e,o=s(2);n(4),u(o.formatMessage("select_existing_device")),n(),l("dataSource",o.availableDevices),Y("value",o.selectedDeviceId),l("displayExpr",o.deviceDisplayExpr)("searchEnabled",!0)("searchExpr",P(17,Ns))("showClearButton",!0)("placeholder",o.formatMessage("search_and_select_available_device"))("noDataText",o.formatMessage("no_devices_available"))("dropDownOptions",P(18,Vs)),n(),l("dxTemplateOf","deviceItemTemplate"),n(),h(o.selectedDeviceId?7:-1),n(4),u(o.formatMessage("common_or")),n(2),l("form",o.addDeviceForm),n(2),l("text",o.formatMessage("common_cancel")),n(),l("text",o.formatMessage("add_device"))("disabled",o.isAssigning||!o.selectedDeviceId&&!(!(o.addDeviceForm==null||(e=o.addDeviceForm.get("name"))==null)&&e.value))}}function Ws(t,c){if(t&1){let e=T();r(0,"dx-popup",25),y("onHidden",function(){v(e);let i=s();return C(i.closeAddDevice())}),I(1,Gs,17,19,"div",26),a()}if(t&2){let e=s();l("visible",e.isVisibleAddDevice)("width","95vw")("maxWidth",620)("height","auto")("maxHeight","90vh")("title",e.formatMessage("create_new_device")),n(),l("dxTemplateOf","content")}}var en=(()=>{class t{get canWrite(){if(!this.isEmployee||!this.userPermissionList.includes(g.RENTAL_CONTRACT_WRITE))return!1;let e=this.rentalContractService.getCurrentContract()?.status;return e!==A.COMPLETED&&e!==A.CANCELLED}get canDelete(){return this.isEmployee&&this.userPermissionList.includes(g.RENTAL_CONTRACT_DELETE)}get canReturn(){return this.isEmployee&&this.userPermissionList.includes(g.RENTAL_RETURN)}constructor(e){this.service=e,this.formatMessage=d,this.ENTITIES=b,this.entity=b.RENTAL_CONTRACT_ITEM,this.PERMISSION_LIST=g,this.activatedRouter=x(te),this.fb=x(ge),this.rentalContractService=x(F),this.rentalDeviceService=x(Ie),this.userSessionService=x(k),this.toastNotificationService=x(B),this.destroyRef=x(O),this.isEmployee=this.userSessionService.isEmployee(),this.userPermissionList=this.userSessionService.userPermissionList(),this.rentalContractId=null,this.isOnAside=!1,this.isVisibleAddDevice=!1,this.isAssigning=!1,this.availableDevices=[],this.selectedDeviceId=null,this.deviceUnitPrice=0,this.deviceContextMenu=[],this.isVisibleReturnPopup=!1,this.isReturning=!1,this.itemToReturn=null,this.selectedItem=null,this.isVisibleArchiveDeletePopup=!1,this.archiveDeleteMode=We("delete"),this.columns=[{dataField:"rental_device.name",caption:d("common_device"),allowSorting:!1},{dataField:"rental_device.device_brand.name",caption:d("device_brand_name"),allowSorting:!1,alignment:"center"},{dataField:"rental_device.device_model.name",caption:d("device_model"),allowSorting:!1,alignment:"center"},{dataField:"rental_device.serial_number",caption:d("serial_number"),allowSorting:!1,alignment:"center"},{dataField:"status",caption:d("common_status"),allowSorting:!1,alignment:"center",width:110,cellTemplate:"statusTemplate"},{dataField:"unit_price",caption:d("monthly_rent"),dataType:"number",allowSorting:!1,alignment:"center",format:{type:"fixedPoint",precision:2}},{dataField:"deposit_amount",caption:d("security_deposit"),dataType:"number",allowSorting:!1,alignment:"center",format:{type:"fixedPoint",precision:2}},{name:"actions",caption:"",allowSorting:!1,alignment:"center",showInColumnChooser:!1,cellTemplate:"actionTemplate",allowExporting:!1}],this.deviceDisplayExpr=o=>{if(!o)return"";let i=o.name||d("common_device");return o.device_number?`${i} \xB7 ${o.device_number}`:i}}ngOnInit(){this.buildContextMenu(),this.rentalContractService.currentContract$.pipe(S(this.destroyRef)).subscribe({next:()=>this.buildContextMenu(),error:e=>console.error(e)}),!this.rentalContractId&&this.activatedRouter.parent?.params.subscribe({next:e=>{this.rentalContractId=+e.rental_contract_id||null},error:e=>console.error(e)})}buildContextMenu(){this.deviceContextMenu=[{name:Xt.RETURN_DEVICE,icon:Z.RETURN.light,visible:this.canReturn,isDisabled:e=>e?.status===Fn.RETURNED,locale_key:d("return_device")},{name:Xt.DELETE,icon:Z.DELETE.light,visible:this.canDelete,locale_key:d("common_delete"),destructive:!0}]}onContextMenuItemClick(e){this.selectedItem=e.entity,e.action===Xt.RETURN_DEVICE&&this.confirmReturn(this.selectedItem),e.action===Xt.DELETE&&(this.archiveDeleteMode.set(this.selectedItem?.deleted_at?"archived-actions":"delete"),this.isVisibleArchiveDeletePopup=!0)}onCloseContextMenuOption(){this.isVisibleReturnPopup=!1,this.isVisibleArchiveDeletePopup=!1,this.itemToReturn=null,this.selectedItem=null}handleArchiveDeleteSuccess(){this.isVisibleArchiveDeletePopup=!1,this.selectedItem=null,this.dataGrid?.getData(),this.rentalContractId&&this.rentalContractService.refreshDetail(this.rentalContractId).subscribe()}confirmReturn(e){e?.id&&(this.itemToReturn=e,this.isVisibleReturnPopup=!0)}get returnConfirmationMessage(){let e=this.itemToReturn;return d("return_device_confirmation",e?.rental_device?.name||e?.device_name_snapshot,e?.rental_device?.device_number||e?.device_number_snapshot)}returnDevice(){let e=this.itemToReturn;e?.id&&(this.isReturning=!0,this.rentalContractService.returnDevice(e.id).subscribe({next:()=>{this.toastNotificationService.success(d("return_device_success")),this.dataGrid?.getData(),this.rentalContractId&&this.rentalContractService.refreshDetail(this.rentalContractId).subscribe()},error:o=>{this.toastNotificationService.error(o?.error?.message||d("something_went_wrong"))}}).add(()=>{this.isReturning=!1,this.onCloseContextMenuOption()}))}openAddDevice(){this.selectedDeviceId=null,this.deviceUnitPrice=0,this.buildCreateForm(),this.isVisibleAddDevice=!0,this.loadAvailableDevices()}buildCreateForm(){this.addDeviceForm=this.fb.group({name:[null],device_brand_id:[null],device_model_id:[null],serial_number:[null],rental_rate_monthly:[0,[V.min(0)]],rental_deposit:[0,[V.min(0)]],rental_status:[z.AVAILABLE],storage_location_id:[null],accessories:[[]],comment:[null]})}closeAddDevice(){this.isVisibleAddDevice=!1}loadAvailableDevices(){this.rentalDeviceService.getListByQuery({}).subscribe({next:e=>{let o=Array.isArray(e)?e:e?.data||[];this.availableDevices=o.filter(i=>i.rental_status?.toLowerCase()===z.AVAILABLE)},error:()=>{this.toastNotificationService.error(d("something_went_wrong"))}})}onDeviceValueChanged(e){let o=this.availableDevices.find(i=>i.id===e.value);this.deviceUnitPrice=o?.rental_rate_monthly??0}saveDevice(){if(this.selectedDeviceId){this.assignExistingDevice(this.selectedDeviceId,this.deviceUnitPrice??0);return}if(!this.addDeviceForm?.get("name")?.value){this.toastNotificationService.error(d("device_type_required_error"));return}this.createAndAssignDevice()}createAndAssignDevice(){this.isAssigning=!0,this.rentalDeviceService.create(this.addDeviceForm.value).subscribe({next:e=>{let o=e?.data??e;this.assignExistingDevice(o.id,o.rental_rate_monthly??this.addDeviceForm.get("rental_rate_monthly").value??0)},error:e=>{this.isAssigning=!1,this.toastNotificationService.error(e?.error?.message||d("something_went_wrong"))}})}assignExistingDevice(e,o){!e||!this.rentalContractId||(this.isAssigning=!0,this.rentalContractService.assignDevice(this.rentalContractId,{rental_device_id:e,unit_price:o??0}).subscribe({next:()=>{this.toastNotificationService.success(d("device_added_success")),this.isVisibleAddDevice=!1,this.dataGrid?.getData(),this.rentalContractService.refreshDetail(this.rentalContractId).subscribe()},error:i=>{this.toastNotificationService.error(i?.error?.message||d("something_went_wrong"))}}).add(()=>{this.isAssigning=!1}))}static{this.\u0275fac=function(o){return new(o||t)(X(pa))}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-contract-devices"]],viewQuery:function(o,i){if(o&1&&fe(ee,5),o&2){let _;he(_=xe())&&(i.dataGrid=_.first)}},inputs:{rentalContractId:"rentalContractId",isOnAside:"isOnAside"},decls:5,vars:4,consts:[[1,"mt-1"],[3,"additionalParams","columns","contextMenuItems","dataGridId","entity","isVisibleAddAction","writeAccessPermissionName","isVisibleEditAction","isVisibleDeleteAction","deleteAcce
1ssPermissionName","isVisibleExportAction","isVisibleTitle","service","showColumnLines","emptyStateConfig"],[3,"isVisible","service","entity","entityName","entityDisplayName","mode"],[3,"confirmButtonText","confirmationMessage","isSaving"],["appPhoneMode","fullscreen","id","rental-add-device-modal",3,"visible","width","maxWidth","height","maxHeight","title"],[3,"contextMenuItemCancelClick","contextMenuItemClick","dataGridAddNewClick","additionalParams","columns","contextMenuItems","dataGridId","entity","isVisibleAddAction","writeAccessPermissionName","isVisibleEditAction","isVisibleDeleteAction","deleteAccessPermissionName","isVisibleExportAction","isVisibleTitle","service","showColumnLines","emptyStateConfig"],["appCardTemplate",""],[1,"app-card"],[1,"d-flex","align-items-center","justify-content-between","gap-2","mb-2"],[1,"fs-label","text-muted","text-truncate"],["kind","rental",3,"status"],[1,"min-width-0"],[1,"fs-subsection","fw-bold","text-truncate"],[1,"d-flex","align-items-center","justify-content-between","gap-2","mt-2"],[1,"my-2"],[1,"d-flex","align-items-center","justify-content-between","gap-2"],[1,"fs-label","text-muted"],[1,"d-flex","align-items-center","gap-2","flex-shrink-0",3,"click"],[1,"fs-label","fw-bold"],[3,"value"],[3,"contextMenuItemCancelClick","contextMenuItemClick","contextMenuItems","entityName","entity","mobileSheet"],[3,"subtitle","title"],[1,"fs-label"],[3,"isVisibleChange","onSuccess","onCancel","isVisible","service","entity","entityName","entityDisplayName","mode"],[3,"confirmActionCallback","rejectActionCallback","confirmButtonText","confirmationMessage","isSaving"],["appPhoneMode","fullscreen","id","rental-add-device-modal",3,"onHidden","visible","width","maxWidth","height","maxHeight","title"],["class","p-3 d-flex flex-column h-100",4,"dxTemplate","dxTemplateOf"],[1,"p-3","d-flex","flex-column","h-100"],[1,"flex-grow-1","min-height-0"],[1,"mb-2"],[1,"form-label","small","fw-semibold"],["valueExpr","id","searchMode","contains","itemTemplate","deviceItemTemplate",3,"valueChange","onValueChanged","dataSource","value","displayExpr","searchEnabled","searchExpr","showClearButton","placeholder","noDataText","dropDownOptions"],[4,"dxTemplate","dxTemplateOf"],[1,"mb-3"],[1,"d-flex","align-items-center","my-3","text-muted"],[1,"flex-fill","my-0"],[1,"px-2","small","fw-semibold"],[3,"form"],[1,"d-flex","gap-2","justify-content-end","mt-2"],["stylingMode","outlined","type","normal",3,"onClick","text"],["type","default",3,"onClick","text","disabled"],[3,"device"],["format","#,##0.00",3,"valueChange","value","min"]],template:function(o,i){o&1&&(r(0,"div",0),f(1,ks,2,21,"app-data-grid",1),a(),f(2,Fs,1,6,"app-archive-delete-popup",2),f(3,Bs,1,3,"app-confirmation-popup",3),f(4,Ws,2,7,"dx-popup",4)),o&2&&(n(),h(i.rentalContractId?1:-1),n(),h(i.isVisibleArchiveDeletePopup&&i.selectedItem?2:-1),n(),h(i.isVisibleReturnPopup?3:-1),n(),h(i.isVisibleAddDevice?4:-1))},dependencies:[ce,ee,_e,H,De,Ue,Ft,yi,se,le,ie,me,pe,re,ae,Ye,Ee,Se,be,Ge,Nt,Pt,Vt,ne,Be],encapsulation:2})}}return t})();var Hs=(t,c)=>({paymentable_id:t,paymentable_type:c});function js(t,c){if(t&1&&(r(0,"div",6)(1,"span",9),p(2),a(),r(3,"span",10),p(4),a()()),t&2){let e=s().$implicit,o=s(2);n(2),u(o.formatMessage("payment_cheque_number")),n(2),u(e.cheque_number)}}function qs(t,c){if(t&1&&(r(0,"div",6)(1,"span",9),p(2),a(),r(3,"span",10),p(4),a()()),t&2){let e=s().$implicit,o=s(2);n(2),u(o.formatMessage("common_created_by")),n(2),u(e.created_user==null?null:e.created_user.name)}}function $s(t,c){if(t&1){let e=T();r(0,"app-payment-card",4),y("toggleExpand",function(){let i=v(e).$implicit,_=s(2);return C(_.expanded.toggle(i.id))}),Ne(1,5),f(2,js,5,2,"div",6),f(3,qs,5,2,"div",6),Ve(),r(4,"app-context-menu",7),y("contextMenuItemClick",function(i){v(e);let _=s(2);return C(_.onContextMenuItemClick(i))}),m(5,"app-sheet-header",8),a()()}if(t&2){let e=c.$implicit,o=s(2);l("expandable",!!(e.cheque_number||e.created_user))("expanded",o.expanded.has(e.id))("isVisibleAgainst",!1)("payment",e),n(2),h(e.cheque_number?2:-1),n(),h(e.created_user!=null&&e.created_user.name?3:-1),n(),l("contextMenuItems",o.paymentContextMenu)("entityName",o.entity.name)("entity",e)("mobileSheet",!0)("showDocuments",!0),n(),l("entity",o.ENTITIES.CUSTOMER)("subtitle",e.payment_type==null?null:e.payment_type.name)("title",e.user==null?null:e.user.name)("user",e.user)}}function Qs(t,c){if(t&1){let e=T();r(0,"app-data-grid",2),y("dataGridAddNewClick",function(){v(e);let i=s();return C(i.create())})("dataGridEditClick",function(i){v(e);let _=s();return C(_.edit(i))}),I(1,$s,6,15,"ng-template",3),a()}if(t&2){let e=s();l("additionalParams",bn(10,Hs,e.rentalContract.id,e.ENTITIES.RENTAL_CONTRACT.name))("columns",e.columns)("entity",e.entity)("isVisibleAddAction",!1)("isVisibleTitle",!e.isOnAside)("isVisibleEditAction",e.isEmployee)("isVisibleDeleteAction",e.isAdmin||e.userPermissionList.includes(e.PERMISSION_LIST.PAYMENT_DELETE))("isVisibleExportAction",!1)("paymentTypes",e.paymentTypes)("service",e.service)}}function Ks(t,c){if(t&1){let e=T();r(0,"app-add-payment-popup",11),y("addPaymentClose",function(){v(e);let i=s();return C(i.isVisiblePopup=!1)})("addPaymentSave",function(){v(e);let i=s();return C(i.onSavePayment())}),a()}if(t&2){let e=s();l("entity",e.rentalContract)("entityType",e.ENTITIES.RENTAL_CONTRACT.name)("isCreate",e.isCreate)("isVisiblePopup",e.isVisiblePopup)("payment",e.payment)}}var tn=(()=>{class t{constructor(e){this.service=e,this.formatMessage=d,this.rentalContract=null,this.isOnAside=!1,this.ENTITIES=b,this.PERMISSION_LIST=g,this.userSessionService=x(k),this.rentalContractService=x(F),this.paymentTypeService=x(Ao),this.isAdmin=this.userSessionService.isAdmin(),this.isEmployee=this.userSessionService.isEmployee(),this.userPermissionList=this.userSessionService.userPermissionList(),this.expanded=new jt,this.isVisiblePopup=!1,this.isCreate=!1,this.paymentTypes=[],this.entity=this.ENTITIES.PAYMENT,this.columns=[{dataField:"is_advance_payment",caption:d("common_payment_type"),width:110,allowSorting:!1,calculateCellValue:o=>o.is_advance_payment?o.amount<0?d("refund"):d("deposit"):d("rent")},{dataField:"paymentable",caption:d("payment_against"),cellTemplate:"paymentableLinkTemplate",width:140,allowSorting:!1},{dataField:"amount",caption:d("common_amount"),width:120,allowSorting:!1,format:{type:"fixedPoint",precision:2}},{dataField:"payment_type.name",caption:d("payment_mode"),allowSorting:!1},{dataField:"transaction_id",caption:d("common_transaction_id"),visible:!1,allowSorting:!1},{dataField:"cheque_number",caption:d("payment_cheque_number"),visible:!1,allowSorting:!1},{dataField:"created_user",caption:d("common_created_by"),cellTemplate:"employeeTemplate",allowSorting:!1},{dataField:"updated_user",caption:d("common_updated_by"),cellTemplate:"employeeTemplate",visible:!1,allowSorting:!1},{dataField:"comment",caption:d("common_comment"),cellTemplate:"commentTemplate",alignment:"center",visible:!1,allowSorting:!1},{dataField:"updated_at",caption:d("common_updated_on"),cellTemplate:"dateTimeTemplate",alignment:"center",visible:!1,allowSorting:!0},{dataField:"created_at",caption:d("common_created_on"),cellTemplate:"dateTimeTemplate",alignment:"center",visible:!1,allowSorting:!0},{name:"actions",caption:"",cellTemplate:"actionTemplate",allowExporting:!1,allowSorting:!1,showInColumnChooser:!1}],this.PAYMENT_CONTEXT_MENU_LIST=Dt,this.paymentContextMenu=[]}ngOnInit(){this.buildPaymentContextMenu(),this.getPaymentTypes()}getPaymentTypes(){this.paymentTypeService.getAll().subscribe({next:e=>{this.paymentTypes=e},error:e=>{}})}get canCollectPayment(){return this.isEmployee&&this.userPermissionList.includes(g.PAYMENT_WRITE)}buildPaymentContextMenu(){this.paymentContextMenu=[{name:Dt.EDIT,icon:Z.EDIT.light,visible:this.isEmployee,locale_key:d("common_edit")},{name:Dt.DELETE,icon:Z.DELETE.light,visible:this.isAdmin||this.userPermissionList.includes(g.PAYMENT_DELETE),locale_key:d("common_delete"),destructive:!0}]}onContextMenuItemClick(e){e.action===Dt.EDIT&&this.edit(e.entity),e.action===Dt.DELETE&&this.dataGrid.delete(e.entity)}create(){this.isCreate=!0,this.payment=null,this.isVisiblePopup=!0}edit(e){this.isCreate=!1,this.payment=e,this.isVisiblePopup=!0}onSavePayment(){this.isVisiblePopup=!1,this.payment=null,this.dataGrid?.getData(),this.rentalContract?.id&&this.rentalContractService.refreshDetail(this.rentalContract.id).subscribe()}static{this.\u0275fac=function(o){return new(o||t)(X(Bo))}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-payment-list"]],viewQuery:function(o,i){if(o&1&&fe(ee,5),o&2){let _;he(_=xe())&&(i.dataGrid=_.first)}},inputs:{rentalContract:"rentalContract",isOnAside:"isOnAside"},decls:2,vars:2,consts:[[3,"additionalParams","columns","entity","isVisibleAddAction","isVisibleTitle","isVisibleEditAction","isVisibleDeleteAction","isVisibleExportAction","paymentTypes","service"],[3,"entity","entityType","isCreate","isVisiblePopup","payment"],[3,"dataGridAddNewClick","dataGridEditClick","additionalParams","columns","entity","isVisibleAddAction","isVisibleTitle","isVisibleEditAction","isVisibleDeleteAction","isVisibleExportAction","paymentTypes","service"],["appCardTemplate",""],[3,"toggleExpand","expandable","expanded","isVisibleAgainst","payment"],["ngProjectAs","[cardDetail
1s]",5,["","cardDetails",""]],[1,"d-flex","align-items-center","justify-content-between","gap-2","fs-body-sm"],[3,"contextMenuItemClick","contextMenuItems","entityName","entity","mobileSheet","showDocuments"],[3,"entity","subtitle","title","user"],[1,"text-muted","text-truncate"],[1,"text-truncate"],[3,"addPaymentClose","addPaymentSave","entity","entityType","isCreate","isVisiblePopup","payment"]],template:function(o,i){o&1&&(f(0,Qs,2,13,"app-data-grid",0),f(1,Ks,1,5,"app-add-payment-popup",1)),o&2&&(h(i.rentalContract!=null&&i.rentalContract.id?0:-1),n(),h(i.rentalContract!=null&&i.rentalContract.id&&i.isVisiblePopup?1:-1))},dependencies:[ee,Ho,De,Ue,Uo,Be],encapsulation:2})}}return t})();var nn=(()=>{class t{constructor(){this.formatMessage=d,this.rentalContractService=x(F),this.destroyRef=x(O),this.rentalContract=null}ngOnInit(){this.rentalContractService.currentContract$.pipe(S(this.destroyRef)).subscribe({next:e=>{this.rentalContract=e}})}static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-contract-payments"]],decls:1,vars:1,consts:[[3,"rentalContract"]],template:function(o,i){o&1&&m(0,"app-rental-payment-list",0),o&2&&l("rentalContract",i.rentalContract)},dependencies:[tn],encapsulation:2})}}return t})();var zs=t=>({rental_contract_id:t});function Xs(t,c){if(t&1&&(m(0,"div",13),M(1,"safe")),t&2){let e=s().$implicit;l("innerHTML",N(1,1,e.comment,"html"),gt)}}function Zs(t,c){if(t&1){let e=T();r(0,"div",7)(1,"div",8)(2,"span",9),p(3),a(),m(4,"app-status-badge",10),a(),r(5,"div",11)(6,"div",12),p(7),a(),f(8,Xs,2,4,"div",13),a(),m(9,"hr",14),r(10,"div",15)(11,"span",16),p(12),M(13,"dateFormat"),a(),r(14,"div",17),y("click",function(i){return i.stopPropagation()}),r(15,"span",18),m(16,"app-money",19),a(),r(17,"app-context-menu",20),y("contextMenuItemCancelClick",function(){v(e);let i=s(2);return C(i.onCloseContextMenuOption())})("contextMenuItemClick",function(i){v(e);let _=s(2);return C(_.onContextMenuItemClick(i))}),r(18,"app-sheet-header",21)(19,"div",22),m(20,"app-money",19),a(),m(21,"app-status-badge",10),a()()()()()}if(t&2){let e=c.$implicit,o=s(2);n(3),U("",o.formatMessage("deposit")," #",e.id),n(),l("status",e.status),n(3),u(e.payment_type==null?null:e.payment_type.name),n(),h(e.comment?8:-1),n(4),u(Dn(13,15,e.collected_at)),n(4),l("value",e.amount),n(),l("contextMenuItems",o.depositContextMenu)("entityName",o.entity.name)("entity",e)("mobileSheet",!0)("showDocuments",!0),n(),l("title",o.formatMessage("deposit")+" #"+e.id),n(2),l("value",e.amount),n(),l("status",e.status)}}function Js(t,c){if(t&1){let e=T();m(0,"app-rental-deposit-summary",4),r(1,"app-data-grid",5),y("contextMenuItemCancelClick",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())})("contextMenuItemClick",function(i){v(e);let _=s();return C(_.onContextMenuItemClick(i))})("dataGridAddNewClick",function(){v(e);let i=s();return C(i.openCollectDeposit())}),I(2,Zs,22,17,"ng-template",6),a()}if(t&2){let e=s();l("collected",e.collectedAmount)("expected",e.expectedAmount)("outstanding",e.outstandingAmount),n(),l("additionalParams",ye(15,zs,e.rentalContractId))("columns",e.columns)("contextMenuItems",e.depositContextMenu)("dataGridId","rentalDepositGrid")("entity",e.entity)("isVisibleAddAction",e.canWrite)("writeAccessPermissionName",e.PERMISSION_LIST.RENTAL_CONTRACT_WRITE)("isVisibleEditAction",!1)("isVisibleDeleteAction",!1)("isVisibleExportAction",!1)("service",e.service)("showColumnLines",!0)}}function ec(t,c){if(t&1){let e=T();r(0,"app-confirmation-popup",23),y("confirmActionCallback",function(){v(e);let i=s();return C(i.refund())})("rejectActionCallback",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())}),a()}if(t&2){let e=s();l("confirmButtonText","refund")("confirmationMessage",e.formatMessage("refund_deposit_confirmation"))("isSaving",e.isRefunding)}}function tc(t,c){if(t&1){let e=T();r(0,"app-archive-delete-popup",24),W("isVisibleChange",function(i){v(e);let _=s();return G(_.isVisibleArchiveDeletePopup,i)||(_.isVisibleArchiveDeletePopup=i),C(i)}),y("onSuccess",function(){v(e);let i=s();return C(i.handleArchiveDeleteSuccess())})("onCancel",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())}),a()}if(t&2){let e=s();Y("isVisible",e.isVisibleArchiveDeletePopup),l("service",e.service)("entity",e.selectedItem)("entityName",e.entity.name)("entityDisplayName",e.entity.displayName)}}function ic(t,c){if(t&1){let e=T();r(0,"app-rental-deposit-popup",25),y("depositChange",function(){v(e);let i=s();return C(i.onDepositChange())})("popupClose",function(){v(e);let i=s();return C(i.onCloseContextMenuOption())}),a()}if(t&2){let e=s();l("deposit",e.selectedItem)("isVisiblePopup",e.isVisibleDepositPopup)("rentalContract",e.rentalContract)}}var on=(()=>{class t{get deposits(){return this.dataGrid?.rows||[]}get expectedAmount(){return+this.rentalContract?.deposit_amount||0}get collectedAmount(){return Yt({deposits:this.deposits})}get outstandingAmount(){return Math.max(0,this.expectedAmount-this.collectedAmount)}get canWrite(){if(!this.isEmployee||!this.userPermissionList.includes(g.RENTAL_CONTRACT_WRITE))return!1;let e=this.rentalContract?.status;return e!==A.COMPLETED&&e!==A.CANCELLED}get canDelete(){return this.isEmployee&&this.userPermissionList.includes(g.RENTAL_CONTRACT_DELETE)}constructor(e){this.service=e,this.formatMessage=d,this.entity=b.RENTAL_DEPOSIT,this.PERMISSION_LIST=g,this.RENTAL_DEPOSIT_CONTEXT_MENU_LIST=tt,this.rentalContractService=x(F),this.userSessionService=x(k),this.toastNotificationService=x(B),this.destroyRef=x(O),this.isEmployee=this.userSessionService.isEmployee(),this.userPermissionList=this.userSessionService.userPermissionList(),this.rentalContract=null,this.rentalContractId=null,this.isVisibleDepositPopup=!1,this.isVisibleRefundPopup=!1,this.isRefunding=!1,this.depositToRefund=null,this.selectedItem=null,this.isVisibleArchiveDeletePopup=!1,this.depositContextMenu=[],this.columns=[{dataField:"amount",caption:d("common_amount"),dataType:"number",allowSorting:!1,alignment:"center",format:{type:"fixedPoint",precision:2}},{dataField:"collected_at",caption:d("common_date"),allowSorting:!1,alignment:"center",cellTemplate:"dateTemplate"},{dataField:"payment_type.name",caption:d("common_payment_type"),allowSorting:!1,alignment:"center"},{dataField:"status",caption:d("common_status"),allowSorting:!1,alignment:"center",width:110,cellTemplate:"statusTemplate"},{name:"actions",caption:"",alignment:"center",cssClass:"custom-action",cellTemplate:"actionTemplate",allowExporting:!1,allowSorting:!1,showInColumnChooser:!1}]}ngOnInit(){this.rentalContractService.currentContract$.pipe(S(this.destroyRef)).subscribe({next:e=>{e?.id&&(this.rentalContract=e,this.rentalContractId=e.id,this.buildContextMenu())},error:e=>console.error(e)}),this.rentalContractService.depositsChanged$.pipe(S(this.destroyRef)).subscribe(()=>this.dataGrid?.getData())}buildContextMenu(){this.depositContextMenu=[{name:tt.EDIT,icon:Z.EDIT.light,visible:this.canWrite,isDisabled:e=>e?.status===cn.REFUNDED,locale_key:d("edit_deposit")},{name:tt.REFUND,icon:Z.RETURN.light,visible:this.canWrite,isDisabled:e=>e?.status===cn.REFUNDED,locale_key:d("refund")},{name:tt.DELETE,icon:Z.DELETE.light,visible:this.canDelete,locale_key:d("delete_deposit"),destructive:!0}]}onContextMenuItemClick(e){let o=e.entity;this.selectedItem=o,e.action===tt.EDIT?this.isVisibleDepositPopup=!0:e.action===tt.REFUND?this.confirmRefund(o):e.action===tt.DELETE&&(this.isVisibleArchiveDeletePopup=!0)}onCloseContextMenuOption(){this.isVisibleDepositPopup=!1,this.isVisibleRefundPopup=!1,this.isVisibleArchiveDeletePopup=!1,this.depositToRefund=null,this.selectedItem=null}handleArchiveDeleteSuccess(){this.isVisibleArchiveDeletePopup=!1,this.selectedItem=null,this.onDepositChange()}confirmRefund(e){e?.id&&(this.depositToRefund=e,this.isVisibleRefundPopup=!0)}openCollectDeposit(){this.selectedItem=null,this.isVisibleDepositPopup=!0}onDepositChange(){this.dataGrid?.getData(),this.rentalContractService.refreshDetail(this.rentalContractId).subscribe()}refund(){let e=this.depositToRefund;e?.id&&(this.isRefunding=!0,this.rentalContractService.refundDeposit(e.id).pipe(S(this.destroyRef)).subscribe({next:()=>{this.toastNotificationService.success(d("refund_deposit_success")),this.onDepositChange()},error:o=>{this.toastNotificationService.error(o?.error?.message||d("something_went_wrong"))}}).add(()=>{this.isRefunding=!1,this.onCloseContextMenuOption()}))}static{this.\u0275fac=function(o){return new(o||t)(X(qt))}}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-contract-deposits"]],viewQuery:function(o,i){if(o&1&&fe(ee,5),o&2){let _;he(_=xe())&&(i.dataGrid=_.first)}},decls:5,vars:4,consts:[[1,"mt-1"],[3,"confirmButtonText","confirmationMessage","isSaving"],[3,"isVisible","service","entity","entityName","entityDisplayName"],[3,"deposit","isVisiblePopup","rentalContract"],[3,"collected","expected","outstanding"],[3,"contextMenuItemCancelClick","contextMenuItemClick","dataGridAddNewClick","additionalParams","columns","contextMenuItems","dataGridId","entity","isVisibleAddAction","writeAccessPermissionName","isVisibleEditAction","isVisibleDeleteAction","isVisibleExportAction","service","showColumnLines"],["appCardTemplate",""],[1,"app-card"],[1,"d-flex","align-items-center","justify-content-between","gap-2","mb-2"],[1,"fs-label","text-muted","text-truncate"],["kind","rental",3,"status"],[1,"min-width-0"],[1,"fs-subsection","fw-bold","text-truncate"],[1,"fs-label","text-muted","app-line-clamp-1",3,"innerHTML"],[1,"my-2"],[1,"d-flex","align-items-center","justify-content-between","gap-2"],[1,"fs-label","text-muted"],[1,"d-flex","align-items-center","gap-2","flex-shrink-0",3,"click"],[1,"fs-label","fw-bold"],[3,"value"],[3,"contextMenuItemCancelClick","contextMenuItemClick","contextMenuItems","entityName","entity","mobileSheet","showDocuments"],[3,"title"],["sheetSubtitle","",1,"fs-label","text-muted","text-truncate"],[3,"confirmActionCallback","rejectActionCallback","confirmButtonText","confirmationMessage","isSaving"],[3,"isVisibleChange","onSuccess","onCancel","isVisible","service","entity","entityName","entityDisplayName"],[3,"depositChange","popupClose","deposit","isVisiblePopup","rentalContract"]],template:function(o,i){o&1&&(r(0,"div",0),f(1,Js,3,17),a(),f(2,ec,1,3,"app-confirmation-popup",1),f(3,tc,1,5,"app-archive-delete-popup",2),f(4,ic,1,3,"app-rental-deposit-popup",3)),o&2&&(n(),h(i.rentalContractId?1:-1),n(),h(i.isVisibleRefundPopup?2:-1),n(),h(i.isVisibleArchiveDeletePopup&&i.selectedItem?3:-1),n(),h(i.rentalContractId&&i.isVisibleDepositPopup?4:-1))},dependencies:[Wi,ee,_e,H,De,Ue,yi,Ft,Ae,Be,Bt,oe],encapsulation:2})}}return t})();function nc(t,c){if(t&1&&m(0,"app-send-whats-app-btn",2),t&2){let e,o=s();
1l("entityId",(e=o.entity())==null?null:e.id)("entityName",o.ENTITIES.RENTAL_CONTRACT.name)}}function oc(t,c){if(t&1){let e=T();r(0,"app-entity-documents-button",10),y("documentCreate",function(i){v(e);let _=s();return C(_.onDocumentCreate(i))}),a()}if(t&2){let e,o=s();l("allowCreate",o.isEmployee)("createTypes",o.documentCreateTypes)("entityId",(e=o.entity())==null?null:e.id)("entityType",o.ENTITIES.RENTAL_CONTRACT.name)("showLabel",!o.isMobileDevice)}}function ac(t,c){if(t&1){let e=T();r(0,"app-rental-deposit-popup",11),y("depositChange",function(){v(e);let i=s();return C(i.onDepositChange())})("popupClose",function(){v(e);let i=s();return C(i.isVisibleDepositPopup.set(!1))}),a()}if(t&2){let e=s();l("isVisiblePopup",e.isVisibleDepositPopup())("rentalContract",e.entity())}}var an=(()=>{class t extends Bi{constructor(){super(...arguments),this.entityType=this.ENTITIES.RENTAL_CONTRACT.name,this.routeParam="rental_contract_id",this.rentalContractService=x(F),this.documentCreateTypes=["payment_receipt","deposit_receipt"],this.isVisibleDepositPopup=We(!1)}fetch(e){return this.rentalContractService.getDetailById(e)}onDocumentCreate(e){if(e==="deposit_receipt"){this.isVisibleDepositPopup.set(!0);return}super.onDocumentCreate(e)}onDepositChange(){let e=this.entity()?.id;this.documentService.invalidate(this.entityType,e),this.consume(this.fetch(e))}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=we(t)))(i||t)}})()}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-contract"]],features:[Me],decls:10,vars:18,consts:[[3,"loadFailed","entityType","entityId","heading"],["ngProjectAs","[actions]",5,["","actions",""]],[3,"entityId","entityName"],[3,"allowCreate","createTypes","entityId","entityType","showLabel"],[3,"entityId","entityName","isVisiblePrintButton","isVisibleThermalPrint"],[3,"entityId","entityType"],[1,"app-document-back"],["edit","",3,"entityType","entityId"],["signature","",3,"business","entityId","entityType"],[3,"isVisiblePopup","rentalContract"],[3,"documentCreate","allowCreate","createTypes","entityId","entityType","showLabel"],[3,"depositChange","popupClose","isVisiblePopup","rentalContract"]],template:function(o,i){if(o&1&&(r(0,"app-document-shell",0),Ne(1,1),f(2,nc,1,2,"app-send-whats-app-btn",2),f(3,oc,1,5,"app-entity-documents-button",3),m(4,"app-print-button",4)(5,"app-share-btn",5)(6,"app-location-back",6),Ve(),m(7,"app-entity-edit-button",7)(8,"app-invoice-signature",8),a(),f(9,ac,1,2,"app-rental-deposit-popup",9)),o&2){let _,L,_t,Ke,xt,ze,ue,yt,ni;l("loadFailed",i.loadFailed())("entityType",i.ENTITIES.RENTAL_CONTRACT.name)("entityId",(_=i.entity())==null?null:_.id)("heading",(L=i.entity())==null?null:L.rental_number),n(2),h(i.entity()&&i.isEmployee?2:-1),n(),h((_t=i.entity())!=null&&_t.id?3:-1),n(),l("entity
1Id",(Ke=i.entity())==null?null:Ke.id)("entityName",i.ENTITIES.RENTAL_CONTRACT.name)("isVisiblePrintButton",!!((xt=i.entity())!=null&&xt.id))("isVisibleThermalPrint",!1),n(),l("entityId",(ze=i.entity())==null?null:ze.id)("entityType",i.ENTITIES.RENTAL_CONTRACT.name),n(2),l("entityType",i.ENTITIES.RENTAL_CONTRACT.name)("entityId",(ue=i.entity())==null?null:ue.id),n(),l("business",(yt=i.entity())==null?null:yt.business_identity)("entityId",(ni=i.entity())==null?null:ni.id)("entityType",i.signatureEntityType),n(),h(i.isVisibleDepositPopup()&&i.entity()?9:-1)}},dependencies:[Fi,so,qo,Ht,Ai,Yi,Ui,Lt,Ae],encapsulation:2})}}return t})();function rc(t,c){if(t&1&&m(0,"app-entity-documents-button",2),t&2){let e,o=s();l("entityId",(e=o.entity())==null?null:e.id)("entityType",o.ENTITIES.RENTAL_DEPOSIT.name)("showLabel",!o.isMobileDevice)}}var rn=(()=>{class t extends Bi{constructor(){super(...arguments),this.entityType=this.ENTITIES.RENTAL_DEPOSIT.name,this.routeParam="rental_deposit_id",this.rentalDepositService=x(qt)}fetch(e){return this.rentalDepositService.getById(e)}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=we(t)))(i||t)}})()}static{this.\u0275cmp=E({type:t,selectors:[["app-rental-deposit-receipt"]],features:[Me],decls:7,vars:14,consts:[[3,"loadFailed","entityType","entityId","heading"],["ngProjectAs","[actions]",5,["","actions",""]],[3,"entityId","entityType","showLabel"],[3,"entityId","entityName","isVisiblePrintButton","isVisibleThermalPrint"],[3,"entityId","entityType"],[1,"app-document-back"],["signature","",3,"business","entityId","entityType"]],template:function(o,i){if(o&1&&(r(0,"app-document-shell",0),Ne(1,1),f(2,rc,1,3,"app-entity-documents-button",2),m(3,"app-print-button",3)(4,"app-share-btn",4)(5,"app-location-back",5),Ve(),m(6,"app-invoice-signature",6),a()),o&2){let _,L,_t,Ke,xt,ze,ue;l("loadFailed",i.loadFailed())("entityType",i.ENTITIES.RENTAL_DEPOSIT.name)("entityId",(_=i.entity())==null?null:_.id)("heading",i.formatMessage("deposit_receipt")),n(2),h((L=i.entity())!=null&&L.id?2:-1),n(),l("entity
1Id",(_t=i.entity())==null?null:_t.id)("entityName",i.ENTITIES.RENTAL_DEPOSIT.name)("isVisiblePrintButton",!!((Ke=i.entity())!=null&&Ke.id))("isVisibleThermalPrint",!1),n(),l("entityId",(xt=i.entity())==null?null:xt.id)("entityType",i.ENTITIES.RENTAL_DEPOSIT.name),n(2),l("business",(ze=i.entity())==null?null:ze.business_identity)("entityId",(ue=i.entity())==null?null:ue.id)("entityType",i.signatureEntityType)}},dependencies:[Fi,Ht,Ai,Yi,Ui,Lt],encapsulation:2})}}return t})();var lc=[{path:"",component:Gi,children:[{path:"list",component:Hi,canActivate:[ve],data:{tab_index:0,permissions:{only:[g.RENTAL_CONTRACT_LIST],redirectTo:"/dashboards"}},title:()=>d("tour_rental_s4_title")},{path:"devices",component:ji,canActivate:[ve],data:{tab_index:1,permissions:{only:[g.RENTAL_CONTRACT_LIST],redirectTo:"/rentals/list"}},title:()=>d("rental_device")},{path:"devices/:rental_device_id",component:ea,canActivate:[ve],data:{tab_index:1,permissions:{only:[g.RENTAL_CONTRACT_LIST],redirectTo:"/rentals/devices"}},title:()=>d("route_title_rental_device")},{path:"overview",component:qi,canActivate:[ve],data:{tab_index:2,permissions:{only:[g.RENTAL_CONTRACT_LIST],redirectTo:"/rentals/list"}},title:()=>d("route_title_rentals_overview")},{path:"reports",component:ta,canActivate:[ve],data:{tab_index:3,permissions:{only:[g.RENTAL_REPORT],redirectTo:"/rentals/list"}},title:()=>d("rental_reports")},{path:"settings",component:$i,canActivate:[ve],data:{tab_index:4,permissions:{only:[g.RENTAL_SETTINGS],redirectTo:"/rentals/list"}},title:()=>d("rental_settings")},{path:"add",component:ii,canActivate:[ve],data:{header:{title:"create_new_rental_contract"},permissions:{only:[g.RENTAL_CONTRACT_WRITE],redirectTo:"/rentals/list"}},title:()=>d("create_new_rental_contract")},{path:"edit/:id",component:ii,canActivate:[ve],data:{permissions:{only:[g.RENTAL_CONTRACT_WRITE],redirectTo:"/rentals/list"}},title:()=>d("route_title_edit_rental_contract")},{path:":rental_contract_id",component:Ki,canActivate:[ve],data:{tab_index:0,permissions:{only:[g.RENTAL_CONTRACT_LIST],redirectTo:"/rentals/list"}},children:[{path:"overview",component:Zi,data:{tab_index:0},pathMatch:"full",title:()=>d("route_title_rental_contract_overview")},{path:"details",component:Ji,data:{tab_index:1},title:()=>d("route_title_rental_contract_details")},{path:"devices",component:en,data:{tab_index:2},title:()=>d("route_title_rental_contract_devices")},{path:"payments",component:nn,data:{tab_index:3},title:()=>d("route_title_rental_contract_payments")},{path:"deposits",component:on,data:{tab_index:4},title:()=>d("route_title_rental_contract_deposits")},{path:"",redirectTo:"overview",pathMatch:"full"}]},{path:":rental_contract_id/rentalContract",component:an,canActivate:[ve],data:{permissions:{only:[g.RENTAL_CONTRACT_WRITE,g.RENTAL_CONTRACT_LIST],redirectTo:"/rentals/list"}},pathMatch:"full",title:()=>d("route_title_rental_contract")},{path:":rental_contract_id/paymentReceipts/:payment_id",component:$o,canActivate:[ve],data:{permissions:{only:[g.PAYMENT_WRITE,g.PAYMENT_DELETE],redirectTo:"/rentals/list"}},title:()=>d("payment_receipt_title")},{path:":rental_contract_id/depositReceipts/:rental_deposit_id",component:rn,canActivate:[ve],data:{permissions:{only:[g.RENTAL_CONTRACT_WRITE,g.RENTAL_CONTRACT_LIST],redirectTo:"/rentals/list"}},title:()=>d("deposit_receipt")},{path:"",redirectTo:"list",pathMatch:"full"}]}],ma=(()=>{class t{static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275mod=li({type:t})}static{this.\u0275inj=ri({imports:[sn.forChild(no(lc)),sn]})}}return t})();var zx=(()=>{class t{static{this.\u0275fac=function(o){return new(o||t)}}static{this.\u0275mod=li({type:t})}static{this.\u0275inj=ri({imports:[Gi,qi,Hi,ji,ii,$i,Ki,Zi,Ji,en,nn,an,tn,Xi,Ge,Ae,rn,on,Qi,ma,zi,Ye]})}}return t})();export{zx as RentalModule};

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.