/***********************************************************************************
 * The contents of this file are subject to the Extension License Agreement
 * ("Agreement") which can be viewed at
 * https://www.espocrm.com/extension-license-agreement/.
 * By copying, installing downloading, or using this file, You have unconditionally
 * agreed to the terms and conditions of the Agreement, and You may not use this
 * file except in compliance with the Agreement. Under the terms of the Agreement,
 * You shall not license, sublicense, sell, resell, rent, lease, lend, distribute,
 * redistribute, market, publish, commercialize, or otherwise transfer rights or
 * usage to the software or any modified version or derivative work of the software
 * created by or for you.
 *
 * Copyright (C) 2015-2026 EspoCRM, Inc.
 *
 * License ID: 19bc86a68a7bb01f458cb391d43a9212
 ************************************************************************************/
define("modules/advanced/report-helper",["exports","underscore","handlebars"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);const a=function(t,e,i,s,a){this.metadata=t,this.language=e,this.dateTime=i,this.config=s,this.preferences=a;const n=this.getFormatData();this.decimalMark=n.decimalMark,this.thousandSeparator=n.thousandSeparator,this.currencyDecimalPlaces=n.currencyDecimalPlaces,this.currency=n.currency,this.currencySymbol=n.currencySymbol,this.currencyFormat=n.currencyFormat};e.default.extend(a.prototype,{getFormatData:function(){const t=this.config,e=this.preferences,i=t.get("defaultCurrency")??"USD",s=this.metadata.get(`app.currency.symbolMap.${i}`)??"";let a=".",n=",";e.has("decimalMark")?a=e.get("decimalMark"):t.has("decimalMark")&&(a=t.get("decimalMark")),e.has("thousandSeparator")?n=e.get("thousandSeparator"):t.has("thousandSeparator")&&(n=t.get("thousandSeparator"));return{currency:i,currencySymbol:s,decimalMark:a,thousandSeparator:n,currencyDecimalPlaces:t.get("currencyDecimalPlaces"),currencyFormat:parseInt(t.get("currencyFormat"))}},formatCellValue:function(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=!1,n=e.split(":");if(1===n.length&&(n=["",e]),n.length>1){const t=this.getGroupFieldData(e,i)||{},s=t.entityType,n=t.field,o=t.fieldType;a=["currency","currencyConverted"].includes(o),a||"Opportunity"!==s||"amountWeightedConverted"!==n||(a=!0)}const o=(i.columnDecimalPlacesMap||{})[e];return this.formatNumber(t,{isCurrency:a,useSiMultiplier:s,decimalPlaces:o,currency:i.currency})},formatNumber:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=e.isCurrency??!1,s=e.useSiMultiplier??!1,a=e.noDecimalPart??!1,n=e.no3CharCurrencyFormat??!1,o=e.decimalPlaces??null,r=this.decimalMark;let l=this.currency,d=this.currencySymbol;e.currency&&(l=e.currency,d=this.metadata.get(`app.currency.symbolMap.${l}`)??"");const c=this.thousandSeparator;let h=this.currencyDecimalPlaces;null!=o&&(h=o);let u="";if(s&&(t>=1e6?(u="M",t/=1e6):t>=1e3&&(u="k",t/=1e3)),null!==t){let e=2;if(i)!a&&s&&""!==u&&(t>=100?(e=0,h=0):t>=10?(e=1,h=1):(e=2,h=2)),a?h=null:t=0===h?Math.round(t):h?Math.round(t*Math.pow(10,h))/Math.pow(10,h):Math.round(t*Math.pow(10,e))/Math.pow(10,e);else{let e=4;null!==o&&o<e&&(e=o),!a&&s&&""!==u&&(e=t>=10?1:2),t=Math.round(t*Math.pow(10,e))/Math.pow(10,e)}const p=t.toString().split(".");if(p[0]=p[0].replace(/\B(?=(\d{3})+(?!\d))/g,c),i)if(0===h)delete p[1];else if(h){let t=0;if(p.length>1?t=p[1].length:p[1]="",h&&t<h){const e=h-t;for(let t=0;t<e;t++)p[1]+="0"}}if(!a&&!i&&null!==o&&""===u){let t=0;if(p.length>1?t=p[1].length:p[1]="",0!==o){const e=o-t;for(let t=0;t<e;t++)p[1]+="0"}else p.pop()}return t=p.join(r),i?1===this.currencyFormat?n?t+=u:t=t+u+" "+l:t=3===this.currencyFormat?t+u+" "+d:d+t+u:t+=u,t}return""},formatColumn:function(t,e){let s=t;return t in e.columnNameMap&&(s=e.columnNameMap[t]),i.default.Utils.escapeExpression(s)},formatGroup:function(t,e,s){if(t in s.groupValueMap)return"__STUB__"===(e=s.groupValueMap[t][e]||e)?"":(null!==e&&""!==e||(e=this.language.translate("-Empty-","labels","Report")),i.default.Utils.escapeExpression(e));if(~t.indexOf("MONTH:"))return moment(e+"-01").format("MMM YYYY");if(~t.indexOf("DAY:")){const t=moment().tz(this.dateTime.getTimeZone()).startOf("day"),i=moment(e);let s=this.dateTime.getReadableDateFormat();return i.format("YYYY")!==t.format("YYYY")&&(s+=", YYYY"),i.format(s)}return null===e||""===e?this.language.translate("-Empty-","labels","Report"):i.default.Utils.escapeExpression(e)},translateGroupName:function(t,e,i){if("COUNT:id"===t)return this.language.translate("COUNT","functions","Report").toUpperCase();if(i){const e=i.attributes.columnsData||{};if(e[t]&&e[t].label)return e[t].label}const s=this.getGroupFieldData(t,{entityType:e})||{},a=s.entityType,n=s.field,o=s.fieldType,r=s.function,l=s.link;let d=this.language.translate(n,"fields",a);return"currencyConverted"===o&&"Converted"===n.substr(-9)&&(d=this.language.translate(n.substr(0,n.length-9),"fields",a)),l&&(d=this.language.translate(l,"links",e)+" . "+d),r&&(d=this.language.translate(r,"functions","Report").toUpperCase()+": "+d),d},getCode:function(){return"19bc86a68a7bb01f458cb391d43a9212"},getReportView:function(t){const e=t.attributes.type,i=t.attributes.groupBy??[];switch(e){case"Grid":case"JointGrid":const e=t.attributes.depth||i.length;if(e>2)throw new Error("Bad report.");return"advanced:views/report/reports/grid"+e.toString();case"List":return"advanced:views/report/reports/list"}throw new Error("Bad report type.")},getChartColumnGroupList:function(t){let e=t.numericColumnList||t.columnList;const i=[];if(!["Line","BarHorizontal","BarVertical","Radar"].includes(t.chartType))return e.forEach(t=>{i.push({column:t})}),i;if(t.chartDataList&&t.chartDataList.length&&t.chartDataList[0])return e=(t.chartDataList[0].columnList||[]).concat(t.chartDataList[0].y2ColumnList||[]),[{columnList:e,secondColumnList:t.chartDataList[0].y2ColumnList,column:null}];if(!t.chartDataList&&t.isJoint)return[{columnList:e,secondColumnList:[]}];const s=[],a=[];let n=null,o=null,r=null;const l=[];e.forEach(e=>{const o=this.getGroupFieldData(e,t);if(!o)return;if(!this.isColumnAggregated(e,t))return;const r=o.function;"currency"===o.fieldType||"currencyConverted"===o.fieldType||"amountWeightedConverted"===o.field&&"Opportunity"===o.entityType?"SUM"!==r&&r?a.push(e):s.push(e):"COUNT"===r?l.push(e):n?i.push({column:e}):n=e}),s.length&&(o={columnList:s}),a.length&&(r={columnList:a});let d=null;return(n||l.length)&&(s.length?l.length?(o.secondColumnList=l,l.forEach(t=>{o.columnList.push(t)})):(o.columnList.push(n),o.secondColumnList=[n]):a.length?l.length?(r.secondColumnList=l,l.forEach(t=>{r.columnList.push(t)})):(r.columnList.push(n),r.secondColumnList=[n]):l.length>1||l.length&&n?(d={columnList:l},n&&(d.columnList.push(n),d.secondColumnList=[n])):1===l.length?d={column:l[0]}:i.length?(i[0].columnList=[n,i[0].column],i[0].secondColumnList=[i[0].column],i[0].column=null):i.push({column:n})),a.length&&(i.unshift(r),1===a.length&&(r.column=a[0],r.columnList=null)),s.length&&(i.unshift(o),1===s.length&&(o.column=s[0],o.columnList=null)),d&&i.unshift(d),i},getGroupFieldData:function(t,e){let i=e.entityType;if(!t)return null;if(~t.indexOf("@")){const s=t.split("@");if(parseInt(s[s.length-1]).toString()===s[s.length-1]){const a=s[s.length-1],n=parseInt(a);t=t.substr(0,t.length-a.length-1),i=e.entityTypeList[n]}}let s=t,a=null,n=null;if(s.includes(":")&&(s=t.split(":")[1],a=t.split(":")[0]),t.includes(":("))return null;if(t.includes(".")){const t=s.split(".");if(s=t[1],n=t[0],i=this.metadata.get(["entityDefs",i,"links",n,"entity"]),!i)return null}return{entityType:i,field:s,fieldType:((null==e?void 0:e.columnTypeMap)??{})[t]??this.metadata.get(["entityDefs",i,"fields",s,"type"]),function:a,link:n}},isColumnNumeric:function(t,e){if("string"==typeof e&&(e={entityType:e}),e.get&&e.set){const i=e.get("columnsData")||{};if(t in i&&null!=i[t].type&&"Summary"===i[t].type)return!0;e={entityType:e.get("entityType")}}const i=this.getGroupFieldData(t,e)||{};return!(!e.numericColumnList||!~e.numericColumnList.indexOf(t))||(!!["COUNT","SUM","AVG"].includes(i.function)||["int","float","currencyConverted","currency","enumInt","enumFloat"].includes(i.fieldType))},isColumnAggregated:function(t,e){return!e.aggregatedColumnList||!!~e.aggregatedColumnList.indexOf(t)},isColumnSummary:function(t){let e=!1;return["COUNT:","SUM:","AVG:","MIN:","MAX:"].forEach(i=>{0===t.indexOf(i)&&(e=!0)}),e}});t.default=a}),define("modules/advanced/views/workflow/actions/base",["exports","view","model"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{template="advanced:workflow/actions/base";defaultActionData={execution:{type:"immediately",field:!1,shiftDays:0}};events={'click [data-action="editAction"]':function(){this.edit()}};data(){const t={};if(this.actionData.fields)for(const[e,i]of Object.entries(this.actionData.fields))if("add"===i.actionType||"remove"===i.actionType){let s;s="remove"===i.actionType?this.translate("Remove"):this.translate("Add"),t[e]=this.translate(s)}return{entityType:this.entityType,actionType:this.actionType,linkedEntityName:this.linkedEntityName||this.entityType,displayedLinkedEntityName:this.displayedLinkedEntityName||this.linkedEntityName||this.entityType,actionData:this.actionData,readOnly:this.readOnly,fieldActionLabelMap:t}}setup(){if(this.actionType=this.options.actionType,this.id=this.options.id,this.readOnly=this.options.readOnly,this.actionData=this.options.actionData||{},this.hasFormulaAvailable=!!this.getMetadata().get("app.formula.functionList"),this.options.isNew){const t={};for(const e in this.defaultActionData)t[e]=Espo.Utils.clone(this.defaultActionData[e]);if("execution"in t)for(const e in t.execution)t.execution[e]=Espo.Utils.clone(t.execution[e]);this.actionData=_.extend(t,this.actionData)}this.entityType=this.options.entityType,this.additionalSetup()}afterRender(){this.renderFields(),this.$formulaField=this.$el.find('.field[data-name="formula"]'),this.hasFormulaAvailable&&this.renderFormula()}renderFormula(){if(this.clearView("formula"),this.actionData.formula&&""!==this.actionData.formula){this.$formulaField.removeClass("hidden");const t=new i.default;return t.set("formula",this.actionData.formula),void this.createView("formula","views/fields/formula",{name:"formula",model:t,mode:"detail",height:100,selector:' .field[data-name="formula"]',inlineEditDisabled:!0,params:{seeMoreDisabled:!0},smallFont:!0},t=>{t.render()})}this.clearView("formula"),this.$formulaField.addClass("hidden")}edit(t){this.createView("edit","advanced:views/workflow/action-modals/"+Espo.Utils.camelCaseToHyphen(this.actionType),{actionData:this.actionData,actionType:this.actionType,entityType:this.entityType,flowchartCreatedEntitiesData:this.options.flowchartCreatedEntitiesData},e=>{e.render(),t&&this.listenToOnce(e,"cancel",()=>{setTimeout(()=>{this.getParentView().removeAction(this.id)},200)}),this.listenToOnce(e,"apply",t=>{this.clearView("edit"),this.actionData=t,this.trigger("change"),this.additionalSetup(),this.afterEdit(),setTimeout(()=>{this.reRender()},200)})})}afterEdit(){}fetch(){return this.actionData.type=this.type,this.actionData.id=this.options.actionId,this.actionData}renderFields(){if(this.actionData.fields){const t=new i.default;t.name=this.linkedEntityName||this.entityType;const e={fields:{},links:{}};_.each(this.actionData.fields,(i,s)=>{t.set(i.attributes),e.fields[s]=this.getMetadata().get(`entityDefs.${t.name}.fields.${s}`),e.links[s]=this.getMetadata().get(`entityDefs.${t.name}.links.${s}`),t.setDefs(e);const a=`entityDefs.${t.name}.fields.${s}`,n=this.getMetadata().get(`${a}.type`);switch(i.subjectType){case"value":const e=this.getMetadata().get(`entityDefs.Workflow.fieldDefinitionsFieldViews.${n}`)||this.getMetadata().get(`${a}.view`)||this.getFieldManager().getViewName(n);this.createView("subject-"+s,e,{selector:`.field-container[data-field="${s}"]`,model:t,name:s,inlineEditDisabled:!0,readOnly:!0},t=>{setTimeout(()=>{t.render()},100)});break;case"field":case"today":const o=this.getMetadata().get(`entityDefs.Workflow.fieldDefinitions.${n}`)||"base";this.createView("field-"+s,"advanced:views/workflow/field-definitions/"+Espo.Utils.camelCaseToHyphen(o),{selector:`.field-container[data-field="${s}"]`,fieldData:i,model:this.model,field:s,entityType:this.entityType,scope:t.name,type:o,fieldType:n,isNew:!1,readOnly:!0},t=>{t.render()})}})}}additionalSetup(){this.actionData.link&&(this.linkedEntityName=this.actionData.link)}translateCreatedEntityAlias(t,e){let i=t;if(0===t.indexOf("created:")&&(i=t.substr(8)),!this.options.flowchartCreatedEntitiesData[i])return t;const s=this.options.flowchartCreatedEntitiesData[i].link,a=this.options.flowchartCreatedEntitiesData[i].entityType,n=this.options.flowchartCreatedEntitiesData[i].numberId;let o=this.translate("Created","labels","Workflow")+" · ",r='<span class="chevron-right"></span>';return e&&(r="-"),s&&(o+=this.translate(s,"links",this.entityType)+" "+r+" "),o+=this.translate(a,"scopeNames"),n&&(o+=" #"+n.toString()),o}translateTargetItem(t,e,i){if(t&&0===t.indexOf("created:"))return this.translateCreatedEntityAlias(t,e);let s=' <span class="chevron-right"></span> ';e&&(s=" . ");let a=i||this.entityType;if(t&&0===t.indexOf("link:")){const e=t.substr(5).split("."),i=[];return e.forEach(t=>{i.push(this.translate(t,"links",a)),a&&(a=this.getMetadata().get(["entityDefs",a,"links",t,"entity"]))}),this.translate("Related","labels","Workflow")+" · "+i.join(s)}return"currentUser"===t?this.getLanguage().translate("currentUser","emailAddressOptions","Workflow"):"targetEntity"!==t&&t?"followers"===t?this.getLanguage().translate("followers","emailAddressOptions","Workflow"):void 0:this.getLanguage().translate("targetEntity","emailAddressOptions","Workflow")+" · "+this.translate(a,"scopeNames")}}t.default=a}),define("modules/advanced/views/report/reports/charts/base",["exports","view","lib!flotr2"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{template="advanced:report/reports/charts/chart";decimalMark=".";thousandSeparator=",";colorList=["#6FA8D6","#4E6CAD","#EDC555","#ED8F42","#DE6666","#7CC4A4","#8A7CC2","#D4729B"];colorListAlt=["#6FA8D6","#EDC555","#ED8F42","#7CC4A4","#D4729B"];successColor="#5ABD37";gridColor="#ddd";tickColor="#e8eced";textColor="#333";hoverColor="#FF3F19";defaultHeight=350;legendColumnWidth=110;legendColumnNumber=8;noLegend=!1;zoomMaxDistanceBetweenPoints=60;zoomStepRatio=1.5;pointXHalfWidth=0;zoomMaxDistanceMultiplier=1;isSquare=!1;xMin=0;result;chartType;data(){return{type:this.chartType}}init(){this.flotr=i.default,this.reportHelper=this.options.reportHelper,this.successColor=this.getThemeManager().getParam("chartSuccessColor")||this.successColor,this.colorList=this.getThemeManager().getParam("chartColorList")||this.colorList,this.colorListAlt=this.getThemeManager().getParam("chartColorAlternativeList")||this.colorListAlt,this.gridColor=this.getThemeManager().getParam("chartGridColor")||this.gridColor,this.tickColor=this.getThemeManager().getParam("chartTickColor")||this.tickColor,this.textColor=this.getThemeManager().getParam("textColor")||this.textColor,this.hoverColor=this.getThemeManager().getParam("hoverColor")||this.hoverColor,this.defaultHeight=this.options.defaultHeight||this.defaultHeight,this.options.colorList&&this.options.colorList.length&&(this.colorList=this.options.colorList,this.colorListAlt=this.options.colorList),this.colors=this.options.colors||{},this.on("resize",()=>{this.isRendered()&&setTimeout(()=>{this.adjustContainer(),this.processDraw()},50)}),$(window).on("resize.report-chart-"+this.cid,()=>{this.adjustContainer(),this.processDraw()}),this.listenToOnce(this,"remove",()=>{$(window).off("resize.report-chart-"+this.cid),this.zooming&&!this.options.isDashletMode&&($(document).off("mouseup."+this.cid),$(document).off("touchend."+this.cid),this.$container.get(0)&&(i.default.EventAdapter.stopObserving(this.$container.get(0),"mousemove"),i.default.EventAdapter.stopObserving(this.$container.get(0),"touchmove"))),this.$graph&&this.$graph.destroy()}),this.result=this.options.result,this.column=this.options.column,this.columnList=this.options.columnList,this.secondColumnList=this.options.secondColumnList;let t=this.column;this.columnList&&this.columnList.length&&(t=this.columnList[0]),this.result.columnTypeMap&&this.result.columnTypeMap[t]&&(this.isCurrency=["currencyConverted","currency"].includes(this.result.columnTypeMap[t])),this.zooming&&!this.options.isDashletMode&&(this.events=this.events||{},this.events['click [data-action="zoomIn"]']=this.zoomIn,this.events['click [data-action="zoomOut"]']=this.zoomOut)}getFontSizeFactor(){return this.getThemeManager().getFontSizeFactor?this.getThemeManager().getFontSizeFactor():1}labelFormatter(t){return'<span style="color:'+this.textColor+'">'+t+"</span>"}formatCellValue(t,e){return this.reportHelper.formatCellValue(t,e,this.result)}adjustContainer(){let t;const e=this.getFontSizeFactor();if(this.options.fitHeight){let i=0;this.noLegend||(i+=this.getLegendHeight()),t=i?"calc(100% - "+i.toString()+"px)":this.options.height||(this.defaultHeight*e).toString()+"px"}else{let e;const i=this.defaultHeight*this.getFontSizeFactor();this.options.height||(e=this.calculateHeight(),i&&e<i&&(e=null)),t=e?e+"px":this.options.height||i+"px"}this.$container.css("height",t),this.isSquare&&this.$container.css({width:t,margin:"0 auto"})}beforeDraw(){this.zooming&&!this.options.isDashletMode&&this.$container.get(0)&&i.default.EventAdapter.stopObserving(this.$container.get(0),"mousemove")}afterDraw(){this.zooming&&!this.options.isDashletMode&&this.controlZoomButtons(),this.zooming&&!this.dragStart&&(i.default.EventAdapter.stopObserving(this.$container.get(0),"flotr:mousedown"),i.default.EventAdapter.stopObserving(this.$container.get(0),"touchstart"),this.isZoomed&&(i.default.EventAdapter.observe(this.$container.get(0),"flotr:mousedown",this.initDrag.bind(this)),i.default.EventAdapter.observe(this.$container.get(0),"touchstart",this.initTouchDrag.bind(this)))),this.zooming&&!this.options.isDashletMode&&this.isZoomed&&this.$el.css("overflow","hidden")}getDisplayedPointCount(){let t;return t=this.xMax?this.xMax-this.xMin:this.getHorizontalPointCount(),t=Math.round(t),t}controlZoomButtons(){this.$zoomIn&&this.$zoomIn.remove();let t=0;this.secondColumnList&&(t+=30),this.$zoomIn=$('<a role="button" data-action="zoomIn"><span class="fas fa-plus fa-sm"></span></a>'),this.$zoomIn.css("position","absolute"),this.$zoomIn.css("right",t),this.$zoomIn.css("top",0),this.$zoomOut=$('<a role="button" data-action="zoomOut"><span class="fas fa-minus fa-sm"></span></a>'),this.$zoomOut.css("position","absolute"),this.$zoomOut.css("right",t+20),this.$zoomOut.css("top",0),this.zoomRatio&&1!==this.zoomRatio||this.$zoomOut.css("display","none");const e=this.getDisplayedPointCount();(e<=1||this.$container.width()/e>this.zoomMaxDistanceBetweenPoints*this.zoomMaxDistanceMultiplier)&&this.$zoomIn.css("display","none"),this.$container.append(this.$zoomIn),this.$container.append(this.$zoomOut)}zoomIn(){void 0===this.xMin&&(this.xMin=0-this.pointXHalfWidth),void 0===this.xMax&&(this.xMax=this.getHorizontalPointCount()+this.pointXHalfWidth);const t=this.xMax-this.xMin;if(t<=1)return;this.middle=this.xMax-t/2;const e=t/this.zoomStepRatio,i=this.getHorizontalPointCount();this.xMin=Math.ceil(this.middle-e/2),this.xMax=Math.floor(this.middle+e/2),this.zoomRatio=i/(this.xMax-this.xMin),this.isZoomed=!0,this.processDraw()}zoomOut(){void 0===this.xMin&&(this.xMin=0-this.pointXHalfWidth),void 0===this.xMax&&(this.xMax=this.getHorizontalPointCount());const t=this.xMax-this.xMin;this.middle=t/2;const e=Math.round(t*this.zoomStepRatio);this.xMin=Math.floor(this.xMin-e/2),this.xMax=Math.ceil(this.xMax+e/2);const i=this.getHorizontalPointCount();this.xMin<0-this.pointXHalfWidth&&(this.xMin=0-this.pointXHalfWidth),this.xMax>i&&(this.xMax=i),this.zoomRatio=i/(this.xMax-this.xMin-this.pointXHalfWidth),1===this.zoomRatio&&(this.isZoomed=!1),this.processDraw()}processDraw(){this.beforeDraw(),this.draw(),this.afterDraw()}getHorizontalPointCount(){}initDrag(t){this.dragStart=this.$graph.getEventPosition(t),i.default.EventAdapter.observe(this.$container.get(0),"mousemove",this.drag.bind(this)),$(document).off("mouseup."+this.cid),$(document).on("mouseup."+this.cid,this.stopDrag.bind(this)),this.$container.css("cursor","grabbing")}initTouchDrag(t){this.dragStart={isTouch:!0,x:this.$graph.axes.x.p2d(t.touches[0].clientX-this.$container.get(0).getBoundingClientRect().left)},i.default.EventAdapter.observe(this.$container.get(0),"touchmove",this.drag.bind(this)),$(document).off("touchend."+this.cid),$(document).on("touchend."+this.cid,this.stopTouchDrag.bind(this))}stopDrag(){$(document).off("mouseup."+this.cid),i.default.EventAdapter.stopObserving(this.$container.get(0),"mousemove"),this.dragStart=null,this.$container.css("cursor",""),setTimeout(()=>{this.processDraw()},50)}stopTouchDrag(){$(document).off("touchend."+this.cid),i.default.EventAdapter.stopObserving(this.$container.get(0),"touchmove"),this.dragStart=null,setTimeout(()=>{this.processDraw()},50)}drag(t){if(!this.dragStart)return;let e;if(this.dragStart.isTouch){const i=t.changedTouches[0].clientX-this.$container.get(0).getBoundingClientRect().left;e=this.dragStart.x-this.$graph.axes.x.p2d(i)}else{const i=this.$graph.getEventPosition(t);e=this.dragStart.x-i.x}const i=this.getHorizontalPointCount()-1,s=this.xMin,a=this.xMax;this.xMin=this.xMin+e,this.xMax=this.xMax+e,this.xMin<0-this.pointXHalfWidth?(this.xMax=a+e-(this.xMin+this.pointXHalfWidth),this.xMin=0-this.pointXHalfWidth):this.xMax>i+this.pointXHalfWidth&&(this.xMin=s+e-(this.xMax-i-this.pointXHalfWidth),this.xMax=i+this.pointXHalfWidth),this.draw(!0)}calculateHeight(){return null}adjustLegend(){const t=this.getLegendColumnNumber();if(!t)return;const e=(this.getThemeManager().getParam("dashletChartLegendBoxWidth")||21)*this.getFontSizeFactor(),i=this.$legendContainer.width(),s=Math.floor((i-e*t)/t),a=(s+e)*(this.$legendContainer.find("> table tr:first-child > td").length/2);this.$legendContainer.find("> table").css("table-layout","fixed").attr("width",a),this.$legendContainer.find("td.flotr-legend-label").attr("width",s),this.$legendContainer.find("td.flotr-legend-color-box").attr("width",e),this.$legendContainer.find("td.flotr-legend-label > span").each((t,e)=>{e.setAttribute("title",e.textContent)})}afterRender(){this.prepareData(),this.$container=this.$el.find(".chart-container"),this.$legendContainer=this.$el.find(".legend-container"),this.adjustContainer(),setTimeout(()=>{this.processDraw()},1)}getLegendColumnNumber(){if(!this.getParentView())return 1;const t=this.getParentView().$el.width();return Math.floor(t/(this.legendColumnWidth*this.getFontSizeFactor()))||this.legendColumnNumber}getLegendHeight(){if(this.noLegend)return 0;const t=Math.ceil(this.chartData.length/this.getLegendColumnNumber());let e=0;const i=this.getThemeManager().getParam("dashletChartLegendRowHeight")||19,s=this.getThemeManager().getParam("dashletChartLegendPaddingTopHeight")||7;return t>0&&(e=i*t+s),e*this.getFontSizeFactor()}showNoData(){const t=this.getThemeManager().getParam("fontSize")||14;this.$container.empty();const e=1.2*t,i=$("<span>").html(this.translate("No Data")).addClass("text-muted"),s=$("<div>").css("text-align","center").css("font-size",e+"px").css("display","table").css("width","100%").css("height","100%").css("user-select","none");i.css("display","table-cell").css("vertical-align","middle").css("padding-bottom",1.5*t+"px"),s.append(i),this.$container.append(s)}}t.default=a}),define("modules/advanced/views/workflow/conditions/base",["exports","view","model"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{template="advanced:workflow/conditions/base";defaultConditionData={comparison:"equals",subjectType:"value"};comparisonList=["equals","notEquals","wasEqual","wasNotEqual","changed","notChanged","notEmpty"];field;data(){return{field:this.field,entityType:this.entityType,comparisonValue:this.conditionData.comparison,comparisonList:this.comparisonList,readOnly:this.readOnly}}setupComparisonList(){if(this.isComplexField||this.options.isChangedDisabled){const t=[];Espo.Utils.clone(this.comparisonList).forEach(e=>{["changed","notChanged","wasEqual","wasNotEqual"].includes(e)||t.push(e)}),this.comparisonList=t}}setup(){if(this.conditionType=this.options.conditionType,this.conditionData=this.options.conditionData||{},this.field=this.options.field,this.entityType=this.options.entityType,this.type=this.options.type,this.fieldType=this.options.fieldType,this.readOnly=this.options.readOnly,this.isComplexField=!!~this.field.indexOf("."),this.comparisonList=Espo.Utils.clone(this.comparisonList),this.setupComparisonList(),this.options.isNew){const t={};for(const e in this.defaultConditionData)t[e]=Espo.Utils.clone(this.defaultConditionData[e]);this.conditionData=_.extend(t,this.conditionData)}this.conditionData.fieldToCompare=this.field,this.readOnly||(this.formModel=new i.default,this.formModel.name="Dummy",this.formModel.set({comparison:this.conditionData.comparison}),this.createView("comparisonField","views/fields/enum",{selector:'[data-field="comparison"]',name:"comparison",model:this.formModel,mode:"edit",params:{options:this.comparisonList,translation:"Workflow.labels"}}),this.listenTo(this.formModel,"change:comparison",()=>{this.setComparison(this.formModel.attributes.comparison),this.handleComparison(this.formModel.attributes.comparison)}),this.listenTo(this.formModel,"change",(t,e)=>{e.ui&&this.trigger("change")}))}afterRender(){this.handleComparison(this.conditionData.comparison,!0),this.$el.find(".selectize-control").addClass("input-sm")}fetchComparison(){const t=this.$el.find('[data-name="comparison"]');t.length&&(this.conditionData.comparison=t.val())}fetchSubjectType(){const t=this.getView("subjectType");t&&(this.conditionData.subjectType=t.fetchValue())}fetchSubject(){if(delete this.conditionData.value,delete this.conditionData.field,"fetch"in(this.getView("subject")||{})){const t=this.getView("subject").fetch()||{};for(const e in t)this.conditionData[e]=t[e];return}switch(this.conditionData.subjectType){case"field":this.fetchSubjectField();break;case"value":const t=this.$el.find('[data-name="subject"]');t.length&&(this.conditionData.value=t.val().trim())}}fetchSubjectField(){this.getView("subject")&&(this.conditionData.field=this.getView("subject").fetchValue())}fetch(){return this.fetchComparison(),this.fetchSubjectType(),this.fetchSubject(),this.conditionData}setComparison(t){this.conditionData.comparison=t}setSubjectType(t){this.conditionData.subjectType=t}setSubject(t){this.conditionData.subject=t}handleComparison(t,e){switch(e||(this.clearView("subjectType"),this.clearView("subject")),t){case"changed":case"notChanged":case"notEmpty":case"isEmpty":case"empty":case"true":case"false":case"today":case"beforeToday":case"afterToday":this.$el.find(".subject-type").empty(),this.$el.find(".subject").empty(),this.conditionData.subjectType=null;break;case"equals":case"wasEqual":case"notEquals":case"wasNotEqual":case"greaterThan":case"lessThan":case"greaterThanOrEquals":case"lessThanOrEquals":case"has":case"notHas":case"contains":case"notContains":case"anyOf":case"noneOf":this.createView("subjectType","advanced:views/workflow/condition-fields/subject-type",{selector:".subject-type",value:this.conditionData.subjectType,readOnly:this.readOnly},t=>{t.render().then(()=>{e||this.fetch(),this.handleSubjectType(this.conditionData.subjectType,e)}),this.listenTo(t,"change",t=>{this.setSubjectType(t),this.handleSubjectType(t),this.trigger("change")})})}}getSubjectInputViewName(){return"advanced:views/workflow/condition-fields/subjects/text-input"}handleSubjectType(t,e){switch(e||this.clearView("subject"),t){case"value":this.createView("subject",this.getSubjectInputViewName(t),{selector:".subject",entityType:this.entityType,field:this.field,value:this.getSubjectValue(),conditionData:this.conditionData,readOnly:this.readOnly},t=>{t.render(()=>{e||this.fetch(),this.handleSubject(this.conditionData.subject,e)}),this.listenTo(t,"change",()=>{this.trigger("change")})});break;case"field":this.createView("subject","advanced:views/workflow/condition-fields/subjects/field",{selector:".subject",entityType:this.options.originalEntityType||this.entityType,value:this.conditionData.field,fieldType:this.fieldType,field:this.field,readOnly:this.readOnly},t=>{t.render().then(()=>{e||setTimeout(()=>this.fetch(),100)}),this.listenTo(t,"change",()=>{this.trigger("change")})});break;default:this.$el.find(".subject").empty()}}handleSubject(t,e){e||this.fetch()}getSubjectValue(){return this.conditionData.value}}t.default=a}),define("modules/advanced/views/workflow/action-modals/base",["exports","views/modal","modules/advanced/views/workflow/actions/base"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{template="advanced:workflow/action-modals/base";escapeDisabled=!0;shortcutKeys={Escape:async function(){await this.confirm(this.translate("confirmLeaveOutMessage","messages")),this.actionClose()}};data(){return{}}setup(){this.actionData=this.options.actionData||{},this.actionDataInitial=Espo.Utils.cloneDeep(this.actionData),this.actionType=this.options.actionType,this.entityType=this.options.entityType,this.once("close",()=>{if(!this.isApplied&&this.actionDataInitial&&this.actionData)for(const t in this.actionDataInitial)this.actionData[t]=this.actionDataInitial[t];this.isApplied=!1}),this.buttonList=[{name:"apply",label:"Apply",style:"primary",onClick:()=>{this.fetch()&&(this.isApplied=!0,this.trigger("apply",this.actionData),this.close())}},{name:"cancel",label:"Cancel",onClick:t=>{this.trigger("cancel"),t.close()}}],this.headerText=this.translate(this.actionType,"actionTypes","Workflow")}translateCreatedEntityAlias(t,e){return i.default.prototype.translateCreatedEntityAlias.call(this,t,e)}getEntityTypeFromTarget(t,e){if(t&&0===t.indexOf("created:")){const e=t.substr(8);return this.options.flowchartCreatedEntitiesData[e]?this.options.flowchartCreatedEntitiesData[e].entityType:null}if(t&&0===t.indexOf("link:")){const i=t.substr(5).split(".");let s=e||this.entityType;return i.forEach(t=>{s&&(s=this.getMetadata().get(["entityDefs",s,"links",t,"entity"]))}),s}const i=e||this.entityType;return"followers"===t||"currentUser"===t?"User":"targetEntity"===t?i:t?null:i}translateTargetItem(t,e,s){return i.default.prototype.translateTargetItem.call(this,t,e,s)}}t.default=a}),define("modules/advanced/views/report/runtime-filters",["exports","view","search-manager"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{template="advanced:report/runtime-filters";filtersParams;data(){return{filterDataList:this.getFilterDataList()}}setup(){this.filterList=this.options.filterList,this.filtersData=this.options.filtersData||{},this.internalClassName=this.options.internalClassName,this.ignoreFilterList=[],this.filtersParams={},this.internalClassName&&(this.filtersParams=this.getMetadata().get(`app.advancedReport.internalReports.${this.internalClassName}.runtimeFiltersParams`)??{}),this.wait((async()=>{this.model=await this.getModelFactory().create(this.options.entityType);const t=await this.getCollectionFactory().create(this.options.entityType);this.searchManager=new i.default(t,"report",null,this.getDateTime()),"setTimeZone"in this.searchManager&&this.searchManager.setTimeZone(null),await this.createFilters()})())}async createFilters(){const t=[];this.options.filterList.forEach(e=>{const i=this.filtersData[e]??this.getFilterDefaultData(e)??null,s=this.createFilter(e,i);t.push(s)}),await Promise.all(t)}getFilterDefaultData(t){var e;const i=null===(e=this.filtersParams[t])||void 0===e?void 0:e.defaultType;if(i)return{type:i,field:t};const s=this.getMetadata().get(["entityDefs",this.model.entityType,"fields",t,"type"]);return["date","datetime","datetimeOptional"].includes(s)?{type:"currentYear",field:t}:null}getFilterDataList(){const t=[];return this.options.filterList.forEach(e=>{this.ignoreFilterList.includes(e)||t.push({key:`filter-${e}`,name:e})}),t}async createFilter(t,e){var i;e=e||{};let s,a=this.model.name,n=t;if(~t.indexOf(".")&&(s=t.split(".")[0],n=t.split(".")[1],a=this.getMetadata().get(`entityDefs.${this.model.name}.links.${s}.entity`)),!a||!n)return void console.warn(`Bad runtime filter ${t}.`);const o=(null===(i=this.filtersParams[t])||void 0===i?void 0:i.view)??null;if(!o&&!this.getMetadata().get(["entityDefs",a,"fields",n]))return console.warn(`Bad runtime filter ${t}.`),void this.ignoreFilterList.push(t);const r=await this.getModelFactory().create(a),l=await this.createView(`filter-${t}`,"views/search/filter",{name:n,model:r,params:e,selector:`.filter[data-name="${t}"]`,notRemovable:!0,viewName:o});this.listenTo(l,"after:render",()=>{var e;let i;const o=null===(e=this.filtersParams[t])||void 0===e?void 0:e.labelTranslation;if(o?i=this.getLanguage().translatePath(o):~t.indexOf(".")&&(i=this.translate(s,"links",this.options.entityType)+" . "+this.translate(n,"fields",a)),i){var r;const t=null===(r=l.element)||void 0===r?void 0:r.querySelector(".control-label");t&&(t.textContent=i)}})}fetchRaw(){const t={};return this.filterList.forEach(e=>{if(!this.hasView(`filter-${e}`))return;const i=this.getView(`filter-${e}`).getView("field");if(!i)return;let s=i.fetchSearch();const a=(t,e)=>{const i=t.type;if("or"===i||"and"===i)return void(t.value||[]).forEach(t=>a(t,e));let s=t.attribute||t.field||e;if(e.includes(".")&&!s.includes(".")){s=e.split(".")[0]+"."+s}t.field=s,t.attribute=s};s=s||null,s&&a(s,e),t[e]=s}),t}fetch(){const t=this.fetchRaw();return this.searchManager.setAdvanced(t),this.searchManager.getWhere()}}t.default=a}),define("modules/advanced/views/report/reports/charts/grid2bar-vertical",["exports","modules/advanced/views/report/reports/charts/base"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{columnWidth=60;barWidth=.5;zooming=!0;pointXHalfWidth=.5;isGrouped=!1;chartType="barVertical";prepareData(){const t=this.result,e=this.firstList=t.grouping[0],i=this.secondList=t.grouping[1];i.length<=5&&(this.colorList=this.colorListAlt);const s=[];this.sumList=[],this.max=0,this.min=0,e.forEach(e=>{const a={};let n;i.forEach(i=>{if(t.reportData[e]&&t.reportData[e][i]){const s=t.reportData[e][i][this.column]||0;a[i]=s,s>this.max&&(this.max=s),s<this.min&&(this.min=s)}}),s.push(a),n=(t.group1Sums[e]||{})[this.column]||0,this.sumList.push(n)});const a={},n=this.group2Count=i.length;this.isGrouped&&n&&(this.barWidth=1/n*.65);const o=1/n,r=Math.ceil(n/2)-1;i.forEach((t,e)=>{let i=0;if(this.isGrouped){i=o*(e-r),n%2==0&&(i-=o/2),i*=.75}a[t]=[],s.forEach((e,s)=>{a[t].push([s+i,e[t]||0])})});const l=[];i.forEach(t=>{const e={data:a[t],label:this.formatGroup(1,t)};this.result.success&&this.result.success===t&&(e.color=this.successColor),t in this.colors&&(e.color=this.colors[t]),l.push(e)}),this.isGrouped||this.isLine||(this.max=0,this.sumList.length&&(this.max=this.sumList.reduce((t,e)=>Math.max(t,e)))),this.isGrouped&&!this.isLine&&(this.zoomMaxDistanceMultiplier=1,this.sumList.length&&(this.zoomMaxDistanceMultiplier=this.sumList.length,this.sumList.length>10?this.zoomMaxDistanceMultiplier=4:this.sumList.length>3&&(this.zoomMaxDistanceMultiplier=2))),this.chartData=l}formatGroup(t,e){let i=this.result.groupByList[t];return 0===this.result.groupByList.length&&(i="__STUB__"),this.reportHelper.formatGroup(i,e,this.result)}getTickNumber(){const t=this.$container.width();return Math.floor(t/this.columnWidth)}getHorizontalPointCount(){return this.sumList.length}isNoData(){return!this.chartData.length}draw(){if(0===this.$container.height())return void this.$container.empty();if(this.isNoData())return void this.showNoData();const t=this.getTickNumber();this.$graph=this.flotr.draw(this.$container.get(0),this.chartData,{shadowSize:!1,colors:this.colorList,bars:{show:!0,stacked:!this.isGrouped,horizontal:!1,shadowSize:0,lineWidth:1,fillOpacity:1,barWidth:this.barWidth},grid:{horizontalLines:!0,verticalLines:!1,outline:"sw",color:this.gridColor,tickColor:this.tickColor},yaxis:{showLabels:!0,color:this.textColor,max:this.max+.1*this.max,min:this.min+.1*this.min,tickFormatter:t=>{if(0==t&&0===this.min)return"";if(t>this.max+.09*this.max)return"";if(t%1==0){return'<span class="numeric-text">'+this.reportHelper.formatNumber(Math.floor(t),{isCurrency:this.isCurrency,useSiMultiplier:!0,noDecimalPart:!0,no3CharCurrencyFormat:!0,currency:this.result.currency})+"</span>"}return""}},xaxis:{min:this.xMin||0,max:this.xMax||null,color:this.textColor,noTicks:t,tickFormatter:e=>{if(e%1==0){const i=parseInt(e);if(i in this.firstList)return this.firstList.length-t>5&&i===this.firstList.length-1?"":'<span class="numeric-text">'+this.formatGroup(0,this.firstList[i])+"</span>"}return""}},legend:{show:!0,noColumns:this.getLegendColumnNumber(),container:this.$el.find(".legend-container"),labelBoxMargin:0,labelFormatter:this.labelFormatter.bind(this),labelBoxBorderColor:"transparent",backgroundOpacity:0},mouse:{track:this.isGrouped||!this.noMouseTrack,relative:!0,position:"s",lineColor:this.hoverColor,autoPositionVertical:this.isGrouped,autoPositionHorizontalHalf:!this.isGrouped,cursorPointer:(this.isGrouped||!this.noMouseTrack)&&!this.result.noSubReport,trackFormatter:t=>{const e=Math.round(t.x),i=this.options.column,s=t.series.data[t.index][1];return this.formatGroup(0,this.firstList[e])+"<br>"+t.series.label+'<br><span class="numeric-text">'+this.formatCellValue(s,i)+"</span>"}}}),this.adjustLegend(),this.dragStart||!this.isGrouped&&this.noMouseTrack||Flotr.EventAdapter.observe(this.$container.get(0),"flotr:click",t=>{t.hit&&"index"in t.hit&&(this.result.noSubReport||this.trigger("click-group",this.firstList[t.hit.index],null,this.secondList[t.hit.seriesIndex]))})}}t.default=s}),define("modules/advanced/views/report/modals/sub-report",["exports","views/modal","modules/advanced/report-helper"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{cssName="sub-report";backdrop=!0;className="dialog dialog-record";templateContent='\n        {{#if switchDataList}}\n            <div class="button-container">\n                <div class="btn-group">\n                    {{#each switchDataList}}\n                        <button\n                            type="button"\n                            class="btn btn-text btn-xs-wide {{#ifEqual ../column name}} disabled active {{/ifEqual}} "\n                            data-action="switchSubReport"\n                            data-name="{{name}}"\n                            {{#ifEqual ../column name}}\n                                disabled="disabled"\n                            {{/ifEqual}}\n                        >{{label}}</button>\n                    {{/each}}\n                </div>\n            </div>\n        {{/if}}\n        <div class="list-container">{{{list}}}</div>\n    ';switchDataList;data(){return{switchDataList:this.switchDataList,column:this.options.column}}constructor(t){super(t),this.options=t}setup(){this.buttonList=[{name:"cancel",label:"Close"}],this.addActionHandler("switchSubReport",(t,e)=>{this.options.onSwitchSubReport(e.dataset.name)});const t=this.options.result,e=new i.default(this.getMetadata(),this.getLanguage(),this.getDateTime(),this.getConfig(),this.getPreferences()),s=this.options.groupValue;let a=this.options.reportName;!a&&this.model&&(a=this.model.attributes.name);const n=this.options.groupIndex||0;this.headerText=a,t.groupByList.length&&(this.headerText+=" · "+e.formatGroup(t.groupByList[n],s,t)),void 0!==this.options.groupValue2&&(this.headerText+=", "+e.formatGroup(t.groupByList[1],this.options.groupValue2,t)),this.options.column&&(this.switchDataList=this.options.switchDataList);const o=this.options.reportId??this.model.id;this.wait(!0),this.createView("list","advanced:views/record/list-for-report",{selector:".list-container",collection:this.collection,type:"listSmall",reportId:o,groupValue:s,groupIndex:n,groupValue2:this.options.groupValue2,subReportTarget:this.options.target,skipBuildRows:!0},t=>{t.getSelectAttributeList(e=>{e&&(this.collection.data.select=e.join(",")),this.listenToOnce(t,"after:build-rows",()=>{this.wait(!1)}),this.collection.fetch()})})}}t.default=a}),define("modules/advanced/helpers/report/sub-report-helper",["exports","di","collection-factory","models/settings"],function(t,e,i,s){"use strict";var a;let n,o,r,l,d;function c(t){return t&&t.__esModule?t:{default:t}}function h(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function u(t,e,i){"symbol"==typeof e&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch(t){}return t}function p(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(null!==t?typeof t:"null"));return t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,i=c(i),s=c(s);let f=t.default=void 0;class m{static#t=(a=({e:[o,r,l,d],c:[f,n]}=function(t,e,i,s,a,n){var o,r,l,d,c,f,m,g=Symbol.metadata||Symbol.for("Symbol.metadata"),y=Object.defineProperty,w=Object.create,v=[w(null),w(null)],b=e.length;function T(e,i,s){return function(a,n){i&&(n=a,a=t);for(var o=0;o<e.length;o++)n=e[o].apply(a,s?[n]:[]);return s?n:a}}function D(t,e,i,s){if("function"!=typeof t&&(s||void 0!==t))throw new TypeError(e+" must "+(i||"be")+" a function"+(s?"":" or undefined"));return t}function k(t,e,i,s,a,n,l,d,c,h,p){function f(t){if(!p(t))throw new TypeError("Attempted to access private element on non-instance")}var m=[].concat(e[0]),g=e[3],w=!l,b=1===a,k=3===a,E=4===a,C=2===a;function x(e,i,s){return function(a,n){return i&&(n=a,a=t),s&&s(a),O[e].call(a,n)}}if(!w){var O={},L=[],M=k?"get":E||b?"set":"value";if(c?(h||b?O={get:u(function(){return g(this)},s,"get"),set:function(t){e[4](this,t)}}:O[M]=g,h||u(O[M],s,C?"":M)):h||(O=Object.getOwnPropertyDescriptor(t,s)),!h&&!c){if((r=v[+d][s])&&7!=(r^a))throw Error("Decorating two elements with the same name ("+O[M].name+") is not supported yet");v[+d][s]=a<3?1:a}}for(var F=t,S=m.length-1;S>=0;S-=i?2:1){var V=D(m[S],"A decorator","be",!0),R=i?m[S-1]:void 0,$={},I={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:o,addInitializer:function(t,e){if(t.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(e,"An initializer","be",!0),n.push(e)}.bind(null,$)};if(w)r=V.call(R,F,I),$.v=1,D(r,"class decorators","return")&&(F=r);else if(I.static=d,I.private=c,r=I.access={has:c?p.bind():function(t){return s in t}},E||(r.get=c?C?function(t){return f(t),O.value}:x("get",0,f):function(t){return t[s]}),C||k||(r.set=c?x("set",0,f):function(t,e){t[s]=e}),F=V.call(R,b?{get:O.get,set:O.set}:O[M],I),$.v=1,b){if("object"==typeof F&&F)(r=D(F.get,"accessor.get"))&&(O.get=r),(r=D(F.set,"accessor.set"))&&(O.set=r),(r=D(F.init,"accessor.init"))&&L.unshift(r);else if(void 0!==F)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(F,(h?"field":"method")+" decorators","return")&&(h?L.unshift(F):O[M]=F)}return a<2&&l.push(T(L,d,1),T(n,d,0)),h||w||(c?b?l.splice(-1,0,x("get",d),x("set",d)):l.push(C?O[M]:D.call.bind(O[M])):y(t,s,O)),F}function E(t){return y(t,g,{configurable:!0,enumerable:!0,value:o})}return void 0!==n&&(o=n[g]),o=w(null==o?null:o),c=[],f=function(t){t&&c.push(T(t))},(m=function(e,s){for(var n=0;n<i.length;n++){var o=i[n],r=o[1],u=7&r;if((8&r)==e&&!u==s){var f=o[2],m=!!o[3],g=16&r;k(e?t:t.prototype,o,g,m?"#"+f:h(f),u,u<2?[]:e?d=d||[]:l=l||[],c,!!e,m,s,e&&m?function(e){return p(e)===t}:a)}}})(8,0),m(0,0),m(8,1),m(0,1),f(l),f(d),r=c,b||E(t),{e:r,get c(){var i=[];return b&&[E(t=k(t,[e],s,t.name,5,i)),T(i,1)]}}}(this,[(0,e.register)()],[[(0,e.inject)(i.default),0,"collectionFactory"],[(0,e.inject)(s.default),0,"config"]])),t.default=f,a);constructor(){d(this)}collectionFactory=o(this);config=(r(this),l(this));async createCollection(t){const e=await this.collectionFactory.create(t.entityType),i=encodeURIComponent(t.groupValue);let s="Report/action/runList";return t.parent&&(s="ReportPanel/action/runList"),s+=`?id=${t.reportId}&groupValue=${i}`,t.groupIndex&&(s+=`&groupIndex=${t.groupIndex}`),void 0!==t.groupValue2&&(s+=`&groupValue2=${encodeURIComponent(t.groupValue2)}`),t.parent&&(s+=`&parentId=${t.parent.id}`,s+=`&parentType=${t.parent.entityType}`),t.target&&(s+=`&target=${t.target}`),e.url=s,t.where&&(e.where=t.where),e.maxSize=this.config.get("recordsPerPage"),e}prepareSwitchDataList(t){const e=[],i=[];for(const s of t.columnList){const a=t.columnReportIdMap[s];if(i.includes(a))continue;i.push(a);const n=t.columnSubReportLabelMap[s]??a;e.push({label:n,name:s})}return e}static#e=n()}}),define("modules/advanced/bpmn-element-helper",["exports"],function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default=class{constructor(t,e){this.viewHelper=t,this.model=e}getTargetEntityTypeList(){const t=this.viewHelper.metadata,e=this.viewHelper.language,i=t.get("scopes"),s=t.get(["entityDefs","Workflow","entityListToIgnore"])||[],a=t.get(["entityDefs","BpmnFlowchart","targetTypeListToIgnore"])||[];return Object.keys(i).filter(t=>{if(~s.indexOf(t))return;if(~a.indexOf(t))return;const e=i[t];return e.entity&&e.object}).sort((t,i)=>e.translate(t,"scopeNamesPlural").localeCompare(e.translate(i,"scopeNamesPlural")))}getTargetCreatedList(){const t=this.model.flowchartCreatedEntitiesData,e=[];return t&&Object.keys(t).forEach(t=>{e.push("created:"+t)}),e}getTargetLinkList(t,e,i){const s=this.model.targetEntityType,a=[],n=[],o=this.viewHelper.metadata.get(["entityDefs",s,"links"])||{};return Object.keys(o).forEach(s=>{const r=o[s].type;if(o[s].disabled)return;if(i&&"belongsToParent"===r)return;if(t&&1!==t){if(!~["belongsTo","belongsToParent"].indexOf(r))return}else if(e){if(!~["belongsTo","belongsToParent","hasMany"].indexOf(r))return}else if(!~["belongsTo","belongsToParent"].indexOf(r))return;const l="link:"+s;a.push(l),n.push(s)}),2===t&&n.forEach(t=>{const s=o[t].entity;if(s){const n=this.viewHelper.metadata.get(["entityDefs",s,"links"])||{};Object.keys(n).forEach(s=>{const o=n[s].type;if(n[s].disabled)return;if(i&&"belongsToParent"===o)return;if(e){if(!~["belongsTo","belongsToParent","hasMany"].indexOf(o))return}else if(!~["belongsTo","belongsToParent"].indexOf(o))return;const r=`link:${t}.${s}`;a.push(r)})}}),this.getTargetEntityTypeList().forEach(t=>{a.push("record:"+t)}),a}translateTargetItem(t){if(t&&0===t.indexOf("created:"))return this.translateCreatedEntityAlias(t);if(t&&0===t.indexOf("record:"))return this.viewHelper.language.translate("Record","labels","Workflow")+" · "+this.viewHelper.language.translate(t.substr(7),"scopeNames");let e=this.model.targetEntityType;if(t&&0===t.indexOf("link:")){const i=t.substr(5).split("."),s=[];return i.forEach(t=>{s.push(this.viewHelper.language.translate(t,"links",e)),e&&(e=this.viewHelper.metadata.get(["entityDefs",e,"links",t,"entity"]))}),this.viewHelper.language.translate("Related","labels","Workflow")+" · "+s.join(" . ")}return"currentUser"===t?this.viewHelper.language.translate("currentUser","emailAddressOptions","Workflow"):"targetEntity"!==t&&t?"followers"===t?this.viewHelper.language.translate("followers","emailAddressOptions","Workflow"):void 0:this.viewHelper.language.translate("targetEntity","emailAddressOptions","Workflow")+" · "+this.viewHelper.language.translate(e,"scopeName")}translateCreatedEntityAlias(t){let e=t;if(0===t.indexOf("created:")&&(e=t.substr(8)),!this.model.flowchartCreatedEntitiesData||!this.model.flowchartCreatedEntitiesData[e])return t;const i=this.model.flowchartCreatedEntitiesData[e].link,s=this.model.flowchartCreatedEntitiesData[e].entityType,a=this.model.flowchartCreatedEntitiesData[e].numberId;let n=this.viewHelper.language.translate("Created","labels","Workflow")+" · ";return i&&(n+=this.viewHelper.language.translate(i,"links",this.entityType)+"  -  "),n+=this.viewHelper.language.translate(s,"scopeNames"),a&&(n+=" #"+a.toString()),n}getEntityTypeFromTarget(t){if(t&&0===t.indexOf("created:")){const e=t.substr(8);return this.model.flowchartCreatedEntitiesData&&this.model.flowchartCreatedEntitiesData[e]?this.model.flowchartCreatedEntitiesData[e].entityType:null}if(t&&0===t.indexOf("record:"))return t.substr(7);const e=this.model.targetEntityType;if(t&&0===t.indexOf("link:")){const i=t.substr(5).split(".");let s=e;return i.forEach(t=>{s&&(s=this.viewHelper.metadata.get(["entityDefs",s,"links",t,"entity"]))}),s}return"followers"===t||"currentUser"===t?"User":"targetEntity"===t?e:t?null:e}}}),define("advanced:views/workflow/conditions/int",["advanced:views/workflow/conditions/base"],function(t){return t.extend({template:"advanced:workflow/conditions/base",comparisonList:["equals","notEquals","greaterThan","lessThan","greaterThanOrEquals","lessThanOrEquals","wasEqual","wasNotEqual","isEmpty","notEmpty","changed","notChanged"],defaultConditionData:{comparison:"equals",subjectType:"value"},fetchSubject:function(){switch(delete this.conditionData.value,delete this.conditionData.field,this.conditionData.subjectType){case"field":this.fetchSubjectField();break;case"value":const t=this.getView("subject");t&&(this.conditionData.value=t.fetch().value)}},getSubjectValue:function(){return this.conditionData.value},getSubjectInputViewName:function(){return"advanced:views/workflow/condition-fields/subjects/int"}})}),define("advanced:views/workflow/action-modals/create-entity",["advanced:views/workflow/action-modals/base","model"],function(t,e){return t.extend({template:"advanced:workflow/action-modals/create-entity",data:function(){return _.extend({scope:this.scope},t.prototype.data.call(this))},events:{'click [data-action="addField"]':function(t){const e=$(t.currentTarget).data("field");this.actionData.fieldList.includes(e)||(this.actionData.fieldList.push(e),this.actionData.fields[e]={},this.addField(e,!1,!0))},'click [data-action="removeField"]':function(t){const e=$(t.currentTarget),i=e.data("field");this.clearView("field-"+i),delete this.actionData.fields[i];const s=this.actionData.fieldList.indexOf(i);this.actionData.fieldList.splice(s,1),e.parent().remove()}},afterRender:function(){t.prototype.afterRender.call(this),this.$fieldDefinitions=this.$el.find(".field-definitions"),this.$formulaCell=this.$el.find('.cell[data-name="formula"]'),this.handleLink(),(this.actionData.fieldList||[]).forEach(t=>{this.addField(t,this.actionData.fields[t])})},setupScope:function(t){if(this.actionData.link){const e=this.actionData.link;if(this.scope=e,!e)throw new Error;return this.wait(!0),void this.getModelFactory().create(e,i=>{this.model=i,(this.actionData.fieldList||[]).forEach(t=>{const e=(this.actionData.fields[t]||{}).attributes||{};i.set(e,{silent:!0})}),this.linkList=this.getLinkList(e),this.isRendered()?this.controlLinkList():this.once("after:render",()=>{this.controlLinkList()}),t()})}this.model=null,this.linkList=[],this.isRendered()?this.controlLinkList():this.once("after:render",()=>{this.controlLinkList()}),t()},controlLinkList:function(){const t=this.$el.find('.cell[data-name="linkList"]'),e={};this.linkList.length?(t.removeClass("hidden"),this.linkList.forEach(t=>{e[t]=this.getLanguage().translate(t,"links",this.scope)})):t.addClass("hidden"),this.getView("linkList").setOptionList(this.linkList),this.getView("linkList").setTranslatedOptions(e),this.getView("linkList").reRender()},getLinkList:function(t){const e=this.entityType,i=this.getMetadata().get(["entityDefs",t,"links"])||{},s=this.getMetadata().get(["entityDefs",t,"fields"])||{},a=[];return Object.keys(i).forEach(t=>{const n=(i[t]||{}).entity;"belongsToParent"===(i[t]||{}).type?~((s[t]||{}).entityList||[]).indexOf(e)&&a.push(t):n===e&&a.push(t)}),a},setup:function(){t.prototype.setup.call(this),this.hasFormulaAvailable=!!this.getMetadata().get("app.formula.functionList"),this.wait(!0),this.setupScope(()=>{this.wait(!1)});const i=this.actionModel=new e;i.name="Workflow",this.actionModel.set({link:this.actionData.link}),"createEntity"===this.actionType&&(i.set("linkList",this.actionData.linkList||[]),this.createView("linkList","views/fields/multi-enum",{name:"linkList",model:i,selector:' .field[data-name="linkList"]',mode:"edit"}));const s=this.getLinkOptions();this.createView("link","views/fields/enum",{name:"link",model:i,mode:"edit",selector:' .field[data-name="link"]',params:{options:s.map(t=>t[0]),required:!0},translatedOptions:Object.fromEntries(s),labelText:this.translate("Field")}),this.listenTo(i,"change:link",()=>this.changeLinkAction())},addField:function(t,e,i){const s=this.getMetadata().get(`entityDefs.${this.scope}.fields.${t}.type`)||"base",a=this.getMetadata().get(`entityDefs.Workflow.fieldDefinitions.${s}`)||"base";e=e||!1;const n=this.getHelper().escapeString(t),o='<div class="margin clearfix field-row" data-field="'+n+'" style="margin-left: 20px;">'+('<a role="button" tabindex="0" class="pull-right" data-action="removeField" data-field="'+n+'"><span class="fas fa-times"></span></a>')+("<label>"+this.translate(n,"fields",this.scope)+"</label>")+'<div class="field-container field" data-field="'+n+'"></div></div>';this.$fieldDefinitions.append($(o));const r=`advanced:views/workflow/field-definitions/${Espo.Utils.camelCaseToHyphen(a)}`;this.createView(`field-${t}`,r,{selector:`.field-container[data-field="${t}"]`,fieldData:e,model:this.model,field:t,entityType:this.entityType,scope:this.scope,type:a,fieldType:s,isNew:i},t=>{t.render()})},handleLink:function(){if(!this.actionData.link)return this.clearView("addField"),this.clearView("formula"),void this.$formulaCell.addClass("hidden");this.hasFormulaAvailable&&this.$formulaCell.removeClass("hidden"),this.setupScope(()=>{this.createView("addField","advanced:views/workflow/action-fields/add-field",{selector:".add-field-container",scope:this.scope,fieldList:this.getFieldList(),addedFieldList:this.actionData.fieldList,onAdd:t=>{this.actionData.fieldList.includes(t)||(this.actionData.fieldList.push(t),this.actionData.fields[t]={},this.addField(t,!1,!0))}},t=>{t.render()})}),this.setupFormulaView()},setupFormulaView:function(){const t=new e,i=this.element.querySelector('[data-name="formula"] .field-info');i&&i.parentNode.removeChild(i),this.hasFormulaAvailable&&(t.set("formula",this.actionData.formula||null),this.createView("formula","views/fields/formula",{name:"formula",model:t,mode:this.readOnly?"detail":"edit",height:100,selector:'.field[data-name="formula"]',inlineEditDisabled:!0,targetEntityType:this.actionData.link,params:{tooltip:!0},tooltipText:this.translate("createEntityFormula","tooltips","Workflow")},t=>{t.render()}))},getFieldList:function(){const t=this.getMetadata().get(`entityDefs.${this.scope}.fields`)||{};return Object.keys(t).filter(e=>{const i=t[e].type;return!t[e].workflowDisabled&&(!t[e].disabled&&!t[e].utility&&(!(t[e].directAccessDisabled&&!t[e].directUpdateEnabled)&&(!t[e].directUpdateDisabled&&!["currencyConverted","autoincrement","map","foreign"].includes(i))))}).sort((t,e)=>this.translate(t,"fields",this.scope).localeCompare(this.translate(e,"fields",this.scope)))},getLinkOptions:function(){const t=[[""]];return this.getEntityList().forEach(e=>{const i=this.translate(e,"scopeNames");t.push([e,i])}),t},fetch:function(){let t=!0,e=!1;if(this.getView("link")&&this.getView("link").validate()&&(e=!0),e)return!1;if(this.actionData.link=this.actionModel.attributes.link,(this.actionData.fieldList||[]).forEach(e=>{t=this.getView(`field-${e}`).fetch(),this.actionData.fields[e]=this.getView(`field-${e}`).fieldData}),this.hasFormulaAvailable&&this.actionData.link){const t=this.getView("formula");t&&(this.actionData.formula=t.fetch().formula)}return"createEntity"===this.actionType&&(this.actionData.linkList=this.actionModel.get("linkList"),this.actionData.entityType=this.actionData.link),t},getEntityList:function(){const t=this.getMetadata().get("scopes");return Object.keys(t).filter(e=>{const i=t[e];return i.entity&&(i.tab||i.object||i.workflow)}).sort((t,e)=>this.translate(t,"scopeNamesPlural").localeCompare(this.translate(e,"scopeNamesPlural")))},changeLinkAction:function(){this.actionData.link=this.actionModel.attributes.link,this.actionData.fieldList.forEach(t=>{this.$el.find(`.field-row[data-field="${t}"]`).remove(),this.clearView("field-"+t)}),this.actionData.fieldList=[],this.actionData.fields={},this.actionData.linkList=[],"createEntity"===this.actionType&&this.actionModel.set("linkList",[]),this.handleLink()}})}),define("modules/advanced/views/report/reports/base",["exports","view","modules/advanced/helpers/report/sub-report-helper","di","modules/advanced/views/report/modals/sub-report","modules/advanced/views/report/runtime-filters"],function(t,e,i,s,a,n){"use strict";let o,r;function l(t){return t&&t.__esModule?t:{default:t}}function d(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function c(t,e,i){"symbol"==typeof e&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch(t){}return t}function h(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(null!==t?typeof t:"null"));return t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=l(e),i=l(i),a=l(a),n=l(n);class u extends e.default{static#t=[o,r]=function(t,e,i,s,a,n){var o,r,l,u,p,f,m,g=Symbol.metadata||Symbol.for("Symbol.metadata"),y=Object.defineProperty,w=Object.create,v=[w(null),w(null)],b=e.length;function T(e,i,s){return function(a,n){i&&(n=a,a=t);for(var o=0;o<e.length;o++)n=e[o].apply(a,s?[n]:[]);return s?n:a}}function D(t,e,i,s){if("function"!=typeof t&&(s||void 0!==t))throw new TypeError(e+" must "+(i||"be")+" a function"+(s?"":" or undefined"));return t}function k(t,e,i,s,a,n,l,d,h,u,p){function f(t){if(!p(t))throw new TypeError("Attempted to access private element on non-instance")}var m=[].concat(e[0]),g=e[3],w=!l,b=1===a,k=3===a,E=4===a,C=2===a;function x(e,i,s){return function(a,n){return i&&(n=a,a=t),s&&s(a),O[e].call(a,n)}}if(!w){var O={},L=[],M=k?"get":E||b?"set":"value";if(h?(u||b?O={get:c(function(){return g(this)},s,"get"),set:function(t){e[4](this,t)}}:O[M]=g,u||c(O[M],s,C?"":M)):u||(O=Object.getOwnPropertyDescriptor(t,s)),!u&&!h){if((r=v[+d][s])&&7!=(r^a))throw Error("Decorating two elements with the same name ("+O[M].name+") is not supported yet");v[+d][s]=a<3?1:a}}for(var F=t,S=m.length-1;S>=0;S-=i?2:1){var V=D(m[S],"A decorator","be",!0),R=i?m[S-1]:void 0,$={},I={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:o,addInitializer:function(t,e){if(t.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(e,"An initializer","be",!0),n.push(e)}.bind(null,$)};if(w)r=V.call(R,F,I),$.v=1,D(r,"class decorators","return")&&(F=r);else if(I.static=d,I.private=h,r=I.access={has:h?p.bind():function(t){return s in t}},E||(r.get=h?C?function(t){return f(t),O.value}:x("get",0,f):function(t){return t[s]}),C||k||(r.set=h?x("set",0,f):function(t,e){t[s]=e}),F=V.call(R,b?{get:O.get,set:O.set}:O[M],I),$.v=1,b){if("object"==typeof F&&F)(r=D(F.get,"accessor.get"))&&(O.get=r),(r=D(F.set,"accessor.set"))&&(O.set=r),(r=D(F.init,"accessor.init"))&&L.unshift(r);else if(void 0!==F)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(F,(u?"field":"method")+" decorators","return")&&(u?L.unshift(F):O[M]=F)}return a<2&&l.push(T(L,d,1),T(n,d,0)),u||w||(h?b?l.splice(-1,0,x("get",d),x("set",d)):l.push(C?O[M]:D.call.bind(O[M])):y(t,s,O)),F}function E(t){return y(t,g,{configurable:!0,enumerable:!0,value:o})}return void 0!==n&&(o=n[g]),o=w(null==o?null:o),p=[],f=function(t){t&&p.push(T(t))},(m=function(e,s){for(var n=0;n<i.length;n++){var o=i[n],r=o[1],c=7&r;if((8&r)==e&&!c==s){var f=o[2],m=!!o[3],g=16&r;k(e?t:t.prototype,o,g,m?"#"+f:d(f),c,c<2?[]:e?u=u||[]:l=l||[],p,!!e,m,s,e&&m?function(e){return h(e)===t}:a)}}})(8,0),m(0,0),m(8,1),m(0,1),f(l),f(u),r=p,b||E(t),{e:r,get c(){var i=[];return b&&[E(t=k(t,[e],s,t.name,5,i)),T(i,1)]}}}(this,[],[[(0,s.inject)(i.default),0,"subReportHelper"]],0,void 0,e.default).e;templateContent='\n        <div class="row report-control-panel margin-bottom">\n            <div class="report-runtime-filters-container col-md-12">{{{runtimeFilters}}}</div>\n            <div class="col-md-4 col-md-offset-8">\n                <div class="button-container clearfix">\n                    <div class="btn-group pull-right">\n                        {{#if hasRuntimeFilters}}\n                            <button\n                                class="btn btn-default"\n                                data-action="run"\n                            >&nbsp;&nbsp;{{translate \'Run\' scope=\'Report\'}}&nbsp;&nbsp;</button>\n                        {{else}}\n                            <button\n                                class="btn btn-default btn-icon btn-icon-wide"\n                                data-action="refresh"\n                                title="{{translate \'Refresh\'}}"\n                            ><span class="fas fa-sync-alt"></span></button>\n                        {{/if}}\n                        {{#if hasDropdownMenu}}\n                            <button\n                                type="button"\n                                class="btn btn-default dropdown-toggle"\n                                data-toggle="dropdown"\n                            ><span class="fas fa-ellipsis-h"></span></button>\n                            <ul class="dropdown-menu">\n                                <li><a\n                                    role="button"\n                                    tabindex="0"\n                                    data-action="exportReport"\n                                >{{translate \'Export\'}}</a></li>\n                                {{#if hasSendEmail}}\n                                    <li><a\n                                        role="button"\n                                        tabindex="0"\n                                        data-action="sendInEmail"\n                                    >{{translate \'Send Email\' scope=\'Report\'}}</a></li>\n                                {{/if}}\n                                {{#if hasPrintPdf}}\n                                    <li><a\n                                        role="button"\n                                        tabindex="0"\n                                        data-action="printPdf"\n                                    >{{translate \'Print to PDF\'}}</a></li>\n                                {{/if}}\n                            </ul>\n                        {{/if}}\n                    </div>\n                </div>\n            </div>\n        </div>\n        <div class="hidden information-box text-info margin-bottom small"></div>\n        <div class="report-results-container sections-container"></div>\n    ';result;isPreview;subReportHelper=o(this);constructor(t){super(t),this.isPreview=t.isPreview||!1}data(){const t={hasSendEmail:this.getAcl().checkScope("Email"),hasRuntimeFilters:this.hasRuntimeFilters(),hasPrintPdf:~(this.getHelper().getAppParam("templateEntityTypeList")||[]).indexOf("Report")};return this.isPreview&&(t.hasSendEmail=!1,t.hasPrintPdf=!1),t.hasDropdownMenu=!this.isPreview,t}events=(r(this),{'click [data-action="run"]':function(){this.refresh(),this.afterRun()},'click [data-action="refresh"]':function(){this.refresh()},'click [data-action="exportReport"]':function(){this.export()},'click [data-action="sendInEmail"]':function(){this.actionSendInEmail()},'click [data-action="printPdf"]':function(){this.actionPrintPdf()},'click [data-action="showSubReport"]':function(t){const e=t.currentTarget,i=$(t.currentTarget).data("group-value");let s,a=$(t.currentTarget).data("group-index");Object.prototype.hasOwnProperty.call(e.dataset,"groupSecondValue")&&(s=e.dataset.groupSecondValue,a=null,console.log(s)),this.showSubReport(i,a,s)}});async refresh(){const t=this.element;t&&(t.style.minHeight=t.clientHeight+"px"),await this.run(),t&&(t.style.minHeight="")}run(){return Promise.resolve()}afterRender(){this.$information=this.$el.find(".information-box")}async showSubReport(t,e,i,s){const n=this.result;if(this.isPreview){const t=this.translate("noSubReportInPreview","messages","Report");return void Espo.Ui.warning(t)}let o=this.model.id,r=this.model.attributes.entityType,l=n.subReportSwitchDataList;if(l){const t=l.find(t=>t.name===s)??l[0];s=t.name,r=t.entityType}this.result.isJoint&&(s??=n.columnList[0],o=n.columnReportIdMap[s],r=n.columnEntityTypeMap[s],l=this.subReportHelper.prepareSwitchDataList(this.result));const d=await this.subReportHelper.createCollection({entityType:r,reportId:o,groupIndex:e,groupValue:t,groupValue2:i,where:this.hasRuntimeFilters()?this.lastFetchedWhere:void 0,target:s});Espo.Ui.notify(" ... ");const c=new a.default({model:this.model,result:n,groupValue:t,collection:d,groupIndex:e,groupValue2:i,column:s,switchDataList:l,target:s,onSwitchSubReport:s=>{c.close(),this.showSubReport(t,e,i,s)}});await this.assignView("dialog",c),Espo.Ui.notify(),await c.render()}initReport(){this.once("after:render",()=>{this.run()}),this.hasRuntimeFilters()&&this.createRuntimeFilters()}afterRun(){}createRuntimeFilters(){const t=this.getStorage().get("state",this.getFilterStorageKey())||null,e=new n.default({entityType:this.model.attributes.entityType,filterList:this.model.attributes.runtimeFilters,internalClassName:this.model.attributes.internalClassName,filtersData:t});this.assignView("runtimeFilters",e,".report-runtime-filters-container")}hasRuntimeFilters(){return!!(this.model.attributes.runtimeFilters??[]).length}getRuntimeFilters(){return this.hasRuntimeFilters()?(this.lastFetchedWhere=this.getRuntimeFiltersView().fetch(),this.lastFetchedWhere):null}getFilterStorageKey(){return`report-filters-${this.model.id}`}getRuntimeFiltersView(){return this.getView("runtimeFilters")}storeRuntimeFilters(){if(this.hasRuntimeFilters()){if(!this.getRuntimeFiltersView())return;const t=this.getRuntimeFiltersView().fetchRaw();this.getStorage().set("state",this.getFilterStorageKey(),t)}}actionSendInEmail(){Espo.Ui.notify(" ... "),Espo.Ajax.postRequest("Report/action/getEmailAttributes",{id:this.model.id,where:this.getRuntimeFilters()},{timeout:0}).then(t=>{Espo.Ui.notify(!1),this.createView("compose","views/modals/compose-email",{attributes:t,keepAttachmentsOnSelectTemplate:!0,signatureDisabled:!0},t=>{t.render()})})}actionPrintPdf(){this.createView("pdfTemplate","views/modals/select-template",{entityType:"Report"},t=>{t.render(),this.listenToOnce(t,"select",t=>{this.clearView("pdfTemplate");const e=this.getRuntimeFilters(),i={id:this.model.id,where:e,templateId:t.id};Espo.Ui.notify(" ... "),Espo.Ajax.postRequest("Report/action/printPdf",i,{timeout:0}).then(t=>{if(Espo.Ui.notify(!1),"id"in t){const e=this.getBasePath()+"?entryPoint=download&id="+t.id;window.open(e,"_blank")}})})})}export(){}}t.default=u}),define("modules/advanced/views/report/reports/tables/grid2",["exports","view"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{templateContent='\n        \x3c!--suppress CssUnusedSymbol --\x3e\n        <style>\n            [data-report-type="grid-2"].with-horizontal-scroll {\n                table {\n                    border: 0;\n\n                    tr {\n                        > th:first-child,\n                        > td:first-child {\n                            position: sticky;\n                            left: 0;\n                            background-color: var(--table-bg-accent);\n                            box-shadow: inset var(--minus-1px) var(--1px) 0 var(--default-border-color);\n\n                            border-right: 0;\n                            border-top: 0;\n                            border-bottom: 0;\n\n                            > a,\n                            > strong {\n                                position: relative;\n                                top: var(--1px);\n                            }\n                        }\n\n                        > th:nth-child(2),\n                        > td:nth-child(2) {\n                            border-left: 0;\n                        }\n                    }\n                }\n            }\n        </style>\n\n        <div class="table-container no-side-margin" data-report-type="grid-2"></div>\n    ';columnWidthPx=110;columnWidth2Px=140;firstColumnWidthPx=170;nonSummaryColumnWidthPx=150;result;setup(){this.column=this.options.column,this.result=this.options.result,this.reportHelper=this.options.reportHelper}events={'click [data-action="showSubReport"]':function(t){const e=$(t.currentTarget),i=e.attr("data-group-value"),s=parseInt(e.attr("data-group-index")||0);this.trigger("click-group",i,s)}};formatGroup(t,e){const i=this.result.groupByList[t];return this.reportHelper.formatGroup(i,e,this.result)}formatCellValue(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!this.reportHelper.isColumnNumeric(e,this.result))return this.result.cellValueMaps&&this.result.cellValueMaps[e]&&(t=this.result.cellValueMaps[e][t]||t||""),Array.isArray(t)?t.join(", "):t;t=t||0;let s=!1,a=e.split(":");if(1===a.length&&(a=["",e]),a.length>1&&!e.includes(":(")){const t=this.reportHelper.getGroupFieldData(e,this.result);if(t){const e=t.entityType,i=t.field,a=t.fieldType;s=["currency","currencyConverted"].includes(a),s||"Opportunity"!==e||"amountWeightedConverted"!==i||(s=!0)}}if(!i&&0==t)return~e.indexOf("COUNT:")?'<span class="text-muted">0</span>':'<span class="text-muted">'+this.reportHelper.formatNumber(0)+"</span>";if(~e.indexOf("COUNT:"))return this.reportHelper.formatNumber(t);const n=(this.result.columnDecimalPlacesMap||{})[e];return this.reportHelper.formatNumber(t,{isCurrency:s,decimalPlaces:n,currency:this.result.currency})}afterRender(){const t=this.result,e=[],i=[];this.result.nonSummaryColumnList&&this.result.nonSummaryColumnList.forEach(t=>{const s=this.result.nonSummaryColumnGroupMap[t];s===this.result.groupByList[0]&&e.push(t),s===this.result.groupByList[1]&&i.push(t)});const s=this.result.grouping[0].length+1+i.length;let a=this.result.grouping[0].length;this.result.group2Sums&&a++;const n=i.length;let o=this.columnWidthPx;const r=this.reportHelper.getGroupFieldData(this.column,t);r&&"int"!==r.fieldType&&"COUNT"!==r.function&&(o=this.columnWidth2Px),e.length&&(o=this.nonSummaryColumnWidthPx);const l=this.firstColumnWidthPx/o,d=this.nonSummaryColumnWidthPx/o,c=100/(l+d*n+a),h=c*d,u=100-h*n-c*a,p=$('<table style="table-layout: fixed;">').addClass("table table-no-overflow").addClass("table-bordered"),f=$("<tbody>");p.append(f);const m=o;if(s>7){const t=m*a+this.nonSummaryColumnWidthPx*n+this.firstColumnWidthPx;p.css("min-width",t+"px")}this.options.hasChart&&!this.options.isLargeMode||p.addClass("no-margin");let g=$('<tr class="accented">');const y=$(`<th style="width: ${u.toString()}%">`);if(y.css({"word-wrap":"break-word"}),y.html("&nbsp;"),g.append(y),i.forEach(t=>{const e=this.reportHelper.formatColumn(t,this.result),i=$(`<th style="width: ${h}%">`).html(e);i.addClass("text-soft"),i.css({"word-wrap":"break-word"}),i.css({"font-weight":"600"}),g.append(i)}),this.result.grouping[0].forEach(t=>{let e=this.formatGroup(0,t);if(!this.result.noSubReport){const i=document.createElement("a");i.role="button",i.tabIndex=0,i.dataset.action="showSubReport",i.className="selectable",i.dataset.groupValue=t,i.innerHTML=e,e=i.outerHTML}const i=$(`<th style="width: ${c}%">`).html(e);i.css({"word-wrap":"break-word"}),g.append(i)}),this.result.group2Sums){const t=this.translate("Total","labels","Report"),e=$('<th class="text-soft">').css({"font-weight":"600"}).html(t);g.append(e)}f.append(g),e.length&&e.forEach(e=>{const s=$('<tr class="accented">'),a=this.reportHelper.formatColumn(e,this.result),n=$("<td>").html(a);n.addClass("text-soft"),n.css({"font-weight":"600"}),s.append(n),n.addClass("accented"),i.forEach(()=>{s.append('<td class="accented">')}),this.result.grouping[0].forEach(i=>{const n=this.formatGroup(0,i);let o=null;const r=t.nonSummaryData[t.groupByList[0]];i in r&&e in r[i]&&(o=r[i][e]);const l=this.reportHelper.isColumnNumeric(e,t)?"end":"",d=$(`<td style="text-align: ${l}">`).html(this.formatCellValue(o,e));this.reportHelper.isColumnNumeric(e,t)&&d.addClass("numeric-text");const c=this.unescapeString(n)+"\n"+this.unescapeString(a);d.attr("title",c),d.css({"word-wrap":"break-word"}),s.append(d)}),this.result.group2Sums&&s.append('<td class="accented">'),f.append(s)}),this.result.grouping[1].forEach(e=>{const s=$("<tr>"),a=this.formatGroup(1,e);let n=this.formatGroup(1,e);if(!this.result.noSubReport){const t=document.createElement("a");t.role="button",t.tabIndex=0,t.dataset.action="showSubReport",t.className="selectable",t.dataset.groupValue=e,t.dataset.groupIndex="1",t.innerHTML=n,n=t.outerHTML}const o=$("<td>").html(n);if(o.addClass("accented"),o.css({"word-wrap":"break-word"}),s.append(o),i.forEach(i=>{let n=null;const o=this.reportHelper.formatColumn(i,this.result),r=t.nonSummaryData[t.groupByList[1]];e in r&&i in r[e]&&(n=r[e][i]);const l=this.reportHelper.isColumnNumeric(i,t)?"end":"",d=$(`<td class="accented" style="text-align: ${l}; width: ${h}%">`).html(this.formatCellValue(n,i));this.reportHelper.isColumnNumeric(i,t)&&d.addClass("numeric-text");const c=this.unescapeString(a)+"\n"+this.unescapeString(o);d.attr("title",c),d.css({"word-wrap":"break-word"}),s.append(d)}),this.result.grouping[0].forEach(i=>{const n=this.formatGroup(0,i);let o=0;i in t.reportData&&e in t.reportData[i]&&(o=t.reportData[i][e][this.column]);const r=this.unescapeString(n)+"\n"+this.unescapeString(a),l=$(`<td style="text-align: end; width: ${m}%">`).addClass("numeric-text").html(this.formatCellValue(o,this.column));l.attr("title",r),l.css({"word-wrap":"break-word"}),s.append(l)}),this.result.group2Sums){let i=0;e in t.group2Sums&&(i=t.group2Sums[e][this.column]);const n=$('<td class="accented" style="text-align: end">').addClass("numeric-text").css("font-weight","600"),o=this.formatCellValue(i,this.column,!0);n.html(o);const r=this.unescapeString(a);n.attr("title",r),n.addClass("text-soft"),s.append(n)}f.append(s)}),g=$('<tr class="accented">');const w=$(`<strong class="text-soft">${this.translate("Total","labels","Report")}</strong>`);if(g.append($("<td>").html(w)),i.forEach(()=>{g.append("<td>")}),this.result.grouping[0].forEach(e=>{const i=this.formatGroup(0,e);let s=0;e in t.group1Sums&&(s=t.group1Sums[e][this.column]);const a=this.unescapeString(i),n=$("<strong>"+this.formatCellValue(s,this.column,!0)+"</strong>"),o=$('<td style="text-align: end">').html(n);o.css({"word-wrap":"break-word"}),o.addClass("text-soft"),o.addClass("numeric-text"),o.attr("title",a),g.append(o)}),this.result.group2Sums){const e=$('<td class="accented" style="text-align: end">').addClass("numeric-text").css("font-weight","600");let i=0;this.column in t.sums&&(i=t.sums[this.column]);const s=this.formatCellValue(i,this.column,!0);e.html(s),g.append(e)}f.append(g),this.$tableContainer=this.$el.find(".table-container"),this.$tableContainer.append(p),s>7&&(this.$tableContainer.css("overflow-y","auto"),this.$tableContainer.addClass("with-horizontal-scroll"))}unescapeString(t){return $("<div>").html(t).text()}}t.default=s}),define("modules/advanced/views/report/reports/charts/grid1bar-vertical",["exports","modules/advanced/views/report/reports/charts/grid2bar-vertical"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{noLegend=!0;columnWidth=60;barWidth=.5;legendColumnWidth=160;pointXHalfWidth=.5;chartType="barVertical";prepareData(){const t=this.result,e=this.grList=t.grouping[0];this.options.color&&(this.colorList=Espo.Utils.clone(this.colorList),this.colorList[0]=this.options.color);const i=this.columnList=this.columnList||[this.column];let s,a=1;this.columnList&&(this.columnList.length>1&&(this.barWidth=1/this.columnList.length*.65),a=1/this.columnList.length,s=Math.ceil(this.columnList.length/2)-1,this.columnList.length>1&&(this.noLegend=!1));let n=0,o=0,r=0,l=0;const d=[];i.forEach((t,i)=>{const c={data:[],label:this.reportHelper.formatColumn(t,this.result),column:t};let h=0;if(this.columnList){if(!this.isLine){h=a*(i-s),this.columnList.length%2==0&&(h-=a/2),h*=.75}this.secondColumnList&&~this.secondColumnList.indexOf(t)&&(c.yaxis=2)}c.value=0,e.forEach((e,i)=>{const s=(this.result.reportData[e]||{})[t]||0;this.secondColumnList&&~this.secondColumnList.indexOf(t)?(s>o&&(o=s),s<l&&(l=s)):(s>n&&(n=s),s<r&&(r=s)),c.data.push([i+h,s]),c.value+=s}),t in this.colors&&(c.color=this.colors[t]),d.push(c)}),this.max=n,this.max2=o,this.min=r,this.min2=l,this.chartData=d}getTickNumber(){const t=this.$container.width();return Math.floor(t/this.columnWidth)}isNoData(){if(!this.chartData.length)return!0;let t=!0;for(const e of this.chartData)if(e&&e.data&&e.data.length&&e.value){t=!1;break}return t}getHorizontalPointCount(){return this.grList.length}draw(){if(0===this.$container.height())return void this.$container.empty();if(this.isNoData())return void this.showNoData();const t=this.getTickNumber();this.$graph=this.flotr.draw(this.$container.get(0),this.chartData,{shadowSize:!1,colors:this.colorList,bars:{show:!0,horizontal:!1,shadowSize:0,lineWidth:1,fillOpacity:1,barWidth:this.barWidth},grid:{horizontalLines:!0,verticalLines:!1,outline:"sw",color:this.gridColor,tickColor:this.tickColor},yaxis:{min:this.min+.08*this.min,showLabels:!0,color:this.textColor,max:this.max+.08*this.max,tickFormatter:t=>{if(0==t&&0===this.min)return"";if(t>this.max+.072*this.max)return"";if(t%1==0){return'<span class="numeric-text">'+this.reportHelper.formatNumber(Math.floor(t),{isCurrency:this.isCurrency,useSiMultiplier:!0,noDecimalPart:!0,no3CharCurrencyFormat:!0,currency:this.result.currency})+"</span>"}return""}},y2axis:{min:this.min2+.08*this.min2,showLabels:!0,color:this.textColor,max:this.max2+.08*this.max2,tickFormatter:t=>0==t&&0===this.min2||t>this.max2+.07*this.max2?"":t%1==0?this.reportHelper.formatNumber(Math.floor(t),{useSiMultiplier:!0,noDecimalPart:!0}):""},xaxis:{min:this.xMin||0,max:this.xMax||null,noTicks:t,color:this.textColor,tickFormatter:e=>{if(e%1==0){const i=parseInt(e);if(i in this.grList)return this.grList.length-t>5&&i===this.grList.length-1&&!this.isZoomed?"":this.formatGroup(0,this.grList[i])}return""}},mouse:{track:!0,relative:!0,position:"s",lineColor:this.hoverColor,autoPositionVertical:!0,cursorPointer:!this.result.noSubReport,trackFormatter:t=>{const e=t.index,i=t.series.column;let s=this.formatGroup(0,this.grList[e]);return this.columnList&&(s&&(s+="<br>"),s+=t.series.label),s&&(s+="<br>"),s+='<span class="numeric-text">'+this.formatCellValue(t.y,i)+"</span>",s}},legend:{show:!this.noLegend,noColumns:this.getLegendColumnNumber(),container:this.$el.find(".legend-container"),labelBoxMargin:0,labelFormatter:this.labelFormatter.bind(this),labelBoxBorderColor:"transparent",backgroundOpacity:0}}),this.noLegend||this.adjustLegend(),this.dragStart||Flotr.EventAdapter.observe(this.$container.get(0),"flotr:click",t=>{if(!t.hit)return;if(!("index"in t.hit))return;let e=null;this.result.isJoint&&(e=this.columnList?this.columnList[t.hit.seriesIndex]:this.column),this.result.noSubReport||this.trigger("click-group",this.grList[t.hit.index],void 0,void 0,e)})}}t.default=s}),define("modules/advanced/views/report/fields/group-by",["exports","views/fields/multi-enum"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{validations=["required","maxCount"];noGroupFieldTypeList;noForeignGroupFieldTypeList;dateFieldTypeList=["date","datetime","datetimeOptional"];setup(){this.noGroupFieldTypeList=this.getMetadata().get("app.advancedReport.noGroupFieldTypeList")??[],this.noForeignGroupFieldTypeList=this.getMetadata().get("app.advancedReport.noForeignGroupFieldTypeList")??[],super.setup(),this.setupOptions(),this.setupTranslatedOptions(),this.events['click [data-action="edit-groups"]']="editGroups"}validateMaxCount(){if((this.model.get(this.name)||[]).length>2){const t=this.translate("validateMaxCount","messages","Report").replace("{field}",this.translate(this.name,"fields",this.model.name)).replace("{maxCount}",2..toString());return this.showValidationMessage(t,".selectize-control"),!0}}translateValueToEditLabel(t){return(this.params.options||[]).includes(t)?super.translateValueToEditLabel(t):t.replace(/\t/g,"")}afterRender(){if(super.afterRender(),this.isEditMode()){const t=$('<button class="pull-right btn btn-default" data-action="edit-groups"><span class="fas fa-pencil-alt fa-sm"></span></button>');this.$el.prepend(t);const e=t.outerWidth()+8;this.$el.find(".selectize-control").css("width","calc(100% - "+e+"px)")}}editGroups(){this.createView("dialog","advanced:views/report/modals/edit-group-by",{value:Espo.Utils.clone(this.model.get(this.name)||[]),model:this.model}).then(t=>{t.render(),this.listenToOnce(t,"apply",e=>{t.close(),this.model.set(this.name,e)})})}setupOptions(){const t=this.model.get("entityType"),e=this.getMetadata().get(`entityDefs.${t}.fields`)||{},i=[],s=Object.keys(e);let a=!0;const n=this.getConfig().get("version")||"",o=n.split(".");"dev"!==n&&o.length>2&&100*parseInt(o[0])+parseInt(o[1])<408&&(a=!1);let r=!0;"dev"!==n&&o.length>2&&100*parseInt(o[0])+parseInt(o[1])<505&&(r=!1),s.sort((e,i)=>this.translate(e,"fields",t).localeCompare(this.translate(i,"fields",t))),s.forEach(s=>{e[s].disabled||e[s].utility||e[s].reportDisabled||e[s].reportGroupByDisabled||e[s].directAccessDisabled||this.getFieldManager().isEntityTypeFieldAvailable(t,s)&&this.dateFieldTypeList.includes(e[s].type)&&(i.push(`MONTH:${s}`),i.push(`YEAR:${s}`),i.push(`DAY:${s}`),a&&i.push(`WEEK:${s}`),r&&i.push(`QUARTER:${s}`),this.getConfig().get("fiscalYearShift")&&(i.push(`YEAR_FISCAL:${s}`),i.push(`QUARTER_FISCAL:${s}`)))}),i.push("id"),s.forEach(s=>{this.noGroupFieldTypeList.includes(e[s].type)||e[s].disabled||e[s].utility||e[s].reportDisabled||e[s].reportGroupByDisabled||e[s].directAccessDisabled||this.getFieldManager().isEntityTypeFieldAvailable(t,s)&&i.push(s)});const l=this.getMetadata().get(`entityDefs.${t}.links`)||{},d=Object.keys(l);d.sort((e,i)=>this.translate(e,"links",t).localeCompare(this.translate(i,"links",t))),d.forEach(t=>{if("belongsTo"!==l[t].type&&"hasOne"!==l[t].type)return;const e=l[t].entity;if(!e)return;if(l[t].disabled||l[t].utility)return;const s=this.getMetadata().get(`entityDefs.${e}.fields`)||{},n=Object.keys(s);n.sort((t,i)=>this.translate(t,"fields",e).localeCompare(this.translate(i,"fields",e))),n.forEach(n=>{s[n].disabled||s[n].utility||s[n].reportDisabled||s[n].reportGroupByDisabled||s[n].directAccessDisabled||s[n].foreignAccessDisabled||(this.dateFieldTypeList.includes(s[n].type)&&(i.push(`MONTH:${t}.${n}`),i.push(`YEAR:${t}.${n}`),i.push(`DAY:${t}.${n}`),a&&i.push(`WEEK:${t}.${n}`)),this.noGroupFieldTypeList.includes(s[n].type)||this.noForeignGroupFieldTypeList.includes(s[n].type)||this.getFieldManager().isEntityTypeFieldAvailable(e,n)&&i.push(`${t}.${n}`))})}),this.params.options=i}setupTranslatedOptions(t){this.translatedOptions={};const e=t||this.model.get("entityType");this.params.options.forEach(t=>{let i=!1,s=t,a=e,n=!1,o=t,r=null,l=null;~t.indexOf(":")&&(i=!0,l=t.split(":")[0],o=s=t.split(":")[1]),~o.indexOf(".")&&(n=!0,r=o.split(".")[0],s=o.split(".")[1],a=this.getMetadata().get(`entityDefs.${e}.links.${r}.entity`)),this.translatedOptions[t]=this.translate(s,"fields",a);"currencyConverted"===this.getMetadata().get(["entityDefs",a,"fields",s,"type"])&&"Converted"===s.substr(-9)&&(this.translatedOptions[t]=this.translate(s.substr(0,s.length-9),"fields",a)),n&&(this.translatedOptions[t]=this.translate(r,"links",e)+" . "+this.translatedOptions[t]),i&&(this.translatedOptions[t]=this.translate(l,"functions","Report").toUpperCase()+": "+this.translatedOptions[t])})}}t.default=s}),define("modules/advanced/views/dashlets/report",["exports","views/dashlets/abstract/base","search-manager","modules/advanced/report-helper","di","modules/advanced/helpers/report/sub-report-helper","modules/advanced/views/report/modals/sub-report"],function(t,e,i,s,a,n,o){"use strict";let r,l;function d(t){return t&&t.__esModule?t:{default:t}}function c(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function h(t,e,i){"symbol"==typeof e&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch(t){}return t}function u(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(null!==t?typeof t:"null"));return t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=d(e),i=d(i),s=d(s),n=d(n),o=d(o);class p extends e.default{static#t=[r,l]=function(t,e,i,s,a,n){var o,r,l,d,p,f,m,g=Symbol.metadata||Symbol.for("Symbol.metadata"),y=Object.defineProperty,w=Object.create,v=[w(null),w(null)],b=e.length;function T(e,i,s){return function(a,n){i&&(n=a,a=t);for(var o=0;o<e.length;o++)n=e[o].apply(a,s?[n]:[]);return s?n:a}}function D(t,e,i,s){if("function"!=typeof t&&(s||void 0!==t))throw new TypeError(e+" must "+(i||"be")+" a function"+(s?"":" or undefined"));return t}function k(t,e,i,s,a,n,l,d,c,u,p){function f(t){if(!p(t))throw new TypeError("Attempted to access private element on non-instance")}var m=[].concat(e[0]),g=e[3],w=!l,b=1===a,k=3===a,E=4===a,C=2===a;function x(e,i,s){return function(a,n){return i&&(n=a,a=t),s&&s(a),O[e].call(a,n)}}if(!w){var O={},L=[],M=k?"get":E||b?"set":"value";if(c?(u||b?O={get:h(function(){return g(this)},s,"get"),set:function(t){e[4](this,t)}}:O[M]=g,u||h(O[M],s,C?"":M)):u||(O=Object.getOwnPropertyDescriptor(t,s)),!u&&!c){if((r=v[+d][s])&&7!=(r^a))throw Error("Decorating two elements with the same name ("+O[M].name+") is not supported yet");v[+d][s]=a<3?1:a}}for(var F=t,S=m.length-1;S>=0;S-=i?2:1){var V=D(m[S],"A decorator","be",!0),R=i?m[S-1]:void 0,$={},I={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:o,addInitializer:function(t,e){if(t.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(e,"An initializer","be",!0),n.push(e)}.bind(null,$)};if(w)r=V.call(R,F,I),$.v=1,D(r,"class decorators","return")&&(F=r);else if(I.static=d,I.private=c,r=I.access={has:c?p.bind():function(t){return s in t}},E||(r.get=c?C?function(t){return f(t),O.value}:x("get",0,f):function(t){return t[s]}),C||k||(r.set=c?x("set",0,f):function(t,e){t[s]=e}),F=V.call(R,b?{get:O.get,set:O.set}:O[M],I),$.v=1,b){if("object"==typeof F&&F)(r=D(F.get,"accessor.get"))&&(O.get=r),(r=D(F.set,"accessor.set"))&&(O.set=r),(r=D(F.init,"accessor.init"))&&L.unshift(r);else if(void 0!==F)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(F,(u?"field":"method")+" decorators","return")&&(u?L.unshift(F):O[M]=F)}return a<2&&l.push(T(L,d,1),T(n,d,0)),u||w||(c?b?l.splice(-1,0,x("get",d),x("set",d)):l.push(C?O[M]:D.call.bind(O[M])):y(t,s,O)),F}function E(t){return y(t,g,{configurable:!0,enumerable:!0,value:o})}return void 0!==n&&(o=n[g]),o=w(null==o?null:o),p=[],f=function(t){t&&p.push(T(t))},(m=function(e,s){for(var n=0;n<i.length;n++){var o=i[n],r=o[1],h=7&r;if((8&r)==e&&!h==s){var f=o[2],m=!!o[3],g=16&r;k(e?t:t.prototype,o,g,m?"#"+f:c(f),h,h<2?[]:e?d=d||[]:l=l||[],p,!!e,m,s,e&&m?function(e){return u(e)===t}:a)}}})(8,0),m(0,0),m(8,1),m(0,1),f(l),f(d),r=p,b||E(t),{e:r,get c(){var i=[];return b&&[E(t=k(t,[e],s,t.name,5,i)),T(i,1)]}}}(this,[],[[(0,a.inject)(n.default),0,"subReportHelper"]],0,void 0,e.default).e;constructor(){super(...arguments),l(this)}name="Report";templateContent='<div class="report-results-container" style="height: 100%;"></div>';totalFontSizeMultiplier=1.5;totalLineHeightMultiplier=1.1;totalMarginMultiplier=.4;totalOnlyFontSizeMultiplier=4;totalLabelMultiplier=.6;total2LabelMultiplier=.4;rowActionsView=!1;subReportHelper=r(this);setup(){this.optionsFields.report={type:"link",entity:"Report",required:!0,view:"advanced:views/report/fields/dashlet-select"},this.optionsFields.column={type:"enum",options:[]},this.reportHelper=new s.default(this.getMetadata(),this.getLanguage(),this.getDateTime(),this.getConfig(),this.getPreferences())}afterAdding(){this.getParentView().actionOptions()}getListLayout(){const t=this.getOption("entityType"),e=[],i=Espo.Utils.cloneDeep(this.columnsData||{});return(this.columns||[]).forEach(s=>{const a=i[s]||{};if(a.name=s,~s.indexOf(".")){const e=s.split(".");a.name=s.replace(".","_"),a.notSortable=!0;const i=e[0],n=e[1],o=this.getMetadata().get(`entityDefs.${t}.links.${i}.entity`);a.customLabel=this.translate(i,"links",t)+" . "+this.translate(n,"fields",o);const r=this.getMetadata().get(`entityDefs.${o}.fields.${n}.type`);"enum"===r?(a.view="views/fields/foreign-enum",a.options={params:{link:i,field:n}}):"image"===r?(a.view="views/fields/image",a.options={foreignScope:o}):"file"===r?(a.view="views/fields/file",a.options={foreignScope:o}):"date"===r?(a.view="views/fields/foreign-date",a.notSortable=!1,a.options={params:{link:i,field:n}}):"datetime"===r?(a.view="views/fields/foreign-datetime",a.options={params:{link:i,field:n}},a.notSortable=!1):"link"===r?a.view="advanced:views/fields/foreign-link":"email"===r?(a.view="views/fields/email",a.notSortable=!1):"phone"===r?(a.view="views/fields/phone",a.notSortable=!1):"array"===r?(a.view="views/fields/foreign-array",a.options={params:{link:i,field:n}}):"multiEnum"===r?(a.view="views/fields/foreign-multi-enum",a.options={params:{link:i,field:n}}):"checklist"===r?(a.view="views/fields/foreign-checklist",a.options={params:{link:i,field:n}}):"urlMultiple"===r?(a.view="views/fields/foreign-url-multiple",a.options={params:{link:i,field:n}}):"varchar"===r?(a.view="views/fields/varchar",a.notSortable=!1):"bool"===r?(a.view="views/fields/bool",a.notSortable=!1):"currencyConverted"===r&&(a.view="views/fields/currency-converted",a.notSortable=!1)}e.push(a)}),e}displayError(t){t=t||"error",this.$el.find(".report-results-container").html(this.translate(t,"errorMessages","Report"))}displayTotal(t,e){const i=this.getThemeManager().getFontSizeFactor?this.getThemeManager().getFontSizeFactor():1,s=(this.getThemeManager().getParam("fontSize")||14)*i,a=100/t.length*i;let n;if(!e){this.$container.empty();let o=s*this.totalOnlyFontSizeMultiplier;t.length>1&&(o=Math.round(o/(Math.log(t.length+1)/Math.log(2.3))),n=Math.round(o*this.total2LabelMultiplier)),this.$container.css("height","100%");const r=$("<div>").css("text-align","center").css("table-layout","fixed").css("display","table").css("width","100%").css("height","100%");return t.forEach(l=>{const d=l.stringValue,c=l.color,h=$("<div>").css("display","table-cell").css("padding-bottom",1.5*s+"px").css("vertical-align","middle");a<100*i&&h.css("width",a.toString()+"%");const u=$('<div class="total-value-text numeric-text">').css("font-size",o.toPrecision(4)+"px").html(d.toString());if(l.stringOriginalValue&&u.attr("title",l.stringOriginalValue),c?u.css("color",c):e||u.addClass("text-primary"),t.length>1){const t=$("<div>").css("font-size",n.toString()+"px").css("max-height","1.3em").css("overflow","hidden").css("user-select","none").addClass("text-muted").html(l.columnLabel);h.append(t)}h.append(u),r.append(h)}),this.$container.append(r),this.totalFontSize=o,this.controlTotalTextOverflow(),this.stopListening(this,"resize",this.controlTotalTextOverflow.bind(this)),void this.listenTo(this,"resize",this.controlTotalTextOverflow.bind(this))}const o=s*this.totalFontSizeMultiplier;t.length>1&&(n=Math.round(o*this.totalLabelMultiplier));const r=this.getContainerTotalHeight(t.length>1)+"px",l=$("<div>").css("text-align","center").css("display","table").css("width","100%");this.$totalContainer.css("height",r),this.$container.css("height",`calc(100% - ${r})`),t.forEach(e=>{const i=e.stringValue,s=e.color,d=$("<div>").html(i.toString());let c="";if(e.stringOriginalValue&&(c=e.stringOriginalValue),1===t.length){d.addClass("pull-right");const t=c;c=this.translate("Total","labels","Report"),t&&(c=c+": "+t)}d.attr("title",c).addClass("text-primary numeric-text").css("font-size",Math.ceil(o)+"px"),s&&d.css("color",s),1===t.length&&d.css("line-height",r);const h=$("<div>").css("display","table-cell");if(a<100&&h.css("width",a.toString()+"%"),t.length>1){const t=$("<div>").css("font-size",n.toString()+"px").css("max-height","1.2em").css("overflow","hidden").css("user-select","none").addClass("text-muted").html(e.columnLabel);h.append(t)}h.append(d),l.append(h)}),this.$totalContainer.append(l)}controlTotalTextOverflow(){let{totalFontSize:t}=this;const e=this.$el.find(".total-value-text");e.css("font-size",t+"px");const i=()=>{let s=!1;e.each((t,e)=>{e.scrollWidth>e.clientWidth&&(s=!0)}),s&&(t--,e.css("font-size",t+"px"),i())};i()}getContainerTotalHeight(t){const e=this.getThemeManager().getParam("fontSize")||14,i=e*this.totalFontSizeMultiplier,s=e*this.totalMarginMultiplier;let a=Math.ceil(i*this.totalLineHeightMultiplier+s);return t&&(a+=a*this.totalLabelMultiplier),a+=3*this.totalFontSizeMultiplier,a}actionRefresh(){this.hasView("reportChart")&&this.clearView("reportChart"),this.reRender()}afterRender(){this.$container=this.$el.find(".report-results-container"),this.run()}getCollectionUrl(){return"Report/action/runList?id="+this.getOption("reportId")}getGridReportUrl(){return"Report/action/run"}getGridReportRequestData(t){return{id:this.getOption("reportId"),where:t}}setContainerHeight(){"List"===this.getOption("type")?this.$container.css("height","auto"):this.$container.css("height","100%")}async run(){if(!this.getOption("reportId"))return void this.displayError("selectReport");const t=this.getOption("entityType");if(!t)return void this.displayError();const e=this.getOption("type");if(!e)return void this.displayError();this.setContainerHeight();const s=await this.getCollectionFactory().create(t),a=new i.default(s,"report",null,this.getDateTime());"setTimeZone"in a&&a.setTimeZone(null);let n=null;if(this.getOption("filtersData")&&(a.setAdvanced(this.getOption("filtersData")),n=a.getWhere()),"List"===e){s.url=this.getCollectionUrl(),s.where=n,s.setOrder&&s.setOrder(null,null,!0),this.collectionMaxSize&&(s.maxSize=this.collectionMaxSize);const t={where:s.getWhere(),offset:s.offset,maxSize:s.maxSize},e=await Espo.Ajax.getRequest(s.url,t),i=this.columns=e.columns;this.columnsData=e.columnsData||{};const a=s.prepareAttributes?s.prepareAttributes(e):s.parse(e);if(s.set(a),!i)return void this.displayError();if(this.getOption("displayOnlyCount")){const t={stringValue:this.reportHelper.formatNumber(s.total,{useSiMultiplier:this.getOption("useSiMultiplier")})};return this.getOption("useSiMultiplier")&&(t.stringOriginalValue=this.reportHelper.formatNumber(s.total)),void this.displayTotal([t])}this.createView("list","views/record/list",{selector:".report-results-container",collection:s,listLayout:this.getListLayout(),checkboxes:!1,rowActionsView:this.rowActionsView,displayTotalCount:!1}).then(t=>{t.render()})}if("Grid"===e||"JointGrid"===e){const t=this.getGridReportUrl(),e=await Espo.Ajax.getRequest(t,this.getGridReportRequestData(n));if(!e.depth&&0!==e.depth)return void this.displayError();const i=e.chartType||"BarHorizontal";let s,a=!1;this.isPanel||(s="100%",(2===e.depth||~["Pie"].indexOf(i))&&(a=!0));let o,r,l=this.getOption("column");if(!l){const t=this.reportHelper.getChartColumnGroupList(e);t.length&&(o=t[0].columnList,r=t[0].secondColumnList,l=t[0].column,l||this.isPanel||(a=!0))}const d=e.numericColumnList||e.columnList,c=[];if("Table"===this.getOption("displayType"))return void this.displayTable(e,n);if(d.length&&(this.getOption("displayOnlyCount")||this.getOption("displayTotal"))&&d.forEach(t=>{let i;if(1===e.depth||0===e.depth)i=e.sums[t]||0;else{i=0;for(const s in e.group1Sums)i+=e.group1Sums[s][t]}const s=this.reportHelper.formatCellValue(i,t,e,this.getOption("useSiMultiplier"));let a=e.chartColor;(e.chartColors||{})[t]&&(a=(e.chartColors||{})[t]),e.chartType||(a=null);let n=null;this.getOption("useSiMultiplier")&&(n=this.reportHelper.formatCellValue(i,t,e)),c.push({column:t,color:a,stringValue:s,columnLabel:this.reportHelper.formatColumn(t,e),stringOriginalValue:n})}),d.length&&this.getOption("displayOnlyCount"))return void this.displayTotal(c);d.length&&this.getOption("displayTotal")&&(this.$totalContainer=$('<div class="report-total-container"></div>'),this.$totalContainer.insertBefore(this.$container),this.displayTotal(c,!0)),this.$el.closest(".panel-body").css({"overflow-y":"visible","overflow-x":"visible"});const h=`advanced:views/report/reports/charts/grid${e.depth}${Espo.Utils.camelCaseToHyphen(i)}`;this.createView("reportChart",h,{selector:" .report-results-container",column:l,columnList:o,secondColumnList:r,result:e,reportHelper:this.reportHelper,height:s,fitHeight:a,colors:e.chartColors||{},color:e.chartColor||null,defaultHeight:this.defaultHeight,isDashletMode:!0}).then(t=>{this._isHidden()?(this.once("show",()=>{this._isHidden()||t.render()}),this.once("tab-show",()=>{this._isHidden()||t.render()})):t.render(),this.on("resize",()=>{t.trigger("resize")}),this.listenTo(t,"click-group",(t,i,s,a)=>{this.showSubReport(n,e,t,i,s,a)})})}}_isHidden(){return!1}async showSubReport(t,e,i,s,a,n){let r=this.getOption("reportId"),l=this.getOption("entityType"),d=e.subReportSwitchDataList;if(d){const t=d.find(t=>t.name===n)??d[0];n=t.name,l=t.entityType}e.isJoint&&(n??=e.columnList[0],r=e.columnReportIdMap[n],l=e.columnEntityTypeMap[n],d=this.subReportHelper.prepareSwitchDataList(e));const c=await this.subReportHelper.createCollection({entityType:l,reportId:r,groupIndex:s,groupValue:i,groupValue2:a,where:t,target:n});Espo.Ui.notify(" ... ");const h=new o.default({reportId:r,reportName:this.getOption("title"),result:e,groupValue:i,groupIndex:s,groupValue2:a,collection:c,column:n,switchDataList:d,target:n,onSwitchSubReport:n=>{h.close(),this.showSubReport(t,e,i,s,a,n)}});await this.assignView("dialog",h),Espo.Ui.notify(),await h.render()}setupActionList(){const t=this.getOption("reportId");this.actionList.unshift({name:"viewReport",html:this.translate("View Report","labels","Report"),url:`#Report/show/${t}`,iconHtml:'<span class="fas fa-chart-bar"></span>'})}displayTable(t,e){let i="modules/advanced/views/report/reports/tables/grid1";2===t.depth&&(i="modules/advanced/views/report/reports/tables/grid2","Normalized"===t.tableMode&&(i="modules/advanced/views/report/reports/tables/grid2-normalized")),this.createView("table",i,{selector:".report-results-container",result:t,reportHelper:this.reportHelper,column:this.getOption("column")}).then(i=>{i.render(),this.listenTo(i,"click-group",(i,s,a)=>{this.showSubReport(e,t,i,s,a,this.getOption("column"))})})}actionViewReport(){const t=this.getOption("reportId");Espo.Ui.notify(" ... "),this.getModelFactory().create("Report",e=>{e.id=t,e.fetch().then(()=>{Espo.Ui.notify(!1),this.createView("resultModal","advanced:views/report/modals/result",{model:e},t=>{t.render(),this.listenToOnce(t,"navigate-to-detail",e=>{this.getRouter().navigate(`#Report/view/${e.id}`,{trigger:!1}),this.getRouter().dispatch("Report","view",{id:e.id,model:e}),t.close()})})})})}}t.default=p}),define("advanced:views/bpmn-flowchart-element/record/edit",["views/record/edit-small"],function(t){return t.extend({setup:function(){this.dynamicLogicDefs=this.options.dynamicLogicDefs,t.prototype.setup.call(this)}})}),define("advanced:views/bpmn-flowchart-element/record/detail",["views/record/detail-small"],function(t){return t.extend({setup:function(){this.dynamicLogicDefs=this.options.dynamicLogicDefs,t.prototype.setup.call(this),this.model.get("description")||(this.hideField("description"),this.hidePanel("description")),this.model.get("text")||(this.hideField("text"),this.hidePanel("text"));var e={list:this.model.get("dataList"),createdEntitiesData:this.model.flowchartCreatedEntitiesData};this.model.set("flowchartData",e)}})}),define("modules/advanced/workflow-helper",["exports","di","metadata"],function(t,e,i){"use strict";var s;let a,n;function o(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function r(t,e,i){"symbol"==typeof e&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch(t){}return t}function l(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(null!==t?typeof t:"null"));return t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,i=(s=i)&&s.__esModule?s:{default:s};class d{static#t=[a,n]=function(t,e,i,s,a,n){var d,c,h,u,p,f,m,g=Symbol.metadata||Symbol.for("Symbol.metadata"),y=Object.defineProperty,w=Object.create,v=[w(null),w(null)],b=e.length;function T(e,i,s){return function(a,n){i&&(n=a,a=t);for(var o=0;o<e.length;o++)n=e[o].apply(a,s?[n]:[]);return s?n:a}}function D(t,e,i,s){if("function"!=typeof t&&(s||void 0!==t))throw new TypeError(e+" must "+(i||"be")+" a function"+(s?"":" or undefined"));return t}function k(t,e,i,s,a,n,o,l,h,u,p){function f(t){if(!p(t))throw new TypeError("Attempted to access private element on non-instance")}var m=[].concat(e[0]),g=e[3],w=!o,b=1===a,k=3===a,E=4===a,C=2===a;function x(e,i,s){return function(a,n){return i&&(n=a,a=t),s&&s(a),O[e].call(a,n)}}if(!w){var O={},L=[],M=k?"get":E||b?"set":"value";if(h?(u||b?O={get:r(function(){return g(this)},s,"get"),set:function(t){e[4](this,t)}}:O[M]=g,u||r(O[M],s,C?"":M)):u||(O=Object.getOwnPropertyDescriptor(t,s)),!u&&!h){if((c=v[+l][s])&&7!=(c^a))throw Error("Decorating two elements with the same name ("+O[M].name+") is not supported yet");v[+l][s]=a<3?1:a}}for(var F=t,S=m.length-1;S>=0;S-=i?2:1){var V=D(m[S],"A decorator","be",!0),R=i?m[S-1]:void 0,$={},I={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:d,addInitializer:function(t,e){if(t.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(e,"An initializer","be",!0),n.push(e)}.bind(null,$)};if(w)c=V.call(R,F,I),$.v=1,D(c,"class decorators","return")&&(F=c);else if(I.static=l,I.private=h,c=I.access={has:h?p.bind():function(t){return s in t}},E||(c.get=h?C?function(t){return f(t),O.value}:x("get",0,f):function(t){return t[s]}),C||k||(c.set=h?x("set",0,f):function(t,e){t[s]=e}),F=V.call(R,b?{get:O.get,set:O.set}:O[M],I),$.v=1,b){if("object"==typeof F&&F)(c=D(F.get,"accessor.get"))&&(O.get=c),(c=D(F.set,"accessor.set"))&&(O.set=c),(c=D(F.init,"accessor.init"))&&L.unshift(c);else if(void 0!==F)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(F,(u?"field":"method")+" decorators","return")&&(u?L.unshift(F):O[M]=F)}return a<2&&o.push(T(L,l,1),T(n,l,0)),u||w||(h?b?o.splice(-1,0,x("get",l),x("set",l)):o.push(C?O[M]:D.call.bind(O[M])):y(t,s,O)),F}function E(t){return y(t,g,{configurable:!0,enumerable:!0,value:d})}return void 0!==n&&(d=n[g]),d=w(null==d?null:d),p=[],f=function(t){t&&p.push(T(t))},m=function(e,s){for(var n=0;n<i.length;n++){var r=i[n],d=r[1],c=7&d;if((8&d)==e&&!c==s){var f=r[2],m=!!r[3],g=16&d;k(e?t:t.prototype,r,g,m?"#"+f:o(f),c,c<2?[]:e?u=u||[]:h=h||[],p,!!e,m,s,e&&m?function(e){return l(e)===t}:a)}}},m(8,0),m(0,0),m(8,1),m(0,1),f(h),f(u),c=p,b||E(t),{e:c,get c(){var i=[];return b&&[E(t=k(t,[e],s,t.name,5,i)),T(i,1)]}}}(this,[],[[(0,e.inject)(i.default),0,"metadata"]]).e;constructor(){n(this)}metadata=a(this);getComplexFieldEntityType(t,e){if(~t.indexOf(".")&&!~t.indexOf("created:")){const i=t.split(".")[0];return this.metadata.get(["entityDefs",e,"links",i,"entity"])}return e}getComplexFieldFieldPart(t){if(~t.indexOf(".")){return t.split(".")[1]}return t}getComplexFieldForeignEntityType(t,e){let i;if(~t.indexOf(".")){const s=t.split("."),a=s[1],n=s[0],o=this.metadata.get(["entityDefs",e,"links",n,"entity"]);i=this.metadata.get(["entityDefs",o,"links",a,"entity"])}else i=this.metadata.get(["entityDefs",e,"links",t,"entity"]);return i}}t.default=d}),define("modules/advanced/views/workflow/record/edit-bottom",["exports","views/record/edit-bottom"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{editMode=!0;template="advanced:workflow/record/edit-bottom";setup(){super.setup(),"scheduled"!==this.model.get("type")&&"manual"!==this.model.get("type")||this.hideConditions(),this.listenTo(this.model,"change",(t,e)=>{e.ui&&(this.model.hasChanged("entityType")||this.model.hasChanged("type"))&&this.onTypeChange(t)})}onTypeChange(){const t=this.model,e=t.attributes.entityType,i=this.model.attributes.type;this.model.hasChanged("entityType")&&(t.set("conditionsAny",[]),t.set("conditionsAll",[]),t.set("actions",[])),this.model.hasChanged("type")&&["scheduled","manual"].includes(i)&&(this.storeConditions(),t.set("conditionsAny",[]),t.set("conditionsAll",[]),t.set("conditionsFormula",null)),this.model.hasChanged("type")&&!["scheduled","manual"].includes(i)&&this.restoreConditions(),"scheduled"===i||"manual"===i?(this.hideConditions(),e?this.showActions():this.hideActions()):e?(this.showConditions(),this.showActions()):(this.hideConditions(),this.hideActions())}storeConditions(){const t={conditionsAny:this.model.get("conditionsAny"),conditionsAll:this.model.get("conditionsAll"),conditionsFormula:this.model.get("conditionsFormula")};this.previousConditions=Espo.Utils.cloneDeep(t)}restoreConditions(){this.previousConditions&&(this.model.set(this.previousConditions,{ui:!0}),this.previousConditions=null)}afterRender(){this.model.isNew()?this.model.get("entityType")&&(this.showConditions(),this.showActions()):(this.showConditions(),this.showActions()),super.afterRender()}showConditions(){var t;null===(t=this.element.querySelector(".panel-conditions"))||void 0===t||t.classList.remove("hidden"),this.clearView("conditions"),this.createView("conditions","advanced:views/workflow/record/conditions",{model:this.model,selector:".conditions-container",readOnly:!this.editMode}).then(t=>{t.render(),this.editMode&&this.listenTo(t,"change",()=>{this.recordViewObject&&this.recordViewObject.onChangeConditions()})})}showActions(){var t;null===(t=this.element.querySelector(".panel-actions"))||void 0===t||t.classList.remove("hidden"),this.clearView("actions"),this.createView("actions","advanced:views/workflow/record/actions",{model:this.model,selector:" .actions-container",readOnly:!this.editMode},t=>{t.render(),this.editMode&&this.listenTo(t,"change",()=>{this.recordViewObject&&this.recordViewObject.onChangeActions()})})}hideConditions(){var t;this.isRendered()?(null===(t=this.element.querySelector(".panel-conditions"))||void 0===t||t.classList.add("hidden"),this.clearView("conditions")):this.once("after:render",()=>{this.hideConditions()})}hideActions(){var t;null===(t=this.element.querySelector(".panel-actions"))||void 0===t||t.classList.add("hidden"),this.clearView("actions")}getFieldViews(t){return{}}}t.default=s}),define("modules/advanced/views/workflow/record/detail",["exports","views/record/detail"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{editModeDisabled=!0;duplicateAction=!0;bottomView="advanced:views/workflow/record/detail-bottom";stickButtonsContainerAllTheWay=!0;saveAndContinueEditingAction=!0;setup(){super.setup(),this.manageFieldsVisibility(),this.listenTo(this.model,"change",(t,e)=>{(this.model.hasChanged("portalOnly")||this.model.hasChanged("type"))&&this.manageFieldsVisibility(e.ui)}),this.model.isNew()||(this.setFieldReadOnly("type"),this.setFieldReadOnly("entityType"))}manageFieldsVisibility(t){const e=this.model.attributes.type;return this.model.attributes.portalOnly&&["afterRecordSaved","afterRecordCreated","afterRecordUpdated","signal"].includes(e)?this.showField("portal"):this.hideField("portal"),"scheduled"!==e&&(this.hideField("targetReport"),this.hideField("scheduling"),this.setFieldNotRequired("targetReport")),"manual"===e?(this.hideField("portalOnly"),this.hideField("portal"),void("edit"===this.mode&&t&&setTimeout(()=>{this.model.set({portalId:null,portalName:null,portalOnly:!1})},100))):"scheduled"===e?(this.showField("targetReport"),this.showField("scheduling"),this.setFieldRequired("targetReport"),this.hideField("portal"),this.hideField("portalOnly"),void("edit"===this.mode&&t&&setTimeout(()=>{this.model.set({portalId:null,portalName:null,portalOnly:!1})},100))):"sequential"===e?(this.hideField("portal"),this.hideField("portalOnly"),void("edit"===this.mode&&t&&setTimeout(()=>{this.model.set({portalId:null,portalName:null,portalOnly:!1})},100))):(this.model.attributes.portalOnly&&this.showField("portal"),void this.showField("portalOnly"))}}t.default=s}),define("modules/advanced/views/workflow/record/conditions",["exports","view"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{template="advanced:workflow/record/conditions";data(){const t=(this.model.attributes.conditionsAll||[]).length>0,e=(this.model.attributes.conditionsAny||[]).length>0,i=!!this.model.attributes.conditionsFormula;return{fieldList:this.fieldList,entityType:this.entityType,readOnly:this.readOnly,showFormula:!this.readOnly||i,showConditionsAll:!this.readOnly||t,showConditionsAny:e,showNoData:this.readOnly&&!i&&!e&&!t,marginForConditionsAny:!this.readOnly||t,marginForFormula:!this.readOnly||t||e}}setup(){this.entityType=this.scope=this.options.entityType||this.model.attributes.entityType,this.readOnly=this.options.readOnly||!1,this.model.isNew()||void 0!==this.model.attributes.conditionsAll&&void 0!==this.model.attributes.conditionsFormula||this.listenToOnce(this.model,"sync",()=>this.reRender())}afterRender(){this.createView("groupAll","advanced:views/workflow/record/conditions/group",{selector:".all-conditions",conditions:this.model.attributes.conditionsAll||[],groupType:"all",entityType:this.entityType,model:this.model,flowchartCreatedEntitiesData:this.options.flowchartCreatedEntitiesData,readOnly:this.readOnly}).then(t=>{t.render(),this.listenTo(t,"change",()=>{this.trigger("change")})}),this.createView("groupAny","advanced:views/workflow/record/conditions/group",{selector:".any-conditions",conditions:this.model.attributes.conditionsAny||[],groupType:"any",entityType:this.entityType,model:this.model,flowchartCreatedEntitiesData:this.options.flowchartCreatedEntitiesData,readOnly:this.readOnly}).then(t=>{t.render(),this.listenTo(t,"change",()=>{this.trigger("change")})}),this.readOnly&&!this.model.attributes.conditionsFormula||this.createView("conditionsFormula","views/fields/formula",{name:"conditionsFormula",model:this.model,mode:this.readOnly?"detail":"edit",height:36,smallFont:!0,selector:".formula-conditions",inlineEditDisabled:!0,targetEntityType:this.entityType}).then(t=>{t.render(),this.listenTo(t,"change",()=>{this.trigger("change")})})}getGroupAllView(){return this.getView("groupAll")}getGroupAnyView(){return this.getView("groupAny")}getFormulaView(){return this.getView("conditionsFormula")}fetch(){if(!this.hasView("conditionsFormula"))return null;const t={all:[],any:[]};return this.getGroupAllView()&&(t.all=this.getGroupAllView().fetch()),this.getGroupAnyView()?t.any=this.getGroupAnyView().fetch():t.any=null,this.getFormulaView()&&(t.formula=(this.getFormulaView().fetch()||{}).conditionsFormula),t}}t.default=s}),define("modules/advanced/views/workflow/record/actions",["exports","view"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{template="advanced:workflow/record/actions";actionsAreReady=!1;data(){return{actionTypeList:this.actionTypeList,entityType:this.entityType,readOnly:this.readOnly,showNoData:this.readOnly&&!(this.model.get("actions")||[]).length}}removeAction(t){const e=this.$el.find(`[data-id="${t}"]`);this.clearView(`action-${t}`),e.parent().remove(),this.trigger("change")}setup(){if(this.addActionHandler("showAddAction",()=>{this.createView("modal","advanced:views/workflow/modals/add-action",{scope:this.entityType,actionList:this.actionTypeList},t=>{t.render(),this.listenToOnce(t,"add",t=>{this.clearView("modal"),this.addAction(t,null,!0)})})}),this.addActionHandler("addAction",(t,e)=>{const i=e.dataset.type;this.addAction(i,null,!0)}),this.addActionHandler("removeAction",(t,e)=>{this.confirm(this.translate("Are you sure?"),()=>{const t=e.dataset.id;this.removeAction(t)})}),this.readOnly=this.options.readOnly||!1,this.entityType=this.options.entityType||this.model.get("entityType"),this.lastCid=0,this.actionTypeList=this.getMetadata().get(["entityDefs","Workflow","actionList"])||[],this.actionTypeList=Espo.Utils.clone(this.actionTypeList),this.actionTypeList=Espo.Utils.clone(this.options.actionTypeList||this.actionTypeList),!this.getMetadata().get(["entityDefs",this.entityType,"fields","assignedUser"])){let t=-1;this.actionTypeList.forEach((e,i)=>{"applyAssignmentRule"===e&&(t=i)}),~t&&this.actionTypeList.splice(t,1)}}afterRender(){this.actionsAreReady=!1;const t=[];if(Espo.Utils.cloneDeep(this.model.attributes.actions??[]).forEach(e=>{if(!(e=e||{}).type)return;const i=this.addAction(e.type,e);t.push(i)}),Promise.all(t).then(()=>{this.actionsAreReady=!0}),!this.readOnly){const t=this.$el.find(".actions");t.sortable({handle:".drag-handle",axis:"y",cursor:"grabbing",stop:()=>{this.trigger("change"),t.children().css({position:"",top:"",left:""})},start:(t,e)=>{e.placeholder.height(e.helper.outerHeight())}})}}addAction(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e=e||{};const s=this.$el.find(".actions"),a=e.cid=this.lastCid;this.lastCid++;let n=e.id;i&&(e.id=n=Math.random().toString(36).substr(2,10));const o=this.getHelper().escapeString(a),r='<div class="clearfix list-group-item">'+(this.readOnly?"":'<a role="button" tabindex="0" class="pull-right" data-action="removeAction" data-id="'+o+'"><span class="fas fa-times"></span></a>')+'<div class="workflow-action" data-id="'+o+'"></div></div>';s.append($(r)),i&&!this.readOnly&&s.sortable("refresh");const l=`advanced:views/workflow/actions/${Espo.Utils.camelCaseToHyphen(t)}`;return this.createView(`action-${a}`,l,{selector:`.workflow-action[data-id="${a}"]`,actionData:e,model:this.model,entityType:this.entityType,actionType:t,id:a,actionId:n,isNew:i,readOnly:this.readOnly,flowchartElementId:this.options.flowchartElementId,flowchartCreatedEntitiesData:this.options.flowchartCreatedEntitiesData},t=>{t.render(()=>{i&&t.edit(!0)}),this.listenTo(t,"change",()=>{this.trigger("change")})})}fetch(){if(!this.actionsAreReady)return null;const t=this.element.querySelectorAll(".actions .workflow-action");if(!t)return[];const e=[];return t.forEach(t=>{let i=t.dataset.id??null;if(null==i)return;i=parseInt(i);const s=this.getView("action-"+i);s&&e.push(s.fetch())}),e}}t.default=s}),define("advanced:views/workflow/field-definitions/base",["view","model"],function(t,e){return t.extend({template:"advanced:workflow/field-definitions/base",defaultFieldData:{subjectType:"value",attributes:{}},subjectTypeList:["value","field"],data:function(){return{subjectTypeList:this.subjectTypeList,subjectTypeValue:this.fieldData.subjectType,readOnly:this.readOnly,hasActionType:!!this.actionTypeList}},setup:function(){if(this.scope=this.options.scope,this.entityType=this.options.entityType,this.field=this.options.field,this.readOnly=this.options.readOnly,this.fieldType=this.model.getFieldType(this.field)||"base",this.fieldData=this.options.fieldData||{},this.actionTypeList=this.getMetadata().get(`entityDefs.Workflow.fieldTypeActions.${this.fieldType}`),this.options.isNew){const t={};for(const e in this.defaultFieldData)t[e]=Espo.Utils.clone(this.defaultFieldData[e]);this.fieldData=_.extend(t,this.fieldData),this.actionTypeList&&(this.fieldData.actionType=this.actionTypeList[0])}this.readOnly||(this.formModel=new e,this.formModel.name="Dummy",this.formModel.set({subjectType:this.fieldData.subjectType}),this.actionTypeList&&this.formModel.set({actionType:this.fieldData.actionType}),this.createView("subjectTypeField","views/fields/enum",{name:"subjectType",selector:'[data-field="subjectType"]',model:this.formModel,mode:"edit",params:{options:this.subjectTypeList},translatedOptions:this.getSubjectTranslatedOptions()}),this.actionTypeList&&this.createView("actionTypeField","views/fields/enum",{name:"actionType",selector:'[data-field="actionType"]',model:this.formModel,mode:"edit",params:{options:this.actionTypeList},translatedOptions:{add:this.translate("Add"),remove:this.translate("Remove"),update:this.translate("Update")}}),this.listenTo(this.formModel,"change:subjectType",()=>{this.fieldData.subjectType=this.formModel.attributes.subjectType,this.handleSubjectType()}))},getSubjectTranslatedOptions:function(){return this.subjectTypeList.reduce((t,e)=>(t[e]=Espo.Utils.upperCaseFirst(this.getLanguage().translateOption(e,"subjectType","Workflow")),t),{})},afterRender:function(){this.handleSubjectType()},handleSubjectType:function(){const t=this.fieldData.subjectType;if("field"===t&&this.createView("subject","advanced:views/workflow/action-fields/subjects/field",{selector:".subject",model:this.model,entityType:this.entityType,scope:this.scope,field:this.field,value:this.fieldData.field,readOnly:this.readOnly},t=>{t.render()}),"value"===t){const t=this.getFieldViewName();this.createView("subject",t,{selector:".subject",model:this.model,name:this.field,mode:"edit",readOnly:this.readOnly,readOnlyDisabled:!0},t=>{t.render()})}},getFieldViewName:function(){return this.getMetadata().get(`entityDefs.Workflow.fieldDefinitionsFieldViews.${this.fieldType}`)||this.model.getFieldParam(this.field,"view")||this.getFieldManager().getViewName(this.fieldType)},fetch:function(){return this.fieldData.attributes={},this.actionTypeList&&(this.fieldData.actionType=this.formModel.attributes.actionType),"value"===this.fieldData.subjectType?(this.getView("subject").fetchToModel(),!this.getView("subject").validate()&&(this.fieldData.attributes=this.getView("subject").fetch(),!0)):("field"===this.fieldData.subjectType&&(this.fieldData.field=this.getView("subject").fetchValue()),!0)}})}),define("advanced:views/workflow/conditions/link-multiple",["advanced:views/workflow/conditions/base"],function(t){return t.extend({template:"advanced:workflow/conditions/base",defaultConditionData:{comparison:"notEmpty"},comparisonList:["notEmpty","isEmpty","has","notHas","changed","notChanged"],data:function(){return _.extend({},t.prototype.data.call(this))},getSubjectInputViewName:function(t){return"advanced:views/workflow/condition-fields/subjects/link"}})}),define("advanced:views/workflow/conditions/float",["advanced:views/workflow/conditions/int"],function(t){return t.extend({template:"advanced:workflow/conditions/base",comparisonList:["equals","notEquals","greaterThan","lessThan","greaterThanOrEquals","lessThanOrEquals","wasEqual","wasNotEqual","isEmpty","notEmpty","changed","notChanged"],fetchSubject:function(){switch(delete this.conditionData.value,delete this.conditionData.field,this.conditionData.subjectType){case"field":this.fetchSubjectField();break;case"value":const t=this.getView("subject");t&&(this.conditionData.value=t.fetch().value)}},getSubjectInputViewName:function(){return"advanced:views/workflow/condition-fields/subjects/float"}})}),define("advanced:views/workflow/condition-fields/subject-type",["view","model"],function(t,e){return t.extend({template:"advanced:workflow/condition-fields/subject-type",list:["value","field"],data:function(){return{value:this.options.value,list:this.list,readOnly:this.options.readOnly}},setup:function(){this.readOnly=this.options.readOnly,this.formModel=new e,this.formModel.name="Dummy",this.readOnly||(this.formModel.set({value:this.options.value||this.list[0]}),this.createView("valueField","views/fields/enum",{selector:'[data-field="value"]',name:"value",model:this.formModel,mode:"edit",params:{options:this.list,translation:"Workflow.options.subjectType"}}),this.listenTo(this.formModel,"change:value",()=>{this.trigger("change",this.formModel.attributes.value)}))},afterRender:function(){this.$el.find(".selectize-control").addClass("input-sm")},fetchValue:function(){return this.formModel.attributes.value}})}),define("advanced:views/workflow/actions/relate-with-entity",["advanced:views/workflow/actions/base","model"],function(t,e){return t.extend({template:"advanced:workflow/actions/relate-with-entity",type:"relateWithEntity",data:function(){let e=t.prototype.data.call(this);return e.linkTranslated=this.translate(this.actionData.link,"links",this.entityType),e},defaultActionData:{link:null},additionalSetup:function(){t.prototype.additionalSetup.call(this),this.actionData.link&&(this.foreignEntityType=this.getMetadata().get("entityDefs."+this.entityType+".links."+this.actionData.link+".entity")),this.model=new e,this.model.set({entityId:this.actionData.entityId,entityName:this.actionData.entityName})},afterRender:function(){t.prototype.afterRender.call(this),this.actionData.entityId&&this.createView("entity","views/fields/link",{selector:' .field[data-name="entity"]',foreignScope:this.foreignEntityType,name:"entity",model:this.model,mode:"detail",readOnly:!0},t=>{t.render()})}})}),define("advanced:views/workflow/action-modals/update-entity",["advanced:views/workflow/action-modals/base","advanced:views/workflow/action-modals/create-entity","model"],function(t,e,i){return t.extend({template:"advanced:workflow/action-modals/update-entity",data:function(){return _.extend({scope:this.scope},t.prototype.data.call(this))},events:{'click [data-action="removeField"]':function(t){const e=$(t.currentTarget),i=e.data("field");this.clearView("field-"+i),delete this.actionData.fields[i];const s=this.actionData.fieldList.indexOf(i);this.actionData.fieldList.splice(s,1),e.parent().remove()}},afterRender:function(){t.prototype.afterRender.call(this),this.$fieldDefinitions=this.$el.find(".field-definitions"),this.$formulaCell=this.$el.find('.cell[data-name="formula"]'),(this.actionData.fieldList||[]).forEach(function(t){this.addField(t,this.actionData.fields[t])},this),this.hasFormulaAvailable?this.$formulaCell.removeClass("hidden"):this.$formulaCell.addClass("hidden"),this.setupFormulaView()},setupFormulaView:function(){const t=new i,e=this.element.querySelector('[data-name="formula"] .field-info');e&&e.parentNode.removeChild(e),this.hasFormulaAvailable&&(t.set("formula",this.actionData.formula||null),this.createView("formula","views/fields/formula",{name:"formula",model:t,mode:this.readOnly?"detail":"edit",height:100,selector:' .field[data-name="formula"]',inlineEditDisabled:!0,targetEntityType:this.scope,params:{tooltip:!0},tooltipText:this.translate("createEntityFormula","tooltips","Workflow")},t=>{t.render()}))},setupScope:function(t){const e=this.entityType;this.scope=e,this.getModelFactory().create(e,e=>{this.model=e,(this.actionData.fieldList||[]).forEach(t=>{const i=(this.actionData.fields[t]||{}).attributes||{};e.set(i,{silent:!0})}),t()})},setup:function(){t.prototype.setup.call(this),this.hasFormulaAvailable=!!this.getMetadata().get("app.formula.functionList"),this.wait(!0),this.setupScope(()=>{this.createView("addField","advanced:views/workflow/action-fields/add-field",{selector:".add-field-container",scope:this.scope,fieldList:this.getFieldList(),addedFieldList:this.actionData.fieldList,onAdd:t=>{this.actionData.fieldList.includes(t)||(this.actionData.fieldList.push(t),this.actionData.fields[t]={},this.addField(t,!1,!0))}},t=>{t.render()}),this.wait(!1)})},addField:function(t,e,i){const s=this.getMetadata().get(`entityDefs.${this.scope}.fields.${t}.type`)||"base",a=this.getMetadata().get("entityDefs.Workflow.fieldDefinitions."+s)||"base";e=e||!1;const n=this.getHelper().escapeString(t),o='<div class="margin clearfix field-row" data-field="'+n+'" style="margin-left: 20px;">'+('<a role="button" tabindex="0" class="pull-right" data-action="removeField" data-field="'+n+'"><span class="fas fa-times"></span></a>')+("<label>"+this.translate(n,"fields",this.scope)+"</label>")+'<div class="field-container field" data-field="'+n+'"></div></div>';this.$fieldDefinitions.append($(o)),this.createView("field-"+t,"advanced:views/workflow/field-definitions/"+Espo.Utils.camelCaseToHyphen(a),{selector:' .field-container[data-field="'+t+'"]',fieldData:e,model:this.model,field:t,entityType:this.entityType,scope:this.scope,type:a,fieldType:s,isNew:i},t=>{t.render()})},getFieldList:function(){return e.prototype.getFieldList.call(this)},fetch:function(){let t=!0;if((this.actionData.fieldList||[]).forEach(e=>{t=this.getView("field-"+e).fetch(),this.actionData.fields[e]=this.getView("field-"+e).fieldData}),this.hasFormulaAvailable){const t=this.getView("formula");t&&(this.actionData.formula=t.fetch().formula)}return t}})}),define("advanced:views/workflow/action-modals/relate-with-entity",["advanced:views/workflow/action-modals/base","model"],function(t,e){return t.extend({template:"advanced:workflow/action-modals/relate-with-entity",setup:function(){t.prototype.setup.call(this),this.setupScope(),this.model=new e,this.model.set("entityId",this.actionData.entityId||null),this.model.set("entityName",this.actionData.entityName||null);const i=this.actionModel=new e;i.name="Workflow",this.actionModel.set({link:this.actionData.link});const s=this.getLinkOptions();this.createView("link","views/fields/enum",{name:"link",model:i,mode:"edit",selector:'.field[data-name="link"]',params:{options:s.map(t=>t[0]),required:!0},translatedOptions:Object.fromEntries(s),labelText:this.translate("Field")}),this.listenTo(i,"change:link",()=>this.changeLinkAction())},getLinkOptions:function(){const t=[[""]];return Object.keys(this.getMetadata().get(`entityDefs.${this.entityType}.links`)||[]).sort((t,e)=>this.translate(t,"links",this.scope).localeCompare(this.translate(e,"links",this.scope))).forEach(e=>{const i=this.getMetadata().get(`entityDefs.${this.entityType}.links.${e}`)||{};if(i.disabled)return;if("hasMany"!==i.type&&"hasChildren"!==i.type)return;const s=this.translate(e,"links",this.entityType);t.push([e,s])}),t},afterRender:function(){t.prototype.afterRender.call(this),this.actionData.link&&this.createEntityLinkField()},changeLinkAction:function(){this.actionData.link=this.actionModel.attributes.link,this.actionData.link||(this.actionData.link=null),this.setupScope(),this.actionData.link&&this.createEntityLinkField(),this.model.set({entityId:null,entityName:null})},createEntityLinkField:function(){this.createView("entity","views/fields/link",{selector:'.field[data-name="entity"]',foreignScope:this.scope,name:"entity",model:this.model,mode:"edit"},t=>{t.render()})},setupScope:function(){if(this.actionData.link){if(this.scope=this.getMetadata().get(`entityDefs.${this.entityType}.links.${this.actionData.link}.entity`),!this.scope)throw new Error}else this.scope=null},fetch:function(){let t=!1;return this.getView("link")&&this.getView("link").validate()&&(t=!0),!t&&(this.actionData.link=this.actionModel.attributes.link,!!this.actionData.link&&(this.actionData.entityId=this.model.get("entityId"),this.actionData.entityName=this.model.get("entityName"),!!this.actionData.entityId))}})}),define("advanced:views/workflow/action-modals/make-followed",["advanced:views/workflow/action-modals/base","model"],function(t,e){return t.extend({template:"advanced:workflow/action-modals/make-followed",data:function(){return _.extend({},t.prototype.data.call(this))},events:{'change select[data-name="recipient"]':function(t){this.actionData.recipient=t.currentTarget.value,this.handleRecipient()}},afterRender:function(){t.prototype.afterRender.call(this),this.handleRecipient()},setModel:function(){this.model.set({usersToMakeToFollowIds:this.actionData.userIdList,usersToMakeToFollowNames:this.actionData.userNames,whatToFollow:this.actionData.whatToFollow,recipient:this.actionData.recipient||"specifiedUsers",specifiedTeamsIds:this.actionData.specifiedTeamsIds,specifiedTeamsNames:this.actionData.specifiedTeamsNames})},setup:function(){t.prototype.setup.call(this),this.actionData.recipient||(this.actionData.recipient="specifiedUsers"),this.actionData.whatToFollow&&"targetEntity"!==this.actionData.whatToFollow&&0!==this.actionData.whatToFollow.indexOf("link:")&&(this.actionData.whatToFollow="link:"+this.actionData.whatToFollow);var i=this.model=new e;i.name="Workflow",this.setModel(),this.on("apply-change",function(){this.setModel()},this),this.setupRecipientOptions(),this.setupWhatToFollowOptions(),this.createView("recipient","views/fields/enum",{mode:"edit",model:i,selector:'.field[data-name="recipient"]',defs:{name:"recipient",params:{options:this.recipientOptionList,required:!0,translatedOptions:this.recipientTranslatedOptions}},readOnly:this.readOnly}),this.createView("whatToFollow","views/fields/enum",{mode:"edit",model:i,selector:'.field[data-name="whatToFollow"]',defs:{name:"whatToFollow",params:{options:this.targetOptionList,required:!0,translatedOptions:this.targetTranslatedOptions}},readOnly:this.readOnly}),this.createView("usersToMakeToFollow","views/fields/link-multiple",{mode:"edit",model:i,selector:'.field[data-name="usersToMakeToFollow"]',foreignScope:"User",defs:{name:"usersToMakeToFollow"},readOnly:this.readOnly}),this.createView("specifiedTeams","views/fields/link-multiple",{selector:'.field[data-name="specifiedTeams"]',model:i,mode:"edit",foreignScope:"Team",defs:{name:"specifiedTeams"},readOnly:this.readOnly})},handleRecipient:function(){"specifiedUsers"===this.actionData.recipient?this.$el.find('.cell[data-name="usersToMakeToFollow"]').removeClass("hidden"):this.$el.find('.cell[data-name="usersToMakeToFollow"]').addClass("hidden"),"specifiedTeams"===this.actionData.recipient?this.$el.find('.cell[data-name="specifiedTeams"]').removeClass("hidden"):this.$el.find('.cell[data-name="specifiedTeams"]').addClass("hidden")},fetch:function(){if(this.getView("whatToFollow").fetchToModel(),!this.getView("whatToFollow").validate()){if(this.actionData.userIdList=(this.getView("usersToMakeToFollow").fetch()||{}).usersToMakeToFollowIds,this.actionData.userNames=(this.getView("usersToMakeToFollow").fetch()||{}).usersToMakeToFollowNames,this.actionData.whatToFollow=this.getView("whatToFollow").fetch().whatToFollow,this.actionData.recipient=(this.getView("recipient").fetch()||{}).recipient,this.actionData.specifiedTeamsIds=[],this.actionData.specifiedTeamsNames={},"specifiedTeams"===this.actionData.recipient){var t=this.getView("specifiedTeams").fetch()||{};this.actionData.specifiedTeamsIds=t.specifiedTeamsIds,this.actionData.specifiedTeamsNames=t.specifiedTeamsNames}return!0}},translateCreatedEntityAlias:function(t,e){var i=t;if(0===t.indexOf("created:")&&(i=t.substr(8)),!this.options.flowchartCreatedEntitiesData[i])return t;var s=this.options.flowchartCreatedEntitiesData[i].link,a=this.options.flowchartCreatedEntitiesData[i].entityType,n=this.options.flowchartCreatedEntitiesData[i].numberId,o=this.translate("Created","labels","Workflow")+" · ",r='<span class="chevron-right"></span>';return e&&(r="-"),s&&(o+=this.translate(s,"links",this.entityType)+" "+r+" "),o+=this.translate(a,"scopeNames"),n&&(o+=" #"+n.toString()),o},setupWhatToFollowOptions:function(){const t=[""],e={targetEntity:this.translate("Target Entity","labels","Workflow")+" · "+this.translate(this.entityType,"scopeNames")};this.getMetadata().get(`scopes.${this.entityType}.stream`)&&t.push("targetEntity");const i=this.getMetadata().get(`entityDefs.${this.entityType}.links`)||{};Object.keys(i).forEach(function(s){const a=i[s].type;"belongsTo"!==a&&"belongsToParent"!==a||("belongsTo"!==a||this.getMetadata().get(`scopes.${i[s].entity}.stream`))&&(t.push("link:"+s),e["link:"+s]=this.translate("Related","labels","Workflow")+" · "+this.getLanguage().translate(s,"links",this.entityType))},this),this.options.flowchartCreatedEntitiesData&&Object.keys(this.options.flowchartCreatedEntitiesData).forEach(function(i){const s=this.options.flowchartCreatedEntitiesData[i].entityType;this.getMetadata().get(["scopes",s,"stream"])&&(t.push("created:"+i),e["created:"+i]=this.translateCreatedEntityAlias(i,!0))},this),this.targetOptionList=t,this.targetTranslatedOptions=e},setupRecipientOptions:function(){this.recipientOptionList=["specifiedUsers","teamUsers","specifiedTeams","followers"],this.options.flowchartCreatedEntitiesData||this.recipientOptionList.push("currentUser");const t=this.getMetadata().get(`entityDefs.${this.entityType}.links`)||{};Object.keys(t).forEach(e=>{if("belongsTo"===t[e].type||"hasMany"===t[e].type){const i=t[e].entity;if(!i)return;if("hasMany"===t[e].type&&"linkMultiple"!==this.getMetadata().get(["entityDefs",this.entityType,"fields",e,"type"]))return;if("User"!==i)return;this.recipientOptionList.push("link:"+e)}}),Object.keys(t).forEach(e=>{if("belongsTo"!==t[e].type)return;const i=this.getMetadata().get(["entityDefs",this.entityType,"links",e,"entity"]);if(!i)return;if("User"===i)return;this.getMetadata().get(["scopes",i,"stream"])&&this.recipientOptionList.push("link:"+e+".followers");const s=this.getMetadata().get(`entityDefs.${i}.links`)||{};Object.keys(s).forEach(t=>{const i=s[t].entity;("belongsTo"!==s[t].type&&"hasMany"!==s[t].type||i)&&("hasMany"===s[t].type&&"linkMultiple"!==this.getMetadata().get(["entityDefs",i,"fields",t,"type"])||"User"===i&&this.recipientOptionList.push(`link:${e}.${t}`))})}),this.recipientTranslatedOptions={},this.recipientOptionList.forEach(function(t){this.recipientTranslatedOptions[t]=this.translateRecipientOption(t)},this)},translateRecipientOption:function(t){if(t&&0===t.indexOf("link:")){let e=t.substring(5);if(~e.indexOf(".")){const t=e.split(".");e=t[0];const i=t[1];if("followers"===i)return this.translate("Related","labels","Workflow")+" · "+this.translate(e,"links",this.entityType)+" . "+this.translate("Followers");const s=this.getMetadata().get(["entityDefs",this.entityType,"links",e,"entity"]);return this.translate("Related","labels","Workflow")+" · "+this.translate(e,"links",this.entityType)+" . "+this.translate(i,"links",s)}return this.translate("Related","labels","Workflow")+" · "+this.translate(e,"links",this.entityType)}let e=this.translate(t,"emailAddressOptions","Workflow");return"targetEntity"===t&&(e+=" · "+this.translate(this.entityType,"scopeNames")),e}})}),define("modules/advanced/views/report-panel/record/panels/report-panel-side",["exports","views/record/panels/side","modules/advanced/views/dashlets/report","modules/advanced/report-helper","di","modules/advanced/helpers/report/sub-report-helper","modules/advanced/views/report/modals/sub-report"],function(t,e,i,s,a,n,o){"use strict";let r,l;function d(t){return t&&t.__esModule?t:{default:t}}function c(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function h(t,e,i){"symbol"==typeof e&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch(t){}return t}function u(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(null!==t?typeof t:"null"));return t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=d(e),i=d(i),s=d(s),n=d(n),o=d(o);class p extends e.default{static#t=[r,l]=function(t,e,i,s,a,n){var o,r,l,d,p,f,m,g=Symbol.metadata||Symbol.for("Symbol.metadata"),y=Object.defineProperty,w=Object.create,v=[w(null),w(null)],b=e.length;function T(e,i,s){return function(a,n){i&&(n=a,a=t);for(var o=0;o<e.length;o++)n=e[o].apply(a,s?[n]:[]);return s?n:a}}function D(t,e,i,s){if("function"!=typeof t&&(s||void 0!==t))throw new TypeError(e+" must "+(i||"be")+" a function"+(s?"":" or undefined"));return t}function k(t,e,i,s,a,n,l,d,c,u,p){function f(t){if(!p(t))throw new TypeError("Attempted to access private element on non-instance")}var m=[].concat(e[0]),g=e[3],w=!l,b=1===a,k=3===a,E=4===a,C=2===a;function x(e,i,s){return function(a,n){return i&&(n=a,a=t),s&&s(a),O[e].call(a,n)}}if(!w){var O={},L=[],M=k?"get":E||b?"set":"value";if(c?(u||b?O={get:h(function(){return g(this)},s,"get"),set:function(t){e[4](this,t)}}:O[M]=g,u||h(O[M],s,C?"":M)):u||(O=Object.getOwnPropertyDescriptor(t,s)),!u&&!c){if((r=v[+d][s])&&7!=(r^a))throw Error("Decorating two elements with the same name ("+O[M].name+") is not supported yet");v[+d][s]=a<3?1:a}}for(var F=t,S=m.length-1;S>=0;S-=i?2:1){var V=D(m[S],"A decorator","be",!0),R=i?m[S-1]:void 0,$={},I={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:o,addInitializer:function(t,e){if(t.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(e,"An initializer","be",!0),n.push(e)}.bind(null,$)};if(w)r=V.call(R,F,I),$.v=1,D(r,"class decorators","return")&&(F=r);else if(I.static=d,I.private=c,r=I.access={has:c?p.bind():function(t){return s in t}},E||(r.get=c?C?function(t){return f(t),O.value}:x("get",0,f):function(t){return t[s]}),C||k||(r.set=c?x("set",0,f):function(t,e){t[s]=e}),F=V.call(R,b?{get:O.get,set:O.set}:O[M],I),$.v=1,b){if("object"==typeof F&&F)(r=D(F.get,"accessor.get"))&&(O.get=r),(r=D(F.set,"accessor.set"))&&(O.set=r),(r=D(F.init,"accessor.init"))&&L.unshift(r);else if(void 0!==F)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(F,(u?"field":"method")+" decorators","return")&&(u?L.unshift(F):O[M]=F)}return a<2&&l.push(T(L,d,1),T(n,d,0)),u||w||(c?b?l.splice(-1,0,x("get",d),x("set",d)):l.push(C?O[M]:D.call.bind(O[M])):y(t,s,O)),F}function E(t){return y(t,g,{configurable:!0,enumerable:!0,value:o})}return void 0!==n&&(o=n[g]),o=w(null==o?null:o),p=[],f=function(t){t&&p.push(T(t))},(m=function(e,s){for(var n=0;n<i.length;n++){var o=i[n],r=o[1],h=7&r;if((8&r)==e&&!h==s){var f=o[2],m=!!o[3],g=16&r;k(e?t:t.prototype,o,g,m?"#"+f:c(f),h,h<2?[]:e?d=d||[]:l=l||[],p,!!e,m,s,e&&m?function(e){return u(e)===t}:a)}}})(8,0),m(0,0),m(8,1),m(0,1),f(l),f(d),r=p,b||E(t),{e:r,get c(){var i=[];return b&&[E(t=k(t,[e],s,t.name,5,i)),T(i,1)]}}}(this,[],[[(0,a.inject)(n.default),0,"subReportHelper"]],0,void 0,e.default).e;constructor(){super(...arguments),l(this)}templateContent='<div class="report-results-container"></div>';isPanel=!0;totalFontSizeMultiplier=1.3;totalLineHeightMultiplier=1.1;totalMarginMultiplier=.4;totalOnlyFontSizeMultiplier=3;totalLabelMultiplier=.7;total2LabelMultiplier=.5;defaultHeight=250;rowActionsView="views/record/row-actions/view-only";subReportHelper=r(this);setup(){super.setup(),this.collectionMaxSize=this.getConfig().get("recordsPerPageSmall"),this.reportHelper=new s.default(this.getMetadata(),this.getLanguage(),this.getDateTime(),this.getConfig(),this.getPreferences())}getOption(t){return"entityType"===t?this.defs.reportEntityType:"type"===t?this.defs.reportType:"displayOnlyCount"===t?this.defs.displayOnlyTotal:"displayTotal"===t?this.defs.displayTotal:"reportId"===t?this.defs.reportPanelId:"column"===t?this.defs.column:"title"===t?this.defs.title:"useSiMultiplier"===t?this.defs.useSiMultiplier:"displayType"===t?this.defs.displayType:void 0}getListLayout(){return i.default.prototype.getListLayout.call(this)}getContainerTotalHeight(t){return i.default.prototype.getContainerTotalHeight.call(this,t)}displayTable(t,e){return i.default.prototype.displayTable.call(this,t,e)}displayTotal(t,e){return i.default.prototype.displayTotal.call(this,t,e)}displayError(t){return i.default.prototype.displayError.call(this,t)}controlTotalTextOverflow(){return i.default.prototype.controlTotalTextOverflow.call(this)}_isHidden(){const t=this.defs||{},e=this.getParentView();if(e&&e.hasTabs&&e.currentTab!==t.tabNumber)return!0;const i=t.name;return!!i&&!!this.recordHelper.getPanelStateParam(i,"hidden")}async showSubReport(t,e,i,s,a,n){const r=this.getOption("reportId");let l=this.getOption("entityType"),d=e.subReportSwitchDataList;if(d){const t=d.find(t=>t.name===n)??d[0];n=t.name,l=t.entityType}let c=null;e.isJoint&&(n??=e.columnList[0],c=e.columnReportIdMap[n],l=e.columnEntityTypeMap[n],d=this.subReportHelper.prepareSwitchDataList(e));const h=await this.subReportHelper.createCollection({entityType:l,reportId:r,groupIndex:s,groupValue:i,groupValue2:a,parent:this.model,target:n});e.isJoint&&(h.url+="&subReportId="+c),Espo.Ui.notify(" ... ");const u=new o.default({reportId:r,reportName:this.getOption("title"),result:e,groupValue:i,groupIndex:s,groupValue2:a,collection:h,column:n,switchDataList:d,target:n,onSwitchSubReport:n=>{u.close(),this.showSubReport(t,e,i,s,a,n)}});await this.assignView("dialog",u),Espo.Ui.notify(),await u.render()}actionRefresh(){const t=this.element;t&&(t.style.minHeight=t.clientHeight+"px"),this.$totalContainer&&this.$totalContainer.remove(),this.hasView("reportChart")&&this.clearView("reportChart"),Espo.Ui.notify(" ... "),this.run().then(()=>{Espo.Ui.notify(!1),t&&(t.style.minHeight="")})}afterRender(){this.$container=this.$el.find(".report-results-container"),this.run(),"List"===this.getOption("type")&&this.$container.addClass("list-container")}getCollectionUrl(){return"ReportPanel/action/runList?id="+this.defs.reportPanelId+"&parentType="+this.model.name+"&parentId="+this.model.id}getGridReportUrl(){return"ReportPanel/action/runGrid"}getGridReportRequestData(){return{id:this.defs.reportPanelId,parentType:this.model.name,parentId:this.model.id}}run(){return i.default.prototype.run.call(this)}setContainerHeight(){"List"===this.getOption("type")?this.$container.css("height","auto"):this.$container.css("height","100%")}}t.default=p}),define("modules/advanced/views/report/reports/grid1",["exports","modules/advanced/views/report/reports/base"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{setup(){this.initReport()}export(){const t=this.getRuntimeFilters(),e={scope:this.model.attributes.entityType,reportType:"Grid"};let i;const s={id:this.model.id,where:t};this.createView("dialogExport","advanced:views/report/modals/export-grid",e,e=>{e.render(),this.listenToOnce(e,"proceed",e=>{s.where=t,"csv"===e.format?i="Report/action/exportGridCsv":"xlsx"===e.format&&(i="Report/action/exportGridXlsx"),Espo.Ui.notify(" ... "),Espo.Ajax.postRequest(i,s,{timeout:0}).then(t=>{Espo.Ui.notify(!1),"id"in t&&(window.location=this.getBasePath()+"?entryPoint=download&id="+t.id)})})})}async run(){Espo.Ui.notify(" ... ");const t=this.$el.find(".report-results-container");t.empty();const e=this.getRuntimeFilters();let i;const s=this.isPreview?this.model.attributes:null;i=this.isPreview?await Espo.Ajax.postRequest("Report/runGridPreview",{where:e,data:s},{timeout:0}):await Espo.Ajax.getRequest("Report/action/run",{id:this.model.id,where:e,data:s},{timeout:0}),Espo.Ui.notify(!1),this.result=i;const a=i.chartType??this.model.attributes.chartType;this.storeRuntimeFilters();const n=$("<div>").addClass("report-table").addClass("section");let o;if(this.options.showChartFirst||t.append(n),a){const e=this.options.isLargeMode?"h4":"h5",s=this.options.isLargeMode?60:0;o=this.options.reportHelper.getChartColumnGroupList(i),o.forEach((a,n)=>{let o=a.column;!o&&a.columnList&&1===a.columnList.length&&(o=a.columnList[0]);const r=$("<div>").addClass("section").addClass("column-"+n);if(o){const t=$("<"+e+">").css("marginBottom","25px").html(this.options.reportHelper.formatColumn(o,i));s&&n&&t.css("marginTop",s),r.append(t)}const l=$("<div>").addClass("section").addClass("report-chart").addClass("report-chart-"+n);r.append(l),t.append(r)})}this.options.showChartFirst&&t.append(n),this.createView("reportTable","advanced:views/report/reports/tables/grid1",{selector:".report-results-container .report-table",result:i,reportHelper:this.options.reportHelper,hasChart:!!a,isLargeMode:this.options.isLargeMode}).then(t=>{t.render()}),this.processInformation(),a&&o.forEach((t,e)=>{const s=t.column,n=t.columnList,o=t.secondColumnList,r="advanced:views/report/reports/charts/grid1"+Espo.Utils.camelCaseToHyphen(a);this.createView("reportChart"+e,r,{selector:`.report-results-container .column-${e} .report-chart`,column:s,columnList:n,secondColumnList:o,result:i,reportHelper:this.options.reportHelper,colors:i.chartColors||{},color:i.chartColor||null}).then(t=>{t.render(),this.listenTo(t,"click-group",(t,e,i,s)=>{this.showSubReport(t,void 0,void 0,s)})})})}processInformation(){this.result.emptyStringGroupExcluded?this.$information.removeClass("hidden").text(this.translate("emptyStringGroupExcluded","messages","Report")):this.$information.addClass("hidden").text("")}}t.default=s}),define("modules/advanced/views/report/reports/tables/grid2-normalized",["exports","view","modules/advanced/views/report/reports/tables/grid2"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{templateContent='\n        <div\n            class="table-container no-side-margin"\n            data-report-type="grid-2-normalized"\n            style="\n                {{#if horizontalScroll}}\n                    overflow-y: auto;\n                {{/if}}\n            "\n        >\n            <table\n                style="\n                    table-layout: fixed;\n                    {{#if minWidth}}\n                        min-width: {{minWidth}};\n                    {{/if}}\n                "\n                class="\n                    table table-no-overflow table-bordered\n                    {{#if noMargin}} no-margin {{/if}}\n                "\n            >\n                <tbody>\n                    {{#each rows}}\n                        <tr\n                            class="\n                                {{#if isAccented}} accented {{/if}}\n                                {{#if isNumeric}} numeric-text {{/if}}\n                            "\n                        >\n                            {{#each columns}}\n                                <{{#if isHead}}th{{else}}td{{/if}}\n                                    {{#if title}} title="{{title}}" {{/if}}\n                                    style="\n                                        {{#if width}}\n                                            width: {{width}};\n                                        {{/if}}\n                                        {{#if isEndAlign}}\n                                            text-align: end;\n                                        {{/if}}\n                                        {{#if isBold}}\n                                            font-weight: 600;\n                                            color: var(--gray-soft);\n                                        {{/if}}\n                                        {{#if isMuted}}\n                                            color: var(--text-muted-color);\n                                        {{/if}}\n                                        overflow-wrap: break-word;\n                                    "\n                                >\n                                {{~#if isLink~}}\n                                    <a\n                                        role="button"\n                                        class="selectable"\n                                        tabindex="0"\n                                        data-action="{{action}}"\n                                        data-group-value="{{groupValue}}"\n                                        {{#if hasSecondGroupValue}}\n                                            data-group-second-value="{{groupSecondValue}}"\n                                        {{/if}}\n                                    >{{value}}</a>\n                                {{~else~}}\n                                    {{value}}\n                                {{~/if~}}\n                                </{{#if isHead}}th{{else}}td{{/if}}>\n                            {{/each}}\n                        </tr>\n                    {{/each}}\n                </tbody>\n            </table>\n        </div>\n    ';result;reportHelper;columnWidthPx=152;nonSummaryColumnWidthPx=170;columnCount;columnCountThreshold=4;constructor(t){super(t),this.options=t}data(){return{rows:this.getRows(),noMargin:this.options.hasChart,minWidth:this.getMinWidthString(),horizontalScroll:this.columnCount>this.columnCountThreshold}}setup(){this.reportHelper=this.options.reportHelper,this.result=this.options.result,this.addActionHandler("showSubReport",(t,e)=>{let i,s=parseInt(e.dataset.groupIndex??0);Object.prototype.hasOwnProperty.call(e.dataset,"groupSecondValue")&&(i=e.dataset.groupSecondValue,s=null),this.trigger("click-group",e.dataset.groupValue,s,i)}),this.columnCount=this.result.summaryColumnList.length+this.result.nonSummaryColumnList.length+2}getRows(){const t=[];{const e=[{value:this.result.groupNameMap[this.result.groupByList[0]],isBold:!0},{value:this.result.groupNameMap[this.result.groupByList[1]],isBold:!0,width:this.nonSummaryColumnWidthPx+"px"}];for(const t of this.result.nonSummaryColumnList)e.push({value:this.result.columnNameMap[t],isBold:!0,width:this.nonSummaryColumnWidthPx+"px"});for(const t of this.result.summaryColumnList)e.push({value:this.result.columnNameMap[t],isBold:!0,width:this.columnWidthPx+"px"});t.push({columns:e,isAccented:!0})}for(const s of this.result.grouping[0])for(const a of this.result.grouping[1]){const n=[];n.push({value:this.formatGroup(0,s),isLink:!0,action:"showSubReport",groupIndex:0,groupValue:s}),n.push({value:this.formatGroup(1,a),isLink:!0,action:"showSubReport",groupValue:s,groupSecondValue:a,hasSecondGroupValue:!0});for(const t of this.result.nonSummaryColumnList){var e;const i=this.result.nonSummaryColumnGroupMap[t],o=i===this.result.groupByList[0]?s:a,r=(null===(e=this.result.nonSummaryData)||void 0===e||null===(e=e[i])||void 0===e||null===(e=e[o])||void 0===e?void 0:e[t])??null,l=this.reportHelper.isColumnNumeric(t,this.result),d=l&&!r;n.push({value:this.formatCellValue(r,t),isNumeric:l,isEndAlign:l,isMuted:d})}let o=!1;for(const t of this.result.summaryColumnList){var i;const e=(null===(i=this.result.reportData[s])||void 0===i||null===(i=i[a])||void 0===i?void 0:i[t])??null;null!=e&&(o=!0),n.push({value:this.formatCellValue(e,t),isNumeric:!0,isEndAlign:!0,isMuted:!e})}o&&t.push({columns:n})}{const e=[{value:this.translate("Total","labels","Report"),isBold:!0},{value:null}];for(const t of this.result.nonSummaryColumnList)e.push({value:null});for(const t of this.result.summaryColumnList){var s;const i=(null===(s=this.result.sums)||void 0===s?void 0:s[t])??0;e.push({value:this.formatCellValue(i,t),isNumeric:!0,isEndAlign:!0,isBold:!0})}t.push({columns:e,isAccented:!0})}return t}formatCellValue(t,e){return this.options.reportHelper.isColumnNumeric(e,this.result)?this.reportHelper.formatCellValue(t,e,this.result):i.default.prototype.formatCellValue.call(this,t,e)}getMinWidthString(){if(this.columnCount<this.columnCountThreshold)return null;return(this.result.summaryColumnList.length*this.columnWidthPx+this.result.nonSummaryColumnList.length*this.nonSummaryColumnWidthPx+2*this.nonSummaryColumnWidthPx).toString()+"px"}formatGroup(t,e){const i=this.result.groupByList[t];return this.reportHelper.formatGroup(i,e,this.result)}unescapeString(t){const e=document.createElement("div");return e.innerHTML=t,e.textContent}}t.default=a}),define("modules/advanced/views/report/reports/charts/grid2bar-horizontal",["exports","modules/advanced/views/report/reports/charts/grid2bar-vertical"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{rowHeight=25;zooming=!1;isGrouped=!1;chartType="barHorizontal";prepareData(){const t=this.result,e=this.firstList=Espo.Utils.clone(t.grouping[0]),i=this.secondList=t.grouping[1];e.reverse(),i.length<=5&&(this.colorList=this.colorListAlt);const s=[];this.max=0,this.min=0,this.sumList=[],e.forEach(e=>{const a={};let n;i.forEach(i=>{if(t.reportData[e]&&t.reportData[e][i]){const s=t.reportData[e][i][this.column]||0;a[i]=s,s>this.max&&(this.max=s),s<this.min&&(this.min=s)}}),s.push(a),n=(t.group1Sums[e]||{})[this.column]||0,this.sumList.push(n)});const a={},n=this.group2Count=i.length;this.isGrouped&&n&&(this.barWidth=1/n*.65);const o=1/n,r=Math.ceil(n/2)-1;i.forEach((t,e)=>{let i=0;if(this.isGrouped){i=o*(e-r),n%2==0&&(i-=o/2),i*=.75}a[t]=[],s.forEach((e,s)=>{a[t].push([e[t]||0,s-i])})});const l=[];i.forEach(t=>{const e={data:a[t],label:this.formatGroup(1,t)};this.result.success&&this.result.success===t&&(e.color=this.successColor),t in this.colors&&(e.color=this.colors[t]),l.push(e)}),this.isGrouped||(this.max=0,this.sumList.length&&(this.max=this.sumList.reduce((t,e)=>Math.max(t,e)))),this.chartData=l}calculateHeight(){let t=this.sumList.length;return this.isGrouped&&this.secondList.length>1&&(t*=.75*this.secondList.length),t*this.rowHeight}getTickNumber(){const t=this.$container.height();return Math.floor(t/this.rowHeight)}draw(){if(0===this.$container.height())return void this.$container.empty();if(this.isNoData())return void this.showNoData();const t=this.getTickNumber();this.$graph=this.flotr.draw(this.$container.get(0),this.chartData,{shadowSize:!1,colors:this.colorList,bars:{show:!0,stacked:!this.isGrouped,horizontal:!0,shadowSize:0,lineWidth:1,fillOpacity:1,barWidth:this.barWidth},grid:{horizontalLines:!1,verticalLines:!0,outline:"sw",color:this.gridColor,tickColor:this.tickColor},yaxis:{min:0,showLabels:!0,color:this.textColor,noTicks:t,title:"&nbsp;",tickFormatter:t=>{if(t%1==0){const e=parseInt(t);if(e in this.firstList)return this.formatGroup(0,this.firstList[e])}return""}},xaxis:{min:this.min+.1*this.min,max:this.max+.1*this.max,color:this.textColor,tickFormatter:t=>{if(0==t&&0==this.min)return"";if(t%1==0){return'<span class="numeric-text">'+this.reportHelper.formatNumber(Math.floor(t),{isCurrency:this.isCurrency,useSiMultiplier:!0,noDecimalPart:!0,no3CharCurrencyFormat:!0,currency:this.result.currency})+"</span>"}return""}},legend:{show:!0,noColumns:this.getLegendColumnNumber(),container:this.$el.find(".legend-container"),labelBoxMargin:0,labelFormatter:this.labelFormatter.bind(this),labelBoxBorderColor:"transparent",backgroundOpacity:0},mouse:{track:!0,relative:!0,position:"w",lineColor:this.hoverColor,autoPositionHorizontal:this.isGrouped,autoPositionVerticalHalf:!this.isGrouped,cursorPointer:!this.result.noSubReport,trackFormatter:t=>{const e=Math.round(t.y),i=this.options.column,s=t.series.data[t.index][0];return this.formatGroup(0,this.firstList[e])+"<br>"+t.series.label+'<br><span class="numeric-text">'+this.formatCellValue(s,i)+"</span>"}}}),this.adjustLegend(),Flotr.EventAdapter.observe(this.$container.get(0),"flotr:click",t=>{t.hit&&"index"in t.hit&&(this.result.noSubReport||this.trigger("click-group",this.firstList[t.hit.index],null,this.secondList[t.hit.seriesIndex]))})}}t.default=s}),define("modules/advanced/views/report/reports/charts/grid1bar-horizontal",["exports","modules/advanced/views/report/reports/charts/grid1bar-vertical"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{noLegend=!0;rowHeight=25;zooming=!1;chartType="barHorizontal";calculateHeight(){let t=this.grList.length;return this.columnList&&this.columnList.length>1&&(t*=this.columnList.length),t*this.rowHeight*this.getFontSizeFactor()}prepareData(){const t=this.result,e=this.grList=Espo.Utils.clone(t.grouping[0]);e.reverse(),this.options.color&&(this.colorList=Espo.Utils.clone(this.colorList),this.colorList[0]=this.options.color);const i=this.columnList=this.columnList||[this.column];let s,a=1;this.columnList&&(this.columnList.length>1&&(this.barWidth=1/this.columnList.length*.65),a=1/this.columnList.length,s=Math.ceil(this.columnList.length/2)-1,this.columnList.length>1&&(this.noLegend=!1));let n=0,o=0,r=0,l=0;const d=[];i.forEach((t,i)=>{const c={data:[],label:this.reportHelper.formatColumn(t,this.result),column:t};let h=0;if(this.columnList){h=a*(i-s),this.columnList.length%2==0&&(h-=a/2),h*=.75,this.secondColumnList&&~this.secondColumnList.indexOf(t)&&(c.xaxis=2)}c.value=0,e.forEach((e,i)=>{const s=(this.result.reportData[e]||{})[t]||0;this.secondColumnList&&~this.secondColumnList.indexOf(t)?(s>o&&(o=s),s<l&&(l=s)):(s>n&&(n=s),s<r&&(r=s)),c.data.push([s,i-h]),c.value+=s}),t in this.colors&&(c.color=this.colors[t]),d.push(c)}),this.max=n,this.max2=o,this.min=r,this.min2=l,this.chartData=d}getTickNumber(){const t=this.$container.height();return Math.floor(t/(this.rowHeight*this.getFontSizeFactor()))}draw(){if(0===this.$container.height())return void this.$container.empty();if(this.isNoData())return void this.showNoData();if(0===this.$container.height())return;const t=this.getTickNumber();this.$graph=this.flotr.draw(this.$container.get(0),this.chartData,{shadowSize:!1,colors:this.colorList,bars:{show:!0,horizontal:!0,shadowSize:0,lineWidth:1,fillOpacity:1,barWidth:this.barWidth},grid:{horizontalLines:!1,verticalLines:!0,outline:"sw",color:this.gridColor,tickColor:this.tickColor},yaxis:{min:0,color:this.textColor,noTicks:t,title:"&nbsp;",tickFormatter:t=>{if(t%1==0){const e=parseInt(t);if(e in this.grList)return this.formatGroup(0,this.grList[e])}return""}},xaxis:{min:this.min+.08*this.min,showLabels:!0,color:this.textColor,max:this.max+.08*this.max,tickFormatter:t=>{if(0==t&&0===this.min)return"";if(t%1==0){if(t>this.max+.05*this.max)return"";return'<span class="numeric-text">'+this.reportHelper.formatNumber(Math.floor(t),{isCurrency:this.isCurrency,useSiMultiplier:!0,noDecimalPart:!0,no3CharCurrencyFormat:!0,currency:this.result.currency})+"</span>"}return""}},x2axis:{min:this.min2+.08*this.min2,showLabels:!1,color:this.textColor,max:this.max2+.08*this.max2,tickFormatter:t=>0==t&&0===this.min2?"":t%1==0?t>this.max2+.05*this.max2?"":this.reportHelper.formatNumber(Math.floor(t),{useSiMultiplier:!0,noDecimalPart:!0}):""},mouse:{track:!0,relative:!0,position:"w",autoPositionHorizontal:!0,lineColor:this.hoverColor,cursorPointer:!this.result.noSubReport,trackFormatter:t=>{const e=t.index,i=t.series.column;let s=this.formatGroup(0,this.grList[e]);return this.columnList&&(s&&(s+="<br>"),s+=t.series.label),s&&(s+="<br>"),s+=this.formatCellValue(t.x,i),s}},legend:{show:!this.noLegend,noColumns:this.getLegendColumnNumber(),container:this.$el.find(".legend-container"),labelBoxMargin:0,labelFormatter:this.labelFormatter.bind(this),labelBoxBorderColor:"transparent",backgroundOpacity:0}}),Flotr.EventAdapter.observe(this.$container.get(0),"flotr:click",t=>{if(!t.hit)return;if(!("index"in t.hit))return;let e=null;this.result.isJoint&&(e=this.columnList?this.columnList[t.hit.seriesIndex]:this.column),this.result.noSubReport||this.trigger("click-group",this.grList[t.hit.index],void 0,void 0,e)}),this.noLegend||this.adjustLegend()}}t.default=s}),define("modules/advanced/views/report/record/detail",["exports","views/record/detail"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{editModeDisabled=!0;printPdfAction=!1;setup(){super.setup(),!this.getMetadata().get(["scopes","ReportCategory","disabled"])&&this.getAcl().checkScope("ReportCategory","read")||this.hideField("category"),"JointGrid"===this.model.attributes.type&&this.hideField("entityType"),this.getUser().isPortal()||this.setupEmailSendingFieldsVisibility(),this.hidePanel("emailSending"),this.getUser().isPortal()||(this.model.has("emailSendingInterval")?this.controlEmailSendingPanelVisibility():this.listenToOnce(this.model,"sync",()=>this.controlEmailSendingPanelVisibility())),this.getUser().isPortal()&&this.hidePanel("default"),this.controlPortalsFieldVisibility(),this.listenTo(this.model,"sync",this.controlPortalsFieldVisibility),this.controlDescriptionFieldVisibility(),this.listenTo(this.model,"sync",this.controlDescriptionFieldVisibility)}controlPortalsFieldVisibility(){"no"!==this.getAcl().get("portalPermission")&&this.model.getLinkMultipleIdList("portals").length?this.showField("portals"):this.hideField("portals")}controlDescriptionFieldVisibility(){this.model.get("description")?this.showField("description"):this.hideField("description")}controlEmailSendingPanelVisibility(){this.model.get("emailSendingInterval")?this.showPanel("emailSending"):this.hidePanel("emailSending")}setupEmailSendingFieldsVisibility(){this.controlEmailSendingIntervalField(),this.listenTo(this.model,"change:emailSendingInterval",()=>{this.controlEmailSendingIntervalField()})}controlEmailSendingIntervalField(){const t=this.model.get("emailSendingInterval");"List"===this.model.get("type")&&""!==t&&t?this.showField("emailSendingDoNotSendEmptyReport"):this.hideField("emailSendingDoNotSendEmptyReport"),"Daily"===t?(this.showField("emailSendingTime"),this.showField("emailSendingUsers"),this.hideField("emailSendingSettingMonth"),this.hideField("emailSendingSettingDay"),this.hideField("emailSendingSettingWeekdays")):"Monthly"===t?(this.showField("emailSendingTime"),this.showField("emailSendingUsers"),this.hideField("emailSendingSettingMonth"),this.showField("emailSendingSettingDay"),this.hideField("emailSendingSettingWeekdays")):"Weekly"===t?(this.showField("emailSendingTime"),this.showField("emailSendingUsers"),this.hideField("emailSendingSettingMonth"),this.hideField("emailSendingSettingDay"),this.showField("emailSendingSettingWeekdays")):"Yearly"===t?(this.showField("emailSendingTime"),this.showField("emailSendingUsers"),this.showField("emailSendingSettingMonth"),this.showField("emailSendingSettingDay"),this.hideField("emailSendingSettingWeekdays")):(this.hideField("emailSendingTime"),this.hideField("emailSendingUsers"),this.hideField("emailSendingSettingMonth"),this.hideField("emailSendingSettingDay"),this.hideField("emailSendingSettingWeekdays"))}handleShortcutKeyCtrlEnter(t){if(!this.inlineEditModeIsOn&&this.mode===this.MODE_DETAIL)return this.recordHelper.trigger("run-report"),void t.stopPropagation();super.handleShortcutKeyCtrlEnter(t)}}t.default=s}),define("modules/advanced/views/report/modals/create-internal",["exports","views/modal","views/record/edit-for-modal","model","views/fields/enum"],function(t,e,i,s,a){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=n(e),i=n(i),s=n(s),a=n(a);class o extends e.default{templateContent='\n        <div class="record-container no-side-margin">{{{record}}}</div>\n    ';constructor(t){super(t),this.options=t}setup(){this.headerText=this.translate("Create Report","labels","Report");const t=new s.default,e=Object.keys(this.getMetadata().get("app.advancedReport.internalReports")??{});e.unshift("");const n=new i.default({model:t,detailLayout:[{rows:[[{view:new a.default({name:"name",labelText:this.translate("internalClassName","fields","Report"),params:{options:e,required:!0,isSorted:!0,translation:"Report.internalReports"}})},!1]]}]});this.assignView("record",n),this.buttonList=[{name:"proceed",label:"Proceed",style:"primary",onClick:()=>{if(n.validate())return;let e="#Report/create/internalClassName="+encodeURIComponent(t.attributes.name);this.options.attributes.categoryId&&(e+=`&categoryId=${this.options.attributes.categoryId}&categoryName=${this.options.attributes.categoryName}`),this.getRouter().navigate(e,{trigger:!0})}},{name:"cancel",label:"Cancel",onClick:()=>this.actionCancel()}]}}t.default=o}),define("advanced:views/report/fields/filters",["views/fields/multi-enum"],function(t){return t.extend({getFilterList:function(){const t=this.model.get("entityType"),e=this.getMetadata().get(`entityDefs.${t}.fields`),i=Object.keys(e).filter(i=>{if((!this.options.skipLinkMultiple||"linkMultiple"!==e[i].type)&&"map"!==e[i].type&&!e[i].disabled&&!e[i].utility&&!e[i].reportDisabled&&!e[i].reportFilterDisabled&&(!e[i].directAccessDisabled||e[i].filtersEnabled)&&this.getFieldManager().isEntityTypeFieldAvailable(t,i))return this.getFieldManager().checkFilter(e[i].type)});i.sort((e,i)=>this.translate(e,"fields",t).localeCompare(this.translate(i,"fields",t)));const s=this.getMetadata().get(`entityDefs.${t}.links`)||{};return Object.keys(s).sort((e,i)=>this.translate(e,"links",t).localeCompare(this.translate(i,"links",t))).forEach(t=>{const e=s[t].type;if("belongsTo"!==e&&"hasMany"!==e&&"hasChildren"!==e)return;const a=s[t].entity;if(!a)return;if(s[t].disabled||s[t].utility)return;const n=this.getMetadata().get(`entityDefs.${a}.fields`)||{},o=Object.keys(n).filter(t=>{const e=n[t].type;if(!["linkMultiple","linkParent","personName","foreign"].includes(e)&&!n[t].reportDisabled&&!n[t].reportFilterDisabled&&(!n[t].directAccessDisabled||n[t].filtersEnabled)&&!n[t].foreignAccessDisabled&&this.getFieldManager().isEntityTypeFieldAvailable(a,t))return this.getFieldManager().checkFilter(n[t].type)&&!n[t].disabled});o.sort((t,e)=>this.translate(t,"fields",a).localeCompare(this.translate(e,"fields",a))),o.forEach(e=>{i.push(t+"."+e)})}),i},setupTranslatedOptions:function(){this.translatedOptions={};const t=this.model.get("entityType");this.params.options.forEach(e=>{const i=e.split(".")[0];let s=e,a=t,n=!1;~e.indexOf(".")&&(n=!0,s=e.split(".")[1],a=this.getMetadata().get(`entityDefs.${t}.links.${i}.entity`)),this.translatedOptions[e]=this.translate(s,"fields",a),n&&(this.translatedOptions[e]=this.translate(i,"links",t)+" . "+this.translatedOptions[e])})},setupOptions:function(){t.prototype.setupOptions.call(this),this.params.options=this.getFilterList(),this.setupTranslatedOptions()},afterRender:function(){t.prototype.afterRender.call(this),this.$element&&this.$element[0]&&this.$element[0].selectize&&this.$element[0].selectize.focus()}})}),define("modules/advanced/views/report/fields/columns",["exports","views/fields/multi-enum","modules/advanced/views/report/fields/group-by"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{fieldTypeList;numericFieldTypeList;setup(){this.fieldTypeList=this.getMetadata().get("app.advancedReport.fieldTypeList")??[],this.numericFieldTypeList=this.getMetadata().get("app.advancedReport.numericFieldTypeList")??[],super.setup(),this.setupOptions(),this.setupTranslatedOptions(),this.listenTo(this.model,"change",t=>{t.hasChanged("groupBy")&&(this.setupOptions(),this.setupTranslatedOptions(),this.reRender())}),this.addActionHandler("editColumns",()=>this.actionEditColumns())}setupOptions(){const t=this.model.get("entityType"),e=this.getMetadata().get(["entityDefs",t,"fields"])||{};let i=!1;const s=this.getConfig().get("version")||"",a=s.split(".");"dev"!==s&&a.length>2&&100*parseInt(a[0])+parseInt(a[1])<506&&(i=!0);let n=!1;"dev"!==s&&a.length>2&&100*parseInt(a[0])+10*parseInt(a[1])+parseInt(a[2])<562&&(n=!0);const o=[];o.push("COUNT:id");let r=Object.keys(e)||[];r=r.sort((e,i)=>this.translate(e,"fields",t).localeCompare(this.translate(i,"fields",t))),r.forEach(i=>{e[i].disabled||e[i].directAccessDisabled||e[i].reportDisabled||this.getFieldManager().isEntityTypeFieldAvailable&&!this.getFieldManager().isEntityTypeFieldAvailable(t,i)||~this.numericFieldTypeList.indexOf(e[i].type)&&(o.push(`SUM:${i}`),o.push(`MAX:${i}`),o.push(`MIN:${i}`),o.push(`AVG:${i}`))});const l=this.model.get("groupBy")||[];l.forEach(e=>{if(!i){const i=this.getMetadata().get(["entityDefs",t,"links"])||{},s=Object.keys(i);s.sort((e,i)=>this.translate(e,"links",t).localeCompare(this.translate(i,"links",t))),s.forEach(t=>{if("belongsTo"!==i[t].type)return;if(t!==e)return;const s=i[t].entity;if(!s)return;if(i[t].disabled||i[t].utility)return;const a=this.getMetadata().get(["entityDefs",s,"fields"])||{},r=Object.keys(a);r.sort((t,e)=>this.translate(t,"fields",s).localeCompare(this.translate(e,"fields",s))),r.forEach(e=>{if(!a[e].disabled&&!a[e].utility&&!a[e].directAccessDisabled&&!a[e].reportDisabled&&(!this.getFieldManager().isEntityTypeFieldAvailable||this.getFieldManager().isEntityTypeFieldAvailable(s,e))&&~this.fieldTypeList.indexOf(a[e].type)){if("enum"===a[e].type&&"Currency"===e.substr(-8))return;if(n&&"email"===a[e].type)return;if(n&&"phone"===a[e].type)return;if("name"===e)return;o.push(t+"."+e)}})})}}),r.forEach(i=>{l.length>1||e[i].disabled||e[i].reportDisabled||e[i].directAccessDisabled||this.getFieldManager().isEntityTypeFieldAvailable&&!this.getFieldManager().isEntityTypeFieldAvailable(t,i)||~this.fieldTypeList.indexOf(e[i].type)&&o.push(i)});const d=this.getMetadata().get(["entityDefs",t,"links"])||{},c=Object.keys(d);c.sort((e,i)=>this.translate(e,"links",t).localeCompare(this.translate(i,"links",t))),c.forEach(t=>{if("belongsTo"!==d[t].type&&"hasOne"!==d[t].type)return;if(d[t].disabled||d[t].utility)return;const e=d[t].entity;if(!e)return;const i=this.getMetadata().get(["entityDefs",e,"fields"])||{};let s=Object.keys(i)||[];s=s.sort((t,i)=>this.translate(t,"fields",e).localeCompare(this.translate(i,"fields",e))),s.forEach(s=>{i[s].disabled||i[s].utility||i[s].directAccessDisabled||i[s].reportDisabled||this.getFieldManager().isEntityTypeFieldAvailable&&!this.getFieldManager().isEntityTypeFieldAvailable(e,s)||~this.numericFieldTypeList.indexOf(i[s].type)&&(o.push(`SUM:${t}.${s}`),o.push(`MAX:${t}.${s}`),o.push(`MIN:${t}.${s}`),o.push(`AVG:${t}.${s}`))})}),this.params.options=o}setupTranslatedOptions(t){i.default.prototype.setupTranslatedOptions.call(this,t),this.params.options.forEach(t=>{"COUNT:id"===t&&(this.translatedOptions[t]=this.translate("COUNT","functions","Report").toUpperCase())})}afterRender(){if(super.afterRender(),this.isEditMode()&&"columns"===this.name){const t=$('<button class="pull-right btn btn-default" data-action="editColumns"><span class="fas fa-pencil-alt fa-sm"></span></button>');this.$el.prepend(t);const e=t.outerWidth()+8;this.$el.find(".selectize-control").css("width","calc(100% - "+e+"px)")}}actionEditColumns(){const t=this.model.get(this.name)||[],e=this.model.get("columnsData")||{},i=t.map(t=>(e[t]||{}).label||null),s=t.map(t=>(e[t]||{}).type||null),a=t.map(t=>{const i=(e[t]||{}).decimalPlaces;return void 0===i?null:i});this.createView("dialog","advanced:views/report/modals/edit-columns",{expressions:t,labels:i,types:s,decimals:a,entityType:this.model.attributes.entityType},t=>{t.render(),this.listenToOnce(t,"apply",(t,e,i,s)=>{const a=t.reduce((t,a,n)=>{const o=e[n]||null,r=i[n]||null,l=s[n];return t[a]={label:o,type:r,decimalPlaces:l},t},{});this.model.set({[this.name]:t,columnsData:a},{ui:!0}),this.clearView("dialog"),this.reRender()})})}}t.default=a}),define("advanced:views/bpmn-process/record/edit","views/record/edit",function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.setupFlowchartDependency()},setupFlowchartDependency:function(){this.listenTo(this.model,"change:flowchartId",function(t,e,i){i.ui&&(this.model.set({targetId:null,targetName:null}),e||this.model.set("startElementIdList",[]),this.model.set("name",this.model.get("flowchartName")))},this),this.model.has("startElementIdList")?(this.showField("startElementId"),this.setStartElementIdList(this.model.get("startElementIdList"))):this.hideField("startElementId"),this.listenTo(this.model,"change:startElementIdList",function(t,e,i){this.setStartElementIdList(e)},this)},setStartElementIdList:function(t){t=t||[],this.setFieldOptionList("startElementId",t),t.length?this.model.set("startElementId",t[0]):this.model.set("startElementId",null),t.length>0?this.showField("startElementId"):this.hideField("startElementId")}})}),define("advanced:views/bpmn-flowchart-element/record/task-user-detail",["advanced:views/bpmn-flowchart-element/record/detail"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.controlFieldsVisibility()},controlFieldsVisibility:function(){this.hideField("targetUser"),this.hideField("targetUser"),this.hideField("targetUserPosition"),this.setFieldNotRequired("targetUser"),this.setFieldNotRequired("targetTeam"),"specifiedUser"===this.model.get("assignmentType")?(this.showPanel("assignmentRule"),this.showField("targetUser"),this.setFieldRequired("targetUser")):0===(this.model.get("assignmentType")||"").indexOf("rule:")&&(this.showPanel("assignmentRule"),this.showField("targetTeam"),this.showField("targetUserPosition"),this.setFieldRequired("targetTeam"))}})}),define("advanced:views/bpmn-flowchart-element/record/task-send-message-detail",["advanced:views/bpmn-flowchart-element/record/detail"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.controlFieldsVisibility()},controlFieldsVisibility:function(){this.hideField("fromEmailAddress"),this.hideField("toEmailAddress"),this.hideField("replyToEmailAddress"),this.hideField("ccEmailAddress"),this.hideField("toSpecifiedTeams"),this.hideField("toSpecifiedUsers"),this.hideField("toSpecifiedContacts"),"specifiedEmailAddress"===this.model.get("from")&&this.showField("fromEmailAddress"),"specifiedEmailAddress"===this.model.get("to")&&this.showField("toEmailAddress"),"specifiedEmailAddress"===this.model.get("replyTo")&&this.showField("replyToEmailAddress"),"specifiedEmailAddress"===this.model.get("cc")&&this.showField("ccEmailAddress"),"specifiedUsers"===this.model.get("to")&&this.showField("toSpecifiedUsers"),"specifiedTeams"===this.model.get("to")&&this.showField("toSpecifiedTeams"),"specifiedContacts"===this.model.get("to")&&this.showField("toSpecifiedContacts")}})}),define("advanced:views/bpmn-flowchart-element/record/gateway-exclusive-detail",["advanced:views/bpmn-flowchart-element/record/detail"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.isDivergent()?this.showPanel("divergent"):(this.hideField("flowsConditions"),this.hidePanel("flowsConditions"),this.hideField("defaultFlowId"),this.hidePanel("divergent"))},isConvergent:function(){var t=this.model.dataHelper.getAllDataList(),e=this.model.id,i=0;return t.forEach(t=>{"flow"===t.type&&t.endId===e&&i++}),i>1},isDivergent:function(){var t=this.model.dataHelper.getAllDataList(),e=this.model.id,i=0;return t.forEach(t=>{"flow"===t.type&&t.startId===e&&i++}),i>1}})}),define("advanced:views/bpmn-flowchart-element/record/event-start-edit",["advanced:views/bpmn-flowchart-element/record/edit"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.model.isInSubProcess?this.showField("isInterrupting"):this.hideField("isInterrupting")}})}),define("advanced:views/bpmn-flowchart-element/record/event-start-detail",["advanced:views/bpmn-flowchart-element/record/detail"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.model.isInSubProcess?this.showField("isInterrupting"):this.hideField("isInterrupting")}})}),define("advanced:views/bpmn-flowchart-element/fields/task-send-message-from",["views/fields/enum"],function(t){return t.extend({setupOptions:function(){t.prototype.setupOptions.call(this),this.params.options=Espo.Utils.clone(this.params.options);this.getLinkOptionList(!0,!0).forEach(t=>{this.params.options.push(t)}),this.translateOptions()},translateOptions:function(){this.translatedOptions={};const t=this.model.targetEntityType;this.params.options.forEach(e=>{if(0===e.indexOf("link:")){let i=e.substring(5);if(~i.indexOf(".")){const s=i.split(".");i=s[0];const a=s[1];if("followers"===a)return void(this.translatedOptions[e]=this.translate("Related","labels","Workflow")+" · "+this.translate(i,"links",t)+" . "+this.translate("Followers"));const n=this.getMetadata().get(["entityDefs",t,"links",i,"entity"]);return void(this.translatedOptions[e]=this.translate("Related","labels","Workflow")+" · "+this.translate(i,"links",t)+" . "+this.translate(a,"links",n))}return void(this.translatedOptions[e]=this.translate("Related","labels","Workflow")+" · "+this.translate(i,"links",t))}this.translatedOptions[e]=this.getLanguage().translateOption(e,"emailAddress","BpmnFlowchartElement")}),this.translatedOptions.targetEntity=this.getLanguage().translateOption("targetEntity","emailAddress","BpmnFlowchartElement")+" · "+this.translate(t,"scopeNames")},getLinkOptionList:function(t,e){const i=[],s=this.model.targetEntityType;return Object.keys(this.getMetadata().get(["entityDefs",s,"links"])||{}).forEach(a=>{const n=this.getMetadata().get(["entityDefs",s,"links",a])||{};if("belongsTo"===n.type||"hasMany"===n.type){const o=n.entity;if(!o)return;if("hasMany"===n.type){if(e)return;if("linkMultiple"!==this.getMetadata().get(["entityDefs",s,"fields",a,"type"]))return}if(t&&"User"!==o)return;const r=this.getMetadata().get(["entityDefs",o,"fields"])||{};"emailAddress"in r&&"email"===r.emailAddress.type&&i.push("link:"+a)}else if("belongsToParent"===n.type){if(t)return;i.push("link:"+a)}}),Object.keys(this.getMetadata().get(["entityDefs",s,"links"])||{}).forEach(a=>{if("belongsTo"!==(this.getMetadata().get(["entityDefs",s,"links",a])||{}).type)return;const n=this.getMetadata().get(["entityDefs",s,"links",a,"entity"]);n&&"User"!==n&&(e||this.getMetadata().get(["scopes",n,"stream"])&&i.push("link:"+a+".followers"),Object.keys(this.getMetadata().get(["entityDefs",n,"links"])||{}).forEach(e=>{const s=this.getMetadata().get(["entityDefs",n,"links",e])||{};if("belongsTo"===s.type||"hasMany"===s.type){const n=s.entity;if(!n)return;if("hasMany"===s.type&&"linkMultiple"!==this.getMetadata().get(["entityDefs",n,"fields",e,"type"]))return;if(t&&"User"!==n)return;const o=this.getMetadata().get(["entityDefs",n,"fields"])||{};"emailAddress"in o&&"email"===o.emailAddress.type&&i.push(`link:${a}.${e}`)}}))}),Object.keys(this.getMetadata().get(["entityDefs",s,"links"])||{}).forEach(e=>{"belongsToParent"===this.getMetadata().get(["entityDefs",s,"links",e,"type"])&&(i.push(`link:${e}.assignedUser`),t||i.push(`link:${e}.followers`))}),i}})}),define("advanced:views/bpmn-flowchart-element/fields/call-activity-target",["views/fields/enum"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this);const e=this.getTargetOptionsData();this.params.options=e.itemList,this.translatedOptions=e.translatedOptions},getTargetOptionsData:function(){const t=[""],e={};e[""]=this.translate("Current","labels","Workflow")+" · "+this.translate(this.model.targetEntityType,"scopeNames");this.model.elementHelper.getTargetCreatedList().forEach(i=>{t.push(i),e[i]=this.model.elementHelper.translateTargetItem(i)});return this.model.elementHelper.getTargetLinkList(2,!1,this.skipParent).forEach(i=>{t.push(i),e[i]=this.model.elementHelper.translateTargetItem(i)}),{itemList:t,translatedOptions:e}}})}),define("modules/advanced/views/bpmn-flowchart/fields/flowchart",["exports","views/fields/base","underscore","jquery"],function(t,e,i,s){"use strict";function a(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=a(e),i=a(i),s=a(s);class n extends e.default{detailTemplate="advanced:bpmn-flowchart/fields/flowchart/detail";editTemplate="advanced:bpmn-flowchart/fields/flowchart/edit";height=500;inlineEditDisabled=!0;dataAttribute="data";undoStackLength=30;undoStack;redoStack;createdEntitiesData;events={'click .action[data-action="setStateCreateFigure"]':function(t){const e=(0,s.default)(t.currentTarget).data("name");this.setStateCreateFigure(e)},'click .action[data-action="resetState"]':function(){this.resetState(!0)},'click .action[data-action="setStateCreateFlow"]':function(){this.setStateCreateFlow()},'click .action[data-action="setStateRemove"]':function(){this.setStateRemove()},'click .action[data-action="apply"]':function(){this.apply()},'click .action[data-action="zoomIn"]':function(){this.zoomIn()},'click .action[data-action="zoomOut"]':function(){this.zoomOut()},'click .action[data-action="switchFullScreenMode"]':function(t){t.preventDefault(),this.isFullScreenMode?this.unsetFullScreenMode():this.setFullScreenMode()}};getAttributeList(){return[this.dataAttribute]}data(){const t=super.data();return t.heightString=this.height.toString()+"px","edit"===this.mode&&(t.elementEventDataList=this.elementEventDataList,t.elementGatewayDataList=this.elementGatewayDataList,t.elementTaskDataList=this.elementTaskDataList,t.currentElement=this.currentElement),t}setup(){super.setup(),this.undoStack=[],this.redoStack=[],this.addActionHandler("moveToCenter",()=>this.moveToCenter()),this.addActionHandler("undo",()=>this.undo()),this.addActionHandler("redo",()=>this.redo());const t="#69a345",e="#5d86b0",i="#b34646";this.elementEventList=["eventStart","eventStartConditional","eventStartTimer","eventStartError","eventStartEscalation","eventStartSignal","eventStartCompensation","eventIntermediateConditionalCatch","eventIntermediateTimerCatch","eventIntermediateSignalCatch","eventIntermediateMessageCatch","eventIntermediateEscalationThrow","eventIntermediateSignalThrow","eventIntermediateCompensationThrow","eventEnd","eventEndTerminate","eventEndError","eventEndEscalation","eventEndSignal","eventEndCompensation","eventIntermediateErrorBoundary","eventIntermediateConditionalBoundary","eventIntermediateTimerBoundary","eventIntermediateEscalationBoundary","eventIntermediateSignalBoundary","eventIntermediateMessageBoundary","eventIntermediateCompensationBoundary"],this.elementGatewayList=["gatewayExclusive","gatewayInclusive","gatewayParallel","gatewayEventBased"],this.elementTaskList=["task","taskSendMessage","taskUser","taskScript","_divider","subProcess","eventSubProcess","callActivity"],this.elementEventDataList=[{name:"eventStart",color:t},{name:"eventStartConditional",color:t},{name:"eventStartTimer",color:t},{name:"eventStartError",color:t},{name:"eventStartEscalation",color:t},{name:"eventStartSignal",color:t},{name:"eventStartCompensation",color:t},{name:"_divider",color:null},{name:"eventIntermediateConditionalCatch",color:e},{name:"eventIntermediateTimerCatch",color:e},{name:"eventIntermediateSignalCatch",color:e},{name:"eventIntermediateMessageCatch",color:e},{name:"_divider",color:null},{name:"eventIntermediateEscalationThrow",color:e},{name:"eventIntermediateSignalThrow",color:e},{name:"eventIntermediateCompensationThrow",color:e},{name:"_divider",color:null},{name:"eventEnd",color:i},{name:"eventEndTerminate",color:i},{name:"eventEndError",color:i},{name:"eventEndEscalation",color:i},{name:"eventEndSignal",color:i},{name:"eventEndCompensation",color:i},{name:"_divider",color:null},{name:"eventIntermediateErrorBoundary",color:e},{name:"eventIntermediateConditionalBoundary",color:e},{name:"eventIntermediateTimerBoundary",color:e},{name:"eventIntermediateEscalationBoundary",color:e},{name:"eventIntermediateSignalBoundary",color:e},{name:"eventIntermediateMessageBoundary",color:e},{name:"eventIntermediateCompensationBoundary",color:e}],this.elementGatewayDataList=[],this.elementGatewayList.forEach(t=>{this.elementGatewayDataList.push({name:t,color:"var(--state-warning-text)"})}),this.elementTaskDataList=[],this.elementTaskList.forEach(t=>{this.elementTaskDataList.push({name:t,color:"var(--gray-soft)"})}),this.dataHelper={getAllDataList:()=>this.getAllDataList(),getElementData:t=>this.getElementData(t)};const s=(t,e)=>{const i=EspoBpmn.Icons[t];if(!i)return null;const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("height",i.height.toString()),s.setAttribute("width",i.width.toString()),s.setAttribute("viewBox",i.viewBox);const a=document.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("d",i.icon),a.setAttribute("fill",e),s.appendChild(a),s.outerHTML};this.wait((async()=>{await Espo.loader.requirePromise("lib!client/custom/modules/advanced/lib/espo-bpmn.js"),this.elementEventDataList.forEach(t=>{if("_divider"===t.name)return;let e;if(t.name.startsWith("eventStart"))e=t.name.replace("eventStart","event")+"Catch";else if(t.name.startsWith("eventEnd"))e=t.name.replace("eventEnd","event")+"Throw";else{if(!t.name.startsWith("eventIntermediate"))return;e=t.name.replace("eventIntermediate","event"),t.name.endsWith("Boundary")&&(e=e.slice(0,-8)+"Catch")}"eventStart"!==t.name&&"eventEnd"!==t.name||(e="gatewayInclusive");const i=s(e,t.color);i&&(t.iconHtml=i)}),this.elementGatewayDataList.forEach(t=>{if("gatewayExclusive"===t.name){const e=document.createElement("span");return e.classList.add("fas","fa-diamond"),e.style.color=t.color,void(t.iconHtml=e.outerHTML)}if("gatewayEventBased"===t.name){const e=document.createElement("span");return e.classList.add("far","fa-circle-dot"),e.style.color=t.color,void(t.iconHtml=e.outerHTML)}const e=s(t.name,t.color);e&&(t.iconHtml=e)});const t={taskSendMessage:"taskSendMessage",taskUser:"taskUser",taskScript:"taskScript"};this.elementTaskDataList.forEach(e=>{if("task"===e.name){const t=document.createElement("span");return t.classList.add("fas","fa-square","fa-sm"),t.style.color=e.color,t.style.transform="translate(var(--minus-1px), 0)",void(e.iconHtml=t.outerHTML)}if("taskScript"===e.name){const t=document.createElement("span");return t.classList.add("fas","fa-code","fa-sm"),t.style.color=e.color,void(e.iconHtml=t.outerHTML)}const i=t[e.name];if(!i)return;const a=s(i,e.color);a&&(e.iconHtml=a)})})()),this.on("inline-edit-off",()=>{this.currentState=null,this.currentElement=null});const a=Espo.Utils.cloneDeep(this.model.get(this.dataAttribute)||{});this.dataList=a.list||[],this.createdEntitiesData=a.createdEntitiesData||{},this.listenTo(this.model,"change:"+this.dataAttribute,(t,e,i)=>{if(i.ui)return;const s=Espo.Utils.cloneDeep(this.model.get(this.dataAttribute)||{});this.dataList=s.list||[]}),this.on("render",()=>{this.canvas&&(this.offsetX=this.canvas.offsetX,this.offsetY=this.canvas.offsetY,this.scaleRatio=this.canvas.scaleRatio)}),this.offsetX=null,this.offsetY=null,this.scaleRatio=null}prepare(){return this.mode===this.MODE_EDIT&&(this.undoStack=[],this.redoStack=[],this.addDataToUndoStack()),super.prepare()}afterRender(){this.$groupContainer=this.$el.find(".flowchart-group-container"),this.$container=this.$el.find(".flowchart-container"),this.isFullScreenMode&&this.setFullScreenMode(),this.isEditMode()&&this.controlUndoActions();const t={},e=this.getMetadata().get(["clientDefs","BpmnFlowchart","elements"])||{};for(const i in e)"defaults"in e[i]&&(t[i]=Espo.Utils.cloneDeep(e[i].defaults));t.subProcess=t.subProcess||{},t.subProcess.targetType=this.model.get("targetType"),t.eventSubProcess=t.eventSubProcess||{},t.eventSubProcess.targetType=this.model.get("targetType");const i={canvasWidth:"100%",canvasHeight:"100%",dataDefaults:t,events:{change:()=>{this.mode===this.MODE_EDIT&&(this.trigger("change"),this.addDataToUndoStack())},resetState:()=>{this.currentElement=null,this.currentState=null,this.resetTool(!0)},figureLeftClick:t=>{const e=t.figureId;e&&this.openElement(e)},removeFigure:t=>{this.onRemoveElement(t.figureId),this.trigger("change"),this.addDataToUndoStack()},createFigure:t=>{this.onCreateElement(t.figureId),this.addDataToUndoStack()}},isReadOnly:this.mode!==this.MODE_EDIT,scaleDisabled:!0,isEventSubProcess:this.isEventSubProcess};this.getThemeManager().getParam("isDark")&&this.applyDarkColorsToCanvasOptions(i),null!==this.offsetX&&(i.offsetX=this.offsetX),null!==this.offsetY&&(i.offsetY=this.offsetY),null!==this.scaleRatio&&(i.scaleRatio=this.scaleRatio);const s=this.$container.get(0);if(this.canvas=new window.EspoBpmn.Canvas(s,i,this.dataList),this.mode===this.MODE_EDIT)if(this.currentState)if("createFigure"===this.currentState)this.setStateCreateFigure(this.currentElement);else{this["setState"+Espo.Utils.upperCaseFirst(this.currentState)]()}else this.resetTool(!0)}openElement(t){const e=this.getElementData(t);if(!e)return;const i=this.getParentSubProcessData(t);let s=this.model.get("targetType");i&&(s=i.targetType||s);let a=this.isSubProcess;a||(a=!!i),a||(a=!!this.model.get("parentProcessId")),this.mode!==this.MODE_DETAIL?this.mode===this.MODE_EDIT&&this.createView("dialog","advanced:views/bpmn-flowchart/modals/element-edit",{elementData:e,targetType:s,flowchartDataList:this.dataList,flowchartModel:this.model,flowchartCreatedEntitiesData:this.createdEntitiesData,dataHelper:this.dataHelper,isInSubProcess:a},a=>{a.render(),this.listenTo(a,"apply",n=>{for(const t in n)e[t]=n[t];"defaultFlowId"in n&&this.updateDefaultFlow(t),"actionList"in n?this.updateCreatedEntitiesData(t,n.actionList,s):"taskUser"===e.type?this.updateCreatedEntitiesDataUserTask(t,n):"taskSendMessage"===e.type&&this.updateCreatedEntitiesDataSendMessageTask(t,n),i&&"eventSubProcess"===i.type&&0===(e.type||"").indexOf("eventStart")&&this.updateEventSubProcessStartData(i.id,n),this.trigger("change"),this.addDataToUndoStack(),a.remove(),this.reRender()}),this.listenToOnce(a,"remove",()=>{this.clearView("dialog")})}):this.createView("dialog","advanced:views/bpmn-flowchart/modals/element-detail",{elementData:e,targetType:s,flowchartDataList:this.dataList,flowchartModel:this.model,flowchartCreatedEntitiesData:this.createdEntitiesData,dataHelper:this.dataHelper,isInSubProcess:a,isInSubProcess2:!!i},t=>{t.render(),this.listenToOnce(t,"remove",()=>{this.clearView("dialog")})})}updateCreatedEntitiesDataUserTask(t,e){const i=t in this.createdEntitiesData?this.createdEntitiesData[t].numberId:this.getNextCreatedEntityNumberId("BpmnUserTask");this.createdEntitiesData[t]={elementId:t,actionId:null,entityType:"BpmnUserTask",numberId:i,text:e.text||null}}updateCreatedEntitiesDataSendMessageTask(t,e){if("Email"===e.messageType&&!e.doNotStore){const i=t in this.createdEntitiesData?this.createdEntitiesData[t].numberId:this.getNextCreatedEntityNumberId("Email");return void(this.createdEntitiesData[t]={elementId:t,actionId:null,entityType:"Email",numberId:i,text:e.text||null})}delete this.createdEntitiesData[t]}removeCreatedEntitiesDataUserTask(t){delete this.createdEntitiesData[t]}updateCreatedEntitiesData(t,e,i){const s=[];for(const i in this.createdEntitiesData){const a=this.createdEntitiesData[i];if(a.elementId===t){let t=!1;e.forEach(e=>{a.actionId===e.id&&(t=!0)}),t||s.push(i)}}s.forEach(t=>{delete this.createdEntitiesData[t]}),e.forEach(e=>{if(!~["createRelatedEntity","createEntity"].indexOf(e.type))return;const s=t+"_"+e.id;let a,n=null;if("createEntity"===e.type?a=e.entityType:"createRelatedEntity"===e.type&&(n=e.link,i=i||this.model.get("targetType"),a=this.getMetadata().get(["entityDefs",i,"links",e.link,"entity"])),!a)return;const o=s in this.createdEntitiesData?this.createdEntitiesData[s].numberId:this.getNextCreatedEntityNumberId(a);this.createdEntitiesData[s]={elementId:t,actionId:e.id,link:n,entityType:a,numberId:o}})}getNextCreatedEntityNumberId(t){let e=0;for(const i in this.createdEntitiesData){const s=this.createdEntitiesData[i];t===s.entityType&&"numberId"in s&&(e=s.numberId+1)}return e}updateDefaultFlow(t){const e=this.getElementData(t);this.getElementFlowIdList(t).forEach(t=>{const i=this.getElementData(t);i&&(i.isDefault=e.defaultFlowId===t)})}getElementFlowIdList(t){const e=[];return this.getAllDataList().forEach(i=>{if("flow"===i.type&&i.startId===t&&i.endId){if(!this.getElementData(i.endId))return;e.push(i.id)}}),e}getElementData(t){const e={};return this._findElementData(t,this.dataList,e),e.data||null}_findElementData(t,e,i){for(let s=0;s<e.length;s++){if(e[s].id===t)return void(i.data=e[s]);if(("subProcess"===e[s].type||"eventSubProcess"===e[s].type)&&(this._findElementData(t,e[s].dataList||[],i),i.data))return}}getParentSubProcessData(t){const e={};return this._findParentSubProcessData(t,this.dataList,e),e.data||null}_findParentSubProcessData(t,e,i,s){for(let a=0;a<e.length;a++){if(e[a].id===t)return void(i.data=s);if(("subProcess"===e[a].type||"eventSubProcess"===e[a].type)&&(this._findParentSubProcessData(t,e[a].dataList||[],i,e[a]),i.data))return}}updateEventSubProcessStartData(t,e){const s=this.getElementData(t);s.eventStartData=i.default.extend(s.eventStartData,Espo.Utils.cloneDeep(e))}resetTool(t){this.$el.find('.action[data-action="setStateCreateFigure"] span[data-role="bpm-menu-item-checkbox"]').addClass("hidden"),this.$el.find(".button-container .btn").removeClass("active"),t&&this.$el.find('.button-container .btn[data-action="resetState"]').addClass("active")}setStateCreateFigure(t){this.currentElement=t,this.currentState="createFigure",this.canvas.setState("createFigure",{type:t}),this.resetTool(),this.$el.find(`.action[data-action="setStateCreateFigure"][data-name="${t}"] span[data-role="bpm-menu-item-checkbox"]`).removeClass("hidden"),~this.elementEventList.indexOf(t)?this.$el.find(".button-container .btn.add-event-element").addClass("active"):~this.elementGatewayList.indexOf(t)?this.$el.find(".button-container .btn.add-gateway-element").addClass("active"):~this.elementTaskList.indexOf(t)&&this.$el.find(".button-container .btn.add-task-element").addClass("active")}setStateCreateFlow(){this.resetState(),this.currentState="createFlow",this.canvas.setState("createFlow"),this.$el.find('.button-container .btn[data-action="setStateCreateFlow"]').addClass("active")}setStateRemove(){this.resetState(),this.currentState="remove",this.canvas.setState("remove"),this.$el.find('.button-container .btn[data-action="setStateRemove"]').addClass("active")}resetState(t){this.canvas.resetState(),this.currentState=null,this.currentElement=null,this.resetTool(t)}getAllDataList(){const t=[];return this._populateAllList(this.dataList,t),t}_populateAllList(t,e){for(let i=0;i<t.length;i++)e.push(t[i]),"subProcess"!==t[i].type&&"eventSubProcess"!==t[i].type||this._populateAllList(t[i].dataList||[],e)}onCreateElement(t){const e=this.getElementData(t);"taskUser"===e.type?this.updateCreatedEntitiesDataUserTask(t,e):"taskSendMessage"===e.type&&this.updateCreatedEntitiesDataSendMessageTask(t,e)}onRemoveElement(t){this.getAllDataList().forEach(e=>{if(e.defaultFlowId===t&&(e.defaultFlowId=null),e.flowList){const i=e.flowList,s=[];let a=!1;i.forEach(e=>{e.id!==t?s.push(e):a=!0}),a&&(e.flowList=s)}}),this.updateCreatedEntitiesData(t,[]),this.removeCreatedEntitiesDataUserTask(t)}setFullScreenMode(){this.isFullScreenMode=!0;let t=null,e=this.$groupContainer;for(;t=window.getComputedStyle(e.get(0),null).getPropertyValue("background-color"),(!t||"rgba(0, 0, 0, 0)"===t)&&(e=e.parent(),e.length););this.$groupContainer.css({width:"100%",height:"100%",position:"fixed",top:0,zIndex:1050,left:0,backgroundColor:t}),this.$container.css("height","100%"),this.$el.find('button[data-action="apply"]').removeClass("hidden"),this.canvas.params.scaleDisabled=!1,this.$groupContainer.addClass("fullscreen")}unsetFullScreenMode(){this.isFullScreenMode=!1,this.$groupContainer.css({width:"",height:"",position:"static",top:"",left:"",zIndex:"",backgroundColor:""}),this.$container.css("height",this.height.toString()+"px"),this.$groupContainer.removeClass("fullscreen"),this.$el.find('button[data-action="apply"]').addClass("hidden"),this.canvas.params.scaleDisabled=!0}apply(){this.model.isNew()&&!this.model.attributes.name&&this.model.set("name","Unnamed"),this.model.save().then(()=>{Espo.Ui.success(this.translate("Saved"))})}zoomIn(){this.canvas.scaleCentered(2)}zoomOut(){this.canvas.scaleCentered(-2)}fetch(){const t={};t.list=Espo.Utils.cloneDeep(this.dataList),t.createdEntitiesData=Espo.Utils.cloneDeep(this.createdEntitiesData);const e={};return e[this.dataAttribute]=t,e}applyDarkColorsToCanvasOptions(t){t.textColor=this.getThemeManager().getParam("textColor")||"#fff",t.strokeColor="#8a8f89",t.rectangleExpandedFillColor="#242424",t.taskStrokeColor=t.strokeColor,t.taskFillColor="#1a1a1a",t.eventStartFillColor="#70995e",t.eventStartStrokeColor="#426e26",t.gatewayStrokeColor="#7e7437",t.gatewayFillColor="#afa152",t.eventEndFillColor="#ab5b5b",t.eventEndStrokeColor="#6a3b3b",t.eventIntermediateFillColor="#6c88b3",t.eventIntermediateStrokeColor="#435d87"}moveToCenter(){this.offsetX=0,this.offsetY=0,this.canvas.moveTo({x:0,y:0})}controlUndoActions(){if(!this.element)return;const t=this.element.querySelector('[data-action="undo"]'),e=this.element.querySelector('[data-action="redo"]');this.undoStack.length>1?t.classList.remove("disabled"):t.classList.add("disabled"),this.redoStack.length>0?e.classList.remove("disabled"):e.classList.add("disabled")}addDataToUndoStackDebounceTimer=null;addDataToUndoStack(){clearTimeout(this.addDataToUndoStackDebounceTimer),this.addDataToUndoStackDebounceTimer=setTimeout(()=>this.addDataToUndoStackActual(),50)}addDataToUndoStackActual(){const t=this.fetch(),e=Espo.Utils.cloneDeep(t.data);this.undoStack.push(e),this.undoStack.length>this.undoStackLength&&this.undoStack.shift(),this.redoStack=[],this.controlUndoActions()}undo(){if(this.undoStack.length<=1)return;const t=this.undoStack.pop();this.redoStack.push(t);const e=this.undoStack[this.undoStack.length-1],i=Espo.Utils.cloneDeep(e);this.dataList=i.list,this.createdEntitiesData=i.createdEntitiesData,this.fetchToModel(),this.reRender(),this.trigger("change"),this.controlUndoActions()}redo(){if(0===this.redoStack.length)return;const t=this.redoStack.pop();this.undoStack.push(t);const e=Espo.Utils.cloneDeep(t);this.dataList=e.list,this.createdEntitiesData=e.createdEntitiesData,this.fetchToModel(),this.reRender(),this.trigger("change"),this.controlUndoActions()}}t.default=n}),define("advanced:views/bpmn-flowchart/fields/entity-type",["views/fields/enum","advanced:bpmn-element-helper"],function(t,e){return t.extend({setupOptions:function(){let t=new e(this.getHelper(),this.model);this.params.options=t.getTargetEntityTypeList(),this.params.options.unshift(""),this.params.translation="Global.scopeNames"}})}),define("modules/advanced/helpers/report/column-helper",["exports","di","language","metadata"],function(t,e,i,s){"use strict";var a;let n,o,r,l,d;function c(t){return t&&t.__esModule?t:{default:t}}function h(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function u(t,e,i){"symbol"==typeof e&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch(t){}return t}function p(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(null!==t?typeof t:"null"));return t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,i=c(i),s=c(s);let f=t.default=void 0;class m{static#t=(a=({e:[o,r,l,d],c:[f,n]}=function(t,e,i,s,a,n){var o,r,l,d,c,f,m,g=Symbol.metadata||Symbol.for("Symbol.metadata"),y=Object.defineProperty,w=Object.create,v=[w(null),w(null)],b=e.length;function T(e,i,s){return function(a,n){i&&(n=a,a=t);for(var o=0;o<e.length;o++)n=e[o].apply(a,s?[n]:[]);return s?n:a}}function D(t,e,i,s){if("function"!=typeof t&&(s||void 0!==t))throw new TypeError(e+" must "+(i||"be")+" a function"+(s?"":" or undefined"));return t}function k(t,e,i,s,a,n,l,d,c,h,p){function f(t){if(!p(t))throw new TypeError("Attempted to access private element on non-instance")}var m=[].concat(e[0]),g=e[3],w=!l,b=1===a,k=3===a,E=4===a,C=2===a;function x(e,i,s){return function(a,n){return i&&(n=a,a=t),s&&s(a),O[e].call(a,n)}}if(!w){var O={},L=[],M=k?"get":E||b?"set":"value";if(c?(h||b?O={get:u(function(){return g(this)},s,"get"),set:function(t){e[4](this,t)}}:O[M]=g,h||u(O[M],s,C?"":M)):h||(O=Object.getOwnPropertyDescriptor(t,s)),!h&&!c){if((r=v[+d][s])&&7!=(r^a))throw Error("Decorating two elements with the same name ("+O[M].name+") is not supported yet");v[+d][s]=a<3?1:a}}for(var F=t,S=m.length-1;S>=0;S-=i?2:1){var V=D(m[S],"A decorator","be",!0),R=i?m[S-1]:void 0,$={},I={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:o,addInitializer:function(t,e){if(t.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(e,"An initializer","be",!0),n.push(e)}.bind(null,$)};if(w)r=V.call(R,F,I),$.v=1,D(r,"class decorators","return")&&(F=r);else if(I.static=d,I.private=c,r=I.access={has:c?p.bind():function(t){return s in t}},E||(r.get=c?C?function(t){return f(t),O.value}:x("get",0,f):function(t){return t[s]}),C||k||(r.set=c?x("set",0,f):function(t,e){t[s]=e}),F=V.call(R,b?{get:O.get,set:O.set}:O[M],I),$.v=1,b){if("object"==typeof F&&F)(r=D(F.get,"accessor.get"))&&(O.get=r),(r=D(F.set,"accessor.set"))&&(O.set=r),(r=D(F.init,"accessor.init"))&&L.unshift(r);else if(void 0!==F)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(F,(h?"field":"method")+" decorators","return")&&(h?L.unshift(F):O[M]=F)}return a<2&&l.push(T(L,d,1),T(n,d,0)),h||w||(c?b?l.splice(-1,0,x("get",d),x("set",d)):l.push(C?O[M]:D.call.bind(O[M])):y(t,s,O)),F}function E(t){return y(t,g,{configurable:!0,enumerable:!0,value:o})}return void 0!==n&&(o=n[g]),o=w(null==o?null:o),c=[],f=function(t){t&&c.push(T(t))},(m=function(e,s){for(var n=0;n<i.length;n++){var o=i[n],r=o[1],u=7&r;if((8&r)==e&&!u==s){var f=o[2],m=!!o[3],g=16&r;k(e?t:t.prototype,o,g,m?"#"+f:h(f),u,u<2?[]:e?d=d||[]:l=l||[],c,!!e,m,s,e&&m?function(e){return p(e)===t}:a)}}})(8,0),m(0,0),m(8,1),m(0,1),f(l),f(d),r=c,b||E(t),{e:r,get c(){var i=[];return b&&[E(t=k(t,[e],s,t.name,5,i)),T(i,1)]}}}(this,[(0,e.register)()],[[(0,e.inject)(i.default),0,"language"],[(0,e.inject)(s.default),0,"metadata"]])),t.default=f,a);constructor(){d(this)}language=o(this);metadata=(r(this),l(this));translateInternalReportColumn(t,e){const i=t;if(!i)return null;const s=this.metadata.get(`app.advancedReport.internalReports.${i}.columnsParams.${e}.labelTranslation`);return s?this.language.translatePath(s):null}static#e=n()}}),define("advanced:start-process-action-handler",["action-handler"],function(t){return t.extend({init:function(){~(this.view.getHelper().getAppParam("flowchartEntityTypeList")||[]).indexOf(this.view.model.entityType)&&this.view.showHeaderActionItem("startProcessGlobal")},actionStartProcessGlobal:function(){this.view.createView("startProcessDialog","views/modals/select-records",{scope:"BpmnFlowchart",primaryFilterName:"isManuallyStartable",createButton:!1,filters:{targetType:{type:"in",value:[this.view.model.entityType],data:{type:"anyOf",valueList:[this.view.model.entityType]}}}}).then(function(t){t.render(),this.view.listenToOnce(t,"select",function(t){var e={flowchartName:t.get("name"),flowchartId:t.id,targetType:this.view.model.entityType,targetName:this.view.model.get("name"),targetId:this.view.model.id,startElementIdList:t.get("eventStartAllIdList"),flowchartElementsDataHash:t.get("elementsDataHash")},i=this.view.getRouter(),s=i.getCurrentUrl();i.navigate("#BpmnProcess/create",{trigger:!1}),i.dispatch("BpmnProcess","create",{attributes:e,returnUrl:s})}.bind(this))}.bind(this))}})}),define("advanced:views/workflow-log-record/list",["views/list"],function(t){return t.extend({createButton:!1})}),define("advanced:views/workflow-log-record/record/list",["views/record/list"],function(t){return t.extend({massActionList:["remove"],rowActionsView:"views/record/row-actions/remove-only"})}),define("advanced:views/workflow-log-record/fields/target",["views/fields/link-parent"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.foreignScopeList=this.getMetadata().getScopeObjectList().sort((t,e)=>this.translate(t,"scopeNames").localeCompare(this.translate(e,"scopeNames")))}})}),define("advanced:views/workflow/list",["views/list-with-categories"],function(t){return t.extend({quickCreate:!1})}),define("advanced:views/workflow/record/list",["views/record/list"],function(t){return t.extend({massActionList:["remove","massUpdate","export"]})}),define("modules/advanced/views/workflow/record/edit",["exports","views/record/edit","modules/advanced/views/workflow/record/detail","modules/advanced/views/workflow/record/actions","modules/advanced/views/workflow/record/conditions"],function(t,e,i,s,a){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=n(e),i=n(i),s=n(s),a=n(a);class o extends e.default{bottomView="advanced:views/workflow/record/edit-bottom";sideView="advanced:views/workflow/record/edit-side";stickButtonsContainerAllTheWay=!0;saveAndContinueEditingAction=!0;fetch(){const t=super.fetch(),e=this.fetchConditions();for(const i in e)t[i]=e[i];const i=this.fetchActions();for(const e in i)t[e]=i[e];return t}fetchConditions(){const t={},e=this.getView("bottom").getView("conditions");let i={};return e instanceof a.default&&(i=e.fetch()),null===i||(t.conditionsAny=i.any||[],t.conditionsAll=i.all||[],t.conditionsFormula=i.formula||null),t}fetchActions(){const t={},e=this.getView("bottom").getView("actions");let i;return e instanceof s.default&&(i=e.fetch()),null!=i&&(t.actions=i),t}onChangeConditions(){const t=this.fetchConditions();this.model.set(t,{ui:!0})}onChangeActions(){const t=this.fetchActions();this.model.set(t,{ui:!0})}setup(){super.setup(),i.default.prototype.manageFieldsVisibility.call(this),this.listenTo(this.model,"change",(t,e)=>{(this.model.hasChanged("portalOnly")||this.model.hasChanged("type"))&&i.default.prototype.manageFieldsVisibility.call(this,e.ui)}),this.listenTo(this.model,"change:entityType",(t,e,i)=>{i.ui&&setTimeout(()=>{t.set({targetReportId:null,targetReportName:null})},100)}),this.model.isNew()||(this.setFieldReadOnly("type"),this.setFieldReadOnly("entityType")),this.listenTo(this.model,"change",()=>{if(!this.model.hasChanged("actions")&&!this.model.hasChanged("conditionsAll")&&!this.model.hasChanged("conditionsAny"))return;if(!this.model.isNew())return;const t=this.model.get("actions")||[],e=this.model.get("conditionsAll")||[],i=this.model.get("conditionsAny")||[];t.length||e.length||i.length?this.setFieldReadOnly("entityType"):this.setFieldNotReadOnly("entityType")})}}t.default=o}),define("advanced:views/workflow/record/edit-side",["views/record/edit-side"],function(t){return t.extend({panelList:[]})}),define("modules/advanced/views/workflow/record/detail-bottom",["exports","views/record/edit-bottom","modules/advanced/views/workflow/record/edit-bottom"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{editMode=!1;template="advanced:workflow/record/edit-bottom";setup(){super.setup(),"scheduled"!==this.model.get("type")&&"manual"!==this.model.get("type")||this.hideConditions(),this.createView("workflowLogRecords","views/record/panels/relationship",{model:this.model,selector:'.panel[data-name="workflowLogRecords"] .panel-body',panelName:"workflowLogRecords",defs:{create:!1,rowActionsView:"views/record/row-actions/remove-only"},recordHelper:this.recordHelper})}afterRender(){this.model.isNew()?this.model.get("entityType")&&(this.showConditions(),this.showActions()):(this.showConditions(),this.showActions()),super.afterRender()}showConditions(){i.default.prototype.showConditions.call(this)}showActions(){var t;null===(t=this.element.querySelector(".panel-actions"))||void 0===t||t.classList.remove("hidden"),this.createView("actions","advanced:views/workflow/record/actions",{model:this.model,selector:".actions-container",readOnly:!this.editMode},t=>{t.render()})}hideConditions(){if(!this.isRendered())return void this.once("after:render",()=>{this.hideConditions()});this.$el.find(".panel-conditions").addClass("hidden");const t=this.getView("conditions");t&&t.remove()}}t.default=a}),define("modules/advanced/views/workflow/record/conditions/group",["exports","view"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{templateContent='\n        <div class="items"></div>\n\n        {{#unless readOnly}}\n            <div class="buttons btn-group">\n                <a\n                    class="small dropdown-toggle"\n                    role="button"\n                    tabindex="0"\n                    data-toggle="dropdown"\n                    title="{{translate \'Add Condition\' scope=\'Workflow\'}}"\n                ><span class="fas fa-plus"></span> {{translate operator category=\'filtersGroupTypes\' scope=\'Report\'}}</a>\n                <ul class="dropdown-menu">\n                    <li><a\n                        data-cid="{{cid}}"\n                        data-action="addCondition"\n                        role="button"\n                        tabindex="0"\n                        title="{{translate \'Add field\' scope=\'Report\'}}"\n                    >{{translate \'Field\' scope=\'Report\'}}</a></li>\n\n                    {{#unless orDisabled}}\n                        <li><a\n                            data-cid="{{cid}}"\n                            data-action="addOr"\n                            role="button"\n                            tabindex="0"\n                            title="{{translate \'Add OR group\' scope=\'Report\'}}"\n                        >(... {{translate \'OR\' scope=\'Report\'}} ...)</a></li>\n                    {{/unless}}\n\n                    {{#unless andDisabled}}\n                        <li><a\n                            data-cid="{{cid}}"\n                            data-action="addAnd"\n                            role="button"\n                            tabindex="0"\n                            title="{{translate \'Add AND group\' scope=\'Report\'}}"\n                        >(... {{translate \'AND\' scope=\'Report\'}} ...)</a></li>\n                    {{/unless}}\n                </ul>\n            </div>\n        {{/unless}}\n    ';groupType="all";level=0;operator;data(){return{fieldList:this.fieldList,entityType:this.entityType,readOnly:this.readOnly,orDisabled:"any"===this.groupType||this.level>1,andDisabled:"all"===this.groupType||this.level>1,operator:this.operator,cid:this.cid}}afterRender(){(this.options.conditions||[]).forEach(t=>{!["or","and"].includes(t.type)||t.field?this.addCondition(t.fieldToCompare,t):this.addGroup(t)})}setup(){this.addHandler("click",`[data-cid="${this.cid}"][data-action="addCondition"]`,()=>{this.createView("dialog","advanced:views/workflow/modals/add-condition",{scope:this.entityType,createdEntitiesData:this.options.flowchartCreatedEntitiesData},t=>{t.render(),this.listenToOnce(t,"add-field",t=>{this.clearView("dialog"),this.addCondition(t,{},!0)})})}),this.addHandler("click",`[data-cid="${this.cid}"][data-action="addOr"]`,()=>this.addGroup({type:"or"})),this.addHandler("click",`[data-cid="${this.cid}"][data-action="addAnd"]`,()=>this.addGroup({type:"and"})),this.addHandler("click",`[data-cid="${this.cid}"][data-action="removeCondition"]`,(t,e)=>{const i=e.dataset.id;this.clearView(`condition-${i}`);const s=e.parentNode,a=s.nextSibling;a.parentNode.removeChild(a),s.parentNode.removeChild(s),this.trigger("change")}),this.entityType=this.options.entityType,"groupType"in this.options&&(this.groupType=this.options.groupType),"level"in this.options&&(this.level=this.options.level),this.operator="all"===this.groupType?"and":"or",this.readOnly=this.options.readOnly||!1;const t=this.getMetadata().get("entityDefs.Workflow.conditionFieldTypes")||{},e=this.getMetadata().get(`entityDefs.${this.entityType}.fields`)||{};this.fieldList=Object.keys(e).filter(i=>{const s=e[i].type||"base";if(!e[i].disabled&&!e[i].utility)return s in t}).sort((t,e)=>this.translate(t,"fields",this.scope).localeCompare(this.translate(e,"fields",this.scope))),this.lastCid=0}addGroup(t){t.value||(t.value=[]),this.addContainer(t);this.createView(`condition-${t.cid}`,"advanced:views/workflow/record/conditions/group",{groupType:"and"===t.type?"all":"any",level:this.level+1,selector:this.getItemSelector(t),conditions:t.value||[],isChangedDisabled:this.options.isChangedDisabled,entityType:this.entityType,model:this.model,flowchartCreatedEntitiesData:this.options.flowchartCreatedEntitiesData,readOnly:this.readOnly},t=>{t.render(),this.listenTo(t,"change",()=>{this.trigger("change")})})}addCondition(t,e,i){let s,a;e=e||{};let n,o,r,l=null,d=null,c=!1,h=null;if(t.includes("."))if(0===t.indexOf("created:")){c=!0;const e=t.split(".");if(n=e[1],r=e[0].substr(8),!this.options.flowchartCreatedEntitiesData||!this.options.flowchartCreatedEntitiesData[r])return;h=this.options.flowchartCreatedEntitiesData[r].entityType,l=this.options.flowchartCreatedEntitiesData[r].link,s=this.options.flowchartCreatedEntitiesData[r].numberId,a=this.getMetadata().get(["entityDefs",h,"fields",n,"type"])||"base"}else{const e=t.split(".");d=e[1],l=e[0],o=this.getMetadata().get(["entityDefs",this.entityType,"links",l,"entity"]),a=this.getMetadata().get(["entityDefs",o,"fields",d,"type"])||"base"}else a=this.getMetadata().get(["entityDefs",this.entityType,"fields",t,"type"])||"base";const u=this.getMetadata().get(`entityDefs.Workflow.conditionFieldTypes.${a}`)||"base";let p,f=t,m=this.entityType;if(c){let t=this.translate("Created","labels","Workflow")+" · ";l&&(t+=this.translate(l,"links",this.entityType)+" - "),t+=this.translate(h,"scopeNames");const e=this.options.flowchartCreatedEntitiesData[r].text;e?t+=" '"+e+"'":s&&(t+=" #"+s.toString()),p=t+" . "+this.translate(n,"fields",h),f=n,m=h}else l?(p=this.translate(l,"links",this.entityType)+" . "+this.translate(d,"fields",o),f=d,m=o):p=this.translate(t,"fields",this.entityType);this.addContainer(e,!0,p);const g=`advanced:views/workflow/conditions/${Espo.Utils.camelCaseToHyphen(u)}`;this.createView(`condition-${e.cid}`,g,{selector:this.getItemSelector(e),conditionData:e,model:this.model,field:t,entityType:h||this.entityType,originalEntityType:this.entityType,actualField:f,actualEntityType:m,type:u,fieldType:a,conditionType:this.groupType,isNew:i,readOnly:this.readOnly,isChangedDisabled:this.options.isChangedDisabled},t=>{if(t.render(),i){const e=t.$el.closest(".cell");e.addClass("has-error"),setTimeout(()=>e.removeClass("has-error"),1500),this.trigger("change")}this.listenTo(t,"change",()=>{this.trigger("change")})})}getItemSelector(t){return`> .items > .cell > .condition[data-id="${t.cid}"]`}addContainer(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;t.cid=this.lastCid,this.lastCid++;let s=null;i&&(s=document.createElement("label"),s.classList.add("field-label-name","control-label","small"),s.textContent=i);let a=null;this.readOnly||(a=document.createElement("a"),a.tabIndex=0,a.role="button",a.classList.add("pull-right"),a.dataset.cid=this.cid,a.dataset.action="removeCondition",a.dataset.id=t.cid.toString(),a.innerHTML='<span class="fas fa-times"></span>');const n=document.createElement("div");n.classList.add("cell"),n.dataset.role=e?"field-cell":"group-cell",a&&n.append(a),s&&n.append(s);const o=document.createElement("div");o.dataset.id=t.cid.toString(),o.classList.add("condition"),e&&o.classList.add("small"),n.append(o);const r=this.$el.find("> .items");r.append(n);const l=document.createElement("div");l.dataset.role="operator",l.textContent=this.translate(this.operator,"filtersGroupTypes","Report"),r.append(l)}fetch(){const t=[];for(let e=0;e<this.lastCid;e++){const i=this.getView(`condition-${e}`);if(!i)continue;let s=i.fetch();i.conditionType?s.type=i.conditionType:i.operator&&!i.field&&(s={type:i.operator,value:s}),t.push(s)}return t}}t.default=s}),define("advanced:views/workflow/modals/add-field",["views/modal"],function(t){return t.extend({templateContent:'<div class="field" data-name="field">{{{field}}}</div>',backdrop:!0,setup:function(){this.headerText=this.translate("Add Field","labels","Workflow");const t=this.scope=this.options.scope,e=this.options.fieldList;this.wait(!0),this.getModelFactory().create("Workflow",i=>{i.targetEntityType=t,this.createView("field","advanced:views/workflow/fields/action-field",{selector:'.field[data-name="field"]',model:i,mode:"edit",name:"field",params:{options:["",...this.options.fieldList],isSorted:!0},translatedOptions:e.reduce((e,i)=>(e[i]=this.translate(i,"fields",t),e),{})},t=>{this.listenTo(t,"change",()=>{this.trigger("add",i.get("field")),this.close()})}),this.wait(!1)})}})}),define("advanced:views/workflow/modals/add-condition",["views/modal"],function(t){return t.extend({templateContent:'<div class="field" data-name="conditionFields">{{{field}}}</div>',backdrop:!0,events:{'click a[data-action="addField"]':function(t){this.trigger("add-field",$(t.currentTarget).data().name)}},setup:function(){this.headerText=this.translate("Add Condition","labels","Workflow");const t=this.scope=this.options.scope;this.wait(!0),this.getModelFactory().create("Workflow",e=>{e.targetEntityType=t,this.createView("field","advanced:views/workflow/fields/condition-fields",{selector:".field",model:e,mode:"edit",createdEntitiesData:this.options.createdEntitiesData,defs:{name:"conditionFields",params:{}}},t=>{this.listenTo(t,"change",()=>{const t=e.get("conditionFields")||[];t.length&&this.trigger("add-field",t[0])})}),this.wait(!1)})}})}),define("advanced:views/workflow/modals/add-action",["views/modal"],t=>class extends t{templateContent='\n            <div class="margin-bottom-2x margin-top">\n                <input\n                    type="text"\n                    maxlength="64"\n                    placeholder="{{translate \'Search\'}}"\n                    data-name="quick-search"\n                    class="form-control"\n                    spellcheck="false"\n                >\n            </div>\n            <ul class="list-group list-group-panel array-add-list-group no-side-margin">\n            {{#each itemList}}\n                <li class="list-group-item" data-name="{{name}}">\n                    <a\n                        role="button"\n                        tabindex="0"\n                        class="text-bold"\n                        data-action="add"\n                        data-name="{{name}}"\n                    >{{label}}</a>\n                </li>\n            {{/each}}\n            </ul>\n            <div class="no-data hidden">{{translate \'No Data\'}}</div>\n        ';backdrop=!0;data(){return{itemList:this.actionDataList}}setup(){this.headerText=this.translate("Add Action","labels","Workflow"),this.addActionHandler("add",(t,e)=>this.actionAdd(e.dataset.name)),this.addHandler("keyup",'input[data-name="quick-search"]',(t,e)=>this.processQuickSearch(e.value)),this.actionList=this.options.actionList,this.actionDataList=this.getDataList()}afterRender(){this.element&&(this.noDataElement=this.element.querySelector(".no-data"),this.quickSearchInputElement=this.element.querySelector('input[data-name="quick-search"]'),this.itemElements=[...this.element.querySelectorAll("ul > li.list-group-item")],setTimeout(()=>this.quickSearchInputElement.focus(),100))}getDataList(){return this.actionList.map(t=>({name:t,label:this.translate(t,"actionTypes","Workflow")})).sort((t,e)=>t.label.localeCompare(e.label))}actionAdd(t){this.trigger("add",t),this.close()}processQuickSearch(t){if(t=t.trim().toLowerCase(),this.noDataElement.classList.add("hidden"),!t)return void this.itemElements.forEach(t=>t.classList.remove("hidden"));const e=[];if(this.actionDataList.forEach(i=>{const s=i.label.toLowerCase();for(const a of s.split(" ")){if(0===a.indexOf(t))return void e.push(i)}}),0===e.length)return this.itemElements.forEach(t=>t.classList.add("hidden")),void this.noDataElement.classList.remove("hidden");this.actionDataList.forEach(t=>{const i=this.itemElements.find(e=>e.dataset.name===t.name);e.includes(t)?i.classList.remove("hidden"):i.classList.add("hidden")})}}),define("advanced:views/workflow/fields/workflow",["views/fields/link"],function(t){return t.extend({createDisabled:!0,getSelectFilters:function(){var t={type:{type:"in",value:["sequential"]}};return this.options.entityType&&(t.entityType={type:"in",value:[this.options.entityType]}),t}})}),define("advanced:views/workflow/fields/target-user-position",["views/fields/enum"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.translatedOptions={"":"--"+this.translate("All")+"--"},this.params.options=[""],this.model.get("targetUserPosition")&&this.model.get("targetTeamId")&&this.params.options.push(this.model.get("targetUserPosition")),this.loadRoleList(()=>{"edit"===this.mode&&this.isRendered()&&this.render()}),this.listenTo(this.model,"change:targetTeamId",()=>{this.loadRoleList(()=>{this.render()})})},loadRoleList:function(t,e){var i=this.model.get("targetTeamId");i||(this.params.options=[""]),this.getModelFactory().create("Team",s=>{s.id=i,this.listenToOnce(s,"sync",()=>{this.params.options=s.get("positionList")||[],this.params.options.unshift(""),t.call(e)}),s.fetch()})}})}),define("advanced:views/workflow/fields/target-report",["views/fields/link"],function(t){return t.extend({selectPrimaryFilterName:"list",createDisabled:!0,getSelectFilters:function(){var t=this.model.get("entityType");if(t)return{entityType:{type:"equals",value:[t]}}}})}),define("modules/advanced/views/workflow/fields/scheduling",["exports","views/fields/varchar"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};let s=!1;class a extends e.default{setup(){super.setup(),(this.isEditMode()||this.isDetailMode())&&this.wait(this.loadCronstrue())}loadCronstrue(){return s?(this.Cronstrue=null,Promise.resolve()):new Promise(t=>{Espo.loader.requirePromise("lib!cronstrue").then(e=>{this.Cronstrue=e,this.listenTo(this.model,"change:"+this.name,()=>this.showText()),t()}).catch(()=>{s=!0,this.Cronstrue=null,t()})})}afterRender(){if(super.afterRender(),this.isEditMode()||this.isDetailMode()){const t=this.$text=$('<div class="small text-success"/>');this.$el.append(t),this.showText()}}showText(){if(!this.$text||!this.$text.length)return;if(!this.Cronstrue)return;const t=this.model.get(this.name);if(!t)return void this.$text.text("");if("* * * * *"===t)return void this.$text.text(this.translate("As often as possible","labels","ScheduledJob"));let e="en";const i=Object.keys(this.Cronstrue.default.locales),s=this.getLanguage().name;let a;i.includes(s)?e=s:i.includes(s.split("_")[0])&&(e=s.split("_")[0]);try{a=this.Cronstrue.toString(t,{use24HourTimeFormat:!this.getDateTime().hasMeridian(),locale:e})}catch(t){a=this.translate("Not valid")}this.$text.text(a)}}t.default=a}),define("advanced:views/workflow/fields/request-headers",["views/fields/array"],function(t){return t.extend({maxItemLength:1e4})}),define("advanced:views/workflow/fields/process-start-element-id",["views/fields/enum"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.listenTo(this.model,"change:startElementNames",function(t,e){this.translatedOptions=e}),this.listenTo(this.model,"change:startElementIdList",function(t,e){this.params.options=e||[],this.reRender()}),this.listenTo(this.model,"change:target",function(t,e){this.params.options=[],this.reRender()})}})}),define("advanced:views/workflow/fields/manual-dynamic-logic",["views/admin/field-manager/fields/dynamic-logic-conditions"],function(t){return t.extend({setupEntityType:function(){this.options.scope=this.scope=this.model.get("entityType"),this.listenTo(this.model,"change:entityType",()=>{this.options.scope=this.scope=this.model.get("entityType"),this.scope&&this.createStringView()})},setup:function(){this.addActionHandler("editConditions",()=>this.edit()),this.setupEntityType(),this.conditionGroup=Espo.Utils.cloneDeep((this.model.get(this.name)||{}).conditionGroup||[]),this.createStringView()}})}),define("advanced:views/workflow/fields/list-report",["views/fields/link"],function(t){return t.extend({selectPrimaryFilterName:"list",createDisabled:!0,getSelectFilters:function(){var t=this.model.targetEntityType;if(t)return{entityType:{type:"equals",value:[t]}}}})}),define("advanced:views/workflow/fields/help-text",["views/fields/text"],function(t){return t.extend({createDisabled:!0,detailTemplate:"advanced:workflow/fields/help-text/detail"})}),define("advanced:views/workflow/fields/flowchart",["views/fields/link"],function(t){return t.extend({selectPrimaryFilterName:"active",createDisabled:!0,setup:function(){t.prototype.setup.call(this),this.targetEntityType=this.options.targetEntityType,this.listenTo(this.model,"change-target-entity-type",function(t){this.targetEntityType=t})},select:function(e){var i=e.get("elementsDataHash")||{},s={};(e.get("eventStartAllIdList")||[]).forEach(function(t){var e=i[t];if(e){var a=e.text||t;a=this.translate(e.type,"elements","BpmnFlowchart")+" · "+a,s[t]=a}},this),this.model.set("startElementNames",s),this.model.set("startElementIdList",e.get("eventStartAllIdList")),t.prototype.select.call(this,e)},getSelectFilters:function(){if(this.targetEntityType)return{targetType:{type:"in",value:[this.targetEntityType]}}}})}),define("advanced:views/workflow/fields/entity-type",["views/fields/enum"],function(t){return t.extend({entityListToIgnore:[],setup:function(){var e=this.getMetadata().get("scopes"),i=this.getMetadata().get("entityDefs.Workflow.entityListToIgnore")||[],s=this.getMetadata().get("entityDefs.Workflow.forcedSupportEntityList")||[];this.params.options=Object.keys(e).filter(t=>{if(!~i.indexOf(t)){var a=e[t];return a.entity&&(a.tab||a.object||a.workflow||~s.indexOf(t))}}).sort((t,e)=>this.translate(t,"scopeNamesPlural").localeCompare(this.translate(e,"scopeNamesPlural"))),this.params.options.unshift(""),this.params.translation="Global.scopeNames",t.prototype.setup.call(this)}})}),define("advanced:views/workflow/fields/condition-fields",["views/fields/multi-enum"],function(t){return t.extend({getItemList:function(){const t=this.model.targetEntityType,e=this.getMetadata().get("entityDefs.Workflow.conditionFieldTypes")||{},i=this.getMetadata().get(`entityDefs.${t}.fields`),s=Object.keys(i).filter(t=>{if(i[t].type&&i[t].type in e&&!i[t].disabled&&!i[t].utility&&!i[t].workflowConditionDisabled&&(!i[t].directAccessDisabled||i[t].loaderClassName))return!0});s.sort((e,i)=>this.translate(e,"fields",t).localeCompare(this.translate(i,"fields",t)));const a=this.getMetadata().get(`entityDefs.${t}.links`)||{};if(Object.keys(a).sort((e,i)=>this.translate(e,"links",t).localeCompare(this.translate(i,"links",t))).forEach(t=>{if("belongsTo"!==a[t].type)return;if(a[t].disabled||a[t].utility)return!1;const i=a[t].entity;if(!i)return;const n=this.getMetadata().get(`entityDefs.${i}.fields`)||{},o=Object.keys(n).filter(t=>{if(n[t].type&&n[t].type in e&&!n[t].disabled&&!n[t].utility&&!n[t].workflowConditionDisabled&&(!n[t].directAccessDisabled||n[t].loaderClassName))return!0});o.sort((t,e)=>this.translate(t,"fields",i).localeCompare(this.translate(e,"fields",i))),o.forEach(e=>{s.push(`${t}.${e}`)})}),this.options.createdEntitiesData){const t=Object.keys(this.options.createdEntitiesData);t.sort((t,e)=>{const i=this.options.createdEntitiesData[t].entityType||"",s=this.options.createdEntitiesData[e].entityType||"";return this.translate(i,"scopeNames").localeCompare(this.translate(s,"scopeNames"))}),t.forEach(t=>{const i=this.options.createdEntitiesData[t].entityType,a=this.getMetadata().get(["entityDefs",i,"fields"])||{},n=Object.keys(a).filter(t=>{const i=a[t];if(i.type&&i.type in e&&!i.disabled&&!i.workflowConditionDisabled)return!0});n.sort((t,e)=>this.translate(t,"fields",i).localeCompare(this.translate(e,"fields",i))),n.forEach(e=>{s.push(`created:${t}.${e}`)})})}return s},setupTranslatedOptions:function(){this.translatedOptions={};const t=this.model.targetEntityType;this.params.options.forEach(e=>{let i,s,a,n=e,o=t,r=!1,l=!1;if(~e.indexOf("."))if(0===e.indexOf("created:")){l=!0,n=e.split(".")[1];const t=e.split(".")[0].substr(8);o=this.options.createdEntitiesData[t].entityType,a=this.options.createdEntitiesData[t].numberId,i=this.options.createdEntitiesData[t].link,s=this.options.createdEntitiesData[t].text}else r=!0,n=e.split(".")[1],i=e.split(".")[0],o=this.getMetadata().get(`entityDefs.${t}.links.${i}.entity`);if(this.translatedOptions[e]=this.translate(n,"fields",o),r)this.translatedOptions[e]=this.translate(i,"links",t)+" . "+this.translatedOptions[e];else if(l){let n=this.translate("Created","labels","Workflow")+" · ";i&&(n+=this.translate(i,"links",t)+" - "),n+=this.translate(o,"scopeNames"),s?n+=" '"+s+"'":a&&(n+=" #"+a.toString()),this.translatedOptions[e]=n+" . "+this.translatedOptions[e]}})},setupOptions:function(){t.prototype.setupOptions.call(this),this.params.options=this.getItemList(),this.setupTranslatedOptions()},afterRender:function(){t.prototype.afterRender.call(this),this.$element&&this.$element[0]&&this.$element[0].selectize&&this.$element[0].selectize.focus()}})}),define("advanced:views/workflow/fields/action-field",["views/fields/enum"],function(t){return t.extend({afterRender:function(){t.prototype.afterRender.call(this);try{this.focusOnInlineEdit()}catch(t){console.error(t)}}})}),define("advanced:views/workflow/field-definitions/date",["advanced:views/workflow/field-definitions/base"],function(t){return t.extend({template:"advanced:workflow/field-definitions/date",defaultFieldData:{subjectType:"today",shiftDays:0,attributes:{}},subjectTypeList:["today","field"],setup:function(){t.prototype.setup.call(this),this.createView("shiftDays","advanced:views/workflow/action-fields/shift-days",{selector:".shift-days",value:this.fieldData.shiftDays,unitValue:this.fieldData.shiftUnit,readOnly:this.readOnly,isDate:"date"===this.fieldType})},getSubjectTranslatedOptions:function(){const e=t.prototype.getSubjectTranslatedOptions.call(this);if("date"!==this.fieldType)return e.today=this.translate("now","labels","Workflow"),e;e.today=this.translate("today","labels","Workflow")},handleSubjectType:function(){const t=this.fieldData.subjectType;if("field"===t)return this.createView("subject","advanced:views/workflow/action-fields/subjects/field",{selector:".subject",model:this.model,entityType:this.entityType,scope:this.scope,field:this.field,value:this.fieldData.field,readOnly:this.readOnly},t=>{t.render()}),void this.$el.find(".subject").removeClass("hidden");this.$el.find(".subject").addClass("hidden"),"today"===t&&this.clearView("subject")},fetch:function(){const t=this.getView("shiftDays").fetch();return this.fieldData.shiftDays=t.value,this.fieldData.shiftUnit=t.unit,"field"===this.fieldData.subjectType&&(this.fieldData.field=this.getView("subject").fetchValue()),!0}})}),define("advanced:views/workflow/field-definitions/fields/duration",["views/fields/base","model"],function(t,e){return t.extend({detailTemplateContent:'\n            <span data-name="value">{{{valueField}}}</span>\n            <span data-name="unit">{{{unitField}}}</span>\n        ',editTemplateContent:'\n            <div class="row">\n                <div data-name="value" class="col-sm-6">{{{valueField}}}</div>\n                <div data-name="unit" class="col-sm-6">{{{unitField}}}</div>\n            </div>\n        ',setup:function(){this.subModel=new e,this.subModel.setDefs({fields:{unit:{type:"enum",options:["m","h","d"],translation:"Global.options.durationUnits"},value:{type:"int",min:0}}}),this.syncModels(),this.listenTo(this.model,"change:duration",(t,e,i)=>{i.ui||this.syncModels()}),this.listenTo(this.subModel,"change",(t,e)=>{e.ui&&this.trigger("change")})},prepare:function(){const t=this.createView("unitField","views/fields/enum",{name:"unit",model:this.subModel,mode:this.mode,selector:'[data-name="unit"]',readOnly:"detail"===this.mode}),e=this.createView("valueField","views/fields/int",{name:"value",model:this.subModel,mode:this.mode,selector:'[data-name="value"]',readOnly:"detail"===this.mode});return Promise.all([t,e])},syncModels:function(){let t,e=this.model.attributes.duration||0;e%86400==0?(t="d",e=Math.floor(e/86400)):e%3600==0?(t="h",e=Math.floor(e/3600)):(t="m",e=Math.floor(e/60)),this.subModel.set({value:e,unit:t})},fetch:function(){let t=this.subModel.attributes.value;t||(t=0);const e=this.subModel.attributes.unit;return t*="d"===e?86400:"h"===e?3600:60,{[this.name]:t}}})}),define("advanced:views/workflow/conditions/varchar",["advanced:views/workflow/conditions/base"],function(t){return t.extend({template:"advanced:workflow/conditions/base",defaultConditionData:{comparison:"equals",subjectType:"value"},comparisonList:["equals","notEquals","wasEqual","wasNotEqual","isEmpty","notEmpty","changed","notChanged","contains","notContains"],data:function(){return _.extend({},t.prototype.data.call(this))}})}),define("advanced:views/workflow/conditions/text",["advanced:views/workflow/conditions/base"],function(t){return t.extend({template:"advanced:workflow/conditions/base",defaultConditionData:{comparison:"notEmpty"},comparisonList:["notEmpty","isEmpty","changed","notChanged","contains","notContains"],data:function(){return _.extend({},t.prototype.data.call(this))}})}),define("advanced:views/workflow/conditions/multi-enum",["advanced:views/workflow/conditions/base"],function(t){return t.extend({template:"advanced:workflow/conditions/base",defaultConditionData:{comparison:"true"},comparisonList:["true","false","changed","notChanged"],data:function(){return _.extend({},t.prototype.data.call(this))}})}),define("modules/advanced/views/workflow/conditions/link",["exports","modules/advanced/views/workflow/conditions/base"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{template="advanced:workflow/conditions/base";defaultConditionData={comparison:"notEmpty"};comparisonList=["notEmpty","isEmpty","equals","notEquals","changed","notChanged"];setupComparisonList(){if(super.setupComparisonList(),"image"===this.fieldType||"file"===this.fieldType){const t=[];Espo.Utils.clone(this.comparisonList).forEach(e=>{["equals","notEquals","wasEqual","wasNotEqual"].includes(e)||t.push(e)}),this.comparisonList=t}}getSubjectInputViewName(t){return"advanced:views/workflow/condition-fields/subjects/link"}}t.default=s}),define("advanced:views/workflow/conditions/link-parent",["advanced:views/workflow/conditions/base"],function(t){return t.extend({template:"advanced:workflow/conditions/base",defaultConditionData:{comparison:"notEmpty"},comparisonList:["notEmpty","isEmpty","equals","notEquals","changed","notChanged"],data:function(){return _.extend({},t.prototype.data.call(this))},fetch:function(){return delete this.conditionData.fieldValueMap,delete this.conditionData.valueName,delete this.conditionData.valueType,t.prototype.fetch.call(this)},getSubjectInputViewName:function(t){return"advanced:views/workflow/condition-fields/subjects/link-parent"},handleSubjectType:function(e,i){i||this.clearView("subject"),"typeOf"!==e?t.prototype.handleSubjectType.call(this,e,i):this.createView("subject","advanced:views/workflow/condition-fields/subjects/link-parent-is-type-of",{selector:".subject",entityType:this.entityType,field:this.field,value:this.getSubjectValue(),conditionData:this.conditionData,readOnly:this.readOnly},t=>{t.render(()=>{i||this.fetch()})})},handleComparison:function(e,i){if(i||this.clearView("subjectType"),"equals"===e||"notEquals"===e)return this.$el.find(".subject").empty(),void this.createView("subjectType","advanced:views/workflow/condition-fields/subject-type-parent",{selector:".subject-type",value:this.conditionData.subjectType,readOnly:this.readOnly},t=>{t.render().then(()=>{i||this.fetch(),this.handleSubjectType(this.conditionData.subjectType,i)}),this.listenTo(t,"change",t=>{this.setSubjectType(t),this.handleSubjectType(t)})});t.prototype.handleComparison.call(this,e,i)}})}),define("advanced:views/workflow/conditions/enum",["advanced:views/workflow/conditions/base"],t=>class extends t{template="advanced:workflow/conditions/enum";defaultConditionData={comparison:"equals",subjectType:"value"};comparisonList=["equals","notEquals","anyOf","noneOf","wasEqual","wasNotEqual","isEmpty","notEmpty","changed","notChanged"];setupComparisonList(){super.setupComparisonList(),"enum"!==this.fieldType&&(this.comparisonList=this.comparisonList.filter(t=>!["anyOf","noneOf"].includes(t)))}getSubjectInputViewName(){return"enum"===this.fieldType&&["anyOf","noneOf"].includes(this.conditionData.comparison)?"advanced:views/workflow/condition-fields/subjects/enum-multiple":"advanced:views/workflow/condition-fields/subjects/enum-input"}}),define("advanced:views/workflow/conditions/decimal",["advanced:views/workflow/conditions/int"],function(t){return t.extend({template:"advanced:workflow/conditions/base",comparisonList:["equals","notEquals","greaterThan","lessThan","greaterThanOrEquals","lessThanOrEquals","wasEqual","wasNotEqual","isEmpty","notEmpty","changed","notChanged"],fetchSubject:function(){switch(delete this.conditionData.value,delete this.conditionData.field,this.conditionData.subjectType){case"field":this.fetchSubjectField();break;case"value":const t=this.getView("subject");t&&(this.conditionData.value=t.fetch().value)}},getSubjectInputViewName:function(){return"advanced:views/workflow/condition-fields/subjects/decimal"}})}),define("advanced:views/workflow/conditions/date",["advanced:views/workflow/conditions/base"],function(t){return t.extend({template:"advanced:workflow/conditions/date",comparisonList:["on","before","after","today","beforeToday","afterToday","isEmpty","notEmpty","changed","notChanged"],defaultConditionData:{comparison:"on",subjectType:"today",shiftDays:0},afterRender:function(){t.prototype.afterRender.call(this),this.handleShiftDays(this.conditionData.shiftDays,!0)},handleComparison:function(e,i){switch(t.prototype.handleComparison.call(this,e,i),e){case"on":case"before":case"after":this.$el.find(".subject").empty(),this.createView("subjectType","advanced:views/workflow/condition-fields/subject-type-date",{selector:".subject-type",value:this.conditionData.subjectType,readOnly:this.readOnly},t=>{t.render().then(()=>{i||this.fetch(),this.handleSubjectType(this.conditionData.subjectType,i)}),this.listenTo(t,"change",t=>{this.setSubjectType(t),this.handleSubjectType(t)})}),this.createView("shiftDays","advanced:views/workflow/condition-fields/shift-days",{selector:".shift-days",entityType:this.entityType,field:this.field,value:this.conditionData.shiftDays||0,readOnly:this.readOnly},t=>{t.render(()=>{i||(this.fetch(),this.handleShiftDays(this.conditionData.subject))})});break;default:this.$el.find(".shift-days").empty()}},fetch:function(){return t.prototype.fetch.call(this),this.fetchShiftDays(),this.conditionData},fetchShiftDays:function(){const t=this.getView("shiftDays");if(!t)return;const e=t.fetch();this.conditionData.shiftDays=e.value},handleShiftDays:function(t,e){e||this.fetch()}})}),define("advanced:views/workflow/conditions/currency",["advanced:views/workflow/conditions/float"],function(t){return t.extend({template:"advanced:workflow/conditions/base",fetchSubject:function(){switch(delete this.conditionData.value,delete this.conditionData.field,this.conditionData.subjectType){case"field":this.fetchSubjectField();break;case"value":const t=this.getView("subject");t&&(this.conditionData.value=t.fetch().value)}},getSubjectInputViewName:function(){return"advanced:views/workflow/condition-fields/subjects/currency"}})}),define("advanced:views/workflow/conditions/bool",["advanced:views/workflow/conditions/base"],function(t){return t.extend({template:"advanced:workflow/conditions/base",defaultConditionData:{comparison:"true"},comparisonList:["true","false","changed","notChanged"],data:function(){return _.extend({},t.prototype.data.call(this))}})}),define("advanced:views/workflow/conditions/attachment-multiple",["advanced:views/workflow/conditions/link-multiple"],function(t){return t.extend({defaultConditionData:{comparison:"notEmpty"},comparisonList:["notEmpty","isEmpty","changed","notChanged"]})}),define("advanced:views/workflow/conditions/array",["advanced:views/workflow/conditions/base"],function(t){return t.extend({template:"advanced:workflow/conditions/enum",defaultConditionData:{comparison:"notEmpty",subjectType:"value"},comparisonList:["notEmpty","isEmpty","has","notHas","changed","notChanged"],data:function(){return _.extend({},t.prototype.data.call(this))},getSubjectInputViewName:function(t){return(this.getMetadata().get(["entityDefs",this.options.actualEntityType,"fields",this.options.actualField,"options"])||[]).length?"advanced:views/workflow/condition-fields/subjects/enum-input":"advanced:views/workflow/condition-fields/subjects/text-input"}})}),define("advanced:views/workflow/condition-fields/subject-type-parent",["advanced:views/workflow/condition-fields/subject-type"],function(t){return t.extend({list:["value","field","typeOf"]})}),define("advanced:views/workflow/condition-fields/subject-type-date",["advanced:views/workflow/condition-fields/subject-type"],function(t){return t.extend({list:["today","field"]})}),define("advanced:views/workflow/condition-fields/shift-days",["view","model"],function(t,e){return t.extend({template:"advanced:workflow/condition-fields/shift-days",data:function(){return{shiftDaysOperator:this.shiftDaysOperator,value:this.value,readOnly:this.readOnly}},setup:function(){this.value=this.options.value,this.readOnly=this.options.readOnly;const t=this.value;this.value<0?(this.shiftDaysOperator="minus",this.value=-1*this.value):this.shiftDaysOperator="plus",this.readOnly||(this.formModel=new e,this.formModel.name="Dummy",this.formModel.set({operator:t<0?"minus":"plus",value:t<0?-1*t:t}),this.createView("operatorField","views/fields/enum",{name:"operator",selector:'[data-field="operator"]',model:this.formModel,mode:"edit",params:{options:["plus","minus"]},translatedOptions:{plus:"+",minus:"-"}}),this.createView("valueField","views/fields/int",{name:"value",selector:'[data-field="value"]',model:this.formModel,mode:"edit",min:0}))},fetch:function(){let t=this.formModel.attributes.value;return"minus"===this.formModel.attributes.operator&&(t*=-1),{value:t,unit:"days"}},afterRender:function(){this.$el.find(".selectize-control").addClass("input-sm").addClass("radius-left"),this.$el.find("input.main-element").addClass("input-sm"),this.$el.find(".input-group-addon").addClass("input-sm").css({userSelect:"none",overflow:"hidden",textOverflow:"ellipsis"})}})}),define("modules/advanced/views/workflow/condition-fields/subjects/text-input",["exports","view"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{template="advanced:workflow/condition-fields/subjects/text-input";data(){return{value:this.options.value,readOnly:this.options.readOnly}}setup(){this.addHandler("change","input",()=>{this.trigger("change")})}}t.default=s}),define("modules/advanced/views/workflow/condition-fields/subjects/link",["exports","view","modules/advanced/workflow-helper"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{templateContent='\n        <div\n            class="field-container"\n            style="display: inline-block; width: 100%"\n        >{{{field}}}</div>\n    ';data(){return{field:this.options.field,value:this.options.value,entityType:this.options.entityType,readOnly:this.options.readOnly}}setup(){this.field=this.options.field,this.entityType=this.options.entityType,this.conditionData=this.options.conditionData||{},this.wait(!0);const t=new i.default,e=t.getComplexFieldEntityType(this.field,this.entityType);this.realField=t.getComplexFieldFieldPart(this.field),this.idName=this.realField+"Id",this.nameName=this.realField+"Name",this.getModelFactory().create(e,t=>{t.set(this.idName,this.conditionData.value||null),t.set(this.nameName,this.conditionData.valueName||null),this.createView("field","views/fields/link",{selector:".field-container",mode:"edit",model:t,readOnly:this.options.readOnly,readOnlyDisabled:!this.options.readOnly,inlineEditDisabled:this.options.readOnly,name:this.realField}).then(t=>{!this.options.readOnly&&t.readOnly&&(t.readOnlyLocked=!1,t.readOnly=!1,t.setMode("edit"),t.reRender()),this.listenTo(t,"change",()=>this.trigger("change")),this.wait(!1)})})}afterRender(){this.$el.find("input").addClass("input-sm"),this.$el.find(".btn").addClass("btn-sm")}fetch(){const t=this.getView("field").fetch();return{value:t[this.idName],valueName:t[this.nameName]}}}t.default=a}),define("modules/advanced/views/workflow/condition-fields/subjects/link-parent",["exports","view","modules/advanced/workflow-helper"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{templateContent='\n        <div\n            class="field-container"\n            style="display: inline-block"\n        >{{{field}}}</div>\n    ';data(){return{field:this.options.field,value:this.options.value,entityType:this.options.entityType,readOnly:this.options.readOnly}}setup(){this.field=this.options.field,this.entityType=this.options.entityType,this.conditionData=this.options.conditionData||{};const t=new i.default,e=t.getComplexFieldEntityType(this.field,this.entityType),s=t.getComplexFieldFieldPart(this.field);this.realField=s,this.idName=this.realField+"Id",this.nameName=this.realField+"Name",this.typeName=this.realField+"Type",this.wait(!0),this.getModelFactory().create(e,t=>{t.set(this.idName,this.conditionData.value||null),t.set(this.nameName,this.conditionData.valueName||null),t.set(this.typeName,this.conditionData.valueType||null);let i=this.getMetadata().get(["entityDefs",e,"fields",s,"entityList"])||[];i.length||(i=Object.keys(this.getMetadata().get(["scopes"])).filter(t=>!!this.getMetadata().get(["scopes",t,"object"])),i.push("CampaignTrackingUrl"),i=i.sort((t,e)=>this.translate(t,"scopeNames").localeCompare(this.translate(e,"scopeNames")))),this.createView("field","views/fields/link-parent",{selector:" .field-container",mode:"edit",model:t,readOnly:this.options.readOnly,readOnlyDisabled:!this.options.readOnly,inlineEditDisabled:this.options.readOnly,name:this.realField,foreignScopeList:i}).then(t=>{!this.options.readOnly&&t.readOnly&&(t.readOnlyLocked=!1,t.readOnly=!1,t.setMode("edit"),t.reRender()),this.listenTo(t,"change",()=>this.trigger("change")),this.wait(!1)})})}afterRender(){this.$el.find("input.form-control").addClass("input-sm"),this.$el.find("select").addClass("input-sm"),this.$el.find(".btn").addClass("btn-sm"),this.$el.find(".selectize-control").addClass("input-sm")}fetch(){const t=this.getView("field").fetch(),e={};return e[this.idName]=t[this.idName],e[this.typeName]=t[this.typeName],{value:t[this.idName],valueName:t[this.nameName],valueType:t[this.typeName],fieldValueMap:e}}}t.default=a}),define("advanced:views/workflow/condition-fields/subjects/link-parent-is-type-of",["view","advanced:workflow-helper"],function(t,e){return t.extend({templateContent:'\n            <div\n                class="field-container"\n                style="display: inline-block; min-width: 70%;"\n            >{{{field}}}</div>\n        ',data:function(){return{list:this.getMetadata().get(`entityDefs.${this.options.entityType}.fields.${this.options.field}.options`)||[],field:this.options.field,value:this.options.value,entityType:this.options.entityType,readOnly:this.options.readOnly}},setup:function(){t.prototype.setup.call(this),this.field=this.options.field,this.entityType=this.options.entityType,this.conditionData=this.options.conditionData||{};const i=new e(this.getMetadata()),s=i.getComplexFieldEntityType(this.field,this.entityType),a=i.getComplexFieldFieldPart(this.field);this.realField=a,this.typeName=this.realField+"Type";let n=this.getMetadata().get(["entityDefs",s,"fields",a,"entityList"])||[];this.wait(!0),this.getModelFactory().create(s).then(t=>{t.set(this.typeName,this.conditionData.valueType),n.length||(n=Object.keys(this.getMetadata().get(["scopes"])).filter(t=>!!this.getMetadata().get(["scopes",t,"object"])),n.push("CampaignTrackingUrl"),n=n.sort((t,e)=>this.translate(t,"scopeNames").localeCompare(this.translate(e,"scopeNames")))),this.createView("field","views/fields/enum",{selector:".field-container",mode:"edit",model:t,readOnly:this.options.readOnly,readOnlyDisabled:!this.options.readOnly,inlineEditDisabled:this.options.readOnly,defs:{name:this.typeName},params:{options:n,translation:"Global.scopeNames"}},t=>{!this.options.readOnly&&t.readOnly&&(t.readOnlyLocked=!1,t.readOnly=!1,t.setMode("edit"),t.reRender()),this.wait(!1)}),this.listenTo(t,"change",(t,e)=>{e.ui&&this.trigger("change")})})},afterRender:function(){t.prototype.afterRender.call(this),this.$el.find("select").addClass("input-sm"),this.$el.find(".selectize-control").addClass("input-sm")},fetch:function(){const t=this.getView("field").fetch(),e={};return e[this.typeName]=t[this.typeName],{valueId:null,valueName:null,valueType:t[this.typeName],fieldValueMap:e}}})}),define("advanced:views/workflow/condition-fields/subjects/int",["view","model"],function(t,e){return t.extend({templateContent:'<span data-field="value">{{{valueField}}}</span>',setup:function(){this.readOnly=this.options.readOnly,this.field=this.options.field,this.entityType=this.options.entityType,this.conditionData=this.options.conditionData||{};const t=this.formModel=new e;t.name="Dummy",t.set({value:this.conditionData.value}),this.createView("valueField","views/fields/int",{selector:'[data-field="value"]',mode:this.readOnly?"detail":"edit",model:t,name:"value"}),this.listenTo(t,"change",(t,e)=>{e.ui&&this.trigger("change")})},afterRender:function(){this.$el.find("input").addClass("input-sm")},fetch:function(){return{value:this.formModel.attributes.value}}})}),define("advanced:views/workflow/condition-fields/subjects/float",["view","model"],function(t,e){return t.extend({templateContent:'<span data-field="value">{{{valueField}}}</span>',setup:function(){this.readOnly=this.options.readOnly,this.field=this.options.field,this.entityType=this.options.entityType,this.conditionData=this.options.conditionData||{};const t=this.formModel=new e;t.name="Dummy",t.set({value:this.conditionData.value}),this.createView("valueField","views/fields/float",{selector:'[data-field="value"]',mode:this.readOnly?"detail":"edit",model:t,name:"value"}),this.listenTo(t,"change",(t,e)=>{e.ui&&this.trigger("change")})},afterRender:function(){this.$el.find("input").addClass("input-sm")},fetch:function(){return{value:this.formModel.attributes.value}}})}),define("advanced:views/workflow/condition-fields/subjects/field",["view","advanced:workflow-helper","model"],function(t,e,i){return t.extend({template:"advanced:workflow/condition-fields/subjects/field",data:function(){return{value:this.options.value,entityType:this.options.entityType,listHtml:this.listHtml,readOnly:this.readOnly}},setup:function(){this.readOnly=this.options.readOnly,this.fieldType=this.options.fieldType,this.field=this.options.field;const t=this.entityType=this.options.entityType;let e=this.value=this.options.value;if(this.readOnly){if(~e.indexOf(".")){const i=e.split("."),s=this.getMetadata().get(`entityDefs.${t}.links.${i[0]}.entity`)||t;this.listHtml=this.translate(i[0],"links",t)+" . "+this.translate(i[1],"fields",s)}else this.listHtml=this.translate(e,"fields",t);return}const s=this.formModel=new i;s.name="Dummy";const a=this.getFieldOptions();!e&&a.length&&(e=a[0][0]),s.set({value:e}),this.createView("valueField","views/fields/enum",{selector:'[data-field="value"]',model:s,name:"value",mode:"edit",params:{options:a.map(t=>t[0])},translatedOptions:Object.fromEntries(a)}),this.listenTo(s,"change",(t,e)=>{e.ui&&this.trigger("change")})},fetchValue:function(){return this.formModel.attributes.value},getFieldOptions:function(){const t=[],i=this.fieldType,s=this.entityType,a=this.field,n=this.getMetadata().get(`entityDefs.Workflow.fieldTypeComparison.${i}`)||[],o=[],r=this.getMetadata().get(`entityDefs.${s}.fields`)||{},l=Object.keys(r);l.sort((t,e)=>this.translate(t,"fields",s).localeCompare(this.translate(e,"fields",s))),n.includes("id")&&"linkParent"===i&&o.unshift("id");let d=null;const c=new e(this.getMetadata());"link"!==i&&"linkMultiple"!==i||(d=c.getComplexFieldForeignEntityType(a,s)),l.forEach(t=>{if(!r[t].utility&&(r[t].type===i||~n.indexOf(r[t].type))&&t!==a){if("link"===i||"linkMultiple"===i){if(this.getMetadata().get(["entityDefs",s,"links",t,"entity"])!==d)return}o.push(t)}}),o.forEach(e=>{const i=this.translate(e,"fields",s);t.push([e,i])});const h={},u=this.getMetadata().get(`entityDefs.${s}.links`)||{},p=Object.keys(u);p.sort((t,e)=>this.translate(t,"links",s).localeCompare(this.translate(e,"links",s))),p.forEach(t=>{const e=[];if("belongsTo"!==u[t].type)return;const s=u[t].entity;if(!s)return;const o=this.getMetadata().get(`entityDefs.${s}.fields`)||{},r=Object.keys(o);r.sort((t,e)=>this.translate(t,"fields",s).localeCompare(this.translate(e,"fields",s))),r.forEach(r=>{if(a!==`${t}.${r}`&&!o[r].utility&&(o[r].type===i||~n.indexOf(o[r].type))){if("link"===i||"linkMultiple"===i){if(this.getMetadata().get(["entityDefs",s,"links",r,"entity"])!==d)return}e.push(r)}}),h[t]=e});for(const e in h)h[e].forEach(i=>{const a=this.translate(e,"links",s)+" . "+this.translate(i,"fields",u[e].entity);t.push([`${e}.${i}`,a])});return t},afterRender:function(){this.readOnly||this.$el.find(".selectize-control").addClass("input-sm")}})}),define("advanced:views/workflow/condition-fields/subjects/enum-multiple",["view","advanced:workflow-helper","model"],function(t,e,i){return class extends t{templateContent='\n            {{#if readOnly}}\n                <code>\n            {{/if}}\n            <div\n                class="field-container"\n                style="display: inline-block;{{#unless readOnly}} min-width: 100%;{{/unless}}"\n            >{{{field}}}</div>\n            {{#if readOnly}}\n                </code>\n            {{/if}}\n        ';data(){return{readOnly:this.options.readOnly}}setup(){this.field=this.options.field,this.entityType=this.options.entityType,this.conditionData=this.options.conditionData||{};const t=new e(this.getMetadata()),s=t.getComplexFieldEntityType(this.field,this.entityType),a=t.getComplexFieldFieldPart(this.field),n=this.getOptionItems(s,a);this.formModel=new i,this.formModel.set("field",this.conditionData.value);const o=n.reduce((t,e)=>(t[e[0]]=e[1],t),{}),r=n.reduce((t,e)=>(t[e[0]]=e[2],t),{});this.wait(!0),this.createView("field","views/fields/multi-enum",{name:"field",selector:".field-container",mode:"edit",model:this.formModel,readOnly:this.options.readOnly,params:{options:n.map(t=>t[0]),style:r},translatedOptions:o}).then(t=>{!this.options.readOnly&&t.readOnly&&(t.readOnlyLocked=!1,t.readOnly=!1,t.setMode("edit"),t.reRender()),this.wait(!1),this.listenTo(t,"change",()=>this.trigger("change"))})}getOptionItems(t,e){let i=this.getMetadata().get(`entityDefs.${t}.fields.${e}`)||{};i.optionsReference&&i.optionsReference.includes(".")&&(t=i.optionsReference.split(".")[0]??null,e=i.optionsReference.split(".")[1]??null,i=this.getMetadata().get(`entityDefs.${t}.fields.${e}`)||{});const s=i.style||{};return(i.options||[]).map(i=>[i,this.getLanguage().translateOption(i,e,t),s[i]||null])}afterRender(){this.$el.find(".selectize-control").addClass("input-sm").addClass("form-control")}fetch(){return{value:Espo.Utils.clone(this.formModel.attributes.field||[])}}}}),define("advanced:views/workflow/condition-fields/subjects/enum-input",["view","advanced:workflow-helper"],function(t,e){return t.extend({template:"advanced:workflow/condition-fields/subjects/enum-input",data:function(){return{readOnly:this.options.readOnly}},setup:function(){t.prototype.setup.call(this),this.field=this.options.field,this.entityType=this.options.entityType,this.conditionData=this.options.conditionData||{},this.wait(!0);const i=new e(this.getMetadata()),s=i.getComplexFieldEntityType(this.field,this.entityType),a=i.getComplexFieldFieldPart(this.field);this.realField=a,this.getModelFactory().create(s,t=>{t.set(this.realField,this.conditionData.value);const e=this.getMetadata().get(`entityDefs.${s}.fields.${a}.view`)||"views/fields/enum";this.createView("field",e,{selector:".field-container",mode:"edit",model:t,readOnly:this.options.readOnly,defs:{name:this.realField}},t=>{!this.options.readOnly&&t.readOnly&&(t.readOnlyLocked=!1,t.readOnly=!1,t.setMode("edit"),t.reRender()),this.wait(!1),this.listenTo(t,"change",()=>this.trigger("change"))})})},afterRender:function(){t.prototype.afterRender.call(this),this.$el.find("select").addClass("input-sm"),this.$el.find(".selectize-control").addClass("input-sm")},fetch:function(){return{value:this.getView("field").fetch()[this.realField]}}})}),define("modules/advanced/views/workflow/condition-fields/subjects/decimal",["exports","view","model"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{templateContent='<span data-field="value">{{{valueField}}}</span>';setup(){this.readOnly=this.options.readOnly,this.field=this.options.field,this.entityType=this.options.entityType,this.conditionData=this.options.conditionData||{};const t=this.formModel=new i.default;t.name="Dummy",t.set({value:this.conditionData.value}),this.createView("valueField","views/fields/decimal",{selector:'[data-field="value"]',mode:this.readOnly?"detail":"edit",model:t,name:"value"}),this.listenTo(t,"change",(t,e)=>{e.ui&&this.trigger("change")})}afterRender(){var t;const e=null===(t=this.element)||void 0===t?void 0:t.querySelector("input");e instanceof HTMLInputElement&&e.classList.add("input-sm")}fetch(){return{value:this.formModel.attributes.value}}}t.default=a}),define("modules/advanced/views/workflow/condition-fields/subjects/currency",["exports","view","model"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{templateContent='<span data-field="value">{{{valueField}}}</span>';setup(){this.readOnly=this.options.readOnly,this.field=this.options.field,this.entityType=this.options.entityType,this.conditionData=this.options.conditionData||{};const t=this.formModel=new i.default;t.name="Dummy",t.set({value:this.conditionData.value,valueCurrency:this.getConfig().get("defaultCurrency")}),this.createView("valueField","views/fields/currency",{selector:'[data-field="value"]',mode:this.readOnly?"detail":"edit",model:t,name:"value",params:{onlyDefaultCurrency:!0}}),this.listenTo(t,"change",(t,e)=>{e.ui&&this.trigger("change")})}afterRender(){this.$el.find("input").addClass("input-sm"),this.$el.find(".input-group-addon").addClass("input-sm")}fetch(){return{value:this.formModel.attributes.value}}}t.default=a}),define("advanced:views/workflow/actions/update-related-entity",["advanced:views/workflow/actions/base"],function(t){return t.extend({template:"advanced:workflow/actions/update-related-entity",type:"updateRelatedEntity",defaultActionData:{link:!1,fieldList:[],fields:{}},data:function(){var e=t.prototype.data.call(this);return this.actionData.link&&(e.linkTranslated=this.translate(this.actionData.link,"links",this.entityType)),this.actionData.parentEntityType&&(e.parentEntityTypeTranslated=this.translate(this.actionData.parentEntityType,"scopeNames")),e},additionalSetup:function(){if(t.prototype.additionalSetup.call(this),this.actionData.link){var e=this.getMetadata().get("entityDefs."+this.entityType+".links."+this.actionData.link);this.linkedEntityName=e.entity||this.entityType,this.displayedLinkedEntityName=null,"belongsToParent"===e.type&&(this.linkedEntityName=this.actionData.parentEntityType||this.linkedEntityName,this.displayedLinkedEntityName=this.translate(this.actionData.link,"links",this.entityType)+' <span class="chevron-right"></span> '+this.translate(this.actionData.parentEntityType,"scopeNames"))}}})}),define("advanced:views/workflow/actions/update-process-entity",["advanced:views/workflow/actions/base"],function(t){return t.extend({type:"updateProcessEntity",linkedEntityName:"BpmnProcess",defaultActionData:{fieldList:[],fields:{}},data:function(){const e=t.prototype.data.call(this);return e.noEntityName=!0,e},additionalSetup:function(){t.prototype.additionalSetup.call(this),this.displayedLinkedEntityName=this.translate("BpmnProcess","scopeNames")}})}),define("advanced:views/workflow/actions/update-entity",["advanced:views/workflow/actions/base"],function(t){return t.extend({type:"updateEntity",defaultActionData:{fieldList:[],fields:{}},additionalSetup:function(){t.prototype.additionalSetup.call(this),this.displayedLinkedEntityName=this.translate(this.entityType,"scopeNames")}})}),define("advanced:views/workflow/actions/update-created-entity",["advanced:views/workflow/actions/base"],function(t){return t.extend({template:"advanced:workflow/actions/update-created-entity",type:"updateCreatedEntity",defaultActionData:{target:null,fieldList:[],fields:{}},data:function(){const e=t.prototype.data.call(this);if(this.actionData.target){const t=this.actionData.target.substr(8);if(this.options.flowchartCreatedEntitiesData[t]){const i=this.options.flowchartCreatedEntitiesData[t].link,s=this.options.flowchartCreatedEntitiesData[t].entityType,a=this.options.flowchartCreatedEntitiesData[t].numberId,n=this.options.flowchartCreatedEntitiesData[t].text;i&&(e.linkTranslated=this.translate(i,"links",this.entityType)),e.entityTypeTranslated=this.translate(s,"scopeNames"),e.numberId=a,e.text=n}}return e},additionalSetup:function(){if(t.prototype.additionalSetup.call(this),this.actionData.target){let t=this.actionData.target;0===t.indexOf("created:")&&(t=t.substr(8)),this.options.flowchartCreatedEntitiesData[t]&&(this.linkedEntityName=this.options.flowchartCreatedEntitiesData[t].entityType)}}})}),define("advanced:views/workflow/actions/unrelate-from-entity",["advanced:views/workflow/actions/relate-with-entity"],function(t){return t.extend({type:"unrelateFromEntity"})}),define("advanced:views/workflow/actions/trigger-workflow",["advanced:views/workflow/actions/base","model"],function(t,e){return t.extend({template:"advanced:workflow/actions/trigger-workflow",type:"triggerWorkflow",defaultActionData:{execution:{type:"immediately",field:!1,shiftDays:0,shiftUnit:"days"}},data:function(){var e=t.prototype.data.call(this);return e.targetTranslated=this.getTargetTranslated(),e},setup:function(){t.prototype.setup.call(this),this.createView("executionTime","advanced:views/workflow/action-fields/execution-time",{selector:" .execution-time-container",executionData:this.actionData.execution||{},entityType:this.entityType,readOnly:!0});var i=new e;i.name="Workflow",i.set({workflowId:this.actionData.workflowId,workflowName:this.actionData.workflowName}),this.createView("workflow","views/fields/link",{selector:" .field-workflow",model:i,mode:"edit",foreignScope:"Workflow",defs:{name:"workflow",params:{required:!0}},readOnly:!0})},render:function(e){this.getView("executionTime").reRender();var i=this.getView("workflow");i.model.set({workflowId:this.actionData.workflowId,workflowName:this.actionData.workflowName}),i.reRender(),t.prototype.render.call(this,e)},getTargetTranslated:function(){return this.translateTargetItem(this.actionData.target)}})}),define("advanced:views/workflow/actions/start-bpmn-process",["advanced:views/workflow/actions/base","model"],function(t,e){return t.extend({template:"advanced:workflow/actions/start-bpmn-process",type:"startBpmnProcess",defaultActionData:{},data:function(){const e=t.prototype.data.call(this);return e.targetTranslated=this.getTargetTranslated(),e},setup:function(){t.prototype.setup.call(this);const i=this.model2=new e;i.name="BpmnFlowchart",i.set({flowchartId:this.actionData.flowchartId,flowchartName:this.actionData.flowchartName,elementId:this.actionData.elementId,target:this.actionData.target,startElementIdList:this.actionData.startElementIdList,startElementNames:this.actionData.startElementNames}),this.createView("flowchart","views/fields/link",{selector:'.field[data-name="flowchart"]',model:i,foreignScope:"BpmnFlowchart",name:"flowchart",mode:"detail",readOnly:!0}),this.createView("elementId","advanced:views/workflow/fields/process-start-element-id",{selector:'.field[data-name="elementId"]',model:i,readOnly:!0,mode:"detail",name:"elementId",options:this.actionData.startElementIdList||[],translatedOptions:this.actionData.startElementNames||{}})},afterEdit:function(){this.model2.set({flowchartId:this.actionData.flowchartId,flowchartName:this.actionData.flowchartName,elementId:this.actionData.elementId,target:this.actionData.target,startElementIdList:this.actionData.startElementIdList,startElementNames:this.actionData.startElementNames})},getTargetTranslated:function(){return this.translateTargetItem(this.actionData.target)}})}),define("advanced:views/workflow/actions/send-request",["advanced:views/workflow/actions/base","model"],function(t,e){return t.extend({type:"sendRequest",template:"advanced:workflow/actions/send-request",defaultActionData:{requestType:"POST",contentType:null,content:"{}",requestUrl:null,headers:null,contentVariable:null},setModel:function(){this.model.set({requestType:this.actionData.requestType||null,contentType:this.actionData.contentType||null,content:this.actionData.content||null,requestUrl:this.actionData.requestUrl||null,headers:this.actionData.headers||null,contentVariable:this.actionData.contentVariable||null})},setup:function(){t.prototype.setup.call(this);const i=this.model=new e;i.name="Workflow",this.setModel(),this.on("change",()=>{this.setModel()}),this.createView("requestType","views/fields/enum",{mode:"detail",model:i,selector:'.field[data-name="requestType"]',defs:{name:"requestType",params:{options:["POST","PUT","PATCH","DELETE","GET"]}},readOnly:!0}),this.createView("contentType","views/fields/enum",{mode:"detail",model:i,selector:'.field[data-name="contentType"]',defs:{name:"contentType",params:{options:["application/json","application/x-www-form-urlencoded"]}},readOnly:!0}),this.createView("requestUrl","views/fields/varchar",{mode:"detail",model:i,selector:'.field[data-name="requestUrl"]',defs:{name:"requestUrl",params:{required:!0}},readOnly:!0}),this.createView("content","views/fields/formula",{mode:"detail",model:i,selector:'.field[data-name="content"]',defs:{name:"content"},insertDisabled:!0,height:30,readOnly:!0,smallFont:!0}),this.createView("headers","views/fields/array",{mode:"detail",model:i,selector:'.field[data-name="headers"]',defs:{name:"headers",params:{displayAsList:!0}},readOnly:!0}),this.createView("contentVariable","views/fields/varchar",{mode:"detail",model:i,selector:' .field[data-name="contentVariable"]',defs:{name:"contentVariable",params:{}},readOnly:!0})}})}),define("advanced:views/workflow/actions/send-email",["advanced:views/workflow/actions/base","model"],function(t,e){return t.extend({template:"advanced:workflow/actions/send-email",type:"sendEmail",defaultActionData:{execution:{type:"immediately",field:!1,shiftDays:0,shiftUnit:"days"},from:"system",to:"",optOutLink:!1,attachmentsVariable:null},data:function(){const e=t.prototype.data.call(this);return e.fromLabel=this.translateEmailOption(this.actionData.from),e.toLabel=this.translateEmailOption(this.actionData.to),e.replyToLabel=this.translateEmailOption(this.actionData.replyTo),e.ccLabel=this.translateEmailOption(this.actionData.cc),e},setModel:function(){this.model.set({emailTemplateId:this.actionData.emailTemplateId,emailTemplateName:this.actionData.emailTemplateName,doNotStore:this.actionData.doNotStore||!1,optOutLink:this.actionData.optOutLink||!1,attachmentsVariable:this.actionData.attachmentsVariable||null})},setup:function(){t.prototype.setup.call(this),this.createView("executionTime","advanced:views/workflow/action-fields/execution-time",{selector:".execution-time-container",executionData:this.actionData.execution||{},entityType:this.entityType,readOnly:!0});const i=this.model=new e;i.name="Workflow",this.setModel(),this.on("change",()=>{this.setModel()}),this.createView("emailTemplate","views/fields/link",{selector:".field-emailTemplate",model:i,mode:"edit",foreignScope:"EmailTemplate",defs:{name:"emailTemplate",params:{required:!0}},readOnly:!0}),this.createView("toSpecifiedTeams","views/fields/link-multiple",{selector:".toSpecifiedTeams-container .field-toSpecifiedTeams",model:i,mode:"edit",foreignScope:"Team",defs:{name:"toSpecifiedTeams"},readOnly:!0}),this.createView("toSpecifiedUsers","views/fields/link-multiple",{selector:".toSpecifiedUsers-container .field-toSpecifiedUsers",model:i,mode:"edit",foreignScope:"User",defs:{name:"toSpecifiedUsers"},readOnly:!0}),this.createView("toSpecifiedContacts","views/fields/link-multiple",{selector:".toSpecifiedContacts-container .field-toSpecifiedContacts",model:i,mode:"edit",foreignScope:"Contact",defs:{name:"toSpecifiedContacts"},readOnly:!0}),this.createView("doNotStore","views/fields/bool",{selector:".field-doNotStore",model:i,mode:"edit",defs:{name:"doNotStore"},readOnly:!0}),this.createView("optOutLink","views/fields/bool",{selector:'.field[data-name="optOutLink"]',model:i,mode:"edit",defs:{name:"optOutLink"},readOnly:!0}),this.createView("attachmentsVariable","views/fields/varchar",{selector:'.field[data-name="attachmentsVariable"]',model:i,mode:"edit",name:"attachmentsVariable",readOnly:!0})},render:function(e){this.getView("executionTime").reRender();const i=this.getView("emailTemplate");if(i.model.set({emailTemplateId:this.actionData.emailTemplateId,emailTemplateName:this.actionData.emailTemplateName}),i.reRender(),this.actionData.toSpecifiedEntityIds){const t="to"+this.actionData.to.charAt(0).toUpperCase()+this.actionData.to.slice(1),e=this.getView(t);if(e){const i={};i[t+"Ids"]=this.actionData.toSpecifiedEntityIds,i[t+"Names"]=this.actionData.toSpecifiedEntityNames,e.model.set(i),e.reRender()}}const s=this.getView("doNotStore");s.model.set({doNotStore:this.actionData.doNotStore}),s.reRender(),t.prototype.render.call(this,e)},renderFields:function(){},translateEmailOption:function(t){if(this.getMetadata().get(`entityDefs.${this.entityType}.links.${t}`))return this.translate(t,"links",this.entityType);if(t&&0===t.indexOf("link:")){let e=t.substring(5);if(~e.indexOf(".")){const t=e.split(".");e=t[0];const i=t[1];if("followers"===i)return this.translate("Related","labels","Workflow")+" · "+this.translate(e,"links",this.entityType)+" . "+this.translate("Followers");const s=this.getMetadata().get(["entityDefs",this.entityType,"links",e,"entity"]);return this.translate("Related","labels","Workflow")+" · "+this.translate(e,"links",this.entityType)+" . "+this.translate(i,"links",s)}return this.translate("Related","labels","Workflow")+" · "+this.translate(e,"links",this.entityType)}let e=this.translate(t,"emailAddressOptions","Workflow");return"targetEntity"===t&&(e+=" · "+this.translate(this.entityType,"scopeNames")),e}})}),define("advanced:views/workflow/actions/run-service",["advanced:views/workflow/actions/base","model"],function(t,e){return t.extend({type:"runService",template:"advanced:workflow/actions/run-service",data:function(){return _.extend({methodName:this.translatedOption||this.getLabel(this.actionData.methodName,"serviceActions"),additionalParameters:this.actionData.additionalParameters,targetTranslated:this.getTargetTranslated()},t.prototype.data.call(this))},setup:function(){t.prototype.setup.call(this);var i=this.actionData.methodName||null,s=new e;s.name="Workflow",s.set({methodName:i,additionalParameters:this.actionData.additionalParameters}),this.translatedOption=this.getLabel(i,"serviceActions")},getTargetTranslated:function(){var t=this.actionData.target;if("targetEntity"===t||!t)return this.translate("Target Entity","labels","Workflow");if(0===t.indexOf("link:")){var e=t.substr(5);return this.translate("Related","labels","Workflow")+" · "+this.getLanguage().translate(e,"links",this.entityType)}return 0===t.indexOf("created:")?this.translateCreatedEntityAlias(t):void 0},getLabel:function(t,e,i){if(t){var s=this.actionData.targetEntityType+t.charAt(0).toUpperCase()+t.slice(1);return this.getLanguage().has(s,e,"Workflow")?this.translate(s,e,"Workflow"):null==i||this.getLanguage().has(t,e,"Workflow")?this.translate(t,e,"Workflow"):i}return""}})}),define("advanced:views/workflow/actions/make-followed",["advanced:views/workflow/actions/base","model","advanced:views/workflow/action-modals/make-followed"],function(t,e,i){return t.extend({type:"makeFollowed",template:"advanced:workflow/actions/make-followed",setModel:function(){this.model.set({usersToMakeToFollowIds:this.actionData.userIdList,usersToMakeToFollowNames:this.actionData.userNames,whatToFollow:this.actionData.whatToFollow,recipient:this.actionData.recipient||"specifiedUsers",specifiedTeamsIds:this.actionData.specifiedTeamsIds,specifiedTeamsNames:this.actionData.specifiedTeamsNames})},setup:function(){t.prototype.setup.call(this),i.prototype.setupRecipientOptions.call(this);const s=this.model=new e;s.name="Workflow",this.setModel(),this.on("change",()=>{this.setModel()}),this.createView("recipient","views/fields/enum",{mode:"edit",model:s,selector:' .field[data-name="recipient"]',defs:{name:"recipient",params:{options:this.recipientOptionList,required:!0,translatedOptions:this.recipientTranslatedOptions}},readOnly:!0}),this.createView("whatToFollow","views/fields/enum",{mode:"edit",model:s,selector:' .field[data-name="whatToFollow"]',defs:{name:"whatToFollow",params:{options:this.targetOptionList,required:!0,translatedOptions:this.targetTranslatedOptions}},readOnly:!0}),this.createView("usersToMakeToFollow","views/fields/link-multiple",{mode:"detail",model:s,selector:' .field[data-name="usersToMakeToFollow"]',foreignScope:"User",defs:{name:"usersToMakeToFollow"},readOnly:!0}),this.createView("specifiedTeams","views/fields/link-multiple",{selector:' .field[data-name="specifiedTeams"]',model:s,mode:"edit",foreignScope:"Team",defs:{name:"specifiedTeams"},readOnly:!0})},data:function(){var e=t.prototype.data.call(this);return e.targetTranslated=this.getTargetTranslated(),e},afterRender:function(){this.handleRecipient()},handleRecipient:function(){this.actionData.recipient&&"specifiedUsers"!==this.actionData.recipient?this.$el.find('.cell[data-name="usersToMakeToFollow"]').addClass("hidden"):this.$el.find('.cell[data-name="usersToMakeToFollow"]').removeClass("hidden"),"specifiedTeams"===this.actionData.recipient?this.$el.find('.cell[data-name="specifiedTeams"]').removeClass("hidden"):this.$el.find('.cell[data-name="specifiedTeams"]').addClass("hidden")},getTargetTranslated:function(){const t=this.actionData.whatToFollow;if(!t)return"";if("targetEntity"===t)return this.translate("Target Entity","labels","Workflow");if(0===t.indexOf("created:"))return this.translateCreatedEntityAlias(t);let e=t;return 0===e.indexOf("link:")&&(e=e.substr(5)),this.translate("Related","labels","Workflow")+" · "+this.getLanguage().translate(e,"links",this.entityType)},translateRecipientOption:function(t){if(t&&0===t.indexOf("link:")){let e=t.substring(5);if(~e.indexOf(".")){const t=e.split(".");e=t[0];const i=t[1];if("followers"===i)return this.translate("Related","labels","Workflow")+" · "+this.translate(e,"links",this.entityType)+" . "+this.translate("Followers");const s=this.getMetadata().get(["entityDefs",this.entityType,"links",e,"entity"]);return this.translate("Related","labels","Workflow")+" · "+this.translate(e,"links",this.entityType)+" . "+this.translate(i,"links",s)}return this.translate("Related","labels","Workflow")+" · "+this.translate(e,"links",this.entityType)}let e=this.translate(t,"emailAddressOptions","Workflow");return"targetEntity"===t&&(e+=" · "+this.translate(this.entityType,"scopeNames")),e}})}),define("advanced:views/workflow/actions/execute-formula",["advanced:views/workflow/actions/base","model"],function(t,e){return t.extend({type:"executeFormula",template:"advanced:workflow/actions/execute-formula",defaultActionData:{formula:null},afterRender:function(){this.$formulaField=this.$el.find('.field[data-name="formula"]'),this.renderFormula()}})}),define("advanced:views/workflow/actions/create-related-entity",["advanced:views/workflow/actions/base"],function(t){return t.extend({type:"createRelatedEntity",defaultActionData:{link:!1,fieldList:[],fields:{}},data:function(){const e=t.prototype.data.call(this);return this.actionData.link&&(e.linkTranslated=this.translate(this.actionData.link,"links",this.entityType)),e.numberId=this.numberId,e.aliasId=this.aliasId,e},setup:function(){if(t.prototype.setup.call(this),this.numberId=null,this.options.flowchartElementId&&this.options.flowchartCreatedEntitiesData){const t=this.options.flowchartElementId+"_"+this.actionData.id;t in this.options.flowchartCreatedEntitiesData&&(this.numberId=this.options.flowchartCreatedEntitiesData[t].numberId),this.aliasId=t}},additionalSetup:function(){t.prototype.additionalSetup.call(this),this.actionData.link&&(this.linkedEntityName=this.getMetadata().get(`entityDefs.${this.entityType}.links.${this.actionData.link}.entity`),this.displayedLinkedEntityName=this.translate(this.linkedEntityName,"scopeNames"))}})}),define("advanced:views/workflow/actions/create-notification",["advanced:views/workflow/actions/base","model"],function(t,e){return t.extend({template:"advanced:workflow/actions/create-notification",type:"createNotification",defaultActionData:{recipient:"specifiedUsers",userIdList:[],userNames:{}},data:function(){const e=t.prototype.data.call(this);return e.recipientLabel=this.translateRecipientOption(this.actionData.recipient),e.messageTemplate=this.actionData.messageTemplate,e},afterRender:function(){t.prototype.afterRender.call(this);const i=new e;i.name="Workflow",i.set({recipient:this.actionData.recipient,messageTemplate:this.actionData.messageTemplate,usersIds:this.actionData.userIdList,usersNames:this.actionData.userNames,specifiedTeamsIds:this.actionData.specifiedTeamsIds,specifiedTeamsNames:this.actionData.specifiedTeamsNames}),"specifiedUsers"===this.actionData.recipient&&this.createView("users","views/fields/link-multiple",{mode:"detail",model:i,selector:".field-recipient",foreignScope:"User",defs:{name:"users"},readOnly:!0},t=>{t.render()}),"specifiedTeams"===this.actionData.recipient&&this.createView("specifiedTeams","views/fields/link-multiple",{mode:"detail",model:i,selector:".field-recipient",foreignScope:"Team",defs:{name:"specifiedTeams"},readOnly:!0},t=>{t.render()})},translateRecipientOption:function(t){if(this.getMetadata().get(`entityDefs.${this.entityType}.links.${t}`))return this.translate(t,"links",this.entityType);if(t&&0===t.indexOf("link:")){let e=t.substring(5);if(~e.indexOf(".")){const t=e.split(".");e=t[0];const i=t[1];if("followers"===i)return this.translate("Related","labels","Workflow")+" · "+this.translate(e,"links",this.entityType)+" . "+this.translate("Followers");const s=this.getMetadata().get(["entityDefs",this.entityType,"links",e,"entity"]);return this.translate("Related","labels","Workflow")+" · "+this.translate(e,"links",this.entityType)+" . "+this.translate(i,"links",s)}return this.translate("Related","labels","Workflow")+" · "+this.translate(e,"links",this.entityType)}let e=this.translate(t,"emailAddressOptions","Workflow");return"targetEntity"===t&&(e+=" · "+this.translate(this.entityType,"scopeNames")),e}})}),define("advanced:views/workflow/actions/create-entity",["advanced:views/workflow/actions/base","model"],function(t,e){return t.extend({type:"createEntity",defaultActionData:{link:!1,fieldList:[],fields:{}},data:function(){const e=t.prototype.data.call(this);return e.numberId=this.numberId,e.aliasId=this.aliasId,e},setup:function(){if(t.prototype.setup.call(this),this.numberId=null,this.options.flowchartElementId&&this.options.flowchartCreatedEntitiesData){const t=this.options.flowchartElementId+"_"+this.actionData.id;t in this.options.flowchartCreatedEntitiesData&&(this.numberId=this.options.flowchartCreatedEntitiesData[t].numberId),this.aliasId=t}},additionalSetup:function(){t.prototype.additionalSetup.call(this),this.displayedLinkedEntityName=this.translate(this.actionData.link,"scopeNames")},afterRender:function(){if(t.prototype.afterRender.call(this),"createEntity"===this.type){const t=new e;t.set("linkList",this.actionData.linkList);const i={};(this.actionData.linkList||[]).forEach(t=>{i[t]=this.getLanguage().translate(t,"links",this.actionData.link)}),this.createView("linkList","views/fields/multi-enum",{model:t,selector:'.field[data-name="linkList"]',mode:"detail",name:"linkList",inlineEditDisabled:!0,translatedOptions:i},t=>{t.render()})}}})}),define("advanced:views/workflow/actions/apply-assignment-rule",["advanced:views/workflow/actions/base","model"],function(t,e){return t.extend({template:"advanced:workflow/actions/apply-assignment-rule",type:"applyAssignmentRule",defaultActionData:{assignmentRule:"Round-Robin",targetTeamId:null,targetTeamName:null,targetUserPosition:null,listReportId:null,listReportName:null},data:function(){var e=t.prototype.data.call(this);return e.hasListReport=this.actionData.listReportId,e.hasTarget=!!this.options.flowchartCreatedEntitiesData,e.hasTarget&&(e.targetTranslated=this.getTargetTranslated()),e},getTargetTranslated:function(){var t=this.actionData.target;return t?"process"===t?this.translate("Process","labels","Workflow"):0===t.indexOf("created:")?this.translateCreatedEntityAlias(t):void 0:this.translate("Target Entity","labels","Workflow")},afterRender:function(){t.prototype.afterRender.call(this);var i=new e;i.name="Workflow",i.set({assignmentRule:this.actionData.assignmentRule,targetTeamId:this.actionData.targetTeamId,targetTeamName:this.actionData.targetTeamName,targetUserPosition:this.actionData.targetUserPosition,listReportId:this.actionData.listReportId,listReportName:this.actionData.listReportName}),this.createView("assignmentRule","views/fields/enum",{mode:"detail",model:i,selector:' .field[data-name="assignmentRule"]',defs:{name:"assignmentRule",params:{options:this.getMetadata().get("entityDefs.Workflow.assignmentRuleList")||[]}},readOnly:!0},t=>{t.render()}),this.createView("targetTeam","views/fields/link",{mode:"detail",model:i,selector:' .field[data-name="targetTeam"]',foreignScope:"Team",defs:{name:"targetTeam"},readOnly:!0},t=>{t.render()}),this.createView("targetUserPosition","advanced:views/workflow/fields/target-user-position",{mode:"detail",model:i,selector:' .field[data-name="targetUserPosition"]',foreignScope:"Report",defs:{name:"targetUserPosition"},readOnly:!0},t=>{t.render()}),this.createView("listReport","advanced:views/workflow/fields/list-report",{mode:"detail",model:i,selector:' .field[data-name="listReport"]',foreignScope:"Report",entityType:this.model.get("entityType"),defs:{name:"listReport"},readOnly:!0},t=>{t.render()})}})}),define("advanced:views/workflow/action-modals/update-related-entity",["advanced:views/workflow/action-modals/create-entity","model"],function(t,e){return t.extend({template:"advanced:workflow/action-modals/update-related-entity",permittedLinkTypes:["belongsTo","hasMany","hasChildren","belongsToParent","hasOne"],getLinkOptions:function(){const t=Object.keys(this.getMetadata().get(`entityDefs.${this.entityType}.links`)),e=[[""]];return t.forEach(t=>{const i=this.getMetadata().get(`entityDefs.${this.entityType}.links.${t}`);if(!i.disabled&&this.permittedLinkTypes.includes(i.type)){const i=this.translate(t,"links",this.entityType);e.push([t,i])}}),e},setup:function(){t.prototype.setup.call(this);const i=new e;i.name="Workflow",this.modelForParentEntityType=i,this.actionModel=i,i.set({assignmentRule:this.actionData.assignmentRule,targetTeamId:this.actionData.targetTeamId,targetTeamName:this.actionData.targetTeamName,targetUserPosition:this.actionData.targetUserPosition,listReportId:this.actionData.listReportId,listReportName:this.actionData.listReportName,link:this.actionData.link});let s=[];this.isParentLink()&&(s=this.getParentEntityTypeList(this.actionData.link)),this.actionData.parentEntityType&&i.set("parentEntityType",this.actionData.parentEntityType),this.createView("parentEntityType","views/fields/enum",{mode:"edit",model:i,selector:'.field[data-name="parentEntityType"]',defs:{name:"parentEntityType",params:{options:s,translation:"Global.scopeNames"}},readOnly:this.readOnly}),this.listenTo(i,"change",(t,e)=>{e.ui&&this.onParentEntityTypeChange()});const a=this.getLinkOptions();this.createView("link","views/fields/enum",{name:"link",model:i,mode:"edit",selector:' .field[data-name="link"]',params:{options:a.map(t=>t[0]),required:!0},translatedOptions:Object.fromEntries(a),labelText:this.translate("Field")}),this.listenTo(i,"change:link",()=>this.changeLinkAction())},afterRender:function(){t.prototype.afterRender.call(this),this.controlParentEntityType()},controlParentEntityType:function(){const t=this.$el.find('.cell[data-name="parentEntityType"]');if(this.isParentLink()){const e=this.getParentEntityTypeList(this.actionData.link);this.getView("parentEntityType").setOptionList(e),t.removeClass("hidden")}else t.addClass("hidden")},isParentLink:function(){return this.actionData.link&&"belongsToParent"===this.getMetadata().get(["entityDefs",this.entityType,"links",this.actionData.link,"type"])},setupScope:function(t){if(this.actionData.link){let e;if(e=this.isParentLink()?this.actionData.parentEntityType:this.getMetadata().get(`entityDefs.${this.entityType}.links.${this.actionData.link}.entity`),this.scope=e,!e)throw new Error;this.wait(!0),this.getModelFactory().create(e,e=>{this.model=e,(this.actionData.fieldList||[]).forEach(t=>{const i=(this.actionData.fields[t]||{}).attributes||{};e.set(i,{silent:!0})}),t()})}else this.model=null,t()},onParentEntityTypeChange:function(){this.actionData.fieldList.forEach(t=>{this.$el.find('.field-row[data-field="'+t+'"]').remove(),this.clearView("field-"+t)}),this.actionData.fieldList=[],this.actionData.fields={},this.actionData.parentEntityType=this.modelForParentEntityType.get("parentEntityType"),this.handleLink()},changeLinkAction:function(t){if(this.actionData.link=this.actionModel.attributes.link,this.actionData.parentEntityType=null,this.isParentLink()&&this.isParentLink()){const t=this.getParentEntityTypeList(this.actionData.link);t.length&&(this.actionData.parentEntityType=t[0])}this.modelForParentEntityType.set("parentEntityType",this.actionData.parentEntityType),this.actionData.fieldList.forEach(t=>{this.$el.find('.field-row[data-field="'+t+'"]').remove(),this.clearView("field-"+t)}),this.actionData.fieldList=[],this.actionData.fields={},this.controlParentEntityType(),this.handleLink()},setupFormulaView:function(){const t=new e,i=this.element.querySelector('[data-name="formula"] .field-info');i&&i.parentNode.removeChild(i),this.hasFormulaAvailable&&(t.set("formula",this.actionData.formula||null),this.createView("formula","views/fields/formula",{name:"formula",model:t,mode:this.readOnly?"detail":"edit",height:100,selector:'.field[data-name="formula"]',inlineEditDisabled:!0,targetEntityType:this.scope,params:{tooltip:!0},tooltipText:this.translate("createEntityFormula","tooltips","Workflow")},t=>{t.render()}))},getParentEntityTypeList:function(t){return this.getMetadata().get(["entityDefs",this.entityType,"fields",t,"entityList"])||this.getAllEntityList()||[]},getAllEntityList:function(){return Object.keys(this.getMetadata().get("scopes")).filter(t=>{if(!this.getMetadata().get("scopes."+t+".disabled"))return this.getMetadata().get("scopes."+t+".entity")&&this.getMetadata().get("scopes."+t+".object")}).sort((t,e)=>this.translate(t,"scopeNamesPlural").localeCompare(this.translate(e,"scopeNamesPlural")))}})}),define("advanced:views/workflow/action-modals/update-process-entity",["advanced:views/workflow/action-modals/update-entity"],function(t){return t.extend({template:"advanced:workflow/action-modals/update-entity",ignoreFieldList:["endedAt","status","targetType","target","flowchartData","flowchart","flowchartElementsDataHash","flowchartVisualization","createdEntitiesData","variables","modifiedAt","endedAt","createdBy","modifiedBy","createdAt","workflowId","startElementId","rootProcess","parentProcessFlowNode","parentProcess"],setupScope:function(t){this.scope="BpmnProcess",this.getModelFactory().create(this.scope,e=>{this.model=e,(this.actionData.fieldList||[]).forEach(t=>{const i=(this.actionData.fields[t]||{}).attributes||{};e.set(i,{silent:!0})}),t()})},setup:function(){t.prototype.setup.call(this),this.hasFormulaAvailable=!!this.getMetadata().get("app.formula.functionList"),this.wait(!0),this.setupScope(()=>{this.createView("addField","advanced:views/workflow/action-fields/add-field",{selector:".add-field-container",scope:this.scope,fieldList:this.getFieldList(),addedFieldList:this.actionData.fieldList,onAdd:t=>{this.actionData.fieldList.includes(t)||(this.actionData.fieldList.push(t),this.actionData.fields[t]={},this.addField(t,!1,!0))}},t=>{t.render()}),this.wait(!1)})},getFieldList:function(){const t=this.getMetadata().get("entityDefs."+this.scope+".fields")||{};return Object.keys(t).filter(e=>!t[e].disabled&&(!~this.ignoreFieldList.indexOf(e)||void 0)).sort((t,e)=>this.translate(t,"fields",this.scope).localeCompare(this.translate(e,"fields",this.scope)))}})}),define("advanced:views/workflow/action-modals/update-created-entity",["advanced:views/workflow/action-modals/create-entity","model"],function(t,e){return t.extend({template:"advanced:workflow/action-modals/update-created-entity",data:function(){return _.extend({target:this.actionData.target,scope:this.scope})},setup:function(){t.prototype.setup.call(this);const i=new e;i.name="Workflow",this.modelForParentEntityType=i,this.actionModel=i;let s=Object.keys(this.options.flowchartCreatedEntitiesData).map(t=>"created:"+t);s=Espo.Utils.clone(s),s.unshift(""),this.actionData.target&&i.set("target",this.actionData.target);const a={};Object.keys(this.options.flowchartCreatedEntitiesData).forEach(t=>{const e=this.options.flowchartCreatedEntitiesData[t].link,i=this.options.flowchartCreatedEntitiesData[t].entityType,s=this.options.flowchartCreatedEntitiesData[t].numberId,n=this.options.flowchartCreatedEntitiesData[t].text;let o=this.translate("Created","labels","Workflow")+" · ";e&&(o+=this.translate(e,"links",this.entityType)+" - "),o+=this.translate(i,"scopeNames"),n?o+=" '"+n+"'":s&&(o+=" #"+s.toString()),a["created:"+t]=o}),this.createView("target","views/fields/enum",{name:"target",mode:"edit",model:i,selector:'.field[data-name="target"]',translatedOptions:a,readOnly:this.readOnly,labelText:this.translate("Field"),params:{options:s,required:!0}}),this.listenTo(i,"change:target",()=>{this.setTarget(this.actionModel.get("target"))})},afterRender:function(){t.prototype.afterRender.call(this)},setupScope:function(t){if(this.actionData.target){let e=this.scope=null;const i=this.actionData.target.substr(8);if(!this.options.flowchartCreatedEntitiesData[i])return void t();if(e=this.options.flowchartCreatedEntitiesData[i].entityType,this.scope=e,!e)throw new Error;this.wait(!0),this.getModelFactory().create(e,e=>{this.model=e,(this.actionData.fieldList||[]).forEach(t=>{const i=(this.actionData.fields[t]||{}).attributes||{};e.set(i,{silent:!0})}),t()})}else this.model=null,t()},setTarget:function(t){this.actionData.target=t,this.actionData.fieldList.forEach(t=>{this.$el.find('.field-row[data-field="'+t+'"]').remove(),this.clearView("field-"+t)}),this.actionData.fieldList=[],this.actionData.fields={},this.handleLink()},handleLink:function(){if(!this.actionData.target)return this.clearView("addField"),this.clearView("formula"),void this.$formulaCell.addClass("hidden");this.hasFormulaAvailable&&this.$formulaCell.removeClass("hidden"),this.setupScope(()=>{this.createView("addField","advanced:views/workflow/action-fields/add-field",{selector:".add-field-container",scope:this.scope,fieldList:this.getFieldList(),addedFieldList:this.actionData.fieldList,onAdd:t=>{this.actionData.fieldList.includes(t)||(this.actionData.fieldList.push(t),this.actionData.fields[t]={},this.addField(t,!1,!0))}},t=>{t.render()})}),this.setupFormulaView()},setupFormulaView:function(){const t=new e,i=this.element.querySelector('[data-name="formula"] .field-info');i&&i.parentNode.removeChild(i),this.hasFormulaAvailable&&(t.set("formula",this.actionData.formula||null),this.createView("formula","views/fields/formula",{name:"formula",model:t,mode:this.readOnly?"detail":"edit",height:100,selector:'.field[data-name="formula"]',inlineEditDisabled:!0,targetEntityType:this.scope,params:{tooltip:!0},tooltipText:this.translate("createEntityFormula","tooltips","Workflow")},t=>{t.render()}))},fetch:function(){let t,e=!0;if(t=this.getView("target").validate(),(this.actionData.fieldList||[]).forEach(t=>{e=this.getView("field-"+t).fetch(),this.actionData.fields[t]=this.getView("field-"+t).fieldData}),this.hasFormulaAvailable&&this.actionData.target){const t=this.getView("formula");t&&(this.actionData.formula=t.fetch().formula)}return!t&&e}})}),define("advanced:views/workflow/action-modals/unrelate-from-entity",["advanced:views/workflow/action-modals/relate-with-entity"],function(t){return t.extend({})}),define("advanced:views/workflow/action-modals/trigger-workflow",["advanced:views/workflow/action-modals/base","model"],function(t,e){return t.extend({template:"advanced:workflow/action-modals/trigger-workflow",data:function(){return _.extend({},t.prototype.data.call(this))},setup:function(){t.prototype.setup.call(this),this.setupTargetOptions(),this.createView("executionTime","advanced:views/workflow/action-fields/execution-time",{selector:".execution-time-container",executionData:this.actionData.execution||{},entityType:this.entityType});const i=this.model2=new e;i.name="Workflow",i.set({workflowId:this.actionData.workflowId,workflowName:this.actionData.workflowName,target:this.actionData.target}),this.createView("target","views/fields/enum",{mode:"edit",model:i,selector:'.field[data-name="target"]',defs:{name:"target",params:{options:this.targetOptionList,translatedOptions:this.targetTranslatedOptions}},readOnly:this.readOnly}),this.createView("workflow","advanced:views/workflow/fields/workflow",{selector:".field-workflow",model:i,mode:"edit",foreignScope:"Workflow",entityType:this.getTargetEntityType(),defs:{name:"workflow",params:{required:!0}},labelText:this.translate("Workflow Rule","labels","Workflow")}),this.listenTo(this.model2,"change:target",(t,e,s)=>{if(!s.ui)return;i.set("workflowId",null),i.set("workflowName",null);const a=this.getView("workflow");a&&(a.options.entityType=this.getTargetEntityType())})},getTargetEntityType:function(){return this.getEntityTypeFromTarget(this.model2.get("target"))},setupTargetOptions:function(){const t=[""],e={};e[""]=this.translate("Current","labels","Workflow")+" · "+this.translate(this.entityType,"scopeNames"),this.options.flowchartCreatedEntitiesData&&Object.keys(this.options.flowchartCreatedEntitiesData).forEach(i=>{t.push("created:"+i),e["created:"+i]=this.translateCreatedEntityAlias(i,!0)});const i=[],s=this.getMetadata().get(["entityDefs",this.entityType,"links"])||{};Object.keys(s).forEach(a=>{const n=s[a]||{},o=n.type;if(n.utility||"belongsTo"!==o&&"belongsToParent"!==o&&"hasMany"!==o)return;const r="link:"+a;t.push(r),e[r]=this.translateTargetItem(r,!0),"belongsTo"!==o&&"belongsToParent"!==o||i.push(a)}),i.forEach(i=>{const a=s[i].entity;if(a){const s=this.getMetadata().get(["entityDefs",a,"links"])||{};Object.keys(s).forEach(a=>{const n=s[a]||{},o=n.type;if(n.utility||"belongsTo"!==o&&"belongsToParent"!==o&&"hasMany"!==o)return;const r=`link:${i}.${a}`;t.push(r),e[r]=this.translateTargetItem(r,!0)})}}),this.targetOptionList=t,this.targetTranslatedOptions=e},fetch:function(){const t=this.getView("workflow");if(t.fetchToModel(),t.validate())return;const e=t.fetch();this.actionData.workflowId=e.workflowId,this.actionData.workflowName=e.workflowName,this.actionData.target=this.getView("target").fetch().target||null;const i=this.getView("executionTime").fetch();return this.actionData.execution=this.actionData.execution||{},this.actionData.execution.type=i.type,delete this.actionData.execution.field,delete this.actionData.execution.shiftDays,delete this.actionData.execution.shiftUnit,"immediately"!==i.type&&(this.actionData.execution.field=i.field,this.actionData.execution.shiftDays=i.shiftValue,this.actionData.execution.shiftUnit=i.shiftUnit),!0}})}),define("advanced:views/workflow/action-modals/start-bpmn-process",["advanced:views/workflow/action-modals/base","model"],function(t,e){return t.extend({template:"advanced:workflow/action-modals/start-bpmn-process",afterRender:function(){t.prototype.afterRender.call(this)},setup:function(){t.prototype.setup.call(this),this.setupTargetOptions();const i=this.model2=new e;i.name="BpmnFlowchart",i.set({flowchartId:this.actionData.flowchartId,flowchartName:this.actionData.flowchartName,elementId:this.actionData.elementId,target:this.actionData.target,startElementIdList:this.actionData.startElementIdList,startElementNames:this.actionData.startElementNames}),this.createView("target","views/fields/enum",{mode:"edit",model:i,selector:' .field[data-name="target"]',defs:{name:"target",params:{options:this.targetOptionList,translatedOptions:this.targetTranslatedOptions}},readOnly:this.readOnly}),this.createView("flowchart","advanced:views/workflow/fields/flowchart",{selector:'.field[data-name="flowchart"]',model:i,mode:"edit",foreignScope:"BpmnFlowchart",entityType:this.getTargetEntityType(),defs:{name:"flowchart",params:{required:!0}},targetEntityType:this.getTargetEntityType(),labelText:this.translate("BpmnFlowchart","scopeNames")}),this.listenTo(i,"change:target",()=>{i.trigger("change-target-entity-type",this.getTargetEntityType())}),this.createView("elementId","advanced:views/workflow/fields/process-start-element-id",{selector:'.field[data-name="elementId"]',model:i,mode:"edit",defs:{name:"elementId",params:{required:!0,options:this.actionData.startElementIdList||[]}},translatedOptions:this.actionData.startElementNames||{}}),this.listenTo(i,"change:target",(t,e,s)=>{s.ui&&(i.set("flowchartId",null),i.set("flowchartName",null),i.set("elementId",null))})},getTargetEntityType:function(){return this.getEntityTypeFromTarget(this.model2.get("target"))},setupTargetOptions:function(){const t=[""],e={};e[""]=this.translate("Current","labels","Workflow")+" · "+this.translate(this.entityType,"scopeNames"),this.options.flowchartCreatedEntitiesData&&Object.keys(this.options.flowchartCreatedEntitiesData).forEach(i=>{t.push("created:"+i),e["created:"+i]=this.translateCreatedEntityAlias(i,!0)});const i=[],s=this.getMetadata().get(["entityDefs",this.entityType,"links"])||{};Object.keys(s).forEach(a=>{const n=s[a].type;if("belongsTo"!==n&&"belongsToParent"!==n)return;const o=s[a].entity;if("belongsToParent"!==n){if(!o)return;if(!this.getMetadata().get(["scopes",o,"object"]))return}const r=`link:${a}`;t.push(r),e[r]=this.translateTargetItem(r,!0),i.push(a)}),i.forEach(i=>{const a=s[i].entity;if(a){const s=this.getMetadata().get(["entityDefs",a,"links"])||{};Object.keys(s).forEach(a=>{const n=s[a].type;if("belongsTo"!==n&&"belongsToParent"!==n)return;const o=s[a].entity;if("belongsToParent"!==n){if(!o)return;if(!this.getMetadata().get(["scopes",o,"object"]))return}const r=`link:${i}.${a}`;t.push(r),e[r]=this.translateTargetItem(r,!0)})}}),this.targetOptionList=t,this.targetTranslatedOptions=e},fetch:function(){const t=this.getView("flowchart");if(t.fetchToModel(),t.validate())return;const e=this.getView("elementId");if(e.fetchToModel(),e.validate())return;const i=t.fetch();return this.actionData.flowchartName=i.flowchartName,this.actionData.flowchartId=i.flowchartId,this.actionData.target=this.getView("target").fetch().target||null,this.actionData.startElementIdList=this.model2.get("startElementIdList")||[],this.actionData.startElementNames=this.model2.get("startElementNames")||{},this.actionData.elementId=this.getView("elementId").fetch().elementId||null,!0}})}),define("advanced:views/workflow/action-modals/send-request",["advanced:views/workflow/action-modals/base","model"],function(t,e){return t.extend({template:"advanced:workflow/action-modals/send-request",setModel:function(){this.model.set({requestType:this.actionData.requestType||null,contentType:this.actionData.contentType||null,content:this.actionData.content||null,requestUrl:this.actionData.requestUrl||null,headers:this.actionData.headers||null,contentVariable:this.actionData.contentVariable||null})},setup:function(){t.prototype.setup.call(this);const i=this.model=new e;i.name="Workflow",this.setModel(),this.on("apply-change",()=>{this.setModel()}),this.createView("requestType","views/fields/enum",{mode:"edit",model:i,selector:'.field[data-name="requestType"]',defs:{name:"requestType",params:{options:["POST","PUT","PATCH","DELETE","GET"]}},readOnly:this.readOnly}),this.createView("contentType","views/fields/enum",{mode:"edit",model:i,selector:'.field[data-name="contentType"]',defs:{name:"contentType",params:{options:["","application/json","application/x-www-form-urlencoded"]}},translatedOptions:{"":this.translate("None")},readOnly:this.readOnly},t=>{t.fetchEmptyValueAsNull=!0}),this.createView("contentVariable","views/fields/varchar",{mode:"edit",model:i,selector:'.field[data-name="contentVariable"]',defs:{name:"contentVariable",params:{maxLength:100,noSpellCheck:!0}},readOnly:this.readOnly,tooltip:"requestContentVariable"}),this.createView("requestUrl","views/fields/varchar",{mode:"edit",model:i,selector:'.field[data-name="requestUrl"]',defs:{name:"requestUrl",params:{required:!0}},readOnly:this.readOnly,tooltip:"requestUrl"}),this.createView("content","views/fields/formula",{mode:"edit",model:i,selector:'.field[data-name="content"]',defs:{name:"content"},insertDisabled:!0,checkSyntaxDisabled:!0,height:60,readOnly:this.readOnly,tooltip:"requestContent"},t=>{t.validations=["json"],t.validateJson=function(){let t=this.model.get(this.name)||"";if(t=t.trim(),!t)return;t=t.replace(/\{\$[a-zA-Z0-9_]+\}/g,"1"),t=t.replace(/\{\$\$[a-zA-Z0-9_]+\}/g,"1");try{return JSON.parse(t),!1}catch(t){}const e=this.translate("jsonInvalid","messages","Workflow");return this.showValidationMessage(e,".ace_editor"),!0}}),this.createView("headers","advanced:views/workflow/fields/request-headers",{mode:"edit",model:i,selector:'.field[data-name="headers"]',defs:{name:"headers",params:{noEmptyString:!0,itemsEditable:!0,maxItemLength:1e4}},readOnly:this.readOnly,tooltip:"requestHeaders"}),this.controlFieldVisibility(),this.listenTo(i,"change:requestType change:contentVariable",()=>this.controlFieldVisibility())},fetch:function(){this.getView("requestType").fetchToModel(),this.getView("contentType").fetchToModel(),this.getView("requestUrl").fetchToModel(),this.getView("content").fetchToModel(),this.getView("headers").fetchToModel(),this.getView("contentVariable").fetchToModel();let t=!1;if(t=t||this.getView("content").validate(),t=t||this.getView("requestUrl").validate(),!t)return this.actionData.requestType=(this.getView("requestType").fetch()||{}).requestType,this.actionData.contentType=(this.getView("contentType").fetch()||{}).contentType,this.actionData.requestUrl=(this.getView("requestUrl").fetch()||{}).requestUrl,this.actionData.content=(this.getView("content").fetch()||{}).content,this.actionData.headers=(this.getView("headers").fetch()||{}).headers,this.actionData.contentVariable=(this.getView("contentVariable").fetch()||{}).contentVariable,!0},async controlFieldVisibility(){if(await this.whenRendered(),!this.element)return;const t=this.element.querySelector('.cell[data-name="content"]'),e=this.element.querySelector('.cell[data-name="contentVariable"]');t&&e&&(this.model.attributes.contentVariable?t.classList.add("hidden"):t.classList.remove("hidden"))}})}),define("advanced:views/workflow/action-modals/send-email",["advanced:views/workflow/action-modals/base","model"],function(t,e){return t.extend({template:"advanced:workflow/action-modals/send-email",afterRender:function(){t.prototype.afterRender.call(this),this.handleFrom(),this.handleTo(),this.handleReplyTo(),this.handleCc()},setup:function(){t.prototype.setup.call(this),this.createView("executionTime","advanced:views/workflow/action-fields/execution-time",{selector:".execution-time-container",executionData:this.actionData.execution||{},entityType:this.entityType});const i=this.formModel=new e;if(i.name="Workflow",i.set({from:this.actionData.from,to:this.actionData.to||"currentUser",replyTo:this.actionData.replyTo,cc:this.actionData.cc,emailTemplateId:this.actionData.emailTemplateId,emailTemplateName:this.actionData.emailTemplateName,doNotStore:this.actionData.doNotStore,optOutLink:this.actionData.optOutLink,fromEmailAddress:this.actionData.fromEmail,toEmailAddress:this.actionData.toEmail,replyToEmailAddress:this.actionData.replyToEmail,ccEmailAddress:this.actionData.ccEmail,attachmentsVariable:this.actionData.attachmentsVariable}),this.actionData.toSpecifiedEntityIds){const t="to"+this.actionData.to.charAt(0).toUpperCase()+this.actionData.to.slice(1);i.set(t+"Ids",this.actionData.toSpecifiedEntityIds),i.set(t+"Names",this.actionData.toSpecifiedEntityNames)}const s=this.getFromOptions(),a=this.getToOptions(),n=this.getReplyToOptions();this.createView("from","views/fields/enum",{selector:".field-from",model:i,mode:"edit",name:"from",params:{options:s.map(t=>t[0])},translatedOptions:Object.fromEntries(s)}),this.createView("to","views/fields/enum",{selector:".field-to",model:i,mode:"edit",name:"to",params:{options:a.map(t=>t[0])},translatedOptions:Object.fromEntries(a)}),this.createView("replyTo","views/fields/enum",{selector:".field-replyTo",model:i,mode:"edit",name:"replyTo",params:{options:n.map(t=>t[0])},translatedOptions:Object.fromEntries(n),labelText:this.translate("Reply-To","labels","Workflow")}),this.createView("cc","views/fields/enum",{selector:'[data-name="cc"]',model:i,mode:"edit",name:"cc",params:{options:n.map(t=>t[0])},translatedOptions:Object.fromEntries(n),labelText:this.translate("CC","labels","Workflow")}),this.createView("fromEmailAddress","advanced:views/fields/email-address-for-send-email",{selector:'.field[data-name="fromEmailAddress"]',model:i,mode:"edit",name:"fromEmailAddress",labelText:this.translate("Email Address","labels","Workflow")}),this.createView("toEmailAddress","advanced:views/fields/email-address-for-send-email",{selector:'.field[data-name="toEmailAddress"]',model:i,mode:"edit",name:"toEmailAddress",labelText:this.translate("Email Address","labels","Workflow"),params:{tooltip:!0},tooltipText:this.translate("toEmailAddress","tooltips","Workflow")}),this.createView("replyToEmailAddress","advanced:views/fields/email-address-for-send-email",{selector:'.field[data-name="replyToEmailAddress"]',model:i,mode:"edit",name:"replyToEmailAddress",labelText:this.translate("Email Address","labels","Workflow"),params:{tooltip:!0},tooltipText:this.translate("toEmailAddress","tooltips","Workflow")}),this.createView("ccEmailAddress","advanced:views/fields/email-address-for-send-email",{selector:'.field[data-name="ccEmailAddress"]',model:i,mode:"edit",name:"ccEmailAddress",labelText:this.translate("Email Address","labels","Workflow"),params:{tooltip:!0},tooltipText:this.translate("toEmailAddress","tooltips","Workflow")}),this.createView("emailTemplate","views/fields/link",{selector:".field-emailTemplate",model:i,mode:"edit",foreignScope:"EmailTemplate",defs:{name:"emailTemplate",params:{required:!0}},labelText:this.translate("Email Template","labels","Workflow")}),this.createView("toSpecifiedTeams","views/fields/link-multiple",{selector:".toSpecifiedTeams-container .field-toSpecifiedTeams",model:i,mode:"edit",foreignScope:"Team",defs:{name:"toSpecifiedTeams"}}),this.createView("toSpecifiedUsers","views/fields/link-multiple",{selector:".toSpecifiedUsers-container .field-toSpecifiedUsers",model:i,mode:"edit",foreignScope:"User",defs:{name:"toSpecifiedUsers"}}),this.createView("toSpecifiedContacts","views/fields/link-multiple",{selector:".toSpecifiedContacts-container .field-toSpecifiedContacts",model:i,mode:"edit",foreignScope:"Contact",defs:{name:"toSpecifiedContacts"}}),this.createView("doNotStore","views/fields/bool",{selector:".doNotStore-container .field-doNotStore",model:i,mode:"edit",defs:{name:"doNotStore"}}),this.createView("optOutLink","views/fields/bool",{selector:'.field[data-name="optOutLink"]',model:i,mode:"edit",defs:{name:"optOutLink"}}),this.createView("attachmentsVariable","views/fields/varchar",{selector:'.field[data-name="attachmentsVariable"]',model:i,mode:"edit",name:"attachmentsVariable",params:{maxLength:64,noSpellCheck:!0,tooltip:!0},labelText:this.translate("attachmentsVariable","fields","Workflow"),tooltipText:this.translate("attachmentsVariable","tooltips","Workflow")}),this.listenTo(this.formModel,"change:from",()=>this.handleFrom()),this.listenTo(this.formModel,"change:to",()=>this.handleTo()),this.listenTo(this.formModel,"change:replyTo",()=>this.handleReplyTo()),this.listenTo(this.formModel,"change:cc",()=>this.handleCc())},handleFrom:function(){"specifiedEmailAddress"===this.formModel.attributes.from?this.$el.find(".from-email-container").removeClass("hidden"):this.$el.find(".from-email-container").addClass("hidden")},handleReplyTo:function(){"specifiedEmailAddress"===this.formModel.attributes.replyTo?this.$el.find(".reply-to-email-container").removeClass("hidden"):this.$el.find(".reply-to-email-container").addClass("hidden")},handleCc:function(){"specifiedEmailAddress"===this.formModel.attributes.cc?this.$el.find(".cc-email-container").removeClass("hidden"):this.$el.find(".cc-email-container").addClass("hidden")},handleTo:function(){const t=this.formModel.attributes.to;"specifiedEmailAddress"===t?this.$el.find(".to-email-container").removeClass("hidden"):this.$el.find(".to-email-container").addClass("hidden");const e=["specifiedTeams","specifiedUsers","specifiedContacts"];e.forEach(t=>{const e=this.$el.find(".to"+Espo.Utils.upperCaseFirst(t)+"-container");e.hasClass("hidden")||e.addClass("hidden")}),e.includes(t)&&this.$el.find(".to"+Espo.Utils.upperCaseFirst(t)+"-container").removeClass("hidden")},getFromOptions:function(){const t=[],e=this.actionData.from,i=["system","specifiedEmailAddress"];return this.options.flowchartCreatedEntitiesData||i.push("currentUser"),i.forEach(e=>{const i=this.translate(e,"emailAddressOptions","Workflow");t.push([e,i])}),this.getLinkOptions(e,!0,!0).forEach(e=>t.push(e)),t},getReplyToOptions:function(){const t=[];return["","system","currentUser","specifiedEmailAddress"].forEach(e=>{const i=this.translate(e,"emailAddressOptions","Workflow");t.push([e,i])}),this.getLinkOptions(void 0,!1,!0).forEach(e=>t.push(e)),t},getToOptions:function(){const t=[],e=this.actionData.to,i=["currentUser","teamUsers","specifiedTeams","specifiedUsers","specifiedContacts","specifiedEmailAddress","followers","followersExcludingAssignedUser"];"Email"===this.entityType&&i.push("fromOrReplyTo");if("emailAddress"in(this.getMetadata().get(`entityDefs.${this.entityType}.fields`)||{})&&"Email"!==this.entityType){const e="targetEntity",i=this.translate(e,"emailAddressOptions","Workflow")+" · "+this.translate(this.entityType,"scopeNames");t.push([e,i])}return i.forEach(e=>{const i=this.translate(e,"emailAddressOptions","Workflow");t.push([e,i])}),this.getLinkOptions(e).forEach(e=>t.push(e)),t},getLinkOptions:function(t,e,i){const s=[],a=this.getMetadata().get(`entityDefs.${this.entityType}.links`)||{};return Object.keys(a).forEach(t=>{if("belongsTo"===a[t].type||"hasMany"===a[t].type){const n=a[t].entity;if(!n)return;if("hasMany"===a[t].type){if(i)return;if("linkMultiple"!==this.getMetadata().get(["entityDefs",this.entityType,"fields",t,"type"]))return}const o=this.getMetadata().get(`entityDefs.${n}.fields`)||{};if(e&&"User"!==n)return;if("emailAddress"in o&&"email"===o.emailAddress.type){const e=this.translate("Related","labels","Workflow")+" · "+this.translate(t,"links",this.entityType);s.push([`link:${t}`,e])}}else if("belongsToParent"===a[t].type){if(e)return;const i=this.translate("Related","labels","Workflow")+" · "+this.translate(t,"links",this.entityType);s.push([`link:${t}`,i])}}),Object.keys(a).forEach(t=>{if("belongsTo"!==a[t].type)return;const n=this.getMetadata().get(["entityDefs",this.entityType,"links",t,"entity"]);if(!n)return;if("User"===n)return;if(!i&&this.getMetadata().get(["scopes",n,"stream"])){const e=this.translate("Related","labels","Workflow")+" · "+this.translate(t,"links",this.entityType)+" . "+this.translate("Followers");s.push([`link:${t}.followers`,e])}const o=this.getMetadata().get(`entityDefs.${n}.links`)||{};Object.keys(o).forEach(i=>{let a;if(("belongsTo"===o[i].type||"hasMany"===o[i].type)&&(a=o[i].entity,!a))return;if("hasMany"===o[i].type&&"linkMultiple"!==this.getMetadata().get(["entityDefs",a,"fields",i,"type"]))return;const r=this.getMetadata().get(["entityDefs",a,"fields"])||{};if((!e||"User"===a)&&"emailAddress"in r&&"email"===r.emailAddress.type){const e=this.translate("Related","labels","Workflow")+" · "+this.translate(t,"links",this.entityType)+" . "+this.translate(i,"links",n);s.push([`link:${t}.${i}`,e])}})}),Object.keys(this.getMetadata().get(["entityDefs",this.entityType,"links"])||{}).forEach(t=>{if("belongsToParent"===this.getMetadata().get(["entityDefs",this.entityType,"links",t,"type"])){let e="assignedUser",a=this.translate("Related","labels","Workflow")+" · "+this.translate(t,"links",this.entityType)+" . "+this.translate(e,"links");if(s.push([`link:${t}.${e}`,a]),i)return;e="followers",a=this.translate("Related","labels","Workflow")+" · "+this.translate(t,"links",this.entityType)+" . "+this.translate("Followers"),s.push([`link:${t}.${e}`,a]),e="contacts",a=this.translate("Related","labels","Workflow")+" · "+this.translate(t,"links",this.entityType)+" . "+this.translate("Contact","scopeNamesPlural"),s.push([`link:${t}.${e}`,a])}}),s},fetch:function(){let t=!1;const e=this.getView("emailTemplate");e.fetchToModel(),e.validate()&&(t=!0);const i=e.fetch();if("specifiedEmailAddress"===this.formModel.attributes.from&&this.getView("fromEmailAddress").validate()&&(t=!0),"specifiedEmailAddress"===this.formModel.attributes.to&&this.getView("toEmailAddress").validate()&&(t=!0),"specifiedEmailAddress"===this.formModel.attributes.replyTo&&this.getView("replyToEmailAddress").validate()&&(t=!0),"specifiedEmailAddress"===this.formModel.attributes.cc&&this.getView("ccEmailAddress").validate()&&(t=!0),t)return;this.actionData.attachmentsVariable=this.formModel.attributes.attachmentsVariable,this.actionData.emailTemplateId=i.emailTemplateId,this.actionData.emailTemplateName=i.emailTemplateName,this.actionData.from=this.formModel.attributes.from,this.actionData.to=this.formModel.attributes.to,this.actionData.replyTo=this.formModel.attributes.replyTo,this.actionData.cc=this.formModel.attributes.cc,["specifiedTeams","specifiedUsers","specifiedContacts"].includes(this.actionData.to)&&(this.actionData=_.extend(this.actionData,this.getSpecifiedEntityData(this.actionData.to,"to"))),this.actionData.fromEmail=this.formModel.attributes.fromEmailAddress,this.actionData.toEmail=this.formModel.attributes.toEmailAddress,this.actionData.replyToEmail=this.formModel.attributes.replyToEmailAddress,this.actionData.ccEmail=this.formModel.attributes.ccEmailAddress,this.actionData.doNotStore=this.getViewData("doNotStore").doNotStore||!1,this.actionData.optOutLink=this.getViewData("optOutLink").optOutLink||!1;const s=this.getView("executionTime").fetch();return this.actionData.execution=this.actionData.execution||{},this.actionData.execution.type=s.type,delete this.actionData.execution.field,delete this.actionData.execution.shiftDays,delete this.actionData.execution.shiftUnit,"immediately"!==s.type&&(this.actionData.execution.field=s.field,this.actionData.execution.shiftDays=s.shiftValue,this.actionData.execution.shiftUnit=s.shiftUnit),!0},getViewData:function(t){const e=this.getView(t);return e?(e.fetchToModel(),e.fetch()):{}},getSpecifiedEntityData:function(t,e){const i=e+t.charAt(0).toUpperCase()+t.slice(1),s=this.getView(i),a={};if(s){s.fetchToModel();const t=s.fetch();a[e+"SpecifiedEntityName"]=s.foreignScope,a[e+"SpecifiedEntityIds"]=t[s.idsName],a[e+"SpecifiedEntityNames"]=t[s.nameHashName]}return a}})}),define("advanced:views/workflow/action-modals/run-service",["advanced:views/workflow/action-modals/base","model"],function(t,e){return t.extend({template:"advanced:workflow/action-modals/run-service",data:function(){return _.extend({},t.prototype.data.call(this))},setup:function(){t.prototype.setup.call(this);var i=new e;i.name="Workflow",this.actionModel=i,this.actionData.methodName&&i.set({methodName:this.actionData.methodName,additionalParameters:this.actionData.additionalParameters,helpText:this.getHelperText(this.actionData.methodName),target:this.actionData.target||"targetEntity"}),this.controlTargetEntity(),this.listenTo(i,"change:target",()=>{this.actionData.target=i.get("target")||null,i.set({methodName:null}),this.controlTargetEntity();var t=this.getView("methodName");t&&(t.translatedOptions=this.methodTranslatedOptions,t.setOptionList(this.methodOptionList))}),this.setupTargetOptions(),this.createView("target","views/fields/enum",{mode:"edit",model:i,selector:'.field[data-name="target"]',defs:{name:"target",params:{options:this.targetOptionList}},readOnly:this.readOnly,translatedOptions:this.targetTranslatedOptions}),this.createView("methodName","views/fields/enum",{mode:"edit",model:i,selector:'.field[data-name="methodName"]',defs:{name:"methodName",params:{options:this.methodOptionList,required:!0,translatedOptions:this.methodTranslatedOptions}},readOnly:this.readOnly}),this.createView("additionalParameters","views/fields/formula",{mode:"edit",model:i,selector:'.field[data-name="additionalParameters"]',defs:{name:"additionalParameters"},readOnly:this.readOnly,height:60,insertDisabled:!0,checkSyntaxDisabled:!0},t=>{t.validations=["json"],t.validateJson=function(){var t=this.model.get(this.name);if(t&&(t=t.trim())){try{return JSON.parse(t),!1}catch(t){}var e=this.translate("jsonInvalid","messages","Workflow");return this.showValidationMessage(e,".ace_editor"),!0}}});this.createView("helpText","advanced:views/workflow/fields/help-text",{mode:"detail",model:i,selector:'.field[data-name="helpText"]',defs:{name:"helpText"},readOnly:!0});this.listenTo(i,"change:methodName",()=>{var t=this.getHelperText(i.get("methodName")).toString();i.set("helpText",t)})},controlTargetEntity:function(){this.setupMethodOptionList()},setupMethodOptionList:function(){var t=[""],e={},i=this.entityType,s=this.actionData.target||"targetEntity";if(0===s.indexOf("link:")){var a=s.substr(5);i=this.getMetadata().get(["entityDefs",this.entityType,"links",a,"entity"])}else if(0===s.indexOf("created:")){var n=s.substr(8);i=this.options.flowchartCreatedEntitiesData[n].entityType}if(i){const s=this.getMetadata().get(["entityDefs","Workflow","serviceActions",i]);if(s&&Array.isArray(s))s.forEach(i=>{t.push(i),e[i]=this.getLabel(i,"serviceActions")});else if(s)for(const i in s)t.push(i),e[i]=this.getLabel(i,"serviceActions");[...Object.keys(this.getMetadata().get("app.workflow.serviceActions.Global")||{}),...Object.keys(this.getMetadata().get(`app.workflow.serviceActions.${i}`)||{})].forEach(i=>{t.includes(i)||(t.push(i),e[i]=this.getLabel(i,"serviceActions"))})}this.targetEntityType=i,this.methodOptionList=t,this.methodTranslatedOptions=e},setupTargetOptions:function(){const t=[],e={targetEntity:this.translateTargetItem("targetEntity",!0)};t.push("targetEntity");const i=this.getMetadata().get(["entityDefs",this.entityType,"links"])||{};Object.keys(i).forEach(s=>{if("belongsTo"!==i[s].type)return;const a="link:"+s;t.push(a),e[a]=this.translateTargetItem(a,!0)}),this.options.flowchartCreatedEntitiesData&&Object.keys(this.options.flowchartCreatedEntitiesData).forEach(i=>{const s="created:"+i;t.push(s),e[s]=this.translateTargetItem(s,!0)}),this.targetOptionList=t,this.targetTranslatedOptions=e},fetch:function(){const t=this.actionModel;this.getView("methodName").fetchToModel(),this.getView("additionalParameters").fetchToModel();let e=!1;if(e=e||this.getView("methodName").validate(),e=e||this.getView("additionalParameters").validate(),!e)return this.actionData.target=t.get("target")||null,this.actionData.targetEntityType=this.targetEntityType,this.actionData.methodName=this.getView("methodName").fetch().methodName,this.actionData.additionalParameters=this.getView("additionalParameters").fetch().additionalParameters,!0},getLabel:function(t,e,i){if(!t)return i;const s=this.targetEntityType+t.charAt(0).toUpperCase()+t.slice(1);return this.getLanguage().has(s,e,"Workflow")?this.translate(s,e,"Workflow"):null==i||this.getLanguage().has(t,e,"Workflow")?this.translate(t,e,"Workflow"):i},getHelperText:function(t){let e=this.getLabel(t,"serviceActionsHelp","");return this.getHelper().transformMarkdownText&&(e=e.replace(/&quot;/g,'"'),e=this.getHelper().transformMarkdownText(e,{})),e}})}),define("advanced:views/workflow/action-modals/execute-formula",["advanced:views/workflow/action-modals/base","model"],function(t,e){return t.extend({template:"advanced:workflow/action-modals/execute-formula",setup:function(){t.prototype.setup.call(this);var i=new e;i.set("formula",this.actionData.formula||null),this.createView("formula","views/fields/formula",{name:"formula",model:i,mode:this.readOnly?"detail":"edit",height:200,selector:'.field[data-name="formula"]',inlineEditDisabled:!0,targetEntityType:this.entityType})},fetch:function(){var t=this.getView("formula");return this.actionData.formula=t.fetch().formula,!0}})}),define("advanced:views/workflow/action-modals/create-related-entity",["advanced:views/workflow/action-modals/create-entity","model"],function(t,e){return t.extend({template:"advanced:workflow/action-modals/create-related-entity",permittedLinkTypes:["belongsTo","hasMany","hasChildren"],getLinkOptions:function(){const t=[[""]];return Object.keys(this.getMetadata().get(`entityDefs.${this.entityType}.links`)||[]).sort((t,e)=>this.translate(t,"links",this.scope).localeCompare(this.translate(e,"links",this.scope))).forEach(e=>{const i=this.getMetadata().get(`entityDefs.${this.entityType}.links.${e}`);if(!i.disabled&&this.permittedLinkTypes.includes(i.type)){const i=this.translate(e,"links",this.entityType);t.push([e,i])}}),t},setupScope:function(t){if(this.actionData.link){const e=this.getMetadata().get(`entityDefs.${this.entityType}.links.${this.actionData.link}.entity`);if(this.scope=e,!e)throw new Error;this.wait(!0),this.getModelFactory().create(e,e=>{this.model=e,(this.actionData.fieldList||[]).forEach(t=>{const i=(this.actionData.fields[t]||{}).attributes||{};e.set(i,{silent:!0})}),t()})}else this.model=null,t()},setupFormulaView:function(){const t=new e,i=this.element.querySelector('[data-name="formula"] .field-info');i&&i.parentNode.removeChild(i),this.hasFormulaAvailable&&(t.set("formula",this.actionData.formula||null),this.createView("formula","views/fields/formula",{name:"formula",model:t,mode:this.readOnly?"detail":"edit",height:100,selector:'.field[data-name="formula"]',inlineEditDisabled:!0,targetEntityType:this.scope,params:{tooltip:!0},tooltipText:this.translate("createEntityFormula","tooltips","Workflow")},t=>{t.render()}))}})}),define("advanced:views/workflow/action-modals/create-notification",["advanced:views/workflow/action-modals/base","model"],function(t,e){return t.extend({template:"advanced:workflow/action-modals/create-notification",data:function(){return _.extend({messageTemplateHelpText:this.translate("messageTemplateHelpText","messages","Workflow")},t.prototype.data.call(this))},afterRender:function(){t.prototype.afterRender.call(this),this.handleRecipient()},setup:function(){t.prototype.setup.call(this);const i=this.formModel=new e;i.name="Workflow",i.set({recipient:this.actionData.recipient,messageTemplate:this.actionData.messageTemplate,usersIds:this.actionData.userIdList,usersNames:this.actionData.userNames,specifiedTeamsIds:this.actionData.specifiedTeamsIds,specifiedTeamsNames:this.actionData.specifiedTeamsNames});const s=this.getRecipientOptions();this.createView("recipient","views/fields/enum",{selector:".field-recipient",model:i,mode:"edit",defs:{name:"recipient"},params:{options:s.map(t=>t[0])},translatedOptions:Object.fromEntries(s)}),this.createView("messageTemplate","views/fields/text",{selector:".field-messageTemplate",model:i,mode:"edit",defs:{name:"messageTemplate",params:{required:!1}}}),this.createView("users","views/fields/link-multiple",{mode:"edit",model:i,selector:".field-users",foreignScope:"User",defs:{name:"users"},readOnly:this.readOnly}),this.createView("specifiedTeams","views/fields/link-multiple",{selector:".field-specifiedTeams",model:i,mode:"edit",foreignScope:"Team",defs:{name:"specifiedTeams"},readOnly:this.readOnly}),this.listenTo(this.formModel,"change:recipient",()=>this.handleRecipient())},handleRecipient:function(){const t=this.formModel.attributes.recipient;"specifiedUsers"===t?this.$el.find(".cell-users").removeClass("hidden"):this.$el.find(".cell-users").addClass("hidden"),"specifiedTeams"===t?this.$el.find(".cell-specifiedTeams").removeClass("hidden"):this.$el.find(".cell-specifiedTeams").addClass("hidden")},getRecipientOptions:function(){const t=["specifiedUsers","teamUsers","specifiedTeams","followers","followersExcludingAssignedUser"];this.options.flowchartCreatedEntitiesData||t.push("currentUser");const e=[];return t.forEach(t=>{const i=this.translate(t,"emailAddressOptions","Workflow");e.push([t,i])}),this.getLinkOptions().forEach(t=>e.push(t)),e},getLinkOptions:function(){const t=this.getMetadata().get(`entityDefs.${this.entityType}.links`)||{},e=[];return Object.keys(t).forEach(i=>{if("belongsTo"===t[i].type||"hasMany"===t[i].type){if("User"!==t[i].entity)return;const s=this.translate("Related","labels","Workflow")+" · "+this.translate(i,"links",this.entityType);e.push([`link:${i}`,s])}}),Object.keys(t).forEach(i=>{const s=t[i].type;if("belongsTo"!==s&&"hasMany"!==s)return;const a=this.getMetadata().get(["entityDefs",this.entityType,"links",i,"entity"]);if(!a||"User"===a)return;if(this.getMetadata().get(["scopes",a,"stream"])){const t=this.translate("Related","labels","Workflow")+" · "+this.translate(i,"links",this.entityType)+" . "+this.translate("Followers");e.push([`link:${i}.followers`,t])}const n=this.getMetadata().get(`entityDefs.${a}.links`)||{};Object.keys(n).forEach(t=>{let o;const r=n[t].type;if("belongsTo"!==s&&"hasMany"===r)return;if("belongsTo"!==r&&"hasMany"!==r||(o=n[t].entity),"User"!==o)return;const l=this.translate("Related","labels","Workflow")+" · "+this.translate(i,"links",this.entityType)+" . "+this.translate(t,"links",a);e.push([`link:${i}.${t}`,l])})}),Object.keys(this.getMetadata().get(["entityDefs",this.entityType,"links"])||{}).forEach(t=>{if("belongsToParent"!==this.getMetadata().get(["entityDefs",this.entityType,"links",t,"type"]))return;let i=this.translate("Related","labels","Workflow")+" · "+this.translate(t,"links",this.entityType)+" . "+this.translate("assignedUser","links");e.push([`link:${t}.assignedUser`,i]),i=this.translate("Related","labels","Workflow")+" · "+this.translate(t,"links",this.entityType)+" . "+this.translate("Followers"),e.push([`link:${t}.followers`,i])}),e},fetch:function(){if(this.actionData.messageTemplate=(this.getView("messageTemplate").fetch()||{}).messageTemplate,this.actionData.recipient=this.formModel.attributes.recipient,"specifiedUsers"===this.actionData.recipient){const t=this.getView("users").fetch()||{};this.actionData.userIdList=t.usersIds,this.actionData.userNames=t.usersNames}else this.actionData.userIdList=[],this.actionData.userNames={};if(this.actionData.specifiedTeamsIds=[],this.actionData.specifiedTeamsNames={},"specifiedTeams"===this.actionData.recipient){const t=this.getView("specifiedTeams").fetch()||{};this.actionData.specifiedTeamsIds=t.specifiedTeamsIds,this.actionData.specifiedTeamsNames=t.specifiedTeamsNames}return!0}})}),define("advanced:views/workflow/action-modals/apply-assignment-rule",["advanced:views/workflow/action-modals/base","model"],function(t,e){return t.extend({template:"advanced:workflow/action-modals/apply-assignment-rule",data:function(){return _.extend({},t.prototype.data.call(this))},events:{},afterRender:function(){t.prototype.afterRender.call(this),this.controlVisibility()},setup:function(){t.prototype.setup.call(this);var i=new e;if(i.name="Workflow",this.actionModel=i,this.actionModel.targetEntityType=this.options.entityType,i.set({assignmentRule:this.actionData.assignmentRule,targetTeamId:this.actionData.targetTeamId,targetTeamName:this.actionData.targetTeamName,targetUserPosition:this.actionData.targetUserPosition,listReportId:this.actionData.listReportId,listReportName:this.actionData.listReportName,target:this.actionData.target||""}),this.createView("assignmentRule","views/fields/enum",{mode:"edit",model:i,selector:'.field[data-name="assignmentRule"]',defs:{name:"assignmentRule",params:{options:this.getMetadata().get("entityDefs.Workflow.assignmentRuleList")||[]}},readOnly:this.readOnly}),this.createView("targetTeam","views/fields/link",{mode:"edit",model:i,selector:'.field[data-name="targetTeam"]',foreignScope:"Team",defs:{name:"targetTeam",params:{required:!0}},readOnly:this.readOnly}),this.createView("targetUserPosition","advanced:views/workflow/fields/target-user-position",{mode:"edit",model:i,selector:'.field[data-name="targetUserPosition"]',defs:{name:"targetUserPosition"},readOnly:this.readOnly}),this.createView("listReport","advanced:views/workflow/fields/list-report",{mode:"edit",model:i,selector:'.field[data-name="listReport"]',entityType:this.options.entityType,foreignScope:"Report",defs:{name:"listReport"},readOnly:this.readOnly}),this.options.flowchartCreatedEntitiesData){this.controlTargetEntity();const t=["","process"],e={"":this.translate("Target Entity","labels","Workflow")+" · "+this.translate(this.entityType,"scopeName"),process:this.translate("Process","labels","Workflow")};Object.keys(this.options.flowchartCreatedEntitiesData).forEach(function(i){t.push("created:"+i);const s=this.options.flowchartCreatedEntitiesData[i].link,a=this.options.flowchartCreatedEntitiesData[i].entityType,n=this.options.flowchartCreatedEntitiesData[i].numberId,o=this.options.flowchartCreatedEntitiesData[i].text;let r=this.translate("Created","labels","Workflow")+" · ";s&&(r+=this.translate(s,"links",this.entityType)+" - "),r+=this.translate(a,"scopeNames"),o?r+=" '"+o+"'":n&&(r+=" #"+n.toString()),e["created:"+i]=r},this),this.createView("target","views/fields/enum",{mode:"edit",model:i,selector:'.field[data-name="target"]',defs:{name:"target",params:{options:t}},readOnly:this.readOnly,translatedOptions:e}),this.listenTo(i,"change:target",function(){this.actionData.target=i.get("target")||null,i.set({listReportId:null,listReportName:null}),this.controlTargetEntity(),this.controlVisibility()},this)}this.listenTo(i,"change:assignmentRule",function(){this.controlVisibility()},this)},controlTargetEntity:function(){if(this.actionModel.targetEntityType=this.options.entityType,this.actionData.target)if(0===this.actionData.target.indexOf("created:")){this.actionModel.targetEntityType=null;var t=this.actionData.target.substr(8);this.options.flowchartCreatedEntitiesData[t]&&(this.actionModel.targetEntityType=this.options.flowchartCreatedEntitiesData[t].entityType)}else"process"===this.actionData.target&&(this.actionModel.targetEntityType=null)},controlVisibility:function(){if(this.isRendered()){var t=this.getView("listReport").$el.closest(".cell");"process"===this.actionData.target||"Least-Busy"!==this.actionModel.get("assignmentRule")?t.addClass("hidden"):t.removeClass("hidden")}},fetch:function(){var t=this.actionModel;this.getView("assignmentRule").fetchToModel(),this.getView("targetTeam").fetchToModel(),this.getView("targetUserPosition").fetchToModel(),this.getView("listReport").fetchToModel(),this.options.flowchartCreatedEntitiesData&&this.getView("target").fetchToModel();var e=!1;if(e=this.getView("assignmentRule").validate()||e,e=this.getView("targetTeam").validate()||e,e=this.getView("targetUserPosition").validate()||e,!(e=this.getView("listReport").validate()||e))return this.actionData.assignmentRule=t.get("assignmentRule"),this.actionData.targetTeamId=t.get("targetTeamId"),this.actionData.targetTeamName=t.get("targetTeamName"),this.actionData.targetUserPosition=t.get("targetUserPosition"),this.actionData.listReportId=t.get("listReportId"),this.actionData.listReportName=t.get("listReportName"),"Least-Busy"!==this.actionData.assignmentRule&&(this.actionData.listReportId=null,this.actionData.listReportName=null),this.options.flowchartCreatedEntitiesData&&(this.actionData.target=t.get("target")||null),!0}})}),define("advanced:views/workflow/action-fields/shift-days",["view","model"],function(t,e){return t.extend({template:"advanced:workflow/action-fields/shift-days",data:function(){return{shiftDaysOperator:this.shiftDaysOperator,value:this.value,unitValue:this.options.unitValue,readOnly:this.readOnly}},setup:function(){this.value=this.options.value,this.readOnly=this.options.readOnly;const t=this.options.value||0;this.value<0?(this.shiftDaysOperator="minus",this.value=-1*this.value):this.shiftDaysOperator="plus";let i=["minutes","hours","days","months"];this.options.isDate&&(i=["days","months"]),this.formModel=new e,this.formModel.name="Dummy",this.formModel.set({operator:t<0?"minus":"plus",value:t<0?-1*t:t,unit:this.options.unitValue||i[0]}),this.readOnly||(this.createView("operatorField","views/fields/enum",{name:"operator",selector:'[data-field="operator"]',model:this.formModel,mode:"edit",params:{options:["plus","minus"]},translatedOptions:{plus:this.translate("plus","labels","Workflow"),minus:this.translate("minus","labels","Workflow")}}),this.createView("valueField","views/fields/int",{name:"value",selector:'[data-field="value"]',model:this.formModel,mode:"edit",min:0}),this.createView("unitField","views/fields/enum",{name:"unit",selector:'[data-field="unit"]',model:this.formModel,mode:"edit",params:{options:i},translatedOptions:{minutes:this.translate("minutes","labels","Workflow"),hours:this.translate("hours","labels","Workflow"),days:this.translate("days","labels","Workflow"),months:this.translate("months","labels","Workflow")}}))},fetch:function(){let t=this.formModel.attributes.value;return"minus"===this.formModel.attributes.operator&&(t*=-1),{value:t,unit:this.formModel.attributes.unit}}})}),define("advanced:views/workflow/action-fields/execution-time",["view","model"],function(t,e){return t.extend({template:"advanced:workflow/action-fields/execution-time",data:function(){return{type:this.executionData.type,field:this.executionData.field,shiftDays:this.executionData.shiftDays,shiftUnit:this.executionData.shiftUnit,readOnly:this.readOnly}},setup:function(){this.executionData=this.options.executionData||{},this.readOnly=this.options.readOnly||!1,this.formModel=new e,this.formModel.name="Dummy",this.formModel.set({type:this.executionData.type||"immediately"}),this.readOnly||(this.createView("typeField","views/fields/enum",{model:this.formModel,selector:'[data-field="type"]',name:"type",mode:"edit",params:{options:["immediately","later"]},translatedOptions:{immediately:this.translate("immediately","labels","Workflow"),later:this.translate("later","labels","Workflow")}}),this.listenTo(this.formModel,"change:type",()=>this.handleType())),this.createFieldView(),this.createShiftDaysView()},afterRender:function(){this.handleType()},reRender:function(){return this.createFieldView(),this.createShiftDaysView(),t.prototype.reRender.call(this)},handleType:function(){if("later"!==(this.readOnly?this.executionData.type:this.formModel.attributes.type))return this.$el.find(".field-container").addClass("hidden"),void this.$el.find(".shift-days-container").addClass("hidden");this.$el.find(".field-container").removeClass("hidden"),this.$el.find(".shift-days-container").removeClass("hidden")},createFieldView:function(){this.createView("field","advanced:views/workflow/action-fields/date-field",{selector:".field-container",value:this.executionData.field,entityType:this.options.entityType,readOnly:this.readOnly})},createShiftDaysView:function(){this.createView("shiftDays","advanced:views/workflow/action-fields/shift-days",{selector:".shift-days-container",value:this.executionData.shiftDays||0,unitValue:this.executionData.shiftUnit||"days",readOnly:this.readOnly})},fetch:function(){const t=this.getView("shiftDays").fetch();return{field:this.getView("field").fetchValue(),type:this.formModel.attributes.type,shiftValue:t.value,shiftUnit:t.unit}}})}),define("advanced:views/workflow/action-fields/date-field",["view","model"],function(t,e){return t.extend({template:"advanced:workflow/action-fields/date-field",data:function(){return{value:this.options.value,entityType:this.entityType,stringValue:this.stringValue,readOnly:this.readOnly}},setup:function(){if(this.entityType=this.options.entityType,this.readOnly=this.options.readOnly,this.readOnly)this.buildStringValue();else{this.formModel=new e,this.formModel.name="Dummy",this.formModel.set({executionField:this.options.value});const t=this.getOptions();this.createView("executionField","views/fields/enum",{name:"executionField",selector:'[data-field="executionField"]',model:this.formModel,mode:"edit",params:{options:t.map(t=>t[0])},translatedOptions:Object.fromEntries(t)})}},getOptions:function(){const t=[],e=["date","datetime"],i=[],s=this.getMetadata().get(`entityDefs.${this.entityType}.fields`)||{};Object.keys(s).forEach(t=>{s[t].utility||s[t].directAccessDisabled&&!s[t].loaderClassName||e.includes(s[t].type)&&i.push(t)}),t.push(["",this.translate("now","labels","Workflow")]),i.forEach(e=>{t.push([e,this.translate(e,"fields",this.entityType)])});const a={},n=this.getMetadata().get(`entityDefs.${this.entityType}.links`);Object.keys(n).forEach(t=>{const i=[];if("belongsTo"===n[t].type){const s=n[t].entity;if(!s)return;const o=this.getMetadata().get(`entityDefs.${s}.fields`)||{};Object.keys(o).forEach(t=>{o[t].utility||o[t].directAccessDisabled||e.includes(o[t].type)&&i.push(t)}),a[t]=i}});for(const e in a)a[e].forEach(i=>{const s=this.translate(e,"links",this.entityType)+" . "+this.translate(i,"fields",n[e].entity);t.push([`${e}.${i}`,s])});return t},buildStringValue:function(){const t=this.options.value;if(t){const e=this.entityType;if(t.includes(".")){const[i,s]=t.split("."),a=this.getMetadata().get(`entityDefs.${this.entityType}.links.${i}.entity`);return void(this.stringValue=this.translate(i,"links",e)+" . "+this.translate(s,"fields",a))}return void(this.stringValue=this.translate(t,"fields",e))}this.stringValue=this.translate("now","labels","Workflow")},fetchValue:function(){return this.formModel.attributes.executionField}})}),define("advanced:views/workflow/action-fields/add-field",["view"],function(t){return t.extend({templateContent:'\n            <button\n                class="btn btn-default radius-right"\n                type="button"\n                data-action="showAddField"\n            ><span class="fas fa-plus fa-sm"></span><span>{{translate \'Add Field\' scope=\'Workflow\'}}</span></button>\n        ',setup:function(){this.addActionHandler("showAddField",()=>{const t=this.options.fieldList.filter(t=>!this.options.addedFieldList.includes(t));this.createView("modal","advanced:views/workflow/modals/add-field",{fieldList:t,scope:this.options.scope}).then(t=>{t.render(),this.listenToOnce(t,"add",t=>{this.options.onAdd(t)})})})}})}),define("advanced:views/workflow/action-fields/subjects/field",["view","model"],function(t,e){return t.extend({template:"advanced:workflow/action-fields/subjects/field",data:function(){return{value:this.options.value,entityType:this.entityType,listHtml:this.listHtml,readOnly:this.readOnly}},setup:function(){const t=this.entityType=this.options.entityType,i=this.options.scope,s=this.options.field;this.readOnly=this.options.readOnly,this.foreignScope=null;let a=this.options.value;const n=this.fieldType=this.getMetadata().get(`entityDefs.${i}.fields.${s}.type`)||"base";if("link"!==n&&"linkMultiple"!==n||(this.foreignScope=this.getMetadata().get(`entityDefs.${i}.links.${s}.entity`)),this.readOnly){if(a&&~a.indexOf(".")){const e=a.split("."),i=this.getMetadata().get(`entityDefs.${t}.links.${e[0]}.entity`);this.listHtml=this.translate("Field","labels","Workflow")+" · "+this.translate(e[0],"links",t)+" . "+this.translate(e[1],"fields",i)}else this.listHtml=this.translate("Field","labels","Workflow")+" · "+this.translate(a,"fields",t);return}const o=this.formModel=new e;o.name="Dummy";const r=this.getFieldOptions();!a&&r.length&&(a=r[0][0]),o.set({value:a}),this.createView("valueField","views/fields/enum",{selector:'[data-field="value"]',model:o,name:"value",mode:"edit",params:{options:r.map(t=>t[0])},translatedOptions:Object.fromEntries(r)})},getFieldOptions:function(){const t=[],e=this.fieldType,i=this.entityType,s=[],a=this.getMetadata().get(`entityDefs.${i}.fields`),n=this.getMetadata().get(`entityDefs.Workflow.fieldTypeComparison.${e}`)||[];Object.keys(a).sort((t,e)=>this.translate(t,"fields",i).localeCompare(this.translate(e,"fields",i))).forEach(t=>{if((a[t].type===e||n.includes(a[t].type))&&!(a[t].directAccessDisabled&&!a[t].loaderClassName||a[t].disabled||a[t].utility)){if("link"===e||"linkMultiple"===e){if(this.getMetadata().get(`entityDefs.${i}.links.${t}.entity`)!==this.foreignScope)return}s.push(t)}}),n.includes("id")&&"linkParent"===e&&s.unshift("id"),s.forEach(e=>{const s=this.translate(e,"fields",i);t.push([e,s])});const o={},r=this.getMetadata().get(`entityDefs.${i}.links`);Object.keys(r).sort().forEach(t=>{const i=[];if("belongsTo"!==r[t].type)return;if(r[t].disabled||r[t].utility)return;const s=r[t].entity;if(!s)return;const a=this.getMetadata().get(`entityDefs.${s}.fields`);Object.keys(a).sort((t,e)=>this.translate(t,"fields",s).localeCompare(this.translate(e,"fields",s))).forEach(t=>{if((a[t].type===e||n.includes(a[t].type))&&!(a[t].directAccessDisabled&&!a[t].loaderClassName||a[t].disabled||a[t].utility)){if("link"===e||"linkMultiple"===e){if(this.getMetadata().get(`entityDefs.${s}.links.${t}.entity`)!==this.foreignScope)return}i.push(t)}}),o[t]=i});for(const e in o)o[e].forEach(s=>{const a=this.translate(e,"links",i)+" . "+this.translate(s,"fields",r[e].entity);t.push([`${e}.${s}`,a])});return t},fetchValue:function(){return this.formModel.attributes.value}})}),define("advanced:views/target-list/record/panels/sync-with-reports",["views/record/panels/side"],function(t){return t.extend({fieldList:["syncWithReportsEnabled","syncWithReports","syncWithReportsUnlink"],actionList:[{name:"syncWithReport",label:"Sync Now",acl:"edit",action:"syncWithReports"}],setup:function(){t.prototype.setup.call(this)},actionSyncWithReports:function(){this.model.get("syncWithReportsEnabled")&&(Espo.Ui.notify(" ... "),Espo.Ajax.postRequest("Report/action/syncTargetListWithReports",{targetListId:this.model.id}).then(()=>{Espo.Ui.success(this.translate("Done")),this.model.trigger("after:relate")}))}})}),define("advanced:views/target-list/record/panels/relationship",["crm:views/target-list/record/panels/relationship"],function(t){return t.extend({actionPopulateFromReport:function(t){let e=t.link,i="list"+Espo.Utils.upperCaseFirst(e);Espo.Ui.notify(" ... "),this.createView("dialog","views/modals/select-records",{scope:"Report",multiple:!1,createButton:!1,primaryFilterName:i},t=>{t.render(),Espo.Ui.notify(!1),this.listenToOnce(t,"select",t=>{Espo.Ajax.postRequest("Report/action/populateTargetList",{id:t.id,targetListId:this.model.id}).then(()=>{Espo.Ui.success(this.translate("Linked")),this.collection.fetch()})})})}})}),define("advanced:views/target-list/fields/sync-with-reports",["views/fields/link-multiple"],function(t){return t.extend({getSelectPrimaryFilterName:function(){return"listTargets"}})}),define("advanced:views/report-panel/list",["views/list"],function(t){return t.extend({actionRebuildPanels:function(){Espo.Ui.notify(" ... "),Espo.Ajax.postRequest("ReportPanel/action/rebuild",{}).then(()=>{Espo.Ui.success(this.translate("Done"))})}})}),define("advanced:views/report-panel/record/list","views/record/list",function(t){return t.extend({massActionList:[]})}),define("advanced:views/report-panel/record/edit",["views/record/edit"],function(t){return t.extend({sideDisabled:!0})}),define("advanced:views/report-panel/record/edit-small",["views/record/edit-small"],function(t){return t.extend({sideDisabled:!0})}),define("advanced:views/report-panel/record/panels/report-panel-bottom",["advanced:views/report-panel/record/panels/report-panel-side"],function(t){return t.extend({})}),define("modules/advanced/views/report-panel/fields/report",["exports","views/fields/link","modules/advanced/report-helper"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{createDisabled=!0;setup(){super.setup(),this.reportHelper=new i.default(this.getMetadata(),this.getLanguage(),this.getDateTime(),this.getConfig(),this.getPreferences())}select(t){if(this.model.set("reportType",t.attributes.type,{isManual:!0}),this.model.set("reportEntityType",t.attributes.entityType),"Grid"!==t.attributes.type)"List"===t.attributes.type&&this.model.set("displayTotal",!1),this.model.set("column",null);else{let e=null,i=t.attributes.columns??[];i.length&&(e=i[0]),i=i.filter(e=>this.reportHelper.isColumnNumeric(e,t)),(t.attributes.groupBy??[]).length<2&&i.length>1&&i.unshift(""),this.model.set("column",e),this.model.set("columnsData",t.attributes.columnsData),this.model.set("internalClassName",t.attributes.internalClassName),this.model.trigger("update-columns",i)}super.select(t)}clearLink(){super.clearLink(),this.model.set("reportType",null,{isManual:!0}),this.model.set("displayTotal",!1)}}t.default=a}),define("advanced:views/report-panel/fields/entity-type",["views/fields/entity-type"],function(t){return t.extend({setupOptions:function(){var t=this.scopesMetadataDefs=this.getMetadata().get("scopes");this.params.options=Object.keys(t).filter(t=>{if(this.checkAvailability(t))return!0}),this.params.options.push("Team"),this.params.options.sort((t,e)=>this.translate(t,"scopeNames").localeCompare(this.translate(e,"scopeNames"))),this.params.options.unshift("")}})}),define("advanced:views/report-panel/fields/dynamic-logic-visible",["views/admin/field-manager/fields/dynamic-logic-conditions"],function(t){return t.extend({setupEntityType:function(){this.options.scope=this.scope=this.model.get("entityType"),this.listenTo(this.model,"change:entityType",()=>{this.options.scope=this.scope=this.model.get("entityType"),this.scope&&this.createStringView()})},setup:function(){this.addActionHandler("editConditions",()=>this.edit()),this.setupEntityType(),this.conditionGroup=Espo.Utils.cloneDeep((this.model.get(this.name)||{}).conditionGroup||[]),this.createStringView()}})}),define("modules/advanced/views/report-panel/fields/column",["exports","views/fields/enum","modules/advanced/views/report/fields/columns","di","modules/advanced/helpers/report/column-helper"],function(t,e,i,s,a){"use strict";let n,o;function r(t){return t&&t.__esModule?t:{default:t}}function l(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function d(t,e,i){"symbol"==typeof e&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch(t){}return t}function c(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(null!==t?typeof t:"null"));return t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=r(e),i=r(i),a=r(a);class h extends e.default{static#t=[n,o]=function(t,e,i,s,a,n){var o,r,h,u,p,f,m,g=Symbol.metadata||Symbol.for("Symbol.metadata"),y=Object.defineProperty,w=Object.create,v=[w(null),w(null)],b=e.length;function T(e,i,s){return function(a,n){i&&(n=a,a=t);for(var o=0;o<e.length;o++)n=e[o].apply(a,s?[n]:[]);return s?n:a}}function D(t,e,i,s){if("function"!=typeof t&&(s||void 0!==t))throw new TypeError(e+" must "+(i||"be")+" a function"+(s?"":" or undefined"));return t}function k(t,e,i,s,a,n,l,c,h,u,p){function f(t){if(!p(t))throw new TypeError("Attempted to access private element on non-instance")}var m=[].concat(e[0]),g=e[3],w=!l,b=1===a,k=3===a,E=4===a,C=2===a;function x(e,i,s){return function(a,n){return i&&(n=a,a=t),s&&s(a),O[e].call(a,n)}}if(!w){var O={},L=[],M=k?"get":E||b?"set":"value";if(h?(u||b?O={get:d(function(){return g(this)},s,"get"),set:function(t){e[4](this,t)}}:O[M]=g,u||d(O[M],s,C?"":M)):u||(O=Object.getOwnPropertyDescriptor(t,s)),!u&&!h){if((r=v[+c][s])&&7!=(r^a))throw Error("Decorating two elements with the same name ("+O[M].name+") is not supported yet");v[+c][s]=a<3?1:a}}for(var F=t,S=m.length-1;S>=0;S-=i?2:1){var V=D(m[S],"A decorator","be",!0),R=i?m[S-1]:void 0,$={},I={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:o,addInitializer:function(t,e){if(t.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(e,"An initializer","be",!0),n.push(e)}.bind(null,$)};if(w)r=V.call(R,F,I),$.v=1,D(r,"class decorators","return")&&(F=r);else if(I.static=c,I.private=h,r=I.access={has:h?p.bind():function(t){return s in t}},E||(r.get=h?C?function(t){return f(t),O.value}:x("get",0,f):function(t){return t[s]}),C||k||(r.set=h?x("set",0,f):function(t,e){t[s]=e}),F=V.call(R,b?{get:O.get,set:O.set}:O[M],I),$.v=1,b){if("object"==typeof F&&F)(r=D(F.get,"accessor.get"))&&(O.get=r),(r=D(F.set,"accessor.set"))&&(O.set=r),(r=D(F.init,"accessor.init"))&&L.unshift(r);else if(void 0!==F)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(F,(u?"field":"method")+" decorators","return")&&(u?L.unshift(F):O[M]=F)}return a<2&&l.push(T(L,c,1),T(n,c,0)),u||w||(h?b?l.splice(-1,0,x("get",c),x("set",c)):l.push(C?O[M]:D.call.bind(O[M])):y(t,s,O)),F}function E(t){return y(t,g,{configurable:!0,enumerable:!0,value:o})}return void 0!==n&&(o=n[g]),o=w(null==o?null:o),p=[],f=function(t){t&&p.push(T(t))},(m=function(e,s){for(var n=0;n<i.length;n++){var o=i[n],r=o[1],d=7&r;if((8&r)==e&&!d==s){var f=o[2],m=!!o[3],g=16&r;k(e?t:t.prototype,o,g,m?"#"+f:l(f),d,d<2?[]:e?u=u||[]:h=h||[],p,!!e,m,s,e&&m?function(e){return c(e)===t}:a)}}})(8,0),m(0,0),m(8,1),m(0,1),f(h),f(u),r=p,b||E(t),{e:r,get c(){var i=[];return b&&[E(t=k(t,[e],s,t.name,5,i)),T(i,1)]}}}(this,[],[[(0,s.inject)(a.default),0,"columnHelper"]],0,void 0,e.default).e;constructor(){super(...arguments),o(this)}columnHelper=n(this);setup(){super.setup(),this.listenTo(this.model,"update-columns",t=>{this.params.options=t,i.default.prototype.setupTranslatedOptions.call(this,this.model.get("reportEntityType")),this.translatedOptions[""]=this.translate("All"),this.setupColumnLabelTranslation(),this.reRender()}),this.listenTo(this.model,"change:columnList",()=>{this.model.trigger("update-columns",this.model.get("columnList")||[])})}setupOptions(){this.params.options=Espo.Utils.clone(this.model.get("columnList")),this.model.isNew||"Grid"!==this.model.get("reportType")||this.params.options||this.listenToOnce(this.model,"sync",()=>{this.model.get("columnList")&&(this.params.options=Espo.Utils.clone(this.model.get("columnList")),i.default.prototype.setupTranslatedOptions.call(this,this.model.get("reportEntityType")),this.translatedOptions[""]=this.translate("All"),this.setupColumnLabelTranslation(),this.reRender())}),!this.params.options&&this.model.get("column")&&(this.params.options=[this.model.get("column")]),this.params.options||(this.params.options=[]),i.default.prototype.setupTranslatedOptions.call(this,this.model.get("reportEntityType")),this.translatedOptions[""]=this.translate("All"),this.setupColumnLabelTranslation()}setupColumnLabelTranslation(){const t=this.model.attributes.columnsData??{};this.params.options.forEach(e=>{const i=t[e]??{};if(i.label)return void(this.translatedOptions[e]=i.label);if(!this.model.attributes.internalClassName)return;const s=this.columnHelper.translateInternalReportColumn(this.model.attributes.internalClassName,e);s&&(this.translatedOptions[e]=s)})}}t.default=h}),define("advanced:views/report-filter/list",["views/list"],function(t){return t.extend({actionRebuildFilters:function(){Espo.Ui.notify(" ... "),Espo.Ajax.postRequest("ReportFilter/action/rebuild",{}).then(()=>{Espo.Ui.success(this.translate("Done"))})}})}),define("advanced:views/report-filter/record/list","views/record/list",function(t){return t.extend({massActionList:[]})}),define("advanced:views/report-filter/record/edit",["views/record/edit"],function(t){return t.extend({sideDisabled:!0})}),define("advanced:views/report-filter/record/edit-small",["views/record/edit-small"],function(t){return t.extend({sideDisabled:!0})}),define("advanced:views/report-filter/fields/report",["views/fields/link"],function(t){return t.extend({selectPrimaryFilterName:"list",createDisabled:!0,getSelectFilters:function(){var t=this.model.get("entityType");if(t)return{entityType:{type:"equals",value:[t]}}}})}),define("advanced:views/report/result",["views/main","advanced:report-helper"],function(t,e){return t.extend({template:"advanced:report/result",name:"result",shortcutKeys:{"Control+Enter":function(t){this.getReportView().run(),t.preventDefault(),t.stopPropagation()}},setup:function(){const t=new e(this.getMetadata(),this.getLanguage(),this.getDateTime(),this.getConfig(),this.getPreferences()),i=t.getReportView(this.model);this.setupHeader(),this.createView("report",i,{selector:".report-container",model:this.model,reportHelper:t,showChartFirst:!0,isLargeMode:!0,isFullWidthMode:!0})},getReportView:function(){return this.getView("report")},setupHeader:function(){this.createView("header","views/header",{model:this.model,fullSelector:"#main > .header",scope:this.scope})},getHeader:function(){let t=this.getHelper().escapeString(this.model.get("name"));""===t&&(t=this.model.id);const e=this.options.rootUrl||this.options.params.rootUrl||`#${this.scope}`,i=this.getHeaderIconHtml();return this.buildHeaderHtml([`${i}<a\n                    href="${e}"\n                    class="action"\n                    data-action="navigateToRoot"\n                >${this.getLanguage().translate(this.scope,"scopeNamesPlural")}</a>`,`<a\n                    href="#${this.scope}/view/${this.model.id}"\n                    class="action"\n                    data-action="backToView"\n                >${t}</a>`])},actionBackToView:function(){const t={id:this.model.id,model:this.model};t.rootUrl=this.options.rootUrl||this.options.params.rootUrl,this.getRouter().navigate(`#${this.scope}/view/${this.model.id}`,{trigger:!1}),this.getRouter().dispatch(this.scope,"view",t)}})}),define("advanced:views/report/list",["views/list-with-categories"],function(t){return t.extend({createButton:!1,quickCreate:!1,currentCategoryId:null,currentCategoryName:"",categoryScope:"ReportCategory",categoryField:"category",categoryFilterType:"inCategory",getCreateAttributes:function(){return{categoryId:this.currentCategoryId,categoryName:this.currentCategoryName}},setup:function(){t.prototype.setup.call(this),this.addMenuItem("buttons",{action:"create",html:'<span class="fas fa-plus fa-sm"></span> '+this.translate("Create "+this.scope,"labels",this.scope),style:"default",acl:"create",aclScope:"Report"},!0)},actionCreate:function(){this.createView("createModal","advanced:views/report/modals/create",{},function(t){t.render(),this.listenToOnce(t,"create",function(e){t.close(),this.getRouter().dispatch("Report","create",{entityType:e.entityType,type:e.type,categoryId:this.currentCategoryId,categoryName:this.currentCategoryName,returnUrl:this.lastUrl||"#"+this.scope,returnDispatchParams:{controller:this.scope,action:null,options:{isReturn:!0}}}),this.getRouter().navigate("#Report/create/entityType="+e.entityType+"&type="+e.type,{trigger:!1})},this)})}})}),define("advanced:views/report/detail",["views/detail"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this);const e=this.getConfig().get("version")||"",i=e.split(".");if("dev"===e||i.length>2&&100*parseInt(i[0])+parseInt(i[1])>=506||"@@version"===e){let t;t=["Grid","JointGrid"].includes(this.model.attributes.type)?'<span class="fas fa-chart-simple fa-sm"></span>':'<span class="fas fa-align-justify fa-sm"></span>',this.addMenuItem("buttons",{action:"show",link:`#Report/show/${this.model.id}`,iconHtml:t,text:this.translate("Results View","labels","Report")})}},actionShow:function(){const t={id:this.model.id,model:this.model},e=this.options.rootUrl||this.options.params.rootUrl;e&&(t.rootUrl=e),this.getRouter().navigate(`#Report/show/${this.model.id}`,{trigger:!1}),this.getRouter().dispatch("Report","show",t)}})}),define("modules/advanced/views/report/reports/list",["exports","modules/advanced/views/report/reports/base"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{setup(){this.initReport()}getListLayout(t){const e=this.model.get("entityType"),i=[],s=Espo.Utils.cloneDeep(this.model.get("columnsData")||{});return(this.model.get("columns")||[]).forEach(a=>{const n=s[a]||{};if(n.name=a,t||!n.exportOnly){if(~a.indexOf(".")){const t=a.split(".");n.name=a.replace(".","_"),n.notSortable=!0;const i=t[0],s=t[1],o=this.getMetadata().get(`entityDefs.${e}.links.${i}.entity`);n.customLabel=this.translate(i,"links",e)+" . "+this.translate(s,"fields",o);const r=this.getMetadata().get(`entityDefs.${o}.fields.${s}.type`);"enum"===r?(n.view="views/fields/foreign-enum",n.options={params:{link:i,field:s}}):"image"===r?(n.view="views/fields/image",n.options={foreignScope:o}):"file"===r?(n.view="views/fields/file",n.options={foreignScope:o}):"date"===r?(n.view="views/fields/foreign-date",n.notSortable=!1,n.options={params:{link:i,field:s}}):"datetime"===r?(n.view="views/fields/foreign-datetime",n.options={params:{link:i,field:s}},n.notSortable=!1):"link"===r?n.view="advanced:views/fields/foreign-link":"email"===r?(n.view="views/fields/email",n.notSortable=!1):"phone"===r?(n.view="views/fields/phone",n.notSortable=!1):"array"===r?(n.view="views/fields/foreign-array",n.options={params:{link:i,field:s}}):"multiEnum"===r?(n.view="views/fields/foreign-multi-enum",n.options={params:{link:i,field:s}}):"checklist"===r?(n.view="views/fields/foreign-checklist",n.options={params:{link:i,field:s}}):"urlMultiple"===r?(n.view="views/fields/foreign-url-multiple",n.options={params:{link:i,field:s}}):"varchar"===r?(n.view="views/fields/varchar",n.notSortable=!1):"bool"===r?(n.view="views/fields/bool",n.notSortable=!1):"currencyConverted"===r&&(n.view="views/fields/currency-converted",n.notSortable=!1)}else{const t=this.getMetadata().get(["entityDefs",e,"fields",a,"type"]);("linkMultiple"===t||"attachmentMultiple"===t)&&(n.notSortable=!0)}i.push(n)}}),i}export(){const t=this.getRuntimeFilters(),e={id:this.model.id},i=[];this.getListLayout(!0).forEach(t=>{i.push(t.name)});const s={fieldList:i,scope:this.model.get("entityType")};this.createView("dialogExport","views/export/modals/export",s,i=>{i.render(),this.listenToOnce(i,"proceed",i=>{i.exportAllFields||(e.attributeList=i.attributeList,e.fieldList=i.fieldList),e.where=t,e.format=i.format,e.params=i.params,Espo.Ui.notify(" ... "),Espo.Ajax.postRequest("Report/action/exportList",e,{timeout:0}).then(t=>{Espo.Ui.notify(!1),"id"in t&&(window.location=this.getBasePath()+"?entryPoint=download&id="+t.id)})})})}prepareBeforeRun(){this.resultContainerElement=this.element.querySelector(".report-results-container");const t=!!this.resultContainerElement.querySelector(".report-list .no-data");this.resultContainerElement.innerHTML="",this.listContainerElement=document.createElement("div"),this.listContainerElement.classList.add("report-list"),t||(this.element.classList.add("no-bottom-margin"),this.resultContainerElement.classList.add("no-bottom-margin"),this.listContainerElement.classList.add("no-bottom-margin")),this.resultContainerElement.append(this.listContainerElement)}async run(){Espo.Ui.notify(" ... "),this.prepareBeforeRun();const t=await this.getCollectionFactory().create(this.model.get("entityType"));let e=`Report/action/runList?id=${this.model.id}`;if(this.isPreview){e="Report/runListPreview?data="+encodeURIComponent(JSON.stringify(this.model.attributes))}t.url=e,t.where=this.getRuntimeFilters();const i=this.model.get("orderByList");if(i){const e=i.split(":");t.setOrder&&t.setOrder(e[1],"ASC"===e[0]?"asc":"desc",!0)}return t.maxSize=this.getConfig().get("recordsPerPage")||20,this.listenToOnce(t,"sync",()=>{this.storeRuntimeFilters(),this.createView("list","advanced:views/record/list-for-report",{selector:".report-list",collection:t,listLayout:this.getListLayout(),displayTotalCount:!0,reportId:this.model.id,runtimeWhere:t.where,pagination:this.options.isLargeMode,isPreview:this.isPreview,layoutName:"customReport"+this.model.id,settingsEnabled:this.options.isFullWidthMode,forceSettings:this.options.isFullWidthMode},async t=>{Espo.Ui.notify(!1),this.listenTo(t,"after:render",()=>{t.$el.find("> .list").addClass("no-side-margin").addClass("no-bottom-margin").addClass("bottom-border-radius"),t.$el.find(".list-buttons-container").addClass("margin-bottom")}),this.element.classList.remove("no-bottom-margin"),this.resultContainerElement.classList.remove("no-bottom-margin"),this.listContainerElement.classList.remove("no-bottom-margin"),await t.render();!!this.resultContainerElement.querySelector(".report-list .no-data")||this.listContainerElement.classList.add("no-bottom-margin")})}),t.fetch()}}t.default=s}),define("modules/advanced/views/report/reports/grid2",["exports","modules/advanced/views/report/reports/base","modules/advanced/views/report/reports/tables/grid2","modules/advanced/views/report/reports/tables/grid2-normalized"],function(t,e,i,s){"use strict";function a(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=a(e),i=a(i),s=a(s);class n extends e.default{setup(){this.initReport()}export(){const t=this.getRuntimeFilters(),e={},i=this.model.get("entityType"),s=(this.model.get("columns")||[]).filter(t=>this.options.reportHelper.isColumnSummary(t));s.forEach(t=>{e[t]=this.options.reportHelper.translateGroupName(t,i)});const a={scope:i,reportType:"Grid",columnList:s,columnsTranslation:e};let n;const o={id:this.model.id,where:t};this.createView("dialogExport","advanced:views/report/modals/export-grid",a,t=>{t.render(),this.listenToOnce(t,"proceed",t=>{o.column=t.column,"csv"===t.format?(n="Report/action/exportGridCsv",o.column=t.column):"xlsx"===t.format&&(n="Report/action/exportGridXlsx"),Espo.Ui.notify(" ... "),Espo.Ajax.postRequest(n,o,{timeout:0}).then(t=>{Espo.Ui.notify(!1),"id"in t&&(window.location=this.getBasePath()+"?entryPoint=download&id="+t.id)})})})}async run(){Espo.Ui.notify(" ... ");const t=this.$el.find(".report-results-container");t.empty();const e=this.getRuntimeFilters();let a;const n=this.isPreview?this.model.attributes:null;a=this.isPreview?await Espo.Ajax.postRequest("Report/runGridPreview",{where:e,data:n},{timeout:0}):await Espo.Ajax.getRequest("Report/action/run",{id:this.model.id,where:e,data:n},{timeout:0}),Espo.Ui.notify(!1),this.result=a,this.storeRuntimeFilters(),this.processInformation();const o=this.options.isLargeMode?"h4":"h5",r=this.options.isLargeMode?60:50,l=a.summaryColumnList||a.columnList,d=a.chartType??this.model.attributes.chartType,c="Normalized"===this.result.tableMode;if(c){const e=document.createElement("div");e.className="report-table clearfix section",d&&e.classList.add("margin-bottom"),t.append(e)}if(l.forEach((e,i)=>{if(c&&!d)return;const s=$("<div>").addClass(`column-${i}`).addClass("section").addClass("sections-container"),n=$("<"+o+' style="margin-bottom: 25px">'+this.options.reportHelper.formatColumn(e,a)+"</"+o+">");this.options.isLargeMode||n.addClass("text-soft"),r&&i&&n.css("marginTop",r);const l=$("<div>").addClass("report-table clearfix").addClass(`report-table-${i}`).addClass("section");d&&l.addClass("margin-bottom");const h=$("<div>").addClass("report-chart").addClass(`report-chart-${i}`).addClass("section");s.append(n),c||this.options.showChartFirst||s.append(l),d&&s.append(h),!c&&this.options.showChartFirst&&s.append(l),t.append(s)}),c){const t=new s.default({result:a,reportHelper:this.options.reportHelper,hasChart:!!d,isLargeMode:this.options.isLargeMode}),e=".report-results-container .report-table";this.assignView("reportTable",t,e).then(()=>{t.render()})}l.forEach((t,e)=>{if(!c){const s=new i.default({column:t,result:a,reportHelper:this.options.reportHelper,hasChart:!!d,isLargeMode:this.options.isLargeMode}),n=`.report-results-container .column-${e} .report-table`;this.assignView(`reportTable${e}`,s,n).then(()=>{s.render()})}if(!d)return;const s="advanced:views/report/reports/charts/grid2"+Espo.Utils.camelCaseToHyphen(d);this.createView(`reportChart${e}`,s,{selector:`.report-results-container .column-${e} .report-chart`,column:t,result:a,reportHelper:this.options.reportHelper,colors:a.chartColors??{},color:a.chartColor??null}).then(t=>{t.render(),this.listenTo(t,"click-group",(t,e,i)=>{this.showSubReport(t,e,i)})})})}processInformation(){this.result.emptyStringGroupExcluded?this.$information.removeClass("hidden").text(this.translate("emptyStringGroupExcluded","messages","Report")):this.$information.addClass("hidden").text("")}}t.default=n}),define("advanced:views/report/reports/grid0",["advanced:views/report/reports/grid1"],t=>class extends t{}),define("modules/advanced/views/report/reports/tables/grid1",["exports","view","modules/advanced/views/report/reports/tables/grid2"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{templateContent='\n        <div class="table-container no-side-margin" data-report-type="grid-1"></div>\n    ';columnWidthPx=130;STUB_KEY="__STUB__";result;setup(){this.column=this.options.column,this.result=this.options.result,this.reportHelper=this.options.reportHelper}events={'click [data-action="showSubReport"]':function(t){const e=$(t.currentTarget).attr("data-group-value");this.trigger("click-group",e)}};formatCellValue(t,e,s){return i.default.prototype.formatCellValue.call(this,t,e,s)}calculateColumnWidth(){const t=this.result.columnList.length+1;let e;return e=this.options.isLargeMode?2===t||3===t?22:4===t?20:100/t:2===t?35:3===t?30:100/t,e}afterRender(){const t=this.result;let e=this.result.groupByList[0],i=!1;0===this.result.groupByList.length&&(i=!0,e=this.STUB_KEY);const s=this.result.columnList.length+1,a=this.calculateColumnWidth(),n=$('<table style="table-layout: fixed;">').addClass("table table-no-overflow").addClass("table-bordered"),o=$("<tbody>");n.append(o);const r=this.columnWidthPx;if(s>4){const t=r*s;n.css("min-width",t+"px")}this.options.hasChart&&!this.options.isLargeMode||n.addClass("no-margin");let l=$('<tr class="accented">');const d=(this.result.subListColumnList||[]).length;if(!i){const t=$("<th>");if(!~e.indexOf(":")&&(this.result.isJoint||d)){const s=this.reportHelper.getGroupFieldData(e,this.result);let a=null;if("link"===s.fieldType){const t=this.getMetadata().get(["entityDefs",s.entityType,"links",s.field,"entity"]);t&&(a=this.translate(t,"scopeNames"))}a&&(a='<strong class="text-soft">'+a+"</strong>",t.html(a),this.options.isLargeMode&&i&&this.result.columnList.length<3&&t.css("font-size","125%"))}l.append(t)}if(this.result.columnList.forEach(t=>{let e=this.reportHelper.formatColumn(t,this.result);e='<strong class="text-soft">'+e+"</strong>";const s=$(`<th style="width: ${a}%">`).html(e+"&nbsp;");s.css("font-weight","600"),this.options.isLargeMode&&i&&!d&&this.result.columnList.length<3&&s.css("font-size","125%"),l.append(s)}),o.append(l),this.result.grouping[0].forEach(s=>{let a,n=$("<tr>");if(d&&n.addClass("accented"),!i){a=this.reportHelper.formatGroup(e,s,this.result);let t=a;if(!this.result.noSubReport){t||(t+="nbsp");const e=document.createElement("a");e.role="button",e.tabIndex=0,e.dataset.action="showSubReport",e.className="selectable",e.dataset.groupValue=s,e.innerHTML=t,t=e.outerHTML}const i=$("<td>").html(t);if(d&&i.css("font-weight","600"),n.append(i),d){this.result.columnList.forEach(t=>{const e=$("<td>");if(!this.options.reportHelper.isColumnNumeric(t,this.result)){const i=this.result.reportData[s]||{},a=this.formatCellValue(i[t]||"",t);e.text(a),e.attr("title",a)}n.append(e)}),o.append(n),n=$("<tr>");const t=$("<td>");t.addClass("text-soft"),t.html(this.translate("Group Total","labels","Report")),n.append(t)}}if(d){this.result.subListData[s].forEach(t=>{const e=$("<tr>");i||e.append("<td>"),this.result.columnList.forEach(i=>{const s=$("<td>");if(!~this.result.subListColumnList.indexOf(i))return void e.append("<td>");this.options.reportHelper.isColumnNumeric(i,this.result)&&(s.attr("align","right"),s.addClass("numeric-text"));const a=t[i],n=this.formatCellValue(a,i);s.html(n),s.attr("title",n),""===n&&s.html("&nbsp;"),e.append(s)}),o.append(e)})}let r=!1;this.result.columnList.forEach(e=>{let o=null,l=!1;s in t.reportData&&(o=t.reportData[s][e]);const c=$("<td>");if(this.options.reportHelper.isColumnNumeric(e,this.result)&&(c.attr("align","right"),c.addClass("numeric-text")),i)c.css("font-weight","600"),c.addClass("text-soft"),this.options.isLargeMode?c.css("font-size","175%"):d||c.css("font-size","125%");else{const t=this.reportHelper.formatColumn(e,this.result),i=this.unescapeString(a)+"\n"+this.unescapeString(t);c.attr("title",i),d&&this.options.reportHelper.isColumnNumeric(e,this.result)&&(c.css("font-weight","600"),c.addClass("text-soft"),r=!0),d&&!this.options.reportHelper.isColumnNumeric(e,this.result)&&(l=!0),d&&!this.options.reportHelper.isColumnAggregated(e,this.result)&&(l=!0)}const h=l?"":this.formatCellValue(o,e);c.html(h),n.append(c)}),(0!==this.result.summaryColumnList.length||r)&&o.append(n)}),!i){l=$('<tr class="accented">');const e=$("<span>"+this.translate("Total","labels","Report")+"</span>"),i=$("<td>").html(e).addClass("text-soft").css("font-weight","600");l.append(i),this.options.isLargeMode&&e.css("vertical-align","middle"),this.result.columnList.forEach(e=>{let i,s=t.sums[e];const a=this.reportHelper.formatColumn(e,this.result);this.options.reportHelper.isColumnNumeric(e,this.result)&&this.options.reportHelper.isColumnAggregated(e,this.result)?(s=s||0,i=this.formatCellValue(s,e,!0)):i="";const n=$('<td style="text-align: right" class="numeric-text">').css("font-weight","600").html(i);this.options.isLargeMode&&n.css("font-size","125%");const o=this.unescapeString(a);n.attr("title",o),l.append(n)}),o.append(l)}this.$el.find(".table-container").append(n),s>4&&this.$el.find(".table-container").css("overflow-y","auto")}unescapeString(t){return $("<div>").html(t).text()}}t.default=a}),define("modules/advanced/views/report/reports/charts/grid2radar",["exports","modules/advanced/views/report/reports/charts/base"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{prepareData(){}draw(){}}t.default=s}),define("modules/advanced/views/report/reports/charts/grid2pie",["exports","modules/advanced/views/report/reports/charts/base"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{prepareData(){}draw(){}}t.default=s}),define("modules/advanced/views/report/reports/charts/grid2line",["exports","modules/advanced/views/report/reports/charts/grid2bar-vertical"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{columnWidth=80;pointXHalfWidth=0;isLine=!0;chartType="line";showPointsThreshold=0;getTickNumber(){const t=this.$container.width();return Math.floor(t/this.columnWidth*this.getFontSizeFactor())}setup(){super.setup(),this.xMin=-.1}prepareData(){super.prepareData(),null==this.xMax&&(this.xMax=this.getHorizontalPointCount()-1+.1)}draw(){if(0===this.$container.height())return void this.$container.empty();if(this.isNoData())return void this.showNoData();const t=this.$container.width();let e=!1;const i=this.getTickNumber(),s=this.getDisplayedPointCount();let a,n=s;t/s<this.columnWidth?n=i:s>i&&(e=!0,a=Math.floor(s/i));const o=this.firstList.length<=this.showPointsThreshold;this.$graph=this.flotr.draw(this.$container.get(0),this.chartData,{shadowSize:!1,colors:this.colorList,lines:{show:!0,lineWidth:3},points:{show:o},grid:{horizontalLines:!0,verticalLines:!0,outline:"s",color:this.gridColor,tickColor:this.tickColor},yaxis:{max:this.max+.1*this.max,min:this.min+.1*this.min,showLabels:!0,autoscale:!0,autoscaleMargin:1,color:this.textColor,tickFormatter:t=>{if(0==t&&0===this.min)return"";if(t>this.max+.09*this.max)return"";if(t%1==0){return'<span class="numeric-text">'+this.reportHelper.formatNumber(Math.floor(t),{isCurrency:this.isCurrency,useSiMultiplier:!0,noDecimalPart:!0,no3CharCurrencyFormat:!0,currency:this.result.currency})+"</span>"}return""}},xaxis:{min:this.xMin||0,max:this.xMax||null,color:this.textColor,noTicks:n,tickFormatter:t=>{if(t%1==0){const i=parseInt(t);if(e&&i%a!==0)return"";if(i in this.firstList)return this.firstList.length>14&&i===this.firstList.length-1||this.firstList.length>200&&i>this.firstList.length-2?"":this.formatGroup(0,this.firstList[i])}return""}},mouse:{track:!0,relative:!0,lineColor:this.hoverColor,autoPositionHorizontal:!0,autoPositionVertical:!0,cursorPointer:!this.result.noSubReport,trackFormatter:t=>{const e=Math.floor(t.x),i=this.options.column;return this.formatGroup(0,this.firstList[e])+'<br><span class="numeric-text">'+this.formatCellValue(t.y,i)+"</span>"}},legend:{show:!0,noColumns:this.getLegendColumnNumber(),container:this.$el.find(".legend-container"),labelBoxMargin:0,labelFormatter:this.labelFormatter.bind(this),labelBoxBorderColor:"transparent",backgroundOpacity:0}}),this.adjustLegend(),this.dragStart||Flotr.EventAdapter.observe(this.$container.get(0),"flotr:click",t=>{t.hit&&"index"in t.hit&&(this.result.noSubReport||this.trigger("click-group",this.firstList[t.hit.index],null,this.secondList[t.hit.seriesIndex]))})}}t.default=s}),define("modules/advanced/views/report/reports/charts/grid2bar-grouped-vertical",["exports","modules/advanced/views/report/reports/charts/grid2bar-vertical"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{isGrouped=!0;columnWidth=60;pointXHalfWidth=.5}t.default=s}),define("modules/advanced/views/report/reports/charts/grid2bar-grouped-horizontal",["exports","modules/advanced/views/report/reports/charts/grid2bar-horizontal"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{isGrouped=!0}t.default=s}),define("modules/advanced/views/report/reports/charts/grid1radar",["exports","modules/advanced/views/report/reports/charts/base"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{noLegend=!0;zooming=!1;defaultHeight=450;chartType="radar";prepareData(){const t=this.result,e=this.grList=t.grouping[0];this.options.color&&(this.colorList=Espo.Utils.clone(this.colorList),this.colorList[0]=this.options.color);const i=this.columnList||[this.column];this.columnList&&this.columnList.length>1&&(this.noLegend=!1);let s=0,a=0;const n=[];this.ticks=[],e.forEach((t,e)=>{const i=this.formatGroup(0,t);this.ticks.push([e,i])}),i.forEach(t=>{if(this.secondColumnList&&~this.secondColumnList.indexOf(t))return;const i={data:[],label:this.reportHelper.formatColumn(t,this.result),column:t};e.forEach((e,n)=>{const o=(this.result.reportData[e]||{})[t]||0;o>s&&(s=o),o<a&&(a=o),i.data.push([n,o])}),t in this.colors&&(i.color=this.colors[t]),n.push(i)}),this.max=s,this.min=a,this.chartData=n}isNoData(){if(!this.chartData.length||this.grList.length<3)return!0;let t=!0;return this.chartData.forEach(e=>{e&&e.data&&e.data.length&&(t=!1)}),!!t}draw(){if(0===this.$container.height())return void this.$container.empty();if(this.isNoData())return void this.showNoData();const t=this.getFontSizeFactor();this.$graph=this.flotr.draw(this.$container.get(0),this.chartData,{shadowSize:!1,colors:this.colorList,htmlText:!0,style:{fontSize:10*t},radar:{show:!0,fill:!0,shadowSize:0,lineWidth:2*t,fillOpacity:.2,radiusRatio:.9},grid:{circular:!0,color:this.gridColor,tickColor:this.gridColor},xaxis:{ticks:this.ticks,color:this.textColor,fontSize:9*t},yaxis:{min:0,max:this.max,minorTickFreq:2,color:this.textColor,fontSize:9*t,tickFormatter:t=>{if("0"===t||0==t)return"";return parseInt(t)>this.max-.09*this.max?"":t%1==0?this.reportHelper.formatNumber(Math.floor(t),{isCurrency:this.isCurrency,useSiMultiplier:!0,noDecimalPart:!0,no3CharCurrencyFormat:!0,currency:this.result.currency}):""}},legend:{show:!this.noLegend,noColumns:this.getLegendColumnNumber(),container:this.$el.find(".legend-container"),labelBoxMargin:0,labelFormatter:this.labelFormatter.bind(this),labelBoxBorderColor:"transparent",backgroundOpacity:0}}),this.noLegend||this.adjustLegend()}formatGroup(t,e){const i=this.result.groupByList[t];return this.reportHelper.formatGroup(i,e,this.result)}}t.default=s}),define("modules/advanced/views/report/reports/charts/grid1pie",["exports","modules/advanced/views/report/reports/charts/grid1bar-vertical"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{noLegend=!1;zooming=!1;isSquare=!0;chartType="pie";prepareData(){const t=this.result,e=this.grList=t.grouping[0];e.length<=5&&(this.colorList=this.colorListAlt);const i=[];this.values=[],e.forEach(t=>{const e=(this.result.reportData[t]||{})[this.column]||0;this.values.push(e);const s={label:this.formatGroup(0,t),groupValue:t,data:[[0,e]],value:e};t in this.colors&&(s.color=this.colors[t]),i.push(s)}),this.chartData=i}isNoData(){if(!this.chartData.length)return!0;let t=!0;return this.chartData.forEach(e=>{e&&e.value&&(t=!1)}),t}draw(){0!==this.$container.height()?this.isNoData()?this.showNoData():(this.$graph=this.flotr.draw(this.$container.get(0),this.chartData,{shadowSize:!1,colors:this.colorList,pie:{show:!0,fillOpacity:1,explode:0,lineWidth:1,sizeRatio:.75,labelFormatter:(t,e)=>{const i=(100*e/t).toFixed(0);if(i<3)return"";const s=i.toString()+"%";return`<span class="small numeric-text" style="${`color:${this.textColor};`}">${s}</span>`}},grid:{horizontalLines:!1,verticalLines:!1,outline:"",color:this.gridColor},yaxis:{showLabels:!1},xaxis:{showLabels:!1},mouse:{track:!0,relative:!0,lineColor:this.hoverColor,cursorPointer:!this.result.noSubReport,trackFormatter:t=>{const e=this.options.column,i=this.formatCellValue(t.series.value,e),s=(100*(t.fraction||0)).toFixed(2).toString();return`${t.series.label||this.translate("-Empty-","labels","Report")}<br><span class="numeric-text">${i} / ${s}%</span>`}},legend:{show:!0,noColumns:this.getLegendColumnNumber(),container:this.$el.find(".legend-container"),labelBoxMargin:0,labelFormatter:this.labelFormatter.bind(this),labelBoxBorderColor:"transparent",backgroundOpacity:0}}),Flotr.EventAdapter.observe(this.$container.get(0),"flotr:click",t=>{t.hit&&"index"in t.hit&&(this.result.noSubReport||this.trigger("click-group",t.hit.series.groupValue))}),this.adjustLegend()):this.$container.empty()}}t.default=s}),define("modules/advanced/views/report/reports/charts/grid1line",["exports","modules/advanced/views/report/reports/charts/grid1bar-vertical"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{noLegend=!0;columnWidth=80;isLine=!0;zooming=!0;pointXHalfWidth=0;chartType="line";showPointsThreshold=0;getTickNumber(){const t=this.$container.width();return Math.floor(t/this.columnWidth*this.getFontSizeFactor())}setup(){super.setup(),this.xMin=-.1}prepareData(){super.prepareData(),null==this.xMax&&(this.xMax=this.getHorizontalPointCount()-1+.1)}draw(){if(0===this.$container.height())return void this.$container.empty();if(this.isNoData())return void this.showNoData();this.columnList&&this.columnList.length>1&&(this.noLegend=!1);const t=this.$container.width();let e=!1;const i=this.getTickNumber(),s=this.getDisplayedPointCount();let a,n=s;t/s<this.columnWidth?n=i:s>i&&(e=!0,a=Math.floor(s/i));const o=this.grList.length<=this.showPointsThreshold;this.$graph=this.flotr.draw(this.$container.get(0),this.chartData,{shadowSize:!1,colors:this.colorList,lines:{show:!0,lineWidth:3,fill:!this.columnList||1===this.columnList.length,fillOpacity:.25},points:{show:o},grid:{horizontalLines:!0,verticalLines:!0,outline:"s",color:this.gridColor,tickColor:this.tickColor},yaxis:{min:this.min+.08*this.min,showLabels:!0,autoscale:!0,autoscaleMargin:.1,color:this.textColor,max:this.max+.08*this.max,tickFormatter:t=>{if(t>this.max+.09*this.max)return"";if((0!=t||0==t&&this.min<0)&&t%1==0){return'<span class="numeric-text">'+this.reportHelper.formatNumber(Math.floor(t),{isCurrency:this.isCurrency,useSiMultiplier:!0,noDecimalPart:!0,no3CharCurrencyFormat:!0,currency:this.result.currency})+"</span>"}return""}},y2axis:{min:this.min2+.08*this.min2,showLabels:!0,color:this.textColor,max:this.max2+.08*this.max2,tickFormatter:t=>{if(0==t&&0===this.min2)return"";if(t>this.max2+.07*this.max2)return"";if(t%1==0){return'<span class="numeric-text">'+this.reportHelper.formatNumber(Math.floor(t))+"</span>"}return""}},xaxis:{min:this.xMin||0,max:this.xMax||null,color:this.textColor,noTicks:n,tickFormatter:t=>{if(t%1==0){const i=parseInt(t);if(e&&i%a!==0)return"";if(i in this.grList)return this.formatGroup(0,this.grList[i])}return""}},mouse:{track:!0,relative:!0,lineColor:this.hoverColor,autoPositionHorizontal:!0,autoPositionVertical:!0,cursorPointer:!this.result.noSubReport,trackFormatter:t=>{const e=Math.floor(t.x),i=t.series.column;let s=this.formatGroup(0,this.grList[e]);return this.columnList&&(s+="<br>"+t.series.label),s+='<br><span class="numeric-text">'+this.formatCellValue(t.y,i)+"</span>",s}},legend:{show:!this.noLegend,noColumns:this.getLegendColumnNumber(),container:this.$el.find(".legend-container"),labelBoxMargin:0,labelFormatter:this.labelFormatter.bind(this),labelBoxBorderColor:"transparent",backgroundOpacity:0}}),this.noLegend||this.adjustLegend(),this.dragStart||Flotr.EventAdapter.observe(this.$container.get(0),"flotr:click",t=>{if(!t.hit)return;if(!("index"in t.hit))return;let e=null;this.result.isJoint&&(e=this.columnList?this.columnList[t.hit.seriesIndex]:this.column),this.result.noSubReport||this.trigger("click-group",this.grList[t.hit.index],void 0,void 0,e)})}}t.default=s}),define("modules/advanced/views/report/reports/charts/grid0bar-vertical",["exports","modules/advanced/views/report/reports/charts/grid1bar-vertical"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{}t.default=s}),define("modules/advanced/views/report/reports/charts/grid0bar-horizontal",["exports","modules/advanced/views/report/reports/charts/grid1bar-horizontal"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{}t.default=s}),define("advanced:views/report/record/list",["views/record/list"],function(t){return t.extend({quickEditDisabled:!0,mergeAction:!1,massActionList:["remove","massUpdate","export"],rowActionsView:"advanced:views/report/record/row-actions/default",massPrintPdfDisabled:!0,actionShow:function(t){if(!t.id)return;let e=this.collection.get(t.id);e&&this.createView("resultModal","advanced:views/report/modals/result",{model:e},t=>{t.render(),this.listenToOnce(t,"navigate-to-detail",e=>{let i={id:e.id,model:e,rootUrl:this.getRouter().getCurrentUrl()};this.getRouter().navigate("#Report/view/"+e.id,{trigger:!1}),this.getRouter().dispatch("Report","view",i),t.close()})})}})}),define("advanced:views/report/record/export-grid",["views/record/base"],function(t){return t.extend({template:"advanced:report/record/export-grid",setup:function(){t.prototype.setup.call(this),this.scope=this.options.scope;var e=this.getMetadata().get("app.export.gridReportFormatList")||[],i=this.getConfig().get("version")||"",s=i.split(".");"dev"!==i&&s.length>2&&100*parseInt(s[0])+parseInt(s[1])<407&&(e=["csv"]),this.createField("exportFormat","views/fields/enum",{options:e}),this.controlColumnField(),this.listenTo(this.model,"change:exportFormat",this.controlColumnField,this),this.options.columnList&&this.createField("column","views/fields/enum",{options:this.options.columnList,translatedOptions:this.options.columnsTranslation||{}})},controlColumnField:function(){"csv"===this.model.get("exportFormat")?this.showField("column"):this.hideField("column")}})}),define("modules/advanced/views/report/record/edit",["exports","views/record/edit","modules/advanced/report-helper","modules/advanced/views/report/record/detail"],function(t,e,i,s){"use strict";function a(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=a(e),i=a(i),s=a(s);class n extends e.default{saveAndContinueEditingAction=!0;saveAndNewAction=!1;setup(){if(!this.model.attributes.type)throw new Error;if(this.model.attributes.isInternal?this.layoutName="detail":this.layoutName="detail"+this.model.attributes.type,this.reportHelper=new i.default(this.getMetadata(),this.getLanguage(),this.getDateTime(),this.getConfig(),this.getPreferences()),"List"===this.model.attributes.type&&this.model.isNew()&&!this.model.has("columns")){const t=this.getMetadata().get(`entityDefs.${this.model.attributes.entityType}.fields.name`);t&&!t.utility&&this.model.set("columns",["name"])}super.setup(),this.controlChartColorsVisibility(),this.listenTo(this.model,"change",()=>{(this.model.hasChanged("chartType")||this.model.hasChanged("groupBy")||this.model.hasChanged("columns")||this.model.hasChanged("columnsData")||this.model.hasChanged("chartOneColumns"))&&this.controlChartColorsVisibility()}),"Grid"===this.model.attributes.type&&(this.controlTableModeField(),this.listenTo(this.model,"change:groupBy",()=>this.controlTableModeField()),this.controlChartField(),this.listenTo(this.model,"change:groupBy change:tableMode",()=>this.controlChartField()),this.controlOrderByField(),this.listenTo(this.model,"change:groupBy",this.controlOrderByField),this.controlChartColumnsFields(),this.listenTo(this.model,"change",(t,e)=>{e.preventLoop||(this.model.hasChanged("chartType")||this.model.hasChanged("groupBy")||this.model.hasChanged("columns")||this.model.hasChanged("chartOneColumns"))&&this.controlChartColumnsFields(e.ui)})),!this.getMetadata().get(["scopes","ReportCategory","disabled"])&&this.getAcl().checkScope("ReportCategory","read")||this.hideField("category"),this.setupEmailSendingFieldsVisibility(),"no"===this.getAcl().getPermissionLevel("portalPermission")&&this.hideField("portals"),this.controlChartTypeFieldOptions(),this.listenTo(this.model,"change:groupBy",this.controlChartTypeFieldOptions),this.model.attributes.isInternal&&this.setFieldReadOnly("internalClassName",!0)}afterRender(){if(super.afterRender(),this.element){const t=document.createElement("button");t.type="button",t.classList.add("btn","btn-text");const e=document.createElement("span");e.textContent=this.translate("Preview","labels","Report");const i=document.createElement("span");i.classList.add("fas","fa-eye","fa-sm"),t.append(i),t.append(e),t.onclick=()=>this.actionPreview();const s=document.createElement("div");s.classList.add("btn-group","pull-right"),s.append(t);const a=this.element.querySelector(".sub-container");a&&a.append(s)}}controlChartTypeFieldOptions(){const t=(this.model.attributes.groupBy||[]).length.toString(),e=this.getMetadata().get(["entityDefs","Report","fields","chartType","optionListMap",t]);this.setFieldOptionList("chartType",e)}setupEmailSendingFieldsVisibility(){s.default.prototype.setupEmailSendingFieldsVisibility.call(this)}controlEmailSendingIntervalField(){s.default.prototype.controlEmailSendingIntervalField.call(this)}controlChartColorsVisibility(){const t=this.model.attributes.chartType;if(!t||""===t)return this.hideField("chartColor"),void this.hideField("chartColorList");if((this.model.attributes.groupBy||[]).length>1)return this.hideField("chartColor"),void this.showField("chartColorList");if("Pie"===t)return this.hideField("chartColor"),void this.showField("chartColorList");if(["Line","BarHorizontal","BarVertical","Radar"].includes(t)){if((this.model.attributes.columns||[]).filter(t=>this.reportHelper.isColumnNumeric(t,this.model)).length>1)return this.hideField("chartColor"),void this.showField("chartColorList")}this.showField("chartColor"),this.hideField("chartColorList")}controlOrderByField(){0===(this.model.attributes.groupBy||[]).length?this.hideField("orderBy"):this.showField("orderBy")}controlChartColumnsFields(t){const e=this.model.attributes.chartType,i=this.model.attributes.columns||[],s=this.model.attributes.groupBy||[];let a;this.setFieldOptionList("chartOneColumns",i),this.setFieldOptionList("chartOneY2Columns",i),0===i.length||s.length>1?(t&&(this.model.set("chartOneColumns",[],{preventLoop:!0}),this.model.set("chartOneY2Columns",[],{preventLoop:!0})),a=!1):a=!0;const n=this.model.attributes.chartOneColumns||[],o=this.model.attributes.chartOneY2Columns||[];if(["BarVertical","BarHorizontal","Line","Radar"].includes(e)||(a=!1),a){this.showField("chartOneColumns");let t=!0;("Radar"===e||0===n.length&&0===o.length||1===i.length&&0===o.length)&&(t=!1),t?this.showField("chartOneY2Columns"):this.hideField("chartOneY2Columns")}else this.hideField("chartOneColumns"),this.hideField("chartOneY2Columns");if(t&&i.length>1){let t=Espo.Utils.clone(this.model.attributes.chartOneColumns||[]),e=Espo.Utils.clone(this.model.attributes.chartOneY2Columns||[]);t=t.filter(t=>i.includes(t)),e=e.filter(t=>i.includes(t)),this.model.set("chartOneColumns",t,{ui:!0,preventLoop:!0}),this.model.set("chartOneY2Columns",e,{ui:!0,preventLoop:!0})}}async actionPreview(){this.model.set(this.fetch());let t=!1;if(this.model.attributes.name||(this.model.set("name","Unnamed"),t=!0),this.validate())return t&&this.model.set("name",null),void Espo.Ui.error(this.translate("Not valid"));t&&this.model.set("name",null);const e=await this.createView("modal","advanced:views/report/modals/result",{model:this.model,isPreview:!0});await e.render()}controlTableModeField(){(this.model.attributes.groupBy??[]).length>=2?this.showField("tableMode"):this.hideField("tableMode")}controlChartField(){(this.model.attributes.groupBy??[]).length>=2&&"Normalized"===this.model.attributes.tableMode?(this.hideField("chartType"),this.hidePanel("chart")):(this.showField("chartType"),this.showPanel("chart"))}}t.default=n}),define("advanced:views/report/record/detail-bottom",["views/record/detail-bottom"],function(t){return t.extend({afterRender:function(){}})}),define("advanced:views/report/record/row-actions/default",["views/record/row-actions/edit-and-remove"],function(t){return t.extend({getActionList:function(){var e=t.prototype.getActionList.call(this);return e.unshift({link:"#Report/show/"+this.model.id,label:"Show",action:"show",data:{id:this.model.id}}),e}})}),define("advanced:views/report/record/panels/report",["view","advanced:report-helper"],function(t,e){return t.extend({template:"advanced:report/record/panels/report",setup:function(){const t=new e(this.getMetadata(),this.getLanguage(),this.getDateTime(),this.getConfig(),this.getPreferences()),i=t.getReportView(this.model);this.createView("report",i,{selector:".report-container",model:this.model,reportHelper:t}),this.recordHelper=this.options.recordHelper,this.listenTo(this.recordHelper,"run-report",()=>this.actionRefresh())},actionRefresh:function(){this.getView("report").refresh()}})}),define("modules/advanced/views/report/record/panels/internal-params",["exports","views/record/panels/bottom"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{templateContent='\n        <div class="field" data-name="internalParams">{{{internalParamsField}}}</div>\n    ';setup(){super.setup(),this.createField("internalParams","modules/advanced/views/report/fields/internal-params",{},this.mode)}getFieldViews(){return{internalParams:this.getView("internalParamsField")}}}t.default=s}),define("modules/advanced/views/report/record/panels/email-sending",["exports","views/record/panels/side"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{}t.default=s}),define("advanced:views/report/modals/select-records",["crm:views/document/modals/select-records"],function(t){return t.extend({categoryScope:"ReportCategory",categoryField:"category",categoryFilterType:"inCategory",createButton:!1})}),define("modules/advanced/views/report/modals/result",["exports","views/modal","modules/advanced/report-helper","views/modals/detail"],function(t,e,i,s){"use strict";function a(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=a(e),i=a(i),s=a(s);class n extends e.default{template="advanced:report/modals/result";backdrop=!0;isPreview;shortcutKeys={"Control+ArrowLeft":function(t){this.handleShortcutKeyControlArrowLeft(t)},"Control+ArrowRight":function(t){this.handleShortcutKeyControlArrowRight(t)},"Control+Enter":function(t){this.getReportView().run(),t.preventDefault(),t.stopPropagation()}};setup(){this.isPreview=this.options.isPreview,this.reportHelper=new i.default(this.getMetadata(),this.getLanguage(),this.getDateTime(),this.getConfig(),this.getPreferences()),this.createRecordView(),!this.isPreview&&this.model&&this.model.collection&&!this.navigateButtonsDisabled?(this.buttonList.push({name:"previous",html:'<span class="fas fa-chevron-left"></span>',title:this.translate("Previous Entry"),pullLeft:!0,className:"btn-text",disabled:!0}),this.buttonList.push({name:"next",html:'<span class="fas fa-chevron-right"></span>',title:this.translate("Next Entry"),pullLeft:!0,className:"btn-text",disabled:!0}),this.indexOfRecord=this.model.collection.indexOf(this.model)):this.navigateButtonsDisabled=!0,this.on("after:render",()=>{this.$el.find(".modal-body").css({"overflow-x":"hidden","overflow-y":"auto"})})}createRecordView(t){const e=`#Report/view/${this.model.id}`,i=this.model.attributes.name;this.isPreview?this.headerText=this.translate("Preview","labels","Report"):this.headerHtml=`<a data-action="link" class="action" href="${e}">${this.getHelper().escapeString(i)}</a>`;const s=this.reportHelper.getReportView(this.model);this.createView("record",s,{selector:".report-container",model:this.model,reportHelper:this.reportHelper,showChartFirst:!this.isPreview,isLargeMode:!0,isPreview:this.isPreview},t)}getReportView(){return this.getView("record")}afterRender(){this.$el.find(".modal-body").addClass("panel-body"),setTimeout(()=>{this.$el.children(0).scrollTop(0)},50),this.navigateButtonsDisabled||this.controlNavigationButtons()}actionLink(){this.trigger("navigate-to-detail",this.model)}actionPrevious(){s.default.prototype.actionPrevious.call(this)}actionNext(){s.default.prototype.actionNext.call(this)}controlNavigationButtons(){s.default.prototype.controlNavigationButtons.call(this)}controlRecordButtonsVisibility(){s.default.prototype.controlRecordButtonsVisibility.call(this)}switchToModelByIndex(t){s.default.prototype.switchToModelByIndex.call(this,t)}getRecordView(){return this.getView("record")}handleShortcutKeyControlArrowLeft(t){this.model.collection&&-1!==this.buttonList.findIndex(t=>"previous"===t.name&&!t.disabled)&&"TEXTAREA"!==t.target.tagName&&"INPUT"!==t.target.tagName&&(t.preventDefault(),t.stopPropagation(),this.actionPrevious())}handleShortcutKeyControlArrowRight(t){this.model.collection&&-1!==this.buttonList.findIndex(t=>"next"===t.name&&!t.disabled)&&"TEXTAREA"!==t.target.tagName&&"INPUT"!==t.target.tagName&&(t.preventDefault(),t.stopPropagation(),this.actionNext())}}t.default=n}),define("advanced:views/report/modals/export-grid",["views/modal","model"],function(t,e){return t.extend({templateContent:'<div class="record">{{{record}}}</div>',setup:function(){this.buttonList=[{name:"export",label:"Export",style:"danger"},{name:"cancel",label:"Cancel"}],this.model=new e,this.model.name="Report",this.scope=this.options.scope;let t=(this.getMetadata().get("app.export.gridReportFormatList")||[])[0];this.model.set("exportFormat",t),this.createView("record","advanced:views/report/record/export-grid",{scope:this.scope,model:this.model,selector:".record",columnList:this.options.columnList,columnsTranslation:this.options.columnsTranslation})},actionExport:function(){let t=this.getView("record").fetch();if(this.model.set(t),this.getView("record").validate())return;let e={format:t.exportFormat,column:t.column};this.trigger("proceed",e),this.close()}})}),define("advanced:views/report/modals/edit-group-by",["views/modal","model"],function(t,e){return t.extend({template:"advanced:report/modals/edit-group-by",data:function(){return{}},setup:function(){this.buttonList=[{name:"apply",label:"Apply",style:"danger"},{name:"cancel",label:"Cancel",onClick:function(t){t.close()}}];var t=this.options.value[0]||"",i=this.options.value[1]||"";t=t.replace(/\t/g,"\r\n"),i=i.replace(/\t/g,"\r\n"),this.headerHtml=this.translate("groupBy","fields","Report"),this.once("close",()=>{this.$entityType&&this.$entityType.popover("destroy")});var s=new e;s.set({v1:t,v2:i});let a="views/fields/formula",n=null,o=!0;this.complexExpressionFieldIsAvailable()&&(a="views/fields/complex-expression",n=this.model.get("entityType"),o=!1),this.createView("v1",a,{model:s,name:"v1",selector:".v1-container",mode:"edit",insertDisabled:o,height:50,targetEntityType:n,smallFont:!0}),this.createView("v2",a,{model:s,name:"v2",selector:".v2-container",mode:"edit",insertDisabled:o,height:50,targetEntityType:n,smallFont:!0})},actionApply:function(){const t=[];let e=this.getView("v1").fetch().v1||"",i=this.getView("v2").fetch().v2||"";e=e.replace(/(?:\r\n|\r|\n)/g,"\t").trim(),i=i.replace(/(?:\r\n|\r|\n)/g,"\t").trim(),e&&t.push(e),i&&t.push(i),this.trigger("apply",t),this.remove()},complexExpressionFieldIsAvailable:function(){let t=this.getConfig().get("version");return!("@@version"!==t&&!this._isVersionGraterThanOrEqual("7.0.9",t))},_isVersionGraterThanOrEqual:function(t,e){if(t===e)return!0;let i=t.split("."),s=e.split("."),a=s.length;a>3&&(a=3);for(let t=0;t<a;t++){let e=~~s[t],a=~~i[t];if(e>a)return!0;if(e<a)return!1}return!1}})}),define("advanced:views/report/modals/edit-columns",["views/modal","model"],function(t){return t.extend({templateContent:'\n            <div class="panel panel-default no-side-margin">\n                <div class="panel-body panel-body-form">\n                    {{#each itemList}}\n                        <div class="margin-bottom" data-key="{{key}}">{{{var key ../this}}}</div>\n                        <hr>\n                    {{/each}}\n                    <div class="button-container margin-top-2x">\n                        <div\n                            class="btn btn-default btn-icon"\n                            title="{{translate \'Add\'}}"\n                            data-action="add"\n                        ><span class="fas fa-plus"></span></div>\n                    </div>\n                </div>\n            </div>\n        ',data:function(){return{itemList:this.getItemList()}},setup:function(){this.addActionHandler("add",()=>this.addItem()),this.buttonList=[{name:"apply",label:"Apply",style:"danger"},{name:"cancel",label:"Cancel",onClick:t=>t.close()}],this.entityType=this.options.entityType,this.expressions=Espo.Utils.clone(this.options.expressions||[]).map(t=>t.replace(/\t/g,"\r\n")),this.labels=Espo.Utils.clone(this.options.labels||[]),this.types=Espo.Utils.clone(this.options.types||[]),this.decimals=Espo.Utils.clone(this.options.decimals||[]),this.headerHtml=this.translate("columns","fields","Report"),this.wait(this.createItemViews())},getItemList:function(){return this.expressions.map((t,e)=>({key:e.toString(),number:e+1,expression:t,label:this.labels[e]||null,type:this.types[e]||null,decimalPlaces:this.decimals[e]}))},createItemViews:function(){const t=this.getItemList().map((t,e)=>this.createItemView(e));return Promise.all(t)},createItemView(t){const e=this.getItemList()[t];if(!e)throw new Error(`No item ${t}.`);return this.createView(e.key,"advanced:views/report/fields/columns/item",{selector:`[data-key="${e.key}"]`,expression:e.expression,label:e.label,type:e.type,decimalPlaces:e.decimalPlaces,entityType:this.entityType,number:e.number,onChange:(e,i,s,a)=>{this.expressions[t]=e,this.labels[t]=i,this.types[t]=s,this.decimals[t]=a}})},actionApply:function(){let t=!0;if(this.getItemList().forEach(e=>{this.getView(e.key).validate()&&(t=!1)}),!t)return;const e=[],i=[],s=[],a=[];this.expressions.forEach((t,n)=>{if(null===t)return;if(""===(t=t.replace(/(?:\r\n|\r|\n)/g,"\t")))return;const o=this.labels[n]||null,r=this.types[n]||null,l=this.decimals[n];e.push(t),i.push(o),s.push(r),a.push(l)}),this.trigger("apply",e,i,s,a),this.remove()},addItem:function(){this.expressions.push(null),this.labels.push(null),this.types.push(null),this.decimals.push(null),this.createItemView(this.expressions.length-1).then(()=>this.reRender())}})}),define("advanced:views/report/modals/create",["views/modal","model"],function(t,e){return t.extend({cssName:"create-report",template:"advanced:report/modals/create",data:function(){return{entityTypeList:this.entityTypeList,typeList:this.typeList}},events:{'click [data-action="create"]':function(t){let e=$(t.currentTarget).data("type"),i=this.getView("entityType");i.fetch(),i.validate();let s=this.model.get("entityType");s&&this.trigger("create",{type:e,entityType:s})}},setup:function(){this.buttonList=[{name:"cancel",label:"Cancel",onClick:t=>{t.close()}}],this.typeList=this.getMetadata().get("entityDefs.Report.fields.type.options");let t=this.getMetadata().get("scopes"),i=this.getMetadata().get("entityDefs.Report.entityListToIgnore")||[],s=this.getMetadata().get("entityDefs.Report.entityListAllowed")||[];this.entityTypeList=Object.keys(t).filter(e=>{if(~i.indexOf(e))return;if(!this.getAcl().check(e,"read"))return;let a=t[e];return a.entity&&(a.tab||a.object||~s.indexOf(e))}).sort((t,e)=>this.translate(t,"scopeNamesPlural").localeCompare(this.translate(e,"scopeNamesPlural"))),this.entityTypeList.unshift(""),this.model=new e,this.createView("entityType","views/fields/enum",{model:this.model,mode:"edit",name:"entityType",selector:'[data-name="entityType"]',params:{options:this.entityTypeList,translation:"Global.scopeNames",required:!0},labelText:this.translate("entityType","fields","Report")}),this.header=this.translate("Create Report","labels","Report")}})}),define("advanced:views/report/modals/add-filter-field",["views/modal"],function(t){return t.extend({templateContent:'<div class="field" data-name="filters">{{{field}}}</div>',backdrop:!0,events:{'click a[data-action="addField"]':function(t){this.trigger("add-field",$(t.currentTarget).data().name)}},data:function(){return{}},setup:function(){this.header=this.translate("Add Field");var t=this.scope=this.options.scope;this.wait(!0),this.getModelFactory().create("Report",e=>{e.set("entityType",t),this.createView("field","advanced:views/report/fields/filters",{selector:".field",model:e,mode:"edit",defs:{name:"filters",params:{}}},t=>{this.listenTo(t,"change",()=>{var t=e.get("filters")||[];t.length&&this.trigger("add-field",t[0])})}),this.wait(!1)})}})}),define("advanced:views/report/filters/node",["view"],function(t){return t.extend({template:"advanced:report/filters/node",events:{'click > .buttons [data-action="addOr"]':function(){this.addOrGroup()},'click > .buttons [data-action="addAnd"]':function(){this.addAndGroup()},'click > .buttons [data-action="addNot"]':function(){this.addNotGroup()},'click > .buttons [data-action="addSubQueryIn"]':function(){this.addSubQueryInGroup()},'click > .buttons [data-action="addField"]':function(){this.addField()},'click > .buttons [data-action="addComplexExpression"]':function(){this.addComplexExpression()},'click > .buttons [data-action="addHavingGroup"]':function(){this.addHavingGroup()}},data:function(){var t=this.getOperator();return{notDisabled:this.notDisabled,subQueryInDisabled:this.subQueryInDisabled,complexExpressionDisabled:this.complexExpressionDisabled,havingDisabled:this.havingDisabled,fieldDisabled:this.fieldDisabled,orDisabled:this.orDisabled||"or"===t,andDisabled:this.andDisabled||"and"===t,operator:t}},setup:function(){this.dataList=Espo.Utils.cloneDeep(this.options.dataList),this.scope=this.options.scope,this.level=this.options.level||0,this.filterData=this.options.filterData||{},this.isHaving="having"===this.filterData.type||this.options.isHaving,(this.level>1||"not"===this.filterData.type||"subQueryIn"===this.filterData.type)&&(this.notDisabled=!0,this.subQueryInDisabled=!0),this.level>0&&(this.havingDisabled=!0),this.isHaving&&(this.fieldDisabled=!0,this.notDisabled=!0),"having"===this.filterData.type&&(this.andDisabled=!0);var t=this.getConfig().get("version")||"",e=t.split(".");"dev"!==t&&e.length>2&&100*parseInt(e[0])+parseInt(e[1])<407&&(this.notDisabled=!0,this.complexExpressionDisabled=!0),"dev"!==t&&e.length>2&&(parseInt(e[0])<5||5===parseInt(e[0])&&0===parseInt(e[1]))&&(this.havingDisabled=!0),"dev"!==t&&e.length>2&&100*parseInt(e[0])+parseInt(e[1])<506&&(this.subQueryInDisabled=!0)},afterRender:function(){this.$itemList=this.$el.find("> .item-list"),this.dataList.forEach(function(t){this.createItem(t)},this)},fetch:function(){var t=[];return this.dataList.forEach(e=>{var i=this.getView(e.id);if(i){var s=i.fetch();t.push(s)}}),t},getOperator:function(){return"or"===this.filterData.type?"or":"and"},createItem:function(t,e){var i=t.type;if(t.id){var s=$("<div>").attr("data-id",t.id);this.$itemList.append(s);var a=$("<div>");a.attr("data-item-id",t.id),a.addClass("node-operator");var n=this.getOperator(),o=$("<div>").addClass("form-group");o.html(this.translate(n,"filtersGroupTypes","Report")),a.append(o),this.$itemList.append(a);var r="advanced:views/report/filters/container";if(~["or","and","not","having","subQueryIn"].indexOf(i))r="advanced:views/report/filters/container-group";else if("complexExpression"===i)r="advanced:views/report/filters/container-complex";else if(!t.name)return;this.createView(t.id,r,{selector:'[data-id="'+t.id+'"]',scope:this.scope,filterData:t,level:this.level+1,isHaving:this.isHaving},s=>{e&&this.listenToOnce(s,"after:render",()=>{if(~["or","and","not","having","subQueryIn"].indexOf(i)){var t=s.$el.find("> label > span");t.addClass("text-danger"),setTimeout(()=>{t.removeClass("text-danger")},1500)}else{var e=s.$el.find(".form-group");e.addClass("has-error"),setTimeout(()=>{e.removeClass("has-error")},1500)}}),s.render(),this.listenToOnce(s,"remove-item",()=>{this.removeItem(t.id)})})}},removeItem:function(t){this.clearView(t),this.$el.find('[data-id="'+t+'"]').remove(),this.$el.find('[data-item-id="'+t+'"]').remove();var e=-1;this.dataList.forEach((i,s)=>{i.id===t&&(e=s)}),~e&&this.dataList.splice(e,1)},addOrGroup:function(){var t={id:this.generateId(),type:"or",params:{type:"or",value:[]}};this.dataList.push(t),this.createItem(t,!0)},addHavingGroup:function(){var t={id:this.generateId(),type:"having",params:{type:"having",value:[]}};this.dataList.push(t),this.createItem(t,!0)},addAndGroup:function(){var t={id:this.generateId(),type:"and",params:{type:"and",value:[]}};this.dataList.push(t),this.createItem(t,!0)},addNotGroup:function(){var t={id:this.generateId(),type:"not",params:{type:"not",value:[]}};this.dataList.push(t),this.createItem(t,!0)},addSubQueryInGroup:function(){var t={id:this.generateId(),type:"subQueryIn",params:{type:"subQueryIn",value:[]}};this.dataList.push(t),this.createItem(t,!0)},addComplexExpression:function(){var t={id:this.generateId(),type:"complexExpression",params:{function:this.isHaving?"COUNT":"custom",attribute:null,operator:"equals",formula:""}};this.dataList.push(t),this.createItem(t,!0)},addField:function(){this.createView("modal","advanced:views/report/modals/add-filter-field",{scope:this.scope,level:this.level},t=>{t.render(),this.listenToOnce(t,"add-field",t=>{var e={id:this.generateId(),name:t,params:{}};this.dataList.push(e),this.createItem(e,1),this.clearView("modal")})})},generateId:function(){return Math.random().toString(16).slice(2)}})}),define("advanced:views/report/filters/container",["view"],function(t){return t.extend({templateContent:'<div class="filter">{{{filter}}}</div>',events:{"click .remove-filter":function(){this.trigger("remove-item")}},setup:function(){this.scope=this.options.scope,this.filterData=this.options.filterData;let t=this.scope;const e=this.filterData.name;let i=e,s=null;~e.indexOf(".")&&(s=e.split(".")[0],i=e.split(".")[1],t=this.getMetadata().get(`entityDefs.${this.scope}.links.${s}.entity`)),t&&i&&(this.wait(!0),this.getModelFactory().create(t,e=>{this.createView("filter","views/search/filter",{name:i,model:e,params:this.filterData.params,selector:".filter"}),t!==this.scope&&this.on("after:render",()=>{const e=this.translate(s,"links",this.scope)+" . "+this.translate(i,"fields",t);this.$el.find(`label[data-name="${i}"]`).html(e)}),this.wait(!1)}))},fetch:function(){const t=this.getView("filter").getView("field");if(!t)return{};const e=t.fetchSearch(),i=function(t,e){const s=t.type;if("or"===s||"and"===s||"not"===s||"subQueryIn"===s)return void(t.value||[]).forEach(t=>{i(t,e)});let a=t.attribute||t.field||e;if(~e.indexOf(".")&&!~a.indexOf(".")){a=e.split(".")[0]+"."+a}t.field=a,t.attribute=a};return i(e,this.filterData.name),{id:this.filterData.id,name:this.filterData.name,params:e}}})}),define("advanced:views/report/filters/container-group",["view"],function(t){return t.extend({template:"advanced:report/filters/container-group",events:{'click > a[data-action="removeGroup"]':function(){this.trigger("remove-item")}},data:function(){var t=!0;return"and"!==this.type&&"or"!==this.type||(t=!1),{type:this.type,noOffset:this.options.level>3,showGroupTypeLabel:t}},setup:function(){this.filterData=this.options.filterData,this.scope=this.options.scope,this.type=this.filterData.type,this.createView("node","advanced:views/report/filters/node",{selector:"> .node",scope:this.scope,dataList:this.filterData.params.value||[],level:this.options.level,filterData:this.filterData,isHaving:this.options.isHaving})},fetch:function(){return{id:this.filterData.id,type:this.filterData.type,params:{type:this.filterData.type,value:this.getView("node").fetch()}}}})}),define("advanced:views/report/filters/container-complex",["views/record/base","model"],function(t,e){return t.extend({template:"advanced:report/filters/container-complex",events:{'click > div > a[data-action="removeGroup"]':function(){this.trigger("remove-item")}},setup:function(){var i=this.model=new e;i.name="Report",t.prototype.setup.call(this),this.scope=this.options.scope,this.filterData=this.options.filterData||{};const s=this.filterData.params||{};let a,n;this.options.isHaving?(a=Espo.Utils.clone(this.getMetadata().get(["entityDefs","Report","complexExpressionHavingFunctionList"])||[]),a.unshift("customWithOperator"),a.unshift("custom")):(a=Espo.Utils.clone(this.getMetadata().get(["entityDefs","Report","complexExpressionFunctionList"])||[]),a.unshift("customWithOperator"),a.unshift("custom"),a.unshift("")),n=this.options.isHaving?Espo.Utils.clone(this.getMetadata().get(["entityDefs","Report","complexExpressionHavingOperatorList"])||[]):Espo.Utils.clone(this.getMetadata().get(["entityDefs","Report","complexExpressionOperatorList"])||[]),i.set({function:s.function,attribute:s.attribute,operator:s.operator,expression:s.expression,value:s.value}),this.createView("function","views/fields/enum",{selector:".function-container",params:{options:a},name:"function",model:i,mode:"edit"},function(t){this.listenTo(t,"after:render",function(){t.$el.find(".form-control").addClass("input-sm")},this)}),this.createView("operator","views/fields/enum",{selector:".operator-container",params:{options:n},name:"operator",model:i,mode:"edit"},function(t){this.listenTo(t,"after:render",function(){t.$el.find(".form-control").addClass("input-sm")},this)}),this.setupAttributes(),this.createView("attribute","views/fields/enum",{selector:".attribute-container",params:{options:this.attributeList,translatedOptions:this.translatedOptions},name:"attribute",model:i,mode:"edit"},function(t){this.listenTo(t,"after:render",()=>{t.$el.find(".form-control").addClass("input-sm")})}),this.createView("value","views/fields/formula",{selector:".value-container",params:{height:50},name:"value",model:i,mode:"edit",allowedFunctionList:["datetime\\","string\\","env\\userAttribute"],smallFont:!0});const o=this.complexExpressionFieldIsAvailable()?"views/fields/complex-expression":"views/fields/varchar";this.createView("expression",o,{selector:".expression-container",name:"expression",model:i,mode:"edit",targetEntityType:this.scope,smallFont:!0},t=>{this.listenTo(t,"after:render",()=>{t.$el.find(".form-control").addClass("input-sm")})}),this.controlVisibility(),this.listenTo(this.model,"change:operator",()=>{this.controlVisibility()}),this.listenTo(this.model,"change:function",()=>{this.controlVisibility()})},controlVisibility:function(){const t=this.model.get("function");"custom"===t?(this.hideField("attribute"),this.hideField("operator"),this.hideField("value"),this.showField("expression")):"customWithOperator"===t?(this.hideField("attribute"),this.showField("operator"),this.showField("value"),this.showField("expression")):(this.hideField("expression"),this.showField("attribute"),this.showField("value"),this.showField("operator")),"custom"!==t&&(~["isNull","isNotNull","isTrue","isFalse"].indexOf(this.model.get("operator"))?this.hideField("value"):(this.showField("value"),this.getFieldView("value")&&this.getFieldView("value").isRendered()&&this.getFieldView("value").reRender()))},getAttributeListForScope:function(t){const e=this.getFieldManager().getEntityTypeFieldList(t).filter(e=>{const i=this.getMetadata().get(["entityDefs",t,"fields",e])||{};if(i.notStorable)return;if(!i.type)return;const s=i.type;return!(i.directAccessDisabled||i.reportDisabled||i.disabled||i.utility||~["linkMultiple","email","phone"].indexOf(s)||this.options.isHaving&&!~["int","float","currency","currencyConverted"].indexOf(s)||!this.getFieldManager().isEntityTypeFieldAvailable(t,e))||void 0}),i=[];return e.forEach(e=>{const s=this.getMetadata().get(["entityDefs",t,"fields",e])||{};this.options.isHaving&&"currency"===s.type?i.push(e):this.getFieldManager().getAttributeList(s.type,e).forEach(t=>{~i.indexOf(t)||i.push(t)})}),this.options.isHaving&&i.push("id"),i.sort(),i},setupAttributes:function(){const t=this.scope,e=this.getAttributeListForScope(t),i=this.getMetadata().get(["entityDefs",this.options.scope,"links"]),s=[];Object.keys(i).forEach(t=>{const e=i[t].type;e&&(i[t].disabled||i[t].utility||(~["belongsToParent","hasOne","belongsTo"].indexOf(e)&&s.push(t),this.options.isHaving&&"hasMany"===e&&s.push(t)))}),s.sort(),s.forEach(t=>{var s=i[t].entity;if(!s)return;this.getAttributeListForScope(s,!0).forEach(i=>{e.push(`${t}.${i}`)})}),this.attributeList=e,this.setupTranslatedOptions()},setupTranslatedOptions:function(){this.translatedOptions={};const t=this.scope;this.attributeList.forEach(e=>{let i,s=e,a=t,n=!1;if(~e.indexOf(".")&&(n=!0,s=e.split(".")[1],i=e.split(".")[0],a=this.getMetadata().get(`entityDefs.${t}.links.${i}.entity`)),this.translatedOptions[e]=this.translate(s,"fields",a),s.indexOf("Id")===s.length-2){const t=s.substr(0,s.length-2);this.getMetadata().get(["entityDefs",a,"fields",t])&&(this.translatedOptions[e]=this.translate(t,"fields",a)+" ("+this.translate("id","fields")+")")}else if(s.indexOf("Name")===s.length-4){const t=s.substr(0,s.length-4);this.getMetadata().get(["entityDefs",a,"fields",t])&&(this.translatedOptions[e]=this.translate(t,"fields",a)+" ("+this.translate("name","fields")+")")}else if(s.indexOf("Type")===s.length-4){const t=s.substr(0,s.length-4);this.getMetadata().get(["entityDefs",a,"fields",t])&&(this.translatedOptions[e]=this.translate(t,"fields",a)+" ("+this.translate("type","fields")+")")}if(s.indexOf("Ids")===s.length-3){const t=s.substr(0,s.length-3);this.getMetadata().get(["entityDefs",a,"fields",t])&&(this.translatedOptions[e]=this.translate(t,"fields",a)+" ("+this.translate("ids","fields")+")")}else if(s.indexOf("Names")===s.length-5){const t=s.substr(0,s.length-5);this.getMetadata().get(["entityDefs",a,"fields",t])&&(this.translatedOptions[e]=this.translate(t,"fields",a)+" ("+this.translate("names","fields")+")")}else if(s.indexOf("Types")===s.length-5){const t=s.substr(0,s.length-5);this.getMetadata().get(["entityDefs",a,"fields",t])&&(this.translatedOptions[e]=this.translate(t,"fields",a)+" ("+this.translate("types","fields")+")")}n&&(this.translatedOptions[e]=this.translate(i,"links",t)+" . "+this.translatedOptions[e])})},fetch:function(){this.getView("function").fetchToModel(),this.getView("attribute").fetchToModel(),this.getView("operator").fetchToModel(),this.getView("value").fetchToModel(),this.getView("expression").fetchToModel();let t=this.model.get("expression");const e=this.model.get("function")||null;let i=this.model.get("attribute"),s=this.model.get("operator")||null,a=this.model.get("value");return"custom"===e?(i=null,s=null,a=null):"customWithOperator"===e?i=null:t=null,{id:this.filterData.id,type:"complexExpression",params:{function:e,attribute:i,operator:s,value:a,expression:t}}},complexExpressionFieldIsAvailable:function(){const t=this.getConfig().get("version");return!("@@version"!==t&&!this._isVersionGraterThanOrEqual("7.0.9",t))},_isVersionGraterThanOrEqual:function(t,e){if(t===e)return!0;const i=t.split("."),s=e.split(".");let a=s.length;a>3&&(a=3);for(let t=0;t<a;t++){const e=~~s[t],a=~~i[t];if(e>a)return!0;if(e<a)return!1}return!1}})}),define("advanced:views/report/fields/runtime-filters",["views/fields/multi-enum","advanced:views/report/fields/filters"],function(t,e){return t.extend({setupOptions:function(){t.prototype.setupOptions.call(this),this.params.options=e.prototype.getFilterList.call(this),e.prototype.setupTranslatedOptions.call(this)}})}),define("advanced:views/report/fields/order-by",["views/fields/multi-enum"],function(t){return t.extend({setupOptions:function(){const t=this.model.get("entityType"),e=[];(this.model.get("groupBy")||[]).forEach(i=>{if("id"===i)return;let s=t,a=i,n=null;~a.indexOf(":")&&(a=i.split(":")[1]),~a.indexOf(".")&&(a=i.split(".")[1],n=i.split(".")[0],s=this.getMetadata().get(`entityDefs.${t}.links.${n}.entity`));const o=this.getMetadata().get(`entityDefs.${s}.fields.${a}.type`);if(!n||!["link","file","image","linkParent"].includes(o))switch(o){case"enum":return void e.push("LIST:"+i);case"date":case"datetime":return;default:~this.selected.indexOf("ASC:"+i)||~this.selected.indexOf("DESC:"+i)?~this.selected.indexOf("ASC:"+i)?e.push("ASC:"+i):~this.selected.indexOf("DESC:"+i)&&e.push("DESC:"+i):(e.push("ASC:"+i),e.push("DESC:"+i))}});(this.model.get("columns")||[]).forEach(t=>{e.push("ASC:"+t),e.push("DESC:"+t)}),this.params.options=e},setupTranslatedOptions:function(){this.translatedOptions={},this.params.options.forEach(t=>{if(~t.indexOf(":")&&~t.indexOf("("))return;const e=t.substr(0,t.indexOf(":"));let i=t.substr(t.indexOf(":")+1),s=this.model.get("entityType");const a=s;let n=i,o=!1,r=!1;~i.indexOf(":")&&(o=i.split(":")[0],i=n=i.split(":")[1]),~i.indexOf(".")&&(r=i.split(".")[0],n=i.split(".")[1],s=this.getMetadata().get(`entityDefs.${a}.links.${r}.entity`)),this.translatedOptions[t]=this.translate(n,"fields",s),r&&(this.translatedOptions[t]=this.translate(r,"links",a)+" . "+this.translatedOptions[t]),o&&(this.translatedOptions[t]="COUNT"===o?this.translate(o,"functions","Report").toUpperCase():this.translate(o,"functions","Report").toUpperCase()+": "+this.translatedOptions[t]),"LIST"!==e&&(this.translatedOptions[t]=this.translatedOptions[t]+" · "+this.translate(e,"orders","Report").toUpperCase())})},setup:function(){t.prototype.setup.call(this),this.setupOptions(),this.setupTranslatedOptions(),this.listenTo(this.model,"change",(t,e)=>{if(this.model.hasChanged("orderBy")||this.model.hasChanged("groupBy")||this.model.hasChanged("columns")){if(this.setupOptions(),this.setupTranslatedOptions(),e.ui&&(this.model.hasChanged("columns")||this.model.hasChanged("groupBy"))){const t=this.model.get("columns")||[],e=this.model.get("groupBy")||[],i=this.model.get(this.name)||[],s=i.filter(i=>(i=i.startsWith("ASC:")?i.substring(4):i.substring(5),t.includes(i)||e.includes(i)));if(i.length!==s.length)return void this.model.set(this.name,s)}this.reRender()}})}})}),define("advanced:views/report/fields/order-by-list",["views/fields/enum"],function(t){return t.extend({setupOptions:function(){const t=this.model.get("entityType"),e=[];e.push("");const i=this.getMetadata().get(`entityDefs.${t}.fields`)||{};Object.keys(i).forEach(s=>{if(!(i[s].disabled||i[s].utility||i[s].reportDisabled||i[s].reportOrderByDisabled||i[s].directAccessDisabled||i[s].orderDisabled||"linkMultiple"===i[s].type)&&"map"!==i[s].type){if(!this.getFieldManager().isEntityTypeFieldAvailable(t,s))return;e.push(`ASC:${s}`),e.push(`DESC:${s}`)}}),this.params.options=e,this.setupTranslatedOptions()},setupTranslatedOptions:function(){this.translatedOptions={},this.translatedOptions[""]=this.translate("Default"),this.params.options.forEach(t=>{if(""===t)return;const e=t.substr(0,t.indexOf(":"));let i=t.substr(t.indexOf(":")+1),s=this.model.get("entityType");const a=s;let n=i,o=!1;~i.indexOf(":")&&(i=n=i.split(":")[1]),~i.indexOf(".")&&(o=i.split(".")[0],n=i.split(".")[1],s=this.getMetadata().get(`entityDefs.${a}.links.${o}.entity`)),this.translatedOptions[t]=this.translate(n,"fields",s),o&&(this.translatedOptions[t]=this.translate(o,"links",a)+" . "+this.translatedOptions[t]),"LIST"!==e&&(this.translatedOptions[t]=this.translatedOptions[t]+" · "+this.translate(e,"orders","Report").toUpperCase())})}})}),define("advanced:views/report/fields/joined-reports",["views/fields/link-multiple-with-columns"],function(t){return t.extend({columnList:["label"],selectPrimaryFilterName:"grid",createDisabled:!0,columnsDefs:{label:{type:"varchar",scope:"Report",field:"joinedReportLabel"}},fetch:function(){var e=t.prototype.fetch.call(this),i=[];return e[this.idsName].forEach(t=>{i.push({id:t,label:((e[this.columnsName]||{})[t]||{}).label})}),e.joinedReportDataList=i,e}})}),define("modules/advanced/views/report/fields/internal-params",["exports","views/fields/base","model","views/record/edit"],function(t,e,i,s){"use strict";function a(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=a(e),i=a(i),s=a(s);class n extends e.default{editTemplateContent='\n        \x3c!--suppress CssUnusedSymbol --\x3e\n        <style>\n            [data-role="sub-record"] {\n                .panel {\n                    box-shadow: none;\n                }\n            }\n        </style>\n        <div data-role="sub-record">{{{record}}}</div>\n    ';formModel=null;recordView=null;async prepare(){if(this.recordView=null,this.formModel=null,this.clearView("record"),!this.getUser().isAdmin()||!this.model.attributes.isInternal||!this.model.attributes.internalClassName)return;const t=this.model.attributes.internalClassName;this.formModel=new i.default;const e=()=>{const t=Espo.Utils.cloneDeep(this.model.attributes.internalParams??{});this.formModel.setMultiple(t)};e(),this.listenTo(this.model,"sync",()=>e());const a=[];(this.getMetadata().get(`app.advancedReport.internalReports.${t}.params`)??[]).forEach(t=>{const e=t.view??this.getFieldManager().getViewName(t.type),i=t.labelTranslation?this.getLanguage().translatePath(t.labelTranslation):null;a.push([{name:t.name,view:e,options:{labelText:i,params:t},customLabel:i},!1])}),this.recordView=new s.default({model:this.formModel,buttonsDisabled:!0,detailLayout:[{rows:a}],sideView:null,bottomView:null,isWide:!0,shortcutKeysEnabled:!0,mode:this.isEditMode()?"edit":"detail",readOnly:this.isReadMode()}),await this.assignView("record",this.recordView)}setup(){this.validations.push(()=>this.validateValid())}fetch(){return this.formModel?{internalParams:Espo.Utils.cloneDeep(this.formModel.attributes)}:{}}validateValid(){return!!this.recordView&&this.recordView.validate()}}t.default=n}),define("modules/advanced/views/report/fields/internal-class-name",["exports","views/fields/base"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{listTemplateContent="\n        {{#if isNotEmpty}}\n            {{label}}\n        {{/if}}\n    ";detailTemplateContent='\n        {{#if isNotEmpty}}\n            {{label}}\n        {{else}}\n            {{#if isSet}}\n                <span class="none-value">{{translate \'None\'}}</span>\n            {{else}}\n                <span class="loading-value"></span>\n            {{/if}}\n        {{/if}}\n    ';data(){const t=this.model.get(this.name),e=t?this.translate(t,"internalReports","Report"):null;return{isSet:this.model.has(this.name),isNotEmpty:null!=this.model.get(this.name),label:e}}setup(){this.params.translation="Report.internalReports",super.setup()}setupOptions(){super.setupOptions()}}t.default=s}),define("advanced:views/report/fields/filters-control",["views/fields/base"],function(t){return t.extend({editTemplate:"advanced:report/fields/filters-control/edit",detailTemplate:"advanced:report/fields/filters-control/detail",setup:function(){var t=this.model.get("entityType");this.wait(!0),this.getModelFactory().create(t,function(t){this.seed=t,this.wait(!1)},this),this.setupFiltersData(),this.listenTo(this.model,"change:filters",function(){var t=Espo.Utils.clone(this.filterList),e=[],i=[];this.setupFiltersData();var s=this.filterList;s.forEach(function(i){~t.indexOf(i)||e.push(i)}),t.forEach(function(t){~s.indexOf(t)||i.push(t)}),this.isRendered()&&(e.forEach(function(t){this.createFilter(t)},this),i.forEach(function(t){this.removeFilter(t)},this))},this)},setupFiltersData:function(){this.filterList=Espo.Utils.clone(this.model.get("filters"))||[]},afterRender:function(){this.filterList.forEach(function(t){var e=(this.model.get("filtersData")||{})[t];this.createFilter(t,e)},this)},removeFilter:function(t){this.clearView("name-"+t),this.$el.find(".filters-row .filter-"+Espo.Utils.toDom(t)).remove()},createFilter:function(t,e,i){e=e||{},this.$el.find(".filters-row").append('<div class="filter filter-'+Espo.Utils.toDom(t)+' col-sm-4 col-md-3" />');var s=this.seed.name,a=t;if(~t.indexOf(".")){var n=t.split(".")[0];a=t.split(".")[1],s=this.getMetadata().get("entityDefs."+this.seed.name+".links."+n+".entity")}s&&a&&this.getModelFactory().create(s,function(s){this.createView("filter-"+t,"Search.Filter",{name:a,model:s,params:e,selector:".filter-"+Espo.Utils.toDom(t),notRemovable:!0},function(t){"function"==typeof i&&t.once("after:render",function(){i()}),t.render()})},this)},fetch:function(){var t={};return this.filterList.forEach(function(e){t[e]=this.getView("filter-"+e).getView("field").fetchSearch();var i=t[e].field||e;~e.indexOf(".")&&!~i.indexOf(".")&&(i=e.split(".")[0]+"."+i);t[e].field=i},this),{filtersData:t}}})}),define("advanced:views/report/fields/filters-control-2",["views/fields/base"],function(t){return t.extend({editTemplate:"advanced:report/fields/filters-control-2/edit",detailTemplate:"advanced:report/fields/filters-control-2/detail",setup:function(){var t=this.model.get("entityType"),e=this.model.get("filtersDataList")||[];if(!e.length){var i=this.model.get("filters")||[],s=this.model.get("filtersData")||{};i.forEach(function(t){if(t in s){var i={};i.id=Math.random().toString(16).slice(2),i.name=t,i.params=s[t],e.push(i)}},this)}this.createView("node","advanced:views/report/filters/node",{selector:"> .node-row > .node",scope:t,dataList:e})},afterRender:function(){},fetch:function(){return{filtersDataList:this.getView("node").fetch(),filtersData:null,filters:null}}})}),define("advanced:views/report/fields/entity-type",["views/fields/enum"],function(t){return t.extend({setup:function(){var e=this.getMetadata().get("scopes"),i=this.getMetadata().get("entityDefs.Report.entityListAllowed")||[],s=this.getMetadata().get("entityDefs.Report.entityListToIgnore")||[];this.params.options=Object.keys(e).filter(t=>{if(!~s.indexOf(t)){var a=e[t];return a.entity&&(a.tab||a.object)||~i.indexOf(t)}}).sort((t,e)=>this.translate(t,"scopeNamesPlural").localeCompare(this.translate(e,"scopeNamesPlural"))),this.params.translation="Global.scopeNames",t.prototype.setup.call(this)}})}),define("advanced:views/report/fields/email-sending-weekdays",["views/fields/base"],function(t){return t.extend({editTemplate:"advanced:report/fields/email-sending-weekdays/edit",detailTemplate:"advanced:report/fields/email-sending-weekdays/detail",afterRender:function(){"edit"!==this.mode&&"search"!==this.mode||(this.$element=this.$el.find('input[data-name="'+this.name+'"]'),"edit"===this.mode&&this.$element.on("change",()=>{this.trigger("change")}))},data:function(){var e=this.model.get(this.name)||"",i={};for(let t=0;t<7;t++)i[t]=e.indexOf(t.toString())>-1||!1;return _.extend({selectedWeekdays:i,days:this.translate("dayNamesShort","lists")},t.prototype.data.call(this))},fetch:function(){var t={},e="";return this.$element.each(function(){$(this).is(":checked")&&(e+=$(this).val())}),t[this.name]=e,t}})}),define("advanced:views/report/fields/email-sending-time",["views/fields/base"],function(t){return t.extend({type:"time",editTemplate:"advanced:report/fields/email-sending-time/edit",timeFormatMap:{"HH:mm":"H:i","hh:mm A":"h:i A","hh:mm a":"h:i a"},data:function(){var e=t.prototype.data.call(this),i=moment.utc(this.model.get(this.name),"HH:mm").format(this.getDateTime().timeFormat);return e.time="Invalid date"===i?"":i,e},getValueForDisplay:function(){var t=this.model.get(this.name);return t?t="Invalid date"===(t=moment.utc(this.model.get(this.name),"HH:mm").format(this.getDateTime().timeFormat))?"":t:"edit"===this.mode||"search"===this.mode?"":this.translate("None")},afterRender:function(){var e=this;if(t.prototype.afterRender.call(this),"edit"===this.mode){this.$date=this.$element;var i=this.$time=this.$el.find('input[data-name="'+this.name+'-time"]');i.timepicker({step:30,scrollDefaultNow:!0,timeFormat:this.timeFormatMap[this.getDateTime().timeFormat]}),i.parent().find("button.time-picker-btn").on("click",()=>{i.timepicker("show")}),this.$element.on("change.time",t=>{});var s=!1;i.on("change",()=>{s||e.trigger("change"),s=!0,setTimeout(()=>{s=!1},100)})}},parse:function(t){var e=moment.utc(t,this.getDateTime().timeFormat);return"Invalid date"===e.format("HH:mm")?"":e.format("HH:mm:ss")},fetch:function(){var t={},e=this.$el.find('[data-name="'+this.name+'-time"]').val(),i=null;return""!==e&&(i=this.parse(e)),t[this.name]=i,t},validateRequired:function(){if(this.isRequired()&&!this.model.get(this.name)){var t=this.translate("fieldIsRequired","messages").replace("{field}",this.translate(this.name,"fields",this.model.name));return this.showValidationMessage(t),!0}},isRequired:function(){return this.params.required||this.model.isRequired(this.name)}})}),define("advanced:views/report/fields/email-sending-month",["views/fields/enum"],function(t){return t.extend({setupOptions:function(){this.params.options=this.params.options.filter(t=>t)},setupTranslation:function(){this.translatedOptions={};let t=this.translate("monthNames","lists");for(let e=0;e<t.length;e++)this.translatedOptions[e+1]=t[e]}})}),define("advanced:views/report/fields/email-sending-day",["views/fields/enum"],function(t){return t.extend({setupOptions:function(){this.params.options=this.params.options.filter(t=>t)}})}),define("advanced:views/report/fields/dashlet-select",["views/fields/link"],function(t){return t.extend({createDisabled:!0})}),define("advanced:views/report/fields/columns-list",["views/fields/multi-enum"],function(t){return t.extend({setupOptions:function(){var t=this.model.get("entityType"),e=this.getMetadata().get("entityDefs."+t+".fields")||{},i=[];Object.keys(e).forEach(s=>{e[s].disabled||e[s].utility||"map"!==e[s].type&&(e[s].reportDisabled||e[s].reportColumnDisabled||e[s].directAccessDisabled&&!e[s].listColumnEnabled||this.getFieldManager().isEntityTypeFieldAvailable(t,s)&&i.push(s))});var s=this.getConfig().get("version")||"",a=s.split("."),n=!1;"dev"!==s&&a.length>2&&100*parseInt(a[0])+10*parseInt(a[1])+parseInt(a[2])<562&&(n=!0);var o=this.getMetadata().get("entityDefs."+t+".links")||{},r=Object.keys(o);r.sort((e,i)=>this.translate(e,"links",t).localeCompare(this.translate(i,"links",t))),r.forEach(t=>{if("belongsTo"===o[t].type){var e=o[t].entity;if(e&&!o[t].disabled&&!o[t].utility){var s=this.getMetadata().get("entityDefs."+e+".fields")||{},a=Object.keys(s);a.sort((t,i)=>this.translate(t,"fields",e).localeCompare(this.translate(i,"fields",e))),a.forEach(a=>{if(!(s[a].disabled||s[a].utility||s[a].reportDisabled||s[a].reportColumnDisabled||s[a].directAccessDisabled)){var o=s[a].type;this.getFieldManager().isEntityTypeFieldAvailable&&!this.getFieldManager().isEntityTypeFieldAvailable(e,a)||~["linkMultiple","linkParent","currency","personName","map","address","foreign"].indexOf(o)||(!n||"phone"!==o&&"email"!==o)&&i.push(t+"."+a)}})}}}),this.params.options=i},setupTranslatedOptions:function(){this.translatedOptions={};const t=this.model.get("entityType");this.params.options.forEach(e=>{let i=e,s=t,a=!1;const n=e;let o=null;~n.indexOf(".")&&(a=!0,o=n.split(".")[0],i=n.split(".")[1],s=this.getMetadata().get(`entityDefs.${t}.links.${o}.entity`)),this.translatedOptions[e]=this.translate(i,"fields",s),a&&(this.translatedOptions[e]=this.translate(o,"links",t)+" . "+this.translatedOptions[e])})},setup:function(){t.prototype.setup.call(this),this.setupOptions(),this.setupTranslatedOptions()}})}),define("advanced:views/report/fields/columns-control",["views/fields/base","model"],function(t,e){return t.extend({editTemplate:"advanced:report/fields/filters-control/edit",detailTemplate:"advanced:report/fields/filters-control/detail",fieldDataList:[{name:"width",view:"views/fields/float"},{name:"align",view:"views/fields/enum",params:{options:["left","right"],translation:"Report.options.layoutAlign"}},{name:"link",view:"views/fields/bool"},{name:"exportOnly",view:"views/fields/bool"},{name:"notSortable",view:"views/fields/bool"},{name:"hidden",view:"views/fields/bool"}],setup:function(){this.entityType=this.model.get("entityType"),this.seed=new e,this.seed.name="LayoutManager",this.setupColumnsData(),this.listenTo(this.model,"change:columns",()=>{const t=Espo.Utils.clone(this.columnList),e=[],i=[];this.setupColumnsData();const s=this.columnList;s.forEach(i=>{~t.indexOf(i)||e.push(i)}),t.forEach(t=>{~s.indexOf(t)||i.push(t)}),this.isRendered()&&(e.forEach(t=>{this.createColumn(t)}),i.forEach(t=>{this.removeColumn(t)}))})},setupColumnsData:function(){this.columnList=Espo.Utils.clone(this.model.get("columns"))||[]},afterRender:function(){this.columnList.forEach(t=>{const e=(this.model.get("columnsData")||{})[t];this.createColumn(t,e)})},removeColumn:function(t){this.clearView(`name-${t}`),this.$el.find(`.filters-row > .column[data-name="${t}"]`).remove(),this.fieldDataList.forEach(e=>{this.clearView(`field-${t}-${e.name}`)})},createColumn:function(t){let e;if(~t.indexOf(".")){const i=t.split(".")[0],s=t.split(".")[1],a=this.getMetadata().get(`entityDefs.${this.entityType}.links.${i}.entity`);e=this.translate(i,"links",this.entityType)+" . "+this.translate(s,"fields",a)}else e=this.translate(t,"fields",this.entityType);const i=this.$el.find(".filters-row"),s=document.createElement("div");s.classList.add("column"),s.setAttribute("data-name",t);const a=document.createElement("div");a.classList.add("column-label","text-soft","margin-bottom-sm"),a.textContent=e;const n=document.createElement("div");n.classList.add("column-content","margin-bottom");const o=document.createElement("div");o.append(a,n),s.append(o),i.append(s);const r=i.find(`> .column[data-name="${t}"]`).find(".column-content"),l=this.seed.clone();l.name="LayoutManager";const d={};"name"===t&&(d.link=!0);const c=(this.model.get("columnsData")||{})[t]||d;l.set(c),this.fieldDataList.forEach(e=>{const i='<div class="column-field" data-name="'+e.name+'"><label class="control-label small">'+this.getHelper().escapeString(this.translate(e.name,"layoutFields","Report"))+'</label><div class="field-content"></div></div>',s=$(i);r.append(s),this.createView(`field-${t}-${e.name}`,e.view,{model:l,name:e.name,defs:{name:e.name,params:e.params||{}},selector:`.column[data-name="${t}"] .column-content .column-field[data-name="${e.name}"] .field-content`,mode:"edit"},t=>{t.render()})})},fetch:function(){const t={};return this.columnList.forEach(e=>{let i={};this.fieldDataList.forEach(t=>{const s=this.getView(`field-${e}-${t.name}`);s&&(i=_.extend(i,s.fetch()))}),t[e]=i}),{columnsData:t}}})}),define("advanced:views/report/fields/chart-columns",["advanced:views/report/fields/columns"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.params.options=Espo.Utils.clone(this.model.get("columns")||[])}})}),define("advanced:views/report/fields/chart-color-list",["views/fields/array","advanced:report-helper"],function(t,e){return t.extend({maxItemLength:500,getAttributeList:function(){return[...t.prototype.getAttributeList.call(this),"columnsData"]},setup:function(){t.prototype.setup.call(this),this.wait(Espo.loader.requirePromise("lib!bootstrap-colorpicker")),this.reportHelper=new e(this.getMetadata(),this.getLanguage(),this.getDateTime(),this.getConfig(),this.getPreferences()),this.translatedOptions=Espo.Utils.clone(this.model.get("chartColors")||{}),this.on("change",this.initColorpicker),this.listenTo(this.model,"change",(t,e)=>{e.ui&&(t.hasChanged("groupBy")||t.hasChanged("columns")||t.hasChanged("chartType")||t.hasChanged("columnsData"))&&this.populateItems()}),this.events["change input.role"]=t=>{const e=$(t.currentTarget);e.closest(".list-group-item").find(".colored-label").css("color",e.val())}},isByColumn:function(){return["Line","BarHorizontal","BarVertical","Radar"].includes(this.model.get("chartType"))},getItemHtml:function(t){let e=t in this.translatedOptions?this.translatedOptions[t]:"#9395FA";const i=this.model.get("chartType");let s=t;if(this.isByColumn())s=this.reportHelper.translateGroupName(t,this.model.get("entityType"),this.model);else{let e=this.getGroupFieldData("Pie"===i),a=e.entityType,n=e.field;"enum"===e.fieldType&&(s=this.getLanguage().translateOption(t,n,a))}let a=this.getHelper().escapeString(t),n=this.getHelper().escapeString(e);return s=this.getHelper().escapeString(s),`\n                <div class="list-group-item link-with-role form-inline" data-value="${a}">\n                    <div class="pull-left" style="width: 92%; display: inline-block;">\n                        <input\n                            data-name="translatedValue" data-value="${a}"\n                            class="role form-control input-sm pull-right"\n                            value="${n}" style="width: 80px"\n                        ><div\n                            class="colored-label"\n                            style="color: ${n}">${s}</div>\n                        </div>\n                        <div style="width: 8%; display: inline-block; vertical-align: top;"\n                        ><a\n                            role="button"\n                            tabindex="0"\n                            class="pull-right"\n                            data-value="${a}"\n                            data-action="removeValue"\n                        ><span class="fas fa-times"></a>\n                    </div><br style="clear: both;" />\n                </div>`},fetch:function(){let e=t.prototype.fetch.call(this);return e.chartColors={},(e[this.name]||[]).forEach(t=>{e.chartColors[t]=this.$el.find('input[data-name="translatedValue"][data-value="'+t+'"]').val()||t}),e},afterRender:function(){t.prototype.afterRender.call(this),this.isEditMode()&&(this.initColorpicker(),this.isByColumn()&&(this.$el.find('[data-action="removeValue"]').remove(),this.$el.find('[data-action="addItem"]').attr("disabled","disabled").addClass("disabled"),this.$el.find("input.main-element").attr("disabled","disabled")))},initColorpicker:function(){this.$el.find("input.role").each((t,e)=>{$(e).hasClass("colorpicker-element")||$(e).colorpicker({format:"hex"})})},getGroupFieldData:function(t){let e=this.model.get("groupBy")||[];if(!t&&e.length<2)return;if(t&&e.length<1)return;let i=1;t&&(i=0);let s=e[i],a=s,n=this.model.get("entityType");if(~s.indexOf(":")&&(a=s.split(":")[1]),~s.indexOf(".")){let t=a.split(".");a=t[1];let e=t[0];if(n=this.getMetadata().get(["entityDefs",n,"links",e,"entity"]),!n)return}return{entityType:n,field:a,fieldType:this.getMetadata().get(["entityDefs",n,"fields",a,"type"])}},populateItems:function(){let t=[],e={},i=this.model.get("chartType"),s=!1;if((this.model.get("groupBy")||[]).length<=1&&~["Line","BarHorizontal","BarVertical","Radar"].indexOf(i)&&(t=Espo.Utils.clone(this.model.get("columns")||[]).filter(t=>this.reportHelper.isColumnNumeric(t,this.model)),1===t.length&&i&&(t=[]),s=!0),!s){let e=this.getGroupFieldData("Pie"===i);if(e){let i=e.entityType,s=e.fieldType,a=e.field;if(~["enum","varchar"].indexOf(s)){let e=Espo.Utils.clone(this.getMetadata().get(["entityDefs",i,"fields",a,"options"])||[]);e.length&&e.length<=8&&(t=e)}}}if(t.length<=8){let i=this.getThemeManager().getParam("chartColorList")||[];t.length<=5&&(i=this.getThemeManager().getParam("chartColorAlternativeList")||[]),t.forEach((t,s)=>{s>i.length-1||(e[t]=i[s])})}this.translatedOptions=e,this.model.set({chartColorList:t,chartColors:e},{ui:!0}),this.reRender()}})}),define("advanced:views/report/fields/columns/item",["view","model"],function(t,e){return t.extend({templateContent:'\n            <div class="row">\n                <div class="cell form-group col-md-10">\n                    <label class="control-label">#{{number}}</label>\n                    <div class="field" data-name="expression">{{{expression}}}</div>\n                </div>\n\n            </div>\n            <div class="row">\n                <div class="cell form-group col-md-3">\n                    <label class="control-label">{{translate \'Label\' scope=\'Report\'}}</label>\n                    <div class="field" data-name="label">{{{label}}}</div>\n                </div>\n                <div class="cell form-group col-md-3">\n                    <label class="control-label">{{translate \'Type\' scope=\'Report\'}}</label>\n                    <div class="field" data-name="type">{{{type}}}</div>\n                </div>\n                <div class="cell form-group col-md-3">\n                    <label class="control-label">{{translate \'Decimal Places\' scope=\'Report\'}}</label>\n                    <div class="field" data-name="decimalPlaces">{{{decimalPlaces}}}</div>\n                </div>\n            </div>\n        ',data:function(){return{number:this.options.number}},setup:function(){const t=this.options.entityType,i=this.options.onChange,s=new e;s.set({expression:this.options.expression||null,label:this.options.label||null,type:this.options.type||null,decimalPlaces:this.options.decimalPlaces}),this.listenTo(s,"change",()=>{let t=s.attributes.expression;null!==t&&(t=t.trim()),i(t,s.attributes.label,s.attributes.type,s.attributes.decimalPlaces)}),this.createView("expression","views/fields/complex-expression",{model:s,name:"expression",selector:' [data-name="expression"]',mode:"edit",height:50,targetEntityType:t,smallFont:!0}),this.createView("label","views/fields/varchar",{model:s,name:"label",selector:' [data-name="label"]',mode:"edit",maxLength:64}),this.createView("type","views/fields/enum",{model:s,name:"type",selector:' [data-name="type"]',mode:"edit",params:{options:["","Summary"],translation:"Report.options.columnType"}}),this.createView("decimalPlaces","views/fields/int",{model:s,name:"decimalPlaces",selector:' [data-name="decimalPlaces"]',mode:"edit",params:{min:0,max:8},labelText:this.translate("Decimal Places","labels","Report")})},validate:function(){const t=this.getView("expression"),e=this.getView("decimalPlaces");return t.validate()||e.validate()}})}),define("modules/advanced/views/record/list-for-report",["exports","views/record/list"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};class s extends e.default{forcedCheckAllResultMassActionList=["export"];checkAllResultMassActionList=["export"];setup(){super.setup(),this.options.isPreview&&this.removeMassAction("export")}export(t,e,i){const s={};let a=null;this.options.listLayout&&(a=[],this.options.listLayout.forEach(t=>{a.push(t.name)})),this.allResultIsChecked||(s.ids=this.checkedList),s.id=this.options.reportId,"runtimeWhere"in this.options&&(s.where=this.options.runtimeWhere),"groupValue"in this.options&&(s.groupValue=this.options.groupValue),"groupIndex"in this.options&&(s.groupIndex=this.options.groupIndex),void 0!==this.options.groupValue2&&(s.groupValue2=this.options.groupValue2),void 0!==this.options.subReportTarget&&(s.subReportTarget=this.options.subReportTarget),s.orderBy=this.collection.orderBy,s.order=this.collection.order;super.export(s,"Report/action/exportList",a)}}t.default=s}),define("advanced:views/fields/foreign-link",["views/fields/link"],function(t){return t.extend({setup:function(){const e=this.name.split("_"),i=e[0],s=e[1],a=this.getMetadata().get(["entityDefs",this.model.entityType,"links",i,"entity"]);this.foreignScope=this.getMetadata().get(["entityDefs",a,"links",s,"entity"]),t.prototype.setup.call(this)}})}),define("advanced:views/fields/foreign-enum",["views/fields/enum"],function(t){return t.extend({getValueForDisplay:function(){const t=this.name.split("_"),e=t[0],i=t[1],s=this.getMetadata().get(`entityDefs.${this.model.entityType}.links.${e}.entity`);return this.getLanguage().translateOption(this.model.get(this.name),i,s)}})}),define("advanced:views/fields/email-address-for-send-email",["views/fields/email-address"],function(t){return class extends t{validateEmailAddress(){const t=this.model.get(this.name);return!!t&&(!/\{\$\$.*?}/.test(t)&&super.validateEmailAddress())}}}),define("advanced:views/dashlets/bpmn-user-tasks",["views/dashlets/abstract/record-list"],function(t){return t.extend({setupActionList:function(){}})}),define("modules/advanced/views/dashlets/options/report",["exports","views/dashlets/options/base","modules/advanced/views/report/fields/columns","modules/advanced/report-helper","modules/advanced/views/report/runtime-filters","di","modules/advanced/helpers/report/column-helper"],function(t,e,i,s,a,n,o){"use strict";let r,l;function d(t){return t&&t.__esModule?t:{default:t}}function c(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function h(t,e,i){"symbol"==typeof e&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch(t){}return t}function u(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(null!==t?typeof t:"null"));return t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=d(e),i=d(i),s=d(s),a=d(a),o=d(o);class p extends e.default{static#t=[r,l]=function(t,e,i,s,a,n){var o,r,l,d,p,f,m,g=Symbol.metadata||Symbol.for("Symbol.metadata"),y=Object.defineProperty,w=Object.create,v=[w(null),w(null)],b=e.length;function T(e,i,s){return function(a,n){i&&(n=a,a=t);for(var o=0;o<e.length;o++)n=e[o].apply(a,s?[n]:[]);return s?n:a}}function D(t,e,i,s){if("function"!=typeof t&&(s||void 0!==t))throw new TypeError(e+" must "+(i||"be")+" a function"+(s?"":" or undefined"));return t}function k(t,e,i,s,a,n,l,d,c,u,p){function f(t){if(!p(t))throw new TypeError("Attempted to access private element on non-instance")}var m=[].concat(e[0]),g=e[3],w=!l,b=1===a,k=3===a,E=4===a,C=2===a;function x(e,i,s){return function(a,n){return i&&(n=a,a=t),s&&s(a),O[e].call(a,n)}}if(!w){var O={},L=[],M=k?"get":E||b?"set":"value";if(c?(u||b?O={get:h(function(){return g(this)},s,"get"),set:function(t){e[4](this,t)}}:O[M]=g,u||h(O[M],s,C?"":M)):u||(O=Object.getOwnPropertyDescriptor(t,s)),!u&&!c){if((r=v[+d][s])&&7!=(r^a))throw Error("Decorating two elements with the same name ("+O[M].name+") is not supported yet");v[+d][s]=a<3?1:a}}for(var F=t,S=m.length-1;S>=0;S-=i?2:1){var V=D(m[S],"A decorator","be",!0),R=i?m[S-1]:void 0,$={},I={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:o,addInitializer:function(t,e){if(t.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(e,"An initializer","be",!0),n.push(e)}.bind(null,$)};if(w)r=V.call(R,F,I),$.v=1,D(r,"class decorators","return")&&(F=r);else if(I.static=d,I.private=c,r=I.access={has:c?p.bind():function(t){return s in t}},E||(r.get=c?C?function(t){return f(t),O.value}:x("get",0,f):function(t){return t[s]}),C||k||(r.set=c?x("set",0,f):function(t,e){t[s]=e}),F=V.call(R,b?{get:O.get,set:O.set}:O[M],I),$.v=1,b){if("object"==typeof F&&F)(r=D(F.get,"accessor.get"))&&(O.get=r),(r=D(F.set,"accessor.set"))&&(O.set=r),(r=D(F.init,"accessor.init"))&&L.unshift(r);else if(void 0!==F)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(F,(u?"field":"method")+" decorators","return")&&(u?L.unshift(F):O[M]=F)}return a<2&&l.push(T(L,d,1),T(n,d,0)),u||w||(c?b?l.splice(-1,0,x("get",d),x("set",d)):l.push(C?O[M]:D.call.bind(O[M])):y(t,s,O)),F}function E(t){return y(t,g,{configurable:!0,enumerable:!0,value:o})}return void 0!==n&&(o=n[g]),o=w(null==o?null:o),p=[],f=function(t){t&&p.push(T(t))},(m=function(e,s){for(var n=0;n<i.length;n++){var o=i[n],r=o[1],h=7&r;if((8&r)==e&&!h==s){var f=o[2],m=!!o[3],g=16&r;k(e?t:t.prototype,o,g,m?"#"+f:c(f),h,h<2?[]:e?d=d||[]:l=l||[],p,!!e,m,s,e&&m?function(e){return u(e)===t}:a)}}})(8,0),m(0,0),m(8,1),m(0,1),f(l),f(d),r=p,b||E(t),{e:r,get c(){var i=[];return b&&[E(t=k(t,[e],s,t.name,5,i)),T(i,1)]}}}(this,[],[[(0,n.inject)(o.default),0,"columnHelper"]],0,void 0,e.default).e;constructor(){super(...arguments),l(this)}template="advanced:dashlets/options/report";runtimeFiltersView;columnHelper=r(this);setup(){!this.optionsData.displayType&&this.optionsData.type&&this.setCorrespondingDisplayType(),super.setup(),this.reportData={entityType:this.optionsData.entityType||null,type:this.optionsData.type||null,runtimeFilters:this.optionsData.runtimeFilters||null,columns:this.optionsData.columns||null,depth:this.optionsData.depth||0,columnsData:this.optionsData.columnsData||{},internalClassName:this.optionsData.internalClassName??null},this.reportHelper=new s.default(this.getMetadata(),this.getLanguage(),this.getDateTime(),this.getConfig(),this.getPreferences()),this.listenTo(this.model,"change:reportName",t=>{setTimeout(()=>{t.set("title",t.get("reportName"))},100)}),this.controlUseSiMultiplierField(),this.listenTo(this.model,"change:displayTotal",()=>{this.controlUseSiMultiplierField()}),this.listenTo(this.model,"change:displayOnlyCount",()=>{this.controlUseSiMultiplierField()}),this.listenTo(this.model,"change:reportId",t=>{this.reportData={},this.removeRuntimeFilters(),this.hideColumnsField(),this.hideField("useSiMultiplier");const e=t.get("reportId");e?this.getModelFactory().create("Report",t=>{t.id=e,t.fetch().then(()=>{const e=(t.get("columns")||[]).filter(e=>this.reportHelper.isColumnNumeric(e,t)),i=t.get("type"),s={entityType:t.get("entityType"),type:t.get("type"),runtimeFilters:t.get("runtimeFilters"),columns:e,columnsData:t.get("columnsData")||{},internalClassName:t.attributes.internalClassName};"Grid"!==i&&"JointGrid"!==i||!t.get("groupBy")?s.depth=null:s.depth=t.get("groupBy").length,this.model.set("depth",s.depth),this.model.set("entityType",t.get("entityType")),"Grid"!==i&&"JointGrid"!==i||this.model.set("column",e[0]||null);let a="";"List"===s.type?a="List":"Grid"!==s.type&&"JointGrid"!==s.type||(a="Chart"),this.model.set("displayType",a),this.model.set("type",s.type),this.reportData=s,this.hasRuntimeFilters()&&this.createRuntimeFilters(),this.controlRuntimeFiltersPanel(),this.handleColumnField(),this.controlUseSiMultiplierField()})}):this.controlRuntimeFiltersPanel()})}setCorrespondingDisplayType(){const t=this.optionsData.type,e=this.optionsData.displayTotal;this.optionsData.displayOnlyCount?this.optionsData.displayType="Total":!e||"Grid"!==t&&"JointGrid"!==t?"List"!==t?"Grid"!==t&&"JointGrid"!==t||(this.optionsData.displayType="Chart"):this.optionsData.displayType="List":this.optionsData.displayType="Chart-Total"}controlUseSiMultiplierField(){this.model.get("displayOnlyCount")||this.model.get("displayTotal")?this.showField("useSiMultiplier"):this.hideField("useSiMultiplier")}handleColumnField(){const t=this.getRecordView();if(this.hideField("displayOnlyCount"),this.reportData.type&&(this.showField("displayOnlyCount"),"Grid"===this.reportData.type&&this.showField("displayTotal"),"JointGrid"===this.reportData.type&&this.showField("displayTotal"),"List"===this.reportData.type&&this.hideField("displayTotal")),!t)return;const e=t.getFieldView("column");"Grid"===this.reportData.type?(e.params.options=Espo.Utils.clone(this.reportData.columns||[]),e.translatedOptions={},i.default.prototype.setupTranslatedOptions.call(e),(0===this.reportData.depth||1===this.reportData.depth)&&e.params.options.length>1&&(e.params.options.unshift(""),e.translatedOptions[""]=this.translate("All")),e.params.options.forEach(t=>{const i=(this.reportData.columnsData[t]??{}).label;if(i)return void(e.translatedOptions[t]=i);if(!this.reportData.internalClassName)return;const s=this.columnHelper.translateInternalReportColumn(this.reportData.internalClassName,t);s&&(e.translatedOptions[t]=s)}),this.$el.find(".cell-column").removeClass("hidden"),"showField"in t&&t.showField("column")):(e.params.options=[],this.hideColumnsField()),e.render()}hideColumnsField(){this.$el.find(".cell-column").addClass("hidden");const t=this.getRecordView();"hideField"in t&&t.hideField("column")}afterRender(){this.handleColumnField(),this.hasRuntimeFilters()&&this.createRuntimeFilters(),this.controlRuntimeFiltersPanel()}controlRuntimeFiltersPanel(){const t=this.$el.find(".runtime-filters-panel");this.hasRuntimeFilters()?t.removeClass("hidden"):t.addClass("hidden")}hasRuntimeFilters(){return 0!==(this.reportData.runtimeFilters||[]).length}removeRuntimeFilters(){this.clearView("runtimeFilters"),this.runtimeFiltersView=null}async createRuntimeFilters(){const t=new a.default({entityType:this.reportData.entityType,filterList:this.reportData.runtimeFilters,filtersData:this.optionsData.filtersData||null,internalClassName:this.reportData.internalClassName});await this.assignView("runtimeFilters",t,".runtime-filters-container"),await t.render(),this.runtimeFiltersView=t}fetchAttributes(){if(this.getRecordView().getFieldView("report").validate())return;const t=super.fetchAttributes()||{};return this.hasRuntimeFilters()&&this.runtimeFiltersView&&(t.filtersData=this.runtimeFiltersView.fetchRaw()),t.entityType=this.reportData.entityType,t.runtimeFilters=this.reportData.runtimeFilters,t.type=this.reportData.type,t.columns=this.reportData.columns,t.depth=this.reportData.depth,t.columnsData=this.reportData.columnsData,t.internalClassName=this.reportData.internalClassName,t}}t.default=p}),define("advanced:views/dashlets/fields/display-type","views/fields/enum",function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.reportTypeField="type",this.displayOnlyTotalField="displayOnlyCount","ReportPanel"===this.model.entityType&&(this.reportTypeField="reportType",this.displayOnlyTotalField="displayOnlyTotal"),this.controlOptions(),this.listenTo(this.model,"change:"+this.reportTypeField,function(){if(this.controlOptions(),"ReportPanel"===this.model.entityType&&this.model.isNew()){var t=this.model.get("reportType"),e="";"Grid"===t||"JointGrid"===t?e="Chart":"List"===t&&(e="List"),this.model.set("displayType",e)}},this)},fetch:function(){var e=t.prototype.fetch.call(this),i=e[this.name];return"List"===i&&(e.displayTotal=!1,e[this.displayOnlyTotalField]=!1),"Chart"===i&&(e.displayTotal=!1,e[this.displayOnlyTotalField]=!1),"Chart-Total"===i&&(e.displayTotal=!0,e[this.displayOnlyTotalField]=!1),"Total"===i&&(e.displayTotal=!0,e[this.displayOnlyTotalField]=!0),e},controlOptions:function(){var t=this.model.get(this.reportTypeField);"List"!==t?"Grid"!==t&&"JointGrid"!==t?this.setOptionList([""]):this.setOptionList(["Chart","Chart-Total","Total","Table"]):this.setOptionList(["List","Total"])}})}),define("advanced:views/bpmn-user-task/detail",["views/detail"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.model.get("resolution")||this.getAcl().checkModel(this.model,"edit")&&(this.addMenuItem("buttons",{label:"Resolve",action:"showResolveModal",acl:"edit"}),this.listenTo(this.model,"sync",()=>{this.model.get("resolution")&&this.removeMenuItem("showResolveModal")}),this.listenTo(this.model,"change:resolution",()=>{this.model.get("resolution")?this.disableMenuItem("showResolveModal"):this.enableMenuItem("showResolveModal")}))},actionShowResolveModal:function(){this.createView("modal","advanced:views/bpmn-user-task/modals/resolve",{model:this.model},t=>{t.render()})}})}),define("advanced:views/bpmn-user-task/record/detail",["views/record/detail"],function(t){return t.extend({duplicateAction:!1})}),define("modules/advanced/views/bpmn-user-task/modals/resolve",["exports","views/modal","views/record/edit-for-modal"],function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=s(e),i=s(i);class a extends e.default{templateContent='\n        <div class="record no-side-margin">{{{record}}}</div>\n    ';backdrop=!0;originalModel;setup(){this.headerHtml=this.translate("BpmnUserTask","scopeNames")+' <span class="chevron-right"></span> '+this.getHelper().escapeString(this.model.get("name")),this.originalModel=this.model,this.model=this.model.clone(),this.buttonList=[{name:"resolve",text:this.translate("Resolve","labels","BpmnUserTask"),style:"danger",disabled:!0,onClick:()=>this.actionResolve()},{name:"cancel",label:"Cancel"}];const t=this.getMetadata().get(`logicDefs.${this.model.entityType}`)??this.getMetadata().get(`clientDefs.${this.model.entityType}.dynamicLogic`)??{};console.log(t),this.recordView=new i.default({model:this.model,dynamicLogicDefs:t,detailLayout:[{rows:[[{name:"resolution",view:"views/fields/enum"},!1],[{name:"resolutionNote",view:"views/fields/text"}]]}]}),this.assignView("record",this.recordView,".record"),this.listenTo(this.model,"change:resolution",(t,e)=>{e?this.enableButton("resolve"):this.disableButton("resolve")})}actionResolve(){this.disableButton("resolve"),this.model.save().then(()=>{this.originalModel.set("resolution",this.model.get("resolution")),this.originalModel.set("resolutionNote",this.model.get("resolutionNote")),this.originalModel.set("isResolved",!0),this.originalModel.trigger("sync"),Espo.Ui.success(this.translate("Done")),this.close()})}}t.default=a}),define("advanced:views/bpmn-user-task/fields/target",["views/fields/link-parent"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this);var e=this.getMetadata().get("scopes"),i=this.getMetadata().get("entityDefs.Workflow.entityListToIgnore")||[];this.foreignScopeList=Object.keys(e).filter(t=>{if(!~i.indexOf(t)){var s=e[t];return s.entity&&(s.tab||s.object||s.workflow)}}).sort((t,e)=>this.translate(t,"scopeNamesPlural").localeCompare(this.translate(e,"scopeNamesPlural")))}})}),define("advanced:views/bpmn-process/record/list",["views/record/list"],function(t){return t.extend({massActionList:["remove","massUpdate"]})}),define("advanced:views/bpmn-process/record/edit-quick",["views/record/edit-small","advanced:views/bpmn-process/record/edit"],function(t,e){return t.extend({setup:function(){t.prototype.setup.call(this),e.prototype.setupFlowchartDependency.call(this)}})}),define("advanced:views/bpmn-process/record/detail",["views/record/detail"],function(t){return t.extend({duplicateAction:!1,setup:function(){t.prototype.setup.call(this),this.hideField("startElementId"),this.getAcl().checkModel(this.model,"edit")&&(this.dropdownItemList.push({label:"Stop Process",name:"stopProcess",hidden:!this.isStoppable()}),this.dropdownItemList.push({label:"Reactivate",name:"reactivate",hidden:!this.isReactivatable()}),this.listenTo(this.model,"sync",()=>this.controlActions())),this.dropdownItemList.push({label:"View Variables",name:"viewVariables"})},controlActions:function(){this.isStoppable()?this.showActionItem("stopProcess"):this.hideActionItem("stopProcess"),this.isReactivatable()?this.showActionItem("reactivate"):this.hideActionItem("reactivate")},isReactivatable:function(){return["Ended","Stopped","Interrupted"].includes(this.model.get("status"))},isStoppable:function(){return["Started","Paused"].includes(this.model.get("status"))},actionStopProcess:function(){this.isStoppable()?this.confirm(this.translate("confirmation","messages"),()=>{Espo.Ajax.postRequest("BpmnProcess/action/stop",{id:this.model.id}).then(()=>{this.model.set("status","Stopped"),Espo.Ui.success(this.translate("Done","labels")),this.hideActionItem("stopProcess"),this.model.trigger("after:relate"),this.model.fetch()})}):console.error("Cannot stop. Not appropriate status.")},actionReactivate:function(){this.isReactivatable()?this.confirm(this.translate("confirmation","messages"),()=>{Espo.Ajax.postRequest("BpmnProcess/action/reactivate",{id:this.model.id}).then(()=>{Espo.Ui.success(this.translate("Done","labels")),this.model.trigger("after:relate"),this.model.fetch()})}):console.error("Cannot reactivate. Not appropriate status.")},actionViewVariables:function(){this.createView("dialog","advanced:views/bpmn-process/modals/view-variables",{model:this.model}).then(t=>{t.render()})}})}),define("advanced:views/bpmn-process/record/detail-quick",["views/record/detail-small"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.hideField("startElementId")}})}),define("advanced:views/bpmn-process/record/panels/flow-nodes",["views/record/panels/relationship"],function(t){return t.extend({fetchOnModelAfterRelate:!0})}),define("advanced:views/bpmn-process/modals/view-variables",["views/modal"],function(t){return t.extend({templateContent:'<div class="record no-side-margin">{{{record}}}</div>',className:"dialog dialog-record",backdrop:!0,setup:function(){this.headerText=this.translate("variables","fields","BpmnProcess"),this.createView("record","views/record/detail",{readOnly:!0,isWide:!0,bottomView:null,sideView:null,buttonsDisabled:!0,scope:this.model.entityType,model:this.model,selector:".record",detailLayout:[{rows:[[{name:"variables",noLabel:!0}]]}]})}})}),define("advanced:views/bpmn-process/fields/variables",["views/fields/text"],function(t){return t.extend({detailTemplateContent:'\n            {{#if isSet}}\n            <div class="complex-text">\n                <pre><code>{{value}}</code></pre>\n            </div>            \n            {{else}}\n            <span class="loading-value">...</span>\n            {{/if}}\n        ',data:function(){if(!this.model.has(this.name))return{};let t=this.model.get(this.name);return{isSet:!0,value:JSON.stringify(t,null,4)}}})}),define("advanced:views/bpmn-process/fields/target",["views/fields/link-parent"],function(t){return t.extend({setup:function(){if(this.params.entityList=["BpmnProcess"],t.prototype.setup.call(this),this.model.isNew()&&"search"!==this.mode)this.setupForeignScope(),this.listenTo(this.model,"change:targetType",()=>{this.setupForeignScope(),this.reRender()});else{var e=this.getMetadata().get("scopes"),i=this.getMetadata().get("entityDefs.Workflow.entityListToIgnore")||[];this.foreignScopeList=Object.keys(e).filter(t=>{if(!~i.indexOf(t)){var s=e[t];return s.entity&&(s.tab||s.object||s.workflow)}}).sort((t,e)=>this.translate(t,"scopeNamesPlural").localeCompare(this.translate(e,"scopeNamesPlural")))}},setupForeignScope:function(){this.model.get("targetType")?this.foreignScopeList=[this.model.get("targetType")]:this.foreignScopeList=["BpmnProcess"]}})}),define("advanced:views/bpmn-process/fields/target-type",["advanced:views/bpmn-flowchart/fields/entity-type"],function(t){return t.extend({readOnly:!0})}),define("advanced:views/bpmn-process/fields/start-element-id",["views/fields/enum"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.model.has("startElementIdList")&&this.controlElementIdList(),this.listenTo(this.model,"change:startElementIdList",()=>{this.controlElementIdList()})},controlElementIdList:function(){const t=this.model.get("flowchartElementsDataHash")||{},e=this.model.get("startElementIdList")||[];this.translatedOptions={},e.forEach(e=>{if(!(e in t))return;this.translatedOptions[e]=t[e].text||e;let i=t[e].text||e;i=this.translate(t[e].type,"elements","BpmnFlowchart")+" · "+i,this.translatedOptions[e]=i})}})}),define("advanced:views/bpmn-process/fields/flowchart","views/fields/link",function(t){return t.extend({selectPrimaryFilterName:"isManuallyStartable",createDisabled:!0,select:function(e){this.model.set("targetType",e.get("targetType"),{ui:!0}),this.model.set("flowchartElementsDataHash",e.get("elementsDataHash")),this.model.set("startElementIdList",e.get("eventStartAllIdList")),t.prototype.select.call(this,e)}})}),define("advanced:views/bpmn-process/fields/flowchart-visualization",["advanced:views/bpmn-flowchart/fields/flowchart"],function(t){return t.extend({dataAttribute:"flowchartData"})}),define("advanced:views/bpmn-flowchart-element/record/task-user-edit",["advanced:views/bpmn-flowchart-element/record/edit","advanced:views/bpmn-flowchart-element/record/task-user-detail"],function(t,e){return t.extend({setup:function(){t.prototype.setup.call(this),e.prototype.controlFieldsVisibility.call(this),this.listenTo(this.model,"change",()=>{this.model.hasChanged("assignmentType")&&e.prototype.controlFieldsVisibility.call(this)})}})}),define("advanced:views/bpmn-flowchart-element/record/task-send-message-edit",["advanced:views/bpmn-flowchart-element/record/edit","advanced:views/bpmn-flowchart-element/record/task-send-message-detail"],function(t,e){return t.extend({setup:function(){t.prototype.setup.call(this),e.prototype.controlFieldsVisibility.call(this),this.listenTo(this.model,"change",()=>{(this.model.hasChanged("from")||this.model.hasChanged("to")||this.model.hasChanged("replyTo")||this.model.hasChanged("cc"))&&e.prototype.controlFieldsVisibility.call(this)})}})}),define("advanced:views/bpmn-flowchart-element/record/sub-process-edit",["advanced:views/bpmn-flowchart-element/record/edit","advanced:bpmn-element-helper"],function(t,e){return t.extend({setup:function(){t.prototype.setup.call(this),this.hideField("targetType"),this.hideField("flowchartVisualization"),this.hidePanel("flowchartVisualization"),this.controlTargetTypeField(),this.bpmnHelper=new e(this.getHelper(),this.model)},controlTargetTypeField:function(){0===(this.model.get("dataList")||[]).length?this.setFieldNotReadOnly("target"):this.setFieldReadOnly("target")}})}),define("advanced:views/bpmn-flowchart-element/record/sub-process-detail",["advanced:views/bpmn-flowchart-element/record/detail"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this)}})}),define("advanced:views/bpmn-flowchart-element/record/gateway-exclusive-edit",["advanced:views/bpmn-flowchart-element/record/edit","advanced:views/bpmn-flowchart-element/record/gateway-exclusive-detail"],function(t,e){return t.extend({setup:function(){t.prototype.setup.call(this),e.prototype.isDivergent.call(this)?this.showPanel("divergent"):(this.hideField("flowsConditions"),this.hidePanel("flowsConditions"),this.hideField("defaultFlowId"),this.hidePanel("divergent"))}})}),define("advanced:views/bpmn-flowchart-element/record/event-start-timer-edit",["advanced:views/bpmn-flowchart-element/record/event-start-edit"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.model.isInSubProcess?(this.showField("timer"),this.hideField("targetReport"),this.hideField("scheduling")):(this.hideField("timer"),this.showField("targetReport"),this.showField("scheduling"))}})}),define("advanced:views/bpmn-flowchart-element/record/event-start-timer-detail",["advanced:views/bpmn-flowchart-element/record/event-start-detail"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.model.isInSubProcess?(this.showField("timer"),this.hideField("targetReport"),this.hideField("scheduling")):(this.hideField("timer"),this.showField("targetReport"),this.showField("scheduling"))}})}),define("advanced:views/bpmn-flowchart-element/record/event-start-signal-edit",["advanced:views/bpmn-flowchart-element/record/event-start-edit"],function(t){return t.extend({setup:function(){if(t.prototype.setup.call(this),!this.model.isInSubProcess){let t=this.getMetadata().get(["entityDefs","Workflow","fields","signalName","options"]);t=Espo.Utils.clone(t),t.includes("@delete")&&t.splice(t.indexOf("@delete"),1),this.setFieldOptionList("signal",t)}}})}),define("advanced:views/bpmn-flowchart-element/record/event-start-conditional-edit",["advanced:views/bpmn-flowchart-element/record/event-start-edit"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.model.isInSubProcess?this.hideField("triggerType"):this.showField("triggerType")}})}),define("advanced:views/bpmn-flowchart-element/record/event-start-conditional-detail",["advanced:views/bpmn-flowchart-element/record/event-start-detail"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.model.isInSubProcess?this.hideField("triggerType"):this.showField("triggerType")}})}),define("advanced:views/bpmn-flowchart-element/record/call-activity-edit",["advanced:views/bpmn-flowchart-element/record/edit","advanced:views/bpmn-flowchart-element/record/task-user-detail"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this),this.listenTo(this.model,"change:target",(t,e,i)=>{i.ui&&t.set({flowchartId:null,flowchartName:null})})}})}),define("advanced:views/bpmn-flowchart-element/fields/timer",["views/fields/base","ui/select"],function(t,e){return t.extend({detailTemplate:"advanced:bpmn-flowchart-element/fields/timer/detail",editTemplate:"advanced:bpmn-flowchart-element/fields/timer/edit",data:function(){const t={};return t.timerBaseTranslatedValue=this.translateTimerBaseValue(this.model.get("timerBase")),t.timerShiftOperatorTranslatedValue=this.getLanguage().translateOption(this.model.get("timerShiftOperator"),"timerShiftOperator","BpmnFlowchartElement"),t.timerShiftUnitsTranslatedValue=this.getLanguage().translateOption(this.model.get("timerShiftUnits"),"timerShiftUnits","BpmnFlowchartElement"),t.timerShiftValue=this.model.get("timerShift"),t.hasShift=0!==this.model.get("timerShift")&&"formula"!==this.model.get("timerBase"),t.hasFormula="formula"===this.model.get("timerBase"),"edit"===this.mode&&(t.timerBaseOptionDataList=[],this.timerBaseOptionList.forEach(e=>{t.timerBaseOptionDataList.push({value:e,label:this.translateTimerBaseValue(e),isSelected:e===this.model.get("timerBase")})}),t.timerShiftOperatorOptionDataList=[],this.timerShiftOperatorOptionList.forEach(e=>{t.timerShiftOperatorOptionDataList.push({value:e,label:this.getLanguage().translateOption(e,"timerShiftOperator","BpmnFlowchartElement"),isSelected:e===this.model.get("timerShiftOperator")})}),t.timerShiftUnitsOptionDataList=[],this.timerShiftUnitsOptionList.forEach(e=>{t.timerShiftUnitsOptionDataList.push({value:e,label:this.getLanguage().translateOption(e,"timerShiftUnits","BpmnFlowchartElement"),isSelected:e===this.model.get("timerShiftUnits")})})),t},setup:function(){t.prototype.setup.call(this),this.timerBaseOptionList=["moment","formula"],this.entityType=this.model.targetEntityType,this.timerShiftOperatorOptionList=["plus","minus"],this.timerShiftUnitsOptionList=["minutes","seconds","hours","days","months"],this.setupBaseOptionList(),this.createView("timerFormula","views/fields/formula",{name:"timerFormula",model:this.model,mode:this.mode,height:50,selector:".formula-container",inlineEditDisabled:!0,targetEntityType:this.model.targetEntityType,smallFont:!0})},setupBaseOptionList:function(){const t=[],e=["date","datetime"],i=this.getMetadata().get(["entityDefs",this.entityType,"fields"])||{};Object.keys(i).forEach(s=>{~e.indexOf(i[s].type)&&t.push(s)});const s=this.getMetadata().get(["entityDefs",this.entityType,"links"])||{};Object.keys(s).forEach(i=>{if("belongsTo"===s[i].type){const a=s[i].entity;if(!a)return;const n=this.getMetadata().get(["entityDefs",a,"fields"]);Object.keys(n).forEach(s=>{~e.indexOf(n[s].type)&&t.push(`${i}.${s}`)})}}),t.forEach(t=>{this.timerBaseOptionList.push("field:"+t)})},afterRender:function(){this.$timerShiftUnits=this.$el.find('[data-name="timerShiftUnits"]'),this.$timerShiftOperator=this.$el.find('[data-name="timerShiftOperator"]'),this.$timerShift=this.$el.find('[data-name="timerShift"]'),this.$timerFormulaContainer=this.$el.find(".formula-container"),this.$el.find('[data-name="timerBase"]').on("change",()=>{this.trigger("change"),this.reRender()}),this.controlVisibility(),this.isEditMode()&&this.element&&this.element.querySelectorAll("select").forEach(t=>{e.init(t)})},controlVisibility:function(){"formula"===this.model.get("timerBase")?(this.$timerShiftUnits.addClass("hidden"),this.$timerShiftOperator.addClass("hidden"),this.$timerShift.addClass("hidden"),this.$timerFormulaContainer.removeClass("hidden")):(this.$timerShiftUnits.removeClass("hidden"),this.$timerShiftOperator.removeClass("hidden"),this.$timerShift.removeClass("hidden"),this.$timerFormulaContainer.addClass("hidden"))},fetch:function(){let t=this.$el.find('[data-name="timerBase"]').val(),e=this.$el.find('[data-name="timerShiftUnits"]').val(),i=this.$el.find('[data-name="timerShiftOperator"]').val(),s=parseInt(this.$el.find('[data-name="timerShift"]').val());isNaN(s)&&(s=null),"moment"===t&&(t=null);let a=null;return"formula"===t&&(a=this.getView("timerFormula").fetch().timerFormula,i=null,s=null,e=null),{timerBase:t,timerShiftUnits:e,timerShiftOperator:i,timerShift:s,timerFormula:a}},translateTimerBaseValue:function(t){if(null===t||"moment"===t)return this.getLanguage().translateOption("moment","timerBase","BpmnFlowchartElement");if("formula"===t)return this.getLanguage().translateOption("formula","timerBase","BpmnFlowchartElement");let e;if(0===t.indexOf("field:")){const i=t.substr(6);let s,a=this.entityType;if(~i.indexOf(".")){const t=i.split("."),n=t[0];s=t[1],a=this.getMetadata().get(["entityDefs",this.entityType,"links",n,"entity"]),e=this.translate(n,"links",this.entityType)+" . "+this.translate(s,"fields",a)}else s=i,e=this.translate(s,"fields",a);return this.translate("Field","labels","BpmnFlowchartElement")+" · "+e}return t}})}),define("advanced:views/bpmn-flowchart-element/fields/task-user-target",["views/fields/enum"],function(t){return t.extend({setup:function(){t.prototype.setup.call(this);const e=this.getTargetOptionsData();this.params.options=e.itemList,this.translatedOptions=e.translatedOptions},getTargetOptionsData:function(){const t=[""],e={};e[""]=this.translate("Current","labels","Workflow")+" · "+this.translate(this.model.targetEntityType,"scopeNames");this.model.elementHelper.getTargetCreatedList().forEach(i=>{"BpmnUserTask"===i&&t.push(i),e[i]=this.model.elementHelper.translateTargetItem(i)});return this.model.elementHelper.getTargetLinkList(2,!1,this.skipParent).forEach(i=>{t.push(i),e[i]=this.model.elementHelper.translateTargetItem(i)}),{itemList:t,translatedOptions:e}}})}),define("advanced:views/bpmn-flowchart-element/fields/task-user-assignment-type",["views/fields/enum","advanced:views/bpmn-flowchart-element/fields/task-send-message-from"],function(t,e){return t.extend({setupOptions:function(){t.prototype.setupOptions.call(this),this.params.options=Espo.Utils.clone(this.params.options);e.prototype.getLinkOptionList.call(this,!0,!0).forEach(t=>{this.params.options.push(t)}),this.translateOptions(this)},translateOptions:function(){this.translatedOptions={};const t=this.model.targetEntityType;this.params.options.forEach(e=>{if(0===e.indexOf("link:")){let i=e.substring(5);if(~i.indexOf(".")){const s=i.split(".");i=s[0];const a=s[1];if("followers"===a)return void(this.translatedOptions[e]=this.translate("Related","labels","Workflow")+" · "+this.translate(i,"links",t)+" . "+this.translate("Followers"));const n=this.getMetadata().get(["entityDefs",t,"links",i,"entity"]);return void(this.translatedOptions[e]=this.translate("Related","labels","Workflow")+": "+this.translate(i,"links",t)+" . "+this.translate(a,"links",n))}return void(this.translatedOptions[e]=this.translate("Related","labels","Workflow")+" · "+this.translate(i,"links",t))}this.translatedOptions[e]=this.getLanguage().translateOption(e,"assignmentType","BpmnFlowchartElement")})}})}),define("advanced:views/bpmn-flowchart-element/fields/task-user-action-type",["views/fields/enum"],function(t){return t.extend({setupOptions:function(){t.prototype.setupOptions.call(this);var e=this.getMetadata().get(["entityDefs","BpmnUserTask","fields","actionType","options"])||[];this.params.options=Espo.Utils.clone(e)}})}),define("advanced:views/bpmn-flowchart-element/fields/task-send-message-to",["views/fields/enum","advanced:views/bpmn-flowchart-element/fields/task-send-message-from"],function(t,e){return t.extend({setupOptions:function(){t.prototype.setupOptions.call(this),this.params.options=Espo.Utils.clone(this.params.options),"email"===this.getMetadata().get(["entityDefs",this.model.targetEntityType,"fields","emailAddress","type"])&&this.params.options.push("targetEntity");let i=e.prototype.getLinkOptionList.call(this);this.getMetadata().get(["scopes",this.model.targetEntityType,"stream"])&&this.params.options.push("followers"),i.forEach(t=>{this.params.options.push(t)}),e.prototype.translateOptions.call(this)}})}),define("advanced:views/bpmn-flowchart-element/fields/task-send-message-reply-to",["views/fields/enum","advanced:views/bpmn-flowchart-element/fields/task-send-message-from"],function(t,e){return t.extend({setupOptions:function(){t.prototype.setupOptions.call(this),this.params.options=Espo.Utils.clone(this.params.options),"email"===this.getMetadata().get(["entityDefs",this.model.targetEntityType,"fields","emailAddress","type"])&&this.params.options.push("targetEntity");e.prototype.getLinkOptionList.call(this,!1,!0).forEach(t=>{this.params.options.push(t)}),e.prototype.translateOptions.call(this)}})}),define("advanced:views/bpmn-flowchart-element/fields/task-script-formula",["views/fields/formula"],function(t){return t.extend({setup:function(){this.params.targetEntityType=this.model.targetEntityType,t.prototype.setup.call(this)}})}),define("advanced:views/bpmn-flowchart-element/fields/target-report",["views/fields/link"],function(t){return t.extend({selectPrimaryFilterName:"list",createDisabled:!0,getSelectFilters:function(){var t=this.model.targetEntityType;if(t)return{entityType:{type:"equals",value:[t]}}}})}),define("advanced:views/bpmn-flowchart-element/fields/target-id-expression","views/fields/formula",function(t){return t.extend({height:15,setup:function(){this.params.targetEntityType=this.model.targetEntityType,t.prototype.setup.call(this)}})}),define("advanced:views/bpmn-flowchart-element/fields/sub-process-target",["advanced:views/bpmn-flowchart-element/fields/call-activity-target","advanced:bpmn-element-helper"],function(t,e){return t.extend({skipParent:!0,setup:function(){t.prototype.setup.call(this),this.bpmnHelper=new e(this.getHelper(),this.model)},fetch:function(){const e=t.prototype.fetch.call(this);return e.targetType=this.bpmnHelper.getEntityTypeFromTarget(e.target),e}})}),define("advanced:views/bpmn-flowchart-element/fields/sub-process-flowchart","advanced:views/bpmn-flowchart/fields/flowchart",function(t){return t.extend({dataAttribute:"flowchartData",isSubProcess:!0,setup:function(){t.prototype.setup.call(this),"eventSubProcess"===this.model.elementType&&(this.isEventSubProcess=!0)}})}),define("advanced:views/bpmn-flowchart-element/fields/start-direction",["views/fields/enum"],function(t){return t.extend({data:function(){var e=t.prototype.data.call(this);return e.isNotEmpty=!0,e},getValueForDisplay:function(){var e=t.prototype.getValueForDisplay.call(this);return e||(e=""),e},fetch:function(){var e=t.prototype.fetch.call(this);return""===e[this.name]&&(e[this.name]=null),e}})}),define("advanced:views/bpmn-flowchart-element/fields/signal",["views/fields/varchar"],function(t){return t.extend({setupOptions:function(){t.prototype.setupOptions.call(this),this.params.options=["create.ENTITY_TYPE","update.ENTITY_TYPE.ID","delete.ENTITY_TYPE.ID","relate.ENTITY_TYPE.ID.LINK_NAME","relate.ENTITY_TYPE.ID.LINK_NAME.FOREIGN_ID","unrelate.ENTITY_TYPE.ID.LINK_NAME","unrelate.ENTITY_TYPE.ID.LINK_NAME.FOREIGN_ID"]}})}),define("advanced:views/bpmn-flowchart-element/fields/message-replied-to","views/fields/enum",function(t){return t.extend({fetchEmptyValueAsNull:!0,setupOptions:function(){var t=[""];this.translatedOptions={"":this.translate("None")};var e=this.model.flowchartCreatedEntitiesData||{};for(var i in e){var s=e[i];"Email"===s.entityType&&(this.translatedOptions[i]=s.text||i,t.push(i))}this.params.options=t}})}),define("advanced:views/bpmn-flowchart-element/fields/message-related-to",["views/fields/enum"],function(t,e){return t.extend({fetchEmptyValueAsNull:!0,setupOptions:function(){const t=[""],e={};this.getMetadata().get(["scopes",this.model.targetEntityType,"object"])&&t.push("targetEntity");const i=["User","Email"];this.model.elementHelper.getTargetCreatedList().forEach(s=>{const a=this.model.elementHelper.getEntityTypeFromTarget(s);~i.indexOf(a)||this.getMetadata().get(["scopes",a,"object"])&&(t.push(s),e[s]=this.model.elementHelper.translateTargetItem(s))}),this.model.elementHelper.getTargetLinkList(2,!1,!1).forEach(s=>{const a=this.model.elementHelper.getEntityTypeFromTarget(s);~i.indexOf(a)||this.getMetadata().get(["scopes",a,"object"])&&(t.push(s),e[s]=this.model.elementHelper.translateTargetItem(s))}),this.params.options=t,e[""]=this.translate("None"),e.targetEntity=this.getLanguage().translateOption("targetEntity","emailAddress","BpmnFlowchartElement")+" · "+this.translate(this.model.targetEntityType,"scopeNames"),this.translatedOptions=e}})}),define("advanced:views/bpmn-flowchart-element/fields/message-conditions-formula","views/fields/formula",function(t){return t.extend({height:30,setup:function(){this.params.targetEntityType="Email",t.prototype.setup.call(this)}})}),define("advanced:views/bpmn-flowchart-element/fields/loop-collection-expression","views/fields/formula",function(t){return t.extend({height:15,setup:function(){this.params.targetEntityType=this.model.targetEntityType,t.prototype.setup.call(this)}})}),define("advanced:views/bpmn-flowchart-element/fields/flows-conditions",["views/fields/base","model"],function(t,e){return t.extend({detailTemplate:"advanced:bpmn-flowchart-element/fields/flows-conditions/detail",editTemplate:"advanced:bpmn-flowchart-element/fields/flows-conditions/detail",setup:function(){t.prototype.setup.call(this),this.setupConditionsList(),this.listenTo(this.model,"change:defaultFlowId",()=>{this.setupConditionsList(()=>{this.reRender()})})},events:{'click [data-action="moveUp"]':function(t){var e=$(t.currentTarget).data("id");this.moveUp(e)},'click [data-action="moveDown"]':function(t){var e=$(t.currentTarget).data("id");this.moveDown(e)}},data:function(){var t={},e=[],i=this.getFlowList();return i.forEach((t,s)=>{e.push({id:t.id,label:this.getFlowLabel(t.id),isTop:0===s,isBottom:s===i.length-1})}),t.flowDataList=e,t.isEditMode="edit"===this.mode,t},moveUp:function(t){this.fetchToModel();var e=this.getFlowList(),i=!1;e.forEach((s,a)=>{if(!i&&s.id===t&&a>0){var n=e[a];e[a]=e[a-1],e[a-1]=n,i=!0}}),this.model.set("flowList",e),this.setupConditionsList(()=>{this.reRender()})},moveDown:function(t){this.fetchToModel();var e=this.getFlowList(),i=!1;e.forEach((s,a)=>{if(!i&&s.id===t&&a<e.length-1){var n=e[a];e[a]=e[a+1],e[a+1]=n,i=!0}}),this.model.set("flowList",e),this.setupConditionsList(()=>{this.reRender()})},setupConditionsList:function(t){var i=this.getFlowList(),s=0;const a=this.model.attributes.defaultFlowId;a&&this.clearView(a),i.forEach(a=>{var n=a.id,o=new e;o.set({conditionsAll:a.conditionsAll||[],conditionsAny:a.conditionsAny||[],conditionsFormula:a.conditionsFormula||null}),this.createView(n,"advanced:views/workflow/record/conditions",{entityType:this.model.targetEntityType,selector:`.flow[data-id="${a.id}"]`,readOnly:"edit"!==this.mode,model:o,flowchartCreatedEntitiesData:this.model.flowchartCreatedEntitiesData,isChangedDisabled:!0},()=>{++s===i.length&&t&&t()})})},getFlowLabel:function(t){var e=this.getElementData(t);if(e){var i=this.getElementData(e.endId);if(i)return this.translate(i.type,"elements","BpmnFlowchart")+" · "+(i.text||i.id)}},getFlowList:function(){var t=this.model.get("flowList")||[];this.getFlowIdList().forEach(e=>{var i=!1;t.forEach(t=>{t.id===e&&(i=!0)}),i||t.push({id:e,conditionsAll:[],conditionsAny:[],conditionsFormula:null})});var e=[];return t.forEach(t=>{t.id!==this.model.get("defaultFlowId")&&e.push(t)}),e},getFlowIdList:function(){var t=[];return this.model.dataHelper.getAllDataList().forEach(e=>{if("flow"===e.type&&e.startId===this.model.id&&e.endId){if(!this.getElementData(e.endId))return;t.push(e.id)}}),t},getElementData:function(t){return this.model.dataHelper.getElementData(t)},fetch:function(){var t=this.getFlowList();return t.forEach(t=>{var e=this.getView(t.id).fetch();t.conditionsAll=e.all,t.conditionsAny=e.any,t.conditionsFormula=e.formula}),{flowList:t}}})}),define("advanced:views/bpmn-flowchart-element/fields/default-flow-id",["views/fields/enum"],function(t){return t.extend({data:function(){var e=t.prototype.data.call(this);return e.isNotEmpty=!0,e},setupOptions:function(){t.prototype.setupOptions.call(this);var e=this.model.dataHelper.getAllDataList(),i=this.model.get("id");this.translatedOptions={};var s=[];e.forEach(function(t){if("flow"===t.type&&t.startId===i&&t.endId){var e=this.getElementData(t.endId);if(!e)return;s.push(t.id),this.translatedOptions[t.id]=this.translate(e.type,"elements","BpmnFlowchart")+" · "+(e.text||e.id)}},this),this.translatedOptions[""]=this.translate("None"),this.params.options=s,this.params.options.unshift("")},getValueForDisplay:function(){var e=t.prototype.getValueForDisplay.call(this);return e||(e=""),e},getElementData:function(t){return this.model.dataHelper.getElementData(t)},fetch:function(){var e=t.prototype.fetch.call(this);return""===e[this.name]&&(e[this.name]=null),e}})}),define("advanced:views/bpmn-flowchart-element/fields/conditions",["views/fields/base","model"],function(t,e){return t.extend({detailTemplate:"advanced:bpmn-flowchart-element/fields/conditions/detail",editTemplate:"advanced:bpmn-flowchart-element/fields/conditions/detail",setup:function(){t.prototype.setup.call(this),this.conditionsModel=new e,this.conditionsModel.set({conditionsAll:this.model.get("conditionsAll")||[],conditionsAny:this.model.get("conditionsAny")||[],conditionsFormula:this.model.get("conditionsFormula")||null});let i=!0,s=this.model.flowchartCreatedEntitiesData;"eventStartConditional"!==this.model.elementType||this.model.isInSubProcess||(s=null,i=!1),this.createView("conditions","advanced:views/workflow/record/conditions",{entityType:this.model.targetEntityType,selector:"> .conditions-container",readOnly:"edit"!==this.mode,model:this.conditionsModel,flowchartCreatedEntitiesData:s,isChangedDisabled:i})},fetch:function(){const t=this.getView("conditions").fetch();return{conditionsAll:t.all,conditionsAny:t.any,conditionsFormula:t.formula}}})}),define("advanced:views/bpmn-flowchart-element/fields/call-activity-flowchart",["views/fields/link"],function(t){return t.extend({selectPrimaryFilterName:"activeHasNoneStartEvent",createDisabled:!0,getSelectFilters:function(){var t=this.model.elementHelper.getEntityTypeFromTarget(this.model.get("target"));if(t){var e={};return t&&(e.targetType={type:"in",value:[t]}),e}}})}),define("advanced:views/bpmn-flowchart-element/fields/actions",["views/fields/base","model"],function(t,e){return t.extend({detailTemplate:"advanced:bpmn-flowchart-element/fields/actions/detail",editTemplate:"advanced:bpmn-flowchart-element/fields/actions/detail",setup:function(){t.prototype.setup.call(this);var i=new e;i.set("entityType",this.model.targetEntityType);var s=this.model.get("actionList")||[];i.set("actions",s);var a=Espo.Utils.clone(this.getMetadata().get(["clientDefs","BpmnFlowchart","elements","task","fields","actions","actionTypeList"]));this.createView("actions","advanced:views/workflow/record/actions",{entityType:this.model.targetEntityType,selector:"> .actions-container",readOnly:"edit"!==this.mode,model:i,actionTypeList:a,flowchartElementId:this.model.id,flowchartCreatedEntitiesData:this.model.flowchartCreatedEntitiesData})},events:{},data:function(){var t={};return t.isEditMode="edit"===this.mode,t},fetch:function(){return{actionList:this.getView("actions").fetch()}}})}),define("advanced:views/bpmn-flowchart/list-with-categories",["views/list-with-categories"],t=>class extends t{quickCreate=!1}),define("advanced:views/bpmn-flowchart/record/edit","views/record/edit",function(t){return t.extend({saveAndContinueEditingAction:!0,setup:function(){t.prototype.setup.call(this);var e={};this.model.isNew()?(this.controlFlowchartField(),this.listenTo(this.model,"change:targetType",function(t){var i=t.previous("targetType"),s=t.get("targetType");e[i]=this.model.get("data");var a=e[s]||{list:[]};this.controlFlowchartField(),this.model.set("data",a)},this)):this.setFieldReadOnly("targetType")},controlFlowchartField:function(){this.model.get("targetType")?this.showField("flowchart"):this.hideField("flowchart")}})}),define("advanced:views/bpmn-flowchart/record/detail","views/record/detail",function(t){return t.extend({saveAndContinueEditingAction:!0,setup:function(){t.prototype.setup.call(this),this.model.isNew()||this.setFieldReadOnly("targetType")}})}),define("advanced:views/bpmn-flowchart/record/panels/flowchart",["views/record/panels/bottom"],function(t){return t.extend({template:"advanced:bpmn-flowchart/record/panels/flowchart",setup:function(){t.prototype.setup.call(this),this.createView("flowchart","advanced:views/bpmn-flowchart/fields/flowchart",{model:this.model,selector:'.field[data-name="flowchart"]',defs:{name:"flowchart"},mode:this.mode,inlineEditDisabled:!0,disabled:this.recordHelper.getFieldStateParam("flowchart","hidden")})},getFieldViews:function(){var t={};return t.flowchart=this.getView("flowchart"),t}})}),define("modules/advanced/views/bpmn-flowchart/modals/element-edit",["exports","views/modal","model","modules/advanced/bpmn-element-helper"],function(t,e,i,s){"use strict";function a(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=a(e),i=a(i),s=a(s);class n extends e.default{template="advanced:bpmn-flowchart/modals/element-detail";escapeDisabled=!0;cssName="detail-modal";className="dialog dialog-record";setup(){this.elementData=Espo.Utils.cloneDeep(this.options.elementData||{}),this.targetType=this.options.targetType;const t=this.model=new i.default(this.elementData,{entityType:"BpmnFlowchartElement"});this.elementType=this.model.attributes.type,t.targetEntityType=this.targetType,t.flowchartDataList=this.options.flowchartDataList,t.flowchartModel=this.options.flowchartModel,t.flowchartCreatedEntitiesData=this.options.flowchartCreatedEntitiesData,t.elementType=this.elementType,t.elementHelper=new s.default(this.getHelper(),t),t.dataHelper=this.options.dataHelper,t.isInSubProcess=this.options.isInSubProcess;const e=this.getMetadata().get(["clientDefs","BpmnFlowchart","elements",this.elementType,"fields"])||{};t.setDefs({fields:e}),this.headerText=this.translate(this.elementType,"elements","BpmnFlowchart"),this.buttonList=[{name:"apply",label:"Apply",style:"danger",onClick:()=>this.actionApply()},{name:"cancel",label:"Close",onClick:()=>this.actionCancel()}];const a=this.getMetadata().get(["clientDefs","BpmnFlowchart","elements",this.elementType,"recordEditView"])||"advanced:views/bpmn-flowchart-element/record/edit",n=this.getMetadata().get(["clientDefs","BpmnFlowchart","elements",this.elementType,"layout"]),o=this.getMetadata().get(["clientDefs","BpmnFlowchart","elements",this.elementType,"dynamicLogic"]),r={model:this.model,fullSelector:this.containerSelector+" .record-container",type:"detailSmall",detailLayout:n,columnCount:2,buttonsPosition:!1,buttonsDisabled:!0,inlineEditDisabled:!0,sideDisabled:!0,bottomDisabled:!0,isWide:!0,dynamicLogicDefs:o};this.createView("record",a,r),this.shortcutKeys={"Control+Enter":t=>{t.preventDefault(),t.stopPropagation(),document.activeElement instanceof HTMLInputElement&&document.activeElement.dispatchEvent(new Event("change",{bubbles:!0})),this.actionApply()},Escape:async t=>{t.stopPropagation(),t.preventDefault();const e=this.getRecordView().getFocusedFieldView();if(e&&this.getRecordView().model.set(e.fetch(),{skipReRender:!0}),this.getRecordView().isChanged)return await this.confirm(this.translate("confirmLeaveOutMessage","messages")),void this.actionClose();this.actionClose()}}}getRecordView(){return this.getView("record")}actionApply(){const t=Espo.Utils.cloneDeep(this.getRecordView().fetch()||{});this.getRecordView().validate()||(this.trigger("apply",t),this.close())}}t.default=n}),define("modules/advanced/views/bpmn-flowchart/modals/element-detail",["exports","views/modal","model","modules/advanced/bpmn-element-helper"],function(t,e,i,s){"use strict";function a(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=a(e),i=a(i),s=a(s);class n extends e.default{template="advanced:bpmn-flowchart/modals/element-detail";backdrop=!0;cssName="detail-modal";className="dialog dialog-record";setup(){this.elementData=Espo.Utils.cloneDeep(this.options.elementData||{}),this.targetType=this.options.targetType;const t=this.model=new i.default(this.elementData,{entityType:"BpmnFlowchartElement"});this.elementType=this.model.attributes.type,t.targetEntityType=this.targetType,t.flowchartDataList=this.options.flowchartDataList,t.flowchartModel=this.options.flowchartModel,t.flowchartCreatedEntitiesData=this.options.flowchartCreatedEntitiesData,t.elementType=this.elementType,t.elementHelper=new s.default(this.getHelper(),t),t.dataHelper=this.options.dataHelper,t.isInSubProcess=this.options.isInSubProcess;const e=this.getMetadata().get(["clientDefs","BpmnFlowchart","elements",this.elementType,"fields"])||{};t.setDefs({fields:e}),this.headerText=this.translate(this.elementType,"elements","BpmnFlowchart"),this.buttonList=[{name:"cancel",label:"Close",onClick:()=>this.actionCancel()}],this.model.flowchartModel&&"BpmnProcess"===this.model.flowchartModel.entityType&&"Started"===this.model.flowchartModel.get("status")&&!this.options.isInSubProcess2&&this.buttonList.push({name:"startFromHere",html:this.translate("Start flow from here","labels","BpmnProcess"),pullLeft:!0,onClick:()=>this.actionStartFromHere()});const a=this.getMetadata().get(["clientDefs","BpmnFlowchart","elements",this.elementType,"recordDetailView"])||"advanced:views/bpmn-flowchart-element/record/detail",n=this.getMetadata().get(["clientDefs","BpmnFlowchart","elements",this.elementType,"layout"]),o=this.getMetadata().get(["clientDefs","BpmnFlowchart","elements",this.elementType,"dynamicLogic"]),r={model:this.model,fullSelector:this.containerSelector+" .record-container",type:"detailSmall",detailLayout:n,columnCount:2,buttonsPosition:!1,buttonsDisabled:!0,inlineEditDisabled:!0,sideDisabled:!0,bottomDisabled:!0,isWide:!0,dynamicLogicDefs:o};this.createView("record",a,r)}actionStartFromHere(){this.confirm(this.translate("confirmation","messages"),()=>{Espo.Ajax.postRequest("BpmnProcess/action/startFlowFromElement",{processId:this.model.flowchartModel.id,elementId:this.model.id}).then(()=>{Espo.Ui.success(this.translate("Done")),this.model.flowchartModel.fetch(),this.close()})})}}t.default=n}),define("advanced:views/bpmn-flow-node/record/list",["views/record/list"],function(t){return t.extend({actionInterruptFlowNode:function(t){this.actionRejectFlowNode(t)},actionRejectFlowNode:function(t){let e=t.id;this.confirm(this.translate("confirmation","messages"),()=>{Espo.Ajax.postRequest("BpmnProcess/action/rejectFlowNode",{id:e}).then(()=>{this.collection.fetch().then(()=>{Espo.Ui.success(this.translate("Done")),this.collection.parentModel&&this.collection.parentModel.fetch()})})})},actionViewError:function(t){let e=this.collection.get(t.id);if(!e)return;let i=e.get("data")||{};this.createView("dialog","advanced:views/bpmn-flow-node/modals/view-error",{nodeData:i}).then(t=>{t.render()})}})}),define("advanced:views/bpmn-flow-node/record/row-actions/default",["views/record/row-actions/default"],function(t){return t.extend({getActionList:function(){let t=[],e=this.model.get("status"),i=this.model.get("elementType");return["In Process"].includes(e)&&t.push({action:"interruptFlowNode",html:this.translate("Interrupt","labels","BpmnProcess"),data:{id:this.model.id}}),["Processed","Interrupted","Rejected","Failed"].includes(e)||t.push({action:"rejectFlowNode",html:this.translate("Reject","labels","BpmnProcess"),data:{id:this.model.id}}),["eventStartError","eventIntermediateErrorBoundary"].includes(i)&&"Processed"===e&&t.push({action:"viewError",html:this.translate("View Error","labels","BpmnProcess"),data:{id:this.model.id}}),t}})}),define("advanced:views/bpmn-flow-node/modals/view-error",["views/modal","model"],function(t,e){return t.extend({templateContent:'<div class="record no-side-margin">{{{record}}}</div>',className:"dialog dialog-record",backdrop:!0,setup:function(){this.headerText=this.translate("View Error","labels","BpmnProcess");let t=new e;t.name="Dummy",t.set({code:this.options.nodeData.code||null,message:this.options.nodeData.message||null}),this.createView("record","views/record/detail",{readOnly:!0,bottomView:null,sideView:null,buttonsDisabled:!0,scope:"Dummy",model:t,selector:".record",detailLayout:[{rows:[[{name:"code",view:"views/fields/varchar",customLabel:this.translate("errorCode","fields","BpmnFlowchartElement")},!1],[{name:"message",view:"views/fields/varchar",customLabel:this.translate("Error Message","labels","BpmnFlowchartElement")}]]}]})}})}),define("advanced:views/bpmn-flow-node/fields/element",["views/fields/varchar"],function(t){return t.extend({listTemplate:"advanced:bpmn-flow-node/fields/element/detail",getValueForDisplay:function(){let t=this.translate(this.model.get("elementType"),"elements","BpmnFlowchart");const e=this.model.get("elementData")||{},i=this.model.get("data")||{};let s=e.text;s&&(t+=" · "+this.getHelper().escapeString(s));const a=this.model.get("elementType");if("taskUser"===a&&this.model.get("userTaskId")&&(t='<a href="#BpmnUserTask/view/'+this.model.get("userTaskId")+'">'+this.getHelper().escapeString(t)+"</a>"),("callActivity"===a||"subProcess"===a||"eventSubProcess"===a)&&("Process"!==e.callableType&&"subProcess"!==a&&"eventSubProcess"!==a||!i.subProcessId||(t='<a href="#BpmnProcess/view/'+i.subProcessId+'">'+this.getHelper().escapeString(t)+"</a>"),i.errorTriggered)){let e=this.translate("Error","labels","BpmnFlowchart");i.errorCode&&(e+=" "+i.errorCode),t+=' · <span class="text-danger">'+this.getHelper().escapeString(e)+"</span>"}return"eventIntermediateConditionalBoundary"!==a&&"eventStartConditionalEventSubProcess"!==a||i.isOpposite&&(t=this.translate("Reset","labels","BpmnFlowNode")+" · "+t),s=Handlebars.Utils.escapeExpression(this.stripTags(t)),t='<span title="'+s+'">'+t+"</span>",t},stripTags:function(t){return"string"==typeof(t=t||"")||t instanceof String?t.replace(/<\/?[^>]+(>|$)/g,""):t}})}),define("advanced:handlers/manual-workflow",["dynamic-logic"],function(t){const e=function(t){this.view=t};return _.extend(e.prototype,{process:function(){const e=(this.view.getHelper().getAppParam("manualWorkflows")||{})[this.view.scope]||[];if(!e.length)return;const i=new t({},this.view),s=(t,e)=>{const s="runWorkflow_"+t;i.checkConditionGroup(e)?this.view.showHeaderActionItem(s):this.view.hideHeaderActionItem(s)};e.forEach(t=>{const e="Button"===t.elementType?"buttons":"dropdown",i={text:t.label,acl:"edit"===t.accessRequired?"edit":"read",name:"runWorkflow_"+t.id,action:"runWorkflow",style:t.style||"default",data:{id:t.id,handler:"advanced:handlers/manual-workflow-action"}};if(this.view.addMenuItem(e,i,!1),t.dynamicLogic){const e=t.dynamicLogic.conditionGroup;s(t.id,e),this.listenTo(this.view.model,"sync",()=>s(t.id,e))}})}}),_.extend(e.prototype,Backbone.Events),e}),define("advanced:handlers/manual-workflow-action",["action-handler"],function(t){return t.extend({actionRunWorkflow:function(t){const e=this.view,i=t.id,s=((e.getHelper().getAppParam("manualWorkflows")||{})[e.model.entityType]||[]).find(t=>t.id===i);let a=e.translate("confirmation","messages");s&&s.confirmationText&&(a=e.getHelper().transformMarkdownText(s.confirmationText).toString()),s.confirmation?Espo.Ui.confirm(a,{confirmText:e.translate("Yes","labels"),cancelText:e.translate("No","labels"),backdrop:!0,isHtml:!0}).then(()=>this.process(i)):this.process(i)},async process(t){const e=this.view,i=this.view.model,s="runWorkflow_"+t;let a;e.disableMenuItem(s),Espo.Ui.notify(" ... ");try{a=await Espo.Ajax.postRequest("WorkflowManual/action/run",{targetId:i.id,id:t})}catch(t){return void e.enableMenuItem(s)}if(await i.fetch(),a.message){const t=a.type||"success";let e;a.autoClose&&(e=3e3),Espo.Ui.notify(a.message,t,e,{closeButton:!a.autoClose,suppress:a.autoClose})}else Espo.Ui.success(e.translate("Done"));e.enableMenuItem(s),i.trigger("update-all")}})}),define("modules/advanced/handlers/report/create-joint-grid-report-action",["exports","di","router"],function(t,e,i){"use strict";var s;let a,n;function o(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function r(t,e,i){"symbol"==typeof e&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch(t){}return t}function l(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(null!==t?typeof t:"null"));return t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,i=(s=i)&&s.__esModule?s:{default:s};class d{static#t=[a,n]=function(t,e,i,s,a,n){var d,c,h,u,p,f,m,g=Symbol.metadata||Symbol.for("Symbol.metadata"),y=Object.defineProperty,w=Object.create,v=[w(null),w(null)],b=e.length;function T(e,i,s){return function(a,n){i&&(n=a,a=t);for(var o=0;o<e.length;o++)n=e[o].apply(a,s?[n]:[]);return s?n:a}}function D(t,e,i,s){if("function"!=typeof t&&(s||void 0!==t))throw new TypeError(e+" must "+(i||"be")+" a function"+(s?"":" or undefined"));return t}function k(t,e,i,s,a,n,o,l,h,u,p){function f(t){if(!p(t))throw new TypeError("Attempted to access private element on non-instance")}var m=[].concat(e[0]),g=e[3],w=!o,b=1===a,k=3===a,E=4===a,C=2===a;function x(e,i,s){return function(a,n){return i&&(n=a,a=t),s&&s(a),O[e].call(a,n)}}if(!w){var O={},L=[],M=k?"get":E||b?"set":"value";if(h?(u||b?O={get:r(function(){return g(this)},s,"get"),set:function(t){e[4](this,t)}}:O[M]=g,u||r(O[M],s,C?"":M)):u||(O=Object.getOwnPropertyDescriptor(t,s)),!u&&!h){if((c=v[+l][s])&&7!=(c^a))throw Error("Decorating two elements with the same name ("+O[M].name+") is not supported yet");v[+l][s]=a<3?1:a}}for(var F=t,S=m.length-1;S>=0;S-=i?2:1){var V=D(m[S],"A decorator","be",!0),R=i?m[S-1]:void 0,$={},I={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:d,addInitializer:function(t,e){if(t.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(e,"An initializer","be",!0),n.push(e)}.bind(null,$)};if(w)c=V.call(R,F,I),$.v=1,D(c,"class decorators","return")&&(F=c);else if(I.static=l,I.private=h,c=I.access={has:h?p.bind():function(t){return s in t}},E||(c.get=h?C?function(t){return f(t),O.value}:x("get",0,f):function(t){return t[s]}),C||k||(c.set=h?x("set",0,f):function(t,e){t[s]=e}),F=V.call(R,b?{get:O.get,set:O.set}:O[M],I),$.v=1,b){if("object"==typeof F&&F)(c=D(F.get,"accessor.get"))&&(O.get=c),(c=D(F.set,"accessor.set"))&&(O.set=c),(c=D(F.init,"accessor.init"))&&L.unshift(c);else if(void 0!==F)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(F,(u?"field":"method")+" decorators","return")&&(u?L.unshift(F):O[M]=F)}return a<2&&o.push(T(L,l,1),T(n,l,0)),u||w||(h?b?o.splice(-1,0,x("get",l),x("set",l)):o.push(C?O[M]:D.call.bind(O[M])):y(t,s,O)),F}function E(t){return y(t,g,{configurable:!0,enumerable:!0,value:d})}return void 0!==n&&(d=n[g]),d=w(null==d?null:d),p=[],f=function(t){t&&p.push(T(t))},m=function(e,s){for(var n=0;n<i.length;n++){var r=i[n],d=r[1],c=7&d;if((8&d)==e&&!c==s){var f=r[2],m=!!r[3],g=16&d;k(e?t:t.prototype,r,g,m?"#"+f:o(f),c,c<2?[]:e?u=u||[]:h=h||[],p,!!e,m,s,e&&m?function(e){return l(e)===t}:a)}}},m(8,0),m(0,0),m(8,1),m(0,1),f(h),f(u),c=p,b||E(t),{e:c,get c(){var i=[];return b&&[E(t=k(t,[e],s,t.name,5,i)),T(i,1)]}}}(this,[],[[(0,e.inject)(i.default),0,"router"]]).e;router=a(this);constructor(t){n(this),this.view=t}process(){const t=this.view.currentCategoryId,e=this.view.currentCategoryName;let i="Report/create/type=JointGrid";t&&(i+=`&categoryId=${t}&categoryName=${e}`),this.router.navigate(i,{trigger:!0})}}t.default=d}),define("modules/advanced/handlers/report/create-internal-report-action",["exports","modules/advanced/views/report/modals/create-internal"],function(t,e){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(i=e)&&i.__esModule?i:{default:i};t.default=class{constructor(t){this.view=t}async process(){const t=this.view.currentCategoryId,i=this.view.currentCategoryName,s=new e.default({attributes:{categoryId:t,categoryName:i}});await this.view.assignView("dialog",s),await s.render()}}}),define("advanced:dynamic-handlers/report-panel",[],function(){var t=function(t){this.recordView=t,this.model=t.model};return _.extend(t.prototype,{init:function(){this.controlReportType(),this.controlReportId(),this.controlEntityType(),this.controlType(),this.controlTotal()},onChange:function(){this.controlTotal()},onChangeEntityType:function(t,e,i){i.ui&&(this.model.set({reportId:null,reportName:null,dynamicLogicVisible:null}),this.controlEntityType())},onChangeReportId:function(t,e,i){this.controlReportId()},onChangeReportType:function(t,e,i){this.controlReportType()},onChangeType:function(t,e,i){this.controlType()},controlEntityType:function(){this.model.get("entityType")?this.recordView.showField("dynamicLogicVisible"):this.recordView.hideField("dynamicLogicVisible")},controlReportType:function(){"Grid"===this.model.get("reportType")?(this.recordView.showField("displayTotal"),this.recordView.showField("column")):"JointGrid"===this.model.get("reportType")?(this.recordView.showField("displayTotal"),this.recordView.hideField("column")):(this.recordView.hideField("displayTotal"),this.recordView.hideField("column"))},controlReportId:function(){this.model.get("reportId")?this.recordView.showField("reportType"):this.recordView.hideField("reportType")},controlType:function(){"bottom"===this.model.get("type")?this.recordView.showField("order"):this.recordView.hideField("order")},controlTotal:function(){this.model.get("reportId")&&(this.model.get("displayTotal")||this.model.get("displayOnlyTotal"))?this.recordView.showField("useSiMultiplier"):this.recordView.hideField("useSiMultiplier")}}),t}),define("advanced:dynamic-handlers/report-filter",[],function(){var t=function(t){this.recordView=t,this.model=t.model};return _.extend(t.prototype,{onChangeEntityType:function(t,e,i){i.ui&&this.model.set({reportId:null,reportName:null})}}),t}),define("modules/advanced/controllers/report",["exports","controllers/record","di","metadata"],function(t,e,i,s){"use strict";let a,n;function o(t){return t&&t.__esModule?t:{default:t}}function r(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function l(t,e,i){"symbol"==typeof e&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch(t){}return t}function d(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(null!==t?typeof t:"null"));return t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=o(e),s=o(s);class c extends e.default{static#t=[a,n]=function(t,e,i,s,a,n){var o,c,h,u,p,f,m,g=Symbol.metadata||Symbol.for("Symbol.metadata"),y=Object.defineProperty,w=Object.create,v=[w(null),w(null)],b=e.length;function T(e,i,s){return function(a,n){i&&(n=a,a=t);for(var o=0;o<e.length;o++)n=e[o].apply(a,s?[n]:[]);return s?n:a}}function D(t,e,i,s){if("function"!=typeof t&&(s||void 0!==t))throw new TypeError(e+" must "+(i||"be")+" a function"+(s?"":" or undefined"));return t}function k(t,e,i,s,a,n,r,d,h,u,p){function f(t){if(!p(t))throw new TypeError("Attempted to access private element on non-instance")}var m=[].concat(e[0]),g=e[3],w=!r,b=1===a,k=3===a,E=4===a,C=2===a;function x(e,i,s){return function(a,n){return i&&(n=a,a=t),s&&s(a),O[e].call(a,n)}}if(!w){var O={},L=[],M=k?"get":E||b?"set":"value";if(h?(u||b?O={get:l(function(){return g(this)},s,"get"),set:function(t){e[4](this,t)}}:O[M]=g,u||l(O[M],s,C?"":M)):u||(O=Object.getOwnPropertyDescriptor(t,s)),!u&&!h){if((c=v[+d][s])&&7!=(c^a))throw Error("Decorating two elements with the same name ("+O[M].name+") is not supported yet");v[+d][s]=a<3?1:a}}for(var F=t,S=m.length-1;S>=0;S-=i?2:1){var V=D(m[S],"A decorator","be",!0),R=i?m[S-1]:void 0,$={},I={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:o,addInitializer:function(t,e){if(t.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(e,"An initializer","be",!0),n.push(e)}.bind(null,$)};if(w)c=V.call(R,F,I),$.v=1,D(c,"class decorators","return")&&(F=c);else if(I.static=d,I.private=h,c=I.access={has:h?p.bind():function(t){return s in t}},E||(c.get=h?C?function(t){return f(t),O.value}:x("get",0,f):function(t){return t[s]}),C||k||(c.set=h?x("set",0,f):function(t,e){t[s]=e}),F=V.call(R,b?{get:O.get,set:O.set}:O[M],I),$.v=1,b){if("object"==typeof F&&F)(c=D(F.get,"accessor.get"))&&(O.get=c),(c=D(F.set,"accessor.set"))&&(O.set=c),(c=D(F.init,"accessor.init"))&&L.unshift(c);else if(void 0!==F)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(F,(u?"field":"method")+" decorators","return")&&(u?L.unshift(F):O[M]=F)}return a<2&&r.push(T(L,d,1),T(n,d,0)),u||w||(h?b?r.splice(-1,0,x("get",d),x("set",d)):r.push(C?O[M]:D.call.bind(O[M])):y(t,s,O)),F}function E(t){return y(t,g,{configurable:!0,enumerable:!0,value:o})}return void 0!==n&&(o=n[g]),o=w(null==o?null:o),p=[],f=function(t){t&&p.push(T(t))},(m=function(e,s){for(var n=0;n<i.length;n++){var o=i[n],l=o[1],c=7&l;if((8&l)==e&&!c==s){var f=o[2],m=!!o[3],g=16&l;k(e?t:t.prototype,o,g,m?"#"+f:r(f),c,c<2?[]:e?u=u||[]:h=h||[],p,!!e,m,s,e&&m?function(e){return d(e)===t}:a)}}})(8,0),m(0,0),m(8,1),m(0,1),f(h),f(u),c=p,b||E(t),{e:c,get c(){var i=[];return b&&[E(t=k(t,[e],s,t.name,5,i)),T(i,1)]}}}(this,[],[[(0,i.inject)(s.default),0,"metadata"]],0,void 0,e.default).e;constructor(){super(...arguments),n(this)}metadata=a(this);async create(t){const e=!!(t=t??{}).attributes,i={...t.attributes};if("type"in t?i.type=t.type:i.type||(i.type="Grid"),"entityType"in t)i.entityType=t.entityType;else if(!e&&"JointGrid"!==i.type&&!t.internalClassName)throw new Espo.Exceptions.NotFound("Bad parameters.");if("categoryId"in t&&(i.categoryId=t.categoryId),"categoryName"in t&&(i.categoryName=t.categoryName),"internalClassName"in t){const e=t.internalClassName;i.internalClassName=e;const s=this.metadata.get(`app.advancedReport.internalReports.${e}`)??{};i.type=s.type,i.isInternal=!0,i.internalParams=Espo.Utils.cloneDeep(s.paramsDefaults)??{},i.depth=s.depth,i.entityType=s.entityType,i.runtimeFilters=s.runtimeFilters}t.attributes=i,await super.create(t)}actionShow(t){const e=t.id;if(!e)throw new Espo.Exceptions.NotFound("No report id.");const i=e=>{const i=this.getViewName("result");this.main(i,{scope:this.name,model:e,returnUrl:t.returnUrl,returnDispatchParams:t.returnDispatchParams,params:t})},s=t.model;if(s&&s.id&&s.get("type")&&s.get("groupBy"))return i(s),this.showLoadingNotification(),s.fetch().then(()=>{this.hideLoadingNotification()}),void this.listenToOnce(this.baseController,"action",()=>{s.abortLastFetch()});this.getModel().then(t=>{t.id=e,this.showLoadingNotification(),t.fetch({main:!0}).then(()=>{i(t)}),this.listenToOnce(this.baseController,"action",()=>{t.abortLastFetch()})})}}t.default=c});