iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 29.7 kB
JavaScript
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[5755],{18804:(t,e,i)=>{"use strict";i.r(e),i.d(e,{Layout1d:()=>h});var s=i(22402);class h extends s.T{constructor(t){super(t),this._physicalItems=new Map,this._newPhysicalItems=new Map,this._metrics=new Map,this._anchorIdx=null,this._anchorPos=null,this._stable=!0,this._needsRemeasure=!1,this._nMeasured=0,this._tMeasured=0,this._estimate=!0}updateItemSizes(t){Object.keys(t).forEach((e=>{const i=t[e],s=this._getMetrics(Number(e)),h=s[this._sizeDim];s.width=i.width+(i.marginLeft||0)+(i.marginRight||0),s.height=i.height+(i.marginTop||0)+(i.marginBottom||0);const r=s[this._sizeDim],n=this._getPhysicalItem(Number(e));if(n){let t;void 0!==r&&(n.size=r,void 0===h?(t=r,this._nMeasured++):t=r-h),this._tMeasured=this._tMeasured+t}})),this._nMeasured?(this._updateItemSize(),this._scheduleReflow()):console.warn("No items measured yet.")}_updateItemSize(){this._itemSize[this._sizeDim]=Math.round(this._tMeasured/this._nMeasured)}_getMetrics(t){return this._metrics[t]=this._metrics[t]||{}}_getPhysicalItem(t){return this._newPhysicalItems.get(t)||this._physicalItems.get(t)}_getSize(t){const e=this._getPhysicalItem(t);return e&&e.size}_getPosition(t){const e=this._physicalItems.get(t);return e?e.pos:t*this._delta+this._spacing}_calculateAnchor(t,e){return 0===t?0:e>this._scrollSize-this._viewDim1?this._totalItems-1:Math.max(0,Math.min(this._totalItems-1,Math.floor((t+e)/2/this._delta)))}_getAnchor(t,e){if(0===this._physicalItems.size)return this._calculateAnchor(t,e);if(this._first<0)return console.error("_getAnchor: negative _first"),this._calculateAnchor(t,e);if(this._last<0)return console.error("_getAnchor: negative _last"),this._calculateAnchor(t,e);const i=this._getPhysicalItem(this._first),s=this._getPhysicalItem(this._last),h=i.pos,r=h+i.size,n=s.pos,l=n+s.size;if(l<t)return this._calculateAnchor(t,e);if(h>e)return this._calculateAnchor(t,e);if(h>=t||r>=t)return this._first;if(l<=e||n<=e)return this._last;let o=this._last,a=this._first;for(;;){const i=Math.round((o+a)/2),s=this._physicalItems.get(i),h=s.pos,r=h+s.size;if(h>=t&&h<=e||r>=t&&r<=e)return i;r<t?a=i+1:h>e&&(o=i-1)}}_getActiveItems(){if(0===this._viewDim1||0===this._totalItems)this._clearItems();else{const t=Math.min(this._scrollSize,this._scrollPosition+this._viewDim1+this._overhang),e=Math.max(0,t-this._viewDim1-2*this._overhang);this._getItems(e,t)}}_clearItems(){this._first=-1,this._last=-1,this._physicalMin=0,this._physicalMax=0;const t=this._newPhysicalItems;this._newPhysicalItems=this._physicalItems,this._newPhysicalItems.clear(),this._physicalItems=t,this._stable=!0}_getItems(t,e){const i=this._newPhysicalItems;null!==this._anchorIdx&&null!==this._anchorPos||(this._anchorIdx=this._getAnchor(t,e),this._anchorPos=this._getPosition(this._anchorIdx));let s=this._getSize(this._anchorIdx);void 0===s&&(s=this._itemDim1);let h=0;for(this._anchorPos+s+this._spacing<t&&(h=t-(this._anchorPos+s+this._spacing)),this._anchorPos>e&&(h=e-this._anchorPos),h&&(this._scrollPosition-=h,t-=h,e-=h,this._scrollError+=h),i.set(this._anchorIdx,{pos:this._anchorPos,size:s}),this._first=this._last=this._anchorIdx,this._physicalMin=this._physicalMax=this._anchorPos,this._stable=!0;this._physicalMin>t&&this._first>0;){let t=this._getSize(--this._first);void 0===t&&(this._stable=!1,t=this._itemDim1);const e=this._physicalMin-=t+this._spacing;if(i.set(this._first,{pos:e,size:t}),!1===this._stable&&!1===this._estimate)break}for(;this._physicalMax<e&&this._last<this._totalItems;){let t=this._getSize(this._last);if(void 0===t&&(this._stable=!1,t=this._itemDim1),i.set(this._last++,{pos:this._physicalMax,size:t}),!1===this._stable&&!1===this._estimate)break;this._physicalMax+=t+this._spacing}this._last--;const r=this._calculateError();r&&(this._physicalMin-=r,this._physicalMax-=r,this._anchorPos-=r,this._scrollPosition-=r,i.forEach((t=>t.pos-=r)),this._scrollError+=r),this._stable&&(this._newPhysicalItems=this._physicalItems,this._newPhysicalItems.clear(),this._physicalItems=i)}_calculateError(){return 0===this._first?this._physicalMin:this._physicalMin<=0?this._physicalMin-this._first*this._delta:this._last===this._totalItems-1?this._physicalMax-this._scrollSize:this._physicalMax>=this._scrollSize?this._physicalMax-this._scrollSize+(this._totalItems-1-this._last)*this._delta:0}_updateScrollSize(){super._updateScrollSize(),this._scrollSize=Math.max(this._physicalMax,this._scrollSize)}_reflow(){const{_first:t,_last:e,_scrollSize:i}=this;this._updateScrollSize(),this._getActiveItems(),this._scrollIfNeeded(),this._scrollSize!==i&&this._emitScrollSize(),this._updateVisibleIndices(),this._emitRange(),-1===this._first&&-1===this._last?this._resetReflowState():this._first!==t||this._last!==e||this._needsRemeasure?(this._emitChildPositions(),this._emitScrollError()):(this._emitChildPositions(),this._emitScrollError(),this._resetReflowState())}_resetReflowState(){this._anchorIdx=null,this._anchorPos=null,this._stable=!0}_getItemPosition(t){return{[this._positionDim]:this._getPosition(t),[this._secondaryPositionDim]:0}}_getItemSize(t){return{[this._sizeDim]:this._getSize(t)||this._itemDim1,[this._secondarySizeDim]:this._itemDim2}}_viewDim2Changed(){this._needsRemeasure=!0,this._scheduleReflow()}_emitRange(){const t=this._needsRemeasure,e=this._stable;this._needsRemeasure=!1,super._emitRange({remeasure:t,stable:e})}}},22402:(t,e,i)=>{"use strict";let s;async function h(){return s||async function(){s=window.EventTarget;try{new s}catch(t){s=(await i.e(8251).then(i.t.bind(i,98251,7))).EventTarget}return s}()}i.d(e,{T:()=>r});class r{constructor(t){this._latestCoords={left:0,top:0},this._direction="vertical",this._viewportSize={width:0,height:0},this._pendingReflow=!1,this._scrollToIndex=-1,this._scrollToAnchor=0,this._eventTargetPromise=h().then((t=>this._eventTarget=new t)),this._physicalMin=0,this._physicalMax=0,this._first=-1,this._last=-1,this._itemSize={width:100,height:100},this._spacing=0,this._sizeDim="height",this._secondarySizeDim="width",this._positionDim="top",this._secondaryPositionDim="left",this._scrollPosition=0,this._scrollError=0,this._totalItems=0,this._scrollSize=1,this._overhang=150,Object.assign(this,t)}get totalItems(){return this._totalItems}set totalItems(t){t!==this._totalItems&&(this._totalItems=t,this._scheduleReflow())}get direction(){return this._direction}set direction(t){(t="horizontal"===t?t:"vertical")!==this._direction&&(this._direction=t,this._sizeDim="horizontal"===t?"width":"height",this._secondarySizeDim="horizontal"===t?"height":"width",this._positionDim="horizontal"===t?"left":"top",this._secondaryPositionDim="horizontal"===t?"top":"left",this._scheduleReflow())}get itemSize(){return this._itemSize}set itemSize(t){const{_itemDim1:e,_itemDim2:i}=this;Object.assign(this._itemSize,t),e===this._itemDim1&&i===this._itemDim2||(i!==this._itemDim2?this._itemDim2Changed():this._scheduleReflow())}get spacing(){return this._spacing}set spacing(t){t!==this._spacing&&(this._spacing=t,this._scheduleReflow())}get viewportSize(){return this._viewportSize}set viewportSize(t){const{_viewDim1:e,_viewDim2:i}=this;Object.assign(this._viewportSize,t),i!==this._viewDim2?this._viewDim2Changed():e!==this._viewDim1&&this._checkThresholds()}get viewportScroll(){return this._latestCoords}set viewportScroll(t){Object.assign(this._latestCoords,t);const e=this._scrollPosition;this._scrollPosition=this._latestCoords[this._positionDim],e!==this._scrollPosition&&(this._scrollPositionChanged(e,this._scrollPosition),this._updateVisibleIndices()),this._checkThresholds()}reflowIfNeeded(){this._pendingReflow&&(this._pendingReflow=!1,this._reflow())}scrollToIndex(t,e="start"){if(Number.isFinite(t)){switch(t=Math.min(this.totalItems,Math.max(0,t)),this._scrollToIndex=t,"nearest"===e&&(e=t>this._first+this._num/2?"end":"start"),e){case"start":this._scrollToAnchor=0;break;case"center":this._scrollToAnchor=.5;break;case"end":this._scrollToAnchor=1;break;default:throw new TypeError("position must be one of: start, center, end, nearest")}this._scheduleReflow(),this.reflowIfNeeded()}}async dispatchEvent(...t){await this._eventTargetPromise,this._eventTarget.dispatchEvent(...t)}async addEventListener(...t){await this._eventTargetPromise,this._eventTarget.addEventListener(...t)}async removeEventListener(...t){await this._eventTargetPromise,this._eventTarget.removeEventListener(...t)}updateItemSizes(t){}_itemDim2Changed(){}_viewDim2Changed(){}_getItemSize(t){return{[this._sizeDim]:this._itemDim1,[this._secondarySizeDim]:this._itemDim2}}get _delta(){return this._itemDim1+this._spacing}get _itemDim1(){return this._itemSize[this._sizeDim]}get _itemDim2(){return this._itemSize[this._secondarySizeDim]}get _viewDim1(){return this._viewportSize[this._sizeDim]}get _viewDim2(){return this._viewportSize[this._secondarySizeDim]}_scheduleReflow(){this._pendingReflow=!0}_reflow(){const{_first:t,_last:e,_scrollSize:i}=this;this._updateScrollSize(),this._getActiveItems(),this._scrollIfNeeded(),this._scrollSize!==i&&this._emitScrollSize(),-1===this._first&&-1===this._last?this._emitRange():(this._first!==t||this._last!==e||this._spacingChanged)&&(this._emitRange(),this._emitChildPositions()),this._emitScrollError()}_updateScrollSize(){this._scrollSize=Math.max(1,this._totalItems*this._delta)}_scrollIfNeeded(){if(-1===this._scrollToIndex)return;const t=this._scrollToIndex,e=this._scrollToAnchor,i=this._getItemPosition(t)[this._positionDim],s=this._getItemSize(t)[this._sizeDim],h=this._scrollPosition+this._viewDim1*e,r=i+s*e,n=Math.floor(Math.min(this._scrollSize-this._viewDim1,Math.max(0,this._scrollPosition-h+r)));this._scrollError+=this._scrollPosition-n,this._scrollPosition=n}_emitRange(t){const e=Object.assign({first:this._first,last:this._last,num:this._num,stable:!0,firstVisible:this._firstVisible,lastVisible:this._lastVisible},t);this.dispatchEvent(new CustomEvent("rangechange",{detail:e}))}_emitScrollSize(){const t={[this._sizeDim]:this._scrollSize};this.dispatchEvent(new CustomEvent("scrollsizechange",{detail:t}))}_emitScrollError(){if(this._scrollError){const t={[this._positionDim]:this._scrollError,[this._secondaryPositionDim]:0};this.dispatchEvent(new CustomEvent("scrollerrorchange",{detail:t})),this._scrollError=0}}_emitChildPositions(){const t={};for(let e=this._first;e<=this._last;e++)t[e]=this._getItemPosition(e);this.dispatchEvent(new CustomEvent("itempositionchange",{detail:t}))}get _num(){return-1===this._first||-1===this._last?0:this._last-this._first+1}_checkThresholds(){if(0===this._viewDim1&&this._num>0)this._scheduleReflow();else{const t=Math.max(0,this._scrollPosition-this._overhang),e=Math.min(this._scrollSize,this._scrollPosition+this._viewDim1+this._overhang);(this._physicalMin>t||this._physicalMax<e)&&this._scheduleReflow()}}_updateVisibleIndices(){let t=this._firstVisible,e=this._lastVisible;for(let i=this._first;i<=this._last;i++){const s=this._getItemPosition(i)[this._positionDim];s<=this._scrollPosition&&(t=i),s<this._scrollPosition+this._viewDim1&&(e=i)}t>e||t===this._firstVisible&&e===this._lastVisible||(this._firstVisible=t,this._lastVisible=e,this._emitRange())}_scrollPositionChanged(t,e){const i=this._scrollSize-this._viewDim1;(t<i||e<i)&&(this._scrollToIndex=-1)}}},55755:(t,e,i)=>{"use strict";i.d(e,{AR:()=>y});var s=i(94707);class h{constructor(t){this._createElementFn=null,this._updateElementFn=null,this._recycleElementFn=null,this._elementKeyFn=null,this._items=[],this._totalItems=null,this._needsReset=!1,this._needsRemeasure=!1,this._active=new Map,this._prevActive=new Map,this._keyToChild=new Map,this._childToKey=new WeakMap,this._indexToMeasure={},this.__incremental=!1,this._measureCallback=null,this._num=1/0,this._first=0,this._last=0,this._prevFirst=0,this._prevLast=0,this._pendingRender=null,this._container=null,this._ordered=[],t&&Object.assign(this,t)}get container(){return this._container}set container(t){t!==this._container&&(this._container&&this._ordered.forEach((t=>this._removeChild(t))),this._container=t,t?this._ordered.forEach((t=>this._insertBefore(t,null))):(this._ordered.length=0,this._active.clear(),this._prevActive.clear()),this.requestReset())}get createElement(){return this._createElementFn}set createElement(t){t!==this._createElementFn&&(this._createElementFn=t,this._keyToChild.clear(),this.requestReset())}get updateElement(){return this._updateElementFn}set updateElement(t){t!==this._updateElementFn&&(this._updateElementFn=t,this.requestReset())}get recycleElement(){return this._recycleElementFn}set recycleElement(t){t!==this._recycleElementFn&&(this._recycleElementFn=t,this.requestReset())}get elementKey(){return this._elementKeyFn}set elementKey(t){t!==this._elementKeyFn&&(this._elementKeyFn=t,this._keyToChild.clear(),this.requestReset())}get first(){return this._first}set first(t){if("number"!=typeof t)throw new Error("New value must be a number.");const e=Math.max(0,Math.min(t,this.totalItems-this._num));e!==this._first&&(this._first=e,this._scheduleRender())}get num(){return this._num}set num(t){if("number"!=typeof t)throw new Error("New value must be a number.");t!==this._num&&(this._num=t,this.first=this._first,this._scheduleRender())}get items(){return this._items}set items(t){t!==this._items&&Array.isArray(t)&&(this._items=t,this.requestReset())}get totalItems(){return null===this._totalItems?this._items.length:this._totalItems}set totalItems(t){if("number"!=typeof t&&null!==t)throw new Error("New value must be a number.");t!==this._totalItems&&(this._totalItems=t,this.first=this._first,this.requestReset())}get _incremental(){return this.__incremental}set _incremental(t){t!==this.__incremental&&(this.__incremental=t,this._scheduleRender())}requestRemeasure(){this._needsRemeasure=!0,this._scheduleRender()}_shouldRender(){return Boolean(this.container&&this.createElement)}async _scheduleRender(){this._pendingRender||(this._pendingRender=!0,await Promise.resolve(),this._pendingRender=!1,this._shouldRender()&&this._render())}requestReset(){this._needsReset=!0,this._scheduleRender()}get _toMeasure(){return this._ordered.reduce(((t,e,i)=>{const s=this._first+i;return(this._needsReset||this._needsRemeasure||s<this._prevFirst||s>this._prevLast)&&(t.indices.push(s),t.children.push(e)),t}),{indices:[],children:[]})}async _measureChildren({indices:t,children:e}){await new Promise((t=>{requestAnimationFrame(t)}));const i=e.map((t=>this._measureChild(t))).reduce(((e,i,s)=>(e[t[s]]=this._indexToMeasure[t[s]]=i,e)),{});this._measureCallback(i)}async _render(){const t=this._first!==this._prevFirst||this._num!==this._prevNum;(t||this._needsReset)&&(this._last=this._first+Math.min(this._num,this.totalItems-this._first)-1,(this._num||this._prevNum)&&(this._needsReset?this._reset(this._first,this._last):(this._discardHead(),this._discardTail(),this._addHead(),this._addTail()))),(this._needsRemeasure||this._needsReset)&&(this._indexToMeasure={});const e=this._num>0&&this._measureCallback&&(t||this._needsRemeasure||this._needsReset)?this._toMeasure:null;this._incremental||(this._prevActive.forEach(((t,e)=>this._unassignChild(e,t))),this._prevActive.clear()),this._prevFirst=this._first,this._prevLast=this._last,this._prevNum=this._num,this._needsReset=!1,this._needsRemeasure=!1,this._didRender(),e&&await this._measureChildren(e)}_didRender(){}_discardHead(){const t=this._ordered;for(let e=this._prevFirst;t.length&&e<this._first;e++)this._unassignChild(t.shift(),e)}_discardTail(){const t=this._ordered;for(let e=this._prevLast;t.length&&e>this._last;e--)this._unassignChild(t.pop(),e)}_addHead(){const t=this._first;for(let e=Math.min(this._last,this._prevFirst-1);e>=t;e--){const t=this._assignChild(e);this._insertBefore(t,this._firstChild),this.updateElement&&this.updateElement(t,this._items[e],e),this._ordered.unshift(t)}}_addTail(){const t=Math.max(this._first,this._prevLast+1),e=this._last;for(let i=t;i<=e;i++){const t=this._assignChild(i);this._insertBefore(t,null),this.updateElement&&this.updateElement(t,this._items[i],i),this._ordered.push(t)}}_reset(t,e){const i=this._active;this._active=this._prevActive,this._prevActive=i,this._ordered.length=0;let s=this._firstChild;for(let h=t;h<=e;h++){const t=this._assignChild(h);this._ordered.push(t),s?s===this._node(t)?s=this._nextSibling(t):this._insertBefore(t,s):this._childIsAttached(t)||this._insertBefore(t,null),this.updateElement&&this.updateElement(t,this._items[h],h)}}_assignChild(t){const e=this.elementKey?this.elementKey(t):t;let i;return(i=this._keyToChild.get(e))?this._prevActive.delete(i):(i=this.createElement(this._items[t],t),this._keyToChild.set(e,i),this._childToKey.set(i,e)),this._showChild(i),this._active.set(i,t),i}_unassignChild(t,e){if(this._hideChild(t),this._incremental)this._active.delete(t),this._prevActive.set(t,e);else{const i=this._childToKey.get(t);this._childToKey.delete(t),this._keyToChild.delete(i),this._active.delete(t),this.recycleElement?this.recycleElement(t,e):this._node(t).parentNode&&this._removeChild(t)}}get _firstChild(){return this._ordered.length&&this._childIsAttached(this._ordered[0])?this._node(this._ordered[0]):null}_node(t){return t}_nextSibling(t){return t.nextSibling}_insertBefore(t,e){this._container.insertBefore(t,e)}_removeChild(t){t.parentNode.removeChild(t)}_childIsAttached(t){const e=this._node(t);return e&&e.parentNode===this._container}_hideChild(t){t instanceof HTMLElement&&(t.style.display="none")}_showChild(t){t instanceof HTMLElement&&(t.style.display=null)}_measureChild(t){const{width:e,height:i}=t.getBoundingClientRect();return Object.assign({width:e,height:i},function(t){const e=window.getComputedStyle(t);return{marginTop:r(e.marginTop),marginRight:r(e.marginRight),marginBottom:r(e.marginBottom),marginLeft:r(e.marginLeft)}}(t))}}function r(t){const e=t?parseFloat(t):NaN;return Number.isNaN(e)?0:e}const n=t=>class extends t{constructor(t){const{part:e,renderItem:i,useShadowDOM:s,layout:h}=t,r=e.startNode.parentNode;super({container:r,scrollTarget:t.scrollTarget||r,useShadowDOM:s,layout:h}),this._pool=[],this._renderItem=i,this._hostPart=e}createElement(){return this._pool.pop()||new s.nt(this._hostPart.options)}updateElement(t,e,i){t.setValue(this._renderItem(e,i)),t.commit()}recycleElement(t){this._pool.push(t)}get _kids(){return this._ordered.map((t=>t.startNode.nextElementSibling))}_node(t){return t.startNode}_nextSibling(t){return t.endNode.nextSibling}_insertBefore(t,e){if(null===e&&(e=this._hostPart.endNode),this._childIsAttached(t)){const i=t.endNode.nextSibling;if(e!==t.startNode&&e!==i)for(let s=t.startNode;s!==i;){const t=s.nextSibling;super._insertBefore(s,e),s=t}}else t.startNode=(0,s.IW)(),t.endNode=(0,s.IW)(),super._insertBefore(t.startNode,e),super._insertBefore(t.endNode,e)}_hideChild(t){let e=t.startNode;for(;e&&e!==t.endNode;)super._hideChild(e),e=e.nextSibling}_showChild(t){let e=t.startNode;for(;e&&e!==t.endNode;)super._showChild(e),e=e.nextSibling}_measureChild(t){return super._measureChild(t.startNode.nextElementSibling)}};class l extends(n(h)){}const o=new WeakMap;(0,s.XM)((t=>async e=>{let i=o.get(e);i||(e.startNode.isConnected||await Promise.resolve(),i=new l({part:e,renderItem:t.renderItem}),o.set(e,i));const{first:s,num:h,totalItems:r}=t;Object.assign(i,{first:s,num:h,totalItems:r})}));let a;async function _(){return a||async function(){a=window.ResizeObserver;try{new a((function(){}))}catch(t){a=(await i.e(8800).then(i.bind(i,88800))).default}return a}()}const c="uni-virtualizer-host";let d=null;function m(t,e){return`\n ${t} {\n display: block;\n position: relative;\n contain: strict;\n height: 150px;\n overflow: auto;\n }\n ${e} {\n box-sizing: border-box;\n }`}class u extends Event{constructor(t,e){super(t,e),this._first=Math.floor(e.first||0),this._last=Math.floor(e.last||0),this._firstVisible=Math.floor(e.firstVisible||0),this._lastVisible=Math.floor(e.lastVisible||0)}get first(){return this._first}get last(){return this._last}get firstVisible(){return this._firstVisible}get lastVisible(){return this._lastVisible}}class p extends h{constructor(t){super({}),this._needsUpdateView=!1,this._layout=null,this._lazyLoadDefaultLayout=!0,this._scrollTarget=null,this._sizer=null,this._scrollSize=null,this._scrollErr=null,this._childrenPos=null,this._containerElement=null,this._containerInlineStyle=null,this._containerStylesheet=null,this._useShadowDOM=!0,this._containerSize=null,this._containerRO=null,this._childrenRO=null,this._skipNextChildrenSizeChanged=!1,this._scrollToIndex=null,this._num=0,this._first=-1,this._last=-1,this._prevFirst=-1,this._prevLast=-1,t&&Object.assign(this,t)}get container(){return super.container}set container(t){super.container=t,this._initResizeObservers().then((()=>{const e=this._containerElement,i=t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE?t.host:t;e!==i&&(this._containerRO.disconnect(),this._containerSize=null,e?(this._containerInlineStyle?e.setAttribute("style",this._containerInlineStyle):e.removeAttribute("style"),this._containerInlineStyle=null,e===this._scrollTarget&&(e.removeEventListener("scroll",this,{passive:!0}),this._sizer&&this._sizer.remove())):addEventListener("scroll",this,{passive:!0}),this._containerElement=i,i&&(this._containerInlineStyle=i.getAttribute("style")||null,this._applyContainerStyles(),i===this._scrollTarget&&(this._sizer=this._sizer||this._createContainerSizer(),this._container.prepend(this._sizer)),this._scheduleUpdateView(),this._containerRO.observe(i)))}))}get layout(){return this._layout}set layout(t){t!==this._layout&&(this._layout&&(this._measureCallback=null,this._layout.removeEventListener("scrollsizechange",this),this._layout.removeEventListener("scrollerrorchange",this),this._layout.removeEventListener("itempositionchange",this),this._layout.removeEventListener("rangechange",this),this._containerElement&&this._sizeContainer(void 0)),this._layout=t,this._layout&&("function"==typeof this._layout.updateItemSizes&&(this._measureCallback=this._layout.updateItemSizes.bind(this._layout),this.requestRemeasure()),this._layout.addEventListener("scrollsizechange",this),this._layout.addEventListener("scrollerrorchange",this),this._layout.addEventListener("itempositionchange",this),this._layout.addEventListener("rangechange",this),this._scheduleUpdateView()))}get scrollTarget(){return this._scrollTarget}set scrollTarget(t){t===window&&(t=null),this._scrollTarget!==t&&(this._scrollTarget&&(this._scrollTarget.removeEventListener("scroll",this,{passive:!0}),this._sizer&&this._scrollTarget===this._containerElement&&this._sizer.remove()),this._scrollTarget=t,t&&(t.addEventListener("scroll",this,{passive:!0}),t===this._containerElement&&(this._sizer=this._sizer||this._createContainerSizer(),this._container.prepend(this._sizer))))}get useShadowDOM(){return this._useShadowDOM}set useShadowDOM(t){this._useShadowDOM!==t&&(this._useShadowDOM=Boolean(t),this._containerStylesheet&&(this._containerStylesheet.parentElement.removeChild(this._containerStylesheet),this._containerStylesheet=null),this._applyContainerStyles())}set scrollToIndex(t){this._scrollToIndex=t,this._scheduleUpdateView()}async _render(){if(!this._lazyLoadDefaultLayout||this._layout){for(this._childrenRO.disconnect(),this._layout.totalItems=this.totalItems,this._needsUpdateView&&(this._needsUpdateView=!1,this._updateView()),null!==this._scrollToIndex&&(this._layout.scrollToIndex(this._scrollToIndex.index,this._scrollToIndex.position),this._scrollToIndex=null),this._layout.reflowIfNeeded();this._pendingRender&&(this._pendingRender=!1),this._sizeContainer(this._scrollSize),this._scrollErr&&(this._correctScrollError(this._scrollErr),this._scrollErr=null),await super._render(),this._layout.reflowIfNeeded(),this._pendingRender;);this._skipNextChildrenSizeChanged=!0,this._kids.forEach((t=>this._childrenRO.observe(t)))}else{this._lazyLoadDefaultLayout=!1;const{Layout1d:t}=await Promise.resolve().then(i.bind(i,18804));this.layout=new t({})}}_didRender(){this._childrenPos&&(this._positionChildren(this._childrenPos),this._childrenPos=null)}handleEvent(t){switch(t.type){case"scroll":this._scrollTarget&&t.target!==this._scrollTarget||this._scheduleUpdateView();break;case"scrollsizechange":this._scrollSize=t.detail,this._scheduleRender();break;case"scrollerrorchange":this._scrollErr=t.detail,this._scheduleRender();break;case"itempositionchange":this._childrenPos=t.detail,this._scheduleRender();break;case"rangechange":this._adjustRange(t.detail);break;default:console.warn("event not handled",t)}}async _initResizeObservers(){if(null===this._containerRO){const t=await _();this._containerRO=new t((t=>this._containerSizeChanged(t[0].contentRect))),this._childrenRO=new t((()=>this._childrenSizeChanged()))}}_applyContainerStyles(){if(this._useShadowDOM){if(null===this._containerStylesheet){(this._containerStylesheet=document.createElement("style")).textContent=m(":host","::slotted(*)")}const t=this._containerElement.shadowRoot||this._containerElement.attachShadow({mode:"open"}),e=t.querySelector("slot:not([name])");t.appendChild(this._containerStylesheet),e||t.appendChild(document.createElement("slot"))}else d||(d=document.createElement("style"),d.textContent=m("."+c,`.${c} > *`),document.head.appendChild(d)),this._containerElement&&this._containerElement.classList.add(c)}_createContainerSizer(){const t=document.createElement("div");return Object.assign(t.style,{position:"absolute",margin:"-2px 0 0 0",padding:0,visibility:"hidden",fontSize:"2px"}),t.innerHTML=" ",t}get _kids(){return this._ordered}_scheduleUpdateView(){this._needsUpdateView=!0,this._scheduleRender()}_updateView(){let t,e,i,s;if(this._scrollTarget===this._containerElement)t=this._containerSize.width,e=this._containerSize.height,s=this._containerElement.scrollLeft,i=this._containerElement.scrollTop;else{const h=this._containerElement.getBoundingClientRect(),r=this._scrollTarget?this._scrollTarget.getBoundingClientRect():{top:h.top+scrollY,left:h.left+scrollX,width:innerWidth,height:innerHeight},n=r.width,l=r.height,o=Math.max(0,Math.min(n,h.left-r.left)),a=Math.max(0,Math.min(l,h.top-r.top));t=("vertical"===this._layout.direction?Math.max(0,Math.min(n,h.right-r.left)):n)-o,e=("vertical"===this._layout.direction?l:Math.max(0,Math.min(l,h.bottom-r.top)))-a,s=Math.max(0,-(h.left-r.left)),i=Math.max(0,-(h.top-r.top))}this._layout.viewportSize={width:t,height:e},this._layout.viewportScroll={top:i,left:s}}_sizeContainer(t){if(this._scrollTarget===this._containerElement){const e=t&&t.width?t.width-1:0,i=t&&t.height?t.height-1:0;this._sizer.style.transform=`translate(${e}px, ${i}px)`}else{const e=this._containerElement.style;e.minWidth=t&&t.width?t.width+"px":null,e.minHeight=t&&t.height?t.height+"px":null}}_positionChildren(t){const e=this._kids;Object.keys(t).forEach((i=>{const s=i-this._first,h=e[s];if(h){const{top:e,left:s}=t[i];h.style.position="absolute",h.style.transform=`translate(${s}px, ${e}px)`}}))}_adjustRange(t){this.num=t.num,this.first=t.first;const e=this._firstVisible!==t.firstVisible||this._lastVisible!==t.lastVisible;this._firstVisible=t.firstVisible,this._lastVisible=t.lastVisible,this._incremental=!t.stable,t.remeasure?this.requestRemeasure():(t.stable||e)&&this._notifyRange()}_shouldRender(){if(!super._shouldRender()||!this._containerElement||!this._layout&&!this._lazyLoadDefaultLayout)return!1;if(null===this._containerSize){const{width:t,height:e}=this._containerElement.getBoundingClientRect();this._containerSize={width:t,height:e}}return this._containerSize.width>0||this._containerSize.height>0}_correctScrollError(t){this._scrollTarget?(this._scrollTarget.scrollTop-=t.top,this._scrollTarget.scrollLeft-=t.left):window.scroll(window.scrollX-t.left,window.scrollY-t.top)}_notifyRange(){const{first:t,num:e}=this,i=t+e-1;this._container.dispatchEvent(new u("rangechange",{first:t,last:i,firstVisible:this._firstVisible,lastVisible:this._lastVisible}))}_containerSizeChanged(t){const{width:e,height:i}=t;this._containerSize={width:e,height:i},this._scheduleUpdateView()}_childrenSizeChanged(){this._skipNextChildrenSizeChanged?this._skipNextChildrenSizeChanged=!1:this.requestRemeasure()}}class g extends(n(p)){}const f=new WeakMap,y=(0,s.XM)((t=>async e=>{let i=f.get(e);if(!i){e.startNode.isConnected||await Promise.resolve();const{renderItem:s,layout:h,scrollTarget:r,useShadowDOM:n}=t;i=new g({part:e,renderItem:s,layout:h,scrollTarget:r,useShadowDOM:n}),f.set(e,i)}Object.assign(i,{items:t.items,totalItems:void 0===t.totalItems?null:t.totalItems,scrollToIndex:void 0===t.scrollToIndex?null:t.scrollToIndex})}));i(18804),i(22402);function w(t,e,i,s){var h,r=arguments.length,n=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var l=t.length-1;l>=0;l--)(h=t[l])&&(n=(r<3?h(n):r>3?h(e,i,n):h(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n}var v=i(15652);let S=class extends v.oi{constructor(){super(),this.renderRoot=this}get renderItem(){return this._renderItem}set renderItem(t){t!==this.renderItem&&(this._renderItem=t,this.requestUpdate())}async scrollToIndex(t,e="start"){this._scrollToIndex={index:t,position:e},this.requestUpdate(),await this.updateComplete,this._scrollToIndex=null}render(){return v.dy`${y({items:this.items,renderItem:this._renderItem,scrollTarget:this.scrollTarget,scrollToIndex:this._scrollToIndex,useShadowDOM:!0})}`}};w([(0,v.Cb)()],S.prototype,"_renderItem",void 0),w([(0,v.Cb)()],S.prototype,"items",void 0),w([(0,v.Cb)()],S.prototype,"scrollTarget",void 0),S=w([(0,v.Mo)("lit-virtualizer")],S)}}]);
//# sourceMappingURL=chunk.38ffaaa4674b21a384ce.js.map