@sankhyalabs/sankhyablocks 10.1.0-dev.57 → 10.1.0-dev.59
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.
- package/dist/cjs/{ConfigStorage-a28eceb2.js → ConfigStorage-156bfcac.js} +2 -2
- package/dist/cjs/{DataFetcher-98d95e8f.js → DataFetcher-d13b4637.js} +12 -0
- package/dist/cjs/{ISave-a9815bb3.js → ISave-55d9dcc3.js} +1 -1
- package/dist/cjs/{SnkFormConfigManager-af47ba2f.js → SnkFormConfigManager-5cb9a39c.js} +2 -2
- package/dist/cjs/{SnkMultiSelectionListDataSource-13774e5f.js → SnkMultiSelectionListDataSource-5c5badfc.js} +5 -5
- package/dist/cjs/{auth-fetcher-9c257a1f.js → auth-fetcher-d1715459.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-afc246d8.js → dataunit-fetcher-fae710c5.js} +1 -1
- package/dist/cjs/{form-config-fetcher-1ce4125c.js → form-config-fetcher-bbebdcb8.js} +1 -1
- package/dist/cjs/{index-e3e39724.js → index-bc950921.js} +6 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pesquisa-grid_2.cjs.entry.js +5 -5
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_9.cjs.entry.js +9 -9
- package/dist/cjs/snk-application.cjs.entry.js +7 -7
- package/dist/cjs/snk-attach_11.cjs.entry.js +14 -12
- package/dist/cjs/snk-crud.cjs.entry.js +14 -10
- package/dist/cjs/snk-data-exporter.cjs.entry.js +59 -14
- package/dist/cjs/{snk-data-unit-ab570f87.js → snk-data-unit-32237a2d.js} +2 -2
- package/dist/cjs/snk-data-unit.cjs.entry.js +3 -3
- package/dist/cjs/snk-detail-view.cjs.entry.js +9 -9
- package/dist/cjs/snk-dynaform-detail-view_2.cjs.entry.js +33 -10
- package/dist/cjs/{snk-dynaform-guides-view-30ce5a8c.js → snk-dynaform-guides-view-2c7c6ce4.js} +389 -42
- package/dist/cjs/snk-dynaform-guides-view.cjs.entry.js +6 -6
- package/dist/cjs/snk-dynaform.cjs.entry.js +14 -10
- package/dist/cjs/snk-filter-bar_4.cjs.entry.js +4 -4
- package/dist/cjs/snk-form_2.cjs.entry.js +4 -4
- package/dist/cjs/snk-grid.cjs.entry.js +8 -8
- package/dist/cjs/{snk-guides-viewer-2a55fa3a.js → snk-guides-viewer-67b9cca9.js} +2 -2
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -7
- package/dist/cjs/snk-layout-form-config.cjs.entry.js +5 -5
- package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
- package/dist/cjs/snk-taskbar.cjs.entry.js +2 -2
- package/dist/cjs/{taskbar-elements-80eddec8.js → taskbar-elements-25f800b3.js} +1 -1
- package/dist/cjs/{taskbarUtils-4ca4235e.js → taskbarUtils-99aaa01f.js} +11 -6
- package/dist/collection/components/snk-actions-button/snk-actions-button.js +3 -3
- package/dist/collection/components/snk-crud/snk-crud.css +9 -4
- package/dist/collection/components/snk-crud/snk-crud.js +5 -1
- package/dist/collection/components/snk-crud/utils/taskbarUtils.js +5 -0
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +2 -2
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +8 -4
- package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +43 -2
- package/dist/collection/components/snk-dynaform/snk-dynaform.css +9 -4
- package/dist/collection/components/snk-dynaform/snk-dynaform.js +5 -1
- package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-detail-view/snk-dynaform-detail-view.css +71 -1
- package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-detail-view/snk-dynaform-detail-view.js +23 -0
- package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-form-view/snk-dynaform-form-view.css +35 -1
- package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-form-view/snk-dynaform-form-view.js +3 -1
- package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-guides-view/snk-dynaform-guides-view.css +229 -6
- package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-guides-view/snk-dynaform-guides-view.js +458 -38
- package/dist/collection/components/snk-dynaform-form-config/SnkFormConfigManager.js +8 -1
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +1 -1
- package/dist/collection/lib/@types/index.js +6 -0
- package/dist/collection/lib/message/resources/en-us/snk-crud.msg.js +4 -0
- package/dist/collection/lib/message/resources/es-es/snk-crud.msg.js +4 -0
- package/dist/collection/lib/message/resources/pt-br/snk-crud.msg.js +4 -0
- package/dist/components/ISave.js +6 -0
- package/dist/components/SnkMessageBuilder.js +12 -0
- package/dist/components/snk-actions-button2.js +3 -3
- package/dist/components/snk-crud.js +6 -2
- package/dist/components/snk-data-exporter2.js +53 -8
- package/dist/components/snk-dynaform-detail-view2.js +419 -41
- package/dist/components/snk-dynaform-form-view2.js +4 -2
- package/dist/components/snk-dynaform.js +6 -2
- package/dist/components/snk-filter-bar2.js +1 -1
- package/dist/components/taskbarUtils.js +5 -0
- package/dist/esm/{ConfigStorage-346d781d.js → ConfigStorage-0d1c0695.js} +2 -2
- package/dist/esm/{DataFetcher-7d8df5a2.js → DataFetcher-70de9419.js} +12 -0
- package/dist/esm/{ISave-2117075a.js → ISave-f5704813.js} +1 -1
- package/dist/esm/{SnkFormConfigManager-066d370b.js → SnkFormConfigManager-e7f05f79.js} +2 -2
- package/dist/esm/{SnkMultiSelectionListDataSource-7c5ffcd4.js → SnkMultiSelectionListDataSource-6ac291a9.js} +5 -5
- package/dist/esm/{auth-fetcher-5891e22c.js → auth-fetcher-e34880e5.js} +1 -1
- package/dist/esm/{dataunit-fetcher-5dcb0e89.js → dataunit-fetcher-d26e4a08.js} +1 -1
- package/dist/esm/{form-config-fetcher-8e2082f3.js → form-config-fetcher-98c42169.js} +1 -1
- package/dist/esm/{index-b40568ff.js → index-c6721886.js} +6 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pesquisa-grid_2.entry.js +5 -5
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_9.entry.js +9 -9
- package/dist/esm/snk-application.entry.js +7 -7
- package/dist/esm/snk-attach_11.entry.js +14 -12
- package/dist/esm/snk-crud.entry.js +14 -10
- package/dist/esm/snk-data-exporter.entry.js +59 -14
- package/dist/esm/{snk-data-unit-f697345b.js → snk-data-unit-ff57ac90.js} +2 -2
- package/dist/esm/snk-data-unit.entry.js +3 -3
- package/dist/esm/snk-detail-view.entry.js +9 -9
- package/dist/esm/snk-dynaform-detail-view_2.entry.js +33 -10
- package/dist/esm/{snk-dynaform-guides-view-6aae38f7.js → snk-dynaform-guides-view-0dfbefc1.js} +390 -43
- package/dist/esm/snk-dynaform-guides-view.entry.js +6 -6
- package/dist/esm/snk-dynaform.entry.js +14 -10
- package/dist/esm/snk-filter-bar_4.entry.js +4 -4
- package/dist/esm/snk-form_2.entry.js +4 -4
- package/dist/esm/snk-grid.entry.js +8 -8
- package/dist/esm/{snk-guides-viewer-3ea7e312.js → snk-guides-viewer-31a0a23d.js} +2 -2
- package/dist/esm/snk-guides-viewer.entry.js +7 -7
- package/dist/esm/snk-layout-form-config.entry.js +5 -5
- package/dist/esm/snk-pesquisa.entry.js +5 -5
- package/dist/esm/snk-taskbar.entry.js +2 -2
- package/dist/esm/{taskbar-elements-63651ca7.js → taskbar-elements-ba9d6889.js} +1 -1
- package/dist/esm/{taskbarUtils-a43e4bba.js → taskbarUtils-cb9db0d9.js} +11 -6
- package/dist/sankhyablocks/{p-3190ac29.js → p-097d75b3.js} +2 -2
- package/dist/sankhyablocks/{p-aa9d61fa.entry.js → p-12579574.entry.js} +1 -1
- package/dist/sankhyablocks/{p-741f1ad0.entry.js → p-1d31aec3.entry.js} +1 -1
- package/dist/sankhyablocks/{p-6f2de911.entry.js → p-250b273e.entry.js} +1 -1
- package/dist/sankhyablocks/p-2a83f20e.entry.js +1 -0
- package/dist/sankhyablocks/p-2c4f7fdd.entry.js +1 -0
- package/dist/sankhyablocks/{p-3072136e.js → p-2ec98523.js} +1 -1
- package/dist/sankhyablocks/{p-10d883b0.js → p-4dd574d6.js} +1 -1
- package/dist/sankhyablocks/{p-7827871d.entry.js → p-541c72ec.entry.js} +1 -1
- package/dist/sankhyablocks/p-5aeae67f.js +1 -0
- package/dist/sankhyablocks/p-5ef0e9a8.entry.js +1 -0
- package/dist/sankhyablocks/{p-9e97fabb.entry.js → p-6d3bcabf.entry.js} +1 -1
- package/dist/sankhyablocks/p-6f60df43.js +1 -0
- package/dist/sankhyablocks/{p-58e0f14b.entry.js → p-846d8f79.entry.js} +1 -1
- package/dist/sankhyablocks/{p-77f608bc.entry.js → p-885262ce.entry.js} +1 -1
- package/dist/sankhyablocks/{p-c1e168a2.js → p-8d1ef77a.js} +1 -1
- package/dist/sankhyablocks/{p-13f91e7e.js → p-8d81c8d3.js} +1 -1
- package/dist/sankhyablocks/{p-ee192f06.entry.js → p-8f5dd87d.entry.js} +1 -1
- package/dist/sankhyablocks/{p-c5889dae.js → p-90037547.js} +1 -1
- package/dist/sankhyablocks/p-9e02a785.js +1 -0
- package/dist/sankhyablocks/{p-5a8390f9.entry.js → p-a25ab2ff.entry.js} +1 -1
- package/dist/sankhyablocks/p-a696bbcd.entry.js +1 -0
- package/dist/sankhyablocks/{p-b3762105.entry.js → p-a9012341.entry.js} +1 -1
- package/dist/sankhyablocks/p-abcb646d.js +1 -0
- package/dist/sankhyablocks/{p-733eba69.js → p-bd2a845c.js} +1 -1
- package/dist/sankhyablocks/p-bfce617e.entry.js +1 -0
- package/dist/sankhyablocks/{p-3630a5ae.entry.js → p-c4b34e2b.entry.js} +1 -1
- package/dist/sankhyablocks/{p-8d513b64.js → p-c9440c8a.js} +1 -1
- package/dist/sankhyablocks/p-cd153f71.entry.js +1 -0
- package/dist/sankhyablocks/{p-e91bd00e.js → p-eac48627.js} +1 -1
- package/dist/sankhyablocks/{p-d7657667.js → p-ec7c87bb.js} +1 -1
- package/dist/sankhyablocks/p-fb6e3c65.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-data-exporter/structure/ItemBuilder.d.ts +16 -0
- package/dist/types/components/snk-dynaform/subcomponents/snk-dynaform-detail-view/snk-dynaform-detail-view.d.ts +11 -0
- package/dist/types/components/snk-dynaform/subcomponents/snk-dynaform-form-view/snk-dynaform-form-view.d.ts +1 -0
- package/dist/types/components.d.ts +32 -0
- package/dist/types/lib/@types/index.d.ts +6 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +2 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-0f3698af.js +0 -1
- package/dist/sankhyablocks/p-1bc6849e.js +0 -1
- package/dist/sankhyablocks/p-2c65dc01.entry.js +0 -1
- package/dist/sankhyablocks/p-3cc67d50.entry.js +0 -1
- package/dist/sankhyablocks/p-4a53fbeb.entry.js +0 -1
- package/dist/sankhyablocks/p-7e63af25.entry.js +0 -1
- package/dist/sankhyablocks/p-a8a93568.entry.js +0 -1
- package/dist/sankhyablocks/p-acd3adf9.entry.js +0 -1
- package/dist/sankhyablocks/p-c3bc693a.js +0 -1
- package/dist/sankhyablocks/p-c6b6567f.entry.js +0 -1
- package/dist/sankhyablocks/p-ed1b1b14.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,e as i,h as s,f as e,F as n,g as a}from"./p-2c9d0870.js";import{ApplicationContext as o,DataType as r,Action as l,UserInterface as h,StringUtils as d,DataUnitLoaderUtils as c,DataUnit as u,ElementIDUtils as v,ObjectUtils as m,KeyboardManager as f}from"@sankhyalabs/core";import{D as p,S as g}from"./p-10d883b0.js";import{S as b}from"./p-3190ac29.js";import{P as k}from"./p-0f3698af.js";import{P as _,D as y,I as w}from"./p-c1e168a2.js";import{F as C}from"./p-ff1990ad.js";import{F as z}from"./p-d7657667.js";import{V as A,S as x}from"./p-9019a32f.js";import{A as S}from"./p-c3bc693a.js";import{T as O}from"./p-3072136e.js";import{A as F,F as I}from"./p-0dbd53d9.js";import{focusOnFieldSerch as E,SEARCH_FIELD_FULL_WIDTH as P,FormLayout as N,ApplicationUtils as T,CSSVarsUtils as L,buildFieldSearch as D}from"@sankhyalabs/ezui/dist/collection/utils";import{DataBinder as j}from"@sankhyalabs/ezui/dist/collection/utils/form";import{g as R,b as M,s as U,a as V,d as B}from"./p-af673291.js";import{P as K,a as G,D as $}from"./p-58709cf9.js";import{E as q}from"./p-1a68fb59.js";import{C as H,P as Q}from"./p-13f91e7e.js";import{s as J}from"./p-a73b6b00.js";import{S as W,T as X,R as Y,a as Z,b as tt}from"./p-733eba69.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{S as it}from"./p-8d513b64.js";import{C as st}from"./p-e5a3711f.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-7dd49d15.js";import"./p-8f3f2306.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";class et{constructor(t){this.dataUnitName=t}async save({dataUnit:t,record:i,updatingFields:s,operation:e}){var n,a;const o="INSERT"==e,r=o?s:i;if(!o&&(null==s?void 0:s.DESCRICAO)&&(null==s?void 0:s.DESCRICAO)!==(null==i?void 0:i.DESCRICAO))throw new Error(b.DESCRIPTION_CANNOT_BE_CHANGED);const l={anexo:{codata:o?null==s?void 0:s.REGISTER_KEY:null==i?void 0:i.CODATA,sequencia:(null==r?void 0:r.SEQUENCIA)||"0",tipo:(null==r?void 0:r.TIPO)||"N",descricao:null==r?void 0:r.DESCRICAO,arquivo:null===(a=null===(n=s.CAMINHO_ARQUIVO)||void 0===n?void 0:n[0])||void 0===a?void 0:a.name,ehInclusao:o?"S":"N",ehArquivoRepositorio:"N"}};return new Promise(((i,e)=>{p.get().callServiceBroker("Attach.save",JSON.stringify(l)).then((e=>{var n;return i([Object.assign(Object.assign(Object.assign({},e),s),{__owner__dataunit__name__:null!==(n=this.dataUnitName)&&void 0!==n?n:t})])})).catch((t=>e(t)))}))}async edit(t){throw new Error("Method not implemented.")}async delete(t){var i={anexo:{codata:t.CODATA,tipo:t.TIPO,descricao:t.DESCRICAO}};const s=await p.get().callServiceBroker("Attach.remove",JSON.stringify(i));return Promise.resolve(s)}async getDownloadKey(t){var i,s,e;if("S"==t.EHARQUIVOREPOSITORIO){const e={config:{path:t.ARQUIVO,tipoconteudo:t.TIPOCONTEUDO}},n=await p.get().callServiceBroker("RepositorioArquivoSP.abreArquivo",JSON.stringify(e));return Promise.resolve({chave:{valor:null===(s=null===(i=null==n?void 0:n.responseBody)||void 0===i?void 0:i.chave)||void 0===s?void 0:s.valor}})}const n={anexo:{codata:t.CODATA,codemp:t.CODEMP,sequencia:t.SEQUENCIA,tipo:t.TIPO,descricao:t.DESCRICAO,tipoConteudo:t.TIPOCONTEUDO}},a=await p.get().callServiceBroker("Attach.view",JSON.stringify(n));return(null==a?void 0:a.chaveAnexo)?Promise.resolve({chave:{valor:null===(e=null==a?void 0:a.chaveAnexo)||void 0===e?void 0:e.idChaveAnexo}}):Promise.reject(new Error("File not found."))}}const nt="AnexoSistemaSP.salvar",at="AnexoSistemaSP.excluir",ot="AnexoSistemaSP.baixar";class rt{constructor(t,i){var s;this.entityName=t,this.dataUnitName=i,this.validateFields=t=>{if(t.LINK&&t.NOMEARQUIVO)throw new Error(b.LINK_AND_FILE_AT_THE_SAME_TIME);if(!t.LINK&&!t.NOMEARQUIVO)throw new Error(b.ANY_LINK_OR_FILE_FILLED);if(!this._registerKey)throw new Error("Register key can not be null")},this.resourceID=window.resourceID||(null===(s=window.workspace)||void 0===s?void 0:s.resourceID)}set registerKey(t){this._registerKey=t}async save(t){var i,s;let{updatingFields:e}=t;e=Object.assign(Object.assign({},e),{NOMEARQUIVO:null===(i=e.NOMEARQUIVO)||void 0===i?void 0:i[0]});try{this.validateFields(e);const t=e.LINK?null:e.NOMEARQUIVO,i={serviceName:nt,requestBody:{params:{resourceID:this.resourceID,description:e.DESCRICAO,fileSelect:t?1:0,keySession:null===(s=null==t?void 0:t.properties)||void 0===s?void 0:s.fileNameTmp,nameAttach:null==t?void 0:t.name,link:e.LINK,nameEntity:this.entityName,pkEntity:this._registerKey,typeAcess:e.TIPOACESSO,typeApres:e.TIPOAPRES}}},n=await p.get().callServiceBroker(nt,JSON.stringify(i));return Promise.resolve([Object.assign(Object.assign(Object.assign({},n),e),{ARQUIVOOULINK:e.LINK?e.LINK:null==t?void 0:t.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}async edit(t){var i,s,e;let{updatingFields:n,record:a}=t;const o=t=>void 0!==n[t]?n[t]:a[t],r=o("NOMEARQUIVO"),l=null===(s=null===(i=n.NOMEARQUIVO)||void 0===i?void 0:i[0])||void 0===s?void 0:s.downloadURL;n=Object.assign(Object.assign({},n),{DESCRICAO:o("DESCRICAO"),LINK:o("LINK"),TIPOACESSO:o("TIPOACESSO"),TIPOAPRES:o("TIPOAPRES"),CHAVEARQUIVO:a.CHAVEARQUIVO,NOMEARQUIVO:null==r?void 0:r[0]});const h=n.LINK?null:n.NOMEARQUIVO;try{this.validateFields(n);const t={serviceName:nt,requestBody:{params:{resourceID:this.resourceID,nuAttach:null==a?void 0:a.NUATTACH,description:n.DESCRICAO,fileSelect:l?1:0,keySession:null===(e=null==h?void 0:h.properties)||void 0===e?void 0:e.fileNameTmp,keyAttach:n.CHAVEARQUIVO,nameAttach:null==h?void 0:h.name,link:n.LINK,nameEntity:this.entityName,pkEntity:this._registerKey,typeAcess:n.TIPOACESSO,typeApres:n.TIPOAPRES}}},i=await p.get().callServiceBroker(nt,JSON.stringify(t));return Promise.resolve([Object.assign(Object.assign(Object.assign({},i),n),{ARQUIVOOULINK:n.LINK?n.LINK:null==h?void 0:h.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}delete(t){var i;const s=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},e={serviceName:at,requestBody:{paramsDelete:{keyAttach:t.CHAVEARQUIVO,nameAttach:null==s?void 0:s.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO}}};return new Promise(((t,i)=>{p.get().callServiceBroker(at,JSON.stringify(e)).then((i=>t(i))).catch((t=>i(t)))}))}getDownloadKey(t){var i;const s=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},e={serviceName:ot,requestBody:{paramsDown:{nameAttach:null==s?void 0:s.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO,keyAttach:t.CHAVEARQUIVO}}};return new Promise(((t,i)=>{p.get().callServiceBroker(ot,JSON.stringify(e)).then((i=>t(i))).catch((t=>i(t)))}))}}class lt{constructor(t,i){this.entityName=t,this.getMessage=i,this._application=o.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,s){this.loader||(this.loader=t.dataLoader),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,e)=>this.saveLoader(e,i).then((t=>(t.length&&s(),t))),t.removeLoader=(t,e)=>this.removeLoader(t,e,i).then((t=>(t.length&&s(),t)))}metadataLoader(t){throw new Error("Method not implemented.")}dataLoader(t,i){return new Promise((s=>{this.loader(t,i).then((t=>{const i=((null==t?void 0:t.records)||[]).map((t=>{let i;return t.LINK||(i=[{name:t.NOMEARQUIVO}]),Object.assign(Object.assign({},t),{ARQUIVOOULINK:t.LINK?t.LINK:t.NOMEARQUIVO,NOMEARQUIVO:i})}));s(Object.assign(Object.assign({},t),{records:i}))}))}))}saveLoader(t,i){return new Promise((s=>{var e;const n=Array.isArray(t)?t[0]:{};((null===(e=null==n?void 0:n.record)||void 0===e?void 0:e.NUATTACH)>=0?i.edit.bind(i):i.save.bind(i))(n).then((t=>{s(t)})).catch((t=>t.message===b.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),s([])):t.message===b.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),s([])):t.message?(this._application.error(t.title||t.name,t.message),s([])):void s([])))}))}removeLoader(t,i,s){return new Promise((e=>{const{records:n}=t.getSelectionInfo(),a=n[0];s.delete(a).then((()=>(_.removeRecords(t,[a]),e(i))))}))}getFilters(t){return[{name:"AttachmentsByPK",expression:"this.PKREGISTRO = :PKREGISTRO",params:[{name:"PKREGISTRO",dataType:r.TEXT,value:`${t}_${this.entityName}`}]}]}getInterceptions(t,i,s){return new Promise((e=>i.type===l.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(s.goToView(A.GRID),e(i)):e(void 0))):e(i):i.type===l.DATA_SAVED?(t.loadData(),e(i)):void e(i)))}}let ht;const dt=t=>(ht||(ht=new g),ht.getMessage(t)),ct={grid:{columns:[{name:"CODATA",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"ARQUIVO",orderIndex:2,width:0},{name:"DTALTER",orderIndex:3,width:0},{name:"USUARIO",orderIndex:4,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",label:dt("snkAttach.attachMetadata.lblDescription"),visible:!0,readOnly:!1,required:!0},{name:"CAMINHO_ARQUIVO",label:dt("snkAttach.attachMetadata.lblFile"),visible:!0,readOnly:!1,required:!0}]}},ut={name:"Attach",label:"Attach List",fields:[{name:"CODATA",label:dt("snkAttach.attachMetadata.lblCode"),dataType:r.TEXT},{name:"DESCRICAO",label:dt("snkAttach.attachMetadata.lblDescription"),dataType:r.TEXT,readOnly:!1},{name:"ARQUIVO",label:dt("snkAttach.attachMetadata.lblFileOrLink"),dataType:r.TEXT},{name:"USUARIO",label:dt("snkAttach.attachMetadata.lblUser"),dataType:r.TEXT},{name:"DTALTER",label:dt("snkAttach.attachMetadata.lblDate"),dataType:r.TEXT},{name:"CAMINHO_ARQUIVO",label:dt("snkAttach.attachMetadata.lblFileUpload"),dataType:r.OBJECT,userInterface:h.FILE,readOnly:!1,required:!0,visible:!0,properties:{subTitle:dt("snkAttach.attachMetadata.lblSubTitle"),MAX_FILES:1,STORAGESTRATEGY:"SESSION",INTERNAL_FILENAME:"Attach.upload"}}]};class vt{constructor(t){this.getMessage=t,this._records=[],this._application=o.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,s){t.metadataLoader=t=>this.metadataLoader(t),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,e)=>this.saveLoader(e,i).then((t=>(t.length&&s(),t))),t.removeLoader=(t,e)=>this.removeLoader(t,e,i).then((t=>(t.length&&s(),t)))}metadataLoader(t){return Promise.resolve(ut)}async dataLoader(t,i){if(!i.source)return Promise.resolve({records:this._records});if(!Number.isNaN(Number(i.source))){const t={criteria:{codata:i.source,tipoAnexo:"N"}},s=await this._application.getDataFetcher(),{anexos:{anexo:e=[]}}=await s.callServiceBroker("Attach.load",JSON.stringify(t)),n=[];e.forEach((t=>{n.push(Object.assign({__record__id__:d.generateUUID(),CAMINHO_ARQUIVO:[{name:null==t?void 0:t.ARQUIVO}]},t))})),this._records=n}return c.buildLoadDataResponse(this._records,t,i)}saveLoader(t,i){return new Promise((s=>{const e=Array.isArray(t)?t[0]:{};i.save(e).then(s).catch((t=>t.message===b.DESCRIPTION_CANNOT_BE_CHANGED?(this._application.alert(this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.title"),this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.message")),s([])):t.message===b.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),s([])):t.message===b.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),s([])):t.message?(this._application.error(t.title||t.name,t.message),s([])):void s([])))}))}removeLoader(t,i,s){return new Promise((e=>{t.getSelectionInfo().records.forEach((async t=>{this._application.hasAccess(S.REMOVE).then((async n=>{n&&(await s.delete(t),e(i))}))}))}))}getFilters(){throw new Error("Method not implemented.")}getInterceptions(t,i,s){return new Promise((e=>{var n,a,o,r,h,d;switch(i.type){case l.EDITION_CANCELED:return t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(s.goToView(A.GRID),e(i)):e(void 0))):e(i);case l.DATA_SAVED:return t.loadData(void 0,void 0,!1,null===(o=null===(a=null===(n=null==i?void 0:i.payload)||void 0===n?void 0:n.records)||void 0===a?void 0:a[0])||void 0===o?void 0:o.REGISTER_KEY),e(i);case l.RECORDS_REMOVED:return t.loadData(void 0,void 0,!1,null===(d=null===(h=null===(r=null==i?void 0:i.payload)||void 0===r?void 0:r.cachedRecords)||void 0===h?void 0:h[0])||void 0===d?void 0:d.CODATA),e(i)}e(i)}))}}let mt;const ft=t=>{var i;if(!mt){const t=o.getContextValue("__SNK__APPLICATION__");mt=null==t?void 0:t.messagesBuilder}return null===(i=null==mt?void 0:mt.getMessage)||void 0===i?void 0:i.call(mt,t,null)},pt={DOWNLOAD:{hint:ft("snkAttach.taskbar.titleDownload"),name:"DOWNLOAD",iconName:"file-download"},LINK:{hint:ft("snkAttach.taskbar.titleLink"),name:"LINK",iconName:"launch"}},gt=()=>{const t=[O.REMOVE,"DOWNLOAD","LINK"];return{getButtons:(t,i,s)=>{const e=s.indexOf(O.REFRESH);if((null==i?void 0:i.insertionMode)||(null==i?void 0:i.isDirty))return s.reverse();-1!==e&&s.splice(e,1);const{selectedRecord:n}=i||{},a=(null==n?void 0:n.LINK)?pt.LINK:pt.DOWNLOAD;s.splice(s.indexOf(O.DIVIDER)+1,0,O.REMOVE,a,O.DIVIDER);const o=[O.CLONE,O.DATA_EXPORTER],r=Array.from(new Set(s.filter((t=>!o.includes(t)))));return r.splice(r.indexOf(a)+1,0,O.DIVIDER),r},isEnabled:(i,s,e)=>{const n=void 0!==(null==s?void 0:s.selectedRecord);return!(t.includes(e)&&!n)}}},bt={grid:{columns:[{name:"ARQUIVOOULINK",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"DHCAD",orderIndex:2,width:0},{name:"DHALTER",orderIndex:3,width:0},{name:"TIPOAPRES",orderIndex:4,width:0},{name:"TIPOACESSO",orderIndex:5,width:0},{name:"CODUSU",orderIndex:6,width:0},{name:"CODUSUALT",orderIndex:7,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",required:!0},{name:"TIPOAPRES",required:!0},{name:"TIPOACESSO",required:!0},{name:"LINK"},{name:"NOMEARQUIVO"}]}},kt=class{constructor(s){t(this,s),this.ezClosePopup=i(this,"ezClosePopup",7),this.handleTaskbarClick=async({detail:t})=>{if(["DOWNLOAD","LINK"].includes(t))return this.downloadAttachment(this._currentDataUnit.getSelectedRecord());"Attach"===this.fetcherType&&["SAVE"].includes(t)&&this._currentDataUnit.isDirty()&&await this._currentDataUnit.setFieldValue("REGISTER_KEY",this.registerKey)},this.handleBack=()=>{this._currentDataUnit.cancelEdition().then((t=>{t&&this.close()}))},this.handleFinish=()=>{if(!this._currentDataUnit.isDirty())return this.close();this.validateAnexoSistema()&&this._currentDataUnit.saveData().then((()=>{this.showFinishedToast(),this.close()}))},this._isOpen=!1,this.gridLegacyConfigName=void 0,this.fetcherType=void 0,this.fetcher=void 0,this.dataUnit=void 0,this.dataUnitBuilder=void 0,this.registerKey=void 0,this.entityName=void 0,this.messagesBuilder=void 0,this._currentFetcher=void 0,this._currentDataUnit=void 0,this.crudConfig=void 0,this._appResourceID=void 0}async open(){this._isOpen=!0,this._currentDataUnit||await this.initAttach(),this._refPopup&&(this._refPopup.opened=!0),this.fetcherType||(this.fetcherType="AnexoSistema"),null==this._currentDataUnit&&this.loadAttachmentDataUnit()}async close(){this._isOpen=!1,this._refPopup&&(this._refPopup.opened=!1)}async registerKeyWatcher(t,i){var s;null==this._currentDataUnit&&this.loadAttachmentDataUnit(),i!==t&&(this._currentFetcher instanceof rt&&(this._currentFetcher.registerKey=t),await(null===(s=this._currentDataUnit)||void 0===s?void 0:s.loadData()))}getAnexoSistemaFetcherInstance(){var t;const i=new rt(this.entityName,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name);return i.registerKey=this.registerKey,i}async initAttach(){var t,i,s,e,n;if(this.fetcherType||this.registerKey){if(this.fetcherType||(this.fetcherType="AnexoSistema"),this.returnToGridMode(),"AnexoSistema"===this.fetcherType)return this._currentFetcher=this.getAnexoSistemaFetcherInstance(),null===(t=this._currentDataUnitBuilder)||void 0===t||t.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this)),void await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData());if("Attach"===this.fetcherType&&(null===(s=this.registerKey)||void 0===s?void 0:s.split("_").length)>1)return;await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadMetadata()),await(null===(n=this._currentDataUnit)||void 0===n?void 0:n.loadData(void 0,void 0,!0,this.registerKey))}}getMessage(t,i){if(this.messagesBuilder)return this.messagesBuilder.getMessage(t,i)}showFinishedToast(){this._application.info(this.getMessage("snkAttach.finishedMessage"),{iconName:"check"})}downloadAttachment(t){if(!t)throw new Error(this.getMessage("snkAttach.alertValidation.noRecordSelected.message"));t.LINK?window.open(`${t.LINK}`):this._currentFetcher.getDownloadKey(t).then((({chave:i})=>{var s;let e=!1;(null===(s=null==t?void 0:t.ARQUIVO)||void 0===s?void 0:s.endsWith(".pdf"))||(e=!0),window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${i.valor}${e?"&forcarDownload=S":""}`)}))}returnToGridMode(){var t;null===(t=this._currentDataUnit)||void 0===t||t.clearSelection(),this._crudElement&&this._crudElement.goToView(A.GRID)}async loadAttachmentDataUnit(){try{switch(this.fetcherType){case"AnexoSistema":await this.loadAnexoSistema();break;case"Attach":await this.loadAttach();break;default:this._currentFetcher=this.fetcher,this._currentDataUnit=this.dataUnit,this._currentDataUnitBuilder=this.dataUnitBuilder}}catch(t){throw new Error("There was an error while creating the data unit")}}async loadAnexoSistema(){var t,i;let s;this._currentDataUnit=(new y).getDataUnit("AnexoSistema","br.com.sankhya.core.v3.anexoSistema"),this._currentFetcher=this.getAnexoSistemaFetcherInstance(),this._currentDataUnit.metadata||(await(null===(t=this._currentDataUnit)||void 0===t?void 0:t.loadMetadata()),this.crudConfig=this.entityName?{form:null==bt?void 0:bt.form}:Object.assign({},bt),s={grid:null==bt?void 0:bt.grid}),this.initDataUnitLoaders(),this._currentDataUnit.addFilterProvider({getFilter:()=>this._currentDataUnitBuilder.getFilters(this.registerKey)}),this._currentDataUnit.addInterceptor({interceptAction:t=>this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}),await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData()),this.disableEditFieldsNotInForm(s)}async loadAttach(){var t,i;let s;this._currentFetcher=new et,this._currentDataUnit=new u(w.IN_MEMORY_DATA_UNIT_NAME),this._currentDataUnit.pageSize=150,this.initDataUnitLoaders(),this._currentDataUnit.addInterceptor({interceptAction:t=>{var i;return t.type===l.METADATA_LOADED&&(this.crudConfig=this.entityName?{form:null==ct?void 0:ct.form}:Object.assign({},ct),s={grid:null==ct?void 0:ct.grid},null===(i=this._crudElement)||void 0===i||i.updateConfig()),this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}}),this._currentDataUnit.metadata||(await(null===(t=this._currentDataUnit)||void 0===t?void 0:t.loadMetadata()),this.crudConfig=this.entityName?{form:null==ct?void 0:ct.form}:Object.assign({},ct),s={grid:null==ct?void 0:ct.grid},await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData(void 0,void 0,!0,this.registerKey)),this.disableEditFieldsNotInForm(s))}initDataUnitLoaders(){var t,i;"AnexoSistema"===this.fetcherType&&(this._currentFetcher=this.getAnexoSistemaFetcherInstance(),this._currentDataUnitBuilder=new lt(this.entityName,this.getMessage.bind(this)),null===(t=this._currentDataUnitBuilder)||void 0===t||t.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this))),"Attach"===this.fetcherType&&(this._currentFetcher=new et,this._currentDataUnitBuilder=new vt(this.getMessage.bind(this)),null===(i=this._currentDataUnitBuilder)||void 0===i||i.initLoaders(this._currentDataUnit,this._currentFetcher,(async()=>{this.returnToGridMode(),await this._currentDataUnit.loadData(void 0,void 0,!0,this.registerKey)})))}disableEditFieldsNotInForm(t){var i,s,e,n,a;const o=(null===(s=null===(i=this._crudElement)||void 0===i?void 0:i.gridConfig)||void 0===s?void 0:s.columns)||(null===(e=null==t?void 0:t.grid)||void 0===e?void 0:e.columns)||(null===(a=null===(n=this.crudConfig)||void 0===n?void 0:n.grid)||void 0===a?void 0:a.columns);this.getGridLegacyConfigName()&&this._currentDataUnit.disableField("ARQUIVOOULINK"),null==o||o.forEach((t=>{var i,s;const e=t.name;(null===(s=null===(i=this.crudConfig)||void 0===i?void 0:i.form)||void 0===s?void 0:s.fields.some((t=>(null==t?void 0:t.name)===e)))||this._currentDataUnit.disableField(e)}))}validateAnexoSistema(){var t;if(this._currentFetcher instanceof rt)try{let i=this._currentDataUnit.getSelectedRecord();i=Object.assign(Object.assign({},i),{NOMEARQUIVO:null===(t=i.NOMEARQUIVO)||void 0===t?void 0:t[0]}),this._currentFetcher.validateFields(i)}catch(t){if(t.message===b.LINK_AND_FILE_AT_THE_SAME_TIME)return this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),!1;if(t.message===b.ANY_LINK_OR_FILE_FILLED)return this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),!1}return!0}async componentWillLoad(){this._application=o.getContextValue("__SNK__APPLICATION__"),this._application&&(this._appResourceID=await this._application.getResourceID()),await this.initAttach()}async handleOnDataStateChange({detail:t}){"Attach"===this.fetcherType&&(t.insertionMode?this._currentDataUnit.enableField("DESCRICAO"):this._currentDataUnit.disableField("DESCRICAO"),await this._currentDataUnit.loadMetadata())}isScreenVariation(){var t;return!!(null===(t=this._appResourceID)||void 0===t?void 0:t.includes("__"))}getGridLegacyConfigName(){if(!this.isScreenVariation())return this.gridLegacyConfigName?this.gridLegacyConfigName:this.entityName?"GrdCfgHtml5:grdcfg.dynaform.anexo."+this.entityName:this.entityName}render(){var t,i;return s("ez-popup",{ref:t=>this._refPopup=t,size:"x-large",ezTitle:this.getMessage("snkAttach.title"),useHeader:!1,autoClose:!1,onEzClosePopup:()=>this.close()},this._isOpen&&this._currentDataUnit&&s("main",{class:"snk-attach__main"},s("header",{class:"snk-attach__header"},s("section",null,s("ez-button",{class:"ez-padding-right--medium",title:this.getMessage("snkSimpleBar.backTitle"),mode:"icon",iconName:"arrow_back",size:"medium",onClick:()=>this.handleBack()}),s("div",{class:"snk-attach__file-info"},s("span",{class:"ez-title--primary ez-text ez-text--large ez-text--bold"},this.getMessage("snkAttach.title")),s("span",{class:"ez-text ez-text--medium ez-text--secondary"},this.getMessage("snkAttach.description")))),s("ez-button",{class:"ez-button--primary",label:this.getMessage("snkAttach.finish"),onClick:this.handleFinish})),s("div",{class:"snk-attach__crud-section"},s("snk-simple-crud",{ref:t=>this._crudElement=t,dataUnit:this._currentDataUnit,taskbarManager:gt(),gridConfig:null===(t=this.crudConfig)||void 0===t?void 0:t.grid,formConfig:null===(i=this.crudConfig)||void 0===i?void 0:i.form,useCancelConfirm:!1,onActionClick:this.handleTaskbarClick,messagesBuilder:this.messagesBuilder,onDataStateChange:this.handleOnDataStateChange.bind(this),multipleSelection:!0,configName:this.isScreenVariation()?void 0:this.entityName?"AnexoSistema_"+this.entityName:void 0,ignoreReadOnlyFormFields:!!this.entityName,gridLegacyConfigName:this.getGridLegacyConfigName(),outlineMode:!0}))))}static get watchers(){return{registerKey:["registerKeyWatcher"]}}};kt.style=".snk-attach__header.sc-snk-attach{display:flex;justify-content:space-between;align-items:center;margin-bottom:var(--space--6, 6px)}.snk-attach__header.sc-snk-attach>section.sc-snk-attach{display:flex;align-items:center}.snk-attach__file-info.sc-snk-attach{display:flex;flex-direction:column;justify-content:center;gap:var(--space--8, 8px)}.snk-attach__main.sc-snk-attach{display:flex;flex-direction:column;height:100%}.ez-box__container.sc-snk-attach{height:100%}.snk-attach__crud-section.sc-snk-attach{padding:1px;display:flex;flex-direction:column;height:100%;width:100%}";const _t=class{constructor(s){t(this,s),this.actionSelected=i(this,"actionSelected",7),this.OFFSET_HEIGHT=5,this.getMessage=void 0,this.hasDefaultFilter=!1,this._opened=!1}repositionDropDown(){if(!this._refIcon||!this._refDropdown)return;const t=this._refIcon.getBoundingClientRect(),i=this._refDropdown.getBoundingClientRect();this._refDropdown.style.top=t.y+t.height+this.OFFSET_HEIGHT+"px",this._refDropdown.style.left=t.x+t.width/2-i.width+"px"}toggleDropdown(){this._opened=!this._opened}closeDropdown(t){const i=null==t?void 0:t.target;i&&(i.closest("#dropdown-parent-demo")||(this._opened=!1))}buildItems(){return[{id:F.EDIT,label:this.getMessage("defaultFilter.edit")},{id:F.REMOVE,label:this.getMessage("defaultFilter.remove")}]}onValueSelected({detail:t}){this._opened=!1,this.actionSelected.emit(t.id)}openCreateNewFilter(){this.actionSelected.emit(F.CREATE)}componentDidRender(){this.repositionDropDown()}componentWillLoad(){this._items=this.buildItems(),document.removeEventListener("scroll",this.repositionDropDown.bind(this)),document.addEventListener("scroll",this.repositionDropDown.bind(this))}render(){return this.hasDefaultFilter?s(e,null,s("button",{class:"default_container",onClick:this.toggleDropdown.bind(this)},s("span",null,this.getMessage("defaultFilter.title")),s("ez-icon",{ref:t=>this._refIcon=t,iconName:"dots-vertical"})),this._opened&&s("ez-dropdown",{ref:t=>this._refDropdown=t,items:this._items,onEzClick:this.onValueSelected.bind(this),onEzOutsideClick:this.closeDropdown.bind(this)})):s(e,null,s("button",{class:"default_container new_filter",onClick:this.openCreateNewFilter.bind(this)},s("span",null,this.getMessage("defaultFilter.create"))))}};_t.style=".sc-snk-default-filter-h{display:flex;justify-content:flex-end}.default_container.sc-snk-default-filter{border:none;background:none;display:flex;align-items:center;gap:var(--space--3xs, 4px);font-family:var(--font-pattern);color:var(--title--primary, #2b3a54);font-size:var(--text--medium, 14px);padding:0;outline:none}.default_container.sc-snk-default-filter ez-icon.sc-snk-default-filter{cursor:pointer}.default_container.sc-snk-default-filter ez-icon.sc-snk-default-filter:hover{color:var(--color--primary-600)}.new_filter.sc-snk-default-filter{cursor:pointer;margin:0 var(--space--3xs, 4px)}.new_filter.sc-snk-default-filter:hover{color:var(--color--primary-600)}";const yt=class{constructor(e){t(this,e),this.snkContentCardChanged=i(this,"snkContentCardChanged",7),this.snkRequestClearFieldToFocus=i(this,"snkRequestClearFieldToFocus",7),this._customEditors=new Map,this._fieldProps=new Map,this.dataUnitObserver=async t=>{var i;if(t.type===l.RECORDS_COPIED){const s=this.buildSourceRecordPK(t);null===(i=this.getImageField())||void 0===i||i.forEach((async t=>{var i;null===(i=this.dataUnit)||void 0===i||i.setFieldValue(t.name,JSON.stringify(s))}))}},this.customUiBuilders=new Map([[h.IMAGE,t=>{var{name:i}=t,e=function(t,i){var s={};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&i.indexOf(e)<0&&(s[e]=t[e]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(e=Object.getOwnPropertySymbols(t);n<e.length;n++)i.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(t,e[n])&&(s[e[n]]=t[e[n]])}return s}(t,["name"]);return s("snk-image-input",Object.assign({dataUnit:this.dataUnit,maxSize:1/0,fieldName:i,entityName:this.entityPath},e))}]]),this._singleColumn=!1,this._currentFormLayout=void 0,this.fieldSearch=void 0,this.label=void 0,this.name=void 0,this.fields=void 0,this.formMetadata=void 0,this.dataUnit=void 0,this.recordsValidator=void 0,this.fieldToFocus=void 0,this.customEditors=void 0,this.fieldsProps=void 0,this.entityPath=void 0}async showUp(){var t,i;this._formView&&(null===(i=(t=this._formView).showUp)||void 0===i||i.call(t))}async addCustomEditor(t,i,s){var e,n;if(this._formView)return void(null===(n=(e=this._formView).addCustomEditor)||void 0===n||n.call(e,t,i,s));const a=new Map(this._customEditors);a.set(t,{customEditor:i,detailContext:null!=s?s:""}),this._customEditors=a}async setFieldProp(t,i,s){const e=this._fieldProps.get(t)||[];this._fieldProps.set(t,[...e,{propName:i,value:s}])}async showSearchField(){if(!this._headerContainer||!this._ezPopoverFieldColumn)return;const t=this._headerContainer.getBoundingClientRect();this.fieldSearch&&(await E(this.fieldSearch),this._ezPopoverFieldColumn.showUnder(this._headerContainer,{horizontalGap:t.width-P,verticalGap:-1*t.height}))}observePropsCustomEditor(t){for(const i in t)this.addCustomEditor(i,t[i])}async observeFieldsProps(t){for(const i in t){const s=t[i],e=Object.keys(s);for(const t of e)await this.setFieldProp(i,t,s[t])}}async observeDataUnit(t,i){t!==i&&t&&t.subscribe(this.dataUnitObserver)}bindFields(t){var i;null==this._dataBinder&&null!=this.dataUnit&&(this._dataBinder=new j(this.dataUnit)),this._dataBinder&&this.dataUnit&&this.formMetadata&&this._dataBinder.bind(t,null===(i=this.dataUnit)||void 0===i?void 0:i.dataUnitId,this.formMetadata,this.recordsValidator)}disconnectedCallback(){null!=this._dataBinder&&this._dataBinder.onDisconnectedCallback(),this.dataUnit&&this.dataUnit.unsubscribe(this.dataUnitObserver)}componentDidLoad(){this.customEditors&&this.observePropsCustomEditor(this.customEditors),this.fieldsProps&&this.observeFieldsProps(this.fieldsProps),this.initLayoutFormConfig()}async initLayoutFormConfig(){const t=o.getContextValue("__SNK__APPLICATION__"),i=await(null==t?void 0:t.getLayoutFormConfig());i&&(this.setSingleColumn(i),this.registerNotifyListeners(i))}setSingleColumn(t){this._singleColumn=(null==t?void 0:t.config)===N.CASCADE||(null==t?void 0:t.config)===N.CLASSIC_CASCADE,this._currentFormLayout=null==t?void 0:t.config}registerNotifyListeners(t){var i;t&&(null===(i=t.onConfigChange)||void 0===i||i.call(t,(t=>{this._singleColumn=t===N.CASCADE||t===N.CLASSIC_CASCADE,this._currentFormLayout=t})))}componentDidRender(){var t;this.setCustomEditors(),this.setFieldProps(),this.fieldToFocus&&(null===(t=this.fields)||void 0===t?void 0:t.some((t=>t.name===this.fieldToFocus)))&&requestAnimationFrame((()=>{var t,i;null===(t=this._dataBinder)||void 0===t||t.setFocus(this.fieldToFocus),null===(i=this.snkRequestClearFieldToFocus)||void 0===i||i.emit()}))}setCustomEditors(){var t,i;if(this._formView)for(const[s,e]of this._customEditors)null===(i=(t=this._formView).addCustomEditor)||void 0===i||i.call(t,s,e.customEditor,e.detailContext),this._customEditors.delete(s)}setFieldProps(){if(this._formView)for(const[t,i]of this._fieldProps)i.forEach((i=>{var s,e;null===(e=(s=this._formView).setFieldProp)||void 0===e||e.call(s,t,i.propName,i.value),this._fieldProps.delete(t)}))}buildSourceRecordPK(t){var i,s,e;const n=(null===(i=t.payload)||void 0===i?void 0:i[0])||{},a=JSON.parse(atob(n.__record__source__id__||""));if(delete a.__DATA_UNIT_NAME__,!this.dataUnit)return{};const o=null!==(s=R(this.dataUnit))&&void 0!==s?s:{},r=Object.keys(o),l={};for(const t of r)l[t]=null===(e=a[t])||void 0===e?void 0:e.value;return l}getImageField(){var t;return null===(t=this.dataUnit)||void 0===t?void 0:t.metadata.fields.filter((t=>t.userInterface===h.IMAGE))}render(){return s(e,null,s("slot",null),s("ez-form-view",{ref:t=>this._formView=t,fields:this.fields,onEzContentReady:t=>this.bindFields(t.detail),singleColumn:this._singleColumn,customUiBuilders:this.customUiBuilders,formLayout:this._currentFormLayout}),this.fieldSearch&&s("ez-popover",{ref:t=>this._ezPopoverFieldColumn=t,overlayType:"none"},this.fieldSearch))}static get watchers(){return{customEditors:["observePropsCustomEditor"],fieldsProps:["observeFieldsProps"],dataUnit:["observeDataUnit"]}}};yt.style=".sc-snk-dynaform-form-view-h{display:flex;flex-direction:column;width:100%;flex-wrap:wrap;background-color:var(--background--xlight);padding:var(--space--12, 12px);border-radius:var(--border--radius-medium);border:1px solid var(--color--petroleum-100, #C8CCD3);--ez-form-card-summary-field-content-weight:700}ez-form-view.sc-snk-dynaform-form-view{padding:var(--space--6 ,6px) 0;--ez-form-view__item--padding:0}.level-path.sc-snk-dynaform-form-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.summary-wrapper.sc-snk-dynaform-form-view{display:flex;overflow:hidden}.summary-header.sc-snk-dynaform-form-view{border-bottom:1px solid var(--color--strokes);margin-bottom:var(--space--medium);padding-bottom:var(--space--medium)}.summary-container.sc-snk-dynaform-form-view{display:flex;flex-direction:column}.summary-container.sc-snk-dynaform-form-view{padding-right:calc(var(--space--extra-large) / 1.5)}.summary-field.sc-snk-dynaform-form-view{min-width:30px;max-width:200px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.summary-field__title.sc-snk-dynaform-form-view{color:var(--text--primary, #626e82);font-size:var(--title--small);white-space:nowrap;font-weight:var(--text-weight--medium)}.summary-field__content.sc-snk-dynaform-form-view{color:var(--title--primary, #2b3a54);font-size:var(--text--large);font-weight:var(--ez-form-card-summary-field-content-weight)}";const wt=class{constructor(s){t(this,s),this.ezExpressionChange=i(this,"ezExpressionChange",7),this.filterAssistent=void 0,this.application=void 0}getMessage(t,i){return this.application.messagesBuilder.getMessage(t,i)}render(){var t;return s(e,null,s("span",{class:"ez-title ez-title--small ez-padding-bottom--small snk-filter-advanced-mode__title"},this.getMessage("snkPersonalizedFilter.info.applyExpression")),s("ez-text-area",{rows:9,label:this.getMessage("snkPersonalizedFilter.info.labelExpression"),value:null===(t=this.filterAssistent)||void 0===t?void 0:t.expression,onEzChange:t=>this.ezExpressionChange.emit(t.detail)}))}};wt.style=".sc-snk-filter-advanced-mode-h{display:block;--snk-personalized-filter--title--color:var(--title--primary, #2B3A54)}.snk-filter-advanced-mode__title.sc-snk-filter-advanced-mode{color:var(--snk-personalized-filter--title--color)}";const Ct=class{constructor(s){t(this,s),this.ezChangeFilter=i(this,"ezChangeFilter",7),this.filterAssistent=void 0,this.messagesBuilder=void 0,this.filterId=void 0,this.entityUri=void 0,this.application=void 0,this.isDefaultFilter=!1}getMessage(t,i){return this.application.messagesBuilder.getMessage(t,i)}async handleFilterGroupChange(){const t=await this._mainExpressionGroup.getExpressionGroup();this.filterAssistent=Object.assign(Object.assign({},this.filterAssistent),{assistent:t}),this.filterAssistent.parameters=K.buildVariableParameters(this.filterAssistent.assistent),this.filterAssistent.expression=K.buildGroupExpression(this.filterAssistent.assistent),this.ezChangeFilter.emit(this.filterAssistent)}render(){var t,i;return s(e,null,s("div",{class:"ez-padding-top--small snk-personalized-filter__group"},s("snk-expression-group",{ref:t=>this._mainExpressionGroup=t,group:null===(t=this.filterAssistent)||void 0===t?void 0:t.assistent,messagesBuilder:this.messagesBuilder,onEzFilterGroupChange:this.handleFilterGroupChange.bind(this),filterId:this.filterId,entityURI:this.entityUri,isDefaultFilter:this.isDefaultFilter})),s("div",{class:"ez-margin-top--auto"},s("div",{class:"snk-personalized-filter__expression-input--line"}),s("ez-collapsible-box",{label:this.getMessage("snkPersonalizedFilter.info.titleCollapsible"),headerSize:"medium",value:!0},s("div",{class:"ez-box"},s("div",{class:"ez-box__container--external"},s("div",{class:"ez-box__container--internal"},s("span",{class:"ez-box__container--title"},this.getMessage("snkPersonalizedFilter.info.labelExpression")),s("span",{class:"ez-box__container--expression"},null===(i=this.filterAssistent)||void 0===i?void 0:i.expression)))))))}};Ct.style=".sc-snk-filter-assistent-mode-h{display:flex;flex-direction:column;height:100%;--text-area--font-family:var(--font-pattern, Arial);--text-area__label--floating--top:var(--space--small, 6px);--snk-filter-assistent-mode__container--border-radius:var(--border--radius-medium, 12px);--snk-filter-assistent-mode__container--background:var(--background--medium, #f0f3f7);--snk-filter-assistent-mode__container--margin:var(--space--small, 6px) var(--space--medium, 12px)}.ez-box__container--external.sc-snk-filter-assistent-mode{height:100px;width:100%;overflow-y:auto;background-color:var(--snk-filter-assistent-mode__container--background);border-radius:var(--snk-filter-assistent-mode__container--border-radius)}.ez-box__container--internal.sc-snk-filter-assistent-mode{margin:var(--snk-filter-assistent-mode__container--margin)}.ez-box__container--title.sc-snk-filter-assistent-mode{display:block;user-select:none;font-family:var(--text-area--font-family);font-size:var(--text--extra-small);color:var(--title--primary);top:var(--text-area__label--floating--top)}.ez-box__container--expression.sc-snk-filter-assistent-mode{display:block;font-family:var(--text-area--font-family);font-size:var(--text--medium);color:var(--title--primary);top:var(--text-area__label--floating--top)}.snk-personalized-filter__expression-input--line.sc-snk-filter-assistent-mode{width:100%;height:2px;background-color:var(--snk-personalized-filter--background-color-line);margin-top:var(--snk-personalized-filter--margin-line);margin-bottom:var(--snk-personalized-filter--margin-line)}";const zt=class{constructor(s){t(this,s),this.filterChange=i(this,"filterChange",7),this.config=void 0,this.getMessage=void 0,this.showHardFixed=!0,this.removalBlocked=!1}async setFocusField(){var t,i,s,e;this._editor&&(this._editor.setFocus?null===(i=null===(t=this._editor)||void 0===t?void 0:t.setFocus)||void 0===i||i.call(t):this._editor.focus&&(null===(e=null===(s=this._editor)||void 0===s?void 0:s.focus)||void 0===e||e.call(s)))}async clearValue(){this._editor&&this._editor.clearValue&&await this._editor.clearValue()}observeConfig(t){var i,s;this._editor&&(this._editor.config=t),null===(s=null===(i=this._editor)||void 0===i?void 0:i.reloadList)||void 0===s||s.call(i),this._customElementObject=this.getContentEditor()}componentDidLoad(){if(this._element){v.addIDInfo(this._element);const t=this._element.getAttribute(v.DATA_ELEMENT_ID_ATTRIBUTE_NAME);this._idContentEditor=`${t}_${this.config.id}`}}changeConfig(t){this.filterChange.emit(t)}getContentEditor(){switch(this.config.type){case C.BINARY_SELECT:return{tag:"snk-filter-binary-select"};case C.MULTI_SELECT:return{tag:"snk-filter-multi-select"};case C.PERIOD:return{tag:"snk-filter-period"};case C.SEARCH:return{tag:"snk-filter-search"};case C.NUMBER:return{tag:"snk-filter-number"};case C.PERSONALIZED:return{tag:"snk-personalized-filter-editor",props:{presentationMode:q.CHIP,onValueChanged:t=>this.handleValueChanged(t)}};case C.CHECK_BOX_LIST:return{tag:"snk-filter-checkbox-list",props:{onValueChanged:t=>this.config=Object.assign(Object.assign({},this.config),{value:t.detail})}};case C.MULTI_LIST:return{tag:"snk-entity-list",props:{onValueChanged:t=>this.config=Object.assign(Object.assign({},this.config),{value:t.detail})}}}return{tag:"snk-filter-text"}}handleValueChanged({detail:t}){const i=(null==t?void 0:t.items)||this.config.groupedItems;this.config=Object.assign(Object.assign({},this.config),{groupedItems:i,visible:(i||[]).filter((t=>t.visible)).length>0})}removeItem(){const t=this.config.type===C.MULTI_LIST&&Array.isArray(this.config.value)?this.config.value.map((t=>Object.assign(Object.assign({},t),{check:!1}))):void 0,i=Object.assign(Object.assign({},this.config),{visible:!1,fixed:!1,value:t});null!=i.groupedItems&&(i.groupedItems=i.groupedItems.map((t=>Object.assign(Object.assign({},t),{visible:!1,fixed:!1,value:void 0})))),this.changeConfig(i)}removeItemFromGroup(t){return Object.assign(Object.assign({},t),{visible:!1,fixed:!1,value:void 0})}getPopUpHeaderButtons(){return s(n,null,!this.removalBlocked&&!this.config.removalBlocked&&this.buildIcon(this.getMessage("snkFilterBar.removeFilter"),"delete",(()=>this.removeItem())),this.showHardFixed&&!this.config.hardFixed&&this.buildIcon(this.getMessage(this.config.fixed?"snkFilterBar.unpinFilter":"snkFilterBar.pinFilter"),this.config.fixed?"un-pin":"push-pin",(()=>this.changeConfig(Object.assign(Object.assign({},this.config),{fixed:!this.config.fixed})))))}buildIcon(t,i,e){return s("button",{onClick:()=>e(),class:"sc-snk-filter-bar snk-filter-item__editor-header-button",ref:i=>i&&this.buildIdButton(i,t)},s("ez-icon",Object.assign({title:t,iconName:i},{[v.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${v.getInternalIDInfo(`_${t}`)}`})))}buildIdButton(t,i){if(!t)return;const s={id:i};t.removeAttribute(v.DATA_ELEMENT_ID_ATTRIBUTE_NAME),v.addIDInfoIfNotExists(t,"button",s)}clearBinarySelectValues(){var t;const i=this._editor||{};null===(t=i.resetValues)||void 0===t||t.call(i),this.config=m.copy(this.originalConfig),this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}apply(){if(!K.validateVariableValues(this.config,this._editor.value))return T.alert(this.getMessage("snkFilterBar.filterModal.validations.notFullFilled.title"),this.getMessage("snkFilterBar.filterModal.validations.notFullFilled.message"));const t=void 0!==this._editor.value?this._editor.value:this.config.value;this.changeConfig(Object.assign(Object.assign({},this.config),{visible:this.isVisible(),value:t}))}isVisible(){return!(this.config.groupedItems&&this.config.groupedItems.length>0)||this.config.groupedItems.filter((t=>t.visible)).length>0}clear(){var t;if(this.config.type!==C.BINARY_SELECT){if(C.MULTI_LIST===this.config.type){const i=m.copy(this.config);return null===(t=i.value)||void 0===t||t.forEach((t=>!!t&&(t.check=!1))),void(this.config=m.copy(i))}this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}else this.clearBinarySelectValues()}filterCanBeCleared(){return this.config.type!==C.PERSONALIZED}onKeyDonwListener(t){"Enter"===t.key&&this.apply()}buildRightSlot(t){return s("ez-icon",{iconName:"delete",onClick:()=>this.removeValueFromConfig(t)})}removeValueFromConfig(t){var i,s;if(this.config){const e=m.copy(this.config),n=null===(i=e.value)||void 0===i?void 0:i.findIndex((i=>(null==i?void 0:i.id)===t.id));null===(s=e.value)||void 0===s||s.splice(n,1),this.config=m.copy(e)}}componentWillLoad(){this.originalConfig=m.copy(this.config),this._customElementObject=this.getContentEditor()}render(){const{tag:t,props:i}=this._customElementObject;return s(e,null,s("div",{class:"col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center"},s("div",{class:"ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header"},this.config.detailTitle),this.getPopUpHeaderButtons()),s(t,Object.assign({maxHeightList:"240px",ref:t=>this._editor=t,value:this.config.value,config:this.config,onKeyDown:t=>this.onKeyDonwListener(t),"data-element-id":this._idContentEditor,getMessage:this.getMessage,rightListSlotBuilder:t=>this.buildRightSlot(t)},i)),s("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),s("div",{class:"ez-col ez-col--sd-12 ez-align--right"},this.filterCanBeCleared()&&s("ez-button",{label:this.getMessage("snkFilterBar.cleanFilter"),onClick:()=>this.clear(),size:"small"}),s("ez-button",{ref:t=>this._applyButton=t,label:this.getMessage("snkFilterBar.applyFilter"),onClick:()=>this.apply(),size:"small",class:"ez-button--primary ez-padding-left--medium"})))}get _element(){return a(this)}static get watchers(){return{config:["observeConfig"]}}},At=class{constructor(s){t(this,s),this.filterChange=i(this,"filterChange",7),this.editPersonalizedFilter=i(this,"editPersonalizedFilter",7),this.addPersonalizedFilter=i(this,"addPersonalizedFilter",7),this.filterItem=void 0,this.configName=void 0,this.resourceID=void 0}getContentEditorConfig(){const t={presentationMode:q.MODAL};switch(this.filterItem.type){case C.BINARY_SELECT:return{tag:"snk-filter-binary-select",props:t};case C.MULTI_SELECT:return{tag:"snk-filter-multi-select"};case C.PERIOD:return{tag:"snk-filter-period",props:t};case C.SEARCH:return{tag:"snk-filter-search"};case C.NUMBER:return{tag:"snk-filter-number",props:t};case C.PERSONALIZED:return this.buildSnkFilterPersonalizedProps();case C.CHECK_BOX_LIST:return{tag:"snk-filter-checkbox-list",props:t};case C.MULTI_LIST:return{tag:"snk-entity-list",props:{maxHeightList:"640px",rightListSlotBuilder:t=>this.buildRightSlot(t)}}}return{tag:"snk-filter-text"}}buildSnkFilterPersonalizedProps(){return{tag:"snk-personalized-filter-editor",props:{onEditFilter:t=>this.editPersonalizedFilter.emit(t.detail),onAddFilter:()=>this.addPersonalizedFilter.emit()}}}isVisible(t){return!!this.filterItem.visible||void 0!==t}updateFilterValue(t){var i,s;const e=void 0!==(null==t?void 0:t.value)?t.value:t;this.filterItem=Object.assign(Object.assign({},this.filterItem),null!=this.filterItem.groupedItems?{visible:e>0,value:e,groupedItems:t.items}:{value:this.filterItem.type===(C.SEARCH||C.CHECK_BOX_LIST)?t:e,visible:this.isVisible(e)}),this._editor&&(this._editor.config=this.filterItem),null===(s=null===(i=this._editor)||void 0===i?void 0:i.reloadList)||void 0===s||s.call(i),this.filterChange.emit(this.filterItem)}handleDeleteFilter(t,i){i===C.PERSONALIZED&&H.removePersonalizedFilter(t,this.resourceID,this.configName)}componentDidLoad(){if(this._element){v.addIDInfo(this._element);const t=this._element.getAttribute(v.DATA_ELEMENT_ID_ATTRIBUTE_NAME);this._idContentEditor=`${t}_${this.filterItem.id}`}}buildRightSlot(t){return s("ez-icon",{iconName:"delete",onClick:()=>this.removeValueFromConfig(t)})}removeValueFromConfig(t){var i,s,e;const n=null===(s=null===(i=this.filterItem)||void 0===i?void 0:i.value)||void 0===s?void 0:s.findIndex((({id:i})=>i===t.id)),a=m.copy(this.filterItem);null===(e=null==a?void 0:a.value)||void 0===e||e.splice(n,1),this.updateFilterValue(a.value)}canShowDetailModal(){const{CUSTOM_FILTER:t,OTHER_FILTERS:i}=I;return![t,i].includes(this.filterItem.filterType)&&this.filterItem.type!==C.BINARY_SELECT}render(){const{tag:t,props:i}=this.getContentEditorConfig();return s(e,null,s("div",{class:"ez-flex ez-flex--column grow"},this.canShowDetailModal()&&s("label",{class:"ez-text ez-text--medium ez-text--primary ez-margin-bottom--extra-small",htmlFor:`filter-item-${this.filterItem.id}`},this.filterItem.detailModal),s(t,Object.assign({ref:t=>this._editor=t,id:`filter-item-${this.filterItem.id}`,config:this.filterItem,value:this.filterItem.value,onValueChanged:t=>this.updateFilterValue(t.detail),"data-element-id":this._idContentEditor},i))))}get _element(){return a(this)}};At.style=".grow{flex-grow:1}.gap{gap:4px}";const xt=class{constructor(s){t(this,s),this.imageError=i(this,"imageError",7),this.dataUnitObserver=async t=>{var i;if([l.NEXT_SELECTED,l.PREVIOUS_SELECTED].includes(t.type))return void await this.loadImage();const s=(null===(i=t.payload)||void 0===i?void 0:i.selection)||[];t.type===l.SELECTION_CHANGED&&s.length>0?await this.loadImage():t.type!==l.RECORDS_ADDED?t.type!==l.EDITION_CANCELED||await this.loadImage():await this.clearImage()},this.dataUnit=void 0,this.fieldName=void 0,this.entityName=void 0,this.enabled=!0,this.acceptType=void 0,this.maxSize=void 0,this.label=void 0,this.imageValue=void 0,this.loading=!0}async reloadImage(t){await this.loadImage(t)}getMessage(t,i){return this.messagesBuilder||(this.messagesBuilder=new g),this.messagesBuilder.getMessage(t,i)}async clearImage(){var t;null===(t=this._loadAbortController)||void 0===t||t.abort(),this.imageValue=void 0}async handleImageChange(t){const i=t.detail;if(!i)return await this.clearImage(),void await this.updatedataUnitField(!0);const s=await M(i);if(this.maxSize&&s.size>1024*this.maxSize){const t=this.getMessage("snkImageInput.errorImageSize")+this.maxSize+"(KB)";return this.imageError.emit(t),void(this.application&&await this.application.error(this.getMessage("snkImageInput.errorTitle"),t))}this.imageValue=i,await U(s,this.entityName,this.fieldName),await this.updatedataUnitField()}async updatedataUnitField(t=!1){this.dataUnit&&this.dataUnit.getSelectedRecord()&&(t?await this.dataUnit.setFieldValue(this.fieldName,"deletado"):await this.dataUnit.setFieldValue(this.fieldName,`$file.session.key{${V(this.entityName,this.fieldName)}}`))}async handleImageError(t){this.imageError.emit(t.detail),this.application&&await this.application.error(this.getMessage("snkImageInput.errorTitle"),t.detail)}getPksFromDataUnit(){if(!this.dataUnit)return;const t=this.dataUnit.getSelectedRecord();if(!t)return;const i=t[this.fieldName];if(i)try{return JSON.parse(i)}catch(t){return void console.error("Error parsing PK from data unit field:",t)}}async loadImage(t){var i,s;null===(i=this._loadAbortController)||void 0===i||i.abort();const e=new AbortController;if(this._loadAbortController=e,this.loading=!0,this.dataUnit&&this.entityName){t=null!==(s=null!=t?t:this.getPksFromDataUnit())&&void 0!==s?s:R(this.dataUnit);const i=await B(t,this.fieldName,this.entityName,e.signal);if(e.signal.aborted)return;this.imageValue=i}this.loading=!1}async componentWillLoad(){this.application=o.getContextValue("__SNK__APPLICATION__"),this.messagesBuilder||(this.messagesBuilder=new g),this.dataUnit&&this.dataUnit.subscribe(this.dataUnitObserver)}disconnectedCallback(){this.dataUnit&&this.dataUnit.unsubscribe(this.dataUnitObserver)}async componentDidLoad(){await this.loadImage()}render(){return s(e,null,s("ez-image-input",{enabled:this.enabled,label:this.label,name:this.fieldName,value:this.imageValue,maxFileSize:this.maxSize?1024*this.maxSize:void 0,accept:this.acceptType||"image/png,image/jpeg,image/gif",onEzChange:t=>this.handleImageChange(t),onEzError:t=>this.handleImageError(t),loading:this.loading}))}};xt.style=":host{display:block}";const St=class{constructor(s){t(this,s),this.ezCancel=i(this,"ezCancel",7),this.ezSave=i(this,"ezSave",7),this.ezAfterSave=i(this,"ezAfterSave",7),this._personalizedFilterFetcher=new Q,this._filterMetadataStorage=new Map,this._dataSourceFetcher={fetchData:async t=>{let i=null==t?void 0:t.uri;if(d.isEmpty(i)&&(i=this.entityUri),!this._filterMetadataStorage.has(i)){const t=await this._personalizedFilterFetcher.loadFields(i);this._filterMetadataStorage.set(i,t)}return this._filterMetadataStorage.get(i)}},this._filterAssistentMode=!0,this._filterAssistent=void 0,this.messagesBuilder=void 0,this.entityUri=void 0,this.filterId=void 0,this.configName=void 0,this.resourceID=void 0,this.isDefaultFilter=!1}async createPersonalizedFilter(){const t={name:"",active:!0,expression:"",parameters:[],assistent:{id:d.generateUUID(),items:[{id:d.generateUUID(),entityName:"",fieldName:"",description:"",fieldLabel:this.getMessage("snkPersonalizedFilter.info.labelDefaultValue"),type:void 0,expression:void 0,operand:void 0,paramVariable:!1,value:void 0,systemConfig:null,userConfig:null}],childrenGroups:[],operand:G.AND}};this.isDefaultFilter&&this.buildDataDefaultFilter(t),this._originalFilterAssistent=m.copy(t),this._filterAssistent=m.copy(t)}loadFilter(t,i){null!=t&&i!=t&&null!=this.resourceID&&(t!==$.id?H.loadPersonalizedFilter(t,this.resourceID,this.configName).then((t=>{const i=this.applyDefaultValues(t);this._filterAssistent=i,this._originalFilterAssistent=m.copy(i),this._filterAssistentMode=this._filterAssistent.hasOwnProperty("assistent")&&null!=this._filterAssistent.assistent})):H.loadDefaultFilter(t,this.resourceID,this.configName).then((t=>{const i=this.applyDefaultValues(t);this._filterAssistent=i,this._originalFilterAssistent=m.copy(i),this._filterAssistentMode=this._filterAssistent.hasOwnProperty("assistent")&&null!=this._filterAssistent.assistent})))}componentWillLoad(){var t;null==J.get(`filterFieldsDataSource.${this.entityUri}`)&&J.set(`filterFieldsDataSource.${this.entityUri}`,this._dataSourceFetcher),this.messagesBuilder||(this._application=o.getContextValue("__SNK__APPLICATION__"),this.messagesBuilder=null===(t=this._application)||void 0===t?void 0:t.messagesBuilder),this.loadFilter(this.filterId,void 0)}componentDidRender(){var t;null===(t=this._viewStackRef)||void 0===t||t.show(this._filterAssistentMode?0:1),this._elButtonMode&&this._elButtonMode.setAttribute(v.DATA_ELEMENT_ID_ATTRIBUTE_NAME,v.getInternalIDInfo(this._filterAssistentMode?"advancedMode_ezButton":"assistentMode_ezButton"))}buildDataDefaultFilter(t){t.name=$.name,t.id=$.id}getMessage(t,i){return this._application.messagesBuilder.getMessage(t,i)}async saveFilter(){let t;t=this.isDefaultFilter?await H.saveDefaultFilter(this._filterAssistent,this.resourceID,this.configName):await H.savePersonalizedFilter(this._filterAssistent,this.resourceID,this.configName),this._elButtonSave.enabled=!1,T.info(this.getMessage(`snkPersonalizedFilter.${this._filterAssistent.id?"confirmEdit":"confirmSave"}.title`),{iconName:"check"});const i=Object.assign(Object.assign({},t),this._filterAssistent);i.parameters=K.buildVariableParameters(this._filterAssistent.assistent),this._originalFilterAssistent=m.copy(i),this._filterAssistent=m.copy(i),this.ezAfterSave.emit()}removeFilter(){H.removePersonalizedFilter(this._filterAssistent,this.resourceID,this.configName)}hasChangesToSave(){return JSON.stringify(this._filterAssistent)===JSON.stringify(this._originalFilterAssistent)}async handleSave(){if(this._filterAssistentMode){if(!K.validateFields(this._filterAssistent.assistent)||!this._filterAssistent.name)return this._application.error(this.getMessage("snkPersonalizedFilter.error.title"),this.getMessage("snkPersonalizedFilter.error.description"));this.saveAssistentMode()}else{if(!this._filterAssistent.expression||!this._filterAssistent.name)return this._application.error(this.getMessage("snkPersonalizedFilter.error.title"),this.getMessage("snkPersonalizedFilter.error.description"));if(!await this.validateExpressionBeforeSaving())return;this.saveAdvancedMode()}}saveAssistentMode(){const{assistent:t,expression:i}=this._filterAssistent,s=t?K.buildGroupExpression(t):i;this._filterAssistent.expression=s,this.ezSave.emit(s),this.saveFilter()}saveAdvancedMode(){this._originalFilterAssistent.expression!==this._filterAssistent.expression&&this._filterAssistent.assistent?T.confirm(this.getMessage("snkPersonalizedFilter.confirmSaveModeAdvanced.title"),this.getMessage("snkPersonalizedFilter.confirmSaveModeAdvanced.description")).then((t=>{t&&this.saveAndTransformToAdvancedMode()})):this._filterAssistent.assistent?this.saveAssistentMode():this.saveAndTransformToAdvancedMode()}saveAndTransformToAdvancedMode(){this._filterAssistent.assistent=void 0,this.ezSave.emit(this._filterAssistent.expression),this.saveFilter()}async validateExpressionBeforeSaving(){const{valid:t,message:i=""}=await this._personalizedFilterFetcher.validatePersonalizedFilter(this.entityUri,this._filterAssistent.expression);return t||this._application.error(this.getMessage("snkPersonalizedFilter.errorValidation.title"),i.replace(/.*Exception: /,"")),t}handleCancel(){if(this.hasChangesToSave())return this.ezCancel.emit();T.confirm(this.getMessage("snkPersonalizedFilter.confirmCancel.title"),this.getMessage("snkPersonalizedFilter.confirmCancel.description")).then((t=>{var i;t&&(this._filterAssistent=m.copy(null!==(i=this._originalFilterAssistent)&&void 0!==i?i:{}),this.ezCancel.emit(),this._elButtonSave.enabled=!1)}))}handleTitleChange(t){this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{name:t}),this._elButtonSave.enabled=!this.hasChangesToSave()}applyDefaultValues(t){return this.addLabelToItems(t),this.addFilterGroupCondition(t),t}addFilterGroupCondition(t){t.assistent&&!t.assistent.operand&&(t.assistent.operand=G.AND)}addLabelToItems(t){t.assistent&&t.assistent.items&&t.assistent.items.length>0&&t.assistent.items.forEach((i=>{if(null==i.fieldLabel){const s=(t.parameters||[]).find((t=>t.fieldName===i.fieldName));s&&(i.fieldLabel=s.label)}}))}handleExpressionChangeAdvancedMode(t){this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{expression:t}),this._elButtonSave.enabled=!this.hasChangesToSave()}handleChangeFilterAssistentMode(t){this._elButtonSave.enabled=!this.hasChangesToSave(),this._filterAssistent=Object.assign({},t)}selectField(t){if(!("name"in t))return;const i=this.buildExpression(t.entityName,t.name,t.entityPath);this._elAdvancedMode.querySelector("ez-text-area").appendTextToSelection(i)}buildExpression(t,i,s){return s.length>0&&s.shift(),s.length>0?`${s.join("->")}->${i}`:`${t}.${i}`}onAddField(t){this._elAdvancedMode.querySelector("ez-text-area").setFocus(),t.setBlur(),this._elFilterFieldSearch&&this._elFilterFieldSearch.show(t,{horizontalGap:0,verticalGap:12,fromRight:!0})}renderButtonAddField(){if(!this._filterAssistentMode)return s(n,null,s("ez-button",{class:"snk-personalized-filter__button-mode",label:this.getMessage("snkPersonalizedFilter.info.addField"),enabled:!0,onClick:t=>this.onAddField(t.target)},s("ez-icon",{class:"ez-padding-right--small",slot:"leftIcon",iconName:"plus"})),s("snk-filter-field-search",{class:"ez-padding-left--medium",ref:t=>this._elFilterFieldSearch=t,onEzSelectFilterItem:t=>this.selectField(t.detail),fieldsDataSource:this._dataSourceFetcher}))}buildContainerPersonalizedFilter(){return s("ez-view-stack",{ref:t=>this._viewStackRef=t},s("stack-item",null,this._filterAssistentMode&&s("snk-filter-assistent-mode",{filterAssistent:this._filterAssistent,messagesBuilder:this.messagesBuilder,filterId:this.filterId,entityUri:this.entityUri,application:this._application,onEzChangeFilter:t=>this.handleChangeFilterAssistentMode(t.detail),isDefaultFilter:this.isDefaultFilter})),s("stack-item",null,s("snk-filter-advanced-mode",{ref:t=>this._elAdvancedMode=t,filterAssistent:this._filterAssistent,application:this._application,onEzExpressionChange:t=>this.handleExpressionChangeAdvancedMode(t.detail)})))}handleModeChange(){var t,i;if(this._filterAssistentMode)T.confirm(this.getMessage("snkPersonalizedFilter.confirmChangeModeAssistent.title"),this.getMessage("snkPersonalizedFilter.confirmChangeModeAssistent.description")).then((t=>{if(t&&(this._filterAssistentMode=!this._filterAssistentMode,!this.hasChangesToSave())){const t=K.buildGroupExpression(this._filterAssistent.assistent);this._filterAssistent.expression=t,this._elButtonSave.enabled=!this.hasChangesToSave()}}));else if((null===(t=this._filterAssistent)||void 0===t?void 0:t.expression)===(null===(i=this._originalFilterAssistent)||void 0===i?void 0:i.expression))this._filterAssistentMode=!this._filterAssistentMode;else{const t=this._filterAssistent.expression,i=K.buildGroupExpression(this._filterAssistent.assistent);t!==i?T.confirm(this.getMessage("snkPersonalizedFilter.confirmChangeModeAdvanced.title"),this.getMessage("snkPersonalizedFilter.confirmChangeModeAdvanced.description")).then((t=>{t&&(this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{expression:i}),this._filterAssistentMode=!this._filterAssistentMode)})):this._filterAssistentMode=!this._filterAssistentMode}}buildTitle(){return this.getMessage(this.isDefaultFilter&&!this.filterId?"snkPersonalizedFilter.info.titleCreateDefault":this.isDefaultFilter&&this.filterId?"snkPersonalizedFilter.info.titleEditDefault":this.filterId?"snkPersonalizedFilter.info.titleEdit":"snkPersonalizedFilter.info.titleAdd")}render(){var t,i,n,a;if((null===(t=this._filterAssistent)||void 0===t?void 0:t.assistent)||!this._filterAssistentMode)return s(e,null,s("div",{class:"snk-personalized-filter"},s("div",null,s("snk-simple-bar",{label:this.buildTitle(),onExit:()=>this.handleCancel()},s("div",{class:"snk-personalized-filter__header-actions",slot:"rightSlot"},s("ez-button",{label:this.getMessage("snkPersonalizedFilter.info.labelCancel"),onClick:()=>this.handleCancel()}),s("ez-button",{ref:t=>this._elButtonSave=t,enabled:!1,class:"ez-button--primary",label:this.getMessage("snkPersonalizedFilter.info.labelSave"),onClick:this.handleSave.bind(this)})))),s("div",{class:"ez-box ez-margin-bottom--medium ez-box__main"},s("div",{class:"ez-box__container"},s("div",{class:"ez-flex ez-flex--column ez-size-width--full"},s("div",{class:"ez-flex"},s("ez-tooltip",{message:this.getMessage("snkPersonalizedFilter.info.textInputDisabled"),active:this.isDefaultFilter},s("ez-text-input",{class:"ez-padding-right--medium",label:this.getMessage("snkPersonalizedFilter.info.labelNameFilter"),value:null===(i=this._filterAssistent)||void 0===i?void 0:i.name,onEzChange:t=>this.handleTitleChange(t.detail),enabled:!this.isDefaultFilter})),this.renderButtonAddField(),s("ez-button",{ref:t=>this._elButtonMode=t,class:"snk-personalized-filter__button-mode",label:this.getMessage(this._filterAssistentMode?"snkPersonalizedFilter.info.activeModeAdvanced":"snkPersonalizedFilter.info.activeModeAssistent"),onClick:()=>this.handleModeChange(),"data-tooltip":this._filterAssistentMode||(null===(n=this._filterAssistent)||void 0===n?void 0:n.assistent)?void 0:this.getMessage("snkPersonalizedFilter.info.tooltipDisabledAssistentMode"),"data-flow":"bottom",enabled:!this._filterAssistent.name||Boolean(this._filterAssistentMode||(null===(a=this._filterAssistent)||void 0===a?void 0:a.assistent))})),this.buildContainerPersonalizedFilter())))))}static get watchers(){return{filterId:["loadFilter"]}}};St.style=".sc-snk-personalized-filter-h{display:flex;height:100%;padding:var(--space--large, 24px);--snk-personalized-filter--width:100%;--snk-personalized-filter--height:100%;--snk-personalized-filter--background-color-line:var(--color--disable-secondary);--snk-personalized-filter--margin-line:var(--border--radius-medium, 12px)}.snk-personalized-filter.sc-snk-personalized-filter{height:var(--snk-personalized-filter--width);width:var(--snk-personalized-filter--height)}.snk-personalized-filter__header-actions.sc-snk-personalized-filter{display:flex;gap:var(--space--medium)}.snk-personalized-filter__group.sc-snk-personalized-filter{flex:1}.snk-personalized-filter__expression-input--line.sc-snk-personalized-filter{width:100%;height:2px;background-color:var(--snk-personalized-filter--background-color-line);margin-top:var(--snk-personalized-filter--margin-line);margin-bottom:var(--snk-personalized-filter--margin-line)}.ez-box__main.sc-snk-personalized-filter{height:90%}.snk-personalized-filter__button-mode.sc-snk-personalized-filter{height:35px}";const Ot=class{constructor(s){t(this,s),this.clickBreadcrumbItem=i(this,"clickBreadcrumbItem",3),this.exit=i(this,"exit",3),this.label=void 0,this.breadcrumbItens=void 0,this.messagesBuilder=void 0}getMessage(t,i){var s;return this.messagesBuilder?this.messagesBuilder.getMessage(t,i):(null===(s=this._application)||void 0===s?void 0:s.messagesBuilder)?this._application.messagesBuilder.getMessage(t,i):void 0}componentDidLoad(){this._element&&(v.addIDInfo(this._element),this._application=o.getContextValue("__SNK__APPLICATION__"))}render(){return s("div",{class:"simple-bar__container ez-margin-vertical--small ez-padding--extra-small"},s("div",{class:"simple-bar__left-slot"},s("ez-button",{class:"ez-padding-right--medium",title:this.getMessage("snkSimpleBar.backTitle"),mode:"icon",iconName:"arrow_back",size:"medium",onClick:()=>this.exit.emit()}),s("div",{class:"simple-bar__column"},s("h1",{class:"ez-title ez-title--primary ez-title--extra-large"},this.label),s("ez-breadcrumb",{items:this.breadcrumbItens,onSelectedItem:({detail:t})=>this.clickBreadcrumbItem.emit(t)}))),s("div",{class:"simple-bar__right-slot"},s("slot",{name:"rightSlot"})))}get _element(){return a(this)}};Ot.style=".sc-snk-simple-bar-h{display:flex;height:100%;width:100%}.simple-bar__container.sc-snk-simple-bar{flex:1;display:flex;align-items:stretch;gap:var(--space--small)}.simple-bar__left-slot.sc-snk-simple-bar{min-width:280px;flex:1;display:flex;align-items:center}.simple-bar__right-slot.sc-snk-simple-bar{flex:1;display:flex;align-items:center;justify-content:flex-end}.simple-bar__column.sc-snk-simple-bar{flex:1;display:flex;flex-direction:column}";const Ft=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","MORE_OPTIONS"],It=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER","MORE_OPTIONS"],Et=class{constructor(s){t(this,s),this.dataStateChange=i(this,"dataStateChange",3),this.dataUnitReady=i(this,"dataUnitReady",3),this.actionClick=i(this,"actionClick",7),this.formItemsReady=i(this,"formItemsReady",7),this.configuratorSave=i(this,"configuratorSave",7),this.configuratorCancel=i(this,"configuratorCancel",7),this._multiSelectionListDataSource=new W,this._formConfigFetcher=new z,this._customEditors=new Map,this._customRenders=new Map,this._container=void 0,this._showPopUpGridConfig=!1,this._currentViewMode=A.GRID,this._config=void 0,this._fieldToGetFocus=void 0,this._customContainerId=`SNK-SIMPLE-CRUD-CUSTOM-CONTAINER-${d.generateUUID()}`,this.enableLockManagerLoadingComp=!1,this.enableLockManagerTaskbarClick=!1,this.dataState=void 0,this.dataUnit=void 0,this.entityName=void 0,this.mode=x.SERVER,this.gridConfig=void 0,this.formConfig=void 0,this._formFields=[],this._fieldsProps=new Map,this.enableContinuousInsert=!1,this.multipleSelection=void 0,this.useCancelConfirm=!0,this.pageSize=150,this.resourceID=void 0,this.enableGridInsert=!1,this.paginationCounterMode="auto",this.taskbarManager=void 0,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.actionsList=void 0,this.configName=void 0,this.showConfiguratorButtons=!1,this.gridLegacyConfigName=void 0,this.formLegacyConfigName=void 0,this.ignoreReadOnlyFormFields=!1,this.autoFocus=!0,this.domainMessagesBuilder=void 0,this.multipleEditionEnabled=!0,this.layoutFormConfig=!0,this.disableGridEdition=!1,this.autoLoad=void 0,this.outlineMode=!1}async addCustomEditor(t,i){if(this._grid&&this._form)return this._grid.addCustomEditor(t,i),void this._form.addCustomEditor(t,i);const s=new Map(this._customEditors);s.set(t,i),this._customEditors=s}async addGridCustomRender(t,i){if(this._grid)return void this._grid.addGridCustomRender(t,i);const s=new Map(this._customRenders);s.set(t,i),this._customRenders=s}async handleResourceIDChanged(t,i){d.isEmpty(t)||t!==i&&(await this.loadFormConfig(!0),await this.loadGridConfig(!0))}async addCustomValueFormatter(t,i){this._grid.addCustomValueFormatter(t,i)}async removeCustomValueFormatter(t){this._grid.removeCustomValueFormatter(t)}async setFieldProp(t,i,s){const e=new Map(this._fieldsProps),n=this._fieldsProps.get(t);e.set(t,Object.assign(Object.assign({},n),{[i]:s})),this._fieldsProps=e}loadTaskbarProcessor(){const t={};t[Pt.FORM_REGULAR]=this.getButtons(!1,[O.GRID_MODE],!0),t[Pt.GRID_REGULAR]=this.getButtons(!1,[O.DATA_EXPORTER,O.FORM_MODE]),t[Pt.FORM_SELECTED]=this.getButtons(!0,[O.GRID_MODE],!0),t[Pt.GRID_SELECTED]=this.getGridSelectedButtonsCallBack.bind(this),t[Pt.FINISH_EDITION]=this.getFinishEditionButtonsCallback.bind(this),t[Pt.MULTIPLE_EDITION]=[O.CANCEL],this._taskbarProcessor=new X(t)}getGridSelectedButtonsCallBack(){var t,i,s;return this.multipleEditionEnabled&&1!==(null===(s=null===(i=null===(t=this.dataState)||void 0===t?void 0:t.selectionInfo)||void 0===i?void 0:i.records)||void 0===s?void 0:s.length)?this.getButtons(!0,[O.UPDATE_MULTIPLE,O.DATA_EXPORTER,O.FORM_MODE]):this.getButtons(!0,[O.DATA_EXPORTER,O.FORM_MODE])}getFinishEditionButtonsCallback(){const t=[O.CANCEL,O.SAVE];return this.enableGridInsert&&this._currentViewMode!==A.ATTACHMENT&&t.push(this._currentViewMode===A.GRID?O.FORM_MODE:O.GRID_MODE),t}getButtons(t,i,s){let e=t?It:Ft;return(s||this.mode===x.IN_MEMORY)&&(e=e.filter((t=>t!==O.REFRESH))),this.addConfigButton(e.concat(i))}addConfigButton(t){return void 0===this.configName||this.configName&&this.gridLegacyConfigName?t:t.concat(O.CONFIGURATOR)}get application(){return o.getContextValue("__SNK__APPLICATION__")}async goToView(t){this._currentViewMode=t,this._viewStack&&(t===A.GRID&&(this.dataUnit.isMultipleEdition=!1),this._viewStack.show(t)),t===A.GRID&&requestAnimationFrame((()=>this.focusToGrid())),t===A.FORM&&requestAnimationFrame((()=>this.focusToForm()))}actionClickListener(t){this.handleTaskbarAction(t.detail),t.stopPropagation()}handleTaskbarAction(t){switch(t){case O.CONFIGURATOR:this._snkConfigurator.open();break;case O.GRID_MODE:this.goToView(A.GRID);break;case O.FORM_MODE:this.goToView(A.FORM);break;case O.UPDATE_MULTIPLE:this.dataUnit.isMultipleEdition=!0,this.goToView(A.FORM)}}async onChangeEntityName(t){if(this.dataUnit)return;const i=o.getContextValue("__SNK__APPLICATION__");this.dataUnit=await i.getDataUnit(t,null,null,this.configName)}onModeChange(){this.mode==x.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(t,i){this.handleDataStateChange(t,i)}async observeFormLegacy(t,i){await this.handleUpdateFormLegacyConfig(t,i)}async observeGridLegacy(t,i){await this.handleUpdateGridLegacyConfig(t,i)}async handleDataStateChange(t,i){m.objectToString(i)!=m.objectToString(t)&&this.dataStateChange.emit(t),await this.processRmPrecision()}async processRmPrecision(){var t,i;const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const e of s||[]){if(!e)continue;const s=null===(i=null===(t=this.dataState)||void 0===t?void 0:t.rowMetadata)||void 0===i?void 0:i.getProp("rm_precision",e);(s||0===s)&&(await this.setFieldProp(e,"precision",s),await this.setFieldProp(e,"prettyPrecision",s))}this._rmPrecisionCustomValueFormatter.setDataState(this.dataState)}async handleUpdateGridLegacyConfig(t,i){null!=t&&t!=i&&this._gridConfigAlreadyLoaded&&await this.loadGridConfig(!0)}async handleUpdateFormLegacyConfig(t,i){null!=t&&t!=i&&this._formConfigAlreadyLoaded&&await this.loadFormConfig(!0)}async openConfig(t){await this._snkConfigurator.close(),t===A.GRID?await this.openGridConfig():t===A.FORM&&await this.openFormConfig()}async openGridConfig(){var t,i,s,e;const n=null!==(i=await(null===(t=this._grid)||void 0===t?void 0:t.getColumns()))&&void 0!==i?i:[],a=null!==(e=await(null===(s=this._grid)||void 0===s?void 0:s.getColumnsState()))&&void 0!==e?e:[];this._snkGridConfig.columns=a.filter((t=>t.name)),this._snkGridConfig.originalColumns=n.filter((t=>t.name)),this._snkGridConfig.selectedIndex=0,this._showPopUpGridConfig=!0}async openFormConfig(){(this.formLegacyConfigName||this.configName)&&await this._snkSimpleFormConfig.show()}addGridLegacyConfigName(){this.gridLegacyConfigName&&this.configName&&H.addGridLegacyConfig(this.configName,this.gridLegacyConfigName)}loadGridConfig(t){if(void 0!==this.configName&&(null==this.gridConfig&&!this._gridConfigAlreadyLoaded||t))return this.addGridLegacyConfigName(),this._gridConfigAlreadyLoaded=!0,new Promise(((t,i)=>{H.loadGridConfig(this.configName,this.resolveResourceID()).then((i=>{this.setGridConfig(i),t()})).catch((t=>{i(t)}))}))}formConfigIsLoaded(){return null!=this.formConfig||this._formConfigAlreadyLoaded}async loadFormConfig(t=!1,i=!1){if(void 0===this.configName)return;if(null==this._formConfigManager&&(this._formConfigManager=new it(this.configName,this.resolveResourceID(),void 0,this.dataUnit),this._formConfigManager.setConfig(this.formConfig)),this.formConfigIsLoaded()&&!t)return;this._formConfigAlreadyLoaded=!0;let s=await this._formConfigFetcher.fetchLegacyConfigurableForm(this.formLegacyConfigName);if(null!=s)return this._formConfigManager.setConfig(s),void this.setFormConfig(s,i);this.setFormConfig(await this._formConfigManager.loadConfig())}async componentWillRender(){this.loadTaskbarProcessor(),this._resourceID=await this.application.getResourceID(),this.dataExporterProviderStore(),this.dataExporterProviderStore(),this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,this.getTaskBarDisabledButtons()),void 0!==this.configName&&(null!=this.gridConfig||this._gridConfigAlreadyLoaded||(await this.addGridLegacyConfigName(),await this.loadGridConfig(),await this.loadFormConfig()))}componentDidRender(){this._rmPrecisionCustomValueFormatter.setGrid(this._grid),this.addGridCustomValueFormattters(),this.setFieldsProps(),this.setCustomRenders(),this.setCustomEditors()}componentWillLoad(){this.processMetadata(),this.onModeChange(),this.configDatasource(),this._rmPrecisionCustomValueFormatter=new Y,this._continuousInsertUtils=new st(this.application,this.resolveResourceID(),this.configName),this.enableGridInsert&&this._continuousInsertUtils.getConfig().then((t=>this.enableContinuousInsert=t))}componentDidLoad(){L.applyVarsGrid(this._element,this._grid),this.initKeyboardManager(),this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this))}async dataUnitActionHandler(t){t.type!==l.EDITION_CANCELED&&t.type!==l.DATA_SAVED||this.dataUnit.isMultipleEdition&&this.goToView(A.GRID)}getMessage(t,i){var s;return null===(s=this.messagesBuilder)||void 0===s?void 0:s.getMessage(t,i)}disconnectedCallback(){var t;null===(t=this._keyboardManager)||void 0===t||t.unbindAllShortcutKeys()}setCustomRenders(){if(this._grid)for(const[t,i]of this._customRenders)this._grid.addGridCustomRender(t,i),this._customRenders.delete(t)}setCustomEditors(){if(this._grid&&this._form)for(const[t,i]of this._customEditors)this._grid.addCustomEditor(t,i),this._form.addCustomEditor(t,i),this._customEditors.delete(t)}configDatasource(){this._multiSelectionListDataSource.setApplication(this.application),this._multiSelectionListDataSource.setDataUnit(this.dataUnit)}setFieldsProps(){if(this._form)for(const[t,i]of this._fieldsProps){for(const s in i)this._form.setFieldProp(t,s,i[s]);this._fieldsProps.delete(t)}}getTaskBarId(){var t,i;return(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?Pt.FINISH_EDITION:this.dataUnit.isMultipleEdition?Pt.MULTIPLE_EDITION:(null===(i=this.dataState)||void 0===i?void 0:i.selectionInfo)&&!this.dataState.selectionInfo.isAllRecords()&&this.dataState.selectionInfo.length>0?this._currentViewMode===A.GRID?Pt.GRID_SELECTED:Pt.FORM_SELECTED:this._currentViewMode===A.GRID?Pt.GRID_REGULAR:Pt.FORM_REGULAR}initInMemoryDataUnit(){this._inMemoryLoader=new w(this._metadata,void 0,{autoLoad:this.autoLoad}),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(t){return this._inMemoryLoader?this._inMemoryLoader.metadata=t:this.dataUnit&&(this.dataUnit.metadata=t),Promise.resolve()}setRecords(t){return this._inMemoryLoader?this._inMemoryLoader.records=t:this.dataUnit&&(this.dataUnit.records=t),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}async openConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.open()}async closeConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.close()}async updateConfig(){null==this._formConfigManager&&(this._formConfigManager=new it(this.configName,this.resolveResourceID())),this._formConfigManager.setConfig(this.formConfig)}processMetadata(){const t=this._element.querySelectorAll("snk-field-metadata"),i=[],s={fields:[],emptyConfig:!1};t.forEach((t=>{const e={name:t.getAttribute("name")||t.getAttribute("label"),label:t.getAttribute("label"),dataType:r[t.getAttribute("dataType")]||r.TEXT,userInterface:h[t.getAttribute("userInterface")]||h.SHORTTEXT,readOnly:"true"==t.getAttribute("readOnly"),required:"true"==t.getAttribute("required"),tab:t.getAttribute("tab")||void 0,visible:"false"!=t.getAttribute("visible")};s.fields.push({name:e.name,tab:e.tab,visible:e.visible}),i.push(e)})),i.length>0&&(this.formConfig||(this.formConfig=s),this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:i})}addGridCustomValueFormattters(){var t,i,s;const e=(null===(t=this._metadata)||void 0===t?void 0:t.fields)||(null===(s=null===(i=this.dataUnit)||void 0===i?void 0:i.metadata)||void 0===s?void 0:s.fields);if(!e)return;const n=[];e.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rm_precision)&&!n.includes(t.name)&&n.push(t.name)})),n.forEach((t=>{this.addCustomValueFormatter(t,this._rmPrecisionCustomValueFormatter)}))}onDataStateChange(t){this.dataState=Object.assign({},t.detail)}getTaskBarDisabledButtons(){var t,i,s,e,n,a;const o=[];return(null===(t=this.dataState)||void 0===t?void 0:t.hasNext)||o.push(O.NEXT),(null===(i=this.dataState)||void 0===i?void 0:i.hasPrevious)||o.push(O.PREVIOUS),(null===(e=null===(s=this.dataState)||void 0===s?void 0:s.selectionInfo)||void 0===e?void 0:e.isEmpty())&&o.push(O.FORM_MODE),(null===(a=null===(n=this.dataState)||void 0===n?void 0:n.selectionInfo)||void 0===a?void 0:a.length)>1&&o.push(O.CLONE),o}handleCancelEdit(){var t;(null===(t=this.dataState)||void 0===t?void 0:t.recordsIsEmpty)&&(this.goToView(A.GRID),this.dataUnit.clearSelection())}handleConfiguratorEvent(t,i){t.stopImmediatePropagation(),"SAVE"!==i?this.configuratorCancel.emit():this.configuratorSave.emit()}onSelectField(t){null!=t&&(this._fieldToGetFocus=t.value)}getFieldSearch(t,i){return null!=this._fieldSearch||(this._splitButtonForm=t,this._fieldSearch=D(i,(({argument:t})=>this.fieldsOptionLoader(t)),(t=>this.onSelectField(t)))),this._fieldSearch}getFormFields(){var t,i;return null!==(i=null===(t=this.formConfig)||void 0===t?void 0:t.fields)&&void 0!==i?i:this._formFields}handleFormSetFields(t){m.equals(this._formFields,t)||(this._formFields=null!=t?t:[])}fieldsOptionLoader(t){const i=null==t?void 0:t.toLowerCase(),s=this.getFormFields().map((t=>{var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.getField(t.name)})).filter((t=>{var s,e;return(null===(s=t.name)||void 0===s?void 0:s.toLowerCase().includes(i))||(null===(e=t.label)||void 0===e?void 0:e.toLowerCase().includes(i))})).map((t=>({value:t.name,label:t.label})));return Promise.resolve(s)}isGridInsertActive(){return this.enableGridInsert&&this.dataUnit.hasNewRecord()}getColumnSearch(t,i){return null!=this._columnSearch||(this._splitButton=t,this._columnSearch=D(i,(({argument:t})=>new Promise((i=>{this._grid.filterColumns(t).then((t=>{i(t.filter((t=>!t.hidden)).map((t=>({label:t.label,value:t.name}))))}))}))),(t=>{null!=t&&this._grid.locateColumn(t.value)}))),this._columnSearch}getActionsList(){const t=[];if(this.enableGridInsert&&t.push(this._continuousInsertUtils.actionContinuousInsert(this.enableContinuousInsert,(()=>{this.enableContinuousInsert=!this.enableContinuousInsert,this._continuousInsertUtils.handleSaveConfig(this.enableContinuousInsert)}))),this.isGridInsertActive())return t;if(null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions){const i=this.getTopTaskBarId();return t.concat(this.taskbarManager.getMoreOptions(i,this.configName,this.dataState,this.actionsList))}return t.concat(this.actionsList)}getSettingsListGrid(){return[{value:d.generateUUID(),label:this.getMessage("snkSimpleCrud.findColumn"),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(t,i)=>this.getColumnSearch(t,i)}]}getSettingsListForm(){return[{value:d.generateUUID(),label:this.getMessage("snkSimpleCrud.findFields"),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(t,i)=>this.getFieldSearch(t,i)}]}getTopTaskBarId(){var t;return(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?`snkGridTopTaskbar.finish_edition${k.PRIMARY}`:`snkGridTopTaskbar.regular${k.PRIMARY}`}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}gridConfigChangeHandler(t){t.stopPropagation(),this.configName&&H.saveGridConfig(t.detail,this.configName,this.resolveResourceID())}modalConfigChangeHandler(t){const i=t.detail;this._grid.setColumnsState(i.columns).then((()=>{this.setGridConfig(i),this.closeGridConfig(),this.dataExporterProviderStore()})),t.stopPropagation()}async dataExporterProviderStore(){if(null==this.dataUnit)return;if(null==this._grid)return;const t=new tt(this.dataUnit,this._grid);J.set("exporterProviders",Object.assign(Object.assign({},J.get("exporterProviders")),{[this.getDataExporterStoreKey()]:t}))}getDataExporterStoreKey(){return`SnkSimpleCrudDataExporter:${null==this.configName?this.dataUnit.name:this.configName}`}setGridConfig(t){this.gridConfig=t,Z.assertDefaultSorting(this.gridConfig,this.dataUnit)}setFormConfig(t,i){this.formConfig&&!i||(this.formConfig=t)}closeGridConfig(){this._showPopUpGridConfig=!1}getPageSize(){return this.mode===x.IN_MEMORY?0:null==this.pageSize?150:this.pageSize}resolveResourceID(){return d.isEmpty(this.resourceID)?this._resourceID:this.resourceID}getFormConfig(){var t;const i=null===(t=this._formConfigManager)||void 0===t?void 0:t.getConfig(this.dataUnit,this.ignoreReadOnlyFormFields);return this.configName||i?i:this.formConfig}updateFormConfig(){let t=this.formConfig;null==this.formLegacyConfigName&&(t=Object.assign(Object.assign({},this.formConfig),{fields:this.dataUnit.metadata.fields})),this.setFormConfig(t,!0),null==this._formConfigManager&&(this._formConfigManager=new it(this.configName,this.resolveResourceID())),this._formConfigManager.setConfig(this.formConfig)}handleDataUnitOnInsertionMode(){this.enableGridInsert||this.goToView(A.FORM)}async initKeyboardManager(){var t;this._keyboardManager=new f({propagate:!1,element:this._element});const i=this.dataUnit||await(null===(t=this._snkDataUnit)||void 0===t?void 0:t.getDataUnit());null!=i&&this._keyboardManager.bind("F7",(()=>i.saveData()),{description:this.getMessage("snkSimpleCrud.keyboardShortcuts.saveData"),element:this._element}).bind("F8",i.addRecord.bind(i),{description:this.getMessage("snkSimpleCrud.keyboardShortcuts.addRecord"),element:this._element}).bind("F9",i.removeSelectedRecords.bind(i),{description:this.getMessage("snkSimpleCrud.keyboardShortcuts.removeRecord"),element:this._element}).bind("Escape",(()=>{i.isDirty()&&i.cancelEdition()}),{debounceTime:1e3,description:this.getMessage("snkSimpleCrud.keyboardShortcuts.cancelAction"),element:this._element})}async handleFormConfigSaved(){await this.loadFormConfig(!0,!0)}focusToGrid(){this._grid.focus()}focusToForm(){this._form.focus()}renderTaskbarContent(t){var i;return s("snk-taskbar",{class:"ez-box--no-outline ez-box "+(this._currentViewMode===A.FORM?(this.outlineMode?"ez-box--outline":"ez-box--shadow-xsmall")+" ez-padding--small":""),dataUnit:this.dataUnit,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"SAVE":"INSERT","data-element-id":"grid_left",messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,actionsList:this.getActionsList(),actionsSettingsList:t===A.GRID?this.getSettingsListGrid():this.getSettingsListForm(),disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,"data-exporter-store-key":this.getDataExporterStoreKey(),slot:"leftButtons",presentationMode:k.SECONDARY,tabindex:"0"},s("slot",{name:"TASKBAR_CUSTOM_ELEMENTS"}))}render(){var t;if(null!=this.dataUnit)return s("snk-data-unit",{ref:t=>this._snkDataUnit=t,class:"simple-crud__container",dataUnit:this.dataUnit,useCancelConfirm:this.useCancelConfirm,onDataStateChange:t=>this.onDataStateChange(t),onCancelEdition:this.handleCancelEdit.bind(this),pageSize:this.getPageSize(),onInsertionMode:this.handleDataUnitOnInsertionMode.bind(this),onDataUnitReady:t=>this.dataUnitReady.emit(t.detail),onMessagesBuilderUpdated:t=>this.messagesBuilder=t.detail,onDataUnitFieldsHidded:this.updateFormConfig.bind(this),domainMessagesBuilder:this.domainMessagesBuilder},s("header",null,s("slot",{name:"snkSimpleCrudHeader"})),s("section",{class:`ez-box ez-box--no-outline ${this.outlineMode?"ez-box--outline":"ez-box--shadow"} simple-crud__container-section`,ref:t=>this._container=t,tabindex:"0"},s("ez-view-stack",{ref:t=>this._viewStack=t,"data-element-id":"simple-crud"},s("stack-item",null,s("ez-grid",{class:"ez-margin-bottom--large ez-box--no-outline",ref:t=>this._grid=t,dataUnit:this.dataUnit,config:this.gridConfig,"no-header":!0,multipleSelection:this.multipleSelection,onEzDoubleClick:()=>this.goToView(A.FORM),onConfigChange:t=>this.gridConfigChangeHandler(t),columnfilterDataSource:this.dataUnit.name&&this.dataUnit.name.includes(w.IN_MEMORY_DATA_UNIT_NAME)?void 0:this._multiSelectionListDataSource,useEnterLikeTab:this.useEnterLikeTab,autoFocus:this.autoFocus,enableGridInsert:this.enableGridInsert,enableContinuousInsert:this.enableContinuousInsert,enableLockManagerTaskbarClick:this.enableLockManagerTaskbarClick,enableLockManagerLoadingComp:this.enableLockManagerLoadingComp,outlineMode:this.outlineMode,tabindex:"0",paginationCounterMode:this.paginationCounterMode,canEdit:!this.disableGridEdition},this.renderTaskbarContent(A.GRID),s("div",{slot:"footer"},s("slot",{name:"snkSimpleCrudFooter"})))),s("stack-item",null,this.renderTaskbarContent(A.FORM),s("ez-form",{ref:t=>this._form=t,class:"ez-margin-top--large ez-box--no-outline",dataUnit:this.dataUnit,config:this.getFormConfig(),fieldToFocus:this._fieldToGetFocus,onEzFormSetFields:t=>this.handleFormSetFields(t.detail),onEzFormRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),elementFocusSearchField:this._container,tabindex:"0"}),s("slot",{name:"snkSimpleCrudFormFooter"}),s("snk-simple-form-config",{ref:t=>this._snkSimpleFormConfig=t,dataUnit:this.dataUnit,onSnkConfigSaved:this.handleFormConfigSaved.bind(this),configName:null!==(t=this.formLegacyConfigName)&&void 0!==t?t:this.configName,messagesBuilder:this.messagesBuilder})),this.messagesBuilder&&s("snk-configurator",{ref:t=>this._snkConfigurator=t,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:t=>this.goToView(t.detail),onOpenConfig:t=>this.openConfig(t.detail),showActionButtons:this.showConfiguratorButtons,onSave:t=>this.handleConfiguratorEvent(t,"SAVE"),onCancel:t=>this.handleConfiguratorEvent(t,"CANCEL"),resourceID:this.resolveResourceID(),customContainerId:this._customContainerId,layoutFormConfig:this.layoutFormConfig})),s("div",{id:`${this._customContainerId}`},s("slot",{name:"SnkConfigContainerSlot"}))),s("ez-popup",{size:"medium",heightMode:"auto",useHeader:!1,opened:this._showPopUpGridConfig,onEzClosePopup:()=>this.closeGridConfig()},s("snk-grid-config",{ref:t=>this._snkGridConfig=t,config:this.gridConfig,"data-element-id":this._element.getAttribute(v.DATA_ELEMENT_ID_ATTRIBUTE_NAME),selectedIndex:0,configName:this.configName,onConfigChange:t=>this.modalConfigChangeHandler(t),onConfigCancel:()=>this.closeGridConfig(),resourceID:this.resolveResourceID()})))}get _element(){return a(this)}static get watchers(){return{resourceID:["handleResourceIDChanged"],entityName:["onChangeEntityName"],mode:["onModeChange"],dataState:["observeDataState"],formLegacyConfigName:["observeFormLegacy"],gridLegacyConfigName:["observeGridLegacy"]}}};var Pt;!function(t){t.FORM_REGULAR="snkSimpleCrudTaskbar.form_regular",t.GRID_REGULAR="snkSimpleCrudTaskbar.grid_regular",t.FORM_SELECTED="snkSimpleCrudTaskbar.form_selected",t.GRID_SELECTED="snkSimpleCrudTaskbar.grid_selected",t.FINISH_EDITION="snkSimpleCrudTaskbar.finish_edition",t.MULTIPLE_EDITION="snkSimpleCrudTaskbar.multiple_edition"}(Pt||(Pt={})),Et.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%;--snk-simple-crud-grid--min-height:300px}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto 1fr;height:100%;width:100%}.simple-crud__container-section.sc-snk-simple-crud{flex-wrap:unset;flex-direction:column}.simple-crud__form--hidden.sc-snk-simple-crud{display:none}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;--ez-grid__container--shadow--outline:none;--ez-grid--min-height:var(--snk-simple-crud-grid--min-height)}ez-form.sc-snk-simple-crud{min-height:300px}";export{kt as snk_attach,_t as snk_default_filter,yt as snk_dynaform_form_view,wt as snk_filter_advanced_mode,Ct as snk_filter_assistent_mode,zt as snk_filter_detail,At as snk_filter_modal_item,xt as snk_image_input,St as snk_personalized_filter,Ot as snk_simple_bar,Et as snk_simple_crud}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,h as i,f as s,g as e,e as n}from"./p-2c9d0870.js";import{ApplicationContext as o,StringUtils as r,ErrorException as a,WarningException as l,ObjectUtils as c,DateUtils as d,ServiceUtils as h,StorageType as u,ArrayUtils as g,ElementIDUtils as f,UserInterface as p}from"@sankhyalabs/core";import{D as m}from"./p-10d883b0.js";import{P as v}from"./p-eaad0aa8.js";import"./p-3190ac29.js";import"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-c1e168a2.js";import"./p-ff1990ad.js";import{F as b}from"./p-d7657667.js";import{O as _}from"./p-9019a32f.js";import{g as k}from"./p-7dd49d15.js";import{R as w}from"./p-688dcb4c.js";import{ApplicationUtils as y,DialogType as C,FormLayout as x}from"@sankhyalabs/ezui/dist/collection/utils";import{C as z}from"./p-13f91e7e.js";import{GRID_COLUMN_DEFAULT_WIDTHS as S}from"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import{S as A}from"./p-cad964b5.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/utils/SortingUtils";class L{execute(t){var i;const s={actionID:t.actionID,refreshType:null===(i=t.actionConfig.javaCall)||void 0===i?void 0:i.refreshType};return new Promise((t=>{t({execSource:s,callback:this.callExecJava})}))}async callExecJava(t){const i={requestBody:{javaCall:t}};await m.get().callServiceBroker("ActionButtonsSP.executeJava",JSON.stringify(i))}}class N{execute(t){var i;const s={actionID:t.actionID,refreshType:null===(i=t.actionConfig.runScript)||void 0===i?void 0:i.refreshType};return new Promise((t=>{t({execSource:s,callback:this.callExecScript})}))}async callExecScript(t){const i={runScript:t};await m.get().callServiceBroker("ActionButtonsSP.executeScript",i)}}class P{constructor(){this._application=o.getContextValue("__SNK__APPLICATION__")}async execute(t,i){const s=t.resourceID;if(!s)return;let e=await this.buildLaunchObject(t,i);return this._application.openApp(s,e),null}buildLaunchObject(t,i){return new Promise((s=>{let e=t.actionConfig.params.param;if(e&&e.length>0){let n={},o=[];e.forEach((s=>{const e=s.localField;let l=i.getFieldValue(e);if(!l){let s=i.getField(e).label;throw s=r.isEmpty(i.getField(e).label)?e:s,new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.launchScreen.emptyField",{description:t.description,localFieldLabel:s}))}null!==l&&"object"==typeof l&&"value"in l&&(l=l.value);const c=r.isEmpty(null==l?void 0:l.toString())?void 0:l.toString();n[s.targetField]=c,o.push({fieldName:s.targetField,value:c})})),n.ACTION_PARAMETERS=o,n.call_time=Date.now(),s(n)}s(null)}))}}class O{execute(t){var i,s,e;const n=null===(i=t.actionConfig.dbCall)||void 0===i?void 0:i.name,o=null===(s=t.actionConfig.dbCall)||void 0===s?void 0:s.rootEntity,r={actionID:t.actionID,refreshType:null===(e=t.actionConfig.dbCall)||void 0===e?void 0:e.refreshType,procName:n,rootEntity:o};return new Promise((t=>{t({execSource:r,callback:this.callExecProcedure})}))}async callExecProcedure(t){const i={requestBody:{stpCall:t}};await m.get().callServiceBroker("ActionButtonsSP.executeSTP",JSON.stringify(i))}}var I,D;!function(t){t.LAUNCH_SCREEN="LC",t.JAVASCRIPT="SC",t.JAVA="RJ",t.PROCEDURE="SP",t.EMBEDDED="EB"}(I||(I={}));class E{constructor(t){this.actionType=t,this._application=o.getContextValue("__SNK__APPLICATION__")}get executor(){switch(this.actionType){case I.LAUNCH_SCREEN:return new P;case I.JAVASCRIPT:return new N;case I.JAVA:return new L;case I.PROCEDURE:return new O;default:throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.nonExistentType",{actionType:this.actionType}))}}}!function(t){t.NONE="NONE",t.PARENT="PARENT",t.MASTER="MASTER",t.ALL="ALL"}(D||(D={}));const T="__MASTER_ROW__";class B{constructor(t,i,s){var e;this._lastValuesCache={},this._actionsExecuteInterface=t,this._dataUnit=i,this._selectedRows=(null===(e=null==i?void 0:i.getSelectionInfo())||void 0===e?void 0:e.isAllRecords())?[]:null==i?void 0:i.getSelectionInfo().records,this._application=o.getContextValue("__SNK__APPLICATION__"),this._appResourceId=s}getPrimaryKeys(){return k(this._dataUnit).map((({name:t})=>t))}apply(t,i){this._application.closePopUp(),this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:s,callback:e})=>{this.resolvePromptParams(t,s,i).then((()=>{this.actionExecute(s,e)}))}))}async execute(t){var i;if(!t.actionConfig)throw new l(this._application.messagesBuilder.getMessage("snkActionsButton.title.warning",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.incorrectAction",{description:t.description}));if(null===(i=t.actionConfig.params)||void 0===i?void 0:i.promptParam){const i=t.actionConfig.params.promptParam;let s=!1;for(let t=0;t<i.length;t++)if(!s&&"true"===i[t].saveLast){s=!0;break}s&&(t.actionConfig.params.promptParam=await this.loadSavedValuesIntoParams(t));const e=document.createElement("snk-actions-form");window.document.body.appendChild(e),e.action=c.copy(t),e.applyParameters=t=>{this.apply(t,s)},e.openPopup()}else t.type!=I.LAUNCH_SCREEN?this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:t,callback:i})=>{this.actionExecute(t,i)})):this._actionsExecuteInterface.execute(t,this._dataUnit)}loadSavedValuesIntoParams(t){return this.loadLastValues(t).then((i=>{let s=t.actionConfig.params.promptParam;return i&&i.param.forEach((t=>{s=s.map((i=>i.name!==t.paramName?i:Object.assign(Object.assign({},i),"B"===i.paramType?{value:"S"===t.$}:{value:t.$})))})),s}))}async actionExecute(t,i){t.virtualPage=this.buildVirtualPage(),await this.prepareAndExecute(t,i),this.recordsReloader(t.refreshType)}resolvePromptParams(t,i,s){return new Promise((e=>{let n=[];t.actionConfig.params.promptParam.forEach((t=>{n.push(this.buildPromptParam(t))})),this.putParamsOnExecSource(n,i),s&&this.saveLastValues(t,n),e()}))}buildPromptParam(t){let i,s,e=t.paramType,n=!1,o=t.value;switch(e){case v.DATE:e="D";break;case v.DATETIME:e="H";break;case v.DECIMAL:e="F",i={"sk-precision":Number(t.precision)};break;case v.BOOLEAN:e="S",n=!0,o=t.value?"S":"N";break;case v.ENTITY:i={"sk-entity-name":t.entityName,"sk-allow-show-hierarchical-mode":t.hierarchyEntity,"sk-data-type":"S"},t.hierarchyEntity&&t.entityPK&&(s=t.entityPK),o=t.value?Number(t.value):null;break;case v.OPTIONS:e="O";let r=t.options.split(";").map((function(t,i){let s,e;if(t.indexOf("=")>-1){let i=t.split("=");s=i[0],e=i[1]}else s=i+1,e=t;return{data:s,value:e}}));i={"sk-options":r}}return{description:t.label,required:"true"==t.required,fieldName:t.name,fieldNameOri:t.name,entityPK:s,paramType:t.paramType,type:e,isCheckbox:n,saveLast:t.saveLast,fieldProp:i,value:o,isGeneratedName:t.isGeneratedName}}putParamsOnExecSource(t,i){i.params={param:[]},t.forEach((t=>{if(t.isGeneratedName&&t.value)throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.emptyParamName",void 0));r.isEmpty(t.value)||i.params.param.push({type:this.getParamDataType(t.paramType),paramName:t.fieldName,$:this.getParamValue(t)})}))}getParamDataType(t){let i;switch(t){case"D":i="F";break;case"DT":case"DH":i="D";break;case"B":case"ENTITY":case"SO":i="S";break;default:i=t}return i}getParamValue(t){let i=t.value;return i?("DT"==t.paramType?i=d.formatDate(i):"DH"==t.paramType&&(i=d.formatDateTime(i)),i):i}async loadLastValues(t){const i=await this.buildResourceId(t.actionID);return new Promise(((t,s)=>{if(this._lastValuesCache[i])t(this._lastValuesCache[i]);else{const e={config:{chave:i,tipo:"T"}};m.get().callServiceBroker("SystemUtilsSP.getConf",e).then((s=>{var e,n;let o;(null===(n=null===(e=s.config)||void 0===e?void 0:e.data)||void 0===n?void 0:n.params)&&(o=s.config.data.params,Array.isArray(o.param)||(o.param=[o.param])),this._lastValuesCache[i]=o,t(o)})).catch((t=>{s(t)}))}}))}async saveLastValues(t,i){if(this._application){let s={params:{param:[]}};i.forEach((t=>{"true"==t.saveLast&&s.params.param.push({paramName:t.fieldName,$:t.value})}));const e=await this.buildResourceId(t.actionID);this._lastValuesCache[e]=s.params,this._application.saveConfig(e,s)}}async buildResourceId(t){return this._appResourceId+".actionconfig."+t}async prepareAndExecute(t,i){this.addRows(t),await i(t)}addRows(t){const i=this.getPrimaryKeys(),s={row:[]},e=this._selectedRows;for(const t in e){const n=e[t],o={};n.hasOwnProperty(T)&&(o.master="S",o.entityName=n.__ENTITY_NAME__,delete n[T],delete n.__ENTITY_NAME__),o.field||(o.field=[]);for(const t of i)o.field.push({fieldName:t,$:n[t]});s.row.push(o)}s.row.length>0&&(t.rows=s)}recordsReloader(t){switch(t){case D.NONE:break;case D.PARENT:case D.MASTER:case D.ALL:this._dataUnit.loadData();break;default:this._dataUnit.reloadCurrentRecord()}}buildVirtualPage(){var t,i,s,e;if(null===(i=null===(t=this._dataUnit)||void 0===t?void 0:t.getSelectionInfo())||void 0===i?void 0:i.isAllRecords())return{filters:{filters:null===(s=this._dataUnit)||void 0===s?void 0:s.getAppliedFilters()},orders:{orders:null===(e=this._dataUnit)||void 0===e?void 0:e.getSort()}}}}class j{async clientConfirm(t,i){return new Promise((s=>{var e,n;const r=o.getContextValue("__SNK__APPLICATION__");let a="";t.content.event.hasOwnProperty("stpCall")?(i.requestBody=t.content.event.stpCall,a=I.PROCEDURE):t.content.event.hasOwnProperty("runScript")?(i.requestBody=t.content.event.runScript,a=I.JAVASCRIPT):t.content.event.hasOwnProperty("javaCall")&&(i.requestBody=t.content.event.javaCall,a=I.JAVA);let l={type:"S",sequence:t.content.event.sequence};i.requestBody.params?Array.isArray(i.requestBody.params.param)||(i.requestBody.params.param=[i.requestBody.params.param]):i.requestBody.params={param:[]},i.requestBody.params.param.push(l);const c=t.content.event.title.$,d=t.content.event.message.$;let h;switch(a){case I.JAVASCRIPT:h={runScript:i.requestBody};break;case I.PROCEDURE:h={requestBody:{stpCall:i.requestBody}};break;case I.JAVA:h={requestBody:{javaCall:i.requestBody}}}if("S"==t.content.event.showNoOption){l.paramName="__ESCOLHA_SIMNAO__";const t=document.createElement("snk-client-confirm");window.document.body.appendChild(t),t.titleMessage=c,t.message=d,t.accept=async()=>{l.$="S",await i.reCall(h),s()},t.cancel=async()=>{l.$="N",await i.reCall(h),s()},t.openPopup()}else r.confirm(c,d,null,"warn",{labelCancel:null===(e=null==r?void 0:r.messagesBuilder)||void 0===e?void 0:e.getMessage("snkActionsButton.clientEvent.labelCancel"),labelConfirm:null===(n=null==r?void 0:r.messagesBuilder)||void 0===n?void 0:n.getMessage("snkActionsButton.clientEvent.labelConfirm")}).then((async t=>{t&&(l.paramName="__CONFIRMACAO__",l.$="S",await i.reCall(h),s())}))}))}}const G=class{constructor(i){t(this,i),this.CLIENT_EVENT_CONFIRM_NAME="br.com.sankhya.actionbutton.clientconfirm",this._actions=[],this.handleClick=t=>{const i=this._actions.find((i=>i.actionID==t.detail.id)),s=new E(i.type).executor;new B(s,this._dataUnit,this._resourceID).execute(Object.assign({},i)),this._showDropdown=!1},this.size="medium",this._items=[],this._showDropdown=!1}async getActions(){const t=await h.useCacheWithService(`SnkActionsButton_${this._entityName}-${this._resourceID}`,(async()=>{var t;const i={param:{entityName:this._entityName,resourceID:this._resourceID}};return(null===(t=(await m.get().callServiceBroker("ActionButtonsSP.getActions",i)).actions)||void 0===t?void 0:t.action)||[]}),u.IN_MEMORY_CACHE);this._actions=G.parameters.isOrderActions?g.sortAlphabetically(t,"description"):t}controlDropdown(){this._showDropdown=!this._showDropdown}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}positionDropdown(){var t;const i=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();i&&this._dropdownParent&&(this._dropdownParent.style.top=i.y+i.height+5+"px",this._dropdownParent.style.left=i.x+"px")}closeDropdown(t){const i=null==t?void 0:t.target;i&&(i.closest(".snk-actions-button")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}async componentWillLoad(){var t,i;this._application=o.getContextValue("__SNK__APPLICATION__"),await this.loadParameters();const s=this._element.parentElement;this._dataUnit=null==s?void 0:s.dataUnit,this._resourceID=null==s?void 0:s.resourceID,this._entityName=null===(i=null===(t=this._dataUnit)||void 0===t?void 0:t.name)||void 0===i?void 0:i.split("/")[2],null==this._resourceID&&(this._resourceID=await w.getResourceID()),this.setEvents(),await this.getActions(),this.loadItems()}async componentDidLoad(){if(this._element&&(f.addIDInfo(this._element),this.positionDropdown(),!await this._application.hasClientEvent(this.CLIENT_EVENT_CONFIRM_NAME))){const t=new j;this._application.addClientEvent(this.CLIENT_EVENT_CONFIRM_NAME,t.clientConfirm)}}componentDidUpdate(){this.positionDropdown()}loadItems(){this._actions&&0!=this._actions.length&&this._actions.forEach((t=>{this._items.push({id:t.actionID,label:t.description})}))}getElementID(t){return{[f.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:f.getInternalIDInfo(t)}}async loadParameters(){null==G.parameters.isOrderActions&&(G.parameters.isOrderActions=await this._application.getBooleanParam("global.ordenar.acoes.personalizadas"))}render(){return i(s,null,this._actions&&this._actions.length>0&&i("div",{class:`snk-actions-button\n ${this.canShowDropdown()?" ez-elevation--16":""}\n `},i("ez-tooltip",{message:this._application.messagesBuilder.getMessage("snkActionsButton.title.actions",void 0)},i("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"acao",mode:"icon",onClick:()=>this.controlDropdown(),size:this.size},this.getElementID("button")))),i("div",Object.assign({ref:t=>this._dropdownParent=t,class:(this.canShowDropdown()?"snk-actions-button__dropdown--show":"snk-actions-button__dropdown")+"\n "},this.getElementID("dropdown")),this.canShowDropdown()&&i("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.handleClick(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&i("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))))}get _element(){return e(this)}};G.parameters={isOrderActions:null},G.style=".sc-snk-actions-button-h{display:flex;width:fit-content;height:fit-content}.snk-actions-button.sc-snk-actions-button{display:flex;width:fit-content;height:fit-content}.snk-actions-button__dropdown--show.sc-snk-actions-button{display:flex;flex-direction:column;position:fixed}.snk-actions-button__dropdown.sc-snk-actions-button>ez-dropdown.sc-snk-actions-button{position:relative}.snk-actions-button__dropdown.sc-snk-actions-button{display:none}";const F=class{constructor(i){t(this,i),this.configChange=n(this,"configChange",7),this.configCancel=n(this,"configCancel",7),this._orderListItems=[],this._orderPriorityList=[],this._visibleList=[],this._hiddenList=[],this._columListItems=[],this._dataChanged=!1,this._componenteInternalKey=Date.now(),this.selectedIndex=0,this.columns=[],this.originalColumns=[],this.config=void 0,this.configName=void 0,this.resourceID=void 0,this.metadata=void 0,this._collapsibleBoxListOrder=!0,this._collapsibleBoxListSelect=!1}getMessage(t,i){return o.getContextValue("__SNK__APPLICATION__").messagesBuilder.getMessage(t,i)}getSortableColumns(){let t=[];return this.columns.filter((t=>{var i;return r.getBooleanValue(null===(i=null==t?void 0:t.props)||void 0===i?void 0:i.get("sortable"),!0)})).forEach((i=>{var s,e;let n=null===(s=this.config)||void 0===s?void 0:s.columns.find((t=>t.name===i.name)),o={label:i.label,sort:null!==(e=null==i?void 0:i.sort)&&void 0!==e?e:_.asc.value,id:i.name};n&&(o.orderIndex=n.orderIndex,o.ascending=n.ascending),i.hidden||t.push(o)})),t}createOrderList(){var t;let i=this.getSortableColumns();if((null===(t=this._orderPriorityList)||void 0===t?void 0:t.length)>0){const t=[];this._orderPriorityList.forEach((s=>{const e=i.find((t=>t.id===s.id));e&&t.push(e)})),i.forEach((i=>{t.find((t=>t.id===i.id))||t.push(i)})),this._orderListItems=t}else i.sort(((t,i)=>0!=t.orderIndex||0!=i.orderIndex||null==t.ascending&&null==i.ascending?null!=t.ascending&&null!=i.ascending?t.orderIndex-i.orderIndex:null!=t.ascending||null!=i.ascending?null!=t.ascending?-1:null!=i.ascending?1:0:t.orderIndex-i.orderIndex:null!=t.ascending?-1:null!=i.ascending?1:0)),this._orderListItems=i}createColumnList(){const t=this.buildVisibleGroup(),i=this.buildHiddenGroup();this.columns.forEach((s=>{const e=this.buildListItemFromColumn(s);s.hidden?i.items.push(e):t.items.push(e)})),this._columListItems=[t,i],this._visibleList=t.items,this._hiddenList=i.items,this.createOrderList()}buildVisibleGroup(){return{group:this.getMessage("snkGridConfig.group.visible"),items:[]}}buildHiddenGroup(){return{group:this.getMessage("snkGridConfig.group.hidden"),items:[],sort:_.asc.value}}createOrderListSlotDataElementId(t){var i;return`${this._element.getAttribute(f.DATA_ELEMENT_ID_ATTRIBUTE_NAME)}_configItem_${r.toCamelCase(null!==(i=t.id)&&void 0!==i?i:t.label)}`}buildOrderListSlot(t){const s=this.createOrderListSlotDataElementId(t);let e=_.none.value;return null!=(null==t?void 0:t.ascending)&&(e=1==t.ascending?_.asc.value:_.desc.value),i("snk-select-box",{selectedOption:e,key:"snk-select-box-"+this._componenteInternalKey+"-"+t,"data-element-id":s,onEzChange:i=>{i.stopPropagation(),this.updateOrder(i.detail,t.id)},preventAutoFocus:!0})}updateOrder(t,i){var s;this._dataChanged=!0;let e,n=[...this.columns],o=n.find((t=>t.name===i));if(o&&(o.sort=t.value===_.none.value?void 0:t.value),(null===(s=this._orderPriorityList)||void 0===s?void 0:s.length)>0){const i=this._orderPriorityList.find((t=>t.id===o.name));i&&(i.sort=t.value===_.none.value?void 0:t.value),this._orderPriorityList.filter((t=>null!=t.sort)).forEach(((t,i)=>{t.id===o.name&&(o.sortIndex=i)}))}else e=n.filter((t=>t.sort&&!0!==t.hidden)).map(((t,i)=>({name:t.name,orderIndex:i}))),e.forEach((t=>{n.find((i=>i.name===t.name)).sortIndex=t.orderIndex}));this.columns=n}finish(){this._dataChanged?(this.updateColumns(),this._dataChanged=!1,this.closeConfig(),this.save(),this._orderPriorityList=[]):this.closeConfig()}updateColumns(){this.columns=this._columListItems.flatMap((t=>t.items.map((i=>this.buildColumnFromListItem(i,t)))))}buildColumnFromListItem(t,i){const s=this.columns.find((i=>i.name===t.id));if(!s)throw new Error(`Column with name "${t.id}" not found.`);return Object.assign(Object.assign({},s),{hidden:i.group===this.getMessage("snkGridConfig.group.hidden")})}saveGridConfigOnStorage(t){z.saveGridConfig(t,this.configName,this.resourceID).then((t=>{this.configChange.emit(t),y.info(this.getMessage("snkGridConfig.info.successfullyConfigSaved"),{iconName:"check"})}))}reOrderPriorityColumns(t,i){let s=[];s=t.filter((t=>t.sort&&!0!==t.hidden)).map((t=>({name:t.name,orderIndex:0})));let e=0,n=[];return i.forEach((t=>{let i=s.find((i=>i.name===t.id));i&&(i.orderIndex=e,n.push(i),e++)})),n.length>0&&(s=n),s}save(){var t;let i;i=this.config?this.config:this.createConfigFromState(this.columns);let s,e=[];(null===(t=this._orderPriorityList)||void 0===t?void 0:t.length)>0&&(s=this.reOrderPriorityColumns(this.columns,this._orderPriorityList)),this.columns.forEach((t=>{let n=i.columns.find((i=>t.name===i.name));!0===t.hidden&&n||(n||!1!==t.hidden||(n={name:t.name,orderIndex:0}),n&&(t.sort?(n.ascending=t.sort.toUpperCase()===_.asc.value,s?function(t,i){if(s){let e=s.find((i=>i.name===t.name));e&&(i.orderIndex=e.orderIndex)}}(t,n):n.orderIndex=t.sortIndex):(delete n.ascending,n.orderIndex=0),n.configVersion=F.CURRENT_CONFIG_VERSION,e.push(n)))})),i.columns=e,this.saveGridConfigOnStorage(i)}createConfigFromState(t){let i={columns:[]};return t.forEach((t=>{if(!t.hidden){let s={name:t.name};t.width&&(s.width=t.width),t.sort?(s.ascending=t.sort.toUpperCase()===_.asc.value,s.orderIndex=t.sortIndex):s.orderIndex=0,s&&i.columns.push(s)}})),i}closeConfig(){if(this._dataChanged){let t={canClose:!1,labelCancel:this.getMessage("snkGridConfig.confirm.cancel"),labelConfirm:this.getMessage("snkGridConfig.confirm.save"),btnConfirmDanger:!1};y.confirm(this.getMessage("snkGridConfig.confirm.alert"),this.getMessage("snkGridConfig.confirm.msgCancel"),null,C.WARN,t).then((t=>{t?this.finish():(this._dataChanged=!1,this._orderPriorityList=[],this.configCancel.emit(),this._componenteInternalKey=Date.now())}))}else this.configCancel.emit()}handleColumnListChange(t){var i;if(t.detail){let s=null===(i=t.detail.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))))||void 0===i?void 0:i.items;s&&(this._dataChanged=!0,this._orderListItems=s)}}handleOrderListChange(t){if(t.detail){let i=t.detail;i&&(this._dataChanged=!0,this._orderPriorityList=i)}}componentWillRender(){var t;(null===(t=this.columns)||void 0===t?void 0:t.length)>0&&this.createColumnList()}componentDidLoad(){f.addIDInfo(this._element)}handleRightListChange(t){const i=this._columListItems.find((t=>t.group===this.getMessage("snkGridConfig.group.visible")));i&&i.items!=t&&(i.items=t,this._dataChanged=!0)}getListSlots(){return{RIGHT_LIST:{itemRightSlotBuilder:t=>this.buildOrderListSlot(t)}}}renderResetConfigBtn(){if(this.resourceID)return i("ez-button",{class:"padding-right--medium",label:this.getMessage("snkGridConfig.reset"),onClick:()=>this.setDefaultConfig()})}async setDefaultConfig(){var t;if(!this.resourceID)return;this._dataChanged=!0,this._orderPriorityList=[];const i=await z.getDefaultGridConfig(this.resourceID),s=null!==(t=null==i?void 0:i.columns.map((t=>t.name)))&&void 0!==t?t:[],e=0===s.length,n=this.buildVisibleGroup(),o=this.buildHiddenGroup(),r=new Map;if((e?this.originalColumns:this.columns).forEach((t=>{const i=this.buildListItemFromColumn(t);e||s.includes(t.name)?(i.width=this.getDefaultWidthBasedOnMetadata(t.name),r.set(t.name,i)):o.items.push(i)})),e){const t=[];r.forEach((i=>t.push(i))),n.items=t}else n.items=s.map((t=>r.get(t))).filter((t=>t));this._columListItems=[n,o],this._visibleList=n.items,this._hiddenList=o.items,this.config&&(this.config.columns=this.transformListToConfig(n.items)),this.updateColumns(),this.createOrderList()}transformListToConfig(t){return t.map(((t,i)=>({name:t.id,hidden:!1,orderIndex:Number(t.sort)||i,width:t.width})))}getDefaultWidthBasedOnMetadata(t){var i,s;if(!this.metadata)return;const e=null===(s=null===(i=this.metadata)||void 0===i?void 0:i.fields)||void 0===s?void 0:s.find((i=>i.name===t));return S[null==e?void 0:e.userInterface]||S[p.SHORTTEXT]}buildListItemFromColumn(t){var i;return{label:t.label,selected:!1,sort:null!==(i=null==t?void 0:t.sort)&&void 0!==i?i:_.asc.value,id:t.name,width:t.width}}render(){return i(s,null,i("div",{class:"grid-config__header"},i("div",{class:"title-container"},i("div",{class:"ez-margin-bottom--medium"},i("label",{class:"title"},this.getMessage("snkGridConfig.gridConfiguration")),i("label",{class:"subtitle"},this.getMessage("snkGridConfig.columnVisibilityOrder"))),i("div",{class:"button-close"},i("ez-button",{mode:"icon",iconName:"close",size:"medium",class:"ez-button--tertiary",onClick:()=>this.closeConfig()})))),i("div",{class:"grid-config__body"},i("ez-collapsible-box",{id:"group-select-columns",label:this.getMessage("snkGridConfig.columnsSelection"),"header-size":"medium",key:"key_group-select-columns",value:this._collapsibleBoxListSelect,onEzChange:({detail:t})=>this._collapsibleBoxListOrder=!t},i("div",{class:"grid-config__main"},i("ez-double-list",{leftList:this._hiddenList,leftTitle:this.getMessage("snkGridConfig.availableColumns"),rightList:this._visibleList,rightTitle:this.getMessage("snkGridConfig.selectedColumns"),onEzRightListChanged:({detail:t})=>this.handleRightListChange(t),emptyMessage:{LEFT_LIST:this.getMessage("snkGridConfig.emptyMensage.left"),RIGHT_LIST:this.getMessage("snkGridConfig.emptyMensage.right")},entityLabel:"coluna",entityLabelPlural:"colunas"}))),i("ez-collapsible-box",{id:"ID_group-order-columns",label:this.getMessage("snkGridConfig.dataOrdering"),"header-size":"medium",key:"KEY_group-order-columns",value:this._collapsibleBoxListOrder,onEzChange:({detail:t})=>this._collapsibleBoxListSelect=!t},i("div",{class:"grid-config__main"},i("ez-double-list",{rightList:this._orderListItems,rightTitle:this.getMessage("snkGridConfig.selectedColumns"),useOnlyRightList:!0,slotsListBuilder:this.getListSlots(),onEzRightListChanged:t=>this.handleOrderListChange(t),emptyMessage:{RIGHT_LIST:this.getMessage("snkGridConfig.emptyMensage.right")},entityLabel:"coluna",entityLabelPlural:"colunas"})))),i("div",{class:"grid-config__footer"},this.renderResetConfigBtn(),i("ez-button",{class:"padding-right--medium",label:this.getMessage("snkGridConfig.cancel"),onClick:()=>this.closeConfig()}),i("ez-button",{label:this.getMessage("snkGridConfig.complete"),class:"ez-button--primary",onClick:()=>this.finish()})))}static get assetsDirs(){return["../assets"]}get _element(){return e(this)}};F.CURRENT_CONFIG_VERSION=1,F.style='.sc-snk-grid-config-h{--snk-grid-config__footer--padding-top:var(--space--medium, 12px);--snk-grid-config__main--padding-right:var(--space--medium, 12px);--snk-grid-config__tabselector-container--padding:var(--space--medium, 12px);--snk-grid-config__button-close--padding-left:var(--space--medium, 12px);--snk-grid-config__title--color:var(--title--primary, #2B3A54);--snk-grid-config__title--font-family:var(--font-pattern, "Roboto");--snk-grid-config__title--font-size:var(--title--large, 20px);--snk-grid-config__title--font-weight:var(--text-weight--extra-large, 700);--snk-grid-config__subtitle--font-family:var(--font-pattern, "Roboto");--snk-grid-config__subtitle--font-size:var(--text--medium, 14px);--snk-grid-config__group--font-family:var(--font-pattern, "Roboto");--snk-grid-config__group--font-size:var(--text--medium, 14px);--snk-grid-config__group--font-weight:var(--text-weight--large, 600);--snk-grid-config__group--padding-bottom:var(--space-small, 6px);--snk-grid-config__scrollbar--color-default:var(--scrollbar--default, #626e82);--snk-grid-config__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--snk-grid-config__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--snk-grid-config__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--snk-grid-config__scrollbar--border-radius:var(--border--radius-small, 6px);--snk-grid-config__scrollbar--width:var(--space--small, 6px);display:flex;flex-direction:column;max-height:100%;width:100%}.grid-config__body.sc-snk-grid-config{overflow:auto}.padding-right--medium.sc-snk-grid-config{padding-right:var(--space--medium)}ez-list.sc-snk-grid-config{height:100%}.height-calc.sc-snk-grid-config{max-height:calc(100% - 24px)}.grid-config__footer.sc-snk-grid-config{display:flex;justify-content:flex-end;width:100%;padding-top:var(--snk-grid-config__footer--padding-top)}.hidden.sc-snk-grid-config{display:none}.tabselector-container.sc-snk-grid-config{padding:var(--snk-grid-config__tabselector-container--padding) 0}.button-close.sc-snk-grid-config{padding-left:var(--snk-grid-config__button-close--padding-left)}.title-container.sc-snk-grid-config{display:flex;justify-content:space-between;align-items:center;width:100%}.title.sc-snk-grid-config{display:flex;margin:0;line-height:normal;letter-spacing:0em;text-align:left;color:var(--snk-grid-config__title--color);font-size:var(--snk-grid-config__title--font-size);font-family:var(--snk-grid-config__title--font-family);font-weight:var(--snk-grid-config__title--font-weight)}.subtitle.sc-snk-grid-config{color:var(--text--primary);font-size:var(--snk-grid-config__subtitle--font-size);font-family:var(--snk-grid-config__subtitle--font-family)}.grid-config__main.sc-snk-grid-config{overflow-y:auto;scrollbar-width:thin;width:100%;padding-bottom:20px;scrollbar-color:var(--snk-grid-config__scrollbar--color-clicked) var(--snk-grid-config__scrollbar--color-background)}.group-name.sc-snk-grid-config{font-family:var(--snk-grid-config__group--font-family);font-size:var(--snk-grid-config__group--font-size);font-weight:var(--snk-grid-config__group--font-weight);padding-bottom:var(--snk-grid-config__group--padding-bottom)}';const R=class{constructor(i){t(this,i),this.handleNumberingConfigChanged=t=>{const i=t.detail;i&&this.applyConfiguration(i)},this.autoNumbering=!1,this.initialNumber=void 0,this.messagesBuilder=void 0,this.entityName=void 0,this.resourceID=void 0}async save(){try{if(this._savedConfig&&this._savedConfig.isAutoNumbering===this.autoNumbering&&this._savedConfig.initialNumber===this.initialNumber)return!0;const t={entityName:this.entityName,isAutoNum:this.autoNumbering,numInicial:this.initialNumber};return await this._servicesNumberingConfig.saveConfig(t),this._savedConfig={isAutoNumbering:this.autoNumbering,initialNumber:this.initialNumber},this._snkCrud&&this._snkCrud.updateNumberingConfig&&await this._snkCrud.updateNumberingConfig(this._savedConfig),!0}catch(t){return console.error("Error saving numbering config:",t),!1}}async componentWillLoad(){const t=o.getContextValue("__SNK__APPLICATION__");this.findParentSnkCrud(),this._servicesNumberingConfig=new A(t,this.resourceID),this.entityName&&await this.loadNumberingConfiguration()}findParentSnkCrud(){const t=this._element.closest("snk-crud");t&&(this._snkCrud=t,this._snkCrud.addEventListener("numberingConfigChanged",this.handleNumberingConfigChanged.bind(this)))}async loadNumberingConfiguration(){try{const t=await this.tryGetConfigFromSnkCrud();if(t)return void this.applyConfiguration(t);const i=await this.loadConfigFromService();this.applyConfiguration(i),await this.updateSnkCrudConfig(i)}catch(t){console.error("Error loading numbering config:",t),this.setDefaultConfiguration()}}async tryGetConfigFromSnkCrud(){if(!this._snkCrud)return null;try{const t=await this._snkCrud.getNumberingConfig();if(t)return t}catch(t){console.log("snk-crud não tem configuração ainda, carregando diretamente...")}return null}async loadConfigFromService(){return await this._servicesNumberingConfig.getConfig(this.entityName)}applyConfiguration(t){this._savedConfig=t,this.autoNumbering=t.isAutoNumbering,this.initialNumber=t.initialNumber}async updateSnkCrudConfig(t){if(this._snkCrud)try{await this._snkCrud.updateNumberingConfig(t)}catch(t){console.warn("Erro ao atualizar configuração no snk-crud:",t)}}setDefaultConfiguration(){this.autoNumbering=!1,this.initialNumber=null}getMessage(t,i){var s;return null===(s=this.messagesBuilder)||void 0===s?void 0:s.getMessage(t,i)}disconnectedCallback(){this._snkCrud&&this._snkCrud.removeEventListener("numberingConfigChanged",this.handleNumberingConfigChanged)}render(){return i("div",{class:"ez-flex ez-flex--column"},i("ez-check",{mode:"SWITCH",label:this.getMessage("snkNumberingConfig.labelAutoNumbering"),class:"ez-margin-bottom--medium",onEzChange:({detail:t})=>this.autoNumbering=t,value:this.autoNumbering}),i("ez-number-input",{label:this.getMessage("snkNumberingConfig.labelInitialNumber"),onEzChange:({detail:t})=>this.initialNumber=t,value:this.initialNumber,precision:0,prettyPrecision:0,allowNegative:!1,enabled:this.autoNumbering}))}get _element(){return e(this)}};R.style=".sc-snk-numbering-config-h{display:block}";const M=class{constructor(i){t(this,i),this.ezChange=n(this,"ezChange",7),this.selectedOption=_.none,this.preventAutoFocus=!1}render(){return i("ez-combo-box",{class:"grid-config-combo ez-input--inverted",label:"",suppressSearch:!0,value:this.selectedOption,enabled:!0,canShowError:!1,suppressEmptyOption:!0,preventAutoFocus:this.preventAutoFocus},Object.keys(_).map((t=>i("option",{value:_[t].value},_[t].label))))}static get assetsDirs(){return["../assets"]}};M.style="ez-combo-box{width:100px;--ez-text-input__margin-bottom:0px}.grid-config-combo{--ez-text-input--height:28px;--ez-text-input__input--background-color:#fff;--ez-text-input__input--border-color:#dce0e8}";const H=class{constructor(i){t(this,i),this.snkConfigSaved=n(this,"snkConfigSaved",7),this._formConfigFetcher=new b,this.fieldsToSave=[],this.dataUnit=void 0,this.configName=void 0,this.messagesBuilder=void 0,this.avaliableFields=[],this.selectedFields=[]}async show(){var t;await(null===(t=this.ezDoubleListRef)||void 0===t?void 0:t.resetSelectedLists()),await this.initializeFormConfig(),this.ezPopupRef.opened=!0}async initializeFormConfig(){if(!this.configName)return;const t=this.getAllVisibleFieldsFromDataUnit(),i=await this.getConfig();if(0===i.length)return this.avaliableFields=[],this.selectedFields=[...t],void(this.fieldsToSave=[...this.selectedFields]);const s=this.sortDisplayedFields(i,t),e=t.filter((t=>!i.includes(t.id)));this.avaliableFields=[...e],this.selectedFields=[...s],this.fieldsToSave=[...this.selectedFields]}async getConfig(){const t=await this._formConfigFetcher.fetchSimpleFormConfig(this.configName);return[...this.removeDuplicates(t)]}getMessage(t,i){var s;return null===(s=this.messagesBuilder)||void 0===s?void 0:s.getMessage(t,i)}removeDuplicates(t){return t.filter(((i,s)=>t.indexOf(i)===s))}sortDisplayedFields(t,i){const s=[];return t.forEach((t=>{const e=i.find((i=>i.id===t));e&&s.push(e)})),s}getAllVisibleFieldsFromDataUnit(){var t,i,s;return(null!==(s=null===(i=null===(t=this.dataUnit)||void 0===t?void 0:t.metadata)||void 0===i?void 0:i.fields)&&void 0!==s?s:[]).filter((t=>t.visible)).map((t=>({id:t.name,label:t.label})))}close(){this.ezPopupRef.opened=!1}async handleResetConfigs(){await this._formConfigFetcher.restoreFormConfig(this.configName),await this.initializeFormConfig(),await this.handleSave()}handleCancel(){this.close()}async handleSave(){const t=this.fieldsToSave.map((t=>t.id));await this._formConfigFetcher.saveSimpleFormConfig(this.configName,t),this.close(),this.snkConfigSaved.emit()}render(){return i("ez-popup",{ref:t=>this.ezPopupRef=t,heightMode:"auto",size:"medium",ezTitle:this.getMessage("snkSimpleFormConfig.popup.title")},i("div",{class:"config-container"},i("div",{class:"config-lists"},i("ez-double-list",{ref:t=>this.ezDoubleListRef=t,leftList:this.avaliableFields,leftTitle:this.getMessage("snkSimpleFormConfig.lists.availableFields"),rightList:this.selectedFields,rightTitle:this.getMessage("snkSimpleFormConfig.lists.selectedFields"),onEzRightListChanged:({detail:t})=>this.fieldsToSave=[...t],entityLabel:this.getMessage("snkSimpleFormConfig.lists.entityLabel"),entityLabelPlural:this.getMessage("snkSimpleFormConfig.lists.entityLabelPlural")})),i("div",{class:"config-actions"},i("ez-button",{label:this.getMessage("snkSimpleFormConfig.buttons.restore"),onClick:this.handleResetConfigs.bind(this),size:"small"}),i("ez-button",{label:this.getMessage("snkSimpleFormConfig.buttons.cancel"),onClick:this.handleCancel.bind(this),size:"small"}),i("ez-button",{label:this.getMessage("snkSimpleFormConfig.buttons.save"),class:"ez-button--primary",onClick:this.handleSave.bind(this),size:"small"}))))}};H.style=":host{display:block}.config-container{display:flex;flex-direction:column;align-items:center;justify-content:space-between}.config-lists{width:100%;margin-bottom:12px}.config-actions{display:flex;flex-direction:row;justify-content:flex-end;width:100%;gap:12px}";const K=class{constructor(i){t(this,i)}render(){return i(s,null,i("ez-skeleton",{variant:"circle",count:12}),i("ez-skeleton",{width:"100px"}))}};K.style=".sc-snk-taskbar-skeleton-h{display:flex;align-items:center;height:100%;padding:0 var(--space--8, 8px)}ez-skeleton.sc-snk-taskbar-skeleton{--skeleton-width:42px;--skeleton-height:42px;--skeleton-margin-left:var(--space--4, 4px)}";const $=class{constructor(i){t(this,i),this.mode=x.SIDE_BY_SIDE}renderCascadeLayout(){return i("div",{class:"svg-container__collumn"},[...Array(3)].map((()=>i("div",{class:"svg-container__section"},i("div",{class:"svg-container__line svg-container__line--short"}),i("div",{class:"svg-container__line svg-container__line--long"})))))}renderSideBySideLayout(){return i("div",{class:"svg-container__inline"},[...Array(2)].map((()=>this.renderCascadeLayout())))}render(){return i("div",{class:"svg-container ez-margin-left--small"},i("div",{class:"svg-container__background"},i("div",{class:"svg-container__header"},i("div",{class:"svg-container__circle svg-container__circle--red"}),i("div",{class:"svg-container__circle svg-container__circle--yellow"}),i("div",{class:"svg-container__circle svg-container__circle--green"})),this.mode===x.CASCADE||this.mode===x.CLASSIC_CASCADE?this.renderCascadeLayout():this.renderSideBySideLayout()))}};$.style=".sc-snk-view-representation-h{display:block}.svg-container.sc-snk-view-representation{display:flex;width:185px;height:125px;border-radius:8px;background-color:#f7f7f7;padding:10px 12px;box-sizing:border-box;position:relative}.svg-container__background.sc-snk-view-representation{display:flex;flex-direction:column;width:100%}.svg-container__header.sc-snk-view-representation{display:flex;gap:2px;margin-bottom:12px}.svg-container__circle.sc-snk-view-representation{width:9px;height:9px;border-radius:50%}.svg-container__circle--red.sc-snk-view-representation{background-color:#ed7678}.svg-container__circle--yellow.sc-snk-view-representation{background-color:#eddb76}.svg-container__circle--green.sc-snk-view-representation{background-color:#7ad08e}.svg-container__section.sc-snk-view-representation{width:100%}.svg-container__collumn.sc-snk-view-representation{width:100%;display:flex;flex-direction:column}.svg-container__inline.sc-snk-view-representation{display:flex;flex-direction:row;gap:6px}.svg-container__line.sc-snk-view-representation{height:13px;border-radius:4px;background-color:#d9d9d9;margin-bottom:4px}.svg-container__line--short.sc-snk-view-representation{width:39.68px;height:7px;border-radius:3.5px}.svg-container__line--long.sc-snk-view-representation{width:100%}";const V=class{constructor(i){t(this,i),this.taskbarActionSelected=n(this,"taskbarActionSelected",7),this.taskbarActionsOpened=n(this,"taskbarActionsOpened",7),this.taskbarActionsButtonDisconnected=n(this,"taskbarActionsButtonDisconnected",7),this._showDropdown=!1,this._openToLeft=!1,this.title=void 0,this.enabled=void 0,this.actions=void 0,this.size="medium"}async handleKeyDown(t){"Escape"!==t.key&&"Esc"!==t.key||await this.hideActions()}async handleClose(){await this.hideActions()}async showActions(){this.checkDropdownPosition(),this._showDropdown=!0,requestAnimationFrame((()=>{this._element.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}))}async hideActions(){this._showDropdown=!1}async isOpened(){return this._showDropdown}controlDropdown(){this._showDropdown||this.checkDropdownPosition(),this._showDropdown=!this._showDropdown}checkDropdownPosition(){const t=this._element.getBoundingClientRect(),i=window.innerWidth;this._openToLeft=i-t.right<150}loadItems(){return this.actions.filter((t=>void 0!==t)).map((t=>{var i;return{id:t.value,label:t.label,value:t.value,type:null!==(i=t.type)&&void 0!==i?i:"item",children:t.children,iconName:t.iconName,subAction:t.subAction,group:t.group,disableCloseOnSelect:t.disableCloseOnSelect}}))}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this.actions)||void 0===t?void 0:t.length)>0}onSelectAction(t){const i=this.actions.map((t=>Object.assign(Object.assign({},t),{id:t.value}))),s=this.getSelectedAction(t.id,i);this.taskbarActionSelected.emit(s),s.disableCloseOnSelect||(this._showDropdown=!1)}getSelectedAction(t,i){let s=null;for(const e of i){if(e.id===t){s=e;break}if((null==e?void 0:e.children)&&(s=this.getSelectedAction(t,e.children),s))break}return s}dropdownItemBuilder(t,s){const e=this.actions.find((i=>i.value===t.id));if(!e||!e.itemBuilder)return;const n=e.itemBuilder(this._element,e);return"string"==typeof n?i("div",{innerHTML:n}):n}initializeEagerItems(){var t;null===(t=this.actions)||void 0===t||t.forEach((t=>{var i;t&&t.eagerInitialize&&t.itemBuilder&&(null===(i=t.itemBuilder)||void 0===i||i.call(t,this._element,t))}))}componentDidLoad(){this.initializeEagerItems()}componentDidRender(){this._showDropdown&&this.taskbarActionsOpened.emit(this._element)}disconnectedCallback(){this.taskbarActionsButtonDisconnected.emit()}render(){return i(s,null,i("div",{class:(this.canShowDropdown()?" ez-elevation--16":"")+" ez-dropdown-container"},i("ez-tooltip",{message:this.title},i("ez-button",{mode:"icon",iconName:"dots-vertical",isDisabled:!this.enabled,onClick:()=>this.controlDropdown(),size:this.size})),this.canShowDropdown()&&i("ez-dropdown",{class:{"ez-dropdown--sticky":!0,"ez-dropdown--open-left":this._openToLeft},items:this.loadItems(),onEzClick:t=>this.onSelectAction(t.detail),onEzOutsideClick:()=>this._showDropdown=!1,itemBuilder:(t,i)=>this.dropdownItemBuilder(t,i)})))}get _element(){return e(this)}};V.style=".sc-taskbar-actions-button-h{--ez-dropdown--min-width:150px;display:flex;width:fit-content;height:fit-content}.ez-dropdown-container.sc-taskbar-actions-button{position:relative;display:inline-block}.ez-dropdown--sticky.sc-taskbar-actions-button{position:absolute;display:block;min-width:var(--ez-dropdown--min-width);top:100%;left:0;margin-top:4px}.ez-dropdown--open-left.sc-taskbar-actions-button{left:auto;right:0}";const q=class{constructor(i){t(this,i),this._showDropdown=!1,this.iconName=void 0,this.action=void 0,this.name=void 0,this.className=void 0,this.dataElementId=void 0,this.title=void 0,this.enabled=void 0,this.actions=void 0,this.size="medium"}initializeEagerItems(){var t;null===(t=this.actions)||void 0===t||t.forEach((t=>{var i;t&&t.eagerInitialize&&t.itemBuilder&&(null===(i=t.itemBuilder)||void 0===i||i.call(t,this._splitButtonRef,t))}))}componentDidLoad(){this.initializeEagerItems()}dropdownItemBuilder(t,s){const e=this.actions.find((i=>i.value===t.id));if(!e||!e.itemBuilder)return;const n=e.itemBuilder(this._splitButtonRef,e);return"string"==typeof n?i("div",{innerHTML:n}):n}loadItems(){return this.actions.filter((t=>void 0!==t)).map((t=>{var i;return{id:t.value,label:t.label,value:t.value,type:null!==(i=t.type)&&void 0!==i?i:"item",children:t.children,iconName:t.iconName,subAction:t.subAction,group:t.group,disableCloseOnSelect:t.disableCloseOnSelect}}))}ajustSizeButton(){return this.size&&"small"!==this.size?"large":"medium"}render(){return i(s,null,i("ez-split-button",{ref:t=>this._splitButtonRef=t,key:this.dataElementId,class:`${this.className} "ez-split-button--tertiary ez-padding--medium"`,items:this.loadItems(),mode:"icon-only",size:this.ajustSizeButton(),leftIconName:this.iconName,isDisabled:!this.enabled,show:this._showDropdown,onButtonClick:()=>this.action(this.name),itemBuilder:(t,i)=>this.dropdownItemBuilder(t,i),leftTitle:this.title}))}};q.style="";export{G as snk_actions_button,F as snk_grid_config,R as snk_numbering_config,M as snk_select_box,H as snk_simple_form_config,K as snk_taskbar_skeleton,$ as snk_view_representation,V as taskbar_actions_button,q as taskbar_split_button}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,h as e,f as i,g as s}from"./p-2c9d0870.js";import{ApplicationContext as o,ObjectUtils as r,UserInterface as n,DataType as l,ElementIDUtils as a}from"@sankhyalabs/core";import{ApplicationUtils as d,DialogType as h}from"@sankhyalabs/ezui/dist/collection/utils";import{I as c}from"./p-8f3f2306.js";import{D as u,a as p,b as m}from"./p-0f3698af.js";import{R as v}from"./p-9019a32f.js";import{D as x}from"./p-10d883b0.js";import{S as g}from"./p-e91bd00e.js";import"./p-3190ac29.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-c1e168a2.js";import"./p-ff1990ad.js";import"./p-d7657667.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/DataType";import"./p-7dd49d15.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class f{constructor(t,e){this._selectedNumber=0,this._getMessage=t,this._selectedNumber=e}setExportOption(t,e){const i=this.getExportGroupName();t===u.EXPORT_TO_PDF&&e.push(this.getExportToPDF(i)),t===u.EXPORT_TO_XLS&&e.push(this.getExportToXLS(i)),this.setExportCurrentPage(t,e),this._selectedNumber>0&&this.setExportAllRecords(t,e),this.setExportByEmail(t,e)}setExportCurrentPage(t,e){var i;const s=[u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS];if(t===u.EXPORT_CURRENT_PAGE&&e.push(this.getCurrentPage()),s.includes(t)){let s=e.find((t=>t.id===u.EXPORT_CURRENT_PAGE));null==s&&(e.push(this.getCurrentPage()),s=e.find((t=>t.id===u.EXPORT_CURRENT_PAGE))),(null===(i=null==s?void 0:s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===u.EXPORT_PAGE_TO_PDF&&s.children.push(this.getExportPageToPDF()),t===u.EXPORT_PAGE_TO_XLS&&s.children.push(this.getExportPageToXLS())}}setExportAllRecords(t,e){var i;const s=[u.EXPORT_ALL_RECORDS_TO_PDF,u.EXPORT_ALL_RECORDS_TO_XLS];if(t===u.EXPORT_ALL_RECORDS&&e.push(this.getAllRecords()),s.includes(t)){let s=e.find((t=>t.id===u.EXPORT_ALL_RECORDS));null==s&&(e.push(this.getAllRecords()),s=e.find((t=>t.id===u.EXPORT_ALL_RECORDS))),(null===(i=s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===u.EXPORT_ALL_RECORDS_TO_PDF&&s.children.push(this.getExportAllRecordsToPDF()),t===u.EXPORT_ALL_RECORDS_TO_XLS&&s.children.push(this.getExportAllRecordsToXLS())}}setExportByEmail(t,e){t===u.EXPORT_BY_EMAIL&&e.push(this.getExportByEmail())}getExportToPDF(t){return{id:u.EXPORT_TO_PDF,label:"PDF (.pdf)",group:t}}getExportToXLS(t){return{id:u.EXPORT_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xls)`,group:t}}getCurrentPage(){return{id:u.EXPORT_CURRENT_PAGE,label:this._getMessage("snkDataExporter.label.currentPage"),group:this._getMessage("snkDataExporter.group.custom")}}getAllRecords(){return{id:u.EXPORT_ALL_RECORDS,label:this._getMessage("snkDataExporter.label.allRecords"),group:this._getMessage("snkDataExporter.group.custom")}}getExportPageToPDF(){return{id:u.EXPORT_PAGE_TO_PDF,label:"PDF (.pdf)"}}getExportPageToXLS(){return{id:u.EXPORT_PAGE_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xls)`}}getExportAllRecordsToPDF(){return{id:u.EXPORT_ALL_RECORDS_TO_PDF,label:"PDF (.pdf)"}}getExportAllRecordsToXLS(){return{id:u.EXPORT_ALL_RECORDS_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`}}getExportByEmail(){return{id:u.EXPORT_BY_EMAIL,label:`${this._getMessage("snkDataExporter.label.sendByEmail")}...`}}getExportGroupName(){return 1===this._selectedNumber?this._getMessage("snkDataExporter.group.export.selectedLine"):this._selectedNumber>1?this._getMessage("snkDataExporter.group.export.multiSelected").replace("{0}",this._selectedNumber.toString()):this._getMessage("snkDataExporter.group.export.default")}}function b(t){const e=[];let i=0;for(const s of t){if(i+=s.width,i>=860)break;e.push(s)}return e}function E(t){return Object.keys(u).find((e=>u[e]===t))}class w{constructor(t){this._provider=t}async getParsedColumns(){return b(await this._provider.getColumnsMetadata())}async getColumns(t){var e;return(null===(e=E(null==t?void 0:t.exportOption))||void 0===e?void 0:e.includes("PDF"))?await this.getParsedColumns():await this._provider.getColumnsMetadata()}async getParams(t){var e,i,s,o,r,n;const l=null===(i=(e=this._provider).getFilters)||void 0===i?void 0:i.call(e),a=await this.getColumns(t),d=null===(o=(s=this._provider).getOrders)||void 0===o?void 0:o.call(s),h=null===(n=(r=this._provider).getResourceURI)||void 0===n?void 0:n.call(r),c=this._provider.getSelectedIDs(),p=t.exportOption,m=[u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS];delete t.exportOption;let v=Object.assign({filters:l,columns:a,sort:d,resourceURI:h,selectedIDs:c.slice(0,this._provider.getExportLimit())},t);if(m.includes(p)||"page"==t.type){const t=this._provider.getOffset(),e=this._provider.getPageSize();v=Object.assign(Object.assign({},v),{offset:t,limit:e,selectedIDs:[]})}else"all"==t.type&&(v=Object.assign(Object.assign({},v),{offset:0,limit:this._provider.getExportLimit(),selectedIDs:[]}));return Promise.resolve(v)}async executeExport(t){const e=await this.getParams(t),{methodName:i}=e,s=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(e,["methodName"]),n=`${o.getContextValue("__SNK__APPLICATION__").getModuleName()}@DataExporterSPBean.${i}`,l={serviceName:n,requestBody:s};return new Promise(((t,e)=>{x.get().callServiceBroker(n,r.objectToString(l)).then((e=>t(this.getFormatResponse(e)))).catch((t=>e(t)))}))}getFormatResponse(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return r.stringToObject(i)}}class D{constructor(t){this._provider=t}async getParsedColumns(){return b(await this._provider.getColumnsMetadata())}async executeExport(t){var e;const{methodName:i,gridTitle:s}=t,o=await this._provider.getRecords(t.type),r=(null===(e=E(null==t?void 0:t.exportOption))||void 0===e?void 0:e.includes("PDF"))?await this.getParsedColumns():await this._provider.getColumnsMetadata(),[n,l]=this.getExecutor(i),a={serviceName:n,requestBody:{grid:{gridTitle:s,columns:this.buildColumnsObject(r),rows:this.buildRowsObject(r,o),customOptions:{xlsxExtension:!1}}}};return new Promise(((t,e)=>{x.get().callServiceBroker(n,a).then((e=>t(l(e)))).catch((t=>e(t)))}))}getExecutor(t){return"exportToPDF"===t?["GridPDFBuilderSP.buildPDFFromJson",t=>({fileSessionKey:t.chavePDF.valor,canPrint:"S"===t.permiteImprimir.valor,canExport:"S"===t.permiteExportar.valor,canSendEmail:"S"===t.canSendEmail.valor,useAppPrint:!0})]:["GridXLSBuilderSP.buildXLSFromJson",t=>({fileSessionKey:t.chaveXLS.valor,canPrint:!0,canExport:!0,canSendEmail:!0,useAppPrint:!1})]}buildColumnsObject(t){return{column:t.map(((t,e)=>{const{label:i,id:s,width:o,userInterface:r}=t;return Object.assign({index:e+1,id:s,label:i,width:o,presentationType:"P"},k[r]||{type:"S",align:"left"})}))}}buildRowsObject(t,e){return{row:e.map((e=>{const i={};return t.forEach(((t,s)=>i["c"+(s+1)]={$:this.formatValue(e,t)})),i}))}}formatValue(t,e){return null!=this._provider.formatValue?this._provider.formatValue(t,e):t[e.id]||""}}const k={[n.DATE]:{type:"D",align:"center"},[n.DATETIME]:{type:"H",align:"center"},[n.TIME]:{type:"I",align:"right"},[n.ELAPSEDTIME]:{type:"I",align:"right"},[n.DECIMALNUMBER]:{type:"F",align:"right"},[n.INTEGERNUMBER]:{type:"I",align:"right"},[n.SEARCH]:{type:"S",align:"right"}},y=class{constructor(e){t(this,e),this._selectedNumber=0,this._customPrefix="$custom$",this._releasedToExport=[u.EXPORT_TO_PDF,u.EXPORT_TO_XLS,u.EXPORT_BY_EMAIL,u.EXPORT_PDF_TO_EMAIL,u.EXPORT_XLS_TO_EMAIL,u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS,u.EXPORT_ALL_RECORDS_TO_PDF,u.EXPORT_ALL_RECORDS_TO_XLS],this._items=[],this._showDropdown=!1,this.provider=null,this.messagesBuilder=void 0,this.size="medium"}async exportByEmail(){const t=this._selectedNumber;this._snkEmailSender.open({type:t>0?"selection":"all",selectedRows:t,email:{attachments:[{name:this._appLabel}]},resolver:({type:t,format:e,email:{to:i,subject:s,message:o}})=>{var r;const n=null!==(r=m[null==e?void 0:e.toUpperCase()])&&void 0!==r?r:m.PDF;this.resolveExporter({type:t,methodName:n,to:i,subject:s,message:o,fileName:this._appLabel,gridTitle:this._appLabel},(()=>{this._snkEmailSender.close(),d.info(this.getMessage("snkDataExporter.message.emailSuccess"),{iconName:"check"})}))}})}getMessage(t,e){if(null==this.messagesBuilder){const t=g.getNearestInstance(this._element);t&&(this.messagesBuilder=t.messagesBuilder)}return this.messagesBuilder.getMessage(t,e)}positionDropdown(){var t;const e=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();null!=e&&null!=this._dropdownParent&&(this._dropdownParent.style.top=e.y+e.height+5+"px",this._dropdownParent.style.left=e.x+"px")}closeDropdown(t){const e=null==t?void 0:t.target;null!=e&&(e.closest(".snk-data-exporter")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}controlDropdown(){this._showDropdown=!this._showDropdown}async resolveExporter(t,e){null!=this.provider&&null!=t&&null!=e&&this.getExporterStrategy().executeExport(t).then((t=>e(t))).catch((t=>{console.error(t);let{title:e,message:i,statusMessage:s}=t||{};d.error(e||this.getMessage("snkDataExporter.message.exportError"),s||i||this.getMessage("snkDataExporter.message.unknownFailure"))}))}getExporterStrategy(){return null==this.provider.getRecords?new w(this.provider):new D(this.provider)}getOptionKey(t){return Object.keys(u).find((e=>u[e]===t))}getExportType(t){return t===u.EXPORT_ALL_RECORDS_TO_PDF||t===u.EXPORT_ALL_RECORDS_TO_XLS?c.ALL:t===u.EXPORT_PAGE_TO_PDF||t===u.EXPORT_PAGE_TO_XLS?c.PAGE:c.SELECTION}async dispatchExporter(t){var e,i,s;const r=this.getOptionKey(t),n=null!==(e=p[r])&&void 0!==e?e:p.EXPORT_TO_PDF,l={methodName:u[`EXPORT_TO_${n}`],fileName:this._appLabel,gridTitle:this._appLabel,exportOption:t,limit:null===(s=null===(i=this.provider)||void 0===i?void 0:i.getExportLimit)||void 0===s?void 0:s.call(i),type:this.getExportType(t)};await this.resolveExporter(l,(t=>{t.canExport||n===p.EXPORT_TO_PDF?function({fileSessionKey:t,isDownload:e}){const i=o.getContextValue("__SNK__APPLICATION__");window.open(`${window.location.protocol}//${window.location.hostname}:${window.location.port}/mge/visualizadorArquivos.mge?chaveArquivo=${t}${e?"&download=S":""}`),d.info(function(t){var e;return null===(e=null==t?void 0:t.messagesBuilder)||void 0===e?void 0:e.getMessage("fileViewer.message.exportSuccess",void 0)}(i),{iconName:"check"})}(Object.assign(Object.assign({},t),{fileType:n})):d.error(this.getMessage("snkDataExporter.title.permission"),this.getMessage("snkDataExporter.message.exportPermission"))}))}async processExporter(t){var e,i,s,o,r,n,l;const a=null==t?void 0:t.detail,c=[u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS],p=null===(e=null==a?void 0:a.id)||void 0===e?void 0:e.includes(this._customPrefix);if((null==a?void 0:a.id)===u.EXPORT_CURRENT_PAGE)return;const m=null===(i=this.provider)||void 0===i?void 0:i.getSelectedIDs(),v=null===(s=this.provider)||void 0===s?void 0:s.getTotalRecords(),x=null===(r=null===(o=this.provider)||void 0===o?void 0:o.getPageSize)||void 0===r?void 0:r.call(o),g=null===(l=null===(n=this.provider)||void 0===n?void 0:n.getExportLimit)||void 0===l?void 0:l.call(n);let f=!1;if(c.includes(null==a?void 0:a.id)&&x<=g||p?f=!1:(null==m?void 0:m.length)?f=m.length>g:v>g&&(f=!0),f){const t=g.toLocaleString("pt-BR",{minimumFractionDigits:0}),e={title:this.getMessage("snkDataExporter.limitExceeded.title"),description:`\n ${this.getMessage("snkDataExporter.limitExceeded.description",{limit:t})}\n <br/><br/>\n <b>\n ${this.getMessage("snkDataExporter.limitExceeded.subdescription")}\n </b>\n `,cancel:this.getMessage("snkDataExporter.limitExceeded.cancel"),confirm:this.getMessage("snkDataExporter.limitExceeded.continue")};if(!await d.confirm(e.title,e.description,null,h.WARN,{labelCancel:e.cancel,labelConfirm:e.confirm}))return}if(p)return this.openPersonalizedReports(a.id),void(this._showDropdown=!1);this.getFilteredReleasedToExport().includes(null==a?void 0:a.id)&&(a.id===u.EXPORT_BY_EMAIL?this.exportByEmail():this.dispatchExporter(a.id),this._showDropdown=!1)}getFilteredReleasedToExport(){var t,e;if(null==this.provider)return this._releasedToExport;const i=null===(e=(t=this.provider).getHiddenOptions)||void 0===e?void 0:e.call(t);return null==i?this._releasedToExport:this._releasedToExport.filter((t=>!i.includes(t)))}loadItems(){const t=[];this.getFilteredReleasedToExport().forEach((e=>{var i;null===(i=this._itemBuilder)||void 0===i||i.setExportOption(e,t)})),this.loadPersonalizedItems(t)}async loadPersonalizedItems(t){var e,i;const s=null===(i=null===(e=this.provider)||void 0===e?void 0:e.getRecordID)||void 0===i?void 0:i.call(e);if(null==s)return void(this._items=t);const n=await function(t){const e=`${o.getContextValue("__SNK__APPLICATION__").getModuleName()}@DataExporterSPBean.getPersonalizedReports`,i={serviceName:e,requestBody:t};return new Promise(((t,s)=>x.get().callServiceBroker(e,r.objectToString(i)).then((e=>t(function(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return r.stringToObject(i)}(e)))).catch((t=>s(t)))))}({recordID:s});null==n||n.forEach((e=>{t.push({id:`${this._customPrefix}_${e.ID}`,label:e.label,group:this.getMessage("snkDataExporter.group.custom")})})),this._items=t}openPersonalizedReports(t){var e,i;const s=[],o=(null==t?void 0:t.replace(this._customPrefix,""))||"";null===(i=null===(e=this.provider)||void 0===e?void 0:e.getSelectedIDs)||void 0===i||i.call(e).forEach((({name:t,type:e,value:i},o)=>{const r={fields:[]};0===o&&(s[`PK_${t}`]={type:this.parseDataType(e),value:i},s.pks=[]);const n={nome:`PK_${t}`,tipo:this.parseDataType(e),valor:i};r.fields.push(n),s.pks.push(r)})),this._application.openApp(`${v}${o}`,s)}parseDataType(t){switch(t){case l.NUMBER:return"I";case l.DATE:return"D";default:return"S"}}loadDropdown(){var t;this._selectedNumber=(null===(t=this.provider)||void 0===t?void 0:t.getSelectedNumber())||0,this._itemBuilder=new f(this.getMessage.bind(this),this._selectedNumber),this.loadItems()}getElementID(t){return{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:a.getInternalIDInfo(t)}}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}componentWillLoad(){var t;this._application=o.getContextValue("__SNK__APPLICATION__"),null===(t=this._application)||void 0===t||t.getAppLabel().then((t=>this._appLabel=t)),this.setEvents()}componentDidLoad(){null!=this._element&&(a.addIDInfo(this._element),this.positionDropdown())}componentWillUpdate(){var t;this._showDropdown&&!(null===(t=this._items)||void 0===t?void 0:t.length)&&this.loadDropdown()}componentDidUpdate(){var t;this._showDropdown?this.positionDropdown():(null===(t=this._items)||void 0===t?void 0:t.length)>0&&(this._items=[])}render(){return e(i,null,e("div",{class:`snk-data-exporter\n ${this.canShowDropdown()?" ez-elevation--16":""}\n `},e("ez-tooltip",{message:this.getMessage("snkDataExporter.group.export.title")},e("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"file-download",mode:"icon",onClick:()=>this.controlDropdown(),size:this.size},this.getElementID("button")))),e("div",Object.assign({ref:t=>this._dropdownParent=t,class:`snk-data-exporter__dropdown\n ${this.canShowDropdown()?"snk-data-exporter__dropdown--show":""}\n `},this.getElementID("dropdown")),this.canShowDropdown()&&e("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.processExporter(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&e("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))),e("snk-exporter-email-sender",Object.assign({ref:t=>this._snkEmailSender=t,getMessage:(t,e)=>this.getMessage(t,e)},this.getElementID("snkExporterEmailSender"))))}get _element(){return s(this)}};y.style=".sc-snk-data-exporter-h{display:flex;width:fit-content;height:fit-content}.snk-data-exporter.sc-snk-data-exporter{display:flex;width:fit-content;height:fit-content}.snk-data-exporter__dropdown.sc-snk-data-exporter{display:none}.snk-data-exporter__dropdown--show.sc-snk-data-exporter{display:flex;flex-direction:column;position:fixed}.snk-data-exporter__dropdown.sc-snk-data-exporter>ez-dropdown.sc-snk-data-exporter{position:relative}";export{y as snk_data_exporter}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{S as snk_dynaform_guides_view}from"./p-ed1b1b14.js";import"./p-2c9d0870.js";import"@sankhyalabs/core";import"@sankhyalabs/ezui/dist/collection/utils";import"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-9019a32f.js";import"./p-13f91e7e.js";import"./p-d7657667.js";import"./p-10d883b0.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";import"./p-3072136e.js";import"./p-0f3698af.js";import"./p-a73b6b00.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,e as i,h as e,f as s,g as r,i as l}from"./p-2c9d0870.js";import{DataType as a,StringUtils as n,ObjectUtils as o,ErrorException as h,ApplicationContext as d,LockManager as c,LockManagerOperation as u,ElementIDUtils as m,DateUtils as f,MaskFormatter as p,KeyboardManager as v,FloatingManager as b,ArrayUtils as g}from"@sankhyalabs/core";import{EzScrollDirection as k}from"@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection";import{C as _}from"./p-13f91e7e.js";import{F,P as z,D as y}from"./p-58709cf9.js";import{toString as x}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{F as w}from"./p-ff1990ad.js";import{F as C}from"./p-fa80e546.js";import{ModalAction as I}from"@sankhyalabs/ezui/dist/collection/components/ez-modal-container";import{ApplicationUtils as $}from"@sankhyalabs/ezui/dist/collection/utils";import{F as N,A as L}from"./p-0dbd53d9.js";import{g as T}from"./p-76e66fd9.js";import"./p-d7657667.js";import"./p-10d883b0.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";function A(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()}const P=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.filterCustomConfig=void 0,this.filterCustomConfigInterceptor=void 0,this.hideFilterButton=!1,this.sizeChips="default",this.allowDefault=void 0,this.scrollerLocked=!1,this.showPersonalizedFilter=!1,this.personalizedFilterId=void 0,this.isFilterModalOpen=!1}observeFilterConfig(t,i){o.equals(t,i)||this.handleFilterConfigsChanged(i,t)}async reload(){this.loadConfigFromStorage(!0)}async getFilterItem(t){const i=this.filterConfig.find((i=>i.id===t));return Promise.resolve(o.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)}async getFilters(){return this.getFilter(null)}async showFilterModal(){this.isFilterModalOpen||(this.isFilterModalOpen=!0)}filterChangeListener(t){this.updateFilter(t.detail)}async emptySearchListener(t){await this.showPersonalizedFilterItem()}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||o.objectToString(i)!=o.objectToString(t),this._loadingPending=this._loadingPending||o.objectToString(i.value)!==o.objectToString(t.value),!this._loadingPending){const e=o.objectToString(i.groupedItems)!=o.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()}hasValidValue(t){var i,e;return null!=t.value&&(t.type===w.PERIOD?!!(null===(i=t.value)||void 0===i?void 0:i.start)||!!(null===(e=t.value)||void 0===e?void 0:e.end):!!t.groupedItems||!Array.isArray(t.value)||t.value.some((t=>!0===t.check)))}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===w.PERSONALIZED))}async processAfterUpdateConfig(){var t;if(this._loadingPending){if(await this._application.isLoadedByPk()&&!this._configUpdated)return;const t=this.getPersonalizedFilterItem();if(this._pendingVariables=!z.validateVariableValues(t),this._pendingVariables)return;this._loadingPending=!1,this.doLoadData()}this._configUpdated&&(this._configUpdated=!1,_.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}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 w.DEFAULT_FILTER:return function(t){return{name:t.id,expression:t.props.expression,params:[]}}(t);case w.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 w.MULTI_SELECT:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:a.TEXT,value:e}]}}(t);case w.MULTI_LIST:return function(t){const{id:i,value:e,props:s}=t,r=(null!==(o=null!==(n=null==(l=e)?void 0:l.elements)&&void 0!==n?n:null==l?void 0:l.members)&&void 0!==o?o:l).filter((t=>null==t?void 0:t.check)).map((({id:t})=>Number.isNaN(+t)?String(t):Number(t)));var l,n,o;if(r.length>0)return{name:i,expression:s.expression,params:[{name:i,dataType:a.TEXT,value:JSON.stringify(r)}]}}(t);case w.PERIOD:return function(t){const{id:i,value:e,props:s}=t;let{end:r,start:l}=e;"string"==typeof r&&(r=new Date(r)),"string"==typeof l&&(l=new Date(l));const n=[];let o;return r&&l?(o=s.expression.fullfill,n.push({name:`${i}.START`,dataType:a.DATE,value:x(a.DATE,l)},{name:`${i}.END`,dataType:a.DATE,value:x(a.DATE,r)})):l?(o=s.expression.onlystart,n.push({name:i,dataType:a.DATE,value:x(a.DATE,l)})):(o=s.expression.onlyend,n.push({name:i,dataType:a.DATE,value:x(a.DATE,r)})),{name:i,expression:o,params:n}}(t);case w.SEARCH:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:a.TEXT,value:x(a.TEXT,null==e?void 0:e.value)}]}}(t);case w.TEXT:return function(t){let{id:i,value:e,props:s}=t;const r=s.expression;var l,o;return n.isEmpty(s.likeAs)||(l=e,e="CONTANIS"===(o=s.likeAs)?`%${l}%`:"STARTS_WITH"===o?`${l}%`:"ENDS_WITH"===o?`%${l}`:l),{name:i,expression:r,params:[{name:i,dataType:a.TEXT,value:x(a.TEXT,e)}]}}(t);case w.NUMBER:return function(t){const{id:i,value:e,props:s}=t;if(s.variation===C.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:a.NUMBER,value:x(a.NUMBER,t)},{name:`${i}.END`,dataType:a.NUMBER,value:x(a.NUMBER,r)}]};if(!isNaN(t))return{name:i,expression:s.intervalExpression.onlystart,params:[{name:i,dataType:a.NUMBER,value:x(a.NUMBER,t)}]};if(!isNaN(r))return{name:i,expression:s.intervalExpression.onlyend,params:[{name:i,dataType:a.NUMBER,value:x(a.NUMBER,r)}]}}return{name:i,expression:s.expression,params:[{name:i,dataType:a.NUMBER,value:x(a.NUMBER,e)}]}}(t);case w.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 l=e>=0&&e<s.length?s[e]:null;return null!=l&&"object"==typeof l&&"value"in l&&(l=l.value),null==l&&r===a.BOOLEAN&&(l=!1),{name:i.name,dataType:r,value:"string"==typeof l?l:x(r,l)}}));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 w.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:A(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===w.DEFAULT_FILTER||this.filterActiveFilter(t)&&this.hasValidValue(t)}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===w.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,sizeChips:this.sizeChips})}))}getFilterItems(){const t=[],i=[];this.filterConfig.sort(((t,i)=>this._filtersComparator(t,i))).filter(this.filterActiveFilter).forEach((s=>{const r=`filter-${(s=o.copy(s)).id}`,l=e("snk-filter-item",{onVisibleChanged:t=>this.scrollerLocked=t.detail,onFilterChange:t=>this.updateFilter(t.detail),onFocusin:()=>this.itemFocused(r),id:r,config:s,getMessage:(t,i)=>this.getMessage(t,i),key:s.id,sizeChips:this.sizeChips});return s.fixed||s.hardFixed||s.required?t.push(l):i.push(l),l}));const s=[];return s.push(...t.reverse()),t.length>0&&i.length>0&&s.push(e("hr",{class:"ez-margin-horizontal--small ez-margin-vertical--auto ez-divider-vertical ez-divider--dark 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),e=t.type===w.PERSONALIZED;return e&&void 0===i.value&&i.groupedItems&&(i.value=i.groupedItems.filter((t=>!!t.visible)).length),["props","value","hardFixed","fixed"].forEach((t=>{"value"===t&&e||null==i[t]&&delete i[t]})),""!==i.value||e||delete i.value,i}updateFilter(t){const i=this.normalizeItem(t);let e=this.filterConfig.map((t=>t.id!==i.id?t:(o.objectToString(t)==o.objectToString(i)&&this.calculateUpdateSequence(i),i))).sort(((t,i)=>this._filtersComparator(t,i)));this.filterCustomConfigInterceptor&&(e=this.filterCustomConfigInterceptor(e)),this.filterConfig=e}loadPermitions(){this._application.isUserSup().then((t=>this.allowDefault=t))}addFilterBarLegacyConfigName(){this.filterBarLegacyConfigName&&_.addFilterBarLegacyConfig(this.configName,this.filterBarLegacyConfigName)}async loadConfigFromStorage(t){try{let i;t&&await _.deleteFilterBarConfigCache(this.configName,this.resourceID),i=this.customFilterBarConfig?await this.customFilterBarConfig(this.configName,this.resourceID,{contextURI:this.dataUnit.name}):await _.loadFilterBarConfig(this.configName,this.resourceID,{contextURI:this.dataUnit.name}),this.filterCustomConfig&&(i=[...this.filterCustomConfig,...i]),this.filterCustomConfigInterceptor&&(i=this.filterCustomConfigInterceptor(i)),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()}async showPersonalizedFilterItem(){const t=this._element.querySelector("#filter-PERSONALIZED_FILTER_GROUP");await(null==t?void 0:t.showUp(!0))}addPersonalizedFilter(t=!1){this.isFilterModalOpen=!1,this._isDefaultFilter=t,this.personalizedFilterId=void 0,this.showPersonalizedFilter=!0,window.requestAnimationFrame((()=>{this._elPersonalizedFilter.createPersonalizedFilter()}))}editPersonalizedFilter(t,i=!1){this.isFilterModalOpen=!1,this._isDefaultFilter=i,this.showPersonalizedFilter=!0,this.personalizedFilterId=t}deletePersonalizedFilter(t,i,e,s=!1){if(s)return _.removeDefaultFilter(t,this.resourceID,e),void(this._isDefaultFilter=!1);i===w.PERSONALIZED&&_.removePersonalizedFilter(t,this.resourceID,e)}closeFilterModal(){this.isFilterModalOpen=!1}applyFiltersFromModal(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),this.isFilterModalOpen=!1}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()}componentDidLoad(){this._element&&m.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}render(){if(!this.dataUnit||!this.filterConfig||0===this.filterConfig.length)return;if(this.showPersonalizedFilter)return 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});let t=o.copy(this.filterConfig);return t=t.sort(((t,i)=>t.originOrder-i.originOrder)),"regular"!==this.mode?e(s,{"data-mode":this.mode},this.getPersonalizedFilterVariableItems(),"button"===this.mode&&!this.hideFilterButton&&e("ez-button",{variant:"secondary",mode:"icon",iconName:"filter",class:"ez-margin-left--medium ez-margin-top--extra-small",size:"small",onClick:this.showFilterModal.bind(this)}),e("snk-filter-modal",{opened:this.isFilterModalOpen,filterConfig:this.filterConfig,configName:this.configName,disablePersonalizedFilter:this.disablePersonalizedFilter,getMessage:(t,i)=>this.getMessage(t,i),applyFilters:t=>this.applyFiltersFromModal(t),closeModal:()=>this.closeFilterModal(),addPersonalizedFilter:t=>this.addPersonalizedFilter(t),editPersonalizedFilter:(t,i)=>this.editPersonalizedFilter(t,i),deletePersonalizedFilter:(t,i,e)=>this.deletePersonalizedFilter(t,w.PERSONALIZED,i,e),filterCustomConfigInterceptor:this.filterCustomConfigInterceptor})):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:k.HORIZONTAL,activeShadow:!0,locked:this.scrollerLocked,scrollAmount:100,navigationMode:"buttons"},e("section",{class:"snk-filter-bar__filter-item-container"},this.getFilterItems())),!this.hideFilterButton&&e("ez-button",{variant:"secondary",mode:"icon",iconName:"filter",class:"ez-padding-left--medium ez-margin-top--extra-small",size:"small",onClick:this.showFilterModal.bind(this)},e("ez-icon",{slot:"leftIcon",iconName:"plus",class:"ez-padding-right--small"})),e("snk-filter-modal",{opened:this.isFilterModalOpen,filterConfig:this.filterConfig,configName:this.configName,disablePersonalizedFilter:this.disablePersonalizedFilter,getMessage:(t,i)=>this.getMessage(t,i),applyFilters:t=>this.applyFiltersFromModal(t),closeModal:()=>this.closeFilterModal(),addPersonalizedFilter:t=>this.addPersonalizedFilter(t),editPersonalizedFilter:(t,i)=>this.editPersonalizedFilter(t,i),deletePersonalizedFilter:(t,i,e)=>this.deletePersonalizedFilter(t,w.PERSONALIZED,i,e),filterCustomConfigInterceptor:this.filterCustomConfigInterceptor}))}get _element(){return r(this)}static get watchers(){return{filterConfig:["observeFilterConfig"]}}};P.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}.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 S=class{constructor(e){t(this,e),this.visibleChanged=i(this,"visibleChanged",7),this.filterChange=i(this,"filterChange",3),this._keyboardManager=void 0,this.detailIsVisible=void 0,this.config=void 0,this.getMessage=void 0,this.showChips=!0,this.sizeChips="default"}observeDetailIsVisible(t){this.visibleChanged.emit(t)}filterChangeListener(t){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),await this._filterDetail.setFocusField())}async hideDetail(){var t;await(null===(t=this._popover)||void 0===t?void 0:t.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===w.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(t)}async togglePopover(t){null==t||t.preventDefault(),null==t||t.stopPropagation(),!1!==this.config.enabled&&(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===w.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===w.MULTI_SELECT)return`${l}: ${a.options.find((t=>t.value===r)).label}`;if(s===w.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===w.SEARCH)return`${l}: ${r.value} - ${r.label}`;if(s===w.PERSONALIZED){const t=this.calculateActiveCount(n);return t<=0?l:`${l}: ${this.getMessage("snkFilterBar.personalizedCount",{activeCount:t})}`}if(s===w.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===w.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===w.NUMBER&&a.variation===C.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 p(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&&(m.addIDInfo(this._filterItemElement),this._idSnkFilterDetail=`filterDetail_${this.config.id}`)}canClearFilter(){const{value:t,groupedItems:i=[]}=this.config;return null!=t&&this.config.type===w.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 w.PERIOD:return"calendar";case w.PERSONALIZED:return"tune"}}hasActiveElements(t){var i;const e=Array.isArray(t)?t:null==t?void 0:t.elements;return(null===(i=null==e?void 0:e.filter((t=>null==t?void 0:t.check)))||void 0===i?void 0:i.length)>0}hasActiveValue(t){var i,e;return t.type===w.PERIOD?!!(null===(i=t.value)||void 0===i?void 0:i.start)||!!(null===(e=t.value)||void 0===e?void 0:e.end):t.type!==w.MULTI_LIST&&void 0!==t.value||this.hasActiveElements(t.value)}getEnabledChip(){if(this.detailIsVisible)return!0;if(this.config.type===w.PERSONALIZED){const{groupedItems:t=[]}=this.config;return t.some((t=>t.visible))}return this.hasActiveValue(this.config)}async handleVisibilityPopover(t){this.detailIsVisible=t.detail,this.detailIsVisible||await this._filterDetail.clearValue()}getCustomMessage(t,i){var e;return null===(e=this.getMessage)||void 0===e?void 0:e.call(this,`snkFilterBar.filterModal.${t}`,i)}hasValue(){return this.config.type===w.MULTI_LIST?this.hasActiveElements(this.config.value):null!=this.config.value}getTooltipMessage(){var t,i;return this.config.required&&!this.hasValue()?{message:null!==(t=this.config.requiredMessage)&&void 0!==t?t:this.getCustomMessage("validations.requiredFilter"),type:"error"}:!1===this.config.enabled&&this.config.disabledMessage?{message:this.config.disabledMessage,type:"warning"}:{message:null!==(i=this.config.defaultMessage)&&void 0!==i?i:this.getLabel(!0),type:"default"}}getTypeChip(t){switch(t){case"default":return"secondary";case"warning":return"warning-light";case"error":return"error-light";case"success":return"success-light";default:return t}}initKeyboardManager(){this._keyboardManager=new v({element:this._filterItemElement,propagate:!0}),this._keyboardManager.bind("Escape",(()=>this.hideDetail()))}connectedCallback(){this.initKeyboardManager()}disconnectedCallback(){this._keyboardManager.unbindAllShortcutKeys()}render(){const t=this.getLeftIconName(),{type:i,message:r}=this.getTooltipMessage();return e(s,null,this.showChips&&e("ez-tooltip",{id:this.config.id,message:r,type:i,active:!this.detailIsVisible,strategy:"fixed"},e("ez-chip",{id:this.config.id,size:this.sizeChips,ref:t=>this._chipElement=t,label:this.getLabel(),value:this.getEnabledChip(),onClick:t=>this.togglePopover(t),disableAutoUpdateValue:!0,type:this.getTypeChip(i),enabled:this.config.enabled},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",{ref:t=>this._filterDetail=t,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&&!this.config.required,removalBlocked:this.config.required})))}get _filterItemElement(){return r(this)}static get watchers(){return{detailIsVisible:["observeDetailIsVisible"]}}};S.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)}ez-chip.sc-snk-filter-item{--ez-label-chip__label__container--margin:var(--space--4, 4px)}";const D="__SHOWMORE__",E=class{constructor(e){t(this,e),this.snkItemSelected=i(this,"snkItemSelected",7),this._preselection=-1,this.innerClickCheck=(t,i)=>i.id!=b.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=b.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&&b.close(this._floatingID)}onListCloseCallback(){this._floatingID=void 0,this._detailIsVisible=!1}buttonClick(){this._detailIsVisible?this.hideDetail():this.showDetail()}componentDidLoad(){this._element&&m.addIDInfo(this._element)}componentDidRender(){null==this._floatingID&&this._popover&&this._popover.remove()}buildIdElement(t,i){if(!t)return;const e={id:i};t.removeAttribute(m.DATA_ELEMENT_ID_ATTRIBUTE_NAME),m.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===D?this._showAll=!0:(this.hideDetail(),this.snkItemSelected.emit(t))}getFilterItems(){const t=this.items?g.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:D,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)}},O=class{constructor(i){t(this,i),this._isUserSup=!1,this.filters=[],this.filtersWithError=[],this.getMessage=void 0,this.configName=void 0,this.filterConfig=void 0,this.opened=!1,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,this.filterCustomConfigInterceptor=void 0}filterConfigChangeHandler(t){this.filters=o.copy(t),this.validateFilters()}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===w.MULTI_LIST?(t.multiListFilters.push(i),t):i.filterType===N.QUICK_FILTER?(t.quickFilters.push(i),t):i.filterType===N.CUSTOM_FILTER?(t.customFilters.push(i),t):i.filterType===N.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))),l(this)}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===N.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 o.objectToString(this.filters)!=o.objectToString(this.filters)}handleClose(){if(this.hasChangeToSave())return $.confirm(this.getCustomMessage("validations.notSaved.title"),this.getCustomMessage("validations.notSaved.message")).then((t=>{t&&this.closeModal()}));this.closeModal()}handleApplyFilters(){if(!this.validateFilters())return;const t=this.filters.find((t=>t.filterType===N.CUSTOM_FILTER||t.filterType===N.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!!z.validateVariableValues(t)||($.alert(this.getCustomMessage("validations.notFullFilled.title"),this.getCustomMessage("validations.notFullFilled.message")),!1)}modalActionListener(t){switch(t.detail){case I.CANCEL:this.handleClearAll();break;case I.OK:this.handleApplyFilters();break;case I.CLOSE:this.handleClose()}}handleFilterChange(t){t.stopPropagation();const i=t.detail;let e=this.filters.map((t=>t.id===i.id?i:t));this.filterCustomConfigInterceptor&&(e=this.filterCustomConfigInterceptor(e)),this.filters=o.copy(e)}handleClearFilterList(t){this.filters=this.filters.map((i=>t.includes(i)?Object.assign(Object.assign({},i),{value:void 0}):i))}handleClearSigleFilter(t){if(w.MULTI_LIST===t.type){let i=o.copy(t);this.uncheckFilterValues(i.value);const e=o.copy(this.filters),s=e.findIndex((i=>i.id===t.id));return e.splice(s,1,i),void(this.filters=o.copy(e))}if(w.CHECK_BOX_LIST===t.type){const i=o.copy(this.filters);return i.find((i=>i.id===t.id)).value=void 0,void(this.filters=o.copy(i))}this.filters.find((i=>i.id===t.id)).value=void 0,this.filters=o.copy(this.filters)}uncheckFilterValues(t){return t.forEach((t=>{t&&(t.check=!1)})),t}validateFilters(){const t=T(this.filters);return this.filtersWithError=t.map((t=>t.id)),0===t.length||(t.forEach((t=>{const i=this._element.querySelector(`#filter-item-${t.id}`);i&&(i.errorMessage=t.requiredMessage||this.getCustomMessage("validations.requiredFilter"))})),!1)}renderFilterItem(t,i){return e("snk-filter-modal-item",{key:`modal-item-${t.id}`,class:i?"ez-col ez-col--sd-12":"ez-size-width--full ez-padding-right--medium",filterItem:t,configName:this.configName,onFilterChange:t=>this.handleFilterChange(t),onEditPersonalizedFilter:t=>this.editPersonalizedFilter(t.detail),onAddPersonalizedFilter:()=>this.addPersonalizedFilter()})}isDefaultFilterNumberVariation(t){var i;return t.type===w.NUMBER&&(!t.props.variation||(null===(i=t.props)||void 0===i?void 0:i.variation)===C.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===w.TEXT||this.isDefaultFilterNumberVariation(l),o=!a&&(t[r+1].type===w.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 i?t.map((t=>this.renderFilterItem(t,i))):e("div",{class:"ez-col ez-col--sd-12 hydrated","data-element-id":"snkFilterModalItem"},e("div",{class:"ez-flex ez-flex--column grow"},e("div",{class:"ez-col ez-col--nowrap"},t.map((t=>this.renderFilterItem(t,i))))))}getIformedFiltersCount(t){let i=0;return t.forEach((t=>{var e,s,r,l,a,n,o,h;const d=this.filterConfig.find((i=>i.id===t.id));w.MULTI_LIST!==d.type?w.CHECK_BOX_LIST!==d.type?w.PERIOD!==d.type?null==d.groupedItems?d.value&&i++:i=d.groupedItems.filter((t=>t.visible)).length:((null===(o=d.value)||void 0===o?void 0:o.start)||(null===(h=d.value)||void 0===h?void 0:h.end))&&i++:i+=Object.entries(null!==(n=d.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=d.value)||void 0===e?void 0:e.elements)&&void 0!==s?s:d.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({label:t,listItems:i,isSingleItem:s,shouldRenderFooter:r=!0,initializeOpen:l=!1}){if(!i.length)return null;const a=this.getIformedFiltersCount(i),n=this.mountFiltersLines(i),o=this.filtersWithError.filter((t=>i.some((i=>i.id===t)))).length;return e("ez-collapsible-box",{class:"snk-filter-modal__collapsible-box",headerSize:"medium",value:!l,label:t},e("div",{class:"ez-flex ez-flex--justify-end grow",slot:"rightSlot"},!!a&&e("ez-badge",{class:"ez-badge--primary-subtle",label:null==a?void 0:a.toString()}),!!o&&e("ez-badge",{class:"ez-badge--error-subtle",label:null==o?void 0:o.toString()})),e("div",{class:"ez-row snk-filter-modal__rendered-items"},n.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!==N.DEFAULT_FILTER)))}))}handleActionSelectedDefaultFilter({detail:t}){switch(t){case L.CREATE:this.addPersonalizedFilter(!0);break;case L.EDIT:this.editPersonalizedFilter(this._defaultFilter.id,!0);break;case L.REMOVE:this.handleDeleteFilter()}}getCustomFilter(t){return t.filter((t=>t.filterType===N.CUSTOM_FILTER))}getDefaultFilter(t){return t.find((t=>t.id===y.id))}async componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__"),this._isUserSup=await this._application.isUserSup(),this.filters=o.copy(this.filterConfig)}componentWillRender(){this._modalTitle=this.getCustomMessage("title"),this._okButtonLabel=this.getCustomMessage("okButtonLabel"),this._cancelButtonLabel=this.getCustomMessage("cancelButtonLabel")}componentDidLoad(){this.validateFilters()}render(){this._defaultFilter=this._isUserSup?this.getDefaultFilter(this.filters):void 0;const t=this.getCustomFilter(this.filters),i=this.filters.filter((t=>t.filterType===N.QUICK_FILTER)),s=this.filters.filter((t=>t.filterType===N.OTHER_FILTERS));return e("ez-modal",{opened:this.opened,modalSize:"col--sd-3",align:"right",heightMode:"full",closeEsc:!0},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"},this._isUserSup&&e("snk-default-filter",{getMessage:this.getCustomMessage.bind(this),hasDefaultFilter:!!this._defaultFilter,onActionSelected:this.handleActionSelectedDefaultFilter.bind(this)}),!this.disablePersonalizedFilter&&this.renderCollapsibleFilterBox({label:this.getCustomMessage("customFilters"),listItems:t,isSingleItem:!1,shouldRenderFooter:!1}),this.renderCollapsibleFilterBox({label:this.getCustomMessage("quickFilters"),listItems:i,isSingleItem:!1,shouldRenderFooter:!0,initializeOpen:!0}),s.map((t=>this.renderCollapsibleFilterBox({label:t.label,listItems:[t],isSingleItem:!0,shouldRenderFooter:!0}))))))}get _element(){return r(this)}static get watchers(){return{filterConfig:["filterConfigChangeHandler"]}}};O.style="ez-modal{--ez-modal-content-padding:24px 12px;--ez-modal-content-min-width:370px}.snk-filter-modal__container{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}.snk-filter-modal__rendered-items::-webkit-scrollbar{width:var(--space--small\n);min-width:var(--space--small);max-width:var(--space--small)}.ez-padding-right--medium:nth-child(even){padding-right:0}";export{P as snk_filter_bar,S as snk_filter_item,E as snk_filter_list,O as snk_filter_modal}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as i,i as t,h as s,f as e,g as o,e as a}from"./p-2c9d0870.js";import{Action as n,StringUtils as r,KeyboardManager as d,ObjectUtils as h,ApplicationContext as l}from"@sankhyalabs/core";import{S as c,a as u}from"./p-ed1b1b14.js";import{buildFormMetadata as v,FormMetadata as f,buildFormConfigFromDataUnit as m}from"@sankhyalabs/ezui/dist/collection/utils/form";import{S as g}from"./p-10d883b0.js";import"./p-3190ac29.js";import{P as p}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-c1e168a2.js";import"./p-ff1990ad.js";import{U as b}from"./p-d7657667.js";import{V as y,a as k,G as w}from"./p-9019a32f.js";import{T as C}from"./p-3072136e.js";import{buildFieldSearch as S,SHORTCUT_SEARCH_FIELD as x,ApplicationUtils as _}from"@sankhyalabs/ezui/dist/collection/utils";import{S as F,D as A,g as T}from"./p-1bc6849e.js";import{b as z,a as D,c as G,d as E,g as L,u as N,e as M}from"./p-46d7e2de.js";import"./p-13f91e7e.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-a73b6b00.js";const I=class{constructor(t){i(this,t),this._taskbarProcessor=new F(A),this._currentView=0,this.attachmentRegisterKey=void 0,this._fieldToGetFocus=void 0,this._hasToCreateFieldSearch=!0,this._selectedSheet=void 0,this._internalErrorTabs=new Set,this._selectedRecordPKDisplay=void 0,this.formConfigManager=void 0,this.dataUnitName=void 0,this.resourceID=void 0,this.entityName=void 0,this.label=void 0,this.dataUnit=void 0,this.selectedForm=void 0,this.dataState=void 0,this.messagesBuilder=void 0,this.canEdit=!0,this.taskbarCustomContainerId=void 0,this.customEditors=void 0,this.customRenders=void 0,this.presentationMode=p.SECONDARY}observeDataUnit(i,t){null==i||i.subscribe(this.dataUnitActionHandler.bind(this)),null==t||t.unsubscribe(this.dataUnitActionHandler)}observerDataState(i,t){const s=!(null==t?void 0:t.insertionMode)&&(null==i?void 0:i.insertionMode),e=(null==t?void 0:t.insertionMode)&&!(null==i?void 0:i.insertionMode);(s||e)&&this.loadMetadata(),null!=this._formMetadata&&(this.selectedSheetIsDetail()||(s&&setTimeout((()=>{this.changeViewMode(y.FORM)}),0),e&&this.changeViewMode(y.GRID)))}async changeViewMode(i){this._viewStack&&(this._viewStack.show(i),this._currentView=i)}async configGrid(){this._snkGrid&&this._snkGrid.showConfig()}async showUp(){this._snkFormView&&this._snkFormView.showUp(),this._snkGrid&&this._snkGrid.scrollIntoView({behavior:"smooth",block:"start"})}async addCustomEditor(i,t){var s,e;const o=this.normalizeDataUnitName();null===(s=this._snkGrid)||void 0===s||s.addCustomEditor(i,t,o),null===(e=this._snkFormView)||void 0===e||e.addCustomEditor(i,t,o)}async observerPropsCustomEditor(i){for(const t in i)await this.addCustomEditor(t,i[t])}async addGridCustomRender(i,t){var s;const e=this.normalizeDataUnitName();await(null===(s=this._snkGrid)||void 0===s?void 0:s.addGridCustomRender(i,t,e))}onContentCardChanged(i){c.updateContentCard(i.detail.formName,i.detail.cardConfig,i.detail.propertyChanged,this.formConfigManager).then((()=>t(this))),i.stopPropagation()}async observeCustomRenders(i){for(const t in i){const s=i[t];await this.addGridCustomRender(t,s)}}loadMetadata(){if(!this.dataUnit||!this.formConfigManager)return;if(!this.formConfigManager.isLoaded)return;const i=this.formConfigManager.getConfig(this.dataUnit);this._formMetadata=v(null==i||0===i.fields.length?void 0:i,this.dataUnit,!0),this.initSelectedSheet()}initSelectedSheet(){if(!this._formMetadata)return void(this._selectedSheet=void 0);const i=this._formMetadata.getAllSheets();if(i&&0!==i.size){if(this._selectedSheet&&this._selectedSheet.name!==I.MAIN_TAB){const t=i.get(this._selectedSheet.name);if(t)return void(this._selectedSheet=t)}this._selectedSheet=this.getFirstNonMainSheet(i)}else this._selectedSheet=void 0}getFirstNonMainSheet(i){for(const[t,s]of i)if(t!==I.MAIN_TAB)return s}dataUnitReadyHandler(i){this.dataUnit=i.detail,this.loadMetadata()}getFormFields(){var i,t,s;const e=null===(t=null===(i=this._formMetadata)||void 0===i?void 0:i.getAllSheets())||void 0===t?void 0:t.get(I.MAIN_TAB);return null!==(s=null==e?void 0:e.fields)&&void 0!==s?s:[]}hasNonMainSheets(){if(!this._formMetadata)return!1;for(const i of this._formMetadata.getAllSheets().keys())if(i!==I.MAIN_TAB)return!0;return!1}selectedSheetIsDetail(){return!!this._selectedSheet&&null!=f.getDetailName(this._selectedSheet.name)}isSheetDisabled(i){var t;if(null==f.getDetailName(i.name))return!1;const s=null===(t=this.dataUnit)||void 0===t?void 0:t.getSelectedRecord();return!s||!this.dataUnit||this.dataUnit.isNewRecord(s.__record__id__)||this.dataUnit.isMultipleEdition}buildInternalTabItems(){return this._formMetadata?Array.from(this._formMetadata.getAllSheets().values()).filter((i=>i.name!==I.MAIN_TAB)).map(((i,t)=>({tabKey:i.name,label:i.label,index:t,disabled:this.isSheetDisabled(i),rightIcon:this._internalErrorTabs.has(i.name)?"alert-circle-inverted":void 0}))):[]}onInternalTabChange(i){var t,s;if(i.tabKey===I.MAIN_TAB)return;const e=null===(s=null===(t=this._formMetadata)||void 0===t?void 0:t.getAllSheets())||void 0===s?void 0:s.get(i.tabKey);e&&!this.isSheetDisabled(e)&&(this._selectedSheet=e)}executeActionHandler(i){var t;i.detail===C.GRID_MODE&&(this.changeViewMode(y.GRID),i.stopPropagation()),i.detail===C.UPDATE_MULTIPLE&&this.dataUnit&&(this.dataUnit.isMultipleEdition=!0,this.changeViewMode(y.FORM),i.stopPropagation()),i.detail!==C.FORM_MODE&&i.detail!==C.UPDATE&&i.detail!==C.INSERT||(this.changeViewMode(y.FORM),i.stopPropagation()),i.detail===C.ATTACH&&(null===(t=this._snkAttach)||void 0===t||t.open(),i.stopPropagation())}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:i})=>i)).join("_")}async handleDataStateChange({detail:i}){var t;this.dataState=i,void 0!==i.selectedRecord&&this._snkDataUnit&&(this.attachmentRegisterKey=null!==(t=await this.getAttachmentRegisterKey())&&void 0!==t?t:void 0),this._selectedRecordPKDisplay=this.buildSelectedRecordPKDisplay()}buildSelectedRecordPKDisplay(){var i,t,s,e,o,a,n;if(!this.dataUnit)return;if(null===(i=this.dataState)||void 0===i?void 0:i.insertionMode){const i=null===(t=this.messagesBuilder)||void 0===t?void 0:t.getMessage("snkCrud.newRecord");return i?{message:i}:void 0}const r=this.dataUnit.getSelectedRecord();if(!r)return;const d=[],h=null!==(e=null===(s=this.dataUnit.metadata)||void 0===s?void 0:s.fields)&&void 0!==e?e:[];for(const i of h){if("true"!==(null===(o=i.properties)||void 0===o?void 0:o.isPrimaryKey))continue;const t=r[i.name],s=null!==(a=null==t?void 0:t.value)&&void 0!==a?a:t;null!=s&&""!==s&&d.push({label:null!==(n=i.label)&&void 0!==n?n:i.name,value:String(s)})}return d.length?{items:d}:void 0}renderSelectedRecordHeader(){var i;if(!this.label&&!this._selectedRecordPKDisplay)return;const t=this._selectedRecordPKDisplay;if(t){if(t.message)return s("div",{class:"selected-record-header selected-record-header--message"},s("span",{class:"selected-record-header__message"},t.message));if(null===(i=t.items)||void 0===i?void 0:i.length)return s("div",{class:"selected-record-header",role:"group"},t.items.map(((i,t)=>[t>0&&s("span",{class:"selected-record-header__separator","aria-hidden":"true"}),s("div",{class:"selected-record-header__chip"},s("span",{class:"selected-record-header__label"},i.label,":"),s("span",{class:"selected-record-header__value"},i.value))])))}}componentWillLoad(){var i;this._configName=`dynaform.${this.entityName}`,this.formConfigManager=new u(this._configName,null!==(i=this.resourceID)&&void 0!==i?i:"",(()=>this.loadMetadata()),this.dataUnit),this.formConfigManager.loadConfig(),null==this.messagesBuilder&&(this.messagesBuilder=new g(this.entityName))}componentWillRender(){this.initializeTaskbarProcessor()}initializeTaskbarProcessor(){if(!this.dataState)return;const i=this.buildDetailTaskbarManager(),t=T(this.dataState,this.presentationMode);this._taskbarProcessor.process(t,i,this.dataState,[],[])}buildDetailTaskbarManager(){const i=[C.CANCEL,C.SAVE],t=this._currentView;return{getButtons:(s,e,o)=>{var a,n,r;if(!s)return[];if((null==e?void 0:e.insertionMode)||(null==e?void 0:e.isDirty))return i;let d=[...o];if(t===y.FORM){const i=d.indexOf(C.FORM_MODE);i>-1&&(d=[...d.slice(0,i),C.GRID_MODE,...d.slice(i+1)])}if((null!==(r=null===(n=null===(a=null==e?void 0:e.selectionInfo)||void 0===a?void 0:a.records)||void 0===n?void 0:n.length)&&void 0!==r?r:0)>1){const i=d.indexOf(C.UPDATE);i>-1&&(d=[...d.slice(0,i),C.UPDATE_MULTIPLE,...d.slice(i+1)])}return d},isEnabled:(i,t,s,e)=>t?!(void 0===t.selectedRecord&&[C.UPDATE,C.REMOVE,C.ATTACH,C.CLONE].includes(s))&&!(s===C.PREVIOUS&&!t.hasPrevious)&&!(s===C.NEXT&&!t.hasNext)&&(s!==C.INSERT||!t.insertionMode)&&e:e}}async componentDidLoad(){this.customEditors&&await this.observerPropsCustomEditor(this.customEditors),this.customRenders&&await this.observeCustomRenders(this.customRenders),this.initKeyboardManager()}disconnectedCallback(){var i;null===(i=this._keyboardManager)||void 0===i||i.unbindAllShortcutKeys()}async dataUnitActionHandler(i){var t;if(i.type===n.FIELD_INVALIDATED){const s=this.findSheetOfField(null===(t=i.payload)||void 0===t?void 0:t.fieldName);s&&(this._internalErrorTabs=new Set([...this._internalErrorTabs,s]))}}findSheetOfField(i){var t;if(!i||!this._formMetadata)return;const s=this._formMetadata.getAllSheets();for(const[e,o]of s)if(null===(t=o.fields)||void 0===t?void 0:t.some((t=>t.name===i)))return e}normalizeDataUnitName(){var i,t;return null!==(t=null===(i=this.dataUnitName)||void 0===i?void 0:i.replace(/\//g,">"))&&void 0!==t?t:""}getSettingsListForm(){var i,t;return[{value:r.generateUUID(),label:null!==(t=null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkCrud.findColumn",void 0))&&void 0!==t?t:"",disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>this.getFieldsSearch(t)}]}getFieldsSearch(i){var t;return(void 0===this._fieldSearch||this._hasToCreateFieldSearch)&&(this._hasToCreateFieldSearch=!1,this._fieldSearch=S(i,(({argument:i})=>this.fieldsOptionLoader(i)),(i=>this.onSelectField(i)))),null!==(t=this._fieldSearch)&&void 0!==t?t:document.createElement("div")}fieldsOptionLoader(i){const t=null==i?void 0:i.toLowerCase(),s=this.getFormFields().map((i=>{var t;return null===(t=this.dataUnit)||void 0===t?void 0:t.getField(i.name)})).filter((i=>{var s,e;if(i)return(null===(s=i.name)||void 0===s?void 0:s.toLowerCase().includes(t))||(null===(e=i.label)||void 0===e?void 0:e.toLowerCase().includes(t))})).map((i=>{if(i)return{value:i.name,label:i.label}}));return Promise.resolve(s)}onSelectField(i){null!=i&&(this._fieldToGetFocus=i.value)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}getColumnSearch(i){var t;return void 0!==this._columnSearch?this._columnSearch:(this._columnSearch=S(i,(({argument:i})=>new Promise((t=>{var s;null===(s=this._snkGrid)||void 0===s||s.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(i=>{var t;null!=i&&(null===(t=this._snkGrid)||void 0===t||t.locateColumn(i.value))})),null!==(t=this._columnSearch)&&void 0!==t?t:document.createElement("div"))}buildTaskbarCustomActionsList(){return[this.buildSearchColumnTaskbarAction()]}buildSearchColumnTaskbarAction(){var i,t;return{value:r.generateUUID(),label:null!==(t=null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkGrid.findColumn",{}))&&void 0!==t?t:"",disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>{var s;return null!==(s=this.getColumnSearch(t))&&void 0!==s?s:document.createElement("div")}}}async initKeyboardManager(){var i;this._keyboardManager=new d({propagate:!1,element:this._element}),this._keyboardManager.bind(x,(async()=>{var i;await(null===(i=this._snkFormView)||void 0===i?void 0:i.showSearchField())}),{description:null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkSimpleCrud.findFields"),element:this._element})}renderTabSelector(){if(!this.hasNonMainSheets())return;const i=this._selectedSheet&&this._selectedSheet.name!==I.MAIN_TAB?this._selectedSheet.name:void 0;return s("ez-tabselector",{class:"ez-tabselector-internal",tabs:this.buildInternalTabItems(),selectedTab:i,onEzChange:i=>this.onInternalTabChange(i.detail)})}renderSelectedSheetContent(){if(!this._selectedSheet||this._selectedSheet.name===I.MAIN_TAB)return;const i=f.getDetailName(this._selectedSheet.name);return i?s("snk-dynaform-detail-view",{key:`sub_${this.dataUnitName}_${this._selectedSheet.name}`,dataUnitName:`${this.dataUnitName}/${i}`,entityName:i,label:this._selectedSheet.label,resourceID:this.resourceID,canEdit:this.canEdit,messagesBuilder:this.messagesBuilder,customEditors:this.customEditors,customRenders:this.customRenders,presentationMode:this.presentationMode,taskbarCustomContainerId:this.taskbarCustomContainerId}):s("snk-dynaform-form-view",{key:`sheet_${this._selectedSheet.name}`,name:this._selectedSheet.name,formMetadata:this._formMetadata,dataUnit:this.dataUnit,fields:this._selectedSheet.fields,fieldToFocus:this._fieldToGetFocus,label:this._selectedSheet.label,onSnkRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),fieldSearch:this._fieldSearch})}renderViewStack(){var i,t;return s("ez-view-stack",{ref:i=>this._viewStack=i},s("stack-item",{class:"ez-size-width--full ez-size-height--full"},s("snk-grid",{class:"ez-size-width--full ez-size-height--full",ref:i=>{i&&(this._snkGrid=i)},configName:this._configName,messagesBuilder:this.messagesBuilder,onGridDoubleClick:()=>this.changeViewMode(y.FORM),onActionClick:i=>this.executeActionHandler(i),presentationMode:this.presentationMode,canEdit:this.canEdit,isDetail:!0,taskbarCustomContainerId:this.taskbarCustomContainerId,gridHeaderCustomSlotId:"DETAIL_GRID_HEADER_CUSTOM_ELEMENTS",topTaskbarCustomSlotId:"DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS",outlineMode:!0,enableGridInsert:!0,autoLoad:!0,multipleEditionEnabled:!0,multipleSelection:!0,hideHeader:!0,hideGridTaskbar:!0})),s("stack-item",{class:"ez-size-width--full ez-size-height--full grid-container"},s("div",{class:"form-and-detail-container"},s("snk-dynaform-form-view",{ref:i=>{i&&(this._snkFormView=i)},name:I.MAIN_TAB,formMetadata:this._formMetadata,dataUnit:this.dataUnit,fields:this.getFormFields(),fieldToFocus:this._fieldToGetFocus,label:this.label,onSnkRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),fieldSearch:this._fieldSearch},this.renderSelectedRecordHeader()),this.renderTabSelector(),this.renderSelectedSheetContent())),s("snk-attach",{ref:i=>this._snkAttach=i,registerKey:null!==(i=this.attachmentRegisterKey)&&void 0!==i?i:"",messagesBuilder:this.messagesBuilder,entityName:null!==(t=this.entityName)&&void 0!==t?t:""}))}render(){return s(e,null,s("snk-data-unit",{ref:i=>{i&&(this._snkDataUnit=i)},dataUnitName:`${this.dataUnitName}`,onDataUnitReady:i=>this.dataUnitReadyHandler(i),entityName:this.entityName,onDataStateChange:this.handleDataStateChange.bind(this),ignoreSaveMessage:this._currentView===y.GRID,messagesBuilder:this.messagesBuilder,configName:this._configName},s("snk-taskbar",{key:"detailViewTaskbar",class:"form-taskbar","data-element-id":"detail_top",configName:this._configName,messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,primaryButton:"INSERT",overflowStrategy:"hiddenItems",alignRigth:!0,sizeButtons:"small",presentationMode:this.presentationMode,onActionClick:i=>this.executeActionHandler(i),dataUnit:this.dataUnit,resourceID:this.resourceID,customContainerId:this.taskbarCustomContainerId,customSlotId:"DETAIL_TASKBAR_CUSTOM_ELEMENTS",actionsSettingsList:this.getSettingsListForm(),customActionsList:this.buildTaskbarCustomActionsList()},s("slot",{name:"DETAIL_TASKBAR_CUSTOM_ELEMENTS"})),this.renderViewStack()))}get _element(){return o(this)}static get watchers(){return{dataUnit:["observeDataUnit"],dataState:["observerDataState"],customEditors:["observerPropsCustomEditor"],customRenders:["observeCustomRenders"]}}};I.MAIN_TAB="__main",I.style=".sc-snk-dynaform-detail-view-h{display:flex;row-gap:24px;flex-direction:column;width:100%;height:100%;overflow:hidden}.level-path.sc-snk-dynaform-detail-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.grid-container.sc-snk-dynaform-detail-view{min-height:100px;height:100%;width:100%;display:flex;flex-wrap:wrap;text-decoration:none;border-radius:var(--border--radius-medium);background-color:var(--color--gray-70, #FFFFFF);border:1px solid var(--color--petroleum-100, #C8CCD3)}.detail-header.sc-snk-dynaform-detail-view{padding-bottom:0}snk-data-unit.sc-snk-dynaform-detail-view{flex:1;gap:var(--space--12, 12px);display:flex;flex-direction:column}snk-grid.sc-snk-dynaform-detail-view{height:100%;--snk-grid-margin:0px;--snk-grid-box-shadow:none}.form-and-detail-container.sc-snk-dynaform-detail-view{display:flex;flex-direction:column;height:100%;width:100%;overflow:auto;padding:var(--space--12, 12px)}.ez-tabselector-internal.sc-snk-dynaform-detail-view{margin:var(--space--8, 8px) 0}.selected-record-header.sc-snk-dynaform-detail-view{display:flex;align-items:center;flex-wrap:wrap;gap:var(--space--8, 8px) var(--space--12, 12px);padding:var(--space--12, 12px) var(--space--16, 16px);margin-bottom:var(--space--12, 12px);background:var(--color--gray-80, #F9F9F9);border-radius:var(--border--radius-12, 12px);font-family:var(--font--pattern);border:1px solid var(--color--petroleum-100, #C8CCD3);border-left:4px solid var(--color--ocean-green-500, #00B07E)}.selected-record-header--message.sc-snk-dynaform-detail-view{border-left-color:var(--color--primary, #007EFF)}.selected-record-header__message.sc-snk-dynaform-detail-view{font-size:var(--font-size--default, 14px);font-weight:var(--font-weight--medium, 500);color:var(--color--title-primary, #2B3A54)}.selected-record-header__chip.sc-snk-dynaform-detail-view{display:inline-flex;flex-direction:row;align-items:center;gap:var(--space--4, 4px);min-width:0}.selected-record-header__label.sc-snk-dynaform-detail-view{font-size:var(--font-size--xs, 11px);font-weight:var(--font-weight--medium, 500);text-transform:uppercase;letter-spacing:0.04em;color:var(--color--text-secondary, #6E7A8A)}.selected-record-header__value.sc-snk-dynaform-detail-view{font-size:var(--font-size--md, 15px);font-weight:var(--font-weight--semibold, 600);color:var(--color--ocean-green-1000, #00281D);line-height:1.2;word-break:break-word}.selected-record-header__separator.sc-snk-dynaform-detail-view{display:inline-block;align-self:stretch;width:1px;background:var(--color--petroleum-100, #C8CCD3);margin:0 var(--space--4, 4px)}";const R=class{constructor(t){i(this,t),this.configClose=a(this,"configClose",7),this.configChange=a(this,"configChange",7),this.guidesMap=new Map,this.availableFields=[],this.guidesList=[],this.groupsList=[],this.mainGuide=void 0,this.mainGroupsList=[],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,this.customGuidesConfig=[]}handleFieldConfigChanged(){this.hasChanges=!0}async handleFormConfigOptionSelected({detail:i}){this.configSelected=i,this.selectedGuide=void 0,await this.loadConfigByUser(),this.optionConfigChanged=!h.equals(this.configSelected,this.originalConfigSelected),this.configSelected.origin===b.DEFAULT&&(this.hasChanges=!1)}async handleAddFieldToGuide({detail:i}){var t,s;const e=this.selectedGuide&&!this.selectedGuide.isCustom&&!this.selectedGuide.isDetail;e||!this.selectedGuide||!this.selectedGuide.isCustom&&!this.selectedGuide.isDetail?e||this.mainGuide?(this.availableFields=[...this.availableFields.filter((t=>t.name!==i.name))],e?await(null===(t=this.refFieldsLayout)||void 0===t?void 0:t.addFieldToLayout(i)):await(null===(s=this.refMainFieldsLayout)||void 0===s?void 0:s.addFieldToLayout(i))):this.showNoGuideSelectedDialog():this.showCanNotAddFieldToGuideDialog()}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,s;if((null==i?void 0:i.name)&&(null===(t=this.mainGuide)||void 0===t?void 0:t.name)&&i.name===this.mainGuide.name)return void(this.selectedGuide=void 0);const e=null!==(s=this.guidesMap.get(null==i?void 0:i.name))&&void 0!==s?s:[];this.groupsList=[...e]}observeConfigManager(){this.loadFormConfig()}showNoGuideSelectedDialog(){const i=this.getMessage("snkFormConfig.noGuideSelected.title"),t=this.getMessage("snkFormConfig.noGuideSelected.message");_.alert(i,t)}showCanNotAddFieldToGuideDialog(){const i=this.getMessage("snkFormConfig.canNotAddFieldToGuide.title"),t=this.getMessage("snkFormConfig.canNotAddFieldToGuide.message");_.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=null==i?void 0:i.find((i=>i.origin===t)),this.originalConfigSelected=null==i?void 0: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 o=t.some((({name:t})=>t===i));return o||!0!==e.visibleOnConfig||s?!0===s&&!1===o:e.visibleOnConfig}))}getInitialOrder(i){var t,s;return Array.isArray(null===(t=this._formConfig)||void 0===t?void 0:t.tabs)?null===(s=this._formConfig.tabs)||void 0===s?void 0:s.length:i.length>0?Math.max(...i.map((i=>i.order))):0}loadGuides(){var i,t,s,e;this.guidesList=[],this.guidesList.push(...z(this._formConfig,this.getMessage("snkFormConfig.form.mainArea"),this.dataUnit,k.general)),this.guidesList.push(...D(this.dataUnit,this.getInitialOrder(this.guidesList),this.guidesList)),this.guidesList.push(...G(this.customGuidesConfig,this.guidesList)),this.guidesMap=E(null===(i=this._formConfig)||void 0===i?void 0:i.fields,this.guidesList,this.dataUnit,k.general),this.mainGuide=this.guidesList.find((i=>i.name===k.main)),this.mainGroupsList=(null===(t=this.mainGuide)||void 0===t?void 0:t.name)?[...null!==(e=null===(s=this.guidesMap)||void 0===s?void 0:s.get(this.mainGuide.name))&&void 0!==e?e:[]]:[],this.ensureSelectedGuide()}ensureSelectedGuide(){if(this.selectedGuide&&this.guidesList.some((i=>i.name===this.selectedGuide.name)))return;const i=this.guidesList.filter((i=>{var t;return i.visible&&i.name!==(null===(t=this.mainGuide)||void 0===t?void 0:t.name)})).sort(((i,t)=>{var s,e;return(null!==(s=i.order)&&void 0!==s?s:Number.MAX_VALUE)-(null!==(e=t.order)&&void 0!==e?e:Number.MAX_VALUE)}))[0];this.selectedGuide=i}getConfig(){let i=this.configManager.getConfig(this.dataUnit,!1);return i.fields&&0===i.fields.length&&(i=void 0),null==i&&(i=m(this.dataUnit)),h.copy(i)}handleSelectGuide({detail:i}){this.selectedGuide=i}handleLayoutChanged({detail:i}){this.selectedGuide&&(this.hasChanges=!0,this.groupsList=[...i],this.guidesMap.set(this.selectedGuide.name,[...i]))}handleMainLayoutChanged({detail:i}){var t;(null===(t=this.mainGuide)||void 0===t?void 0:t.name)&&(this.hasChanges=!0,this.mainGroupsList=[...i],this.guidesMap.set(this.mainGuide.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===k.main?i.name:i.label,order:i.name===k.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,_.info(this.getMessage("snkFormConfig.info.successfullyConfigSaved"),{iconName:"check"}),this.configChange.emit(t)}buildConfigToSave(){const i=h.copy(this._formConfig);return i.tabs=this.getTabsToSave(),i.fields=L(this.guidesMap),i.defaultConfiguration=this.getIsDefaultConfig(),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,o=null!==(t=this.guidesMap.get(e))&&void 0!==t?t:[],a=[];o.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.ensureSelectedGuide()),this.hasChanges=!0}handleGuideListChanged({detail:i}){this.hasChanges=!0,this.guidesList=[...i]}handleGuideRenamed({detail:i}){var t;const s=this.selectedGuide;if(!(null==s?void 0:s.name))return;const e=s.name,o=null!==(t=this.guidesMap.get(e))&&void 0!==t?t:[],a=N(o,i);this.guidesMap.delete(e),this.guidesMap.set(i,a);const n={name:i,label:i,visible:s.visible,order:s.order};this.guidesList=[...this.guidesList.map((i=>i.name===e?n:i))],this.groupsList=[...a],this.selectedGuide=n,this.hasChanges=!0}handleCreateNewGuide(){const i=M(this.guidesList,this.getMessage.bind(this)),t={name:i,label:i,visible:!0,order:this.guidesList.length+1},s={name:w.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=l.getContextValue("__SNK__APPLICATION__");this.messagesBuilder=i.messagesBuilder}}async componentWillLoad(){this.loadFormConfig(),await this.initializeUserConfig()}render(){var i;return s(e,null,s("snk-dynaform-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:"form-config-body"},s("div",{class:"form-config-layout"},s("snk-dynaform-fields-selector",{dataUnit:this.dataUnit,availableFields:this.availableFields,onFieldListChanged:this.handleAvailableFieldListChanged.bind(this),messagesBuilder:this.messagesBuilder}),s("div",{class:"main-editing-area"},this.mainGuide&&s("div",{class:"main-fields-section"},s("snk-dynaform-fields-layout",{ref:i=>this.refMainFieldsLayout=i,selectedGuide:this.mainGuide,guideNames:this.getGuideNames(),groupsList:this.mainGroupsList,messagesBuilder:this.messagesBuilder,dataUnit:this.dataUnit,isMainSection:!0,onLayoutChanged:this.handleMainLayoutChanged.bind(this),onSetFieldListAsAvailable:this.handleSetFieldListAsAvailable.bind(this)})),s("snk-dynaform-guides-configurator",{messagesBuilder:this.messagesBuilder,guidesList:this.guidesList,selectedGuide:this.selectedGuide,mainGuideName:null===(i=this.mainGuide)||void 0===i?void 0:i.name,onGuideSelected:this.handleSelectGuide.bind(this),onGuideListChanged:this.handleGuideListChanged.bind(this),onCreateNewGuide:this.handleCreateNewGuide.bind(this),onGuideDeleted:this.handleGuideDeleted.bind(this)}),s("snk-dynaform-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)})))))}static get watchers(){return{selectedGuide:["observeSelectedGuide"],configManager:["observeConfigManager"]}}};R.style='.sc-snk-dynaform-form-config-h{display:flex;flex-direction:column;height:100vh;width:100%;font-family:var(--font-pattern, "Roboto");background:white;color:#2b3a54;--snk-form-config-container-height:calc(100vh - 95px);outline:none}.form-config-body.sc-snk-dynaform-form-config{height:var(--snk-form-config-container-height);overflow:hidden;padding-top:var(--space--12, 12px)}.form-config-layout.sc-snk-dynaform-form-config{display:flex;flex-direction:row;height:100%;gap:20px;align-items:stretch}.main-editing-area.sc-snk-dynaform-form-config{display:flex;flex-direction:column;flex:1;min-width:0;height:100%;overflow:hidden;gap:12px}.main-editing-area.sc-snk-dynaform-form-config>snk-dynaform-fields-layout.sc-snk-dynaform-form-config{flex:1 1 auto;min-height:0;overflow:auto;flex-direction:row}.main-editing-area.sc-snk-dynaform-form-config>snk-dynaform-guides-configurator.sc-snk-dynaform-form-config{flex:0 0 auto}.main-fields-section.sc-snk-dynaform-form-config{flex:0 0 40vh;display:flex;flex-direction:column;min-height:0;overflow:hidden}.guide-header.sc-snk-dynaform-form-config{display:flex;width:100%;padding-bottom:12px;border-bottom:1px solid #dce0e8;height:30px;font-weight:500;font-size:16px}';export{I as snk_dynaform_detail_view,R as snk_dynaform_form_config}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ObjectUtils as t}from"@sankhyalabs/core";import{R as a}from"./p-d7657667.js";class s extends a{getData(a){const s=`cfg://auth/${a}`;return new Promise(((a,e)=>{this.loadResource(s).then((s=>{let e=t.stringToObject(s);e&&"object"==typeof e&&a(e)})).catch((t=>{e(t)}))}))}}var e;!function(t){t.INSERT="I",t.UPDATE="A",t.REMOVE="E",t.SHOW="C",t.CONFIG="F",t.CONFIG_NUMBER="N",t.CLONE="D",t.CONFIG_GRID="G"}(e||(e={}));export{e as A,s as a}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{S as snk_guides_viewer}from"./p-c5889dae.js";import"./p-2c9d0870.js";import"@sankhyalabs/core";import"@sankhyalabs/ezui/dist/collection/utils";import"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-9019a32f.js";import"./p-8d513b64.js";import"./p-13f91e7e.js";import"./p-d7657667.js";import"./p-10d883b0.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";import"./p-3072136e.js";import"./p-0f3698af.js";import"./p-a73b6b00.js";
|