@timlassiter11/yatl 0.3.22 → 1.0.0

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.
@@ -0,0 +1,455 @@
1
+ "use strict";var yatl=(()=>{var dt=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ti=Object.getOwnPropertyNames;var ei=Object.prototype.hasOwnProperty;var Nt=(r,e)=>()=>(r&&(e=r(r=0)),e);var he=(r,e)=>{for(var t in e)dt(r,t,{get:e[t],enumerable:!0})},ii=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ti(e))!ei.call(r,s)&&s!==t&&dt(r,s,{get:()=>e[s],enumerable:!(i=le(e,s))||i.enumerable});return r};var si=r=>ii(dt({},"__esModule",{value:!0}),r),y=(r,e,t,i)=>{for(var s=i>1?void 0:i?le(e,t):e,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&dt(e,t,s),s};var ct,He=Nt(()=>{"use strict";ct=class{constructor(e){this._map=new Map,this._roundAverageSize=!1,this.totalSize=0,e?.roundAverageSize===!0&&(this._roundAverageSize=!0)}set(e,t){let i=this._map.get(e)||0;this._map.set(e,t),this.totalSize+=t-i}get averageSize(){if(this._map.size>0){let e=this.totalSize/this._map.size;return this._roundAverageSize?Math.round(e):e}return 0}getSize(e){return this._map.get(e)}clear(){this._map.clear(),this.totalSize=0}}});function ie(r){return r==="horizontal"?"width":"height"}var It,Be=Nt(()=>{"use strict";It=class{_getDefaultConfig(){return{direction:"vertical"}}constructor(e,t){this._latestCoords={left:0,top:0},this._direction=null,this._viewportSize={width:0,height:0},this.totalScrollSize={width:0,height:0},this.offsetWithinScroller={left:0,top:0},this._pendingReflow=!1,this._pendingLayoutUpdate=!1,this._pin=null,this._firstVisible=0,this._lastVisible=0,this._physicalMin=0,this._physicalMax=0,this._first=-1,this._last=-1,this._sizeDim="height",this._secondarySizeDim="width",this._positionDim="top",this._secondaryPositionDim="left",this._scrollPosition=0,this._scrollError=0,this._items=[],this._scrollSize=1,this._overhang=1e3,this._hostSink=e,Promise.resolve().then(()=>this.config=t||this._getDefaultConfig())}set config(e){Object.assign(this,Object.assign({},this._getDefaultConfig(),e))}get config(){return{direction:this.direction}}get items(){return this._items}set items(e){this._setItems(e)}_setItems(e){e!==this._items&&(this._items=e,this._scheduleReflow())}get direction(){return this._direction}set direction(e){e=e==="horizontal"?e:"vertical",e!==this._direction&&(this._direction=e,this._sizeDim=e==="horizontal"?"width":"height",this._secondarySizeDim=e==="horizontal"?"height":"width",this._positionDim=e==="horizontal"?"left":"top",this._secondaryPositionDim=e==="horizontal"?"top":"left",this._triggerReflow())}get viewportSize(){return this._viewportSize}set viewportSize(e){let{_viewDim1:t,_viewDim2:i}=this;Object.assign(this._viewportSize,e),i!==this._viewDim2?this._scheduleLayoutUpdate():t!==this._viewDim1&&this._checkThresholds()}get viewportScroll(){return this._latestCoords}set viewportScroll(e){Object.assign(this._latestCoords,e);let t=this._scrollPosition;this._scrollPosition=this._latestCoords[this._positionDim],Math.abs(t-this._scrollPosition)>=1&&this._checkThresholds()}reflowIfNeeded(e=!1){(e||this._pendingReflow)&&(this._pendingReflow=!1,this._reflow())}set pin(e){this._pin=e,this._triggerReflow()}get pin(){if(this._pin!==null){let{index:e,block:t}=this._pin;return{index:Math.max(0,Math.min(e,this.items.length-1)),block:t}}return null}_clampScrollPosition(e){return Math.max(-this.offsetWithinScroller[this._positionDim],Math.min(e,this.totalScrollSize[ie(this.direction)]-this._viewDim1))}unpin(){this._pin!==null&&(this._sendUnpinnedMessage(),this._pin=null)}_updateLayout(){}get _viewDim1(){return this._viewportSize[this._sizeDim]}get _viewDim2(){return this._viewportSize[this._secondarySizeDim]}_scheduleReflow(){this._pendingReflow=!0}_scheduleLayoutUpdate(){this._pendingLayoutUpdate=!0,this._scheduleReflow()}_triggerReflow(){this._scheduleLayoutUpdate(),Promise.resolve().then(()=>this.reflowIfNeeded())}_reflow(){this._pendingLayoutUpdate&&(this._updateLayout(),this._pendingLayoutUpdate=!1),this._updateScrollSize(),this._setPositionFromPin(),this._getActiveItems(),this._updateVisibleIndices(),this._sendStateChangedMessage()}_setPositionFromPin(){if(this.pin!==null){let e=this._scrollPosition,{index:t,block:i}=this.pin;this._scrollPosition=this._calculateScrollIntoViewPosition({index:t,block:i||"start"})-this.offsetWithinScroller[this._positionDim],this._scrollError=e-this._scrollPosition}}_calculateScrollIntoViewPosition(e){let{block:t}=e,i=Math.min(this.items.length,Math.max(0,e.index)),s=this._getItemPosition(i)[this._positionDim],n=s;if(t!=="start"){let o=this._getItemSize(i)[this._sizeDim];if(t==="center")n=s-.5*this._viewDim1+.5*o;else{let a=s-this._viewDim1+o;if(t==="end")n=a;else{let l=this._scrollPosition;n=Math.abs(l-s)<Math.abs(l-a)?s:a}}}return n+=this.offsetWithinScroller[this._positionDim],this._clampScrollPosition(n)}getScrollIntoViewCoordinates(e){return{[this._positionDim]:this._calculateScrollIntoViewPosition(e)}}_sendUnpinnedMessage(){this._hostSink({type:"unpinned"})}_sendVisibilityChangedMessage(){this._hostSink({type:"visibilityChanged",firstVisible:this._firstVisible,lastVisible:this._lastVisible})}_sendStateChangedMessage(){let e=new Map;if(this._first!==-1&&this._last!==-1)for(let i=this._first;i<=this._last;i++)e.set(i,this._getItemPosition(i));let t={type:"stateChanged",scrollSize:{[this._sizeDim]:this._scrollSize,[this._secondarySizeDim]:null},range:{first:this._first,last:this._last,firstVisible:this._firstVisible,lastVisible:this._lastVisible},childPositions:e};this._scrollError&&(t.scrollError={[this._positionDim]:this._scrollError,[this._secondaryPositionDim]:0},this._scrollError=0),this._hostSink(t)}get _num(){return this._first===-1||this._last===-1?0:this._last-this._first+1}_checkThresholds(){if(this._viewDim1===0&&this._num>0||this._pin!==null)this._scheduleReflow();else{let e=Math.max(0,this._scrollPosition-this._overhang),t=Math.min(this._scrollSize,this._scrollPosition+this._viewDim1+this._overhang);this._physicalMin>e||this._physicalMax<t?this._scheduleReflow():this._updateVisibleIndices({emit:!0})}}_updateVisibleIndices(e){if(this._first===-1||this._last===-1)return;let t=this._first;for(;t<this._last&&Math.round(this._getItemPosition(t)[this._positionDim]+this._getItemSize(t)[this._sizeDim])<=Math.round(this._scrollPosition);)t++;let i=this._last;for(;i>this._first&&Math.round(this._getItemPosition(i)[this._positionDim])>=Math.round(this._scrollPosition+this._viewDim1);)i--;(t!==this._firstVisible||i!==this._lastVisible)&&(this._firstVisible=t,this._lastVisible=i,e&&e.emit&&this._sendVisibilityChangedMessage())}}});var We={};he(We,{FlowLayout:()=>kt,flow:()=>Ci});function Ke(r){return r==="horizontal"?"marginLeft":"marginTop"}function xi(r){return r==="horizontal"?"marginRight":"marginBottom"}function Ti(r){return r==="horizontal"?"xOffset":"yOffset"}function $i(r,e){let t=[r,e].sort();return t[1]<=0?Math.min(...t):t[0]>=0?Math.max(...t):t[0]+t[1]}var Ci,se,kt,qe=Nt(()=>{"use strict";He();Be();Ci=r=>Object.assign({type:kt},r);se=class{constructor(){this._childSizeCache=new ct,this._marginSizeCache=new ct,this._metricsCache=new Map}update(e,t){let i=new Set;Object.keys(e).forEach(s=>{let n=Number(s);this._metricsCache.set(n,e[n]),this._childSizeCache.set(n,e[n][ie(t)]),i.add(n),i.add(n+1)});for(let s of i){let n=this._metricsCache.get(s)?.[Ke(t)]||0,o=this._metricsCache.get(s-1)?.[xi(t)]||0;this._marginSizeCache.set(s,$i(n,o))}}get averageChildSize(){return this._childSizeCache.averageSize}get totalChildSize(){return this._childSizeCache.totalSize}get averageMarginSize(){return this._marginSizeCache.averageSize}get totalMarginSize(){return this._marginSizeCache.totalSize}getLeadingMarginValue(e,t){return this._metricsCache.get(e)?.[Ke(t)]||0}getChildSize(e){return this._childSizeCache.getSize(e)}getMarginSize(e){return this._marginSizeCache.getSize(e)}clear(){this._childSizeCache.clear(),this._marginSizeCache.clear(),this._metricsCache.clear()}},kt=class extends It{constructor(){super(...arguments),this._itemSize={width:100,height:100},this._physicalItems=new Map,this._newPhysicalItems=new Map,this._metricsCache=new se,this._anchorIdx=null,this._anchorPos=null,this._stable=!0,this._measureChildren=!0,this._estimate=!0}get measureChildren(){return this._measureChildren}updateItemSizes(e){this._metricsCache.update(e,this.direction),this._scheduleReflow()}_getPhysicalItem(e){return this._newPhysicalItems.get(e)??this._physicalItems.get(e)}_getSize(e){return this._getPhysicalItem(e)&&this._metricsCache.getChildSize(e)}_getAverageSize(){return this._metricsCache.averageChildSize||this._itemSize[this._sizeDim]}_estimatePosition(e){let t=this._metricsCache;if(this._first===-1||this._last===-1)return t.averageMarginSize+e*(t.averageMarginSize+this._getAverageSize());if(e<this._first){let i=this._first-e;return this._getPhysicalItem(this._first).pos-(t.getMarginSize(this._first-1)||t.averageMarginSize)-(i*t.averageChildSize+(i-1)*t.averageMarginSize)}else{let i=e-this._last;return this._getPhysicalItem(this._last).pos+(t.getChildSize(this._last)||t.averageChildSize)+(t.getMarginSize(this._last)||t.averageMarginSize)+i*(t.averageChildSize+t.averageMarginSize)}}_getPosition(e){let t=this._getPhysicalItem(e),{averageMarginSize:i}=this._metricsCache;return e===0?this._metricsCache.getMarginSize(0)??i:t?t.pos:this._estimatePosition(e)}_calculateAnchor(e,t){return e<=0?0:t>this._scrollSize-this._viewDim1?this.items.length-1:Math.max(0,Math.min(this.items.length-1,Math.floor((e+t)/2/this._delta)))}_getAnchor(e,t){if(this._physicalItems.size===0)return this._calculateAnchor(e,t);if(this._first<0)return this._calculateAnchor(e,t);if(this._last<0)return this._calculateAnchor(e,t);let i=this._getPhysicalItem(this._first),s=this._getPhysicalItem(this._last),n=i.pos;if(s.pos+this._metricsCache.getChildSize(this._last)<e)return this._calculateAnchor(e,t);if(n>t)return this._calculateAnchor(e,t);let l=this._firstVisible-1,h=-1/0;for(;h<e;)h=this._getPhysicalItem(++l).pos+this._metricsCache.getChildSize(l);return l}_getActiveItems(){this._viewDim1===0||this.items.length===0?this._clearItems():this._getItems()}_clearItems(){this._first=-1,this._last=-1,this._physicalMin=0,this._physicalMax=0;let e=this._newPhysicalItems;this._newPhysicalItems=this._physicalItems,this._newPhysicalItems.clear(),this._physicalItems=e,this._stable=!0}_getItems(){let e=this._newPhysicalItems;this._stable=!0;let t,i;if(this.pin!==null){let{index:h}=this.pin;this._anchorIdx=h,this._anchorPos=this._getPosition(h)}if(t=this._scrollPosition-this._overhang,i=this._scrollPosition+this._viewDim1+this._overhang,i<0||t>this._scrollSize){this._clearItems();return}(this._anchorIdx===null||this._anchorPos===null)&&(this._anchorIdx=this._getAnchor(t,i),this._anchorPos=this._getPosition(this._anchorIdx));let s=this._getSize(this._anchorIdx);s===void 0&&(this._stable=!1,s=this._getAverageSize());let n=this._metricsCache.getMarginSize(this._anchorIdx)??this._metricsCache.averageMarginSize,o=this._metricsCache.getMarginSize(this._anchorIdx+1)??this._metricsCache.averageMarginSize;this._anchorIdx===0&&(this._anchorPos=n),this._anchorIdx===this.items.length-1&&(this._anchorPos=this._scrollSize-o-s);let a=0;for(this._anchorPos+s+o<t&&(a=t-(this._anchorPos+s+o)),this._anchorPos-n>i&&(a=i-(this._anchorPos-n)),a&&(this._scrollPosition-=a,t-=a,i-=a,this._scrollError+=a),e.set(this._anchorIdx,{pos:this._anchorPos,size:s}),this._first=this._last=this._anchorIdx,this._physicalMin=this._anchorPos-n,this._physicalMax=this._anchorPos+s+o;this._physicalMin>t&&this._first>0;){let h=this._getSize(--this._first);h===void 0&&(this._stable=!1,h=this._getAverageSize());let u=this._metricsCache.getMarginSize(this._first);u===void 0&&(this._stable=!1,u=this._metricsCache.averageMarginSize),this._physicalMin-=h;let c=this._physicalMin;if(e.set(this._first,{pos:c,size:h}),this._physicalMin-=u,this._stable===!1&&this._estimate===!1)break}for(;this._physicalMax<i&&this._last<this.items.length-1;){let h=this._getSize(++this._last);h===void 0&&(this._stable=!1,h=this._getAverageSize());let u=this._metricsCache.getMarginSize(this._last);u===void 0&&(this._stable=!1,u=this._metricsCache.averageMarginSize);let c=this._physicalMax;if(e.set(this._last,{pos:c,size:h}),this._physicalMax+=h+u,!this._stable&&!this._estimate)break}let l=this._calculateError();l&&(this._physicalMin-=l,this._physicalMax-=l,this._anchorPos-=l,this._scrollPosition-=l,e.forEach(h=>h.pos-=l),this._scrollError+=l),this._stable&&(this._newPhysicalItems=this._physicalItems,this._newPhysicalItems.clear(),this._physicalItems=e)}_calculateError(){return this._first===0?this._physicalMin:this._physicalMin<=0?this._physicalMin-this._first*this._delta:this._last===this.items.length-1?this._physicalMax-this._scrollSize:this._physicalMax>=this._scrollSize?this._physicalMax-this._scrollSize+(this.items.length-1-this._last)*this._delta:0}_reflow(){let{_first:e,_last:t}=this;super._reflow(),(this._first===-1&&this._last==-1||this._first===e&&this._last===t)&&this._resetReflowState()}_resetReflowState(){this._anchorIdx=null,this._anchorPos=null,this._stable=!0}_updateScrollSize(){let{averageMarginSize:e}=this._metricsCache;this._scrollSize=Math.max(1,this.items.length*(e+this._getAverageSize())+e)}get _delta(){let{averageMarginSize:e}=this._metricsCache;return this._getAverageSize()+e}_getItemPosition(e){return{[this._positionDim]:this._getPosition(e),[this._secondaryPositionDim]:0,[Ti(this.direction)]:-(this._metricsCache.getLeadingMarginValue(e,this.direction)??this._metricsCache.averageMarginSize)}}_getItemSize(e){return{[this._sizeDim]:this._getSize(e)||this._getAverageSize(),[this._secondarySizeDim]:this._itemSize[this._secondarySizeDim]}}_viewDim2Changed(){this._metricsCache.clear(),this._scheduleReflow()}}});var Ri={};he(Ri,{YatlChangeEvent:()=>Q,YatlColumnReorderEvent:()=>Z,YatlColumnResizeEvent:()=>J,YatlColumnToggleEvent:()=>X,YatlEvent:()=>E,YatlRowClickEvent:()=>q,YatlSearchEvent:()=>jt,YatlSortEvent:()=>G,YatlTable:()=>m,createRegexTokenizer:()=>Gt,findColumn:()=>b,whitespaceTokenizer:()=>Xt});var E=class extends CustomEvent{constructor(e,t,i={}){super(e,{bubbles:!0,composed:!0,cancelable:!1,...i,detail:t})}},ft=class ft extends E{constructor(e,t,i,s){super(ft.EVENT_NAME,{row:e,index:t,field:i,originalEvent:s})}};ft.EVENT_NAME="yatl-row-click";var q=ft,pt=class pt extends E{constructor(e){super(pt.EVENT_NAME,{data:e})}};pt.EVENT_NAME="yatl-change";var Q=pt,mt=class mt extends E{constructor(e,t){super(mt.EVENT_NAME,{field:e,order:t},{cancelable:!0})}};mt.EVENT_NAME="yatl-sort";var G=mt,_t=class _t extends E{constructor(e,t){super(_t.EVENT_NAME,{field:e,visible:t},{cancelable:!0})}};_t.EVENT_NAME="yatl-column-toggle";var X=_t,gt=class gt extends E{constructor(e,t){super(gt.EVENT_NAME,{field:e,width:t})}};gt.EVENT_NAME="yatl-column-resize";var J=gt,yt=class yt extends E{constructor(e,t,i){super(yt.EVENT_NAME,{draggedColumn:e,droppedColumn:t,order:i},{cancelable:!0})}};yt.EVENT_NAME="yatl-column-reorder";var Z=yt,bt=class bt extends E{constructor(e){super(bt.EVENT_NAME,{query:e})}};bt.EVENT_NAME="yatl-search";var jt=bt;var vt=globalThis,St=vt.ShadowRoot&&(vt.ShadyCSS===void 0||vt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ut=Symbol(),ce=new WeakMap,Y=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==Ut)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(St&&e===void 0){let i=t!==void 0&&t.length===1;i&&(e=ce.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&ce.set(t,e))}return e}toString(){return this.cssText}},ue=r=>new Y(typeof r=="string"?r:r+"",void 0,Ut),Ft=(r,...e)=>{let t=r.length===1?r[0]:e.reduce((i,s,n)=>i+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+r[n+1],r[0]);return new Y(t,r,Ut)},de=(r,e)=>{if(St)r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let i=document.createElement("style"),s=vt.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,r.appendChild(i)}},Ht=St?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(let i of e.cssRules)t+=i.cssText;return ue(t)})(r):r;var{is:ri,defineProperty:ni,getOwnPropertyDescriptor:oi,getOwnPropertyNames:ai,getOwnPropertySymbols:li,getPrototypeOf:hi}=Object,R=globalThis,fe=R.trustedTypes,ci=fe?fe.emptyScript:"",ui=R.reactiveElementPolyfillSupport,tt=(r,e)=>r,et={toAttribute(r,e){switch(e){case Boolean:r=r?ci:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,e){let t=r;switch(e){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r)}catch{t=null}}return t}},wt=(r,e)=>!ri(r,e),pe={attribute:!0,type:String,converter:et,reflect:!1,useDefault:!1,hasChanged:wt};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),R.litPropertyMetadata??(R.litPropertyMetadata=new WeakMap);var z=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=pe){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let i=Symbol(),s=this.getPropertyDescriptor(e,i,t);s!==void 0&&ni(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){let{get:s,set:n}=oi(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:s,set(o){let a=s?.call(this);n?.call(this,o),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??pe}static _$Ei(){if(this.hasOwnProperty(tt("elementProperties")))return;let e=hi(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(tt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(tt("properties"))){let t=this.properties,i=[...ai(t),...li(t)];for(let s of i)this.createProperty(s,t[s])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[i,s]of t)this.elementProperties.set(i,s)}this._$Eh=new Map;for(let[t,i]of this.elementProperties){let s=this._$Eu(t,i);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let i=new Set(e.flat(1/0).reverse());for(let s of i)t.unshift(Ht(s))}else e!==void 0&&t.push(Ht(e));return t}static _$Eu(e,t){let i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return de(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){let i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(s!==void 0&&i.reflect===!0){let n=(i.converter?.toAttribute!==void 0?i.converter:et).toAttribute(t,i.type);this._$Em=e,n==null?this.removeAttribute(s):this.setAttribute(s,n),this._$Em=null}}_$AK(e,t){let i=this.constructor,s=i._$Eh.get(e);if(s!==void 0&&this._$Em!==s){let n=i.getPropertyOptions(s),o=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute!==void 0?n.converter:et;this._$Em=s;let a=o.fromAttribute(t,n.type);this[s]=a??this._$Ej?.get(s)??a,this._$Em=null}}requestUpdate(e,t,i,s=!1,n){if(e!==void 0){let o=this.constructor;if(s===!1&&(n=this[e]),i??(i=o.getPropertyOptions(e)),!((i.hasChanged??wt)(n,t)||i.useDefault&&i.reflect&&n===this._$Ej?.get(e)&&!this.hasAttribute(o._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:n},o){i&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,o??t??this[e]),n!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),s===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[s,n]of this._$Ep)this[s]=n;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[s,n]of i){let{wrapped:o}=n,a=this[s];o!==!0||this._$AL.has(s)||a===void 0||this.C(s,void 0,n,a)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(t)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(t=>this._$ET(t,this[t]))),this._$EM()}updated(e){}firstUpdated(e){}};z.elementStyles=[],z.shadowRootOptions={mode:"open"},z[tt("elementProperties")]=new Map,z[tt("finalized")]=new Map,ui?.({ReactiveElement:z}),(R.reactiveElementVersions??(R.reactiveElementVersions=[])).push("2.1.2");var st=globalThis,me=r=>r,Et=st.trustedTypes,_e=Et?Et.createPolicy("lit-html",{createHTML:r=>r}):void 0,Kt="$lit$",A=`lit$${Math.random().toFixed(9).slice(2)}$`,Wt="?"+A,di=`<${Wt}>`,L=document,rt=()=>L.createComment(""),nt=r=>r===null||typeof r!="object"&&typeof r!="function",qt=Array.isArray,we=r=>qt(r)||typeof r?.[Symbol.iterator]=="function",Bt=`[
2
+ \f\r]`,it=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ge=/-->/g,ye=/>/g,k=RegExp(`>|${Bt}(?:([^\\s"'>=/]+)(${Bt}*=${Bt}*(?:[^
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),be=/'/g,ve=/"/g,Ee=/^(?:script|style|textarea|title)$/i,Qt=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),v=Qt(1),ji=Qt(2),Ui=Qt(3),w=Symbol.for("lit-noChange"),_=Symbol.for("lit-nothing"),Se=new WeakMap,D=L.createTreeWalker(L,129);function Ce(r,e){if(!qt(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return _e!==void 0?_e.createHTML(e):e}var xe=(r,e)=>{let t=r.length-1,i=[],s,n=e===2?"<svg>":e===3?"<math>":"",o=it;for(let a=0;a<t;a++){let l=r[a],h,u,c=-1,d=0;for(;d<l.length&&(o.lastIndex=d,u=o.exec(l),u!==null);)d=o.lastIndex,o===it?u[1]==="!--"?o=ge:u[1]!==void 0?o=ye:u[2]!==void 0?(Ee.test(u[2])&&(s=RegExp("</"+u[2],"g")),o=k):u[3]!==void 0&&(o=k):o===k?u[0]===">"?(o=s??it,c=-1):u[1]===void 0?c=-2:(c=o.lastIndex-u[2].length,h=u[1],o=u[3]===void 0?k:u[3]==='"'?ve:be):o===ve||o===be?o=k:o===ge||o===ye?o=it:(o=k,s=void 0);let f=o===k&&r[a+1].startsWith("/>")?" ":"";n+=o===it?l+di:c>=0?(i.push(h),l.slice(0,c)+Kt+l.slice(c)+A+f):l+A+(c===-2?a:f)}return[Ce(r,n+(r[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]},ot=class r{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let n=0,o=0,a=e.length-1,l=this.parts,[h,u]=xe(e,t);if(this.el=r.createElement(h,i),D.currentNode=this.el.content,t===2||t===3){let c=this.el.content.firstChild;c.replaceWith(...c.childNodes)}for(;(s=D.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(let c of s.getAttributeNames())if(c.endsWith(Kt)){let d=u[o++],f=s.getAttribute(c).split(A),g=/([.?@])?(.*)/.exec(d);l.push({type:1,index:n,name:g[2],strings:f,ctor:g[1]==="."?xt:g[1]==="?"?Tt:g[1]==="@"?$t:N}),s.removeAttribute(c)}else c.startsWith(A)&&(l.push({type:6,index:n}),s.removeAttribute(c));if(Ee.test(s.tagName)){let c=s.textContent.split(A),d=c.length-1;if(d>0){s.textContent=Et?Et.emptyScript:"";for(let f=0;f<d;f++)s.append(c[f],rt()),D.nextNode(),l.push({type:2,index:++n});s.append(c[d],rt())}}}else if(s.nodeType===8)if(s.data===Wt)l.push({type:2,index:n});else{let c=-1;for(;(c=s.data.indexOf(A,c+1))!==-1;)l.push({type:7,index:n}),c+=A.length-1}n++}}static createElement(e,t){let i=L.createElement("template");return i.innerHTML=e,i}};function V(r,e,t=r,i){if(e===w)return e;let s=i!==void 0?t._$Co?.[i]:t._$Cl,n=nt(e)?void 0:e._$litDirective$;return s?.constructor!==n&&(s?._$AO?.(!1),n===void 0?s=void 0:(s=new n(r),s._$AT(r,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=s:t._$Cl=s),s!==void 0&&(e=V(r,s._$AS(r,e.values),s,i)),e}var Ct=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:i}=this._$AD,s=(e?.creationScope??L).importNode(t,!0);D.currentNode=s;let n=D.nextNode(),o=0,a=0,l=i[0];for(;l!==void 0;){if(o===l.index){let h;l.type===2?h=new U(n,n.nextSibling,this,e):l.type===1?h=new l.ctor(n,l.name,l.strings,this,e):l.type===6&&(h=new zt(n,this,e)),this._$AV.push(h),l=i[++a]}o!==l?.index&&(n=D.nextNode(),o++)}return D.currentNode=L,s}p(e){let t=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}},U=class r{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=_,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=V(this,e,t),nt(e)?e===_||e==null||e===""?(this._$AH!==_&&this._$AR(),this._$AH=_):e!==this._$AH&&e!==w&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):we(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==_&&nt(this._$AH)?this._$AA.nextSibling.data=e:this.T(L.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=ot.createElement(Ce(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{let n=new Ct(s,this),o=n.u(this.options);n.p(t),this.T(o),this._$AH=n}}_$AC(e){let t=Se.get(e.strings);return t===void 0&&Se.set(e.strings,t=new ot(e)),t}k(e){qt(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,i,s=0;for(let n of e)s===t.length?t.push(i=new r(this.O(rt()),this.O(rt()),this,this.options)):i=t[s],i._$AI(n),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let i=me(e).nextSibling;me(e).remove(),e=i}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},N=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,n){this.type=1,this._$AH=_,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=n,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=_}_$AI(e,t=this,i,s){let n=this.strings,o=!1;if(n===void 0)e=V(this,e,t,0),o=!nt(e)||e!==this._$AH&&e!==w,o&&(this._$AH=e);else{let a=e,l,h;for(e=n[0],l=0;l<n.length-1;l++)h=V(this,a[i+l],t,l),h===w&&(h=this._$AH[l]),o||(o=!nt(h)||h!==this._$AH[l]),h===_?e=_:e!==_&&(e+=(h??"")+n[l+1]),this._$AH[l]=h}o&&!s&&this.j(e)}j(e){e===_?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},xt=class extends N{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===_?void 0:e}},Tt=class extends N{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==_)}},$t=class extends N{constructor(e,t,i,s,n){super(e,t,i,s,n),this.type=5}_$AI(e,t=this){if((e=V(this,e,t,0)??_)===w)return;let i=this._$AH,s=e===_&&i!==_||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,n=e!==_&&(i===_||s);s&&this.element.removeEventListener(this.name,this,i),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},zt=class{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){V(this,e)}},Te={M:Kt,P:A,A:Wt,C:1,L:xe,R:Ct,D:we,V,I:U,H:N,N:Tt,U:$t,B:xt,F:zt},fi=st.litHtmlPolyfillSupport;fi?.(ot,U),(st.litHtmlVersions??(st.litHtmlVersions=[])).push("3.3.2");var $e=(r,e,t)=>{let i=t?.renderBefore??e,s=i._$litPart$;if(s===void 0){let n=t?.renderBefore??null;i._$litPart$=s=new U(e.insertBefore(rt(),n),n,void 0,t??{})}return s._$AI(r),s};var at=globalThis,C=class extends z{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;let e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=$e(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return w}};C._$litElement$=!0,C.finalized=!0,at.litElementHydrateSupport?.({LitElement:C});var pi=at.litElementPolyfillSupport;pi?.({LitElement:C});(at.litElementVersions??(at.litElementVersions=[])).push("4.2.2");var ze=r=>r.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,e=>e.toUpperCase()),Gt=(r="\\S+")=>{let e=new RegExp(`"[^"]*"|${r}`,"g");return t=>(t.match(e)||[]).map(s=>(s=s.toLocaleLowerCase().trim(),s.startsWith('"')&&s.endsWith('"')?{value:s.slice(1,-1),quoted:!0}:{value:s,quoted:!1}))},Xt=Gt();function mi(r,e){return r in e}function M(r,e){let t=e.split("."),i=r;for(let s of t)if(i&&mi(s,i))i=i[s];else return;return i}function b(r,e){return e.find(t=>t.field===r)}function Ae(r,e){if(!r||!e||e.length===0)return r;let t=[...e].sort((a,l)=>a[0]-l[0]),i=[],s=t[0];for(let a=1;a<t.length;a++){let l=t[a];l[0]<s[1]?s[1]=Math.max(s[1],l[1]):(i.push(s),s=l)}i.push(s);let n=[],o=0;for(let[a,l]of i){let h=Math.max(0,Math.min(a,r.length)),u=Math.max(0,Math.min(l,r.length));h>o&&n.push(r.slice(o,h)),n.push(v`<mark class="highlight">${r.slice(h,u)}</mark>`),o=u}return o<r.length&&n.push(r.slice(o)),v`${n}`}function Jt(r,e="1fr"){return r.map(t=>t?`${t}px`:e)}function Me(r,e){if(!e)return!0;let t=new Set([...e.map(i=>i.field),...r.map(i=>i.field)]);for(let i of t){let s=b(i,e)?.sortState,n=b(i,r)?.sortState;if(s?.order!==n?.order||s?.priority!==n?.priority)return!0}return!1}function Oe(r){return typeof r=="string"||typeof r=="number"||typeof r=="boolean"||r instanceof Date}var Pe=r=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(r,e)}):customElements.define(r,e)};var _i={attribute:!0,type:String,converter:et,reflect:!1,hasChanged:wt},gi=(r=_i,e,t)=>{let{kind:i,metadata:s}=t,n=globalThis.litPropertyMetadata.get(s);if(n===void 0&&globalThis.litPropertyMetadata.set(s,n=new Map),i==="setter"&&((r=Object.create(r)).wrapped=!0),n.set(t.name,r),i==="accessor"){let{name:o}=t;return{set(a){let l=e.get.call(this);e.set.call(this,a),this.requestUpdate(o,l,r,!0,a)},init(a){return a!==void 0&&this.C(o,void 0,r,a),a}}}if(i==="setter"){let{name:o}=t;return function(a){let l=this[o];e.call(this,a),this.requestUpdate(o,l,r,!0,a)}}throw Error("Unsupported decorator location: "+i)};function p(r){return(e,t)=>typeof t=="object"?gi(r,e,t):((i,s,n)=>{let o=s.hasOwnProperty(n);return s.constructor.createProperty(n,i),o?Object.getOwnPropertyDescriptor(s,n):void 0})(r,e,t)}function Re(r){return p({...r,state:!0,attribute:!1})}var j=(r,e,t)=>(t.configurable=!0,t.enumerable=!0,Reflect.decorate&&typeof e!="object"&&Object.defineProperty(r,e,t),t);function Zt(r,e){return(t,i,s)=>{let n=o=>o.renderRoot?.querySelector(r)??null;if(e){let{get:o,set:a}=typeof i=="object"?t:s??(()=>{let l=Symbol();return{get(){return this[l]},set(h){this[l]=h}}})();return j(t,i,{get(){let l=o.call(this);return l===void 0&&(l=n(this),(l!==null||this.hasUpdated)&&a.call(this,l)),l}})}return j(t,i,{get(){return n(this)}})}}var T={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},O=r=>(...e)=>({_$litDirective$:r,values:e}),x=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};var Yt=O(class extends x{constructor(r){if(super(r),r.type!==T.ATTRIBUTE||r.name!=="class"||r.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(r){return" "+Object.keys(r).filter(e=>r[e]).join(" ")+" "}update(r,[e]){if(this.st===void 0){this.st=new Set,r.strings!==void 0&&(this.nt=new Set(r.strings.join(" ").split(/\s/).filter(i=>i!=="")));for(let i in e)e[i]&&!this.nt?.has(i)&&this.st.add(i);return this.render(e)}let t=r.element.classList;for(let i of this.st)i in e||(t.remove(i),this.st.delete(i));for(let i in e){let s=!!e[i];s===this.st.has(i)||this.nt?.has(i)||(s?(t.add(i),this.st.add(i)):(t.remove(i),this.st.delete(i)))}return w}});var te=r=>r??_;var{I:yi}=Te,Ie=r=>r;var De=r=>r.strings===void 0,ke=()=>document.createComment(""),F=(r,e,t)=>{let i=r._$AA.parentNode,s=e===void 0?r._$AB:e._$AA;if(t===void 0){let n=i.insertBefore(ke(),s),o=i.insertBefore(ke(),s);t=new yi(n,o,r,r.options)}else{let n=t._$AB.nextSibling,o=t._$AM,a=o!==r;if(a){let l;t._$AQ?.(r),t._$AM=r,t._$AP!==void 0&&(l=r._$AU)!==o._$AU&&t._$AP(l)}if(n!==s||a){let l=t._$AA;for(;l!==n;){let h=Ie(l).nextSibling;Ie(i).insertBefore(l,s),l=h}}}return t},I=(r,e,t=r)=>(r._$AI(e,t),r),bi={},Le=(r,e=bi)=>r._$AH=e,Ve=r=>r._$AH,At=r=>{r._$AR(),r._$AA.remove()};var Ne=(r,e,t)=>{let i=new Map;for(let s=e;s<=t;s++)i.set(r[s],s);return i},Mt=O(class extends x{constructor(r){if(super(r),r.type!==T.CHILD)throw Error("repeat() can only be used in text expressions")}dt(r,e,t){let i;t===void 0?t=e:e!==void 0&&(i=e);let s=[],n=[],o=0;for(let a of r)s[o]=i?i(a,o):o,n[o]=t(a,o),o++;return{values:n,keys:s}}render(r,e,t){return this.dt(r,e,t).values}update(r,[e,t,i]){let s=Ve(r),{values:n,keys:o}=this.dt(e,t,i);if(!Array.isArray(s))return this.ut=o,n;let a=this.ut??(this.ut=[]),l=[],h,u,c=0,d=s.length-1,f=0,g=n.length-1;for(;c<=d&&f<=g;)if(s[c]===null)c++;else if(s[d]===null)d--;else if(a[c]===o[f])l[f]=I(s[c],n[f]),c++,f++;else if(a[d]===o[g])l[g]=I(s[d],n[g]),d--,g--;else if(a[c]===o[g])l[g]=I(s[c],n[g]),F(r,l[g+1],s[c]),c++,g--;else if(a[d]===o[f])l[f]=I(s[d],n[f]),F(r,s[c],s[d]),d--,f++;else if(h===void 0&&(h=Ne(o,f,g),u=Ne(a,c,d)),h.has(a[c]))if(h.has(a[d])){let S=u.get(o[f]),W=S!==void 0?s[S]:null;if(W===null){let $=F(r,s[c]);I($,n[f]),l[f]=$}else l[f]=I(W,n[f]),F(r,s[c],W),s[S]=null;f++}else At(s[d]),d--;else At(s[c]),c++;for(;f<=g;){let S=F(r,l[g+1]);I(S,n[f]),l[f++]=S}for(;c<=d;){let S=s[c++];S!==null&&At(S)}return this.ut=o,Le(r,l),w}});var je="important",vi=" !"+je,Ue=O(class extends x{constructor(r){if(super(r),r.type!==T.ATTRIBUTE||r.name!=="style"||r.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(r){return Object.keys(r).reduce((e,t)=>{let i=r[t];return i==null?e:e+`${t=t.includes("-")?t:t.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(r,[e]){let{style:t}=r.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(e)),this.render(e);for(let i of this.ft)e[i]==null&&(this.ft.delete(i),i.includes("-")?t.removeProperty(i):t[i]=null);for(let i in e){let s=e[i];if(s!=null){this.ft.add(i);let n=typeof s=="string"&&s.endsWith(vi);i.includes("-")||n?t.setProperty(i,n?s.slice(0,-11):s,n?je:""):t[i]=s}}return w}});function H(r,e,t,i){var s=arguments.length,n=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(r,e,t,i);else for(var a=r.length-1;a>=0;a--)(o=r[a])&&(n=(s<3?o(n):s>3?o(e,t,n):o(e,t))||n);return s>3&&n&&Object.defineProperty(e,t,n),n}var lt=(r,e)=>{let t=r._$AN;if(t===void 0)return!1;for(let i of t)i._$AO?.(e,!1),lt(i,e);return!0},Ot=r=>{let e,t;do{if((e=r._$AM)===void 0)break;t=e._$AN,t.delete(r),r=e}while(t?.size===0)},Fe=r=>{for(let e;e=r._$AM;r=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(r))break;t.add(r),Ei(e)}};function Si(r){this._$AN!==void 0?(Ot(this),this._$AM=r,Fe(this)):this._$AM=r}function wi(r,e=!1,t=0){let i=this._$AH,s=this._$AN;if(s!==void 0&&s.size!==0)if(e)if(Array.isArray(i))for(let n=t;n<i.length;n++)lt(i[n],!1),Ot(i[n]);else i!=null&&(lt(i,!1),Ot(i));else lt(this,r)}var Ei=r=>{r.type==T.CHILD&&(r._$AP??(r._$AP=wi),r._$AQ??(r._$AQ=Si))},Pt=class extends x{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,i){super._$AT(e,t,i),Fe(this),this.isConnected=e._$AU}_$AO(e,t=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),t&&(lt(this,e),Ot(this))}setValue(e){if(De(this._$Ct))this._$Ct._$AI(e,this);else{let t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}};var B=class r extends Event{constructor(e){super(r.eventName,{bubbles:!1}),this.first=e.first,this.last=e.last}};B.eventName="rangeChanged";var K=class r extends Event{constructor(e){super(r.eventName,{bubbles:!1}),this.first=e.first,this.last=e.last}};K.eventName="visibilityChanged";var ht=class r extends Event{constructor(){super(r.eventName,{bubbles:!1})}};ht.eventName="unpinned";var ee=class{constructor(e){this._element=null;let t=e??window;this._node=t,e&&(this._element=e)}get element(){return this._element||document.scrollingElement||document.documentElement}get scrollTop(){return this.element.scrollTop||window.scrollY}get scrollLeft(){return this.element.scrollLeft||window.scrollX}get scrollHeight(){return this.element.scrollHeight}get scrollWidth(){return this.element.scrollWidth}get viewportHeight(){return this._element?this._element.getBoundingClientRect().height:window.innerHeight}get viewportWidth(){return this._element?this._element.getBoundingClientRect().width:window.innerWidth}get maxScrollTop(){return this.scrollHeight-this.viewportHeight}get maxScrollLeft(){return this.scrollWidth-this.viewportWidth}},Rt=class extends ee{constructor(e,t){super(t),this._clients=new Set,this._retarget=null,this._end=null,this.__destination=null,this.correctingScrollError=!1,this._checkForArrival=this._checkForArrival.bind(this),this._updateManagedScrollTo=this._updateManagedScrollTo.bind(this),this.scrollTo=this.scrollTo.bind(this),this.scrollBy=this.scrollBy.bind(this);let i=this._node;this._originalScrollTo=i.scrollTo,this._originalScrollBy=i.scrollBy,this._originalScroll=i.scroll,this._attach(e)}get _destination(){return this.__destination}get scrolling(){return this._destination!==null}scrollTo(e,t){let i=typeof e=="number"&&typeof t=="number"?{left:e,top:t}:e;this._scrollTo(i)}scrollBy(e,t){let i=typeof e=="number"&&typeof t=="number"?{left:e,top:t}:e;i.top!==void 0&&(i.top+=this.scrollTop),i.left!==void 0&&(i.left+=this.scrollLeft),this._scrollTo(i)}_nativeScrollTo(e){this._originalScrollTo.bind(this._element||window)(e)}_scrollTo(e,t=null,i=null){this._end!==null&&this._end(),e.behavior==="smooth"?(this._setDestination(e),this._retarget=t,this._end=i):this._resetScrollState(),this._nativeScrollTo(e)}_setDestination(e){let{top:t,left:i}=e;return t=t===void 0?void 0:Math.max(0,Math.min(t,this.maxScrollTop)),i=i===void 0?void 0:Math.max(0,Math.min(i,this.maxScrollLeft)),this._destination!==null&&i===this._destination.left&&t===this._destination.top?!1:(this.__destination={top:t,left:i,behavior:"smooth"},!0)}_resetScrollState(){this.__destination=null,this._retarget=null,this._end=null}_updateManagedScrollTo(e){this._destination&&this._setDestination(e)&&this._nativeScrollTo(this._destination)}managedScrollTo(e,t,i){return this._scrollTo(e,t,i),this._updateManagedScrollTo}correctScrollError(e){this.correctingScrollError=!0,requestAnimationFrame(()=>requestAnimationFrame(()=>this.correctingScrollError=!1)),this._nativeScrollTo(e),this._retarget&&this._setDestination(this._retarget()),this._destination&&this._nativeScrollTo(this._destination)}_checkForArrival(){if(this._destination!==null){let{scrollTop:e,scrollLeft:t}=this,{top:i,left:s}=this._destination;i=Math.min(i||0,this.maxScrollTop),s=Math.min(s||0,this.maxScrollLeft);let n=Math.abs(i-e),o=Math.abs(s-t);n<1&&o<1&&(this._end&&this._end(),this._resetScrollState())}}detach(e){return this._clients.delete(e),this._clients.size===0&&(this._node.scrollTo=this._originalScrollTo,this._node.scrollBy=this._originalScrollBy,this._node.scroll=this._originalScroll,this._node.removeEventListener("scroll",this._checkForArrival)),null}_attach(e){this._clients.add(e),this._clients.size===1&&(this._node.scrollTo=this.scrollTo,this._node.scrollBy=this.scrollBy,this._node.scroll=this.scrollTo,this._node.addEventListener("scroll",this._checkForArrival))}};var Qe=typeof window<"u"?window.ResizeObserver:void 0;var ut=Symbol("virtualizerRef"),Dt="virtualizer-sizer",Ge,Vt=class{constructor(e){if(this._benchmarkStart=null,this._layout=null,this._clippingAncestors=[],this._scrollSize=null,this._scrollError=null,this._childrenPos=null,this._childMeasurements=null,this._toBeMeasured=new Map,this._rangeChanged=!0,this._itemsChanged=!0,this._visibilityChanged=!0,this._scrollerController=null,this._isScroller=!1,this._sizer=null,this._hostElementRO=null,this._childrenRO=null,this._mutationObserver=null,this._scrollEventListeners=[],this._scrollEventListenerOptions={passive:!0},this._loadListener=this._childLoaded.bind(this),this._scrollIntoViewTarget=null,this._updateScrollIntoViewCoordinates=null,this._items=[],this._first=-1,this._last=-1,this._firstVisible=-1,this._lastVisible=-1,this._scheduled=new WeakSet,this._measureCallback=null,this._measureChildOverride=null,this._layoutCompletePromise=null,this._layoutCompleteResolver=null,this._layoutCompleteRejecter=null,this._pendingLayoutComplete=null,this._layoutInitialized=null,this._connected=!1,!e)throw new Error("Virtualizer constructor requires a configuration object");if(e.hostElement)this._init(e);else throw new Error('Virtualizer configuration requires the "hostElement" property')}set items(e){Array.isArray(e)&&e!==this._items&&(this._itemsChanged=!0,this._items=e,this._schedule(this._updateLayout))}_init(e){this._isScroller=!!e.scroller,this._initHostElement(e);let t=e.layout||{};this._layoutInitialized=this._initLayout(t)}_initObservers(){this._mutationObserver=new MutationObserver(this._finishDOMUpdate.bind(this)),this._hostElementRO=new Qe(()=>this._hostElementSizeChanged()),this._childrenRO=new Qe(this._childrenSizeChanged.bind(this))}_initHostElement(e){let t=this._hostElement=e.hostElement;this._applyVirtualizerStyles(),t[ut]=this}connected(){this._initObservers();let e=this._isScroller;this._clippingAncestors=Mi(this._hostElement,e),this._scrollerController=new Rt(this,this._clippingAncestors[0]),this._schedule(this._updateLayout),this._observeAndListen(),this._connected=!0}_observeAndListen(){this._mutationObserver.observe(this._hostElement,{childList:!0}),this._hostElementRO.observe(this._hostElement),this._scrollEventListeners.push(window),window.addEventListener("scroll",this,this._scrollEventListenerOptions),this._clippingAncestors.forEach(e=>{e.addEventListener("scroll",this,this._scrollEventListenerOptions),this._scrollEventListeners.push(e),this._hostElementRO.observe(e)}),this._hostElementRO.observe(this._scrollerController.element),this._children.forEach(e=>this._childrenRO.observe(e)),this._scrollEventListeners.forEach(e=>e.addEventListener("scroll",this,this._scrollEventListenerOptions))}disconnected(){this._scrollEventListeners.forEach(e=>e.removeEventListener("scroll",this,this._scrollEventListenerOptions)),this._scrollEventListeners=[],this._clippingAncestors=[],this._scrollerController?.detach(this),this._scrollerController=null,this._mutationObserver?.disconnect(),this._mutationObserver=null,this._hostElementRO?.disconnect(),this._hostElementRO=null,this._childrenRO?.disconnect(),this._childrenRO=null,this._rejectLayoutCompletePromise("disconnected"),this._connected=!1}_applyVirtualizerStyles(){let t=this._hostElement.style;t.display=t.display||"block",t.position=t.position||"relative",t.contain=t.contain||"size layout",this._isScroller&&(t.overflow=t.overflow||"auto",t.minHeight=t.minHeight||"150px")}_getSizer(){let e=this._hostElement;if(!this._sizer){let t=e.querySelector(`[${Dt}]`);t||(t=document.createElement("div"),t.setAttribute(Dt,""),e.appendChild(t)),Object.assign(t.style,{position:"absolute",margin:"-2px 0 0 0",padding:0,visibility:"hidden",fontSize:"2px"}),t.textContent="&nbsp;",t.setAttribute(Dt,""),this._sizer=t}return this._sizer}async updateLayoutConfig(e){await this._layoutInitialized;let t=e.type||Ge;if(typeof t=="function"&&this._layout instanceof t){let i={...e};return delete i.type,this._layout.config=i,!0}return!1}async _initLayout(e){let t,i;if(typeof e.type=="function"){i=e.type;let s={...e};delete s.type,t=s}else t=e;i===void 0&&(Ge=i=(await Promise.resolve().then(()=>(qe(),We))).FlowLayout),this._layout=new i(s=>this._handleLayoutMessage(s),t),this._layout.measureChildren&&typeof this._layout.updateItemSizes=="function"&&(typeof this._layout.measureChildren=="function"&&(this._measureChildOverride=this._layout.measureChildren),this._measureCallback=this._layout.updateItemSizes.bind(this._layout)),this._layout.listenForChildLoadEvents&&this._hostElement.addEventListener("load",this._loadListener,!0),this._schedule(this._updateLayout)}startBenchmarking(){this._benchmarkStart===null&&(this._benchmarkStart=window.performance.now())}stopBenchmarking(){if(this._benchmarkStart!==null){let e=window.performance.now(),t=e-this._benchmarkStart,s=performance.getEntriesByName("uv-virtualizing","measure").filter(n=>n.startTime>=this._benchmarkStart&&n.startTime<e).reduce((n,o)=>n+o.duration,0);return this._benchmarkStart=null,{timeElapsed:t,virtualizationTime:s}}return null}_measureChildren(){let e={},t=this._children,i=this._measureChildOverride||this._measureChild;for(let s=0;s<t.length;s++){let n=t[s],o=this._first+s;(this._itemsChanged||this._toBeMeasured.has(n))&&(e[o]=i.call(this,n,this._items[o]))}this._childMeasurements=e,this._schedule(this._updateLayout),this._toBeMeasured.clear()}_measureChild(e){let{width:t,height:i}=e.getBoundingClientRect();return Object.assign({width:t,height:i},zi(e))}async _schedule(e){this._scheduled.has(e)||(this._scheduled.add(e),await Promise.resolve(),this._scheduled.delete(e),e.call(this))}async _updateDOM(e){this._scrollSize=e.scrollSize,this._adjustRange(e.range),this._childrenPos=e.childPositions,this._scrollError=e.scrollError||null;let{_rangeChanged:t,_itemsChanged:i}=this;this._visibilityChanged&&(this._notifyVisibility(),this._visibilityChanged=!1),(t||i)&&(this._notifyRange(),this._rangeChanged=!1),this._finishDOMUpdate()}_finishDOMUpdate(){this._connected&&(this._children.forEach(e=>this._childrenRO.observe(e)),this._checkScrollIntoViewTarget(this._childrenPos),this._positionChildren(this._childrenPos),this._sizeHostElement(this._scrollSize),this._correctScrollError(),this._benchmarkStart&&"mark"in window.performance&&window.performance.mark("uv-end"))}_updateLayout(){this._layout&&this._connected&&(this._layout.items=this._items,this._updateView(),this._childMeasurements!==null&&(this._measureCallback&&this._measureCallback(this._childMeasurements),this._childMeasurements=null),this._layout.reflowIfNeeded(),this._benchmarkStart&&"mark"in window.performance&&window.performance.mark("uv-end"))}_handleScrollEvent(){if(this._benchmarkStart&&"mark"in window.performance){try{window.performance.measure("uv-virtualizing","uv-start","uv-end")}catch(e){console.warn("Error measuring performance data: ",e)}window.performance.mark("uv-start")}this._scrollerController.correctingScrollError===!1&&this._layout?.unpin(),this._schedule(this._updateLayout)}handleEvent(e){switch(e.type){case"scroll":(e.currentTarget===window||this._clippingAncestors.includes(e.currentTarget))&&this._handleScrollEvent();break;default:console.warn("event not handled",e)}}_handleLayoutMessage(e){e.type==="stateChanged"?this._updateDOM(e):e.type==="visibilityChanged"?(this._firstVisible=e.firstVisible,this._lastVisible=e.lastVisible,this._notifyVisibility()):e.type==="unpinned"&&this._hostElement.dispatchEvent(new ht)}get _children(){let e=[],t=this._hostElement.firstElementChild;for(;t;)t.hasAttribute(Dt)||e.push(t),t=t.nextElementSibling;return e}_updateView(){let e=this._hostElement,t=this._scrollerController?.element,i=this._layout;if(e&&t&&i){let s,n,o,a,l=e.getBoundingClientRect();s=0,n=0,o=window.innerHeight,a=window.innerWidth;let h=this._clippingAncestors.map($=>$.getBoundingClientRect());h.unshift(l);for(let $ of h)s=Math.max(s,$.top),n=Math.max(n,$.left),o=Math.min(o,$.bottom),a=Math.min(a,$.right);let u=t.getBoundingClientRect(),c={left:l.left-u.left,top:l.top-u.top},d={width:t.scrollWidth,height:t.scrollHeight},f=s-l.top+e.scrollTop,g=n-l.left+e.scrollLeft,S=Math.max(0,o-s),W=Math.max(0,a-n);i.viewportSize={width:W,height:S},i.viewportScroll={top:f,left:g},i.totalScrollSize=d,i.offsetWithinScroller=c}}_sizeHostElement(e){let i=e&&e.width!==null?Math.min(82e5,e.width):0,s=e&&e.height!==null?Math.min(82e5,e.height):0;if(this._isScroller)this._getSizer().style.transform=`translate(${i}px, ${s}px)`;else{let n=this._hostElement.style;n.minWidth=i?`${i}px`:"100%",n.minHeight=s?`${s}px`:"100%"}}_positionChildren(e){e&&e.forEach(({top:t,left:i,width:s,height:n,xOffset:o,yOffset:a},l)=>{let h=this._children[l-this._first];h&&(h.style.position="absolute",h.style.boxSizing="border-box",h.style.transform=`translate(${i}px, ${t}px)`,s!==void 0&&(h.style.width=s+"px"),n!==void 0&&(h.style.height=n+"px"),h.style.left=o===void 0?null:o+"px",h.style.top=a===void 0?null:a+"px")})}async _adjustRange(e){let{_first:t,_last:i,_firstVisible:s,_lastVisible:n}=this;this._first=e.first,this._last=e.last,this._firstVisible=e.firstVisible,this._lastVisible=e.lastVisible,this._rangeChanged=this._rangeChanged||this._first!==t||this._last!==i,this._visibilityChanged=this._visibilityChanged||this._firstVisible!==s||this._lastVisible!==n}_correctScrollError(){if(this._scrollError){let{scrollTop:e,scrollLeft:t}=this._scrollerController,{top:i,left:s}=this._scrollError;this._scrollError=null,this._scrollerController.correctScrollError({top:e-i,left:t-s})}}element(e){return e===1/0&&(e=this._items.length-1),this._items?.[e]===void 0?void 0:{scrollIntoView:(t={})=>this._scrollElementIntoView({...t,index:e})}}_scrollElementIntoView(e){if(e.index>=this._first&&e.index<=this._last)this._children[e.index-this._first].scrollIntoView(e);else if(e.index=Math.min(e.index,this._items.length-1),e.behavior==="smooth"){let t=this._layout.getScrollIntoViewCoordinates(e),{behavior:i}=e;this._updateScrollIntoViewCoordinates=this._scrollerController.managedScrollTo(Object.assign(t,{behavior:i}),()=>this._layout.getScrollIntoViewCoordinates(e),()=>this._scrollIntoViewTarget=null),this._scrollIntoViewTarget=e}else this._layout.pin=e}_checkScrollIntoViewTarget(e){let{index:t}=this._scrollIntoViewTarget||{};t&&e?.has(t)&&this._updateScrollIntoViewCoordinates(this._layout.getScrollIntoViewCoordinates(this._scrollIntoViewTarget))}_notifyRange(){this._hostElement.dispatchEvent(new B({first:this._first,last:this._last}))}_notifyVisibility(){this._hostElement.dispatchEvent(new K({first:this._firstVisible,last:this._lastVisible}))}get layoutComplete(){return this._layoutCompletePromise||(this._layoutCompletePromise=new Promise((e,t)=>{this._layoutCompleteResolver=e,this._layoutCompleteRejecter=t})),this._layoutCompletePromise}_rejectLayoutCompletePromise(e){this._layoutCompleteRejecter!==null&&this._layoutCompleteRejecter(e),this._resetLayoutCompleteState()}_scheduleLayoutComplete(){this._layoutCompletePromise&&this._pendingLayoutComplete===null&&(this._pendingLayoutComplete=requestAnimationFrame(()=>requestAnimationFrame(()=>this._resolveLayoutCompletePromise())))}_resolveLayoutCompletePromise(){this._layoutCompleteResolver!==null&&this._layoutCompleteResolver(),this._resetLayoutCompleteState()}_resetLayoutCompleteState(){this._layoutCompletePromise=null,this._layoutCompleteResolver=null,this._layoutCompleteRejecter=null,this._pendingLayoutComplete=null}_hostElementSizeChanged(){this._schedule(this._updateLayout)}_childLoaded(){}_childrenSizeChanged(e){if(this._layout?.measureChildren){for(let t of e)this._toBeMeasured.set(t.target,t.contentRect);this._measureChildren()}this._scheduleLayoutComplete(),this._itemsChanged=!1,this._rangeChanged=!1}};function zi(r){let e=window.getComputedStyle(r);return{marginTop:Lt(e.marginTop),marginRight:Lt(e.marginRight),marginBottom:Lt(e.marginBottom),marginLeft:Lt(e.marginLeft)}}function Lt(r){let e=r?parseFloat(r):NaN;return Number.isNaN(e)?0:e}function Xe(r){if(r.assignedSlot!==null)return r.assignedSlot;if(r.parentElement!==null)return r.parentElement;let e=r.parentNode;return e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&e.host||null}function Ai(r,e=!1){let t=[],i=e?r:Xe(r);for(;i!==null;)t.push(i),i=Xe(i);return t}function Mi(r,e=!1){let t=!1;return Ai(r,e).filter(i=>{if(t)return!1;let s=getComputedStyle(i);return t=s.position==="fixed",s.overflow!=="visible"})}var ne=r=>r,oe=(r,e)=>v`${e}: ${JSON.stringify(r,null,2)}`,re=class extends Pt{constructor(e){if(super(e),this._virtualizer=null,this._first=0,this._last=-1,this._renderItem=(t,i)=>oe(t,i+this._first),this._keyFunction=(t,i)=>ne(t,i+this._first),this._items=[],e.type!==T.CHILD)throw new Error("The virtualize directive can only be used in child expressions")}render(e){e&&this._setFunctions(e);let t=[];if(this._first>=0&&this._last>=this._first)for(let i=this._first;i<=this._last;i++)t.push(this._items[i]);return Mt(t,this._keyFunction,this._renderItem)}update(e,[t]){this._setFunctions(t);let i=this._items!==t.items;return this._items=t.items||[],this._virtualizer?this._updateVirtualizerConfig(e,t):this._initialize(e,t),i?w:this.render()}async _updateVirtualizerConfig(e,t){if(!await this._virtualizer.updateLayoutConfig(t.layout||{})){let s=e.parentNode;this._makeVirtualizer(s,t)}this._virtualizer.items=this._items}_setFunctions(e){let{renderItem:t,keyFunction:i}=e;t&&(this._renderItem=(s,n)=>t(s,n+this._first)),i&&(this._keyFunction=(s,n)=>i(s,n+this._first))}_makeVirtualizer(e,t){this._virtualizer&&this._virtualizer.disconnected();let{layout:i,scroller:s,items:n}=t;this._virtualizer=new Vt({hostElement:e,layout:i,scroller:s}),this._virtualizer.items=n,this._virtualizer.connected()}_initialize(e,t){let i=e.parentNode;i&&i.nodeType===1&&(i.addEventListener("rangeChanged",s=>{this._first=s.first,this._last=s.last,this.setValue(this.render())}),this._makeVirtualizer(i,t))}disconnected(){this._virtualizer?.disconnected()}reconnected(){this._virtualizer?.connected()}},Je=O(re);var P=class extends C{constructor(){super(...arguments),this.items=[],this.renderItem=oe,this.keyFunction=ne,this.layout={},this.scroller=!1}createRenderRoot(){return this}render(){let{items:e,renderItem:t,keyFunction:i,layout:s,scroller:n}=this;return v`${Je({items:e,renderItem:t,keyFunction:i,layout:s,scroller:n})}`}element(e){return this[ut]?.element(e)}get layoutComplete(){return this[ut]?.layoutComplete}scrollToIndex(e,t="start"){this.element(e)?.scrollIntoView({block:t})}};H([p({attribute:!1})],P.prototype,"items",void 0);H([p()],P.prototype,"renderItem",void 0);H([p()],P.prototype,"keyFunction",void 0);H([p({attribute:!1})],P.prototype,"layout",void 0);H([p({reflect:!0,type:Boolean})],P.prototype,"scroller",void 0);customElements.define("lit-virtualizer",P);var Ze=Ft`
4
+ /* Style declarations */
5
+ :host {
6
+ /* Typography */
7
+ --yatl-font-family: var(
8
+ --yatl-table-font,
9
+ -apple-system,
10
+ BlinkMacSystemFont,
11
+ 'Segoe UI',
12
+ Roboto,
13
+ Helvetica,
14
+ Arial,
15
+ sans-serif,
16
+ 'Apple Color Emoji',
17
+ 'Segoe UI Emoji'
18
+ );
19
+ --yatl-font-size: var(--yatl-table-font-size, 0.875rem);
20
+ --yatl-line-height: var(--yatl-table-line-height, 1.25rem);
21
+
22
+ /* Spacing */
23
+ --yatl-cell-padding: var(--yatl-table-cell-padding, 10px 16px);
24
+ --yatl-header-padding: var(--yatl-table-header-padding, 12px 16px);
25
+
26
+ /* Colors */
27
+ --yatl-bg: var(--yatl-table-bg, #ffffff);
28
+ --yatl-text: var(--yatl-table-text, #0f172a);
29
+ --yatl-text-muted: var(--yatl-table-text-muted, #64748b);
30
+ --yatl-border-color: var(--yatl-table-border-color, #e2e8f0);
31
+
32
+ --yatl-header-bg: var(--yatl-table-header-bg, #f8fafc);
33
+ --yatl-header-text: var(--yatl-table-header-text, #475569);
34
+
35
+ --yatl-row-hover-bg: var(--yatl-table-row-hover-bg, #f1f5f9);
36
+ --yatl-row-selected-bg: var(--yatl-table-row-selected-bg, #e0f2fe);
37
+
38
+ /* Resize grab handle width */
39
+ --yatl-resizer-width: 10px;
40
+ /* z-index for the header */
41
+ --header-z-index: 2;
42
+ /* Drop target background color */
43
+ --header-drop-color: rgba(255, 255, 255, 0.1);
44
+
45
+ font-family: var(--yatl-font-family);
46
+ font-size: var(--yatl-font-size);
47
+ color: var(--yatl-text);
48
+ }
49
+
50
+ :host(.dark) {
51
+ --yatl-table-bg: #1e293b;
52
+ --yatl-table-text: #f1f5f9;
53
+ --yatl-table-text-muted: #94a3b8;
54
+ --yatl-table-border-color: #334155;
55
+
56
+ --yatl-table-header-bg: #0f172a;
57
+ --yatl-table-header-text: #cbd5e1;
58
+
59
+ --yatl-table-row-hover-bg: #334155;
60
+ --yatl-table-row-selected-bg: #1e3a8a;
61
+ }
62
+
63
+ @media (prefers-color-scheme: dark) {
64
+ :host {
65
+ --yatl-bg: var(--yatl-table-bg, #1e293b);
66
+ --yatl-text: var(--yatl-table-text, #f1f5f9);
67
+ --yatl-text-muted: var(--yatl-table-text-muted, #94a3b8);
68
+ --yatl-border-color: var(--yatl-table-border-color, #334155);
69
+
70
+ --yatl-header-bg: var(--yatl-table-header-bg, #0f172a);
71
+ --yatl-header-text: var(--yatl-table-header-text, #cbd5e1);
72
+
73
+ --yatl-row-hover-bg: var(--yatl-table-row-hover-bg, #334155);
74
+ --yatl-row-selected-bg: var(--yatl-table-row-selected-bg, #1e3a8a);
75
+ }
76
+ }
77
+
78
+ :host {
79
+ font-family: system-ui, sans-serif;
80
+ }
81
+
82
+ .table {
83
+ background-color: var(--yatl-bg);
84
+ border: 1px solid var(--yatl-border-color);
85
+ border-radius: 6px;
86
+ }
87
+
88
+ .header.row {
89
+ background-color: var(--yatl-header-bg);
90
+ border-bottom: 1px solid var(--yatl-border-color);
91
+ font-weight: 600;
92
+ color: var(--yatl-header-text);
93
+ }
94
+
95
+ .row {
96
+ background-color: var(--yatl-bg);
97
+ border-bottom: 1px solid var(--yatl-border-color);
98
+ transition: background-color 50ms;
99
+ position: relative;
100
+ }
101
+
102
+ .row:last-child {
103
+ border-bottom: none;
104
+ }
105
+
106
+ .header .cell::after,
107
+ .row:not(.header)::after {
108
+ content: '';
109
+ position: absolute;
110
+ inset: 0;
111
+ pointer-events: none;
112
+ background-color: transparent;
113
+ transition: background-color 50ms;
114
+ z-index: 1;
115
+ }
116
+
117
+ .header .cell:hover::after,
118
+ .row:not(.header):hover::after {
119
+ background-color: rgba(0, 0, 0, 0.2);
120
+ }
121
+
122
+ .cell {
123
+ align-items: center;
124
+ padding: var(--yatl-cell-padding);
125
+ }
126
+
127
+ .header .cell {
128
+ padding: var(--yatl-header-padding);
129
+ }
130
+
131
+ .footer {
132
+ padding: 8px 12px;
133
+ background-color: var(--yatl-header-bg);
134
+ border-top: 1px solid var(--yatl-border-color);
135
+ color: var(--yatl-text-muted);
136
+ font-size: 0.8em;
137
+ }
138
+
139
+ .resizer::after {
140
+ height: 60%;
141
+ width: 1px;
142
+ background-color: color-mix(in srgb, currentColor 30%, transparent);
143
+ transition: background-color 0.2s;
144
+ }
145
+
146
+ .resizer:hover::after {
147
+ background-color: currentColor;
148
+ width: 2px;
149
+ }
150
+
151
+ .drop-indicator {
152
+ background: rgba(0, 0, 0, 0.4);
153
+ }
154
+
155
+ .message {
156
+ font-size: large;
157
+ }
158
+
159
+ /* Layout stuff
160
+ * Most of this is functional and needed
161
+ * for the table to work properly.
162
+ * Modify with caution!
163
+ */
164
+ :host {
165
+ display: block;
166
+ height: 100%;
167
+ width: 100%;
168
+ }
169
+
170
+ .table {
171
+ display: flex;
172
+ flex-direction: column;
173
+ height: 100%;
174
+ width: 100%;
175
+ min-height: 0;
176
+ overflow: auto;
177
+ box-sizing: border-box;
178
+ }
179
+
180
+ .header {
181
+ z-index: var(--header-z-index);
182
+ flex-shrink: 0;
183
+ position: sticky;
184
+ top: 0;
185
+ }
186
+
187
+ .header-content {
188
+ position: relative;
189
+ width: 100%;
190
+ display: flex;
191
+ flex-direction: row;
192
+ align-items: baseline;
193
+ gap: 0.5rem;
194
+ }
195
+
196
+ .sort-icon {
197
+ position: relative;
198
+ width: 1ch;
199
+ align-self: stretch;
200
+ padding: 0;
201
+ overflow: hidden;
202
+ flex-shrink: 0;
203
+ }
204
+
205
+ .sort-icon::after {
206
+ content: '';
207
+ position: absolute;
208
+ }
209
+
210
+ .sort-icon.descending::after {
211
+ content: '\\2191';
212
+ }
213
+
214
+ .sort-icon.ascending::after {
215
+ content: '\\2193';
216
+ }
217
+
218
+ .resizer {
219
+ position: absolute;
220
+ top: 0;
221
+ bottom: 0;
222
+ right: 0;
223
+ width: var(--yatl-resizer-width);
224
+ cursor: col-resize;
225
+ display: flex;
226
+ justify-content: center;
227
+ align-items: center;
228
+ }
229
+
230
+ .resizer::after {
231
+ content: '';
232
+ display: block;
233
+ }
234
+
235
+ .drop-indicator {
236
+ display: none;
237
+ position: absolute;
238
+ top: 0;
239
+ left: 0;
240
+ right: 0;
241
+ bottom: 0;
242
+ pointer-events: none;
243
+ z-index: calc(var(--header-z-index) + 1);
244
+ }
245
+
246
+ .drop-indicator.active {
247
+ display: block;
248
+ }
249
+
250
+ .sortable {
251
+ cursor: pointer;
252
+ }
253
+
254
+ /* Footer */
255
+ .footer {
256
+ display: flex;
257
+ align-items: center;
258
+ justify-content: space-between;
259
+ flex-shrink: 0;
260
+
261
+ position: sticky;
262
+ bottom: 0;
263
+ z-index: var(--header-z-index);
264
+ }
265
+
266
+ /* Generic table parts */
267
+ .row {
268
+ display: grid;
269
+ grid-template-columns: var(--grid-template);
270
+ min-width: 100%;
271
+ width: fit-content;
272
+ }
273
+
274
+ .cell {
275
+ white-space: nowrap;
276
+ overflow: hidden;
277
+ text-overflow: ellipsis;
278
+ position: relative;
279
+ display: flex;
280
+ align-items: center;
281
+ }
282
+
283
+ .message {
284
+ width: 100%;
285
+ height: 100%;
286
+ text-align: center;
287
+ pointer-events: none;
288
+ display: flex;
289
+ align-items: center;
290
+ justify-content: center;
291
+ }
292
+
293
+ .truncate {
294
+ display: block;
295
+ white-space: nowrap;
296
+ overflow: hidden;
297
+ text-overflow: ellipsis;
298
+ }
299
+ `;var Oi=1e3,Ye={storage:"local",saveColumnSortOrders:!0,saveColumnVisibility:!0,saveColumnWidths:!0,saveColumnOrder:!0},Pi=new Set(["searchQuery","filters","columns","columnStates","storageOptions"]),ae={EXACT:100,PREFIX:50,SUBSTRING:10},m=class extends C{constructor(){super(...arguments);this._enableSearchTokenization=!1;this._enableSearchScoring=!1;this._columns=[];this._columnStates=[];this._storageOptions=null;this._data=[];this._searchQuery="";this._searchIncludedFields=[];this._searchTokenizer=Xt;this._filters=null;this._filteredData=[];this.hasRestoredState=!1;this.saveTimer=0;this.filterDirty=!1;this.sortDirty=!1;this.dataLastUpdate=null;this.rowMetadata=new WeakMap;this.queryTokens=null;this.resizeState=null;this.dragColumn=null;this.enableVirtualScroll=!1;this.enableSearchHighlight=!0;this.enableColumnReorder=!0;this.enableFooter=!1;this.nullValuePlaceholder="-";this.emptyMessage="No records to display";this.noResultsMessage="No matching records found";this.rowParts=null;this.handleHeaderClicked=(t,i)=>{let s=t.target;if(!i.sortable||s.classList.contains("resizer"))return;let n=t.shiftKey,o=b(i.field,this._columnStates);o?.sortState?o.sortState.order==="asc"?this.sort(i.field,"desc",!n):o.sortState.order&&this.sort(i.field,null,!n):this.sort(i.field,"asc",!n)};this.handleCellClick=(t,i,s)=>{if(window.getSelection()?.toString())return;let n=this.rowMetadata.get(i).index;this.dispatchEvent(new q(i,n,s,t))};this.handleResizeMouseMove=t=>{this.resizeState?.active&&requestAnimationFrame(()=>{if(!this.resizeState?.active)return;let i=t.pageX-this.resizeState.startX,s=Math.max(50,this.resizeState.startWidth+i);this.resizeState.currentWidths[this.resizeState.columnIndex]=`${s}px`,this.tableElement.style.setProperty("--grid-template",this.resizeState.currentWidths.join(" "))})};this.handleResizeMouseUp=t=>{if(window.removeEventListener("mousemove",this.handleResizeMouseMove),window.removeEventListener("mouseup",this.handleResizeMouseUp),document.body.style.cursor="",this.resizeState?.active){let i=parseFloat(this.resizeState.currentWidths[this.resizeState.columnIndex]),s=this.columnStates,n=b(this.resizeState.columnField,s);n.width=i,this.columnStates=s,this.dispatchEvent(new J(n.field,n.width))}this.resizeState=null};this.handleDragColumnStart=(t,i)=>{let s=t.target;if(console.log("Starting drag event"),console.log(s),s?.classList.contains("resizer")){t.preventDefault();return}t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",i),this.dragColumn=i)};this.handleDragColumnEnter=t=>{t.currentTarget.querySelector(".drop-indicator")?.classList.add("active")};this.handleDragColumnLeave=t=>{let i=t.currentTarget,s=t.relatedTarget;i.contains(s)||i.querySelector(".drop-indicator")?.classList.remove("active")};this.handleDragColumnOver=t=>{t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move")};this.handleDragColumnDrop=(t,i)=>{if(!this.dragColumn||this.dragColumn===i)return;t.preventDefault(),t.stopPropagation();let s=[...this.columns],n=s.findIndex(a=>a.field===this.dragColumn),o=s.findIndex(a=>a.field===i);if(n>-1&&o>-1){let[a]=s.splice(n,1),l=b(i,this.columns);if(!l)return;s.splice(o,0,a);let h=s.map(c=>c.field),u=new Z(a.field,l.field,h);if(!this.dispatchEvent(u))return;this.setColumnOrder(h)}};this.handleDragColumnEnd=()=>{this.dragColumn=null,this.tableElement.querySelectorAll(".drop-indicator.active").forEach(t=>t.classList.remove("active"))}}get enableSearchTokenization(){return this._enableSearchTokenization}set enableSearchTokenization(t){if(this._enableSearchTokenization===t)return;let i=this._enableSearchTokenization;this._enableSearchTokenization=t,this.updateInternalQuery(),this.filterDirty=!0,this.requestUpdate("enableSearchTokenization",i)}get enableSearchScoring(){return this._enableSearchScoring}set enableSearchScoring(t){if(this._enableSearchScoring===t)return;let i=this._enableSearchScoring;this._enableSearchScoring=t,this.filterDirty=!0,this.requestUpdate("enableSearchScoring",i)}get columns(){return this._columns}set columns(t){if(this._columns===t)return;let i=this._columns;this._columns=t,this.createColumnStates(),this.filterDirty=!0,this.requestUpdate("columns",i)}get columnStates(){return this._columnStates.map(t=>({...t,sortState:t.sortState?{...t.sortState}:void 0}))}set columnStates(t){if(this._columnStates===t)return;let i=this._columnStates;this._columnStates=t,Me(this._columnStates,i)&&(this.sortDirty=!0),this.requestUpdate("columnStates",i)}get searchQuery(){return this._searchQuery}set searchQuery(t){if(this._searchQuery===t)return;let i=this._searchQuery;this._searchQuery=t,this.updateInternalQuery(),this.filterDirty=!0,this.requestUpdate("searchQuery",i)}get searchIncludedFields(){return this._searchIncludedFields}set searchIncludedFields(t){if(this._searchIncludedFields===t)return;let i=this._searchIncludedFields;this._searchIncludedFields=t,this.filterDirty=!0,this.requestUpdate("searchIncludedFields",i)}get searchTokenizer(){return this._searchTokenizer}set searchTokenizer(t){if(this._searchTokenizer===t)return;let i=this._searchTokenizer;this._searchTokenizer=t,this.filterDirty=!0,this.requestUpdate("searchTokenizer",i)}get filters(){return this._filters}set filters(t){if(this._filters===t)return;let i=this._filters;this._filters=t,this.filterDirty=!0,this.requestUpdate("filters",i)}get storageOptions(){return this._storageOptions}set storageOptions(t){if(this._storageOptions===t)return;let i=this._storageOptions;this._storageOptions=t,this.hasRestoredState||this.loadStateFromStorage(),this.requestUpdate("storageOptions",i)}get data(){return this._data}set data(t){let i=this._data;this._data=t,this.dataLastUpdate=new Date,this.createMetadata(),this.filterDirty=!0,this.requestUpdate("data",i)}get filteredData(){return this.filterDirty?this.filterRows():this.sortDirty&&this.sortRows(),this.filterDirty=!1,this.sortDirty=!1,[...this._filteredData]}getState(){let t=this.columnStates;return{searchQuery:this.searchQuery,filters:this.filters,columnOrder:this.columns.map(i=>i.field),columns:this.columns.map(i=>{let s=b(i.field,t);return{field:i.field,visible:s?.visible??!0,sortState:s?.sortState,width:s?.width}})}}restoreState(t){if("searchQuery"in t&&t.searchQuery!==void 0&&(this.searchQuery=t.searchQuery),"filters"in t&&t.filters!==void 0&&(this.filters=t.filters),"columnOrder"in t&&t.columnOrder!==void 0&&this.setColumnOrder(t.columnOrder),"columns"in t&&t.columns!==void 0){let i=[];for(let s of t.columns){let n=b(s.field,this._columnStates)??{field:s.field,visible:!0};i.push(n),s&&("visible"in s&&s.visible!==void 0&&(n.visible=s.visible),"sortState"in s&&s.sortState!==void 0&&(n.sortState=s.sortState),"width"in s&&s.width!==void 0&&(n.width=s.width))}this.columnStates=i}}sort(t,i,s=!0){let n=this.columnStates,o=b(t,n);if(!o)throw new Error(`Cannot get options for non-existent column "${t}"`);if(i!==o.sortState?.order&&this.dispatchEvent(new G(t,i))){if(i&&!o.sortState){let a=n.map(u=>u.sortState?.priority).filter(u=>u!==void 0),l=this.columns.length+1,h=Math.min(l,...a)-1;o.sortState={order:i,priority:h}}else i&&o.sortState?o.sortState.order=i:o.sortState=null;if(s)for(let a of n)a.field!==t&&(a.sortState=null);this.columnStates=n}}setColumnVisibility(t,i){let s=this.columnStates,n=b(t,s);if(!n)throw new Error(`Cannot get options for non-existent column "${t}"`);n.visible!==i&&this.dispatchEvent(new X(t,i))&&(n.visible=i,this.columnStates=s)}toggleColumnVisibility(t){let i=b(t,this._columnStates);this.setColumnVisibility(t,!i)}showColumn(t){this.setColumnVisibility(t,!0)}hideColumn(t){this.setColumnVisibility(t,!1)}export(t,i=!1){let n=[...(i?this.data:this.filteredData).values()],o=this.columnData,a=o.filter(d=>i||d.state?.visible).map(d=>`"${d.options.title}"`).join(","),l=n.map(d=>{let f=[];for(let g of o){let S=M(d,g.field);(i||g.state.visible)&&(typeof g.options.valueFormatter=="function"&&(S=g.options.valueFormatter(S,d)),S=String(S).replace('"','""'),f.push(`"${S}"`))}return f.join(",")}).join(`
300
+ `),h=a+`
301
+ `+l,u=new Blob([h],{type:"text/csv;charset=utf-8,"}),c=document.createElement("a");c.style.display="none",c.href=URL.createObjectURL(u),c.download=`${t}.csv`,document.body.append(c),c.click(),c.remove()}scrollToRow(t){let i=this.data.findIndex(s=>s===t);if(typeof i=="number")return this.scrollToOriginalIndex(i);throw new Error("Row not in table")}scrollToOriginalIndex(t){let i=this.data[t];if(i){let s=this.filteredData.indexOf(i);if(s>=0)return this.scrollToFilteredIndex(s);throw new Error("Cannot scroll to filtered out row")}else throw new RangeError(`Row index ${t} out of range`)}async scrollToFilteredIndex(t){if(!this.filteredData[t])throw new RangeError(`Row index ${t} out of range`);await this.updateComplete,this.virtualizer?this.virtualizer.element(t)?.scrollIntoView({block:"start",behavior:"instant"}):this.tableElement.querySelector(`.row[data-filtered-index="${t}"]`)?.scrollIntoView({block:"start",behavior:"smooth"})}async scrollToPx(t){await this.updateComplete,this.virtualizer?this.virtualizer.scrollTop=t:this.tableElement.scrollTop=t}setColumnOrder(t){let i=[];for(let s of t){let n=b(s,this.columns);n&&i.push(n)}for(let s of this.columns)b(s.field,i)||i.push(s);this.columns=[...i]}findRow(t,i){return this.data.find(s=>M(s,t)===i)}findRowIndex(t,i){let s=this.findRow(t,i);return s?this.rowMetadata.get(s).index:-1}updateRow(t,i){let s=this.data[t];s&&(Object.assign(s,i),this.requestUpdate("data"))}deleteRow(t){this.data=this.data.toSpliced(t,1)}renderColumnSortIcon(t,i){return t.sortable?v`<div
302
+ part="header-sort-icon"
303
+ class=${Yt({"sort-icon":!0,ascending:i.sortState?.order==="asc",descending:i.sortState?.order==="desc"})}
304
+ ></div>`:_}renderColumnResizer(t,i){return t.resizable?v`<div
305
+ part="header-resizer"
306
+ class="resizer"
307
+ @click=${s=>s.stopPropagation()}
308
+ @mousedown=${s=>this.handleResizeMouseDown(s,t.field)}
309
+ ></div>`:_}renderHeaderCell(t){let i=b(t.field,this._columnStates);return i.visible==!1?_:v`
310
+ <div
311
+ part="cell header-cell"
312
+ class=${Yt({cell:!0,sortable:t.sortable??!1})}
313
+ draggable=${te(this.enableColumnReorder?!0:void 0)}
314
+ data-field=${t.field}
315
+ @dragstart=${s=>this.handleDragColumnStart(s,t.field)}
316
+ @dragenter=${this.handleDragColumnEnter}
317
+ @dragleave=${this.handleDragColumnLeave}
318
+ @dragover=${this.handleDragColumnOver}
319
+ @drop=${s=>this.handleDragColumnDrop(s,t.field)}
320
+ @dragend=${this.handleDragColumnEnd}
321
+ @click=${s=>this.handleHeaderClicked(s,t)}
322
+ >
323
+ <div class="header-content">
324
+ <span class="header-title truncate" part="header-title">
325
+ ${t.title??ze(t.field)}
326
+ </span>
327
+ ${this.renderColumnSortIcon(t,i)}
328
+ </div>
329
+ ${this.renderColumnResizer(t,i)}
330
+ <div part="drop-indicator" class="drop-indicator"></div>
331
+ </div>
332
+ `}renderHeader(){return v`
333
+ <div part="header" class="header row">
334
+ ${this.columns.map(t=>this.renderHeaderCell(t))}
335
+ </div>
336
+ `}renderCellContents(t,i,s){if(i.cellRenderer)return i.cellRenderer(t,i.field,s);if(t==null)return this.nullValuePlaceholder;let n=this.rowMetadata.get(s).highlightIndices;return this.enableSearchHighlight&&n?Ae(String(t),n[i.field]):t}renderCell(t,i){if(b(t.field,this._columnStates)?.visible==!1)return _;let n=M(i,t.field),o=t.cellParts?.call(this,n,t.field,i);return Array.isArray(o)&&(o=o.join(" ")),typeof t.valueFormatter=="function"&&(n=t.valueFormatter(n,i)),v`
337
+ <div
338
+ part="cell body-cell cell-${t.field} ${o}"
339
+ data-field=${t.field}
340
+ class="cell"
341
+ title=${te(n?String(n):void 0)}
342
+ @click=${a=>this.handleCellClick(a,i,t.field)}
343
+ >
344
+ <span class="truncate">
345
+ ${this.renderCellContents(n,t,i)}
346
+ </span>
347
+ </div>
348
+ `}renderRow(t,i){let s=this.rowMetadata.get(t),n=this.rowParts?.(t)??"";return Array.isArray(n)&&(n=n.join(" ")),v`
349
+ <div
350
+ part=${"row "+n}
351
+ class="row"
352
+ data-index=${s.index}
353
+ data-filtered-index=${i}
354
+ >
355
+ ${this.columns.map(o=>this.renderCell(o,t))}
356
+ </div>
357
+ `}renderBody(){return this.columnWidths.length===0?v`
358
+ <div part="message" class="message">No visible columns.</div>
359
+ `:this.data.length===0?v`<div part="message" class="message">
360
+ ${this.emptyMessage}
361
+ </div>`:this.filteredData.length===0?v`<div part="message" class="message">
362
+ ${this.noResultsMessage}
363
+ </div>`:this.enableVirtualScroll?v`
364
+ <lit-virtualizer
365
+ .items=${this.filteredData}
366
+ .renderItem=${(t,i)=>this.renderRow(t,i)}
367
+ ></lit-virtualizer>
368
+ `:v`
369
+ ${Mt(this.filteredData,t=>this.rowMetadata.get(t).index,(t,i)=>this.renderRow(t,i))}
370
+ `}renderFooter(){if(!this.enableFooter)return _;let t=this.data.length,i=this.filteredData.length,s=new Intl.NumberFormat(void 0),n=s.format(t),o=s.format(i),a=t!==i?`Showing ${o} of ${n} records`:`Total records: ${n}`,l=Intl.DateTimeFormat(void 0,{dateStyle:"short",timeStyle:"short"}),h=this.dataLastUpdate?l.format(this.dataLastUpdate):"Never";return v`
371
+ <div part="footer" class="footer">
372
+ <slot name="footer">
373
+ <span part="row-count">${a}</span>
374
+ <span part="timestamp">${h}</span>
375
+ </slot>
376
+ </div>
377
+ `}render(){let t=Jt(this.columnWidths).join(" ");return v`
378
+ <div
379
+ part="table"
380
+ class="table"
381
+ style=${Ue({"--grid-template":t})}
382
+ >
383
+ ${this.renderHeader()} ${this.renderBody()} ${this.renderFooter()}
384
+ </div>
385
+ `}updated(t){if(super.updated(t),!this.storageOptions?.key)return;Array.from(t.keys()).some(s=>Pi.has(s))&&this.scheduleSave()}disconnectedCallback(){super.disconnectedCallback(),window.addEventListener("mousemove",this.handleResizeMouseMove),window.addEventListener("mouseup",this.handleResizeMouseUp)}calculateSearchScore(t,i){let s={score:0,ranges:[]};if(!t||!i)return s;let n=0,o=0;if(i===t)o=ae.EXACT,n=t.length,s.ranges.push([0,i.length]);else if(i.startsWith(t))o=ae.PREFIX,n=t.length,s.ranges.push([0,t.length]);else{let h=i.indexOf(t);if(h!==-1){o=ae.SUBSTRING,n=t.length;let u=h;for(;u!==-1;)s.ranges.push([u,u+t.length]),u=i.indexOf(t,u+1)}else return s}let l=1/(1+(i.length-t.length));return s.score=n*o*l,s}searchField(t,i,s){let n={score:0,ranges:[]},o=a=>{let l=i.indexOf(a);for(;l!==-1;)n.ranges.push([l,l+a.length]),l=i.indexOf(a,l+1)};if(t.quoted||!s){if(!this.enableSearchScoring)i.includes(t.value)&&(n.score=1,o(t.value));else{let a=this.calculateSearchScore(t.value,i);n.score=a.score,n.ranges=a.ranges}return n}if(!this.enableSearchScoring)return s.some(l=>l.includes(t.value))&&(n.score=1,o(t.value)),n;for(let a of s){let l=this.calculateSearchScore(t.value,a);l.score>0&&(n.score+=l.score,o(t.value))}return n}filterField(t,i,s=null){return Array.isArray(i)?i.length===0?!0:i.some(n=>this.filterField(t,n,s)):Array.isArray(t)?t.length===0?!1:t.some(n=>this.filterField(n,i,s)):typeof s=="function"?s(t,i):i instanceof RegExp?i.test(String(t)):i===t}filterRow(t,i){if(!this.filters)return!0;if(typeof this.filters=="function")return this.filters(t,i);for(let s in this.filters){let n=M(this.filters,s),o=M(t,s);if(typeof n=="function"){if(!n(o))return!1}else{let a=b(s,this.columns),l=a?a.filter:void 0;if(!this.filterField(o,n,l))return!1}}return!0}filterRows(){let i=[...[...this.columnData.values()].filter(s=>s.options.searchable).map(s=>s.field),...this.searchIncludedFields];this._filteredData=this.data.filter((s,n)=>{let o=this.rowMetadata.get(s);if(o.searchScore=0,o.highlightIndices={},!this.filterRow(s,n))return!1;if(!this.queryTokens)return!0;for(let a of i){let l=M(s,a),h=o.searchValues[a],u=o.searchTokens[a];if(typeof l!="string"||typeof h!="string")continue;let c={score:0,ranges:[]};for(let d of this.queryTokens){let f=this.searchField(d,h,u);c.score+=f.score,c.ranges.push(...f.ranges)}c.score>0&&(o.searchScore+=c.score,o.highlightIndices[a]=c.ranges)}return o.searchScore>0}),this.filterDirty=!1,this.sortRows(),this.dispatchEvent(new Q(this.data))}compareRows(t,i,s){let n,o,a=b(s,this.columnData);if(!a.state.sortState)return 0;let l=this.rowMetadata.get(t),h=this.rowMetadata.get(i);if(a.state.sortState?.order==="asc"?(n=l.sortValues[a.field],o=h.sortValues[a.field]):(n=h.sortValues[a.field],o=l.sortValues[a.field]),typeof a.options.sorter=="function"){let d=a.options.sorter(n,o);if(d!==0)return d}let u=n==null,c=o==null;return u&&!c?-1:c&&!u?1:n<o?-1:n>o?1:0}sortRows(){if(this.filterDirty){this.filterRows();return}let t=this.columnData.filter(i=>i.state.visible&&i.state.sortState).sort((i,s)=>s.state.sortState.priority-i.state.sortState.priority);this._filteredData=this._filteredData.toSorted((i,s)=>{let n=this.rowMetadata.get(i),o=this.rowMetadata.get(s);if(this.enableSearchScoring&&this.queryTokens){let a=n.searchScore||0,l=o.searchScore||0;if(a>l)return-1;if(a<l)return 1}for(let a of t){let l=this.compareRows(i,s,a.field);if(l!==0)return l}return n.index-o.index}),this.sortDirty=!1}createColumnStates(){this.columnStates=this.columns.map(t=>{let i=b(t.field,this._columnStates);return{field:t.field,visible:i?.visible??!0,sortState:i?.sortState,width:i?.width}})}createMetadata(){this.rowMetadata=new WeakMap;let t=0;for(let i of this.data){let s={index:t++,searchTokens:{},searchValues:{},sortValues:{}};this.rowMetadata.set(i,s);for(let n of this.columns){let o=M(i,n.field);if(typeof n.sortValue=="function"?s.sortValues[n.field]=n.sortValue(o):typeof o=="string"?s.sortValues[n.field]=o.toLocaleLowerCase():Oe(o)?s.sortValues[n.field]=o:s.sortValues[n.field]=String(o),typeof o=="string"&&(s.searchValues[n.field]=o.toLocaleLowerCase()),n.searchable&&n.tokenize&&o){let a=n.searchTokenizer??this.searchTokenizer;s.searchTokens[n.field]=a(String(o)).map(l=>l.value)}}for(let n of this.searchIncludedFields){let o=M(i,n);typeof o=="string"&&(s.searchValues[n]=o.toLocaleLowerCase())}}}updateInternalQuery(){if(this.searchQuery.length===0){this.queryTokens=null;return}this.queryTokens=[{value:this.searchQuery.toLocaleLowerCase(),quoted:!0}],this.enableSearchTokenization&&this.queryTokens.push(...this.searchTokenizer(this.searchQuery))}get columnData(){return this.columns.map(t=>({field:t.field,options:t,state:b(t.field,this._columnStates)??{field:t.field,visible:!0}}))}get columnWidths(){return this.columns.map(t=>b(t.field,this._columnStates)).filter(t=>t?t.visible:!0).map(t=>t?.width??null)}scheduleSave(){window.clearTimeout(this.saveTimer),this.saveTimer=window.setTimeout(()=>{this.saveStateToStorage()},Oi)}saveStateToStorage(){if(!this.storageOptions)return;let t={...Ye,...this.storageOptions},i={columns:[]},s=this.getState();t.saveColumnOrder&&(i.columnOrder=s.columnOrder);for(let o of s.columns){let a={field:o.field};t.saveColumnSortOrders&&(a.sortState=o.sortState),t.saveColumnVisibility&&(a.visible=o.visible),t.saveColumnWidths&&(a.width=o.width),i.columns?.push(a)}let n=t.storage==="session"?sessionStorage:localStorage;try{n.setItem(t.key,JSON.stringify(i))}catch(o){console.warn("Failed to save table state",o)}}loadStateFromStorage(){if(!this.storageOptions)return;let t={...Ye,...this.storageOptions},i=localStorage.getItem(t.key);if(i)try{let s=JSON.parse(i),n={};if(t.saveColumnOrder&&(n.columnOrder=s.columnOrder),s.columns){n.columns=[];for(let o of s.columns){let a={field:o.field};t.saveColumnVisibility&&(a.visible=o.visible),t.saveColumnWidths&&(a.width=o.width),t.saveColumnSortOrders&&(a.sortState=o.sortState),n.columns.push(a)}}this.restoreState(n),this.hasRestoredState=!0}catch(s){console.error("Failed to restore DataTable state:",s)}}handleResizeMouseDown(t,i){t.preventDefault(),t.stopPropagation();let n=t.target.closest(".cell");if(!n)return;let o=this.columns.findIndex(a=>a.field===i);o<0||(this.tableElement.querySelectorAll(".header .cell").forEach(a=>{let l=a.dataset.field;if(l){let h=b(l,this._columnStates);h&&(h.width=a.getBoundingClientRect().width)}}),this.resizeState={active:!0,startX:t.pageX,startWidth:n.getBoundingClientRect().width,columnIndex:o,columnField:i,currentWidths:Jt(this.columnWidths)},this.tableElement.style.setProperty("--grid-template",this.resizeState.currentWidths.join(" ")),window.addEventListener("mousemove",this.handleResizeMouseMove),window.addEventListener("mouseup",this.handleResizeMouseUp),document.body.style.cursor="col-resize")}addEventListener(t,i,s){super.addEventListener(t,i,s)}removeEventListener(t,i,s){super.removeEventListener(t,i,s)}dispatchEvent(t){return super.dispatchEvent(t)}};m.styles=[Ze],y([Zt(".table")],m.prototype,"tableElement",2),y([Zt("lit-virtualizer")],m.prototype,"virtualizer",2),y([Re()],m.prototype,"_filteredData",2),y([p({type:Boolean,attribute:"enable-virtual-scroll"})],m.prototype,"enableVirtualScroll",2),y([p({type:Boolean,attribute:"enable-search-highlight"})],m.prototype,"enableSearchHighlight",2),y([p({type:Boolean,attribute:"enable-search-tokenization"})],m.prototype,"enableSearchTokenization",1),y([p({type:Boolean,attribute:"enable-search-scoring"})],m.prototype,"enableSearchScoring",1),y([p({type:Boolean,attribute:"enable-column-reorder"})],m.prototype,"enableColumnReorder",2),y([p({type:Boolean,attribute:"enable-footer"})],m.prototype,"enableFooter",2),y([p({type:String,attribute:"null-value-placeholder"})],m.prototype,"nullValuePlaceholder",2),y([p({type:String,attribute:"empty-message"})],m.prototype,"emptyMessage",2),y([p({type:String,attribute:"no-results-message"})],m.prototype,"noResultsMessage",2),y([p({attribute:!1})],m.prototype,"columns",1),y([p({attribute:!1})],m.prototype,"columnStates",1),y([p({type:String,attribute:"search-query"})],m.prototype,"searchQuery",1),y([p({type:Array,attribute:"search-included-fields"})],m.prototype,"searchIncludedFields",1),y([p({attribute:!1})],m.prototype,"searchTokenizer",1),y([p({attribute:!1})],m.prototype,"filters",1),y([p({attribute:!1})],m.prototype,"rowParts",2),y([p({type:Object,attribute:"storage-options"})],m.prototype,"storageOptions",1),y([p({attribute:!1})],m.prototype,"data",1),m=y([Pe("yatl-table")],m);return si(Ri);})();
386
+ /*! Bundled license information:
387
+
388
+ @lit-labs/virtualizer/layouts/shared/SizeCache.js:
389
+ @lit-labs/virtualizer/layouts/shared/BaseLayout.js:
390
+ @lit-labs/virtualizer/layouts/flow.js:
391
+ @lit/reactive-element/decorators/query-assigned-elements.js:
392
+ @lit-labs/virtualizer/events.js:
393
+ @lit-labs/virtualizer/ScrollerController.js:
394
+ @lit-labs/virtualizer/Virtualizer.js:
395
+ @lit-labs/virtualizer/virtualize.js:
396
+ @lit-labs/virtualizer/LitVirtualizer.js:
397
+ @lit-labs/virtualizer/lit-virtualizer.js:
398
+ (**
399
+ * @license
400
+ * Copyright 2021 Google LLC
401
+ * SPDX-License-Identifier: BSD-3-Clause
402
+ *)
403
+
404
+ @lit/reactive-element/css-tag.js:
405
+ (**
406
+ * @license
407
+ * Copyright 2019 Google LLC
408
+ * SPDX-License-Identifier: BSD-3-Clause
409
+ *)
410
+
411
+ @lit/reactive-element/reactive-element.js:
412
+ lit-html/lit-html.js:
413
+ lit-element/lit-element.js:
414
+ @lit/reactive-element/decorators/custom-element.js:
415
+ @lit/reactive-element/decorators/property.js:
416
+ @lit/reactive-element/decorators/state.js:
417
+ @lit/reactive-element/decorators/event-options.js:
418
+ @lit/reactive-element/decorators/base.js:
419
+ @lit/reactive-element/decorators/query.js:
420
+ @lit/reactive-element/decorators/query-all.js:
421
+ @lit/reactive-element/decorators/query-async.js:
422
+ @lit/reactive-element/decorators/query-assigned-nodes.js:
423
+ lit-html/directive.js:
424
+ lit-html/directives/repeat.js:
425
+ lit-html/async-directive.js:
426
+ (**
427
+ * @license
428
+ * Copyright 2017 Google LLC
429
+ * SPDX-License-Identifier: BSD-3-Clause
430
+ *)
431
+
432
+ lit-html/is-server.js:
433
+ (**
434
+ * @license
435
+ * Copyright 2022 Google LLC
436
+ * SPDX-License-Identifier: BSD-3-Clause
437
+ *)
438
+
439
+ lit-html/directives/class-map.js:
440
+ lit-html/directives/if-defined.js:
441
+ lit-html/directives/style-map.js:
442
+ (**
443
+ * @license
444
+ * Copyright 2018 Google LLC
445
+ * SPDX-License-Identifier: BSD-3-Clause
446
+ *)
447
+
448
+ lit-html/directive-helpers.js:
449
+ (**
450
+ * @license
451
+ * Copyright 2020 Google LLC
452
+ * SPDX-License-Identifier: BSD-3-Clause
453
+ *)
454
+ */
455
+ //# sourceMappingURL=yatl.min.global.js.map