Files
ferrovia-panel/public/wcs/p-f2f7595e.entry.js
T
AdminGit 935b9cf92b V5.0.0 //
-> Refonte du système de GESTION DES ROULEMENTS de matériels roulants
-> Cartographie Infra + Widget
2026-10-04 23:47:21 +02:00

2 lines
27 KiB
JavaScript

import{h as r,r as t,c as e,f as i,H as o,g as s}from"./p-32e583ea.js";import{G as n}from"./p-c5bad0b8.js";import{k as a}from"./p-89b8c724.js";import{i as c,a as d,s as l}from"./p-52d77e1f.js";import{i as u,b as h,a as f,S as g,c as b,g as v,e as w,d as p,f as m,h as k,M as y,o as j,k as C,r as x,j as A,s as _,l as R,m as O,U as S,n as F,p as I,q as E,t as P,u as D,v as M,w as T}from"./p-ff826ebe.js";function W(r){switch(r){case"asc":return 1;case"desc":return-1}}var U;var G=new Uint8Array(16);function H(){if(!U){U=typeof crypto!=="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!=="undefined"&&typeof msCrypto.getRandomValues==="function"&&msCrypto.getRandomValues.bind(msCrypto);if(!U){throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported")}}return U(G)}const N=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function z(r){return typeof r==="string"&&N.test(r)}var L=[];for(var B=0;B<256;++B){L.push((B+256).toString(16).substr(1))}function $(r){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var e=(L[r[t+0]]+L[r[t+1]]+L[r[t+2]]+L[r[t+3]]+"-"+L[r[t+4]]+L[r[t+5]]+"-"+L[r[t+6]]+L[r[t+7]]+"-"+L[r[t+8]]+L[r[t+9]]+"-"+L[r[t+10]]+L[r[t+11]]+L[r[t+12]]+L[r[t+13]]+L[r[t+14]]+L[r[t+15]]).toLowerCase();if(!z(e)){throw TypeError("Stringified UUID is invalid")}return e}function V(r,t,e){r=r||{};var i=r.random||(r.rng||H)();i[6]=i[6]&15|64;i[8]=i[8]&63|128;if(t){e=e||0;for(var o=0;o<16;++o){t[e+o]=i[o]}return t}return $(i)}var K="[object Symbol]";function q(r){return typeof r=="symbol"||u(r)&&h(r)==K}function J(r,t){var e=-1,i=r==null?0:r.length,o=Array(i);while(++e<i){o[e]=t(r[e],e,r)}return o}var Q=1/0;var X=g?g.prototype:undefined,Y=X?X.toString:undefined;function Z(r){if(typeof r=="string"){return r}if(f(r)){return J(r,Z)+""}if(q(r)){return Y?Y.call(r):""}var t=r+"";return t=="0"&&1/r==-Q?"-0":t}var rr=Object.create;var tr=function(){function r(){}return function(t){if(!b(t)){return{}}if(rr){return rr(t)}r.prototype=t;var e=new r;r.prototype=undefined;return e}}();const er=tr;function ir(r,t){var e=-1,i=r.length;t||(t=Array(i));while(++e<i){t[e]=r[e]}return t}var or=function(){try{var r=v(Object,"defineProperty");r({},"",{});return r}catch(r){}}();const sr=or;function nr(r,t){var e=-1,i=r==null?0:r.length;while(++e<i){if(t(r[e],e,r)===false){break}}return r}function ar(r,t,e){if(t=="__proto__"&&sr){sr(r,t,{configurable:true,enumerable:true,value:e,writable:true})}else{r[t]=e}}var cr=Object.prototype;var dr=cr.hasOwnProperty;function lr(r,t,e){var i=r[t];if(!(dr.call(r,t)&&w(i,e))||e===undefined&&!(t in r)){ar(r,t,e)}}function ur(r,t,e,i){var o=!e;e||(e={});var s=-1,n=t.length;while(++s<n){var a=t[s];var c=i?i(e[a],r[a],a,e,r):undefined;if(c===undefined){c=r[a]}if(o){ar(e,a,c)}else{lr(e,a,c)}}return e}function hr(r){var t=[];if(r!=null){for(var e in Object(r)){t.push(e)}}return t}var fr=Object.prototype;var gr=fr.hasOwnProperty;function br(r){if(!b(r)){return hr(r)}var t=p(r),e=[];for(var i in r){if(!(i=="constructor"&&(t||!gr.call(r,i)))){e.push(i)}}return e}function vr(r){return m(r)?k(r,true):br(r)}var wr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,pr=/^\w*$/;function mr(r,t){if(f(r)){return false}var e=typeof r;if(e=="number"||e=="symbol"||e=="boolean"||r==null||q(r)){return true}return pr.test(r)||!wr.test(r)||t!=null&&r in Object(t)}var kr="Expected a function";function yr(r,t){if(typeof r!="function"||t!=null&&typeof t!="function"){throw new TypeError(kr)}var e=function(){var i=arguments,o=t?t.apply(this,i):i[0],s=e.cache;if(s.has(o)){return s.get(o)}var n=r.apply(this,i);e.cache=s.set(o,n)||s;return n};e.cache=new(yr.Cache||y);return e}yr.Cache=y;var jr=500;function Cr(r){var t=yr(r,(function(r){if(e.size===jr){e.clear()}return r}));var e=t.cache;return t}var xr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;var Ar=/\\(\\)?/g;var _r=Cr((function(r){var t=[];if(r.charCodeAt(0)===46){t.push("")}r.replace(xr,(function(r,e,i,o){t.push(i?o.replace(Ar,"$1"):e||r)}));return t}));const Rr=_r;function Or(r){return r==null?"":Z(r)}function Sr(r,t){if(f(r)){return r}return mr(r,t)?[r]:Rr(Or(r))}var Fr=1/0;function Ir(r){if(typeof r=="string"||q(r)){return r}var t=r+"";return t=="0"&&1/r==-Fr?"-0":t}function Er(r,t){t=Sr(t,r);var e=0,i=t.length;while(r!=null&&e<i){r=r[Ir(t[e++])]}return e&&e==i?r:undefined}function Pr(r,t,e){var i=r==null?undefined:Er(r,t);return i===undefined?e:i}var Dr=j(Object.getPrototypeOf,Object);const Mr=Dr;function Tr(r,t){return r&&ur(t,C(t),r)}function Wr(r,t){return r&&ur(t,vr(t),r)}var Ur=typeof exports=="object"&&exports&&!exports.nodeType&&exports;var Gr=Ur&&typeof module=="object"&&module&&!module.nodeType&&module;var Hr=Gr&&Gr.exports===Ur;var Nr=Hr?x.Buffer:undefined,zr=Nr?Nr.allocUnsafe:undefined;function Lr(r,t){if(t){return r.slice()}var e=r.length,i=zr?zr(e):new r.constructor(e);r.copy(i);return i}function Br(r,t){return ur(r,A(r),t)}var $r=Object.getOwnPropertySymbols;var Vr=!$r?_:function(r){var t=[];while(r){R(t,A(r));r=Mr(r)}return t};const Kr=Vr;function qr(r,t){return ur(r,Kr(r),t)}function Jr(r){return O(r,vr,Kr)}var Qr=Object.prototype;var Xr=Qr.hasOwnProperty;function Yr(r){var t=r.length,e=new r.constructor(t);if(t&&typeof r[0]=="string"&&Xr.call(r,"index")){e.index=r.index;e.input=r.input}return e}function Zr(r){var t=new r.constructor(r.byteLength);new S(t).set(new S(r));return t}function rt(r,t){var e=t?Zr(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.byteLength)}var tt=/\w*$/;function et(r){var t=new r.constructor(r.source,tt.exec(r));t.lastIndex=r.lastIndex;return t}var it=g?g.prototype:undefined,ot=it?it.valueOf:undefined;function st(r){return ot?Object(ot.call(r)):{}}function nt(r,t){var e=t?Zr(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.length)}var at="[object Boolean]",ct="[object Date]",dt="[object Map]",lt="[object Number]",ut="[object RegExp]",ht="[object Set]",ft="[object String]",gt="[object Symbol]";var bt="[object ArrayBuffer]",vt="[object DataView]",wt="[object Float32Array]",pt="[object Float64Array]",mt="[object Int8Array]",kt="[object Int16Array]",yt="[object Int32Array]",jt="[object Uint8Array]",Ct="[object Uint8ClampedArray]",xt="[object Uint16Array]",At="[object Uint32Array]";function _t(r,t,e){var i=r.constructor;switch(t){case bt:return Zr(r);case at:case ct:return new i(+r);case vt:return rt(r,e);case wt:case pt:case mt:case kt:case yt:case jt:case Ct:case xt:case At:return nt(r,e);case dt:return new i;case lt:case ft:return new i(r);case ut:return et(r);case ht:return new i;case gt:return st(r)}}function Rt(r){return typeof r.constructor=="function"&&!p(r)?er(Mr(r)):{}}var Ot="[object Map]";function St(r){return u(r)&&F(r)==Ot}var Ft=E&&E.isMap;var It=Ft?I(Ft):St;const Et=It;var Pt="[object Set]";function Dt(r){return u(r)&&F(r)==Pt}var Mt=E&&E.isSet;var Tt=Mt?I(Mt):Dt;const Wt=Tt;var Ut=1,Gt=2,Ht=4;var Nt="[object Arguments]",zt="[object Array]",Lt="[object Boolean]",Bt="[object Date]",$t="[object Error]",Vt="[object Function]",Kt="[object GeneratorFunction]",qt="[object Map]",Jt="[object Number]",Qt="[object Object]",Xt="[object RegExp]",Yt="[object Set]",Zt="[object String]",re="[object Symbol]",te="[object WeakMap]";var ee="[object ArrayBuffer]",ie="[object DataView]",oe="[object Float32Array]",se="[object Float64Array]",ne="[object Int8Array]",ae="[object Int16Array]",ce="[object Int32Array]",de="[object Uint8Array]",le="[object Uint8ClampedArray]",ue="[object Uint16Array]",he="[object Uint32Array]";var fe={};fe[Nt]=fe[zt]=fe[ee]=fe[ie]=fe[Lt]=fe[Bt]=fe[oe]=fe[se]=fe[ne]=fe[ae]=fe[ce]=fe[qt]=fe[Jt]=fe[Qt]=fe[Xt]=fe[Yt]=fe[Zt]=fe[re]=fe[de]=fe[le]=fe[ue]=fe[he]=true;fe[$t]=fe[Vt]=fe[te]=false;function ge(r,t,e,i,o,s){var n,a=t&Ut,c=t&Gt,d=t&Ht;if(e){n=o?e(r,i,o,s):e(r)}if(n!==undefined){return n}if(!b(r)){return r}var l=f(r);if(l){n=Yr(r);if(!a){return ir(r,n)}}else{var u=F(r),h=u==Vt||u==Kt;if(P(r)){return Lr(r,a)}if(u==Qt||u==Nt||h&&!o){n=c||h?{}:Rt(r);if(!a){return c?qr(r,Wr(n,r)):Br(r,Tr(n,r))}}else{if(!fe[u]){return o?r:{}}n=_t(r,u,a)}}s||(s=new D);var g=s.get(r);if(g){return g}s.set(r,n);if(Wt(r)){r.forEach((function(i){n.add(ge(i,t,e,i,r,s))}))}else if(Et(r)){r.forEach((function(i,o){n.set(o,ge(i,t,e,o,r,s))}))}var v=d?c?Jr:M:c?vr:C;var w=l?undefined:v(r);nr(w||r,(function(i,o){if(w){o=i;i=r[o]}lr(n,o,ge(i,t,e,o,r,s))}));return n}var be=1,ve=4;function we(r){return ge(r,be|ve)}function pe(r,t){const e=a(r);if(e==="UNKNOWN"){return[]}switch(e){case"UP_ARROW":return[{kind:"FocusCell",target:"up"}];case"DOWN_ARROW":return[{kind:"FocusCell",target:"down"}];case"LEFT_ARROW":return[{kind:"FocusCell",target:"left"}];case"RIGHT_ARROW":return[{kind:"FocusCell",target:"right"}];case"HOME":return[{kind:"FocusCell",target:"first_of_row"}];case"END":return[{kind:"FocusCell",target:"last_of_row"}];case"MAJ+SPACE":switch(t){case"grid_selection_single":case"grid_selection_multiple":return[{kind:"SelectRow",target:"one"}]}break;case"CTRL+A":switch(t){case"grid_selection_multiple":return[{kind:"SelectRow",target:"all"}]}break;case"CTRL+HOME":return[{kind:"FocusCell",target:"first_of_grid"}];case"CTRL+END":return[{kind:"FocusCell",target:"last_of_grid"}]}return[]}const me=({checked:t,row:e,rowIndex:i,totalRows:o,onClick:s})=>{let n;return r("div",{class:`grid-radio ${t?"checked":""}`,onClick:r=>n.click()},r("input",{type:"radio",name:"selection","aria-setsize":o,"aria-posinset":i,tabindex:"-1",checked:t,"aria-checked":`${t}`,ref:r=>n=r,onClick:r=>s(e)}))};const ke=":host{--wcs-grid-gap:0;--wcs-grid-vertical-align:middle;--wcs-grid-outline-color:var(--wcs-semantic-color-border-focus-base);--wcs-grid-cell-text-color:var(--wcs-semantic-color-text-secondary);--wcs-grid-cell-padding-horizontal:var(--wcs-semantic-spacing-large);--wcs-grid-cell-padding-vertical:var(--wcs-semantic-spacing-base);--wcs-grid-cell-border-bottom:none;--wcs-grid-cell-separator-border:none;--wcs-grid-first-cell-border-radius:0;--wcs-grid-last-cell-border-radius:0;--wcs-grid-highlight-color:var(--wcs-semantic-color-background-surface-accent-lighter);--wcs-grid-row-background-color:var(--wcs-semantic-color-background-surface-primary);--wcs-grid-row-odd-background-color:var(--wcs-grid-row-background-color);--wcs-grid-row-even-background-color:var(--wcs-semantic-color-background-surface-accent-lightest);--wcs-grid-header-background-color-default:var(--wcs-semantic-color-background-action-secondary-default);--wcs-grid-header-background-color-hover:var(--wcs-semantic-color-background-action-secondary-hover);--wcs-grid-header-background-color-press:var(--wcs-semantic-color-background-action-secondary-press);--wcs-grid-header-text-color:var(--wcs-semantic-color-text-primary);--wcs-grid-header-font-weight:var(--wcs-semantic-font-weight-heavy);--wcs-grid-header-font-size:var(--wcs-semantic-font-size-label-1);--wcs-grid-header-line-height:var(--wcs-primitive-font-line-height-140);--wcs-grid-header-padding-vertical:var(--wcs-semantic-spacing-base);--wcs-grid-header-padding-horizontal:var(--wcs-semantic-spacing-large);--wcs-grid-header-border-left:none;--wcs-grid-header-border-radius:0;--wcs-grid-header-border-bottom:solid var(--wcs-semantic-border-width-default) var(--wcs-semantic-color-border-secondary);--wcs-grid-header-transition-duration:var(--wcs-semantic-motion-duration-feedback-fast);--wcs-grid-first-header-background-color:var(--wcs-semantic-color-background-action-secondary-default);--wcs-grid-first-header-border-radius:0;--wcs-grid-last-header-border-radius:0;--wcs-grid-column-selection-width:calc(5 * var(--wcs-semantic-spacing-base));--wcs-grid-header-sort-arrow-color-default:var(--wcs-semantic-color-foreground-action-neutral-default);--wcs-grid-header-sort-arrow-color-hover:var(--wcs-semantic-color-foreground-action-neutral-hover);display:block}:host th{border-radius:var(--wcs-grid-first-header-border-radius);background-color:var(--wcs-grid-first-header-background-color)}:host ::slotted([slot=grid-column]:first-child){--wcs-grid-header-border-left:none}:host :host([selection]) ::slotted([slot=grid-column]:first-child){--wcs-component-grid-header-border-radius-first:0;--wcs-grid-header-border-left:var(--wcs-grid-header-border-left)}:host table{width:100%;border-collapse:collapse;border-spacing:var(--wcs-grid-gap)}:host table thead{border-bottom:var(--wcs-grid-header-border-bottom)}:host table tbody{vertical-align:var(--wcs-grid-vertical-align)}:host td{color:var(--wcs-grid-cell-text-color);margin:0;padding:var(--wcs-grid-cell-padding-vertical) var(--wcs-grid-cell-padding-horizontal)}:host td:focus-visible{outline:var(--wcs-semantic-border-width-large) dashed var(--wcs-grid-outline-color);outline-offset:0;border-radius:0.1rem}:host td:first-child{border-radius:var(--wcs-grid-first-cell-border-radius)}:host td:last-child{border-radius:var(--wcs-grid-last-cell-border-radius)}:host td:not(:first-child){border-left:var(--wcs-grid-cell-separator-border)}:host tr{background-color:var(--wcs-grid-row-background-color)}:host tr:nth-child(odd){background-color:var(--wcs-grid-row-odd-background-color, var(--wcs-grid-row-background-color))}:host tr:nth-child(even){background-color:var(--wcs-grid-row-even-background-color, var(--wcs-grid-row-background-color))}:host tr:not(:last-child) td{border-bottom:var(--wcs-grid-cell-border-bottom)}:host .wcs-grid-selection-column{padding:var(--wcs-grid-cell-padding-vertical) var(--wcs-grid-cell-padding-horizontal);width:var(--wcs-grid-column-selection-width);text-align:start}:host tr.selected{background-color:var(--wcs-grid-highlight-color)}:host .loading{text-align:center}";const ye=ke;const je='.grid-radio{--wcs-grid-radio-outline-color:var(--wcs-semantic-color-border-focus-base);--wcs-grid-radio-padding:calc(var(--wcs-semantic-size-base) / 4);--wcs-grid-radio-transition:var(--wcs-semantic-motion-duration-feedback-base);--wcs-grid-radio-border-color-default:var(--wcs-semantic-color-border-control-indicator-default);--wcs-grid-radio-border-color-selected:var(--wcs-semantic-color-border-control-indicator-selected);--wcs-grid-radio-border-color-hover:var(--wcs-semantic-color-border-control-indicator-hover);--wcs-grid-radio-border-color-disabled:var(--wcs-semantic-color-border-control-indicator-disabled);--wcs-grid-radio-background-color-default:transparent;--wcs-grid-radio-background-color-selected:var(--wcs-semantic-color-background-control-indicator-selected);--wcs-grid-radio-background-color-disabled:var(--wcs-semantic-color-background-control-indicator-disabled);--wcs-grid-radio-inner-border-color:white;width:fit-content;cursor:pointer;padding:var(--wcs-grid-radio-padding, 0.125rem);}.grid-radio:has(input:focus-visible){outline:var(--wcs-semantic-border-width-large) dashed var(--wcs-grid-radio-outline-color);outline-offset:var(--wcs-semantic-spacing-small);border-radius:0.1rem}@supports not selector(:has(input:focus-visible)){.grid-radio:focus-within{outline:var(--wcs-semantic-border-width-large) dashed var(--wcs-grid-radio-outline-color);outline-offset:var(--wcs-semantic-spacing-small);border-radius:0.1rem}}.grid-radio input{position:absolute;opacity:0;height:1px;width:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.grid-radio::before{content:"";display:flex;border-radius:50%;border:2px solid var(--wcs-grid-radio-border-color-default);position:relative;width:1.125rem;height:1.125rem;box-sizing:border-box;background-color:var(--wcs-grid-radio-background-color-default);transition:var(--wcs-grid-radio-transition, 0.175s) ease-in-out}.grid-radio:hover::before{border-color:var(--wcs-grid-radio-border-color-hover)}.grid-radio.checked::before{border-color:var(--wcs-grid-radio-border-color-selected);background-color:var(--wcs-grid-radio-background-color-selected);outline:solid 2px var(--wcs-grid-radio-inner-border-color);outline-offset:-4px}';const Ce=je;const xe=["title"];const Ae=class{constructor(r){t(this,r);this.wcsGridSelectionChange=e(this,"wcsGridSelectionChange",7);this.wcsGridAllSelectionChange=e(this,"wcsGridAllSelectionChange",7);this.wcsFocus=e(this,"wcsFocus",7);this.wcsBlur=e(this,"wcsBlur",7);this.inheritedAttributes={};this.serverMode=false;this.data=undefined;this.loading=undefined;this.selectionConfig="none";this.selectedItems=[];this.wcsGridPaginationId=undefined;this.rowIdPath=undefined;this.rowCssPartsFn=r=>null;this.columns=undefined;this.paginationEl=undefined;this.rows=[];this.cursorPosition={col:0,row:1}}onCursorPositionChange(r){this.getGridColumnsFromTemplate().forEach((t=>t.cursorPosition=r))}onDataChange(r){this.updateGridRows(r);this.refreshSort(false);this.updatePageIndex()}onSelectedItemsPropertyChange(r){this.updateSelectionWithValues(r)}onFocus(r){var t;(t=this.getElementToFocusAtCursorPosition())===null||t===void 0?void 0:t.focus();this.wcsFocus.emit(r)}onBlur(r){this.wcsBlur.emit(r)}async focusFirstCell(){var r;this.cursorPosition={col:this.selectionConfig==="none"?0:1,row:1};(r=this.getElementToFocusAtCursorPosition())===null||r===void 0?void 0:r.focus()}hasSelectionColumn(){return this.selectionConfig!=="none"}getElementToFocusAtCursorPosition(){var r,t;const e=(r=this.gridElementsWithCoordinates.find((r=>{var t,e;return r.col===((t=this.cursorPosition)===null||t===void 0?void 0:t.col)&&r.row===((e=this.cursorPosition)===null||e===void 0?void 0:e.row)})))===null||r===void 0?void 0:r.el;return this.hasSelectionColumn()?(t=e.querySelector('wcs-checkbox,input[type="radio"]'))!==null&&t!==void 0?t:e:e}moveCursorPosition(r,t){var e;this.cursorPosition={col:r==="first"?0:r==="last"?this.totalDisplayedColumnCount()-1:Math.min(Math.max(this.cursorPosition.col+r,0),this.totalDisplayedColumnCount()-1),row:t==="first"?0:t==="last"?this.getRowsForCurrentPage().length:Math.min(Math.max(this.cursorPosition.row+t,0),this.getRowsForCurrentPage().length)};this.handleCursorPositionOnEmptyTh();(e=this.getElementToFocusAtCursorPosition())===null||e===void 0?void 0:e.focus()}handleCursorPositionOnEmptyTh(){if(this.selectionConfig==="single"&&this.cursorPosition.col===0&&this.cursorPosition.row===0){this.cursorPosition={col:1,row:0}}}onHiddenColumnChange(){i(this);this.cursorPosition={col:0,row:1}}onKeyDown(r){var t;if(((t=document.activeElement)===null||t===void 0?void 0:t.tagName)==="WCS-GRID-PAGINATION"){return}let e;switch(this.selectionConfig){case"multiple":e="grid_selection_multiple";break;case"single":e="grid_selection_single";break;case"none":e="grid_no_selection";break}const i=pe(r,e);if(i.length!=0){r.preventDefault()}for(const t of i){this.doActionFromKeyboardEventAssociatedAction(t,r)}}doActionFromKeyboardEventAssociatedAction(r,t){switch(r.kind){case"FocusCell":switch(r.target){case"up":this.moveCursorPosition(0,-1);break;case"down":this.moveCursorPosition(0,1);break;case"left":this.moveCursorPosition(-1,0);break;case"right":this.moveCursorPosition(1,0);break;case"first_of_row":this.moveCursorPosition("first",0);break;case"last_of_row":this.moveCursorPosition("last",0);break;case"first_of_grid":this.moveCursorPosition("first","first");break;case"last_of_grid":this.moveCursorPosition("last","last");break}case"SelectRow":switch(r.target){case"one":t.preventDefault();if(this.cursorPosition.row>0){this.onRowSelection(this.rows[this.cursorPosition.row-1])}break;case"all":this.selectAllRows();break}break;default:throw new Error("Internal error")}}onClick(r){const t=r.composedPath().filter((r=>["TD","TH"].includes(r.nodeName)))[0];if(!t)return;const e=this.gridElementsWithCoordinates.find((r=>r.el===t));this.cursorPosition={col:e.col,row:e.row}}updateSelectionWithValues(r){if(this.selectionConfig==="single"){this.rows.map((r=>r.selected=false));for(const t of this.rows){if(T(t.data,r)){t.selected=true;break}}}else if(this.selectionConfig==="multiple"){this.rows.map((r=>r.selected=false));for(const t of this.rows){if(r.find((r=>T(r,t.data)))){t.selected=true}}}this.rows=we(this.rows)}wcsGridRowToWcsGridRowData(r){return{selected:r.selected,page:r.page,data:r.data}}updateGridRows(r){const t=[];if(r&&this.columns){for(let e=0;e<r.length;e++){const i={uuid:V(),data:r[e],selected:false,cells:[]};let o=0;for(const t of this.columns){t.columnPosition=o+(this.hasSelectionColumn()?1:0);o++;i.cells.push({content:Pr(r[e],t.path),column:t,formatter:t.formatter})}t.push(i)}this.rows=t}}componentDidLoad(){this.columns=this.getGridColumnsFromTemplate();this.paginationEl=this.wcsGridPaginationId?document.getElementById(this.wcsGridPaginationId):this.getGridPaginationsFromTemplate()[0];this.updateGridRows(this.data);if(this.selectedItems){this.updateSelectionWithValues(this.selectedItems)}this.refreshSort(true);this.updatePageIndex()}componentWillLoad(){this.inheritedAttributes=Object.assign(Object.assign({},c(this.el)),d(this.el,xe))}async setAriaAttribute(r,t){l(this.nativeTable,r,t)}refreshSort(r){if(this.columns){const[t,...e]=this.columns.filter((r=>r.sortOrder!=="none"));if(t&&!this.serverMode){this.sortBy(t)}r&&this.disableSortOrderForColumns(e)}}disableSortOrderForColumns(r){r===null||r===void 0?void 0:r.forEach((r=>r.sortOrder="none"))}getGridColumnsFromTemplate(){const r=this.el.shadowRoot.querySelector('slot[name="grid-column"]');return r.assignedElements()}getGridPaginationsFromTemplate(){const r=this.el.shadowRoot.querySelector('slot[name="grid-pagination"]');return r.assignedElements()}get gridElementsWithCoordinates(){const r=[];if(this.selectionConfig==="multiple"){r.push({el:this.el.shadowRoot.querySelector("th"),row:0,col:0})}this.getGridColumnsFromTemplate().filter((r=>!r.hidden)).forEach(((t,e)=>{r.push({el:t.shadowRoot.querySelector("th"),row:0,col:e+(this.hasSelectionColumn()?1:0)})}));this.el.shadowRoot.querySelectorAll("td").forEach(((t,e)=>{r.push({el:t,row:1+Math.floor(e/this.totalDisplayedColumnCount()),col:e%this.totalDisplayedColumnCount()})}));return r}sortChangeEventHandler(r){if(r.detail.order==="none"||!this.columns)return;this.disableSortOrderForColumns(this.columns.filter((t=>t!==r.detail.column)));if(this.serverMode)return;this.sortBy(r.detail.column);this.updatePageIndex()}sortBy(r){if(r.sortFn){this.rows=we(this.rows).sort(((t,e)=>r.sortFn(t.data,e.data,r)*W(r.sortOrder)))}else{this.rows=we(this.rows).sort(((t,e)=>{const i=r.path;return(Pr(t.data,i)<Pr(e.data,i)?-1:Pr(t.data,i)>Pr(e.data,i)?1:0)*W(r.sortOrder)}))}}updatePageIndex(){if(!this.serverMode&&this.paginationEl){this.paginationEl.itemsCount=this.data.length;this.paginationEl.pageCount=Math.ceil(this.data.length/this.paginationEl.pageSize);if(this.paginationEl.pageCount<=1){this.paginationEl.currentPage=n.INDEX_FIRST_PAGE}else if(this.paginationEl.pageCount>0&&this.paginationEl.currentPage+1>this.paginationEl.pageCount){this.paginationEl.currentPage=this.paginationEl.pageCount-1}const r=we(this.rows);r.forEach(((r,t)=>r.page=Math.floor(t/this.paginationEl.pageSize)));this.rows=[...r]}}paginationChangeEventHandler(){this.onPaginationChange()}paginationChangeEventHandlerOutside(r){if(this.wcsGridPaginationId&&this.wcsGridPaginationId===r.target.id){this.onPaginationChange()}}onPaginationChange(){if(this.serverMode)return;this.updatePageIndex()}onRowSelection(r){if(this.selectionConfig==="single"){this.rows.filter((t=>t.uuid!==r.uuid)).map((r=>r.selected=false))}r.selected=!r.selected;if(this.selectionConfig!=="single"||r.selected){this.wcsGridSelectionChange.emit({selectedRows:this.selectedRows.map((r=>this.wcsGridRowToWcsGridRowData(r))),changedRow:this.wcsGridRowToWcsGridRowData(r)})}this.rows=we(this.rows)}get selectedRows(){return this.rows.filter((r=>r.selected))}selectAllRows(){const r=this.getRowsForCurrentPage();const t=!this.allRowsAreSelected();r.map((r=>r.selected=t));this.wcsGridAllSelectionChange.emit({rows:t?r.map((r=>this.wcsGridRowToWcsGridRowData(r))):[]});this.wcsGridSelectionChange.emit({selectedRows:this.selectedRows.map((r=>this.wcsGridRowToWcsGridRowData(r))),changedRow:"allCheckbox"});this.rows=we(this.rows)}allRowsAreSelected(){const r=this.getRowsForCurrentPage();return r.length>0&&r.filter((r=>r.selected)).length===r.length}getRowsForCurrentPage(){if(!this.serverMode&&this.paginationEl){return this.rows.filter((r=>r.page===this.paginationEl.currentPage))}return this.rows}renderSelectionColumn(t,e){var i,o,s,n;switch(this.selectionConfig){case"none":return;case"single":return r("td",{"aria-colindex":this.atLeastOneColumnHidden()?1:null,tabIndex:((i=this.cursorPosition)===null||i===void 0?void 0:i.col)===0&&e+1===((o=this.cursorPosition)===null||o===void 0?void 0:o.row)?0:-1},r(me,{checked:t.selected,row:t,rowIndex:e+1,totalRows:this.rows.length,onClick:r=>{if(!r.selected){this.onRowSelection(r)}}}));case"multiple":return r("td",{"aria-colindex":this.atLeastOneColumnHidden()?1:null,tabIndex:((s=this.cursorPosition)===null||s===void 0?void 0:s.col)===0&&e+1===((n=this.cursorPosition)===null||n===void 0?void 0:n.row)?0:-1},r("wcs-checkbox",{tabIndex:-1,part:"row-checkbox",checked:t.selected,onWcsChange:this.onRowSelection.bind(this,t)}))}}getCellContent(t,e){if(e.formatter){return e.formatter(r,e.column,this.wcsGridRowToWcsGridRowData(t))}return e.content}totalColumnCount(){if(!this.columns){return 0}return this.columns.length+(this.hasSelectionColumn()?1:0)}totalDisplayedColumnCount(){var r,t;return(t=this.totalColumnCount()-((r=this.columns)===null||r===void 0?void 0:r.filter((r=>r.hidden)).length))!==null&&t!==void 0?t:0}atLeastOneColumnHidden(){return this.totalDisplayedColumnCount()!==this.totalColumnCount()}render(){var t,e,i,s;return r(o,{key:"1e9b1d5dc405c67428750276de3e38e8e163d20e"},r("table",Object.assign({key:"42e610c403c108f36c2f5e4eb276b9e1c6349b8c",role:"grid",ref:r=>this.nativeTable=r,"aria-rowcount":!this.loading&&((t=this.rows)===null||t===void 0?void 0:t.length),"aria-colcount":!this.loading&&this.totalDisplayedColumnCount()},this.inheritedAttributes),r("thead",{key:"365bf4de9329c94c5c891040b14ca844c6e8fd99"},r("tr",{key:"9d1e4c4cf0418f585679a055edbb88ca08493d3d","aria-rowindex":"1"},this.selectionConfig==="none"?"":r("th",{class:"wcs-grid-selection-column"},this.selectionConfig==="single"?"":r("wcs-checkbox",{tabIndex:((e=this.cursorPosition)===null||e===void 0?void 0:e.col)===0&&((i=this.cursorPosition)===null||i===void 0?void 0:i.row)===0?0:-1,part:"all-rows-checkbox",checked:this.allRowsAreSelected(),onWcsChange:this.selectAllRows.bind(this)})),r("slot",{key:"4c1ed31eeaf61d0f94a156cc97b393abafdfb6e3",name:"grid-column"}))),r("tbody",{key:"5758c76c248e9e54759bd008310047a5c670339a"},this.loading?r("tr",{"aria-busy":"true"},r("td",{colSpan:this.totalColumnCount(),class:"loading"},r("wcs-spinner",null))):(s=this.rows)===null||s===void 0?void 0:s.filter((r=>this.serverMode||!this.paginationEl||r.page===this.paginationEl.currentPage)).map(((r,t)=>this.renderRow(r,t))))),r("slot",{key:"170e79b086e8235ae736c8cc54512b0e3bb0e7ab",name:"grid-pagination"}))}renderRow(t,e){var i,o;let s=0;return r("tr",{class:t.selected?"selected":"",part:(i=this.rowCssPartsWithoutEmptyList(t))===null||i===void 0?void 0:i.join(" "),"aria-selected":t.selected?"true":null,"aria-rowindex":e+2},this.renderSelectionColumn(t,e),(o=t.cells)===null||o===void 0?void 0:o.map(((i,o)=>{var n,a;if(i.column.hidden){s++;return}const c=o-s+1+(this.hasSelectionColumn()?1:0);const d=c-1===((n=this.cursorPosition)===null||n===void 0?void 0:n.col)&&e+1===((a=this.cursorPosition)===null||a===void 0?void 0:a.row);return i.column.customCells?r("td",{tabIndex:d?0:-1,"aria-colindex":this.atLeastOneColumnHidden()?c:null},r("slot",{name:i.column.id+"-"+Pr(t.data,this.rowIdPath)})):r("td",{tabIndex:d?0:-1,"aria-colindex":this.atLeastOneColumnHidden()?c:null,part:i.column.path+"-column"},this.getCellContent(t,i))})))}rowCssPartsWithoutEmptyList(r){const t=this.rowCssPartsFn(r);return(t===null||t===void 0?void 0:t.length)===0?null:t}get el(){return s(this)}static get watchers(){return{cursorPosition:["onCursorPositionChange"],data:["onDataChange"],selectedItems:["onSelectedItemsPropertyChange"]}}};Ae.style=ye+Ce;export{Ae as wcs_grid};
//# sourceMappingURL=p-f2f7595e.entry.js.map