1import{$c as g,A as c,Ag as Q,D as p,Dg as K,Eg as U,F as s,Gc as G,Hf as M,If as T,Jd as d,Je as N,Kd as k,Mg as q,Og as C,Pg as J,Sg as u,Yc as l,Zc as y,_b as V,_c as O,b as R,cc as F,ce as b,de as D,ed as x,kc as f,pc as w,pd as j,s as I,uc as L,v as B}from"./chunk-DYSAII2F.js";import{g as X,j as v}from"./chunk-B6OI3ZQI.js";var ht=(()=>{class r{static{this.STORAGE_FISCAL_TOKEN="fiscal.token"}constructor(t,i,e,a,n,o,h,S,m){this.api=t,this.shiftService=i,this.languageService=e,this.storageService=a,this.authService=n,this.snackService=o,this.translateService=h,this.utilService=S,this.priceInCentsPipe=m,this._token=null,this._shift=null,this._interval=5*1e3,a.get(r.STORAGE_FISCAL_TOKEN)&&(this.token=parseFloat(a.get(r.STORAGE_FISCAL_TOKEN)),this.isOperationPending=!0,this.getOperationStatus())}get token(){return this._token}set token(t){this._token=t,this.storageService.set(r.STORAGE_FISCAL_TOKEN,t)}removeToken(){this._token=null,this.storageService.remove(r.STORAGE_FISCAL_TOKEN)}get shift(){return this._shift}set shift(t){this._shift=t}get isReady(){return this.shift&&[j.Started,j.StartedPreviousUnfinished].indexOf(this.shift.status)!==-1&&this.shift.start&&!this.shift.end}set fiscal(t){this.token=t.operationToken,t.shift&&(this.shift=t.shift),this.isOperationPending=!0,this.printFiscal()}getShiftStatus(){this.shiftService.shiftStatusGet().pipe(c({error:t=>this.snackService.showBackendError(t)})).subscribe(t=>{this.shift=t,!this.shift&&this.authService.checkSalespointProperty("cashier_auto_start")&&this.startDay()})}getOperationStatus(){this.isOperationPending&&this.api.fiscalStatusIdGet(this.token).pipe(c({error:t=>{this.isOperationPending&&setTimeout(()=>this.getOperationStatus(),this._interval)}})).subscribe(t=>{t.fiscal?.status===g.Pending?setTimeout(()=>this.getOperationStatus(),this._interval):(this.isOperationPending=!1,this.removeToken(),t.fiscal.status===g.Success?(t.shift&&(this.shift=t.shift),this.snackService.showSuccess(this.translateService.instant(t.fiscal.message)),this.utilService.fiscalOperationFinished.emit()):t.fiscal.status===g.Failure&&(this.snackService.showError(this.translateService.instant(t.fiscal.message)),this.utilService.fiscalOperationFailed.emit()))})}printFiscal(){let t=this.api.fiscalTransactionPrintIdGet(this.token,this.languageService.selectedLang,x.Regular);this.isTransaction||(t=this.api.fiscalPrintIdGet(this.token)),this.isTransaction=!1,t.pipe(c({error:i=>this.snackService.showBackendError(i)})).subscribe(i=>{let e=d.getFileData("json_fiscal","json"),a;e.firefox?(a=new File([i],e.filename,{type:e.mime}),window.location.href=URL.createObjectURL(a)):(a=new Blob([i],{type:e.mime}),N(a,e.filename)),this.getOperationStatus()})}printTransaction(t){return this.api.fiscalTransactionPrintIdGet(this.token,this.languageService.selectedLang,t).pipe(c({error:i=>this.snackService.showBackendError(i)}))}cancelOperation(){this.api.fiscalCancelIdPost(this.token).pipe(c({error:t=>this.snackService.showBackendError(t)})).subscribe(()=>{this.getShiftStatus(),this.removeToken(),this.isOperationPending=!1,this.utilService.fiscalOperationFailed.emit()})}cut(){this.fiscalOperation(l.Cut).subscribe(t=>this.fiscal=t)}feed(){this.fiscalOperation(l.Feed).subscribe(t=>this.fiscal=t)}openCashRegister(){this.fiscalOperation(l.Opencashreg).subscribe(t=>this.fiscal=t)}xReport(){this.fiscalOperation(l.Xreport).subscribe(t=>this.fiscal=t)}fiscalOperation(t){return this.api.fiscalOperationPost({operation:t}).pipe(c({error:i=>this.snackService.showBackendError(i)}))}startDay(){this.fiscalShift(O.Startshift).subscribe(t=>this.fiscal=t)}endDay(){this.fiscalShift(O.Endshift).subscribe(t=>this.fiscal=t)}fiscalShift(t){return this.api.fiscalShiftPost({operation:t}).pipe(c({error:i=>{i.error?.message==="api_fiscal_shift_not_finished"?this.endDay():this.snackService.showBackendError(i)}}))}cashIn(t){this.fiscalCash(y.Insertcash,this.priceInCentsPipe.transform(t)).subscribe(i=>this.fiscal=i)}cashOut(t){this.fiscalCash(y.Withdrawcash,this.priceInCentsPipe.transform(t)).subscribe(i=>this.fiscal=i)}fiscalCash(t,i){return this.api.fiscalCashPost({operation:t,amount:i}).pipe(c({error:e=>this.snackService.showBackendError(e)}))}scrap(t){return this.api.fiscalScrapPost(t).pipe(c({next:i=>this.fiscal=i,error:i=>this.snackService.showBackendError(i)}))}checkout(t){return this.api.fiscalCheckoutPost(t).pipe(c({next:i=>{this.isOperationPending=!0,this.token=i.operationToken,this.getOperationStatus()},error:i=>this.snackService.showBackendError(i)}))}bookingCheckout(t,i){return this.api.fiscalBookingIdCheckoutPost(i,this.languageService.selectedLang,t).pipe(c({next:e=>{this.isOperationPending=!0,this.token=e.operationToken},error:e=>this.snackService.showBackendError(e)}))}refund(t){this.isTransaction=!0,this.api.fiscalRefundPost(t).pipe(c({error:i=>this.snackService.showBackendError(i)})).subscribe(i=>this.fiscal=i)}static{this.\u0275fac=function(i){return new(i||r)(s(L),s(G),s(k),s(f),s(T),s(b),s(F),s(d),s(C))}}static{this.\u0275prov=p({token:r,factory:r.\u0275fac})}}return r})();var Tt=(()=>{class r extends Q{static{this.STORAGE_CART_SCRAP="cart.scrap"}constructor(t,i,e,a,n,o,h,S,m,P,E,_,A){super(e,a,n,o,h,S,m,P,E,_,A),this._api=t,this.cartService=i,this.authService=e,this.centrePropertyService=a,this.languageService=n,this.snackService=o,this.storageService=h,this.eventService=S,this.selfServiceEventService=m,this.routeService=P,this.priceInCentsPipe=E,this.ticketPricePipe=_,this.pricePipe=A,h.get(r.STORAGE_CART_SCRAP)&&(this._cart=JSON.parse(h.get(r.STORAGE_CART_SCRAP)))}get events(){return super.events}get cart(){return this._cart||this._emptyCart}set cart(t){this._cart=t,this.cartTotal=t.total,this.mapTickets(this._cart.events),this.updateSelectionMap(),this.storageService.set(r.STORAGE_CART_SCRAP,JSON.stringify(t))}retryCart(){this.storageService.get(r.STORAGE_CART_SCRAP)?(this.cart=JSON.parse(this.storageService.get(r.STORAGE_CART_SCRAP)),this.updateTotalScrapSum()):this.clearScrap()}subTotals(t){return this.cartService.subTotals(t)}updateSubTotals(t,i){if(this.isLoading=!0,this.hasSelectedTickets){this.retryCart();let e=this.getSelectedTicketIds.length;this.cart.total.ticketQuantity=e,this.cart.total.total=this.cart.total.total/(this.ticketCount||1)*e,this.cart.total.ticketTotal=this.cart.total.ticketTotal/(this.ticketCount||1)*e,this.cartTotal=this.cart.total,this.setSubTotals(this.cartTotal),this.isLoading=!1}else this.setSubTotals(v(this._emptyTotals)),this.isLoading=!1}clearScrap(){this.cart=v(this._emptyCart)}processScrap(t){return this._api.cartScrapPost(t).pipe(c({error:i=>this.snackService.showBackendError(i)}))}static{this.\u0275fac=function(i){return new(i||r)(s(w),s(u),s(T),s(M),s(k),s(b),s(f),s(K),s(U),s(D),s(C),s(J),s(q))}}static{this.\u0275prov=p({token:r,factory:r.\u0275fac})}}return r})();var W=X(V());var jt=(()=>
1{class r{constructor(t,i){this.storageService=t,this.cartService=i,this._subscriptions=[],this.typeTempCounts={},this._typeInitialCounts={},this.typeQuantities={},this.typeSubjects={},this.typeSubjectBuffer={},this.ticketTypeCountMap={}}initTicketTypeHandling(t,i,e){this.typeSubjects={},this.typeSubjectBuffer={},e&&(this.changeDetector=e),this.clearSubscriptions(),i?.forEach(a=>{a.boEvent&&(this.typeSubjects[a.id]=new R,this.typeSubjectBuffer[a.id]={},a.unassignedTickets?.length&&a.unassignedTickets.forEach(n=>{this._typeInitialCounts[n.ticketTypeUuid]=n.quantity,this.typeQuantities[n.ticketTypeUuid]=n.quantity}),this._subscriptions.push(this.typeSubjects[a.id].pipe(I(1e3)).subscribe(n=>{n?.length&&(this.toggleLoading(!0),t.setUnassignedTickets(a.id,n).pipe(B(()=>{this.typeTempCounts={},this.setInitialCounts(t.cart),this.typeSubjectBuffer[a.id]={},this.toggleLoading(!1)})).subscribe(o=>{t.cart=o.cart,this.updateCart(t,a.id,o.pricing)}))})))})}toggleLoading(t){this.typesLoading=t,this.cartService.isLoading=t,this.changeDetector&&this.changeDetector.markForCheck()}updateCart(t,i,e){t.caller=!0,this.storageService.set(u.STORAGE_CART_UPDATE,W.default.now()),t.updateCartForEvent(i),t.eventPricing=e}setInitialCounts(t){this._typeInitialCounts={},this.typeQuantities={},t?.events?.length&&t.events.forEach(i=>{i.unassignedTickets?.length&&i.unassignedTickets.forEach(e=>{this._typeInitialCounts[e.ticketTypeUuid]=e.quantity,this.typeQuantities[e.ticketTypeUuid]=e.quantity})})}changeTicketTypeCount(t,i,e){this.typesLoading||this.cartService.isLoading||(this.typeSubjectBuffer[i]||(this.typeSubjectBuffer[i]={}),this.typeQuantities[t]=e,this.typeTempCounts[t]=e-this._typeInitialCounts[t],this.typeTempCounts[t]===0?delete this.typeSubjectBuffer[i][t]:this.typeSubjectBuffer[i][t]={ticketTypeUuid:t,quantity:this.typeTempCounts[t]},this.typeSubjects[i]?.next(Object.values(this.typeSubjectBuffer[i])))}resetTicketTypeCounts(){this.ticketTypeCountMap={},this.cartService.eventPricing?.ticketTypes?.length&&this.cartService.eventPricing.ticketTypes.forEach(t=>{this.ticketTypeCountMap[t.uuid]=0})}getTicketTypeAvailable(t,i){let e=this.cartService.eventPricingMap?this.cartService.eventPricingMap[i]:null;return e?.ticketTypes.find(n=>n.uuid===t)?.available??(e?.available||0)}getTicketTypeInitialCount(t){return this._typeInitialCounts[t]||0}clearSubscriptions(){this._subscriptions.forEach(t=>t.unsubscribe()),this._subscriptions=[]}static{this.\u0275fac=function(i){return new(i||r)(s(f),s(u))}}static{this.\u0275prov=p({token:r,factory:r.\u0275fac,providedIn:"root"})}}return r})();export{ht as a,Tt as b,jt as c};
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.