@object-ui/runner 3.1.5 → 3.3.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.
@@ -1,4 +1,4 @@
1
- import{Jr as e,Qr as t,Yr as n,qr as r}from"./Tooltip-vqI0Da0Z.js";import{a as i,c as a,d as o,f as s,i as c,l,n as u,o as d,p as f,r as p,s as m,u as h}from"./index-BfeSbj6K.js";import{a as g,d as _,f as v,i as y,l as b,n as x,o as S,r as C,s as w,t as T,u as E}from"./sortable.esm-C55isRg_.js";var D=t(e(),1),O=t(n(),1);function k(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
1
+ import{$r as e,Jr as t,Xr as n,Yr as r}from"./Tooltip-zjJ0WkPX.js";import{A as i,D as a,F as o,I as s,T as c,_ as l,b as u,g as d,i as f,v as p,x as m,y as h}from"./src-6Z82Iaov.js";import{a as g,d as _,f as v,i as y,l as b,n as x,o as S,r as C,s as w,t as T,u as E}from"./sortable.esm-CTSGpbbL.js";var D=e(n(),1),O=e(r(),1);function k(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
2
2
  font-size: .6rem;
3
3
  font-weight: bold;
4
- color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function A(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var j=(e,t)=>Math.abs(e-t)<1.01,M=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},N=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},ee=e=>e,P=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},F=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(N(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(N(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},I={passive:!0},L=typeof window>`u`?!0:`onscrollend`in window,R=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&L?()=>void 0:M(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,I);let l=e.options.useScrollendEvent&&L;return l&&n.addEventListener(`scrollend`,c,I),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},z=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},B=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},V=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:ee,rangeExtractor:P,onChange:()=>{},measureElement:z,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=k(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},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??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=k(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=k(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=k(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?U({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=k(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=k(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return A(t[H(0,t.length-1,e=>A(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&j(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},H=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function U({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=H(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var W=typeof document<`u`?O.useLayoutEffect:O.useEffect;function G({useFlushSync:e=!0,...t}){let n=O.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,D.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=O.useState(()=>new V(r));return i.setOptions(r),W(()=>i._didMount(),[]),W(()=>i._willUpdate()),i}function K(e){return G({observeElementRect:F,observeElementOffset:R,scrollToFn:B,...e})}var q=r(),J=(...e)=>e.filter(Boolean).join(` `);function Y(e,t){if(!t||t.length===0)return{};for(let n of t){let t=e[n.field];if(t==null)continue;let r=!1,i=String(t);switch(n.operator){case`equals`:r=i===String(n.value);break;case`not_equals`:r=i!==String(n.value);break;case`contains`:r=i.toLowerCase().includes(String(n.value).toLowerCase());break;case`in`:r=Array.isArray(n.value)&&n.value.includes(i);break}if(r)return{...n.backgroundColor?{backgroundColor:n.backgroundColor}:{},...n.borderColor?{borderColor:n.borderColor}:{}}}return{}}function X({card:e,conditionalFormatting:t}){let{attributes:n,listeners:r,setNodeRef:o,transform:s,transition:l,isDragging:u}=C({id:e.id}),f={transform:v.Transform.toString(s),transition:l,opacity:u?.5:void 0},h=Y(e,t);return(0,q.jsx)(`div`,{ref:o,style:f,...n,...r,children:(0,q.jsxs)(p,{className:`mb-2 cursor-grab active:cursor-grabbing border-border bg-card/60 hover:border-primary/40 hover:shadow-lg hover:shadow-primary/10 transition-all duration-300 group`,style:h,children:[e.coverImage&&(0,q.jsx)(`div`,{className:`w-full h-32 overflow-hidden rounded-t-lg`,children:(0,q.jsx)(`img`,{src:e.coverImage,alt:``,className:`w-full h-full object-cover`,loading:`lazy`})}),(0,q.jsxs)(d,{className:`p-4`,children:[(0,q.jsx)(m,{className:`text-sm font-medium font-mono tracking-tight text-foreground group-hover:text-primary transition-colors`,children:e.title}),e.description&&(0,q.jsx)(i,{className:`text-xs text-muted-foreground font-mono`,children:e.description})]}),e.badges&&e.badges.length>0&&(0,q.jsx)(c,{className:`p-4 pt-0`,children:(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.badges.map((e,t)=>(0,q.jsx)(a,{variant:e.variant||`default`,className:`text-xs`,children:e.label},t))})})]})})}function Z({cards:e,parentRef:t,conditionalFormatting:n}){let r=K({count:e.length,getScrollElement:()=>t.current,estimateSize:()=>120,overscan:5});return(0,q.jsx)(`div`,{style:{height:`${r.getTotalSize()}px`,width:`100%`,position:`relative`},children:r.getVirtualItems().map(t=>{let r=e[t.index];return(0,q.jsx)(`div`,{style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${t.start}px)`},children:(0,q.jsx)(X,{card:r,conditionalFormatting:n})},r.id)})})}function Q({columnId:e,onAdd:t}){let[n,r]=O.useState(!1),[i,a]=O.useState(``),s=O.useRef(null),c=()=>{let n=i.trim();n&&(t(e,n),a(``)),r(!1)};return n?(0,q.jsx)(`div`,{className:`mt-2 space-y-2`,children:(0,q.jsx)(u,{ref:s,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),c()):e.key===`Escape`&&(a(``),r(!1))},onBlur:c,placeholder:`Enter card title...`,className:`text-sm`,autoFocus:!0})}):(0,q.jsxs)(l,{variant:`ghost`,size:`sm`,className:`w-full mt-2 text-muted-foreground hover:text-foreground`,onClick:()=>{r(!0),setTimeout(()=>s.current?.focus(),0)},children:[(0,q.jsx)(o,{className:`h-4 w-4 mr-1`}),`Add Card`]})}function te({column:e,cards:t,onToggle:n,enableVirtual:r,quickAdd:i,onQuickAdd:o,conditionalFormatting:c}){let u=t||[],d=O.useRef(null),{setNodeRef:p}=C({id:e.id,data:{type:`column`}}),m=e.limit&&u.length>=e.limit,g=e.limit&&u.length>=e.limit*.8;return(0,q.jsxs)(`div`,{ref:p,className:J(`flex flex-col flex-shrink-0 rounded-lg border border-border bg-card/20 backdrop-blur-sm shadow-xl transition-all`,e.collapsed?`w-16`:`w-80`,e.className),children:[(0,q.jsxs)(`div`,{className:`p-4 border-b border-border/50 bg-muted/20 flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,q.jsx)(l,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:()=>n(!e.collapsed),children:e.collapsed?(0,q.jsx)(s,{className:`h-4 w-4`}):(0,q.jsx)(f,{className:`h-4 w-4`})}),!e.collapsed&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`h3`,{className:`font-mono text-sm font-semibold tracking-wider text-primary/90 uppercase truncate`,children:e.title}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:J(`font-mono text-xs`,m?`text-destructive`:g?`text-yellow-500`:`text-muted-foreground`),children:[u.length,e.limit&&` / ${e.limit}`]}),m&&(0,q.jsx)(a,{variant:`destructive`,className:`text-xs`,children:`Full`}),g&&!m&&(0,q.jsx)(h,{className:`h-3 w-3 text-yellow-500`})]})]})]}),e.collapsed&&(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,q.jsx)(`span`,{className:`font-mono text-xs font-bold text-primary/90 [writing-mode:vertical-rl] rotate-180`,children:e.title}),(0,q.jsx)(a,{variant:`secondary`,className:`text-xs`,children:u.length})]})]}),!e.collapsed&&(0,q.jsxs)(`div`,{ref:d,className:`flex-1 p-4 overflow-y-auto`,style:{maxHeight:`600px`},children:[(0,q.jsx)(T,{items:u.map(e=>e.id),strategy:y,children:r?(0,q.jsx)(Z,{cards:u,parentRef:d,conditionalFormatting:c}):(0,q.jsx)(`div`,{className:`space-y-2`,children:u.map(e=>(0,q.jsx)(X,{card:e,conditionalFormatting:c},e.id))})}),i&&o&&(0,q.jsx)(Q,{columnId:e.id,onAdd:o})]})]})}function $({columns:e,onCardMove:t,onColumnToggle:n,enableVirtualScrolling:r=!1,virtualScrollThreshold:i=50,className:a,quickAdd:o,onQuickAdd:s,conditionalFormatting:c}){let[l,u]=O.useState(null),d=O.useMemo(()=>(e||[]).map(e=>({...e,cards:e.cards||[]})),[e]),[f,p]=O.useState(d);O.useEffect(()=>{p(d)},[d]);let m=_(E(w,{activationConstraint:{distance:8}})),h=e=>{let{active:t}=e;u(y(t.id))},v=e=>{let{active:n,over:r}=e;if(u(null),!r)return;let i=n.id,a=r.id;if(i===a)return;let o=C(i),s=C(a)||T(a);if(!(!o||!s))if(o.id===s.id){let e=[...o.cards],t=x(e,e.findIndex(e=>e.id===i),e.findIndex(e=>e.id===a));p(e=>e.map(e=>e.id===o.id?{...e,cards:t}:e))}else{let e=[...o.cards],n=[...s.cards],r=e.findIndex(e=>e.id===i),c=a===s.id?n.length:n.findIndex(e=>e.id===a),[l]=e.splice(r,1);n.splice(c,0,l),p(t=>t.map(t=>t.id===o.id?{...t,cards:e}:t.id===s.id?{...t,cards:n}:t)),t&&t(i,o.id,s.id,c)}},y=O.useCallback(e=>{for(let t of f){let n=t.cards.find(t=>t.id===e);if(n)return n}return null},[f]),C=O.useCallback(e=>f.find(t=>t.cards.some(t=>t.id===e))||null,[f]),T=O.useCallback(e=>f.find(t=>t.id===e)||null,[f]),D=O.useCallback((e,t)=>{p(n=>n.map(n=>n.id===e?{...n,collapsed:t}:n)),n?.(e,t)},[n]);return(0,q.jsxs)(g,{sensors:m,collisionDetection:b,onDragStart:h,onDragEnd:v,children:[(0,q.jsx)(`div`,{className:J(`flex gap-4 overflow-x-auto p-4`,a),children:f.map(e=>{let t=r&&e.cards.length>i;return(0,q.jsx)(te,{column:e,cards:e.cards,onToggle:t=>D(e.id,t),enableVirtual:t,quickAdd:o,onQuickAdd:s,conditionalFormatting:c},e.id)})}),(0,q.jsx)(S,{children:l?(0,q.jsx)(X,{card:l,conditionalFormatting:c}):null})]})}export{$ as KanbanEnhanced,$ as default};
4
+ color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function A(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var j=(e,t)=>Math.abs(e-t)<1.01,M=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},N=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},P=e=>e,ee=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},F=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(N(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(N(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},I={passive:!0},L=typeof window>`u`?!0:`onscrollend`in window,R=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&L?()=>void 0:M(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,I);let l=e.options.useScrollendEvent&&L;return l&&n.addEventListener(`scrollend`,c,I),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},z=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},B=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},V=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:P,rangeExtractor:ee,onChange:()=>{},measureElement:z,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=k(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},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??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=k(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=k(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=k(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?U({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=k(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=k(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return A(t[H(0,t.length-1,e=>A(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&j(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},H=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function U({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=H(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var W=typeof document<`u`?D.useLayoutEffect:D.useEffect;function G({useFlushSync:e=!0,...t}){let n=D.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,O.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=D.useState(()=>new V(r));return i.setOptions(r),W(()=>i._didMount(),[]),W(()=>i._willUpdate()),i}function K(e){return G({observeElementRect:F,observeElementOffset:R,scrollToFn:B,...e})}var q=t(),J=(...e)=>e.filter(Boolean).join(` `);function Y(e,t){if(!t||t.length===0)return{};for(let n of t){let t=e[n.field];if(t==null)continue;let r=!1,i=String(t);switch(n.operator){case`equals`:r=i===String(n.value);break;case`not_equals`:r=i!==String(n.value);break;case`contains`:r=i.toLowerCase().includes(String(n.value).toLowerCase());break;case`in`:r=Array.isArray(n.value)&&n.value.includes(i);break}if(r)return{...n.backgroundColor?{backgroundColor:n.backgroundColor}:{},...n.borderColor?{borderColor:n.borderColor}:{}}}return{}}function X({card:e,conditionalFormatting:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=C({id:e.id}),c={transform:v.Transform.toString(a),transition:o,opacity:s?.5:void 0},f=Y(e,t);return(0,q.jsx)(`div`,{ref:i,style:c,...n,...r,children:(0,q.jsxs)(d,{className:`mb-2 cursor-grab active:cursor-grabbing border-border bg-card/60 hover:border-primary/40 hover:shadow-lg hover:shadow-primary/10 transition-all duration-300 group`,style:f,children:[e.coverImage&&(0,q.jsx)(`div`,{className:`w-full h-32 overflow-hidden rounded-t-lg`,children:(0,q.jsx)(`img`,{src:e.coverImage,alt:``,className:`w-full h-full object-cover`,loading:`lazy`})}),(0,q.jsxs)(h,{className:`p-4`,children:[(0,q.jsx)(u,{className:`text-sm font-medium font-mono tracking-tight text-foreground group-hover:text-primary transition-colors`,children:e.title}),e.description&&(0,q.jsx)(p,{className:`text-xs text-muted-foreground font-mono`,children:e.description})]}),e.badges&&e.badges.length>0&&(0,q.jsx)(l,{className:`p-4 pt-0`,children:(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.badges.map((e,t)=>(0,q.jsx)(m,{variant:e.variant||`default`,className:`text-xs`,children:e.label},t))})})]})})}function Z({cards:e,parentRef:t,conditionalFormatting:n}){let r=K({count:e.length,getScrollElement:()=>t.current,estimateSize:()=>120,overscan:5});return(0,q.jsx)(`div`,{style:{height:`${r.getTotalSize()}px`,width:`100%`,position:`relative`},children:r.getVirtualItems().map(t=>{let r=e[t.index];return(0,q.jsx)(`div`,{style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${t.start}px)`},children:(0,q.jsx)(X,{card:r,conditionalFormatting:n})},r.id)})})}function Q({columnId:e,onAdd:t}){let[n,r]=D.useState(!1),[a,o]=D.useState(``),s=D.useRef(null),l=()=>{let n=a.trim();n&&(t(e,n),o(``)),r(!1)};return n?(0,q.jsx)(`div`,{className:`mt-2 space-y-2`,children:(0,q.jsx)(f,{ref:s,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),l()):e.key===`Escape`&&(o(``),r(!1))},onBlur:l,placeholder:`Enter card title...`,className:`text-sm`,autoFocus:!0})}):(0,q.jsxs)(c,{variant:`ghost`,size:`sm`,className:`w-full mt-2 text-muted-foreground hover:text-foreground`,onClick:()=>{r(!0),setTimeout(()=>s.current?.focus(),0)},children:[(0,q.jsx)(i,{className:`h-4 w-4 mr-1`}),`Add Card`]})}function te({column:e,cards:t,onToggle:n,enableVirtual:r,quickAdd:i,onQuickAdd:l,conditionalFormatting:u}){let d=t||[],f=D.useRef(null),{setNodeRef:p}=C({id:e.id,data:{type:`column`}}),h=e.limit&&d.length>=e.limit,g=e.limit&&d.length>=e.limit*.8;return(0,q.jsxs)(`div`,{ref:p,className:J(`flex flex-col flex-shrink-0 rounded-lg border border-border bg-card/20 backdrop-blur-sm shadow-xl transition-all`,e.collapsed?`w-16`:`w-80`,e.className),children:[(0,q.jsxs)(`div`,{className:`p-4 border-b border-border/50 bg-muted/20 flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,q.jsx)(c,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:()=>n(!e.collapsed),children:e.collapsed?(0,q.jsx)(o,{className:`h-4 w-4`}):(0,q.jsx)(s,{className:`h-4 w-4`})}),!e.collapsed&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`h3`,{className:`font-mono text-sm font-semibold tracking-wider text-primary/90 uppercase truncate`,children:e.title}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:J(`font-mono text-xs`,h?`text-destructive`:g?`text-yellow-500`:`text-muted-foreground`),children:[d.length,e.limit&&` / ${e.limit}`]}),h&&(0,q.jsx)(m,{variant:`destructive`,className:`text-xs`,children:`Full`}),g&&!h&&(0,q.jsx)(a,{className:`h-3 w-3 text-yellow-500`})]})]})]}),e.collapsed&&(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,q.jsx)(`span`,{className:`font-mono text-xs font-bold text-primary/90 [writing-mode:vertical-rl] rotate-180`,children:e.title}),(0,q.jsx)(m,{variant:`secondary`,className:`text-xs`,children:d.length})]})]}),!e.collapsed&&(0,q.jsxs)(`div`,{ref:f,className:`flex-1 p-4 overflow-y-auto`,style:{maxHeight:`600px`},children:[(0,q.jsx)(T,{items:d.map(e=>e.id),strategy:y,children:r?(0,q.jsx)(Z,{cards:d,parentRef:f,conditionalFormatting:u}):(0,q.jsx)(`div`,{className:`space-y-2`,children:d.map(e=>(0,q.jsx)(X,{card:e,conditionalFormatting:u},e.id))})}),i&&l&&(0,q.jsx)(Q,{columnId:e.id,onAdd:l})]})]})}function $({columns:e,onCardMove:t,onColumnToggle:n,enableVirtualScrolling:r=!1,virtualScrollThreshold:i=50,className:a,quickAdd:o,onQuickAdd:s,conditionalFormatting:c}){let[l,u]=D.useState(null),d=D.useMemo(()=>(e||[]).map(e=>({...e,cards:e.cards||[]})),[e]),[f,p]=D.useState(d);D.useEffect(()=>{p(d)},[d]);let m=_(E(w,{activationConstraint:{distance:8}})),h=e=>{let{active:t}=e;u(y(t.id))},v=e=>{let{active:n,over:r}=e;if(u(null),!r)return;let i=n.id,a=r.id;if(i===a)return;let o=C(i),s=C(a)||T(a);if(!(!o||!s))if(o.id===s.id){let e=[...o.cards],t=x(e,e.findIndex(e=>e.id===i),e.findIndex(e=>e.id===a));p(e=>e.map(e=>e.id===o.id?{...e,cards:t}:e))}else{let e=[...o.cards],n=[...s.cards],r=e.findIndex(e=>e.id===i),c=a===s.id?n.length:n.findIndex(e=>e.id===a),[l]=e.splice(r,1);n.splice(c,0,l),p(t=>t.map(t=>t.id===o.id?{...t,cards:e}:t.id===s.id?{...t,cards:n}:t)),t&&t(i,o.id,s.id,c)}},y=D.useCallback(e=>{for(let t of f){let n=t.cards.find(t=>t.id===e);if(n)return n}return null},[f]),C=D.useCallback(e=>f.find(t=>t.cards.some(t=>t.id===e))||null,[f]),T=D.useCallback(e=>f.find(t=>t.id===e)||null,[f]),O=D.useCallback((e,t)=>{p(n=>n.map(n=>n.id===e?{...n,collapsed:t}:n)),n?.(e,t)},[n]);return(0,q.jsxs)(g,{sensors:m,collisionDetection:b,onDragStart:h,onDragEnd:v,children:[(0,q.jsx)(`div`,{className:J(`flex gap-4 overflow-x-auto p-4`,a),children:f.map(e=>{let t=r&&e.cards.length>i;return(0,q.jsx)(te,{column:e,cards:e.cards,onToggle:t=>O(e.id,t),enableVirtual:t,quickAdd:o,onQuickAdd:s,conditionalFormatting:c},e.id)})}),(0,q.jsx)(S,{children:l?(0,q.jsx)(X,{card:l,conditionalFormatting:c}):null})]})}export{$ as KanbanEnhanced,$ as default};
@@ -0,0 +1 @@
1
+ import{$r as e,Jr as t,Xr as n}from"./Tooltip-zjJ0WkPX.js";import{A as r,B as i,T as a,_ as o,b as s,g as c,i as l,r as u,v as d,x as f,y as p,z as m}from"./src-6Z82Iaov.js";import{a as h,c as g,d as _,f as v,i as y,l as b,n as x,o as S,r as C,s as w,t as T,u as E}from"./sortable.esm-CTSGpbbL.js";var D=e(n(),1),O=t(),k=(...e)=>e.filter(Boolean).join(` `),A=`Uncategorized`;function j(e,t){if(!t||t.length===0)return{};for(let n of t){let t=e[n.field];if(t==null)continue;let r=!1,i=String(t);switch(n.operator){case`equals`:r=i===String(n.value);break;case`not_equals`:r=i!==String(n.value);break;case`contains`:r=i.toLowerCase().includes(String(n.value).toLowerCase());break;case`in`:r=Array.isArray(n.value)&&n.value.includes(i);break}if(r)return{...n.backgroundColor?{backgroundColor:n.backgroundColor}:{},...n.borderColor?{borderColor:n.borderColor}:{}}}return{}}function M({card:e,onCardClick:t,conditionalFormatting:n}){let{attributes:r,listeners:i,setNodeRef:a,transform:l,transition:u,isDragging:m}=C({id:e.id}),h={transform:v.Transform.toString(l),transition:u,opacity:m?.5:void 0},g=j(e,n);return(0,O.jsx)(`div`,{ref:a,style:h,...r,...i,role:`listitem`,"aria-label":e.title,onClick:()=>t?.(e),children:(0,O.jsxs)(c,{className:`mb-2 cursor-grab active:cursor-grabbing border-border border-l-4 border-l-primary/40 bg-card/60 hover:border-primary/40 hover:shadow-lg hover:shadow-primary/10 transition-all duration-300 group touch-manipulation`,style:g,children:[e.coverImage&&(0,O.jsx)(`div`,{className:`w-full h-32 overflow-hidden rounded-t-lg`,children:(0,O.jsx)(`img`,{src:e.coverImage,alt:``,className:`w-full h-full object-cover`,loading:`lazy`})}),(0,O.jsxs)(p,{className:`p-2 sm:p-4`,children:[(0,O.jsx)(s,{className:`text-xs sm:text-sm font-medium font-mono tracking-tight text-foreground group-hover:text-primary transition-colors`,children:e.title}),e.description&&(0,O.jsx)(d,{className:`text-xs text-muted-foreground font-mono line-clamp-2 sm:line-clamp-none`,children:e.description})]}),e.badges&&e.badges.length>0&&(0,O.jsx)(o,{className:`p-2 sm:p-4 pt-0`,children:(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.badges.map((e,t)=>(0,O.jsx)(f,{variant:e.variant||`default`,className:`text-xs`,children:e.label},t))})})]})})}function N({columnId:e,onAdd:t}){let[n,i]=D.useState(!1),[o,s]=D.useState(``),c=D.useRef(null),u=()=>{let n=o.trim();n&&(t(e,n),s(``)),i(!1)};return n?(0,O.jsx)(`div`,{className:`mt-2 space-y-2`,children:(0,O.jsx)(l,{ref:c,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),u()):e.key===`Escape`&&(s(``),i(!1))},onBlur:u,placeholder:`Enter card title...`,className:`text-sm`,autoFocus:!0})}):(0,O.jsxs)(a,{variant:`ghost`,size:`sm`,className:`w-full mt-2 text-muted-foreground hover:text-foreground`,onClick:()=>{i(!0),setTimeout(()=>c.current?.focus(),0)},children:[(0,O.jsx)(r,{className:`h-4 w-4 mr-1`}),`Add Card`]})}function P({column:e,cards:t,onCardClick:n,quickAdd:r,onQuickAdd:i,conditionalFormatting:a}){let o=t||[],{setNodeRef:s}=C({id:e.id,data:{type:`column`}}),c=e.limit&&o.length>=e.limit;return(0,O.jsxs)(`div`,{ref:s,role:`group`,"aria-label":e.title,className:k(`flex flex-col w-[85vw] sm:w-80 flex-shrink-0 rounded-lg border border-border bg-card/20 backdrop-blur-sm shadow-xl snap-start`,e.className),children:[(0,O.jsx)(`div`,{className:`p-3 sm:p-4 border-b border-border/50 bg-muted/30 rounded-t-lg`,children:(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(`h3`,{id:`kanban-col-${e.id}`,className:`font-mono text-xs sm:text-sm font-semibold tracking-wider text-primary/90 uppercase truncate`,children:e.title}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(f,{variant:`secondary`,className:`text-xs font-mono tabular-nums`,children:[o.length,e.limit&&` / ${e.limit}`]}),c&&(0,O.jsx)(f,{variant:`destructive`,className:`text-xs`,children:`Full`})]})]})}),(0,O.jsxs)(u,{className:`flex-1 p-4`,children:[(0,O.jsx)(T,{items:o.map(e=>e.id),strategy:y,children:(0,O.jsxs)(`div`,{className:`space-y-2`,role:`list`,"aria-label":`${e.title} cards`,children:[o.length===0&&(0,O.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground/50`,children:(0,O.jsx)(`span`,{className:`text-xs font-mono`,children:`No cards`})}),o.map(e=>(0,O.jsx)(M,{card:e,onCardClick:n,conditionalFormatting:a},e.id))]})}),r&&i&&(0,O.jsx)(N,{columnId:e.id,onAdd:i})]})]})}function F({children:e}){return(0,O.jsx)(O.Fragment,{children:e(m())})}function I({columns:e,onCardMove:t,onCardClick:n,className:r,quickAdd:a,onQuickAdd:o,coverImageField:s,conditionalFormatting:c,swimlaneField:l}){return i()?(0,O.jsx)(F,{children:i=>(0,O.jsx)(L,{columns:e,onCardMove:t,onCardClick:n,className:r,dnd:i,quickAdd:a,onQuickAdd:o,coverImageField:s,conditionalFormatting:c,swimlaneField:l})}):(0,O.jsx)(L,{columns:e,onCardMove:t,onCardClick:n,className:r,dnd:null,quickAdd:a,onQuickAdd:o,coverImageField:s,conditionalFormatting:c,swimlaneField:l})}function L({columns:e,onCardMove:t,onCardClick:n,className:r,dnd:i,quickAdd:a,onQuickAdd:o,coverImageField:s,conditionalFormatting:c,swimlaneField:l}){let[u,d]=D.useState(null),f=l?`objectui:kanban-collapsed:${l}`:null,[p,m]=D.useState(()=>{if(!f)return new Set;try{let e=localStorage.getItem(f);if(e){let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>typeof e==`string`))}}catch{}return new Set}),v=D.useMemo(()=>(e||[]).map(e=>({...e,cards:e.cards||[]})),[e]),[C,j]=D.useState(v);D.useEffect(()=>{j(v)},[v]);let N=D.useMemo(()=>{if(!l)return null;let e=C.flatMap(e=>e.cards),t=new Set;return e.forEach(e=>{let n=e[l];t.add(n==null?A:String(n))}),Array.from(t).sort()},[C,l]),F=D.useCallback(e=>{m(t=>{let n=new Set(t);if(n.has(e)?n.delete(e):n.add(e),f)try{localStorage.setItem(f,JSON.stringify([...n]))}catch{}return n})},[f]),I=_(E(w,{activationConstraint:{distance:5}}),E(g,{activationConstraint:{delay:200,tolerance:5}})),L=e=>{let{active:t}=e,n=z(t.id);if(d(n),i&&n){let e=B(n.id);e&&i.startDrag({id:n.id,type:`kanban-card`,data:n,sourceId:e.id})}},R=e=>{let{active:n,over:r}=e;if(d(null),!r){i&&i.endDrag();return}let a=n.id,o=r.id;if(a===o){i&&i.endDrag();return}let s=B(a),c=B(o)||V(o);if(!s||!c){i&&i.endDrag();return}if(s.id===c.id){let e=[...s.cards],t=x(e,e.findIndex(e=>e.id===a),e.findIndex(e=>e.id===o));j(e=>e.map(e=>e.id===s.id?{...e,cards:t}:e))}else{let e=[...s.cards],n=[...c.cards],r=e.findIndex(e=>e.id===a),i=o===c.id?n.length:n.findIndex(e=>e.id===o),[l]=e.splice(r,1);n.splice(i,0,l),j(t=>t.map(t=>t.id===s.id?{...t,cards:e}:t.id===c.id?{...t,cards:n}:t)),t&&t(a,s.id,c.id,i)}i&&i.endDrag(c.id)},z=D.useCallback(e=>{for(let t of C){let n=t.cards.find(t=>t.id===e);if(n)return n}return null},[C]),B=D.useCallback(e=>C.find(t=>t.cards.some(t=>t.id===e))||null,[C]),V=D.useCallback(e=>C.find(t=>t.id===e)||null,[C]);return(0,O.jsxs)(h,{sensors:I,collisionDetection:b,onDragStart:L,onDragEnd:R,children:[(0,O.jsxs)(`div`,{className:`flex sm:hidden items-center justify-between px-3 pb-2 text-xs text-muted-foreground`,children:[(0,O.jsxs)(`span`,{children:[C.length,` columns`]}),(0,O.jsx)(`span`,{children:`← Swipe to navigate →`})]}),N?(0,O.jsxs)(`div`,{className:k(`flex flex-col gap-1 p-2 sm:p-4 min-w-0 overflow-hidden`,r),role:`region`,"aria-label":`Kanban board with swimlanes`,children:[(0,O.jsx)(`div`,{className:`flex gap-3 sm:gap-4 pl-36 sm:pl-44 overflow-x-auto`,children:C.map(e=>(0,O.jsxs)(`div`,{className:`w-[85vw] sm:w-80 flex-shrink-0 text-center`,children:[(0,O.jsx)(`span`,{className:`font-mono text-xs sm:text-sm font-semibold tracking-wider text-primary/90 uppercase`,children:e.title}),(0,O.jsxs)(`span`,{className:`ml-2 font-mono text-xs text-muted-foreground`,children:[`(`,e.cards.length,`)`]})]},e.id))}),N.map(e=>{let t=p.has(e),r=C.reduce((t,n)=>t+n.cards.filter(t=>(t[l]==null?A:String(t[l]))===e).length,0);return(0,O.jsxs)(`div`,{className:`border rounded-lg bg-muted/10`,children:[(0,O.jsxs)(`button`,{className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-muted/30 transition-colors`,onClick:()=>F(e),"aria-expanded":!t,children:[(0,O.jsx)(`span`,{className:k(`transition-transform text-xs`,t?``:`rotate-90`),children:`▶`}),(0,O.jsx)(`span`,{className:`font-mono text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e}),(0,O.jsxs)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:[`(`,r,`)`]})]}),!t&&(0,O.jsx)(`div`,{className:`flex gap-3 sm:gap-4 overflow-x-auto px-2 pb-3 pl-36 sm:pl-44`,children:C.map(t=>{let r=t.cards.filter(t=>(t[l]==null?A:String(t[l]))===e);return(0,O.jsx)(`div`,{className:`w-[85vw] sm:w-80 flex-shrink-0 min-h-[60px] rounded-md bg-card/20 p-2`,children:(0,O.jsx)(T,{items:r.map(e=>e.id),strategy:y,children:(0,O.jsx)(`div`,{className:`space-y-2`,role:`list`,"aria-label":`${t.title} - ${e} cards`,children:r.map(e=>(0,O.jsx)(M,{card:e,onCardClick:n,conditionalFormatting:c},e.id))})})},t.id)})})]},e)})]}):(0,O.jsx)(`div`,{className:k(`flex gap-3 sm:gap-4 overflow-x-auto snap-x snap-mandatory p-2 sm:p-4 bg-muted/10 rounded-lg [-webkit-overflow-scrolling:touch] min-w-0`,r),role:`region`,"aria-label":`Kanban board`,children:C.map(e=>(0,O.jsx)(P,{column:e,cards:e.cards,onCardClick:n,quickAdd:a,onQuickAdd:o,conditionalFormatting:c},e.id))}),(0,O.jsx)(S,{children:(0,O.jsx)(`div`,{"aria-live":`assertive`,"aria-label":u?`Dragging ${u.title}`:void 0,children:u?(0,O.jsx)(M,{card:u,conditionalFormatting:c}):null})})]})}export{I as default};