@getflip/swirl-components 0.534.0 → 0.534.1

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.
@@ -1 +0,0 @@
1
- import{r as t,c as i,h as s,a as h,d as e}from"./p-Dz56lJ37.js";import{g as n,c as l}from"./p-orsBiyT_.js";import{S as o}from"./p-CMrz6687.js";import{d as r,u as a,i as u,q as c}from"./p-D23VxAsw.js";var d,f,b=n((f||(f=1,d=function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},h=void 0,e=void 0,n=void 0,l=[];return function(){var r=function(t){return"function"==typeof t?t():t}(i),a=(new Date).getTime(),u=!h||a-h>r;h=a;for(var c=arguments.length,d=Array(c),f=0;f<c;f++)d[f]=arguments[f];if(u&&s.leading)return s.accumulate?Promise.resolve(t.call(this,[d])).then((function(t){return t[0]})):Promise.resolve(t.call.apply(t,[this].concat(d)));if(e?clearTimeout(n):e=function(){var t={};return t.promise=new Promise((function(i,s){t.resolve=i,t.reject=s})),t}(),l.push(d),n=setTimeout(o.bind(this),r),s.accumulate){var b=l.length-1;return e.promise.then((function(t){return t[b]}))}return e.promise};function o(){var i=e;clearTimeout(n),Promise.resolve(s.accumulate?t.call(this,l):t.apply(this,l[l.length-1])).then(i.resolve,i.reject),l=[],e=null}}),d));function v(t,i,s){let h,e=s.initialDeps??[],n=!0;function l(){const l=t();return l.length!==e.length||l.some(((t,i)=>e[i]!==t))?(e=l,h=i(...l),!(null==s?void 0:s.onChange)||n&&s.skipInitialOnChange||s.onChange(h),n=!1,h):h}return l.updateDeps=t=>{e=t},l}function w(t){if(void 0===t)throw new Error("Unexpected undefined");return t}const p=(t,i)=>Math.abs(t-i)<1.01,m=(t,i,s)=>{let h;return Object.assign((function(...e){t.clearTimeout(h),h=t.setTimeout((()=>i.apply(this,e)),s)}),{cancel:()=>{t.clearTimeout(h)}})};let g;const y=()=>{if(void 0!==g)return g;if("undefined"==typeof navigator)return g=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return g=!0;const t=navigator.maxTouchPoints;return g="MacIntel"===navigator.platform&&void 0!==t&&t>0};let x;const M={capture:!0,passive:!0};class k{constructor(t){this.host=t,this._touch=null,this.inMotion=()=>null!==this._touch&&"lateFling"!==this._touch.phase,this.dragging=()=>{var t;return"down"===(null==(t=this._touch)?void 0:t.phase)&&this._touch.moved},this.tail=()=>{var t;return"tail"===(null==(t=this._touch)?void 0:t.phase)?this._touch.moved?"fling":"tap":null},this.onScroll=({isScrolling:t,ownReadBack:i,moved:s,external:h})=>{var e,n,l;return t&&"tail"===(null==(e=this._touch)?void 0:e.phase)?this._openTail(this._touch.moved||!i,!1):"lateFling"===(null==(n=this._touch)?void 0:n.phase)&&(this.host.now()>this._touch.until?this._touch=null:h&&t&&s&&this._openTail(!0,!1)),!(i||!t||!s||"down"!==(null==(l=this._touch)?void 0:l.phase)||(this._touch.moved=!0,0))},this.touchStart=()=>{this.end(),this._touch={phase:"down",moved:!1}},this.touchEnd=()=>{var t;const i="down"===(null==(t=this._touch)?void 0:t.phase)&&this._touch.moved;this.end(),this._openTail(i,i)},this.end=()=>{var t;const i=this.host.getWindow();"tail"===(null==(t=this._touch)?void 0:t.phase)&&null!=i&&i.clearTimeout(this._touch.timerId),this._touch=null},this.listen=t=>{const i=()=>this.touchStart(),s=()=>this.touchEnd();return t.addEventListener("touchstart",i,M),t.addEventListener("touchend",s,M),t.addEventListener("touchcancel",s,M),()=>{t.removeEventListener("touchstart",i,M),t.removeEventListener("touchend",s,M),t.removeEventListener("touchcancel",s,M),this.end()}},this._openTail=(t,i)=>{const s=this.host.getWindow();if(null==s)return;this.end();const h={phase:"tail",moved:t,awaitingFling:i,timerId:s.setTimeout((()=>{this.host.tailStillMoving()?this._openTail(h.moved,h.awaitingFling):(this._touch=h.awaitingFling?{phase:"lateFling",until:this.host.now()+1e3}:null,this.host.onTailClosed())}),150)};this._touch=h}}get touch(){return this._touch}}const S=t=>{const{clientWidth:i,clientHeight:s}=t;return{width:i,height:s}},_=t=>{const i=new Set;return{schedule:s=>{const h=t.requestAnimationFrame((()=>{i.delete(h),s()}));i.add(h)},cancel:()=>{i.forEach((i=>t.cancelAnimationFrame(i))),i.clear()}}},C=t=>t,R=t=>{const i=t.overscan*Math.max(t.lanes??1,1),s=Math.max(t.startIndex-i,0),h=Math.min(t.endIndex+i,t.count-1)-s+1,e=new Array(h);for(let t=0;t<h;t++)e[t]=s+t;return e},A=(t,i)=>{const s=t.scrollElement;if(!s)return;const h=t.targetWindow;if(!h)return;const e=t=>{const{width:s,height:h}=t;i({width:Math.round(s),height:Math.round(h)})};if(e(S(s)),!h.ResizeObserver)return()=>{};const n=_(h),l=new h.ResizeObserver((()=>{const i=()=>{e(S(s))};t.options.useAnimationFrameWithResizeObserver?n.schedule(i):i()}));return l.observe(s,{box:"content-box"}),()=>{l.unobserve(s),n.cancel()}},I={passive:!0},z=(t,i)=>{const s=t.scrollElement;if(!s)return;const h=()=>{i({width:s.innerWidth,height:s.innerHeight})};return h(),s.addEventListener("resize",h,I),()=>{s.removeEventListener("resize",h)}},O="undefined"==typeof window||"onscrollend"in window,B=(t,i,s)=>{const h=t.scrollElement;if(!h)return;const e=t.targetWindow;if(!e)return;const n=t.options.useScrollendEvent&&O;let l=0;const o=n?null:m(e,(()=>i(s(h),!1)),t.options.isScrollingResetDelay),r=t=>()=>{l=s(h),null==o||o(),i(l,t)},a=r(!0),u=r(!1);return h.addEventListener("scroll",a,I),n&&h.addEventListener("scrollend",u,I),()=>{h.removeEventListener("scroll",a),n&&h.removeEventListener("scrollend",u),null==o||o.cancel()}},E=(t,i)=>B(t,i,(i=>{const{horizontal:s,isRtl:h}=t.options;return s?i.scrollLeft*(h?-1:1):i.scrollTop})),F=(t,i)=>B(t,i,(i=>t.options.horizontal?i.scrollX:i.scrollY)),D=(t,i,s)=>{if(s.options.useCachedMeasurements){const i=s.indexFromElement(t),h=s.options.getItemKey(i);return s.itemSizeCache.get(h)??s.options.estimateSize(i)}if(null==i?void 0:i.borderBoxSize){const t=i.borderBoxSize[0];if(t)return Math.round(t[s.options.horizontal?"inlineSize":"blockSize"])}if(!i){const i=s.indexFromElement(t),h=s.options.getItemKey(i),e=s.itemSizeCache.get(h);if(void 0!==e)return e}return t[s.options.horizontal?"offsetWidth":"offsetHeight"]},T=(t,{adjustments:i=0,behavior:s},h)=>{var e,n;null==(n=null==(e=h.scrollElement)?void 0:e.scrollTo)||n.call(e,{[h.options.horizontal?"left":"top"]:t+i,behavior:s})},W=T,q=T,L=(t,i)=>"smooth"===t?i?"smoothLanded":"smooth":"instant",j=t=>"smooth"===(null==t?void 0:t.phase)||"smoothLanded"===(null==t?void 0:t.phase);class P{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this._holdOffset=0,this._reportedOverscroll=!1,this._iosGesture=new k({getWindow:()=>this.targetWindow,now:()=>this.now(),tailStillMoving:()=>{const t=this.scrollState;if("queued"!==(null==t?void 0:t.phase)||null!==this.pendingWrite)return!1;const i=this._readElementOffset();return!(null===i||null===this._lastElementOffset||Math.abs(i-this._lastElementOffset)<1||(this._lastElementOffset=i,t.samples=[...t.samples??[],{t:this.now(),offset:i}],0))},onTailClosed:()=>{const t=this.scrollState;"queued"===(null==t?void 0:t.phase)&&function(t){const i=t[t.length-1];if(void 0===i)return!1;let s=t.length-2;for(;s>=0&&i.t-t[s].t<40;)s--;if(s<0)return!1;const h=t[s];return Math.abs(i.offset-h.offset)/(i.t-h.t)>=.05}(t.samples??[])&&(this.scrollState=null),this._flushHoldIfReady(!0),this._writeAwaitingCommand(),this._retryClampedAdjustment()}}),this._lastElementOffset=null,this.pendingWrite=null,this._clampedAdjustment=null,this.elementsCache=new Map,this._resizeBatch=null,this.now=()=>{var t,i,s;return(null==(s=null==(i=null==(t=this.targetWindow)?void 0:t.performance)?void 0:i.now)?void 0:s.call(i))??Date.now()},this.observer=(()=>{let t=null,i=null,s=!1,h=!1;const e=new Set,n=()=>{if(t)return t;const h=this.targetWindow;if(!h||!h.ResizeObserver)return null;const e=i=_(h);return t=new h.ResizeObserver((t=>{const i=()=>{const i={sync:!1};this._resizeBatch=i;try{t.forEach(l)}finally{this._resizeBatch=null,i.notify&&(this.notify(i.sync),this._noteClampMax(),this._flushHoldIfReady(!0),this._retryClampedAdjustment(),this.measureElement(null))}};if(this.options.useAnimationFrameWithResizeObserver)e.schedule(i);else{s=!0;try{i()}finally{s=!1}}}))},l=t=>{const i=t.target,s=this.indexFromElement(i);if(i.isConnected)this.isIndexInRange(s)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(i,t,this));else{this.observer.unobserve(i);for(const[t,s]of this.elementsCache)if(s===i){this.elementsCache.delete(t);break}}};return{disconnect:()=>{var s;null==(s=n())||s.disconnect(),null==i||i.cancel(),e.clear(),h=!1,t=null,i=null},observe:l=>{const o=n();o&&(s?(e.add(l),h||(h=!0,null==i||i.schedule((()=>{h=!1,e.forEach((i=>{i.isConnected&&(null==t||t.observe(i,{box:"border-box"}))})),e.clear()})))):o.observe(l,{box:"border-box"}))},unobserve:t=>{var i;e.delete(t),null==(i=n())||i.unobserve(t)}}})(),this.range=null,this.setOptions=t=>{var i;const s={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:C,rangeExtractor:R,onChange:()=>{},measureElement:D,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const i in t){const h=t[i];void 0!==h&&(s[i]=h)}const h=this.options;let e=null,n=null,l=!1;if(void 0!==h&&h.enabled&&s.enabled&&"end"===s.anchorTo&&null!==this.scrollElement){const t=h.count,o=s.count,r=this.getMeasurements(),a=(null==(i=this._singleLaneMeasurements)?void 0:i.items)??r,u=t=>{return"object"==typeof(i=a[t])?i.key:i;var i},c=t>0?u(0):null,d=t>0?u(t-1):null;if(o!==t||t>0&&o>0&&(s.getItemKey(0)!==c||s.getItemKey(o-1)!==d)){l=!0;const i=t>0?this.getVirtualItemForOffset(this.getScrollOffset())??r[0]:null;i&&(e=[i.key,this.getScrollOffset()-i.start]);const a=!0===s.followOnAppend?"auto":s.followOnAppend||null;a&&o>0&&this.isAtEnd(h.scrollEndThreshold)&&(0===t||s.getItemKey(o-1)!==d)&&(o>t||function(t,i,s,h){if(0===i)return!1;const e=h(0),n=new Set;let l=0;for(;l<t;){const t=s(l);if(t===e)break;n.add(t),l++}const o=t-l;if(0===o||o>=i)return!1;for(let t=0;t<o;t++)if(h(t)!==s(l+t))return!1;for(let t=o;t<i;t++)if(n.has(h(t)))return!1;return!0}(t,o,u,s.getItemKey))&&(n=a)}}this.options=s,l&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=null;if(e&&null!==this.scrollOffset&&!this._awaitingCommandReadBack()){const[t,i]=e,s=this.getMeasurements(),{count:h,getItemKey:l}=this.options;let r=0;for(;r<h&&l(r)!==t;)r++;if(r<h){const t=s[r];if(t){const s=Math.max(0,t.start+i);n||s===this.scrollOffset||(o=s-this.scrollOffset,this.scrollOffset=s)}}}n?this.pendingScrollAnchor={kind:"follow",behavior:n}:null!==o&&(this._canWriteScroll()?this.pendingScrollAnchor={kind:"anchor",delta:o}:(this._holdOffset+=o,this._followOffsetTarget(o)))},this.notify=t=>{var i,s;null==(s=(i=this.options).onChange)||s.call(i,this,t)},this.maybeNotify=v((()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null])),(t=>{this.notify(t)}),{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{var t;this.unsubs.filter(Boolean).forEach((t=>t())),this.unsubs=[],this.observer.disconnect(),null!=this.rafId&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,null==(t=this._momentumStop)||t.restore(),this._momentumStop=null,this.isScrolling=!1,this.scrollDirection=null,this._holdOffset=0,this._reportedOverscroll=!1,this._clampedAdjustment=null,this.pendingWrite=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const i=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==i){if(this.cleanup(),!i)return void this.maybeNotify();this.scrollElement=i,this.targetWindow=this.scrollElement&&"ownerDocument"in this.scrollElement?this.scrollElement.ownerDocument.defaultView:(null==(t=this.scrollElement)?void 0:t.window)??null,this.elementsCache.forEach((t=>{this.observer.observe(t)})),this.unsubs.push(this.options.observeElementRect(this,(t=>{this.scrollRect=t,this.maybeNotify()}))),this.unsubs.push(this.options.observeElementOffset(this,((t,i)=>{var s,h,e,n;const l=i?this._elementMaxScrollOffset():null,o=this._reportedOverscroll;this._reportedOverscroll=t<0||null!==l&&t>l+1;const r=t;this._lastElementOffset=r,t=this._toLayoutOffset(t);const a=this._classifyScrollEvent(t,i,l);if("spurious"===a)return;"readBack"===a?t=this.pendingWrite.target:"clampedReadBack"===a&&null!=(null==(s=this.scrollState)?void 0:s.index)&&t<this.getMaxScrollOffset()-1.5?this.scrollState.lastTargetOffset=t:function({kind:t,offset:i,command:s,target:h}){return!("spurious"===t||"readBack"===t||"clampedReadBack"===t||null==(null==s?void 0:s.index)||"queued"===s.phase||(e=s.phase,"smooth"===e||"smoothFinishing"===e)||p(i,s.lastTargetOffset)||p(i,h())||"clampedEcho"===t);var e}({kind:a,offset:t,command:this.scrollState,target:()=>this.getScrollStateTarget(this.scrollState)})&&(this.scrollState=null),this.pendingWrite=null,null!==this._clampedAdjustment&&Math.abs(t-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null);const u=this.getScrollOffset(),c=this.scrollDirection;this.scrollDirection=i?u===t?this.scrollDirection:u<t?"forward":"backward":null,this.scrollOffset=t,this.isScrolling=i;const d=this.scrollState;if("queued"===(null==d?void 0:d.phase)&&"external"===a&&i)if(o||this._reportedOverscroll)d.samples=[];else{const t=this.now();d.samples=[...(d.samples??[]).filter((i=>t-i.t<=200)),{t,offset:r}],(null!==c&&this.scrollDirection!==c||function(t){const i=t[t.length-1];if(void 0===i)return!1;let s=t.length-2;for(;s>=0&&i.t-t[s].t<40;)s--;if(s<0)return!1;const h=t[s];let e=s-1;for(;e>=0&&h.t-t[e].t<40;)e--;if(e<0)return!1;const n=t[e],l=(i.offset-h.offset)/(i.t-h.t),o=(h.offset-n.offset)/(h.t-n.t);return l*o>=0&&Math.abs(l)>=2*Math.abs(o)&&Math.abs(l)-Math.abs(o)>=.8}(d.samples))&&(this.scrollState=null)}this._iosGesture.onScroll({isScrolling:i,ownReadBack:"readBack"===a,moved:t!==u,external:"external"===a&&"smooth"!==(null==(h=this.scrollState)?void 0:h.phase)&&"smoothFinishing"!==(null==(e=this.scrollState)?void 0:e.phase)})&&"queued"===(null==(n=this.scrollState)?void 0:n.phase)&&(this.scrollState=null),this._flushHoldIfReady(!0),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()}))),"addEventListener"in this.scrollElement&&this.unsubs.push(this._iosGesture.listen(this.scrollElement)),this._scrollToOffset(this.getScrollOffset())}this._noteClampMax();const s=this.pendingScrollAnchor;this.pendingScrollAnchor=null,s&&this.scrollElement&&this.options.enabled&&("anchor"===s.kind?this._canWriteScroll()?j(this.scrollState)&&!p(this.getScrollOffset()-s.delta,this.scrollState.lastTargetOffset)||(this._followOffsetTarget(s.delta),this._scrollToOffset(this.getScrollOffset())):(this._holdOffset+=s.delta,this._followOffsetTarget(s.delta),this.notify(!1)):this.scrollToEnd({behavior:s.behavior})),this._flushHoldIfReady(!1),this._retryClampedAdjustment()},this._classifyScrollEvent=(t,i,s)=>{var h;return function({offset:t,isScrolling:i,elementMax:s,holdOffset:h,scrollOffset:e,pendingWrite:n,clampedMaxAtWrite:l}){var o;return i&&null===n&&t===e?"spurious":null!==n&&Math.abs(t-n.target)<1.5?"readBack":null!==n&&!n.smooth&&null!==s&&n.target>s+h+.5&&Math.abs(t-(s+h))<1.5||null!==n&&!n.smooth&&(null==(o=n.lowMaxes)?void 0:o.some((i=>Math.abs(t-i)<1.5)))?"clampedReadBack":null!==l&&Math.abs(t-l)<1.5?"clampedEcho":"external"}({offset:t,isScrolling:i,elementMax:s,holdOffset:this._holdOffset,scrollOffset:this.scrollOffset,pendingWrite:this.pendingWrite,clampedMaxAtWrite:(null==(h=this._clampedAdjustment)?void 0:h.maxAtWrite)??null})},this._retryClampedAdjustment=()=>{if(null===this._clampedAdjustment||!this.scrollElement||!this.options.enabled||!this._canWriteScroll())return;const{target:t,maxAtWrite:i}=this._clampedAdjustment,s=this.getMaxScrollOffset();s>i+.5&&(this._clampedAdjustment=t>s+.5?{target:t,maxAtWrite:s}:null,this._scrollToOffset(t))},this._writeAwaitingCommand=()=>{const t=this.scrollState;if(null===t||"queued"!==t.phase)return;const{behavior:i}=t;this.getMeasurements();const s=this.getScrollStateTarget(t);t.lastTargetOffset=s,this._clampedAdjustment=null,t.phase=L(i,null!=t.index&&p(s,this.getScrollOffset())),this._scrollToOffset(s,{behavior:i}),this.scheduleScrollReconcile()},this._readElementOffset=()=>{const t=this.scrollElement;if(null==t)return null;const{horizontal:i,isRtl:s}=this.options;return"number"==typeof t.scrollTop?i?t.scrollLeft*(s?-1:1):t.scrollTop:"number"==typeof t.scrollY?i?t.scrollX:t.scrollY:null},this._canWriteScroll=()=>!(y()&&this._iosGesture.inMotion()||this._reportedOverscroll),this._flushHoldIfReady=t=>{var i;if(0===this._holdOffset)return;if(!this.scrollElement||!this.options.enabled)return;if(!this._canWriteScroll())return;if("smooth"===(null==(i=this.scrollState)?void 0:i.phase))return;this._holdOffset=0,null!==this.scrollOffset&&this.scrollOffset<0&&(this.scrollOffset=0),this.notify(t);const s=this.getCommandWrittenOffset()??this.getScrollOffset();this._clampedAdjustment=this._clampedBy(s),this._scrollToOffset(s)},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??("function"==typeof this.options.initialOffset?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=v((()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap]),((t,i,s,h,e,n,l,o)=>(void 0!==this.prevLanes&&this.prevLanes!==n&&(this.lanesChangedFlag=!0),this.prevLanes=n,this.pendingMin=null,{count:t,paddingStart:i,scrollMargin:s,getItemKey:h,enabled:e,lanes:n,laneAssignmentMode:l,gap:o})),{key:!1}),this.isIndexInRange=t=>t>=0&&t<this.options.count,this.getMeasurements=v((()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion]),(({count:t,paddingStart:i,scrollMargin:s,getItemKey:h,enabled:e,lanes:n,laneAssignmentMode:l,gap:o})=>{var r;const a=this.itemSizeCache;if(!e)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const i of this.laneAssignments.keys())i>=t&&this.laneAssignments.delete(i);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),0!==this.measurementsCache.length||this.lanesSettling||(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach((t=>{this.itemSizeCache.set(t.key,t.size)})));const u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),1===n){const e=2*t;let n=null==(r=this._singleLaneMeasurements)?void 0:r.flat;if(!n||n.length<e){const t=new Float64Array(e);n&&u>0&&t.set(n.subarray(0,2*u)),n=t}const l=0===u?new Array(t):this._singleLaneMeasurements.items.slice();let c;if(0===u)c=i+s;else{const t=u-1;c=n[2*t]+n[2*t+1]+o}for(let i=u;i<t;i++){const t=h(i);l[i]=t;const s=a.get(t),e="number"==typeof s?s:this.options.estimateSize(i);n[2*i]=c,n[2*i+1]=e,c+=e+o}this._singleLaneMeasurements={flat:n,items:l};const d=function(t,i){const s=t.length;return new Proxy(t,{get(t,h,e){if("string"==typeof h){const e=h.charCodeAt(0);if(e>=48&&e<=57){const e=+h;if(Number.isInteger(e)&&e>=0&&e<s){let s=t[e];if("object"!=typeof s){const h=i[2*e];s=t[e]={index:e,key:s,start:h,size:i[2*e+1],end:h+i[2*e+1],lane:0}}return s}}if("length"===h)return s}return Reflect.get(t,h,e)}})}(l,n);return this.measurementsCache=d,d}const c=this.measurementsCache.slice(0,u),d=new Array(n).fill(void 0),f=new Float64Array(n);let b=0;for(let t=0;t<u;t++){const i=c[t];i&&(void 0===d[i.lane]&&b++,d[i.lane]=t,f[i.lane]=i.end)}for(let e=u;e<t;e++){const t=h(e),r=this.laneAssignments.get(e);let u,v;const w="estimate"===l||a.has(t);if(void 0!==r&&this.options.lanes>1){u=r;const t=d[u],h=void 0!==t?c[t]:void 0;v=h?h.end+o:i+s}else if(b===n){let t=0,i=f[0],s=d[0];for(let h=1;h<n;h++){const e=f[h];(e<i||e===i&&d[h]<s)&&(t=h,i=e,s=d[h])}u=t,v=i+o,w&&this.laneAssignments.set(e,u)}else u=e%this.options.lanes,v=i+s,w&&this.laneAssignments.set(e,u);const p=a.get(t),m="number"==typeof p?p:this.options.estimateSize(e),g=v+m;c[e]={index:e,start:v,size:m,end:g,key:t,lane:u},void 0===d[u]&&b++,d[u]=e,f[u]=g}return this.measurementsCache=c,c}),{key:!1,debug:()=>this.options.debug}),this.calculateRange=v((()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes,this._getLayoutTotalSize()+this.options.scrollMargin]),((t,i,s,h,e)=>{if(0===t.length||0===i)return this.range=null,null;const n=Math.max(e-i,0);return this.range=function(t,i,s,h,e){const n=t.length-1;if(t.length<=h)return{startIndex:0,endIndex:n};if(1===h&&null!==e){const t=function(t,i,s){let h=0;for(;h<=i;){const e=(h+i)/2|0,n=t[2*e];if(n<s)h=e+1;else{if(!(n>s))return e;i=e-1}}return h>0?h-1:0}(e,n,s);let h=t;const l=s+i;for(;h<n&&e[2*h]+e[2*h+1]<l;)h++;return{startIndex:t,endIndex:h}}let l=V(0,n,(i=>t[i].start),s),o=l;if(1===h)for(;o<n&&t[o].end<s+i;)o++;else if(h>1){const e=Array(h).fill(0);for(;o<n&&e.some((t=>t<s+i));){const i=t[o];e[i.lane]=i.end,o++}const r=Array(h).fill(s+i);for(;l>=0&&r.some((t=>t>=s));){const i=t[l];r[i.lane]=i.start,l--}l=Math.max(0,l-l%h),o=Math.min(n,o+(h-1-o%h))}return{startIndex:l,endIndex:o}}(t,i,Math.min(s,n),h,1===h&&null!==this._singleLaneMeasurements?this._singleLaneMeasurements.flat:null),this.range}),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=v((()=>{let t=null,i=null;const s=this.calculateRange();return s&&(t=s.startIndex,i=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,i,this.options.lanes]}),((t,i,s,h,e,n)=>null===h||null===e?[]:t({startIndex:h,endIndex:e,overscan:i,count:s,lanes:n})),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const i=this.options.indexAttribute,s=t.getAttribute(i);return s?parseInt(s,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var i;if(!j(this.scrollState))return!0;const s=this.scrollState.index??(null==(i=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))?void 0:i.index);if(void 0!==s&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),h=Math.max(0,s-i),e=Math.min(this.options.count-1,s+i);return t>=h&&t<=e}return!0},this.measureElement=t=>{if(!t)return void this.elementsCache.forEach(((t,i)=>{t.isConnected||(this.observer.unobserve(t),this.elementsCache.delete(i))}));const i=this.indexFromElement(t);if(!this.isIndexInRange(i))return;const s=this.options.getItemKey(i),h=this.elementsCache.get(s);h!==t&&(h&&this.observer.unobserve(h),this.observer.observe(t),this.elementsCache.set(s,t)),t.isConnected&&(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,i)=>{var s,h,e;if(!this.isIndexInRange(t))return;let n,l,o;(null==(s=this._resizeBatch)?void 0:s.sync)&&this.getMeasurements();const r=null==(h=this._singleLaneMeasurements)?void 0:h.flat;if(1===this.options.lanes&&null!=r)o=this.options.getItemKey(t),l=r[2*t],n=r[2*t+1];else{const i=this.measurementsCache[t];if(!i)return;o=i.key,l=i.start,n=i.size}const a=this.itemSizeCache.get(o)??n,u=i-a;if(0!==u){const s="end"===this.options.anchorTo&&!j(this.scrollState)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,h=s?this._getLayoutTotalSize():0,r=this.getScrollOffset(),c=this.itemSizeCache.has(o)?l+a<=r&&"backward"!==this.scrollDirection:l<r,d=!j(this.scrollState)&&(void 0!==this.shouldAdjustScrollPositionOnItemSizeChange?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:o,start:l,size:n,end:l+n,lane:0},u,this):c);(null===this.pendingMin||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(o,i),this.itemSizeCacheVersion++;let f=!1;if(this._awaitingCommandReadBack()||(s?f=this.applyScrollAdjustment(this._getLayoutTotalSize()-h):d&&(f=this.applyScrollAdjustment(u))),this._resizeBatch)return this._resizeBatch.notify=!0,void((e=this._resizeBatch).sync||(e.sync=f));this.notify(f),this._noteClampMax(),this._flushHoldIfReady(!0),this._retryClampedAdjustment()}},this.getVirtualItems=v((()=>[this.getVirtualIndexes(),this.getMeasurements(),this._holdOffset]),((t,i,s)=>{const h=[];for(let e=0,n=t.length;e<n;e++){const n=i[t[e]];h.push(0===s?n:{...n,start:n.start-s,end:n.end-s})}return h}),{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{var i;const s=this.getMeasurements();if(0===s.length)return;const h=null==(i=this._singleLaneMeasurements)?void 0:i.flat,e=V(0,s.length-1,1===this.options.lanes&&null!=h?t=>h[2*t]:t=>w(s[t]).start,t);return w(s[e])},this._noteClampMax=()=>{if(!this._awaitingCommandReadBack())return;const t=this._elementMaxScrollOffset();if(null===t)return;const i=this.pendingWrite,s=Math.max(t,0)+this._holdOffset;if(s>=i.target)return;const h=i.lowMaxes??(i.lowMaxes=[]);h[h.length-1]!==s&&h.push(s)},this.getMaxScrollOffset=()=>(this._elementMaxScrollOffset()??0)+this._holdOffset,this._toLayoutOffset=t=>{var i;let s=t+this._holdOffset;return"anchor"===(null==(i=this.pendingScrollAnchor)?void 0:i.kind)&&(s+=this.pendingScrollAnchor.delta),s},this._elementMaxScrollOffset=()=>{const t=this.scrollElement;if(null===t)return null;if("scrollHeight"in t)return this.options.horizontal?t.scrollWidth-t.clientWidth:t.scrollHeight-t.clientHeight;if("document"in t){const i=t.document.documentElement;return this.options.horizontal?i.scrollWidth-t.innerWidth:i.scrollHeight-t.innerHeight}return null},this._momentumStop=null,this._stopMomentum=t=>{const i=this.scrollElement,s=this.targetWindow;if(null===i||null===s)return;const h="document"in i?i.document.scrollingElement:i;if(!(null==h?void 0:h.style))return;if(this._momentumStop)return void(this._momentumStop.done=t);const{style:e}=h,n=this.options.horizontal?"overflow-x":"overflow-y",l=e.getPropertyValue(n),o=e.getPropertyPriority(n),r=()=>this.options.horizontal?h.clientHeight:h.clientWidth,a=r();if(e.setProperty(n,"hidden","important"),r()!==a)return void e.setProperty(n,l,o);const u={restore:()=>"hidden"===e.getPropertyValue(n)&&"important"===e.getPropertyPriority(n)&&(e.setProperty(n,l,o),!0),done:t};this._momentumStop=u,s.requestAnimationFrame((()=>s.requestAnimationFrame((()=>{this._momentumStop===u&&(this._momentumStop=null,u.restore()&&u.done())}))))},this._clampedBy=t=>{const i=this._elementMaxScrollOffset();if(null===i)return null;const s=i+this._holdOffset;return t>s+.5?{target:t,maxAtWrite:s}:null},this.getVirtualDistanceFromEnd=()=>Math.max(this._getLayoutTotalSize()+this.options.scrollMargin-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,i,s=0)=>{if(!this.scrollElement)return 0;const h=this.getSize(),e=this.getScrollOffset();"auto"===i&&(i=t>=e+h?"end":"start"),"center"===i?t+=(s-h)/2:"end"===i&&(t-=h);const n=this.getMaxScrollOffset();return Math.max(Math.min(n,t),0)},this.getOffsetForIndex=(t,i="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const s=this.getSize(),h=this.getScrollOffset(),e=this.measurementsCache[t];if(e){if("auto"===i)if(e.end>=h+s-this.options.scrollPaddingEnd)i="end";else{if(!(e.start<=h+this.options.scrollPaddingStart))return[h,i];i="start"}if("end"===i&&t===this.options.count-1){const t=this.getMaxScrollOffset();return[Math.max(Math.min(t-this.options.paddingEnd+this.options.scrollPaddingEnd,t),0),i]}return[this.getOffsetForAlignment("end"===i?e.end+this.options.scrollPaddingEnd:e.start-this.options.scrollPaddingStart,i,e.size),i]}},this.scrollToOffset=(t,{align:i="start",behavior:s="auto"}={})=>{this._startScroll({index:null,align:i},this.getOffsetForAlignment(t,i),s,"absolute")},this.scrollToIndex=(t,{align:i="auto",behavior:s="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const h=this.getOffsetForIndex(t,i);if(!h)return;const[e,n]=h;this._startScroll({index:t,align:n},e,s,"absolute")},this.scrollBy=(t,{behavior:i="auto"}={})=>{const s=this.getOffsetForAlignment((this.getCommandWrittenOffset()??this.getScrollOffset())+t,"start");this._startScroll({index:null,align:"start"},s,i,"relative")},this.scrollToEnd=({behavior:t="auto"}={})=>{this.options.count>0?this._startScroll({index:this.options.count-1,align:"end",toEnd:!0},Math.max(this.getMaxScrollOffset(),0),t,"absolute"):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.cancelScroll=()=>{null!=this.rafId&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null},this.getTotalSize=()=>Math.max(this._getLayoutTotalSize()-this._holdOffset,0),this._getLayoutTotalSize=()=>{var t,i;const s=this.getMeasurements();let h;if(0===s.length)h=this.options.paddingStart;else if(1===this.options.lanes){const e=s.length-1,n=null==(t=this._singleLaneMeasurements)?void 0:t.flat;h=null!=n?n[2*e]+n[2*e+1]:(null==(i=s[e])?void 0:i.end)??0}else{const t=Array(this.options.lanes).fill(null);let i=s.length-1;for(;i>=0&&t.some((t=>null===t));){const h=s[i];null===t[h.lane]&&(t[h.lane]=h.end),i--}h=Math.max(...t.filter((t=>null!==t)))}return Math.max(h-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(0===this.itemSizeCache.size)return t;const i=this.getMeasurements();for(const s of i)s&&this.itemSizeCache.has(s.key)&&t.push({index:s.index,key:s.key,start:s.start,size:s.size,end:s.end,lane:s.lane});return t},this._scrollToOffset=(t,{adjustments:i,behavior:s}={})=>{const h={target:t+(i??0),smooth:"smooth"===s};return this.pendingWrite=h,this.options.scrollToFn(t-this._holdOffset,{behavior:s,adjustments:i},this),h},this.getCommandWrittenOffset=()=>null===this.scrollState||null===this.pendingWrite||this.pendingWrite.smooth?null:this.pendingWrite.target,this._awaitingCommandReadBack=()=>{const t=this.getCommandWrittenOffset();return!(y()&&this._iosGesture.dragging()||null===t||p(t,this.getScrollOffset()))},this._followOffsetTarget=t=>{null!==this.scrollState&&null==this.scrollState.index&&(this.scrollState.lastTargetOffset+=t)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}get scrollAdjustments(){return 0}applyScrollAdjustment(t,i){if(0===t)return!1;if(this._followOffsetTarget(t),this._canWriteScroll()){const s=this.getScrollOffset();this._clampedAdjustment=this._clampedBy(s+t);const h=this._scrollToOffset(s,{adjustments:t,behavior:i});return null!==this.scrollOffset&&(this.pendingWrite===h&&(this.scrollOffset+=t),this.scrollOffset<0&&(this.scrollOffset=0)),!0}return this._holdOffset+=t,null!==this.scrollOffset&&(this.scrollOffset+=t),!0}scheduleScrollReconcile(){this.targetWindow?null==this.rafId&&(this.rafId=this.targetWindow.requestAnimationFrame((()=>{this.rafId=null,this.reconcileScroll()}))):this.scrollState=null}getScrollStateTarget(t){const i=t.toEnd?[Math.max(this.getMaxScrollOffset(),0)]:null!=t.index?this.getOffsetForIndex(t.index,t.align):void 0;return i?i[0]:t.lastTargetOffset}reconcileScroll(){if(!this.scrollState)return;if(!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3)return void(this.scrollState=null);if("queued"===this.scrollState.phase)return void this.scheduleScrollReconcile();this.getMeasurements();const t=this.getScrollStateTarget(this.scrollState),i=null==this.scrollState.index?1:this.options.useAnimationFrameWithResizeObserver?3:2,s=t!==this.scrollState.lastTargetOffset;if(!s&&p(t,this.getScrollOffset())){if("smooth"===this.scrollState.phase?this.scrollState.phase="smoothLanded":"smoothFinishing"===this.scrollState.phase&&(this.scrollState.phase="instant"),this.scrollState.stableFrames++,this.scrollState.stableFrames>=i)return this.getScrollOffset()!==t&&this._scrollToOffset(t,{behavior:"auto"}),void(this.scrollState=null)}else if(this.scrollState.stableFrames=0,s){const i=this.getSize()||600,s=Math.abs(t-this.getScrollOffset()),h=j(this.scrollState)&&s>i;this.scrollState.lastTargetOffset=t,h?this.scrollState.phase="smooth":"smooth"===this.scrollState.phase?this.scrollState.phase="smoothFinishing":"smoothLanded"===this.scrollState.phase&&(this.scrollState.phase="instant"),this._scrollToOffset(t,{behavior:h?"smooth":"auto"})}this.scheduleScrollReconcile()}_startScroll(t,i,s,h){this.pendingScrollAnchor=null,this._clampedAdjustment=null;const e=this._iosGesture.tail();if("absolute"===h&&null!==e){if("fling"===e&&(!y()||(void 0!==x?x:x=y()&&"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("overflow-anchor: auto"))))return this._stopMomentum((()=>{const t=this.scrollState;"queued"!==(null==t?void 0:t.phase)||"fling"!==this._iosGesture.tail()||this._reportedOverscroll||(this._iosGesture.end(),this._flushHoldIfReady(!0),this._writeAwaitingCommand())})),this.scrollState={...t,startedAt:this.now(),lastTargetOffset:i,stableFrames:0,phase:"queued",behavior:s,samples:[]},void this.scheduleScrollReconcile();this._iosGesture.end()}this.scrollState={...t,startedAt:this.now(),lastTargetOffset:i,stableFrames:0,behavior:s,phase:L(s,null!=t.index&&p(i,this.getScrollOffset()))},this._scrollToOffset(i,{behavior:s}),this.scheduleScrollReconcile()}}const V=(t,i,s,h)=>{for(;t<=i;){const e=(t+i)/2|0,n=s(e);if(n<h)t=e+1;else{if(!(n>h))return e;i=e-1}}return t>0?t-1:0};class K{constructor(t,i,s,h){this.bodyEl=t,this.scrollElement=i,this.config=s,this.onIndexesChange=h,this.measuredIndexes=new WeakMap,this.observedRows=new Set,this.resizeObserver=new ResizeObserver((t=>this.resizeRows(t.map((({borderBoxSize:t,target:i})=>({row:i,height:t[0].blockSize})))))),this.indexes=[],this.isResizingRows=!1,this.hasChangeWhileResizing=!1,this.bodyEl.style.overflowAnchor="none",this.scrollMargin=this.measureScrollMargin(),this.virtualizer=new P(this.options()),this.unmount=this.virtualizer._didMount(),this.virtualizer._willUpdate(),this.update()}setConfig(t){this.config=t,this.applyOptions()}sync(){this.updateScrollMargin(),this.observedRows.forEach((t=>{t.isConnected||(this.resizeObserver.unobserve(t),this.observedRows.delete(t))}));const t=this.getRenderedRows();t.forEach((t=>{this.observedRows.has(t)||(this.observedRows.add(t),this.resizeObserver.observe(t))})),this.resizeRows(t.filter((t=>this.measuredIndexes.get(t)!==N(t))).map((t=>({row:t,height:t.getBoundingClientRect().height})))),this.layout()}destroy(){this.unmount(),this.resizeObserver.disconnect(),this.observedRows.clear(),this.bodyEl.style.overflowAnchor="",this.bodyEl.style.paddingTop="",this.bodyEl.style.paddingBottom="",this.getRenderedRows().forEach((t=>t.style.marginTop=""))}applyOptions(){this.virtualizer.setOptions(this.options()),this.virtualizer._willUpdate(),this.update()}update(){if(this.updateScrollMargin())return;const t=this.virtualizer.getVirtualItems().map((({index:t})=>t));var i,s;(i=t).length===(s=this.indexes).length&&i.every(((t,i)=>t===s[i]))||(this.indexes=t,this.onIndexesChange(t)),this.layout()}updateScrollMargin(){const t=this.measureScrollMargin();return!(Math.abs(t-this.scrollMargin)<1||(this.scrollMargin=t,this.applyOptions(),0))}resizeRows(t){this.isResizingRows=!0;try{t.forEach((({row:t,height:i})=>{const s=N(t);t.isConnected&&!Number.isNaN(s)&&0!==i&&(this.measuredIndexes.set(t,s),this.virtualizer.resizeItem(s,i))}))}finally{this.isResizingRows=!1}this.hasChangeWhileResizing&&(this.hasChangeWhileResizing=!1,this.update())}handleChange(){this.isResizingRows?this.hasChangeWhileResizing=!0:this.update()}layout(){const t=new Map(this.virtualizer.getVirtualItems().map((t=>[t.index,t])));let i;this.getRenderedRows().forEach((s=>{const h=N(s),e=t.get(h);if(!e)return;s.index!==h+2&&(s.index=h+2);const n=e.start-this.scrollMargin;void 0===i?($(this.bodyEl,"paddingTop",n),$(s,"marginTop",0)):$(s,"marginTop",n-i),i=e.end-this.scrollMargin})),void 0===i&&$(this.bodyEl,"paddingTop",0),$(this.bodyEl,"paddingBottom",this.virtualizer.getTotalSize()-(i??0))}getRenderedRows(){return Array.from(this.bodyEl.querySelectorAll("swirl-table-row[data-index]"))}options(){const{estimatedRowHeight:t,keptIndexes:i,overscan:s,rowCount:h}=this.config,e=this.scrollElement instanceof Window;return{count:h,estimateSize:()=>t,getScrollElement:()=>this.scrollElement,initialOffset:()=>this.scrollElement instanceof Window?this.scrollElement.scrollY:this.scrollElement.scrollTop,overscan:s,scrollMargin:this.scrollMargin,rangeExtractor:t=>{return s=R(t),e=i.filter((t=>Number.isInteger(t)&&t>=0&&t<h)),[...new Set([...s,...e])].sort(((t,i)=>t-i));var s,e},observeElementRect:e?z:A,observeElementOffset:e?F:E,scrollToFn:e?W:q,onChange:()=>this.handleChange()}}measureScrollMargin(){const t=this.bodyEl.getBoundingClientRect().top;return this.scrollElement instanceof Window?t+this.scrollElement.scrollY:t-this.scrollElement.getBoundingClientRect().top+this.scrollElement.scrollTop}}function N(t){return Number(t.dataset.index)}function $(t,i,s){const h=s>0?`${s}px`:"";t.style[i]!==h&&(t.style[i]=h)}const H={end:"Dropped. Final position in table: {position} of {rowCount}.",initial:"Press space to move the row.",moved:"Current position in table: {position} of {rowCount}.",start:"Row grabbed. Current position in table: {position} of {rowCount}. Press up and down arrow keys to change position, Space to drop."},U=class{constructor(s){t(this,s),this.dropRow=i(this,"dropRow",7),this.virtualizationRowsChange=i(this,"virtualizationRowsChange",7),this.dragDropInstructions=H,this.emptyStateLabel="No results found.",this.virtualizationEstimatedRowHeight=56,this.virtualizationOverscan=10,this.virtualizationKeepRowsRendered=[],this.liveRegionText="",this.triggerRerender=r((async()=>{await this.updateLayout(),this.updateEmptyState()}),0,!0),this.updateLayout=b((async()=>{this.resetCellStyles(),this.resetColumnStyles(),this.resetEmptyRowStyles(),this.resetRowGroupStyles(),this.layoutEmptyRow(),this.layoutRowGroups(),this.layOutCellsAndColumns(),this.updateScrolledState()}),16,{leading:!0}),this.onScroll=()=>{this.updateScrolledState()},this.onFocus=t=>{if(this.trackFocusedRow(t.target),this.movingViaKeyboard){const t=this.el.querySelector(".table-row--moving");t&&this.focusDragHandleOfRow(t)}const i=!!t.target?.closest(this.dragDropHandle);""===this.liveRegionText&&i&&this.updateLiveRegionText("initial")},this.onBlur=t=>{const i=t.relatedTarget;this.el.contains(i)||this.trackFocusedRow(null);const s=!!i?.closest(this.dragDropHandle);this.el.contains(i)&&s||""!==this.liveRegionText&&this.updateLiveRegionText()},this.onKeyDown=t=>{if(!this.enableDragDrop)return;const i=t.target?.closest("swirl-table-row");t.target?.closest(this.dragDropHandle)&&("Space"===t.code?(t.preventDefault(),t.stopPropagation(),this.toggleKeyboardMove(i)):"ArrowUp"===t.code?(t.preventDefault(),t.stopPropagation(),this.moveRow(i,"up")):"ArrowDown"===t.code?(t.preventDefault(),t.stopPropagation(),this.moveRow(i,"down")):"Escape"===t.code&&(t.preventDefault(),t.stopPropagation(),this.cancelKeyboardMove()))}}async componentDidLoad(){this.setupIntersectionObserver(),this.setupMutationObservers(),this.updateVirtualizer(),queueMicrotask((()=>{this.setupDragDrop()}))}disconnectedCallback(){this.intersectionObserver?.disconnect(),this.columnMutationObserver?.disconnect(),this.rowMutationObserver?.disconnect(),this.sortable?.destroy(),this.destroyVirtualizer()}handleVirtualizationChange(){this.updateVirtualizer()}get virtualizerConfig(){if(this.enableVirtualization&&this.virtualizationRowCount)return{estimatedRowHeight:this.virtualizationEstimatedRowHeight,keptIndexes:void 0===this.focusedRowIndex?this.virtualizationKeepRowsRendered??[]:[...this.virtualizationKeepRowsRendered??[],this.focusedRowIndex],overscan:this.virtualizationOverscan,rowCount:this.virtualizationRowCount}}updateVirtualizer(){if(!this.bodyEl)return;const t=this.virtualizerConfig;if(!t){const t=Boolean(this.virtualizer);return this.destroyVirtualizer(),void(this.enableVirtualization&&t&&queueMicrotask((()=>this.virtualizationRowsChange.emit({indexes:[]}))))}if(this.virtualizer)return this.virtualizer.setConfig(t),void(this.virtualizer.scrollElement===window&&this.updateScrollParent());this.bodyEl.style.paddingBottom=t.rowCount*t.estimatedRowHeight+"px",this.virtualizer=new K(this.bodyEl,a(this.el),t,(t=>queueMicrotask((()=>this.virtualizationRowsChange.emit({indexes:t})))))}destroyVirtualizer(){this.virtualizer?.destroy(),this.virtualizer=void 0}handleEnableDragDropChange(){queueMicrotask((()=>{this.setupDragDrop()}))}setupIntersectionObserver(){this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange.bind(this),{threshold:0}),this.intersectionObserver.observe(this.container)}setupMutationObservers(){this.columnMutationObserver=new MutationObserver((t=>{t.some((t=>t.addedNodes.length||t.removedNodes.length))&&this.updateLayout()})),this.columnMutationObserver.observe(this.headerEl,{childList:!0,subtree:!0}),this.rowMutationObserver=new MutationObserver((t=>{const i=t.some((t=>t.addedNodes.length||t.removedNodes.length)),s=t.some((t=>"attributes"===t.type));i&&(this.updateEmptyState(),this.setupDragDrop()),(i||s)&&this.syncVirtualizedRows()})),this.startRowMutationObserver()}startRowMutationObserver(){this.rowMutationObserver?.observe(this.bodyEl,{attributeFilter:["data-index"],childList:!0,subtree:!0})}stopRowMutationObserver(){this.rowMutationObserver?.disconnect()}setupDragDrop(){if(this.sortable&&(this.sortable.destroy(),this.sortable=void 0),this.enableDragDrop){if(this.el.querySelector("swirl-table-row-group"))return void console.warn('[Swirl] Drag & drop is not yet supported for swirl-tables using the "swirl-table-row-group" component.');if(!this.dragDropHandle)return void console.warn('[Swirl] swirl-table required the "dragDropHandle" prop to be set when drag & drop is enabled.');const t=this.el.querySelector('[slot="rows"]');this.dragDropContainer="SWIRL-TABLE-ROW"!==t?.tagName?t??this.bodyEl:this.bodyEl,this.sortable=new o(this.dragDropContainer,{animation:100,direction:"vertical",handle:this.dragDropHandle,fallbackOnBody:!0,group:`swirl-table-${Math.random().toString().substring(2)}`,onStart:()=>{this.stopRowMutationObserver()},onEnd:t=>{t.stopPropagation();const{to:i,newIndex:s,oldIndex:h,item:e}=t;this.dropRow.emit({newIndex:s,oldIndex:h,item:e,itemId:e.id??e.querySelector(":scope > swirl-table-row").id,newNextSiblingItemId:s<i.children.length-1?i.children[s+1].id:void 0,newPrevSiblingItemId:s>0?i.children[s-1].id:void 0}),this.startRowMutationObserver()}})}}async onVisibilityChange(t){t.some((t=>t.isIntersecting))&&setTimeout((async()=>{this.updateScrollParent(),await this.updateLayout()}),100)}updateScrollParent(){this.virtualizer&&a(this.el)!==this.virtualizer.scrollElement&&(this.destroyVirtualizer(),this.updateVirtualizer())}async componentDidRender(){await this.updateLayout(),this.updateEmptyState()}async onWindowResize(){await this.updateLayout()}async rerender(){this.triggerRerender()}resetEmptyRowStyles(){const t=this.el.querySelector(".table__empty-row");Boolean(t)&&(t.style.width="")}resetRowGroupStyles(){Array.from(this.el.querySelectorAll("swirl-table-row-group")).forEach((t=>{const i=t.shadowRoot.querySelector(".table-row-group__header-row");Boolean(i)&&(t.shadowRoot.querySelector(".table-row-group__header-row").style.width="")}))}resetColumnStyles(){this.getColumns().forEach((t=>{t.classList.remove("table-column--has-shadow","table-column--is-sticky","table-column--is-sticky-right"),t.style.right="",t.style.left="",t.style.position="",t.style.zIndex=""}))}resetCellStyles(){this.getCells().forEach((t=>{t.classList.remove("table-cell--has-shadow","table-cell--is-sticky","table-cell--is-sticky-right"),t.style.flex="",t.style.left="",t.style.right="",t.style.position="",t.style.zIndex=""}))}updateScrolledState(){const t=u();if(void 0===this.container)return;const i=this.container.scrollWidth>this.container.clientWidth,s=this.container.scrollLeft>0,h=Math.ceil(this.container.clientWidth+this.container.scrollLeft)>=Math.floor(this.container.scrollWidth);i!==this.scrollable&&(i&&!t?this.container.classList.add("table__container--scrollable"):this.container.classList.remove("table__container--scrollable")),s!==this.scrolled&&(s&&!t?this.container.classList.add("table__container--scrolled"):this.container.classList.remove("table__container--scrolled")),h!==this.scrolledToEnd&&(h&&!t?this.container.classList.add("table__container--scrolled-to-end"):this.container.classList.remove("table__container--scrolled-to-end"))}getColumns(){return Array.from(this.el.querySelectorAll("swirl-table-column"))}getCells(){return Array.from(this.el.querySelectorAll("swirl-table-cell"))}layoutEmptyRow(){const t=this.el.querySelector(".table__empty-row");if(!Boolean(t))return;const i=`${this.el.querySelector(".table__container").scrollWidth}px`;t.style.width=i}layoutRowGroups(){const t=Array.from(this.el.querySelectorAll("swirl-table-row-group")),i=`${this.el.querySelector(".table__container")?.scrollWidth}px`;t.forEach((t=>{const s=t.shadowRoot.querySelector(".table-row-group__header-row");Boolean(s)&&(t.shadowRoot.querySelector(".table-row-group__header-row").style.width=i)}))}layOutCellsAndColumns(){const t=this.getColumns(),i=this.getCells();t.forEach(((s,h)=>{const e=this.getCellsForColumn(i,t,h),n=this.calculateColumnProperties(s,t,h);e.forEach((t=>this.applyCellStyles(t,s,n))),this.applyColumnStyles(s,n)}))}getCellsForColumn(t,i,s){return t.filter(((t,h)=>(s-h)%i.length==0))}calculateColumnProperties(t,i,s){return{leftOffsetForStickyColumn:t.sticky?this.getLeftOffsetForStickyColumn(i,s):0,columnWidth:`${t.getBoundingClientRect().width}px`,isLastColumnSticky:t.sticky&&i.length===s+1,hasShadowRight:t.sticky&&!this.hasStickyColumnsToRight(i,s)}}applyCellStyles(t,i,s){const{leftOffsetForStickyColumn:h,columnWidth:e,isLastColumnSticky:n,hasShadowRight:l}=s;t.style.flex=Boolean(e)?`0 0 ${e}`:"",u()||(i.sticky&&!n&&(t.classList.add("table-cell--is-sticky"),t.style.left=h+"px",l&&t.classList.add("table-cell--has-shadow-right")),n&&t.classList.add("table-cell--is-sticky-right","table-cell--has-shadow-left"))}applyColumnStyles(t,i){if(u())return;const{leftOffsetForStickyColumn:s,isLastColumnSticky:h,hasShadowRight:e}=i;t.sticky&&!h&&(t.classList.add("table-column--is-sticky"),t.style.left=s+"px",e&&t.classList.add("table-column--has-shadow-right")),h&&t.classList.add("table-column--is-sticky-right","table-column--has-shadow-left")}getLeftOffsetForStickyColumn(t,i){return t.slice(0,i).reduce(((t,i)=>{if(i.sticky)return t+i.getBoundingClientRect().width}),0)}hasStickyColumnsToRight(t,i){return t.slice(i+1,t.length-1).some((t=>t.sticky))}updateEmptyState(){if(this.enableVirtualization&&this.virtualizationRowCount)return void(this.empty=!1);const t=this.el.querySelector('[slot="rows"]');this.empty=!Boolean(t)||0===t.children.length}updateLiveRegionText(t,i={}){let s=t?this.dragDropInstructions[t]:"";for(const[t,h]of Object.entries(i??{}))s=s.replaceAll(`{${t}}`,String(h));s!==this.liveRegionText&&(this.liveRegionText=s)}toggleKeyboardMove(t){this.movingViaKeyboard?this.endKeyboardMove(t):this.startKeyboardMove(t)}startKeyboardMove(t){this.movingViaKeyboard=!0,this.positionBeforeKeyboardMove=Array.from(this.dragDropContainer.children).indexOf(t),t.classList.add("table-row--moving"),this.updateLiveRegionText("start",{position:Array.from(this.dragDropContainer.children).indexOf(t)+1,rowCount:this.dragDropContainer.children.length})}endKeyboardMove(t){this.movingViaKeyboard=!1,t.classList.remove("table-row--moving"),this.updateLiveRegionText("end",{position:Array.from(this.dragDropContainer.children).indexOf(t)+1,rowCount:this.dragDropContainer.children.length}),this.dropRow.emit({item:t,newIndex:Array.from(this.dragDropContainer.children).indexOf(t),oldIndex:this.positionBeforeKeyboardMove,itemId:t.id,newNextSiblingItemId:Array.from(this.dragDropContainer.children).indexOf(t)<this.dragDropContainer.children.length-1?this.dragDropContainer.children[Array.from(this.dragDropContainer.children).indexOf(t)+1].id:void 0,newPrevSiblingItemId:Array.from(this.dragDropContainer.children).indexOf(t)>0?this.dragDropContainer.children[Array.from(this.dragDropContainer.children).indexOf(t)-1].id:void 0}),this.positionBeforeKeyboardMove=void 0}cancelKeyboardMove(){if(!this.movingViaKeyboard)return;const t=this.el.querySelector(".table-row--moving");t&&(t.classList.remove("table-row--moving"),this.movingViaKeyboard=!1,void 0!==this.positionBeforeKeyboardMove&&this.dragDropContainer.insertBefore(t,this.dragDropContainer.children[this.positionBeforeKeyboardMove]))}moveRow(t,i){if(!this.movingViaKeyboard)return;let s;if("up"===i){const i=Array.from(this.dragDropContainer.children).indexOf(t);s=Math.max(0,i-1),this.dragDropContainer.insertBefore(t,this.dragDropContainer.children[s])}else{const i=Array.from(this.dragDropContainer.children).indexOf(t);s=Math.min(this.dragDropContainer.children.length-1,i+1),this.dragDropContainer.insertBefore(t,this.dragDropContainer.children[s+1])}this.updateLiveRegionText("moved",{position:s+1,rowCount:this.dragDropContainer.children.length}),this.focusDragHandleOfRow(t)}focusDragHandleOfRow(t){const i=c(t,this.dragDropHandle)?.[0];"BUTTON"===i.tagName?i.focus():i.querySelector("button")?.focus()}syncVirtualizedRows(){this.virtualizer&&(this.trackFocusedRow(this.el.querySelector("swirl-table-row[data-index]:focus-within")),this.virtualizer.sync())}trackFocusedRow(t){if(!this.enableVirtualization)return;const i=t?.closest("swirl-table-row[data-index]")?.dataset.index,s=void 0===i?void 0:Number(i);s!==this.focusedRowIndex&&(this.focusedRowIndex=s,this.updateVirtualizer())}render(){const t=Boolean(this.el.querySelector('[slot="empty"]')),i=l("table",{"table--show-empty-state":this.empty&&!this.loading,"table--keyboard-move":this.movingViaKeyboard});return s(h,{key:"5fd51d538c87dce53702fa483657035e251d3507"},s("div",{key:"7ec3b5830bcc7b0dfc5324f554b80b442b7bc290",class:i},this.enableDragDrop&&s("swirl-visually-hidden",{key:"2928eb420bb8cad6477917a1883aeeffda3260eb"},s("span",{key:"fc615afed57d8dbfbf636f9e8feb9c6ef76ae72b","aria-live":"assertive"},this.liveRegionText)),s("div",{key:"4b7d5b9c4691d1828d0c24fc635d8e7c5dc48cf4",class:"table__container",onFocusin:this.onFocus,onFocusout:this.onBlur,onKeyDown:this.onKeyDown,onScroll:this.onScroll,ref:t=>this.container=t,tabIndex:-1},s("div",{key:"9669435927eb4944290b4fdcb4083ef1473c000e","aria-describedby":Boolean(this.caption)?"caption":void 0,"aria-label":this.label,"aria-rowcount":this.enableVirtualization&&this.virtualizationRowCount?this.virtualizationRowCount+1:void 0,role:"table",class:"table__table"},this.caption&&s("swirl-visually-hidden",{key:"6806eedf8d1aa22b3ee8f51736032ead77a502cc"},s("div",{key:"bea8e3d31ba2e81461ff8e4d056ee3ea718707ea",id:"caption"},this.caption)),s("div",{key:"386fa4a8c2d31471a43580b62ad1003cfbcf224d",role:"rowgroup"},s("div",{key:"aebae228fab2eb7d4a688bb50ee069e7138001c1",class:"table__header","aria-rowindex":this.enableVirtualization?1:void 0,ref:t=>this.headerEl=t,role:"row"},s("slot",{key:"111dd938896772934ba589167ee254936c8bbe9d",name:"columns"}))),s("div",{key:"7a6b87e277bd50dfc8c5ff3e680aabe95384bb7f",class:"table__body",ref:t=>this.bodyEl=t},s("slot",{key:"a766d1ff38bf321fac0b3c52a686d57d2b4551ea",name:"rows"}),s("div",{key:"a26bec40f580546c85e3dd1007c913d53da4c18a",class:"table__empty-row",role:"row"},s("div",{key:"cd9793a4e353a88bfb04658354f247ddfd621e20","aria-colspan":this.getColumns().length,class:"table__empty-row-cell",role:"cell"},s("slot",{key:"3c79cf8327876b4be8e237e6d43c918d6f6dbda0",name:"empty"}),!t&&s("swirl-text",{key:"6f2d3365cd41f0242f8dc6720aed3c5bc1edf4fb",align:"center",size:"sm"},this.emptyStateLabel))))))))}get el(){return e(this)}static get watchers(){return{enableVirtualization:[{handleVirtualizationChange:0}],virtualizationRowCount:[{handleVirtualizationChange:0}],virtualizationEstimatedRowHeight:[{handleVirtualizationChange:0}],virtualizationOverscan:[{handleVirtualizationChange:0}],virtualizationKeepRowsRendered:[{handleVirtualizationChange:0}],enableDragDrop:[{handleEnableDragDropChange:0}]}}};U.style=".sc-swirl-table-h{--swirl-table-shadow-rgba:rgba(23, 23, 23, 0.2);position:relative;display:block}.sc-swirl-table-h *.sc-swirl-table{box-sizing:border-box}html.theme-dark.sc-swirl-table-h,html.theme-dark .sc-swirl-table-h{--swirl-table-shadow-rgba:rgba(0, 0, 0, 0.2)}.table--keyboard-move.sc-swirl-table:focus-within{--swirl-table-moving-row-border:var(--s-border-width-default) solid var(--s-border-highlight)}.table--show-empty-state.sc-swirl-table .table__empty-row.sc-swirl-table{display:flex}.table__container.sc-swirl-table{position:relative;overflow:auto;width:100%}.table__container--scrolled.sc-swirl-table{--swirl-table-sticky-right-shadow:4px 0 16px -4px var(--swirl-table-shadow-rgba), 2px 0 4px -2px var(--swirl-table-shadow-rgba)}.table__container--scrollable.sc-swirl-table:not(.table__container--scrolled-to-end){--swirl-table-sticky-left-shadow:0px 4px 16px 0px var(--swirl-table-shadow-rgba), 0px 1px 4px 0px var(--swirl-table-shadow-rgba)}.table__table.sc-swirl-table{width:-moz-max-content;width:max-content;min-width:max(20rem, 100%)}.table__header.sc-swirl-table-s>*,.table__header .sc-swirl-table-s>*{display:flex}.table__empty-row.sc-swirl-table{display:none}.table__empty-row-cell.sc-swirl-table{display:flex;overflow:auto;padding-top:var(--s-space-8);padding-right:var(--s-space-16);padding-bottom:var(--s-space-8);padding-left:var(--s-space-16);flex-basis:0;flex-grow:1;flex-shrink:1;align-items:center;background-color:var(--s-surface-default)}.table__empty-row-cell.sc-swirl-table>*.sc-swirl-table{flex-grow:1}";export{U as swirl_table}