@seniorsistemas/yms-integration 1.30.2 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/bundles/seniorsistemas-yms-integration.umd.js +96 -71
  2. package/bundles/seniorsistemas-yms-integration.umd.js.map +1 -1
  3. package/bundles/seniorsistemas-yms-integration.umd.min.js +1 -1
  4. package/bundles/seniorsistemas-yms-integration.umd.min.js.map +1 -1
  5. package/esm2015/src/wms/components/document-grid/document-grid.component.js +26 -16
  6. package/esm2015/src/wms/components/document-grid/insert-key/insert-key.component.js +30 -7
  7. package/esm2015/src/wms/components/document-grid/insert-key/insert-key.module.js +6 -5
  8. package/esm2015/src/wms/components/document-grid/register-document/register-document.component.js +5 -14
  9. package/esm5/src/wms/components/document-grid/document-grid.component.js +27 -16
  10. package/esm5/src/wms/components/document-grid/insert-key/insert-key.component.js +30 -7
  11. package/esm5/src/wms/components/document-grid/insert-key/insert-key.module.js +6 -5
  12. package/esm5/src/wms/components/document-grid/register-document/register-document.component.js +5 -14
  13. package/fesm2015/seniorsistemas-yms-integration.js +91 -67
  14. package/fesm2015/seniorsistemas-yms-integration.js.map +1 -1
  15. package/fesm5/seniorsistemas-yms-integration.js +96 -71
  16. package/fesm5/seniorsistemas-yms-integration.js.map +1 -1
  17. package/package.json +1 -1
  18. package/seniorsistemas-yms-integration.metadata.json +1 -1
  19. package/src/wms/components/document-grid/document-grid.component.d.ts +5 -5
  20. package/src/wms/components/document-grid/insert-key/insert-key.component.d.ts +4 -2
  21. package/src/wms/components/document-grid/register-document/register-document.component.d.ts +2 -3
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("rxjs"),require("rxjs/operators"),require("@angular/common"),require("@angular/core"),require("@ngx-translate/core"),require("@seniorsistemas/angular-components"),require("primeng/message"),require("primeng/table"),require("@angular/common/http"),require("primeng/api"),require("@seniorsistemas/yms-routines"),require("@angular/animations"),require("@seniorsistemas/platform-components"),require("@stomp/ng2-stompjs"),require("sockjs-client"),require("ngx-cookie-service"),require("primeng/components/dynamicdialog/dynamicdialog"),require("primeng/primeng"),require("@seniorsistemas/yms-components"),require("@angular/router"),require("primeng/inputswitch"),require("primeng/inputtext"),require("@angular/forms"),require("moment"),require("primeng/components/common/messageservice"),require("primeng/shared"),require("primeng/button"),require("ngx-highlightjs"),require("primeng/accordion"),require("primeng/confirmdialog"),require("primeng/dialog"),require("primeng/dropdown"),require("primeng/panel"),require("angular2-hotkeys"),require("primeng/components/common/api"),require("highlight.js/lib/languages/json"),require("highlight.js/lib/languages/xml")):"function"==typeof define&&define.amd?define("@seniorsistemas/yms-integration",["exports","rxjs","rxjs/operators","@angular/common","@angular/core","@ngx-translate/core","@seniorsistemas/angular-components","primeng/message","primeng/table","@angular/common/http","primeng/api","@seniorsistemas/yms-routines","@angular/animations","@seniorsistemas/platform-components","@stomp/ng2-stompjs","sockjs-client","ngx-cookie-service","primeng/components/dynamicdialog/dynamicdialog","primeng/primeng","@seniorsistemas/yms-components","@angular/router","primeng/inputswitch","primeng/inputtext","@angular/forms","moment","primeng/components/common/messageservice","primeng/shared","primeng/button","ngx-highlightjs","primeng/accordion","primeng/confirmdialog","primeng/dialog","primeng/dropdown","primeng/panel","angular2-hotkeys","primeng/components/common/api","highlight.js/lib/languages/json","highlight.js/lib/languages/xml"],t):t(((e=e||self).seniorsistemas=e.seniorsistemas||{},e.seniorsistemas["yms-integration"]={}),e.rxjs,e.rxjs.operators,e.ng.common,e.ng.core,e.core$1,e.angularComponents,e.message,e.table,e.ng.common.http,e.api,e.ymsRoutines,e.ng.animations,e.platformComponents,e.ng2Stompjs,e.SockJS,e.ngxCookieService,e.dynamicdialog,e.primeng,e.ymsComponents,e.ng.router,e.inputswitch,e.inputtext,e.ng.forms,e._moment,e.messageservice,e.shared,e.button,e.ngxHighlightjs,e.accordion,e.confirmdialog,e.dialog,e.dropdown,e.panel,e.angular2Hotkeys,e.api$1,e.jsonx,e.xmlx)}(this,function(e,t,a,i,r,o,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F,S,D,C,_,I,T,k,M,R,E,N,A,w,G,O,x,L){"use strict";x=x&&Object.prototype.hasOwnProperty.call(x,"default")?x["default"]:x,L=L&&Object.prototype.hasOwnProperty.call(L,"default")?L["default"]:L;var q=function(e,t){return(q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)t.hasOwnProperty(a)&&(e[a]=t[a])})(e,t)};function P(e,t){function a(){this.constructor=e}q(e,t),e.prototype=null===t?Object.create(t):(a.prototype=t.prototype,new a)}var j=function(){return(j=Object.assign||function(e){for(var t,a=1,i=arguments.length;a<i;a++)for(var r in t=arguments[a])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function V(e,t,a,i){var r,o=arguments.length,n=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,a):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,a,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(n=(o<3?r(n):o>3?r(t,a,n):r(t,a))||n);return o>3&&n&&Object.defineProperty(t,a,n),n}function U(e,t){return function(a,i){t(a,i,e)}}function B(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function z(e){var t="function"==typeof Symbol&&e[Symbol.iterator],a=0;return t?t.call(e):{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}}}function $(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var i,r,o=a.call(e),n=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)n.push(i.value)}catch(s){r={error:s}}finally{try{i&&!i.done&&(a=o["return"])&&a.call(o)}finally{if(r)throw r.error}}return n}function H(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat($(arguments[t]));return e}var Y=function(){function e(e,a,i){this._client=e;var r=JSON.parse(a.get("com.senior.token")),o=r.access_token,n=r.username.split("@")[1];this._subscriptionUrl="/topic/"+n+"/"+o+"/yms/"+i+"/",this._unsubscribe$=new t.Subject}return e.prototype.connect=function(e){var t=this;this._client.connectObservable.pipe(a.takeUntil(this._unsubscribe$)).subscribe(function(a){return e(t._subscriptionUrl,t._client,a)})},e.prototype.dispose=function(){this._unsubscribe$.next(),this._unsubscribe$.complete()},e}(),Q=function(){function e(e){this.messageService=e}return e.prototype.getListQueryParams=function(e){var t=e.page,a=void 0===t?0:t,i=e.size,r=void 0===i?10:i,o=e.sort,n=void 0===o?[]:o,s=e.filterQuery,l=void 0===s?"":s,c=e.displayFields,p=void 0===c?[]:c,u=new d.HttpParams;return u=(u=u.append("size",String(r))).append("offset",String(a)),n&&n.length&&(u=u.append("orderby",n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", "))),l&&(u=u.append("filter",l)),p&&p.length&&(u=u.append("displayfields",p.join())),u},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e}(),K=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.url="yms/integration/",i}return P(t,e),t.prototype.listGateByArea=function(e){var t=this.getListQueryParams({size:1e3,page:0,displayFields:["*"],filterQuery:"area.id eq '"+e+"'"});return this.http.get(this.url+"entities/gate",{params:t})},t.prototype.openGate=function(e){return this.http.post(this.url+"actions/openGate",{ip:e}).pipe(this.defaultCatch())},t.prototype.closeGate=function(e){return this.http.post(this.url+"actions/closeGate",{ip:e}).pipe(this.defaultCatch())},t.prototype.checkAccess=function(e){var t={includeFilters:!1,permissions:e};return this.http.post("platform/authorization/queries/checkAccess",t).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),W=function(){function e(){}return e=V([p.ControleCircuito({header:"Cancelas",name:"yms.integracao.devices"}),p.ControleOperacao({header:"Cancelas",name:"yms.integracao.devices"})],e)}(),J=function(e){function i(a,i){var r=e.call(this)||this;return r.service=a,r.translate=i,r.successState="default",r.permissionOpenGate=!1,r.permissionCloseGate=!1,r.uriGateDefault="res://senior.com.br/yms/devices/gate",r.unsubscribe$=new t.Subject,r.gates$=new t.Subject,r}return P(i,e),i.prototype.ngOnInit=function(){this.checkPermissionsGates()},i.prototype.checkPermissionsGates=function(){var e=this;this.service.listGateByArea(this.sequenciaCircuito.area.id).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(t){var a=t.contents,i=e.buildResourceGateAndAction(a);i.length<=0||e.checkAcessPermissionGate(i,a)})},i.prototype.buildResourceGateAndAction=function(e){var t=[];return t.push({resource:this.uriGateDefault,action:"Close"}),t.push({resource:this.uriGateDefault,action:"Open"}),e.filter(function(e){e.resourceUri!==undefined&&(t.push({resource:e.resourceUri,action:"Close"}),t.push({resource:e.resourceUri,action:"Open"}))}),t},i.prototype.checkAcessPermissionGate=function(e,t){var i=this;this.service.checkAccess(e).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return i.loading=undefined})).subscribe(function(e){var a=e.permissions;i.gates$.next(i.buildGateWithActionsAndPermissions(a,t))})},i.prototype.buildGateWithActionsAndPermissions=function(e,t){var a=this,i=[];return t.filter(function(t){if(t.isActionButton=!1,t.actions=[],a.permissionCloseGate&&a.permissionOpenGate)return t.isActionButton=!0,void i.push(t);e.filter(function(e){t.isActionButton=!!t.isActionButton||a.checkDefaultGatePermission(e,t),t.resourceUri===e.resource&&(t.actions.push({action:e.action,authorized:e.authorized}),t.isActionButton=!!t.isActionButton||e.authorized)}),i.push(t)}),i},i.prototype.checkDefaultGatePermission=function(e,t){if(this.uriGateDefault===e.resource){if("Open"===e.action)return this.permissionOpenGate=e.authorized,e.authorized;if("Close"===e.action)return this.permissionCloseGate=e.authorized,e.authorized}return!1},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},i.prototype.model=function(e){var t=this,a=!1,i=!1;return this.permissionCloseGate&&this.permissionOpenGate||e.actions.filter(function(e){"Open"===e.action&&(a=e.authorized),"Close"===e.action&&(i=e.authorized)}),!0===this.permissionOpenGate&&(a=this.permissionOpenGate),!0===this.permissionCloseGate&&(i=this.permissionCloseGate),[{label:this.translate.instant("yms.integration.open_gate"),visible:a,command:function(){return t.openGate(e)}},{label:this.translate.instant("yms.integration.close_gate"),visible:i,command:function(){return t.closeGate(e)}}]},i.prototype.openGate=function(e){var t=this;this.loading=e.id,this.service.openGate(e.ip).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return t.loading=undefined})).subscribe(function(a){return t.successState=e.id})},i.prototype.closeGate=function(e){var t=this;this.loading=e.id,this.service.closeGate(e.ip).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return t.loading=undefined})).subscribe(function(a){return t.successState=e.id})},V([r.Input(),B("design:type",Object)],i.prototype,"sequenciaCircuito",void 0),i=V([r.Component({selector:"controlador-cancela-component",template:'<div>\n <p-table [value]="gates$ | async">\n <ng-template pTemplate="header">\n <tr>\n <th>{{\'yms.integration.gate_ip\' | translate}}</th>\n <th>{{\'yms.integration.gate_type\' | translate}}</th>\n <th></th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData>\n <tr \n [@success]="successState === rowData.id ? successState : \'default\'" \n (@success.done)="successState = \'default\'"\n >\n <td>{{rowData.ip}}</td>\n <td>{{rowData.type | translate}}</td>\n <td>\n <div *ngIf="rowData.isActionButton">\n <span *sLoadingState="loading === rowData.id" >\n <s-button priority="default" [auxiliary]="true" label="Ações" [model]="model(rowData)" >\n </s-button>\n </span>\n </div>\n </td>\n </tr>\n </ng-template>\n </p-table>\n</div>',animations:[u.trigger("success",[u.state("*",u.style({backgroundColor:"#0C9348",opacity:.5})),u.state("default",u.style({backgroundColor:"#FFF",opacity:1})),u.transition("* => default",u.animate("1.2s ease-in")),u.transition("default => *",u.animate("0s"))])]}),B("design:paramtypes",[K,o.TranslateService])],i)}(W),X=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(J)}return e=V([r.NgModule({imports:[i.CommonModule,l.TableModule,o.TranslateModule,s.MessageModule,n.ButtonModule,n.LoadingStateModule,m.PermissionsModule.forChild([{name:"gate",actions:["Open","Close"],uri:"res://senior.com.br/yms/devices/gate"}])],declarations:[J],entryComponents:[J],exports:[J],providers:[K]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),Z=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.urlIntegration="yms/integration/",i.urlBalanca="yms/balanca/",i}return P(t,e),t.prototype.getWeightScaleByArea=function(e){var t={displayFields:["description","code"],page:0,size:1e3,filterQuery:"area.id eq '"+e+"'"};return this.http.get(this.urlIntegration+"entities/weightScale",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.fallbackCall=function(e,t){return this.http.post(this.urlBalanca+"actions/manualWeight",{code:e,weight:t}).pipe(this.defaultCatch())},t.prototype.getStabilizedWeight=function(e){return this.http.post(this.urlBalanca+"queries/getStabilizedWeight",{code:e}).pipe(this.defaultCatch())},t.prototype.getWeightScaleByCode=function(e){var t={displayFields:["description","code"],page:0,size:10,filterQuery:"code eq '"+e+"'"};return this.http.get(this.urlIntegration+"entities/weightScale",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),ee=function(){function e(){}return e=V([p.ControleCircuito({header:"Balanças",name:"yms.integracao.devices"}),p.ControleOperacao({header:"Balanças",name:"yms.integracao.devices"})],e)}(),te=function(e){function i(a){var i=e.call(this)||this;return i.service=a,i.loading=!1,i.unsubscribe$=new t.Subject,i.weightScales$=new t.BehaviorSubject([]),i.weightScaleValues=new Map,i}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this.sequenciaCircuito&&(this.loading=!0,this.service.getWeightScaleByArea(this.sequenciaCircuito.area.id).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(t){var a=t.contents;e.weightScales$.next(a),a.forEach(function(t){e.weightScaleValues.set(t.id,0),e.service.getStabilizedWeight(t.code).subscribe(function(a){e.weightScaleValues.set(t.id,a.weight)})})}))},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},V([r.Input(),B("design:type",Object)],i.prototype,"sequenciaCircuito",void 0),i=V([r.Component({selector:"visualizar-balanca-component",template:'<div *sLoadingState="loading">\n <p-table [value]="weightScales$ | async">\n <ng-template pTemplate="header">\n <tr>\n <th>Código</th>\n <th>Descrição</th>\n <th>Peso</th>\n </tr>\n </ng-template>\n <ng-template let-rowData pTemplate="body">\n <tr>\n <td>{{rowData.code}}</td>\n <td>{{rowData.description}}</td>\n <td>{{weightScaleValues.get(rowData.id)}}</td>\n </tr>\n </ng-template>\n </p-table>\n</div>'}),B("design:paramtypes",[Z])],i)}(ee),ae=function(e){function t(){var t=e.call(this)||this,a=t.getCookieObject("com.senior.token").access_token,i=t.getCookie("com.senior.base.url")+"/websocket/subscription";return t.socketProvider=function(){return new h(i)},t.configureConfig(a),t}return P(t,e),t.prototype.getCookieObject=function(e){var t=this.getCookie(e);return t?JSON.parse(t):t},t.prototype.getCookie=function(e){try{for(var t=e+"=",a=decodeURIComponent(document.cookie).split(";"),i=0;i<a.length;i++){for(var r=a[i];" "==r.charAt(0);)r=r.substring(1);if(0==r.indexOf(t))return r.substring(t.length,r.length)}return null}catch(o){return null}},t.prototype.configureConfig=function(e){this.url=this.socketProvider,this.headers={"content-type":"application/json",Authorization:"Bearer "+e,"Access-Control-Allow-Origin":"*"},this.heartbeat_in=1e4,this.heartbeat_out=1e4,this.reconnect_delay=15e3,this.debug=!1},t}(f.StompConfig),ie=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(te)}return e=V([r.NgModule({imports:[i.CommonModule,l.TableModule,s.MessageModule,n.LoadingStateModule],declarations:[te],entryComponents:[te],exports:[te],providers:[Z,g.CookieService,f.StompService,{provide:f.StompConfig,useClass:ae}]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),re=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.url="yms/integration/",i.patioUrl="yms/patio/",i}return P(t,e),t.prototype.getCamerasByArea=function(e){var t={page:0,size:1e3,filterQuery:"area.id eq '"+e+"'",displayFields:["id","description","ip"]};return this.http.get(this.url+"entities/camera",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.takeSnapshot=function(e){return this.http.get(this.url+"queries/fetchSnapshot",{params:{ip:e.ip}}).pipe(this.defaultCatch())},t.prototype.saveSnapshotInCircuit=function(e){return this.http.post(this.patioUrl+"actions/adicionaImagemExecucaoCircuito",e).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),oe=function(){function e(e,a,i,r){this.dialogRef=e,this.dialogConfig=a,this.service=i,this.messageService=r,this.loading=!1,this.unsubscribe$=new t.Subject}return e.prototype.ngOnInit=function(){this.imageUrl=this.dialogConfig.data.url},e.prototype.save=function(){var e=this;this.loading=!0;var t=this.dialogConfig.data.execucaoCircuito,i=this.dialogConfig.data.cameraIp;this.service.saveSnapshotInCircuit({execucaoCircuitoId:t.id,alvoId:t.sequenciaCircuito.id,cameraIp:i,imagemUrl:this.imageUrl}).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(){e.messageService.add({severity:"success",summary:"Salvo com sucesso!",detail:"Imagem salva com sucesso"}),e.dialogRef.close()})},e.prototype.close=function(e){this.dialogRef.close(e)},e=V([r.Component({selector:"view-image-component",template:'\n <s-loading-state [loading]="loading">\n <img [src]="imageUrl" width="100%">\n <br>\n </s-loading-state>\n\n <div style="position: absolute; bottom: 0; width: 670px; padding-top: 10px; border-top: 1px solid #ccc;" [style.pointer-events]="loading ? \'none\' : \'all\'">\n <s-button priority="primary" label="Salvar" (onClick)="save()"></s-button>\n <s-button priority="link" label="Cancelar" (onClick)="close()"></s-button>\n </div> \n '}),B("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,re,c.MessageService])],e)}(),ne=function(){function e(){}return e=V([p.ControleOperacao({header:"Câmeras",name:"yms.integracao.devices"}),p.ControleCircuito({header:"Câmeras",name:"yms.integracao.devices"})],e)}(),se=function(e){function i(a,i){var r=e.call(this)||this;return r.service=a,r.dialogService=i,r.loadingAll=!1,r.loading=[],r.unsubscribe$=new t.Subject,r.cameras$=new t.Subject,r}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this.loadingAll=!0,this.service.getCamerasByArea(this.sequenciaCircuito.area.id).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loadingAll=!1})).subscribe(function(t){var a=t.contents;return e.cameras$.next(a)})},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},i.prototype.takeSnapshot=function(e){var t=this;this.loading.push(e.id),this.service.takeSnapshot(e).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){var a=t.loading.indexOf(e.id);t.loading.splice(a,1)})).subscribe(function(a){var i=a.url;t.dialogService.open(oe,{header:e.description,width:"700px",height:"600px",contentStyle:{height:"500px",overflow:"hidden"},data:{url:i,cameraIp:e.ip,execucaoCircuito:t.execucaoCircuito}})})},V([r.Input(),B("design:type",Object)],i.prototype,"sequenciaCircuito",void 0),V([r.Input(),B("design:type",Object)],i.prototype,"execucaoCircuito",void 0),i=V([r.Component({selector:"snapshot-component",template:'<div class="lista-cameras" *sLoadingState="loadingAll">\n <div class="camera" *ngFor="let camera of cameras$ | async">\n <span *sLoadingState="loading.includes(camera.id)">\n <div class="info">\n <div class="info-title">\n Descrição\n </div>\n <div class="info-data">\n {{camera.description}}\n </div>\n </div>\n\n <div class="info">\n <div class="info-title">\n IP\n </div>\n <div class="info-data">\n {{camera.ip}}\n </div>\n </div>\n\n <s-button priority="default" [auxiliary]="true" iconClass="fa fa-camera" (onClick)="takeSnapshot(camera)">\n </s-button>\n </span>\n </div>\n</div>',providers:[c.DialogService],styles:[".lista-cameras{display:flex;flex-direction:column}.lista-cameras .camera{width:100%;height:60px;border-bottom:1px solid #ccc;padding-left:20px}.lista-cameras .camera .info{width:40%;margin-top:5px;display:inline-block}.lista-cameras .camera .info .info-title{display:block;font-size:12px}.lista-cameras .camera .info .info-data{display:inline-block;font-size:16px;font-weight:800}"]}),B("design:paramtypes",[re,c.DialogService])],i)}(ne),le=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(se)}return e=V([r.NgModule({imports:[i.CommonModule,n.ButtonModule,n.LoadingStateModule,v.DynamicDialogModule],declarations:[se,oe],entryComponents:[se,oe],exports:[se],providers:[re]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),de=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.url="yms/integration/",i}return P(t,e),t.prototype.getLprByArea=function(e){var t={page:0,size:1e3,filterQuery:"area.id eq '"+e+"'",displayFields:["id","stream","description","area.*"]};return this.http.get(this.url+"entities/lprConfiguration",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.fallbackCall=function(e,t){return this.http.post(this.url+"actions/lprEventPublish",{stream:e,licencePlate:t}).pipe(this.defaultCatch())},t.prototype.getLprByCode=function(e){var t={page:0,size:10,filterQuery:"stream eq '"+e+"'",displayFields:["id","stream","description","locked"]};return this.http.get(this.url+"entities/lprConfiguration",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),ce=function(){function e(){}return e=V([r.NgModule({providers:[de]})],e)}(),pe=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.url="yms/integration/",i}return P(t,e),t.prototype.listLogByCircuit=function(e,t){return t.filterQuery="execucaoCircuitoId eq '"+e+"'",this.http.get(this.url+"entities/logCircuit",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),ue=function(){function e(){}return e=V([p.CircuitoFinalizado({header:"Logs com dispositivos",name:"yms.integracao.devices"})],e)}(),me=function(e){function i(a,i){var r=e.call(this)||this;return r.logsService=a,r.translate=i,r.unsubscribe$=new t.Subject,r}return P(i,e),i.prototype.ngOnInit=function(){this.columns=[{field:"username",header:this.translate.instant("yms.integration.usuario")},{field:"log",header:this.translate.instant("yms.integration.log")},{field:"createdDate",header:this.translate.instant("yms.integration.created_date")}]},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},i.prototype.onGridChange=function(e){var t=e.rows,a=e.first/t;this.updateGrid({size:t,page:a,sort:[{field:"createdDate",order:-1}]})},i.prototype.updateGrid=function(e){var t=this;this.loading=!0;var i=e.page,r=e.size,o=e.sort;this.logsService.listLogByCircuit(this.execucaoCircuito.id,{page:i,size:r,sort:o}).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(e){var a=e.contents,i=e.totalElements;t.logsData=a,t.totalRecords=i})},V([r.Input(),B("design:type",Object)],i.prototype,"execucaoCircuito",void 0),i=V([r.Component({template:'<p-table [columns]="columns" [value]="logsData" [paginator]="true" [lazy]="true" [totalRecords]="totalRecords"\nrows="10" [rowsPerPageOptions]="[10, 20, 50, 100]" (onLazyLoad)="onGridChange($event)">\n <ng-template pTemplate="header" let-columns>\n <tr>\n <th *ngFor="let column of columns">{{ column.header }}</th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData>\n <tr>\n <td>{{rowData.username}}</td>\n <td [pTooltip]="rowData.log">{{rowData.log}}</td>\n <td>{{rowData.createdDate | date: \'dd/MM/yyyy hh:mm:ss\'}}</td>\n </tr>\n </ng-template>\n</p-table>\n'}),B("design:paramtypes",[pe,o.TranslateService])],i)}(ue),fe=function(){function e(e){e.dispatch(me)}return e=V([r.NgModule({declarations:[me],entryComponents:[me],providers:[pe],imports:[i.CommonModule,l.TableModule,o.TranslateModule,y.TooltipModule,n.LoadingStateModule]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),he=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i}return P(t,e),t.prototype.agendas=function(e){return this.http.get("yms/patio/entities/agenda",{params:this.getListQueryParams(e)}).pipe(this.defaultCatch())},t.prototype.ultimaPlacaLida=function(e){return this.http.post("yms/integration/queries/getLastValidPlateByLpr",{stream:e}).pipe(this.defaultCatch())},t.prototype.getPortarias=function(e){return this.http.get("yms/integration/entities/lobby",{params:this.getListQueryParams({page:0,size:100,filterQuery:"planta.id eq '"+e+"'",displayFields:["description","entranceLpr.*","lprs.*","planta.*"]})}).pipe(this.defaultCatch())},t.prototype.executarEntrada=function(e,t){return this.http.post("yms/integration/actions/executeLobby",{lobbyId:e,plate:t}).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),ge=function(){function e(){}return e=V([p.ControleUnificado({header:"Periféricos",name:"yms.integracao.devices"})],e)}(),ve=function(e){function i(a,i){var r=e.call(this)||this;return r.selectPlantService=a,r.portariaService=i,r.unsubscribe$=new t.Subject,r}return P(i,e),i.prototype.ngOnInit=function(){var e=this,t=this.selectPlantService.getPlant();this.portariaService.getPortarias(t.id).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(t){var a=t.contents;return e.portarias=a})},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},i=V([r.Component({selector:"portarias",template:'\n <h3>Portarias</h3>\n <div class="separator"></div>\n <div class="ui-g">\n <portaria-entrada *ngFor="let portaria of portarias" class="ui-md-4" [portaria]="portaria"></portaria-entrada>\n </div>\n '}),B("design:paramtypes",[b.SelectPlantService,he])],i)}(ge),ye=function(){function e(e,a,i,r){this.dialogRef=e,this.dialogConfig=a,this.portariaService=i,this.router=r,this.unsubscribe$=new t.Subject}return e.prototype.ngOnInit=function(){var e=this;this.veiculo=this.dialogConfig.data.veiculo,this.portaria=this.dialogConfig.data.portaria,this.loading=!0,this.portariaService.agendas({size:100,page:0,displayFields:["veiculo.primario.*","tipoAgendamento.*","descricao","externalTenant","dataEsperadaAgendamento"],filterQuery:"veiculo.primario.placa eq '"+this.veiculo+"' and status eq 'AGENDADO' and planta eq '"+this.portaria.planta.id+"'"}).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(t){var a=t.contents;e.agendas=a,e.agendas.length?1===e.agendas.length&&(e.selected=e.agendas[0]):e.chegadaSimplificada()})},e.prototype.chegadaSimplificada=function(){this.router.navigate(["execucao-circuito/new"],{queryParams:{veiculo:this.veiculo,navigateTo:"processo-entrada"}}),this.dialogRef.close()},e.prototype.chegada=function(){this.selected&&(this.router.navigate(["execucao-circuito/"+this.selected.id]),this.dialogRef.close())},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.getColumns=function(){return[{field:"descricao",label:"Descrição"},{field:"dataEsperadaAgendamento",label:"Data"},{field:"tipoAgendamento",label:"Tipo de Agendamento"},{field:"externalTenant",label:"Parceiro"}]},e=V([r.Component({template:'\n <div style="width: 100%; height: calc(100% - 50px); overflow: auto;">\n <div *sLoadingState="loading">\n <p-table [value]="agendas" [columns]="getColumns()" selectionMode="single" [(selection)]="selected" dataKey="id">\n <ng-template pTemplate="header" let-columns>\n <tr>\n <th style="width: 50px;"></th>\n <th *ngFor="let column of columns">{{column.label}}</th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData>\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px;">\n <p-tableRadioButton [value]="rowData"></p-tableRadioButton>\n </td>\n <td>{{rowData[\'descricao\']}}</td>\n <td>{{rowData[\'dataEsperadaAgendamento\'] | date: \'dd/MM/yyyy HH:mm\'}}</td>\n <td>{{rowData[\'tipoAgendamento\']?.descricao}}</td>\n <td>{{rowData[\'externalTenant\']?.descricao}}</td>\n </tr>\n </ng-template>\n </p-table>\n </div>\n </div>\n <div style="position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: flex-end; height: 40px; align-items: center;">\n <s-button priority="primary" label="Registrar chegada" [disabled]="!selected" (onClick)="chegada()"></s-button>\n <s-button priority="primary" label="Registrar chegada simplificada" (onClick)="chegadaSimplificada()"></s-button>\n </div>\n '}),B("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,he,F.Router])],e)}(),be=function(){function e(e){this.dialogRef=e}return e.prototype["continue"]=function(){this.dialogRef.close({placa:this.placa})},e=V([r.Component({template:'\n <p>Não foi encontrada uma leitura de placa. Deseja informar a placa para realizar a entrada?</p>\n <div class="separator"></div>\n <input pInputText type="text" pattern="[A-Z0-9]{6,10}" maxlength="10" placeholder="Digite a placa" [(ngModel)]="placa" #placaInput>\n \n <div style="position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: flex-end; height: 40px; align-items: center;">\n <s-button priority="primary" label="Continuar" [disabled]="!placa || !placaInput.validity.valid" (onClick)="continue()"></s-button>\n </div>\n '}),B("design:paramtypes",[c.DynamicDialogRef])],e)}(),Fe=function(){function e(e,a,i,r){this.dialogService=e,this.portariaService=a,this.loading=!1,this.unsubscribe$=new t.Subject,this.websocket=new Y(i,r,"integration")}return e.prototype.ngOnInit=function(){var e=this;this.websocket.connect(function(t,i){i.subscribe(t+"wsLprLockUnlocked").pipe(a.map(function(e){return e.body}),a.map(function(e){return JSON.parse(e).data}),a.takeUntil(e.unsubscribe$)).subscribe(function(t){return e.portaria.lprs=e.portaria.lprs.map(function(e){return e.stream===t.stream?j({},e,{locked:t.locked}):e})})})},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.readPlaque=function(){var e=this;this.loading=!0,this.portariaService.ultimaPlacaLida(this.portaria.entranceLpr.stream).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(t){var a=t.plate;if(!a)return e.placaNaoEncontrada();e.openAgendas(a)})},e.prototype.placaNaoEncontrada=function(){var e=this;this.dialogService.open(be,{header:"Placa não encontrada",style:{display:"flex","flex-direction":"column"},height:"80%",styleClass:"ui-g-12 ui-md-8",contentStyle:{"overflow-y":"auto",height:"100%","max-height":"100%",flex:1}}).onClose.pipe(a.filter(function(e){return!!e})).subscribe(function(t){return e.openAgendas(t.placa)})},e.prototype.openAgendas=function(e){var t=this;this.portariaService.executarEntrada(this.portaria.id,e).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(){t.dialogService.open(ye,{header:"Agendamentos | "+e.toUpperCase(),style:{display:"flex","flex-direction":"column"},height:"80%",styleClass:"ui-g-12 ui-md-8",contentStyle:{"overflow-y":"auto",height:"100%","max-height":"100%",flex:1},data:{veiculo:e,portaria:t.portaria}})})},V([r.Input(),B("design:type",Object)],e.prototype,"portaria",void 0),e=V([r.Component({selector:"portaria-entrada",template:'\n <div class="card-entrada" *sLoadingState="loading">\n <div class="portaria-card">\n <h4>{{portaria?.description}}</h4>\n <s-button style="float: right" [auxiliary]="true" iconClass="fas fa-camera" priority="default" (onClick)="readPlaque()"></s-button>\n </div>\n <div class="portaria-card" *ngFor="let lpr of portaria.lprs">\n <h4>{{lpr.description || lpr.stream}}</h4>\n <p-inputSwitch styleClass="lprInputSwitch" [ngModel]="lpr.locked" [readonly]="true"></p-inputSwitch>\n </div>\n </div>\n ',providers:[c.DialogService],styles:[":host{display:block;padding:10px}.card-entrada{border-radius:20px;border:1px solid #ccc;padding:10px}.card-entrada .portaria-card{min-height:40px;display:flex;justify-content:space-between;align-items:center}"]}),B("design:paramtypes",[c.DialogService,he,f.StompService,g.CookieService])],e)}(),Se=function(){function e(e){e.dispatch(ve)}return e=V([r.NgModule({imports:[i.CommonModule,C.FormsModule,F.RouterModule,n.ButtonModule,l.TableModule,n.LoadingStateModule,S.InputSwitchModule,D.InputTextModule,v.DynamicDialogModule,d.HttpClientModule,b.SelectPlantModule,s.MessageModule],declarations:[ve,Fe,ye,be],entryComponents:[ve,ye,be],providers:[he,g.CookieService,f.StompService,{provide:f.StompConfig,useClass:ae}]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),De=[n.FieldType.Integer,n.FieldType.Double],Ce=/^\d+\b$/,_e=function(e,t){return e.concat(t.filter(function(t){return!e.includes(t)}))},Ie=function(e,t){var a=Te(e,t),i=a.isValidValue;return!(a.typeExists&&!i)},Te=function(e,t){switch(e){case n.FieldType.Time:case n.FieldType.Date:case n.FieldType.DateTime:return{isValidValue:!1,typeExists:!0};case n.FieldType.Integer:case n.FieldType.Double:default:return{isValidValue:t.match(Ce),typeExists:De.includes(e)}}},ke=function(e,t){return 0===Object.keys(e.controls).filter(function(a){var i=e.get(a).errors?e.get(a).errors.required:e.get(a).errors;return t[a]&&!t[a].visualizar&&i}).length},Me=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},Re={style:{display:"flex","flex-direction":"column"},height:"80%",styleClass:"ui-g-12 ui-md-4",contentStyle:{"overflow-y":"auto",height:"auto","max-height":"none","margin-bottom":"0",flex:1}},Ee=_;function Ne(e,t,a,i){void 0===e&&(e={}),void 0===t&&(t=[]);return t.map(function(t){return t.indexOf(".")>0?Me(e,t):e[t]}).join(a).split("-").reduce(function(e,t){return void 0===e&&(e=" "),void 0===t&&(t=" "),e.trim()&&t.trim()?e+" - "+t:e.trim()&&!t.trim()?""+e:!e.trim()&&t.trim()?""+t:void 0})||(i?"yms.erp.sem_descricao":" - ")}var Ae,we,Ge,Oe=function(e,t,i,r,o,s,l){void 0===l&&(l="");var d=t.map(function(e){return{field:e,order:1}}),c=e.filter(function(e){var t=e.type;return Ie(t,s)}).map(function(e){var t=e.name,a=e.type;return"number"==typeof s||a===n.FieldType.Integer?t+" eq "+s:a==n.FieldType.Date?t+" eq '"+Ee(s).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Ee(s).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Ee(s).format()+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+s.replace(/'/g,"\\'")+"'))":t+" eq '"+s+"'"}).join(" or ");l&&l.trim()&&(c=c?"("+c+") and "+l:l);var p=_e(t,i);return o.list({sort:d,filterQuery:c,displayFields:p}).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:Ne(e,t,r)})})})}))},xe=function(e,t,i,r,o,s,l){void 0===l&&(l="");var d=s.first,c=s.rows,p=s.multiSortMeta,u=s.filterData,m=d/c,f=p,h=e.filter(function(e){var t=e.name;return u[t]!=undefined&&""!=u[t]}).map(function(e){var t=e.name,a=e.type,i=u[t];return"number"==typeof i||a===n.FieldType.Integer?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Ee(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Ee(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Ee(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.Lookup?t+" eq '"+i.id+"'":a==n.FieldType.String&&-1!==t.indexOf(".")?"containing("+t+", '"+i.replace(/'/g,"\\'")+"')":a==n.FieldType.String&&-1===t.indexOf(".")?"containing(lower("+t+"),lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and ");h=l&&l.trim()?h.concat(h?" and ":"").concat(l):h;var g=_e(t,i);return o.list({page:m,sort:f,filterQuery:h,displayFields:g}).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:Ne(e,t,r)})})})}))},Le=_,qe=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Le(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Le(a.lastModifiedDate).toDate();return a.label=Ne(a,["descricao"]," - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Le(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Le(a.lastModifiedDate).format(),delete a.label,a},e}(),Pe="Ronda",je=function(){function e(){}return e=V([p.ChegadaVeiculo({header:Pe,name:"yms.integracao.sam",icon:"fal fa-shield"})],e)}(),Ve=function(e){function i(a){var i=e.call(this)||this;return i.integrationCallback=a,i.save=[],i.header=Pe,i.loading=!1,i.unsubscribe$=new t.Subject,i._integrationCallback=a,i}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this._integrationCallback.onAgendamentoSaved().pipe(a.takeUntil(this.unsubscribe$),a.mergeMap(function(a){e.save;return e.agenda=a,t.empty()})).subscribe()},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},V([r.Output(),B("design:type",qe)],i.prototype,"agenda",void 0),V([r.Input(),B("design:type",Array)],i.prototype,"save",void 0),i=V([r.Component({template:'\n <div *ngIf="agenda">\n <scheduling [agenda]="agenda"></scheduling>\n </div>\n '}),B("design:paramtypes",[p.IntegrationEventsCallback])],i)}(je),Ue=function(){function e(){}return e.prototype.focusFirstInvalidInput=function(){var e=Array.from(document.getElementsByClassName("ng-invalid")).find(function(e){return"FORM"!==e.nodeName});if(e)if("P-CALENDAR"===e.nodeName){var t=e.getAttribute("ng-reflect-input-id"),a=document.getElementById(t);a&&a.focus()}else if("S-LOOKUP"===e.nodeName){var i=this.getNestedInput(e.firstElementChild);i&&i.focus()}else e.focus()},e.prototype.getNestedInput=function(e){return"INPUT"===e.nodeName?e:this.getNestedInput(e.firstElementChild)},e=V([r.Injectable()],e)}(),Be=function(){function e(e,t){this.http=e,this.messageService=t,this.http=e,this.messageService=t,this.defaultCatch=this.defaultCatch.bind(this)}return e.prototype.commitFiles=function(e){return this.http.post("platform/field_customization/actions/commitObject",{objects:e}).pipe(this.defaultCatch())},e.prototype.deleteFiles=function(e){return this.http.post("platform/field_customization/actions/deleteObjects",e).pipe(this.defaultCatch())},e.prototype.getFiles=function(e){var t=this,a=[];e.value.custom&&(a=e.value.custom.fieldCustomization||[],delete e.value.custom.fieldCustomization);var i=[],r={};return a.forEach(function(e){var a=e.domain,o=e.service,n=e.entity,s=e.toDelete,l=e.toInsert;if(!t.isEmpty(l)){var d=Object.keys(l).map(function(e){return{version:l[e].version,fileName:l[e].name,objectId:l[e].objectId}});t.isEmpty(d)||i.push.apply(i,H(d))}if(!t.isEmpty(s)){var c=[];Object.keys(s).forEach(function(e){var t=(s[e]||[]).map(function(t){return{field:e,objectId:t}});c.push.apply(c,H(t))}),r={domain:a,service:o,entityName:n,objects:c}}}),{filesToCommit:i,filesToDelete:r}},e.prototype.isEmpty=function(e){return Array.isArray(e)?0===e.length:0===Object.entries(e).length&&e.constructor===Object},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,I.MessageService])],e)}(),ze=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.domainService="yms_int/sam",i}return P(t,e),t.prototype.getVisited=function(e){return this.http.post("yms_int/sam/queries/getVisited",{id:e})},t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(I.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,I.MessageService])],t)}(Q),$e=function(){return function(){}}(),He=function(){return function(){}}(),Ye=function(e){function i(a){var i=e.call(this)||this;return i.service=a,i.visited=new $e,i.ngUnsubscribe=new t.Subject,i.visitedService=a,i}return P(i,e),i.prototype.ngOnInit=function(){},i.prototype.ngAfterContentInit=function(){var e=this;this.agenda||console.error("agenda not found"),this.visitedService.getVisited(this.agenda.id).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){t&&(e.visited.name=t.name,e.visited.contactPhone=t.contactPhone)})},V([r.Input(),B("design:type",Object)],i.prototype,"agenda",void 0),i=V([r.Component({selector:"visited-info",template:'\n <div> \n <div class="info">\n <div class="info-title">\n Visitado:\n </div>\n <div class="info-data">\n {{ visited.name }} {{ visited.contactPhone }}\n </div>\n </div>\n </div>\n',styles:[".info{width:40%;margin-top:5px;display:inline-block}.info .info-title{display:block;font-size:12px}.info .info-data{display:inline-block;font-size:16px;font-weight:800}"]}),B("design:paramtypes",[ze])],i)}(He),Qe=function(){return function(){this.credentialCards=[]}}();!function(e){e.BARCODE_CARD="BARCODE_CARD",e.RFID_CARD="RFID_CARD",e.SMART_CARD="SMART_CARD"}(Ae||(Ae={})),function(e){e.CHECK_IN_PENDING="CHECK_IN_PENDING",e.CHECK_IN_REALIZED="CHECK_IN_REALIZED",e.VISITING="VISITING",e.CHECK_OUT_REALIZED="CHECK_OUT_REALIZED",e.CHECK_IN_NOT_REALIZED="CHECK_IN_NOT_REALIZED",e.CHECK_IN_EXPIRED="CHECK_IN_EXPIRED"}(we||(we={})),function(e){e.BARCODE_CARD="BARCODE_CARD",e.RFID_CARD="RFID_CARD",e.SMART_CARD="SMART_CARD"}(Ge||(Ge={}));var Ke,We=_,Je=function(){function e(e,a,i,r,o){this.fb=e,this.dialogRef=a,this.translate=i,this.route=r,this.dialogConfig=o,this.unsubscribe$=new t.Subject,this.technologies=[],this.localeConfig={}}return e.prototype.ngOnInit=function(){var e=this;this.formGroup=this.fb.group({tecnologiaCracha:[undefined,C.Validators.compose([C.Validators.required])],numero:[undefined,C.Validators.compose([C.Validators.required])],validadeCredencial:[undefined,C.Validators.compose([C.Validators.required])],hora:[undefined,C.Validators.compose([C.Validators.required])]}),this.route.data.pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(t){e.localeConfig=t.localeConfig}),this.tecnologiaCracha(Ge.BARCODE_CARD,Ge.RFID_CARD,Ge.SMART_CARD),this.formataDataEHoraDaCredencial()},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.gerar=function(){if(!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);var e=this.getDataHora(),t=this.dialogConfig.data.visitante,a=this.gerarCredencial(t,e);this.close(a)},e.prototype.tecnologiaCracha=function(){for(var e,t,a=[],i=0;i<arguments.length;i++)a[i]=arguments[i];this.technologies=[];try{for(var r=z(a),o=r.next();!o.done;o=r.next()){var n=o.value;this.technologies.push({label:this.getTecnologiaCrachaTraduzida(n),value:n})}}catch(s){e={error:s}}finally{try{o&&!o.done&&(t=r["return"])&&t.call(r)}finally{if(e)throw e.error}}},e.prototype.getTecnologiaCrachaTraduzida=function(e){return e===Ge.BARCODE_CARD?this.translate.instant("yms.patio.cartao_credencial_codigo_barras"):e===Ge.RFID_CARD?this.translate.instant("yms.patio.cartao_credencial_rfid"):e===Ge.SMART_CARD?this.translate.instant("yms.patio.cartao_credencial_smart"):void 0},e.prototype.formataDataEHoraDaCredencial=function(){var e=We().add(1,"hour");this.formGroup.get("validadeCredencial").disable(),this.definiValor("validadeCredencial",e.format("DD/MM/YYYY")),this.definiValor("hora",e.format("HH:mm"))},e.prototype.getDataHora=function(){var e=new Date,t=this.formGroup.get("hora").value,a=We().date(t).add(1,"hour").hours(),i=We().date(t).minutes();return e.setHours(a),e.setMinutes(i),e},e.prototype.gerarCredencial=function(e,t){return{visitor:e,cardTechnology:this.formGroup.get("tecnologiaCracha").value,cardNumber:this.formGroup.get("numero").value,endDate:t}},e.prototype.definiValor=function(e,t){return this.formGroup.get(e).setValue(t)},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);if(i instanceof C.FormControl)i.markAsDirty({onlySelf:!0});else{if(!(i instanceof C.FormGroup))throw"Instance fot found";t.validateAllFormFields(i)}}),e.markAsDirty({onlySelf:!0})},e=V([r.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 required">\n <label for="tecnologiaCracha">{{\n "yms.patio.motorista_tecnologiaCracha" | translate\n }}</label>\n <p-dropdown\n inputId="tecnologiaCracha"\n name="tecnologiaCracha"\n [options]="this.technologies"\n formControlName="tecnologiaCracha"\n [autoWidth]="false"\n placeholder="{{\n \'yms.patio.visitante_credencial_tecnologia_cracha_place_holder\' | translate\n }}"\n ></p-dropdown>\n <s-control-errors\n [control]="formGroup.controls[\'tecnologiaCracha\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n <div class="ui-g-12 required">\n <label for="numero">{{ "yms.patio.visitante_credencial_numero" | translate }}</label>\n <input\n id="numero"\n type="text"\n name="numero"\n pInputText\n formControlName="numero"\n autocomplete="off"\n />\n <s-control-errors\n [control]="formGroup.controls[\'numero\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="validadeCredencial">{{\n "yms.patio.visitante_validade_credencial" | translate\n }}</label>\n <input\n id="validadeCredencial"\n type="text"\n name="validadeCredencial"\n pInputText\n formControlName="validadeCredencial"\n autocomplete="off"\n />\n <s-control-errors\n [control]="formGroup.controls[\'numero\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="hora">{{ "yms.patio.visitante_credecnial_hora" | translate }}</label>\n <p-calendar\n id="hora"\n name="hora"\n formControlName="hora"\n [locale]="localeConfig.calendar"\n inputId="hora"\n [showTime]="true"\n [hourFormat]="localeConfig.calendar.hourFormat"\n [timeOnly]="true"\n >\n </p-calendar>\n <s-control-errors\n [control]="formGroup.controls[\'numero\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n </div>\n\n <s-button\n [label]="\'yms.patio.visitante_button_cancelar\' | translate"\n (onClick)="close()"\n priority="link"\n ></s-button>\n <s-button\n [label]="\'yms.patio.visitante_button_gerar\' | translate"\n (onClick)="gerar()"\n ></s-button>\n</form>\n',providers:[c.ConfirmationService]}),B("design:paramtypes",[C.FormBuilder,c.DynamicDialogRef,o.TranslateService,F.ActivatedRoute,c.DynamicDialogConfig])],e)}(),Xe=function(){function e(e,a,i){this.dialogRef=a,this.dialogConfig=i,this.unsubscribe$=new t.Subject,this.ngUnsubscribe=new t.Subject,this.notSavedData=new r.EventEmitter,this.actualChanged=!1,this.isFormModified=!1,this.formGroup=e.group({name:[undefined,C.Validators.compose([C.Validators.required])],document:[undefined,C.Validators.compose([C.Validators.required])],contact:[undefined,C.Validators.compose([C.Validators.required])]})}return e.prototype.ngOnInit=function(){var e=this,i=this.dialogConfig.data;i!==undefined&&(this.id=i.id,this.formGroup.get("name").setValue(i.name),this.formGroup.get("document").setValue(i.document),this.formGroup.get("contact").setValue(i.contact),i.document!==undefined&&this.formGroup.get("document").disable()),this.notSavedData.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.actualChanged=t}),(new t.ReplaySubject).subscribe(function(t){return e.isFormModified=!t})},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.save=function(){if(!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);var e=this.formGroup.getRawValue();e.id=this.id,this.close(e)},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);if(i instanceof C.FormControl)i.markAsDirty({onlySelf:!0});else{if(!(i instanceof C.FormGroup))throw"Instance fot found";t.validateAllFormFields(i)}}),e.markAsDirty({onlySelf:!0})},V([r.Output(),B("design:type",r.EventEmitter)],e.prototype,"notSavedData",void 0),e=V([r.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 required">\n <label for="name">{{ "yms.visitante_nome" | translate }}</label>\n <input\n id="name"\n type="text"\n name="name"\n pInputText\n formControlName="name"\n dialog\n autocomplete="off"\n />\n <s-control-errors\n [control]="formGroup.controls[\'name\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n <div class="ui-g-12 required">\n <label for="document">{{ "yms.visitante_documento" | translate }}</label>\n <input\n id="document"\n type="text"\n name="document"\n pInputText\n formControlName="document"\n autocomplete="off"\n />\n <s-control-errors\n [control]="formGroup.controls[\'document\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n <div class="ui-g-12 required">\n <label for="contact">{{ "yms.visitante_contato" | translate }}</label>\n <input\n id="contact"\n type="text"\n name="contact"\n pInputText\n formControlName="contact"\n autocomplete="off"\n />\n <s-control-errors\n [control]="formGroup.controls[\'contact\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n </div>\n\n <s-button\n [label]="\'yms.patio.visitante_button_cancelar\' | translate"\n (onClick)="close()"\n priority="link"\n ></s-button>\n <s-button\n [label]="\'yms.patio.visitante_button_salvar\' | translate"\n (onClick)="save()"\n ></s-button>\n</form>\n',providers:[c.ConfirmationService]}),B("design:paramtypes",[C.FormBuilder,c.DynamicDialogRef,c.DynamicDialogConfig])],e)}(),Ze=function(){function e(e,a,i){this.translate=e,this.dialogService=a,this.integrationCallback=i,this.visitors=[],this.visitorsChange=new r.EventEmitter,this.hasChange=new r.EventEmitter,this.ngUnsubscribe=new t.Subject,this.unsubscribe$=new t.Subject,this._integrationCallback=i}return e.prototype.ngOnInit=function(){this.constroiCamposTabelaVistante(),this.visitanteTotalRecords=0},e.prototype.ngAfterContentInit=function(){var e=this;this.visitanteGridLoading=!1,this.adicionaVisitantesGrid(),this._integrationCallback.onAgendamentoMotoristaChanged().pipe(a.takeUntil(this.unsubscribe$),a.mergeMap(function(a){return e.atualizaMotorista(a),t.empty()})).subscribe()},e.prototype.atualizaMotorista=function(e){var t=this.visitanteGridData.find(function(e){return e.driver});t&&t.documentType===this.getDocumentType()&&t.document===e.cpf||(this.visitanteGridData.length>0?this.visitanteGridData[0]={name:e.nome,document:e.cpf,contact:this.getContatoMotorista(e),visitorSituation:we.CHECK_IN_PENDING,documentType:this.getDocumentType(),driver:!0}:this.visitanteGridData.push({name:e.nome,document:e.cpf,contact:this.getContatoMotorista(e),visitorSituation:we.CHECK_IN_PENDING,documentType:this.getDocumentType(),driver:!0}),this.visitors.length>0&&(this.visitors[0].visitor={name:e.nome,document:e.cpf,contact:this.getContatoMotorista(e),visitorSituation:we.CHECK_IN_PENDING,documentType:this.getDocumentType(),driver:!0}))},e.prototype.adicionaVisitantesGrid=function(){var e=this;if(this.visitors.length)this.visitanteGridData=[],this.adicionaMotoristaNoVisitanteGridData(),this.visitors.forEach(function(t){e.motorista.cpf!==t.visitor.document&&e.visitanteGridData.push({id:t.visitor.id,name:t.visitor.name,document:t.visitor.document,contact:t.visitor.contact,visitorSituation:e.getVisitorSituation(t.visitor.visitorSituation),documentType:e.getDocumentType(),driver:!0}),e.visitanteTotalRecords=e.visitors.length});else{this.visitanteGridData=[];var t=new Qe;t.visitor={name:this.motorista.nome,document:this.motorista.cpf,contact:this.getContatoMotorista(this.motorista),documentType:this.getDocumentType(),visitorSituation:we.CHECK_IN_PENDING,driver:!0},this.visitanteGridData.find(function(e){return t.visitor.document===e.document})===undefined&&(this.visitanteGridData.push(t.visitor),this.visitors.push(t),this.visitanteTotalRecords=1)}this.visitanteGridLoading=!1},e.prototype.isCredentialCardsEmpty=function(e){var t=this.visitors.find(function(t){return t.visitor.document===e.document});return t!==undefined&&t.credentialCards.filter(function(e){return 0!==Object.keys(e).length}).length>0},e.prototype.adicionaMotoristaNoVisitanteGridData=function(){var e=this,t=this.visitors.find(function(t){return e.motorista.cpf===t.visitor.document});t===undefined?this.visitanteGridData.push({name:this.motorista.nome,document:this.motorista.cpf,contact:this.getContatoMotorista(this.motorista),visitorSituation:we.CHECK_IN_PENDING,documentType:this.getDocumentType(),driver:!0}):this.visitanteGridData.push({id:t.visitor.id,name:t.visitor.name,document:t.visitor.document,contact:this.getContatoMotorista(this.motorista),visitorSituation:this.getVisitorSituation(t.visitor.visitorSituation),documentType:this.getDocumentType(),driver:!0})},e.prototype.criarOuAtualizarVisitante=function(e){var t=this;this.dialogService.open(Xe,j({header:this.translate.instant("yms.patio.motorista_adicionar_visitante")},Re,this.constroiVisitante(e))).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(e){return t.adicionaVisitanteParaSalvar(e)})},e.prototype.adicionaVisitanteParaSalvar=function(e){var t=this;if(this.visitanteGridData.forEach(function(a){if(a.document===e.document){a.contact=e.contact,a.name=e.name;var i=t.buildVisitorCredentialsDto(a);t.visitors.forEach(function(e){e.visitor.document===i.visitor.document&&(e.visitor.name=i.visitor.name,e.visitor.contact=i.visitor.contact)}),t.visitorsChange.emit(t.visitors),t.visitorFound=!0}}),!this.visitorFound){this.visitanteGridLoading=!0,e.documentType=this.getDocumentType(),e.visitorSituation===undefined&&(e.visitorSituation=we.CHECK_IN_PENDING),this.addVisitanteNaTabela(e),this.visitanteTotalRecords++,this.visitanteGridLoading=!1;var a=new Qe;a.visitor={name:e.name,document:e.document,contact:e.contact,documentType:e.documentType,visitorSituation:e.visitorSituation,driver:!1},this.visitors.push(a),this.visitorsChange.emit(this.visitors),this.hasChange.emit(!0)}},e.prototype.buildVisitorCredentialsDto=function(e){var t=new Qe,a={name:e.name,document:e.document,contact:e.contact,documentType:e.documentType,visitorSituation:e.visitorSituation,driver:!1};return t.visitor=a,t},e.prototype.model=function(e){var t=this,a=e.document===this.motorista.cpf,i=this.visitors.find(function(t){return t.visitor.document===e.document});return[{label:this.translate.instant("yms.patio.motorista_editar_visitante"),command:function(){return t.editarVisitante(e)},visible:!a},{label:this.translate.instant("yms.patio.delete"),command:function(){return t.deletarVisitante(e)},visible:!a},{label:this.translate.instant("yms.patio.motorista_visitante_entregar_credencial"),command:function(){return t.entregarCredencial(e)},visible:a||!a},{label:this.translate.instant("yms.patio.remover_credenciais"),command:function(){return t.deletarCredenciais(i)},visible:null!=i&&null!=i.credentialCards&&i.credentialCards.length>0}]},e.prototype.addVisitanteNaTabela=function(e){e.id!==undefined?this.visitanteGridData=this.visitanteGridData.map(function(t){return t.id===e.id?e:t}):this.visitanteGridData.push(e)},e.prototype.entregarCredencial=function(e){var t=this;this.dialogService.open(Je,{header:this.translate.instant("yms.patio.motorista_visitante_credencial"),data:{visitante:e}}).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(e){return t.adicionaCredencialParaEntregar(e)})},e.prototype.adicionaCredencialParaEntregar=function(e){var t=this.visitors.find(function(t){return t.visitor.document===e.visitor.document});t===undefined?this.visitors.push({visitor:e.visitor,credentialCards:[this.createCredentialCard(e)]}):t.credentialCards.push(this.createCredentialCard(e)),this.hasChange.emit(!0)},e.prototype.editarVisitante=function(e){this.criarOuAtualizarVisitante(e)},e.prototype.deletarVisitante=function(e){var t=this;this.visitanteGridData.forEach(function(a,i){if(a.document===e.document){t.visitanteGridData.splice(i,1);var r=t.visitors.findIndex(function(e){return e.visitor.document===a.document});-1!==r&&(t.visitors.splice(r,1),t.hasChange.emit(!0))}})},e.prototype.deletarCredenciais=function(e){e.credentialCards.splice(0,e.credentialCards.length),this.hasChange.emit(!0)},e.prototype.getContatoMotorista=function(e){return e.telefone===undefined?"0":e.telefone},e.prototype.getCredentialCards=function(e){var t=this;return this.visitors.length<=0?[]:this.visitors.find(function(t){return t.visitor.document===e.document}).credentialCards.filter(function(e){return 0!==Object.keys(e).length}).map(function(e){return{cardTechnology:t.getTecnologiaCrachaTraduzida(e.cardTechnology),cardNumber:e.cardNumber,endDate:e.endDate}})},e.prototype.constroiVisitante=function(e){var t={data:{}};return e!==undefined&&null!==e&&(t={data:{id:e.id,name:e.name,document:e.document,contact:e.contact,visitorSituation:this.getVisitorSituation(e.visitorSituation),documentType:this.getDocumentType()}}),t},e.prototype.createCredentialCard=function(e){return{visitor:e.id,cardTechnology:e.cardTechnology,cardNumber:e.cardNumber,endDate:e.endDate}},e.prototype.getTecnologiaCrachaTraduzida=function(e){return e===Ae.BARCODE_CARD?this.translate.instant("yms.patio.cartao_credencial_codigo_barras"):e===Ae.RFID_CARD?this.translate.instant("yms.patio.cartao_credencial_rfid"):e===Ae.SMART_CARD?this.translate.instant("yms.patio.cartao_credencial_smart"):void 0},e.prototype.getVisitorSituation=function(e){return e===undefined?we.CHECK_IN_PENDING:e},e.prototype.constroiCamposTabelaVistante=function(){this.visitanteGridColumns=[{field:"name",header:this.translate.instant("yms.patio.motorista_visitante_nome")},{field:"document",header:this.translate.instant("yms.patio.motorista_visitante_documento")},{field:"contact",header:this.translate.instant("yms.patio.motorista_visitante_contato")}]},e.prototype.getDocumentType=function(){return"cpf"},V([r.Input(),B("design:type",Object)],e.prototype,"motorista",void 0),V([r.Input(),B("design:type",Array)],e.prototype,"visitors",void 0),V([r.Output(),B("design:type",Object)],e.prototype,"visitorsChange",void 0),V([r.Output(),B("design:type",Object)],e.prototype,"hasChange",void 0),e=V([r.Component({selector:"visitante-component",template:'<div style="margin-bottom: 15px">\n <div>\n <p-header>\n {{ "yms.patio.motorista_titulo_lista_visitante" | translate}}\n <button\n style="margin-left: 50px"\n type="button"\n pButton\n (click)="criarOuAtualizarVisitante(null)"\n label="{{ \'yms.patio.motorista_add_visitante\' | translate }}"\n >\n </button>\n </p-header>\n <div class="ui-g">\n <div class="ui-g-12">\n <p-table\n #visitanteTable\n [value]="visitanteGridData"\n [columns]="visitanteGridColumns"\n dataKey="id"\n [lazy]="true"\n [scrollable]="true"\n [resizableColumns]="true"\n sortMode="single"\n [paginator]="true"\n [totalRecords]="visitanteTotalRecords"\n rows="10"\n [rowsPerPageOptions]="[10, 20, 50, 100]"\n [loading]="visitanteGridLoading"\n >\n <ng-template pTemplate="colgroup" let-columns>\n <colgroup>\n <col *ngFor="let col of columns" [style.width]="col.width" />\n </colgroup>\n </ng-template>\n <ng-template pTemplate="header" let-columns>\n <tr>\n <th id="espaco-coluna-plus" style="width: 50px"></th>\n <th\n id=""\n *ngFor="let col of columns"\n [pSortableColumn]="col.field"\n pResizableColumn\n >\n <div class="senior-header">\n <span class="senior-header-title">{{ col.header }}</span>\n <p-sortIcon [field]="col.field"></p-sortIcon>\n </div>\n </th>\n <th id="" style="width: 15%"></th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData let-columns let-expanded="expanded">\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px">\n <a href="#" [pRowToggler]="rowData" style="color: #000">\n <em [ngClass]="expanded ? \'fa fa-minus\' : \'fa fa-plus\'"></em>\n </a>\n </td>\n <td>\n <span>{{ rowData["name"] }}</span>\n </td>\n <td>\n <span>{{ rowData["document"] }}</span>\n </td>\n <td>\n <span>{{ rowData["contact"] }}</span>\n </td>\n <td style="width: 15%">\n <s-button\n priority="default"\n label="{{ \'yms.patio.motorista_acao_visitante\' | translate }}"\n [model]="model(rowData)"\n >\n </s-button>\n </td>\n </tr>\n </ng-template>\n <ng-template pTemplate="rowexpansion" let-rowData let-columns="columns">\n <tr class="bg-white no-hover">\n <td [attr.colspan]="columns.length + 2">\n <div *ngIf="isCredentialCardsEmpty(rowData); else elseBlock">\n <div\n class="container flex-container"\n *ngFor="let credentialCard of getCredentialCards(rowData)"\n >\n <p-card\n header="{{ credentialCard.cardTechnology }}"\n [style]="{ width: \'300px\', margin: \'10px\' }"\n >\n <div>\n Número: <strong>{{ credentialCard.cardNumber }}</strong>\n </div>\n <div>\n Data de validade:\n <strong>{{ credentialCard.endDate | date : "dd/MM/yyyy hh:mm" }}</strong>\n </div>\n </p-card>\n </div>\n </div>\n <ng-template #elseBlock\n >Não há credenciais para salvar ou entregues</ng-template\n >\n </td>\n </tr>\n </ng-template>\n <ng-template pTemplate="paginatorright">\n <span\n [translate]="\'total_records\'"\n [translateParams]="{ value: visitanteTotalRecords }"\n ></span>\n </ng-template>\n </p-table>\n </div>\n </div>\n</div>\n</div>',styles:[".container{display:inline-flex}.flex-container{flex-wrap:wrap}"]}),B("design:paramtypes",[o.TranslateService,c.DialogService,p.IntegrationEventsCallback])],e)}(),et=function(){function e(e,t,a,i){this.http=e,this.messageService=t,this.entityUrl=a,this.actionsUrl=i,this.http=e,this.messageService=t,this.entityUrl=a,this.actionsUrl=i,this.defaultCatch=this.defaultCatch.bind(this)}return e.prototype.getListQueryParams=function(e){var t=e.page,a=void 0===t?0:t,i=e.size,r=void 0===i?10:i,o=e.sort,n=void 0===o?[]:o,s=e.filterQuery,l=void 0===s?"":s,c=e.displayFields,p=void 0===c?[]:c,u=new d.HttpParams;return u=(u=u.append("size",String(r))).append("offset",String(a)),n&&n.length&&(u=u.append("orderby",n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", "))),l&&(u=u.append("filter",l)),p&&p.length&&(u=u.append("displayfields",p.join())),u},e.prototype.getBodyParams=function(e){var t=e.page,a=void 0===t?0:t,i=e.size,r=void 0===i?10:i,o=e.sort,n=void 0===o?[]:o,s=e.filterQuery,l=void 0===s?"":s,d=e.displayFields,c=void 0===d?[]:d,p={};return p.size=r,p.offset=a,n&&n.length&&(p.orderBy=n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", ")),l&&(p.filter=l),c&&c.length&&(p.displayFields=c.join()),p},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e.prototype.getListBodyParams=function(e){var t=this.getBodyParams(e);return e.displayFields&&e.displayFields.length&&(t.displayFields=e.displayFields),t},e.prototype.list=function(e){return this.http.get(this.entityUrl,{params:this.getListQueryParams(e)}).pipe(this.defaultCatch())},e.prototype.get=function(e,t){return void 0===t&&(t=!0),this.http.get(this.entityUrl+"/"+e).pipe(t?this.defaultCatch():a.tap())},e.prototype.insert=function(e){return this.http.post(""+this.entityUrl,e).pipe(this.defaultCatch())},e.prototype.update=function(e,t,i){return void 0===i&&(i=!0),this.http.put(this.entityUrl+"/"+e,t).pipe(i?this.defaultCatch():a.tap())},e.prototype["delete"]=function(e){return this.http["delete"](this.entityUrl+"/"+e).pipe(this.defaultCatch())},e.prototype.listCustomFilter=function(e,t){return this.http.post(this.actionsUrl+"/"+t,this.getBodyParams(e)).pipe(this.defaultCatch())},e}(),tt=function(e){function t(t,a){var i=e.call(this,t,a,"yms_int/sam/entities/scheduling")||this;return i.http=t,i.messageService=a,i.domainService="yms_int/sam",i}return P(t,e),t.prototype.saveScheduling=function(e){return this.http.post(this.domainService+"/actions/saveScheduling",e).pipe(this.defaultCatch())},t.prototype.startScheduling=function(e){return this.http.post(this.domainService+"/actions/startScheduling",{id:e}).pipe(this.defaultCatch())},t.prototype.getSchedulingByYms=function(e){return this.http.post(this.domainService+"/queries/getSchedulingByYms",{id:e}).pipe(this.defaultCatch())},t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(I.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,I.MessageService])],t)}(et),at=function(e,t){return e.concat(t.filter(function(t){return!e.includes(t)}))},it=[n.FieldType.Integer,n.FieldType.Double],rt=_,ot=function(){function e(e,a,i,r,o){void 0===r&&(r=""),this._lookupDisplayFields=[],this._advancedDisplayFields=[],this._params=[],this._url={},this._nameService={},this._useCustomSearch=!1,this._responseNamesData={},this._service=a,this._searchFields=e,this._searchGridFields=i||e,this._lookupSeparator=r,this.unsubscribe$=new t.Subject,this.verificaAtivo=o}return Object.defineProperty(e.prototype,"searchFields",{get:function(){return this._searchFields},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"searchGridFields",{get:function(){return this._searchGridFields},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"searchGridData",{get:function(){return this._searchGridData},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lookupSuggestions",{get:function(){return this._lookupSuggestions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"searchTotalRecords",{get:function(){return this._searchTotalRecords},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lookupDisplayFields",{get:function(){return this._lookupDisplayFields},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"advancedDisplayFields",{get:function(){return this._advancedDisplayFields},enumerable:!0,configurable:!0}),e.prototype.setLookupDisplayFields=function(e){return this._lookupDisplayFields=e,this},e.prototype.setAdvancedDisplayFields=function(e){return this._advancedDisplayFields=e,this},e.prototype.setVariablesCustomSearch=function(e){return void 0===e&&(e={}),this._params=e.params,this._url=e.url,this._nameService=e.nameService,this._customService=e.service,this._responseNamesData=e.responseNamesData,this},e.prototype.lookupRequest=function(e,t){var i=this,r=this._lookupDisplayFields.map(function(e){return{field:e,order:1}}),o=this._searchFields.filter(function(t){return function(e,t){var a=it.includes(e),i=t.match(/^\d+\b$/);return!(a&&!i)}(t.type,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+rt(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+rt(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+rt(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or "),s=at(this._lookupDisplayFields,this._advancedDisplayFields),l=this.geradorFiltro(o,t);this._service.list({sort:r,filterQuery:l,displayFields:s}).pipe(a.takeUntil(this.unsubscribe$)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:i._lookupDisplayFields.map(function(t){return t.indexOf(".")>0?i.getProp(e,t):e[t]}).join(i._lookupSeparator)})})})})).subscribe(function(e){return i._lookupSuggestions=e.contents})},e.prototype.searchRequest=function(e,t){var i=this,r=e.first,o=e.rows,s=e.multiSortMeta,l=e.filterData,d=r/o,c=s,p=this._searchGridFields.filter(function(e){var t=e.name;return l[t]!=undefined&&""!=l[t]}).map(function(e){var t=e.name,a=e.type,i=l[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+rt(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+rt(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+rt(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":a==n.FieldType.Lookup?t+" eq '"+i.id+"'":t+" eq '"+i+"'"}).join(" and "),u=at(this._lookupDisplayFields,this._advancedDisplayFields),m=this.geradorFiltro(p,t);this._service.list({page:d,sort:c,filterQuery:m,displayFields:u}).pipe(a.takeUntil(this.unsubscribe$)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:i._lookupDisplayFields.map(function(t){return t.indexOf(".")>0?i.getProp(e,t):e[t]}).join(i._lookupSeparator)})})})})).subscribe(function(e){i._searchGridData=e.contents,i._searchTotalRecords=e.totalElements})},e.prototype.customLookupRequest=function(e){var t=this;this._params.descricao=e,this._customService[this._nameService](this._params,this._url).pipe(a.takeUntil(this.unsubscribe$)).pipe(a.map(function(e){return j({},e,{contents:e[t._responseNamesData.contents].map(function(e){return j({},e,{label:t._lookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t._lookupSeparator)})})})})).subscribe(function(e){return t._lookupSuggestions=e[t._responseNamesData.contents]})},e.prototype.customSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.sortField,n=e.sortOrder,s=e.filterData,l={plantaId:this._params.plantaId,page:i/r,size:r,sortField:o,sortOrder:n};Object.entries(s).filter(function(e){return!(!e[0]||!e[1])&&(l[e[0]]=e[1])}),this._customService[this._nameService](l,this._url).pipe(a.takeUntil(this.unsubscribe$)).pipe(a.map(function(e){return j({},e,{contents:e[t._responseNamesData.contents].map(function(e){return j({},e,{label:t._lookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t._lookupSeparator)})})})})).subscribe(function(e){t._searchGridData=e[t._responseNamesData.contents],t._searchTotalRecords=e[t._responseNamesData.totalElements]})},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.geradorFiltro=function(e,t){var a=e?"("+e+")":"";return this.verificaAtivo&&(a+=e?"and ativo eq true":"ativo eq true"),a.concat(""+(t?t(e):""))},e}(),nt=function(e){function t(t,a){var i=e.call(this,t,a,"sam/lobby/entities/lobby")||this;return i.http=t,i.messageService=a,i}return P(t,e),t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(I.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,I.MessageService])],t)}(et),st=function(){return function(){}}(),lt=function(){return function(){}}();!function(e){e.PENDING="PENDING",e.IN_PROGRESS="IN_PROGRESS",e.FINISHED="FINISHED",e.NOT_OCCURRED="NOT_OCCURRED"}(Ke||(Ke={}));var dt,ct=function(){function e(e,a,i,o,n,s){this.fb=e,this.route=a,this.translate=i,this.messageService=o,this.lobbyService=n,this.schedulingService=s,this.notSavedData=new r.EventEmitter,this.schedulingVisitors=new st,this.isFormModified=!1,this.loading=!1,this.localeConfig={},this.ngUnsubscribe=new t.Subject}return e.prototype.ngOnInit=function(){var e=this;this.createForm(),this.portariaLookup=new ot(this.getLobbyFields(),this.lobbyService),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){e.localeConfig=t.localeConfig}),this.formGroup.valueChanges.subscribe(function(t){return e.isFormModified=!0})},e.prototype.ngAfterViewInit=function(){this.saveAndInitButton=document.getElementById("init")},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},e.prototype.ngOnChanges=function(){var e=this;this.agenda.id&&(this.loading=!0,this.schedulingService.getSchedulingByYms(this.agenda.id).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return e.loading=!1})).subscribe(function(t){if(t.scheduling){var a=t.scheduling;e.schedulingVisitors.scheduling=a,e.schedulingVisitors.visitors=t.visitors,e.formGroup.controls.motivoVisita.setValue(a.description),e.formGroup.controls.dataSaida.setValue(new Date(a.expectedEndDate)),e.formGroup.controls.horaSaida.setValue(new Date(a.expectedEndDate)),e.getLobby(a).subscribe(function(t){return e.formGroup.controls.portaria.setValue(t)})}else{var i=new Date;i.setHours((new Date).getHours()+1),e.schedulingVisitors.scheduling=new lt,e.schedulingVisitors.visitors=[],e.schedulingVisitors.scheduling.visitSituation=Ke.PENDING,e.schedulingVisitors.scheduling.description=e.agenda.descricao,e.schedulingVisitors.scheduling.expectedStartDate=new Date,e.schedulingVisitors.scheduling.expectedEndDate=i,e.formGroup.controls.motivoVisita.setValue(e.schedulingVisitors.scheduling.description),e.formGroup.controls.dataSaida.setValue(e.schedulingVisitors.scheduling.expectedStartDate),e.formGroup.controls.horaSaida.setValue(e.schedulingVisitors.scheduling.expectedEndDate)}}),this.patchActualValue())},e.prototype.getLobby=function(e){if(e.lobbyIdSAM)return this.lobbyService.get(e.lobbyIdSAM)},e.prototype.patchActualValue=function(){var e=this;setTimeout(function(){e.actualValue=e.formGroup.value,e.formGroup.patchValue(e.actualValue)},500)},e.prototype.canSave=function(){return!!(this.agenda&&this.agenda.id&&this.isFormModified)},e.prototype.onSave=function(e){var i=this;if(this.formGroup.invalid)this.validateAllFormFields(this.formGroup);else{this.isFormModified=!1;var r=this.schedulingVisitors.scheduling;r.idYMS=this.agenda.id,r.description=this.formGroup.controls.motivoVisita.value,r.expectedStartDate=new Date;var o=this.formGroup.controls.dataSaida.value,n=this.formGroup.controls.horaSaida.value;r.expectedEndDate=this.getDate(o,n);var s=this.formGroup.controls.portaria.value;s&&(r.lobbyIdSAM=s.id),this.loading=!0,this.schedulingService.saveScheduling(this.schedulingVisitors).pipe(a.takeUntil(this.ngUnsubscribe),a.mergeMap(function(a){return i.schedulingVisitors=a,e?i.schedulingService.startScheduling(i.schedulingVisitors.scheduling.idYMS):(i.loading=!1,t.NEVER)}),a.finalize(function(){return i.loading=!1})).subscribe(function(e){e&&i.saveAndInitButton&&i.saveAndInitButton.click(),i.loading=!1})}},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup&&t.validateAllFormFields(i)})},e.prototype.getDate=function(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes())},e.prototype.reset=function(){this.formGroup.patchValue(j({},this.actualValue))},e.prototype.createForm=function(){this.formGroup=this.fb.group({motivoVisita:[undefined,C.Validators.compose([C.Validators.required])],portaria:[undefined,C.Validators.compose([C.Validators.required])],dataSaida:[undefined,C.Validators.compose([C.Validators.required])],horaSaida:[undefined,C.Validators.compose([C.Validators.required])]})},e.prototype.getLobbyFields=function(){return[new n.FormField({name:"name",type:n.FieldType.String,label:this.translate.instant("yms.patio.sam_portaria_descricao")})]},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),V([r.Output(),B("design:type",r.EventEmitter)],e.prototype,"notSavedData",void 0),e=V([r.Component({selector:"scheduling",template:'<visited-info [agenda]="agenda"> </visited-info>\r\n<form [formGroup]="formGroup" *sLoadingState="loading" novalidate>\r\n <div class="ui-fluid">\r\n <div class="ui-g">\r\n <div class="ui-g-12 ui-md-6 required">\r\n <label for="motivoVisita">{{ "yms.patio.sam_motivo_visita" | translate }}</label>\r\n <input\r\n type="text"\r\n id="motivoVisita"\r\n name="motivoVisita"\r\n pInputText\r\n formControlName="motivoVisita"\r\n autocomplete="off"\r\n />\r\n <s-control-errors\r\n [control]="formGroup.controls[\'motivoVisita\']"\r\n [errorMessages]="{ required: \'error_required\' | translate }"\r\n >\r\n </s-control-errors>\r\n </div>\r\n <div class="ui-g-12 ui-md-6 required">\r\n <label for="portaria">{{ "yms.patio.sam_portaria" | translate }}</label>\r\n <s-lookup\r\n dataKey="id"\r\n id="portaria"\r\n name="portaria"\r\n formControlName="portaria"\r\n lookupDisplayField="name"\r\n [multiple]="false"\r\n (onLookupRequest)="portariaLookup.lookupRequest($event)"\r\n (onSearchRequest)="portariaLookup.searchRequest($event)"\r\n [searchTitle]="\'yms.patio.sam_portaria\' | translate"\r\n [searchEmptyTitle]="\'nothing_found\' | translate"\r\n [searchFields]="portariaLookup.searchFields"\r\n [searchGridFields]="portariaLookup.searchGridFields"\r\n [searchGridData]="portariaLookup.searchGridData"\r\n [searchTotalRecords]="portariaLookup.searchTotalRecords"\r\n [searchTotalRecordsLabel]="\r\n \'total_records\' | translate : { value: portariaLookup.searchTotalRecords }\r\n ">\r\n </s-lookup>\r\n <s-control-errors \r\n [control]="formGroup.controls[\'portaria\']"\r\n [errorMessages]="{ required: \'error_required\' | translate }">\r\n </s-control-errors>\r\n </div>\r\n <div class="ui-g-6 ui-md-3 required">\r\n <label for="dataSaida">{{ "yms.patio.sam_data_saida" | translate }}</label>\r\n <p-calendar\r\n id="dataSaida"\r\n name="dataSaida"\r\n formControlName="dataSaida"\r\n inputId="dataSaida"\r\n [showIcon]="true"\r\n [locale]="localeConfig.calendar"\r\n [dateFormat]="localeConfig.calendar.dateFormat"\r\n >\r\n </p-calendar>\r\n <s-control-errors\r\n [control]="formGroup.controls[\'dataSaida\']"\r\n [errorMessages]="{ required: \'error_required\' | translate }"\r\n >\r\n </s-control-errors>\r\n </div>\r\n <div class="ui-g-6 ui-md-3 required">\r\n <label for="horaSaida">{{ "yms.patio.sam_hora_saida" | translate }}</label>\r\n <p-calendar\r\n id="horaSaida"\r\n name="horaSaida"\r\n formControlName="horaSaida"\r\n [locale]="localeConfig.calendar"\r\n inputId="horaSaida"\r\n [showTime]="true"\r\n [hourFormat]="localeConfig.calendar.hourFormat"\r\n [timeOnly]="true"\r\n >\r\n </p-calendar>\r\n <s-control-errors\r\n [control]="formGroup.controls[\'horaSaida\']"\r\n [errorMessages]="{ required: \'error_required\' | translate }"\r\n >\r\n </s-control-errors>\r\n </div>\r\n </div>\r\n </div>\r\n</form>\r\n<div class="separator"></div>\r\n<div *ngIf="schedulingVisitors.visitors">\r\n <visitante-component\r\n [motorista]="agenda.motorista"\r\n [(visitors)]="schedulingVisitors.visitors"\r\n (hasChange)="isFormModified = $event">\r\n </visitante-component>\r\n</div>\r\n<div class="separator"></div>\r\n<div style="margin-top: 10px">\r\n <s-button priority="primary" [label]="\'save\' | translate" (onClick)="onSave()"\r\n [disabled]="loading || !canSave()"></s-button>\r\n <s-button *ngIf="saveAndInitButton" priority="primary" [label]="\'save_and_init\' | translate" (onClick)="onSave(true)"\r\n [disabled]="loading"></s-button>\r\n \r\n</div>\r\n'}),B("design:paramtypes",[C.FormBuilder,F.ActivatedRoute,o.TranslateService,I.MessageService,nt,tt])],e)}(),pt=function(){function e(e){this.dispatcher=e,this._dispatcher=e,this._dispatcher.dispatch(Ve)}return e=V([r.NgModule({declarations:[Ve,Ye,ct,Ze,Xe,Je],entryComponents:[Ve,Ye,ct,Ze,Xe,Je],exports:[Ve,Ye,ct],imports:[p.IntegrationModule,i.CommonModule,o.TranslateModule,C.FormsModule,n.ButtonModule,y.SharedModule,y.CardModule,k.ButtonModule,C.ReactiveFormsModule,T.SharedModule,n.CustomFieldsModule,n.ControlErrorsModule,y.DialogModule,n.EmptyStateModule,n.DynamicFormModule,n.TokenListModule,y.PanelModule,y.InputTextModule,y.DropdownModule,n.ButtonModule,n.LoadingStateModule,n.NumberInputModule,y.ConfirmDialogModule,n.LocaleModule,m.PermissionsModule,v.DynamicDialogModule,l.TableModule,y.TabViewModule,y.CalendarModule],providers:[Be,Ue]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),ut=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.domainService="yms_int/sam",i}return P(t,e),t.prototype.findVisitors=function(e){return this.http.post("yms_int/sam/queries/findVisitorsBySchedulingIdYMS",{agendaIdYMS:e})},t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(I.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,I.MessageService])],t)}(Q),mt=function(e){function i(a){var i=e.call(this)||this;return i.service=a,i.ngUnsubscribe=new t.Subject,i.visitorService=a,i}return P(i,e),i.prototype.ngOnInit=function(){},i.prototype.ngAfterContentInit=function(){var e=this;this.visitorService.findVisitors(this.agenda.id).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){t.visitors.length&&(e.visitors=t.visitors)})},i.prototype.credentialResume=function(e){var t,a,i="";try{for(var r=z(e),o=r.next();!o.done;o=r.next()){var n=o.value;n.cardNumber?i+=n.cardNumber:i+=" - "}}catch(s){t={error:s}}finally{try{o&&!o.done&&(a=r["return"])&&a.call(r)}finally{if(t)throw t.error}}return i},V([r.Input(),B("design:type",Object)],i.prototype,"agenda",void 0),i=V([r.Component({selector:"visitor-list-component",template:'\n<div> \n <p-table [value]="visitors">\n <ng-template pTemplate="header">\n <tr>\n <th id="visitor_name">{{\'yms.patio.motorista_visitante_nome\' | translate}}</th>\n <th id="visitor_docuemnt">{{\'yms.patio.motorista_visitante_documento\' | translate}}</th> \n <th id="visitor_credential">{{\'yms.patio.motorista_visitante_credenciais\' | translate}}</th>\n <th id="visitor_contact">{{\'yms.patio.motorista_visitante_contato\' | translate}}</th>\n </tr>\n </ng-template>\n <ng-template let-rowData pTemplate="body">\n <tr>\n <td id="">{{rowData.visitor.name}}</td>\n <td id="">{{rowData.visitor.document}}</td>\n <td id="">{{credentialResume(rowData.credentialCards)}} </td>\n <td id="">{{rowData.visitor.contact}}</td>\n </tr>\n </ng-template>\n </p-table>\n</div>'}),B("design:paramtypes",[ut])],i)}(function(){function e(){}return e=V([p.ControleCircuito({header:"Ronda",name:"yms.integracao.sam"}),p.ControleOperacao({header:"Ronda",name:"yms.integracao.sam"})],e)}()),ft=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(mt)}return e=V([r.NgModule({imports:[i.CommonModule,l.TableModule,s.MessageModule,o.TranslateModule,n.LoadingStateModule],declarations:[mt],entryComponents:[mt],exports:[mt],providers:[ut]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}();!function(e){e.NONE="NONE",e.SENIOR="SENIOR",e.WIS="WIS",e.ALCIS="ALCIS",e.SENIOR_CONNECT="SENIOR_CONNECT",e.GENERIC="GENERIC"}(dt||(dt={}));var ht,gt=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i}return P(t,e),t.prototype.getSystemIntegration=function(){return this.http.post("yms_int/wms/queries/getSystemIntegration",{})},t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(I.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,I.MessageService])],t)}(Q),vt="Informações adicionais",yt=function(){function e(){}return e=V([p.Agendamento({header:vt,name:"yms.integracao.wms"}),p.ChegadaVeiculo({header:vt,name:"yms.integracao.wms",icon:"fa fa-plus"})],e)}(),bt=function(e){function i(a,i){var r=e.call(this)||this;return r.integrationCallback=a,r.wmsService=i,r.save=[],r.header=vt,r.loading=!1,r.unsubscribe$=new t.Subject,r._integrationCallback=a,r}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this._integrationCallback.onAgendamentoSaved().pipe(a.takeUntil(this.unsubscribe$),a.mergeMap(function(a){return e.agenda=a,t.empty()})).subscribe(),this.wmsService.getSystemIntegration().subscribe(function(t){var a=t.system;e.wmsSystem=a})},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},V([r.Output(),B("design:type",qe)],i.prototype,"agenda",void 0),V([r.Input(),B("design:type",Array)],i.prototype,"save",void 0),V([r.Input(),B("design:type",String)],i.prototype,"wmsSystem",void 0),i=V([r.Component({template:'\n <div *ngIf="agenda">\n <document-grid [agenda]="agenda" [wmsSystem]="wmsSystem" ></document-grid>\n </div>\n '}),B("design:paramtypes",[p.IntegrationEventsCallback,gt])],i)}(yt),Ft=function(){function e(e){this.httpClient=e}return e.prototype.getProcessTypeByScheduling=function(e){return this.httpClient.post("yms/integration/queries/getProcessTypeByScheduling",{idSchedulingType:e})},e.ngInjectableDef=r.defineInjectable({factory:function(){return new e(r.inject(d.HttpClient))},token:e,providedIn:"root"}),e=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient])],e)}();!function(e){e.RECEBIMENTO_CONTRATO="RECEBIMENTO_CONTRATO",e.RECEBIMENTO_ORDEM_COMPRA="RECEBIMENTO_ORDEM_COMPRA",e.EXPEDICAO="EXPEDICAO",e.DEVOLUCAO="DEVOLUCAO",e.PROCESSO_AVULSO="PROCESSO_AVULSO",e.RECEBIMENTO_WMS="RECEBIMENTO_WMS"}(ht||(ht={}));var St,Dt=function(e){function t(t,a){var i=e.call(this,t,a,"yms_int/wms/entities/document","")||this;return i.http=t,i.messageService=a,i}return P(t,e),t.prototype.findDocuments=function(e){return this.http.post("yms_int/wms/queries/findDocuments",e)},t.prototype.getSystemIntegration=function(){return this.http.get("yms_int/wms/queries/getSystemIntegration")},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(et),Ct=function(){function e(e,t,a,i){this.http=e,this.messageService=t,this.entityUrl=a,this.actionsUrl=i,this.http=e,this.messageService=t,this.entityUrl=a,this.actionsUrl=i,this.defaultCatch=this.defaultCatch.bind(this)}return e.prototype.getListQueryParams=function(e){var t=e.page,a=void 0===t?0:t,i=e.size,r=void 0===i?10:i,o=e.sort,n=void 0===o?[]:o,s=e.filterQuery,l=void 0===s?"":s,c=e.displayFields,p=void 0===c?[]:c,u=new d.HttpParams;return u=(u=u.append("size",String(r))).append("offset",String(a)),n&&n.length&&(u=u.append("orderby",n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", "))),l&&(u=u.append("filter",l)),p&&p.length&&(u=u.append("displayfields",p.join())),u},e.prototype.getBodyParams=function(e){var t=e.page,a=void 0===t?0:t,i=e.size,r=void 0===i?10:i,o=e.sort,n=void 0===o?[]:o,s=e.filterQuery,l=void 0===s?"":s,d=e.displayFields,c=void 0===d?[]:d,p={};return p.size=r,p.offset=a,n&&n.length&&(p.orderBy=n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", ")),l&&(p.filter=l),c&&c.length&&(p.displayfields=c.join()),p},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e.prototype.list=function(e){return this.http.get(this.entityUrl,{params:this.getListQueryParams(e)}).pipe(this.defaultCatch())},e.prototype.get=function(e){return this.http.get(this.entityUrl+"/"+e).pipe(this.defaultCatch())},e.prototype.insert=function(e){return this.http.post(""+this.entityUrl,e).pipe(this.defaultCatch())},e.prototype.update=function(e,t){return this.http.put(this.entityUrl+"/"+e,t).pipe(this.defaultCatch())},e.prototype["delete"]=function(e){return this.http["delete"](this.entityUrl+"/"+e).pipe(this.defaultCatch())},e.prototype.listCustomFilter=function(e,t){return this.http.post(this.actionsUrl+"/"+t,this.getBodyParams(e)).pipe(this.defaultCatch())},e}(),_t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return P(t,e),t}(Ct),It=function(e){function t(t,a){var i=e.call(this,t,a,"yms/agenda/entities/agenda","")||this;return i.http=t,i.messageService=a,i.url="yms/agenda/queries/isClienteExterno",i}return P(t,e),t.prototype.isClienteExterno=function(){return this.http.post(""+this.url,{})},t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(I.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,I.MessageService])],t)}(_t),Tt=function(){function e(e,a,i,o,n,s){this.translate=e,this.documentService=a,this.messageService=i,this.confirmationService=o,this.integrationService=n,this.agendaService=s,this.viewDocument=new r.EventEmitter,this.gridData=[],this.enableButtonIsClienteExterno=!0,this.ngUnsubscribe=new t.Subject,this.selection=[]}return e.prototype.ngOnInit=function(){this.verifyClienteExterno(),this.getProcessTypeByScheduling(),this.listDocuments()},e.prototype.ngAfterContentChecked=function(){this.gridColumns=this.getGridColumns()},e.prototype.verifyClienteExterno=function(){var e=this;this.agendaService.isClienteExterno().subscribe(function(t){e.isClienteExterno=t.isClienteExterno,e.cantEditStatus()})},e.prototype.getProcessTypeByScheduling=function(){var e=this;this.integrationService.getProcessTypeByScheduling(this.agenda.tipoAgendamento.id).subscribe(function(t){return e.processType=t.processType})},e.prototype.onChangeDocument=function(e){this.gridData.push(e),this.disabled=!1},e.prototype.cantEditStatus=function(){["CANCELADO","EM_EXECUCAO","CONCLUIDO","AGUARDANDO_POR_VALIDACAO"].includes(this.agenda.status.toString())&&(this.enableButtonIsClienteExterno=!1)},e.prototype.getActions=function(){var e=this;return[{disabled:this.checkWmsSystemInvalid(),label:this.translate.instant("yms.int.wms_search"),command:function(){e.selection=[],e.visibleInvoiceKey=!0},icon:"fa fa-search"},{disabled:this.checkWmsSystemInvalid(),label:this.translate.instant("yms.int.wms_add_document_register"),command:function(){e.selection=[],e.edit=!0,e.visibleDocumentRegister=!0},icon:"fas fa-pen-square"}]},e.prototype.checkWmsSystemInvalid=function(){return!(!this.wmsSystem||this.wmsSystem!==dt.NONE)},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.view=function(){this.viewDocument.emit(this.selection[0]),this.visibleDocumentRegister=!0,this.edit=!1},e.prototype.save=function(){var e=this;this.gridData.length>0&&this.gridData.forEach(function(t){t.id||(t.schedulingId||(t.schedulingId=e.agenda.id),t.key=e.updateKeyByWms(t),e.documentService.insert(t).subscribe(function(){e.message("success","saved_message_title","saved_message_content")}),e.disabled=!0)})},e.prototype.updateKeyByWms=function(e){return e.key||(e.key=e.invoiceKey),this.wmsSystem===dt.WIS&&(e.key=e.invoiceNumber+":"+e.invoiceSerialNumber+":"+e.partnerDocument),e.key},e.prototype.onDelete=function(){var e=this;this.confirmationService.confirm({message:this.translate.instant("delete_confirmation_message"),header:this.translate.instant("delete_confirmation_title"),accept:function(){return e.removeDocumentIfIdUndfined(),e.selection.length<1?t.empty():t.forkJoin(e.selection.map(function(t){return e.documentService["delete"](t.id)})).pipe(a.takeUntil(e.ngUnsubscribe)).subscribe(function(){e.messageService.add({severity:"success",summary:e.translate.instant("deleted_message_title"),detail:e.translate.instant("deleted_message_content")}),e.gridData=[],e.listDocuments()})}})},e.prototype.removeDocumentIfIdUndfined=function(){var e=this;this.selection.forEach(function(t,a){t.id||(e.gridData.splice(a,1),e.selection.splice(a,1))})},e.prototype.listDocuments=function(){var e=this;this.documentService.list({filterQuery:"schedulingId eq '"+this.agenda.id+"'"}).subscribe(function(t){e.gridData=[],t.totalElements>0?(e.gridData=t.contents,e.documentTotalRecords=t.totalElements):e.documentTotalRecords=e.gridData.length,e.disabled=!0,e.loading=!1})},e.prototype.getGridColumns=function(){return this.isWmsSeniorConnect()?H([{field:"key",header:this.translate.instant("yms.int.wms_purchaseOrder")}],this.getColumnPartner()):this.isWmsWIS()?this.getColumnInvoiceAndlogistcUnit():H([{field:"invoiceKey",header:this.translate.instant("yms.int.wms_register_document_invoice_key")}],this.getColumnInvoiceAndlogistcUnit(),[{field:"ownerName",header:this.translate.instant("yms.int.wms_register_document_owner_name")},{field:"ownerDocument",header:this.translate.instant("yms.int.wms_register_document_owner_document")}])},e.prototype.getColumnInvoiceAndlogistcUnit=function(){return H([{field:"invoiceNumber",header:this.translate.instant("yms.int.wms_register_document_invoice_number")},{field:"invoiceSerialNumber",header:this.translate.instant("yms.int.wms_register_document_invoice_serial_number")}],this.getColumnPartner(),[{field:"logistcUnitName",header:this.translate.instant("yms.int.wms_register_document_logistc_unit_name")},{field:"logistcUnitDocument",header:this.translate.instant("yms.int.wms_register_document_logistc_unit_document")}])},e.prototype.getColumnPartner=function(){return[{field:"partnerName",header:this.translate.instant("yms.int.wms_register_document_partner_name")},{field:"partnerDocument",header:this.translate.instant("yms.int.wms_register_document_partner_document")}]},e.prototype.isWmsSeniorConnect=function(){return this.wmsSystem===dt.SENIOR_CONNECT},e.prototype.isWmsWIS=function(){return this.wmsSystem===dt.WIS},e.prototype.message=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),V([r.Input(),B("design:type",String)],e.prototype,"wmsSystem",void 0),V([r.Output(),B("design:type",Boolean)],e.prototype,"visibleInvoiceKey",void 0),V([r.Output(),B("design:type",Boolean)],e.prototype,"visibleDocumentRegister",void 0),V([r.Output(),B("design:type",r.EventEmitter)],e.prototype,"viewDocument",void 0),V([r.ViewChild("documentTable"),B("design:type",l.Table)],e.prototype,"table",void 0),V([r.ViewChild("customTemplate"),B("design:type",r.TemplateRef)],e.prototype,"customTemplate",void 0),V([r.ViewChild("customFilterFields"),B("design:type",r.TemplateRef)],e.prototype,"customFilterFields",void 0),V([r.ViewChild("customGridColgroup"),B("design:type",r.TemplateRef)],e.prototype,"customGridColgroup",void 0),V([r.ViewChild("customGridHeader"),B("design:type",r.TemplateRef)],e.prototype,"customGridHeader",void 0),V([r.ViewChild("customGridBody"),B("design:type",r.TemplateRef)],e.prototype,"customGridBody",void 0),e=V([r.Component({selector:"document-grid",template:'<div *ngIf="this.processType === \'RECEBIMENTO_WMS\'; else processNotConfigured">\n <p-panel>\n <p-header>\n <div class="buttons">\n <div>\n <s-button\n label="{{\'yms.int.wms_add_document\' | translate}}"\n priority="primary"\n [model]="getActions()"\n [auxiliary]="false"\n [disabled]="!enableButtonIsClienteExterno">\n </s-button>\n <s-button\n label="{{\'yms.wms_view_button\' | translate}}"\n priority="secondary"\n [auxiliary]="false"\n [disabled]="!selection || selection.length !== 1"\n (onClick)="view()">\n </s-button>\n <s-button\n label="{{\'yms.wms_delete_button\' | translate}}"\n priority="secondary"\n [disabled]="!selection || !selection.length || !enableButtonIsClienteExterno"\n (click)="onDelete()">\n </s-button>\n </div>\n <s-button\n id="refresh-button"\n priority="default"\n iconClass="fa fa-refresh"\n (onClick)="listDocuments()"\n >\n </s-button>\n </div>\n </p-header>\n <div class="ui-g">\n <div class="ui-g-12" *ngIf="gridData && gridData.length; else emptyList">\n <p-table #documentTable [value]="gridData"\n [columns]="gridColumns" dataKey="id" [lazy]="true" [scrollable]="true" [resizableColumns]="true"\n sortMode="multiple" [paginator]="true" [totalRecords]="documentTotalRecords" rows="10"\n [rowsPerPageOptions]="[10, 20, 50, 100]" [(selection)]="selection"\n [loading]="loading">\n <ng-template pTemplate="colgroup" let-columns>\n <colgroup>\n <col *ngFor="let col of columns" [style.width]="col.width"/>\n </colgroup>\n </ng-template>\n <ng-template pTemplate="header" let-columns>\n <tr>\n <th id="checkbox" class="table-checkbox">\n <p-tableHeaderCheckbox></p-tableHeaderCheckbox>\n </th>\n <th id="col" *ngFor="let col of columns" [pSortableColumn]="col.field" pResizableColumn>\n <div class="senior-header">\n <span class="senior-header-title">{{ col.header }}</span>\n <p-sortIcon [field]="col.field"></p-sortIcon>\n </div>\n </th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData let-columns let-expanded="expanded">\n <tr [pSelectableRow]="rowData">\n <td class="table-checkbox">\n <p-tableCheckbox [value]="rowData"></p-tableCheckbox>\n </td>\n <td *ngFor="let column of getGridColumns()" (click)="selection = [rowData]">\n <span>{{ rowData[ column.field ] }}</span>\n </td>\n </tr>\n </ng-template>\n <ng-template pTemplate="paginatorright">\n <span [translate]="\'total_records\'" [translateParams]="{ value: documentTotalRecords }"></span>\n </ng-template>\n </p-table> \n </div>\n </div>\n <register-document\n [wmsSystem]="wmsSystem"\n [edit]="edit"\n [viewDocument]="selection"\n (document)="onChangeDocument($event)"\n [(visible)]="visibleDocumentRegister"\n [agenda]="agenda">\n </register-document> \n <insert-key [wmsSystem]="wmsSystem" \n (document)="onChangeDocument($event)" [(visible)]="visibleInvoiceKey"></insert-key>\n </p-panel>\n</div>\n <div class="button-save">\n <s-button \n priority="primary" [label]="\'save\' | translate"\n [disabled]="disabled || !this.gridData || !enableButtonIsClienteExterno"\n (click)="save()">\n </s-button>\n </div>\n <register-document\n [wmsSystem]="wmsSystem"\n [edit]="edit"\n [viewDocument]="selection"\n (document)="onChangeDocument($event)"\n [(visible)]="visibleDocumentRegister"\n [agenda]="agenda">\n </register-document> \n <insert-key [wmsSystem]="wmsSystem" \n (document)="onChangeDocument($event)" [(visible)]="visibleInvoiceKey"></insert-key>\n\n<ng-template #emptyList>\n <div class="center">\n <s-empty-state\n iconClass="fa fa-exclamation-triangle" [title]="\'detail_empty_state_title\' | translate"\n [description]="\'detail_empty_state_description\' | translate">\n </s-empty-state>\n </div>\n</ng-template>\n\n<ng-template #processNotConfigured>\n <div class="center">\n <s-empty-state\n iconClass="fa fa-exclamation-triangle"\n [title]="\'yms.int.wms_there_no_process_type_configured_for_this_type_scheduling\' | translate"\n >\n </s-empty-state>\n </div>\n</ng-template>',styles:[".buttons{display:flex;justify-content:space-between}.center{flex-direction:column;text-align:center}.ui-g{display:block}.button-save{margin:5px 0}#refresh-button{color:#fff}.table-checkbox{width:50px}"]}),B("design:paramtypes",[o.TranslateService,Dt,c.MessageService,c.ConfirmationService,Ft,It])],e)}(),kt=_,Mt=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&kt(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&kt(a.lastModifiedDate).toDate();return a.label=["id","schedulingId","invoiceKey","invoiceNumber","invoiceSerialNumber","systemIntegration","logistcUnitName","logistcUnitDocument","ownerName","ownerDocument","partnerName","partnerDocument","notes","code","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&kt(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&kt(a.lastModifiedDate).format(),a},e}(),Rt=function(){function e(e,t,a){this.fb=e,this.messageService=t,this.translateService=a,this.document=new r.EventEmitter,this.visible=new r.EventEmitter,this.visibleChange=new r.EventEmitter}return e.prototype.ngOnInit=function(){this.getFormGroup()},e.prototype.ngOnChanges=function(){this.visibilityConfig()},e.prototype.visibilityConfig=function(){if(!this.edit&&this.visible)return this.formGroup.disable(),this.setValuesFormGroup(this.viewDocument[0]),this.hideSaveButton=!0,this.visible;this.formGroup!==undefined&&(this.formGroup.enable(),this.hideSaveButton=!1)},e.prototype.close=function(){this.visibleChange.emit(!1),this.formGroup.reset()},e.prototype.setValuesFormGroup=function(e){this.formGroup.get("key").setValue(e.key),this.formGroup.get("invoiceKey").setValue(e.invoiceKey),this.formGroup.get("invoiceNumber").setValue(e.invoiceNumber),this.formGroup.get("invoiceSerialNumber").setValue(e.invoiceSerialNumber),this.formGroup.get("logistcUnitDocument").setValue(e.logistcUnitDocument),this.formGroup.get("logistcUnitName").setValue(e.logistcUnitName),this.formGroup.get("notes").setValue(e.notes),this.formGroup.get("code").setValue(e.code),this.formGroup.get("partnerName").setValue(e.partnerName),this.formGroup.get("partnerDocument").setValue(e.partnerDocument),this.formGroup.get("ownerDocument").setValue(e.ownerDocument),this.formGroup.get("ownerName").setValue(e.ownerName)},e.prototype.getFormGroup=function(){this.formGroup=this.fb.group({key:[undefined,C.Validators.required],invoiceKey:[undefined],schedulingId:[undefined],invoiceNumber:[undefined],invoiceSerialNumber:[undefined],logistcUnitName:[undefined],logistcUnitDocument:[undefined],ownerName:[undefined],ownerDocument:[undefined],partnerName:[undefined],partnerDocument:[undefined],notes:[undefined],code:[undefined]})},e.prototype.save=function(){var e=this.formGroup.getRawValue();e.id===undefined&&(this.agenda.id!==undefined&&(e.schedulingId=this.agenda.id),e.key===undefined&&(e.key=e.invoiceKey,this.isWmsWis()&&(e.key=e.invoiceNumber+":"+e.invoiceSerialNumber+":"+e.partnerDocument)),this.document.emit(Mt.fromDto(e)),this.successMessage(),this.visibleChange.emit(!1))},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translateService.instant("yms.saved_message_title"),detail:this.translateService.instant("yms.int.wms_success_message_description")})},e.prototype.isWmsWis=function(){return this.wmsSystem===dt.WIS},e.prototype.isWmsSeniorConnect=function(){return this.wmsSystem===dt.SENIOR_CONNECT},V([r.Input(),B("design:type",Array)],e.prototype,"viewDocument",void 0),V([r.Input(),B("design:type",Boolean)],e.prototype,"edit",void 0),V([r.Input(),B("design:type",qe)],e.prototype,"agenda",void 0),V([r.Output(),B("design:type",r.EventEmitter)],e.prototype,"document",void 0),V([r.Input(),B("design:type",String)],e.prototype,"wmsSystem",void 0),V([r.Input(),B("design:type",r.EventEmitter)],e.prototype,"visible",void 0),V([r.Output(),B("design:type",Object)],e.prototype,"visibleChange",void 0),e=V([r.Component({selector:"register-document",template:'<s-sidebar\n [visible]="visible"\n header="{{ \'yms.int.wms_register_document_add_document\' | translate }} {{ wmsSystem }}"\n (visibleChange)="close()">\n <form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-6" *ngIf="isWmsSeniorConnect()">\n <label for="key">{{\'yms.int.wms_purchaseOrder\' | translate}}</label>\n <input id="key" pInputText type="text" formControlName="key">\n </div>\n <div class="ui-g-6" *ngIf="!isWmsSeniorConnect() && !isWmsWis()">\n <label for="invoiceKey">{{\'yms.int.wms_register_document_invoice_key\' | translate}}</label>\n <input id="invoiceKey" pInputText type="text" formControlName="invoiceKey">\n </div>\n <div class="ui-g-6" *ngIf="!isWmsSeniorConnect()">\n <label for="invoiceNumber">{{\'yms.int.wms_register_document_invoice_number\' | translate}}</label>\n <input id="invoiceNumber" pInputText type="text" formControlName="invoiceNumber">\n </div>\n <div class="ui-g-6" *ngIf="!isWmsSeniorConnect()">\n <label for="invoiceSerialNumber">\n {{\'yms.int.wms_register_document_invoice_serial_number\' | translate}}\n </label>\n <input id="invoiceSerialNumber" pInputText type="text" formControlName="invoiceSerialNumber">\n </div>\n <div class="ui-g-8">\n <label for="logistcUnitName">{{\'yms.int.wms_register_document_logistc_unit_name\' | translate}}</label>\n <input id="logistcUnitName" pInputText type="text" formControlName="logistcUnitName">\n </div>\n <div class="ui-g-4">\n <label for="logistcUnitDocument">\n {{\'yms.int.wms_register_document_logistc_unit_document\' | translate}}\n </label>\n <input id="logistcUnitDocument" pInputText type="text" formControlName="logistcUnitDocument">\n </div>\n <div class="ui-g-8" *ngIf="!isWmsSeniorConnect() && !isWmsWis()">\n <label for="documentOwnerName">{{\'yms.int.wms_register_document_owner_name\' | translate}}</label>\n <input id="documentOwnerName" pInputText type="text" formControlName="ownerName">\n </div>\n <div class="ui-g-4" *ngIf="!isWmsSeniorConnect() && !isWmsWis()">\n <label for="ownerDocument">{{\'yms.int.wms_register_document_owner_document\' | translate}}</label>\n <input id="ownerDocument" pInputText type="text" formControlName="ownerDocument">\n </div>\n <div class="ui-g-8">\n <label for="partnerName">{{\'yms.int.wms_register_document_partner_name\' | translate}}</label>\n <input id="partnerName" pInputText type="text" formControlName="partnerName">\n </div>\n <div class="ui-g-4">\n <label for="partnerDocument">{{\'yms.int.wms_register_document_partner_document\' | translate}}</label>\n <input id="partnerDocument" pInputText type="text" formControlName="partnerDocument">\n </div>\n <div class="ui-g-12">\n <label for="notes" id="notes">{{\'yms.int.wms_register_document_notes\' | translate}}</label>\n <textarea id="notes" rows="4" pInputTextarea autoResize="autoResize" formControlName="notes"></textarea>\n </div>\n <div class="ui-g-4">\n <label for="code">\n {{\'yms.int.wms_register_document_order_receiving_code\' | translate}}\n </label>\n <input id="code" pInputText type="text" formControlName="code">\n </div>\n </div>\n </form>\n <div class="space-between">\n <button\n pButton label="{{\'save\' | translate}}" (click)="save()" [attr.data-hidden]="hideSaveButton">\n </button>\n <button\n type="button" class="ui-button-link" pButton label="{{\'cancel\' | translate}}" (click)="close()">\n </button>\n </div>\n</s-sidebar>'}),B("design:paramtypes",[C.FormBuilder,c.MessageService,o.TranslateService])],e)}(),Et=function(){function e(){}return e=V([r.NgModule({imports:[i.CommonModule,n.SidebarModule,n.ButtonModule,y.PanelModule,y.ConfirmDialogModule,o.TranslateModule,y.InputTextModule,n.ControlErrorsModule,y.InputTextareaModule,C.ReactiveFormsModule],exports:[Rt],declarations:[Rt],providers:[Dt]})],e)}(),Nt=function(){function e(e,t,a,i){this.formBuilder=e,this.documentService=t,this.messageService=a,this.translate=i,this.document=new r.EventEmitter,this.visible=new r.EventEmitter,this.visibleChange=new r.EventEmitter}return e.prototype.ngOnInit=function(){this.formGroup=this.formBuilder.group({key:[undefined],purchaseOrder:[undefined],invoiceNumber:[undefined],invoiceSerie:[undefined],partnerDocument:[undefined]})},e.prototype.isWmsWis=function(){return this.wmsSystem===dt.WIS},e.prototype.isWmsSeniorConnect=function(){return this.wmsSystem===dt.SENIOR_CONNECT},e.prototype.add=function(){this.visibleChange.emit(!1),this.searchKey()},e.prototype.searchKey=function(){var e=this,t={documentKeys:[this.formGroup.get("key").value],invoices:[{number:this.formGroup.get("invoiceNumber").value,serialNumber:this.formGroup.get("invoiceSerie").value,partnerDocument:this.formGroup.get("partnerDocument").value}],logistcUnitName:undefined,size:0,offset:0};this.documentService.findDocuments(t).subscribe(function(t){t.totalElements<1?e.message("warn","yms.int.wms_insert_key_warning_message_header","yms.int.wms_insert_key_warning_message_description"):(e.document.emit(t.contents[0]),e.message("success","yms.int.wms_insert_key_success_message_header","yms.int.wms_success_message_description"),e.formGroup.reset())})},e.prototype.message=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.cancel=function(){this.visibleChange.emit(!1)},V([r.Output(),B("design:type",r.EventEmitter)],e.prototype,"document",void 0),V([r.Input(),B("design:type",r.EventEmitter)],e.prototype,"visible",void 0),V([r.Input(),B("design:type",String)],e.prototype,"wmsSystem",void 0),V([r.Output(),B("design:type",Object)],e.prototype,"visibleChange",void 0),e=V([r.Component({selector:"insert-key",template:'<form [formGroup]="formGroup">\n <p-dialog [(visible)]="visible" [modal]="true" [draggable]="false" (visibleChange)="cancel()">\n <p-header>{{\'yms.int.wms_search_document\' | translate}} {{ wmsSystem }}</p-header>\n <div class="flex py-2 justify-content-center spacing-bottom" \n *ngIf="!isWmsSeniorConnect() && !isWmsWis()">\n <label for="key">{{\'yms.int.wms_insert_key_label\' | translate}}</label>\n <input id="key" class="size-input" pInputText type="text" formControlName="key">\n </div>\n <div class="flex py-2 justify-content-center spacing-bottom" *ngIf="isWmsSeniorConnect()">\n <label for="purchaseOrder">{{\'yms.int.wms_purchaseOrder\' | translate}} </label>\n <input id="purchaseOrder" class="size-input" pInputText type="text" formControlName="purchaseOrder">\n </div>\n <div class="flex py-2 justify-content-center spacing-bottom" *ngIf="isWmsWis()">\n <label for="invoiceNumber">{{\'yms.int.wms_invoice_number\' | translate}}</label>\n <input id="invoiceNumber" class="size-input" pInputText type="text" formControlName="invoiceNumber">\n </div>\n <div class="flex py-2 justify-content-center spacing-bottom" *ngIf="isWmsWis()">\n <label for="invoiceSerie">{{\'yms.int.wms_invoice_serie\' | translate}}</label>\n <input id="invoiceSerie" class="size-input" pInputText type="text" formControlName="invoiceSerie">\n </div>\n <div class="flex py-2 justify-content-center spacing-bottom" *ngIf="isWmsWis()">\n <label for="partnerDocument">{{\'yms.int.wms_partner_document\' | translate}}</label>\n <input id="partnerDocument" class="size-input" pInputText type="text" formControlName="partnerDocument">\n </div>\n <div class="separator"></div>\n <div class="spacing-top">\n <s-button pButton label="{{\'yms.int.wms_search\' | translate}}" (click)="add()"></s-button>\n <s-button\n type="button"\n class="ui-button-link"\n pButton label="{{\'cancel\' | translate}}"\n (click)="cancel()">\n </s-button>\n </div>\n </p-dialog>\n</form>',styles:[".spacing-top{margin-top:10px}.spacing-bottom{margin-bottom:10px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.size-input{width:480px}"]}),B("design:paramtypes",[C.FormBuilder,Dt,c.MessageService,o.TranslateService])],e)}(),At=function(){function e(){}return e=V([r.NgModule({imports:[i.CommonModule,C.ReactiveFormsModule,n.ButtonModule,o.TranslateModule,y.DialogModule,y.InputTextModule],exports:[Nt],declarations:[Nt]})],e)}(),wt=function(){function e(){}return e=V([r.NgModule({declarations:[Tt],entryComponents:[Tt],exports:[Tt],imports:[i.CommonModule,o.TranslateModule,n.ButtonModule,y.PanelModule,l.TableModule,Et,At,k.ButtonModule,b.ComponentsModule,n.EmptyStateModule]})],e)}(),Gt=function(){function e(e){e.dispatch(bt)}return e=V([r.NgModule({declarations:[bt],entryComponents:[bt],exports:[bt],imports:[p.IntegrationModule,wt,i.CommonModule,o.TranslateModule,C.FormsModule,n.ButtonModule,y.SharedModule,y.CardModule,k.ButtonModule,C.ReactiveFormsModule,T.SharedModule,n.CustomFieldsModule,n.ControlErrorsModule,y.DialogModule,n.EmptyStateModule,n.DynamicFormModule,n.TokenListModule,y.PanelModule,y.InputTextModule,y.DropdownModule,n.ButtonModule,n.LoadingStateModule,n.NumberInputModule,y.ConfirmDialogModule,n.LocaleModule,m.PermissionsModule,v.DynamicDialogModule,l.TableModule,y.TabViewModule,y.CalendarModule],providers:[Be,Ue,gt]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),Ot=function(e){function t(t){var a=e.call(this)||this;return a.documentService=t,a.getColumns=[],a.documents=[],a.labels=[],a}return P(t,e),t.prototype.ngOnInit=function(){this.getSystemIntegration()},t.prototype.getSystemIntegration=function(){var e=this;this.documentService.getSystemIntegration().subscribe(function(t){e.wmsSystem=t.system,e.getDocumentBySchedulingId()})},t.prototype.getDocumentBySchedulingId=function(){var e=this;this.documentService.list({filterQuery:"schedulingId eq '"+this.agenda.id+"'"}).subscribe(function(t){t.totalElements>0&&(e.documents=t.contents,e.getColumns=e.getColumnLabels())})},t.prototype.getColumnLabels=function(){return this.isWmsWIS()?H(this.getLabelsInvoice()):this.isWmsSeniorConnect()?[{label:"yms.int.wms_purchaseOrder"},{label:"yms.int.wms_register_document_partner_name"},{label:"yms.int.wms_register_document_partner_document"}]:H([{label:"yms.int.wms_register_document_invoice_key"}],this.getLabelsInvoice())},t.prototype.isWmsSeniorConnect=function(){return this.wmsSystem===dt.SENIOR_CONNECT},t.prototype.isWmsWIS=function(){return this.wmsSystem===dt.WIS},t.prototype.getLabelsInvoice=function(){return[{label:"yms.int.wms_register_document_invoice_number"},{label:"yms.int.wms_register_document_invoice_serial_number"}]},V([r.Input(),B("design:type",Object)],t.prototype,"agenda",void 0),V([r.Input(),B("design:type",String)],t.prototype,"wmsSystem",void 0),t=V([r.Component({template:'<div> \n <p-table [value]="documents">\n <ng-template pTemplate="header">\n <tr>\n <th id="columns" *ngFor="let column of getColumns">\n <div class="senior-header">\n <span class="senior-header-title">{{ column.label | translate }}</span>\n </div>\n </th>\n </tr>\n </ng-template>\n <ng-template let-rowData pTemplate="body">\n <tr *ngIf="isWmsWIS()">\n <td id="">{{rowData?.invoiceNumber}}</td>\n <td id="">{{rowData?.invoiceSerialNumber}}</td>\n </tr>\n <tr *ngIf="isWmsSeniorConnect()">\n <td id="">{{rowData?.key}}</td>\n <td id="">{{rowData?.partnerName}}</td>\n <td id="">{{rowData?.partnerDocument}}</td>\n </tr>\n <tr *ngIf="!isWmsWIS() && !isWmsSeniorConnect()">\n <td id="">{{rowData?.invoiceKey}}</td>\n <td id="">{{rowData?.invoiceNumber}}</td>\n <td id="">{{rowData?.invoiceSerialNumber}}</td>\n </tr>\n </ng-template>\n </p-table>\n</div>'}),B("design:paramtypes",[Dt])],t)}(function(){function e(){}return e=V([p.ControleCircuito({header:"Informações adicionais",name:"yms.integracao.wms"})],e)}()),xt=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(Ot)}return e=V([r.NgModule({imports:[i.CommonModule,o.TranslateModule,n.LoadingStateModule,l.TableModule],declarations:[Ot],entryComponents:[Ot],exports:[Ot],providers:[Dt]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),Lt=new r.InjectionToken("integration_environment"),qt=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/agenda",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r._agendaUrl=i.project.domain+"/patio",r}return P(t,e),t.prototype.atualizarAgenda=function(e){return this.http.post(this._agendaUrl+"/actions/atualizarAgenda",{agenda:e}).pipe(this.defaultCatch())},t.prototype.retornaModelosValidacao=function(e){return this.http.post("yms/agenda/queries/retornaModelosDeValidacao",{tipoAgendamentoId:e}).pipe(this.defaultCatch())},t.prototype.checarRevalidacao=function(e){return this.http.post("yms/agenda/actions/checarRevalidacao",e).pipe(this.defaultCatch())},t.prototype.listExternalAgenda=function(e){return this.http.get("yms/agenda/entities/agenda",{params:this.getListQueryParams(e)}).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),Pt=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/recebimentoContrato",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r._baseUrl=i.project.domain+"/"+i.project.service,r}return P(t,e),t.prototype.registrarChegadaVeiculoComRecebimento=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComRecebimento",e).pipe(this.defaultCatch())},t.prototype.insertContratoRecebimento=function(e,t){return this.http.post(this.entityUrl+"/recebimento/"+e+"/contratos",t).pipe(this.defaultCatch())},t.prototype.insertContratoRecebimentoItem=function(e,t){return this.http.post(this.entityUrl+"/contratoRecebimento/"+e+"/itens",t).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),jt=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.recebimentoService=a,this.RECEBIMENTO_KEY="ERP_SENIOR_RECEBIMENTO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.RECEBIMENTO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.RECEBIMENTO_KEY)},e.prototype.functionToOverride=function(e){var i=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return i.recebimentoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?i.recebimentoService.registrarChegadaVeiculoComRecebimento({recebimento:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Os dados da guia ERP Senior não foram informados")}))},e=V([r.Injectable(),B("design:paramtypes",[p.ChegadaVeiculoOverride,qt,Pt])],e)}(),Vt=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/expedicao",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r._baseUrl=i.project.domain+"/"+i.project.service,r}return P(t,e),t.prototype.registrarChegadaVeiculoComExpedicao=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComExpedicao",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,c.MessageService,Object])],t)}(Ct),Ut=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.expedicaoService=a,this.EXPEDICAO_KEY="ERP_SENIOR_EXPEDICAO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.EXPEDICAO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.EXPEDICAO_KEY)},e.prototype.functionToOverride=function(e){var i=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return i.expedicaoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?i.expedicaoService.registrarChegadaVeiculoComExpedicao({expedicao:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Não foi possível encontrar os dados de expedição")}))},e=V([r.Injectable(),B("design:paramtypes",[p.ChegadaVeiculoOverride,qt,Vt])],e)}(),Bt=function(){function e(e,t){this.http=e,this.messageService=t,this.baseUrl="yms/integration/"}return e.prototype.getProcessConfigurationErp=function(e){return this.http.get(this.baseUrl+"queries/getErpProcessConfigurationByTipoAgendamento",{params:{idTipoAgendamento:e}}).pipe(this.defaultCatch())},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],e)}(),zt="ERP Senior",$t=function(){function e(){}return e=V([p.Agendamento({header:zt,name:"yms.integracao.erpagrox"}),p.ChegadaVeiculo({header:zt,name:"yms.integracao.erpagrox",icon:"fal fa-book"})],e)}(),Ht=function(e){function i(a,i){var r=e.call(this)||this;return r.integrationCallback=a,r.integrationService=i,r.header=zt,r.loading=!1,r.unsubscribe$=new t.Subject,r}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this.integrationCallback.onAgendamentoSaved().pipe(a.takeUntil(this.unsubscribe$),a.mergeMap(function(i){return e.agenda=i,e.loading=!0,e.agenda?e.integrationService.getProcessConfigurationErp(e.agenda.tipoAgendamento.id).pipe(a.finalize(function(){return e.loading=!1})):t.empty()})).subscribe(function(t){return e.tipoProcessoErpAtual=t.id})},i.prototype.ngOnChanges=function(){},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},i=V([r.Component({template:'\n <div *ngIf="agenda">\n <div [ngSwitch]="tipoProcessoErpAtual">\n <recebimento-form *ngSwitchCase="\'RECEBIMENTO_CONTRATO\'" [agenda]="agenda"></recebimento-form>\n <expedicao-form *ngSwitchCase="\'EXPEDICAO\'" [agenda]="agenda"></expedicao-form>\n <devolucao-form *ngSwitchCase="\'DEVOLUCAO\'" [agenda]="agenda"></devolucao-form>\n <recebimento-ordem-compra-form *ngSwitchCase="\'RECEBIMENTO_ORDEM_COMPRA\'" [agenda]="agenda"></recebimento-ordem-compra-form>\n <processo-avulso-form *ngSwitchCase="\'PROCESSO_AVULSO\'" [agenda]="agenda"></processo-avulso-form>\n <div *ngSwitchDefault>\n <s-loading-state [loading]="loading">\n <h3 *ngIf="!loading" style="text-align: center;">\n ATENÇÃO, não existe Tipo de Processo configurado para esse tipo de agendamento.\n </h3>\n <h3 *ngIf="loading" style="text-align: center;"> Carregando configurações </h3>\n </s-loading-state>\n </div>\n </div>\n </div>\n '}),B("design:paramtypes",[p.IntegrationEventsCallback,Bt])],i)}($t),Yt="Informações fiscais",Qt=function(){function e(){}return e=V([p.ControleCircuito({header:Yt,name:"yms.integracao.erpagrox"}),p.ControleOperacao({header:Yt,name:"yms.integracao.erpagrox"}),p.CircuitoFinalizado({header:Yt,name:"yms.integracao.erpagrox"})],e)}(),Kt=function(e){function i(a){var i=e.call(this)||this;return i.integrationService=a,i.ngUnsubscribe=new t.Subject,i}return P(i,e),i.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},i.prototype.ngOnInit=function(){var e=this;this.integrationService.getProcessConfigurationErp(this.agenda.tipoAgendamento.id).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.tipoProcessoErpAtual=t.id})},V([r.Input(),B("design:type",Object)],i.prototype,"agenda",void 0),i=V([r.Component({template:'\n <div *ngIf="agenda">\n <div [ngSwitch]="tipoProcessoErpAtual">\n <recebimento-info *ngSwitchCase="\'RECEBIMENTO_CONTRATO\'" [agenda]="agenda"></recebimento-info>\n <expedicao-info *ngSwitchCase="\'EXPEDICAO\'" [agenda]="agenda"></expedicao-info>\n <devolucao-info *ngSwitchCase="\'DEVOLUCAO\'" [agenda]="agenda"></devolucao-info> \n <recebimento-ordem-compra-info *ngSwitchCase="\'RECEBIMENTO_ORDEM_COMPRA\'" [agenda]="agenda"></recebimento-ordem-compra-info>\n <processo-avulso-info *ngSwitchCase="\'PROCESSO_AVULSO\'" [agenda]="agenda"></processo-avulso-info>\n </div>\n </div>\n '}),B("design:paramtypes",[Bt])],i)}(Qt),Wt=function(){function e(e,t){this.messageService=e,this.translate=t}return e.prototype.verificaSeNotaFiscalEstaDuplicada=function(e,t,a){if(""==e)return!1;var i=a.filter(function(t){return t.id==e});return void 0!==t&&i.length<=0&&(t=t.value).length>0&&(i=t.filter(function(t){return!(t.notas.length<=0)&&t.notas.filter(function(t){return t.chaveNotaFiscal==e}).length>0})),i.length>0&&(this.messageService.add({severity:"error",summary:this.translate.instant("yms.integration.titulo_nota_fical_ja_exite"),detail:this.translate.instant("yms.integration.conteudo_nota_fical_ja_exite")}),!0)},e.prototype.findDuplicateFornecedores=function(e){var t,a=e.documentos.map(function(e){return e.numero});return(t=a,t.filter(function(e,t){return a.indexOf(e)!==t})).length>0?e.documentos.map(function(e){return e.fornecedor.codigo}).join(" "):null},e=V([r.Injectable(),B("design:paramtypes",[I.MessageService,o.TranslateService])],e)}(),Jt=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/ordemCompra",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.environment=i,r}return P(t,e),t.prototype.listOrdensCompra=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarOrdensCompra",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),Xt=_,Zt=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Xt(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Xt(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","nome","fantasia"]," - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Xt(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Xt(a.lastModifiedDate).format(),delete a.label,a},e}(),ea=_,ta=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&ea(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ea(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","nome","cpfCnpj"]," - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&ea(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ea(a.lastModifiedDate).format(),delete a.label,a},e}(),aa=_,ia=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&aa(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&aa(a.lastModifiedDate).toDate();return a.label=["id","pessoa.codigo","pessoa.nome","pessoa.site","pessoa.situacao","pessoa.cliente","pessoa.fornecedor","pessoa.representante","cnpj","nomeFantasia","inscricaoEstadual","inscricaoMunicipal","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.fromDto(a.pessoa,"PessoaJuridica")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&aa(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&aa(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.toDto(a.pessoa,"PessoaJuridica")),a},e}(),ra=_,oa=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&ra(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ra(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&ra(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ra(a.lastModifiedDate).format(),delete a.label,a},e}(),na=_,sa=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&na(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&na(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","abreviatura","pais.id","pais.codigo","pais.descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Pais"!==t&&a.pais&&(a.pais=oa.fromDto(a.pais,"Estado")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&na(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&na(a.lastModifiedDate).format(),delete a.label,"Pais"!==t&&a.pais&&(a.pais=oa.toDto(a.pais,"Estado")),a},e}(),la=_,da=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&la(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&la(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","estado.id","estado.codigo","estado.descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Estado"!==t&&a.estado&&(a.estado=sa.fromDto(a.estado,"Cidade")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&la(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&la(a.lastModifiedDate).format(),delete a.label,"Estado"!==t&&a.estado&&(a.estado=sa.toDto(a.estado,"Cidade")),a},e}(),ca=_,pa=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&ca(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ca(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","endereco"]," - "),"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.fromDto(a.pessoa,"PessoaEndereco")),"Cidade"!==t&&a.cidade&&(a.cidade=da.fromDto(a.cidade,"PessoaEndereco")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&ca(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ca(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.toDto(a.pessoa,"PessoaEndereco")),"Cidade"!==t&&a.cidade&&(a.cidade=da.toDto(a.cidade,"PessoaEndereco")),a},e}(),ua=_,ma=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&ua(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ua(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","nome","empresa.nome"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"Filial")),"PessoaJuridica"!==t&&a.pessoaJuridica&&(a.pessoaJuridica=ia.fromDto(a.pessoaJuridica,"Filial")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=pa.fromDto(a.endereco,"Filial")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&ua(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ua(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"Filial")),"PessoaJuridica"!==t&&a.pessoaJuridica&&(a.pessoaJuridica=ia.toDto(a.pessoaJuridica,"Filial")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=pa.toDto(a.endereco,"Filial")),a},e}(),fa=_,ha=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&fa(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&fa(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","descricao","tipo"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"Produto")),"Filial"!==t&&a.filial&&(a.filial=ma.fromDto(a.filial,"Produto")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&fa(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&fa(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"Produto")),"Filial"!==t&&a.filial&&(a.filial=ma.toDto(a.filial,"Produto")),a},e}(),ga=_,va=function(){function e(e,a,i,r,o,n){this.dialogRef=e,this.dialogConfig=a,this.ordemCompraService=i,this.translate=r,this.fb=o,this.route=n,this.ordemCompraLookupDisplayFields=["codigo","empresa.nome"],this.ordemCompraAdvancedDisplayFields=["id","codigo","empresa.nome","filial.nome","pessoa.nome"],this.ordemCompraLookupSeparator=" - ",this.permissions={},this.ngUnsubscribe=new t.Subject}return e.prototype.ngOnInit=function(){var e=this,t=this.dialogConfig.data;this.agenda=t.agenda,this.filial=t.filial,this.fornecedor=t.fornecedor,this.ordensCompra=t.ordens.map(function(e){var t=e.ordemCompra;return t?t.id:undefined}).filter(function(e){return!!e}),this.formGroup=this.getForm(),this.ordemCompraSearchFields=this.getOrdemCompraFields(),this.ordemCompraSearchGridFields=this.getOrdemCompraGridFields(),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)})},e.prototype.onRouteDataChange=function(e){this.permissions=e.allPermissions.agenda},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},e.prototype.onOrdemCompraLookupRequest=function(e){var t=this,a=this.ordemCompraLookupDisplayFields.map(function(e){return{field:e,order:"Asc"}})[0],i={numero:+e.replace(/\D/g,"")},r=this.filial;r&&r.empresa&&r.empresa.id&&(i.empresaId=r.empresa.id),this.ordemCompraService.listOrdensCompra(j({},i,{pessoaId:(this.fornecedor||{id:undefined}).id,filialId:(r||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,ordensCompraSelecionados:this.ordensCompra,pagina:{limit:30,offset:0,listaOrdenacao:[{campo:a.field,ordenacao:a.order}]}})).subscribe(function(e){t.ordemCompraLookupSuggestions=e.contents.map(ha.fromDto)})},e.prototype.onOrdemCompraSearchRequest=function(e){var t=this,a=e.first,i=e.rows,r=e.multiSortMeta,o=e.filterData,n=a/i,s=this.getOrdemCompraFields().filter(function(e){var t=e.name;return o[t]!=undefined&&""!=o[t]}).reduce(function(e,t){var a;return j({},e,((a={})[t.name]=o[t.name],a))},{}),l=this.filial;l&&l.empresa&&l.empresa.id&&(s.empresaId=l.empresa.id),s.dataEmissao=s.dataEmissao&&ga(s.dataEmissao).format("YYYY-MM-DD");var d=(r||[]).length?{field:r[0].field,order:1===r[0].order?"Asc":"Desc"}:{field:"numero",order:"Asc"};this.ordemCompraService.listOrdensCompra(j({},s,{pessoaId:(this.fornecedor||{id:undefined}).id,filialId:(l||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,ordensCompraSelecionados:this.ordensCompra,pagina:{limit:i,offset:n,listaOrdenacao:[{campo:d.field,ordenacao:d.order}]}})).subscribe(function(e){t.ordemCompraSearchGridData=e.contents.map(ha.fromDto),t.ordemCompraSearchTotalRecords=e.totalElements})},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup?t.validateAllFormFields(i):i instanceof C.FormArray&&i.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e.prototype.save=function(){if(!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);this.close(this.formGroup.get("ordemCompra").value)},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.getForm=function(){return this.fb.group({ordemCompra:[undefined,C.Validators.required]})},e.prototype.getOrdemCompraFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")})]},e.prototype.getOrdemCompraGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")})]},e=V([r.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 ui-md-6">\n <label for="ordemCompra">Ordem Compra</label>\n <s-lookup dataKey="id" name="ordemCompra"\n formControlName="ordemCompra" [searchFields]="ordemCompraSearchFields"\n [searchGridFields]="ordemCompraSearchGridFields"\n [searchGridData]="ordemCompraSearchGridData" [multiple]="false"\n [lookupSuggestions]="ordemCompraLookupSuggestions"\n (onLookupRequest)="onOrdemCompraLookupRequest($event)"\n (onSearchRequest)="onOrdemCompraSearchRequest($event)"\n lookupDisplayField="label" [searchTotalRecords]="ordemCompraSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_ordem_compra_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: ordemCompraSearchTotalRecords}">\n </s-lookup>\n </div>\n </div>\n \n <div style="margin-top: 10px;">\n <div class="separator"></div>\n <s-button style="float: right;" [label]="\'save\' | translate" priority="primary" (onClick)="save()"\n [disabled]="!permissions.editar"></s-button>\n <s-button style="float: right;" [label]="\'cancel\' | translate" priority="link" (onClick)="close()"></s-button>\n </div>\n</form>'}),B("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,Jt,o.TranslateService,C.FormBuilder,F.ActivatedRoute])],e)}(),ya=function(){function e(e,t,a){this.http=t,this.messageService=a,this.baseUrl=e.project.domain+"/"+e.project.service}return e.prototype.pesquisarDocumento=function(e){return this.http.post(this.baseUrl+"/queries/pesquisarDocumento",e).pipe(this.defaultCatch())},e.prototype.pesquisarDocumentoValidaNotaEmUso=function(e){return this.http.post(this.baseUrl+"/queries/pesquisarDocumentoValidaNotaEmUso",e).pipe(this.defaultCatch())},e.prototype.pesquisarDocumentoGenerico=function(e){return this.http.post("yms/integration/queries/pesquisarDocumentoGenerico",e).pipe(this.defaultCatch())},e.prototype.executarAuditoria=function(e){return this.http.post(this.baseUrl+"/actions/executarAuditoria",e).pipe(this.defaultCatch())},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e=V([r.Injectable(),U(0,r.Inject(Lt)),B("design:paramtypes",[Object,d.HttpClient,c.MessageService])],e)}(),ba=function(){function e(e,a,i,r,o,n){var s=this;this.notaValidatorService=a,this.dialogConfig=i,this.confirmationService=r,this.dialogRef=o,this.verificaNotaFiscal=n,this.loading=!1,this.botaoDesabilitado=!1,this.disabled=!0,this.unsubscribe$=new t.Subject,this.validateNotaFiscal=function(e){if(0!==s.formGroup.get("chaveNotaFiscal").value.length&&(s.disabled=!1,e&&e.documentos[0])){var t=e.documentos[0];if(s.validaProdutoNaNotaFiscal(t.itens)){var a={chave:s.formGroup.get("chaveNotaFiscal").value,serie:t.serie,serieLegal:t.serieLegal,numero:t.numero};s.fornecedor?(t.fornecedor||{id:undefined}).id&&t.fornecedor.id!==s.fornecedor.id?s.confirmAndAddNovoFornecedor(a,t.fornecedor,t.origemMercadoria):(s.formGroup.get("serieNotaFiscal").setValue(t.serie),s.formGroup.get("serieLegalNotaFiscal").setValue(t.serieLegal),s.formGroup.get("numeroNotaFiscal").setValue(t.numero),s.desabilitaCamposNotaFiscal()):s.closeAndReturnNota(a,t.fornecedor,t.origemMercadoria)}}},this.camposPreenchidosValidation=function(e){var t=e.get("chaveNotaFiscal").value,a=e.get("serieNotaFiscal").value,i=e.get("numeroNotaFiscal").value;return t||a||i?null:{erroMultiplosCampos:!0}},this.formGroup=e.group({chaveNotaFiscal:[undefined,C.Validators.required],serieNotaFiscal:[undefined,C.Validators.required],serieLegalNotaFiscal:[undefined,C.Validators.required],numeroNotaFiscal:[undefined,C.Validators.required]},{validators:this.camposPreenchidosValidation})}return e.prototype.ngOnInit=function(){this.filialId=this.dialogConfig.data.filial.id,this.fornecedor=this.dialogConfig.data.fornecedor,this.produto=this.dialogConfig.data.produto,this.fornecedorNotasTokens=this.dialogConfig.data.fornecedorNotasTokens,this.contratos=this.dialogConfig.data.contratos},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.save=function(){var e=this.formGroup.get("chaveNotaFiscal").value;if(!this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(e,this.contratos,this.fornecedorNotasTokens)){if(e||this.removeErrorChaveNota(),!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);this.habilitaCamposNotaFiscal(),this.close(this.formGroup.value)}},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.onBlurNotaFiscal=function(){var e=this,i=this.formGroup.get("chaveNotaFiscal").value;this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(i,this.contratos,this.fornecedorNotasTokens)?this.botaoDesabilitado=!0:(this.removeErrorChaveNota(),this.loading=!0,this.notaValidatorService.pesquisarDocumentoValidaNotaEmUso({chaveDocumento:(i||"").replace(/\s/g,""),filialId:this.filialId}).pipe(a.takeUntil(this.unsubscribe$),a.catchError(function(){return e.disabled=!1,t.of(null)}),a.finalize(function(){return e.loading=!1})).subscribe(this.validateNotaFiscal),this.botaoDesabilitado=!1)},e.prototype.validaProdutoNaNotaFiscal=function(e){if(null!=e&&e.length>0){var t=e[0].produto;if(t&&this.produto&&t.id!==this.produto.id)return this.addErrorIfProdutoIsDifferent(),!1}return!0},e.prototype.confirmAndAddNovoFornecedor=function(e,t,a){var i=this;this.confirmationService.confirm({header:"O fornecedor vinculado a nota não é o mesmo que o selecionado",message:"O fornecedor vinculado a nota não é o mesmo que o selecionado. Deseja adicionar um novo fornecedor ou cancelar a operação?",acceptLabel:"Adicionar um novo fornecedor",rejectLabel:"Cancelar operação",accept:function(){return i.closeAndReturnNota(e,t,a)},reject:function(){return i.formGroup.get("chaveNotaFiscal").setValue(undefined)}})},e.prototype.addErrorIfProdutoIsDifferent=function(){this.formGroup.get("chaveNotaFiscal").setErrors({errorChaveNota:!0})},e.prototype.removeErrorChaveNota=function(){this.formGroup.get("chaveNotaFiscal").setErrors(null)},e.prototype.closeAndReturnNota=function(e,t,a){this.dialogRef.close({addFornecedor:!0,infoNota:e,fornecedor:t,origemMercadoria:a})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup&&t.validateAllFormFields(i)}),e.markAsDirty({onlySelf:!0})},e.prototype.habilitaCamposNotaFiscal=function(){this.formGroup.get("serieNotaFiscal").enable(),this.formGroup.get("serieLegalNotaFiscal").enable(),this.formGroup.get("numeroNotaFiscal").enable()},e.prototype.desabilitaCamposNotaFiscal=function(){this.formGroup.get("serieNotaFiscal").disable(),this.formGroup.get("serieLegalNotaFiscal").disable(),this.formGroup.get("numeroNotaFiscal").disable()},e=V([r.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid" *sLoadingState="loading">\n <div class="ui-g-12 required">\n <label for="chaveNotaFiscal">{{\'yms.erp.recebimento_chave_nota_fiscal\' | translate}}</label>\n <input\n id="chaveNotaFiscal"\n trim\n pInputText\n type="text"\n formControlName="chaveNotaFiscal"\n (blur)="onBlurNotaFiscal()"\n >\n <s-control-errors\n [control]="formGroup.controls.chaveNotaFiscal"\n [errorMessages]="{ errorChaveNota: \'yms.erp.produto_nota_error_detail\' | translate }">\n </s-control-errors>\n </div>\n <div class="ui-g-12 required" [attr.data-hidden]="disabled">\n <label for="serieNotaFiscal">{{\'yms.erp.recebimento_serie_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" formControlName="serieNotaFiscal">\n <s-control-errors\n [control]="formGroup.controls[\'serieNotaFiscal\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }">\n </s-control-errors>\n </div>\n <div class="ui-g-12 required" [attr.data-hidden]="disabled">\n <label for="serieLegalNotaFiscal">{{\'yms.erp.recebimento_serie_legal_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" formControlName="serieLegalNotaFiscal">\n <s-control-errors\n [control]="formGroup.controls[\'serieLegalNotaFiscal\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }">\n </s-control-errors>\n </div>\n <div class="ui-g-12 required" [attr.data-hidden]="disabled">\n <label for="numeroNotaFiscal">{{\'yms.erp.recebimento_numero_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" formControlName="numeroNotaFiscal">\n <s-control-errors\n [control]="formGroup.controls[\'numeroNotaFiscal\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }">\n </s-control-errors>\n </div>\n </div>\n\n <s-control-errors [control]="formGroup" [errorMessages]="{ erroMultiplosCampos: \'yms.erp.nota_fiscal_no_value\' | translate }"></s-control-errors>\n\n <s-button label="Cancelar" (onClick)="close()" priority="link"></s-button>\n <s-button label="Salvar" [disabled]="botaoDesabilitado || disabled" (onClick)="save()"></s-button>\n</form>\n\n<p-confirmDialog appendTo="body"></p-confirmDialog>',providers:[c.ConfirmationService]}),B("design:paramtypes",[C.FormBuilder,ya,c.DynamicDialogConfig,c.ConfirmationService,c.DynamicDialogRef,Wt])],e)}(),Fa=function(){function e(e){this.elementRef=e}return e.prototype.onBlur=function(){var e=this.elementRef.nativeElement.value;e&&(this.elementRef.nativeElement.value=e.replace(/\s/g,""))},V([r.HostListener("blur"),B("design:type",Function),B("design:paramtypes",[]),B("design:returntype",void 0)],e.prototype,"onBlur",null),e=V([r.Directive({selector:"[trim]"}),B("design:paramtypes",[r.ElementRef])],e)}(),Sa=function(){function e(){}return e=V([r.NgModule({imports:[i.CommonModule],declarations:[Fa],exports:[Fa]})],e)}(),Da=function(){function e(){}return e=V([r.NgModule({imports:[i.CommonModule,C.ReactiveFormsModule,v.DynamicDialogModule,D.InputTextModule,n.ButtonModule,n.ControlErrorsModule,o.TranslateModule,n.LoadingStateModule,E.ConfirmDialogModule,Sa],declarations:[ba],entryComponents:[ba]})],e)}(),Ca=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/agenda/entities/agenda"}])],providers:[qt],declarations:[],exports:[]})],e)}(),_a=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/cidade",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),Ia=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"cidade",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/cidade"}])],providers:[_a],declarations:[],exports:[]})],e)}(),Ta=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/contratoCompraItem",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.environment=i,r}return P(t,e),t.prototype.pesquisarItensContratoCompra=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarItensContratoCompra",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),ka=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"contratoCompraItem",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/contratoCompraItem"}])],providers:[Ta],declarations:[],exports:[]})],e)}(),Ma=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/contratoCompra",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.environment=i,r}return P(t,e),t.prototype.listContratosCompra=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarContratosCompra",e).pipe(this.defaultCatch())},t.prototype.getItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t.prototype.updateItens=function(e,t,a){return this.http.put(this.entityUrl+"/"+e+"/itens/"+t,a).pipe(this.defaultCatch())},t.prototype.listItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.insertItens=function(e,t){return this.http.post(this.entityUrl+"/"+e+"/itens",t).pipe(this.defaultCatch())},t.prototype.deleteItens=function(e,t){return this.http["delete"](this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),Ra=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"contratoCompra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/contratoCompra"}])],providers:[Ma],declarations:[],exports:[]})],e)}(),Ea=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/derivacao",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),Na=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"derivacao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/derivacao"}])],providers:[Ea],declarations:[],exports:[]})],e)}(),Aa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/empresa",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),wa=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"empresa",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/empresa"}])],providers:[Aa],declarations:[],exports:[]})],e)}(),Ga=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/estado",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),Oa=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"estado",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/estado"}])],providers:[Ga],declarations:[],exports:[]})],e)}(),xa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/familiaProduto",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),La=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"familiaProduto",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/familiaProduto"}])],providers:[xa],declarations:[],exports:[]})],e)}(),qa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/filial",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.baseUrl=i.project.domain+"/"+i.project.service+"/",r}return P(t,e),t.prototype.listFiliais=function(e){return this.http.post(this.baseUrl+"queries/pesquisarFiliais",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),Pa=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"filial",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/filial"}])],providers:[qa],declarations:[],exports:[]})],e)}(),ja=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pais",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),Va=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pais",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pais"}])],providers:[ja],declarations:[],exports:[]})],e)}(),Ua=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pedidoVendaItem",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.queriesUrl=i.project.domain+"/"+i.project.service+"/queries",r}return P(t,e),t.prototype.pesquisarItensPedidoVenda=function(e){return this.http.post(this.queriesUrl+"/pesquisarItensPedidoVenda",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),Ba=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pedidoVendaItem",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pedidoVendaItem"}])],providers:[Ua],declarations:[],exports:[]})],e)}(),za=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pedidoVenda",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.queriesUrl=i.project.domain+"/"+i.project.service+"/queries",r}return P(t,e),t.prototype.getItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t.prototype.pesquisarPedidosVenda=function(e){return this.http.post(this.queriesUrl+"/pesquisarPedidosVenda",e).pipe(this.defaultCatch())},t.prototype.updateItens=function(e,t,a){return this.http.put(this.entityUrl+"/"+e+"/itens/"+t,a).pipe(this.defaultCatch())},t.prototype.listItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.insertItens=function(e,t){return this.http.post(this.entityUrl+"/"+e+"/itens",t).pipe(this.defaultCatch())},t.prototype.deleteItens=function(e,t){return this.http["delete"](this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),$a=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pedidoVenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pedidoVenda"}])],providers:[za],declarations:[],exports:[]})],e)}(),Ha=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pessoaEndereco",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),Ya=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoaEndereco",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pessoaEndereco"}])],providers:[Ha],declarations:[],exports:[]})],e)}(),Qa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pessoaFisica",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),Ka=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoaFisica",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pessoaFisica"}])],providers:[Qa],declarations:[],exports:[]})],e)}(),Wa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pessoaJuridica",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),Ja=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoaJuridica",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pessoaJuridica"}])],providers:[Wa],declarations:[],exports:[]})],e)}(),Xa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pessoa",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),Za=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoa",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pessoa"}])],providers:[Xa],declarations:[],exports:[]})],e)}(),ei=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/produto",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.environment=i,r}return P(t,e),t.prototype.listProdutosRecebimento=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarProdutoRecebimento",e).pipe(this.defaultCatch())},t.prototype.listProdutos=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarProduto",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),ti=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"produto",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/produto"}])],providers:[ei],declarations:[],exports:[]})],e)}(),ai=function(){function e(){this.messageSource=new t.BehaviorSubject({id:null,change:!1}),this.current=this.messageSource.asObservable()}return e.prototype.hasChange=function(e){var t={id:e,change:!0};this.messageSource.next(t)},e.prototype.hasChangeSave=function(e){var t={id:e,change:!1};this.messageSource.next(t)},Object.defineProperty(e.prototype,"change",{get:function(){return this.messageSource.value},enumerable:!0,configurable:!0}),e=V([r.Injectable(),B("design:paramtypes",[])],e)}(),ii=function(){return function(){}}(),ri=function(){function e(){this.messageSource=new t.BehaviorSubject(undefined),this.current=this.messageSource.asObservable()}return e.prototype.changeData=function(e){return this.messageSource.next(e),e},e.prototype.getProcessData=function(){return this.messageSource.value},e.prototype.changeDataErp=function(e){var t=this.messageSource.value?this.messageSource.value:e;return t.filialId=e.filialId,t.chaveIntegracao=e.chaveIntegracao,t.produtoId=e.produtoId,t.transgeniaId=e.transgeniaId,t.transportadoraId=e.transportadoraId,this.changeData(t)},e.prototype.changeDataVeiculo=function(e,t){var a=this.messageSource.value?this.messageSource.value:new ii;return a.veiculoId=e,a.eixos=t,this.changeData(a)},e.prototype.changeDataMotorista=function(e){var t=this.messageSource.value?this.messageSource.value:new ii;return t.motoristaId=e,this.changeData(t)},e.prototype.changeDataAgenda=function(e,t,a,i){var r=this.messageSource.value?this.messageSource.value:new ii;return r.agendaId=e,r.motoristaId=t,r.veiculoId=a,r.eixos=i,this.changeData(r)},e.prototype.builderErpProcessData=function(e,t){return e.chaveIntegracao=null!=t.get("chaveNotaFiscal")?t.get("chaveNotaFiscal").value:null,e.filialId=this.getFieldFormGroup(t,"filial"),e.produtoId=this.getFieldFormGroup(t,"produto"),e.transgeniaId=this.getFieldFormGroup(t,"transgenia"),e.transportadoraId=this.getFieldFormGroup(t,"transportadora"),e.fornecedores=this.listarIdsFornecedores(t.getRawValue().fornecedores),e},e.prototype.builderErpProcessDataValidaNotaNoContrato=function(e,t){return(e=this.builderErpProcessData(e,t)).recebimentoTemNota=this.verificaSeTemNotaNoContratoNoFornecedo(t.getRawValue().fornecedores),e},e.prototype.verificaSeTemNotaNoContratoNoFornecedo=function(e){var t=this,a=!1,i=[];null!=e&&e.filter(function(e){return null!=e.contratos&&e.contratos!=undefined}).forEach(function(e){return i.push(e.contratos)});var r=[];return null!=i&&i.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return r.push(a=t.verificaSeContratosTemNota(e))}),a},e.prototype.verificaSeContratosTemNota=function(e){var t=!0;return e.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return t=t&&e.notas.length>0}),t},e.prototype.builderErpProcessDataValidaNotaNaOrdemCompra=function(e,t){return(e=this.builderErpProcessData(e,t)).recebimentoTemNota=this.verificaSeTemNotaNaOrdemCompraDoFornecedo(t.getRawValue().fornecedores),e},e.prototype.verificaSeTemNotaNaOrdemCompraDoFornecedo=function(e){var t=this,a=!1,i=[];null!=e&&e.filter(function(e){return null!=e.ordens&&e.ordens!=undefined}).forEach(function(e){return i.push(e.ordens)});var r=[];return null!=i&&i.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return r.push(a=t.verificaSeOrdemCompraTemNota(e))}),a},e.prototype.verificaSeOrdemCompraTemNota=function(e){var t=!0;return e.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return t=t&&e.notas.length>0}),t},e.prototype.getFieldFormGroup=function(e,t){return null==e.get(t)||null==e.get(t).value?null:e.get(t).value.id},e.prototype.listarIdsFornecedores=function(e){var t=[];return null!=e&&e.filter(function(e){return null!=e.fornecedor&&e.fornecedor!=undefined}).forEach(function(e){return t.push(e.fornecedor)}),t.map(function(e){return e.id})},e=V([r.Injectable(),B("design:paramtypes",[])],e)}(),oi=function(){function e(){this.messageSource=new t.BehaviorSubject(!1),this.current=this.messageSource.asObservable()}return e.prototype.enableRevalidation=function(){this.messageSource.next(!0)},Object.defineProperty(e.prototype,"enable",{get:function(){return this.messageSource.value},enumerable:!0,configurable:!0}),e=V([r.Injectable(),B("design:paramtypes",[])],e)}(),ni=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"recebimentoContrato",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/recebimentoContrato"},{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/agenda/entities/agenda"}])],providers:[Pt,ri,oi,ai],declarations:[],exports:[]})],e)}(),si=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/royalty",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),li=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"royalty",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/royalty"}])],providers:[si],declarations:[],exports:[]})],e)}(),di=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/safra",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),ci=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"safra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/safra"}])],providers:[di],declarations:[],exports:[]})],e)}(),pi=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/transportadora",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),ui=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"transportadora",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/transportadora"}])],providers:[pi],declarations:[],exports:[]})],e)}(),mi=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/unidadeMedida",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),fi=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"unidadeMedida",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/unidadeMedida"}])],providers:[mi],declarations:[],exports:[]})],e)}(),hi=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"expedicao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/expedicao"}])],providers:[Vt]})],e)}(),gi=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/devolucao",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r._baseUrl=i.project.domain+"/"+i.project.service,r}return P(t,e),t.prototype.registrarChegadaVeiculoComDevolucao=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComDevolucao",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),vi=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"devolucao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/devolucao"}])],providers:[gi,ri,oi],declarations:[],exports:[]})],e)}(),yi=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"ordemCompra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/ordem-compra"},{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/agenda/entities/agenda"}])],providers:[Jt],declarations:[],exports:[]})],e)}(),bi=function(){function e(e){this.translate=e}return e.prototype.buildForString=function(e,t){return this.build(e,t,n.FieldType.String)},e.prototype.buildForInteger=function(e,t){return this.build(e,t,n.FieldType.Integer)},e.prototype.build=function(e,t,a){return new n.FormField({label:this.translate.instant(t),name:e,type:a})},e=V([r.Injectable(),B("design:paramtypes",[o.TranslateService])],e)}(),Fi=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/recebimentoOrdemCompra",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r._baseUrl=i.project.domain+"/"+i.project.service,r}return P(t,e),t.prototype.registrarChegadaVeiculoRecebimentoOrdemCompra=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComRecebimentoOrdemCompra",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),Si=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"recebimentoOrdemCompra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/recebimentoOrdemCompra"},{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/agenda/entities/agenda"}])],providers:[Fi,ri,oi,bi],declarations:[],exports:[]})],e)}(),Di=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/transgenia",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,c.MessageService,Object])],t)}(Ct),Ci=function(){function e(){}return e=V([r.NgModule({providers:[Di]})],e)}(),_i=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/processoAvulso",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t.prototype.registrarChegada=function(e){return this.http.post(this.actionsUrl+"/registrarChegadaDeVeiculoComProcessoAvulso",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,c.MessageService,Object])],t)}(Ct),Ii=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"processoAvulso",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/processoAvulso"},{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/agenda/entities/agenda"}])],providers:[_i,ri,oi]})],e)}(),Ti=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/erp/entities/logIntegracao",i.project.domain+"/erp/actions")||this;return r.http=t,r.messageService=a,r.environment=i,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ct),ki=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"logIntegracao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/logIntegracao"}])],providers:[Ti],declarations:[],exports:[]})],e)}(),Mi=function(){function e(){}return e=V([r.NgModule({imports:[wa,Za,Ka,Ja,Va,Oa,Ia,Ya,Pa,ui,ti,fi,li,La,ci,$a,Ba,Ra,ka,ni,Ca,Na,hi,vi,yi,Si,Ci,m.PermissionsModule,Ii,ki],providers:[Bt,ya],exports:[]})],e)}(),Ri=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.devolucaoService=a,this.DEVOLUCAO_KEY="ERP_SENIOR_DEVOLUCAO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.DEVOLUCAO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.DEVOLUCAO_KEY)},e.prototype.functionToOverride=function(e){var i=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return i.devolucaoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?i.devolucaoService.registrarChegadaVeiculoComDevolucao({devolucao:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Não foi possível encontrar os dados de devolução")}))},e=V([r.Injectable(),B("design:paramtypes",[p.ChegadaVeiculoOverride,qt,gi])],e)}(),Ei=_,Ni=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Ei(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Ei(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","quantidadeDecimais","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Ei(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Ei(a.lastModifiedDate).format(),delete a.label,a},e}(),Ai=_,wi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Ai(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Ai(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"Royalty")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Ai(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Ai(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"Royalty")),a},e}(),Gi=_,Oi=function(){function e(){}return e.fromDto=function(e,t){if(e.id===undefined)return e;var a=j({},e);a.createdDate=a.codigo&&Gi(a.createdDate).toDate(),a.createdDate=a.createdDate&&Gi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Gi(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","situacao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"FamiliaProduto")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Gi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Gi(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"FamiliaProduto")),a},e}(),xi=_,Li=function(){function e(){this.produtoMisto=!1,this.comprado=!1}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&xi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&xi(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedida&&(a.unidadeMedida=Ni.fromDto(a.unidadeMedida,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedidaAgroG5&&(a.unidadeMedidaAgroG5=Ni.fromDto(a.unidadeMedidaAgroG5,"Produto")),"Royalty"!==t&&a.royalty&&(a.royalty=wi.fromDto(a.royalty,"Produto")),"FamiliaProduto"!==t&&a.familia&&(a.familia=Oi.fromDto(a.familia,"Produto")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&xi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&xi(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedida&&(a.unidadeMedida=Ni.toDto(a.unidadeMedida,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedidaAgroG5&&(a.unidadeMedidaAgroG5=Ni.toDto(a.unidadeMedidaAgroG5,"Produto")),"Royalty"!==t&&a.royalty&&(a.royalty=wi.toDto(a.royalty,"Produto")),"FamiliaProduto"!==t&&a.familia&&(a.familia=Oi.toDto(a.familia,"Produto")),a},e}(),qi=_,Pi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&qi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&qi(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"Derivacao")),"Produto"!==t&&a.produto&&(a.produto=Li.fromDto(a.produto,"Derivacao")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&qi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&qi(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"Derivacao")),"Produto"!==t&&a.produto&&(a.produto=Li.toDto(a.produto,"Derivacao")),a},e}(),ji=_,Vi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&ji(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ji(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","pessoa.nome","pessoa.cpfCnpj"]," - "),"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.fromDto(a.pessoa,"Transportadora")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=pa.fromDto(a.endereco,"Transportadora")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&ji(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ji(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.toDto(a.pessoa,"Transportadora")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=pa.toDto(a.endereco,"Transportadora")),a},e}(),Ui=_,Bi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Ui(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Ui(a.lastModifiedDate).toDate();return a.label=[""].map(function(e){return a[e]}).join(" - "),"Pessoa"!==t&&a.fornecedor&&(a.fornecedor=ta.fromDto(a.fornecedor,"Devolucao")),"Filial"!==t&&a.filial&&(a.filial=ma.fromDto(a.filial,"Devolucao")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.fromDto(a.transportadora,"Devolucao")),"Produto"!==t&&a.produto&&(a.produto=Li.fromDto(a.produto,"Devolucao")),"Agenda"!==t&&a.agenda&&(a.agenda=qe.fromDto(a.agenda,"Devolucao")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=pa.fromDto(a.origemMercadoria,"Recebimento")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=Pi.fromDto(a.derivacao,"Devolucao")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Ui(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Ui(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.fornecedor&&(a.fornecedor=ta.toDto(a.fornecedor,"Devolucao")),"Filial"!==t&&a.filial&&(a.filial=ma.toDto(a.filial,"Devolucao")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.toDto(a.transportadora,"Devolucao")),"Produto"!==t&&a.produto&&(a.produto=Li.toDto(a.produto,"Devolucao")),"Agenda"!==t&&a.agenda&&(a.agenda=qe.toDto(a.agenda,"Devolucao")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=pa.toDto(a.origemMercadoria,"Devolucao")),a},e}();!function(e){e.AGUARDANDO_CONFIRMACAO="AGUARDANDO_CONFIRMACAO_SOLICITANTE",e.AGENDADO="AGENDADO",e.AGUARDANDO_CONFIRMACAO_SOLICITANTE="AGUARDANDO_CONFIRMACAO",e.REJEITADO_POR_VALIDACAO="REJEITADO_POR_VALIDACAO",e.CANCELADO="CANCELADO"}(St||(St={}));var zi,$i,Hi=function(){function e(e,a,i,r,o,n,s,l,d,c,p,u,m,f,h,g,v,y){this.fb=e,this.router=a,this.translate=i,this.filialService=r,this.pessoaService=o,this.produtoService=n,this.derivacaoService=s,this.origemMercadoriaService=l,this.transportadoraService=d,this.devolucaoService=c,this.messageService=p,this.route=u,this.override=m,this.confirmationService=f,this.agendaService=h,this.erpProcessService=g,this.erpFormConfigService=v,this.hasChangeService=y,this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.fornecedorLookupDisplayFields=["codigo","nome"],this.fornecedorAdvancedDisplayFields=["id","codigo","nome"],this.fornecedorLookupSeparator=" - ",this.produtoLookupDisplayFields=["codigo","descricao"],this.produtoAdvancedDisplayFields=["id","codigo","descricao"],this.produtoLookupSeparator=" - ",this.derivacaoLookupDisplayFields=["codigo","descricao"],this.derivacaoAdvancedDisplayFields=["id","codigo","descricao"],this.derivacaoLookupSeparator=" - ",this.origemMercadoriaLookupDisplayFields=["codigo","endereco"],this.origemMercadoriaAdvancedDisplayFields=["id","codigo","endereco","numero"],this.origemMercadoriaLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.disableButtonSave=!1,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.permissions={},this.ngUnsubscribe=new t.Subject,this.formGroup=this.getFormGroup()}return e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.override.remove()},e.prototype.ngAfterViewInit=function(){var e=this;this.override.initialize(),this.saveAndInitButton=document.getElementById("init"),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)});(this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)||!this.permissions.editar)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.createdByErpDisableForm()},e.prototype.ngOnInit=function(){var e=this;this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.fornecedorSearchFields=this.getFornecedorSearchFields(),this.produtoSearchFields=this.getProdutoSearchFields(),this.derivacaoSearchFields=this.getDerivacaoSearchFields(),this.origemMercadoriaSearchFields=this.getOrigemMercadoriaSearchFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;"new"!=a&&e.getDevolucao(a)}),this.getEmpresaFilial(),this.filialValueChanges();this.checkValuesChanges("produto","derivacao",this.derivacaoService,function(e){return"produto.id eq '"+e.id+"' and situacao eq 'ATIVO'"},["codigo","descricao"],10,!0,!0);this.checkValuesChanges("fornecedor","origemMercadoria",this.origemMercadoriaService,function(e){return"pessoa.id eq '"+e.id+"'"},["codigo","endereco"],10,!1,!0),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0,this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)})},e.prototype.onRouteDataChange=function(e){this.permissions=e.allPermissions.agenda},e.prototype.createdByErpDisableForm=function(){this.agenda&&this.agenda.createdByErp&&(this.formGroup.get("filial").disable(),this.formGroup.get("fornecedor").disable(),this.formGroup.get("produto").disable(),this.formGroup.get("derivacao").disable(),this.formGroup.get("origemMercadoria").disable(),this.formGroup.get("transportadora").disable(),this.formGroup.get("contratos").disable())},e.prototype.getEmpresaFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length&&this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&e.formGroup.get("filial").setValue(ma.fromDto(a[0]))})},e.prototype.filialValueChanges=function(){var e=this;this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){if(t)return e.formGroup.get("produto").enable();e.formGroup.get("produto").setValue(undefined),e.formGroup.get("produto").disable()})},e.prototype.checkValuesChanges=function(e,t,i,r,o,n,s,l){var d=this;void 0===n&&(n=1),this.formGroup.get(e).valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return s&&d.formGroup.get(t).setValidators(e?C.Validators.required:C.Validators.nullValidator),l&&d.formGroup.get(t).setValue(null),!!e||(d.formGroup.get(t).setValue(undefined),d.formGroup.get(t).disable(),!1)}),a.mergeMap(function(e){var t=r(e);return i.list({filterQuery:t,page:0,size:n})})).subscribe(function(e){var a=e.contents;if(a.length){if(1===a.length){var i=a[0][o[0]]?a[0][o[0]].toString():"",r=a[0][o[1]]?a[0][o[1]].toString():"";r.trim()||i.trim()?a[0].label=i+" - "+r:a[0].label=d.translate.instant("yms.erp.derivacao_sem_descricao"),d.formGroup.get(t).setValue(a[0])}a.length>1?d.formGroup.get(t).enable():d.formGroup.get(t).disable()}else d.formGroup.get(t).enable()})},e.prototype.getDevolucao=function(e){var t=this;this.devolucaoService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(a.length){t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var i=Bi.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(i)}}),this.formCarregado=!0},e.prototype.onFilialLookupRequest=function(e){var t=this,i=this.getFilialSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).reduce(function(t,a){var i,r,o=a.name;return a.type===n.FieldType.Integer?j({},t,((i={})[o]=e.replace(/\D/,""),i)):j({},t,((r={})[o]=e,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(i).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return ma.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(ma.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onFornecedorLookupRequest=function(e){var t=this;Oe(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.fornecedorLookupSuggestions=e.contents})},e.prototype.onFornecedorSearchRequest=function(e){var t=this;xe(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.fornecedorSearchGridData=e.contents,t.fornecedorSearchTotalRecords=e.totalElements})},e.prototype.onProdutoLookupRequest=function(e){var t=this,i=this.formGroup.get("filial").value,r=this.agenda.tipoAgendamento;this.produtoService.listProdutos({pesquisa:e,empresaId:i?i.empresa.id:null,filialId:i?i.id:null,tipoAgendamentoId:r?r.id:null,situacao:"ATIVO",pagina:{limit:100,offset:0}}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.produtoLookupSuggestions=e.produtos.map(Li.fromDto)})},e.prototype.onProdutoSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getProdutoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}}),u=this.formGroup.get("filial").value,m=this.agenda.tipoAgendamento;this.produtoService.listProdutos(j({},p,{empresaId:u?u.empresa.id:null,filialId:u?u.id:null,situacao:"ATIVO",tipoAgendamentoId:m?m.id:null})).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoSearchTotalRecords=e.qtdTotalRegistros,t.produtoSearchGridData=e.produtos.map(Li.fromDto)})},e.prototype.onDerivacaoLookupRequest=function(e){var t=this;Oe(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoLookupSuggestions=e.contents})},e.prototype.onDerivacaoSearchRequest=function(e){var t=this;xe(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoSearchGridData=e.contents,t.derivacaoSearchTotalRecords=e.totalElements})},e.prototype.onOrigemMercadoriaLookupRequest=function(e){var t=this;Oe(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,e," pessoa.id eq '"+this.formGroup.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.origemMercadoriaLookupSuggestions=e.contents})},e.prototype.onOrigemMercadoriaSearchRequest=function(e){var t=this;xe(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,e," pessoa.id eq '"+this.formGroup.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.origemMercadoriaSearchGridData=e.contents,t.origemMercadoriaSearchTotalRecords=e.totalElements})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Oe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this;xe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.setTransportadora=function(e){var t=this;if(e){var i="pessoa.cpfCnpj eq '"+e.replace(".","").replace("/","").replace("-","")+"'";this.transportadoraService.list({filterQuery:i,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(1===a.length){var i=a[0].codigo?a[0].codigo.toString():"",r=a[0].descricao?a[0].descricao.toString():"";r.trim()||i.trim()?a[0].label=i+" - "+r:a[0].label=t.translate.instant("yms.erp.derivacao_sem_descricao"),t.formGroup.get("transportadora").setValue(a[0])}})}},e.prototype.onSave=function(e){var t=this;return this.formGroup.get("agenda").setValue(this.agenda),this.formGroup.invalid&&this.validateAllFormFields(this.formGroup),this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessData(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)}))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=St.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.get("id").setValue(a.id||null),t.successMessage(),e&&t.saveAndInitButton&&(t.hasChangeService.hasChangeSave(t.agenda.id),t.saveAndInitButton.click())})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.getSaveObservable=function(){var e=this.formGroup.getRawValue(),t=Bi.toDto(e);return this.isNew()&&!e.id?this.devolucaoService.insert(t):this.devolucaoService.update(this.formGroup.value.id,t)},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.getFormGroup=function(){return this.fb.group({id:[undefined],filial:[undefined,C.Validators.required],fornecedor:[undefined,C.Validators.required],produto:[{value:undefined,disabled:!0},C.Validators.required],derivacao:[{value:undefined,disabled:!0},C.Validators.required],origemMercadoria:[{value:undefined,disabled:!0},C.Validators.required],transportadora:[undefined],agenda:[undefined,C.Validators.required],chaveNotaFiscal:[undefined],numeroNotaFiscal:[undefined],serieNotaFiscal:[undefined],numeroNotaFiscalProdutor:[undefined],serieNotaFiscalProdutor:[undefined]})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup&&t.validateAllFormFields(i)})},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")})]},e.prototype.getFornecedorSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_codigo")})]},e.prototype.getProdutoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_codigo")})]},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_codigo")})]},e.prototype.getOrigemMercadoriaSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_endereco_codigo")}),new n.FormField({name:"numero",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_numero")}),new n.FormField({name:"endereco",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_endereco")})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},V([r.Input(),B("design:type",qe)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"devolucao-form",template:'<p-confirmDialog [acceptLabel]="\'yes\' | translate" acceptIcon="" [rejectLabel]="\'no\' | translate" rejectIcon=""></p-confirmDialog>\n<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-fluid ui-g"> \n <div class="ui-md-6 ui-g-12 required">\n <label for="filial">{{\'yms.erp.devolucao_filial\' | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions"\n (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="fornecedor">{{\'yms.erp.devolucao_fornecedor\' | translate}}</label>\n <s-lookup dataKey="id" id="fornecedor" name="fornecedor" formControlName="fornecedor"\n [searchFields]="fornecedorSearchFields" [searchGridFields]="fornecedorSearchFields"\n [searchGridData]="fornecedorSearchGridData" [multiple]="false"\n [lookupSuggestions]="fornecedorLookupSuggestions"\n (onLookupRequest)="onFornecedorLookupRequest($event)"\n (onSearchRequest)="onFornecedorSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="fornecedorSearchTotalRecords"\n [searchTitle]="\'yms.erp.fornecedor_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: fornecedorSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'fornecedor\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="produto">{{\'yms.erp.devolucao_produto\' | translate}}</label>\n <s-lookup dataKey="id" id="produto" name="produto" formControlName="produto"\n [searchFields]="produtoSearchFields" [searchGridFields]="produtoSearchFields"\n [searchGridData]="produtoSearchGridData" [multiple]="false"\n [lookupSuggestions]="produtoLookupSuggestions"\n (onLookupRequest)="onProdutoLookupRequest($event)"\n (onSearchRequest)="onProdutoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="produtoSearchTotalRecords"\n [searchTitle]="\'yms.erp.produto_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: produtoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'produto\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div> \n \n <div class="ui-md-6 ui-g-12" [ngClass]="{\'required\': formGroup.get(\'produto\').value}">\n <label for="derivacao">{{\'yms.erp.devolucao_derivacao\' | translate}}</label>\n <s-lookup dataKey="id" id="derivacao" name="derivacao" formControlName="derivacao"\n [searchFields]="derivacaoSearchFields" [searchGridFields]="derivacaoSearchFields"\n [searchGridData]="derivacaoSearchGridData" [multiple]="false"\n [lookupSuggestions]="derivacaoLookupSuggestions"\n (onLookupRequest)="onDerivacaoLookupRequest($event)"\n (onSearchRequest)="onDerivacaoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="derivacaoSearchTotalRecords"\n [searchTitle]="\'yms.erp.derivacao_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: derivacaoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'derivacao\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="origemMercadoria">{{\'yms.erp.devolucao_origem_mercadoria\' | translate}}</label>\n <s-lookup dataKey="id" id="origemMercadoria" name="origemMercadoria" formControlName="origemMercadoria"\n [searchFields]="origemMercadoriaSearchFields" [searchGridFields]="origemMercadoriaSearchFields"\n [searchGridData]="origemMercadoriaSearchGridData" [multiple]="false"\n [lookupSuggestions]="origemMercadoriaLookupSuggestions"\n (onLookupRequest)="onOrigemMercadoriaLookupRequest($event)"\n (onSearchRequest)="onOrigemMercadoriaSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="origemMercadoriaSearchTotalRecords"\n [searchTitle]="\'yms.erp.origem_mercadoria_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: origemMercadoriaSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'origemMercadoria\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n \n <div class="ui-md-6 ui-g-12">\n <label for="transportadora">{{\'yms.erp.devolucao_transportadora\' | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="chaveNotaFiscal">{{\'yms.erp.devolucao_chave_nota_fiscal\' | translate}}</label>\n <input type="text" id="chaveNotaFiscal" name="chaveNotaFiscal" pInputText formControlName="chaveNotaFiscal"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="numeroNotaFiscal">{{\'yms.erp.devolucao_numero_nota_fiscal\' | translate}}</label>\n <input type="text" id="numeroNotaFiscal" name="numeroNotaFiscal" pInputText formControlName="numeroNotaFiscal"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="serieNotaFiscal">{{\'yms.erp.devolucao_serie_nota_fiscal\' | translate}}</label>\n <input type="text" id="serieNotaFiscal" name="serieNotaFiscal" pInputText formControlName="serieNotaFiscal"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="numeroNotaFiscalProdutor">{{\'yms.erp.devolucao_numero_nota_fiscal_produtor\' | translate}}</label>\n <input type="text" id="numeroNotaFiscalProdutor" name="numeroNotaFiscalProdutor" pInputText formControlName="numeroNotaFiscalProdutor"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="serieNotaFiscalProdutor">{{\'yms.erp.devolucao_serie_nota_fiscal_produtor\' | translate}}</label>\n <input type="text" id="serieNotaFiscalProdutor" name="serieNotaFiscalProdutor" pInputText formControlName="serieNotaFiscalProdutor"> \n </div>\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">{{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} / </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">{{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}</label>\n </div>\n </div>\n </form>\n \n <div style="margin: 5px 0 5px 0;">\n <s-button priority="primary" [label]="\'save\' | translate" (onClick)="onSave()" [disabled]="loading || disableButtonSave"></s-button>\n <s-button *ngIf="saveAndInitButton" priority="primary" [label]="\'save_and_init\' | translate" (onClick)="onSave(true)" [disabled]="disableButtonSave"></s-button>\n </div>\n</div>\n'}),B("design:paramtypes",[C.FormBuilder,F.Router,o.TranslateService,qa,Xa,ei,Ea,Ha,pi,gi,c.MessageService,F.ActivatedRoute,Ri,c.ConfirmationService,qt,ri,oi,ai])],e)}(),Yi=function(){function e(e){this.devolucaoService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.devolucaoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Devolução não encontrado.")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.devolucao=Bi.fromDto(t)})},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"devolucao-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_fornecedor\' | translate}}</span>\n <span class="data">{{devolucao?.fornecedor?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_transportadora\' | translate}}</span>\n <span class="data">{{devolucao?.transportadora?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_produto\' | translate}}</span>\n <span class="data">{{devolucao?.produto?.descricao}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_derivacao\' | translate}}</span>\n <span class="data">{{devolucao?.derivacao?.descricao}}</span>\n </div>\n \n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_chave_nota_fiscal\' | translate}}</span>\n <span class="data">{{devolucao?.chaveNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_numero_nota_fiscal\' | translate}}</span>\n <span class="data">{{devolucao?.numeroNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_serie_nota_fiscal\' | translate}}</span>\n <span class="data">{{devolucao?.serieNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_numero_nota_fiscal_produtor\' | translate}}</span>\n <span class="data">{{devolucao?.numeroNotaFiscalProdutor}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_serie_nota_fiscal_produtor\' | translate}}</span>\n <span class="data">{{devolucao?.serieNotaFiscalProdutor}}</span>\n </div> \n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_origem_mercadoria\' | translate}}</span>\n <span class="data">{{devolucao?.origemMercadoria?.cep}} - {{devolucao?.origemMercadoria?.endereco}}</span>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),B("design:paramtypes",[gi])],e)}(),Qi=_,Ki=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Qi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Qi(a.lastModifiedDate).toDate();return a.label=["id","clienteFaturamento.id","clienteFaturamento.codigo","clienteFaturamento.nome","clienteRemessa.id","clienteRemessa.codigo","clienteRemessa.nome","filial.id","filial.codigo","filial.nome","transportadora.id","transportadora.codigo","transportadora.placaVeiculo","pedidoVenda.id","agenda.id","agenda.descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Pessoa"!==t&&a.clienteFaturamento&&(a.clienteFaturamento=ta.fromDto(a.clienteFaturamento,"Recebimento")),"Pessoa"!==t&&a.clienteRemessa&&(a.clienteRemessa=ta.fromDto(a.clienteRemessa,"Recebimento")),"Filial"!==t&&a.filial&&(a.filial=ma.fromDto(a.filial,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.fromDto(a.transportadora,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=qe.fromDto(a.agenda,"Recebimento")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Qi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Qi(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.clienteFaturamento&&(a.clienteFaturamento=ta.toDto(a.clienteFaturamento,"Recebimento")),"Pessoa"!==t&&a.clienteRemessa&&(a.clienteRemessa=ta.toDto(a.clienteRemessa,"Recebimento")),"Filial"!==t&&a.filial&&(a.filial=ma.toDto(a.filial,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.toDto(a.transportadora,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=qe.toDto(a.agenda,"Recebimento")),a},e}(),Wi=_,Ji=function(){function e(e,a,i,r,o,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F){this.expedicaoService=e,this.router=a,this.route=i,this.messageService=r,this.formBuilder=o,this.translate=n,this.hotkeysService=s,this.fieldCustomization=l,this.focusService=d,this.pessoaService=c,this.filialService=p,this.transportadoraService=u,this.pedidoVendaService=m,this.pedidoVendaItemService=f,this.agendaService=h,this.override=g,this.confirmationService=v,this.erpProcessService=y,this.erpFormConfigService=b,this.hasChangeService=F,this.localeConfig={},this.currencyLocaleOptions={},this.permissions={},this.allPermissions={},this.mainPanelCollapsed=!1,this.visibleDialog=!1,this.formCarregado=!1,this.clienteFaturamentoLookupDisplayFields=["codigo","nome","cpfCnpj"],this.clienteFaturamentoAdvancedDisplayFields=["id","codigo","nome"],this.clienteFaturamentoLookupSeparator=" - ",this.clienteRemessaLookupDisplayFields=["codigo","nome","cpfCnpj"],this.clienteRemessaAdvancedDisplayFields=["id","codigo","nome"],this.clienteRemessaLookupSeparator=" - ",this.filialLookupDisplayFields=["codigo","nome"],this.filialAdvancedDisplayFields=["id","codigo","nome"],this.filialLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.pedidoVendaLookupDisplayFields=["numero","cliente"],this.pedidoVendaAdvancedDisplayFields=["id","numero","filial.nome","filial.codigo","pessoa.id","pessoa.codigo","pessoa.nome"],this.pedidoVendaLookupSeparator=" - ",this.pedidoVendaItemLookupDisplayFields=["sequencia","sku.descricao"],this.pedidoVendaItemAdvancedDisplayFields=["id","sequencia","sku.descricao"],this.pedidoVendaItemLookupSeparator=" - ",this.agendaLookupDisplayFields=["id","descricao"],this.agendaAdvancedDisplayFields=["id","descricao"],this.agendaLookupSeparator=" - ",this.disableButtonSave=!1,this.disableOrdersButtons=!0,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.ordersValid=!0,this.ngUnsubscribe=new t.Subject,this.formGroup=this.getFormGroup(),this.pedidoVendaForm=this.getPedidoVendaForm(),this.itemFormGroup=this.getOrdemVendaItemForm()}return e.prototype.ngOnInit=function(){var e=this;this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)}),this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;"new"!=a?e.getExpedicao(a):e.buscarFilial()}),this.clienteFaturamentoSearchFields=this.getClienteSearchFields(),this.clienteFaturamentoSearchGridFields=this.getClienteSearchGridFields(),this.clienteRemessaSearchFields=this.getClienteSearchFields(),this.clienteRemessaSearchGridFields=this.getClienteSearchGridFields(),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.pedidoVendaSearchFields=this.getPedidoVendaSearchFields(),this.pedidoVendaSearchGridFields=this.getPedidoVendaSearchGridFields(),this.pedidoVendaItemSearchFields=this.getPedidoVendaItemSearchFields(),this.pedidoVendaItemSearchGridFields=this.getPedidoVendaItemSearchGridFields(),this.agendaSearchFields=this.getAgendaSearchFields(),this.agendaSearchGridFields=this.getAgendaSearchGridFields(),this.setHotkeys(),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0,this.setPedidosValueChanges(),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.revalidacaoTransportadora(),this.verificaSeTemAlteracao()},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.revalidacaoTransportadora=function(){var e=this;this.formGroup.get("transportadora").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=e.formGroup.get("transportadora").value;e.erpProcessService&&a&&(e.erpProcessData.transportadoraId=a.id,e.erpProcessService.changeData(e.erpProcessData))})},e.prototype.abrirPedidoVenda=function(e){var t=document.getElementById("pedidoVenda").getElementsByTagName("button");t.length&&(this.pedidoVendaForm.patchValue({pedidoVenda:e}),t[0].click())},e.prototype.excluirPedidoVenda=function(e){this.formGroup.get("pedidos").removeAt(e)},e.prototype.abrirPedidoVendaItem=function(e,t){this.itemFormGroup.patchValue(t||{item:undefined,quantidade:1}),this.pedidoAtual=e,this.visibleDialog=!0},e.prototype.excluirPedidoVendaItem=function(e,t){var a=t.get("itens").value.findIndex(function(t){return t.item.id===e});a>=0&&t.get("itens").removeAt(a)},e.prototype.setPedidosValueChanges=function(){var e=this;this.formGroup.get("pedidos").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(){var t=e.formGroup.get("pedidos").length;e.ordersValid=t>0,e.formGroup.get("filial")[t>=1?"disable":"enable"]()})},e.prototype.selecionarPedidoVenda=function(e){if(this.formGroup.get("pedidos").value.find(function(t){return t.pedidoVenda.id===e.id}))return this.addMessage("warn",this.translate.instant("yms.erp.pedido_venda_search_already_selected_summary"),this.translate.instant("yms.erp.pedido_venda_search_already_selected_detail"));this.formGroup.get("pedidos").push(this.getOrdemVendaForm(e,!0)),e&&1===this.formGroup.get("pedidos").length&&!this.formGroup.get("clienteFaturamento").value&&this.buscarClienteAFaturar(e)},e.prototype.selecionarPedidoVendaItem=function(){var e=this.itemFormGroup.value,t=this.pedidoAtual.get("itens").value;if(t&&e&&e.item&&t.find(function(t){return t.item.id===e.item.id}))return this.addMessage("warn",this.translate.instant("yms.erp.item_pedido_venda_search_already_selected_summary"),this.translate.instant("yms.erp.item_pedido_venda_search_already_selected_detail"));var a=this.getOrdemVendaItemForm();a.patchValue(j({},this.itemFormGroup.value)),a.get("item").value!=undefined&&(this.pedidoAtual.get("itens").push(a),this.visibleDialog=!1)},e.prototype.selecionarPedidoVendaItemAutomaticamente=function(e,t){if(e&&1===e.length){var a=this.getOrdemVendaItemForm(),i=this.getPedidos().filter(function(e){return!(!e||!e.value.pedidoVenda)&&e.value.pedidoVenda.id===t.id});this.itemFormGroup.get("item").setValue(1===e.length?e[0]:{}),this.itemFormGroup.get("quantidade").setValue(1),a.patchValue(j({},this.itemFormGroup.value)),i[0].get("itens").push(a),this.visibleDialog=!1}},e.prototype.getPedidos=function(){return this.formGroup.get("pedidos").controls},e.prototype.buildTokens=function(e){return e.map(function(e){var t=e&&e.item?e.item:e,a=t.sku?t.sku:t.produto;return{id:t.id,label:"Produto: "+a.descricao+", Sequencia: "+t.sequencia}})},e.prototype.ngAfterViewInit=function(){var e=this,t=document.getElementsByTagName("input"),a=Array.from(t).find(function(e){return!e.disabled});a&&a.focus(),this.override.initialize(),this.saveAndInitButton=document.getElementById("init"),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)});(this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)||!this.permissions.editar)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.agenda&&this.agenda.createdByErp&&(this.formGroup.get("filial").disable(),this.formGroup.get("transportadora").disable(),this.formGroup.get("clienteRemessa").disable(),this.formGroup.get("clienteFaturamento").disable(),this.pedidoVendaForm.disable(),this.itemFormGroup.disable(),this.disableOrdersButtons=!0)},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.override.remove()},e.prototype.setHotkeys=function(){var e=this;this.hotkeysService.add(new G.Hotkey("alt+shift+s",function(){return(e.isNew()||e.permissions.editar)&&e.onSave(),!1},["INPUT","SELECT","TEXTAREA"])),this.hotkeysService.add(new G.Hotkey("alt+shift+c",function(){return e.onCancel(),!1},["INPUT","SELECT","TEXTAREA"]))},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.updateSuggestions=function(e){e.agenda&&(e.agenda.label=this.getSuggestionValue(["id","descricao"],"agenda",e,this.agendaLookupSeparator),e.agenda.label.trim()===this.agendaLookupSeparator.trim()&&delete e.agenda.label)},e.prototype.getSuggestionValue=function(e,t,a,i){var r=this;return e.map(function(e){return r.getProp(a,t+"."+e)}).reduce(function(e,t){return""+e+i+t})},e.prototype.onRouteDataChange=function(e){var t=e.localeConfig.number,a=t.currencySymbol,i=t.thousandsSeparator,r=t.decimalSeparator;if(this.localeConfig=e.localeConfig,this.currencyLocaleOptions={align:"left",prefix:a,thousands:i,decimal:r},this.permissions=e.allPermissions.expedicao,this.allPermissions=e.allPermissions,e.entity){this.permissions.editar||this.formGroup.disable();var o=Ki.fromDto(e.entity);this.updateSuggestions(o),this.formGroup.patchValue(o)}else this.formGroup.patchValue(new Ki)},e.prototype.onCancel=function(){this.goBack()},e.prototype.onSendFile=function(e,a){var i=[];return this.fieldCustomization.isEmpty(e)||i.push(this.fieldCustomization.deleteFiles(e)),this.fieldCustomization.isEmpty(a)||i.push(this.fieldCustomization.commitFiles(a)),this.fieldCustomization.isEmpty(i)?t.of({}):t.forkJoin(i)},e.prototype.setValuesPedidoBiodisel=function(){var e=this.formGroup.get("numeroPedidoCliente").value,t=this.formGroup.get("itemPedidoCliente").value,a=this.formGroup.get("pedidos").value;(a||[]).map(function(a){a&&a.itens&&a.itens.length&&(a.itens[0].numeroPedidoCliente=e,a.itens[0].itemPedidoCliente=t)}),this.formGroup.get("pedidos").patchValue(a)},e.prototype.getValuesPedidoBiodisel=function(){var e=this.formGroup.get("pedidos").value,t=this.formGroup.get("numeroPedidoCliente"),a=this.formGroup.get("itemPedidoCliente");(e||[]).map(function(e){if(!t.value||!a.value){var i=e&&e.itens&&e.itens.length?e.itens[0].pedido:null;i&&i.itens&&i.itens.length&&1===i.itens.length&&(t.patchValue(i.itens[0].numeroPedidoCliente),a.patchValue(i.itens[0].itemPedidoCliente))}})},e.prototype.onSave=function(e){var t=this;if(this.formGroup.get("agenda").setValue(this.agenda),this.ordersValid=this.formGroup.get("pedidos").length>0,this.formGroup.invalid||!this.ordersValid)return this.validateAllFormFields(this.formGroup);this.setValuesPedidoBiodisel();var i=this.fieldCustomization.getFiles(this.formGroup),r=i.filesToDelete,o=i.filesToCommit;return this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(r,o,e):(this.erpProcessData=this.erpProcessService.builderErpProcessData(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(r,o,e)}))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=St.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e,t,a){var i=this;this.atualizaExpedicao(e,t,function(){i.hasChangeService.hasChangeSave(i.agenda.id),a&&i.saveAndInitButton&&(i.hasChangeService.hasChangeSave(i.agenda.id),i.saveAndInitButton.click())})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.atualizaExpedicao=function(e,i,r){var o=this;return this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return o.loading=!1})).subscribe(function(n){o.formGroup.get("id").setValue(n.id||null),o.onSendFile(e,i).pipe(a.takeUntil(o.ngUnsubscribe),a.catchError(function(e){return o.loading=!1,t.throwError(e)})).subscribe(function(){o.addMessage("success","saved_message_title","saved_message_content"),r()})})},e.prototype.setTransportadora=function(e){var t=this;if(e){var i="pessoa.cpfCnpj eq '"+e.replace(".","").replace("/","").replace("-","")+"'";this.transportadoraService.list({filterQuery:i,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(1===a.length){var i=a[0].codigo?a[0].codigo.toString():"",r=a[0].descricao?a[0].descricao.toString():"";r.trim()||i.trim()?a[0].label=i+" - "+r:a[0].label=t.translate.instant("yms.erp.derivacao_sem_descricao"),t.formGroup.get("transportadora").setValue(a[0])}})}},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.getExpedicao=function(e){var t=this;this.loading=!0,this.expedicaoService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(e){var a=e.contents;if(a.length){t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var i=Ki.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(i),i.pedidos.forEach(function(e){var a=t.getOrdemVendaForm();a.patchValue(e),e.itens.forEach(function(e){var i=t.getOrdemVendaItemForm();i.patchValue(e),a.get("itens").push(i)}),t.formGroup.get("pedidos").push(a)}),t.getValuesPedidoBiodisel(),t.formCarregado=!0}else t.buscarFilial()})},e.prototype.onClienteFaturamentoLookupRequest=function(e){var t=this;Oe(this.clienteFaturamentoSearchFields,this.clienteFaturamentoLookupDisplayFields,this.clienteFaturamentoAdvancedDisplayFields,this.clienteFaturamentoLookupSeparator,this.pessoaService,e,"cliente eq true").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.clienteFaturamentoLookupSuggestions=e.contents})},e.prototype.onClienteFaturamentoSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getClienteSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Wi(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Wi(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Wi(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":a==n.FieldType.Lookup?t+" eq '"+i.id+"'":t+" eq '"+i+"'"}).join(" and ");c=c+(c?" and ":"")+"situacao eq ATIVO and cliente eq true";var p=_e(this.clienteFaturamentoLookupDisplayFields,this.clienteFaturamentoAdvancedDisplayFields);this.pessoaService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.clienteFaturamentoLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.clienteFaturamentoLookupSeparator)})})})})).subscribe(function(e){t.clienteFaturamentoSearchGridData=e.contents,t.clienteFaturamentoSearchTotalRecords=e.totalElements})},e.prototype.onClienteRemessaLookupRequest=function(e){var t=this;Oe(this.clienteRemessaSearchFields,this.clienteRemessaLookupDisplayFields,this.clienteRemessaAdvancedDisplayFields,this.clienteRemessaLookupSeparator,this.pessoaService,e,"cliente eq true").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.clienteRemessaLookupSuggestions=e.contents})},e.prototype.onClienteRemessaSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getClienteSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Wi(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Wi(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Wi(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and ");c=c+(c?" and ":"")+"situacao eq ATIVO and cliente eq true";var p=_e(this.clienteRemessaLookupDisplayFields,this.clienteRemessaAdvancedDisplayFields);this.pessoaService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.clienteRemessaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.clienteRemessaLookupSeparator)})})})})).subscribe(function(e){t.clienteRemessaSearchGridData=e.contents,t.clienteRemessaSearchTotalRecords=e.totalElements})},e.prototype.onFilialSelect=function(e){this.disableOrdersButtons=!e||this.agenda.createdByErp},e.prototype.onFilialLookupRequest=function(e){var t=this,i=this.getFilialSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).reduce(function(t,a){var i,r,o=a.name;return a.type===n.FieldType.Integer?j({},t,((i={})[o]=e.replace(/\D/,""),i)):j({},t,((r={})[o]=e,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(i).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return ma.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(ma.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Oe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this;xe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.onPedidoVendaLookupRequest=function(e){var t=this,i=this.pedidoVendaLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=this.getPedidoVendaSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+Wi(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+Wi(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+Wi(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or ");r=r+(r?" and ":"")+"situacaoPedido eq ABERTO_TOTAL or situacaoPedido eq ABERTO_PARCIAL";var o=this.formGroup.get("pedidos").value||[],s="";o.map(function(e){return!!(e&&e.pedidoVenda&&e.pedidoVenda.id)&&(s+=" and (id ne '"+e.pedidoVenda.id+"')")}),o.length&&s&&(r+=s);var l=_e(this.pedidoVendaLookupDisplayFields,this.pedidoVendaAdvancedDisplayFields);this.pedidoVendaService.list({sort:i,filterQuery:r,displayFields:l}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.pedidoVendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaLookupSuggestions=e.contents})},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.onPedidoVendaSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,n=e.filterData,s=o||[],l=this.formGroup.get("filial").value,d=this.formGroup.get("pedidos").value||[],c=[];d.map(function(e){return!!(e&&e.pedidoVenda&&e.pedidoVenda.id)&&c.push(e.pedidoVenda.id)});var p={pessoaId:n.cliente?n.cliente.id:null,filialId:l?l.id:null,tipoAgendamentoId:this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,filialPedido:n.filialPedido,pedidosSelecionados:c,numero:n.numero,pagina:this.getRecPagina(i,r,s)};this.pedidoVendaService.pesquisarPedidosVenda(p).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.pedidoVendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaSearchGridData=e.contents,t.pedidoVendaSearchTotalRecords=e.totalElements})},e.prototype.onPedidoVendaItemLookupRequest=function(e){var t=this,i=this.pedidoVendaItemLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=(this.formGroup.get("filial").value||{}).id,o={pedidoId:(this.pedidoAtual.get("pedidoVenda").value||{}).id,filialId:r,sequencia:isNaN(e)?null:e,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(0,10,i)};this.pedidoVendaItemService.pesquisarItensPedidoVenda(o).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.pedidoVendaItemLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaItemLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaItemLookupSuggestions=e.contents})},e.prototype.onPedidoVendaItemSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,n=e.filterData,s=o,l=(this.formGroup.get("filial").value||{}).id,d={pedidoId:(this.pedidoAtual.get("pedidoVenda").value||{}).id,filialId:l,sequencia:n.sequencia,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(i,r,s)};this.pedidoVendaItemService.pesquisarItensPedidoVenda(d).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.pedidoVendaItemLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaItemLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaItemSearchGridData=e.contents,t.pedidoVendaItemSearchTotalRecords=e.totalElements})},e.prototype.getAutomaticItensOrder=function(e){var t=this;if(e&&e.id){var i=this.pedidoVendaItemLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=(this.formGroup.get("filial").value||{}).id,o={pedidoId:e.id,filialId:r,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(0,10,i)};this.pedidoVendaItemService.pesquisarItensPedidoVenda(o).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.pedidoVendaItemLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaItemLookupSeparator)})})})})).subscribe(function(a){t.selecionarPedidoVendaItemAutomaticamente(a.contents,e)})}},e.prototype.onAgendaLookupRequest=function(e){var t=this,i=this.agendaLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=this.getAgendaSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+Wi(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+Wi(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+Wi(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or "),o=_e(this.agendaLookupDisplayFields,this.agendaAdvancedDisplayFields);this.agendaService.listExternalAgenda({sort:i,filterQuery:r,displayFields:o}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.agendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.agendaLookupSeparator)})})})})).subscribe(function(e){t.agendaLookupSuggestions=e.contents})},e.prototype.onAgendaSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getAgendaSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Wi(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Wi(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Wi(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and "),p=_e(this.agendaLookupDisplayFields,this.agendaAdvancedDisplayFields);this.agendaService.listExternalAgenda({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.agendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.agendaLookupSeparator)})})})})).subscribe(function(e){t.agendaSearchGridData=e.contents,t.agendaSearchTotalRecords=e.totalElements})},e.prototype.getFormGroup=function(){return this.formBuilder.group({id:[{value:undefined,disabled:!0},C.Validators.compose([])],clienteFaturamento:[{value:undefined,disabled:!1},C.Validators.compose([C.Validators.required])],clienteRemessa:[{value:undefined,disabled:!1}],filial:[{value:undefined,disabled:!1},C.Validators.compose([C.Validators.required])],transportadora:[{value:undefined,disabled:!1},C.Validators.compose([])],pedidos:this.formBuilder.array([]),agenda:[{value:undefined,disabled:!1},C.Validators.compose([C.Validators.required])],numeroAgendamentoCliente:[{value:undefined,disabled:!1},C.Validators.compose([])],numeroPedidoCliente:[{value:undefined,disabled:!1},C.Validators.compose([])],itemPedidoCliente:[{value:undefined,disabled:!1},C.Validators.compose([])],createdBy:[{value:undefined,disabled:!0},C.Validators.compose([])],createdDate:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedBy:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedDate:[{value:undefined,disabled:!0},C.Validators.compose([])]})},e.prototype.getClienteSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.pessoa_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.pessoa_nome"),type:n.FieldType.String}),new n.FormField({name:"cpfCnpj",label:this.translate.instant("yms.erp.pessoa_cpfCnpj"),type:n.FieldType.String})]},e.prototype.getClienteSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.pessoa_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.pessoa_nome"),type:n.FieldType.String}),new n.FormField({name:"cpfCnpj",label:this.translate.instant("yms.erp.pessoa_cpfCnpj"),type:n.FieldType.String}),new n.FormField({name:"site",label:this.translate.instant("yms.erp.pessoa_site"),type:n.FieldType.String})]},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.filial_nome"),type:n.FieldType.String})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.filial_nome"),type:n.FieldType.String})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getPedidoVendaSearchFields=function(){var e=this,i=new t.Subject,r=new t.Subject;return[new n.FormField({name:"numero",label:this.translate.instant("yms.erp.pedido_venda_numero"),type:n.FieldType.Integer}),new n.FormField({name:"filialPedido",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"cliente",label:this.translate.instant("yms.erp.pessoa_cliente_label"),type:n.FieldType.Lookup,searchFields:this.getClienteSearchFields(),searchGridFields:this.getClienteSearchGridFields(),suggestionsObservable:i,searchObservable:r,emptyMessage:"Nenhuma sugestão encontrada",size:{sm:12,md:12,lg:12,xl:12},onLookupRequest:function(t){Oe(e.clienteFaturamentoSearchFields,e.clienteFaturamentoLookupDisplayFields,e.clienteFaturamentoAdvancedDisplayFields,e.clienteFaturamentoLookupSeparator,e.pessoaService,t,"situacao eq ATIVO and cliente eq true").pipe(a.takeUntil(e.ngUnsubscribe)).subscribe(function(e){return i.next(e.contents)})},onSearchRequest:function(t){xe(e.clienteFaturamentoSearchFields,e.clienteFaturamentoLookupDisplayFields,e.clienteFaturamentoAdvancedDisplayFields,e.clienteFaturamentoLookupSeparator,e.pessoaService,t,"situacao eq ATIVO and cliente eq true").pipe(a.takeUntil(e.ngUnsubscribe)).subscribe(function(e){r.next({totalRecords:e.totalElements,gridData:e.contents})})},dataKey:"id",lookupDisplayField:"label",searchTitle:this.translate.instant("yms.erp.pessoa_cliente_label"),searchEmptyTitle:this.translate.instant("yms.erp.nothing_found"),filterLabel:this.translate.instant("yms.erp.filter"),filterTitle:this.translate.instant("yms.integration.filters"),clearLabel:this.translate.instant("yms.erp.clear"),cancelLabel:this.translate.instant("yms.erp.cancel"),selectLabel:this.translate.instant("yms.erp.select"),tooltip:this.translate.instant("yms.erp.pessoa_cliente_label")})]},e.prototype.getPedidoVendaSearchGridFields=function(){return[new n.FormField({name:"numero",label:this.translate.instant("yms.erp.pedido_venda_numero"),type:n.FieldType.Integer}),new n.FormField({name:"filial.nome",label:this.translate.instant("yms.erp.filial"),type:n.FieldType.String}),new n.FormField({name:"filial.codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"pessoa.nome",label:this.translate.instant("yms.erp.pessoa_cliente_label"),type:n.FieldType.Integer}),new n.FormField({name:"pessoa.codigo",label:this.translate.instant("yms.erp.pessoa_cliente_codigo_label"),type:n.FieldType.Integer})]},e.prototype.getPedidoVendaItemSearchFields=function(){return[new n.FormField({name:"sequencia",label:this.translate.instant("yms.erp.pedido_venda_item_sequencia"),type:n.FieldType.Integer})]},e.prototype.getPedidoVendaItemSearchGridFields=function(){return H(this.getPedidoVendaItemSearchFields(),[new n.FormField({name:"sku.descricao",label:this.translate.instant("yms.erp.produto"),type:n.FieldType.String})])},e.prototype.getAgendaSearchFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getAgendaSearchGridFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.goBack=function(){this.router.navigate(["../"],{relativeTo:this.route.parent})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup&&t.validateAllFormFields(i)}),this.focusService.focusFirstInvalidInput()},e.prototype.getSaveObservable=function(){var e,t=this.formGroup.getRawValue(),a=Ki.toDto(t);if(this.isNew()&&!t.id)e=this.expedicaoService.insert(a);else{var i=t.id;e=this.expedicaoService.update(i,a)}return e},e.prototype.validateVisualization=function(){ke(this.formGroup,this.allPermissions)||this.addMessage("error","yms.erp.cannot_visualize_form_summary","yms.erp.cannot_visualize_form_detail")},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.getPedidoVendaForm=function(){return this.formBuilder.group({pedidoVenda:[undefined]})},e.prototype.getOrdemVendaForm=function(e,t){return t&&this.getAutomaticItensOrder(e),this.formBuilder.group({id:[undefined],pedidoVenda:[e],itens:this.formBuilder.array([])})},e.prototype.getOrdemVendaItemForm=function(e){return this.formBuilder.group({id:[undefined],pedido:[undefined],item:[e],quantidade:[undefined],numeroPedidoCliente:[undefined],itemPedidoCliente:[undefined]})},e.prototype.buscarFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length?(this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&(e.formGroup.get("filial").setValue(ma.fromDto(a[0])),e.disableOrdersButtons=!1)}),this.formCarregado=!0):this.formCarregado=!0},e.prototype.buscarClienteAFaturar=function(e){var t=this;this.pessoaService.list({size:1,page:0,filterQuery:"id eq '"+e.pessoa.id+"'"}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;1===(a||[]).length&&t.formGroup.get("clienteFaturamento").setValue(ta.fromDto(a[0]))})},V([r.Input(),B("design:type",qe)],e.prototype,"agenda",void 0),V([r.Input(),B("design:type",Boolean)],e.prototype,"revalidacao",void 0),V([r.ViewChild("customTemplate"),B("design:type",r.TemplateRef)],e.prototype,"customTemplate",void 0),V([r.ViewChild("customFormFields"),B("design:type",r.TemplateRef)],e.prototype,"customFormFields",void 0),e=V([r.Component({selector:"expedicao-form",template:'<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-g">\n <div class="ui-g-12 ui-md-12">\n <label class="required-h3">Pedidos:</label>\n <s-button label="Adicionar pedido" priority="default" (onClick)="abrirPedidoVenda()" [disabled]="disableButtonSave || disableOrdersButtons"></s-button>\n <div class="error-required-message" [hidden]="ordersValid">{{\'yms.erp.error_required\' | translate}}</div>\n <p-accordion>\n <p-accordionTab *ngFor="let pedido of getPedidos(); let i = index">\n <p-header>\n Pedido: {{ pedido.get(\'pedidoVenda\')?.value?.numero }}\n </p-header>\n \n <div style="margin: 10px 0; display: block;">\n <s-button label="Adicionar item do pedido" priority="default" size="small"\n (onClick)="abrirPedidoVendaItem(pedido)" [disabled]="disableButtonSave || disableOrdersButtons"></s-button>\n <s-button label="Excluir pedido" priority="default" size="small"\n (onClick)="excluirPedidoVenda(i)" [disabled]="disableButtonSave || disableOrdersButtons"></s-button>\n </div>\n \n <s-token-list [tokens]="buildTokens(pedido.get(\'itens\')?.value)" [removableTokens]="true"\n (tokenRemoved)="excluirPedidoVendaItem($event.id, pedido)">\n </s-token-list>\n </p-accordionTab>\n </p-accordion>\n <div style="display: inline-block;" class="separator"></div>\n </div>\n </div>\n <div class="ui-fluid">\n <div class="ui-g">\n <div [attr.data-hidden]="true" class="ui-g-12 ui-md-6">\n <label for="id">{{"yms.erp.recebimento_id" | translate}}</label>\n <input #idFormInput type="text" id="id" name="id" pInputText formControlName="id"\n autocomplete="off" />\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="filial">{{"yms.erp.expedicao_filial" | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions" (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n (onSelect)="onFilialSelect($event)"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="clienteFaturamento">{{"yms.erp.expedicao_cliente_faturamento" | translate}}</label>\n <s-lookup dataKey="id" id="clienteFaturamento" name="clienteFaturamento"\n formControlName="clienteFaturamento" [searchFields]="clienteFaturamentoSearchFields"\n [searchGridFields]="clienteFaturamentoSearchGridFields"\n [searchGridData]="clienteFaturamentoSearchGridData" [multiple]="false"\n [lookupSuggestions]="clienteFaturamentoLookupSuggestions"\n (onLookupRequest)="onClienteFaturamentoLookupRequest($event)"\n (onSearchRequest)="onClienteFaturamentoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="clienteFaturamentoSearchTotalRecords"\n [searchTitle]="\'yms.erp.cliente_faturamento_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: clienteFaturamentoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'clienteFaturamento\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="clienteRemessa">{{"yms.erp.expedicao_cliente_remessa" | translate}}</label>\n <s-lookup dataKey="id" id="clienteRemessa" name="clienteRemessa" formControlName="clienteRemessa"\n [searchFields]="clienteRemessaSearchFields" [searchGridFields]="clienteRemessaSearchGridFields"\n [searchGridData]="clienteRemessaSearchGridData" [multiple]="false"\n [lookupSuggestions]="clienteRemessaLookupSuggestions"\n (onLookupRequest)="onClienteRemessaLookupRequest($event)"\n (onSearchRequest)="onClienteRemessaSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="clienteRemessaSearchTotalRecords"\n [searchTitle]="\'yms.erp.cliente_remessa_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: clienteRemessaSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'clienteRemessa\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="transportadora">{{"yms.erp.expedicao_transportadora" | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchGridFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="numeroAgendamentoCliente">Número agendamento do cliente</label>\n <input type="text" pInputText formControlName="numeroAgendamentoCliente" pattern="[0-9]+$">\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="numeroPedidoCliente">Número pedido do cliente</label>\n <input type="text" pInputText formControlName="numeroPedidoCliente" pattern="[0-9]+$">\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="itemPedidoCliente">Item pedido do cliente</label>\n <input type="text" pInputText formControlName="itemPedidoCliente" pattern="[0-9]+$">\n </div>\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">{{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} / </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">{{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}</label>\n </div>\n </div>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button priority="primary" [label]="\'save\' | translate" (onClick)="onSave()" [disabled]="disableButtonSave"></s-button>\n <s-button *ngIf="saveAndInitButton" priority="primary" [label]="\'save_and_init\' | translate" (onClick)="onSave(true)" [disabled]="disableButtonSave"></s-button>\n </div>\n\n <form [formGroup]="pedidoVendaForm" [hidden]="true">\n <s-lookup dataKey="id" id="pedidoVenda" name="pedidoVenda" formControlName="pedidoVenda"\n [searchFields]="pedidoVendaSearchFields" [searchGridFields]="pedidoVendaSearchGridFields"\n [searchGridData]="pedidoVendaSearchGridData" [multiple]="false"\n [lookupSuggestions]="pedidoVendaLookupSuggestions" (onLookupRequest)="onPedidoVendaLookupRequest($event)"\n (onSearchRequest)="onPedidoVendaSearchRequest($event)" lookupDisplayField="label"\n (onSelect)="selecionarPedidoVenda($event)" [searchTotalRecords]="pedidoVendaSearchTotalRecords"\n [searchTitle]="\'yms.erp.pedido_venda_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate" [filterLabel]="\'yms.erp.filter\' | translate"\n [clearLabel]="\'yms.erp.clear\' | translate" [cancelLabel]="\'yms.erp.cancel\' | translate"\n [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: pedidoVendaSearchTotalRecords}">\n </s-lookup>\n </form>\n\n <p-dialog [(visible)]="visibleDialog" styleClass="s-lookup-modal" [modal]="true">\n <p-header>\n Adicionar item\n </p-header>\n\n <form [formGroup]="itemFormGroup">\n <div class="ui-fluid">\n <div class="ui-g">\n <div class="ui-g-12 ui-md-6">\n <label for="item">Item do pedido</label>\n <s-lookup dataKey="id" id="item" name="item" formControlName="item"\n [searchFields]="pedidoVendaItemSearchFields"\n [searchGridFields]="pedidoVendaItemSearchGridFields"\n [searchGridData]="pedidoVendaItemSearchGridData" [multiple]="false"\n [lookupSuggestions]="pedidoVendaItemLookupSuggestions"\n (onLookupRequest)="onPedidoVendaItemLookupRequest($event)"\n (onSearchRequest)="onPedidoVendaItemSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="pedidoVendaItemSearchTotalRecords"\n [searchTitle]="\'yms.erp.expedicao_pedido_venda_itens_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: pedidoVendaItemSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="quantidade">Quantidade</label>\n <input type="number" pInputText formControlName="quantidade">\n </div>\n </div>\n </div>\n </form>\n\n <p-footer>\n <s-button [label]="\'select\' | translate" (onClick)="selecionarPedidoVendaItem()"></s-button>\n </p-footer>\n </p-dialog>\n</div>',styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),B("design:paramtypes",[Vt,F.Router,F.ActivatedRoute,I.MessageService,C.FormBuilder,o.TranslateService,G.HotkeysService,Be,Ue,Xa,qa,pi,za,Ua,qt,Ut,c.ConfirmationService,ri,oi,ai])],e)}(),Xi=function(){function e(e){this.expedicaoService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.expedicaoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Dados de expedição não encontrados")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.expedicao=Ki.fromDto(t)})},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"expedicao-info",template:'\n <div *sLoadingState="loading" style="padding: 20px">\n <div class="detail-pane" *ngIf="agenda && expedicao">\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_filial\' | translate}}</span>\n <span class="data">{{expedicao.filial?.codigo}} - {{expedicao.filial?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_cliente_faturamento\' | translate}}</span>\n <span class="data">{{expedicao.clienteFaturamento?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_cliente_remessa\' | translate}}</span>\n <span class="data">{{expedicao.clienteRemessa?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_transportadora\' | translate}}</span>\n <span class="data">{{expedicao.transportadora?.pessoa?.nomeFantasia}}</span>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),B("design:paramtypes",[Vt])],e)}(),Zi=function(){function e(){}return e=V([p.CircuitoFinalizado({header:"Logs de integração YMS/ERP",name:"yms.integracao.erpagrox"})],e)}(),er=function(e){function i(a,i,r){var o=e.call(this)||this;return o.route=a,o.logIntegracaoService=i,o.translate=r,o.allPermissions={},o.permissions={},o.localeConfig={},o.currentListParams={page:0,size:10,sort:[],filterData:{}},o.serverError=!1,o.ngUnsubscribe=new t.Subject,o.xmlFormatter=require("xml-formatter")||function(e,t){return e},o}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this.gridColumns=this.getGridColumns(),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)})},i.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},i.prototype.onRouteDataChange=function(e){this.allPermissions=e.allPermissions,this.permissions=e.allPermissions.logIntegracao,this.localeConfig=e.localeConfig},i.prototype.onSearch=function(){this.resetGrid()},i.prototype.onGridChange=function(e){var t=e.rows,a=e.first/t,i=e.multiSortMeta;return this.updateGrid({page:a,size:t,sort:i})},i.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},i.prototype.getGridColumns=function(){return[{field:"nome",header:this.translate.instant("yms.integration.log_integracao_nome")},{field:"entradaEm",header:this.translate.instant("yms.integration.log_integracao_entrada_em")},{field:"saidaEm",header:this.translate.instant("yms.integration.log_integracao_saida_em")}]},i.prototype.updateGrid=function(e){var t=this;void 0===e&&(e={}),this.showLoader=!0,this.currentListParams=j({},this.currentListParams,e);var i=this.currentListParams,r=i.page,o=i.size;this.logIntegracaoService.list({page:r,size:o,sort:[{field:"entradaEm",order:-1}],filterQuery:"agenda eq '"+this.agenda.id+"'",displayFields:["*"]}).pipe(a.takeUntil(this.ngUnsubscribe),a.catchError(function(e){throw t.serverError=!0,e}),a.finalize(function(){t.showLoader=!1})).subscribe(function(e){t.selection=[],t.gridData=e.contents,t.totalRecords=e.totalElements,t.serverError=!1})},i.prototype.getPayload=function(e){return"{"==e[0]?JSON.stringify(JSON.parse(e),null,2):"<"===e[0]?this.xmlFormatter(e):e},i.prototype.resetGrid=function(e){e&&(this.currentListParams=j({},this.currentListParams,e)),this.currentListParams=j({},this.currentListParams,{page:0,sort:[]}),this.table.reset()},i.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup&&t.validateAllFormFields(i)})},V([r.Input(),B("design:type",qe)],i.prototype,"agenda",void 0),V([r.ViewChild("logIntegracaoTable"),B("design:type",l.Table)],i.prototype,"table",void 0),V([r.ViewChild("customTemplate"),B("design:type",r.TemplateRef)],i.prototype,"customTemplate",void 0),V([r.ViewChild("customFilterFields"),B("design:type",r.TemplateRef)],i.prototype,"customFilterFields",void 0),V([r.ViewChild("customGridColgroup"),B("design:type",r.TemplateRef)],i.prototype,"customGridColgroup",void 0),V([r.ViewChild("customGridHeader"),B("design:type",r.TemplateRef)],i.prototype,"customGridHeader",void 0),V([r.ViewChild("customGridBody"),B("design:type",r.TemplateRef)],i.prototype,"customGridBody",void 0),i=V([r.Component({template:'<div *sLoadingState="showLoader">\n <s-empty-state *ngIf="serverError" iconClass="fa fa-exclamation-triangle" title="{{\'yms.integration.error_server_title\' | translate}}"\n primaryActionLabel="{{\'yms.integration.error_server_try_again\' | translate}}" (primaryAction)="resetGrid()"\n description="{{\'yms.integration.error_server_description\' | translate}}"></s-empty-state>\n <s-empty-state *ngIf="gridData && !gridData.length" [title]="\'yms.integration.log_integracao_empty_state_title\' | translate"\n [description]="\'yms.integration.log_integracao_empty_state_description\' | translate"></s-empty-state>\n <div [attr.data-hidden]="!gridData?.length || serverError">\n <div class="ui-g">\n <div class="ui-g-12">\n <p-table #logIntegracaoTable [value]="gridData" [columns]="gridColumns" dataKey="id" [lazy]="true" [scrollable]="true"\n [resizableColumns]="true" [paginator]="true" [totalRecords]="totalRecords"\n rows="10" [rowsPerPageOptions]="[10, 20, 50, 100]" [(selection)]="selection" (onLazyLoad)="onGridChange($event)" >\n <ng-template pTemplate="colgroup" let-columns *ngIf="!customGridColgroup else customGridColgroup">\n <colgroup>\n <col *ngFor="let col of columns" [style.width]="col.width">\n \x3c!--{CA:GRID_COLGROUP_COLUMNS:START}--\x3e\n \x3c!--{CA:GRID_COLGROUP_COLUMNS:END}--\x3e\n </colgroup>\n </ng-template>\n <ng-template pTemplate="header" let-columns *ngIf="!customGridHeader else customGridHeader">\n <tr>\n <th style="width: 50px">\n \n </th>\n <th *ngFor="let col of columns; let i = index" [ngStyle]="i === 0 ? {\'width\': \'200px\'} : {\'width\': \'150px\'}" pResizableColumn>\n <div class="senior-header">\n <span class="senior-header-title">{{col.header}}</span>\n </div>\n </th>\n \x3c!--{CA:GRID_HEADER_COLUMNS:START}--\x3e\n \x3c!--{CA:GRID_HEADER_COLUMNS:END}--\x3e\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData let-columns let-expanded="expanded" *ngIf="!customGridBody else customGridBody">\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px;">\n <a href="#" [pRowToggler]="rowData">\n <i [ngClass]="expanded ? \'pi pi-chevron-down\' : \'pi pi-chevron-right\'"></i>\n </a>\n </td>\n <td (click)="selection = [rowData]" style="width: 200px">\n <span>{{getProp(rowData, \'nome\') || (\'yms.integration.list_grid_empty_field\' | translate)}}</span>\n </td>\n <td (click)="selection = [rowData]" style="width: 150px">\n <span>{{getProp(rowData, \'entradaEm\') | localizedDate | async}}</span>\n </td>\n <td (click)="selection = [rowData]" style="width: 150px">\n <span>{{getProp(rowData, \'saidaEm\') | localizedDate | async}}</span>\n </td>\n \x3c!--{CA:GRID_BODY_COLUMNS:START}--\x3e\n \x3c!--{CA:GRID_BODY_COLUMNS:END}--\x3e\n </tr>\n </ng-template>\n <ng-template pTemplate="rowexpansion" let-rowData>\n <td colspan="4">\n <p-tabView>\n <p-tabPanel header="Payload de entrada">\n <pre *ngIf="rowData.entrada">\n <code [highlight]="getPayload(rowData.entrada)" [languages]="[\'json\', \'xml\']">\n </code>\n </pre>\n <s-empty-state *ngIf="!rowData.entrada" [title]="\'Não há informação\' | translate"\n [description]="\'Não há informações a serem exibidas\' | translate">\n </s-empty-state>\n </p-tabPanel>\n <p-tabPanel header="Payload de saída">\n <pre *ngIf="rowData.saida">\n <code [highlight]="getPayload(rowData.saida)" [languages]="[\'json\', \'xml\']">\n </code>\n </pre>\n <s-empty-state *ngIf="!rowData.saida" [title]="\'Não há informação\' | translate"\n [description]="\'Não há informações a serem exibidas\' | translate">\n </s-empty-state>\n </p-tabPanel>\n <p-tabPanel header="Stack Trace">\n <pre *ngIf="rowData.stackTrace">\n <code [highlight]="getPayload(rowData.stackTrace)" [languages]="[\'json\', \'xml\']">\n </code>\n </pre>\n <s-empty-state *ngIf="!rowData.stackTrace" [title]="\'Não há informação\' | translate"\n [description]="\'Não há informações a serem exibidas\' | translate">\n </s-empty-state>\n </p-tabPanel>\n </p-tabView>\n <div class="separator"></div>\n </td>\n </ng-template>\n <ng-template pTemplate="paginatorright">\n <span [translate]="\'yms.integration.total_records\'" [translateParams]="{value: totalRecords}"></span>\n </ng-template>\n \x3c!--{CA:GRID_TEMPLATES:START}--\x3e\n \x3c!--{CA:GRID_TEMPLATES:END}--\x3e\n </p-table>\n </div>\n </div>\n </div>\n</div>\n\x3c!--{CA:FILE_CONTENTS:START}--\x3e\n\x3c!--{CA:FILE_CONTENTS:END}--\x3e',providers:[O.ConfirmationService],styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),B("design:paramtypes",[F.ActivatedRoute,Ti,o.TranslateService])],i)}(Zi),tr=function(){function e(){}return e.fromDto=function(e){var t=j({},e);return t.filial=ma.fromDto(t.filial),t},e.toDto=function(e){var t=j({},e);return t.filial=ma.toDto(t.filial),t},e}(),ar=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.processoAvulsoService=a,this.AVULSO_KEY="ERP_SENIOR_PROCESSO_AVULSO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.AVULSO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.AVULSO_KEY)},e.prototype.functionToOverride=function(e){var i=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return i.processoAvulsoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?i.processoAvulsoService.registrarChegada({processoAvulso:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Os dados da guia ERP Senior não foram informados")}))},e=V([r.Injectable(),B("design:paramtypes",[p.ChegadaVeiculoOverride,qt,_i])],e)}(),ir=function(){function e(e,a,i,r,o,n,s,l,d,c,p,u,m){this.fb=e,this.router=a,this.route=i,this.filialService=r,this.processoAvulsoService=o,this.messageService=n,this.processoAvulsoOverride=s,this.translate=l,this.confirmationService=d,this.agendaService=c,this.erpProcessService=p,this.erpFormConfigService=u,this.hasChangeService=m,this.loading=!1,this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.permissions={},this.formCarregado=!1,this.ngUnsubscribe=new t.Subject}return e.prototype.ngOnInit=function(){var e=this;this.formGroup=this.fb.group({id:[undefined],filial:[undefined,C.Validators.required],agenda:[undefined]}),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.getProcessoAvulso(),this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=e.formGroup.get("filial").value;e.erpProcessService&&a&&(e.erpProcessData.filialId=a.id,e.erpProcessService.changeData(e.erpProcessData))}),this.processoAvulsoOverride.initialize(),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)}),this.verificaSeTemAlteracao()},e.prototype.onRouteDataChange=function(e){this.permissions=e.allPermissions.agenda},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngAfterViewInit=function(){var e=this;this.saveAndInitButton=document.getElementById("init"),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.processoAvulsoOverride.remove()},e.prototype.onSave=function(e){var t=this;return this.formGroup.invalid?this.validateAllFormFields(this.formGroup):(this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessData(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)})))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=St.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.patchValue(j({},tr.fromDto(a))),t.successMessage(),t.hasChangeService.hasChangeSave(t.agenda.id),e&&t.saveAndInitButton&&(t.hasChangeService.hasChangeSave(t.agenda.id),t.saveAndInitButton.click())})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.onFilialLookupRequest=function(e){var t=this,i=this.getFilialSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).reduce(function(t,a){var i,r,o=a.name;return a.type===n.FieldType.Integer?j({},t,((i={})[o]=e.replace(/\D/,""),i)):j({},t,((r={})[o]=e,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(i).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return ma.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(ma.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.getSaveObservable=function(){var e=this.formGroup.value;e.agenda=this.agenda;var t=tr.toDto(e);return e.id?this.processoAvulsoService.update(e.id,t):this.processoAvulsoService.insert(t)},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup?t.validateAllFormFields(i):i instanceof C.FormArray&&i.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e.prototype.getProcessoAvulso=function(){var e=this;this.processoAvulsoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;if(!a||a.length<=0)return e.buscarFilial();var i=a[0];e.formGroup.patchValue(j({},tr.fromDto(i))),e.formCarregado=!0})},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")})]},e.prototype.buscarFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length&&this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&e.formGroup.get("filial").setValue(ma.fromDto(a[0]))}),this.formCarregado=!0},V([r.Input(),B("design:type",qe)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"processo-avulso-form",template:'<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-md-6 ui-g-12 required">\n <label for="filial">{{\'yms.erp.recebimento_ordem_compra_filial\' | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions" (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}"\n [disabled]="!permissions.editar">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button priority="primary" [label]="\'save\' | translate" (onClick)="onSave()" \n [disabled]="loading || !permissions.editar"></s-button>\n <s-button *ngIf="saveAndInitButton" priority="primary" [label]="\'save_and_init\' | translate"\n (onClick)="onSave(true)" [disabled]="loading || !permissions.editar"></s-button>\n </div>\n</div>'}),B("design:paramtypes",[C.FormBuilder,F.Router,F.ActivatedRoute,qa,_i,c.MessageService,ar,o.TranslateService,c.ConfirmationService,qt,ri,oi,ai])],e)}(),rr=function(){function e(e){this.processoAvulsoService=e,this.loading=!1,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.processoAvulsoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(t){var a=t.contents;!a||a.length<=0||(e.processoAvulso=tr.fromDto(a[0]))})},V([r.Input(),B("design:type",qe)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"processo-avulso-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n <div class="detail-span">\n <span class="title">{{\'yms.erp.filial\' | translate}}</span>\n <span class="data">{{processoAvulso?.filial?.nome}} - {{processoAvulso?.filial?.codigo}}</span>\n </div>\n </div>\n </div>\n '}),B("design:paramtypes",[_i])],e)}(),or=_,nr=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.competenciaInicial=a.competenciaInicial&&or(a.competenciaInicial).toDate(),a.competenciaFinal=a.competenciaFinal&&or(a.competenciaFinal).toDate(),a.createdDate=a.createdDate&&or(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&or(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"Safra")),a},e.toDto=function(e,t){var a=j({},e);return a.competenciaInicial=a.competenciaInicial&&or(a.competenciaInicial).format("YYYY-MM-DD"),a.competenciaFinal=a.competenciaFinal&&or(a.competenciaFinal).format("YYYY-MM-DD"),a.createdDate=a.createdDate&&or(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&or(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"Safra")),a},e}(),sr=_,lr=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&sr(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&sr(a.lastModifiedDate).toDate();return a.label=[""].map(function(e){return a[e]}).join(" - "),"Agenda"!==t&&a.agenda&&(a.agenda=qe.fromDto(a.agenda,"RecebimentoOrdemCompra")),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"RecebimentoOrdemCompra")),"Filial"!==t&&a.filial&&(a.filial=ma.fromDto(a.filial,"RecebimentoOrdemCompra")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=pa.fromDto(a.origemMercadoria,"RecebimentoOrdemCompra")),"Produto"!==t&&a.produto&&(a.produto=Li.fromDto(a.produto,"RecebimentoOrdemCompra")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=Pi.fromDto(a.derivacao,"RecebimentoOrdemCompra")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.fromDto(a.transportadora,"RecebimentoOrdemCompra")),"Safra"!==t&&a.safra&&(a.safra=nr.fromDto(a.safra,"RecebimentoOrdemCompra")),"OrdemCompra"!==t&&a.ordemCompra&&(a.ordemCompra=ha.fromDto(a.ordemCompra,"RecebimentoOrdemCompra")),a.fornecedores=a.fornecedores.map(function(e){return j({},e,{fornecedor:ta.fromDto(e.fornecedor),origemMercadoria:pa.fromDto(e.origemMercadoria),ordens:e.ordens.map(ha.fromDto)})}),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&sr(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&sr(a.lastModifiedDate).format(),delete a.label,"Agenda"!==t&&a.agenda&&(a.agenda=qe.toDto(a.agenda,"RecebimentoOrdemCompra")),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"RecebimentoOrdemCompra")),"Filial"!==t&&a.filial&&(a.filial=ma.toDto(a.filial,"RecebimentoOrdemCompra")),"Produto"!==t&&a.produto&&(a.produto=Li.toDto(a.produto,"RecebimentoOrdemCompra")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=Pi.toDto(a.derivacao,"RecebimentoOrdemCompra")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.toDto(a.transportadora,"RecebimentoOrdemCompra")),"Safra"!==t&&a.safra&&(a.safra=nr.toDto(a.safra,"RecebimentoOrdemCompra")),"OrdemCompra"!==t&&a.ordemCompra&&(a.ordemCompra=ha.toDto(a.ordemCompra,"RecebimentoOrdemCompra")),a},e}(),dr=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.recebimentoOrdemCompraService=a,this.RECEBIMENTO_ORDEMCOMPRA_KEY="ERP_SENIOR_RECEBIMENTO_ORDEMCOMPRA_KEY"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.RECEBIMENTO_ORDEMCOMPRA_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.RECEBIMENTO_ORDEMCOMPRA_KEY)},e.prototype.functionToOverride=function(e){var i=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return i.recebimentoOrdemCompraService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?i.recebimentoOrdemCompraService.registrarChegadaVeiculoRecebimentoOrdemCompra({recebimentoOrdemCompra:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Não foi possível encontrar os dados de Recebimento de ordem de compra")}))},e=V([r.Injectable(),B("design:paramtypes",[p.ChegadaVeiculoOverride,qt,Fi])],e)}(),cr=function(){function e(e,a,i,r,o,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F,S,D,C){var _=this;this.formBuilder=e,this.translate=a,this.filialService=i,this.pessoaService=r,this.produtoService=o,this.derivacaoService=n,this.transportadoraService=s,this.ordemCompraService=l,this.recebimentoOrdemCompraService=d,this.messageService=c,this.route=p,this.router=u,this.origemMercadoriaService=m,this.safraService=f,this.override=h,this.notaValidatorService=g,this.confirmationService=v,this.dialogService=y,this.agendaService=b,this.erpProcessService=F,this.erpFormConfigService=S,this.verificaNotaFiscal=D,this.hasChangeService=C,this.derivacaoLookupDisplayFields=["codigo","descricao"],this.derivacaoAdvancedDisplayFields=["id","codigo","descricao"],this.derivacaoLookupSeparator=" - ",this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.fornecedorLookupDisplayFields=["codigo","nome","cpfCnpj"],this.fornecedorAdvancedDisplayFields=["id","codigo","nome"],this.fornecedorLookupSeparator=" - ",this.ordemCompraLookupDisplayFields=["codigo","empresa.nome"],this.ordemCompraAdvancedDisplayFields=["id","codigo","empresa.nome","filial.nome","pessoa.nome"],this.ordemCompraLookupSeparator=" - ",this.origemMercadoriaLookupDisplayFields=["codigo","endereco"],this.origemMercadoriaAdvancedDisplayFields=["id","codigo","endereco","numero"],this.origemMercadoriaLookupSeparator=" - ",this.produtoLookupDisplayFields=["codigo","descricao"],this.produtoAdvancedDisplayFields=["id","codigo","descricao"],this.produtoLookupSeparator=" - ",this.safraLookupDisplayFields=["codigo","descricao"],this.safraAdvancedDisplayFields=["id","codigo","descricao"],this.safraLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.disableButtonSave=!1,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.erroChaveNota=!1,this.erroFornecedores=!1,this.notasTokens=[],this.fornecedorNotasTokens=[],this.fornecedorNotas=[],this.formCarregado=!1,this.ordemCompraSelecionado=null,this.permissions={},this.ngUnsubscribe=new t.Subject,this.onFilialValueChange=function(e,t){_.changeFormGroupValue(e,"produto",t)},this.onFornecedorChange=function(e,t){_.changeFormGroupValue(e,"origemMercadoria",t),_.changeFormGroupValue(e,"ordens",t)},this.onChangeRevalidation=function(e){_.erpProcessData&&_.formGroup&&(_.erpProcessData=_.erpProcessService.builderErpProcessData(_.erpProcessData,_.formGroup),_.erpProcessService.changeData(_.erpProcessData))},this.formGroup=this.getFormGroup()}return e.prototype.ngOnInit=function(){var e=this;this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;if("new"==a)return e.configureForm();e.getRecebimentoOrdemCompra(a)}),this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("fornecedores").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("transportadora").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.derivacaoSearchFields=this.getDerivacaoSearchFields(),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.fornecedorSearchFields=this.getFornecedorSearchFields(),this.origemMercadoriaSearchFields=this.getOrigemMercadoriaSearchFields(),this.produtoSearchFields=this.getProdutoSearchFields(),this.safraSearchFields=this.getSafraSearchFields(),this.safraSearchGridFields=this.getSafraSearchGridFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.ordemCompraSearchFields=this.getOrdemCompraFields(),this.ordemCompraSearchGridFields=this.getOrdemCompraGridFields(),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.getEmpresaFilial(),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0;this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.createdByErpDisableForm(),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.verificaSeTemAlteracao(),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)})},e.prototype.onRouteDataChange=function(e){this.permissions=e.allPermissions.agenda},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngAfterViewInit=function(){this.override.initialize(),this.saveAndInitButton=document.getElementById("init")},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.override.remove()},e.prototype.createdByErpDisableForm=function(){this.agenda&&this.agenda.createdByErp&&(this.createdByErp=!0,this.formGroup.get("filial").disable(),this.formGroup.get("produto").disable(),this.formGroup.get("derivacao").disable(),this.formGroup.get("transportadora").value&&this.formGroup.get("transportadora").disable())},e.prototype.configureForm=function(){var e=this;this.valueChanges(this.formGroup,"filial",this.onFilialValueChange);this.checkValuesChanges(this.formGroup,"produto","derivacao",this.derivacaoService,function(e){return"produto.id eq '"+e.id+"' and situacao eq 'ATIVO'"},["codigo","descricao"],function(e){return Pi.fromDto(e)},10,!0,!0),this.formGroup.get("fornecedores").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){t&&t.length>0?(e.formGroup.get("produto").disable(),e.formGroup.get("derivacao").disable()):(e.formGroup.get("produto").enable(),e.formGroup.get("derivacao").enable())}),this.createdByErpDisableForm(),this.formCarregado=!0},e.prototype.getEmpresaFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};if(1===t.cnpj.length){var i="pessoa.cpfCnpj eq '"+t.cnpj[0]+"'";this.filialService.list({filterQuery:i,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;if(1===a.length){var i=a[0],r=a[0].empresa;i.label=i.codigo+" - "+i.nome,r.label=r.codigo+" - "+r.nome,e.formGroup.get("empresa").setValue(r),e.formGroup.get("filial").setValue(i),e.formGroup.get("filial").enable(),e.formGroup.get("produto").enable(),e.formGroup.get("ordemCompra").enable()}})}},e.prototype.checkValuesChanges=function(e,t,i,r,o,n,s,l,d,c){var p=this;void 0===l&&(l=1),e.get(t).valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.debounceTime(500),a.filter(function(t){return d&&e.get(i).setValidators(t?C.Validators.required:C.Validators.nullValidator),c&&e.get(i).setValue(null),!!t||(e.get(i).setValue(null),e.get(i).disable(),!1)}),a.mergeMap(function(e){var t=o(e);return r.list({filterQuery:t,page:0,size:l})})).subscribe(function(t){var a=t.contents;if(!a||!a.length||a.length>1)return e.get(i).enable();1===a.length&&(a[0].label=p.translate.instant(Ne(a[0],n," - ",!0)),e.get(i).setValue(s(a[0]))),a.length>1?e.get(i).enable():e.get(i).disable()})},e.prototype.onBlurChaveNotaFiscal=function(){var e=this;if(!this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(this.chaveNotaFiscal,this.ordens,this.fornecedorNotasTokens)){this.removeNotaError();var t=this.chaveNotaFiscal;t&&(this.loading=!0,this.mensagemBuscandoNota(),this.notaValidatorService.pesquisarDocumentoValidaNotaEmUso({filialId:this.formGroup.get("filial").value&&this.formGroup.get("filial").value.id||null,chaveDocumento:t.replace(/\s/g,"")||""}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.addNovaNota(t)}))}},e.prototype.valueChanges=function(e,t,i){e.get(t).valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return i(t,e)})},e.prototype.changeFormGroupValue=function(e,t,a){if(!e)return a.get(t).setValue(undefined),void a.get(t).disable();a.get(t).enable()},e.prototype.getRecebimentoOrdemCompra=function(e){var t=this;this.loading=!0,this.recebimentoOrdemCompraService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(e){var a=e.contents;if(!a.length)return t.formCarregado=!0,t.configureForm();t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var i=lr.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(i),i.fornecedores.forEach(function(e){var a=t.getFornecedorForm(e);t.getFornecedoresForm().push(a),e.ordens.forEach(function(e){var i=t.getOrdemCompraForm(e);t.getOrdensCompra(a).push(i),e.notas.forEach(function(e){var a=t.getNotaForm(e);t.getNotas(i).push(a)})})}),t.configureForm()})},e.prototype.onFilialLookupRequest=function(e){var t=this,i=this.getFilialSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).reduce(function(t,a){var i,r,o=a.name;return a.type===n.FieldType.Integer?j({},t,((i={})[o]=e.replace(/\D/,""),i)):j({},t,((r={})[o]=e,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(i).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return ma.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(ma.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onFornecedorLookupRequest=function(e){var t=this;Oe(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.fornecedorLookupSuggestions=e.contents})},e.prototype.onFornecedorSearchRequest=function(e){var t=this;xe(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.fornecedorSearchGridData=e.contents,t.fornecedorSearchTotalRecords=e.totalElements})},e.prototype.onOrigemMercadoriaLookupRequest=function(e,t){var i=this;Oe(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,t," pessoa.id eq '"+e.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){i.origemMercadoriaLookupSuggestions=e.contents})},e.prototype.onOrigemMercadoriaSearchRequest=function(e,t){var i=this;xe(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,t," pessoa.id eq '"+e.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){i.origemMercadoriaSearchGridData=e.contents,i.origemMercadoriaSearchTotalRecords=e.totalElements})},e.prototype.onDerivacaoLookupRequest=function(e){var t=this;Oe(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e," produto.id eq '"+this.formGroup.get("produto").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoLookupSuggestions=e.contents})},e.prototype.onDerivacaoSearchRequest=function(e){var t=this;xe(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e," produto.id eq '"+this.formGroup.get("produto").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoSearchGridData=e.contents,t.derivacaoSearchTotalRecords=e.totalElements})},e.prototype.onOrdemCompraLookupRequest=function(e,t){var i=this;Oe(this.ordemCompraSearchFields,this.ordemCompraLookupDisplayFields,this.ordemCompraAdvancedDisplayFields,this.ordemCompraLookupSeparator,this.ordemCompraService,t,"filial.id eq '"+this.formGroup.get("filial").value.id+"' and pessoa.id eq '"+e.get("fornecedor").value.id+"'").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){i.ordemCompraLookupSuggestions=e.contents})},e.prototype.onOrdemCompraSearchRequest=function(e,t){var i=this;xe(this.ordemCompraSearchFields,this.ordemCompraLookupDisplayFields,this.ordemCompraAdvancedDisplayFields,this.ordemCompraLookupSeparator,this.ordemCompraService,t,"filial.id eq '"+this.formGroup.get("filial").value.id+"' and pessoa.id eq '"+e.get("fornecedor").value.id+"'").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){i.ordemCompraSearchGridData=e.contents,i.ordemCompraSearchTotalRecords=e.totalElements})},e.prototype.addOrdemCompra=function(e){var t=this;this.dialogService.open(va,j({},Re,{header:"Adicionar Ordem de Compra",data:{agenda:this.agenda,filial:this.formGroup.get("filial").value,fornecedor:e.get("fornecedor").value,ordens:e.get("ordens").value}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){return t.onOrdemCompraSaved(a,e)})},e.prototype.onProdutoLookupRequest=function(e){var t=this,i=this.formGroup.get("filial").value,r=this.agenda.tipoAgendamento;this.produtoService.listProdutos({pesquisa:e,empresaId:i?i.empresa.id:null,filialId:i?i.id:null,tipoAgendamentoId:r?r.id:null,situacao:"ATIVO",pagina:{limit:100,offset:0}}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.produtoLookupSuggestions=e.produtos.map(Li.fromDto)})},e.prototype.onProdutoSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getProdutoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}}),u=this.formGroup.get("filial").value,m=this.agenda.tipoAgendamento;this.produtoService.listProdutos(j({},p,{empresaId:u?u.empresa.id:null,filialId:u?u.id:null,situacao:"ATIVO",tipoAgendamentoId:m?m.id:null})).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoSearchTotalRecords=e.qtdTotalRegistros,t.produtoSearchGridData=e.produtos.map(Li.fromDto)})},e.prototype.onSafraLookupRequest=function(e){var t=this;Oe(this.safraSearchFields,this.safraLookupDisplayFields,this.safraAdvancedDisplayFields,this.safraLookupSeparator,this.safraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.safraLookupSuggestions=e.contents})},e.prototype.onSafraSearchRequest=function(e){var t=this;xe(this.safraSearchFields,this.safraLookupDisplayFields,this.safraAdvancedDisplayFields,this.safraLookupSeparator,this.safraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.safraSearchGridData=e.contents,t.safraSearchTotalRecords=e.totalElements})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Oe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this;xe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.setTransportadora=function(e){var t=this;if(e){var i="pessoa.cpfCnpj eq '"+e.replace(/\./g,"").replace(/\//g,"").replace(/\-/g,"")+"'";this.transportadoraService.list({filterQuery:i,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;1===a.length&&(a[0].label=t.translate.instant(Ne(a[0],["codigo","pessoa.nome"]," - ",!0)),t.formGroup.get("transportadora").setValue(a[0]))})}},e.prototype.onSave=function(e){var t=this;return this.formGroup.get("agenda").setValue(this.agenda),this.formGroup.invalid?this.validateAllFormFields(this.formGroup):this.formGroup.get("fornecedores").length<=0?void(this.erroFornecedores=!0):(this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessDataValidaNotaNaOrdemCompra(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)})))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=St.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.get("id").setValue(a.id||null),t.successMessage(),t.hasChangeService.hasChangeSave(t.agenda.id),e&&t.saveAndInitButton&&t.saveAndInitButton.click()})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.addFornecedor=function(e){this.erroFornecedores=!1;var t=this.getFornecedorForm(e);return this.getFornecedoresForm().push(t),t},e.prototype.removeFornecedor=function(e){var t=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_fornecedor_header"),message:this.translate.instant("yms.erp.remove_fornecedor_message"),accept:function(){var a=t.getFornecedoresForm().controls.indexOf(e);t.getFornecedoresForm().removeAt(a)}})},e.prototype.getFornecedorForm=function(e){void 0===e&&(e={});var t=this.formBuilder.group({fornecedor:[e.fornecedor,C.Validators.required],origemMercadoria:[e.origemMercadoria],ordens:this.formBuilder.array([])});this.valueChanges(t,"fornecedor",this.onFornecedorChange);return this.checkValuesChanges(t,"fornecedor","origemMercadoria",this.origemMercadoriaService,function(e){return"pessoa.id eq '"+e.id+"'"},["codigo","endereco"],function(e){return pa.fromDto(e)},10,!1,!0),t},e.prototype.getFornecedoresForm=function(){return this.formGroup.get("fornecedores")},e.prototype.getNotas=function(e){return e.get("notas")},e.prototype.addNota=function(e){var t=this;this.dialogService.open(ba,j({header:this.translate.instant("yms.erp.adicionar_nota")},Re,{data:{fornecedor:e.get("fornecedor").value,produto:this.formGroup.get("produto").value,filial:this.formGroup.get("filial").value,fornecedorNotasTokens:this.fornecedorNotasTokens,ordens:this.ordens}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){return t.onNotaSaved(a,e)})},e.prototype.removerNota=function(e,t,a){var i=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_nota_header"),message:this.translate.instant("yms.erp.remove_nota_message"),accept:function(){var r=t.value.ordemCompra.id,o=i.getNotasFromOrdens(e,r).controls.indexOf(a);i.getNotasFromOrdens(e,r).removeAt(o);var n=a.value;i.fornecedorNotasTokens.push({id:n.chaveNotaFiscal,label:n.numeroNotaFiscal}),i.fornecedorNotas.push({chaveNotaFiscal:n.chaveNotaFiscal,serieNotaFiscal:n.serieNotaFiscal,serieLegalNotaFiscal:n.serieLegalNotaFiscal,numeroNotaFiscal:n.numeroNotaFiscal})}})},e.prototype.showButtons=function(){return!!this.agenda&&[St.AGENDADO,St.AGUARDANDO_CONFIRMACAO,St.AGUARDANDO_CONFIRMACAO_SOLICITANTE,St.REJEITADO_POR_VALIDACAO].includes(this.agenda.status)},e.prototype.disableAdicionarNota=function(){return null===this.ordemCompraSelecionado||this.ordemCompraSelecionado===undefined},e.prototype.removerOrdemCompra=function(e,t){var a=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_ordem_compra_header"),message:this.translate.instant("yms.erp.remove_ordem_compra_message"),accept:function(){var i=a.getOrdensCompra(e),r=i.controls.indexOf(t);i.removeAt(r)}})},e.prototype.onOrdemCompraSaved=function(e,t){var a=this.getOrdemCompraForm({ordemCompra:e});this.getOrdensCompra(t).push(a),this.getFornecedorByOrdemCompra(e,t)},e.prototype.getFornecedorByOrdemCompra=function(e,t){this.pessoaService.list({size:1,page:0,filterQuery:"id eq '"+e.pessoa.id+"'"}).pipe(a.takeUntil(this.ngUnsubscribe),a.map(function(e){var t=e.contents;return(t||[]).length&&t[0]}),a.filter(function(e){return!!e})).subscribe(function(e){t.get("fornecedor").setValue(ta.fromDto(e))})},e.prototype.getOrdensCompra=function(e){return this.ordens=e.get("ordens"),e.get("ordens")},e.prototype.getNotasFromOrdens=function(e,t){var a,i,r=null,o=e.controls.ordens.controls;try{for(var n=z(o),s=n.next();!s.done;s=n.next()){var l=s.value;l.controls.ordemCompra.value.id===t&&(r=l.controls.notas)}}catch(d){a={error:d}}finally{try{s&&!s.done&&(i=n["return"])&&i.call(n)}finally{if(a)throw a.error}}return r},e.prototype.addFornecedorNotasTokenEmOrdemCompra=function(e,t){if(null!==this.ordemCompraSelecionado){var a=this.fornecedorNotas.filter(function(e){return e.chaveNotaFiscal===t.id}),i=this.getNotasFromOrdens(e,this.ordemCompraSelecionado.id);null!==i&&null!==a[0]&&i.push(this.getNotaForm(a[0])),this.removeFornecedorNotasTokenDaOrdemCompra(t)}else this.mensagemOrdemCompraNaoSelecionado()},e.prototype.removeFornecedorNotasTokenDaOrdemCompra=function(e){this.fornecedorNotasTokens.splice(this.fornecedorNotasTokens.indexOf(e),1),this.fornecedorNotas=this.fornecedorNotas.filter(function(t){return t.chaveNotaFiscal!==e.id})},e.prototype.getOrdemCompraForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({ordemCompra:[e.ordemCompra,C.Validators.required],notas:this.formBuilder.array([])})},e.prototype.getNotaForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({chaveNotaFiscal:[e.chaveNotaFiscal],serieNotaFiscal:[e.serieNotaFiscal],serieLegalNotaFiscal:[e.serieLegalNotaFiscal],numeroNotaFiscal:[e.numeroNotaFiscal]})},e.prototype.mensagemOrdemCompraNaoSelecionado=function(){this.addMessage("error","Ordem de compra não selecionado","Nenhum ordem de compra foi selecionado!")},e.prototype.onNotaSaved=function(e,t){if(null!==this.ordemCompraSelecionado)if(e.addFornecedor){var a=this.formGroup.get("fornecedores").controls.find(function(t){return(t.value.fornecedor||{id:undefined}).id===e.fornecedor.id}),i=e.infoNota,r=this.getNotaForm({chaveNotaFiscal:i.chave,serieNotaFiscal:i.serie,serieLegalNotaFiscal:i.serieLegal,numeroNotaFiscal:i.numero});if(a)(n=this.getNotasFromOrdens(a,this.ordemCompraSelecionado.id)).push(r),this.disableFields(a,"fornecedor","origemMercadoria");else if(t.get("fornecedor").value){var o=this.addFornecedor({fornecedor:ta.fromDto(e.fornecedor),origemMercadoria:pa.fromDto(e.origemMercadoria)});(n=this.getNotasFromOrdens(o,this.ordemCompraSelecionado.id)).push(r),this.disableFields(o,"fornecedor","origemMercadoria")}else{t.get("fornecedor").setValue(ta.fromDto(e.fornecedor)),t.get("origemMercadoria").setValue(pa.fromDto(e.origemMercadoria)),(n=this.getNotasFromOrdens(t,this.ordemCompraSelecionado.id)).push(r),this.disableFields(t,"fornecedor","origemMercadoria")}}else{var n;null!==(n=this.getNotasFromOrdens(t,this.ordemCompraSelecionado.id))&&n.push(this.getNotaForm(e))}else this.mensagemOrdemCompraNaoSelecionado()},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.getSaveObservable=function(){var e=this.formGroup.getRawValue();e.empresa=e.filial.empresa;var t=lr.toDto(e),a=t.fornecedores;return t.fornecedores.forEach(function(e){t.fornecedores.forEach(function(t){e.fornecedor.id===t.fornecedor.id&&e.origemMercadoria.id===t.origemMercadoria.id&&(a=a.splice(a.indexOf(t),1))})}),t.fornecedores=a,this.isNew()&&!e.id?this.recebimentoOrdemCompraService.insert(t):this.recebimentoOrdemCompraService.update(this.formGroup.value.id,t)},e.prototype.getFormGroup=function(){return this.formBuilder.group({id:[undefined],filial:[{value:undefined,disabled:!1},C.Validators.required],fornecedores:this.formBuilder.array([]),produto:[{value:undefined,disabled:!0}],derivacao:[{value:undefined,disabled:!0}],transportadora:[undefined],safra:[undefined],agenda:[{value:undefined,disabled:!0},C.Validators.required]})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup?t.validateAllFormFields(i):i instanceof C.FormArray&&i.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e.prototype.addNovaNota=function(e){var t=(e.documentos||[]).length?e.documentos[0]:undefined;if(t){var a=ta.fromDto(t.fornecedor),i=pa.fromDto(t.origemMercadoria);if(!this.getFornecedoresForm().controls.find(function(e){return e.value.fornecedor.id===a.id}))return this.addFornecedor({fornecedor:a,origemMercadoria:i}),void this.addFornecedorNotasToken(t);this.addFornecedorNotasToken(t)}},e.prototype.addFornecedorNotasToken=function(e){this.fornecedorNotasTokens.push({id:this.chaveNotaFiscal,label:e.numero}),this.fornecedorNotas.push({chaveNotaFiscal:this.chaveNotaFiscal,serieNotaFiscal:e.serie,serieLegalNotaFiscal:e.serieLegal,numeroNotaFiscal:e.numero}),this.chaveNotaFiscal=undefined,this.loading=!1},e.prototype.removeNotaError=function(){this.erroChaveNota=!1},e.prototype.addNotaError=function(){this.erroChaveNota=!0},e.prototype.mensagemBuscandoNota=function(){this.messageService.add({severity:"info",summary:this.translate.instant("yms.erp.nota_search_summary"),detail:this.translate.instant("yms.erp.nota_search_detail"),life:5e3})},e.prototype.disableFields=function(e){for(var t=[],a=1;a<arguments.length;a++)t[a-1]=arguments[a];t.forEach(function(t){return e.get(t).disable()})},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_codigo")})]},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")})]},e.prototype.getFornecedorSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_codigo")}),new n.FormField({name:"cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_cpfCnpj")})]},e.prototype.getOrigemMercadoriaSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_endereco_codigo")}),new n.FormField({name:"numero",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_numero")}),new n.FormField({name:"endereco",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_endereco")})]},e.prototype.getProdutoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_codigo")})]},e.prototype.getSafraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_descricao")})]},e.prototype.getSafraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_descricao")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_empresa")})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getOrdemCompraFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")})]},e.prototype.getOrdemCompraGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")})]},V([r.Input(),B("design:type",qe)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"recebimento-ordem-compra-form",template:'<p-confirmDialog [acceptLabel]="\'yes\' | translate" acceptIcon="" [rejectLabel]="\'no\' | translate" rejectIcon="">\n</p-confirmDialog>\n<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-fluid ui-g">\n\n <div class="ui-g-12">\n <label for="chaveNotaFiscal">{{\'yms.erp.recebimento_chave_nota_fiscal\' | translate}}</label>\n <input\n id="chaveNotaFiscal"\n trim\n pInputText\n type="text"\n [(ngModel)]="chaveNotaFiscal"\n [ngModelOptions]="{standalone: true}"\n (blur)="onBlurChaveNotaFiscal()"\n >\n \x3c!-- <input [class.ng-invalid]="erroChaveNota" pInputText type="text" [(ngModel)]="chaveNotaFiscal" [ngModelOptions]="{standalone: true}" (blur)="onBlurChaveNotaFiscal()"> --\x3e\n \x3c!-- <span class="input-error" *ngIf="erroChaveNota">{{\'yms.erp.produto_nota_error_detail\' | translate}}</span> --\x3e\n </div>\n\n <div class="ui-md-6 ui-g-12 required">\n <label for="filial">{{\'yms.erp.recebimento_ordem_compra_filial\' | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions" (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n\n <div class="ui-md-6 ui-g-12">\n <label for="transportadora">{{\'yms.erp.recebimento_ordem_compra_transportadora\' | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">\n {{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} /\n </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">\n {{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}\n </label>\n </div>\n\n <div class="ui-md-12">\n <s-button *ngIf="showButtons() && !!formGroup.get(\'filial\').value && !createdByErp" styleClass="btn-erp-forms" \n iconClass="fas fa-plus" label="Adicionar fornecedor" priority="secondary" \n (onClick)="addFornecedor()" [disabled]="disableButtonSave || !permissions.editar"></s-button>\n <span style="display: block;" class="input-error" *ngIf="erroFornecedores">{{\'Selecione ao menos um fornecedor para continuar\' | translate}}</span>\n </div>\n\n <form class="ui-g-12" *ngFor="let fornecedorForm of getFornecedoresForm().controls; let i = index;" [formGroup]="fornecedorForm">\n <p-panel [style]="{position: \'relative\'}" styleClass="form-group ui-g-12 ui-md-12" [toggleable]="true">\n\n <p-header>\n Fornecedor {{+i+1}}\n <s-button \n style="display: inline-block; position: absolute; right: 50px; top: 10px" \n *ngIf="showButtons() && !createdByErp"\n iconClass="fas fa-trash"\n label="Remover"\n priority="default"\n [auxiliary]="true"\n (onClick)="removeFornecedor(fornecedorForm)">\n </s-button>\n </p-header>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="fornecedor">{{\'yms.erp.recebimento_ordem_compra_fornecedor\' | translate}}</label>\n <s-lookup dataKey="id" id="fornecedor" name="fornecedor" formControlName="fornecedor"\n [searchFields]="fornecedorSearchFields" [searchGridFields]="fornecedorSearchFields"\n [searchGridData]="fornecedorSearchGridData" [multiple]="false"\n [lookupSuggestions]="fornecedorLookupSuggestions"\n (onLookupRequest)="onFornecedorLookupRequest($event)"\n (onSearchRequest)="onFornecedorSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="fornecedorSearchTotalRecords"\n [searchTitle]="\'yms.erp.fornecedor_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: { value: fornecedorSearchTotalRecords }">\n </s-lookup>\n <s-control-errors\n [control]="fornecedorForm.get(\'fornecedor\')"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }">\n </s-control-errors>\n </div>\n\n <div class="ui-md-6 ui-g-12">\n <label for="origem_mercadoria">{{\'yms.erp.recebimento_ordem_compra_mercadoria\' | translate}}</label>\n <s-lookup dataKey="id" id="origem_mercadoria" name="origem_mercadoria" formControlName="origemMercadoria" \n [searchFields]="origemMercadoriaSearchFields" [searchGridFields]="origemMercadoriaSearchFields"\n [searchGridData]="origemMercadoriaSearchGridData" [multiple]="false"\n [lookupSuggestions]="origemMercadoriaLookupSuggestions" lookupDisplayField="label"\n (onLookupRequest)="onOrigemMercadoriaLookupRequest(fornecedorForm, $event)"\n (onSearchRequest)="onOrigemMercadoriaSearchRequest(fornecedorForm, $event)" \n [searchTotalRecords]="origemMercadoriaSearchTotalRecords"\n [searchTitle]="\'yms.erp.origem_mercadoria_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: { value: origemMercadoriaSearchTotalRecords }">\n </s-lookup>\n </div>\n\n <div class="ui-g-12">\n <label for="fornecedorNotas">Notas a serem adicionadas</label>\n <s-token-list id="fornecedorNotas" [tokens]="fornecedorNotasTokens" (tokenSelected)="addFornecedorNotasTokenEmOrdemCompra(fornecedorForm, $event)" (tokenRemoved)="removeFornecedorNotasTokenDaOrdemCompra($event)" [removableTokens]="true"></s-token-list>\n </div>\n\n <div class="ui-g-12">\n <s-button label="Adicionar nota" *ngIf="showButtons()" styleClass="btn-erp-forms" priority="secondary" (onClick)="addNota(fornecedorForm)" [disabled]="disableAdicionarNota()"></s-button>\n <s-button label="Adicionar ordem de compra" *ngIf="showButtons() && !createdByErp" styleClass="btn-erp-forms" priority="secondary" (onClick)="addOrdemCompra(fornecedorForm)"></s-button>\n </div>\n\n <div class="ui-g-12">\n <h4>Ordens de Compra</h4>\n <p-table [value]="getOrdensCompra(fornecedorForm).controls" [(selection)]="ordemCompraSelecionado">\n <ng-template pTemplate="body" let-rowData>\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px">\n <p-tableRadioButton [value]="rowData.get(\'ordemCompra\').value"></p-tableRadioButton>\n </td>\n <td>\n <p-accordion>\n <p-accordionTab>\n <p-header>\n Ordem {{rowData.get(\'ordemCompra\').value.codigo}}, Filial {{rowData.get(\'ordemCompra\').value.filial?.codigo}}\n\n <span *ngIf="showButtons() && !createdByErp" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerOrdemCompra(fornecedorForm, rowData)"></span>\n </p-header>\n\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Notas</span>\n <span class="data">\n <p-accordion>\n <p-accordionTab *ngFor="let nota of getNotas(rowData).controls">\n <p-header>\n {{nota.get(\'chaveNotaFiscal\').value || (nota.get(\'serieNotaFiscal\').value + \' - \' + nota.get(\'numeroNotaFiscal\').value)}}\n\n <span *ngIf="showButtons()" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerNota(fornecedorForm, rowData, nota)"></span>\n </p-header>\n\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Série nota fiscal</span>\n <span class="data">{{nota.value?.serieNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Série legal nota fiscal</span>\n <span class="data">{{nota.value?.serieLegalNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{nota.value?.numeroNotaFiscal}}</span>\n </div>\n </div>\n\n </p-accordionTab> \n </p-accordion>\n </span>\n </div>\n </div>\n </p-accordionTab>\n </p-accordion>\n </td>\n </tr>\n </ng-template>\n </p-table>\n </div>\n </p-panel>\n </form>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button *ngIf="showButtons()" priority="primary" [label]="\'save\' | translate" (onClick)="onSave()"\n [disabled]="loading || disableButtonSave">\n </s-button>\n <s-button *ngIf="saveAndInitButton && showButtons()" priority="primary" [label]="\'save_and_init\' | translate"\n (onClick)="onSave(true)" [disabled]="loading || disableButtonSave">\n </s-button>\n </div>\n</div>',providers:[c.ConfirmationService],styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),B("design:paramtypes",[C.FormBuilder,o.TranslateService,qa,Xa,ei,Ea,pi,Jt,Fi,c.MessageService,F.ActivatedRoute,F.Router,Ha,di,dr,ya,c.ConfirmationService,c.DialogService,qt,ri,oi,Wt,ai])],e)}(),pr=function(){function e(e){this.recebimentoOrdemCompraService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.recebimentoOrdemCompraService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Recebimento Ordem de Compra não encontrado.")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.recebimentoOrdemCompra=lr.fromDto(t)})},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"recebimento-ordem-compra-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_filial\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.filial?.codigo}} - {{recebimentoOrdemCompra?.filial?.nome}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_produto\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.produto?.descricao}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_derivacao\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.derivacao?.descricao}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_transportadora\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.transportadora?.placaVeiculo}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_safra\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.safra?.descricao}}</span>\n </div>\n </div>\n <div *ngFor="let fornecedor of recebimentoOrdemCompra?.fornecedores">\n <div class="separator"></div>\n <h3>Fornecedor - {{fornecedor?.fornecedor?.nome}}</h3>\n <div class="detail-pane">\n <div class="detail-span" *ngFor="let ordemCompra of fornecedor.ordens">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_ordemcompra\' | translate}}</span>\n <span class="data">{{ ordemCompra.ordemCompra?.codigo }}</span>\n </div>\n </div>\n\n <div>\n <h4>Ordens de Compra</h4>\n <p-accordion>\n <p-accordionTab *ngFor="let ordemCompra of fornecedor.ordens">\n <p-header>\n Ordem de compra {{ ordemCompra?.ordemCompra?.numero }}, Filial {{ ordemCompra?.ordemCompra?.filial?.codigo }}\n </p-header>\n\n <div *ngFor="let nota of ordemCompra.notas">\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Chave nota fiscal</span>\n <span class="data">{{ nota?.chaveNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie nota fiscal</span>\n <span class="data">{{ nota?.serieNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie legal nota fiscal</span>\n <span class="data">{{ nota?.serieLegalNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{ nota?.numeroNotaFiscal }}</span>\n </div>\n </div>\n <hr />\n </div>\n </p-accordionTab>\n </p-accordion>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),B("design:paramtypes",[Fi])],e)}(),ur=_,mr=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);return a.dataEmissao=a.dataEmissao&&ur(a.dataEmissao).toDate(),a.dataInicioVigencia=a.dataInicioVigencia&&ur(a.dataInicioVigencia).toDate(),a.dataFimVigencia=a.dataFimVigencia&&ur(a.dataFimVigencia).toDate(),a.createdDate=a.createdDate&&ur(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ur(a.lastModifiedDate).toDate(),a.label="Número: "+a.numero+", Filial: "+a.filial.codigo,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"ContratoCompra")),"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.fromDto(a.pessoa,"ContratoCompra")),"Filial"!==t&&a.filial&&(a.filial=ma.fromDto(a.filial,"ContratoCompra")),"Safra"!==t&&a.safra&&(a.safra=nr.fromDto(a.safra,"ContratoCompra")),"ContratoCompraItem"!==t&&a.itens&&(a.itens=Object.values(a.itens).map(function(e){return hr.fromDto(e,"ContratoCompra")})),a},e.toDto=function(e,t){var a=j({},e);return a.dataEmissao=a.dataEmissao&&ur(a.dataEmissao).format("YYYY-MM-DD"),a.dataInicioVigencia=a.dataInicioVigencia&&ur(a.dataInicioVigencia).format("YYYY-MM-DD"),a.dataFimVigencia=a.dataFimVigencia&&ur(a.dataFimVigencia).format("YYYY-MM-DD"),a.createdDate=a.createdDate&&ur(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ur(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"ContratoCompra")),"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.toDto(a.pessoa,"ContratoCompra")),"Filial"!==t&&a.filial&&(a.filial=ma.toDto(a.filial,"ContratoCompra")),"Safra"!==t&&a.safra&&(a.safra=nr.toDto(a.safra,"ContratoCompra")),"ContratoCompraItem"!==t&&a.itens&&(a.itens=Object.values(a.itens).map(function(e){return hr.toDto(e,"ContratoCompra")}).filter(function(e){return Object.keys(e).length})),a},e}(),fr=_,hr=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);return a.sku=a.sku||{},a.dataCompetencia=a.dataCompetencia&&fr(a.dataCompetencia).toDate(),a.createdDate=a.createdDate&&fr(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&fr(a.lastModifiedDate).toDate(),a.label=a.sequencia+" - "+a.sku.descricao+" - "+a.sku.codigo,"ContratoCompra"!==t&&a.contrato&&(a.contrato=mr.fromDto(a.contrato,"ContratoCompraItem")),"Produto"!==t&&a.sku&&(a.sku=Li.fromDto(a.sku,"ContratoCompraItem")),a},e.toDto=function(e,t){var a=j({},e);return a.dataCompetencia=a.dataCompetencia&&fr(a.dataCompetencia).format("YYYY-MM-DD"),a.createdDate=a.createdDate&&fr(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&fr(a.lastModifiedDate).format(),delete a.label,"ContratoCompra"!==t&&a.contrato&&(a.contrato=mr.toDto(a.contrato,"ContratoCompraItem")),"Produto"!==t&&a.sku&&(a.sku=Li.toDto(a.sku,"ContratoCompraItem")),a},e}(),gr=_,vr=function(){function e(e,a,i,r,o,n,s){this.dialogRef=e,this.dialogConfig=a,this.contratoCompraService=i,this.contratoCompraItemService=r,this.translate=o,this.fb=n,this.route=s,this.contratoCompraLookupDisplayFields=["numero"],this.contratoCompraAdvancedDisplayFields=["id","numero","numeroAprovacao","situacaoAprovacao","dataEmissao","contratoPrioritario","dataInicioVigencia","dataFimVigencia"],this.contratoCompraLookupSeparator=" - ",this.contratoCompraItensLookupDisplayFields=["sequencia","sku.descricao"],this.contratoCompraItensAdvancedDisplayFields=["id","sequencia","sku.*","situacao","quantidadeContratada","quantidadeUtilizada","quantidadeEncerrada","dataCompetencia"],this.contratoCompraItensLookupSeparator=" - ",this.disableButtonSave=!1,this.permissions={},this.ngUnsubscribe=new t.Subject}return e.prototype.ngOnInit=function(){var e=this,t=this.dialogConfig.data;this.agenda=t.agenda,this.filial=t.filial,this.fornecedor=t.fornecedor,this.produto=t.produto,this.contratos=t.contratos.map(function(e){var t=e.contrato;return t?t.id:undefined}).filter(function(e){return!!e}),this.formGroup=this.getForm(),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)}),this.contratoCompraSearchFields=this.getContratoCompraFields(),this.contratoCompraSearchGridFields=this.getContratoCompraGridFields(),this.contratoCompraItensSearchFields=this.getContratoCompraItensFields(),this.contratoCompraItensSearchGridFields=this.getContratoCompraItensGridFields()},e.prototype.ngAfterViewInit=function(){(this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)||!this.permissions.editar)&&(this.formGroup.disable(),this.disableButtonSave=!0)},e.prototype.onRouteDataChange=function(e){this.permissions=e.allPermissions.agenda},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},e.prototype.onContratoCompraLookupRequest=function(e){var t=this,a=this.contratoCompraLookupDisplayFields.map(function(e){return{field:e,order:"Asc"}})[0],i={numero:+e.replace(/\D/g,"")},r=this.filial;r&&r.empresa&&r.empresa.id&&(i.empresaId=r.empresa.id),this.contratoCompraService.listContratosCompra(j({},i,{pessoaId:(this.fornecedor||{id:undefined}).id,produtoId:(this.produto||{id:undefined}).id,filialId:(r||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,contratosSelecionados:this.contratos,pagina:{limit:30,offset:0,listaOrdenacao:[{campo:a.field,ordenacao:a.order}]}})).subscribe(function(e){t.contratoCompraLookupSuggestions=e.contents.map(mr.fromDto)})},e.prototype.onContratoCompraSearchRequest=function(e){var t=this,a=e.first,i=e.rows,r=e.multiSortMeta,o=e.filterData,n=a/i,s=this.getContratoCompraFields().filter(function(e){var t=e.name;return o[t]!=undefined&&""!=o[t]}).reduce(function(e,t){var a;return j({},e,((a={})[t.name]=o[t.name],a))},{}),l=this.filial;l&&l.empresa&&l.empresa.id&&(s.empresaId=l.empresa.id),s.dataEmissao=s.dataEmissao&&gr(s.dataEmissao).format("YYYY-MM-DD");var d=(r||[]).length?{field:r[0].field,order:1===r[0].order?"Asc":"Desc"}:{field:"numero",order:"Asc"};this.contratoCompraService.listContratosCompra(j({},s,{pessoaId:(this.fornecedor||{id:undefined}).id,produtoId:(this.produto||{id:undefined}).id,filialId:(l||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,contratosSelecionados:this.contratos,pagina:{limit:i,offset:n,listaOrdenacao:[{campo:d.field,ordenacao:d.order}]}})).subscribe(function(e){t.contratoCompraSearchGridData=e.contents.map(mr.fromDto),t.contratoCompraSearchTotalRecords=e.totalElements})},e.prototype.onContratoCompraItensLookupRequest=function(e){var t=this,i=this.contratoCompraItensLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=this.filial.id,o={contratoId:this.formGroup.get("contrato").value.id,filialId:r,sequencia:isNaN(e)?null:e,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(0,10,i)};this.contratoCompraItemService.pesquisarItensContratoCompra(o).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.contratoCompraItensLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.contratoCompraItensLookupSeparator)})})})})).subscribe(function(e){t.contratoCompraItensLookupSuggestions=e.contents.map(hr.fromDto)})},e.prototype.onContratoCompraItensSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,n=e.filterData,s=o,l=this.filial.id,d={contratoId:this.formGroup.get("contrato").value.id,filialId:l,sequencia:n.sequencia,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(i,r,s)};this.contratoCompraItemService.pesquisarItensContratoCompra(d).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.contratoCompraItensLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.contratoCompraItensLookupSeparator)})})})})).subscribe(function(e){t.contratoCompraItensSearchGridData=e.contents.map(hr.fromDto),t.contratoCompraItensSearchTotalRecords=e.totalElements})},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.addItemContrato=function(){this.getItensForm().push(this.getItemForm())},e.prototype.getItensForm=function(){return this.formGroup.get("itens")},e.prototype.save=function(){if(!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);this.close({contrato:this.formGroup.value})},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.getForm=function(){return this.fb.group({contrato:[undefined,C.Validators.required],itens:this.fb.array([])})},e.prototype.getItemForm=function(){return this.fb.group({item:[undefined,C.Validators.required],quantidade:[1]})},e.prototype.getContratoCompraFields=function(){return[new n.FormField({name:"filialContrato",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"numero",label:this.translate.instant("yms.erp.contrato_compra_numero"),type:n.FieldType.Integer})]},e.prototype.getContratoCompraGridFields=function(){return[new n.FormField({name:"numero",label:this.translate.instant("yms.erp.contrato_compra_numero"),type:n.FieldType.Integer}),new n.FormField({name:"filial.pessoa.nomeFantasia",label:this.translate.instant("yms.erp.contrato_compra_filial"),type:n.FieldType.Integer}),new n.FormField({name:"filial.pessoa.codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"dataEmissao",label:this.translate.instant("yms.erp.contrato_compra_data_emissao"),type:n.FieldType.Date})]},e.prototype.getContratoCompraItensFields=function(){return[new n.FormField({name:"sequencia",label:this.translate.instant("yms.erp.contrato_compra_item_sequencia"),type:n.FieldType.Integer})]},e.prototype.getContratoCompraItensGridFields=function(){return[new n.FormField({name:"sequencia",label:this.translate.instant("yms.erp.contrato_compra_item_sequencia"),type:n.FieldType.Integer}),new n.FormField({name:"sku.descricao",label:this.translate.instant("yms.erp.produto"),type:n.FieldType.String})]},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup?t.validateAllFormFields(i):i instanceof C.FormArray&&i.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e=V([r.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 ui-md-6">\n <label for="contrato">Contrato</label>\n <s-lookup dataKey="id" name="contrato"\n formControlName="contrato" [searchFields]="contratoCompraSearchFields"\n [searchGridFields]="contratoCompraSearchGridFields"\n [searchGridData]="contratoCompraSearchGridData" [multiple]="false"\n [lookupSuggestions]="contratoCompraLookupSuggestions"\n (onLookupRequest)="onContratoCompraLookupRequest($event)"\n (onSearchRequest)="onContratoCompraSearchRequest($event)"\n lookupDisplayField="label" [searchTotalRecords]="contratoCompraSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_contrato_compra_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: contratoCompraSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="separator"></div>\n <div class="ui-g-12" *ngFor="let itemForm of getItensForm().controls">\n <form [formGroup]="itemForm">\n <div class="ui-g-6">\n <label>Contrato Item</label>\n <s-lookup dataKey="id" id="item" name="item" formControlName="item"\n [searchFields]="contratoCompraItensSearchFields"\n [searchGridFields]="contratoCompraItensSearchGridFields"\n [searchGridData]="contratoCompraItensSearchGridData" [multiple]="false"\n [lookupSuggestions]="contratoCompraItensLookupSuggestions"\n (onLookupRequest)="onContratoCompraItensLookupRequest($event)"\n (onSearchRequest)="onContratoCompraItensSearchRequest($event)"\n lookupDisplayField="label" [searchTotalRecords]="contratoCompraItensSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_contrato_compra_itens_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: contratoCompraItensSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-6">\n <label>Quantidade</label>\n <input pInputText type="number" formControlName="quantidade">\n </div>\n </form>\n </div>\n <s-button label="Adicionar item" priority="secondary" (onClick)="addItemContrato()"\n [disabled]="disableButtonSave"></s-button>\n </div>\n\n <div style="margin-top: 10px;">\n <div class="separator"></div>\n <s-button style="float: right;" [label]="\'save\' | translate" priority="primary" (onClick)="save()"\n [disabled]="disableButtonSave"></s-button>\n <s-button style="float: right;" [label]="\'cancel\' | translate" priority="link" (onClick)="close()"></s-button>\n </div>\n</form>\n\n'}),B("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,Ma,Ta,o.TranslateService,C.FormBuilder,F.ActivatedRoute])],e)}(),yr=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);return a.label=Ne(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"Transgenia")),"Royalty"!==t&&a.royalty&&(a.royalty=wi.fromDto(a.royalty,"Royalty")),a},e.toDto=function(e,t){var a=j({},e);return delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"Transgenia")),"Royalty"!==t&&a.royalty&&(a.roylty=wi.toDto(a.royalty,"Transgenia")),a},e}(),br=_,Fr=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&br(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&br(a.lastModifiedDate).toDate();return a.label=["id","fornecedor.id","fornecedor.codigo","fornecedor.nome","fornecedor.situacao","produto.id","produto.codigo","produto.comprado","produto.descricao","produto.produtoMisto","produto.situacao","produto.tipo","agenda.id","agenda.descricao","transportadora.id","transportadora.codigo","transportadora.placaVeiculo","transgenia.id","transgenia.codigo","transgenia.descricao","tipoNotaFiscal","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Filial"!==t&&a.filial&&(a.filial=ma.fromDto(a.filial,"Recebimento")),"Produto"!==t&&a.produto&&(a.produto=Li.fromDto(a.produto,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=qe.fromDto(a.agenda,"Recebimento")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=pa.fromDto(a.origemMercadoria,"Recebimento")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=Pi.fromDto(a.derivacao,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.fromDto(a.transportadora,"Recebimento")),"Transgenia"!==t&&a.transgenia&&(a.transgenia=yr.fromDto(a.transgenia,"Transgenia")),a.fornecedores=a.fornecedores.map(function(e){return j({},e,{fornecedor:ta.fromDto(e.fornecedor,"Recebimento"),origemMercadoria:pa.fromDto(e.origemMercadoria,"Recebimento"),contratos:e.contratos.map(function(e){return j({},e,{contrato:mr.fromDto(e.contrato),itens:e.itens.map(function(e){return j({},e,{item:hr.fromDto(e.item)})})})})})}),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&br(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&br(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.fornecedor&&(a.fornecedor=ta.toDto(a.fornecedor,"Recebimento")),"Filial"!==t&&a.filial&&(a.filial=ma.toDto(a.filial,"Filial")),"Produto"!==t&&a.produto&&(a.produto=Li.toDto(a.produto,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=qe.toDto(a.agenda,"Recebimento")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=pa.toDto(a.origemMercadoria,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.toDto(a.transportadora,"Recebimento")),"Transgenia"!==t&&a.transgenia&&(a.transgenia=yr.toDto(a.transgenia,"Transgenia")),a.fornecedores=e.fornecedores.map(function(e){return j({},e,{fornecedor:ta.toDto(e.fornecedor,"Recebimento"),origemMercadoria:pa.toDto(e.origemMercadoria,"Recebimento"),contratos:e.contratos.map(function(e){return j({},e,{contrato:mr.toDto(e.contrato),itens:e.itens.map(function(e){return j({},e,{item:hr.toDto(e.item)})})})})})}),a},e}();!function(e){e.EMPRESA_JURIDICA="EMPRESA_JURIDICA",e.PRODUTOR_RURAL="PRODUTOR_RURAL"}(zi||(zi={})),function(e){e.INATIVO="INATIVO",e.ATIVO="ATIVO"}($i||($i={}));var Sr=_,Dr=function(){function e(e,a,i,r,o,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F,S,D,C,_,I,T,k){var M=this;this.recebimentoService=e,this.router=a,this.route=i,this.messageService=r,this.confirmationService=o,this.formBuilder=n,this.translate=s,this.hotkeysService=l,this.fieldCustomization=d,this.focusService=c,this.filialService=p,this.transportadoraService=u,this.pessoaEnderecoService=m,this.contratoCompraService=f,this.pessoaService=h,this.produtoService=g,this.derivacaoService=v,this.recebimentoChegadaOverride=y,this.notaValidatorService=b,this.transgeniaService=F,this.dialogService=S,this.agendaService=D,this.erpProcessService=C,this.erpFormConfigService=_,this.verificaNotaFiscal=I,this.hasChangeService=T,this.buildFormField=k,this.localeConfig={},this.currencyLocaleOptions={},this.permissions={},this.allPermissions={},this.visibleDialog=!1,this.quantidadeSelecionada=1,this.mainPanelCollapsed=!1,this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.fornecedorLookupDisplayFields=["codigo","nome","cpfCnpj"],this.fornecedorAdvancedDisplayFields=["id","codigo","nome","situacao","cpfCnpj","tipoParticipante"],this.fornecedorLookupSeparator=" - ",this.origemMercadoriaLookupDisplayFields=["codigo","cep","endereco","empresa.descricao"],this.origemMercadoriaAdvancedDisplayFields=["id","codigo","cep","endereco","numero","complemento","cidade.*","bairro","situacao","empresa.descricao","cnpjCpf","inscricaoEstadual"],this.origemMercadoriaLookupSeparator=" - ",this.produtoLookupDisplayFields=["codigo","descricao","tipo"],this.produtoAdvancedDisplayFields=["id","codigo","comprado","descricao","produtoMisto","situacao","tipo"],this.produtoLookupSeparator=" - ",this.agendaLookupDisplayFields=["id","descricao"],this.agendaAdvancedDisplayFields=["id","descricao"],this.agendaLookupSeparator=" - ",this.derivacaoLookupDisplayFields=["codigo","descricao"],this.derivacaoAdvancedDisplayFields=["id","codigo","descricao"],this.derivacaoLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.transgeniaLookupDisplayFields=["codigo","descricao"],this.transgeniaAdvancedDisplayFields=["id","codigo","descricao","familia","tipoParticipante","situacao"],this.transgeniaLookupSeparator=" - ",this.disableButtonSave=!1,this.disableOrdersButtons=!0,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.tiposNota=[{label:this.translate.instant("yms.erp.tipo_nota_fiscal_empresa_juridica"),value:zi.EMPRESA_JURIDICA},{label:this.translate.instant("yms.erp.tipo_nota_fiscal_produtor_rural"),value:zi.PRODUTOR_RURAL}],this.erroChaveNota=!1,this.erroFornecedores=!1,this.erroFornecedoresNotaDuplicada=null,this.notasTokens=[],this.fornecedorNotasTokens=[],this.fornecedorNotas=[],this.contratoSelecionado=null,this.ngUnsubscribe=new t.Subject,this.carregandoErpFilial=!0,this.carregandoErpRouteData=!0,this.carregandoErpRecebimento=!0,this.onChangeRevalidation=function(e){M.erpProcessData&&M.formGroup&&(M.erpProcessData=M.erpProcessService.builderErpProcessData(M.erpProcessData,M.formGroup),M.erpProcessService.changeData(M.erpProcessData))},this.onFilialValueChange=function(e){if(M.disableOrdersButtons=!e,!e&&M.isNew())return M.formGroup.get("produto").setValue(undefined),M.formGroup.get("produto").disable(),M.formGroup.get("transgenia").setValue(undefined),M.formGroup.get("transgenia").disable(),void(M.carregandoErpFilial=!1);M.formGroup.get("produto").enable(),M.formGroup.get("transgenia").enable(),M.carregandoErpFilial=!1}}return e.prototype.ngOnInit=function(){var e=this;this.formGroup=this.getFormGroup(),this.itemFormGroup=this.getItemForm(),this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onFilialValueChange),this.formGroup.get("produto").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.debounceTime(500),a.filter(function(t){var a=e.formGroup.get("derivacao").value;return(!a||a.produto.id!==t.id)&&(!!t||(e.formGroup.get("derivacao").setValue(undefined),e.formGroup.get("derivacao").disable(),!1))}),a.mergeMap(function(t){return e.derivacaoService.list({filterQuery:"produto.id eq '"+t.id+"' and situacao eq 'ATIVO'",page:0,size:1})})).subscribe(function(t){var a=t.contents;a.length?(e.formGroup.get("derivacao").setValue(a[0]),e.formGroup.get("derivacao").disable()):e.formGroup.get("derivacao").enable()}),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)}),this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;"new"==a?e.buscarFilial():e.getRecebimento(a)}),this.formGroup.get("transportadora").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("transgenia").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("fornecedores").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchFields(),this.fornecedorSearchFields=this.getFornecedorSearchFields(),this.fornecedorSearchGridFields=this.getFornecedorSearchGridFields(),this.origemMercadoriaSearchFields=this.getOrigemMercadoriaFields(),this.origemMercadoriaSearchGridFields=this.getOrigemMercadoriaGridFields(),this.produtoSearchFields=this.getProdutoSearchFields(),this.produtoSearchGridFields=this.getProdutoSearchGridFields(),this.agendaSearchFields=this.getAgendaSearchFields(),this.agendaSearchGridFields=this.getAgendaSearchGridFields(),this.derivacaoSearchFields=this.getDerivacaoSearchFields(),this.derivacaoSearchGridFields=this.getDerivacaoSearchGridFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.transgeniaSearchFields=this.getTransgeniaSearchFields(),this.transgeniaSearchGridFields=this.getTransgeniaSearchGridFields(),this.setHotkeys(),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0;this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.verificaSeTemAlteracao(),this.formGroup.get("produto").valueChanges.subscribe(function(){e.validaTransgenia()}),this.formGroup.get("fornecedores").valueChanges.subscribe(function(){e.validaTransgenia()})},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.validaTransgenia=function(){if(!this.erpCarregado()){var e=this.formGroup.get("transgenia").value,t=this.formGroup.get("produto").value,a=this.getFamiliaProduto();t&&e&&(this.validaFamiliaProdutoCorrespondeFamiliaTrangenia(e,a)?this.validaFornecedorCorrespondeTipoPaticipanteDaTransgenia(e):this.mensagemTransgeniaInvalida())}},e.prototype.erpCarregado=function(){return!!this.carregandoErpFilial||(!!this.carregandoErpRouteData||!!this.carregandoErpRecebimento)},e.prototype.mensagemTransgeniaInvalida=function(){this.addMessage("error","yms.integration.mensagem_erro_titulo_informar_transgenia","yms.integration.mensagem_erro_conteuto_informar_transgenia"),this.formGroup.get("transgenia").setValue(undefined)},e.prototype.validaFamiliaProdutoCorrespondeFamiliaTrangenia=function(e,t){return null!==t&&e.familia===t},e.prototype.validaFornecedorCorrespondeTipoPaticipanteDaTransgenia=function(e){var t=this.getTipoTransgenia(),a=this.formGroup.get("fornecedores");if(a.length>0){var i=!0;if(a.controls.forEach(function(e){i=null===e.value.fornecedor}),i)return!0;if(null===t)return this.mensagemTransgeniaInvalida(),!1;if(t!==e.tipoParticipante)return this.mensagemTransgeniaInvalida(),!1;if(t===e.tipoParticipante)return!0}return!1},e.prototype.ngAfterViewInit=function(){var e=this,t=document.getElementsByTagName("input"),a=Array.from(t).find(function(e){return!e.disabled});a&&a.focus(),this.recebimentoChegadaOverride.initialize(),this.saveAndInitButton=document.getElementById("init"),this.createdByErpDisableForm(),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.recebimentoChegadaOverride.remove()},e.prototype.createdByErpDisableForm=function(){this.disableOrdersButtons=this.agenda.createdByErp,this.isNew()&&(this.createdByErp=!1,this.formGroup.get("filial").enable(),this.formGroup.get("produto").enable(),this.formGroup.get("derivacao").enable(),this.formGroup.get("transportadora").enable(),this.formGroup.get("fornecedores").controls.forEach(function(e){return e.get("fornecedor").enable()})),this.agenda&&this.agenda.createdByErp&&(this.createdByErp=!0,this.formGroup.get("filial").disable(),this.formGroup.get("produto").disable(),this.formGroup.get("derivacao").disable(),this.disableFornecedores(),this.formGroup.get("transportadora").value&&this.formGroup.get("transportadora").disable())},e.prototype.disableFornecedores=function(){this.formGroup.get("fornecedores").controls.forEach(function(e){return e.get("fornecedor").disable()})},e.prototype.setHotkeys=function(){var e=this;this.hotkeysService.add(new G.Hotkey("alt+shift+x",function(){return e.permissions.excluir&&e.onDelete(),!1},["INPUT","SELECT","TEXTAREA"])),this.hotkeysService.add(new G.Hotkey("alt+shift+s",function(){return(e.isNew()||e.permissions.editar)&&e.onSave(),!1},["INPUT","SELECT","TEXTAREA"])),this.hotkeysService.add(new G.Hotkey("alt+shift+c",function(){return e.onCancel(),!1},["INPUT","SELECT","TEXTAREA"]))},e.prototype.onBlurChaveNotaFiscal=function(){var e=this;if(!this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(this.chaveNotaFiscal,this.contratos,this.fornecedorNotasTokens)){this.removeNotaError();var t=this.chaveNotaFiscal;t&&(this.loading=!0,this.mensagemBuscandoNota(),this.notaValidatorService.pesquisarDocumentoValidaNotaEmUso({filialId:this.formGroup.get("filial").value&&this.formGroup.get("filial").value.id||null,chaveDocumento:t.replace(/\s/g,"")}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.addNovaNota(t)}))}},e.prototype.addNovaNota=function(e){var t=(e.documentos||[]).length?e.documentos[0]:undefined;if(t){var a=t.itens[0]||{produto:undefined,derivacao:undefined},i=Li.fromDto(a.produto);if(!this.formGroup.get("produto").value&&a.produto)this.formGroup.get("produto").setValue(i),this.formGroup.get("derivacao").setValue(Pi.fromDto(a.derivacao));else if(a.produto&&!this.validateProduto(i))return void this.addNotaError();var r=ta.fromDto(t.fornecedor),o=pa.fromDto(t.origemMercadoria),n=this.getFornecedoresForm().controls.find(function(e){return e.value.fornecedor.id===r.id});this.validarCnpjFornecedor(r.cpfCnpj)?(n||this.addFornecedor({fornecedor:r,origemMercadoria:o}),this.addFornecedorNotasToken(t)):n||(this.addFornecedor({fornecedor:r,origemMercadoria:o}),this.addFornecedorNotasToken(t)),this.validaRetornoPesquisaDocumentos(e)}},e.prototype.validaRetornoPesquisaDocumentos=function(e){var t=this.verificaNotaFiscal.findDuplicateFornecedores(e);null!==t&&(this.erroFornecedoresNotaDuplicada=this.translate.instant("yms.patio.duplicate_supplier")+t)},e.prototype.addFornecedorNotasToken=function(e){this.fornecedorNotasTokens.push({id:this.chaveNotaFiscal,label:e.numero}),this.fornecedorNotas.push({chaveNotaFiscal:this.chaveNotaFiscal,serieNotaFiscal:e.serie,serieLegalNotaFiscal:e.serieLegal,numeroNotaFiscal:e.numero}),this.chaveNotaFiscal=undefined,this.loading=!1},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.updateSuggestions=function(e){e.fornecedor&&(e.fornecedor.label=this.getSuggestionValue(["id","codigo","nome","situacao"],"fornecedor",e,this.fornecedorLookupSeparator),e.fornecedor.label.trim()===this.fornecedorLookupSeparator.trim()&&delete e.fornecedor.label),e.produto&&(e.produto.label=this.getSuggestionValue(["id","codigo","comprado","descricao","produtoMisto","situacao","tipo"],"produto",e,this.produtoLookupSeparator),e.produto.label.trim()===this.produtoLookupSeparator.trim()&&delete e.produto.label),e.agenda&&(e.agenda.label=this.getSuggestionValue(["id","descricao"],"agenda",e,this.agendaLookupSeparator),e.agenda.label.trim()===this.agendaLookupSeparator.trim()&&delete e.agenda.label),e.derivacao&&(e.derivacao.label=this.getSuggestionValue(["id","codigo","descricao"],"derivacao",e,this.derivacaoLookupSeparator),e.derivacao.label.trim()===this.derivacaoLookupSeparator.trim()&&delete e.derivacao.label)},e.prototype.getSuggestionValue=function(e,t,a,i){var r=this;return e.map(function(e){return r.getProp(a,t+"."+e)}).reduce(function(e,t){return""+e+i+t})},e.prototype.onRouteDataChange=function(e){var t=e.localeConfig.number,a=t.currencySymbol,i=t.thousandsSeparator,r=t.decimalSeparator;if(this.localeConfig=e.localeConfig,this.currencyLocaleOptions={align:"left",prefix:a,thousands:i,decimal:r},this.permissions=e.allPermissions.agenda,this.allPermissions=e.allPermissions,e.entity){this.permissions.editar||this.formGroup.disable();var o=Fr.fromDto(e.entity);this.updateSuggestions(o),this.formGroup.patchValue(o)}else this.formGroup.patchValue(new Fr);this.carregandoErpRouteData=!1},e.prototype.onCancel=function(){this.goBack()},e.prototype.onSendFile=function(e,a){var i=[];return this.fieldCustomization.isEmpty(e)||i.push(this.fieldCustomization.deleteFiles(e)),this.fieldCustomization.isEmpty(a)||i.push(this.fieldCustomization.commitFiles(a)),this.fieldCustomization.isEmpty(i)?t.of({}):t.forkJoin(i)},e.prototype.onSave=function(e){var t=this;if(!(this.formGroup.get("fornecedores").length<=0))return this.formGroup.invalid?this.validateAllFormFields(this.formGroup):(this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessDataValidaNotaNoContrato(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)})));this.erroFornecedores=!0},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=St.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.get("id").setValue(a.id||null),t.successMessage(),t.hasChangeService.hasChangeSave(t.agenda.id),e&&t.saveAndInitButton&&t.saveAndInitButton.click()})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.onDelete=function(){var e=this;this.confirmationService.confirm({message:this.translate.instant("yms.erp.delete_confirmation_message"),header:this.translate.instant("yms.erp.delete_confirmation_title"),accept:function(){return e.getDeleteObservable().pipe(a.takeUntil(e.ngUnsubscribe)).subscribe()}})},e.prototype.setTransportadora=function(e){var t=this;if(e){var i="pessoa.cpfCnpj eq '"+e.replace(".","").replace("/","").replace("-","")+"'";this.transportadoraService.list({filterQuery:i,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(1===a.length){var i=a[0].codigo?a[0].codigo.toString():"",r=a[0].descricao?a[0].descricao.toString():"";r.trim()||i.trim()?a[0].label=i+" - "+r:a[0].label=t.translate.instant("yms.erp.derivacao_sem_descricao"),t.formGroup.get("transportadora").setValue(a[0])}})}},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.getRecebimento=function(e){var t=this;this.loading=!0,this.recebimentoService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(e){var a=e.contents;if(a.length){t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var i=Fr.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(i),i.fornecedores.forEach(function(e){var a=t.getFornecedorForm(e);t.getFornecedoresForm().push(a),e.contratos.forEach(function(e){var i=t.getContratoForm(e);t.getContratos(a).push(i),e.itens.forEach(function(e){var a=t.getItemForm(e);t.getItensContrato(i).push(a)}),e.notas.forEach(function(e){var a=t.getNotaForm(e);t.getNotas(i).push(a)})})}),t.createdByErpDisableForm(),t.formCarregado=!0,t.carregandoErpRecebimento=!1}else t.buscarFilial()})},e.prototype.onFilialLookupRequest=function(e){var t=this,i=this.getFilialSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).reduce(function(t,a){var i,r,o=a.name;return a.type===n.FieldType.Integer?j({},t,((i={})[o]=e.replace(/\D/,""),i)):j({},t,((r={})[o]=e,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(i).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(ma.fromDto)})},e.prototype.onFilialSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(ma.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onFornecedorLookupRequest=function(e){var t=this,i=this.fornecedorLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=this.getFornecedorSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+Sr(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+Sr(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+Sr(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or ");r="("+r+")"+(r?" and ":"")+"situacao eq 'ATIVO' and fornecedor eq true";var o=_e(this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields);this.pessoaService.list({sort:i,filterQuery:r,displayFields:o}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.fornecedorLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.fornecedorLookupSeparator)})})})})).subscribe(function(e){t.fornecedorLookupSuggestions=e.contents})},e.prototype.onFornecedorSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getFornecedorSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Sr(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Sr(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Sr(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and ");c=c.concat((c?" and ":"")+"situacao eq 'ATIVO' and fornecedor eq true");var p=_e(this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields);this.pessoaService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.fornecedorLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.fornecedorLookupSeparator)})})})})).subscribe(function(e){t.fornecedorSearchGridData=e.contents,t.fornecedorSearchTotalRecords=e.totalElements})},e.prototype.montaQueryOrigemMercadoria=function(e){return"situacao eq 'ATIVO' and origem eq 'true' and pessoa.id eq '"+e+"'"},e.prototype.onOrigemMercadoriaLookupRequest=function(e,t){var i=this,r=(this.origemMercadoriaLookupDisplayFields.map(function(e){return{field:e,order:1}}),this.getOrigemMercadoriaFields().filter(function(t){var a=t.type;return Ie(a,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+Sr(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+Sr(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+Sr(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or "));r="("+r+")"+(r?" and ":""),r+=this.montaQueryOrigemMercadoria(t.get("fornecedor").value.id);var o=_e(this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields);this.pessoaEnderecoService.list({filterQuery:r,displayFields:o}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:i.origemMercadoriaLookupDisplayFields.map(function(t){return t.indexOf(".")>0?i.getProp(e,t):e[t]}).join(i.origemMercadoriaLookupSeparator)})})})})).subscribe(function(e){i.origemMercadoriaLookupSuggestions=e.contents})},e.prototype.onOrigemMercadoriaSearchRequest=function(e,t){var i=this,r=e.first,o=e.rows,s=e.multiSortMeta,l=e.filterData,d=r/o,c=s,p=this.getOrigemMercadoriaFields().filter(function(e){var t=e.name;return l[t]!=undefined&&""!=l[t]}).map(function(e){var t=e.name,a=e.type,i=l[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Sr(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Sr(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Sr(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and ");p=p.concat(p?" and ":""),p+=this.montaQueryOrigemMercadoria(t.get("fornecedor").value.id);var u=_e(this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields);this.pessoaEnderecoService.list({page:d,sort:c,filterQuery:p,displayFields:u}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:i.origemMercadoriaLookupDisplayFields.map(function(t){return t.indexOf(".")>0?i.getProp(e,t):e[t]}).join(i.origemMercadoriaLookupSeparator)})})})})).subscribe(function(e){i.origemMercadoriaSearchGridData=e.contents,i.origemMercadoriaSearchTotalRecords=e.totalElements})},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.onProdutoLookupRequest=function(e){var t=this,i=this.formGroup.get("filial").value,r=this.agenda.tipoAgendamento;this.produtoService.listProdutosRecebimento({pesquisa:e,empresaId:i?i.empresa.id:null,filialId:i?i.id:null,tipoAgendamentoId:r?r.id:null}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoLookupSuggestions=(e.produtos||[]).map(function(e){return Li.fromDto(e)})})},e.prototype.onProdutoSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getProdutoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}}),u=this.formGroup.get("filial").value,m=this.agenda.tipoAgendamento;this.produtoService.listProdutosRecebimento(j({},p,{empresaId:u?u.empresa.id:null,filialId:u?u.id:null,tipoAgendamentoId:m?m.id:null})).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoSearchTotalRecords=e.qtdTotalRegistros,t.produtoSearchGridData=(e.produtos||[]).map(function(e){return Li.fromDto(e)})})},e.prototype.onDerivacaoLookupRequest=function(e){var t=this,i=this.derivacaoLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=this.getDerivacaoSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+Sr(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+Sr(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+Sr(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or "),o=_e(this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields);this.derivacaoService.list({sort:i,filterQuery:r,displayFields:o}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.derivacaoLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.derivacaoLookupSeparator)})})})})).subscribe(function(e){t.derivacaoLookupSuggestions=e.contents})},e.prototype.onDerivacaoSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getDerivacaoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Sr(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Sr(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Sr(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and "),p=_e(this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields);this.derivacaoService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.derivacaoLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.derivacaoLookupSeparator)})})})})).subscribe(function(e){t.derivacaoSearchGridData=e.contents,t.derivacaoSearchTotalRecords=e.totalElements})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Oe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getTransportadoraSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Sr(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Sr(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Sr(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and "),p=_e(this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields);this.transportadoraService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.transportadoraLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.transportadoraLookupSeparator)})})})})).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.onTransgeniaLookupRequest=function(e){var t=this;Oe(this.getTransgeniaSearchFields(),this.transgeniaLookupDisplayFields,this.transgeniaAdvancedDisplayFields,this.transgeniaLookupSeparator,this.transgeniaService,e,this.geraFiltroTransgenia()).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.transgeniaLookupSuggestions=e.contents})},e.prototype.onTransgeniaSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getTransgeniaSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and "),p=this.geraFiltroTransgenia();p&&p.trim()&&(c=c?"("+c+") and "+p:p);var u=_e(this.transgeniaLookupDisplayFields,this.transgeniaAdvancedDisplayFields);this.transgeniaService.list({page:l,sort:d,filterQuery:c,displayFields:u}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.transgeniaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.transgeniaLookupSeparator)})})})})).subscribe(function(e){t.transgeniaSearchGridData=e.contents,t.transgeniaSearchTotalRecords=e.totalElements})},e.prototype.addFornecedor=function(e){void 0===e&&(e={}),this.erroFornecedores=!1;var t=this.getFornecedorForm(e);return this.configureFornecedor(t),this.getFornecedoresForm().push(t),t},e.prototype.removeFornecedor=function(e){var t=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_fornecedor_header"),message:this.translate.instant("yms.erp.remove_fornecedor_message"),accept:function(){var a=t.getFornecedoresForm().controls.indexOf(e);t.getFornecedoresForm().removeAt(a)}})},e.prototype.getFornecedoresForm=function(){return this.formGroup.get("fornecedores")},e.prototype.addContrato=function(e){var t=this;this.dialogService.open(vr,j({},Re,{header:"Adicionar Contrato",data:{agenda:this.agenda,filial:this.formGroup.get("filial").value,produto:this.formGroup.get("produto").value,fornecedor:e.get("fornecedor").value,contratos:e.get("contratos").value}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){var i=a.contrato;return t.onContratoSaved(i,e)})},e.prototype.removerContrato=function(e,t){this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_contrato_header"),message:this.translate.instant("yms.erp.remove_contrato_message"),accept:function(){var a=e.get("contratos").controls.indexOf(t);e.get("contratos").removeAt(a)}})},e.prototype.getContratos=function(e){return this.contratos=e.get("contratos"),this.contratos},e.prototype.addNota=function(e){var t=this;this.dialogService.open(ba,j({header:this.translate.instant("yms.erp.adicionar_nota")},Re,{data:{fornecedor:e.get("fornecedor").value,produto:this.formGroup.get("produto").value,filial:this.formGroup.get("filial").value,fornecedorNotasTokens:this.fornecedorNotasTokens,contratos:this.contratos}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){return t.onNotaSaved(a,e)})},e.prototype.removerNota=function(e,t,a){var i=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_nota_header"),message:this.translate.instant("yms.erp.remove_nota_message"),accept:function(){var r=t.value.contrato.id,o=i.getNotasFromContratos(e,r).controls.indexOf(a);i.getNotasFromContratos(e,r).removeAt(o);var n=a.value;i.fornecedorNotasTokens.push({id:n.chaveNotaFiscal,label:n.numeroNotaFiscal}),i.fornecedorNotas.push({chaveNotaFiscal:n.chaveNotaFiscal,serieNotaFiscal:n.serieNotaFiscal,serieLegalNotaFiscal:n.serieLegalNotaFiscal,numeroNotaFiscal:n.numeroNotaFiscal})}})},e.prototype.getNotas=function(e){return e.controls.notas},e.prototype.getItensContrato=function(e){return e.get("itens")},e.prototype.showButtons=function(){return!!this.agenda&&(this.isNew()||[St.AGENDADO,St.AGUARDANDO_CONFIRMACAO,St.AGUARDANDO_CONFIRMACAO_SOLICITANTE,St.REJEITADO_POR_VALIDACAO].includes(this.agenda.status))},e.prototype.disableAdicionarNota=function(){return null===this.contratoSelecionado},e.prototype.getTipoTransgenia=function(){if(this.formGroup.get("fornecedores").length<=0)return null;var e=null;return Fr.toDto(this.formGroup.getRawValue()).fornecedores.forEach(function(t){null!=t.fornecedor&&null!=t.fornecedor.tipoParticipante&&(e=t.fornecedor.tipoParticipante)}),e},e.prototype.getFamiliaProduto=function(){var e=this.formGroup.get("produto").value;return e&&e.familia&&e.familia.codigo?e.familia.codigo:e&&e.familia?e.familia:null},e.prototype.geraFiltroTransgenia=function(){var e="empresa.id eq '"+this.formGroup.get("filial").value.empresa.id+"'";e+="and situacao eq '"+$i.ATIVO+"'";var t=this.getFamiliaProduto();t&&(e+=" and ",e+="familia eq '"+t+"'");var a=this.getTipoTransgenia();return a&&(e+=" and ",e+="tipoParticipante eq '"+a+"'"),e},e.prototype.getNotaForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({chaveNotaFiscal:[e.chaveNotaFiscal],serieNotaFiscal:[e.serieNotaFiscal],serieLegalNotaFiscal:[e.serieLegalNotaFiscal],numeroNotaFiscal:[e.numeroNotaFiscal]})},e.prototype.getContratoForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({contrato:[e.contrato,C.Validators.required],itens:this.formBuilder.array([]),notas:this.formBuilder.array([])})},e.prototype.getItemForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({item:[e.item,C.Validators.required],quantidade:[e.quantidade]})},e.prototype.getFornecedorForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({fornecedor:[e.fornecedor,C.Validators.required],origemMercadoria:[e.origemMercadoria,C.Validators.compose([C.Validators.required])],tipoNotaFiscal:[e.tipoNotaFiscal||zi.EMPRESA_JURIDICA,C.Validators.compose([])],contratos:this.formBuilder.array([])})},e.prototype.getFormGroup=function(){return this.formBuilder.group({id:[{value:undefined,disabled:!0},C.Validators.compose([])],filial:[{value:undefined,disabled:!1},C.Validators.required],produto:[{value:undefined,disabled:!0},C.Validators.compose([C.Validators.required])],derivacao:[{value:undefined,disabled:!0},C.Validators.compose([])],transportadora:[{value:undefined,disabled:!1},C.Validators.compose([])],agenda:[{value:this.agenda,disabled:!1},C.Validators.compose([C.Validators.required])],transgenia:[{value:undefined,disabled:!0},C.Validators.compose([])],fornecedores:this.formBuilder.array([]),createdBy:[{value:undefined,disabled:!0},C.Validators.compose([])],createdDate:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedBy:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedDate:[{value:undefined,disabled:!0},C.Validators.compose([])],custom:[]})},e.prototype.getFornecedorByContrato=function(e,t){this.pessoaService.list({size:1,page:0,filterQuery:"id eq '"+e.pessoa.id+"'"}).pipe(a.takeUntil(this.ngUnsubscribe),a.map(function(e){var t=e.contents;return(t||[]).length&&t[0]}),a.filter(function(e){return!!e})).subscribe(function(e){t.get("fornecedor").setValue(ta.fromDto(e))})},e.prototype.getProdutoByContrato=function(e){var i=this;this.contratoCompraService.listItens(e.id,{size:1,page:0,displayFields:["sku.id"]}).pipe(a.takeUntil(this.ngUnsubscribe),a.mergeMap(function(e){var r=e.contents;return 1===r.length?i.produtoService.list({size:1,page:0,filterQuery:"id eq '"+r[0].sku.id+"'"}).pipe(a.takeUntil(i.ngUnsubscribe),a.map(function(e){var t=e.contents;return(t||[]).length&&t[0]})):t.empty()}),a.filter(function(e){return!!e})).subscribe(function(e){i.formGroup.get("produto").setValue(Li.fromDto(e)),i.formGroup.get("produto").disable()})},e.prototype.onContratoSaved=function(e,t){var a=this;this.formGroup.get("produto").value||this.getProdutoByContrato(e.contrato),t.get("fornecedor").value||this.getFornecedorByContrato(e.contrato,t);var i=this.getContratoForm(e);(e.itens||[]).forEach(function(e){return i.get("itens").push(a.getItemForm(e))}),this.getContratos(t).push(i)},e.prototype.mensagemContratoNaoSelecionado=function(){this.addMessage("error","Contrato não selecionado","Nenhum contrato foi selecionado!")},e.prototype.onNotaSaved=function(e,t){if(null!==this.contratoSelecionado)if(e.addFornecedor){var a=this.formGroup.get("fornecedores").controls.find(function(t){return(t.value.fornecedor||{id:undefined}).id===e.fornecedor.id}),i=e.infoNota,r=this.getNotaForm({chaveNotaFiscal:i.chave,serieNotaFiscal:i.serie,serieLegalNotaFiscal:i.serieLegal,numeroNotaFiscal:i.numero});if(a)(n=this.getNotasFromContratos(a,this.contratoSelecionado.id)).push(r);else if(t.get("fornecedor").value){var o=this.addFornecedor({fornecedor:ta.fromDto(e.fornecedor),origemMercadoria:pa.fromDto(e.origemMercadoria)});(n=this.getNotasFromContratos(o,this.contratoSelecionado.id)).push(r)}else{t.get("fornecedor").setValue(ta.fromDto(e.fornecedor)),t.get("origemMercadoria").setValue(pa.fromDto(e.origemMercadoria)),(n=this.getNotasFromContratos(t,this.contratoSelecionado.id)).push(r)}}else{var n;null!==(n=this.getNotasFromContratos(t,this.contratoSelecionado.id))&&n.push(this.getNotaForm(e))}else this.mensagemContratoNaoSelecionado()},e.prototype.getNotasFromContratos=function(e,t){var a,i,r=null,o=e.controls.contratos.controls;try{for(var n=z(o),s=n.next();!s.done;s=n.next()){var l=s.value;l.controls.contrato.value.id===t&&(r=l.controls.notas)}}catch(d){a={error:d}}finally{try{s&&!s.done&&(i=n["return"])&&i.call(n)}finally{if(a)throw a.error}}return r},e.prototype.addFornecedorNotasTokenEmContrato=function(e,t){if(null!==this.contratoSelecionado){var a=this.fornecedorNotas.filter(function(e){return e.chaveNotaFiscal===t.id}),i=this.getNotasFromContratos(e,this.contratoSelecionado.id);null!==i&&null!==a[0]&&i.push(this.getNotaForm(a[0])),this.removeFornecedorNotasTokenDoContrato(t)}else this.mensagemContratoNaoSelecionado()},e.prototype.removeFornecedorNotasTokenDoContrato=function(e){this.fornecedorNotasTokens.splice(this.fornecedorNotasTokens.indexOf(e),1),this.fornecedorNotas=this.fornecedorNotas.filter(function(t){return t.chaveNotaFiscal!==e.id})},e.prototype.removeNotaError=function(){this.erroFornecedoresNotaDuplicada=null,this.erroChaveNota=!1},e.prototype.addNotaError=function(){this.erroChaveNota=!0},e.prototype.validateProduto=function(e){return this.formGroup.get("produto").value.id===e.id},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.filial_nome"),type:n.FieldType.String})]},e.prototype.getFornecedorSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.pessoa_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.pessoa_nome"),type:n.FieldType.String}),new n.FormField({name:"cpfCnpj",label:this.translate.instant("yms.erp.pessoa_cpfCnpj"),type:n.FieldType.String})]},e.prototype.getFornecedorSearchGridFields=function(){return this.getFornecedorSearchFields()},e.prototype.getOrigemMercadoriaFields=function(){return[this.buildFormField.buildForInteger("codigo","yms.erp.pessoa_endereco_codigo"),this.buildFormField.buildForString("cnpjCpf","yms.erp.pessoa_endereco_cnpj_cpf"),this.buildFormField.buildForString("inscricaoEstadual","yms.erp.pessoa_endereco_inscricao_estadual"),this.buildFormField.buildForString("cep","yms.erp.pessoa_endereco_cep"),this.buildFormField.buildForString("endereco","yms.erp.pessoa_endereco_endereco"),this.buildFormField.buildForString("numero","yms.erp.pessoa_endereco_numero"),this.buildFormField.buildForString("bairro","yms.erp.pessoa_endereco_bairro")]},e.prototype.getOrigemMercadoriaGridFields=function(){var e=this.getOrigemMercadoriaFields();return e.push(this.buildFormField.buildForString("empresa.descricao","yms.erp.empresa")),e},e.prototype.getProdutoSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.produto_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.produto_descricao"),type:n.FieldType.String})]},e.prototype.getProdutoSearchGridFields=function(){var e=this.getProdutoSearchFields();return e.push(new n.FormField({name:"descricaoComplementar",label:this.translate.instant("yms.erp.produto_descricao_complementar"),type:n.FieldType.String})),e},e.prototype.getAgendaSearchFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getAgendaSearchGridFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransgeniaSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_descricao")})]},e.prototype.getTransgeniaSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_descricao")})]},e.prototype.goBack=function(){this.router.navigate(["../"],{relativeTo:this.route.parent})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup?t.validateAllFormFields(i):i instanceof C.FormArray&&i.controls.forEach(function(e){return t.validateAllFormFields(e)})}),this.focusService.focusFirstInvalidInput()},e.prototype.getSaveObservable=function(){var e=this.formGroup.getRawValue();e.agenda=this.agenda;var t,a=Fr.toDto(e),i=a.fornecedores;if(a.fornecedores.forEach(function(e){a.fornecedores.forEach(function(t){e.fornecedor.id===t.fornecedor.id&&e.origemMercadoria.id===t.origemMercadoria.id&&(t.contratos.forEach(function(t){return e.contratos.push(t)}),i=i.splice(i.indexOf(t),1))})}),a.fornecedores=i,this.isNew()&&!e.id)t=this.recebimentoService.insert(a);else{var r=e.id;t=this.recebimentoService.update(r,a)}return t},e.prototype.getDeleteObservable=function(){var e=this;return this.recebimentoService["delete"]("").pipe(a.tap(function(){e.addMessage("success","yms.erp.deleted_message_title","yms.erp.deleted_message_content"),e.goBack()}))},e.prototype.validateVisualization=function(){ke(this.formGroup,this.allPermissions)||this.addMessage("error","yms.erp.cannot_visualize_form_summary","yms.erp.cannot_visualize_form_detail")},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.buscarFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length?this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&e.formGroup.get("filial").setValue(ma.fromDto(a[0])),e.formCarregado=!0}):this.formCarregado=!0},e.prototype.configureFornecedor=function(e){var t=this;e.get("fornecedor").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.debounceTime(500),a.tap(function(a){if(a)return t.ehPessoaJuridica(a)?(e.get("tipoNotaFiscal").setValue(zi.EMPRESA_JURIDICA),void e.get("tipoNotaFiscal").enable()):(e.get("tipoNotaFiscal").setValue(zi.PRODUTOR_RURAL),void e.get("tipoNotaFiscal").disable());e.get("tipoNotaFiscal").setValue(zi.EMPRESA_JURIDICA),e.get("tipoNotaFiscal").disable()}),a.filter(function(e){return!!e||(t.formGroup.get("transgenia").setValue(null),t.formGroup.get("transgenia").disable(),!1)}),a.mergeMap(function(e){return t.pessoaEnderecoService.list({size:10,page:0,filterQuery:"situacao eq 'ATIVO' and pessoa.id eq '"+e.id+"'"}).pipe(a.takeUntil(t.ngUnsubscribe))})).subscribe(function(a){var i=a.contents;t.formGroup.get("transgenia").enable(),1===i.length?e.get("origemMercadoria").setValue(pa.fromDto(i[0])):(e.get("origemMercadoria").setValue(undefined),e.get("origemMercadoria").enable())})},e.prototype.ehPessoaJuridica=function(e){return(e.cpfCnpj||"").replace(/\D+/g,"").length>11},e.prototype.mensagemBuscandoNota=function(){this.messageService.add({severity:"info",summary:"Buscando dados da nota",detail:"Aguarde, buscando dados da nota",life:5e3})},e.prototype.validarCnpjFornecedor=function(e){return!!this.ehPessoaJuridica({cpfCnpj:e})&&this.formGroup.get("fornecedores").controls.find(function(t){return(t.value.fornecedor||{cpfCnpj:""}).cpfCnpj.substring(0,8)===e.substring(0,8)})},V([r.Input(),B("design:type",qe)],e.prototype,"agenda",void 0),V([r.ViewChild("customTemplate"),B("design:type",r.TemplateRef)],e.prototype,"customTemplate",void 0),V([r.ViewChild("customFormFields"),B("design:type",r.TemplateRef)],e.prototype,"customFormFields",void 0),e=V([r.Component({selector:"recebimento-form",template:'<p-confirmDialog [acceptLabel]="\'yes\' | translate" acceptIcon="" [rejectLabel]="\'no\' | translate" rejectIcon=""></p-confirmDialog>\n<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 ui-md-6">\n <label for="chaveNotaFiscal">{{"yms.erp.recebimento_chave_nota_fiscal" | translate}}</label>\n <input\n id="chaveNotaFiscal"\n trim\n [class.ng-invalid]="erroChaveNota"\n [(ngModel)]="chaveNotaFiscal"\n [ngModelOptions]="{ standalone: true }"\n type="text"\n name="chaveNotaFiscal"\n pInputText\n autocomplete="off"\n (blur)="onBlurChaveNotaFiscal()"\n />\n <span class="nota-error" *ngIf="erroChaveNota">{{\'yms.erp.produto_nota_error_detail\' | translate}}</span>\n </div>\n </div>\n <div class="ui-fluid">\n <div class="ui-g">\n <div [attr.data-hidden]="true" class="ui-g-12 ui-md-6">\n <label for="id">{{"yms.erp.recebimento_id" | translate}}</label>\n <input #idFormInput type="text" id="id" name="id" pInputText formControlName="id" autocomplete="off" />\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="filial">{{"yms.erp.filial" | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions"\n (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="produto">{{"yms.erp.recebimento_produto" | translate}}</label>\n <s-lookup dataKey="id" id="produto" name="produto" formControlName="produto"\n [searchFields]="produtoSearchFields" [searchGridFields]="produtoSearchGridFields"\n [searchGridData]="produtoSearchGridData" [multiple]="false"\n [lookupSuggestions]="produtoLookupSuggestions"\n (onLookupRequest)="onProdutoLookupRequest($event)"\n (onSearchRequest)="onProdutoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]=produtoSearchTotalRecords\n [searchTitle]="\'yms.erp.recebimento_produto_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: produtoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'produto\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="derivacao">{{"yms.erp.recebimento_derivacao" | translate}}</label>\n <s-lookup dataKey="id" id="derivacao" name="derivacao" formControlName="derivacao"\n [searchFields]="derivacaoSearchFields" [searchGridFields]="derivacaoSearchGridFields"\n [searchGridData]="derivacaoSearchGridData" [multiple]="false"\n [lookupSuggestions]="derivacaoLookupSuggestions"\n (onLookupRequest)="onDerivacaoLookupRequest($event)"\n (onSearchRequest)="onDerivacaoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]=derivacaoSearchTotalRecords\n [searchTitle]="\'yms.erp.recebimento_derivacao_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: derivacaoSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="transportadora">{{"yms.erp.recebimento_transportadora" | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchGridFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="transgenia">{{"yms.erp.recebimento_transgenia" | translate}}</label>\n <s-lookup dataKey="id" id="transgenia" name="transgenia"\n formControlName="transgenia" [searchFields]="transgeniaSearchFields"\n [searchGridFields]="transgeniaSearchGridFields"\n [searchGridData]="transgeniaSearchGridData" [multiple]="false"\n [lookupSuggestions]="transgeniaLookupSuggestions"\n (onLookupRequest)="onTransgeniaLookupRequest($event)"\n (onSearchRequest)="onTransgeniaSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transgeniaSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_transgenia_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transgeniaSearchTotalRecords}">\n </s-lookup>\n </div>\n\n <div class="ui-md-12">\n <s-button styleClass="btn-erp-forms" *ngIf="showButtons() && !!formGroup.get(\'filial\').value && !createdByErp"\n iconClass="fas fa-plus" label="Adicionar fornecedor" priority="secondary" (onClick)="addFornecedor()"\n [disabled]="disableButtonSave || !permissions.editar"></s-button>\n <span style="display: block;" class="input-error" *ngIf="erroFornecedores">{{\'Selecione ao menos um fornecedor para continuar\' | translate}}</span>\n <span style="display: block;" class="input-error" *ngIf="erroFornecedoresNotaDuplicada">{{ erroFornecedoresNotaDuplicada }}</span>\n </div>\n\n <form class="ui-g-12" *ngFor="let fornecedorForm of getFornecedoresForm().controls; let i = index;" [formGroup]="fornecedorForm">\n <p-panel [style]="{position: \'relative\'}" styleClass="form-group ui-g-12 ui-md-12" [toggleable]="true" >\n\n <p-header>\n Fornecedor {{+i+1}}\n <s-button \n style="display: inline-block; position: absolute; right: 50px; top: 10px" \n *ngIf="showButtons() && !createdByErp"\n iconClass="fas fa-trash"\n label="Remover"\n priority="default"\n [auxiliary]="true"\n (onClick)="removeFornecedor(fornecedorForm)"\n >\n </s-button>\n </p-header>\n <div class="ui-g-12 ui-md-6 required">\n <label for="fornecedor">{{"yms.erp.recebimento_fornecedor" | translate}}</label>\n <s-lookup dataKey="id" id="fornecedor" name="fornecedor" formControlName="fornecedor"\n [searchFields]="fornecedorSearchFields" [searchGridFields]="fornecedorSearchGridFields"\n [searchGridData]="fornecedorSearchGridData" [multiple]="false"\n [lookupSuggestions]="fornecedorLookupSuggestions"\n (onLookupRequest)="onFornecedorLookupRequest($event)"\n (onSearchRequest)="onFornecedorSearchRequest($event)" \n lookupDisplayField="label"\n [searchTotalRecords]=fornecedorSearchTotalRecords\n [searchTitle]="\'yms.erp.recebimento_fornecedor_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: fornecedorSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="fornecedorForm.get(\'fornecedor\')"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="origemMercadoria">{{"yms.erp.recebimento_origem_mercadoria" | translate}}</label>\n <s-lookup dataKey="id" id="origemMercadoria" name="origemMercadoria"\n formControlName="origemMercadoria" [searchFields]="origemMercadoriaSearchFields"\n [searchGridFields]="origemMercadoriaSearchGridFields"\n [searchGridData]="origemMercadoriaSearchGridData" [multiple]="false"\n [lookupSuggestions]="origemMercadoriaLookupSuggestions"\n (onLookupRequest)="onOrigemMercadoriaLookupRequest($event, fornecedorForm)"\n (onSearchRequest)="onOrigemMercadoriaSearchRequest($event, fornecedorForm)" lookupDisplayField="label"\n [searchTotalRecords]="origemMercadoriaSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_pessoa_endereco_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: origemMercadoriaSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="fornecedorForm.get(\'origemMercadoria\')"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n\n <div class="ui-g-12">\n <label for="fornecedorNotas">Notas a serem adicionadas</label>\n <s-token-list id="fornecedorNotas" [tokens]="fornecedorNotasTokens" (tokenSelected)="addFornecedorNotasTokenEmContrato(fornecedorForm, $event)" (tokenRemoved)="removeFornecedorNotasTokenDoContrato($event)" [removableTokens]="true"></s-token-list>\n </div>\n\n <div class="ui-g-12">\n <s-button label="Adicionar nota" *ngIf="showButtons()" styleClass="btn-erp-forms" priority="secondary" (onClick)="addNota(fornecedorForm)" [disabled]="disableAdicionarNota()"></s-button>\n <s-button label="Adicionar contrato" *ngIf="showButtons() && !createdByErp" styleClass="btn-erp-forms" priority="secondary" (onClick)="addContrato(fornecedorForm)"></s-button>\n </div>\n\n <div class="ui-g-12 ui-md-6">\n <label for="tipoNotaFiscal">{{"yms.erp.recebimento_tipo_nota_fiscal" | translate}}</label>\n <p-dropdown inputId="tipoNotaFiscal" name="tipoNotaFiscal" [options]="tiposNota" formControlName="tipoNotaFiscal">\n </p-dropdown>\n </div>\n\n <div class="ui-g-12">\n <h4>Contratos</h4>\n <p-table [value]="getContratos(fornecedorForm).controls" [(selection)]="contratoSelecionado">\n <ng-template pTemplate="body" let-rowData>\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px">\n <p-tableRadioButton [value]="rowData.get(\'contrato\').value"></p-tableRadioButton>\n </td>\n <td>\n <p-accordion>\n <p-accordionTab>\n <p-header>\n Contrato {{rowData.get(\'contrato\').value.numero}}, Filial {{rowData.get(\'contrato\').value.filial?.codigo}}\n\n <span *ngIf="showButtons() && !createdByErp" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerContrato(fornecedorForm, rowData)"></span>\n </p-header>\n \n <div class="detail-pane" *ngFor="let item of getItensContrato(rowData).controls">\n <div class="detail-span">\n <span class="title">Sequência</span>\n <span class="data">{{item.value?.item.sequencia}}</span>\n </div>\n </div>\n \n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Notas</span>\n <span class="data">\n <p-accordion>\n <p-accordionTab *ngFor="let nota of getNotas(rowData).controls">\n <p-header>\n {{nota.get(\'chaveNotaFiscal\').value || (nota.get(\'serieNotaFiscal\').value + \' - \' + nota.get(\'numeroNotaFiscal\').value)}}\n\n <span *ngIf="showButtons()" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerNota(fornecedorForm, rowData, nota)"></span>\n </p-header>\n \n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Série nota fiscal</span>\n <span class="data">{{nota.value?.serieNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Série legal nota fiscal</span>\n <span class="data">{{nota.value?.serieLegalNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{nota.value?.numeroNotaFiscal}}</span>\n </div>\n </div>\n \n </p-accordionTab> \n </p-accordion>\n </span>\n </div>\n </div>\n </p-accordionTab>\n </p-accordion>\n </td>\n </tr>\n </ng-template>\n </p-table>\n </div>\n\n </p-panel>\n\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">{{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} / </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">{{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}</label>\n </div>\n </form>\n\n </div>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button *ngIf="showButtons()" priority="primary" [label]="\'save\' | translate" (onClick)="onSave()"\n [disabled]="disableButtonSave || !allPermissions.agenda.editar"></s-button>\n <s-button *ngIf="saveAndInitButton && showButtons()" priority="primary" [label]="\'save_and_init\' | translate"\n (onClick)="onSave(true)" [disabled]="disableButtonSave || !allPermissions.agenda.editar"></s-button>\n </div>\n</div>',providers:[c.ConfirmationService],styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),B("design:paramtypes",[Pt,F.Router,F.ActivatedRoute,I.MessageService,c.ConfirmationService,C.FormBuilder,o.TranslateService,G.HotkeysService,Be,Ue,qa,pi,Ha,Ma,Xa,ei,Ea,jt,ya,Di,c.DialogService,qt,ri,oi,Wt,ai,bi])],e)}(),Cr=function(){function e(e){this.recebimentoService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.recebimentoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Recebimento não encontrado.")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.recebimento=Fr.fromDto(t)})},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"recebimento-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_filial" | translate }}\n </span>\n <span class="data">\n {{ recebimento?.filial?.codigo }} - {{ recebimento?.filial?.nome }}\n </span>\n </div>\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_produto" | translate }}\n </span>\n <span class="data">{{ recebimento?.produto?.descricao }}</span>\n </div>\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_derivacao" | translate }}\n </span>\n <span class="data">{{ recebimento?.derivacao?.descricao }}</span>\n </div>\n </div>\n <div *ngFor="let fornecedor of recebimento?.fornecedores">\n <div class="separator"></div>\n <h3>Fornecedor - {{ fornecedor?.fornecedor?.nome }}</h3>\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_origem_mercadoria" | translate }}\n </span>\n <span class="data">\n {{ fornecedor?.origemMercadoria?.codigo }} - {{ fornecedor?.origemMercadoria?.cep }}\n </span>\n </div>\n </div>\n\n <div>\n <h4>Contratos</h4>\n <p-accordion>\n <p-accordionTab *ngFor="let contrato of fornecedor.contratos">\n <p-header>\n Contrato {{ contrato?.contrato?.numero }}, Filial {{ contrato?.contrato?.filial?.codigo }}\n </p-header>\n\n <div class="detail-pane" *ngFor="let item of contrato?.itens">\n <div class="detail-span">\n <span class="title">Sequência</span>\n <span class="data">{{ item?.item?.sequencia }}</span>\n </div>\n </div>\n\n <div *ngFor="let nota of contrato.notas">\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Chave nota fiscal</span>\n <span class="data">{{ nota?.chaveNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie nota fiscal</span>\n <span class="data">{{ nota?.serieNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie legal nota fiscal</span>\n <span class="data">{{ nota?.serieLegalNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{ nota?.numeroNotaFiscal }}</span>\n </div>\n </div>\n <hr />\n </div>\n </p-accordionTab>\n </p-accordion>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),B("design:paramtypes",[Pt])],e)}();function _r(){return[{name:"json",func:x},{name:"xml",func:L}]}var Ir=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(Ht).dispatch(Kt).dispatch(er)}return e=V([r.NgModule({declarations:[Ht,Dr,Ji,Kt,Xi,Cr,Hi,cr,pr,Yi,vr,va,ir,rr,er],entryComponents:[Ht,Kt,vr,va,er],exports:[Ht,Kt],imports:[i.CommonModule,C.FormsModule,C.ReactiveFormsModule,o.TranslateModule,n.CustomFieldsModule,n.ControlErrorsModule,N.DialogModule,n.EmptyStateModule,n.DynamicFormModule,n.TokenListModule,w.PanelModule,R.AccordionModule,D.InputTextModule,A.DropdownModule,n.ButtonModule,n.LoadingStateModule,n.NumberInputModule,E.ConfirmDialogModule,n.LocaleModule,p.IntegrationModule,Mi,m.PermissionsModule,v.DynamicDialogModule,Da,R.AccordionModule,l.TableModule,y.TabViewModule,n.LoadingStateModule,M.HighlightModule.forRoot({languages:_r}),G.HotkeyModule.forRoot(),Sa],providers:[Be,Ue,jt,Ut,Ri,dr,ar,Wt]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),Tr=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.url_dock="yms/dock/",i}return P(t,e),t.prototype.fallbackCall=function(e,t,a){return this.http.post(this.url_dock+"actions/setVagaInTransit",{plantId:e,vaga:t,plate:a}).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),kr=function(){function e(){}return e=V([r.NgModule({providers:[Tr]})],e)}();e.AgendaModule=Ca,e.AgendaService=qt,e.BalancaModule=ie,e.BalancasService=Z,e.CamerasModule=le,e.CamerasService=re,e.CancelasModule=X,e.CidadeModule=Ia,e.CidadeService=_a,e.ContratoCompraItemModule=ka,e.ContratoCompraItemService=Ta,e.ContratoCompraModule=Ra,e.ContratoCompraService=Ma,e.ControladorCancelaComponent=J,e.ControladorCancelaDescritor=W,e.ControladorCancelasService=K,e.CoreModule=Mi,e.DockModule=kr,e.DockService=Tr,e.DocumentListComponent=Ot,e.DocumentListModule=xt,e.ERP_ENVIRONMENT=Lt,e.ERP_SENIOR_HEADER=zt,e.EmpresaModule=wa,e.EmpresaService=Aa,e.ErpFormConfigService=oi,e.ErpProcessData=ii,e.ErpProcessService=ri,e.ErpSeniorModule=Ir,e.EstadoModule=Oa,e.EstadoService=Ga,e.ExpedicaoChegadaVeiculoOverride=Ut,e.ExpedicaoModule=hi,e.ExpedicaoService=Vt,e.FamiliaProdutoModule=La,e.FamiliaProdutoService=xa,e.FieldCustomizationService=Be,e.FilialModule=Pa,e.FilialService=qa,e.FormComponent=Ht,e.FormDescritor=$t,e.FormSamComponent=Ve,e.FormSamDescritor=je,e.FormWmsComponent=bt,e.FormWmsDescritor=yt,e.HasChangeService=ai,e.INFORMACAOES_ADICIONAIS_HEADER=vt,e.InfoComponent=Kt,e.InfoDescritor=Qt,e.IntegrationWebSocket=Y,e.LogsModule=fe,e.LogsService=pe,e.LprModule=ce,e.LprService=de,e.PaisModule=Va,e.PaisService=ja,e.PedidoVendaItemModule=Ba,e.PedidoVendaItemService=Ua,e.PedidoVendaModule=$a,e.PedidoVendaService=za,e.PessoaEnderecoModule=Ya,e.PessoaEnderecoService=Ha,e.PessoaFisicaModule=Ka,e.PessoaFisicaService=Qa,e.PessoaJuridicaModule=Ja,e.PessoaJuridicaService=Wa,e.PessoaModule=Za,e.PessoaService=Xa,e.PortariasComponent=ve,e.PortariasDescritor=ge,e.PortariasModule=Se,e.ProdutoModule=ti,e.ProdutoService=ei,e.RecebimentoChegadaVeiculoOverride=jt,e.RecebimentoContratoModule=ni,e.RecebimentoContratoService=Pt,e.RoyaltyModule=li,e.RoyaltyService=si,e.SAM_SENIOR_HEADER=Pe,e.SafraModule=ci,e.SafraService=di,e.SamSeniorModule=pt,e.SnapshotComponent=se,e.SnapshotDescritor=ne,e.TransportadoraModule=ui,e.TransportadoraService=pi,e.UnidadeMedidaModule=fi,e.UnidadeMedidaService=mi,e.VisitorListComponent=mt,e.VisitorListModule=ft,e.VisitorListService=ut,e.VisualizarBalancaComponent=te,e.VisualizarBalancaDescritor=ee,e.WmsModule=Gt,e.highlightLanguages=_r,e.ɵa=Q,e.ɵb=ae,e.ɵba=_t,e.ɵbb=Ct,e.ɵbc=Et,e.ɵbd=Rt,e.ɵbe=At,e.ɵbf=Nt,e.ɵbg=Bt,e.ɵbh=Dr,e.ɵbi=Ea,e.ɵbj=ya,e.ɵbk=Di,e.ɵbl=Wt,e.ɵbm=bi,e.ɵbn=Ji,e.ɵbo=Xi,e.ɵbp=Cr,e.ɵbq=Hi,e.ɵbr=gi,e.ɵbs=Ri,e.ɵbt=cr,e.ɵbu=Jt,e.ɵbv=Fi,e.ɵbw=dr,e.ɵbx=pr,e.ɵby=Yi,e.ɵbz=vr,e.ɵc=oe,e.ɵca=va,e.ɵcb=ir,e.ɵcc=_i,e.ɵcd=ar,e.ɵce=rr,e.ɵcf=Zi,e.ɵcg=er,e.ɵch=Ti,e.ɵci=Na,e.ɵcj=vi,e.ɵck=yi,e.ɵcl=Si,e.ɵcm=Ci,e.ɵcn=Ii,e.ɵco=ki,e.ɵcp=Da,e.ɵcq=Sa,e.ɵcr=Fa,e.ɵcs=ba,e.ɵd=ue,e.ɵe=me,e.ɵf=he,e.ɵg=Fe,e.ɵh=ye,e.ɵi=be,e.ɵj=He,e.ɵk=Ye,e.ɵl=ze,e.ɵm=ct,e.ɵn=nt,e.ɵo=et,e.ɵp=tt,e.ɵq=Ze,e.ɵr=Xe,e.ɵs=Je,e.ɵt=Ue,e.ɵu=gt,e.ɵv=wt,e.ɵw=Tt,e.ɵx=Dt,e.ɵy=Ft,e.ɵz=It,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("rxjs"),require("rxjs/operators"),require("@angular/common"),require("@angular/core"),require("@ngx-translate/core"),require("@seniorsistemas/angular-components"),require("primeng/message"),require("primeng/table"),require("@angular/common/http"),require("primeng/api"),require("@seniorsistemas/yms-routines"),require("@angular/animations"),require("@seniorsistemas/platform-components"),require("@stomp/ng2-stompjs"),require("sockjs-client"),require("ngx-cookie-service"),require("primeng/components/dynamicdialog/dynamicdialog"),require("primeng/primeng"),require("@seniorsistemas/yms-components"),require("@angular/router"),require("primeng/inputswitch"),require("primeng/inputtext"),require("@angular/forms"),require("moment"),require("primeng/components/common/messageservice"),require("primeng/shared"),require("primeng/button"),require("ngx-highlightjs"),require("primeng/accordion"),require("primeng/confirmdialog"),require("primeng/dialog"),require("primeng/dropdown"),require("primeng/panel"),require("angular2-hotkeys"),require("primeng/components/common/api"),require("highlight.js/lib/languages/json"),require("highlight.js/lib/languages/xml")):"function"==typeof define&&define.amd?define("@seniorsistemas/yms-integration",["exports","rxjs","rxjs/operators","@angular/common","@angular/core","@ngx-translate/core","@seniorsistemas/angular-components","primeng/message","primeng/table","@angular/common/http","primeng/api","@seniorsistemas/yms-routines","@angular/animations","@seniorsistemas/platform-components","@stomp/ng2-stompjs","sockjs-client","ngx-cookie-service","primeng/components/dynamicdialog/dynamicdialog","primeng/primeng","@seniorsistemas/yms-components","@angular/router","primeng/inputswitch","primeng/inputtext","@angular/forms","moment","primeng/components/common/messageservice","primeng/shared","primeng/button","ngx-highlightjs","primeng/accordion","primeng/confirmdialog","primeng/dialog","primeng/dropdown","primeng/panel","angular2-hotkeys","primeng/components/common/api","highlight.js/lib/languages/json","highlight.js/lib/languages/xml"],t):t(((e=e||self).seniorsistemas=e.seniorsistemas||{},e.seniorsistemas["yms-integration"]={}),e.rxjs,e.rxjs.operators,e.ng.common,e.ng.core,e.core$1,e.angularComponents,e.message,e.table,e.ng.common.http,e.api,e.ymsRoutines,e.ng.animations,e.platformComponents,e.ng2Stompjs,e.SockJS,e.ngxCookieService,e.dynamicdialog,e.primeng,e.ymsComponents,e.ng.router,e.inputswitch,e.inputtext,e.ng.forms,e._moment,e.messageservice,e.shared,e.button,e.ngxHighlightjs,e.accordion,e.confirmdialog,e.dialog,e.dropdown,e.panel,e.angular2Hotkeys,e.api$1,e.jsonx,e.xmlx)}(this,function(e,t,a,i,r,o,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F,S,D,C,_,I,T,k,M,R,E,N,A,w,G,O,x,L){"use strict";x=x&&Object.prototype.hasOwnProperty.call(x,"default")?x["default"]:x,L=L&&Object.prototype.hasOwnProperty.call(L,"default")?L["default"]:L;var q=function(e,t){return(q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)t.hasOwnProperty(a)&&(e[a]=t[a])})(e,t)};function P(e,t){function a(){this.constructor=e}q(e,t),e.prototype=null===t?Object.create(t):(a.prototype=t.prototype,new a)}var j=function(){return(j=Object.assign||function(e){for(var t,a=1,i=arguments.length;a<i;a++)for(var r in t=arguments[a])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function V(e,t,a,i){var r,o=arguments.length,n=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,a):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,a,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(n=(o<3?r(n):o>3?r(t,a,n):r(t,a))||n);return o>3&&n&&Object.defineProperty(t,a,n),n}function U(e,t){return function(a,i){t(a,i,e)}}function B(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function z(e){var t="function"==typeof Symbol&&e[Symbol.iterator],a=0;return t?t.call(e):{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}}}function $(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var i,r,o=a.call(e),n=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)n.push(i.value)}catch(s){r={error:s}}finally{try{i&&!i.done&&(a=o["return"])&&a.call(o)}finally{if(r)throw r.error}}return n}function H(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat($(arguments[t]));return e}var Y=function(){function e(e,a,i){this._client=e;var r=JSON.parse(a.get("com.senior.token")),o=r.access_token,n=r.username.split("@")[1];this._subscriptionUrl="/topic/"+n+"/"+o+"/yms/"+i+"/",this._unsubscribe$=new t.Subject}return e.prototype.connect=function(e){var t=this;this._client.connectObservable.pipe(a.takeUntil(this._unsubscribe$)).subscribe(function(a){return e(t._subscriptionUrl,t._client,a)})},e.prototype.dispose=function(){this._unsubscribe$.next(),this._unsubscribe$.complete()},e}(),Q=function(){function e(e){this.messageService=e}return e.prototype.getListQueryParams=function(e){var t=e.page,a=void 0===t?0:t,i=e.size,r=void 0===i?10:i,o=e.sort,n=void 0===o?[]:o,s=e.filterQuery,l=void 0===s?"":s,c=e.displayFields,p=void 0===c?[]:c,u=new d.HttpParams;return u=(u=u.append("size",String(r))).append("offset",String(a)),n&&n.length&&(u=u.append("orderby",n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", "))),l&&(u=u.append("filter",l)),p&&p.length&&(u=u.append("displayfields",p.join())),u},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e}(),K=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.url="yms/integration/",i}return P(t,e),t.prototype.listGateByArea=function(e){var t=this.getListQueryParams({size:1e3,page:0,displayFields:["*"],filterQuery:"area.id eq '"+e+"'"});return this.http.get(this.url+"entities/gate",{params:t})},t.prototype.openGate=function(e){return this.http.post(this.url+"actions/openGate",{ip:e}).pipe(this.defaultCatch())},t.prototype.closeGate=function(e){return this.http.post(this.url+"actions/closeGate",{ip:e}).pipe(this.defaultCatch())},t.prototype.checkAccess=function(e){var t={includeFilters:!1,permissions:e};return this.http.post("platform/authorization/queries/checkAccess",t).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),W=function(){function e(){}return e=V([p.ControleCircuito({header:"Cancelas",name:"yms.integracao.devices"}),p.ControleOperacao({header:"Cancelas",name:"yms.integracao.devices"})],e)}(),J=function(e){function i(a,i){var r=e.call(this)||this;return r.service=a,r.translate=i,r.successState="default",r.permissionOpenGate=!1,r.permissionCloseGate=!1,r.uriGateDefault="res://senior.com.br/yms/devices/gate",r.unsubscribe$=new t.Subject,r.gates$=new t.Subject,r}return P(i,e),i.prototype.ngOnInit=function(){this.checkPermissionsGates()},i.prototype.checkPermissionsGates=function(){var e=this;this.service.listGateByArea(this.sequenciaCircuito.area.id).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(t){var a=t.contents,i=e.buildResourceGateAndAction(a);i.length<=0||e.checkAcessPermissionGate(i,a)})},i.prototype.buildResourceGateAndAction=function(e){var t=[];return t.push({resource:this.uriGateDefault,action:"Close"}),t.push({resource:this.uriGateDefault,action:"Open"}),e.filter(function(e){e.resourceUri!==undefined&&(t.push({resource:e.resourceUri,action:"Close"}),t.push({resource:e.resourceUri,action:"Open"}))}),t},i.prototype.checkAcessPermissionGate=function(e,t){var i=this;this.service.checkAccess(e).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return i.loading=undefined})).subscribe(function(e){var a=e.permissions;i.gates$.next(i.buildGateWithActionsAndPermissions(a,t))})},i.prototype.buildGateWithActionsAndPermissions=function(e,t){var a=this,i=[];return t.filter(function(t){if(t.isActionButton=!1,t.actions=[],a.permissionCloseGate&&a.permissionOpenGate)return t.isActionButton=!0,void i.push(t);e.filter(function(e){t.isActionButton=!!t.isActionButton||a.checkDefaultGatePermission(e,t),t.resourceUri===e.resource&&(t.actions.push({action:e.action,authorized:e.authorized}),t.isActionButton=!!t.isActionButton||e.authorized)}),i.push(t)}),i},i.prototype.checkDefaultGatePermission=function(e,t){if(this.uriGateDefault===e.resource){if("Open"===e.action)return this.permissionOpenGate=e.authorized,e.authorized;if("Close"===e.action)return this.permissionCloseGate=e.authorized,e.authorized}return!1},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},i.prototype.model=function(e){var t=this,a=!1,i=!1;return this.permissionCloseGate&&this.permissionOpenGate||e.actions.filter(function(e){"Open"===e.action&&(a=e.authorized),"Close"===e.action&&(i=e.authorized)}),!0===this.permissionOpenGate&&(a=this.permissionOpenGate),!0===this.permissionCloseGate&&(i=this.permissionCloseGate),[{label:this.translate.instant("yms.integration.open_gate"),visible:a,command:function(){return t.openGate(e)}},{label:this.translate.instant("yms.integration.close_gate"),visible:i,command:function(){return t.closeGate(e)}}]},i.prototype.openGate=function(e){var t=this;this.loading=e.id,this.service.openGate(e.ip).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return t.loading=undefined})).subscribe(function(a){return t.successState=e.id})},i.prototype.closeGate=function(e){var t=this;this.loading=e.id,this.service.closeGate(e.ip).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return t.loading=undefined})).subscribe(function(a){return t.successState=e.id})},V([r.Input(),B("design:type",Object)],i.prototype,"sequenciaCircuito",void 0),i=V([r.Component({selector:"controlador-cancela-component",template:'<div>\n <p-table [value]="gates$ | async">\n <ng-template pTemplate="header">\n <tr>\n <th>{{\'yms.integration.gate_ip\' | translate}}</th>\n <th>{{\'yms.integration.gate_type\' | translate}}</th>\n <th></th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData>\n <tr \n [@success]="successState === rowData.id ? successState : \'default\'" \n (@success.done)="successState = \'default\'"\n >\n <td>{{rowData.ip}}</td>\n <td>{{rowData.type | translate}}</td>\n <td>\n <div *ngIf="rowData.isActionButton">\n <span *sLoadingState="loading === rowData.id" >\n <s-button priority="default" [auxiliary]="true" label="Ações" [model]="model(rowData)" >\n </s-button>\n </span>\n </div>\n </td>\n </tr>\n </ng-template>\n </p-table>\n</div>',animations:[u.trigger("success",[u.state("*",u.style({backgroundColor:"#0C9348",opacity:.5})),u.state("default",u.style({backgroundColor:"#FFF",opacity:1})),u.transition("* => default",u.animate("1.2s ease-in")),u.transition("default => *",u.animate("0s"))])]}),B("design:paramtypes",[K,o.TranslateService])],i)}(W),X=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(J)}return e=V([r.NgModule({imports:[i.CommonModule,l.TableModule,o.TranslateModule,s.MessageModule,n.ButtonModule,n.LoadingStateModule,m.PermissionsModule.forChild([{name:"gate",actions:["Open","Close"],uri:"res://senior.com.br/yms/devices/gate"}])],declarations:[J],entryComponents:[J],exports:[J],providers:[K]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),Z=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.urlIntegration="yms/integration/",i.urlBalanca="yms/balanca/",i}return P(t,e),t.prototype.getWeightScaleByArea=function(e){var t={displayFields:["description","code"],page:0,size:1e3,filterQuery:"area.id eq '"+e+"'"};return this.http.get(this.urlIntegration+"entities/weightScale",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.fallbackCall=function(e,t){return this.http.post(this.urlBalanca+"actions/manualWeight",{code:e,weight:t}).pipe(this.defaultCatch())},t.prototype.getStabilizedWeight=function(e){return this.http.post(this.urlBalanca+"queries/getStabilizedWeight",{code:e}).pipe(this.defaultCatch())},t.prototype.getWeightScaleByCode=function(e){var t={displayFields:["description","code"],page:0,size:10,filterQuery:"code eq '"+e+"'"};return this.http.get(this.urlIntegration+"entities/weightScale",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),ee=function(){function e(){}return e=V([p.ControleCircuito({header:"Balanças",name:"yms.integracao.devices"}),p.ControleOperacao({header:"Balanças",name:"yms.integracao.devices"})],e)}(),te=function(e){function i(a){var i=e.call(this)||this;return i.service=a,i.loading=!1,i.unsubscribe$=new t.Subject,i.weightScales$=new t.BehaviorSubject([]),i.weightScaleValues=new Map,i}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this.sequenciaCircuito&&(this.loading=!0,this.service.getWeightScaleByArea(this.sequenciaCircuito.area.id).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(t){var a=t.contents;e.weightScales$.next(a),a.forEach(function(t){e.weightScaleValues.set(t.id,0),e.service.getStabilizedWeight(t.code).subscribe(function(a){e.weightScaleValues.set(t.id,a.weight)})})}))},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},V([r.Input(),B("design:type",Object)],i.prototype,"sequenciaCircuito",void 0),i=V([r.Component({selector:"visualizar-balanca-component",template:'<div *sLoadingState="loading">\n <p-table [value]="weightScales$ | async">\n <ng-template pTemplate="header">\n <tr>\n <th>Código</th>\n <th>Descrição</th>\n <th>Peso</th>\n </tr>\n </ng-template>\n <ng-template let-rowData pTemplate="body">\n <tr>\n <td>{{rowData.code}}</td>\n <td>{{rowData.description}}</td>\n <td>{{weightScaleValues.get(rowData.id)}}</td>\n </tr>\n </ng-template>\n </p-table>\n</div>'}),B("design:paramtypes",[Z])],i)}(ee),ae=function(e){function t(){var t=e.call(this)||this,a=t.getCookieObject("com.senior.token").access_token,i=t.getCookie("com.senior.base.url")+"/websocket/subscription";return t.socketProvider=function(){return new h(i)},t.configureConfig(a),t}return P(t,e),t.prototype.getCookieObject=function(e){var t=this.getCookie(e);return t?JSON.parse(t):t},t.prototype.getCookie=function(e){try{for(var t=e+"=",a=decodeURIComponent(document.cookie).split(";"),i=0;i<a.length;i++){for(var r=a[i];" "==r.charAt(0);)r=r.substring(1);if(0==r.indexOf(t))return r.substring(t.length,r.length)}return null}catch(o){return null}},t.prototype.configureConfig=function(e){this.url=this.socketProvider,this.headers={"content-type":"application/json",Authorization:"Bearer "+e,"Access-Control-Allow-Origin":"*"},this.heartbeat_in=1e4,this.heartbeat_out=1e4,this.reconnect_delay=15e3,this.debug=!1},t}(f.StompConfig),ie=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(te)}return e=V([r.NgModule({imports:[i.CommonModule,l.TableModule,s.MessageModule,n.LoadingStateModule],declarations:[te],entryComponents:[te],exports:[te],providers:[Z,g.CookieService,f.StompService,{provide:f.StompConfig,useClass:ae}]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),re=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.url="yms/integration/",i.patioUrl="yms/patio/",i}return P(t,e),t.prototype.getCamerasByArea=function(e){var t={page:0,size:1e3,filterQuery:"area.id eq '"+e+"'",displayFields:["id","description","ip"]};return this.http.get(this.url+"entities/camera",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.takeSnapshot=function(e){return this.http.get(this.url+"queries/fetchSnapshot",{params:{ip:e.ip}}).pipe(this.defaultCatch())},t.prototype.saveSnapshotInCircuit=function(e){return this.http.post(this.patioUrl+"actions/adicionaImagemExecucaoCircuito",e).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),oe=function(){function e(e,a,i,r){this.dialogRef=e,this.dialogConfig=a,this.service=i,this.messageService=r,this.loading=!1,this.unsubscribe$=new t.Subject}return e.prototype.ngOnInit=function(){this.imageUrl=this.dialogConfig.data.url},e.prototype.save=function(){var e=this;this.loading=!0;var t=this.dialogConfig.data.execucaoCircuito,i=this.dialogConfig.data.cameraIp;this.service.saveSnapshotInCircuit({execucaoCircuitoId:t.id,alvoId:t.sequenciaCircuito.id,cameraIp:i,imagemUrl:this.imageUrl}).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(){e.messageService.add({severity:"success",summary:"Salvo com sucesso!",detail:"Imagem salva com sucesso"}),e.dialogRef.close()})},e.prototype.close=function(e){this.dialogRef.close(e)},e=V([r.Component({selector:"view-image-component",template:'\n <s-loading-state [loading]="loading">\n <img [src]="imageUrl" width="100%">\n <br>\n </s-loading-state>\n\n <div style="position: absolute; bottom: 0; width: 670px; padding-top: 10px; border-top: 1px solid #ccc;" [style.pointer-events]="loading ? \'none\' : \'all\'">\n <s-button priority="primary" label="Salvar" (onClick)="save()"></s-button>\n <s-button priority="link" label="Cancelar" (onClick)="close()"></s-button>\n </div> \n '}),B("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,re,c.MessageService])],e)}(),ne=function(){function e(){}return e=V([p.ControleOperacao({header:"Câmeras",name:"yms.integracao.devices"}),p.ControleCircuito({header:"Câmeras",name:"yms.integracao.devices"})],e)}(),se=function(e){function i(a,i){var r=e.call(this)||this;return r.service=a,r.dialogService=i,r.loadingAll=!1,r.loading=[],r.unsubscribe$=new t.Subject,r.cameras$=new t.Subject,r}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this.loadingAll=!0,this.service.getCamerasByArea(this.sequenciaCircuito.area.id).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loadingAll=!1})).subscribe(function(t){var a=t.contents;return e.cameras$.next(a)})},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},i.prototype.takeSnapshot=function(e){var t=this;this.loading.push(e.id),this.service.takeSnapshot(e).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){var a=t.loading.indexOf(e.id);t.loading.splice(a,1)})).subscribe(function(a){var i=a.url;t.dialogService.open(oe,{header:e.description,width:"700px",height:"600px",contentStyle:{height:"500px",overflow:"hidden"},data:{url:i,cameraIp:e.ip,execucaoCircuito:t.execucaoCircuito}})})},V([r.Input(),B("design:type",Object)],i.prototype,"sequenciaCircuito",void 0),V([r.Input(),B("design:type",Object)],i.prototype,"execucaoCircuito",void 0),i=V([r.Component({selector:"snapshot-component",template:'<div class="lista-cameras" *sLoadingState="loadingAll">\n <div class="camera" *ngFor="let camera of cameras$ | async">\n <span *sLoadingState="loading.includes(camera.id)">\n <div class="info">\n <div class="info-title">\n Descrição\n </div>\n <div class="info-data">\n {{camera.description}}\n </div>\n </div>\n\n <div class="info">\n <div class="info-title">\n IP\n </div>\n <div class="info-data">\n {{camera.ip}}\n </div>\n </div>\n\n <s-button priority="default" [auxiliary]="true" iconClass="fa fa-camera" (onClick)="takeSnapshot(camera)">\n </s-button>\n </span>\n </div>\n</div>',providers:[c.DialogService],styles:[".lista-cameras{display:flex;flex-direction:column}.lista-cameras .camera{width:100%;height:60px;border-bottom:1px solid #ccc;padding-left:20px}.lista-cameras .camera .info{width:40%;margin-top:5px;display:inline-block}.lista-cameras .camera .info .info-title{display:block;font-size:12px}.lista-cameras .camera .info .info-data{display:inline-block;font-size:16px;font-weight:800}"]}),B("design:paramtypes",[re,c.DialogService])],i)}(ne),le=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(se)}return e=V([r.NgModule({imports:[i.CommonModule,n.ButtonModule,n.LoadingStateModule,v.DynamicDialogModule],declarations:[se,oe],entryComponents:[se,oe],exports:[se],providers:[re]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),de=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.url="yms/integration/",i}return P(t,e),t.prototype.getLprByArea=function(e){var t={page:0,size:1e3,filterQuery:"area.id eq '"+e+"'",displayFields:["id","stream","description","area.*"]};return this.http.get(this.url+"entities/lprConfiguration",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.fallbackCall=function(e,t){return this.http.post(this.url+"actions/lprEventPublish",{stream:e,licencePlate:t}).pipe(this.defaultCatch())},t.prototype.getLprByCode=function(e){var t={page:0,size:10,filterQuery:"stream eq '"+e+"'",displayFields:["id","stream","description","locked"]};return this.http.get(this.url+"entities/lprConfiguration",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),ce=function(){function e(){}return e=V([r.NgModule({providers:[de]})],e)}(),pe=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.url="yms/integration/",i}return P(t,e),t.prototype.listLogByCircuit=function(e,t){return t.filterQuery="execucaoCircuitoId eq '"+e+"'",this.http.get(this.url+"entities/logCircuit",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),ue=function(){function e(){}return e=V([p.CircuitoFinalizado({header:"Logs com dispositivos",name:"yms.integracao.devices"})],e)}(),me=function(e){function i(a,i){var r=e.call(this)||this;return r.logsService=a,r.translate=i,r.unsubscribe$=new t.Subject,r}return P(i,e),i.prototype.ngOnInit=function(){this.columns=[{field:"username",header:this.translate.instant("yms.integration.usuario")},{field:"log",header:this.translate.instant("yms.integration.log")},{field:"createdDate",header:this.translate.instant("yms.integration.created_date")}]},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},i.prototype.onGridChange=function(e){var t=e.rows,a=e.first/t;this.updateGrid({size:t,page:a,sort:[{field:"createdDate",order:-1}]})},i.prototype.updateGrid=function(e){var t=this;this.loading=!0;var i=e.page,r=e.size,o=e.sort;this.logsService.listLogByCircuit(this.execucaoCircuito.id,{page:i,size:r,sort:o}).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(e){var a=e.contents,i=e.totalElements;t.logsData=a,t.totalRecords=i})},V([r.Input(),B("design:type",Object)],i.prototype,"execucaoCircuito",void 0),i=V([r.Component({template:'<p-table [columns]="columns" [value]="logsData" [paginator]="true" [lazy]="true" [totalRecords]="totalRecords"\nrows="10" [rowsPerPageOptions]="[10, 20, 50, 100]" (onLazyLoad)="onGridChange($event)">\n <ng-template pTemplate="header" let-columns>\n <tr>\n <th *ngFor="let column of columns">{{ column.header }}</th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData>\n <tr>\n <td>{{rowData.username}}</td>\n <td [pTooltip]="rowData.log">{{rowData.log}}</td>\n <td>{{rowData.createdDate | date: \'dd/MM/yyyy hh:mm:ss\'}}</td>\n </tr>\n </ng-template>\n</p-table>\n'}),B("design:paramtypes",[pe,o.TranslateService])],i)}(ue),fe=function(){function e(e){e.dispatch(me)}return e=V([r.NgModule({declarations:[me],entryComponents:[me],providers:[pe],imports:[i.CommonModule,l.TableModule,o.TranslateModule,y.TooltipModule,n.LoadingStateModule]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),he=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i}return P(t,e),t.prototype.agendas=function(e){return this.http.get("yms/patio/entities/agenda",{params:this.getListQueryParams(e)}).pipe(this.defaultCatch())},t.prototype.ultimaPlacaLida=function(e){return this.http.post("yms/integration/queries/getLastValidPlateByLpr",{stream:e}).pipe(this.defaultCatch())},t.prototype.getPortarias=function(e){return this.http.get("yms/integration/entities/lobby",{params:this.getListQueryParams({page:0,size:100,filterQuery:"planta.id eq '"+e+"'",displayFields:["description","entranceLpr.*","lprs.*","planta.*"]})}).pipe(this.defaultCatch())},t.prototype.executarEntrada=function(e,t){return this.http.post("yms/integration/actions/executeLobby",{lobbyId:e,plate:t}).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),ge=function(){function e(){}return e=V([p.ControleUnificado({header:"Periféricos",name:"yms.integracao.devices"})],e)}(),ve=function(e){function i(a,i){var r=e.call(this)||this;return r.selectPlantService=a,r.portariaService=i,r.unsubscribe$=new t.Subject,r}return P(i,e),i.prototype.ngOnInit=function(){var e=this,t=this.selectPlantService.getPlant();this.portariaService.getPortarias(t.id).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(t){var a=t.contents;return e.portarias=a})},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},i=V([r.Component({selector:"portarias",template:'\n <h3>Portarias</h3>\n <div class="separator"></div>\n <div class="ui-g">\n <portaria-entrada *ngFor="let portaria of portarias" class="ui-md-4" [portaria]="portaria"></portaria-entrada>\n </div>\n '}),B("design:paramtypes",[b.SelectPlantService,he])],i)}(ge),ye=function(){function e(e,a,i,r){this.dialogRef=e,this.dialogConfig=a,this.portariaService=i,this.router=r,this.unsubscribe$=new t.Subject}return e.prototype.ngOnInit=function(){var e=this;this.veiculo=this.dialogConfig.data.veiculo,this.portaria=this.dialogConfig.data.portaria,this.loading=!0,this.portariaService.agendas({size:100,page:0,displayFields:["veiculo.primario.*","tipoAgendamento.*","descricao","externalTenant","dataEsperadaAgendamento"],filterQuery:"veiculo.primario.placa eq '"+this.veiculo+"' and status eq 'AGENDADO' and planta eq '"+this.portaria.planta.id+"'"}).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(t){var a=t.contents;e.agendas=a,e.agendas.length?1===e.agendas.length&&(e.selected=e.agendas[0]):e.chegadaSimplificada()})},e.prototype.chegadaSimplificada=function(){this.router.navigate(["execucao-circuito/new"],{queryParams:{veiculo:this.veiculo,navigateTo:"processo-entrada"}}),this.dialogRef.close()},e.prototype.chegada=function(){this.selected&&(this.router.navigate(["execucao-circuito/"+this.selected.id]),this.dialogRef.close())},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.getColumns=function(){return[{field:"descricao",label:"Descrição"},{field:"dataEsperadaAgendamento",label:"Data"},{field:"tipoAgendamento",label:"Tipo de Agendamento"},{field:"externalTenant",label:"Parceiro"}]},e=V([r.Component({template:'\n <div style="width: 100%; height: calc(100% - 50px); overflow: auto;">\n <div *sLoadingState="loading">\n <p-table [value]="agendas" [columns]="getColumns()" selectionMode="single" [(selection)]="selected" dataKey="id">\n <ng-template pTemplate="header" let-columns>\n <tr>\n <th style="width: 50px;"></th>\n <th *ngFor="let column of columns">{{column.label}}</th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData>\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px;">\n <p-tableRadioButton [value]="rowData"></p-tableRadioButton>\n </td>\n <td>{{rowData[\'descricao\']}}</td>\n <td>{{rowData[\'dataEsperadaAgendamento\'] | date: \'dd/MM/yyyy HH:mm\'}}</td>\n <td>{{rowData[\'tipoAgendamento\']?.descricao}}</td>\n <td>{{rowData[\'externalTenant\']?.descricao}}</td>\n </tr>\n </ng-template>\n </p-table>\n </div>\n </div>\n <div style="position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: flex-end; height: 40px; align-items: center;">\n <s-button priority="primary" label="Registrar chegada" [disabled]="!selected" (onClick)="chegada()"></s-button>\n <s-button priority="primary" label="Registrar chegada simplificada" (onClick)="chegadaSimplificada()"></s-button>\n </div>\n '}),B("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,he,F.Router])],e)}(),be=function(){function e(e){this.dialogRef=e}return e.prototype["continue"]=function(){this.dialogRef.close({placa:this.placa})},e=V([r.Component({template:'\n <p>Não foi encontrada uma leitura de placa. Deseja informar a placa para realizar a entrada?</p>\n <div class="separator"></div>\n <input pInputText type="text" pattern="[A-Z0-9]{6,10}" maxlength="10" placeholder="Digite a placa" [(ngModel)]="placa" #placaInput>\n \n <div style="position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: flex-end; height: 40px; align-items: center;">\n <s-button priority="primary" label="Continuar" [disabled]="!placa || !placaInput.validity.valid" (onClick)="continue()"></s-button>\n </div>\n '}),B("design:paramtypes",[c.DynamicDialogRef])],e)}(),Fe=function(){function e(e,a,i,r){this.dialogService=e,this.portariaService=a,this.loading=!1,this.unsubscribe$=new t.Subject,this.websocket=new Y(i,r,"integration")}return e.prototype.ngOnInit=function(){var e=this;this.websocket.connect(function(t,i){i.subscribe(t+"wsLprLockUnlocked").pipe(a.map(function(e){return e.body}),a.map(function(e){return JSON.parse(e).data}),a.takeUntil(e.unsubscribe$)).subscribe(function(t){return e.portaria.lprs=e.portaria.lprs.map(function(e){return e.stream===t.stream?j({},e,{locked:t.locked}):e})})})},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.readPlaque=function(){var e=this;this.loading=!0,this.portariaService.ultimaPlacaLida(this.portaria.entranceLpr.stream).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(t){var a=t.plate;if(!a)return e.placaNaoEncontrada();e.openAgendas(a)})},e.prototype.placaNaoEncontrada=function(){var e=this;this.dialogService.open(be,{header:"Placa não encontrada",style:{display:"flex","flex-direction":"column"},height:"80%",styleClass:"ui-g-12 ui-md-8",contentStyle:{"overflow-y":"auto",height:"100%","max-height":"100%",flex:1}}).onClose.pipe(a.filter(function(e){return!!e})).subscribe(function(t){return e.openAgendas(t.placa)})},e.prototype.openAgendas=function(e){var t=this;this.portariaService.executarEntrada(this.portaria.id,e).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(){t.dialogService.open(ye,{header:"Agendamentos | "+e.toUpperCase(),style:{display:"flex","flex-direction":"column"},height:"80%",styleClass:"ui-g-12 ui-md-8",contentStyle:{"overflow-y":"auto",height:"100%","max-height":"100%",flex:1},data:{veiculo:e,portaria:t.portaria}})})},V([r.Input(),B("design:type",Object)],e.prototype,"portaria",void 0),e=V([r.Component({selector:"portaria-entrada",template:'\n <div class="card-entrada" *sLoadingState="loading">\n <div class="portaria-card">\n <h4>{{portaria?.description}}</h4>\n <s-button style="float: right" [auxiliary]="true" iconClass="fas fa-camera" priority="default" (onClick)="readPlaque()"></s-button>\n </div>\n <div class="portaria-card" *ngFor="let lpr of portaria.lprs">\n <h4>{{lpr.description || lpr.stream}}</h4>\n <p-inputSwitch styleClass="lprInputSwitch" [ngModel]="lpr.locked" [readonly]="true"></p-inputSwitch>\n </div>\n </div>\n ',providers:[c.DialogService],styles:[":host{display:block;padding:10px}.card-entrada{border-radius:20px;border:1px solid #ccc;padding:10px}.card-entrada .portaria-card{min-height:40px;display:flex;justify-content:space-between;align-items:center}"]}),B("design:paramtypes",[c.DialogService,he,f.StompService,g.CookieService])],e)}(),Se=function(){function e(e){e.dispatch(ve)}return e=V([r.NgModule({imports:[i.CommonModule,C.FormsModule,F.RouterModule,n.ButtonModule,l.TableModule,n.LoadingStateModule,S.InputSwitchModule,D.InputTextModule,v.DynamicDialogModule,d.HttpClientModule,b.SelectPlantModule,s.MessageModule],declarations:[ve,Fe,ye,be],entryComponents:[ve,ye,be],providers:[he,g.CookieService,f.StompService,{provide:f.StompConfig,useClass:ae}]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),De=[n.FieldType.Integer,n.FieldType.Double],Ce=/^\d+\b$/,_e=function(e,t){return e.concat(t.filter(function(t){return!e.includes(t)}))},Ie=function(e,t){var a=Te(e,t),i=a.isValidValue;return!(a.typeExists&&!i)},Te=function(e,t){switch(e){case n.FieldType.Time:case n.FieldType.Date:case n.FieldType.DateTime:return{isValidValue:!1,typeExists:!0};case n.FieldType.Integer:case n.FieldType.Double:default:return{isValidValue:t.match(Ce),typeExists:De.includes(e)}}},ke=function(e,t){return 0===Object.keys(e.controls).filter(function(a){var i=e.get(a).errors?e.get(a).errors.required:e.get(a).errors;return t[a]&&!t[a].visualizar&&i}).length},Me=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},Re={style:{display:"flex","flex-direction":"column"},height:"80%",styleClass:"ui-g-12 ui-md-4",contentStyle:{"overflow-y":"auto",height:"auto","max-height":"none","margin-bottom":"0",flex:1}},Ee=_;function Ne(e,t,a,i){void 0===e&&(e={}),void 0===t&&(t=[]);return t.map(function(t){return t.indexOf(".")>0?Me(e,t):e[t]}).join(a).split("-").reduce(function(e,t){return void 0===e&&(e=" "),void 0===t&&(t=" "),e.trim()&&t.trim()?e+" - "+t:e.trim()&&!t.trim()?""+e:!e.trim()&&t.trim()?""+t:void 0})||(i?"yms.erp.sem_descricao":" - ")}var Ae,we,Ge,Oe=function(e,t,i,r,o,s,l){void 0===l&&(l="");var d=t.map(function(e){return{field:e,order:1}}),c=e.filter(function(e){var t=e.type;return Ie(t,s)}).map(function(e){var t=e.name,a=e.type;return"number"==typeof s||a===n.FieldType.Integer?t+" eq "+s:a==n.FieldType.Date?t+" eq '"+Ee(s).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Ee(s).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Ee(s).format()+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+s.replace(/'/g,"\\'")+"'))":t+" eq '"+s+"'"}).join(" or ");l&&l.trim()&&(c=c?"("+c+") and "+l:l);var p=_e(t,i);return o.list({sort:d,filterQuery:c,displayFields:p}).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:Ne(e,t,r)})})})}))},xe=function(e,t,i,r,o,s,l){void 0===l&&(l="");var d=s.first,c=s.rows,p=s.multiSortMeta,u=s.filterData,m=d/c,f=p,h=e.filter(function(e){var t=e.name;return u[t]!=undefined&&""!=u[t]}).map(function(e){var t=e.name,a=e.type,i=u[t];return"number"==typeof i||a===n.FieldType.Integer?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Ee(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Ee(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Ee(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.Lookup?t+" eq '"+i.id+"'":a==n.FieldType.String&&-1!==t.indexOf(".")?"containing("+t+", '"+i.replace(/'/g,"\\'")+"')":a==n.FieldType.String&&-1===t.indexOf(".")?"containing(lower("+t+"),lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and ");h=l&&l.trim()?h.concat(h?" and ":"").concat(l):h;var g=_e(t,i);return o.list({page:m,sort:f,filterQuery:h,displayFields:g}).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:Ne(e,t,r)})})})}))},Le=_,qe=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Le(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Le(a.lastModifiedDate).toDate();return a.label=Ne(a,["descricao"]," - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Le(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Le(a.lastModifiedDate).format(),delete a.label,a},e}(),Pe="Ronda",je=function(){function e(){}return e=V([p.ChegadaVeiculo({header:Pe,name:"yms.integracao.sam",icon:"fal fa-shield"})],e)}(),Ve=function(e){function i(a){var i=e.call(this)||this;return i.integrationCallback=a,i.save=[],i.header=Pe,i.loading=!1,i.unsubscribe$=new t.Subject,i._integrationCallback=a,i}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this._integrationCallback.onAgendamentoSaved().pipe(a.takeUntil(this.unsubscribe$),a.mergeMap(function(a){e.save;return e.agenda=a,t.empty()})).subscribe()},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},V([r.Output(),B("design:type",qe)],i.prototype,"agenda",void 0),V([r.Input(),B("design:type",Array)],i.prototype,"save",void 0),i=V([r.Component({template:'\n <div *ngIf="agenda">\n <scheduling [agenda]="agenda"></scheduling>\n </div>\n '}),B("design:paramtypes",[p.IntegrationEventsCallback])],i)}(je),Ue=function(){function e(){}return e.prototype.focusFirstInvalidInput=function(){var e=Array.from(document.getElementsByClassName("ng-invalid")).find(function(e){return"FORM"!==e.nodeName});if(e)if("P-CALENDAR"===e.nodeName){var t=e.getAttribute("ng-reflect-input-id"),a=document.getElementById(t);a&&a.focus()}else if("S-LOOKUP"===e.nodeName){var i=this.getNestedInput(e.firstElementChild);i&&i.focus()}else e.focus()},e.prototype.getNestedInput=function(e){return"INPUT"===e.nodeName?e:this.getNestedInput(e.firstElementChild)},e=V([r.Injectable()],e)}(),Be=function(){function e(e,t){this.http=e,this.messageService=t,this.http=e,this.messageService=t,this.defaultCatch=this.defaultCatch.bind(this)}return e.prototype.commitFiles=function(e){return this.http.post("platform/field_customization/actions/commitObject",{objects:e}).pipe(this.defaultCatch())},e.prototype.deleteFiles=function(e){return this.http.post("platform/field_customization/actions/deleteObjects",e).pipe(this.defaultCatch())},e.prototype.getFiles=function(e){var t=this,a=[];e.value.custom&&(a=e.value.custom.fieldCustomization||[],delete e.value.custom.fieldCustomization);var i=[],r={};return a.forEach(function(e){var a=e.domain,o=e.service,n=e.entity,s=e.toDelete,l=e.toInsert;if(!t.isEmpty(l)){var d=Object.keys(l).map(function(e){return{version:l[e].version,fileName:l[e].name,objectId:l[e].objectId}});t.isEmpty(d)||i.push.apply(i,H(d))}if(!t.isEmpty(s)){var c=[];Object.keys(s).forEach(function(e){var t=(s[e]||[]).map(function(t){return{field:e,objectId:t}});c.push.apply(c,H(t))}),r={domain:a,service:o,entityName:n,objects:c}}}),{filesToCommit:i,filesToDelete:r}},e.prototype.isEmpty=function(e){return Array.isArray(e)?0===e.length:0===Object.entries(e).length&&e.constructor===Object},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,I.MessageService])],e)}(),ze=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.domainService="yms_int/sam",i}return P(t,e),t.prototype.getVisited=function(e){return this.http.post("yms_int/sam/queries/getVisited",{id:e})},t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(I.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,I.MessageService])],t)}(Q),$e=function(){return function(){}}(),He=function(){return function(){}}(),Ye=function(e){function i(a){var i=e.call(this)||this;return i.service=a,i.visited=new $e,i.ngUnsubscribe=new t.Subject,i.visitedService=a,i}return P(i,e),i.prototype.ngOnInit=function(){},i.prototype.ngAfterContentInit=function(){var e=this;this.agenda||console.error("agenda not found"),this.visitedService.getVisited(this.agenda.id).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){t&&(e.visited.name=t.name,e.visited.contactPhone=t.contactPhone)})},V([r.Input(),B("design:type",Object)],i.prototype,"agenda",void 0),i=V([r.Component({selector:"visited-info",template:'\n <div> \n <div class="info">\n <div class="info-title">\n Visitado:\n </div>\n <div class="info-data">\n {{ visited.name }} {{ visited.contactPhone }}\n </div>\n </div>\n </div>\n',styles:[".info{width:40%;margin-top:5px;display:inline-block}.info .info-title{display:block;font-size:12px}.info .info-data{display:inline-block;font-size:16px;font-weight:800}"]}),B("design:paramtypes",[ze])],i)}(He),Qe=function(){return function(){this.credentialCards=[]}}();!function(e){e.BARCODE_CARD="BARCODE_CARD",e.RFID_CARD="RFID_CARD",e.SMART_CARD="SMART_CARD"}(Ae||(Ae={})),function(e){e.CHECK_IN_PENDING="CHECK_IN_PENDING",e.CHECK_IN_REALIZED="CHECK_IN_REALIZED",e.VISITING="VISITING",e.CHECK_OUT_REALIZED="CHECK_OUT_REALIZED",e.CHECK_IN_NOT_REALIZED="CHECK_IN_NOT_REALIZED",e.CHECK_IN_EXPIRED="CHECK_IN_EXPIRED"}(we||(we={})),function(e){e.BARCODE_CARD="BARCODE_CARD",e.RFID_CARD="RFID_CARD",e.SMART_CARD="SMART_CARD"}(Ge||(Ge={}));var Ke,We=_,Je=function(){function e(e,a,i,r,o){this.fb=e,this.dialogRef=a,this.translate=i,this.route=r,this.dialogConfig=o,this.unsubscribe$=new t.Subject,this.technologies=[],this.localeConfig={}}return e.prototype.ngOnInit=function(){var e=this;this.formGroup=this.fb.group({tecnologiaCracha:[undefined,C.Validators.compose([C.Validators.required])],numero:[undefined,C.Validators.compose([C.Validators.required])],validadeCredencial:[undefined,C.Validators.compose([C.Validators.required])],hora:[undefined,C.Validators.compose([C.Validators.required])]}),this.route.data.pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(t){e.localeConfig=t.localeConfig}),this.tecnologiaCracha(Ge.BARCODE_CARD,Ge.RFID_CARD,Ge.SMART_CARD),this.formataDataEHoraDaCredencial()},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.gerar=function(){if(!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);var e=this.getDataHora(),t=this.dialogConfig.data.visitante,a=this.gerarCredencial(t,e);this.close(a)},e.prototype.tecnologiaCracha=function(){for(var e,t,a=[],i=0;i<arguments.length;i++)a[i]=arguments[i];this.technologies=[];try{for(var r=z(a),o=r.next();!o.done;o=r.next()){var n=o.value;this.technologies.push({label:this.getTecnologiaCrachaTraduzida(n),value:n})}}catch(s){e={error:s}}finally{try{o&&!o.done&&(t=r["return"])&&t.call(r)}finally{if(e)throw e.error}}},e.prototype.getTecnologiaCrachaTraduzida=function(e){return e===Ge.BARCODE_CARD?this.translate.instant("yms.patio.cartao_credencial_codigo_barras"):e===Ge.RFID_CARD?this.translate.instant("yms.patio.cartao_credencial_rfid"):e===Ge.SMART_CARD?this.translate.instant("yms.patio.cartao_credencial_smart"):void 0},e.prototype.formataDataEHoraDaCredencial=function(){var e=We().add(1,"hour");this.formGroup.get("validadeCredencial").disable(),this.definiValor("validadeCredencial",e.format("DD/MM/YYYY")),this.definiValor("hora",e.format("HH:mm"))},e.prototype.getDataHora=function(){var e=new Date,t=this.formGroup.get("hora").value,a=We().date(t).add(1,"hour").hours(),i=We().date(t).minutes();return e.setHours(a),e.setMinutes(i),e},e.prototype.gerarCredencial=function(e,t){return{visitor:e,cardTechnology:this.formGroup.get("tecnologiaCracha").value,cardNumber:this.formGroup.get("numero").value,endDate:t}},e.prototype.definiValor=function(e,t){return this.formGroup.get(e).setValue(t)},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);if(i instanceof C.FormControl)i.markAsDirty({onlySelf:!0});else{if(!(i instanceof C.FormGroup))throw"Instance fot found";t.validateAllFormFields(i)}}),e.markAsDirty({onlySelf:!0})},e=V([r.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 required">\n <label for="tecnologiaCracha">{{\n "yms.patio.motorista_tecnologiaCracha" | translate\n }}</label>\n <p-dropdown\n inputId="tecnologiaCracha"\n name="tecnologiaCracha"\n [options]="this.technologies"\n formControlName="tecnologiaCracha"\n [autoWidth]="false"\n placeholder="{{\n \'yms.patio.visitante_credencial_tecnologia_cracha_place_holder\' | translate\n }}"\n ></p-dropdown>\n <s-control-errors\n [control]="formGroup.controls[\'tecnologiaCracha\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n <div class="ui-g-12 required">\n <label for="numero">{{ "yms.patio.visitante_credencial_numero" | translate }}</label>\n <input\n id="numero"\n type="text"\n name="numero"\n pInputText\n formControlName="numero"\n autocomplete="off"\n />\n <s-control-errors\n [control]="formGroup.controls[\'numero\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="validadeCredencial">{{\n "yms.patio.visitante_validade_credencial" | translate\n }}</label>\n <input\n id="validadeCredencial"\n type="text"\n name="validadeCredencial"\n pInputText\n formControlName="validadeCredencial"\n autocomplete="off"\n />\n <s-control-errors\n [control]="formGroup.controls[\'numero\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="hora">{{ "yms.patio.visitante_credecnial_hora" | translate }}</label>\n <p-calendar\n id="hora"\n name="hora"\n formControlName="hora"\n [locale]="localeConfig.calendar"\n inputId="hora"\n [showTime]="true"\n [hourFormat]="localeConfig.calendar.hourFormat"\n [timeOnly]="true"\n >\n </p-calendar>\n <s-control-errors\n [control]="formGroup.controls[\'numero\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n </div>\n\n <s-button\n [label]="\'yms.patio.visitante_button_cancelar\' | translate"\n (onClick)="close()"\n priority="link"\n ></s-button>\n <s-button\n [label]="\'yms.patio.visitante_button_gerar\' | translate"\n (onClick)="gerar()"\n ></s-button>\n</form>\n',providers:[c.ConfirmationService]}),B("design:paramtypes",[C.FormBuilder,c.DynamicDialogRef,o.TranslateService,F.ActivatedRoute,c.DynamicDialogConfig])],e)}(),Xe=function(){function e(e,a,i){this.dialogRef=a,this.dialogConfig=i,this.unsubscribe$=new t.Subject,this.ngUnsubscribe=new t.Subject,this.notSavedData=new r.EventEmitter,this.actualChanged=!1,this.isFormModified=!1,this.formGroup=e.group({name:[undefined,C.Validators.compose([C.Validators.required])],document:[undefined,C.Validators.compose([C.Validators.required])],contact:[undefined,C.Validators.compose([C.Validators.required])]})}return e.prototype.ngOnInit=function(){var e=this,i=this.dialogConfig.data;i!==undefined&&(this.id=i.id,this.formGroup.get("name").setValue(i.name),this.formGroup.get("document").setValue(i.document),this.formGroup.get("contact").setValue(i.contact),i.document!==undefined&&this.formGroup.get("document").disable()),this.notSavedData.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.actualChanged=t}),(new t.ReplaySubject).subscribe(function(t){return e.isFormModified=!t})},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.save=function(){if(!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);var e=this.formGroup.getRawValue();e.id=this.id,this.close(e)},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);if(i instanceof C.FormControl)i.markAsDirty({onlySelf:!0});else{if(!(i instanceof C.FormGroup))throw"Instance fot found";t.validateAllFormFields(i)}}),e.markAsDirty({onlySelf:!0})},V([r.Output(),B("design:type",r.EventEmitter)],e.prototype,"notSavedData",void 0),e=V([r.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 required">\n <label for="name">{{ "yms.visitante_nome" | translate }}</label>\n <input\n id="name"\n type="text"\n name="name"\n pInputText\n formControlName="name"\n dialog\n autocomplete="off"\n />\n <s-control-errors\n [control]="formGroup.controls[\'name\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n <div class="ui-g-12 required">\n <label for="document">{{ "yms.visitante_documento" | translate }}</label>\n <input\n id="document"\n type="text"\n name="document"\n pInputText\n formControlName="document"\n autocomplete="off"\n />\n <s-control-errors\n [control]="formGroup.controls[\'document\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n <div class="ui-g-12 required">\n <label for="contact">{{ "yms.visitante_contato" | translate }}</label>\n <input\n id="contact"\n type="text"\n name="contact"\n pInputText\n formControlName="contact"\n autocomplete="off"\n />\n <s-control-errors\n [control]="formGroup.controls[\'contact\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n </div>\n\n <s-button\n [label]="\'yms.patio.visitante_button_cancelar\' | translate"\n (onClick)="close()"\n priority="link"\n ></s-button>\n <s-button\n [label]="\'yms.patio.visitante_button_salvar\' | translate"\n (onClick)="save()"\n ></s-button>\n</form>\n',providers:[c.ConfirmationService]}),B("design:paramtypes",[C.FormBuilder,c.DynamicDialogRef,c.DynamicDialogConfig])],e)}(),Ze=function(){function e(e,a,i){this.translate=e,this.dialogService=a,this.integrationCallback=i,this.visitors=[],this.visitorsChange=new r.EventEmitter,this.hasChange=new r.EventEmitter,this.ngUnsubscribe=new t.Subject,this.unsubscribe$=new t.Subject,this._integrationCallback=i}return e.prototype.ngOnInit=function(){this.constroiCamposTabelaVistante(),this.visitanteTotalRecords=0},e.prototype.ngAfterContentInit=function(){var e=this;this.visitanteGridLoading=!1,this.adicionaVisitantesGrid(),this._integrationCallback.onAgendamentoMotoristaChanged().pipe(a.takeUntil(this.unsubscribe$),a.mergeMap(function(a){return e.atualizaMotorista(a),t.empty()})).subscribe()},e.prototype.atualizaMotorista=function(e){var t=this.visitanteGridData.find(function(e){return e.driver});t&&t.documentType===this.getDocumentType()&&t.document===e.cpf||(this.visitanteGridData.length>0?this.visitanteGridData[0]={name:e.nome,document:e.cpf,contact:this.getContatoMotorista(e),visitorSituation:we.CHECK_IN_PENDING,documentType:this.getDocumentType(),driver:!0}:this.visitanteGridData.push({name:e.nome,document:e.cpf,contact:this.getContatoMotorista(e),visitorSituation:we.CHECK_IN_PENDING,documentType:this.getDocumentType(),driver:!0}),this.visitors.length>0&&(this.visitors[0].visitor={name:e.nome,document:e.cpf,contact:this.getContatoMotorista(e),visitorSituation:we.CHECK_IN_PENDING,documentType:this.getDocumentType(),driver:!0}))},e.prototype.adicionaVisitantesGrid=function(){var e=this;if(this.visitors.length)this.visitanteGridData=[],this.adicionaMotoristaNoVisitanteGridData(),this.visitors.forEach(function(t){e.motorista.cpf!==t.visitor.document&&e.visitanteGridData.push({id:t.visitor.id,name:t.visitor.name,document:t.visitor.document,contact:t.visitor.contact,visitorSituation:e.getVisitorSituation(t.visitor.visitorSituation),documentType:e.getDocumentType(),driver:!0}),e.visitanteTotalRecords=e.visitors.length});else{this.visitanteGridData=[];var t=new Qe;t.visitor={name:this.motorista.nome,document:this.motorista.cpf,contact:this.getContatoMotorista(this.motorista),documentType:this.getDocumentType(),visitorSituation:we.CHECK_IN_PENDING,driver:!0},this.visitanteGridData.find(function(e){return t.visitor.document===e.document})===undefined&&(this.visitanteGridData.push(t.visitor),this.visitors.push(t),this.visitanteTotalRecords=1)}this.visitanteGridLoading=!1},e.prototype.isCredentialCardsEmpty=function(e){var t=this.visitors.find(function(t){return t.visitor.document===e.document});return t!==undefined&&t.credentialCards.filter(function(e){return 0!==Object.keys(e).length}).length>0},e.prototype.adicionaMotoristaNoVisitanteGridData=function(){var e=this,t=this.visitors.find(function(t){return e.motorista.cpf===t.visitor.document});t===undefined?this.visitanteGridData.push({name:this.motorista.nome,document:this.motorista.cpf,contact:this.getContatoMotorista(this.motorista),visitorSituation:we.CHECK_IN_PENDING,documentType:this.getDocumentType(),driver:!0}):this.visitanteGridData.push({id:t.visitor.id,name:t.visitor.name,document:t.visitor.document,contact:this.getContatoMotorista(this.motorista),visitorSituation:this.getVisitorSituation(t.visitor.visitorSituation),documentType:this.getDocumentType(),driver:!0})},e.prototype.criarOuAtualizarVisitante=function(e){var t=this;this.dialogService.open(Xe,j({header:this.translate.instant("yms.patio.motorista_adicionar_visitante")},Re,this.constroiVisitante(e))).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(e){return t.adicionaVisitanteParaSalvar(e)})},e.prototype.adicionaVisitanteParaSalvar=function(e){var t=this;if(this.visitanteGridData.forEach(function(a){if(a.document===e.document){a.contact=e.contact,a.name=e.name;var i=t.buildVisitorCredentialsDto(a);t.visitors.forEach(function(e){e.visitor.document===i.visitor.document&&(e.visitor.name=i.visitor.name,e.visitor.contact=i.visitor.contact)}),t.visitorsChange.emit(t.visitors),t.visitorFound=!0}}),!this.visitorFound){this.visitanteGridLoading=!0,e.documentType=this.getDocumentType(),e.visitorSituation===undefined&&(e.visitorSituation=we.CHECK_IN_PENDING),this.addVisitanteNaTabela(e),this.visitanteTotalRecords++,this.visitanteGridLoading=!1;var a=new Qe;a.visitor={name:e.name,document:e.document,contact:e.contact,documentType:e.documentType,visitorSituation:e.visitorSituation,driver:!1},this.visitors.push(a),this.visitorsChange.emit(this.visitors),this.hasChange.emit(!0)}},e.prototype.buildVisitorCredentialsDto=function(e){var t=new Qe,a={name:e.name,document:e.document,contact:e.contact,documentType:e.documentType,visitorSituation:e.visitorSituation,driver:!1};return t.visitor=a,t},e.prototype.model=function(e){var t=this,a=e.document===this.motorista.cpf,i=this.visitors.find(function(t){return t.visitor.document===e.document});return[{label:this.translate.instant("yms.patio.motorista_editar_visitante"),command:function(){return t.editarVisitante(e)},visible:!a},{label:this.translate.instant("yms.patio.delete"),command:function(){return t.deletarVisitante(e)},visible:!a},{label:this.translate.instant("yms.patio.motorista_visitante_entregar_credencial"),command:function(){return t.entregarCredencial(e)},visible:a||!a},{label:this.translate.instant("yms.patio.remover_credenciais"),command:function(){return t.deletarCredenciais(i)},visible:null!=i&&null!=i.credentialCards&&i.credentialCards.length>0}]},e.prototype.addVisitanteNaTabela=function(e){e.id!==undefined?this.visitanteGridData=this.visitanteGridData.map(function(t){return t.id===e.id?e:t}):this.visitanteGridData.push(e)},e.prototype.entregarCredencial=function(e){var t=this;this.dialogService.open(Je,{header:this.translate.instant("yms.patio.motorista_visitante_credencial"),data:{visitante:e}}).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(e){return t.adicionaCredencialParaEntregar(e)})},e.prototype.adicionaCredencialParaEntregar=function(e){var t=this.visitors.find(function(t){return t.visitor.document===e.visitor.document});t===undefined?this.visitors.push({visitor:e.visitor,credentialCards:[this.createCredentialCard(e)]}):t.credentialCards.push(this.createCredentialCard(e)),this.hasChange.emit(!0)},e.prototype.editarVisitante=function(e){this.criarOuAtualizarVisitante(e)},e.prototype.deletarVisitante=function(e){var t=this;this.visitanteGridData.forEach(function(a,i){if(a.document===e.document){t.visitanteGridData.splice(i,1);var r=t.visitors.findIndex(function(e){return e.visitor.document===a.document});-1!==r&&(t.visitors.splice(r,1),t.hasChange.emit(!0))}})},e.prototype.deletarCredenciais=function(e){e.credentialCards.splice(0,e.credentialCards.length),this.hasChange.emit(!0)},e.prototype.getContatoMotorista=function(e){return e.telefone===undefined?"0":e.telefone},e.prototype.getCredentialCards=function(e){var t=this;return this.visitors.length<=0?[]:this.visitors.find(function(t){return t.visitor.document===e.document}).credentialCards.filter(function(e){return 0!==Object.keys(e).length}).map(function(e){return{cardTechnology:t.getTecnologiaCrachaTraduzida(e.cardTechnology),cardNumber:e.cardNumber,endDate:e.endDate}})},e.prototype.constroiVisitante=function(e){var t={data:{}};return e!==undefined&&null!==e&&(t={data:{id:e.id,name:e.name,document:e.document,contact:e.contact,visitorSituation:this.getVisitorSituation(e.visitorSituation),documentType:this.getDocumentType()}}),t},e.prototype.createCredentialCard=function(e){return{visitor:e.id,cardTechnology:e.cardTechnology,cardNumber:e.cardNumber,endDate:e.endDate}},e.prototype.getTecnologiaCrachaTraduzida=function(e){return e===Ae.BARCODE_CARD?this.translate.instant("yms.patio.cartao_credencial_codigo_barras"):e===Ae.RFID_CARD?this.translate.instant("yms.patio.cartao_credencial_rfid"):e===Ae.SMART_CARD?this.translate.instant("yms.patio.cartao_credencial_smart"):void 0},e.prototype.getVisitorSituation=function(e){return e===undefined?we.CHECK_IN_PENDING:e},e.prototype.constroiCamposTabelaVistante=function(){this.visitanteGridColumns=[{field:"name",header:this.translate.instant("yms.patio.motorista_visitante_nome")},{field:"document",header:this.translate.instant("yms.patio.motorista_visitante_documento")},{field:"contact",header:this.translate.instant("yms.patio.motorista_visitante_contato")}]},e.prototype.getDocumentType=function(){return"cpf"},V([r.Input(),B("design:type",Object)],e.prototype,"motorista",void 0),V([r.Input(),B("design:type",Array)],e.prototype,"visitors",void 0),V([r.Output(),B("design:type",Object)],e.prototype,"visitorsChange",void 0),V([r.Output(),B("design:type",Object)],e.prototype,"hasChange",void 0),e=V([r.Component({selector:"visitante-component",template:'<div style="margin-bottom: 15px">\n <div>\n <p-header>\n {{ "yms.patio.motorista_titulo_lista_visitante" | translate}}\n <button\n style="margin-left: 50px"\n type="button"\n pButton\n (click)="criarOuAtualizarVisitante(null)"\n label="{{ \'yms.patio.motorista_add_visitante\' | translate }}"\n >\n </button>\n </p-header>\n <div class="ui-g">\n <div class="ui-g-12">\n <p-table\n #visitanteTable\n [value]="visitanteGridData"\n [columns]="visitanteGridColumns"\n dataKey="id"\n [lazy]="true"\n [scrollable]="true"\n [resizableColumns]="true"\n sortMode="single"\n [paginator]="true"\n [totalRecords]="visitanteTotalRecords"\n rows="10"\n [rowsPerPageOptions]="[10, 20, 50, 100]"\n [loading]="visitanteGridLoading"\n >\n <ng-template pTemplate="colgroup" let-columns>\n <colgroup>\n <col *ngFor="let col of columns" [style.width]="col.width" />\n </colgroup>\n </ng-template>\n <ng-template pTemplate="header" let-columns>\n <tr>\n <th id="espaco-coluna-plus" style="width: 50px"></th>\n <th\n id=""\n *ngFor="let col of columns"\n [pSortableColumn]="col.field"\n pResizableColumn\n >\n <div class="senior-header">\n <span class="senior-header-title">{{ col.header }}</span>\n <p-sortIcon [field]="col.field"></p-sortIcon>\n </div>\n </th>\n <th id="" style="width: 15%"></th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData let-columns let-expanded="expanded">\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px">\n <a href="#" [pRowToggler]="rowData" style="color: #000">\n <em [ngClass]="expanded ? \'fa fa-minus\' : \'fa fa-plus\'"></em>\n </a>\n </td>\n <td>\n <span>{{ rowData["name"] }}</span>\n </td>\n <td>\n <span>{{ rowData["document"] }}</span>\n </td>\n <td>\n <span>{{ rowData["contact"] }}</span>\n </td>\n <td style="width: 15%">\n <s-button\n priority="default"\n label="{{ \'yms.patio.motorista_acao_visitante\' | translate }}"\n [model]="model(rowData)"\n >\n </s-button>\n </td>\n </tr>\n </ng-template>\n <ng-template pTemplate="rowexpansion" let-rowData let-columns="columns">\n <tr class="bg-white no-hover">\n <td [attr.colspan]="columns.length + 2">\n <div *ngIf="isCredentialCardsEmpty(rowData); else elseBlock">\n <div\n class="container flex-container"\n *ngFor="let credentialCard of getCredentialCards(rowData)"\n >\n <p-card\n header="{{ credentialCard.cardTechnology }}"\n [style]="{ width: \'300px\', margin: \'10px\' }"\n >\n <div>\n Número: <strong>{{ credentialCard.cardNumber }}</strong>\n </div>\n <div>\n Data de validade:\n <strong>{{ credentialCard.endDate | date : "dd/MM/yyyy hh:mm" }}</strong>\n </div>\n </p-card>\n </div>\n </div>\n <ng-template #elseBlock\n >Não há credenciais para salvar ou entregues</ng-template\n >\n </td>\n </tr>\n </ng-template>\n <ng-template pTemplate="paginatorright">\n <span\n [translate]="\'total_records\'"\n [translateParams]="{ value: visitanteTotalRecords }"\n ></span>\n </ng-template>\n </p-table>\n </div>\n </div>\n</div>\n</div>',styles:[".container{display:inline-flex}.flex-container{flex-wrap:wrap}"]}),B("design:paramtypes",[o.TranslateService,c.DialogService,p.IntegrationEventsCallback])],e)}(),et=function(){function e(e,t,a,i){this.http=e,this.messageService=t,this.entityUrl=a,this.actionsUrl=i,this.http=e,this.messageService=t,this.entityUrl=a,this.actionsUrl=i,this.defaultCatch=this.defaultCatch.bind(this)}return e.prototype.getListQueryParams=function(e){var t=e.page,a=void 0===t?0:t,i=e.size,r=void 0===i?10:i,o=e.sort,n=void 0===o?[]:o,s=e.filterQuery,l=void 0===s?"":s,c=e.displayFields,p=void 0===c?[]:c,u=new d.HttpParams;return u=(u=u.append("size",String(r))).append("offset",String(a)),n&&n.length&&(u=u.append("orderby",n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", "))),l&&(u=u.append("filter",l)),p&&p.length&&(u=u.append("displayfields",p.join())),u},e.prototype.getBodyParams=function(e){var t=e.page,a=void 0===t?0:t,i=e.size,r=void 0===i?10:i,o=e.sort,n=void 0===o?[]:o,s=e.filterQuery,l=void 0===s?"":s,d=e.displayFields,c=void 0===d?[]:d,p={};return p.size=r,p.offset=a,n&&n.length&&(p.orderBy=n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", ")),l&&(p.filter=l),c&&c.length&&(p.displayFields=c.join()),p},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e.prototype.getListBodyParams=function(e){var t=this.getBodyParams(e);return e.displayFields&&e.displayFields.length&&(t.displayFields=e.displayFields),t},e.prototype.list=function(e){return this.http.get(this.entityUrl,{params:this.getListQueryParams(e)}).pipe(this.defaultCatch())},e.prototype.get=function(e,t){return void 0===t&&(t=!0),this.http.get(this.entityUrl+"/"+e).pipe(t?this.defaultCatch():a.tap())},e.prototype.insert=function(e){return this.http.post(""+this.entityUrl,e).pipe(this.defaultCatch())},e.prototype.update=function(e,t,i){return void 0===i&&(i=!0),this.http.put(this.entityUrl+"/"+e,t).pipe(i?this.defaultCatch():a.tap())},e.prototype["delete"]=function(e){return this.http["delete"](this.entityUrl+"/"+e).pipe(this.defaultCatch())},e.prototype.listCustomFilter=function(e,t){return this.http.post(this.actionsUrl+"/"+t,this.getBodyParams(e)).pipe(this.defaultCatch())},e}(),tt=function(e){function t(t,a){var i=e.call(this,t,a,"yms_int/sam/entities/scheduling")||this;return i.http=t,i.messageService=a,i.domainService="yms_int/sam",i}return P(t,e),t.prototype.saveScheduling=function(e){return this.http.post(this.domainService+"/actions/saveScheduling",e).pipe(this.defaultCatch())},t.prototype.startScheduling=function(e){return this.http.post(this.domainService+"/actions/startScheduling",{id:e}).pipe(this.defaultCatch())},t.prototype.getSchedulingByYms=function(e){return this.http.post(this.domainService+"/queries/getSchedulingByYms",{id:e}).pipe(this.defaultCatch())},t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(I.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,I.MessageService])],t)}(et),at=function(e,t){return e.concat(t.filter(function(t){return!e.includes(t)}))},it=[n.FieldType.Integer,n.FieldType.Double],rt=_,ot=function(){function e(e,a,i,r,o){void 0===r&&(r=""),this._lookupDisplayFields=[],this._advancedDisplayFields=[],this._params=[],this._url={},this._nameService={},this._useCustomSearch=!1,this._responseNamesData={},this._service=a,this._searchFields=e,this._searchGridFields=i||e,this._lookupSeparator=r,this.unsubscribe$=new t.Subject,this.verificaAtivo=o}return Object.defineProperty(e.prototype,"searchFields",{get:function(){return this._searchFields},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"searchGridFields",{get:function(){return this._searchGridFields},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"searchGridData",{get:function(){return this._searchGridData},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lookupSuggestions",{get:function(){return this._lookupSuggestions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"searchTotalRecords",{get:function(){return this._searchTotalRecords},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lookupDisplayFields",{get:function(){return this._lookupDisplayFields},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"advancedDisplayFields",{get:function(){return this._advancedDisplayFields},enumerable:!0,configurable:!0}),e.prototype.setLookupDisplayFields=function(e){return this._lookupDisplayFields=e,this},e.prototype.setAdvancedDisplayFields=function(e){return this._advancedDisplayFields=e,this},e.prototype.setVariablesCustomSearch=function(e){return void 0===e&&(e={}),this._params=e.params,this._url=e.url,this._nameService=e.nameService,this._customService=e.service,this._responseNamesData=e.responseNamesData,this},e.prototype.lookupRequest=function(e,t){var i=this,r=this._lookupDisplayFields.map(function(e){return{field:e,order:1}}),o=this._searchFields.filter(function(t){return function(e,t){var a=it.includes(e),i=t.match(/^\d+\b$/);return!(a&&!i)}(t.type,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+rt(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+rt(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+rt(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or "),s=at(this._lookupDisplayFields,this._advancedDisplayFields),l=this.geradorFiltro(o,t);this._service.list({sort:r,filterQuery:l,displayFields:s}).pipe(a.takeUntil(this.unsubscribe$)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:i._lookupDisplayFields.map(function(t){return t.indexOf(".")>0?i.getProp(e,t):e[t]}).join(i._lookupSeparator)})})})})).subscribe(function(e){return i._lookupSuggestions=e.contents})},e.prototype.searchRequest=function(e,t){var i=this,r=e.first,o=e.rows,s=e.multiSortMeta,l=e.filterData,d=r/o,c=s,p=this._searchGridFields.filter(function(e){var t=e.name;return l[t]!=undefined&&""!=l[t]}).map(function(e){var t=e.name,a=e.type,i=l[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+rt(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+rt(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+rt(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":a==n.FieldType.Lookup?t+" eq '"+i.id+"'":t+" eq '"+i+"'"}).join(" and "),u=at(this._lookupDisplayFields,this._advancedDisplayFields),m=this.geradorFiltro(p,t);this._service.list({page:d,sort:c,filterQuery:m,displayFields:u}).pipe(a.takeUntil(this.unsubscribe$)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:i._lookupDisplayFields.map(function(t){return t.indexOf(".")>0?i.getProp(e,t):e[t]}).join(i._lookupSeparator)})})})})).subscribe(function(e){i._searchGridData=e.contents,i._searchTotalRecords=e.totalElements})},e.prototype.customLookupRequest=function(e){var t=this;this._params.descricao=e,this._customService[this._nameService](this._params,this._url).pipe(a.takeUntil(this.unsubscribe$)).pipe(a.map(function(e){return j({},e,{contents:e[t._responseNamesData.contents].map(function(e){return j({},e,{label:t._lookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t._lookupSeparator)})})})})).subscribe(function(e){return t._lookupSuggestions=e[t._responseNamesData.contents]})},e.prototype.customSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.sortField,n=e.sortOrder,s=e.filterData,l={plantaId:this._params.plantaId,page:i/r,size:r,sortField:o,sortOrder:n};Object.entries(s).filter(function(e){return!(!e[0]||!e[1])&&(l[e[0]]=e[1])}),this._customService[this._nameService](l,this._url).pipe(a.takeUntil(this.unsubscribe$)).pipe(a.map(function(e){return j({},e,{contents:e[t._responseNamesData.contents].map(function(e){return j({},e,{label:t._lookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t._lookupSeparator)})})})})).subscribe(function(e){t._searchGridData=e[t._responseNamesData.contents],t._searchTotalRecords=e[t._responseNamesData.totalElements]})},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.geradorFiltro=function(e,t){var a=e?"("+e+")":"";return this.verificaAtivo&&(a+=e?"and ativo eq true":"ativo eq true"),a.concat(""+(t?t(e):""))},e}(),nt=function(e){function t(t,a){var i=e.call(this,t,a,"sam/lobby/entities/lobby")||this;return i.http=t,i.messageService=a,i}return P(t,e),t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(I.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,I.MessageService])],t)}(et),st=function(){return function(){}}(),lt=function(){return function(){}}();!function(e){e.PENDING="PENDING",e.IN_PROGRESS="IN_PROGRESS",e.FINISHED="FINISHED",e.NOT_OCCURRED="NOT_OCCURRED"}(Ke||(Ke={}));var dt,ct=function(){function e(e,a,i,o,n,s){this.fb=e,this.route=a,this.translate=i,this.messageService=o,this.lobbyService=n,this.schedulingService=s,this.notSavedData=new r.EventEmitter,this.schedulingVisitors=new st,this.isFormModified=!1,this.loading=!1,this.localeConfig={},this.ngUnsubscribe=new t.Subject}return e.prototype.ngOnInit=function(){var e=this;this.createForm(),this.portariaLookup=new ot(this.getLobbyFields(),this.lobbyService),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){e.localeConfig=t.localeConfig}),this.formGroup.valueChanges.subscribe(function(t){return e.isFormModified=!0})},e.prototype.ngAfterViewInit=function(){this.saveAndInitButton=document.getElementById("init")},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},e.prototype.ngOnChanges=function(){var e=this;this.agenda.id&&(this.loading=!0,this.schedulingService.getSchedulingByYms(this.agenda.id).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return e.loading=!1})).subscribe(function(t){if(t.scheduling){var a=t.scheduling;e.schedulingVisitors.scheduling=a,e.schedulingVisitors.visitors=t.visitors,e.formGroup.controls.motivoVisita.setValue(a.description),e.formGroup.controls.dataSaida.setValue(new Date(a.expectedEndDate)),e.formGroup.controls.horaSaida.setValue(new Date(a.expectedEndDate)),e.getLobby(a).subscribe(function(t){return e.formGroup.controls.portaria.setValue(t)})}else{var i=new Date;i.setHours((new Date).getHours()+1),e.schedulingVisitors.scheduling=new lt,e.schedulingVisitors.visitors=[],e.schedulingVisitors.scheduling.visitSituation=Ke.PENDING,e.schedulingVisitors.scheduling.description=e.agenda.descricao,e.schedulingVisitors.scheduling.expectedStartDate=new Date,e.schedulingVisitors.scheduling.expectedEndDate=i,e.formGroup.controls.motivoVisita.setValue(e.schedulingVisitors.scheduling.description),e.formGroup.controls.dataSaida.setValue(e.schedulingVisitors.scheduling.expectedStartDate),e.formGroup.controls.horaSaida.setValue(e.schedulingVisitors.scheduling.expectedEndDate)}}),this.patchActualValue())},e.prototype.getLobby=function(e){if(e.lobbyIdSAM)return this.lobbyService.get(e.lobbyIdSAM)},e.prototype.patchActualValue=function(){var e=this;setTimeout(function(){e.actualValue=e.formGroup.value,e.formGroup.patchValue(e.actualValue)},500)},e.prototype.canSave=function(){return!!(this.agenda&&this.agenda.id&&this.isFormModified)},e.prototype.onSave=function(e){var i=this;if(this.formGroup.invalid)this.validateAllFormFields(this.formGroup);else{this.isFormModified=!1;var r=this.schedulingVisitors.scheduling;r.idYMS=this.agenda.id,r.description=this.formGroup.controls.motivoVisita.value,r.expectedStartDate=new Date;var o=this.formGroup.controls.dataSaida.value,n=this.formGroup.controls.horaSaida.value;r.expectedEndDate=this.getDate(o,n);var s=this.formGroup.controls.portaria.value;s&&(r.lobbyIdSAM=s.id),this.loading=!0,this.schedulingService.saveScheduling(this.schedulingVisitors).pipe(a.takeUntil(this.ngUnsubscribe),a.mergeMap(function(a){return i.schedulingVisitors=a,e?i.schedulingService.startScheduling(i.schedulingVisitors.scheduling.idYMS):(i.loading=!1,t.NEVER)}),a.finalize(function(){return i.loading=!1})).subscribe(function(e){e&&i.saveAndInitButton&&i.saveAndInitButton.click(),i.loading=!1})}},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup&&t.validateAllFormFields(i)})},e.prototype.getDate=function(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes())},e.prototype.reset=function(){this.formGroup.patchValue(j({},this.actualValue))},e.prototype.createForm=function(){this.formGroup=this.fb.group({motivoVisita:[undefined,C.Validators.compose([C.Validators.required])],portaria:[undefined,C.Validators.compose([C.Validators.required])],dataSaida:[undefined,C.Validators.compose([C.Validators.required])],horaSaida:[undefined,C.Validators.compose([C.Validators.required])]})},e.prototype.getLobbyFields=function(){return[new n.FormField({name:"name",type:n.FieldType.String,label:this.translate.instant("yms.patio.sam_portaria_descricao")})]},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),V([r.Output(),B("design:type",r.EventEmitter)],e.prototype,"notSavedData",void 0),e=V([r.Component({selector:"scheduling",template:'<visited-info [agenda]="agenda"> </visited-info>\r\n<form [formGroup]="formGroup" *sLoadingState="loading" novalidate>\r\n <div class="ui-fluid">\r\n <div class="ui-g">\r\n <div class="ui-g-12 ui-md-6 required">\r\n <label for="motivoVisita">{{ "yms.patio.sam_motivo_visita" | translate }}</label>\r\n <input\r\n type="text"\r\n id="motivoVisita"\r\n name="motivoVisita"\r\n pInputText\r\n formControlName="motivoVisita"\r\n autocomplete="off"\r\n />\r\n <s-control-errors\r\n [control]="formGroup.controls[\'motivoVisita\']"\r\n [errorMessages]="{ required: \'error_required\' | translate }"\r\n >\r\n </s-control-errors>\r\n </div>\r\n <div class="ui-g-12 ui-md-6 required">\r\n <label for="portaria">{{ "yms.patio.sam_portaria" | translate }}</label>\r\n <s-lookup\r\n dataKey="id"\r\n id="portaria"\r\n name="portaria"\r\n formControlName="portaria"\r\n lookupDisplayField="name"\r\n [multiple]="false"\r\n (onLookupRequest)="portariaLookup.lookupRequest($event)"\r\n (onSearchRequest)="portariaLookup.searchRequest($event)"\r\n [searchTitle]="\'yms.patio.sam_portaria\' | translate"\r\n [searchEmptyTitle]="\'nothing_found\' | translate"\r\n [searchFields]="portariaLookup.searchFields"\r\n [searchGridFields]="portariaLookup.searchGridFields"\r\n [searchGridData]="portariaLookup.searchGridData"\r\n [searchTotalRecords]="portariaLookup.searchTotalRecords"\r\n [searchTotalRecordsLabel]="\r\n \'total_records\' | translate : { value: portariaLookup.searchTotalRecords }\r\n ">\r\n </s-lookup>\r\n <s-control-errors \r\n [control]="formGroup.controls[\'portaria\']"\r\n [errorMessages]="{ required: \'error_required\' | translate }">\r\n </s-control-errors>\r\n </div>\r\n <div class="ui-g-6 ui-md-3 required">\r\n <label for="dataSaida">{{ "yms.patio.sam_data_saida" | translate }}</label>\r\n <p-calendar\r\n id="dataSaida"\r\n name="dataSaida"\r\n formControlName="dataSaida"\r\n inputId="dataSaida"\r\n [showIcon]="true"\r\n [locale]="localeConfig.calendar"\r\n [dateFormat]="localeConfig.calendar.dateFormat"\r\n >\r\n </p-calendar>\r\n <s-control-errors\r\n [control]="formGroup.controls[\'dataSaida\']"\r\n [errorMessages]="{ required: \'error_required\' | translate }"\r\n >\r\n </s-control-errors>\r\n </div>\r\n <div class="ui-g-6 ui-md-3 required">\r\n <label for="horaSaida">{{ "yms.patio.sam_hora_saida" | translate }}</label>\r\n <p-calendar\r\n id="horaSaida"\r\n name="horaSaida"\r\n formControlName="horaSaida"\r\n [locale]="localeConfig.calendar"\r\n inputId="horaSaida"\r\n [showTime]="true"\r\n [hourFormat]="localeConfig.calendar.hourFormat"\r\n [timeOnly]="true"\r\n >\r\n </p-calendar>\r\n <s-control-errors\r\n [control]="formGroup.controls[\'horaSaida\']"\r\n [errorMessages]="{ required: \'error_required\' | translate }"\r\n >\r\n </s-control-errors>\r\n </div>\r\n </div>\r\n </div>\r\n</form>\r\n<div class="separator"></div>\r\n<div *ngIf="schedulingVisitors.visitors">\r\n <visitante-component\r\n [motorista]="agenda.motorista"\r\n [(visitors)]="schedulingVisitors.visitors"\r\n (hasChange)="isFormModified = $event">\r\n </visitante-component>\r\n</div>\r\n<div class="separator"></div>\r\n<div style="margin-top: 10px">\r\n <s-button priority="primary" [label]="\'save\' | translate" (onClick)="onSave()"\r\n [disabled]="loading || !canSave()"></s-button>\r\n <s-button *ngIf="saveAndInitButton" priority="primary" [label]="\'save_and_init\' | translate" (onClick)="onSave(true)"\r\n [disabled]="loading"></s-button>\r\n \r\n</div>\r\n'}),B("design:paramtypes",[C.FormBuilder,F.ActivatedRoute,o.TranslateService,I.MessageService,nt,tt])],e)}(),pt=function(){function e(e){this.dispatcher=e,this._dispatcher=e,this._dispatcher.dispatch(Ve)}return e=V([r.NgModule({declarations:[Ve,Ye,ct,Ze,Xe,Je],entryComponents:[Ve,Ye,ct,Ze,Xe,Je],exports:[Ve,Ye,ct],imports:[p.IntegrationModule,i.CommonModule,o.TranslateModule,C.FormsModule,n.ButtonModule,y.SharedModule,y.CardModule,k.ButtonModule,C.ReactiveFormsModule,T.SharedModule,n.CustomFieldsModule,n.ControlErrorsModule,y.DialogModule,n.EmptyStateModule,n.DynamicFormModule,n.TokenListModule,y.PanelModule,y.InputTextModule,y.DropdownModule,n.ButtonModule,n.LoadingStateModule,n.NumberInputModule,y.ConfirmDialogModule,n.LocaleModule,m.PermissionsModule,v.DynamicDialogModule,l.TableModule,y.TabViewModule,y.CalendarModule],providers:[Be,Ue]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),ut=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.domainService="yms_int/sam",i}return P(t,e),t.prototype.findVisitors=function(e){return this.http.post("yms_int/sam/queries/findVisitorsBySchedulingIdYMS",{agendaIdYMS:e})},t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(I.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,I.MessageService])],t)}(Q),mt=function(e){function i(a){var i=e.call(this)||this;return i.service=a,i.ngUnsubscribe=new t.Subject,i.visitorService=a,i}return P(i,e),i.prototype.ngOnInit=function(){},i.prototype.ngAfterContentInit=function(){var e=this;this.visitorService.findVisitors(this.agenda.id).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){t.visitors.length&&(e.visitors=t.visitors)})},i.prototype.credentialResume=function(e){var t,a,i="";try{for(var r=z(e),o=r.next();!o.done;o=r.next()){var n=o.value;n.cardNumber?i+=n.cardNumber:i+=" - "}}catch(s){t={error:s}}finally{try{o&&!o.done&&(a=r["return"])&&a.call(r)}finally{if(t)throw t.error}}return i},V([r.Input(),B("design:type",Object)],i.prototype,"agenda",void 0),i=V([r.Component({selector:"visitor-list-component",template:'\n<div> \n <p-table [value]="visitors">\n <ng-template pTemplate="header">\n <tr>\n <th id="visitor_name">{{\'yms.patio.motorista_visitante_nome\' | translate}}</th>\n <th id="visitor_docuemnt">{{\'yms.patio.motorista_visitante_documento\' | translate}}</th> \n <th id="visitor_credential">{{\'yms.patio.motorista_visitante_credenciais\' | translate}}</th>\n <th id="visitor_contact">{{\'yms.patio.motorista_visitante_contato\' | translate}}</th>\n </tr>\n </ng-template>\n <ng-template let-rowData pTemplate="body">\n <tr>\n <td id="">{{rowData.visitor.name}}</td>\n <td id="">{{rowData.visitor.document}}</td>\n <td id="">{{credentialResume(rowData.credentialCards)}} </td>\n <td id="">{{rowData.visitor.contact}}</td>\n </tr>\n </ng-template>\n </p-table>\n</div>'}),B("design:paramtypes",[ut])],i)}(function(){function e(){}return e=V([p.ControleCircuito({header:"Ronda",name:"yms.integracao.sam"}),p.ControleOperacao({header:"Ronda",name:"yms.integracao.sam"})],e)}()),ft=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(mt)}return e=V([r.NgModule({imports:[i.CommonModule,l.TableModule,s.MessageModule,o.TranslateModule,n.LoadingStateModule],declarations:[mt],entryComponents:[mt],exports:[mt],providers:[ut]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}();!function(e){e.NONE="NONE",e.SENIOR="SENIOR",e.WIS="WIS",e.ALCIS="ALCIS",e.SENIOR_CONNECT="SENIOR_CONNECT",e.GENERIC="GENERIC"}(dt||(dt={}));var ht,gt=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i}return P(t,e),t.prototype.getSystemIntegration=function(){return this.http.post("yms_int/wms/queries/getSystemIntegration",{})},t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(I.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,I.MessageService])],t)}(Q),vt="Informações adicionais",yt=function(){function e(){}return e=V([p.Agendamento({header:vt,name:"yms.integracao.wms"}),p.ChegadaVeiculo({header:vt,name:"yms.integracao.wms",icon:"fa fa-plus"})],e)}(),bt=function(e){function i(a,i){var r=e.call(this)||this;return r.integrationCallback=a,r.wmsService=i,r.save=[],r.header=vt,r.loading=!1,r.unsubscribe$=new t.Subject,r._integrationCallback=a,r}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this._integrationCallback.onAgendamentoSaved().pipe(a.takeUntil(this.unsubscribe$),a.mergeMap(function(a){return e.agenda=a,t.empty()})).subscribe(),this.wmsService.getSystemIntegration().subscribe(function(t){var a=t.system;e.wmsSystem=a})},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},V([r.Output(),B("design:type",qe)],i.prototype,"agenda",void 0),V([r.Input(),B("design:type",Array)],i.prototype,"save",void 0),V([r.Input(),B("design:type",String)],i.prototype,"wmsSystem",void 0),i=V([r.Component({template:'\n <div *ngIf="agenda">\n <document-grid [agenda]="agenda" [wmsSystem]="wmsSystem" ></document-grid>\n </div>\n '}),B("design:paramtypes",[p.IntegrationEventsCallback,gt])],i)}(yt),Ft=function(){function e(e,t,a,i){this.http=e,this.messageService=t,this.entityUrl=a,this.actionsUrl=i,this.http=e,this.messageService=t,this.entityUrl=a,this.actionsUrl=i,this.defaultCatch=this.defaultCatch.bind(this)}return e.prototype.getListQueryParams=function(e){var t=e.page,a=void 0===t?0:t,i=e.size,r=void 0===i?10:i,o=e.sort,n=void 0===o?[]:o,s=e.filterQuery,l=void 0===s?"":s,c=e.displayFields,p=void 0===c?[]:c,u=new d.HttpParams;return u=(u=u.append("size",String(r))).append("offset",String(a)),n&&n.length&&(u=u.append("orderby",n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", "))),l&&(u=u.append("filter",l)),p&&p.length&&(u=u.append("displayfields",p.join())),u},e.prototype.getBodyParams=function(e){var t=e.page,a=void 0===t?0:t,i=e.size,r=void 0===i?10:i,o=e.sort,n=void 0===o?[]:o,s=e.filterQuery,l=void 0===s?"":s,d=e.displayFields,c=void 0===d?[]:d,p={};return p.size=r,p.offset=a,n&&n.length&&(p.orderBy=n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", ")),l&&(p.filter=l),c&&c.length&&(p.displayfields=c.join()),p},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e.prototype.list=function(e){return this.http.get(this.entityUrl,{params:this.getListQueryParams(e)}).pipe(this.defaultCatch())},e.prototype.get=function(e){return this.http.get(this.entityUrl+"/"+e).pipe(this.defaultCatch())},e.prototype.insert=function(e){return this.http.post(""+this.entityUrl,e).pipe(this.defaultCatch())},e.prototype.update=function(e,t){return this.http.put(this.entityUrl+"/"+e,t).pipe(this.defaultCatch())},e.prototype["delete"]=function(e){return this.http["delete"](this.entityUrl+"/"+e).pipe(this.defaultCatch())},e.prototype.listCustomFilter=function(e,t){return this.http.post(this.actionsUrl+"/"+t,this.getBodyParams(e)).pipe(this.defaultCatch())},e}(),St=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return P(t,e),t}(Ft),Dt=function(e){function t(t,a){var i=e.call(this,t,a,"yms/agenda/entities/agenda","")||this;return i.http=t,i.messageService=a,i.url="yms/agenda/queries/isClienteExterno",i}return P(t,e),t.prototype.isClienteExterno=function(){return this.http.post(""+this.url,{})},t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(I.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,I.MessageService])],t)}(St),Ct=function(e){function t(t,a){var i=e.call(this,t,a,"yms_int/wms/entities/document","")||this;return i.http=t,i.messageService=a,i}return P(t,e),t.prototype.findDocuments=function(e){return this.http.post("yms_int/wms/queries/findDocuments",e)},t.prototype.getSystemIntegration=function(){return this.http.get("yms_int/wms/queries/getSystemIntegration")},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(et),_t=function(){function e(e){this.httpClient=e}return e.prototype.getProcessTypeByScheduling=function(e){return this.httpClient.post("yms/integration/queries/getProcessTypeByScheduling",{idSchedulingType:e})},e.ngInjectableDef=r.defineInjectable({factory:function(){return new e(r.inject(d.HttpClient))},token:e,providedIn:"root"}),e=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient])],e)}();!function(e){e.RECEBIMENTO_CONTRATO="RECEBIMENTO_CONTRATO",e.RECEBIMENTO_ORDEM_COMPRA="RECEBIMENTO_ORDEM_COMPRA",e.EXPEDICAO="EXPEDICAO",e.DEVOLUCAO="DEVOLUCAO",e.PROCESSO_AVULSO="PROCESSO_AVULSO",e.RECEBIMENTO_WMS="RECEBIMENTO_WMS"}(ht||(ht={}));var It,Tt=function(){function e(e,a,i,o,n,s){this.translate=e,this.documentService=a,this.messageService=i,this.confirmationService=o,this.integrationService=n,this.agendaService=s,this.viewDocument=new r.EventEmitter,this.gridData=[],this.enableButtonIsClienteExterno=!0,this.ngUnsubscribe=new t.Subject,this.selection=[]}return e.prototype.ngOnInit=function(){this.verifyClienteExterno(),this.getProcessTypeByScheduling(),this.listDocuments(!1)},e.prototype.ngAfterContentChecked=function(){this.gridColumns=this.getGridColumns()},e.prototype.verifyClienteExterno=function(){var e=this;this.agendaService.isClienteExterno().subscribe(function(t){e.isClienteExterno=t.isClienteExterno,e.cantEditStatus()})},e.prototype.getProcessTypeByScheduling=function(){var e=this;this.integrationService.getProcessTypeByScheduling(this.agenda.tipoAgendamento.id).subscribe(function(t){return e.processType=t.processType})},e.prototype.onChangeDocument=function(e){if(this.gridData.find(function(t){return t.key===e.key}))return this.message("error","yms.int.wms_error_register_document_message_title","yms.int.wms_error_register_document_message_description"),this.selection[0]=e,void(this.visibleDocumentRegister=!0);this.gridData.push(e),this.disabled=!1,this.message("success","yms.int.wms_saved_document_message_title","yms.int.wms_success_message_description"),this.visibleDocumentRegister=!1},e.prototype.cantEditStatus=function(){["CANCELADO","EM_EXECUCAO","CONCLUIDO","AGUARDANDO_POR_VALIDACAO"].includes(this.agenda.status.toString())&&(this.enableButtonIsClienteExterno=!1)},e.prototype.getActions=function(){var e=this;return[{disabled:this.checkWmsSystemInvalid(),label:this.translate.instant("yms.int.wms_search"),command:function(){e.selection=[],e.visibleInvoiceKey=!0},icon:"fa fa-search"},{disabled:this.checkWmsSystemInvalid(),label:this.translate.instant("yms.int.wms_add_document_register"),command:function(){e.selection=[],e.edit=!0,e.visibleDocumentRegister=!0},icon:"fas fa-pen-square"}]},e.prototype.checkWmsSystemInvalid=function(){return!(!this.wmsSystem||this.wmsSystem!==dt.NONE)},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.view=function(){this.viewDocument.emit(this.selection[0]),this.visibleDocumentRegister=!0,this.edit=!1},e.prototype.save=function(){var e=this;this.gridData.length>0&&this.gridData.forEach(function(t){t.id||(t.schedulingId||(t.schedulingId=e.agenda.id),t.key=e.updateKeyByWms(t),e.documentService.insert(t).subscribe(function(){e.message("success","yms.int.wms_saved_document_message_title","saved_message_content")}),e.disabled=!0,e.listDocuments(!1))})},e.prototype.updateKeyByWms=function(e){return e.key||(e.key=e.invoiceKey),this.wmsSystem===dt.WIS&&(e.key=e.invoiceNumber+":"+e.invoiceSerialNumber+":"+e.partnerDocument),e.key},e.prototype.onDelete=function(){var e=this;this.confirmationService.confirm({message:this.translate.instant("delete_confirmation_message"),header:this.translate.instant("delete_confirmation_title"),accept:function(){return e.removeDocumentIfIdUndfined(),e.selection.length<1?t.empty():t.forkJoin(e.selection.map(function(t){return e.documentService["delete"](t.id)})).pipe(a.takeUntil(e.ngUnsubscribe)).subscribe(function(){e.messageService.add({severity:"success",summary:e.translate.instant("deleted_message_title"),detail:e.translate.instant("deleted_message_content")}),e.listDocuments(!0)})}})},e.prototype.removeDocumentIfIdUndfined=function(){var e=this;this.selection.forEach(function(t,a){if(!t.id){var i=e.gridData.findIndex(function(e){return e.key===t.key});e.gridData.splice(i,1),e.selection.splice(a,1)}})},e.prototype.listDocuments=function(e){var t=this;this.documentService.list({filterQuery:"schedulingId eq '"+this.agenda.id+"'"}).subscribe(function(a){var i;t.gridData=e?t.gridData.filter(function(e){return!e.id}):[],a.totalElements>0?((i=t.gridData).push.apply(i,H(a.contents)),t.documentTotalRecords=a.totalElements):t.documentTotalRecords=t.gridData.length;var r=t.gridData.some(function(e){return!e.id});t.disabled=!r,t.loading=!1})},e.prototype.getGridColumns=function(){return this.isWmsSeniorConnect()?H([{field:"key",header:this.translate.instant("yms.int.wms_purchaseOrder")}],this.getColumnPartner()):this.isWmsWIS()?this.getColumnInvoiceAndlogistcUnit():H([{field:"invoiceKey",header:this.translate.instant("yms.int.wms_register_document_invoice_key")}],this.getColumnInvoiceAndlogistcUnit(),[{field:"ownerName",header:this.translate.instant("yms.int.wms_register_document_owner_name")},{field:"ownerDocument",header:this.translate.instant("yms.int.wms_register_document_owner_document")}])},e.prototype.getColumnInvoiceAndlogistcUnit=function(){return H([{field:"invoiceNumber",header:this.translate.instant("yms.int.wms_register_document_invoice_number")},{field:"invoiceSerialNumber",header:this.translate.instant("yms.int.wms_register_document_invoice_serial_number")}],this.getColumnPartner(),[{field:"logistcUnitName",header:this.translate.instant("yms.int.wms_register_document_logistc_unit_name")},{field:"logistcUnitDocument",header:this.translate.instant("yms.int.wms_register_document_logistc_unit_document")}])},e.prototype.getColumnPartner=function(){return[{field:"partnerName",header:this.translate.instant("yms.int.wms_register_document_partner_name")},{field:"partnerDocument",header:this.translate.instant("yms.int.wms_register_document_partner_document")}]},e.prototype.isWmsSeniorConnect=function(){return this.wmsSystem===dt.SENIOR_CONNECT},e.prototype.isWmsWIS=function(){return this.wmsSystem===dt.WIS},e.prototype.message=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),V([r.Input(),B("design:type",String)],e.prototype,"wmsSystem",void 0),V([r.Output(),B("design:type",Boolean)],e.prototype,"visibleInvoiceKey",void 0),V([r.Output(),B("design:type",Boolean)],e.prototype,"visibleDocumentRegister",void 0),V([r.Output(),B("design:type",r.EventEmitter)],e.prototype,"viewDocument",void 0),V([r.ViewChild("documentTable"),B("design:type",l.Table)],e.prototype,"table",void 0),V([r.ViewChild("customTemplate"),B("design:type",r.TemplateRef)],e.prototype,"customTemplate",void 0),V([r.ViewChild("customFilterFields"),B("design:type",r.TemplateRef)],e.prototype,"customFilterFields",void 0),V([r.ViewChild("customGridColgroup"),B("design:type",r.TemplateRef)],e.prototype,"customGridColgroup",void 0),V([r.ViewChild("customGridHeader"),B("design:type",r.TemplateRef)],e.prototype,"customGridHeader",void 0),V([r.ViewChild("customGridBody"),B("design:type",r.TemplateRef)],e.prototype,"customGridBody",void 0),e=V([r.Component({selector:"document-grid",template:'<div *ngIf="this.processType === \'RECEBIMENTO_WMS\'; else processNotConfigured">\n <p-panel>\n <p-header>\n <div class="buttons">\n <div>\n <s-button\n label="{{\'yms.int.wms_add_document\' | translate}}"\n priority="primary"\n [model]="getActions()"\n [auxiliary]="false"\n [disabled]="!enableButtonIsClienteExterno">\n </s-button>\n <s-button\n label="{{\'yms.wms_view_button\' | translate}}"\n priority="secondary"\n [auxiliary]="false"\n [disabled]="!selection || selection.length !== 1"\n (onClick)="view()">\n </s-button>\n <s-button\n label="{{\'yms.wms_delete_button\' | translate}}"\n priority="secondary"\n [disabled]="!selection || !selection.length || !enableButtonIsClienteExterno"\n (click)="onDelete()">\n </s-button>\n </div>\n <s-button\n id="refresh-button"\n priority="default"\n iconClass="fa fa-refresh"\n (onClick)="listDocuments(false)"\n >\n </s-button>\n </div>\n </p-header>\n <div class="ui-g">\n <div class="ui-g-12" *ngIf="gridData && gridData.length; else emptyList">\n <p-table #documentTable [value]="gridData"\n [columns]="gridColumns" dataKey="key" [lazy]="true" [scrollable]="true" [resizableColumns]="true"\n sortMode="multiple" [paginator]="true" [totalRecords]="documentTotalRecords" rows="10"\n [rowsPerPageOptions]="[10, 20, 50, 100]" [(selection)]="selection"\n [loading]="loading">\n <ng-template pTemplate="colgroup" let-columns>\n <colgroup>\n <col *ngFor="let col of columns" [style.width]="col.width"/>\n </colgroup>\n </ng-template>\n <ng-template pTemplate="header" let-columns>\n <tr>\n <th id="checkbox" class="table-checkbox">\n <p-tableHeaderCheckbox></p-tableHeaderCheckbox>\n </th>\n <th id="col" *ngFor="let col of columns" [pSortableColumn]="col.field" pResizableColumn>\n <div class="senior-header">\n <span class="senior-header-title">{{ col.header }}</span>\n <p-sortIcon [field]="col.field"></p-sortIcon>\n </div>\n </th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData let-columns let-expanded="expanded">\n <tr [pSelectableRow]="rowData">\n <td class="table-checkbox">\n <p-tableCheckbox [value]="rowData"></p-tableCheckbox>\n </td>\n <td *ngFor="let column of getGridColumns()" (click)="selection = [rowData]">\n <span>{{ rowData[ column.field ] }}</span>\n </td>\n </tr>\n </ng-template>\n <ng-template pTemplate="paginatorright">\n <span [translate]="\'total_records\'" [translateParams]="{ value: documentTotalRecords }"></span>\n </ng-template>\n </p-table> \n </div>\n </div>\n <register-document\n [wmsSystem]="wmsSystem"\n [edit]="edit"\n [viewDocument]="selection"\n (document)="onChangeDocument($event)"\n [(visible)]="visibleDocumentRegister"\n [agenda]="agenda">\n </register-document> \n <insert-key [wmsSystem]="wmsSystem" \n (document)="onChangeDocument($event)" [(visible)]="visibleInvoiceKey"></insert-key>\n </p-panel>\n</div>\n <div class="button-save">\n <s-button \n priority="primary" [label]="\'save\' | translate"\n [disabled]="disabled || !this.gridData || !enableButtonIsClienteExterno"\n (click)="save()">\n </s-button>\n </div>\n <register-document\n [wmsSystem]="wmsSystem"\n [edit]="edit"\n [viewDocument]="selection"\n (document)="onChangeDocument($event)"\n [(visible)]="visibleDocumentRegister"\n [agenda]="agenda">\n </register-document> \n <insert-key [wmsSystem]="wmsSystem" \n (document)="onChangeDocument($event)" [(visible)]="visibleInvoiceKey"></insert-key>\n\n<ng-template #emptyList>\n <div class="center">\n <s-empty-state\n iconClass="fa fa-exclamation-triangle" [title]="\'detail_empty_state_title\' | translate"\n [description]="\'detail_empty_state_description\' | translate">\n </s-empty-state>\n </div>\n</ng-template>\n\n<ng-template #processNotConfigured>\n <div class="center">\n <s-empty-state\n iconClass="fa fa-exclamation-triangle"\n [title]="\'yms.int.wms_there_no_process_type_configured_for_this_type_scheduling\' | translate"\n >\n </s-empty-state>\n </div>\n</ng-template>',styles:[".buttons{display:flex;justify-content:space-between}.center{flex-direction:column;text-align:center}.ui-g{display:block}.button-save{margin:5px 0}#refresh-button{color:#fff}.table-checkbox{width:50px}"]}),B("design:paramtypes",[o.TranslateService,Ct,c.MessageService,c.ConfirmationService,_t,Dt])],e)}(),kt=_,Mt=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&kt(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&kt(a.lastModifiedDate).toDate();return a.label=["id","schedulingId","invoiceKey","invoiceNumber","invoiceSerialNumber","systemIntegration","logistcUnitName","logistcUnitDocument","ownerName","ownerDocument","partnerName","partnerDocument","notes","code","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&kt(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&kt(a.lastModifiedDate).format(),a},e}(),Rt=function(){function e(e,t,a){this.fb=e,this.messageService=t,this.translateService=a,this.document=new r.EventEmitter,this.visible=new r.EventEmitter,this.visibleChange=new r.EventEmitter}return e.prototype.ngOnInit=function(){this.getFormGroup()},e.prototype.ngOnChanges=function(){this.visibilityConfig()},e.prototype.visibilityConfig=function(){if(!this.edit&&this.visible)return this.formGroup.disable(),this.setValuesFormGroup(this.viewDocument[0]),this.hideSaveButton=!0,this.visible;this.formGroup!==undefined&&(this.formGroup.enable(),this.hideSaveButton=!1)},e.prototype.close=function(){this.visibleChange.emit(!1)},e.prototype.setValuesFormGroup=function(e){this.formGroup.get("key").setValue(e.key),this.formGroup.get("invoiceKey").setValue(e.invoiceKey),this.formGroup.get("invoiceNumber").setValue(e.invoiceNumber),this.formGroup.get("invoiceSerialNumber").setValue(e.invoiceSerialNumber),this.formGroup.get("logistcUnitDocument").setValue(e.logistcUnitDocument),this.formGroup.get("logistcUnitName").setValue(e.logistcUnitName),this.formGroup.get("notes").setValue(e.notes),this.formGroup.get("code").setValue(e.code),this.formGroup.get("partnerName").setValue(e.partnerName),this.formGroup.get("partnerDocument").setValue(e.partnerDocument),this.formGroup.get("ownerDocument").setValue(e.ownerDocument),this.formGroup.get("ownerName").setValue(e.ownerName)},e.prototype.getFormGroup=function(){this.formGroup=this.fb.group({key:[undefined,C.Validators.required],invoiceKey:[undefined],schedulingId:[undefined],invoiceNumber:[undefined],invoiceSerialNumber:[undefined],logistcUnitName:[undefined],logistcUnitDocument:[undefined],ownerName:[undefined],ownerDocument:[undefined],partnerName:[undefined],partnerDocument:[undefined],notes:[undefined],code:[undefined]})},e.prototype.save=function(){var e=this.formGroup.getRawValue();e.id===undefined&&(this.agenda.id!==undefined&&(e.schedulingId=this.agenda.id),e.key!==undefined&&null!==e.key||(e.key=e.invoiceKey,this.isWmsWis()&&(e.key=e.invoiceNumber+":"+e.invoiceSerialNumber+":"+e.partnerDocument)),this.formGroup.reset(),this.document.emit(Mt.fromDto(e)))},e.prototype.isWmsWis=function(){return this.wmsSystem===dt.WIS},e.prototype.isWmsSeniorConnect=function(){return this.wmsSystem===dt.SENIOR_CONNECT},V([r.Input(),B("design:type",Array)],e.prototype,"viewDocument",void 0),V([r.Input(),B("design:type",Boolean)],e.prototype,"edit",void 0),V([r.Input(),B("design:type",qe)],e.prototype,"agenda",void 0),V([r.Output(),B("design:type",r.EventEmitter)],e.prototype,"document",void 0),V([r.Input(),B("design:type",String)],e.prototype,"wmsSystem",void 0),V([r.Input(),B("design:type",r.EventEmitter)],e.prototype,"visible",void 0),V([r.Output(),B("design:type",Object)],e.prototype,"visibleChange",void 0),e=V([r.Component({selector:"register-document",template:'<s-sidebar\n [visible]="visible"\n header="{{ \'yms.int.wms_register_document_add_document\' | translate }} {{ wmsSystem }}"\n (visibleChange)="close()">\n <form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-6" *ngIf="isWmsSeniorConnect()">\n <label for="key">{{\'yms.int.wms_purchaseOrder\' | translate}}</label>\n <input id="key" pInputText type="text" formControlName="key">\n </div>\n <div class="ui-g-6" *ngIf="!isWmsSeniorConnect() && !isWmsWis()">\n <label for="invoiceKey">{{\'yms.int.wms_register_document_invoice_key\' | translate}}</label>\n <input id="invoiceKey" pInputText type="text" formControlName="invoiceKey">\n </div>\n <div class="ui-g-6" *ngIf="!isWmsSeniorConnect()">\n <label for="invoiceNumber">{{\'yms.int.wms_register_document_invoice_number\' | translate}}</label>\n <input id="invoiceNumber" pInputText type="text" formControlName="invoiceNumber">\n </div>\n <div class="ui-g-6" *ngIf="!isWmsSeniorConnect()">\n <label for="invoiceSerialNumber">\n {{\'yms.int.wms_register_document_invoice_serial_number\' | translate}}\n </label>\n <input id="invoiceSerialNumber" pInputText type="text" formControlName="invoiceSerialNumber">\n </div>\n <div class="ui-g-8">\n <label for="logistcUnitName">{{\'yms.int.wms_register_document_logistc_unit_name\' | translate}}</label>\n <input id="logistcUnitName" pInputText type="text" formControlName="logistcUnitName">\n </div>\n <div class="ui-g-4">\n <label for="logistcUnitDocument">\n {{\'yms.int.wms_register_document_logistc_unit_document\' | translate}}\n </label>\n <input id="logistcUnitDocument" pInputText type="text" formControlName="logistcUnitDocument">\n </div>\n <div class="ui-g-8" *ngIf="!isWmsSeniorConnect() && !isWmsWis()">\n <label for="documentOwnerName">{{\'yms.int.wms_register_document_owner_name\' | translate}}</label>\n <input id="documentOwnerName" pInputText type="text" formControlName="ownerName">\n </div>\n <div class="ui-g-4" *ngIf="!isWmsSeniorConnect() && !isWmsWis()">\n <label for="ownerDocument">{{\'yms.int.wms_register_document_owner_document\' | translate}}</label>\n <input id="ownerDocument" pInputText type="text" formControlName="ownerDocument">\n </div>\n <div class="ui-g-8">\n <label for="partnerName">{{\'yms.int.wms_register_document_partner_name\' | translate}}</label>\n <input id="partnerName" pInputText type="text" formControlName="partnerName">\n </div>\n <div class="ui-g-4">\n <label for="partnerDocument">{{\'yms.int.wms_register_document_partner_document\' | translate}}</label>\n <input id="partnerDocument" pInputText type="text" formControlName="partnerDocument">\n </div>\n <div class="ui-g-12">\n <label for="notes" id="notes">{{\'yms.int.wms_register_document_notes\' | translate}}</label>\n <textarea id="notes" rows="4" pInputTextarea autoResize="autoResize" formControlName="notes"></textarea>\n </div>\n <div class="ui-g-4">\n <label for="code">\n {{\'yms.int.wms_register_document_order_receiving_code\' | translate}}\n </label>\n <input id="code" pInputText type="text" formControlName="code">\n </div>\n </div>\n </form>\n <div class="space-between">\n <button\n pButton label="{{\'save\' | translate}}" (click)="save()" [attr.data-hidden]="hideSaveButton">\n </button>\n <button\n type="button" class="ui-button-link" pButton label="{{\'cancel\' | translate}}" (click)="close()">\n </button>\n </div>\n</s-sidebar>'}),B("design:paramtypes",[C.FormBuilder,c.MessageService,o.TranslateService])],e)}(),Et=function(){function e(){}return e=V([r.NgModule({imports:[i.CommonModule,n.SidebarModule,n.ButtonModule,y.PanelModule,y.ConfirmDialogModule,o.TranslateModule,y.InputTextModule,n.ControlErrorsModule,y.InputTextareaModule,C.ReactiveFormsModule],exports:[Rt],declarations:[Rt],providers:[Ct]})],e)}(),Nt=function(){function e(e,t,a,i){this.formBuilder=e,this.documentService=t,this.messageService=a,this.translate=i,this.document=new r.EventEmitter,this.visible=new r.EventEmitter,this.visibleChange=new r.EventEmitter,this.isLoading=!1}return e.prototype.ngOnInit=function(){this.formGroup=this.formBuilder.group({key:[undefined],purchaseOrder:[undefined],invoiceNumber:[undefined],invoiceSerie:[undefined],partnerDocument:[undefined]})},e.prototype.isWmsWis=function(){return this.wmsSystem===dt.WIS},e.prototype.isWmsSeniorConnect=function(){return this.wmsSystem===dt.SENIOR_CONNECT},e.prototype.add=function(){this.searchKey()},e.prototype.searchKey=function(){var e=this;this.isLoading=!0;var i={documentKeys:[this.formGroup.get("key").value],invoices:[{number:this.formGroup.get("invoiceNumber").value,serialNumber:this.formGroup.get("invoiceSerie").value,partnerDocument:this.formGroup.get("partnerDocument").value}],logistcUnitName:undefined,size:0,offset:0};this.documentService.findDocuments(i).pipe(a.catchError(function(a){return a.error&&a.error.message.includes("404")?e.message("error","yms.int.wms_error_search_document_message_header","yms.int.wms_error_search_document_not_found_message_content"):e.messageService.add({severity:"error",summary:e.translate.instant("yms.int.wms_error_search_document_message_header"),detail:e.translate.instant("yms.int.wms_error_unknown_search_document_message_content")+a.error.message}),t.throwError(a)}),a.finalize(function(){e.isLoading=!1})).subscribe(function(t){e.visibleChange.emit(!1),!t||t.totalElements<1?e.message("warn","yms.int.wms_insert_key_warning_message_header","yms.int.wms_insert_key_warning_message_description"):(e.document.emit(t.contents[0]),e.message("success","yms.int.wms_insert_key_success_message_header","yms.int.wms_success_message_description"),e.formGroup.reset())})},e.prototype.message=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.cancel=function(){this.visibleChange.emit(!1)},e.prototype.onDialogShow=function(){this.formGroup.reset()},V([r.Output(),B("design:type",r.EventEmitter)],e.prototype,"document",void 0),V([r.Input(),B("design:type",r.EventEmitter)],e.prototype,"visible",void 0),V([r.Input(),B("design:type",String)],e.prototype,"wmsSystem",void 0),V([r.Output(),B("design:type",Object)],e.prototype,"visibleChange",void 0),e=V([r.Component({selector:"insert-key",template:'<form [formGroup]="formGroup">\n <p-dialog [(visible)]="visible" [modal]="true" \n [draggable]="false" (visibleChange)="cancel()" (onShow)="onDialogShow()">\n <p-header>{{\'yms.int.wms_search_document\' | translate}} {{ wmsSystem }}</p-header>\n <s-loading-state [loading]="isLoading">\n <div class="flex py-2 justify-content-center spacing-bottom" \n *ngIf="!isWmsSeniorConnect() && !isWmsWis()">\n <label for="key">{{\'yms.int.wms_insert_key_label\' | translate}}</label>\n <input id="key" class="size-input" pInputText type="text" formControlName="key">\n </div>\n <div class="flex py-2 justify-content-center spacing-bottom" *ngIf="isWmsSeniorConnect()">\n <label for="purchaseOrder">{{\'yms.int.wms_purchaseOrder\' | translate}} </label>\n <input id="purchaseOrder" class="size-input" pInputText type="text" formControlName="purchaseOrder">\n </div>\n <div class="flex py-2 justify-content-center spacing-bottom" *ngIf="isWmsWis()">\n <label for="invoiceNumber">{{\'yms.int.wms_invoice_number\' | translate}}</label>\n <input id="invoiceNumber" class="size-input" pInputText type="text" formControlName="invoiceNumber">\n </div>\n <div class="flex py-2 justify-content-center spacing-bottom" *ngIf="isWmsWis()">\n <label for="invoiceSerie">{{\'yms.int.wms_invoice_serie\' | translate}}</label>\n <input id="invoiceSerie" class="size-input" pInputText type="text" formControlName="invoiceSerie">\n </div>\n <div class="flex py-2 justify-content-center spacing-bottom" *ngIf="isWmsWis()">\n <label for="partnerDocument">{{\'yms.int.wms_partner_document\' | translate}}</label>\n <input id="partnerDocument" class="size-input" pInputText type="text" formControlName="partnerDocument">\n </div>\n <div class="separator"></div>\n <div class="spacing-top">\n <s-button pButton label="{{\'yms.int.wms_search\' | translate}}" (click)="add()"></s-button>\n <s-button\n type="button"\n class="ui-button-link"\n pButton label="{{\'cancel\' | translate}}"\n (click)="cancel()">\n </s-button>\n </div>\n </s-loading-state>\n </p-dialog>\n\n</form>\n',styles:[".spacing-top{margin-top:10px}.spacing-bottom{margin-bottom:10px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.size-input{width:480px}"]}),B("design:paramtypes",[C.FormBuilder,Ct,c.MessageService,o.TranslateService])],e)}(),At=function(){function e(){}return e=V([r.NgModule({imports:[i.CommonModule,C.ReactiveFormsModule,n.ButtonModule,o.TranslateModule,y.DialogModule,y.InputTextModule,n.LoadingStateModule],exports:[Nt],declarations:[Nt]})],e)}(),wt=function(){function e(){}return e=V([r.NgModule({declarations:[Tt],entryComponents:[Tt],exports:[Tt],imports:[i.CommonModule,o.TranslateModule,n.ButtonModule,y.PanelModule,l.TableModule,Et,At,k.ButtonModule,b.ComponentsModule,n.EmptyStateModule]})],e)}(),Gt=function(){function e(e){e.dispatch(bt)}return e=V([r.NgModule({declarations:[bt],entryComponents:[bt],exports:[bt],imports:[p.IntegrationModule,wt,i.CommonModule,o.TranslateModule,C.FormsModule,n.ButtonModule,y.SharedModule,y.CardModule,k.ButtonModule,C.ReactiveFormsModule,T.SharedModule,n.CustomFieldsModule,n.ControlErrorsModule,y.DialogModule,n.EmptyStateModule,n.DynamicFormModule,n.TokenListModule,y.PanelModule,y.InputTextModule,y.DropdownModule,n.ButtonModule,n.LoadingStateModule,n.NumberInputModule,y.ConfirmDialogModule,n.LocaleModule,m.PermissionsModule,v.DynamicDialogModule,l.TableModule,y.TabViewModule,y.CalendarModule],providers:[Be,Ue,gt]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),Ot=function(e){function t(t){var a=e.call(this)||this;return a.documentService=t,a.getColumns=[],a.documents=[],a.labels=[],a}return P(t,e),t.prototype.ngOnInit=function(){this.getSystemIntegration()},t.prototype.getSystemIntegration=function(){var e=this;this.documentService.getSystemIntegration().subscribe(function(t){e.wmsSystem=t.system,e.getDocumentBySchedulingId()})},t.prototype.getDocumentBySchedulingId=function(){var e=this;this.documentService.list({filterQuery:"schedulingId eq '"+this.agenda.id+"'"}).subscribe(function(t){t.totalElements>0&&(e.documents=t.contents,e.getColumns=e.getColumnLabels())})},t.prototype.getColumnLabels=function(){return this.isWmsWIS()?H(this.getLabelsInvoice()):this.isWmsSeniorConnect()?[{label:"yms.int.wms_purchaseOrder"},{label:"yms.int.wms_register_document_partner_name"},{label:"yms.int.wms_register_document_partner_document"}]:H([{label:"yms.int.wms_register_document_invoice_key"}],this.getLabelsInvoice())},t.prototype.isWmsSeniorConnect=function(){return this.wmsSystem===dt.SENIOR_CONNECT},t.prototype.isWmsWIS=function(){return this.wmsSystem===dt.WIS},t.prototype.getLabelsInvoice=function(){return[{label:"yms.int.wms_register_document_invoice_number"},{label:"yms.int.wms_register_document_invoice_serial_number"}]},V([r.Input(),B("design:type",Object)],t.prototype,"agenda",void 0),V([r.Input(),B("design:type",String)],t.prototype,"wmsSystem",void 0),t=V([r.Component({template:'<div> \n <p-table [value]="documents">\n <ng-template pTemplate="header">\n <tr>\n <th id="columns" *ngFor="let column of getColumns">\n <div class="senior-header">\n <span class="senior-header-title">{{ column.label | translate }}</span>\n </div>\n </th>\n </tr>\n </ng-template>\n <ng-template let-rowData pTemplate="body">\n <tr *ngIf="isWmsWIS()">\n <td id="">{{rowData?.invoiceNumber}}</td>\n <td id="">{{rowData?.invoiceSerialNumber}}</td>\n </tr>\n <tr *ngIf="isWmsSeniorConnect()">\n <td id="">{{rowData?.key}}</td>\n <td id="">{{rowData?.partnerName}}</td>\n <td id="">{{rowData?.partnerDocument}}</td>\n </tr>\n <tr *ngIf="!isWmsWIS() && !isWmsSeniorConnect()">\n <td id="">{{rowData?.invoiceKey}}</td>\n <td id="">{{rowData?.invoiceNumber}}</td>\n <td id="">{{rowData?.invoiceSerialNumber}}</td>\n </tr>\n </ng-template>\n </p-table>\n</div>'}),B("design:paramtypes",[Ct])],t)}(function(){function e(){}return e=V([p.ControleCircuito({header:"Informações adicionais",name:"yms.integracao.wms"})],e)}()),xt=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(Ot)}return e=V([r.NgModule({imports:[i.CommonModule,o.TranslateModule,n.LoadingStateModule,l.TableModule],declarations:[Ot],entryComponents:[Ot],exports:[Ot],providers:[Ct]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),Lt=new r.InjectionToken("integration_environment"),qt=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/agenda",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r._agendaUrl=i.project.domain+"/patio",r}return P(t,e),t.prototype.atualizarAgenda=function(e){return this.http.post(this._agendaUrl+"/actions/atualizarAgenda",{agenda:e}).pipe(this.defaultCatch())},t.prototype.retornaModelosValidacao=function(e){return this.http.post("yms/agenda/queries/retornaModelosDeValidacao",{tipoAgendamentoId:e}).pipe(this.defaultCatch())},t.prototype.checarRevalidacao=function(e){return this.http.post("yms/agenda/actions/checarRevalidacao",e).pipe(this.defaultCatch())},t.prototype.listExternalAgenda=function(e){return this.http.get("yms/agenda/entities/agenda",{params:this.getListQueryParams(e)}).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),Pt=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/recebimentoContrato",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r._baseUrl=i.project.domain+"/"+i.project.service,r}return P(t,e),t.prototype.registrarChegadaVeiculoComRecebimento=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComRecebimento",e).pipe(this.defaultCatch())},t.prototype.insertContratoRecebimento=function(e,t){return this.http.post(this.entityUrl+"/recebimento/"+e+"/contratos",t).pipe(this.defaultCatch())},t.prototype.insertContratoRecebimentoItem=function(e,t){return this.http.post(this.entityUrl+"/contratoRecebimento/"+e+"/itens",t).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),jt=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.recebimentoService=a,this.RECEBIMENTO_KEY="ERP_SENIOR_RECEBIMENTO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.RECEBIMENTO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.RECEBIMENTO_KEY)},e.prototype.functionToOverride=function(e){var i=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return i.recebimentoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?i.recebimentoService.registrarChegadaVeiculoComRecebimento({recebimento:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Os dados da guia ERP Senior não foram informados")}))},e=V([r.Injectable(),B("design:paramtypes",[p.ChegadaVeiculoOverride,qt,Pt])],e)}(),Vt=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/expedicao",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r._baseUrl=i.project.domain+"/"+i.project.service,r}return P(t,e),t.prototype.registrarChegadaVeiculoComExpedicao=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComExpedicao",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,c.MessageService,Object])],t)}(Ft),Ut=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.expedicaoService=a,this.EXPEDICAO_KEY="ERP_SENIOR_EXPEDICAO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.EXPEDICAO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.EXPEDICAO_KEY)},e.prototype.functionToOverride=function(e){var i=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return i.expedicaoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?i.expedicaoService.registrarChegadaVeiculoComExpedicao({expedicao:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Não foi possível encontrar os dados de expedição")}))},e=V([r.Injectable(),B("design:paramtypes",[p.ChegadaVeiculoOverride,qt,Vt])],e)}(),Bt=function(){function e(e,t){this.http=e,this.messageService=t,this.baseUrl="yms/integration/"}return e.prototype.getProcessConfigurationErp=function(e){return this.http.get(this.baseUrl+"queries/getErpProcessConfigurationByTipoAgendamento",{params:{idTipoAgendamento:e}}).pipe(this.defaultCatch())},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],e)}(),zt="ERP Senior",$t=function(){function e(){}return e=V([p.Agendamento({header:zt,name:"yms.integracao.erpagrox"}),p.ChegadaVeiculo({header:zt,name:"yms.integracao.erpagrox",icon:"fal fa-book"})],e)}(),Ht=function(e){function i(a,i){var r=e.call(this)||this;return r.integrationCallback=a,r.integrationService=i,r.header=zt,r.loading=!1,r.unsubscribe$=new t.Subject,r}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this.integrationCallback.onAgendamentoSaved().pipe(a.takeUntil(this.unsubscribe$),a.mergeMap(function(i){return e.agenda=i,e.loading=!0,e.agenda?e.integrationService.getProcessConfigurationErp(e.agenda.tipoAgendamento.id).pipe(a.finalize(function(){return e.loading=!1})):t.empty()})).subscribe(function(t){return e.tipoProcessoErpAtual=t.id})},i.prototype.ngOnChanges=function(){},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},i=V([r.Component({template:'\n <div *ngIf="agenda">\n <div [ngSwitch]="tipoProcessoErpAtual">\n <recebimento-form *ngSwitchCase="\'RECEBIMENTO_CONTRATO\'" [agenda]="agenda"></recebimento-form>\n <expedicao-form *ngSwitchCase="\'EXPEDICAO\'" [agenda]="agenda"></expedicao-form>\n <devolucao-form *ngSwitchCase="\'DEVOLUCAO\'" [agenda]="agenda"></devolucao-form>\n <recebimento-ordem-compra-form *ngSwitchCase="\'RECEBIMENTO_ORDEM_COMPRA\'" [agenda]="agenda"></recebimento-ordem-compra-form>\n <processo-avulso-form *ngSwitchCase="\'PROCESSO_AVULSO\'" [agenda]="agenda"></processo-avulso-form>\n <div *ngSwitchDefault>\n <s-loading-state [loading]="loading">\n <h3 *ngIf="!loading" style="text-align: center;">\n ATENÇÃO, não existe Tipo de Processo configurado para esse tipo de agendamento.\n </h3>\n <h3 *ngIf="loading" style="text-align: center;"> Carregando configurações </h3>\n </s-loading-state>\n </div>\n </div>\n </div>\n '}),B("design:paramtypes",[p.IntegrationEventsCallback,Bt])],i)}($t),Yt="Informações fiscais",Qt=function(){function e(){}return e=V([p.ControleCircuito({header:Yt,name:"yms.integracao.erpagrox"}),p.ControleOperacao({header:Yt,name:"yms.integracao.erpagrox"}),p.CircuitoFinalizado({header:Yt,name:"yms.integracao.erpagrox"})],e)}(),Kt=function(e){function i(a){var i=e.call(this)||this;return i.integrationService=a,i.ngUnsubscribe=new t.Subject,i}return P(i,e),i.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},i.prototype.ngOnInit=function(){var e=this;this.integrationService.getProcessConfigurationErp(this.agenda.tipoAgendamento.id).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.tipoProcessoErpAtual=t.id})},V([r.Input(),B("design:type",Object)],i.prototype,"agenda",void 0),i=V([r.Component({template:'\n <div *ngIf="agenda">\n <div [ngSwitch]="tipoProcessoErpAtual">\n <recebimento-info *ngSwitchCase="\'RECEBIMENTO_CONTRATO\'" [agenda]="agenda"></recebimento-info>\n <expedicao-info *ngSwitchCase="\'EXPEDICAO\'" [agenda]="agenda"></expedicao-info>\n <devolucao-info *ngSwitchCase="\'DEVOLUCAO\'" [agenda]="agenda"></devolucao-info> \n <recebimento-ordem-compra-info *ngSwitchCase="\'RECEBIMENTO_ORDEM_COMPRA\'" [agenda]="agenda"></recebimento-ordem-compra-info>\n <processo-avulso-info *ngSwitchCase="\'PROCESSO_AVULSO\'" [agenda]="agenda"></processo-avulso-info>\n </div>\n </div>\n '}),B("design:paramtypes",[Bt])],i)}(Qt),Wt=function(){function e(e,t){this.messageService=e,this.translate=t}return e.prototype.verificaSeNotaFiscalEstaDuplicada=function(e,t,a){if(""==e)return!1;var i=a.filter(function(t){return t.id==e});return void 0!==t&&i.length<=0&&(t=t.value).length>0&&(i=t.filter(function(t){return!(t.notas.length<=0)&&t.notas.filter(function(t){return t.chaveNotaFiscal==e}).length>0})),i.length>0&&(this.messageService.add({severity:"error",summary:this.translate.instant("yms.integration.titulo_nota_fical_ja_exite"),detail:this.translate.instant("yms.integration.conteudo_nota_fical_ja_exite")}),!0)},e.prototype.findDuplicateFornecedores=function(e){var t,a=e.documentos.map(function(e){return e.numero});return(t=a,t.filter(function(e,t){return a.indexOf(e)!==t})).length>0?e.documentos.map(function(e){return e.fornecedor.codigo}).join(" "):null},e=V([r.Injectable(),B("design:paramtypes",[I.MessageService,o.TranslateService])],e)}(),Jt=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/ordemCompra",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.environment=i,r}return P(t,e),t.prototype.listOrdensCompra=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarOrdensCompra",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),Xt=_,Zt=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Xt(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Xt(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","nome","fantasia"]," - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Xt(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Xt(a.lastModifiedDate).format(),delete a.label,a},e}(),ea=_,ta=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&ea(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ea(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","nome","cpfCnpj"]," - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&ea(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ea(a.lastModifiedDate).format(),delete a.label,a},e}(),aa=_,ia=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&aa(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&aa(a.lastModifiedDate).toDate();return a.label=["id","pessoa.codigo","pessoa.nome","pessoa.site","pessoa.situacao","pessoa.cliente","pessoa.fornecedor","pessoa.representante","cnpj","nomeFantasia","inscricaoEstadual","inscricaoMunicipal","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.fromDto(a.pessoa,"PessoaJuridica")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&aa(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&aa(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.toDto(a.pessoa,"PessoaJuridica")),a},e}(),ra=_,oa=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&ra(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ra(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&ra(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ra(a.lastModifiedDate).format(),delete a.label,a},e}(),na=_,sa=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&na(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&na(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","abreviatura","pais.id","pais.codigo","pais.descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Pais"!==t&&a.pais&&(a.pais=oa.fromDto(a.pais,"Estado")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&na(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&na(a.lastModifiedDate).format(),delete a.label,"Pais"!==t&&a.pais&&(a.pais=oa.toDto(a.pais,"Estado")),a},e}(),la=_,da=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&la(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&la(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","estado.id","estado.codigo","estado.descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Estado"!==t&&a.estado&&(a.estado=sa.fromDto(a.estado,"Cidade")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&la(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&la(a.lastModifiedDate).format(),delete a.label,"Estado"!==t&&a.estado&&(a.estado=sa.toDto(a.estado,"Cidade")),a},e}(),ca=_,pa=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&ca(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ca(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","endereco"]," - "),"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.fromDto(a.pessoa,"PessoaEndereco")),"Cidade"!==t&&a.cidade&&(a.cidade=da.fromDto(a.cidade,"PessoaEndereco")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&ca(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ca(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.toDto(a.pessoa,"PessoaEndereco")),"Cidade"!==t&&a.cidade&&(a.cidade=da.toDto(a.cidade,"PessoaEndereco")),a},e}(),ua=_,ma=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&ua(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ua(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","nome","empresa.nome"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"Filial")),"PessoaJuridica"!==t&&a.pessoaJuridica&&(a.pessoaJuridica=ia.fromDto(a.pessoaJuridica,"Filial")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=pa.fromDto(a.endereco,"Filial")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&ua(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ua(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"Filial")),"PessoaJuridica"!==t&&a.pessoaJuridica&&(a.pessoaJuridica=ia.toDto(a.pessoaJuridica,"Filial")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=pa.toDto(a.endereco,"Filial")),a},e}(),fa=_,ha=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&fa(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&fa(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","descricao","tipo"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"Produto")),"Filial"!==t&&a.filial&&(a.filial=ma.fromDto(a.filial,"Produto")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&fa(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&fa(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"Produto")),"Filial"!==t&&a.filial&&(a.filial=ma.toDto(a.filial,"Produto")),a},e}(),ga=_,va=function(){function e(e,a,i,r,o,n){this.dialogRef=e,this.dialogConfig=a,this.ordemCompraService=i,this.translate=r,this.fb=o,this.route=n,this.ordemCompraLookupDisplayFields=["codigo","empresa.nome"],this.ordemCompraAdvancedDisplayFields=["id","codigo","empresa.nome","filial.nome","pessoa.nome"],this.ordemCompraLookupSeparator=" - ",this.permissions={},this.ngUnsubscribe=new t.Subject}return e.prototype.ngOnInit=function(){var e=this,t=this.dialogConfig.data;this.agenda=t.agenda,this.filial=t.filial,this.fornecedor=t.fornecedor,this.ordensCompra=t.ordens.map(function(e){var t=e.ordemCompra;return t?t.id:undefined}).filter(function(e){return!!e}),this.formGroup=this.getForm(),this.ordemCompraSearchFields=this.getOrdemCompraFields(),this.ordemCompraSearchGridFields=this.getOrdemCompraGridFields(),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)})},e.prototype.onRouteDataChange=function(e){this.permissions=e.allPermissions.agenda},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},e.prototype.onOrdemCompraLookupRequest=function(e){var t=this,a=this.ordemCompraLookupDisplayFields.map(function(e){return{field:e,order:"Asc"}})[0],i={numero:+e.replace(/\D/g,"")},r=this.filial;r&&r.empresa&&r.empresa.id&&(i.empresaId=r.empresa.id),this.ordemCompraService.listOrdensCompra(j({},i,{pessoaId:(this.fornecedor||{id:undefined}).id,filialId:(r||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,ordensCompraSelecionados:this.ordensCompra,pagina:{limit:30,offset:0,listaOrdenacao:[{campo:a.field,ordenacao:a.order}]}})).subscribe(function(e){t.ordemCompraLookupSuggestions=e.contents.map(ha.fromDto)})},e.prototype.onOrdemCompraSearchRequest=function(e){var t=this,a=e.first,i=e.rows,r=e.multiSortMeta,o=e.filterData,n=a/i,s=this.getOrdemCompraFields().filter(function(e){var t=e.name;return o[t]!=undefined&&""!=o[t]}).reduce(function(e,t){var a;return j({},e,((a={})[t.name]=o[t.name],a))},{}),l=this.filial;l&&l.empresa&&l.empresa.id&&(s.empresaId=l.empresa.id),s.dataEmissao=s.dataEmissao&&ga(s.dataEmissao).format("YYYY-MM-DD");var d=(r||[]).length?{field:r[0].field,order:1===r[0].order?"Asc":"Desc"}:{field:"numero",order:"Asc"};this.ordemCompraService.listOrdensCompra(j({},s,{pessoaId:(this.fornecedor||{id:undefined}).id,filialId:(l||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,ordensCompraSelecionados:this.ordensCompra,pagina:{limit:i,offset:n,listaOrdenacao:[{campo:d.field,ordenacao:d.order}]}})).subscribe(function(e){t.ordemCompraSearchGridData=e.contents.map(ha.fromDto),t.ordemCompraSearchTotalRecords=e.totalElements})},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup?t.validateAllFormFields(i):i instanceof C.FormArray&&i.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e.prototype.save=function(){if(!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);this.close(this.formGroup.get("ordemCompra").value)},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.getForm=function(){return this.fb.group({ordemCompra:[undefined,C.Validators.required]})},e.prototype.getOrdemCompraFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")})]},e.prototype.getOrdemCompraGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")})]},e=V([r.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 ui-md-6">\n <label for="ordemCompra">Ordem Compra</label>\n <s-lookup dataKey="id" name="ordemCompra"\n formControlName="ordemCompra" [searchFields]="ordemCompraSearchFields"\n [searchGridFields]="ordemCompraSearchGridFields"\n [searchGridData]="ordemCompraSearchGridData" [multiple]="false"\n [lookupSuggestions]="ordemCompraLookupSuggestions"\n (onLookupRequest)="onOrdemCompraLookupRequest($event)"\n (onSearchRequest)="onOrdemCompraSearchRequest($event)"\n lookupDisplayField="label" [searchTotalRecords]="ordemCompraSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_ordem_compra_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: ordemCompraSearchTotalRecords}">\n </s-lookup>\n </div>\n </div>\n \n <div style="margin-top: 10px;">\n <div class="separator"></div>\n <s-button style="float: right;" [label]="\'save\' | translate" priority="primary" (onClick)="save()"\n [disabled]="!permissions.editar"></s-button>\n <s-button style="float: right;" [label]="\'cancel\' | translate" priority="link" (onClick)="close()"></s-button>\n </div>\n</form>'}),B("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,Jt,o.TranslateService,C.FormBuilder,F.ActivatedRoute])],e)}(),ya=function(){function e(e,t,a){this.http=t,this.messageService=a,this.baseUrl=e.project.domain+"/"+e.project.service}return e.prototype.pesquisarDocumento=function(e){return this.http.post(this.baseUrl+"/queries/pesquisarDocumento",e).pipe(this.defaultCatch())},e.prototype.pesquisarDocumentoValidaNotaEmUso=function(e){return this.http.post(this.baseUrl+"/queries/pesquisarDocumentoValidaNotaEmUso",e).pipe(this.defaultCatch())},e.prototype.pesquisarDocumentoGenerico=function(e){return this.http.post("yms/integration/queries/pesquisarDocumentoGenerico",e).pipe(this.defaultCatch())},e.prototype.executarAuditoria=function(e){return this.http.post(this.baseUrl+"/actions/executarAuditoria",e).pipe(this.defaultCatch())},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e=V([r.Injectable(),U(0,r.Inject(Lt)),B("design:paramtypes",[Object,d.HttpClient,c.MessageService])],e)}(),ba=function(){function e(e,a,i,r,o,n){var s=this;this.notaValidatorService=a,this.dialogConfig=i,this.confirmationService=r,this.dialogRef=o,this.verificaNotaFiscal=n,this.loading=!1,this.botaoDesabilitado=!1,this.disabled=!0,this.unsubscribe$=new t.Subject,this.validateNotaFiscal=function(e){if(0!==s.formGroup.get("chaveNotaFiscal").value.length&&(s.disabled=!1,e&&e.documentos[0])){var t=e.documentos[0];if(s.validaProdutoNaNotaFiscal(t.itens)){var a={chave:s.formGroup.get("chaveNotaFiscal").value,serie:t.serie,serieLegal:t.serieLegal,numero:t.numero};s.fornecedor?(t.fornecedor||{id:undefined}).id&&t.fornecedor.id!==s.fornecedor.id?s.confirmAndAddNovoFornecedor(a,t.fornecedor,t.origemMercadoria):(s.formGroup.get("serieNotaFiscal").setValue(t.serie),s.formGroup.get("serieLegalNotaFiscal").setValue(t.serieLegal),s.formGroup.get("numeroNotaFiscal").setValue(t.numero),s.desabilitaCamposNotaFiscal()):s.closeAndReturnNota(a,t.fornecedor,t.origemMercadoria)}}},this.camposPreenchidosValidation=function(e){var t=e.get("chaveNotaFiscal").value,a=e.get("serieNotaFiscal").value,i=e.get("numeroNotaFiscal").value;return t||a||i?null:{erroMultiplosCampos:!0}},this.formGroup=e.group({chaveNotaFiscal:[undefined,C.Validators.required],serieNotaFiscal:[undefined,C.Validators.required],serieLegalNotaFiscal:[undefined,C.Validators.required],numeroNotaFiscal:[undefined,C.Validators.required]},{validators:this.camposPreenchidosValidation})}return e.prototype.ngOnInit=function(){this.filialId=this.dialogConfig.data.filial.id,this.fornecedor=this.dialogConfig.data.fornecedor,this.produto=this.dialogConfig.data.produto,this.fornecedorNotasTokens=this.dialogConfig.data.fornecedorNotasTokens,this.contratos=this.dialogConfig.data.contratos},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.save=function(){var e=this.formGroup.get("chaveNotaFiscal").value;if(!this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(e,this.contratos,this.fornecedorNotasTokens)){if(e||this.removeErrorChaveNota(),!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);this.habilitaCamposNotaFiscal(),this.close(this.formGroup.value)}},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.onBlurNotaFiscal=function(){var e=this,i=this.formGroup.get("chaveNotaFiscal").value;this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(i,this.contratos,this.fornecedorNotasTokens)?this.botaoDesabilitado=!0:(this.removeErrorChaveNota(),this.loading=!0,this.notaValidatorService.pesquisarDocumentoValidaNotaEmUso({chaveDocumento:(i||"").replace(/\s/g,""),filialId:this.filialId}).pipe(a.takeUntil(this.unsubscribe$),a.catchError(function(){return e.disabled=!1,t.of(null)}),a.finalize(function(){return e.loading=!1})).subscribe(this.validateNotaFiscal),this.botaoDesabilitado=!1)},e.prototype.validaProdutoNaNotaFiscal=function(e){if(null!=e&&e.length>0){var t=e[0].produto;if(t&&this.produto&&t.id!==this.produto.id)return this.addErrorIfProdutoIsDifferent(),!1}return!0},e.prototype.confirmAndAddNovoFornecedor=function(e,t,a){var i=this;this.confirmationService.confirm({header:"O fornecedor vinculado a nota não é o mesmo que o selecionado",message:"O fornecedor vinculado a nota não é o mesmo que o selecionado. Deseja adicionar um novo fornecedor ou cancelar a operação?",acceptLabel:"Adicionar um novo fornecedor",rejectLabel:"Cancelar operação",accept:function(){return i.closeAndReturnNota(e,t,a)},reject:function(){return i.formGroup.get("chaveNotaFiscal").setValue(undefined)}})},e.prototype.addErrorIfProdutoIsDifferent=function(){this.formGroup.get("chaveNotaFiscal").setErrors({errorChaveNota:!0})},e.prototype.removeErrorChaveNota=function(){this.formGroup.get("chaveNotaFiscal").setErrors(null)},e.prototype.closeAndReturnNota=function(e,t,a){this.dialogRef.close({addFornecedor:!0,infoNota:e,fornecedor:t,origemMercadoria:a})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup&&t.validateAllFormFields(i)}),e.markAsDirty({onlySelf:!0})},e.prototype.habilitaCamposNotaFiscal=function(){this.formGroup.get("serieNotaFiscal").enable(),this.formGroup.get("serieLegalNotaFiscal").enable(),this.formGroup.get("numeroNotaFiscal").enable()},e.prototype.desabilitaCamposNotaFiscal=function(){this.formGroup.get("serieNotaFiscal").disable(),this.formGroup.get("serieLegalNotaFiscal").disable(),this.formGroup.get("numeroNotaFiscal").disable()},e=V([r.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid" *sLoadingState="loading">\n <div class="ui-g-12 required">\n <label for="chaveNotaFiscal">{{\'yms.erp.recebimento_chave_nota_fiscal\' | translate}}</label>\n <input\n id="chaveNotaFiscal"\n trim\n pInputText\n type="text"\n formControlName="chaveNotaFiscal"\n (blur)="onBlurNotaFiscal()"\n >\n <s-control-errors\n [control]="formGroup.controls.chaveNotaFiscal"\n [errorMessages]="{ errorChaveNota: \'yms.erp.produto_nota_error_detail\' | translate }">\n </s-control-errors>\n </div>\n <div class="ui-g-12 required" [attr.data-hidden]="disabled">\n <label for="serieNotaFiscal">{{\'yms.erp.recebimento_serie_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" formControlName="serieNotaFiscal">\n <s-control-errors\n [control]="formGroup.controls[\'serieNotaFiscal\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }">\n </s-control-errors>\n </div>\n <div class="ui-g-12 required" [attr.data-hidden]="disabled">\n <label for="serieLegalNotaFiscal">{{\'yms.erp.recebimento_serie_legal_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" formControlName="serieLegalNotaFiscal">\n <s-control-errors\n [control]="formGroup.controls[\'serieLegalNotaFiscal\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }">\n </s-control-errors>\n </div>\n <div class="ui-g-12 required" [attr.data-hidden]="disabled">\n <label for="numeroNotaFiscal">{{\'yms.erp.recebimento_numero_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" formControlName="numeroNotaFiscal">\n <s-control-errors\n [control]="formGroup.controls[\'numeroNotaFiscal\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }">\n </s-control-errors>\n </div>\n </div>\n\n <s-control-errors [control]="formGroup" [errorMessages]="{ erroMultiplosCampos: \'yms.erp.nota_fiscal_no_value\' | translate }"></s-control-errors>\n\n <s-button label="Cancelar" (onClick)="close()" priority="link"></s-button>\n <s-button label="Salvar" [disabled]="botaoDesabilitado || disabled" (onClick)="save()"></s-button>\n</form>\n\n<p-confirmDialog appendTo="body"></p-confirmDialog>',providers:[c.ConfirmationService]}),B("design:paramtypes",[C.FormBuilder,ya,c.DynamicDialogConfig,c.ConfirmationService,c.DynamicDialogRef,Wt])],e)}(),Fa=function(){function e(e){this.elementRef=e}return e.prototype.onBlur=function(){var e=this.elementRef.nativeElement.value;e&&(this.elementRef.nativeElement.value=e.replace(/\s/g,""))},V([r.HostListener("blur"),B("design:type",Function),B("design:paramtypes",[]),B("design:returntype",void 0)],e.prototype,"onBlur",null),e=V([r.Directive({selector:"[trim]"}),B("design:paramtypes",[r.ElementRef])],e)}(),Sa=function(){function e(){}return e=V([r.NgModule({imports:[i.CommonModule],declarations:[Fa],exports:[Fa]})],e)}(),Da=function(){function e(){}return e=V([r.NgModule({imports:[i.CommonModule,C.ReactiveFormsModule,v.DynamicDialogModule,D.InputTextModule,n.ButtonModule,n.ControlErrorsModule,o.TranslateModule,n.LoadingStateModule,E.ConfirmDialogModule,Sa],declarations:[ba],entryComponents:[ba]})],e)}(),Ca=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/agenda/entities/agenda"}])],providers:[qt],declarations:[],exports:[]})],e)}(),_a=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/cidade",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),Ia=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"cidade",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/cidade"}])],providers:[_a],declarations:[],exports:[]})],e)}(),Ta=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/contratoCompraItem",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.environment=i,r}return P(t,e),t.prototype.pesquisarItensContratoCompra=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarItensContratoCompra",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),ka=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"contratoCompraItem",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/contratoCompraItem"}])],providers:[Ta],declarations:[],exports:[]})],e)}(),Ma=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/contratoCompra",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.environment=i,r}return P(t,e),t.prototype.listContratosCompra=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarContratosCompra",e).pipe(this.defaultCatch())},t.prototype.getItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t.prototype.updateItens=function(e,t,a){return this.http.put(this.entityUrl+"/"+e+"/itens/"+t,a).pipe(this.defaultCatch())},t.prototype.listItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.insertItens=function(e,t){return this.http.post(this.entityUrl+"/"+e+"/itens",t).pipe(this.defaultCatch())},t.prototype.deleteItens=function(e,t){return this.http["delete"](this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),Ra=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"contratoCompra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/contratoCompra"}])],providers:[Ma],declarations:[],exports:[]})],e)}(),Ea=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/derivacao",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),Na=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"derivacao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/derivacao"}])],providers:[Ea],declarations:[],exports:[]})],e)}(),Aa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/empresa",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),wa=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"empresa",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/empresa"}])],providers:[Aa],declarations:[],exports:[]})],e)}(),Ga=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/estado",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),Oa=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"estado",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/estado"}])],providers:[Ga],declarations:[],exports:[]})],e)}(),xa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/familiaProduto",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),La=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"familiaProduto",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/familiaProduto"}])],providers:[xa],declarations:[],exports:[]})],e)}(),qa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/filial",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.baseUrl=i.project.domain+"/"+i.project.service+"/",r}return P(t,e),t.prototype.listFiliais=function(e){return this.http.post(this.baseUrl+"queries/pesquisarFiliais",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),Pa=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"filial",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/filial"}])],providers:[qa],declarations:[],exports:[]})],e)}(),ja=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pais",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),Va=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pais",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pais"}])],providers:[ja],declarations:[],exports:[]})],e)}(),Ua=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pedidoVendaItem",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.queriesUrl=i.project.domain+"/"+i.project.service+"/queries",r}return P(t,e),t.prototype.pesquisarItensPedidoVenda=function(e){return this.http.post(this.queriesUrl+"/pesquisarItensPedidoVenda",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),Ba=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pedidoVendaItem",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pedidoVendaItem"}])],providers:[Ua],declarations:[],exports:[]})],e)}(),za=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pedidoVenda",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.queriesUrl=i.project.domain+"/"+i.project.service+"/queries",r}return P(t,e),t.prototype.getItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t.prototype.pesquisarPedidosVenda=function(e){return this.http.post(this.queriesUrl+"/pesquisarPedidosVenda",e).pipe(this.defaultCatch())},t.prototype.updateItens=function(e,t,a){return this.http.put(this.entityUrl+"/"+e+"/itens/"+t,a).pipe(this.defaultCatch())},t.prototype.listItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.insertItens=function(e,t){return this.http.post(this.entityUrl+"/"+e+"/itens",t).pipe(this.defaultCatch())},t.prototype.deleteItens=function(e,t){return this.http["delete"](this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),$a=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pedidoVenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pedidoVenda"}])],providers:[za],declarations:[],exports:[]})],e)}(),Ha=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pessoaEndereco",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),Ya=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoaEndereco",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pessoaEndereco"}])],providers:[Ha],declarations:[],exports:[]})],e)}(),Qa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pessoaFisica",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),Ka=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoaFisica",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pessoaFisica"}])],providers:[Qa],declarations:[],exports:[]})],e)}(),Wa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pessoaJuridica",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),Ja=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoaJuridica",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pessoaJuridica"}])],providers:[Wa],declarations:[],exports:[]})],e)}(),Xa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pessoa",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),Za=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoa",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pessoa"}])],providers:[Xa],declarations:[],exports:[]})],e)}(),ei=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/produto",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.environment=i,r}return P(t,e),t.prototype.listProdutosRecebimento=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarProdutoRecebimento",e).pipe(this.defaultCatch())},t.prototype.listProdutos=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarProduto",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),ti=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"produto",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/produto"}])],providers:[ei],declarations:[],exports:[]})],e)}(),ai=function(){function e(){this.messageSource=new t.BehaviorSubject({id:null,change:!1}),this.current=this.messageSource.asObservable()}return e.prototype.hasChange=function(e){var t={id:e,change:!0};this.messageSource.next(t)},e.prototype.hasChangeSave=function(e){var t={id:e,change:!1};this.messageSource.next(t)},Object.defineProperty(e.prototype,"change",{get:function(){return this.messageSource.value},enumerable:!0,configurable:!0}),e=V([r.Injectable(),B("design:paramtypes",[])],e)}(),ii=function(){return function(){}}(),ri=function(){function e(){this.messageSource=new t.BehaviorSubject(undefined),this.current=this.messageSource.asObservable()}return e.prototype.changeData=function(e){return this.messageSource.next(e),e},e.prototype.getProcessData=function(){return this.messageSource.value},e.prototype.changeDataErp=function(e){var t=this.messageSource.value?this.messageSource.value:e;return t.filialId=e.filialId,t.chaveIntegracao=e.chaveIntegracao,t.produtoId=e.produtoId,t.transgeniaId=e.transgeniaId,t.transportadoraId=e.transportadoraId,this.changeData(t)},e.prototype.changeDataVeiculo=function(e,t){var a=this.messageSource.value?this.messageSource.value:new ii;return a.veiculoId=e,a.eixos=t,this.changeData(a)},e.prototype.changeDataMotorista=function(e){var t=this.messageSource.value?this.messageSource.value:new ii;return t.motoristaId=e,this.changeData(t)},e.prototype.changeDataAgenda=function(e,t,a,i){var r=this.messageSource.value?this.messageSource.value:new ii;return r.agendaId=e,r.motoristaId=t,r.veiculoId=a,r.eixos=i,this.changeData(r)},e.prototype.builderErpProcessData=function(e,t){return e.chaveIntegracao=null!=t.get("chaveNotaFiscal")?t.get("chaveNotaFiscal").value:null,e.filialId=this.getFieldFormGroup(t,"filial"),e.produtoId=this.getFieldFormGroup(t,"produto"),e.transgeniaId=this.getFieldFormGroup(t,"transgenia"),e.transportadoraId=this.getFieldFormGroup(t,"transportadora"),e.fornecedores=this.listarIdsFornecedores(t.getRawValue().fornecedores),e},e.prototype.builderErpProcessDataValidaNotaNoContrato=function(e,t){return(e=this.builderErpProcessData(e,t)).recebimentoTemNota=this.verificaSeTemNotaNoContratoNoFornecedo(t.getRawValue().fornecedores),e},e.prototype.verificaSeTemNotaNoContratoNoFornecedo=function(e){var t=this,a=!1,i=[];null!=e&&e.filter(function(e){return null!=e.contratos&&e.contratos!=undefined}).forEach(function(e){return i.push(e.contratos)});var r=[];return null!=i&&i.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return r.push(a=t.verificaSeContratosTemNota(e))}),a},e.prototype.verificaSeContratosTemNota=function(e){var t=!0;return e.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return t=t&&e.notas.length>0}),t},e.prototype.builderErpProcessDataValidaNotaNaOrdemCompra=function(e,t){return(e=this.builderErpProcessData(e,t)).recebimentoTemNota=this.verificaSeTemNotaNaOrdemCompraDoFornecedo(t.getRawValue().fornecedores),e},e.prototype.verificaSeTemNotaNaOrdemCompraDoFornecedo=function(e){var t=this,a=!1,i=[];null!=e&&e.filter(function(e){return null!=e.ordens&&e.ordens!=undefined}).forEach(function(e){return i.push(e.ordens)});var r=[];return null!=i&&i.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return r.push(a=t.verificaSeOrdemCompraTemNota(e))}),a},e.prototype.verificaSeOrdemCompraTemNota=function(e){var t=!0;return e.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return t=t&&e.notas.length>0}),t},e.prototype.getFieldFormGroup=function(e,t){return null==e.get(t)||null==e.get(t).value?null:e.get(t).value.id},e.prototype.listarIdsFornecedores=function(e){var t=[];return null!=e&&e.filter(function(e){return null!=e.fornecedor&&e.fornecedor!=undefined}).forEach(function(e){return t.push(e.fornecedor)}),t.map(function(e){return e.id})},e=V([r.Injectable(),B("design:paramtypes",[])],e)}(),oi=function(){function e(){this.messageSource=new t.BehaviorSubject(!1),this.current=this.messageSource.asObservable()}return e.prototype.enableRevalidation=function(){this.messageSource.next(!0)},Object.defineProperty(e.prototype,"enable",{get:function(){return this.messageSource.value},enumerable:!0,configurable:!0}),e=V([r.Injectable(),B("design:paramtypes",[])],e)}(),ni=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"recebimentoContrato",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/recebimentoContrato"},{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/agenda/entities/agenda"}])],providers:[Pt,ri,oi,ai],declarations:[],exports:[]})],e)}(),si=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/royalty",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),li=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"royalty",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/royalty"}])],providers:[si],declarations:[],exports:[]})],e)}(),di=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/safra",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),ci=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"safra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/safra"}])],providers:[di],declarations:[],exports:[]})],e)}(),pi=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/transportadora",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),ui=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"transportadora",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/transportadora"}])],providers:[pi],declarations:[],exports:[]})],e)}(),mi=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/unidadeMedida",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),fi=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"unidadeMedida",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/unidadeMedida"}])],providers:[mi],declarations:[],exports:[]})],e)}(),hi=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"expedicao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/expedicao"}])],providers:[Vt]})],e)}(),gi=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/devolucao",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r._baseUrl=i.project.domain+"/"+i.project.service,r}return P(t,e),t.prototype.registrarChegadaVeiculoComDevolucao=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComDevolucao",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),vi=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"devolucao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/devolucao"}])],providers:[gi,ri,oi],declarations:[],exports:[]})],e)}(),yi=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"ordemCompra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/ordem-compra"},{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/agenda/entities/agenda"}])],providers:[Jt],declarations:[],exports:[]})],e)}(),bi=function(){function e(e){this.translate=e}return e.prototype.buildForString=function(e,t){return this.build(e,t,n.FieldType.String)},e.prototype.buildForInteger=function(e,t){return this.build(e,t,n.FieldType.Integer)},e.prototype.build=function(e,t,a){return new n.FormField({label:this.translate.instant(t),name:e,type:a})},e=V([r.Injectable(),B("design:paramtypes",[o.TranslateService])],e)}(),Fi=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/recebimentoOrdemCompra",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r._baseUrl=i.project.domain+"/"+i.project.service,r}return P(t,e),t.prototype.registrarChegadaVeiculoRecebimentoOrdemCompra=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComRecebimentoOrdemCompra",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),Si=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"recebimentoOrdemCompra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/recebimentoOrdemCompra"},{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/agenda/entities/agenda"}])],providers:[Fi,ri,oi,bi],declarations:[],exports:[]})],e)}(),Di=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/transgenia",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,c.MessageService,Object])],t)}(Ft),Ci=function(){function e(){}return e=V([r.NgModule({providers:[Di]})],e)}(),_i=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/processoAvulso",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t.prototype.registrarChegada=function(e){return this.http.post(this.actionsUrl+"/registrarChegadaDeVeiculoComProcessoAvulso",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,c.MessageService,Object])],t)}(Ft),Ii=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"processoAvulso",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/processoAvulso"},{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/agenda/entities/agenda"}])],providers:[_i,ri,oi]})],e)}(),Ti=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/erp/entities/logIntegracao",i.project.domain+"/erp/actions")||this;return r.http=t,r.messageService=a,r.environment=i,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(Lt)),B("design:paramtypes",[d.HttpClient,I.MessageService,Object])],t)}(Ft),ki=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"logIntegracao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/logIntegracao"}])],providers:[Ti],declarations:[],exports:[]})],e)}(),Mi=function(){function e(){}return e=V([r.NgModule({imports:[wa,Za,Ka,Ja,Va,Oa,Ia,Ya,Pa,ui,ti,fi,li,La,ci,$a,Ba,Ra,ka,ni,Ca,Na,hi,vi,yi,Si,Ci,m.PermissionsModule,Ii,ki],providers:[Bt,ya],exports:[]})],e)}(),Ri=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.devolucaoService=a,this.DEVOLUCAO_KEY="ERP_SENIOR_DEVOLUCAO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.DEVOLUCAO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.DEVOLUCAO_KEY)},e.prototype.functionToOverride=function(e){var i=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return i.devolucaoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?i.devolucaoService.registrarChegadaVeiculoComDevolucao({devolucao:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Não foi possível encontrar os dados de devolução")}))},e=V([r.Injectable(),B("design:paramtypes",[p.ChegadaVeiculoOverride,qt,gi])],e)}(),Ei=_,Ni=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Ei(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Ei(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","quantidadeDecimais","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Ei(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Ei(a.lastModifiedDate).format(),delete a.label,a},e}(),Ai=_,wi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Ai(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Ai(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"Royalty")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Ai(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Ai(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"Royalty")),a},e}(),Gi=_,Oi=function(){function e(){}return e.fromDto=function(e,t){if(e.id===undefined)return e;var a=j({},e);a.createdDate=a.codigo&&Gi(a.createdDate).toDate(),a.createdDate=a.createdDate&&Gi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Gi(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","situacao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"FamiliaProduto")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Gi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Gi(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"FamiliaProduto")),a},e}(),xi=_,Li=function(){function e(){this.produtoMisto=!1,this.comprado=!1}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&xi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&xi(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedida&&(a.unidadeMedida=Ni.fromDto(a.unidadeMedida,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedidaAgroG5&&(a.unidadeMedidaAgroG5=Ni.fromDto(a.unidadeMedidaAgroG5,"Produto")),"Royalty"!==t&&a.royalty&&(a.royalty=wi.fromDto(a.royalty,"Produto")),"FamiliaProduto"!==t&&a.familia&&(a.familia=Oi.fromDto(a.familia,"Produto")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&xi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&xi(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedida&&(a.unidadeMedida=Ni.toDto(a.unidadeMedida,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedidaAgroG5&&(a.unidadeMedidaAgroG5=Ni.toDto(a.unidadeMedidaAgroG5,"Produto")),"Royalty"!==t&&a.royalty&&(a.royalty=wi.toDto(a.royalty,"Produto")),"FamiliaProduto"!==t&&a.familia&&(a.familia=Oi.toDto(a.familia,"Produto")),a},e}(),qi=_,Pi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&qi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&qi(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"Derivacao")),"Produto"!==t&&a.produto&&(a.produto=Li.fromDto(a.produto,"Derivacao")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&qi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&qi(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"Derivacao")),"Produto"!==t&&a.produto&&(a.produto=Li.toDto(a.produto,"Derivacao")),a},e}(),ji=_,Vi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&ji(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ji(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","pessoa.nome","pessoa.cpfCnpj"]," - "),"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.fromDto(a.pessoa,"Transportadora")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=pa.fromDto(a.endereco,"Transportadora")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&ji(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ji(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.toDto(a.pessoa,"Transportadora")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=pa.toDto(a.endereco,"Transportadora")),a},e}(),Ui=_,Bi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Ui(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Ui(a.lastModifiedDate).toDate();return a.label=[""].map(function(e){return a[e]}).join(" - "),"Pessoa"!==t&&a.fornecedor&&(a.fornecedor=ta.fromDto(a.fornecedor,"Devolucao")),"Filial"!==t&&a.filial&&(a.filial=ma.fromDto(a.filial,"Devolucao")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.fromDto(a.transportadora,"Devolucao")),"Produto"!==t&&a.produto&&(a.produto=Li.fromDto(a.produto,"Devolucao")),"Agenda"!==t&&a.agenda&&(a.agenda=qe.fromDto(a.agenda,"Devolucao")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=pa.fromDto(a.origemMercadoria,"Recebimento")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=Pi.fromDto(a.derivacao,"Devolucao")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Ui(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Ui(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.fornecedor&&(a.fornecedor=ta.toDto(a.fornecedor,"Devolucao")),"Filial"!==t&&a.filial&&(a.filial=ma.toDto(a.filial,"Devolucao")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.toDto(a.transportadora,"Devolucao")),"Produto"!==t&&a.produto&&(a.produto=Li.toDto(a.produto,"Devolucao")),"Agenda"!==t&&a.agenda&&(a.agenda=qe.toDto(a.agenda,"Devolucao")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=pa.toDto(a.origemMercadoria,"Devolucao")),a},e}();!function(e){e.AGUARDANDO_CONFIRMACAO="AGUARDANDO_CONFIRMACAO_SOLICITANTE",e.AGENDADO="AGENDADO",e.AGUARDANDO_CONFIRMACAO_SOLICITANTE="AGUARDANDO_CONFIRMACAO",e.REJEITADO_POR_VALIDACAO="REJEITADO_POR_VALIDACAO",e.CANCELADO="CANCELADO"}(It||(It={}));var zi,$i,Hi=function(){function e(e,a,i,r,o,n,s,l,d,c,p,u,m,f,h,g,v,y){this.fb=e,this.router=a,this.translate=i,this.filialService=r,this.pessoaService=o,this.produtoService=n,this.derivacaoService=s,this.origemMercadoriaService=l,this.transportadoraService=d,this.devolucaoService=c,this.messageService=p,this.route=u,this.override=m,this.confirmationService=f,this.agendaService=h,this.erpProcessService=g,this.erpFormConfigService=v,this.hasChangeService=y,this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.fornecedorLookupDisplayFields=["codigo","nome"],this.fornecedorAdvancedDisplayFields=["id","codigo","nome"],this.fornecedorLookupSeparator=" - ",this.produtoLookupDisplayFields=["codigo","descricao"],this.produtoAdvancedDisplayFields=["id","codigo","descricao"],this.produtoLookupSeparator=" - ",this.derivacaoLookupDisplayFields=["codigo","descricao"],this.derivacaoAdvancedDisplayFields=["id","codigo","descricao"],this.derivacaoLookupSeparator=" - ",this.origemMercadoriaLookupDisplayFields=["codigo","endereco"],this.origemMercadoriaAdvancedDisplayFields=["id","codigo","endereco","numero"],this.origemMercadoriaLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.disableButtonSave=!1,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.permissions={},this.ngUnsubscribe=new t.Subject,this.formGroup=this.getFormGroup()}return e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.override.remove()},e.prototype.ngAfterViewInit=function(){var e=this;this.override.initialize(),this.saveAndInitButton=document.getElementById("init"),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)});(this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)||!this.permissions.editar)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.createdByErpDisableForm()},e.prototype.ngOnInit=function(){var e=this;this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.fornecedorSearchFields=this.getFornecedorSearchFields(),this.produtoSearchFields=this.getProdutoSearchFields(),this.derivacaoSearchFields=this.getDerivacaoSearchFields(),this.origemMercadoriaSearchFields=this.getOrigemMercadoriaSearchFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;"new"!=a&&e.getDevolucao(a)}),this.getEmpresaFilial(),this.filialValueChanges();this.checkValuesChanges("produto","derivacao",this.derivacaoService,function(e){return"produto.id eq '"+e.id+"' and situacao eq 'ATIVO'"},["codigo","descricao"],10,!0,!0);this.checkValuesChanges("fornecedor","origemMercadoria",this.origemMercadoriaService,function(e){return"pessoa.id eq '"+e.id+"'"},["codigo","endereco"],10,!1,!0),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0,this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)})},e.prototype.onRouteDataChange=function(e){this.permissions=e.allPermissions.agenda},e.prototype.createdByErpDisableForm=function(){this.agenda&&this.agenda.createdByErp&&(this.formGroup.get("filial").disable(),this.formGroup.get("fornecedor").disable(),this.formGroup.get("produto").disable(),this.formGroup.get("derivacao").disable(),this.formGroup.get("origemMercadoria").disable(),this.formGroup.get("transportadora").disable(),this.formGroup.get("contratos").disable())},e.prototype.getEmpresaFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length&&this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&e.formGroup.get("filial").setValue(ma.fromDto(a[0]))})},e.prototype.filialValueChanges=function(){var e=this;this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){if(t)return e.formGroup.get("produto").enable();e.formGroup.get("produto").setValue(undefined),e.formGroup.get("produto").disable()})},e.prototype.checkValuesChanges=function(e,t,i,r,o,n,s,l){var d=this;void 0===n&&(n=1),this.formGroup.get(e).valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return s&&d.formGroup.get(t).setValidators(e?C.Validators.required:C.Validators.nullValidator),l&&d.formGroup.get(t).setValue(null),!!e||(d.formGroup.get(t).setValue(undefined),d.formGroup.get(t).disable(),!1)}),a.mergeMap(function(e){var t=r(e);return i.list({filterQuery:t,page:0,size:n})})).subscribe(function(e){var a=e.contents;if(a.length){if(1===a.length){var i=a[0][o[0]]?a[0][o[0]].toString():"",r=a[0][o[1]]?a[0][o[1]].toString():"";r.trim()||i.trim()?a[0].label=i+" - "+r:a[0].label=d.translate.instant("yms.erp.derivacao_sem_descricao"),d.formGroup.get(t).setValue(a[0])}a.length>1?d.formGroup.get(t).enable():d.formGroup.get(t).disable()}else d.formGroup.get(t).enable()})},e.prototype.getDevolucao=function(e){var t=this;this.devolucaoService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(a.length){t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var i=Bi.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(i)}}),this.formCarregado=!0},e.prototype.onFilialLookupRequest=function(e){var t=this,i=this.getFilialSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).reduce(function(t,a){var i,r,o=a.name;return a.type===n.FieldType.Integer?j({},t,((i={})[o]=e.replace(/\D/,""),i)):j({},t,((r={})[o]=e,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(i).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return ma.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(ma.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onFornecedorLookupRequest=function(e){var t=this;Oe(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.fornecedorLookupSuggestions=e.contents})},e.prototype.onFornecedorSearchRequest=function(e){var t=this;xe(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.fornecedorSearchGridData=e.contents,t.fornecedorSearchTotalRecords=e.totalElements})},e.prototype.onProdutoLookupRequest=function(e){var t=this,i=this.formGroup.get("filial").value,r=this.agenda.tipoAgendamento;this.produtoService.listProdutos({pesquisa:e,empresaId:i?i.empresa.id:null,filialId:i?i.id:null,tipoAgendamentoId:r?r.id:null,situacao:"ATIVO",pagina:{limit:100,offset:0}}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.produtoLookupSuggestions=e.produtos.map(Li.fromDto)})},e.prototype.onProdutoSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getProdutoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}}),u=this.formGroup.get("filial").value,m=this.agenda.tipoAgendamento;this.produtoService.listProdutos(j({},p,{empresaId:u?u.empresa.id:null,filialId:u?u.id:null,situacao:"ATIVO",tipoAgendamentoId:m?m.id:null})).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoSearchTotalRecords=e.qtdTotalRegistros,t.produtoSearchGridData=e.produtos.map(Li.fromDto)})},e.prototype.onDerivacaoLookupRequest=function(e){var t=this;Oe(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoLookupSuggestions=e.contents})},e.prototype.onDerivacaoSearchRequest=function(e){var t=this;xe(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoSearchGridData=e.contents,t.derivacaoSearchTotalRecords=e.totalElements})},e.prototype.onOrigemMercadoriaLookupRequest=function(e){var t=this;Oe(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,e," pessoa.id eq '"+this.formGroup.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.origemMercadoriaLookupSuggestions=e.contents})},e.prototype.onOrigemMercadoriaSearchRequest=function(e){var t=this;xe(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,e," pessoa.id eq '"+this.formGroup.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.origemMercadoriaSearchGridData=e.contents,t.origemMercadoriaSearchTotalRecords=e.totalElements})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Oe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this;xe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.setTransportadora=function(e){var t=this;if(e){var i="pessoa.cpfCnpj eq '"+e.replace(".","").replace("/","").replace("-","")+"'";this.transportadoraService.list({filterQuery:i,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(1===a.length){var i=a[0].codigo?a[0].codigo.toString():"",r=a[0].descricao?a[0].descricao.toString():"";r.trim()||i.trim()?a[0].label=i+" - "+r:a[0].label=t.translate.instant("yms.erp.derivacao_sem_descricao"),t.formGroup.get("transportadora").setValue(a[0])}})}},e.prototype.onSave=function(e){var t=this;return this.formGroup.get("agenda").setValue(this.agenda),this.formGroup.invalid&&this.validateAllFormFields(this.formGroup),this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessData(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)}))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=It.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.get("id").setValue(a.id||null),t.successMessage(),e&&t.saveAndInitButton&&(t.hasChangeService.hasChangeSave(t.agenda.id),t.saveAndInitButton.click())})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.getSaveObservable=function(){var e=this.formGroup.getRawValue(),t=Bi.toDto(e);return this.isNew()&&!e.id?this.devolucaoService.insert(t):this.devolucaoService.update(this.formGroup.value.id,t)},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.getFormGroup=function(){return this.fb.group({id:[undefined],filial:[undefined,C.Validators.required],fornecedor:[undefined,C.Validators.required],produto:[{value:undefined,disabled:!0},C.Validators.required],derivacao:[{value:undefined,disabled:!0},C.Validators.required],origemMercadoria:[{value:undefined,disabled:!0},C.Validators.required],transportadora:[undefined],agenda:[undefined,C.Validators.required],chaveNotaFiscal:[undefined],numeroNotaFiscal:[undefined],serieNotaFiscal:[undefined],numeroNotaFiscalProdutor:[undefined],serieNotaFiscalProdutor:[undefined]})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup&&t.validateAllFormFields(i)})},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")})]},e.prototype.getFornecedorSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_codigo")})]},e.prototype.getProdutoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_codigo")})]},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_codigo")})]},e.prototype.getOrigemMercadoriaSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_endereco_codigo")}),new n.FormField({name:"numero",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_numero")}),new n.FormField({name:"endereco",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_endereco")})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},V([r.Input(),B("design:type",qe)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"devolucao-form",template:'<p-confirmDialog [acceptLabel]="\'yes\' | translate" acceptIcon="" [rejectLabel]="\'no\' | translate" rejectIcon=""></p-confirmDialog>\n<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-fluid ui-g"> \n <div class="ui-md-6 ui-g-12 required">\n <label for="filial">{{\'yms.erp.devolucao_filial\' | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions"\n (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="fornecedor">{{\'yms.erp.devolucao_fornecedor\' | translate}}</label>\n <s-lookup dataKey="id" id="fornecedor" name="fornecedor" formControlName="fornecedor"\n [searchFields]="fornecedorSearchFields" [searchGridFields]="fornecedorSearchFields"\n [searchGridData]="fornecedorSearchGridData" [multiple]="false"\n [lookupSuggestions]="fornecedorLookupSuggestions"\n (onLookupRequest)="onFornecedorLookupRequest($event)"\n (onSearchRequest)="onFornecedorSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="fornecedorSearchTotalRecords"\n [searchTitle]="\'yms.erp.fornecedor_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: fornecedorSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'fornecedor\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="produto">{{\'yms.erp.devolucao_produto\' | translate}}</label>\n <s-lookup dataKey="id" id="produto" name="produto" formControlName="produto"\n [searchFields]="produtoSearchFields" [searchGridFields]="produtoSearchFields"\n [searchGridData]="produtoSearchGridData" [multiple]="false"\n [lookupSuggestions]="produtoLookupSuggestions"\n (onLookupRequest)="onProdutoLookupRequest($event)"\n (onSearchRequest)="onProdutoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="produtoSearchTotalRecords"\n [searchTitle]="\'yms.erp.produto_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: produtoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'produto\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div> \n \n <div class="ui-md-6 ui-g-12" [ngClass]="{\'required\': formGroup.get(\'produto\').value}">\n <label for="derivacao">{{\'yms.erp.devolucao_derivacao\' | translate}}</label>\n <s-lookup dataKey="id" id="derivacao" name="derivacao" formControlName="derivacao"\n [searchFields]="derivacaoSearchFields" [searchGridFields]="derivacaoSearchFields"\n [searchGridData]="derivacaoSearchGridData" [multiple]="false"\n [lookupSuggestions]="derivacaoLookupSuggestions"\n (onLookupRequest)="onDerivacaoLookupRequest($event)"\n (onSearchRequest)="onDerivacaoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="derivacaoSearchTotalRecords"\n [searchTitle]="\'yms.erp.derivacao_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: derivacaoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'derivacao\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="origemMercadoria">{{\'yms.erp.devolucao_origem_mercadoria\' | translate}}</label>\n <s-lookup dataKey="id" id="origemMercadoria" name="origemMercadoria" formControlName="origemMercadoria"\n [searchFields]="origemMercadoriaSearchFields" [searchGridFields]="origemMercadoriaSearchFields"\n [searchGridData]="origemMercadoriaSearchGridData" [multiple]="false"\n [lookupSuggestions]="origemMercadoriaLookupSuggestions"\n (onLookupRequest)="onOrigemMercadoriaLookupRequest($event)"\n (onSearchRequest)="onOrigemMercadoriaSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="origemMercadoriaSearchTotalRecords"\n [searchTitle]="\'yms.erp.origem_mercadoria_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: origemMercadoriaSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'origemMercadoria\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n \n <div class="ui-md-6 ui-g-12">\n <label for="transportadora">{{\'yms.erp.devolucao_transportadora\' | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="chaveNotaFiscal">{{\'yms.erp.devolucao_chave_nota_fiscal\' | translate}}</label>\n <input type="text" id="chaveNotaFiscal" name="chaveNotaFiscal" pInputText formControlName="chaveNotaFiscal"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="numeroNotaFiscal">{{\'yms.erp.devolucao_numero_nota_fiscal\' | translate}}</label>\n <input type="text" id="numeroNotaFiscal" name="numeroNotaFiscal" pInputText formControlName="numeroNotaFiscal"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="serieNotaFiscal">{{\'yms.erp.devolucao_serie_nota_fiscal\' | translate}}</label>\n <input type="text" id="serieNotaFiscal" name="serieNotaFiscal" pInputText formControlName="serieNotaFiscal"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="numeroNotaFiscalProdutor">{{\'yms.erp.devolucao_numero_nota_fiscal_produtor\' | translate}}</label>\n <input type="text" id="numeroNotaFiscalProdutor" name="numeroNotaFiscalProdutor" pInputText formControlName="numeroNotaFiscalProdutor"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="serieNotaFiscalProdutor">{{\'yms.erp.devolucao_serie_nota_fiscal_produtor\' | translate}}</label>\n <input type="text" id="serieNotaFiscalProdutor" name="serieNotaFiscalProdutor" pInputText formControlName="serieNotaFiscalProdutor"> \n </div>\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">{{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} / </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">{{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}</label>\n </div>\n </div>\n </form>\n \n <div style="margin: 5px 0 5px 0;">\n <s-button priority="primary" [label]="\'save\' | translate" (onClick)="onSave()" [disabled]="loading || disableButtonSave"></s-button>\n <s-button *ngIf="saveAndInitButton" priority="primary" [label]="\'save_and_init\' | translate" (onClick)="onSave(true)" [disabled]="disableButtonSave"></s-button>\n </div>\n</div>\n'}),B("design:paramtypes",[C.FormBuilder,F.Router,o.TranslateService,qa,Xa,ei,Ea,Ha,pi,gi,c.MessageService,F.ActivatedRoute,Ri,c.ConfirmationService,qt,ri,oi,ai])],e)}(),Yi=function(){function e(e){this.devolucaoService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.devolucaoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Devolução não encontrado.")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.devolucao=Bi.fromDto(t)})},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"devolucao-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_fornecedor\' | translate}}</span>\n <span class="data">{{devolucao?.fornecedor?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_transportadora\' | translate}}</span>\n <span class="data">{{devolucao?.transportadora?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_produto\' | translate}}</span>\n <span class="data">{{devolucao?.produto?.descricao}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_derivacao\' | translate}}</span>\n <span class="data">{{devolucao?.derivacao?.descricao}}</span>\n </div>\n \n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_chave_nota_fiscal\' | translate}}</span>\n <span class="data">{{devolucao?.chaveNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_numero_nota_fiscal\' | translate}}</span>\n <span class="data">{{devolucao?.numeroNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_serie_nota_fiscal\' | translate}}</span>\n <span class="data">{{devolucao?.serieNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_numero_nota_fiscal_produtor\' | translate}}</span>\n <span class="data">{{devolucao?.numeroNotaFiscalProdutor}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_serie_nota_fiscal_produtor\' | translate}}</span>\n <span class="data">{{devolucao?.serieNotaFiscalProdutor}}</span>\n </div> \n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_origem_mercadoria\' | translate}}</span>\n <span class="data">{{devolucao?.origemMercadoria?.cep}} - {{devolucao?.origemMercadoria?.endereco}}</span>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),B("design:paramtypes",[gi])],e)}(),Qi=_,Ki=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Qi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Qi(a.lastModifiedDate).toDate();return a.label=["id","clienteFaturamento.id","clienteFaturamento.codigo","clienteFaturamento.nome","clienteRemessa.id","clienteRemessa.codigo","clienteRemessa.nome","filial.id","filial.codigo","filial.nome","transportadora.id","transportadora.codigo","transportadora.placaVeiculo","pedidoVenda.id","agenda.id","agenda.descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Pessoa"!==t&&a.clienteFaturamento&&(a.clienteFaturamento=ta.fromDto(a.clienteFaturamento,"Recebimento")),"Pessoa"!==t&&a.clienteRemessa&&(a.clienteRemessa=ta.fromDto(a.clienteRemessa,"Recebimento")),"Filial"!==t&&a.filial&&(a.filial=ma.fromDto(a.filial,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.fromDto(a.transportadora,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=qe.fromDto(a.agenda,"Recebimento")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Qi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Qi(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.clienteFaturamento&&(a.clienteFaturamento=ta.toDto(a.clienteFaturamento,"Recebimento")),"Pessoa"!==t&&a.clienteRemessa&&(a.clienteRemessa=ta.toDto(a.clienteRemessa,"Recebimento")),"Filial"!==t&&a.filial&&(a.filial=ma.toDto(a.filial,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.toDto(a.transportadora,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=qe.toDto(a.agenda,"Recebimento")),a},e}(),Wi=_,Ji=function(){function e(e,a,i,r,o,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F){this.expedicaoService=e,this.router=a,this.route=i,this.messageService=r,this.formBuilder=o,this.translate=n,this.hotkeysService=s,this.fieldCustomization=l,this.focusService=d,this.pessoaService=c,this.filialService=p,this.transportadoraService=u,this.pedidoVendaService=m,this.pedidoVendaItemService=f,this.agendaService=h,this.override=g,this.confirmationService=v,this.erpProcessService=y,this.erpFormConfigService=b,this.hasChangeService=F,this.localeConfig={},this.currencyLocaleOptions={},this.permissions={},this.allPermissions={},this.mainPanelCollapsed=!1,this.visibleDialog=!1,this.formCarregado=!1,this.clienteFaturamentoLookupDisplayFields=["codigo","nome","cpfCnpj"],this.clienteFaturamentoAdvancedDisplayFields=["id","codigo","nome"],this.clienteFaturamentoLookupSeparator=" - ",this.clienteRemessaLookupDisplayFields=["codigo","nome","cpfCnpj"],this.clienteRemessaAdvancedDisplayFields=["id","codigo","nome"],this.clienteRemessaLookupSeparator=" - ",this.filialLookupDisplayFields=["codigo","nome"],this.filialAdvancedDisplayFields=["id","codigo","nome"],this.filialLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.pedidoVendaLookupDisplayFields=["numero","cliente"],this.pedidoVendaAdvancedDisplayFields=["id","numero","filial.nome","filial.codigo","pessoa.id","pessoa.codigo","pessoa.nome"],this.pedidoVendaLookupSeparator=" - ",this.pedidoVendaItemLookupDisplayFields=["sequencia","sku.descricao"],this.pedidoVendaItemAdvancedDisplayFields=["id","sequencia","sku.descricao"],this.pedidoVendaItemLookupSeparator=" - ",this.agendaLookupDisplayFields=["id","descricao"],this.agendaAdvancedDisplayFields=["id","descricao"],this.agendaLookupSeparator=" - ",this.disableButtonSave=!1,this.disableOrdersButtons=!0,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.ordersValid=!0,this.ngUnsubscribe=new t.Subject,this.formGroup=this.getFormGroup(),this.pedidoVendaForm=this.getPedidoVendaForm(),this.itemFormGroup=this.getOrdemVendaItemForm()}return e.prototype.ngOnInit=function(){var e=this;this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)}),this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;"new"!=a?e.getExpedicao(a):e.buscarFilial()}),this.clienteFaturamentoSearchFields=this.getClienteSearchFields(),this.clienteFaturamentoSearchGridFields=this.getClienteSearchGridFields(),this.clienteRemessaSearchFields=this.getClienteSearchFields(),this.clienteRemessaSearchGridFields=this.getClienteSearchGridFields(),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.pedidoVendaSearchFields=this.getPedidoVendaSearchFields(),this.pedidoVendaSearchGridFields=this.getPedidoVendaSearchGridFields(),this.pedidoVendaItemSearchFields=this.getPedidoVendaItemSearchFields(),this.pedidoVendaItemSearchGridFields=this.getPedidoVendaItemSearchGridFields(),this.agendaSearchFields=this.getAgendaSearchFields(),this.agendaSearchGridFields=this.getAgendaSearchGridFields(),this.setHotkeys(),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0,this.setPedidosValueChanges(),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.revalidacaoTransportadora(),this.verificaSeTemAlteracao()},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.revalidacaoTransportadora=function(){var e=this;this.formGroup.get("transportadora").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=e.formGroup.get("transportadora").value;e.erpProcessService&&a&&(e.erpProcessData.transportadoraId=a.id,e.erpProcessService.changeData(e.erpProcessData))})},e.prototype.abrirPedidoVenda=function(e){var t=document.getElementById("pedidoVenda").getElementsByTagName("button");t.length&&(this.pedidoVendaForm.patchValue({pedidoVenda:e}),t[0].click())},e.prototype.excluirPedidoVenda=function(e){this.formGroup.get("pedidos").removeAt(e)},e.prototype.abrirPedidoVendaItem=function(e,t){this.itemFormGroup.patchValue(t||{item:undefined,quantidade:1}),this.pedidoAtual=e,this.visibleDialog=!0},e.prototype.excluirPedidoVendaItem=function(e,t){var a=t.get("itens").value.findIndex(function(t){return t.item.id===e});a>=0&&t.get("itens").removeAt(a)},e.prototype.setPedidosValueChanges=function(){var e=this;this.formGroup.get("pedidos").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(){var t=e.formGroup.get("pedidos").length;e.ordersValid=t>0,e.formGroup.get("filial")[t>=1?"disable":"enable"]()})},e.prototype.selecionarPedidoVenda=function(e){if(this.formGroup.get("pedidos").value.find(function(t){return t.pedidoVenda.id===e.id}))return this.addMessage("warn",this.translate.instant("yms.erp.pedido_venda_search_already_selected_summary"),this.translate.instant("yms.erp.pedido_venda_search_already_selected_detail"));this.formGroup.get("pedidos").push(this.getOrdemVendaForm(e,!0)),e&&1===this.formGroup.get("pedidos").length&&!this.formGroup.get("clienteFaturamento").value&&this.buscarClienteAFaturar(e)},e.prototype.selecionarPedidoVendaItem=function(){var e=this.itemFormGroup.value,t=this.pedidoAtual.get("itens").value;if(t&&e&&e.item&&t.find(function(t){return t.item.id===e.item.id}))return this.addMessage("warn",this.translate.instant("yms.erp.item_pedido_venda_search_already_selected_summary"),this.translate.instant("yms.erp.item_pedido_venda_search_already_selected_detail"));var a=this.getOrdemVendaItemForm();a.patchValue(j({},this.itemFormGroup.value)),a.get("item").value!=undefined&&(this.pedidoAtual.get("itens").push(a),this.visibleDialog=!1)},e.prototype.selecionarPedidoVendaItemAutomaticamente=function(e,t){if(e&&1===e.length){var a=this.getOrdemVendaItemForm(),i=this.getPedidos().filter(function(e){return!(!e||!e.value.pedidoVenda)&&e.value.pedidoVenda.id===t.id});this.itemFormGroup.get("item").setValue(1===e.length?e[0]:{}),this.itemFormGroup.get("quantidade").setValue(1),a.patchValue(j({},this.itemFormGroup.value)),i[0].get("itens").push(a),this.visibleDialog=!1}},e.prototype.getPedidos=function(){return this.formGroup.get("pedidos").controls},e.prototype.buildTokens=function(e){return e.map(function(e){var t=e&&e.item?e.item:e,a=t.sku?t.sku:t.produto;return{id:t.id,label:"Produto: "+a.descricao+", Sequencia: "+t.sequencia}})},e.prototype.ngAfterViewInit=function(){var e=this,t=document.getElementsByTagName("input"),a=Array.from(t).find(function(e){return!e.disabled});a&&a.focus(),this.override.initialize(),this.saveAndInitButton=document.getElementById("init"),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)});(this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)||!this.permissions.editar)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.agenda&&this.agenda.createdByErp&&(this.formGroup.get("filial").disable(),this.formGroup.get("transportadora").disable(),this.formGroup.get("clienteRemessa").disable(),this.formGroup.get("clienteFaturamento").disable(),this.pedidoVendaForm.disable(),this.itemFormGroup.disable(),this.disableOrdersButtons=!0)},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.override.remove()},e.prototype.setHotkeys=function(){var e=this;this.hotkeysService.add(new G.Hotkey("alt+shift+s",function(){return(e.isNew()||e.permissions.editar)&&e.onSave(),!1},["INPUT","SELECT","TEXTAREA"])),this.hotkeysService.add(new G.Hotkey("alt+shift+c",function(){return e.onCancel(),!1},["INPUT","SELECT","TEXTAREA"]))},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.updateSuggestions=function(e){e.agenda&&(e.agenda.label=this.getSuggestionValue(["id","descricao"],"agenda",e,this.agendaLookupSeparator),e.agenda.label.trim()===this.agendaLookupSeparator.trim()&&delete e.agenda.label)},e.prototype.getSuggestionValue=function(e,t,a,i){var r=this;return e.map(function(e){return r.getProp(a,t+"."+e)}).reduce(function(e,t){return""+e+i+t})},e.prototype.onRouteDataChange=function(e){var t=e.localeConfig.number,a=t.currencySymbol,i=t.thousandsSeparator,r=t.decimalSeparator;if(this.localeConfig=e.localeConfig,this.currencyLocaleOptions={align:"left",prefix:a,thousands:i,decimal:r},this.permissions=e.allPermissions.expedicao,this.allPermissions=e.allPermissions,e.entity){this.permissions.editar||this.formGroup.disable();var o=Ki.fromDto(e.entity);this.updateSuggestions(o),this.formGroup.patchValue(o)}else this.formGroup.patchValue(new Ki)},e.prototype.onCancel=function(){this.goBack()},e.prototype.onSendFile=function(e,a){var i=[];return this.fieldCustomization.isEmpty(e)||i.push(this.fieldCustomization.deleteFiles(e)),this.fieldCustomization.isEmpty(a)||i.push(this.fieldCustomization.commitFiles(a)),this.fieldCustomization.isEmpty(i)?t.of({}):t.forkJoin(i)},e.prototype.setValuesPedidoBiodisel=function(){var e=this.formGroup.get("numeroPedidoCliente").value,t=this.formGroup.get("itemPedidoCliente").value,a=this.formGroup.get("pedidos").value;(a||[]).map(function(a){a&&a.itens&&a.itens.length&&(a.itens[0].numeroPedidoCliente=e,a.itens[0].itemPedidoCliente=t)}),this.formGroup.get("pedidos").patchValue(a)},e.prototype.getValuesPedidoBiodisel=function(){var e=this.formGroup.get("pedidos").value,t=this.formGroup.get("numeroPedidoCliente"),a=this.formGroup.get("itemPedidoCliente");(e||[]).map(function(e){if(!t.value||!a.value){var i=e&&e.itens&&e.itens.length?e.itens[0].pedido:null;i&&i.itens&&i.itens.length&&1===i.itens.length&&(t.patchValue(i.itens[0].numeroPedidoCliente),a.patchValue(i.itens[0].itemPedidoCliente))}})},e.prototype.onSave=function(e){var t=this;if(this.formGroup.get("agenda").setValue(this.agenda),this.ordersValid=this.formGroup.get("pedidos").length>0,this.formGroup.invalid||!this.ordersValid)return this.validateAllFormFields(this.formGroup);this.setValuesPedidoBiodisel();var i=this.fieldCustomization.getFiles(this.formGroup),r=i.filesToDelete,o=i.filesToCommit;return this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(r,o,e):(this.erpProcessData=this.erpProcessService.builderErpProcessData(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(r,o,e)}))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=It.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e,t,a){var i=this;this.atualizaExpedicao(e,t,function(){i.hasChangeService.hasChangeSave(i.agenda.id),a&&i.saveAndInitButton&&(i.hasChangeService.hasChangeSave(i.agenda.id),i.saveAndInitButton.click())})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.atualizaExpedicao=function(e,i,r){var o=this;return this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return o.loading=!1})).subscribe(function(n){o.formGroup.get("id").setValue(n.id||null),o.onSendFile(e,i).pipe(a.takeUntil(o.ngUnsubscribe),a.catchError(function(e){return o.loading=!1,t.throwError(e)})).subscribe(function(){o.addMessage("success","saved_message_title","saved_message_content"),r()})})},e.prototype.setTransportadora=function(e){var t=this;if(e){var i="pessoa.cpfCnpj eq '"+e.replace(".","").replace("/","").replace("-","")+"'";this.transportadoraService.list({filterQuery:i,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(1===a.length){var i=a[0].codigo?a[0].codigo.toString():"",r=a[0].descricao?a[0].descricao.toString():"";r.trim()||i.trim()?a[0].label=i+" - "+r:a[0].label=t.translate.instant("yms.erp.derivacao_sem_descricao"),t.formGroup.get("transportadora").setValue(a[0])}})}},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.getExpedicao=function(e){var t=this;this.loading=!0,this.expedicaoService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(e){var a=e.contents;if(a.length){t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var i=Ki.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(i),i.pedidos.forEach(function(e){var a=t.getOrdemVendaForm();a.patchValue(e),e.itens.forEach(function(e){var i=t.getOrdemVendaItemForm();i.patchValue(e),a.get("itens").push(i)}),t.formGroup.get("pedidos").push(a)}),t.getValuesPedidoBiodisel(),t.formCarregado=!0}else t.buscarFilial()})},e.prototype.onClienteFaturamentoLookupRequest=function(e){var t=this;Oe(this.clienteFaturamentoSearchFields,this.clienteFaturamentoLookupDisplayFields,this.clienteFaturamentoAdvancedDisplayFields,this.clienteFaturamentoLookupSeparator,this.pessoaService,e,"cliente eq true").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.clienteFaturamentoLookupSuggestions=e.contents})},e.prototype.onClienteFaturamentoSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getClienteSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Wi(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Wi(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Wi(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":a==n.FieldType.Lookup?t+" eq '"+i.id+"'":t+" eq '"+i+"'"}).join(" and ");c=c+(c?" and ":"")+"situacao eq ATIVO and cliente eq true";var p=_e(this.clienteFaturamentoLookupDisplayFields,this.clienteFaturamentoAdvancedDisplayFields);this.pessoaService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.clienteFaturamentoLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.clienteFaturamentoLookupSeparator)})})})})).subscribe(function(e){t.clienteFaturamentoSearchGridData=e.contents,t.clienteFaturamentoSearchTotalRecords=e.totalElements})},e.prototype.onClienteRemessaLookupRequest=function(e){var t=this;Oe(this.clienteRemessaSearchFields,this.clienteRemessaLookupDisplayFields,this.clienteRemessaAdvancedDisplayFields,this.clienteRemessaLookupSeparator,this.pessoaService,e,"cliente eq true").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.clienteRemessaLookupSuggestions=e.contents})},e.prototype.onClienteRemessaSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getClienteSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Wi(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Wi(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Wi(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and ");c=c+(c?" and ":"")+"situacao eq ATIVO and cliente eq true";var p=_e(this.clienteRemessaLookupDisplayFields,this.clienteRemessaAdvancedDisplayFields);this.pessoaService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.clienteRemessaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.clienteRemessaLookupSeparator)})})})})).subscribe(function(e){t.clienteRemessaSearchGridData=e.contents,t.clienteRemessaSearchTotalRecords=e.totalElements})},e.prototype.onFilialSelect=function(e){this.disableOrdersButtons=!e||this.agenda.createdByErp},e.prototype.onFilialLookupRequest=function(e){var t=this,i=this.getFilialSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).reduce(function(t,a){var i,r,o=a.name;return a.type===n.FieldType.Integer?j({},t,((i={})[o]=e.replace(/\D/,""),i)):j({},t,((r={})[o]=e,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(i).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return ma.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(ma.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Oe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this;xe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.onPedidoVendaLookupRequest=function(e){var t=this,i=this.pedidoVendaLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=this.getPedidoVendaSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+Wi(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+Wi(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+Wi(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or ");r=r+(r?" and ":"")+"situacaoPedido eq ABERTO_TOTAL or situacaoPedido eq ABERTO_PARCIAL";var o=this.formGroup.get("pedidos").value||[],s="";o.map(function(e){return!!(e&&e.pedidoVenda&&e.pedidoVenda.id)&&(s+=" and (id ne '"+e.pedidoVenda.id+"')")}),o.length&&s&&(r+=s);var l=_e(this.pedidoVendaLookupDisplayFields,this.pedidoVendaAdvancedDisplayFields);this.pedidoVendaService.list({sort:i,filterQuery:r,displayFields:l}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.pedidoVendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaLookupSuggestions=e.contents})},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.onPedidoVendaSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,n=e.filterData,s=o||[],l=this.formGroup.get("filial").value,d=this.formGroup.get("pedidos").value||[],c=[];d.map(function(e){return!!(e&&e.pedidoVenda&&e.pedidoVenda.id)&&c.push(e.pedidoVenda.id)});var p={pessoaId:n.cliente?n.cliente.id:null,filialId:l?l.id:null,tipoAgendamentoId:this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,filialPedido:n.filialPedido,pedidosSelecionados:c,numero:n.numero,pagina:this.getRecPagina(i,r,s)};this.pedidoVendaService.pesquisarPedidosVenda(p).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.pedidoVendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaSearchGridData=e.contents,t.pedidoVendaSearchTotalRecords=e.totalElements})},e.prototype.onPedidoVendaItemLookupRequest=function(e){var t=this,i=this.pedidoVendaItemLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=(this.formGroup.get("filial").value||{}).id,o={pedidoId:(this.pedidoAtual.get("pedidoVenda").value||{}).id,filialId:r,sequencia:isNaN(e)?null:e,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(0,10,i)};this.pedidoVendaItemService.pesquisarItensPedidoVenda(o).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.pedidoVendaItemLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaItemLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaItemLookupSuggestions=e.contents})},e.prototype.onPedidoVendaItemSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,n=e.filterData,s=o,l=(this.formGroup.get("filial").value||{}).id,d={pedidoId:(this.pedidoAtual.get("pedidoVenda").value||{}).id,filialId:l,sequencia:n.sequencia,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(i,r,s)};this.pedidoVendaItemService.pesquisarItensPedidoVenda(d).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.pedidoVendaItemLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaItemLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaItemSearchGridData=e.contents,t.pedidoVendaItemSearchTotalRecords=e.totalElements})},e.prototype.getAutomaticItensOrder=function(e){var t=this;if(e&&e.id){var i=this.pedidoVendaItemLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=(this.formGroup.get("filial").value||{}).id,o={pedidoId:e.id,filialId:r,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(0,10,i)};this.pedidoVendaItemService.pesquisarItensPedidoVenda(o).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.pedidoVendaItemLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaItemLookupSeparator)})})})})).subscribe(function(a){t.selecionarPedidoVendaItemAutomaticamente(a.contents,e)})}},e.prototype.onAgendaLookupRequest=function(e){var t=this,i=this.agendaLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=this.getAgendaSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+Wi(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+Wi(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+Wi(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or "),o=_e(this.agendaLookupDisplayFields,this.agendaAdvancedDisplayFields);this.agendaService.listExternalAgenda({sort:i,filterQuery:r,displayFields:o}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.agendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.agendaLookupSeparator)})})})})).subscribe(function(e){t.agendaLookupSuggestions=e.contents})},e.prototype.onAgendaSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getAgendaSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Wi(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Wi(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Wi(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and "),p=_e(this.agendaLookupDisplayFields,this.agendaAdvancedDisplayFields);this.agendaService.listExternalAgenda({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.agendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.agendaLookupSeparator)})})})})).subscribe(function(e){t.agendaSearchGridData=e.contents,t.agendaSearchTotalRecords=e.totalElements})},e.prototype.getFormGroup=function(){return this.formBuilder.group({id:[{value:undefined,disabled:!0},C.Validators.compose([])],clienteFaturamento:[{value:undefined,disabled:!1},C.Validators.compose([C.Validators.required])],clienteRemessa:[{value:undefined,disabled:!1}],filial:[{value:undefined,disabled:!1},C.Validators.compose([C.Validators.required])],transportadora:[{value:undefined,disabled:!1},C.Validators.compose([])],pedidos:this.formBuilder.array([]),agenda:[{value:undefined,disabled:!1},C.Validators.compose([C.Validators.required])],numeroAgendamentoCliente:[{value:undefined,disabled:!1},C.Validators.compose([])],numeroPedidoCliente:[{value:undefined,disabled:!1},C.Validators.compose([])],itemPedidoCliente:[{value:undefined,disabled:!1},C.Validators.compose([])],createdBy:[{value:undefined,disabled:!0},C.Validators.compose([])],createdDate:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedBy:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedDate:[{value:undefined,disabled:!0},C.Validators.compose([])]})},e.prototype.getClienteSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.pessoa_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.pessoa_nome"),type:n.FieldType.String}),new n.FormField({name:"cpfCnpj",label:this.translate.instant("yms.erp.pessoa_cpfCnpj"),type:n.FieldType.String})]},e.prototype.getClienteSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.pessoa_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.pessoa_nome"),type:n.FieldType.String}),new n.FormField({name:"cpfCnpj",label:this.translate.instant("yms.erp.pessoa_cpfCnpj"),type:n.FieldType.String}),new n.FormField({name:"site",label:this.translate.instant("yms.erp.pessoa_site"),type:n.FieldType.String})]},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.filial_nome"),type:n.FieldType.String})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.filial_nome"),type:n.FieldType.String})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getPedidoVendaSearchFields=function(){var e=this,i=new t.Subject,r=new t.Subject;return[new n.FormField({name:"numero",label:this.translate.instant("yms.erp.pedido_venda_numero"),type:n.FieldType.Integer}),new n.FormField({name:"filialPedido",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"cliente",label:this.translate.instant("yms.erp.pessoa_cliente_label"),type:n.FieldType.Lookup,searchFields:this.getClienteSearchFields(),searchGridFields:this.getClienteSearchGridFields(),suggestionsObservable:i,searchObservable:r,emptyMessage:"Nenhuma sugestão encontrada",size:{sm:12,md:12,lg:12,xl:12},onLookupRequest:function(t){Oe(e.clienteFaturamentoSearchFields,e.clienteFaturamentoLookupDisplayFields,e.clienteFaturamentoAdvancedDisplayFields,e.clienteFaturamentoLookupSeparator,e.pessoaService,t,"situacao eq ATIVO and cliente eq true").pipe(a.takeUntil(e.ngUnsubscribe)).subscribe(function(e){return i.next(e.contents)})},onSearchRequest:function(t){xe(e.clienteFaturamentoSearchFields,e.clienteFaturamentoLookupDisplayFields,e.clienteFaturamentoAdvancedDisplayFields,e.clienteFaturamentoLookupSeparator,e.pessoaService,t,"situacao eq ATIVO and cliente eq true").pipe(a.takeUntil(e.ngUnsubscribe)).subscribe(function(e){r.next({totalRecords:e.totalElements,gridData:e.contents})})},dataKey:"id",lookupDisplayField:"label",searchTitle:this.translate.instant("yms.erp.pessoa_cliente_label"),searchEmptyTitle:this.translate.instant("yms.erp.nothing_found"),filterLabel:this.translate.instant("yms.erp.filter"),filterTitle:this.translate.instant("yms.integration.filters"),clearLabel:this.translate.instant("yms.erp.clear"),cancelLabel:this.translate.instant("yms.erp.cancel"),selectLabel:this.translate.instant("yms.erp.select"),tooltip:this.translate.instant("yms.erp.pessoa_cliente_label")})]},e.prototype.getPedidoVendaSearchGridFields=function(){return[new n.FormField({name:"numero",label:this.translate.instant("yms.erp.pedido_venda_numero"),type:n.FieldType.Integer}),new n.FormField({name:"filial.nome",label:this.translate.instant("yms.erp.filial"),type:n.FieldType.String}),new n.FormField({name:"filial.codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"pessoa.nome",label:this.translate.instant("yms.erp.pessoa_cliente_label"),type:n.FieldType.Integer}),new n.FormField({name:"pessoa.codigo",label:this.translate.instant("yms.erp.pessoa_cliente_codigo_label"),type:n.FieldType.Integer})]},e.prototype.getPedidoVendaItemSearchFields=function(){return[new n.FormField({name:"sequencia",label:this.translate.instant("yms.erp.pedido_venda_item_sequencia"),type:n.FieldType.Integer})]},e.prototype.getPedidoVendaItemSearchGridFields=function(){return H(this.getPedidoVendaItemSearchFields(),[new n.FormField({name:"sku.descricao",label:this.translate.instant("yms.erp.produto"),type:n.FieldType.String})])},e.prototype.getAgendaSearchFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getAgendaSearchGridFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.goBack=function(){this.router.navigate(["../"],{relativeTo:this.route.parent})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup&&t.validateAllFormFields(i)}),this.focusService.focusFirstInvalidInput()},e.prototype.getSaveObservable=function(){var e,t=this.formGroup.getRawValue(),a=Ki.toDto(t);if(this.isNew()&&!t.id)e=this.expedicaoService.insert(a);else{var i=t.id;e=this.expedicaoService.update(i,a)}return e},e.prototype.validateVisualization=function(){ke(this.formGroup,this.allPermissions)||this.addMessage("error","yms.erp.cannot_visualize_form_summary","yms.erp.cannot_visualize_form_detail")},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.getPedidoVendaForm=function(){return this.formBuilder.group({pedidoVenda:[undefined]})},e.prototype.getOrdemVendaForm=function(e,t){return t&&this.getAutomaticItensOrder(e),this.formBuilder.group({id:[undefined],pedidoVenda:[e],itens:this.formBuilder.array([])})},e.prototype.getOrdemVendaItemForm=function(e){return this.formBuilder.group({id:[undefined],pedido:[undefined],item:[e],quantidade:[undefined],numeroPedidoCliente:[undefined],itemPedidoCliente:[undefined]})},e.prototype.buscarFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length?(this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&(e.formGroup.get("filial").setValue(ma.fromDto(a[0])),e.disableOrdersButtons=!1)}),this.formCarregado=!0):this.formCarregado=!0},e.prototype.buscarClienteAFaturar=function(e){var t=this;this.pessoaService.list({size:1,page:0,filterQuery:"id eq '"+e.pessoa.id+"'"}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;1===(a||[]).length&&t.formGroup.get("clienteFaturamento").setValue(ta.fromDto(a[0]))})},V([r.Input(),B("design:type",qe)],e.prototype,"agenda",void 0),V([r.Input(),B("design:type",Boolean)],e.prototype,"revalidacao",void 0),V([r.ViewChild("customTemplate"),B("design:type",r.TemplateRef)],e.prototype,"customTemplate",void 0),V([r.ViewChild("customFormFields"),B("design:type",r.TemplateRef)],e.prototype,"customFormFields",void 0),e=V([r.Component({selector:"expedicao-form",template:'<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-g">\n <div class="ui-g-12 ui-md-12">\n <label class="required-h3">Pedidos:</label>\n <s-button label="Adicionar pedido" priority="default" (onClick)="abrirPedidoVenda()" [disabled]="disableButtonSave || disableOrdersButtons"></s-button>\n <div class="error-required-message" [hidden]="ordersValid">{{\'yms.erp.error_required\' | translate}}</div>\n <p-accordion>\n <p-accordionTab *ngFor="let pedido of getPedidos(); let i = index">\n <p-header>\n Pedido: {{ pedido.get(\'pedidoVenda\')?.value?.numero }}\n </p-header>\n \n <div style="margin: 10px 0; display: block;">\n <s-button label="Adicionar item do pedido" priority="default" size="small"\n (onClick)="abrirPedidoVendaItem(pedido)" [disabled]="disableButtonSave || disableOrdersButtons"></s-button>\n <s-button label="Excluir pedido" priority="default" size="small"\n (onClick)="excluirPedidoVenda(i)" [disabled]="disableButtonSave || disableOrdersButtons"></s-button>\n </div>\n \n <s-token-list [tokens]="buildTokens(pedido.get(\'itens\')?.value)" [removableTokens]="true"\n (tokenRemoved)="excluirPedidoVendaItem($event.id, pedido)">\n </s-token-list>\n </p-accordionTab>\n </p-accordion>\n <div style="display: inline-block;" class="separator"></div>\n </div>\n </div>\n <div class="ui-fluid">\n <div class="ui-g">\n <div [attr.data-hidden]="true" class="ui-g-12 ui-md-6">\n <label for="id">{{"yms.erp.recebimento_id" | translate}}</label>\n <input #idFormInput type="text" id="id" name="id" pInputText formControlName="id"\n autocomplete="off" />\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="filial">{{"yms.erp.expedicao_filial" | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions" (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n (onSelect)="onFilialSelect($event)"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="clienteFaturamento">{{"yms.erp.expedicao_cliente_faturamento" | translate}}</label>\n <s-lookup dataKey="id" id="clienteFaturamento" name="clienteFaturamento"\n formControlName="clienteFaturamento" [searchFields]="clienteFaturamentoSearchFields"\n [searchGridFields]="clienteFaturamentoSearchGridFields"\n [searchGridData]="clienteFaturamentoSearchGridData" [multiple]="false"\n [lookupSuggestions]="clienteFaturamentoLookupSuggestions"\n (onLookupRequest)="onClienteFaturamentoLookupRequest($event)"\n (onSearchRequest)="onClienteFaturamentoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="clienteFaturamentoSearchTotalRecords"\n [searchTitle]="\'yms.erp.cliente_faturamento_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: clienteFaturamentoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'clienteFaturamento\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="clienteRemessa">{{"yms.erp.expedicao_cliente_remessa" | translate}}</label>\n <s-lookup dataKey="id" id="clienteRemessa" name="clienteRemessa" formControlName="clienteRemessa"\n [searchFields]="clienteRemessaSearchFields" [searchGridFields]="clienteRemessaSearchGridFields"\n [searchGridData]="clienteRemessaSearchGridData" [multiple]="false"\n [lookupSuggestions]="clienteRemessaLookupSuggestions"\n (onLookupRequest)="onClienteRemessaLookupRequest($event)"\n (onSearchRequest)="onClienteRemessaSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="clienteRemessaSearchTotalRecords"\n [searchTitle]="\'yms.erp.cliente_remessa_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: clienteRemessaSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'clienteRemessa\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="transportadora">{{"yms.erp.expedicao_transportadora" | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchGridFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="numeroAgendamentoCliente">Número agendamento do cliente</label>\n <input type="text" pInputText formControlName="numeroAgendamentoCliente" pattern="[0-9]+$">\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="numeroPedidoCliente">Número pedido do cliente</label>\n <input type="text" pInputText formControlName="numeroPedidoCliente" pattern="[0-9]+$">\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="itemPedidoCliente">Item pedido do cliente</label>\n <input type="text" pInputText formControlName="itemPedidoCliente" pattern="[0-9]+$">\n </div>\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">{{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} / </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">{{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}</label>\n </div>\n </div>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button priority="primary" [label]="\'save\' | translate" (onClick)="onSave()" [disabled]="disableButtonSave"></s-button>\n <s-button *ngIf="saveAndInitButton" priority="primary" [label]="\'save_and_init\' | translate" (onClick)="onSave(true)" [disabled]="disableButtonSave"></s-button>\n </div>\n\n <form [formGroup]="pedidoVendaForm" [hidden]="true">\n <s-lookup dataKey="id" id="pedidoVenda" name="pedidoVenda" formControlName="pedidoVenda"\n [searchFields]="pedidoVendaSearchFields" [searchGridFields]="pedidoVendaSearchGridFields"\n [searchGridData]="pedidoVendaSearchGridData" [multiple]="false"\n [lookupSuggestions]="pedidoVendaLookupSuggestions" (onLookupRequest)="onPedidoVendaLookupRequest($event)"\n (onSearchRequest)="onPedidoVendaSearchRequest($event)" lookupDisplayField="label"\n (onSelect)="selecionarPedidoVenda($event)" [searchTotalRecords]="pedidoVendaSearchTotalRecords"\n [searchTitle]="\'yms.erp.pedido_venda_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate" [filterLabel]="\'yms.erp.filter\' | translate"\n [clearLabel]="\'yms.erp.clear\' | translate" [cancelLabel]="\'yms.erp.cancel\' | translate"\n [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: pedidoVendaSearchTotalRecords}">\n </s-lookup>\n </form>\n\n <p-dialog [(visible)]="visibleDialog" styleClass="s-lookup-modal" [modal]="true">\n <p-header>\n Adicionar item\n </p-header>\n\n <form [formGroup]="itemFormGroup">\n <div class="ui-fluid">\n <div class="ui-g">\n <div class="ui-g-12 ui-md-6">\n <label for="item">Item do pedido</label>\n <s-lookup dataKey="id" id="item" name="item" formControlName="item"\n [searchFields]="pedidoVendaItemSearchFields"\n [searchGridFields]="pedidoVendaItemSearchGridFields"\n [searchGridData]="pedidoVendaItemSearchGridData" [multiple]="false"\n [lookupSuggestions]="pedidoVendaItemLookupSuggestions"\n (onLookupRequest)="onPedidoVendaItemLookupRequest($event)"\n (onSearchRequest)="onPedidoVendaItemSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="pedidoVendaItemSearchTotalRecords"\n [searchTitle]="\'yms.erp.expedicao_pedido_venda_itens_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: pedidoVendaItemSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="quantidade">Quantidade</label>\n <input type="number" pInputText formControlName="quantidade">\n </div>\n </div>\n </div>\n </form>\n\n <p-footer>\n <s-button [label]="\'select\' | translate" (onClick)="selecionarPedidoVendaItem()"></s-button>\n </p-footer>\n </p-dialog>\n</div>',styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),B("design:paramtypes",[Vt,F.Router,F.ActivatedRoute,I.MessageService,C.FormBuilder,o.TranslateService,G.HotkeysService,Be,Ue,Xa,qa,pi,za,Ua,qt,Ut,c.ConfirmationService,ri,oi,ai])],e)}(),Xi=function(){function e(e){this.expedicaoService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.expedicaoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Dados de expedição não encontrados")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.expedicao=Ki.fromDto(t)})},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"expedicao-info",template:'\n <div *sLoadingState="loading" style="padding: 20px">\n <div class="detail-pane" *ngIf="agenda && expedicao">\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_filial\' | translate}}</span>\n <span class="data">{{expedicao.filial?.codigo}} - {{expedicao.filial?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_cliente_faturamento\' | translate}}</span>\n <span class="data">{{expedicao.clienteFaturamento?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_cliente_remessa\' | translate}}</span>\n <span class="data">{{expedicao.clienteRemessa?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_transportadora\' | translate}}</span>\n <span class="data">{{expedicao.transportadora?.pessoa?.nomeFantasia}}</span>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),B("design:paramtypes",[Vt])],e)}(),Zi=function(){function e(){}return e=V([p.CircuitoFinalizado({header:"Logs de integração YMS/ERP",name:"yms.integracao.erpagrox"})],e)}(),er=function(e){function i(a,i,r){var o=e.call(this)||this;return o.route=a,o.logIntegracaoService=i,o.translate=r,o.allPermissions={},o.permissions={},o.localeConfig={},o.currentListParams={page:0,size:10,sort:[],filterData:{}},o.serverError=!1,o.ngUnsubscribe=new t.Subject,o.xmlFormatter=require("xml-formatter")||function(e,t){return e},o}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this.gridColumns=this.getGridColumns(),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)})},i.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},i.prototype.onRouteDataChange=function(e){this.allPermissions=e.allPermissions,this.permissions=e.allPermissions.logIntegracao,this.localeConfig=e.localeConfig},i.prototype.onSearch=function(){this.resetGrid()},i.prototype.onGridChange=function(e){var t=e.rows,a=e.first/t,i=e.multiSortMeta;return this.updateGrid({page:a,size:t,sort:i})},i.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},i.prototype.getGridColumns=function(){return[{field:"nome",header:this.translate.instant("yms.integration.log_integracao_nome")},{field:"entradaEm",header:this.translate.instant("yms.integration.log_integracao_entrada_em")},{field:"saidaEm",header:this.translate.instant("yms.integration.log_integracao_saida_em")}]},i.prototype.updateGrid=function(e){var t=this;void 0===e&&(e={}),this.showLoader=!0,this.currentListParams=j({},this.currentListParams,e);var i=this.currentListParams,r=i.page,o=i.size;this.logIntegracaoService.list({page:r,size:o,sort:[{field:"entradaEm",order:-1}],filterQuery:"agenda eq '"+this.agenda.id+"'",displayFields:["*"]}).pipe(a.takeUntil(this.ngUnsubscribe),a.catchError(function(e){throw t.serverError=!0,e}),a.finalize(function(){t.showLoader=!1})).subscribe(function(e){t.selection=[],t.gridData=e.contents,t.totalRecords=e.totalElements,t.serverError=!1})},i.prototype.getPayload=function(e){return"{"==e[0]?JSON.stringify(JSON.parse(e),null,2):"<"===e[0]?this.xmlFormatter(e):e},i.prototype.resetGrid=function(e){e&&(this.currentListParams=j({},this.currentListParams,e)),this.currentListParams=j({},this.currentListParams,{page:0,sort:[]}),this.table.reset()},i.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup&&t.validateAllFormFields(i)})},V([r.Input(),B("design:type",qe)],i.prototype,"agenda",void 0),V([r.ViewChild("logIntegracaoTable"),B("design:type",l.Table)],i.prototype,"table",void 0),V([r.ViewChild("customTemplate"),B("design:type",r.TemplateRef)],i.prototype,"customTemplate",void 0),V([r.ViewChild("customFilterFields"),B("design:type",r.TemplateRef)],i.prototype,"customFilterFields",void 0),V([r.ViewChild("customGridColgroup"),B("design:type",r.TemplateRef)],i.prototype,"customGridColgroup",void 0),V([r.ViewChild("customGridHeader"),B("design:type",r.TemplateRef)],i.prototype,"customGridHeader",void 0),V([r.ViewChild("customGridBody"),B("design:type",r.TemplateRef)],i.prototype,"customGridBody",void 0),i=V([r.Component({template:'<div *sLoadingState="showLoader">\n <s-empty-state *ngIf="serverError" iconClass="fa fa-exclamation-triangle" title="{{\'yms.integration.error_server_title\' | translate}}"\n primaryActionLabel="{{\'yms.integration.error_server_try_again\' | translate}}" (primaryAction)="resetGrid()"\n description="{{\'yms.integration.error_server_description\' | translate}}"></s-empty-state>\n <s-empty-state *ngIf="gridData && !gridData.length" [title]="\'yms.integration.log_integracao_empty_state_title\' | translate"\n [description]="\'yms.integration.log_integracao_empty_state_description\' | translate"></s-empty-state>\n <div [attr.data-hidden]="!gridData?.length || serverError">\n <div class="ui-g">\n <div class="ui-g-12">\n <p-table #logIntegracaoTable [value]="gridData" [columns]="gridColumns" dataKey="id" [lazy]="true" [scrollable]="true"\n [resizableColumns]="true" [paginator]="true" [totalRecords]="totalRecords"\n rows="10" [rowsPerPageOptions]="[10, 20, 50, 100]" [(selection)]="selection" (onLazyLoad)="onGridChange($event)" >\n <ng-template pTemplate="colgroup" let-columns *ngIf="!customGridColgroup else customGridColgroup">\n <colgroup>\n <col *ngFor="let col of columns" [style.width]="col.width">\n \x3c!--{CA:GRID_COLGROUP_COLUMNS:START}--\x3e\n \x3c!--{CA:GRID_COLGROUP_COLUMNS:END}--\x3e\n </colgroup>\n </ng-template>\n <ng-template pTemplate="header" let-columns *ngIf="!customGridHeader else customGridHeader">\n <tr>\n <th style="width: 50px">\n \n </th>\n <th *ngFor="let col of columns; let i = index" [ngStyle]="i === 0 ? {\'width\': \'200px\'} : {\'width\': \'150px\'}" pResizableColumn>\n <div class="senior-header">\n <span class="senior-header-title">{{col.header}}</span>\n </div>\n </th>\n \x3c!--{CA:GRID_HEADER_COLUMNS:START}--\x3e\n \x3c!--{CA:GRID_HEADER_COLUMNS:END}--\x3e\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData let-columns let-expanded="expanded" *ngIf="!customGridBody else customGridBody">\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px;">\n <a href="#" [pRowToggler]="rowData">\n <i [ngClass]="expanded ? \'pi pi-chevron-down\' : \'pi pi-chevron-right\'"></i>\n </a>\n </td>\n <td (click)="selection = [rowData]" style="width: 200px">\n <span>{{getProp(rowData, \'nome\') || (\'yms.integration.list_grid_empty_field\' | translate)}}</span>\n </td>\n <td (click)="selection = [rowData]" style="width: 150px">\n <span>{{getProp(rowData, \'entradaEm\') | localizedDate | async}}</span>\n </td>\n <td (click)="selection = [rowData]" style="width: 150px">\n <span>{{getProp(rowData, \'saidaEm\') | localizedDate | async}}</span>\n </td>\n \x3c!--{CA:GRID_BODY_COLUMNS:START}--\x3e\n \x3c!--{CA:GRID_BODY_COLUMNS:END}--\x3e\n </tr>\n </ng-template>\n <ng-template pTemplate="rowexpansion" let-rowData>\n <td colspan="4">\n <p-tabView>\n <p-tabPanel header="Payload de entrada">\n <pre *ngIf="rowData.entrada">\n <code [highlight]="getPayload(rowData.entrada)" [languages]="[\'json\', \'xml\']">\n </code>\n </pre>\n <s-empty-state *ngIf="!rowData.entrada" [title]="\'Não há informação\' | translate"\n [description]="\'Não há informações a serem exibidas\' | translate">\n </s-empty-state>\n </p-tabPanel>\n <p-tabPanel header="Payload de saída">\n <pre *ngIf="rowData.saida">\n <code [highlight]="getPayload(rowData.saida)" [languages]="[\'json\', \'xml\']">\n </code>\n </pre>\n <s-empty-state *ngIf="!rowData.saida" [title]="\'Não há informação\' | translate"\n [description]="\'Não há informações a serem exibidas\' | translate">\n </s-empty-state>\n </p-tabPanel>\n <p-tabPanel header="Stack Trace">\n <pre *ngIf="rowData.stackTrace">\n <code [highlight]="getPayload(rowData.stackTrace)" [languages]="[\'json\', \'xml\']">\n </code>\n </pre>\n <s-empty-state *ngIf="!rowData.stackTrace" [title]="\'Não há informação\' | translate"\n [description]="\'Não há informações a serem exibidas\' | translate">\n </s-empty-state>\n </p-tabPanel>\n </p-tabView>\n <div class="separator"></div>\n </td>\n </ng-template>\n <ng-template pTemplate="paginatorright">\n <span [translate]="\'yms.integration.total_records\'" [translateParams]="{value: totalRecords}"></span>\n </ng-template>\n \x3c!--{CA:GRID_TEMPLATES:START}--\x3e\n \x3c!--{CA:GRID_TEMPLATES:END}--\x3e\n </p-table>\n </div>\n </div>\n </div>\n</div>\n\x3c!--{CA:FILE_CONTENTS:START}--\x3e\n\x3c!--{CA:FILE_CONTENTS:END}--\x3e',providers:[O.ConfirmationService],styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),B("design:paramtypes",[F.ActivatedRoute,Ti,o.TranslateService])],i)}(Zi),tr=function(){function e(){}return e.fromDto=function(e){var t=j({},e);return t.filial=ma.fromDto(t.filial),t},e.toDto=function(e){var t=j({},e);return t.filial=ma.toDto(t.filial),t},e}(),ar=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.processoAvulsoService=a,this.AVULSO_KEY="ERP_SENIOR_PROCESSO_AVULSO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.AVULSO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.AVULSO_KEY)},e.prototype.functionToOverride=function(e){var i=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return i.processoAvulsoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?i.processoAvulsoService.registrarChegada({processoAvulso:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Os dados da guia ERP Senior não foram informados")}))},e=V([r.Injectable(),B("design:paramtypes",[p.ChegadaVeiculoOverride,qt,_i])],e)}(),ir=function(){function e(e,a,i,r,o,n,s,l,d,c,p,u,m){this.fb=e,this.router=a,this.route=i,this.filialService=r,this.processoAvulsoService=o,this.messageService=n,this.processoAvulsoOverride=s,this.translate=l,this.confirmationService=d,this.agendaService=c,this.erpProcessService=p,this.erpFormConfigService=u,this.hasChangeService=m,this.loading=!1,this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.permissions={},this.formCarregado=!1,this.ngUnsubscribe=new t.Subject}return e.prototype.ngOnInit=function(){var e=this;this.formGroup=this.fb.group({id:[undefined],filial:[undefined,C.Validators.required],agenda:[undefined]}),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.getProcessoAvulso(),this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=e.formGroup.get("filial").value;e.erpProcessService&&a&&(e.erpProcessData.filialId=a.id,e.erpProcessService.changeData(e.erpProcessData))}),this.processoAvulsoOverride.initialize(),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)}),this.verificaSeTemAlteracao()},e.prototype.onRouteDataChange=function(e){this.permissions=e.allPermissions.agenda},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngAfterViewInit=function(){var e=this;this.saveAndInitButton=document.getElementById("init"),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.processoAvulsoOverride.remove()},e.prototype.onSave=function(e){var t=this;return this.formGroup.invalid?this.validateAllFormFields(this.formGroup):(this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessData(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)})))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=It.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.patchValue(j({},tr.fromDto(a))),t.successMessage(),t.hasChangeService.hasChangeSave(t.agenda.id),e&&t.saveAndInitButton&&(t.hasChangeService.hasChangeSave(t.agenda.id),t.saveAndInitButton.click())})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.onFilialLookupRequest=function(e){var t=this,i=this.getFilialSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).reduce(function(t,a){var i,r,o=a.name;return a.type===n.FieldType.Integer?j({},t,((i={})[o]=e.replace(/\D/,""),i)):j({},t,((r={})[o]=e,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(i).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return ma.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(ma.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.getSaveObservable=function(){var e=this.formGroup.value;e.agenda=this.agenda;var t=tr.toDto(e);return e.id?this.processoAvulsoService.update(e.id,t):this.processoAvulsoService.insert(t)},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup?t.validateAllFormFields(i):i instanceof C.FormArray&&i.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e.prototype.getProcessoAvulso=function(){var e=this;this.processoAvulsoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;if(!a||a.length<=0)return e.buscarFilial();var i=a[0];e.formGroup.patchValue(j({},tr.fromDto(i))),e.formCarregado=!0})},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")})]},e.prototype.buscarFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length&&this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&e.formGroup.get("filial").setValue(ma.fromDto(a[0]))}),this.formCarregado=!0},V([r.Input(),B("design:type",qe)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"processo-avulso-form",template:'<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-md-6 ui-g-12 required">\n <label for="filial">{{\'yms.erp.recebimento_ordem_compra_filial\' | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions" (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}"\n [disabled]="!permissions.editar">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button priority="primary" [label]="\'save\' | translate" (onClick)="onSave()" \n [disabled]="loading || !permissions.editar"></s-button>\n <s-button *ngIf="saveAndInitButton" priority="primary" [label]="\'save_and_init\' | translate"\n (onClick)="onSave(true)" [disabled]="loading || !permissions.editar"></s-button>\n </div>\n</div>'}),B("design:paramtypes",[C.FormBuilder,F.Router,F.ActivatedRoute,qa,_i,c.MessageService,ar,o.TranslateService,c.ConfirmationService,qt,ri,oi,ai])],e)}(),rr=function(){function e(e){this.processoAvulsoService=e,this.loading=!1,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.processoAvulsoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(t){var a=t.contents;!a||a.length<=0||(e.processoAvulso=tr.fromDto(a[0]))})},V([r.Input(),B("design:type",qe)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"processo-avulso-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n <div class="detail-span">\n <span class="title">{{\'yms.erp.filial\' | translate}}</span>\n <span class="data">{{processoAvulso?.filial?.nome}} - {{processoAvulso?.filial?.codigo}}</span>\n </div>\n </div>\n </div>\n '}),B("design:paramtypes",[_i])],e)}(),or=_,nr=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.competenciaInicial=a.competenciaInicial&&or(a.competenciaInicial).toDate(),a.competenciaFinal=a.competenciaFinal&&or(a.competenciaFinal).toDate(),a.createdDate=a.createdDate&&or(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&or(a.lastModifiedDate).toDate();return a.label=Ne(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"Safra")),a},e.toDto=function(e,t){var a=j({},e);return a.competenciaInicial=a.competenciaInicial&&or(a.competenciaInicial).format("YYYY-MM-DD"),a.competenciaFinal=a.competenciaFinal&&or(a.competenciaFinal).format("YYYY-MM-DD"),a.createdDate=a.createdDate&&or(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&or(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"Safra")),a},e}(),sr=_,lr=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&sr(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&sr(a.lastModifiedDate).toDate();return a.label=[""].map(function(e){return a[e]}).join(" - "),"Agenda"!==t&&a.agenda&&(a.agenda=qe.fromDto(a.agenda,"RecebimentoOrdemCompra")),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"RecebimentoOrdemCompra")),"Filial"!==t&&a.filial&&(a.filial=ma.fromDto(a.filial,"RecebimentoOrdemCompra")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=pa.fromDto(a.origemMercadoria,"RecebimentoOrdemCompra")),"Produto"!==t&&a.produto&&(a.produto=Li.fromDto(a.produto,"RecebimentoOrdemCompra")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=Pi.fromDto(a.derivacao,"RecebimentoOrdemCompra")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.fromDto(a.transportadora,"RecebimentoOrdemCompra")),"Safra"!==t&&a.safra&&(a.safra=nr.fromDto(a.safra,"RecebimentoOrdemCompra")),"OrdemCompra"!==t&&a.ordemCompra&&(a.ordemCompra=ha.fromDto(a.ordemCompra,"RecebimentoOrdemCompra")),a.fornecedores=a.fornecedores.map(function(e){return j({},e,{fornecedor:ta.fromDto(e.fornecedor),origemMercadoria:pa.fromDto(e.origemMercadoria),ordens:e.ordens.map(ha.fromDto)})}),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&sr(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&sr(a.lastModifiedDate).format(),delete a.label,"Agenda"!==t&&a.agenda&&(a.agenda=qe.toDto(a.agenda,"RecebimentoOrdemCompra")),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"RecebimentoOrdemCompra")),"Filial"!==t&&a.filial&&(a.filial=ma.toDto(a.filial,"RecebimentoOrdemCompra")),"Produto"!==t&&a.produto&&(a.produto=Li.toDto(a.produto,"RecebimentoOrdemCompra")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=Pi.toDto(a.derivacao,"RecebimentoOrdemCompra")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.toDto(a.transportadora,"RecebimentoOrdemCompra")),"Safra"!==t&&a.safra&&(a.safra=nr.toDto(a.safra,"RecebimentoOrdemCompra")),"OrdemCompra"!==t&&a.ordemCompra&&(a.ordemCompra=ha.toDto(a.ordemCompra,"RecebimentoOrdemCompra")),a},e}(),dr=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.recebimentoOrdemCompraService=a,this.RECEBIMENTO_ORDEMCOMPRA_KEY="ERP_SENIOR_RECEBIMENTO_ORDEMCOMPRA_KEY"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.RECEBIMENTO_ORDEMCOMPRA_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.RECEBIMENTO_ORDEMCOMPRA_KEY)},e.prototype.functionToOverride=function(e){var i=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return i.recebimentoOrdemCompraService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?i.recebimentoOrdemCompraService.registrarChegadaVeiculoRecebimentoOrdemCompra({recebimentoOrdemCompra:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Não foi possível encontrar os dados de Recebimento de ordem de compra")}))},e=V([r.Injectable(),B("design:paramtypes",[p.ChegadaVeiculoOverride,qt,Fi])],e)}(),cr=function(){function e(e,a,i,r,o,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F,S,D,C){var _=this;this.formBuilder=e,this.translate=a,this.filialService=i,this.pessoaService=r,this.produtoService=o,this.derivacaoService=n,this.transportadoraService=s,this.ordemCompraService=l,this.recebimentoOrdemCompraService=d,this.messageService=c,this.route=p,this.router=u,this.origemMercadoriaService=m,this.safraService=f,this.override=h,this.notaValidatorService=g,this.confirmationService=v,this.dialogService=y,this.agendaService=b,this.erpProcessService=F,this.erpFormConfigService=S,this.verificaNotaFiscal=D,this.hasChangeService=C,this.derivacaoLookupDisplayFields=["codigo","descricao"],this.derivacaoAdvancedDisplayFields=["id","codigo","descricao"],this.derivacaoLookupSeparator=" - ",this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.fornecedorLookupDisplayFields=["codigo","nome","cpfCnpj"],this.fornecedorAdvancedDisplayFields=["id","codigo","nome"],this.fornecedorLookupSeparator=" - ",this.ordemCompraLookupDisplayFields=["codigo","empresa.nome"],this.ordemCompraAdvancedDisplayFields=["id","codigo","empresa.nome","filial.nome","pessoa.nome"],this.ordemCompraLookupSeparator=" - ",this.origemMercadoriaLookupDisplayFields=["codigo","endereco"],this.origemMercadoriaAdvancedDisplayFields=["id","codigo","endereco","numero"],this.origemMercadoriaLookupSeparator=" - ",this.produtoLookupDisplayFields=["codigo","descricao"],this.produtoAdvancedDisplayFields=["id","codigo","descricao"],this.produtoLookupSeparator=" - ",this.safraLookupDisplayFields=["codigo","descricao"],this.safraAdvancedDisplayFields=["id","codigo","descricao"],this.safraLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.disableButtonSave=!1,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.erroChaveNota=!1,this.erroFornecedores=!1,this.notasTokens=[],this.fornecedorNotasTokens=[],this.fornecedorNotas=[],this.formCarregado=!1,this.ordemCompraSelecionado=null,this.permissions={},this.ngUnsubscribe=new t.Subject,this.onFilialValueChange=function(e,t){_.changeFormGroupValue(e,"produto",t)},this.onFornecedorChange=function(e,t){_.changeFormGroupValue(e,"origemMercadoria",t),_.changeFormGroupValue(e,"ordens",t)},this.onChangeRevalidation=function(e){_.erpProcessData&&_.formGroup&&(_.erpProcessData=_.erpProcessService.builderErpProcessData(_.erpProcessData,_.formGroup),_.erpProcessService.changeData(_.erpProcessData))},this.formGroup=this.getFormGroup()}return e.prototype.ngOnInit=function(){var e=this;this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;if("new"==a)return e.configureForm();e.getRecebimentoOrdemCompra(a)}),this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("fornecedores").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("transportadora").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.derivacaoSearchFields=this.getDerivacaoSearchFields(),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.fornecedorSearchFields=this.getFornecedorSearchFields(),this.origemMercadoriaSearchFields=this.getOrigemMercadoriaSearchFields(),this.produtoSearchFields=this.getProdutoSearchFields(),this.safraSearchFields=this.getSafraSearchFields(),this.safraSearchGridFields=this.getSafraSearchGridFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.ordemCompraSearchFields=this.getOrdemCompraFields(),this.ordemCompraSearchGridFields=this.getOrdemCompraGridFields(),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.getEmpresaFilial(),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0;this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.createdByErpDisableForm(),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.verificaSeTemAlteracao(),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)})},e.prototype.onRouteDataChange=function(e){this.permissions=e.allPermissions.agenda},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngAfterViewInit=function(){this.override.initialize(),this.saveAndInitButton=document.getElementById("init")},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.override.remove()},e.prototype.createdByErpDisableForm=function(){this.agenda&&this.agenda.createdByErp&&(this.createdByErp=!0,this.formGroup.get("filial").disable(),this.formGroup.get("produto").disable(),this.formGroup.get("derivacao").disable(),this.formGroup.get("transportadora").value&&this.formGroup.get("transportadora").disable())},e.prototype.configureForm=function(){var e=this;this.valueChanges(this.formGroup,"filial",this.onFilialValueChange);this.checkValuesChanges(this.formGroup,"produto","derivacao",this.derivacaoService,function(e){return"produto.id eq '"+e.id+"' and situacao eq 'ATIVO'"},["codigo","descricao"],function(e){return Pi.fromDto(e)},10,!0,!0),this.formGroup.get("fornecedores").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){t&&t.length>0?(e.formGroup.get("produto").disable(),e.formGroup.get("derivacao").disable()):(e.formGroup.get("produto").enable(),e.formGroup.get("derivacao").enable())}),this.createdByErpDisableForm(),this.formCarregado=!0},e.prototype.getEmpresaFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};if(1===t.cnpj.length){var i="pessoa.cpfCnpj eq '"+t.cnpj[0]+"'";this.filialService.list({filterQuery:i,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;if(1===a.length){var i=a[0],r=a[0].empresa;i.label=i.codigo+" - "+i.nome,r.label=r.codigo+" - "+r.nome,e.formGroup.get("empresa").setValue(r),e.formGroup.get("filial").setValue(i),e.formGroup.get("filial").enable(),e.formGroup.get("produto").enable(),e.formGroup.get("ordemCompra").enable()}})}},e.prototype.checkValuesChanges=function(e,t,i,r,o,n,s,l,d,c){var p=this;void 0===l&&(l=1),e.get(t).valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.debounceTime(500),a.filter(function(t){return d&&e.get(i).setValidators(t?C.Validators.required:C.Validators.nullValidator),c&&e.get(i).setValue(null),!!t||(e.get(i).setValue(null),e.get(i).disable(),!1)}),a.mergeMap(function(e){var t=o(e);return r.list({filterQuery:t,page:0,size:l})})).subscribe(function(t){var a=t.contents;if(!a||!a.length||a.length>1)return e.get(i).enable();1===a.length&&(a[0].label=p.translate.instant(Ne(a[0],n," - ",!0)),e.get(i).setValue(s(a[0]))),a.length>1?e.get(i).enable():e.get(i).disable()})},e.prototype.onBlurChaveNotaFiscal=function(){var e=this;if(!this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(this.chaveNotaFiscal,this.ordens,this.fornecedorNotasTokens)){this.removeNotaError();var t=this.chaveNotaFiscal;t&&(this.loading=!0,this.mensagemBuscandoNota(),this.notaValidatorService.pesquisarDocumentoValidaNotaEmUso({filialId:this.formGroup.get("filial").value&&this.formGroup.get("filial").value.id||null,chaveDocumento:t.replace(/\s/g,"")||""}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.addNovaNota(t)}))}},e.prototype.valueChanges=function(e,t,i){e.get(t).valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return i(t,e)})},e.prototype.changeFormGroupValue=function(e,t,a){if(!e)return a.get(t).setValue(undefined),void a.get(t).disable();a.get(t).enable()},e.prototype.getRecebimentoOrdemCompra=function(e){var t=this;this.loading=!0,this.recebimentoOrdemCompraService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(e){var a=e.contents;if(!a.length)return t.formCarregado=!0,t.configureForm();t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var i=lr.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(i),i.fornecedores.forEach(function(e){var a=t.getFornecedorForm(e);t.getFornecedoresForm().push(a),e.ordens.forEach(function(e){var i=t.getOrdemCompraForm(e);t.getOrdensCompra(a).push(i),e.notas.forEach(function(e){var a=t.getNotaForm(e);t.getNotas(i).push(a)})})}),t.configureForm()})},e.prototype.onFilialLookupRequest=function(e){var t=this,i=this.getFilialSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).reduce(function(t,a){var i,r,o=a.name;return a.type===n.FieldType.Integer?j({},t,((i={})[o]=e.replace(/\D/,""),i)):j({},t,((r={})[o]=e,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(i).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return ma.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(ma.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onFornecedorLookupRequest=function(e){var t=this;Oe(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.fornecedorLookupSuggestions=e.contents})},e.prototype.onFornecedorSearchRequest=function(e){var t=this;xe(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.fornecedorSearchGridData=e.contents,t.fornecedorSearchTotalRecords=e.totalElements})},e.prototype.onOrigemMercadoriaLookupRequest=function(e,t){var i=this;Oe(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,t," pessoa.id eq '"+e.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){i.origemMercadoriaLookupSuggestions=e.contents})},e.prototype.onOrigemMercadoriaSearchRequest=function(e,t){var i=this;xe(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,t," pessoa.id eq '"+e.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){i.origemMercadoriaSearchGridData=e.contents,i.origemMercadoriaSearchTotalRecords=e.totalElements})},e.prototype.onDerivacaoLookupRequest=function(e){var t=this;Oe(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e," produto.id eq '"+this.formGroup.get("produto").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoLookupSuggestions=e.contents})},e.prototype.onDerivacaoSearchRequest=function(e){var t=this;xe(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e," produto.id eq '"+this.formGroup.get("produto").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoSearchGridData=e.contents,t.derivacaoSearchTotalRecords=e.totalElements})},e.prototype.onOrdemCompraLookupRequest=function(e,t){var i=this;Oe(this.ordemCompraSearchFields,this.ordemCompraLookupDisplayFields,this.ordemCompraAdvancedDisplayFields,this.ordemCompraLookupSeparator,this.ordemCompraService,t,"filial.id eq '"+this.formGroup.get("filial").value.id+"' and pessoa.id eq '"+e.get("fornecedor").value.id+"'").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){i.ordemCompraLookupSuggestions=e.contents})},e.prototype.onOrdemCompraSearchRequest=function(e,t){var i=this;xe(this.ordemCompraSearchFields,this.ordemCompraLookupDisplayFields,this.ordemCompraAdvancedDisplayFields,this.ordemCompraLookupSeparator,this.ordemCompraService,t,"filial.id eq '"+this.formGroup.get("filial").value.id+"' and pessoa.id eq '"+e.get("fornecedor").value.id+"'").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){i.ordemCompraSearchGridData=e.contents,i.ordemCompraSearchTotalRecords=e.totalElements})},e.prototype.addOrdemCompra=function(e){var t=this;this.dialogService.open(va,j({},Re,{header:"Adicionar Ordem de Compra",data:{agenda:this.agenda,filial:this.formGroup.get("filial").value,fornecedor:e.get("fornecedor").value,ordens:e.get("ordens").value}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){return t.onOrdemCompraSaved(a,e)})},e.prototype.onProdutoLookupRequest=function(e){var t=this,i=this.formGroup.get("filial").value,r=this.agenda.tipoAgendamento;this.produtoService.listProdutos({pesquisa:e,empresaId:i?i.empresa.id:null,filialId:i?i.id:null,tipoAgendamentoId:r?r.id:null,situacao:"ATIVO",pagina:{limit:100,offset:0}}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.produtoLookupSuggestions=e.produtos.map(Li.fromDto)})},e.prototype.onProdutoSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getProdutoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}}),u=this.formGroup.get("filial").value,m=this.agenda.tipoAgendamento;this.produtoService.listProdutos(j({},p,{empresaId:u?u.empresa.id:null,filialId:u?u.id:null,situacao:"ATIVO",tipoAgendamentoId:m?m.id:null})).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoSearchTotalRecords=e.qtdTotalRegistros,t.produtoSearchGridData=e.produtos.map(Li.fromDto)})},e.prototype.onSafraLookupRequest=function(e){var t=this;Oe(this.safraSearchFields,this.safraLookupDisplayFields,this.safraAdvancedDisplayFields,this.safraLookupSeparator,this.safraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.safraLookupSuggestions=e.contents})},e.prototype.onSafraSearchRequest=function(e){var t=this;xe(this.safraSearchFields,this.safraLookupDisplayFields,this.safraAdvancedDisplayFields,this.safraLookupSeparator,this.safraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.safraSearchGridData=e.contents,t.safraSearchTotalRecords=e.totalElements})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Oe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this;xe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.setTransportadora=function(e){var t=this;if(e){var i="pessoa.cpfCnpj eq '"+e.replace(/\./g,"").replace(/\//g,"").replace(/\-/g,"")+"'";this.transportadoraService.list({filterQuery:i,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;1===a.length&&(a[0].label=t.translate.instant(Ne(a[0],["codigo","pessoa.nome"]," - ",!0)),t.formGroup.get("transportadora").setValue(a[0]))})}},e.prototype.onSave=function(e){var t=this;return this.formGroup.get("agenda").setValue(this.agenda),this.formGroup.invalid?this.validateAllFormFields(this.formGroup):this.formGroup.get("fornecedores").length<=0?void(this.erroFornecedores=!0):(this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessDataValidaNotaNaOrdemCompra(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)})))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=It.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.get("id").setValue(a.id||null),t.successMessage(),t.hasChangeService.hasChangeSave(t.agenda.id),e&&t.saveAndInitButton&&t.saveAndInitButton.click()})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.addFornecedor=function(e){this.erroFornecedores=!1;var t=this.getFornecedorForm(e);return this.getFornecedoresForm().push(t),t},e.prototype.removeFornecedor=function(e){var t=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_fornecedor_header"),message:this.translate.instant("yms.erp.remove_fornecedor_message"),accept:function(){var a=t.getFornecedoresForm().controls.indexOf(e);t.getFornecedoresForm().removeAt(a)}})},e.prototype.getFornecedorForm=function(e){void 0===e&&(e={});var t=this.formBuilder.group({fornecedor:[e.fornecedor,C.Validators.required],origemMercadoria:[e.origemMercadoria],ordens:this.formBuilder.array([])});this.valueChanges(t,"fornecedor",this.onFornecedorChange);return this.checkValuesChanges(t,"fornecedor","origemMercadoria",this.origemMercadoriaService,function(e){return"pessoa.id eq '"+e.id+"'"},["codigo","endereco"],function(e){return pa.fromDto(e)},10,!1,!0),t},e.prototype.getFornecedoresForm=function(){return this.formGroup.get("fornecedores")},e.prototype.getNotas=function(e){return e.get("notas")},e.prototype.addNota=function(e){var t=this;this.dialogService.open(ba,j({header:this.translate.instant("yms.erp.adicionar_nota")},Re,{data:{fornecedor:e.get("fornecedor").value,produto:this.formGroup.get("produto").value,filial:this.formGroup.get("filial").value,fornecedorNotasTokens:this.fornecedorNotasTokens,ordens:this.ordens}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){return t.onNotaSaved(a,e)})},e.prototype.removerNota=function(e,t,a){var i=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_nota_header"),message:this.translate.instant("yms.erp.remove_nota_message"),accept:function(){var r=t.value.ordemCompra.id,o=i.getNotasFromOrdens(e,r).controls.indexOf(a);i.getNotasFromOrdens(e,r).removeAt(o);var n=a.value;i.fornecedorNotasTokens.push({id:n.chaveNotaFiscal,label:n.numeroNotaFiscal}),i.fornecedorNotas.push({chaveNotaFiscal:n.chaveNotaFiscal,serieNotaFiscal:n.serieNotaFiscal,serieLegalNotaFiscal:n.serieLegalNotaFiscal,numeroNotaFiscal:n.numeroNotaFiscal})}})},e.prototype.showButtons=function(){return!!this.agenda&&[It.AGENDADO,It.AGUARDANDO_CONFIRMACAO,It.AGUARDANDO_CONFIRMACAO_SOLICITANTE,It.REJEITADO_POR_VALIDACAO].includes(this.agenda.status)},e.prototype.disableAdicionarNota=function(){return null===this.ordemCompraSelecionado||this.ordemCompraSelecionado===undefined},e.prototype.removerOrdemCompra=function(e,t){var a=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_ordem_compra_header"),message:this.translate.instant("yms.erp.remove_ordem_compra_message"),accept:function(){var i=a.getOrdensCompra(e),r=i.controls.indexOf(t);i.removeAt(r)}})},e.prototype.onOrdemCompraSaved=function(e,t){var a=this.getOrdemCompraForm({ordemCompra:e});this.getOrdensCompra(t).push(a),this.getFornecedorByOrdemCompra(e,t)},e.prototype.getFornecedorByOrdemCompra=function(e,t){this.pessoaService.list({size:1,page:0,filterQuery:"id eq '"+e.pessoa.id+"'"}).pipe(a.takeUntil(this.ngUnsubscribe),a.map(function(e){var t=e.contents;return(t||[]).length&&t[0]}),a.filter(function(e){return!!e})).subscribe(function(e){t.get("fornecedor").setValue(ta.fromDto(e))})},e.prototype.getOrdensCompra=function(e){return this.ordens=e.get("ordens"),e.get("ordens")},e.prototype.getNotasFromOrdens=function(e,t){var a,i,r=null,o=e.controls.ordens.controls;try{for(var n=z(o),s=n.next();!s.done;s=n.next()){var l=s.value;l.controls.ordemCompra.value.id===t&&(r=l.controls.notas)}}catch(d){a={error:d}}finally{try{s&&!s.done&&(i=n["return"])&&i.call(n)}finally{if(a)throw a.error}}return r},e.prototype.addFornecedorNotasTokenEmOrdemCompra=function(e,t){if(null!==this.ordemCompraSelecionado){var a=this.fornecedorNotas.filter(function(e){return e.chaveNotaFiscal===t.id}),i=this.getNotasFromOrdens(e,this.ordemCompraSelecionado.id);null!==i&&null!==a[0]&&i.push(this.getNotaForm(a[0])),this.removeFornecedorNotasTokenDaOrdemCompra(t)}else this.mensagemOrdemCompraNaoSelecionado()},e.prototype.removeFornecedorNotasTokenDaOrdemCompra=function(e){this.fornecedorNotasTokens.splice(this.fornecedorNotasTokens.indexOf(e),1),this.fornecedorNotas=this.fornecedorNotas.filter(function(t){return t.chaveNotaFiscal!==e.id})},e.prototype.getOrdemCompraForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({ordemCompra:[e.ordemCompra,C.Validators.required],notas:this.formBuilder.array([])})},e.prototype.getNotaForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({chaveNotaFiscal:[e.chaveNotaFiscal],serieNotaFiscal:[e.serieNotaFiscal],serieLegalNotaFiscal:[e.serieLegalNotaFiscal],numeroNotaFiscal:[e.numeroNotaFiscal]})},e.prototype.mensagemOrdemCompraNaoSelecionado=function(){this.addMessage("error","Ordem de compra não selecionado","Nenhum ordem de compra foi selecionado!")},e.prototype.onNotaSaved=function(e,t){if(null!==this.ordemCompraSelecionado)if(e.addFornecedor){var a=this.formGroup.get("fornecedores").controls.find(function(t){return(t.value.fornecedor||{id:undefined}).id===e.fornecedor.id}),i=e.infoNota,r=this.getNotaForm({chaveNotaFiscal:i.chave,serieNotaFiscal:i.serie,serieLegalNotaFiscal:i.serieLegal,numeroNotaFiscal:i.numero});if(a)(n=this.getNotasFromOrdens(a,this.ordemCompraSelecionado.id)).push(r),this.disableFields(a,"fornecedor","origemMercadoria");else if(t.get("fornecedor").value){var o=this.addFornecedor({fornecedor:ta.fromDto(e.fornecedor),origemMercadoria:pa.fromDto(e.origemMercadoria)});(n=this.getNotasFromOrdens(o,this.ordemCompraSelecionado.id)).push(r),this.disableFields(o,"fornecedor","origemMercadoria")}else{t.get("fornecedor").setValue(ta.fromDto(e.fornecedor)),t.get("origemMercadoria").setValue(pa.fromDto(e.origemMercadoria)),(n=this.getNotasFromOrdens(t,this.ordemCompraSelecionado.id)).push(r),this.disableFields(t,"fornecedor","origemMercadoria")}}else{var n;null!==(n=this.getNotasFromOrdens(t,this.ordemCompraSelecionado.id))&&n.push(this.getNotaForm(e))}else this.mensagemOrdemCompraNaoSelecionado()},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.getSaveObservable=function(){var e=this.formGroup.getRawValue();e.empresa=e.filial.empresa;var t=lr.toDto(e),a=t.fornecedores;return t.fornecedores.forEach(function(e){t.fornecedores.forEach(function(t){e.fornecedor.id===t.fornecedor.id&&e.origemMercadoria.id===t.origemMercadoria.id&&(a=a.splice(a.indexOf(t),1))})}),t.fornecedores=a,this.isNew()&&!e.id?this.recebimentoOrdemCompraService.insert(t):this.recebimentoOrdemCompraService.update(this.formGroup.value.id,t)},e.prototype.getFormGroup=function(){return this.formBuilder.group({id:[undefined],filial:[{value:undefined,disabled:!1},C.Validators.required],fornecedores:this.formBuilder.array([]),produto:[{value:undefined,disabled:!0}],derivacao:[{value:undefined,disabled:!0}],transportadora:[undefined],safra:[undefined],agenda:[{value:undefined,disabled:!0},C.Validators.required]})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup?t.validateAllFormFields(i):i instanceof C.FormArray&&i.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e.prototype.addNovaNota=function(e){var t=(e.documentos||[]).length?e.documentos[0]:undefined;if(t){var a=ta.fromDto(t.fornecedor),i=pa.fromDto(t.origemMercadoria);if(!this.getFornecedoresForm().controls.find(function(e){return e.value.fornecedor.id===a.id}))return this.addFornecedor({fornecedor:a,origemMercadoria:i}),void this.addFornecedorNotasToken(t);this.addFornecedorNotasToken(t)}},e.prototype.addFornecedorNotasToken=function(e){this.fornecedorNotasTokens.push({id:this.chaveNotaFiscal,label:e.numero}),this.fornecedorNotas.push({chaveNotaFiscal:this.chaveNotaFiscal,serieNotaFiscal:e.serie,serieLegalNotaFiscal:e.serieLegal,numeroNotaFiscal:e.numero}),this.chaveNotaFiscal=undefined,this.loading=!1},e.prototype.removeNotaError=function(){this.erroChaveNota=!1},e.prototype.addNotaError=function(){this.erroChaveNota=!0},e.prototype.mensagemBuscandoNota=function(){this.messageService.add({severity:"info",summary:this.translate.instant("yms.erp.nota_search_summary"),detail:this.translate.instant("yms.erp.nota_search_detail"),life:5e3})},e.prototype.disableFields=function(e){for(var t=[],a=1;a<arguments.length;a++)t[a-1]=arguments[a];t.forEach(function(t){return e.get(t).disable()})},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_codigo")})]},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")})]},e.prototype.getFornecedorSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_codigo")}),new n.FormField({name:"cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_cpfCnpj")})]},e.prototype.getOrigemMercadoriaSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_endereco_codigo")}),new n.FormField({name:"numero",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_numero")}),new n.FormField({name:"endereco",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_endereco")})]},e.prototype.getProdutoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_codigo")})]},e.prototype.getSafraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_descricao")})]},e.prototype.getSafraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_descricao")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_empresa")})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getOrdemCompraFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")})]},e.prototype.getOrdemCompraGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")})]},V([r.Input(),B("design:type",qe)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"recebimento-ordem-compra-form",template:'<p-confirmDialog [acceptLabel]="\'yes\' | translate" acceptIcon="" [rejectLabel]="\'no\' | translate" rejectIcon="">\n</p-confirmDialog>\n<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-fluid ui-g">\n\n <div class="ui-g-12">\n <label for="chaveNotaFiscal">{{\'yms.erp.recebimento_chave_nota_fiscal\' | translate}}</label>\n <input\n id="chaveNotaFiscal"\n trim\n pInputText\n type="text"\n [(ngModel)]="chaveNotaFiscal"\n [ngModelOptions]="{standalone: true}"\n (blur)="onBlurChaveNotaFiscal()"\n >\n \x3c!-- <input [class.ng-invalid]="erroChaveNota" pInputText type="text" [(ngModel)]="chaveNotaFiscal" [ngModelOptions]="{standalone: true}" (blur)="onBlurChaveNotaFiscal()"> --\x3e\n \x3c!-- <span class="input-error" *ngIf="erroChaveNota">{{\'yms.erp.produto_nota_error_detail\' | translate}}</span> --\x3e\n </div>\n\n <div class="ui-md-6 ui-g-12 required">\n <label for="filial">{{\'yms.erp.recebimento_ordem_compra_filial\' | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions" (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n\n <div class="ui-md-6 ui-g-12">\n <label for="transportadora">{{\'yms.erp.recebimento_ordem_compra_transportadora\' | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">\n {{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} /\n </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">\n {{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}\n </label>\n </div>\n\n <div class="ui-md-12">\n <s-button *ngIf="showButtons() && !!formGroup.get(\'filial\').value && !createdByErp" styleClass="btn-erp-forms" \n iconClass="fas fa-plus" label="Adicionar fornecedor" priority="secondary" \n (onClick)="addFornecedor()" [disabled]="disableButtonSave || !permissions.editar"></s-button>\n <span style="display: block;" class="input-error" *ngIf="erroFornecedores">{{\'Selecione ao menos um fornecedor para continuar\' | translate}}</span>\n </div>\n\n <form class="ui-g-12" *ngFor="let fornecedorForm of getFornecedoresForm().controls; let i = index;" [formGroup]="fornecedorForm">\n <p-panel [style]="{position: \'relative\'}" styleClass="form-group ui-g-12 ui-md-12" [toggleable]="true">\n\n <p-header>\n Fornecedor {{+i+1}}\n <s-button \n style="display: inline-block; position: absolute; right: 50px; top: 10px" \n *ngIf="showButtons() && !createdByErp"\n iconClass="fas fa-trash"\n label="Remover"\n priority="default"\n [auxiliary]="true"\n (onClick)="removeFornecedor(fornecedorForm)">\n </s-button>\n </p-header>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="fornecedor">{{\'yms.erp.recebimento_ordem_compra_fornecedor\' | translate}}</label>\n <s-lookup dataKey="id" id="fornecedor" name="fornecedor" formControlName="fornecedor"\n [searchFields]="fornecedorSearchFields" [searchGridFields]="fornecedorSearchFields"\n [searchGridData]="fornecedorSearchGridData" [multiple]="false"\n [lookupSuggestions]="fornecedorLookupSuggestions"\n (onLookupRequest)="onFornecedorLookupRequest($event)"\n (onSearchRequest)="onFornecedorSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="fornecedorSearchTotalRecords"\n [searchTitle]="\'yms.erp.fornecedor_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: { value: fornecedorSearchTotalRecords }">\n </s-lookup>\n <s-control-errors\n [control]="fornecedorForm.get(\'fornecedor\')"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }">\n </s-control-errors>\n </div>\n\n <div class="ui-md-6 ui-g-12">\n <label for="origem_mercadoria">{{\'yms.erp.recebimento_ordem_compra_mercadoria\' | translate}}</label>\n <s-lookup dataKey="id" id="origem_mercadoria" name="origem_mercadoria" formControlName="origemMercadoria" \n [searchFields]="origemMercadoriaSearchFields" [searchGridFields]="origemMercadoriaSearchFields"\n [searchGridData]="origemMercadoriaSearchGridData" [multiple]="false"\n [lookupSuggestions]="origemMercadoriaLookupSuggestions" lookupDisplayField="label"\n (onLookupRequest)="onOrigemMercadoriaLookupRequest(fornecedorForm, $event)"\n (onSearchRequest)="onOrigemMercadoriaSearchRequest(fornecedorForm, $event)" \n [searchTotalRecords]="origemMercadoriaSearchTotalRecords"\n [searchTitle]="\'yms.erp.origem_mercadoria_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: { value: origemMercadoriaSearchTotalRecords }">\n </s-lookup>\n </div>\n\n <div class="ui-g-12">\n <label for="fornecedorNotas">Notas a serem adicionadas</label>\n <s-token-list id="fornecedorNotas" [tokens]="fornecedorNotasTokens" (tokenSelected)="addFornecedorNotasTokenEmOrdemCompra(fornecedorForm, $event)" (tokenRemoved)="removeFornecedorNotasTokenDaOrdemCompra($event)" [removableTokens]="true"></s-token-list>\n </div>\n\n <div class="ui-g-12">\n <s-button label="Adicionar nota" *ngIf="showButtons()" styleClass="btn-erp-forms" priority="secondary" (onClick)="addNota(fornecedorForm)" [disabled]="disableAdicionarNota()"></s-button>\n <s-button label="Adicionar ordem de compra" *ngIf="showButtons() && !createdByErp" styleClass="btn-erp-forms" priority="secondary" (onClick)="addOrdemCompra(fornecedorForm)"></s-button>\n </div>\n\n <div class="ui-g-12">\n <h4>Ordens de Compra</h4>\n <p-table [value]="getOrdensCompra(fornecedorForm).controls" [(selection)]="ordemCompraSelecionado">\n <ng-template pTemplate="body" let-rowData>\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px">\n <p-tableRadioButton [value]="rowData.get(\'ordemCompra\').value"></p-tableRadioButton>\n </td>\n <td>\n <p-accordion>\n <p-accordionTab>\n <p-header>\n Ordem {{rowData.get(\'ordemCompra\').value.codigo}}, Filial {{rowData.get(\'ordemCompra\').value.filial?.codigo}}\n\n <span *ngIf="showButtons() && !createdByErp" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerOrdemCompra(fornecedorForm, rowData)"></span>\n </p-header>\n\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Notas</span>\n <span class="data">\n <p-accordion>\n <p-accordionTab *ngFor="let nota of getNotas(rowData).controls">\n <p-header>\n {{nota.get(\'chaveNotaFiscal\').value || (nota.get(\'serieNotaFiscal\').value + \' - \' + nota.get(\'numeroNotaFiscal\').value)}}\n\n <span *ngIf="showButtons()" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerNota(fornecedorForm, rowData, nota)"></span>\n </p-header>\n\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Série nota fiscal</span>\n <span class="data">{{nota.value?.serieNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Série legal nota fiscal</span>\n <span class="data">{{nota.value?.serieLegalNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{nota.value?.numeroNotaFiscal}}</span>\n </div>\n </div>\n\n </p-accordionTab> \n </p-accordion>\n </span>\n </div>\n </div>\n </p-accordionTab>\n </p-accordion>\n </td>\n </tr>\n </ng-template>\n </p-table>\n </div>\n </p-panel>\n </form>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button *ngIf="showButtons()" priority="primary" [label]="\'save\' | translate" (onClick)="onSave()"\n [disabled]="loading || disableButtonSave">\n </s-button>\n <s-button *ngIf="saveAndInitButton && showButtons()" priority="primary" [label]="\'save_and_init\' | translate"\n (onClick)="onSave(true)" [disabled]="loading || disableButtonSave">\n </s-button>\n </div>\n</div>',providers:[c.ConfirmationService],styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),B("design:paramtypes",[C.FormBuilder,o.TranslateService,qa,Xa,ei,Ea,pi,Jt,Fi,c.MessageService,F.ActivatedRoute,F.Router,Ha,di,dr,ya,c.ConfirmationService,c.DialogService,qt,ri,oi,Wt,ai])],e)}(),pr=function(){function e(e){this.recebimentoOrdemCompraService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.recebimentoOrdemCompraService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Recebimento Ordem de Compra não encontrado.")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.recebimentoOrdemCompra=lr.fromDto(t)})},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"recebimento-ordem-compra-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_filial\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.filial?.codigo}} - {{recebimentoOrdemCompra?.filial?.nome}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_produto\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.produto?.descricao}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_derivacao\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.derivacao?.descricao}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_transportadora\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.transportadora?.placaVeiculo}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_safra\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.safra?.descricao}}</span>\n </div>\n </div>\n <div *ngFor="let fornecedor of recebimentoOrdemCompra?.fornecedores">\n <div class="separator"></div>\n <h3>Fornecedor - {{fornecedor?.fornecedor?.nome}}</h3>\n <div class="detail-pane">\n <div class="detail-span" *ngFor="let ordemCompra of fornecedor.ordens">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_ordemcompra\' | translate}}</span>\n <span class="data">{{ ordemCompra.ordemCompra?.codigo }}</span>\n </div>\n </div>\n\n <div>\n <h4>Ordens de Compra</h4>\n <p-accordion>\n <p-accordionTab *ngFor="let ordemCompra of fornecedor.ordens">\n <p-header>\n Ordem de compra {{ ordemCompra?.ordemCompra?.numero }}, Filial {{ ordemCompra?.ordemCompra?.filial?.codigo }}\n </p-header>\n\n <div *ngFor="let nota of ordemCompra.notas">\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Chave nota fiscal</span>\n <span class="data">{{ nota?.chaveNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie nota fiscal</span>\n <span class="data">{{ nota?.serieNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie legal nota fiscal</span>\n <span class="data">{{ nota?.serieLegalNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{ nota?.numeroNotaFiscal }}</span>\n </div>\n </div>\n <hr />\n </div>\n </p-accordionTab>\n </p-accordion>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),B("design:paramtypes",[Fi])],e)}(),ur=_,mr=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);return a.dataEmissao=a.dataEmissao&&ur(a.dataEmissao).toDate(),a.dataInicioVigencia=a.dataInicioVigencia&&ur(a.dataInicioVigencia).toDate(),a.dataFimVigencia=a.dataFimVigencia&&ur(a.dataFimVigencia).toDate(),a.createdDate=a.createdDate&&ur(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ur(a.lastModifiedDate).toDate(),a.label="Número: "+a.numero+", Filial: "+a.filial.codigo,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"ContratoCompra")),"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.fromDto(a.pessoa,"ContratoCompra")),"Filial"!==t&&a.filial&&(a.filial=ma.fromDto(a.filial,"ContratoCompra")),"Safra"!==t&&a.safra&&(a.safra=nr.fromDto(a.safra,"ContratoCompra")),"ContratoCompraItem"!==t&&a.itens&&(a.itens=Object.values(a.itens).map(function(e){return hr.fromDto(e,"ContratoCompra")})),a},e.toDto=function(e,t){var a=j({},e);return a.dataEmissao=a.dataEmissao&&ur(a.dataEmissao).format("YYYY-MM-DD"),a.dataInicioVigencia=a.dataInicioVigencia&&ur(a.dataInicioVigencia).format("YYYY-MM-DD"),a.dataFimVigencia=a.dataFimVigencia&&ur(a.dataFimVigencia).format("YYYY-MM-DD"),a.createdDate=a.createdDate&&ur(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ur(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"ContratoCompra")),"Pessoa"!==t&&a.pessoa&&(a.pessoa=ta.toDto(a.pessoa,"ContratoCompra")),"Filial"!==t&&a.filial&&(a.filial=ma.toDto(a.filial,"ContratoCompra")),"Safra"!==t&&a.safra&&(a.safra=nr.toDto(a.safra,"ContratoCompra")),"ContratoCompraItem"!==t&&a.itens&&(a.itens=Object.values(a.itens).map(function(e){return hr.toDto(e,"ContratoCompra")}).filter(function(e){return Object.keys(e).length})),a},e}(),fr=_,hr=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);return a.sku=a.sku||{},a.dataCompetencia=a.dataCompetencia&&fr(a.dataCompetencia).toDate(),a.createdDate=a.createdDate&&fr(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&fr(a.lastModifiedDate).toDate(),a.label=a.sequencia+" - "+a.sku.descricao+" - "+a.sku.codigo,"ContratoCompra"!==t&&a.contrato&&(a.contrato=mr.fromDto(a.contrato,"ContratoCompraItem")),"Produto"!==t&&a.sku&&(a.sku=Li.fromDto(a.sku,"ContratoCompraItem")),a},e.toDto=function(e,t){var a=j({},e);return a.dataCompetencia=a.dataCompetencia&&fr(a.dataCompetencia).format("YYYY-MM-DD"),a.createdDate=a.createdDate&&fr(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&fr(a.lastModifiedDate).format(),delete a.label,"ContratoCompra"!==t&&a.contrato&&(a.contrato=mr.toDto(a.contrato,"ContratoCompraItem")),"Produto"!==t&&a.sku&&(a.sku=Li.toDto(a.sku,"ContratoCompraItem")),a},e}(),gr=_,vr=function(){function e(e,a,i,r,o,n,s){this.dialogRef=e,this.dialogConfig=a,this.contratoCompraService=i,this.contratoCompraItemService=r,this.translate=o,this.fb=n,this.route=s,this.contratoCompraLookupDisplayFields=["numero"],this.contratoCompraAdvancedDisplayFields=["id","numero","numeroAprovacao","situacaoAprovacao","dataEmissao","contratoPrioritario","dataInicioVigencia","dataFimVigencia"],this.contratoCompraLookupSeparator=" - ",this.contratoCompraItensLookupDisplayFields=["sequencia","sku.descricao"],this.contratoCompraItensAdvancedDisplayFields=["id","sequencia","sku.*","situacao","quantidadeContratada","quantidadeUtilizada","quantidadeEncerrada","dataCompetencia"],this.contratoCompraItensLookupSeparator=" - ",this.disableButtonSave=!1,this.permissions={},this.ngUnsubscribe=new t.Subject}return e.prototype.ngOnInit=function(){var e=this,t=this.dialogConfig.data;this.agenda=t.agenda,this.filial=t.filial,this.fornecedor=t.fornecedor,this.produto=t.produto,this.contratos=t.contratos.map(function(e){var t=e.contrato;return t?t.id:undefined}).filter(function(e){return!!e}),this.formGroup=this.getForm(),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)}),this.contratoCompraSearchFields=this.getContratoCompraFields(),this.contratoCompraSearchGridFields=this.getContratoCompraGridFields(),this.contratoCompraItensSearchFields=this.getContratoCompraItensFields(),this.contratoCompraItensSearchGridFields=this.getContratoCompraItensGridFields()},e.prototype.ngAfterViewInit=function(){(this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)||!this.permissions.editar)&&(this.formGroup.disable(),this.disableButtonSave=!0)},e.prototype.onRouteDataChange=function(e){this.permissions=e.allPermissions.agenda},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},e.prototype.onContratoCompraLookupRequest=function(e){var t=this,a=this.contratoCompraLookupDisplayFields.map(function(e){return{field:e,order:"Asc"}})[0],i={numero:+e.replace(/\D/g,"")},r=this.filial;r&&r.empresa&&r.empresa.id&&(i.empresaId=r.empresa.id),this.contratoCompraService.listContratosCompra(j({},i,{pessoaId:(this.fornecedor||{id:undefined}).id,produtoId:(this.produto||{id:undefined}).id,filialId:(r||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,contratosSelecionados:this.contratos,pagina:{limit:30,offset:0,listaOrdenacao:[{campo:a.field,ordenacao:a.order}]}})).subscribe(function(e){t.contratoCompraLookupSuggestions=e.contents.map(mr.fromDto)})},e.prototype.onContratoCompraSearchRequest=function(e){var t=this,a=e.first,i=e.rows,r=e.multiSortMeta,o=e.filterData,n=a/i,s=this.getContratoCompraFields().filter(function(e){var t=e.name;return o[t]!=undefined&&""!=o[t]}).reduce(function(e,t){var a;return j({},e,((a={})[t.name]=o[t.name],a))},{}),l=this.filial;l&&l.empresa&&l.empresa.id&&(s.empresaId=l.empresa.id),s.dataEmissao=s.dataEmissao&&gr(s.dataEmissao).format("YYYY-MM-DD");var d=(r||[]).length?{field:r[0].field,order:1===r[0].order?"Asc":"Desc"}:{field:"numero",order:"Asc"};this.contratoCompraService.listContratosCompra(j({},s,{pessoaId:(this.fornecedor||{id:undefined}).id,produtoId:(this.produto||{id:undefined}).id,filialId:(l||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,contratosSelecionados:this.contratos,pagina:{limit:i,offset:n,listaOrdenacao:[{campo:d.field,ordenacao:d.order}]}})).subscribe(function(e){t.contratoCompraSearchGridData=e.contents.map(mr.fromDto),t.contratoCompraSearchTotalRecords=e.totalElements})},e.prototype.onContratoCompraItensLookupRequest=function(e){var t=this,i=this.contratoCompraItensLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=this.filial.id,o={contratoId:this.formGroup.get("contrato").value.id,filialId:r,sequencia:isNaN(e)?null:e,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(0,10,i)};this.contratoCompraItemService.pesquisarItensContratoCompra(o).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.contratoCompraItensLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.contratoCompraItensLookupSeparator)})})})})).subscribe(function(e){t.contratoCompraItensLookupSuggestions=e.contents.map(hr.fromDto)})},e.prototype.onContratoCompraItensSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,n=e.filterData,s=o,l=this.filial.id,d={contratoId:this.formGroup.get("contrato").value.id,filialId:l,sequencia:n.sequencia,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(i,r,s)};this.contratoCompraItemService.pesquisarItensContratoCompra(d).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.contratoCompraItensLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.contratoCompraItensLookupSeparator)})})})})).subscribe(function(e){t.contratoCompraItensSearchGridData=e.contents.map(hr.fromDto),t.contratoCompraItensSearchTotalRecords=e.totalElements})},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.addItemContrato=function(){this.getItensForm().push(this.getItemForm())},e.prototype.getItensForm=function(){return this.formGroup.get("itens")},e.prototype.save=function(){if(!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);this.close({contrato:this.formGroup.value})},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.getForm=function(){return this.fb.group({contrato:[undefined,C.Validators.required],itens:this.fb.array([])})},e.prototype.getItemForm=function(){return this.fb.group({item:[undefined,C.Validators.required],quantidade:[1]})},e.prototype.getContratoCompraFields=function(){return[new n.FormField({name:"filialContrato",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"numero",label:this.translate.instant("yms.erp.contrato_compra_numero"),type:n.FieldType.Integer})]},e.prototype.getContratoCompraGridFields=function(){return[new n.FormField({name:"numero",label:this.translate.instant("yms.erp.contrato_compra_numero"),type:n.FieldType.Integer}),new n.FormField({name:"filial.pessoa.nomeFantasia",label:this.translate.instant("yms.erp.contrato_compra_filial"),type:n.FieldType.Integer}),new n.FormField({name:"filial.pessoa.codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"dataEmissao",label:this.translate.instant("yms.erp.contrato_compra_data_emissao"),type:n.FieldType.Date})]},e.prototype.getContratoCompraItensFields=function(){return[new n.FormField({name:"sequencia",label:this.translate.instant("yms.erp.contrato_compra_item_sequencia"),type:n.FieldType.Integer})]},e.prototype.getContratoCompraItensGridFields=function(){return[new n.FormField({name:"sequencia",label:this.translate.instant("yms.erp.contrato_compra_item_sequencia"),type:n.FieldType.Integer}),new n.FormField({name:"sku.descricao",label:this.translate.instant("yms.erp.produto"),type:n.FieldType.String})]},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup?t.validateAllFormFields(i):i instanceof C.FormArray&&i.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e=V([r.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 ui-md-6">\n <label for="contrato">Contrato</label>\n <s-lookup dataKey="id" name="contrato"\n formControlName="contrato" [searchFields]="contratoCompraSearchFields"\n [searchGridFields]="contratoCompraSearchGridFields"\n [searchGridData]="contratoCompraSearchGridData" [multiple]="false"\n [lookupSuggestions]="contratoCompraLookupSuggestions"\n (onLookupRequest)="onContratoCompraLookupRequest($event)"\n (onSearchRequest)="onContratoCompraSearchRequest($event)"\n lookupDisplayField="label" [searchTotalRecords]="contratoCompraSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_contrato_compra_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: contratoCompraSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="separator"></div>\n <div class="ui-g-12" *ngFor="let itemForm of getItensForm().controls">\n <form [formGroup]="itemForm">\n <div class="ui-g-6">\n <label>Contrato Item</label>\n <s-lookup dataKey="id" id="item" name="item" formControlName="item"\n [searchFields]="contratoCompraItensSearchFields"\n [searchGridFields]="contratoCompraItensSearchGridFields"\n [searchGridData]="contratoCompraItensSearchGridData" [multiple]="false"\n [lookupSuggestions]="contratoCompraItensLookupSuggestions"\n (onLookupRequest)="onContratoCompraItensLookupRequest($event)"\n (onSearchRequest)="onContratoCompraItensSearchRequest($event)"\n lookupDisplayField="label" [searchTotalRecords]="contratoCompraItensSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_contrato_compra_itens_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: contratoCompraItensSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-6">\n <label>Quantidade</label>\n <input pInputText type="number" formControlName="quantidade">\n </div>\n </form>\n </div>\n <s-button label="Adicionar item" priority="secondary" (onClick)="addItemContrato()"\n [disabled]="disableButtonSave"></s-button>\n </div>\n\n <div style="margin-top: 10px;">\n <div class="separator"></div>\n <s-button style="float: right;" [label]="\'save\' | translate" priority="primary" (onClick)="save()"\n [disabled]="disableButtonSave"></s-button>\n <s-button style="float: right;" [label]="\'cancel\' | translate" priority="link" (onClick)="close()"></s-button>\n </div>\n</form>\n\n'}),B("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,Ma,Ta,o.TranslateService,C.FormBuilder,F.ActivatedRoute])],e)}(),yr=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);return a.label=Ne(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Zt.fromDto(a.empresa,"Transgenia")),"Royalty"!==t&&a.royalty&&(a.royalty=wi.fromDto(a.royalty,"Royalty")),a},e.toDto=function(e,t){var a=j({},e);return delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Zt.toDto(a.empresa,"Transgenia")),"Royalty"!==t&&a.royalty&&(a.roylty=wi.toDto(a.royalty,"Transgenia")),a},e}(),br=_,Fr=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&br(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&br(a.lastModifiedDate).toDate();return a.label=["id","fornecedor.id","fornecedor.codigo","fornecedor.nome","fornecedor.situacao","produto.id","produto.codigo","produto.comprado","produto.descricao","produto.produtoMisto","produto.situacao","produto.tipo","agenda.id","agenda.descricao","transportadora.id","transportadora.codigo","transportadora.placaVeiculo","transgenia.id","transgenia.codigo","transgenia.descricao","tipoNotaFiscal","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Filial"!==t&&a.filial&&(a.filial=ma.fromDto(a.filial,"Recebimento")),"Produto"!==t&&a.produto&&(a.produto=Li.fromDto(a.produto,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=qe.fromDto(a.agenda,"Recebimento")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=pa.fromDto(a.origemMercadoria,"Recebimento")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=Pi.fromDto(a.derivacao,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.fromDto(a.transportadora,"Recebimento")),"Transgenia"!==t&&a.transgenia&&(a.transgenia=yr.fromDto(a.transgenia,"Transgenia")),a.fornecedores=a.fornecedores.map(function(e){return j({},e,{fornecedor:ta.fromDto(e.fornecedor,"Recebimento"),origemMercadoria:pa.fromDto(e.origemMercadoria,"Recebimento"),contratos:e.contratos.map(function(e){return j({},e,{contrato:mr.fromDto(e.contrato),itens:e.itens.map(function(e){return j({},e,{item:hr.fromDto(e.item)})})})})})}),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&br(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&br(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.fornecedor&&(a.fornecedor=ta.toDto(a.fornecedor,"Recebimento")),"Filial"!==t&&a.filial&&(a.filial=ma.toDto(a.filial,"Filial")),"Produto"!==t&&a.produto&&(a.produto=Li.toDto(a.produto,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=qe.toDto(a.agenda,"Recebimento")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=pa.toDto(a.origemMercadoria,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Vi.toDto(a.transportadora,"Recebimento")),"Transgenia"!==t&&a.transgenia&&(a.transgenia=yr.toDto(a.transgenia,"Transgenia")),a.fornecedores=e.fornecedores.map(function(e){return j({},e,{fornecedor:ta.toDto(e.fornecedor,"Recebimento"),origemMercadoria:pa.toDto(e.origemMercadoria,"Recebimento"),contratos:e.contratos.map(function(e){return j({},e,{contrato:mr.toDto(e.contrato),itens:e.itens.map(function(e){return j({},e,{item:hr.toDto(e.item)})})})})})}),a},e}();!function(e){e.EMPRESA_JURIDICA="EMPRESA_JURIDICA",e.PRODUTOR_RURAL="PRODUTOR_RURAL"}(zi||(zi={})),function(e){e.INATIVO="INATIVO",e.ATIVO="ATIVO"}($i||($i={}));var Sr=_,Dr=function(){function e(e,a,i,r,o,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F,S,D,C,_,I,T,k){var M=this;this.recebimentoService=e,this.router=a,this.route=i,this.messageService=r,this.confirmationService=o,this.formBuilder=n,this.translate=s,this.hotkeysService=l,this.fieldCustomization=d,this.focusService=c,this.filialService=p,this.transportadoraService=u,this.pessoaEnderecoService=m,this.contratoCompraService=f,this.pessoaService=h,this.produtoService=g,this.derivacaoService=v,this.recebimentoChegadaOverride=y,this.notaValidatorService=b,this.transgeniaService=F,this.dialogService=S,this.agendaService=D,this.erpProcessService=C,this.erpFormConfigService=_,this.verificaNotaFiscal=I,this.hasChangeService=T,this.buildFormField=k,this.localeConfig={},this.currencyLocaleOptions={},this.permissions={},this.allPermissions={},this.visibleDialog=!1,this.quantidadeSelecionada=1,this.mainPanelCollapsed=!1,this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.fornecedorLookupDisplayFields=["codigo","nome","cpfCnpj"],this.fornecedorAdvancedDisplayFields=["id","codigo","nome","situacao","cpfCnpj","tipoParticipante"],this.fornecedorLookupSeparator=" - ",this.origemMercadoriaLookupDisplayFields=["codigo","cep","endereco","empresa.descricao"],this.origemMercadoriaAdvancedDisplayFields=["id","codigo","cep","endereco","numero","complemento","cidade.*","bairro","situacao","empresa.descricao","cnpjCpf","inscricaoEstadual"],this.origemMercadoriaLookupSeparator=" - ",this.produtoLookupDisplayFields=["codigo","descricao","tipo"],this.produtoAdvancedDisplayFields=["id","codigo","comprado","descricao","produtoMisto","situacao","tipo"],this.produtoLookupSeparator=" - ",this.agendaLookupDisplayFields=["id","descricao"],this.agendaAdvancedDisplayFields=["id","descricao"],this.agendaLookupSeparator=" - ",this.derivacaoLookupDisplayFields=["codigo","descricao"],this.derivacaoAdvancedDisplayFields=["id","codigo","descricao"],this.derivacaoLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.transgeniaLookupDisplayFields=["codigo","descricao"],this.transgeniaAdvancedDisplayFields=["id","codigo","descricao","familia","tipoParticipante","situacao"],this.transgeniaLookupSeparator=" - ",this.disableButtonSave=!1,this.disableOrdersButtons=!0,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.tiposNota=[{label:this.translate.instant("yms.erp.tipo_nota_fiscal_empresa_juridica"),value:zi.EMPRESA_JURIDICA},{label:this.translate.instant("yms.erp.tipo_nota_fiscal_produtor_rural"),value:zi.PRODUTOR_RURAL}],this.erroChaveNota=!1,this.erroFornecedores=!1,this.erroFornecedoresNotaDuplicada=null,this.notasTokens=[],this.fornecedorNotasTokens=[],this.fornecedorNotas=[],this.contratoSelecionado=null,this.ngUnsubscribe=new t.Subject,this.carregandoErpFilial=!0,this.carregandoErpRouteData=!0,this.carregandoErpRecebimento=!0,this.onChangeRevalidation=function(e){M.erpProcessData&&M.formGroup&&(M.erpProcessData=M.erpProcessService.builderErpProcessData(M.erpProcessData,M.formGroup),M.erpProcessService.changeData(M.erpProcessData))},this.onFilialValueChange=function(e){if(M.disableOrdersButtons=!e,!e&&M.isNew())return M.formGroup.get("produto").setValue(undefined),M.formGroup.get("produto").disable(),M.formGroup.get("transgenia").setValue(undefined),M.formGroup.get("transgenia").disable(),void(M.carregandoErpFilial=!1);M.formGroup.get("produto").enable(),M.formGroup.get("transgenia").enable(),M.carregandoErpFilial=!1}}return e.prototype.ngOnInit=function(){var e=this;this.formGroup=this.getFormGroup(),this.itemFormGroup=this.getItemForm(),this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onFilialValueChange),this.formGroup.get("produto").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.debounceTime(500),a.filter(function(t){var a=e.formGroup.get("derivacao").value;return(!a||a.produto.id!==t.id)&&(!!t||(e.formGroup.get("derivacao").setValue(undefined),e.formGroup.get("derivacao").disable(),!1))}),a.mergeMap(function(t){return e.derivacaoService.list({filterQuery:"produto.id eq '"+t.id+"' and situacao eq 'ATIVO'",page:0,size:1})})).subscribe(function(t){var a=t.contents;a.length?(e.formGroup.get("derivacao").setValue(a[0]),e.formGroup.get("derivacao").disable()):e.formGroup.get("derivacao").enable()}),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)}),this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;"new"==a?e.buscarFilial():e.getRecebimento(a)}),this.formGroup.get("transportadora").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("transgenia").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("fornecedores").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchFields(),this.fornecedorSearchFields=this.getFornecedorSearchFields(),this.fornecedorSearchGridFields=this.getFornecedorSearchGridFields(),this.origemMercadoriaSearchFields=this.getOrigemMercadoriaFields(),this.origemMercadoriaSearchGridFields=this.getOrigemMercadoriaGridFields(),this.produtoSearchFields=this.getProdutoSearchFields(),this.produtoSearchGridFields=this.getProdutoSearchGridFields(),this.agendaSearchFields=this.getAgendaSearchFields(),this.agendaSearchGridFields=this.getAgendaSearchGridFields(),this.derivacaoSearchFields=this.getDerivacaoSearchFields(),this.derivacaoSearchGridFields=this.getDerivacaoSearchGridFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.transgeniaSearchFields=this.getTransgeniaSearchFields(),this.transgeniaSearchGridFields=this.getTransgeniaSearchGridFields(),this.setHotkeys(),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0;this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.verificaSeTemAlteracao(),this.formGroup.get("produto").valueChanges.subscribe(function(){e.validaTransgenia()}),this.formGroup.get("fornecedores").valueChanges.subscribe(function(){e.validaTransgenia()})},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.validaTransgenia=function(){if(!this.erpCarregado()){var e=this.formGroup.get("transgenia").value,t=this.formGroup.get("produto").value,a=this.getFamiliaProduto();t&&e&&(this.validaFamiliaProdutoCorrespondeFamiliaTrangenia(e,a)?this.validaFornecedorCorrespondeTipoPaticipanteDaTransgenia(e):this.mensagemTransgeniaInvalida())}},e.prototype.erpCarregado=function(){return!!this.carregandoErpFilial||(!!this.carregandoErpRouteData||!!this.carregandoErpRecebimento)},e.prototype.mensagemTransgeniaInvalida=function(){this.addMessage("error","yms.integration.mensagem_erro_titulo_informar_transgenia","yms.integration.mensagem_erro_conteuto_informar_transgenia"),this.formGroup.get("transgenia").setValue(undefined)},e.prototype.validaFamiliaProdutoCorrespondeFamiliaTrangenia=function(e,t){return null!==t&&e.familia===t},e.prototype.validaFornecedorCorrespondeTipoPaticipanteDaTransgenia=function(e){var t=this.getTipoTransgenia(),a=this.formGroup.get("fornecedores");if(a.length>0){var i=!0;if(a.controls.forEach(function(e){i=null===e.value.fornecedor}),i)return!0;if(null===t)return this.mensagemTransgeniaInvalida(),!1;if(t!==e.tipoParticipante)return this.mensagemTransgeniaInvalida(),!1;if(t===e.tipoParticipante)return!0}return!1},e.prototype.ngAfterViewInit=function(){var e=this,t=document.getElementsByTagName("input"),a=Array.from(t).find(function(e){return!e.disabled});a&&a.focus(),this.recebimentoChegadaOverride.initialize(),this.saveAndInitButton=document.getElementById("init"),this.createdByErpDisableForm(),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.recebimentoChegadaOverride.remove()},e.prototype.createdByErpDisableForm=function(){this.disableOrdersButtons=this.agenda.createdByErp,this.isNew()&&(this.createdByErp=!1,this.formGroup.get("filial").enable(),this.formGroup.get("produto").enable(),this.formGroup.get("derivacao").enable(),this.formGroup.get("transportadora").enable(),this.formGroup.get("fornecedores").controls.forEach(function(e){return e.get("fornecedor").enable()})),this.agenda&&this.agenda.createdByErp&&(this.createdByErp=!0,this.formGroup.get("filial").disable(),this.formGroup.get("produto").disable(),this.formGroup.get("derivacao").disable(),this.disableFornecedores(),this.formGroup.get("transportadora").value&&this.formGroup.get("transportadora").disable())},e.prototype.disableFornecedores=function(){this.formGroup.get("fornecedores").controls.forEach(function(e){return e.get("fornecedor").disable()})},e.prototype.setHotkeys=function(){var e=this;this.hotkeysService.add(new G.Hotkey("alt+shift+x",function(){return e.permissions.excluir&&e.onDelete(),!1},["INPUT","SELECT","TEXTAREA"])),this.hotkeysService.add(new G.Hotkey("alt+shift+s",function(){return(e.isNew()||e.permissions.editar)&&e.onSave(),!1},["INPUT","SELECT","TEXTAREA"])),this.hotkeysService.add(new G.Hotkey("alt+shift+c",function(){return e.onCancel(),!1},["INPUT","SELECT","TEXTAREA"]))},e.prototype.onBlurChaveNotaFiscal=function(){var e=this;if(!this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(this.chaveNotaFiscal,this.contratos,this.fornecedorNotasTokens)){this.removeNotaError();var t=this.chaveNotaFiscal;t&&(this.loading=!0,this.mensagemBuscandoNota(),this.notaValidatorService.pesquisarDocumentoValidaNotaEmUso({filialId:this.formGroup.get("filial").value&&this.formGroup.get("filial").value.id||null,chaveDocumento:t.replace(/\s/g,"")}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.addNovaNota(t)}))}},e.prototype.addNovaNota=function(e){var t=(e.documentos||[]).length?e.documentos[0]:undefined;if(t){var a=t.itens[0]||{produto:undefined,derivacao:undefined},i=Li.fromDto(a.produto);if(!this.formGroup.get("produto").value&&a.produto)this.formGroup.get("produto").setValue(i),this.formGroup.get("derivacao").setValue(Pi.fromDto(a.derivacao));else if(a.produto&&!this.validateProduto(i))return void this.addNotaError();var r=ta.fromDto(t.fornecedor),o=pa.fromDto(t.origemMercadoria),n=this.getFornecedoresForm().controls.find(function(e){return e.value.fornecedor.id===r.id});this.validarCnpjFornecedor(r.cpfCnpj)?(n||this.addFornecedor({fornecedor:r,origemMercadoria:o}),this.addFornecedorNotasToken(t)):n||(this.addFornecedor({fornecedor:r,origemMercadoria:o}),this.addFornecedorNotasToken(t)),this.validaRetornoPesquisaDocumentos(e)}},e.prototype.validaRetornoPesquisaDocumentos=function(e){var t=this.verificaNotaFiscal.findDuplicateFornecedores(e);null!==t&&(this.erroFornecedoresNotaDuplicada=this.translate.instant("yms.patio.duplicate_supplier")+t)},e.prototype.addFornecedorNotasToken=function(e){this.fornecedorNotasTokens.push({id:this.chaveNotaFiscal,label:e.numero}),this.fornecedorNotas.push({chaveNotaFiscal:this.chaveNotaFiscal,serieNotaFiscal:e.serie,serieLegalNotaFiscal:e.serieLegal,numeroNotaFiscal:e.numero}),this.chaveNotaFiscal=undefined,this.loading=!1},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.updateSuggestions=function(e){e.fornecedor&&(e.fornecedor.label=this.getSuggestionValue(["id","codigo","nome","situacao"],"fornecedor",e,this.fornecedorLookupSeparator),e.fornecedor.label.trim()===this.fornecedorLookupSeparator.trim()&&delete e.fornecedor.label),e.produto&&(e.produto.label=this.getSuggestionValue(["id","codigo","comprado","descricao","produtoMisto","situacao","tipo"],"produto",e,this.produtoLookupSeparator),e.produto.label.trim()===this.produtoLookupSeparator.trim()&&delete e.produto.label),e.agenda&&(e.agenda.label=this.getSuggestionValue(["id","descricao"],"agenda",e,this.agendaLookupSeparator),e.agenda.label.trim()===this.agendaLookupSeparator.trim()&&delete e.agenda.label),e.derivacao&&(e.derivacao.label=this.getSuggestionValue(["id","codigo","descricao"],"derivacao",e,this.derivacaoLookupSeparator),e.derivacao.label.trim()===this.derivacaoLookupSeparator.trim()&&delete e.derivacao.label)},e.prototype.getSuggestionValue=function(e,t,a,i){var r=this;return e.map(function(e){return r.getProp(a,t+"."+e)}).reduce(function(e,t){return""+e+i+t})},e.prototype.onRouteDataChange=function(e){var t=e.localeConfig.number,a=t.currencySymbol,i=t.thousandsSeparator,r=t.decimalSeparator;if(this.localeConfig=e.localeConfig,this.currencyLocaleOptions={align:"left",prefix:a,thousands:i,decimal:r},this.permissions=e.allPermissions.agenda,this.allPermissions=e.allPermissions,e.entity){this.permissions.editar||this.formGroup.disable();var o=Fr.fromDto(e.entity);this.updateSuggestions(o),this.formGroup.patchValue(o)}else this.formGroup.patchValue(new Fr);this.carregandoErpRouteData=!1},e.prototype.onCancel=function(){this.goBack()},e.prototype.onSendFile=function(e,a){var i=[];return this.fieldCustomization.isEmpty(e)||i.push(this.fieldCustomization.deleteFiles(e)),this.fieldCustomization.isEmpty(a)||i.push(this.fieldCustomization.commitFiles(a)),this.fieldCustomization.isEmpty(i)?t.of({}):t.forkJoin(i)},e.prototype.onSave=function(e){var t=this;if(!(this.formGroup.get("fornecedores").length<=0))return this.formGroup.invalid?this.validateAllFormFields(this.formGroup):(this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessDataValidaNotaNoContrato(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)})));this.erroFornecedores=!0},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=It.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.get("id").setValue(a.id||null),t.successMessage(),t.hasChangeService.hasChangeSave(t.agenda.id),e&&t.saveAndInitButton&&t.saveAndInitButton.click()})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.onDelete=function(){var e=this;this.confirmationService.confirm({message:this.translate.instant("yms.erp.delete_confirmation_message"),header:this.translate.instant("yms.erp.delete_confirmation_title"),accept:function(){return e.getDeleteObservable().pipe(a.takeUntil(e.ngUnsubscribe)).subscribe()}})},e.prototype.setTransportadora=function(e){var t=this;if(e){var i="pessoa.cpfCnpj eq '"+e.replace(".","").replace("/","").replace("-","")+"'";this.transportadoraService.list({filterQuery:i,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(1===a.length){var i=a[0].codigo?a[0].codigo.toString():"",r=a[0].descricao?a[0].descricao.toString():"";r.trim()||i.trim()?a[0].label=i+" - "+r:a[0].label=t.translate.instant("yms.erp.derivacao_sem_descricao"),t.formGroup.get("transportadora").setValue(a[0])}})}},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.getRecebimento=function(e){var t=this;this.loading=!0,this.recebimentoService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(e){var a=e.contents;if(a.length){t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var i=Fr.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(i),i.fornecedores.forEach(function(e){var a=t.getFornecedorForm(e);t.getFornecedoresForm().push(a),e.contratos.forEach(function(e){var i=t.getContratoForm(e);t.getContratos(a).push(i),e.itens.forEach(function(e){var a=t.getItemForm(e);t.getItensContrato(i).push(a)}),e.notas.forEach(function(e){var a=t.getNotaForm(e);t.getNotas(i).push(a)})})}),t.createdByErpDisableForm(),t.formCarregado=!0,t.carregandoErpRecebimento=!1}else t.buscarFilial()})},e.prototype.onFilialLookupRequest=function(e){var t=this,i=this.getFilialSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).reduce(function(t,a){var i,r,o=a.name;return a.type===n.FieldType.Integer?j({},t,((i={})[o]=e.replace(/\D/,""),i)):j({},t,((r={})[o]=e,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(i).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(ma.fromDto)})},e.prototype.onFilialSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(ma.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onFornecedorLookupRequest=function(e){var t=this,i=this.fornecedorLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=this.getFornecedorSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+Sr(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+Sr(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+Sr(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or ");r="("+r+")"+(r?" and ":"")+"situacao eq 'ATIVO' and fornecedor eq true";var o=_e(this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields);this.pessoaService.list({sort:i,filterQuery:r,displayFields:o}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.fornecedorLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.fornecedorLookupSeparator)})})})})).subscribe(function(e){t.fornecedorLookupSuggestions=e.contents})},e.prototype.onFornecedorSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getFornecedorSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Sr(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Sr(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Sr(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and ");c=c.concat((c?" and ":"")+"situacao eq 'ATIVO' and fornecedor eq true");var p=_e(this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields);this.pessoaService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.fornecedorLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.fornecedorLookupSeparator)})})})})).subscribe(function(e){t.fornecedorSearchGridData=e.contents,t.fornecedorSearchTotalRecords=e.totalElements})},e.prototype.montaQueryOrigemMercadoria=function(e){return"situacao eq 'ATIVO' and origem eq 'true' and pessoa.id eq '"+e+"'"},e.prototype.onOrigemMercadoriaLookupRequest=function(e,t){var i=this,r=(this.origemMercadoriaLookupDisplayFields.map(function(e){return{field:e,order:1}}),this.getOrigemMercadoriaFields().filter(function(t){var a=t.type;return Ie(a,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+Sr(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+Sr(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+Sr(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or "));r="("+r+")"+(r?" and ":""),r+=this.montaQueryOrigemMercadoria(t.get("fornecedor").value.id);var o=_e(this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields);this.pessoaEnderecoService.list({filterQuery:r,displayFields:o}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:i.origemMercadoriaLookupDisplayFields.map(function(t){return t.indexOf(".")>0?i.getProp(e,t):e[t]}).join(i.origemMercadoriaLookupSeparator)})})})})).subscribe(function(e){i.origemMercadoriaLookupSuggestions=e.contents})},e.prototype.onOrigemMercadoriaSearchRequest=function(e,t){var i=this,r=e.first,o=e.rows,s=e.multiSortMeta,l=e.filterData,d=r/o,c=s,p=this.getOrigemMercadoriaFields().filter(function(e){var t=e.name;return l[t]!=undefined&&""!=l[t]}).map(function(e){var t=e.name,a=e.type,i=l[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Sr(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Sr(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Sr(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and ");p=p.concat(p?" and ":""),p+=this.montaQueryOrigemMercadoria(t.get("fornecedor").value.id);var u=_e(this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields);this.pessoaEnderecoService.list({page:d,sort:c,filterQuery:p,displayFields:u}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:i.origemMercadoriaLookupDisplayFields.map(function(t){return t.indexOf(".")>0?i.getProp(e,t):e[t]}).join(i.origemMercadoriaLookupSeparator)})})})})).subscribe(function(e){i.origemMercadoriaSearchGridData=e.contents,i.origemMercadoriaSearchTotalRecords=e.totalElements})},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.onProdutoLookupRequest=function(e){var t=this,i=this.formGroup.get("filial").value,r=this.agenda.tipoAgendamento;this.produtoService.listProdutosRecebimento({pesquisa:e,empresaId:i?i.empresa.id:null,filialId:i?i.id:null,tipoAgendamentoId:r?r.id:null}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoLookupSuggestions=(e.produtos||[]).map(function(e){return Li.fromDto(e)})})},e.prototype.onProdutoSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getProdutoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}}),u=this.formGroup.get("filial").value,m=this.agenda.tipoAgendamento;this.produtoService.listProdutosRecebimento(j({},p,{empresaId:u?u.empresa.id:null,filialId:u?u.id:null,tipoAgendamentoId:m?m.id:null})).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoSearchTotalRecords=e.qtdTotalRegistros,t.produtoSearchGridData=(e.produtos||[]).map(function(e){return Li.fromDto(e)})})},e.prototype.onDerivacaoLookupRequest=function(e){var t=this,i=this.derivacaoLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=this.getDerivacaoSearchFields().filter(function(t){var a=t.type;return Ie(a,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+Sr(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+Sr(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+Sr(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or "),o=_e(this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields);this.derivacaoService.list({sort:i,filterQuery:r,displayFields:o}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.derivacaoLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.derivacaoLookupSeparator)})})})})).subscribe(function(e){t.derivacaoLookupSuggestions=e.contents})},e.prototype.onDerivacaoSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getDerivacaoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Sr(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Sr(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Sr(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and "),p=_e(this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields);this.derivacaoService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.derivacaoLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.derivacaoLookupSeparator)})})})})).subscribe(function(e){t.derivacaoSearchGridData=e.contents,t.derivacaoSearchTotalRecords=e.totalElements})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Oe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getTransportadoraSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Sr(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Sr(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Sr(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and "),p=_e(this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields);this.transportadoraService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.transportadoraLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.transportadoraLookupSeparator)})})})})).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.onTransgeniaLookupRequest=function(e){var t=this;Oe(this.getTransgeniaSearchFields(),this.transgeniaLookupDisplayFields,this.transgeniaAdvancedDisplayFields,this.transgeniaLookupSeparator,this.transgeniaService,e,this.geraFiltroTransgenia()).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.transgeniaLookupSuggestions=e.contents})},e.prototype.onTransgeniaSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getTransgeniaSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and "),p=this.geraFiltroTransgenia();p&&p.trim()&&(c=c?"("+c+") and "+p:p);var u=_e(this.transgeniaLookupDisplayFields,this.transgeniaAdvancedDisplayFields);this.transgeniaService.list({page:l,sort:d,filterQuery:c,displayFields:u}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.transgeniaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.transgeniaLookupSeparator)})})})})).subscribe(function(e){t.transgeniaSearchGridData=e.contents,t.transgeniaSearchTotalRecords=e.totalElements})},e.prototype.addFornecedor=function(e){void 0===e&&(e={}),this.erroFornecedores=!1;var t=this.getFornecedorForm(e);return this.configureFornecedor(t),this.getFornecedoresForm().push(t),t},e.prototype.removeFornecedor=function(e){var t=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_fornecedor_header"),message:this.translate.instant("yms.erp.remove_fornecedor_message"),accept:function(){var a=t.getFornecedoresForm().controls.indexOf(e);t.getFornecedoresForm().removeAt(a)}})},e.prototype.getFornecedoresForm=function(){return this.formGroup.get("fornecedores")},e.prototype.addContrato=function(e){var t=this;this.dialogService.open(vr,j({},Re,{header:"Adicionar Contrato",data:{agenda:this.agenda,filial:this.formGroup.get("filial").value,produto:this.formGroup.get("produto").value,fornecedor:e.get("fornecedor").value,contratos:e.get("contratos").value}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){var i=a.contrato;return t.onContratoSaved(i,e)})},e.prototype.removerContrato=function(e,t){this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_contrato_header"),message:this.translate.instant("yms.erp.remove_contrato_message"),accept:function(){var a=e.get("contratos").controls.indexOf(t);e.get("contratos").removeAt(a)}})},e.prototype.getContratos=function(e){return this.contratos=e.get("contratos"),this.contratos},e.prototype.addNota=function(e){var t=this;this.dialogService.open(ba,j({header:this.translate.instant("yms.erp.adicionar_nota")},Re,{data:{fornecedor:e.get("fornecedor").value,produto:this.formGroup.get("produto").value,filial:this.formGroup.get("filial").value,fornecedorNotasTokens:this.fornecedorNotasTokens,contratos:this.contratos}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){return t.onNotaSaved(a,e)})},e.prototype.removerNota=function(e,t,a){var i=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_nota_header"),message:this.translate.instant("yms.erp.remove_nota_message"),accept:function(){var r=t.value.contrato.id,o=i.getNotasFromContratos(e,r).controls.indexOf(a);i.getNotasFromContratos(e,r).removeAt(o);var n=a.value;i.fornecedorNotasTokens.push({id:n.chaveNotaFiscal,label:n.numeroNotaFiscal}),i.fornecedorNotas.push({chaveNotaFiscal:n.chaveNotaFiscal,serieNotaFiscal:n.serieNotaFiscal,serieLegalNotaFiscal:n.serieLegalNotaFiscal,numeroNotaFiscal:n.numeroNotaFiscal})}})},e.prototype.getNotas=function(e){return e.controls.notas},e.prototype.getItensContrato=function(e){return e.get("itens")},e.prototype.showButtons=function(){return!!this.agenda&&(this.isNew()||[It.AGENDADO,It.AGUARDANDO_CONFIRMACAO,It.AGUARDANDO_CONFIRMACAO_SOLICITANTE,It.REJEITADO_POR_VALIDACAO].includes(this.agenda.status))},e.prototype.disableAdicionarNota=function(){return null===this.contratoSelecionado},e.prototype.getTipoTransgenia=function(){if(this.formGroup.get("fornecedores").length<=0)return null;var e=null;return Fr.toDto(this.formGroup.getRawValue()).fornecedores.forEach(function(t){null!=t.fornecedor&&null!=t.fornecedor.tipoParticipante&&(e=t.fornecedor.tipoParticipante)}),e},e.prototype.getFamiliaProduto=function(){var e=this.formGroup.get("produto").value;return e&&e.familia&&e.familia.codigo?e.familia.codigo:e&&e.familia?e.familia:null},e.prototype.geraFiltroTransgenia=function(){var e="empresa.id eq '"+this.formGroup.get("filial").value.empresa.id+"'";e+="and situacao eq '"+$i.ATIVO+"'";var t=this.getFamiliaProduto();t&&(e+=" and ",e+="familia eq '"+t+"'");var a=this.getTipoTransgenia();return a&&(e+=" and ",e+="tipoParticipante eq '"+a+"'"),e},e.prototype.getNotaForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({chaveNotaFiscal:[e.chaveNotaFiscal],serieNotaFiscal:[e.serieNotaFiscal],serieLegalNotaFiscal:[e.serieLegalNotaFiscal],numeroNotaFiscal:[e.numeroNotaFiscal]})},e.prototype.getContratoForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({contrato:[e.contrato,C.Validators.required],itens:this.formBuilder.array([]),notas:this.formBuilder.array([])})},e.prototype.getItemForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({item:[e.item,C.Validators.required],quantidade:[e.quantidade]})},e.prototype.getFornecedorForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({fornecedor:[e.fornecedor,C.Validators.required],origemMercadoria:[e.origemMercadoria,C.Validators.compose([C.Validators.required])],tipoNotaFiscal:[e.tipoNotaFiscal||zi.EMPRESA_JURIDICA,C.Validators.compose([])],contratos:this.formBuilder.array([])})},e.prototype.getFormGroup=function(){return this.formBuilder.group({id:[{value:undefined,disabled:!0},C.Validators.compose([])],filial:[{value:undefined,disabled:!1},C.Validators.required],produto:[{value:undefined,disabled:!0},C.Validators.compose([C.Validators.required])],derivacao:[{value:undefined,disabled:!0},C.Validators.compose([])],transportadora:[{value:undefined,disabled:!1},C.Validators.compose([])],agenda:[{value:this.agenda,disabled:!1},C.Validators.compose([C.Validators.required])],transgenia:[{value:undefined,disabled:!0},C.Validators.compose([])],fornecedores:this.formBuilder.array([]),createdBy:[{value:undefined,disabled:!0},C.Validators.compose([])],createdDate:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedBy:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedDate:[{value:undefined,disabled:!0},C.Validators.compose([])],custom:[]})},e.prototype.getFornecedorByContrato=function(e,t){this.pessoaService.list({size:1,page:0,filterQuery:"id eq '"+e.pessoa.id+"'"}).pipe(a.takeUntil(this.ngUnsubscribe),a.map(function(e){var t=e.contents;return(t||[]).length&&t[0]}),a.filter(function(e){return!!e})).subscribe(function(e){t.get("fornecedor").setValue(ta.fromDto(e))})},e.prototype.getProdutoByContrato=function(e){var i=this;this.contratoCompraService.listItens(e.id,{size:1,page:0,displayFields:["sku.id"]}).pipe(a.takeUntil(this.ngUnsubscribe),a.mergeMap(function(e){var r=e.contents;return 1===r.length?i.produtoService.list({size:1,page:0,filterQuery:"id eq '"+r[0].sku.id+"'"}).pipe(a.takeUntil(i.ngUnsubscribe),a.map(function(e){var t=e.contents;return(t||[]).length&&t[0]})):t.empty()}),a.filter(function(e){return!!e})).subscribe(function(e){i.formGroup.get("produto").setValue(Li.fromDto(e)),i.formGroup.get("produto").disable()})},e.prototype.onContratoSaved=function(e,t){var a=this;this.formGroup.get("produto").value||this.getProdutoByContrato(e.contrato),t.get("fornecedor").value||this.getFornecedorByContrato(e.contrato,t);var i=this.getContratoForm(e);(e.itens||[]).forEach(function(e){return i.get("itens").push(a.getItemForm(e))}),this.getContratos(t).push(i)},e.prototype.mensagemContratoNaoSelecionado=function(){this.addMessage("error","Contrato não selecionado","Nenhum contrato foi selecionado!")},e.prototype.onNotaSaved=function(e,t){if(null!==this.contratoSelecionado)if(e.addFornecedor){var a=this.formGroup.get("fornecedores").controls.find(function(t){return(t.value.fornecedor||{id:undefined}).id===e.fornecedor.id}),i=e.infoNota,r=this.getNotaForm({chaveNotaFiscal:i.chave,serieNotaFiscal:i.serie,serieLegalNotaFiscal:i.serieLegal,numeroNotaFiscal:i.numero});if(a)(n=this.getNotasFromContratos(a,this.contratoSelecionado.id)).push(r);else if(t.get("fornecedor").value){var o=this.addFornecedor({fornecedor:ta.fromDto(e.fornecedor),origemMercadoria:pa.fromDto(e.origemMercadoria)});(n=this.getNotasFromContratos(o,this.contratoSelecionado.id)).push(r)}else{t.get("fornecedor").setValue(ta.fromDto(e.fornecedor)),t.get("origemMercadoria").setValue(pa.fromDto(e.origemMercadoria)),(n=this.getNotasFromContratos(t,this.contratoSelecionado.id)).push(r)}}else{var n;null!==(n=this.getNotasFromContratos(t,this.contratoSelecionado.id))&&n.push(this.getNotaForm(e))}else this.mensagemContratoNaoSelecionado()},e.prototype.getNotasFromContratos=function(e,t){var a,i,r=null,o=e.controls.contratos.controls;try{for(var n=z(o),s=n.next();!s.done;s=n.next()){var l=s.value;l.controls.contrato.value.id===t&&(r=l.controls.notas)}}catch(d){a={error:d}}finally{try{s&&!s.done&&(i=n["return"])&&i.call(n)}finally{if(a)throw a.error}}return r},e.prototype.addFornecedorNotasTokenEmContrato=function(e,t){if(null!==this.contratoSelecionado){var a=this.fornecedorNotas.filter(function(e){return e.chaveNotaFiscal===t.id}),i=this.getNotasFromContratos(e,this.contratoSelecionado.id);null!==i&&null!==a[0]&&i.push(this.getNotaForm(a[0])),this.removeFornecedorNotasTokenDoContrato(t)}else this.mensagemContratoNaoSelecionado()},e.prototype.removeFornecedorNotasTokenDoContrato=function(e){this.fornecedorNotasTokens.splice(this.fornecedorNotasTokens.indexOf(e),1),this.fornecedorNotas=this.fornecedorNotas.filter(function(t){return t.chaveNotaFiscal!==e.id})},e.prototype.removeNotaError=function(){this.erroFornecedoresNotaDuplicada=null,this.erroChaveNota=!1},e.prototype.addNotaError=function(){this.erroChaveNota=!0},e.prototype.validateProduto=function(e){return this.formGroup.get("produto").value.id===e.id},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.filial_nome"),type:n.FieldType.String})]},e.prototype.getFornecedorSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.pessoa_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.pessoa_nome"),type:n.FieldType.String}),new n.FormField({name:"cpfCnpj",label:this.translate.instant("yms.erp.pessoa_cpfCnpj"),type:n.FieldType.String})]},e.prototype.getFornecedorSearchGridFields=function(){return this.getFornecedorSearchFields()},e.prototype.getOrigemMercadoriaFields=function(){return[this.buildFormField.buildForInteger("codigo","yms.erp.pessoa_endereco_codigo"),this.buildFormField.buildForString("cnpjCpf","yms.erp.pessoa_endereco_cnpj_cpf"),this.buildFormField.buildForString("inscricaoEstadual","yms.erp.pessoa_endereco_inscricao_estadual"),this.buildFormField.buildForString("cep","yms.erp.pessoa_endereco_cep"),this.buildFormField.buildForString("endereco","yms.erp.pessoa_endereco_endereco"),this.buildFormField.buildForString("numero","yms.erp.pessoa_endereco_numero"),this.buildFormField.buildForString("bairro","yms.erp.pessoa_endereco_bairro")]},e.prototype.getOrigemMercadoriaGridFields=function(){var e=this.getOrigemMercadoriaFields();return e.push(this.buildFormField.buildForString("empresa.descricao","yms.erp.empresa")),e},e.prototype.getProdutoSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.produto_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.produto_descricao"),type:n.FieldType.String})]},e.prototype.getProdutoSearchGridFields=function(){var e=this.getProdutoSearchFields();return e.push(new n.FormField({name:"descricaoComplementar",label:this.translate.instant("yms.erp.produto_descricao_complementar"),type:n.FieldType.String})),e},e.prototype.getAgendaSearchFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getAgendaSearchGridFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransgeniaSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_descricao")})]},e.prototype.getTransgeniaSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_descricao")})]},e.prototype.goBack=function(){this.router.navigate(["../"],{relativeTo:this.route.parent})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup?t.validateAllFormFields(i):i instanceof C.FormArray&&i.controls.forEach(function(e){return t.validateAllFormFields(e)})}),this.focusService.focusFirstInvalidInput()},e.prototype.getSaveObservable=function(){var e=this.formGroup.getRawValue();e.agenda=this.agenda;var t,a=Fr.toDto(e),i=a.fornecedores;if(a.fornecedores.forEach(function(e){a.fornecedores.forEach(function(t){e.fornecedor.id===t.fornecedor.id&&e.origemMercadoria.id===t.origemMercadoria.id&&(t.contratos.forEach(function(t){return e.contratos.push(t)}),i=i.splice(i.indexOf(t),1))})}),a.fornecedores=i,this.isNew()&&!e.id)t=this.recebimentoService.insert(a);else{var r=e.id;t=this.recebimentoService.update(r,a)}return t},e.prototype.getDeleteObservable=function(){var e=this;return this.recebimentoService["delete"]("").pipe(a.tap(function(){e.addMessage("success","yms.erp.deleted_message_title","yms.erp.deleted_message_content"),e.goBack()}))},e.prototype.validateVisualization=function(){ke(this.formGroup,this.allPermissions)||this.addMessage("error","yms.erp.cannot_visualize_form_summary","yms.erp.cannot_visualize_form_detail")},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.buscarFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length?this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&e.formGroup.get("filial").setValue(ma.fromDto(a[0])),e.formCarregado=!0}):this.formCarregado=!0},e.prototype.configureFornecedor=function(e){var t=this;e.get("fornecedor").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.debounceTime(500),a.tap(function(a){if(a)return t.ehPessoaJuridica(a)?(e.get("tipoNotaFiscal").setValue(zi.EMPRESA_JURIDICA),void e.get("tipoNotaFiscal").enable()):(e.get("tipoNotaFiscal").setValue(zi.PRODUTOR_RURAL),void e.get("tipoNotaFiscal").disable());e.get("tipoNotaFiscal").setValue(zi.EMPRESA_JURIDICA),e.get("tipoNotaFiscal").disable()}),a.filter(function(e){return!!e||(t.formGroup.get("transgenia").setValue(null),t.formGroup.get("transgenia").disable(),!1)}),a.mergeMap(function(e){return t.pessoaEnderecoService.list({size:10,page:0,filterQuery:"situacao eq 'ATIVO' and pessoa.id eq '"+e.id+"'"}).pipe(a.takeUntil(t.ngUnsubscribe))})).subscribe(function(a){var i=a.contents;t.formGroup.get("transgenia").enable(),1===i.length?e.get("origemMercadoria").setValue(pa.fromDto(i[0])):(e.get("origemMercadoria").setValue(undefined),e.get("origemMercadoria").enable())})},e.prototype.ehPessoaJuridica=function(e){return(e.cpfCnpj||"").replace(/\D+/g,"").length>11},e.prototype.mensagemBuscandoNota=function(){this.messageService.add({severity:"info",summary:"Buscando dados da nota",detail:"Aguarde, buscando dados da nota",life:5e3})},e.prototype.validarCnpjFornecedor=function(e){return!!this.ehPessoaJuridica({cpfCnpj:e})&&this.formGroup.get("fornecedores").controls.find(function(t){return(t.value.fornecedor||{cpfCnpj:""}).cpfCnpj.substring(0,8)===e.substring(0,8)})},V([r.Input(),B("design:type",qe)],e.prototype,"agenda",void 0),V([r.ViewChild("customTemplate"),B("design:type",r.TemplateRef)],e.prototype,"customTemplate",void 0),V([r.ViewChild("customFormFields"),B("design:type",r.TemplateRef)],e.prototype,"customFormFields",void 0),e=V([r.Component({selector:"recebimento-form",template:'<p-confirmDialog [acceptLabel]="\'yes\' | translate" acceptIcon="" [rejectLabel]="\'no\' | translate" rejectIcon=""></p-confirmDialog>\n<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 ui-md-6">\n <label for="chaveNotaFiscal">{{"yms.erp.recebimento_chave_nota_fiscal" | translate}}</label>\n <input\n id="chaveNotaFiscal"\n trim\n [class.ng-invalid]="erroChaveNota"\n [(ngModel)]="chaveNotaFiscal"\n [ngModelOptions]="{ standalone: true }"\n type="text"\n name="chaveNotaFiscal"\n pInputText\n autocomplete="off"\n (blur)="onBlurChaveNotaFiscal()"\n />\n <span class="nota-error" *ngIf="erroChaveNota">{{\'yms.erp.produto_nota_error_detail\' | translate}}</span>\n </div>\n </div>\n <div class="ui-fluid">\n <div class="ui-g">\n <div [attr.data-hidden]="true" class="ui-g-12 ui-md-6">\n <label for="id">{{"yms.erp.recebimento_id" | translate}}</label>\n <input #idFormInput type="text" id="id" name="id" pInputText formControlName="id" autocomplete="off" />\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="filial">{{"yms.erp.filial" | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions"\n (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="produto">{{"yms.erp.recebimento_produto" | translate}}</label>\n <s-lookup dataKey="id" id="produto" name="produto" formControlName="produto"\n [searchFields]="produtoSearchFields" [searchGridFields]="produtoSearchGridFields"\n [searchGridData]="produtoSearchGridData" [multiple]="false"\n [lookupSuggestions]="produtoLookupSuggestions"\n (onLookupRequest)="onProdutoLookupRequest($event)"\n (onSearchRequest)="onProdutoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]=produtoSearchTotalRecords\n [searchTitle]="\'yms.erp.recebimento_produto_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: produtoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'produto\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="derivacao">{{"yms.erp.recebimento_derivacao" | translate}}</label>\n <s-lookup dataKey="id" id="derivacao" name="derivacao" formControlName="derivacao"\n [searchFields]="derivacaoSearchFields" [searchGridFields]="derivacaoSearchGridFields"\n [searchGridData]="derivacaoSearchGridData" [multiple]="false"\n [lookupSuggestions]="derivacaoLookupSuggestions"\n (onLookupRequest)="onDerivacaoLookupRequest($event)"\n (onSearchRequest)="onDerivacaoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]=derivacaoSearchTotalRecords\n [searchTitle]="\'yms.erp.recebimento_derivacao_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: derivacaoSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="transportadora">{{"yms.erp.recebimento_transportadora" | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchGridFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="transgenia">{{"yms.erp.recebimento_transgenia" | translate}}</label>\n <s-lookup dataKey="id" id="transgenia" name="transgenia"\n formControlName="transgenia" [searchFields]="transgeniaSearchFields"\n [searchGridFields]="transgeniaSearchGridFields"\n [searchGridData]="transgeniaSearchGridData" [multiple]="false"\n [lookupSuggestions]="transgeniaLookupSuggestions"\n (onLookupRequest)="onTransgeniaLookupRequest($event)"\n (onSearchRequest)="onTransgeniaSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transgeniaSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_transgenia_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transgeniaSearchTotalRecords}">\n </s-lookup>\n </div>\n\n <div class="ui-md-12">\n <s-button styleClass="btn-erp-forms" *ngIf="showButtons() && !!formGroup.get(\'filial\').value && !createdByErp"\n iconClass="fas fa-plus" label="Adicionar fornecedor" priority="secondary" (onClick)="addFornecedor()"\n [disabled]="disableButtonSave || !permissions.editar"></s-button>\n <span style="display: block;" class="input-error" *ngIf="erroFornecedores">{{\'Selecione ao menos um fornecedor para continuar\' | translate}}</span>\n <span style="display: block;" class="input-error" *ngIf="erroFornecedoresNotaDuplicada">{{ erroFornecedoresNotaDuplicada }}</span>\n </div>\n\n <form class="ui-g-12" *ngFor="let fornecedorForm of getFornecedoresForm().controls; let i = index;" [formGroup]="fornecedorForm">\n <p-panel [style]="{position: \'relative\'}" styleClass="form-group ui-g-12 ui-md-12" [toggleable]="true" >\n\n <p-header>\n Fornecedor {{+i+1}}\n <s-button \n style="display: inline-block; position: absolute; right: 50px; top: 10px" \n *ngIf="showButtons() && !createdByErp"\n iconClass="fas fa-trash"\n label="Remover"\n priority="default"\n [auxiliary]="true"\n (onClick)="removeFornecedor(fornecedorForm)"\n >\n </s-button>\n </p-header>\n <div class="ui-g-12 ui-md-6 required">\n <label for="fornecedor">{{"yms.erp.recebimento_fornecedor" | translate}}</label>\n <s-lookup dataKey="id" id="fornecedor" name="fornecedor" formControlName="fornecedor"\n [searchFields]="fornecedorSearchFields" [searchGridFields]="fornecedorSearchGridFields"\n [searchGridData]="fornecedorSearchGridData" [multiple]="false"\n [lookupSuggestions]="fornecedorLookupSuggestions"\n (onLookupRequest)="onFornecedorLookupRequest($event)"\n (onSearchRequest)="onFornecedorSearchRequest($event)" \n lookupDisplayField="label"\n [searchTotalRecords]=fornecedorSearchTotalRecords\n [searchTitle]="\'yms.erp.recebimento_fornecedor_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: fornecedorSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="fornecedorForm.get(\'fornecedor\')"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="origemMercadoria">{{"yms.erp.recebimento_origem_mercadoria" | translate}}</label>\n <s-lookup dataKey="id" id="origemMercadoria" name="origemMercadoria"\n formControlName="origemMercadoria" [searchFields]="origemMercadoriaSearchFields"\n [searchGridFields]="origemMercadoriaSearchGridFields"\n [searchGridData]="origemMercadoriaSearchGridData" [multiple]="false"\n [lookupSuggestions]="origemMercadoriaLookupSuggestions"\n (onLookupRequest)="onOrigemMercadoriaLookupRequest($event, fornecedorForm)"\n (onSearchRequest)="onOrigemMercadoriaSearchRequest($event, fornecedorForm)" lookupDisplayField="label"\n [searchTotalRecords]="origemMercadoriaSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_pessoa_endereco_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: origemMercadoriaSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="fornecedorForm.get(\'origemMercadoria\')"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n\n <div class="ui-g-12">\n <label for="fornecedorNotas">Notas a serem adicionadas</label>\n <s-token-list id="fornecedorNotas" [tokens]="fornecedorNotasTokens" (tokenSelected)="addFornecedorNotasTokenEmContrato(fornecedorForm, $event)" (tokenRemoved)="removeFornecedorNotasTokenDoContrato($event)" [removableTokens]="true"></s-token-list>\n </div>\n\n <div class="ui-g-12">\n <s-button label="Adicionar nota" *ngIf="showButtons()" styleClass="btn-erp-forms" priority="secondary" (onClick)="addNota(fornecedorForm)" [disabled]="disableAdicionarNota()"></s-button>\n <s-button label="Adicionar contrato" *ngIf="showButtons() && !createdByErp" styleClass="btn-erp-forms" priority="secondary" (onClick)="addContrato(fornecedorForm)"></s-button>\n </div>\n\n <div class="ui-g-12 ui-md-6">\n <label for="tipoNotaFiscal">{{"yms.erp.recebimento_tipo_nota_fiscal" | translate}}</label>\n <p-dropdown inputId="tipoNotaFiscal" name="tipoNotaFiscal" [options]="tiposNota" formControlName="tipoNotaFiscal">\n </p-dropdown>\n </div>\n\n <div class="ui-g-12">\n <h4>Contratos</h4>\n <p-table [value]="getContratos(fornecedorForm).controls" [(selection)]="contratoSelecionado">\n <ng-template pTemplate="body" let-rowData>\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px">\n <p-tableRadioButton [value]="rowData.get(\'contrato\').value"></p-tableRadioButton>\n </td>\n <td>\n <p-accordion>\n <p-accordionTab>\n <p-header>\n Contrato {{rowData.get(\'contrato\').value.numero}}, Filial {{rowData.get(\'contrato\').value.filial?.codigo}}\n\n <span *ngIf="showButtons() && !createdByErp" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerContrato(fornecedorForm, rowData)"></span>\n </p-header>\n \n <div class="detail-pane" *ngFor="let item of getItensContrato(rowData).controls">\n <div class="detail-span">\n <span class="title">Sequência</span>\n <span class="data">{{item.value?.item.sequencia}}</span>\n </div>\n </div>\n \n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Notas</span>\n <span class="data">\n <p-accordion>\n <p-accordionTab *ngFor="let nota of getNotas(rowData).controls">\n <p-header>\n {{nota.get(\'chaveNotaFiscal\').value || (nota.get(\'serieNotaFiscal\').value + \' - \' + nota.get(\'numeroNotaFiscal\').value)}}\n\n <span *ngIf="showButtons()" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerNota(fornecedorForm, rowData, nota)"></span>\n </p-header>\n \n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Série nota fiscal</span>\n <span class="data">{{nota.value?.serieNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Série legal nota fiscal</span>\n <span class="data">{{nota.value?.serieLegalNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{nota.value?.numeroNotaFiscal}}</span>\n </div>\n </div>\n \n </p-accordionTab> \n </p-accordion>\n </span>\n </div>\n </div>\n </p-accordionTab>\n </p-accordion>\n </td>\n </tr>\n </ng-template>\n </p-table>\n </div>\n\n </p-panel>\n\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">{{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} / </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">{{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}</label>\n </div>\n </form>\n\n </div>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button *ngIf="showButtons()" priority="primary" [label]="\'save\' | translate" (onClick)="onSave()"\n [disabled]="disableButtonSave || !allPermissions.agenda.editar"></s-button>\n <s-button *ngIf="saveAndInitButton && showButtons()" priority="primary" [label]="\'save_and_init\' | translate"\n (onClick)="onSave(true)" [disabled]="disableButtonSave || !allPermissions.agenda.editar"></s-button>\n </div>\n</div>',providers:[c.ConfirmationService],styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),B("design:paramtypes",[Pt,F.Router,F.ActivatedRoute,I.MessageService,c.ConfirmationService,C.FormBuilder,o.TranslateService,G.HotkeysService,Be,Ue,qa,pi,Ha,Ma,Xa,ei,Ea,jt,ya,Di,c.DialogService,qt,ri,oi,Wt,ai,bi])],e)}(),Cr=function(){function e(e){this.recebimentoService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.recebimentoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Recebimento não encontrado.")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.recebimento=Fr.fromDto(t)})},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"recebimento-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_filial" | translate }}\n </span>\n <span class="data">\n {{ recebimento?.filial?.codigo }} - {{ recebimento?.filial?.nome }}\n </span>\n </div>\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_produto" | translate }}\n </span>\n <span class="data">{{ recebimento?.produto?.descricao }}</span>\n </div>\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_derivacao" | translate }}\n </span>\n <span class="data">{{ recebimento?.derivacao?.descricao }}</span>\n </div>\n </div>\n <div *ngFor="let fornecedor of recebimento?.fornecedores">\n <div class="separator"></div>\n <h3>Fornecedor - {{ fornecedor?.fornecedor?.nome }}</h3>\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_origem_mercadoria" | translate }}\n </span>\n <span class="data">\n {{ fornecedor?.origemMercadoria?.codigo }} - {{ fornecedor?.origemMercadoria?.cep }}\n </span>\n </div>\n </div>\n\n <div>\n <h4>Contratos</h4>\n <p-accordion>\n <p-accordionTab *ngFor="let contrato of fornecedor.contratos">\n <p-header>\n Contrato {{ contrato?.contrato?.numero }}, Filial {{ contrato?.contrato?.filial?.codigo }}\n </p-header>\n\n <div class="detail-pane" *ngFor="let item of contrato?.itens">\n <div class="detail-span">\n <span class="title">Sequência</span>\n <span class="data">{{ item?.item?.sequencia }}</span>\n </div>\n </div>\n\n <div *ngFor="let nota of contrato.notas">\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Chave nota fiscal</span>\n <span class="data">{{ nota?.chaveNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie nota fiscal</span>\n <span class="data">{{ nota?.serieNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie legal nota fiscal</span>\n <span class="data">{{ nota?.serieLegalNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{ nota?.numeroNotaFiscal }}</span>\n </div>\n </div>\n <hr />\n </div>\n </p-accordionTab>\n </p-accordion>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),B("design:paramtypes",[Pt])],e)}();function _r(){return[{name:"json",func:x},{name:"xml",func:L}]}var Ir=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(Ht).dispatch(Kt).dispatch(er)}return e=V([r.NgModule({declarations:[Ht,Dr,Ji,Kt,Xi,Cr,Hi,cr,pr,Yi,vr,va,ir,rr,er],entryComponents:[Ht,Kt,vr,va,er],exports:[Ht,Kt],imports:[i.CommonModule,C.FormsModule,C.ReactiveFormsModule,o.TranslateModule,n.CustomFieldsModule,n.ControlErrorsModule,N.DialogModule,n.EmptyStateModule,n.DynamicFormModule,n.TokenListModule,w.PanelModule,R.AccordionModule,D.InputTextModule,A.DropdownModule,n.ButtonModule,n.LoadingStateModule,n.NumberInputModule,E.ConfirmDialogModule,n.LocaleModule,p.IntegrationModule,Mi,m.PermissionsModule,v.DynamicDialogModule,Da,R.AccordionModule,l.TableModule,y.TabViewModule,n.LoadingStateModule,M.HighlightModule.forRoot({languages:_r}),G.HotkeyModule.forRoot(),Sa],providers:[Be,Ue,jt,Ut,Ri,dr,ar,Wt]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),Tr=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.url_dock="yms/dock/",i}return P(t,e),t.prototype.fallbackCall=function(e,t,a){return this.http.post(this.url_dock+"actions/setVagaInTransit",{plantId:e,vaga:t,plate:a}).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),kr=function(){function e(){}return e=V([r.NgModule({providers:[Tr]})],e)}();e.AgendaModule=Ca,e.AgendaService=qt,e.BalancaModule=ie,e.BalancasService=Z,e.CamerasModule=le,e.CamerasService=re,e.CancelasModule=X,e.CidadeModule=Ia,e.CidadeService=_a,e.ContratoCompraItemModule=ka,e.ContratoCompraItemService=Ta,e.ContratoCompraModule=Ra,e.ContratoCompraService=Ma,e.ControladorCancelaComponent=J,e.ControladorCancelaDescritor=W,e.ControladorCancelasService=K,e.CoreModule=Mi,e.DockModule=kr,e.DockService=Tr,e.DocumentListComponent=Ot,e.DocumentListModule=xt,e.ERP_ENVIRONMENT=Lt,e.ERP_SENIOR_HEADER=zt,e.EmpresaModule=wa,e.EmpresaService=Aa,e.ErpFormConfigService=oi,e.ErpProcessData=ii,e.ErpProcessService=ri,e.ErpSeniorModule=Ir,e.EstadoModule=Oa,e.EstadoService=Ga,e.ExpedicaoChegadaVeiculoOverride=Ut,e.ExpedicaoModule=hi,e.ExpedicaoService=Vt,e.FamiliaProdutoModule=La,e.FamiliaProdutoService=xa,e.FieldCustomizationService=Be,e.FilialModule=Pa,e.FilialService=qa,e.FormComponent=Ht,e.FormDescritor=$t,e.FormSamComponent=Ve,e.FormSamDescritor=je,e.FormWmsComponent=bt,e.FormWmsDescritor=yt,e.HasChangeService=ai,e.INFORMACAOES_ADICIONAIS_HEADER=vt,e.InfoComponent=Kt,e.InfoDescritor=Qt,e.IntegrationWebSocket=Y,e.LogsModule=fe,e.LogsService=pe,e.LprModule=ce,e.LprService=de,e.PaisModule=Va,e.PaisService=ja,e.PedidoVendaItemModule=Ba,e.PedidoVendaItemService=Ua,e.PedidoVendaModule=$a,e.PedidoVendaService=za,e.PessoaEnderecoModule=Ya,e.PessoaEnderecoService=Ha,e.PessoaFisicaModule=Ka,e.PessoaFisicaService=Qa,e.PessoaJuridicaModule=Ja,e.PessoaJuridicaService=Wa,e.PessoaModule=Za,e.PessoaService=Xa,e.PortariasComponent=ve,e.PortariasDescritor=ge,e.PortariasModule=Se,e.ProdutoModule=ti,e.ProdutoService=ei,e.RecebimentoChegadaVeiculoOverride=jt,e.RecebimentoContratoModule=ni,e.RecebimentoContratoService=Pt,e.RoyaltyModule=li,e.RoyaltyService=si,e.SAM_SENIOR_HEADER=Pe,e.SafraModule=ci,e.SafraService=di,e.SamSeniorModule=pt,e.SnapshotComponent=se,e.SnapshotDescritor=ne,e.TransportadoraModule=ui,e.TransportadoraService=pi,e.UnidadeMedidaModule=fi,e.UnidadeMedidaService=mi,e.VisitorListComponent=mt,e.VisitorListModule=ft,e.VisitorListService=ut,e.VisualizarBalancaComponent=te,e.VisualizarBalancaDescritor=ee,e.WmsModule=Gt,e.highlightLanguages=_r,e.ɵa=Q,e.ɵb=ae,e.ɵba=St,e.ɵbb=Ft,e.ɵbc=Et,e.ɵbd=Rt,e.ɵbe=At,e.ɵbf=Nt,e.ɵbg=Bt,e.ɵbh=Dr,e.ɵbi=Ea,e.ɵbj=ya,e.ɵbk=Di,e.ɵbl=Wt,e.ɵbm=bi,e.ɵbn=Ji,e.ɵbo=Xi,e.ɵbp=Cr,e.ɵbq=Hi,e.ɵbr=gi,e.ɵbs=Ri,e.ɵbt=cr,e.ɵbu=Jt,e.ɵbv=Fi,e.ɵbw=dr,e.ɵbx=pr,e.ɵby=Yi,e.ɵbz=vr,e.ɵc=oe,e.ɵca=va,e.ɵcb=ir,e.ɵcc=_i,e.ɵcd=ar,e.ɵce=rr,e.ɵcf=Zi,e.ɵcg=er,e.ɵch=Ti,e.ɵci=Na,e.ɵcj=vi,e.ɵck=yi,e.ɵcl=Si,e.ɵcm=Ci,e.ɵcn=Ii,e.ɵco=ki,e.ɵcp=Da,e.ɵcq=Sa,e.ɵcr=Fa,e.ɵcs=ba,e.ɵd=ue,e.ɵe=me,e.ɵf=he,e.ɵg=Fe,e.ɵh=ye,e.ɵi=be,e.ɵj=He,e.ɵk=Ye,e.ɵl=ze,e.ɵm=ct,e.ɵn=nt,e.ɵo=et,e.ɵp=tt,e.ɵq=Ze,e.ɵr=Xe,e.ɵs=Je,e.ɵt=Ue,e.ɵu=gt,e.ɵv=wt,e.ɵw=Tt,e.ɵx=Ct,e.ɵy=_t,e.ɵz=Dt,Object.defineProperty(e,"__esModule",{value:!0})});
2
2
  //# sourceMappingURL=seniorsistemas-yms-integration.umd.min.js.map