@sankhyalabs/sankhyablocks 9.2.0-dev.14 → 9.2.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  3. package/dist/cjs/snk-application.cjs.entry.js +3 -0
  4. package/dist/cjs/snk-data-exporter.cjs.entry.js +1 -1
  5. package/dist/cjs/{snk-data-unit-72715da9.js → snk-data-unit-448fce74.js} +1 -11
  6. package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
  7. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +15 -25
  8. package/dist/cjs/snk-form_2.cjs.entry.js +1 -27
  9. package/dist/cjs/snk-grid.cjs.entry.js +7 -55
  10. package/dist/cjs/snk-personalized-filter.cjs.entry.js +2 -10
  11. package/dist/cjs/snk-simple-bar.cjs.entry.js +5 -5
  12. package/dist/cjs/snk-simple-crud.cjs.entry.js +8 -45
  13. package/dist/collection/components/snk-application/snk-application.js +2 -0
  14. package/dist/collection/components/snk-data-unit/snk-data-unit.js +28 -173
  15. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +63 -210
  16. package/dist/collection/components/snk-form/snk-form.js +22 -133
  17. package/dist/collection/components/snk-grid/snk-grid.js +83 -333
  18. package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.js +21 -83
  19. package/dist/collection/components/snk-simple-bar/snk-simple-bar.js +9 -9
  20. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +119 -414
  21. package/dist/collection/components/snk-taskbar/snk-taskbar.js +36 -102
  22. package/dist/collection/lib/licenses/sankhyalicense.module.js +1 -0
  23. package/dist/components/snk-application2.js +3 -0
  24. package/dist/components/snk-data-unit2.js +1 -11
  25. package/dist/components/snk-filter-bar2.js +15 -26
  26. package/dist/components/snk-form.js +2 -29
  27. package/dist/components/snk-grid2.js +7 -57
  28. package/dist/components/snk-personalized-filter2.js +2 -10
  29. package/dist/components/snk-simple-bar2.js +5 -5
  30. package/dist/components/snk-simple-crud2.js +8 -45
  31. package/dist/esm/loader.js +1 -1
  32. package/dist/esm/sankhyablocks.js +1 -1
  33. package/dist/esm/snk-application.entry.js +3 -0
  34. package/dist/esm/snk-data-exporter.entry.js +1 -1
  35. package/dist/esm/{snk-data-unit-d31619fb.js → snk-data-unit-b7e6e7a6.js} +1 -11
  36. package/dist/esm/snk-data-unit.entry.js +1 -1
  37. package/dist/esm/snk-filter-bar_4.entry.js +15 -25
  38. package/dist/esm/snk-form_2.entry.js +1 -27
  39. package/dist/esm/snk-grid.entry.js +7 -55
  40. package/dist/esm/snk-personalized-filter.entry.js +2 -10
  41. package/dist/esm/snk-simple-bar.entry.js +5 -5
  42. package/dist/esm/snk-simple-crud.entry.js +8 -45
  43. package/dist/sankhyablocks/p-012208e0.entry.js +1 -0
  44. package/dist/sankhyablocks/{p-a2e8c7a7.entry.js → p-158adf33.entry.js} +1 -1
  45. package/dist/sankhyablocks/p-81769310.entry.js +11 -0
  46. package/dist/sankhyablocks/{p-69b815ab.entry.js → p-8d1508aa.entry.js} +1 -1
  47. package/dist/sankhyablocks/p-a86eee47.entry.js +1 -0
  48. package/dist/sankhyablocks/p-fa18530e.entry.js +1 -0
  49. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  50. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +3 -46
  51. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +28 -45
  52. package/dist/types/components/snk-form/snk-form.d.ts +4 -29
  53. package/dist/types/components/snk-grid/snk-grid.d.ts +45 -104
  54. package/dist/types/components/snk-personalized-filter/snk-personalized-filter.d.ts +5 -53
  55. package/dist/types/components/snk-simple-bar/snk-simple-bar.d.ts +15 -15
  56. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +43 -100
  57. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +21 -23
  58. package/dist/types/components.d.ts +224 -511
  59. package/package.json +3 -4
  60. package/dist/sankhyablocks/p-51464e95.entry.js +0 -1
  61. package/dist/sankhyablocks/p-665dd170.entry.js +0 -11
  62. package/dist/sankhyablocks/p-6fa3d474.entry.js +0 -1
  63. package/dist/sankhyablocks/p-cf7063a4.entry.js +0 -1
  64. /package/dist/sankhyablocks/{p-8b601472.js → p-0e495575.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sankhyalabs/sankhyablocks",
3
- "version": "9.2.0-dev.14",
3
+ "version": "9.2.0-dev.2",
4
4
  "description": "Stencil Component Starter",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -21,10 +21,9 @@
21
21
  ],
