!function(){function t(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,n){if(!t)return;if("string"==typeof t)return e(t,n);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return e(t,n)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=new Array(e);ni)){e.next=13;break}return i>-1&&(this._pageIndex=i),e.next=9,this._httpService.get(Array.isArray(this._api)?[this._api[0],"".concat(this._api[1],"?").concat(this.query,"sort=").concat(this._sort,"&offset=").concat(this._pageSize*this._pageIndex,"&limit=").concat(this._pageSize)]:"".concat(this._api,"?").concat(this.query,"sort=").concat(this._sort,"&offset=").concat(this._pageSize*this._pageIndex,"&limit=").concat(this._pageSize));case 9:a=e.sent,i=a?Math.max(0,Math.ceil(a.total/this._pageSize)-1):Number.MAX_VALUE;case 11:e.next=5;break;case 13:e.next=18;break;case 15:return e.next=17,this._httpService.get(Array.isArray(this._api)?[this._api[0],"".concat(this._api[1],"?").concat(this.query,"sort=").concat(this._sort)]:"".concat(this._api,"?").concat(this.query,"sort=").concat(this._sort));case 17:a=e.sent;case 18:if(e.t0=a,!e.t0){e.next=29;break}if(e.t1=this._convertor,!e.t1){e.next=25;break}return e.next=24,this._convertor(a);case 24:a=e.sent;case 25:this._loading=!1,this._total=a.total,this._rows=a.items,this._selection.clear();case 29:this.refreshEvent.emit(n);case 30:case"end":return e.stop()}},e,this)}))}},{key:"edit",value:function(t){return Object(c.a)(this,void 0,void 0,regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._dialogService.open(H,{autoFocus:!t,data:{data:t,fields:this._editors,pk:this._pk,api:this._api,error:this._error}});case 2:if(e.t0=e.sent,!e.t0){e.next=5;break}this.refresh({action:t?"edit":"add"});case 5:case"end":return e.stop()}},e,this)}))}},{key:"delete",value:function(){return Object(c.a)(this,void 0,void 0,regeneratorRuntime.mark(function t(){var e=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._dialogService.confirm(this._i18nService.translate("shared.notification.confirm"));case 2:if(t.t0=t.sent,!t.t0){t.next=9;break}return t.t1=void 0,t.next=7,this._httpService.post(Array.isArray(this._api)?[this._api[0],this._api[1]+"/batch"]:this._api+"/batch",{method:"delete",data:this._selection.selected.map(function(t){return t[e._pk]})});case 7:t.t2=t.sent,t.t0=t.t1!==t.t2;case 9:if(t.t3=t.t0,!t.t3){t.next=12;break}this._toastService.show(this._i18nService.translate("shared.notification.success")),this.refresh({action:"delete"});case 12:case"end":return t.stop()}},t,this)}))}},{key:"filter",get:function(){return this._filter}},{key:"columns",get:function(){return this._columns}},{key:"fixed",get:function(){return this._fixed},set:function(t){this._fixed=t}},{key:"pageable",get:function(){return this._pageable},set:function(t){this._pageable=t}},{key:"selectable",get:function(){return this._selectable},set:function(t){var e,n;this._selectable=t,t?((null===(e=this._columns)||void 0===e?void 0:e.length)&&!this._columns.find(function(t){return"@selection"==t.id})&&this._columns.unshift({id:"@selection",sticky:"start"}),this._selection._multiple="single"!=t):(null===(n=this._columns)||void 0===n?void 0:n.length)&&"@selection"==this._columns[0].id&&this._columns.shift()}},{key:"editable",get:function(){return this._editable},set:function(t){var e,n;this._editable=t,t?(null===(e=this._columns)||void 0===e?void 0:e.length)&&!this._columns.find(function(t){return"@operation"==t.id})&&this._columns.push({id:"@operation",sticky:"end"}):(null===(n=this._columns)||void 0===n?void 0:n.length)&&"@operation"==this._columns[this._columns.length-1].id&&this._columns.pop()}},{key:"addable",get:function(){return this._addable},set:function(t){this._addable=t}},{key:"deletable",get:function(){return this._deletable},set:function(t){this._deletable=t}},{key:"rowClass",get:function(){return this._rowClass},set:function(t){this._rowClass=t}},{key:"toolbarTemplate",get:function(){return this._toolbarTemplate},set:function(t){this._toolbarTemplate=t}},{key:"toolbarButtonsTemplate",get:function(){return this._toolbarButtonsTemplate},set:function(t){this._toolbarButtonsTemplate=t}},{key:"toolbarIconsTemplate",get:function(){return this._toolbarIconsTemplate},set:function(t){this._toolbarIconsTemplate=t}},{key:"toolbarSelectionTemplate",get:function(){return this._toolbarSelectionTemplate},set:function(t){this._toolbarSelectionTemplate=t}},{key:"rowOperationTemplate",get:function(){return this._rowOperationTemplate},set:function(t){this._rowOperationTemplate=t}},{key:"rowExpandingTemplate",get:function(){return this._rowExpandingTemplate},set:function(t){this._rowExpandingTemplate=t}},{key:"filters",get:function(){return this._filters}},{key:"loading",get:function(){return this._loading},set:function(t){this._loading=t}},{key:"query",get:function(){return this._query.static?"".concat(this._query.static,"&").concat(this._query.dynamic):this._query.dynamic},set:function(t){this._query.static=t}},{key:"pageIndex",get:function(){return this._pageIndex}},{key:"pageSize",get:function(){return this._pageSize}},{key:"rows",get:function(){return this._rows}},{key:"total",get:function(){return this._total}},{key:"selection",get:function(){return this._selection}},{key:"pk",set:function(t){this._pk=t}},{key:"api",set:function(t){(this._api=t)&&this.refresh({action:"init"})}},{key:"defination",set:function(t){var e=this,n=t?t.filter(function(t){return null!==t.display}).map(function(t){return{id:t.id,header:t.header,template:t.template,style:t.style,sortable:t.sortable,sticky:t.sticky,display:t.display}}):[];this._selectable&&n.unshift({id:"@selection",header:null,template:null,style:null,sortable:!1,sticky:"start",display:!0}),(this._editable||this.rowOperationTemplate)&&n.push({id:"@operation",header:null,template:null,style:null,sortable:!1,sticky:"end",display:!0}),this._columns=new s.a(n),this._filters=[],this._editors=[],t&&t.forEach(function(t){var n,a;if(t.filter){var i={id:t.id,type:t.filter.field,label:t.header,order:t.filter.order,template:t.filter.template,range:t.filter.range,convertor:t.filter.convertor,default:null!==(n=t.filter.default)&&void 0!==n?n:null};e._filters.push(i),i.default&&(e._query.dynamic=(e._query.dynamic||"")+at.queryString(i,i.default))}t.editor&&e._editors.push({id:t.id,type:t.editor.field,label:t.header,order:t.editor.order,template:t.editor.template,range:t.editor.range,convertor:t.editor.convertor,validator:t.editor.validator,required:t.editor.required,default:null!==(a=t.editor.default)&&void 0!==a?a:null})})}},{key:"convertor",set:function(t){this._convertor=t}},{key:"error",set:function(t){this._error=t}}]),t}()).\u0275fac=function(t){return new(t||le)(r.Ob(it.a),r.Ob(d.a),r.Ob(m.a),r.Ob(b.a))},le.\u0275cmp=r.Ib({type:le,selectors:[["crud-template"]],viewQuery:function(t,e){var n;1&t&&r.Oc(gt,!0),2&t&&r.tc(n=r.cc())&&(e._filter=n.first)},hostAttrs:[1,"crud-template"],inputs:{pk:"pk",api:"api",defination:"defination",fixed:"fixed",pageable:"pageable",selectable:"selectable",editable:"editable",addable:"addable",deletable:"deletable",rowClass:["row-class","rowClass"],toolbarTemplate:["toolbar-template","toolbarTemplate"],toolbarButtonsTemplate:["toolbar-buttons-template","toolbarButtonsTemplate"],toolbarIconsTemplate:["toolbar-icons-template","toolbarIconsTemplate"],toolbarSelectionTemplate:["toolbar-selection-template","toolbarSelectionTemplate"],rowOperationTemplate:["row-operation-template","rowOperationTemplate"],rowExpandingTemplate:["row-expanding-template","rowExpandingTemplate"],convertor:"convertor",error:"error",query:"query"},outputs:{refreshEvent:"refresh"},decls:20,vars:12,consts:[["hasBackdrop","true"],["mode","over","position","end","autoFocus","false"],["$sidenav",""],[3,"fields","changed"],["$filter",""],[3,"loading"],[1,"row-auto"],["class","app-background-primary-lighter",4,"ngIf","ngIfElse"],["$toolbar",""],[1,"row-fill"],["mat-table","","matSort","",3,"multiTemplateDataRows","dataSource","matSortChange"],[3,"matColumnDef","ngSwitch","sticky","stickyEnd",4,"ngFor","ngForOf"],["matColumnDef","@expanding"],["mat-cell","",4,"matCellDef"],["mat-header-row","",4,"matHeaderRowDef","matHeaderRowDefSticky"],["mat-row","",3,"ngClass",4,"matRowDef","matRowDefColumns"],[4,"ngIf"],["class","mat-row",3,"hidden",4,"matNoDataRow"],["class","row-auto",4,"ngIf"],[1,"app-background-primary-lighter"],[1,"spacer","app-foreground-primary"],["mat-icon-button","",3,"matTooltip","click",4,"ngIf"],[3,"ngTemplateOutlet","ngTemplateOutletContext"],["mat-icon-button","",3,"matTooltip","click"],[1,"app-background-card"],[4,"ngIf","ngIfElse"],["$buttons",""],["mat-icon-button","",3,"matTooltip","matMenuTriggerFor",4,"ngIf"],[3,"ngTemplateOutlet"],["mat-button","","color","primary",3,"click",4,"ngIf"],["mat-button","","color","primary",3,"click"],[1,"spacer"],["mat-icon-button","",3,"matTooltip","matMenuTriggerFor"],["$columns",""],[3,"columns"],[3,"matColumnDef","ngSwitch","sticky","stickyEnd"],[4,"ngSwitchCase"],[4,"ngSwitchDefault"],["mat-header-cell","","style","width: 22px; padding-right: 24px;",4,"matHeaderCellDef"],["mat-cell","","style","padding-right: 24px;",4,"matCellDef"],["mat-header-cell","",2,"width","22px","padding-right","24px"],[3,"model","data",4,"ngIf"],[3,"model","data"],["mat-cell","",2,"padding-right","24px"],["mat-header-cell","","style","width: 40px; padding-right: 16px;",4,"matHeaderCellDef"],["mat-cell","","style","padding-right: 16px; text-align: right;",4,"matCellDef"],["mat-header-cell","",2,"width","40px","padding-right","16px"],["mat-cell","",2,"padding-right","16px","text-align","right"],["mat-header-cell","","mat-sort-header","",3,"ngStyle","disabled",4,"matHeaderCellDef"],["mat-cell","",3,"ngStyle",4,"matCellDef"],["mat-header-cell","","mat-sort-header","",3,"ngStyle","disabled"],["mat-cell","",3,"ngStyle"],["$text",""],["mat-cell",""],["mat-header-row",""],["mat-row","",3,"ngClass"],["mat-row","","class","expanding",4,"matRowDef","matRowDefColumns"],["mat-row","",1,"expanding"],[1,"mat-row",3,"hidden"],[1,"mat-cell","no-data"],[3,"length","pageIndex","pageSize","page"]],template:function(t,e){if(1&t){var n=r.Vb();r.Ub(0,"mat-sidenav-container",0),r.Ub(1,"mat-sidenav",1,2),r.Ub(3,"crud-template-filter",3,4),r.bc("changed",function(t){return r.wc(n),r.uc(2).toggle(),e.refresh(t)}),r.Tb(),r.Tb(),r.Ub(5,"mat-sidenav-content",5),r.Ub(6,"div",6),r.Fc(7,Tt,6,8,"mat-toolbar",7),r.Fc(8,$t,8,5,"ng-template",null,8,r.Gc),r.Tb(),r.Ub(10,"div",9),r.Ub(11,"table",10),r.bc("matSortChange",function(t){return e.refresh(t)}),r.Fc(12,Yt,4,6,"ng-container",11),r.Sb(13,12),r.Fc(14,te,2,6,"td",13),r.Rb(),r.Fc(15,ee,1,0,"tr",14),r.Fc(16,ne,1,1,"tr",15),r.Fc(17,oe,2,2,"ng-container",16),r.Fc(18,ce,4,5,"tr",17),r.Tb(),r.Tb(),r.Fc(19,re,3,3,"div",18),r.Tb(),r.Tb()}if(2&t){var a=r.uc(9);r.Cb(3),r.lc("fields",e.filters),r.Cb(2),r.lc("loading",e.loading),r.Cb(2),r.lc("ngIf",e.selection.hasValue())("ngIfElse",a),r.Cb(4),r.lc("multiTemplateDataRows",e.rowExpandingTemplate)("dataSource",e.rows),r.Cb(1),r.lc("ngForOf",e.columns),r.Cb(3),r.lc("matHeaderRowDef",null==e.columns?null:e.columns.display)("matHeaderRowDefSticky",!0),r.Cb(1),r.lc("matRowDefColumns",null==e.columns?null:e.columns.display),r.Cb(1),r.lc("ngIf",e.rowExpandingTemplate),r.Cb(2),r.lc("ngIf",e.pageable)}},directives:[ot.b,ot.a,at,ot.c,ct.a,p.n,rt.k,lt.a,p.m,rt.c,rt.b,rt.g,rt.j,rt.h,st.a,p.s,g.a,ft.c,ut.a,dt.a,mt.e,mt.a,s.b,p.p,p.q,p.r,rt.e,rt.d,bt.a,rt.a,lt.b,p.o,rt.f,rt.i,p.l,pt.b],pipes:[y.d,p.v],styles:[".mat-sidenav-container[_ngcontent-%COMP%]{height:100%}.mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav[_ngcontent-%COMP%]{padding:24px;width:280px}.mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav-content[_ngcontent-%COMP%]{display:flex;flex-direction:column}.mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav-content[_ngcontent-%COMP%] .row-auto[_ngcontent-%COMP%]{flex:0 0 auto}.mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav-content[_ngcontent-%COMP%] .row-auto[_ngcontent-%COMP%] .mat-toolbar[_ngcontent-%COMP%] + .mat-divider[_ngcontent-%COMP%]{margin-top:-1px}.mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav-content[_ngcontent-%COMP%] .row-auto[_ngcontent-%COMP%] .mat-toolbar[_ngcontent-%COMP%] button:first-child{margin-left:-8px}.mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav-content[_ngcontent-%COMP%] .row-auto[_ngcontent-%COMP%] .mat-toolbar[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{font-size:14px}.mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav-content[_ngcontent-%COMP%] .row-auto[_ngcontent-%COMP%] .mat-toolbar[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:first-child{margin-left:8px}.mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav-content[_ngcontent-%COMP%] .row-auto[_ngcontent-%COMP%] .mat-toolbar[_ngcontent-%COMP%] .spacer[_ngcontent-%COMP%]{flex:1 1 auto}.mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav-content[_ngcontent-%COMP%] > .row-fill[_ngcontent-%COMP%]{flex:1 1 auto;overflow:auto}.mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav-content[_ngcontent-%COMP%] > .row-fill[_ngcontent-%COMP%] .mat-table[_ngcontent-%COMP%]{width:100%}.mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav-content[_ngcontent-%COMP%] > .row-fill[_ngcontent-%COMP%] .mat-table[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] td[_ngcontent-%COMP%], .mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav-content[_ngcontent-%COMP%] > .row-fill[_ngcontent-%COMP%] .mat-table[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{padding-right:56px;white-space:nowrap}.mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav-content[_ngcontent-%COMP%] > .row-fill[_ngcontent-%COMP%] .mat-table[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] td.no-data[_ngcontent-%COMP%], .mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav-content[_ngcontent-%COMP%] > .row-fill[_ngcontent-%COMP%] .mat-table[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] th.no-data[_ngcontent-%COMP%]{position:absolute;width:100%;height:48px;padding:0;text-align:center;line-height:48px}.mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav-content[_ngcontent-%COMP%] > .row-fill[_ngcontent-%COMP%] .mat-table[_ngcontent-%COMP%] tr.expanding[_ngcontent-%COMP%]{height:auto}.mat-sidenav-container[_ngcontent-%COMP%] .mat-sidenav-content[_ngcontent-%COMP%] > .row-fill[_ngcontent-%COMP%] .mat-table[_ngcontent-%COMP%] tr.expanding[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:0;border:none}"]}),le)}}])}();