import{c}from"./chunk-4DABTOZZ.js";import{a as Q}from"./chunk-HEC2ZS3L.js";import{a as A}from"./chunk-FNDXPXHD.js";import{a as l}from"./chunk-4EEGS4SZ.js";import{D as q,V as K,W as U,_ as V,ea as j,y as E}from"./chunk-3SGEAGU4.js";import{e as _}from"./chunk-PCQVD4UN.js";import{d as F}from"./chunk-LTTEKZWN.js";import{k as x}from"./chunk-PNYIEM2I.js";import{b as u}from"./chunk-DIZJ6SFW.js";import{B as N,C as J,h as b,i as G,j as B,k as H}from"./chunk-DQXXLIFV.js";import{$b as a,Ab as P,Bb as m,Fd as f,Gb as y,Ld as C,Rb as r,_ as $,ac as p,bc as s,ea as d,fd as w,kc as I,nb as n,ob as g,r as M,rc as S,sc as T,ta as D,tc as L,ud as R}from"./chunk-LU6Q5ONP.js";import{k as h}from"./chunk-5VMFMKJR.js";C();J();C();w();var z=(()=>{class t{static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275mod=m({type:t})}static{this.\u0275inj=d({imports:[f,u]})}}return t})();$();G();w();H();C();U();function W(t,O){if(t&1&&s(0,"paw-pdf-viewer-dialog",6),t&2){let o=I();r("pdfId",o.pdfId)("base64",o.pdfBase64)("isLoading",o.isLoading)("dialogRef",o.dialogRef)}}function X(t,O){t&1&&(a(0,"div"),s(1,"paw-spinner",7),p()),t&2&&(n(),r("showBackdrop",!0))}var ce=(()=>{class t{constructor(o,i){this.api=o,this.dialogService=i,this.pdfDocuments=[],this.isLoading=!1,this.model={},this.currentReportType="",this.renderRequestNo=0,this.inputFields={document:{id:"document",label:"Document",component:q,options:this.pdfDocuments,required:!0,valueMapper:e=>e.report,labelMapper:e=>`${e.report} - ${e.name}`||e.description||e.name||e.report,valueSetter:e=>e.option,onSelected:e=>h(this,null,function*(){this.model.document=e||void 0,yield this.renderPdf(e)})}}}ngOnChanges(o){this.inputFields.document.options=this.pdfDocuments,(o.pdfDocuments||o.acKey)&&this.pdfDocuments.length>0&&(this.model.document=this.pdfDocuments[0],this.renderPdf(this.model.document))}renderPdf(o){return h(this,null,function*(){if(!this.acKey||!o)return;let i=++this.renderRequestNo;this.isLoading=!0;try{let e=yield M(this.api.post(b.reports.paasPrintByAcKeyAndType,{acKey:this.acKey,type:o.report,fiscalize:!1}));if(i!==this.renderRequestNo)return;if(!e){this.dialogService.openTyped({id:l.DialogPrintTreeMenuError,type:"error",text:"GeneralError",confirmButtonLabel:"Confirm",denyButtonLabel:null});return}if(e.error){this.dialogService.openTyped({id:l.DialogPrintTreeMenuError,type:"error",text:e.error,confirmButtonLabel:"Confirm",denyButtonLabel:null});return}if(!e.stream){this.dialogService.openTyped({id:l.DialogPrintTreeMenuError,type:"error",text:"NoData",confirmButtonLabel:"Confirm",denyButtonLabel:null});return}this.currentReportType=o.report,this.pdfId=o.report,this.pdfBase64=e.stream}finally{i===this.renderRequestNo&&(this.isLoading=!1)}})}print(){this.pdfViewer?.print()}static{this.\u0275fac=function(i){return new(i||t)(g(B),g(x))}}static{this.\u0275cmp=P({type:t,selectors:[["paw-pdf-document-selector-component"]],viewQuery:function(i,e){if(i&1&&S(c,5),i&2){let v;T(v=L())&&(e.pdfViewer=v.first)}},inputs:{acKey:"acKey",docType:"docType",pdfDocuments:"pdfDocuments",dialogRef:"dialogRef"},standalone:!1,features:[D],decls:6,vars:4,consts:[[1,"paw-area-v","paw-holder"],[1,"paw-offset"],[1,"paw-label-width-m",3,"field","model"],[1,"paw-holder","paw-border-top"],[3,"pdfId","base64","isLoading","dialogRef",4,"ngIf"],[4,"ngIf"],[3,"pdfId","base64","isLoading","dialogRef"],["size","m",3,"showBackdrop"]],template:function(i,e){i&1&&(a(0,"div",0)(1,"div",1),s(2,"paw-input-field",2),p(),a(3,"div",3),y(4,W,1,4,"paw-pdf-viewer-dialog",4),p(),y(5,X,2,1,"div",5),p()),i&2&&(n(2),r("field",e.inputFields.document)("model",e.model),n(2),r("ngIf",e.pdfBase64),n(),r("ngIf",e.isLoading&&!e.pdfBase64))},dependencies:[R,K,E,c],encapsulation:2})}}return t})();w();var Ke=(()=>{class t{static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275mod=m({type:t})}static{this.\u0275inj=d({imports:[f,F,V,u,N,Q,A,j,_,z]})}}return t})();export{z as a,ce as b,Ke as c};
