react-resizable-panels 4.0.8-alpha.1 → 4.0.8-alpha.2

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 F=require("react/jsx-runtime"),y=require("react");function b(e,t="Assertion error"){if(!e)throw Error(t)}function se(e,t){return t.sort(e==="horizontal"?Te:De)}function Te(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function De(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function Q({group:e}){const{orientation:t,panels:n}=e;return n.reduce((o,a)=>(o+=t==="horizontal"?a.element.offsetWidth:a.element.offsetHeight,o),0)}function xe(e){const{element:t,orientation:n,panels:o,separators:a}=e,s=se(n,Array.from(t.children).filter(l=>l instanceof HTMLElement).map(l=>({element:l}))).map(({element:l})=>l),u=[];let i,r;for(const l of s){const f=o.find(c=>c.element===l);if(f){if(i){const c=i.element.getBoundingClientRect(),h=l.getBoundingClientRect();u.push({group:e,groupSize:Q({group:e}),panels:[i,f],separator:r,rect:n==="horizontal"?new DOMRect(c.right,h.top,h.left-c.right,h.height):new DOMRect(h.left,c.bottom,h.width,h.top-c.bottom)})}i=f,r=void 0}else{const c=a.find(h=>h.element===l);c?r=c:(i=void 0,r=void 0)}}return u}function Ae(e,t){const n=getComputedStyle(e),o=parseFloat(n.fontSize);return t*o}function $e(e,t){const n=getComputedStyle(e.ownerDocument.body),o=parseFloat(n.fontSize);return t*o}function Ne(e){return e/100*window.innerHeight}function _e(e){return e/100*window.innerWidth}function je(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 Y({groupSize:e,panelElement:t,styleProp:n}){let o;const[a,s]=je(n);switch(s){case"%":{o=a/100*e;break}case"px":{o=a;break}case"rem":{o=$e(t,a);break}case"em":{o=Ae(t,a);break}case"vh":{o=Ne(a);break}case"vw":{o=_e(a);break}}return o}function I(e){return parseFloat(e.toFixed(3))}function pe(e){const{panels:t}=e,n=Q({group:e});return n===0?t.map(o=>({collapsedSize:0,collapsible:o.panelConstraints.collapsible===!0,defaultSize:void 0,minSize:0,maxSize:100,panelId:o.id})):t.map(o=>{const{element:a,panelConstraints:s}=o;let u=0;if(s.collapsedSize){const f=Y({groupSize:n,panelElement:a,styleProp:s.collapsedSize});u=I(f/n*100)}let i;if(s.defaultSize){const f=Y({groupSize:n,panelElement:a,styleProp:s.defaultSize});i=I(f/n*100)}let r=0;if(s.minSize){const f=Y({groupSize:n,panelElement:a,styleProp:s.minSize});r=I(f/n*100)}let l=100;if(s.maxSize){const f=Y({groupSize:n,panelElement:a,styleProp:s.maxSize});l=I(f/n*100)}return{collapsedSize:u,collapsible:s.collapsible===!0,defaultSize:i,minSize:r,maxSize:l,panelId:o.id}})}class Fe{#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);else{let a=!1,s=null;const u=Array.from(o);for(let i=0;i<u.length;i++){const r=u[i];try{r.call(null,n)}catch(l){s===null&&(a=!0,s=l)}}if(a)throw s}}removeAllListeners(){this.#e={}}removeListener(t,n){const o=this.#e[t];if(o!==void 0){const a=o.indexOf(n);a>=0&&o.splice(a,1)}}}function L(e,t,n=0){return Math.abs(I(e)-I(t))<=n}let C={cursorFlags:0,interactionState:{state:"inactive"},mountedGroups:new Map};const D=new Fe;function O(){return C}function M(e){const t=typeof e=="function"?e(C):e;if(C===t)return C;const n=C;return C={...C,...t},t.cursorFlags!==void 0&&D.emit("cursorFlagsChange",C.cursorFlags),t.interactionState!==void 0&&D.emit("interactionStateChange",C.interactionState),t.mountedGroups!==void 0&&(C.mountedGroups.forEach((o,a)=>{o.derivedPanelConstraints.forEach(s=>{if(s.collapsible){const{layout:u}=n.mountedGroups.get(a)??{};if(u){const i=L(s.collapsedSize,o.layout[s.panelId]),r=L(s.collapsedSize,u[s.panelId]);i&&!r&&(a.inMemoryLastExpandedPanelSizes[s.panelId]=u[s.panelId])}}})}),D.emit("mountedGroupsChange",C.mountedGroups)),C}const He=e=>e,oe=()=>{},ze=1,be=2,we=4,Le=8,me={coarse:10,precise:5};function We({cursorFlags:e,groups:t,state:n}){let o=0,a=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.disableCursor)switch(s.orientation){case"horizontal":{o++;break}case"vertical":{a++;break}}})}if(o===0&&a===0)return null;switch(n){case"active":{const s=(e&ze)!==0,u=(e&be)!==0,i=(e&we)!==0,r=(e&Le)!==0;if(e){if(s)return i?"se-resize":r?"ne-resize":"e-resize";if(u)return i?"sw-resize":r?"nw-resize":"w-resize";if(i)return"s-resize";if(r)return"n-resize"}break}}return o>0&&a>0?"move":o>0?"ew-resize":"ns-resize"}let ie,k;function re(){k===void 0&&(k=new CSSStyleSheet,document.adoptedStyleSheets=[k]);const{cursorFlags:e,interactionState:t}=O();switch(t.state){case"active":case"hover":{const n=We({cursorFlags:e,groups:t.hitRegions.map(a=>a.group),state:t.state}),o=`*{cursor: ${n} !important; ${t.state==="active"?"touch-action: none;":""} }`;if(ie===o)return;ie=o,n?k.cssRules.length===0?k.insertRule(o):k.replaceSync(o):k.cssRules.length===1&&k.deleteRule(0);break}case"inactive":{ie=void 0,k.cssRules.length===1&&k.deleteRule(0);break}}}function Ve(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 H(e,t){return L(e,t)?0:e>t?1:-1}function _({panelConstraints:e,size:t}){const{collapsedSize:n=0,collapsible:o,maxSize:a=100,minSize:s=0}=e;if(H(t,s)<0)if(o){const u=(n+s)/2;H(t,u)<0?t=n:t=s}else t=s;return t=Math.min(a,t),t=I(t),t}function W({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:o,prevLayout:a,trigger:s}){if(L(e,0))return t;const u=Object.values(t),i=Object.values(a),r=[...u],[l,f]=o;b(l!=null,"Invalid first pivot index"),b(f!=null,"Invalid second pivot index");let c=0;if(s==="keyboard"){{const d=e<0?f:l,p=n[d];b(p,`Panel constraints not found for index ${d}`);const{collapsedSize:v=0,collapsible:m,minSize:z=0}=p;if(m){const x=u[d];if(b(x!=null,`Previous layout not found for panel index ${d}`),L(x,v)){const g=z-x;H(g,Math.abs(e))>0&&(e=e<0?0-g:g)}}}{const d=e<0?l:f,p=n[d];b(p,`No panel constraints found for index ${d}`);const{collapsedSize:v=0,collapsible:m,minSize:z=0}=p;if(m){const x=u[d];if(b(x!=null,`Previous layout not found for panel index ${d}`),L(x,z)){const g=x-v;H(g,Math.abs(e))>0&&(e=e<0?0-g:g)}}}}{const d=e<0?1:-1;let p=e<0?f:l,v=0;for(;;){const z=u[p];b(z!=null,`Previous layout not found for panel index ${p}`);const g=_({panelConstraints:n[p],size:100})-z;if(v+=g,p+=d,p<0||p>=n.length)break}const m=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-m:m}{let p=e<0?l:f;for(;p>=0&&p<n.length;){const v=Math.abs(e)-Math.abs(c),m=u[p];b(m!=null,`Previous layout not found for panel index ${p}`);const z=m-v,x=_({panelConstraints:n[p],size:z});if(!L(m,x)&&(c+=m-x,r[p]=x,c.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(Ve(i,r))return a;{const d=e<0?f:l,p=u[d];b(p!=null,`Previous layout not found for panel index ${d}`);const v=p+c,m=_({panelConstraints:n[d],size:v});if(r[d]=m,!L(m,v)){let z=v-m,g=e<0?f:l;for(;g>=0&&g<n.length;){const P=r[g];b(P!=null,`Previous layout not found for panel index ${g}`);const R=P+z,E=_({panelConstraints:n[g],size:R});if(L(P,E)||(z-=E-P,r[g]=E),L(z,0))break;e>0?g--:g++}}}const h=Object.values(r).reduce((d,p)=>p+d,0);if(!L(h,100,.1))return a;const S=Object.keys(a);return r.reduce((d,p,v)=>(d[S[v]]=p,d),{})}function V(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(H(e[n],t[n])!==0)return!1;return!0}function Pe({event:e,hitRegions:t,initialLayoutMap:n,mountedGroups:o,pointerDownAtPoint:a}){let s=0;const u=new Map(o);t.forEach(i=>{const{group:r,groupSize:l}=i,{disableCursor:f,orientation:c,panels:h}=r;let S=0;a?c==="horizontal"?S=(e.clientX-a.x)/l*100:S=(e.clientY-a.y)/l*100:c==="horizontal"?S=e.clientX<0?-100:100:S=e.clientY<0?-100:100;const d=n.get(r),{derivedPanelConstraints:p,layout:v,separatorToPanels:m}=o.get(r)??{};if(p&&d&&v&&m){const z=W({delta:S,initialLayout:d,panelConstraints:p,pivotIndices:i.panels.map(x=>h.indexOf(x)),prevLayout:v,trigger:"mouse-or-touch"});if(V(z,v)){if(S!==0&&!f)switch(c){case"horizontal":{s|=S<0?ze:be;break}case"vertical":{s|=S<0?we:Le;break}}}else{u.set(i.group,{derivedPanelConstraints:p,layout:z,separatorToPanels:m});const x=i.group.panels.map(({id:g})=>g).join(",");i.group.inMemoryLayouts[x]=z}}}),M({cursorFlags:s,mountedGroups:u}),re()}function he(e){if(e.defaultPrevented)return;if(e.relatedTarget!==null)return;if(e.clientX===0&&e.clientY===0)return;const{interactionState:t,mountedGroups:n}=O();switch(t.state){case"active":t.hitRegions.forEach(o=>{e.currentTarget===o.group.element&&Pe({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n})})}}function J(e){const t=e.parentElement;b(t,"Parent group element not found");const{mountedGroups:n}=O();for(const[o]of n)if(o.element===t)return o;throw Error("Could not find parent Group for separator element")}function A({layout:e,panelConstraints:t}){const o=[...Object.values(e)],a=o.reduce((i,r)=>i+r,0);if(o.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${o.map(i=>`${i}%`).join(", ")}`);if(!L(a,100)&&o.length>0)for(let i=0;i<t.length;i++){const r=o[i];b(r!=null,`No layout data found for index ${i}`);const l=100/a*r;o[i]=l}let s=0;for(let i=0;i<t.length;i++){const r=o[i];b(r!=null,`No layout data found for index ${i}`);const l=_({panelConstraints:t[i],size:r});r!=l&&(s+=r-l,o[i]=l)}if(!L(s,0))for(let i=0;i<t.length;i++){const r=o[i];b(r!=null,`No layout data found for index ${i}`);const l=r+s,f=_({panelConstraints:t[i],size:l});if(r!==f&&(s-=f-r,o[i]=f,L(s,0)))break}const u=Object.keys(e);return o.reduce((i,r,l)=>(i[u[l]]=r,i),{})}function Re({groupId:e}){const t=()=>{const{mountedGroups:n}=O();for(const[o,a]of n)if(o.id===e)return{group:o,...a};throw Error(`Group ${e} not found`)};return{getLayout(){const{layout:n}=t();return n},setLayout(n){const{derivedPanelConstraints:o,group:a,layout:s,separatorToPanels:u}=t(),i=A({layout:n,panelConstraints:o});return V(s,i)||M(r=>({mountedGroups:new Map(r.mountedGroups).set(a,{derivedPanelConstraints:o,layout:i,separatorToPanels:u})})),i}}}function Ee(e){const{mountedGroups:t}=O(),n=t.get(e);return b(n,`Mounted Group ${e.id} not found`),n}function T(e,t){const n=J(e),o=Ee(n),a=n.separators.find(c=>c.element===e);b(a,"Matching separator not found");const s=o.separatorToPanels.get(a);b(s,"Matching panels not found");const u=s.map(c=>n.panels.indexOf(c)),r=Re({groupId:n.id}).getLayout(),l=W({delta:t,initialLayout:r,panelConstraints:o.derivedPanelConstraints,pivotIndices:u,prevLayout:r,trigger:"keyboard"}),f=A({layout:l,panelConstraints:o.derivedPanelConstraints});V(r,f)||M(c=>({mountedGroups:new Map(c.mountedGroups).set(n,{derivedPanelConstraints:o.derivedPanelConstraints,layout:f,separatorToPanels:o.separatorToPanels})}))}function ve(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=J(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&T(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&T(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&T(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&T(t,-5);break}case"End":{e.preventDefault(),T(t,100);break}case"Enter":{e.preventDefault();const o=J(t),{derivedPanelConstraints:a,layout:s,separatorToPanels:u}=Ee(o),i=o.separators.find(c=>c.element===t);b(i,"Matching separator not found");const r=u.get(i);b(r,"Matching panels not found");const l=r[0],f=a.find(c=>c.panelId===l.id);if(b(f,"Panel metadata not found"),f.collapsible){const c=s[l.id],h=f.collapsedSize===c?o.inMemoryLastExpandedPanelSizes[l.id]??f.minSize:f.collapsedSize;T(t,h-c)}break}case"F6":{e.preventDefault();const a=J(t).separators.map(r=>r.element),s=Array.from(a).findIndex(r=>r===e.currentTarget);b(s!==null,"Index not found");const u=e.shiftKey?s>0?s-1:a.length-1:s+1<a.length?s+1:0;a[u].focus();break}case"Home":{e.preventDefault(),T(t,-100);break}}}function Be(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 Ue(e,t,n){let o,a={x:1/0,y:1/0};for(const s of t){const u=Be(n,s.rect);switch(e){case"horizontal":{u.x<=a.x&&(o=s,a=u);break}case"vertical":{u.y<=a.y&&(o=s,a=u);break}}}return o?{distance:a,hitRegion:o}:void 0}let Z;function Ke(){return Z===void 0&&(typeof matchMedia=="function"?Z=!!matchMedia("(pointer:coarse)").matches:Z=!1),Z}function Ce(e,t){const n=[];return t.forEach((o,a)=>{if(a.disabled)return;const s=Ke()?me.coarse:me.precise,u=xe(a),i=Ue(a.orientation,u,{x:e.clientX,y:e.clientY});i&&i.distance.x<=s&&i.distance.y<=s&&n.push(i.hitRegion)}),n}function ye(e){if(e.defaultPrevented)return;const{mountedGroups:t}=O(),n=Ce(e,t),o=new Set,a=new Set,s=new Set,u=new Map;let i=!1;n.forEach(r=>{o.add(r.group),r.panels.forEach(f=>{a.add(f)}),r.separator&&(s.add(r.separator),i||(i=!0,r.separator.element.focus()));const l=t.get(r.group);l&&u.set(r.group,l.layout)}),M({interactionState:{hitRegions:n,initialLayoutMap:u,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}}),n.length&&e.preventDefault()}function Se(e){if(e.defaultPrevented)return;const{interactionState:t,mountedGroups:n}=O();switch(t.state){case"active":{if(e.type!=="pointerleave"&&e.buttons===0){M(o=>o.interactionState.state==="inactive"?o:{cursorFlags:0,interactionState:{state:"inactive"}});return}Pe({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint});break}default:{const o=Ce(e,n);o.length===0?t.state!=="inactive"&&M({interactionState:{state:"inactive"}}):M({interactionState:{hitRegions:o,state:"hover"}}),re();break}}}function ge(e){if(e.defaultPrevented)return;e.preventDefault();const{interactionState:t}=O();switch(t.state){case"active":M({cursorFlags:0,interactionState:{state:"inactive"}}),re()}}function qe(e){let t=0,n=0;const o={};for(const s of e)if(s.defaultSize!==void 0){t++;const u=I(s.defaultSize);n+=u,o[s.panelId]=u}else o[s.panelId]=void 0;const a=e.length-t;if(a!==0){const s=I((100-n)/a);for(const u of e)u.defaultSize===void 0&&(o[u.panelId]=s)}return o}function Xe(e,t,n){const o=n[0];if(!o)return;const a=e.panels.find(u=>u.element===t);if(!a||!a.onResize)return;const s=Q({group:e});a.onResize({asPercentage:I(o.inlineSize/s*100),inPixels:o.inlineSize},a.id)}function Ye(e){let t=!0;b(e.separators.length===0||e.separators.length<e.panels.length,"Invalid Group configuration; too many Separator components");const n=new Set,o=new Set,a=new ResizeObserver(c=>{for(const h of c){const{borderBoxSize:S,target:d}=h;d===e.element?t&&M(p=>{const v=p.mountedGroups.get(e);if(v){const m=pe(e),z=v.layout,x=A({layout:z,panelConstraints:m});return{mountedGroups:new Map(p.mountedGroups).set(e,{derivedPanelConstraints:m,layout:x,separatorToPanels:v.separatorToPanels})}}return p}):Xe(e,d,S)}});a.observe(e.element),e.panels.forEach(c=>{b(!n.has(c.id),`Panel ids must be unique; id "${c.id}" was used more than once`),n.add(c.id),c.onResize&&a.observe(c.element)});const s=pe(e),u=e.panels.map(({id:c})=>c).join(","),i=e.inMemoryLayouts[u]??e.defaultLayout??qe(s),r=A({layout:i,panelConstraints:s}),l=xe(e),f=M(c=>({mountedGroups:new Map(c.mountedGroups).set(e,{derivedPanelConstraints:s,layout:r,separatorToPanels:new Map(l.filter(h=>h.separator).map(h=>[h.separator,h.panels]))})}));return e.element.addEventListener("pointerleave",he),e.separators.forEach(c=>{b(!o.has(c.id),`Separator ids must be unique; id "${c.id}" was used more than once`),o.add(c.id),c.element.addEventListener("keydown",ve)}),f.mountedGroups.size===1&&(window.addEventListener("pointerdown",ye),window.addEventListener("pointermove",Se),window.addEventListener("pointerup",ge)),function(){t=!1;const h=M(S=>{const d=new Map(S.mountedGroups);return d.delete(e),{mountedGroups:d}});e.element.removeEventListener("pointerleave",he),e.separators.forEach(S=>{S.element.removeEventListener("keydown",ve)}),h.mountedGroups.size===0&&(window.removeEventListener("pointerdown",ye),window.removeEventListener("pointermove",Se),window.removeEventListener("pointerup",ge)),a.disconnect()}}function le(e){const t=y.useId();return`${e??t}`}const j=typeof window<"u"?y.useLayoutEffect:y.useEffect;function ue(e){const t=y.useRef(e);return j(()=>{t.current=e},[e]),y.useCallback(n=>t.current?.(n),[t])}function ce(...e){return ue(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}const Me="--react-resizable-panels--panel--pointer-events";function Ge(e,t){const n=e.replace(/[^a-zA-Z0-9\-_]/g,""),o=t.replace(/[^a-zA-Z0-9\-_]/g,"");return`--react-resizable-panels--${n}--${o}`}const Ie=y.createContext(null);function Ze(e,t){const n=y.useRef({getLayout:()=>({}),setLayout:He});y.useImperativeHandle(t,()=>n.current,[]),j(()=>{Object.assign(n.current,Re({groupId:e}))})}function Je(e){return y.useSyncExternalStore(t=>(e?.addEventListener("contentvisibilityautostatechange",t),()=>{e?.removeEventListener("contentvisibilityautostatechange",t)}),()=>typeof e?.checkVisibility=="function"?e.checkVisibility():!0,()=>!0)}function Qe({children:e,className:t,defaultLayout:n,disableCursor:o,disabled:a,elementRef:s,groupRef:u,id:i,onLayoutChange:r,orientation:l="horizontal",style:f,...c}){const h=y.useRef({}),S=ue(w=>{V(h.current,w)||(h.current=w,r?.(w))}),d=le(i),[p,v]=y.useState(!1),[m,z]=y.useState(null),[x,g]=y.useState(n??{}),[P,R]=y.useState([]),[E,B]=y.useState([]),ee=Je(m),U=y.useRef({}),K=y.useRef({}),q=ce(z,s);Ze(d,u);const te=y.useMemo(()=>({id:d,orientation:l,registerPanel:w=>(R(G=>se(l,[...G,w])),()=>{R(G=>G.filter($=>$!==w))}),registerSeparator:w=>(B(G=>se(l,[...G,w])),()=>{B(G=>G.filter($=>$!==w))})}),[d,l]);j(()=>{if(m===null||P.length===0)return;const w={defaultLayout:n,disableCursor:!!o,disabled:!!a,element:m,id:d,inMemoryLastExpandedPanelSizes:U.current,inMemoryLayouts:K.current,orientation:l,panels:P,separators:E},G=Ye(w),ne=O().mountedGroups.get(w);ne&&(g(ne.layout),S?.(ne.layout));const ke=D.addListener("interactionStateChange",X=>{switch(X.state){case"active":{v(X.hitRegions.some(N=>N.group===w));break}default:{v(!1);break}}}),Oe=D.addListener("mountedGroupsChange",X=>{const N=X.get(w);N&&N.derivedPanelConstraints.length>0&&(g(N.layout),S?.(N.layout))});return()=>{G(),ke(),Oe()}},[n,o,a,m,d,ee,S,l,P,E]);const de={[Me]:p?"none":void 0};for(const w in x){const G=Ge(d,w),$=x[w];de[G]=$}return F.jsx(Ie.Provider,{value:te,children:F.jsx("div",{...c,"aria-orientation":l,className:t,"data-group":!0,"data-testid":d,id:d,ref:q,style:{...f,...de,contentVisibility:"auto",display:"flex",flexDirection:l==="horizontal"?"row":"column",flexWrap:"nowrap"},children:e})})}function ae(e){return`react-resizable-panels:${e}`}function et({id:e,layout:t,storage:n}){try{const o=ae(e);n.setItem(o,JSON.stringify(t))}catch(o){console.error(o)}}function tt({groupId:e,storage:t}){const n=y.useSyncExternalStore(nt,()=>t.getItem(ae(e)),()=>t.getItem(ae(e))),o=y.useMemo(()=>n?JSON.parse(n):void 0,[n]),a=y.useCallback(s=>et({id:e,layout:s,storage:t}),[e,t]);return{defaultLayout:o,onLayoutChange:a}}function nt(){return function(){}}function ot(){return y.useState(null)}function it(){return y.useRef(null)}function fe(){const e=y.useContext(Ie);return b(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function st({groupId:e,panelId:t}){const n=()=>{const{mountedGroups:i}=O();for(const[r,{derivedPanelConstraints:l,layout:f,separatorToPanels:c}]of i)if(r.id===e)return{derivedPanelConstraints:l,group:r,layout:f,separatorToPanels:c};throw Error(`Group ${e} not found`)},o=()=>{const i=n().derivedPanelConstraints.find(r=>r.panelId===t);if(i!==void 0)return i;throw Error(`Panel constraints not found for Panel ${t}`)},a=()=>{const i=n().group.panels.find(r=>r.id===t);if(i!==void 0)return i;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const i=n().layout[t];if(i!==void 0)return i;throw Error(`Layout not found for Panel ${t}`)},u=i=>{const r=s();if(i===r)return;const{derivedPanelConstraints:l,group:f,layout:c,separatorToPanels:h}=n(),S=f.panels.findIndex(m=>m.id===t),d=S===f.panels.length-1,p=W({delta:d?r-i:i-r,initialLayout:c,panelConstraints:l,pivotIndices:d?[S-1,S]:[S,S+1],prevLayout:c,trigger:"imperative-api"}),v=A({layout:p,panelConstraints:l});V(c,v)||M(m=>({mountedGroups:new Map(m.mountedGroups).set(f,{derivedPanelConstraints:l,layout:v,separatorToPanels:h})}))};return{collapse:()=>{const{collapsible:i,collapsedSize:r}=o(),l=s();i&&l!==r&&u(r)},expand:()=>{const{collapsible:i,collapsedSize:r,minSize:l}=o(),f=s();i&&f===r&&u(l)},getSize:()=>{const{group:i}=n(),r=s(),{element:l}=a(),f=i.orientation==="horizontal"?l.offsetWidth:l.offsetHeight;return{asPercentage:r,inPixels:f}},isCollapsed:()=>{const{collapsible:i,collapsedSize:r}=o(),l=s();return i&&L(r,l)},resize:i=>{if(s()!==i){let l;switch(typeof i){case"number":{const{group:f}=n(),c=Q({group:f});l=I(i/c*100);break}case"string":{l=parseFloat(i);break}}u(l)}}}}function at(e,t){const{id:n}=fe(),o=y.useRef({collapse:oe,expand:oe,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:oe});y.useImperativeHandle(t,()=>o.current,[]),j(()=>{Object.assign(o.current,st({groupId:n,panelId:e}))})}function rt({children:e,className:t,collapsedSize:n="0%",collapsible:o=!1,defaultSize:a,elementRef:s,id:u,maxSize:i="100%",minSize:r="0%",onResize:l,panelRef:f,style:c,...h}){const S=!!u,d=le(u),[p,v]=y.useState(null),m=ce(v,s),{id:z,registerPanel:x}=fe(),g=l!==null,P=ue(E=>{l?.(E,u)});j(()=>{if(p!==null)return x({element:p,id:d,idIsStable:S,onResize:g?P:void 0,panelConstraints:{collapsedSize:n,collapsible:o,defaultSize:a,maxSize:i,minSize:r}})},[n,o,a,p,g,d,S,i,r,P,x]),at(d,f);const R=Ge(z,d);return F.jsx("div",{...h,"data-panel":!0,"data-testid":d,id:d,ref:m,style:{...lt,flexBasis:0,flexGrow:`var(${R}, 1)`,flexShrink:1,overflow:"hidden",pointerEvents:`var(${Me})`},children:F.jsx("div",{className:t,style:{width:"100%",height:"100%",...c},children:e})})}const lt={minHeight:"unset",maxHeight:"unset",height:"unset",minWidth:"unset",maxWidth:"unset",width:"unset",flex:"unset",flexBasis:"unset",flexShrink:"unset",flexGrow:"unset",border:"unset",borderWidth:"unset",padding:"unset",margin:"unset"};function ut(){return y.useState(null)}function ct(){return y.useRef(null)}function ft({layout:e,panelConstraints:t,panelId:n,panelIndex:o}){let a,s;const u=e[n],i=t.find(r=>r.panelId===n);if(i){const r=i.maxSize,l=s=i.collapsible?i.collapsedSize:i.minSize,f=[o,o+1];s=A({layout:W({delta:l-u,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n],a=A({layout:W({delta:r-u,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n]}return{valueControls:n,valueMax:a,valueMin:s,valueNow:u}}function dt({children:e,className:t,elementRef:n,id:o,style:a,...s}){const u=le(o),[i,r]=y.useState({}),[l,f]=y.useState("inactive"),[c,h]=y.useState(null),S=ce(h,n),{id:d,orientation:p,registerSeparator:v}=fe(),m=p==="horizontal"?"vertical":"horizontal";return j(()=>{if(c!==null){const z={element:c,id:u},x=v(z),g=D.addListener("interactionStateChange",R=>{f(R.state!=="inactive"&&R.hitRegions.some(E=>E.separator===z)?R.state:"inactive")}),P=D.addListener("mountedGroupsChange",R=>{R.forEach(({derivedPanelConstraints:E,layout:B,separatorToPanels:ee},U)=>{if(U.id===d){const K=ee.get(z);if(K){const q=K[0],te=U.panels.indexOf(q);r(ft({layout:B,panelConstraints:E,panelId:q.id,panelIndex:te}))}}})});return()=>{g(),P(),x()}}},[c,d,u,v]),F.jsx("div",{...s,"aria-controls":i.valueControls,"aria-orientation":m,"aria-valuemax":i.valueMax,"aria-valuemin":i.valueMin,"aria-valuenow":i.valueNow,children:e,className:t,"data-separator":l,"data-testid":u,id:u,ref:S,role:"separator",style:{flexBasis:"auto",...a,flexGrow:0,flexShrink:0},tabIndex:0})}exports.Group=Qe;exports.Panel=rt;exports.Separator=dt;exports.useDefaultLayout=tt;exports.useGroupCallbackRef=ot;exports.useGroupRef=it;exports.usePanelCallbackRef=ut;exports.usePanelRef=ct;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("react/jsx-runtime"),g=require("react");function b(e,t="Assertion error"){if(!e)throw Error(t)}function j({group:e}){const{orientation:t,panels:n}=e;return n.reduce((o,s)=>(o+=t==="horizontal"?s.element.offsetWidth:s.element.offsetHeight,o),0)}function se(e,t){return t.sort(e==="horizontal"?Te:De)}function Te(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function De(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function xe(e){const{element:t,orientation:n,panels:o,separators:s}=e,a=se(n,Array.from(t.children).filter(l=>l instanceof HTMLElement).map(l=>({element:l}))).map(({element:l})=>l),u=[];let i,r;for(const l of a){const c=o.find(d=>d.element===l);if(c){if(i){const d=i.element.getBoundingClientRect(),m=l.getBoundingClientRect();u.push({group:e,groupSize:j({group:e}),panels:[i,c],separator:r,rect:n==="horizontal"?new DOMRect(d.right,m.top,m.left-d.right,m.height):new DOMRect(m.left,d.bottom,m.width,m.top-d.bottom)})}i=c,r=void 0}else{const d=s.find(m=>m.element===l);d?r=d:(i=void 0,r=void 0)}}return u}function Ae(e,t){const n=getComputedStyle(e),o=parseFloat(n.fontSize);return t*o}function $e(e,t){const n=getComputedStyle(e.ownerDocument.body),o=parseFloat(n.fontSize);return t*o}function Ne(e){return e/100*window.innerHeight}function _e(e){return e/100*window.innerWidth}function je(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 J({groupSize:e,panelElement:t,styleProp:n}){let o;const[s,a]=je(n);switch(a){case"%":{o=s/100*e;break}case"px":{o=s;break}case"rem":{o=$e(t,s);break}case"em":{o=Ae(t,s);break}case"vh":{o=Ne(s);break}case"vw":{o=_e(s);break}}return o}function I(e){return parseFloat(e.toFixed(3))}function de(e){const{panels:t}=e,n=j({group:e});return n===0?t.map(o=>({collapsedSize:0,collapsible:o.panelConstraints.collapsible===!0,defaultSize:void 0,minSize:0,maxSize:100,panelId:o.id})):t.map(o=>{const{element:s,panelConstraints:a}=o;let u=0;if(a.collapsedSize){const c=J({groupSize:n,panelElement:s,styleProp:a.collapsedSize});u=I(c/n*100)}let i;if(a.defaultSize){const c=J({groupSize:n,panelElement:s,styleProp:a.defaultSize});i=I(c/n*100)}let r=0;if(a.minSize){const c=J({groupSize:n,panelElement:s,styleProp:a.minSize});r=I(c/n*100)}let l=100;if(a.maxSize){const c=J({groupSize:n,panelElement:s,styleProp:a.maxSize});l=I(c/n*100)}return{collapsedSize:u,collapsible:a.collapsible===!0,defaultSize:i,minSize:r,maxSize:l,panelId:o.id}})}class Fe{#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);else{let s=!1,a=null;const u=Array.from(o);for(let i=0;i<u.length;i++){const r=u[i];try{r.call(null,n)}catch(l){a===null&&(s=!0,a=l)}}if(s)throw a}}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 P(e,t,n=0){return Math.abs(I(e)-I(t))<=n}let C={cursorFlags:0,interactionState:{state:"inactive"},mountedGroups:new Map};const D=new Fe;function O(){return C}function M(e){const t=typeof e=="function"?e(C):e;if(C===t)return C;const n=C;return C={...C,...t},t.cursorFlags!==void 0&&D.emit("cursorFlagsChange",C.cursorFlags),t.interactionState!==void 0&&D.emit("interactionStateChange",C.interactionState),t.mountedGroups!==void 0&&(C.mountedGroups.forEach((o,s)=>{o.derivedPanelConstraints.forEach(a=>{if(a.collapsible){const{layout:u}=n.mountedGroups.get(s)??{};if(u){const i=P(a.collapsedSize,o.layout[a.panelId]),r=P(a.collapsedSize,u[a.panelId]);i&&!r&&(s.inMemoryLastExpandedPanelSizes[a.panelId]=u[a.panelId])}}})}),D.emit("mountedGroupsChange",C.mountedGroups)),C}const He=e=>e,oe=()=>{},ze=1,be=2,Le=4,we=8,pe={coarse:10,precise:5};function We({cursorFlags:e,groups:t,state:n}){let o=0,s=0;switch(n){case"active":case"hover":t.forEach(a=>{if(!a.disableCursor)switch(a.orientation){case"horizontal":{o++;break}case"vertical":{s++;break}}})}if(o===0&&s===0)return null;switch(n){case"active":{const a=(e&ze)!==0,u=(e&be)!==0,i=(e&Le)!==0,r=(e&we)!==0;if(e){if(a)return i?"se-resize":r?"ne-resize":"e-resize";if(u)return i?"sw-resize":r?"nw-resize":"w-resize";if(i)return"s-resize";if(r)return"n-resize"}break}}return o>0&&s>0?"move":o>0?"ew-resize":"ns-resize"}let ie,k;function re(){k===void 0&&(k=new CSSStyleSheet,document.adoptedStyleSheets=[k]);const{cursorFlags:e,interactionState:t}=O();switch(t.state){case"active":case"hover":{const n=We({cursorFlags:e,groups:t.hitRegions.map(s=>s.group),state:t.state}),o=`*{cursor: ${n} !important; ${t.state==="active"?"touch-action: none;":""} }`;if(ie===o)return;ie=o,n?k.cssRules.length===0?k.insertRule(o):k.replaceSync(o):k.cssRules.length===1&&k.deleteRule(0);break}case"inactive":{ie=void 0,k.cssRules.length===1&&k.deleteRule(0);break}}}function Be(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 B(e,t){return P(e,t)?0:e>t?1:-1}function _({panelConstraints:e,size:t}){const{collapsedSize:n=0,collapsible:o,maxSize:s=100,minSize:a=0}=e;if(B(t,a)<0)if(o){const u=(n+a)/2;B(t,u)<0?t=n:t=a}else t=a;return t=Math.min(s,t),t=I(t),t}function U({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:o,prevLayout:s,trigger:a}){if(P(e,0))return t;const u=Object.values(t),i=Object.values(s),r=[...u],[l,c]=o;b(l!=null,"Invalid first pivot index"),b(c!=null,"Invalid second pivot index");let d=0;if(a==="keyboard"){{const f=e<0?c:l,p=n[f];b(p,`Panel constraints not found for index ${f}`);const{collapsedSize:y=0,collapsible:h,minSize:x=0}=p;if(h){const z=u[f];if(b(z!=null,`Previous layout not found for panel index ${f}`),P(z,y)){const S=x-z;B(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}{const f=e<0?l:c,p=n[f];b(p,`No panel constraints found for index ${f}`);const{collapsedSize:y=0,collapsible:h,minSize:x=0}=p;if(h){const z=u[f];if(b(z!=null,`Previous layout not found for panel index ${f}`),P(z,x)){const S=z-y;B(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}}{const f=e<0?1:-1;let p=e<0?c:l,y=0;for(;;){const x=u[p];b(x!=null,`Previous layout not found for panel index ${p}`);const S=_({panelConstraints:n[p],size:100})-x;if(y+=S,p+=f,p<0||p>=n.length)break}const h=Math.min(Math.abs(e),Math.abs(y));e=e<0?0-h:h}{let p=e<0?l:c;for(;p>=0&&p<n.length;){const y=Math.abs(e)-Math.abs(d),h=u[p];b(h!=null,`Previous layout not found for panel index ${p}`);const x=h-y,z=_({panelConstraints:n[p],size:x});if(!P(h,z)&&(d+=h-z,r[p]=z,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(Be(i,r))return s;{const f=e<0?c:l,p=u[f];b(p!=null,`Previous layout not found for panel index ${f}`);const y=p+d,h=_({panelConstraints:n[f],size:y});if(r[f]=h,!P(h,y)){let x=y-h,S=e<0?c:l;for(;S>=0&&S<n.length;){const w=r[S];b(w!=null,`Previous layout not found for panel index ${S}`);const R=w+x,E=_({panelConstraints:n[S],size:R});if(P(w,E)||(x-=E-w,r[S]=E),P(x,0))break;e>0?S--:S++}}}const m=Object.values(r).reduce((f,p)=>p+f,0);if(!P(m,100,.1))return s;const v=Object.keys(s);return r.reduce((f,p,y)=>(f[v[y]]=p,f),{})}function F(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(B(e[n],t[n])!==0)return!1;return!0}function Pe({event:e,hitRegions:t,initialLayoutMap:n,mountedGroups:o,pointerDownAtPoint:s}){let a=0;const u=new Map(o);t.forEach(i=>{const{group:r,groupSize:l}=i,{disableCursor:c,orientation:d,panels:m}=r;let v=0;s?d==="horizontal"?v=(e.clientX-s.x)/l*100:v=(e.clientY-s.y)/l*100:d==="horizontal"?v=e.clientX<0?-100:100:v=e.clientY<0?-100:100;const f=n.get(r),{derivedPanelConstraints:p,layout:y,separatorToPanels:h}=o.get(r)??{};if(p&&f&&y&&h){const x=U({delta:v,initialLayout:f,panelConstraints:p,pivotIndices:i.panels.map(z=>m.indexOf(z)),prevLayout:y,trigger:"mouse-or-touch"});if(F(x,y)){if(v!==0&&!c)switch(d){case"horizontal":{a|=v<0?ze:be;break}case"vertical":{a|=v<0?Le:we;break}}}else{u.set(i.group,{derivedPanelConstraints:p,layout:x,separatorToPanels:h});const z=i.group.panels.map(({id:S})=>S).join(",");i.group.inMemoryLayouts[z]=x}}}),M({cursorFlags:a,mountedGroups:u}),re()}function me(e){if(e.defaultPrevented)return;if(e.relatedTarget!==null)return;if(e.clientX===0&&e.clientY===0)return;const{interactionState:t,mountedGroups:n}=O();switch(t.state){case"active":t.hitRegions.forEach(o=>{e.currentTarget===o.group.element&&Pe({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n})})}}function ee(e){const t=e.parentElement;b(t,"Parent group element not found");const{mountedGroups:n}=O();for(const[o]of n)if(o.element===t)return o;throw Error("Could not find parent Group for separator element")}function A({layout:e,panelConstraints:t}){const o=[...Object.values(e)],s=o.reduce((i,r)=>i+r,0);if(o.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${o.map(i=>`${i}%`).join(", ")}`);if(!P(s,100)&&o.length>0)for(let i=0;i<t.length;i++){const r=o[i];b(r!=null,`No layout data found for index ${i}`);const l=100/s*r;o[i]=l}let a=0;for(let i=0;i<t.length;i++){const r=o[i];b(r!=null,`No layout data found for index ${i}`);const l=_({panelConstraints:t[i],size:r});r!=l&&(a+=r-l,o[i]=l)}if(!P(a,0))for(let i=0;i<t.length;i++){const r=o[i];b(r!=null,`No layout data found for index ${i}`);const l=r+a,c=_({panelConstraints:t[i],size:l});if(r!==c&&(a-=c-r,o[i]=c,P(a,0)))break}const u=Object.keys(e);return o.reduce((i,r,l)=>(i[u[l]]=r,i),{})}function Re({groupId:e}){const t=()=>{const{mountedGroups:n}=O();for(const[o,s]of n)if(o.id===e)return{group:o,...s};throw Error(`Group ${e} not found`)};return{getLayout(){const{layout:n}=t();return n},setLayout(n){const{derivedPanelConstraints:o,group:s,layout:a,separatorToPanels:u}=t(),i=A({layout:n,panelConstraints:o});return F(a,i)||M(r=>({mountedGroups:new Map(r.mountedGroups).set(s,{derivedPanelConstraints:o,layout:i,separatorToPanels:u})})),i}}}function Ee(e){const{mountedGroups:t}=O(),n=t.get(e);return b(n,`Mounted Group ${e.id} not found`),n}function T(e,t){const n=ee(e),o=Ee(n),s=n.separators.find(d=>d.element===e);b(s,"Matching separator not found");const a=o.separatorToPanels.get(s);b(a,"Matching panels not found");const u=a.map(d=>n.panels.indexOf(d)),r=Re({groupId:n.id}).getLayout(),l=U({delta:t,initialLayout:r,panelConstraints:o.derivedPanelConstraints,pivotIndices:u,prevLayout:r,trigger:"keyboard"}),c=A({layout:l,panelConstraints:o.derivedPanelConstraints});F(r,c)||M(d=>({mountedGroups:new Map(d.mountedGroups).set(n,{derivedPanelConstraints:o.derivedPanelConstraints,layout:c,separatorToPanels:o.separatorToPanels})}))}function he(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=ee(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&T(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&T(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&T(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&T(t,-5);break}case"End":{e.preventDefault(),T(t,100);break}case"Enter":{e.preventDefault();const o=ee(t),{derivedPanelConstraints:s,layout:a,separatorToPanels:u}=Ee(o),i=o.separators.find(d=>d.element===t);b(i,"Matching separator not found");const r=u.get(i);b(r,"Matching panels not found");const l=r[0],c=s.find(d=>d.panelId===l.id);if(b(c,"Panel metadata not found"),c.collapsible){const d=a[l.id],m=c.collapsedSize===d?o.inMemoryLastExpandedPanelSizes[l.id]??c.minSize:c.collapsedSize;T(t,m-d)}break}case"F6":{e.preventDefault();const s=ee(t).separators.map(r=>r.element),a=Array.from(s).findIndex(r=>r===e.currentTarget);b(a!==null,"Index not found");const u=e.shiftKey?a>0?a-1:s.length-1:a+1<s.length?a+1:0;s[u].focus();break}case"Home":{e.preventDefault(),T(t,-100);break}}}function Ue(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 Ke(e,t,n){let o,s={x:1/0,y:1/0};for(const a of t){const u=Ue(n,a.rect);switch(e){case"horizontal":{u.x<=s.x&&(o=a,s=u);break}case"vertical":{u.y<=s.y&&(o=a,s=u);break}}}return o?{distance:s,hitRegion:o}:void 0}let Q;function Ve(){return Q===void 0&&(typeof matchMedia=="function"?Q=!!matchMedia("(pointer:coarse)").matches:Q=!1),Q}function Ce(e,t){const n=[];return t.forEach((o,s)=>{if(s.disabled)return;const a=Ve()?pe.coarse:pe.precise,u=xe(s),i=Ke(s.orientation,u,{x:e.clientX,y:e.clientY});i&&i.distance.x<=a&&i.distance.y<=a&&n.push(i.hitRegion)}),n}function ve(e){if(e.defaultPrevented)return;const{mountedGroups:t}=O(),n=Ce(e,t),o=new Set,s=new Set,a=new Set,u=new Map;let i=!1;n.forEach(r=>{o.add(r.group),r.panels.forEach(c=>{s.add(c)}),r.separator&&(a.add(r.separator),i||(i=!0,r.separator.element.focus()));const l=t.get(r.group);l&&u.set(r.group,l.layout)}),M({interactionState:{hitRegions:n,initialLayoutMap:u,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}}),n.length&&e.preventDefault()}function Se(e){if(e.defaultPrevented)return;const{interactionState:t,mountedGroups:n}=O();switch(t.state){case"active":{if(e.type!=="pointerleave"&&e.buttons===0){M(o=>o.interactionState.state==="inactive"?o:{cursorFlags:0,interactionState:{state:"inactive"}});return}Pe({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint});break}default:{const o=Ce(e,n);o.length===0?t.state!=="inactive"&&M({interactionState:{state:"inactive"}}):M({interactionState:{hitRegions:o,state:"hover"}}),re();break}}}function ge(e){if(e.defaultPrevented)return;e.preventDefault();const{interactionState:t}=O();switch(t.state){case"active":M({cursorFlags:0,interactionState:{state:"inactive"}}),re()}}function ye(e){let t=0,n=0;const o={};for(const a of e)if(a.defaultSize!==void 0){t++;const u=I(a.defaultSize);n+=u,o[a.panelId]=u}else o[a.panelId]=void 0;const s=e.length-t;if(s!==0){const a=I((100-n)/s);for(const u of e)u.defaultSize===void 0&&(o[u.panelId]=a)}return o}function qe(e,t,n){const o=n[0];if(!o)return;const s=e.panels.find(u=>u.element===t);if(!s||!s.onResize)return;const a=j({group:e});s.onResize({asPercentage:I(o.inlineSize/a*100),inPixels:o.inlineSize},s.id)}function Xe(e){let t=!0;b(e.separators.length===0||e.separators.length<e.panels.length,"Invalid Group configuration; too many Separator components");const n=new Set,o=new Set,s=new ResizeObserver(m=>{for(const v of m){const{borderBoxSize:f,target:p}=v;if(p===e.element){if(t){if(j({group:e})===0)return;M(h=>{const x=h.mountedGroups.get(e);if(x){const z=de(e),S=x.defaultLayoutDeferred?ye(z):x.layout,w=A({layout:S,panelConstraints:z});return!x.defaultLayoutDeferred&&F(S,w)?h:{mountedGroups:new Map(h.mountedGroups).set(e,{derivedPanelConstraints:z,layout:w,separatorToPanels:x.separatorToPanels})}}return h})}}else qe(e,p,f)}});s.observe(e.element),e.panels.forEach(m=>{b(!n.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),n.add(m.id),m.onResize&&s.observe(m.element)});const a=j({group:e}),u=de(e),i=e.panels.map(({id:m})=>m).join(","),r=e.inMemoryLayouts[i]??e.defaultLayout??ye(u),l=A({layout:r,panelConstraints:u}),c=xe(e),d=M(m=>({mountedGroups:new Map(m.mountedGroups).set(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:u,layout:l,separatorToPanels:new Map(c.filter(v=>v.separator).map(v=>[v.separator,v.panels]))})}));return e.element.addEventListener("pointerleave",me),e.separators.forEach(m=>{b(!o.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),o.add(m.id),m.element.addEventListener("keydown",he)}),d.mountedGroups.size===1&&(window.addEventListener("pointerdown",ve),window.addEventListener("pointermove",Se),window.addEventListener("pointerup",ge)),function(){t=!1;const v=M(f=>{const p=new Map(f.mountedGroups);return p.delete(e),{mountedGroups:p}});e.element.removeEventListener("pointerleave",me),e.separators.forEach(f=>{f.element.removeEventListener("keydown",he)}),v.mountedGroups.size===0&&(window.removeEventListener("pointerdown",ve),window.removeEventListener("pointermove",Se),window.removeEventListener("pointerup",ge)),s.disconnect()}}function le(e){const t=g.useId();return`${e??t}`}const H=typeof window<"u"?g.useLayoutEffect:g.useEffect;function ue(e){const t=g.useRef(e);return H(()=>{t.current=e},[e]),g.useCallback(n=>t.current?.(n),[t])}function ce(...e){return ue(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}const Me="--react-resizable-panels--panel--pointer-events";function Ge(e,t){const n=e.replace(/[^a-zA-Z0-9\-_]/g,""),o=t.replace(/[^a-zA-Z0-9\-_]/g,"");return`--react-resizable-panels--${n}--${o}`}const Ie=g.createContext(null);function Ye(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:He});g.useImperativeHandle(t,()=>n.current,[]),H(()=>{Object.assign(n.current,Re({groupId:e}))})}function Ze({children:e,className:t,defaultLayout:n,disableCursor:o,disabled:s,elementRef:a,groupRef:u,id:i,onLayoutChange:r,orientation:l="horizontal",style:c,...d}){const m=g.useRef({}),v=ue(L=>{F(m.current,L)||(m.current=L,r?.(L))}),f=le(i),[p,y]=g.useState(!1),[h,x]=g.useState(null),[z,S]=g.useState(n??{}),[w,R]=g.useState([]),[E,K]=g.useState([]),te=g.useRef({}),V=g.useRef({}),q=ce(x,a);Ye(f,u);const X=g.useMemo(()=>({id:f,orientation:l,registerPanel:L=>(R(G=>se(l,[...G,L])),()=>{R(G=>G.filter($=>$!==L))}),registerSeparator:L=>(K(G=>se(l,[...G,L])),()=>{K(G=>G.filter($=>$!==L))})}),[f,l]);H(()=>{if(h===null||w.length===0)return;const L={defaultLayout:n,disableCursor:!!o,disabled:!!s,element:h,id:f,inMemoryLastExpandedPanelSizes:te.current,inMemoryLayouts:V.current,orientation:l,panels:w,separators:E},G=Xe(L),ne=O().mountedGroups.get(L);ne&&(S(ne.layout),v?.(ne.layout));const ke=D.addListener("interactionStateChange",Z=>{switch(Z.state){case"active":{y(Z.hitRegions.some(N=>N.group===L));break}default:{y(!1);break}}}),Oe=D.addListener("mountedGroupsChange",Z=>{const N=Z.get(L);N&&N.derivedPanelConstraints.length>0&&(S(N.layout),v?.(N.layout))});return()=>{G(),ke(),Oe()}},[n,o,s,h,f,v,l,w,E]);const Y={[Me]:p?"none":void 0};for(const L in z){const G=Ge(f,L),$=z[L];Y[G]=$}return W.jsx(Ie.Provider,{value:X,children:W.jsx("div",{...d,"aria-orientation":l,className:t,"data-group":!0,"data-testid":f,id:f,ref:q,style:{...c,...Y,display:"flex",flexDirection:l==="horizontal"?"row":"column",flexWrap:"nowrap"},children:e})})}function ae(e){return`react-resizable-panels:${e}`}function Je({id:e,layout:t,storage:n}){try{const o=ae(e);n.setItem(o,JSON.stringify(t))}catch(o){console.error(o)}}function Qe({groupId:e,storage:t}){const n=g.useSyncExternalStore(et,()=>t.getItem(ae(e)),()=>t.getItem(ae(e))),o=g.useMemo(()=>n?JSON.parse(n):void 0,[n]),s=g.useCallback(a=>Je({id:e,layout:a,storage:t}),[e,t]);return{defaultLayout:o,onLayoutChange:s}}function et(){return function(){}}function tt(){return g.useState(null)}function nt(){return g.useRef(null)}function fe(){const e=g.useContext(Ie);return b(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function ot({groupId:e,panelId:t}){const n=()=>{const{mountedGroups:i}=O();for(const[r,{derivedPanelConstraints:l,layout:c,separatorToPanels:d}]of i)if(r.id===e)return{derivedPanelConstraints:l,group:r,layout:c,separatorToPanels:d};throw Error(`Group ${e} not found`)},o=()=>{const i=n().derivedPanelConstraints.find(r=>r.panelId===t);if(i!==void 0)return i;throw Error(`Panel constraints not found for Panel ${t}`)},s=()=>{const i=n().group.panels.find(r=>r.id===t);if(i!==void 0)return i;throw Error(`Layout not found for Panel ${t}`)},a=()=>{const i=n().layout[t];if(i!==void 0)return i;throw Error(`Layout not found for Panel ${t}`)},u=i=>{const r=a();if(i===r)return;const{derivedPanelConstraints:l,group:c,layout:d,separatorToPanels:m}=n(),v=c.panels.findIndex(h=>h.id===t),f=v===c.panels.length-1,p=U({delta:f?r-i:i-r,initialLayout:d,panelConstraints:l,pivotIndices:f?[v-1,v]:[v,v+1],prevLayout:d,trigger:"imperative-api"}),y=A({layout:p,panelConstraints:l});F(d,y)||M(h=>({mountedGroups:new Map(h.mountedGroups).set(c,{derivedPanelConstraints:l,layout:y,separatorToPanels:m})}))};return{collapse:()=>{const{collapsible:i,collapsedSize:r}=o(),l=a();i&&l!==r&&u(r)},expand:()=>{const{collapsible:i,collapsedSize:r,minSize:l}=o(),c=a();i&&c===r&&u(l)},getSize:()=>{const{group:i}=n(),r=a(),{element:l}=s(),c=i.orientation==="horizontal"?l.offsetWidth:l.offsetHeight;return{asPercentage:r,inPixels:c}},isCollapsed:()=>{const{collapsible:i,collapsedSize:r}=o(),l=a();return i&&P(r,l)},resize:i=>{if(a()!==i){let l;switch(typeof i){case"number":{const{group:c}=n(),d=j({group:c});l=I(i/d*100);break}case"string":{l=parseFloat(i);break}}u(l)}}}}function it(e,t){const{id:n}=fe(),o=g.useRef({collapse:oe,expand:oe,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:oe});g.useImperativeHandle(t,()=>o.current,[]),H(()=>{Object.assign(o.current,ot({groupId:n,panelId:e}))})}function st({children:e,className:t,collapsedSize:n="0%",collapsible:o=!1,defaultSize:s,elementRef:a,id:u,maxSize:i="100%",minSize:r="0%",onResize:l,panelRef:c,style:d,...m}){const v=!!u,f=le(u),[p,y]=g.useState(null),h=ce(y,a),{id:x,registerPanel:z}=fe(),S=l!==null,w=ue(E=>{l?.(E,u)});H(()=>{if(p!==null)return z({element:p,id:f,idIsStable:v,onResize:S?w:void 0,panelConstraints:{collapsedSize:n,collapsible:o,defaultSize:s,maxSize:i,minSize:r}})},[n,o,s,p,S,f,v,i,r,w,z]),it(f,c);const R=Ge(x,f);return W.jsx("div",{...m,"data-panel":!0,"data-testid":f,id:f,ref:h,style:{...at,flexBasis:0,flexGrow:`var(${R}, 1)`,flexShrink:1,overflow:"hidden",pointerEvents:`var(${Me})`},children:W.jsx("div",{className:t,style:{width:"100%",height:"100%",...d},children:e})})}const at={minHeight:"unset",maxHeight:"unset",height:"unset",minWidth:"unset",maxWidth:"unset",width:"unset",flex:"unset",flexBasis:"unset",flexShrink:"unset",flexGrow:"unset",border:"unset",borderWidth:"unset",padding:"unset",margin:"unset"};function rt(){return g.useState(null)}function lt(){return g.useRef(null)}function ut({layout:e,panelConstraints:t,panelId:n,panelIndex:o}){let s,a;const u=e[n],i=t.find(r=>r.panelId===n);if(i){const r=i.maxSize,l=a=i.collapsible?i.collapsedSize:i.minSize,c=[o,o+1];a=A({layout:U({delta:l-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n],s=A({layout:U({delta:r-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n]}return{valueControls:n,valueMax:s,valueMin:a,valueNow:u}}function ct({children:e,className:t,elementRef:n,id:o,style:s,...a}){const u=le(o),[i,r]=g.useState({}),[l,c]=g.useState("inactive"),[d,m]=g.useState(null),v=ce(m,n),{id:f,orientation:p,registerSeparator:y}=fe(),h=p==="horizontal"?"vertical":"horizontal";return H(()=>{if(d!==null){const x={element:d,id:u},z=y(x),S=D.addListener("interactionStateChange",R=>{c(R.state!=="inactive"&&R.hitRegions.some(E=>E.separator===x)?R.state:"inactive")}),w=D.addListener("mountedGroupsChange",R=>{R.forEach(({derivedPanelConstraints:E,layout:K,separatorToPanels:te},V)=>{if(V.id===f){const q=te.get(x);if(q){const X=q[0],Y=V.panels.indexOf(X);r(ut({layout:K,panelConstraints:E,panelId:X.id,panelIndex:Y}))}}})});return()=>{S(),w(),z()}}},[d,f,u,y]),W.jsx("div",{...a,"aria-controls":i.valueControls,"aria-orientation":h,"aria-valuemax":i.valueMax,"aria-valuemin":i.valueMin,"aria-valuenow":i.valueNow,children:e,className:t,"data-separator":l,"data-testid":u,id:u,ref:v,role:"separator",style:{flexBasis:"auto",...s,flexGrow:0,flexShrink:0},tabIndex:0})}exports.Group=Ze;exports.Panel=st;exports.Separator=ct;exports.useDefaultLayout=Qe;exports.useGroupCallbackRef=tt;exports.useGroupRef=nt;exports.usePanelCallbackRef=rt;exports.usePanelRef=lt;
2
2
  //# sourceMappingURL=react-resizable-panels.cjs.map