cronapp-framework-js 3.0.0-SP.32 → 3.0.0-SP.33

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.
@@ -34,7 +34,12 @@ maskDirectiveAsDate.$inject=["$compile","$translate","$parse"],maskDirectiveMask
34
34
  </tbody>
35
35
  </table>
36
36
  </div>
37
- </div>`),a.sender.element.find(".k-scheduler-header.k-state-default").addClass("changed"))},r=a=>{let e=a.sender.element.find(".k-more-events.k-button.hooked").length;if(!e){let e=a.sender.view(),i=t.views.find(t=>t.type===e.name),o=app.common.generateId();a.sender.element.find(".k-more-events.k-button").attr("data-id",o);let d=generateBlocklyCall(i.moreEventsBlockly);d&&s(o,a=>{let e=$(a.currentTarget).prev(),i=e.data("uid"),o=t.refComponent.dataItems().find(e=>e.uid==i),l={scheduleData:{type:"seeAll",selectedDate:o.start}};n.$eval(d,l)}),a.sender.element.find(".k-more-events.k-button").addClass("hooked")}},s=(e,t)=>new Promise(a=>{let n=setInterval(()=>{let i=$(`[data-id="${e}"]`);if(i.length){clearInterval(n);let e="click";$(".km-pane-wrapper").length&&(e="touchstart"),i.off(e),i.on(e,a=>{t(a),a.stopImmediatePropagation()}),a()}},100)}),c=[];if(t.views)for(let e in t.views){let a=t.views[e];a.visible&&c.push(a)}else t.showDayTab&&c.push("day"),t.showAgendaTab&&c.push("agenda"),t.showMonthTab&&c.push("month"),t.showTimelineTab&&c.push("timeline"),t.showWeekTab&&c.push("week"),t.showWorkWeekTab&&c.push("workWeek");let p={dateHeaderTemplate:kendo.template(`#=kendo.toString(date, ${kendo.culture().name.toLowerCase().includes("pt")?"'ddd dd/M'":"'ddd M/dd'"})#`),showWorkHours:t.showWorkHours,selectable:!0,date:i,mobile:!1,allDaySlot:t.allDaySlot,messages:{editor:{timezone:$translate.instant("TimezoneEvent")}},currentTimeMarker:t.currentTimeMarker?{updateInterval:1e4,useLocalTimezone:!1}:t.currentTimeMarker,views:c,navigate:function(t){let e=t.sender.view()},dataBound:function(t){let e=t.sender.view();l(t),r(t)},eventTemplate:e=>{let a={scheduleData:e},i=t=>e.description?(t?" - ":"")+e.description:"",o=app.common.generateId(),d=t.refComponent.view().name,l=t.views.find(e=>e.type===d),r=[];r.push(`<div class='k-event-template' data-id='${o}'>`),"agenda"===d?(r.push(`<div class='k-event-title'>${e.title}</div>`),!l.showDescription||r.push(`<div class='k-event-description'>${i(!1)}</div>`)):r.push(`<div class='k-event-title'>${e.title}${l.showDescription?i(!0):""} </div>`),r.push("</div>");let c=generateBlocklyCall(l.blockly);return c&&s(o,()=>{n.$eval(c,a)}),r.join("")},change:t=>{t&&t.events&&t.events.length?this.setDatasourceActiveItem(a,t.events[0],"id"):a.startInserting({}),console.log("Active: ",a.active)},edit:function(a){if(t&&t.allowCustomAction){let e=a.container,i=t.customActionLabel?t.customActionLabel:$translate.instant("Details"),o=$("<a class=\"k-button\">"+i+"</a>");o.click(function(a){n.safeApply(()=>{n.$eval(generateBlocklyCall(t.customActionBlockly))})});let d=e.find(".k-edit-buttons");d.append(o)}},dataSource:{batch:!1,transport:{isComponentInDocument:function(e){return!!e&&$(document).has(e.element[0]).length},getCurrentCallbackForPush:function(e,t){return e||t},pushAction:function(e,n){return i=>{let o=["read","memorydelete","overRideRefresh"];if(this.isComponentInDocument(t.refComponent)){let a=this.getCurrentCallbackForPush(n,t.refComponent),o=a[e];o?o(i):(t.fromRead="read"===e,t.refComponent.dataSource.read())}else o.includes(e)||a.removeDataSourceEvents(this.options.dataSourceEventsPush)}},push:function(e){!this.dataSourceEventsPush&&a&&(this.dataSourceEventsPush={create:this.pushAction.bind(this)("pushUpdate",e),update:this.pushAction.bind(this)("pushUpdate",e),delete:this.pushAction.bind(this)("pushDestroy",e),read:this.pushAction.bind(this)("read",e),memorycreate:this.pushAction.bind(this)("pushUpdate",e),memoryupdate:this.pushAction.bind(this)("pushUpdate",e),memorydelete:this.pushAction.bind(this)("pushDestroy",e)},a.addDataSourceEvents(this.dataSourceEventsPush))},read:function(e){e.data=e.data||{};let n=!1;try{t.kendoCallback?t.fromRead?t.isReading?e.error():(t.isReading=!0,t.kendoCallback.success(a.data)):n=!0:(t.kendoCallback=e,n=!0)}finally{t.fromRead=!1,t.isReading=!1}if(n)if(d(e.data)){o=e.data,jQuery.isEmptyObject(e.data)&&(e.data[t.schedulerDataModel.start.name]=i);let n=kendo.data.transports.odata.parameterMap(e.data,"read"),d="",l={};l.params=n,a.fetch(l,{success:function(t){e.success(angular.copy(t))},canceled:function(t){e.error(angular.copy(t))}},!1)}else e.error()}.bind(this),update:e=>{let n=this.parseToDatasourceSchema(a,e.data,t);a.startEditing(a.active),this.mergeSchedulerEventWithDatasourceActive(a,n),a.update(a.active,t=>{let n=angular.copy(t);e.success(n),a.fetch({},{success:e=>{this.setDatasourceActiveItem(a,n,"id")},canceled:e=>{}},!1)},t=>{e.error(angular.copy(t))})},create:e=>{let n=this.parseToDatasourceSchema(a,e.data,t);this.mergeSchedulerEventWithDatasourceActive(a,n),a.insert(a.active,t=>{let n=angular.copy(t);e.success(n),a.fetch({},{success:e=>{this.setDatasourceActiveItem(a,n,"id")},canceled:function(e){}},!1)},t=>{e.error(angular.copy(t))})},destroy:function(e){a.removeSilent(this.parseToDatasourceSchema(a,e.data,t),function(t){e.success(angular.copy(t))},function(t){e.error(angular.copy(t))})}.bind(this)},schema:{model:this.getSchedulerModel(t.schedulerDataModel)}}};return t.views||(p.editable=t.editable),window.fixedTimeZone&&window.timeZone&&(p.timezone=window.timeZone),p},showError:function(e,t,a){let n={message:a,title:t,delay:null};e.Notification.error(n)},parseToDatasourceSchema:function(e,t,a){let n={};for(let i in e.schema){let a=e.schema[i].name;n[a]=t[a]}return n[a.schedulerDataModel.isAllDay.name]=!0===n[a.schedulerDataModel.isAllDay.name],n[a.schedulerDataModel.id.name]||delete n[a.schedulerDataModel.id.name],n},link:function(scope,element,attrs,ngModelCtrl){let datasource,schedulerElement=$("<div></div>"),options=JSON.parse(attrs.options||"{}");if(options.dataSourceScreen&&options.dataSourceScreen.entityDataSource&&(datasource=eval(options.dataSourceScreen.entityDataSource.name)),!datasource){let e={};return void $translate("DatasourceNotFoundMessage").then(t=>(e.message=t,$translate("Scheduler"))).then(t=>(e.component=t,$translate("DatasourceNotFoundTitle"))).then(t=>{e.title=t,this.showError(scope,e.title,e.message.replace("{0}",e.component))})}if(jQuery.isEmptyObject(options.schedulerDataModel))return;let baseUrl="node_modules/cronapp-lib-js/dist/js/kendo-ui/js/messages/kendo.messages.";baseUrl+="pt_br"===$translate.use()?"pt-BR.min.js":"en-US.min.js",this.initCulture(),$.getScript(baseUrl,async function(){function e(e,t){if(!e||!t)return;let a;return e.forEach((e,n)=>t.forEach(t=>{a=e.getTime()===t.getTime()})),a}let t=app.kendoHelper.getDataSource(options.dataSourceScreen.entityDataSource,scope,!0,options.dataSourceScreen.rowsPerPage),a=await this.getSchedulerProperties(options,datasource,scope);schedulerElement.kendoScheduler(a);let n=schedulerElement.data("kendoScheduler");options.refComponent=n;let i;n.bind("navigate",function(t){n._previousView=t.sender.view()}),n.bind("dataBound",function(t){if(n._currentView=t.sender.view(),n._previousView){let t=e(n._previousView._dates,n._currentView._dates);if(!t){let e={};e[options.schedulerDataModel.start.name]=n._currentView._startDate,e[options.schedulerDataModel.end.name]=n._currentView._endDate,n.dataSource.read(e),n._previousView=n._currentView}}})}.bind(this)),element.html(schedulerElement),$compile(schedulerElement)(element.scope())}}}]).directive("cronGrid",["$compile","$translate",function($compile,$translate){return{restrict:"E",replace:!0,require:"ngModel",initCulture:function(){var e=$translate.use();e=e.replace(/_/gm,"-");var t=e.split("-");t[t.length-1]=t[t.length-1].toUpperCase(),e=t.join("-"),kendo.culture(e)},changeObjectField:function(e,t){t=e.getKeyValues(t);var a=Object.keys(t);return 1===a.length&&(t=t[a]),t},removeSpecialChar:function(e){return e.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()},getModelName:function(e){return e?this.removeSpecialChar(e.ngModel):"subgrid"},generateToolbarButtonCall:function(toolbarButton,scope,options,attrs){var buttonCall,generateObjTemplate=function(e,t,a){var n={template:function(){return createTemplateButton(e,t,a)}.bind(this)};return n}.bind(this),createTemplateButton=function(functionToCall,title,iconClass){var template="";let security=toolbarButton.security?`cronapp-security="${toolbarButton.security}"`:"",modelName=this.getModelName(attrs),buttonType=this.removeSpecialChar(toolbarButton.type),buttonDesc=toolbarButton.title?this.removeSpecialChar(toolbarButton.title):this.removeSpecialChar(toolbarButton.iconClass),buttonId=`${modelName}-${buttonType}-${buttonDesc}`;"SaveOrCancelChanges"==toolbarButton.type?toolbarButton.saveButton?template="<a #SECURITY# role=\"button\" class=\"saveorcancelchanges k-button k-button-icontext k-grid-save-changes\" data-id=\"#BUTTONID#\" href=\"javascript:void(0)\"><span class=\"k-icon k-i-check\"></span>#TITLE#</a>":template="<a #SECURITY# role=\"button\" class=\"saveorcancelchanges k-button k-button-icontext k-grid-cancel-changes\" data-id=\"#BUTTONID#\" href=\"javascript:void(0)\"><span class=\"k-icon k-i-cancel\" ></span>#TITLE#</a>":"Blockly"==toolbarButton.type||"Customized"==toolbarButton.type?template="<a #SECURITY# class=\"k-button k-grid-custom\" data-id=\"#BUTTONID#\" href=\"javascript:void(0)\"><span class=\"#ICONCLASS#\" ></span>#TITLE#</a>":"Native"==toolbarButton.type&&"create"==toolbarButton.title?template="<a #SECURITY# role=\"button\" data-id=\"#BUTTONID#\" class=\"k-button k-button-icontext k-grid-add\" href=\"javascript:void(0)\"><span class=\"k-icon k-i-plus\"></span>{{\"Add\" | translate}}</a>":"Native"==toolbarButton.type&&"excel"==toolbarButton.title?template="<a #SECURITY# role=\"button\" data-id=\"#BUTTONID#\" class=\"k-button k-button-icontext k-grid-excel\" href=\"javascript:void(0)\"><span class=\"k-icon k-i-file-excel\"></span>{{\"exportExcel\" | translate}}</a>":"Native"==toolbarButton.type&&"pdf"==toolbarButton.title&&(template="<a #SECURITY# role=\"button\" data-id=\"#BUTTONID#\" class=\"k-button k-button-icontext k-grid-pdf\" href=\"javascript:void(0)\"><span class=\"k-icon k-i-file-pdf\"></span>{{\"exportPDF\" | translate}}</a>"),template=template.split("#BUTTONID#").join(buttonId).split("#FUNCTIONCALL#").join(this.encodeHTML(functionToCall)).split("#TITLE#").join(title).split("#ICONCLASS#").join(iconClass).split("#SECURITY#").join(security);var cronappDatasource=eval(options.dataSourceScreen.entityDataSource.name),waitRender=setInterval(function(){0<$(`[data-id=${buttonId}]`).length&&(scope.safeApply(function(){var e=angular.element($(`[data-id=${buttonId}]`));$compile(e)(scope),$(`[data-id=${buttonId}]`).attr("id",buttonId)}),$(`[data-id=${buttonId}]`).click(function(){var e=options.refComponent,t=[];e.select().each(function(){var a=e.dataItem(this);cronappDatasource.data.forEach(function(e){e.__$id==a.__$id&&t.push(e)})});var a={item:t.length?cronappDatasource.active:null,index:t.length?cronappDatasource.cursor:null};let n=[];options.fieldType&&"key"===options.fieldType?t.forEach(e=>{n.push(this.changeObjectField(cronappDatasource,cronappDatasource.findObjInDs(e)))}):n=t;var i={currentData:cronappDatasource.data,datasource:cronappDatasource.copyWithoutAngularObj(),selectedIndex:t.length?cronappDatasource.cursor:null,index:t.length?cronappDatasource.cursor:null,selectedRow:t.length?cronappDatasource.active:null,consolidated:a,item:t.length?cronappDatasource.active:null,selectedKeys:t.length?cronappDatasource.getKeyValues(cronappDatasource.findObjInDs(t[0]),!0):null,selectedRows:n};scope.$eval(functionToCall,i)}.bind(this)),clearInterval(waitRender))}.bind(this),200);return template}.bind(this),call="";call="Customized"==toolbarButton.type?toolbarButton.execute:toolbarButton.methodCall?toolbarButton.methodCall:generateBlocklyCall(toolbarButton.blocklyInfo);var title=null==toolbarButton.title?"":toolbarButton.title;return buttonCall=generateObjTemplate(call,title,toolbarButton.iconClass),buttonCall},generateModalSaveOrCancelButtonCall:function(e,t,a,n,i){var o=app.common.generateId(),d=function(e,t,a,n){var d;d="save"==e?"<button id=\"#BUTTONID#\" aria-label=\"#ARIALABELSAVE#\" class=\"btn btn-primary btn-fab ng-binding grid-save-button-modal k-button\" data-component=\"crn-button\" ng-click=\"#FUNCTIONCALL#\" onclick=\"(!#DATASOURCENAME#.missingRequiredField(true)?$('##MODALID#').modal('hide'):void(0))\"><span class=\"k-icon k-i-check\"></span></button>":"saveAdd"==e?"<button id=\"#BUTTONID#\" aria-label=\"#ARIALABELSAVEADD#\" class=\"btn btn-primary btn-fab ng-binding grid-save-add-button-modal k-button\" data-component=\"crn-button\" ng-click=\"#FUNCTIONCALL#\"><span class=\"k-icon k-i-plus\"></span></button>":"<button id=\"#BUTTONID#\" aria-label=\"#ARIALABELCANCEL#\" type=\"button\" class=\"btn btn-default btn-fab ng-binding k-button\" data-component=\"crn-button\" data-dismiss=\"modal\"><span class=\"k-icon k-i-cancel\"></span></button>",d=d.split("#BUTTONID#").join(o).split("#FUNCTIONCALL#").join(t).split("#DATASOURCENAME#").join(a).split("#ARIALABELSAVE#").join($translate.instant("SaveChanges")).split("#ARIALABELSAVEADD#").join($translate.instant("SaveAddChanges")).split("#ARIALABELCANCEL#").join($translate.instant("CancelChanges")).split("#MODALID#").join(n);var l=setInterval(function(){0<$("#"+o).length&&i.safeApply(function(){var e=angular.element($("#"+o));$compile(e)(i),clearInterval(l)})},200);return d};return buttonCall=d(e,t,a,n),buttonCall},addButtonsInModal:function(e,t,a,n){var i=$("#"+e).find(".modal-footer");if(!i.find(".grid-save-button-modal").length){var o=t+".post();",d=this.generateModalSaveOrCancelButtonCall("save",o,t,e,a);if(i.append(d),n){let n=this.generateModalSaveOrCancelButtonCall("saveAdd",o+t+".startInserting();",t,e,a);i.append(n)}var l=this.generateModalSaveOrCancelButtonCall("cancel",null,null,null,a);i.append(l)}},getObjectId:function(e){if(!e)e="";else if(e instanceof Date){var t=moment.utc(e);e=new Date(t.format("YYYY-MM-DDTHH:mm:ss"))}else if("object"==typeof e)if(e.id)e=e.id;else for(var a in e){e=e[a];break}return e},encodeHTML:function(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")},decodeHTML:function(e){return e.replace(/&apos;/g,"'").replace(/&quot;/g,"\"").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")},getColumnByField:function(e,t){var a=null;return e.columns.forEach(function(e){e.field==t&&(a=e)}),a},resizeGridUsingWidthForDevice:function(e){for(let t,a=0;a<e.columns.length;a++)t=this.getWidthForDevice(e.columns[a]),e.columns[a].width=t.width,t.visible?e.showColumn(a):e.hideColumn(a);if(e.options.hasSecurity){let t=$(e.element.find("col")).last();t.css("width","0px")}},getWidthForDevice:function(e){let t=1210,a=1002,n=778,i=424,o=$(window).width(),d=function(t){let a;return e.widthDevices.forEach(e=>{e.device===t&&(a=e)}),void 0===a&&("deviceSmall"===t?a=d("deviceMedium"):"deviceMedium"===t?a=d("deviceDesktop"):"deviceDesktop"===t?a=d("deviceBig"):a=e.widthDevices[0]),a},l={width:e.width};return l.visible=void 0!==e.visible&&null!==e.visible?e.visible:!e.hidden,null!==e.widthDevices&&void 0!==e.widthDevices&&0<e.widthDevices.length&&(1210<=o?l=d("deviceBig"):o>=a&&1210>o?l=d("deviceDesktop"):o>=n&&o<a?l=d("deviceMedium"):l=d("deviceSmall")),l},getColumns:function(options,datasource,scope,tooltips,attrs){function getTemplate(column){var template="#=showTreatedValue("+column.field+")#";return"switch"==column.inputType?template="<span class=\"k-switch km-switch k-widget km-widget k-switch-off km-switch-off\" style=\"width: 100%\"> <span class=\"k-switch-wrapper km-switch-wrapper\"> <span class=\"k-switch-background km-switch-background\" style=\"margin-left: #="+column.field+" ? \"80%\": \"0%\" #\"></span> </span> <span class=\"k-switch-container km-switch-container\"> <span class=\"k-switch-handle km-switch-handle\" style=#="+column.field+" ? \"float:right;margin-right:-1px\": \"margin-left:0%\" #> </span> </span> </span>":"checkbox"==column.inputType||"boolean"==column.type?template="<input crn-set-indeterminate=#="+column.field+"# type='checkbox' class='k-checkbox' #="+column.field+" ? \"checked='checked'\": '' # /><label class='k-checkbox-label k-no-text'></label>":column.displayField&&0<column.displayField.length?hasMask(column.type)||column.format&&"null"!=column.format?template="#= useMask("+column.displayField+",'"+column.format+"','"+column.type+"') #":template="#="+column.displayField+"#":hasMask(column.type)||column.format&&"null"!=column.format?template="#= useMask("+column.field+",'"+column.format+"','"+column.type+"') #":column.showAsImage&&(template=column.showAsImageTemplate?column.showAsImageTemplate:"<img src='#:${column.field}#'/>",template=eval("`"+template+"`")),template}function hasMask(e){return!!(e&&"string"==typeof e)&&(e.startsWith("date")||e.startsWith("month")||e.startsWith("time")||e.startsWith("week")||e.startsWith("money")||e.startsWith("number")||e.startsWith("tel")||e.startsWith("integer"))}function getFormat(e){return hasMask(e.type)?void 0:e.format}function isRequired(e){var t=!1,a=null;return datasource.schema.model.fields[e]&&(a=datasource.schema.model.fields[e]),a&&(t=!a.nullable),t}function getEditor(e){return editor.bind(this)}async function editor(e,t){let a=e=>new Promise((t,a)=>{let n=setInterval(function(){let a=$("#"+e);if(0<a.length){let i=a.closest("td"),o=angular.element(i||a);$compile(o)(scope),clearInterval(n),t(e)}},10)}),n=e=>{e!==t.model[t.field]&&(t.model[t.field]=e,t.model.dirty=!0,t.model.dirtyFields[t.field]=!0)};var i=this.getColumnByField(options,t.field);null==i.visibleCrud||i.visibleCrud||(e.parent().find(".k-edit-label [for="+i.field+"]").parent().remove(),e.remove());var o=isRequired(t.field)?"required":"",d=app.common.generateId();let l=`${options.dataSourceScreen.name}.active.${t.field}`;var r=$(`<input ${o} name="${t.field}" id="${d}" from-grid=true ng-model="${l}" />`);if(r.data("change-grid-model",n),r.data("column-type",i.type),"dynamicComboBox"==i.inputType||"comboBox"==i.inputType){var s=app.kendoHelper.getConfigComboboxSync(i.comboboxOptions,scope);s.autoBind=!0,s.optionLabel=void 0,i.displayField&&(s.change=function(a){t.model.set(i.displayField,this.text()),t.model.dirty=!0,t.model.dirtyFields[i.displayField]=!0});let a=r.appendTo(e).kendoDropDownList(s,scope).data("kendoDropDownList");r.data("kendoDropDownList",a)}else if("slider"==i.inputType){var s=app.kendoHelper.getConfigSlider(i.sliderOptions);s.change=t=>scope.$apply(()=>scope.$eval(`${l}=${t.value}`));let t=r.appendTo(e).kendoSlider(s,scope).data("kendoSlider");r.data("kendoSlider",t)}else if("switch"==i.inputType){var s=app.kendoHelper.getConfigSwitch(i.switchOptions);r.appendTo(e).kendoMobileSwitch(s,scope)}else"checkbox"==i.inputType||"boolean"==i.type?(r=$(`<input id="${d}" name="${t.field}" ng-false-value="false" ng-true-value="true" crn-allow-null-values="${!o}" class="k-checkbox" type="checkbox" from-grid=true ng-model="${l}"><label class="k-checkbox-label" for="${d}"></label>`),r.data("change-grid-model",n),r.appendTo(e)):"date"==i.inputType?(r.attr("cron-date",""),r.attr("options",JSON.stringify(i.dateOptions)),r.data("initial-date",t.model[t.field]),r.attr("type","datetime"),r.appendTo(e).off("change")):(r.attr("type",i.type),r.attr("mask",i.format?i.format:""),("999.999.999-99;0"===i.format||"99.999.999/9999-99;0"===i.format)&&(r.attr("valid","999.999.999-99;0"===i.format?"cpf":"cnpj"),r.attr("data-"+i.field.toLocaleLowerCase()+"validation-msg",$translate.instant("invalid."+r.attr("valid")))),r.css("text-align",i.alignment),r.attr("class","k-input k-textbox"),r.data("initial-value",t.model[t.field]),r.appendTo(e));a(d).then(e=>{$(`#${e}`).data("alreadycompiled",!0),$(`#${e}`).data("$compile",$compile),$(`#${e}`).data("ref-component",options.refComponent)})}function setIdCommandButton(e,t){let a=setInterval(()=>{if($(`.k-grid-${e}`).is(":visible")){clearInterval(a);var n=options.refComponent;$(`.k-grid-${e}`).each((e,a)=>{let i=$(a);if(!i.attr("id")){let e=n.dataItem(i.closest("tr")),a=this.getModelName(attrs),o=e._objectKey,d=`${a}-${t}-${o}`;i.attr("id",d)}})}},200)}function getCommandForEditButtonDatabase(e,t){var a;let n=app.common.generateId(),i=$translate.instant("Edit"),o=`<a href class='k-button k-grid-edit k-grid-${n}' aria-label='${i}'><span class='k-icon k-i-edit'></span></a>`;return a="popupCustom"==e.editable||"datasource"==e.editable?{name:n,template:o,click:function(t){t.preventDefault();var a=$(t.target).closest("tr"),n=a.closest("table"),i=this.dataItem(a),o=this.dataSource.transport.options.cronappDatasource;scope.safeApply(function(){options.hideModalButtons||helperDirective.addButtonsInModal(options.popupEdit,o.name,scope,!1);var t=o.goTo(i);o.startEditing(t,function(e){}),"datasource"==e.editable?cronapi.internal.focusFormInput():cronapi.screen.showModal(options.popupEdit)})}}:{name:t,template:o,text:{edit:" ",update:" ",cancel:" "}},setIdCommandButton.bind(this)(n,t),a}function getCommandForRemoveButtonDatabase(e,t){var a;let n=app.common.generateId(),i=$translate.instant("Remove"),o=`<a href class='k-button k-grid-delete k-grid-${n}' aria-label='${i}'><span class='k-icon k-i-close'></span></a>`;return a="popupCustom"==e.editable||"datasource"==e.editable?{name:n,template:o,click:function(t){t.preventDefault();var e=$(t.target).closest("tr"),a=this.dataItem(e),n=this.dataSource.transport.options.cronappDatasource,i=this;scope.safeApply(function(){var e=n.goTo(a);n.remove(e)})}}:{name:t,template:o},setIdCommandButton.bind(this)(n,t),a}function getAggregate(e){if(e&&e.aggregates){var t=[];if(e.aggregates.forEach(function(e){t.push(e.type)}),0<t.length)return t}}function getAggregateFooter(e,t){if(e&&e.aggregates){var n=[];return e.aggregates.forEach(function(i){var a="#=data."+e.field+" ? data."+e.field+"."+i.type+" : 0 #";("average"==i.type||"sum"==i.type)&&(a="#=useMask(data."+e.field+" ? data."+e.field+"."+i.type+" : 0,'"+e.format+"','"+e.type+"')#");var o=t?i.groupFooterTemplate:i.footerTemplate;o?o+=": ":o="";var d=o+a;e.alignment&&("right"!==e.alignment||t?d="<div style=\"text-align: "+e.alignment+"\">"+d+"</div>":d="<div style=\"text-align: "+e.alignment+"\" class=\"k-fix-margin\">"+d+"</div>"),n.push(d)}),n.join("<br/>")}}function getAggregateHeader(e){return hasMask(e.type)||e.format&&"null"!=e.format?e.headerText+": #=useMask(value,'"+e.format+"','"+e.type+"')#":void 0}function getAttributes(e){let t={};return e&&(e.alignment&&(t.style="text-align: "+e.alignment+";"),e.security&&(t["cronapp-security"]=e.security)),t}var helperDirective=this,columns=[];return options.columns&&options.columns.forEach(function(t){let a=this.getWidthForDevice(t);if("Database"==t.dataType){var n={field:t.field,title:t.headerText,type:t.type,width:a.width,sortable:t.sortable,filterable:t.filterable,hidden:!a.visible};n.template=getTemplate(t),n.format=getFormat(t),n.editor=getEditor.bind(this)(t),n.aggregates=getAggregate(t),n.footerTemplate=getAggregateFooter(t,!1),n.groupFooterTemplate=getAggregateFooter(t,!0),n.groupHeaderTemplate=getAggregateHeader(t),n.attributes=getAttributes(t),n.headerAttributes=n.attributes,n.widthDevices=t.widthDevices,columns.push(n)}else if("Command"==t.dataType){if("no"!=options.editable){var i=t.command.split("|"),o=[];i.forEach(function(e){var t;t="edit"==e?getCommandForEditButtonDatabase.bind(this)(options,e):getCommandForRemoveButtonDatabase.bind(this)(options,e),o.push(t)}.bind(this));var n={command:o,title:t.headerText,width:a.width?a.width:155,hidden:!a.visible,attributes:getAttributes(t)};columns.push(n)}}else if("Blockly"==t.dataType||"Customized"==t.dataType||"CustomizedLink"==t.dataType){var d=null==t.label?"":t.label;t.iconClass&&d&&(d="&nbsp;"+d);var l="";l="CustomizedLink"==t.dataType?"k-custom-link":"k-custom-command"+(d?" k-button-with-label":""),t.theme&&(l+=" "+t.theme);var r="";if(t.tooltip&&t.tooltip.length&&(r=t.tooltip),r){var s=app.common.generateId();tooltips[s]=r,l+=" "+s}let e=app.common.generateId(),i=r||d||e,o=`<a href class='k-button ${l} k-grid-${e}' aria-label='${i}'><span class='${t.iconClass}'></span>${d}</a>`;var n={command:[{name:e,template:o,click:function(a){a.preventDefault();var e=$(a.target).closest("tr"),n=e.closest("table"),i=this.dataItem(e),o=this.dataItem(e),d=$(n.find("tbody")[0]).children().index(e),l=void 0;l="Customized"==t.dataType||"CustomizedLink"==t.dataType?t.execute:generateBlocklyCall(t.blocklyInfo);var r=this.dataSource.transport.options.cronappDatasource,s=options.refComponent,c=[];if(s.select().each(function(){var e=s.dataItem(this);r.data.forEach(function(t){t.__$id==e.__$id&&c.push(t)})}),!(r.inserting||r.editing)){var e=a.currentTarget.parentElement.parentElement;this.select(e)}let p=[];options.fieldType&&"key"===options.fieldType?(o=helperDirective.changeObjectField(r,r.findObjInDs(o)),c.forEach(e=>{p.push(helperDirective.changeObjectField(r,r.findObjInDs(e)))})):p=c;var u={item:o,index:d},m={currentData:r.data,datasource:r.copyWithoutAngularObj(),selectedIndex:d,index:d,selectedRow:o,consolidated:u,item:o,selectedKeys:r.getKeyValues(r.findObjInDs(i),!0),selectedRows:p};return r.goTo(i),void scope.$eval(l,m)}}],width:a.width,title:t.headerText?t.headerText:"",hidden:!a.visible,attributes:getAttributes(t)};columns.push(n),setIdCommandButton.bind(this)(e,t.dataType)}else if("Selectable"==t.dataType){var c={selectable:!0,attributes:getAttributes(t)};columns.push(c)}}.bind(this)),columns},getPageAble:function(e){var t={refresh:e.allowRefreshGrid,pageSizes:e.allowSelectionTotalPageToShow,buttonCount:5};return e.allowPaging||(t=e.allowPaging),t},getToolbar:function(e,t,a){function n(e){let t=e.security?`cronapp-security="${e.security}" class`:"class";e.template&&(e.template=e.template.split("class").join(t));let a={template:e.template};return a}var i=[];return e.toolBarButtons.forEach(function(o){if("Native"==o.type){if("no"==e.editable)("pdf"==o.title||"excel"==o.title)&&i.push(o.title);else if(("datasource"==e.editable||"popupCustom"==e.editable)&&"create"==o.title){var d=e.dataSourceScreen.name,l=e.popupInsert;o.methodCall=d+".startInserting();","popupCustom"==e.editable?o.methodCall=o.methodCall+" cronapi.screen.showModal('"+l+"');":o.methodCall+="cronapi.internal.focusFormInput();";var r=this.generateToolbarButtonCall(o,t,e,a);i.push(r),e.hideModalButtons||this.addButtonsInModal(l,d,t,e.enableModalSaveAdd)}else{let n=this.generateToolbarButtonCall(o,t,e,a);i.push(n)}}else if("Blockly"==o.type||"Customized"==o.type){var s=this.generateToolbarButtonCall(o,t,e,a);i.push(s)}else if("SaveOrCancelChanges"==o.type){if("no"!=e.editable){var c=this.generateToolbarButtonCall(o,t,e,a);i.push(c)}}else if("Template"==o.type||"Title"==o.type){let e=n(o);i.push(e)}}.bind(this)),0==i.length&&(i=void 0),i},getEditable:function(e){var t={mode:e.editable,confirmation:!1};return"batch"==e.editable?t=!0:("no"==e.editable||"popupCustom"==e.editable||"datasource"==e.editable)&&(t=!1),t},getTooltipsDefault:function(){var e={k_grid_edit:$translate.instant("Edit"),k_grid_delete:$translate.instant("Remove"),k_grid_update:$translate.instant("Save"),k_grid_cancel:$translate.instant("Cancel")};return e},setTooltips:function(e,t){for(var a in t){var n="."+a.replace(/_/g,"-");e.kendoTooltip({filter:n,content:function(a){var e=a.sender.options.filter.substr(1).replace(/-/g,"_");return t[e]}})}},generateKendoGridInit:function(t,a,n,i,o){function d(n){if(n.masterRow.find("a").hasClass("k-i-expand"))return void s(this,n.detailRow,n.masterRow);var e=this.dataSource.transport.options.cronappDatasource;e.inserting||e.editing?r(this,null,null):(this.selectable?(c.bind(this)(n.data),this.select(n.masterRow),void 0!==t.columns.find(e=>"Selectable"==e.dataType)&&r(this,n.detailRow,n.masterRow)):(c.bind(this)(n.data),r(this,n.detailRow,n.masterRow)),n.sender.options.listCurrentOptions.forEach(function(e){var t=l.generateKendoGridInit(e,a,void 0,void 0,o),i=$("<div/>"),d=i.appendTo(n.detailCell).kendoGrid(t).data("kendoGrid");app.kendoHelper.receivePushData(d),e.refComponent=d,window.addEventListener("resize",()=>{l.resizeGridUsingWidthForDevice(d)}),l.setTooltips(i,o)}))}var l=this,r=function(e,t,a){var n=e.table.find(".k-master-row");n.each(function(){(null==a||this!=a[0])&&e.collapseRow(this)});var i=e.table.find(".k-detail-row");i.each(function(){(null==t||this!=t[0])&&$(this).remove()})},s=function(e,t,a){var n=e.table.find(".k-master-row");n.each(function(){(null!=a||this==a[0])&&e.collapseRow(this)});var i=e.table.find(".k-detail-row");i.each(function(){(null!=t||this==t[0])&&$(this).remove()})},c=function(e){var t=this.dataSource.transport.options.cronappDatasource;t.inserting||t.editing||a.safeApply(t.goTo(e))},p=function(n){if(n.sender.tbody&&n.sender.tbody.length){var e=n.sender.tbody;$(n.sender.tbody).find(".k-grid-edit-row").length?e=$(n.sender.tbody).find("tr:not(.k-grid-edit-row)"):e.parent()&&e.parent().parent()&&e.parent().parent().parent()&&(e=e.parent().parent().parent()),a.safeApply(function(){var n=$(e),i=angular.element(n);$compile(i)(a),t.refComponent&&l.resizeGridUsingWidthForDevice(t.refComponent)})}},u=function(e){var t=!1;if(e.columns)for(var a=0;a<e.columns.length;a++)if("Database"==e.columns[a].dataType&&e.columns[a].filterable){t=!0;break}return t},m=function(e){var a,n=0;return t.columns.forEach(function(t){"Database"==t.dataType&&(n==e&&t.visible&&(a=t),t.visible&&n++)}),a},g=function(t){let e=t.workbook.sheets[0],n=/{{(.*?)}}/;for(let i,o=1;o<e.rows.length;o++){i=e.rows[o];for(let e,t=0;t<i.cells.length;t++){if(e=m(t),e&&i.cells[t].value instanceof Date){let a=new Date(i.cells[t].value.getTime());a.setMinutes(a.getMinutes()+a.getTimezoneOffset()),a.setSeconds(a.getSeconds()),i.cells[t].value=a,"time"==e.type?i.cells[t].format="[$-x-systime]hh:mm:ss":"datetime"==e.type&&(i.cells[t].format="dd/mm/yyyy hh:mm:ss;@")}if(("footer"===i.type||"group-footer"===i.type)&&i.cells[t].value){let e=i.cells[t].value,o=$(e)[0].innerHTML,d=n.exec(o);if(d&&1<d.length){o=o.replace(d[0],"");let e=a.$eval(d[1]);i.cells[t].value=`${o}${e}`}}}}},f=app.kendoHelper.getDataSource(t.dataSourceScreen.entityDataSource,a,t.allowPaging,t.pageCount,t.columns,t.groupings),h=this.getColumns(t,f,a,o,i),v=this.getPageAble(t),b=this.getToolbar(t,a,i),y=this.getEditable(t),k=u(t),C={hasSecurity:t.columns.filter(e=>e.security).length,toolbar:b,pdf:{allPages:!0,avoidLinks:!0,paperSize:"A4",margin:{top:"2cm",left:"1cm",right:"1cm",bottom:"1cm"},landscape:!0,repeatHeaders:!0,scale:.8},dataSource:f,editable:y,height:t.height,groupable:t.allowGrouping,sortable:t.allowSorting,filterable:!0,pageable:v,columns:h,selectable:t.allowSelectionRow,detailInit:t.details&&0<t.details.length?d:void 0,listCurrentOptions:t.details&&0<t.details.length?t.details:void 0,excelExport:g,edit:function(t){this.dataSource.transport.options.disableAndSelect(t);var e=t.container,n=this.dataSource.transport.options.cronappDatasource;if(t.model.isNew()){var o=t.model;n.startInserting(null,function(t){for(var a in t)if(o.fields[a]){if(o.fields[a].validation&&o.fields[a].validation.required){var n=e.find("input[name='"+a+"']");n.length&&n.val(t[a]).trigger("change")}o.set(a,t[a])}})}else t.model.isNew()||t.model.dirty||a.safeApply(function(){var e=n.goTo(t.model);n.startEditing(e,function(e){})});i&&i.ngEdit&&a.$eval(i.ngEdit),p(t)},change:function(o){var e=this.dataItem(this.select());(t.details&&0==t.details.length||!cronapi.internal.hasMethodInCallStack("detailInit"))&&c.bind(this)(e);var d=this.dataSource.transport.options.cronappDatasource;t.fieldType&&"key"===t.fieldType&&(d.active=l.changeObjectField(d,d.active));let s=this.select().next(),u=this.select();if(n)if("multiple"===t.allowSelectionRowType){let e=[];s=[],u=[],this.select().each((a,n)=>{let i=this.dataItem(n),o=d.findObjInDs(i,!1);t.fieldType&&"key"===t.fieldType&&(o=l.changeObjectField(d,o)),null!==o&&e.push(o),i._objectKey===d.active._objectKey&&(u.push(this.select()[a]),s.push(this.select().next()[a]))}),n.$setViewValue(e)}else e?n.$setViewValue(d.active):n.$setViewValue(null);r(this,s,u),i&&i.ngChange&&a.$eval(i.ngChange),p(o),$(".k-command-cell a[class*='k-grid-']").each((e,t)=>{let a=$(t);if(!a.attr("id")){let e=this.dataItem(a.closest("tr")),t="destroy";a.hasClass("k-grid-update")?t="update":a.hasClass("k-grid-cancel")?t="cancel":a.hasClass("k-grid-edit")&&(t="edit");let n=l.getModelName(i);if(e&&e._objectKey){let i=e._objectKey,o=`${n}-${t}-${i}`;a.attr("id",o)}}})},cancel:function(t){var e=this.dataSource.transport.options.cronappDatasource;a.safeApply(e.cancel()),this.dataSource.transport.options.enableAndSelect(t),setTimeout(function(){i&&i.ngCancel&&a.$eval(i.ngCancel),p(t)}.bind(this))},dataBound:function(n){setTimeout(()=>this.dataSource.transport.options.selectActiveInGrid(),100),i&&i.ngDataBound&&a.$eval(i.ngDataBound);for(let e,a=0;a<this.columns.length;a++)e=l.getColumnByField(t,this.columns[a].field),e.visible&&this.showColumn(a);0==$("div.k-grouping-header").length?t.groupings&&t.groupings.forEach(e=>this.hideColumn(e.field)):$("div.k-group-indicator").each((e,t)=>{this.hideColumn($(t).data("field"))});let e=this;setTimeout(function(){e.pager&&e.pager.element.find("a").not(".k-state-disabled").attr("tabindex","0")}),p(n)}};return C.selectable&&"multiple"==t.allowSelectionRowType&&(C.selectable="multiple"),C.originalSelectable=C.selectable,i&&i.ngBeforeEdit&&(C.beforeEdit=function(t){a.$eval(i.ngBeforeEdit)}),i&&i.ngDataBinding&&(C.dataBinding=function(t){a.$eval(i.ngDataBinding)}),i&&i.ngSave&&(C.save=function(t){a.$eval(i.ngSave)}),i&&i.ngSaveChanges&&(C.saveChanges=function(t){a.$eval(i.ngSaveChanges)}),i&&i.ngRemove&&(C.remove=function(t){a.$eval(i.ngRemove)}),C},link:function(e,t,a,n){if(!t.children().length){var i=$("<div></div>"),o="node_modules/cronapp-lib-js/dist/js/kendo-ui/js/messages/kendo.messages.";o+="pt_br"==$translate.use()?"pt-BR.min.js":"en-US.min.js",this.initCulture();var d=this;$.getScript(o,function(){var t=JSON.parse(a.options||"{}");app.kendoHelper.getCorrectlyDS(t.dataSourceScreen.entityDataSource.name,e).batchPost=!1;var o=null==t.batchMode||t.batchMode;o&&"datasource"!=t.editable&&app.kendoHelper.getCorrectlyDS(t.dataSourceScreen.entityDataSource.name,e)&&!app.kendoHelper.getCorrectlyDS(t.dataSourceScreen.entityDataSource.name,e).dependentLazyPost&&(app.kendoHelper.getCorrectlyDS(t.dataSourceScreen.entityDataSource.name,e).batchPost=!0,t.toolBarButtons=t.toolBarButtons||[],t.toolBarButtons.push({type:"SaveOrCancelChanges",title:$translate.instant("SaveChanges"),methodCall:t.dataSourceScreen.entityDataSource.name+".postBatchData()",saveButton:!0}),t.toolBarButtons.push({type:"SaveOrCancelChanges",title:$translate.instant("CancelChanges"),methodCall:t.dataSourceScreen.entityDataSource.name+".cancelBatchData()",saveButton:!1}));var l=d.getTooltipsDefault(),r=d.generateKendoGridInit(t,e,n,a,l);r.scrollable="true"===a.scrollable;var s=i.kendoGrid(r).data("kendoGrid");app.kendoHelper.receivePushData(s),t.refComponent=s,window.addEventListener("resize",()=>{d.resizeGridUsingWidthForDevice(s)}),d.setTooltips(i,l),e.safeApply(function(){app.kendoHelper.getCorrectlyDS(t.dataSourceScreen.entityDataSource.name,e)&&(i.find(".k-filter-row").show(),i.find(".k-pager-sizes").show(),i.find(".k-pager-nav").show(),i.find(".k-pager-numbers").show(),i.find(".k-pager-refresh.k-link").show(),i.find(".saveorcancelchanges").hide(),app.kendoHelper.getCorrectlyDS(t.dataSourceScreen.entityDataSource.name,e).addDataSourceEvents({pendingchanges:function(e){e?(i.find(".k-filter-row").hide(),i.find(".k-pager-sizes").hide(),i.find(".k-pager-nav").hide(),i.find(".k-pager-numbers").hide(),i.find(".k-pager-refresh.k-link").hide(),i.find(".saveorcancelchanges").show()):(i.find(".k-filter-row").show(),i.find(".k-pager-sizes").show(),i.find(".k-pager-nav").show(),i.find(".k-pager-numbers").show(),i.find(".k-pager-refresh.k-link").show(),i.find(".saveorcancelchanges").hide())}}),app.kendoHelper.getCorrectlyDS(t.dataSourceScreen.entityDataSource.name,e).addDataSourceEvents({afterchanges:function(e){}}))})}),t.html(i),$compile(i)(t.scope())}}}}]).directive("src",["$compile",function(e){return{restrict:"A",link:function(e,t,a,n){"IMG"===t[0].tagName&&cronapi.internal.isBase64(a.src)&&setTimeout(()=>$(t[0]).attr("src","data:image/png;base64,"+a.src))}}}]).directive("crnSkin",["$compile","$http",function(e,t){return{restrict:"A",link:function(e,a,n,i){n.crnSkin&&t.get(n.crnSkin,{cache:!0}).then(e=>{if(e.data){let t=e.data;t.startsWith(":root{")&&(t=t.substring(6)),t.endsWith("}")&&(t=t.substring(0,t.length-2)),$element=$(a);let n=$element.find("[data-role=\"grid\"]");n.length&&($element=n);let i=$element.attr("style")||"";i&&(i+=", "),i+=t,$element.attr("style",i)}})}}}]).directive("cronTreeView",["$compile","$translate",function($compile,$translate){return{restrict:"E",replace:!0,require:"ngModel",scope:!0,getDataSource:function(options,scope,ngModelCtrl){let id=options.dataSourceScreen.schema.filter(e=>!0===e.key)[0].name,schema={model:{id:id,hasChildren:function(e){return e.hasChildren}}},getAllParent=function(e,t,a,n,i){t[schema.model.id]&&a.push(t[schema.model.id]);let o=`${e.entity}?$filter=${schema.model.id} eq '${t[options.selfRelationshipField]}'&$format=json&$inlinecount=allpages`;t[options.selfRelationshipField]?$.ajax({url:o,success:t=>{getAllParent(e,t.d.results[0],a,n,i)},beforeSend:e=>{window.isUsingCookie()||e.setRequestHeader("X-AUTH-TOKEN",cronapi.util.getUserToken())},error:()=>i(),type:"GET"}):n(a)},reloadAndExpand=function(e){let t=()=>{let t=new Promise((t,a)=>{getAllParent(this.options.cronappDatasource,e,[],t,a)});t.then(e=>{this.options.kendoObj.expandPath(e.reverse())})};this.options.kendoObj.dataSource.bind("requestEnd",t),this.options.kendoObj.dataSource.read()},helperDirective=this,waitingPromise=!1,datasource=new kendo.data.HierarchicalDataSource({transport:{push:async function(e){let t=await this.options.cronappDatasource();!helperDirective.dataSourceEventsPush&&t&&(helperDirective.dataSourceEventsPush={create:function(e){reloadAndExpand.bind(this)(e)}.bind(this),update:function(e){reloadAndExpand.bind(this)(e)}.bind(this),delete:function(e){reloadAndExpand.bind(this)(e),ngModelCtrl.$setViewValue(null)}.bind(this),overRideRefresh:function(e){this.options.fromRefresh=!0,this.options.kendoObj.dataSource.read(),ngModelCtrl.$setViewValue(null)}.bind(this),read:function(e){waitingPromise||(this.options.kendoObj.dataSource.read(),ngModelCtrl.$setViewValue(null))}.bind(this)},t.addDataSourceEvents(helperDirective.dataSourceEventsPush))},read:async function(e){let cronappDatasource=await this.options.cronappDatasource(),conditionIsEmpty=e=>{let t=!0;if(e){let a=JSON.parse(e);a.expression&&a.expression.args&&a.expression.args.forEach(e=>{""!==e.right&&"''"!==e.right&&e.right!==void 0&&(t=!1)})}return t};for(key in e.data)null==e.data[key]&&delete e.data[key];let logicFilter={filter:{logic:"and",filters:[]}};for(let t in e.data){let a={field:options.selfRelationshipField,operator:"eq",value:e.data[t]};logicFilter.filter.filters.push(a)}let condition=cronappDatasource.condition,conditionEmpty=conditionIsEmpty(condition),paramsOData={$inlinecount:"allpages",$format:"json",$filter:`${options.selfRelationshipField} eq null`};logicFilter.filter.filters.length?(cronappDatasource.condition="",paramsOData=kendo.data.transports.odata.parameterMap(logicFilter,"read")):this.options.fromRefresh&&(this.options.fromRefresh=!1,!conditionEmpty&&(cronappDatasource.cleanup(),paramsOData={$inlinecount:"allpages",$format:"json"})),cronappDatasource.rowsPerPage=e.data.pageSize,cronappDatasource.offset=e.data.page-1;let fetchData={};fetchData.params=paramsOData,helperKendoDs=this,cronappDatasource.fetch(fetchData,{success:function(data){let all=data.map(item=>{let odataUrl=`${this.entity}/$count?$filter=${options.selfRelationshipField} eq '${item[schema.model.id]}'`;return new Promise((resolve,reject)=>{$.ajax({url:odataUrl,success:count=>{item.hasChildren=0<eval(count),resolve()},beforeSend:e=>{window.isUsingCookie()||e.setRequestHeader("X-AUTH-TOKEN",cronapi.util.getUserToken())},error:()=>reject(),type:"GET"})})});waitingPromise=!0,Promise.all(all).then(()=>{e.success(data),waitingPromise=!1})},canceled:function(t){e.error("canceled","canceled","canceled")}},!0),condition&&(cronappDatasource.condition=condition)},options:{fromRead:!1,cronappDatasource:async()=>await app.kendoHelper.getCorrectlyDSPromise(options.dataSourceScreen.name,scope)}},schema:schema});return datasource},link:function(t,a,n,i){let o=$("<div></div>"),d=JSON.parse(n.options),l=this,r=function(e,t){t=e.getKeyValues(t);var a=Object.keys(t);return 1===a.length&&(t=t[a]),t},s=o.kendoTreeView({dataSource:l.getDataSource(d,t,i),dataTextField:d.textField,dataImageUrlField:d.imageUrlField,change:async function(a){let e=this.dataItem(this.select()),n=await this.dataSource.transport.options.cronappDatasource();t.safeApply(n.goTo(e)),d.fieldType&&"key"===d.fieldType&&(n.active=r(n,n.active)),i.$setViewValue(n.active)}}).data("kendoTreeView");s.dataSource.transport.options.kendoObj=s,a.html(o),$compile(o)(a.scope())}}}]).directive("cronSelect",["$compile",function(e){return{restrict:"E",replace:!0,require:"ngModel",link:async function(t,a,n,i){var o={};try{o=JSON.parse(n.options)}catch(e){console.log("ComboBox invalid configuration! "+e)}var d=n.id?" id=\""+n.id+"\"":"",e=n.name?" name=\""+n.name+"\"":"",l=a.parent();$(l).append("<input style=\"width: 100%;\" "+d+e+" class=\"cronSelect\"/>");var r=$(l).find("input.cronSelect"),s=await app.kendoHelper.getConfigCombobox(o,t);s.close=n.ngClose?function(){t.$eval(n.ngClose)}:void 0,s.dataBound=n.ngDataBound?function(){t.$eval(n.ngDataBound)}:void 0,s.filtering=n.ngFiltering?function(){t.$eval(n.ngFiltering)}:void 0,s.select=n.ngSelect?function(a){t.safeApply(()=>{var e={selected:a.dataItem,selectedKey:a.dataItem[s.dataValueField],selectedValue:a.dataItem[s.dataTextField]};t.$eval(n.ngSelect,e)})}:void 0,s.change=n.ngChange?function(a){var e=this.dataItem();t.safeApply(()=>{n.ngModel&&g.$$parse(n.ngModel).assign(t,this.value(),n.ngModel.split("."));var a={selected:e,selectedKey:e[s.dataValueField],selectedValue:e[s.dataTextField]};t.$eval(n.ngChange,a)})}:function(a){t.safeApply(()=>{n.ngModel&&g.$$parse(n.ngModel).assign(t,this.value(),n.ngModel.split("."))})},s.messages={noData:n.noResultsMessage?n.noResultsMessage:"NO DATA FOUND"};var c;if(!0===o.dontAllowOutsideList){c=r.kendoDropDownList(s).data("kendoDropDownList");let e=l.find("span").first();e.on("focus",()=>cronapi.internal.selectContent(e.find(".k-input")[0]))}else c=r.kendoComboBox(s).data("kendoComboBox");$(a).remove();let p,u=()=>{if(p=$(l).find(".k-input.cronSelect"),p.length){p.attr("ng-required",n.ngRequired),"true"===n.ngRequired&&p.attr("required","required"),p.attr("ng-model",n.ngModel),p.attr("id",n.id),p.attr("validationmessage",n.validationmessage);let e=p.parent();p.on("change",()=>{"true"===n.ngRequired&&(0==p.val().length?(e.addClass("ng-invalid-required"),p.addClass("ng-invalid-required")):(e.removeClass("ng-invalid-required"),p.removeClass("ng-invalid-required")))})}else setTimeout(()=>u())};u(),t.$watch(n.cronDisabled,function(e){c.enable(!e)});var m=t,g=i;i&&(i.$formatters.push(function(e){var t="";return("boolean"==typeof e||e)&&(t=e),c.value(t),t}),i.$parsers.push(function(e){return p&&p.trigger("change"),"boolean"==typeof e||e?e:null}))}}}]).directive("cronDynamicSelect",["$compile","$timeout","$parse","$translate","$log",function($compile,$timeout,$parse,$translate,$log){return{restrict:"E",replace:!0,require:"?ngModel",goTo:function(e,t,a){if(dataSourceScreen=$(t).data("dataSourceScreen"),null!=dataSourceScreen)return dataSourceScreen.goTo(a,!0)},compileAngular:function(e,t){var a=$(t),n=angular.element(a);$compile(n)(e)},getActive:function(active){if(active&&active.indexOf(".active."))try{return eval(active.substr(0,active.indexOf(".active.")))}catch(t){}return null},getFieldText:function(e,t){if(e&&e.indexOf(".active.")&&t.dataTextField)try{var a=e.substr(e.indexOf(".active.")+8);return a+"_"+t.dataTextField}catch(t){}return null},isDefaultEntity:function(e){if(e&&e.entity){var t=e.entity.split("/");if(t&&0<t.length)return-1==t.pop().indexOf("query")}return!1},getModelParent:function(e){if("string"==typeof e&&9<e.length&&0<e.indexOf("|raw}}")){e=e.trim();var t=e.substr(e.indexOf("{{")+2);return t=t.substr(0,t.indexOf("|raw}}")),t.trim()}return null},toComboType:function(e,t,a,n){let i=t.find("span").first();switch(i.on("focus",()=>cronapi.internal.selectContent(i.find("span.ng-scope")[0])),a.type){case"autoComplete":let t=["Tab","Shift","CapsLock","Control","Alt","Escape","PageDown","PageUp","Backspace","ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Delete","Insert","Enter"," "],o=["Tab","Shift","CapsLock","Control","Alt","Escape","PageDown","PageUp","ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Insert"];i.attr("contenteditable","true");let d=$(`input[aria-owns=${e.id}_listbox]`),l=d.parent(),r=$(`#${e.id}-list`);l.hide(),i.on("keyup",a=>{document.activeElement!==i[0]||o.includes(a.originalEvent.key)||d.val(i.find("span.ng-scope").text()),i.hasClass("k-state-border-down")||t.includes(a.originalEvent.key)||i.trigger("click")}),i.on("focusout",()=>{r.is(":visible")||s()}),i.on("click",()=>c());let s=()=>{i.find("span.ng-scope").text(n.dataItem()[a.dataTextField]),n.search()},c=()=>{let e=setInterval(()=>{r.is(":visible")||(clearInterval(e),document.activeElement!==i[0]&&s())})};break;default:i.on("keydown",t=>{if("ArrowDown"===t.originalEvent.key||"ArrowUp"===t.originalEvent.key)return t.stopImmediatePropagation(),void i.trigger("click")})}},link:async function(scope,element,attrs,ngModelCtrl){await cronapi.internal.skipIterationLoop();var modelGetter=$parse(attrs.ngModel),modelSetter=(e,t)=>{$log.debug("modelSetter | "+attrs.id+" | "+t),modelGetter.assign(e,t)},select={},self=this,parentDS={},textField=null;try{select=JSON.parse(attrs.options),parentDS=this.getActive(attrs.ngModel),textField=this.getFieldText(attrs.ngModel,select)}catch(e){console.log("DynamicComboBox invalid configuration! "+e)}let lastFieldInModel=attrs.ngModel.split(".");lastFieldInModel=lastFieldInModel[lastFieldInModel.length-1];let modelForTextField=attrs.ngModel.replace(lastFieldInModel,textField),modelTextFieldGetter=$parse(modelForTextField),modelTextFieldSetter=modelTextFieldGetter.assign;var options=await app.kendoHelper.getConfigCombobox(select,scope);options.autoBind=!0;var dataSourceScreen=null;try{delete options.dataSource.schema.model.id,dataSourceScreen=eval(select.dataSourceScreen.name),dataSourceScreen.rowsPerPage=dataSourceScreen.rowsPerPage?dataSourceScreen.rowsPerPage:100,options.dataSource.transport.origin="combobox"}catch(t){}var _scope=scope,_goTo=this.goTo,_compileAngular=this.compileAngular;options.virtual={},options.virtual.itemHeight=26;let lastValueMapper;if(options.dataSource.pageSize&&0<options.dataSource.pageSize){options.height=options.dataSource.pageSize*options.virtual.itemHeight/4,options.virtual.mapValueTo="dataItem";var _options=options;let e=()=>new Promise(e=>{let t;_options.combobox?e():t=setInterval(()=>{_options.combobox&&(clearInterval(t),e())})});options.virtual.valueMapper=async function(t){await e(),$log.debug("valueMapper | "+attrs.id+" | "+t.value),lastValueMapper&&!lastValueMapper.completed&&($log.debug("valueMapper Canceling | "+lastValueMapper.value),lastValueMapper.canceled=!0),lastValueMapper=t;var a=_options.combobox;if(t.canceled)return void $log.debug("valueMapper CANCELED | "+t.value);if(!(t.value||""===t.value))$log.debug("valueMapper.success | "+attrs.id+" | NULL"),t.success(null);else if(null!==a.options.optionLabel[a.options.dataValueField]&&""===t.value)t.completed=!0,$log.debug("valueMapper.success | "+attrs.id+" | NULL"),t.success(null);else{a.isEvaluating=!0;var n=_options.dataSource.transport.options.cronappDatasource;void 0===t.value||null===t.value||""===t.value?(t.completed=!0,$log.debug("valueMapper.success | "+attrs.id+" | NULL"),t.success(null),a.isEvaluating=!1):($log.debug("valueMapper.findObj | "+attrs.id+" | "+t.value),n.findObj([t.value],!1,function(e){return t.completed=!0,t.canceled?($log.debug("valueMapper CANCELED | "+t.value),void(a.isEvaluating=!1)):void(Array.isArray(e)&&(e=e[0]),$log.debug("valueMapper.success | "+attrs.id+" | "+e),t.success(e),a.isEvaluating=!1,select.changeCursor?scope.safeApply(function(){if(t.canceled)return void $log.debug("valueMapper CANCELED | "+t.value);if(null!=e){var i=_goTo(_scope,a,e);i||(n.data.push(e),i=_goTo(_scope,a,e)),i&&modelSetter(_scope,i[select.dataValueField])}else modelSetter(_scope,null)}):null==e&&modelSetter(_scope,null))},function(){return t.completed=!0,t.canceled?($log.debug("valueMapper CANCELED | "+t.value),void(a.isEvaluating=!1)):void($log.debug("valueMapper.success | "+attrs.id+" | NULL"),t.success(null),a.isEvaluating=!1)},[combobox.options.dataValueField]))}}}options.messages={noData:attrs.noResultsMessage?attrs.noResultsMessage:"NO DATA FOUND"},options.change=attrs.ngChange?function(t){var e=this.dataItem();scope.safeApply(()=>{var t={selected:e,selectedKey:e[options.dataValueField],selectedValue:e[options.dataTextField]};scope.$eval(attrs.ngChange,t)})}:void 0,options.close=attrs.ngClose?function(){scope.$eval(attrs.ngClose)}:void 0,options.dataBound=attrs.ngDataBound?function(){scope.$eval(attrs.ngDataBound)}:void 0,options.filtering=attrs.ngFiltering?function(){scope.$eval(attrs.ngFiltering)}:void 0,options.open=function(t){dataSourceScreen.fetched&&dataSourceScreen.lastLoadedTime===combobox.dataSource.lastLoadedTime||(combobox.options.firstLazyRead=!0,combobox.dataSource.read(),combobox.dataSource.lastLoadedTime=dataSourceScreen.lastLoadedTime)},options.select=attrs.ngSelect?function(t){scope.safeApply(()=>{var e={selected:t.dataItem,selectedKey:t.dataItem[options.dataValueField],selectedValue:t.dataItem[options.dataTextField]};scope.$eval(attrs.ngSelect,e)})}:void 0;var parent=element.parent(),id=attrs.id?" id=\""+attrs.id+"\"":"",name=attrs.name?" name=\""+attrs.name+"\"":"",validationmessage=attrs.validationmessage?" validationmessage=\""+attrs.validationmessage+"\"":"",inputSelect=$("<input style=\"width: 100%;\""+id+name+validationmessage+" class=\"cronDynamicSelect\" ng-model=\""+attrs.ngModel+"\"/>");attrs.$observe("required",function(e){inputSelect.prop("required",e)}),$(parent).append(inputSelect);var $element=$(parent).find("input.cronDynamicSelect");dataSourceScreen&&(dataSourceScreen.__ignoreFirstFetch=!0);var combobox=$element.kendoDropDownList(options).data("kendoDropDownList");options.combobox=combobox,$(combobox.element[0]).attr("tabindex","-1"),null!=dataSourceScreen&&null!=dataSourceScreen&&$(combobox).data("dataSourceScreen",dataSourceScreen),(attrs.ngRequired||attrs.required)&&($(combobox.element[0]).attr("style",""),$(combobox.element[0]).attr("class","cron-select-offscreen")),$(combobox.wrapper).children(".k-dropdown-wrap").children(".k-select").before(inputSelect),this.toComboType(attrs,parent,select,combobox);let forcedRefreshModelAt,canRefresh=()=>{let e=performance.now();return!forcedRefreshModelAt||2e3<e-forcedRefreshModelAt};var forceChangeModel=async function(e){$log.debug("forceChangeModel | "+attrs.id+" | "+e),void 0===e&&(e=null);let t=combobox.value();t=void 0!==t&&null!==t?t.trim():t;let a=void 0!==e&&null!==e?(""+e).trim():e;a!==t&&(await combobox.value(e)),select.changeCursor&&scope.safeApply(()=>{null==e||null==e?(dataSourceScreen.active={},dataSourceScreen.cursor=-1,modelSetter(_scope,null)):_goTo(_scope,combobox,combobox.dataItem())})};let returnTypedValue=e=>{if(dataSourceScreen.schema){let t=dataSourceScreen.schema.find(e=>e.name===options.dataValueField);t&&"String"!==t.type&&(e=parseFloat(e)||e)}return e};var defineInitialValue=function(){if(!combobox.definingInitialValue)if(!combobox.isEvaluating){var e=returnTypedValue(combobox.value()),t=null,a=dataSourceScreen.goTo(e);a||((combobox.options.lazyFirstInitialValue||!dataSourceScreen.lazy)&&null!=select.initValue&&null!=select.initValue&&(combobox.options.lazyFirstInitialValue=!1,a=dataSourceScreen.goTo(select.initValue),a&&(t=select.initValue)),null==t&&select.firstValue?dataSourceScreen&&(combobox.definingInitialValue=!0,dataSourceScreen.fetch({params:{$top:1}},{success:function(e){e.length&&(dataSourceScreen.data.push(e[0]),t=e[0][select.dataValueField]),modelSetter(_scope,t),forceChangeModel(t),combobox.definingInitialValue=!1},error:function(){combobox.definingInitialValue=!1},canceled:function(){combobox.definingInitialValue=!1}},void 0,{lookup:!0})):(modelSetter(_scope,t),forceChangeModel(t),combobox.definingInitialValue=!1))}else setTimeout(()=>defineInitialValue(),300)},_ngModelCtrl=ngModelCtrl;null!=dataSourceScreen&&null!=dataSourceScreen&&dataSourceScreen.addDataSourceEvents({overRideRefresh:function(){dataSourceScreen.fetched=!1,dataSourceScreen.cleanup(),canRefresh()&&defineInitialValue()}});var _isDefaultEntity=this.isDefaultEntity;if($element.on("change",function(event){let applyChange=function(){return combobox.isEvaluating?void setTimeout(applyChange,100):void _scope.$apply(function(){if(modelSetter(_scope,combobox.dataItem()[select.dataValueField]),modelTextFieldSetter(_scope,combobox.dataItem()[select.dataTextField]),select.changeValueBasedOnLabel){let comboLabelValue=combobox.dataItem()[select.dataTextField];try{eval(select.changeValueBasedOnLabel+"=\""+comboLabelValue+"\"")}catch(t){try{_scope.$eval(select.changeValueBasedOnLabel+"=\""+comboLabelValue+"\"")}catch(t){console.error("N\xE3o foi poss\xEDvel atribuir o texto do combobox ",comboLabelValue," no compo informado ",select.changeValueBasedOnLabel)}}}_compileAngular(scope,options.combobox.element[0])})};applyChange()}),ngModelCtrl&&(ngModelCtrl.$formatters.push(function(e){$log.debug("$formatters | "+attrs.id+" | "+e);var t=combobox.value();return(void 0===e||""===e&&void 0===select.optionLabelValue)&&(e=null,modelSetter(_scope,e)),forceChangeModel(e),e}),ngModelCtrl.$parsers.push(function(e){if($log.debug("$parsers | "+attrs.id+" | "+e),"boolean"==typeof e||e)if(!0===combobox.options.valuePrimitive){if("string"==typeof e)return e;if("boolean"==typeof e[select.dataValueField]||e[select.dataValueField])return e[select.dataValueField]}else try{return objectClone(e,combobox.dataSource.options.schema.model.fields)}catch(t){}return null})),!select.initValue)select.initValue=null;else if(select.initValue.startsWith("params.")){var type=combobox.dataSource.options.schema.model.fields[select.dataValueField].type;select.initValue=scope.$eval(select.initValue),"string"!=type&&(select.initValue=dataSourceScreen.normalizeValue(select.initValue,!0))}else select.initValue=scope.$eval(select.initValue);""==select.initValue&&(select.initValue=null),combobox.dataSource.transport&&combobox.dataSource.transport.options&&(combobox.dataSource.transport.options.combobox=combobox,combobox.dataSource.transport.options.$compile=$compile,combobox.dataSource.transport.options.scope=scope,combobox.dataSource.transport.options.ngModelCtrl=ngModelCtrl,combobox.dataSource.transport.options.initRead=!0,null!=select.initValue&&null!=select.initValue?(setTimeout(()=>{modelSetter(_scope,select.initValue)},0),combobox.options.lazyFirstInitialValue=!0):select.firstValue&&defineInitialValue()),$(combobox.span).on("DOMSubtreeModified",function(t){_compileAngular(scope,t.target)}),$(combobox.ul).on("DOMSubtreeModified",function(t){$timeout(function(){_compileAngular(scope,t.target)})}),_compileAngular(scope,combobox.span),_compileAngular(scope,combobox.ul),$(element).remove(),scope.$watch(attrs.cronDisabled,function(e){combobox.enable(!e)}),$("[aria-owns='"+`${attrs.id}_listbox`+"']").attr("aria-label",$translate.instant("template.crud.search")),ngModelCtrl.$modelValue&&(_scope.cronapi.internal.forceRefreshNgModel(attrs.ngModel,ngModelCtrl.$modelValue),forcedRefreshModelAt=performance.now())}}}]).directive("cronMultiSelect",["$compile","$parse",function($compile,$parse){return{restrict:"E",require:"ngModel",link:async function(scope,element,attrs,ngModelCtrl){var modelGetter=$parse(attrs.ngModel),modelSetter=modelGetter.assign,model=attrs.ngModel,_self=this,select={};try{select=JSON.parse(attrs.options)}catch(e){console.log("MultiSelect invalid configuration! "+e)}var _scope=scope,_ngModelCtrl=ngModelCtrl,relactionDS={relationDataSource:null==select.relationDataSource?null:eval(select.relationDataSource.name),relationField:null==select.relationField?"":select.relationField},options=await app.kendoHelper.getConfigCombobox(select,scope);try{delete options.dataSource.schema.model.id}catch(t){}var parent=element.parent(),id=attrs.id?" id=\""+attrs.id+"\"":"",name=attrs.name?" name=\""+attrs.name+"\"":"";let required=attrs.ngRequired&&eval(attrs.ngRequired)?`required="required"`:"";$(parent).append(`<div style="width: 100%;"> <input style="width: 100%;" ${id} ${name} ${required} class="cronMultiSelect" ng-model="${attrs.ngModel}"/> </div>`),$(parent).find("label").attr("for",attrs.id);let $inp=$(`${attrs.id}`);$compile($inp)(scope);var $element=$(parent).find("input.cronMultiSelect");$(element).remove();var evtSelect,deselect;options.deselect=function(e){var dataItem=e.dataItem,relation=this.relationDataSource,dataValueField=e.sender.options.dataValueField,selectItem=null;if(relation&&relation.data&&dataItem[dataValueField]){for(key in relation.data){var item=relation.data[key];if(item[this.relationField]&&item[this.relationField]==dataItem[dataValueField]){selectItem=item;break}}null!=selectItem&&($(combobox).data("silent",!0),this.relationDataSource.removeSilent(selectItem,null,null))}else model&&_scope.$apply(function(){try{var data=eval("_scope."+model);data=data.filter(e=>"object"==typeof e?e[dataValueField]!==dataItem[dataValueField]:e!==dataItem[dataValueField]),$(combobox).data("silent",!0),modelSetter(_scope,data)}catch(t){}});deselect&&deselect()}.bind(relactionDS),options.select=function(e){var dataItem=e.dataItem,dataValueField=e.sender.options.dataValueField,combobox=e.sender;if(this.relationDataSource&&dataItem[dataValueField]){var obj={};obj[this.relationField]=dataItem[dataValueField],$(combobox).data("silent",!0),this.relationDataSource.startInserting(obj,function(e){this.postSilent()}.bind(this.relationDataSource))}else model&&_scope.$apply(function(){try{var data=eval("_scope."+model);if(data||(data=[]),select.fieldType&&"key"===select.fieldType){var keyValues=combobox.dataSource.options.transport.options.cronappDatasource.getKeyValues(dataItem),keys=Object.keys(keyValues);1===keys.length&&(keyValues=keyValues[keys]),data.push(keyValues)}else data.push(objectClone(dataItem,combobox.dataSource.options.schema.model.fields));$(combobox).data("silent",!0),modelSetter(_scope,data)}catch(t){}});evtSelect&&evtSelect()}.bind(relactionDS);var hideSelectedItem="true"==attrs.crnHideSelectedItem,onSelectedItem=()=>{hideSelectedItem&&combobox.list&&0<combobox.list.length&&(combobox.list.find(".k-item").show(),combobox.list.find(".k-item.k-state-selected").hide())};options.change=attrs.ngChange?function(){_scope.$eval(attrs.ngChange)}:void 0,options.close=attrs.ngClose?function(){_scope.$eval(attrs.ngClose)}:void 0,options.dataBound=attrs.ngDatabound?function(){_scope.$eval(attrs.ngDatabound)}:void 0,options.filtering=attrs.ngFiltering?function(){_scope.$eval(attrs.ngFiltering)}:void 0,options.open=attrs.ngOpen?function(){_scope.$eval(attrs.ngOpen),onSelectedItem()}:onSelectedItem,options.cascade=attrs.ngCascade?function(){_scope.$eval(attrs.ngCascade)}:void 0,evtSelect=attrs.ngSelect?function(){_scope.$eval(attrs.ngSelect)}:void 0,deselect=attrs.ngDeselect?function(){_scope.$eval(attrs.ngDeselect)}:void 0;var combobox=$element.kendoMultiSelect(options).data("kendoMultiSelect");scope.$watch(attrs.cronDisabled,function(e){combobox.enable(!e)}),app.kendoHelper.receivePushData(combobox),$("[aria-describedby='"+`${attrs.id}_taglist`+"']").attr("id",`${attrs.id}-container`),attrs.crnReadonly&&_scope.$watch(attrs.crnReadonly,(e,t)=>{combobox.readonly(_scope.$eval(attrs.crnReadonly))});var convertArray=function(e){var t=[];if(e)for(var a in e)t.push(e[a][relactionDS.relationField]);return t};scope.$watchCollection(function(){return ngModelCtrl.$modelValue},function(value,old){var silent=$(combobox).data("silent");value&&0===value.length?($(`#${attrs.id}`).addClass("ng-empty"),attrs.ngRequired&&eval(attrs.ngRequired)&&$(`#${attrs.id}`).attr("required","required")):($(`#${attrs.id}`).removeClass("ng-empty"),$(`#${attrs.id}`).removeAttr("required")),$(combobox).data("silent",!1),silent||JSON.stringify(value)===JSON.stringify(old)||(relactionDS.relationDataSource&&relactionDS.relationField?combobox.value(convertArray(value)):combobox.value(value))})}}}]).directive("cronAutoComplete",["$compile",function(e){return{restrict:"E",require:"ngModel",link:async function(t,a,n,i){var o={};try{o=JSON.parse(n.options)}catch(e){console.log("AutoComplete invalid configuration! "+e)}try{delete d.dataSource.schema.model.id}catch(t){}var d=await app.kendoHelper.getConfigCombobox(o,t);d.change=n.ngChange?function(){t.$eval(n.ngChange)}:void 0,d.close=n.ngClose?function(){t.$eval(n.ngClose)}:void 0,d.dataBound=n.ngDataBound?function(){t.$eval(n.ngDataBound)}:void 0,d.filtering=n.ngFiltering?function(){t.$eval(n.ngFiltering)}:void 0,d.select=n.ngSelect?function(){t.$eval(n.ngSelect)}:void 0;var l=a.parent(),r=n.id?" id=\""+n.id+"\"":"",e=n.name?" name=\""+n.name+"\"":"",s=n.validationmessage?" validationmessage=\""+n.validationmessage+"\"":"",c="";(n.ngRequired||n.required)&&(c=" required "),$(l).append("<input style=\"width: 100%;\" "+r+e+c+s+" class=\"cronAutoComplete\" ng-model=\""+n.ngModel+"\"/>");var p=$(l).find("input.cronAutoComplete");$(a).remove(),d.change=function(a){t.$apply(function(){i.$setViewValue(p.val())})},"true"==n.autoExpand&&p.on("focus",function(t){u.search()}),d.messages={noData:n.noResultsMessage?n.noResultsMessage:"NO DATA FOUND"},"false"==n.firstOptionOnBlur&&(d.suggest=!1);var u=p.kendoAutoComplete(d).data("kendoAutoComplete");t.$watch(n.cronDisabled,function(e){u.enable(!e)}),i&&(i.$formatters.push(function(e){return u.value(e),e}),i.$parsers.push(function(e){if(e){if("string"==typeof e)return e;if(e[o.dataTextField])return e[o.dataTextField]}return null}))}}}]).directive("cronDate",["$compile","$translate","$window",function(e,t,a){return{restrict:"AE",require:"?ngModel",link:function(a,n,i,o){var d={},l={};try{if(i.options)l=JSON.parse(i.options);else{var r=window.buildElementOptions(n);l=JSON.parse(r)}l.format||(l.format=parseMaskType(l.type,t)),d=app.kendoHelper.getConfigDate(t,l)}catch(e){console.log("AutoComplete invalid configuration! "+e)}var s="date"==d.type||"datetime"==d.type||"time"==d.type;window.fixedTimeZone||(s=!1);var c=$(n);if(!c.data("alreadycompiled")){if(c.data("alreadycompiled",!0),c.data("$compile",e),i.fromGrid)c=$(n);else{var p=n.parent(),u=$("<input style=\"width: 100%;\" class=\"cronDate\" ng-model=\""+i.ngModel+"\"/>");$(p).append(u),c=$(p).find("input.cronDate"),c.data("type",d.type),c.attr("type","date")}var m=app.kendoHelper.buildKendoMomentPicker(c,d,a,o);i.fromGrid||(o&&(o.$formatters.push(function(e){var t=null;if(e){var a=null;a=s?moment(e).utcOffset(window.timeZoneOffset):moment(e),t=a.format(d.momentFormat)}return m.value(t),t}),o.$parsers.push(function(e){if(e){var t=null;return t=s?moment(m._oldText,d.momentFormat).utcOffset(window.timeZoneOffset):moment(m._oldText,d.momentFormat),t.toDate()}return null})),$(n).remove())}}}}]).directive("cronSlider",["$compile",function(e){return{restrict:"E",require:"ngModel",getActive:function(e,t){if(e&&e.indexOf(".active."))try{return t.$eval(e.substr(0,e.indexOf(".active.")))}catch(t){}},link:function(t,a,n,i){var o={};try{o=JSON.parse(n.options)}catch(e){console.log("Slider invalid configuration! "+e)}var d=app.kendoHelper.getConfigSlider(o),l=this.getActive(n.ngModel,t);d.change=function(){t.$apply(function(){var e=$(a).val();l&&(e=l.normalizeValue(e,!0)),i.$setViewValue(e),n.ngChange&&t.$eval(n.ngChange)})},d.slide=n.ngSlide?function(){t.$eval(n.ngSlide)}:void 0;var o=$(a).kendoSlider(d).data("kendoSlider");o._drag.element[0].title=d.dragHandleTitle,o._drag.element[1].title=d.dragHandleTitle;const r=new ResizeObserver(e=>{o.resize()});if(r.observe(o.wrapper[0]),"true"===n.ngRequired||n.required){var s=n.id?" id=\"input"+app.common.generateId()+"\"":"",c=n.name?" name=\"input"+app.common.generateId()+"\"":"",p=a.parent();$(p).append("<input aria-label=\"slider\" autocomplete=\"off\" tabindex=\"-1\" style=\"width: 100%;\""+s+c+" required class=\"cronSlider cron-select-offscreen\" ng-model=\""+n.ngModel+"\"/>");var u=$(p).find("input.cronSlider");e(u)(a.scope())}t.$watch(function(){return i.$modelValue},function(e,t){e!==t&&(e?o.value(e):o.value(o.min()))}),i&&(i.$formatters.push(function(e){var t=null;return!e&&o.min?t=o.min:e&&(t=e),o.value(t),t}),i.$parsers.push(function(e){return e?e:null}))}}}]).directive("cronSwitch",["$compile",function(e){return{restrict:"E",require:"ngModel",link:function(t,a,n,i){var o={};try{var d=window.buildElementOptions(a);o=JSON.parse(d)}catch(e){console.log("Switch invalid configuration! "+e)}var l=app.kendoHelper.getConfigSwitch(o),r=a.parent();$(r).append("<input style=\"width: 100%;\" class=\"cronSwitch\" ng-model=\""+n.ngModel+"\"/>");var s=$(r).find("input.cronSwitch"),c=function(a){t.$apply(function(){i.$setViewValue(this.value())}.bind(this))};l.change=c;var p=s.kendoMobileSwitch(l).data("kendoMobileSwitch");$(a).remove(),i&&(i.$formatters.push(function(e){var t=!1;return null!=e&&(t=e),p.value(t),t}),i.$parsers.push(function(e){return null!=e&&e}))}}}]).directive("cronBarcode",["$compile",function(e){return{restrict:"E",require:"ngModel",link:function(e,t,a,n){var i={};try{var o=window.buildElementOptions(t);i=JSON.parse(o)}catch(e){console.log("Barcode invalid configuration! "+e)}var d=app.kendoHelper.getConfigBarcode(i),l=t.parent();$(l).append("<span class=\"cronBarcode\" ng-model=\""+a.ngModel+"\"></span>");var r=$(l).find("span.cronBarcode"),s=r.kendoBarcode(d).data("kendoBarcode");$(t).remove(),e.$watch(function(){return n.$modelValue},function(e,t){var a="";e!==t&&(a=e),d.value=a,s.setOptions(d)})}}}]).directive("cronQrcode",["$compile",function(e){return{restrict:"E",require:"ngModel",link:function(e,t,a,n){var i={};try{var o=window.buildElementOptions(t);i=JSON.parse(o)}catch(e){console.log("Qrcode invalid configuration! "+e)}var d=app.kendoHelper.getConfigQrcode(i),l=t.parent();$(l).append("<span class=\"cronQrcode\" ng-model=\""+a.ngModel+"\"></span>");var r=$(l).find("span.cronQrcode"),s=r.kendoQRCode().data("kendoQRCode");$(t).remove(),e.$watch(function(){return n.$modelValue},function(e,t){var a="";e!==t&&(a=e),d.value=a,s.setOptions(d)})}}}]).directive("cronappRating",function(){"use strict";return{restrict:"E",require:"ngModel",link:function(e,t,a,n){function o(e){for(var t=1;5>=t;t++)c[t-1].removeClass(a.iconOff||"fa fa-star-o"),c[t-1].removeClass(a.classElem),c[t-1].removeClass(a.iconTheme),t<=e?c[t-1].addClass(a.classElem):(c[t-1].addClass(a.iconOff||"fa fa-star-o"),c[t-1].addClass(a.theme),c[t-1].addClass(a.iconSize));return e}a.theme=$(t).find("i").attr("icon-theme"),a.classElem=$(t).find("i").attr("class"),a.iconSize=$(t).find("i").attr("icon-size"),a.iconOn=$(t).find("i").attr("class");var d=$(t),l=[];a.xattrDefaultValue&&(n.$viewValue=0,n.$commitViewValue());for(var r=1;5>=r;r++)l.push($(t).find("i").get(r-1)),$(l[r-1]).addClass(a.iconOff||"fa fa-star-o");d.html("");for(var s,c=[],r=1;5>=r;r++)s=$(l[r-1]).clone(),d.append(s),s.attr("idx",r),s.click(function(){e.$apply(function(){let e=parseInt($(this).attr("idx"));n.$viewValue=n.$viewValue===e?0:e,n.$commitViewValue()}.bind(this))}),c.push(s);n.$parsers.push(o),n.$formatters.push(o)}}}).directive("cronDynamicMenu",["$compile","$translate",function(e,t){"use strict";const a=e=>{var n="";return e&&0<e.length&&Array.isArray(e)&&(e.forEach(function(e){var i=e.security&&null!=e.security?` cronapp-security="${e.security}" `:"",o=e.action&&null!=e.action?` ng-click="cronapi.internal.lastCronappMenuClick('${e.id}');${e.action}" `:"",d=e.hide&&null!=e.hide?` ng-hide="${e.hide}" `:"",l=e.iconClass&&null!=e.iconClass?`<i class="${e.iconClass}" id="menu-tag-i-${e.id}"></i>&nbsp;`:"",r=`<span id="menu-tag-span-${e.id}"></span>`,s=e.menuItems&&Array.isArray(e.menuItems)&&0<e.menuItems.length?`<span class="caret submenu" id="menu-tag-span-sub-${e.id}"></span>`:"";e.title&&(r=`<span id="menu-tag-span-${e.id}">${t.instant(e.title)}</span>`),n+=0<e.menuItems.length?`
37
+ </div>`),a.sender.element.find(".k-scheduler-header.k-state-default").addClass("changed"))},r=a=>{let e=a.sender.element.find(".k-more-events.k-button.hooked").length;if(!e){let e=a.sender.view(),i=t.views.find(t=>t.type===e.name),o=app.common.generateId();a.sender.element.find(".k-more-events.k-button").attr("data-id",o);let d=generateBlocklyCall(i.moreEventsBlockly);d&&s(o,a=>{let e=$(a.currentTarget).prev(),i=e.data("uid"),o=t.refComponent.dataItems().find(e=>e.uid==i),l={scheduleData:{type:"seeAll",selectedDate:o.start}};n.$eval(d,l)}),a.sender.element.find(".k-more-events.k-button").addClass("hooked")}},s=(e,t)=>new Promise(a=>{let n=setInterval(()=>{let i=$(`[data-id="${e}"]`);if(i.length){clearInterval(n);let e="click";$(".km-pane-wrapper").length&&(e="touchstart"),i.off(e),i.on(e,a=>{t(a),a.stopImmediatePropagation()}),a()}},100)}),c=[];if(t.views)for(let e in t.views){let a=t.views[e];a.visible&&c.push(a)}else t.showDayTab&&c.push("day"),t.showAgendaTab&&c.push("agenda"),t.showMonthTab&&c.push("month"),t.showTimelineTab&&c.push("timeline"),t.showWeekTab&&c.push("week"),t.showWorkWeekTab&&c.push("workWeek");let p={dateHeaderTemplate:kendo.template(`#=kendo.toString(date, ${kendo.culture().name.toLowerCase().includes("pt")?"'ddd dd/M'":"'ddd M/dd'"})#`),showWorkHours:t.showWorkHours,selectable:!0,date:i,mobile:!1,allDaySlot:t.allDaySlot,messages:{editor:{timezone:$translate.instant("TimezoneEvent")}},currentTimeMarker:t.currentTimeMarker?{updateInterval:1e4,useLocalTimezone:!1}:t.currentTimeMarker,views:c,navigate:function(t){let e=t.sender.view()},dataBound:function(t){let e=t.sender.view();l(t),r(t)},eventTemplate:e=>{let a={scheduleData:e},i=t=>e.description?(t?" - ":"")+e.description:"",o=app.common.generateId(),d=t.refComponent.view().name,l=t.views.find(e=>e.type===d),r=[];r.push(`<div class='k-event-template' data-id='${o}'>`),"agenda"===d?(r.push(`<div class='k-event-title'>${e.title}</div>`),!l.showDescription||r.push(`<div class='k-event-description'>${i(!1)}</div>`)):r.push(`<div class='k-event-title'>${e.title}${l.showDescription?i(!0):""} </div>`),r.push("</div>");let c=generateBlocklyCall(l.blockly);return c&&s(o,()=>{n.$eval(c,a)}),r.join("")},change:t=>{t&&t.events&&t.events.length?this.setDatasourceActiveItem(a,t.events[0],"id"):a.startInserting({}),console.log("Active: ",a.active)},edit:function(a){if(t&&t.allowCustomAction){let e=a.container,i=t.customActionLabel?t.customActionLabel:$translate.instant("Details"),o=$("<a class=\"k-button\">"+i+"</a>");o.click(function(a){n.safeApply(()=>{n.$eval(generateBlocklyCall(t.customActionBlockly))})});let d=e.find(".k-edit-buttons");d.append(o)}},dataSource:{batch:!1,transport:{isComponentInDocument:function(e){return!!e&&$(document).has(e.element[0]).length},getCurrentCallbackForPush:function(e,t){return e||t},pushAction:function(e,n){return i=>{let o=["read","memorydelete","overRideRefresh"];if(this.isComponentInDocument(t.refComponent)){let a=this.getCurrentCallbackForPush(n,t.refComponent),o=a[e];o?o(i):(t.fromRead="read"===e,t.refComponent.dataSource.read())}else o.includes(e)||a.removeDataSourceEvents(this.options.dataSourceEventsPush)}},push:function(e){!this.dataSourceEventsPush&&a&&(this.dataSourceEventsPush={create:this.pushAction.bind(this)("pushUpdate",e),update:this.pushAction.bind(this)("pushUpdate",e),delete:this.pushAction.bind(this)("pushDestroy",e),read:this.pushAction.bind(this)("read",e),memorycreate:this.pushAction.bind(this)("pushUpdate",e),memoryupdate:this.pushAction.bind(this)("pushUpdate",e),memorydelete:this.pushAction.bind(this)("pushDestroy",e)},a.addDataSourceEvents(this.dataSourceEventsPush))},read:function(e){e.data=e.data||{};let n=!1;try{t.kendoCallback?t.fromRead?t.isReading?e.error():(t.isReading=!0,t.kendoCallback.success(a.data)):n=!0:(t.kendoCallback=e,n=!0)}finally{t.fromRead=!1,t.isReading=!1}if(n)if(d(e.data)){o=e.data,jQuery.isEmptyObject(e.data)&&(e.data[t.schedulerDataModel.start.name]=i);let n=kendo.data.transports.odata.parameterMap(e.data,"read"),d="",l={};l.params=n,a.fetch(l,{success:function(t){e.success(angular.copy(t))},canceled:function(t){e.error(angular.copy(t))}},!1)}else e.error()}.bind(this),update:e=>{let n=this.parseToDatasourceSchema(a,e.data,t);a.startEditing(a.active),this.mergeSchedulerEventWithDatasourceActive(a,n),a.update(a.active,t=>{let n=angular.copy(t);e.success(n),a.fetch({},{success:e=>{this.setDatasourceActiveItem(a,n,"id")},canceled:e=>{}},!1)},t=>{e.error(angular.copy(t))})},create:e=>{let n=this.parseToDatasourceSchema(a,e.data,t);this.mergeSchedulerEventWithDatasourceActive(a,n),a.insert(a.active,t=>{let n=angular.copy(t);e.success(n),a.fetch({},{success:e=>{this.setDatasourceActiveItem(a,n,"id")},canceled:function(e){}},!1)},t=>{e.error(angular.copy(t))})},destroy:function(e){a.removeSilent(this.parseToDatasourceSchema(a,e.data,t),function(t){e.success(angular.copy(t))},function(t){e.error(angular.copy(t))})}.bind(this)},schema:{model:this.getSchedulerModel(t.schedulerDataModel)}}};return t.views||(p.editable=t.editable),window.fixedTimeZone&&window.timeZone&&(p.timezone=window.timeZone),p},showError:function(e,t,a){let n={message:a,title:t,delay:null};e.Notification.error(n)},parseToDatasourceSchema:function(e,t,a){let n={};for(let i in e.schema){let a=e.schema[i].name;n[a]=t[a]}return n[a.schedulerDataModel.isAllDay.name]=!0===n[a.schedulerDataModel.isAllDay.name],n[a.schedulerDataModel.id.name]||delete n[a.schedulerDataModel.id.name],n},link:function(scope,element,attrs,ngModelCtrl){let datasource,schedulerElement=$("<div></div>"),options=JSON.parse(attrs.options||"{}");if(options.dataSourceScreen&&options.dataSourceScreen.entityDataSource&&(datasource=eval(options.dataSourceScreen.entityDataSource.name)),!datasource){let e={};return void $translate("DatasourceNotFoundMessage").then(t=>(e.message=t,$translate("Scheduler"))).then(t=>(e.component=t,$translate("DatasourceNotFoundTitle"))).then(t=>{e.title=t,this.showError(scope,e.title,e.message.replace("{0}",e.component))})}if(jQuery.isEmptyObject(options.schedulerDataModel))return;let baseUrl="node_modules/cronapp-lib-js/dist/js/kendo-ui/js/messages/kendo.messages.";baseUrl+="pt_br"===$translate.use()?"pt-BR.min.js":"en-US.min.js",this.initCulture(),$.getScript(baseUrl,async function(){function e(e,t){if(!e||!t)return;let a;return e.forEach((e,n)=>t.forEach(t=>{a=e.getTime()===t.getTime()})),a}let t=app.kendoHelper.getDataSource(options.dataSourceScreen.entityDataSource,scope,!0,options.dataSourceScreen.rowsPerPage),a=await this.getSchedulerProperties(options,datasource,scope);schedulerElement.kendoScheduler(a);let n=schedulerElement.data("kendoScheduler");options.refComponent=n;let i;n.bind("navigate",function(t){n._previousView=t.sender.view()}),n.bind("dataBound",function(t){if(n._currentView=t.sender.view(),n._previousView){let t=e(n._previousView._dates,n._currentView._dates);if(!t){let e={};e[options.schedulerDataModel.start.name]=n._currentView._startDate,e[options.schedulerDataModel.end.name]=n._currentView._endDate,n.dataSource.read(e),n._previousView=n._currentView}}})}.bind(this)),element.html(schedulerElement),$compile(schedulerElement)(element.scope())}}}]).directive("cronGrid",["$compile","$translate",function($compile,$translate){return{restrict:"E",replace:!0,require:"ngModel",initCulture:function(){var e=$translate.use();e=e.replace(/_/gm,"-");var t=e.split("-");t[t.length-1]=t[t.length-1].toUpperCase(),e=t.join("-"),kendo.culture(e)},changeObjectField:function(e,t){t=e.getKeyValues(t);var a=Object.keys(t);return 1===a.length&&(t=t[a]),t},removeSpecialChar:function(e){return e.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()},getModelName:function(e){return e?this.removeSpecialChar(e.ngModel):"subgrid"},generateToolbarButtonCall:function(toolbarButton,scope,options,attrs){var buttonCall,generateObjTemplate=function(e,t,a){var n={template:function(){return createTemplateButton(e,t,a)}.bind(this)};return n}.bind(this),createTemplateButton=function(functionToCall,title,iconClass){var template="";let security=toolbarButton.security?`cronapp-security="${toolbarButton.security}"`:"",modelName=this.getModelName(attrs),buttonType=this.removeSpecialChar(toolbarButton.type),buttonDesc=toolbarButton.title?this.removeSpecialChar(toolbarButton.title):this.removeSpecialChar(toolbarButton.iconClass),buttonId=`${modelName}-${buttonType}-${buttonDesc}`;"SaveOrCancelChanges"==toolbarButton.type?toolbarButton.saveButton?template="<a #SECURITY# role=\"button\" class=\"saveorcancelchanges k-button k-button-icontext k-grid-save-changes\" data-id=\"#BUTTONID#\" href=\"javascript:void(0)\"><span class=\"k-icon k-i-check\"></span>#TITLE#</a>":template="<a #SECURITY# role=\"button\" class=\"saveorcancelchanges k-button k-button-icontext k-grid-cancel-changes\" data-id=\"#BUTTONID#\" href=\"javascript:void(0)\"><span class=\"k-icon k-i-cancel\" ></span>#TITLE#</a>":"Blockly"==toolbarButton.type||"Customized"==toolbarButton.type?template="<a #SECURITY# class=\"k-button k-grid-custom\" data-id=\"#BUTTONID#\" href=\"javascript:void(0)\"><span class=\"#ICONCLASS#\" ></span>#TITLE#</a>":"Native"==toolbarButton.type&&"create"==toolbarButton.title?template="<a #SECURITY# role=\"button\" data-id=\"#BUTTONID#\" class=\"k-button k-button-icontext k-grid-add\" href=\"javascript:void(0)\"><span class=\"k-icon k-i-plus\"></span>{{\"Add\" | translate}}</a>":"Native"==toolbarButton.type&&"excel"==toolbarButton.title?template="<a #SECURITY# role=\"button\" data-id=\"#BUTTONID#\" class=\"k-button k-button-icontext k-grid-excel\" href=\"javascript:void(0)\"><span class=\"k-icon k-i-file-excel\"></span>{{\"exportExcel\" | translate}}</a>":"Native"==toolbarButton.type&&"pdf"==toolbarButton.title&&(template="<a #SECURITY# role=\"button\" data-id=\"#BUTTONID#\" class=\"k-button k-button-icontext k-grid-pdf\" href=\"javascript:void(0)\"><span class=\"k-icon k-i-file-pdf\"></span>{{\"exportPDF\" | translate}}</a>"),template=template.split("#BUTTONID#").join(buttonId).split("#FUNCTIONCALL#").join(this.encodeHTML(functionToCall)).split("#TITLE#").join(title).split("#ICONCLASS#").join(iconClass).split("#SECURITY#").join(security);var cronappDatasource=eval(options.dataSourceScreen.entityDataSource.name),waitRender=setInterval(function(){0<$(`[data-id=${buttonId}]`).length&&(scope.safeApply(function(){var e=angular.element($(`[data-id=${buttonId}]`));$compile(e)(scope),$(`[data-id=${buttonId}]`).attr("id",buttonId)}),$(`[data-id=${buttonId}]`).click(function(){var e=options.refComponent,t=[];e.select().each(function(){var a=e.dataItem(this);cronappDatasource.data.forEach(function(e){e.__$id==a.__$id&&t.push(e)})});var a={item:t.length?cronappDatasource.active:null,index:t.length?cronappDatasource.cursor:null};let n=[];options.fieldType&&"key"===options.fieldType?t.forEach(e=>{n.push(this.changeObjectField(cronappDatasource,cronappDatasource.findObjInDs(e)))}):n=t;var i={currentData:cronappDatasource.data,datasource:cronappDatasource.copyWithoutAngularObj(),selectedIndex:t.length?cronappDatasource.cursor:null,index:t.length?cronappDatasource.cursor:null,selectedRow:t.length?cronappDatasource.active:null,consolidated:a,item:t.length?cronappDatasource.active:null,selectedKeys:t.length?cronappDatasource.getKeyValues(cronappDatasource.findObjInDs(t[0]),!0):null,selectedRows:n};scope.$eval(functionToCall,i)}.bind(this)),clearInterval(waitRender))}.bind(this),200);return template}.bind(this),call="";call="Customized"==toolbarButton.type?toolbarButton.execute:toolbarButton.methodCall?toolbarButton.methodCall:generateBlocklyCall(toolbarButton.blocklyInfo);var title=null==toolbarButton.title?"":toolbarButton.title;return buttonCall=generateObjTemplate(call,title,toolbarButton.iconClass),buttonCall},generateModalSaveOrCancelButtonCall:function(e,t,a,n,i){var o=app.common.generateId(),d=function(e,t,a,n){var d;d="save"==e?"<button id=\"#BUTTONID#\" aria-label=\"#ARIALABELSAVE#\" class=\"btn btn-primary btn-fab ng-binding grid-save-button-modal k-button\" data-component=\"crn-button\" ng-click=\"#FUNCTIONCALL#\" onclick=\"(!#DATASOURCENAME#.missingRequiredField(true)?$('##MODALID#').modal('hide'):void(0))\"><span class=\"k-icon k-i-check\"></span></button>":"saveAdd"==e?"<button id=\"#BUTTONID#\" aria-label=\"#ARIALABELSAVEADD#\" class=\"btn btn-primary btn-fab ng-binding grid-save-add-button-modal k-button\" data-component=\"crn-button\" ng-click=\"#FUNCTIONCALL#\"><span class=\"k-icon k-i-plus\"></span></button>":"<button id=\"#BUTTONID#\" aria-label=\"#ARIALABELCANCEL#\" type=\"button\" class=\"btn btn-default btn-fab ng-binding k-button\" data-component=\"crn-button\" data-dismiss=\"modal\"><span class=\"k-icon k-i-cancel\"></span></button>",d=d.split("#BUTTONID#").join(o).split("#FUNCTIONCALL#").join(t).split("#DATASOURCENAME#").join(a).split("#ARIALABELSAVE#").join($translate.instant("SaveChanges")).split("#ARIALABELSAVEADD#").join($translate.instant("SaveAddChanges")).split("#ARIALABELCANCEL#").join($translate.instant("CancelChanges")).split("#MODALID#").join(n);var l=setInterval(function(){0<$("#"+o).length&&i.safeApply(function(){var e=angular.element($("#"+o));$compile(e)(i),clearInterval(l)})},200);return d};return buttonCall=d(e,t,a,n),buttonCall},addButtonsInModal:function(e,t,a,n){var i=$("#"+e).find(".modal-footer");if(!i.find(".grid-save-button-modal").length){var o=t+".post();",d=this.generateModalSaveOrCancelButtonCall("save",o,t,e,a);if(i.append(d),n){let n=this.generateModalSaveOrCancelButtonCall("saveAdd",o+t+".startInserting();",t,e,a);i.append(n)}var l=this.generateModalSaveOrCancelButtonCall("cancel",null,null,null,a);i.append(l)}},getObjectId:function(e){if(!e)e="";else if(e instanceof Date){var t=moment.utc(e);e=new Date(t.format("YYYY-MM-DDTHH:mm:ss"))}else if("object"==typeof e)if(e.id)e=e.id;else for(var a in e){e=e[a];break}return e},encodeHTML:function(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")},decodeHTML:function(e){return e.replace(/&apos;/g,"'").replace(/&quot;/g,"\"").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")},getColumnByField:function(e,t){var a=null;return e.columns.forEach(function(e){e.field==t&&(a=e)}),a},resizeGridUsingWidthForDevice:function(e){for(let t,a=0;a<e.columns.length;a++)t=this.getWidthForDevice(e.columns[a]),e.columns[a].width=t.width,t.visible?e.showColumn(a):e.hideColumn(a);if(e.options.hasSecurity){let t=$(e.element.find("col")).last();t.css("width","0px")}},getWidthForDevice:function(e){let t=1210,a=1002,n=778,i=424,o=$(window).width(),d=function(t){let a;return e.widthDevices.forEach(e=>{e.device===t&&(a=e)}),void 0===a&&("deviceSmall"===t?a=d("deviceMedium"):"deviceMedium"===t?a=d("deviceDesktop"):"deviceDesktop"===t?a=d("deviceBig"):a=e.widthDevices[0]),a},l={width:e.width};return l.visible=void 0!==e.visible&&null!==e.visible?e.visible:!e.hidden,null!==e.widthDevices&&void 0!==e.widthDevices&&0<e.widthDevices.length&&(1210<=o?l=d("deviceBig"):o>=a&&1210>o?l=d("deviceDesktop"):o>=n&&o<a?l=d("deviceMedium"):l=d("deviceSmall")),l},getColumns:function(options,datasource,scope,tooltips,attrs){function getTemplate(column){var template="#=showTreatedValue("+column.field+")#";return"switch"==column.inputType?template="<span class=\"k-switch km-switch k-widget km-widget k-switch-off km-switch-off\" style=\"width: 100%\"> <span class=\"k-switch-wrapper km-switch-wrapper\"> <span class=\"k-switch-background km-switch-background\" style=\"margin-left: #="+column.field+" ? \"80%\": \"0%\" #\"></span> </span> <span class=\"k-switch-container km-switch-container\"> <span class=\"k-switch-handle km-switch-handle\" style=#="+column.field+" ? \"float:right;margin-right:-1px\": \"margin-left:0%\" #> </span> </span> </span>":"checkbox"==column.inputType||"boolean"==column.type?template="<input crn-set-indeterminate=#="+column.field+"# type='checkbox' class='k-checkbox' #="+column.field+" ? \"checked='checked'\": '' # /><label class='k-checkbox-label k-no-text'></label>":column.displayField&&0<column.displayField.length?hasMask(column.type)||column.format&&"null"!=column.format?template="#= useMask("+column.displayField+",'"+column.format+"','"+column.type+"') #":template="#="+column.displayField+"#":hasMask(column.type)||column.format&&"null"!=column.format?template="#= useMask("+column.field+",'"+column.format+"','"+column.type+"') #":column.showAsImage&&(template=column.showAsImageTemplate?column.showAsImageTemplate:"<img src='#:${column.field}#'/>",template=eval("`"+template+"`")),template}function hasMask(e){return!!(e&&"string"==typeof e)&&(e.startsWith("date")||e.startsWith("month")||e.startsWith("time")||e.startsWith("week")||e.startsWith("money")||e.startsWith("number")||e.startsWith("tel")||e.startsWith("integer"))}function getFormat(e){return hasMask(e.type)?void 0:e.format}function isRequired(e){var t=!1,a=null;return datasource.schema.model.fields[e]&&(a=datasource.schema.model.fields[e]),a&&(t=!a.nullable),t}function getEditor(e){return editor.bind(this)}async function editor(e,t){let a=e=>new Promise((t,a)=>{let n=setInterval(function(){let a=$("#"+e);if(0<a.length){let i=a.closest("td"),o=angular.element(i||a);$compile(o)(scope),clearInterval(n),t(e)}},10)}),n=e=>{e!==t.model[t.field]&&(t.model[t.field]=e,t.model.dirty=!0,t.model.dirtyFields[t.field]=!0)};var i=this.getColumnByField(options,t.field);null==i.visibleCrud||i.visibleCrud||(e.parent().find(".k-edit-label [for="+i.field+"]").parent().remove(),e.remove());var o=isRequired(t.field)?"required":"",d=app.common.generateId();let l=`${options.dataSourceScreen.name}.active.${t.field}`;var r=$(`<input ${o} name="${t.field}" id="${d}" from-grid=true ng-model="${l}" />`);if(r.data("change-grid-model",n),r.data("column-type",i.type),"dynamicComboBox"==i.inputType||"comboBox"==i.inputType){var s=app.kendoHelper.getConfigComboboxSync(i.comboboxOptions,scope);s.autoBind=!0,s.optionLabel=void 0,i.displayField&&(s.change=function(a){t.model.set(i.displayField,this.text()),t.model.dirty=!0,t.model.dirtyFields[i.displayField]=!0});let a=r.appendTo(e).kendoDropDownList(s,scope).data("kendoDropDownList");r.data("kendoDropDownList",a)}else if("slider"==i.inputType){var s=app.kendoHelper.getConfigSlider(i.sliderOptions);s.change=t=>scope.$apply(()=>scope.$eval(`${l}=${t.value}`));let t=r.appendTo(e).kendoSlider(s,scope).data("kendoSlider");r.data("kendoSlider",t)}else if("switch"==i.inputType){var s=app.kendoHelper.getConfigSwitch(i.switchOptions);r.appendTo(e).kendoMobileSwitch(s,scope)}else"checkbox"==i.inputType||"boolean"==i.type?(r=$(`<input id="${d}" name="${t.field}" ng-false-value="false" ng-true-value="true" crn-allow-null-values="${!o}" class="k-checkbox" type="checkbox" from-grid=true ng-model="${l}"><label class="k-checkbox-label" for="${d}"></label>`),r.data("change-grid-model",n),r.appendTo(e)):"date"==i.inputType?(r.attr("cron-date",""),r.attr("options",JSON.stringify(i.dateOptions)),r.data("initial-date",t.model[t.field]),r.attr("type","datetime"),r.appendTo(e).off("change")):(r.attr("type",i.type),r.attr("mask",i.format?i.format:""),("999.999.999-99;0"===i.format||"99.999.999/9999-99;0"===i.format)&&(r.attr("valid","999.999.999-99;0"===i.format?"cpf":"cnpj"),r.attr("data-"+i.field.toLocaleLowerCase()+"validation-msg",$translate.instant("invalid."+r.attr("valid")))),r.css("text-align",i.alignment),r.attr("class","k-input k-textbox"),r.data("initial-value",t.model[t.field]),r.appendTo(e));a(d).then(e=>{$(`#${e}`).data("alreadycompiled",!0),$(`#${e}`).data("$compile",$compile),$(`#${e}`).data("ref-component",options.refComponent)})}function setIdCommandButton(e,t){let a=setInterval(()=>{if($(`.k-grid-${e}`).is(":visible")){clearInterval(a);var n=options.refComponent;$(`.k-grid-${e}`).each((e,a)=>{let i=$(a);if(!i.attr("id")){let e=n.dataItem(i.closest("tr")),a=this.getModelName(attrs),o=e._objectKey,d=`${a}-${t}-${o}`;i.attr("id",d)}})}},200)}function getCommandForEditButtonDatabase(e,t){var a;let n=app.common.generateId(),i=$translate.instant("Edit"),o=`<a href class='k-button k-grid-edit k-grid-${n}' aria-label='${i}'><span class='k-icon k-i-edit'></span></a>`;return a="popupCustom"==e.editable||"datasource"==e.editable?{name:n,template:o,click:function(t){t.preventDefault();var a=$(t.target).closest("tr"),n=a.closest("table"),i=this.dataItem(a),o=this.dataSource.transport.options.cronappDatasource;scope.safeApply(function(){options.hideModalButtons||helperDirective.addButtonsInModal(options.popupEdit,o.name,scope,!1);var t=o.goTo(i);o.startEditing(t,function(e){}),"datasource"==e.editable?cronapi.internal.focusFormInput():cronapi.screen.showModal(options.popupEdit)})}}:{name:t,template:o,text:{edit:" ",update:" ",cancel:" "}},setIdCommandButton.bind(this)(n,t),a}function getCommandForRemoveButtonDatabase(e,t){var a;let n=app.common.generateId(),i=$translate.instant("Remove"),o=`<a href class='k-button k-grid-delete k-grid-${n}' aria-label='${i}'><span class='k-icon k-i-close'></span></a>`;return a="popupCustom"==e.editable||"datasource"==e.editable?{name:n,template:o,click:function(t){t.preventDefault();var e=$(t.target).closest("tr"),a=this.dataItem(e),n=this.dataSource.transport.options.cronappDatasource,i=this;scope.safeApply(function(){var e=n.goTo(a);n.remove(e)})}}:{name:t,template:o},setIdCommandButton.bind(this)(n,t),a}function getAggregate(e){if(e&&e.aggregates){var t=[];if(e.aggregates.forEach(function(e){t.push(e.type)}),0<t.length)return t}}function getAggregateFooter(e,t){if(e&&e.aggregates){var n=[];return e.aggregates.forEach(function(i){var a="#=data."+e.field+" ? data."+e.field+"."+i.type+" : 0 #";("average"==i.type||"sum"==i.type)&&(a="#=useMask(data."+e.field+" ? data."+e.field+"."+i.type+" : 0,'"+e.format+"','"+e.type+"')#");var o=t?i.groupFooterTemplate:i.footerTemplate;o?o+=": ":o="";var d=o+a;e.alignment&&("right"!==e.alignment||t?d="<div style=\"text-align: "+e.alignment+"\">"+d+"</div>":d="<div style=\"text-align: "+e.alignment+"\" class=\"k-fix-margin\">"+d+"</div>"),n.push(d)}),n.join("<br/>")}}function getAggregateHeader(e){return hasMask(e.type)||e.format&&"null"!=e.format?e.headerText+": #=useMask(value,'"+e.format+"','"+e.type+"')#":void 0}function getAttributes(e){let t={};return e&&(e.alignment&&(t.style="text-align: "+e.alignment+";"),e.security&&(t["cronapp-security"]=e.security)),t}function commandClick(t,e){t.preventDefault();let a,n=$(t.target).closest("tr"),i=n.closest("table"),o=this.dataItem(n),d=this.dataItem(n),l=$(i.find("tbody")[0]).children().index(n);a="Customized"==e.dataType||"CustomizedLink"==e.dataType||"GroupedButtons"==e.dataType?e.execute:generateBlocklyCall(e.blocklyInfo);let r=this.dataSource.transport.options.cronappDatasource,s=options.refComponent,c=[];if(s.select().each(function(){let e=s.dataItem(this);r.data.forEach(function(t){t.__$id==e.__$id&&c.push(t)})}),!(r.inserting||r.editing)){let e=t.currentTarget.parentElement.parentElement;this.select(e)}let p=[];options.fieldType&&"key"===options.fieldType?(d=helperDirective.changeObjectField(r,r.findObjInDs(d)),c.forEach(e=>{p.push(helperDirective.changeObjectField(r,r.findObjInDs(e)))})):p=c;let u={item:d,index:l},m={currentData:r.data,datasource:r.copyWithoutAngularObj(),selectedIndex:l,index:l,selectedRow:d,consolidated:u,item:d,selectedKeys:r.getKeyValues(r.findObjInDs(o),!0),selectedRows:p};return r.goTo(o),void scope.$eval(a,m)}var helperDirective=this,columns=[];return options.columns&&options.columns.forEach(function(t){let a=this.getWidthForDevice(t);if("Database"==t.dataType){var n={field:t.field,title:t.headerText,type:t.type,width:a.width,sortable:t.sortable,filterable:t.filterable,hidden:!a.visible};n.template=getTemplate(t),n.format=getFormat(t),n.editor=getEditor.bind(this)(t),n.aggregates=getAggregate(t),n.footerTemplate=getAggregateFooter(t,!1),n.groupFooterTemplate=getAggregateFooter(t,!0),n.groupHeaderTemplate=getAggregateHeader(t),n.attributes=getAttributes(t),n.headerAttributes=n.attributes,n.widthDevices=t.widthDevices,columns.push(n)}else if("Command"==t.dataType){if("no"!=options.editable){var i=t.command.split("|"),o=[];i.forEach(function(e){var t;t="edit"==e?getCommandForEditButtonDatabase.bind(this)(options,e):getCommandForRemoveButtonDatabase.bind(this)(options,e),o.push(t)}.bind(this));var n={command:o,title:t.headerText,width:a.width?a.width:155,hidden:!a.visible,attributes:getAttributes(t)};columns.push(n)}}else if("Blockly"==t.dataType||"Customized"==t.dataType||"CustomizedLink"==t.dataType){var d=null==t.label?"":t.label;t.iconClass&&d&&(d="&nbsp;"+d);var l="";l="CustomizedLink"==t.dataType?"k-custom-link":"k-custom-command"+(d?" k-button-with-label":""),t.theme&&(l+=" "+t.theme);var r="";if(t.tooltip&&t.tooltip.length&&(r=t.tooltip),r){var s=app.common.generateId();tooltips[s]=r,l+=" "+s}let e=app.common.generateId(),i=r||d||e,o=`<a href class='k-button ${l} k-grid-${e}' aria-label='${i}'><span class='${t.iconClass}'></span>${d}</a>`;var n={command:[{name:e,template:o,click:function(a){commandClick.bind(this)(a,t)}}],width:a.width,title:t.headerText?t.headerText:"",hidden:!a.visible,attributes:getAttributes(t)};columns.push(n),setIdCommandButton.bind(this)(e,t.dataType)}else if("GroupedButtons"==t.dataType){if(t.buttonColumns&&t.buttonColumns.length){let e=[];t.buttonColumns.forEach(function(a){let n=null==a.label?"":a.label;a.iconClass&&n&&(n="&nbsp;"+n);let i="k-custom-command"+(n?" k-button-with-label":"");a.theme&&(i+=" "+a.theme);let o="";if(a.tooltip&&a.tooltip.length&&(o=a.tooltip),o){let e=app.common.generateId();tooltips[e]=o,i+=" "+e}let d=app.common.generateId(),l=o||n||d,r=`<a href class='k-button ${i} k-grid-${d}' aria-label='${l}'><span class='${a.iconClass}'></span>${n}</a>`,s={name:d,template:r,click:function(n){a.dataType=t.dataType,commandClick.bind(this)(n,a)}};e.push(s)});var n={command:e,width:a.width,title:t.headerText?t.headerText:"",hidden:!a.visible,attributes:getAttributes(t)};columns.push(n),setIdCommandButton.bind(this)(app.common.generateId(),t.dataType)}}else if("Selectable"==t.dataType){var c={selectable:!0,attributes:getAttributes(t)};columns.push(c)}}.bind(this)),columns},getPageAble:function(e){var t={refresh:e.allowRefreshGrid,pageSizes:e.allowSelectionTotalPageToShow,buttonCount:5};return e.allowPaging||(t=e.allowPaging),t},getToolbar:function(e,t,a){function n(e){let t=e.security?`cronapp-security="${e.security}" class`:"class";e.template&&(e.template=e.template.split("class").join(t));let a={template:e.template};return a}var i=[];return e.toolBarButtons.forEach(function(o){if("Native"==o.type){if("no"==e.editable)("pdf"==o.title||"excel"==o.title)&&i.push(o.title);else if(("datasource"==e.editable||"popupCustom"==e.editable)&&"create"==o.title){var d=e.dataSourceScreen.name,l=e.popupInsert;o.methodCall=d+".startInserting();","popupCustom"==e.editable?o.methodCall=o.methodCall+" cronapi.screen.showModal('"+l+"');":o.methodCall+="cronapi.internal.focusFormInput();";var r=this.generateToolbarButtonCall(o,t,e,a);i.push(r),e.hideModalButtons||this.addButtonsInModal(l,d,t,e.enableModalSaveAdd)}else{let n=this.generateToolbarButtonCall(o,t,e,a);i.push(n)}}else if("Blockly"==o.type||"Customized"==o.type){var s=this.generateToolbarButtonCall(o,t,e,a);i.push(s)}else if("SaveOrCancelChanges"==o.type){if("no"!=e.editable){var c=this.generateToolbarButtonCall(o,t,e,a);i.push(c)}}else if("Template"==o.type||"Title"==o.type){let e=n(o);i.push(e)}}.bind(this)),0==i.length&&(i=void 0),i},getEditable:function(e){var t={mode:e.editable,confirmation:!1};return"batch"==e.editable?t=!0:("no"==e.editable||"popupCustom"==e.editable||"datasource"==e.editable)&&(t=!1),t},getTooltipsDefault:function(){var e={k_grid_edit:$translate.instant("Edit"),k_grid_delete:$translate.instant("Remove"),k_grid_update:$translate.instant("Save"),k_grid_cancel:$translate.instant("Cancel")};return e},setTooltips:function(e,t){for(var a in t){var n="."+a.replace(/_/g,"-");e.kendoTooltip({filter:n,content:function(a){var e=a.sender.options.filter.substr(1).replace(/-/g,"_");return t[e]}})}},generateKendoGridInit:function(t,a,n,i,o){function d(n){if(n.masterRow.find("a").hasClass("k-i-expand"))return void s(this,n.detailRow,n.masterRow);var e=this.dataSource.transport.options.cronappDatasource;e.inserting||e.editing?r(this,null,null):(this.selectable?(c.bind(this)(n.data),this.select(n.masterRow),void 0!==t.columns.find(e=>"Selectable"==e.dataType)&&r(this,n.detailRow,n.masterRow)):(c.bind(this)(n.data),r(this,n.detailRow,n.masterRow)),n.sender.options.listCurrentOptions.forEach(function(e){var t=l.generateKendoGridInit(e,a,void 0,void 0,o),i=$("<div/>"),d=i.appendTo(n.detailCell).kendoGrid(t).data("kendoGrid");app.kendoHelper.receivePushData(d),e.refComponent=d,window.addEventListener("resize",()=>{l.resizeGridUsingWidthForDevice(d)}),l.setTooltips(i,o)}))}var l=this,r=function(e,t,a){var n=e.table.find(".k-master-row");n.each(function(){(null==a||this!=a[0])&&e.collapseRow(this)});var i=e.table.find(".k-detail-row");i.each(function(){(null==t||this!=t[0])&&$(this).remove()})},s=function(e,t,a){var n=e.table.find(".k-master-row");n.each(function(){(null!=a||this==a[0])&&e.collapseRow(this)});var i=e.table.find(".k-detail-row");i.each(function(){(null!=t||this==t[0])&&$(this).remove()})},c=function(e){var t=this.dataSource.transport.options.cronappDatasource;t.inserting||t.editing||a.safeApply(t.goTo(e))},p=function(n){if(n.sender.tbody&&n.sender.tbody.length){var e=n.sender.tbody;$(n.sender.tbody).find(".k-grid-edit-row").length?e=$(n.sender.tbody).find("tr:not(.k-grid-edit-row)"):e.parent()&&e.parent().parent()&&e.parent().parent().parent()&&(e=e.parent().parent().parent()),a.safeApply(function(){var n=$(e),i=angular.element(n);$compile(i)(a),t.refComponent&&l.resizeGridUsingWidthForDevice(t.refComponent)})}},u=function(e){var t=!1;if(e.columns)for(var a=0;a<e.columns.length;a++)if("Database"==e.columns[a].dataType&&e.columns[a].filterable){t=!0;break}return t},m=function(e){var a,n=0;return t.columns.forEach(function(t){"Database"==t.dataType&&(n==e&&t.visible&&(a=t),t.visible&&n++)}),a},g=function(t){let e=t.workbook.sheets[0],n=/{{(.*?)}}/;for(let i,o=1;o<e.rows.length;o++){i=e.rows[o];for(let e,t=0;t<i.cells.length;t++){if(e=m(t),e&&i.cells[t].value instanceof Date){let a=new Date(i.cells[t].value.getTime());a.setMinutes(a.getMinutes()+a.getTimezoneOffset()),a.setSeconds(a.getSeconds()),i.cells[t].value=a,"time"==e.type?i.cells[t].format="[$-x-systime]hh:mm:ss":"datetime"==e.type&&(i.cells[t].format="dd/mm/yyyy hh:mm:ss;@")}if(("footer"===i.type||"group-footer"===i.type)&&i.cells[t].value){let e=i.cells[t].value,o=$(e)[0].innerHTML,d=n.exec(o);if(d&&1<d.length){o=o.replace(d[0],"");let e=a.$eval(d[1]);i.cells[t].value=`${o}${e}`}}}}},f=app.kendoHelper.getDataSource(t.dataSourceScreen.entityDataSource,a,t.allowPaging,t.pageCount,t.columns,t.groupings),h=this.getColumns(t,f,a,o,i),v=this.getPageAble(t),b=this.getToolbar(t,a,i),y=this.getEditable(t),k=u(t),C={hasSecurity:t.columns.filter(e=>e.security).length,toolbar:b,pdf:{allPages:!0,avoidLinks:!0,paperSize:"A4",margin:{top:"2cm",left:"1cm",right:"1cm",bottom:"1cm"},landscape:!0,repeatHeaders:!0,scale:.8},dataSource:f,editable:y,height:t.height,groupable:t.allowGrouping,sortable:t.allowSorting,filterable:!0,pageable:v,columns:h,selectable:t.allowSelectionRow,detailInit:t.details&&0<t.details.length?d:void 0,listCurrentOptions:t.details&&0<t.details.length?t.details:void 0,excelExport:g,edit:function(t){this.dataSource.transport.options.disableAndSelect(t);var e=t.container,n=this.dataSource.transport.options.cronappDatasource;if(t.model.isNew()){var o=t.model;n.startInserting(null,function(t){for(var a in t)if(o.fields[a]){if(o.fields[a].validation&&o.fields[a].validation.required){var n=e.find("input[name='"+a+"']");n.length&&n.val(t[a]).trigger("change")}o.set(a,t[a])}})}else t.model.isNew()||t.model.dirty||a.safeApply(function(){var e=n.goTo(t.model);n.startEditing(e,function(e){})});i&&i.ngEdit&&a.$eval(i.ngEdit),p(t)},change:function(o){var e=this.dataItem(this.select());(t.details&&0==t.details.length||!cronapi.internal.hasMethodInCallStack("detailInit"))&&c.bind(this)(e);var d=this.dataSource.transport.options.cronappDatasource;t.fieldType&&"key"===t.fieldType&&(d.active=l.changeObjectField(d,d.active));let s=this.select().next(),u=this.select();if(n)if("multiple"===t.allowSelectionRowType){let e=[];s=[],u=[],this.select().each((a,n)=>{let i=this.dataItem(n),o=d.findObjInDs(i,!1);t.fieldType&&"key"===t.fieldType&&(o=l.changeObjectField(d,o)),null!==o&&e.push(o),i._objectKey===d.active._objectKey&&(u.push(this.select()[a]),s.push(this.select().next()[a]))}),n.$setViewValue(e)}else e?n.$setViewValue(d.active):n.$setViewValue(null);r(this,s,u),i&&i.ngChange&&a.$eval(i.ngChange),p(o),$(".k-command-cell a[class*='k-grid-']").each((e,t)=>{let a=$(t);if(!a.attr("id")){let e=this.dataItem(a.closest("tr")),t="destroy";a.hasClass("k-grid-update")?t="update":a.hasClass("k-grid-cancel")?t="cancel":a.hasClass("k-grid-edit")&&(t="edit");let n=l.getModelName(i);if(e&&e._objectKey){let i=e._objectKey,o=`${n}-${t}-${i}`;a.attr("id",o)}}})},cancel:function(t){var e=this.dataSource.transport.options.cronappDatasource;a.safeApply(e.cancel()),this.dataSource.transport.options.enableAndSelect(t),setTimeout(function(){i&&i.ngCancel&&a.$eval(i.ngCancel),p(t)}.bind(this))},dataBound:function(n){setTimeout(()=>this.dataSource.transport.options.selectActiveInGrid(),100),i&&i.ngDataBound&&a.$eval(i.ngDataBound);for(let e,a=0;a<this.columns.length;a++)e=l.getColumnByField(t,this.columns[a].field),e.visible&&this.showColumn(a);0==$("div.k-grouping-header").length?t.groupings&&t.groupings.forEach(e=>this.hideColumn(e.field)):$("div.k-group-indicator").each((e,t)=>{this.hideColumn($(t).data("field"))});let e=this;setTimeout(function(){e.pager&&e.pager.element.find("a").not(".k-state-disabled").attr("tabindex","0")}),p(n)}};return C.selectable&&"multiple"==t.allowSelectionRowType&&(C.selectable="multiple"),C.originalSelectable=C.selectable,i&&i.ngBeforeEdit&&(C.beforeEdit=function(t){a.$eval(i.ngBeforeEdit)}),i&&i.ngDataBinding&&(C.dataBinding=function(t){a.$eval(i.ngDataBinding)}),i&&i.ngSave&&(C.save=function(t){a.$eval(i.ngSave)}),i&&i.ngSaveChanges&&(C.saveChanges=function(t){a.$eval(i.ngSaveChanges)}),i&&i.ngRemove&&(C.remove=function(t){a.$eval(i.ngRemove)}),C},link:function(e,t,a,n){if(t.children().length)return;var i=$("<div></div>"),o="node_modules/cronapp-lib-js/dist/js/kendo-ui/js/messages/kendo.messages.";o+="pt_br"==$translate.use()?"pt-BR.min.js":"en-US.min.js",this.initCulture();var d=this;$.getScript(o,function(){var t=JSON.parse(a.options||"{}");app.kendoHelper.getCorrectlyDS(t.dataSourceScreen.entityDataSource.name,e).batchPost=!1;var o=t.batchMode==null||t.batchMode;o&&"datasource"!=t.editable&&app.kendoHelper.getCorrectlyDS(t.dataSourceScreen.entityDataSource.name,e)&&!app.kendoHelper.getCorrectlyDS(t.dataSourceScreen.entityDataSource.name,e).dependentLazyPost&&(app.kendoHelper.getCorrectlyDS(t.dataSourceScreen.entityDataSource.name,e).batchPost=!0,t.toolBarButtons=t.toolBarButtons||[],t.toolBarButtons.push({type:"SaveOrCancelChanges",title:$translate.instant("SaveChanges"),methodCall:t.dataSourceScreen.entityDataSource.name+".postBatchData()",saveButton:!0}),t.toolBarButtons.push({type:"SaveOrCancelChanges",title:$translate.instant("CancelChanges"),methodCall:t.dataSourceScreen.entityDataSource.name+".cancelBatchData()",saveButton:!1}));var l=d.getTooltipsDefault(),r=d.generateKendoGridInit(t,e,n,a,l);r.scrollable="true"===a.scrollable;var s=i.kendoGrid(r).data("kendoGrid");app.kendoHelper.receivePushData(s),t.refComponent=s,window.addEventListener("resize",()=>{d.resizeGridUsingWidthForDevice(s)}),d.setTooltips(i,l),e.safeApply(function(){app.kendoHelper.getCorrectlyDS(t.dataSourceScreen.entityDataSource.name,e)&&(i.find(".k-filter-row").show(),i.find(".k-pager-sizes").show(),i.find(".k-pager-nav").show(),i.find(".k-pager-numbers").show(),i.find(".k-pager-refresh.k-link").show(),i.find(".saveorcancelchanges").hide(),app.kendoHelper.getCorrectlyDS(t.dataSourceScreen.entityDataSource.name,e).addDataSourceEvents({pendingchanges:function(e){e?(i.find(".k-filter-row").hide(),i.find(".k-pager-sizes").hide(),i.find(".k-pager-nav").hide(),i.find(".k-pager-numbers").hide(),i.find(".k-pager-refresh.k-link").hide(),i.find(".saveorcancelchanges").show()):(i.find(".k-filter-row").show(),i.find(".k-pager-sizes").show(),i.find(".k-pager-nav").show(),i.find(".k-pager-numbers").show(),i.find(".k-pager-refresh.k-link").show(),i.find(".saveorcancelchanges").hide())}}),app.kendoHelper.getCorrectlyDS(t.dataSourceScreen.entityDataSource.name,e).addDataSourceEvents({afterchanges:function(e){}}))}),s.selectable.userEvents.unbind("select")});let l=app.common.generateId(),r=app.common.generateId(),s=app.common.generateId(),c=$(`<ul id="${l}">
38
+ <li id="copyText">
39
+ <input id="${r}">
40
+ <span id="${s}" class="k-icon k-i-close" style="margin-left: 5px;"></span>
41
+ </li>
42
+ </ul>`);t.html(i),t.append(c),$compile(i)(t.scope());let p=$(`#${l}`).kendoContextMenu({target:i,filter:"td",close:t=>{closeContextMenu||t.preventDefault()},open:t=>{let e=t.target,a=$(e).parent()[0],n=i.data("kendoGrid"),o=t.item.id,d=e.innerText;if(d.length&&"\u200B"!==d)$(t.item).find(`#${r}`).val(d),closeContextMenu=!1;else{let e=()=>new Promise((e,t)=>{let a=setInterval(()=>{$(`#${l}`).is(":visible")&&(clearInterval(a),$(`#${l}`).hide())})});e()}}}).data("kendoContextMenu");$(`#${s}`).on("click",t=>{closeContextMenu=!0,p.close()})}}}]).directive("src",["$compile",function(e){return{restrict:"A",link:function(e,t,a,n){"IMG"===t[0].tagName&&cronapi.internal.isBase64(a.src)&&setTimeout(()=>$(t[0]).attr("src","data:image/png;base64,"+a.src))}}}]).directive("crnSkin",["$compile","$http",function(e,t){return{restrict:"A",link:function(e,a,n,i){n.crnSkin&&t.get(n.crnSkin,{cache:!0}).then(e=>{if(e.data){let t=e.data;t.startsWith(":root{")&&(t=t.substring(6)),t.endsWith("}")&&(t=t.substring(0,t.length-2)),$element=$(a);let n=$element.find("[data-role=\"grid\"]");n.length&&($element=n);let i=$element.attr("style")||"";i&&(i+=", "),i+=t,$element.attr("style",i)}})}}}]).directive("cronTreeView",["$compile","$translate",function($compile,$translate){return{restrict:"E",replace:!0,require:"ngModel",scope:!0,getDataSource:function(options,scope,ngModelCtrl){let id=options.dataSourceScreen.schema.filter(e=>!0===e.key)[0].name,schema={model:{id:id,hasChildren:function(e){return e.hasChildren}}},getAllParent=function(e,t,a,n,i){t[schema.model.id]&&a.push(t[schema.model.id]);let o=`${e.entity}?$filter=${schema.model.id} eq '${t[options.selfRelationshipField]}'&$format=json&$inlinecount=allpages`;t[options.selfRelationshipField]?$.ajax({url:o,success:t=>{getAllParent(e,t.d.results[0],a,n,i)},beforeSend:e=>{window.isUsingCookie()||e.setRequestHeader("X-AUTH-TOKEN",cronapi.util.getUserToken())},error:()=>i(),type:"GET"}):n(a)},reloadAndExpand=function(e){let t=()=>{let t=new Promise((t,a)=>{getAllParent(this.options.cronappDatasource,e,[],t,a)});t.then(e=>{this.options.kendoObj.expandPath(e.reverse())})};this.options.kendoObj.dataSource.bind("requestEnd",t),this.options.kendoObj.dataSource.read()},helperDirective=this,waitingPromise=!1,datasource=new kendo.data.HierarchicalDataSource({transport:{push:async function(e){let t=await this.options.cronappDatasource();!helperDirective.dataSourceEventsPush&&t&&(helperDirective.dataSourceEventsPush={create:function(e){reloadAndExpand.bind(this)(e)}.bind(this),update:function(e){reloadAndExpand.bind(this)(e)}.bind(this),delete:function(e){reloadAndExpand.bind(this)(e),ngModelCtrl.$setViewValue(null)}.bind(this),overRideRefresh:function(e){this.options.fromRefresh=!0,this.options.kendoObj.dataSource.read(),ngModelCtrl.$setViewValue(null)}.bind(this),read:function(e){waitingPromise||(this.options.kendoObj.dataSource.read(),ngModelCtrl.$setViewValue(null))}.bind(this)},t.addDataSourceEvents(helperDirective.dataSourceEventsPush))},read:async function(e){let cronappDatasource=await this.options.cronappDatasource(),conditionIsEmpty=e=>{let t=!0;if(e){let a=JSON.parse(e);a.expression&&a.expression.args&&a.expression.args.forEach(e=>{""!==e.right&&"''"!==e.right&&e.right!==void 0&&(t=!1)})}return t};for(key in e.data)null==e.data[key]&&delete e.data[key];let logicFilter={filter:{logic:"and",filters:[]}};for(let t in e.data){let a={field:options.selfRelationshipField,operator:"eq",value:e.data[t]};logicFilter.filter.filters.push(a)}let condition=cronappDatasource.condition,conditionEmpty=conditionIsEmpty(condition),paramsOData={$inlinecount:"allpages",$format:"json",$filter:`${options.selfRelationshipField} eq null`};logicFilter.filter.filters.length?(cronappDatasource.condition="",paramsOData=kendo.data.transports.odata.parameterMap(logicFilter,"read")):this.options.fromRefresh&&(this.options.fromRefresh=!1,!conditionEmpty&&(cronappDatasource.cleanup(),paramsOData={$inlinecount:"allpages",$format:"json"})),cronappDatasource.rowsPerPage=e.data.pageSize,cronappDatasource.offset=e.data.page-1;let fetchData={};fetchData.params=paramsOData,helperKendoDs=this,cronappDatasource.fetch(fetchData,{success:function(data){let all=data.map(item=>{let odataUrl=`${this.entity}/$count?$filter=${options.selfRelationshipField} eq '${item[schema.model.id]}'`;return new Promise((resolve,reject)=>{$.ajax({url:odataUrl,success:count=>{item.hasChildren=0<eval(count),resolve()},beforeSend:e=>{window.isUsingCookie()||e.setRequestHeader("X-AUTH-TOKEN",cronapi.util.getUserToken())},error:()=>reject(),type:"GET"})})});waitingPromise=!0,Promise.all(all).then(()=>{e.success(data),waitingPromise=!1})},canceled:function(t){e.error("canceled","canceled","canceled")}},!0),condition&&(cronappDatasource.condition=condition)},options:{fromRead:!1,cronappDatasource:async()=>await app.kendoHelper.getCorrectlyDSPromise(options.dataSourceScreen.name,scope)}},schema:schema});return datasource},link:function(t,a,n,i){let o=$("<div></div>"),d=JSON.parse(n.options),l=this,r=function(e,t){t=e.getKeyValues(t);var a=Object.keys(t);return 1===a.length&&(t=t[a]),t},s=o.kendoTreeView({dataSource:l.getDataSource(d,t,i),dataTextField:d.textField,dataImageUrlField:d.imageUrlField,change:async function(a){let e=this.dataItem(this.select()),n=await this.dataSource.transport.options.cronappDatasource();t.safeApply(n.goTo(e)),d.fieldType&&"key"===d.fieldType&&(n.active=r(n,n.active)),i.$setViewValue(n.active)}}).data("kendoTreeView");s.dataSource.transport.options.kendoObj=s,a.html(o),$compile(o)(a.scope())}}}]).directive("cronSelect",["$compile",function(e){return{restrict:"E",replace:!0,require:"ngModel",link:async function(t,a,n,i){var o={};try{o=JSON.parse(n.options)}catch(e){console.log("ComboBox invalid configuration! "+e)}var d=n.id?" id=\""+n.id+"\"":"",e=n.name?" name=\""+n.name+"\"":"",l=a.parent();$(l).append("<input style=\"width: 100%;\" "+d+e+" class=\"cronSelect\"/>");var r=$(l).find("input.cronSelect"),s=await app.kendoHelper.getConfigCombobox(o,t);s.close=n.ngClose?function(){t.$eval(n.ngClose)}:void 0,s.dataBound=n.ngDataBound?function(){t.$eval(n.ngDataBound)}:void 0,s.filtering=n.ngFiltering?function(){t.$eval(n.ngFiltering)}:void 0,s.select=n.ngSelect?function(a){t.safeApply(()=>{var e={selected:a.dataItem,selectedKey:a.dataItem[s.dataValueField],selectedValue:a.dataItem[s.dataTextField]};t.$eval(n.ngSelect,e)})}:void 0,s.change=n.ngChange?function(a){var e=this.dataItem();t.safeApply(()=>{n.ngModel&&g.$$parse(n.ngModel).assign(t,this.value(),n.ngModel.split("."));var a={selected:e,selectedKey:e[s.dataValueField],selectedValue:e[s.dataTextField]};t.$eval(n.ngChange,a)})}:function(a){t.safeApply(()=>{n.ngModel&&g.$$parse(n.ngModel).assign(t,this.value(),n.ngModel.split("."))})},s.messages={noData:n.noResultsMessage?n.noResultsMessage:"NO DATA FOUND"};var c;if(!0===o.dontAllowOutsideList){c=r.kendoDropDownList(s).data("kendoDropDownList");let e=l.find("span").first();e.on("focus",()=>cronapi.internal.selectContent(e.find(".k-input")[0]))}else c=r.kendoComboBox(s).data("kendoComboBox");$(a).remove();let p,u=()=>{if(p=$(l).find(".k-input.cronSelect"),p.length){p.attr("ng-required",n.ngRequired),"true"===n.ngRequired&&p.attr("required","required"),p.attr("ng-model",n.ngModel),p.attr("id",n.id),p.attr("validationmessage",n.validationmessage);let e=p.parent();p.on("change",()=>{"true"===n.ngRequired&&(0==p.val().length?(e.addClass("ng-invalid-required"),p.addClass("ng-invalid-required")):(e.removeClass("ng-invalid-required"),p.removeClass("ng-invalid-required")))})}else setTimeout(()=>u())};u(),t.$watch(n.cronDisabled,function(e){c.enable(!e)});var m=t,g=i;i&&(i.$formatters.push(function(e){var t="";return("boolean"==typeof e||e)&&(t=e),c.value(t),t}),i.$parsers.push(function(e){return p&&p.trigger("change"),"boolean"==typeof e||e?e:null}))}}}]).directive("cronDynamicSelect",["$compile","$timeout","$parse","$translate","$log",function($compile,$timeout,$parse,$translate,$log){return{restrict:"E",replace:!0,require:"?ngModel",goTo:function(e,t,a){if(dataSourceScreen=$(t).data("dataSourceScreen"),null!=dataSourceScreen)return dataSourceScreen.goTo(a,!0)},compileAngular:function(e,t){var a=$(t),n=angular.element(a);$compile(n)(e)},getActive:function(active){if(active&&active.indexOf(".active."))try{return eval(active.substr(0,active.indexOf(".active.")))}catch(t){}return null},getFieldText:function(e,t){if(e&&e.indexOf(".active.")&&t.dataTextField)try{var a=e.substr(e.indexOf(".active.")+8);return a+"_"+t.dataTextField}catch(t){}return null},isDefaultEntity:function(e){if(e&&e.entity){var t=e.entity.split("/");if(t&&0<t.length)return-1==t.pop().indexOf("query")}return!1},getModelParent:function(e){if("string"==typeof e&&9<e.length&&0<e.indexOf("|raw}}")){e=e.trim();var t=e.substr(e.indexOf("{{")+2);return t=t.substr(0,t.indexOf("|raw}}")),t.trim()}return null},toComboType:function(e,t,a,n){let i=t.find("span").first();switch(i.on("focus",()=>cronapi.internal.selectContent(i.find("span.ng-scope")[0])),a.type){case"autoComplete":let t=["Tab","Shift","CapsLock","Control","Alt","Escape","PageDown","PageUp","Backspace","ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Delete","Insert","Enter"," "],o=["Tab","Shift","CapsLock","Control","Alt","Escape","PageDown","PageUp","ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Insert"];i.attr("contenteditable","true");let d=$(`input[aria-owns=${e.id}_listbox]`),l=d.parent(),r=$(`#${e.id}-list`);l.hide(),i.on("keyup",a=>{document.activeElement!==i[0]||o.includes(a.originalEvent.key)||d.val(i.find("span.ng-scope").text()),i.hasClass("k-state-border-down")||t.includes(a.originalEvent.key)||i.trigger("click")}),i.on("focusout",()=>{r.is(":visible")||s()}),i.on("click",()=>c());let s=()=>{i.find("span.ng-scope").text(n.dataItem()[a.dataTextField]),n.search()},c=()=>{let e=setInterval(()=>{r.is(":visible")||(clearInterval(e),document.activeElement!==i[0]&&s())})};break;default:i.on("keydown",t=>{if("ArrowDown"===t.originalEvent.key||"ArrowUp"===t.originalEvent.key)return t.stopImmediatePropagation(),void i.trigger("click")})}},link:async function(scope,element,attrs,ngModelCtrl){await cronapi.internal.skipIterationLoop();var modelGetter=$parse(attrs.ngModel),modelSetter=(e,t)=>{$log.debug("modelSetter | "+attrs.id+" | "+t),modelGetter.assign(e,t)},select={},self=this,parentDS={},textField=null;try{select=JSON.parse(attrs.options),parentDS=this.getActive(attrs.ngModel),textField=this.getFieldText(attrs.ngModel,select)}catch(e){console.log("DynamicComboBox invalid configuration! "+e)}let lastFieldInModel=attrs.ngModel.split(".");lastFieldInModel=lastFieldInModel[lastFieldInModel.length-1];let modelForTextField=attrs.ngModel.replace(lastFieldInModel,textField),modelTextFieldGetter=$parse(modelForTextField),modelTextFieldSetter=modelTextFieldGetter.assign;var options=await app.kendoHelper.getConfigCombobox(select,scope);options.autoBind=!0;var dataSourceScreen=null;try{delete options.dataSource.schema.model.id,dataSourceScreen=eval(select.dataSourceScreen.name),dataSourceScreen.rowsPerPage=dataSourceScreen.rowsPerPage?dataSourceScreen.rowsPerPage:100,options.dataSource.transport.origin="combobox"}catch(t){}var _scope=scope,_goTo=this.goTo,_compileAngular=this.compileAngular;options.virtual={},options.virtual.itemHeight=26;let lastValueMapper;if(options.dataSource.pageSize&&0<options.dataSource.pageSize){options.height=options.dataSource.pageSize*options.virtual.itemHeight/4,options.virtual.mapValueTo="dataItem";var _options=options;let e=()=>new Promise(e=>{let t;_options.combobox?e():t=setInterval(()=>{_options.combobox&&(clearInterval(t),e())})});options.virtual.valueMapper=async function(t){await e(),$log.debug("valueMapper | "+attrs.id+" | "+t.value),lastValueMapper&&!lastValueMapper.completed&&($log.debug("valueMapper Canceling | "+lastValueMapper.value),lastValueMapper.canceled=!0),lastValueMapper=t;var a=_options.combobox;if(t.canceled)return void $log.debug("valueMapper CANCELED | "+t.value);if(!(t.value||""===t.value))$log.debug("valueMapper.success | "+attrs.id+" | NULL"),t.success(null);else if(null!==a.options.optionLabel[a.options.dataValueField]&&""===t.value)t.completed=!0,$log.debug("valueMapper.success | "+attrs.id+" | NULL"),t.success(null);else{a.isEvaluating=!0;var n=_options.dataSource.transport.options.cronappDatasource;void 0===t.value||null===t.value||""===t.value?(t.completed=!0,$log.debug("valueMapper.success | "+attrs.id+" | NULL"),t.success(null),a.isEvaluating=!1):($log.debug("valueMapper.findObj | "+attrs.id+" | "+t.value),n.findObj([t.value],!1,function(e){return t.completed=!0,t.canceled?($log.debug("valueMapper CANCELED | "+t.value),void(a.isEvaluating=!1)):void(Array.isArray(e)&&(e=e[0]),$log.debug("valueMapper.success | "+attrs.id+" | "+e),t.success(e),a.isEvaluating=!1,select.changeCursor?scope.safeApply(function(){if(t.canceled)return void $log.debug("valueMapper CANCELED | "+t.value);if(null!=e){var i=_goTo(_scope,a,e);i||(n.data.push(e),i=_goTo(_scope,a,e)),i&&modelSetter(_scope,i[select.dataValueField])}else modelSetter(_scope,null)}):null==e&&modelSetter(_scope,null))},function(){return t.completed=!0,t.canceled?($log.debug("valueMapper CANCELED | "+t.value),void(a.isEvaluating=!1)):void($log.debug("valueMapper.success | "+attrs.id+" | NULL"),t.success(null),a.isEvaluating=!1)},[combobox.options.dataValueField]))}}}options.messages={noData:attrs.noResultsMessage?attrs.noResultsMessage:"NO DATA FOUND"},options.change=attrs.ngChange?function(t){var e=this.dataItem();scope.safeApply(()=>{var t={selected:e,selectedKey:e[options.dataValueField],selectedValue:e[options.dataTextField]};scope.$eval(attrs.ngChange,t)})}:void 0,options.close=attrs.ngClose?function(){scope.$eval(attrs.ngClose)}:void 0,options.dataBound=attrs.ngDataBound?function(){scope.$eval(attrs.ngDataBound)}:void 0,options.filtering=attrs.ngFiltering?function(){scope.$eval(attrs.ngFiltering)}:void 0,options.open=function(t){dataSourceScreen.fetched&&dataSourceScreen.lastLoadedTime===combobox.dataSource.lastLoadedTime||(combobox.options.firstLazyRead=!0,combobox.dataSource.read(),combobox.dataSource.lastLoadedTime=dataSourceScreen.lastLoadedTime)},options.select=attrs.ngSelect?function(t){scope.safeApply(()=>{var e={selected:t.dataItem,selectedKey:t.dataItem[options.dataValueField],selectedValue:t.dataItem[options.dataTextField]};scope.$eval(attrs.ngSelect,e)})}:void 0;var parent=element.parent(),id=attrs.id?" id=\""+attrs.id+"\"":"",name=attrs.name?" name=\""+attrs.name+"\"":"",validationmessage=attrs.validationmessage?" validationmessage=\""+attrs.validationmessage+"\"":"",inputSelect=$("<input style=\"width: 100%;\""+id+name+validationmessage+" class=\"cronDynamicSelect\" ng-model=\""+attrs.ngModel+"\"/>");attrs.$observe("required",function(e){inputSelect.prop("required",e)}),$(parent).append(inputSelect);var $element=$(parent).find("input.cronDynamicSelect");dataSourceScreen&&(dataSourceScreen.__ignoreFirstFetch=!0);var combobox=$element.kendoDropDownList(options).data("kendoDropDownList");options.combobox=combobox,$(combobox.element[0]).attr("tabindex","-1"),null!=dataSourceScreen&&null!=dataSourceScreen&&$(combobox).data("dataSourceScreen",dataSourceScreen),(attrs.ngRequired||attrs.required)&&($(combobox.element[0]).attr("style",""),$(combobox.element[0]).attr("class","cron-select-offscreen")),$(combobox.wrapper).children(".k-dropdown-wrap").children(".k-select").before(inputSelect),this.toComboType(attrs,parent,select,combobox);let forcedRefreshModelAt,canRefresh=()=>{let e=performance.now();return!forcedRefreshModelAt||2e3<e-forcedRefreshModelAt};var forceChangeModel=async function(e){$log.debug("forceChangeModel | "+attrs.id+" | "+e),void 0===e&&(e=null);let t=combobox.value();t=void 0!==t&&null!==t?t.trim():t;let a=void 0!==e&&null!==e?(""+e).trim():e;a!==t&&(await combobox.value(e)),select.changeCursor&&scope.safeApply(()=>{null==e||null==e?(dataSourceScreen.active={},dataSourceScreen.cursor=-1,modelSetter(_scope,null)):_goTo(_scope,combobox,combobox.dataItem())})};let returnTypedValue=e=>{if(dataSourceScreen.schema){let t=dataSourceScreen.schema.find(e=>e.name===options.dataValueField);t&&"String"!==t.type&&(e=parseFloat(e)||e)}return e};var defineInitialValue=function(){if(!combobox.definingInitialValue)if(!combobox.isEvaluating){var e=returnTypedValue(combobox.value()),t=null,a=dataSourceScreen.goTo(e);a||((combobox.options.lazyFirstInitialValue||!dataSourceScreen.lazy)&&null!=select.initValue&&null!=select.initValue&&(combobox.options.lazyFirstInitialValue=!1,a=dataSourceScreen.goTo(select.initValue),a&&(t=select.initValue)),null==t&&select.firstValue?dataSourceScreen&&(combobox.definingInitialValue=!0,dataSourceScreen.fetch({params:{$top:1}},{success:function(e){e.length&&(dataSourceScreen.data.push(e[0]),t=e[0][select.dataValueField]),modelSetter(_scope,t),forceChangeModel(t),combobox.definingInitialValue=!1},error:function(){combobox.definingInitialValue=!1},canceled:function(){combobox.definingInitialValue=!1}},void 0,{lookup:!0})):(modelSetter(_scope,t),forceChangeModel(t),combobox.definingInitialValue=!1))}else setTimeout(()=>defineInitialValue(),300)},_ngModelCtrl=ngModelCtrl;null!=dataSourceScreen&&null!=dataSourceScreen&&dataSourceScreen.addDataSourceEvents({overRideRefresh:function(){dataSourceScreen.fetched=!1,dataSourceScreen.cleanup(),canRefresh()&&defineInitialValue()}});var _isDefaultEntity=this.isDefaultEntity;if($element.on("change",function(event){let applyChange=function(){return combobox.isEvaluating?void setTimeout(applyChange,100):void _scope.$apply(function(){if(modelSetter(_scope,combobox.dataItem()[select.dataValueField]),modelTextFieldSetter(_scope,combobox.dataItem()[select.dataTextField]),select.changeValueBasedOnLabel){let comboLabelValue=combobox.dataItem()[select.dataTextField];try{eval(select.changeValueBasedOnLabel+"=\""+comboLabelValue+"\"")}catch(t){try{_scope.$eval(select.changeValueBasedOnLabel+"=\""+comboLabelValue+"\"")}catch(t){console.error("N\xE3o foi poss\xEDvel atribuir o texto do combobox ",comboLabelValue," no compo informado ",select.changeValueBasedOnLabel)}}}_compileAngular(scope,options.combobox.element[0])})};applyChange()}),ngModelCtrl&&(ngModelCtrl.$formatters.push(function(e){$log.debug("$formatters | "+attrs.id+" | "+e);var t=combobox.value();return(void 0===e||""===e&&void 0===select.optionLabelValue)&&(e=null,modelSetter(_scope,e)),forceChangeModel(e),e}),ngModelCtrl.$parsers.push(function(e){if($log.debug("$parsers | "+attrs.id+" | "+e),"boolean"==typeof e||e)if(!0===combobox.options.valuePrimitive){if("string"==typeof e)return e;if("boolean"==typeof e[select.dataValueField]||e[select.dataValueField])return e[select.dataValueField]}else try{return objectClone(e,combobox.dataSource.options.schema.model.fields)}catch(t){}return null})),!select.initValue)select.initValue=null;else if(select.initValue.startsWith("params.")){var type=combobox.dataSource.options.schema.model.fields[select.dataValueField].type;select.initValue=scope.$eval(select.initValue),"string"!=type&&(select.initValue=dataSourceScreen.normalizeValue(select.initValue,!0))}else select.initValue=scope.$eval(select.initValue);""==select.initValue&&(select.initValue=null),combobox.dataSource.transport&&combobox.dataSource.transport.options&&(combobox.dataSource.transport.options.combobox=combobox,combobox.dataSource.transport.options.$compile=$compile,combobox.dataSource.transport.options.scope=scope,combobox.dataSource.transport.options.ngModelCtrl=ngModelCtrl,combobox.dataSource.transport.options.initRead=!0,null!=select.initValue&&null!=select.initValue?(setTimeout(()=>{modelSetter(_scope,select.initValue)},0),combobox.options.lazyFirstInitialValue=!0):select.firstValue&&defineInitialValue()),$(combobox.span).on("DOMSubtreeModified",function(t){_compileAngular(scope,t.target)}),$(combobox.ul).on("DOMSubtreeModified",function(t){$timeout(function(){_compileAngular(scope,t.target)})}),_compileAngular(scope,combobox.span),_compileAngular(scope,combobox.ul),$(element).remove(),scope.$watch(attrs.cronDisabled,function(e){combobox.enable(!e)}),$("[aria-owns='"+`${attrs.id}_listbox`+"']").attr("aria-label",$translate.instant("template.crud.search")),ngModelCtrl.$modelValue&&(_scope.cronapi.internal.forceRefreshNgModel(attrs.ngModel,ngModelCtrl.$modelValue),forcedRefreshModelAt=performance.now())}}}]).directive("cronMultiSelect",["$compile","$parse",function($compile,$parse){return{restrict:"E",require:"ngModel",link:async function(scope,element,attrs,ngModelCtrl){var modelGetter=$parse(attrs.ngModel),modelSetter=modelGetter.assign,model=attrs.ngModel,_self=this,select={};try{select=JSON.parse(attrs.options)}catch(e){console.log("MultiSelect invalid configuration! "+e)}var _scope=scope,_ngModelCtrl=ngModelCtrl,relactionDS={relationDataSource:null==select.relationDataSource?null:eval(select.relationDataSource.name),relationField:null==select.relationField?"":select.relationField},options=await app.kendoHelper.getConfigCombobox(select,scope);try{delete options.dataSource.schema.model.id}catch(t){}var parent=element.parent(),id=attrs.id?" id=\""+attrs.id+"\"":"",name=attrs.name?" name=\""+attrs.name+"\"":"";let required=attrs.ngRequired&&eval(attrs.ngRequired)?`required="required"`:"";$(parent).append(`<div style="width: 100%;"> <input style="width: 100%;" ${id} ${name} ${required} class="cronMultiSelect" ng-model="${attrs.ngModel}"/> </div>`),$(parent).find("label").attr("for",attrs.id);let $inp=$(`${attrs.id}`);$compile($inp)(scope);var $element=$(parent).find("input.cronMultiSelect");$(element).remove();var evtSelect,deselect;options.deselect=function(e){var dataItem=e.dataItem,relation=this.relationDataSource,dataValueField=e.sender.options.dataValueField,selectItem=null;if(relation&&relation.data&&dataItem[dataValueField]){for(key in relation.data){var item=relation.data[key];if(item[this.relationField]&&item[this.relationField]==dataItem[dataValueField]){selectItem=item;break}}null!=selectItem&&($(combobox).data("silent",!0),this.relationDataSource.removeSilent(selectItem,null,null))}else model&&_scope.$apply(function(){try{var data=eval("_scope."+model);data=data.filter(e=>"object"==typeof e?e[dataValueField]!==dataItem[dataValueField]:e!==dataItem[dataValueField]),$(combobox).data("silent",!0),modelSetter(_scope,data)}catch(t){}});deselect&&deselect()}.bind(relactionDS),options.select=function(e){var dataItem=e.dataItem,dataValueField=e.sender.options.dataValueField,combobox=e.sender;if(this.relationDataSource&&dataItem[dataValueField]){var obj={};obj[this.relationField]=dataItem[dataValueField],$(combobox).data("silent",!0),this.relationDataSource.startInserting(obj,function(e){this.postSilent()}.bind(this.relationDataSource))}else model&&_scope.$apply(function(){try{var data=eval("_scope."+model);if(data||(data=[]),select.fieldType&&"key"===select.fieldType){var keyValues=combobox.dataSource.options.transport.options.cronappDatasource.getKeyValues(dataItem),keys=Object.keys(keyValues);1===keys.length&&(keyValues=keyValues[keys]),data.push(keyValues)}else data.push(objectClone(dataItem,combobox.dataSource.options.schema.model.fields));$(combobox).data("silent",!0),modelSetter(_scope,data)}catch(t){}});evtSelect&&evtSelect()}.bind(relactionDS);var hideSelectedItem="true"==attrs.crnHideSelectedItem,onSelectedItem=()=>{hideSelectedItem&&combobox.list&&0<combobox.list.length&&(combobox.list.find(".k-item").show(),combobox.list.find(".k-item.k-state-selected").hide())};options.change=attrs.ngChange?function(){_scope.$eval(attrs.ngChange)}:void 0,options.close=attrs.ngClose?function(){_scope.$eval(attrs.ngClose)}:void 0,options.dataBound=attrs.ngDatabound?function(){_scope.$eval(attrs.ngDatabound)}:void 0,options.filtering=attrs.ngFiltering?function(){_scope.$eval(attrs.ngFiltering)}:void 0,options.open=attrs.ngOpen?function(){_scope.$eval(attrs.ngOpen),onSelectedItem()}:onSelectedItem,options.cascade=attrs.ngCascade?function(){_scope.$eval(attrs.ngCascade)}:void 0,evtSelect=attrs.ngSelect?function(){_scope.$eval(attrs.ngSelect)}:void 0,deselect=attrs.ngDeselect?function(){_scope.$eval(attrs.ngDeselect)}:void 0;var combobox=$element.kendoMultiSelect(options).data("kendoMultiSelect");scope.$watch(attrs.cronDisabled,function(e){combobox.enable(!e)}),app.kendoHelper.receivePushData(combobox),$("[aria-describedby='"+`${attrs.id}_taglist`+"']").attr("id",`${attrs.id}-container`),attrs.crnReadonly&&_scope.$watch(attrs.crnReadonly,(e,t)=>{combobox.readonly(_scope.$eval(attrs.crnReadonly))});var convertArray=function(e){var t=[];if(e)for(var a in e)t.push(e[a][relactionDS.relationField]);return t};scope.$watchCollection(function(){return ngModelCtrl.$modelValue},function(value,old){var silent=$(combobox).data("silent");value&&0===value.length?($(`#${attrs.id}`).addClass("ng-empty"),attrs.ngRequired&&eval(attrs.ngRequired)&&$(`#${attrs.id}`).attr("required","required")):($(`#${attrs.id}`).removeClass("ng-empty"),$(`#${attrs.id}`).removeAttr("required")),$(combobox).data("silent",!1),silent||JSON.stringify(value)===JSON.stringify(old)||(relactionDS.relationDataSource&&relactionDS.relationField?combobox.value(convertArray(value)):combobox.value(value))})}}}]).directive("cronAutoComplete",["$compile",function(e){return{restrict:"E",require:"ngModel",link:async function(t,a,n,i){var o={};try{o=JSON.parse(n.options)}catch(e){console.log("AutoComplete invalid configuration! "+e)}try{delete d.dataSource.schema.model.id}catch(t){}var d=await app.kendoHelper.getConfigCombobox(o,t);d.change=n.ngChange?function(){t.$eval(n.ngChange)}:void 0,d.close=n.ngClose?function(){t.$eval(n.ngClose)}:void 0,d.dataBound=n.ngDataBound?function(){t.$eval(n.ngDataBound)}:void 0,d.filtering=n.ngFiltering?function(){t.$eval(n.ngFiltering)}:void 0,d.select=n.ngSelect?function(){t.$eval(n.ngSelect)}:void 0;var l=a.parent(),r=n.id?" id=\""+n.id+"\"":"",e=n.name?" name=\""+n.name+"\"":"",s=n.validationmessage?" validationmessage=\""+n.validationmessage+"\"":"",c="";(n.ngRequired||n.required)&&(c=" required "),$(l).append("<input style=\"width: 100%;\" "+r+e+c+s+" class=\"cronAutoComplete\" ng-model=\""+n.ngModel+"\"/>");var p=$(l).find("input.cronAutoComplete");$(a).remove(),d.change=function(a){t.$apply(function(){i.$setViewValue(p.val())})},"true"==n.autoExpand&&p.on("focus",function(t){u.search()}),d.messages={noData:n.noResultsMessage?n.noResultsMessage:"NO DATA FOUND"},"false"==n.firstOptionOnBlur&&(d.suggest=!1);var u=p.kendoAutoComplete(d).data("kendoAutoComplete");t.$watch(n.cronDisabled,function(e){u.enable(!e)}),i&&(i.$formatters.push(function(e){return u.value(e),e}),i.$parsers.push(function(e){if(e){if("string"==typeof e)return e;if(e[o.dataTextField])return e[o.dataTextField]}return null}))}}}]).directive("cronDate",["$compile","$translate","$window",function(e,t,a){return{restrict:"AE",require:"?ngModel",link:function(a,n,i,o){var d={},l={};try{if(i.options)l=JSON.parse(i.options);else{var r=window.buildElementOptions(n);l=JSON.parse(r)}l.format||(l.format=parseMaskType(l.type,t)),d=app.kendoHelper.getConfigDate(t,l)}catch(e){console.log("AutoComplete invalid configuration! "+e)}var s="date"==d.type||"datetime"==d.type||"time"==d.type;window.fixedTimeZone||(s=!1);var c=$(n);if(!c.data("alreadycompiled")){if(c.data("alreadycompiled",!0),c.data("$compile",e),i.fromGrid)c=$(n);else{var p=n.parent(),u=$("<input style=\"width: 100%;\" class=\"cronDate\" ng-model=\""+i.ngModel+"\"/>");$(p).append(u),c=$(p).find("input.cronDate"),c.data("type",d.type),c.attr("type","date")}var m=app.kendoHelper.buildKendoMomentPicker(c,d,a,o);i.fromGrid||(o&&(o.$formatters.push(function(e){var t=null;if(e){var a=null;a=s?moment(e).utcOffset(window.timeZoneOffset):moment(e),t=a.format(d.momentFormat)}return m.value(t),t}),o.$parsers.push(function(e){if(e){var t=null;return t=s?moment(m._oldText,d.momentFormat).utcOffset(window.timeZoneOffset):moment(m._oldText,d.momentFormat),t.toDate()}return null})),$(n).remove())}}}}]).directive("cronSlider",["$compile",function(e){return{restrict:"E",require:"ngModel",getActive:function(e,t){if(e&&e.indexOf(".active."))try{return t.$eval(e.substr(0,e.indexOf(".active.")))}catch(t){}},link:function(t,a,n,i){var o={};try{o=JSON.parse(n.options)}catch(e){console.log("Slider invalid configuration! "+e)}var d=app.kendoHelper.getConfigSlider(o),l=this.getActive(n.ngModel,t);d.change=function(){t.$apply(function(){var e=$(a).val();l&&(e=l.normalizeValue(e,!0)),i.$setViewValue(e),n.ngChange&&t.$eval(n.ngChange)})},d.slide=n.ngSlide?function(){t.$eval(n.ngSlide)}:void 0;var o=$(a).kendoSlider(d).data("kendoSlider");o._drag.element[0].title=d.dragHandleTitle,o._drag.element[1].title=d.dragHandleTitle;const r=new ResizeObserver(e=>{o.resize()});if(r.observe(o.wrapper[0]),"true"===n.ngRequired||n.required){var s=n.id?" id=\"input"+app.common.generateId()+"\"":"",c=n.name?" name=\"input"+app.common.generateId()+"\"":"",p=a.parent();$(p).append("<input aria-label=\"slider\" autocomplete=\"off\" tabindex=\"-1\" style=\"width: 100%;\""+s+c+" required class=\"cronSlider cron-select-offscreen\" ng-model=\""+n.ngModel+"\"/>");var u=$(p).find("input.cronSlider");e(u)(a.scope())}t.$watch(function(){return i.$modelValue},function(e,t){e!==t&&(e?o.value(e):o.value(o.min()))}),i&&(i.$formatters.push(function(e){var t=null;return!e&&o.min?t=o.min:e&&(t=e),o.value(t),t}),i.$parsers.push(function(e){return e?e:null}))}}}]).directive("cronSwitch",["$compile",function(e){return{restrict:"E",require:"ngModel",link:function(t,a,n,i){var o={};try{var d=window.buildElementOptions(a);o=JSON.parse(d)}catch(e){console.log("Switch invalid configuration! "+e)}var l=app.kendoHelper.getConfigSwitch(o),r=a.parent();$(r).append("<input style=\"width: 100%;\" class=\"cronSwitch\" ng-model=\""+n.ngModel+"\"/>");var s=$(r).find("input.cronSwitch"),c=function(a){t.$apply(function(){i.$setViewValue(this.value())}.bind(this))};l.change=c;var p=s.kendoMobileSwitch(l).data("kendoMobileSwitch");$(a).remove(),i&&(i.$formatters.push(function(e){var t=!1;return null!=e&&(t=e),p.value(t),t}),i.$parsers.push(function(e){return null!=e&&e}))}}}]).directive("cronBarcode",["$compile",function(e){return{restrict:"E",require:"ngModel",link:function(e,t,a,n){var i={};try{var o=window.buildElementOptions(t);i=JSON.parse(o)}catch(e){console.log("Barcode invalid configuration! "+e)}var d=app.kendoHelper.getConfigBarcode(i),l=t.parent();$(l).append("<span class=\"cronBarcode\" ng-model=\""+a.ngModel+"\"></span>");var r=$(l).find("span.cronBarcode"),s=r.kendoBarcode(d).data("kendoBarcode");$(t).remove(),e.$watch(function(){return n.$modelValue},function(e,t){var a="";e!==t&&(a=e),d.value=a,s.setOptions(d)})}}}]).directive("cronQrcode",["$compile",function(e){return{restrict:"E",require:"ngModel",link:function(e,t,a,n){var i={};try{var o=window.buildElementOptions(t);i=JSON.parse(o)}catch(e){console.log("Qrcode invalid configuration! "+e)}var d=app.kendoHelper.getConfigQrcode(i),l=t.parent();$(l).append("<span class=\"cronQrcode\" ng-model=\""+a.ngModel+"\"></span>");var r=$(l).find("span.cronQrcode"),s=r.kendoQRCode().data("kendoQRCode");$(t).remove(),e.$watch(function(){return n.$modelValue},function(e,t){var a="";e!==t&&(a=e),d.value=a,s.setOptions(d)})}}}]).directive("cronappRating",function(){"use strict";return{restrict:"E",require:"ngModel",link:function(e,t,a,n){function o(e){for(var t=1;5>=t;t++)c[t-1].removeClass(a.iconOff||"fa fa-star-o"),c[t-1].removeClass(a.classElem),c[t-1].removeClass(a.iconTheme),t<=e?c[t-1].addClass(a.classElem):(c[t-1].addClass(a.iconOff||"fa fa-star-o"),c[t-1].addClass(a.theme),c[t-1].addClass(a.iconSize));return e}a.theme=$(t).find("i").attr("icon-theme"),a.classElem=$(t).find("i").attr("class"),a.iconSize=$(t).find("i").attr("icon-size"),a.iconOn=$(t).find("i").attr("class");var d=$(t),l=[];a.xattrDefaultValue&&(n.$viewValue=0,n.$commitViewValue());for(var r=1;5>=r;r++)l.push($(t).find("i").get(r-1)),$(l[r-1]).addClass(a.iconOff||"fa fa-star-o");d.html("");for(var s,c=[],r=1;5>=r;r++)s=$(l[r-1]).clone(),d.append(s),s.attr("idx",r),s.click(function(){e.$apply(function(){let e=parseInt($(this).attr("idx"));n.$viewValue=n.$viewValue===e?0:e,n.$commitViewValue()}.bind(this))}),c.push(s);n.$parsers.push(o),n.$formatters.push(o)}}}).directive("cronDynamicMenu",["$compile","$translate",function(e,t){"use strict";const a=e=>{var n="";return e&&0<e.length&&Array.isArray(e)&&(e.forEach(function(e){var i=e.security&&null!=e.security?` cronapp-security="${e.security}" `:"",o=e.action&&null!=e.action?` ng-click="cronapi.internal.lastCronappMenuClick('${e.id}');${e.action}" `:"",d=e.hide&&null!=e.hide?` ng-hide="${e.hide}" `:"",l=e.iconClass&&null!=e.iconClass?`<i class="${e.iconClass}" id="menu-tag-i-${e.id}"></i>&nbsp;`:"",r=`<span id="menu-tag-span-${e.id}"></span>`,s=e.menuItems&&Array.isArray(e.menuItems)&&0<e.menuItems.length?`<span class="caret submenu" id="menu-tag-span-sub-${e.id}"></span>`:"";e.title&&(r=`<span id="menu-tag-span-${e.id}">${t.instant(e.title)}</span>`),n+=0<e.menuItems.length?`
38
43
  <li class="dropdown-submenu" ${i}${d} id="menu-tag-li-sub-${e.id}"> \
