@snk-libs/sankhya-ds 1.0.0-dev.47 → 1.0.0-rc.7
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/chart/catalog.json +1 -1
- package/dist/chart/web-types.json +1 -1
- package/dist/code-editor/catalog.json +1 -1
- package/dist/code-editor/web-types.json +1 -1
- package/dist/custom-elements.json +1 -1
- package/dist/data-grid/catalog.json +1 -1
- package/dist/data-grid/cdn/chunks/{data-grid-BLBYtNPV.js → data-grid-xFL6yWNx.js} +2 -2
- package/dist/data-grid/cdn/chunks/{define-Csxzwkt8.js → define-BEFisBI0.js} +1 -1
- package/dist/data-grid/cdn/chunks/{define-VTcPsgZv.js → define-C8PxHM4z.js} +1 -1
- package/dist/data-grid/cdn/chunks/{define-EU1MkDqa.js → define-CFP25HPW.js} +1 -1
- package/dist/data-grid/cdn/chunks/{define-CJKm_-fO.js → define-oIgn67JN.js} +1 -1
- package/dist/data-grid/cdn/sankhya-ds-data-grid.js +1 -1
- package/dist/data-grid/components/data-grid/data-grid.js +1 -1
- package/dist/data-grid/components/data-grid/data-grid.styles.js +1 -1
- package/dist/data-grid/docs/components/data-grid.md +54 -53
- package/dist/data-grid/docs/llms-full.txt +54 -53
- package/dist/data-grid/web-types.json +1 -1
- package/dist/icons/catalog.json +1 -1
- package/dist/icons/web-types.json +1 -1
- package/dist/rich-text/catalog.json +1 -1
- package/dist/rich-text/web-types.json +1 -1
- package/dist/tokens/tokens.json +1 -1
- package/dist/ui/catalog.json +1 -1
- package/dist/ui/custom-elements.json +1 -1
- package/dist/ui/web-types.json +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{styles as e}from"./data-grid.styles.js";import{formatValue as t,parseValue as n}from"./core/format.js";import{SELECT_ID as r,cellText as i,fullHeader as a,normalizeColumns as o,selectColumnDef as s}from"./core/columns.js";import{downloadText as c,parseDelimited as l,serialize as u}from"./core/clipboard.js";import{editorFor as d,fromEditorText as f,todayIso as p}from"./core/editors.js";import{createField as m,fieldValue as h}from"./core/editor-fields.js";import{fold as g,hasFilter as _,prepareRows as v}from"./core/prepare.js";import{sortDirectionLabels as y,sortMenuLabels as ee}from"../grid-config/sort-labels.js";import{BlockCache as te}from"./core/block-cache.js";import{rowWindow as b,scrollTopForRow as x}from"./core/row-window.js";import{inRange as S,navigate as C,normalizeRange as w}from"./core/navigation.js";import{AGGREGATE_KINDS as ne,OPTION_ITEMS as re,matchColumns as ie,moveGroup as ae,orderNeighbour as oe,parseOptionItems as se,setAggregate as ce,shiftGroup as le,toggleGroup as ue,withAggregates as de}from"./core/options.js";import{defaultLayout as fe,mergeLayout as T,moveColumn as E,pinColumn as pe,regionOf as me,setHidden as D,toggleSort as he}from"./core/layout.js";import{applyLayout as O,createGridTable as ge,setTableData as _e}from"./core/table.js";import{arrowDown as ve,arrowUp as ye,check as be,chevronDown as xe,chevronRight as Se,close as k,columns as Ce,ellipsisVertical as A,funnel as we,grip as Te,list as Ee,pin as De,rightIndent as Oe,rows3 as ke,search as j,sortAmountDown as Ae,sortAmountUp as je}from"./core/icons.js";import{afterAnimation as M,flip as N,ghostOf as P,measure as F,motionTiming as Me,reducedMotion as Ne,registerColorProperty as I}from"./core/motion.js";import{html as L,nothing as R}from"lit";import{property as z}from"lit/decorators.js";import{repeat as B}from"lit/directives/repeat.js";import{live as V}from"lit/directives/live.js";import{MESA_2026_11_DEPRECATION as Pe,RODADA_2026_11_18_DEPRECATION as Fe,deprecated as Ie,devWarn as H,warnA11y as Le,warnInvalid as Re}from"@snk-libs/sankhya-ds/ui/internal/dev";import{Virtualizer as ze,defaultRangeExtractor as Be,elementScroll as Ve,observeElementOffset as He,observeElementRect as Ue}from"@tanstack/virtual-core";import{SankhyaDsElement as U}from"@snk-libs/sankhya-ds/ui/internal/sankhya-ds-element";import{cloneData as We}from"@snk-libs/sankhya-ds/ui/internal/clone";import{msg as W,str as G}from"@snk-libs/sankhya-ds/ui/internal/localize";import{HasSlotController as Ge}from"@snk-libs/sankhya-ds/ui/internal/slot";import{OverflowTipController as Ke}from"@snk-libs/sankhya-ds/ui/internal/overflow-tip";import{pageDensity as qe}from"@snk-libs/sankhya-ds/ui/internal/density";import{cssStyle as K}from"@snk-libs/sankhya-ds/ui/internal/css-style";import{safeFileName as Je}from"@snk-libs/sankhya-ds/ui/internal/filename";import{layoutScale as Ye}from"@snk-libs/sankhya-ds/ui/internal/box";import{loadDropdownMenu as Xe}from"@snk-libs/sankhya-ds/ui/internal/dropdown-menu-loader";import{whenIdle as Ze}from"@snk-libs/sankhya-ds/ui/internal/lazy-loader";import{AreaMotionController as Qe,SlotMotionController as $e,cssTimeMs as et,fade as tt}from"@snk-libs/sankhya-ds/ui/internal/motion";var q=function(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else(d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0},J=function(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0},nt,rt=()=>nt??=import(`@snk-libs/sankhya-ds/ui/components/column-filter/define`),Y=()=>!!customElements.get(`sankhya-ds-dropdown-menu`),it,at=()=>it??=import(`@snk-libs/sankhya-ds/ui/components/export-dialog/define`);I(`--_sankhya-ds-grid-tint`),I(`--_sankhya-ds-kebab-mask`);var ot=[`compact`,`default`,`comfortable`],st=[`none`,`down`,`right`],ct=[`cell`,`row`],lt=[`hover`,`always`],ut=640,dt=[`sankhya-ds-change`,`sankhya-ds-input`,`sankhya-ds-revert`,`sankhya-ds-open`,`sankhya-ds-close`,`sankhya-ds-invalid`],ft=32,pt=40,mt=50,ht=(e,t,n)=>`width:${e}px;${t===`start`?`left:${n}px`:t===`end`?`right:${n}px`:n?`margin-inline-start:${n}px`:``}`,X=e=>e.dataset.key,gt=`.rows > [data-row-key]`,_t=e=>e.dataset.rowKey,vt=[`SANKHYA-DS-BUTTON`,`SANKHYA-DS-SPLIT-BUTTON`,`SANKHYA-DS-CIRCLE-BUTTON`,`SANKHYA-DS-MENU-BUTTON`],yt=`sankhya-ds-overflow:`,bt=8,xt=260,St=e=>e.charAt(0).toLocaleLowerCase(`pt-BR`)+e.slice(1),Ct=[200,240,280],wt=8,Tt=2,Et=[`create`,`clear`,`retry`,`other`],Dt=`a[href], button, input:not([type="hidden"]), sankhya-ds-circle-button, sankhya-ds-button, sankhya-ds-switch, sankhya-ds-checkbox, [tabindex]:not([tabindex="-1"])`,Ot=[`subtle`,`strong`,`none`];function Z(e,t){return typeof e==`function`?e(t):e}function kt(e){e&&(e.dataset.dismissed=``,e.hidePopover())}var At=16,jt=480,Mt=2e5,Nt=16,Pt=4,Q=e=>e.reduce((e,t)=>e+t.getSize(),0),Ft=(()=>{let I=U,nt,it=[],Ft=[],It,Lt=[],Rt=[],zt,Bt=[],Vt=[],Ht,Ut=[],Wt=[],Gt,Kt=[],qt=[],Jt,Yt=[],Xt=[],Zt,Qt=[],$t=[],en,tn=[],nn=[],rn,an=[],on=[],sn,cn=[],ln=[],un,dn=[],fn=[],pn,mn=[],hn=[],gn,_n=[],vn=[],yn,bn=[],xn=[],Sn,Cn=[],wn=[],Tn,En=[],Dn=[],On,kn=[],An=[],jn,Mn=[],Nn=[],Pn,Fn=[],In=[],Ln,Rn=[],zn=[],Bn,Vn=[],Hn=[],Un,Wn=[],Gn=[],Kn,qn=[],Jn=[],Yn,Xn=[],Zn=[],Qn,$n=[],er=[],tr,nr=[],rr=[],ir,ar=[],or=[],sr,cr=[],lr=[],ur,dr=[],fr=[],pr,mr=[],hr=[],gr,_r=[],vr=[],yr,br=[],xr=[],Sr,Cr=[],wr=[],Tr,Er=[],Dr=[],Or,kr=[],Ar=[],jr,Mr=[],Nr=[],Pr,Fr=[],Ir=[],Lr,Rr=[],zr=[],Br,Vr=[],Hr=[],Ur,Wr=[],Gr=[],Kr,qr=[],Jr=[],Yr,Xr=[],Zr=[],Qr,$r=[],ei=[],ti,ni=[],ri=[];return class U extends I{static{let e=typeof Symbol==`function`&&Symbol.metadata?Object.create(I[Symbol.metadata]??null):void 0;nt=[z({attribute:!1})],It=[z({attribute:!1})],zt=[z({attribute:!1})],Ht=[z({type:Number,attribute:`block-size`})],Gt=[z({reflect:!0})],Jt=[z({attribute:`row-key`})],Zt=[z()],en=[z({type:Boolean,reflect:!0})],rn=[z({type:Boolean,reflect:!0,attribute:`column-select`})],sn=[z({attribute:!1})],un=[z({type:Boolean,attribute:!1})],pn=[z({attribute:!1})],gn=[z({attribute:!1})],yn=[z({attribute:!1})],Sn=[z({attribute:!1})],Tn=[z({attribute:!1})],On=[z({attribute:!1})],jn=[z({attribute:!1})],Pn=[z({attribute:!1})],Ln=[z({attribute:!1})],Bn=[z({type:Boolean,reflect:!0})],Un=[z({type:Boolean,attribute:`row-clickable`,reflect:!0})],Kn=[z({type:Boolean,reflect:!0})],Yn=[z({type:Boolean,reflect:!0,attribute:`auto-height`})],Qn=[z({type:Number,attribute:`max-rows`})],tr=[z({reflect:!0,attribute:`vertical-dividers`,converter:{fromAttribute:e=>e===``||e===`true`?`strong`:e}})],ir=[z({type:Boolean,reflect:!0,attribute:`no-stripes`})],sr=[z({reflect:!0,attribute:`column-menu`})],ur=[z({attribute:`enter-navigation`})],pr=[z({attribute:!1})],gr=[z({type:Boolean,reflect:!0,attribute:`no-options`})],yr=[z({type:Boolean,reflect:!0,attribute:`columns-locked`})],Sr=[z({type:Boolean,reflect:!0})],Tr=[z({type:Boolean,reflect:!0})],Or=[z({type:Boolean,reflect:!0})],jr=[z({attribute:`option-items`,converter:{fromAttribute:se,toAttribute:e=>e.join(` `)}})],Pr=[z({attribute:`empty-heading`})],Lr=[z({attribute:`empty-description`})],Br=[z({attribute:`empty-action-label`})],Ur=[z({attribute:`empty-action-type`})],Kr=[z({attribute:`empty-icon`})],Yr=[z({type:Boolean,reflect:!0,attribute:`filter-row`})],Qr=[z({type:Boolean,reflect:!0,attribute:`dynamic-mode`})],ti=[z({attribute:`edit-mode`})],q(this,null,nt,{kind:`accessor`,name:`columns`,static:!1,private:!1,access:$(`columns`),metadata:e},it,Ft),q(this,null,It,{kind:`accessor`,name:`rows`,static:!1,private:!1,access:$(`rows`),metadata:e},Lt,Rt),q(this,null,zt,{kind:`accessor`,name:`dataSource`,static:!1,private:!1,access:$(`dataSource`),metadata:e},Bt,Vt),q(this,null,Ht,{kind:`accessor`,name:`blockSize`,static:!1,private:!1,access:$(`blockSize`),metadata:e},Ut,Wt),q(this,null,Gt,{kind:`accessor`,name:`density`,static:!1,private:!1,access:$(`density`),metadata:e},Kt,qt),q(this,null,Jt,{kind:`accessor`,name:`rowKey`,static:!1,private:!1,access:$(`rowKey`),metadata:e},Yt,Xt),q(this,null,Zt,{kind:`accessor`,name:`label`,static:!1,private:!1,access:$(`label`),metadata:e},Qt,$t),q(this,null,en,{kind:`accessor`,name:`selectable`,static:!1,private:!1,access:$(`selectable`),metadata:e},tn,nn),q(this,null,rn,{kind:`accessor`,name:`columnSelect`,static:!1,private:!1,access:$(`columnSelect`),metadata:e},an,on),q(this,null,sn,{kind:`accessor`,name:`selected`,static:!1,private:!1,access:$(`selected`),metadata:e},cn,ln),q(this,null,un,{kind:`accessor`,name:`allMatching`,static:!1,private:!1,access:$(`allMatching`),metadata:e},dn,fn),q(this,null,pn,{kind:`accessor`,name:`sort`,static:!1,private:!1,access:$(`sort`),metadata:e},mn,hn),q(this,null,gn,{kind:`accessor`,name:`config`,static:!1,private:!1,access:$(`config`),metadata:e},_n,vn),q(this,null,yn,{kind:`accessor`,name:`saveConfig`,static:!1,private:!1,access:$(`saveConfig`),metadata:e},bn,xn),q(this,null,Sn,{kind:`accessor`,name:`filter`,static:!1,private:!1,access:$(`filter`),metadata:e},Cn,wn),q(this,null,Tn,{kind:`accessor`,name:`groupBy`,static:!1,private:!1,access:$(`groupBy`),metadata:e},En,Dn),q(this,null,On,{kind:`accessor`,name:`subRows`,static:!1,private:!1,access:$(`subRows`),metadata:e},kn,An),q(this,null,jn,{kind:`accessor`,name:`rowKind`,static:!1,private:!1,access:$(`rowKind`),metadata:e},Mn,Nn),q(this,null,Pn,{kind:`accessor`,name:`rowStatus`,static:!1,private:!1,access:$(`rowStatus`),metadata:e},Fn,In),q(this,null,Ln,{kind:`accessor`,name:`expanded`,static:!1,private:!1,access:$(`expanded`),metadata:e},Rn,zn),q(this,null,Bn,{kind:`accessor`,name:`readonly`,static:!1,private:!1,access:$(`readonly`),metadata:e},Vn,Hn),q(this,null,Un,{kind:`accessor`,name:`rowClickable`,static:!1,private:!1,access:$(`rowClickable`),metadata:e},Wn,Gn),q(this,null,Kn,{kind:`accessor`,name:`loading`,static:!1,private:!1,access:$(`loading`),metadata:e},qn,Jn),q(this,null,Yn,{kind:`accessor`,name:`autoHeight`,static:!1,private:!1,access:$(`autoHeight`),metadata:e},Xn,Zn),q(this,null,Qn,{kind:`accessor`,name:`maxRows`,static:!1,private:!1,access:$(`maxRows`),metadata:e},$n,er),q(this,null,tr,{kind:`accessor`,name:`verticalDividers`,static:!1,private:!1,access:$(`verticalDividers`),metadata:e},nr,rr),q(this,null,ir,{kind:`accessor`,name:`noStripes`,static:!1,private:!1,access:$(`noStripes`),metadata:e},ar,or),q(this,null,sr,{kind:`accessor`,name:`columnMenu`,static:!1,private:!1,access:$(`columnMenu`),metadata:e},cr,lr),q(this,null,ur,{kind:`accessor`,name:`enterNavigation`,static:!1,private:!1,access:$(`enterNavigation`),metadata:e},dr,fr),q(this,null,pr,{kind:`accessor`,name:`columnActions`,static:!1,private:!1,access:$(`columnActions`),metadata:e},mr,hr),q(this,null,gr,{kind:`accessor`,name:`noOptions`,static:!1,private:!1,access:$(`noOptions`),metadata:e},_r,vr),q(this,null,yr,{kind:`accessor`,name:`columnsLocked`,static:!1,private:!1,access:$(`columnsLocked`),metadata:e},br,xr),q(this,null,Sr,{kind:`accessor`,name:`searchable`,static:!1,private:!1,access:$(`searchable`),metadata:e},Cr,wr),q(this,null,Tr,{kind:`accessor`,name:`refreshable`,static:!1,private:!1,access:$(`refreshable`),metadata:e},Er,Dr),q(this,null,Or,{kind:`accessor`,name:`exportable`,static:!1,private:!1,access:$(`exportable`),metadata:e},kr,Ar),q(this,null,jr,{kind:`accessor`,name:`optionItems`,static:!1,private:!1,access:$(`optionItems`),metadata:e},Mr,Nr),q(this,null,Pr,{kind:`accessor`,name:`emptyHeading`,static:!1,private:!1,access:$(`emptyHeading`),metadata:e},Fr,Ir),q(this,null,Lr,{kind:`accessor`,name:`emptyDescription`,static:!1,private:!1,access:$(`emptyDescription`),metadata:e},Rr,zr),q(this,null,Br,{kind:`accessor`,name:`emptyActionLabel`,static:!1,private:!1,access:$(`emptyActionLabel`),metadata:e},Vr,Hr),q(this,null,Ur,{kind:`accessor`,name:`emptyActionType`,static:!1,private:!1,access:$(`emptyActionType`),metadata:e},Wr,Gr),q(this,null,Kr,{kind:`accessor`,name:`emptyIcon`,static:!1,private:!1,access:$(`emptyIcon`),metadata:e},qr,Jr),q(this,null,Yr,{kind:`accessor`,name:`filterRow`,static:!1,private:!1,access:$(`filterRow`),metadata:e},Xr,Zr),q(this,null,Qr,{kind:`accessor`,name:`dynamicMode`,static:!1,private:!1,access:$(`dynamicMode`),metadata:e},$r,ei),q(this,null,ti,{kind:`accessor`,name:`editMode`,static:!1,private:!1,access:$(`editMode`),metadata:e},ni,ri),e&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})}static css=e;static enums={density:ot,enterNavigation:st,editMode:ct,columnMenu:lt,emptyActionType:Et,verticalDividers:Ot};#e=J(this,it,[]);get columns(){return this.#e}set columns(e){this.#e=e}#t=(J(this,Ft),J(this,Lt,[]));get rows(){return this.#t}set rows(e){this.#t=e}#n=(J(this,Rt),J(this,Bt,void 0));get dataSource(){return this.#n}set dataSource(e){this.#n=e}#r=(J(this,Vt),J(this,Ut,100));get blockSize(){return this.#r}set blockSize(e){this.#r=e}#i=(J(this,Wt),void 0);#a=J(this,Kt,void 0);get density(){return this.#a}set density(e){this.#a=e}#o=(J(this,qt),J(this,Yt,`id`));get rowKey(){return this.#o}set rowKey(e){this.#o=e}#s=(J(this,Xt),J(this,Qt,``));get label(){return this.#s}set label(e){this.#s=e}#c=(J(this,$t),J(this,tn,!1));get selectable(){return this.#c}set selectable(e){this.#c=e}#l=(J(this,nn),J(this,an,!1));get columnSelect(){return this.#l}set columnSelect(e){this.#l=e}#u=(J(this,on),J(this,cn,[]));get selected(){return this.#u}set selected(e){this.#u=e}#d=(J(this,ln),J(this,dn,!1));get allMatching(){return this.#d}set allMatching(e){this.#d=e}#f=(J(this,fn),J(this,mn,[]));get sort(){return this.#f}set sort(e){this.#f=e}#p=(J(this,hn),J(this,_n,void 0));get config(){return this.#p}set config(e){this.#p=e}#m=(J(this,vn),J(this,bn,void 0));get saveConfig(){return this.#m}set saveConfig(e){this.#m=e}#h=(J(this,xn),J(this,Cn,{}));get filter(){return this.#h}set filter(e){this.#h=e}#g=(J(this,wn),J(this,En,[]));get groupBy(){return this.#g}set groupBy(e){this.#g=e}#_=(J(this,Dn),J(this,kn,void 0));get subRows(){return this.#_}set subRows(e){this.#_=e}#v=(J(this,An),J(this,Mn,void 0));get rowKind(){return this.#v}set rowKind(e){this.#v=e}#y=(J(this,Nn),J(this,Fn,void 0));get rowStatus(){return this.#y}set rowStatus(e){this.#y=e}#b=(J(this,In),J(this,Rn,{}));get expanded(){return this.#b}set expanded(e){this.#b=e}#x=(J(this,zn),J(this,Vn,!1));get readonly(){return this.#x}set readonly(e){this.#x=e}#S=(J(this,Hn),J(this,Wn,!1));get rowClickable(){return this.#S}set rowClickable(e){this.#S=e}#C=(J(this,Gn),J(this,qn,!1));get loading(){return this.#C}set loading(e){this.#C=e}#w=(J(this,Jn),J(this,Xn,!1));get autoHeight(){return this.#w}set autoHeight(e){this.#w=e}#T=(J(this,Zn),J(this,$n,50));get maxRows(){return this.#T}set maxRows(e){this.#T=e}#E=(J(this,er),J(this,nr,`subtle`));get verticalDividers(){return this.#E}set verticalDividers(e){this.#E=e}#D=(J(this,rr),J(this,ar,!1));get noStripes(){return this.#D}set noStripes(e){this.#D=e}#O=(J(this,or),J(this,cr,`hover`));get columnMenu(){return this.#O}set columnMenu(e){this.#O=e}#k=(J(this,lr),J(this,dr,`none`));get enterNavigation(){return this.#k}set enterNavigation(e){this.#k=e}#A=(J(this,fr),J(this,mr,[]));get columnActions(){return this.#A}set columnActions(e){this.#A=e}#j=(J(this,hr),J(this,_r,!1));get noOptions(){return this.#j}set noOptions(e){this.#j=e}#M=(J(this,vr),J(this,br,!1));get columnsLocked(){return this.#M}set columnsLocked(e){this.#M=e}#N=(J(this,xr),J(this,Cr,!1));get searchable(){return this.#N}set searchable(e){this.#N=e}#P=(J(this,wr),J(this,Er,!1));get refreshable(){return this.#P}set refreshable(e){this.#P=e}#F=(J(this,Dr),J(this,kr,!1));get exportable(){return this.#F}set exportable(e){this.#F=e}#I=(J(this,Ar),J(this,Mr,[...re]));get optionItems(){return this.#I}set optionItems(e){this.#I=e}#L=(J(this,Nr),J(this,Fr,``));get emptyHeading(){return this.#L}set emptyHeading(e){this.#L=e}#R=(J(this,Ir),J(this,Rr,``));get emptyDescription(){return this.#R}set emptyDescription(e){this.#R=e}#z=(J(this,zr),J(this,Vr,``));get emptyActionLabel(){return this.#z}set emptyActionLabel(e){this.#z=e}#B=(J(this,Hr),J(this,Wr,`create`));get emptyActionType(){return this.#B}set emptyActionType(e){this.#B=e}#V=(J(this,Gr),J(this,qr,``));get emptyIcon(){return this.#V}set emptyIcon(e){this.#V=e}#H=(J(this,Jr),J(this,Xr,!1));get filterRow(){return this.#H}set filterRow(e){this.#H=e}#U=(J(this,Zr),J(this,$r,!1));get dynamicMode(){return this.#U}set dynamicMode(e){this.#U=e}#W=(J(this,ei),J(this,ni,`cell`));get editMode(){return this.#W}set editMode(e){this.#W=e}#G=(J(this,ri),o([]));#K=ge({columns:[],data:[],getRowId:()=>``});#q=fe([]);#J=!1;#Y=!1;#X=null;#Z=!1;#Q={rows:[],children:/* @__PURE__ */ new WeakMap};#$=[];#ee;#te;#ne=/* @__PURE__ */ new Set;#re=`none`;#ie=!1;#ae=!1;#oe=0;#se;#ce=200;#le=[];#ue=0;#de=0;#fe=0;#pe=new Ge(this,`footer`,`actions`,`selection-actions`,`more-actions`,`custom-actions`,`pagination`);#me=new $e(this,`actions`,`selection-actions`);#he=new Qe(this,{target:()=>this.renderRoot.querySelector(`.toolbar`),shown:()=>this.#mi()});#ge=0;#_e=-1;#ve={start:0,end:0,top:0,height:0,scale:1,page:1};#ye=[];#be=[];#xe=[];#Se=[];#Ce=``;#we;#Te;#Ee=0;#De=new ResizeObserver(()=>{let e=this.#ft;this.#de=e.clientHeight,this.#fe=e.clientWidth,this.#Ee=Math.max(0,e.offsetHeight-e.clientHeight),this.#ct=this.offsetWidth<ut,this.requestUpdate()});#Oe=null;#ke=!1;#Ae=null;#je=null;#Me=null;#Ne=null;#Pe=!1;#Fe=null;#Ie=!1;#Le={row:0,col:0};#Re=!1;#ze=``;#Be=!1;#Ve=!1;#He=``;#Ue=0;#We=null;#Ge=e=>{let t=this.renderRoot.querySelector(`[role="columnheader"][data-id="${CSS.escape(this.#We??``)}"]`);t&&e.composedPath().includes(t)||(this.#We=null,document.removeEventListener(`pointerdown`,this.#Ge,!0),this.requestUpdate())};#Ke=``;#qe=null;#Je=`actions`;#Ye=!1;#Xe=null;#Ze=null;#Qe=null;#$e=null;#et=!1;#tt=/* @__PURE__ */ new Map;#nt=/* @__PURE__ */ new Set;#rt=null;#it=null;#at=!1;#ot=!1;#st=null;#ct=!1;#lt=null;#ut=!1;#dt=null;constructor(){super(),this.#we=new ze(this.#ln())}get#ft(){return this.renderRoot.querySelector(`.viewport`)}get rowCount(){return this.dataSource?this.#ee?.total??0:this.#$.length}get fitRows(){return this.#pt}#pt=0;#mt=0;#ht(){return this.#de?Math.max(1,Math.floor(this.#on()/this.#ue)):0}#gt(){this.#mt||this.#ht()===this.#pt||(this.#mt=requestAnimationFrame(()=>{this.#mt=0;let e=this.#ht();e&&e!==this.#pt&&(this.#pt=e,this.emit(`sankhya-ds-fit-rows`,{rows:e}))}))}#_t;connectedCallback(){super.connectedCallback(),this.addEventListener(`keydown`,this.#Gi),Y()||(this.addEventListener(`pointerenter`,this.#Bi),this.addEventListener(`focusin`,this.#Bi),this.#_t??=Ze(()=>{this.#_t=void 0,this.#Bi()})),this.#Te=this.#we._didMount(),this.#ft&&(this.#De.observe(this.#ft),this.#De.observe(this))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`keydown`,this.#Gi),this.removeEventListener(`pointerenter`,this.#Bi),this.removeEventListener(`focusin`,this.#Bi),this.#_t?.(),this.#_t=void 0,this.#Te?.(),this.#De.disconnect(),cancelAnimationFrame(this.#mt),this.#mt=0,document.removeEventListener(`pointerdown`,this.#Ge,!0),window.removeEventListener(`blur`,this.#kt),clearTimeout(this.#br),clearTimeout(this.#se)}getLayout(){return We({...this.#q,sort:this.sort})}setConfigurator(e,t){if(t){if(this.renderRoot.contains(e))return;this.#X=e}else this.#X===e&&(this.#X=null)}async#vt(){this.#X?this.#X.show():(this.#Z||(await import(`../grid-config/define.js`),this.#Z=!0,this.requestUpdate(),await this.updateComplete),this.renderRoot.querySelector(`.own-config`).show())}#yt=e=>e.stopPropagation();setLayout(e){this.#Pt=!0;let t=T(this.#q,{...e,sort:e.sort??this.sort},this.#St());this.#Et(t),this.#Ct(t)}getSelectedRange(){return this.#Me?w(this.#Me.anchor,this.#Me.focus):null}exportCsv({filename:e=`dados.csv`,download:t=!0,columns:n,rows:r=`all`}={}){let o=n?n.flatMap(e=>this.#G.byId.get(e)??[]):this.#Se.flatMap(e=>{let t=this.#G.byId.get(e.id);return t&&!t.def.actions?[t]:[]}),s=[];if(this.dataSource)H(this,`export-server`,`exportCsv() no modelo servidor exporta só as linhas carregadas; gere o arquivo completo no servidor.`),s.push(...this.#ee.loadedRows());else{let e=t=>{for(let n of t)s.push(n),e(this.#Q.children.get(n)??[])};e(this.#Q.rows)}let l=new Set(this.selected),d=r===`selected`?s.filter(e=>l.has(String(e[this.rowKey]))):s,f=[o.map(e=>a(e,this.#G.groups)),...d.map(e=>o.map(t=>i(t,t.accessor(e),e)))],p=`\ufeff${u(f,`;`,{neutralizeFormulas:!0})}`,m=`${Je(e,{fallback:`dados`,max:100}).replace(/\.csv$/i,``)}.csv`;return t&&c(p,m,`text/csv;charset=utf-8`),p}expandAll(){this.expanded=!0}collapseAll(){this.expanded={}}refresh(){this.#ee=void 0,this.requestUpdate()}scrollToRow(e){let t=this.#ft,n=this.#on(),r=this.#an()?this.#ue:0,i=this.#xt()&&parseFloat(getComputedStyle(t).scrollPaddingBlockEnd)||0,a=Math.max(0,i-r),o=x(e,this.#ue,t.scrollTop,n-a>=this.#ue?n-a:n,this.#ve.scale);o!==null&&(t.scrollTop=o)}#bt(){let e=this.#ta&&this.selected===this.#na;return this.selectable&&this.selected.length>1&&!e}#xt(){let e=this.#bt();return this.#ft?.toggleAttribute(`data-feedback`,e),e}scrollToColumn(e){let t=this.#Se.findIndex(t=>t.id===e);t<0?H(this,`scroll-column:${e}`,`scrollToColumn("${e}"): a coluna não existe ou está oculta.`):this.#gn(t,!0)}async editCell(e,t){await this.updateComplete;let n=-1;if(this.dataSource)for(let t=this.#ve.start;t<this.#ve.end&&n<0;t++)this.#uo(t).id===e&&(n=t);else n=this.#$.findIndex(t=>t.id===e);let r=this.#Se.findIndex(e=>e.id===t);return n<0||r<0?(H(this,`edit-cell:${e}:${t}`,`editCell("${e}", "${t}"): linha ou coluna não encontrada.`),!1):(this.#hn({row:n,col:r}),this.#Gn(n,r))}async revealRow(e,{focus:t=!1}={}){await this.updateComplete;let n=this.dataSource?Array.from({length:this.rowCount},(e,t)=>t).find(t=>this.#ee.get(t)&&this.#uo(t).id===e)??-1:this.#$.findIndex(t=>t.id===e);if(n<0)return H(this,`reveal-row:${e}`,`revealRow("${e}"): linha não encontrada.`),!1;let r=Math.max(0,this.#Le.col);return this.scrollToRow(n),this.#Le={row:n,col:r},this.#Re=t,this.requestUpdate(),await this.updateComplete,!0}renderBarStart(){return R}focus(e){let t=this.hasUpdated?this.#mn():null;t?t.focus(e):super.focus(e)}#St(){return new Set(this.#G.leaves.map(e=>e.id))}#Ct(e){this.#q=e,this.#J=!0,O(this.#K,e,this.selectable,this.#Dr),JSON.stringify(e.sort)!==JSON.stringify(this.sort)&&(this.sort=e.sort),e.groupBy.join()!==this.groupBy.join()&&(this.groupBy=e.groupBy),this.requestUpdate()}#wt(){this.#Y=!1;let e=this.#Tt(this.config);this.#Et(e),this.#q=e,this.#J=!0,this.#ut&&(this.#ut=!1,this.#Jt()),O(this.#K,this.#q,this.selectable,this.#Dr),JSON.stringify(this.#q.sort)!==JSON.stringify(this.sort)&&(this.sort=this.#q.sort)}#Tt(e){let t=this.#G.byId,n=e.hidden?.filter(e=>t.get(e)?.hideable!==!1);n&&n.length!==e.hidden.length&&H(this,`config-hideable`,`config.hidden: colunas com hideable: false continuam visíveis.`),n&&this.#G.leaves.every(e=>n.includes(e.id))&&(H(this,`config-all-hidden`,`config.hidden oculta todas as colunas; a configuração de colunas ocultas foi ignorada.`),n=void 0);let r=e.sort?.filter(e=>t.get(e.id)?.sortable!==!1);return r&&r.length!==e.sort.length&&H(this,`config-sortable`,`config.sort: colunas com sortable: false foram ignoradas na ordenação.`),T(this.#q,{order:e.order,hidden:n,sort:r,...e.aggregates?{aggregates:e.aggregates}:{}},this.#St())}applyUserConfig(e){let t=JSON.stringify(this.sort);this.#Pt=!0,this.#Dt(this.#Tt(e)),JSON.stringify(this.sort)!==t&&this.emit(`sankhya-ds-sort-change`,{sort:this.sort})}#Et(e){JSON.stringify(e.aggregates)!==JSON.stringify(this.#q.aggregates)&&(this.#ut=!0,this.#et=!0)}#Dt(e){if(this.columnsLocked){let{order:t,hidden:n,pinned:r}=this.#q;e={...e,order:t,hidden:n,pinned:r}}this.#Et(e),this.#Ct(e),this.emit(`sankhya-ds-layout-change`,{layout:this.getLayout()})}update(e){let t=this.renderRoot,n=[...t.querySelectorAll(`.menu, .cell-error`)].filter(e=>!(`ghosted`in e.dataset)&&(e.matches(`:popover-open`)||`dismissed`in e.dataset)),r=[...t.querySelectorAll(`[data-flip]`)],i=r.map(e=>({el:e,parent:e.parentElement,zone:e.closest(`.zone`),next:e.nextElementSibling})),a=F(r,X),o=this.#at;this.#at=!1;let s=o?F(t.querySelectorAll(gt),_t):null;super.update(e);let c=Me(this);for(let e of n)e.isConnected||this.#At(e);for(let{el:e,parent:t,zone:n,next:r}of i){if(e.isConnected||e.dataset.flip!==`exit`)continue;let i=t.isConnected?t:n?.isConnected?n:null;i&&this.#Mt(e,i,r?.parentElement===i?r:null)}r.length&&N(a,t.querySelectorAll(`[data-flip]`),X,c),s&&N(s,t.querySelectorAll(gt),_t,c)}#Ot=e=>{let t=e.target;if(e.newState!==`closed`||(window.removeEventListener(`blur`,this.#kt),`ghosted`in t.dataset))return;t.dataset.ghosted=``;let n=P(t);requestAnimationFrame(()=>this.isConnected&&this.#jt(n))};#kt=()=>{for(let e of this.renderRoot.querySelectorAll(`.menu:popover-open`))e.closest(`.ghosts`)||e.hidePopover()};#At(e){this.#jt(P(e))}#jt(e){delete e.dataset.ghosted,e.setAttribute(`popover`,`manual`),this.renderRoot.querySelector(`.ghosts`).append(e),e.showPopover(),M(e,()=>e.remove())}#Mt(e,t,n){let r=P(e);t.insertBefore(r,n),M(r,()=>{let e=[...t.querySelectorAll(`[data-flip]`)],n=F(e,X);r.remove(),N(n,e,X,Me(this))})}#Nt(e,t=!0){let n={value:t};this.#tt.set(e,n),this.updateComplete.then(()=>{let t=()=>{this.#tt.get(e)===n&&(this.#tt.delete(e),e===`filter-row`&&(this.#at=!0),this.requestUpdate())},r=this.renderRoot.querySelector(`[data-leave="${e}"]`);r?M(r,t):t()})}#Pt=!1;#Ft=!1;#It=null;static#Lt(e){try{return JSON.stringify(e,(e,t)=>typeof t==`function`?String(t):t)}catch{return``}}#Rt(e){let t=e.get(`rows`);if(e.has(`rows`)&&t?.length&&this.rows!==t){let e=new Set(t),n=this.rows.slice(0,50);if(n.filter(t=>e.has(t)).length<n.length/2||!n.length)return!0}let n=e.get(`columns`);return e.has(`columns`)&&!!n?.length&&U.#Lt(n)!==U.#Lt(this.columns)}#zt(){let e=this.#ft;if(!e?.offsetWidth)return;let t=P(e);for(let e of[t,...t.querySelectorAll(`[role], [part], [data-row], [data-col], [id]`)])for(let t of[`role`,`part`,`data-row`,`data-col`,`id`])e.removeAttribute(t);this.#It={el:t,top:e.offsetTop,left:e.offsetLeft,width:e.offsetWidth,height:e.offsetHeight,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft}}#Bt(e){let t=this.#ft,n=getComputedStyle(this),r=e=>et(n.getPropertyValue(`--sankhya-ds-duration-${e}`));Object.assign(e.el.style,{position:`absolute`,top:`${e.top}px`,left:`${e.left}px`,width:`${e.width}px`,height:`${e.height}px`,margin:`0`,pointerEvents:`none`,zIndex:`2`}),t.parentElement.append(e.el),e.el.scrollTop=e.scrollTop,e.el.scrollLeft=e.scrollLeft,e.el.animate([{opacity:1},{opacity:0}],{duration:r(`micro`),easing:n.getPropertyValue(`--sankhya-ds-ease-standard`).trim()||`ease`,fill:`forwards`}).finished.catch(()=>void 0).then(()=>e.el.remove()),t.animate([{opacity:0},{opacity:1}],{duration:r(`base`),easing:n.getPropertyValue(`--sankhya-ds-ease-enter`).trim()||`ease`})}willUpdate(e){if(super.willUpdate(e),e.has(`selected`)&&this.hasUpdated&&!(this.selectable&&this.selected.length>0)){let e=document.activeElement;this.#Ut=!!(e&&[...this.querySelectorAll(`:scope > [slot="selection-actions"]`)].some(t=>t.contains(e)))}e.has(`allMatching`)&&this.allMatching&&!this.dataSource&&(H(this,`all-matching-no-data-source`,`allMatching sem dataSource não é suportado: o modo "todos do filtro" é do modelo servidor. Correção: com as linhas na mão, ponha todos os ids em selected.`),this.hasUpdated||(this.allMatching=!1)),e.has(`maxRows`)&&(!Number.isFinite(this.maxRows)||this.maxRows<0)&&Re(this,`max-rows`,this.maxRows,[`0 (sem limite)`,`inteiro positivo`]),(e.has(`maxRows`)||e.has(`autoHeight`))&&!this.autoHeight&&(this.hasAttribute(`max-rows`)||this.maxRows!==50)&&H(this,`max-rows-no-auto-height`,`max-rows só vale com auto-height. Correção: adicione auto-height ou tire max-rows.`),this.allMatching&&(e.has(`filter`)||e.has(`dataSource`)||!this.dataSource||!this.selected.length)&&this.hasUpdated&&(this.allMatching=!1,this.#Wt=this.selected.length>0),e.has(`optionItems`)&&this.optionItems.includes(`select-all`)&&Ie(this,`option-items "select-all"`,{...Fe,replacement:`a caixa do cabeçalho e "Selecionar todos os N registros" da barra de seleção`,ref:`P1-14`}),this.hasUpdated&&!this.#It&&(this.#Pt||this.#Rt(e))&&this.#zt(),this.#Pt=!1,this.#Gt(e),(!this.#ue||e.has(`density`))&&this.#qt();let t=this.#ut||[`columns`,`selectable`,`subRows`].some(t=>e.has(t));this.#ut=!1,e.has(`subRows`)&&this.subRows&&this.dataSource&&H(this,`tree-server`,`dataSource não suporta subRows (árvore no modelo servidor); a árvore é ignorada.`),t&&this.#Jt(),t&&!this.readonly&&this.#G.leaves.some(e=>e.def.editable&&typeof e.def.editor!=`object`)&&this.#Zn(),e.has(`config`)&&(this.#Y=!!this.config),this.#Y&&this.#G.leaves.length&&this.#wt(),e.has(`groupBy`)&&this.groupBy.join()!==this.#q.groupBy.join()&&(this.#q=T(this.#q,{groupBy:this.groupBy},this.#St()),O(this.#K,this.#q,this.selectable,this.#Dr)),e.has(`sort`)&&(this.#q={...this.#q,sort:this.sort}),(t||e.has(`expanded`))&&this.#K.setExpanded(this.expanded),[`rows`,`sort`,`filter`,`groupBy`,`dataSource`].some(t=>e.has(t))&&(this.#Me=null,this.#Fe=null,this.#dt=null);let n=this.dataSource;if((t||[`rows`,`sort`,`filter`,`dataSource`].some(t=>e.has(t)))&&this.#Yt(),n&&(!this.#ee||[`dataSource`,`sort`,`filter`,`blockSize`].some(t=>e.has(t)))&&this.#Xt(n),e.has(`selected`)||e.has(`rows`)||e.has(`filter`)){this.#ne=new Set(this.selected);let t=this.#Qt(),n=t.filter(e=>this.#ne.has(e)).length;this.#re=n===0?`none`:n===t.length?`all`:`some`,e.has(`selected`)&&this.selectable&&this.selected.length>0&&(this.#ze=this.#oi(this.#ei())),e.has(`selected`)&&this.#fi()}let r=e.has(`rows`)&&this.hasUpdated&&!this.#It&&this.#$.length?new Set(this.#$.map(e=>e.id)):null;if(this.#$=this.#K.getRowModel().rows,r){let e=this.#$.filter(e=>!r.has(e.id)).map(e=>e.id);e.length&&(this.#nt=/* @__PURE__ */ new Set([...this.#nt,...e]),setTimeout(()=>this.#nt.clear(),450))}if(this.#rt!==null){let e=this.#$.findIndex(e=>e.id===this.#rt);this.#rt=null,this.#nt=this.#Kt(e),setTimeout(()=>this.#nt.clear(),450)}this.#ye=this.#K.getStartVisibleLeafColumns(),this.#be=this.#K.getCenterVisibleLeafColumns(),this.#xe=this.#K.getEndVisibleLeafColumns(),this.#Se=[...this.#ye,...this.#be,...this.#xe],this.#dn(),this.#ve=this.#cn(),this.#we.setOptions(this.#ln()),n&&this.#Zt(),this.#Ht()}#Vt=!1;#Ht(){if(!this.#Vt)return;let e=this.dataSource?this.#ee?.total??null:this.#$.filter(e=>!e.getIsGrouped()).length;e!==null&&(this.#Vt=!1,this.#ze=W(e===1?`1 registro encontrado.`:G`${e} registros encontrados.`))}firstUpdated(){this.#De.observe(this.#ft),this.#De.observe(this)}#Ut=!1;#Wt=!1;updated(e){if(this.#gt(),this.#Wt&&(this.#Wt=!1,this.#$r()),this.#Ut){this.#Ut=!1;let e=this.querySelector(`:scope > [slot="actions"]`);e?e.focus():this.focus()}super.updated(e),this.#Fo(e),this.#xt();let t=this.#It;if(this.#It=null,t&&this.#Bt(t),this.#Zi(),this.#fn(),this.#kr(),this.#we._willUpdate(),this.label||this.getAttribute(`aria-label`)||this.getAttribute(`aria-labelledby`)||Le(this,`no-label`,`grade sem nome acessível. Correção: adicione label="...".`),this.#Re&&(this.#Re=!1,this.#mn()?.focus({preventScroll:!0})),this.#Ie){this.#Ie=!1;let e=this.#Fe.el;e.focus(),e instanceof HTMLInputElement&&this.#Fe.text===void 0&&e.select();let t=e.localName,n=t.includes(`-`)?customElements.whenDefined(t):Promise.resolve(),r=this.#Fe.text;n.then(()=>e.updateComplete).then(()=>{if(this.#Fe?.el!==e)return;e.focus();let t=e.shadowRoot?.activeElement;t instanceof HTMLInputElement&&r===void 0&&t.select()})}let n=this.renderRoot.querySelector(`.cell-error:not(.leaving)`);if(n){let e=this.renderRoot.querySelector(`.editing`).getBoundingClientRect();n.matches(`:popover-open`)||n.showPopover(),n.style.left=`${Math.max(0,Math.min(e.left,innerWidth-n.offsetWidth))}px`,n.style.top=`${Math.max(0,Math.min(e.bottom,innerHeight-n.offsetHeight))}px`}if(this.#ke){this.#ke=!1;let e=this.renderRoot.querySelector(`.column-menu:not(.leaving)`);this.#Za(e,this.#Pr(this.#Oe).getBoundingClientRect(),!1)}if(this.#Ve){this.#Ve=!1;let e=this.renderRoot.querySelector(`.options:not(.leaving)`);this.#Za(e,this.#si().getBoundingClientRect(),!0)}if(this.#Ye){this.#Ye=!1;let e=this.renderRoot.querySelector(this.#Ga()),t=this.renderRoot.querySelector(`.panel-menu:not(.leaving)`);this.#Za(t,e.getBoundingClientRect(),!0),t.querySelector(`[aria-checked="true"]`)?.focus()}let r=this.renderRoot.querySelector(`.panel-resizer`);if(r){let{min:e,max:t}=this.#Da();r.setAttribute(`aria-valuemin`,String(e)),r.setAttribute(`aria-valuemax`,String(t)),r.setAttribute(`aria-valuenow`,String(r.parentElement.offsetWidth))}if(this.#lt){let e=this.renderRoot.querySelector(this.#lt);this.#lt=null,e?.focus()}}#Gt(e){if(e.has(`dynamicMode`)&&(this.#at=!0,this.dynamicMode?this.#tt.delete(`panel`):e.get(`dynamicMode`)&&this.#Nt(`panel`)),e.has(`filterRow`)&&(this.filterRow?(this.#tt.delete(`filter-row`),this.#at=!0):e.get(`filterRow`)&&this.#Nt(`filter-row`)),e.has(`selected`)){let t=e.get(`selected`)?.length??0;this.selected.length>0?(this.#ta=!1,this.#tt.delete(`feedback`)):t>0&&!this.#ta&&this.#Nt(`feedback`,t)}}#Kt(e){let t=/* @__PURE__ */ new Set,n=this.#$[e]?.depth??0;for(let r=e+1;r<this.#$.length&&this.#$[r].depth>n;r++)t.add(this.#$[r].id);return t}#qt(){let e=getComputedStyle(this),t=this.density??qe(this),n=parseFloat(e.getPropertyValue(`--sankhya-ds-grid-row-height-${t}`))||parseFloat(e.getPropertyValue(`--sankhya-ds-density-row-height`));this.#ue=n>0?n:ft}#Jt(){let e=o(this.columns);for(let t of e.problems)H(this,`columns:${t}`,`columns: ${t}`);let t=this.#J?this.#q.aggregates:void 0,n=t?o(de(this.columns,t)):e;this.#G=n,this.#K=ge({columns:this.selectable?[s,...n.defs]:n.defs,data:[],getRowId:(e,t,n)=>{let r=e[this.rowKey];return r==null?n?`${n.id}.${t}`:String(t):String(r)},getSubRows:this.subRows?e=>this.#Q.children.get(e):void 0}),this.#q=T(fe(n.leaves),this.#J?this.#q:{},this.#St()),O(this.#K,this.#q,this.selectable,this.#Dr)}#Yt(){this.#Q=v(this.dataSource?[]:this.rows,{sort:this.sort,filter:this.filter,specs:this.#G.leaves,byId:this.#G.byId,getChildren:this.subRows}),_e(this.#K,this.#Q.rows)}#Xt(e){this.#ee?.reset(),clearTimeout(this.#te),this.#te=void 0,this.#ee=new te({blockSize:Math.max(1,this.blockSize),maxBlocks:mt,load:(t,n,r)=>e.getRows({start:t,end:n,sort:this.sort,filter:this.filter,signal:r}),onChange:()=>{this.#ti(),this.requestUpdate()},onError:e=>this.emit(`sankhya-ds-error`,{error:e})})}#Zt(){let e=this.#ee;e.total===null?e.ensure(0,this.#ve.page):this.#te??=setTimeout(()=>{this.#te=void 0,e.ensure(this.#ve.start,this.#ve.end)},pt)}#Qt(){return this.#K.getCoreRowModel().flatRows.map(e=>e.id)}#$t(){return this.#G.depth+(this.filterRow||this.#tt.has(`filter-row`)?1:0)}#en(){return this.#ue*this.#$t()}#tn(){return[{id:`grid-config`,label:W(`Configurar grade`),icon:Ce(),run:()=>void this.#vt()},{id:`search`,label:this.filterRow?W(`Limpar busca`):W(`Buscar`),icon:j(),run:()=>this.#ha(!this.filterRow)},{id:`dynamic-mode`,label:this.dynamicMode?W(`Fechar agrupar e totalizar`):W(`Agrupar e totalizar`),icon:ke(),run:()=>this.#va(!this.dynamicMode)},{id:`density`,label:this.density===`comfortable`?W(`Modo compacto`):W(`Modo confortável`),icon:Ee(),run:()=>{this.density===`comfortable`?this.density=this.#i:(this.#i=this.density,this.density=`comfortable`),this.emit(`sankhya-ds-density-change`,{density:this.density??qe(this)})}}].filter(e=>this.optionItems.includes(e.id)&&(e.id!==`grid-config`||!this.columnsLocked))}#nn(){return!this.columnsLocked&&!this.noOptions&&this.optionItems.includes(`grid-config`)}#rn(){return!this.noOptions&&(this.optionItems.includes(`find-column`)||this.#tn().length>0)}#in(){return Math.max(0,Math.floor(this.#fe-this.#K.getTotalSize()))}#an(){return this.#G.leaves.some(e=>e.def.aggregate)}#on(){let e=this.#an()?this.#ue:0;return Math.max(0,this.#de-this.#en()-e)}#sn(e){if(!this.autoHeight||e===0)return null;let t=this.maxRows>0?Math.floor(this.maxRows):e,n=Math.min(e,t),r=this.#an()?this.#ue:0;return`block-size:${this.#en()+n*this.#ue+r+this.#Ee}px`}#cn(){return b({count:this.rowCount,rowHeight:this.#ue,scrollTop:this.#ge,viewport:this.#on()})}#ln(){let e=this.#be.length;return{count:e,horizontal:!0,getScrollElement:()=>this.#ft,estimateSize:e=>this.#be[e].getSize(),getItemKey:e=>this.#be[e].id,scrollToFn:Ve,observeElementRect:Ue,observeElementOffset:He,paddingStart:Q(this.#ye),paddingEnd:Q(this.#xe),overscan:2,rangeExtractor:t=>{let n=Be(t),r=this.#Le.col-this.#ye.length;return r>=0&&r<e&&!n.includes(r)&&(n.push(r),n.sort((e,t)=>e-t)),n},onChange:e=>{`${e.range?.startIndex}:${e.range?.endIndex}`!==this.#Ce&&this.requestUpdate()}}}#un=()=>{this.#ge=this.#ft.scrollTop;let e=this.#cn();(e.start!==this.#ve.start||e.end!==this.#ve.end||e.scale!==1)&&this.requestUpdate();let t=this.rowCount;!this.dataSource&&t>0&&e.end>=t&&this.#_e!==t&&(this.#_e=t,this.emit(`sankhya-ds-scroll-end`,{rowCount:t}))};#dn(){let e=this.rowCount-1;this.#Le={row:Math.min(this.#Le.row,e),col:Math.max(0,Math.min(this.#Le.col,this.#Se.length-1))}}#fn(){let e=(this.density??this.closest(`[data-density]`)?.getAttribute(`data-density`))===`compact`;for(let t of this.renderRoot.querySelectorAll(`.rows [data-row-key]`)){let n=0;for(let r of t.querySelectorAll(`.visual`)){let t=r.querySelectorAll(`sankhya-ds-circle-button, sankhya-ds-button`);n+=t.length;for(let n of t){n.getAttribute(`size`)!==`xs`&&n.setAttribute(`size`,`xs`);let t=n.dataset.sankhyaDsVariant,r=t??n.getAttribute(`variant`)??`secondary`;r===`danger`?H(this,`cell-danger`,`ação destrutiva não fica na célula (V19). Correção: leve "Excluir" para o menu ⋮ da linha, com sankhya-ds-dialog de confirmação.`):r===`primary`&&H(this,`cell-primary`,`botão primário na célula (RV12): a ação da linha é secundária ou terciária. Correção: variant="secondary".`),n.tagName===`SANKHYA-DS-BUTTON`&&(n.textContent??``).trim().split(/\s+/).length>2&&H(this,`cell-text-button`,`botão com texto longo na célula (RV12): o rótulo tem 1 ou 2 palavras. Correção: encurte o rótulo ou use sankhya-ds-circle-button com dica.`),e&&r!==`danger`&&r!==`primary`?(t===void 0&&(n.dataset.sankhyaDsVariant=n.getAttribute(`variant`)??``),n.getAttribute(`variant`)!==`tertiary`&&n.setAttribute(`variant`,`tertiary`)):!e&&t!==void 0&&(t?n.setAttribute(`variant`,t):n.removeAttribute(`variant`),delete n.dataset.sankhyaDsVariant)}}n>2&&H(this,`cell-icons`,`${n} ações numa linha: o máximo é 2 (RV12). Correção: deixe as 2 ações mais usadas, na mesma ordem em todas as linhas, e as outras no menu ⋮ da linha.`);for(let e of t.querySelectorAll(`.visual`)){let t=e.querySelectorAll(`sankhya-ds-tag`);(t.length>1||[...t].some(e=>e.getAttribute(`tone`)===`solid`))&&H(this,`cell-tag`,`a célula mostra uma Tag só, no tom light (V19). Correção: uma sankhya-ds-tag sem tone="solid" por célula.`)}}}#pn(e){let t=e.target,n=t.closest(`[role="gridcell"]`);if(!n||n.classList.contains(`select-cell`))return!1;let r=[...n.querySelectorAll(Dt)].filter(e=>!e.matches(`:disabled, [disabled]`));if(t===n){if(e.key!==`Enter`&&e.key!==`F2`)return!1;let t=this.#Mn(n),i=t&&this.#G.byId.get(this.#Se[t.col].id);return!r.length||i&&this.#Hn(this.#uo(t.row),i)?!1:(e.preventDefault(),r[0].focus(),!0)}return e.key===`Escape`||e.key===`F2`?(e.preventDefault(),n.focus(),!0):(e.key===`Tab`&&r.length&&(e.preventDefault(),r[(r.findIndex(e=>e===t||e.contains(t))+(e.shiftKey?-1:1)+r.length)%r.length].focus()),!0)}#mn(){return this.renderRoot.querySelector(`[tabindex="0"]`)}#hn(e){this.#dt&&e.row!==this.#dt.index&&this.#$a(),this.#Le=e,e.row>=0&&this.scrollToRow(e.row),this.#gn(e.col),this.#Re=!0,this.requestUpdate()}#gn(e,t=!1){let n=this.#ft,r=this.#Se[e];if(r.getIsPinned()!==!1)return;let i=Q(this.#ye),a=r.getStart(`center`),o=a+r.getSize(),s=n.clientWidth-i-Q(this.#xe),c=t&&!Ne()?`smooth`:`auto`;a<n.scrollLeft?n.scrollTo({left:a,behavior:c}):o>n.scrollLeft+s&&n.scrollTo({left:o-s,behavior:c})}#_n=e=>{let t=e.target.closest(`[data-col]`);if(!t)return;let n={row:Number(t.dataset.row),col:Number(t.dataset.col)};this.#dt&&n.row!==this.#dt.index&&this.#$a(),(n.row!==this.#Le.row||n.col!==this.#Le.col)&&(this.#Le=n,this.requestUpdate())};#vn(e){return!!e?.closest?.(`.filter-row`)}#yn(){return this.selectable}#bn=e=>{if(this.#vn(e.target)){let t=e.target;e.key===`Escape`&&t.value&&(t.value=``,t.dispatchEvent(new Event(`input`)),e.preventDefault());return}if(this.#Fe){this.#Qn(e);return}if(this.#pn(e))return;let t=e.ctrlKey||e.metaKey,{row:n,col:r}=this.#Le,i=this.#Se[r]?.id;if(n>=0&&this.#Do(e)||(n<0?this.#or(e):this.#An(e,n,i))){e.preventDefault();return}let a=this.#yn(),o=e.key===`Tab`&&n>=0&&!t&&!e.altKey?this.#xn(e.shiftKey):null,s=o??C(e.key,t,this.#Le,{rows:this.rowCount,cols:this.#Se.length,minRow:-1,page:this.#ve.page});if(s){e.preventDefault(),a?(this.#jn(null),s.row>=0&&this.#Cn(s.row,e.shiftKey&&!o)):e.shiftKey&&!o&&n>=0&&s.row>=0?this.#jn(this.#Me?.anchor??this.#Le,s):this.#jn(null),this.#hn(s);return}if(t&&e.key.toLowerCase()===`a`&&this.rowCount){e.preventDefault(),a&&!this.dataSource?this.#wn():this.#jn({row:0,col:0},{row:this.rowCount-1,col:this.#Se.length-1});return}if(e.key===`Escape`){this.#jn(null),this.#bt()&&(e.preventDefault(),this.#oa());return}let c=e.key.length===1&&e.key!==` `&&!t&&!e.altKey;if(n>=0&&(e.key===`Enter`||e.key===`F2`||c)&&this.#Gn(n,r,c?e.key:void 0))e.preventDefault();else if(e.key===`Enter`||e.key===` `){if(n>=0&&e.key===`Enter`)this.enterNavigation===`none`?this.#En(n,r):(e.preventDefault(),this.#jn(null),this.#hn(this.#Tn(e.shiftKey)));else if(n<0)e.preventDefault(),this.columnSelect&&t&&e.key===` `&&i!==`__select`?this.#sr(r,e.shiftKey):i===`__select`?this.dataSource||this.#ii():this.#Qr(i,e.shiftKey);else if(e.key===` `&&this.selectable){e.preventDefault();let r=this.#uo(n);if(!r.data)return;t?this.#ri(r.id):this.#Cn(n,!1,!0)}}};#xn(e){let{row:t,col:n}=this.#Le,r=+(this.#Se[0]?.id===`__select`),i=this.#Se.length-1;return e?n>r?{row:t,col:n-1}:t>0?{row:t-1,col:i}:null:n<i?{row:t,col:n+1}:t<this.rowCount-1?{row:t+1,col:r}:null}#Sn(e,t){let n=[];for(let r=Math.min(e,t);r<=Math.max(e,t);r++){let e=this.#uo(r);e.data&&!e.group&&n.push(e.id)}return n}#Cn(e,t,n=!1){let r=this.#uo(e);if(!r.data||r.group)return;let i;t?(this.#ir<0&&(this.#ir=Math.max(0,this.#Le.row)),i=this.#Sn(this.#ir,e)):(i=[r.id],this.#ir=e),(n||i.join(`\0`)!==this.selected.join(`\0`))&&(this.selected=i,this.#$r())}#wn(){let e=this.#Qt(),t=new Set(e);this.selected=[...this.selected.filter(e=>!t.has(e)),...e],this.#$r()}#Tn(e){let{row:t,col:n}=this.#Le;return this.enterNavigation===`down`||this.editMode===`row`?{row:Math.max(0,Math.min(this.rowCount-1,t+(e?-1:1))),col:n}:this.#xn(e)??{row:t,col:n}}#En(e,t){let n=this.#uo(e),r=this.#Se[t].id;n.data&&!n.group&&r!==`__select`&&this.emit(`sankhya-ds-row-activate`,{rowId:n.id,row:n.data,columnId:r})}#Dn(){return this.#Se.find(e=>e.id!==r)?.id}#On(){return!this.dataSource&&(this.#q.groupBy.length>0||!!this.subRows)}#kn(e,t,n=!0){if(this.#it){let n=this.#it.row;if(this.#it=null,this.#kn(n,!1,!1),n.id===e.id&&!t)return}let r=t||!n?/* @__PURE__ */ new Set:this.#Kt(e.index);if(r.size){let t={row:e,ids:r};this.#it=t,this.requestUpdate(),this.updateComplete.then(()=>{let n=()=>{this.#it===t&&(this.#it=null,this.#kn(e,!1,!1))},r=this.renderRoot.querySelector(`.row-out`);r?M(r,n):n()});return}this.#at=!0,t&&(this.#rt=e.id);let i=this.expanded===!0?Object.fromEntries(this.#$.filter(e=>e.getCanExpand()).map(e=>[e.id,!0])):{...this.expanded};t?i[e.id]=!0:delete i[e.id],this.expanded=i,this.emit(`sankhya-ds-expand-change`,{rowId:e.id,expanded:t})}#An(e,t,n){if(!this.#On()||e.altKey||e.shiftKey)return!1;let r=this.#uo(t);if(e.key===`Enter`&&r.canExpand)return this.#kn(r,!r.expanded),!0;if(n!==this.#Dn())return!1;if(e.key===`ArrowRight`&&r.canExpand&&!r.expanded)return this.#kn(r,!0),!0;if(e.key!==`ArrowLeft`)return!1;if(r.expanded)return this.#kn(r,!1),!0;let i=t-1;for(;i>=0&&this.#$[i].depth>=r.depth;)i--;return i<0?!1:(this.#hn({row:i,col:this.#Le.col}),!0)}#jn(e,t){let n=JSON.stringify(this.getSelectedRange());this.#Me=e?{anchor:e,focus:t}:null,JSON.stringify(this.getSelectedRange())!==n&&(this.requestUpdate(),this.emit(`sankhya-ds-range-change`,{range:this.getSelectedRange()}))}#Mn(e){let t=e.closest(`[data-row]`);return t?{row:Number(t.dataset.row),col:Number(t.dataset.col)}:null}#Nn=null;#Pn=e=>{let t=this.#Mn(e.target);this.#Nn=t,e.button===0&&t&&!e.target.closest(`input, select, .toggle`)&&(this.#jn(e.shiftKey?this.#Me?.anchor??this.#Le:t,t),this.#Pe=!0,addEventListener(`pointerup`,()=>this.#Pe=!1,{once:!0}))};#Fn=e=>{let t=this.#Mn(e.target);this.#Pe&&t&&this.#jn(this.#Me.anchor,t);let n=e.target.closest?.(`.cell`);if(n?.id&&!n.querySelector(`input, select, textarea`)){let e=(n.textContent??``).replace(/\s+/g,` `).trim();this.#Rn.get(n.id)!==e&&(this.#Rn.set(n.id,e),this.requestUpdate()),this.#Ln.sync(n)}};#In=e=>{let t=e.currentTarget,n=t.querySelector(`.label`).textContent.trim();this.#Rn.get(t.id)!==n&&(this.#Rn.set(t.id,n),this.requestUpdate()),this.#Ln.check(e)};#Ln=new Ke(this);#Rn=/* @__PURE__ */ new Map;#zn(e,t){let n=this.#Se[t].id,r=this.#G.byId.get(n);if(e<0)return r.header;let a=this.#uo(e);return a.data?a.group?this.#Ro(a,n,r):i(r,a.tan?a.tan.getValue(n):r.accessor(a.data),a.data):``}#Bn=e=>{if(this.#Fe||this.#vn(e.target))return;let{start:t,end:n}=this.getSelectedRange()??{start:this.#Le,end:this.#Le},r=[];for(let e=t.row;e<=n.row;e++){let i=[];for(let r=t.col;r<=n.col;r++)this.#Se[r].id!==`__select`&&i.push(this.#zn(e,r));r.push(i)}e.preventDefault(),e.clipboardData.setData(`text/plain`,u(r,` `))};#Vn=e=>{if(this.#Fe||this.#Le.row<0||this.#vn(e.target))return;let t=l(e.clipboardData.getData(`text/plain`));if(!t.length)return;e.preventDefault();let r=this.getSelectedRange(),i=r?.start??this.#Le,a=r&&t.length===1&&t[0].length===1,o=a?r.end.row-i.row+1:t.length,s=a?r.end.col-i.col+1:Math.max(...t.map(e=>e.length)),c=[];for(let e=0;e<o&&i.row+e<this.rowCount;e++){let r=this.#uo(i.row+e);for(let o=0;o<s&&i.col+o<this.#Se.length;o++){let s=this.#G.byId.get(this.#Se[i.col+o].id),l=a?t[0][0]:t[e][o];if(!s||l===void 0||!this.#Hn(r,s))continue;let u=s.def.options?.find(e=>e.label===l.trim());c.push({row:r,spec:s,value:u?u.value:n(l,s.type)})}}this.#Wn(c)};#Hn(e,t){let n=t.def.editable;return this.readonly||!e.data||e.group||!n?!1:typeof n!=`function`||n(e.data)}#Un(e,t,n){return e.def.validate?.(t,n)||null}#Wn(e){let t=!1,n=[];for(let{row:r,spec:i,value:a}of e){let e=r.data,o=i.accessor(e);if(Object.is(o,a))continue;let s=this.#Un(i,a,e);s?n.push(`${i.header}: ${s}`):!this.emit(`sankhya-ds-change`,{rowId:r.id,columnId:i.id,value:a,previousValue:o,row:e},{cancelable:!0}).defaultPrevented&&i.def.field&&(e[i.def.field]=a,t=!0)}t&&!this.dataSource&&(this.#Q={...this.#Q,rows:[...this.#Q.rows]},_e(this.#K,this.#Q.rows)),n.length&&(this.#ze=n.join(` `)),this.requestUpdate()}#Gn(e,t,n){let r=this.#uo(e),i=this.#G.byId.get(this.#Se[t].id);if(!i||!this.#Hn(r,i))return!1;let a=d(i),o=this.#dt?.view.id===r.id?this.#dt.values:void 0,s=o?.has(i.id)?o.get(i.id):i.accessor(r.data);if(i.type===`boolean`&&!i.def.editor)return n!==void 0&&!/^[sn]$/i.test(n)?!1:(this.#qn(r,i,n===void 0?!s:/^s$/i.test(n)),!0);if((a===`date`||a===`datetime`)&&n!==void 0&&/^h$/i.test(n))return this.#qn(r,i,f(p(a),a,s)),!0;let c={row:e,col:t,view:r,spec:i,kind:a,value:s,text:n};return c.el=typeof a==`string`?this.#Yn(a,i,s,n):a.create({value:s,row:r.data,column:i.def,initialText:n,commit:e=>this.#Kn(e),cancel:()=>this.#Jn()}),this.#Fe=c,this.#Ie=!0,this.requestUpdate(),!0}#Kn(e,t=!1){let n=this.#Fe;if(!n)return!0;let{kind:r,spec:i,view:a}=n,o=e;o===void 0&&(o=typeof r==`object`?r.getValue(n.el):h(r,n.el,i,n.value));let s=Object.is(o,n.value)?null:this.#Un(i,o,a.data);return s&&!t?(n.error=s,this.requestUpdate(),!1):(this.#Jn(),s?this.#ze=`${i.header}: ${s}`:this.editMode===`row`?this.#Qa(a,i,o):this.#Wn([{row:a,spec:i,value:o}]),!0)}#qn(e,t,n){this.editMode===`row`?this.#Qa(e,t,n):this.#Wn([{row:e,spec:t,value:n}])}#Jn(){this.#Fe=null,this.#Re=!0,this.requestUpdate()}#Yn(e,t,n,r){this.#Zn();let i=m(e,t,n,r);i.addEventListener(`keydown`,e=>{e.key!==`Enter`&&e.key!==`Escape`||i.open||this.#Fe?.el!==i||(e.stopPropagation(),this.#Qn(e))},{capture:!0});for(let e of dt)i.addEventListener(e,e=>e.stopPropagation());return(e===`date`||e===`datetime`)&&i.addEventListener(`keydown`,t=>{!/^h$/i.test(t.key)||t.ctrlKey||t.metaKey||t.altKey||this.#Fe?.el!==i||(t.preventDefault(),t.stopPropagation(),this.#Kn(f(p(e),e,this.#Fe.value)))},{capture:!0}),(e===`select`||e===`date`||e===`datetime`)&&i.addEventListener(`sankhya-ds-change`,()=>setTimeout(()=>{this.#Fe?.el===i&&!i.open&&this.#Kn()})),i}#Xn=null;#Zn(){return this.#Xn??=import(`./core/editor-fields.define.js`),this.#Xn}#Qn(e){if(e.defaultPrevented)return;let t=this.editMode===`row`,{row:n,col:r}=this.#Fe;if(e.key===`Escape`)this.#Jn(),t&&this.#eo();else if(e.key===`Enter`)this.#Kn()&&(t&&this.#$a(),(t||this.enterNavigation!==`none`)&&this.#hn(this.#Tn(e.shiftKey)));else if(e.key===`Tab`&&t){if(this.#Kn()){let t=this.#to(n,r,e.shiftKey);t>=0?(this.#hn({row:n,col:t}),this.#Gn(n,t)):(this.#$a(),this.#hn(this.#xn(e.shiftKey)??{row:n,col:r}))}}else if(e.key===`Tab`)this.#Kn()&&this.#hn(C(e.shiftKey?`ArrowLeft`:`ArrowRight`,!1,this.#Le,{rows:this.rowCount,cols:this.#Se.length,minRow:-1,page:1}));else return;e.preventDefault()}#$n=e=>{let t=e.target.closest(`.editing`);this.#Fe&&t&&!t.contains(e.relatedTarget)&&this.#Kn(void 0,!0)};#er=e=>{let t=this.#Mn(e.target);t&&!e.target.closest(`.toggle`)&&this.#En(t.row,t.col)};#tr(e){let t=e.el;return e.error?(t.setAttribute(`aria-invalid`,`true`),t.setAttribute(`aria-describedby`,`cell-error`)):(t.removeAttribute(`aria-invalid`),t.removeAttribute(`aria-describedby`)),t}#nr=e=>{let t=e.target,n=t.closest(`.toggle`);if(n){let e=this.#uo(Number(n.closest(`[data-row]`).dataset.row));this.#kn(e,!e.expanded);return}let r=this.#Mn(t),i=this.#Nn??r;this.#Nn=null;let a=!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.detail<=1,o=this.#Fe;o&&r&&o.row===r.row&&o.col===r.col||(this.#ar(e,t),a&&r&&i?.row===r.row&&i.col===r.col&&(this.#Gn(r.row,r.col),this.#Fe||this.#rr(r.row,r.col,e,t)))};#rr(e,t,n,r){if(r.closest(`input, select, textarea, button, a, [contenteditable], .editor`))return;let i=this.#uo(e),a=this.#Se[t].id;if(!i.data||i.group||a===`__select`)return;let o={rowId:i.id,row:i.data,rowIndex:e,columnId:a,originalEvent:n};this.emit(`sankhya-ds-row-click`,o)}#ir=-1;#ar(e,t){if(!this.selectable||this.#Fe||t.closest(`input, select, textarea, button, a, [contenteditable], .editor`))return;let n=t.closest(`[data-row]`),r=Number(n?.dataset.row);if(!n||Number.isNaN(r)||r<0)return;let i=this.#uo(r);if(i.data&&!i.group){if(e.shiftKey&&this.#ir>=0)this.selected=this.#Sn(this.#ir,r);else if(e.ctrlKey||e.metaKey){let e=new Set(this.selected);e.has(i.id)?e.delete(i.id):e.add(i.id),this.selected=[...e],this.#ir=r}else if(this.rowClickable){this.#ir=r;return}else this.selected=[i.id],this.#ir=r;this.#$r()}}#or(e){let t=this.#Se[this.#Le.col].id;if(t===`__select`)return!1;if(e.altKey&&e.key===`ArrowDown`||e.shiftKey&&e.key===`F10`||e.key===`ContextMenu`)return this.#Fr(t),!0;if(e.altKey&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)){if(!this.#G.byId.get(t).resizable)return!0;let n=e.key===`ArrowLeft`?-16:At;return this.#xr(),this.#Dt(this.#dr(t,this.#K.getColumn(t).getSize()+n)),!0}return!1}#sr(e,t){if(!this.rowCount)return;let n=t&&this.#Me?this.#Me.anchor.col:e;this.#jn({row:0,col:n},{row:this.rowCount-1,col:e})}#cr(e){let t=this.columnSelect?this.getSelectedRange():null;return!!(t&&t.start.row===0&&t.end.row===this.rowCount-1&&e>=t.start.col&&e<=t.end.col)}#lr=e=>{let t=e.target,n=t.closest(`[data-col]`),r=n?.dataset.id;r&&r!==`__select`&&!t.closest(`.resizer`)&&(this.columnSelect&&(e.ctrlKey||e.metaKey)&&!t.closest(`.menu-btn, .filter-btn`)?this.#sr(Number(n.dataset.col),e.shiftKey):t.closest(`.menu-btn`)?this.#Fr(r):t.closest(`.filter-btn`)?this.#Kr(r):this.#Qr(r,e.shiftKey))};#ur=e=>{let t=e.target.closest(`[data-col]`)?.dataset.id;t&&t!==`__select`&&(e.preventDefault(),this.#Fr(t))};#dr(e,t){let n=this.#G.byId.get(e),r=Math.round(Math.min(n.maxWidth,Math.max(this.#fr(n),t)));return{...this.#q,widths:{...this.#q.widths,[e]:r}}}#fr(e){return e.def.minWidth===void 0?Math.min(e.minWidth,this.#Dr[e.id]??e.minWidth):e.def.minWidth}#pr=e=>{let t=e.target,n=t.closest(`[data-id]`).dataset.id;e.preventDefault(),e.stopPropagation(),t.setPointerCapture(e.pointerId),clearTimeout(this.#br),this.#yr&&(this.#yr=!1,this.requestUpdate()),this.#je={id:n,x:e.clientX,width:this.#K.getColumn(n).getSize()}};#mr=e=>{if(!this.#je)return;let{id:t,x:n,width:r}=this.#je;this.#Ct(this.#dr(t,r+e.clientX-n))};#hr=()=>{this.#je&&(this.#je=null,this.emit(`sankhya-ds-layout-change`,{layout:this.getLayout()}))};#gr=e=>{this.#_r(e.target.closest(`[data-id]`).dataset.id)};#_r(e){this.#xr(),this.#Dt(this.#dr(e,this.#Cr(e)))}#vr(e){let t={...this.#q.widths};delete t[e],this.#xr(),this.#Dt({...this.#q,widths:t})}#yr=!1;#br;#xr(){this.#yr=!0,clearTimeout(this.#br),this.#br=setTimeout(()=>{this.#yr=!1,this.requestUpdate()},450)}#Sr=null;#Cr(e){return this.#wr([e],1/0).get(e)??this.#K.getColumn(e).getSize()}#wr(e,t){let n=/* @__PURE__ */ new Map,r=this.renderRoot,a=r.querySelector(`.head[data-id]:not(.select-cell) .head-main > .label`),o=a?.closest(`.head`);if(!o||!a)return n;let s=a.parentElement;this.#Sr??=document.createElement(`canvas`).getContext(`2d`);let c=this.#Sr,l=e=>{let t=getComputedStyle(e);return`${t.fontStyle} ${t.fontWeight} ${t.fontSize} ${t.fontFamily}`},u=e=>{let t=getComputedStyle(e);return parseFloat(t.paddingInlineStart)+parseFloat(t.paddingInlineEnd)+parseFloat(t.borderInlineStartWidth)+parseFloat(t.borderInlineEndWidth)},d=parseFloat(getComputedStyle(s).columnGap)||0,f=document.createElement(`span`);f.className=`icon`,s.append(f);let p=f.offsetWidth+d;f.remove();let m=l(a),h=o.querySelector(`.menu-btn`),g=parseFloat(getComputedStyle(o).columnGap)||0,_=h&&getComputedStyle(h).position!==`absolute`,v=u(o)+u(s)+(_?h.offsetWidth+g:0),y=r.querySelector(`[role="gridcell"]:not(.select-cell):not(.editing):not(.visual)`),ee=y?l(y):``,te=y?u(y):0,b=y?document.createElement(`span`):null;b&&y.append(b);let x=/* @__PURE__ */ new Set;for(let e of r.querySelectorAll(`[role="gridcell"]:not(.select-cell):not(.visual)`)){let t=getComputedStyle(e);x.add(`${t.fontStyle}|${t.fontWeight}`)}let S=r.querySelector(`[role="gridcell"].divider`),C=S?parseFloat(getComputedStyle(S).borderInlineStartWidth):0,w=[];if(this.dataSource)w.push(...this.#ee.loadedRows());else{let e=t=>{for(let n of t)w.push(n),e(this.#Q.children.get(n)??[])};e(this.#Q.rows)}let ne=Math.max(1,Math.ceil(w.length/t)),re=document.createRange();for(let t of e){let e=this.#G.byId.get(t);if(!e)continue;c.font=m;let a=c.measureText(this.#Ca(e)).width+v,o=r.querySelector(`.head[data-id="${CSS.escape(t)}"] .head-main`),s=o?[...o.children].filter(e=>!e.matches(`.label`)):[];a+=s.reduce((e,t)=>e+t.getBoundingClientRect().width+d,0),e.sortable&&!s.some(e=>e.matches(`.icon`))&&(a+=p);let l=this.#Se.findIndex(e=>e.id===t),f=l<0?[]:r.querySelectorAll(`[role="gridcell"][data-col="${l}"]`);for(let e of f)re.selectNodeContents(e),a=Math.max(a,re.getBoundingClientRect().width+u(e));if(b&&!e.def.render&&e.type!==`boolean`&&e.type!==`component`){c.font=ee;let t=[];for(let n=0;n<w.length;n+=ne){let r=w[n],a=i(e,e.accessor(r),r);t.push([c.measureText(a).width,a])}t.sort((e,t)=>t[0]-e[0]),b.className=e.numeric?`probe num`:`probe`;let n=0;for(let e of x){let[r,i]=e.split(`|`);b.style.fontStyle=r,b.style.fontWeight=i;for(let[,e]of t.slice(0,Nt))b.textContent=e,n=Math.max(n,b.getBoundingClientRect().width)}a=Math.max(a,n+te+(e.def.divider?C:0))}n.set(t,Math.ceil(a)+Pt)}return b?.remove(),n}#Tr=!1;#Er(){return document.fonts.status===`loading`&&(this.#Tr||(this.#Tr=!0,document.fonts.ready.then(()=>requestAnimationFrame(()=>{this.#Tr=!1,this.requestUpdate()}))),!0)}#Dr={};#Or=/* @__PURE__ */ new Set;#kr(){if(this.#Tr)return;let e=this.#G.leaves.filter(e=>e.def.width===void 0&&!e.def.actions&&!this.#Or.has(e.id));if(!e.length)return;let t=(this.dataSource?this.#ee.loadedRows().length>0:this.#Q.rows.length>0)&&!!this.renderRoot.querySelector(`[role="gridcell"]:not(.select-cell):not(.editing):not(.visual)`),n=Math.max(200,Math.floor(Mt/e.length)),r=this.#wr(e.map(e=>e.id),n);if(!r.size)return;let i=!1,a=this.#Er();for(let n of e){let e=r.get(n.id),o=!!n.def.render||n.type===`component`,s=Math.round(Math.min(n.maxWidth,jt,Math.max(n.def.minWidth??0,o?Math.max(e,150):e)));this.#Dr[n.id]!==s&&(this.#Dr[n.id]=s,i=!0),t&&!a&&this.#Or.add(n.id)}i&&(O(this.#K,this.#q,this.selectable,this.#Dr),this.requestUpdate())}#Ar=e=>{let t=e.target.dataset.id;this.#je?e.preventDefault():(this.#Ae={id:t},e.dataTransfer?.setData(`text/plain`,t))};#jr=e=>{let t=e.target.closest(`[data-id]`),n=t?.dataset.id;if(!this.#Ae||this.#Ae.from||!n||n===`__select`||this.columnsLocked)return;e.preventDefault();let r=t.getBoundingClientRect(),i=e.clientX>r.left+r.width/2;(this.#Ae.target!==n||this.#Ae.after!==i)&&(this.#Ae={...this.#Ae,target:n,after:i},this.requestUpdate())};#Mr=e=>{let t=this.#Ae;this.#Ae=null,t?.target&&(e.preventDefault(),this.#Dt(E(this.#q,t.id,t.target,t.after)))};#Nr=()=>{this.#Ae=null,this.#Xe=null,this.#Ze=null,this.#st=null,this.requestUpdate()};#Pr(e){return this.renderRoot.querySelector(`[role="columnheader"][data-id="${CSS.escape(e)}"]`)}#Fr(e){this.#Br(e).length&&(this.#Oe=e,this.#ke=!0,this.requestUpdate())}#Ir(){let e=this.#Oe;this.#Oe=null,kt(this.renderRoot.querySelector(`.column-menu:not(.leaving)`)),this.requestUpdate(),this.#Pr(e)?.focus({preventScroll:!0})}#Lr=e=>{e.newState===`closed`&&this.#Oe&&(e.target.dataset.dismissed=``,this.#Oe=null,this.requestUpdate())};#Rr=e=>{let t=[...e.currentTarget.querySelectorAll(`[role^="menuitem"]:not([aria-disabled="true"])`)],n=t.indexOf(e.target),r=e=>t[(e+t.length)%t.length].focus();if(e.key===`ArrowDown`)r(n+1);else if(e.key===`ArrowUp`)r(n-1);else if(e.key===`Home`)r(0);else if(e.key===`End`)r(t.length-1);else if(e.key===`Escape`||e.key===`Tab`)this.#qe?this.#Ka():this.#Ir();else return;e.preventDefault(),e.stopPropagation()};#zr(e,t){let n=this.#Se.map(e=>e.id).filter(e=>e!==r);return n[n.indexOf(e)+t]}#Br(e){let t=this.#G.byId.get(e),n=this.#q,r=me(n,e),i=this.sort.find(t=>t.id===e),a=t=>()=>{this.sort=t===null?[]:[{id:e,desc:t}],this.emit(`sankhya-ds-sort-change`,{sort:this.sort})},o=t=>()=>this.#Dt(pe(n,e,t)),s=t=>{let r=this.#zr(e,t);return{disabled:!r,run:()=>this.#Dt(E(n,e,r,t>0))}},c=this.#G.leaves.filter(e=>!n.hidden.includes(e.id)).length,l=[],u=[];if(t.sortable&&u.push({icon:je,label:ee(t.type)[0],run:a(!1),checked:i?.desc===!1},{icon:Ae,label:ee(t.type)[1],run:a(!0),checked:i?.desc===!0}),this.#Wr(t)&&u.push({icon:()=>we(),label:W(`Filtrar`),run:()=>this.#Kr(e)}),this.#ya()){let t=n.groupBy.includes(e);u.push({icon:Oe,label:W(t?`Desagrupar`:`Agrupar por esta coluna`),run:()=>this.#Dt({...n,groupBy:t?n.groupBy.filter(t=>t!==e):[...n.groupBy,e]})})}let d=this.columnsLocked;d||u.push(r===`center`?{icon:De,label:W(`Fixar coluna`),run:o(`start`)}:{icon:De,label:W(`Desafixar coluna`),run:o(null)}),u.length&&l.push(u);let f=[];return t.sortable&&f.push({label:W(`Remover ordenação`),run:a(null),disabled:!i}),d||f.push({label:W(`Fixar à direita`),run:o(`end`),checked:r===`end`},{label:W(`Mover para a esquerda`),...s(-1)},{label:W(`Mover para a direita`),...s(1)}),f.length&&l.push(f),t.resizable&&l.push([{label:W(`Ajustar largura ao conteúdo`),run:()=>this.#_r(e)},{label:W(`Largura padrão`),run:()=>this.#vr(e),disabled:n.widths[e]===void 0}]),d||l.push([{label:W(`Ocultar coluna`),run:()=>this.#Dt(D(n,e,!0)),disabled:!t.hideable||c<2},{label:W(`Restaurar colunas`),run:()=>this.#Dt({...fe(this.#G.leaves),groupBy:n.groupBy,sort:this.sort})},...this.#nn()?[{label:W(`Configurar colunas`),run:()=>void this.#vt()}]:[]]),this.columnActions.length&&l.push(this.columnActions.map(t=>({label:t.label,run:()=>this.emit(`sankhya-ds-column-action`,{action:t.id,columnId:e})}))),d||l.push(this.#G.leaves.map(e=>{let t=!n.hidden.includes(e.id);return{label:e.header,checked:t,keep:!0,disabled:t&&(!e.hideable||c<2),run:()=>this.#Dt(D(this.#q,e.id,t))}})),l}#Vr(){let e=this.#Oe;if(!e)return R;let t=this.#G.byId.get(e),n=this.#Br(e),r=n.length-1;return L`<div class="menu column-menu" part="menu" popover="auto" role="menu" aria-label=${W(G`Opções da coluna ${t.header}`)} @beforetoggle=${this.#Ot} @toggle=${this.#Lr} @keydown=${this.#Rr} > ${n.map((e,t)=>L` ${t===r&&!this.columnsLocked?L`<div class="menu-label" role="presentation">${W(`Colunas`)}</div>`:R} ${e.map(e=>L`<button type="button" class="item" role=${e.checked===void 0?`menuitem`:`menuitemcheckbox`} aria-checked=${e.checked===void 0?R:String(e.checked)} aria-disabled=${e.disabled?`true`:R} tabindex="-1" @click=${()=>{e.disabled||(e.run(),e.keep||this.#Ir())}} > <span class="mark">${e.checked?be():R}</span>${e.icon?e.icon():R}${e.label} </button>`)} ${t<r?L`<div class="sep" role="separator"></div>`:R} `)} </div>`}#Hr=null;#Ur=!1;#Wr(e){return e.def.filterable===!1||e.def.render||e.def.actions||e.type===`component`?!1:!this.dataSource||!!e.def.filterOptions?.length}#Gr(e){if(e.def.filterOptions)return e.def.filterOptions;let t=/* @__PURE__ */ new Set,n=r=>{for(let a of r){t.add(i(e,e.accessor(a),a));let r=this.subRows?.(a);r?.length&&n(r)}};return n(Array.isArray(this.rows)?this.rows:[]),[...t]}#Kr(e){this.#Hr=e,this.#Ur=!0,this.requestUpdate()}#qr=e=>{e.stopPropagation();let t=this.#Hr,n=this.#G.byId.get(t),r=this.#Gr(n),i={...this.filter.values};r.every(t=>e.detail.value.includes(t))?delete i[t]:i[t]=e.detail.value,this.#Ur=!1,this.filter={...this.filter,values:i},this.emit(`sankhya-ds-filter-change`,{filter:this.filter,filterRow:this.filterRow}),this.#Pr(t)?.focus({preventScroll:!0})};#Jr=e=>{e.stopPropagation(),this.#Ur&&(this.#Ur=!1,this.requestUpdate(),this.#Pr(this.#Hr)?.focus({preventScroll:!0}))};#Yr(){let e=this.#Hr,t=e?this.#G.byId.get(e):void 0;if(!t)return R;rt();let n=this.renderRoot.querySelector(`[role="columnheader"][data-id="${CSS.escape(t.id)}"] .filter-anchor`);return L`<sankhya-ds-column-filter part="column-filter" column-label=${t.header} .options=${this.#Gr(t)} .value=${this.filter.values?.[t.id]??null} .anchor=${n} .open=${this.#Ur&&!!n} @sankhya-ds-apply=${this.#qr} @sankhya-ds-close=${this.#Jr} @sankhya-ds-change=${e=>e.stopPropagation()} @sankhya-ds-open=${e=>e.stopPropagation()} ></sankhya-ds-column-filter>`}#Xr=()=>{this.filter={...this.filter,values:{},columns:{}},this.emit(`sankhya-ds-filter-change`,{filter:this.filter,filterRow:this.filterRow})};#Zr(){return _(this.filter)&&!this.dataSource&&this.rows.length>0?L`<sankhya-ds-empty-state part="empty" mode="inline" icon=${this.emptyIcon||`search`} heading=${W(`Nenhum registro encontrado com esses filtros`)} description=${W(`Ajuste ou limpe os filtros.`)} action-label=${W(`Limpar filtros`)} action-type="clear" variant="no-results" @sankhya-ds-action=${e=>{e.stopPropagation(),this.#Xr()}} ></sankhya-ds-empty-state>`:L`<sankhya-ds-empty-state part="empty" mode="inline" icon=${this.emptyIcon||`search`} heading=${this.emptyHeading||W(`Nenhum registro encontrado`)} description=${this.emptyDescription} action-label=${this.emptyActionLabel} action-type=${this.emptyActionType} @sankhya-ds-action=${e=>{e.stopPropagation(),this.emit(`sankhya-ds-empty-action`)}} ></sankhya-ds-empty-state>`}#Qr(e,t){let n=this.#G.byId.get(e);if(!n.sortable)return;this.sort=he(this.sort,e,t);let r=this.sort.find(t=>t.id===e);this.#ze=W(r?G`Ordenado por ${n.header}, ${St(y(n.type)[+!!r.desc])}.`:`Ordenação removida.`),this.emit(`sankhya-ds-sort-change`,{sort:this.sort})}#$r(e=!1){this.allMatching=e;let t={selected:this.selected,allMatching:e};e&&(t.total=this.#ee?.total??this.selected.length,t.filter=this.filter,t.sort=this.sort),this.emit(`sankhya-ds-select`,t)}#ei(){return this.allMatching&&this.dataSource?Math.max(this.#ee?.total??0,this.selected.length):this.selected.length}#ti(){if(!this.allMatching||!this.dataSource)return;let e=new Set(this.selected),t=[];for(let n of this.#ee.loadedRows()){let r=n[this.rowKey];r!=null&&(e.has(String(r))||t.push(String(r)))}t.length&&(this.selected=[...this.selected,...t])}#ni(){this.allMatching=!0,this.#ti(),this.#$r(!0)}#ri(e){let t=new Set(this.selected);t.has(e)?t.delete(e):t.add(e),this.selected=[...t],this.#$r()}#ii(){let e=this.#Qt(),t=new Set(e),n=this.selected.filter(e=>!t.has(e));this.selected=this.#re===`all`?n:[...n,...e],this.#$r()}#ai(){let e=this.#in();return e?L`<div class="cell filler" aria-hidden="true" style=${K(`width:${e}px`)} ></div>`:R}#oi(e){return W(e===1?`1 registro selecionado`:G`${t(e,`number`)} registros selecionados`)}#si(){return this.renderRoot.querySelector(`.options-btn`)}#ci=e=>{for(let t of e.target.assignedElements({flatten:!0})){if(!vt.includes(t.tagName))continue;t.setAttribute(`size`,`sm`);let e=t.getAttribute(`variant`);e===`primary`?H(this,`toolbar-primary`,`a toolbar só aceita botões secondary (ACORDE): a ação primária da tela fica no cabeçalho. Correção: variant="secondary".`):e===`danger`&&H(this,`toolbar-danger`,`a toolbar e a barra de lote só aceitam botões secondary (V15): "Excluir" é secondary e fica por último; o vermelho fica no sankhya-ds-dialog de confirmação. Correção: variant="secondary".`)}this.#di(),this.#fi(),this.requestUpdate()};#li=()=>{this.#fi(),this.requestUpdate()};#ui(e){return e.localName===`sankhya-ds-circle-button`?``:e.localName===`sankhya-ds-split-button`||e.localName===`sankhya-ds-menu-button`?(e.getAttribute(`label`)??``).trim():(e.textContent??``).trim()}#di(){let e=/* @__PURE__ */ new Map;for(let t of this.querySelectorAll(`:scope > [slot="actions"], :scope > [slot="selection-actions"]`)){if(!vt.includes(t.tagName))continue;let n=this.#ui(t),r=n||t.getAttribute(`label`)||t.getAttribute(`aria-label`)||``;if(n||H(this,`toolbar-no-label:${r}`,`ação "${r||t.localName}" do slot "${t.slot}" sem rótulo (Y02): ações da tela e da seleção levam ícone e rótulo; só busca, Atualizar, Exportar, engrenagem e ⋯ ficam só com ícone. Correção: <sankhya-ds-button variant="secondary" icon="...">Rótulo</sankhya-ds-button>.`),!r)continue;let i=r.toLocaleLowerCase(`pt-BR`),a=e.get(i);a&&a!==t.slot?H(this,`toolbar-duplicate:${i}`,`a ação "${r}" está em "actions" e em "selection-actions" (Y06): ao selecionar, as duas somam e o rótulo aparece duas vezes. Correção: deixe a ação num slot só (a que depende de seleção vai em selection-actions).`):e.set(i,t.slot)}}#fi(){for(let e of this.querySelectorAll(`:scope > [data-scope]`)){let t=e.dataset.scope;(e.slot!==`selection-actions`&&e.slot!==`custom-actions`||t!==`one`&&t!==`many`)&&H(this,`data-scope:${e.slot}:${t}`,`data-scope="${t}" no slot "${e.slot}": data-scope vale "one" (um registro) ou "many" (um ou mais) em ações de selection-actions e em itens de custom-actions (⚡). Correção: ajuste o valor ou tire o atributo.`)}let e=this.#ei();for(let t of this.querySelectorAll(`:scope > [slot="selection-actions"], :scope > [slot="custom-actions"]`)){let{reason:n,hint:r}=this.#pi(t,e),i=t.dataset.sankhyaDsScopeOff!==void 0;if(n&&(i||!t.hasAttribute(`disabled`)))i||(t.dataset.sankhyaDsScopeOff=t.getAttribute(`disabled-reason`)??``,t.dataset.sankhyaDsScopeHint=t.getAttribute(`disabled-hint`)??``),t.setAttribute(`disabled`,``),t.setAttribute(`disabled-reason`,n),r&&t.setAttribute(`disabled-hint`,r);else if(!n&&i){let e=t.dataset.sankhyaDsScopeOff,n=t.dataset.sankhyaDsScopeHint??``;delete t.dataset.sankhyaDsScopeOff,delete t.dataset.sankhyaDsScopeHint,t.removeAttribute(`disabled`),e?t.setAttribute(`disabled-reason`,e):t.removeAttribute(`disabled-reason`),n?t.setAttribute(`disabled-hint`,n):t.removeAttribute(`disabled-hint`)}}}#pi(e,t){let n={reason:``,hint:``},r=e.dataset.scope;if(r!==`one`&&r!==`many`)return n;let i=e.slot===`custom-actions`,a=r===`one`&&t>1;if(!a&&(t>0||!i))return n;let o=i?(e.textContent??``).trim():this.#ui(e),s=/^.[A-Z]/.test(o)?o:St(o),c=W(a?s?G`Selecione só um registro para ${s}`:`Selecione só um registro`:s?G`Selecione um registro para ${s}`:`Selecione um registro`);return i?{reason:W(a?`Disponível com 1 registro`:`Nenhum registro selecionado`),hint:c}:{reason:c,hint:``}}#mi(){return this.#rn()||this.searchable||this.refreshable||this.exportable||this.#pe.test(`custom-actions`)||this.#pe.test(`more-actions`)||this.#pe.test(`actions`)||this.#pe.test(`selection-actions`)||this.#me.leaving}#hi(){let e=this.#rn(),t=this.selectable&&this.selected.length>0,n=this.#pe.test(`custom-actions`);return L`<div class="toolbar" part="toolbar" ?hidden=${this.#he.hidden}> ${this.#_i()} <div class="toolbar-actions${!t&&!this.#pe.test(`actions`)&&!this.#me.leavingFrom(`actions`)?` idle`:``}" > <div class="toolbar-mode${t?``:` off`}" ?inert=${!t}> <slot name="selection-actions" @slotchange=${this.#ci}></slot> </div> <slot name="actions" @slotchange=${this.#ci}></slot> </div> ${this.#gi(n,this.#Pi())} ${this.#gi(this.refreshable,L`<sankhya-ds-circle-button class="tool-btn" part="refresh-button" icon="sync" size="sm" variant="secondary" label=${W(`Atualizar`)} @click=${this.#xi} ></sankhya-ds-circle-button>`)} ${this.#gi(this.exportable,L`<sankhya-ds-circle-button class="tool-btn" part="export-button" icon="export" size="sm" variant="secondary" label=${W(`Exportar`)} @click=${this.#Si} ></sankhya-ds-circle-button>`)} ${this.#gi(e,L`<sankhya-ds-circle-button class="options-btn" part="options-button" icon="setting" size="sm" variant="secondary" label=${W(`Configurar grade`)} aria-haspopup="dialog" aria-expanded=${this.#Be?`true`:`false`} @click=${this.#sa} ></sankhya-ds-circle-button>`)} ${this.#Ki()} </div>`}#gi(e,t){return L`<div class="tool${e?` on`:``}" ?inert=${!e}>${t}</div>`}#_i(){let e=this.filter.query??``,t=this.#ie||!!e||!this.#ae;return L`<div class="toolbar-search tool sankhya-ds-swap${t?` open`:``}${this.searchable?` on`:``}" ?inert=${!this.searchable} > ${tt(t?`field`:`button`,()=>t?L`<sankhya-ds-search class="search-field" part="search" size="sm" aria-label=${W(`Buscar na grade`)} placeholder=${W(`Buscar`)} .value=${e} @sankhya-ds-search=${this.#yi} @focusout=${this.#bi} ></sankhya-ds-search>`:L`<sankhya-ds-circle-button class="search-btn" part="search-button" icon="search" size="sm" variant="secondary" label=${W(`Buscar`)} @click=${this.#vi} ></sankhya-ds-circle-button>`)} </div>`}#vi=()=>{this.#ie=!0,this.requestUpdate(),this.updateComplete.then(()=>{let e=this.renderRoot.querySelector(`.search-field:not([data-leaving])`);e?.updateComplete?.then(()=>e.focus())})};#yi=e=>{e.stopPropagation();let t=e.detail.value;(this.filter.query??``)!==t&&(this.filter={...this.filter,query:t},this.#Vt=!0,this.emit(`sankhya-ds-filter-change`,{filter:this.filter,filterRow:this.filterRow}))};#bi=e=>{let t=e.currentTarget;t.contains(e.relatedTarget)||t.value||(this.#ie=!1,this.requestUpdate())};#xi=()=>{this.emit(`sankhya-ds-refresh`,void 0,{cancelable:!0}).defaultPrevented||this.refresh()};#Si=()=>{this.emit(`sankhya-ds-export`,void 0,{cancelable:!0}).defaultPrevented||this.#Ti()};#Ci=!1;#wi=!1;async#Ti(){await at(),this.#Ci=!0,this.#wi=!0,this.requestUpdate()}#Ei(){let e=[],t=n=>{for(let r of n)e.push(r),t(this.#Q.children.get(r)??[])};return t(this.#Q.rows),e}#Di(){let e=this.querySelector(`:scope > [slot="pagination"]`),t=Number(e?.total)>0?Number(e.total):null,n=this.dataSource?null:this.#Ei().length;return{page:e&&n!==null?n:null,selected:this.selectable?this.#ei():null,filtered:t??(this.dataSource?this.#ee?.total??null:n)}}#Oi(){return(this.#q.order.length?this.#q.order:this.#G.leaves.map(e=>e.id)).flatMap(e=>{let t=this.#G.byId.get(e);return!t||t.def.actions||t.type===`component`?[]:[{key:e,label:a(t,this.#G.groups),hidden:this.#q.hidden.includes(e)}]})}#ki(){if(!this.#Ci)return R;let e=this.#wi?this.#Di():null;return L`<sankhya-ds-export-dialog class="export-dialog" part="export-dialog" .open=${this.#wi} .columns=${this.#wi?this.#Oi():[]} .pageCount=${e?.page??null} .selectedCount=${e?.selected??null} .filteredCount=${e?.filtered??null} .scope=${e?.selected?`selected`:`filtered`} .filename=${this.label} @sankhya-ds-export=${this.#ji} @sankhya-ds-open=${e=>e.stopPropagation()} @sankhya-ds-close=${this.#Ai} ></sankhya-ds-export-dialog>`}#Ai=e=>{e.stopPropagation(),this.#wi&&(this.#wi=!1,this.requestUpdate())};#ji=e=>{e.stopPropagation(),e.preventDefault();let{format:t,columns:n,filename:r,count:i}=e.detail,a=e.detail.scope===`all`?`filtered`:e.detail.scope,o={format:t,scope:a,columns:[...n],filename:r,count:i,selected:this.selected,allMatching:this.allMatching,filter:this.filter,sort:this.sort};if(this.emit(`sankhya-ds-request-export`,o,{cancelable:!0}).defaultPrevented)return;let s=this.#pe.test(`pagination`),c=!this.dataSource&&(a===`selected`||a===`page`||a===`filtered`&&!s);t!==`csv`||!c?H(this,`request-export:${t}:${a}`,`exportar ${t.toUpperCase()} (${a}) não é gerado pela grade: ela só gera CSV das linhas que tem na mão. Correção: trate sankhya-ds-request-export, chame preventDefault() e gere o arquivo (ex.: no servidor, com detail.filter e detail.sort).`):this.exportCsv({filename:r,columns:n,rows:a===`selected`?`selected`:`all`})};#Mi(){return[...this.querySelectorAll(`:scope > [slot="custom-actions"]`)]}#Ni=``;#Pi(){let e=this.#Mi().length>=wt;return L`<sankhya-ds-dropdown-menu class="custom-menu" part="custom-actions" placement="bottom-start" label=${W(`Ações personalizadas`)} @sankhya-ds-select=${e=>this.#Xi(e,`custom`)} @sankhya-ds-open=${this.#Fi} @sankhya-ds-close=${this.#Ii} > <sankhya-ds-circle-button slot="trigger" class="custom-btn" part="custom-actions-button" @click=${this.#Ui} @keydown=${this.#Wi} icon="bolt" size="sm" variant="secondary" label=${W(`Ações personalizadas`)} shortcut="Ctrl+Alt+B" ></sankhya-ds-circle-button> ${e?L`<div class="custom-search" slot="header"> <sankhya-ds-search class="custom-search-field" part="custom-actions-search" size="sm" aria-label=${W(`Buscar ações personalizadas`)} placeholder=${W(`Buscar`)} .value=${this.#Ni} @sankhya-ds-search=${this.#Li} @sankhya-ds-input=${this.#Li} @sankhya-ds-change=${e=>e.stopPropagation()} @sankhya-ds-clear=${e=>e.stopPropagation()} @keydown=${this.#zi} ></sankhya-ds-search> <div class="sankhya-ds-swap custom-status" role="status"> ${tt(!!this.#Ni.trim()&&this.#Mi().every(e=>e.hidden),()=>L`<p class="custom-empty">${W(`Nenhuma ação encontrada`)}</p>`)} </div> </div>`:R} <slot name="custom-actions" @slotchange=${this.#li}></slot> </sankhya-ds-dropdown-menu>`}#Fi=e=>{e.stopPropagation();let t=this.renderRoot.querySelector(`.custom-search-field`);t&&t.updateComplete.then(()=>t.focus())};#Ii=e=>{e.stopPropagation(),this.#Ni&&this.#Ri(``)};#Li=e=>{e.stopPropagation(),this.#Ri(e.detail.value)};#Ri(e){this.#Ni=e;let t=g(e.trim());for(let e of this.#Mi()){let n=e.dataset.sankhyaDsSearchHidden!==void 0,r=!t||g(e.textContent??``).includes(t);!r&&!e.hidden?(e.dataset.sankhyaDsSearchHidden=``,e.hidden=!0):r&&n&&(delete e.dataset.sankhyaDsSearchHidden,e.hidden=!1)}this.requestUpdate()}#zi=e=>{let t=this.renderRoot.querySelector(`.custom-menu`);e.key===`ArrowDown`?(e.preventDefault(),this.#Mi().find(e=>!e.hidden)?.focus()):e.key===`Escape`&&!this.#Ni?(e.preventDefault(),t.hide()):e.key===`Tab`&&t.hide()};#Bi=()=>{Y()||Xe().catch(()=>void 0)};async#Vi(e){try{await Xe()}catch{return H(this,`menu-load`,`os menus da grade não carregaram (rede?). Tente de novo.`),!1}await customElements.whenDefined(`sankhya-ds-dropdown-menu`),await e.updateComplete;let t=document.activeElement;return e.isConnected&&(!t||t===document.body||this.matches(`:focus-within`))}async#Hi(e){await this.#Vi(e)&&e.show()}#Ui=e=>{Y()||this.#Hi(e.currentTarget.parentElement)};#Wi=e=>{e.key!==`ArrowDown`&&e.key!==`ArrowUp`||Y()||(e.preventDefault(),this.#Ui(e))};#Gi=e=>{if(!e.ctrlKey||!e.altKey||e.shiftKey||e.metaKey||e.getModifierState(`AltGraph`))return;if(e.code===`KeyL`){if(!this.#rn()||!this.optionItems.includes(`find-column`))return;e.preventDefault(),this.#Be||this.#sa(),this.updateComplete.then(()=>this.renderRoot.querySelector(`.options:not(.leaving) .find-input`)?.focus());return}if(e.code!==`KeyB`)return;let t=this.renderRoot.querySelector(`.tool.on > .custom-menu`);t&&(e.preventDefault(),Y()?t.show():this.#Hi(t))};#Ki(){let e=this.#pe.test(`more-actions`);return this.#gi(this.#le.length>0||e,L`<sankhya-ds-dropdown-menu class="overflow-menu" part="overflow" placement="bottom-end" label=${W(`Mais ações`)} @sankhya-ds-select=${this.#Yi} @sankhya-ds-open=${this.#Ji} @sankhya-ds-close=${e=>e.stopPropagation()} > <sankhya-ds-circle-button slot="trigger" class="overflow-btn" part="overflow-button" @click=${this.#Ui} @keydown=${this.#Wi} icon="ellipsis-h" size="sm" variant="secondary" label=${W(`Mais ações`)} ></sankhya-ds-circle-button> ${this.#le.map((e,t)=>this.#qi(e,t))} ${this.#le.length&&e?L`<hr class="overflow-divider" />`:R} <slot name="more-actions"></slot> </sankhya-ds-dropdown-menu>`)}#qi(e,t){let n=e.getAttribute(`label`)||e.textContent.trim(),r=e.localName===`sankhya-ds-split-button`?[...e.children].filter(e=>e.localName===`sankhya-ds-menu-item`):[];return L`<sankhya-ds-menu-item class="overflow-item" value=${`${yt}${t}`} icon=${e.getAttribute(`icon`)??``} ?disabled=${e.hasAttribute(`disabled`)} disabled-reason=${e.dataset.sankhyaDsScopeOff===void 0?e.getAttribute(`disabled-reason`)??``:W(`Disponível com 1 registro`)} disabled-hint=${e.dataset.sankhyaDsScopeOff===void 0?e.getAttribute(`disabled-hint`)??``:e.getAttribute(`disabled-reason`)??``} shortcut=${e.getAttribute(`shortcut`)??``} >${n}${r.length?L`<sankhya-ds-menu-item slot="submenu" class="overflow-sub" value=${`${yt}${t}:main`} icon=${e.getAttribute(`icon`)??``} >${n}</sankhya-ds-menu-item >${r.map((e,n)=>L`<sankhya-ds-menu-item slot="submenu" class="overflow-sub" value=${`${yt}${t}:${n}`} icon=${e.getAttribute(`icon`)??``} ?disabled=${e.hasAttribute(`disabled`)} disabled-reason=${e.getAttribute(`disabled-reason`)??``} disabled-hint=${e.getAttribute(`disabled-hint`)??``} ?divider=${n===0} >${e.text??e.textContent.trim()}</sankhya-ds-menu-item >`)}`:R}</sankhya-ds-menu-item >`}#Ji=async e=>{e.stopPropagation();let t=e.currentTarget;for(let e of Ct)if(t.width=e,await t.updateComplete,!t.items.some(e=>e.truncated))return};#Yi=e=>{let{item:t,value:n}=e.detail;if(t.classList.contains(`overflow-item`)||t.classList.contains(`overflow-sub`)){e.stopPropagation();let[t,r]=n.slice(20).split(`:`),i=this.#le[Number(t)];if(!i)return;if(r===void 0||r===`main`){i.click();return}let a=[...i.children].filter(e=>e.localName===`sankhya-ds-menu-item`)[Number(r)];if(!a)return;i.dispatchEvent(new CustomEvent(`sankhya-ds-select`,{bubbles:!0,composed:!0,cancelable:!0,detail:{item:a,value:a.value||a.text||a.textContent.trim(),checked:!!a.checked}}))}else this.#Xi(e,`more`)};#Xi(e,t){e.stopPropagation(),this.emit(`sankhya-ds-action`,{item:e.detail.item,value:e.detail.value,source:t})}#Zi(){let e=this.renderRoot.querySelector(`.toolbar`),t=this.renderRoot.querySelector(`.toolbar-actions`);if(!e||!t||e.hidden)return;let n=this.renderRoot.querySelector(`.toolbar-search`),r=this.renderRoot.querySelector(`.search-field:not([data-leaving])`);if(r&&n){let e=parseFloat(getComputedStyle(n).minInlineSize);e>0&&(this.#ce=e)}let i=this.#ie||!!this.filter.query||(r?.matches(`:focus-within`)??!1),a=Ye(e),o=()=>e.getBoundingClientRect().right-parseFloat(getComputedStyle(e).paddingInlineEnd)*a,s=()=>[...e.children].some(e=>e.getBoundingClientRect().right>o()+a),c=()=>{let e=[...t.querySelectorAll(`slot`)].flatMap(e=>e.assignedElements({flatten:!0})).filter(e=>e.getClientRects().length).at(-1);return e?e.getBoundingClientRect().right>t.getBoundingClientRect().right+a:!1},l=()=>c()||s(),u=[...this.querySelectorAll(`[slot="actions"], [slot="selection-actions"]`)];for(let e of u)e.removeAttribute(`data-sankhya-ds-overflow`);let d=r&&n?n.getBoundingClientRect().width/a<this.#ce-1:!1;if(this.searchable&&!this.#ae&&!i&&(d||l())&&this.#Qi(!0))return;if(n?.querySelector(`[data-leaving]`)){clearTimeout(this.#se),this.#se=setTimeout(()=>this.requestUpdate(),xt);return}let f=[...this.selectable&&this.selected.length>0?this.querySelectorAll(`:scope > [slot="selection-actions"]`):[],...this.querySelectorAll(`:scope > [slot="actions"]`)].filter(e=>!e.hidden),p=[];for(let e=f.length-1;e>=0&&l();e--)f[e].setAttribute(`data-sankhya-ds-overflow`,``),p.unshift(f[e]);if(this.searchable&&this.#ae&&!p.length&&n){let t=[...e.children].filter(e=>e.getClientRects().length),r=t.reduce((e,t)=>e+t.offsetWidth,0),i=Math.max(0,t.length-1)*bt,a=getComputedStyle(e);e.clientWidth-parseFloat(a.paddingInlineStart)-parseFloat(a.paddingInlineEnd)-r-i+n.offsetWidth>=this.#ce+bt&&this.#Qi(!1)}(p.length!==this.#le.length||p.some((e,t)=>e!==this.#le[t]))&&(this.#le=p,this.requestUpdate())}#Qi(e){return this.#oe>=Tt?!1:(this.#oe++||requestAnimationFrame(()=>this.#oe=0),this.#ae=e,this.requestUpdate(),!0)}#$i(){if(!this.selectable)return R;let e=this.#ei(),n=e>1&&!this.#ta,r=n?e:this.#tt.get(`feedback`)?.value;if(!r)return R;if(n){if(this.dataSource){let t=this.#ee?.total??0;this.#ra=!this.allMatching&&t>1&&t>e?t:0}else{let e=this.#Qt(),t=new Set(this.selected);this.#ra=e.length>1&&e.some(e=>!t.has(e))?e.length:0}}let i=this.#ra;return L`<div class="feedback-area${n?``:` leaving`}" data-leave=${n?R:`feedback`} ?inert=${!n} > <div class="selection-feedback" part="selection-feedback"> <span class="feedback-text">${this.#oi(r)}</span> ${i?L`<button type="button" class="feedback-all" @click=${this.#ia}> ${W(G`Selecionar todos os ${t(i,`number`)} registros`)} </button>`:R} <button type="button" class="feedback-clear" @click=${this.#aa}> ${W(`Limpar seleção`)} </button> <sankhya-ds-circle-button class="feedback-close" icon="times" size="xs" variant="tertiary" label=${W(`Fechar`)} @click=${this.#oa} ></sankhya-ds-circle-button> </div> </div>`}#ea=!1;#ta=!1;#na=null;#ra=0;#ia=()=>{if(this.dataSource){this.#ni();return}let e=this.#Qt(),t=new Set(e);this.selected=[...this.selected.filter(e=>!t.has(e)),...e],this.#$r()};#aa=()=>{this.selected=[],this.#$r()};#oa=()=>{this.#ta=!0,this.#na=this.selected,this.requestUpdate(),this.#Nt(`feedback`,this.#ei())};#sa=()=>{this.#Be?this.#ca():(this.#Be=!0,this.#Ve=!0,this.emit(`sankhya-ds-configure`),this.#He=``,this.#Ue=0,this.requestUpdate())};#ca(e=!0){this.#Be=!1,kt(this.renderRoot.querySelector(`.options:not(.leaving)`)),this.requestUpdate(),e&&this.#si()?.focus()}#la=e=>{e.newState===`closed`&&this.#Be&&(e.target.dataset.dismissed=``,this.#Be=!1,this.requestUpdate())};#ua(){let e=this.columnsLocked?this.#G.leaves.filter(e=>!this.#q.hidden.includes(e.id)):this.#G.leaves;return ie(e,this.#He)}#da(){if(!this.#Be)return R;let e=this.optionItems.includes(`find-column`),t=this.#ua(),n=Math.min(this.#Ue,t.length-1),r=this.#tn();return L`<div class="menu options" part="options" popover="auto" role="dialog" aria-label=${W(`Opções da grade`)} @beforetoggle=${this.#Ot} @toggle=${this.#la} @keydown=${this.#pa} > ${e?L`<div class="find-field"> ${j()} <input class="find-input" type="search" role="combobox" autocomplete="off" aria-label=${W(`Localizar coluna`)} aria-keyshortcuts="Control+Alt+L" placeholder=${W(`Localizar coluna… (Ctrl+Alt+L)`)} aria-autocomplete="list" aria-expanded=${t.length?`true`:`false`} aria-controls=${t.length?`find-list`:R} aria-activedescendant=${t.length?`find-${n}`:R} .value=${V(this.#He)} @input=${e=>{this.#He=e.target.value,this.#Ue=0,this.requestUpdate()}} /> </div> ${this.#He.trim()?t.length?L`<div id="find-list" class="find-list" role="listbox" aria-label=${W(`Colunas encontradas`)} > ${t.map((e,t)=>L`<div id="find-${t}" class="item${t===n?` active`:``}" role="option" aria-selected=${t===n?`true`:`false`} @pointerdown=${e=>e.preventDefault()} @click=${()=>this.#ma(e.id)} > <span class="text">${a(e,this.#G.groups)}</span>${this.#q.hidden.includes(e.id)?L`<span class="visually-hidden">, </span ><span class="hidden-mark">${W(`oculta`)}</span>`:R} </div>`)} </div>`:L`<div class="find-empty" role="status"> ${W(`Nenhuma coluna encontrada.`)} </div>`:R} ${r.length?L`<div class="sep" role="separator"></div>`:R}`:R} ${r.length?L`<div role="menu" aria-label=${W(`Opções da grade`)}> ${r.map(e=>L`<button type="button" class="item" role="menuitem" tabindex="-1" data-option=${e.id} @click=${()=>this.#fa(e.id,e.run)} > ${e.icon}<span class="text">${e.label}</span> </button>`)} </div>`:R} </div>`}#fa(e,t){let n=e===`search`&&!this.filterRow||e===`dynamic-mode`&&!this.dynamicMode;this.#ca(!n),t()}#pa=e=>{let t=e.currentTarget,n=e.target,r=[...t.querySelectorAll(`[role="menuitem"]`)],i=t.querySelector(`.find-input`),a=[...i?[i]:[],...r],o=a.indexOf(n),s=e=>a[(e+a.length)%a.length].focus();if(e.key===`Escape`||e.key===`Tab`)this.#ca();else if(n===i){let t=this.#ua(),n=Math.min(this.#Ue,t.length-1);if(e.key===`Enter`&&t.length)this.#ma(t[n].id);else if(e.key===`ArrowDown`&&t.length)this.#Ue=(n+1)%t.length,this.requestUpdate();else if(e.key===`ArrowUp`&&t.length)this.#Ue=(n||t.length)-1,this.requestUpdate();else if(e.key===`ArrowDown`&&r.length)r[0].focus();else if(e.key===`ArrowUp`&&r.length)r.at(-1).focus();else return}else if(e.key===`ArrowDown`)s(o+1);else if(e.key===`ArrowUp`)s(o-1);else if(e.key===`Home`)s(0);else if(e.key===`End`)s(a.length-1);else return;e.preventDefault(),e.stopPropagation()};#ma(e){this.#ca(!1),this.#q.hidden.includes(e)&&this.#Dt(D(this.#q,e,!1)),this.#We=e,document.removeEventListener(`pointerdown`,this.#Ge,!0),document.addEventListener(`pointerdown`,this.#Ge,!0),this.updateComplete.then(()=>{this.#jn(null),this.#hn({row:-1,col:this.#Se.findIndex(t=>t.id===e)})}),this.#ze=W(G`Coluna ${this.#G.byId.get(e).header} encontrada.`),this.requestUpdate()}#ha(e){if(this.filterRow=e,e)this.#lt=`.filter-input`;else{let e={...this.filter};delete e.columns,this.filter=e}this.emit(`sankhya-ds-filter-change`,{filter:this.filter,filterRow:e})}#ga(e,t){let n=!this.filterRow;return L`<div role="row" class="row filter-row${n?` leaving`:``}" aria-rowindex=${t} data-leave=${n?`filter-row`:R} ?inert=${n} > ${B(e,e=>e.col.id,e=>L`<div role="gridcell" class=${this.#oo(e,`filter-cell`)} style=${K(e.style)} aria-colindex=${e.index+1} > ${e.spec?L`<input class="filter-input" type="search" autocomplete="off" data-filter=${e.col.id} aria-label=${W(G`Buscar em ${e.spec.header}`)} .value=${V(this.filter.columns?.[e.col.id]??``)} @input=${this.#_a} />`:R} </div>`)}${this.#ai()} </div>`}#_a=e=>{let t=e.target,n={...this.filter.columns};t.value.trim()?n[t.dataset.filter]=t.value:delete n[t.dataset.filter],this.filter={...this.filter,columns:n},this.emit(`sankhya-ds-filter-change`,{filter:this.filter,filterRow:this.filterRow})};#va(e,t=!1){this.dynamicMode=e,e?this.#lt=`.panel-search`:t&&(this.#lt=`.options-btn`),this.emit(`sankhya-ds-dynamic-mode-change`,{dynamicMode:e})}#ya(){return!this.dataSource&&!this.subRows}#ba(){let e=!this.dynamicMode;if(e&&!this.#tt.has(`panel`))return R;let t=this.#q,n=t.order.flatMap(e=>this.#G.byId.get(e)??[]),r=this.#Ke.trim()?ie(n,this.#Ke):n,i=n.filter(e=>!t.hidden.includes(e.id)).length,a=(e,t,n,r)=>L`<section class="zone${this.#st===e?` over`:``}" aria-label=${t} data-zone=${e} @dragover=${this.#za} @dragleave=${this.#Ba} @drop=${this.#Va} > <div class="zone-title">${t}</div> ${r.length?L`<ul class="chips"> ${r} </ul>`:L`<p class="hint">${n}</p>`} </section>`,o=e=>this.#G.byId.get(e).header,s=(e,t)=>e?.target===t?e.after?` drop-after`:` drop-before`:``,c=(e,t)=>this.#qe===e&&this.#Je===t?`true`:`false`;return L`<aside class="panel${e?` leaving`:``}${this.#ot?` ease-size`:``}" part="panel" aria-label=${W(`Agrupar e totalizar`)} style=${K(this.#Qe?`--_panel-w:${this.#Qe}px`:R)} data-leave=${e?`panel`:R} ?inert=${e} @keydown=${this.#wa} > ${this.#ct||e?R:L`<div class="panel-resizer" role="separator" tabindex="0" aria-orientation="vertical" aria-label=${W(`Largura do painel Agrupar e totalizar`)} @keydown=${this.#ka} @pointerdown=${this.#Aa} @pointermove=${this.#ja} @pointerup=${this.#Ma} @lostpointercapture=${this.#Ma} ></div>`} <div class="panel-body"> <div class="panel-head"> <span class="panel-title">${W(`Agrupar e totalizar`)}</span> <button type="button" class="icon-btn" aria-label=${W(`Fechar painel Agrupar e totalizar`)} @click=${()=>this.#va(!1,!0)} > ${k()} </button> </div> <div class="find-field"> ${j()} <input class="panel-search" type="search" autocomplete="off" aria-label=${W(`Buscar coluna`)} placeholder=${W(`Buscar coluna`)} .value=${V(this.#Ke)} @input=${e=>{this.#Ke=e.target.value,this.requestUpdate()}} /> </div> <ul class="col-list" aria-label=${W(`Colunas`)}> ${B(r,e=>e.id,e=>{let n=!t.hidden.includes(e.id),r=n&&(!e.hideable||i<2),a=L`<span class="text" id=${`panel-text-${e.id}`} @pointerenter=${this.#Ln.check} >${e.header}</span >${this.#Ln.render(`panel-text-${e.id}`,e.header)}`,o=!this.columnsLocked||this.#ya()||this.#co(e);return L`<li class="col-item${s(this.#Xe,e.id)}" draggable="true" data-panel-id=${e.id} data-flip="move" data-key=${`col:${e.id}`} @dragstart=${this.#Na} @dragover=${this.#Pa} @drop=${this.#Fa} @dragend=${this.#Nr} > <span class="grip" aria-hidden="true">${Te()}</span> ${this.columnsLocked?L`<span class="col-label">${a}</span>`:L`<label class="col-label"> <input type="checkbox" class="check sankhya-ds-check" data-panel-id=${e.id} aria-describedby="panel-hint" aria-disabled=${r?`true`:R} .checked=${n} @click=${t=>{r?t.preventDefault():this.#Dt(D(this.#q,e.id,n))}} /> ${a} </label>`} ${o?L`<button type="button" class="icon-btn" data-panel-menu=${e.id} aria-label=${W(G`Ações da coluna ${e.header}`)} aria-haspopup="menu" aria-expanded=${c(e.id,`actions`)} @click=${()=>this.#Wa(e.id,`actions`)} > ${A()} </button>`:R} </li>`})} </ul> ${r.length?R:L`<p class="hint">${W(`Nenhuma coluna encontrada.`)}</p>`} <p id="panel-hint" class="visually-hidden"> ${W(`Alt+seta para cima ou para baixo muda a posição da coluna.`)} </p> <p id="group-hint" class="visually-hidden"> ${W(`Alt+seta para cima ou para baixo muda a ordem dos agrupamentos.`)} </p> ${this.#ya()?a(`group`,W(`Agrupamentos`),W(`Arraste as colunas até aqui para criar grupos`),t.groupBy.map((e,n)=>L`<li class="chip${s(this.#Ze,e)}" draggable="true" tabindex="0" data-group-id=${e} data-flip="exit" data-key=${`group:${e}`} aria-label=${W(G`Agrupamento ${n+1} de ${t.groupBy.length}: ${o(e)}`)} aria-describedby="group-hint" @dragstart=${this.#Ia} @dragover=${this.#La} @drop=${this.#Ra} @dragend=${this.#Nr} > <span class="grip" aria-hidden="true">${Te()}</span> <span class="text" id=${`group-text-${e}`} @pointerenter=${this.#Ln.check} >${o(e)}</span >${this.#Ln.render(`group-text-${e}`,o(e))} <button type="button" class="icon-btn" aria-label=${W(G`Remover agrupamento por ${o(e)}`)} @click=${()=>this.#Dt(ue(this.#q,e,!1))} > ${k()} </button> </li>`)):R} ${this.dataSource?R:a(`aggregate`,W(`Colunas totalizadas`),W(`Arraste as colunas numéricas até aqui para totalizar`),Object.entries(t.aggregates??{}).map(([e,t])=>{let n=this.#Sa(t,o(e));return L`<li class="chip" data-flip="exit" data-key=${`agg:${e}`}> <button type="button" class="chip-btn" id=${`agg-chip-${e}`} data-agg-menu=${e} @pointerenter=${this.#Ln.check} @focusin=${this.#Ln.check} aria-haspopup="menu" aria-expanded=${c(e,`aggregate`)} @click=${()=>this.#Wa(e,`aggregate`)} > <span class="text" data-cut>${n}</span>${xe()}</button >${this.#Ln.render(`agg-chip-${e}`,n)} <button type="button" class="icon-btn" aria-label=${W(G`Remover total de ${o(e)}`)} @click=${()=>this.#Dt(ce(this.#q,e,null))} > ${k()} </button> </li>`}))} </div> </aside>`}#xa(e){return{sum:W(`Soma`),avg:W(`Média`),min:W(`Mínimo`),max:W(`Máximo`),count:W(`Contagem`),first:W(`Primeiro`),last:W(`Último`)}[e]}#Sa(e,t){return W(G`${this.#xa(e)} (${t})`)}#Ca(e){let t=this.#et&&!this.dataSource?e.def.aggregate:void 0;return t?this.#Sa(t,e.header):e.header}#wa=e=>{let t=e.target,{panelId:n,groupId:r}=t.dataset,i=e.key===`ArrowUp`?-1:+(e.key===`ArrowDown`);(n||r)&&e.altKey&&i?(e.preventDefault(),n?this.#Ta(n,i):this.#Ea(r,i)):e.key===`Escape`&&(e.preventDefault(),t.matches(`.panel-search`)&&this.#Ke?(this.#Ke=``,this.requestUpdate()):this.#va(!1,!0))};#Ta(e,t){if(this.columnsLocked)return;let n=oe(this.#q,e,t);if(!n)return;this.#Dt(E(this.#q,e,n,t>0));let r=this.#q.order.indexOf(e)+1;this.#ze=W(G`${this.#G.byId.get(e).header}: posição ${r} de ${this.#q.order.length}.`),this.#lt=`.col-item[data-panel-id="${CSS.escape(e)}"] .check`}#Ea(e,t){let n=le(this.#q,e,t);if(n===this.#q)return;this.#Dt(n);let{groupBy:r}=this.#q,i=this.#G.byId.get(e).header;this.#ze=W(G`Agrupamento por ${i}: nível ${r.indexOf(e)+1} de ${r.length}.`),this.#lt=`.chip[data-group-id="${CSS.escape(e)}"]`}#Da(){let e=this.renderRoot.querySelector(`.panel:not(.leaving)`),t=getComputedStyle(e),n=Math.round(parseFloat(t.minInlineSize)),r=e.parentElement.clientWidth-n;return{min:n,max:Math.max(n,Math.round(Math.min(parseFloat(t.maxInlineSize),r)))}}#Oa(e){let{min:t,max:n}=this.#Da();this.#Qe=Math.max(t,Math.min(n,Math.round(e))),this.requestUpdate()}#ka=e=>{let t=e.currentTarget.parentElement.offsetWidth,{min:n,max:r}=this.#Da(),i={ArrowLeft:t+At,ArrowRight:t-At,Home:n,End:r}[e.key];i!==void 0&&(e.preventDefault(),e.stopPropagation(),this.#ot=!0,this.#Oa(i))};#Aa=e=>{let t=e.currentTarget;e.preventDefault(),t.setPointerCapture(e.pointerId),this.#ot=!1,this.#$e={x:e.clientX,width:t.parentElement.offsetWidth}};#ja=e=>{this.#$e&&this.#Oa(this.#$e.width+this.#$e.x-e.clientX)};#Ma=()=>{this.#$e=null};#Na=e=>{let t=e.currentTarget.dataset.panelId;this.#Ae={id:t},e.dataTransfer?.setData(`text/plain`,t)};#Pa=e=>{let t=e.currentTarget;if(!this.#Ae||this.#Ae.from||this.columnsLocked)return;e.preventDefault();let n=t.getBoundingClientRect(),r={target:t.dataset.panelId,after:e.clientY>n.top+n.height/2};JSON.stringify(r)!==JSON.stringify(this.#Xe)&&(this.#Xe=r,this.requestUpdate())};#Fa=e=>{let t=this.#Ae,n=this.#Xe;this.#Nr(),t&&n&&(e.preventDefault(),this.#Dt(E(this.#q,t.id,n.target,n.after)))};#Ia=e=>{let t=e.currentTarget.dataset.groupId;this.#Ae={id:t,from:`group`},e.dataTransfer?.setData(`text/plain`,t)};#La=e=>{let t=e.currentTarget;if(!this.#Ae)return;let n=t.getBoundingClientRect(),r={target:t.dataset.groupId,after:e.clientY>n.top+n.height/2};JSON.stringify(r)!==JSON.stringify(this.#Ze)&&(this.#Ze=r,this.requestUpdate())};#Ra=e=>{let t=this.#Ae,n=this.#Ze;this.#Nr(),t&&n&&(e.preventDefault(),this.#Dt(ae(this.#q,t.id,n.target,n.after)))};#za=e=>{let t=e.currentTarget.dataset.zone;!this.#Ae||this.#Ae.from&&t!==`group`||(e.preventDefault(),this.#st!==t&&(this.#st=t,this.requestUpdate()))};#Ba=e=>{e.currentTarget.contains(e.relatedTarget)||(this.#st=null,this.requestUpdate())};#Va=e=>{let t=this.#Ae,n=e.currentTarget.dataset.zone;this.#Nr(),t&&!t.from&&(e.preventDefault(),n===`group`?this.#q.groupBy.includes(t.id)||this.#Ha(t.id):this.#q.aggregates?.[t.id]||this.#Ua(t.id))};#Ha(e){this.#Dt(ue(this.#q,e,!this.#q.groupBy.includes(e)))}#Ua(e){let t=this.#G.byId.get(e);if(!t.numeric){this.#ze=W(G`${t.header}: só colunas numéricas podem ser agregadas.`),this.requestUpdate();return}let n=!this.#q.aggregates?.[e];this.#Dt(ce(this.#q,e,n?`sum`:null))}#Wa(e,t){this.#qe=e,this.#Je=t,this.#Ye=!0,this.requestUpdate()}#Ga(){return`[${this.#Je===`aggregate`?`data-agg-menu`:`data-panel-menu`}="${CSS.escape(this.#qe)}"]`}#Ka(e=!0){let t=this.#Ga();this.#qe=null,kt(this.renderRoot.querySelector(`.panel-menu:not(.leaving)`)),this.requestUpdate(),e&&(this.#lt=t)}#qa=e=>{e.newState===`closed`&&this.#qe&&(e.target.dataset.dismissed=``,this.#qe=null,this.requestUpdate())};#Ja(e){let t=this.#q.aggregates?.[e];return ne.map(n=>({label:this.#xa(n),radio:!0,checked:n===t,run:()=>this.#Dt(ce(this.#q,e,n))}))}#Ya(){let e=this.#qe;if(!e||!this.dynamicMode)return R;let t=this.#G.byId.get(e),n=this.#q,r=[],i=W(G`Ações da coluna ${t.header}`);if(this.#Je===`aggregate`)i=W(G`Função de agregação de ${t.header}`),r.push({items:this.#Ja(e)});else{let i=this.columnsLocked?[]:[{label:W(`Mover para cima`),disabled:!oe(n,e,-1),run:()=>this.#Ta(e,-1)},{label:W(`Mover para baixo`),disabled:!oe(n,e,1),run:()=>this.#Ta(e,1)}];this.#ya()&&i.push({label:n.groupBy.includes(e)?W(`Desagrupar`):W(`Agrupar por esta coluna`),run:()=>this.#Ha(e)});let a=this.#co(t),o=a&&!!n.aggregates?.[e];a&&i.push({label:W(o?`Remover total`:`Totalizar (soma)`),run:()=>this.#Ua(e)}),r.push({items:i}),o&&r.push({label:W(`Função de agregação`),items:this.#Ja(e)})}return L`<div class="menu panel-menu" part="menu" popover="auto" role="menu" aria-label=${i} @beforetoggle=${this.#Ot} @toggle=${this.#qa} @keydown=${this.#Rr} > ${r.map((e,t)=>L` ${t?L`<div class="sep" role="separator"></div>`:R} ${e.label?L`<div class="menu-label" role="presentation">${e.label}</div>`:R} ${e.items.map(e=>L`<button type="button" class="item" role=${e.radio?`menuitemradio`:`menuitem`} aria-checked=${e.radio?String(e.checked):R} aria-disabled=${e.disabled?`true`:R} tabindex="-1" @click=${()=>{e.disabled||(this.#Ka(),e.run())}} > <span class="mark">${e.checked?be():R}</span>${e.label} </button>`)} `)} </div>`}#Xa(e,t,n){let r=this.getBoundingClientRect(),i=Math.max(0,r.left),a=Math.min(innerWidth,r.right);a-i<t&&([i,a]=[0,innerWidth]);let o=n?e.right-t:e.left;return!n&&o+t>a&&(o=e.right-t),n&&o<i&&(o=e.left),Math.max(i,Math.min(o,a-t))}#Za(e,t,n){delete e.dataset.dismissed,delete e.dataset.ghosted,e.showPopover(),window.addEventListener(`blur`,this.#kt),e.style.left=`${this.#Xa(t,e.offsetWidth,n)}px`;let r=e.offsetHeight,i=t.bottom+r>innerHeight&&t.top-r>=0?t.top-r:t.bottom;e.style.top=`${Math.max(0,Math.min(i,innerHeight-r))}px`,e.querySelector(`input, [role^="menuitem"]:not([aria-disabled="true"])`)?.focus()}#Qa(e,t,n){this.#dt&&this.#dt.view.id!==e.id&&this.#$a(),this.#dt??={index:e.index,view:e,values:/* @__PURE__ */ new Map},Object.is(t.accessor(e.data),n)?this.#dt.values.delete(t.id):this.#dt.values.set(t.id,n),this.requestUpdate()}#$a(){let e=this.#dt;if(!e)return;this.#dt=null,this.requestUpdate();let t=e.view.data,n=[...e.values].map(([e,n])=>({columnId:e,value:n,previousValue:this.#G.byId.get(e).accessor(t)}));n.length&&(this.emit(`sankhya-ds-row-commit`,{rowId:e.view.id,row:t,changes:n},{cancelable:!0}).defaultPrevented||this.#Wn(n.map(t=>({row:e.view,spec:this.#G.byId.get(t.columnId),value:t.value}))))}#eo(){this.#dt&&(this.#dt=null,this.#ze=W(`Alterações da linha descartadas.`),this.requestUpdate())}#to(e,t,n){let r=this.#uo(e),i=n?-1:1;for(let e=t+i;e>=0&&e<this.#Se.length;e+=i){let t=this.#G.byId.get(this.#Se[e].id);if(t&&this.#Hn(r,t))return e}return-1}#no=e=>{if(!this.#dt||this.#Fe)return;let t=e.relatedTarget?.closest?.(`[data-row]`);t&&Number(t.dataset.row)===this.#dt.index||this.#$a()};#ro(){let e=[],t=(t,n,r,i,a)=>{let o=t.getSize();e.push({col:t,spec:this.#G.byId.get(t.id),index:n,width:o,region:r,offset:i,style:ht(o,r,i),cls:a})},n=0;this.#ye.forEach((e,r)=>{t(e,r,`start`,n,`pin-start${r===this.#ye.length-1?` edge`:``}`),n+=e.getSize()});let r=n;for(let e of this.#we.getVirtualItems())t(this.#be[e.index],this.#ye.length+e.index,`center`,e.start-r,``),r=e.end;this.#Ce=`${this.#we.range?.startIndex}:${this.#we.range?.endIndex}`;let i=Q(this.#xe),a=this.#ye.length+this.#be.length;return this.#xe.forEach((e,n)=>{i-=e.getSize(),t(e,a+n,`end`,i,`pin-end${n===0?` edge first`:``}`)}),e}#io(e){let t=[];for(let n=0;n<this.#G.depth-1;n++){let r=[];for(let t of e){let e=t.spec?.path[n]??``,i=r.at(-1);e&&i?.id===e&&i.slots[0].region===t.region&&(t.region!==`center`||t.offset===0)?i.slots.push(t):r.push({id:e,slots:[t]})}t.push(L`<div role="row" class="row" aria-rowindex=${n+1}> ${r.map(({id:e,slots:t})=>{let n=t[0],r=t.at(-1),i=t.reduce((e,t)=>e+t.width,0),a=n.region===`end`?r.offset:n.offset,o=n.region===`start`?r.cls:n.cls;return L`<div role="columnheader" class="cell head group-head ${o}${e?``:` placeholder`}" style=${K(ht(i,n.region,a))} aria-colindex=${n.index+1} aria-colspan=${t.length} > ${e?L`<span class="label">${this.#G.groups.get(e).header}</span>`:R} </div>`})}${this.#ai()} </div>`)}return t}#ao(e,t){return e===this.#Le.row&&t===this.#Le.col?`0`:`-1`}#oo(e,t){let n=e.spec,r=` align-${n?.align??`center`}${n?.numeric?` num`:``}`,i=this.#so&&e.index===this.#Se.length-1?` last-col`:``;return`cell ${t} ${e.cls}${r}${n?.def.divider?` divider`:``}${i}`}#so=!0;#co(e){return!this.dataSource&&e.numeric}#lo(e){let t=e.col.id;if(t===`__select`)return this.dataSource?L`<div role="columnheader" class=${this.#oo(e,`head select-cell`)} style=${K(e.style)} aria-colindex=${e.index+1} aria-label=${W(`Seleção`)} tabindex=${this.#ao(-1,e.index)} data-row="-1" data-col=${e.index} data-id=${t} ></div>`:L`<div role="columnheader" class=${this.#oo(e,`head select-cell`)} style=${K(e.style)} aria-colindex=${e.index+1} tabindex=${this.#ao(-1,e.index)} data-row="-1" data-col=${e.index} data-id=${t} > <input type="checkbox" class="check sankhya-ds-check" tabindex="-1" aria-label=${W(`Selecionar todas as linhas`)} .checked=${this.#re===`all`} .indeterminate=${this.#re===`some`} @change=${()=>this.#ii()} /> </div>`;let n=e.spec,r=this.sort.findIndex(e=>e.id===t),i=this.sort[r],a=this.#Ae?.target===t?this.#Ae.after?` drop-after`:` drop-before`:``,o=this.#Ca(n),s=this.#cr(e.index);return L`<div role="columnheader" class=${this.#oo(e,`head${n.sortable?` sortable`:``}${a}${this.#We===t?` flash`:``}${s?` col-selected`:``}`)} style=${K(e.style)} aria-colindex=${e.index+1} aria-sort=${i?i.desc?`descending`:`ascending`:R} aria-selected=${this.columnSelect?String(s):R} tabindex=${this.#ao(-1,e.index)} draggable="true" id=${`head-${e.index}`} data-row="-1" data-col=${e.index} data-id=${t} @dragstart=${this.#Ar} @pointerenter=${this.#In} @focusin=${this.#In} > <span class="head-main"> <span class="label" data-cut>${o}</span> ${i?i.desc?ve():ye():R} ${i&&this.sort.length>1?L`<span class="sort-index" aria-hidden="true">${r+1}</span>`:R} ${this.filter.values?.[t]?L`<button type="button" class="filter-btn" id=${`filter-mark-${t}`} data-tip="always" tabindex="-1" aria-label=${W(G`Filtro ativo em ${n.header}`)} @pointerenter=${this.#Ln.check} > ${we(`filter-mark`)}</button >${this.#Ln.render(`filter-mark-${t}`,W(G`Filtro ativo em ${n.header}`))}`:R} </span> ${!this.columnsLocked||this.#Br(t).length?L`<button type="button" class="menu-btn" tabindex="-1" aria-haspopup="menu" aria-expanded=${this.#Oe===t?`true`:`false`} aria-label=${W(G`Opções da coluna ${n.header}`)} > ${A()} </button>`:R} <span class="filter-anchor" aria-hidden="true"></span> ${n.resizable?L`<span class="resizer" aria-hidden="true" @pointerdown=${this.#pr} @pointermove=${this.#mr} @pointerup=${this.#hr} @lostpointercapture=${this.#hr} @dblclick=${this.#gr} ></span>`:R} </div>`}#uo(e){if(this.dataSource){let t=this.#ee.get(e),n=t&&t[this.rowKey];return{index:e,id:String(n??e),data:t,tan:void 0,depth:0,group:!1,kind:t&&this.rowKind?.(t),status:t&&this.#do(t),canExpand:!1,expanded:!1}}let t=this.#$[e],n=t.getIsGrouped(),r=t.original;return{index:e,id:t.id,data:r,tan:t,depth:t.depth,group:n,kind:n?void 0:this.rowKind?.(r),status:n?void 0:this.#do(r),canExpand:t.getCanExpand(),expanded:t.getIsExpanded()}}#do(e){let t=this.rowStatus?.(e);return t===`negative`?(Ie(this,`rowStatus "negative"`,{...Pe,replacement:`"danger"`,ref:`vocabulário semântico, T13`}),`danger`):t}#fo(e,t,n){let r=this.#uo(e),i=this.#ne.has(r.id),a=this.#On(),o=r.kind?` kind-${r.kind}`:``,s=r.status?` status-${r.status}`:``,c=!!this.#it?.ids.has(r.id),l=`${this.#nt.has(r.id)?` row-in`:``}${c?` row-out`:``}`,u=this.#it?.row.id!==r.id&&r.expanded;return L`<div role="row" aria-hidden=${c?`true`:R} ?inert=${c} class="row${r.index%2&&!this.noStripes?` odd`:``}${r.index===this.rowCount-1?` last`:``}${r.group?` group-row`:``}${o}${s}${l}" style=${K(n)} data-row-key=${r.id} aria-rowindex=${e+this.#$t()+1} aria-selected=${this.selectable&&!r.group?String(i):R} aria-level=${a?r.depth+1:R} aria-expanded=${a&&r.canExpand?String(u):R} > ${B(t,e=>e.col.id,e=>this.#po(r,e,i))}${this.#ai()} </div>`}#po(e,n,r){let a=n.col.id,o=this.#Fe,s=o?.row===e.index&&o.col===n.index,c=S(this.#Ne,e.index,n.index),l,u=`${c?`in-range`:``}${s?` editing`:``}${s&&o.error?` invalid`:``}`;if(s)l=this.#tr(o);else if(!e.data)l=L`<span class="skeleton" aria-hidden="true"></span>`;else if(e.group)l=this.#Ro(e,a,n.spec);else if(a===`__select`)u+=` select-cell`,l=L`<input type="checkbox" class="check sankhya-ds-check" tabindex="-1" aria-label=${W(`Selecionar linha`)} .checked=${r} @change=${()=>this.#ri(e.id)} />`;else{let r=n.spec,o=this.#dt?.view.id===e.id?this.#dt.values:void 0,s=o?.has(a)?o.get(a):e.tan?e.tan.getValue(a):r.accessor(e.data);if(o?.has(a)&&(u+=` pending`),r.def.actions)u+=` visual actions-cell`,l=this.#xo(e,r);else if(r.def.render)u+=` visual`,l=this.#mo(e.data,r,s);else if(r.type===`boolean`){u+=` visual`;let t=!r.def.editor&&this.#Hn(e,r);l=L`<input type="checkbox" class="check sankhya-ds-check" tabindex="-1" ?disabled=${!t} aria-label=${r.header} .checked=${V(!!s)} @change=${t=>this.#qn(e,r,t.target.checked)} />`}else l=e.kind===`percent`&&r.numeric?t(s,`percent`,r.def):i(r,s,e.data)}let d=a===this.#Dn();if(d&&e.kind&&e.kind!==`percent`){let t=e.kind===`subtotal`?`(=) `:`(-) `;String(l).startsWith(t.trim())||(l=`${t}${l}`)}if(d&&e.status){let t=e.status===`warning`?W(`Atenção:`):W(`Crítico:`);l=L`<span class="visually-hidden">${t} </span>${l}`}return this.#On()&&d&&(l=L`<span class="tree" style=${K(`--_depth:${e.depth}`)}> <span class="toggle${e.expanded?` open`:``}" aria-hidden="true"> ${e.canExpand?Se():R} </span> <span class="text">${l}</span> </span>`),L`<div role="gridcell" class=${this.#oo(n,u)} style=${K(n.style)} aria-colindex=${n.index+1} aria-selected=${c?`true`:R} tabindex=${this.#ao(e.index,n.index)} id=${`cell-${e.index}-${n.index}`} data-row=${e.index} data-col=${n.index} > ${l} </div>`}#mo(e,t,n){let r=t.def.render,i=this.#ho.get(e),a=i?.get(t.id);if(a&&a.render===r&&Object.is(a.value,n))return a.node;let o=r(n,e);return o instanceof Node?(i||this.#ho.set(e,i=/* @__PURE__ */ new Map),i.set(t.id,{render:r,value:n,node:o})):i?.delete(t.id),o}#ho=/* @__PURE__ */ new WeakMap;#go=null;#_o;#vo=!1;#yo(e,t){let n=e.data,r=t.def.actions.filter(e=>!Z(e.hidden,n));return[...r.filter(e=>e.variant!==`danger`),...r.filter(e=>e.variant===`danger`)]}#bo(e){let t=this.#Se.map(e=>e.id===`__select`?void 0:this.#G.byId.get(e.id)).find(e=>e&&!e.def.actions),n=e.data,r=(t&&n&&!t.def.render?i(t,t.accessor(n),n):``).trim()||String(e.index+1);return W(G`Ações da linha ${r}`)}#xo(e,t){return this.#yo(e,t).length?L`<button type="button" class="row-menu-btn" part="row-menu-button" tabindex="-1" aria-haspopup="menu" aria-expanded="false" aria-label=${this.#bo(e)} @pointerdown=${this.#Co} @focus=${this.#Co} @click=${this.#wo} > ${A()} </button>`:R}#So(e){let t=this.#Mn(e);return{button:e,row:this.#uo(t.row),spec:this.#G.byId.get(this.#Se[t.col].id)}}#Co=e=>{let t=e.currentTarget;if(this.#go?.button===t)return;let n=this.#So(t);this.#vo?this.#_o={target:n,show:this.#_o?.show??!1}:(this.#go=n,this.requestUpdate())};#wo=async e=>{let t=e.currentTarget,n=this.#Mo();if(n.anchor===t&&this.#go?.button===t&&!this.#_o)return;e.stopImmediatePropagation();let r=this.#So(t);this.#vo?(this.#_o={target:r,show:!0},n.hide()):(this.#go=r,this.requestUpdate(),await this.#To(n))};async#To(e){if(await this.updateComplete,!Y()&&!await this.#Vi(e))return;await e.updateComplete;let t=this.#go;t?.button.isConnected&&(t.point?e.showAt(t.point.x,t.point.y):e.show())}#Eo=e=>{let t=this.#Oo(e.target);if(!t)return;e.preventDefault();let n=e.button!==2&&e.clientX===0&&e.clientY===0;this.#jo(t,n?this.#Ao(t):{x:e.clientX,y:e.clientY})};#Do(e){if(!(e.shiftKey&&e.key===`F10`||e.key===`ContextMenu`))return!1;let t=this.#Oo(e.target);return t?(this.#jo(t,this.#Ao(t)),!0):!1}#Oo(e){if(this.#Fe||!(e instanceof Element)||e.closest(`input, textarea, select, a[href], [contenteditable=""], [contenteditable="true"]`))return null;let t=e.closest(`[role="gridcell"][data-row]`);return!t||t.classList.contains(`select-cell`)?null:this.#ko(this.#uo(Number(t.dataset.row)))?t:null}#ko(e){if(!e.group&&e.data)return this.#Se.map(e=>this.#G.byId.get(e.id)).find(t=>t?.def.actions&&this.#yo(e,t).length)}#Ao(e){let t=e.getBoundingClientRect();return{x:t.left,y:t.bottom}}async#jo(e,t){let n=this.#Mo(),r=this.#uo(Number(e.dataset.row)),i={button:e,row:r,spec:this.#ko(r),point:t};if(this.#vo){let e=this.#go;if(n.open&&e?.point&&e.row.data===r.data&&!this.#_o){this.#go=i,n.showAt(t.x,t.y);return}this.#_o={target:i,show:!0},n.hide()}else this.#go=i,this.requestUpdate(),await this.#To(n)}#Mo(){return this.renderRoot.querySelector(`.row-menu`)}#No=e=>{e.stopPropagation(),this.#vo=!0};#Po=e=>{e.stopPropagation();let t=e.currentTarget;M(t.shadowRoot.querySelector(`.panel`),()=>{if(t.open)return;this.#vo=!1;let e=this.#_o;e&&(this.#_o=void 0,this.#go=e.target,this.requestUpdate(),e.show&&this.#To(t))})};#Fo(e){let t=this.#go;if(!t||this.#_o?.target===null)return;let n=t.button.isConnected?this.#Mn(t.button):null;if(!(!n||[`rows`,`sort`,`filter`,`dataSource`,`columns`].some(t=>e.has(t))||n.row<this.#ve.start||n.row>=this.#ve.end||this.#uo(n.row).data!==t.row.data))return;let r=this.#Mo();this.#vo?(this.#_o={target:null,show:!1},r?.hide()):queueMicrotask(()=>{this.#go===t&&(this.#go=null,this.requestUpdate())})}#Io=e=>{e.stopPropagation();let{row:t,spec:n}=this.#go;this.emit(`sankhya-ds-row-action`,{action:e.detail.value,row:t.data,rowId:t.id,columnId:n.id})};#Lo(){if(!this.#G.leaves.some(e=>e.def.actions))return R;let e=this.#go,t=e?.row.data,n=e?this.#yo(e.row,e.spec):[],r=n.findIndex(e=>e.variant===`danger`);return L`<sankhya-ds-dropdown-menu class="row-menu" part="row-menu" placement="bottom-end" label=${e?this.#bo(e.row):W(`Ações da linha`)} no-trigger .anchorElement=${e&&!e.point?e.button:null} @sankhya-ds-select=${this.#Io} @sankhya-ds-open=${this.#No} @sankhya-ds-close=${this.#Po} > ${B(n,e=>e.id,(e,n)=>{let i=!!Z(e.disabled,t);return L`<sankhya-ds-menu-item value=${e.id} icon=${e.icon??``} variant=${e.variant??`default`} ?divider=${n>0&&n===r} ?disabled=${i} disabled-reason=${i?Z(e.disabledReason,t)??``:``} disabled-hint=${i?Z(e.disabledHint,t)??``:``} >${e.label}</sankhya-ds-menu-item >`})} </sankhya-ds-dropdown-menu>`}#Ro(e,t,n){let r=e.tan;if(t===this.#Dn()){let t=this.#G.byId.get(r.groupingColumnId),n=i(t,r.groupingValue,e.data),a=r.leafRows.length;return`${t.header}: ${n} (${a})`}return n?.def.aggregate?this.#zo(n,r.getValue(n.id)):``}#zo(e,n){return e.def.aggregate===`count`?t(n,`number`):i(e,n,{})}#Bo(e,t,n){let r=this.dataSource?this.#ee.totals:void 0,i=this.#Dn();return L`<div class="footer" part="footer" role="rowgroup" style=${K(t)}> <div role="row" class="row" aria-rowindex=${n}> ${B(e,e=>e.col.id,e=>{let t=e.spec,n=``;if(t?.def.aggregate){let e=this.dataSource?r?.[t.id]:this.#K.getColumn(t.id).getAggregationValue();n=this.#zo(t,e)}else e.col.id===i&&(n=W(`Total`));return L`<div role="gridcell" class=${this.#oo(e,``)} style=${K(e.style)} aria-colindex=${e.index+1} > ${n} </div>`})}${this.#ai()} </div> </div>`}#Vo(e,t,n){let i=e%2&&!this.noStripes?` odd`:``,a=t.filter(e=>e.col.id!==r);return L`<div role="row" class="row${i}${e===n-1?` last`:``}" aria-rowindex=${e+this.#$t()+1} > ${t.map(e=>{let t=a.indexOf(e),n=e.col.id===`__select`?` box`:t===0?` first`:t%3==0?` third`:``;return L`<div role="gridcell" class=${this.#oo(e,e.col.id===`__select`?`select-cell`:``)} style=${K(e.style)} aria-colindex=${e.index+1} > <span class="skeleton${n}" aria-hidden="true"></span> </div>`})}${this.#ai()} </div>`}render(){let e=this.#ro(),t=this.getSelectedRange();this.#Ne=t&&(t.start.row!==t.end.row||t.start.col!==t.end.col)?t:null;let n=this.#in();this.#so=n===0;let r=`width:${this.#K.getTotalSize()+n}px`,i=this.#ve,a=this.rowCount,o=(this.dataSource?this.#ee.total===null:this.loading)&&a===0,s=a===0&&!o;s?this.#tt.delete(`empty`):this.#ea&&!this.#tt.has(`empty`)&&this.#Nt(`empty`),this.#ea=s;let c=!s&&this.#tt.has(`empty`);this.hasUpdated&&o!==this.#Ft&&!this.#It&&this.#zt(),this.#Ft=o;let l=o||!!(this.dataSource&&this.#ee.loading),u=[];for(let e=i.start;e<i.end;e++)u.push(e);let d=this.#Le.row;d>=0&&(d<i.start||d>=i.end)&&(u.push(d),u.sort((e,t)=>e-t));let f=e=>Math.max(-1,Math.min(e-i.start,i.end-i.start))*this.#ue,p=this.#G.depth,m=this.#$t(),h=this.#an(),g=this.#pe.test(`footer`),_=this.#pe.test(`pagination`),v=this.renderBarStart();return L` ${this.#hi()} <div class="main${this.#ct?` narrow`:``}${this.dynamicMode?` panel-open`:``}${this.#yr?` ease-cols`:``}" > <div class="grid-area"> <div class="viewport" part="base" style=${K(this.#sn(a))} role=${this.#On()?`treegrid`:`grid`} aria-label=${this.label||R} aria-rowcount=${a+m+ +!!h} aria-colcount=${this.#Se.length} aria-multiselectable=${this.selectable?`true`:R} aria-busy=${l?`true`:R} @scroll=${this.#un} @keydown=${this.#bn} @focusin=${this.#_n} @focusout=${this.#no} @copy=${this.#Bn} @paste=${this.#Vn} > <div class="header" part="header" role="rowgroup" style=${K(r)} @click=${this.#lr} @contextmenu=${this.#ur} @dragover=${this.#jr} @drop=${this.#Mr} @dragend=${this.#Nr} > ${this.#io(e)} <div role="row" class="row" aria-rowindex=${p}> ${B(e,e=>e.col.id,e=>this.#lo(e))}${this.#ai()} </div> ${this.filterRow||this.#tt.has(`filter-row`)?this.#ga(e,p+1):R} </div> <div class="body" part="body" role="rowgroup" style=${K(`${r};height:${o?i.page*this.#ue:i.height}px`)} @click=${this.#nr} @dblclick=${this.#er} @pointerdown=${this.#Pn} @pointerover=${this.#Fn} @contextmenu=${this.#Eo} @focusout=${this.#$n} > <div class="rows" style=${K(`transform:translateY(${i.top}px)`)}> ${o?Array.from({length:i.page},(t,n)=>this.#Vo(n,e,i.page)):B(u,e=>e,t=>this.#fo(t,e,t<i.start||t>=i.end?`position:absolute;inset-inline:0;top:${f(t)}px`:``))} </div> </div> ${h?this.#Bo(e,r,m+a+1):R} </div> ${s||c?L`<div class="empty${c?` leaving`:``}" data-leave=${c?`empty`:R} ?inert=${c} aria-hidden=${c?`true`:R} style=${K(`top:${this.#en()}px`)} > <slot name="empty">${this.#Zr()}</slot> </div>`:R} ${this.#$i()} </div> ${this.#ba()} </div> <div class="bar" part="bar" ?hidden=${!g&&!_&&v===R}> ${v} <slot name="footer"></slot> <div class="pager" ?hidden=${!_}><slot name="pagination"></slot></div> </div> ${this.#Vr()} ${this.#da()} ${this.#Ya()} ${this.#Lo()} ${this.#Z?L`<sankhya-ds-grid-config class="own-config" .grid=${this} .saveConfig=${this.saveConfig} @sankhya-ds-open=${this.#yt} @sankhya-ds-close=${this.#yt} @sankhya-ds-error=${this.#yt} ></sankhya-ds-grid-config>`:R} ${this.#Yr()} ${this.#ki()} ${[...this.#Rn].map(([e,t])=>this.#Ln.render(e,t))} ${this.#Fe?.error?L`<div id="cell-error" class="cell-error" part="cell-error" popover="manual" role="alert" > ${this.#Fe.error} </div>`:R} <div class="visually-hidden" aria-live="polite">${this.#ze}</div> <div class="ghosts"></div> `}}})();function $(e){return{has:t=>e in t,get:t=>t[e],set:(t,n)=>{t[e]=n}}}export{Ft as SankhyaDsDataGrid};
|
|
1
|
+
import{styles as e}from"./data-grid.styles.js";import{formatValue as t,parseValue as n}from"./core/format.js";import{SELECT_ID as r,cellText as i,fullHeader as a,normalizeColumns as o,selectColumnDef as s}from"./core/columns.js";import{downloadText as c,parseDelimited as l,serialize as u}from"./core/clipboard.js";import{editorFor as d,fromEditorText as f,todayIso as p}from"./core/editors.js";import{createField as m,fieldValue as h}from"./core/editor-fields.js";import{fold as g,hasFilter as _,prepareRows as v}from"./core/prepare.js";import{sortDirectionLabels as y,sortMenuLabels as ee}from"../grid-config/sort-labels.js";import{BlockCache as te}from"./core/block-cache.js";import{rowWindow as b,scrollTopForRow as x}from"./core/row-window.js";import{inRange as S,navigate as C,normalizeRange as w}from"./core/navigation.js";import{AGGREGATE_KINDS as ne,OPTION_ITEMS as re,matchColumns as ie,moveGroup as ae,orderNeighbour as oe,parseOptionItems as se,setAggregate as ce,shiftGroup as le,toggleGroup as ue,withAggregates as de}from"./core/options.js";import{defaultLayout as fe,mergeLayout as T,moveColumn as E,pinColumn as pe,regionOf as me,setHidden as D,toggleSort as he}from"./core/layout.js";import{applyLayout as O,createGridTable as ge,setTableData as _e}from"./core/table.js";import{arrowDown as ve,arrowUp as ye,check as be,chevronDown as xe,chevronRight as Se,close as k,columns as Ce,ellipsisVertical as A,funnel as we,grip as Te,list as Ee,pin as De,rightIndent as Oe,rows3 as ke,search as j,sortAmountDown as Ae,sortAmountUp as je}from"./core/icons.js";import{afterAnimation as M,flip as N,ghostOf as P,measure as F,motionTiming as Me,reducedMotion as Ne,registerColorProperty as I}from"./core/motion.js";import{html as L,nothing as R}from"lit";import{property as z}from"lit/decorators.js";import{repeat as B}from"lit/directives/repeat.js";import{live as V}from"lit/directives/live.js";import{MESA_2026_11_DEPRECATION as Pe,RODADA_2026_11_18_DEPRECATION as Fe,deprecated as Ie,devWarn as H,warnA11y as Le,warnInvalid as Re}from"@snk-libs/sankhya-ds/ui/internal/dev";import{Virtualizer as ze,defaultRangeExtractor as Be,elementScroll as Ve,observeElementOffset as He,observeElementRect as Ue}from"@tanstack/virtual-core";import{SankhyaDsElement as U}from"@snk-libs/sankhya-ds/ui/internal/sankhya-ds-element";import{cloneData as We}from"@snk-libs/sankhya-ds/ui/internal/clone";import{msg as W,str as G}from"@snk-libs/sankhya-ds/ui/internal/localize";import{HasSlotController as Ge}from"@snk-libs/sankhya-ds/ui/internal/slot";import{OverflowTipController as Ke}from"@snk-libs/sankhya-ds/ui/internal/overflow-tip";import{pageDensity as qe}from"@snk-libs/sankhya-ds/ui/internal/density";import{cssStyle as K}from"@snk-libs/sankhya-ds/ui/internal/css-style";import{safeFileName as Je}from"@snk-libs/sankhya-ds/ui/internal/filename";import{layoutScale as Ye}from"@snk-libs/sankhya-ds/ui/internal/box";import{loadDropdownMenu as Xe}from"@snk-libs/sankhya-ds/ui/internal/dropdown-menu-loader";import{whenIdle as Ze}from"@snk-libs/sankhya-ds/ui/internal/lazy-loader";import{AreaMotionController as Qe,SlotMotionController as $e,cssTimeMs as et,fade as tt}from"@snk-libs/sankhya-ds/ui/internal/motion";var q=function(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else(d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0},J=function(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0},nt,rt=()=>nt??=import(`@snk-libs/sankhya-ds/ui/components/column-filter/define`),Y=()=>!!customElements.get(`sankhya-ds-dropdown-menu`),it,at=()=>it??=import(`@snk-libs/sankhya-ds/ui/components/export-dialog/define`);I(`--_sankhya-ds-grid-tint`),I(`--_sankhya-ds-kebab-mask`);var ot=[`compact`,`default`,`comfortable`],st=[`none`,`down`,`right`],ct=[`cell`,`row`],lt=[`hover`,`always`],ut=640,dt=[`sankhya-ds-change`,`sankhya-ds-input`,`sankhya-ds-revert`,`sankhya-ds-open`,`sankhya-ds-close`,`sankhya-ds-invalid`],ft=`sankhya-ds-input, sankhya-ds-number-input, sankhya-ds-select, sankhya-ds-combobox, sankhya-ds-date-picker, sankhya-ds-time-input, sankhya-ds-lookup`,pt=32,mt=40,ht=50,gt=(e,t,n)=>`width:${e}px;${t===`start`?`left:${n}px`:t===`end`?`right:${n}px`:n?`margin-inline-start:${n}px`:``}`,X=e=>e.dataset.key,_t=`.rows > [data-row-key]`,vt=e=>e.dataset.rowKey,yt=[`SANKHYA-DS-BUTTON`,`SANKHYA-DS-SPLIT-BUTTON`,`SANKHYA-DS-CIRCLE-BUTTON`,`SANKHYA-DS-MENU-BUTTON`],bt=`sankhya-ds-overflow:`,xt=8,St=260,Ct=e=>e.charAt(0).toLocaleLowerCase(`pt-BR`)+e.slice(1),wt=[200,240,280],Tt=8,Et=2,Dt=[`create`,`clear`,`retry`,`other`],Ot=`a[href], button, input:not([type="hidden"]), sankhya-ds-circle-button, sankhya-ds-button, sankhya-ds-switch, sankhya-ds-checkbox, ${ft}, [tabindex]:not([tabindex="-1"])`,kt=[`subtle`,`strong`,`none`];function Z(e,t){return typeof e==`function`?e(t):e}function At(e){e&&(e.dataset.dismissed=``,e.hidePopover())}var jt=16,Mt=480,Nt=2e5,Pt=16,Ft=4,Q=e=>e.reduce((e,t)=>e+t.getSize(),0),It=(()=>{let I=U,nt,it=[],It=[],Lt,Rt=[],zt=[],Bt,Vt=[],Ht=[],Ut,Wt=[],Gt=[],Kt,qt=[],Jt=[],Yt,Xt=[],Zt=[],Qt,$t=[],en=[],tn,nn=[],rn=[],an,on=[],sn=[],cn,ln=[],un=[],dn,fn=[],pn=[],mn,hn=[],gn=[],_n,vn=[],yn=[],bn,xn=[],Sn=[],Cn,wn=[],Tn=[],En,Dn=[],On=[],kn,An=[],jn=[],Mn,Nn=[],Pn=[],Fn,In=[],Ln=[],Rn,zn=[],Bn=[],Vn,Hn=[],Un=[],Wn,Gn=[],Kn=[],qn,Jn=[],Yn=[],Xn,Zn=[],Qn=[],$n,er=[],tr=[],nr,rr=[],ir=[],ar,or=[],sr=[],cr,lr=[],ur=[],dr,fr=[],pr=[],mr,hr=[],gr=[],_r,vr=[],yr=[],br,xr=[],Sr=[],Cr,wr=[],Tr=[],Er,Dr=[],Or=[],kr,Ar=[],jr=[],Mr,Nr=[],Pr=[],Fr,Ir=[],Lr=[],Rr,zr=[],Br=[],Vr,Hr=[],Ur=[],Wr,Gr=[],Kr=[],qr,Jr=[],Yr=[],Xr,Zr=[],Qr=[],$r,ei=[],ti=[],ni,ri=[],ii=[];return class U extends I{static{let e=typeof Symbol==`function`&&Symbol.metadata?Object.create(I[Symbol.metadata]??null):void 0;nt=[z({attribute:!1})],Lt=[z({attribute:!1})],Bt=[z({attribute:!1})],Ut=[z({type:Number,attribute:`block-size`})],Kt=[z({reflect:!0})],Yt=[z({attribute:`row-key`})],Qt=[z()],tn=[z({type:Boolean,reflect:!0})],an=[z({type:Boolean,reflect:!0,attribute:`column-select`})],cn=[z({attribute:!1})],dn=[z({type:Boolean,attribute:!1})],mn=[z({attribute:!1})],_n=[z({attribute:!1})],bn=[z({attribute:!1})],Cn=[z({attribute:!1})],En=[z({attribute:!1})],kn=[z({attribute:!1})],Mn=[z({attribute:!1})],Fn=[z({attribute:!1})],Rn=[z({attribute:!1})],Vn=[z({type:Boolean,reflect:!0})],Wn=[z({type:Boolean,attribute:`row-clickable`,reflect:!0})],qn=[z({type:Boolean,reflect:!0})],Xn=[z({type:Boolean,reflect:!0,attribute:`auto-height`})],$n=[z({type:Number,attribute:`max-rows`})],nr=[z({reflect:!0,attribute:`vertical-dividers`,converter:{fromAttribute:e=>e===``||e===`true`?`strong`:e}})],ar=[z({type:Boolean,reflect:!0,attribute:`no-stripes`})],cr=[z({reflect:!0,attribute:`column-menu`})],dr=[z({attribute:`enter-navigation`})],mr=[z({attribute:!1})],_r=[z({type:Boolean,reflect:!0,attribute:`no-options`})],br=[z({type:Boolean,reflect:!0,attribute:`columns-locked`})],Cr=[z({type:Boolean,reflect:!0})],Er=[z({type:Boolean,reflect:!0})],kr=[z({type:Boolean,reflect:!0})],Mr=[z({attribute:`option-items`,converter:{fromAttribute:se,toAttribute:e=>e.join(` `)}})],Fr=[z({attribute:`empty-heading`})],Rr=[z({attribute:`empty-description`})],Vr=[z({attribute:`empty-action-label`})],Wr=[z({attribute:`empty-action-type`})],qr=[z({attribute:`empty-icon`})],Xr=[z({type:Boolean,reflect:!0,attribute:`filter-row`})],$r=[z({type:Boolean,reflect:!0,attribute:`dynamic-mode`})],ni=[z({attribute:`edit-mode`})],q(this,null,nt,{kind:`accessor`,name:`columns`,static:!1,private:!1,access:$(`columns`),metadata:e},it,It),q(this,null,Lt,{kind:`accessor`,name:`rows`,static:!1,private:!1,access:$(`rows`),metadata:e},Rt,zt),q(this,null,Bt,{kind:`accessor`,name:`dataSource`,static:!1,private:!1,access:$(`dataSource`),metadata:e},Vt,Ht),q(this,null,Ut,{kind:`accessor`,name:`blockSize`,static:!1,private:!1,access:$(`blockSize`),metadata:e},Wt,Gt),q(this,null,Kt,{kind:`accessor`,name:`density`,static:!1,private:!1,access:$(`density`),metadata:e},qt,Jt),q(this,null,Yt,{kind:`accessor`,name:`rowKey`,static:!1,private:!1,access:$(`rowKey`),metadata:e},Xt,Zt),q(this,null,Qt,{kind:`accessor`,name:`label`,static:!1,private:!1,access:$(`label`),metadata:e},$t,en),q(this,null,tn,{kind:`accessor`,name:`selectable`,static:!1,private:!1,access:$(`selectable`),metadata:e},nn,rn),q(this,null,an,{kind:`accessor`,name:`columnSelect`,static:!1,private:!1,access:$(`columnSelect`),metadata:e},on,sn),q(this,null,cn,{kind:`accessor`,name:`selected`,static:!1,private:!1,access:$(`selected`),metadata:e},ln,un),q(this,null,dn,{kind:`accessor`,name:`allMatching`,static:!1,private:!1,access:$(`allMatching`),metadata:e},fn,pn),q(this,null,mn,{kind:`accessor`,name:`sort`,static:!1,private:!1,access:$(`sort`),metadata:e},hn,gn),q(this,null,_n,{kind:`accessor`,name:`config`,static:!1,private:!1,access:$(`config`),metadata:e},vn,yn),q(this,null,bn,{kind:`accessor`,name:`saveConfig`,static:!1,private:!1,access:$(`saveConfig`),metadata:e},xn,Sn),q(this,null,Cn,{kind:`accessor`,name:`filter`,static:!1,private:!1,access:$(`filter`),metadata:e},wn,Tn),q(this,null,En,{kind:`accessor`,name:`groupBy`,static:!1,private:!1,access:$(`groupBy`),metadata:e},Dn,On),q(this,null,kn,{kind:`accessor`,name:`subRows`,static:!1,private:!1,access:$(`subRows`),metadata:e},An,jn),q(this,null,Mn,{kind:`accessor`,name:`rowKind`,static:!1,private:!1,access:$(`rowKind`),metadata:e},Nn,Pn),q(this,null,Fn,{kind:`accessor`,name:`rowStatus`,static:!1,private:!1,access:$(`rowStatus`),metadata:e},In,Ln),q(this,null,Rn,{kind:`accessor`,name:`expanded`,static:!1,private:!1,access:$(`expanded`),metadata:e},zn,Bn),q(this,null,Vn,{kind:`accessor`,name:`readonly`,static:!1,private:!1,access:$(`readonly`),metadata:e},Hn,Un),q(this,null,Wn,{kind:`accessor`,name:`rowClickable`,static:!1,private:!1,access:$(`rowClickable`),metadata:e},Gn,Kn),q(this,null,qn,{kind:`accessor`,name:`loading`,static:!1,private:!1,access:$(`loading`),metadata:e},Jn,Yn),q(this,null,Xn,{kind:`accessor`,name:`autoHeight`,static:!1,private:!1,access:$(`autoHeight`),metadata:e},Zn,Qn),q(this,null,$n,{kind:`accessor`,name:`maxRows`,static:!1,private:!1,access:$(`maxRows`),metadata:e},er,tr),q(this,null,nr,{kind:`accessor`,name:`verticalDividers`,static:!1,private:!1,access:$(`verticalDividers`),metadata:e},rr,ir),q(this,null,ar,{kind:`accessor`,name:`noStripes`,static:!1,private:!1,access:$(`noStripes`),metadata:e},or,sr),q(this,null,cr,{kind:`accessor`,name:`columnMenu`,static:!1,private:!1,access:$(`columnMenu`),metadata:e},lr,ur),q(this,null,dr,{kind:`accessor`,name:`enterNavigation`,static:!1,private:!1,access:$(`enterNavigation`),metadata:e},fr,pr),q(this,null,mr,{kind:`accessor`,name:`columnActions`,static:!1,private:!1,access:$(`columnActions`),metadata:e},hr,gr),q(this,null,_r,{kind:`accessor`,name:`noOptions`,static:!1,private:!1,access:$(`noOptions`),metadata:e},vr,yr),q(this,null,br,{kind:`accessor`,name:`columnsLocked`,static:!1,private:!1,access:$(`columnsLocked`),metadata:e},xr,Sr),q(this,null,Cr,{kind:`accessor`,name:`searchable`,static:!1,private:!1,access:$(`searchable`),metadata:e},wr,Tr),q(this,null,Er,{kind:`accessor`,name:`refreshable`,static:!1,private:!1,access:$(`refreshable`),metadata:e},Dr,Or),q(this,null,kr,{kind:`accessor`,name:`exportable`,static:!1,private:!1,access:$(`exportable`),metadata:e},Ar,jr),q(this,null,Mr,{kind:`accessor`,name:`optionItems`,static:!1,private:!1,access:$(`optionItems`),metadata:e},Nr,Pr),q(this,null,Fr,{kind:`accessor`,name:`emptyHeading`,static:!1,private:!1,access:$(`emptyHeading`),metadata:e},Ir,Lr),q(this,null,Rr,{kind:`accessor`,name:`emptyDescription`,static:!1,private:!1,access:$(`emptyDescription`),metadata:e},zr,Br),q(this,null,Vr,{kind:`accessor`,name:`emptyActionLabel`,static:!1,private:!1,access:$(`emptyActionLabel`),metadata:e},Hr,Ur),q(this,null,Wr,{kind:`accessor`,name:`emptyActionType`,static:!1,private:!1,access:$(`emptyActionType`),metadata:e},Gr,Kr),q(this,null,qr,{kind:`accessor`,name:`emptyIcon`,static:!1,private:!1,access:$(`emptyIcon`),metadata:e},Jr,Yr),q(this,null,Xr,{kind:`accessor`,name:`filterRow`,static:!1,private:!1,access:$(`filterRow`),metadata:e},Zr,Qr),q(this,null,$r,{kind:`accessor`,name:`dynamicMode`,static:!1,private:!1,access:$(`dynamicMode`),metadata:e},ei,ti),q(this,null,ni,{kind:`accessor`,name:`editMode`,static:!1,private:!1,access:$(`editMode`),metadata:e},ri,ii),e&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})}static css=e;static enums={density:ot,enterNavigation:st,editMode:ct,columnMenu:lt,emptyActionType:Dt,verticalDividers:kt};#e=J(this,it,[]);get columns(){return this.#e}set columns(e){this.#e=e}#t=(J(this,It),J(this,Rt,[]));get rows(){return this.#t}set rows(e){this.#t=e}#n=(J(this,zt),J(this,Vt,void 0));get dataSource(){return this.#n}set dataSource(e){this.#n=e}#r=(J(this,Ht),J(this,Wt,100));get blockSize(){return this.#r}set blockSize(e){this.#r=e}#i=(J(this,Gt),void 0);#a=J(this,qt,void 0);get density(){return this.#a}set density(e){this.#a=e}#o=(J(this,Jt),J(this,Xt,`id`));get rowKey(){return this.#o}set rowKey(e){this.#o=e}#s=(J(this,Zt),J(this,$t,``));get label(){return this.#s}set label(e){this.#s=e}#c=(J(this,en),J(this,nn,!1));get selectable(){return this.#c}set selectable(e){this.#c=e}#l=(J(this,rn),J(this,on,!1));get columnSelect(){return this.#l}set columnSelect(e){this.#l=e}#u=(J(this,sn),J(this,ln,[]));get selected(){return this.#u}set selected(e){this.#u=e}#d=(J(this,un),J(this,fn,!1));get allMatching(){return this.#d}set allMatching(e){this.#d=e}#f=(J(this,pn),J(this,hn,[]));get sort(){return this.#f}set sort(e){this.#f=e}#p=(J(this,gn),J(this,vn,void 0));get config(){return this.#p}set config(e){this.#p=e}#m=(J(this,yn),J(this,xn,void 0));get saveConfig(){return this.#m}set saveConfig(e){this.#m=e}#h=(J(this,Sn),J(this,wn,{}));get filter(){return this.#h}set filter(e){this.#h=e}#g=(J(this,Tn),J(this,Dn,[]));get groupBy(){return this.#g}set groupBy(e){this.#g=e}#_=(J(this,On),J(this,An,void 0));get subRows(){return this.#_}set subRows(e){this.#_=e}#v=(J(this,jn),J(this,Nn,void 0));get rowKind(){return this.#v}set rowKind(e){this.#v=e}#y=(J(this,Pn),J(this,In,void 0));get rowStatus(){return this.#y}set rowStatus(e){this.#y=e}#b=(J(this,Ln),J(this,zn,{}));get expanded(){return this.#b}set expanded(e){this.#b=e}#x=(J(this,Bn),J(this,Hn,!1));get readonly(){return this.#x}set readonly(e){this.#x=e}#S=(J(this,Un),J(this,Gn,!1));get rowClickable(){return this.#S}set rowClickable(e){this.#S=e}#C=(J(this,Kn),J(this,Jn,!1));get loading(){return this.#C}set loading(e){this.#C=e}#w=(J(this,Yn),J(this,Zn,!1));get autoHeight(){return this.#w}set autoHeight(e){this.#w=e}#T=(J(this,Qn),J(this,er,50));get maxRows(){return this.#T}set maxRows(e){this.#T=e}#E=(J(this,tr),J(this,rr,`subtle`));get verticalDividers(){return this.#E}set verticalDividers(e){this.#E=e}#D=(J(this,ir),J(this,or,!1));get noStripes(){return this.#D}set noStripes(e){this.#D=e}#O=(J(this,sr),J(this,lr,`hover`));get columnMenu(){return this.#O}set columnMenu(e){this.#O=e}#k=(J(this,ur),J(this,fr,`none`));get enterNavigation(){return this.#k}set enterNavigation(e){this.#k=e}#A=(J(this,pr),J(this,hr,[]));get columnActions(){return this.#A}set columnActions(e){this.#A=e}#j=(J(this,gr),J(this,vr,!1));get noOptions(){return this.#j}set noOptions(e){this.#j=e}#M=(J(this,yr),J(this,xr,!1));get columnsLocked(){return this.#M}set columnsLocked(e){this.#M=e}#N=(J(this,Sr),J(this,wr,!1));get searchable(){return this.#N}set searchable(e){this.#N=e}#P=(J(this,Tr),J(this,Dr,!1));get refreshable(){return this.#P}set refreshable(e){this.#P=e}#F=(J(this,Or),J(this,Ar,!1));get exportable(){return this.#F}set exportable(e){this.#F=e}#I=(J(this,jr),J(this,Nr,[...re]));get optionItems(){return this.#I}set optionItems(e){this.#I=e}#L=(J(this,Pr),J(this,Ir,``));get emptyHeading(){return this.#L}set emptyHeading(e){this.#L=e}#R=(J(this,Lr),J(this,zr,``));get emptyDescription(){return this.#R}set emptyDescription(e){this.#R=e}#z=(J(this,Br),J(this,Hr,``));get emptyActionLabel(){return this.#z}set emptyActionLabel(e){this.#z=e}#B=(J(this,Ur),J(this,Gr,`create`));get emptyActionType(){return this.#B}set emptyActionType(e){this.#B=e}#V=(J(this,Kr),J(this,Jr,``));get emptyIcon(){return this.#V}set emptyIcon(e){this.#V=e}#H=(J(this,Yr),J(this,Zr,!1));get filterRow(){return this.#H}set filterRow(e){this.#H=e}#U=(J(this,Qr),J(this,ei,!1));get dynamicMode(){return this.#U}set dynamicMode(e){this.#U=e}#W=(J(this,ti),J(this,ri,`cell`));get editMode(){return this.#W}set editMode(e){this.#W=e}#G=(J(this,ii),o([]));#K=ge({columns:[],data:[],getRowId:()=>``});#q=fe([]);#J=!1;#Y=!1;#X=null;#Z=!1;#Q={rows:[],children:/* @__PURE__ */ new WeakMap};#$=[];#ee;#te;#ne=/* @__PURE__ */ new Set;#re=`none`;#ie=!1;#ae=!1;#oe=0;#se;#ce=200;#le=[];#ue=0;#de=0;#fe=0;#pe=new Ge(this,`footer`,`actions`,`selection-actions`,`more-actions`,`custom-actions`,`pagination`);#me=new $e(this,`actions`,`selection-actions`);#he=new Qe(this,{target:()=>this.renderRoot.querySelector(`.toolbar`),shown:()=>this.#mi()});#ge=0;#_e=-1;#ve={start:0,end:0,top:0,height:0,scale:1,page:1};#ye=[];#be=[];#xe=[];#Se=[];#Ce=``;#we;#Te;#Ee=0;#De=new ResizeObserver(()=>{let e=this.#ft;this.#de=e.clientHeight,this.#fe=e.clientWidth,this.#Ee=Math.max(0,e.offsetHeight-e.clientHeight),this.#ct=this.offsetWidth<ut,this.requestUpdate()});#Oe=null;#ke=!1;#Ae=null;#je=null;#Me=null;#Ne=null;#Pe=!1;#Fe=null;#Ie=!1;#Le={row:0,col:0};#Re=!1;#ze=``;#Be=!1;#Ve=!1;#He=``;#Ue=0;#We=null;#Ge=e=>{let t=this.renderRoot.querySelector(`[role="columnheader"][data-id="${CSS.escape(this.#We??``)}"]`);t&&e.composedPath().includes(t)||(this.#We=null,document.removeEventListener(`pointerdown`,this.#Ge,!0),this.requestUpdate())};#Ke=``;#qe=null;#Je=`actions`;#Ye=!1;#Xe=null;#Ze=null;#Qe=null;#$e=null;#et=!1;#tt=/* @__PURE__ */ new Map;#nt=/* @__PURE__ */ new Set;#rt=null;#it=null;#at=!1;#ot=!1;#st=null;#ct=!1;#lt=null;#ut=!1;#dt=null;constructor(){super(),this.#we=new ze(this.#ln())}get#ft(){return this.renderRoot.querySelector(`.viewport`)}get rowCount(){return this.dataSource?this.#ee?.total??0:this.#$.length}get fitRows(){return this.#pt}#pt=0;#mt=0;#ht(){return this.#de?Math.max(1,Math.floor(this.#on()/this.#ue)):0}#gt(){this.#mt||this.#ht()===this.#pt||(this.#mt=requestAnimationFrame(()=>{this.#mt=0;let e=this.#ht();e&&e!==this.#pt&&(this.#pt=e,this.emit(`sankhya-ds-fit-rows`,{rows:e}))}))}#_t;connectedCallback(){super.connectedCallback(),this.addEventListener(`keydown`,this.#Gi),Y()||(this.addEventListener(`pointerenter`,this.#Bi),this.addEventListener(`focusin`,this.#Bi),this.#_t??=Ze(()=>{this.#_t=void 0,this.#Bi()})),this.#Te=this.#we._didMount(),this.#ft&&(this.#De.observe(this.#ft),this.#De.observe(this))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`keydown`,this.#Gi),this.removeEventListener(`pointerenter`,this.#Bi),this.removeEventListener(`focusin`,this.#Bi),this.#_t?.(),this.#_t=void 0,this.#Te?.(),this.#De.disconnect(),cancelAnimationFrame(this.#mt),this.#mt=0,document.removeEventListener(`pointerdown`,this.#Ge,!0),window.removeEventListener(`blur`,this.#kt),clearTimeout(this.#br),clearTimeout(this.#se)}getLayout(){return We({...this.#q,sort:this.sort})}setConfigurator(e,t){if(t){if(this.renderRoot.contains(e))return;this.#X=e}else this.#X===e&&(this.#X=null)}async#vt(){this.#X?this.#X.show():(this.#Z||(await import(`../grid-config/define.js`),this.#Z=!0,this.requestUpdate(),await this.updateComplete),this.renderRoot.querySelector(`.own-config`).show())}#yt=e=>e.stopPropagation();setLayout(e){this.#Pt=!0;let t=T(this.#q,{...e,sort:e.sort??this.sort},this.#St());this.#Et(t),this.#Ct(t)}getSelectedRange(){return this.#Me?w(this.#Me.anchor,this.#Me.focus):null}exportCsv({filename:e=`dados.csv`,download:t=!0,columns:n,rows:r=`all`}={}){let o=n?n.flatMap(e=>this.#G.byId.get(e)??[]):this.#Se.flatMap(e=>{let t=this.#G.byId.get(e.id);return t&&!t.def.actions?[t]:[]}),s=[];if(this.dataSource)H(this,`export-server`,`exportCsv() no modelo servidor exporta só as linhas carregadas; gere o arquivo completo no servidor.`),s.push(...this.#ee.loadedRows());else{let e=t=>{for(let n of t)s.push(n),e(this.#Q.children.get(n)??[])};e(this.#Q.rows)}let l=new Set(this.selected),d=r===`selected`?s.filter(e=>l.has(String(e[this.rowKey]))):s,f=[o.map(e=>a(e,this.#G.groups)),...d.map(e=>o.map(t=>i(t,t.accessor(e),e)))],p=`\ufeff${u(f,`;`,{neutralizeFormulas:!0})}`,m=`${Je(e,{fallback:`dados`,max:100}).replace(/\.csv$/i,``)}.csv`;return t&&c(p,m,`text/csv;charset=utf-8`),p}expandAll(){this.expanded=!0}collapseAll(){this.expanded={}}refresh(){this.#ee=void 0,this.requestUpdate()}scrollToRow(e){let t=this.#ft,n=this.#on(),r=this.#an()?this.#ue:0,i=this.#xt()&&parseFloat(getComputedStyle(t).scrollPaddingBlockEnd)||0,a=Math.max(0,i-r),o=x(e,this.#ue,t.scrollTop,n-a>=this.#ue?n-a:n,this.#ve.scale);o!==null&&(t.scrollTop=o)}#bt(){let e=this.#ta&&this.selected===this.#na;return this.selectable&&this.selected.length>1&&!e}#xt(){let e=this.#bt();return this.#ft?.toggleAttribute(`data-feedback`,e),e}scrollToColumn(e){let t=this.#Se.findIndex(t=>t.id===e);t<0?H(this,`scroll-column:${e}`,`scrollToColumn("${e}"): a coluna não existe ou está oculta.`):this.#gn(t,!0)}async editCell(e,t){await this.updateComplete;let n=-1;if(this.dataSource)for(let t=this.#ve.start;t<this.#ve.end&&n<0;t++)this.#uo(t).id===e&&(n=t);else n=this.#$.findIndex(t=>t.id===e);let r=this.#Se.findIndex(e=>e.id===t);return n<0||r<0?(H(this,`edit-cell:${e}:${t}`,`editCell("${e}", "${t}"): linha ou coluna não encontrada.`),!1):(this.#hn({row:n,col:r}),this.#Gn(n,r))}async revealRow(e,{focus:t=!1}={}){await this.updateComplete;let n=this.dataSource?Array.from({length:this.rowCount},(e,t)=>t).find(t=>this.#ee.get(t)&&this.#uo(t).id===e)??-1:this.#$.findIndex(t=>t.id===e);if(n<0)return H(this,`reveal-row:${e}`,`revealRow("${e}"): linha não encontrada.`),!1;let r=Math.max(0,this.#Le.col);return this.scrollToRow(n),this.#Le={row:n,col:r},this.#Re=t,this.requestUpdate(),await this.updateComplete,!0}renderBarStart(){return R}focus(e){let t=this.hasUpdated?this.#mn():null;t?t.focus(e):super.focus(e)}#St(){return new Set(this.#G.leaves.map(e=>e.id))}#Ct(e){this.#q=e,this.#J=!0,O(this.#K,e,this.selectable,this.#Dr),JSON.stringify(e.sort)!==JSON.stringify(this.sort)&&(this.sort=e.sort),e.groupBy.join()!==this.groupBy.join()&&(this.groupBy=e.groupBy),this.requestUpdate()}#wt(){this.#Y=!1;let e=this.#Tt(this.config);this.#Et(e),this.#q=e,this.#J=!0,this.#ut&&(this.#ut=!1,this.#Jt()),O(this.#K,this.#q,this.selectable,this.#Dr),JSON.stringify(this.#q.sort)!==JSON.stringify(this.sort)&&(this.sort=this.#q.sort)}#Tt(e){let t=this.#G.byId,n=e.hidden?.filter(e=>t.get(e)?.hideable!==!1);n&&n.length!==e.hidden.length&&H(this,`config-hideable`,`config.hidden: colunas com hideable: false continuam visíveis.`),n&&this.#G.leaves.every(e=>n.includes(e.id))&&(H(this,`config-all-hidden`,`config.hidden oculta todas as colunas; a configuração de colunas ocultas foi ignorada.`),n=void 0);let r=e.sort?.filter(e=>t.get(e.id)?.sortable!==!1);return r&&r.length!==e.sort.length&&H(this,`config-sortable`,`config.sort: colunas com sortable: false foram ignoradas na ordenação.`),T(this.#q,{order:e.order,hidden:n,sort:r,...e.aggregates?{aggregates:e.aggregates}:{}},this.#St())}applyUserConfig(e){let t=JSON.stringify(this.sort);this.#Pt=!0,this.#Dt(this.#Tt(e)),JSON.stringify(this.sort)!==t&&this.emit(`sankhya-ds-sort-change`,{sort:this.sort})}#Et(e){JSON.stringify(e.aggregates)!==JSON.stringify(this.#q.aggregates)&&(this.#ut=!0,this.#et=!0)}#Dt(e){if(this.columnsLocked){let{order:t,hidden:n,pinned:r}=this.#q;e={...e,order:t,hidden:n,pinned:r}}this.#Et(e),this.#Ct(e),this.emit(`sankhya-ds-layout-change`,{layout:this.getLayout()})}update(e){let t=this.renderRoot,n=[...t.querySelectorAll(`.menu, .cell-error`)].filter(e=>!(`ghosted`in e.dataset)&&(e.matches(`:popover-open`)||`dismissed`in e.dataset)),r=[...t.querySelectorAll(`[data-flip]`)],i=r.map(e=>({el:e,parent:e.parentElement,zone:e.closest(`.zone`),next:e.nextElementSibling})),a=F(r,X),o=this.#at;this.#at=!1;let s=o?F(t.querySelectorAll(_t),vt):null;super.update(e);let c=Me(this);for(let e of n)e.isConnected||this.#At(e);for(let{el:e,parent:t,zone:n,next:r}of i){if(e.isConnected||e.dataset.flip!==`exit`)continue;let i=t.isConnected?t:n?.isConnected?n:null;i&&this.#Mt(e,i,r?.parentElement===i?r:null)}r.length&&N(a,t.querySelectorAll(`[data-flip]`),X,c),s&&N(s,t.querySelectorAll(_t),vt,c)}#Ot=e=>{let t=e.target;if(e.newState!==`closed`||(window.removeEventListener(`blur`,this.#kt),`ghosted`in t.dataset))return;t.dataset.ghosted=``;let n=P(t);requestAnimationFrame(()=>this.isConnected&&this.#jt(n))};#kt=()=>{for(let e of this.renderRoot.querySelectorAll(`.menu:popover-open`))e.closest(`.ghosts`)||e.hidePopover()};#At(e){this.#jt(P(e))}#jt(e){delete e.dataset.ghosted,e.setAttribute(`popover`,`manual`),this.renderRoot.querySelector(`.ghosts`).append(e),e.showPopover(),M(e,()=>e.remove())}#Mt(e,t,n){let r=P(e);t.insertBefore(r,n),M(r,()=>{let e=[...t.querySelectorAll(`[data-flip]`)],n=F(e,X);r.remove(),N(n,e,X,Me(this))})}#Nt(e,t=!0){let n={value:t};this.#tt.set(e,n),this.updateComplete.then(()=>{let t=()=>{this.#tt.get(e)===n&&(this.#tt.delete(e),e===`filter-row`&&(this.#at=!0),this.requestUpdate())},r=this.renderRoot.querySelector(`[data-leave="${e}"]`);r?M(r,t):t()})}#Pt=!1;#Ft=!1;#It=null;static#Lt(e){try{return JSON.stringify(e,(e,t)=>typeof t==`function`?String(t):t)}catch{return``}}#Rt(e){let t=e.get(`rows`);if(e.has(`rows`)&&t?.length&&this.rows!==t){let e=new Set(t),n=this.rows.slice(0,50);if(n.filter(t=>e.has(t)).length<n.length/2||!n.length)return!0}let n=e.get(`columns`);return e.has(`columns`)&&!!n?.length&&U.#Lt(n)!==U.#Lt(this.columns)}#zt(){let e=this.#ft;if(!e?.offsetWidth)return;let t=P(e);for(let e of[t,...t.querySelectorAll(`[role], [part], [data-row], [data-col], [id]`)])for(let t of[`role`,`part`,`data-row`,`data-col`,`id`])e.removeAttribute(t);this.#It={el:t,top:e.offsetTop,left:e.offsetLeft,width:e.offsetWidth,height:e.offsetHeight,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft}}#Bt(e){let t=this.#ft,n=getComputedStyle(this),r=e=>et(n.getPropertyValue(`--sankhya-ds-duration-${e}`));Object.assign(e.el.style,{position:`absolute`,top:`${e.top}px`,left:`${e.left}px`,width:`${e.width}px`,height:`${e.height}px`,margin:`0`,pointerEvents:`none`,zIndex:`2`}),t.parentElement.append(e.el),e.el.scrollTop=e.scrollTop,e.el.scrollLeft=e.scrollLeft,e.el.animate([{opacity:1},{opacity:0}],{duration:r(`micro`),easing:n.getPropertyValue(`--sankhya-ds-ease-standard`).trim()||`ease`,fill:`forwards`}).finished.catch(()=>void 0).then(()=>e.el.remove()),t.animate([{opacity:0},{opacity:1}],{duration:r(`base`),easing:n.getPropertyValue(`--sankhya-ds-ease-enter`).trim()||`ease`})}willUpdate(e){if(super.willUpdate(e),e.has(`selected`)&&this.hasUpdated&&!(this.selectable&&this.selected.length>0)){let e=document.activeElement;this.#Ut=!!(e&&[...this.querySelectorAll(`:scope > [slot="selection-actions"]`)].some(t=>t.contains(e)))}e.has(`allMatching`)&&this.allMatching&&!this.dataSource&&(H(this,`all-matching-no-data-source`,`allMatching sem dataSource não é suportado: o modo "todos do filtro" é do modelo servidor. Correção: com as linhas na mão, ponha todos os ids em selected.`),this.hasUpdated||(this.allMatching=!1)),e.has(`maxRows`)&&(!Number.isFinite(this.maxRows)||this.maxRows<0)&&Re(this,`max-rows`,this.maxRows,[`0 (sem limite)`,`inteiro positivo`]),(e.has(`maxRows`)||e.has(`autoHeight`))&&!this.autoHeight&&(this.hasAttribute(`max-rows`)||this.maxRows!==50)&&H(this,`max-rows-no-auto-height`,`max-rows só vale com auto-height. Correção: adicione auto-height ou tire max-rows.`),this.allMatching&&(e.has(`filter`)||e.has(`dataSource`)||!this.dataSource||!this.selected.length)&&this.hasUpdated&&(this.allMatching=!1,this.#Wt=this.selected.length>0),e.has(`optionItems`)&&this.optionItems.includes(`select-all`)&&Ie(this,`option-items "select-all"`,{...Fe,replacement:`a caixa do cabeçalho e "Selecionar todos os N registros" da barra de seleção`,ref:`P1-14`}),this.hasUpdated&&!this.#It&&(this.#Pt||this.#Rt(e))&&this.#zt(),this.#Pt=!1,this.#Gt(e),(!this.#ue||e.has(`density`))&&this.#qt();let t=this.#ut||[`columns`,`selectable`,`subRows`].some(t=>e.has(t));this.#ut=!1,e.has(`subRows`)&&this.subRows&&this.dataSource&&H(this,`tree-server`,`dataSource não suporta subRows (árvore no modelo servidor); a árvore é ignorada.`),t&&this.#Jt(),t&&!this.readonly&&this.#G.leaves.some(e=>e.def.editable&&typeof e.def.editor!=`object`)&&this.#Zn(),e.has(`config`)&&(this.#Y=!!this.config),this.#Y&&this.#G.leaves.length&&this.#wt(),e.has(`groupBy`)&&this.groupBy.join()!==this.#q.groupBy.join()&&(this.#q=T(this.#q,{groupBy:this.groupBy},this.#St()),O(this.#K,this.#q,this.selectable,this.#Dr)),e.has(`sort`)&&(this.#q={...this.#q,sort:this.sort}),(t||e.has(`expanded`))&&this.#K.setExpanded(this.expanded),[`rows`,`sort`,`filter`,`groupBy`,`dataSource`].some(t=>e.has(t))&&(this.#Me=null,this.#Fe=null,this.#dt=null);let n=this.dataSource;if((t||[`rows`,`sort`,`filter`,`dataSource`].some(t=>e.has(t)))&&this.#Yt(),n&&(!this.#ee||[`dataSource`,`sort`,`filter`,`blockSize`].some(t=>e.has(t)))&&this.#Xt(n),e.has(`selected`)||e.has(`rows`)||e.has(`filter`)){this.#ne=new Set(this.selected);let t=this.#Qt(),n=t.filter(e=>this.#ne.has(e)).length;this.#re=n===0?`none`:n===t.length?`all`:`some`,e.has(`selected`)&&this.selectable&&this.selected.length>0&&(this.#ze=this.#oi(this.#ei())),e.has(`selected`)&&this.#fi()}let r=e.has(`rows`)&&this.hasUpdated&&!this.#It&&this.#$.length?new Set(this.#$.map(e=>e.id)):null;if(this.#$=this.#K.getRowModel().rows,r){let e=this.#$.filter(e=>!r.has(e.id)).map(e=>e.id);e.length&&(this.#nt=/* @__PURE__ */ new Set([...this.#nt,...e]),setTimeout(()=>this.#nt.clear(),450))}if(this.#rt!==null){let e=this.#$.findIndex(e=>e.id===this.#rt);this.#rt=null,this.#nt=this.#Kt(e),setTimeout(()=>this.#nt.clear(),450)}this.#ye=this.#K.getStartVisibleLeafColumns(),this.#be=this.#K.getCenterVisibleLeafColumns(),this.#xe=this.#K.getEndVisibleLeafColumns(),this.#Se=[...this.#ye,...this.#be,...this.#xe],this.#dn(),this.#ve=this.#cn(),this.#we.setOptions(this.#ln()),n&&this.#Zt(),this.#Ht()}#Vt=!1;#Ht(){if(!this.#Vt)return;let e=this.dataSource?this.#ee?.total??null:this.#$.filter(e=>!e.getIsGrouped()).length;e!==null&&(this.#Vt=!1,this.#ze=W(e===1?`1 registro encontrado.`:G`${e} registros encontrados.`))}firstUpdated(){this.#De.observe(this.#ft),this.#De.observe(this)}#Ut=!1;#Wt=!1;updated(e){if(this.#gt(),this.#Wt&&(this.#Wt=!1,this.#$r()),this.#Ut){this.#Ut=!1;let e=this.querySelector(`:scope > [slot="actions"]`);e?e.focus():this.focus()}super.updated(e),this.#Fo(e),this.#xt();let t=this.#It;if(this.#It=null,t&&this.#Bt(t),this.#Zi(),this.#fn(),this.#kr(),this.#we._willUpdate(),this.label||this.getAttribute(`aria-label`)||this.getAttribute(`aria-labelledby`)||Le(this,`no-label`,`grade sem nome acessível. Correção: adicione label="...".`),this.#Re&&(this.#Re=!1,this.#mn()?.focus({preventScroll:!0})),this.#Ie){this.#Ie=!1;let e=this.#Fe.el;e.focus(),e instanceof HTMLInputElement&&this.#Fe.text===void 0&&e.select();let t=e.localName,n=t.includes(`-`)?customElements.whenDefined(t):Promise.resolve(),r=this.#Fe.text;n.then(()=>e.updateComplete).then(()=>{if(this.#Fe?.el!==e)return;e.focus();let t=e.shadowRoot?.activeElement;t instanceof HTMLInputElement&&r===void 0&&t.select()})}let n=this.renderRoot.querySelector(`.cell-error:not(.leaving)`);if(n){let e=this.renderRoot.querySelector(`.editing`).getBoundingClientRect();n.matches(`:popover-open`)||n.showPopover(),n.style.left=`${Math.max(0,Math.min(e.left,innerWidth-n.offsetWidth))}px`,n.style.top=`${Math.max(0,Math.min(e.bottom,innerHeight-n.offsetHeight))}px`}if(this.#ke){this.#ke=!1;let e=this.renderRoot.querySelector(`.column-menu:not(.leaving)`);this.#Za(e,this.#Pr(this.#Oe).getBoundingClientRect(),!1)}if(this.#Ve){this.#Ve=!1;let e=this.renderRoot.querySelector(`.options:not(.leaving)`);this.#Za(e,this.#si().getBoundingClientRect(),!0)}if(this.#Ye){this.#Ye=!1;let e=this.renderRoot.querySelector(this.#Ga()),t=this.renderRoot.querySelector(`.panel-menu:not(.leaving)`);this.#Za(t,e.getBoundingClientRect(),!0),t.querySelector(`[aria-checked="true"]`)?.focus()}let r=this.renderRoot.querySelector(`.panel-resizer`);if(r){let{min:e,max:t}=this.#Da();r.setAttribute(`aria-valuemin`,String(e)),r.setAttribute(`aria-valuemax`,String(t)),r.setAttribute(`aria-valuenow`,String(r.parentElement.offsetWidth))}if(this.#lt){let e=this.renderRoot.querySelector(this.#lt);this.#lt=null,e?.focus()}}#Gt(e){if(e.has(`dynamicMode`)&&(this.#at=!0,this.dynamicMode?this.#tt.delete(`panel`):e.get(`dynamicMode`)&&this.#Nt(`panel`)),e.has(`filterRow`)&&(this.filterRow?(this.#tt.delete(`filter-row`),this.#at=!0):e.get(`filterRow`)&&this.#Nt(`filter-row`)),e.has(`selected`)){let t=e.get(`selected`)?.length??0;this.selected.length>0?(this.#ta=!1,this.#tt.delete(`feedback`)):t>0&&!this.#ta&&this.#Nt(`feedback`,t)}}#Kt(e){let t=/* @__PURE__ */ new Set,n=this.#$[e]?.depth??0;for(let r=e+1;r<this.#$.length&&this.#$[r].depth>n;r++)t.add(this.#$[r].id);return t}#qt(){let e=getComputedStyle(this),t=this.density??qe(this),n=parseFloat(e.getPropertyValue(`--sankhya-ds-grid-row-height-${t}`))||parseFloat(e.getPropertyValue(`--sankhya-ds-density-row-height`));this.#ue=n>0?n:pt}#Jt(){let e=o(this.columns);for(let t of e.problems)H(this,`columns:${t}`,`columns: ${t}`);let t=this.#J?this.#q.aggregates:void 0,n=t?o(de(this.columns,t)):e;this.#G=n,this.#K=ge({columns:this.selectable?[s,...n.defs]:n.defs,data:[],getRowId:(e,t,n)=>{let r=e[this.rowKey];return r==null?n?`${n.id}.${t}`:String(t):String(r)},getSubRows:this.subRows?e=>this.#Q.children.get(e):void 0}),this.#q=T(fe(n.leaves),this.#J?this.#q:{},this.#St()),O(this.#K,this.#q,this.selectable,this.#Dr)}#Yt(){this.#Q=v(this.dataSource?[]:this.rows,{sort:this.sort,filter:this.filter,specs:this.#G.leaves,byId:this.#G.byId,getChildren:this.subRows}),_e(this.#K,this.#Q.rows)}#Xt(e){this.#ee?.reset(),clearTimeout(this.#te),this.#te=void 0,this.#ee=new te({blockSize:Math.max(1,this.blockSize),maxBlocks:ht,load:(t,n,r)=>e.getRows({start:t,end:n,sort:this.sort,filter:this.filter,signal:r}),onChange:()=>{this.#ti(),this.requestUpdate()},onError:e=>this.emit(`sankhya-ds-error`,{error:e})})}#Zt(){let e=this.#ee;e.total===null?e.ensure(0,this.#ve.page):this.#te??=setTimeout(()=>{this.#te=void 0,e.ensure(this.#ve.start,this.#ve.end)},mt)}#Qt(){return this.#K.getCoreRowModel().flatRows.map(e=>e.id)}#$t(){return this.#G.depth+(this.filterRow||this.#tt.has(`filter-row`)?1:0)}#en(){return this.#ue*this.#$t()}#tn(){return[{id:`grid-config`,label:W(`Configurar grade`),icon:Ce(),run:()=>void this.#vt()},{id:`search`,label:this.filterRow?W(`Limpar busca`):W(`Buscar`),icon:j(),run:()=>this.#ha(!this.filterRow)},{id:`dynamic-mode`,label:this.dynamicMode?W(`Fechar agrupar e totalizar`):W(`Agrupar e totalizar`),icon:ke(),run:()=>this.#va(!this.dynamicMode)},{id:`density`,label:this.density===`comfortable`?W(`Modo compacto`):W(`Modo confortável`),icon:Ee(),run:()=>{this.density===`comfortable`?this.density=this.#i:(this.#i=this.density,this.density=`comfortable`),this.emit(`sankhya-ds-density-change`,{density:this.density??qe(this)})}}].filter(e=>this.optionItems.includes(e.id)&&(e.id!==`grid-config`||!this.columnsLocked))}#nn(){return!this.columnsLocked&&!this.noOptions&&this.optionItems.includes(`grid-config`)}#rn(){return!this.noOptions&&(this.optionItems.includes(`find-column`)||this.#tn().length>0)}#in(){return Math.max(0,Math.floor(this.#fe-this.#K.getTotalSize()))}#an(){return this.#G.leaves.some(e=>e.def.aggregate)}#on(){let e=this.#an()?this.#ue:0;return Math.max(0,this.#de-this.#en()-e)}#sn(e){if(!this.autoHeight||e===0)return null;let t=this.maxRows>0?Math.floor(this.maxRows):e,n=Math.min(e,t),r=this.#an()?this.#ue:0;return`block-size:${this.#en()+n*this.#ue+r+this.#Ee}px`}#cn(){return b({count:this.rowCount,rowHeight:this.#ue,scrollTop:this.#ge,viewport:this.#on()})}#ln(){let e=this.#be.length;return{count:e,horizontal:!0,getScrollElement:()=>this.#ft,estimateSize:e=>this.#be[e].getSize(),getItemKey:e=>this.#be[e].id,scrollToFn:Ve,observeElementRect:Ue,observeElementOffset:He,paddingStart:Q(this.#ye),paddingEnd:Q(this.#xe),overscan:2,rangeExtractor:t=>{let n=Be(t),r=this.#Le.col-this.#ye.length;return r>=0&&r<e&&!n.includes(r)&&(n.push(r),n.sort((e,t)=>e-t)),n},onChange:e=>{`${e.range?.startIndex}:${e.range?.endIndex}`!==this.#Ce&&this.requestUpdate()}}}#un=()=>{this.#ge=this.#ft.scrollTop;let e=this.#cn();(e.start!==this.#ve.start||e.end!==this.#ve.end||e.scale!==1)&&this.requestUpdate();let t=this.rowCount;!this.dataSource&&t>0&&e.end>=t&&this.#_e!==t&&(this.#_e=t,this.emit(`sankhya-ds-scroll-end`,{rowCount:t}))};#dn(){let e=this.rowCount-1;this.#Le={row:Math.min(this.#Le.row,e),col:Math.max(0,Math.min(this.#Le.col,this.#Se.length-1))}}#fn(){let e=(this.density??this.closest(`[data-density]`)?.getAttribute(`data-density`))===`compact`;for(let t of this.renderRoot.querySelectorAll(`.rows [data-row-key]`)){let n=0;for(let r of t.querySelectorAll(`.visual`)){let t=r.querySelectorAll(`sankhya-ds-circle-button, sankhya-ds-button`);n+=t.length;for(let n of t){n.getAttribute(`size`)!==`xs`&&n.setAttribute(`size`,`xs`);let t=n.dataset.sankhyaDsVariant,r=t??n.getAttribute(`variant`)??`secondary`;r===`danger`?H(this,`cell-danger`,`ação destrutiva não fica na célula (V19). Correção: leve "Excluir" para o menu ⋮ da linha, com sankhya-ds-dialog de confirmação.`):r===`primary`&&H(this,`cell-primary`,`botão primário na célula (RV12): a ação da linha é secundária ou terciária. Correção: variant="secondary".`),n.tagName===`SANKHYA-DS-BUTTON`&&(n.textContent??``).trim().split(/\s+/).length>2&&H(this,`cell-text-button`,`botão com texto longo na célula (RV12): o rótulo tem 1 ou 2 palavras. Correção: encurte o rótulo ou use sankhya-ds-circle-button com dica.`),e&&r!==`danger`&&r!==`primary`?(t===void 0&&(n.dataset.sankhyaDsVariant=n.getAttribute(`variant`)??``),n.getAttribute(`variant`)!==`tertiary`&&n.setAttribute(`variant`,`tertiary`)):!e&&t!==void 0&&(t?n.setAttribute(`variant`,t):n.removeAttribute(`variant`),delete n.dataset.sankhyaDsVariant)}}n>2&&H(this,`cell-icons`,`${n} ações numa linha: o máximo é 2 (RV12). Correção: deixe as 2 ações mais usadas, na mesma ordem em todas as linhas, e as outras no menu ⋮ da linha.`);for(let e of t.querySelectorAll(`.visual`)){if(e.querySelector(ft)){H(this,`cell-field`,`campo de digitação na célula (V19): a grade edita o valor no próprio editor. Correção: tire o render da coluna e use editable na grade com o type da coluna (ex.: type: "number" abre o sankhya-ds-number-input), ou editor: { create, getValue } para um editor próprio.`);for(let t of e.querySelectorAll(`sankhya-ds-number-input:not([no-buttons])`))t.setAttribute(`no-buttons`,``)}let t=e.querySelectorAll(`sankhya-ds-tag`);(t.length>1||[...t].some(e=>e.getAttribute(`tone`)===`solid`))&&H(this,`cell-tag`,`a célula mostra uma Tag só, no tom light (V19). Correção: uma sankhya-ds-tag sem tone="solid" por célula.`)}}}#pn(e){let t=e.target,n=t.closest(`[role="gridcell"]`);if(!n||n.classList.contains(`select-cell`))return!1;let r=[...n.querySelectorAll(Ot)].filter(e=>!e.matches(`:disabled, [disabled]`));if(t===n){if(e.key!==`Enter`&&e.key!==`F2`)return!1;let t=this.#Mn(n),i=t&&this.#G.byId.get(this.#Se[t.col].id);return!r.length||i&&this.#Hn(this.#uo(t.row),i)?!1:(e.preventDefault(),r[0].focus(),!0)}return e.key===`Escape`||e.key===`F2`?(e.defaultPrevented||(e.preventDefault(),n.focus()),!0):(e.key===`Tab`&&r.length&&(e.preventDefault(),r[(r.findIndex(e=>e===t||e.contains(t))+(e.shiftKey?-1:1)+r.length)%r.length].focus()),!0)}#mn(){return this.renderRoot.querySelector(`[tabindex="0"]`)}#hn(e){this.#dt&&e.row!==this.#dt.index&&this.#$a(),this.#Le=e,e.row>=0&&this.scrollToRow(e.row),this.#gn(e.col),this.#Re=!0,this.requestUpdate()}#gn(e,t=!1){let n=this.#ft,r=this.#Se[e];if(r.getIsPinned()!==!1)return;let i=Q(this.#ye),a=r.getStart(`center`),o=a+r.getSize(),s=n.clientWidth-i-Q(this.#xe),c=t&&!Ne()?`smooth`:`auto`;a<n.scrollLeft?n.scrollTo({left:a,behavior:c}):o>n.scrollLeft+s&&n.scrollTo({left:o-s,behavior:c})}#_n=e=>{let t=e.target.closest(`[data-col]`);if(!t)return;let n={row:Number(t.dataset.row),col:Number(t.dataset.col)};this.#dt&&n.row!==this.#dt.index&&this.#$a(),(n.row!==this.#Le.row||n.col!==this.#Le.col)&&(this.#Le=n,this.requestUpdate())};#vn(e){return!!e?.closest?.(`.filter-row`)}#yn(){return this.selectable}#bn=e=>{if(this.#vn(e.target)){let t=e.target;e.key===`Escape`&&t.value&&(t.value=``,t.dispatchEvent(new Event(`input`)),e.preventDefault());return}if(this.#Fe){this.#Qn(e);return}if(this.#pn(e))return;let t=e.ctrlKey||e.metaKey,{row:n,col:r}=this.#Le,i=this.#Se[r]?.id;if(n>=0&&this.#Do(e)||(n<0?this.#or(e):this.#An(e,n,i))){e.preventDefault();return}let a=this.#yn(),o=e.key===`Tab`&&n>=0&&!t&&!e.altKey?this.#xn(e.shiftKey):null,s=o??C(e.key,t,this.#Le,{rows:this.rowCount,cols:this.#Se.length,minRow:-1,page:this.#ve.page});if(s){e.preventDefault(),a?(this.#jn(null),s.row>=0&&this.#Cn(s.row,e.shiftKey&&!o)):e.shiftKey&&!o&&n>=0&&s.row>=0?this.#jn(this.#Me?.anchor??this.#Le,s):this.#jn(null),this.#hn(s);return}if(t&&e.key.toLowerCase()===`a`&&this.rowCount){e.preventDefault(),a&&!this.dataSource?this.#wn():this.#jn({row:0,col:0},{row:this.rowCount-1,col:this.#Se.length-1});return}if(e.key===`Escape`){this.#jn(null),this.#bt()&&(e.preventDefault(),this.#oa());return}let c=e.key.length===1&&e.key!==` `&&!t&&!e.altKey;if(n>=0&&(e.key===`Enter`||e.key===`F2`||c)&&this.#Gn(n,r,c?e.key:void 0))e.preventDefault();else if(e.key===`Enter`||e.key===` `){if(n>=0&&e.key===`Enter`)this.enterNavigation===`none`?this.#En(n,r):(e.preventDefault(),this.#jn(null),this.#hn(this.#Tn(e.shiftKey)));else if(n<0)e.preventDefault(),this.columnSelect&&t&&e.key===` `&&i!==`__select`?this.#sr(r,e.shiftKey):i===`__select`?this.dataSource||this.#ii():this.#Qr(i,e.shiftKey);else if(e.key===` `&&this.selectable){e.preventDefault();let r=this.#uo(n);if(!r.data)return;t?this.#ri(r.id):this.#Cn(n,!1,!0)}}};#xn(e){let{row:t,col:n}=this.#Le,r=+(this.#Se[0]?.id===`__select`),i=this.#Se.length-1;return e?n>r?{row:t,col:n-1}:t>0?{row:t-1,col:i}:null:n<i?{row:t,col:n+1}:t<this.rowCount-1?{row:t+1,col:r}:null}#Sn(e,t){let n=[];for(let r=Math.min(e,t);r<=Math.max(e,t);r++){let e=this.#uo(r);e.data&&!e.group&&n.push(e.id)}return n}#Cn(e,t,n=!1){let r=this.#uo(e);if(!r.data||r.group)return;let i;t?(this.#ir<0&&(this.#ir=Math.max(0,this.#Le.row)),i=this.#Sn(this.#ir,e)):(i=[r.id],this.#ir=e),(n||i.join(`\0`)!==this.selected.join(`\0`))&&(this.selected=i,this.#$r())}#wn(){let e=this.#Qt(),t=new Set(e);this.selected=[...this.selected.filter(e=>!t.has(e)),...e],this.#$r()}#Tn(e){let{row:t,col:n}=this.#Le;return this.enterNavigation===`down`||this.editMode===`row`?{row:Math.max(0,Math.min(this.rowCount-1,t+(e?-1:1))),col:n}:this.#xn(e)??{row:t,col:n}}#En(e,t){let n=this.#uo(e),r=this.#Se[t].id;n.data&&!n.group&&r!==`__select`&&this.emit(`sankhya-ds-row-activate`,{rowId:n.id,row:n.data,columnId:r})}#Dn(){return this.#Se.find(e=>e.id!==r)?.id}#On(){return!this.dataSource&&(this.#q.groupBy.length>0||!!this.subRows)}#kn(e,t,n=!0){if(this.#it){let n=this.#it.row;if(this.#it=null,this.#kn(n,!1,!1),n.id===e.id&&!t)return}let r=t||!n?/* @__PURE__ */ new Set:this.#Kt(e.index);if(r.size){let t={row:e,ids:r};this.#it=t,this.requestUpdate(),this.updateComplete.then(()=>{let n=()=>{this.#it===t&&(this.#it=null,this.#kn(e,!1,!1))},r=this.renderRoot.querySelector(`.row-out`);r?M(r,n):n()});return}this.#at=!0,t&&(this.#rt=e.id);let i=this.expanded===!0?Object.fromEntries(this.#$.filter(e=>e.getCanExpand()).map(e=>[e.id,!0])):{...this.expanded};t?i[e.id]=!0:delete i[e.id],this.expanded=i,this.emit(`sankhya-ds-expand-change`,{rowId:e.id,expanded:t})}#An(e,t,n){if(!this.#On()||e.altKey||e.shiftKey)return!1;let r=this.#uo(t);if(e.key===`Enter`&&r.canExpand)return this.#kn(r,!r.expanded),!0;if(n!==this.#Dn())return!1;if(e.key===`ArrowRight`&&r.canExpand&&!r.expanded)return this.#kn(r,!0),!0;if(e.key!==`ArrowLeft`)return!1;if(r.expanded)return this.#kn(r,!1),!0;let i=t-1;for(;i>=0&&this.#$[i].depth>=r.depth;)i--;return i<0?!1:(this.#hn({row:i,col:this.#Le.col}),!0)}#jn(e,t){let n=JSON.stringify(this.getSelectedRange());this.#Me=e?{anchor:e,focus:t}:null,JSON.stringify(this.getSelectedRange())!==n&&(this.requestUpdate(),this.emit(`sankhya-ds-range-change`,{range:this.getSelectedRange()}))}#Mn(e){let t=e.closest(`[data-row]`);return t?{row:Number(t.dataset.row),col:Number(t.dataset.col)}:null}#Nn=null;#Pn=e=>{let t=this.#Mn(e.target);this.#Nn=t,e.button===0&&t&&!e.target.closest(`input, select, .toggle`)&&(this.#jn(e.shiftKey?this.#Me?.anchor??this.#Le:t,t),this.#Pe=!0,addEventListener(`pointerup`,()=>this.#Pe=!1,{once:!0}))};#Fn=e=>{let t=this.#Mn(e.target);this.#Pe&&t&&this.#jn(this.#Me.anchor,t);let n=e.target.closest?.(`.cell`);if(n?.id&&!n.querySelector(`input, select, textarea`)){let e=(n.textContent??``).replace(/\s+/g,` `).trim();this.#Rn.get(n.id)!==e&&(this.#Rn.set(n.id,e),this.requestUpdate()),this.#Ln.sync(n)}};#In=e=>{let t=e.currentTarget,n=t.querySelector(`.label`).textContent.trim();this.#Rn.get(t.id)!==n&&(this.#Rn.set(t.id,n),this.requestUpdate()),this.#Ln.check(e)};#Ln=new Ke(this);#Rn=/* @__PURE__ */ new Map;#zn(e,t){let n=this.#Se[t].id,r=this.#G.byId.get(n);if(e<0)return r.header;let a=this.#uo(e);return a.data?a.group?this.#Ro(a,n,r):i(r,a.tan?a.tan.getValue(n):r.accessor(a.data),a.data):``}#Bn=e=>{if(this.#Fe||this.#vn(e.target))return;let{start:t,end:n}=this.getSelectedRange()??{start:this.#Le,end:this.#Le},r=[];for(let e=t.row;e<=n.row;e++){let i=[];for(let r=t.col;r<=n.col;r++)this.#Se[r].id!==`__select`&&i.push(this.#zn(e,r));r.push(i)}e.preventDefault(),e.clipboardData.setData(`text/plain`,u(r,` `))};#Vn=e=>{if(this.#Fe||this.#Le.row<0||this.#vn(e.target))return;let t=l(e.clipboardData.getData(`text/plain`));if(!t.length)return;e.preventDefault();let r=this.getSelectedRange(),i=r?.start??this.#Le,a=r&&t.length===1&&t[0].length===1,o=a?r.end.row-i.row+1:t.length,s=a?r.end.col-i.col+1:Math.max(...t.map(e=>e.length)),c=[];for(let e=0;e<o&&i.row+e<this.rowCount;e++){let r=this.#uo(i.row+e);for(let o=0;o<s&&i.col+o<this.#Se.length;o++){let s=this.#G.byId.get(this.#Se[i.col+o].id),l=a?t[0][0]:t[e][o];if(!s||l===void 0||!this.#Hn(r,s))continue;let u=s.def.options?.find(e=>e.label===l.trim());c.push({row:r,spec:s,value:u?u.value:n(l,s.type)})}}this.#Wn(c)};#Hn(e,t){let n=t.def.editable;return this.readonly||!e.data||e.group||!n?!1:typeof n!=`function`||n(e.data)}#Un(e,t,n){return e.def.validate?.(t,n)||null}#Wn(e){let t=!1,n=[];for(let{row:r,spec:i,value:a}of e){let e=r.data,o=i.accessor(e);if(Object.is(o,a))continue;let s=this.#Un(i,a,e);s?n.push(`${i.header}: ${s}`):!this.emit(`sankhya-ds-change`,{rowId:r.id,columnId:i.id,value:a,previousValue:o,row:e},{cancelable:!0}).defaultPrevented&&i.def.field&&(e[i.def.field]=a,t=!0)}t&&!this.dataSource&&(this.#Q={...this.#Q,rows:[...this.#Q.rows]},_e(this.#K,this.#Q.rows)),n.length&&(this.#ze=n.join(` `)),this.requestUpdate()}#Gn(e,t,n){let r=this.#uo(e),i=this.#G.byId.get(this.#Se[t].id);if(!i||!this.#Hn(r,i))return!1;let a=d(i),o=this.#dt?.view.id===r.id?this.#dt.values:void 0,s=o?.has(i.id)?o.get(i.id):i.accessor(r.data);if(i.type===`boolean`&&!i.def.editor)return n!==void 0&&!/^[sn]$/i.test(n)?!1:(this.#qn(r,i,n===void 0?!s:/^s$/i.test(n)),!0);if((a===`date`||a===`datetime`)&&n!==void 0&&/^h$/i.test(n))return this.#qn(r,i,f(p(a),a,s)),!0;let c={row:e,col:t,view:r,spec:i,kind:a,value:s,text:n};return c.el=typeof a==`string`?this.#Yn(a,i,s,n):a.create({value:s,row:r.data,column:i.def,initialText:n,commit:e=>this.#Kn(e),cancel:()=>this.#Jn()}),this.#Fe=c,this.#Ie=!0,this.requestUpdate(),!0}#Kn(e,t=!1){let n=this.#Fe;if(!n)return!0;let{kind:r,spec:i,view:a}=n,o=e;o===void 0&&(o=typeof r==`object`?r.getValue(n.el):h(r,n.el,i,n.value));let s=Object.is(o,n.value)?null:this.#Un(i,o,a.data);return s&&!t?(n.error=s,this.requestUpdate(),!1):(this.#Jn(),s?this.#ze=`${i.header}: ${s}`:this.editMode===`row`?this.#Qa(a,i,o):this.#Wn([{row:a,spec:i,value:o}]),!0)}#qn(e,t,n){this.editMode===`row`?this.#Qa(e,t,n):this.#Wn([{row:e,spec:t,value:n}])}#Jn(){this.#Fe=null,this.#Re=!0,this.requestUpdate()}#Yn(e,t,n,r){this.#Zn();let i=m(e,t,n,r);i.addEventListener(`keydown`,e=>{e.key!==`Enter`&&e.key!==`Escape`||i.open||this.#Fe?.el!==i||(e.stopPropagation(),this.#Qn(e))},{capture:!0});for(let e of dt)i.addEventListener(e,e=>e.stopPropagation());return(e===`date`||e===`datetime`)&&i.addEventListener(`keydown`,t=>{!/^h$/i.test(t.key)||t.ctrlKey||t.metaKey||t.altKey||this.#Fe?.el!==i||(t.preventDefault(),t.stopPropagation(),this.#Kn(f(p(e),e,this.#Fe.value)))},{capture:!0}),(e===`select`||e===`date`||e===`datetime`)&&i.addEventListener(`sankhya-ds-change`,()=>setTimeout(()=>{this.#Fe?.el===i&&!i.open&&this.#Kn()})),i}#Xn=null;#Zn(){return this.#Xn??=import(`./core/editor-fields.define.js`),this.#Xn}#Qn(e){if(e.defaultPrevented)return;let t=this.editMode===`row`,{row:n,col:r}=this.#Fe;if(e.key===`Escape`)this.#Jn(),t&&this.#eo();else if(e.key===`Enter`)this.#Kn()&&(t&&this.#$a(),(t||this.enterNavigation!==`none`)&&this.#hn(this.#Tn(e.shiftKey)));else if(e.key===`Tab`&&t){if(this.#Kn()){let t=this.#to(n,r,e.shiftKey);t>=0?(this.#hn({row:n,col:t}),this.#Gn(n,t)):(this.#$a(),this.#hn(this.#xn(e.shiftKey)??{row:n,col:r}))}}else if(e.key===`Tab`)this.#Kn()&&this.#hn(C(e.shiftKey?`ArrowLeft`:`ArrowRight`,!1,this.#Le,{rows:this.rowCount,cols:this.#Se.length,minRow:-1,page:1}));else return;e.preventDefault()}#$n=e=>{let t=e.target.closest(`.editing`);this.#Fe&&t&&!t.contains(e.relatedTarget)&&this.#Kn(void 0,!0)};#er=e=>{let t=this.#Mn(e.target);t&&!e.target.closest(`.toggle`)&&this.#En(t.row,t.col)};#tr(e){let t=e.el;return e.error?(t.setAttribute(`aria-invalid`,`true`),t.setAttribute(`aria-describedby`,`cell-error`)):(t.removeAttribute(`aria-invalid`),t.removeAttribute(`aria-describedby`)),t}#nr=e=>{let t=e.target,n=t.closest(`.toggle`);if(n){let e=this.#uo(Number(n.closest(`[data-row]`).dataset.row));this.#kn(e,!e.expanded);return}let r=this.#Mn(t),i=this.#Nn??r;this.#Nn=null;let a=!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.detail<=1,o=this.#Fe;o&&r&&o.row===r.row&&o.col===r.col||(this.#ar(e,t),a&&r&&i?.row===r.row&&i.col===r.col&&(this.#Gn(r.row,r.col),this.#Fe||this.#rr(r.row,r.col,e,t)))};#rr(e,t,n,r){if(r.closest(`input, select, textarea, button, a, [contenteditable], .editor`))return;let i=this.#uo(e),a=this.#Se[t].id;if(!i.data||i.group||a===`__select`)return;let o={rowId:i.id,row:i.data,rowIndex:e,columnId:a,originalEvent:n};this.emit(`sankhya-ds-row-click`,o)}#ir=-1;#ar(e,t){if(!this.selectable||this.#Fe||t.closest(`input, select, textarea, button, a, [contenteditable], .editor`))return;let n=t.closest(`[data-row]`),r=Number(n?.dataset.row);if(!n||Number.isNaN(r)||r<0)return;let i=this.#uo(r);if(i.data&&!i.group){if(e.shiftKey&&this.#ir>=0)this.selected=this.#Sn(this.#ir,r);else if(e.ctrlKey||e.metaKey){let e=new Set(this.selected);e.has(i.id)?e.delete(i.id):e.add(i.id),this.selected=[...e],this.#ir=r}else if(this.rowClickable){this.#ir=r;return}else this.selected=[i.id],this.#ir=r;this.#$r()}}#or(e){let t=this.#Se[this.#Le.col].id;if(t===`__select`)return!1;if(e.altKey&&e.key===`ArrowDown`||e.shiftKey&&e.key===`F10`||e.key===`ContextMenu`)return this.#Fr(t),!0;if(e.altKey&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)){if(!this.#G.byId.get(t).resizable)return!0;let n=e.key===`ArrowLeft`?-16:jt;return this.#xr(),this.#Dt(this.#dr(t,this.#K.getColumn(t).getSize()+n)),!0}return!1}#sr(e,t){if(!this.rowCount)return;let n=t&&this.#Me?this.#Me.anchor.col:e;this.#jn({row:0,col:n},{row:this.rowCount-1,col:e})}#cr(e){let t=this.columnSelect?this.getSelectedRange():null;return!!(t&&t.start.row===0&&t.end.row===this.rowCount-1&&e>=t.start.col&&e<=t.end.col)}#lr=e=>{let t=e.target,n=t.closest(`[data-col]`),r=n?.dataset.id;r&&r!==`__select`&&!t.closest(`.resizer`)&&(this.columnSelect&&(e.ctrlKey||e.metaKey)&&!t.closest(`.menu-btn, .filter-btn`)?this.#sr(Number(n.dataset.col),e.shiftKey):t.closest(`.menu-btn`)?this.#Fr(r):t.closest(`.filter-btn`)?this.#Kr(r):this.#Qr(r,e.shiftKey))};#ur=e=>{let t=e.target.closest(`[data-col]`)?.dataset.id;t&&t!==`__select`&&(e.preventDefault(),this.#Fr(t))};#dr(e,t){let n=this.#G.byId.get(e),r=Math.round(Math.min(n.maxWidth,Math.max(this.#fr(n),t)));return{...this.#q,widths:{...this.#q.widths,[e]:r}}}#fr(e){return e.def.minWidth===void 0?Math.min(e.minWidth,this.#Dr[e.id]??e.minWidth):e.def.minWidth}#pr=e=>{let t=e.target,n=t.closest(`[data-id]`).dataset.id;e.preventDefault(),e.stopPropagation(),t.setPointerCapture(e.pointerId),clearTimeout(this.#br),this.#yr&&(this.#yr=!1,this.requestUpdate()),this.#je={id:n,x:e.clientX,width:this.#K.getColumn(n).getSize()}};#mr=e=>{if(!this.#je)return;let{id:t,x:n,width:r}=this.#je;this.#Ct(this.#dr(t,r+e.clientX-n))};#hr=()=>{this.#je&&(this.#je=null,this.emit(`sankhya-ds-layout-change`,{layout:this.getLayout()}))};#gr=e=>{this.#_r(e.target.closest(`[data-id]`).dataset.id)};#_r(e){this.#xr(),this.#Dt(this.#dr(e,this.#Cr(e)))}#vr(e){let t={...this.#q.widths};delete t[e],this.#xr(),this.#Dt({...this.#q,widths:t})}#yr=!1;#br;#xr(){this.#yr=!0,clearTimeout(this.#br),this.#br=setTimeout(()=>{this.#yr=!1,this.requestUpdate()},450)}#Sr=null;#Cr(e){return this.#wr([e],1/0).get(e)??this.#K.getColumn(e).getSize()}#wr(e,t){let n=/* @__PURE__ */ new Map,r=this.renderRoot,a=r.querySelector(`.head[data-id]:not(.select-cell) .head-main > .label`),o=a?.closest(`.head`);if(!o||!a)return n;let s=a.parentElement;this.#Sr??=document.createElement(`canvas`).getContext(`2d`);let c=this.#Sr,l=e=>{let t=getComputedStyle(e);return`${t.fontStyle} ${t.fontWeight} ${t.fontSize} ${t.fontFamily}`},u=e=>{let t=getComputedStyle(e);return parseFloat(t.paddingInlineStart)+parseFloat(t.paddingInlineEnd)+parseFloat(t.borderInlineStartWidth)+parseFloat(t.borderInlineEndWidth)},d=parseFloat(getComputedStyle(s).columnGap)||0,f=document.createElement(`span`);f.className=`icon`,s.append(f);let p=f.offsetWidth+d;f.remove();let m=l(a),h=o.querySelector(`.menu-btn`),g=parseFloat(getComputedStyle(o).columnGap)||0,_=h&&getComputedStyle(h).position!==`absolute`,v=u(o)+u(s)+(_?h.offsetWidth+g:0),y=r.querySelector(`[role="gridcell"]:not(.select-cell):not(.editing):not(.visual)`),ee=y?l(y):``,te=y?u(y):0,b=y?document.createElement(`span`):null;b&&y.append(b);let x=/* @__PURE__ */ new Set;for(let e of r.querySelectorAll(`[role="gridcell"]:not(.select-cell):not(.visual)`)){let t=getComputedStyle(e);x.add(`${t.fontStyle}|${t.fontWeight}`)}let S=r.querySelector(`[role="gridcell"].divider`),C=S?parseFloat(getComputedStyle(S).borderInlineStartWidth):0,w=[];if(this.dataSource)w.push(...this.#ee.loadedRows());else{let e=t=>{for(let n of t)w.push(n),e(this.#Q.children.get(n)??[])};e(this.#Q.rows)}let ne=Math.max(1,Math.ceil(w.length/t)),re=document.createRange();for(let t of e){let e=this.#G.byId.get(t);if(!e)continue;c.font=m;let a=c.measureText(this.#Ca(e)).width+v,o=r.querySelector(`.head[data-id="${CSS.escape(t)}"] .head-main`),s=o?[...o.children].filter(e=>!e.matches(`.label`)):[];a+=s.reduce((e,t)=>e+t.getBoundingClientRect().width+d,0),e.sortable&&!s.some(e=>e.matches(`.icon`))&&(a+=p);let l=this.#Se.findIndex(e=>e.id===t),f=l<0?[]:r.querySelectorAll(`[role="gridcell"][data-col="${l}"]`);for(let e of f)re.selectNodeContents(e),a=Math.max(a,re.getBoundingClientRect().width+u(e));if(b&&!e.def.render&&e.type!==`boolean`&&e.type!==`component`){c.font=ee;let t=[];for(let n=0;n<w.length;n+=ne){let r=w[n],a=i(e,e.accessor(r),r);t.push([c.measureText(a).width,a])}t.sort((e,t)=>t[0]-e[0]),b.className=e.numeric?`probe num`:`probe`;let n=0;for(let e of x){let[r,i]=e.split(`|`);b.style.fontStyle=r,b.style.fontWeight=i;for(let[,e]of t.slice(0,Pt))b.textContent=e,n=Math.max(n,b.getBoundingClientRect().width)}a=Math.max(a,n+te+(e.def.divider?C:0))}n.set(t,Math.ceil(a)+Ft)}return b?.remove(),n}#Tr=!1;#Er(){return document.fonts.status===`loading`&&(this.#Tr||(this.#Tr=!0,document.fonts.ready.then(()=>requestAnimationFrame(()=>{this.#Tr=!1,this.requestUpdate()}))),!0)}#Dr={};#Or=/* @__PURE__ */ new Set;#kr(){if(this.#Tr)return;let e=this.#G.leaves.filter(e=>e.def.width===void 0&&!e.def.actions&&!this.#Or.has(e.id));if(!e.length)return;let t=(this.dataSource?this.#ee.loadedRows().length>0:this.#Q.rows.length>0)&&!!this.renderRoot.querySelector(`[role="gridcell"]:not(.select-cell):not(.editing):not(.visual)`),n=Math.max(200,Math.floor(Nt/e.length)),r=this.#wr(e.map(e=>e.id),n);if(!r.size)return;let i=!1,a=this.#Er();for(let n of e){let e=r.get(n.id),o=!!n.def.render||n.type===`component`,s=Math.round(Math.min(n.maxWidth,Mt,Math.max(n.def.minWidth??0,o?Math.max(e,150):e)));this.#Dr[n.id]!==s&&(this.#Dr[n.id]=s,i=!0),t&&!a&&this.#Or.add(n.id)}i&&(O(this.#K,this.#q,this.selectable,this.#Dr),this.requestUpdate())}#Ar=e=>{let t=e.target.dataset.id;this.#je?e.preventDefault():(this.#Ae={id:t},e.dataTransfer?.setData(`text/plain`,t))};#jr=e=>{let t=e.target.closest(`[data-id]`),n=t?.dataset.id;if(!this.#Ae||this.#Ae.from||!n||n===`__select`||this.columnsLocked)return;e.preventDefault();let r=t.getBoundingClientRect(),i=e.clientX>r.left+r.width/2;(this.#Ae.target!==n||this.#Ae.after!==i)&&(this.#Ae={...this.#Ae,target:n,after:i},this.requestUpdate())};#Mr=e=>{let t=this.#Ae;this.#Ae=null,t?.target&&(e.preventDefault(),this.#Dt(E(this.#q,t.id,t.target,t.after)))};#Nr=()=>{this.#Ae=null,this.#Xe=null,this.#Ze=null,this.#st=null,this.requestUpdate()};#Pr(e){return this.renderRoot.querySelector(`[role="columnheader"][data-id="${CSS.escape(e)}"]`)}#Fr(e){this.#Br(e).length&&(this.#Oe=e,this.#ke=!0,this.requestUpdate())}#Ir(){let e=this.#Oe;this.#Oe=null,At(this.renderRoot.querySelector(`.column-menu:not(.leaving)`)),this.requestUpdate(),this.#Pr(e)?.focus({preventScroll:!0})}#Lr=e=>{e.newState===`closed`&&this.#Oe&&(e.target.dataset.dismissed=``,this.#Oe=null,this.requestUpdate())};#Rr=e=>{let t=[...e.currentTarget.querySelectorAll(`[role^="menuitem"]:not([aria-disabled="true"])`)],n=t.indexOf(e.target),r=e=>t[(e+t.length)%t.length].focus();if(e.key===`ArrowDown`)r(n+1);else if(e.key===`ArrowUp`)r(n-1);else if(e.key===`Home`)r(0);else if(e.key===`End`)r(t.length-1);else if(e.key===`Escape`||e.key===`Tab`)this.#qe?this.#Ka():this.#Ir();else return;e.preventDefault(),e.stopPropagation()};#zr(e,t){let n=this.#Se.map(e=>e.id).filter(e=>e!==r);return n[n.indexOf(e)+t]}#Br(e){let t=this.#G.byId.get(e),n=this.#q,r=me(n,e),i=this.sort.find(t=>t.id===e),a=t=>()=>{this.sort=t===null?[]:[{id:e,desc:t}],this.emit(`sankhya-ds-sort-change`,{sort:this.sort})},o=t=>()=>this.#Dt(pe(n,e,t)),s=t=>{let r=this.#zr(e,t);return{disabled:!r,run:()=>this.#Dt(E(n,e,r,t>0))}},c=this.#G.leaves.filter(e=>!n.hidden.includes(e.id)).length,l=[],u=[];if(t.sortable&&u.push({icon:je,label:ee(t.type)[0],run:a(!1),checked:i?.desc===!1},{icon:Ae,label:ee(t.type)[1],run:a(!0),checked:i?.desc===!0}),this.#Wr(t)&&u.push({icon:()=>we(),label:W(`Filtrar`),run:()=>this.#Kr(e)}),this.#ya()){let t=n.groupBy.includes(e);u.push({icon:Oe,label:W(t?`Desagrupar`:`Agrupar por esta coluna`),run:()=>this.#Dt({...n,groupBy:t?n.groupBy.filter(t=>t!==e):[...n.groupBy,e]})})}let d=this.columnsLocked;d||u.push(r===`center`?{icon:De,label:W(`Fixar coluna`),run:o(`start`)}:{icon:De,label:W(`Desafixar coluna`),run:o(null)}),u.length&&l.push(u);let f=[];return t.sortable&&f.push({label:W(`Remover ordenação`),run:a(null),disabled:!i}),d||f.push({label:W(`Fixar à direita`),run:o(`end`),checked:r===`end`},{label:W(`Mover para a esquerda`),...s(-1)},{label:W(`Mover para a direita`),...s(1)}),f.length&&l.push(f),t.resizable&&l.push([{label:W(`Ajustar largura ao conteúdo`),run:()=>this.#_r(e)},{label:W(`Largura padrão`),run:()=>this.#vr(e),disabled:n.widths[e]===void 0}]),d||l.push([{label:W(`Ocultar coluna`),run:()=>this.#Dt(D(n,e,!0)),disabled:!t.hideable||c<2},{label:W(`Restaurar colunas`),run:()=>this.#Dt({...fe(this.#G.leaves),groupBy:n.groupBy,sort:this.sort})},...this.#nn()?[{label:W(`Configurar colunas`),run:()=>void this.#vt()}]:[]]),this.columnActions.length&&l.push(this.columnActions.map(t=>({label:t.label,run:()=>this.emit(`sankhya-ds-column-action`,{action:t.id,columnId:e})}))),d||l.push(this.#G.leaves.map(e=>{let t=!n.hidden.includes(e.id);return{label:e.header,checked:t,keep:!0,disabled:t&&(!e.hideable||c<2),run:()=>this.#Dt(D(this.#q,e.id,t))}})),l}#Vr(){let e=this.#Oe;if(!e)return R;let t=this.#G.byId.get(e),n=this.#Br(e),r=n.length-1;return L`<div class="menu column-menu" part="menu" popover="auto" role="menu" aria-label=${W(G`Opções da coluna ${t.header}`)} @beforetoggle=${this.#Ot} @toggle=${this.#Lr} @keydown=${this.#Rr} > ${n.map((e,t)=>L` ${t===r&&!this.columnsLocked?L`<div class="menu-label" role="presentation">${W(`Colunas`)}</div>`:R} ${e.map(e=>L`<button type="button" class="item" role=${e.checked===void 0?`menuitem`:`menuitemcheckbox`} aria-checked=${e.checked===void 0?R:String(e.checked)} aria-disabled=${e.disabled?`true`:R} tabindex="-1" @click=${()=>{e.disabled||(e.run(),e.keep||this.#Ir())}} > <span class="mark">${e.checked?be():R}</span>${e.icon?e.icon():R}${e.label} </button>`)} ${t<r?L`<div class="sep" role="separator"></div>`:R} `)} </div>`}#Hr=null;#Ur=!1;#Wr(e){return e.def.filterable===!1||e.def.render||e.def.actions||e.type===`component`?!1:!this.dataSource||!!e.def.filterOptions?.length}#Gr(e){if(e.def.filterOptions)return e.def.filterOptions;let t=/* @__PURE__ */ new Set,n=r=>{for(let a of r){t.add(i(e,e.accessor(a),a));let r=this.subRows?.(a);r?.length&&n(r)}};return n(Array.isArray(this.rows)?this.rows:[]),[...t]}#Kr(e){this.#Hr=e,this.#Ur=!0,this.requestUpdate()}#qr=e=>{e.stopPropagation();let t=this.#Hr,n=this.#G.byId.get(t),r=this.#Gr(n),i={...this.filter.values};r.every(t=>e.detail.value.includes(t))?delete i[t]:i[t]=e.detail.value,this.#Ur=!1,this.filter={...this.filter,values:i},this.emit(`sankhya-ds-filter-change`,{filter:this.filter,filterRow:this.filterRow}),this.#Pr(t)?.focus({preventScroll:!0})};#Jr=e=>{e.stopPropagation(),this.#Ur&&(this.#Ur=!1,this.requestUpdate(),this.#Pr(this.#Hr)?.focus({preventScroll:!0}))};#Yr(){let e=this.#Hr,t=e?this.#G.byId.get(e):void 0;if(!t)return R;rt();let n=this.renderRoot.querySelector(`[role="columnheader"][data-id="${CSS.escape(t.id)}"] .filter-anchor`);return L`<sankhya-ds-column-filter part="column-filter" column-label=${t.header} .options=${this.#Gr(t)} .value=${this.filter.values?.[t.id]??null} .anchor=${n} .open=${this.#Ur&&!!n} @sankhya-ds-apply=${this.#qr} @sankhya-ds-close=${this.#Jr} @sankhya-ds-change=${e=>e.stopPropagation()} @sankhya-ds-open=${e=>e.stopPropagation()} ></sankhya-ds-column-filter>`}#Xr=()=>{this.filter={...this.filter,values:{},columns:{}},this.emit(`sankhya-ds-filter-change`,{filter:this.filter,filterRow:this.filterRow})};#Zr(){return _(this.filter)&&!this.dataSource&&this.rows.length>0?L`<sankhya-ds-empty-state part="empty" mode="inline" icon=${this.emptyIcon||`search`} heading=${W(`Nenhum registro encontrado com esses filtros`)} description=${W(`Ajuste ou limpe os filtros.`)} action-label=${W(`Limpar filtros`)} action-type="clear" variant="no-results" @sankhya-ds-action=${e=>{e.stopPropagation(),this.#Xr()}} ></sankhya-ds-empty-state>`:L`<sankhya-ds-empty-state part="empty" mode="inline" icon=${this.emptyIcon||`search`} heading=${this.emptyHeading||W(`Nenhum registro encontrado`)} description=${this.emptyDescription} action-label=${this.emptyActionLabel} action-type=${this.emptyActionType} @sankhya-ds-action=${e=>{e.stopPropagation(),this.emit(`sankhya-ds-empty-action`)}} ></sankhya-ds-empty-state>`}#Qr(e,t){let n=this.#G.byId.get(e);if(!n.sortable)return;this.sort=he(this.sort,e,t);let r=this.sort.find(t=>t.id===e);this.#ze=W(r?G`Ordenado por ${n.header}, ${Ct(y(n.type)[+!!r.desc])}.`:`Ordenação removida.`),this.emit(`sankhya-ds-sort-change`,{sort:this.sort})}#$r(e=!1){this.allMatching=e;let t={selected:this.selected,allMatching:e};e&&(t.total=this.#ee?.total??this.selected.length,t.filter=this.filter,t.sort=this.sort),this.emit(`sankhya-ds-select`,t)}#ei(){return this.allMatching&&this.dataSource?Math.max(this.#ee?.total??0,this.selected.length):this.selected.length}#ti(){if(!this.allMatching||!this.dataSource)return;let e=new Set(this.selected),t=[];for(let n of this.#ee.loadedRows()){let r=n[this.rowKey];r!=null&&(e.has(String(r))||t.push(String(r)))}t.length&&(this.selected=[...this.selected,...t])}#ni(){this.allMatching=!0,this.#ti(),this.#$r(!0)}#ri(e){let t=new Set(this.selected);t.has(e)?t.delete(e):t.add(e),this.selected=[...t],this.#$r()}#ii(){let e=this.#Qt(),t=new Set(e),n=this.selected.filter(e=>!t.has(e));this.selected=this.#re===`all`?n:[...n,...e],this.#$r()}#ai(){let e=this.#in();return e?L`<div class="cell filler" aria-hidden="true" style=${K(`width:${e}px`)} ></div>`:R}#oi(e){return W(e===1?`1 registro selecionado`:G`${t(e,`number`)} registros selecionados`)}#si(){return this.renderRoot.querySelector(`.options-btn`)}#ci=e=>{for(let t of e.target.assignedElements({flatten:!0})){if(!yt.includes(t.tagName))continue;t.setAttribute(`size`,`sm`);let e=t.getAttribute(`variant`);e===`primary`?H(this,`toolbar-primary`,`a toolbar só aceita botões secondary (ACORDE): a ação primária da tela fica no cabeçalho. Correção: variant="secondary".`):e===`danger`&&H(this,`toolbar-danger`,`a toolbar e a barra de lote só aceitam botões secondary (V15): "Excluir" é secondary e fica por último; o vermelho fica no sankhya-ds-dialog de confirmação. Correção: variant="secondary".`)}this.#di(),this.#fi(),this.requestUpdate()};#li=()=>{this.#fi(),this.requestUpdate()};#ui(e){return e.localName===`sankhya-ds-circle-button`?``:e.localName===`sankhya-ds-split-button`||e.localName===`sankhya-ds-menu-button`?(e.getAttribute(`label`)??``).trim():(e.textContent??``).trim()}#di(){let e=/* @__PURE__ */ new Map;for(let t of this.querySelectorAll(`:scope > [slot="actions"], :scope > [slot="selection-actions"]`)){if(!yt.includes(t.tagName))continue;let n=this.#ui(t),r=n||t.getAttribute(`label`)||t.getAttribute(`aria-label`)||``;if(n||H(this,`toolbar-no-label:${r}`,`ação "${r||t.localName}" do slot "${t.slot}" sem rótulo (Y02): ações da tela e da seleção levam ícone e rótulo; só busca, Atualizar, Exportar, engrenagem e ⋯ ficam só com ícone. Correção: <sankhya-ds-button variant="secondary" icon="...">Rótulo</sankhya-ds-button>.`),!r)continue;let i=r.toLocaleLowerCase(`pt-BR`),a=e.get(i);a&&a!==t.slot?H(this,`toolbar-duplicate:${i}`,`a ação "${r}" está em "actions" e em "selection-actions" (Y06): ao selecionar, as duas somam e o rótulo aparece duas vezes. Correção: deixe a ação num slot só (a que depende de seleção vai em selection-actions).`):e.set(i,t.slot)}}#fi(){for(let e of this.querySelectorAll(`:scope > [data-scope]`)){let t=e.dataset.scope;(e.slot!==`selection-actions`&&e.slot!==`custom-actions`||t!==`one`&&t!==`many`)&&H(this,`data-scope:${e.slot}:${t}`,`data-scope="${t}" no slot "${e.slot}": data-scope vale "one" (um registro) ou "many" (um ou mais) em ações de selection-actions e em itens de custom-actions (⚡). Correção: ajuste o valor ou tire o atributo.`)}let e=this.#ei();for(let t of this.querySelectorAll(`:scope > [slot="selection-actions"], :scope > [slot="custom-actions"]`)){let{reason:n,hint:r}=this.#pi(t,e),i=t.dataset.sankhyaDsScopeOff!==void 0;if(n&&(i||!t.hasAttribute(`disabled`)))i||(t.dataset.sankhyaDsScopeOff=t.getAttribute(`disabled-reason`)??``,t.dataset.sankhyaDsScopeHint=t.getAttribute(`disabled-hint`)??``),t.setAttribute(`disabled`,``),t.setAttribute(`disabled-reason`,n),r&&t.setAttribute(`disabled-hint`,r);else if(!n&&i){let e=t.dataset.sankhyaDsScopeOff,n=t.dataset.sankhyaDsScopeHint??``;delete t.dataset.sankhyaDsScopeOff,delete t.dataset.sankhyaDsScopeHint,t.removeAttribute(`disabled`),e?t.setAttribute(`disabled-reason`,e):t.removeAttribute(`disabled-reason`),n?t.setAttribute(`disabled-hint`,n):t.removeAttribute(`disabled-hint`)}}}#pi(e,t){let n={reason:``,hint:``},r=e.dataset.scope;if(r!==`one`&&r!==`many`)return n;let i=e.slot===`custom-actions`,a=r===`one`&&t>1;if(!a&&(t>0||!i))return n;let o=i?(e.textContent??``).trim():this.#ui(e),s=/^.[A-Z]/.test(o)?o:Ct(o),c=W(a?s?G`Selecione só um registro para ${s}`:`Selecione só um registro`:s?G`Selecione um registro para ${s}`:`Selecione um registro`);return i?{reason:W(a?`Disponível com 1 registro`:`Nenhum registro selecionado`),hint:c}:{reason:c,hint:``}}#mi(){return this.#rn()||this.searchable||this.refreshable||this.exportable||this.#pe.test(`custom-actions`)||this.#pe.test(`more-actions`)||this.#pe.test(`actions`)||this.#pe.test(`selection-actions`)||this.#me.leaving}#hi(){let e=this.#rn(),t=this.selectable&&this.selected.length>0,n=this.#pe.test(`custom-actions`);return L`<div class="toolbar" part="toolbar" ?hidden=${this.#he.hidden}> ${this.#_i()} <div class="toolbar-actions${!t&&!this.#pe.test(`actions`)&&!this.#me.leavingFrom(`actions`)?` idle`:``}" > <div class="toolbar-mode${t?``:` off`}" ?inert=${!t}> <slot name="selection-actions" @slotchange=${this.#ci}></slot> </div> <slot name="actions" @slotchange=${this.#ci}></slot> </div> ${this.#gi(n,this.#Pi())} ${this.#gi(this.refreshable,L`<sankhya-ds-circle-button class="tool-btn" part="refresh-button" icon="sync" size="sm" variant="secondary" label=${W(`Atualizar`)} @click=${this.#xi} ></sankhya-ds-circle-button>`)} ${this.#gi(this.exportable,L`<sankhya-ds-circle-button class="tool-btn" part="export-button" icon="export" size="sm" variant="secondary" label=${W(`Exportar`)} @click=${this.#Si} ></sankhya-ds-circle-button>`)} ${this.#gi(e,L`<sankhya-ds-circle-button class="options-btn" part="options-button" icon="setting" size="sm" variant="secondary" label=${W(`Configurar grade`)} aria-haspopup="dialog" aria-expanded=${this.#Be?`true`:`false`} @click=${this.#sa} ></sankhya-ds-circle-button>`)} ${this.#Ki()} </div>`}#gi(e,t){return L`<div class="tool${e?` on`:``}" ?inert=${!e}>${t}</div>`}#_i(){let e=this.filter.query??``,t=this.#ie||!!e||!this.#ae;return L`<div class="toolbar-search tool sankhya-ds-swap${t?` open`:``}${this.searchable?` on`:``}" ?inert=${!this.searchable} > ${tt(t?`field`:`button`,()=>t?L`<sankhya-ds-search class="search-field" part="search" size="sm" aria-label=${W(`Buscar na grade`)} placeholder=${W(`Buscar`)} .value=${e} @sankhya-ds-search=${this.#yi} @focusout=${this.#bi} ></sankhya-ds-search>`:L`<sankhya-ds-circle-button class="search-btn" part="search-button" icon="search" size="sm" variant="secondary" label=${W(`Buscar`)} @click=${this.#vi} ></sankhya-ds-circle-button>`)} </div>`}#vi=()=>{this.#ie=!0,this.requestUpdate(),this.updateComplete.then(()=>{let e=this.renderRoot.querySelector(`.search-field:not([data-leaving])`);e?.updateComplete?.then(()=>e.focus())})};#yi=e=>{e.stopPropagation();let t=e.detail.value;(this.filter.query??``)!==t&&(this.filter={...this.filter,query:t},this.#Vt=!0,this.emit(`sankhya-ds-filter-change`,{filter:this.filter,filterRow:this.filterRow}))};#bi=e=>{let t=e.currentTarget;t.contains(e.relatedTarget)||t.value||(this.#ie=!1,this.requestUpdate())};#xi=()=>{this.emit(`sankhya-ds-refresh`,void 0,{cancelable:!0}).defaultPrevented||this.refresh()};#Si=()=>{this.emit(`sankhya-ds-export`,void 0,{cancelable:!0}).defaultPrevented||this.#Ti()};#Ci=!1;#wi=!1;async#Ti(){await at(),this.#Ci=!0,this.#wi=!0,this.requestUpdate()}#Ei(){let e=[],t=n=>{for(let r of n)e.push(r),t(this.#Q.children.get(r)??[])};return t(this.#Q.rows),e}#Di(){let e=this.querySelector(`:scope > [slot="pagination"]`),t=Number(e?.total)>0?Number(e.total):null,n=this.dataSource?null:this.#Ei().length;return{page:e&&n!==null?n:null,selected:this.selectable?this.#ei():null,filtered:t??(this.dataSource?this.#ee?.total??null:n)}}#Oi(){return(this.#q.order.length?this.#q.order:this.#G.leaves.map(e=>e.id)).flatMap(e=>{let t=this.#G.byId.get(e);return!t||t.def.actions||t.type===`component`?[]:[{key:e,label:a(t,this.#G.groups),hidden:this.#q.hidden.includes(e)}]})}#ki(){if(!this.#Ci)return R;let e=this.#wi?this.#Di():null;return L`<sankhya-ds-export-dialog class="export-dialog" part="export-dialog" .open=${this.#wi} .columns=${this.#wi?this.#Oi():[]} .pageCount=${e?.page??null} .selectedCount=${e?.selected??null} .filteredCount=${e?.filtered??null} .scope=${e?.selected?`selected`:`filtered`} .filename=${this.label} @sankhya-ds-export=${this.#ji} @sankhya-ds-open=${e=>e.stopPropagation()} @sankhya-ds-close=${this.#Ai} ></sankhya-ds-export-dialog>`}#Ai=e=>{e.stopPropagation(),this.#wi&&(this.#wi=!1,this.requestUpdate())};#ji=e=>{e.stopPropagation(),e.preventDefault();let{format:t,columns:n,filename:r,count:i}=e.detail,a=e.detail.scope===`all`?`filtered`:e.detail.scope,o={format:t,scope:a,columns:[...n],filename:r,count:i,selected:this.selected,allMatching:this.allMatching,filter:this.filter,sort:this.sort};if(this.emit(`sankhya-ds-request-export`,o,{cancelable:!0}).defaultPrevented)return;let s=this.#pe.test(`pagination`),c=!this.dataSource&&(a===`selected`||a===`page`||a===`filtered`&&!s);t!==`csv`||!c?H(this,`request-export:${t}:${a}`,`exportar ${t.toUpperCase()} (${a}) não é gerado pela grade: ela só gera CSV das linhas que tem na mão. Correção: trate sankhya-ds-request-export, chame preventDefault() e gere o arquivo (ex.: no servidor, com detail.filter e detail.sort).`):this.exportCsv({filename:r,columns:n,rows:a===`selected`?`selected`:`all`})};#Mi(){return[...this.querySelectorAll(`:scope > [slot="custom-actions"]`)]}#Ni=``;#Pi(){let e=this.#Mi().length>=Tt;return L`<sankhya-ds-dropdown-menu class="custom-menu" part="custom-actions" placement="bottom-start" label=${W(`Ações personalizadas`)} @sankhya-ds-select=${e=>this.#Xi(e,`custom`)} @sankhya-ds-open=${this.#Fi} @sankhya-ds-close=${this.#Ii} > <sankhya-ds-circle-button slot="trigger" class="custom-btn" part="custom-actions-button" @click=${this.#Ui} @keydown=${this.#Wi} icon="bolt" size="sm" variant="secondary" label=${W(`Ações personalizadas`)} shortcut="Ctrl+Alt+B" ></sankhya-ds-circle-button> ${e?L`<div class="custom-search" slot="header"> <sankhya-ds-search class="custom-search-field" part="custom-actions-search" size="sm" aria-label=${W(`Buscar ações personalizadas`)} placeholder=${W(`Buscar`)} .value=${this.#Ni} @sankhya-ds-search=${this.#Li} @sankhya-ds-input=${this.#Li} @sankhya-ds-change=${e=>e.stopPropagation()} @sankhya-ds-clear=${e=>e.stopPropagation()} @keydown=${this.#zi} ></sankhya-ds-search> <div class="sankhya-ds-swap custom-status" role="status"> ${tt(!!this.#Ni.trim()&&this.#Mi().every(e=>e.hidden),()=>L`<p class="custom-empty">${W(`Nenhuma ação encontrada`)}</p>`)} </div> </div>`:R} <slot name="custom-actions" @slotchange=${this.#li}></slot> </sankhya-ds-dropdown-menu>`}#Fi=e=>{e.stopPropagation();let t=this.renderRoot.querySelector(`.custom-search-field`);t&&t.updateComplete.then(()=>t.focus())};#Ii=e=>{e.stopPropagation(),this.#Ni&&this.#Ri(``)};#Li=e=>{e.stopPropagation(),this.#Ri(e.detail.value)};#Ri(e){this.#Ni=e;let t=g(e.trim());for(let e of this.#Mi()){let n=e.dataset.sankhyaDsSearchHidden!==void 0,r=!t||g(e.textContent??``).includes(t);!r&&!e.hidden?(e.dataset.sankhyaDsSearchHidden=``,e.hidden=!0):r&&n&&(delete e.dataset.sankhyaDsSearchHidden,e.hidden=!1)}this.requestUpdate()}#zi=e=>{let t=this.renderRoot.querySelector(`.custom-menu`);e.key===`ArrowDown`?(e.preventDefault(),this.#Mi().find(e=>!e.hidden)?.focus()):e.key===`Escape`&&!this.#Ni?(e.preventDefault(),t.hide()):e.key===`Tab`&&t.hide()};#Bi=()=>{Y()||Xe().catch(()=>void 0)};async#Vi(e){try{await Xe()}catch{return H(this,`menu-load`,`os menus da grade não carregaram (rede?). Tente de novo.`),!1}await customElements.whenDefined(`sankhya-ds-dropdown-menu`),await e.updateComplete;let t=document.activeElement;return e.isConnected&&(!t||t===document.body||this.matches(`:focus-within`))}async#Hi(e){await this.#Vi(e)&&e.show()}#Ui=e=>{Y()||this.#Hi(e.currentTarget.parentElement)};#Wi=e=>{e.key!==`ArrowDown`&&e.key!==`ArrowUp`||Y()||(e.preventDefault(),this.#Ui(e))};#Gi=e=>{if(!e.ctrlKey||!e.altKey||e.shiftKey||e.metaKey||e.getModifierState(`AltGraph`))return;if(e.code===`KeyL`){if(!this.#rn()||!this.optionItems.includes(`find-column`))return;e.preventDefault(),this.#Be||this.#sa(),this.updateComplete.then(()=>this.renderRoot.querySelector(`.options:not(.leaving) .find-input`)?.focus());return}if(e.code!==`KeyB`)return;let t=this.renderRoot.querySelector(`.tool.on > .custom-menu`);t&&(e.preventDefault(),Y()?t.show():this.#Hi(t))};#Ki(){let e=this.#pe.test(`more-actions`);return this.#gi(this.#le.length>0||e,L`<sankhya-ds-dropdown-menu class="overflow-menu" part="overflow" placement="bottom-end" label=${W(`Mais ações`)} @sankhya-ds-select=${this.#Yi} @sankhya-ds-open=${this.#Ji} @sankhya-ds-close=${e=>e.stopPropagation()} > <sankhya-ds-circle-button slot="trigger" class="overflow-btn" part="overflow-button" @click=${this.#Ui} @keydown=${this.#Wi} icon="ellipsis-h" size="sm" variant="secondary" label=${W(`Mais ações`)} ></sankhya-ds-circle-button> ${this.#le.map((e,t)=>this.#qi(e,t))} ${this.#le.length&&e?L`<hr class="overflow-divider" />`:R} <slot name="more-actions"></slot> </sankhya-ds-dropdown-menu>`)}#qi(e,t){let n=e.getAttribute(`label`)||e.textContent.trim(),r=e.localName===`sankhya-ds-split-button`?[...e.children].filter(e=>e.localName===`sankhya-ds-menu-item`):[];return L`<sankhya-ds-menu-item class="overflow-item" value=${`${bt}${t}`} icon=${e.getAttribute(`icon`)??``} ?disabled=${e.hasAttribute(`disabled`)} disabled-reason=${e.dataset.sankhyaDsScopeOff===void 0?e.getAttribute(`disabled-reason`)??``:W(`Disponível com 1 registro`)} disabled-hint=${e.dataset.sankhyaDsScopeOff===void 0?e.getAttribute(`disabled-hint`)??``:e.getAttribute(`disabled-reason`)??``} shortcut=${e.getAttribute(`shortcut`)??``} >${n}${r.length?L`<sankhya-ds-menu-item slot="submenu" class="overflow-sub" value=${`${bt}${t}:main`} icon=${e.getAttribute(`icon`)??``} >${n}</sankhya-ds-menu-item >${r.map((e,n)=>L`<sankhya-ds-menu-item slot="submenu" class="overflow-sub" value=${`${bt}${t}:${n}`} icon=${e.getAttribute(`icon`)??``} ?disabled=${e.hasAttribute(`disabled`)} disabled-reason=${e.getAttribute(`disabled-reason`)??``} disabled-hint=${e.getAttribute(`disabled-hint`)??``} ?divider=${n===0} >${e.text??e.textContent.trim()}</sankhya-ds-menu-item >`)}`:R}</sankhya-ds-menu-item >`}#Ji=async e=>{e.stopPropagation();let t=e.currentTarget;for(let e of wt)if(t.width=e,await t.updateComplete,!t.items.some(e=>e.truncated))return};#Yi=e=>{let{item:t,value:n}=e.detail;if(t.classList.contains(`overflow-item`)||t.classList.contains(`overflow-sub`)){e.stopPropagation();let[t,r]=n.slice(20).split(`:`),i=this.#le[Number(t)];if(!i)return;if(r===void 0||r===`main`){i.click();return}let a=[...i.children].filter(e=>e.localName===`sankhya-ds-menu-item`)[Number(r)];if(!a)return;i.dispatchEvent(new CustomEvent(`sankhya-ds-select`,{bubbles:!0,composed:!0,cancelable:!0,detail:{item:a,value:a.value||a.text||a.textContent.trim(),checked:!!a.checked}}))}else this.#Xi(e,`more`)};#Xi(e,t){e.stopPropagation(),this.emit(`sankhya-ds-action`,{item:e.detail.item,value:e.detail.value,source:t})}#Zi(){let e=this.renderRoot.querySelector(`.toolbar`),t=this.renderRoot.querySelector(`.toolbar-actions`);if(!e||!t||e.hidden)return;let n=this.renderRoot.querySelector(`.toolbar-search`),r=this.renderRoot.querySelector(`.search-field:not([data-leaving])`);if(r&&n){let e=parseFloat(getComputedStyle(n).minInlineSize);e>0&&(this.#ce=e)}let i=this.#ie||!!this.filter.query||(r?.matches(`:focus-within`)??!1),a=Ye(e),o=()=>e.getBoundingClientRect().right-parseFloat(getComputedStyle(e).paddingInlineEnd)*a,s=()=>[...e.children].some(e=>e.getBoundingClientRect().right>o()+a),c=()=>{let e=[...t.querySelectorAll(`slot`)].flatMap(e=>e.assignedElements({flatten:!0})).filter(e=>e.getClientRects().length).at(-1);return e?e.getBoundingClientRect().right>t.getBoundingClientRect().right+a:!1},l=()=>c()||s(),u=[...this.querySelectorAll(`[slot="actions"], [slot="selection-actions"]`)];for(let e of u)e.removeAttribute(`data-sankhya-ds-overflow`);let d=r&&n?n.getBoundingClientRect().width/a<this.#ce-1:!1;if(this.searchable&&!this.#ae&&!i&&(d||l())&&this.#Qi(!0))return;if(n?.querySelector(`[data-leaving]`)){clearTimeout(this.#se),this.#se=setTimeout(()=>this.requestUpdate(),St);return}let f=[...this.selectable&&this.selected.length>0?this.querySelectorAll(`:scope > [slot="selection-actions"]`):[],...this.querySelectorAll(`:scope > [slot="actions"]`)].filter(e=>!e.hidden),p=[];for(let e=f.length-1;e>=0&&l();e--)f[e].setAttribute(`data-sankhya-ds-overflow`,``),p.unshift(f[e]);if(this.searchable&&this.#ae&&!p.length&&n){let t=[...e.children].filter(e=>e.getClientRects().length),r=t.reduce((e,t)=>e+t.offsetWidth,0),i=Math.max(0,t.length-1)*xt,a=getComputedStyle(e);e.clientWidth-parseFloat(a.paddingInlineStart)-parseFloat(a.paddingInlineEnd)-r-i+n.offsetWidth>=this.#ce+xt&&this.#Qi(!1)}(p.length!==this.#le.length||p.some((e,t)=>e!==this.#le[t]))&&(this.#le=p,this.requestUpdate())}#Qi(e){return this.#oe>=Et?!1:(this.#oe++||requestAnimationFrame(()=>this.#oe=0),this.#ae=e,this.requestUpdate(),!0)}#$i(){if(!this.selectable)return R;let e=this.#ei(),n=e>1&&!this.#ta,r=n?e:this.#tt.get(`feedback`)?.value;if(!r)return R;if(n){if(this.dataSource){let t=this.#ee?.total??0;this.#ra=!this.allMatching&&t>1&&t>e?t:0}else{let e=this.#Qt(),t=new Set(this.selected);this.#ra=e.length>1&&e.some(e=>!t.has(e))?e.length:0}}let i=this.#ra;return L`<div class="feedback-area${n?``:` leaving`}" data-leave=${n?R:`feedback`} ?inert=${!n} > <div class="selection-feedback" part="selection-feedback"> <span class="feedback-text">${this.#oi(r)}</span> ${i?L`<button type="button" class="feedback-all" @click=${this.#ia}> ${W(G`Selecionar todos os ${t(i,`number`)} registros`)} </button>`:R} <button type="button" class="feedback-clear" @click=${this.#aa}> ${W(`Limpar seleção`)} </button> <sankhya-ds-circle-button class="feedback-close" icon="times" size="xs" variant="tertiary" label=${W(`Fechar`)} @click=${this.#oa} ></sankhya-ds-circle-button> </div> </div>`}#ea=!1;#ta=!1;#na=null;#ra=0;#ia=()=>{if(this.dataSource){this.#ni();return}let e=this.#Qt(),t=new Set(e);this.selected=[...this.selected.filter(e=>!t.has(e)),...e],this.#$r()};#aa=()=>{this.selected=[],this.#$r()};#oa=()=>{this.#ta=!0,this.#na=this.selected,this.requestUpdate(),this.#Nt(`feedback`,this.#ei())};#sa=()=>{this.#Be?this.#ca():(this.#Be=!0,this.#Ve=!0,this.emit(`sankhya-ds-configure`),this.#He=``,this.#Ue=0,this.requestUpdate())};#ca(e=!0){this.#Be=!1,At(this.renderRoot.querySelector(`.options:not(.leaving)`)),this.requestUpdate(),e&&this.#si()?.focus()}#la=e=>{e.newState===`closed`&&this.#Be&&(e.target.dataset.dismissed=``,this.#Be=!1,this.requestUpdate())};#ua(){let e=this.columnsLocked?this.#G.leaves.filter(e=>!this.#q.hidden.includes(e.id)):this.#G.leaves;return ie(e,this.#He)}#da(){if(!this.#Be)return R;let e=this.optionItems.includes(`find-column`),t=this.#ua(),n=Math.min(this.#Ue,t.length-1),r=this.#tn();return L`<div class="menu options" part="options" popover="auto" role="dialog" aria-label=${W(`Opções da grade`)} @beforetoggle=${this.#Ot} @toggle=${this.#la} @keydown=${this.#pa} > ${e?L`<div class="find-field"> ${j()} <input class="find-input" type="search" role="combobox" autocomplete="off" aria-label=${W(`Localizar coluna`)} aria-keyshortcuts="Control+Alt+L" placeholder=${W(`Localizar coluna… (Ctrl+Alt+L)`)} aria-autocomplete="list" aria-expanded=${t.length?`true`:`false`} aria-controls=${t.length?`find-list`:R} aria-activedescendant=${t.length?`find-${n}`:R} .value=${V(this.#He)} @input=${e=>{this.#He=e.target.value,this.#Ue=0,this.requestUpdate()}} /> </div> ${this.#He.trim()?t.length?L`<div id="find-list" class="find-list" role="listbox" aria-label=${W(`Colunas encontradas`)} > ${t.map((e,t)=>L`<div id="find-${t}" class="item${t===n?` active`:``}" role="option" aria-selected=${t===n?`true`:`false`} @pointerdown=${e=>e.preventDefault()} @click=${()=>this.#ma(e.id)} > <span class="text">${a(e,this.#G.groups)}</span>${this.#q.hidden.includes(e.id)?L`<span class="visually-hidden">, </span ><span class="hidden-mark">${W(`oculta`)}</span>`:R} </div>`)} </div>`:L`<div class="find-empty" role="status"> ${W(`Nenhuma coluna encontrada.`)} </div>`:R} ${r.length?L`<div class="sep" role="separator"></div>`:R}`:R} ${r.length?L`<div role="menu" aria-label=${W(`Opções da grade`)}> ${r.map(e=>L`<button type="button" class="item" role="menuitem" tabindex="-1" data-option=${e.id} @click=${()=>this.#fa(e.id,e.run)} > ${e.icon}<span class="text">${e.label}</span> </button>`)} </div>`:R} </div>`}#fa(e,t){let n=e===`search`&&!this.filterRow||e===`dynamic-mode`&&!this.dynamicMode;this.#ca(!n),t()}#pa=e=>{let t=e.currentTarget,n=e.target,r=[...t.querySelectorAll(`[role="menuitem"]`)],i=t.querySelector(`.find-input`),a=[...i?[i]:[],...r],o=a.indexOf(n),s=e=>a[(e+a.length)%a.length].focus();if(e.key===`Escape`||e.key===`Tab`)this.#ca();else if(n===i){let t=this.#ua(),n=Math.min(this.#Ue,t.length-1);if(e.key===`Enter`&&t.length)this.#ma(t[n].id);else if(e.key===`ArrowDown`&&t.length)this.#Ue=(n+1)%t.length,this.requestUpdate();else if(e.key===`ArrowUp`&&t.length)this.#Ue=(n||t.length)-1,this.requestUpdate();else if(e.key===`ArrowDown`&&r.length)r[0].focus();else if(e.key===`ArrowUp`&&r.length)r.at(-1).focus();else return}else if(e.key===`ArrowDown`)s(o+1);else if(e.key===`ArrowUp`)s(o-1);else if(e.key===`Home`)s(0);else if(e.key===`End`)s(a.length-1);else return;e.preventDefault(),e.stopPropagation()};#ma(e){this.#ca(!1),this.#q.hidden.includes(e)&&this.#Dt(D(this.#q,e,!1)),this.#We=e,document.removeEventListener(`pointerdown`,this.#Ge,!0),document.addEventListener(`pointerdown`,this.#Ge,!0),this.updateComplete.then(()=>{this.#jn(null),this.#hn({row:-1,col:this.#Se.findIndex(t=>t.id===e)})}),this.#ze=W(G`Coluna ${this.#G.byId.get(e).header} encontrada.`),this.requestUpdate()}#ha(e){if(this.filterRow=e,e)this.#lt=`.filter-input`;else{let e={...this.filter};delete e.columns,this.filter=e}this.emit(`sankhya-ds-filter-change`,{filter:this.filter,filterRow:e})}#ga(e,t){let n=!this.filterRow;return L`<div role="row" class="row filter-row${n?` leaving`:``}" aria-rowindex=${t} data-leave=${n?`filter-row`:R} ?inert=${n} > ${B(e,e=>e.col.id,e=>L`<div role="gridcell" class=${this.#oo(e,`filter-cell`)} style=${K(e.style)} aria-colindex=${e.index+1} > ${e.spec?L`<input class="filter-input" type="search" autocomplete="off" data-filter=${e.col.id} aria-label=${W(G`Buscar em ${e.spec.header}`)} .value=${V(this.filter.columns?.[e.col.id]??``)} @input=${this.#_a} />`:R} </div>`)}${this.#ai()} </div>`}#_a=e=>{let t=e.target,n={...this.filter.columns};t.value.trim()?n[t.dataset.filter]=t.value:delete n[t.dataset.filter],this.filter={...this.filter,columns:n},this.emit(`sankhya-ds-filter-change`,{filter:this.filter,filterRow:this.filterRow})};#va(e,t=!1){this.dynamicMode=e,e?this.#lt=`.panel-search`:t&&(this.#lt=`.options-btn`),this.emit(`sankhya-ds-dynamic-mode-change`,{dynamicMode:e})}#ya(){return!this.dataSource&&!this.subRows}#ba(){let e=!this.dynamicMode;if(e&&!this.#tt.has(`panel`))return R;let t=this.#q,n=t.order.flatMap(e=>this.#G.byId.get(e)??[]),r=this.#Ke.trim()?ie(n,this.#Ke):n,i=n.filter(e=>!t.hidden.includes(e.id)).length,a=(e,t,n,r)=>L`<section class="zone${this.#st===e?` over`:``}" aria-label=${t} data-zone=${e} @dragover=${this.#za} @dragleave=${this.#Ba} @drop=${this.#Va} > <div class="zone-title">${t}</div> ${r.length?L`<ul class="chips"> ${r} </ul>`:L`<p class="hint">${n}</p>`} </section>`,o=e=>this.#G.byId.get(e).header,s=(e,t)=>e?.target===t?e.after?` drop-after`:` drop-before`:``,c=(e,t)=>this.#qe===e&&this.#Je===t?`true`:`false`;return L`<aside class="panel${e?` leaving`:``}${this.#ot?` ease-size`:``}" part="panel" aria-label=${W(`Agrupar e totalizar`)} style=${K(this.#Qe?`--_panel-w:${this.#Qe}px`:R)} data-leave=${e?`panel`:R} ?inert=${e} @keydown=${this.#wa} > ${this.#ct||e?R:L`<div class="panel-resizer" role="separator" tabindex="0" aria-orientation="vertical" aria-label=${W(`Largura do painel Agrupar e totalizar`)} @keydown=${this.#ka} @pointerdown=${this.#Aa} @pointermove=${this.#ja} @pointerup=${this.#Ma} @lostpointercapture=${this.#Ma} ></div>`} <div class="panel-body"> <div class="panel-head"> <span class="panel-title">${W(`Agrupar e totalizar`)}</span> <button type="button" class="icon-btn" aria-label=${W(`Fechar painel Agrupar e totalizar`)} @click=${()=>this.#va(!1,!0)} > ${k()} </button> </div> <div class="find-field"> ${j()} <input class="panel-search" type="search" autocomplete="off" aria-label=${W(`Buscar coluna`)} placeholder=${W(`Buscar coluna`)} .value=${V(this.#Ke)} @input=${e=>{this.#Ke=e.target.value,this.requestUpdate()}} /> </div> <ul class="col-list" aria-label=${W(`Colunas`)}> ${B(r,e=>e.id,e=>{let n=!t.hidden.includes(e.id),r=n&&(!e.hideable||i<2),a=L`<span class="text" id=${`panel-text-${e.id}`} @pointerenter=${this.#Ln.check} >${e.header}</span >${this.#Ln.render(`panel-text-${e.id}`,e.header)}`,o=!this.columnsLocked||this.#ya()||this.#co(e);return L`<li class="col-item${s(this.#Xe,e.id)}" draggable="true" data-panel-id=${e.id} data-flip="move" data-key=${`col:${e.id}`} @dragstart=${this.#Na} @dragover=${this.#Pa} @drop=${this.#Fa} @dragend=${this.#Nr} > <span class="grip" aria-hidden="true">${Te()}</span> ${this.columnsLocked?L`<span class="col-label">${a}</span>`:L`<label class="col-label"> <input type="checkbox" class="check sankhya-ds-check" data-panel-id=${e.id} aria-describedby="panel-hint" aria-disabled=${r?`true`:R} .checked=${n} @click=${t=>{r?t.preventDefault():this.#Dt(D(this.#q,e.id,n))}} /> ${a} </label>`} ${o?L`<button type="button" class="icon-btn" data-panel-menu=${e.id} aria-label=${W(G`Ações da coluna ${e.header}`)} aria-haspopup="menu" aria-expanded=${c(e.id,`actions`)} @click=${()=>this.#Wa(e.id,`actions`)} > ${A()} </button>`:R} </li>`})} </ul> ${r.length?R:L`<p class="hint">${W(`Nenhuma coluna encontrada.`)}</p>`} <p id="panel-hint" class="visually-hidden"> ${W(`Alt+seta para cima ou para baixo muda a posição da coluna.`)} </p> <p id="group-hint" class="visually-hidden"> ${W(`Alt+seta para cima ou para baixo muda a ordem dos agrupamentos.`)} </p> ${this.#ya()?a(`group`,W(`Agrupamentos`),W(`Arraste as colunas até aqui para criar grupos`),t.groupBy.map((e,n)=>L`<li class="chip${s(this.#Ze,e)}" draggable="true" tabindex="0" data-group-id=${e} data-flip="exit" data-key=${`group:${e}`} aria-label=${W(G`Agrupamento ${n+1} de ${t.groupBy.length}: ${o(e)}`)} aria-describedby="group-hint" @dragstart=${this.#Ia} @dragover=${this.#La} @drop=${this.#Ra} @dragend=${this.#Nr} > <span class="grip" aria-hidden="true">${Te()}</span> <span class="text" id=${`group-text-${e}`} @pointerenter=${this.#Ln.check} >${o(e)}</span >${this.#Ln.render(`group-text-${e}`,o(e))} <button type="button" class="icon-btn" aria-label=${W(G`Remover agrupamento por ${o(e)}`)} @click=${()=>this.#Dt(ue(this.#q,e,!1))} > ${k()} </button> </li>`)):R} ${this.dataSource?R:a(`aggregate`,W(`Colunas totalizadas`),W(`Arraste as colunas numéricas até aqui para totalizar`),Object.entries(t.aggregates??{}).map(([e,t])=>{let n=this.#Sa(t,o(e));return L`<li class="chip" data-flip="exit" data-key=${`agg:${e}`}> <button type="button" class="chip-btn" id=${`agg-chip-${e}`} data-agg-menu=${e} @pointerenter=${this.#Ln.check} @focusin=${this.#Ln.check} aria-haspopup="menu" aria-expanded=${c(e,`aggregate`)} @click=${()=>this.#Wa(e,`aggregate`)} > <span class="text" data-cut>${n}</span>${xe()}</button >${this.#Ln.render(`agg-chip-${e}`,n)} <button type="button" class="icon-btn" aria-label=${W(G`Remover total de ${o(e)}`)} @click=${()=>this.#Dt(ce(this.#q,e,null))} > ${k()} </button> </li>`}))} </div> </aside>`}#xa(e){return{sum:W(`Soma`),avg:W(`Média`),min:W(`Mínimo`),max:W(`Máximo`),count:W(`Contagem`),first:W(`Primeiro`),last:W(`Último`)}[e]}#Sa(e,t){return W(G`${this.#xa(e)} (${t})`)}#Ca(e){let t=this.#et&&!this.dataSource?e.def.aggregate:void 0;return t?this.#Sa(t,e.header):e.header}#wa=e=>{let t=e.target,{panelId:n,groupId:r}=t.dataset,i=e.key===`ArrowUp`?-1:+(e.key===`ArrowDown`);(n||r)&&e.altKey&&i?(e.preventDefault(),n?this.#Ta(n,i):this.#Ea(r,i)):e.key===`Escape`&&(e.preventDefault(),t.matches(`.panel-search`)&&this.#Ke?(this.#Ke=``,this.requestUpdate()):this.#va(!1,!0))};#Ta(e,t){if(this.columnsLocked)return;let n=oe(this.#q,e,t);if(!n)return;this.#Dt(E(this.#q,e,n,t>0));let r=this.#q.order.indexOf(e)+1;this.#ze=W(G`${this.#G.byId.get(e).header}: posição ${r} de ${this.#q.order.length}.`),this.#lt=`.col-item[data-panel-id="${CSS.escape(e)}"] .check`}#Ea(e,t){let n=le(this.#q,e,t);if(n===this.#q)return;this.#Dt(n);let{groupBy:r}=this.#q,i=this.#G.byId.get(e).header;this.#ze=W(G`Agrupamento por ${i}: nível ${r.indexOf(e)+1} de ${r.length}.`),this.#lt=`.chip[data-group-id="${CSS.escape(e)}"]`}#Da(){let e=this.renderRoot.querySelector(`.panel:not(.leaving)`),t=getComputedStyle(e),n=Math.round(parseFloat(t.minInlineSize)),r=e.parentElement.clientWidth-n;return{min:n,max:Math.max(n,Math.round(Math.min(parseFloat(t.maxInlineSize),r)))}}#Oa(e){let{min:t,max:n}=this.#Da();this.#Qe=Math.max(t,Math.min(n,Math.round(e))),this.requestUpdate()}#ka=e=>{let t=e.currentTarget.parentElement.offsetWidth,{min:n,max:r}=this.#Da(),i={ArrowLeft:t+jt,ArrowRight:t-jt,Home:n,End:r}[e.key];i!==void 0&&(e.preventDefault(),e.stopPropagation(),this.#ot=!0,this.#Oa(i))};#Aa=e=>{let t=e.currentTarget;e.preventDefault(),t.setPointerCapture(e.pointerId),this.#ot=!1,this.#$e={x:e.clientX,width:t.parentElement.offsetWidth}};#ja=e=>{this.#$e&&this.#Oa(this.#$e.width+this.#$e.x-e.clientX)};#Ma=()=>{this.#$e=null};#Na=e=>{let t=e.currentTarget.dataset.panelId;this.#Ae={id:t},e.dataTransfer?.setData(`text/plain`,t)};#Pa=e=>{let t=e.currentTarget;if(!this.#Ae||this.#Ae.from||this.columnsLocked)return;e.preventDefault();let n=t.getBoundingClientRect(),r={target:t.dataset.panelId,after:e.clientY>n.top+n.height/2};JSON.stringify(r)!==JSON.stringify(this.#Xe)&&(this.#Xe=r,this.requestUpdate())};#Fa=e=>{let t=this.#Ae,n=this.#Xe;this.#Nr(),t&&n&&(e.preventDefault(),this.#Dt(E(this.#q,t.id,n.target,n.after)))};#Ia=e=>{let t=e.currentTarget.dataset.groupId;this.#Ae={id:t,from:`group`},e.dataTransfer?.setData(`text/plain`,t)};#La=e=>{let t=e.currentTarget;if(!this.#Ae)return;let n=t.getBoundingClientRect(),r={target:t.dataset.groupId,after:e.clientY>n.top+n.height/2};JSON.stringify(r)!==JSON.stringify(this.#Ze)&&(this.#Ze=r,this.requestUpdate())};#Ra=e=>{let t=this.#Ae,n=this.#Ze;this.#Nr(),t&&n&&(e.preventDefault(),this.#Dt(ae(this.#q,t.id,n.target,n.after)))};#za=e=>{let t=e.currentTarget.dataset.zone;!this.#Ae||this.#Ae.from&&t!==`group`||(e.preventDefault(),this.#st!==t&&(this.#st=t,this.requestUpdate()))};#Ba=e=>{e.currentTarget.contains(e.relatedTarget)||(this.#st=null,this.requestUpdate())};#Va=e=>{let t=this.#Ae,n=e.currentTarget.dataset.zone;this.#Nr(),t&&!t.from&&(e.preventDefault(),n===`group`?this.#q.groupBy.includes(t.id)||this.#Ha(t.id):this.#q.aggregates?.[t.id]||this.#Ua(t.id))};#Ha(e){this.#Dt(ue(this.#q,e,!this.#q.groupBy.includes(e)))}#Ua(e){let t=this.#G.byId.get(e);if(!t.numeric){this.#ze=W(G`${t.header}: só colunas numéricas podem ser agregadas.`),this.requestUpdate();return}let n=!this.#q.aggregates?.[e];this.#Dt(ce(this.#q,e,n?`sum`:null))}#Wa(e,t){this.#qe=e,this.#Je=t,this.#Ye=!0,this.requestUpdate()}#Ga(){return`[${this.#Je===`aggregate`?`data-agg-menu`:`data-panel-menu`}="${CSS.escape(this.#qe)}"]`}#Ka(e=!0){let t=this.#Ga();this.#qe=null,At(this.renderRoot.querySelector(`.panel-menu:not(.leaving)`)),this.requestUpdate(),e&&(this.#lt=t)}#qa=e=>{e.newState===`closed`&&this.#qe&&(e.target.dataset.dismissed=``,this.#qe=null,this.requestUpdate())};#Ja(e){let t=this.#q.aggregates?.[e];return ne.map(n=>({label:this.#xa(n),radio:!0,checked:n===t,run:()=>this.#Dt(ce(this.#q,e,n))}))}#Ya(){let e=this.#qe;if(!e||!this.dynamicMode)return R;let t=this.#G.byId.get(e),n=this.#q,r=[],i=W(G`Ações da coluna ${t.header}`);if(this.#Je===`aggregate`)i=W(G`Função de agregação de ${t.header}`),r.push({items:this.#Ja(e)});else{let i=this.columnsLocked?[]:[{label:W(`Mover para cima`),disabled:!oe(n,e,-1),run:()=>this.#Ta(e,-1)},{label:W(`Mover para baixo`),disabled:!oe(n,e,1),run:()=>this.#Ta(e,1)}];this.#ya()&&i.push({label:n.groupBy.includes(e)?W(`Desagrupar`):W(`Agrupar por esta coluna`),run:()=>this.#Ha(e)});let a=this.#co(t),o=a&&!!n.aggregates?.[e];a&&i.push({label:W(o?`Remover total`:`Totalizar (soma)`),run:()=>this.#Ua(e)}),r.push({items:i}),o&&r.push({label:W(`Função de agregação`),items:this.#Ja(e)})}return L`<div class="menu panel-menu" part="menu" popover="auto" role="menu" aria-label=${i} @beforetoggle=${this.#Ot} @toggle=${this.#qa} @keydown=${this.#Rr} > ${r.map((e,t)=>L` ${t?L`<div class="sep" role="separator"></div>`:R} ${e.label?L`<div class="menu-label" role="presentation">${e.label}</div>`:R} ${e.items.map(e=>L`<button type="button" class="item" role=${e.radio?`menuitemradio`:`menuitem`} aria-checked=${e.radio?String(e.checked):R} aria-disabled=${e.disabled?`true`:R} tabindex="-1" @click=${()=>{e.disabled||(this.#Ka(),e.run())}} > <span class="mark">${e.checked?be():R}</span>${e.label} </button>`)} `)} </div>`}#Xa(e,t,n){let r=this.getBoundingClientRect(),i=Math.max(0,r.left),a=Math.min(innerWidth,r.right);a-i<t&&([i,a]=[0,innerWidth]);let o=n?e.right-t:e.left;return!n&&o+t>a&&(o=e.right-t),n&&o<i&&(o=e.left),Math.max(i,Math.min(o,a-t))}#Za(e,t,n){delete e.dataset.dismissed,delete e.dataset.ghosted,e.showPopover(),window.addEventListener(`blur`,this.#kt),e.style.left=`${this.#Xa(t,e.offsetWidth,n)}px`;let r=e.offsetHeight,i=t.bottom+r>innerHeight&&t.top-r>=0?t.top-r:t.bottom;e.style.top=`${Math.max(0,Math.min(i,innerHeight-r))}px`,e.querySelector(`input, [role^="menuitem"]:not([aria-disabled="true"])`)?.focus()}#Qa(e,t,n){this.#dt&&this.#dt.view.id!==e.id&&this.#$a(),this.#dt??={index:e.index,view:e,values:/* @__PURE__ */ new Map},Object.is(t.accessor(e.data),n)?this.#dt.values.delete(t.id):this.#dt.values.set(t.id,n),this.requestUpdate()}#$a(){let e=this.#dt;if(!e)return;this.#dt=null,this.requestUpdate();let t=e.view.data,n=[...e.values].map(([e,n])=>({columnId:e,value:n,previousValue:this.#G.byId.get(e).accessor(t)}));n.length&&(this.emit(`sankhya-ds-row-commit`,{rowId:e.view.id,row:t,changes:n},{cancelable:!0}).defaultPrevented||this.#Wn(n.map(t=>({row:e.view,spec:this.#G.byId.get(t.columnId),value:t.value}))))}#eo(){this.#dt&&(this.#dt=null,this.#ze=W(`Alterações da linha descartadas.`),this.requestUpdate())}#to(e,t,n){let r=this.#uo(e),i=n?-1:1;for(let e=t+i;e>=0&&e<this.#Se.length;e+=i){let t=this.#G.byId.get(this.#Se[e].id);if(t&&this.#Hn(r,t))return e}return-1}#no=e=>{if(!this.#dt||this.#Fe)return;let t=e.relatedTarget?.closest?.(`[data-row]`);t&&Number(t.dataset.row)===this.#dt.index||this.#$a()};#ro(){let e=[],t=(t,n,r,i,a)=>{let o=t.getSize();e.push({col:t,spec:this.#G.byId.get(t.id),index:n,width:o,region:r,offset:i,style:gt(o,r,i),cls:a})},n=0;this.#ye.forEach((e,r)=>{t(e,r,`start`,n,`pin-start${r===this.#ye.length-1?` edge`:``}`),n+=e.getSize()});let r=n;for(let e of this.#we.getVirtualItems())t(this.#be[e.index],this.#ye.length+e.index,`center`,e.start-r,``),r=e.end;this.#Ce=`${this.#we.range?.startIndex}:${this.#we.range?.endIndex}`;let i=Q(this.#xe),a=this.#ye.length+this.#be.length;return this.#xe.forEach((e,n)=>{i-=e.getSize(),t(e,a+n,`end`,i,`pin-end${n===0?` edge first`:``}`)}),e}#io(e){let t=[];for(let n=0;n<this.#G.depth-1;n++){let r=[];for(let t of e){let e=t.spec?.path[n]??``,i=r.at(-1);e&&i?.id===e&&i.slots[0].region===t.region&&(t.region!==`center`||t.offset===0)?i.slots.push(t):r.push({id:e,slots:[t]})}t.push(L`<div role="row" class="row" aria-rowindex=${n+1}> ${r.map(({id:e,slots:t})=>{let n=t[0],r=t.at(-1),i=t.reduce((e,t)=>e+t.width,0),a=n.region===`end`?r.offset:n.offset,o=n.region===`start`?r.cls:n.cls;return L`<div role="columnheader" class="cell head group-head ${o}${e?``:` placeholder`}" style=${K(gt(i,n.region,a))} aria-colindex=${n.index+1} aria-colspan=${t.length} > ${e?L`<span class="label">${this.#G.groups.get(e).header}</span>`:R} </div>`})}${this.#ai()} </div>`)}return t}#ao(e,t){return e===this.#Le.row&&t===this.#Le.col?`0`:`-1`}#oo(e,t){let n=e.spec,r=` align-${n?.align??`center`}${n?.numeric?` num`:``}`,i=this.#so&&e.index===this.#Se.length-1?` last-col`:``;return`cell ${t} ${e.cls}${r}${n?.def.divider?` divider`:``}${i}`}#so=!0;#co(e){return!this.dataSource&&e.numeric}#lo(e){let t=e.col.id;if(t===`__select`)return this.dataSource?L`<div role="columnheader" class=${this.#oo(e,`head select-cell`)} style=${K(e.style)} aria-colindex=${e.index+1} aria-label=${W(`Seleção`)} tabindex=${this.#ao(-1,e.index)} data-row="-1" data-col=${e.index} data-id=${t} ></div>`:L`<div role="columnheader" class=${this.#oo(e,`head select-cell`)} style=${K(e.style)} aria-colindex=${e.index+1} tabindex=${this.#ao(-1,e.index)} data-row="-1" data-col=${e.index} data-id=${t} > <input type="checkbox" class="check sankhya-ds-check" tabindex="-1" aria-label=${W(`Selecionar todas as linhas`)} .checked=${this.#re===`all`} .indeterminate=${this.#re===`some`} @change=${()=>this.#ii()} /> </div>`;let n=e.spec,r=this.sort.findIndex(e=>e.id===t),i=this.sort[r],a=this.#Ae?.target===t?this.#Ae.after?` drop-after`:` drop-before`:``,o=this.#Ca(n),s=this.#cr(e.index);return L`<div role="columnheader" class=${this.#oo(e,`head${n.sortable?` sortable`:``}${a}${this.#We===t?` flash`:``}${s?` col-selected`:``}`)} style=${K(e.style)} aria-colindex=${e.index+1} aria-sort=${i?i.desc?`descending`:`ascending`:R} aria-selected=${this.columnSelect?String(s):R} tabindex=${this.#ao(-1,e.index)} draggable="true" id=${`head-${e.index}`} data-row="-1" data-col=${e.index} data-id=${t} @dragstart=${this.#Ar} @pointerenter=${this.#In} @focusin=${this.#In} > <span class="head-main"> <span class="label" data-cut>${o}</span> ${i?i.desc?ve():ye():R} ${i&&this.sort.length>1?L`<span class="sort-index" aria-hidden="true">${r+1}</span>`:R} ${this.filter.values?.[t]?L`<button type="button" class="filter-btn" id=${`filter-mark-${t}`} data-tip="always" tabindex="-1" aria-label=${W(G`Filtro ativo em ${n.header}`)} @pointerenter=${this.#Ln.check} > ${we(`filter-mark`)}</button >${this.#Ln.render(`filter-mark-${t}`,W(G`Filtro ativo em ${n.header}`))}`:R} </span> ${!this.columnsLocked||this.#Br(t).length?L`<button type="button" class="menu-btn" tabindex="-1" aria-haspopup="menu" aria-expanded=${this.#Oe===t?`true`:`false`} aria-label=${W(G`Opções da coluna ${n.header}`)} > ${A()} </button>`:R} <span class="filter-anchor" aria-hidden="true"></span> ${n.resizable?L`<span class="resizer" aria-hidden="true" @pointerdown=${this.#pr} @pointermove=${this.#mr} @pointerup=${this.#hr} @lostpointercapture=${this.#hr} @dblclick=${this.#gr} ></span>`:R} </div>`}#uo(e){if(this.dataSource){let t=this.#ee.get(e),n=t&&t[this.rowKey];return{index:e,id:String(n??e),data:t,tan:void 0,depth:0,group:!1,kind:t&&this.rowKind?.(t),status:t&&this.#do(t),canExpand:!1,expanded:!1}}let t=this.#$[e],n=t.getIsGrouped(),r=t.original;return{index:e,id:t.id,data:r,tan:t,depth:t.depth,group:n,kind:n?void 0:this.rowKind?.(r),status:n?void 0:this.#do(r),canExpand:t.getCanExpand(),expanded:t.getIsExpanded()}}#do(e){let t=this.rowStatus?.(e);return t===`negative`?(Ie(this,`rowStatus "negative"`,{...Pe,replacement:`"danger"`,ref:`vocabulário semântico, T13`}),`danger`):t}#fo(e,t,n){let r=this.#uo(e),i=this.#ne.has(r.id),a=this.#On(),o=r.kind?` kind-${r.kind}`:``,s=r.status?` status-${r.status}`:``,c=!!this.#it?.ids.has(r.id),l=`${this.#nt.has(r.id)?` row-in`:``}${c?` row-out`:``}`,u=this.#it?.row.id!==r.id&&r.expanded;return L`<div role="row" aria-hidden=${c?`true`:R} ?inert=${c} class="row${r.index%2&&!this.noStripes?` odd`:``}${r.index===this.rowCount-1?` last`:``}${r.group?` group-row`:``}${o}${s}${l}" style=${K(n)} data-row-key=${r.id} aria-rowindex=${e+this.#$t()+1} aria-selected=${this.selectable&&!r.group?String(i):R} aria-level=${a?r.depth+1:R} aria-expanded=${a&&r.canExpand?String(u):R} > ${B(t,e=>e.col.id,e=>this.#po(r,e,i))}${this.#ai()} </div>`}#po(e,n,r){let a=n.col.id,o=this.#Fe,s=o?.row===e.index&&o.col===n.index,c=S(this.#Ne,e.index,n.index),l,u=`${c?`in-range`:``}${s?` editing`:``}${s&&o.error?` invalid`:``}`;if(s)l=this.#tr(o);else if(!e.data)l=L`<span class="skeleton" aria-hidden="true"></span>`;else if(e.group)l=this.#Ro(e,a,n.spec);else if(a===`__select`)u+=` select-cell`,l=L`<input type="checkbox" class="check sankhya-ds-check" tabindex="-1" aria-label=${W(`Selecionar linha`)} .checked=${r} @change=${()=>this.#ri(e.id)} />`;else{let r=n.spec,o=this.#dt?.view.id===e.id?this.#dt.values:void 0,s=o?.has(a)?o.get(a):e.tan?e.tan.getValue(a):r.accessor(e.data);if(o?.has(a)&&(u+=` pending`),r.def.actions)u+=` visual actions-cell`,l=this.#xo(e,r);else if(r.def.render)u+=` visual`,l=this.#mo(e.data,r,s);else if(r.type===`boolean`){u+=` visual`;let t=!r.def.editor&&this.#Hn(e,r);l=L`<input type="checkbox" class="check sankhya-ds-check" tabindex="-1" ?disabled=${!t} aria-label=${r.header} .checked=${V(!!s)} @change=${t=>this.#qn(e,r,t.target.checked)} />`}else l=e.kind===`percent`&&r.numeric?t(s,`percent`,r.def):i(r,s,e.data)}let d=a===this.#Dn();if(d&&e.kind&&e.kind!==`percent`){let t=e.kind===`subtotal`?`(=) `:`(-) `;String(l).startsWith(t.trim())||(l=`${t}${l}`)}if(d&&e.status){let t=e.status===`warning`?W(`Atenção:`):W(`Crítico:`);l=L`<span class="visually-hidden">${t} </span>${l}`}return this.#On()&&d&&(l=L`<span class="tree" style=${K(`--_depth:${e.depth}`)}> <span class="toggle${e.expanded?` open`:``}" aria-hidden="true"> ${e.canExpand?Se():R} </span> <span class="text">${l}</span> </span>`),L`<div role="gridcell" class=${this.#oo(n,u)} style=${K(n.style)} aria-colindex=${n.index+1} aria-selected=${c?`true`:R} tabindex=${this.#ao(e.index,n.index)} id=${`cell-${e.index}-${n.index}`} data-row=${e.index} data-col=${n.index} > ${l} </div>`}#mo(e,t,n){let r=t.def.render,i=this.#ho.get(e),a=i?.get(t.id);if(a&&a.render===r&&Object.is(a.value,n))return a.node;let o=r(n,e);return o instanceof Node?(i||this.#ho.set(e,i=/* @__PURE__ */ new Map),i.set(t.id,{render:r,value:n,node:o})):i?.delete(t.id),o}#ho=/* @__PURE__ */ new WeakMap;#go=null;#_o;#vo=!1;#yo(e,t){let n=e.data,r=t.def.actions.filter(e=>!Z(e.hidden,n));return[...r.filter(e=>e.variant!==`danger`),...r.filter(e=>e.variant===`danger`)]}#bo(e){let t=this.#Se.map(e=>e.id===`__select`?void 0:this.#G.byId.get(e.id)).find(e=>e&&!e.def.actions),n=e.data,r=(t&&n&&!t.def.render?i(t,t.accessor(n),n):``).trim()||String(e.index+1);return W(G`Ações da linha ${r}`)}#xo(e,t){return this.#yo(e,t).length?L`<button type="button" class="row-menu-btn" part="row-menu-button" tabindex="-1" aria-haspopup="menu" aria-expanded="false" aria-label=${this.#bo(e)} @pointerdown=${this.#Co} @focus=${this.#Co} @click=${this.#wo} > ${A()} </button>`:R}#So(e){let t=this.#Mn(e);return{button:e,row:this.#uo(t.row),spec:this.#G.byId.get(this.#Se[t.col].id)}}#Co=e=>{let t=e.currentTarget;if(this.#go?.button===t)return;let n=this.#So(t);this.#vo?this.#_o={target:n,show:this.#_o?.show??!1}:(this.#go=n,this.requestUpdate())};#wo=async e=>{let t=e.currentTarget,n=this.#Mo();if(n.anchor===t&&this.#go?.button===t&&!this.#_o)return;e.stopImmediatePropagation();let r=this.#So(t);this.#vo?(this.#_o={target:r,show:!0},n.hide()):(this.#go=r,this.requestUpdate(),await this.#To(n))};async#To(e){if(await this.updateComplete,!Y()&&!await this.#Vi(e))return;await e.updateComplete;let t=this.#go;t?.button.isConnected&&(t.point?e.showAt(t.point.x,t.point.y):e.show())}#Eo=e=>{let t=this.#Oo(e.target);if(!t)return;e.preventDefault();let n=e.button!==2&&e.clientX===0&&e.clientY===0;this.#jo(t,n?this.#Ao(t):{x:e.clientX,y:e.clientY})};#Do(e){if(!(e.shiftKey&&e.key===`F10`||e.key===`ContextMenu`))return!1;let t=this.#Oo(e.target);return t?(this.#jo(t,this.#Ao(t)),!0):!1}#Oo(e){if(this.#Fe||!(e instanceof Element)||e.closest(`input, textarea, select, a[href], [contenteditable=""], [contenteditable="true"]`))return null;let t=e.closest(`[role="gridcell"][data-row]`);return!t||t.classList.contains(`select-cell`)?null:this.#ko(this.#uo(Number(t.dataset.row)))?t:null}#ko(e){if(!e.group&&e.data)return this.#Se.map(e=>this.#G.byId.get(e.id)).find(t=>t?.def.actions&&this.#yo(e,t).length)}#Ao(e){let t=e.getBoundingClientRect();return{x:t.left,y:t.bottom}}async#jo(e,t){let n=this.#Mo(),r=this.#uo(Number(e.dataset.row)),i={button:e,row:r,spec:this.#ko(r),point:t};if(this.#vo){let e=this.#go;if(n.open&&e?.point&&e.row.data===r.data&&!this.#_o){this.#go=i,n.showAt(t.x,t.y);return}this.#_o={target:i,show:!0},n.hide()}else this.#go=i,this.requestUpdate(),await this.#To(n)}#Mo(){return this.renderRoot.querySelector(`.row-menu`)}#No=e=>{e.stopPropagation(),this.#vo=!0};#Po=e=>{e.stopPropagation();let t=e.currentTarget;M(t.shadowRoot.querySelector(`.panel`),()=>{if(t.open)return;this.#vo=!1;let e=this.#_o;e&&(this.#_o=void 0,this.#go=e.target,this.requestUpdate(),e.show&&this.#To(t))})};#Fo(e){let t=this.#go;if(!t||this.#_o?.target===null)return;let n=t.button.isConnected?this.#Mn(t.button):null;if(!(!n||[`rows`,`sort`,`filter`,`dataSource`,`columns`].some(t=>e.has(t))||n.row<this.#ve.start||n.row>=this.#ve.end||this.#uo(n.row).data!==t.row.data))return;let r=this.#Mo();this.#vo?(this.#_o={target:null,show:!1},r?.hide()):queueMicrotask(()=>{this.#go===t&&(this.#go=null,this.requestUpdate())})}#Io=e=>{e.stopPropagation();let{row:t,spec:n}=this.#go;this.emit(`sankhya-ds-row-action`,{action:e.detail.value,row:t.data,rowId:t.id,columnId:n.id})};#Lo(){if(!this.#G.leaves.some(e=>e.def.actions))return R;let e=this.#go,t=e?.row.data,n=e?this.#yo(e.row,e.spec):[],r=n.findIndex(e=>e.variant===`danger`);return L`<sankhya-ds-dropdown-menu class="row-menu" part="row-menu" placement="bottom-end" label=${e?this.#bo(e.row):W(`Ações da linha`)} no-trigger .anchorElement=${e&&!e.point?e.button:null} @sankhya-ds-select=${this.#Io} @sankhya-ds-open=${this.#No} @sankhya-ds-close=${this.#Po} > ${B(n,e=>e.id,(e,n)=>{let i=!!Z(e.disabled,t);return L`<sankhya-ds-menu-item value=${e.id} icon=${e.icon??``} variant=${e.variant??`default`} ?divider=${n>0&&n===r} ?disabled=${i} disabled-reason=${i?Z(e.disabledReason,t)??``:``} disabled-hint=${i?Z(e.disabledHint,t)??``:``} >${e.label}</sankhya-ds-menu-item >`})} </sankhya-ds-dropdown-menu>`}#Ro(e,t,n){let r=e.tan;if(t===this.#Dn()){let t=this.#G.byId.get(r.groupingColumnId),n=i(t,r.groupingValue,e.data),a=r.leafRows.length;return`${t.header}: ${n} (${a})`}return n?.def.aggregate?this.#zo(n,r.getValue(n.id)):``}#zo(e,n){return e.def.aggregate===`count`?t(n,`number`):i(e,n,{})}#Bo(e,t,n){let r=this.dataSource?this.#ee.totals:void 0,i=this.#Dn();return L`<div class="footer" part="footer" role="rowgroup" style=${K(t)}> <div role="row" class="row" aria-rowindex=${n}> ${B(e,e=>e.col.id,e=>{let t=e.spec,n=``;if(t?.def.aggregate){let e=this.dataSource?r?.[t.id]:this.#K.getColumn(t.id).getAggregationValue();n=this.#zo(t,e)}else e.col.id===i&&(n=W(`Total`));return L`<div role="gridcell" class=${this.#oo(e,``)} style=${K(e.style)} aria-colindex=${e.index+1} > ${n} </div>`})}${this.#ai()} </div> </div>`}#Vo(e,t,n){let i=e%2&&!this.noStripes?` odd`:``,a=t.filter(e=>e.col.id!==r);return L`<div role="row" class="row${i}${e===n-1?` last`:``}" aria-rowindex=${e+this.#$t()+1} > ${t.map(e=>{let t=a.indexOf(e),n=e.col.id===`__select`?` box`:t===0?` first`:t%3==0?` third`:``;return L`<div role="gridcell" class=${this.#oo(e,e.col.id===`__select`?`select-cell`:``)} style=${K(e.style)} aria-colindex=${e.index+1} > <span class="skeleton${n}" aria-hidden="true"></span> </div>`})}${this.#ai()} </div>`}render(){let e=this.#ro(),t=this.getSelectedRange();this.#Ne=t&&(t.start.row!==t.end.row||t.start.col!==t.end.col)?t:null;let n=this.#in();this.#so=n===0;let r=`width:${this.#K.getTotalSize()+n}px`,i=this.#ve,a=this.rowCount,o=(this.dataSource?this.#ee.total===null:this.loading)&&a===0,s=a===0&&!o;s?this.#tt.delete(`empty`):this.#ea&&!this.#tt.has(`empty`)&&this.#Nt(`empty`),this.#ea=s;let c=!s&&this.#tt.has(`empty`);this.hasUpdated&&o!==this.#Ft&&!this.#It&&this.#zt(),this.#Ft=o;let l=o||!!(this.dataSource&&this.#ee.loading),u=[];for(let e=i.start;e<i.end;e++)u.push(e);let d=this.#Le.row;d>=0&&(d<i.start||d>=i.end)&&(u.push(d),u.sort((e,t)=>e-t));let f=e=>Math.max(-1,Math.min(e-i.start,i.end-i.start))*this.#ue,p=this.#G.depth,m=this.#$t(),h=this.#an(),g=this.#pe.test(`footer`),_=this.#pe.test(`pagination`),v=this.renderBarStart();return L` ${this.#hi()} <div class="main${this.#ct?` narrow`:``}${this.dynamicMode?` panel-open`:``}${this.#yr?` ease-cols`:``}" > <div class="grid-area"> <div class="viewport" part="base" style=${K(this.#sn(a))} role=${this.#On()?`treegrid`:`grid`} aria-label=${this.label||R} aria-rowcount=${a+m+ +!!h} aria-colcount=${this.#Se.length} aria-multiselectable=${this.selectable?`true`:R} aria-busy=${l?`true`:R} @scroll=${this.#un} @keydown=${this.#bn} @focusin=${this.#_n} @focusout=${this.#no} @copy=${this.#Bn} @paste=${this.#Vn} > <div class="header" part="header" role="rowgroup" style=${K(r)} @click=${this.#lr} @contextmenu=${this.#ur} @dragover=${this.#jr} @drop=${this.#Mr} @dragend=${this.#Nr} > ${this.#io(e)} <div role="row" class="row" aria-rowindex=${p}> ${B(e,e=>e.col.id,e=>this.#lo(e))}${this.#ai()} </div> ${this.filterRow||this.#tt.has(`filter-row`)?this.#ga(e,p+1):R} </div> <div class="body" part="body" role="rowgroup" style=${K(`${r};height:${o?i.page*this.#ue:i.height}px`)} @click=${this.#nr} @dblclick=${this.#er} @pointerdown=${this.#Pn} @pointerover=${this.#Fn} @contextmenu=${this.#Eo} @focusout=${this.#$n} > <div class="rows" style=${K(`transform:translateY(${i.top}px)`)}> ${o?Array.from({length:i.page},(t,n)=>this.#Vo(n,e,i.page)):B(u,e=>e,t=>this.#fo(t,e,t<i.start||t>=i.end?`position:absolute;inset-inline:0;top:${f(t)}px`:``))} </div> </div> ${h?this.#Bo(e,r,m+a+1):R} </div> ${s||c?L`<div class="empty${c?` leaving`:``}" data-leave=${c?`empty`:R} ?inert=${c} aria-hidden=${c?`true`:R} style=${K(`top:${this.#en()}px`)} > <slot name="empty">${this.#Zr()}</slot> </div>`:R} ${this.#$i()} </div> ${this.#ba()} </div> <div class="bar" part="bar" ?hidden=${!g&&!_&&v===R}> ${v} <slot name="footer"></slot> <div class="pager" ?hidden=${!_}><slot name="pagination"></slot></div> </div> ${this.#Vr()} ${this.#da()} ${this.#Ya()} ${this.#Lo()} ${this.#Z?L`<sankhya-ds-grid-config class="own-config" .grid=${this} .saveConfig=${this.saveConfig} @sankhya-ds-open=${this.#yt} @sankhya-ds-close=${this.#yt} @sankhya-ds-error=${this.#yt} ></sankhya-ds-grid-config>`:R} ${this.#Yr()} ${this.#ki()} ${[...this.#Rn].map(([e,t])=>this.#Ln.render(e,t))} ${this.#Fe?.error?L`<div id="cell-error" class="cell-error" part="cell-error" popover="manual" role="alert" > ${this.#Fe.error} </div>`:R} <div class="visually-hidden" aria-live="polite">${this.#ze}</div> <div class="ghosts"></div> `}}})();function $(e){return{has:t=>e in t,get:t=>t[e],set:(t,n)=>{t[e]=n}}}export{It as SankhyaDsDataGrid};
|