22
22
  "scripts": {
23
23
  "prebuild": "(test -f ./src/components.d.ts && git checkout ./src/components.d.ts) || true",
24
- "build": "stencil build --docs && npm run formatdocs",
25
- "build.prod": "npm run prebuild && stencil build --docs --prod && npm run formatdocs",
24
+ "build": "stencil build --docs",
25
+ "build.prod": "npm run prebuild && stencil build --docs --prod",
26
26
  "build.with.peerdeps": "stencil build --docs --prod --force-peer-deps",
27
- "formatdocs": "node ./scripts/format-docs.js",
28
27
  "start": "stencil build --dev --watch --serve --force-peer-deps",
29
28
  "test": "stencil test --spec --e2e --coverage --silent --testResultsProcessor jest-sonar-reporter --runInBand",
30
29
  "test.dev": "stencil test --spec --e2e",
@@ -1 +0,0 @@
1
- import{r as i,c as t,h as s,F as e,g as a}from"./p-d8d8169b.js";import{KeyboardManager as r,Action as n,ElementIDUtils as o,ApplicationContext as d,StringUtils as h}from"@sankhyalabs/core";import{T as l}from"./p-7de79adf.js";import{C as c}from"./p-3dba3468.js";import{P as u,E as g}from"./p-0f3698af.js";import{T as m}from"./p-1a0caadb.js";import{s as k}from"./p-a349689a.js";import{C as v,S as p,a as T,R as f,b,c as C}from"./p-16fc4acd.js";import{SelectionMode as E}from"@sankhyalabs/core/dist/dataunit/DataUnit";import"./p-0dac8fef.js";import"./p-ba4979b4.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-b35574b5.js";import"./p-ff1990ad.js";import"./p-c6331595.js";import"./p-9019a32f.js";import{g as R}from"./p-7dd49d15.js";import{buildFieldSearch as O}from"@sankhyalabs/ezui/dist/collection/utils";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";import"./p-8f3f2306.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class _ extends v{getFilters(){var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.getAppliedFilters()}getOrders(){var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.getSort()}getResourceURI(){var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.name}getSelectedNumber(){return this.dataUnit.getSelectionInfo().length}getTotalRecords(){var i,t,s;const{total:e}=(null===(i=this.dataUnit)||void 0===i?void 0:i.getPaginationInfo())||{};return null!=e?e:null===(s=null===(t=this.dataUnit)||void 0===t?void 0:t.records)||void 0===s?void 0:s.length}getSelectedIDs(){return R(this.dataUnit)}getOffset(){return this.getExporterOffset(this.getPaginationInfo())}getPageSize(){var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.pageSize}getExportLimit(){return 5e3}getRecordID(){var i,t,s;return null===(s=null===(t=null===(i=this.dataUnit)||void 0===i?void 0:i.records)||void 0===t?void 0:t[0])||void 0===s?void 0:s.__record__id__}getPaginationInfo(){var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.getPaginationInfo()}getExporterOffset(i){if(null==i)return;const t=i.firstRecord;return t>0?t-1:t}}const I=class{constructor(s){i(this,s),this.actionClick=t(this,"actionClick",7),this.gridDoubleClick=t(this,"gridDoubleClick",7),this.componentReady=t(this,"componentReady",7),this._customEditors=new Map,this._customRenders=new Map,this._keyboardManager=new r,this._topTaskbarProcessor=new m({"snkGridTopTaskbar.regular":["FORM_MODE","CONFIGURATOR","INSERT"],"snkGridTopTaskbar.regular.secondary":["FORM_MODE","CONFIGURATOR","INSERT"],"snkGridTopTaskbar.regular.singleTaskbar":[],"snkGridTopTaskbar.finish_edition":["CANCEL","SAVE",this.handleAddFormMode()],"snkGridTopTaskbar.finish_edition.secondary":[],"snkGridTopTaskbar.finish_edition.singleTaskbar":[]}),this._headerTaskbarProcessor=new m({"snkGridHeaderTaskbar.unselected":["REFRESH","DATA_EXPORTER","ACTIONS_BUTTON","MORE_OPTIONS"],"snkGridHeaderTaskbar.selected":this.getGridHeaderSelectedBtns(),"snkGridHeaderTaskbar.detail.unselected":["REFRESH","MORE_OPTIONS"],"snkGridHeaderTaskbar.detail.selected":["UPDATE","ATTACH","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","REFRESH"],"snkGridHeaderTaskbar.singleTaskbar.unselected":["INSERT","FORM_MODE","CONFIGURATOR","REFRESH","DATA_EXPORTER","ACTIONS_BUTTON","MORE_OPTIONS"],"snkGridHeaderTaskbar.singleTaskbar.selected":["UPDATE","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","ATTACH","FORM_MODE","CONFIGURATOR","REFRESH","DATA_EXPORTER","ACTIONS_BUTTON"],"snkGridHeaderTaskbar.singleTaskbar.detail.unselected":["INSERT","FORM_MODE","CONFIGURATOR","REFRESH","MORE_OPTIONS"],"snkGridHeaderTaskbar.singleTaskbar.detail.selected":["UPDATE","ATTACH","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","FORM_MODE","CONFIGURATOR","REFRESH"],"snkGridHeaderTaskbar.singleTaskbar.finish_edition":["CANCEL","SAVE",this.handleAddFormMode()]}),this.dataUnitInterceptor={interceptAction:async i=>i.type===n.METADATA_LOADED?await this.interceptMetadataLoaded(i):i},this._dataUnit=void 0,this._dataState=void 0,this._gridConfig=void 0,this._popUpGridConfig=!1,this._showSnkFilterBar=!0,this._enableContinuousInsert=!1,this.columnFilterDataSource=new p,this.enableLockManagerLoadingComp=!1,this.enableLockManagerTaskbarClick=!1,this.configName=void 0,this.filterBarTitle=void 0,this.resourceID=void 0,this.selectionToastConfig=void 0,this.actionsList=void 0,this.isDetail=void 0,this.taskbarManager=void 0,this.statusResolver=void 0,this.multipleSelection=void 0,this.presentationMode=u.PRIMARY,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.recordsValidator=void 0,this.canEdit=!0,this.taskbarCustomContainerId=void 0,this.gridHeaderCustomSlotId="GRID_HEADER_CUSTOM_ELEMENTS",this.topTaskbarCustomSlotId="GRID_TASKBAR_CUSTOM_ELEMENTS",this.disablePersonalizedFilter=void 0,this.gridLegacyConfigName=void 0,this.filterBarLegacyConfigName=void 0,this.autoLoad=void 0,this.autoFocus=!0,this.enableGridInsert=!1,this.outlineMode=!1,this.suppressHorizontalScroll=!1,this.strategyExporter=g.SERVER_SIDE,this.useSearchColumn=!0,this.multipleEditionEnabled=!0,this.paginationCounterMode="auto",this.suppressCheckboxColumn=void 0,this.suppressFilterColumn=!1,this.compact=void 0}getGridHeaderSelectedBtns(){const i=[l.UPDATE,l.CLONE,l.REMOVE,l.MORE_OPTIONS,l.DIVIDER,l.ATTACH,l.FORM_MODE,l.CONFIGURATOR,l.REFRESH,l.DATA_EXPORTER,l.ACTIONS_BUTTON];return this.multipleEditionEnabled&&i.unshift(l.UPDATE_MULTIPLE),i}async refreshColumnFilterDataSource(){await this._grid.refreshColumnFilterDataSource()}reloadConfig(){this.loadConfig()}async showConfig(){null!=this._grid&&this.openGridConfig()}async hideConfig(){null!=this._grid&&this.closeGridConfig()}async setConfig(i){this.setGridConfig(i)}async reloadFilterBar(){var i;null===(i=this._snkFilterBar)||void 0===i||i.reload()}async getFilterBar(){return this._snkFilterBar}async addCustomEditor(i,t,s){if(this._grid)return void this._grid.addCustomEditor(i,t,s);const e=new Map(this._customEditors);e.set(i,{customEditor:t,detailContext:s}),this._customEditors=e}async addGridCustomRender(i,t,s){if(this._grid)return void this._grid.addGridCustomRender(i,t,s);const e=new Map(this._customRenders);e.set(i,{customRender:t,detailContext:s}),this._customRenders=e}async addCustomValueFormatter(i,t){this._grid.addCustomValueFormatter(i,t)}async removeCustomValueFormatter(i){this._grid.removeCustomValueFormatter(i)}async setFocus(){this._grid.setFocus()}async handleClick(i){var t;if(this.hasToBlockEvent(i)){if(i.preventDefault(),i.stopPropagation(),!await this._dataUnit.cancelEdition())return;const s=new i.constructor(i.type,i);null===(t=i.target)||void 0===t||t.dispatchEvent(s)}this._grid&&!this._grid.contains(i.target)&&this._grid.stopEdit()}hasToBlockEvent(i){var t;return(null===(t=this._snkFilterBar)||void 0===t?void 0:t.contains(i.target))&&this.enableGridInsert&&this._dataUnit.hasNewRecord()}async handleGridLegacyConfigName(i,t){i&&i!==t&&(this.addGridLegacyConfigName(),this.loadConfig())}handleAddFormMode(){return this.enableGridInsert?l.FORM_MODE:""}openGridConfig(){this._grid.getColumnsState().then((i=>{this._snkGridConfig.columns=i.filter((i=>i.name)),this._popUpGridConfig=!0}))}closeGridConfig(){this._popUpGridConfig=!1}setGridConfig(i){this._gridConfig=i,T.assertDefaultSorting(this._gridConfig,this._dataUnit)}fixColumNameCharset(i){try{return decodeURIComponent(escape(i))}catch(t){return i}}normalizeGridConfig(i){if(!i)return i;const t=i.columns.map((i=>Object.assign(Object.assign({},i),{name:this.fixColumNameCharset(i.name)})));return Object.assign(Object.assign({},i),{columns:t})}loadConfig(){c.loadGridConfig(this.configName,this.resourceID).then((i=>{this.setGridConfig(this.normalizeGridConfig(i))})).catch((i=>{console.warn(i)}))}addGridLegacyConfigName(){this.gridLegacyConfigName&&this.configName&&c.addGridLegacyConfig(this.configName,this.gridLegacyConfigName)}gridConfigChangeHandler(i){const t=this.normalizeGridConfig(i.detail);c.saveGridConfig(t,this.configName,this.resourceID),i.stopPropagation()}modalConfigChangeHandler(i){const t=this.normalizeGridConfig(i.detail);this._grid.setColumnsState(t.columns).then((()=>{this.setGridConfig(t),this.closeGridConfig(),this.dataExporterProviderStore()})),i.stopPropagation()}async dataExporterProviderStore(){const i=this.strategyExporter===g.SERVER_SIDE?new _(this._dataUnit,this._grid):new C(this._dataUnit,this._grid);k.set("exporterProviders",Object.assign(Object.assign({},k.get("exporterProviders")),{[this.configName]:i}))}addElementID(){o.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}loadGridCustomFormatters(i){i&&this._grid&&i.forEach((i=>{var t;(null===(t=i.properties)||void 0===t?void 0:t.rm_precision)&&this.addCustomValueFormatter(i.name,this._rmPrecisionCustomValueFormatter)}))}async interceptMetadataLoaded(i){return this.loadGridCustomFormatters(i.payload.fields),i}finishLoading(){this._dataUnit.addInterceptor(this.dataUnitInterceptor),T.assertDefaultSorting(this._gridConfig,this._dataUnit),this.addElementID(),null!=this.columnFilterDataSource&&(this.columnFilterDataSource.setApplication(this._application),this.columnFilterDataSource.setDataUnit(this._dataUnit))}setCustomRenders(){if(this._grid)for(const[i,t]of this._customRenders)this._grid.addGridCustomRender(i,t.customRender,t.detailContext),this._customRenders.delete(i)}setCustomEditors(){if(this._grid)for(const[i,t]of this._customEditors)this._grid.addCustomEditor(i,t.customEditor,t.detailContext),this._customEditors.delete(i)}componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__");let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._dataUnit=this._snkDataUnit.dataUnit,this._dataUnit?this.finishLoading():this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail,this.finishLoading()})),this.messagesBuilder||(this.messagesBuilder=this._snkDataUnit.messagesBuilder),this._snkDataUnit.addEventListener("dataStateChange",this.handleDataStateChange.bind(this)),this._snkDataUnit.addEventListener("cancelEdition",(()=>{var i;(null===(i=this._dataState)||void 0===i?void 0:i.recordsIsEmpty)&&this._dataUnit.clearSelection()}));break}i=i.parentElement}this._rmPrecisionCustomValueFormatter=new f,this.addGridLegacyConfigName(),this.loadConfig(),this._continuousInsertUtils=new b(this._application,this.resourceID,this.configName),this.enableGridInsert&&this._continuousInsertUtils.getConfig().then((i=>this._enableContinuousInsert=i))}componentDidRender(){var i,t;this._rmPrecisionCustomValueFormatter.setGrid(this._grid),this.loadGridCustomFormatters(null===(t=null===(i=this._dataUnit)||void 0===i?void 0:i.metadata)||void 0===t?void 0:t.fields),this.setCustomRenders(),this.setCustomEditors()}async handleDataStateChange(i){this._dataState=i.detail,this._rmPrecisionCustomValueFormatter.setDataState(this._dataState)}getHeaderDisabledButtons(){var i;const t=[];return(null===(i=this._dataState)||void 0===i?void 0:i.selectionInfo)&&(this._dataState.selectionInfo.length>1&&t.push(l.CLONE,l.ATTACH,l.UPDATE),this._dataState.selectionInfo.isAllRecords()&&t.push(l.REMOVE)),t}getInvisibleButtons(){var i,t;let s=[];return this._dataUnit&&0!==this._dataUnit.records.length||s.push(l.DATA_EXPORTER),(null===(i=this._dataState)||void 0===i?void 0:i.selectionInfo.mode)===E.ALL_RECORDS&&s.push(l.ACTIONS_BUTTON),1===(null===(t=this._dataState)||void 0===t?void 0:t.selectionInfo.length)&&s.push(l.UPDATE_MULTIPLE),s}componentWillRender(){const i=this.getInvisibleButtons();this._headerTaskbarProcessor.process(this.getHeaderTaskbarId(),this.taskbarManager,this._dataState,this.getHeaderDisabledButtons(),i),this._topTaskbarProcessor.process(this.getTopTaskBarId(),this.taskbarManager,this._dataState,void 0,i),this.dataExporterProviderStore()}getHeaderTaskbarId(){var i,t;const s=this._dataState&&!!(null===(i=this._dataState.selectionInfo)||void 0===i?void 0:i.length),e={primary:this.isDetail?"snkGridHeaderTaskbar.detail":"snkGridHeaderTaskbar",secondary:this.isDetail?"snkGridHeaderTaskbar.detail":"snkGridHeaderTaskbar",singleTaskbar:this.isDetail?"snkGridHeaderTaskbar.singleTaskbar.detail":"snkGridHeaderTaskbar.singleTaskbar"}[this.presentationMode];let a=s?`${e}.selected`:`${e}.unselected`;return(null===(t=this._dataState)||void 0===t?void 0:t.isDirty)&&this.presentationMode===u.SINGLE_TASKBAR&&(a="snkGridHeaderTaskbar.singleTaskbar.finish_edition"),a}getTopTaskBarId(){var i;const t={primary:"",secondary:".secondary",singleTaskbar:".singleTaskbar"}[this.presentationMode];return(null===(i=this._dataState)||void 0===i?void 0:i.isDirty)?`snkGridTopTaskbar.finish_edition${t}`:`snkGridTopTaskbar.regular${t}`}getPrimaryButton(){return{primary:"INSERT",secondary:"",singleTaskbar:"INSERT"}[this.presentationMode]}getColumnSearch(i){return null!=this._columnSearch||(this._columnSearch=O(i,(({argument:i})=>new Promise((t=>{this._grid.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(i=>{null!=i&&this._grid.locateColumn(i.value)}))),this._columnSearch}getActionsList(){const i=[];if(this.enableGridInsert&&i.push(this._continuousInsertUtils.actionContinuousInsert(this._enableContinuousInsert,(()=>{this._enableContinuousInsert=!this._enableContinuousInsert,this._continuousInsertUtils.handleSaveConfig(this._enableContinuousInsert)}))),this.isGridInsertActive())return i;if(null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions){const t=this.getTopTaskBarId();return i.concat(this.taskbarManager.getMoreOptions(t,this.configName,this._dataState,this.actionsList))}return i.concat(this.actionsList)}getActionsSettingsList(){return[{value:h.generateUUID(),label:this.messagesBuilder.getMessage("snkGrid.findColumn",{}),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>this.getColumnSearch(t)}]}handleFilterConfigUpdated(i){this._showSnkFilterBar=!!i.length&&(1!==i.length||"PERSONALIZED_FILTER_GROUP"!==i[0].id||i[0].groupedItems.length>0)}getGridHeaderButtons(){return this.isGridInsertActive()?l.MORE_OPTIONS:this._headerTaskbarProcessor.buttons}isGridInsertActive(){return this.enableGridInsert&&this._dataUnit.hasNewRecord()}render(){if(this._dataUnit)return s("div",{class:"snk-grid__container ez-flex ez-flex--column ez-flex-item--auto ez-padding--large ez-box--no-outline",tabindex:"0"},s("div",{class:"snk-grid__header ez-margin-bottom--extra-small"},this._showSnkFilterBar&&s(e,null,s("snk-filter-bar",{ref:i=>this._snkFilterBar=i,title:this.filterBarTitle,dataUnit:this._dataUnit,"data-element-id":"gridFilter",class:"snk-grid__filter-bar ez-align--top",configName:this.configName,messagesBuilder:this.messagesBuilder,resourceID:this.resourceID,onConfigUpdated:i=>this.handleFilterConfigUpdated(i.detail),disablePersonalizedFilter:this.disablePersonalizedFilter,filterBarLegacyConfigName:this.filterBarLegacyConfigName,autoLoad:this.autoLoad,enableLockManagerLoadingComp:this.enableLockManagerLoadingComp}),s("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider"})),s("snk-taskbar",{class:"ez-padding-left--medium ez-padding-top--extra-small","data-element-id":"grid_top",key:"topTaskbar",configName:this.configName,dataUnit:this._dataUnit,messagesBuilder:this.messagesBuilder,buttons:this._topTaskbarProcessor.buttons,disabledButtons:this._topTaskbarProcessor.disabledButtons,customButtons:this._topTaskbarProcessor.customButtons,primaryButton:this.getPrimaryButton(),resourceID:this.resourceID,customContainerId:this.taskbarCustomContainerId,customSlotId:this.topTaskbarCustomSlotId,overflowStrategy:"none",actionsSettingsList:this.getActionsSettingsList()},s("slot",{name:this.topTaskbarCustomSlotId}))),s("ez-grid",{ref:i=>this._grid=i,class:(this.presentationMode===u.SECONDARY?"snk-grid-container__without-shadow ":"")+"snk-grid__table","data-element-id":"embedded",dataUnit:this._dataUnit,key:"grid-"+this._snkDataUnit.entityName,config:this._gridConfig,onConfigChange:i=>{this.gridConfigChangeHandler(i)},onEzDoubleClick:i=>this.gridDoubleClick.emit(i.detail),statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,columnfilterDataSource:this.columnFilterDataSource,selectionToastConfig:this.selectionToastConfig,useEnterLikeTab:this.useEnterLikeTab,recordsValidator:this.recordsValidator,canEdit:this.canEdit,autoFocus:this.autoFocus,enableGridInsert:this.enableGridInsert,enableContinuousInsert:this._enableContinuousInsert,enableLockManagerTaskbarClick:this.enableLockManagerTaskbarClick,enableLockManagerLoadingComp:this.enableLockManagerLoadingComp,outlineMode:this.outlineMode,useSearchColumn:this.useSearchColumn,suppressHorizontalScroll:this.suppressHorizontalScroll,paginationCounterMode:this.paginationCounterMode,suppressCheckboxColumn:this.suppressCheckboxColumn,compact:this.compact},s("snk-taskbar",{id:"teste",dataUnit:this._dataUnit,configName:this.configName,messagesBuilder:this.messagesBuilder,"data-element-id":"grid_left",buttons:this.getGridHeaderButtons(),presentationMode:this.presentationMode,disabledButtons:this._headerTaskbarProcessor.disabledButtons,customButtons:this._headerTaskbarProcessor.customButtons,slot:"leftButtons",actionsList:this.getActionsList(),primaryButton:this.getPrimaryButton(),resourceID:this.resourceID,customContainerId:this.taskbarCustomContainerId,customSlotId:this.gridHeaderCustomSlotId,actionsSettingsList:this.getActionsSettingsList()},s("slot",{name:this.gridHeaderCustomSlotId}))),s("div",{class:"ez-col ez-col--sd-12 snk-grid-container__footer"},s("slot",{name:"SnkGridFooter"})),s("ez-popup",{size:"medium",heightMode:"auto",useHeader:!1,opened:this._popUpGridConfig,onEzClosePopup:()=>this.closeGridConfig()},s("snk-grid-config",{ref:i=>this._snkGridConfig=i,config:this._gridConfig,"data-element-id":this._element.getAttribute(o.DATA_ELEMENT_ID_ATTRIBUTE_NAME),selectedIndex:0,configName:this.configName,onConfigChange:i=>this.modalConfigChangeHandler(i),onConfigCancel:()=>this.closeGridConfig(),resourceID:this.resourceID})))}get _element(){return a(this)}static get watchers(){return{gridLegacyConfigName:["handleGridLegacyConfigName"]}}};I.style=".sc-snk-grid-h{--snk-grid-min-height:300px;--snk-grid-padding:var(--space--small)}.snk-grid__container.sc-snk-grid{display:flex;height:100%;width:100%;padding:var(--snk-grid-padding);outline:none}.snk-grid__header.sc-snk-grid{width:100%;display:flex;flex-wrap:nowrap;justify-content:flex-end}.snk-grid__filter-bar.sc-snk-grid{width:100%}.snk-grid__header-divider.sc-snk-grid{margin-bottom:var(--space--medium)}.snk-grid__table.sc-snk-grid{min-height:var(--snk-grid-min-height)}.snk-grid-container__without-shadow.sc-snk-grid{--ezgrid__container--shadow:unset}.snk-grid-container__footer.sc-snk-grid{background-color:var(--background--xlight, #FFF);border-radius:0 0 var(--border--radius-medium) var(--border--radius-medium);box-shadow:var(--shadow--small)}";export{I as snk_grid}
@@ -1,11 +0,0 @@
1
- import{r as t,c as e,h as i,H as s,g as n}from"./p-d8d8169b.js";import{DateUtils as r,StringUtils as a,ObjectUtils as o,WaitingChangeException as h,SilentException as l,WarningException as c,ErrorException as d,ElementIDUtils as u,SearchUtils as p,ArrayUtils as m,KeyboardManager as g,OnboardingUtils as w,DependencyType as y,ApplicationContext as v,DataType as f,ErrorTracking as P,UserAgentUtils as k,LockManager as z,LockManagerOperation as _}from"@sankhyalabs/core";import{ApplicationUtils as x}from"@sankhyalabs/ezui/dist/collection/utils";import{C as A}from"./p-3dba3468.js";import{d as S,D as b,U as I,S as T}from"./p-0dac8fef.js";import{A as N,a as L}from"./p-c9e6d720.js";import{P as E,D as C}from"./p-b35574b5.js";import{P as O}from"./p-ba4979b4.js";import{T as D}from"./p-9019a32f.js";import"./p-0f3698af.js";import"./p-ff1990ad.js";import{F as R}from"./p-c6331595.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class M{static webConnectionCaller(t,e,i){var s;null===(s=window.AppletCaller)||void 0===s||s.webConnectionCaller(t,e,i)}}const F=U;function U(t,e){const i=$();return(U=function(t){return i[t-=378]})(t,e)}function $(){const t=["true","863GKWjmo","parse","56355fjjjAm","isSup","putAccess","4324480sjuCdS","hasOwnProperty","239748okvJLB","name","6055770tXeRaU","actions","forEach","7RPRvzn","1042CHxkUw","2988126NIwRMm","20MTNzmH","authorizationSf","item","string","hasAccess","isArray","Objeto não pode ser indefinido.","3071943fWslZp","parseFromJSON"];return($=function(){return t})()}!function(){const t=U,e=$();for(;;)try{if(281287==parseInt(t(399))/1*(-parseInt(t(387))/2)+-parseInt(t(401))/3+parseInt(t(381))/4*(-parseInt(t(389))/5)+parseInt(t(388))/6*(-parseInt(t(386))/7)+parseInt(t(379))/8+parseInt(t(396))/9+parseInt(t(383))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class j{[F(397)](t){const e=F;if(typeof(t=utxt(t[e(390)]))==e(392)&&(t=JSON[e(400)](t)),null==t)throw Error(e(395));const i=new H("S"===t[e(402)]||!0===t[e(402)]);return Array[e(394)](t[e(391)])&&t[e(391)][e(385)]((t=>i.putAccess(t[e(382)],String(t.status)==e(398)))),i}}class H{constructor(t){const e=F;this.isSup=t,this[e(384)]={}}[F(378)](t,e){this[F(384)][t]=e}[F(393)](t){const e=F;if(this[e(402)])return!0;let i=!0;return this[e(384)][e(380)](t)&&(i=this.actions[t]),i}isUserSup(){return this.isSup}}class B{constructor(){this._embeddedParams=new Map,this._cachedParams=new Map,this.templateByQuery=new Map;try{if(null!=window.MGE_PARAMS){atob(window.MGE_PARAMS).split("__;__").forEach((t=>{const[e,i]=t.split("__=__");this._embeddedParams.set(e,i)}))}}catch(t){console.error("Problemas ao obter parâmetros embarcados"),console.error(t)}this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",S.gql`query($name: String!) {
2
- $queryAlias$: fetchResource(name: $name){
3
- name
4
- resource
5
- }
6
- }`)}async getParam(t){if(this._embeddedParams.has(t))return Promise.resolve(this._embeddedParams.get(t));if(this._cachedParams.has(t))return this._cachedParams.get(t);const e=`param://application?params=${t}`,i=await b.get().callGraphQL({values:{name:e},query:this.templateByQuery.get("fetchParam")});return this._cachedParams.set(t,i),i}async asString(t){const e=await this.getParam(t);return this.getValue(e)}async asInteger(t){const e=await this.getParam(t);return parseInt(this.getValue(e))}async asFloat(t){const e=await this.getParam(t);return parseFloat(this.getValue(e))}async asBoolean(t){const e=await this.getParam(t);return"S"===this.getValue(e)}async asDate(t){const e=await this.getParam(t);return r.strToDate(this.getValue(e))}async getBatchParams(t){const e=await this.getParam(t.join(",")),i={};return e.forEach((t=>i[t.name]=t.resource)),i}getValue(t={}){if(Array.isArray(t)&&t.length>0&&(t=t[0]),"string"==typeof t)return t;if(a.isEmpty(t.resource))return"";try{const e=o.stringToObject(t.resource),[i]=Object.keys(e);return e[i]}catch(t){console.warn("Erro ao converter string JSON.")}}}class q{constructor(){this.templateByQuery=new Map,this.cancel=[],this.buildTemplates()}buildTemplates(){this.templateByQuery.set("fetchTotals",S.gql`query($filters: [InputFilter!] $name: String!) {
7
- $queryAlias$: fetchTotals(name: $name, filters: $filters ){
8
- name
9
- value
10
- }
11
- }`)}fetchTotals(t,e,i=[]){const s=`${t}_${e}`,n=this.cancel.findIndex((t=>t[s]));return n>=0&&(this.cancel[n][s](),this.cancel.splice(n,1)),Promise.race([new Promise((t=>this.cancel.push({[s]:t}))),this.getTotals(t,e,i)]).then((t=>{let e=new Map;if(t){e=t;const i=this.cancel.findIndex((t=>t[s]));i>=0&&this.cancel.splice(i,1)}return e}))}getTotals(t,e,i=[]){return new Promise(((s,n)=>{b.get().callGraphQL({query:this.templateByQuery.get("fetchTotals"),values:{name:`totals://${t}/${e}`,filters:i}}).then((t=>{if(t.length>0){const e=new Map;return t.forEach((t=>e.set(t.name,parseFloat(t.value)))),s(e)}return n("Não foi possível recuperar os totalizadores")})).catch(n)}))}}var K;class V{static openAppActivity(t,e){var i;null===(i=window.workspace)||void 0===i||i.openAppActivity(t,e)}static getAppLabel(t){if(null!=(null===window||void 0===window?void 0:window.workspace))return null==window.workspace.getAppLabel&&(window.workspace.getAppLabel=t=>(t||"").split(".").pop()),window.workspace.getAppLabel(t)}static setScreenToUseV3Layout(){var t;null===(t=window.workspace)||void 0===t||t.setScreenToUseV3Layout()}static setScreenToUseOldLayout(){var t;null===(t=window.workspace)||void 0===t||t.setScreenToUseOldLayout()}static showDesktop(){var t,e;null===(e=null===(t=window.workspace)||void 0===t?void 0:t.showDesktop)||void 0===e||e.call(t)}static searchApp(){var t,e;null===(e=null===(t=window.workspace)||void 0===t?void 0:t.searchApp)||void 0===e||e.call(t)}static openHelp(){var t,e;null===(e=null===(t=window.workspace)||void 0===t?void 0:t.openHelp)||void 0===e||e.call(t)}static applicationClick(){var t,e;(null===(t=window.workspace)||void 0===t?void 0:t.applicationClick)&&(null===(e=window.workspace)||void 0===e||e.applicationClick())}}V.resourceID=null===(K=window.workspace)||void 0===K?void 0:K.resourceID;class W{constructor(t){this._app=t,window.addEventListener("error",(t=>this.errorHandler(t))),window.addEventListener("unhandledrejection",(t=>this.rejectionHandler(t)))}getMessage(t,e){return this._app.messagesBuilder.getMessage(t,e)}rejectionHandler(t){const e=t.reason;e instanceof h||(e?this.processException(e):this._app.isDebugMode().then((t=>{t&&this._app.error(this.getMessage("snkErrorHandler.title.promiseRejected"),this.getMessage("snkErrorHandler.message.undeterminedPromiseRejection"))})))}errorHandler(t){this.processException(t.error)}buildErrorCodeHTML(t){return`<br><a href="#" onclick="try{window.workspace.openHelp('_tbcode:${t}')} catch(e){alert('${this.getMessage("snkErrorHandler.message.cannotOpenHelp")}');}">${this.getMessage("snkErrorHandler.errorCode.label")}${t}</a>`}processException(t){t.errorCode&&(t.message+=this.buildErrorCodeHTML(t.errorCode)),t instanceof l?console.warn(this.getMessage("snkErrorHandler.message.silentExceptionIgnored"),t):t instanceof h||t instanceof c?this._app.alert(t.title,t.message):t instanceof d?this._app.error(t.title,t.message):this._app.isDebugMode().then((e=>{if(e)if(t instanceof Error)this._app.error(t.name,t.message);else{const e=(null==t?void 0:t.title)||this.getMessage("snkErrorHandler.title.errorDetected",void 0),i="string"==typeof t?t:t.message||`${this.getMessage("snkErrorHandler.error.internal")} "${o.objectToString(t)}"`;this._app.error(e,i)}}))}}class G{constructor(){this._debounceTime=1500,this.requests=new Map,this.requestsLoadingBar=[]}onRequestStart(t){if(t.url.includes("quietMode=true"))return;this.requestsLoadingBar.push(t.requestId);const e=setTimeout((()=>{this.ezLoadingBar.show()}),this._debounceTime);this.requests.set(t.requestId,e)}onRequestEnd(t){var e,i,s;const n=this.requests.get(t.requestId);clearTimeout(n),(null===(e=this.requestsLoadingBar)||void 0===e?void 0:e.includes(t.requestId))&&(this.requestsLoadingBar=null===(i=this.requestsLoadingBar)||void 0===i?void 0:i.filter((e=>e!==t.requestId)),!this.requestsLoadingBar.length&&(null===(s=this.ezLoadingBar)||void 0===s||s.hide()))}}class J{constructor(){this._debounceTime=1e3,this._ignoredNameTypes=["totals"],this._countRequest=0}onRequestStart(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest++,this.ezLoadingBar.show(),this._timerLoading&&clearTimeout(this._timerLoading))}onRequestEnd(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest--,this._timerLoading=setTimeout((()=>{this._countRequest<=0&&this.ezLoadingBar.hide()}),this._debounceTime))}isIgnoreLoadingOnRequest(t){if(null==t)return!1;if(t.url.includes("quietMode=true"))return!0;if(null==t.requestBody)return!1;if(1==t.requestBody.length){const{name:e}=t.requestBody[0].variables;if(e){const t=e.split(":");return this._ignoredNameTypes.indexOf(t[0])>=0}}return!1}}class Y{static create({strategy:t}){switch(t){case"request_name":return new J;case"request_time":return new G;default:throw new Error("Strategy not found")}}}const Z=["<img","<svg"];class X{constructor(){this._config=null,this.listeners=[]}static getInstance(){return X.instance||(X.instance=new X),X.instance}get config(){return this._config}setConfig(t){this._config=t,this.notifyListeners()}onConfigChange(t){this.listeners.push(t)}notifyListeners(){this.listeners.forEach((t=>t(this._config)))}}const Q=class{constructor(i){t(this,i),this.applicationLoaded=e(this,"applicationLoaded",7),this.applicationLoading=e(this,"applicationLoading",7),this.NEW_VERSION_POPUP_LOCKER="NEW_VERSION_POPUP_LOCKER",this.FEATURE_FLAG_CACHE_DURATION=36e5,this._authPromises=[],this._keyboardManager=new g,this._waitingAppReady=new Array,this._duCache=new Map,this._duPromises=new Map,this._requestListener=Y.create({strategy:"request_time"}),this._maxTimerAppLoading=1e4,this._featureFlagsCache=new Map,this._isBrowserTypeElectron=!1,this._pendingActions=new Map,this._loadPkParameter=null,this._isLoadedByPk=!1,this._formConfigFetcher=new R,this._LayoutFormConfigSingleton=X.getInstance(),this._applicationReady=!1,this._templateSkeleton=D.GRID,this._activeScrimWindow=!1,this.enableLockManagerLoadingApp=void 0,this.messagesBuilder=void 0,this.configName=void 0,this.gridLegacyConfigName=void 0,this.formLegacyConfigName=void 0,this.loadByPK=void 0}async processPendingActions(t){const e=this._pendingActions.get(t);e&&e.length&&(e.forEach((t=>t())),this._pendingActions.set(t,[]))}get parameters(){return this._parameters||(this._parameters=new B),this._parameters}async getAuth(t){return null==t?this.getApplicationAuth():new Promise(((e,i)=>{this.authFetcher.getData(t).then((t=>{e(t)})).catch((t=>{i(t)}))}))}async getApplicationAuth(){return this._auth?Promise.resolve(this._auth):new Promise(((t,e)=>{const i=this._authPromises.length>0;this._authPromises.push(new tt(t,e)),i||this.authFetcher.getData(this.applicationResourceID).then((t=>{for(this._auth=t;this._authPromises.length>0;)this._authPromises.pop().resolve(this._auth)})).catch((t=>{for(;this._authPromises.length>0;)this._authPromises.pop().reject(t)}))}))}watchPropHandler(t,e){t&&this._loadPkParameter&&(this.loadByPK(this._loadPkParameter.pk,this._loadPkParameter.redirect),this._loadPkParameter=null)}async getKeyboardManager(){return Promise.resolve(this._keyboardManager)}async getLayoutFormConfig(){return Promise.resolve(this._LayoutFormConfigSingleton)}async isUserSup(){return new Promise(((t,e)=>{this.getAuth().then((i=>{this.getAuthList(i).then((e=>{t(e.isSup)})).catch((t=>e(t)))}))}))}async addPendingAction(t,e){var i;const s=null!==(i=this._pendingActions.get(t))&&void 0!==i?i:[];this._pendingActions.set(t,[...s,e])}async callServiceBroker(t,e,i){return b.get().callServiceBroker(t,e,i)}async initOnboarding(t){this.hasToShowNewVersionPopup()?await this.addPendingAction(this.NEW_VERSION_POPUP_LOCKER,(()=>this.doInitOnboarding(t))):this.doInitOnboarding(t)}doInitOnboarding(t){w.getInstance().init(t,window.envContext)}async hasAccess(t,e){return new Promise(((i,s)=>{this.getAuth(e).then((e=>{this.getAuthList(e).then((e=>{i(e.isSup||e.actions[t])})).catch((t=>s(t)))}))}))}async getAllAccess(t){return new Promise(((e,i)=>{this.getAuth(t).then((t=>{this.getAuthList(t).then((t=>{const i={};i.isSup=t.isSup,Object.entries(N).forEach((e=>{i[e[0]]=e[1]===N.CLONE?t.actions[N.INSERT]&&t.actions[N.CLONE]||!1:t.actions[e[1]]||!1})),e(i)})).catch((t=>i(t)))}))}))}async getStringParam(t){return this.parameters.asString(t)}async getIntParam(t){return this.parameters.asInteger(t)}async getFloatParam(t){return this.parameters.asFloat(t)}async getBooleanParam(t){return this.parameters.asBoolean(t)}async getDateParam(t){return this.parameters.asDate(t)}async showPopUp(t,e="full",i=!0,s){this.clearContent(this._popUp),this._popUp.addEventListener("ezClosePopup",(()=>{s()}),{once:!0}),this._popUp.appendChild(t),this._popUp.opened=!0,this._popUp.heightMode=e,this._popUp.useHeader=i,"EZ-MODAL-CONTAINER"===t.tagName&&(this._popUp.useHeader=!1)}async showModal(t){this.clearContent(this._rightModal),this._rightModal.appendChild(t),this._rightModal.opened=!0}showAlerts(t){return x.showAlerts({alerts:t})}async closeModal(){this.clearContent(this._rightModal),this._rightModal.opened=!1}async closePopUp(){this.clearContent(this._popUp),this._popUp.opened=!1,this._popUp.useHeader=!0,this._popUp.heightMode="full"}async temOpcional(t){const e=t.split(",");return new Promise(((t,i)=>{this.getAttributeFromHTMLWrapper("opc0009").then((s=>{"1"===s?t(!0):Promise.all(e.map((t=>this.getAttributeFromHTMLWrapper("opc"+t)))).then((e=>{t(e.includes("1"))})).catch((t=>{i(t)}))})).catch((t=>{i(t)}))}))}async getConfig(t){let e={serviceName:"SystemUtilsSP.getConf",requestBody:{config:{chave:t,tipo:"T"}}};return new Promise(((t,i)=>{b.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(e)).then((e=>{var i;return t(null===(i=e.config)||void 0===i?void 0:i.data)})).catch((t=>i(t)))}))}async isFeatureActive(t){const e=Date.now();let i={serviceName:"SystemUtilsSP.featureIsActive",requestBody:{featureName:t}};if(this._featureFlagsCache.get(t)&&e<this._featureFlagsCache.get(t).expires)return Promise.resolve(this._featureFlagsCache.get(t).isActive);const s=(await b.get().callServiceBroker("SystemUtilsSP.featureIsActive",JSON.stringify(i))).isActive;return this._featureFlagsCache.set(t,{isActive:s,expires:e+this.FEATURE_FLAG_CACHE_DURATION}),s}async saveConfig(t,e){let i={serviceName:"SystemUtilsSP.saveConf",requestBody:{config:{chave:t,tipo:"T",data:e}}};return new Promise(((t,e)=>{b.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(i)).then((e=>t(e))).catch((t=>e(t)))}))}async getAttributeFromHTMLWrapper(t){return Promise.resolve(window[t])}async openApp(t,e){V.openAppActivity(t,e)}async webConnection(t,e,i){this.getStringParam(t).then((t=>{M.webConnectionCaller(t,e,i)}))}getDuPromissesStack(t){let e;return t&&(e=this._duPromises.get(t),e||(e=[],this._duPromises.set(t,e))),e||[]}async createDataunit(t,e,i,s,n){return null==n&&(n=this.applicationResourceID),new Promise(((r,a)=>{const o=this.getDuPromissesStack(e),h=o.length>0;if(o.push(new tt(r,a)),!h){const r=this.dataUnitFetcher.getDataUnit(t,n,i,s);r.loadMetadata().then((()=>{this.processResolveDataUnit(r,e,o)})).catch((t=>{for(;o.length>0;)o.pop().reject(t)}))}}))}processResolveDataUnit(t,e,i){for(e&&this.updateDataunitCache(void 0,e,t);i.length>0;)i.pop().resolve(t)}async updateDataunitCache(t,e,i){t&&this._duCache.delete(t),this._duCache.set(e,i)}async getDataUnit(t,e,i,s,n){return new Promise(((r,a)=>{const o=this._duCache.get(e);o?r(o):this.createDataunit(t,e,i,s,n).then((t=>{r(t)})).catch((t=>a(t)))}))}async addClientEvent(t,e){return new Promise((i=>{b.addClientEvent(t,e),i()}))}async removeClientEvent(t){return new Promise((e=>{b.removeClientEvent(t),e()}))}async hasClientEvent(t){return new Promise((e=>{e(b.hasClientEvent(t))}))}get applicationResourceID(){return this._applicationResourceID||(this._applicationResourceID=this.urlParams.get("workspaceResourceID")||this.urlParams.get("resourceID")||V.resourceID||"unknown.resource.id"),this._applicationResourceID}async getResourceID(){return Promise.resolve(this.applicationResourceID)}async getUserID(){return Promise.resolve(window.UID)}async alert(t,e,i,s){return x.alert(t,e,i,s)}async error(t,e,i,s){return x.error(t,e,i,s)}async success(t,e,i,s){return x.success(t,e,i,s)}async message(t,e,i,s){return x.message(t,e,i,s)}async confirm(t,e,i,s,n){return x.confirm(t,e,i,s,n)}async info(t,e){return x.info(t,e)}async loadTotals(t,e,i){return this.totalsFetcher.fetchTotals(t,e,i)}async isLoadedByPk(){return Promise.resolve(this._isLoadedByPk)}async preloadMangerRemoveRecord(t,e){const i=e.map((t=>({__record__id__:t})));E.removeRecords(t,i)}getCountSkeleton(t,e,i){i=i||160;const s=window.innerHeight-i;return Math.floor(s/(t+(e||10)))-1||1}getSkeletonRandomWidth(){return`${Math.floor(71*Math.random())+30}%`}async getAuthList(t){return await(new j).parseFromJSON(t)}get urlParams(){return this._urlParams||(this._urlParams=I.getQueryParams(location.search)),this._urlParams}getMessage(t,e){var i;return null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage(t,e)}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new C),this._dataUnitFetcher}get totalsFetcher(){return this._totalsFetcher||(this._totalsFetcher=new q),this._totalsFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new O),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new L),this._authFetcher}async executeSearch(t,e,i,s){const n=null==i?void 0:i.getField(e);if(n){const{mode:e,argument:r}=t,{ENTITYNAME:a,CODEFIELD:o,DESCRIPTIONFIELD:h,ROOTENTITY:l,DESCRIPTIONENTITY:c,ISHIERARCHYENTITY:d}=n.properties,u=n.dependencies;let p;const m={rootEntity:l,descriptionFieldName:h,codeFieldName:o,showInactives:!1,dataUnitId:i.dataUnitId};null==u||u.filter((t=>t.masterFields)).forEach((t=>{var e;t.type===y.SEARCHING&&(null===(e=t.masterFields)||void 0===e?void 0:e.length)>0&&(p={expression:t.expression,params:t.masterFields.map((t=>{const e=i.getField(t),s=(null==e?void 0:e.dataType)||f.TEXT,n=i.getFieldValue(t);if(null==n)throw this.alert(this.getMessage("snkApplication.search.error.title"),this.getMessage("snkApplication.search.error.requiredField",{fieldLabel:e.label})),new Error(this.getMessage("snkApplication.search.error.requiredField",{fieldLabel:e.label}));return{name:t,value:n,dataType:s}}))})}));const g={entity:a,entityDescription:c,isHierarchyEntity:d,criteria:p,searchOptions:m,allowsNonAnalytic:null==s?void 0:s.allowsNonAnalytic};return(null==s?void 0:s.useSearchPlus)?this.executePreparedSearchPlus(e,r,g):this.executePreparedSearch(e,r,g)}}filterInvalidFields(t,e,i){return t.fieldsMetadata.filter((s=>{let n=!a.isEmpty(e[s.fieldName])&&!1!==s.visible&&"B"!==s.type&&t.pkField!==s.fieldName&&t.descriptionField!==s.fieldName&&(s.isPrimaryKey||!s.isLinkField)&&!("S"===s.type&&"H"===s.presentationType);return n&&(i[s.fieldName]=s),("string"!=typeof e[s.fieldName]||!(e[s.fieldName].indexOf("<img")>-1||e[s.fieldName].indexOf("<svg")>-1))&&n}))}filterMathFields(t,e,i,s){return t&&Array.isArray(t)&&t.forEach((t=>{let i=m.removeReference(e,s[t]);i&&e.unshift(i)})),e=e.slice(0,i)}builOptionItem(t,e,i,s,n){var r;return{value:a.highlightValue(t,e.__matchFields,null===(r=e[n])||void 0===r?void 0:r.toString(),i,!0),label:s?a.highlightValue(t,e.__matchFields,e[s],i,!0):"",details:p.buildDetails(t,i,e)}}async executePreparedSearchPlus(t,e,i){return await this.executePreparedSearch(t,e,Object.assign(Object.assign({},i),{useSearchPlus:!0}))}async executePreparedSearch(t,e,i){const s={},{entity:n,entityDescription:r,criteria:h,searchOptions:l,isHierarchyEntity:c,allowsNonAnalytic:d,useSearchPlus:g}=i;return g?(async(t,e,i,s,n)=>{var r;const h={},{entity:l,entityDescription:c,criteria:d,searchOptions:g,isHierarchyEntity:w,allowsNonAnalytic:y}=i;if("ADVANCED"===t)return new Promise(((t,i)=>{const r=document.createElement("snk-pesquisa");r[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=`entity_${l}`,r.entityName=l,r.argument=e,r.searchLoader=t=>n.loadAdvancedSearch(l,t,d,g),r.isHierarchyEntity=w,w&&(r.treeLoader=t=>n.loadTree(l,t,d,g),r.allowsNonAnalytic=y),r.selectItem=e=>{t(e),s.clearPopUpTitle(),s.closePopUp()},s.setPopUpTitle(c),s.showPopUp(r,void 0,void 0,i)}));if("LOAD_DESCRIPTION"===t){let t=await n.loadByCode(l,e,d,g);t=o.stringToObject(t.json.$);const i=null===(r=t.data)||void 0===r?void 0:r[0];return i?{value:e,label:i[t.descriptionField]}:{value:e,label:""}}{let t,i=await n.loadAdvancedSearch(l,e,d,g,t);i=o.stringToObject(i.json.$);let s=i.descriptionField,r=i.pkField;return i.data.map((t=>{let n=((t,e,i)=>t.fieldsMetadata.filter((s=>{let n=!a.isEmpty(e[s.fieldName])&&!1!==s.visible&&"B"!==s.type&&t.pkField!==s.fieldName&&t.descriptionField!==s.fieldName&&(s.isPrimaryKey||!s.isLinkField)&&!("S"===s.type&&"H"===s.presentationType);return n&&(i[s.fieldName]=s),("string"!=typeof e[s.fieldName]||!Z.some((t=>e[s.fieldName].includes(t))))&&n})))(i,t,h),o=((t,e,i,s)=>(t&&Array.isArray(t)&&t.forEach((t=>{let i=m.removeReference(e,s[t]);i&&e.unshift(i)})),e=e.slice(0,i)))(t.__matchFields,n,6,h);return((t,e,i,s,n)=>{var r;const o=e.__matchFields,h=null!==(r=e[s])&&void 0!==r?r:"",l=e[n];return{value:l,label:h,presentationValue:a.highlightValue(t,o,l,i,!0),presentationLabel:s?a.highlightValue(t,o,h,i,!0):"",details:p.buildDetails(t,i,e)}})(e,t,o,s,r)}))}})(t,e,i,this,this.pesquisaFetcher):new Promise("ADVANCED"===t?(t,i)=>{const s=document.createElement("snk-pesquisa");s[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=`entity_${n}`,s.entityName=n,s.argument=e,s.searchLoader=t=>this.pesquisaFetcher.loadAdvancedSearch(n,t,h,l),s.isHierarchyEntity=c,c&&(s.treeLoader=t=>this.pesquisaFetcher.loadTree(n,t,h,l),s.allowsNonAnalytic=d),s.selectItem=e=>{t(e),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(r),this.showPopUp(s,void 0,void 0,i)}:(t,i)=>{this.pesquisaFetcher.loadAdvancedSearch(n,e,h,l).then((i=>{let n=(i=o.stringToObject(i.json.$)).descriptionField,r=i.pkField;const a=[];i.data.forEach((t=>{let o=this.filterInvalidFields(i,t,s),h=this.filterMathFields(t.__matchFields,o,6,s);a.push(this.builOptionItem(e,t,h,n,r))})),t(a)})).catch((t=>{i(t)}))})}async isDebugMode(){return new Promise((t=>{t(window.isDebugMode)}))}async getAppLabel(){return V.getAppLabel(this.applicationResourceID)}addSearchListener(t,e,i){return new Promise((s=>{s(this.pesquisaFetcher.addSearchListener(t,e.dataUnitId,i))}))}importScript(t){return new Promise((e=>{this.getApplicationPath().then((i=>{let s=[];Array.isArray(t)||(s=[t]),s.forEach((t=>{const e=document.createElement("script");e.src=`${i}/${t}`,e.async=!0,document.body.appendChild(e)})),e()}))}))}async getApplicationPath(){return new Promise((t=>{"dev"===window.applicationenv?t(""):t(`/${this.getModuleName()}/labsApps/${window.APPLICATION_NAME}/build`)}))}getModuleName(){return window.MGE_MODULE_NAME||"mgefin-bff"}executeSelectDistinct(t,e,i){return this.dataUnitFetcher.loadSelectDistinct(t,e,i)}getDataFetcher(){return Promise.resolve(b.get())}async whenApplicationReady(){return v.getContextValue("__SNK__APPLICATION__LOADING__")?Promise.resolve(this):new Promise((t=>{this._waitingAppReady.push((()=>t(this)))}))}async setSearchFilterContext(t,e){v.setContextValue(`__SNK__APPLICATION__FILTER__CONTEXT(${t})__`,e)}clearContent(t){t&&Array.from(t.children).forEach((e=>{t.removeChild(e)}))}async clearPopUpTitle(){this._popUp.ezTitle=""}async setPopUpTitle(t){this._popUp.ezTitle=t}async pkChangeListener(){const t=top.window.location.hash.split("/")[2];if(this._currentPkParameter===t)return;const e=this.getResourceIdFromToken(),i=I.getPkObjectFromUrlToken(top.window.location.hash),s=window.redirectFrom;if(void 0===i)return;if((!s||-1===s.split("_")[0].indexOf(e.split("_")[0]))&&e!==this.applicationResourceID)return;const n={pk:i};if(this._isLoadedByPk=!0,this.loadByPK)return this.loadByPK(n,s),void(this._currentPkParameter=t);this._loadPkParameter={pk:n,redirect:s},this.defaultLoadByPK(n,t)}getResourceIdFromToken(){var t;return(null===(t=top.window.location.pathname)||void 0===t?void 0:t.indexOf("tabContent.jsp"))>-1&&window.location.generateHash?I.getResourceIdFromUrlToken(window.location.generateHash(window.location.hash)):I.getResourceIdFromUrlToken(top.window.location.hash)}defaultLoadByPK(t,e){if(!(null==t?void 0:t.pk))return;const i=this.getFirstDataUnitFromDOM(),s=i.dataUnit;if(!s)return console.warn(this.getMessage("snkApplication.dataUnit.initDataUnitError")),void i.addEventListener("dataUnitReady",(i=>{this.loadDataWithPKFilter(t,i.detail),this._currentPkParameter=e}));this.loadDataWithPKFilter(t,s),this._currentPkParameter=e}loadDataWithPKFilter(t,e){const i={term:"",filter:{name:"LOAD_BY_PK_FILTER",expression:this.buildFilterExpressionByPkObject(t),params:this.getFilterParamsFromPkObject(t,e)}};e.loadData(i)}getFirstDataUnitFromDOM(){let t=this._element.querySelector("snk-data-unit[data-load-by-pk]");if(t||(t=this._element.querySelector("snk-data-unit")),t)return t}getFilterParamsFromPkObject(t,e){var i;const s=[];for(const n in t.pk)t.pk.hasOwnProperty(n)&&!Array.isArray(t.pk[n])&&s.push({name:n,dataType:(null===(i=e.getField(n))||void 0===i?void 0:i.dataType)||this.getDefaultDataTypeLoadByPK(t.pk[n]),value:t.pk[n]});return s}getDefaultDataTypeLoadByPK(t){return"number"==typeof t||t instanceof Number?f.NUMBER:"boolean"==typeof t||t instanceof Boolean?f.BOOLEAN:t instanceof Date?f.DATE:f.TEXT}buildFilterExpressionByPkObject(t){let e="";for(const i in t.pk)a.isEmpty(e)||(e+=" AND "),Array.isArray(t.pk[i])?e+=`${i} IN (${t.pk[i].toString()})`:e+=`${i} = :${i}`;return e}async showNewVersionPopup(){const t=document.createElement("ez-modal-container"),e=await this.getAppLabel();t.modalTitle=this.getMessage("snkApplication.newVersionPopup.title",{screenName:e}),t.okButtonLabel=this.getMessage("snkApplication.newVersionPopup.okButton"),t.cancelButtonLabel=this.getMessage("snkApplication.newVersionPopup.cancelButton");const i=document.createElement("p");i.innerText=this.getMessage("snkApplication.newVersionPopup.info"),i.className="ez-text",t.appendChild(i),t.addEventListener("ezModalAction",this.newVersionPopupEventListener.bind(this));const s=await x.showPopup({content:t});this._removeVersionLayoutPopup=async()=>{await s(),await this.processPendingActions(this.NEW_VERSION_POPUP_LOCKER)}}async newVersionPopupEventListener(t){"LOAD"!==t.detail&&("OK"===t.detail&&V.setScreenToUseV3Layout(),"CANCEL"===t.detail&&V.setScreenToUseOldLayout(),this._popUp.opened=!1,this._removeVersionLayoutPopup&&await this._removeVersionLayoutPopup())}async handleShowNewVersionPopup(){this.hasToShowNewVersionPopup()&&await this.showNewVersionPopup()}hasToShowNewVersionPopup(){const t=new URLSearchParams(window.location.search).get("firstLoadConv");return t&&"S"===t}registerPkChangeListener(){window.hasOwnProperty("onhashchange")?window.onhashchange=this.pkChangeListener.bind(this):setInterval(this.pkChangeListener.bind(this),100)}componentWillLoad(){v.setContextValue("__SNK__APPLICATION__LOADING__",!0),this._errorHandler=new W(this),this.messagesBuilder=new T,v.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${I.getUrlBase()}/mge/upload/file`),v.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((t,e,i,s)=>this.executeSearch(t,e,i,s))),v.setContextValue("__EZUI__SEARCH__PLUS__OPTION__LOADER__",((t,e,i,s)=>this.executeSearch(t,e,i,Object.assign(Object.assign({},s),{useSearchPlus:!0})))),this.registerPkChangeListener(),P.init(),A.preload(this.applicationResourceID,this.configName,{gridLegacyConfig:this.gridLegacyConfigName,formLegacyConfig:this.formLegacyConfigName}),document.addEventListener("click",(()=>V.applicationClick())),this._waitingAppReady.forEach((t=>t())),this.setLayoutFormConfig()}async setLayoutFormConfig(){const t=await this._formConfigFetcher.fetchLayoutFormConfig("formColCfg."+this.applicationResourceID),e=isNaN(Number(null==t?void 0:t.config))?null:Number(null==t?void 0:t.config);this._LayoutFormConfigSingleton.setConfig(e)}connectedCallback(){this._isBrowserTypeElectron=k.isElectron(),v.setContextValue("__SNK__APPLICATION__",this),b.addRequestListener(this._requestListener)}disconnectedCallback(){null==b||b.removeRequestListener(this._requestListener),this.removeShortcuts(),this._lockManagerTimer&&clearTimeout(this._lockManagerTimer),this._scrimWindowTimer&&clearTimeout(this._scrimWindowTimer)}async componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{v.setContextValue("__SNK__APPLICATION__LOADING__",!1),this.applicationLoaded.emit(!0),this.pkChangeListener()})),u.addIDInfo(this._element,`resource_${this.applicationResourceID}`),await this.handleShowNewVersionPopup(),this.initKeyboardManager(),this.enableLockManagerLoadingApp?(z.addLockManagerCtxId(this._element),this.resolveApplicationReady()):this._applicationReady=!0}async showScrimApp(t){if(!this.enableLockManagerLoadingApp||!this._applicationReady||!t)return this._activeScrimWindow=!1,void(this._scrimWindowTimer&&clearTimeout(this._scrimWindowTimer));this._activeScrimWindow=!0,this._scrimWindowTimer=setTimeout((async()=>{this._activeScrimWindow&&(this._activeScrimWindow=!1,clearTimeout(this._scrimWindowTimer))}),this._maxTimerAppLoading)}async changeTemplateSkeleton(t){this._templateSkeleton=t||this._templateSkeleton}async markToReload(t){this.enableLockManagerLoadingApp&&(await this.changeTemplateSkeleton(t),this._applicationReady=!1,await z.resetLocks(this._element,_.APP_LOADING),this.resolveApplicationReady())}async addLoadingLock(t=!1,e){if(this.enableLockManagerLoadingApp)return await this.changeTemplateSkeleton(e),t&&(this._applicationReady=!1,this._activeScrimWindow=!!this._applicationReady,await z.resetLocks(this._element,_.APP_LOADING)),this.resolveApplicationReady(),await z.lock(this._element,_.APP_LOADING)}async resolveApplicationReady(){if(!this._applicationReady)try{await this.checkTimeoutLimitLockManager(),await z.whenHasLock(this._element,_.APP_LOADING),await z.whenResolve(this._element,_.APP_LOADING,200),await z.resetLocks(this._element,_.APP_LOADING),this._applicationReady=!0}catch(t){console.warn(t),this._applicationReady=!0}}stopTimeoutLockManager(){this._lockManagerTimer&&clearTimeout(this._lockManagerTimer)}async checkTimeoutLimitLockManager(){this.stopTimeoutLockManager(),this._applicationReady||(this._lockManagerTimer=setTimeout((async()=>{this._applicationReady||(await z.resetLocks(this._element,_.APP_LOADING),this.stopTimeoutLockManager(),this._applicationReady=!0)}),this._maxTimerAppLoading))}initKeyboardManager(){this._keyboardManager.bind("ctrl + g",V.searchApp.bind(this),{description:this.getMessage("snkApplication.keyboard.shortcuts.searchApp")}).bind("ctrl + d",V.showDesktop.bind(this),{description:this.getMessage("snkApplication.keyboard.shortcuts.showDesktop")}).bind("F1",V.openHelp.bind(this),{description:this.getMessage("snkApplication.keyboard.shortcuts.openHelp")})}removeShortcuts(){this._keyboardManager.unbindAllShortcutKeys()}renderLoadingSkeleton(){if(this.enableLockManagerLoadingApp){if(this._isBrowserTypeElectron)return this.getSpinnerLoadingDefault();switch(this._templateSkeleton){case D.CUSTOM_TEMPLATE:case D.GRID:return this.getSkeletonTemplateGrid();case D.GRID_WITH_SIDEBAR:return this.getSkeletonTemplateGridWithSidebar();case D.GRID_WITH_PANEL:return this.getSkeletonTemplateGridWithPanel();case D.FORM_WITH_SIDEBAR:return this.getSkeletonTemplateFormWithSidebar();default:return this.getSkeletonTemplateGrid()}}}getLoadingVisibilityStyle(){return{visibility:this._applicationReady?"hidden":"initial",display:this._applicationReady?"none":"unset"}}getSkeletonTemplateGrid(){return i("div",{class:"loading-hidden",style:this.getLoadingVisibilityStyle()},i("div",{class:"ez-flex ez-flex--column ez-margin--large ez-margin-top--medium"},i("div",{class:"ez-margin-bottom--medium"},i("ez-skeleton",{count:1,variant:"text",width:"20%",height:"35px",animation:"progress"})),i("div",{class:""},i("ez-skeleton",{count:1,variant:"text",width:"70%",height:"25px",animation:"progress"}))),i("div",{class:"ez-flex ez-flex--justify-start skeleton-content-column ez-margin-horizontal--large",style:{height:"calc(-105px + 100vh)"}},[1,2,3,4].map(((t,e)=>i("div",{class:"ez-margin-right--large",key:e,style:{width:"25%"}},i("ez-skeleton",{count:this.getCountSkeleton(50,10),variant:"text",width:"100%",height:"50px",animation:"progress",marginBottom:"10px"}))))))}getSkeletonTemplateGridWithSidebar(){return i("div",{class:"loading-hidden",style:this.getLoadingVisibilityStyle()},i("div",{class:"ez-flex ez-flex--column ez-margin--large ez-margin-top--medium"},i("div",{class:"ez-margin-bottom--medium"},i("ez-skeleton",{count:1,variant:"text",width:"20%",height:"35px",animation:"progress"})),i("div",{class:""},i("ez-skeleton",{count:1,variant:"text",width:"70%",height:"25px",animation:"progress"}))),i("div",{class:"ez-flex ez-flex--justify-start skeleton-content-column ez-margin-horizontal--large",style:{height:"calc(100vh - 160px)"}},i("div",{class:"ez-flex ez-flex--column ez-margin-right--large",style:{width:"25%",overflow:"hidden"}},Array(this.getCountSkeleton(30,6)).fill(null).map(((t,e)=>i("ez-skeleton",{key:e,count:1,variant:"text",width:this.getSkeletonRandomWidth(),height:"30px",animation:"progress",marginBottom:"10px"})))),i("div",{class:"ez-margin-right--large",style:{width:"75%"}},i("ez-skeleton",{count:this.getCountSkeleton(50,10),variant:"text",width:"100%",height:"50px",animation:"progress",marginBottom:"10px"}))))}getSkeletonTemplateGridWithPanel(){return i("div",{class:"loading-hidden",style:this.getLoadingVisibilityStyle()},i("div",{class:"ez-margin--medium ez-margin-top--medium ez-padding--medium"},i("ez-skeleton",{count:1,variant:"text",width:"70%",height:"25px",animation:"progress"})),i("div",{class:"ez-flex ez-margin--medium ez-margin-top--medium",style:{maxHeight:"calc(-105px + 100vh)",overflow:"hidden"}},i("div",{class:"",style:{width:"70%",overflow:"hidden"}},i("div",{class:"ez-padding--medium",style:{height:"50%"}},i("ez-skeleton",{count:1,variant:"text",width:"100%",height:"100%",animation:"progress"})),i("div",{class:"ez-padding--medium",style:{}},i("ez-skeleton",{count:1,variant:"text",width:"250px",height:"25px",animation:"progress"})),i("div",{class:"ez-flex ez-padding--medium",style:{height:"45%"}},[1,2].map((()=>i("div",{style:{width:"50%"}},i("ez-skeleton",{count:1,variant:"text",width:"100%",height:"100%",animation:"progress"})))))),i("div",{class:"ez-flex ez-flex--column ez-padding--medium",style:{width:"30%",overflow:"hidden"}},Array(this.getCountSkeleton(30,10)).fill(null).map(((t,e)=>i("ez-skeleton",{key:e,count:1,variant:"text",width:"100%",height:"50px",animation:"progress",marginBottom:"10px"}))))))}getSkeletonTemplateFormWithSidebar(){return i("div",{class:"loading-hidden",style:this.getLoadingVisibilityStyle()},i("div",{class:"ez-margin--medium ez-margin-top--medium ez-padding--medium"},i("ez-skeleton",{count:1,variant:"text",width:"70%",height:"25px",animation:"progress"})),i("div",{class:"ez-flex ez-margin--medium ez-margin-top--medium",style:{maxHeight:"calc(-105px + 100vh)",overflow:"hidden"}},i("div",{class:"ez-flex ez-flex--column ez-margin-right--large",style:{width:"25%",overflow:"hidden"}},Array(this.getCountSkeleton(30,6)).fill(null).map(((t,e)=>i("ez-skeleton",{key:e,count:1,variant:"text",width:this.getSkeletonRandomWidth(),height:"30px",animation:"progress",marginBottom:"10px"})))),i("div",{class:"ez-flex ez-flex--column",style:{width:"75%"}},i("div",{class:"ez-padding--medium",style:{width:"100%"}},i("ez-skeleton",{count:1,variant:"text",width:"30%",height:"25px",animation:"progress"})),i("div",{class:"ez-padding--medium",style:{height:"45%"}},i("div",{class:"ez-flex",style:{width:"100%",height:"100%"}},[1,2,3,4].map(((t,e)=>i("div",{key:e,class:"ez-padding-right--large",style:{width:"25%",overflow:"hidden"}},Array(this.getCountSkeleton(50,20)).fill(null).map(((t,e)=>i("ez-skeleton",{key:e,count:1,variant:"text",width:"100%",height:"50px",animation:"progress",marginBottom:"10px"})))))))),i("div",{class:"ez-padding--medium",style:{width:"100%"}},i("ez-skeleton",{count:1,variant:"text",width:"30%",height:"25px",animation:"progress"})),i("div",{class:"ez-padding--medium",style:{height:"45%"}},i("div",{class:"ez-flex",style:{width:"100%",height:"100%"}},[1,2,3,4].map(((t,e)=>i("div",{key:e,class:"ez-padding-right--large",style:{width:"25%",overflow:"hidden"}},Array(this.getCountSkeleton(50,20)).fill(null).map(((t,e)=>i("ez-skeleton",{key:e,count:1,variant:"text",width:"100%",height:"50px",animation:"progress",marginBottom:"10px"})))))))))))}getSpinnerLoadingDefault(){return i("div",{class:"loading-hidden",style:this.getLoadingVisibilityStyle()},i("div",{class:"ez-flex ez-size-height--full ez-size-width--full ez-flex--justify-center ez-flex--align-items-center spinner"},i("ez-icon",{iconName:"sync",size:"x-large",class:"spin"}),i("span",{class:"ez-title ez-title--secondary ez-title--extra-large"},this.getMessage("snkApplication.loading.text"))))}render(){return i(s,{style:{visibility:!this.enableLockManagerLoadingApp||this._applicationReady?"unset":"hidden",overflow:!this.enableLockManagerLoadingApp||this._applicationReady?"unset":"hidden"}},i("div",null,i("ez-loading-bar",{ref:t=>this._requestListener.ezLoadingBar=t}),i("ez-popup",{opened:!1,ref:t=>this._popUp=t,onEzClosePopup:()=>this.closePopUp()}),i("ez-modal",{opened:!1,ref:t=>this._rightModal=t,"modal-size":"small",closeOutsideClick:!0,closeEsc:!0}),this.renderLoadingSkeleton(),this._activeScrimWindow&&i("div",{class:"ez-scrim ez-scrim--light",style:{cursor:"progress",zIndex:"var(--scrim-z-index)"}})))}get _element(){return n(this)}static get watchers(){return{loadByPK:["watchPropHandler"]}}};class tt{constructor(t,e){this.resolve=t,this.reject=e}}Q.style=".sc-snk-application-h{--scrim-z-index:var(--elevation--100, 100);display:flex;flex-direction:column;height:100%}.sc-snk-application-h>.loading-hidden.sc-snk-application{display:none;pointer-events:none}.skeleton-content-left.sc-snk-application{width:300px;padding-right:5px}.skeleton-content.sc-snk-application{height:calc(100vh - 310px)}.spinner.sc-snk-application{height:100vh;gap:10px}.spinner.sc-snk-application>.spin.sc-snk-application{animation-name:spin;animation-duration:5000ms;animation-iteration-count:infinite;animation-timing-function:linear}@keyframes spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}";export{Q as snk_application}
@@ -1 +0,0 @@
1
- import{r as i,c as t,h as s,g as e,H as h}from"./p-d8d8169b.js";import{ElementIDUtils as a,ObjectUtils as o,ApplicationContext as n}from"@sankhyalabs/core";import{S as d}from"./p-1210500e.js";import{R as l}from"./p-688dcb4c.js";import{buildFormConfigFromDataUnit as r}from"@sankhyalabs/ezui/dist/collection/utils/form";import{b as c,a as f,g,u as m,c as u}from"./p-8f73da95.js";import{a as v,G as p}from"./p-9019a32f.js";import{ApplicationUtils as C}from"@sankhyalabs/ezui/dist/collection/utils";import{U as b}from"./p-c6331595.js";import"./p-3dba3468.js";import"./p-0dac8fef.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";const y=class{constructor(s){i(this,s),this.exit=t(this,"exit",7),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(this,"formItemsReady",7),this._customEditors=new Map,this._dataUnit=void 0,this._dataState=void 0,this._showFormConfig=!1,this._configManager=void 0,this.configName=void 0,this.recordsValidator=void 0,this.messagesBuilder=void 0,this.formLegacyConfigName=void 0,this.resourceID=void 0}async showConfig(){this._showFormConfig=!0}async hideConfig(){this._showFormConfig=!1}async addCustomEditor(i,t){if(this._form)return void this._form.addCustomEditor(i,t);const s=new Map(this._customEditors);s.set(i,t),this._customEditors=s}async setFieldProp(i,t,s){await this._form.setFieldProp(i,t,s)}async validate(){await this._form.validate()}closeConfig(){this.hideConfig()}dataunitReady(){a.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}setCustomEditors(){if(this._form)for(const[i,t]of this._customEditors)this._form.addCustomEditor(i,t),this._customEditors.delete(i)}async componentDidRender(){this.setCustomEditors()}async componentWillLoad(){let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.dataunitReady():this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail})),this._snkDataUnit.addEventListener("dataStateChange",this.handleDataStateChange.bind(this));break}i=i.parentElement}null==this.resourceID&&(this.resourceID=await l.getResourceID()),this._configManager=new d(this.configName,this.resourceID,void 0,this._dataUnit),this.addFormLegacyConfig(),await this._configManager.loadConfig()}async handleDataStateChange(i){var t;this._dataState=i.detail;const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const i of s||[]){if(!i)continue;const s=null===(t=this._dataState.rowMetadata)||void 0===t?void 0:t.getProp("rm_precision",i);(s||0===s)&&(await this.setFieldProp(i,"precision",s),await this.setFieldProp(i,"prettyPrecision",s))}}addFormLegacyConfig(){this.formLegacyConfigName&&this._configManager.addFormLegacyConfig(this.formLegacyConfigName)}render(){if(this._dataUnit&&this._dataState)return s("section",null,s("div",{class:"ez-row"},s("div",{class:"ez-col ez-col--sd-12"},s("ez-form",{ref:i=>this._form=i,key:"ezForm"+this._snkDataUnit.entityName,"data-element-id":"embedded",dataUnit:this._dataUnit,config:this._configManager.getConfig(this._dataUnit),recordsValidator:this.recordsValidator,class:this._showFormConfig?"snk-form__form--hidden":""}),this._showFormConfig&&s("snk-form-config",{messagesBuilder:this.messagesBuilder,dataUnit:this._dataUnit,configManager:this._configManager,onConfigClose:()=>this.closeConfig()}))))}get _element(){return e(this)}};y.style=".sc-snk-form-h{--snk-form__header--min-height:94px;display:block}.snk-form__form--hidden.sc-snk-form{display:none}";const k=class{constructor(s){i(this,s),this.configClose=t(this,"configClose",7),this.configChange=t(this,"configChange",7),this.guidesMap=new Map,this.availableFields=[],this.guidesList=[],this.groupsList=[],this.selectedGuide=void 0,this._formConfig={},this.configOptions=[],this.originalConfigSelected=void 0,this.configSelected=void 0,this.hasChanges=!1,this.optionConfigChanged=!1,this.dataUnit=void 0,this.configManager=void 0,this.ignoreReadOnlyFormFields=void 0,this.messagesBuilder=void 0}handleFieldConfigChanged(){this.hasChanges=!0}async handleFormConfigOptionSelected({detail:i}){this.configSelected=i,await this.loadConfigByUser(),this.selectedGuide=void 0,this.optionConfigChanged=!o.equals(this.configSelected,this.originalConfigSelected),this.configSelected.origin===b.DEFAULT&&(this.hasChanges=!1)}async handleAddFieldToGuide({detail:i}){var t;this.selectedGuide?(this.availableFields=[...this.availableFields.filter((t=>t.name!==i.name))],await(null===(t=this.refFieldsLayout)||void 0===t?void 0:t.addFieldToLayout(i))):this.showNoGuideSelectedDialog()}async handleSetFieldAsAvailable({detail:i}){this.availableFields.some((t=>t.name===i.name))||(this.availableFields=[...this.availableFields,i])}async handleRemoveFieldFromAvailable({detail:i}){this.availableFields=this.availableFields.filter((t=>t.name!==i.name))}observeSelectedGuide(i){var t;const s=null!==(t=this.guidesMap.get(null==i?void 0:i.name))&&void 0!==t?t:[];this.groupsList=[...s]}observeConfigManager(){this.loadFormConfig()}showNoGuideSelectedDialog(){const i=this.getMessage("snkFormConfig.noGuideSelected.title"),t=this.getMessage("snkFormConfig.noGuideSelected.message");C.alert(i,t)}getMessage(i,t){return this.messagesBuilder.getMessage(i,t)}async initializeUserConfig(){if(null!=this.configManager)try{const i=await this.configManager.fetchUserAvailableConfigs();this.configOptions=i;const t=null==this._formConfig||this._formConfig.defaultConfiguration?b.DEFAULT:b.USER;this.configSelected=i.find((i=>i.origin===t)),this.originalConfigSelected=i.find((i=>i.origin===t))}catch(i){console.error(this.getMessage("snkFormConfig.errors.failFetchUserConfig")),console.error(i)}}async loadConfigByUser(){this.configManager&&this.configSelected&&(this.isConfigDefaultSelected()?await this.handleLoadDefaultConfig():this.loadFormConfig())}async handleLoadDefaultConfig(){const i=await this.configManager.fetchDefaultConfig();if(i)return void this.loadFormConfig(i);const t=this.configManager.getEmptyConfig();t&&this.loadFormConfig(t)}isConfigDefaultSelected(){return this.configSelected.origin===b.DEFAULT}loadFormConfig(i){this._formConfig=i||this.getConfig(),this.loadGuides(),this.initializeAvailableFields()}initializeAvailableFields(){var i;if(null==(null===(i=this._formConfig)||void 0===i?void 0:i.fields))return;const t=[...this._formConfig.fields];this.availableFields=this.dataUnit.metadata.fields.filter((({name:i,visible:s,properties:e})=>{const h=t.some((({name:t})=>t===i));return h||!0!==e.visibleOnConfig||s?!0===s&&!1===h:e.visibleOnConfig}))}loadGuides(){var i;this.guidesList=[...c(this._formConfig,this.getMessage("snkFormConfig.form.mainArea"))],this.guidesMap=f(null===(i=this._formConfig)||void 0===i?void 0:i.fields,this.guidesList,this.dataUnit,this.getMessage("snkFormConfig.form.tabGeneral"))}getConfig(){let i=this.configManager.getConfig(this.dataUnit,!1);return i.fields&&0===i.fields.length&&(i=void 0),null==i&&(i=r(this.dataUnit)),o.copy(i)}handleSelectGuide({detail:i}){this.selectedGuide=i}handleLayoutChanged({detail:i}){this.hasChanges=!0,this.groupsList=[...i],this.guidesMap.set(this.selectedGuide.name,[...i])}getIsDefaultConfig(){var i;return(null===(i=this.configSelected)||void 0===i?void 0:i.origin)===b.DEFAULT&&!0===this.optionConfigChanged&&!1===this.hasChanges}getTabsToSave(){return this.guidesList.map((i=>({name:i.name,label:i.name===v.main?i.name:i.label,order:i.name===v.main?0:i.order,visible:i.visible})))}async handleSaveConfig(){var i;const t=await this.configManager.saveConfig(this.buildConfigToSave());this.configSelected=null===(i=this.configOptions)||void 0===i?void 0:i.find((i=>i.origin===(this.hasChanges?b.USER:b.DEFAULT))),this.originalConfigSelected=this.configSelected,this.hasChanges=!1,this.optionConfigChanged=!1,C.info(this.getMessage("snkFormConfig.info.successfullyConfigSaved"),{iconName:"check"}),this.configChange.emit(t)}buildConfigToSave(){if(this.getIsDefaultConfig()){const i=this._formConfig;return i.defaultConfiguration=!0,i}const i=o.copy(this._formConfig);return i.tabs=this.getTabsToSave(),i.fields=g(this.guidesMap),i.defaultConfiguration=!1,i}handleAvailableFieldListChanged({detail:i}){this.availableFields=[...i]}handleSetFieldListAsAvailable({detail:i}){this.availableFields=[...this.availableFields,...i]}handleGuideDeleted({detail:i}){var t,s;const e=i.name,h=null!==(t=this.guidesMap.get(e))&&void 0!==t?t:[],a=[];h.forEach((i=>a.push(...i.fields))),this.availableFields=[...this.availableFields,...a],this.guidesList=[...this.guidesList.filter((i=>i.name!==e))],this.guidesMap.delete(e),(null===(s=this.selectedGuide)||void 0===s?void 0:s.name)===e&&(this.selectedGuide=void 0),this.hasChanges=!0}handleGuideListChanged({detail:i}){this.hasChanges=!0,this.guidesList=[...i]}handleGuideRenamed({detail:i}){var t;const s=null!==(t=this.guidesMap.get(this.selectedGuide.name))&&void 0!==t?t:[],e=m(s,i);this.guidesMap.delete(this.selectedGuide.name),this.guidesMap.set(i,e);const h={name:i,label:i,visible:this.selectedGuide.visible,order:this.selectedGuide.order};this.guidesList=[...this.guidesList.map((i=>i.name===this.selectedGuide.name?h:i))],this.groupsList=[...e],this.selectedGuide=h,this.hasChanges=!0}handleCreateNewGuide(){const i=u(this.guidesList,this.getMessage.bind(this)),t={name:i,label:i,visible:!0,order:this.guidesList.length+1},s={name:p.noGroup,fields:[]};this.guidesList=[...this.guidesList,t],this.guidesMap.set(i,[s]),this.selectedGuide=t,this.hasChanges=!0}getGuideNames(){return[...this.guidesList.map((i=>i.name.toLowerCase())),this.getMessage("snkFormConfig.form.mainArea").toLowerCase()]}async componentWillRender(){if(null==this.messagesBuilder){const i=n.getContextValue("__SNK__APPLICATION__");this.messagesBuilder=i.messagesBuilder}}async componentWillLoad(){this.loadFormConfig(),await this.initializeUserConfig()}render(){return s(h,null,s("config-header",{configOptions:this.configOptions,selectedConfig:this.configSelected,messagesBuilder:this.messagesBuilder,hasChanges:this.hasChanges,optionConfigChanged:this.optionConfigChanged,onConfigClose:()=>this.configClose.emit(),onSaveConfig:async()=>await this.handleSaveConfig()}),s("div",{class:"ez-padding--medium"},s("div",{class:"ez-flex sidebarNavigator__container"},s("guides-configurator",{messagesBuilder:this.messagesBuilder,guidesList:this.guidesList,selectedGuide:this.selectedGuide,onGuideSelected:this.handleSelectGuide.bind(this),onGuideListChanged:this.handleGuideListChanged.bind(this),onCreateNewGuide:this.handleCreateNewGuide.bind(this),onGuideDeleted:this.handleGuideDeleted.bind(this)}),s("fields-layout",{ref:i=>this.refFieldsLayout=i,selectedGuide:this.selectedGuide,guideNames:this.getGuideNames(),groupsList:this.groupsList,messagesBuilder:this.messagesBuilder,dataUnit:this.dataUnit,onGuideRenamed:this.handleGuideRenamed.bind(this),onLayoutChanged:this.handleLayoutChanged.bind(this),onSetFieldListAsAvailable:this.handleSetFieldListAsAvailable.bind(this)}),s("fields-selector",{dataUnit:this.dataUnit,availableFields:this.availableFields,onFieldListChanged:this.handleAvailableFieldListChanged.bind(this),messagesBuilder:this.messagesBuilder}))))}static get watchers(){return{selectedGuide:["observeSelectedGuide"],configManager:["observeConfigManager"]}}};k.style='.sc-snk-form-config-h{display:flex;flex-direction:column;height:100vh;width:100vw;font-family:var(--font-pattern, "Roboto");background:white;color:#2b3a54;--snk-form-config-container-height:calc(100vh - 95px);outline:none}.sidebarNavigator__container.sc-snk-form-config{height:var(--snk-form-config-container-height);gap:20px;align-items:flex-start}.guide-header.sc-snk-form-config{display:flex;width:100%;padding-bottom:12px;border-bottom:1px solid #dce0e8;height:30px;font-weight:500;font-size:16px}';export{y as snk_form,k as snk_form_config}
@@ -1 +0,0 @@
1
- import{r as t,c as i,h as e,H as s,g as r}from"./p-d8d8169b.js";import{DataType as l,StringUtils as a,ObjectUtils as n,ElementIDUtils as o,ErrorException as h,ApplicationContext as d,LockManager as c,LockManagerOperation as u,DateUtils as f,MaskFormatter as m,FloatingManager as p,ArrayUtils as v}from"@sankhyalabs/core";import{EzScrollDirection as b}from"@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection";import{C as k}from"./p-3dba3468.js";import{toString as g}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{F as _}from"./p-ff1990ad.js";import{F,D as z}from"./p-84345e7a.js";import{F as x}from"./p-fa80e546.js";import{ApplicationUtils as y}from"@sankhyalabs/ezui/dist/collection/utils";import{P as w}from"./p-988afe78.js";import{ModalAction as C}from"@sankhyalabs/ezui/dist/collection/components/ez-modal-container";import{F as I}from"./p-b568c1d4.js";import{A as $}from"./p-6a4b21dd.js";import"./p-c6331595.js";import"./p-0dac8fef.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";function N(t){let i="";return t.forEach(((t,e)=>{var s;i+=` ${e>0?null!==(s=t.operand)&&void 0!==s?s:"OR":""} ${t.expression}`})),i.trim()}class L{constructor({filterConfig:t,configName:i,onComplete:e,getMessage:s,disablePersonalizedFilter:r,onAddPersonalizedFilter:l,onEditPersonalizedFilter:a,onDeletePersonalizedFilter:n}){this._filterConfig=t,this._configName=i,this._onComplete=e,this._getMessage=s,this._disablePersonalizedFilter=r,this._addPersonalizedFilterFn=l,this._editPersonalizedFilterFn=a,this._onDeletePersonalizedFilter=n}applyFilters(t){this._onComplete(t),this._closeModal()}buildFilterModal(){const t=document.createElement("snk-filter-modal");return t.className="ez-size-height--full",t.filters=this._filterConfig,t.configName=this._configName,t.disablePersonalizedFilter=this._disablePersonalizedFilter,t.getMessage=this._getMessage.bind(this),t.applyFilters=this.applyFilters.bind(this),t.closeModal=()=>this._closeModal(),t.addPersonalizedFilter=t=>this._addPersonalizedFilterFn(t),t.editPersonalizedFilter=(t,i)=>this._editPersonalizedFilterFn(t,i),t.deletePersonalizedFilter=(t,i,e)=>this._onDeletePersonalizedFilter(t,i,e),t}async showModal(){const t={content:this.buildFilterModal(),position:"right",heightMode:"full",closeOutsideClick:!1,useScrimLight:!0};this._closeModal=await y.showModal(t)}async closeModal(){this._closeModal()}}const T=class{constructor(e){t(this,e),this.configUpdated=i(this,"configUpdated",7),this._updateSequence=[],this._loadingPending=!1,this._configUpdated=!1,this._firstLoad=!0,this._pendingVariables=!1,this._isDefaultFilter=!1,this._customfiltersToBeUpdated=[],this._resolveLoading=void 0,this._calculateSortIndex=t=>{if(!t.visible)return 0;if(t.hardFixed)return 1e6;let i=t.fixed?1e5:0;return i+=this.hasValidValue(t)?1e4:0,i+=this._updateSequence.lastIndexOf(t.id)+1,i},this._filtersComparator=(t,i)=>this._calculateSortIndex(i)-this._calculateSortIndex(t),this.enableLockManagerLoadingComp=!1,this.customFilterBarConfig=void 0,this.dataUnit=void 0,this.title=void 0,this.configName=void 0,this.resourceID=void 0,this.mode="regular",this.filterConfig=void 0,this.messagesBuilder=void 0,this.disablePersonalizedFilter=void 0,this.filterBarLegacyConfigName=void 0,this.autoLoad=void 0,this.afterApplyConfig=void 0,this.allowDefault=void 0,this.scrollerLocked=!1,this.showPersonalizedFilter=!1,this.personalizedFilterId=void 0}hasValidValue(t){return null!=t.value&&(!Array.isArray(t.value)||t.value.some((t=>!0===t.check)))}observeFilterConfig(t,i){n.equals(t,i)||this.handleFilterConfigsChanged(i,t)}handleFilterConfigsChanged(t,i){if(null!=t&&null==i)this._loadingPending=!0,this._configUpdated=!0;else{const e=new Map(t?t.map((t=>[t.id,t])):void 0);0===e.size&&i.length>0?(this._loadingPending=!0,this._configUpdated=!1):i.forEach((t=>{const i=e.get(t.id);if(null!=i){if(this._configUpdated=this._configUpdated||n.objectToString(i)!=n.objectToString(t),this._loadingPending=this._loadingPending||n.objectToString(i.value)!==n.objectToString(t.value),!this._loadingPending){const e=n.objectToString(i.groupedItems)!=n.objectToString(t.groupedItems);this._configUpdated=this._configUpdated||e,this._loadingPending=this._loadingPending||e}}else this._configUpdated=!0,this._loadingPending=this._loadingPending||null!=t.value}))}(this._loadingPending||this._configUpdated)&&this.configUpdated.emit(i),this.processAfterUpdateConfig()}async reload(){this.loadConfigFromStorage(!0)}async getFilterItem(t){const i=this.filterConfig.find((i=>i.id===t));return Promise.resolve(n.copy(i))}async updateFilterItem(t){return-1==this.filterConfig.findIndex((i=>i.id===t.id))?(console.warn("[SnkFilterBar.updateFilterItem] "+this.getMessage("snkFilterBar.filterItem.updateFilterItemNotFound")),Promise.resolve()):(this._loadingPending=!0,this.updateFilter(t),Promise.resolve())}async addFilterItem(t){return this.filterConfig.findIndex((i=>i.id===t.id))>-1?(console.warn("[SnkFilterBar.addFilterItem] "+this.getMessage("snkFilterBar.filterItem.addFilterItemExists")),Promise.resolve()):(this.filterConfig.push(t),this._loadingPending=!0,this.updateFilter(t),Promise.resolve())}async removeFilterItem(t){const i=this.filterConfig.findIndex((i=>i.id===t));if(-1==i)return console.warn("[SnkFilterBar.removeFilterItem] "+this.getMessage("snkFilterBar.filterItem.removeFilterItemNotFound")),Promise.resolve(void 0);const e=this.filterConfig[i];return this.filterConfig=this.filterConfig.filter((i=>i.id!==t)),Promise.resolve(e)}componentDidLoad(){this._element&&o.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}processPendingFilter(){if(this._pendingVariables){const t=this._element.querySelector("#filter-PERSONALIZED_FILTER_GROUP");t&&t.showUp(!0).then((()=>{this.processAfterUpdateConfig()}))}else this.processAfterUpdateConfig()}getPersonalizedFilterItem(){return this.filterConfig.find((t=>t.type===_.PERSONALIZED))}async processAfterUpdateConfig(){var t;if(this._loadingPending){if(await this._application.isLoadedByPk()&&!this._configUpdated)return;const t=this.getPersonalizedFilterItem();if(this._pendingVariables=!w.validateVariableValues(t),this._pendingVariables)return;this._loadingPending=!1,this.doLoadData(null!=this.dataUnit.getLastLoadRequest())}this._configUpdated&&(this._configUpdated=!1,k.saveFilterBarConfig(this.filterConfig,this.configName,this.resourceID),null===(t=this.afterApplyConfig)||void 0===t||t.call(this))}async doLoadData(t=!1){try{if(this._firstLoad&&!1===this.autoLoad)return;if(this._firstLoad&&!t&&void 0===this.autoLoad&&!await this._application.getBooleanParam("global.carregar.registros.iniciar.tela"))return;this.dataUnit.loadData(void 0,void 0,!0)}finally{this._firstLoad=!1}}getMessage(t,i,e){var s;return null==this.messagesBuilder&&this._application&&(this.messagesBuilder=this._application.messagesBuilder),(null===(s=this.messagesBuilder)||void 0===s?void 0:s.getMessage(t,i))||e}async getFilters(){return this.getFilter(null)}getFilter(t){var i;const e=[];return null===(i=this.filterConfig)||void 0===i||i.filter((t=>this.isActiveFilter(t))).forEach((t=>{const i=(t=>{switch(t.type){case _.DEFAULT_FILTER:return function(t){return{name:t.id,expression:t.props.expression,params:[]}}(t);case _.BINARY_SELECT:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.options.find((t=>t.name===e)).expression,params:[]}}(t);case _.MULTI_SELECT:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:l.TEXT,value:e}]}}(t);case _.MULTI_LIST:return function(t){const{id:i,value:e,props:s}=t,r=(null!==(o=null!==(n=null==(a=e)?void 0:a.elements)&&void 0!==n?n:null==a?void 0:a.members)&&void 0!==o?o:a).filter((t=>null==t?void 0:t.check)).map((({id:t})=>Number.isNaN(+t)?String(t):Number(t)));var a,n,o;if(r.length>0)return{name:i,expression:s.expression,params:[{name:i,dataType:l.TEXT,value:JSON.stringify(r)}]}}(t);case _.PERIOD:return function(t){const{id:i,value:e,props:s}=t;let{end:r,start:a}=e;"string"==typeof r&&(r=new Date(r)),"string"==typeof a&&(a=new Date(a));const n=[];let o;return r&&a?(o=s.expression.fullfill,n.push({name:`${i}.START`,dataType:l.DATE,value:g(l.DATE,a)},{name:`${i}.END`,dataType:l.DATE,value:g(l.DATE,r)})):a?(o=s.expression.onlystart,n.push({name:i,dataType:l.DATE,value:g(l.DATE,a)})):(o=s.expression.onlyend,n.push({name:i,dataType:l.DATE,value:g(l.DATE,r)})),{name:i,expression:o,params:n}}(t);case _.SEARCH:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:l.TEXT,value:g(l.TEXT,null==e?void 0:e.value)}]}}(t);case _.TEXT:return function(t){let{id:i,value:e,props:s}=t;const r=s.expression;var n,o;return a.isEmpty(s.likeAs)||(n=e,e="CONTANIS"===(o=s.likeAs)?`%${n}%`:"STARTS_WITH"===o?`${n}%`:"ENDS_WITH"===o?`%${n}`:n),{name:i,expression:r,params:[{name:i,dataType:l.TEXT,value:g(l.TEXT,e)}]}}(t);case _.NUMBER:return function(t){const{id:i,value:e,props:s}=t;if(s.variation===x.INTERVAL){const{start:t,end:r}=null!=e?e:{start:0,end:0};if(!isNaN(t)&&!isNaN(r))return{name:i,expression:s.intervalExpression.fullfill,params:[{name:`${i}.START`,dataType:l.NUMBER,value:g(l.NUMBER,t)},{name:`${i}.END`,dataType:l.NUMBER,value:g(l.NUMBER,r)}]};if(!isNaN(t))return{name:i,expression:s.intervalExpression.onlystart,params:[{name:i,dataType:l.NUMBER,value:g(l.NUMBER,t)}]};if(!isNaN(r))return{name:i,expression:s.intervalExpression.onlyend,params:[{name:i,dataType:l.NUMBER,value:g(l.NUMBER,r)}]}}return{name:i,expression:s.expression,params:[{name:i,dataType:l.NUMBER,value:g(l.NUMBER,e)}]}}(t);case _.PERSONALIZED:return function(t){const{id:i,groupedItems:e=[]}=t,s=e.filter((t=>!!t.visible)).map((t=>{var i;const e=t.props.expression,s=((null===(i=t.props.personalizedFilter)||void 0===i?void 0:i.parameters)||[]).map(((i,e)=>{const s=Array.from(t.value||0),r=i.dataType;let a=e>=0&&e<s.length?s[e]:null;return null!=a&&"object"==typeof a&&"value"in a&&(a=a.value),null==a&&r===l.BOOLEAN&&(a=!1),{name:i.name,dataType:r,value:"string"==typeof a?a:g(r,a)}}));return{expression:e,name:t.id,params:s}}));return{name:i,expression:s.map((t=>`(${t.expression})`)).join(` ${F.AND} `),params:s.flatMap((t=>t.params))}}(t);case _.CHECK_BOX_LIST:return function(t){var i;const{id:e,value:s,props:r}=t,l=Object.entries(null!=s?s:{}).filter((([t,i])=>!0===i)).map((([t,i])=>t));return{name:e,expression:N(null===(i=r.options)||void 0===i?void 0:i.filter((t=>l.includes(t.name)))),params:[]}}(t);default:return}})(t);i&&e.push(i)})),e}isActiveFilter(t){return t.type===_.DEFAULT_FILTER||this.filterActiveFilter(t)&&(t.groupedItems||null!=t.value)}async registryFilterProvider(){this.dataUnit.addFilterProvider(this),this.filterConfig&&await this.doLoadData()}itemFocused(t){this._element.querySelectorAll("snk-filter-item,snk-filter-list").forEach((i=>{i.id===t?"snk-filter-item"===i.tagName.toLowerCase()&&i.getClientRects()[0].x<0&&i.scrollIntoView({behavior:"auto",inline:"nearest"}):i.hideDetail()}))}filterActiveFilter(t){return t.visible||t.removalBlocked}filterPersonalizedItems(t){return t.type===_.PERSONALIZED}getPersonalizedFilterVariableItems(){return this.filterConfig.filter(this.filterPersonalizedItems).map((t=>{const i=`filter-${t.id}`;return e("snk-filter-item",{key:t.id,id:i,config:Object.assign({},t),onFocusin:()=>this.itemFocused(i),onVisibleChanged:t=>this.scrollerLocked=t.detail,onFilterChange:t=>this.updateFilter(t.detail),getMessage:(t,i)=>this.getMessage(t,i),showChips:!1})}))}getFilterItems(){const t=[],i=[];this.filterConfig.sort(((t,i)=>this._filtersComparator(t,i))).filter(this.filterActiveFilter).forEach(((s,r)=>{const l=`filter-${(s=n.copy(s)).id}`,a=e("snk-filter-item",{onVisibleChanged:t=>this.scrollerLocked=t.detail,onFilterChange:t=>this.updateFilter(t.detail),onFocusin:()=>this.itemFocused(l),id:l,config:s,class:r>0?"ez-padding-left--medium":"",getMessage:(t,i)=>this.getMessage(t,i),key:s.id});return s.fixed||s.hardFixed?t.push(a):i.push(a),a}));const s=[];return s.push(...t),t.length>0&&i.length>0&&s.push(e("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider"})),s.push(...i),s}calculateUpdateSequence(t){t&&(this._updateSequence=this._updateSequence.filter((i=>t.id!==i)),this._updateSequence.push(t.id))}normalizeItem(t){const i=Object.assign({},t);return["props","value","hardFixed","fixed"].forEach((t=>{null==i[t]&&delete i[t]})),""===t.value&&delete t.value,i}updateFilter(t){this.filterConfig=this.filterConfig.map((i=>(t=this.normalizeItem(t),i.id===t.id?(n.objectToString(i)!=n.objectToString(t)&&this.calculateUpdateSequence(t),t):i))).sort(((t,i)=>this._filtersComparator(t,i)))}loadPermitions(){this._application.isUserSup().then((t=>this.allowDefault=t))}addFilterBarLegacyConfigName(){this.filterBarLegacyConfigName&&k.addFilterBarLegacyConfig(this.configName,this.filterBarLegacyConfigName)}async loadConfigFromStorage(t){try{let i;t&&await k.deleteFilterBarConfigCache(this.configName,this.resourceID),i=this.customFilterBarConfig?await this.customFilterBarConfig(this.configName,this.resourceID,{contextURI:this.dataUnit.name}):await k.loadFilterBarConfig(this.configName,this.resourceID,{contextURI:this.dataUnit.name}),this.filterConfig=i.map((t=>this.normalizeItem(t))),this.filterConfig.sort(((t,i)=>this._filtersComparator(t,i)))}catch(t){throw new h(this.getMessage("snkFilterBar.failToLoadConfig"),t)}}async attachDataUnit(){if(null==this.dataUnit){let t=this._element.parentElement;for(;t;)if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){const i=t;this.dataUnit=i.dataUnit,this.dataUnit?await this.registryFilterProvider():i.addEventListener("dataUnitReady",(async t=>{this.dataUnit=t.detail,await this.registryFilterProvider()}));break}t=t.parentElement}else await this.registryFilterProvider()}filterChangeListener(t){this.updateFilter(t.detail)}async showFilterModal(){let t=n.copy(this.filterConfig);t=t.sort(((t,i)=>t.originOrder-i.originOrder)),this._filterModalFactory=new L({filterConfig:t,configName:this.configName,onComplete:t=>{var i;this.filterConfig=t.map(this.normalizeItem).sort(((t,i)=>this._filtersComparator(t,i))),null===(i=this.afterApplyConfig)||void 0===i||i.call(this)},disablePersonalizedFilter:this.disablePersonalizedFilter,getMessage:(t,i)=>this.getMessage(t,i),onAddPersonalizedFilter:t=>this.addPersonalizedFilter(t),onEditPersonalizedFilter:(t,i)=>this.editPersonalizedFilter(t,i),onDeletePersonalizedFilter:(t,i,e)=>this.deletePersonalizedFilter(t,_.PERSONALIZED,i,e)}),await this._filterModalFactory.showModal()}addPersonalizedFilter(t=!1){this._filterModalFactory.closeModal(),this._isDefaultFilter=t,this.personalizedFilterId=void 0,this.showPersonalizedFilter=!0,window.requestAnimationFrame((()=>{this._elPersonalizedFilter.createPersonalizedFilter()}))}editPersonalizedFilter(t,i=!1){this._filterModalFactory.closeModal(),this._isDefaultFilter=i,this.showPersonalizedFilter=!0,this.personalizedFilterId=t}deletePersonalizedFilter(t,i,e,s=!1){if(s)return k.removeDefaultFilter(t,this.resourceID,e),void(this._isDefaultFilter=!1);i===_.PERSONALIZED&&k.removePersonalizedFilter(t,this.resourceID,e)}handleHidePersonalizedFilter(t){t?this.loadConfigFromStorage().then((()=>{this.hidePersonalizedFilter()})):this.hidePersonalizedFilter()}hidePersonalizedFilter(){this.personalizedFilterId=void 0,this.showPersonalizedFilter=!1,this._isDefaultFilter=!1}async componentWillLoad(){var t;try{if(this._application=d.getContextValue("__SNK__APPLICATION__"),await this.attachDataUnit(),this._application){if(this._application.enableLockManagerLoadingApp&&this.enableLockManagerLoadingComp){const t=c.addLockManagerCtxId(this._element);this._resolveLoading=c.lock(t,u.APP_LOADING)}await Promise.all([this.loadPermitions(),this.addFilterBarLegacyConfigName(),this.loadConfigFromStorage()])}}finally{null===(t=this._resolveLoading)||void 0===t||t.call(this)}}componentDidRender(){this.processPendingFilter()}render(){if(this.dataUnit&&this.filterConfig&&0!==this.filterConfig.length)return this.showPersonalizedFilter?e("snk-personalized-filter",{class:"filter-bar__personalized-filter",filterId:this.personalizedFilterId,ref:t=>this._elPersonalizedFilter=t,isDefaultFilter:this._isDefaultFilter,onEzCancel:()=>this.handleHidePersonalizedFilter(!1),onEzAfterSave:()=>this.handleHidePersonalizedFilter(!0),entityUri:this.dataUnit.name,configName:this.configName,resourceID:this.resourceID}):"regular"!==this.mode?e(s,{"data-mode":this.mode},this.getPersonalizedFilterVariableItems(),"button"===this.mode&&e("ez-button",{class:"ez-margin-left--medium",size:"small",label:this.getMessage("snkFilterBar.filters",void 0,this.getMessage("snkFilterBar.filters")),onClick:this.showFilterModal.bind(this)})):e(s,null,e("div",null,e("span",{class:"snk-filter-bar__title",title:this.title,"data-tooltip":this.title,"data-flow":"bottom"},this.title)),e("ez-scroller",{class:"snk-filter-bar__scroller",direction:b.HORIZONTAL,activeShadow:!0,locked:this.scrollerLocked},e("section",{class:"snk-filter-bar__filter-item-container"},this.getFilterItems())),e("ez-button",{class:"ez-padding-left--medium ez-margin-top--extra-small",size:"small",label:this.getMessage("snkFilterBar.filters",void 0,this.getMessage("snkFilterBar.filters")),onClick:this.showFilterModal.bind(this)},e("ez-icon",{slot:"leftIcon",iconName:"plus",class:"ez-padding-right--small"})))}get _element(){return r(this)}static get watchers(){return{filterConfig:["observeFilterConfig"]}}};T.style='.sc-snk-filter-bar-h{display:grid;grid-template-columns:1fr minmax(100px, 100%) 1fr 1fr;--snk-personalized-filter--z-index:var(--elevation--20, 20);--snk-personalized-filter--background-color:var(--background--xlight, #fff)}.snk-filter-bar__title.sc-snk-filter-bar{max-width:260px;display:inline-block;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;font-size:16px;font-family:var(--font-pattern, Arial);font-weight:var(--text-weight--large, 600);color:var(--color--title-primary, #2B3A54);margin-top:12px}[data-mode="hidden"].sc-snk-filter-bar-h{width:0px;height:0px}[data-mode="button"].sc-snk-filter-bar-h{grid-template-columns:1fr;width:fit-content}.snk-filter__popover-container.sc-snk-filter-bar{display:flex;cursor:auto}.filter-bar__personalized-filter.sc-snk-filter-bar{display:flex;flex-direction:column;position:fixed;top:0;left:0;width:100%;height:100%;overflow:auto;z-index:var(--snk-personalized-filter--z-index);background-color:var(--snk-personalized-filter--background-color)}.snk-filter__popover.sc-snk-filter-bar{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;min-width:265px;background-color:var(--background--xlight, #fff);border-radius:var(--border--radius-medium, 12px);box-shadow:var(--shadow, 0px 0px 16px 0px #000)}.snk-filter-item__editor-header.sc-snk-filter-bar{flex-grow:1;font-weight:var(--text-weight--medium, 400);color:var(--color--title-primary, #2B3A54)}.snk-filter__popover-rule.sc-snk-filter-bar{border-style:solid;border-color:var(--color--disable-secondary, #F2F5F8);border-radius:1px;border-width:1px;width:100%}.editor__ez-check.sc-snk-filter-bar{--ez-check__label--padding-left:0}.snk-filter-item__editor-header-button.sc-snk-filter-bar{cursor:pointer;background-color:transparent;border:none;padding:3px;outline-color:var(--color--primary)}.snk-filter-bar__divider.sc-snk-filter-bar{margin-bottom:var(--space--small);height:80%}.snk-filter-bar__filter-item-container.sc-snk-filter-bar{display:flex;align-items:start;margin:var(--space--2, 2px) 0}.snk-filter-bar__scroller.sc-snk-filter-bar .sc-snk-filter-bar:first-child{margin-left:var(--space-extra-small, 3px)}.snk-filter-bar__filter-list-items-container.sc-snk-filter-bar{overflow-y:auto;max-height:360px;margin-top:var(--space--small, 6px)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar{cursor:pointer;border-radius:var(--border--radius-small, 6px);border:none;background-color:transparent}.snk-filter-bar__filter-list-item__label.sc-snk-filter-bar{color:var(--title--primary)}.snk-filter-bar__filter-list-item__label--secondary.sc-snk-filter-bar{color:var(--text--primary)}.snk-filter-bar__filter-list-item__icon.sc-snk-filter-bar{--ez-icon--color:var(--title--primary)}.snk-filter-bar__filter-list-item__icon--secondary.sc-snk-filter-bar{--ez-icon--color:var(--text--secondary)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:focus-visible{outline:none;background-color:var(--background--medium)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:hover{background-color:var(--background--medium)}.snk-filter-bar__filter-list-items-container--empty.sc-snk-filter-bar{width:100%;height:100px;display:flex;justify-content:center;align-self:center;align-items:center}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar{position:relative}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar::after{display:flex;position:absolute;content:"";width:8px;height:8px;top:7px;left:17px;background-color:var(--icon--alert--color, #008561);border-radius:50%}.snk-filter-bar__filter-modal-item.sc-snk-filter-bar{--modal-item-border-width:2px;display:flex;flex-direction:row;margin-left:var(--modal-item-border-width);border-radius:var(--border--radius-medium, 12px);background-color:var(--background--medium, #f0f3f7);border:none;width:100%}.snk-filter-bar__filter-modal-item.sc-snk-filter-bar:focus-visible{outline:var(--color--primary) solid var(--modal-item-border-width)}.snk-filter-bar__filter-modal-item__check.sc-snk-filter-bar{width:auto}.snk-filter-bar__filter-modal-item__label.sc-snk-filter-bar{font-weight:var(--text-weight--medium)}.snk-filter-bar__filter-modal-content.sc-snk-filter-bar{display:grid;grid-template-rows:auto auto 1fr auto;width:99%;height:100%}';const A=class{constructor(e){t(this,e),this.visibleChanged=i(this,"visibleChanged",7),this.filterChange=i(this,"filterChange",3),this.detailIsVisible=void 0,this.config=void 0,this.getMessage=void 0,this.showChips=!0}observeDetailIsVisible(t){this.visibleChanged.emit(t)}filterChangeListener(){this.hideDetail()}async showUp(t=!1){var i;this._filterItemElement.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"}),t&&(await(null===(i=this._chipElement)||void 0===i?void 0:i.setBlur()),await this._popover.showUnder(this._chipElement))}async hideDetail(){await this._popover.hide()}getConfigChanges(){var t;const i=this.config;(null===(t=i.groupedItems)||void 0===t?void 0:t.length)&&(i.visible=!1,i.groupedItems=i.groupedItems.map((t=>Object.assign(Object.assign({},t),{visible:!1}))));const e=i.type===_.MULTI_LIST&&Array.isArray(i.value)?i.value.map((t=>Object.assign(Object.assign({},t),{check:!1}))):void 0;return Object.assign(Object.assign({},i),{value:e})}clearFilter(t){if(null==t||t.stopPropagation(),this.canClearFilter()){const t=this.getConfigChanges();this.filterChange.emit(t)}else this.togglePopover()}async togglePopover(t){null==t||t.preventDefault(),null==t||t.stopPropagation(),this.detailIsVisible?await this.hideDetail():await this.showUp(!0)}getLabel(t=!1){var i,e;const{type:s,value:r,label:l,props:a,groupedItems:n=[]}=this.config;if(r||n.length){if(s===_.BINARY_SELECT){const[i,e]=a.options,s=this.getMessage("snkFilterBar.binarySelectTooltip");if(i.name===r)return t?`${s} ${String(i.label).toLowerCase()}`:i.label;if(e.name===r)return t?`${s} ${String(e.label).toLowerCase()}`:e.label}if(s===_.MULTI_SELECT)return`${l}: ${a.options.find((t=>t.value===r)).label}`;if(s===_.PERIOD){let{end:i,start:e}=r;"string"==typeof i&&(i=new Date(i),i.setMinutes(i.getMinutes()+i.getTimezoneOffset())),"string"==typeof e&&(e=new Date(e),e.setMinutes(e.getMinutes()+e.getTimezoneOffset()));const s=new Intl.DateTimeFormat("pt-BR");if(i&&e){const s=e.getFullYear()===i.getFullYear(),r=Object.assign({day:"2-digit",month:"2-digit"},(!s||t)&&{year:"2-digit"}),a=f.formatDate(e,r),n=f.formatDate(i,r);return t?this.getMessage("snkFilterBar.fullPeriodTooltip",{LABEL:l,START_LABEL:a,END_LABEL:n}):`${l}: ${a} → ${n}`}return e?`${l}: ${this.getMessage("snkFilterBar.onlyStartToltip")} ${s.format(e)}`:i?`${l}: ${this.getMessage("snkFilterBar.onlyEndToltip")} ${s.format(i)}`:l}if(s===_.SEARCH)return`${l}: ${r.value} - ${r.label}`;if(s===_.PERSONALIZED){const t=this.calculateActiveCount(n);return t<=0?l:`${l}: ${this.getMessage("snkFilterBar.personalizedCount",{activeCount:t})}`}if(s===_.MULTI_LIST){const e=(null!==(i=r.elements)&&void 0!==i?i:r).filter((t=>null==t?void 0:t.check));return this.getLabelFromCheckedOptions(e,l,t)}if(s===_.CHECK_BOX_LIST){const i=Object.entries(null!=r?r:{}).filter((([t,i])=>!0===i)).map((([t,i])=>t)),s=(null!==(e=a.options)&&void 0!==e?e:[]).filter((t=>i.includes(t.name)));return this.getLabelFromCheckedOptions(s,l,t)}if(s===_.NUMBER&&a.variation===x.INTERVAL){const{start:t,end:i}=r;if(!isNaN(t)&&!isNaN(i))return this.getMessage("snkFilterBar.fullIntervalTooltip",{LABEL:l,START_LABEL:t,END_LABEL:i});if(!isNaN(t))return`${l}: ${this.getMessage("snkFilterBar.onlyStartToltip")} ${Number(t)}`;if(!isNaN(i))return`${l}: ${this.getMessage("snkFilterBar.onlyEndToltip")} ${Number(i)}`}return this.config.mask?`${l}: ${new m(this.config.mask).format(r)}`:`${l}: ${r}`}return l}getLabelFromCheckedOptions(t,i,e){const s=t.length;return 0===s?`${i}`:s>1?e?`${i}: ${t.map((t=>t.label)).join(",")}`:`${i}: ${s} ${this.getMessage("snkFilterBar.multiListToltip")}`:`${i}: ${t[0].label}`}calculateActiveCount(t){return t.reduce(((t,i)=>i.visible?t+1:t),0)}componentDidLoad(){this._filterItemElement&&(o.addIDInfo(this._filterItemElement),this._idSnkFilterDetail=`filterDetail_${this.config.id}`)}canClearFilter(){const{value:t,groupedItems:i=[]}=this.config;return null!=t&&this.config.type===_.MULTI_LIST?t.some((t=>t.check)):void 0!==t||i.some((t=>t.visible))}getRightIconName(){return this.canClearFilter()?"close":this.detailIsVisible?"chevron-up":"chevron-down"}getLeftIconName(){switch(this.config.type){case _.PERIOD:return"calendar";case _.PERSONALIZED:return"tune"}}hasActiveElements(t){var i,e,s;return(null===(s=null===(e=null!==(i=null==t?void 0:t.elements)&&void 0!==i?i:t)||void 0===e?void 0:e.filter((t=>null==t?void 0:t.check)))||void 0===s?void 0:s.length)>0}hasActiveValue(t){return t.type!==_.MULTI_LIST&&void 0!==t.value||this.hasActiveElements(t.value)}getEnabledChip(){if(this.detailIsVisible)return!0;if(this.config.type===_.PERSONALIZED){const{groupedItems:t=[]}=this.config;return t.some((t=>t.visible))}return this.hasActiveValue(this.config)}handleVisibilityPopover(t){this.detailIsVisible=t.detail}render(){const t=this.getLeftIconName();return e(s,null,this.showChips&&e("ez-chip",{id:this.config.id,ref:t=>this._chipElement=t,label:this.getLabel(),value:this.getEnabledChip(),onClick:t=>this.togglePopover(t),disableAutoUpdateValue:!0,type:"secondary"},t&&e("ez-icon",{ref:t=>this._leftIconElement=t,iconName:t,slot:"leftIcon"}),e("ez-icon",{ref:t=>this._rightIconElement=t,iconName:this.getRightIconName(),slot:"rightIcon",id:"removeFilter",onClick:t=>this.clearFilter(t)})),e("ez-popover-core",{ref:t=>this._popover=t,onEzVisibilityChange:t=>this.handleVisibilityPopover(t)},e("snk-filter-detail",{key:this.config.id,config:this.config,getMessage:this.getMessage,class:"sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--16","data-element-id":this._idSnkFilterDetail,showHardFixed:this.showChips})))}get _filterItemElement(){return r(this)}static get watchers(){return{detailIsVisible:["observeDetailIsVisible"]}}};A.style="ez-popover-core.sc-snk-filter-item{--ez-popover__box--z-index:var(--elevation--20, 20);--ez-popover__box--overlay-z-index:var(--elevation--16, 16)}";const P="__SHOWMORE__",D=class{constructor(e){t(this,e),this.snkItemSelected=i(this,"snkItemSelected",7),this._preselection=-1,this.innerClickCheck=(t,i)=>i.id!=p.MODAL_ELEMENT_ID||(this._detailIsVisible=!1,!1),this._filterArgument=void 0,this._showAll=void 0,this.label=void 0,this.iconName=void 0,this.items=void 0,this.getMessage=void 0,this.emptyText=void 0,this.findFilterText=void 0,this.buttonClass=void 0}showDetail(){this._preselection=-1,this._floatingID=p.float(this._popover,this._popoverContainer,{autoClose:!0,innerClickTest:this.innerClickCheck,backClickListener:()=>this.onListCloseCallback(),useOverlay:!0}),this._detailIsVisible=!0,this._showAll=!1,this._filterArgument="",this._filterInput.setFocus()}async hideDetail(){null!=this._floatingID&&p.close(this._floatingID)}onListCloseCallback(){this._floatingID=void 0,this._detailIsVisible=!1}buttonClick(){this._detailIsVisible?this.hideDetail():this.showDetail()}componentDidLoad(){this._element&&o.addIDInfo(this._element)}componentDidRender(){null==this._floatingID&&this._popover&&this._popover.remove()}buildIdElement(t,i){if(!t)return;const e={id:i};t.removeAttribute(o.DATA_ELEMENT_ID_ATTRIBUTE_NAME),o.addIDInfoIfNotExists(t,"filterItemList",e)}buildItemElement(t){const i=++this._selectableItemsCount;return e("button",{ref:i=>i&&this.buildIdElement(i,t.label),id:`filter-item${i}`,onFocusin:()=>this._preselection=i,class:"ez-col ez-col--sd-12 ez-align--middle ez-padding--small sc-snk-filter-bar snk-filter-bar__filter-list-item",onClick:()=>this.itemSelected(t.name),name:t.label,key:i},t.iconName?e("ez-icon",{iconName:t.iconName,size:"small",class:`ez-padding-right--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__icon ${t.iconClass||""}`}):void 0,e("div",{class:`ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__label ${t.labelClass||""}`},t.label))}itemSelected(t){t===P?this._showAll=!0:(this.hideDetail(),this.snkItemSelected.emit(t))}getFilterItems(){const t=this.items?v.applyStringFilter(this._filterArgument,this.items.filter((t=>"FILTER"===t.kind))):[];return 0===t.length?e("div",{class:"ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-items-container--empty"},this.emptyText):(!this._filterArgument&&!this._showAll&&t.length>6&&(t.splice(5),t.push({kind:"INTERNAL",label:this.getMessage("snkFilterList.showMore"),iconName:"dots-horizontal",name:P,iconClass:"snk-filter-bar__filter-list-item__icon--secondary",labelClass:"snk-filter-bar__filter-list-item__label--secondary"})),this._selectableItemsCount=0,e("div",{class:"sc-snk-filter-bar snk-filter-bar__filter-list-items-container"},t.map((t=>this.buildItemElement(t)))))}getFooterItems(){return this.items.filter((t=>"FOOTER"===t.kind))}keyDownHandler(t){switch(t.key){case"ArrowDown":this.changePreselection(this._preselection+1),t.stopImmediatePropagation(),t.stopPropagation(),t.preventDefault();break;case"ArrowUp":this.changePreselection(this._preselection-1),t.stopImmediatePropagation(),t.stopPropagation(),t.preventDefault()}}changePreselection(t){if(t<0&&(t=this._selectableItemsCount),this._preselection=t>this._selectableItemsCount?0:t,0===this._preselection)this._filterInput.setFocus();else{const t=this._element.querySelector(`#filter-item${this._preselection}`);t&&t.focus()}}render(){return e(s,{class:"ez-flex ez-flex--column"},e("ez-button",{class:this.buttonClass,label:this.label,onClick:()=>this.buttonClick(),mode:this.iconName?"icon":void 0,iconName:this.iconName,size:"small"},e("slot",{name:"leftIcon"})),e("section",{class:"ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container",ref:t=>this._popoverContainer=t},e("div",{class:"sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--4",ref:t=>this._popover=t},e("ez-filter-input",{ref:t=>this._filterInput=t,"data-element-id":"serachFilters",mode:"slim",label:this.findFilterText,value:this._filterArgument,onEzChange:t=>this._filterArgument=t.detail,onFocus:()=>this._preselection=0}),this.getFilterItems(),e("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),this.items?this.getFooterItems().map((t=>this.buildItemElement(t))):void 0)))}get _element(){return r(this)}},S=class{constructor(i){t(this,i),this.getMessage=void 0,this.configName=void 0,this.filters=void 0,this.applyFilters=void 0,this.closeModal=void 0,this.addPersonalizedFilter=void 0,this.editPersonalizedFilter=void 0,this.deletePersonalizedFilter=void 0,this.filtersToDelete=[],this.filterDefaultToDelete=void 0,this.disablePersonalizedFilter=void 0}deletePersonalizedFilterListener(t){this.filtersToDelete.push(t.detail)}getCustomMessage(t,i){var e;return null===(e=this.getMessage)||void 0===e?void 0:e.call(this,`snkFilterBar.filterModal.${t}`,i)}handleClearAll(){const{customFilters:t,quickFilters:i,otherFilters:e,multiListFilters:s}=this.filters.reduce(((t,i)=>i.type===_.MULTI_LIST?(t.multiListFilters.push(i),t):i.filterType===I.QUICK_FILTER?(t.quickFilters.push(i),t):i.filterType===I.CUSTOM_FILTER?(t.customFilters.push(i),t):i.filterType===I.OTHER_FILTERS?(t.otherFilters.push(i),t):t),{quickFilters:[],customFilters:[],otherFilters:[],multiListFilters:[]});this.handleClearFilterList(i),this.handleClearCustomFilters(t),this.handleClearOthersFilters(e),s.forEach((t=>this.handleClearSigleFilter(t)))}handleClearOthersFilters(t){this.filters=this.filters.map((i=>t.includes(i)?Object.assign(Object.assign({},i),{value:void 0}):i))}handleClearCustomFilters(t){this.filters.forEach(((i,e)=>{i.filterType===I.CUSTOM_FILTER&&(this.filters[e]=this.clearAllCustomFilter(t).shift())}))}clearAllCustomFilter(t){return t.map((t=>{const i=Object.assign({},t);return delete i.value,i.visible=!1,i.groupedItems&&(i.groupedItems=this.clearAllCustomFilter(i.groupedItems)),i}))}hasChangeToSave(){return n.objectToString(this.filters)!==n.objectToString(this._originalFilterConfig)}handleClose(){if(this.hasChangeToSave())return y.confirm(this.getCustomMessage("validations.notSaved.title"),this.getCustomMessage("validations.notSaved.message")).then((t=>{t&&this.closeModal()}));this.closeModal()}handleApplyFilters(){const t=this.filters.find((t=>t.filterType===I.CUSTOM_FILTER||t.filterType===I.DEFAULT_FILTER));this.isValidCustomFilter(t)&&this.applyFilters(this.filters),this.filtersToDelete.length>0&&(this.filtersToDelete.forEach((t=>{this.deletePersonalizedFilter(t,this.configName)})),this.filtersToDelete=[]),this.filterDefaultToDelete&&(this.deletePersonalizedFilter(this.filterDefaultToDelete,this.configName,!0),this._defaultFilter=void 0,this.filterDefaultToDelete=void 0)}isValidCustomFilter(t){return!!w.validateVariableValues(t)||(y.alert(this.getCustomMessage("validations.notFullFilled.title"),this.getCustomMessage("validations.notFullFilled.message")),!1)}modalActionListener(t){switch(t.detail){case C.CANCEL:this.handleClearAll();break;case C.OK:this.handleApplyFilters();break;case C.CLOSE:this.handleClose()}}handleFilterChange(t){this.filters=this.filters.map((i=>i.id===t.id?t:i))}handleClearFilterList(t){this.filters=this.filters.map((i=>t.includes(i)?Object.assign(Object.assign({},i),{value:void 0}):i))}handleClearSigleFilter(t){if(_.MULTI_LIST===t.type){let i=n.copy(t);this.uncheckFilterValues(i.value);const e=n.copy(this.filters),s=e.findIndex((i=>i.id===t.id));return e.splice(s,1,i),void(this.filters=n.copy(e))}if(_.CHECK_BOX_LIST===t.type){const i=n.copy(this.filters);return i.find((i=>i.id===t.id)).value=void 0,void(this.filters=n.copy(i))}this.filters.find((i=>i.id===t.id)).value=void 0,this.filters=n.copy(this.filters)}uncheckFilterValues(t){return t.forEach((t=>{t&&(t.check=!1)})),t}renderFilterItem(t,i){return e("snk-filter-modal-item",{class:i?"ez-col ez-col--sd-12":"ez-col ez-col--sd-6 ez-padding--small",filterItem:t,configName:this.configName,onFilterChange:t=>this.handleFilterChange(t.detail),onEditPersonalizedFilter:t=>this.editPersonalizedFilter(t.detail),onAddPersonalizedFilter:()=>this.addPersonalizedFilter()})}isDefaultFilterNumberVariation(t){var i;return t.type===_.NUMBER&&(!t.props.variation||(null===(i=t.props)||void 0===i?void 0:i.variation)===x.DEFAULT)}mountFiltersLines(t){let i=0,e=!1;const s={};for(let r=0;r<t.length;r++){s[i]=s[i]||[];const l=t[r],a=r===t.length-1,n=l.type===_.TEXT||this.isDefaultFilterNumberVariation(l),o=!a&&(t[r+1].type===_.TEXT||this.isDefaultFilterNumberVariation(t[r+1]));n&&o||e?(s[i].push(l),e=s[i].length<2,2===s[i].length&&++i):(s[i]=s[i]||[],s[i].push(l),++i)}return Object.values(s)}renderFilterLine(t){const i=1===t.length;return t.map((t=>this.renderFilterItem(t,i)))}getIformedFiltersCount(t){let i=0;return t.forEach((t=>{var e,s,r,l,a,n;_.MULTI_LIST!==t.type?_.CHECK_BOX_LIST!==t.type?null==t.groupedItems?t.value&&i++:i=t.groupedItems.filter((t=>t.visible)).length:i+=Object.entries(null!==(n=t.value)&&void 0!==n?n:{}).filter((([t,i])=>!0===i)).map((([t,i])=>t)).length:i+=null!==(a=null===(l=null===(r=null!==(s=null===(e=t.value)||void 0===e?void 0:e.elements)&&void 0!==s?s:t.value)||void 0===r?void 0:r.filter((t=>null==t?void 0:t.check)))||void 0===l?void 0:l.length)&&void 0!==a?a:0})),i}renderCollapsibleFilterBox(t,i,s,r=!0){if(!i.length)return null;const l=this.getIformedFiltersCount(i),a=this.mountFiltersLines(i);return e("ez-collapsible-box",{class:"snk-filter-modal__collapsible-box",headerSize:"medium",value:!0,label:t},!!l&&e("ez-badge",{class:"ez-badge--primary-subtle",slot:"rightSlot",label:null==l?void 0:l.toString()}),e("div",{class:"ez-row snk-filter-modal__rendered-items"},a.map(this.renderFilterLine.bind(this))),r&&e("div",{class:"ez-flex ez-flex--justify-end grow"},e("ez-button",{class:"ez-button--tertiary",size:"medium",label:this.getCustomMessage("clearModal"),onClick:()=>s?this.handleClearSigleFilter(i[0]):this.handleClearFilterList(i)})))}handleDeleteFilter(){this._application.confirm(this.getMessage("snkPersonalizedFilter.deleteConfirm.title"),this.getMessage("snkPersonalizedFilter.info.deleteDefaultFilterConfirm"),"alert-circle-inverted","critical").then((t=>{t&&(this.filterDefaultToDelete=this._defaultFilter,this.filters=this.filters.filter((t=>t.id!==I.DEFAULT_FILTER)))}))}handleActionSelectedDefaultFilter({detail:t}){switch(t){case $.CREATE:this.addPersonalizedFilter(!0);break;case $.EDIT:this.editPersonalizedFilter(this._defaultFilter.id,!0);break;case $.REMOVE:this.handleDeleteFilter()}}getCustomFilter(t){return t.filter((t=>t.filterType===I.CUSTOM_FILTER))}getDefaultFilter(t){return t.find((t=>t.id===z.id))}componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__")}componentWillRender(){this._modalTitle=this.getCustomMessage("title"),this._okButtonLabel=this.getCustomMessage("okButtonLabel"),this._cancelButtonLabel=this.getCustomMessage("cancelButtonLabel")}componentDidLoad(){this._originalFilterConfig||(this._originalFilterConfig=this.filters)}render(){this._defaultFilter=this.getDefaultFilter(this.filters);const t=this.getCustomFilter(this.filters),i=this.filters.filter((t=>t.filterType===I.QUICK_FILTER)),s=this.filters.filter((t=>t.filterType===I.OTHER_FILTERS));return e("ez-modal-container",{class:"snk-filter-modal__container",modalTitle:this._modalTitle,cancelButtonLabel:this._cancelButtonLabel,okButtonLabel:this._okButtonLabel,onEzModalAction:this.modalActionListener.bind(this)},e("div",{class:"snk-filter-modal__content ez-col--sd-12"},e("snk-default-filter",{getMessage:this.getCustomMessage.bind(this),hasDefaultFilter:!!this._defaultFilter,onActionSelected:this.handleActionSelectedDefaultFilter.bind(this)}),!this.disablePersonalizedFilter&&this.renderCollapsibleFilterBox(this.getCustomMessage("customFilters"),t,!1,!1),this.renderCollapsibleFilterBox(this.getCustomMessage("quickFilters"),i,!1),s.map((t=>this.renderCollapsibleFilterBox(t.label,[t],!0)))))}};S.style="ez-modal{--ez-modal-content-padding:24px 12px}.snk-filter-modal__container{width:344px;max-width:344px;min-width:344px;overflow:hidden}.snk-filter-modal__content{display:flex;flex-direction:column;gap:var(--space--medium, 12px);padding-right:var(--space--3xs, 4px)}.snk-filter-modal__collapsible-box{border:var(--border--small, 1px solid) var(--color--strokes, #DCE0E8);border-radius:var(--border--radius-medium);padding:var(--space--medium, 12px) var(--space--small, 6px)}.snk-filter-modal__rendered-items{max-height:760px;overflow-x:hidden;overflow-y:auto}.snk-filter-modal__rendered-items::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";export{T as snk_filter_bar,A as snk_filter_item,D as snk_filter_list,S as snk_filter_modal}