react-resizable-panels 4.18.0 → 4.18.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,2 +1,2 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("react/jsx-runtime"),f=require("react"),$s=require("react-dom");function js(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Ns=js(f);function $t(e){return(typeof e=="number"||typeof e=="string")&&e!==""}function Je(e){const t=f.useId();return $t(e)?`${e}`:t}const ne=typeof window<"u"?f.useLayoutEffect:f.useEffect;function ze(e){const t=f.useRef(e);return ne(()=>{t.current=e},[e]),f.useCallback((...n)=>t.current?.(...n),[t])}function Ze(...e){return ze(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function at(e,t){const n=e?.["data-testid"];return $t(n)?`${n}`:$t(t)?`${t}`:void 0}function sn(e,t){return t?e*2+1:e+1}function Gs(e,t){return t?e*2-1:e}function Un(e,t,n){const o=sn(e,n);return t===void 0?`${o} / -1`:`${o} / span ${Gs(t,n)}`}function Fs(e){return`${e*2} / span 1`}function Ws({crossCount:e,crossSpan:t,crossStart:n,hasGutters:o}){const s=t===void 0?e:n+t;if(n===0&&s===e)return"1 / -1";let r=sn(n,o),i=sn(s-1,o)+1;return o&&(n>0&&r--,s<e&&i++),`${r} / ${i}`}function dn(e,t){return Number.isInteger(e)&&e>=1&&e<t}function te(e,t="Assertion error"){if(!e)throw Error(t)}const Eo=f.createContext(null);function Do(){const e=f.useContext(Eo);return te(e,"Grid Context not found; did you render a Cell or Gridline outside of a Grid?"),e}function Bs({children:e,className:t,column:n,columnSpan:o=1,elementRef:s,id:r,row:i,rowSpan:a=1,style:l,...c}){const u=Je(r),{gutters:d,registerCell:g}=Do(),h=f.useRef(null),m=Ze(h,s);return ne(()=>{const p=h.current;if(p!==null)return g({column:n,columnSpan:o,element:p,id:u,row:i,rowSpan:a})},[n,o,u,g,i,a]),A.jsx("div",{...c,className:t,"data-cell":!0,"data-testid":at(c,r),id:u,ref:m,style:{overflow:"auto",...l,minHeight:0,minWidth:0,gridColumn:Un(n,o,d.column),gridRow:Un(i,a,d.row)},children:e})}const Hs=Object.assign(Bs,{displayName:"Cell"});let Mt;function Oo(){return Mt===void 0&&(typeof matchMedia=="function"?Mt=!!matchMedia("(pointer:coarse)").matches:Mt=!1),Mt}function rn({expandHitTargets:e,axis:t,rect:n}){const o=e?Oo()?t.resizeTargetMinimumSize.coarse:t.resizeTargetMinimumSize.fine:0;if(n.width<o){const s=o-n.width;n=new DOMRect(n.x-s/2,n.y,n.width+s,n.height)}if(n.height<o){const s=o-n.height;n=new DOMRect(n.x,n.y-s/2,n.width,n.height+s)}return n}function Kn({axis:e,cells:t,index:n,rect:o}){let s=[o];for(const r of t){const i=e==="column"?r.column:r.row,a=e==="column"?r.columnSpan:r.rowSpan;if(i>=n||i+a<=n)continue;const l=r.element.getBoundingClientRect(),c=e==="column"?l.top:l.left,u=e==="column"?l.bottom:l.right;u<=c||(s=s.flatMap(d=>{const g=e==="column"?d.top:d.left,h=e==="column"?d.bottom:d.right;if(c>=h||u<=g)return[d];const m=[],p=(b,y)=>{m.push(e==="column"?new DOMRect(d.x,b,d.width,y-b):new DOMRect(b,d.y,y-b,d.height))};return g<c&&p(g,c),h>u&&p(u,h),m}))}return s}function Vs({axis:e,cells:t,crossTrackCount:n,expandHitTargets:o,resizeAxis:s,axisSize:r,includeDisabled:i,separatorPlacements:a}){const{items:l,separators:c}=s,u=l.length;let d=-1,g=-1,h=0;if(l.forEach((T,I)=>{T.constraintProps.disabled||(h++,d===-1&&(d=I),g=I)}),!i&&h<2)return[];const m=T=>i||T>d&&T<=g,p=[],b=(T,I,v)=>({axis:s,axisSize:r,items:[l[T-1],l[T]],rect:I,separator:v}),y=(T,I)=>{let v;for(const L of t){const E=e==="column"?L.row:L.column,B=e==="column"?L.rowSpan:L.columnSpan;if(I==="start"?E===T:E+B-1===T){const _=L.element.getBoundingClientRect();if(I==="start"){const D=e==="column"?_.top:_.left;v=v===void 0?D:Math.min(v,D)}else{const D=e==="column"?_.bottom:_.right;v=v===void 0?D:Math.max(v,D)}}}return v},S=new Set;for(const T of c){const I=a.get(T);if(!I||I.index<1||I.index>=u||(S.add(I.index),!i&&(T.disabled||T.element.hasAttribute("aria-disabled")))||!m(I.index))continue;let v=T.element.getBoundingClientRect();const{crossSpan:L,crossStart:E}=I,B=L===void 0?n:E+L;let _=e==="column"?v.top:v.left,D=e==="column"?v.bottom:v.right;if(E>0){const K=y(E-1,"end");K!==void 0&&K<_&&(_=K)}if(B<n){const K=y(B,"start");K!==void 0&&K>D&&(D=K)}v=e==="column"?new DOMRect(v.x,_,v.width,D-_):new DOMRect(_,v.y,D-_,v.height),v=rn({expandHitTargets:o,axis:s,rect:v}),i?p.push(b(I.index,v,T)):Kn({axis:e,cells:t,index:I.index,rect:v}).forEach(K=>{p.push(b(I.index,K,T))})}const x=(T,I)=>{Kn({axis:e,cells:t,index:T,rect:rn({expandHitTargets:o,axis:s,rect:I})}).forEach(v=>{p.push(b(T,v))})},C=Array.from({length:n},()=>new Array(u));for(const T of t){const[I,v,L,E]=e==="column"?[T.column,T.columnSpan,T.row,T.rowSpan]:[T.row,T.rowSpan,T.column,T.columnSpan];for(let B=Math.max(0,L);B<Math.min(n,L+E);B++)for(let _=Math.max(0,I);_<Math.min(u,I+v);_++)C[B][_]??=T}const O=new Map,$=T=>{let I=O.get(T);if(!I){const v=T.element.getBoundingClientRect();I=e==="column"?{crossEnd:v.bottom,crossStart:v.top,end:v.right,start:v.left}:{crossEnd:v.right,crossStart:v.left,end:v.bottom,start:v.top},O.set(T,I)}return I},M=({crossEnd:T,crossStart:I,end:v,start:L})=>e==="column"?new DOMRect(L,I,v-L,T-I):new DOMRect(I,L,T-I,v-L);for(let T=1;T<u;T++){if(S.has(T)||!m(T))continue;let I;for(let v=0;v<n;v++){const L=C[v][T-1],E=C[v][T];let B;if((L||E)&&L!==E){const _=L?$(L):void 0,D=E?$(E):void 0,K=_?.end??D.start,H=D?.start??_.end,W=Math.max(_?.crossStart??-1/0,D?.crossStart??-1/0),N=Math.min(_?.crossEnd??1/0,D?.crossEnd??1/0);B={crossEnd:Math.max(W,N),crossStart:W,end:Math.max(K,H),start:Math.min(K,H)}}B?I=I?{crossEnd:Math.max(I.crossEnd,B.crossEnd),crossStart:Math.min(I.crossStart,B.crossStart),end:Math.max(I.end,B.end),start:Math.min(I.start,B.start)}:B:I&&(x(T,M(I)),I=void 0)}I&&x(T,M(I))}return p}function Me(e){const t=parseFloat(e??"");return Number.isFinite(t)?t:0}function _s({axis:e,element:t,gutterSizes:n,hasGutters:o,layout:s,trackIds:r}){const i=r.length,a=o?i*2-1:i,l=t.ownerDocument.defaultView?.getComputedStyle(t),c=e==="column"?l?.gridTemplateColumns:l?.gridTemplateRows;if(c){const p=c.trim().split(/\s+/);if(p.length===a&&p.every(b=>/^-?[\d.]+px$/.test(b))){const b=r.map((y,S)=>Me(p[o?S*2:S]));return{availableSize:b.reduce((y,S)=>y+S,0),trackSizes:b}}}const u=e==="column"?t.offsetWidth:t.offsetHeight,d=e==="column"?Me(l?.paddingLeft)+Me(l?.paddingRight)+Me(l?.borderLeftWidth)+Me(l?.borderRightWidth):Me(l?.paddingTop)+Me(l?.paddingBottom)+Me(l?.borderTopWidth)+Me(l?.borderBottomWidth),g=Me(e==="column"?l?.columnGap:l?.rowGap),h=n.reduce((p,b)=>p+b,0),m=Math.max(0,u-d-g*Math.max(0,a-1)-h);return{availableSize:m,trackSizes:r.map(p=>s&&s[p]!==void 0?s[p]/100*m:m/i)}}class fn{#e={};addListener(t,n){const o=this.#e[t];return o===void 0?this.#e[t]=[n]:o.includes(n)||o.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const o=this.#e[t];if(o!==void 0){if(o.length===1){o[0].call(null,n);return}let s;const r=Array.from(o);for(let i=0;i<r.length;i++){const a=r[i];try{a.call(null,n)}catch(l){s??={error:l}}}if(s)throw s.error}}removeAllListeners(){this.#e={}}removeListener(t,n){const o=this.#e[t];if(o!==void 0){const s=o.indexOf(n);s>=0&&o.splice(s,1)}}}function an(e){const t=o=>{o.preventDefault(),o.stopPropagation(),n()},n=()=>{e.removeEventListener("click",t,!0)};e.addEventListener("click",t,!0),setTimeout(n,0)}let ce={cursorFlags:0,state:"inactive"};const pn=new fn;function ye(){return ce}function Wt(e){return pn.addListener("change",e)}function qs(e,t=[],n,o=!1){const s=ce,r={...ce};r.cursorFlags=e,r.state==="active"&&(r.didPointerMove||=o,r.previews=t,n&&(r.previewLayoutMap=n)),ce=r,pn.emit("change",{prev:s,next:r})}function Ee(e){const t=ce;ce=e,t.state==="active"&&e.state!=="active"&&t.didPointerMove&&(t.hitRegions.forEach(({separator:n})=>{n&&n.element.ownerDocument.activeElement===n.element&&n.element.blur()}),an(t.ownerDocument)),pn.emit("change",{prev:t,next:e})}function Us(e){ce.state!=="active"||!ce.previews.some(t=>t.separator===e)||Ee({...ce,previews:ce.previews.map(t=>t.separator===e?{...t}:t)})}function Ks(e){if(ce.state==="inactive")return;const t=ce.hitRegions.filter(o=>o.axis!==e),n=ce.state==="active"&&ce.previews.some(o=>o.axis===e);if(!(t.length===ce.hitRegions.length&&!n))if(t.length===0)Ee({cursorFlags:0,state:"inactive"});else if(ce.state==="active"){const o=new Map(ce.initialLayoutMap),s=new Map(ce.previewLayoutMap);o.delete(e),s.delete(e),Ee({...ce,cursorFlags:0,hitRegions:t,initialLayoutMap:o,previewLayoutMap:s,previews:ce.previews.filter(r=>r.axis!==e)})}else Ee({...ce,hitRegions:t})}const Ys=e=>e,tn=()=>{},Ao=1,$o=2,jo=4,No=8,Yn=3,Xn=12;let kt;function Jn(){return kt===void 0&&(kt=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(kt=!0)),kt}function Xs({cursorFlags:e,axes:t,state:n}){let o=0,s=0;switch(n){case"active":case"hover":t.forEach(r=>{if(!r.mutableState.disableCursor)switch(r.orientation){case"horizontal":{o++;break}case"vertical":{s++;break}}})}if(!(o===0&&s===0)){switch(n){case"active":{if(e&&Jn()){const r=(e&Ao)!==0,i=(e&$o)!==0,a=(e&jo)!==0,l=(e&No)!==0;if(r)return a?"se-resize":l?"ne-resize":"e-resize";if(i)return a?"sw-resize":l?"nw-resize":"w-resize";if(a)return"s-resize";if(l)return"n-resize"}break}}return Jn()?o>0&&s>0?"move":o>0?"ew-resize":"ns-resize":o>0&&s>0?"grab":o>0?"col-resize":"row-resize"}}const Zn=new WeakMap;function Qn(e){if(!e.defaultView||!e.adoptedStyleSheets)return;let{prevStyle:t,styleSheet:n}=Zn.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let o=ye();switch(o.state!=="inactive"&&o.ownerDocument!==e&&(o={cursorFlags:0,state:"inactive"}),o.state){case"active":case"hover":{const s=Xs({cursorFlags:o.cursorFlags,axes:o.hitRegions.map(i=>i.axis),state:o.state}),r=`*, *:hover {cursor: ${s} !important; }`;if(t===r)return;t=r,s?n.cssRules.length===0?n.insertRule(r):n.replaceSync(r):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}Zn.set(e,{prevStyle:t,styleSheet:n})}function eo(e){return e.state==="inactive"?void 0:e.ownerDocument}function Js({next:e,prev:t}){const n=eo(t),o=eo(e);n&&n!==o&&Qn(n),o&&Qn(o)}function gt({axis:e}){const{layoutStrategy:t,orientation:n,items:o}=e;return t?t.calculateAvailableSize():o.reduce((s,r)=>(s+=n==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,s),0)}function mn(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_DISCONNECTED?0:n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0}function ft(e,t){return Array.from(t).sort((n,o)=>{const s=e==="horizontal"?Zs(n,o):Qs(n,o);return s!==0?s:mn(n.element,o.element)})}function Zs(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function Qs(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function Oe(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function Go(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function er({orientation:e,rects:t,targetRect:n}){const o={x:n.x+n.width/2,y:n.y+n.height/2};let s,r=Number.MAX_VALUE;for(const i of t){const{x:a,y:l}=Go(o,i),c=e==="horizontal"?a:l;c<r&&(r=c,s=i)}return te(s,"No rect found"),s}function Ae(e,t){const n=t==="horizontal"?e.offsetWidth:e.offsetHeight;if(n===0)return 1;const o=e.getBoundingClientRect(),s=t==="horizontal"?o.width:o.height;return s<=0||Math.abs(s-n)<1?1:s/n}function hn({expandHitTargets:e=!0,axis:t,includeDisabled:n=!1}){if(t.layoutStrategy)return t.layoutStrategy.calculateHitRegions({expandHitTargets:e,axis:t,includeDisabled:n});const{element:o,orientation:s,items:r,separators:i}=t,a=ft(s,Array.from(o.children).filter(Oe).filter(y=>!y.hasAttribute("data-resize-preview")).map(y=>({element:y}))).map(({element:y})=>y),l=[];let c=!1,u=!1,d=-1,g,h=-1,m=0,p,b=[];{let y=-1;for(const S of a)S.hasAttribute("data-panel")&&(y++,S.hasAttribute("data-disabled")||(m++,d===-1&&(d=y),h=y))}if(n||m>1){let y=-1;for(const S of a)if(S.hasAttribute("data-panel")){y++;const x=r.find(C=>C.element===S);if(x){if(p){const C=p.element.getBoundingClientRect(),O=S.getBoundingClientRect();let $;if(u){const M=s==="horizontal"?new DOMRect(C.right,C.top,0,C.height):new DOMRect(C.left,C.bottom,C.width,0),T=s==="horizontal"?new DOMRect(O.left,O.top,0,O.height):new DOMRect(O.left,O.top,O.width,0);switch(b.length){case 0:{$=[M,T];break}case 1:{const I=b[0],v=er({orientation:s,rects:[C,O],targetRect:I.element.getBoundingClientRect()});$=[I,v===C?T:M];break}default:{$=b;break}}}else b.length?$=b:$=[s==="horizontal"?new DOMRect(C.right,O.top,O.left-C.right,O.height):new DOMRect(O.left,C.bottom,O.width,O.top-C.bottom)];for(const M of $){const T=rn({expandHitTargets:e,axis:t,rect:"width"in M?M:M.element.getBoundingClientRect()}),I=y<=d||y>h;(n||!c&&!I)&&(g??=gt({axis:t})*Ae(t.element,t.orientation),l.push({axis:t,axisSize:g,items:[p,x],separator:"width"in M?void 0:M,rect:T})),c=!1}}u=!1,p=x,b=[]}}else if(S.hasAttribute("data-separator")){S.ariaDisabled!==null&&(c=!0);const x=i.find(C=>C.element===S);x?b.push(x):(p=void 0,b=[])}else u=!0}return l}function gn(e){return e.ownerDocument.defaultView??window}function tr(e,t){const n=gn(e).getComputedStyle(e),o=parseFloat(n.fontSize);return t*o}function nr(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),o=parseFloat(n.fontSize);return t*o}function or(e,t){return t/100*gn(e).innerHeight}function sr(e,t){return t/100*gn(e).innerWidth}function bn(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Ke({axisSize:e,itemElement:t,styleProp:n}){let o;const[s,r]=bn(n);switch(r){case"%":{o=s/100*e;break}case"px":{o=s;break}case"rem":{o=nr(t,s);break}case"em":{o=tr(t,s);break}case"vh":{o=or(t,s);break}case"vw":{o=sr(t,s);break}}return o}function fe(e){return parseFloat(e.toFixed(3))}function yn(e,t=gt({axis:e})){const{items:n}=e;return t===0?n.map(o=>({groupResizeBehavior:o.constraintProps.groupResizeBehavior,collapsedSize:0,collapsible:o.constraintProps.collapsible===!0,defaultSize:void 0,disabled:o.constraintProps.disabled,minSize:0,maxSize:100,itemId:o.id})):n.map(o=>{const{element:s,constraintProps:r}=o;let i=0;if(r.collapsedSize!==void 0){const d=Ke({axisSize:t,itemElement:s,styleProp:r.collapsedSize});i=fe(d/t*100)}let a;if(r.collapsedThreshold!==void 0){const d=Ke({axisSize:t,itemElement:s,styleProp:r.collapsedThreshold});a=fe(d/t*100)}let l;if(r.defaultSize!==void 0){const d=Ke({axisSize:t,itemElement:s,styleProp:r.defaultSize});l=fe(d/t*100)}let c=0;if(r.minSize!==void 0){const d=Ke({axisSize:t,itemElement:s,styleProp:r.minSize});c=fe(d/t*100)}let u=100;if(r.maxSize!==void 0){const d=Ke({axisSize:t,itemElement:s,styleProp:r.maxSize});u=fe(d/t*100)}return{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsedThreshold:a,collapsible:r.collapsible===!0,defaultSize:l,disabled:r.disabled,minSize:c,maxSize:u,itemId:o.id}})}let ke=new Map;const vn=new fn;let pt=0;const Dt=[];let Ot;function Bt(){pt++}function Sn(){for(let e=0;e<Dt.length;e++)try{vn.emit("axisChange",Dt[e])}catch(t){Ot??={error:t}}Dt.length=0}function Ht(){if(pt===1&&Sn(),pt--,pt===0&&Ot){const{error:e}=Ot;throw Ot=void 0,e}}function rr(e){ke=new Map(ke),ke.delete(e)}function st(e,t){for(const[n]of ke)if(n.id===e)return n}function ge(e,t){for(const[n,o]of ke)if(n.id===e)return o;if(t)throw Error(`Could not find data for Group with id ${e}`)}function $e(){return ke}function rt(e,t){return vn.addListener("axisChange",n=>{n.axis.id===e&&t(n)})}function De(e,t,n){const o=ke.get(e);ke=new Map(ke),ke.set(e,t);const s={axis:e,isUserInteraction:n?.isUserInteraction===!0,prev:o,next:t};pt>0?Dt.push(s):vn.emit("axisChange",s)}function Fo(e,{pointerId:t,pointerType:n}){return t===e.pointerId||n==="pen"&&e.pointerType==="pen"}function bt(e,t,n={}){return e.ownerDocument===t&&(n.pointerId===void 0||Fo(e,n))}function ir(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function re(e,t,n=0){return Math.abs(fe(e)-fe(t))<=n}function ve(e,t){return re(e,t)?0:e>t?1:-1}function Ye({overrideDisabledItems:e,itemConstraints:t,prevSize:n,size:o}){const{collapsedSize:s=0,collapsedThreshold:r,collapsible:i,disabled:a,maxSize:l=100,minSize:c=0}=t;if(a&&!e)return n;if(ve(o,c)<0)if(i){const u=r??(c-s)/2,d=ve(n,s)<=0,g=d?s+u:c-u,h=ve(o,g);ve(o,s)<=0||h<0||r!==void 0&&d&&h===0?o=s:o=c}else o=c;return o=Math.min(l,o),o=fe(o),o}function ht({delta:e,initialLayout:t,itemConstraints:n,pivotIndices:o,prevLayout:s,trigger:r}){if(re(e,0))return t;const i=r==="imperative-api",a=n.map(({itemId:m})=>t[m]),l=n.map(({itemId:m})=>s[m]),c=[...a],[u,d]=o;te(u!=null,"Invalid first pivot index"),te(d!=null,"Invalid second pivot index");let g=0;switch(r){case"keyboard":{{const m=e<0?d:u,p=n[m];te(p,`Panel constraints not found for index ${m}`);const{collapsedSize:b=0,collapsible:y,minSize:S=0}=p;if(y){const x=a[m];if(te(x!=null,`Previous layout not found for panel index ${m}`),re(x,b)){const C=S-x;ve(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}{const m=e<0?u:d,p=n[m];te(p,`No panel constraints found for index ${m}`);const{collapsedSize:b=0,collapsible:y,minSize:S=0}=p;if(y){const x=a[m];if(te(x!=null,`Previous layout not found for panel index ${m}`),re(x,S)){const C=x-b;ve(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}break}default:{const m=e<0?d:u,p=n[m];te(p,`Panel constraints not found for index ${m}`);const b=a[m],{collapsedSize:y,collapsedThreshold:S,collapsible:x,minSize:C}=p;if(x&&ve(b,C)<0){const O=C-y,$=S??O/2,M=b+Math.abs(e);if(ve(M,C)<0){const T=ve(Math.abs(e),$),I=S===void 0&&e<0;T>0||T===0&&I?e=e<0?-O:O:e=0}}break}}{const m=e<0?1:-1;let p=e<0?d:u,b=0;for(;;){const S=a[p];te(S!=null,`Previous layout not found for panel index ${p}`);const C=Ye({overrideDisabledItems:i,itemConstraints:n[p],prevSize:S,size:100})-S;if(b+=C,p+=m,p<0||p>=n.length)break}const y=Math.min(Math.abs(e),Math.abs(b));e=e<0?0-y:y}{let p=e<0?u:d;for(;p>=0&&p<n.length;){const b=Math.abs(e)-Math.abs(g),y=a[p];te(y!=null,`Previous layout not found for panel index ${p}`);const S=y-b,x=Ye({overrideDisabledItems:i,itemConstraints:n[p],prevSize:y,size:S});if(!re(y,x)&&(g+=y-x,c[p]=x,g.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(ir(l,c))return s;{const m=e<0?d:u,p=a[m];te(p!=null,`Previous layout not found for panel index ${m}`);const b=p+g,y=Ye({overrideDisabledItems:i,itemConstraints:n[m],prevSize:p,size:b});if(c[m]=y,!re(y,b)){let S=b-y,C=e<0?d:u;for(;C>=0&&C<n.length;){const O=c[C];te(O!=null,`Previous layout not found for panel index ${C}`);const $=O+S,M=Ye({overrideDisabledItems:i,itemConstraints:n[C],prevSize:O,size:$});if(re(O,M)||(S-=M-O,c[C]=M),re(S,0))break;e>0?C--:C++}}}const h=Object.values(c).reduce((m,p)=>p+m,0);return re(h,100,.1)?c.reduce((m,p,b)=>(m[n[b].itemId]=p,m),{}):s}function Te(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||ve(e[n],t[n])!==0)return!1;return!0}function xn(e){Bt();try{ar(e)}finally{Ht()}}function ar({commit:e,event:t,hitRegions:n,initialLayoutMap:o,mountedAxes:s,pointerDownAtPoint:r,prevCursorFlags:i}){let a=0;const l=ye();let c=l.state==="active"?l.previews:[];const u=new Map(l.state==="active"?l.previewLayoutMap:void 0);n.forEach(h=>{const{axis:m,axisSize:p}=h,{orientation:b,items:y}=m;if(e&&m.resizePreviewMode!=="separator")return;const{disableCursor:S}=m.mutableState;let x=0;r?b==="horizontal"?x=(t.clientX-r.x)/p*100:x=(t.clientY-r.y)/p*100:b==="horizontal"?x=t.clientX<0?-100:100:x=t.clientY<0?-100:100;const C=o.get(m),O=s.get(m);if(!C||!O)return;const{defaultLayoutDeferred:$,derivedItemConstraints:M,axisSize:T,layout:I,separatorToItems:v}=O;if(M&&I&&v){const L=m.resizePreviewMode==="separator"?u.get(m)??I:I,E=ht({delta:x,initialLayout:C,itemConstraints:M,pivotIndices:h.items.map(B=>y.indexOf(B)),prevLayout:L,trigger:"mouse-or-touch"});if(m.resizePreviewMode==="separator"&&!e&&!Te(E,L)){u.set(m,E);let B=0;const _=y.map(D=>(B+=E[D.id]-C[D.id],B*(p/100)));c=c.map(D=>{if(D.axis!==m)return D;const K=_[D.itemIndex];return K===D.offset?D:{...D,offset:K}})}if(Te(E,L)&&x!==0&&!S)switch(b){case"horizontal":{a|=x<0?Ao:$o;break}case"vertical":{a|=x<0?jo:No;break}}(m.resizePreviewMode!=="separator"||e)&&!Te(E,I)&&De(h.axis,{defaultLayoutDeferred:$,derivedItemConstraints:M,axisSize:T,layout:E,requestedAxisSize:T,requestedLayout:E,separatorToItems:v})}});let d=0;t.movementX===0?d|=i&Yn:d|=a&Yn,t.movementY===0?d|=i&Xn:d|=a&Xn;const g=l.state==="active"&&(t.clientX!==l.pointerDownAtPoint.x||t.clientY!==l.pointerDownAtPoint.y);qs(d,c,u,g)}function Wo(e,t){const n=ye();if(n.state!=="active"||!bt(n,e,t))return;const o=$e();Bt();try{xn({commit:!0,event:t,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:o,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:n.cursorFlags}),Sn(),Ee({cursorFlags:0,state:"inactive"}),n.hitRegions.length>0&&(t.preventDefault?.(),n.hitRegions.forEach(s=>{if(!o.has(s.axis))return;const r=ge(s.axis.id,!0);De(s.axis,r,{isUserInteraction:!0})}))}finally{Ht()}}function to(e){if(e.defaultPrevented)return;const{clientX:t,clientY:n,movementX:o,movementY:s}=e;Wo(e.currentTarget,{clientX:t,clientY:n,movementX:o,movementY:s})}function cr(e,t,n){let o,s={x:1/0,y:1/0};for(const r of t){const i=Go(n,r.rect);switch(e){case"horizontal":{(i.x<s.x||i.x===s.x&&i.y<=s.y)&&(o=r,s=i);break}case"vertical":{(i.y<s.y||i.y===s.y&&i.x<=s.x)&&(o=r,s=i);break}}}return o?{distance:s,hitRegion:o}:void 0}function Bo(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function lr(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:so(e),b:so(t)};let o;for(;n.a.at(-1)===n.b.at(-1);)o=n.a.pop(),n.b.pop();te(o,"Stacking order can only be calculated for elements with a common ancestor");const s={a:oo(no(n.a)),b:oo(no(n.b))};if(s.a===s.b){const r=o.childNodes,i={a:n.a.at(-1),b:n.b.at(-1)};let a=r.length;for(;a--;){const l=r[a];if(l===i.a)return 1;if(l===i.b)return-1}}return Math.sign(s.a-s.b)}const ur=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function dr(e){const t=getComputedStyle(Ho(e)??e).display;return t==="flex"||t==="inline-flex"}function fr(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||dr(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||ur.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function no(e){let t=e.length;for(;t--;){const n=e[t];if(te(n,"Missing node"),fr(n))return n}return null}function oo(e){return e&&Number(getComputedStyle(e).zIndex)||0}function so(e){const t=[];for(;e;)t.push(e),e=Ho(e);return t}function Ho(e){const{parentNode:t}=e;return Bo(t)?t.host:t}function pr(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function mr(e){try{return e.matches(":modal")}catch{return!1}}function hr({axisElement:e,hitRegion:t,pointerEventTarget:n}){if(Oe(n)){const o=n.closest("dialog");if(o&&!o.contains(e)&&mr(o))return!1}if(!Oe(n)||n.contains(e)||e.contains(n)||!n.isConnected||!e.isConnected)return!0;if(lr(n,e)>0){let o=n;for(;o;){if(o.contains(e))return!0;if(pr(o.getBoundingClientRect(),t))return!1;o=o.parentElement}}return!0}function wn(e,t,n){const o=[];return t.forEach((s,r)=>{if(r.disabled||r.element.ownerDocument!==n)return;const i=hn({axis:r}),a=cr(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&hr({axisElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&o.push(a.hitRegion)}),o}function Vo(e){let t=0,n=0;const o={};for(const r of e)if(r.defaultSize!==void 0){t++;const i=fe(r.defaultSize);n+=i,o[r.itemId]=i}else o[r.itemId]=void 0;const s=e.length-t;if(s!==0){const r=fe((100-n)/s);for(const i of e)i.defaultSize===void 0&&(o[i.itemId]=r)}return o}function gr(e,t){const n=e.map(s=>s.id),o=Object.keys(t);if(n.length!==o.length)return!1;for(const s of n)if(!o.includes(s))return!1;return!0}function _o({axis:e,itemConstraints:t}){const n=e.items.map(({id:s})=>s).join(","),o=e.mutableState.defaultLayout;return e.mutableState.layouts[n]??(o&&gr(e.items,o)?o:Vo(t))}function zn(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const o in e)if(e[o]!==t[o])return!1;return!0}function br(e,t){return e.length!==t.length?!1:e.every((n,o)=>zn(n,t[o]))}function He({layout:e,itemConstraints:t}){const n=t.map(({itemId:i})=>e[i]),o=[...n],s=o.reduce((i,a)=>i+a,0);if(Object.keys(e).length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${Object.values(e).map(i=>`${i}%`).join(", ")}`);if(!re(s,100)&&o.length>0)for(let i=0;i<t.length;i++){const a=o[i];te(a!=null,`No layout data found for index ${i}`);const l=100/s*a;o[i]=l}let r=0;for(let i=0;i<t.length;i++){const a=n[i];te(a!=null,`No layout data found for index ${i}`);const l=o[i];te(l!=null,`No layout data found for index ${i}`);const c=Ye({overrideDisabledItems:!0,itemConstraints:t[i],prevSize:a,size:l});l!=c&&(r+=l-c,o[i]=c)}if(!re(r,0))for(let i=0;i<t.length;i++){const a=o[i];te(a!=null,`No layout data found for index ${i}`);const l=a+r,c=Ye({overrideDisabledItems:!0,itemConstraints:t[i],prevSize:a,size:l});if(a!==c&&(r-=c-a,o[i]=c,re(r,0)))break}return o.reduce((i,a,l)=>(i[t[l].itemId]=a,i),{})}function qo({itemIds:e,layout:t}){return He({layout:t,itemConstraints:e.map(n=>({collapsedSize:0,collapsible:!1,defaultSize:void 0,disabled:void 0,itemId:n,maxSize:100,minSize:0}))})}function yr({axis:e,nextAxisSize:t,prevAxisSize:n,prevLayout:o}){if(n<=0||t<=0||n===t)return o;let s=0,r=0,i=!1;const a=new Map,l=[];for(const d of e.items){const g=o[d.id]??0;switch(d.constraintProps.groupResizeBehavior){case"preserve-pixel-size":{i=!0;const h=g/100*n,m=fe(h/t*100);a.set(d.id,m),s+=m;break}case"preserve-relative-size":default:{l.push(d.id),r+=g;break}}}if(!i||l.length===0)return o;const c=100-s,u={...o};if(a.forEach((d,g)=>{u[g]=d}),r>0)for(const d of l){const g=o[d]??0;u[d]=fe(g/r*c)}else{const d=fe(c/l.length);for(const g of l)u[g]=d}return u}function Cn({axis:e,axisState:t}){const n=gt({axis:e});if(n===0)return;const o=yn(e,n);let s=t.requestedAxisSize,r=t.requestedLayout;t.defaultLayoutDeferred&&(s=n,r=qo({itemIds:e.items.map(({id:c})=>c),layout:_o({axis:e,itemConstraints:o})}));const i=yr({axis:e,nextAxisSize:n,prevAxisSize:s,prevLayout:r}),a=He({layout:i,itemConstraints:o});return{changed:t.defaultLayoutDeferred||!Te(t.layout,a)||!br(t.derivedItemConstraints,o)||t.axisSize!==n,state:{defaultLayoutDeferred:!1,derivedItemConstraints:o,axisSize:n,layout:a,requestedAxisSize:s,requestedLayout:r,separatorToItems:t.separatorToItems}}}function Tn({axisId:e,itemId:t}){const n=()=>{const c=$e();for(const[u,d]of c)if(u.id===e)return{axis:u,...d};throw Error(`Group ${e} not found`)},o=()=>{const c=n().derivedItemConstraints.find(u=>u.itemId===t);if(c!==void 0)return c;throw Error(`Panel constraints not found for Panel ${t}`)},s=()=>{const{axis:c,...u}=n(),d=Cn({axis:c,axisState:u}),g=d?.state??u,h=g.derivedItemConstraints.find(p=>p.itemId===t);if(h===void 0)throw Error(`Panel constraints not found for Panel ${t}`);const m=g.layout[t];if(m===void 0)throw Error(`Layout not found for Panel ${t}`);return{axis:c,changed:d?.changed===!0,itemConstraints:h,itemSize:m,state:g}},r=()=>{const c=n().axis.items.find(u=>u.id===t);if(c!==void 0)return c;throw Error(`Layout not found for Panel ${t}`)},i=()=>{const c=n().layout[t];if(c!==void 0)return c;throw Error(`Layout not found for Panel ${t}`)},a=({allowPartialSize:c=!1,nextSize:u,items:d,prevLayout:g,derivedItemConstraints:h})=>{const m=g[t],p=d.findIndex(v=>v.id===t),b=p===0,y=p===d.length-1;if(y&&u<m&&(b||d.slice(0,p).every((v,L)=>{const E=h[L];return E?.collapsible&&re(E.collapsedSize,g[E.itemId])}))){const v=d.slice(0,p).reduce((L,E)=>L+g[E.id],0);return{...g,[t]:fe(100-v)}}const x=h[p],C=Ye({overrideDisabledItems:!0,itemConstraints:x,prevSize:m,size:u}),O={...g};let $=C-m;for(const v of b?[1]:y?[-1]:[1,-1])for(let L=p+v;L>=0&&L<d.length&&!re($,0);L+=v){const E=h[L],B=O[E.itemId];if(jt(E,O)||($>0?ve(B,E.minSize)<=0:ve(B,E.maxSize)>=0))continue;const _=$>0?Math.max(E.minSize,B-$):Math.min(E.maxSize,B-$);$-=B-_,O[E.itemId]=fe(_)}if(O[t]=fe(C-$),re($,0)||c&&ve(O[t],x.minSize)>=0)return O;const M=(v,L,E)=>{const B=v==="after"?1:-1,_=K=>{for(let H=p+B;H>=0&&H<d.length;H+=B){const W=h[H];if(!jt(W,L)&&K(W))return H}},D=_(({itemId:K,maxSize:H,minSize:W})=>E>0?ve(L[K],W)>0:ve(L[K],H)<0)??_(()=>!0)??p+B;return ht({delta:v==="after"?E:-E,initialLayout:L,itemConstraints:h,pivotIndices:v==="after"?[p,D]:[D,p],prevLayout:L,trigger:"imperative-api"})};if(b||y)return M(y?"before":"after",g,u-m);const T=v=>{const L=M(v,g,u-m),E=u-L[t];return re(E,0)?L:M(v==="after"?"before":"after",L,E)},I=T("after");if(ro({itemConstraints:h,itemId:t,nextLayout:I,prevLayout:g})){const v=T("before");if(!ro({itemConstraints:h,itemId:t,nextLayout:v,prevLayout:g}))return v}return I},l=(c,{axis:u,changed:d,itemSize:g,state:h},{allowPartialSize:m=!1}={})=>{if(c===g)return;const{derivedItemConstraints:p,axisSize:b,layout:y}=h,S=a({allowPartialSize:m,nextSize:c,items:u.items,prevLayout:y,derivedItemConstraints:p}),x=He({layout:S,itemConstraints:p});(d||!Te(y,x))&&De(u,{...h,layout:x,requestedAxisSize:b,requestedLayout:x})};return{collapse:()=>{const c=s(),{collapsible:u,collapsedSize:d}=c.itemConstraints,{mutableValues:g}=r(),h=c.itemSize;u&&h!==d&&(g.expandToSize=h,l(d,c))},expand:()=>{const c=s(),{collapsible:u,collapsedSize:d,minSize:g}=c.itemConstraints,{mutableValues:h}=r(),m=c.itemSize;if(u&&m===d){let p=h.expandToSize??g;p===0&&(p=1),l(p,c,{allowPartialSize:!0})}},getSize:()=>{const{axis:c}=n(),u=i(),{element:d}=r(),g=c.layoutStrategy?c.layoutStrategy.getItemSizeInPixels(t):c.orientation==="horizontal"?d.offsetWidth:d.offsetHeight;return{asPercentage:u,inPixels:g}},isCollapsed:()=>{const{collapsible:c,collapsedSize:u}=o(),d=i();return c&&re(u,d)},resize:c=>{const u=s(),{axisSize:d}=u.state,{element:g}=r(),h=Ke({axisSize:d,itemElement:g,styleProp:c}),m=fe(h/d*100);l(m,u)}}}function jt({collapsedSize:e,collapsible:t,itemId:n},o){return t&&re(o[n],e)}function ro({itemConstraints:e,itemId:t,nextLayout:n,prevLayout:o}){return e.some(s=>s.itemId!==t&&jt(s,o)!==jt(s,n))}function io(e){if(e.defaultPrevented)return;const t=$e();wn(e,t,e.currentTarget).forEach(o=>{if(o.separator&&!o.separator.disableDoubleClick){const s=o.items.find(r=>r.constraintProps.defaultSize!==void 0);if(s){const r=s.constraintProps.defaultSize,i=Tn({axisId:o.axis.id,itemId:s.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Uo(e){const t=$e();for(const[n]of t)if(n.separators.some(o=>o.element===e))return n;throw Error("Could not find parent Group for separator element")}function mt({axisId:e}){const t=()=>{const n=$e();for(const[o,s]of n)if(o.id===e)return{axis:o,...s};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:o}=t();return n?{}:o},setLayout(n){const{axis:o,...s}=t(),r=Cn({axis:o,axisState:s}),i=r?.state??s,{defaultLayoutDeferred:a,derivedItemConstraints:l,axisSize:c,layout:u}=i,d=He({layout:n,itemConstraints:l});return a?u:((r?.changed||!Te(u,d))&&De(o,{...i,layout:d,requestedAxisSize:c,requestedLayout:d}),d)}}}function Ue(e,t){const n=Uo(e),o=ge(n.id,!0),s=n.separators.find(d=>d.element===e);te(s,"Matching separator not found");const r=o.separatorToItems.get(s);te(r,"Matching panels not found");const i=r.map(d=>n.items.indexOf(d)),l=mt({axisId:n.id}).getLayout(),c=ht({delta:t,initialLayout:l,itemConstraints:o.derivedItemConstraints,pivotIndices:i,prevLayout:l,trigger:"keyboard"}),u=He({layout:c,itemConstraints:o.derivedItemConstraints});Te(l,u)||De(n,{defaultLayoutDeferred:o.defaultLayoutDeferred,derivedItemConstraints:o.derivedItemConstraints,axisSize:o.axisSize,layout:u,requestedAxisSize:o.axisSize,requestedLayout:u,separatorToItems:o.separatorToItems},{isUserInteraction:!0})}function vr(e){return e.separators.filter(t=>!t.disabled)}function ao(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Uo(t);if(!(n.disabled||n.separators.find(s=>s.element===t)?.disabled))switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Ue(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Ue(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Ue(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Ue(t,-5);break}case"End":{e.preventDefault(),Ue(t,100);break}case"Enter":{e.preventDefault();const s=ge(n.id,!0),{derivedItemConstraints:r,layout:i,separatorToItems:a}=s,l=n.separators.find(g=>g.element===t);te(l,"Matching separator not found");const c=a.get(l);te(c,"Matching panels not found");const u=c[0],d=r.find(g=>g.itemId===u.id);if(te(d,"Panel metadata not found"),d.collapsible){const g=i[u.id],h=d.collapsedSize===g?n.mutableState.expandedItemSizes[u.id]??d.minSize:d.collapsedSize;Ue(t,h-g)}break}case"F6":{e.preventDefault();const s=vr(n).map(l=>l.element),r=s.findIndex(l=>l===e.currentTarget);te(r!==-1,"Index not found");const i=e.shiftKey?r>0?r-1:s.length-1:r+1<s.length?r+1:0;s[i].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Ue(t,-100);break}}}function ct(e,t){const n=ye();if(n.state!=="active"||!bt(n,e,t))return!1;const o=$e();Bt();try{n.previewLayoutMap.forEach((s,r)=>{const i=o.get(r);r.resizePreviewMode==="separator"&&i&&!Te(s,i.layout)&&De(r,{...i,layout:s,requestedAxisSize:i.axisSize,requestedLayout:s})}),Sn(),Ee({cursorFlags:0,state:"inactive"}),n.hitRegions.forEach(s=>{if(!o.has(s.axis))return;const r=ge(s.axis.id,!0);De(s.axis,r,{isUserInteraction:!0})})}finally{Ht()}return!0}function co(e){const t=ye();if(t.state!=="active")return;const n=t.hitRegions.flatMap(({separator:o})=>o?[o.element]:[]);!n.some(o=>o===e.target)||n.some(o=>o.hasPointerCapture?.(e.pointerId))||ct(e.currentTarget,e)}function lo(e){ct(e.currentTarget,e)}function Sr(e,t){const{element:n,orientation:o,items:s}=e,r=n.getBoundingClientRect(),i=o==="horizontal";return hn({expandHitTargets:!1,axis:e,includeDisabled:!0}).map(({items:l,rect:c,separator:u},d)=>{const g=s.indexOf(l[0]),h=i?c.left+c.width/2:c.top+c.height/2;return{active:t.some(p=>{if(p.axis!==e||p.items[0]!==l[0])return!1;if(u||p.separator)return p.separator===u;const b=i?p.rect.left+p.rect.width/2:p.rect.top+p.rect.height/2;return re(h,b)}),axis:e,key:u?`separator-${u.id}`:`panel-${l[0].id}-${d}`,offset:0,itemIndex:g,rect:new DOMRect((i&&!u?h:c.left)-r.left-n.clientLeft+n.scrollLeft,(!i&&!u?h:c.top)-r.top-n.clientTop+n.scrollTop,i&&!u?0:c.width,!i&&!u?0:c.height),separator:u}})}function uo(e){if(e.defaultPrevented)return;if(e.pointerType==="mouse"&&e.button>0)return;const t=ye();if(t.state==="active"){Fo(t,e)&&ct(t.ownerDocument,t);return}const n=$e(),o=wn(e,n,e.currentTarget);if(o.length===0)return;const s=new Map;let r=!1;o.forEach(a=>{a.separator&&(r||(r=!0,a.separator.element.focus({focusVisible:!1,preventScroll:!0})));const l=n.get(a.axis);l&&s.set(a.axis,l.layout)});const i=Array.from(s.keys()).flatMap(a=>a.resizePreviewMode==="separator"?Sr(a,o):[]);Ee({cursorFlags:0,didPointerMove:!1,hitRegions:o,initialLayoutMap:s,ownerDocument:e.currentTarget,pointerDownAtPoint:{x:e.clientX,y:e.clientY},pointerId:e.pointerId,pointerType:e.pointerType,previewLayoutMap:new Map(s),previews:i,state:"active"}),e.preventDefault()}function fo(e){const t=e.currentTarget,n=$e(),o=ye();switch(o.state){case"active":{if(!bt(o,t,e))return;xn({commit:!1,event:e,hitRegions:o.hitRegions,initialLayoutMap:o.initialLayoutMap,mountedAxes:n,prevCursorFlags:o.cursorFlags})}}}function po(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=ye(),o=$e();switch(n.state){case"active":{if(!bt(n,t,e))return;if(e.buttons===0){ct(t,e);return}for(const s of n.hitRegions)if(s.separator){const{element:r}=s.separator;r.isConnected&&!r.hasPointerCapture?.(e.pointerId)&&r.setPointerCapture?.(e.pointerId)}xn({commit:!1,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:o,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:n.cursorFlags});break}default:{const s=wn(e,o,t);s.length===0?n.state!=="inactive"&&Ee({cursorFlags:0,state:"inactive"}):Ee({cursorFlags:0,hitRegions:s,ownerDocument:t,state:"hover"});break}}}function mo(e){const t=e.relatedTarget;if(Oe(t)&&t.localName==="iframe"){const n=ye();switch(n.state){case"hover":n.ownerDocument===e.currentTarget&&Ee({cursorFlags:0,state:"inactive"})}}}function ho(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||Wo(e.currentTarget,e)}function go(e){e.target===e.currentTarget&&ct(e.currentTarget.document)}function bo(e){ct(e.currentTarget.document)}function xr(e,t,n){if(!n[0])return;const s=e.items.find(c=>c.element===t);if(!s||!s.onResize)return;const r=gt({axis:e}),i=e.orientation==="horizontal"?s.element.offsetWidth:s.element.offsetHeight,a=s.mutableValues.prevSize,l={asPercentage:fe(i/r*100),inPixels:i};s.mutableValues.prevSize=l,s.onResize(l,s.id,a)}const tt=new Map;let yo=!1;function Ko(e){let t=!0;te(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,o=new Set,s=new Set,r=new n(m=>{let p;Bt();try{for(const b of m){const{borderBoxSize:y,target:S}=b;if(S===e.element){if(t){const x=ge(e.id);if(!x)break;const C=Cn({axis:e,axisState:x});if(!C)break;if(!C.changed)continue;De(e,C.state)}}else try{xr(e,S,y)}catch(x){p??={error:x}}}}finally{Ht()}if(p)throw p.error});r.observe(e.element),e.items.forEach(m=>{te(!o.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),o.add(m.id),m.onResize&&r.observe(m.element)});const i=gt({axis:e}),a=yn(e,i),l=_o({axis:e,itemConstraints:a}),c=He({layout:l,itemConstraints:a}),u=e.element.ownerDocument,d=u.defaultView;tt.set(u,(tt.get(u)??0)+1);const g=new Map;return hn({axis:e,includeDisabled:!0}).forEach(m=>{m.separator&&g.set(m.separator,m.items)}),De(e,{defaultLayoutDeferred:i===0,derivedItemConstraints:a,axisSize:i,layout:c,requestedAxisSize:i,requestedLayout:qo({itemIds:e.items.map(({id:m})=>m),layout:l}),separatorToItems:g}),e.separators.forEach(m=>{te(!s.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),s.add(m.id),m.element.addEventListener("keydown",ao)}),yo||(yo=!0,Wt(Js)),tt.get(u)===1&&(u.addEventListener("contextmenu",to,!0),u.addEventListener("dblclick",io,!0),u.addEventListener("lostpointercapture",co,!0),u.addEventListener("pointercancel",lo,!0),u.addEventListener("pointerdown",uo,!0),u.addEventListener("pointerleave",fo),u.addEventListener("pointermove",po),u.addEventListener("pointerout",mo),u.addEventListener("pointerup",ho,!0),d?.addEventListener("blur",go),d?.addEventListener("pagehide",bo)),function(){t=!1,tt.set(u,Math.max(0,(tt.get(u)??0)-1)),rr(e),Ks(e),e.separators.forEach(p=>{p.element.removeEventListener("keydown",ao)}),tt.get(u)||(u.removeEventListener("contextmenu",to,!0),u.removeEventListener("dblclick",io,!0),u.removeEventListener("lostpointercapture",co,!0),u.removeEventListener("pointercancel",lo,!0),u.removeEventListener("pointerdown",uo,!0),u.removeEventListener("pointerleave",fo),u.removeEventListener("pointermove",po),u.removeEventListener("pointerout",mo),u.removeEventListener("pointerup",ho,!0),d?.removeEventListener("blur",go),d?.removeEventListener("pagehide",bo)),r.disconnect()}}function Yo({derivedItemConstraints:e,axis:t,layout:n,prevLayout:o,requestedLayout:s}){const r=t.items.map(({id:i})=>i).join(",");t.mutableState.layouts[r]=s,o&&e.forEach(i=>{if(i.collapsible){const a=re(i.collapsedSize,n[i.itemId]),l=re(i.collapsedSize,o[i.itemId]);a&&!l&&(t.mutableState.expandedItemSizes[i.itemId]=o[i.itemId])}})}function Xo(){const[e,t]=f.useState({}),n=f.useCallback(()=>t({}),[]);return[e,n]}function Vt(e){const t=f.useRef({...e});return ne(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const In=f.createContext(null),ot=["column","row"],_t=f.createContext(null);function wr({layout:e,itemConstraints:t,itemId:n,itemIndex:o}){let s,r;const i=e[n],a=t.find(l=>l.itemId===n);if(a){const l=a.maxSize,c=a.collapsible?a.collapsedSize:a.minSize,u=[o,o+1];r=He({layout:ht({delta:c-i,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n],s=He({layout:ht({delta:l-i,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n]}return{valueControls:n,valueMax:s,valueMin:r,valueNow:i}}function Jo({attributes:e,axisId:t,axisOrientation:n,children:o,className:s,"data-testid":r,disableCursor:i,disabled:a,disableDoubleClick:l,elementRef:c,id:u,isSharedHitRegion:d,preview:g,registerSeparator:h,requiredStyle:m,style:p,styleDefaults:b,tabIndex:y=0,updateSeparatorProps:S}){const x=Vt({disabled:a,disableDoubleClick:l,children:o,className:s,preview:g,style:p}),[C,O]=f.useState({}),[$,M]=f.useState("inactive"),[T,I]=f.useState(!1),v=f.useRef(null),L=f.useRef(null),E=Ze(v,c),B=n==="horizontal"?"vertical":"horizontal";ne(()=>{const K=v.current;if(K!==null){const H={disabled:x.disabled,disableDoubleClick:x.disableDoubleClick,element:K,id:u,get children(){return x.children},get className(){return x.className},get preview(){return x.preview},get style(){return x.style}};L.current=H;const W=h(H),N=Wt(J=>{M(J.next.state!=="inactive"&&J.next.hitRegions.some(Y=>Y.separator===H||(d?.(Y)??!1))?J.next.state:"inactive")}),j=rt(t,J=>{const{derivedItemConstraints:Y,layout:se,separatorToItems:ue}=J.next,be=ue.get(H);if(be){const z=be[0],q=Y.findIndex(P=>P.itemId===z.id),{layoutStrategy:V}=J.axis;O({...wr({layout:se,itemConstraints:Y,itemId:z.id,itemIndex:q}),...V?.getItemAriaControls&&{valueControls:V.getItemAriaControls(z.id)}})}});return()=>{L.current=null,N(),j(),W()}}},[t,u,d,h,x]),ne(()=>{const K=L.current;K&&Us(K)},[g]),f.useEffect(()=>{S(u,{disabled:a,disableDoubleClick:l})},[a,l,u,S]);let _;a&&!i&&(_="not-allowed");let D;if(a)D="disabled";else switch($){case"active":{D="active";break}default:T?D="focus":D=$}return A.jsx("div",{...e,"aria-controls":C.valueControls,"aria-disabled":a||void 0,"aria-orientation":B,"aria-valuemax":C.valueMax,"aria-valuemin":C.valueMin,"aria-valuenow":C.valueNow,children:o,className:s,"data-separator":D,"data-testid":r,id:u,onBlur:()=>I(!1),onFocus:()=>I(!0),ref:E,role:"separator",style:{...b,cursor:_,...p,...m,touchAction:"none"},tabIndex:a?void 0:y})}function vo({axis:e,children:t,className:n,crossSpan:o,crossStart:s,disabled:r,elementRef:i,index:a,style:l}){const c=Je(void 0),{getDisableCursor:u,getResizeAxisId:d,gutters:g,registerSeparator:h,separatorPlacements:m,trackCounts:p,updateSeparatorProps:b}=Do(),y=d(e),S=e==="column"?"row":"column",x=p[S],C=!!r||!dn(a,p[e]);let O=!0;for(const v of m.values())if(v.axis===e&&v.index===a&&!v.disabled&&v.crossStart<s){O=!1;break}const $=f.useCallback(v=>v.axis.id===y&&v.axis.items.indexOf(v.items[1])===a,[y,a]),M=f.useCallback(v=>h({axis:e,crossSpan:o,crossStart:s,disabled:!!r,index:a},v),[e,o,s,r,a,h]),T=Fs(a),I=Ws({crossCount:x,crossSpan:o,crossStart:s,hasGutters:g[S]});return A.jsx(Jo,{axisId:y,axisOrientation:e==="column"?"horizontal":"vertical",className:n,disableCursor:u(),disabled:C,disableDoubleClick:void 0,elementRef:i,id:c,isSharedHitRegion:$,registerSeparator:M,requiredStyle:{gridColumn:e==="column"?T:I,gridRow:e==="row"?T:I},style:l,tabIndex:O?0:-1,updateSeparatorProps:b,children:t})}function zr(e){const{children:t,className:n,disabled:o,elementRef:s,style:r}=e;return e.type==="column"?A.jsx(vo,{axis:"column",className:n,crossSpan:e.rowSpan,crossStart:e.row??0,disabled:o,elementRef:s,index:e.column,style:r,children:t}):A.jsx(vo,{axis:"row",className:n,crossSpan:e.columnSpan,crossStart:e.column??0,disabled:o,elementRef:s,index:e.row,style:r,children:t})}const Zo=Object.assign(zr,{displayName:"Gridline"});function Qo(e,t){f.Children.forEach(e,n=>{if(f.isValidElement(n))if(n.type===Zo){const{type:o}=n.props;o==="column"?t.column=!0:o==="row"&&(t.row=!0)}else typeof n.type=="symbol"&&n.props!==null&&typeof n.props=="object"&&"children"in n.props&&Qo(n.props.children,t)})}function Cr(e,t){if(t)return e.map(r=>`minmax(0, ${t[r.id]??1}fr)`);const n=e.map(r=>r.defaultSize===void 0?void 0:bn(r.defaultSize));let o=100,s=0;return n.forEach(r=>{r===void 0?s++:r[1]==="%"&&(o-=r[0])}),n.map(r=>{if(r===void 0)return`minmax(0, ${Math.max(0,o)/Math.max(1,s)}fr)`;const[i,a]=r;return a==="%"?`minmax(0, ${i}fr)`:`${i}${a}`})}function Tr({cells:e,separatorPlacements:t,trackCounts:n}){const o=[];for(const a of e)ot.forEach(l=>{const[c,u]=l==="column"?[a.column,a.columnSpan]:[a.row,a.rowSpan],d=n[l];(!Number.isInteger(c)||!Number.isInteger(u)||c<0||u<1||c+u>d)&&o.push(`Invalid Cell ${l} placement (${l}: ${c}, ${l}Span: ${u}); Grid has ${d} ${l}s`)});const s=({axis:a,crossSpan:l,crossStart:c,disabled:u,index:d})=>{const g=a==="column"?"row":"column";let h=`type="${a}" ${a}={${d}}`;return(c!==0||l!==void 0)&&(h+=` ${g}={${c}}`),l!==void 0&&(h+=` ${g}Span={${l}}`),u&&(h+=" disabled"),`<Gridline ${h} />`},r=Array.from(t.values()).filter(a=>{const{axis:l,crossSpan:c,crossStart:u,index:d}=a,g=l==="column"?"row":"column",h=n[l],m=n[g];let p=!0;return dn(d,h)||(o.push(`Invalid ${l} Gridline ${l} (${d}); must be between 1 and ${h-1}`),p=!1),!Number.isInteger(u)||u<0||u>=m?(o.push(`Invalid ${l} Gridline ${g} (${u}); must be between 0 and ${m-1}`),p=!1):c!==void 0&&(!Number.isInteger(c)||c<1||u+c>m)&&(o.push(`Invalid ${l} Gridline ${g}Span (${c}); Grid has ${m} ${g}s`),p=!1),p}),i=a=>{const l=n[a.axis==="column"?"row":"column"];return[a.crossStart,a.crossSpan===void 0?l:a.crossStart+a.crossSpan]};return r.forEach((a,l)=>{const{axis:c,index:u}=a,[d,g]=i(a);for(const h of e){const[m,p,b,y]=c==="column"?[h.column,h.columnSpan,h.row,h.rowSpan]:[h.row,h.rowSpan,h.column,h.columnSpan];if(m<u&&u<m+p&&b<g&&d<b+y){const S=c==="column"?"row":"column";o.push(`${s(a)} overlaps a Cell that spans across it (${c}: ${m}, ${c}Span: ${p}, ${S}: ${b}, ${S}Span: ${y}); use the ${S} and ${S}Span props to render gridlines beside the Cell instead`)}}for(const h of r.slice(l+1))if(h.axis===c&&h.index===u){const[m,p]=i(h);m<g&&d<p&&o.push(`${s(a)} overlaps ${s(h)}`)}}),o}function So(e,t){return Te(e.columns,t.columns)&&Te(e.rows,t.rows)}const xo={columns:{},rows:{}};function Ir({children:e,className:t,columns:n,defaultLayout:o,disableCursor:s,disabled:r,elementRef:i,gridRef:a,id:l,onLayoutChange:c,onLayoutChanged:u,resizeTargetMinimumSize:d={coarse:20,fine:10},rows:g,style:h,...m}){const p=Je(l),b=f.useCallback(P=>P==="column"?`${p}:columns`:`${p}:rows`,[p]),y=wo(n,"columns"),S=wo(g,"rows"),x=P=>P==="column"?y:S,C=f.useRef({onLayoutChange:xo,onLayoutChanged:xo}),O=ze(P=>{So(C.current.onLayoutChange,P)||(C.current.onLayoutChange=P,c?.(P))}),$=ze((P,k,G)=>{So(C.current.onLayoutChanged,P)||(C.current.onLayoutChanged=P,u?.(P,{isUserInteraction:k,requestedLayout:G}))}),M=f.useRef(null),T=Ze(M,i),[I,v]=Xo(),L=f.useRef({cells:[],column:{expandedItemSizes:{},layouts:{}},loggedErrors:new Set,row:{expandedItemSizes:{},layouts:{}},separators:new Map}),E={column:!1,row:!1};for(const P of L.current.separators.values())E[P.axis]=!0;Qo(e,E);const B=Vt({defaultLayout:o,disableCursor:s,resizeTargetMinimumSize:d}),_=ze(()=>!!B.disableCursor),D=f.useCallback(P=>{const k=L.current;return k.cells=[...k.cells,P],v(),()=>{k.cells=k.cells.filter(G=>G!==P),v()}},[v]),K=f.useCallback((P,k)=>{const G=L.current;return G.separators=new Map(G.separators),G.separators.set(k,P),v(),()=>{G.separators=new Map(G.separators),G.separators.delete(k),v()}},[v]),H=f.useCallback((P,{disabled:k,disableDoubleClick:G})=>{for(const U of L.current.separators.keys())U.id===P&&(U.disabled=k,U.disableDoubleClick=G)},[]),W=L.current.separators,N=f.useMemo(()=>({getDisableCursor:_,getResizeAxisId:b,gutters:{column:E.column,row:E.row},id:p,registerCell:D,registerSeparator:K,separatorPlacements:W,trackCounts:{column:y.length,row:S.length},updateSeparatorProps:H}),[y.length,_,b,E.column,E.row,p,D,K,S.length,W,H]),j=f.useRef([]);ne(()=>{const P=M.current;if(P===null)return;const k=L.current,G=Tr({cells:k.cells,separatorPlacements:k.separators,trackCounts:{column:y.length,row:S.length}});G.forEach(Z=>{k.loggedErrors.has(Z)||console.error(Z)}),k.loggedErrors=new Set(G);const U=Z=>Array.from(k.separators.entries()).filter(([,oe])=>oe.axis===Z).sort(([,oe],[,we])=>oe.index-we.index).map(([oe])=>oe),X=Z=>{const oe=Z==="column"?y:S,we=Z==="column"?S:y,Ce=oe.map(pe=>pe.id),he=b(Z),je=U(Z),Re=je.length>0,Ve=oe.map(({id:pe,...ie},me)=>({element:P,id:Ce[me],idIsStable:!0,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:void 0,constraintProps:ie})),Pe=()=>{const pe=[];if(Re){for(const[ie,me]of k.separators)if(me.axis===Z&&dn(me.index,oe.length)){const Fe=ie.element.getBoundingClientRect();pe[me.index]=Math.max(pe[me.index]??0,Z==="column"?Fe.width:Fe.height)}}return _s({axis:Z,element:P,gutterSizes:pe.filter(ie=>ie!==void 0),hasGutters:Re,layout:ge(he)?.layout,trackIds:Ce})};let Ne;const Ge=B.defaultLayout?.[Z==="column"?"columns":"rows"];if(Ge!==void 0&&Object.keys(Ge).length===Ce.length){Ne={};for(const pe of Ce){const ie=Ge[pe];ie!==void 0&&(Ne[pe]=ie)}}return{disabled:!!r,element:P,id:he,layoutStrategy:{getItemAriaControls:pe=>{const ie=Ce.indexOf(pe);return k.cells.filter(me=>{const Fe=Z==="column"?me.column:me.row,We=Z==="column"?me.columnSpan:me.rowSpan;return Fe<=ie&&ie<Fe+We}).map(me=>me.element.id).filter(Boolean).join(" ")||void 0},calculateAvailableSize:()=>Pe().availableSize,calculateHitRegions:({expandHitTargets:pe,axis:ie,includeDisabled:me})=>Vs({axis:Z,cells:k.cells,crossTrackCount:we.length,expandHitTargets:pe,resizeAxis:ie,axisSize:Pe().availableSize*Ae(ie.element,ie.orientation),includeDisabled:me,separatorPlacements:k.separators}),getItemSizeInPixels:pe=>Pe().trackSizes[Ce.indexOf(pe)]??0},mutableState:{defaultLayout:Ne,disableCursor:!!B.disableCursor,expandedItemSizes:k[Z].expandedItemSizes,layouts:k[Z].layouts},orientation:Z==="column"?"horizontal":"vertical",items:Ve,resizePreviewMode:"panel",get resizeTargetMinimumSize(){return B.resizeTargetMinimumSize},separators:je}},Q=ot.map(X);j.current=Q;const ee=Q.map(Z=>Ko(Z)),de=()=>{const[Z,oe]=Q.map(we=>ge(we.id));if(!(!Z||!oe||Z.defaultLayoutDeferred||oe.defaultLayoutDeferred))return{layout:{columns:Z.layout,rows:oe.layout},requestedLayout:{columns:Z.requestedLayout,rows:oe.requestedLayout}}};{const Z=de();if(Z)try{try{O(Z.layout)}finally{$(Z.layout,!1,Z.requestedLayout)}}catch(oe){throw j.current=[],ee.forEach(we=>we()),oe}}const xe=Q.map(Z=>rt(Z.id,oe=>{const{defaultLayoutDeferred:we,derivedItemConstraints:Ce,layout:he,requestedLayout:je}=oe.next;if(we||Ce.length===0)return;Yo({derivedItemConstraints:Ce,axis:Z,layout:he,prevLayout:oe.prev?.layout,requestedLayout:je});const Re=de();if(Re){const Ve=ye(),Pe=Ve.state!=="active"||!Ve.hitRegions.some(Ne=>Q.includes(Ne.axis));try{O(Re.layout)}finally{Pe&&$(Re.layout,oe.isUserInteraction,Re.requestedLayout)}}}));return()=>{j.current=[],ee.forEach(Z=>Z()),xe.forEach(Z=>Z())}},[y,r,b,p,$,O,S,I,B]),f.useEffect(()=>{j.current.forEach(P=>{P.mutableState.defaultLayout=o?.[P.orientation==="horizontal"?"columns":"rows"],P.mutableState.disableCursor=!!s})});const J=f.useMemo(()=>{const P=()=>{const[U,X]=ot.map(b);return!st(U)||!st(X)?{columns:{},rows:{}}:{columns:mt({axisId:U}).getLayout(),rows:mt({axisId:X}).getLayout()}},k=U=>U.map(X=>`"${X}"`).join(", "),G=(U,X)=>{const Q=b(U),ee=()=>{const de=st(Q);return te(de,`Grid "${p}" has not been mounted`),te(de.items.some(xe=>xe.id===X),`Grid "${p}" no longer contains a ${U} with id "${X}"; ${U} ids are ${k(de.items.map(xe=>xe.id))}`),Tn({axisId:Q,itemId:X})};return{collapse:()=>ee().collapse(),expand:()=>ee().expand(),getSize:()=>ee().getSize(),isCollapsed:()=>ee().isCollapsed(),resize:de=>ee().resize(de)}};return{getLayout:P,getTrackById:(U,X)=>{const Q=U==="column"?y:S,ee=`${X}`;return te(Q.some(de=>de.id===ee),`Grid "${p}" does not contain a ${U} with id "${ee}"; ${U} ids are ${k(Q.map(de=>de.id))}`),G(U,ee)},getTrackByIndex:(U,X)=>{const Q=U==="column"?y:S,ee=Number.isInteger(X)?Q[X]:void 0;return te(ee,`Grid "${p}" does not contain a ${U} at index ${X}; it has ${Q.length} ${U}s`),G(U,ee.id)},setLayout:U=>(ot.forEach(X=>{const Q=U[X==="column"?"columns":"rows"],ee=b(X);Q&&st(ee)&&mt({axisId:ee}).setLayout(Q)}),P())}},[y,b,p,S]);f.useImperativeHandle(a,()=>J,[J]);const Y=f.useRef(J);ne(()=>{Y.current=J});const se=f.useMemo(()=>({getLayout:()=>Y.current.getLayout(),getTrackById:(P,k)=>Y.current.getTrackById(P,k),getTrackByIndex:(P,k)=>Y.current.getTrackByIndex(P,k),id:p,setLayout:P=>Y.current.setLayout(P)}),[p]),ue=()=>ot.map(P=>{const k=ge(b(P)),G=x(P);return(k&&!k.defaultLayoutDeferred?G.map(X=>`minmax(0, ${k.layout[X.id]??1}fr)`):Cr(G,o?.[P==="column"?"columns":"rows"])).join(E[P]?" auto ":" ")}).join("|"),be=f.useCallback(P=>{const k=ot.map(G=>rt(b(G),P));return()=>k.forEach(G=>G())},[b]),z=f.useSyncExternalStore(be,ue,ue),[q,V]=z.split("|");return A.jsx(Eo.Provider,{value:N,children:A.jsx("div",{...m,className:t,"data-grid":!0,"data-testid":at(m,l),id:p,ref:T,style:{height:"100%",width:"100%",overflow:"hidden",...h,display:"grid",gridTemplateColumns:q,gridTemplateRows:V,touchAction:"none"},children:A.jsx(In.Provider,{value:null,children:A.jsx(_t.Provider,{value:se,children:e})})})})}const Rr=Object.assign(Ir,{displayName:"Grid"});function wo(e,t){const n=JSON.stringify(e);return f.useMemo(()=>{const o=typeof e=="number"?Array.from({length:e},(s,r)=>({id:`${r}`})):e.map((s,r)=>({...s,id:`${s.id??r}`}));return te(o.length>0,`Grid must have at least one track; "${t}" is ${n}`),o},[n])}function qt(){return()=>{}}function Lr({id:e,onlySaveAfterUserInteractions:t,storage:n=localStorage}){const o=`react-resizable-panels:grid:${e}`,s=f.useSyncExternalStore(qt,()=>n.getItem(o),()=>n.getItem(o)),r=f.useMemo(()=>{if(s)try{const a=JSON.parse(s);if(a!==null&&typeof a=="object")return a}catch{}},[s]),i=f.useCallback((a,l)=>{if(!(t&&!l.isUserInteraction))try{n.setItem(o,JSON.stringify(l.requestedLayout??a))}catch(c){console.error(c)}},[t,n,o]);return{defaultLayout:r,onLayoutChanged:i}}function Pr(){return f.useState(null)}function Mr(){return f.useRef(null)}function kr(){return f.useContext(_t)}function Er(e){for(let t=1;t<e.length;t++)if(mn(e[t-1],e[t])>0)return!1;return!0}function Dr({separator:e}){const{element:t}=e,n=f.useRef(null);return ne(()=>{const o=t.cloneNode(!0),s=[t,...t.querySelectorAll("*")],r=[o,...o.querySelectorAll("*")],i=t.ownerDocument.defaultView;return s.forEach((a,l)=>{const c=r[l],{style:u}=c;if(u){const d=i.getComputedStyle(a);for(let g=0;g<d.length;g++){const h=d.item(g);u.setProperty(h,d.getPropertyValue(h))}}c.removeAttribute("data-testid"),c.removeAttribute("id")}),Object.assign(o.style,{boxSizing:"border-box",height:"100%",margin:"0",position:"static",transform:"none",width:"100%"}),n.current.appendChild(o),()=>o.remove()},[t]),A.jsx("div",{ref:n,style:{height:"100%",opacity:.65,pointerEvents:"none",width:"100%"}})}function Ut(){const e=f.useContext(In);return te(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Or(e){const{registerOverlay:t}=Ut(),n=f.useRef(e);zn(n.current,e)||(n.current=e);const o=n.current;return ne(()=>t(o),[t,o]),null}const es=Object.assign(Or,{displayName:"SeparatorOverlay"});function Ar({active:e,orientation:t,style:n,...o}){let s;switch(t){case"horizontal":{s={height:"100%",minWidth:"1px"};break}case"vertical":{s={minHeight:"1px",width:"100%"};break}}return A.jsx("div",{...o,"data-separator-overlay":e?"active":"inactive",style:{...s,...n,flexShrink:0,pointerEvents:"none"}})}function $r({overlay:e,preview:t}){const{axis:n,offset:o,rect:s,separator:r}=t,i=n.orientation==="horizontal";let a=r?.preview,l=e;return f.isValidElement(a)&&a.type===es&&(l=a.props,a=void 0),a==null&&(l?a=A.jsx(Ar,{...l,active:t.active,orientation:n.orientation}):r&&(a=A.jsx(Dr,{separator:r}))),A.jsx("div",{"aria-hidden":"true","data-resize-preview":!0,inert:!0,style:{height:s.height,left:s.left,pointerEvents:"none",position:"absolute",top:s.top,transform:i?`translateX(${o}px)`:`translateY(${o}px)`,width:s.width},children:a})}function jr(e){return Array.from(e).sort(mn)}const Kt=f.createContext(null);function Nr(e,t){const n=f.useRef({getLayout:()=>({}),setLayout:Ys});return f.useImperativeHandle(t,()=>n.current,[]),ne(()=>{Object.assign(n.current,mt({axisId:e}))}),n}function Gr({groupId:e,resizePreviewMode:t}){const[n,o]=f.useState([]),s=f.useRef(n);return ne(()=>{const r=a=>{const l=st(e),c=t==="separator"&&a.state==="active"?a.previews.filter(d=>d.axis===l&&(d.active||!re(d.offset,0))):[],u=s.current;u.length===c.length&&c.every((d,g)=>d===u[g])||(s.current=c,o(c))};if(t!=="separator"){r(ye());return}const i=Wt(({next:a})=>r(a));return r(ye()),i},[e,t]),n}function Fr({children:e,className:t,defaultLayout:n,disableCursor:o,disabled:s,elementRef:r,groupRef:i,id:a,onLayoutChange:l,onLayoutChanged:c,orientation:u="horizontal",resizePreviewMode:d="panel",resizeTargetMinimumSize:g={coarse:20,fine:10},style:h,...m}){const p=f.useRef({onLayoutChange:{},onLayoutChanged:{}}),b=ze(W=>{Te(p.current.onLayoutChange,W)||(p.current.onLayoutChange=W,l?.(W))}),y=ze((W,N,j)=>{Te(p.current.onLayoutChanged,W)||(p.current.onLayoutChanged=W,c?.(W,{isUserInteraction:N,requestedLayout:j}))}),S=Je(a),[x,C]=f.useState(),O=Gr({groupId:S,resizePreviewMode:d}),$=f.useRef(null),[M,T]=Xo(),I=f.useRef([]),v=f.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],separators:[]}),L=Ze($,r),E=Nr(S,i),B=f.useMemo(()=>({getLayout:()=>E.current.getLayout(),id:S,orientation:u,setLayout:W=>E.current.setLayout(W)}),[S,E,u]),_=ze((W,N)=>{const j=ge(W);if(j)return{flexGrow:j.layout[N]??1};if(n?.[N])return{flexGrow:n?.[N]}}),D=Vt({defaultLayout:n,disableCursor:o,resizeTargetMinimumSize:g}),K=f.useMemo(()=>({get disableCursor(){return!!D.disableCursor},getPanelStyles:_,id:S,orientation:u,registerPanel:W=>{const N=v.current;return N.panels=ft(u,[...N.panels,W]),T(),()=>{N.panels=N.panels.filter(j=>j!==W),T()}},registerOverlay:W=>(C(W),()=>{C(void 0)}),registerSeparator:W=>{const N=v.current;return N.separators=ft(u,[...N.separators,W]),T(),()=>{N.separators=N.separators.filter(j=>j!==W),T()}},updatePanelProps:(W,{disabled:N})=>{const J=v.current.panels.find(ue=>ue.id===W);if(!J||J.constraintProps.disabled===N)return;J.constraintProps.disabled=N;const Y=st(S),se=ge(S);Y&&se&&De(Y,{...se,derivedItemConstraints:yn(Y)})},updateSeparatorProps:(W,{disabled:N,disableDoubleClick:j})=>{const Y=v.current.separators.find(se=>se.id===W);Y&&(Y.disabled=N,Y.disableDoubleClick=j)}}),[_,S,T,u,D]),H=f.useRef(null);return ne(()=>{const W=$.current;if(W===null)return;const N=v.current;N.panels=ft(u,N.panels),N.separators=ft(u,N.separators),I.current=jr([...N.panels.map(({element:V})=>V),...N.separators.map(({element:V})=>V)]);let j;if(D.defaultLayout!==void 0&&Object.keys(D.defaultLayout).length===N.panels.length){j={};for(const V of N.panels){const P=D.defaultLayout[V.id];P!==void 0&&(j[V.id]=P)}}const J={disabled:!!s,element:W,id:S,mutableState:{defaultLayout:j,disableCursor:!!D.disableCursor,expandedItemSizes:v.current.lastExpandedPanelSizes,layouts:v.current.layouts},orientation:u,items:N.panels,resizePreviewMode:d,get resizeTargetMinimumSize(){return D.resizeTargetMinimumSize},separators:N.separators};H.current=J;const Y=Ko(J),{defaultLayoutDeferred:se,derivedItemConstraints:ue,layout:be,requestedLayout:z}=ge(J.id,!0);if(!se&&ue.length>0)try{try{b(be)}finally{y(be,!1,z)}}catch(V){throw H.current=null,Y(),V}const q=rt(S,V=>{const{defaultLayoutDeferred:P,derivedItemConstraints:k,layout:G,requestedLayout:U}=V.next;if(P||k.length===0)return;Yo({derivedItemConstraints:k,axis:J,layout:G,prevLayout:V.prev?.layout,requestedLayout:U});const X=ye(),Q=X.state!=="active"||!X.hitRegions.some(ee=>ee.axis===J);try{b(G)}finally{Q&&y(G,V.isUserInteraction,U)}});return()=>{H.current=null,Y(),q()}},[s,S,y,b,u,M,d,D]),ne(()=>{Er(I.current)||T()}),f.useEffect(()=>{const W=H.current;W&&(W.mutableState.defaultLayout=n,W.mutableState.disableCursor=!!o)}),A.jsx(Kt.Provider,{value:B,children:A.jsx(In.Provider,{value:K,children:A.jsxs("div",{...m,className:t,"data-group":!0,"data-testid":at(m,a),id:S,ref:L,style:{height:"100%",width:"100%",overflow:"hidden",position:d==="separator"?"relative":void 0,...h,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:[e,O.map(W=>A.jsx($r,{overlay:x,preview:W},W.key))]})})})}const ts=Object.assign(Fr,{displayName:"Group"});function At(e,t){return`react-resizable-panels:${[e,...t].join(":")}`}function Wr({id:e,panelIds:t,storage:n}){const o=At(e,[]),s=n.getItem(o);if(s)try{const r=JSON.parse(s);if(t){const i=t.join(","),a=r[i];if(a&&Array.isArray(a.layout)&&t.length===a.layout.length){const l={};for(let c=0;c<t.length;c++)l[t[c]]=a.layout[c];return l}}else{const i=Object.keys(r);if(i.length===1){const a=r[i[0]];if(a&&Array.isArray(a.layout)){const l=i[0].split(",");if(l.length===a.layout.length){const c={};for(let u=0;u<l.length;u++)c[l[u]]=a.layout[u];return c}}}}}catch{}}function Br({debounceSaveMs:e=100,onlySaveAfterUserInteractions:t,panelIds:n,storage:o=localStorage,...s}){const r=n!==void 0,i="id"in s?s.id:s.groupId,a=At(i,n??[]),l=f.useSyncExternalStore(qt,()=>o.getItem(a),()=>o.getItem(a)),c=f.useMemo(()=>{if(l){const b=JSON.parse(l),y=Object.values(b);if(Array.from(y).every(S=>typeof S=="number"))return b}},[l]),u=f.useMemo(()=>{if(!c)return Wr({id:i,panelIds:n,storage:o})},[c,i,n,o]),d=c??u,g=f.useRef(null),h=f.useCallback(()=>{const b=g.current;b&&(g.current=null,clearTimeout(b))},[]);f.useLayoutEffect(()=>()=>{h()},[h]);const m=f.useCallback((b,y)=>{if(t&&!y.isUserInteraction)return;h();const S=y.requestedLayout??b;let x;r?x=At(i,Object.keys(S)):x=At(i,[]);try{o.setItem(x,JSON.stringify(S))}catch(C){console.error(C)}},[h,r,i,t,o]),p=f.useCallback(b=>{h(),e===0?m(b,{isUserInteraction:!1}):g.current=setTimeout(()=>{m(b,{isUserInteraction:!1})},e)},[h,e,m]);return{defaultLayout:d,onLayoutChange:p,onLayoutChanged:m}}function Hr(){return f.useState(null)}function ns(){return f.useRef(null)}function Vr(){return f.useContext(Kt)}const Yt=f.createContext(null);function _r(e,t){const{id:n}=Ut(),o=f.useRef({collapse:tn,expand:tn,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:tn});return f.useImperativeHandle(t,()=>o.current,[]),ne(()=>{Object.assign(o.current,Tn({axisId:n,itemId:e}))}),o}function qr({children:e,className:t,collapsedSize:n="0%",collapsedThreshold:o,collapsible:s=!1,defaultSize:r,disabled:i,elementRef:a,groupResizeBehavior:l="preserve-relative-size",id:c,maxSize:u="100%",minSize:d="0%",onResize:g,panelRef:h,style:m,...p}){const b=$t(c),y=Je(c),S=Vt({disabled:i}),x=f.useRef(null),C=Ze(x,a),{getPanelStyles:O,id:$,orientation:M,registerPanel:T,updatePanelProps:I}=Ut(),v=g!==null,L=ze((H,W,N)=>{g?.(H,c,N)});ne(()=>{const H=x.current;if(H!==null){const W={element:H,id:y,idIsStable:b,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:v?L:void 0,constraintProps:{groupResizeBehavior:l,collapsedSize:n,collapsedThreshold:o,collapsible:s,defaultSize:r,disabled:S.disabled,maxSize:u,minSize:d}};return T(W)}},[l,n,o,s,r,v,y,b,u,d,L,T,S]),f.useEffect(()=>{I(y,{disabled:i})},[i,y,I]);const E=_r(y,h),B=f.useMemo(()=>({collapse:()=>E.current.collapse(),expand:()=>E.current.expand(),getSize:()=>E.current.getSize(),groupId:$,id:y,isCollapsed:()=>E.current.isCollapsed(),resize:H=>E.current.resize(H)}),[$,y,E]),_=()=>{const H=O($,y);if(H)return JSON.stringify(H)},D=f.useSyncExternalStore(H=>rt($,H),_,_);let K;return D?K=JSON.parse(D):r!==void 0?K={flexGrow:void 0,flexShrink:void 0,flexBasis:r}:K={flexGrow:1},A.jsx("div",{...p,"data-disabled":i||void 0,"data-panel":!0,"data-testid":at(p,c),id:y,ref:C,style:{...Ur,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...K},children:A.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...m,touchAction:M==="horizontal"?"pan-y":"pan-x"},children:A.jsx(Yt.Provider,{value:B,children:e})})})}const os=Object.assign(qr,{displayName:"Panel"}),Ur={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function Kr(){return f.useState(null)}function Yr(){return f.useRef(null)}function Xr(){return f.useContext(Yt)}const Jr={flexBasis:"auto"},Zr={flexGrow:0,flexShrink:0};function Qr({children:e,className:t,disabled:n,disableDoubleClick:o,elementRef:s,id:r,preview:i,style:a,...l}){const c=Je(r),{disableCursor:u,id:d,orientation:g,registerSeparator:h,updateSeparatorProps:m}=Ut();return A.jsx(Jo,{attributes:l,axisId:d,axisOrientation:g,className:t,"data-testid":at(l,r),disableCursor:u,disabled:n,disableDoubleClick:o,elementRef:s,id:c,preview:i,registerSeparator:h,requiredStyle:Zr,style:a,styleDefaults:Jr,updateSeparatorProps:m,children:e})}const ss=Object.assign(Qr,{displayName:"Separator"});function rs(){try{return process.env.NODE_ENV!=="production"}catch{return!1}}const zo=new Set;function Ie(e){rs()&&!zo.has(e)&&(zo.add(e),console.warn(`react-resizable-panels: ${e}`))}const lt=f.createContext(null),Rn=f.createContext(null);function is(e){return e.type==="split"?{...e,children:e.children.map(is)}:{...e,tabs:e.tabs.map(t=>({...t}))}}function Le(e){return{...e,root:is(e.root)}}function ut(e){return e.type==="tabset"?[e]:e.children.flatMap(t=>ut(t))}function Xe(e,t){return ut(e.root).find(({tabs:n})=>n.some(({id:o})=>o===t))}function it(e,t){return Xe(e,t)?.tabs.find(({id:n})=>n===t)}function ei(e){const t=new Set,n=r=>{r.id!==void 0&&t.add(r.id),r.type==="split"&&r.children.forEach(n)};n(e);const o=(r,i)=>{if(r.id!==void 0)return r.id;const a=`${r.type}-${i.length>0?i.join("-"):"root"}`;let l=a,c=1;for(;t.has(l);)c++,l=`${a}-${c}`;return t.add(l),l},s=(r,i)=>r.type==="split"?{...r,children:r.children.map((a,l)=>s(a,[...i,l])),id:o(r,i)}:{...r,id:o(r,i),tabs:r.tabs.map(a=>({...a}))};return s(e,[])}function as(e,t){if(e.type==="tabset"){if(e.tabs.some(({id:r})=>r===e.selectedId)||(e.selectedId=e.tabs[0]?.id),e.collapsible||delete e.collapsed,e.recentTabIds!==void 0){const r=Array.isArray(e.recentTabIds)?e.recentTabIds.filter((i,a,l)=>l.indexOf(i)===a&&e.tabs.some(c=>c.id===i)):[];r.length>0?e.recentTabIds=r:delete e.recentTabIds}return e.tabs.length>0||t||e.keepWhenEmpty?e:null}const n=[];for(const r of e.children){const i=as(r,!1);if(i!==null)if(i.type==="split"&&i.orientation===e.orientation)for(const a of i.children)n.push({...a,size:typeof a.size=="number"&&typeof i.size=="number"?a.size*i.size/100:void 0});else n.push(i)}if(n.length===0)return null;if(n.length===1)return{...n[0],size:e.size};const o=r=>r.type==="tabset"&&!!r.collapsed;n.every(o)&&delete n[n.length-1].collapsed;const s=n.filter(r=>!o(r));if(s.every(({size:r})=>typeof r=="number")){const r=s.reduce((i,{size:a})=>i+a,0);if(r>0)for(const i of s)i.size=i.size/r*100}return{...e,children:n}}function ti(e){const t=new Set,n=s=>{t.has(s)&&Ie(`Duplicate id found in workspace model: "${s}"`),t.add(s)},o=s=>{n(s.id),s.type==="split"?s.children.forEach(o):s.tabs.forEach(({id:r})=>n(r))};o(e)}function Se(e){e.version!==1&&Ie(`Unsupported workspace model version: ${e.version}`);const t=ei(e.root),n=as(t,!0)??{id:t.id,tabs:[],type:"tabset"};n.type==="tabset"&&delete n.collapsed,rs()&&ti(n);const o={root:n,version:1};return e.maximizedTabsetId!==void 0&&n.type==="split"&&ut(n).some(({id:s})=>s===e.maximizedTabsetId)&&(o.maximizedTabsetId=e.maximizedTabsetId),o}function cs(e,t){const n=e.recentTabIds?.find(s=>s!==t&&e.tabs.some(r=>r.id===s));if(n!==void 0)return n;const o=e.tabs.findIndex(({id:s})=>s===t);return(e.tabs[o+1]??e.tabs[o-1])?.id}function cn(e,t){const n=e.tabs.findIndex(({id:o})=>o===t);n<0||(e.selectedId===t&&(e.selectedId=cs(e,t)),e.tabs.splice(n,1))}function Ln(e,t){if(!it(e,t))return e;const n=Le(e),o=Xe(n,t);return o&&cn(o,t),Se(n)}function Nt(e,t){return t[e.id]??!!e.collapsed}const ls=f.createContext(null);function us(e){const t=f.useContext(ls),n=f.useRef(null),o=()=>{const s=t?e(t.getState()):null,r=n.current;return r&&(r.value===s||r.value!==null&&s!==null&&zn(r.value,s))?r.value:(n.current={value:s},s)};return f.useSyncExternalStore(t?.subscribe??qt,o,o)}function ds(){const t=f.useContext(lt)?.id;return us(({collapseOverrides:n,disabled:o,model:s,modelIndex:r})=>{const i=t!==void 0?r.tabsetsByTabId.get(t):void 0,a=i?.tabs.find(({id:u})=>u===t);if(!i||!a)return null;const l=i.selectedId===a.id,c=s.maximizedTabsetId;return{isCloseDisabled:o||!!a.disableClose,isDragDisabled:o||!!a.disableDrag,isSelected:l,isVisible:l&&(c===void 0?!Nt(i,n):c===i.id),tabsetId:i.id}})}function ni({"aria-label":e,children:t="×",onClick:n,...o}){const s=f.useContext(Rn),r=f.useContext(lt),i=ds();if(!s||!r)Ie("TabCloseButton must be rendered within a tab (see renderTab)");else if(i?.isCloseDisabled)return null;const a=r?s?.modelIndex.tabsetsByTabId.get(r.id)?.tabs.find(({id:l})=>l===r.id):void 0;return A.jsx("button",{"aria-label":e??`Close ${a?.title??a?.id??"tab"}`,tabIndex:-1,type:"button",...o,onClick:l=>{n?.(l),!l.defaultPrevented&&s&&r&&s.updateModel("close",!0,c=>Ln(c,r.id))},children:t})}const fs=Object.assign(ni,{displayName:"TabCloseButton"}),dt=f.createContext(null);function Pn(e,t){return!!t.collapsible&&!!e&&e.children.some(n=>n.id!==t.id&&!(n.type==="tabset"&&n.collapsed))}function Mn(e,t,n){return n||!!t.disableDrag||t.tabs.some(({disableDrag:o})=>o)||e.root.id===t.id||e.maximizedTabsetId!==void 0}function ps(){const t=f.useContext(dt)?.id;return us(({activeTabsetId:n,collapseOverrides:o,collapseToFit:s,disabled:r,model:i,modelIndex:a})=>{const l=t!==void 0?a.tabsetsById.get(t):void 0;return l?{isActive:n===l.id,isCollapsed:Nt(l,o),isCollapsedToFit:Nt(l,o)&&s[l.id]===!0,isCollapsible:!!l.collapsed||Pn(a.parentsById.get(l.id),l),isDragDisabled:Mn(i,l,r),isMaximized:i.maximizedTabsetId===l.id,isRoot:i.root.id===l.id,selectedTabId:l.selectedId}:null})}function oi({style:e,...t}){const n=f.useContext(dt),o=ps();n||Ie("TabsetDragHandle must be rendered within a tabset's header (see renderTabsetToolbar)");const s=o?.isDragDisabled??!0;return A.jsx("div",{"data-disabled":s||void 0,"data-tabset-drag-handle":"",...t,style:s?e:{touchAction:"none",...e}})}const si=Object.assign(oi,{displayName:"TabsetDragHandle"});function ri(){return f.useContext(lt)}function ii(){return f.useContext(dt)}const kn=f.createContext(null);function ai(){return f.useContext(kn)}function ci(){const e=f.useContext(kn),t=f.useContext(dt)?.id,n=f.useCallback(s=>e&&t!==void 0?e.subscribeToTabListFreeSpace(t,s):()=>{},[t,e]),o=()=>e&&t!==void 0?e.getTabListFreeSpace(t):void 0;return f.useSyncExternalStore(n,o,li)}function li(){}function ui(){return f.useState(null)}function di(){return f.useRef(null)}function fi(e,{getChromeSize:t,getCollapsedSize:n,getContentMaximumSize:o,getSeparatorsSize:s}){const r=new Map,i=new Map,a=c=>{let u;if(c.type==="tabset"){const d=o(c),g=t(c.id)??{height:0,width:0};r.set(c.id,d),u={height:d.height+g.height,width:d.width+g.width}}else{const d=c.children.map(p=>{const b=a(p);if(p.type!=="tabset"||!p.collapsed)return b;const y=n(p.id)??0;return c.orientation==="horizontal"?{...b,width:y}:{...b,height:y}}),g=s(c.id)??0,h=p=>d.reduce((b,y)=>b+y[p],0)+g,m=p=>Math.min(...d.map(b=>b[p]));u=c.orientation==="horizontal"?{height:m("height"),width:h("width")}:{height:h("height"),width:m("width")}}return i.set(c.id,u),u},l=(c,u)=>{const d=i.get(c.id);if(c.type==="tabset"){const g=r.get(c.id);for(const h of["height","width"])!u[h]&&Number.isFinite(g[h])&&Ie(`Tabset "${c.id}" can't be limited to its ${h==="height"?"maxHeight":"maxWidth"}, since nothing else can take up the rest of the space (e.g. every other tabset in its split has a maximum ${h}, or it fills the workspace)`)}else{const g=c.orientation==="horizontal"?"width":"height",h=g==="width"?"height":"width",m=c.children.filter(p=>!(p.type==="tabset"&&p.collapsed)&&!Number.isFinite(i.get(p.id)[g])).map(({id:p})=>p);for(const p of c.children){const b=m.some(y=>y!==p.id);l(p,{[g]:b||u[g],[h]:u[h]})}}i.set(c.id,{height:u.height?d.height:1/0,width:u.width?d.width:1/0})};return a(e),l(e,{height:!1,width:!1}),i}function pi(e,{getChromeSize:t,getCollapsedSize:n,getContentMinimumSize:o,getSeparatorsSize:s}){const r=new Map,i=a=>{let l;if(a.type==="tabset"){const c=o(a),u=t(a.id)??{height:0,width:0};l={height:c.height+u.height,width:c.width+u.width}}else{const c=a.children.map(h=>{const m=i(h);if(h.type!=="tabset"||!h.collapsed)return m;const p=n(h.id)??0;return a.orientation==="horizontal"?{height:0,width:p}:{height:p,width:0}}),u=s(a.id)??0,d=h=>c.reduce((m,p)=>m+p[h],0)+u,g=h=>Math.max(0,...c.map(m=>m[h]));l=a.orientation==="horizontal"?{height:g("height"),width:d("width")}:{height:d("height"),width:g("width")}}return r.set(a.id,l),l};return i(e),r}function mi(){const e=new Map,t=new Map,n=new Map,o=(s,r)=>{if(e.get(s)===r)return;r===void 0?e.delete(s):e.set(s,r);const i=t.get(s);if(!i)return;let a;for(const l of Array.from(i))try{l(r)}catch(c){a??={error:c}}if(a)throw a.error};return{get:s=>e.get(s),retain:s=>(n.set(s,(n.get(s)??0)+1),()=>{n.set(s,n.get(s)-1),queueMicrotask(()=>{n.get(s)||(n.delete(s),o(s,void 0))})}),set:o,subscribe:(s,r)=>{let i=t.get(s);return i||(i=new Set,t.set(s,i)),i.add(r),()=>{i.delete(r),i.size===0&&t.get(s)===i&&t.delete(s)}}}}function hi(e){const t=new fn;let n=e,o=e;return{getState:()=>o,notify:()=>{n!==o&&(n=o,t.emit("change",void 0))},setState:s=>{o=s},subscribe:s=>t.addListener("change",s)}}function le(e,t){return ut(e.root).find(({id:n})=>n===t)}function Gt(e,t){const n=Xe(e,t);if(!n||n.selectedId===t)return e;const o=Le(e),s=Xe(o,t);return s&&(s.selectedId=t),o}function gi(e,t,{index:n,select:o=!0,tabsetId:s}={}){if(it(e,t.id))return{added:!1,model:Gt(e,t.id)};const r=Le(e);let i=le(r,s);i||(s!==void 0&&Ie(`Tabset "${s}" not found in workspace model; adding tab to the first tabset instead`),i=ut(r.root)[0]);const a=n===void 0?i.tabs.length:Math.max(0,Math.min(n,i.tabs.length));return i.tabs.splice(a,0,{...t}),(o||i.selectedId===void 0)&&(i.selectedId=t.id),{added:!0,model:Se(r)}}function bi(e,t){if(!le(e,t))return e;const n=Le(e),o=le(n,t);return o&&(o.tabs=[],o.selectedId=void 0,delete o.keepWhenEmpty),Se(n)}function yt(e,t){if(e.type==="split")for(const n of e.children){if(n.id===t)return e;const o=yt(n,t);if(o)return o}}function yi(e,t){const n=le(e,t);if(!n||n.collapsed||!Pn(yt(e.root,t),n))return e;const o=Le(e),s=le(o,t);return s&&(s.collapsed=!0),Se(o)}function vt(e,t){if(!le(e,t)?.collapsed)return e;const n=Le(e),o=le(n,t);if(!o)return e;delete o.collapsed;const s=o.size,r=yt(n.root,t)?.children.filter(i=>i!==o&&!(i.type==="tabset"&&i.collapsed))??[];if(typeof s=="number"&&s<100&&r.every(i=>typeof i.size=="number"))for(const i of r)i.size=i.size*(100-s)/100;return Se(n)}function vi(e){return ut(e).flatMap(t=>t.tabs)}function ms(e){return ln(e)&&hs(e.root)}function ln(e){return typeof e=="object"&&e!==null}function Co(e){return e===void 0||typeof e=="string"}function hs(e){if(!ln(e)||!Co(e.id))return!1;switch(e.type){case"split":return(e.orientation==="horizontal"||e.orientation==="vertical")&&Array.isArray(e.children)&&e.children.every(hs);case"tabset":return Array.isArray(e.tabs)&&e.tabs.every(t=>ln(t)&&typeof t.id=="string"&&Co(t.title));default:return!1}}function To(e){return ms(e)?e:(Ie("Invalid workspace model; using an empty workspace instead"),{root:{tabs:[],type:"tabset"},version:1})}function Si(e){const t={nodeIds:new Set,parentsById:new Map,tabsetsById:new Map,tabsetsByTabId:new Map},n=o=>{if(t.nodeIds.add(o.id),o.type==="tabset"){t.tabsetsById.set(o.id,o);for(const s of o.tabs)t.tabsetsByTabId.set(s.id,o)}else for(const s of o.children)t.parentsById.set(s.id,o),n(s)};return n(e.root),t}function xi(e,t){return e.maximizedTabsetId===t||e.root.id===t||!le(e,t)?e:{...e,maximizedTabsetId:t}}function gs(){return Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,"0")).join("")}function wi(e,t){return{id:gs(),selectedId:e[0]?.id,size:t,tabs:e,type:"tabset"}}function bs(e,t,n,o){const s=o==="left"||o==="right"?"horizontal":"vertical",r=o==="left"||o==="top",i=yt(e,t.id);if(i&&i.orientation===s){const l=i.children.indexOf(t);return typeof t.size=="number"?(t.size/=2,n.size=t.size):n.size=void 0,i.children.splice(r?l:l+1,0,n),e}const a={children:r?[n,t]:[t,n],id:gs(),orientation:s,size:t.size,type:"split"};return t.size=50,n.size=50,i?(i.children[i.children.indexOf(t)]=a,e):a}function Io(e,t,n){const o=Le(e),s=Xe(o,t),r=le(o,n.tabsetId);if(!s||!r)return e;const i=s.tabs.findIndex(({id:l})=>l===t),a=s.tabs[i];if("index"in n||n.region==="center"){let l="index"in n?Math.max(0,Math.min(n.index,r.tabs.length)):r.tabs.length;if(s===r&&(l>i&&l--,l===i&&r.selectedId===t))return e;if(cn(s,t),r.tabs.splice(l,0,a),r.selectedId=a.id,r.collapsed&&s!==r)return vt(Se(o),r.id)}else{if(s===r&&s.tabs.length===1&&!s.keepWhenEmpty)return e;cn(s,t),o.root=bs(o.root,r,wi([a]),n.region),o.maximizedTabsetId===r.id&&(o.maximizedTabsetId=void 0)}return Se(o)}function Ro(e,t,n){const o=Le(e),s=le(o,t),r=le(o,n.tabsetId);if(!s||!r||s===r)return e;if("index"in n||n.region==="center"){if(s.tabs.length===0)return e;const i="index"in n?Math.max(0,Math.min(n.index,r.tabs.length)):r.tabs.length;if(r.tabs.splice(i,0,...s.tabs),r.selectedId=s.selectedId??s.tabs[0].id,s.recentTabIds&&(r.recentTabIds=[...r.recentTabIds??[],...s.recentTabIds]),s.tabs=[],s.selectedId=void 0,r.collapsed)return vt(Se(o),r.id)}else{const i=yt(o.root,s.id);if(!i)return e;delete s.collapsed,i.children.splice(i.children.indexOf(s),1),o.root=bs(o.root,r,s,n.region),o.maximizedTabsetId===r.id&&(o.maximizedTabsetId=void 0)}return Se(o)}function zi(e){if(e.maximizedTabsetId===void 0)return e;const t={...e};return delete t.maximizedTabsetId,t}function Ci(e,t,n){if(!it(e,t))return e;const o=Le(e),s=it(o,t);return s&&Object.assign(s,n),o}function nn(e,t){const n=ys(e.root,t);return n===e.root?e:{...e,root:n}}function ys(e,t){if(e.type==="split"){const s=e.children.map(r=>ys(r,t));return s.every((r,i)=>r===e.children[i])?e:{...e,children:s}}const n=e.recentTabIds,o=e.selectedId;if(t==="adjacent"||o===void 0){if(n===void 0)return e;const{recentTabIds:s,...r}=e;return r}return n?.[0]===o?e:{...e,recentTabIds:[o,...(n??[]).filter(s=>s!==o)]}}function Ti(e,t,n){if(!le(e,t))return e;const o=Le(e),s=le(o,t);return s&&Object.assign(s,n),Se(o)}const vs=f.createContext(null);function Qe(e){const t=f.useContext(Rn);return te(t,`${e} must be rendered within a Workspace`),t}function Xt(e){const t=f.useContext(vs);return te(t,`${e} must be rendered within a tabset`),t}const Ii=f.memo(function({render:t,tab:n}){return t(n)},(e,t)=>e.render===t.render&&e.tab.id===t.tab.id&&e.tab.data===t.tab.data&&e.tab.title===t.tab.title&&e.tab.disableClose===t.tab.disableClose&&e.tab.disableDrag===t.tab.disableDrag),Ri=Object.assign(Ii,{displayName:"Workspace.MemoizedContent"});function Li({hiddenTabBehavior:e,renderTabContent:t,tab:n}){const{classNames:o,getTabHandle:s,getTabHost:r,getTabsetHandle:i,modelIndex:a,styles:l}=Qe("TabContent"),c=a.tabsetsByTabId.get(n.id);if(!c)return null;const u=c.selectedId===n.id;let d=null;if((e!=="unmount"||u)&&(d=A.jsx(Ri,{render:t,tab:n}),e==="activity")){const m=Ns.Activity;m?d=A.jsx(m,{mode:u?"visible":"hidden",children:d}):Ie('hiddenTabBehavior "activity" requires React 19.2 or newer; falling back to "keep-mounted"')}const{panelId:g,tabElementId:h}=r(n.id);return A.jsx("div",{"aria-labelledby":h,className:o?.tabContent,"data-tab-content":"",id:g,role:"tabpanel",style:l?.tabContent,children:A.jsx(dt.Provider,{value:i(c.id),children:A.jsx(lt.Provider,{value:s(n.id),children:d})})})}const Ss=Object.assign(Li,{displayName:"Workspace.TabContent"}),Lo=new WeakMap;function xs(e,t){if(!e)return;let n=Lo.get(e);if(!n){const{margin:r,translate:i}=e.style;e.style.margin="0",e.style.transform="none",e.style.translate="none";const a=e.getBoundingClientRect();n={scaleX:Ae(e,"horizontal"),scaleY:Ae(e,"vertical"),x:a.left,y:a.top},Lo.set(e,n),e.style.margin=r,e.style.translate=i}const o=(t.clientX-n.x)/n.scaleX,s=(t.clientY-n.y)/n.scaleY;e.style.transform=`translate(${o}px, ${s}px)`}function Ft(e,t){return Array.from(e.querySelectorAll(t)).find(n=>n.closest("[data-tabset-id]")===e)}const Pi=.25;function ws(e,t,n){const o=e.width>0?(t-e.left)/e.width:.5,s=e.height>0?(n-e.top)/e.height:.5,r={bottom:1-s,left:o,right:1-o,top:s},i=Object.keys(r).reduce((a,l)=>r[l]<r[a]?l:a,"left");return r[i]<Pi?i:"center"}function zs(e,t,n){const o=e.dataset.orientation==="vertical",s=Array.from(e.querySelectorAll("[data-tab]")).filter(i=>i.closest("[data-tab-list]")===e),r=s.findIndex(i=>{const a=i.getBoundingClientRect();return o?n<a.top+a.height/2:t<a.left+a.width/2});return r===-1?s.length:r}function Mi({clientX:e,clientY:t,model:n,rootElement:o,source:s}){const r=o.getRootNode(),i=(Bo(r)?r:o.ownerDocument).elementFromPoint(e,t);if(!i||!o.contains(i))return;let a=i.closest("[data-tabset-id]");for(;a&&a.closest("[data-workspace]")!==o;)a=a.parentElement?.closest("[data-tabset-id]")??null;const l=a?.dataset.tabsetId,c=le(n,l);if(!a||!c||n.maximizedTabsetId!==void 0&&n.maximizedTabsetId!==c.id)return;if(s.type==="tabset")return ki({clientX:e,clientY:t,element:i,model:n,sourceTabsetId:s.tabsetId,tabsetElement:a,tabsetId:c.id});const u=Ft(a,"[data-tab-list]");if(u?.contains(i))return{index:zs(u,e,t),tabsetId:c.id};const d=Ft(a,"[data-tab-panels]");if(d?.contains(i)){const g=c.tabs.some(({id:p})=>p===s.tabId),m=!!c.keepWhenEmpty||!(c.tabs.length===1&&g)?ws(d.getBoundingClientRect(),e,t):"center";return m==="center"&&g?void 0:{region:m,tabsetId:c.id}}}function ki({clientX:e,clientY:t,element:n,model:o,sourceTabsetId:s,tabsetElement:r,tabsetId:i}){if(i===s)return;const a=!!le(o,s)?.keepWhenEmpty,l=Ft(r,"[data-tab-list]");if(l?.contains(n))return a?void 0:{index:zs(l,e,t),tabsetId:i};const c=Ft(r,"[data-tab-panels]");if(c?.contains(n)){const u=ws(c.getBoundingClientRect(),e,t);return u==="center"&&a?void 0:{region:u,tabsetId:i}}}function Ei(e,t){return e===void 0||t===void 0?e===t:e.tabsetId!==t.tabsetId?!1:"index"in e&&"index"in t?e.index===t.index:"region"in e&&"region"in t?e.region===t.region:!1}const Di=5;function Oi({getModel:e,getRootElement:t,isDropDisabled:n,onDrop:o}){const[s,r]=f.useState(),[i,a]=f.useState(),l=f.useRef(null),c=f.useRef({clientX:0,clientY:0}),u=f.useRef(null);f.useEffect(()=>()=>u.current?.(),[]);const d=f.useCallback((m,p)=>{const b=t();if(!b)return;const y=ye();if(y.state==="active"&&bt(y,p.currentTarget.ownerDocument,p))return;u.current?.();const S=p.currentTarget,x=S.ownerDocument,{clientX:C,clientY:O,pointerId:$}=p;S.setPointerCapture?.($);let M=!1,T,I;const v={cursor:x.documentElement.style.cursor,sourceCursor:S.style.cursor,userSelect:x.body.style.userSelect},L=N=>{x.documentElement.style.cursor=N??v.cursor,S.style.cursor=N??v.sourceCursor},E=N=>{if(N.pointerId!==$)return;const{clientX:j,clientY:J}=N;if(!M){if(Math.hypot(j-C,J-O)<Di)return;M=!0,x.body.style.userSelect="none",r(m)}c.current={clientX:j,clientY:J},xs(l.current,c.current);const Y=Mi({clientX:j,clientY:J,model:e(),rootElement:b,source:m});if(!Ei(I,Y)){I=Y;const se=Y!==void 0&&n(m,Y);T=se?void 0:Y,L(se?"not-allowed":void 0),a(T)}},B=(N,{isPointerDown:j=!1}={})=>{if(u.current=null,x.removeEventListener("pointermove",E),x.removeEventListener("pointerup",_),x.removeEventListener("pointercancel",D),x.removeEventListener("keydown",K,!0),H?.removeEventListener("blur",W),M){if(x.body.style.userSelect=v.userSelect,L(void 0),r(void 0),a(void 0),j){const J=Y=>{Y.pointerId===$&&(x.removeEventListener("pointerup",J),x.removeEventListener("pointercancel",J),an(x))};x.addEventListener("pointerup",J),x.addEventListener("pointercancel",J)}else an(x);N&&T&&o(m,T)}},_=N=>{N.pointerId===$&&B(!0)},D=N=>{N.pointerId===$&&B(!1)},K=N=>{N.key==="Escape"&&(M&&(N.preventDefault(),N.stopPropagation()),B(!1,{isPointerDown:!0}))},H=x.defaultView,W=()=>B(!1);u.current=()=>B(!1),x.addEventListener("pointermove",E),x.addEventListener("pointerup",_),x.addEventListener("pointercancel",D),x.addEventListener("keydown",K,!0),H?.addEventListener("blur",W)},[e,t,n,o]),g=f.useCallback((m,p)=>d({tabId:m,type:"tab"},p),[d]),h=f.useCallback((m,p)=>d({tabsetId:m,type:"tabset"},p),[d]);return{dragSource:s,dropTarget:i,previewElementRef:l,previewPointRef:c,startTabDrag:g,startTabsetDrag:h}}function un(e,t){if(e.type==="split"){if(e.id===t)return e;for(const n of e.children){const o=un(n,t);if(o)return o}}}function Ai(e,t,n,o,s){const r=un(e.root,t);if(!r||r.children.length!==Object.keys(n).length||r.children.some(({id:c})=>n[c]===void 0))return e;const i=Le(e),a=un(i.root,t);if(!a)return e;let l=!1;for(const c of a.children){if(s?.has(c.id))continue;const u=c.type==="tabset"&&(o?o.has(c.id):!!c.collapsed);c.type==="tabset"&&u!==!!c.collapsed&&(l=!0,u?c.collapsed=!0:delete c.collapsed),u||(c.size=n[c.id]??c.size)}return l||(s?.size??0)>0||a.children.some(c=>c.type==="tabset"&&c.collapsed)?Se(i):i}function Po(e,t,n){const o=Vo(e.map(l=>{const c=n[l.itemId];return typeof c=="number"?{...l,defaultSize:c}:l}));let s=0;const r=[];for(const l of e)t.has(l.itemId)?s+=l.collapsedSize:r.push(l);const i=$i(r.map(({itemId:l,maxSize:c,minSize:u})=>({maxSize:c,minSize:u,weight:o[l]})),Math.max(0,100-s)),a={};for(const{collapsedSize:l,itemId:c}of e)a[c]=fe(t.has(c)?l:i[r.findIndex(u=>u.itemId===c)]);return a}function $i(e,t){const n=(i,a)=>{const l=i.reduce((c,u)=>c+u,0);return i.map(c=>l>0?c/l*a:a/i.length)},o=new Map;for(;o.size<e.length;){const i=e.map((g,h)=>({...g,index:h})).filter(({index:g})=>!o.has(g)),a=t-Array.from(o.values()).reduce((g,h)=>g+h,0),l=n(i.map(({weight:g})=>g),a);let c=0;const u=[];if(i.forEach(({index:g,maxSize:h,minSize:m},p)=>{const b=l[p],y=Math.min(h,Math.max(m,b));y!==b&&(c+=y-b,u.push({index:g,isMinimum:y>b,size:y}))}),u.length===0){i.forEach(({index:g},h)=>o.set(g,l[h]));break}let d=0;for(const{index:g,isMinimum:h,size:m}of u)(c===0||c>0===h)&&(o.set(g,m),d++);if(d===0)for(const{index:g,size:h}of u)o.set(g,h)}const s=e.map((i,a)=>o.get(a)),r=s.reduce((i,a)=>i+a,0);return Math.abs(r-t)>.001?n(e.map(({weight:i})=>i),t):s}function ji(e,t){let n=!1;for(const o of e){if(o.type!=="tabset")continue;const s=t.has(o.id);if(s!==!!o.collapsed){if(!s)return"expand";n=!0}}return n?"collapse":"resize"}function Ni({split:e}){const{classNames:t,collapsedSizes:n,collapseToFit:o,disabled:s,id:r,maximumSizes:i,minimumSizes:a,renderSeparator:l,reportCollapsePreview:c,reportCollapseToFit:u,reportSeparatorsSize:d,resizePreviewMode:g,splitGeneration:h,styles:m,updateModel:p}=Qe("SplitView"),b=`${r}-${e.id}`,y=z=>`${r}:${z}`,S=ns(),[x,C]=f.useState(null),O=f.useRef(null),$=f.useCallback(z=>{O.current=z,C(z)},[]),M=()=>{const z=O.current;return z?e.orientation==="horizontal"?z.offsetWidth:z.offsetHeight:0},T=e.children.map(({id:z})=>z).join(),I=e.children.map(({id:z})=>y(z)).join(),v=new Set(e.children.filter(z=>z.type==="tabset"&&z.collapsed).map(({id:z})=>y(z))),L=e.children.filter(z=>z.type==="tabset"&&z.collapsed).map(({id:z})=>`${z}=${n[z]??0}`).join(),E=`${h}:${e.orientation}:${T}:${L}`,B=f.useRef(null),[,_]=f.useState(0),D=()=>{const z=ge(b);return!z||z.defaultLayoutDeferred||z.derivedItemConstraints.map(({itemId:q})=>q).join()!==I?null:`${E}|${z.derivedItemConstraints.filter(({itemId:q})=>v.has(q)).map(({collapsedSize:q})=>q).join()}`},K=()=>{const z={};for(const q of e.children)z[y(q.id)]=q.size;return z},H=z=>{const q=ge(b)?.derivedItemConstraints??[],V=new Set;for(const{id:P}of e.children){const k=y(P),G=q.find(({itemId:U})=>U===k);G?.collapsible&&z[k]!==void 0&&z[k]<=G.collapsedSize+.01&&V.add(P)}return V},W=(z,q)=>{const V=H(z),P={};for(const k of e.children)if(k.type==="tabset"){const G=V.has(k.id);P[k.id]=q||G!==!!k.collapsed?G:void 0}return P},N=()=>{const z=ye();return z.state==="active"&&z.hitRegions.some(q=>q.axis.id===b)},j=ze(z=>c(W(z,!0))),J=z=>{N()||u(W(z,!1))},Y=f.useRef(null),se=f.useRef(null),ue=ze(()=>{const z=D();if(z===null||B.current!==z||N())return;const q=M(),V=se.current;if(se.current=q,V===null||V===q)return;const{derivedItemConstraints:P,layout:k}=ge(b),G=Po(P,v,K()),U=H(k);e.children.some(Q=>{const ee=y(Q.id);return Q.type==="tabset"&&U.has(Q.id)!==!!Q.collapsed||typeof Q.size=="number"&&!re(k[ee],G[ee],.01)})&&S.current?.setLayout(G)}),be=e.children.some(z=>z.type==="tabset"&&z.collapsible);return f.useEffect(()=>rt(b,({axis:z,next:q,prev:V})=>{V?.derivedItemConstraints!==q.derivedItemConstraints&&(ue(),be&&_(k=>k+1));const P=ye();be&&P.state==="active"&&P.hitRegions.some(k=>k.axis===z)&&j(q.layout)}),[ue,b,be,j]),ne(()=>{const z=D();if(z===null||(B.current!==z&&(B.current=z,S.current?.setLayout(Po(ge(b).derivedItemConstraints,v,K())),se.current=M()),N()))return;const{derivedItemConstraints:q}=ge(b),V=Y.current,P=M(),{layout:k}=ge(b);(V?.constraints!==q||V.layout!==k||V.size!==P||V.structureKey!==E)&&(Y.current={constraints:q,layout:k,size:P,structureKey:E},J(k))}),ne(()=>{const z=x?.ownerDocument.defaultView;if(!x||!z)return;const q=G=>Oe(G)&&G.hasAttribute("data-separator"),V=()=>{let G=0,U=0;const X=z.getComputedStyle(x),Q=parseFloat(e.orientation==="horizontal"?X.columnGap:X.rowGap)||0;for(const ee of x.children)if(Oe(ee)&&ee.hasAttribute("data-panel")&&U++,q(ee))if(U++,"offsetWidth"in ee){const{offsetHeight:de,offsetWidth:xe}=ee;G+=e.orientation==="horizontal"?xe:de}else{const de=ee.getBoundingClientRect();G+=e.orientation==="horizontal"?de.width:de.height}G+=Q*Math.max(0,U-1),d(e.id,G)},P=z.ResizeObserver?new z.ResizeObserver(V):null;P?.observe(x);for(const G of x.children)q(G)&&P?.observe(G);const k=z.MutationObserver?new z.MutationObserver(G=>{for(const U of G)U.addedNodes.forEach(X=>{q(X)&&P?.observe(X)}),U.removedNodes.forEach(X=>{q(X)&&P?.unobserve(X)});V()}):null;return k?.observe(x,{childList:!0}),V(),()=>{P?.disconnect(),k?.disconnect()}},[t?.split,x,d,e.id,e.orientation,m?.split]),A.jsx(ts,{className:t?.split,"data-split":"","data-split-id":e.id,disabled:s,elementRef:$,groupRef:S,id:b,onLayoutChanged:(z,{isUserInteraction:q,requestedLayout:V})=>{if(q){const P=V??z,k={};for(const{id:Q}of e.children){const ee=P[y(Q)];ee!==void 0&&(k[Q]=ee)}const G=H(z),U=new Set;for(const Q of G)o[Q]===!0&&(G.delete(Q),U.add(Q));const X=ji(e.children,G);p(X,!0,Q=>Ai(Q,e.id,k,G,U))}else{const P=D();P!==null&&B.current===P?J(z):_(k=>k+1)}},orientation:e.orientation,resizePreviewMode:g,style:m?.split,children:e.children.map((z,q)=>{const V=a.get(z.id),P=e.orientation==="horizontal"?V?.width:V?.height,k=i.get(z.id),G=e.orientation==="horizontal"?k?.width:k?.height;return A.jsxs(f.Fragment,{children:[q>0&&(l?l(e.orientation):A.jsx(ss,{})),A.jsx(os,{collapsedSize:z.type==="tabset"&&z.collapsible?`${n[z.id]??0}px`:void 0,collapsible:z.type==="tabset"&&(!!z.collapsed||Pn(e,z)),defaultSize:typeof z.size=="number"?`${z.size}%`:z.size,id:y(z.id),maxSize:G!==void 0&&Number.isFinite(G)?`${Math.max(G,P??0)}px`:void 0,minSize:P||void 0,children:A.jsx(Rs,{node:z})})]},z.id)})})}const Gi=Object.assign(Ni,{displayName:"Workspace.SplitView"}),Cs=f.createContext({isOverflowing:!1,orientation:"horizontal"}),Fi='button, [role="button"], [data-tab-ignore]';function on(e){const t=e.target.closest?.(Fi);return!!t&&t!==e.currentTarget&&e.currentTarget.contains(t)}function Wi({tab:e}){const{classNames:t,disabled:n,dragTabId:o,dropTarget:s,getTabHandle:r,getTabHost:i,modelIndex:a,renderTab:l,requestFocus:c,startTabDrag:u,styles:d,takeFocusRequest:g,updateModel:h}=Qe("Tab"),{isCollapsed:m,tabPlacement:p,tabset:b}=Xt("Tab"),{isOverflowing:y,orientation:S}=f.useContext(Cs),x=f.useRef(null),C=f.useCallback(j=>{x.current=j},[]),O=a.tabsetsByTabId.get(e.id)??b,$=O.tabs.findIndex(({id:j})=>j===e.id),M=O.tabs[$]??e,T=O.selectedId===M.id,I=n||!!M.disableClose,v=n||!!M.disableDrag;let L=d?.tab?.touchAction;v||(y?L=S==="horizontal"?"pan-x":"pan-y":L="none");const E=s!==void 0&&"index"in s&&s.tabsetId===O.id,B=E&&s.index===$,_=E&&s.index===O.tabs.length&&$===O.tabs.length-1;ne(()=>{g(M.id)&&x.current?.focus()}),ne(()=>{const j=x.current;j?!v&&"touchAction"in j.style&&j.style.touchAction!==L&&Ie("The element returned by renderTab replaced props.style (rather than merging it, e.g. style={{ ...props.style, padding: 4 }}); tabs can't be dragged by touch without its touch-action"):Ie("The element returned by renderTab must receive its props (including ref); otherwise tabs can't be selected, dragged, or focused")},[v,L]);const{panelId:D,tabElementId:K}=i(M.id),H=()=>m&&O.collapsed?h("expand",!0,j=>vt(Gt(j,M.id),O.id)):h("select",!0,j=>Gt(j,M.id)),W=j=>{if(j.target!==j.currentTarget)return;const J=j.currentTarget.closest("[data-tab-list]"),Y=J?Array.from(J.querySelectorAll("[data-tab]")).filter(q=>q.closest("[data-tab-list]")===J):[],se=Y.indexOf(j.currentTarget),ue=q=>{j.preventDefault(),Y[(q+Y.length)%Y.length]?.focus()},be=S==="horizontal"?"ArrowLeft":"ArrowUp",z=S==="horizontal"?"ArrowRight":"ArrowDown";switch(j.key){case be:{ue(se-1);break}case z:{ue(se+1);break}case"Home":{ue(0);break}case"End":{ue(Y.length-1);break}case"Enter":case" ":{j.preventDefault(),H();break}case"Backspace":case"Delete":{if(!I){j.preventDefault();const q=T?cs(O,M.id):(O.tabs[$+1]??O.tabs[$-1])?.id;q!==void 0&&c(q),h("close",!0,V=>Ln(V,M.id))}break}}},N={"aria-controls":D,"aria-selected":T,className:t?.tab,"data-drop-after":_||void 0,"data-drop-before":B||void 0,"data-tab":"","data-tab-dragging":o===M.id||void 0,"data-tab-id":M.id,"data-tab-placement":p,"data-tabset-collapsed":m||void 0,"data-tab-selected":T||void 0,id:K,onClick:j=>{on(j)||H()},onKeyDown:j=>{on(j)||W(j)},onPointerDown:j=>{j.button===0&&!v&&!on(j)&&u(M.id,j)},ref:C,role:"tab",style:{...d?.tab,touchAction:L,WebkitTouchCallout:"none"},tabIndex:T?0:-1};return A.jsx(lt.Provider,{value:r(M.id),children:l?l(M,N):A.jsxs("div",{...N,children:[M.title??M.id,A.jsx(fs,{})]})})}const Bi=Object.assign(Wi,{displayName:"Workspace.Tab"});function Hi(e){const t=e.dataset.orientation==="vertical",n=e.ownerDocument.defaultView?.getComputedStyle(e),o=(h,m)=>parseFloat(h?.getPropertyValue(m)??"")||0,[s,r]=t?["top","bottom"]:["left","right"],i=Ae(e,t?"vertical":"horizontal"),a=e.getBoundingClientRect(),l=(t?a.height:a.width)/i-o(n,`border-${s}-width`)-o(n,`border-${r}-width`)-o(n,`padding-${s}`)-o(n,`padding-${r}`);let c,u;for(const h of e.children){if(!Oe(h)||h.offsetParent===null)continue;const m=h.getBoundingClientRect(),p=t?m.top:m.left,b=t?m.bottom:m.right;(!c||p<c.position)&&(c={element:h,position:p}),(!u||b>u.position)&&(u={element:h,position:b})}if(!c||!u)return Math.round(l);const d=h=>h.ownerDocument.defaultView?.getComputedStyle(h),g=o(d(c.element),`margin-${s}`)+o(d(u.element),`margin-${r}`);return Math.round(l-g-(u.position-c.position)/i)}function Vi({children:e}){const{classNames:t,disabled:n,model:o,styles:s,tabListFreeSpaceStore:r}=Qe("TabList"),{isCollapsed:i,tabPlacement:a,tabset:l}=Xt("TabList"),c=a==="left"||a==="right"?"vertical":"horizontal",u=f.useRef(null),[d,g]=f.useState(!1),h=l.id;ne(()=>{const b=u.current;if(!b)return;const y=()=>{const M=b.dataset.orientation==="vertical",T=M?b.scrollTop:b.scrollLeft,I=M?b.scrollHeight-b.offsetHeight:b.scrollWidth-b.offsetWidth;b.toggleAttribute("data-overflow-start",T>1),b.toggleAttribute("data-overflow-end",I-T>1),g(I>1)};let S;const x=()=>{y();const M=Hi(b);M!==S&&(S=M,b.style.setProperty("--tab-list-free-space",`${M}px`)),r.set(h,M)};let C=null,O=null;y();let $=!1;return queueMicrotask(()=>{const M=b.ownerDocument.defaultView;if(!($||!M)){C=M.ResizeObserver?new M.ResizeObserver(x):null,C?.observe(b);for(const T of b.children)C?.observe(T);O=M.MutationObserver?new M.MutationObserver(T=>{for(const I of T){for(const v of I.addedNodes)Oe(v)&&C?.observe(v);for(const v of I.removedNodes)Oe(v)&&C?.unobserve(v)}x()}):null,O?.observe(b,{childList:!0}),x()}}),b.addEventListener("scroll",y,{passive:!0}),()=>{$=!0,C?.disconnect(),O?.disconnect(),b.removeEventListener("scroll",y)}},[c,r,h]),ne(()=>r.retain(h),[r,h]);let m=s?.tabList?.touchAction;Mn(o,l,n)||(d?m=c==="horizontal"?"pan-x":"pan-y":m="none");const p=f.useMemo(()=>({isOverflowing:d,orientation:c}),[d,c]);return A.jsx(Cs.Provider,{value:p,children:A.jsx("div",{"aria-orientation":c,className:t?.tabList,"data-orientation":c,"data-tab-list":!0,"data-tab-placement":a,"data-tabset-collapsed":i||void 0,ref:u,role:"tablist",style:{...s?.tabList,touchAction:m},children:e})})}const _i=Object.assign(Vi,{displayName:"Workspace.TabList"}),qi={bottom:{bottom:0,left:0,right:0,top:"50%"},center:{bottom:0,left:0,right:0,top:0},left:{bottom:0,left:0,right:"50%",top:0},right:{bottom:0,left:"50%",right:0,top:0},top:{bottom:"50%",left:0,right:0,top:0}};function Ui(){const{classNames:e,dropTarget:t,getHiddenTabBehavior:n,getTabHost:o,isHydrating:s,renderEmptyTabset:r,renderTabContent:i,shouldServerRenderTabContent:a,styles:l}=Qe("TabPanels"),{isCollapsed:c,setPanelsElement:u,tabPlacement:d,tabset:g}=Xt("TabPanels"),h=f.useRef(null),m=Ze(h,u);ne(()=>{const S=h.current;if(S&&!s)for(const x of g.tabs){const{element:C}=o(x.id);C&&(C.parentElement!==S&&S.appendChild(C),C.style.display=x.id===g.selectedId?"contents":"none")}});const p=g.tabs.find(({id:S})=>S===g.selectedId),b=s&&p&&a(p)?p:void 0,y=t?.tabsetId===g.id&&"region"in t?t.region:void 0;return A.jsxs("div",{className:e?.tabPanels,"data-tab-panels":!0,"data-tab-placement":d,"data-tabset-collapsed":c||void 0,ref:m,style:{position:"relative",...l?.tabPanels,...c&&{display:"none"}},children:[g.tabs.length===0&&r?.(g),b&&A.jsx("div",{style:{display:"contents"},children:A.jsx(Ss,{hiddenTabBehavior:n(b),renderTabContent:i,tab:b})}),y&&A.jsx("div",{className:e?.dropIndicator,"data-drop-indicator":!0,"data-region":y,style:{...l?.dropIndicator,...qi[y],pointerEvents:"none",position:"absolute",zIndex:1}})]})}const Mo=Object.assign(Ui,{displayName:"Workspace.TabPanels"});function Ts(e,t){return t===e||t.hasAttribute("data-tab-list")&&t.closest("[data-tabset-header]")===e}function Ki(e,t){const n=Array.from(e.querySelectorAll("[data-tabset-drag-handle]")).filter(o=>o.closest("[data-tabset-header]")===e);return n.length>0?n.some(o=>o.contains(t)):Ts(e,t)}function Yi(){const{activeTabsetId:e,classNames:t,disabled:n,dragTabsetId:o,model:s,renderTabsetToolbar:r,setActiveTabsetId:i,startTabsetDrag:a,styles:l,updateModel:c}=Qe("TabsetView"),{isCollapsed:u,setHeaderElement:d,setTabsetElement:g,tabPlacement:h,tabset:m}=Xt("TabsetView"),p=Mn(s,m,n),b=A.jsxs("div",{className:t?.header,"data-tab-placement":h,"data-tabset-collapsed":u||void 0,"data-tabset-header":!0,onClick:y=>{u&&Ts(y.currentTarget,y.target)&&c("expand",!0,S=>vt(S,m.id))},onPointerDown:y=>{y.button===0&&!p&&Ki(y.currentTarget,y.target)&&a(m.id,y)},ref:d,style:l?.header,children:[A.jsx(_i,{children:m.tabs.map(y=>A.jsx(Bi,{tab:y},y.id))}),r&&A.jsx("div",{className:t?.toolbar,"data-tab-placement":h,"data-tabset-collapsed":u||void 0,"data-tabset-toolbar":!0,style:l?.toolbar,children:r(m)})]});return A.jsx("div",{className:t?.tabset,"data-tab-placement":h,"data-tabset":!0,"data-tabset-active":e===m.id||void 0,"data-tabset-collapsed":u||void 0,"data-tabset-dragging":o===m.id||void 0,"data-tabset-id":m.id,"data-tabset-maximized":s.maximizedTabsetId===m.id||void 0,onFocusCapture:()=>i(m.id),onPointerDownCapture:()=>i(m.id),ref:g,style:l?.tabset,children:h==="bottom"||h==="right"?A.jsxs(A.Fragment,{children:[A.jsx(Mo,{}),b]}):A.jsxs(A.Fragment,{children:[b,A.jsx(Mo,{})]})})}const Xi=Object.assign(Yi,{displayName:"Workspace.TabsetView"});function Ji(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return{height:Math.max(0,Math.round((n.height-o.height)/Ae(e,"vertical"))),width:Math.max(0,Math.round((n.width-o.width)/Ae(e,"horizontal")))}}function Zi(e,t,n){const o=t.dataset.tabPlacement==="left"||t.dataset.tabPlacement==="right",s=o?"width":"height",r=t.style,i=r.flex,a=r[s];r.flex="none",r[s]="max-content";const l=t.getBoundingClientRect();r.flex=i,r[s]=a;const c=o?l.width/Ae(t,"horizontal"):l.height/Ae(t,"vertical"),u=e.ownerDocument.defaultView?.getComputedStyle(e),d=n==="horizontal"?["left","right"]:["top","bottom"];let g=0;for(const h of d)g+=(parseFloat(u?.getPropertyValue(`padding-${h}`)??"")||0)+(parseFloat(u?.getPropertyValue(`border-${h}-width`)??"")||0);return Math.round(c+g)}function Qi({isMaximizedOverlay:e=!1,tabset:t}){const{collapseOverrides:n,collapsePreview:o,getTabsetHandle:s,model:r,modelIndex:i,outerParents:a,reportChromeSize:l,reportCollapsedSize:c,tabPlacement:u}=Qe("TabsetSlot"),d=i.parentsById.get(t.id),g=d?.orientation,h=!e&&Nt(t,n),m=o[t.id]!==void 0;let p=t.tabPlacement??u;if(h&&d){const I=d.children[d.children.length-1]?.id===t.id,v=p==="left"||p==="right";g==="horizontal"&&!v?p=I?"right":"left":g==="vertical"&&v&&(p=I?"bottom":"top")}const[b,y]=f.useState(null),[S,x]=f.useState(null),[C,O]=f.useState(null),$=t.collapsible&&!e?g:void 0,M=f.useRef(null);ne(()=>{if(!b||!C)return;const I=()=>{if(!m){if(!h){const L=C.getBoundingClientRect();(g==="horizontal"?L.width<=0:g==="vertical"?L.height<=0:L.width<=0||L.height<=0)||l(t.id,Ji(b,C))}if(S&&$){const L=Zi(b,S,$),E=M.current;h?(M.current={orientation:$,size:L},c(t.id,L)):E?.orientation!==$&&c(t.id,L)}}};I();const v=b.ownerDocument.defaultView?.ResizeObserver;if(v){const L=new v(I);return L.observe(b),L.observe(C),S&&L.observe(S),()=>{L.disconnect()}}},[$,S,h,m,g,C,l,c,p,t.id,b]);const T=f.useMemo(()=>({isCollapsed:h,setHeaderElement:x,setPanelsElement:O,setTabsetElement:y,tabPlacement:p,tabset:t}),[h,p,t]);return!e&&r.maximizedTabsetId===t.id?null:A.jsx(_t.Provider,{value:a.grid,children:A.jsx(Kt.Provider,{value:a.group,children:A.jsx(Yt.Provider,{value:a.panel,children:A.jsx(lt.Provider,{value:null,children:A.jsx(dt.Provider,{value:s(t.id),children:A.jsx(vs.Provider,{value:T,children:A.jsx(Xi,{})})})})})})})}const Is=Object.assign(Qi,{displayName:"Workspace.TabsetSlot"});function ea({node:e}){return e.type==="split"?A.jsx(Gi,{split:e}):A.jsx(Is,{tabset:e})}const Rs=Object.assign(ea,{displayName:"Workspace.NodeView"});function nt(e,t){const n=Object.keys(e).filter(s=>!t.has(s));if(n.length===0)return e;const o={...e};for(const s of n)delete o[s];return o}function ko(e,t){let n=e;for(const[o,s]of Object.entries(t))e[o]!==s&&(n===e&&(n={...e}),s===void 0?delete n[o]:n[o]=s);return n}function Et(e,t){if(e===void 0)return;if(typeof e!="string"){Ie(`Workspace tabset sizes (e.g. minWidth or maxWidth) must be strings with units (e.g. "200px"); received ${e}`);return}const[n,o]=bn(e);switch(o){case"%":{Ie(`Workspace tabset sizes (e.g. minWidth or maxWidth) must use absolute units (px, em, rem, vh, or vw); received "${e}". Use "vw" or "vh" for sizes relative to the viewport.`);return}case"px":return n;default:return t?Ke({axisSize:0,itemElement:t,styleProp:e}):void 0}}function ta({children:e,className:t,dragType:n,elementRef:o,pointRef:s,style:r}){const i=f.useRef(null);return ne(()=>(o.current=i.current,xs(i.current,s.current),()=>{o.current=null}),[o,s]),A.jsx("div",{className:t,"data-drag-preview":!0,"data-drag-type":n,ref:i,style:{zIndex:2,...r,left:0,pointerEvents:"none",position:"fixed",top:0},children:e})}const na=Object.assign(ta,{displayName:"Workspace.DragPreview"});function oa({className:e,classNames:t,defaultModel:n,disabled:o=!1,disableDrop:s,elementRef:r,hiddenTabBehavior:i="keep-mounted",id:a,onModelChanged:l,renderDragPreview:c,renderEmptyTabset:u,renderSeparator:d,renderTab:g,renderTabContent:h,renderTabsetDragPreview:m,renderTabsetToolbar:p,resizePreviewMode:b,serverRenderTabContent:y=!1,style:S,styles:x,tabPlacement:C="top",tabRemovalSelectionBehavior:O="adjacent",tabsetMinHeight:$,tabsetMinWidth:M,workspaceRef:T,...I}){const v=Je(a),L=f.useContext(_t),E=f.useContext(Kt),B=f.useContext(Yt),_=f.useMemo(()=>({grid:L,group:E,panel:B}),[L,E,B]),[D,K]=f.useState(()=>nn(Se(To(n)),O)),H=f.useRef(D),[W,N]=f.useState(0),[j,J]=f.useState(),Y=f.useRef(void 0),se=f.useCallback(w=>{Y.current!==w&&(Y.current=w,J(w))},[]),ue=ze((...w)=>l?.(...w)),be=ze(()=>O),z=f.useCallback((w,R,F)=>{const ae=be(),qe=nn(H.current,ae),Pt=F(qe);if(Pt!==qe){const en=nn(Pt,ae);H.current=en,K(en),ue(en,{isUserInteraction:R,reason:w})}},[be,ue]),[q]=f.useState(mi),V=f.useMemo(()=>{const w=()=>{const R=Y.current;return le(H.current,R)?R:void 0};return{addTab:(R,F={})=>{const ae=gi(H.current,R,{...F,tabsetId:F.tabsetId??w()});return z(ae.added?"add":"select",!1,()=>ae.model),ae.added},closeTab:R=>z("close",!1,F=>Ln(F,R)),closeTabset:R=>z("close",!1,F=>bi(F,R)),collapseTabset:R=>z("collapse",!1,F=>yi(F,R)),expandTabset:R=>z("expand",!1,F=>vt(F,R)),getActiveTabsetId:w,getModel:()=>H.current,getTabListFreeSpace:R=>q.get(R),maximizeTabset:R=>z("maximize",!1,F=>xi(F,R)),moveTab:(R,F)=>z("move",!1,ae=>Io(ae,R,F)),moveTabset:(R,F)=>z("move",!1,ae=>Ro(ae,R,F)),restoreTabset:()=>z("restore",!1,zi),selectTab:R=>z("select",!1,F=>Gt(F,R)),setModel:R=>(z("set-model",!1,()=>Se(To(R))),N(F=>F+1),H.current),subscribeToTabListFreeSpace:(R,F)=>q.subscribe(R,F),updateTab:(R,F)=>z("update",!1,ae=>Ci(ae,R,F)),updateTabset:(R,F)=>z("update",!1,ae=>Ti(ae,R,F))}},[q,z]);f.useImperativeHandle(T,()=>V,[V]);const P=f.useMemo(()=>({...V,id:v}),[V,v]),[k]=f.useState(()=>({tabs:new Map,tabsets:new Map})),G=f.useCallback(w=>{let R=k.tabs.get(w);return R||(R={close:()=>V.closeTab(w),getTabsetId:()=>Xe(H.current,w)?.id??"",id:w,isSelected:()=>Xe(H.current,w)?.selectedId===w,select:()=>V.selectTab(w),workspaceId:v},k.tabs.set(w,R)),R},[V,k,v]),U=f.useCallback(w=>{let R=k.tabsets.get(w);return R||(R={addTab:(F,ae={})=>V.addTab(F,{...ae,tabsetId:w}),close:()=>V.closeTabset(w),collapse:()=>V.collapseTabset(w),expand:()=>V.expandTabset(w),id:w,isCollapsed:()=>!!le(H.current,w)?.collapsed,isMaximized:()=>H.current.maximizedTabsetId===w,maximize:()=>V.maximizeTabset(w),restore:()=>{H.current.maximizedTabsetId===w&&V.restoreTabset()},workspaceId:v},k.tabsets.set(w,R)),R},[V,k,v]),[X,Q]=f.useState(null),ee=f.useRef(null),de=Ze(ee,Q,r),[xe]=f.useState(()=>new Map),Z=f.useRef(0),oe=X?.ownerDocument,we=f.useCallback(w=>{let R=xe.get(w);if(!R){const F=++Z.current;R={element:null,panelId:`${v}-tab-panel-${F}`,tabElementId:`${v}-tab-${F}`},xe.set(w,R)}return!R.element&&oe&&(R.element=oe.createElement("div")),R},[v,oe,xe]),Ce=vi(D.root),he=f.useMemo(()=>Si(D),[D]);f.useEffect(()=>{const w=new Set(Ce.map(({id:R})=>R));for(const[R,F]of xe)w.has(R)||(F.element?.remove(),xe.delete(R),k.tabs.delete(R));for(const R of k.tabsets.keys())he.tabsetsById.has(R)||k.tabsets.delete(R)});const je=f.useSyncExternalStore(qt,()=>!1,()=>!0),Re=f.useCallback(w=>typeof i=="function"?i(w):i,[i]),Ve=f.useCallback(w=>typeof y=="function"?y(w):y,[y]),[Pe,Ne]=f.useState({}),[Ge,pe]=f.useState({}),[ie,me]=f.useState({}),Fe=f.useCallback((w,R)=>Ne(F=>F[w]?.height===R.height&&F[w]?.width===R.width?F:{...F,[w]:R}),[]),[We,Jt]=f.useState({}),En=f.useCallback(w=>Jt(R=>ko(R,w)),[]),[Dn,On]=f.useState({}),An=f.useCallback(w=>On(R=>ko(R,w)),[]),St=f.useMemo(()=>new Set(he.parentsById.keys()),[he]),Be=f.useMemo(()=>nt(Dn,St),[Dn,St]),xt=f.useMemo(()=>Object.keys(Be).length===0?We:Object.keys(We).length===0?Be:{...Be,...We},[We,Be]);f.useEffect(()=>Wt(({next:w,prev:R})=>{R.state==="active"&&w.state!=="active"&&Jt(F=>Object.keys(F).length>0?{}:F)}),[]);const $n=f.useCallback((w,R)=>me(F=>F[w]===R?F:{...F,[w]:R}),[]),jn=f.useCallback((w,R)=>pe(F=>F[w]===R?F:{...F,[w]:R}),[]);f.useEffect(()=>{Ne(w=>nt(w,he.nodeIds)),pe(w=>nt(w,he.nodeIds)),me(w=>nt(w,he.nodeIds)),Jt(w=>nt(w,he.nodeIds)),On(w=>nt(w,St))},[he,St]);const[et,Ls]=f.useState(null);f.useEffect(()=>{if(!X)return;const w=()=>Ls({element:X});w();const R=X.ownerDocument.defaultView;return R?.addEventListener("resize",w),()=>{R?.removeEventListener("resize",w)}},[X]);const Nn=f.useMemo(()=>pi(D.root,{getChromeSize:w=>Pe[w],getCollapsedSize:w=>ie[w],getContentMinimumSize:w=>({height:Et(w.minHeight??$,et?.element??null)??0,width:Et(w.minWidth??M,et?.element??null)??0}),getSeparatorsSize:w=>Ge[w]}),[Pe,ie,D.root,Ge,$,M,et]),Gn=f.useMemo(()=>fi(D.root,{getChromeSize:w=>Pe[w],getCollapsedSize:w=>ie[w],getContentMaximumSize:w=>({height:Et(w.maxHeight,et?.element??null)??1/0,width:Et(w.maxWidth,et?.element??null)??1/0}),getSeparatorsSize:w=>Ge[w]}),[Pe,ie,D.root,Ge,et]),Ps=ze((w,R)=>{if(typeof s!="function")return!!s;const F=H.current;if(w.type==="tab"){const qe=it(F,w.tabId);return qe?s({model:F,tab:qe,tabset:void 0,target:R}):!0}const ae=le(F,w.tabsetId);return ae?ae.tabs.length===0?s({model:F,tab:void 0,tabset:ae,target:R}):ae.tabs.some((qe,Pt)=>s({model:F,tab:qe,tabset:ae,target:"index"in R?{...R,index:R.index+Pt}:R})):!0}),Ms=f.useCallback((w,R)=>z("move",!0,F=>w.type==="tab"?Io(F,w.tabId,R):Ro(F,w.tabsetId,R)),[z]),ks=f.useCallback(()=>H.current,[]),Es=f.useCallback(()=>ee.current,[]),{dragSource:wt,dropTarget:Fn,previewElementRef:Ds,previewPointRef:Os,startTabDrag:Wn,startTabsetDrag:Bn}=Oi({getModel:ks,getRootElement:Es,isDropDisabled:Ps,onDrop:Ms}),zt=wt?.type==="tab"?wt.tabId:void 0,Ct=wt?.type==="tabset"?wt.tabsetId:void 0,Zt=f.useRef(void 0),Hn=f.useCallback(w=>{Zt.current=w},[]),Vn=f.useCallback(w=>Zt.current===w?(Zt.current=void 0,!0):!1,[]),As=f.useMemo(()=>({activeTabsetId:j,collapsedSizes:ie,collapseOverrides:xt,collapsePreview:We,collapseToFit:Be,disabled:o,dragTabId:zt,dragTabsetId:Ct,dropTarget:Fn,getTabHandle:G,getTabHost:we,getHiddenTabBehavior:Re,getTabsetHandle:U,id:v,isHydrating:je,maximumSizes:Gn,minimumSizes:Nn,model:D,modelIndex:he,outerParents:_,classNames:t,renderEmptyTabset:u,renderSeparator:d,renderTab:g,renderTabContent:h,renderTabsetToolbar:p,reportChromeSize:Fe,reportCollapsePreview:En,reportCollapseToFit:An,reportCollapsedSize:$n,reportSeparatorsSize:jn,requestFocus:Hn,resizePreviewMode:b,setActiveTabsetId:se,shouldServerRenderTabContent:Ve,splitGeneration:W,startTabDrag:Wn,startTabsetDrag:Bn,styles:x,tabListFreeSpaceStore:q,tabPlacement:C,takeFocusRequest:Vn,updateModel:z}),[j,ie,xt,We,Be,o,zt,Ct,Fn,G,we,Re,U,v,je,Gn,Nn,D,he,_,t,u,d,g,h,p,Fe,En,An,$n,jn,Hn,b,se,Ve,W,Wn,Bn,x,q,C,Vn,z]),Qt=f.useMemo(()=>({activeTabsetId:j,collapseOverrides:xt,collapseToFit:Be,disabled:o,model:D,modelIndex:he}),[j,xt,Be,o,D,he]),[Tt]=f.useState(()=>hi(Qt));Tt.setState(Qt),ne(()=>{Tt.notify()},[Tt,Qt]);const It=le(D,D.maximizedTabsetId),_n=f.useRef(null);ne(()=>{_n.current?.toggleAttribute("inert",!!It)},[It]);const Rt=zt?it(D,zt):void 0,_e=Ct?le(D,Ct):void 0,qn=(w,R=0)=>{if(c)return c(w);const F=w.title??w.id;return R>0?`${F} (+${R})`:F};let Lt=null;if(Rt)Lt=qn(Rt);else if(_e)if(m)Lt=m(_e);else{const w=_e.tabs.find(({id:R})=>R===_e.selectedId);Lt=w?qn(w,_e.tabs.length-1):_e.id}return A.jsx(kn.Provider,{value:P,children:A.jsx(ls.Provider,{value:Tt,children:A.jsxs(Rn.Provider,{value:As,children:[A.jsxs("div",{...I,className:e,"data-testid":at(I,a),"data-workspace":!0,id:v,ref:de,style:{position:"relative",...S},children:[A.jsx("div",{"data-workspace-layout":!0,ref:_n,style:{height:"100%",width:"100%"},children:A.jsx(Rs,{node:D.root})}),It&&A.jsx("div",{"data-workspace-maximized":!0,style:{inset:0,position:"absolute",zIndex:1},children:A.jsx(Is,{isMaximizedOverlay:!0,tabset:It})}),(Rt||_e)&&A.jsx(na,{className:t?.dragPreview,dragType:Rt?"tab":"tabset",elementRef:Ds,pointRef:Os,style:x?.dragPreview,children:Lt})]}),!je&&Ce.map(w=>{const R=we(w.id).element;return R?$s.createPortal(A.jsx(Ss,{hiddenTabBehavior:Re(w),renderTabContent:h,tab:w}),R,w.id):null})]})})})}const sa=Object.assign(oa,{displayName:"Workspace"});function ra(e,{mapTab:t}={}){if(!ms(e)||e.version!==1)return null;if(!t)return Se(e);const n=s=>s.type==="split"?{...s,children:s.children.map(n)}:{...s,tabs:s.tabs.flatMap(r=>{const i=t(r);return i?[i]:[]})},o={...e,root:n(e.root)};return Se(o)}exports.Cell=Hs;exports.Grid=Rr;exports.Gridline=Zo;exports.Group=ts;exports.Panel=os;exports.Separator=ss;exports.SeparatorOverlay=es;exports.TabCloseButton=fs;exports.TabsetDragHandle=si;exports.Workspace=sa;exports.isCoarsePointer=Oo;exports.normalizeWorkspaceModel=ra;exports.useDefaultGridLayout=Lr;exports.useDefaultLayout=Br;exports.useGridCallbackRef=Pr;exports.useGridRef=Mr;exports.useGroupCallbackRef=Hr;exports.useGroupRef=ns;exports.usePanelCallbackRef=Kr;exports.usePanelRef=Yr;exports.useParentGrid=kr;exports.useParentGroup=Vr;exports.useParentPanel=Xr;exports.useParentTab=ri;exports.useParentTabState=ds;exports.useParentTabset=ii;exports.useParentTabsetState=ps;exports.useParentWorkspace=ai;exports.useTabListFreeSpace=ci;exports.useWorkspaceCallbackRef=ui;exports.useWorkspaceRef=di;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("react/jsx-runtime"),p=require("react"),Fs=require("react-dom");function Bs(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Ws=Bs(p);function jt(e){return(typeof e=="number"||typeof e=="string")&&e!==""}function Je(e){const t=p.useId();return jt(e)?`${e}`:t}const ne=typeof window<"u"?p.useLayoutEffect:p.useEffect;function Ce(e){const t=p.useRef(e);return ne(()=>{t.current=e},[e]),p.useCallback((...n)=>t.current?.(...n),[t])}function Ze(...e){return Ce(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function at(e,t){const n=e?.["data-testid"];return jt(n)?`${n}`:jt(t)?`${t}`:void 0}function an(e,t){return t?e*2+1:e+1}function Hs(e,t){return t?e*2-1:e}function Yn(e,t,n){const o=an(e,n);return t===void 0?`${o} / -1`:`${o} / span ${Hs(t,n)}`}function Vs(e){return`${e*2} / span 1`}function _s({crossCount:e,crossSpan:t,crossStart:n,hasGutters:o}){const s=t===void 0?e:n+t;if(n===0&&s===e)return"1 / -1";let r=an(n,o),i=an(s-1,o)+1;return o&&(n>0&&r--,s<e&&i++),`${r} / ${i}`}function pn(e,t){return Number.isInteger(e)&&e>=1&&e<t}function ee(e,t="Assertion error"){if(!e)throw Error(t)}const Ao=p.createContext(null);function $o(){const e=p.useContext(Ao);return ee(e,"Grid Context not found; did you render a Cell or Gridline outside of a Grid?"),e}function qs({children:e,className:t,column:n,columnSpan:o=1,elementRef:s,id:r,row:i,rowSpan:a=1,style:l,...c}){const u=Je(r),{gutters:d,registerCell:h}=$o(),g=p.useRef(null),m=Ze(g,s);return ne(()=>{const f=g.current;if(f!==null)return h({column:n,columnSpan:o,element:f,id:u,row:i,rowSpan:a})},[n,o,u,h,i,a]),O.jsx("div",{...c,className:t,"data-cell":!0,"data-testid":at(c,r),id:u,ref:m,style:{overflow:"auto",...l,minHeight:0,minWidth:0,gridColumn:Yn(n,o,d.column),gridRow:Yn(i,a,d.row)},children:e})}const Us=Object.assign(qs,{displayName:"Cell"});let kt;function jo(){return kt===void 0&&(typeof matchMedia=="function"?kt=!!matchMedia("(pointer:coarse)").matches:kt=!1),kt}function cn({expandHitTargets:e,axis:t,rect:n}){const o=e?jo()?t.resizeTargetMinimumSize.coarse:t.resizeTargetMinimumSize.fine:0;if(n.width<o){const s=o-n.width;n=new DOMRect(n.x-s/2,n.y,n.width+s,n.height)}if(n.height<o){const s=o-n.height;n=new DOMRect(n.x,n.y-s/2,n.width,n.height+s)}return n}function Xn({axis:e,cells:t,index:n,rect:o}){let s=[o];for(const r of t){const i=e==="column"?r.column:r.row,a=e==="column"?r.columnSpan:r.rowSpan;if(i>=n||i+a<=n)continue;const l=r.element.getBoundingClientRect(),c=e==="column"?l.top:l.left,u=e==="column"?l.bottom:l.right;u<=c||(s=s.flatMap(d=>{const h=e==="column"?d.top:d.left,g=e==="column"?d.bottom:d.right;if(c>=g||u<=h)return[d];const m=[],f=(b,y)=>{m.push(e==="column"?new DOMRect(d.x,b,d.width,y-b):new DOMRect(b,d.y,y-b,d.height))};return h<c&&f(h,c),g>u&&f(u,g),m}))}return s}function Ks({axis:e,cells:t,crossTrackCount:n,expandHitTargets:o,resizeAxis:s,axisSize:r,includeDisabled:i,separatorPlacements:a}){const{items:l,separators:c}=s,u=l.length;let d=-1,h=-1,g=0;if(l.forEach((I,R)=>{I.constraintProps.disabled||(g++,d===-1&&(d=R),h=R)}),!i&&g<2)return[];const m=I=>i||I>d&&I<=h,f=[],b=(I,R,v)=>({axis:s,axisSize:r,items:[l[I-1],l[I]],rect:R,separator:v}),y=(I,R)=>{let v;for(const C of t){const M=e==="column"?C.row:C.column,N=e==="column"?C.rowSpan:C.columnSpan;if(R==="start"?M===I:M+N-1===I){const V=C.element.getBoundingClientRect();if(R==="start"){const D=e==="column"?V.top:V.left;v=v===void 0?D:Math.min(v,D)}else{const D=e==="column"?V.bottom:V.right;v=v===void 0?D:Math.max(v,D)}}}return v},S=new Set;for(const I of c){const R=a.get(I);if(!R||R.index<1||R.index>=u||(S.add(R.index),!i&&(I.disabled||I.element.hasAttribute("aria-disabled")))||!m(R.index))continue;let v=I.element.getBoundingClientRect();const{crossSpan:C,crossStart:M}=R,N=C===void 0?n:M+C;let V=e==="column"?v.top:v.left,D=e==="column"?v.bottom:v.right;if(M>0){const K=y(M-1,"end");K!==void 0&&K<V&&(V=K)}if(N<n){const K=y(N,"start");K!==void 0&&K>D&&(D=K)}v=e==="column"?new DOMRect(v.x,V,v.width,D-V):new DOMRect(V,v.y,D-V,v.height),v=cn({expandHitTargets:o,axis:s,rect:v}),i?f.push(b(R.index,v,I)):Xn({axis:e,cells:t,index:R.index,rect:v}).forEach(K=>{f.push(b(R.index,K,I))})}const x=(I,R)=>{Xn({axis:e,cells:t,index:I,rect:cn({expandHitTargets:o,axis:s,rect:R})}).forEach(v=>{f.push(b(I,v))})},T=Array.from({length:n},()=>new Array(u));for(const I of t){const[R,v,C,M]=e==="column"?[I.column,I.columnSpan,I.row,I.rowSpan]:[I.row,I.rowSpan,I.column,I.columnSpan];for(let N=Math.max(0,C);N<Math.min(n,C+M);N++)for(let V=Math.max(0,R);V<Math.min(u,R+v);V++)T[N][V]??=I}const E=new Map,j=I=>{let R=E.get(I);if(!R){const v=I.element.getBoundingClientRect();R=e==="column"?{crossEnd:v.bottom,crossStart:v.top,end:v.right,start:v.left}:{crossEnd:v.right,crossStart:v.left,end:v.bottom,start:v.top},E.set(I,R)}return R},k=({crossEnd:I,crossStart:R,end:v,start:C})=>e==="column"?new DOMRect(C,R,v-C,I-R):new DOMRect(R,C,I-R,v-C);for(let I=1;I<u;I++){if(S.has(I)||!m(I))continue;let R;for(let v=0;v<n;v++){const C=T[v][I-1],M=T[v][I];let N;if((C||M)&&C!==M){const V=C?j(C):void 0,D=M?j(M):void 0,K=V?.end??D.start,H=D?.start??V.end,W=Math.max(V?.crossStart??-1/0,D?.crossStart??-1/0),F=Math.min(V?.crossEnd??1/0,D?.crossEnd??1/0);N={crossEnd:Math.max(W,F),crossStart:W,end:Math.max(K,H),start:Math.min(K,H)}}N?R=R?{crossEnd:Math.max(R.crossEnd,N.crossEnd),crossStart:Math.min(R.crossStart,N.crossStart),end:Math.max(R.end,N.end),start:Math.min(R.start,N.start)}:N:R&&(x(I,k(R)),R=void 0)}R&&x(I,k(R))}return f}function ke(e){const t=parseFloat(e??"");return Number.isFinite(t)?t:0}function Ys({axis:e,element:t,gutterSizes:n,hasGutters:o,layout:s,trackIds:r}){const i=r.length,a=o?i*2-1:i,l=t.ownerDocument.defaultView?.getComputedStyle(t),c=e==="column"?l?.gridTemplateColumns:l?.gridTemplateRows;if(c){const f=c.trim().split(/\s+/);if(f.length===a&&f.every(b=>/^-?[\d.]+px$/.test(b))){const b=r.map((y,S)=>ke(f[o?S*2:S]));return{availableSize:b.reduce((y,S)=>y+S,0),trackSizes:b}}}const u=e==="column"?t.offsetWidth:t.offsetHeight,d=e==="column"?ke(l?.paddingLeft)+ke(l?.paddingRight)+ke(l?.borderLeftWidth)+ke(l?.borderRightWidth):ke(l?.paddingTop)+ke(l?.paddingBottom)+ke(l?.borderTopWidth)+ke(l?.borderBottomWidth),h=ke(e==="column"?l?.columnGap:l?.rowGap),g=n.reduce((f,b)=>f+b,0),m=Math.max(0,u-d-h*Math.max(0,a-1)-g);return{availableSize:m,trackSizes:r.map(f=>s&&s[f]!==void 0?s[f]/100*m:m/i)}}class mn{#e={};addListener(t,n){const o=this.#e[t];return o===void 0?this.#e[t]=[n]:o.includes(n)||o.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const o=this.#e[t];if(o!==void 0){if(o.length===1){o[0].call(null,n);return}let s;const r=Array.from(o);for(let i=0;i<r.length;i++){const a=r[i];try{a.call(null,n)}catch(l){s??={error:l}}}if(s)throw s.error}}removeAllListeners(){this.#e={}}removeListener(t,n){const o=this.#e[t];if(o!==void 0){const s=o.indexOf(n);s>=0&&o.splice(s,1)}}}function ln(e){const t=o=>{o.preventDefault(),o.stopPropagation(),n()},n=()=>{e.removeEventListener("click",t,!0)};e.addEventListener("click",t,!0),setTimeout(n,0)}let ce={cursorFlags:0,state:"inactive"};const hn=new mn;function ye(){return ce}function Wt(e){return hn.addListener("change",e)}function Xs(e,t=[],n,o=!1){const s=ce,r={...ce};r.cursorFlags=e,r.state==="active"&&(r.didPointerMove||=o,r.previews=t,n&&(r.previewLayoutMap=n)),ce=r,hn.emit("change",{prev:s,next:r})}function De(e){const t=ce;ce=e,t.state==="active"&&e.state!=="active"&&t.didPointerMove&&(t.hitRegions.forEach(({separator:n})=>{n&&n.element.ownerDocument.activeElement===n.element&&n.element.blur()}),ln(t.ownerDocument)),hn.emit("change",{prev:t,next:e})}function Js(e){ce.state!=="active"||!ce.previews.some(t=>t.separator===e)||De({...ce,previews:ce.previews.map(t=>t.separator===e?{...t}:t)})}function Zs(e){if(ce.state==="inactive")return;const t=ce.hitRegions.filter(o=>o.axis!==e),n=ce.state==="active"&&ce.previews.some(o=>o.axis===e);if(!(t.length===ce.hitRegions.length&&!n))if(t.length===0)De({cursorFlags:0,state:"inactive"});else if(ce.state==="active"){const o=new Map(ce.initialLayoutMap),s=new Map(ce.previewLayoutMap);o.delete(e),s.delete(e),De({...ce,cursorFlags:0,hitRegions:t,initialLayoutMap:o,previewLayoutMap:s,previews:ce.previews.filter(r=>r.axis!==e)})}else De({...ce,hitRegions:t})}const Qs=e=>e,nn=()=>{},No=1,Go=2,Fo=4,Bo=8,Jn=3,Zn=12;let Et;function Qn(){return Et===void 0&&(Et=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Et=!0)),Et}function er({cursorFlags:e,axes:t,state:n}){let o=0,s=0;switch(n){case"active":case"hover":t.forEach(r=>{if(!r.mutableState.disableCursor)switch(r.orientation){case"horizontal":{o++;break}case"vertical":{s++;break}}})}if(!(o===0&&s===0)){switch(n){case"active":{if(e&&Qn()){const r=(e&No)!==0,i=(e&Go)!==0,a=(e&Fo)!==0,l=(e&Bo)!==0;if(r)return a?"se-resize":l?"ne-resize":"e-resize";if(i)return a?"sw-resize":l?"nw-resize":"w-resize";if(a)return"s-resize";if(l)return"n-resize"}break}}return Qn()?o>0&&s>0?"move":o>0?"ew-resize":"ns-resize":o>0&&s>0?"grab":o>0?"col-resize":"row-resize"}}const eo=new WeakMap;function to(e){if(!e.defaultView||!e.adoptedStyleSheets)return;let{prevStyle:t,styleSheet:n}=eo.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let o=ye();switch(o.state!=="inactive"&&o.ownerDocument!==e&&(o={cursorFlags:0,state:"inactive"}),o.state){case"active":case"hover":{const s=er({cursorFlags:o.cursorFlags,axes:o.hitRegions.map(i=>i.axis),state:o.state}),r=`*, *:hover {cursor: ${s} !important; }`;if(t===r)return;t=r,s?n.cssRules.length===0?n.insertRule(r):n.replaceSync(r):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}eo.set(e,{prevStyle:t,styleSheet:n})}function no(e){return e.state==="inactive"?void 0:e.ownerDocument}function tr({next:e,prev:t}){const n=no(t),o=no(e);n&&n!==o&&to(n),o&&to(o)}function bt({axis:e}){const{layoutStrategy:t,orientation:n,items:o}=e;return t?t.calculateAvailableSize():o.reduce((s,r)=>(s+=n==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,s),0)}function gn(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_DISCONNECTED?0:n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0}function ft(e,t){return Array.from(t).sort((n,o)=>{const s=e==="horizontal"?nr(n,o):or(n,o);return s!==0?s:gn(n.element,o.element)})}function nr(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function or(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function xe(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function Wo(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function sr({orientation:e,rects:t,targetRect:n}){const o={x:n.x+n.width/2,y:n.y+n.height/2};let s,r=Number.MAX_VALUE;for(const i of t){const{x:a,y:l}=Wo(o,i),c=e==="horizontal"?a:l;c<r&&(r=c,s=i)}return ee(s,"No rect found"),s}function Ae(e,t){const n=t==="horizontal"?e.offsetWidth:e.offsetHeight;if(n===0)return 1;const o=e.getBoundingClientRect(),s=t==="horizontal"?o.width:o.height;return s<=0||Math.abs(s-n)<1?1:s/n}function bn({expandHitTargets:e=!0,axis:t,includeDisabled:n=!1}){if(t.layoutStrategy)return t.layoutStrategy.calculateHitRegions({expandHitTargets:e,axis:t,includeDisabled:n});const{element:o,orientation:s,items:r,separators:i}=t,a=ft(s,Array.from(o.children).filter(xe).filter(y=>!y.hasAttribute("data-resize-preview")).map(y=>({element:y}))).map(({element:y})=>y),l=[];let c=!1,u=!1,d=-1,h,g=-1,m=0,f,b=[];{let y=-1;for(const S of a)S.hasAttribute("data-panel")&&(y++,S.hasAttribute("data-disabled")||(m++,d===-1&&(d=y),g=y))}if(n||m>1){let y=-1;for(const S of a)if(S.hasAttribute("data-panel")){y++;const x=r.find(T=>T.element===S);if(x){if(f){const T=f.element.getBoundingClientRect(),E=S.getBoundingClientRect();let j;if(u){const k=s==="horizontal"?new DOMRect(T.right,T.top,0,T.height):new DOMRect(T.left,T.bottom,T.width,0),I=s==="horizontal"?new DOMRect(E.left,E.top,0,E.height):new DOMRect(E.left,E.top,E.width,0);switch(b.length){case 0:{j=[k,I];break}case 1:{const R=b[0],v=sr({orientation:s,rects:[T,E],targetRect:R.element.getBoundingClientRect()});j=[R,v===T?I:k];break}default:{j=b;break}}}else b.length?j=b:j=[s==="horizontal"?new DOMRect(T.right,E.top,E.left-T.right,E.height):new DOMRect(E.left,T.bottom,E.width,E.top-T.bottom)];for(const k of j){const I=cn({expandHitTargets:e,axis:t,rect:"width"in k?k:k.element.getBoundingClientRect()}),R=y<=d||y>g;(n||!c&&!R)&&(h??=bt({axis:t})*Ae(t.element,t.orientation),l.push({axis:t,axisSize:h,items:[f,x],separator:"width"in k?void 0:k,rect:I})),c=!1}}u=!1,f=x,b=[]}}else if(S.hasAttribute("data-separator")){S.ariaDisabled!==null&&(c=!0);const x=i.find(T=>T.element===S);x?b.push(x):(f=void 0,b=[])}else u=!0}return l}function yn(e){return e.ownerDocument.defaultView??window}function rr(e,t){const n=yn(e).getComputedStyle(e),o=parseFloat(n.fontSize);return t*o}function ir(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),o=parseFloat(n.fontSize);return t*o}function ar(e,t){return t/100*yn(e).innerHeight}function cr(e,t){return t/100*yn(e).innerWidth}function vn(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Ke({axisSize:e,itemElement:t,styleProp:n}){let o;const[s,r]=vn(n);switch(r){case"%":{o=s/100*e;break}case"px":{o=s;break}case"rem":{o=ir(t,s);break}case"em":{o=rr(t,s);break}case"vh":{o=ar(t,s);break}case"vw":{o=cr(t,s);break}}return o}function fe(e){return parseFloat(e.toFixed(3))}function Sn(e,t=bt({axis:e})){const{items:n}=e;return t===0?n.map(o=>({groupResizeBehavior:o.constraintProps.groupResizeBehavior,collapsedSize:0,collapsible:o.constraintProps.collapsible===!0,defaultSize:void 0,disabled:o.constraintProps.disabled,minSize:0,maxSize:100,itemId:o.id})):n.map(o=>{const{element:s,constraintProps:r}=o;let i=0;if(r.collapsedSize!==void 0){const d=Ke({axisSize:t,itemElement:s,styleProp:r.collapsedSize});i=fe(d/t*100)}let a;if(r.collapsedThreshold!==void 0){const d=Ke({axisSize:t,itemElement:s,styleProp:r.collapsedThreshold});a=fe(d/t*100)}let l;if(r.defaultSize!==void 0){const d=Ke({axisSize:t,itemElement:s,styleProp:r.defaultSize});l=fe(d/t*100)}let c=0;if(r.minSize!==void 0){const d=Ke({axisSize:t,itemElement:s,styleProp:r.minSize});c=fe(d/t*100)}let u=100;if(r.maxSize!==void 0){const d=Ke({axisSize:t,itemElement:s,styleProp:r.maxSize});u=fe(d/t*100)}return{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsedThreshold:a,collapsible:r.collapsible===!0,defaultSize:l,disabled:r.disabled,minSize:c,maxSize:u,itemId:o.id}})}let Ee=new Map;const xn=new mn;let pt=0;const Ot=[];let At;function Ht(){pt++}function wn(){for(let e=0;e<Ot.length;e++)try{xn.emit("axisChange",Ot[e])}catch(t){At??={error:t}}Ot.length=0}function Vt(){if(pt===1&&wn(),pt--,pt===0&&At){const{error:e}=At;throw At=void 0,e}}function lr(e){Ee=new Map(Ee),Ee.delete(e)}function st(e,t){for(const[n]of Ee)if(n.id===e)return n}function be(e,t){for(const[n,o]of Ee)if(n.id===e)return o;if(t)throw Error(`Could not find data for Group with id ${e}`)}function $e(){return Ee}function rt(e,t){return xn.addListener("axisChange",n=>{n.axis.id===e&&t(n)})}function Oe(e,t,n){const o=Ee.get(e);Ee=new Map(Ee),Ee.set(e,t);const s={axis:e,isUserInteraction:n?.isUserInteraction===!0,prev:o,next:t};pt>0?Ot.push(s):xn.emit("axisChange",s)}function Ho(e,{pointerId:t,pointerType:n}){return t===e.pointerId||n==="pen"&&e.pointerType==="pen"}function yt(e,t,n={}){return e.ownerDocument===t&&(n.pointerId===void 0||Ho(e,n))}function ur(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function ie(e,t,n=0){return Math.abs(fe(e)-fe(t))<=n}function ve(e,t){return ie(e,t)?0:e>t?1:-1}function Ye({overrideDisabledItems:e,itemConstraints:t,prevSize:n,size:o}){const{collapsedSize:s=0,collapsedThreshold:r,collapsible:i,disabled:a,maxSize:l=100,minSize:c=0}=t;if(a&&!e)return n;if(ve(o,c)<0)if(i){const u=r??(c-s)/2,d=ve(n,s)<=0,h=d?s+u:c-u,g=ve(o,h);ve(o,s)<=0||g<0||r!==void 0&&d&&g===0?o=s:o=c}else o=c;return o=Math.min(l,o),o=fe(o),o}function gt({delta:e,initialLayout:t,itemConstraints:n,pivotIndices:o,prevLayout:s,trigger:r}){if(ie(e,0))return t;const i=r==="imperative-api",a=n.map(({itemId:m})=>t[m]),l=n.map(({itemId:m})=>s[m]),c=[...a],[u,d]=o;ee(u!=null,"Invalid first pivot index"),ee(d!=null,"Invalid second pivot index");let h=0;switch(r){case"keyboard":{{const m=e<0?d:u,f=n[m];ee(f,`Panel constraints not found for index ${m}`);const{collapsedSize:b=0,collapsible:y,minSize:S=0}=f;if(y){const x=a[m];if(ee(x!=null,`Previous layout not found for panel index ${m}`),ie(x,b)){const T=S-x;ve(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}{const m=e<0?u:d,f=n[m];ee(f,`No panel constraints found for index ${m}`);const{collapsedSize:b=0,collapsible:y,minSize:S=0}=f;if(y){const x=a[m];if(ee(x!=null,`Previous layout not found for panel index ${m}`),ie(x,S)){const T=x-b;ve(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}break}default:{const m=e<0?d:u,f=n[m];ee(f,`Panel constraints not found for index ${m}`);const b=a[m],{collapsedSize:y,collapsedThreshold:S,collapsible:x,minSize:T}=f;if(x&&ve(b,T)<0){const E=T-y,j=S??E/2,k=b+Math.abs(e);if(ve(k,T)<0){const I=ve(Math.abs(e),j),R=S===void 0&&e<0;I>0||I===0&&R?e=e<0?-E:E:e=0}}break}}{const m=e<0?1:-1;let f=e<0?d:u,b=0;for(;;){const S=a[f];ee(S!=null,`Previous layout not found for panel index ${f}`);const T=Ye({overrideDisabledItems:i,itemConstraints:n[f],prevSize:S,size:100})-S;if(b+=T,f+=m,f<0||f>=n.length)break}const y=Math.min(Math.abs(e),Math.abs(b));e=e<0?0-y:y}{let f=e<0?u:d;for(;f>=0&&f<n.length;){const b=Math.abs(e)-Math.abs(h),y=a[f];ee(y!=null,`Previous layout not found for panel index ${f}`);const S=y-b,x=Ye({overrideDisabledItems:i,itemConstraints:n[f],prevSize:y,size:S});if(!ie(y,x)&&(h+=y-x,c[f]=x,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(ur(l,c))return s;{const m=e<0?d:u,f=a[m];ee(f!=null,`Previous layout not found for panel index ${m}`);const b=f+h,y=Ye({overrideDisabledItems:i,itemConstraints:n[m],prevSize:f,size:b});if(c[m]=y,!ie(y,b)){let S=b-y,T=e<0?d:u;for(;T>=0&&T<n.length;){const E=c[T];ee(E!=null,`Previous layout not found for panel index ${T}`);const j=E+S,k=Ye({overrideDisabledItems:i,itemConstraints:n[T],prevSize:E,size:j});if(ie(E,k)||(S-=k-E,c[T]=k),ie(S,0))break;e>0?T--:T++}}}const g=Object.values(c).reduce((m,f)=>f+m,0);return ie(g,100,.1)?c.reduce((m,f,b)=>(m[n[b].itemId]=f,m),{}):s}function Ie(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||ve(e[n],t[n])!==0)return!1;return!0}function zn(e){Ht();try{dr(e)}finally{Vt()}}function dr({commit:e,event:t,hitRegions:n,initialLayoutMap:o,mountedAxes:s,pointerDownAtPoint:r,prevCursorFlags:i}){let a=0;const l=ye();let c=l.state==="active"?l.previews:[];const u=new Map(l.state==="active"?l.previewLayoutMap:void 0);n.forEach(g=>{const{axis:m,axisSize:f}=g,{orientation:b,items:y}=m;if(e&&m.resizePreviewMode!=="separator")return;const{disableCursor:S}=m.mutableState;let x=0;r?b==="horizontal"?x=(t.clientX-r.x)/f*100:x=(t.clientY-r.y)/f*100:b==="horizontal"?x=t.clientX<0?-100:100:x=t.clientY<0?-100:100;const T=o.get(m),E=s.get(m);if(!T||!E)return;const{defaultLayoutDeferred:j,derivedItemConstraints:k,axisSize:I,layout:R,separatorToItems:v}=E;if(k&&R&&v){const C=m.resizePreviewMode==="separator"?u.get(m)??R:R,M=gt({delta:x,initialLayout:T,itemConstraints:k,pivotIndices:g.items.map(N=>y.indexOf(N)),prevLayout:C,trigger:"mouse-or-touch"});if(m.resizePreviewMode==="separator"&&!e&&!Ie(M,C)){u.set(m,M);let N=0;const V=y.map(D=>(N+=M[D.id]-T[D.id],N*(f/100)));c=c.map(D=>{if(D.axis!==m)return D;const K=V[D.itemIndex];return K===D.offset?D:{...D,offset:K}})}if(Ie(M,C)&&x!==0&&!S)switch(b){case"horizontal":{a|=x<0?No:Go;break}case"vertical":{a|=x<0?Fo:Bo;break}}(m.resizePreviewMode!=="separator"||e)&&!Ie(M,R)&&Oe(g.axis,{defaultLayoutDeferred:j,derivedItemConstraints:k,axisSize:I,layout:M,requestedAxisSize:I,requestedLayout:M,separatorToItems:v})}});let d=0;t.movementX===0?d|=i&Jn:d|=a&Jn,t.movementY===0?d|=i&Zn:d|=a&Zn;const h=l.state==="active"&&(t.clientX!==l.pointerDownAtPoint.x||t.clientY!==l.pointerDownAtPoint.y);Xs(d,c,u,h)}function Vo(e,t){const n=ye();if(n.state!=="active"||!yt(n,e,t))return;const o=$e();Ht();try{zn({commit:!0,event:t,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:o,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:n.cursorFlags}),wn(),De({cursorFlags:0,state:"inactive"}),n.hitRegions.length>0&&(t.preventDefault?.(),n.hitRegions.forEach(s=>{if(!o.has(s.axis))return;const r=be(s.axis.id,!0);Oe(s.axis,r,{isUserInteraction:!0})}))}finally{Vt()}}function oo(e){if(e.defaultPrevented)return;const{clientX:t,clientY:n,movementX:o,movementY:s}=e;Vo(e.currentTarget,{clientX:t,clientY:n,movementX:o,movementY:s})}function fr(e,t,n){let o,s={x:1/0,y:1/0};for(const r of t){const i=Wo(n,r.rect);switch(e){case"horizontal":{(i.x<s.x||i.x===s.x&&i.y<=s.y)&&(o=r,s=i);break}case"vertical":{(i.y<s.y||i.y===s.y&&i.x<=s.x)&&(o=r,s=i);break}}}return o?{distance:s,hitRegion:o}:void 0}function _o(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function pr(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:io(e),b:io(t)};let o;for(;n.a.at(-1)===n.b.at(-1);)o=n.a.pop(),n.b.pop();ee(o,"Stacking order can only be calculated for elements with a common ancestor");const s={a:ro(so(n.a)),b:ro(so(n.b))};if(s.a===s.b){const r=o.childNodes,i={a:n.a.at(-1),b:n.b.at(-1)};let a=r.length;for(;a--;){const l=r[a];if(l===i.a)return 1;if(l===i.b)return-1}}return Math.sign(s.a-s.b)}const mr=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function hr(e){const t=getComputedStyle(qo(e)??e).display;return t==="flex"||t==="inline-flex"}function gr(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||hr(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||mr.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function so(e){let t=e.length;for(;t--;){const n=e[t];if(ee(n,"Missing node"),gr(n))return n}return null}function ro(e){return e&&Number(getComputedStyle(e).zIndex)||0}function io(e){const t=[];for(;e;)t.push(e),e=qo(e);return t}function qo(e){const{parentNode:t}=e;return _o(t)?t.host:t}function br(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function yr(e){try{return e.matches(":modal")}catch{return!1}}function vr({axisElement:e,hitRegion:t,pointerEventTarget:n}){if(xe(n)){const o=n.closest("dialog");if(o&&!o.contains(e)&&yr(o))return!1}if(!xe(n)||n.contains(e)||e.contains(n)||!n.isConnected||!e.isConnected)return!0;if(pr(n,e)>0){let o=n;for(;o;){if(o.contains(e))return!0;if(br(o.getBoundingClientRect(),t))return!1;o=o.parentElement}}return!0}function Cn(e,t,n){const o=[];return t.forEach((s,r)=>{if(r.disabled||r.element.ownerDocument!==n)return;const i=bn({axis:r}),a=fr(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&vr({axisElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&o.push(a.hitRegion)}),o}function Uo(e){let t=0,n=0;const o={};for(const r of e)if(r.defaultSize!==void 0){t++;const i=fe(r.defaultSize);n+=i,o[r.itemId]=i}else o[r.itemId]=void 0;const s=e.length-t;if(s!==0){const r=fe((100-n)/s);for(const i of e)i.defaultSize===void 0&&(o[i.itemId]=r)}return o}function Sr(e,t){const n=e.map(s=>s.id),o=Object.keys(t);if(n.length!==o.length)return!1;for(const s of n)if(!o.includes(s))return!1;return!0}function Ko({axis:e,itemConstraints:t}){const n=e.items.map(({id:s})=>s).join(","),o=e.mutableState.defaultLayout;return e.mutableState.layouts[n]??(o&&Sr(e.items,o)?o:Uo(t))}function Tn(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const o in e)if(e[o]!==t[o])return!1;return!0}function xr(e,t){return e.length!==t.length?!1:e.every((n,o)=>Tn(n,t[o]))}function He({layout:e,itemConstraints:t}){const n=t.map(({itemId:i})=>e[i]),o=[...n],s=o.reduce((i,a)=>i+a,0);if(Object.keys(e).length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${Object.values(e).map(i=>`${i}%`).join(", ")}`);if(!ie(s,100)&&o.length>0)for(let i=0;i<t.length;i++){const a=o[i];ee(a!=null,`No layout data found for index ${i}`);const l=100/s*a;o[i]=l}let r=0;for(let i=0;i<t.length;i++){const a=n[i];ee(a!=null,`No layout data found for index ${i}`);const l=o[i];ee(l!=null,`No layout data found for index ${i}`);const c=Ye({overrideDisabledItems:!0,itemConstraints:t[i],prevSize:a,size:l});l!=c&&(r+=l-c,o[i]=c)}if(!ie(r,0))for(let i=0;i<t.length;i++){const a=o[i];ee(a!=null,`No layout data found for index ${i}`);const l=a+r,c=Ye({overrideDisabledItems:!0,itemConstraints:t[i],prevSize:a,size:l});if(a!==c&&(r-=c-a,o[i]=c,ie(r,0)))break}return o.reduce((i,a,l)=>(i[t[l].itemId]=a,i),{})}function Yo({itemIds:e,layout:t}){return He({layout:t,itemConstraints:e.map(n=>({collapsedSize:0,collapsible:!1,defaultSize:void 0,disabled:void 0,itemId:n,maxSize:100,minSize:0}))})}function wr({axis:e,nextAxisSize:t,prevAxisSize:n,prevLayout:o}){if(n<=0||t<=0||n===t)return o;let s=0,r=0,i=!1;const a=new Map,l=[];for(const d of e.items){const h=o[d.id]??0;switch(d.constraintProps.groupResizeBehavior){case"preserve-pixel-size":{i=!0;const g=h/100*n,m=fe(g/t*100);a.set(d.id,m),s+=m;break}case"preserve-relative-size":default:{l.push(d.id),r+=h;break}}}if(!i||l.length===0)return o;const c=100-s,u={...o};if(a.forEach((d,h)=>{u[h]=d}),r>0)for(const d of l){const h=o[d]??0;u[d]=fe(h/r*c)}else{const d=fe(c/l.length);for(const h of l)u[h]=d}return u}function In({axis:e,axisState:t}){const n=bt({axis:e});if(n===0)return;const o=Sn(e,n);let s=t.requestedAxisSize,r=t.requestedLayout;t.defaultLayoutDeferred&&(s=n,r=Yo({itemIds:e.items.map(({id:c})=>c),layout:Ko({axis:e,itemConstraints:o})}));const i=wr({axis:e,nextAxisSize:n,prevAxisSize:s,prevLayout:r}),a=He({layout:i,itemConstraints:o});return{changed:t.defaultLayoutDeferred||!Ie(t.layout,a)||!xr(t.derivedItemConstraints,o)||t.axisSize!==n,state:{defaultLayoutDeferred:!1,derivedItemConstraints:o,axisSize:n,layout:a,requestedAxisSize:s,requestedLayout:r,separatorToItems:t.separatorToItems}}}function Rn({axisId:e,itemId:t}){const n=()=>{const c=$e();for(const[u,d]of c)if(u.id===e)return{axis:u,...d};throw Error(`Group ${e} not found`)},o=()=>{const c=n().derivedItemConstraints.find(u=>u.itemId===t);if(c!==void 0)return c;throw Error(`Panel constraints not found for Panel ${t}`)},s=()=>{const{axis:c,...u}=n(),d=In({axis:c,axisState:u}),h=d?.state??u,g=h.derivedItemConstraints.find(f=>f.itemId===t);if(g===void 0)throw Error(`Panel constraints not found for Panel ${t}`);const m=h.layout[t];if(m===void 0)throw Error(`Layout not found for Panel ${t}`);return{axis:c,changed:d?.changed===!0,itemConstraints:g,itemSize:m,state:h}},r=()=>{const c=n().axis.items.find(u=>u.id===t);if(c!==void 0)return c;throw Error(`Layout not found for Panel ${t}`)},i=()=>{const c=n().layout[t];if(c!==void 0)return c;throw Error(`Layout not found for Panel ${t}`)},a=({allowPartialSize:c=!1,nextSize:u,items:d,prevLayout:h,derivedItemConstraints:g})=>{const m=h[t],f=d.findIndex(v=>v.id===t),b=f===0,y=f===d.length-1;if(y&&u<m&&(b||d.slice(0,f).every((v,C)=>{const M=g[C];return M?.collapsible&&ie(M.collapsedSize,h[M.itemId])}))){const v=d.slice(0,f).reduce((C,M)=>C+h[M.id],0);return{...h,[t]:fe(100-v)}}const x=g[f],T=Ye({overrideDisabledItems:!0,itemConstraints:x,prevSize:m,size:u}),E={...h};let j=T-m;for(const v of b?[1]:y?[-1]:[1,-1])for(let C=f+v;C>=0&&C<d.length&&!ie(j,0);C+=v){const M=g[C],N=E[M.itemId];if(Nt(M,E)||(j>0?ve(N,M.minSize)<=0:ve(N,M.maxSize)>=0))continue;const V=j>0?Math.max(M.minSize,N-j):Math.min(M.maxSize,N-j);j-=N-V,E[M.itemId]=fe(V)}if(E[t]=fe(T-j),ie(j,0)||c&&ve(E[t],x.minSize)>=0)return E;const k=(v,C,M)=>{const N=v==="after"?1:-1,V=K=>{for(let H=f+N;H>=0&&H<d.length;H+=N){const W=g[H];if(!Nt(W,C)&&K(W))return H}},D=V(({itemId:K,maxSize:H,minSize:W})=>M>0?ve(C[K],W)>0:ve(C[K],H)<0)??V(()=>!0)??f+N;return gt({delta:v==="after"?M:-M,initialLayout:C,itemConstraints:g,pivotIndices:v==="after"?[f,D]:[D,f],prevLayout:C,trigger:"imperative-api"})};if(b||y)return k(y?"before":"after",h,u-m);const I=v=>{const C=k(v,h,u-m),M=u-C[t];return ie(M,0)?C:k(v==="after"?"before":"after",C,M)},R=I("after");if(ao({itemConstraints:g,itemId:t,nextLayout:R,prevLayout:h})){const v=I("before");if(!ao({itemConstraints:g,itemId:t,nextLayout:v,prevLayout:h}))return v}return R},l=(c,{axis:u,changed:d,itemSize:h,state:g},{allowPartialSize:m=!1}={})=>{if(c===h)return;const{derivedItemConstraints:f,axisSize:b,layout:y}=g,S=a({allowPartialSize:m,nextSize:c,items:u.items,prevLayout:y,derivedItemConstraints:f}),x=He({layout:S,itemConstraints:f});(d||!Ie(y,x))&&Oe(u,{...g,layout:x,requestedAxisSize:b,requestedLayout:x})};return{collapse:()=>{const c=s(),{collapsible:u,collapsedSize:d}=c.itemConstraints,{mutableValues:h}=r(),g=c.itemSize;u&&g!==d&&(h.expandToSize=g,l(d,c))},expand:()=>{const c=s(),{collapsible:u,collapsedSize:d,minSize:h}=c.itemConstraints,{mutableValues:g}=r(),m=c.itemSize;if(u&&m===d){let f=g.expandToSize??h;f===0&&(f=1),l(f,c,{allowPartialSize:!0})}},getSize:()=>{const{axis:c}=n(),u=i(),{element:d}=r(),h=c.layoutStrategy?c.layoutStrategy.getItemSizeInPixels(t):c.orientation==="horizontal"?d.offsetWidth:d.offsetHeight;return{asPercentage:u,inPixels:h}},isCollapsed:()=>{const{collapsible:c,collapsedSize:u}=o(),d=i();return c&&ie(u,d)},resize:c=>{const u=s(),{axisSize:d}=u.state,{element:h}=r(),g=Ke({axisSize:d,itemElement:h,styleProp:c}),m=fe(g/d*100);l(m,u)}}}function Nt({collapsedSize:e,collapsible:t,itemId:n},o){return t&&ie(o[n],e)}function ao({itemConstraints:e,itemId:t,nextLayout:n,prevLayout:o}){return e.some(s=>s.itemId!==t&&Nt(s,o)!==Nt(s,n))}function co(e){if(e.defaultPrevented)return;const t=$e();Cn(e,t,e.currentTarget).forEach(o=>{if(o.separator&&!o.separator.disableDoubleClick){const s=o.items.find(r=>r.constraintProps.defaultSize!==void 0);if(s){const r=s.constraintProps.defaultSize,i=Rn({axisId:o.axis.id,itemId:s.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Xo(e){const t=$e();for(const[n]of t)if(n.separators.some(o=>o.element===e))return n;throw Error("Could not find parent Group for separator element")}function mt({axisId:e}){const t=()=>{const n=$e();for(const[o,s]of n)if(o.id===e)return{axis:o,...s};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:o}=t();return n?{}:o},setLayout(n){const{axis:o,...s}=t(),r=In({axis:o,axisState:s}),i=r?.state??s,{defaultLayoutDeferred:a,derivedItemConstraints:l,axisSize:c,layout:u}=i,d=He({layout:n,itemConstraints:l});return a?u:((r?.changed||!Ie(u,d))&&Oe(o,{...i,layout:d,requestedAxisSize:c,requestedLayout:d}),d)}}}function Ue(e,t){const n=Xo(e),o=be(n.id,!0),s=n.separators.find(d=>d.element===e);ee(s,"Matching separator not found");const r=o.separatorToItems.get(s);ee(r,"Matching panels not found");const i=r.map(d=>n.items.indexOf(d)),l=mt({axisId:n.id}).getLayout(),c=gt({delta:t,initialLayout:l,itemConstraints:o.derivedItemConstraints,pivotIndices:i,prevLayout:l,trigger:"keyboard"}),u=He({layout:c,itemConstraints:o.derivedItemConstraints});Ie(l,u)||Oe(n,{defaultLayoutDeferred:o.defaultLayoutDeferred,derivedItemConstraints:o.derivedItemConstraints,axisSize:o.axisSize,layout:u,requestedAxisSize:o.axisSize,requestedLayout:u,separatorToItems:o.separatorToItems},{isUserInteraction:!0})}function zr(e){return e.separators.filter(t=>!t.disabled)}function lo(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Xo(t);if(!(n.disabled||n.separators.find(s=>s.element===t)?.disabled))switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Ue(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Ue(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Ue(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Ue(t,-5);break}case"End":{e.preventDefault(),Ue(t,100);break}case"Enter":{e.preventDefault();const s=be(n.id,!0),{derivedItemConstraints:r,layout:i,separatorToItems:a}=s,l=n.separators.find(h=>h.element===t);ee(l,"Matching separator not found");const c=a.get(l);ee(c,"Matching panels not found");const u=c[0],d=r.find(h=>h.itemId===u.id);if(ee(d,"Panel metadata not found"),d.collapsible){const h=i[u.id],g=d.collapsedSize===h?n.mutableState.expandedItemSizes[u.id]??d.minSize:d.collapsedSize;Ue(t,g-h)}break}case"F6":{e.preventDefault();const s=zr(n).map(l=>l.element),r=s.findIndex(l=>l===e.currentTarget);ee(r!==-1,"Index not found");const i=e.shiftKey?r>0?r-1:s.length-1:r+1<s.length?r+1:0;s[i].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Ue(t,-100);break}}}function ct(e,t){const n=ye();if(n.state!=="active"||!yt(n,e,t))return!1;const o=$e();Ht();try{n.previewLayoutMap.forEach((s,r)=>{const i=o.get(r);r.resizePreviewMode==="separator"&&i&&!Ie(s,i.layout)&&Oe(r,{...i,layout:s,requestedAxisSize:i.axisSize,requestedLayout:s})}),wn(),De({cursorFlags:0,state:"inactive"}),n.hitRegions.forEach(s=>{if(!o.has(s.axis))return;const r=be(s.axis.id,!0);Oe(s.axis,r,{isUserInteraction:!0})})}finally{Vt()}return!0}function uo(e){const t=ye();if(t.state!=="active")return;const n=t.hitRegions.flatMap(({separator:o})=>o?[o.element]:[]);!n.some(o=>o===e.target)||n.some(o=>o.hasPointerCapture?.(e.pointerId))||ct(e.currentTarget,e)}function fo(e){ct(e.currentTarget,e)}function Cr(e,t){const{element:n,orientation:o,items:s}=e,r=n.getBoundingClientRect(),i=o==="horizontal";return bn({expandHitTargets:!1,axis:e,includeDisabled:!0}).map(({items:l,rect:c,separator:u},d)=>{const h=s.indexOf(l[0]),g=i?c.left+c.width/2:c.top+c.height/2;return{active:t.some(f=>{if(f.axis!==e||f.items[0]!==l[0])return!1;if(u||f.separator)return f.separator===u;const b=i?f.rect.left+f.rect.width/2:f.rect.top+f.rect.height/2;return ie(g,b)}),axis:e,key:u?`separator-${u.id}`:`panel-${l[0].id}-${d}`,offset:0,itemIndex:h,rect:new DOMRect((i&&!u?g:c.left)-r.left-n.clientLeft+n.scrollLeft,(!i&&!u?g:c.top)-r.top-n.clientTop+n.scrollTop,i&&!u?0:c.width,!i&&!u?0:c.height),separator:u}})}function po(e){if(e.defaultPrevented)return;if(e.pointerType==="mouse"&&e.button>0)return;const t=ye();if(t.state==="active"){Ho(t,e)&&ct(t.ownerDocument,t);return}const n=$e(),o=Cn(e,n,e.currentTarget);if(o.length===0)return;const s=new Map;let r=!1;o.forEach(a=>{a.separator&&(r||(r=!0,a.separator.element.focus({focusVisible:!1,preventScroll:!0})));const l=n.get(a.axis);l&&s.set(a.axis,l.layout)});const i=Array.from(s.keys()).flatMap(a=>a.resizePreviewMode==="separator"?Cr(a,o):[]);De({cursorFlags:0,didPointerMove:!1,hitRegions:o,initialLayoutMap:s,ownerDocument:e.currentTarget,pointerDownAtPoint:{x:e.clientX,y:e.clientY},pointerId:e.pointerId,pointerType:e.pointerType,previewLayoutMap:new Map(s),previews:i,state:"active"}),e.preventDefault()}function mo(e){const t=e.currentTarget,n=$e(),o=ye();switch(o.state){case"active":{if(!yt(o,t,e))return;zn({commit:!1,event:e,hitRegions:o.hitRegions,initialLayoutMap:o.initialLayoutMap,mountedAxes:n,prevCursorFlags:o.cursorFlags})}}}function ho(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=ye(),o=$e();switch(n.state){case"active":{if(!yt(n,t,e))return;if(e.buttons===0){ct(t,e);return}for(const s of n.hitRegions)if(s.separator){const{element:r}=s.separator;r.isConnected&&!r.hasPointerCapture?.(e.pointerId)&&r.setPointerCapture?.(e.pointerId)}zn({commit:!1,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:o,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:n.cursorFlags});break}default:{const s=Cn(e,o,t);s.length===0?n.state!=="inactive"&&De({cursorFlags:0,state:"inactive"}):De({cursorFlags:0,hitRegions:s,ownerDocument:t,state:"hover"});break}}}function go(e){const t=e.relatedTarget;if(xe(t)&&t.localName==="iframe"){const n=ye();switch(n.state){case"hover":n.ownerDocument===e.currentTarget&&De({cursorFlags:0,state:"inactive"})}}}function bo(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||Vo(e.currentTarget,e)}function yo(e){e.target===e.currentTarget&&ct(e.currentTarget.document)}function vo(e){ct(e.currentTarget.document)}function Tr(e,t,n){if(!n[0])return;const s=e.items.find(c=>c.element===t);if(!s||!s.onResize)return;const r=bt({axis:e}),i=e.orientation==="horizontal"?s.element.offsetWidth:s.element.offsetHeight,a=s.mutableValues.prevSize,l={asPercentage:fe(i/r*100),inPixels:i};s.mutableValues.prevSize=l,s.onResize(l,s.id,a)}const tt=new Map;let So=!1;function Jo(e){let t=!0;ee(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,o=new Set,s=new Set,r=new n(m=>{let f;Ht();try{for(const b of m){const{borderBoxSize:y,target:S}=b;if(S===e.element){if(t){const x=be(e.id);if(!x)break;const T=In({axis:e,axisState:x});if(!T)break;if(!T.changed)continue;Oe(e,T.state)}}else try{Tr(e,S,y)}catch(x){f??={error:x}}}}finally{Vt()}if(f)throw f.error});r.observe(e.element),e.items.forEach(m=>{ee(!o.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),o.add(m.id),m.onResize&&r.observe(m.element)});const i=bt({axis:e}),a=Sn(e,i),l=Ko({axis:e,itemConstraints:a}),c=He({layout:l,itemConstraints:a}),u=e.element.ownerDocument,d=u.defaultView;tt.set(u,(tt.get(u)??0)+1);const h=new Map;return bn({axis:e,includeDisabled:!0}).forEach(m=>{m.separator&&h.set(m.separator,m.items)}),Oe(e,{defaultLayoutDeferred:i===0,derivedItemConstraints:a,axisSize:i,layout:c,requestedAxisSize:i,requestedLayout:Yo({itemIds:e.items.map(({id:m})=>m),layout:l}),separatorToItems:h}),e.separators.forEach(m=>{ee(!s.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),s.add(m.id),m.element.addEventListener("keydown",lo)}),So||(So=!0,Wt(tr)),tt.get(u)===1&&(u.addEventListener("contextmenu",oo,!0),u.addEventListener("dblclick",co,!0),u.addEventListener("lostpointercapture",uo,!0),u.addEventListener("pointercancel",fo,!0),u.addEventListener("pointerdown",po,!0),u.addEventListener("pointerleave",mo),u.addEventListener("pointermove",ho),u.addEventListener("pointerout",go),u.addEventListener("pointerup",bo,!0),d?.addEventListener("blur",yo),d?.addEventListener("pagehide",vo)),function(){t=!1,tt.set(u,Math.max(0,(tt.get(u)??0)-1)),lr(e),Zs(e),e.separators.forEach(f=>{f.element.removeEventListener("keydown",lo)}),tt.get(u)||(u.removeEventListener("contextmenu",oo,!0),u.removeEventListener("dblclick",co,!0),u.removeEventListener("lostpointercapture",uo,!0),u.removeEventListener("pointercancel",fo,!0),u.removeEventListener("pointerdown",po,!0),u.removeEventListener("pointerleave",mo),u.removeEventListener("pointermove",ho),u.removeEventListener("pointerout",go),u.removeEventListener("pointerup",bo,!0),d?.removeEventListener("blur",yo),d?.removeEventListener("pagehide",vo)),r.disconnect()}}function Zo({derivedItemConstraints:e,axis:t,layout:n,prevLayout:o,requestedLayout:s}){const r=t.items.map(({id:i})=>i).join(",");t.mutableState.layouts[r]=s,o&&e.forEach(i=>{if(i.collapsible){const a=ie(i.collapsedSize,n[i.itemId]),l=ie(i.collapsedSize,o[i.itemId]);a&&!l&&(t.mutableState.expandedItemSizes[i.itemId]=o[i.itemId])}})}function Qo(){const[e,t]=p.useState({}),n=p.useCallback(()=>t({}),[]);return[e,n]}function _t(e){const t=p.useRef({...e});return ne(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const Ln=p.createContext(null),ot=["column","row"],qt=p.createContext(null);function Ir({layout:e,itemConstraints:t,itemId:n,itemIndex:o}){let s,r;const i=e[n],a=t.find(l=>l.itemId===n);if(a){const l=a.maxSize,c=a.collapsible?a.collapsedSize:a.minSize,u=[o,o+1];r=He({layout:gt({delta:c-i,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n],s=He({layout:gt({delta:l-i,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n]}return{valueControls:n,valueMax:s,valueMin:r,valueNow:i}}function es({attributes:e,axisId:t,axisOrientation:n,children:o,className:s,"data-testid":r,disableCursor:i,disabled:a,disableDoubleClick:l,elementRef:c,id:u,isSharedHitRegion:d,preview:h,registerSeparator:g,requiredStyle:m,style:f,styleDefaults:b,tabIndex:y=0,updateSeparatorProps:S}){const x=_t({disabled:a,disableDoubleClick:l,children:o,className:s,preview:h,style:f}),[T,E]=p.useState({}),[j,k]=p.useState("inactive"),[I,R]=p.useState(!1),v=p.useRef(null),C=p.useRef(null),M=Ze(v,c),N=n==="horizontal"?"vertical":"horizontal";ne(()=>{const K=v.current;if(K!==null){const H={disabled:x.disabled,disableDoubleClick:x.disableDoubleClick,element:K,id:u,get children(){return x.children},get className(){return x.className},get preview(){return x.preview},get style(){return x.style}};C.current=H;const W=g(H),F=Wt(J=>{k(J.next.state!=="inactive"&&J.next.hitRegions.some(Y=>Y.separator===H||(d?.(Y)??!1))?J.next.state:"inactive")}),G=rt(t,J=>{const{derivedItemConstraints:Y,layout:re,separatorToItems:ue}=J.next,pe=ue.get(H);if(pe){const w=pe[0],_=Y.findIndex(L=>L.itemId===w.id),{layoutStrategy:q}=J.axis;E({...Ir({layout:re,itemConstraints:Y,itemId:w.id,itemIndex:_}),...q?.getItemAriaControls&&{valueControls:q.getItemAriaControls(w.id)}})}});return()=>{C.current=null,F(),G(),W()}}},[t,u,d,g,x]),ne(()=>{const K=C.current;K&&Js(K)},[h]),p.useEffect(()=>{S(u,{disabled:a,disableDoubleClick:l})},[a,l,u,S]);let V;a&&!i&&(V="not-allowed");let D;if(a)D="disabled";else switch(j){case"active":{D="active";break}default:I?D="focus":D=j}return O.jsx("div",{...e,"aria-controls":T.valueControls,"aria-disabled":a||void 0,"aria-orientation":N,"aria-valuemax":T.valueMax,"aria-valuemin":T.valueMin,"aria-valuenow":T.valueNow,children:o,className:s,"data-separator":D,"data-testid":r,id:u,onBlur:()=>R(!1),onFocus:()=>R(!0),ref:M,role:"separator",style:{...b,cursor:V,...f,...m,touchAction:"none"},tabIndex:a?void 0:y})}function xo({axis:e,children:t,className:n,crossSpan:o,crossStart:s,disabled:r,elementRef:i,index:a,style:l}){const c=Je(void 0),{getDisableCursor:u,getResizeAxisId:d,gutters:h,registerSeparator:g,separatorPlacements:m,trackCounts:f,updateSeparatorProps:b}=$o(),y=d(e),S=e==="column"?"row":"column",x=f[S],T=!!r||!pn(a,f[e]);let E=!0;for(const v of m.values())if(v.axis===e&&v.index===a&&!v.disabled&&v.crossStart<s){E=!1;break}const j=p.useCallback(v=>v.axis.id===y&&v.axis.items.indexOf(v.items[1])===a,[y,a]),k=p.useCallback(v=>g({axis:e,crossSpan:o,crossStart:s,disabled:!!r,index:a},v),[e,o,s,r,a,g]),I=Vs(a),R=_s({crossCount:x,crossSpan:o,crossStart:s,hasGutters:h[S]});return O.jsx(es,{axisId:y,axisOrientation:e==="column"?"horizontal":"vertical",className:n,disableCursor:u(),disabled:T,disableDoubleClick:void 0,elementRef:i,id:c,isSharedHitRegion:j,registerSeparator:k,requiredStyle:{gridColumn:e==="column"?I:R,gridRow:e==="row"?I:R},style:l,tabIndex:E?0:-1,updateSeparatorProps:b,children:t})}function Rr(e){const{children:t,className:n,disabled:o,elementRef:s,style:r}=e;return e.type==="column"?O.jsx(xo,{axis:"column",className:n,crossSpan:e.rowSpan,crossStart:e.row??0,disabled:o,elementRef:s,index:e.column,style:r,children:t}):O.jsx(xo,{axis:"row",className:n,crossSpan:e.columnSpan,crossStart:e.column??0,disabled:o,elementRef:s,index:e.row,style:r,children:t})}const ts=Object.assign(Rr,{displayName:"Gridline"});function ns(e,t){p.Children.forEach(e,n=>{if(p.isValidElement(n))if(n.type===ts){const{type:o}=n.props;o==="column"?t.column=!0:o==="row"&&(t.row=!0)}else typeof n.type=="symbol"&&n.props!==null&&typeof n.props=="object"&&"children"in n.props&&ns(n.props.children,t)})}function Lr(e,t){if(t)return e.map(r=>`minmax(0, ${t[r.id]??1}fr)`);const n=e.map(r=>r.defaultSize===void 0?void 0:vn(r.defaultSize));let o=100,s=0;return n.forEach(r=>{r===void 0?s++:r[1]==="%"&&(o-=r[0])}),n.map(r=>{if(r===void 0)return`minmax(0, ${Math.max(0,o)/Math.max(1,s)}fr)`;const[i,a]=r;return a==="%"?`minmax(0, ${i}fr)`:`${i}${a}`})}function Pr({cells:e,separatorPlacements:t,trackCounts:n}){const o=[];for(const a of e)ot.forEach(l=>{const[c,u]=l==="column"?[a.column,a.columnSpan]:[a.row,a.rowSpan],d=n[l];(!Number.isInteger(c)||!Number.isInteger(u)||c<0||u<1||c+u>d)&&o.push(`Invalid Cell ${l} placement (${l}: ${c}, ${l}Span: ${u}); Grid has ${d} ${l}s`)});const s=({axis:a,crossSpan:l,crossStart:c,disabled:u,index:d})=>{const h=a==="column"?"row":"column";let g=`type="${a}" ${a}={${d}}`;return(c!==0||l!==void 0)&&(g+=` ${h}={${c}}`),l!==void 0&&(g+=` ${h}Span={${l}}`),u&&(g+=" disabled"),`<Gridline ${g} />`},r=Array.from(t.values()).filter(a=>{const{axis:l,crossSpan:c,crossStart:u,index:d}=a,h=l==="column"?"row":"column",g=n[l],m=n[h];let f=!0;return pn(d,g)||(o.push(`Invalid ${l} Gridline ${l} (${d}); must be between 1 and ${g-1}`),f=!1),!Number.isInteger(u)||u<0||u>=m?(o.push(`Invalid ${l} Gridline ${h} (${u}); must be between 0 and ${m-1}`),f=!1):c!==void 0&&(!Number.isInteger(c)||c<1||u+c>m)&&(o.push(`Invalid ${l} Gridline ${h}Span (${c}); Grid has ${m} ${h}s`),f=!1),f}),i=a=>{const l=n[a.axis==="column"?"row":"column"];return[a.crossStart,a.crossSpan===void 0?l:a.crossStart+a.crossSpan]};return r.forEach((a,l)=>{const{axis:c,index:u}=a,[d,h]=i(a);for(const g of e){const[m,f,b,y]=c==="column"?[g.column,g.columnSpan,g.row,g.rowSpan]:[g.row,g.rowSpan,g.column,g.columnSpan];if(m<u&&u<m+f&&b<h&&d<b+y){const S=c==="column"?"row":"column";o.push(`${s(a)} overlaps a Cell that spans across it (${c}: ${m}, ${c}Span: ${f}, ${S}: ${b}, ${S}Span: ${y}); use the ${S} and ${S}Span props to render gridlines beside the Cell instead`)}}for(const g of r.slice(l+1))if(g.axis===c&&g.index===u){const[m,f]=i(g);m<h&&d<f&&o.push(`${s(a)} overlaps ${s(g)}`)}}),o}function wo(e,t){return Ie(e.columns,t.columns)&&Ie(e.rows,t.rows)}const zo={columns:{},rows:{}};function Mr({children:e,className:t,columns:n,defaultLayout:o,disableCursor:s,disabled:r,elementRef:i,gridRef:a,id:l,onLayoutChange:c,onLayoutChanged:u,resizeTargetMinimumSize:d={coarse:20,fine:10},rows:h,style:g,...m}){const f=Je(l),b=p.useCallback(L=>L==="column"?`${f}:columns`:`${f}:rows`,[f]),y=Co(n,"columns"),S=Co(h,"rows"),x=L=>L==="column"?y:S,T=p.useRef({onLayoutChange:zo,onLayoutChanged:zo}),E=Ce(L=>{wo(T.current.onLayoutChange,L)||(T.current.onLayoutChange=L,c?.(L))}),j=Ce((L,A,$)=>{wo(T.current.onLayoutChanged,L)||(T.current.onLayoutChanged=L,u?.(L,{isUserInteraction:A,requestedLayout:$}))}),k=p.useRef(null),I=Ze(k,i),[R,v]=Qo(),C=p.useRef({cells:[],column:{expandedItemSizes:{},layouts:{}},loggedErrors:new Set,row:{expandedItemSizes:{},layouts:{}},separators:new Map}),M={column:!1,row:!1};for(const L of C.current.separators.values())M[L.axis]=!0;ns(e,M);const N=_t({defaultLayout:o,disableCursor:s,resizeTargetMinimumSize:d}),V=Ce(()=>!!N.disableCursor),D=p.useCallback(L=>{const A=C.current;return A.cells=[...A.cells,L],v(),()=>{A.cells=A.cells.filter($=>$!==L),v()}},[v]),K=p.useCallback((L,A)=>{const $=C.current;return $.separators=new Map($.separators),$.separators.set(A,L),v(),()=>{$.separators=new Map($.separators),$.separators.delete(A),v()}},[v]),H=p.useCallback((L,{disabled:A,disableDoubleClick:$})=>{for(const U of C.current.separators.keys())U.id===L&&(U.disabled=A,U.disableDoubleClick=$)},[]),W=C.current.separators,F=p.useMemo(()=>({getDisableCursor:V,getResizeAxisId:b,gutters:{column:M.column,row:M.row},id:f,registerCell:D,registerSeparator:K,separatorPlacements:W,trackCounts:{column:y.length,row:S.length},updateSeparatorProps:H}),[y.length,V,b,M.column,M.row,f,D,K,S.length,W,H]),G=p.useRef([]);ne(()=>{const L=k.current;if(L===null)return;const A=C.current,$=Pr({cells:A.cells,separatorPlacements:A.separators,trackCounts:{column:y.length,row:S.length}});$.forEach(Z=>{A.loggedErrors.has(Z)||console.error(Z)}),A.loggedErrors=new Set($);const U=Z=>Array.from(A.separators.entries()).filter(([,se])=>se.axis===Z).sort(([,se],[,ze])=>se.index-ze.index).map(([se])=>se),Q=Z=>{const se=Z==="column"?y:S,ze=Z==="column"?S:y,Te=se.map(me=>me.id),ge=b(Z),je=U(Z),Le=je.length>0,Ve=se.map(({id:me,...ae},he)=>({element:L,id:Te[he],idIsStable:!0,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:void 0,constraintProps:ae})),Me=()=>{const me=[];if(Le){for(const[ae,he]of A.separators)if(he.axis===Z&&pn(he.index,se.length)){const Fe=ae.element.getBoundingClientRect();me[he.index]=Math.max(me[he.index]??0,Z==="column"?Fe.width:Fe.height)}}return Ys({axis:Z,element:L,gutterSizes:me.filter(ae=>ae!==void 0),hasGutters:Le,layout:be(ge)?.layout,trackIds:Te})};let Ne;const Ge=N.defaultLayout?.[Z==="column"?"columns":"rows"];if(Ge!==void 0&&Object.keys(Ge).length===Te.length){Ne={};for(const me of Te){const ae=Ge[me];ae!==void 0&&(Ne[me]=ae)}}return{disabled:!!r,element:L,id:ge,layoutStrategy:{getItemAriaControls:me=>{const ae=Te.indexOf(me);return A.cells.filter(he=>{const Fe=Z==="column"?he.column:he.row,Be=Z==="column"?he.columnSpan:he.rowSpan;return Fe<=ae&&ae<Fe+Be}).map(he=>he.element.id).filter(Boolean).join(" ")||void 0},calculateAvailableSize:()=>Me().availableSize,calculateHitRegions:({expandHitTargets:me,axis:ae,includeDisabled:he})=>Ks({axis:Z,cells:A.cells,crossTrackCount:ze.length,expandHitTargets:me,resizeAxis:ae,axisSize:Me().availableSize*Ae(ae.element,ae.orientation),includeDisabled:he,separatorPlacements:A.separators}),getItemSizeInPixels:me=>Me().trackSizes[Te.indexOf(me)]??0},mutableState:{defaultLayout:Ne,disableCursor:!!N.disableCursor,expandedItemSizes:A[Z].expandedItemSizes,layouts:A[Z].layouts},orientation:Z==="column"?"horizontal":"vertical",items:Ve,resizePreviewMode:"panel",get resizeTargetMinimumSize(){return N.resizeTargetMinimumSize},separators:je}},X=ot.map(Q);G.current=X;const te=X.map(Z=>Jo(Z)),de=()=>{const[Z,se]=X.map(ze=>be(ze.id));if(!(!Z||!se||Z.defaultLayoutDeferred||se.defaultLayoutDeferred))return{layout:{columns:Z.layout,rows:se.layout},requestedLayout:{columns:Z.requestedLayout,rows:se.requestedLayout}}};{const Z=de();if(Z)try{try{E(Z.layout)}finally{j(Z.layout,!1,Z.requestedLayout)}}catch(se){throw G.current=[],te.forEach(ze=>ze()),se}}const we=X.map(Z=>rt(Z.id,se=>{const{defaultLayoutDeferred:ze,derivedItemConstraints:Te,layout:ge,requestedLayout:je}=se.next;if(ze||Te.length===0)return;Zo({derivedItemConstraints:Te,axis:Z,layout:ge,prevLayout:se.prev?.layout,requestedLayout:je});const Le=de();if(Le){const Ve=ye(),Me=Ve.state!=="active"||!Ve.hitRegions.some(Ne=>X.includes(Ne.axis));try{E(Le.layout)}finally{Me&&j(Le.layout,se.isUserInteraction,Le.requestedLayout)}}}));return()=>{G.current=[],te.forEach(Z=>Z()),we.forEach(Z=>Z())}},[y,r,b,f,j,E,S,R,N]),p.useEffect(()=>{G.current.forEach(L=>{L.mutableState.defaultLayout=o?.[L.orientation==="horizontal"?"columns":"rows"],L.mutableState.disableCursor=!!s})});const J=p.useMemo(()=>{const L=()=>{const[U,Q]=ot.map(b);return!st(U)||!st(Q)?{columns:{},rows:{}}:{columns:mt({axisId:U}).getLayout(),rows:mt({axisId:Q}).getLayout()}},A=U=>U.map(Q=>`"${Q}"`).join(", "),$=(U,Q)=>{const X=b(U),te=()=>{const de=st(X);return ee(de,`Grid "${f}" has not been mounted`),ee(de.items.some(we=>we.id===Q),`Grid "${f}" no longer contains a ${U} with id "${Q}"; ${U} ids are ${A(de.items.map(we=>we.id))}`),Rn({axisId:X,itemId:Q})};return{collapse:()=>te().collapse(),expand:()=>te().expand(),getSize:()=>te().getSize(),isCollapsed:()=>te().isCollapsed(),resize:de=>te().resize(de)}};return{getLayout:L,getTrackById:(U,Q)=>{const X=U==="column"?y:S,te=`${Q}`;return ee(X.some(de=>de.id===te),`Grid "${f}" does not contain a ${U} with id "${te}"; ${U} ids are ${A(X.map(de=>de.id))}`),$(U,te)},getTrackByIndex:(U,Q)=>{const X=U==="column"?y:S,te=Number.isInteger(Q)?X[Q]:void 0;return ee(te,`Grid "${f}" does not contain a ${U} at index ${Q}; it has ${X.length} ${U}s`),$(U,te.id)},setLayout:U=>(ot.forEach(Q=>{const X=U[Q==="column"?"columns":"rows"],te=b(Q);X&&st(te)&&mt({axisId:te}).setLayout(X)}),L())}},[y,b,f,S]);p.useImperativeHandle(a,()=>J,[J]);const Y=p.useRef(J);ne(()=>{Y.current=J});const re=p.useMemo(()=>({getLayout:()=>Y.current.getLayout(),getTrackById:(L,A)=>Y.current.getTrackById(L,A),getTrackByIndex:(L,A)=>Y.current.getTrackByIndex(L,A),id:f,setLayout:L=>Y.current.setLayout(L)}),[f]),ue=()=>ot.map(L=>{const A=be(b(L)),$=x(L);return(A&&!A.defaultLayoutDeferred?$.map(Q=>`minmax(0, ${A.layout[Q.id]??1}fr)`):Lr($,o?.[L==="column"?"columns":"rows"])).join(M[L]?" auto ":" ")}).join("|"),pe=p.useCallback(L=>{const A=ot.map($=>rt(b($),L));return()=>A.forEach($=>$())},[b]),w=p.useSyncExternalStore(pe,ue,ue),[_,q]=w.split("|");return O.jsx(Ao.Provider,{value:F,children:O.jsx("div",{...m,className:t,"data-grid":!0,"data-testid":at(m,l),id:f,ref:I,style:{height:"100%",width:"100%",overflow:"hidden",...g,display:"grid",gridTemplateColumns:_,gridTemplateRows:q,touchAction:"none"},children:O.jsx(Ln.Provider,{value:null,children:O.jsx(qt.Provider,{value:re,children:e})})})})}const kr=Object.assign(Mr,{displayName:"Grid"});function Co(e,t){const n=JSON.stringify(e);return p.useMemo(()=>{const o=typeof e=="number"?Array.from({length:e},(s,r)=>({id:`${r}`})):e.map((s,r)=>({...s,id:`${s.id??r}`}));return ee(o.length>0,`Grid must have at least one track; "${t}" is ${n}`),o},[n])}function Ut(){return()=>{}}function Er({id:e,onlySaveAfterUserInteractions:t,storage:n=localStorage}){const o=`react-resizable-panels:grid:${e}`,s=p.useSyncExternalStore(Ut,()=>n.getItem(o),()=>n.getItem(o)),r=p.useMemo(()=>{if(s)try{const a=JSON.parse(s);if(a!==null&&typeof a=="object")return a}catch{}},[s]),i=p.useCallback((a,l)=>{if(!(t&&!l.isUserInteraction))try{n.setItem(o,JSON.stringify(l.requestedLayout??a))}catch(c){console.error(c)}},[t,n,o]);return{defaultLayout:r,onLayoutChanged:i}}function Dr(){return p.useState(null)}function Or(){return p.useRef(null)}function Ar(){return p.useContext(qt)}function $r(e){for(let t=1;t<e.length;t++)if(gn(e[t-1],e[t])>0)return!1;return!0}function jr({separator:e}){const{element:t}=e,n=p.useRef(null);return ne(()=>{const o=t.cloneNode(!0),s=[t,...t.querySelectorAll("*")],r=[o,...o.querySelectorAll("*")],i=t.ownerDocument.defaultView;return s.forEach((a,l)=>{const c=r[l],{style:u}=c;if(u){const d=i.getComputedStyle(a);for(let h=0;h<d.length;h++){const g=d.item(h);u.setProperty(g,d.getPropertyValue(g))}}c.removeAttribute("data-testid"),c.removeAttribute("id")}),Object.assign(o.style,{boxSizing:"border-box",height:"100%",margin:"0",position:"static",transform:"none",width:"100%"}),n.current.appendChild(o),()=>o.remove()},[t]),O.jsx("div",{ref:n,style:{height:"100%",opacity:.65,pointerEvents:"none",width:"100%"}})}function Kt(){const e=p.useContext(Ln);return ee(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Nr(e){const{registerOverlay:t}=Kt(),n=p.useRef(e);Tn(n.current,e)||(n.current=e);const o=n.current;return ne(()=>t(o),[t,o]),null}const os=Object.assign(Nr,{displayName:"SeparatorOverlay"});function Gr({active:e,orientation:t,style:n,...o}){let s;switch(t){case"horizontal":{s={height:"100%",minWidth:"1px"};break}case"vertical":{s={minHeight:"1px",width:"100%"};break}}return O.jsx("div",{...o,"data-separator-overlay":e?"active":"inactive",style:{...s,...n,flexShrink:0,pointerEvents:"none"}})}function Fr({overlay:e,preview:t}){const{axis:n,offset:o,rect:s,separator:r}=t,i=n.orientation==="horizontal";let a=r?.preview,l=e;return p.isValidElement(a)&&a.type===os&&(l=a.props,a=void 0),a==null&&(l?a=O.jsx(Gr,{...l,active:t.active,orientation:n.orientation}):r&&(a=O.jsx(jr,{separator:r}))),O.jsx("div",{"aria-hidden":"true","data-resize-preview":!0,inert:!0,style:{height:s.height,left:s.left,pointerEvents:"none",position:"absolute",top:s.top,transform:i?`translateX(${o}px)`:`translateY(${o}px)`,width:s.width},children:a})}function Br(e){return Array.from(e).sort(gn)}const Yt=p.createContext(null);function Wr(e,t){const n=p.useRef({getLayout:()=>({}),setLayout:Qs});return p.useImperativeHandle(t,()=>n.current,[]),ne(()=>{Object.assign(n.current,mt({axisId:e}))}),n}function Hr({groupId:e,resizePreviewMode:t}){const[n,o]=p.useState([]),s=p.useRef(n);return ne(()=>{const r=a=>{const l=st(e),c=t==="separator"&&a.state==="active"?a.previews.filter(d=>d.axis===l&&(d.active||!ie(d.offset,0))):[],u=s.current;u.length===c.length&&c.every((d,h)=>d===u[h])||(s.current=c,o(c))};if(t!=="separator"){r(ye());return}const i=Wt(({next:a})=>r(a));return r(ye()),i},[e,t]),n}function Vr({children:e,className:t,defaultLayout:n,disableCursor:o,disabled:s,elementRef:r,groupRef:i,id:a,onLayoutChange:l,onLayoutChanged:c,orientation:u="horizontal",resizePreviewMode:d="panel",resizeTargetMinimumSize:h={coarse:20,fine:10},style:g,...m}){const f=p.useRef({onLayoutChange:{},onLayoutChanged:{}}),b=Ce(W=>{Ie(f.current.onLayoutChange,W)||(f.current.onLayoutChange=W,l?.(W))}),y=Ce((W,F,G)=>{Ie(f.current.onLayoutChanged,W)||(f.current.onLayoutChanged=W,c?.(W,{isUserInteraction:F,requestedLayout:G}))}),S=Je(a),[x,T]=p.useState(),E=Hr({groupId:S,resizePreviewMode:d}),j=p.useRef(null),[k,I]=Qo(),R=p.useRef([]),v=p.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],separators:[]}),C=Ze(j,r),M=Wr(S,i),N=p.useMemo(()=>({getLayout:()=>M.current.getLayout(),id:S,orientation:u,setLayout:W=>M.current.setLayout(W)}),[S,M,u]),V=Ce((W,F)=>{const G=be(W);if(G)return{flexGrow:G.layout[F]??1};if(n?.[F])return{flexGrow:n?.[F]}}),D=_t({defaultLayout:n,disableCursor:o,resizeTargetMinimumSize:h}),K=p.useMemo(()=>({get disableCursor(){return!!D.disableCursor},getPanelStyles:V,id:S,orientation:u,registerPanel:W=>{const F=v.current;return F.panels=ft(u,[...F.panels,W]),I(),()=>{F.panels=F.panels.filter(G=>G!==W),I()}},registerOverlay:W=>(T(W),()=>{T(void 0)}),registerSeparator:W=>{const F=v.current;return F.separators=ft(u,[...F.separators,W]),I(),()=>{F.separators=F.separators.filter(G=>G!==W),I()}},updatePanelProps:(W,{disabled:F})=>{const J=v.current.panels.find(ue=>ue.id===W);if(!J||J.constraintProps.disabled===F)return;J.constraintProps.disabled=F;const Y=st(S),re=be(S);Y&&re&&Oe(Y,{...re,derivedItemConstraints:Sn(Y)})},updateSeparatorProps:(W,{disabled:F,disableDoubleClick:G})=>{const Y=v.current.separators.find(re=>re.id===W);Y&&(Y.disabled=F,Y.disableDoubleClick=G)}}),[V,S,I,u,D]),H=p.useRef(null);return ne(()=>{const W=j.current;if(W===null)return;const F=v.current;F.panels=ft(u,F.panels),F.separators=ft(u,F.separators),R.current=Br([...F.panels.map(({element:q})=>q),...F.separators.map(({element:q})=>q)]);let G;if(D.defaultLayout!==void 0&&Object.keys(D.defaultLayout).length===F.panels.length){G={};for(const q of F.panels){const L=D.defaultLayout[q.id];L!==void 0&&(G[q.id]=L)}}const J={disabled:!!s,element:W,id:S,mutableState:{defaultLayout:G,disableCursor:!!D.disableCursor,expandedItemSizes:v.current.lastExpandedPanelSizes,layouts:v.current.layouts},orientation:u,items:F.panels,resizePreviewMode:d,get resizeTargetMinimumSize(){return D.resizeTargetMinimumSize},separators:F.separators};H.current=J;const Y=Jo(J),{defaultLayoutDeferred:re,derivedItemConstraints:ue,layout:pe,requestedLayout:w}=be(J.id,!0);if(!re&&ue.length>0)try{try{b(pe)}finally{y(pe,!1,w)}}catch(q){throw H.current=null,Y(),q}const _=rt(S,q=>{const{defaultLayoutDeferred:L,derivedItemConstraints:A,layout:$,requestedLayout:U}=q.next;if(L||A.length===0)return;Zo({derivedItemConstraints:A,axis:J,layout:$,prevLayout:q.prev?.layout,requestedLayout:U});const Q=ye(),X=Q.state!=="active"||!Q.hitRegions.some(te=>te.axis===J);try{b($)}finally{X&&y($,q.isUserInteraction,U)}});return()=>{H.current=null,Y(),_()}},[s,S,y,b,u,k,d,D]),ne(()=>{$r(R.current)||I()}),p.useEffect(()=>{const W=H.current;W&&(W.mutableState.defaultLayout=n,W.mutableState.disableCursor=!!o)}),O.jsx(Yt.Provider,{value:N,children:O.jsx(Ln.Provider,{value:K,children:O.jsxs("div",{...m,className:t,"data-group":!0,"data-testid":at(m,a),id:S,ref:C,style:{height:"100%",width:"100%",overflow:"hidden",position:d==="separator"?"relative":void 0,...g,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:[e,E.map(W=>O.jsx(Fr,{overlay:x,preview:W},W.key))]})})})}const ss=Object.assign(Vr,{displayName:"Group"});function $t(e,t){return`react-resizable-panels:${[e,...t].join(":")}`}function _r({id:e,panelIds:t,storage:n}){const o=$t(e,[]),s=n.getItem(o);if(s)try{const r=JSON.parse(s);if(t){const i=t.join(","),a=r[i];if(a&&Array.isArray(a.layout)&&t.length===a.layout.length){const l={};for(let c=0;c<t.length;c++)l[t[c]]=a.layout[c];return l}}else{const i=Object.keys(r);if(i.length===1){const a=r[i[0]];if(a&&Array.isArray(a.layout)){const l=i[0].split(",");if(l.length===a.layout.length){const c={};for(let u=0;u<l.length;u++)c[l[u]]=a.layout[u];return c}}}}}catch{}}function qr({debounceSaveMs:e=100,onlySaveAfterUserInteractions:t,panelIds:n,storage:o=localStorage,...s}){const r=n!==void 0,i="id"in s?s.id:s.groupId,a=$t(i,n??[]),l=p.useSyncExternalStore(Ut,()=>o.getItem(a),()=>o.getItem(a)),c=p.useMemo(()=>{if(l){const b=JSON.parse(l),y=Object.values(b);if(Array.from(y).every(S=>typeof S=="number"))return b}},[l]),u=p.useMemo(()=>{if(!c)return _r({id:i,panelIds:n,storage:o})},[c,i,n,o]),d=c??u,h=p.useRef(null),g=p.useCallback(()=>{const b=h.current;b&&(h.current=null,clearTimeout(b))},[]);p.useLayoutEffect(()=>()=>{g()},[g]);const m=p.useCallback((b,y)=>{if(t&&!y.isUserInteraction)return;g();const S=y.requestedLayout??b;let x;r?x=$t(i,Object.keys(S)):x=$t(i,[]);try{o.setItem(x,JSON.stringify(S))}catch(T){console.error(T)}},[g,r,i,t,o]),f=p.useCallback(b=>{g(),e===0?m(b,{isUserInteraction:!1}):h.current=setTimeout(()=>{m(b,{isUserInteraction:!1})},e)},[g,e,m]);return{defaultLayout:d,onLayoutChange:f,onLayoutChanged:m}}function Ur(){return p.useState(null)}function rs(){return p.useRef(null)}function Kr(){return p.useContext(Yt)}const Xt=p.createContext(null);function Yr(e,t){const{id:n}=Kt(),o=p.useRef({collapse:nn,expand:nn,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:nn});return p.useImperativeHandle(t,()=>o.current,[]),ne(()=>{Object.assign(o.current,Rn({axisId:n,itemId:e}))}),o}function Xr({children:e,className:t,collapsedSize:n="0%",collapsedThreshold:o,collapsible:s=!1,defaultSize:r,disabled:i,elementRef:a,groupResizeBehavior:l="preserve-relative-size",id:c,maxSize:u="100%",minSize:d="0%",onResize:h,panelRef:g,style:m,...f}){const b=jt(c),y=Je(c),S=_t({disabled:i}),x=p.useRef(null),T=Ze(x,a),{getPanelStyles:E,id:j,orientation:k,registerPanel:I,updatePanelProps:R}=Kt(),v=h!==null,C=Ce((H,W,F)=>{h?.(H,c,F)});ne(()=>{const H=x.current;if(H!==null){const W={element:H,id:y,idIsStable:b,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:v?C:void 0,constraintProps:{groupResizeBehavior:l,collapsedSize:n,collapsedThreshold:o,collapsible:s,defaultSize:r,disabled:S.disabled,maxSize:u,minSize:d}};return I(W)}},[l,n,o,s,r,v,y,b,u,d,C,I,S]),p.useEffect(()=>{R(y,{disabled:i})},[i,y,R]);const M=Yr(y,g),N=p.useMemo(()=>({collapse:()=>M.current.collapse(),expand:()=>M.current.expand(),getSize:()=>M.current.getSize(),groupId:j,id:y,isCollapsed:()=>M.current.isCollapsed(),resize:H=>M.current.resize(H)}),[j,y,M]),V=()=>{const H=E(j,y);if(H)return JSON.stringify(H)},D=p.useSyncExternalStore(H=>rt(j,H),V,V);let K;return D?K=JSON.parse(D):r!==void 0?K={flexGrow:void 0,flexShrink:void 0,flexBasis:r}:K={flexGrow:1},O.jsx("div",{...f,"data-disabled":i||void 0,"data-panel":!0,"data-testid":at(f,c),id:y,ref:T,style:{...Jr,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...K},children:O.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...m,touchAction:k==="horizontal"?"pan-y":"pan-x"},children:O.jsx(Xt.Provider,{value:N,children:e})})})}const is=Object.assign(Xr,{displayName:"Panel"}),Jr={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function Zr(){return p.useState(null)}function Qr(){return p.useRef(null)}function ei(){return p.useContext(Xt)}const ti={flexBasis:"auto"},ni={flexGrow:0,flexShrink:0};function oi({children:e,className:t,disabled:n,disableDoubleClick:o,elementRef:s,id:r,preview:i,style:a,...l}){const c=Je(r),{disableCursor:u,id:d,orientation:h,registerSeparator:g,updateSeparatorProps:m}=Kt();return O.jsx(es,{attributes:l,axisId:d,axisOrientation:h,className:t,"data-testid":at(l,r),disableCursor:u,disabled:n,disableDoubleClick:o,elementRef:s,id:c,preview:i,registerSeparator:g,requiredStyle:ni,style:a,styleDefaults:ti,updateSeparatorProps:m,children:e})}const as=Object.assign(oi,{displayName:"Separator"});function cs(){try{return process.env.NODE_ENV!=="production"}catch{return!1}}const To=new Set;function Re(e){cs()&&!To.has(e)&&(To.add(e),console.warn(`react-resizable-panels: ${e}`))}const lt=p.createContext(null),Pn=p.createContext(null);function ls(e){return e.type==="split"?{...e,children:e.children.map(ls)}:{...e,tabs:e.tabs.map(t=>({...t}))}}function Pe(e){return{...e,root:ls(e.root)}}function ut(e){return e.type==="tabset"?[e]:e.children.flatMap(t=>ut(t))}function Xe(e,t){return ut(e.root).find(({tabs:n})=>n.some(({id:o})=>o===t))}function it(e,t){return Xe(e,t)?.tabs.find(({id:n})=>n===t)}function si(e){const t=new Set,n=r=>{r.id!==void 0&&t.add(r.id),r.type==="split"&&r.children.forEach(n)};n(e);const o=(r,i)=>{if(r.id!==void 0)return r.id;const a=`${r.type}-${i.length>0?i.join("-"):"root"}`;let l=a,c=1;for(;t.has(l);)c++,l=`${a}-${c}`;return t.add(l),l},s=(r,i)=>r.type==="split"?{...r,children:r.children.map((a,l)=>s(a,[...i,l])),id:o(r,i)}:{...r,id:o(r,i),tabs:r.tabs.map(a=>({...a}))};return s(e,[])}function us(e,t){if(e.type==="tabset"){if(e.tabs.some(({id:r})=>r===e.selectedId)||(e.selectedId=e.tabs[0]?.id),e.collapsible||delete e.collapsed,e.recentTabIds!==void 0){const r=Array.isArray(e.recentTabIds)?e.recentTabIds.filter((i,a,l)=>l.indexOf(i)===a&&e.tabs.some(c=>c.id===i)):[];r.length>0?e.recentTabIds=r:delete e.recentTabIds}return e.tabs.length>0||t||e.keepWhenEmpty?e:null}const n=[];for(const r of e.children){const i=us(r,!1);if(i!==null)if(i.type==="split"&&i.orientation===e.orientation)for(const a of i.children)n.push({...a,size:typeof a.size=="number"&&typeof i.size=="number"?a.size*i.size/100:void 0});else n.push(i)}if(n.length===0)return null;if(n.length===1)return{...n[0],size:e.size};const o=r=>r.type==="tabset"&&!!r.collapsed;n.every(o)&&delete n[n.length-1].collapsed;const s=n.filter(r=>!o(r));if(s.every(({size:r})=>typeof r=="number")){const r=s.reduce((i,{size:a})=>i+a,0);if(r>0)for(const i of s)i.size=i.size/r*100}return{...e,children:n}}function ri(e){const t=new Set,n=s=>{t.has(s)&&Re(`Duplicate id found in workspace model: "${s}"`),t.add(s)},o=s=>{n(s.id),s.type==="split"?s.children.forEach(o):s.tabs.forEach(({id:r})=>n(r))};o(e)}function Se(e){e.version!==1&&Re(`Unsupported workspace model version: ${e.version}`);const t=si(e.root),n=us(t,!0)??{id:t.id,tabs:[],type:"tabset"};n.type==="tabset"&&delete n.collapsed,cs()&&ri(n);const o={root:n,version:1};return e.maximizedTabsetId!==void 0&&n.type==="split"&&ut(n).some(({id:s})=>s===e.maximizedTabsetId)&&(o.maximizedTabsetId=e.maximizedTabsetId),o}function ds(e,t){const n=e.recentTabIds?.find(s=>s!==t&&e.tabs.some(r=>r.id===s));if(n!==void 0)return n;const o=e.tabs.findIndex(({id:s})=>s===t);return(e.tabs[o+1]??e.tabs[o-1])?.id}function un(e,t){const n=e.tabs.findIndex(({id:o})=>o===t);n<0||(e.selectedId===t&&(e.selectedId=ds(e,t)),e.tabs.splice(n,1))}function Mn(e,t){if(!it(e,t))return e;const n=Pe(e),o=Xe(n,t);return o&&un(o,t),Se(n)}function Gt(e,t){return t[e.id]??!!e.collapsed}const fs=p.createContext(null);function ps(e){const t=p.useContext(fs),n=p.useRef(null),o=()=>{const s=t?e(t.getState()):null,r=n.current;return r&&(r.value===s||r.value!==null&&s!==null&&Tn(r.value,s))?r.value:(n.current={value:s},s)};return p.useSyncExternalStore(t?.subscribe??Ut,o,o)}function ms(){const t=p.useContext(lt)?.id;return ps(({collapseOverrides:n,disabled:o,model:s,modelIndex:r})=>{const i=t!==void 0?r.tabsetsByTabId.get(t):void 0,a=i?.tabs.find(({id:u})=>u===t);if(!i||!a)return null;const l=i.selectedId===a.id,c=s.maximizedTabsetId;return{isCloseDisabled:o||!!a.disableClose,isDragDisabled:o||!!a.disableDrag,isSelected:l,isVisible:l&&(c===void 0?!Gt(i,n):c===i.id),tabsetId:i.id}})}function ii({"aria-label":e,children:t="×",onClick:n,...o}){const s=p.useContext(Pn),r=p.useContext(lt),i=ms();if(!s||!r)Re("TabCloseButton must be rendered within a tab (see renderTab)");else if(i?.isCloseDisabled)return null;const a=r?s?.modelIndex.tabsetsByTabId.get(r.id)?.tabs.find(({id:l})=>l===r.id):void 0;return O.jsx("button",{"aria-label":e??`Close ${a?.title??a?.id??"tab"}`,tabIndex:-1,type:"button",...o,onClick:l=>{n?.(l),!l.defaultPrevented&&s&&r&&s.updateModel("close",!0,c=>Mn(c,r.id))},children:t})}const hs=Object.assign(ii,{displayName:"TabCloseButton"}),dt=p.createContext(null);function kn(e,t){return!!t.collapsible&&!!e&&e.children.some(n=>n.id!==t.id&&!(n.type==="tabset"&&n.collapsed))}function En(e,t,n){return n||!!t.disableDrag||t.tabs.some(({disableDrag:o})=>o)||e.root.id===t.id||e.maximizedTabsetId!==void 0}function gs(){const t=p.useContext(dt)?.id;return ps(({activeTabsetId:n,collapseOverrides:o,collapseToFit:s,disabled:r,model:i,modelIndex:a})=>{const l=t!==void 0?a.tabsetsById.get(t):void 0;return l?{isActive:n===l.id,isCollapsed:Gt(l,o),isCollapsedToFit:Gt(l,o)&&s[l.id]===!0,isCollapsible:!!l.collapsed||kn(a.parentsById.get(l.id),l),isDragDisabled:En(i,l,r),isMaximized:i.maximizedTabsetId===l.id,isRoot:i.root.id===l.id,selectedTabId:l.selectedId}:null})}function ai({style:e,...t}){const n=p.useContext(dt),o=gs();n||Re("TabsetDragHandle must be rendered within a tabset's header (see renderTabsetToolbar)");const s=o?.isDragDisabled??!0;return O.jsx("div",{"data-disabled":s||void 0,"data-tabset-drag-handle":"",...t,style:s?e:{touchAction:"none",...e}})}const ci=Object.assign(ai,{displayName:"TabsetDragHandle"});function li(){return p.useContext(lt)}function ui(){return p.useContext(dt)}const Dn=p.createContext(null);function di(){return p.useContext(Dn)}function fi(){const e=p.useContext(Dn),t=p.useContext(dt)?.id,n=p.useCallback(s=>e&&t!==void 0?e.subscribeToTabListFreeSpace(t,s):()=>{},[t,e]),o=()=>e&&t!==void 0?e.getTabListFreeSpace(t):void 0;return p.useSyncExternalStore(n,o,pi)}function pi(){}function mi(){return p.useState(null)}function hi(){return p.useRef(null)}function gi(e,{getChromeSize:t,getCollapsedSize:n,getContentMaximumSize:o,getSeparatorsSize:s}){const r=new Map,i=new Map,a=c=>{let u;if(c.type==="tabset"){const d=o(c),h=t(c.id)??{height:0,width:0};r.set(c.id,d),u={height:d.height+h.height,width:d.width+h.width}}else{const d=c.children.map(f=>{const b=a(f);if(f.type!=="tabset"||!f.collapsed)return b;const y=n(f.id)??0;return c.orientation==="horizontal"?{...b,width:y}:{...b,height:y}}),h=s(c.id)??0,g=f=>d.reduce((b,y)=>b+y[f],0)+h,m=f=>Math.min(...d.map(b=>b[f]));u=c.orientation==="horizontal"?{height:m("height"),width:g("width")}:{height:g("height"),width:m("width")}}return i.set(c.id,u),u},l=(c,u)=>{const d=i.get(c.id);if(c.type==="tabset"){const h=r.get(c.id);for(const g of["height","width"])!u[g]&&Number.isFinite(h[g])&&Re(`Tabset "${c.id}" can't be limited to its ${g==="height"?"maxHeight":"maxWidth"}, since nothing else can take up the rest of the space (e.g. every other tabset in its split has a maximum ${g}, or it fills the workspace)`)}else{const h=c.orientation==="horizontal"?"width":"height",g=h==="width"?"height":"width",m=c.children.filter(f=>!(f.type==="tabset"&&f.collapsed)&&!Number.isFinite(i.get(f.id)[h])).map(({id:f})=>f);for(const f of c.children){const b=m.some(y=>y!==f.id);l(f,{[h]:b||u[h],[g]:u[g]})}}i.set(c.id,{height:u.height?d.height:1/0,width:u.width?d.width:1/0})};return a(e),l(e,{height:!1,width:!1}),i}function bi(e,{getChromeSize:t,getCollapsedSize:n,getContentMinimumSize:o,getSeparatorsSize:s}){const r=new Map,i=a=>{let l;if(a.type==="tabset"){const c=o(a),u=t(a.id)??{height:0,width:0};l={height:c.height+u.height,width:c.width+u.width}}else{const c=a.children.map(g=>{const m=i(g);if(g.type!=="tabset"||!g.collapsed)return m;const f=n(g.id)??0;return a.orientation==="horizontal"?{height:0,width:f}:{height:f,width:0}}),u=s(a.id)??0,d=g=>c.reduce((m,f)=>m+f[g],0)+u,h=g=>Math.max(0,...c.map(m=>m[g]));l=a.orientation==="horizontal"?{height:h("height"),width:d("width")}:{height:d("height"),width:h("width")}}return r.set(a.id,l),l};return i(e),r}function yi(){const e=new Map,t=new Map,n=new Map,o=(s,r)=>{if(e.get(s)===r)return;r===void 0?e.delete(s):e.set(s,r);const i=t.get(s);if(!i)return;let a;for(const l of Array.from(i))try{l(r)}catch(c){a??={error:c}}if(a)throw a.error};return{get:s=>e.get(s),retain:s=>(n.set(s,(n.get(s)??0)+1),()=>{n.set(s,n.get(s)-1),queueMicrotask(()=>{n.get(s)||(n.delete(s),o(s,void 0))})}),set:o,subscribe:(s,r)=>{let i=t.get(s);return i||(i=new Set,t.set(s,i)),i.add(r),()=>{i.delete(r),i.size===0&&t.get(s)===i&&t.delete(s)}}}}function vi(e){const t=new mn;let n=e,o=e;return{getState:()=>o,notify:()=>{n!==o&&(n=o,t.emit("change",void 0))},setState:s=>{o=s},subscribe:s=>t.addListener("change",s)}}function le(e,t){return ut(e.root).find(({id:n})=>n===t)}function Ft(e,t){const n=Xe(e,t);if(!n||n.selectedId===t)return e;const o=Pe(e),s=Xe(o,t);return s&&(s.selectedId=t),o}function Si(e,t,{index:n,select:o=!0,tabsetId:s}={}){if(it(e,t.id))return{added:!1,model:Ft(e,t.id)};const r=Pe(e);let i=le(r,s);i||(s!==void 0&&Re(`Tabset "${s}" not found in workspace model; adding tab to the first tabset instead`),i=ut(r.root)[0]);const a=n===void 0?i.tabs.length:Math.max(0,Math.min(n,i.tabs.length));return i.tabs.splice(a,0,{...t}),(o||i.selectedId===void 0)&&(i.selectedId=t.id),{added:!0,model:Se(r)}}function xi(e,t){if(!le(e,t))return e;const n=Pe(e),o=le(n,t);return o&&(o.tabs=[],o.selectedId=void 0,delete o.keepWhenEmpty),Se(n)}function vt(e,t){if(e.type==="split")for(const n of e.children){if(n.id===t)return e;const o=vt(n,t);if(o)return o}}function wi(e,t){const n=le(e,t);if(!n||n.collapsed||!kn(vt(e.root,t),n))return e;const o=Pe(e),s=le(o,t);return s&&(s.collapsed=!0),Se(o)}function St(e,t){if(!le(e,t)?.collapsed)return e;const n=Pe(e),o=le(n,t);if(!o)return e;delete o.collapsed;const s=o.size,r=vt(n.root,t)?.children.filter(i=>i!==o&&!(i.type==="tabset"&&i.collapsed))??[];if(typeof s=="number"&&s<100&&r.every(i=>typeof i.size=="number"))for(const i of r)i.size=i.size*(100-s)/100;return Se(n)}function zi(e){return ut(e).flatMap(t=>t.tabs)}function bs(e){return dn(e)&&ys(e.root)}function dn(e){return typeof e=="object"&&e!==null}function Io(e){return e===void 0||typeof e=="string"}function ys(e){if(!dn(e)||!Io(e.id))return!1;switch(e.type){case"split":return(e.orientation==="horizontal"||e.orientation==="vertical")&&Array.isArray(e.children)&&e.children.every(ys);case"tabset":return Array.isArray(e.tabs)&&e.tabs.every(t=>dn(t)&&typeof t.id=="string"&&Io(t.title));default:return!1}}function Ro(e){return bs(e)?e:(Re("Invalid workspace model; using an empty workspace instead"),{root:{tabs:[],type:"tabset"},version:1})}function Ci(e){const t={nodeIds:new Set,parentsById:new Map,tabsetsById:new Map,tabsetsByTabId:new Map},n=o=>{if(t.nodeIds.add(o.id),o.type==="tabset"){t.tabsetsById.set(o.id,o);for(const s of o.tabs)t.tabsetsByTabId.set(s.id,o)}else for(const s of o.children)t.parentsById.set(s.id,o),n(s)};return n(e.root),t}function Ti(e,t){return e.maximizedTabsetId===t||e.root.id===t||!le(e,t)?e:{...e,maximizedTabsetId:t}}function vs(){return Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,"0")).join("")}function Ii(e,t){return{id:vs(),selectedId:e[0]?.id,size:t,tabs:e,type:"tabset"}}function Ss(e,t,n,o){const s=o==="left"||o==="right"?"horizontal":"vertical",r=o==="left"||o==="top",i=vt(e,t.id);if(i&&i.orientation===s){const l=i.children.indexOf(t);return typeof t.size=="number"?(t.size/=2,n.size=t.size):n.size=void 0,i.children.splice(r?l:l+1,0,n),e}const a={children:r?[n,t]:[t,n],id:vs(),orientation:s,size:t.size,type:"split"};return t.size=50,n.size=50,i?(i.children[i.children.indexOf(t)]=a,e):a}function Lo(e,t,n){const o=Pe(e),s=Xe(o,t),r=le(o,n.tabsetId);if(!s||!r)return e;const i=s.tabs.findIndex(({id:l})=>l===t),a=s.tabs[i];if("index"in n||n.region==="center"){let l="index"in n?Math.max(0,Math.min(n.index,r.tabs.length)):r.tabs.length;if(s===r&&(l>i&&l--,l===i&&r.selectedId===t))return e;if(un(s,t),r.tabs.splice(l,0,a),r.selectedId=a.id,r.collapsed&&s!==r)return St(Se(o),r.id)}else{if(s===r&&s.tabs.length===1&&!s.keepWhenEmpty)return e;un(s,t),o.root=Ss(o.root,r,Ii([a]),n.region),o.maximizedTabsetId===r.id&&(o.maximizedTabsetId=void 0)}return Se(o)}function Po(e,t,n){const o=Pe(e),s=le(o,t),r=le(o,n.tabsetId);if(!s||!r||s===r)return e;if("index"in n||n.region==="center"){if(s.tabs.length===0)return e;const i="index"in n?Math.max(0,Math.min(n.index,r.tabs.length)):r.tabs.length;if(r.tabs.splice(i,0,...s.tabs),r.selectedId=s.selectedId??s.tabs[0].id,s.recentTabIds&&(r.recentTabIds=[...r.recentTabIds??[],...s.recentTabIds]),s.tabs=[],s.selectedId=void 0,r.collapsed)return St(Se(o),r.id)}else{const i=vt(o.root,s.id);if(!i)return e;delete s.collapsed,i.children.splice(i.children.indexOf(s),1),o.root=Ss(o.root,r,s,n.region),o.maximizedTabsetId===r.id&&(o.maximizedTabsetId=void 0)}return Se(o)}function Ri(e){if(e.maximizedTabsetId===void 0)return e;const t={...e};return delete t.maximizedTabsetId,t}function Li(e,t,n){if(!it(e,t))return e;const o=Pe(e),s=it(o,t);return s&&Object.assign(s,n),o}function on(e,t){const n=xs(e.root,t);return n===e.root?e:{...e,root:n}}function xs(e,t){if(e.type==="split"){const s=e.children.map(r=>xs(r,t));return s.every((r,i)=>r===e.children[i])?e:{...e,children:s}}const n=e.recentTabIds,o=e.selectedId;if(t==="adjacent"||o===void 0){if(n===void 0)return e;const{recentTabIds:s,...r}=e;return r}return n?.[0]===o?e:{...e,recentTabIds:[o,...(n??[]).filter(s=>s!==o)]}}function Pi(e,t,n){if(!le(e,t))return e;const o=Pe(e),s=le(o,t);return s&&Object.assign(s,n),Se(o)}const ws=p.createContext(null);function Qe(e){const t=p.useContext(Pn);return ee(t,`${e} must be rendered within a Workspace`),t}function Jt(e){const t=p.useContext(ws);return ee(t,`${e} must be rendered within a tabset`),t}const Mi=p.memo(function({render:t,tab:n}){return t(n)},(e,t)=>e.render===t.render&&e.tab.id===t.tab.id&&e.tab.data===t.tab.data&&e.tab.title===t.tab.title&&e.tab.disableClose===t.tab.disableClose&&e.tab.disableDrag===t.tab.disableDrag),ki=Object.assign(Mi,{displayName:"Workspace.MemoizedContent"});function Ei({hiddenTabBehavior:e,renderTabContent:t,tab:n}){const{classNames:o,getTabHandle:s,getTabHost:r,getTabsetHandle:i,modelIndex:a,styles:l}=Qe("TabContent"),c=a.tabsetsByTabId.get(n.id);if(!c)return null;const u=c.selectedId===n.id;let d=null;if((e!=="unmount"||u)&&(d=O.jsx(ki,{render:t,tab:n}),e==="activity")){const m=Ws.Activity;m?d=O.jsx(m,{mode:u?"visible":"hidden",children:d}):Re('hiddenTabBehavior "activity" requires React 19.2 or newer; falling back to "keep-mounted"')}const{panelId:h,tabElementId:g}=r(n.id);return O.jsx("div",{"aria-labelledby":g,className:o?.tabContent,"data-tab-content":"",id:h,role:"tabpanel",style:l?.tabContent,children:O.jsx(dt.Provider,{value:i(c.id),children:O.jsx(lt.Provider,{value:s(n.id),children:d})})})}const zs=Object.assign(Ei,{displayName:"Workspace.TabContent"}),Mo=new WeakMap;function Cs(e,t){if(!e)return;let n=Mo.get(e);if(!n){const{margin:r,translate:i}=e.style;e.style.margin="0",e.style.transform="none",e.style.translate="none";const a=e.getBoundingClientRect();n={scaleX:Ae(e,"horizontal"),scaleY:Ae(e,"vertical"),x:a.left,y:a.top},Mo.set(e,n),e.style.margin=r,e.style.translate=i}const o=(t.clientX-n.x)/n.scaleX,s=(t.clientY-n.y)/n.scaleY;e.style.transform=`translate(${o}px, ${s}px)`}function Bt(e,t){return Array.from(e.querySelectorAll(t)).find(n=>n.closest("[data-tabset-id]")===e)}const Di=.25;function Ts(e,t,n){const o=e.width>0?(t-e.left)/e.width:.5,s=e.height>0?(n-e.top)/e.height:.5,r={bottom:1-s,left:o,right:1-o,top:s},i=Object.keys(r).reduce((a,l)=>r[l]<r[a]?l:a,"left");return r[i]<Di?i:"center"}function ht(e){return e?.ownerDocument.defaultView?.getComputedStyle(e).direction==="rtl"}function Is(e,t,n){const o=e.dataset.orientation==="vertical",s=!o&&ht(e),r=Array.from(e.querySelectorAll("[data-tab]")).filter(a=>a.closest("[data-tab-list]")===e),i=r.findIndex(a=>{const l=a.getBoundingClientRect();if(o)return n<l.top+l.height/2;const c=l.left+l.width/2;return s?t>c:t<c});return i===-1?r.length:i}function Oi({clientX:e,clientY:t,model:n,rootElement:o,source:s}){const r=o.getRootNode(),i=(_o(r)?r:o.ownerDocument).elementFromPoint(e,t);if(!i||!o.contains(i))return;let a=i.closest("[data-tabset-id]");for(;a&&a.closest("[data-workspace]")!==o;)a=a.parentElement?.closest("[data-tabset-id]")??null;const l=a?.dataset.tabsetId,c=le(n,l);if(!a||!c||n.maximizedTabsetId!==void 0&&n.maximizedTabsetId!==c.id)return;if(s.type==="tabset")return Ai({clientX:e,clientY:t,element:i,model:n,sourceTabsetId:s.tabsetId,tabsetElement:a,tabsetId:c.id});const u=Bt(a,"[data-tab-list]");if(u?.contains(i))return{index:Is(u,e,t),tabsetId:c.id};const d=Bt(a,"[data-tab-panels]");if(d?.contains(i)){const h=c.tabs.some(({id:f})=>f===s.tabId),m=!!c.keepWhenEmpty||!(c.tabs.length===1&&h)?Ts(d.getBoundingClientRect(),e,t):"center";return m==="center"&&h?void 0:{region:m,tabsetId:c.id}}}function Ai({clientX:e,clientY:t,element:n,model:o,sourceTabsetId:s,tabsetElement:r,tabsetId:i}){if(i===s)return;const a=!!le(o,s)?.keepWhenEmpty,l=Bt(r,"[data-tab-list]");if(l?.contains(n))return a?void 0:{index:Is(l,e,t),tabsetId:i};const c=Bt(r,"[data-tab-panels]");if(c?.contains(n)){const u=Ts(c.getBoundingClientRect(),e,t);return u==="center"&&a?void 0:{region:u,tabsetId:i}}}function $i(e,t){return e===void 0||t===void 0?e===t:e.tabsetId!==t.tabsetId?!1:"index"in e&&"index"in t?e.index===t.index:"region"in e&&"region"in t?e.region===t.region:!1}const ji=5;function Ni({getModel:e,getRootElement:t,isDropDisabled:n,onDrop:o}){const[s,r]=p.useState(),[i,a]=p.useState(),l=p.useRef(null),c=p.useRef({clientX:0,clientY:0}),u=p.useRef(null);p.useEffect(()=>()=>u.current?.(),[]);const d=p.useCallback((m,f)=>{const b=t();if(!b)return;const y=ye();if(y.state==="active"&&yt(y,f.currentTarget.ownerDocument,f))return;u.current?.();const S=f.currentTarget,x=S.ownerDocument,{clientX:T,clientY:E,pointerId:j}=f;S.setPointerCapture?.(j);let k=!1,I,R;const v={cursor:x.documentElement.style.cursor,sourceCursor:S.style.cursor,userSelect:x.body.style.userSelect},C=F=>{x.documentElement.style.cursor=F??v.cursor,S.style.cursor=F??v.sourceCursor},M=F=>{if(F.pointerId!==j)return;const{clientX:G,clientY:J}=F;if(!k){if(Math.hypot(G-T,J-E)<ji)return;k=!0,x.body.style.userSelect="none",r(m)}c.current={clientX:G,clientY:J},Cs(l.current,c.current);const Y=Oi({clientX:G,clientY:J,model:e(),rootElement:b,source:m});if(!$i(R,Y)){R=Y;const re=Y!==void 0&&n(m,Y);I=re?void 0:Y,C(re?"not-allowed":void 0),a(I)}},N=(F,{isPointerDown:G=!1}={})=>{if(u.current=null,x.removeEventListener("pointermove",M),x.removeEventListener("pointerup",V),x.removeEventListener("pointercancel",D),x.removeEventListener("keydown",K,!0),H?.removeEventListener("blur",W),k){if(x.body.style.userSelect=v.userSelect,C(void 0),r(void 0),a(void 0),G){const J=Y=>{Y.pointerId===j&&(x.removeEventListener("pointerup",J),x.removeEventListener("pointercancel",J),ln(x))};x.addEventListener("pointerup",J),x.addEventListener("pointercancel",J)}else ln(x);F&&I&&o(m,I)}},V=F=>{F.pointerId===j&&N(!0)},D=F=>{F.pointerId===j&&N(!1)},K=F=>{F.key==="Escape"&&(k&&(F.preventDefault(),F.stopPropagation()),N(!1,{isPointerDown:!0}))},H=x.defaultView,W=()=>N(!1);u.current=()=>N(!1),x.addEventListener("pointermove",M),x.addEventListener("pointerup",V),x.addEventListener("pointercancel",D),x.addEventListener("keydown",K,!0),H?.addEventListener("blur",W)},[e,t,n,o]),h=p.useCallback((m,f)=>d({tabId:m,type:"tab"},f),[d]),g=p.useCallback((m,f)=>d({tabsetId:m,type:"tabset"},f),[d]);return{dragSource:s,dropTarget:i,previewElementRef:l,previewPointRef:c,startTabDrag:h,startTabsetDrag:g}}function fn(e,t){if(e.type==="split"){if(e.id===t)return e;for(const n of e.children){const o=fn(n,t);if(o)return o}}}function Gi(e,t,n,o,s){const r=fn(e.root,t);if(!r||r.children.length!==Object.keys(n).length||r.children.some(({id:c})=>n[c]===void 0))return e;const i=Pe(e),a=fn(i.root,t);if(!a)return e;let l=!1;for(const c of a.children){if(s?.has(c.id))continue;const u=c.type==="tabset"&&(o?o.has(c.id):!!c.collapsed);c.type==="tabset"&&u!==!!c.collapsed&&(l=!0,u?c.collapsed=!0:delete c.collapsed),u||(c.size=n[c.id]??c.size)}return l||(s?.size??0)>0||a.children.some(c=>c.type==="tabset"&&c.collapsed)?Se(i):i}function ko(e,t,n){const o=Uo(e.map(l=>{const c=n[l.itemId];return typeof c=="number"?{...l,defaultSize:c}:l}));let s=0;const r=[];for(const l of e)t.has(l.itemId)?s+=l.collapsedSize:r.push(l);const i=Fi(r.map(({itemId:l,maxSize:c,minSize:u})=>({maxSize:c,minSize:u,weight:o[l]})),Math.max(0,100-s)),a={};for(const{collapsedSize:l,itemId:c}of e)a[c]=fe(t.has(c)?l:i[r.findIndex(u=>u.itemId===c)]);return a}function Fi(e,t){const n=(i,a)=>{const l=i.reduce((c,u)=>c+u,0);return i.map(c=>l>0?c/l*a:a/i.length)},o=new Map;for(;o.size<e.length;){const i=e.map((h,g)=>({...h,index:g})).filter(({index:h})=>!o.has(h)),a=t-Array.from(o.values()).reduce((h,g)=>h+g,0),l=n(i.map(({weight:h})=>h),a);let c=0;const u=[];if(i.forEach(({index:h,maxSize:g,minSize:m},f)=>{const b=l[f],y=Math.min(g,Math.max(m,b));y!==b&&(c+=y-b,u.push({index:h,isMinimum:y>b,size:y}))}),u.length===0){i.forEach(({index:h},g)=>o.set(h,l[g]));break}let d=0;for(const{index:h,isMinimum:g,size:m}of u)(c===0||c>0===g)&&(o.set(h,m),d++);if(d===0)for(const{index:h,size:g}of u)o.set(h,g)}const s=e.map((i,a)=>o.get(a)),r=s.reduce((i,a)=>i+a,0);return Math.abs(r-t)>.001?n(e.map(({weight:i})=>i),t):s}function Bi(e,t){let n=!1;for(const o of e){if(o.type!=="tabset")continue;const s=t.has(o.id);if(s!==!!o.collapsed){if(!s)return"expand";n=!0}}return n?"collapse":"resize"}function Wi({split:e}){const{classNames:t,collapsedSizes:n,collapseToFit:o,disabled:s,id:r,maximumSizes:i,minimumSizes:a,renderSeparator:l,reportCollapsePreview:c,reportCollapseToFit:u,reportSeparatorsSize:d,resizePreviewMode:h,splitGeneration:g,styles:m,updateModel:f}=Qe("SplitView"),b=`${r}-${e.id}`,y=w=>`${r}:${w}`,S=rs(),[x,T]=p.useState(null),E=p.useRef(null),j=p.useCallback(w=>{E.current=w,T(w)},[]),k=()=>{const w=E.current;return w?e.orientation==="horizontal"?w.offsetWidth:w.offsetHeight:0},I=e.children.map(({id:w})=>w).join(),R=e.children.map(({id:w})=>y(w)).join(),v=new Set(e.children.filter(w=>w.type==="tabset"&&w.collapsed).map(({id:w})=>y(w))),C=e.children.filter(w=>w.type==="tabset"&&w.collapsed).map(({id:w})=>`${w}=${n[w]??0}`).join(),M=`${g}:${e.orientation}:${I}:${C}`,N=p.useRef(null),[,V]=p.useState(0),D=()=>{const w=be(b);return!w||w.defaultLayoutDeferred||w.derivedItemConstraints.map(({itemId:_})=>_).join()!==R?null:`${M}|${w.derivedItemConstraints.filter(({itemId:_})=>v.has(_)).map(({collapsedSize:_})=>_).join()}`},K=()=>{const w={};for(const _ of e.children)w[y(_.id)]=_.size;return w},H=w=>{const _=be(b)?.derivedItemConstraints??[],q=new Set;for(const{id:L}of e.children){const A=y(L),$=_.find(({itemId:U})=>U===A);$?.collapsible&&w[A]!==void 0&&w[A]<=$.collapsedSize+.01&&q.add(L)}return q},W=(w,_)=>{const q=H(w),L={};for(const A of e.children)if(A.type==="tabset"){const $=q.has(A.id);L[A.id]=_||$!==!!A.collapsed?$:void 0}return L},F=()=>{const w=ye();return w.state==="active"&&w.hitRegions.some(_=>_.axis.id===b)},G=Ce(w=>c(W(w,!0))),J=w=>{F()||u(W(w,!1))},Y=p.useRef(null),re=p.useRef(null),ue=Ce(()=>{const w=D();if(w===null||N.current!==w||F())return;const _=k(),q=re.current;if(re.current=_,q===null||q===_)return;const{derivedItemConstraints:L,layout:A}=be(b),$=ko(L,v,K()),U=H(A);e.children.some(X=>{const te=y(X.id);return X.type==="tabset"&&U.has(X.id)!==!!X.collapsed||typeof X.size=="number"&&!ie(A[te],$[te],.01)})&&S.current?.setLayout($)}),pe=e.children.some(w=>w.type==="tabset"&&w.collapsible);return p.useEffect(()=>rt(b,({axis:w,next:_,prev:q})=>{q?.derivedItemConstraints!==_.derivedItemConstraints&&(ue(),pe&&V(A=>A+1));const L=ye();pe&&L.state==="active"&&L.hitRegions.some(A=>A.axis===w)&&G(_.layout)}),[ue,b,pe,G]),ne(()=>{const w=D();if(w===null||(N.current!==w&&(N.current=w,S.current?.setLayout(ko(be(b).derivedItemConstraints,v,K())),re.current=k()),F()))return;const{derivedItemConstraints:_}=be(b),q=Y.current,L=k(),{layout:A}=be(b);(q?.constraints!==_||q.layout!==A||q.size!==L||q.structureKey!==M)&&(Y.current={constraints:_,layout:A,size:L,structureKey:M},J(A))}),ne(()=>{const w=x?.ownerDocument.defaultView;if(!x||!w)return;const _=$=>xe($)&&$.hasAttribute("data-separator"),q=()=>{let $=0,U=0;const Q=w.getComputedStyle(x),X=parseFloat(e.orientation==="horizontal"?Q.columnGap:Q.rowGap)||0;for(const te of x.children)if(xe(te)&&te.hasAttribute("data-panel")&&U++,_(te))if(U++,"offsetWidth"in te){const{offsetHeight:de,offsetWidth:we}=te;$+=e.orientation==="horizontal"?we:de}else{const de=te.getBoundingClientRect();$+=e.orientation==="horizontal"?de.width:de.height}$+=X*Math.max(0,U-1),d(e.id,$)},L=w.ResizeObserver?new w.ResizeObserver(q):null;L?.observe(x);for(const $ of x.children)_($)&&L?.observe($);const A=w.MutationObserver?new w.MutationObserver($=>{for(const U of $)U.addedNodes.forEach(Q=>{_(Q)&&L?.observe(Q)}),U.removedNodes.forEach(Q=>{_(Q)&&L?.unobserve(Q)});q()}):null;return A?.observe(x,{childList:!0}),q(),()=>{L?.disconnect(),A?.disconnect()}},[t?.split,x,d,e.id,e.orientation,m?.split]),O.jsx(ss,{className:t?.split,"data-split":"","data-split-id":e.id,disabled:s,elementRef:j,groupRef:S,id:b,onLayoutChanged:(w,{isUserInteraction:_,requestedLayout:q})=>{if(_){const L=q??w,A={};for(const{id:X}of e.children){const te=L[y(X)];te!==void 0&&(A[X]=te)}const $=H(w),U=new Set;for(const X of $)o[X]===!0&&($.delete(X),U.add(X));const Q=Bi(e.children,$);f(Q,!0,X=>Gi(X,e.id,A,$,U))}else{const L=D();L!==null&&N.current===L?J(w):V(A=>A+1)}},orientation:e.orientation,resizePreviewMode:h,style:m?.split,children:e.children.map((w,_)=>{const q=a.get(w.id),L=e.orientation==="horizontal"?q?.width:q?.height,A=i.get(w.id),$=e.orientation==="horizontal"?A?.width:A?.height;return O.jsxs(p.Fragment,{children:[_>0&&(l?l(e.orientation):O.jsx(as,{})),O.jsx(is,{collapsedSize:w.type==="tabset"&&w.collapsible?`${n[w.id]??0}px`:void 0,collapsible:w.type==="tabset"&&(!!w.collapsed||kn(e,w)),defaultSize:typeof w.size=="number"?`${w.size}%`:w.size,id:y(w.id),maxSize:$!==void 0&&Number.isFinite($)?`${Math.max($,L??0)}px`:void 0,minSize:L||void 0,children:O.jsx(ks,{node:w})})]},w.id)})})}const Hi=Object.assign(Wi,{displayName:"Workspace.SplitView"}),Rs=p.createContext({isOverflowing:!1,orientation:"horizontal"}),Vi='button, [role="button"], [data-tab-ignore]';function sn(e){const t=e.target.closest?.(Vi);return!!t&&t!==e.currentTarget&&e.currentTarget.contains(t)}function _i({tab:e}){const{classNames:t,disabled:n,dragTabId:o,dropTarget:s,getTabHandle:r,getTabHost:i,modelIndex:a,renderTab:l,requestFocus:c,startTabDrag:u,styles:d,takeFocusRequest:h,updateModel:g}=Qe("Tab"),{isCollapsed:m,tabPlacement:f,tabset:b}=Jt("Tab"),{isOverflowing:y,orientation:S}=p.useContext(Rs),x=p.useRef(null),T=p.useCallback(G=>{x.current=G},[]),E=a.tabsetsByTabId.get(e.id)??b,j=E.tabs.findIndex(({id:G})=>G===e.id),k=E.tabs[j]??e,I=E.selectedId===k.id,R=n||!!k.disableClose,v=n||!!k.disableDrag;let C=d?.tab?.touchAction;v||(y?C=S==="horizontal"?"pan-x":"pan-y":C="none");const M=s!==void 0&&"index"in s&&s.tabsetId===E.id,N=M&&s.index===j,V=M&&s.index===E.tabs.length&&j===E.tabs.length-1;ne(()=>{h(k.id)&&x.current?.focus()}),ne(()=>{const G=x.current;G?!v&&"touchAction"in G.style&&G.style.touchAction!==C&&Re("The element returned by renderTab replaced props.style (rather than merging it, e.g. style={{ ...props.style, padding: 4 }}); tabs can't be dragged by touch without its touch-action"):Re("The element returned by renderTab must receive its props (including ref); otherwise tabs can't be selected, dragged, or focused")},[v,C]);const{panelId:D,tabElementId:K}=i(k.id),H=()=>m&&E.collapsed?g("expand",!0,G=>St(Ft(G,k.id),E.id)):g("select",!0,G=>Ft(G,k.id)),W=G=>{if(G.target!==G.currentTarget)return;const J=G.currentTarget.closest("[data-tab-list]"),Y=J?Array.from(J.querySelectorAll("[data-tab]")).filter(_=>_.closest("[data-tab-list]")===J):[],re=Y.indexOf(G.currentTarget),ue=_=>{G.preventDefault(),Y[(_+Y.length)%Y.length]?.focus()};let[pe,w]=S==="horizontal"?["ArrowLeft","ArrowRight"]:["ArrowUp","ArrowDown"];switch(S==="horizontal"&&ht(J)&&([pe,w]=[w,pe]),G.key){case pe:{ue(re-1);break}case w:{ue(re+1);break}case"Home":{ue(0);break}case"End":{ue(Y.length-1);break}case"Enter":case" ":{G.preventDefault(),H();break}case"Backspace":case"Delete":{if(!R){G.preventDefault();const _=I?ds(E,k.id):(E.tabs[j+1]??E.tabs[j-1])?.id;_!==void 0&&c(_),g("close",!0,q=>Mn(q,k.id))}break}}},F={"aria-controls":D,"aria-selected":I,className:t?.tab,"data-drop-after":V||void 0,"data-drop-before":N||void 0,"data-tab":"","data-tab-dragging":o===k.id||void 0,"data-tab-id":k.id,"data-tab-placement":f,"data-tabset-collapsed":m||void 0,"data-tab-selected":I||void 0,id:K,onClick:G=>{sn(G)||H()},onKeyDown:G=>{sn(G)||W(G)},onPointerDown:G=>{G.button===0&&!v&&!sn(G)&&u(k.id,G)},ref:T,role:"tab",style:{...d?.tab,touchAction:C,WebkitTouchCallout:"none"},tabIndex:I?0:-1};return O.jsx(lt.Provider,{value:r(k.id),children:l?l(k,F):O.jsxs("div",{...F,children:[k.title??k.id,O.jsx(hs,{})]})})}const qi=Object.assign(_i,{displayName:"Workspace.Tab"});function Ls(e){const t=[];for(const n of e.children){if(!xe(n))continue;const o=n.ownerDocument.defaultView?.getComputedStyle(n);o?.display==="contents"?t.push(...Ls(n)):n.offsetParent!==null&&o?.position!=="absolute"&&o?.position!=="fixed"&&t.push(n)}return t}function Ui(e){const t=e.dataset.orientation==="vertical",n=e.parentElement,o=Ae(n&&xe(n)?n:e,t?"vertical":"horizontal"),s=Array.from(e.children).filter(a=>xe(a)&&a.offsetParent!==null),r=Eo(e,s,t,o);let i=0;if(n){const a=e.getBoundingClientRect(),[l,c]=t?[a.left,a.right]:[a.top,a.bottom],u=Ls(n).filter(d=>{if(d===e)return!0;const h=d.getBoundingClientRect(),[g,m]=t?[h.left,h.right]:[h.top,h.bottom];return c>l?g<c&&m>l:g<=l&&m>=l});i=Math.max(0,-Eo(n,u,t,o))}return Math.round(r-i)}function Eo(e,t,n,o){const s=m=>m.ownerDocument.defaultView?.getComputedStyle(m),r=(m,f)=>parseFloat(m?.getPropertyValue(f)??"")||0,[i,a]=n?["top","bottom"]:["left","right"],l=s(e),c=e.getBoundingClientRect(),u=(n?c.height:c.width)/o-r(l,`border-${i}-width`)-r(l,`border-${a}-width`)-r(l,`padding-${i}`)-r(l,`padding-${a}`);let d,h;for(const m of t){const f=m.getBoundingClientRect(),b=n?f.top:f.left,y=n?f.bottom:f.right;(!d||b<d.position)&&(d={element:m,position:b}),(!h||y>h.position)&&(h={element:m,position:y})}if(!d||!h)return u;const g=r(s(d.element),`margin-${i}`)+r(s(h.element),`margin-${a}`);return u-g-(h.position-d.position)/o}function Ki({children:e}){const{classNames:t,disabled:n,model:o,styles:s,tabListFreeSpaceStore:r}=Qe("TabList"),{isCollapsed:i,tabPlacement:a,tabset:l}=Jt("TabList"),c=a==="left"||a==="right"?"vertical":"horizontal",u=p.useRef(null),[d,h]=p.useState(!1),g=l.id;ne(()=>{const b=u.current;if(!b)return;const y=()=>{const k=b.dataset.orientation==="vertical",I=Math.abs(k?b.scrollTop:b.scrollLeft),R=k?b.scrollHeight-b.offsetHeight:b.scrollWidth-b.offsetWidth;b.toggleAttribute("data-overflow-start",I>1),b.toggleAttribute("data-overflow-end",R-I>1),h(R>1)};let S;const x=()=>{y();const k=Ui(b);k!==S&&(S=k,b.style.setProperty("--tab-list-free-space",`${k}px`)),r.set(g,k)};let T=null,E=null;y();let j=!1;return queueMicrotask(()=>{const k=b.ownerDocument.defaultView;if(j||!k)return;const I=b.parentElement,R=C=>{if(k.getComputedStyle(C).display==="contents"){E?.observe(C,{childList:!0});for(const M of C.children)xe(M)&&R(M)}else T?.observe(C)},v=C=>{T?.unobserve(C);for(const M of C.children)xe(M)&&v(M)};T=k.ResizeObserver?new k.ResizeObserver(x):null,E=k.MutationObserver?new k.MutationObserver(C=>{for(const M of C){for(const N of M.addedNodes)if(xe(N))M.target===b?T?.observe(N):R(N);else continue;for(const N of M.removedNodes)xe(N)&&v(N)}x()}):null,T?.observe(b);for(const C of b.children)T?.observe(C);if(E?.observe(b,{childList:!0}),I){T?.observe(I);for(const C of I.children)xe(C)&&C!==b&&R(C);E?.observe(I,{childList:!0})}x()}),b.addEventListener("scroll",y,{passive:!0}),()=>{j=!0,T?.disconnect(),E?.disconnect(),b.removeEventListener("scroll",y)}},[c,r,g]),ne(()=>r.retain(g),[r,g]);let m=s?.tabList?.touchAction;En(o,l,n)||(d?m=c==="horizontal"?"pan-x":"pan-y":m="none");const f=p.useMemo(()=>({isOverflowing:d,orientation:c}),[d,c]);return O.jsx(Rs.Provider,{value:f,children:O.jsx("div",{"aria-orientation":c,className:t?.tabList,"data-orientation":c,"data-tab-list":!0,"data-tab-placement":a,"data-tabset-collapsed":i||void 0,ref:u,role:"tablist",style:{...s?.tabList,touchAction:m},children:e})})}const Yi=Object.assign(Ki,{displayName:"Workspace.TabList"}),Xi={bottom:{bottom:0,left:0,right:0,top:"50%"},center:{bottom:0,left:0,right:0,top:0},left:{bottom:0,left:0,right:"50%",top:0},right:{bottom:0,left:"50%",right:0,top:0},top:{bottom:"50%",left:0,right:0,top:0}};function Ji(){const{classNames:e,dropTarget:t,getHiddenTabBehavior:n,getTabHost:o,isHydrating:s,renderEmptyTabset:r,renderTabContent:i,shouldServerRenderTabContent:a,styles:l}=Qe("TabPanels"),{isCollapsed:c,setPanelsElement:u,tabPlacement:d,tabset:h}=Jt("TabPanels"),g=p.useRef(null),m=Ze(g,u);ne(()=>{const S=g.current;if(S&&!s)for(const x of h.tabs){const{element:T}=o(x.id);T&&(T.parentElement!==S&&S.appendChild(T),T.style.display=x.id===h.selectedId?"contents":"none")}});const f=h.tabs.find(({id:S})=>S===h.selectedId),b=s&&f&&a(f)?f:void 0,y=t?.tabsetId===h.id&&"region"in t?t.region:void 0;return O.jsxs("div",{className:e?.tabPanels,"data-tab-panels":!0,"data-tab-placement":d,"data-tabset-collapsed":c||void 0,ref:m,style:{position:"relative",...l?.tabPanels,...c&&{display:"none"}},children:[h.tabs.length===0&&r?.(h),b&&O.jsx("div",{style:{display:"contents"},children:O.jsx(zs,{hiddenTabBehavior:n(b),renderTabContent:i,tab:b})}),y&&O.jsx("div",{className:e?.dropIndicator,"data-drop-indicator":!0,"data-region":y,style:{...l?.dropIndicator,...Xi[y],pointerEvents:"none",position:"absolute",zIndex:1}})]})}const Do=Object.assign(Ji,{displayName:"Workspace.TabPanels"});function Ps(e,t){return t===e||t.hasAttribute("data-tab-list")&&t.closest("[data-tabset-header]")===e}function Zi(e,t){const n=Array.from(e.querySelectorAll("[data-tabset-drag-handle]")).filter(o=>o.closest("[data-tabset-header]")===e);return n.length>0?n.some(o=>o.contains(t)):Ps(e,t)}function Qi(){const{activeTabsetId:e,classNames:t,disabled:n,dragTabsetId:o,model:s,renderTabsetToolbar:r,setActiveTabsetId:i,startTabsetDrag:a,styles:l,updateModel:c}=Qe("TabsetView"),{isCollapsed:u,setHeaderElement:d,setTabsetElement:h,tabPlacement:g,tabset:m}=Jt("TabsetView"),f=En(s,m,n),b=O.jsxs("div",{className:t?.header,"data-tab-placement":g,"data-tabset-collapsed":u||void 0,"data-tabset-header":!0,onClick:y=>{u&&Ps(y.currentTarget,y.target)&&c("expand",!0,S=>St(S,m.id))},onPointerDown:y=>{y.button===0&&!f&&Zi(y.currentTarget,y.target)&&a(m.id,y)},ref:d,style:l?.header,children:[O.jsx(Yi,{children:m.tabs.map(y=>O.jsx(qi,{tab:y},y.id))}),r&&O.jsx("div",{className:t?.toolbar,"data-tab-placement":g,"data-tabset-collapsed":u||void 0,"data-tabset-toolbar":!0,style:l?.toolbar,children:r(m)})]});return O.jsx("div",{className:t?.tabset,"data-tab-placement":g,"data-tabset":!0,"data-tabset-active":e===m.id||void 0,"data-tabset-collapsed":u||void 0,"data-tabset-dragging":o===m.id||void 0,"data-tabset-id":m.id,"data-tabset-maximized":s.maximizedTabsetId===m.id||void 0,onFocusCapture:()=>i(m.id),onPointerDownCapture:()=>i(m.id),ref:h,style:l?.tabset,children:g==="bottom"||g==="right"?O.jsxs(O.Fragment,{children:[O.jsx(Do,{}),b]}):O.jsxs(O.Fragment,{children:[b,O.jsx(Do,{})]})})}const ea=Object.assign(Qi,{displayName:"Workspace.TabsetView"});function ta(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return{height:Math.max(0,Math.round((n.height-o.height)/Ae(e,"vertical"))),width:Math.max(0,Math.round((n.width-o.width)/Ae(e,"horizontal")))}}function na(e,t,n){const o=t.dataset.tabPlacement==="left"||t.dataset.tabPlacement==="right",s=o?"width":"height",r=t.style,i=r.flex,a=r[s];r.flex="none",r[s]="max-content";const l=t.getBoundingClientRect();r.flex=i,r[s]=a;const c=o?l.width/Ae(t,"horizontal"):l.height/Ae(t,"vertical"),u=e.ownerDocument.defaultView?.getComputedStyle(e),d=n==="horizontal"?["left","right"]:["top","bottom"];let h=0;for(const g of d)h+=(parseFloat(u?.getPropertyValue(`padding-${g}`)??"")||0)+(parseFloat(u?.getPropertyValue(`border-${g}-width`)??"")||0);return Math.round(c+h)}function oa({isMaximizedOverlay:e=!1,tabset:t}){const{collapseOverrides:n,collapsePreview:o,getTabsetHandle:s,model:r,modelIndex:i,outerParents:a,reportChromeSize:l,reportCollapsedSize:c,tabPlacement:u}=Qe("TabsetSlot"),d=i.parentsById.get(t.id),h=d?.orientation,g=!e&&Gt(t,n),m=o[t.id]!==void 0;let f=t.tabPlacement??u;if(g&&d){const R=d.children[d.children.length-1]?.id===t.id,v=f==="left"||f==="right";h==="horizontal"&&!v?f=R?"right":"left":h==="vertical"&&v&&(f=R?"bottom":"top")}const[b,y]=p.useState(null),[S,x]=p.useState(null),[T,E]=p.useState(null),j=t.collapsible&&!e?h:void 0,k=p.useRef(null);ne(()=>{if(!b||!T)return;const R=()=>{if(!m){if(!g){const C=T.getBoundingClientRect();(h==="horizontal"?C.width<=0:h==="vertical"?C.height<=0:C.width<=0||C.height<=0)||l(t.id,ta(b,T))}if(S&&j){const C=na(b,S,j),M=k.current;g?(k.current={orientation:j,size:C},c(t.id,C)):M?.orientation!==j&&c(t.id,C)}}};R();const v=b.ownerDocument.defaultView?.ResizeObserver;if(v){const C=new v(R);return C.observe(b),C.observe(T),S&&C.observe(S),()=>{C.disconnect()}}},[j,S,g,m,h,T,l,c,f,t.id,b]);const I=p.useMemo(()=>({isCollapsed:g,setHeaderElement:x,setPanelsElement:E,setTabsetElement:y,tabPlacement:f,tabset:t}),[g,f,t]);return!e&&r.maximizedTabsetId===t.id?null:O.jsx(qt.Provider,{value:a.grid,children:O.jsx(Yt.Provider,{value:a.group,children:O.jsx(Xt.Provider,{value:a.panel,children:O.jsx(lt.Provider,{value:null,children:O.jsx(dt.Provider,{value:s(t.id),children:O.jsx(ws.Provider,{value:I,children:O.jsx(ea,{})})})})})})})}const Ms=Object.assign(oa,{displayName:"Workspace.TabsetSlot"});function sa({node:e}){return e.type==="split"?O.jsx(Hi,{split:e}):O.jsx(Ms,{tabset:e})}const ks=Object.assign(sa,{displayName:"Workspace.NodeView"});function nt(e,t){const n=Object.keys(e).filter(s=>!t.has(s));if(n.length===0)return e;const o={...e};for(const s of n)delete o[s];return o}function Oo(e,t){let n=e;for(const[o,s]of Object.entries(t))e[o]!==s&&(n===e&&(n={...e}),s===void 0?delete n[o]:n[o]=s);return n}function Dt(e,t){if(e===void 0)return;if(typeof e!="string"){Re(`Workspace tabset sizes (e.g. minWidth or maxWidth) must be strings with units (e.g. "200px"); received ${e}`);return}const[n,o]=vn(e);switch(o){case"%":{Re(`Workspace tabset sizes (e.g. minWidth or maxWidth) must use absolute units (px, em, rem, vh, or vw); received "${e}". Use "vw" or "vh" for sizes relative to the viewport.`);return}case"px":return n;default:return t?Ke({axisSize:0,itemElement:t,styleProp:e}):void 0}}function rn(e,t){if(!t||"index"in e)return e;switch(e.region){case"left":return{...e,region:"right"};case"right":return{...e,region:"left"};default:return e}}function ra({children:e,className:t,dragType:n,elementRef:o,pointRef:s,style:r}){const i=p.useRef(null);return ne(()=>(o.current=i.current,Cs(i.current,s.current),()=>{o.current=null}),[o,s]),O.jsx("div",{className:t,"data-drag-preview":!0,"data-drag-type":n,ref:i,style:{zIndex:2,...r,left:0,pointerEvents:"none",position:"fixed",top:0},children:e})}const ia=Object.assign(ra,{displayName:"Workspace.DragPreview"});function aa({className:e,classNames:t,defaultModel:n,disabled:o=!1,disableDrop:s,elementRef:r,hiddenTabBehavior:i="keep-mounted",id:a,onModelChanged:l,renderDragPreview:c,renderEmptyTabset:u,renderSeparator:d,renderTab:h,renderTabContent:g,renderTabsetDragPreview:m,renderTabsetToolbar:f,resizePreviewMode:b,serverRenderTabContent:y=!1,style:S,styles:x,tabPlacement:T="top",tabRemovalSelectionBehavior:E="adjacent",tabsetMinHeight:j,tabsetMinWidth:k,workspaceRef:I,...R}){const v=Je(a),C=p.useContext(qt),M=p.useContext(Yt),N=p.useContext(Xt),V=p.useMemo(()=>({grid:C,group:M,panel:N}),[C,M,N]),[D,K]=p.useState(()=>on(Se(Ro(n)),E)),H=p.useRef(D),[W,F]=p.useState(0),[G,J]=p.useState(),Y=p.useRef(void 0),re=p.useCallback(z=>{Y.current!==z&&(Y.current=z,J(z))},[]),ue=Ce((...z)=>l?.(...z)),pe=Ce(()=>E),w=p.useCallback((z,P,B)=>{const oe=pe(),qe=on(H.current,oe),Mt=B(qe);if(Mt!==qe){const tn=on(Mt,oe);H.current=tn,K(tn),ue(tn,{isUserInteraction:P,reason:z})}},[pe,ue]),[_]=p.useState(yi),q=p.useRef(null),L=p.useMemo(()=>{const z=()=>{const P=Y.current;return le(H.current,P)?P:void 0};return{addTab:(P,B={})=>{const oe=Si(H.current,P,{...B,tabsetId:B.tabsetId??z()});return w(oe.added?"add":"select",!1,()=>oe.model),oe.added},closeTab:P=>w("close",!1,B=>Mn(B,P)),closeTabset:P=>w("close",!1,B=>xi(B,P)),collapseTabset:P=>w("collapse",!1,B=>wi(B,P)),expandTabset:P=>w("expand",!1,B=>St(B,P)),getActiveTabsetId:z,getModel:()=>H.current,getTabListFreeSpace:P=>_.get(P),maximizeTabset:P=>w("maximize",!1,B=>Ti(B,P)),moveTab:(P,B)=>w("move",!1,oe=>Lo(oe,P,rn(B,ht(q.current)))),moveTabset:(P,B)=>w("move",!1,oe=>Po(oe,P,rn(B,ht(q.current)))),restoreTabset:()=>w("restore",!1,Ri),selectTab:P=>w("select",!1,B=>Ft(B,P)),setModel:P=>(w("set-model",!1,()=>Se(Ro(P))),F(B=>B+1),H.current),subscribeToTabListFreeSpace:(P,B)=>_.subscribe(P,B),updateTab:(P,B)=>w("update",!1,oe=>Li(oe,P,B)),updateTabset:(P,B)=>w("update",!1,oe=>Pi(oe,P,B))}},[_,w]);p.useImperativeHandle(I,()=>L,[L]);const A=p.useMemo(()=>({...L,id:v}),[L,v]),[$]=p.useState(()=>({tabs:new Map,tabsets:new Map})),U=p.useCallback(z=>{let P=$.tabs.get(z);return P||(P={close:()=>L.closeTab(z),getTabsetId:()=>Xe(H.current,z)?.id??"",id:z,isSelected:()=>Xe(H.current,z)?.selectedId===z,select:()=>L.selectTab(z),workspaceId:v},$.tabs.set(z,P)),P},[L,$,v]),Q=p.useCallback(z=>{let P=$.tabsets.get(z);return P||(P={addTab:(B,oe={})=>L.addTab(B,{...oe,tabsetId:z}),close:()=>L.closeTabset(z),collapse:()=>L.collapseTabset(z),expand:()=>L.expandTabset(z),id:z,isCollapsed:()=>!!le(H.current,z)?.collapsed,isMaximized:()=>H.current.maximizedTabsetId===z,maximize:()=>L.maximizeTabset(z),restore:()=>{H.current.maximizedTabsetId===z&&L.restoreTabset()},workspaceId:v},$.tabsets.set(z,P)),P},[L,$,v]),[X,te]=p.useState(null),de=Ze(q,te,r),[we]=p.useState(()=>new Map),Z=p.useRef(0),se=X?.ownerDocument,ze=p.useCallback(z=>{let P=we.get(z);if(!P){const B=++Z.current;P={element:null,panelId:`${v}-tab-panel-${B}`,tabElementId:`${v}-tab-${B}`},we.set(z,P)}return!P.element&&se&&(P.element=se.createElement("div")),P},[v,se,we]),Te=zi(D.root),ge=p.useMemo(()=>Ci(D),[D]);p.useEffect(()=>{const z=new Set(Te.map(({id:P})=>P));for(const[P,B]of we)z.has(P)||(B.element?.remove(),we.delete(P),$.tabs.delete(P));for(const P of $.tabsets.keys())ge.tabsetsById.has(P)||$.tabsets.delete(P)});const je=p.useSyncExternalStore(Ut,()=>!1,()=>!0),Le=p.useCallback(z=>typeof i=="function"?i(z):i,[i]),Ve=p.useCallback(z=>typeof y=="function"?y(z):y,[y]),[Me,Ne]=p.useState({}),[Ge,me]=p.useState({}),[ae,he]=p.useState({}),Fe=p.useCallback((z,P)=>Ne(B=>B[z]?.height===P.height&&B[z]?.width===P.width?B:{...B,[z]:P}),[]),[Be,Zt]=p.useState({}),On=p.useCallback(z=>Zt(P=>Oo(P,z)),[]),[An,$n]=p.useState({}),jn=p.useCallback(z=>$n(P=>Oo(P,z)),[]),xt=p.useMemo(()=>new Set(ge.parentsById.keys()),[ge]),We=p.useMemo(()=>nt(An,xt),[An,xt]),wt=p.useMemo(()=>Object.keys(We).length===0?Be:Object.keys(Be).length===0?We:{...We,...Be},[Be,We]);p.useEffect(()=>Wt(({next:z,prev:P})=>{P.state==="active"&&z.state!=="active"&&Zt(B=>Object.keys(B).length>0?{}:B)}),[]);const Nn=p.useCallback((z,P)=>he(B=>B[z]===P?B:{...B,[z]:P}),[]),Gn=p.useCallback((z,P)=>me(B=>B[z]===P?B:{...B,[z]:P}),[]);p.useEffect(()=>{Ne(z=>nt(z,ge.nodeIds)),me(z=>nt(z,ge.nodeIds)),he(z=>nt(z,ge.nodeIds)),Zt(z=>nt(z,ge.nodeIds)),$n(z=>nt(z,xt))},[ge,xt]);const[et,Es]=p.useState(null);p.useEffect(()=>{if(!X)return;const z=()=>Es({element:X});z();const P=X.ownerDocument.defaultView;return P?.addEventListener("resize",z),()=>{P?.removeEventListener("resize",z)}},[X]);const Fn=p.useMemo(()=>bi(D.root,{getChromeSize:z=>Me[z],getCollapsedSize:z=>ae[z],getContentMinimumSize:z=>({height:Dt(z.minHeight??j,et?.element??null)??0,width:Dt(z.minWidth??k,et?.element??null)??0}),getSeparatorsSize:z=>Ge[z]}),[Me,ae,D.root,Ge,j,k,et]),Bn=p.useMemo(()=>gi(D.root,{getChromeSize:z=>Me[z],getCollapsedSize:z=>ae[z],getContentMaximumSize:z=>({height:Dt(z.maxHeight,et?.element??null)??1/0,width:Dt(z.maxWidth,et?.element??null)??1/0}),getSeparatorsSize:z=>Ge[z]}),[Me,ae,D.root,Ge,et]),Ds=Ce((z,P)=>{if(typeof s!="function")return!!s;const B=H.current;if(z.type==="tab"){const qe=it(B,z.tabId);return qe?s({model:B,tab:qe,tabset:void 0,target:P}):!0}const oe=le(B,z.tabsetId);return oe?oe.tabs.length===0?s({model:B,tab:void 0,tabset:oe,target:P}):oe.tabs.some((qe,Mt)=>s({model:B,tab:qe,tabset:oe,target:"index"in P?{...P,index:P.index+Mt}:P})):!0}),Os=p.useCallback((z,P)=>w("move",!0,B=>{const oe=rn(P,ht(q.current));return z.type==="tab"?Lo(B,z.tabId,oe):Po(B,z.tabsetId,oe)}),[w]),As=p.useCallback(()=>H.current,[]),$s=p.useCallback(()=>q.current,[]),{dragSource:zt,dropTarget:Wn,previewElementRef:js,previewPointRef:Ns,startTabDrag:Hn,startTabsetDrag:Vn}=Ni({getModel:As,getRootElement:$s,isDropDisabled:Ds,onDrop:Os}),Ct=zt?.type==="tab"?zt.tabId:void 0,Tt=zt?.type==="tabset"?zt.tabsetId:void 0,Qt=p.useRef(void 0),_n=p.useCallback(z=>{Qt.current=z},[]),qn=p.useCallback(z=>Qt.current===z?(Qt.current=void 0,!0):!1,[]),Gs=p.useMemo(()=>({activeTabsetId:G,collapsedSizes:ae,collapseOverrides:wt,collapsePreview:Be,collapseToFit:We,disabled:o,dragTabId:Ct,dragTabsetId:Tt,dropTarget:Wn,getTabHandle:U,getTabHost:ze,getHiddenTabBehavior:Le,getTabsetHandle:Q,id:v,isHydrating:je,maximumSizes:Bn,minimumSizes:Fn,model:D,modelIndex:ge,outerParents:V,classNames:t,renderEmptyTabset:u,renderSeparator:d,renderTab:h,renderTabContent:g,renderTabsetToolbar:f,reportChromeSize:Fe,reportCollapsePreview:On,reportCollapseToFit:jn,reportCollapsedSize:Nn,reportSeparatorsSize:Gn,requestFocus:_n,resizePreviewMode:b,setActiveTabsetId:re,shouldServerRenderTabContent:Ve,splitGeneration:W,startTabDrag:Hn,startTabsetDrag:Vn,styles:x,tabListFreeSpaceStore:_,tabPlacement:T,takeFocusRequest:qn,updateModel:w}),[G,ae,wt,Be,We,o,Ct,Tt,Wn,U,ze,Le,Q,v,je,Bn,Fn,D,ge,V,t,u,d,h,g,f,Fe,On,jn,Nn,Gn,_n,b,re,Ve,W,Hn,Vn,x,_,T,qn,w]),en=p.useMemo(()=>({activeTabsetId:G,collapseOverrides:wt,collapseToFit:We,disabled:o,model:D,modelIndex:ge}),[G,wt,We,o,D,ge]),[It]=p.useState(()=>vi(en));It.setState(en),ne(()=>{It.notify()},[It,en]);const Rt=le(D,D.maximizedTabsetId),Un=p.useRef(null);ne(()=>{Un.current?.toggleAttribute("inert",!!Rt)},[Rt]);const Lt=Ct?it(D,Ct):void 0,_e=Tt?le(D,Tt):void 0,Kn=(z,P=0)=>{if(c)return c(z);const B=z.title??z.id;return P>0?`${B} (+${P})`:B};let Pt=null;if(Lt)Pt=Kn(Lt);else if(_e)if(m)Pt=m(_e);else{const z=_e.tabs.find(({id:P})=>P===_e.selectedId);Pt=z?Kn(z,_e.tabs.length-1):_e.id}return O.jsx(Dn.Provider,{value:A,children:O.jsx(fs.Provider,{value:It,children:O.jsxs(Pn.Provider,{value:Gs,children:[O.jsxs("div",{...R,className:e,"data-testid":at(R,a),"data-workspace":!0,id:v,ref:de,style:{position:"relative",...S},children:[O.jsx("div",{"data-workspace-layout":!0,ref:Un,style:{height:"100%",width:"100%"},children:O.jsx(ks,{node:D.root})}),Rt&&O.jsx("div",{"data-workspace-maximized":!0,style:{inset:0,position:"absolute",zIndex:1},children:O.jsx(Ms,{isMaximizedOverlay:!0,tabset:Rt})}),(Lt||_e)&&O.jsx(ia,{className:t?.dragPreview,dragType:Lt?"tab":"tabset",elementRef:js,pointRef:Ns,style:x?.dragPreview,children:Pt})]}),!je&&Te.map(z=>{const P=ze(z.id).element;return P?Fs.createPortal(O.jsx(zs,{hiddenTabBehavior:Le(z),renderTabContent:g,tab:z}),P,z.id):null})]})})})}const ca=Object.assign(aa,{displayName:"Workspace"});function la(e,{mapTab:t}={}){if(!bs(e)||e.version!==1)return null;if(!t)return Se(e);const n=s=>s.type==="split"?{...s,children:s.children.map(n)}:{...s,tabs:s.tabs.flatMap(r=>{const i=t(r);return i?[i]:[]})},o={...e,root:n(e.root)};return Se(o)}exports.Cell=Us;exports.Grid=kr;exports.Gridline=ts;exports.Group=ss;exports.Panel=is;exports.Separator=as;exports.SeparatorOverlay=os;exports.TabCloseButton=hs;exports.TabsetDragHandle=ci;exports.Workspace=ca;exports.isCoarsePointer=jo;exports.normalizeWorkspaceModel=la;exports.useDefaultGridLayout=Er;exports.useDefaultLayout=qr;exports.useGridCallbackRef=Dr;exports.useGridRef=Or;exports.useGroupCallbackRef=Ur;exports.useGroupRef=rs;exports.usePanelCallbackRef=Zr;exports.usePanelRef=Qr;exports.useParentGrid=Ar;exports.useParentGroup=Kr;exports.useParentPanel=ei;exports.useParentTab=li;exports.useParentTabState=ms;exports.useParentTabset=ui;exports.useParentTabsetState=gs;exports.useParentWorkspace=di;exports.useTabListFreeSpace=fi;exports.useWorkspaceCallbackRef=mi;exports.useWorkspaceRef=hi;
|
|
2
2
|
//# sourceMappingURL=react-resizable-panels.cjs.map
|