39
44
  <a href="" ${o} id="menu-tag-a-sub-${e.id}" class="dropdown-item dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> ${l} ${r} ${s} </a> \
40
45
  ${a(e.menuItems)}\
@@ -47,4 +52,4 @@ maskDirectiveAsDate.$inject=["$compile","$translate","$parse"],maskDirectiveMask
47
52
  ${s} ${c} ${l}
48
53
  </a>
49
54
  ${a(e.menuItems)}
50
- </li>`}),i},link:function(a,n,i){var o=this.populateMenu;i.$observe("options",function(d){t.onReady(()=>{let t=n.closest(".crn-navigator-vertical").length;var l={};try{l=JSON.parse(d)}catch(t){console.log("CronDynamicMenu: Invalid configuration!")}let r=l&&l.subMenuOptions&&l.subMenuOptions.length?l.subMenuOptions[0].id:"first";var s=`<ul id="menu-tag-ul-base-${r}" class="nav navbar-nav ${t?"col-md-12 padding-0":""}" ></ul>`,c=$(s);c.attr("id",i.id);var p=o(l,t);c.append(p),t&&c.append($("#navbar2 li:first").addClass("col-md-12 padding-0"));var u=angular.element(c);n.html(""),n.append(c),n.attr("id",null),e(u)(a);var m=i.multilevelAction;"hover"===m&&($(".dropdown-menu .dropdown-submenu").on("mouseover",function(){var e=$(this).children("ul.dropdown-menu");e.addClass("displayBlock")}),$(".dropdown-menu .dropdown-submenu").on("mouseout",function(){var e=$(this).children("ul.dropdown-menu");e.removeClass("displayBlock")})),"click"===m&&$(".dropdown-menu a.dropdown-toggle").on("click",function(t){$(this).next().hasClass("show")||$(this).parents(".dropdown-menu").first().find(".show").removeClass("show");var e=$(this).next(".dropdown-menu");return e.toggleClass("show"),$(this).parents("li.nav-item.dropdown").on("hidden.bs.dropdown",function(t){$(".dropdown-submenu .show").removeClass("show")}),!1}),$("#checkCollapsibleMenu").on("click",function(){var e=document.getElementById("main-view");this.checked?e.classList.remove("main-view-retratil"):e.classList.add("main-view-retratil")})})})}}}]).directive("cronBreadcrumbs",["$rootScope",function(e){"use strict";return{restrict:"E",replace:!0,link:function(e,t,a){var n=a.ngInit?a.ngInit:null;const i=a.crnDelimiterIcon,o=a.typeMenu,d=a.idMenu?a.idMenu:null,l=a.id,r=a.breadcrumbIcon?a.breadcrumbIcon:null,s=[],c=async()=>{const t=n.replace("cronapi.client('js.","blockly.js.");n=t.replace("').run()",""),n=e.$eval(n),s=await n();const a=async t=>{t.item.action&&t.item.action()};$(`#${l}`).kendoBreadcrumb({items:s,delimiterIcon:i,navigational:!0,click:a})},p=e=>e?e.replace("cronapi.screen.changeView('","").replace("', [])",""):"#/home";if(n&&"idBloco"===o)c();else{var u=new MutationObserver((e,t)=>{const a=$(`#${d}`).parent(),n=a.attr("options");if(n){t.disconnect();const e=JSON.parse(n),a=document.location.hash||"home",d=(e,t,a=[])=>{for(let o=0;o<e.length;o++){var n=e[o];if(n.action=p(n.action),n.action===t)return[...a,n];if(n.menuItems){const e=d(n.menuItems,t,[...a,n]);if(e)return e}}return null},r=d(e.subMenuOptions,a);if(r){for(var o in r){const e=r[o];s.push({type:0==o?"rootitem":"item",href:e.action,text:e.title,showText:!0,showIcon:!1})}$(`#${l}`).kendoBreadcrumb({items:s,delimiterIcon:i,navigational:!0})}}});u.observe(document.body,{childList:!0})}}}}]).directive("ngInitialValue",["$parse",function(e){return{restrict:"A",require:"ngModel",link:async function(t,a,n,i){if(n.ngInitialValue){var o,d=e(n.ngModel),l=d.assign;try{if(-1!=n.ngInitialValue.indexOf("cronapi.client('js.")){let e=n.ngInitialValue.replace("cronapi.client('js.","blockly.js."),a=e.split("').names")[0];a=a.split("').attr()")[0];let i=e.split(".run")[1];o=await t.$eval(a+i)}else o=t.$eval(n.ngInitialValue)||n.ngInitialValue}catch(t){o=n.ngInitialValue}"checkbox"==a[0].type&&o&&(o="true"==(""+o).toLowerCase()),l(t,o)}}}}]).directive("crnSetIndeterminate",["$parse",function($parse){return{restrict:"A",link:function(scope,element,attrs){let value=eval(attrs.crnSetIndeterminate);null===value&&$(element).prop("indeterminate",!0)}}}]).directive("crnAllowNullValues",[function(){return{restrict:"A",require:"?ngModel",link:function(e,t,a,n){n.$formatters=[],n.$parsers=[];let i=e=>(e&&-1===e.indexOf("'")&&(e=`'${e}'`),e);a.ngFalseValue=i(a.ngFalseValue),a.ngTrueValue=i(a.ngTrueValue);let o=!!a.ngFalseValue&&a.ngFalseValue.split("'").join(""),d=!a.ngTrueValue||a.ngTrueValue.split("'").join(""),l=e=>"true"===e||void 0===e||null===e||0==e.length;n.$render=l(a.crnAllowNullValues)?function(){let e=n.$viewValue;t.data("checked",e),!0===e||e===d?(t.prop("indeterminate",!1),t.prop("checked",!0),e=d):!1===e||e===o?(t.prop("indeterminate",!1),t.prop("checked",!1),e=o):(e=null,t.prop("indeterminate",!0)),setTimeout(()=>n.$setViewValue(e))}:function(){let i=n.$viewValue;if((void 0===n.$viewValue||null===n.$viewValue)&&(n.$setViewValue(!1),i=!1),i===o){let n=a.ngFalseValue?`${t.attr("ng-model")}=${a.ngFalseValue}`:`${t.attr("ng-model")}=${o}`;e.$eval(n)}switch(t.data("checked",i),i){case!0:case d:t.prop("indeterminate",!1),t.prop("checked",!0),i=d;break;default:t.prop("indeterminate",!1),t.prop("checked",!1),i=o}setTimeout(()=>n.$setViewValue(i))},t.bind("click",function(){let i;switch(t.data("checked")){case!1:case o:i=!a.ngTrueValue||d;break;default:i=!!a.ngFalseValue&&o}n.$setViewValue(i),e.$apply(n.$render)})}}}]).directive("signaturePad",["$compile","$window",function(e,t){"use strict";var a,n,i=null;return{restrict:"E",require:"ngModel",scope:!0,replace:!0,transclude:!0,template:"<div style=\"height: 100%; width: 100%;\"> <canvas style=\"width:100%; height: 100%;\" ng-click=\"mouseup()\" ng-mouseup=\"mouseup()\"></canvas> <div class=\"component-holder ng-scope col-md-2\" style=\"bottom: 0; position: absolute; padding-left: 5px;\" data-component=\"crn-button\"> <button class=\"btn k-button btn-warning\" ng-click=\"clear()\" xattr-fullsize=\"\" xattr-theme=\"btn-warning\" xattr-disabled=\"\"> <i class=\"glyphicon glyphicon-erase\" icon-theme=\"\"></i> <span class=\"\" text-theme=\"\">{{'clear'|translate}}</span> </button> </div> </div>",scope:{dataurl:"=",ngClick:"@",ngModel:"="},controller:["$scope",function(t){let a=()=>{let e=t.signaturePad.toDataURL();return e&&(e=e.split(",")[1]),e};t.mouseup=function(n){t.signaturePad.isEmpty()||(t.ngModel=a())},t.$watch("ngModel",function(e,n){e!==n&&(a()!==e&&t.signaturePad.fromDataURL("data:image/png;base64,"+e,{ratio:1}),t.ngModel=e)},!0),t.clear=function(){t.signaturePad.clear(),t.ngModel=null}}],link:function(n,i,o,d,l){a=i.find("canvas")[0],n.onResize=function(){var e=Math.max(t.devicePixelRatio||1,1),a=i.find("canvas")[0],n=document.createElement("canvas");n.width=a.width,n.height=a.height;var o=n.getContext("2d");o.drawImage(a,0,0),a.width=a.offsetWidth*e,a.height=a.offsetHeight*e,a.getContext("2d").drawImage(n,0,0),a.getContext("2d").scale(e,e)},n.onResize(),n.signaturePad=new SignaturePad(a),angular.element(t).on("resize",function(){n.onResize()}),e(i)(i.scope());let r=!1;$(a).on("pointerdown",t=>{1===t.which&&(r=!0),t.preventDefault()}),$(a).on("pointerup",t=>{1===t.which&&r&&(r=!1,l(()=>angular.element(a).triggerHandler("mouseup")))})}}}]).directive("cronChat",["$compile","$translate",function(e,t){return{restrict:"E",replace:!0,link:function(e,t,a,n){var i=JSON.parse(a.options||"{}");if(i.token&&i.urlCronchat){var o=i.urlCronchat.endsWith("/")?i.urlCronchat:i.urlCronchat+"/",d=i.token,l=$(`<script src="${o}get-chat?token=${d}" type="text/javascript"></script>`);t.html(l)}}}}]).directive("updateLanguage",["$rootScope",function(e){return{link:function(t,a){var n=function(e,t){var n="en",i=t.language;"pt_br"===i?i="pt-br":i.startsWith("en")&&(i="en"),a.attr("lang",i||"en")};e.$on("$translateChangeSuccess",n)}}}]).directive("cronFrame",cronFrame).directive("crnComponent",cronFrame).directive("fromGrid",["$compile",e=>({restrict:"A",priority:-999999,exist:e=>{let t=e.attr("id");return $(`#${t}`).length},isFromGrid:e=>"true"===e.fromGrid,isCompiled:e=>e.data("alreadycompiled"),getDateAs:function(e,t,a){let n=e.data("mask"),i=e.data("useUTC");return formatWithMomentAs(n,i,t,a)},prepareValue:function(e,t){let a=e.data("column-type")||"";return a.startsWith("date")&&(t=this.getDateAs(e,t,"date")),t},formatComponent:function(e,t){let a=e.data("kendoDropDownList")||e.data("kendoSlider"),n=e.data("column-type")||"";n.startsWith("date")?e.val(this.getDateAs(e,t,"string")):a&&a.value(t)},compileGridListing:function(t,a){let n=t.data("ref-component");if(n&&n.tbody&&n.tbody.length&&!$(n.tbody).find(".k-grid-edit-row").length){var i=n.tbody;setTimeout(()=>{a.safeApply(()=>{var t=$(i),n=angular.element(t);e(n)(a)})})}},link:function(e,t,a){e.$watch(a.ngModel,n=>{this.isFromGrid(a)&&this.exist(t)&&this.isCompiled(t)&&(n=this.prepareValue(t,n),this.formatComponent(t,n),this.compileGridListing(t,e),call=t.data("change-grid-model"),call&&call(n))})}})]).directive("cronOrderedList",["$compile","$sce","$parse",function(e,t,a){"use strict";return{restrict:"EA",replace:!0,link:function(t,a,n,i){let o=n.attributeValue,d=n.orderedAttributeValue,l=n.listType,r=a[0].children[0].children;r=$(r);let s="",c="";$.each(r,function(e,t){c+=t.outerHTML});"numbered-list"===l?s=`<ol style="list-style-type: ${o}">${c}</ol>`:"ordered-list"===l?s=`<ul style="list-style-type: ${d}">${c}</ul>`:void 0;s=$(s),$(a).replaceWith(s),e(s)(t)}}}]).directive("crnInfiniteScroll",["$compile",function($compile){"use strict";return{restrict:"EA",link:function(scope,element,attrs){var dataSource=attrs.crnInfiniteScroll?eval(attrs.crnInfiniteScroll):attrs.crnDatasource?eval(attrs.crnDatasource):void 0;if(dataSource){let e={isVisible:!1,checkVisibility:function(t){if(e.isVisible!==t&&(e.isVisible=t,e.isVisible))if(dataSource.loaded&&dataSource.loadedFinish)dataSource.nextPage();else{let e=setInterval(function(){dataSource.loaded&&dataSource.loadedFinish&&(dataSource.nextPage(),clearInterval(e))},250)}},eventScroll:function(){var t=element.offset().top,a=element.offset().top+element.outerHeight(),n=$(window).scrollTop()+$(window).innerHeight(),i=$(window).scrollTop();e.checkVisibility(n>t&&i<a)}};$(window).scroll(e.eventScroll),$(window).ready(e.eventScroll)}}}}])}(app);function maskDirectiveAsDate(e,t,a){return maskDirective(e,t,a,"as-date")}function maskDirectiveMask(e,t,a){return maskDirective(e,t,a,"mask")}function maskDirective(e,t,a,n){return{restrict:"A",require:"?ngModel",link:function(i,o,d,l){if("as-date"!=n||void 0===d.mask){var r=a(d.ngModel),s=r.assign,c=$(o);if(!c.data("alreadycompiled")){c.data("alreadycompiled",!0),c.data("$compile",e);var p=c.attr("type");if("checkbox"!=p&&"password"!=p&&"url"!=p){if("color"==p||"range"==p)return c[0].classList.remove("form-control"),void c[0].classList.remove("k-textbox");c.data("type",p),c.attr("type","text"),l&&(l.$formatters=[],l.$parsers=[]),void 0!==d.asDate&&"text"==p&&(p="date");var u=!0,m=!1,g=d.mask||d.format;g=g?parseMaskType(g,t):parseMaskType(p,t),g.endsWith(";0")&&(m=!0);var f=g.replace(";1","").replace(";0","").trim();if(null!=f&&0!=f.length)if("date"==p||"datetime"==p||"datetime-local"==p||"month"==p||"time"==p||"time-local"==p||"week"==p){var h={format:f,locale:t.use(),showTodayButton:!0,useStrict:!0,tooltips:{today:t.instant("DatePicker.today"),clear:t.instant("DatePicker.clear"),close:t.instant("DatePicker.close"),selectMonth:t.instant("DatePicker.selectMonth"),prevMonth:t.instant("DatePicker.prevMonth"),nextMonth:t.instant("DatePicker.nextMonth"),selectYear:t.instant("DatePicker.selectYear"),prevYear:t.instant("DatePicker.prevYear"),nextYear:t.instant("DatePicker.nextYear"),selectDecade:t.instant("DatePicker.selectDecade"),prevDecade:t.instant("DatePicker.prevDecade"),nextDecade:t.instant("DatePicker.nextDecade"),prevCentury:t.instant("DatePicker.prevCentury"),nextCentury:t.instant("DatePicker.nextCentury")}};"DD/MM/YYYY"!=f&&"MM/DD/YYYY"!=f&&(h.sideBySide=!0);var v="date"==p||"datetime"==p||"time"==p;if(window.fixedTimeZone||(v=!1),c.data("mask",f),c.data("useUTC",v),c.attr("from-grid")){var b=function(){var e=$(this).offset(),t=!0,a=$(this).parent().find(".bootstrap-datetimepicker-widget.dropdown-menu.usetwentyfour.bottom");if(a.length||(t=!1,a=$(this).parent().find(".bootstrap-datetimepicker-widget.dropdown-menu.usetwentyfour.top")),$(a).offset()){var n=$(a).offset().left,i=$("body");a.appendTo(i);var o=0;o=t?e.top+35:e.top-($(a).height()+15),a.css("top",o),a.css("bottom","auto"),a.css("left",n),a.css("z-index",999999)}};if(c.on("click",b),c.on("focus",function(){setTimeout(b.bind(this),100)}),c.on("dp.change",function(){i.safeApply(function(){var e=null;e=v?moment(c.val(),f).utcOffset(window.timeZoneOffset,!0):moment(c.val(),f),("time"==p||"time-local"==p)&&(e=e.year(1970).dayOfYear(1).month(0)),e.isValid()&&l&&s(i,e.toDate())})}),c.data("initial-value")){var y=c.data("initial-value"),k=null;k=v?moment(y).utcOffset(window.timeZoneOffset):moment(y),c.val(k.format(f)),c.data("initial-value",null)}}else c.wrap("<div style=\"position:relative\"></div>");c.datetimepicker(h),"true"!==d.fromGrid&&c.on("dp.change",function(){$(this).is(":visible")&&($(this).trigger("change"),i.safeApply(function(){var e=c.val(),t=null;t=v?moment(e,f).utcOffset(window.timeZoneOffset,!0):moment(e,f),("time"==p||"time-local"==p)&&(t=t.year(1970).dayOfYear(1).month(0)),t.isValid()&&l&&s(i,t.toDate())}))}),l&&(l.$formatters.push(function(e){if(e)return formatWithMomentAs(f,v,e,"string");if(null===e){var t=c.datetimepicker(h).data("DateTimePicker");t.date(null)}return null}),l.$parsers.push(function(e){if(e){if(e instanceof Date)return e;var t=null;return t=v?moment(e,f).utcOffset(window.timeZoneOffset,!0):moment(e,f),("time"==p||"time-local"==p)&&(t=t.year(1970).dayOfYear(1).month(0)),t.toDate()}return null}))}else if("number"==p||"money"==p||"integer"==p||"money-decimal"==p){m=!0;var C=f.trim().replace(/\./g,"").replace(/\,/g,"").replace(/#/g,"").replace(/0/g,"").replace(/9/g,""),S="",w="",D="",T=",",M=0;f.startsWith(C)?S=C:f.endsWith(C)&&(w=C);var x=f.trim().replace(S,"").replace(w,"").trim();x.startsWith("#.")?D=".":x.startsWith("#,")&&(D=",");var E=null;if(-1==x.indexOf(",0")?-1!=x.indexOf(".0")&&(T=".",E=".0"):(T=",",E=",0"),null!=E){var I=x.substring(x.indexOf(E)+1);M=I.length}var A="numeric";0==M&&(A="integer"),"money-decimal"==p&&(A="currency");var F={rightAlign:"money"==p||"money-decimal"==p,unmaskAsNumber:!0,allowMinus:!0,prefix:S,suffix:w,radixPoint:T,digits:M,numericInput:"money-decimal"==p};D&&(F.autoGroup=!0,F.groupSeparator=D),$(o).inputmask(A,F),useInputMaskPlugin(o,l,i,s,f)}else if("text"==p||"tel"==p||"string"==p){let e=["D","M","Y","H","m","s"],t=t=>(e.forEach(e=>t=t.replaceAll(e,"9")),t);f=t(f),d.maskPlaceholder?(h={},h.placeholder=d.maskPlaceholder,$(o).inputmask(f,h),m&&useInputMaskPlugin(o,l,i,s,f)):(c.mask(f),useMaskPlugin(o,l,i,s,m))}}}}}}}function useInputMaskPlugin(e,t,a,n,i){var o=$(e),d=function(){$(this).data("rawvalue",$(this).inputmask("unmaskedvalue"))};$(e).on("keydown",d).on("keyup",d),t&&(t.$formatters.push(function(e){return null!=e&&null!=e&&""!==e?format(i,e):null}),t.$parsers.push(function(e){if(e!=null&&null!=e&&""!==e){var t=o.inputmask("unmaskedvalue");if(""!==t)return t}return null}))}function useMaskPlugin(e,t,a,n,i){var o=$(e),d=function(){i&&$(this).data("rawvalue",$(this).cleanVal())};$(e).on("keydown",d).on("keyup",d),i&&t&&(t.$formatters.push(function(e){return e?o.masked(e):null}),t.$parsers.push(function(e){return e?o.cleanVal():null}))}function parseMaskType(e,t){return"datetime"==e||"datetime-local"==e?(e=t.instant("Format.DateTime"),"Format.DateTime"==e&&(e="DD/MM/YYYY HH:mm:ss")):"date"==e?(e=t.instant("Format.Date"),"Format.Date"==e&&(e="DD/MM/YYYY")):"time"==e||"time-local"==e?(e=t.instant("Format.Hour"),"Format.Hour"==e&&(e="HH:mm:ss")):"month"==e?e="MMMM":"number"==e?(e=t.instant("Format.Decimal"),"Format.Decimal"==e&&(e="#.#00,00")):"money"==e||"money-decimal"==e?(e=t.instant("Format.Money"),"Format.Money"==e&&(e="#.#00,00")):"integer"==e?(e=t.instant("Format.Integer"),"Format.Integer"==e&&(e="#,##0.####")):"week"==e?e="dddd":"tel"==e?e="(00) 00000-0000;0":"text"==e?e="":"string"==e&&(e=""),e}function transformText(){return{restrict:"E",require:"?ngModel",link:function(e,t,a,n){var i=function(e,t){if(e){if(t!==void 0&&null!==t){if("uppercase"===e.css("text-transform"))return t.toUpperCase();if("lowercase"===e.css("text-transform"))return t.toLowerCase()}return t}};n&&(n.$formatters.push(function(e){return i(t,e)}),n.$parsers.push(function(e){return i(t,e)}))}}}app.kendoHelper={getCorrectlyDS:(e,t)=>{if(t[e]&&t[e].apiVersion)return t[e];else{let a=t.$parent[e];return t[e]=a,a}},getCorrectlyDSPromise:async(e,t)=>new Promise((a,n)=>{let i=()=>{let o=null;if(t[e]&&t[e].apiVersion)o=t[e];else{let a=t.$parent[e];t[e]=a,o=a}o?a(o):$(`datasource[name="${e}"]`).length?setTimeout(()=>i(),100):n(null)};i()}),receivePushData:e=>!e||!e.dataSource||(e.dataSource.transport.options.refComponent=e),getSchema:function(e){var t=[{kendoType:"string",entityType:["string","character","uuid","guid"]},{kendoType:"number",entityType:["integer","long","double","int","float","bigdecimal","single","int32","int64","decimal","byte"]},{kendoType:"date",entityType:["date","time","datetime"]},{kendoType:"boolean",entityType:["boolean"]}],a=function(e){for(var a=0;a<t.length;a++)if(t[a].entityType.includes(e.toLocaleLowerCase()))return t[a].kendoType;return"string"},n={model:{id:"__$id",fields:{}}};return e&&e.schemaFields&&(e.schemaFields.forEach(function(e){n.model.fields[e.name]={type:a(e.type),editable:!0,nullable:e.nullable,validation:{required:!e.nullable}}}),n.model.fields.__$id={type:"string",editable:!0,nullable:!0,validation:{required:!1}}),n},getDataSource:function(t,a,n,i,o,d){var l=Number.MAX_SAFE_INTEGER_32;function r(t){if(t.response&&t.response.d){var e=null;e=t.response.d.results?t.response.d.results:[t.response.d],this.group().length?o.forEach(function(t){if("Database"==t.dataType){var a="datetime-local"==t.type||"month"==t.type||"time-local"==t.type||"week"==t.type;if(a)for(var n,o=0;o<e.length;o++)n=e[o],t.field==n.Member&&(n.Key=n.Key.replace(/\d+/,function(e){return parseInt(e)+g})),s.bind(this)(n.Items)}}):s.bind(this)(e)}}function s(e){for(var t=0;t<e.length;t++)o&&o.forEach(function(a){if("Database"==a.dataType){var n="datetime-local"==a.type||"month"==a.type||"time-local"==a.type||"week"==a.type;n&&e[t][a.field]&&(e[t][a.field]=e[t][a.field].replace(/\d+/,function(e){return parseInt(e)+g}))}})}function c(e){var t=[];return e&&e.forEach(function(e){e.aggregates&&e.aggregates.forEach(function(a){t.push({field:e.field,aggregate:a.type})})}),t}var p=this.getSchema(t);o&&o.forEach(function(e){for(var t in p.model.fields)if("Database"==e.dataType&&e.field==t){if(p.model.fields[t].nullable=!e.required,p.model.fields[t].validation.required=e.required,"999.999.999-99;0"===e.format||"99.999.999/9999-99;0"===e.format){let a="999.999.999-99;0"===e.format?"cpf":"cnpj",n={cpf:CPF,cnpj:CNPJ},i=t.toLocaleLowerCase()+"validation";p.model.fields[t].validation[i]=function(e){return!(e.is("[name='"+t+"']")&&""!=e.val())||n[a].isValid(e.val())}}break}});var u=function(e){for(var t in e)if(p.model.fields.hasOwnProperty(t)){var a=p.model.fields[t];"string"==a.type&&null!=e[t]?e[t]+="":"number"==a.type&&null!=e[t]?e[t]=parseFloat(e[t]):"date"==a.type&&null!=e[t]?e[t]="/Date("+e[t].getTime()+")/":"boolean"==a.type&&(null==e[t]?e[t]=!1:e[t]="true"==e[t].toString().toLowerCase()),p.model.id==t&&null!=e[t]&&0==e[t].toString().length&&delete e[t]}return e},m=10;app.kendoHelper.getCorrectlyDS(t.name,a)&&(m=app.kendoHelper.getCorrectlyDS(t.name,a).rowsPerPage);var g=6e4*new Date().getTimezoneOffset(),f=app.common.generateId(),h={transport:{setActiveAndPost:function(t){var e=this.options.cronappDatasource;a.safeApply(e.updateActive(u(t.data))),e.active.__sender=f,e.postSilent(function(e){this.options.enableAndSelect(t),t.success(e),this.options.refComponent.dataSource._pristineTotal=this.options.refComponent.dataSource._pristineData.push(e)}.bind(this),function(e){this.options.enableAndSelect(t),t.error(e,e,e)}.bind(this))},pushAction:function(e,t){return a=>{let n=["read","memorydelete","overRideRefresh"];if(this.options.isComponentInDocument(this.options.refComponent)){let n=this.options.getCurrentCallbackForPush(t,this.options.refComponent),i=n[e];i?i(a):(this.options.fromRead="read"===e,this.options.cronappDatasource.reloadedFromCronapi&&(this.options.fromRead=!1,delete this.options.cronappDatasource.reloadedFromCronapi),"overRideRefresh"===e&&(this.options.refComponent.dataSource._page=1,this.options.refComponent.dataSource._skip=0),this.options.refComponent.dataSource.read())}else n.includes(e)||this.options.cronappDatasource.removeDataSourceEvents(this.options.dataSourceEventsPush)}},push:function(e){!this.options.dataSourceEventsPush&&this.options.cronappDatasource&&(this.options.dataSourceEventsPush={create:this.pushAction.bind(this)("pushUpdate",e),update:this.pushAction.bind(this)("pushUpdate",e),delete:this.pushAction.bind(this)("pushDestroy",e),overRideRefresh:this.pushAction.bind(this)("overRideRefresh",e),read:this.pushAction.bind(this)("read",e),memorycreate:this.pushAction.bind(this)("pushUpdate",e),memoryupdate:this.pushAction.bind(this)("pushUpdate",e),memorydelete:this.pushAction.bind(this)("pushDestroy",e)},"combobox"==this.origin&&delete this.options.dataSourceEventsPush.overRideRefresh,this.options.cronappDatasource.addDataSourceEvents(this.options.dataSourceEventsPush))},read:function(a){var e=!1;try{var n=this.options.cronappDatasource;this.options.kendoCallback?this.options.fromRead?this.options.kendoCallback.success(n.data):e=!0:(this.options.kendoCallback=a,e=!0)}finally{this.options.fromRead=!1}if(e){for(key in a.data)null==a.data[key]&&delete a.data[key];var i=kendo.data.transports.odata.parameterMap(a.data,"read"),o="";this.options.refComponent&&this.options.refComponent.dataSource.group().forEach(function(e){o+=e.field+" "+e.dir+","}),0<o.length&&(o=o.substr(0,o.length-1),i.$orderby=i.$orderby?o+","+i.$orderby:o);var n=this.options.cronappDatasource;if(n.rowsPerPage=a.data.pageSize,n.offset=a.data.page-1,!a.data.pageSize&&(n.rowsPerPage=l,n.offset=void 0,i.$skip=0,this.options.refComponent&&1!=this.options.refComponent.dataSource.page()))return this.options.refComponent.dataSource.page(1),void a.error("canceled","canceled","canceled");var d={params:i},r=!1;t.append&&(r=t.append);var s={};"button"===n.loadDataStrategy&&0<n.data.length&&(s.origin=n.loadDataStrategy),n.append=r,n.fetch(d,{success:function(e){a.success(e)},canceled:function(e){a.error("canceled","canceled","canceled")},error:function(e){a.error("canceled","canceled","canceled")}},r,s)}},update:function(t){this.setActiveAndPost(t)},create:function(t){this.setActiveAndPost(t)},destroy:function(t){cronappDatasource=this.options.cronappDatasource,cronappDatasource.removeSilent(t.data,function(e){t.success(e)},function(e){t.error("canceled","canceled","canceled")})},batch:function(t){},options:{fromRead:!1,disableAndSelect:function(t){this.isComponentInDocument(this.refComponent)&&(this.refComponent.select(t.container),this.refComponent.options.selectable=!1,this.refComponent.selectable&&this.refComponent.selectable.element&&(this.refComponent.selectable.destroy(),this.refComponent.selectable=null))},enableAndSelect:function(t){this.isComponentInDocument(this.refComponent)&&(this.refComponent.options.selectable=this.refComponent.options.originalSelectable,this.refComponent._selectable(),this.refComponent.select(t.container))},selectActiveInGrid:function(e){if(this.isComponentInDocument(this.refComponent)&&this.refComponent.selectable&&0<this.refComponent.dataItems().length&&this.cronappDatasource.active&&this.cronappDatasource.active.__$id){for(var t=this.refComponent.dataItems(),a=-1,n=0;n<t.length;n++)if(this.cronappDatasource.active.__$id==t[n].__$id){a=n;break}-1<a&&!this.refComponent.selectable.options.multiple&&this.refComponent.select(this.refComponent.table.find("tr")[a+1])}},isComponentInDocument:function(e){return!!e&&$(document).has(e.element[0]).length},getCurrentCallbackForPush:function(e,t){return e?e:t},cronappDatasource:app.kendoHelper.getCorrectlyDS(t.name,a)}},pageSize:m,serverPaging:!0,serverFiltering:!0,serverSorting:!0,batch:!1,schema:p,requestEnd:r};return h.aggregate=c(o),h.schema.total=function(){return h.transport.options.cronappDatasource.getRowsCount()},d&&(h.group=[],d.forEach(function(e){var t={field:e.field,aggregates:h.aggregate};h.group.push(t)})),h},getEventReadCombo:function(t){var e=this.options.cronappDatasource;if(!e)return void t.error("canceled","canceled","canceled");this.options.kendoCallback||(this.options.kendoCallback=t);var a;if(this.options.combobox&&this.options.combobox.options.readData)return t.success(this.options.combobox.options.readData),this.options.combobox.options.readData=null,void(this.options.alreadyLoaded=!0);this.options.combobox?a=!this.options.alreadyLoaded:e.__ignoreFirstFetch?(a=!0,delete e.__ignoreFirstFetch):a=!1,this.options.alreadyLoaded=!0;var n=!0;if(a&&(n=!1,e.lazy?t.success([{}]):t.success([])),(this.options.fromRead||this.options.combobox&&void 0===this.options.combobox.options.firstLazyRead)&&(this.options.fromRead=!1,this.options.kendoCallback.success(e.data),n=!1),n){for(key in t.data)null==t.data[key]&&delete t.data[key];var i=kendo.data.transports.odata.parameterMap(t.data,"read");e.rowsPerPage=t.data.pageSize,e.offset=t.data.page-1;var o=this,d=!0,l={};l.params=i,o.options.combobox&&(o.options.combobox.options.fromCombo=!0),e.fetch(l,{success:function(e){if(t.success&&(o.options.combobox&&(o.options.combobox.options.expanded=!0),t.success(e),o.options.kendoCallback=t,o.options&&o.options.combobox&&o.options.combobox.element[0].id)){var a=" .k-animation-container",n=angular.element($(" .k-animation-container"));o.options.$compile(n)(o.options.scope)}},canceled:function(e){o.options.combobox&&(o.options.combobox.options.fromCombo=!1),t.success&&t.error("canceled","canceled","canceled")},error:function(e){o.options.combobox&&(o.options.combobox.options.fromCombo=!1),t.success&&t.error("error","error","error")}},!1,{ignoreAtive:!0})}},parseOptionsCronToConfigKendo:function(e,t,a){let n=!1;e.dynamic&&"false"!=e.dynamic?e.dataSourceScreen&&e.dataSourceScreen.entityDataSource&&(e.dataSourceScreen.entityDataSource.append=!0,t=app.kendoHelper.getDataSource(e.dataSourceScreen.entityDataSource,a,!0,e.dataSourceScreen.rowsPerPage),t.transport.read=app.kendoHelper.getEventReadCombo,n=!0):(n=!0,e.dataValueField=e.dataValueField||"value",e.dataTextField=e.dataTextField||"key"),e.dataValueField&&""!=e.dataValueField.trim()||(e.dataValueField=null==e.dataTextField?void 0:e.dataTextField);var i=function(t){var a=e.dataSourceScreen.entityDataSource.schemaFields;for(count=0;count<a.length;count++)if(t==a[count].name){return a[count].type.toLowerCase();break}return null},o=function(e){var t=["date","time","datetime"];return-1<t.indexOf(e)?e:null};!e.customTemplate&&e.dataSourceScreen&&e.dataSourceScreen.entityDataSource&&e.dataSourceScreen.entityDataSource.schemaFields&&(e.format||o(i(e.dataTextField)))&&(e.template="#= useMask("+e.dataTextField+",'"+e.format+"','"+i(e.dataTextField)+"') #",e.valueTemplate="#= useMask("+e.dataTextField+",'"+e.format+"','"+i(e.dataTextField)+"') #");var d={dataTextField:null==e.dataTextField?void 0:e.dataTextField,dataValueField:null==e.dataValueField?void 0:e.dataValueField,dataSource:t,headerTemplate:null==e.headerTemplate?void 0:e.headerTemplate,template:null==e.template?void 0:e.template,tagTemplate:null==e.tagTemplate?void 0:e.tagTemplate,placeholder:null==e.placeholder?void 0:e.placeholder,footerTemplate:null==e.footerTemplate?void 0:e.footerTemplate,filter:null==e.filter?void 0:e.filter,valuePrimitive:n,valueTemplate:null==e.valueTemplate?void 0:e.valueTemplate,suggest:!0};return e.optionLabel&&(e.optionLabelText=e.optionLabel,e.optionLabelValue=""),d.optionLabel={},d.optionLabel[d.dataTextField]=void 0===e.optionLabelText?"":e.optionLabelText,d.optionLabel[d.dataValueField]=void 0===e.optionLabelValue?null:e.optionLabelValue,d},getConfigComboboxSync:function(e,t){var a={};if(e){if(!e.dynamic||"false"==e.dynamic){a.data=null==e.staticDataSource?void 0:e.staticDataSource;for(let n=0;n<a.data.length;n++)try{a.data[n].key&&a.data[n].key.startsWith("cronapi.server(")&&(a.data[n].key=a.data[n].key.replace(".run(",".notAsync().run("));let e=t.$eval(a.data[n].key);a.data[n].key=void 0!==e&&null!==e?e:a.data[n].key}catch(t){a.data[n].key=a.data[n].key}}return config=this.parseOptionsCronToConfigKendo(e,a,t),config}return{}},getConfigCombobox:async function(e,t){var a={};if(e){if(!e.dynamic||"false"==e.dynamic){a.data=null==e.staticDataSource?void 0:e.staticDataSource;for(let n=0;n<a.data.length;n++)try{a.data[n].key&&a.data[n].key.startsWith("cronapi.server(")&&(a.data[n].key=a.data[n].key.replace(".run(",".toPromise().run("));let e=await t.$eval(a.data[n].key);a.data[n].key=void 0!==e&&null!==e?e:a.data[n].key}catch(t){a.data[n].key=a.data[n].key}}return config=this.parseOptionsCronToConfigKendo(e,a,t),config}return{}},getConfigDate:function(e,t){var a={};if(a){var n=function(e){e=e.replace(/_/gm,"-");var t=e.split("-");return t[t.length-1]=t[t.length-1].toUpperCase(),t.join("-")},i=function(e){return e&&(e=e.replace(/:MM/gm,":mm"),e=e.replace(/:M/gm,":m"),e=e.replace(/S/gm,"s"),e=e.replace(/D/gm,"d"),e=e.replace(/Y/gm,"y")),e},o=function(t,a){return null==a&&(a=parseMaskType(t,e)),a},d={};if(t.animation)try{d=JSON.parse(t.animation)}catch(e){console.log("DateAnimation invalid configuration! "+e)}var l=o(t.type,t.format),r=i(l),s=i(t.timeFormat),c=n(e.use());a={value:null,format:r,timeFormat:s,momentFormat:l,culture:c,type:null==t.type?void 0:t.type,weekNumber:null==t.weekNumber?void 0:t.weekNumber,dateInput:null==t.dateInput?void 0:t.dateInput,animation:d,footer:null==t.footer?void 0:t.footer,start:null==t.start?void 0:t.start,depth:null==t.start?void 0:t.start}}return a},buildKendoMomentPicker:function(e,t,a,n){var i="date"==t.type||"datetime"==t.type||"time"==t.type;window.fixedTimeZone||(i=!1),e.data("mask",t.momentFormat),e.data("useUTC",i);var o=function(){var a=e.val();if(!a||""==a.trim())n&&n.$setViewValue("");else{var o=formatWithMomentAs(t.momentFormat,i,a,"date");n&&(n.$setViewValue(o),e.data("changed",!0))}};return(t.change=a?function(){a.$apply(function(){o()})}:o,"date"==t.type)?e.kendoDatePicker(t).data("kendoDatePicker"):"datetime"==t.type||"datetime-local"==t.type?e.kendoDateTimePicker(t).data("kendoDateTimePicker"):"time"==t.type||"time-local"==t.type?e.kendoTimePicker(t).data("kendoTimePicker"):void 0},getConfigSlider:function(e){e=e||{};var t={increaseButtonTitle:e.increaseButtonTitle,decreaseButtonTitle:e.decreaseButtonTitle,dragHandleTitle:e.dragHandleTitle};try{t.min=e.min?parseInt(e.min):1,t.max=e.max?parseInt(e.max):1,t.smallStep=e.smallStep?parseInt(e.smallStep):1,t.largeStep=e.largeStep?parseInt(e.largeStep):1}catch(e){console.log("Slider invalid configuration! "+e)}return t},getConfigSwitch:function(e){e=e||{};var t={onLabel:null==e.onLabel?void 0:e.onLabel,offLabel:null==e.offLabel?void 0:e.offLabel};return t},getConfigBarcode:function(e){var t={type:null==e.type?void 0:e.type,width:null==e.width?void 0:parseInt(e.width),height:null==e.height?void 0:parseInt(e.height)};return t.type||(t.type="EAN8"),t},getConfigQrcode:function(e){var t={errorCorrection:null==e.errorCorrection?void 0:e.errorCorrection,size:null==e.size?void 0:parseInt(e.size),color:null==e.color?void 0:e.color};return(e.borderColor||e.borderSize)&&(t.border={size:null==e.size?void 0:parseInt(e.size),color:null==e.color?void 0:e.color}),t}},window.showTreatedValue=function(e){return e||!1===e?e:""},window.useMask=function(e,t,a){var n="";t="null"==t||"undefined"==t?void 0:t;var i=e,o=t||a;if(null!=e&&e!=null){if(e instanceof Date){var d=moment(e).utcOffset(window.timeZoneOffset);i="\""+d.format()+"\""}else i="number"==typeof e?e:"\""+e+"\"";n="{{ "+i+" | mask:\""+o+"\":\""+a+"\"}}"}return n},window.formatWithMomentAs=function(e,t,a,n){if(!a)return;let i=null;return i=a instanceof Date||a.startsWith("/Date")?t?moment(a).utcOffset(window.timeZoneOffset):moment(a):t?moment(a,e).utcOffset(window.timeZoneOffset,!0):moment(a,e),"string"===n?i.format(e):i.toDate()};function cronFrame($compile,$sce,$parse){"use strict";return{restrict:"AE",link:function(scope,element,attrs,ngModelCtrl){scope.fragment=scope.fragment||{};var framentMap=scope.fragment[element.parent.id]||{};scope.$watch(function(){return attrs.origin},function(newVal){let template="",style=attrs.style||"",clazz=attrs.class||"";if(attrs.origin)if(attrs.type||(attrs.type="include"),"include"==attrs.type){let str=`<div style="${style}" class="${clazz}" ng-include="'${attrs.origin}'" ng-if="true"></div>`;if(template=$(str),attrs.params)try{let params=eval(attrs.params);for(let e in params){let t=params[e];"expression"==t.type?scope.$watch(t.value,function(e){framentMap[t.key]=e;var a=$(str);a.attr("onload",`params = ${JSON.stringify(framentMap)}`);var n=$compile(a)(scope);element.html(n)}):framentMap[t.key]=t.value}template.attr("onload",`params = ${JSON.stringify(framentMap)}`)}catch(e){console.error(e)}}else if("frame"==attrs.type){var url=$sce.trustAsResourceUrl(attrs.origin);template=$(`<iframe style="${style}" class="${clazz}" ng-src="${url}" width="100%" height="100%" loading="lazy"></iframe>`)}element.html(template),$compile(template)(scope)})}}}function cronReportViewer(e){return{restrict:"E",replace:!0,require:"ngModel",link:function(e,t,a,n){function i(a){var n=JSON.parse(a),i={element:t};e.$eval(n.reportCommand||n.dashboardCommand,i)}i(a.options);let o=t[0].parentElement;for(;o;)if("BODY"===o.tagName)o=null;else if(o.classList.contains("tab-pane"))break;else o=o.parentElement;if(o&&!o.classList.contains("active")){let e=new MutationObserver(function(e,t){for(let n of e)if("class"===n.attributeName&&n.target.classList.contains("active")){i(a.options),t.disconnect();break}});e.observe(o,{attributes:!0})}var d=null;e.$watch(function(){return a.options},function(e,t){e!==t&&(d&&(clearInterval(d),d=null),d=setTimeout(function(){i(e)}.bind(this),500))})}}}
55
+ </li>`}),i},link:function(a,n,i){var o=this.populateMenu;i.$observe("options",function(d){t.onReady(()=>{let t=n.closest(".crn-navigator-vertical").length;var l={};try{l=JSON.parse(d)}catch(t){console.log("CronDynamicMenu: Invalid configuration!")}let r=l&&l.subMenuOptions&&l.subMenuOptions.length?l.subMenuOptions[0].id:"first";var s=`<ul id="menu-tag-ul-base-${r}" class="nav navbar-nav ${t?"col-md-12 padding-0":""}" ></ul>`,c=$(s);c.attr("id",i.id);var p=o(l,t);c.append(p),t&&c.append($("#navbar2 li:first").addClass("col-md-12 padding-0"));var u=angular.element(c);n.html(""),n.append(c),n.attr("id",null),e(u)(a);var m=i.multilevelAction;"hover"===m&&($(".dropdown-menu .dropdown-submenu").on("mouseover",function(){var e=$(this).children("ul.dropdown-menu");e.addClass("displayBlock")}),$(".dropdown-menu .dropdown-submenu").on("mouseout",function(){var e=$(this).children("ul.dropdown-menu");e.removeClass("displayBlock")})),"click"===m&&$(".dropdown-menu a.dropdown-toggle").on("click",function(t){$(this).next().hasClass("show")||$(this).parents(".dropdown-menu").first().find(".show").removeClass("show");var e=$(this).next(".dropdown-menu");return e.toggleClass("show"),$(this).parents("li.nav-item.dropdown").on("hidden.bs.dropdown",function(t){$(".dropdown-submenu .show").removeClass("show")}),!1}),$("#checkCollapsibleMenu").on("click",function(){var e=document.getElementById("main-view");this.checked?e.classList.remove("main-view-retratil"):e.classList.add("main-view-retratil")})})})}}}]).directive("cronBreadcrumbs",["$rootScope",function(e){"use strict";return{restrict:"E",replace:!0,link:function(e,t,a){var n=a.ngInit?a.ngInit:null;const i=a.crnDelimiterIcon,o=a.typeMenu,d=a.idMenu?a.idMenu:null,l=a.id,r=a.breadcrumbIcon?a.breadcrumbIcon:null,s=[],c=async()=>{const t=n.replace("cronapi.client('js.","blockly.js.");n=t.replace("').run()",""),n=e.$eval(n),s=await n();const a=async t=>{t.item.action&&t.item.action()};$(`#${l}`).kendoBreadcrumb({items:s,delimiterIcon:i,navigational:!0,click:a})},p=e=>e?e.replace("cronapi.screen.changeView('","").replace("', [])",""):"#/home";if(n&&"idBloco"===o)c();else{var u=new MutationObserver((e,t)=>{const a=$(`#${d}`).parent(),n=a.attr("options");if(n){t.disconnect();const e=JSON.parse(n),a=document.location.hash||"home",d=(e,t,a=[])=>{for(let o=0;o<e.length;o++){var n=e[o];if(n.action=p(n.action),n.action===t)return[...a,n];if(n.menuItems){const e=d(n.menuItems,t,[...a,n]);if(e)return e}}return null},r=d(e.subMenuOptions,a);if(r){for(var o in r){const e=r[o];s.push({type:0==o?"rootitem":"item",href:e.action,text:e.title,showText:!0,showIcon:!1})}$(`#${l}`).kendoBreadcrumb({items:s,delimiterIcon:i,navigational:!0})}}});u.observe(document.body,{childList:!0})}}}}]).directive("ngInitialValue",["$parse",function(e){return{restrict:"A",require:"ngModel",link:async function(t,a,n,i){if(n.ngInitialValue){var o,d=e(n.ngModel),l=d.assign;try{if(-1!=n.ngInitialValue.indexOf("cronapi.client('js.")){let e=n.ngInitialValue.replace("cronapi.client('js.","blockly.js."),a=e.split("').names")[0];a=a.split("').attr()")[0];let i=e.split(".run")[1];o=await t.$eval(a+i)}else o=t.$eval(n.ngInitialValue)||n.ngInitialValue}catch(t){o=n.ngInitialValue}"checkbox"==a[0].type&&o&&(o="true"==(""+o).toLowerCase()),l(t,o)}}}}]).directive("crnSetIndeterminate",["$parse",function($parse){return{restrict:"A",link:function(scope,element,attrs){let value=eval(attrs.crnSetIndeterminate);null===value&&$(element).prop("indeterminate",!0)}}}]).directive("crnAllowNullValues",[function(){return{restrict:"A",require:"?ngModel",link:function(e,t,a,n){n.$formatters=[],n.$parsers=[];let i=e=>(e&&-1===e.indexOf("'")&&(e=`'${e}'`),e);a.ngFalseValue=i(a.ngFalseValue),a.ngTrueValue=i(a.ngTrueValue);let o=!!a.ngFalseValue&&a.ngFalseValue.split("'").join(""),d=!a.ngTrueValue||a.ngTrueValue.split("'").join(""),l=e=>"true"===e||void 0===e||null===e||0==e.length;n.$render=l(a.crnAllowNullValues)?function(){let e=n.$viewValue;t.data("checked",e),!0===e||e===d?(t.prop("indeterminate",!1),t.prop("checked",!0),e=d):!1===e||e===o?(t.prop("indeterminate",!1),t.prop("checked",!1),e=o):(e=null,t.prop("indeterminate",!0)),setTimeout(()=>n.$setViewValue(e))}:function(){let i=n.$viewValue;if((void 0===n.$viewValue||null===n.$viewValue)&&(n.$setViewValue(!1),i=!1),i===o){let n=a.ngFalseValue?`${t.attr("ng-model")}=${a.ngFalseValue}`:`${t.attr("ng-model")}=${o}`;e.$eval(n)}switch(t.data("checked",i),i){case!0:case d:t.prop("indeterminate",!1),t.prop("checked",!0),i=d;break;default:t.prop("indeterminate",!1),t.prop("checked",!1),i=o}setTimeout(()=>n.$setViewValue(i))},t.bind("click",function(){let i;switch(t.data("checked")){case!1:case o:i=!a.ngTrueValue||d;break;default:i=!!a.ngFalseValue&&o}n.$setViewValue(i),e.$apply(n.$render)})}}}]).directive("signaturePad",["$compile","$window",function(e,t){"use strict";var a,n,i=null;return{restrict:"E",require:"ngModel",scope:!0,replace:!0,transclude:!0,template:"<div style=\"height: 100%; width: 100%;\"> <canvas style=\"width:100%; height: 100%;\" ng-click=\"mouseup()\" ng-mouseup=\"mouseup()\"></canvas> <div class=\"component-holder ng-scope col-md-2\" style=\"bottom: 0; position: absolute; padding-left: 5px;\" data-component=\"crn-button\"> <button class=\"btn k-button btn-warning\" ng-click=\"clear()\" xattr-fullsize=\"\" xattr-theme=\"btn-warning\" xattr-disabled=\"\"> <i class=\"glyphicon glyphicon-erase\" icon-theme=\"\"></i> <span class=\"\" text-theme=\"\">{{'clear'|translate}}</span> </button> </div> </div>",scope:{dataurl:"=",ngClick:"@",ngModel:"="},controller:["$scope",function(t){let a=()=>{let e=t.signaturePad.toDataURL();return e&&(e=e.split(",")[1]),e};t.mouseup=function(n){t.signaturePad.isEmpty()||(t.ngModel=a())},t.$watch("ngModel",function(e,n){e!==n&&(a()!==e&&t.signaturePad.fromDataURL("data:image/png;base64,"+e,{ratio:1}),t.ngModel=e)},!0),t.clear=function(){t.signaturePad.clear(),t.ngModel=null}}],link:function(n,i,o,d,l){a=i.find("canvas")[0],n.onResize=function(){var e=Math.max(t.devicePixelRatio||1,1),a=i.find("canvas")[0],n=document.createElement("canvas");n.width=a.width,n.height=a.height;var o=n.getContext("2d");o.drawImage(a,0,0),a.width=a.offsetWidth*e,a.height=a.offsetHeight*e,a.getContext("2d").drawImage(n,0,0),a.getContext("2d").scale(e,e)},n.onResize(),n.signaturePad=new SignaturePad(a),angular.element(t).on("resize",function(){n.onResize()}),e(i)(i.scope());let r=!1;$(a).on("pointerdown",t=>{1===t.which&&(r=!0),t.preventDefault()}),$(a).on("pointerup",t=>{1===t.which&&r&&(r=!1,l(()=>angular.element(a).triggerHandler("mouseup")))})}}}]).directive("cronChat",["$compile","$translate",function(e,t){return{restrict:"E",replace:!0,link:function(e,t,a,n){var i=JSON.parse(a.options||"{}");if(i.token&&i.urlCronchat){var o=i.urlCronchat.endsWith("/")?i.urlCronchat:i.urlCronchat+"/",d=i.token,l=$(`<script src="${o}get-chat?token=${d}" type="text/javascript"></script>`);t.html(l)}}}}]).directive("updateLanguage",["$rootScope",function(e){return{link:function(t,a){var n=function(e,t){var n="en",i=t.language;"pt_br"===i?i="pt-br":i.startsWith("en")&&(i="en"),a.attr("lang",i||"en")};e.$on("$translateChangeSuccess",n)}}}]).directive("cronFrame",cronFrame).directive("crnComponent",cronFrame).directive("fromGrid",["$compile",e=>({restrict:"A",priority:-999999,exist:e=>{let t=e.attr("id");return $(`#${t}`).length},isFromGrid:e=>"true"===e.fromGrid,isCompiled:e=>e.data("alreadycompiled"),getDateAs:function(e,t,a){let n=e.data("mask"),i=e.data("useUTC");return formatWithMomentAs(n,i,t,a)},prepareValue:function(e,t){let a=e.data("column-type")||"";return a.startsWith("date")&&(t=this.getDateAs(e,t,"date")),t},formatComponent:function(e,t){let a=e.data("kendoDropDownList")||e.data("kendoSlider"),n=e.data("column-type")||"";n.startsWith("date")?e.val(this.getDateAs(e,t,"string")):a&&a.value(t)},compileGridListing:function(t,a){let n=t.data("ref-component");if(n&&n.tbody&&n.tbody.length&&!$(n.tbody).find(".k-grid-edit-row").length){var i=n.tbody;setTimeout(()=>{a.safeApply(()=>{var t=$(i),n=angular.element(t);e(n)(a)})})}},link:function(e,t,a){e.$watch(a.ngModel,n=>{this.isFromGrid(a)&&this.exist(t)&&this.isCompiled(t)&&(n=this.prepareValue(t,n),this.formatComponent(t,n),this.compileGridListing(t,e),call=t.data("change-grid-model"),call&&call(n))})}})]).directive("cronOrderedList",["$compile","$sce","$parse",function(e,t,a){"use strict";return{restrict:"EA",replace:!0,link:function(t,a,n,i){let o=n.attributeValue,d=n.orderedAttributeValue,l=n.listType,r=a[0].children[0].children;r=$(r);let s="",c="";$.each(r,function(e,t){c+=t.outerHTML});"numbered-list"===l?s=`<ol style="list-style-type: ${o}">${c}</ol>`:"ordered-list"===l?s=`<ul style="list-style-type: ${d}">${c}</ul>`:void 0;s=$(s),$(a).replaceWith(s),e(s)(t)}}}]).directive("crnInfiniteScroll",["$compile",function($compile){"use strict";return{restrict:"EA",link:function(scope,element,attrs){var dataSource=attrs.crnInfiniteScroll?eval(attrs.crnInfiniteScroll):attrs.crnDatasource?eval(attrs.crnDatasource):void 0;if(dataSource){let e={isVisible:!1,checkVisibility:function(t){if(e.isVisible!==t&&(e.isVisible=t,e.isVisible))if(dataSource.loaded&&dataSource.loadedFinish)dataSource.nextPage();else{let e=setInterval(function(){dataSource.loaded&&dataSource.loadedFinish&&(dataSource.nextPage(),clearInterval(e))},250)}},eventScroll:function(){var t=element.offset().top,a=element.offset().top+element.outerHeight(),n=$(window).scrollTop()+$(window).innerHeight(),i=$(window).scrollTop();e.checkVisibility(n>t&&i<a)}};$(window).scroll(e.eventScroll),$(window).ready(e.eventScroll)}}}}])}(app);function maskDirectiveAsDate(e,t,a){return maskDirective(e,t,a,"as-date")}function maskDirectiveMask(e,t,a){return maskDirective(e,t,a,"mask")}function maskDirective(e,t,a,n){return{restrict:"A",require:"?ngModel",link:function(i,o,d,l){if("as-date"!=n||void 0===d.mask){var r=a(d.ngModel),s=r.assign,c=$(o);if(!c.data("alreadycompiled")){c.data("alreadycompiled",!0),c.data("$compile",e);var p=c.attr("type");if("checkbox"!=p&&"password"!=p&&"url"!=p){if("color"==p||"range"==p)return c[0].classList.remove("form-control"),void c[0].classList.remove("k-textbox");c.data("type",p),c.attr("type","text"),l&&(l.$formatters=[],l.$parsers=[]),void 0!==d.asDate&&"text"==p&&(p="date");var u=!0,m=!1,g=d.mask||d.format;g=g?parseMaskType(g,t):parseMaskType(p,t),g.endsWith(";0")&&(m=!0);var f=g.replace(";1","").replace(";0","").trim();if(null!=f&&0!=f.length)if("date"==p||"datetime"==p||"datetime-local"==p||"month"==p||"time"==p||"time-local"==p||"week"==p){var h={format:f,locale:t.use(),showTodayButton:!0,useStrict:!0,tooltips:{today:t.instant("DatePicker.today"),clear:t.instant("DatePicker.clear"),close:t.instant("DatePicker.close"),selectMonth:t.instant("DatePicker.selectMonth"),prevMonth:t.instant("DatePicker.prevMonth"),nextMonth:t.instant("DatePicker.nextMonth"),selectYear:t.instant("DatePicker.selectYear"),prevYear:t.instant("DatePicker.prevYear"),nextYear:t.instant("DatePicker.nextYear"),selectDecade:t.instant("DatePicker.selectDecade"),prevDecade:t.instant("DatePicker.prevDecade"),nextDecade:t.instant("DatePicker.nextDecade"),prevCentury:t.instant("DatePicker.prevCentury"),nextCentury:t.instant("DatePicker.nextCentury")}};"DD/MM/YYYY"!=f&&"MM/DD/YYYY"!=f&&(h.sideBySide=!0);var v="date"==p||"datetime"==p||"time"==p;if(window.fixedTimeZone||(v=!1),c.data("mask",f),c.data("useUTC",v),c.attr("from-grid")){var b=function(){var e=$(this).offset(),t=!0,a=$(this).parent().find(".bootstrap-datetimepicker-widget.dropdown-menu.usetwentyfour.bottom");if(a.length||(t=!1,a=$(this).parent().find(".bootstrap-datetimepicker-widget.dropdown-menu.usetwentyfour.top")),$(a).offset()){var n=$(a).offset().left,i=$("body");a.appendTo(i);var o=0;o=t?e.top+35:e.top-($(a).height()+15),a.css("top",o),a.css("bottom","auto"),a.css("left",n),a.css("z-index",999999)}};if(c.on("click",b),c.on("focus",function(){setTimeout(b.bind(this),100)}),c.on("dp.change",function(){i.safeApply(function(){var e=null;e=v?moment(c.val(),f).utcOffset(window.timeZoneOffset,!0):moment(c.val(),f),("time"==p||"time-local"==p)&&(e=e.year(1970).dayOfYear(1).month(0)),e.isValid()&&l&&s(i,e.toDate())})}),c.data("initial-value")){var y=c.data("initial-value"),k=null;k=v?moment(y).utcOffset(window.timeZoneOffset):moment(y),c.val(k.format(f)),c.data("initial-value",null)}}else c.wrap("<div style=\"position:relative\"></div>");c.datetimepicker(h),"true"!==d.fromGrid&&c.on("dp.change",function(){$(this).is(":visible")&&($(this).trigger("change"),i.safeApply(function(){var e=c.val(),t=null;t=v?moment(e,f).utcOffset(window.timeZoneOffset,!0):moment(e,f),("time"==p||"time-local"==p)&&(t=t.year(1970).dayOfYear(1).month(0)),t.isValid()&&l&&s(i,t.toDate())}))}),l&&(l.$formatters.push(function(e){if(e)return formatWithMomentAs(f,v,e,"string");if(null===e){var t=c.datetimepicker(h).data("DateTimePicker");t.date(null)}return null}),l.$parsers.push(function(e){if(e){if(e instanceof Date)return e;var t=null;return t=v?moment(e,f).utcOffset(window.timeZoneOffset,!0):moment(e,f),("time"==p||"time-local"==p)&&(t=t.year(1970).dayOfYear(1).month(0)),t.toDate()}return null}))}else if("number"==p||"money"==p||"integer"==p||"money-decimal"==p){m=!0;var C=f.trim().replace(/\./g,"").replace(/\,/g,"").replace(/#/g,"").replace(/0/g,"").replace(/9/g,""),w="",S="",D="",T=",",M=0;f.startsWith(C)?w=C:f.endsWith(C)&&(S=C);var x=f.trim().replace(w,"").replace(S,"").trim();x.startsWith("#.")?D=".":x.startsWith("#,")&&(D=",");var I=null;if(-1==x.indexOf(",0")?-1!=x.indexOf(".0")&&(T=".",I=".0"):(T=",",I=",0"),null!=I){var E=x.substring(x.indexOf(I)+1);M=E.length}var A="numeric";0==M&&(A="integer"),"money-decimal"==p&&(A="currency");var F={rightAlign:"money"==p||"money-decimal"==p,unmaskAsNumber:!0,allowMinus:!0,prefix:w,suffix:S,radixPoint:T,digits:M,numericInput:"money-decimal"==p};D&&(F.autoGroup=!0,F.groupSeparator=D),$(o).inputmask(A,F),useInputMaskPlugin(o,l,i,s,f)}else if("text"==p||"tel"==p||"string"==p){let e=["D","M","Y","H","m","s"],t=t=>(e.forEach(e=>t=t.replaceAll(e,"9")),t);f=t(f),d.maskPlaceholder?(h={},h.placeholder=d.maskPlaceholder,$(o).inputmask(f,h),m&&useInputMaskPlugin(o,l,i,s,f)):(c.mask(f),useMaskPlugin(o,l,i,s,m))}}}}}}}function useInputMaskPlugin(e,t,a,n,i){var o=$(e),d=function(){$(this).data("rawvalue",$(this).inputmask("unmaskedvalue"))};$(e).on("keydown",d).on("keyup",d),t&&(t.$formatters.push(function(e){return null!=e&&null!=e&&""!==e?format(i,e):null}),t.$parsers.push(function(e){if(e!=null&&null!=e&&""!==e){var t=o.inputmask("unmaskedvalue");if(""!==t)return t}return null}))}function useMaskPlugin(e,t,a,n,i){var o=$(e),d=function(){i&&$(this).data("rawvalue",$(this).cleanVal())};$(e).on("keydown",d).on("keyup",d),i&&t&&(t.$formatters.push(function(e){return e?o.masked(e):null}),t.$parsers.push(function(e){return e?o.cleanVal():null}))}function parseMaskType(e,t){return"datetime"==e||"datetime-local"==e?(e=t.instant("Format.DateTime"),"Format.DateTime"==e&&(e="DD/MM/YYYY HH:mm:ss")):"date"==e?(e=t.instant("Format.Date"),"Format.Date"==e&&(e="DD/MM/YYYY")):"time"==e||"time-local"==e?(e=t.instant("Format.Hour"),"Format.Hour"==e&&(e="HH:mm:ss")):"month"==e?e="MMMM":"number"==e?(e=t.instant("Format.Decimal"),"Format.Decimal"==e&&(e="#.#00,00")):"money"==e||"money-decimal"==e?(e=t.instant("Format.Money"),"Format.Money"==e&&(e="#.#00,00")):"integer"==e?(e=t.instant("Format.Integer"),"Format.Integer"==e&&(e="#,##0.####")):"week"==e?e="dddd":"tel"==e?e="(00) 00000-0000;0":"text"==e?e="":"string"==e&&(e=""),e}function transformText(){return{restrict:"E",require:"?ngModel",link:function(e,t,a,n){var i=function(e,t){if(e){if(t!==void 0&&null!==t){if("uppercase"===e.css("text-transform"))return t.toUpperCase();if("lowercase"===e.css("text-transform"))return t.toLowerCase()}return t}};n&&(n.$formatters.push(function(e){return i(t,e)}),n.$parsers.push(function(e){return i(t,e)}))}}}app.kendoHelper={getCorrectlyDS:(e,t)=>{if(t[e]&&t[e].apiVersion)return t[e];else{let a=t.$parent[e];return t[e]=a,a}},getCorrectlyDSPromise:async(e,t)=>new Promise((a,n)=>{let i=()=>{let o=null;if(t[e]&&t[e].apiVersion)o=t[e];else{let a=t.$parent[e];t[e]=a,o=a}o?a(o):$(`datasource[name="${e}"]`).length?setTimeout(()=>i(),100):n(null)};i()}),receivePushData:e=>!e||!e.dataSource||(e.dataSource.transport.options.refComponent=e),getSchema:function(e){var t=[{kendoType:"string",entityType:["string","character","uuid","guid"]},{kendoType:"number",entityType:["integer","long","double","int","float","bigdecimal","single","int32","int64","decimal","byte"]},{kendoType:"date",entityType:["date","time","datetime"]},{kendoType:"boolean",entityType:["boolean"]}],a=function(e){for(var a=0;a<t.length;a++)if(t[a].entityType.includes(e.toLocaleLowerCase()))return t[a].kendoType;return"string"},n={model:{id:"__$id",fields:{}}};return e&&e.schemaFields&&(e.schemaFields.forEach(function(e){n.model.fields[e.name]={type:a(e.type),editable:!0,nullable:e.nullable,validation:{required:!e.nullable}}}),n.model.fields.__$id={type:"string",editable:!0,nullable:!0,validation:{required:!1}}),n},getDataSource:function(t,a,n,i,o,d){var l=Number.MAX_SAFE_INTEGER_32;function r(t){if(t.response&&t.response.d){var e=null;e=t.response.d.results?t.response.d.results:[t.response.d],this.group().length?o.forEach(function(t){if("Database"==t.dataType){var a="datetime-local"==t.type||"month"==t.type||"time-local"==t.type||"week"==t.type;if(a)for(var n,o=0;o<e.length;o++)n=e[o],t.field==n.Member&&(n.Key=n.Key.replace(/\d+/,function(e){return parseInt(e)+g})),s.bind(this)(n.Items)}}):s.bind(this)(e)}}function s(e){for(var t=0;t<e.length;t++)o&&o.forEach(function(a){if("Database"==a.dataType){var n="datetime-local"==a.type||"month"==a.type||"time-local"==a.type||"week"==a.type;n&&e[t][a.field]&&(e[t][a.field]=e[t][a.field].replace(/\d+/,function(e){return parseInt(e)+g}))}})}function c(e){var t=[];return e&&e.forEach(function(e){e.aggregates&&e.aggregates.forEach(function(a){t.push({field:e.field,aggregate:a.type})})}),t}var p=this.getSchema(t);o&&o.forEach(function(e){for(var t in p.model.fields)if("Database"==e.dataType&&e.field==t){if(p.model.fields[t].nullable=!e.required,p.model.fields[t].validation.required=e.required,"999.999.999-99;0"===e.format||"99.999.999/9999-99;0"===e.format){let a="999.999.999-99;0"===e.format?"cpf":"cnpj",n={cpf:CPF,cnpj:CNPJ},i=t.toLocaleLowerCase()+"validation";p.model.fields[t].validation[i]=function(e){return!(e.is("[name='"+t+"']")&&""!=e.val())||n[a].isValid(e.val())}}break}});var u=function(e){for(var t in e)if(p.model.fields.hasOwnProperty(t)){var a=p.model.fields[t];"string"==a.type&&null!=e[t]?e[t]+="":"number"==a.type&&null!=e[t]?e[t]=parseFloat(e[t]):"date"==a.type&&null!=e[t]?e[t]="/Date("+e[t].getTime()+")/":"boolean"==a.type&&(null==e[t]?e[t]=!1:e[t]="true"==e[t].toString().toLowerCase()),p.model.id==t&&null!=e[t]&&0==e[t].toString().length&&delete e[t]}return e},m=10;app.kendoHelper.getCorrectlyDS(t.name,a)&&(m=app.kendoHelper.getCorrectlyDS(t.name,a).rowsPerPage);var g=6e4*new Date().getTimezoneOffset(),f=app.common.generateId(),h={transport:{setActiveAndPost:function(t){var e=this.options.cronappDatasource;a.safeApply(e.updateActive(u(t.data))),e.active.__sender=f,e.postSilent(function(e){this.options.enableAndSelect(t),t.success(e),this.options.refComponent.dataSource._pristineTotal=this.options.refComponent.dataSource._pristineData.push(e)}.bind(this),function(e){this.options.enableAndSelect(t),t.error(e,e,e)}.bind(this))},pushAction:function(e,t){return a=>{let n=["read","memorydelete","overRideRefresh"];if(this.options.isComponentInDocument(this.options.refComponent)){let n=this.options.getCurrentCallbackForPush(t,this.options.refComponent),i=n[e];i?i(a):(this.options.fromRead="read"===e,this.options.cronappDatasource.reloadedFromCronapi&&(this.options.fromRead=!1,delete this.options.cronappDatasource.reloadedFromCronapi),"overRideRefresh"===e&&(this.options.refComponent.dataSource._page=1,this.options.refComponent.dataSource._skip=0),this.options.refComponent.dataSource.read())}else n.includes(e)||this.options.cronappDatasource.removeDataSourceEvents(this.options.dataSourceEventsPush)}},push:function(e){!this.options.dataSourceEventsPush&&this.options.cronappDatasource&&(this.options.dataSourceEventsPush={create:this.pushAction.bind(this)("pushUpdate",e),update:this.pushAction.bind(this)("pushUpdate",e),delete:this.pushAction.bind(this)("pushDestroy",e),overRideRefresh:this.pushAction.bind(this)("overRideRefresh",e),read:this.pushAction.bind(this)("read",e),memorycreate:this.pushAction.bind(this)("pushUpdate",e),memoryupdate:this.pushAction.bind(this)("pushUpdate",e),memorydelete:this.pushAction.bind(this)("pushDestroy",e)},"combobox"==this.origin&&delete this.options.dataSourceEventsPush.overRideRefresh,this.options.cronappDatasource.addDataSourceEvents(this.options.dataSourceEventsPush))},read:function(a){var e=!1;try{var n=this.options.cronappDatasource;this.options.kendoCallback?this.options.fromRead?this.options.kendoCallback.success(n.data):e=!0:(this.options.kendoCallback=a,e=!0)}finally{this.options.fromRead=!1}if(e){for(key in a.data)null==a.data[key]&&delete a.data[key];var i=kendo.data.transports.odata.parameterMap(a.data,"read"),o="";this.options.refComponent&&this.options.refComponent.dataSource.group().forEach(function(e){o+=e.field+" "+e.dir+","}),0<o.length&&(o=o.substr(0,o.length-1),i.$orderby=i.$orderby?o+","+i.$orderby:o);var n=this.options.cronappDatasource;if(n.rowsPerPage=a.data.pageSize,n.offset=a.data.page-1,!a.data.pageSize&&(n.rowsPerPage=l,n.offset=void 0,i.$skip=0,this.options.refComponent&&1!=this.options.refComponent.dataSource.page()))return this.options.refComponent.dataSource.page(1),void a.error("canceled","canceled","canceled");var d={params:i},r=!1;t.append&&(r=t.append);var s={};"button"===n.loadDataStrategy&&0<n.data.length&&(s.origin=n.loadDataStrategy),n.append=r,n.fetch(d,{success:function(e){a.success(e)},canceled:function(e){a.error("canceled","canceled","canceled")},error:function(e){a.error("canceled","canceled","canceled")}},r,s)}},update:function(t){this.setActiveAndPost(t)},create:function(t){this.setActiveAndPost(t)},destroy:function(t){cronappDatasource=this.options.cronappDatasource,cronappDatasource.removeSilent(t.data,function(e){t.success(e)},function(e){t.error("canceled","canceled","canceled")})},batch:function(t){},options:{fromRead:!1,disableAndSelect:function(t){this.isComponentInDocument(this.refComponent)&&(this.refComponent.select(t.container),this.refComponent.options.selectable=!1,this.refComponent.selectable&&this.refComponent.selectable.element&&(this.refComponent.selectable.destroy(),this.refComponent.selectable=null))},enableAndSelect:function(t){this.isComponentInDocument(this.refComponent)&&(this.refComponent.options.selectable=this.refComponent.options.originalSelectable,this.refComponent._selectable(),this.refComponent.select(t.container))},selectActiveInGrid:function(e){if(this.isComponentInDocument(this.refComponent)&&this.refComponent.selectable&&0<this.refComponent.dataItems().length&&this.cronappDatasource.active&&this.cronappDatasource.active.__$id){for(var t=this.refComponent.dataItems(),a=-1,n=0;n<t.length;n++)if(this.cronappDatasource.active.__$id==t[n].__$id){a=n;break}-1<a&&!this.refComponent.selectable.options.multiple&&this.refComponent.select(this.refComponent.table.find("tr")[a+1])}},isComponentInDocument:function(e){return!!e&&$(document).has(e.element[0]).length},getCurrentCallbackForPush:function(e,t){return e?e:t},cronappDatasource:app.kendoHelper.getCorrectlyDS(t.name,a)}},pageSize:m,serverPaging:!0,serverFiltering:!0,serverSorting:!0,batch:!1,schema:p,requestEnd:r};return h.aggregate=c(o),h.schema.total=function(){return h.transport.options.cronappDatasource.getRowsCount()},d&&(h.group=[],d.forEach(function(e){var t={field:e.field,aggregates:h.aggregate};h.group.push(t)})),h},getEventReadCombo:function(t){var e=this.options.cronappDatasource;if(!e)return void t.error("canceled","canceled","canceled");this.options.kendoCallback||(this.options.kendoCallback=t);var a;if(this.options.combobox&&this.options.combobox.options.readData)return t.success(this.options.combobox.options.readData),this.options.combobox.options.readData=null,void(this.options.alreadyLoaded=!0);this.options.combobox?a=!this.options.alreadyLoaded:e.__ignoreFirstFetch?(a=!0,delete e.__ignoreFirstFetch):a=!1,this.options.alreadyLoaded=!0;var n=!0;if(a&&(n=!1,e.lazy?t.success([{}]):t.success([])),(this.options.fromRead||this.options.combobox&&void 0===this.options.combobox.options.firstLazyRead)&&(this.options.fromRead=!1,this.options.kendoCallback.success(e.data),n=!1),n){for(key in t.data)null==t.data[key]&&delete t.data[key];var i=kendo.data.transports.odata.parameterMap(t.data,"read");e.rowsPerPage=t.data.pageSize,e.offset=t.data.page-1;var o=this,d=!0,l={};l.params=i,o.options.combobox&&(o.options.combobox.options.fromCombo=!0),e.fetch(l,{success:function(e){if(t.success&&(o.options.combobox&&(o.options.combobox.options.expanded=!0),t.success(e),o.options.kendoCallback=t,o.options&&o.options.combobox&&o.options.combobox.element[0].id)){var a=" .k-animation-container",n=angular.element($(" .k-animation-container"));o.options.$compile(n)(o.options.scope)}},canceled:function(e){o.options.combobox&&(o.options.combobox.options.fromCombo=!1),t.success&&t.error("canceled","canceled","canceled")},error:function(e){o.options.combobox&&(o.options.combobox.options.fromCombo=!1),t.success&&t.error("error","error","error")}},!1,{ignoreAtive:!0})}},parseOptionsCronToConfigKendo:function(e,t,a){let n=!1;e.dynamic&&"false"!=e.dynamic?e.dataSourceScreen&&e.dataSourceScreen.entityDataSource&&(e.dataSourceScreen.entityDataSource.append=!0,t=app.kendoHelper.getDataSource(e.dataSourceScreen.entityDataSource,a,!0,e.dataSourceScreen.rowsPerPage),t.transport.read=app.kendoHelper.getEventReadCombo,n=!0):(n=!0,e.dataValueField=e.dataValueField||"value",e.dataTextField=e.dataTextField||"key"),e.dataValueField&&""!=e.dataValueField.trim()||(e.dataValueField=null==e.dataTextField?void 0:e.dataTextField);var i=function(t){var a=e.dataSourceScreen.entityDataSource.schemaFields;for(count=0;count<a.length;count++)if(t==a[count].name){return a[count].type.toLowerCase();break}return null},o=function(e){var t=["date","time","datetime"];return-1<t.indexOf(e)?e:null};!e.customTemplate&&e.dataSourceScreen&&e.dataSourceScreen.entityDataSource&&e.dataSourceScreen.entityDataSource.schemaFields&&(e.format||o(i(e.dataTextField)))&&(e.template="#= useMask("+e.dataTextField+",'"+e.format+"','"+i(e.dataTextField)+"') #",e.valueTemplate="#= useMask("+e.dataTextField+",'"+e.format+"','"+i(e.dataTextField)+"') #");var d={dataTextField:null==e.dataTextField?void 0:e.dataTextField,dataValueField:null==e.dataValueField?void 0:e.dataValueField,dataSource:t,headerTemplate:null==e.headerTemplate?void 0:e.headerTemplate,template:null==e.template?void 0:e.template,tagTemplate:null==e.tagTemplate?void 0:e.tagTemplate,placeholder:null==e.placeholder?void 0:e.placeholder,footerTemplate:null==e.footerTemplate?void 0:e.footerTemplate,filter:null==e.filter?void 0:e.filter,valuePrimitive:n,valueTemplate:null==e.valueTemplate?void 0:e.valueTemplate,suggest:!0};return e.optionLabel&&(e.optionLabelText=e.optionLabel,e.optionLabelValue=""),d.optionLabel={},d.optionLabel[d.dataTextField]=void 0===e.optionLabelText?"":e.optionLabelText,d.optionLabel[d.dataValueField]=void 0===e.optionLabelValue?null:e.optionLabelValue,d},getConfigComboboxSync:function(e,t){var a={};if(e){if(!e.dynamic||"false"==e.dynamic){a.data=null==e.staticDataSource?void 0:e.staticDataSource;for(let n=0;n<a.data.length;n++)try{a.data[n].key&&a.data[n].key.startsWith("cronapi.server(")&&(a.data[n].key=a.data[n].key.replace(".run(",".notAsync().run("));let e=t.$eval(a.data[n].key);a.data[n].key=void 0!==e&&null!==e?e:a.data[n].key}catch(t){a.data[n].key=a.data[n].key}}return config=this.parseOptionsCronToConfigKendo(e,a,t),config}return{}},getConfigCombobox:async function(e,t){var a={};if(e){if(!e.dynamic||"false"==e.dynamic){a.data=null==e.staticDataSource?void 0:e.staticDataSource;for(let n=0;n<a.data.length;n++)try{a.data[n].key&&a.data[n].key.startsWith("cronapi.server(")&&(a.data[n].key=a.data[n].key.replace(".run(",".toPromise().run("));let e=await t.$eval(a.data[n].key);a.data[n].key=void 0!==e&&null!==e?e:a.data[n].key}catch(t){a.data[n].key=a.data[n].key}}return config=this.parseOptionsCronToConfigKendo(e,a,t),config}return{}},getConfigDate:function(e,t){var a={};if(a){var n=function(e){e=e.replace(/_/gm,"-");var t=e.split("-");return t[t.length-1]=t[t.length-1].toUpperCase(),t.join("-")},i=function(e){return e&&(e=e.replace(/:MM/gm,":mm"),e=e.replace(/:M/gm,":m"),e=e.replace(/S/gm,"s"),e=e.replace(/D/gm,"d"),e=e.replace(/Y/gm,"y")),e},o=function(t,a){return null==a&&(a=parseMaskType(t,e)),a},d={};if(t.animation)try{d=JSON.parse(t.animation)}catch(e){console.log("DateAnimation invalid configuration! "+e)}var l=o(t.type,t.format),r=i(l),s=i(t.timeFormat),c=n(e.use());a={value:null,format:r,timeFormat:s,momentFormat:l,culture:c,type:null==t.type?void 0:t.type,weekNumber:null==t.weekNumber?void 0:t.weekNumber,dateInput:null==t.dateInput?void 0:t.dateInput,animation:d,footer:null==t.footer?void 0:t.footer,start:null==t.start?void 0:t.start,depth:null==t.start?void 0:t.start}}return a},buildKendoMomentPicker:function(e,t,a,n){var i="date"==t.type||"datetime"==t.type||"time"==t.type;window.fixedTimeZone||(i=!1),e.data("mask",t.momentFormat),e.data("useUTC",i);var o=function(){var a=e.val();if(!a||""==a.trim())n&&n.$setViewValue("");else{var o=formatWithMomentAs(t.momentFormat,i,a,"date");n&&(n.$setViewValue(o),e.data("changed",!0))}};return(t.change=a?function(){a.$apply(function(){o()})}:o,"date"==t.type)?e.kendoDatePicker(t).data("kendoDatePicker"):"datetime"==t.type||"datetime-local"==t.type?e.kendoDateTimePicker(t).data("kendoDateTimePicker"):"time"==t.type||"time-local"==t.type?e.kendoTimePicker(t).data("kendoTimePicker"):void 0},getConfigSlider:function(e){e=e||{};var t={increaseButtonTitle:e.increaseButtonTitle,decreaseButtonTitle:e.decreaseButtonTitle,dragHandleTitle:e.dragHandleTitle};try{t.min=e.min?parseInt(e.min):1,t.max=e.max?parseInt(e.max):1,t.smallStep=e.smallStep?parseInt(e.smallStep):1,t.largeStep=e.largeStep?parseInt(e.largeStep):1}catch(e){console.log("Slider invalid configuration! "+e)}return t},getConfigSwitch:function(e){e=e||{};var t={onLabel:null==e.onLabel?void 0:e.onLabel,offLabel:null==e.offLabel?void 0:e.offLabel};return t},getConfigBarcode:function(e){var t={type:null==e.type?void 0:e.type,width:null==e.width?void 0:parseInt(e.width),height:null==e.height?void 0:parseInt(e.height)};return t.type||(t.type="EAN8"),t},getConfigQrcode:function(e){var t={errorCorrection:null==e.errorCorrection?void 0:e.errorCorrection,size:null==e.size?void 0:parseInt(e.size),color:null==e.color?void 0:e.color};return(e.borderColor||e.borderSize)&&(t.border={size:null==e.size?void 0:parseInt(e.size),color:null==e.color?void 0:e.color}),t}},window.showTreatedValue=function(e){return e||!1===e?e:""},window.useMask=function(e,t,a){var n="";t="null"==t||"undefined"==t?void 0:t;var i=e,o=t||a;if(null!=e&&e!=null){if(e instanceof Date){var d=moment(e).utcOffset(window.timeZoneOffset);i="\""+d.format()+"\""}else i="number"==typeof e?e:"\""+e+"\"";n="{{ "+i+" | mask:\""+o+"\":\""+a+"\"}}"}return n},window.formatWithMomentAs=function(e,t,a,n){if(!a)return;let i=null;return i=a instanceof Date||a.startsWith("/Date")?t?moment(a).utcOffset(window.timeZoneOffset):moment(a):t?moment(a,e).utcOffset(window.timeZoneOffset,!0):moment(a,e),"string"===n?i.format(e):i.toDate()};function cronFrame($compile,$sce,$parse){"use strict";return{restrict:"AE",link:function(scope,element,attrs,ngModelCtrl){scope.fragment=scope.fragment||{};var framentMap=scope.fragment[element.parent.id]||{};scope.$watch(function(){return attrs.origin},function(newVal){let template="",style=attrs.style||"",clazz=attrs.class||"";if(attrs.origin)if(attrs.type||(attrs.type="include"),"include"==attrs.type){let str=`<div style="${style}" class="${clazz}" ng-include="'${attrs.origin}'" ng-if="true"></div>`;if(template=$(str),attrs.params)try{let params=eval(attrs.params);for(let e in params){let t=params[e];"expression"==t.type?scope.$watch(t.value,function(e){framentMap[t.key]=e;var a=$(str);a.attr("onload",`params = ${JSON.stringify(framentMap)}`);var n=$compile(a)(scope);element.html(n)}):framentMap[t.key]=t.value}template.attr("onload",`params = ${JSON.stringify(framentMap)}`)}catch(e){console.error(e)}}else if("frame"==attrs.type){var url=$sce.trustAsResourceUrl(attrs.origin);template=$(`<iframe style="${style}" class="${clazz}" ng-src="${url}" width="100%" height="100%" loading="lazy"></iframe>`)}element.html(template),$compile(template)(scope)})}}}function cronReportViewer(e){return{restrict:"E",replace:!0,require:"ngModel",link:function(e,t,a,n){function i(a){var n=JSON.parse(a),i={element:t};e.$eval(n.reportCommand||n.dashboardCommand,i)}i(a.options);let o=t[0].parentElement;for(;o;)if("BODY"===o.tagName)o=null;else if(o.classList.contains("tab-pane"))break;else o=o.parentElement;if(o&&!o.classList.contains("active")){let e=new MutationObserver(function(e,t){for(let n of e)if("class"===n.attributeName&&n.target.classList.contains("active")){i(a.options),t.disconnect();break}});e.observe(o,{attributes:!0})}var d=null;e.$watch(function(){return a.options},function(e,t){e!==t&&(d&&(clearInterval(d),d=null),d=setTimeout(function(){i(e)}.bind(this),500))})}}}