react-dockable-desktop 7.6.2 → 7.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -1
- package/README.md +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +118 -34
- package/dist/index.d.ts +118 -34
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/styles.css +26 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{forwardRef as ba,useContext as kr,useEffect as ho,useLayoutEffect as ln,useMemo as Nn,useRef as cn,useSyncExternalStore as ha}from"react";var Nt=class{registry=new Map;register(t,n,o){this.registry.set(t,{Component:n,defaultOptions:o})}get(t){return this.registry.get(t)}getRegisteredIds(){return Array.from(this.registry.keys())}},vn=new Nt;import{createContext as yt,useContext as Ve,useState as Hi,useRef as Qo,useMemo as so,useEffect as Cn,useSyncExternalStore as er}from"react";import{createContext as Li,useContext as Oi,useSyncExternalStore as Ni}from"react";var Wi={requestClose:()=>{console.warn("FormContainerContract: requestClose called but no container is present")},setDirty:()=>{},onCloseRequested:()=>()=>{},registerStateProvider:()=>()=>{},setTitle:()=>{},setIcon:()=>{},containerType:"standalone",instanceId:"standalone",onClose:()=>()=>{},onMinimize:()=>()=>{},onRestore:()=>()=>{},onResize:()=>()=>{},requestMinimize:()=>{},getDimensions:()=>null,onActivate:()=>()=>{},onDeactivate:()=>()=>{},onContainerTypeChange:()=>()=>{}},jo=Li(Wi),Wt=jo.Provider,Be=()=>Oi(jo),Ai=()=>{let{onResize:e,getDimensions:t}=Be();return Ni(n=>e?e(()=>n()):()=>{},()=>t?t():null)};var Jt={floatWindow:{id:"dockable-desktop-floatWindow",defaultMessage:"Float Window"},minimizePanel:{id:"dockable-desktop-minimizePanel",defaultMessage:"Minimize Panel"},closeTab:{id:"dockable-desktop-closeTab",defaultMessage:"Close Tab"},restorePanel:{id:"dockable-desktop-restorePanel",defaultMessage:"Restore Panel"},maximizePanel:{id:"dockable-desktop-maximizePanel",defaultMessage:"Maximize Panel"},closePanel:{id:"dockable-desktop-closePanel",defaultMessage:"Close Panel"},dockWindow:{id:"dockable-desktop-dockWindow",defaultMessage:"Dock Window"},minimize:{id:"dockable-desktop-minimize",defaultMessage:"Minimize"},maximize:{id:"dockable-desktop-maximize",defaultMessage:"Maximize"},restoreSize:{id:"dockable-desktop-restoreSize",defaultMessage:"Restore Size"},close:{id:"dockable-desktop-close",defaultMessage:"Close"},closeEmptyGroup:{id:"dockable-desktop-closeEmptyGroup",defaultMessage:"Close empty split group"},unsavedChangesTitle:{id:"dockable-desktop-unsavedChangesTitle",defaultMessage:"Unsaved Changes"},unsavedChangesMessage:{id:"dockable-desktop-unsavedChangesMessage",defaultMessage:'"{title}" has unsaved changes. Do you want to discard your changes and close?'},discardChanges:{id:"dockable-desktop-discardChanges",defaultMessage:"Discard Changes"},cancel:{id:"dockable-desktop-cancel",defaultMessage:"Cancel"},yes:{id:"dockable-desktop-yes",defaultMessage:"Yes"},no:{id:"dockable-desktop-no",defaultMessage:"No"},ok:{id:"dockable-desktop-ok",defaultMessage:"OK"},closePanelTooltip:{id:"dockable-desktop-closePanelTooltip",defaultMessage:"Close panel"},closeTooltip:{id:"dockable-desktop-closeTooltip",defaultMessage:"Close"},notifications:{id:"dockable-desktop-notifications",defaultMessage:"Notifications"},closeNotification:{id:"dockable-desktop-closeNotification",defaultMessage:"Close notification"},scrollTabsLeft:{id:"dockable-desktop-scrollTabsLeft",defaultMessage:"Scroll tabs left"},scrollTabsRight:{id:"dockable-desktop-scrollTabsRight",defaultMessage:"Scroll tabs right"},scrollTaskbarLeft:{id:"dockable-desktop-scrollTaskbarLeft",defaultMessage:"Scroll taskbar left"},scrollTaskbarRight:{id:"dockable-desktop-scrollTaskbarRight",defaultMessage:"Scroll taskbar right"},moreActions:{id:"dockable-desktop-moreActions",defaultMessage:"More actions"},search:{id:"dockable-desktop-search",defaultMessage:"Search"},closeSearch:{id:"dockable-desktop-closeSearch",defaultMessage:"Close search"},searchPlaceholder:{id:"dockable-desktop-searchPlaceholder",defaultMessage:"Search\u2026"},modalTitle:{id:"dockable-desktop-modalTitle",defaultMessage:"Confirmation"},emptyGroup:{id:"dockable-desktop-emptyGroup",defaultMessage:"Empty Workspace Section"},emptyGrid:{id:"dockable-desktop-emptyGrid",defaultMessage:"Grid Empty"},componentUnregistered:{id:"dockable-desktop-componentUnregistered",defaultMessage:"Component Unregistered"},componentKey:{id:"dockable-desktop-componentKey",defaultMessage:"Key: {key}"},untitledPanel:{id:"dockable-desktop-untitledPanel",defaultMessage:"Panel"}};var yn=e=>{let t=e.defaultMessage||e.id;if(e.values)for(let[n,o]of Object.entries(e.values))t=t.split(`{${n}}`).join(String(o));return t},q=(e,t)=>e?typeof e=="string"?e:typeof e=="function"?e():t(e):"";import{isValidElement as zi}from"react";function At(e){if(e===null)return!0;if(e===void 0)return!1;let t=typeof e;if(t==="string"||t==="number"||t==="boolean")return!0;if(t==="function"||t==="symbol"||t==="bigint")return!1;if(e instanceof Date)return!0;if(zi(e))return!1;if(Array.isArray(e))return e.every(At);let n=Object.getPrototypeOf(e);return n!==Object.prototype&&n!==null?!1:Object.values(e).every(At)}function Fi(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e);return n.length!==Object.keys(t).length?!1:n.every(o=>e[o]===t[o])}function Qt(e,t){return e===t?!0:typeof e!="object"||typeof t!="object"||!e||!t?!1:e.id===t.id&&e.defaultMessage===t.defaultMessage&&Fi(e.values,t.values)}function Pn(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let o of n){let r=e[o],a=t[o];if(o==="title"||o==="message"?!Qt(r,a):r!==a)return!1}return!0}var xn=class{listeners={};subscribe(t,n){return this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(n),()=>{this.listeners[t]=this.listeners[t].filter(o=>o!==n)}}publish(t,n){if(this.listeners[t])for(let o of this.listeners[t])try{o(n)}catch(r){console.error(`[react-dockable-desktop] A subscriber to "${t}" threw:`,r)}}};var tt={type:"leaf",id:"group-default",panels:[],activePanelId:null};function zt(e,t){let n=t.panels[e];if(!n||n.state==="minimized")return!1;if(t.floating.some(r=>r.id===e))return!0;let o=r=>r.type==="leaf"?r.activePanelId===e:r.children.some(o);return t.gridRoot?o(t.gridRoot):!1}function Ft(e){let t=a=>a!==null&&!!e.panels[a]&&e.panels[a].state!=="minimized",n=a=>{if(a.type==="leaf")return t(a.activePanelId)?a.activePanelId:null;for(let u of a.children){let s=n(u);if(s)return s}return null},o=e.gridRoot?n(e.gridRoot):null;if(o)return o;let r=null;for(let a of e.floating)t(a.id)&&(!r||a.z>r.z)&&(r=a);return r?.id??null}function bt(e,t){return t&&zt(t,e)?t:e.activePanelId&&zt(e.activePanelId,e)?e.activePanelId:Ft(e)}function qo(e,t){let n=[],o=new Set,r=s=>{if(s.type==="leaf"){let M=s.panels.filter(D=>t[D]?o.has(D)?(n.push(`panel "${D}" was listed in more than one group`),!1):(o.add(D),!0):(n.push(`group "${s.id}" listed panel "${D}", which the layout doesn't have`),!1));if(M.length===s.panels.length)return s;if(M.length===0&&!s.keepOnEmpty)return null;let P=s.activePanelId&&M.includes(s.activePanelId)?s.activePanelId:M[0]??null;return{...s,panels:M,activePanelId:P}}let d=s.children.map(r).filter(M=>M!==null),C=(M,P)=>Array.isArray(M)&&M.length===P&&M.every(D=>typeof D=="number"&&Number.isFinite(D)&&D>0),R=d.length===s.children.length&&d.every((M,P)=>M===s.children[P]);if(R&&C(s.sizes,d.length))return s;if(d.length===0)return null;if(d.length===1)return d[0];if(R)return n.push(`a split had sizes ${JSON.stringify(s.sizes)} for ${d.length} children`),{...s,sizes:d.map(()=>1/d.length)};let y=Array.isArray(s.sizes)?s.sizes.slice(0,d.length):[];if(!C(y,d.length))return{...s,children:d,sizes:d.map(()=>1/d.length)};let m=y.reduce((M,P)=>M+P,0);return{...s,children:d,sizes:y.map(M=>M/m)}},a=r(e)||tt,u=Object.values(t).filter(s=>s.state==="docked"&&!o.has(s.id));if(u.length>0){let s=d=>{if(d.type==="leaf"){let C=u.map(R=>R.id);return{...d,panels:[...d.panels,...C],activePanelId:d.activePanelId??C[0]}}return{...d,children:[s(d.children[0]),...d.children.slice(1)]}};for(let d of u)n.push(`panel "${d.id}" is docked but was in no group`);a=s(a)}return{gridRoot:a,repairs:n}}var We=(e,t)=>{if(e.type==="leaf"){let n=e.panels.indexOf(t);if(n===-1)return e;let o=e.panels.filter(u=>u!==t),r=e.activePanelId===t?o[n]||o[n-1]||o[0]||null:e.activePanelId,a={...e,panels:o,activePanelId:r};return o.length===0&&!e.keepOnEmpty?null:a}else{let n=e.children.map(a=>We(a,t)).filter(a=>a!==null);if(n.length===0)return null;if(n.length===1)return n[0];let o=e.sizes.slice(0,n.length),r=o.reduce((a,u)=>a+u,0);return{...e,children:n,sizes:o.map(a=>a/r)}}},ht=(e,t,n)=>{if(e.type==="leaf"){if(e.id===t){let o=e.panels.includes(n)?e.panels:[...e.panels,n];return{...e,panels:o,activePanelId:n}}return e}else return{...e,children:e.children.map(o=>ht(o,t,n))}},_t=(e,t,n)=>e.type==="leaf"?e.id===t&&e.panels.length===1&&e.panels[0]===n:e.children.some(o=>_t(o,t,n)),nt=(e,t)=>e.type==="leaf"?e.id===t:e.children.some(n=>nt(n,t)),en=e=>{if(e.type==="leaf")return e.id;for(let t of e.children){let n=en(t);if(n)return n}return null},io=(e,t,n,o,r)=>{if(e.type==="leaf"){if(e.id===t){let a={type:"leaf",id:`group-split-${Date.now()}-${Math.floor(Math.random()*1e3)}`,panels:[n],activePanelId:n},u=o==="left"||o==="right"?"horizontal":"vertical",s=o==="left"||o==="top"?[a,e]:[e,a],d=o==="left"||o==="top"?[r,1-r]:[1-r,r];return{type:"branch",orientation:u,sizes:d,children:s}}return e}else return{...e,children:e.children.map(a=>io(a,t,n,o,r))}};var Rn={x:300,y:150,width:450,height:350};function _i(e,t){let n=e;for(let o of["x","y","width","height"]){let r=e[o];typeof r=="string"||typeof r=="number"&&Number.isFinite(r)||(n={...n,[o]:Rn[o]},t.push(`floating window "${e.id}" had ${o} = ${String(r)}`))}return n}function ao(e){if(!e||!e.gridRoot||!Array.isArray(e.floating)||!Array.isArray(e.minimized)||!e.panels)return null;let t=[],n=e.floating.map(d=>_i(d,t)).map(d=>{if("stickyRight"in d||"stickyBottom"in d){let C=d.stickyRight&&d.stickyBottom?"bottom-right":d.stickyRight?"top-right":d.stickyBottom?"bottom-left":null,{stickyRight:R,stickyBottom:y,...m}=d;return{...m,anchor:C}}return d}),o=qo(e.gridRoot,e.panels);o.repairs.length>0&&process.env.NODE_ENV==="development"&&console.warn(`[react-dockable-desktop] Repaired the saved layout on load: ${o.repairs.join("; ")}. (Layouts saved by versions before 6.3.1 can list a panel twice \u2014 dropping a lone docked panel onto its own group duplicated it.) The repair is applied every time it is read, so saving again from this session stores the corrected layout.`),t.length>0&&process.env.NODE_ENV==="development"&&console.warn(`[react-dockable-desktop] Repaired the saved layout on load: ${t.join("; ")}. Each is replaced by the default a new floating window gets (${JSON.stringify(Rn)}); saving again from this session stores the corrected layout.`);let r=o.gridRoot,a={gridRoot:r,floating:n,panels:e.panels},u=typeof e.activePanelId=="string"?e.activePanelId:null,s=null;return u!==null&&(zt(u,a)?s=u:process.env.NODE_ENV==="development"&&console.warn(`[react-dockable-desktop] Ignoring the saved layout's activePanelId ("${u}") \u2014 it doesn't name a currently visible panel (it may have been closed, minimized, or excluded from the snapshot as non-serializable). Falling back to the selected tab of the first leaf in the grid.`)),s===null&&(s=Ft(a)),{gridRoot:r,floating:n,minimized:e.minimized,panels:e.panels,activePanelId:s}}function Uo(e){if(e)try{let t=ao(JSON.parse(e));if(t)return t}catch{}return{gridRoot:tt,floating:[],minimized:[],panels:{},activePanelId:null}}function tn(e){let t=e.registry,n=e.dir,o=e.zIndexBase??1e3,r={...Uo(e.initialState??null),draggedPanelId:null,dir:n||"ltr",isRtl:n==="rtl",splitRatio:Math.min(.9,Math.max(.1,e.defaultSplitRatio??.5)),edgeSplitRatio:Math.min(.9,Math.max(.1,e.defaultEdgeSplitRatio??.2))},a=new Set,u=i=>{let b=r,T=typeof i=="function"?i(b):i;T!==b&&(r=T,a.forEach(v=>v()))},s={get current(){return r}},d=()=>r,C=i=>(a.add(i),()=>{a.delete(i)}),R={current:{}},y={current:{}},m={current:new xn},M=i=>i.reduce((b,T)=>Number.isFinite(T.z)&&T.z>b?T.z:b,o),P={current:M(r.floating)},D=(i,b)=>m.current.subscribe(i,b),p=(i,b)=>{m.current.publish(i,b)},E=(i,b)=>{let T=typeof i.x=="string"?parseFloat(i.x):i.x,v=typeof i.y=="string"?parseFloat(i.y):i.y,_=typeof i.width=="string"?parseFloat(i.width):i.width,z=typeof i.height=="string"?parseFloat(i.height):i.height;isNaN(T)&&(T=300),isNaN(v)&&(v=150),isNaN(_)&&(_=450),isNaN(z)&&(z=350);let K=G=>b.some(B=>{let J=typeof B.x=="string"?parseFloat(B.x):B.x,ae=typeof B.y=="string"?parseFloat(B.y):B.y;return!B.maximized&&Math.abs(J-G.x)<20&&Math.abs(ae-G.y)<20}),V=0;for(;K({x:T,y:v})&&V<10;)T+=30,v+=30,V++;let Z=Math.max(100,typeof window<"u"&&window.innerWidth||1024),O=Math.max(100,typeof window<"u"&&window.innerHeight||768);return(T+_>Z||v+z>O)&&(T=100+V%5*30,v=100+V%5*30),T=Math.max(0,Math.min(T,Z-100)),v=Math.max(0,Math.min(v,O-40)),{x:T,y:v,width:_,height:z}},I=i=>{u(b=>{let T=b.panels[i];if(!T)return b;if(T.state==="floating"){let v=b.floating.find(z=>z.id===i);if(!v)return b;let _=!b.floating.some(z=>z.z>v.z);return _&&b.activePanelId===i?b:(_||(P.current+=1),{...b,floating:b.floating.map(z=>z.id===i?{...z,z:_?v.z:P.current}:z),activePanelId:i})}else if(T.state==="docked"){if(b.activePanelId===i)return b;let v=_=>_.type==="leaf"?_.panels.includes(i)?{..._,activePanelId:i}:_:{..._,children:_.children.map(v)};return{...b,gridRoot:v(b.gridRoot),activePanelId:i}}return b.activePanelId===i?b:{...b,activePanelId:i}})},f=(i,b,T)=>{let v=i.panels[b];if(!v||v.state!=="minimized")return i;let _=i.minimized.filter(G=>G.id!==b),z=v.previousState||"docked",K=T?b:i.activePanelId,V=t.get(v.component),Z=()=>{P.current+=1;let G=v.lastFloatingRect||V?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},B=E(G,i.floating);return{...i,minimized:_,floating:[...i.floating,{...B,id:b,z:P.current,anchor:v.lastFloatingRect?.anchor??null}],panels:{...i.panels,[b]:{...v,state:"floating"}},activePanelId:K}};if(z==="floating")return Z();if(v.lastLeafId&&nt(i.gridRoot,v.lastLeafId))return{...i,minimized:_,gridRoot:ht(i.gridRoot,v.lastLeafId,b),panels:{...i.panels,[b]:{...v,state:"docked"}},activePanelId:K};if(V?.defaultOptions?.canDrag!==!1)return Z();let O=en(i.gridRoot)||"group-default";return{...i,minimized:_,gridRoot:ht(i.gridRoot,O,b),panels:{...i.panels,[b]:{...v,state:"docked"}},activePanelId:K}},k=(i,b,{rect:T,anchor:v,activate:_=!0}={})=>{let z=i.panels[b];if(!z)return i;let K=t.get(z.component);if(K?.defaultOptions?.canDrag===!1)return i;let V=T||K?.defaultOptions?.favoritePosition||Rn,Z=We(i.gridRoot,b),O=i.floating.filter(J=>J.id!==b);P.current+=1;let G=E(V,O),B={...i,gridRoot:Z||{type:"leaf",id:"group-default",panels:[],activePanelId:null},floating:[...O,{...G,id:b,z:P.current,anchor:v??null}],panels:{...i.panels,[b]:{...z,state:"floating"}}};return{...B,activePanelId:bt(B,_?b:null)}},c=(i,b,T,v=!0)=>{let _=i.panels[b];if(!_)return i;let z=i.floating.filter(G=>G.id!==b),K=We(i.gridRoot,b)||tt,Z=(T&&nt(K,T)?T:void 0)||en(K)||tt.id,O={...i,gridRoot:ht(K,Z,b),floating:z,panels:{...i.panels,[b]:{..._,state:"docked"}}};return{...O,activePanelId:bt(O,v?b:null)}},l=(i,b,T)=>{let v=i;if(T?.dedupeKey!==void 0){let O=Object.values(s.current.panels).find(G=>G.component===b&&G.dedupeKey===T.dedupeKey);O&&(v=O.id)}let _=!(v in s.current.panels),z=v!==i,K=T?.focus!==!1,Z=T?.props!==void 0?At(T.props):!0;if(s.current.panels[v]?.state==="minimized"){let O=T?.initialTarget;u(G=>{let B=f(G,v,K),J=B.panels[v]?.state;return O==="floating"&&J==="docked"?k(B,v,{activate:K}):O&&O!=="floating"&&J==="floating"?c(B,v,void 0,K):B}),m.current.publish("panel:restored",{id:v}),m.current.publish("layout:changed",{});return}u(O=>{let G=O.panels[v],B=t.get(b),J=T?.title||B?.defaultOptions?.title||v,ae=T?.initialTarget||B?.defaultOptions?.initialTarget||"docked",ce=B?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},Re=K?v:O.activePanelId;if(G){if(G.state==="minimized")return f(O,v,K);if(G.state==="floating")return K&&I(v),O;{let Me=ye=>ye.type==="leaf"?ye.panels.includes(v)?{...ye,activePanelId:v}:ye:{...ye,children:ye.children.map(Me)};return{...O,gridRoot:Me(O.gridRoot),activePanelId:Re}}}let ke={id:v,title:J,component:b,state:ae==="tabbed"?"docked":ae,props:T?.props,serializable:Z,dedupeKey:T?.dedupeKey},Ee={...O.panels,[v]:ke};if(ae==="floating"){P.current+=1;let Me=E(ce,O.floating),ye=T?.anchor??B?.defaultOptions?.defaultAnchor??null;return{...O,floating:[...O.floating,{...Me,id:v,z:P.current,anchor:ye}],panels:Ee,activePanelId:Re}}else{let Me=en(O.gridRoot)||"group-default";return{...O,gridRoot:ht(O.gridRoot,Me,v),panels:Ee,activePanelId:Re}}}),_&&m.current.publish("panel:opened",{id:v,component:b}),(_||z)&&m.current.publish("layout:changed",{})},g=i=>{let b=i in s.current.panels;u(T=>{let v=T.panels[i];if(!v||t.get(v.component)?.defaultOptions?.canClose===!1)return T;delete R.current[i],delete y.current[i];let z={...T.panels};delete z[i];let K=We(T.gridRoot,i)||{type:"leaf",id:"group-default",panels:[],activePanelId:null},V=T.floating.filter(O=>O.id!==i),Z=T.activePanelId===i?Ft({gridRoot:K,floating:V,panels:z}):T.activePanelId;return{...T,gridRoot:K,floating:V,minimized:T.minimized.filter(O=>O.id!==i),panels:z,activePanelId:Z}}),b&&(m.current.publish("panel:closed",{id:i}),m.current.publish("layout:changed",{}))},F=(i,b)=>{R.current[i]=b},H=i=>{delete R.current[i]},S=(i,b)=>{y.current[i]=b},A=i=>{delete y.current[i]},W=(i,b,T)=>{u(v=>{let _=v.panels[i];return!_||!!_.dirty===b&&Pn(_.dirtyOptions,T)?v:{...v,panels:{...v.panels,[i]:{..._,dirty:b,dirtyOptions:T}}}})},N=(i,b)=>{u(T=>{let v=T.panels[i];return!v||Qt(v.title,b)?T:{...T,panels:{...T.panels,[i]:{...v,title:b}}}})},w=(i,b)=>{u(T=>{let v=T.panels[i];if(!v)return T;let _=b??void 0;return v.icon===_?T:{...T,panels:{...T.panels,[i]:{...v,icon:_}}}})},h=async(i,b)=>{if(b?.force){g(i);return}let T=R.current[i];if(T&&!await T())return;let v=s.current.panels[i];if(v?.dirty)if(b?.onConfirm){if(!await b.onConfirm(v.dirtyOptions))return}else return;g(i)},x=i=>{let b=s.current.panels[i]?.state!=="minimized"&&i in s.current.panels;u(T=>{let v=T.panels[i];if(!v||v.state==="minimized"||t.get(v.component)?.defaultOptions?.canMinimize===!1)return T;let z,K;if(v.state==="floating"){let B=T.floating.find(J=>J.id===i);B&&(z={x:Number(B.x),y:Number(B.y),width:Number(B.width),height:Number(B.height),anchor:B.anchor??null})}else if(v.state==="docked"){let B=J=>{if(J.type==="leaf")return J.panels.includes(i)?J.id:null;for(let ae of J.children){let ce=B(ae);if(ce)return ce}return null};K=B(T.gridRoot)??void 0}let V=We(T.gridRoot,i)||{type:"leaf",id:"group-default",panels:[],activePanelId:null},Z=T.floating.filter(B=>B.id!==i),O={...T.panels,[i]:{...v,state:"minimized",previousState:v.state,lastFloatingRect:z,lastLeafId:K}},G=T.activePanelId===i?Ft({gridRoot:V,floating:Z,panels:O}):T.activePanelId;return{...T,gridRoot:V,floating:Z,minimized:[...T.minimized,{id:i,title:v.title,component:v.component}],panels:O,activePanelId:G}}),b&&(m.current.publish("panel:minimized",{id:i}),m.current.publish("layout:changed",{}))},L=(i,b)=>{let T=s.current.panels[i]?.state==="minimized",v=b?.focus!==!1;u(_=>f(_,i,v)),T&&(m.current.publish("panel:restored",{id:i}),m.current.publish("layout:changed",{}))},$=(i,b,T)=>{let v=s.current.panels[i],_=!!v&&t.get(v.component)?.defaultOptions?.canDrag!==!1;u(z=>k(z,i,{rect:b,anchor:T})),_&&m.current.publish("layout:changed",{})},Y=(i,b)=>{let T=i in s.current.panels;u(v=>c(v,i,b)),T&&m.current.publish("layout:changed",{})},U=i=>{u(b=>({...b,draggedPanelId:i}))},j=(i,b,T)=>{let v=s.current,_=i in v.panels&&nt(v.gridRoot,b)&&!_t(v.gridRoot,b,i);u(z=>{let K=z.panels[i];if(!K||_t(z.gridRoot,b,i))return z;if(!nt(z.gridRoot,b))return process.env.NODE_ENV==="development"&&console.warn(`[react-dockable-desktop] dockPanelToGroup("${i}", "${b}") was ignored: no group with that id is in the layout. Emptying a group removes it, so an id held across a layout change can name a group that no longer exists.`),z;let V=z.floating.filter(B=>B.id!==i),Z=We(z.gridRoot,i)||tt,O;T==="center"?O=ht(Z,b,i):O=io(Z,b,i,T,z.splitRatio);let G={...z,gridRoot:O,floating:V,panels:{...z.panels,[i]:{...K,state:"docked"}},draggedPanelId:null};return{...G,activePanelId:bt(G,i)}}),_&&m.current.publish("layout:changed",{})},oe=(i,b)=>{let T=s.current,v=i in T.panels&&We(T.gridRoot,i)!==null;u(_=>{let z=_.panels[i];if(!z)return _;let K=_.floating.filter(ce=>ce.id!==i),V=We(_.gridRoot,i);if(V===null)return _;let Z={type:"leaf",id:`group-edge-${Date.now()}-${Math.floor(Math.random()*1e3)}`,panels:[i],activePanelId:i},O=b==="left"||b==="right"?"horizontal":"vertical",G=b==="left"||b==="top"?[Z,V]:[V,Z],B=_.edgeSplitRatio,J={type:"branch",orientation:O,sizes:b==="left"||b==="top"?[B,1-B]:[1-B,B],children:G},ae={..._,gridRoot:J,floating:K,panels:{..._.panels,[i]:{...z,state:"docked"}},draggedPanelId:null};return{...ae,activePanelId:bt(ae,i)}}),v&&m.current.publish("layout:changed",{})},re=(i,b,T)=>{let v=s.current,_=i in v.panels&&nt(v.gridRoot,b)&&!_t(v.gridRoot,b,i);u(z=>{let K=z.panels[i];if(!K||_t(z.gridRoot,b,i))return z;if(!nt(z.gridRoot,b))return process.env.NODE_ENV==="development"&&console.warn(`[react-dockable-desktop] movePanelOrder("${i}", "${b}") was ignored: no group with that id is in the layout.`),z;let V=We(z.gridRoot,i),Z=J=>{if(J.type==="leaf"){if(J.id===b){let ae=J.panels.filter(Oe=>Oe!==i),ce=Math.max(0,Math.min(T,ae.length)),Re=[...ae];return Re.splice(ce,0,i),{...J,panels:Re,activePanelId:i}}return J}else return{...J,children:J.children.map(Z)}},O=Z(V||tt),G=z.floating.filter(J=>J.id!==i),B={...z,gridRoot:O,floating:G,panels:{...z.panels,[i]:{...K,state:"docked"}},draggedPanelId:null};return{...B,activePanelId:bt(B,i)}}),_&&m.current.publish("layout:changed",{})},te=async(i,b)=>{let T=K=>{if(K.type==="leaf")return K.id===i?K:null;for(let V of K.children){let Z=T(V);if(Z)return Z}return null},v=T(s.current.gridRoot);if(!v||v.canClose===!1)return;for(let K of[...v.panels])await h(K,{onConfirm:b?.onConfirm});let _=K=>{if(K.type==="leaf")return K.id===i?null:K;let V=K.children.map(G=>_(G)).filter(G=>G!==null);if(V.length===0)return null;if(V.length===1)return V[0];let Z=K.sizes.slice(0,V.length),O=Z.reduce((G,B)=>G+B,0);return{...K,children:V,sizes:Z.map(G=>G/O)}},z=!1;u(K=>{let V=T(K.gridRoot);if(!V||V.panels.length>0)return K;z=!0;let Z={...K,gridRoot:_(K.gridRoot)||{type:"leaf",id:"group-default",panels:[],activePanelId:null}};return{...Z,activePanelId:bt(Z,null)}}),z&&m.current.publish("layout:changed",{})},he=i=>{let b=s.current.panels[i];if(b){if(b.state==="minimized"){u(T=>{let v=f(T,i,!0);if(v===T)return T;let _=v;return v.panels[i]?.state==="docked"&&(_=k(v,i),_===v)?v:{..._,floating:_.floating.map(z=>z.id===i?{...z,maximized:!0}:z),activePanelId:i}}),m.current.publish("panel:restored",{id:i}),m.current.publish("layout:changed",{});return}if(b.state==="docked"){process.env.NODE_ENV==="development"&&console.warn(`[react-dockable-desktop] maximizePanel("${i}") was ignored: only floating windows can be maximized. Float the panel first with floatPanel("${i}").`);return}u(T=>({...T,floating:T.floating.map(v=>v.id===i?{...v,maximized:!v.maximized}:v)}))}},we=(i,b)=>{let T=(v,_)=>{if(v.type==="leaf")return v;if(_===i.length)return{...v,sizes:b};let z=i[_],K=v.children.map((V,Z)=>Z===z?T(V,_+1):V);return{...v,children:K}};u(v=>({...v,gridRoot:T(v.gridRoot,0)}))},ne=(i,b)=>{u(T=>({...T,floating:T.floating.map(v=>v.id===i?{...v,...b}:v)}))},Ke=()=>{let i=s.current.panels,b=[],T={};for(let[O,G]of Object.entries(i)){let B=y.current[O],J=B?.(),ae=B!==void 0&&J!==void 0,ce=ae?J:G.props,Re=ae?At(J):G.serializable;if(Re){let{icon:Oe,...ke}=G;typeof ke.title=="function"&&delete ke.title,T[O]=ae?{...ke,props:ce,serializable:Re}:ke}else b.push(O)}let v=s.current.gridRoot,_=s.current.floating,z=s.current.minimized;for(let O of b)v=We(v,O)||{type:"leaf",id:"group-default",panels:[],activePanelId:null},_=_.filter(G=>G.id!==O),z=z.filter(G=>G.id!==O);b.length>0&&m.current.publish("layout:panels-excluded",{panels:b.map(O=>({id:O,component:i[O].component}))});let K=s.current.activePanelId,V=K!==null&&zt(K,{gridRoot:v,floating:_,panels:T})?K:null,Z={version:2,...V!==null?{activePanelId:V}:{},gridRoot:v,floating:_,minimized:z.map(O=>typeof O.title=="function"?{id:O.id,component:O.component}:O),panels:T};return JSON.stringify(Z)},Le=i=>{try{let b=ao(JSON.parse(i));return b?(P.current=Math.max(P.current,M(b.floating)),u(T=>{let v={};for(let[z,K]of Object.entries(b.panels)){let V=K.title?K:{...K,title:t.get(K.component)?.defaultOptions?.title||z},Z=T.panels[z];v[z]=Z?.icon!==void 0&&Z.component===V.component?{...V,icon:Z.icon}:V}let _=z=>z.title||v[z.id]?.title||z.id;return{...T,gridRoot:b.gridRoot,floating:b.floating,minimized:b.minimized.map(z=>z.title?z:{...z,title:_(z)}),panels:v,draggedPanelId:null,activePanelId:b.activePanelId}}),!0):!1}catch(b){return console.error("Failed to parse layout configuration:",b),!1}},$e=i=>{u(b=>b.activePanelId===i?b:{...b,activePanelId:i})},Xe=i=>{u(b=>b.dir===i?b:{...b,dir:i,isRtl:i==="rtl"})},mt=i=>i in s.current.panels,Qe=()=>Object.keys(s.current.panels),et=(i,b)=>Object.values(s.current.panels).find(v=>v.component===i&&v.dedupeKey===b)?.id??null,Se={current:new Map},pe={current:null};return{actions:{openPanel:l,closePanel:g,minimizePanel:x,restorePanel:L,floatPanel:$,dockPanel:Y,maximizePanel:he,updateSplitSizes:we,updateFloatingPosition:ne,focusPanel:I,isOpen:mt,getOpenPanelIds:Qe,findPanelId:et,saveLayout:Ke,loadLayout:Le,publish:p,subscribe:D,setDraggedPanelId:U,dockPanelToGroup:j,movePanelOrder:re,closeLeafGroup:te,registerCloseGuard:F,unregisterCloseGuard:H,registerStateProvider:S,unregisterStateProvider:A,setPanelDirty:W,updatePanelTitle:N,setPanelIcon:w,requestClosePanel:h,dockPanelToWorkspaceEdge:oe,setActivePanel:$e,setDirection:Xe,registerPanelContextMenu:(i,b)=>(Se.current.set(i,b),()=>{Se.current.delete(i)}),getPanelContextMenuItems:i=>Se.current.get(i)?.()??[],showContextMenu:i=>{pe.current?.({dir:s.current.dir,...i})},registerContextMenuFn:i=>(pe.current=i,()=>{pe.current=null})},getSnapshot:d,subscribeToState:C,applyProviderDefaults:i=>{e.dir===void 0&&i.dir&&Xe(i.dir),e.zIndexBase===void 0&&i.zIndexBase!==void 0&&r.floating.length===0&&(P.current=i.zIndexBase)}}}import{jsx as vt}from"react/jsx-runtime";var ot=yt(null),wn=yt(null),tr=yt(null),kn=yt(null),nr=yt(Jt),or=yt({}),Ze=()=>Ve(or),rr=yt(vn),Ht=()=>Ve(rr),ir=({children:e,client:t,formatMessage:n,predefinedMessages:o,dir:r,modalClass:a,modalBodyClass:u,sidePanelClass:s,sidePanelBodyClass:d,windowClass:C,windowBodyClass:R,zIndexBase:y})=>{let[m]=Hi(()=>{let g=t?t._core:tn({registry:vn,dir:r,zIndexBase:y});return g.applyProviderDefaults({dir:r,zIndexBase:y}),g}),M=t?.registry??vn,P=er(m.subscribeToState,m.getSnapshot,m.getSnapshot),D=m.actions,p=t?.config.formatMessage??n,E=t?.config.predefinedMessages??o,I=t?.config.dir??r,f=t?.config.zIndexBase??y??1e3,k=so(()=>({...Jt,...E}),[E]);Cn(()=>(document.documentElement.style.setProperty("--rdd-z-base",String(f)),()=>{document.documentElement.style.removeProperty("--rdd-z-base")}),[f]),Cn(()=>{I&&D.setDirection(I)},[I,D]);let c=so(()=>({modalClass:a,modalBodyClass:u,sidePanelClass:s,sidePanelBodyClass:d,windowClass:C,windowBodyClass:R}),[a,u,s,d,C,R]);Cn(()=>{if(process.env.NODE_ENV==="development")try{getComputedStyle(document.documentElement).getPropertyValue("--rdd-styles-loaded").trim()!=="1"&&console.error(`[react-dockable-desktop] styles.css is not imported.
|
|
1
|
+
import{forwardRef as Ds,useContext as Wr,useEffect as Mo,useLayoutEffect as pn,useMemo as $n,useRef as fn,useSyncExternalStore as Ls}from"react";var At=class{registry=new Map;register(t,n,o){this.registry.set(t,{Component:n,defaultOptions:o})}get(t){return this.registry.get(t)}getRegisteredIds(){return Array.from(this.registry.keys())}},xn=new At;import{createContext as xt,useContext as Ze,useState as qi,useRef as lr,useMemo as go,useEffect as Mn,useSyncExternalStore as cr}from"react";import{createContext as Bi,useContext as Gi,useSyncExternalStore as Yi}from"react";var Ki={requestClose:()=>{console.warn("FormContainerContract: requestClose called but no container is present")},setDirty:()=>{},onCloseRequested:()=>()=>{},registerStateProvider:()=>()=>{},setTitle:()=>{},setIcon:()=>{},containerType:"standalone",instanceId:"standalone",onClose:()=>()=>{},onMinimize:()=>()=>{},onRestore:()=>()=>{},onResize:()=>()=>{},requestMinimize:()=>{},getDimensions:()=>null,onActivate:()=>()=>{},onDeactivate:()=>()=>{},onContainerTypeChange:()=>()=>{}},rr=Bi(Ki),zt=rr.Provider,De=()=>Gi(rr),Xi=()=>{let{onResize:e,getDimensions:t}=De();return Yi(n=>e?e(()=>n()):()=>{},()=>t?t():null)};var en={floatWindow:{id:"dockable-desktop-floatWindow",defaultMessage:"Float Window"},minimizePanel:{id:"dockable-desktop-minimizePanel",defaultMessage:"Minimize Panel"},closeTab:{id:"dockable-desktop-closeTab",defaultMessage:"Close Tab"},restorePanel:{id:"dockable-desktop-restorePanel",defaultMessage:"Restore Panel"},maximizePanel:{id:"dockable-desktop-maximizePanel",defaultMessage:"Maximize Panel"},closePanel:{id:"dockable-desktop-closePanel",defaultMessage:"Close Panel"},dockWindow:{id:"dockable-desktop-dockWindow",defaultMessage:"Dock Window"},minimize:{id:"dockable-desktop-minimize",defaultMessage:"Minimize"},maximize:{id:"dockable-desktop-maximize",defaultMessage:"Maximize"},restoreSize:{id:"dockable-desktop-restoreSize",defaultMessage:"Restore Size"},close:{id:"dockable-desktop-close",defaultMessage:"Close"},closeEmptyGroup:{id:"dockable-desktop-closeEmptyGroup",defaultMessage:"Close empty split group"},unsavedChangesTitle:{id:"dockable-desktop-unsavedChangesTitle",defaultMessage:"Unsaved Changes"},unsavedChangesMessage:{id:"dockable-desktop-unsavedChangesMessage",defaultMessage:'"{title}" has unsaved changes. Do you want to discard your changes and close?'},discardChanges:{id:"dockable-desktop-discardChanges",defaultMessage:"Discard Changes"},cancel:{id:"dockable-desktop-cancel",defaultMessage:"Cancel"},yes:{id:"dockable-desktop-yes",defaultMessage:"Yes"},no:{id:"dockable-desktop-no",defaultMessage:"No"},ok:{id:"dockable-desktop-ok",defaultMessage:"OK"},closePanelTooltip:{id:"dockable-desktop-closePanelTooltip",defaultMessage:"Close panel"},closeTooltip:{id:"dockable-desktop-closeTooltip",defaultMessage:"Close"},notifications:{id:"dockable-desktop-notifications",defaultMessage:"Notifications"},closeNotification:{id:"dockable-desktop-closeNotification",defaultMessage:"Close notification"},scrollTabsLeft:{id:"dockable-desktop-scrollTabsLeft",defaultMessage:"Scroll tabs left"},scrollTabsRight:{id:"dockable-desktop-scrollTabsRight",defaultMessage:"Scroll tabs right"},scrollTaskbarLeft:{id:"dockable-desktop-scrollTaskbarLeft",defaultMessage:"Scroll taskbar left"},scrollTaskbarRight:{id:"dockable-desktop-scrollTaskbarRight",defaultMessage:"Scroll taskbar right"},moreActions:{id:"dockable-desktop-moreActions",defaultMessage:"More actions"},search:{id:"dockable-desktop-search",defaultMessage:"Search"},closeSearch:{id:"dockable-desktop-closeSearch",defaultMessage:"Close search"},searchPlaceholder:{id:"dockable-desktop-searchPlaceholder",defaultMessage:"Search\u2026"},modalTitle:{id:"dockable-desktop-modalTitle",defaultMessage:"Confirmation"},alertTitle:{id:"dockable-desktop-alertTitle",defaultMessage:"Information"},emptyGroup:{id:"dockable-desktop-emptyGroup",defaultMessage:"Empty Workspace Section"},emptyGrid:{id:"dockable-desktop-emptyGrid",defaultMessage:"Grid Empty"},componentUnregistered:{id:"dockable-desktop-componentUnregistered",defaultMessage:"Component Unregistered"},componentKey:{id:"dockable-desktop-componentKey",defaultMessage:"Key: {key}"},untitledPanel:{id:"dockable-desktop-untitledPanel",defaultMessage:"Panel"}};var Rn=e=>{let t=e.defaultMessage||e.id;if(e.values)for(let[n,o]of Object.entries(e.values))t=t.split(`{${n}}`).join(String(o));return t},q=(e,t)=>e?typeof e=="string"?e:typeof e=="function"?e():t(e):"";import{isValidElement as Vi}from"react";function Ft(e){if(e===null)return!0;if(e===void 0)return!1;let t=typeof e;if(t==="string"||t==="number"||t==="boolean")return!0;if(t==="function"||t==="symbol"||t==="bigint")return!1;if(e instanceof Date)return!0;if(Vi(e))return!1;if(Array.isArray(e))return e.every(Ft);let n=Object.getPrototypeOf(e);return n!==Object.prototype&&n!==null?!1:Object.values(e).every(Ft)}function Zi(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e);return n.length!==Object.keys(t).length?!1:n.every(o=>e[o]===t[o])}function tn(e,t){return e===t?!0:typeof e!="object"||typeof t!="object"||!e||!t?!1:e.id===t.id&&e.defaultMessage===t.defaultMessage&&Zi(e.values,t.values)}function Cn(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let o of n){let r=e[o],i=t[o];if(o==="title"||o==="message"?!tn(r,i):r!==i)return!1}return!0}var wn=class{listeners={};subscribe(t,n){return this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(n),()=>{this.listeners[t]=this.listeners[t].filter(o=>o!==n)}}publish(t,n){if(this.listeners[t])for(let o of this.listeners[t])try{o(n)}catch(r){console.error(`[react-dockable-desktop] A subscriber to "${t}" threw:`,r)}}};var ot={type:"leaf",id:"group-default",panels:[],activePanelId:null};function _t(e,t){let n=t.panels[e];if(!n||n.state==="minimized")return!1;if(t.floating.some(r=>r.id===e))return!0;let o=r=>r.type==="leaf"?r.activePanelId===e:r.children.some(o);return t.gridRoot?o(t.gridRoot):!1}function Ht(e){let t=i=>i!==null&&!!e.panels[i]&&e.panels[i].state!=="minimized",n=i=>{if(i.type==="leaf")return t(i.activePanelId)?i.activePanelId:null;for(let u of i.children){let l=n(u);if(l)return l}return null},o=e.gridRoot?n(e.gridRoot):null;if(o)return o;let r=null;for(let i of e.floating)t(i.id)&&(!r||i.z>r.z)&&(r=i);return r?.id??null}function vt(e,t){return t&&_t(t,e)?t:e.activePanelId&&_t(e.activePanelId,e)?e.activePanelId:Ht(e)}function ir(e,t){let n=[],o=new Set,r=l=>{if(l.type==="leaf"){let P=l.panels.filter(I=>t[I]?o.has(I)?(n.push(`panel "${I}" was listed in more than one group`),!1):(o.add(I),!0):(n.push(`group "${l.id}" listed panel "${I}", which the layout doesn't have`),!1));if(P.length===l.panels.length)return l;if(P.length===0&&!l.keepOnEmpty)return null;let b=l.activePanelId&&P.includes(l.activePanelId)?l.activePanelId:P[0]??null;return{...l,panels:P,activePanelId:b}}let d=l.children.map(r).filter(P=>P!==null),R=(P,b)=>Array.isArray(P)&&P.length===b&&P.every(I=>typeof I=="number"&&Number.isFinite(I)&&I>0),w=d.length===l.children.length&&d.every((P,b)=>P===l.children[b]);if(w&&R(l.sizes,d.length))return l;if(d.length===0)return null;if(d.length===1)return d[0];if(w)return n.push(`a split had sizes ${JSON.stringify(l.sizes)} for ${d.length} children`),{...l,sizes:d.map(()=>1/d.length)};let C=Array.isArray(l.sizes)?l.sizes.slice(0,d.length):[];if(!R(C,d.length))return{...l,children:d,sizes:d.map(()=>1/d.length)};let f=C.reduce((P,b)=>P+b,0);return{...l,children:d,sizes:C.map(P=>P/f)}},i=r(e)||ot,u=Object.values(t).filter(l=>l.state==="docked"&&!o.has(l.id));if(u.length>0){let l=d=>{if(d.type==="leaf"){let R=u.map(w=>w.id);return{...d,panels:[...d.panels,...R],activePanelId:d.activePanelId??R[0]}}return{...d,children:[l(d.children[0]),...d.children.slice(1)]}};for(let d of u)n.push(`panel "${d.id}" is docked but was in no group`);i=l(i)}return{gridRoot:i,repairs:n}}var Fe=(e,t)=>{if(e.type==="leaf"){let n=e.panels.indexOf(t);if(n===-1)return e;let o=e.panels.filter(u=>u!==t),r=e.activePanelId===t?o[n]||o[n-1]||o[0]||null:e.activePanelId,i={...e,panels:o,activePanelId:r};return o.length===0&&!e.keepOnEmpty?null:i}else{let n=e.children.map(i=>Fe(i,t)).filter(i=>i!==null);if(n.length===0)return null;if(n.length===1)return n[0];let o=e.sizes.slice(0,n.length),r=o.reduce((i,u)=>i+u,0);return{...e,children:n,sizes:o.map(i=>i/r)}}},yt=(e,t,n)=>{if(e.type==="leaf"){if(e.id===t){let o=e.panels.includes(n)?e.panels:[...e.panels,n];return{...e,panels:o,activePanelId:n}}return e}else return{...e,children:e.children.map(o=>yt(o,t,n))}},$t=(e,t,n)=>e.type==="leaf"?e.id===t&&e.panels.length===1&&e.panels[0]===n:e.children.some(o=>$t(o,t,n)),rt=(e,t)=>e.type==="leaf"?e.id===t:e.children.some(n=>rt(n,t)),nn=e=>{if(e.type==="leaf")return e.id;for(let t of e.children){let n=nn(t);if(n)return n}return null},fo=(e,t,n,o,r)=>{if(e.type==="leaf"){if(e.id===t){let i={type:"leaf",id:`group-split-${Date.now()}-${Math.floor(Math.random()*1e3)}`,panels:[n],activePanelId:n},u=o==="left"||o==="right"?"horizontal":"vertical",l=o==="left"||o==="top"?[i,e]:[e,i],d=o==="left"||o==="top"?[r,1-r]:[1-r,r];return{type:"branch",orientation:u,sizes:d,children:l}}return e}else return{...e,children:e.children.map(i=>fo(i,t,n,o,r))}};var kn={x:300,y:150,width:450,height:350};function ji(e,t){let n=e;for(let o of["x","y","width","height"]){let r=e[o];typeof r=="string"||typeof r=="number"&&Number.isFinite(r)||(n={...n,[o]:kn[o]},t.push(`floating window "${e.id}" had ${o} = ${String(r)}`))}return n}function mo(e){if(!e||!e.gridRoot||!Array.isArray(e.floating)||!Array.isArray(e.minimized)||!e.panels)return null;let t=[],n=e.floating.map(d=>ji(d,t)).map(d=>{if("stickyRight"in d||"stickyBottom"in d){let R=d.stickyRight&&d.stickyBottom?"bottom-right":d.stickyRight?"top-right":d.stickyBottom?"bottom-left":null,{stickyRight:w,stickyBottom:C,...f}=d;return{...f,anchor:R}}return d}),o=ir(e.gridRoot,e.panels);o.repairs.length>0&&process.env.NODE_ENV==="development"&&console.warn(`[react-dockable-desktop] Repaired the saved layout on load: ${o.repairs.join("; ")}. (Layouts saved by versions before 6.3.1 can list a panel twice \u2014 dropping a lone docked panel onto its own group duplicated it.) The repair is applied every time it is read, so saving again from this session stores the corrected layout.`),t.length>0&&process.env.NODE_ENV==="development"&&console.warn(`[react-dockable-desktop] Repaired the saved layout on load: ${t.join("; ")}. Each is replaced by the default a new floating window gets (${JSON.stringify(kn)}); saving again from this session stores the corrected layout.`);let r=o.gridRoot,i={gridRoot:r,floating:n,panels:e.panels},u=typeof e.activePanelId=="string"?e.activePanelId:null,l=null;return u!==null&&(_t(u,i)?l=u:process.env.NODE_ENV==="development"&&console.warn(`[react-dockable-desktop] Ignoring the saved layout's activePanelId ("${u}") \u2014 it doesn't name a currently visible panel (it may have been closed, minimized, or excluded from the snapshot as non-serializable). Falling back to the selected tab of the first leaf in the grid.`)),l===null&&(l=Ht(i)),{gridRoot:r,floating:n,minimized:e.minimized,panels:e.panels,activePanelId:l}}function sr(e){if(e)try{let t=mo(JSON.parse(e));if(t)return t}catch{}return{gridRoot:ot,floating:[],minimized:[],panels:{},activePanelId:null}}function on(e){let t=e.registry,n=e.dir,o=e.zIndexBase??1e3,r={...sr(e.initialState??null),draggedPanelId:null,dir:n||"ltr",isRtl:n==="rtl",splitRatio:Math.min(.9,Math.max(.1,e.defaultSplitRatio??.5)),edgeSplitRatio:Math.min(.9,Math.max(.1,e.defaultEdgeSplitRatio??.2))},i=new Set,u=s=>{let g=r,S=typeof s=="function"?s(g):s;S!==g&&(r=S,i.forEach(y=>y()))},l={get current(){return r}},d=()=>r,R=s=>(i.add(s),()=>{i.delete(s)}),w={current:{}},C={current:{}},f={current:new wn},P=s=>s.reduce((g,S)=>Number.isFinite(S.z)&&S.z>g?S.z:g,o),b={current:P(r.floating)},I=(s,g)=>f.current.subscribe(s,g),h=(s,g)=>{f.current.publish(s,g)},E=(s,g)=>{let S=typeof s.x=="string"?parseFloat(s.x):s.x,y=typeof s.y=="string"?parseFloat(s.y):s.y,$=typeof s.width=="string"?parseFloat(s.width):s.width,F=typeof s.height=="string"?parseFloat(s.height):s.height;isNaN(S)&&(S=300),isNaN(y)&&(y=150),isNaN($)&&($=450),isNaN(F)&&(F=350);let X=G=>g.some(B=>{let Q=typeof B.x=="string"?parseFloat(B.x):B.x,se=typeof B.y=="string"?parseFloat(B.y):B.y;return!B.maximized&&Math.abs(Q-G.x)<20&&Math.abs(se-G.y)<20}),Z=0;for(;X({x:S,y})&&Z<10;)S+=30,y+=30,Z++;let j=Math.max(100,typeof window<"u"&&window.innerWidth||1024),O=Math.max(100,typeof window<"u"&&window.innerHeight||768);return(S+$>j||y+F>O)&&(S=100+Z%5*30,y=100+Z%5*30),S=Math.max(0,Math.min(S,j-100)),y=Math.max(0,Math.min(y,O-40)),{x:S,y,width:$,height:F}},N=s=>{u(g=>{let S=g.panels[s];if(!S)return g;if(S.state==="floating"){let y=g.floating.find(F=>F.id===s);if(!y)return g;let $=!g.floating.some(F=>F.z>y.z);return $&&g.activePanelId===s?g:($||(b.current+=1),{...g,floating:g.floating.map(F=>F.id===s?{...F,z:$?y.z:b.current}:F),activePanelId:s})}else if(S.state==="docked"){if(g.activePanelId===s)return g;let y=$=>$.type==="leaf"?$.panels.includes(s)?{...$,activePanelId:s}:$:{...$,children:$.children.map(y)};return{...g,gridRoot:y(g.gridRoot),activePanelId:s}}return g.activePanelId===s?g:{...g,activePanelId:s}})},x=(s,g,S)=>{let y=s.panels[g];if(!y||y.state!=="minimized")return s;let $=s.minimized.filter(G=>G.id!==g),F=y.previousState||"docked",X=S?g:s.activePanelId,Z=t.get(y.component),j=()=>{b.current+=1;let G=y.lastFloatingRect||Z?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},B=E(G,s.floating);return{...s,minimized:$,floating:[...s.floating,{...B,id:g,z:b.current,anchor:y.lastFloatingRect?.anchor??null}],panels:{...s.panels,[g]:{...y,state:"floating"}},activePanelId:X}};if(F==="floating")return j();if(y.lastLeafId&&rt(s.gridRoot,y.lastLeafId))return{...s,minimized:$,gridRoot:yt(s.gridRoot,y.lastLeafId,g),panels:{...s.panels,[g]:{...y,state:"docked"}},activePanelId:X};if(Z?.defaultOptions?.canDrag!==!1)return j();let O=nn(s.gridRoot)||"group-default";return{...s,minimized:$,gridRoot:yt(s.gridRoot,O,g),panels:{...s.panels,[g]:{...y,state:"docked"}},activePanelId:X}},m=(s,g,{rect:S,anchor:y,activate:$=!0}={})=>{let F=s.panels[g];if(!F)return s;let X=t.get(F.component);if(X?.defaultOptions?.canDrag===!1)return s;let Z=S||X?.defaultOptions?.favoritePosition||kn,j=Fe(s.gridRoot,g),O=s.floating.filter(Q=>Q.id!==g);b.current+=1;let G=E(Z,O),B={...s,gridRoot:j||{type:"leaf",id:"group-default",panels:[],activePanelId:null},floating:[...O,{...G,id:g,z:b.current,anchor:y??null}],panels:{...s.panels,[g]:{...F,state:"floating"}}};return{...B,activePanelId:vt(B,$?g:null)}},c=(s,g,S,y=!0)=>{let $=s.panels[g];if(!$)return s;let F=s.floating.filter(G=>G.id!==g),X=Fe(s.gridRoot,g)||ot,j=(S&&rt(X,S)?S:void 0)||nn(X)||ot.id,O={...s,gridRoot:yt(X,j,g),floating:F,panels:{...s.panels,[g]:{...$,state:"docked"}}};return{...O,activePanelId:vt(O,y?g:null)}},a=(s,g,S)=>{let y=s;if(S?.dedupeKey!==void 0){let O=Object.values(l.current.panels).find(G=>G.component===g&&G.dedupeKey===S.dedupeKey);O&&(y=O.id)}let $=!(y in l.current.panels),F=y!==s,X=S?.focus!==!1,j=S?.props!==void 0?Ft(S.props):!0;if(l.current.panels[y]?.state==="minimized"){let O=S?.initialTarget;u(G=>{let B=x(G,y,X),Q=B.panels[y]?.state;return O==="floating"&&Q==="docked"?m(B,y,{activate:X}):O&&O!=="floating"&&Q==="floating"?c(B,y,void 0,X):B}),f.current.publish("panel:restored",{id:y}),f.current.publish("layout:changed",{});return}u(O=>{let G=O.panels[y],B=t.get(g),Q=S?.title||B?.defaultOptions?.title||y,se=S?.initialTarget||B?.defaultOptions?.initialTarget||"docked",ue=B?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},Ce=X?y:O.activePanelId;if(G){if(G.state==="minimized")return x(O,y,X);if(G.state==="floating")return X&&N(y),O;{let Me=ye=>ye.type==="leaf"?ye.panels.includes(y)?{...ye,activePanelId:y}:ye:{...ye,children:ye.children.map(Me)};return{...O,gridRoot:Me(O.gridRoot),activePanelId:Ce}}}let ke={id:y,title:Q,component:g,state:se==="tabbed"?"docked":se,props:S?.props,serializable:j,dedupeKey:S?.dedupeKey},Ie={...O.panels,[y]:ke};if(se==="floating"){b.current+=1;let Me=E(ue,O.floating),ye=S?.anchor??B?.defaultOptions?.defaultAnchor??null;return{...O,floating:[...O.floating,{...Me,id:y,z:b.current,anchor:ye}],panels:Ie,activePanelId:Ce}}else{let Me=nn(O.gridRoot)||"group-default";return{...O,gridRoot:yt(O.gridRoot,Me,y),panels:Ie,activePanelId:Ce}}}),$&&f.current.publish("panel:opened",{id:y,component:g}),($||F)&&f.current.publish("layout:changed",{})},p=s=>{let g=s in l.current.panels;u(S=>{let y=S.panels[s];if(!y||t.get(y.component)?.defaultOptions?.canClose===!1)return S;delete w.current[s],delete C.current[s];let F={...S.panels};delete F[s];let X=Fe(S.gridRoot,s)||{type:"leaf",id:"group-default",panels:[],activePanelId:null},Z=S.floating.filter(O=>O.id!==s),j=S.activePanelId===s?Ht({gridRoot:X,floating:Z,panels:F}):S.activePanelId;return{...S,gridRoot:X,floating:Z,minimized:S.minimized.filter(O=>O.id!==s),panels:F,activePanelId:j}}),g&&(f.current.publish("panel:closed",{id:s}),f.current.publish("layout:changed",{}))},D=(s,g)=>{w.current[s]=g},_=s=>{delete w.current[s]},M=(s,g)=>{C.current[s]=g},A=s=>{delete C.current[s]},z=(s,g,S)=>{u(y=>{let $=y.panels[s];return!$||!!$.dirty===g&&Cn($.dirtyOptions,S)?y:{...y,panels:{...y.panels,[s]:{...$,dirty:g,dirtyOptions:S}}}})},W=(s,g)=>{u(S=>{let y=S.panels[s];return!y||tn(y.title,g)?S:{...S,panels:{...S.panels,[s]:{...y,title:g}}}})},T=(s,g)=>{u(S=>{let y=S.panels[s];if(!y)return S;let $=g??void 0;return y.icon===$?S:{...S,panels:{...S.panels,[s]:{...y,icon:$}}}})},v=async(s,g)=>{if(g?.force){p(s);return}let S=w.current[s];if(S&&!await S())return;let y=l.current.panels[s];if(y?.dirty)if(g?.onConfirm){if(!await g.onConfirm(y.dirtyOptions))return}else return;p(s)},k=s=>{let g=l.current.panels[s]?.state!=="minimized"&&s in l.current.panels;u(S=>{let y=S.panels[s];if(!y||y.state==="minimized"||t.get(y.component)?.defaultOptions?.canMinimize===!1)return S;let F,X;if(y.state==="floating"){let B=S.floating.find(Q=>Q.id===s);B&&(F={x:Number(B.x),y:Number(B.y),width:Number(B.width),height:Number(B.height),anchor:B.anchor??null})}else if(y.state==="docked"){let B=Q=>{if(Q.type==="leaf")return Q.panels.includes(s)?Q.id:null;for(let se of Q.children){let ue=B(se);if(ue)return ue}return null};X=B(S.gridRoot)??void 0}let Z=Fe(S.gridRoot,s)||{type:"leaf",id:"group-default",panels:[],activePanelId:null},j=S.floating.filter(B=>B.id!==s),O={...S.panels,[s]:{...y,state:"minimized",previousState:y.state,lastFloatingRect:F,lastLeafId:X}},G=S.activePanelId===s?Ht({gridRoot:Z,floating:j,panels:O}):S.activePanelId;return{...S,gridRoot:Z,floating:j,minimized:[...S.minimized,{id:s,title:y.title,component:y.component}],panels:O,activePanelId:G}}),g&&(f.current.publish("panel:minimized",{id:s}),f.current.publish("layout:changed",{}))},L=(s,g)=>{let S=l.current.panels[s]?.state==="minimized",y=g?.focus!==!1;u($=>x($,s,y)),S&&(f.current.publish("panel:restored",{id:s}),f.current.publish("layout:changed",{}))},H=(s,g,S)=>{let y=l.current.panels[s],$=!!y&&t.get(y.component)?.defaultOptions?.canDrag!==!1;u(F=>m(F,s,{rect:g,anchor:S})),$&&f.current.publish("layout:changed",{})},Y=(s,g)=>{let S=s in l.current.panels;u(y=>c(y,s,g)),S&&f.current.publish("layout:changed",{})},U=s=>{u(g=>({...g,draggedPanelId:s}))},K=(s,g,S)=>{let y=l.current,$=s in y.panels&&rt(y.gridRoot,g)&&!$t(y.gridRoot,g,s);u(F=>{let X=F.panels[s];if(!X||$t(F.gridRoot,g,s))return F;if(!rt(F.gridRoot,g))return process.env.NODE_ENV==="development"&&console.warn(`[react-dockable-desktop] dockPanelToGroup("${s}", "${g}") was ignored: no group with that id is in the layout. Emptying a group removes it, so an id held across a layout change can name a group that no longer exists.`),F;let Z=F.floating.filter(B=>B.id!==s),j=Fe(F.gridRoot,s)||ot,O;S==="center"?O=yt(j,g,s):O=fo(j,g,s,S,F.splitRatio);let G={...F,gridRoot:O,floating:Z,panels:{...F.panels,[s]:{...X,state:"docked"}},draggedPanelId:null};return{...G,activePanelId:vt(G,s)}}),$&&f.current.publish("layout:changed",{})},oe=(s,g)=>{let S=l.current,y=s in S.panels&&Fe(S.gridRoot,s)!==null;u($=>{let F=$.panels[s];if(!F)return $;let X=$.floating.filter(ue=>ue.id!==s),Z=Fe($.gridRoot,s);if(Z===null)return $;let j={type:"leaf",id:`group-edge-${Date.now()}-${Math.floor(Math.random()*1e3)}`,panels:[s],activePanelId:s},O=g==="left"||g==="right"?"horizontal":"vertical",G=g==="left"||g==="top"?[j,Z]:[Z,j],B=$.edgeSplitRatio,Q={type:"branch",orientation:O,sizes:g==="left"||g==="top"?[B,1-B]:[1-B,B],children:G},se={...$,gridRoot:Q,floating:X,panels:{...$.panels,[s]:{...F,state:"docked"}},draggedPanelId:null};return{...se,activePanelId:vt(se,s)}}),y&&f.current.publish("layout:changed",{})},le=(s,g,S)=>{let y=l.current,$=s in y.panels&&rt(y.gridRoot,g)&&!$t(y.gridRoot,g,s);u(F=>{let X=F.panels[s];if(!X||$t(F.gridRoot,g,s))return F;if(!rt(F.gridRoot,g))return process.env.NODE_ENV==="development"&&console.warn(`[react-dockable-desktop] movePanelOrder("${s}", "${g}") was ignored: no group with that id is in the layout.`),F;let Z=Fe(F.gridRoot,s),j=Q=>{if(Q.type==="leaf"){if(Q.id===g){let se=Q.panels.filter(Ae=>Ae!==s),ue=Math.max(0,Math.min(S,se.length)),Ce=[...se];return Ce.splice(ue,0,s),{...Q,panels:Ce,activePanelId:s}}return Q}else return{...Q,children:Q.children.map(j)}},O=j(Z||ot),G=F.floating.filter(Q=>Q.id!==s),B={...F,gridRoot:O,floating:G,panels:{...F.panels,[s]:{...X,state:"docked"}},draggedPanelId:null};return{...B,activePanelId:vt(B,s)}}),$&&f.current.publish("layout:changed",{})},te=async(s,g)=>{let S=X=>{if(X.type==="leaf")return X.id===s?X:null;for(let Z of X.children){let j=S(Z);if(j)return j}return null},y=S(l.current.gridRoot);if(!y||y.canClose===!1)return;for(let X of[...y.panels])await v(X,{onConfirm:g?.onConfirm});let $=X=>{if(X.type==="leaf")return X.id===s?null:X;let Z=X.children.map(G=>$(G)).filter(G=>G!==null);if(Z.length===0)return null;if(Z.length===1)return Z[0];let j=X.sizes.slice(0,Z.length),O=j.reduce((G,B)=>G+B,0);return{...X,children:Z,sizes:j.map(G=>G/O)}},F=!1;u(X=>{let Z=S(X.gridRoot);if(!Z||Z.panels.length>0)return X;F=!0;let j={...X,gridRoot:$(X.gridRoot)||{type:"leaf",id:"group-default",panels:[],activePanelId:null}};return{...j,activePanelId:vt(j,null)}}),F&&f.current.publish("layout:changed",{})},re=s=>{let g=l.current.panels[s];if(g){if(g.state==="minimized"){u(S=>{let y=x(S,s,!0);if(y===S)return S;let $=y;return y.panels[s]?.state==="docked"&&($=m(y,s),$===y)?y:{...$,floating:$.floating.map(F=>F.id===s?{...F,maximized:!0}:F),activePanelId:s}}),f.current.publish("panel:restored",{id:s}),f.current.publish("layout:changed",{});return}if(g.state==="docked"){process.env.NODE_ENV==="development"&&console.warn(`[react-dockable-desktop] maximizePanel("${s}") was ignored: only floating windows can be maximized. Float the panel first with floatPanel("${s}").`);return}u(S=>({...S,floating:S.floating.map(y=>y.id===s?{...y,maximized:!y.maximized}:y)}))}},Re=(s,g)=>{let S=(y,$)=>{if(y.type==="leaf")return y;if($===s.length)return{...y,sizes:g};let F=s[$],X=y.children.map((Z,j)=>j===F?S(Z,$+1):Z);return{...y,children:X}};u(y=>({...y,gridRoot:S(y.gridRoot,0)}))},ne=(s,g)=>{u(S=>({...S,floating:S.floating.map(y=>y.id===s?{...y,...g}:y)}))},Xe=()=>{let s=l.current.panels,g=[],S={};for(let[O,G]of Object.entries(s)){let B=C.current[O],Q=B?.(),se=B!==void 0&&Q!==void 0,ue=se?Q:G.props,Ce=se?Ft(Q):G.serializable;if(Ce){let{icon:Ae,...ke}=G;typeof ke.title=="function"&&delete ke.title,S[O]=se?{...ke,props:ue,serializable:Ce}:ke}else g.push(O)}let y=l.current.gridRoot,$=l.current.floating,F=l.current.minimized;for(let O of g)y=Fe(y,O)||{type:"leaf",id:"group-default",panels:[],activePanelId:null},$=$.filter(G=>G.id!==O),F=F.filter(G=>G.id!==O);g.length>0&&f.current.publish("layout:panels-excluded",{panels:g.map(O=>({id:O,component:s[O].component}))});let X=l.current.activePanelId,Z=X!==null&&_t(X,{gridRoot:y,floating:$,panels:S})?X:null,j={version:2,...Z!==null?{activePanelId:Z}:{},gridRoot:y,floating:$,minimized:F.map(O=>typeof O.title=="function"?{id:O.id,component:O.component}:O),panels:S};return JSON.stringify(j)},We=s=>{try{let g=mo(JSON.parse(s));return g?(b.current=Math.max(b.current,P(g.floating)),u(S=>{let y={};for(let[F,X]of Object.entries(g.panels)){let Z=X.title?X:{...X,title:t.get(X.component)?.defaultOptions?.title||F},j=S.panels[F];y[F]=j?.icon!==void 0&&j.component===Z.component?{...Z,icon:j.icon}:Z}let $=F=>F.title||y[F.id]?.title||F.id;return{...S,gridRoot:g.gridRoot,floating:g.floating,minimized:g.minimized.map(F=>F.title?F:{...F,title:$(F)}),panels:y,draggedPanelId:null,activePanelId:g.activePanelId}}),!0):!1}catch(g){return console.error("Failed to parse layout configuration:",g),!1}},Ge=s=>{u(g=>g.activePanelId===s?g:{...g,activePanelId:s})},Ve=s=>{u(g=>g.dir===s?g:{...g,dir:s,isRtl:s==="rtl"})},ht=s=>s in l.current.panels,tt=()=>Object.keys(l.current.panels),nt=(s,g)=>Object.values(l.current.panels).find(y=>y.component===s&&y.dedupeKey===g)?.id??null,Ee={current:new Map},me={current:null};return{actions:{openPanel:a,closePanel:p,minimizePanel:k,restorePanel:L,floatPanel:H,dockPanel:Y,maximizePanel:re,updateSplitSizes:Re,updateFloatingPosition:ne,focusPanel:N,isOpen:ht,getOpenPanelIds:tt,findPanelId:nt,saveLayout:Xe,loadLayout:We,publish:h,subscribe:I,setDraggedPanelId:U,dockPanelToGroup:K,movePanelOrder:le,closeLeafGroup:te,registerCloseGuard:D,unregisterCloseGuard:_,registerStateProvider:M,unregisterStateProvider:A,setPanelDirty:z,updatePanelTitle:W,setPanelIcon:T,requestClosePanel:v,dockPanelToWorkspaceEdge:oe,setActivePanel:Ge,setDirection:Ve,registerPanelContextMenu:(s,g)=>(Ee.current.set(s,g),()=>{Ee.current.delete(s)}),getPanelContextMenuItems:s=>Ee.current.get(s)?.()??[],showContextMenu:s=>{me.current?.({dir:l.current.dir,...s})},registerContextMenuFn:s=>(me.current=s,()=>{me.current=null})},getSnapshot:d,subscribeToState:R,applyProviderDefaults:s=>{e.dir===void 0&&s.dir&&Ve(s.dir),e.zIndexBase===void 0&&s.zIndexBase!==void 0&&r.floating.length===0&&(b.current=s.zIndexBase)}}}import{jsx as Pt}from"react/jsx-runtime";var it=xt(null),Tn=xt(null),dr=xt(null),Sn=xt(null),ur=xt(en),pr=xt({}),je=()=>Ze(pr),fr=xt(xn),Bt=()=>Ze(fr),mr=({children:e,client:t,formatMessage:n,predefinedMessages:o,dir:r,modalClass:i,modalBodyClass:u,sidePanelClass:l,sidePanelBodyClass:d,windowClass:R,windowBodyClass:w,zIndexBase:C})=>{let[f]=qi(()=>{let p=t?t._core:on({registry:xn,dir:r,zIndexBase:C});return p.applyProviderDefaults({dir:r,zIndexBase:C}),p}),P=t?.registry??xn,b=cr(f.subscribeToState,f.getSnapshot,f.getSnapshot),I=f.actions,h=t?.config.formatMessage??n,E=t?.config.predefinedMessages??o,N=t?.config.dir??r,x=t?.config.zIndexBase??C??1e3,m=go(()=>({...en,...E}),[E]);Mn(()=>(document.documentElement.style.setProperty("--rdd-z-base",String(x)),()=>{document.documentElement.style.removeProperty("--rdd-z-base")}),[x]),Mn(()=>{N&&I.setDirection(N)},[N,I]);let c=go(()=>({modalClass:i,modalBodyClass:u,sidePanelClass:l,sidePanelBodyClass:d,windowClass:R,windowBodyClass:w}),[i,u,l,d,R,w]);Mn(()=>{if(process.env.NODE_ENV==="development")try{getComputedStyle(document.documentElement).getPropertyValue("--rdd-styles-loaded").trim()!=="1"&&console.error(`[react-dockable-desktop] styles.css is not imported.
|
|
2
2
|
Add this to your entry file (main.tsx / index.tsx):
|
|
3
3
|
import 'react-dockable-desktop/styles.css'
|
|
4
|
-
Without it the workspace renders as a black screen with no console errors.`)}catch{}},[]);let l=so(()=>({getSnapshot:m.getSnapshot,subscribeToState:m.subscribeToState}),[m]);return vt(or.Provider,{value:c,children:vt(rr.Provider,{value:M,children:vt(kn.Provider,{value:l,children:vt(ot.Provider,{value:P,children:vt(wn.Provider,{value:D,children:vt(tr.Provider,{value:p||yn,children:vt(nr.Provider,{value:k,children:e})})})})})})})},Jo=e=>()=>{};function Ce(e){let t=Ve(ot),n=Ve(kn),o=Qo(e);o.current=e;let r=er(e?n?.subscribeToState??Jo:Jo,()=>{let a=n?.getSnapshot()??t;return o.current?o.current(a):a},()=>{let a=n?.getSnapshot()??t;return o.current?o.current(a):a});if(!t)throw new Error("useWorkspaceState must be used within <DockableDesktopProvider>");return e?r:t}var Mn=()=>{let e=Ve(wn);if(!e)throw new Error("useWorkspace must be used within <DockableDesktopProvider>");return e},Tn=()=>{let e=Ve(wn);if(!e)throw new Error("react-dockable-desktop components must be used within <DockableDesktopProvider>");return e},fe=()=>Ve(tr)||yn;var de=()=>Ve(nr),lo=()=>Be().instanceId;function $i(e){let t=Ve(wn),n=lo(),o=Qo(e);o.current=e,Cn(()=>{if(!(!t?.registerPanelContextMenu||!n))return t.registerPanelContextMenu(n,()=>o.current)},[n,t?.registerPanelContextMenu])}var $t=class e{registry;initialState;config;_core;get _actions(){return this._core.actions}constructor(t={}){if(this.registry=new Nt,this.initialState=t.initialState??null,this.config={formatMessage:t.formatMessage,predefinedMessages:t.predefinedMessages,dir:t.dir,defaultSplitRatio:t.defaultSplitRatio,defaultEdgeSplitRatio:t.defaultEdgeSplitRatio,zIndexBase:t.zIndexBase},t.panels)for(let[n,o]of Object.entries(t.panels))this.registry.register(n,o.component,o.defaultOptions);for(let n of Object.getOwnPropertyNames(e.prototype)){let o=Object.getOwnPropertyDescriptor(e.prototype,n);n==="constructor"||!o||typeof o.value!="function"||(this[n]=o.value.bind(this))}this._core=tn({registry:this.registry,initialState:this.initialState,dir:t.dir,zIndexBase:t.zIndexBase,defaultSplitRatio:t.defaultSplitRatio,defaultEdgeSplitRatio:t.defaultEdgeSplitRatio})}_dispatch(t){t(this._actions)}_subscribeRaw(t,n){return this._actions.subscribe(t,n)}openPanel(...t){this._actions.openPanel(...t)}closePanel(t){this._dispatch(n=>n.closePanel(t))}minimizePanel(t){this._dispatch(n=>n.minimizePanel(t))}restorePanel(...t){this._dispatch(n=>n.restorePanel(...t))}floatPanel(...t){this._dispatch(n=>n.floatPanel(...t))}dockPanel(...t){this._dispatch(n=>n.dockPanel(...t))}maximizePanel(t){this._dispatch(n=>n.maximizePanel(t))}focusPanel(t){this._dispatch(n=>n.focusPanel(t))}isOpen(t){return this._actions.isOpen(t)}getOpenPanelIds(){return this._actions.getOpenPanelIds()}findPanelId(t,n){return this._actions.findPanelId(t,n)}saveLayout(){return this._actions.saveLayout()}loadLayout(t){return this._actions.loadLayout(t)}setDirection(t){this._dispatch(n=>n.setDirection(t))}updateSplitSizes(t,n){this._dispatch(o=>o.updateSplitSizes(t,n))}updateFloatingPosition(t,n){this._dispatch(o=>o.updateFloatingPosition(t,n))}setDraggedPanelId(t){this._dispatch(n=>n.setDraggedPanelId(t))}dockPanelToGroup(t,n,o){this._dispatch(r=>r.dockPanelToGroup(t,n,o))}movePanelOrder(t,n,o){this._dispatch(r=>r.movePanelOrder(t,n,o))}closeLeafGroup(t,n){return this._actions.closeLeafGroup(t,n)}registerCloseGuard(t,n){this._dispatch(o=>o.registerCloseGuard(t,n))}unregisterCloseGuard(t){this._dispatch(n=>n.unregisterCloseGuard(t))}registerStateProvider(t,n){this._dispatch(o=>o.registerStateProvider(t,n))}unregisterStateProvider(t){this._dispatch(n=>n.unregisterStateProvider(t))}setPanelDirty(t,n,o){this._dispatch(r=>r.setPanelDirty(t,n,o))}updatePanelTitle(t,n){this._dispatch(o=>o.updatePanelTitle(t,n))}setPanelIcon(t,n){this._dispatch(o=>o.setPanelIcon(t,n))}requestClosePanel(t,n){return this._actions.requestClosePanel(t,n)}dockPanelToWorkspaceEdge(t,n){this._dispatch(o=>o.dockPanelToWorkspaceEdge(t,n))}showContextMenu(t){this._dispatch(n=>n.showContextMenu(t))}publish(t,n){this._dispatch(o=>o.publish(t,n))}subscribe(t,n){return this._subscribeRaw(t,n)}onPanelOpen(t){return this._subscribeRaw("panel:opened",n=>{let o=n;t(o.id,o.component)})}onPanelClose(t){return this._subscribeRaw("panel:closed",n=>{t(n.id)})}onPanelMinimize(t){return this._subscribeRaw("panel:minimized",n=>{t(n.id)})}onPanelRestore(t){return this._subscribeRaw("panel:restored",n=>{t(n.id)})}onLayoutChanged(t){return this._subscribeRaw("layout:changed",()=>t())}onPanelsExcluded(t){return this._subscribeRaw("layout:panels-excluded",n=>{t(n.panels)})}};import{createContext as Bi}from"react";var Sn=Bi(null);import{createContext as lr,useContext as cr,useState as Gi,useCallback as Ae,useMemo as Yi,useRef as Ki}from"react";import{jsx as sr}from"react/jsx-runtime";var Xi=0,co=()=>`panel-${++Xi}-${Date.now()}`,En=new Map;function Vi(e,t){if("props"in t&&t.props!==e.props||"dirty"in t&&!!t.dirty!=!!e.dirty||"dirtyOptions"in t&&!Pn(t.dirtyOptions,e.dirtyOptions))return!1;if("options"in t&&t.options!==e.options){let n=t.options,o=e.options,r=new Set([...Object.keys(n),...Object.keys(o)]);for(let a of r)if(a==="title"?!Qt(n[a],o[a]):n[a]!==o[a])return!1}return!0}var ar={leftPanel:null,rightPanel:null,modals:[]},dr=lr(null),ur=lr(null),pr=({children:e})=>{let[t,n]=Gi(ar),o=de().modalTitle,r=Ki(t);r.current=t;let a=Ae((E,I)=>{En.set(E,I)},[]),u=Ae(E=>{En.delete(E)},[]),s=Ae(async(E,I,f={})=>{let k=r.current.leftPanel;if(k){let g=En.get(k.id);if(g&&!await g())return null}let c=co(),l={id:c,Component:E,props:I,containerType:"left-panel",options:f};return n(g=>({...g,leftPanel:l})),c},[]),d=Ae(async(E,I,f={})=>{let k=r.current.rightPanel;if(k){let g=En.get(k.id);if(g&&!await g())return null}let c=co(),l={id:c,Component:E,props:I,containerType:"right-panel",options:f};return n(g=>({...g,rightPanel:l})),c},[]),C=Ae((E,I,f={})=>{let k=co(),c=I.title,l={...f,title:f.title||c||o},g={id:k,Component:E,props:I,containerType:"modal",options:l};return n(F=>({...F,modals:[...F.modals,g]})),k},[o]),R=Ae(E=>{n(I=>({leftPanel:I.leftPanel?.id===E?null:I.leftPanel,rightPanel:I.rightPanel?.id===E?null:I.rightPanel,modals:I.modals.filter(f=>f.id!==E)}))},[]),y=Ae(()=>{n(ar)},[]),m=Ae(()=>{n(E=>({...E,modals:[]}))},[]),M=Ae(E=>t.leftPanel?.id===E?t.leftPanel:t.rightPanel?.id===E?t.rightPanel:t.modals.find(I=>I.id===E),[t]),P=Ae((E,I)=>{n(f=>{let k=f.leftPanel?.id===E?f.leftPanel:f.rightPanel?.id===E?f.rightPanel:f.modals.find(c=>c.id===E);return!k||Vi(k,I)?f:{leftPanel:f.leftPanel?.id===E?{...f.leftPanel,...I}:f.leftPanel,rightPanel:f.rightPanel?.id===E?{...f.rightPanel,...I}:f.rightPanel,modals:f.modals.map(c=>c.id===E?{...c,...I}:c)}})},[]),D=Ae((E,I,f)=>{P(E,{dirty:I,dirtyOptions:f})},[P]),p=Yi(()=>({openLeftPanel:s,openRightPanel:d,openModal:C,close:R,closeAll:y,closeAllModals:m,getInstance:M,updateInstance:P,setDirty:D,registerCloseHandler:a,unregisterCloseHandler:u}),[s,d,C,R,y,m,M,P,D,a,u]);return sr(dr.Provider,{value:t,children:sr(ur.Provider,{value:p,children:e})})},je=()=>{let e=cr(dr);if(!e)throw new Error("useModals / useSidePanels must be used within <DockableDesktopProvider>");return e},qe=()=>{let e=cr(ur);if(!e)throw new Error("useModals / useSidePanels must be used within <DockableDesktopProvider>");return e};import{useCallback as Bt,useRef as po,useEffect as oa,useState as ra,useMemo as ia}from"react";import{useEffect as fr,useRef as Zi}from"react";import{jsx as Pt,jsxs as uo}from"react/jsx-runtime";var ji=({title:e,message:t,alert:n,alertType:o="info",useYesNoTitles:r=!1,onOK:a,onCancel:u})=>{let{requestClose:s,setIcon:d,setTitle:C}=Be(),R=fe(),y=de(),m=Zi(null);fr(()=>{if(e){let I=typeof e=="string"?e:typeof e=="function"?e():R(e);C(I)}d&&d(Pt("span",{children:"\u2753"}))},[e,C,d,R]),fr(()=>{m.current?.focus({preventScroll:!0})},[]);let M=typeof t=="string"?t:R(t),P=R(r?y.no:y.cancel),D=R(r?y.yes:y.ok),p=I=>{I.preventDefault(),a?.(),s()},E=()=>{u?.(),s()};return uo("form",{onSubmit:p,className:"rdd-confirmation-form-body",children:[n&&uo("div",{className:`rdd-confirmation-alert rdd-confirmation-alert-${o}`,children:[Pt("span",{children:"\u2139\uFE0F"}),Pt("span",{children:n})]}),Pt("div",{className:"rdd-confirmation-message",children:M}),Pt("hr",{className:"rdd-confirmation-divider"}),uo("div",{className:"rdd-confirmation-actions",children:[Pt("button",{type:"button",className:"rdd-btn rdd-btn-sm rdd-btn-outline",onClick:E,children:P}),Pt("button",{type:"submit",className:"rdd-btn rdd-btn-sm rdd-btn-primary",ref:m,children:D})]})]})},xt=ji;import{useEffect as qi,useLayoutEffect as Ui,useRef as Ji}from"react";var mr={drawer:1,modal:2,popup:3},rt=[],Qi=0;function gr(e){if(e.key!=="Escape"||e.defaultPrevented||rt.length===0)return;let t=rt[0];for(let n of rt){let o=mr[n.layer]-mr[t.layer];(o>0||o===0&&n.order>t.order)&&(t=n)}e.preventDefault(),t.onEscape()}function ea(e,t){let n={layer:e,order:Qi++,onEscape:t};return rt.push(n),rt.length===1&&document.addEventListener("keydown",gr),()=>{let o=rt.indexOf(n);o!==-1&&(rt.splice(o,1),rt.length===0&&document.removeEventListener("keydown",gr))}}function it(e,t,n){let o=Ji(n);Ui(()=>{o.current=n}),qi(()=>{if(e)return ea(t,()=>o.current())},[e,t])}import{useLayoutEffect as ta,useState as na}from"react";function br(e){let[t,n]=na(null);return ta(()=>{let o=e.current?.parentElement;if(!o)return;let r=()=>{let u=o.getBoundingClientRect();n({top:u.top,left:u.left,right:window.innerWidth-u.right,height:u.height})};r();let a=new ResizeObserver(r);return a.observe(o),window.addEventListener("resize",r),()=>{a.disconnect(),window.removeEventListener("resize",r)}},[e]),t}import{Fragment as sa,jsx as Pe,jsxs as fo}from"react/jsx-runtime";var In=({panel:e,position:t,defaultWidth:n,containerRect:o})=>{let{close:r,openModal:a,updateInstance:u,setDirty:s,registerCloseHandler:d,unregisterCloseHandler:C}=qe(),R=fe(),y=de(),{dir:m}=Ce(),{sidePanelClass:M,sidePanelBodyClass:P}=Ze(),D=po(null),{id:p,Component:E,props:I,options:f,dirty:k,dirtyOptions:c}=e,l=f,[g,F]=ra(l.icon||null),H=po(l);H.current=l;let S=q(l.title,R),A=Bt(async re=>{if(re?.force){r(p);return}if(D.current){if(!await D.current())return;r(p);return}if(k){a(xt,{title:c?.title||y.unsavedChangesTitle,message:c?.message||{id:y.unsavedChangesMessage.id,defaultMessage:y.unsavedChangesMessage.defaultMessage,values:{title:S}},alert:c?.alert,alertType:c?.alertType||"danger",useYesNoTitles:!0,onOK:()=>r(p)},{size:"small"});return}r(p)},[r,a,p,k,c,S,y]),W=Bt(async()=>D.current?await D.current():!k,[k]);oa(()=>(d(p,W),()=>C(p)),[p,W,d,C]);let N=Bt((re,te)=>s(p,re,te),[s,p]),w=Bt(re=>u(p,{options:{...H.current,title:re}}),[u,p]),h=Bt(re=>F(re),[]),x=Bt(re=>(D.current=re,()=>{D.current=null}),[]),L=ia(()=>({requestClose:A,setDirty:N,setTitle:w,setIcon:h,onCloseRequested:x,containerType:t==="left"?"left-panel":"right-panel",instanceId:p}),[A,N,w,h,x,t,p]),$=k?`${S} *`:S;it(!0,"drawer",A);let Y=l.width||n||400,U=typeof Y=="number"?`${Y}px`:Y,j=l.bodyPadding,oe=j!=null?typeof j=="number"?`${j}px`:j:void 0;return Pe("div",{className:`rdd-side-panel rdd-side-panel-${t} rdd-side-panel-visible ${M??""}`,style:{width:U,...o?{top:o.top,height:o.height,bottom:"auto",...t==="right"?{right:o.right}:{left:o.left}}:{}},dir:m,children:fo("div",{className:"rdd-side-panel-window",children:[fo("div",{className:"rdd-side-panel-header",children:[g&&Pe("div",{className:"rdd-side-panel-icon",children:g}),Pe("h4",{className:"rdd-side-panel-title",children:$}),Pe("button",{className:"rdd-side-panel-close-button",onClick:()=>A(),title:R(y.closeTooltip),type:"button",children:Pe("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:Pe("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),Pe("div",{className:`rdd-side-panel-body ${P??""}`,style:oe!=null?{padding:oe}:void 0,children:Pe(Wt,{value:L,children:Pe(E,{...I,panelId:p})})})]})})},mo=({children:e})=>{let t=po(null),n=br(t);return Pe("div",{ref:t,className:"rdd-side-panel-anchor",children:e(n)})},aa=({defaultWidth:e})=>{let{leftPanel:t,rightPanel:n}=je();return Pe(mo,{children:o=>fo(sa,{children:[t&&Pe(In,{panel:t,position:"left",defaultWidth:e,containerRect:o},t.id),n&&Pe(In,{panel:n,position:"right",defaultWidth:e,containerRect:o},n.id)]})})},hr=({defaultWidth:e})=>{let{leftPanel:t}=je();return Pe(mo,{children:n=>t?Pe(In,{panel:t,position:"left",defaultWidth:e,containerRect:n},t.id):null})},vr=({defaultWidth:e})=>{let{rightPanel:t}=je();return Pe(mo,{children:n=>t?Pe(In,{panel:t,position:"right",defaultWidth:e,containerRect:n},t.id):null})},yr=aa;import rn,{forwardRef as xr,useImperativeHandle as ca,useState as go,useRef as Rt,useEffect as da,useLayoutEffect as Dn}from"react";import{createPortal as Rr}from"react-dom";function la(e){if(!e)return typeof document<"u"?document.documentElement.dir?.toLowerCase()==="rtl"||document.body.dir?.toLowerCase()==="rtl":!1;let t=e.closest("[dir]");return t?t.getAttribute("dir")?.toLowerCase()==="rtl":document.documentElement.dir?.toLowerCase()==="rtl"||document.body.dir?.toLowerCase()==="rtl"}function xe(e){return!e||typeof getComputedStyle>"u"?!1:getComputedStyle(e).direction==="rtl"}var Gt=e=>e?Array.from(e.querySelectorAll(':scope > [role^="menuitem"]:not(:disabled)')):[];function nn(e,t){let n=Gt(e);if(n.length===0)return!1;let o=n.indexOf(document.activeElement),r;return t==="ArrowDown"?r=n[(o+1)%n.length]:t==="ArrowUp"?r=n[o<0?n.length-1:(o-1+n.length)%n.length]:t==="Home"?r=n[0]:t==="End"&&(r=n[n.length-1]),r?(r.focus(),!0):!1}import{Fragment as ga,jsx as me,jsxs as Ct}from"react/jsx-runtime";function ua(e){if(!e||"touches"in e)return!1;let t=e;return t.clientX===0&&t.clientY===0}function pa(e){if(!e)return{x:0,y:0};if("touches"in e&&e.touches.length>0)return{x:e.touches[0].clientX,y:e.touches[0].clientY};let t=e;if(t.clientX===0&&t.clientY===0&&t.target instanceof Element){let n=t.target.getBoundingClientRect();if(n.width||n.height)return{x:n.left,y:n.bottom}}return{x:t.clientX,y:t.clientY}}function Yt(e,t){return typeof e=="string"?e:t?t(e):e.defaultMessage??e.id}function bo(e){return"separator"in e}function on(e){return!bo(e)&&"items"in e}var Cr=xr(({items:e,getAnchor:t,autoFocus:n,onBack:o,theme:r,dir:a,fmt:u,onClose:s,onMouseEnter:d,onMouseLeave:C},R)=>{Dn(()=>{let m=R?.current,M=t();if(!m||!M)return;let P=8,D=2,p=m.offsetWidth,E=m.offsetHeight,I=M.menuRight+D,f=M.menuLeft-D-p,k=I+p<=window.innerWidth-P,c=f>=P,l;M.rtl?l=c||!k?f:I:l=k||!c?I:f,l=Math.max(P,Math.min(l,window.innerWidth-p-P));let g=Math.max(P,Math.min(M.top,window.innerHeight-E-P));m.style.left=`${l}px`,m.style.top=`${g}px`}),Dn(()=>{n&&Gt(R?.current)[0]?.focus()},[n,R]);let y=m=>{let M=t()?.rtl?"ArrowRight":"ArrowLeft";if(m.key===M){m.preventDefault(),m.stopPropagation(),o();return}if(m.key==="Tab"){m.preventDefault(),m.stopPropagation(),s();return}nn(m.currentTarget,m.key)&&(m.preventDefault(),m.stopPropagation())};return Rr(me("div",{ref:R,className:`rdd-context-menu rdd-context-menu--${r} rdd-context-menu--submenu`,dir:a,role:"menu",tabIndex:-1,onKeyDown:y,onMouseEnter:d,onMouseLeave:C,children:e.map((m,M)=>{if(bo(m))return me("hr",{className:"rdd-context-menu__separator",role:"separator"},M);let P=m,D=P.checkbox&&P.checkbox.active!==!1,p=D&&P.checkbox.value,E=P.disabled===!0||(D?P.checkbox.enabled===!1:!1);return Ct("button",{type:"button",className:`rdd-context-menu__item${E?" rdd-context-menu__item--disabled":""}`,title:P.title?Yt(P.title,u):void 0,disabled:E,"data-cy-action":P.cyAction,onClick:()=>{E||(P.action?.(),s())},role:D?"menuitemcheckbox":"menuitem","aria-checked":D?p:void 0,children:[P.icon?me("span",{className:"rdd-context-menu__icon",children:P.icon}):me("span",{className:"rdd-context-menu__icon","aria-hidden":"true"}),me("span",{className:"rdd-context-menu__label",children:Yt(P.label,u)}),D&&me("span",{className:`rdd-context-menu__checkbox${p?" rdd-context-menu__checkbox--checked":""}`,"aria-hidden":"true",children:Ct("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[me("rect",{x:"0.75",y:"0.75",width:"10.5",height:"10.5",rx:"2",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),p&&me("path",{d:"M2.5 6 L4.5 8.5 L9.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})]},M)})}),document.body)});Cr.displayName="ContextMenuSubMenuPanel";var Pr={visible:!1,x:0,y:0,items:[],dir:"ltr",initialFocus:"menu"};function fa(e,t){let n=e?.target;return n instanceof Element?xe(n)?"rtl":"ltr":t||(xe(document.documentElement)?"rtl":"ltr")}var Ln=xr(({theme:e="dark",formatMessageProvider:t,onShow:n,onHide:o,onOpenChange:r,className:a,style:u},s)=>{let[d,C]=go(Pr),[R,y]=go(null),[m,M]=go(!1),P=Rt(null),D=Rt(null),p=Rt(!1),E=Rt(null),I=Rt(new Map),f=Rt({open:null,close:null}),k=rn.useCallback(()=>{let w=document.activeElement;p.current=!!w&&(!!P.current?.contains(w)||!!E.current?.contains(w)),C(Pr),y(null),f.current.open&&clearTimeout(f.current.open),f.current.close&&clearTimeout(f.current.close),f.current.open=null,f.current.close=null,o?.(),r?.(!1)},[o,r]);if(ca(s,()=>({show({event:w,x:h,y:x,items:L,dir:$,initialFocus:Y}){let U=w?pa(w):{x:h??0,y:x??0};D.current=document.activeElement instanceof HTMLElement&&document.activeElement!==document.body?document.activeElement:null,I.current.clear(),C({visible:!0,x:U.x,y:U.y,items:L,dir:fa(w,$),initialFocus:Y??(ua(w)?"first-item":"menu")}),y(null),M(!1),n?.(),r?.(!0)}}),[n,r]),Dn(()=>{if(d.visible){d.initialFocus==="first-item"?Gt(P.current)[0]?.focus():P.current?.focus({preventScroll:!0});return}if(!p.current)return;p.current=!1;let w=D.current,h=document.activeElement;w?.isConnected&&(!h||h===document.body)&&w.focus()},[d.visible,d.items,d.initialFocus]),da(()=>{if(!d.visible)return;let w=h=>{if(!(h.target instanceof Node)){k();return}P.current?.contains(h.target)||E.current?.contains(h.target)||k()};return document.addEventListener("pointerdown",w,{capture:!0}),window.addEventListener("click",w),()=>{document.removeEventListener("pointerdown",w,{capture:!0}),window.removeEventListener("click",w)}},[d.visible,k]),it(d.visible,"popup",k),Dn(()=>{if(!d.visible||!P.current)return;let w=P.current,h=w.getBoundingClientRect(),x=8;h.right>window.innerWidth-x&&(w.style.left=`${Math.max(x,window.innerWidth-h.width-x)}px`),h.bottom>window.innerHeight-x&&(w.style.top=`${Math.max(x,window.innerHeight-h.height-x)}px`),h.left<x&&(w.style.left=`${x}px`),h.top<x&&(w.style.top=`${x}px`)},[d.visible]),!d.visible)return null;let c=t,l=()=>{let w=R===null?null:I.current.get(R),h=P.current;if(!w||!h)return null;let x=h.getBoundingClientRect();return{menuLeft:x.left,menuRight:x.right,top:w.getBoundingClientRect().top,rtl:xe(w)}},g=()=>{let w=R===null?null:I.current.get(R);y(null),M(!1),w?.focus()};function F(){f.current.open&&(clearTimeout(f.current.open),f.current.open=null)}function H(){f.current.close&&(clearTimeout(f.current.close),f.current.close=null)}function S(w,h){H(),R!==null&&R!==w&&(F(),y(null)),on(h)&&h.items?.length?(F(),f.current.open=setTimeout(()=>{M(!1),y(w)},150)):on(h)||(F(),R!==null&&(f.current.close=setTimeout(()=>y(null),200)))}let A=w=>{F(),H(),M(!0),y(w)};function W(w){if(w.key==="Tab"){w.preventDefault(),k();return}let h=xe(w.currentTarget)?"ArrowLeft":"ArrowRight";if(w.key===h){let x=Number(document.activeElement?.dataset.menuIndex),L=d.items[x];L&&on(L)&&L.items?.length&&(w.preventDefault(),A(x));return}nn(w.currentTarget,w.key)&&(w.preventDefault(),R!==null&&y(null))}function N(w){F(),on(w)&&w.items?.length&&(f.current.close=setTimeout(()=>y(null),200))}return Rr(Ct(ga,{children:[me("div",{ref:P,className:`rdd-context-menu rdd-context-menu--${e}${a?` ${a}`:""}`,dir:d.dir,style:{left:d.x,top:d.y,...u},role:"menu",tabIndex:-1,"aria-orientation":"vertical",onKeyDown:W,children:d.items.map((w,h)=>{if(bo(w))return me("hr",{className:"rdd-context-menu__separator",role:"separator"},h);if(on(w))return Ct("button",{ref:U=>{I.current.set(h,U)},type:"button",className:`rdd-context-menu__item rdd-context-menu__item--has-submenu${R===h?" rdd-context-menu__item--submenu-open":""}`,title:w.title?Yt(w.title,c):void 0,"data-menu-index":h,onMouseEnter:()=>S(h,w),onMouseLeave:()=>N(w),onClick:U=>{w.items?.length&&(F(),H(),M(U.detail===0),y(R===h&&U.detail!==0?null:h))},role:"menuitem","aria-haspopup":"true","aria-expanded":R===h,children:[me("span",{className:"rdd-context-menu__icon","aria-hidden":"true"}),me("span",{className:"rdd-context-menu__label",children:Yt(w.label,c)}),me("span",{className:"rdd-context-menu__chevron","aria-hidden":"true",children:"\u203A"})]},h);let x=w,L=x.checkbox&&x.checkbox.active!==!1,$=L&&x.checkbox.value,Y=x.disabled===!0||(L?x.checkbox.enabled===!1:!1);return Ct("button",{ref:U=>{I.current.set(h,U)},"data-menu-index":h,type:"button",className:`rdd-context-menu__item${Y?" rdd-context-menu__item--disabled":""}`,title:x.title?Yt(x.title,c):void 0,disabled:Y,"data-cy-action":x.cyAction,onClick:()=>{Y||(x.action?.(),k())},onMouseEnter:()=>S(h,w),onMouseLeave:()=>N(w),role:L?"menuitemcheckbox":"menuitem","aria-checked":L?$:void 0,children:[x.icon?me("span",{className:"rdd-context-menu__icon",children:x.icon}):me("span",{className:"rdd-context-menu__icon","aria-hidden":"true"}),me("span",{className:"rdd-context-menu__label",children:Yt(x.label,c)}),L&&me("span",{className:`rdd-context-menu__checkbox${$?" rdd-context-menu__checkbox--checked":""}`,"aria-hidden":"true",children:Ct("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[me("rect",{x:"0.75",y:"0.75",width:"10.5",height:"10.5",rx:"2",fill:$?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.5"}),$&&me("path",{d:"M2.5 6 L4.5 8.5 L9.5 3.5",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})]},h)})}),R!==null&&(()=>{let w=d.items[R];return me(Cr,{ref:E,items:w.items??[],getAnchor:l,autoFocus:m,onBack:g,theme:e,dir:d.dir,fmt:c,onClose:k,onMouseEnter:()=>H(),onMouseLeave:()=>{f.current.close=setTimeout(()=>y(null),200)}})})()]}),document.body)});Ln.displayName="ContextMenu";var an={Component:Ln},Kt=rn.createContext(null),On=({adapter:e=an,children:t,...n})=>{let o=Rt(null),[r,a]=rn.useState(!1),u=rn.useCallback(s=>{o.current?.show(s)},[]);return Ct(Kt.Provider,{value:{show:u,isOpen:r},children:[t,me(e.Component,{ref:o,...n,onShow:()=>{a(!0),n.onShow?.()},onHide:()=>{a(!1),n.onHide?.()}})]})};function ma(){let e=rn.useContext(Kt);if(!e)throw new Error("useContextMenu must be used within <DockableDesktopProvider> or <RddContextMenu>");return e.show}import{jsx as sn}from"react/jsx-runtime";function va(e={}){let{messages:t,...n}=e;return new $t({...n,predefinedMessages:t})}function ya(){let e=kr(Sn);if(!e)throw new Error("useWorkspace must be used within <DockableDesktopProvider>");return e}var Pa=()=>()=>{};function wr(e,t){let n=kr(kn),o=cn(e);ln(()=>{o.current=e});let r=()=>n?e(n.getSnapshot()):t;return ha(n?.subscribeToState??Pa,r,r)}function xa(){let e=Be(),t=e.instanceId,n=wr(s=>s.panels[t]?.state,void 0),o=wr(s=>s.activePanelId===t,!1),r=n?n==="floating"?"floating-window":"dockable-panel":e.containerType??"standalone",a=cn(e);ln(()=>{a.current=e});let u=Nn(()=>({close:s=>a.current.requestClose(s),minimize:()=>a.current.requestMinimize?.(),setDirty:(s,d)=>a.current.setDirty(s,d),setTitle:s=>a.current.setTitle(s),setIcon:s=>a.current.setIcon?.(s)}),[t]);return Nn(()=>({id:t,containerType:r,isActive:!!n&&o,isMinimized:n==="minimized",isFloating:n==="floating",...u}),[u,t,r,n,o])}function Ra(e){let t=Be(),n=cn(e);ln(()=>{n.current=e}),ho(()=>{let o=[t.onActivate?.(()=>n.current.onActivate?.()),t.onDeactivate?.(()=>n.current.onDeactivate?.()),t.onMinimize?.(()=>n.current.onMinimize?.()),t.onRestore?.(()=>n.current.onRestore?.()),t.onClose?.(()=>n.current.onClose?.()),t.onResize?.((r,a)=>n.current.onResize?.(r,a)),t.onContainerTypeChange?.(r=>n.current.onContainerTypeChange?.(r))];return()=>{o.forEach(r=>r?.())}},[t])}function Ca(e){let t=Be(),n=cn(e);ln(()=>{n.current=e}),ho(()=>t.onCloseRequested(()=>n.current?n.current():!0),[t])}function wa(e){let t=Be(),n=cn(e);ln(()=>{n.current=e}),ho(()=>t.registerStateProvider?.(()=>n.current?.()),[t])}function ka(){let{modals:e}=je(),t=qe();return Nn(()=>({stack:e,topmost:e[e.length-1]??null,open:t.openModal,close:t.close,closeAll:t.closeAllModals,get:t.getInstance,update:t.updateInstance,setDirty:t.setDirty}),[e,t])}function Ma(){let{leftPanel:e,rightPanel:t}=je(),n=qe();return Nn(()=>({left:e,right:t,openLeft:n.openLeftPanel,openRight:n.openRightPanel,close:n.close,closeAll:()=>{e&&n.close(e.id),t&&n.close(t.id)},get:n.getInstance,update:n.updateInstance,setDirty:n.setDirty}),[e,t,n])}function Ta({side:e,defaultWidth:t}){return e==="left"?sn(hr,{defaultWidth:t}):e==="right"?sn(vr,{defaultWidth:t}):sn(yr,{defaultWidth:t})}var Sa=ba(function({children:t,adapter:n,...o},r){return t!==void 0?sn(On,{adapter:n,...o,children:t}):sn(Ln,{ref:r,...o})});import{useContext as Ya,useState as Ka}from"react";import{createContext as Ea,useContext as Ia,useMemo as Da,useState as Mr}from"react";import{jsx as La}from"react/jsx-runtime";var Tr=Ea(null),vo=({children:e})=>{let[t,n]=Mr({}),[o,r]=Mr({}),a=Da(()=>({getActiveInGroup:u=>t[u]??null,setActiveInGroup:(u,s)=>n(d=>({...d,[u]:s})),isModifierActive:u=>o[u]??!1,setModifierActive:(u,s)=>r(d=>({...d,[u]:s})),toggleModifier:u=>r(s=>({...s,[u]:!s[u]}))}),[t,o]);return La(Tr.Provider,{value:a,children:e})};function Wn(){let e=Ia(Tr);if(!e)throw new Error("useToolbar must be used within DockableDesktopProvider");return e}import{createContext as Oa,useCallback as Na,useContext as Sr,useLayoutEffect as Wa,useMemo as Aa,useRef as za,useSyncExternalStore as Fa}from"react";import{jsx as Ga}from"react/jsx-runtime";function _a(){let e=new Map,t=new Set,n=()=>t.forEach(o=>o());return{publish(o,r){return e.set(o,r),n(),()=>{e.get(o)===r&&(e.delete(o),n())}},get(o){return e.get(o)??null},subscribe(o){return t.add(o),()=>t.delete(o)}}}var yo=Oa(null),Er=({children:e})=>{let t=Aa(()=>_a(),[]);return Ga(yo.Provider,{value:t,children:e})};function Ha(e){let t=lo(),n=Sr(yo),o=za(null);if(!n)throw new Error("usePanelContribution must be used within <DockableDesktopProvider>");Wa(()=>{if(n)return o.current?.(),o.current=n.publish(t,e),()=>{o.current?.(),o.current=null}},[n,t,e])}function Po(){let e=Ce(r=>r.activePanelId),t=Sr(yo);if(!t)throw new Error("useActiveContribution must be used within <DockableDesktopProvider>");let n=Na(r=>t?t.subscribe(r):()=>{},[t]),o=()=>t&&e?t.get(e):null;return Fa(n,o,o)}function Ir(e,t=null){return{id:e.id,label:e.label,icon:e.icon??t,renderContent:()=>e.content}}function $a(e){let t=Po();return t?.toolbarItems?.length?[...e,{type:"separator"},...t.toolbarItems]:e}function Ba(e,t=null){let n=Po();return n?.sidebarSections?.length?[...e,...n.sidebarSections.map(o=>Ir(o,t))]:e}import{jsx as Xt}from"react/jsx-runtime";var Xa=({contextMenuAdapter:e=an,workspace:t,messages:n,children:o,...r})=>{let a=Ya(Kt),[u]=Ka(()=>t??new $t),s=Xt(Sn.Provider,{value:u,children:Xt(vo,{children:Xt(ir,{client:u,predefinedMessages:n,...r,children:Xt(Er,{children:Xt(pr,{children:o})})})})});return a!==null?s:Xt(On,{adapter:e,formatMessageProvider:r.formatMessage,children:s})};import ps,{useState as Eo,useRef as ct,useEffect as Ie,useCallback as Io,useContext as fs}from"react";import{createPortal as ms}from"react-dom";import{useSyncExternalStore as Va}from"react";var Za=()=>()=>{},ja=()=>!0,qa=()=>!1;function An(){return Va(Za,ja,qa)}var xo=new Map,Dr=new WeakSet,Lr=e=>e.isConnected&&e.getClientRects().length>0;function Or(e,t){if(Dr.has(t))return;Dr.add(t);let n={scrolls:new Map,focused:null};xo.set(e,n),t.addEventListener("scroll",o=>{let r=o.target;!(r instanceof Element)||!Lr(r)||n.scrolls.set(r,{top:r.scrollTop,left:r.scrollLeft})},{capture:!0,passive:!0}),t.addEventListener("focusin",o=>{o.target instanceof HTMLElement&&(n.focused=o.target)})}function Ro(e,{refocus:t}){let n=xo.get(e);if(!n)return;let o=()=>{n.scrolls.forEach(({top:u,left:s},d)=>{if(!d.isConnected){n.scrolls.delete(d);return}d.scrollTop!==u&&(d.scrollTop=u),d.scrollLeft!==s&&(d.scrollLeft=s)});let r=n.focused,a=document.activeElement===null||document.activeElement===document.body;t&&a&&r?.isConnected&&Lr(r)&&r.focus({preventScroll:!0})};o(),typeof requestAnimationFrame<"u"&&requestAnimationFrame(o)}function Nr(e){xo.delete(e)}import{useSyncExternalStore as Ua}from"react";var Ja=()=>document.documentElement.getAttribute("data-color-scheme")==="light"?"light":"dark",Qa=e=>{let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["data-color-scheme"]}),()=>t.disconnect()},es=()=>"dark";function Co(){return Ua(Qa,Ja,es)}import ts,{useRef as kt,useEffect as Vt,useLayoutEffect as ns}from"react";import{jsx as st,jsxs as Wr}from"react/jsx-runtime";var Zt=new Map,zn="preserved-dom-container",wo=e=>{let t=Zt.get(e);return t||(t=document.createElement("div"),t.className="rdd-panel-dom",Zt.set(e,t),Or(e,t)),t},Ar=(e,t,n,o,r)=>{let a=t.component,u=n.get(a);if(!u)return console.warn(`[react-dockable-desktop] Panel "${e}" references component key "${a}" which is not registered. Add it to the workspace's panels:
|
|
5
|
-
createWorkspace({ panels: { "${a}": { component: YourComponent } } })`),Wr("div",{className:"rdd-unregistered-panel",children:[Wr("h6",{className:"rdd-unregistered-panel__title",children:["\u26A0\uFE0F ",q(o.componentUnregistered,r)]}),st("span",{className:"rdd-unregistered-panel__key",children:q({...o.componentKey,values:{key:a}},r)})]});let s=u.Component;return st(s,{...t.props??{},panelId:e})},ko=new Map,at=new Map,wt=e=>{let t=at.get(e);return t||(t={onClose:new Set,onMinimize:new Set,onRestore:new Set,onResize:new Set,onActivate:new Set,onDeactivate:new Set,onContainerTypeChange:new Set},at.set(e,t)),t},Fn=({panelId:e})=>{let t=kt(null),n=Ce(r=>r.activePanelId===e),o=kt(n);return ns(()=>{o.current=n}),Vt(()=>{let r=t.current;if(!r)return;let a=wo(e);r.appendChild(a),Ro(e,{refocus:o.current});let u=new ResizeObserver(s=>{for(let d of s){let{width:C,height:R}=d.contentRect;if(C>0&&R>0){ko.set(e,{width:C,height:R});let y=at.get(e);y&&y.onResize.forEach(m=>m(C,R))}}});return u.observe(r),()=>{u.disconnect();let s=document.getElementById(zn);s||(s=document.createElement("div"),s.id=zn,s.style.display="none",document.body.appendChild(s)),s.appendChild(a)}},[e]),st("div",{ref:t,className:"rdd-panel-dom-host"})},zr=({panelId:e})=>{let t=Ce(),n=Ht(),o=fe(),r=de(),a=kt(null),u=t.panels[e],s=u?n.get(u.component):null,d=s?.defaultOptions?.disableLivePreview||!1,C=ko.get(e)||{width:800,height:500},R=C.width,y=C.height,P=Math.min(220/R,140/y);if(Vt(()=>{if(d)return;let D=a.current;if(!D)return;let p=Zt.get(e);if(p)return D.appendChild(p),Ro(e,{refocus:!1}),()=>{let E=document.getElementById(zn);E||(E=document.createElement("div"),E.id=zn,E.style.display="none",document.body.appendChild(E)),E.appendChild(p)}},[e,d]),d){let D=R*P,p=y*P,E=u?.title||s?.defaultOptions?.title||r.untitledPanel,I=q(E,o),f=(Array.from(I)[0]||"P").toUpperCase();return st("div",{className:"rdd-taskbar-item-preview-frame rdd-taskbar-item-preview-frame--empty",style:{width:`${D}px`,height:`${p}px`},children:st("div",{className:"rdd-taskbar-item-preview-initial",children:f})})}return st("div",{className:"rdd-taskbar-item-preview-frame",style:{width:`${R*P}px`,height:`${y*P}px`},children:st("div",{ref:a,className:"rdd-taskbar-item-preview-host",style:{width:`${R}px`,height:`${y}px`,transform:`scale(${P})`,"--rdd-preview-scale":P}})})},Fr=({panelId:e,children:t})=>{let n=Ce(),{requestClosePanel:o,setPanelDirty:r,registerCloseGuard:a,unregisterCloseGuard:u,registerStateProvider:s,unregisterStateProvider:d,updatePanelTitle:C,setPanelIcon:R,minimizePanel:y}=Mn(),m=n.minimized.some(c=>c.id===e),M=kt(m);Vt(()=>{let c=at.get(e);c&&(m&&!M.current?c.onMinimize.forEach(l=>l()):!m&&M.current&&c.onRestore.forEach(l=>l()),M.current=m)},[m,e]);let P=n.activePanelId===e,D=kt(P);Vt(()=>{let c=D.current;D.current=P;let l=at.get(e);l&&(P&&!c?l.onActivate.forEach(g=>g()):!P&&c&&l.onDeactivate.forEach(g=>g()))},[P,e]);let p=n.panels[e]?.state,E=p==="floating"?"floating-window":"dockable-panel",I=kt(E);Vt(()=>{if(p==="minimized")return;let c=I.current;I.current=E;let l=at.get(e);l&&E!==c&&l.onContainerTypeChange.forEach(g=>g(E))},[E,p,e]),Vt(()=>()=>{let c=at.get(e);c&&(D.current&&c.onDeactivate.forEach(l=>l()),c.onClose.forEach(l=>l()),at.delete(e))},[e]);let f=kt(E),k=ts.useMemo(()=>({requestClose:c=>o(e,c),setDirty:(c,l)=>r(e,c,l),onCloseRequested:c=>(a(e,c),()=>u(e)),registerStateProvider:c=>(s(e,c),()=>d(e)),setTitle:c=>C(e,c),setIcon:c=>R(e,c??null),instanceId:e,containerType:f.current,onClose:c=>{let l=wt(e);return l.onClose.add(c),()=>l.onClose.delete(c)},onMinimize:c=>{let l=wt(e);return l.onMinimize.add(c),()=>l.onMinimize.delete(c)},onRestore:c=>{let l=wt(e);return l.onRestore.add(c),()=>l.onRestore.delete(c)},onResize:c=>{let l=wt(e);return l.onResize.add(c),()=>l.onResize.delete(c)},requestMinimize:()=>y(e),getDimensions:()=>ko.get(e)??null,onActivate:c=>{let l=wt(e);return l.onActivate.add(c),()=>l.onActivate.delete(c)},onDeactivate:c=>{let l=wt(e);return l.onDeactivate.add(c),()=>l.onDeactivate.delete(c)},onContainerTypeChange:c=>{let l=wt(e);return l.onContainerTypeChange.add(c),()=>l.onContainerTypeChange.delete(c)}}),[e,o,r,a,u,s,d,C,R,y]);return st(Wt,{value:k,children:t})};import ss from"react";function Ue(e){let{element:t,pointerId:n,startClientX:o,startClientY:r,captureStart:a,onMove:u,onEnd:s,activeClasses:d}=e;t.setPointerCapture(n),d?.forEach(({el:m,classes:M})=>m.classList.add(...M));let C=a(),R=m=>{u(m.clientX-o,m.clientY-r,C)},y=()=>{d?.forEach(({el:m,classes:M})=>m.classList.remove(...M)),t.removeEventListener("pointermove",R),t.removeEventListener("pointerup",y),t.removeEventListener("pointercancel",y),s?.(C)};t.addEventListener("pointermove",R),t.addEventListener("pointerup",y),t.addEventListener("pointercancel",y)}function dn(e,t,n,o,r){let{minW:a,minH:u,maxW:s,maxH:d,minX:C,minY:R}=r,{x:y,y:m,w:M,h:P}=o;if(e.includes("e")&&(M=Math.max(a,Math.min(o.w+t,s??1/0))),e.includes("w")){let D=o.w-a,p=C!=null?-(o.x-C):-1/0,E=Math.max(p,Math.min(t,D));M=o.w-E,y=o.x+E}if(e.includes("s")&&(P=Math.max(u,Math.min(o.h+n,d??1/0))),e.includes("n")){let D=o.h-u,p=R!=null?-(o.y-R):-1/0,E=Math.max(p,Math.min(n,D));P=o.h-E,m=o.y+E}return{x:y,y:m,w:M,h:P}}import{useState as os,useRef as rs,useEffect as is,useCallback as as}from"react";import"react";var Mo=(e,t)=>{if(!e)return null;if(e.type==="leaf")return e.id===t?e:null;for(let n of e.children){let o=Mo(n,t);if(o)return o}return null},_n=(e,t)=>{let n=e.getBoundingClientRect();return t-n.left<n.width/2!==xe(e)?"left":"right"},Hn=e=>e.key==="ContextMenu"||e.shiftKey&&e.key==="F10",_r=new WeakSet,$n=e=>{let t=e.getBoundingClientRect(),n=new MouseEvent("contextmenu",{clientX:t.left,clientY:t.bottom,cancelable:!0});return _r.add(n),n},un=e=>_r.has(e)||e.type==="click"&&e.detail===0?"first-item":void 0,Hr=(e,t,n)=>{if(!n?.isConnected)return;let o=e.replace(/["\\]/g,"\\$&");if(n.querySelector(`[data-tab-id="${o}"]`))return;let r=document.activeElement;if(r&&r!==document.body)return;((t?.isConnected?t.querySelector('[role="tab"][aria-selected="true"]'):null)??n.querySelector(".rdd-workspace-tab-active-focused")??n.querySelector('[role="tab"][aria-selected="true"]')??n).focus()},To=e=>e.replace(/[^A-Za-z0-9_-]/g,"_"),Mt=300,Tt=8;import{jsx as ve,jsxs as $r}from"react/jsx-runtime";var jt=$r("svg",{className:"rdd-svg-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[ve("rect",{x:"3",y:"3",width:"7",height:"9",rx:"1"}),ve("rect",{x:"14",y:"3",width:"7",height:"5",rx:"1"}),ve("rect",{x:"14",y:"12",width:"7",height:"9",rx:"1"}),ve("rect",{x:"3",y:"16",width:"7",height:"5",rx:"1"})]}),St={float:ve("span",{className:"rdd-menu-icon",children:$r("svg",{className:"rdd-svg-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[ve("rect",{x:"2",y:"8",width:"14",height:"14",rx:"1"}),ve("rect",{x:"8",y:"2",width:"14",height:"14",rx:"1"})]})}),minimize:ve("span",{className:"rdd-menu-icon",children:ve("svg",{className:"rdd-svg-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:ve("line",{x1:"4",y1:"18",x2:"20",y2:"18"})})}),restore:ve("span",{className:"rdd-menu-icon",children:ve("svg",{className:"rdd-svg-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:ve("rect",{x:"4",y:"4",width:"16",height:"16",rx:"1"})})}),maximize:ve("span",{className:"rdd-menu-icon",children:ve("svg",{className:"rdd-svg-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:ve("rect",{x:"2",y:"2",width:"20",height:"20",rx:"1"})})}),close:ve("span",{className:"rdd-menu-icon",children:ve("svg",{className:"rdd-svg-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:ve("path",{d:"M18 6L6 18M6 6l12 12"})})})};import{jsx as ge,jsxs as Et}from"react/jsx-runtime";var Br=({leaf:e,onTabRightClick:t,activeDropZone:n,onHoverDropZone:o,onTabDragStart:r,hoveredTab:a,onTabHover:u,defaultPanelIcon:s,onRequestClosePanel:d})=>{let C=Ce(),R=Ht(),{openPanel:y,closeLeafGroup:m,setActivePanel:M}=Tn(),P=fe(),D=de(),{windowClass:p,windowBodyClass:E}=Ze(),I=rs(null),[f,k]=os({start:!1,end:!1,rtl:!1}),c=as(()=>{let h=I.current;if(!h)return;let x=Math.abs(h.scrollLeft),L=h.scrollWidth-h.clientWidth,$={start:x>1,end:x<L-1,rtl:xe(h)};k(Y=>Y.start===$.start&&Y.end===$.end&&Y.rtl===$.rtl?Y:$)},[]);is(()=>{let h=I.current;if(!h)return;h.addEventListener("scroll",c,{passive:!0});let x=new ResizeObserver(c);return x.observe(h),c(),()=>{h.removeEventListener("scroll",c),x.disconnect()}},[c]);let l=h=>{let x=h==="end"?120:-120;I.current?.scrollBy({left:f.rtl?-x:x,behavior:"smooth"})},g=f.rtl?"right":"left",F=f.rtl?"left":"right",H={left:"\u2039",right:"\u203A"},S={left:D.scrollTabsLeft,right:D.scrollTabsRight},A=h=>{y(h,C.panels[h].component),M(h)},W=(h,x,L)=>{if(Hn(h)){h.preventDefault(),t(x,$n(h.currentTarget));return}let $=e.panels.filter(oe=>C.panels[oe]),Y=$.indexOf(x),U=xe(h.currentTarget)?-1:1,j;switch(h.key){case"ArrowRight":j=$[(Y+U+$.length)%$.length];break;case"ArrowLeft":j=$[(Y-U+$.length)%$.length];break;case"Home":j=$[0];break;case"End":j=$[$.length-1];break;case"Enter":case" ":h.preventDefault(),A(x);return;case"Delete":{if(!L)return;h.preventDefault();let oe=h.currentTarget.closest(".rdd-workspace");Promise.resolve(d(x)).then(()=>requestAnimationFrame(()=>{Hr(x,I.current,oe)}));return}default:return}h.preventDefault(),!(!j||j===x)&&(A(j),I.current?.querySelector(`[data-tab-id="${j.replace(/["\\]/g,"\\$&")}"]`)?.focus())},N=`rdd-tabpanel-${To(e.id)}`,w=h=>`rdd-tab-${To(h)}`;return Et("div",{"data-active-panel-id":e.activePanelId||"","data-rdd-leaf":e.id,className:`rdd-workspace-panel ${p??""}`,children:[Et("div",{className:"rdd-workspace-tab-bar",children:[f.start&&ge("button",{className:`rdd-tab-scroll-btn rdd-tab-scroll-btn-${g}`,onPointerDown:h=>h.stopPropagation(),onClick:()=>l("start"),tabIndex:-1,"aria-label":q(S[g],P),children:H[g]}),ge("div",{ref:I,className:"rdd-tab-headers-container",role:"tablist","aria-orientation":"horizontal",onPointerMove:h=>{C.draggedPanelId&&h.target===h.currentTarget&&u(e.id,"EMPTY",e.panels.length,"right")},onPointerLeave:h=>{C.draggedPanelId&&h.target===h.currentTarget&&u(e.id,"",-1,null)},children:e.panels.map((h,x)=>{let L=C.panels[h];if(!L)return null;let $=e.activePanelId===h,Y=C.activePanelId===h,j=R.get(L.component)?.defaultOptions,oe=a&&a.leafId===e.id&&a.panelId===h,re=x===e.panels.length-1,te=a&&a.leafId===e.id&&a.panelId==="EMPTY"&&re,he=oe?a.side==="left"?"rdd-drag-hover-left":"rdd-drag-hover-right":te?"rdd-drag-hover-right":"",we=$?Y?"rdd-active rdd-workspace-tab-active-focused":"rdd-active rdd-workspace-tab-active-unfocused":"rdd-workspace-tab-inactive";return Et("div",{id:w(h),role:"tab","aria-selected":$,"aria-controls":N,"aria-keyshortcuts":j?.canClose!==!1?"Delete":void 0,tabIndex:$?0:-1,onKeyDown:ne=>W(ne,h,j?.canClose!==!1),"data-tab-id":h,"data-leaf-id":e.id,"data-rdd-tab":h,"data-tab-index":String(x),onClick:()=>A(h),onPointerDown:ne=>{j?.canDrag!==!1&&r(h,ne)},onContextMenu:ne=>t(h,ne),onPointerMove:ne=>{C.draggedPanelId&&ne.pointerType!=="touch"&&u(e.id,h,x,_n(ne.currentTarget,ne.clientX))},onPointerLeave:()=>{C.draggedPanelId&&u(e.id,"",-1,null)},className:`rdd-workspace-tab ${we} ${he}`,style:{cursor:j?.canDrag===!1?"default":"pointer"},children:[Et("span",{className:"rdd-text-truncate rdd-workspace-tab-title",children:[ge("span",{className:"rdd-workspace-tab-icon",children:L.icon??(j?.icon||s||jt)}),Et("span",{children:[q(L.title,P),L.dirty?" *":""]})]}),j?.renderHeaderActions&&ge("span",{className:"rdd-tab-header-actions",onClick:ne=>ne.stopPropagation(),onPointerDown:ne=>ne.stopPropagation(),children:j.renderHeaderActions(h)}),j?.canClose!==!1&&ge("span",{onClick:ne=>{ne.stopPropagation(),d(h)},title:q(D.closeTab,P),"aria-hidden":"true",className:`rdd-close-tab-x${j?.renderHeaderActions?"":" rdd-close-tab-x--end"}`,children:ge("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:ge("path",{d:"M18 6L6 18M6 6l12 12"})})})]},h)})}),f.end&&ge("button",{className:`rdd-tab-scroll-btn rdd-tab-scroll-btn-${F}`,onPointerDown:h=>h.stopPropagation(),onClick:()=>l("end"),tabIndex:-1,"aria-label":q(S[F],P),children:H[F]}),e.panels.length===0&&e.keepOnEmpty&&e.canClose!==!1&&ge("button",{type:"button",onClick:()=>{m(e.id)},className:"rdd-close-tab-x rdd-header-close-empty-group",title:q(D.closeEmptyGroup,P),"aria-label":q(D.closeEmptyGroup,P),children:ge("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5","aria-hidden":"true",children:ge("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),Et("div",{id:N,role:"tabpanel","aria-labelledby":e.activePanelId?w(e.activePanelId):void 0,className:`rdd-panel-body ${E??""}`,children:[e.activePanelId&&C.panels[e.activePanelId]?ge(Fn,{panelId:e.activePanelId},e.activePanelId):ge("div",{className:"rdd-empty-leaf-placeholder",children:ge("span",{children:q(D.emptyGroup,P)})}),C.draggedPanelId!==null&&(()=>{let h=x=>n?.leafId===e.id&&n.position===x;return ge("div",{className:"rdd-dock-drop-zone-overlay",children:Et("div",{className:"rdd-dock-target-cross",children:[ge("div",{"data-leaf-id":e.id,"data-drop-zone":"top",onPointerEnter:()=>o(e.id,"top"),onPointerLeave:()=>o(e.id,null),className:`rdd-dock-target-box rdd-dock-target-top${h("top")?" rdd-dock-target-box--active":""}`,children:"\u25B2"}),ge("div",{"data-leaf-id":e.id,"data-drop-zone":"bottom",onPointerEnter:()=>o(e.id,"bottom"),onPointerLeave:()=>o(e.id,null),className:`rdd-dock-target-box rdd-dock-target-bottom${h("bottom")?" rdd-dock-target-box--active":""}`,children:"\u25BC"}),ge("div",{"data-leaf-id":e.id,"data-drop-zone":"left",onPointerEnter:()=>o(e.id,"left"),onPointerLeave:()=>o(e.id,null),className:`rdd-dock-target-box rdd-dock-target-left${h("left")?" rdd-dock-target-box--active":""}`,children:"\u25C0"}),ge("div",{"data-leaf-id":e.id,"data-drop-zone":"right",onPointerEnter:()=>o(e.id,"right"),onPointerLeave:()=>o(e.id,null),className:`rdd-dock-target-box rdd-dock-target-right${h("right")?" rdd-dock-target-box--active":""}`,children:"\u25B6"}),ge("div",{"data-leaf-id":e.id,"data-drop-zone":"center",onPointerEnter:()=>o(e.id,"center"),onPointerLeave:()=>o(e.id,null),className:`rdd-dock-target-box rdd-dock-target-center${h("center")?" rdd-dock-target-box--active":""}`,children:"\u25A3"})]})})})(),C.draggedPanelId!==null&&n!==null&&n.leafId===e.id&&ge("div",{className:"rdd-dock-preview-highlight",style:(()=>{let h=n.position,x=`${C.splitRatio*100}%`,L=`${(1-C.splitRatio)*100}%`;return{left:h==="right"?L:"0",top:h==="bottom"?L:"0",width:h==="left"||h==="right"?x:"100%",height:h==="top"||h==="bottom"?x:"100%"}})()})]})]})};import{jsx as pn,jsxs as ls}from"react/jsx-runtime";var So=({node:e,path:t,onTabRightClick:n,activeDropZone:o,onHoverDropZone:r,onTabDragStart:a,hoveredTab:u,onTabHover:s,defaultPanelIcon:d,onRequestClosePanel:C})=>{let{updateSplitSizes:R}=Mn();if(e.type==="leaf")return pn(Br,{leaf:e,onTabRightClick:n,activeDropZone:o,onHoverDropZone:r,onTabDragStart:a,hoveredTab:u,onTabHover:s,defaultPanelIcon:d,onRequestClosePanel:C});let y=e.orientation==="horizontal",m=(M,P)=>{P.preventDefault();let D=P.currentTarget,p=D.parentElement,E=p?y?p.clientWidth:p.clientHeight:y?1e3:800,I=xe(p);Ue({element:D,pointerId:P.pointerId,startClientX:P.clientX,startClientY:P.clientY,captureStart:()=>[...e.sizes],activeClasses:[{el:D,classes:["rdd-active"]},{el:document.body,classes:["rdd-resizing-active",y?"rdd-resizing-col-active":"rdd-resizing-row-active"]}],onMove:(f,k,c)=>{let g=(y?(y&&I?-1:1)*f:k)/E,F=[...c];F[M]+=g,F[M+1]-=g,F[M]>.1&&F[M+1]>.1&&R(t,F)}})};return pn("div",{className:`rdd-split ${y?"rdd-split--row":"rdd-split--column"}`,children:e.children.map((M,P)=>{let D=e.sizes[P]*100;return ls(ss.Fragment,{children:[pn("div",{className:"rdd-split-child",style:{flexGrow:e.sizes[P],flexBasis:`${D}%`},children:pn(So,{node:M,path:[...t,P],onTabRightClick:n,activeDropZone:o,onHoverDropZone:r,onTabDragStart:a,hoveredTab:u,onTabHover:s,defaultPanelIcon:d,onRequestClosePanel:C})}),P<e.children.length-1&&pn("div",{onPointerDown:p=>m(P,p),className:`rdd-resizer-bar ${y?"rdd-resizer-bar--vertical":"rdd-resizer-bar--horizontal"}`})]},P)})})};import"react";import{Fragment as Gr,jsx as qt,jsxs as Yr}from"react/jsx-runtime";var Kr=({state:e,activeEdgeDrop:t,activeCornerAnchor:n,setActiveEdgeDrop:o,setActiveCornerAnchor:r})=>Yr(Gr,{children:[e.draggedPanelId!==null&&Yr(Gr,{children:[qt("div",{"data-edge-trigger":"left",className:"rdd-workspace-edge-trigger rdd-edge-trigger-left",onPointerEnter:()=>o("left"),onPointerLeave:()=>o(null)}),qt("div",{"data-edge-trigger":"right",className:"rdd-workspace-edge-trigger rdd-edge-trigger-right",onPointerEnter:()=>o("right"),onPointerLeave:()=>o(null)}),qt("div",{"data-edge-trigger":"top",className:"rdd-workspace-edge-trigger rdd-edge-trigger-top",onPointerEnter:()=>o("top"),onPointerLeave:()=>o(null)}),qt("div",{"data-edge-trigger":"bottom",className:"rdd-workspace-edge-trigger rdd-edge-trigger-bottom",onPointerEnter:()=>o("bottom"),onPointerLeave:()=>o(null)})]}),e.draggedPanelId!==null&&["top-left","top-right","bottom-left","bottom-right"].map(a=>qt("div",{className:`rdd-corner-zone rdd-corner-zone--${a}${n===a?" rdd-corner-zone--hovered":""}`,onPointerEnter:()=>{r(a),o(null)},onPointerLeave:()=>r(null),"aria-hidden":"true"},a)),e.draggedPanelId!==null&&t!==null&&qt("div",{className:"rdd-workspace-edge-preview",style:(()=>{let a=`${e.edgeSplitRatio*100}%`;switch(t){case"left":return{left:0,top:0,bottom:0,width:a};case"right":return{right:0,top:0,bottom:0,width:a};case"top":return{top:0,left:0,right:0,height:a};case"bottom":return{bottom:0,left:0,right:0,height:a}}})()})]});import"react";import{Fragment as Xr,jsx as se,jsxs as lt}from"react/jsx-runtime";var Vr=({state:e,registry:t,windowClass:n,windowBodyClass:o,defaultPanelIcon:r,messages:a,formatMessage:u,setActivePanel:s,focusPanel:d,maximizePanel:C,minimizePanel:R,getPanelContextMenuItems:y,showContextMenu:m,handleRequestClose:M,startDrag:P,startResize:D})=>se(Xr,{children:e.floating.map(p=>{let E=e.panels[p.id];if(!E)return null;let I=p.maximized,f=e.draggedPanelId===p.id,k=e.activePanelId===p.id,l=t.get(E.component)?.defaultOptions;return lt("div",{"data-window-id":p.id,"data-rdd-window":p.id,dir:e.dir,onPointerDownCapture:()=>{s(p.id),d(p.id)},className:`rdd-floating-window ${I?"rdd-maximized":""} ${k?"rdd-window-focused":""} ${n??""}`,style:(()=>{let H=typeof p.width=="number"?`${p.width}px`:p.width,S=typeof p.height=="number"?`${p.height}px`:p.height;if(I)return{position:"absolute",left:0,top:0,width:"100%",height:"100%",zIndex:p.z,pointerEvents:f?"none":"auto"};if(p.anchor){let A=e.floating.filter(x=>x.anchor===p.anchor&&!x.maximized),W=A.findIndex(x=>x.id===p.id),N=8;for(let x=0;x<W;x++){let L=typeof A[x].height=="number"?A[x].height:parseFloat(A[x].height);N+=L+8}let w=p.anchor.startsWith("top");return{position:"absolute",[p.anchor.endsWith("-right")?"insetInlineEnd":"insetInlineStart"]:8,[w?"top":"bottom"]:N,width:H,height:S,zIndex:p.z,transition:f?"none":"top 0.2s ease, bottom 0.2s ease",pointerEvents:f?"none":"auto"}}return{position:"absolute",left:typeof p.x=="number"?`${p.x}px`:p.x,top:typeof p.y=="number"?`${p.y}px`:p.y,width:H,height:S,zIndex:p.z,pointerEvents:f?"none":"auto"}})(),children:[lt("div",{className:"rdd-floating-window-frame",children:[lt("div",{onDoubleClick:()=>C(p.id),onPointerDown:g=>{l?.canDrag!==!1&&P(p.id,g)},"data-rdd-titlebar":p.id,className:"rdd-floating-window-titlebar rdd-cursor-move",style:{cursor:I||l?.canDrag===!1?"default":"move"},children:[lt("span",{className:"rdd-floating-window-title",children:[se("span",{className:"rdd-window-title-icon",children:E.icon??(l?.icon||r||jt)}),lt("span",{children:[q(E.title,u),E.dirty?" *":""]})]}),lt("div",{className:"rdd-titlebar-actions",onPointerDown:g=>g.stopPropagation(),children:[l?.renderHeaderActions&&se("div",{className:"rdd-window-header-actions",children:l.renderHeaderActions(p.id)}),y(p.id).length>0&&se("button",{type:"button",className:"rdd-custom-tab-btn rdd-btn-more-actions",title:q(a.moreActions,u),"aria-label":q(a.moreActions,u),onClick:g=>{g.stopPropagation();let F=y(p.id);F.length!==0&&m({event:g,items:F,initialFocus:un(g)})},children:lt("svg",{className:"rdd-svg-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:[se("circle",{cx:"12",cy:"5",r:"2"}),se("circle",{cx:"12",cy:"12",r:"2"}),se("circle",{cx:"12",cy:"19",r:"2"})]})}),se("button",{type:"button",title:I?q(a.restoreSize,u):q(a.maximize,u),onClick:()=>C(p.id),className:"rdd-custom-tab-btn rdd-btn-maximize-tab",children:se("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:se("rect",{x:"4",y:"4",width:"16",height:"16",rx:"1.5"})})}),l?.canMinimize!==!1&&se("button",{type:"button",title:q(a.minimize,u),onClick:()=>R(p.id),className:"rdd-custom-tab-btn rdd-btn-minimize-tab",children:se("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:se("path",{d:"M5 12h14"})})}),l?.canClose!==!1&&se("button",{type:"button",title:q(a.close,u),onClick:()=>M(p.id),className:"rdd-custom-tab-btn rdd-btn-close-tab",children:se("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:se("path",{d:"M18 6L6 18M6 6l12 12"})})})]})]}),se("div",{className:`rdd-floating-window-body${o?` ${o}`:""}`,children:se(Fn,{panelId:p.id},p.id)})]}),!I&<(Xr,{children:[se("div",{onPointerDown:g=>D(p.id,"n",g),className:"rdd-resize-handle rdd-resize-n"}),se("div",{onPointerDown:g=>D(p.id,"ne",g),className:"rdd-resize-handle rdd-resize-ne"}),se("div",{onPointerDown:g=>D(p.id,"e",g),className:"rdd-resize-handle rdd-resize-e"}),se("div",{onPointerDown:g=>D(p.id,"se",g),className:"rdd-resize-handle rdd-resize-se"}),se("div",{onPointerDown:g=>D(p.id,"s",g),className:"rdd-resize-handle rdd-resize-s"}),se("div",{onPointerDown:g=>D(p.id,"sw",g),className:"rdd-resize-handle rdd-resize-sw"}),se("div",{onPointerDown:g=>D(p.id,"w",g),className:"rdd-resize-handle rdd-resize-w"}),se("div",{onPointerDown:g=>D(p.id,"nw",g),className:"rdd-resize-handle rdd-resize-nw"})]})]},p.id)})});import"react";import{createPortal as cs}from"react-dom";import{jsx as Ge,jsxs as Bn}from"react/jsx-runtime";var Zr=({state:e,registry:t,taskbarVisibility:n,taskbarExpanded:o,expandTaskbar:r,leaveTaskbar:a,scrollTaskbar:u,taskbarRef:s,defaultPanelIcon:d,messages:C,formatMessage:R,lastTaskbarPointerTypeRef:y,hoveredMinimized:m,setHoveredMinimized:M,minimizedTooltipTimeoutRef:P,isContextMenuOpen:D,handleMinimizedRightClick:p,handleRequestClose:E,restorePanel:I})=>n==="always"||e.minimized.length>0?Bn("div",{className:["rdd-taskbar-footer-container",`rdd-taskbar-mode-${n}`,n==="autohide"&&o?"rdd-taskbar-expanded":""].filter(Boolean).join(" "),onPointerEnter:n==="autohide"?r:void 0,onPointerLeave:n==="autohide"?a:void 0,children:[n==="autohide"&&Ge("div",{className:"rdd-taskbar-peek-handle"}),Ge("button",{type:"button",onClick:()=>u("left"),className:"rdd-taskbar-nav-btn","aria-label":q(C.scrollTaskbarLeft,R),style:{display:e.minimized.length>4?"block":"none"},children:"\u25C0"}),Ge("div",{ref:s,className:"rdd-taskbar-items-container",children:e.minimized.map(f=>{let k=t.get(f.component),c=e.panels[f.id]?.icon??(k?.defaultOptions?.icon||d||jt);return Ge("button",{type:"button","aria-label":q(f.title,R),onClick:l=>{l.detail!==0&&y.current==="touch"||(M(null),I(f.id))},onContextMenu:l=>p(f.id,l),onKeyDown:l=>{Hn(l)&&(l.preventDefault(),p(f.id,$n(l.currentTarget)))},onPointerDown:l=>{if(y.current=l.pointerType,l.pointerType!=="touch")return;let g=l.currentTarget,F=l.clientX,H=l.clientY,S=l.pointerId,A=!1,W=()=>{A=!0,clearTimeout(h),g.removeEventListener("pointermove",w),g.removeEventListener("pointerup",N),g.removeEventListener("pointercancel",W)},N=()=>{W();let x=g.getBoundingClientRect();m?.id===f.id?(I(f.id),M(null)):M({id:f.id,rect:x,title:f.title,component:f.component,fromTouch:!0})},w=x=>{Math.hypot(x.clientX-F,x.clientY-H)>Tt&&W()},h=setTimeout(()=>{if(A)return;g.removeEventListener("pointermove",w),g.removeEventListener("pointerup",N),g.removeEventListener("pointercancel",W);try{g.setPointerCapture(S)}catch{return}navigator.vibrate&&navigator.vibrate(10);let x=L=>{g.removeEventListener("pointerup",x),g.removeEventListener("pointercancel",x),p(f.id,L)};g.addEventListener("pointerup",x),g.addEventListener("pointercancel",x)},Mt);g.addEventListener("pointermove",w),g.addEventListener("pointerup",N),g.addEventListener("pointercancel",W)},onPointerEnter:l=>{if(l.pointerType==="touch"||D)return;P.current&&clearTimeout(P.current);let g=l.currentTarget.getBoundingClientRect();l.clientX>=g.left&&l.clientX<=g.right&&l.clientY>=g.top&&l.clientY<=g.bottom&&M({id:f.id,rect:g,title:f.title,component:f.component})},onPointerLeave:l=>{l.pointerType!=="touch"&&(P.current=setTimeout(()=>{M(null)},150))},className:"rdd-taskbar-glassmorphic-item","data-rdd-taskbar-item":f.id,children:Ge("span",{className:"rdd-taskbar-item-icon","aria-hidden":"true",children:c})},f.id)})}),m&&cs(Bn("div",{className:"rdd-taskbar-item-tooltip",dir:e.dir,style:{left:`${m.rect.left+m.rect.width/2}px`,top:`${m.rect.top-8}px`},onPointerEnter:()=>{P.current&&clearTimeout(P.current)},onPointerLeave:f=>{f.pointerType!=="touch"&&M(null)},onClick:()=>{I(m.id),M(null)},onContextMenu:f=>p(m.id,f),onPointerDown:f=>{if(f.pointerType!=="touch")return;let k=m.id,c=f.currentTarget,l=f.clientX,g=f.clientY,F=f.pointerId,H=!1,S=()=>{H=!0,clearTimeout(W),c.removeEventListener("pointermove",A),c.removeEventListener("pointerup",S),c.removeEventListener("pointercancel",S)},A=N=>{Math.hypot(N.clientX-l,N.clientY-g)>Tt&&S()},W=setTimeout(()=>{if(H)return;c.removeEventListener("pointermove",A),c.removeEventListener("pointerup",S),c.removeEventListener("pointercancel",S);try{c.setPointerCapture(F)}catch{return}navigator.vibrate&&navigator.vibrate(10);let N=w=>{c.removeEventListener("pointerup",N),c.removeEventListener("pointercancel",N),p(k,w)};c.addEventListener("pointerup",N),c.addEventListener("pointercancel",N)},Mt);c.addEventListener("pointermove",A),c.addEventListener("pointerup",S),c.addEventListener("pointercancel",S)},children:[Bn("div",{className:"rdd-tooltip-header-row",children:[Bn("span",{className:"rdd-tooltip-title-text rdd-text-truncate",children:[q(m.title,R),e.panels[m.id]?.dirty?" *":""]}),Ge("button",{type:"button",onClick:f=>{f.stopPropagation(),E(m.id),M(null)},title:q(C.closePanel,R),"aria-label":q(C.closePanel,R),className:"rdd-tooltip-close-x",children:Ge("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5","aria-hidden":"true",children:Ge("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),Ge(zr,{panelId:m.id})]}),document.body),Ge("button",{type:"button",onClick:()=>u("right"),className:"rdd-taskbar-nav-btn","aria-label":q(C.scrollTaskbarRight,R),style:{display:e.minimized.length>4?"block":"none"},children:"\u25B6"})]}):null;import{useState as fn,useRef as Gn}from"react";function jr({setDraggedPanelId:e,isRtl:t}){let[n,o]=fn(null),r=Gn(null),[a,u]=fn({x:0,y:0}),[s,d]=fn(null),C=Gn(null),R=g=>{d(g),C.current=g},[y,m]=fn(null),M=Gn(null),P=g=>{m(g),M.current=g},[D,p]=fn(null),E=Gn(null);return{activeDropZone:n,setActiveDropZone:o,activeDropZoneRef:r,dragPos:a,setDragPos:u,activeEdgeDrop:s,activeEdgeDropRef:C,setActiveEdgeDrop:R,activeCornerAnchor:y,activeCornerAnchorRef:M,setActiveCornerAnchor:P,hoveredTab:D,setHoveredTab:p,hoveredTabRef:E,handleTabHover:(g,F,H,S)=>{let A=S?{leafId:g,panelId:F,index:H,side:S}:null;p(A),E.current=A},handleHoverDropZone:(g,F)=>{let H=F?{leafId:g,position:F}:null;o(H),r.current=H,H&&(R(null),P(null))},updateHoverFromPoint:(g,F)=>{let H=document.elementsFromPoint(g,F),S=!1,A=!1,W=!1;for(let N of H)if(N instanceof HTMLElement){if(!S&&N.dataset.dropZone){let w=N.dataset.leafId;if(w){let h=N.dataset.dropZone;o({leafId:w,position:h}),r.current={leafId:w,position:h},S=!0}}if(!W&&N.dataset.tabId){let w=N.dataset.leafId,h=parseInt(N.dataset.tabIndex||"0",10);if(w){let x=_n(N,g);p({leafId:w,panelId:N.dataset.tabId,index:h,side:x}),E.current={leafId:w,panelId:N.dataset.tabId,index:h,side:x},W=!0}}if(!A&&N.dataset.edgeTrigger&&(R(N.dataset.edgeTrigger),A=!0),S&&A&&W)break}S||(o(null),r.current=null),A||R(null),W||(p(null),E.current=null)},clearDragState:()=>{e(null),o(null),r.current=null,p(null),E.current=null,R(null),P(null)},flipRtl:g=>t?g==="left"?"right":g==="right"?"left":g:g}}import"react";function qr(e){let{state:t,handleTabRightClick:n}=e,{activeDropZoneRef:o,hoveredTabRef:r,activeEdgeDropRef:a,activeCornerAnchorRef:u,setActiveCornerAnchor:s,clearDragState:d,flipRtl:C,setDragPos:R,updateHoverFromPoint:y}=e.targets,{dockPanelToWorkspaceEdge:m,movePanelOrder:M,dockPanelToGroup:P,floatPanel:D,setDraggedPanelId:p}=e.actions,E=(f,k)=>{let c=o.current,l=r.current,g=a.current,F=u.current;if(g)m(f,C(g));else if(l){let H=l.index;l.side==="right"&&(H+=1);let S=Mo(t.gridRoot,l.leafId);if(S){let A=S.panels.indexOf(f);A!==-1&&A<H&&(H-=1)}M(f,l.leafId,H)}else c?P(f,c.leafId,C(c.position)):F?D(f,void 0,F):D(f,{x:k.clientX-150,y:k.clientY-15,width:450,height:350});s(null),d()};return{executeDrop:E,handleTabDragStart:(f,k)=>{if(k.pointerType==="mouse"&&k.button!==0)return;k.preventDefault();let c=k.currentTarget,l=k.clientX,g=k.clientY;if(k.pointerType==="touch"){let F=k.pointerId,H=!1,S=()=>{H=!0,clearTimeout(W),c.removeEventListener("pointermove",A),c.removeEventListener("pointerup",S),c.removeEventListener("pointercancel",S)},A=N=>{Math.hypot(N.clientX-l,N.clientY-g)>Tt&&S()},W=setTimeout(()=>{if(H)return;c.removeEventListener("pointermove",A),c.removeEventListener("pointerup",S),c.removeEventListener("pointercancel",S);try{c.setPointerCapture(F)}catch{return}c.classList.add("rdd-long-press-active"),document.body.classList.add("rdd-dragging-active"),navigator.vibrate&&navigator.vibrate(10);let N=!1,w=L=>{N||(N=!0,p(f)),R({x:L.clientX,y:L.clientY}),y(L.clientX,L.clientY)},h=L=>{c.classList.remove("rdd-long-press-active"),document.body.classList.remove("rdd-dragging-active"),c.removeEventListener("pointermove",w),c.removeEventListener("pointerup",h),c.removeEventListener("pointercancel",x),window.removeEventListener("blur",x),N?E(f,L):n(f,L)},x=()=>{c.classList.remove("rdd-long-press-active"),document.body.classList.remove("rdd-dragging-active"),c.removeEventListener("pointermove",w),c.removeEventListener("pointerup",h),c.removeEventListener("pointercancel",x),window.removeEventListener("blur",x),N&&d()};c.addEventListener("pointermove",w),c.addEventListener("pointerup",h),c.addEventListener("pointercancel",x),window.addEventListener("blur",x)},Mt);c.addEventListener("pointermove",A),c.addEventListener("pointerup",S),c.addEventListener("pointercancel",S)}else{let F=!1,H=W=>{let N=W.clientX-l,w=W.clientY-g;!F&&(Math.abs(N)>5||Math.abs(w)>5)&&(F=!0,p(f)),F&&R({x:W.clientX,y:W.clientY})},S=W=>{document.body.classList.remove("rdd-dragging-active"),window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",A),window.removeEventListener("blur",A),F&&E(f,W)},A=()=>{document.body.classList.remove("rdd-dragging-active"),window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",A),window.removeEventListener("blur",A),F&&d()};document.body.classList.add("rdd-dragging-active"),window.addEventListener("pointermove",H),window.addEventListener("pointerup",S),window.addEventListener("pointercancel",A),window.addEventListener("blur",A)}}}}import"react";function Ur(e){let{state:t,registry:n,messages:o,formatMessage:r,handleRequestClose:a,setHoveredMinimized:u}=e,{floatPanel:s,minimizePanel:d,restorePanel:C,maximizePanel:R,getPanelContextMenuItems:y,showContextMenu:m}=e.actions;return{handleTabRightClick:(D,p)=>{p.preventDefault();let E=t.panels[D];if(!E)return;let f=n.get(E.component)?.defaultOptions,k=[];if(f?.canDrag!==!1&&k.push({label:q(o.floatWindow,r),icon:St.float,action:()=>s(D)}),f?.canMinimize!==!1&&k.push({label:q(o.minimizePanel,r),icon:St.minimize,action:()=>d(D)}),k.length>0&&f?.canClose!==!1&&k.push({separator:!0}),f?.canClose!==!1&&k.push({label:q(o.closeTab,r),icon:St.close,action:()=>a(D)}),k.length===0)return;let c=y(D),l=c.length>0?[...k,{separator:!0},...c]:k;m({event:p,items:l,initialFocus:un(p)})},handleMinimizedRightClick:(D,p)=>{p.preventDefault(),u(null);let E=t.panels[D],I=E?.previousState==="floating"||n.get(E?.component??"")?.defaultOptions?.canDrag!==!1;m({event:p,initialFocus:un(p),items:[{label:q(o.restorePanel,r),icon:St.restore,action:()=>C(D)},...I?[{label:q(o.maximizePanel,r),icon:St.maximize,action:()=>R(D)}]:[],{separator:!0},{label:q(o.closePanel,r),icon:St.close,action:()=>a(D)}]})}}}import{useState as ds,useEffect as us}from"react";function Jr(e){let[t,n]=ds({width:1024,height:768});return us(()=>{let o=e.current;if(!o)return;let r=!1,a=!1,u=new ResizeObserver(s=>{if(!s||s.length===0)return;let d=s[0].contentRect;if(process.env.NODE_ENV==="development"&&d.height<10&&!r){r=!0;let C=o,R=o.parentElement;for(;R&&R!==document.documentElement&&R.getBoundingClientRect().height<10;){C=R;R=R.parentElement}let y=C.tagName.toLowerCase(),m=C.id?` id="${C.id}"`:"",M=C.className?` class="${C.className}"`:"",P=C===o?"the RddDesktop container itself":`a wrapper element: <${y}${m}${M}>`;console.warn(`[react-dockable-desktop] Workspace height is 0px \u2014 the workspace will be invisible.
|
|
4
|
+
Without it the workspace renders as a black screen with no console errors.`)}catch{}},[]);let a=go(()=>({getSnapshot:f.getSnapshot,subscribeToState:f.subscribeToState}),[f]);return Pt(pr.Provider,{value:c,children:Pt(fr.Provider,{value:P,children:Pt(Sn.Provider,{value:a,children:Pt(it.Provider,{value:b,children:Pt(Tn.Provider,{value:I,children:Pt(dr.Provider,{value:h||Rn,children:Pt(ur.Provider,{value:m,children:e})})})})})})})},ar=e=>()=>{};function we(e){let t=Ze(it),n=Ze(Sn),o=lr(e);o.current=e;let r=cr(e?n?.subscribeToState??ar:ar,()=>{let i=n?.getSnapshot()??t;return o.current?o.current(i):i},()=>{let i=n?.getSnapshot()??t;return o.current?o.current(i):i});if(!t)throw new Error("useWorkspaceState must be used within <DockableDesktopProvider>");return e?r:t}var En=()=>{let e=Ze(Tn);if(!e)throw new Error("useWorkspace must be used within <DockableDesktopProvider>");return e},In=()=>{let e=Ze(Tn);if(!e)throw new Error("react-dockable-desktop components must be used within <DockableDesktopProvider>");return e},pe=()=>Ze(dr)||Rn;var ae=()=>Ze(ur),ho=()=>De().instanceId;function Ui(e){let t=Ze(Tn),n=ho(),o=lr(e);o.current=e,Mn(()=>{if(!(!t?.registerPanelContextMenu||!n))return t.registerPanelContextMenu(n,()=>o.current)},[n,t?.registerPanelContextMenu])}var Gt=class e{registry;initialState;config;_core;get _actions(){return this._core.actions}constructor(t={}){if(this.registry=new At,this.initialState=t.initialState??null,this.config={formatMessage:t.formatMessage,predefinedMessages:t.predefinedMessages,dir:t.dir,defaultSplitRatio:t.defaultSplitRatio,defaultEdgeSplitRatio:t.defaultEdgeSplitRatio,zIndexBase:t.zIndexBase},t.panels)for(let[n,o]of Object.entries(t.panels))this.registry.register(n,o.component,o.defaultOptions);for(let n of Object.getOwnPropertyNames(e.prototype)){let o=Object.getOwnPropertyDescriptor(e.prototype,n);n==="constructor"||!o||typeof o.value!="function"||(this[n]=o.value.bind(this))}this._core=on({registry:this.registry,initialState:this.initialState,dir:t.dir,zIndexBase:t.zIndexBase,defaultSplitRatio:t.defaultSplitRatio,defaultEdgeSplitRatio:t.defaultEdgeSplitRatio})}_dispatch(t){t(this._actions)}_subscribeRaw(t,n){return this._actions.subscribe(t,n)}openPanel(...t){this._actions.openPanel(...t)}closePanel(t){this._dispatch(n=>n.closePanel(t))}minimizePanel(t){this._dispatch(n=>n.minimizePanel(t))}restorePanel(...t){this._dispatch(n=>n.restorePanel(...t))}floatPanel(...t){this._dispatch(n=>n.floatPanel(...t))}dockPanel(...t){this._dispatch(n=>n.dockPanel(...t))}maximizePanel(t){this._dispatch(n=>n.maximizePanel(t))}focusPanel(t){this._dispatch(n=>n.focusPanel(t))}isOpen(t){return this._actions.isOpen(t)}getOpenPanelIds(){return this._actions.getOpenPanelIds()}findPanelId(t,n){return this._actions.findPanelId(t,n)}saveLayout(){return this._actions.saveLayout()}loadLayout(t){return this._actions.loadLayout(t)}setDirection(t){this._dispatch(n=>n.setDirection(t))}updateSplitSizes(t,n){this._dispatch(o=>o.updateSplitSizes(t,n))}updateFloatingPosition(t,n){this._dispatch(o=>o.updateFloatingPosition(t,n))}setDraggedPanelId(t){this._dispatch(n=>n.setDraggedPanelId(t))}dockPanelToGroup(t,n,o){this._dispatch(r=>r.dockPanelToGroup(t,n,o))}movePanelOrder(t,n,o){this._dispatch(r=>r.movePanelOrder(t,n,o))}closeLeafGroup(t,n){return this._actions.closeLeafGroup(t,n)}registerCloseGuard(t,n){this._dispatch(o=>o.registerCloseGuard(t,n))}unregisterCloseGuard(t){this._dispatch(n=>n.unregisterCloseGuard(t))}registerStateProvider(t,n){this._dispatch(o=>o.registerStateProvider(t,n))}unregisterStateProvider(t){this._dispatch(n=>n.unregisterStateProvider(t))}setPanelDirty(t,n,o){this._dispatch(r=>r.setPanelDirty(t,n,o))}updatePanelTitle(t,n){this._dispatch(o=>o.updatePanelTitle(t,n))}setPanelIcon(t,n){this._dispatch(o=>o.setPanelIcon(t,n))}requestClosePanel(t,n){return this._actions.requestClosePanel(t,n)}dockPanelToWorkspaceEdge(t,n){this._dispatch(o=>o.dockPanelToWorkspaceEdge(t,n))}showContextMenu(t){this._dispatch(n=>n.showContextMenu(t))}publish(t,n){this._dispatch(o=>o.publish(t,n))}subscribe(t,n){return this._subscribeRaw(t,n)}onPanelOpen(t){return this._subscribeRaw("panel:opened",n=>{let o=n;t(o.id,o.component)})}onPanelClose(t){return this._subscribeRaw("panel:closed",n=>{t(n.id)})}onPanelMinimize(t){return this._subscribeRaw("panel:minimized",n=>{t(n.id)})}onPanelRestore(t){return this._subscribeRaw("panel:restored",n=>{t(n.id)})}onLayoutChanged(t){return this._subscribeRaw("layout:changed",()=>t())}onPanelsExcluded(t){return this._subscribeRaw("layout:panels-excluded",n=>{t(n.panels)})}};import{createContext as Ji}from"react";var Dn=Ji(null);import{createContext as vr,useContext as yr,useState as Qi,useCallback as Te,useMemo as es,useRef as gr}from"react";import{jsx as br}from"react/jsx-runtime";var ts=0,bo=()=>`panel-${++ts}-${Date.now()}`,Ln=new Map;function ns(e,t){if("props"in t&&t.props!==e.props||"dirty"in t&&!!t.dirty!=!!e.dirty||"dirtyOptions"in t&&!Cn(t.dirtyOptions,e.dirtyOptions))return!1;if("options"in t&&t.options!==e.options){let n=t.options,o=e.options,r=new Set([...Object.keys(n),...Object.keys(o)]);for(let i of r)if(i==="title"?!tn(n[i],o[i]):n[i]!==o[i])return!1}return!0}var hr={leftPanel:null,rightPanel:null,modals:[]},Pr=vr(null),xr=vr(null),Rr=({children:e})=>{let[t,n]=Qi(hr),o=ae().modalTitle,r=gr(t);r.current=t;let i=gr(new Map),u=Te((m,c)=>{let a=i.current;return a.has(m)||a.set(m,new Set),a.get(m).add(c),()=>{a.get(m)?.delete(c)}},[]),l=Te(m=>{for(let c of m){if(!c)continue;let a=i.current.get(c);i.current.delete(c),a?.forEach(p=>p())}},[]),d=Te((m,c)=>{Ln.set(m,c)},[]),R=Te(m=>{Ln.delete(m)},[]),w=Te(async(m,c,a={})=>{let p=r.current.leftPanel;if(p){let M=Ln.get(p.id);if(M&&!await M())return null}let D=bo(),_={id:D,Component:m,props:c,containerType:"left-panel",options:a};return n(M=>({...M,leftPanel:_})),l([p?.id]),D},[l]),C=Te(async(m,c,a={})=>{let p=r.current.rightPanel;if(p){let M=Ln.get(p.id);if(M&&!await M())return null}let D=bo(),_={id:D,Component:m,props:c,containerType:"right-panel",options:a};return n(M=>({...M,rightPanel:_})),l([p?.id]),D},[l]),f=Te((m,c,a={})=>{let p=bo(),D=c.title,_={...a,title:a.title||D||o},M={id:p,Component:m,props:c,containerType:"modal",options:_};return n(A=>({...A,modals:[...A.modals,M]})),p},[o]),P=Te(m=>{n(c=>({leftPanel:c.leftPanel?.id===m?null:c.leftPanel,rightPanel:c.rightPanel?.id===m?null:c.rightPanel,modals:c.modals.filter(a=>a.id!==m)})),l([m])},[l]),b=Te(()=>{let{leftPanel:m,rightPanel:c,modals:a}=r.current;n(hr),l([m?.id,c?.id,...a.map(p=>p.id)])},[l]),I=Te(()=>{let{modals:m}=r.current;n(c=>({...c,modals:[]})),l(m.map(c=>c.id))},[l]),h=Te(m=>t.leftPanel?.id===m?t.leftPanel:t.rightPanel?.id===m?t.rightPanel:t.modals.find(c=>c.id===m),[t]),E=Te((m,c)=>{n(a=>{let p=a.leftPanel?.id===m?a.leftPanel:a.rightPanel?.id===m?a.rightPanel:a.modals.find(D=>D.id===m);return!p||ns(p,c)?a:{leftPanel:a.leftPanel?.id===m?{...a.leftPanel,...c}:a.leftPanel,rightPanel:a.rightPanel?.id===m?{...a.rightPanel,...c}:a.rightPanel,modals:a.modals.map(D=>D.id===m?{...D,...c}:D)}})},[]),N=Te((m,c,a)=>{E(m,{dirty:c,dirtyOptions:a})},[E]),x=es(()=>({openLeftPanel:w,openRightPanel:C,openModal:f,close:P,closeAll:b,closeAllModals:I,getInstance:h,updateInstance:E,setDirty:N,registerCloseHandler:d,unregisterCloseHandler:R,onInstanceClose:u}),[w,C,f,P,b,I,h,E,N,d,R,u]);return br(Pr.Provider,{value:t,children:br(xr.Provider,{value:x,children:e})})},qe=()=>{let e=yr(Pr);if(!e)throw new Error("useModals / useSidePanels must be used within <DockableDesktopProvider>");return e},Ue=()=>{let e=yr(xr);if(!e)throw new Error("useModals / useSidePanels must be used within <DockableDesktopProvider>");return e};import{useCallback as Ct,useRef as yo,useEffect as bs,useState as vs,useMemo as ys}from"react";import{useEffect as vo,useRef as Nn}from"react";import"react";import{jsx as Le,jsxs as rn}from"react/jsx-runtime";var os=()=>rn("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[Le("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),Le("path",{d:"M6.25 6.25a1.75 1.75 0 1 1 2.6 1.53c-.5.28-.85.7-.85 1.27v.2M8 11.25v.01",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),rs=()=>rn("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[Le("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),Le("path",{d:"M8 5v.01M8 7.5v3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),is=()=>rn("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[Le("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),Le("path",{d:"M5 8l2 2 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),ss=()=>rn("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[Le("path",{d:"M8 2.5L14 13.5H2L8 2.5z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),Le("path",{d:"M8 7v2.5M8 11.5v.01",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),as=()=>rn("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[Le("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),Le("path",{d:"M5.5 5.5l5 5M10.5 5.5l-5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),ls={info:rs,success:is,warning:ss,danger:as},On=({icon:e,type:t,question:n})=>{if(e===null)return null;let o=n?os:ls[t];return Le("div",{className:`rdd-dialog-icon rdd-dialog-icon-${t}`,"data-rdd-dialog-icon":e===void 0?"default":"custom",children:e===void 0?Le(o,{}):e})};import{jsx as Rt,jsxs as Wn}from"react/jsx-runtime";var cs=({title:e,message:t,alert:n,alertType:o="info",useYesNoTitles:r=!1,onOK:i,onCancel:u,onSettled:l,icon:d})=>{let{requestClose:R,setTitle:w,onClose:C}=De(),f=pe(),P=ae(),b=Nn(null),I=Nn(!1),h=Nn(l);h.current=l;let E=D=>{I.current||(I.current=!0,h.current?.(D))},N=Nn(E);N.current=E,vo(()=>C?.(()=>N.current(!1)),[C]),vo(()=>{if(e){let D=typeof e=="string"?e:typeof e=="function"?e():f(e);w(D)}},[e,w,f]),vo(()=>{b.current?.focus({preventScroll:!0})},[]);let x=typeof t=="string"?t:f(t),m=f(r?P.no:P.cancel),c=f(r?P.yes:P.ok),a=D=>{D.preventDefault(),E(!0),i?.(),R()},p=()=>{E(!1),u?.(),R()};return Wn("form",{onSubmit:a,className:"rdd-confirmation-form-body",children:[n&&Wn("div",{className:`rdd-confirmation-alert rdd-confirmation-alert-${o}`,children:[Rt("span",{children:"\u2139\uFE0F"}),Rt("span",{children:n})]}),Wn("div",{className:"rdd-dialog-content",children:[Rt(On,{icon:d,type:o,question:!0}),Rt("div",{className:"rdd-confirmation-message",children:x})]}),Rt("hr",{className:"rdd-confirmation-divider"}),Wn("div",{className:"rdd-confirmation-actions",children:[Rt("button",{type:"button",className:"rdd-btn rdd-btn-sm rdd-btn-outline",onClick:p,"data-rdd-confirm-cancel":!0,children:m}),Rt("button",{type:"submit",className:"rdd-btn rdd-btn-sm rdd-btn-primary",ref:b,"data-rdd-confirm-ok":!0,children:c})]})]})},Je=cs;import{useEffect as ds,useLayoutEffect as us,useRef as ps}from"react";var Cr={drawer:1,modal:2,popup:3},st=[],fs=0;function wr(e){if(e.key!=="Escape"||e.defaultPrevented||st.length===0)return;let t=st[0];for(let n of st){let o=Cr[n.layer]-Cr[t.layer];(o>0||o===0&&n.order>t.order)&&(t=n)}e.preventDefault(),t.onEscape()}function ms(e,t){let n={layer:e,order:fs++,onEscape:t};return st.push(n),st.length===1&&document.addEventListener("keydown",wr),()=>{let o=st.indexOf(n);o!==-1&&(st.splice(o,1),st.length===0&&document.removeEventListener("keydown",wr))}}function at(e,t,n){let o=ps(n);us(()=>{o.current=n}),ds(()=>{if(e)return ms(t,()=>o.current())},[e,t])}import{useLayoutEffect as gs,useState as hs}from"react";function kr(e){let[t,n]=hs(null);return gs(()=>{let o=e.current?.parentElement;if(!o)return;let r=()=>{let u=o.getBoundingClientRect();n({top:u.top,left:u.left,right:window.innerWidth-u.right,height:u.height})};r();let i=new ResizeObserver(r);return i.observe(o),window.addEventListener("resize",r),()=>{i.disconnect(),window.removeEventListener("resize",r)}},[e]),t}import{Fragment as xs,jsx as Pe,jsxs as Po}from"react/jsx-runtime";var An=({panel:e,position:t,defaultWidth:n,containerRect:o})=>{let{close:r,openModal:i,updateInstance:u,setDirty:l,registerCloseHandler:d,unregisterCloseHandler:R,onInstanceClose:w}=Ue(),C=pe(),f=ae(),{dir:P}=we(),{sidePanelClass:b,sidePanelBodyClass:I}=je(),h=yo(null),{id:E,Component:N,props:x,options:m,dirty:c,dirtyOptions:a}=e,p=m,[D,_]=vs(p.icon||null),M=yo(p);M.current=p;let A=q(p.title,C),z=Ct(async re=>{if(re?.force){r(E);return}if(h.current){if(!await h.current())return;r(E);return}if(c){i(Je,{title:a?.title||f.unsavedChangesTitle,message:a?.message||{id:f.unsavedChangesMessage.id,defaultMessage:f.unsavedChangesMessage.defaultMessage,values:{title:A}},alert:a?.alert,alertType:a?.alertType||"danger",useYesNoTitles:!0,onOK:()=>r(E)},{size:"small"});return}r(E)},[r,i,E,c,a,A,f]),W=Ct(async()=>h.current?await h.current():!c,[c]);bs(()=>(d(E,W),()=>R(E)),[E,W,d,R]);let T=Ct((re,Re)=>l(E,re,Re),[l,E]),v=Ct(re=>u(E,{options:{...M.current,title:re}}),[u,E]),k=Ct(re=>_(re),[]),L=Ct(re=>(h.current=re,()=>{h.current=null}),[]),H=Ct(re=>w(E,re),[w,E]),Y=ys(()=>({requestClose:z,setDirty:T,setTitle:v,setIcon:k,onCloseRequested:L,containerType:t==="left"?"left-panel":"right-panel",instanceId:E,onClose:H}),[z,H,T,v,k,L,t,E]),U=c?`${A} *`:A;at(!0,"drawer",z);let K=p.width||n||400,oe=typeof K=="number"?`${K}px`:K,le=p.bodyPadding,te=le!=null?typeof le=="number"?`${le}px`:le:void 0;return Pe("div",{className:`rdd-side-panel rdd-side-panel-${t} rdd-side-panel-visible ${b??""}`,style:{width:oe,...o?{top:o.top,height:o.height,bottom:"auto",...t==="right"?{right:o.right}:{left:o.left}}:{}},dir:P,children:Po("div",{className:"rdd-side-panel-window",children:[Po("div",{className:"rdd-side-panel-header",children:[D&&Pe("div",{className:"rdd-side-panel-icon",children:D}),Pe("h4",{className:"rdd-side-panel-title",children:U}),Pe("button",{className:"rdd-side-panel-close-button",onClick:()=>z(),title:C(f.closeTooltip),type:"button",children:Pe("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:Pe("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),Pe("div",{className:`rdd-side-panel-body ${I??""}`,style:te!=null?{padding:te}:void 0,children:Pe(zt,{value:Y,children:Pe(N,{...x,panelId:E})})})]})})},xo=({children:e})=>{let t=yo(null),n=kr(t);return Pe("div",{ref:t,className:"rdd-side-panel-anchor",children:e(n)})},Ps=({defaultWidth:e})=>{let{leftPanel:t,rightPanel:n}=qe();return Pe(xo,{children:o=>Po(xs,{children:[t&&Pe(An,{panel:t,position:"left",defaultWidth:e,containerRect:o},t.id),n&&Pe(An,{panel:n,position:"right",defaultWidth:e,containerRect:o},n.id)]})})},Mr=({defaultWidth:e})=>{let{leftPanel:t}=qe();return Pe(xo,{children:n=>t?Pe(An,{panel:t,position:"left",defaultWidth:e,containerRect:n},t.id):null})},Tr=({defaultWidth:e})=>{let{rightPanel:t}=qe();return Pe(xo,{children:n=>t?Pe(An,{panel:t,position:"right",defaultWidth:e,containerRect:n},t.id):null})},Sr=Ps;import{useEffect as Ro,useRef as zn}from"react";import{jsx as sn,jsxs as Er}from"react/jsx-runtime";var Rs=({title:e,message:t,alertType:n="info",icon:o,okLabel:r,onSettled:i})=>{let{requestClose:u,setTitle:l,onClose:d}=De(),R=pe(),w=ae(),C=zn(null),f=zn(!1),P=zn(i);P.current=i;let b=()=>{f.current||(f.current=!0,P.current?.())},I=zn(b);I.current=b,Ro(()=>d?.(()=>I.current()),[d]),Ro(()=>{if(e){let x=typeof e=="string"?e:typeof e=="function"?e():R(e);l(x)}},[e,l,R]),Ro(()=>{C.current?.focus({preventScroll:!0})},[]);let h=typeof t=="string"?t:R(t),E=r===void 0?R(w.ok):typeof r=="string"?r:R(r);return Er("form",{onSubmit:x=>{x.preventDefault(),b(),u({force:!0})},className:"rdd-confirmation-form-body",children:[Er("div",{className:"rdd-dialog-content",children:[sn(On,{icon:o,type:n}),sn("div",{className:"rdd-confirmation-message",children:h})]}),sn("hr",{className:"rdd-confirmation-divider"}),sn("div",{className:"rdd-confirmation-actions",children:sn("button",{type:"submit",className:"rdd-btn rdd-btn-sm rdd-btn-primary",ref:C,"data-rdd-alert-ok":!0,children:E})})]})},Co=Rs;import cn,{forwardRef as Dr,useImperativeHandle as ws,useState as wo,useRef as wt,useEffect as ks,useLayoutEffect as Fn}from"react";import{createPortal as Lr}from"react-dom";function Cs(e){if(!e)return typeof document<"u"?document.documentElement.dir?.toLowerCase()==="rtl"||document.body.dir?.toLowerCase()==="rtl":!1;let t=e.closest("[dir]");return t?t.getAttribute("dir")?.toLowerCase()==="rtl":document.documentElement.dir?.toLowerCase()==="rtl"||document.body.dir?.toLowerCase()==="rtl"}function xe(e){return!e||typeof getComputedStyle>"u"?!1:getComputedStyle(e).direction==="rtl"}var Yt=e=>e?Array.from(e.querySelectorAll(':scope > [role^="menuitem"]:not(:disabled)')):[];function an(e,t){let n=Yt(e);if(n.length===0)return!1;let o=n.indexOf(document.activeElement),r;return t==="ArrowDown"?r=n[(o+1)%n.length]:t==="ArrowUp"?r=n[o<0?n.length-1:(o-1+n.length)%n.length]:t==="Home"?r=n[0]:t==="End"&&(r=n[n.length-1]),r?(r.focus(),!0):!1}import{Fragment as Is,jsx as ge,jsxs as kt}from"react/jsx-runtime";function Ms(e){if(!e||"touches"in e)return!1;let t=e;return t.clientX===0&&t.clientY===0}function Ts(e){if(!e)return{x:0,y:0};if("touches"in e&&e.touches.length>0)return{x:e.touches[0].clientX,y:e.touches[0].clientY};let t=e;if(t.clientX===0&&t.clientY===0&&t.target instanceof Element){let n=t.target.getBoundingClientRect();if(n.width||n.height)return{x:n.left,y:n.bottom}}return{x:t.clientX,y:t.clientY}}function Kt(e,t){return typeof e=="string"?e:t?t(e):e.defaultMessage??e.id}function ko(e){return"separator"in e}function ln(e){return!ko(e)&&"items"in e}var Or=Dr(({items:e,getAnchor:t,autoFocus:n,onBack:o,theme:r,dir:i,fmt:u,onClose:l,onMouseEnter:d,onMouseLeave:R},w)=>{Fn(()=>{let f=w?.current,P=t();if(!f||!P)return;let b=8,I=2,h=f.offsetWidth,E=f.offsetHeight,N=P.menuRight+I,x=P.menuLeft-I-h,m=N+h<=window.innerWidth-b,c=x>=b,a;P.rtl?a=c||!m?x:N:a=m||!c?N:x,a=Math.max(b,Math.min(a,window.innerWidth-h-b));let p=Math.max(b,Math.min(P.top,window.innerHeight-E-b));f.style.left=`${a}px`,f.style.top=`${p}px`}),Fn(()=>{n&&Yt(w?.current)[0]?.focus()},[n,w]);let C=f=>{let P=t()?.rtl?"ArrowRight":"ArrowLeft";if(f.key===P){f.preventDefault(),f.stopPropagation(),o();return}if(f.key==="Tab"){f.preventDefault(),f.stopPropagation(),l();return}an(f.currentTarget,f.key)&&(f.preventDefault(),f.stopPropagation())};return Lr(ge("div",{ref:w,className:`rdd-context-menu rdd-context-menu--${r} rdd-context-menu--submenu`,dir:i,role:"menu",tabIndex:-1,onKeyDown:C,onMouseEnter:d,onMouseLeave:R,children:e.map((f,P)=>{if(ko(f))return ge("hr",{className:"rdd-context-menu__separator",role:"separator"},P);let b=f,I=b.checkbox&&b.checkbox.active!==!1,h=I&&b.checkbox.value,E=b.disabled===!0||(I?b.checkbox.enabled===!1:!1);return kt("button",{type:"button",className:`rdd-context-menu__item${E?" rdd-context-menu__item--disabled":""}`,title:b.title?Kt(b.title,u):void 0,disabled:E,"data-cy-action":b.cyAction,onClick:()=>{E||(b.action?.(),l())},role:I?"menuitemcheckbox":"menuitem","aria-checked":I?h:void 0,children:[b.icon?ge("span",{className:"rdd-context-menu__icon",children:b.icon}):ge("span",{className:"rdd-context-menu__icon","aria-hidden":"true"}),ge("span",{className:"rdd-context-menu__label",children:Kt(b.label,u)}),I&&ge("span",{className:`rdd-context-menu__checkbox${h?" rdd-context-menu__checkbox--checked":""}`,"aria-hidden":"true",children:kt("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[ge("rect",{x:"0.75",y:"0.75",width:"10.5",height:"10.5",rx:"2",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),h&&ge("path",{d:"M2.5 6 L4.5 8.5 L9.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})]},P)})}),document.body)});Or.displayName="ContextMenuSubMenuPanel";var Ir={visible:!1,x:0,y:0,items:[],dir:"ltr",initialFocus:"menu"};function Ss(e,t){let n=e?.target;return n instanceof Element?xe(n)?"rtl":"ltr":t||(xe(document.documentElement)?"rtl":"ltr")}var _n=Dr(({theme:e="dark",formatMessageProvider:t,onShow:n,onHide:o,onOpenChange:r,className:i,style:u},l)=>{let[d,R]=wo(Ir),[w,C]=wo(null),[f,P]=wo(!1),b=wt(null),I=wt(null),h=wt(!1),E=wt(null),N=wt(new Map),x=wt({open:null,close:null}),m=cn.useCallback(()=>{let T=document.activeElement;h.current=!!T&&(!!b.current?.contains(T)||!!E.current?.contains(T)),R(Ir),C(null),x.current.open&&clearTimeout(x.current.open),x.current.close&&clearTimeout(x.current.close),x.current.open=null,x.current.close=null,o?.(),r?.(!1)},[o,r]);if(ws(l,()=>({show({event:T,x:v,y:k,items:L,dir:H,initialFocus:Y}){let U=T?Ts(T):{x:v??0,y:k??0};I.current=document.activeElement instanceof HTMLElement&&document.activeElement!==document.body?document.activeElement:null,N.current.clear(),R({visible:!0,x:U.x,y:U.y,items:L,dir:Ss(T,H),initialFocus:Y??(Ms(T)?"first-item":"menu")}),C(null),P(!1),n?.(),r?.(!0)}}),[n,r]),Fn(()=>{if(d.visible){d.initialFocus==="first-item"?Yt(b.current)[0]?.focus():b.current?.focus({preventScroll:!0});return}if(!h.current)return;h.current=!1;let T=I.current,v=document.activeElement;T?.isConnected&&(!v||v===document.body)&&T.focus()},[d.visible,d.items,d.initialFocus]),ks(()=>{if(!d.visible)return;let T=v=>{if(!(v.target instanceof Node)){m();return}b.current?.contains(v.target)||E.current?.contains(v.target)||m()};return document.addEventListener("pointerdown",T,{capture:!0}),window.addEventListener("click",T),()=>{document.removeEventListener("pointerdown",T,{capture:!0}),window.removeEventListener("click",T)}},[d.visible,m]),at(d.visible,"popup",m),Fn(()=>{if(!d.visible||!b.current)return;let T=b.current,v=T.getBoundingClientRect(),k=8;v.right>window.innerWidth-k&&(T.style.left=`${Math.max(k,window.innerWidth-v.width-k)}px`),v.bottom>window.innerHeight-k&&(T.style.top=`${Math.max(k,window.innerHeight-v.height-k)}px`),v.left<k&&(T.style.left=`${k}px`),v.top<k&&(T.style.top=`${k}px`)},[d.visible]),!d.visible)return null;let c=t,a=()=>{let T=w===null?null:N.current.get(w),v=b.current;if(!T||!v)return null;let k=v.getBoundingClientRect();return{menuLeft:k.left,menuRight:k.right,top:T.getBoundingClientRect().top,rtl:xe(T)}},p=()=>{let T=w===null?null:N.current.get(w);C(null),P(!1),T?.focus()};function D(){x.current.open&&(clearTimeout(x.current.open),x.current.open=null)}function _(){x.current.close&&(clearTimeout(x.current.close),x.current.close=null)}function M(T,v){_(),w!==null&&w!==T&&(D(),C(null)),ln(v)&&v.items?.length?(D(),x.current.open=setTimeout(()=>{P(!1),C(T)},150)):ln(v)||(D(),w!==null&&(x.current.close=setTimeout(()=>C(null),200)))}let A=T=>{D(),_(),P(!0),C(T)};function z(T){if(T.key==="Tab"){T.preventDefault(),m();return}let v=xe(T.currentTarget)?"ArrowLeft":"ArrowRight";if(T.key===v){let k=Number(document.activeElement?.dataset.menuIndex),L=d.items[k];L&&ln(L)&&L.items?.length&&(T.preventDefault(),A(k));return}an(T.currentTarget,T.key)&&(T.preventDefault(),w!==null&&C(null))}function W(T){D(),ln(T)&&T.items?.length&&(x.current.close=setTimeout(()=>C(null),200))}return Lr(kt(Is,{children:[ge("div",{ref:b,className:`rdd-context-menu rdd-context-menu--${e}${i?` ${i}`:""}`,dir:d.dir,style:{left:d.x,top:d.y,...u},role:"menu",tabIndex:-1,"aria-orientation":"vertical",onKeyDown:z,children:d.items.map((T,v)=>{if(ko(T))return ge("hr",{className:"rdd-context-menu__separator",role:"separator"},v);if(ln(T))return kt("button",{ref:U=>{N.current.set(v,U)},type:"button",className:`rdd-context-menu__item rdd-context-menu__item--has-submenu${w===v?" rdd-context-menu__item--submenu-open":""}`,title:T.title?Kt(T.title,c):void 0,"data-menu-index":v,onMouseEnter:()=>M(v,T),onMouseLeave:()=>W(T),onClick:U=>{T.items?.length&&(D(),_(),P(U.detail===0),C(w===v&&U.detail!==0?null:v))},role:"menuitem","aria-haspopup":"true","aria-expanded":w===v,children:[ge("span",{className:"rdd-context-menu__icon","aria-hidden":"true"}),ge("span",{className:"rdd-context-menu__label",children:Kt(T.label,c)}),ge("span",{className:"rdd-context-menu__chevron","aria-hidden":"true",children:"\u203A"})]},v);let k=T,L=k.checkbox&&k.checkbox.active!==!1,H=L&&k.checkbox.value,Y=k.disabled===!0||(L?k.checkbox.enabled===!1:!1);return kt("button",{ref:U=>{N.current.set(v,U)},"data-menu-index":v,type:"button",className:`rdd-context-menu__item${Y?" rdd-context-menu__item--disabled":""}`,title:k.title?Kt(k.title,c):void 0,disabled:Y,"data-cy-action":k.cyAction,onClick:()=>{Y||(k.action?.(),m())},onMouseEnter:()=>M(v,T),onMouseLeave:()=>W(T),role:L?"menuitemcheckbox":"menuitem","aria-checked":L?H:void 0,children:[k.icon?ge("span",{className:"rdd-context-menu__icon",children:k.icon}):ge("span",{className:"rdd-context-menu__icon","aria-hidden":"true"}),ge("span",{className:"rdd-context-menu__label",children:Kt(k.label,c)}),L&&ge("span",{className:`rdd-context-menu__checkbox${H?" rdd-context-menu__checkbox--checked":""}`,"aria-hidden":"true",children:kt("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[ge("rect",{x:"0.75",y:"0.75",width:"10.5",height:"10.5",rx:"2",fill:H?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.5"}),H&&ge("path",{d:"M2.5 6 L4.5 8.5 L9.5 3.5",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})]},v)})}),w!==null&&(()=>{let T=d.items[w];return ge(Or,{ref:E,items:T.items??[],getAnchor:a,autoFocus:f,onBack:p,theme:e,dir:d.dir,fmt:c,onClose:m,onMouseEnter:()=>_(),onMouseLeave:()=>{x.current.close=setTimeout(()=>C(null),200)}})})()]}),document.body)});_n.displayName="ContextMenu";var dn={Component:_n},Xt=cn.createContext(null),Hn=({adapter:e=dn,children:t,...n})=>{let o=wt(null),[r,i]=cn.useState(!1),u=cn.useCallback(l=>{o.current?.show(l)},[]);return kt(Xt.Provider,{value:{show:u,isOpen:r},children:[t,ge(e.Component,{ref:o,...n,onShow:()=>{i(!0),n.onShow?.()},onHide:()=>{i(!1),n.onHide?.()}})]})};function Es(){let e=cn.useContext(Xt);if(!e)throw new Error("useContextMenu must be used within <DockableDesktopProvider> or <RddContextMenu>");return e.show}import{jsx as un}from"react/jsx-runtime";function Os(e={}){let{messages:t,...n}=e;return new Gt({...n,predefinedMessages:t})}function Ns(){let e=Wr(Dn);if(!e)throw new Error("useWorkspace must be used within <DockableDesktopProvider>");return e}var Ws=()=>()=>{};function Nr(e,t){let n=Wr(Sn),o=fn(e);pn(()=>{o.current=e});let r=()=>n?e(n.getSnapshot()):t;return Ls(n?.subscribeToState??Ws,r,r)}function As(){let e=De(),t=e.instanceId,n=Nr(l=>l.panels[t]?.state,void 0),o=Nr(l=>l.activePanelId===t,!1),r=n?n==="floating"?"floating-window":"dockable-panel":e.containerType??"standalone",i=fn(e);pn(()=>{i.current=e});let u=$n(()=>({close:l=>i.current.requestClose(l),minimize:()=>i.current.requestMinimize?.(),setDirty:(l,d)=>i.current.setDirty(l,d),setTitle:l=>i.current.setTitle(l),setIcon:l=>i.current.setIcon?.(l)}),[t]);return $n(()=>({id:t,containerType:r,isActive:!!n&&o,isMinimized:n==="minimized",isFloating:n==="floating",...u}),[u,t,r,n,o])}function zs(e){let t=De(),n=fn(e);pn(()=>{n.current=e}),Mo(()=>{let o=[t.onActivate?.(()=>n.current.onActivate?.()),t.onDeactivate?.(()=>n.current.onDeactivate?.()),t.onMinimize?.(()=>n.current.onMinimize?.()),t.onRestore?.(()=>n.current.onRestore?.()),t.onClose?.(()=>n.current.onClose?.()),t.onResize?.((r,i)=>n.current.onResize?.(r,i)),t.onContainerTypeChange?.(r=>n.current.onContainerTypeChange?.(r))];return()=>{o.forEach(r=>r?.())}},[t])}function Fs(e){let t=De(),n=fn(e);pn(()=>{n.current=e}),Mo(()=>t.onCloseRequested(()=>n.current?n.current():!0),[t])}function _s(e){let t=De(),n=fn(e);pn(()=>{n.current=e}),Mo(()=>t.registerStateProvider?.(()=>n.current?.()),[t])}function Hs(){let{modals:e}=qe(),t=Ue(),n=ae();return $n(()=>({stack:e,topmost:e[e.length-1]??null,open:t.openModal,close:t.close,closeAll:t.closeAllModals,get:t.getInstance,update:t.updateInstance,setDirty:t.setDirty,confirm:({message:o,title:r,alert:i,alertType:u,icon:l,yesNo:d,size:R="small"})=>new Promise(w=>{t.openModal(Je,{message:o,alert:i,alertType:u,icon:l,useYesNoTitles:d,onSettled:w},{title:r??n.modalTitle,size:R})}),alert:({message:o,title:r,alertType:i,icon:u,okLabel:l,size:d="small"})=>new Promise(R=>{t.openModal(Co,{message:o,alertType:i,icon:u,okLabel:l,onSettled:R},{title:r??n.alertTitle,size:d})})}),[e,t,n])}function $s(){let{leftPanel:e,rightPanel:t}=qe(),n=Ue();return $n(()=>({left:e,right:t,openLeft:n.openLeftPanel,openRight:n.openRightPanel,close:n.close,closeAll:()=>{e&&n.close(e.id),t&&n.close(t.id)},get:n.getInstance,update:n.updateInstance,setDirty:n.setDirty}),[e,t,n])}function Bs({side:e,defaultWidth:t}){return e==="left"?un(Mr,{defaultWidth:t}):e==="right"?un(Tr,{defaultWidth:t}):un(Sr,{defaultWidth:t})}var Gs=Ds(function({children:t,adapter:n,...o},r){return t!==void 0?un(Hn,{adapter:n,...o,children:t}):un(_n,{ref:r,...o})});import{useContext as ia,useState as sa}from"react";import{createContext as Ys,useContext as Ks,useMemo as Xs,useState as Ar}from"react";import{jsx as Vs}from"react/jsx-runtime";var zr=Ys(null),To=({children:e})=>{let[t,n]=Ar({}),[o,r]=Ar({}),i=Xs(()=>({getActiveInGroup:u=>t[u]??null,setActiveInGroup:(u,l)=>n(d=>({...d,[u]:l})),isModifierActive:u=>o[u]??!1,setModifierActive:(u,l)=>r(d=>({...d,[u]:l})),toggleModifier:u=>r(l=>({...l,[u]:!l[u]}))}),[t,o]);return Vs(zr.Provider,{value:i,children:e})};function Bn(){let e=Ks(zr);if(!e)throw new Error("useToolbar must be used within DockableDesktopProvider");return e}import{createContext as Zs,useCallback as js,useContext as Fr,useLayoutEffect as qs,useMemo as Us,useRef as Js,useSyncExternalStore as Qs}from"react";import{jsx as ra}from"react/jsx-runtime";function ea(){let e=new Map,t=new Set,n=()=>t.forEach(o=>o());return{publish(o,r){return e.set(o,r),n(),()=>{e.get(o)===r&&(e.delete(o),n())}},get(o){return e.get(o)??null},subscribe(o){return t.add(o),()=>t.delete(o)}}}var So=Zs(null),_r=({children:e})=>{let t=Us(()=>ea(),[]);return ra(So.Provider,{value:t,children:e})};function ta(e){let t=ho(),n=Fr(So),o=Js(null);if(!n)throw new Error("usePanelContribution must be used within <DockableDesktopProvider>");qs(()=>{if(n)return o.current?.(),o.current=n.publish(t,e),()=>{o.current?.(),o.current=null}},[n,t,e])}function Eo(){let e=we(r=>r.activePanelId),t=Fr(So);if(!t)throw new Error("useActiveContribution must be used within <DockableDesktopProvider>");let n=js(r=>t?t.subscribe(r):()=>{},[t]),o=()=>t&&e?t.get(e):null;return Qs(n,o,o)}function Hr(e,t=null){return{id:e.id,label:e.label,icon:e.icon??t,renderContent:()=>e.content}}function na(e){let t=Eo();return t?.toolbarItems?.length?[...e,{type:"separator"},...t.toolbarItems]:e}function oa(e,t=null){let n=Eo();return n?.sidebarSections?.length?[...e,...n.sidebarSections.map(o=>Hr(o,t))]:e}import{jsx as Vt}from"react/jsx-runtime";var aa=({contextMenuAdapter:e=dn,workspace:t,messages:n,children:o,...r})=>{let i=ia(Xt),[u]=sa(()=>t??new Gt),l=Vt(Dn.Provider,{value:u,children:Vt(To,{children:Vt(mr,{client:u,predefinedMessages:n,...r,children:Vt(_r,{children:Vt(Rr,{children:o})})})})});return i!==null?l:Vt(Hn,{adapter:e,formatMessageProvider:r.formatMessage,children:l})};import Ta,{useState as Fo,useRef as ut,useEffect as Oe,useCallback as _o,useContext as Sa}from"react";import{createPortal as Ea}from"react-dom";import{useSyncExternalStore as la}from"react";var ca=()=>()=>{},da=()=>!0,ua=()=>!1;function Gn(){return la(ca,da,ua)}var Io=new Map,$r=new WeakSet,Br=e=>e.isConnected&&e.getClientRects().length>0;function Gr(e,t){if($r.has(t))return;$r.add(t);let n={scrolls:new Map,focused:null};Io.set(e,n),t.addEventListener("scroll",o=>{let r=o.target;!(r instanceof Element)||!Br(r)||n.scrolls.set(r,{top:r.scrollTop,left:r.scrollLeft})},{capture:!0,passive:!0}),t.addEventListener("focusin",o=>{o.target instanceof HTMLElement&&(n.focused=o.target)})}function Do(e,{refocus:t}){let n=Io.get(e);if(!n)return;let o=()=>{n.scrolls.forEach(({top:u,left:l},d)=>{if(!d.isConnected){n.scrolls.delete(d);return}d.scrollTop!==u&&(d.scrollTop=u),d.scrollLeft!==l&&(d.scrollLeft=l)});let r=n.focused,i=document.activeElement===null||document.activeElement===document.body;t&&i&&r?.isConnected&&Br(r)&&r.focus({preventScroll:!0})};o(),typeof requestAnimationFrame<"u"&&requestAnimationFrame(o)}function Yr(e){Io.delete(e)}import{useSyncExternalStore as pa}from"react";var fa=()=>document.documentElement.getAttribute("data-color-scheme")==="light"?"light":"dark",ma=e=>{let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["data-color-scheme"]}),()=>t.disconnect()},ga=()=>"dark";function Lo(){return pa(ma,fa,ga)}import ha,{useRef as Tt,useEffect as Zt,useLayoutEffect as ba}from"react";import{jsx as ct,jsxs as Kr}from"react/jsx-runtime";var jt=new Map,Yn="preserved-dom-container",Oo=e=>{let t=jt.get(e);return t||(t=document.createElement("div"),t.className="rdd-panel-dom",jt.set(e,t),Gr(e,t)),t},Xr=(e,t,n,o,r)=>{let i=t.component,u=n.get(i);if(!u)return console.warn(`[react-dockable-desktop] Panel "${e}" references component key "${i}" which is not registered. Add it to the workspace's panels:
|
|
5
|
+
createWorkspace({ panels: { "${i}": { component: YourComponent } } })`),Kr("div",{className:"rdd-unregistered-panel",children:[Kr("h6",{className:"rdd-unregistered-panel__title",children:["\u26A0\uFE0F ",q(o.componentUnregistered,r)]}),ct("span",{className:"rdd-unregistered-panel__key",children:q({...o.componentKey,values:{key:i}},r)})]});let l=u.Component;return ct(l,{...t.props??{},panelId:e})},No=new Map,lt=new Map,Mt=e=>{let t=lt.get(e);return t||(t={onClose:new Set,onMinimize:new Set,onRestore:new Set,onResize:new Set,onActivate:new Set,onDeactivate:new Set,onContainerTypeChange:new Set},lt.set(e,t)),t},Kn=({panelId:e})=>{let t=Tt(null),n=we(r=>r.activePanelId===e),o=Tt(n);return ba(()=>{o.current=n}),Zt(()=>{let r=t.current;if(!r)return;let i=Oo(e);r.appendChild(i),Do(e,{refocus:o.current});let u=new ResizeObserver(l=>{for(let d of l){let{width:R,height:w}=d.contentRect;if(R>0&&w>0){No.set(e,{width:R,height:w});let C=lt.get(e);C&&C.onResize.forEach(f=>f(R,w))}}});return u.observe(r),()=>{u.disconnect();let l=document.getElementById(Yn);l||(l=document.createElement("div"),l.id=Yn,l.style.display="none",document.body.appendChild(l)),l.appendChild(i)}},[e]),ct("div",{ref:t,className:"rdd-panel-dom-host"})},Vr=({panelId:e})=>{let t=we(),n=Bt(),o=pe(),r=ae(),i=Tt(null),u=t.panels[e],l=u?n.get(u.component):null,d=l?.defaultOptions?.disableLivePreview||!1,R=No.get(e)||{width:800,height:500},w=R.width,C=R.height,b=Math.min(220/w,140/C);if(Zt(()=>{if(d)return;let I=i.current;if(!I)return;let h=jt.get(e);if(h)return I.appendChild(h),Do(e,{refocus:!1}),()=>{let E=document.getElementById(Yn);E||(E=document.createElement("div"),E.id=Yn,E.style.display="none",document.body.appendChild(E)),E.appendChild(h)}},[e,d]),d){let I=w*b,h=C*b,E=u?.title||l?.defaultOptions?.title||r.untitledPanel,N=q(E,o),x=(Array.from(N)[0]||"P").toUpperCase();return ct("div",{className:"rdd-taskbar-item-preview-frame rdd-taskbar-item-preview-frame--empty",style:{width:`${I}px`,height:`${h}px`},children:ct("div",{className:"rdd-taskbar-item-preview-initial",children:x})})}return ct("div",{className:"rdd-taskbar-item-preview-frame",style:{width:`${w*b}px`,height:`${C*b}px`},children:ct("div",{ref:i,className:"rdd-taskbar-item-preview-host",style:{width:`${w}px`,height:`${C}px`,transform:`scale(${b})`,"--rdd-preview-scale":b}})})},Zr=({panelId:e,children:t})=>{let n=we(),{requestClosePanel:o,setPanelDirty:r,registerCloseGuard:i,unregisterCloseGuard:u,registerStateProvider:l,unregisterStateProvider:d,updatePanelTitle:R,setPanelIcon:w,minimizePanel:C}=En(),f=n.minimized.some(c=>c.id===e),P=Tt(f);Zt(()=>{let c=lt.get(e);c&&(f&&!P.current?c.onMinimize.forEach(a=>a()):!f&&P.current&&c.onRestore.forEach(a=>a()),P.current=f)},[f,e]);let b=n.activePanelId===e,I=Tt(b);Zt(()=>{let c=I.current;I.current=b;let a=lt.get(e);a&&(b&&!c?a.onActivate.forEach(p=>p()):!b&&c&&a.onDeactivate.forEach(p=>p()))},[b,e]);let h=n.panels[e]?.state,E=h==="floating"?"floating-window":"dockable-panel",N=Tt(E);Zt(()=>{if(h==="minimized")return;let c=N.current;N.current=E;let a=lt.get(e);a&&E!==c&&a.onContainerTypeChange.forEach(p=>p(E))},[E,h,e]),Zt(()=>()=>{let c=lt.get(e);c&&(I.current&&c.onDeactivate.forEach(a=>a()),c.onClose.forEach(a=>a()),lt.delete(e))},[e]);let x=Tt(E),m=ha.useMemo(()=>({requestClose:c=>o(e,c),setDirty:(c,a)=>r(e,c,a),onCloseRequested:c=>(i(e,c),()=>u(e)),registerStateProvider:c=>(l(e,c),()=>d(e)),setTitle:c=>R(e,c),setIcon:c=>w(e,c??null),instanceId:e,containerType:x.current,onClose:c=>{let a=Mt(e);return a.onClose.add(c),()=>a.onClose.delete(c)},onMinimize:c=>{let a=Mt(e);return a.onMinimize.add(c),()=>a.onMinimize.delete(c)},onRestore:c=>{let a=Mt(e);return a.onRestore.add(c),()=>a.onRestore.delete(c)},onResize:c=>{let a=Mt(e);return a.onResize.add(c),()=>a.onResize.delete(c)},requestMinimize:()=>C(e),getDimensions:()=>No.get(e)??null,onActivate:c=>{let a=Mt(e);return a.onActivate.add(c),()=>a.onActivate.delete(c)},onDeactivate:c=>{let a=Mt(e);return a.onDeactivate.add(c),()=>a.onDeactivate.delete(c)},onContainerTypeChange:c=>{let a=Mt(e);return a.onContainerTypeChange.add(c),()=>a.onContainerTypeChange.delete(c)}}),[e,o,r,i,u,l,d,R,w,C]);return ct(zt,{value:m,children:t})};import Ra from"react";function Qe(e){let{element:t,pointerId:n,startClientX:o,startClientY:r,captureStart:i,onMove:u,onEnd:l,activeClasses:d}=e;t.setPointerCapture(n),d?.forEach(({el:f,classes:P})=>f.classList.add(...P));let R=i(),w=f=>{u(f.clientX-o,f.clientY-r,R)},C=()=>{d?.forEach(({el:f,classes:P})=>f.classList.remove(...P)),t.removeEventListener("pointermove",w),t.removeEventListener("pointerup",C),t.removeEventListener("pointercancel",C),l?.(R)};t.addEventListener("pointermove",w),t.addEventListener("pointerup",C),t.addEventListener("pointercancel",C)}function mn(e,t,n,o,r){let{minW:i,minH:u,maxW:l,maxH:d,minX:R,minY:w}=r,{x:C,y:f,w:P,h:b}=o;if(e.includes("e")&&(P=Math.max(i,Math.min(o.w+t,l??1/0))),e.includes("w")){let I=o.w-i,h=R!=null?-(o.x-R):-1/0,E=Math.max(h,Math.min(t,I));P=o.w-E,C=o.x+E}if(e.includes("s")&&(b=Math.max(u,Math.min(o.h+n,d??1/0))),e.includes("n")){let I=o.h-u,h=w!=null?-(o.y-w):-1/0,E=Math.max(h,Math.min(n,I));b=o.h-E,f=o.y+E}return{x:C,y:f,w:P,h:b}}import{useState as va,useRef as ya,useEffect as Pa,useCallback as xa}from"react";import"react";var Wo=(e,t)=>{if(!e)return null;if(e.type==="leaf")return e.id===t?e:null;for(let n of e.children){let o=Wo(n,t);if(o)return o}return null},Xn=(e,t)=>{let n=e.getBoundingClientRect();return t-n.left<n.width/2!==xe(e)?"left":"right"},Vn=e=>e.key==="ContextMenu"||e.shiftKey&&e.key==="F10",jr=new WeakSet,Zn=e=>{let t=e.getBoundingClientRect(),n=new MouseEvent("contextmenu",{clientX:t.left,clientY:t.bottom,cancelable:!0});return jr.add(n),n},gn=e=>jr.has(e)||e.type==="click"&&e.detail===0?"first-item":void 0,qr=(e,t,n)=>{if(!n?.isConnected)return;let o=e.replace(/["\\]/g,"\\$&");if(n.querySelector(`[data-tab-id="${o}"]`))return;let r=document.activeElement;if(r&&r!==document.body)return;((t?.isConnected?t.querySelector('[role="tab"][aria-selected="true"]'):null)??n.querySelector(".rdd-workspace-tab-active-focused")??n.querySelector('[role="tab"][aria-selected="true"]')??n).focus()},Ao=e=>e.replace(/[^A-Za-z0-9_-]/g,"_"),St=300,Et=8;import{jsx as ve,jsxs as Ur}from"react/jsx-runtime";var qt=Ur("svg",{className:"rdd-svg-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[ve("rect",{x:"3",y:"3",width:"7",height:"9",rx:"1"}),ve("rect",{x:"14",y:"3",width:"7",height:"5",rx:"1"}),ve("rect",{x:"14",y:"12",width:"7",height:"9",rx:"1"}),ve("rect",{x:"3",y:"16",width:"7",height:"5",rx:"1"})]}),It={float:ve("span",{className:"rdd-menu-icon",children:Ur("svg",{className:"rdd-svg-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[ve("rect",{x:"2",y:"8",width:"14",height:"14",rx:"1"}),ve("rect",{x:"8",y:"2",width:"14",height:"14",rx:"1"})]})}),minimize:ve("span",{className:"rdd-menu-icon",children:ve("svg",{className:"rdd-svg-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:ve("line",{x1:"4",y1:"18",x2:"20",y2:"18"})})}),restore:ve("span",{className:"rdd-menu-icon",children:ve("svg",{className:"rdd-svg-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:ve("rect",{x:"4",y:"4",width:"16",height:"16",rx:"1"})})}),maximize:ve("span",{className:"rdd-menu-icon",children:ve("svg",{className:"rdd-svg-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:ve("rect",{x:"2",y:"2",width:"20",height:"20",rx:"1"})})}),close:ve("span",{className:"rdd-menu-icon",children:ve("svg",{className:"rdd-svg-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:ve("path",{d:"M18 6L6 18M6 6l12 12"})})})};import{jsx as he,jsxs as Dt}from"react/jsx-runtime";var Jr=({leaf:e,onTabRightClick:t,activeDropZone:n,onHoverDropZone:o,onTabDragStart:r,hoveredTab:i,onTabHover:u,defaultPanelIcon:l,onRequestClosePanel:d})=>{let R=we(),w=Bt(),{openPanel:C,closeLeafGroup:f,setActivePanel:P}=In(),b=pe(),I=ae(),{windowClass:h,windowBodyClass:E}=je(),N=ya(null),[x,m]=va({start:!1,end:!1,rtl:!1}),c=xa(()=>{let v=N.current;if(!v)return;let k=Math.abs(v.scrollLeft),L=v.scrollWidth-v.clientWidth,H={start:k>1,end:k<L-1,rtl:xe(v)};m(Y=>Y.start===H.start&&Y.end===H.end&&Y.rtl===H.rtl?Y:H)},[]);Pa(()=>{let v=N.current;if(!v)return;v.addEventListener("scroll",c,{passive:!0});let k=new ResizeObserver(c);return k.observe(v),c(),()=>{v.removeEventListener("scroll",c),k.disconnect()}},[c]);let a=v=>{let k=v==="end"?120:-120;N.current?.scrollBy({left:x.rtl?-k:k,behavior:"smooth"})},p=x.rtl?"right":"left",D=x.rtl?"left":"right",_={left:"\u2039",right:"\u203A"},M={left:I.scrollTabsLeft,right:I.scrollTabsRight},A=v=>{C(v,R.panels[v].component),P(v)},z=(v,k,L)=>{if(Vn(v)){v.preventDefault(),t(k,Zn(v.currentTarget));return}let H=e.panels.filter(oe=>R.panels[oe]),Y=H.indexOf(k),U=xe(v.currentTarget)?-1:1,K;switch(v.key){case"ArrowRight":K=H[(Y+U+H.length)%H.length];break;case"ArrowLeft":K=H[(Y-U+H.length)%H.length];break;case"Home":K=H[0];break;case"End":K=H[H.length-1];break;case"Enter":case" ":v.preventDefault(),A(k);return;case"Delete":{if(!L)return;v.preventDefault();let oe=v.currentTarget.closest(".rdd-workspace");Promise.resolve(d(k)).then(()=>requestAnimationFrame(()=>{qr(k,N.current,oe)}));return}default:return}v.preventDefault(),!(!K||K===k)&&(A(K),N.current?.querySelector(`[data-tab-id="${K.replace(/["\\]/g,"\\$&")}"]`)?.focus())},W=`rdd-tabpanel-${Ao(e.id)}`,T=v=>`rdd-tab-${Ao(v)}`;return Dt("div",{"data-active-panel-id":e.activePanelId||"","data-rdd-leaf":e.id,className:`rdd-workspace-panel ${h??""}`,children:[Dt("div",{className:"rdd-workspace-tab-bar",children:[x.start&&he("button",{className:`rdd-tab-scroll-btn rdd-tab-scroll-btn-${p}`,onPointerDown:v=>v.stopPropagation(),onClick:()=>a("start"),tabIndex:-1,"aria-label":q(M[p],b),children:_[p]}),he("div",{ref:N,className:"rdd-tab-headers-container",role:"tablist","aria-orientation":"horizontal",onPointerMove:v=>{R.draggedPanelId&&v.target===v.currentTarget&&u(e.id,"EMPTY",e.panels.length,"right")},onPointerLeave:v=>{R.draggedPanelId&&v.target===v.currentTarget&&u(e.id,"",-1,null)},children:e.panels.map((v,k)=>{let L=R.panels[v];if(!L)return null;let H=e.activePanelId===v,Y=R.activePanelId===v,K=w.get(L.component)?.defaultOptions,oe=i&&i.leafId===e.id&&i.panelId===v,le=k===e.panels.length-1,te=i&&i.leafId===e.id&&i.panelId==="EMPTY"&&le,re=oe?i.side==="left"?"rdd-drag-hover-left":"rdd-drag-hover-right":te?"rdd-drag-hover-right":"",Re=H?Y?"rdd-active rdd-workspace-tab-active-focused":"rdd-active rdd-workspace-tab-active-unfocused":"rdd-workspace-tab-inactive";return Dt("div",{id:T(v),role:"tab","aria-selected":H,"aria-controls":W,"aria-keyshortcuts":K?.canClose!==!1?"Delete":void 0,tabIndex:H?0:-1,onKeyDown:ne=>z(ne,v,K?.canClose!==!1),"data-tab-id":v,"data-leaf-id":e.id,"data-rdd-tab":v,"data-tab-index":String(k),onClick:()=>A(v),onPointerDown:ne=>{K?.canDrag!==!1&&r(v,ne)},onContextMenu:ne=>t(v,ne),onPointerMove:ne=>{R.draggedPanelId&&ne.pointerType!=="touch"&&u(e.id,v,k,Xn(ne.currentTarget,ne.clientX))},onPointerLeave:()=>{R.draggedPanelId&&u(e.id,"",-1,null)},className:`rdd-workspace-tab ${Re} ${re}`,style:{cursor:K?.canDrag===!1?"default":"pointer"},children:[Dt("span",{className:"rdd-text-truncate rdd-workspace-tab-title",children:[he("span",{className:"rdd-workspace-tab-icon",children:L.icon??(K?.icon||l||qt)}),Dt("span",{children:[q(L.title,b),L.dirty?" *":""]})]}),K?.renderHeaderActions&&he("span",{className:"rdd-tab-header-actions",onClick:ne=>ne.stopPropagation(),onPointerDown:ne=>ne.stopPropagation(),children:K.renderHeaderActions(v)}),K?.canClose!==!1&&he("span",{onClick:ne=>{ne.stopPropagation(),d(v)},title:q(I.closeTab,b),"aria-hidden":"true",className:`rdd-close-tab-x${K?.renderHeaderActions?"":" rdd-close-tab-x--end"}`,children:he("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:he("path",{d:"M18 6L6 18M6 6l12 12"})})})]},v)})}),x.end&&he("button",{className:`rdd-tab-scroll-btn rdd-tab-scroll-btn-${D}`,onPointerDown:v=>v.stopPropagation(),onClick:()=>a("end"),tabIndex:-1,"aria-label":q(M[D],b),children:_[D]}),e.panels.length===0&&e.keepOnEmpty&&e.canClose!==!1&&he("button",{type:"button",onClick:()=>{f(e.id)},className:"rdd-close-tab-x rdd-header-close-empty-group",title:q(I.closeEmptyGroup,b),"aria-label":q(I.closeEmptyGroup,b),children:he("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5","aria-hidden":"true",children:he("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),Dt("div",{id:W,role:"tabpanel","aria-labelledby":e.activePanelId?T(e.activePanelId):void 0,className:`rdd-panel-body ${E??""}`,children:[e.activePanelId&&R.panels[e.activePanelId]?he(Kn,{panelId:e.activePanelId},e.activePanelId):he("div",{className:"rdd-empty-leaf-placeholder",children:he("span",{children:q(I.emptyGroup,b)})}),R.draggedPanelId!==null&&(()=>{let v=k=>n?.leafId===e.id&&n.position===k;return he("div",{className:"rdd-dock-drop-zone-overlay",children:Dt("div",{className:"rdd-dock-target-cross",children:[he("div",{"data-leaf-id":e.id,"data-drop-zone":"top",onPointerEnter:()=>o(e.id,"top"),onPointerLeave:()=>o(e.id,null),className:`rdd-dock-target-box rdd-dock-target-top${v("top")?" rdd-dock-target-box--active":""}`,children:"\u25B2"}),he("div",{"data-leaf-id":e.id,"data-drop-zone":"bottom",onPointerEnter:()=>o(e.id,"bottom"),onPointerLeave:()=>o(e.id,null),className:`rdd-dock-target-box rdd-dock-target-bottom${v("bottom")?" rdd-dock-target-box--active":""}`,children:"\u25BC"}),he("div",{"data-leaf-id":e.id,"data-drop-zone":"left",onPointerEnter:()=>o(e.id,"left"),onPointerLeave:()=>o(e.id,null),className:`rdd-dock-target-box rdd-dock-target-left${v("left")?" rdd-dock-target-box--active":""}`,children:"\u25C0"}),he("div",{"data-leaf-id":e.id,"data-drop-zone":"right",onPointerEnter:()=>o(e.id,"right"),onPointerLeave:()=>o(e.id,null),className:`rdd-dock-target-box rdd-dock-target-right${v("right")?" rdd-dock-target-box--active":""}`,children:"\u25B6"}),he("div",{"data-leaf-id":e.id,"data-drop-zone":"center",onPointerEnter:()=>o(e.id,"center"),onPointerLeave:()=>o(e.id,null),className:`rdd-dock-target-box rdd-dock-target-center${v("center")?" rdd-dock-target-box--active":""}`,children:"\u25A3"})]})})})(),R.draggedPanelId!==null&&n!==null&&n.leafId===e.id&&he("div",{className:"rdd-dock-preview-highlight",style:(()=>{let v=n.position,k=`${R.splitRatio*100}%`,L=`${(1-R.splitRatio)*100}%`;return{left:v==="right"?L:"0",top:v==="bottom"?L:"0",width:v==="left"||v==="right"?k:"100%",height:v==="top"||v==="bottom"?k:"100%"}})()})]})]})};import{jsx as hn,jsxs as Ca}from"react/jsx-runtime";var zo=({node:e,path:t,onTabRightClick:n,activeDropZone:o,onHoverDropZone:r,onTabDragStart:i,hoveredTab:u,onTabHover:l,defaultPanelIcon:d,onRequestClosePanel:R})=>{let{updateSplitSizes:w}=En();if(e.type==="leaf")return hn(Jr,{leaf:e,onTabRightClick:n,activeDropZone:o,onHoverDropZone:r,onTabDragStart:i,hoveredTab:u,onTabHover:l,defaultPanelIcon:d,onRequestClosePanel:R});let C=e.orientation==="horizontal",f=(P,b)=>{b.preventDefault();let I=b.currentTarget,h=I.parentElement,E=h?C?h.clientWidth:h.clientHeight:C?1e3:800,N=xe(h);Qe({element:I,pointerId:b.pointerId,startClientX:b.clientX,startClientY:b.clientY,captureStart:()=>[...e.sizes],activeClasses:[{el:I,classes:["rdd-active"]},{el:document.body,classes:["rdd-resizing-active",C?"rdd-resizing-col-active":"rdd-resizing-row-active"]}],onMove:(x,m,c)=>{let p=(C?(C&&N?-1:1)*x:m)/E,D=[...c];D[P]+=p,D[P+1]-=p,D[P]>.1&&D[P+1]>.1&&w(t,D)}})};return hn("div",{className:`rdd-split ${C?"rdd-split--row":"rdd-split--column"}`,children:e.children.map((P,b)=>{let I=e.sizes[b]*100;return Ca(Ra.Fragment,{children:[hn("div",{className:"rdd-split-child",style:{flexGrow:e.sizes[b],flexBasis:`${I}%`},children:hn(zo,{node:P,path:[...t,b],onTabRightClick:n,activeDropZone:o,onHoverDropZone:r,onTabDragStart:i,hoveredTab:u,onTabHover:l,defaultPanelIcon:d,onRequestClosePanel:R})}),b<e.children.length-1&&hn("div",{onPointerDown:h=>f(b,h),className:`rdd-resizer-bar ${C?"rdd-resizer-bar--vertical":"rdd-resizer-bar--horizontal"}`})]},b)})})};import"react";import{Fragment as Qr,jsx as Ut,jsxs as ei}from"react/jsx-runtime";var ti=({state:e,activeEdgeDrop:t,activeCornerAnchor:n,setActiveEdgeDrop:o,setActiveCornerAnchor:r})=>ei(Qr,{children:[e.draggedPanelId!==null&&ei(Qr,{children:[Ut("div",{"data-edge-trigger":"left",className:"rdd-workspace-edge-trigger rdd-edge-trigger-left",onPointerEnter:()=>o("left"),onPointerLeave:()=>o(null)}),Ut("div",{"data-edge-trigger":"right",className:"rdd-workspace-edge-trigger rdd-edge-trigger-right",onPointerEnter:()=>o("right"),onPointerLeave:()=>o(null)}),Ut("div",{"data-edge-trigger":"top",className:"rdd-workspace-edge-trigger rdd-edge-trigger-top",onPointerEnter:()=>o("top"),onPointerLeave:()=>o(null)}),Ut("div",{"data-edge-trigger":"bottom",className:"rdd-workspace-edge-trigger rdd-edge-trigger-bottom",onPointerEnter:()=>o("bottom"),onPointerLeave:()=>o(null)})]}),e.draggedPanelId!==null&&["top-left","top-right","bottom-left","bottom-right"].map(i=>Ut("div",{className:`rdd-corner-zone rdd-corner-zone--${i}${n===i?" rdd-corner-zone--hovered":""}`,onPointerEnter:()=>{r(i),o(null)},onPointerLeave:()=>r(null),"aria-hidden":"true"},i)),e.draggedPanelId!==null&&t!==null&&Ut("div",{className:"rdd-workspace-edge-preview",style:(()=>{let i=`${e.edgeSplitRatio*100}%`;switch(t){case"left":return{left:0,top:0,bottom:0,width:i};case"right":return{right:0,top:0,bottom:0,width:i};case"top":return{top:0,left:0,right:0,height:i};case"bottom":return{bottom:0,left:0,right:0,height:i}}})()})]});import"react";import{Fragment as ni,jsx as ce,jsxs as dt}from"react/jsx-runtime";var oi=({state:e,registry:t,windowClass:n,windowBodyClass:o,defaultPanelIcon:r,messages:i,formatMessage:u,setActivePanel:l,focusPanel:d,maximizePanel:R,minimizePanel:w,getPanelContextMenuItems:C,showContextMenu:f,handleRequestClose:P,startDrag:b,startResize:I})=>ce(ni,{children:e.floating.map(h=>{let E=e.panels[h.id];if(!E)return null;let N=h.maximized,x=e.draggedPanelId===h.id,m=e.activePanelId===h.id,a=t.get(E.component)?.defaultOptions;return dt("div",{"data-window-id":h.id,"data-rdd-window":h.id,dir:e.dir,onPointerDownCapture:()=>{l(h.id),d(h.id)},className:`rdd-floating-window ${N?"rdd-maximized":""} ${m?"rdd-window-focused":""} ${n??""}`,style:(()=>{let _=typeof h.width=="number"?`${h.width}px`:h.width,M=typeof h.height=="number"?`${h.height}px`:h.height;if(N)return{position:"absolute",left:0,top:0,width:"100%",height:"100%",zIndex:h.z,pointerEvents:x?"none":"auto"};if(h.anchor){let A=e.floating.filter(k=>k.anchor===h.anchor&&!k.maximized),z=A.findIndex(k=>k.id===h.id),W=8;for(let k=0;k<z;k++){let L=typeof A[k].height=="number"?A[k].height:parseFloat(A[k].height);W+=L+8}let T=h.anchor.startsWith("top");return{position:"absolute",[h.anchor.endsWith("-right")?"insetInlineEnd":"insetInlineStart"]:8,[T?"top":"bottom"]:W,width:_,height:M,zIndex:h.z,transition:x?"none":"top 0.2s ease, bottom 0.2s ease",pointerEvents:x?"none":"auto"}}return{position:"absolute",left:typeof h.x=="number"?`${h.x}px`:h.x,top:typeof h.y=="number"?`${h.y}px`:h.y,width:_,height:M,zIndex:h.z,pointerEvents:x?"none":"auto"}})(),children:[dt("div",{className:"rdd-floating-window-frame",children:[dt("div",{onDoubleClick:()=>R(h.id),onPointerDown:p=>{a?.canDrag!==!1&&b(h.id,p)},"data-rdd-titlebar":h.id,className:"rdd-floating-window-titlebar rdd-cursor-move",style:{cursor:N||a?.canDrag===!1?"default":"move"},children:[dt("span",{className:"rdd-floating-window-title",children:[ce("span",{className:"rdd-window-title-icon",children:E.icon??(a?.icon||r||qt)}),dt("span",{children:[q(E.title,u),E.dirty?" *":""]})]}),dt("div",{className:"rdd-titlebar-actions",onPointerDown:p=>p.stopPropagation(),children:[a?.renderHeaderActions&&ce("div",{className:"rdd-window-header-actions",children:a.renderHeaderActions(h.id)}),C(h.id).length>0&&ce("button",{type:"button",className:"rdd-custom-tab-btn rdd-btn-more-actions",title:q(i.moreActions,u),"aria-label":q(i.moreActions,u),onClick:p=>{p.stopPropagation();let D=C(h.id);D.length!==0&&f({event:p,items:D,initialFocus:gn(p)})},children:dt("svg",{className:"rdd-svg-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:[ce("circle",{cx:"12",cy:"5",r:"2"}),ce("circle",{cx:"12",cy:"12",r:"2"}),ce("circle",{cx:"12",cy:"19",r:"2"})]})}),ce("button",{type:"button",title:N?q(i.restoreSize,u):q(i.maximize,u),onClick:()=>R(h.id),className:"rdd-custom-tab-btn rdd-btn-maximize-tab",children:ce("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:ce("rect",{x:"4",y:"4",width:"16",height:"16",rx:"1.5"})})}),a?.canMinimize!==!1&&ce("button",{type:"button",title:q(i.minimize,u),onClick:()=>w(h.id),className:"rdd-custom-tab-btn rdd-btn-minimize-tab",children:ce("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:ce("path",{d:"M5 12h14"})})}),a?.canClose!==!1&&ce("button",{type:"button",title:q(i.close,u),onClick:()=>P(h.id),className:"rdd-custom-tab-btn rdd-btn-close-tab",children:ce("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:ce("path",{d:"M18 6L6 18M6 6l12 12"})})})]})]}),ce("div",{className:`rdd-floating-window-body${o?` ${o}`:""}`,children:ce(Kn,{panelId:h.id},h.id)})]}),!N&&dt(ni,{children:[ce("div",{onPointerDown:p=>I(h.id,"n",p),className:"rdd-resize-handle rdd-resize-n"}),ce("div",{onPointerDown:p=>I(h.id,"ne",p),className:"rdd-resize-handle rdd-resize-ne"}),ce("div",{onPointerDown:p=>I(h.id,"e",p),className:"rdd-resize-handle rdd-resize-e"}),ce("div",{onPointerDown:p=>I(h.id,"se",p),className:"rdd-resize-handle rdd-resize-se"}),ce("div",{onPointerDown:p=>I(h.id,"s",p),className:"rdd-resize-handle rdd-resize-s"}),ce("div",{onPointerDown:p=>I(h.id,"sw",p),className:"rdd-resize-handle rdd-resize-sw"}),ce("div",{onPointerDown:p=>I(h.id,"w",p),className:"rdd-resize-handle rdd-resize-w"}),ce("div",{onPointerDown:p=>I(h.id,"nw",p),className:"rdd-resize-handle rdd-resize-nw"})]})]},h.id)})});import"react";import{createPortal as wa}from"react-dom";import{jsx as Ye,jsxs as jn}from"react/jsx-runtime";var ri=({state:e,registry:t,taskbarVisibility:n,taskbarExpanded:o,expandTaskbar:r,leaveTaskbar:i,scrollTaskbar:u,taskbarRef:l,defaultPanelIcon:d,messages:R,formatMessage:w,lastTaskbarPointerTypeRef:C,hoveredMinimized:f,setHoveredMinimized:P,minimizedTooltipTimeoutRef:b,isContextMenuOpen:I,handleMinimizedRightClick:h,handleRequestClose:E,restorePanel:N})=>n==="always"||e.minimized.length>0?jn("div",{className:["rdd-taskbar-footer-container",`rdd-taskbar-mode-${n}`,n==="autohide"&&o?"rdd-taskbar-expanded":""].filter(Boolean).join(" "),onPointerEnter:n==="autohide"?r:void 0,onPointerLeave:n==="autohide"?i:void 0,children:[n==="autohide"&&Ye("div",{className:"rdd-taskbar-peek-handle"}),Ye("button",{type:"button",onClick:()=>u("left"),className:"rdd-taskbar-nav-btn","aria-label":q(R.scrollTaskbarLeft,w),style:{display:e.minimized.length>4?"block":"none"},children:"\u25C0"}),Ye("div",{ref:l,className:"rdd-taskbar-items-container",children:e.minimized.map(x=>{let m=t.get(x.component),c=e.panels[x.id]?.icon??(m?.defaultOptions?.icon||d||qt);return Ye("button",{type:"button","aria-label":q(x.title,w),onClick:a=>{a.detail!==0&&C.current==="touch"||(P(null),N(x.id))},onContextMenu:a=>h(x.id,a),onKeyDown:a=>{Vn(a)&&(a.preventDefault(),h(x.id,Zn(a.currentTarget)))},onPointerDown:a=>{if(C.current=a.pointerType,a.pointerType!=="touch")return;let p=a.currentTarget,D=a.clientX,_=a.clientY,M=a.pointerId,A=!1,z=()=>{A=!0,clearTimeout(v),p.removeEventListener("pointermove",T),p.removeEventListener("pointerup",W),p.removeEventListener("pointercancel",z)},W=()=>{z();let k=p.getBoundingClientRect();f?.id===x.id?(N(x.id),P(null)):P({id:x.id,rect:k,title:x.title,component:x.component,fromTouch:!0})},T=k=>{Math.hypot(k.clientX-D,k.clientY-_)>Et&&z()},v=setTimeout(()=>{if(A)return;p.removeEventListener("pointermove",T),p.removeEventListener("pointerup",W),p.removeEventListener("pointercancel",z);try{p.setPointerCapture(M)}catch{return}navigator.vibrate&&navigator.vibrate(10);let k=L=>{p.removeEventListener("pointerup",k),p.removeEventListener("pointercancel",k),h(x.id,L)};p.addEventListener("pointerup",k),p.addEventListener("pointercancel",k)},St);p.addEventListener("pointermove",T),p.addEventListener("pointerup",W),p.addEventListener("pointercancel",z)},onPointerEnter:a=>{if(a.pointerType==="touch"||I)return;b.current&&clearTimeout(b.current);let p=a.currentTarget.getBoundingClientRect();a.clientX>=p.left&&a.clientX<=p.right&&a.clientY>=p.top&&a.clientY<=p.bottom&&P({id:x.id,rect:p,title:x.title,component:x.component})},onPointerLeave:a=>{a.pointerType!=="touch"&&(b.current=setTimeout(()=>{P(null)},150))},className:"rdd-taskbar-glassmorphic-item","data-rdd-taskbar-item":x.id,children:Ye("span",{className:"rdd-taskbar-item-icon","aria-hidden":"true",children:c})},x.id)})}),f&&wa(jn("div",{className:"rdd-taskbar-item-tooltip",dir:e.dir,style:{left:`${f.rect.left+f.rect.width/2}px`,top:`${f.rect.top-8}px`},onPointerEnter:()=>{b.current&&clearTimeout(b.current)},onPointerLeave:x=>{x.pointerType!=="touch"&&P(null)},onClick:()=>{N(f.id),P(null)},onContextMenu:x=>h(f.id,x),onPointerDown:x=>{if(x.pointerType!=="touch")return;let m=f.id,c=x.currentTarget,a=x.clientX,p=x.clientY,D=x.pointerId,_=!1,M=()=>{_=!0,clearTimeout(z),c.removeEventListener("pointermove",A),c.removeEventListener("pointerup",M),c.removeEventListener("pointercancel",M)},A=W=>{Math.hypot(W.clientX-a,W.clientY-p)>Et&&M()},z=setTimeout(()=>{if(_)return;c.removeEventListener("pointermove",A),c.removeEventListener("pointerup",M),c.removeEventListener("pointercancel",M);try{c.setPointerCapture(D)}catch{return}navigator.vibrate&&navigator.vibrate(10);let W=T=>{c.removeEventListener("pointerup",W),c.removeEventListener("pointercancel",W),h(m,T)};c.addEventListener("pointerup",W),c.addEventListener("pointercancel",W)},St);c.addEventListener("pointermove",A),c.addEventListener("pointerup",M),c.addEventListener("pointercancel",M)},children:[jn("div",{className:"rdd-tooltip-header-row",children:[jn("span",{className:"rdd-tooltip-title-text rdd-text-truncate",children:[q(f.title,w),e.panels[f.id]?.dirty?" *":""]}),Ye("button",{type:"button",onClick:x=>{x.stopPropagation(),E(f.id),P(null)},title:q(R.closePanel,w),"aria-label":q(R.closePanel,w),className:"rdd-tooltip-close-x",children:Ye("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5","aria-hidden":"true",children:Ye("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),Ye(Vr,{panelId:f.id})]}),document.body),Ye("button",{type:"button",onClick:()=>u("right"),className:"rdd-taskbar-nav-btn","aria-label":q(R.scrollTaskbarRight,w),style:{display:e.minimized.length>4?"block":"none"},children:"\u25B6"})]}):null;import{useState as bn,useRef as qn}from"react";function ii({setDraggedPanelId:e,isRtl:t}){let[n,o]=bn(null),r=qn(null),[i,u]=bn({x:0,y:0}),[l,d]=bn(null),R=qn(null),w=p=>{d(p),R.current=p},[C,f]=bn(null),P=qn(null),b=p=>{f(p),P.current=p},[I,h]=bn(null),E=qn(null);return{activeDropZone:n,setActiveDropZone:o,activeDropZoneRef:r,dragPos:i,setDragPos:u,activeEdgeDrop:l,activeEdgeDropRef:R,setActiveEdgeDrop:w,activeCornerAnchor:C,activeCornerAnchorRef:P,setActiveCornerAnchor:b,hoveredTab:I,setHoveredTab:h,hoveredTabRef:E,handleTabHover:(p,D,_,M)=>{let A=M?{leafId:p,panelId:D,index:_,side:M}:null;h(A),E.current=A},handleHoverDropZone:(p,D)=>{let _=D?{leafId:p,position:D}:null;o(_),r.current=_,_&&(w(null),b(null))},updateHoverFromPoint:(p,D)=>{let _=document.elementsFromPoint(p,D),M=!1,A=!1,z=!1;for(let W of _)if(W instanceof HTMLElement){if(!M&&W.dataset.dropZone){let T=W.dataset.leafId;if(T){let v=W.dataset.dropZone;o({leafId:T,position:v}),r.current={leafId:T,position:v},M=!0}}if(!z&&W.dataset.tabId){let T=W.dataset.leafId,v=parseInt(W.dataset.tabIndex||"0",10);if(T){let k=Xn(W,p);h({leafId:T,panelId:W.dataset.tabId,index:v,side:k}),E.current={leafId:T,panelId:W.dataset.tabId,index:v,side:k},z=!0}}if(!A&&W.dataset.edgeTrigger&&(w(W.dataset.edgeTrigger),A=!0),M&&A&&z)break}M||(o(null),r.current=null),A||w(null),z||(h(null),E.current=null)},clearDragState:()=>{e(null),o(null),r.current=null,h(null),E.current=null,w(null),b(null)},flipRtl:p=>t?p==="left"?"right":p==="right"?"left":p:p}}import"react";function si(e){let{state:t,handleTabRightClick:n}=e,{activeDropZoneRef:o,hoveredTabRef:r,activeEdgeDropRef:i,activeCornerAnchorRef:u,setActiveCornerAnchor:l,clearDragState:d,flipRtl:R,setDragPos:w,updateHoverFromPoint:C}=e.targets,{dockPanelToWorkspaceEdge:f,movePanelOrder:P,dockPanelToGroup:b,floatPanel:I,setDraggedPanelId:h}=e.actions,E=(x,m)=>{let c=o.current,a=r.current,p=i.current,D=u.current;if(p)f(x,R(p));else if(a){let _=a.index;a.side==="right"&&(_+=1);let M=Wo(t.gridRoot,a.leafId);if(M){let A=M.panels.indexOf(x);A!==-1&&A<_&&(_-=1)}P(x,a.leafId,_)}else c?b(x,c.leafId,R(c.position)):D?I(x,void 0,D):I(x,{x:m.clientX-150,y:m.clientY-15,width:450,height:350});l(null),d()};return{executeDrop:E,handleTabDragStart:(x,m)=>{if(m.pointerType==="mouse"&&m.button!==0)return;m.preventDefault();let c=m.currentTarget,a=m.clientX,p=m.clientY;if(m.pointerType==="touch"){let D=m.pointerId,_=!1,M=()=>{_=!0,clearTimeout(z),c.removeEventListener("pointermove",A),c.removeEventListener("pointerup",M),c.removeEventListener("pointercancel",M)},A=W=>{Math.hypot(W.clientX-a,W.clientY-p)>Et&&M()},z=setTimeout(()=>{if(_)return;c.removeEventListener("pointermove",A),c.removeEventListener("pointerup",M),c.removeEventListener("pointercancel",M);try{c.setPointerCapture(D)}catch{return}c.classList.add("rdd-long-press-active"),document.body.classList.add("rdd-dragging-active"),navigator.vibrate&&navigator.vibrate(10);let W=!1,T=L=>{W||(W=!0,h(x)),w({x:L.clientX,y:L.clientY}),C(L.clientX,L.clientY)},v=L=>{c.classList.remove("rdd-long-press-active"),document.body.classList.remove("rdd-dragging-active"),c.removeEventListener("pointermove",T),c.removeEventListener("pointerup",v),c.removeEventListener("pointercancel",k),window.removeEventListener("blur",k),W?E(x,L):n(x,L)},k=()=>{c.classList.remove("rdd-long-press-active"),document.body.classList.remove("rdd-dragging-active"),c.removeEventListener("pointermove",T),c.removeEventListener("pointerup",v),c.removeEventListener("pointercancel",k),window.removeEventListener("blur",k),W&&d()};c.addEventListener("pointermove",T),c.addEventListener("pointerup",v),c.addEventListener("pointercancel",k),window.addEventListener("blur",k)},St);c.addEventListener("pointermove",A),c.addEventListener("pointerup",M),c.addEventListener("pointercancel",M)}else{let D=!1,_=z=>{let W=z.clientX-a,T=z.clientY-p;!D&&(Math.abs(W)>5||Math.abs(T)>5)&&(D=!0,h(x)),D&&w({x:z.clientX,y:z.clientY})},M=z=>{document.body.classList.remove("rdd-dragging-active"),window.removeEventListener("pointermove",_),window.removeEventListener("pointerup",M),window.removeEventListener("pointercancel",A),window.removeEventListener("blur",A),D&&E(x,z)},A=()=>{document.body.classList.remove("rdd-dragging-active"),window.removeEventListener("pointermove",_),window.removeEventListener("pointerup",M),window.removeEventListener("pointercancel",A),window.removeEventListener("blur",A),D&&d()};document.body.classList.add("rdd-dragging-active"),window.addEventListener("pointermove",_),window.addEventListener("pointerup",M),window.addEventListener("pointercancel",A),window.addEventListener("blur",A)}}}}import"react";function ai(e){let{state:t,registry:n,messages:o,formatMessage:r,handleRequestClose:i,setHoveredMinimized:u}=e,{floatPanel:l,minimizePanel:d,restorePanel:R,maximizePanel:w,getPanelContextMenuItems:C,showContextMenu:f}=e.actions;return{handleTabRightClick:(I,h)=>{h.preventDefault();let E=t.panels[I];if(!E)return;let x=n.get(E.component)?.defaultOptions,m=[];if(x?.canDrag!==!1&&m.push({label:q(o.floatWindow,r),icon:It.float,action:()=>l(I)}),x?.canMinimize!==!1&&m.push({label:q(o.minimizePanel,r),icon:It.minimize,action:()=>d(I)}),m.length>0&&x?.canClose!==!1&&m.push({separator:!0}),x?.canClose!==!1&&m.push({label:q(o.closeTab,r),icon:It.close,action:()=>i(I)}),m.length===0)return;let c=C(I),a=c.length>0?[...m,{separator:!0},...c]:m;f({event:h,items:a,initialFocus:gn(h)})},handleMinimizedRightClick:(I,h)=>{h.preventDefault(),u(null);let E=t.panels[I],N=E?.previousState==="floating"||n.get(E?.component??"")?.defaultOptions?.canDrag!==!1;f({event:h,initialFocus:gn(h),items:[{label:q(o.restorePanel,r),icon:It.restore,action:()=>R(I)},...N?[{label:q(o.maximizePanel,r),icon:It.maximize,action:()=>w(I)}]:[],{separator:!0},{label:q(o.closePanel,r),icon:It.close,action:()=>i(I)}]})}}}import{useState as ka,useEffect as Ma}from"react";function li(e){let[t,n]=ka({width:1024,height:768});return Ma(()=>{let o=e.current;if(!o)return;let r=!1,i=!1,u=new ResizeObserver(l=>{if(!l||l.length===0)return;let d=l[0].contentRect;if(process.env.NODE_ENV==="development"&&d.height<10&&!r){r=!0;let R=o,w=o.parentElement;for(;w&&w!==document.documentElement&&w.getBoundingClientRect().height<10;){R=w;w=w.parentElement}let C=R.tagName.toLowerCase(),f=R.id?` id="${R.id}"`:"",P=R.className?` class="${R.className}"`:"",b=R===o?"the RddDesktop container itself":`a wrapper element: <${C}${f}${P}>`;console.warn(`[react-dockable-desktop] Workspace height is 0px \u2014 the workspace will be invisible.
|
|
6
6
|
|
|
7
|
-
Zero height found at: ${
|
|
7
|
+
Zero height found at: ${b}
|
|
8
8
|
|
|
9
9
|
Root cause: in CSS, "height: 100%" only works when the parent has an explicit height.
|
|
10
10
|
If any ancestor has height: auto (the default for <div>), the chain breaks and
|
|
@@ -20,10 +20,10 @@ Fix options:
|
|
|
20
20
|
.layout { display: flex; flex-direction: column; height: 100vh; }
|
|
21
21
|
.workspace { flex: 1; min-height: 0; }
|
|
22
22
|
|
|
23
|
-
3. For a workspace that fills the window, put className="rdd-fill-viewport" on its wrapper.`)}process.env.NODE_ENV==="development"&&!
|
|
23
|
+
3. For a workspace that fills the window, put className="rdd-fill-viewport" on its wrapper.`)}process.env.NODE_ENV==="development"&&!i&&d.height>window.innerHeight+1&&document.documentElement.scrollHeight>window.innerHeight+1&&(i=!0,console.warn(`[react-dockable-desktop] The workspace is taller than the window (${Math.round(d.height)}px > ${window.innerHeight}px), so the page scrolls instead of the panels.
|
|
24
24
|
|
|
25
25
|
For a workspace that fills the window, give its wrapper the rdd-fill-viewport class:
|
|
26
26
|
<div className="rdd-fill-viewport"> \u2026 <RddDesktop /> \u2026 </div>
|
|
27
27
|
|
|
28
|
-
(Before 7.0 the stylesheet fixed html, body and #root to 100% height; it no longer styles the host page.)`)),n({width:Math.max(100,d.width),height:Math.max(100,d.height)})});return u.observe(o),()=>{u.disconnect()}},[]),t}import"react";function Qr(e){let{state:t,workspaceSize:n}=e,{activeDropZoneRef:o,hoveredTabRef:r,activeEdgeDropRef:a,activeCornerAnchorRef:u,setActiveCornerAnchor:s,clearDragState:d,flipRtl:C,updateHoverFromPoint:R}=e.targets,{focusPanel:y,updateFloatingPosition:m,dockPanelToWorkspaceEdge:M,movePanelOrder:P,dockPanelToGroup:D,setDraggedPanelId:p}=e.actions;return{startDrag:(f,k)=>{k.preventDefault();let c=t.floating.find(N=>N.id===f);if(!c||c.maximized)return;y(f);let l=k.currentTarget,g=l.closest(".rdd-floating-window"),F=k.clientX,H=k.clientY,S=g?g.offsetLeft:0,A=g?g.offsetTop:0,W=()=>{let N=o.current,w=r.current,h=a.current,x=u.current;if(x)m(f,{anchor:x});else if(h)M(f,C(h));else if(w){let L=w.index;w.side==="right"&&(L+=1),P(f,w.leafId,L)}else N&&D(f,N.leafId,C(N.position));s(null),d()};if(k.pointerType==="touch"){let N=k.pointerId,w=!1,h=()=>{w=!0,clearTimeout(L),l.removeEventListener("pointermove",x),l.removeEventListener("pointerup",h),l.removeEventListener("pointercancel",h)},x=$=>{Math.hypot($.clientX-F,$.clientY-H)>Tt&&h()},L=setTimeout(()=>{if(w)return;l.removeEventListener("pointermove",x),l.removeEventListener("pointerup",h),l.removeEventListener("pointercancel",h);try{l.setPointerCapture(N)}catch{return}l.classList.add("rdd-long-press-active"),document.body.classList.add("rdd-dragging-active"),p(f);let $=j=>{let oe=j.clientX-F,re=j.clientY-H;m(f,{x:S+oe,y:A+re,anchor:null}),R(j.clientX,j.clientY)},Y=()=>{l.classList.remove("rdd-long-press-active"),document.body.classList.remove("rdd-dragging-active"),l.removeEventListener("pointermove",$),l.removeEventListener("pointerup",Y),l.removeEventListener("pointercancel",U),window.removeEventListener("blur",U),W()},U=()=>{l.classList.remove("rdd-long-press-active"),document.body.classList.remove("rdd-dragging-active"),l.removeEventListener("pointermove",$),l.removeEventListener("pointerup",Y),l.removeEventListener("pointercancel",U),window.removeEventListener("blur",U),d()};l.addEventListener("pointermove",$),l.addEventListener("pointerup",Y),l.addEventListener("pointercancel",U),window.addEventListener("blur",U)},Mt);l.addEventListener("pointermove",x),l.addEventListener("pointerup",h),l.addEventListener("pointercancel",h)}else{let N=!1,w=L=>{let $=L.clientX-F,Y=L.clientY-H;!N&&(Math.abs($)>5||Math.abs(Y)>5)&&(N=!0,p(f)),N&&m(f,{x:S+$,y:A+Y,anchor:null})},h=()=>{document.body.classList.remove("rdd-dragging-active"),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",x),window.removeEventListener("blur",x),N&&W()},x=()=>{document.body.classList.remove("rdd-dragging-active"),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",x),window.removeEventListener("blur",x),N&&d()};document.body.classList.add("rdd-dragging-active"),window.addEventListener("pointermove",w),window.addEventListener("pointerup",h),window.addEventListener("pointercancel",x),window.addEventListener("blur",x)}},startResize:(f,k,c)=>{c.preventDefault(),c.stopPropagation();let l=t.floating.find($=>$.id===f);if(!l||l.maximized)return;y(f);let g=c.currentTarget,F=g.closest(".rdd-floating-window"),H={x:F?F.offsetLeft:0,y:F?F.offsetTop:0,w:F?F.offsetWidth:400,h:F?F.offsetHeight:300},S=n.width,A=n.height,W=typeof l.x=="string"?parseFloat(l.x):l.x,N=typeof l.y=="string"?parseFloat(l.y):l.y,w=typeof l.width=="string"?parseFloat(l.width):l.width,h=typeof l.height=="string"?parseFloat(l.height):l.height,x=k==="se"&&Math.abs(W+w-S)<4,L=k==="se"&&Math.abs(N+h-A)<4;Ue({element:g,pointerId:c.pointerId,startClientX:c.clientX,startClientY:c.clientY,captureStart:()=>H,activeClasses:[{el:document.body,classes:["rdd-resizing-active"]}],onMove:($,Y,U)=>{let j=dn(k,$,Y,U,{minW:200,minH:150}),{x:oe,y:re,w:te,h:he}=j;x&&(oe=S-te,oe<0&&(oe=0,te=S)),L&&(re=A-he,re<0&&(re=0,he=A)),m(f,{x:oe,y:re,width:te,height:he})}})}}}import{jsx as Je,jsxs as Do}from"react/jsx-runtime";var gs=({skin:e="vscode",defaultPanelIcon:t,taskbarVisibility:n="autohide",animations:o=!0})=>{let r=an,a=Ce(),u=Ht(),{restorePanel:s,minimizePanel:d,requestClosePanel:C,maximizePanel:R,updateFloatingPosition:y,focusPanel:m,floatPanel:M,setDraggedPanelId:P,dockPanelToGroup:D,movePanelOrder:p,dockPanelToWorkspaceEdge:E,setActivePanel:I,getPanelContextMenuItems:f,showContextMenu:k,registerContextMenuFn:c}=Tn(),{openModal:l}=qe(),g=fe(),F=de(),H=ps.useCallback(O=>{let G=a.panels[O];return C(O,{onConfirm:B=>new Promise(J=>{let ae=B||G?.dirtyOptions,ce=q(G?G.title:F.untitledPanel,g);l(xt,{title:ae?.title||F.unsavedChangesTitle,message:ae?.message||{id:F.unsavedChangesMessage.id,defaultMessage:F.unsavedChangesMessage.defaultMessage,values:{title:ce}},alert:ae?.alert,alertType:ae?.alertType||"danger",useYesNoTitles:!0,onOK:()=>J(!0),onCancel:()=>J(!1)},{size:"small"})})})},[C,a.panels,g,l,F]),{windowClass:S,windowBodyClass:A}=Ze(),W=fs(Kt),N=ct(null);Ie(()=>c(W!==null?O=>W.show(O):O=>N.current?.show(O)),[W,c]);let w=ct(null),[h,x]=Eo(!1),L=ct(null),$=ct(!1),Y=ct(a.minimized.length),[U,j]=Eo(null),oe=ct(null),re=ct("mouse"),[te,he]=Eo(!1),we=W!==null?W.isOpen:te;Ie(()=>()=>{oe.current&&clearTimeout(oe.current)},[]),Ie(()=>{U&&(a.minimized.some(G=>G.id===U.id)||j(null))},[a.minimized,U]),Ie(()=>{if(!U?.fromTouch)return;let O=G=>{G.pointerType!=="touch"||document.querySelector(".rdd-taskbar-item-tooltip")?.contains(G.target)||j(null)};return document.addEventListener("pointerdown",O,{capture:!0}),()=>document.removeEventListener("pointerdown",O,{capture:!0})},[U?.fromTouch]);let ne=jr({setDraggedPanelId:P,isRtl:a.isRtl}),{activeDropZone:Ke,setActiveDropZone:Le,dragPos:$e,activeEdgeDrop:Xe,setActiveEdgeDrop:mt,activeCornerAnchor:Qe,setActiveCornerAnchor:et,hoveredTab:Se,setHoveredTab:pe,handleTabHover:gt,handleHoverDropZone:ee}=ne,{handleTabRightClick:X,handleMinimizedRightClick:Q}=Ur({state:a,registry:u,messages:F,formatMessage:g,handleRequestClose:H,setHoveredMinimized:j,actions:{floatPanel:M,minimizePanel:d,restorePanel:s,maximizePanel:R,getPanelContextMenuItems:f,showContextMenu:k}}),{handleTabDragStart:ie}=qr({state:a,targets:ne,handleTabRightClick:X,actions:{dockPanelToWorkspaceEdge:E,movePanelOrder:p,dockPanelToGroup:D,floatPanel:M,setDraggedPanelId:P}});Ie(()=>{let O=Object.keys(a.panels);for(let G of Array.from(Zt.keys()))O.includes(G)||(Zt.delete(G),Nr(G))},[a.panels]),Ie(()=>{let O=()=>{a.draggedPanelId!==null&&(P(null),Le(null),pe(null))};return window.addEventListener("blur",O),()=>{window.removeEventListener("blur",O)}},[a.draggedPanelId]);let le=ct(null),i=Jr(le);Ie(()=>{let O=i.width,G=i.height;a.floating.forEach(B=>{let J=typeof B.width=="string"?parseFloat(B.width):B.width,ae=typeof B.height=="string"?parseFloat(B.height):B.height,ce=typeof B.x=="string"?parseFloat(B.x):B.x,Re=typeof B.y=="string"?parseFloat(B.y):B.y,Oe=J,ke=ae,Ee=ce,Me=Re,ye=!1;if(Oe>O&&(Oe=Math.max(200,O-20),ye=!0),ke>G&&(ke=Math.max(150,G-40),ye=!0),!B.anchor){let Ne=O-100;Ee>Ne&&(Ee=Math.max(0,Ne),ye=!0);let Zo=G-40;Me>Zo&&(Me=Math.max(0,Zo),ye=!0)}ye&&y(B.id,{x:Ee,y:Me,width:Oe,height:ke})})},[i,a.floating,y]),Ie(()=>{let O=G=>{if(G.button!==0)return;let B=G.target;if(!B||typeof B.closest!="function")return;let J=B.closest(".rdd-floating-window");if(J){let ce=J.getAttribute("data-window-id");ce&&(I(ce),m(ce));return}let ae=B.closest(".rdd-workspace-panel");if(ae){let ce=ae.getAttribute("data-active-panel-id");ce&&I(ce)}};return document.addEventListener("pointerdown",O),()=>{document.removeEventListener("pointerdown",O)}},[m,I]);let{startDrag:b,startResize:T}=Qr({state:a,workspaceSize:i,targets:ne,actions:{focusPanel:m,updateFloatingPosition:y,dockPanelToWorkspaceEdge:E,movePanelOrder:p,dockPanelToGroup:D,setDraggedPanelId:P}}),v=O=>{if(w.current){let G=O==="left"?-150:150;w.current.scrollBy({left:G,behavior:"smooth"})}},_=Io(O=>{L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{L.current=null,$.current||x(!1)},O)},[]),z=Io(()=>{$.current=!0,L.current&&clearTimeout(L.current),x(!0)},[]),K=Io(()=>{$.current=!1,_(400)},[_]);Ie(()=>()=>{L.current&&clearTimeout(L.current)},[]),Ie(()=>{n==="autohide"&&a.minimized.length>Y.current&&(x(!0),_(2e3)),a.minimized.length===0&&($.current=!1),Y.current=a.minimized.length},[a.minimized.length,n,_]);let V=Co(),Z=An();return Ie(()=>(e?document.documentElement.setAttribute("data-rdd-skin",e):document.documentElement.removeAttribute("data-rdd-skin"),()=>{document.documentElement.removeAttribute("data-rdd-skin")}),[e]),Ie(()=>(o?document.documentElement.classList.remove("rdd-no-animations"):document.documentElement.classList.add("rdd-no-animations"),()=>{document.documentElement.classList.remove("rdd-no-animations")}),[o]),Do("div",{className:`rdd-workspace${o?"":" rdd-no-animations"}`,"data-rdd-skin":e,"data-color-scheme":V,dir:a.dir,tabIndex:-1,children:[Do("div",{ref:le,className:`rdd-workspace-viewport${a.draggedPanelId?" rdd-dragging-active":""}`,children:[Je(Kr,{state:a,activeEdgeDrop:Xe,activeCornerAnchor:Qe,setActiveEdgeDrop:mt,setActiveCornerAnchor:et}),Je("div",{className:"rdd-workspace-grid-host",children:a.gridRoot?Je(So,{node:a.gridRoot,path:[],onTabRightClick:X,activeDropZone:Ke,onHoverDropZone:ee,onTabDragStart:ie,hoveredTab:Se,onTabHover:gt,defaultPanelIcon:t,onRequestClosePanel:H}):Je("div",{className:"rdd-empty-workspace-grid",children:q(F.emptyGrid,g)})}),Je(Vr,{state:a,registry:u,windowClass:S,windowBodyClass:A,defaultPanelIcon:t,messages:F,formatMessage:g,setActivePanel:I,focusPanel:m,maximizePanel:R,minimizePanel:d,getPanelContextMenuItems:f,showContextMenu:k,handleRequestClose:H,startDrag:b,startResize:T})]}),Je(Zr,{state:a,registry:u,taskbarVisibility:n,taskbarExpanded:h,expandTaskbar:z,leaveTaskbar:K,scrollTaskbar:v,taskbarRef:w,defaultPanelIcon:t,messages:F,formatMessage:g,lastTaskbarPointerTypeRef:re,hoveredMinimized:U,setHoveredMinimized:j,minimizedTooltipTimeoutRef:oe,isContextMenuOpen:we,handleMinimizedRightClick:Q,handleRequestClose:H,restorePanel:s}),Z&&Object.keys(a.panels).map(O=>{let G=a.panels[O];if(!G)return null;let B=wo(O);return ms(Je(Fr,{panelId:O,children:Je("div",{className:"rdd-panel-content","data-rdd-panel":O,dir:a.dir,children:Ar(O,G,u,F,g)})}),B,O)}),W===null&&Je(r.Component,{ref:N,theme:"dark",formatMessageProvider:g,onShow:()=>he(!0),onHide:()=>he(!1)}),a.draggedPanelId!==null&&!a.floating.some(O=>O.id===a.draggedPanelId)&&Do("div",{className:"rdd-drag-ghost-tab",style:{left:$e.x+12,top:$e.y+12},children:["\u{1F4C4} ",q(a.panels[a.draggedPanelId]?.title||F.untitledPanel,g)]})]})},bs=gs;import{useCallback as mn,useRef as ei,useState as hs,useMemo as vs}from"react";import{Fragment as Rs,jsx as ze,jsxs as Lo}from"react/jsx-runtime";var ys=({modal:e,index:t})=>{let{close:n,openModal:o,updateInstance:r,setDirty:a}=qe(),u=fe(),s=de(),{dir:d}=Ce(),{modalClass:C,modalBodyClass:R}=Ze(),y=ei(null),{id:m,Component:M,props:P,options:D,dirty:p,dirtyOptions:E}=e,I=D,[f,k]=hs(I.icon||null),c=ei(I);c.current=I;let l=q(I.title,u),g=mn(async Y=>{if(Y?.force){n(m);return}if(y.current){if(!await y.current())return;n(m);return}if(p){o(xt,{title:E?.title||s.unsavedChangesTitle,message:E?.message||{id:s.unsavedChangesMessage.id,defaultMessage:s.unsavedChangesMessage.defaultMessage,values:{title:l}},alert:E?.alert,alertType:E?.alertType||"danger",useYesNoTitles:!0,onOK:()=>n(m)},{size:"small"});return}n(m)},[n,o,m,p,E,l,s]),F=mn((Y,U)=>a(m,Y,U),[a,m]),H=mn(Y=>r(m,{options:{...c.current,title:Y}}),[r,m]),S=mn(Y=>k(Y),[]),A=mn(Y=>(y.current=Y,()=>{y.current=null}),[]),W=vs(()=>({requestClose:g,setDirty:F,setTitle:H,setIcon:S,onCloseRequested:A,containerType:"modal",instanceId:m}),[g,F,H,S,A,m]),N=p?`${l} *`:l,w=I.size?`rdd-modal-size-${I.size}`:"rdd-modal-size-auto",h=I.closable!==!1,x=I.bodyPadding,L=x!=null?typeof x=="number"?`${x}px`:x:void 0;it(!0,"modal",()=>{h&&g()});let $=`calc(var(--rdd-z-base, 1000) + 9000 + ${t*10})`;return Lo("div",{className:"rdd-modal-overlay",style:{zIndex:$},dir:d,children:[ze("div",{className:"rdd-modal-curtain",onClick:h?()=>g():void 0}),Lo("div",{className:`rdd-modal-window ${w} ${C??""}`,children:[Lo("div",{className:"rdd-modal-header",children:[f&&ze("div",{className:"rdd-modal-icon",children:f}),ze("h4",{className:"rdd-modal-title",children:N}),h&&ze("button",{className:"rdd-modal-close-button",onClick:()=>g(),title:u(s.closeTooltip),type:"button",children:ze("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:ze("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),ze("div",{className:`rdd-modal-body ${R??""}`,style:L!=null?{padding:L}:void 0,children:ze(Wt,{value:W,children:ze(M,{...P,panelId:m})})})]})]})},Ps=()=>{let{modals:e}=je();return e.length===0?null:ze(Rs,{children:e.map((t,n)=>ze(ys,{modal:t,index:n},t.id))})},xs=Ps;import Cs,{useState as Yn,useEffect as Kn,useRef as Oo,useCallback as Xn,useImperativeHandle as ws,useContext as Zn,useMemo as dt,createContext as ri,forwardRef as ii,memo as ks}from"react";import{jsx as ue,jsxs as Vn}from"react/jsx-runtime";function No(e){return"renderContent"in e}function Ms(e){return"render"in e}function ti(e){return e==null?[]:Array.isArray(e)?e:[e]}var Wo=ri(null),ai=ri(null);function Ts({tabId:e,onClose:t,onOpen:n,setActiveTabId:o,children:r}){let a=dt(()=>({tabId:e,onClose:t,onOpen:n,openTab:u=>o(u)}),[e,t,n,o]);return ue(ai.Provider,{value:a,children:r})}function ni(e,t,n,o){if(Ms(e))return ue(Cs.Fragment,{children:e.render()},e.id??t);if(No(e)){if(e.hidden)return null;let r=n===e.id;return ue("button",{type:"button",onClick:()=>o(e.id),"data-rdd-sidebar-tab":e.id,className:`rdd-sidebar-tab-btn${r?" rdd-active":""}`,title:e.label,"aria-pressed":r,children:e.icon},e.id)}return ue("button",{type:"button",onClick:e.onClick,disabled:e.disabled,className:"rdd-sidebar-tab-btn rdd-sidebar-header-action-btn",title:e.label,"aria-label":e.label,children:e.icon},e.id??t)}var oi=ks(function({tabs:t,headerEntries:n,footerEntries:o,activeTabId:r,isVisible:a,position:u,onTabClick:s}){return ue("div",{className:`rdd-sidebar-strip-wrap${a?"":" rdd-sidebar-strip-wrap--collapsed"}`,children:Vn("div",{className:`rdd-sidebar-tabs-strip rdd-${u}${n.length?" rdd-sidebar-tabs-strip--has-header-action":""}${o.length?" rdd-sidebar-tabs-strip--has-footer-action":""}`,children:[n.length>0&&ue("div",{className:"rdd-sidebar-header-area",children:n.map((d,C)=>ni(d,C,r,s))}),ue("div",{className:"rdd-sidebar-tabs-list",children:t.map(d=>{if(d.hidden)return null;let C=r===d.id;return ue("button",{type:"button",onClick:()=>s(d.id),"data-rdd-sidebar-tab":d.id,className:`rdd-sidebar-tab-btn${C?" rdd-active":""}`,title:d.label,"aria-pressed":C,children:d.icon},d.id)})}),o.length>0&&ue("div",{className:"rdd-sidebar-footer-area",children:o.map((d,C)=>ni(d,C,r,s))})]})})});function Ss({position:e,currentWidth:t,minWidth:n,maxWidth:o,onWidthChange:r,onResizeStart:a,onResizeEnd:u}){return ue("div",{className:"rdd-resizer-bar rdd-resizer-bar--vertical",onPointerDown:d=>{d.preventDefault();let C=d.currentTarget,R=[{el:C,classes:["rdd-active"]},{el:document.body,classes:["rdd-resizing-active","rdd-resizing-col-active"]}];a();let y=e==="right"!==xe(C);Ue({element:C,pointerId:d.pointerId,startClientX:d.clientX,startClientY:d.clientY,captureStart:()=>t,activeClasses:R,onMove:(m,M,P)=>{let D=y?P-m:P+m;r(Math.max(n,Math.min(o,D)))},onEnd:()=>u()})}})}var si=ii(function({position:t="right",tabs:n,headerAction:o,footerAction:r,defaultWidth:a,minWidth:u=150,maxWidth:s=600,onWidthChange:d,activeTabId:C,onActiveTabChange:R,visible:y,onVisibilityChange:m,stripVisible:M,onStripVisibilityChange:P,showCloseButton:D=!1,hideDefaultHeader:p=!1,renderHeader:E,isSecondary:I=!1,children:f},k){let c=Zn(ot)?.dir,l=C!==void 0,g=fe(),F=q(de().closeTooltip,g),[H,S]=Yn(()=>a??280),A=Xn(ee=>{S(ee),d?.(ee)},[d]),[W,N]=Yn(!1),[w,h]=Yn(null),x=l?C:w,L=dt(()=>ti(o),[o]),$=dt(()=>ti(r),[r]),Y=dt(()=>L.filter(No),[L]),U=dt(()=>$.filter(No),[$]),j=dt(()=>[...Y,...n,...U],[Y,n,U]),[oe,re]=Yn(()=>new Set),te=dt(()=>{let ee=new Set(oe);x&&ee.add(x);for(let X of j)X.eagerMount&&ee.add(X.id);return ee},[oe,x,j]),he=Oo(x??null);Kn(()=>{he.current=x??null},[x]);let we=Oo(H);Kn(()=>{we.current=H},[H]);let ne=Xn(ee=>{re(ee!==null?X=>{if(X.has(ee))return X;let Q=new Set(X);return Q.add(ee),Q}:X=>{let Q=!1,ie=new Set(X);for(let le of X){let i=j.find(b=>b.id===le);i&&!i.eagerMount&&!i.preserveState&&(ie.delete(le),Q=!0)}return Q?ie:X}),l||h(ee),R?.(ee)},[l,R,j]);Kn(()=>{x!=null&&!j.some(ee=>ee.id===x)&&ne(null)},[x,j,ne]),ws(k,()=>({openTab:ee=>ne(ee),closeDrawer:()=>ne(null),getActiveTab:()=>he.current,show:()=>m?.(!0),hide:()=>m?.(!1),toggle:()=>m?.(y===!1),showStrip:()=>P?.(!0),hideStrip:()=>P?.(!1),setWidth:ee=>A(Math.max(u,Math.min(s,ee))),getWidth:()=>we.current}),[ne,y,m,P,A,u,s]);let Ke=Xn(ee=>{ne(x===ee?null:ee)},[x,ne]),Le=Xn(()=>ne(null),[ne]),$e=p||E!=null,Xe=Oo(!1);Kn(()=>{process.env.NODE_ENV==="development"&&(!D||!$e||Xe.current||(Xe.current=!0,console.warn('[react-dockable-desktop] `showCloseButton` has no effect because the default header is suppressed (`hideDefaultHeader` is set, or `renderHeader` was passed). The "X" close button only renders as part of the library\'s own default header, which is skipped in this case. Add your own close control inside `renderHeader` (or `renderContent`), wired to its `onClose` parameter or `useSidebarTab().onClose`.')))},[D,$e]);let mt=dt(()=>({openTab:ee=>ne(ee),closeDrawer:()=>ne(null),getActiveTab:()=>he.current,position:t,isSecondary:I}),[ne,t,I]),Qe=y!==!1,et=Qe&&M!==!1,Se=Qe&&x!=null,pe=ue("div",{className:`rdd-sidebar-content-drawer rdd-${t}`,style:{flexBasis:Se?`${H}px`:"0px",minWidth:Se?`${u}px`:"0px",maxWidth:Se?`${s}px`:"0px",transition:W?"none":"flex-basis 0.2s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.2s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.2s cubic-bezier(0.4, 0, 0.2, 1)"},children:j.map(ee=>{if(!te.has(ee.id))return null;let Q=x===ee.id,ie=()=>ne(ee.id);return Vn("div",{className:"rdd-sidebar-pane",style:{display:Q?"flex":"none"},children:[$e?E?.(ee,Le,ie):Vn("div",{className:"rdd-sidebar-drawer-header",children:[ue("span",{className:"rdd-sidebar-header-title",children:ee.label}),D&&ue("button",{type:"button",className:"rdd-sidebar-drawer-close-button",onClick:Le,title:F,"aria-label":F,children:ue("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:ue("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),ue("div",{className:"rdd-sidebar-drawer-body",children:ue(Ts,{tabId:ee.id,onClose:Le,onOpen:ie,setActiveTabId:ne,children:ee.renderContent(ee.id,Le,ie)})})]},ee.id)})}),gt=Se?ue(Ss,{position:t,currentWidth:H,minWidth:u,maxWidth:s,onWidthChange:A,onResizeStart:()=>N(!0),onResizeEnd:()=>N(!1)}):null;return ue(Wo.Provider,{value:mt,children:Vn("div",{className:"rdd-sidebar-layout",dir:c==="rtl"?"rtl":void 0,children:[t==="left"&&ue(oi,{tabs:n,headerEntries:L,footerEntries:$,activeTabId:x,isVisible:et,position:t,onTabClick:Ke}),t==="left"&&pe,t==="left"&>,ue("div",{className:"rdd-sidebar-content",children:f}),t==="right"&>,t==="right"&&pe,t==="right"&&ue(oi,{tabs:n,headerEntries:L,footerEntries:$,activeTabId:x,isVisible:et,position:t,onTabClick:Ke})]})})}),Es=ii(function(t,n){let o=Zn(Wo);if(!o)throw new Error("RddSecondarySidebar must be rendered inside a primary RddSidebar's children");if(o.isSecondary)throw new Error("RddSecondarySidebar cannot be nested inside another RddSecondarySidebar");let r=o.position==="left"?"right":"left";return ue(si,{ref:n,...t,position:r,isSecondary:!0})});function Is(){let e=Zn(Wo);if(!e)throw new Error("useSidebar must be used within <RddSidebar>");return e}function Ds(){let e=Zn(ai);if(!e)throw new Error("useSidebarTab must be used within an RddSidebar tab's renderContent");return e}import{forwardRef as Ls,useImperativeHandle as Os,useState as Ao,useRef as zo,useEffect as Ns,useLayoutEffect as Fo}from"react";import{createPortal as Ws}from"react-dom";import{Fragment as Hs,jsx as De,jsxs as li}from"react/jsx-runtime";function As(e,t,n=!1,o=8){switch(t){case"left":return n?{right:window.innerWidth-e.left+o,top:e.top}:{left:e.right+o,top:e.top};case"right":return n?{left:e.right+o,top:e.top}:{right:window.innerWidth-e.left+o,top:e.top};case"top":return n?{top:e.bottom+o,right:window.innerWidth-e.right}:{top:e.bottom+o,left:e.left};case"bottom":return n?{bottom:window.innerHeight-e.top+o,right:window.innerWidth-e.right}:{bottom:window.innerHeight-e.top+o,left:e.left}}}function zs({item:e,position:t,toolbar:n}){let[o,r]=Ao(!1),[a,u]=Ao(null),[s,d]=Ao(!1),C=zo(null),R=zo(null),y=e.activeItemId!==void 0,m=y?e.activeItemId:n.getActiveInGroup(e.id),M=e.items.find(k=>!("type"in k)&&k.id===m),P=m!==null,D=M?.icon??e.defaultIcon,p=M?.label??e.label,E=()=>{e.disabled||(!o&&C.current&&(u(C.current.getBoundingClientRect()),d(xe(C.current))),r(k=>!k))};Fo(()=>{if(!o||!R.current)return;let k=R.current,c=k.getBoundingClientRect(),l=8;c.right>window.innerWidth-l&&(k.style.left=`${Math.max(l,window.innerWidth-c.width-l)}px`,k.style.right="auto"),c.left<l&&(k.style.left=`${l}px`,k.style.right="auto"),c.bottom>window.innerHeight-l&&(k.style.top=`${Math.max(l,window.innerHeight-c.height-l)}px`,k.style.bottom="auto"),c.top<l&&(k.style.top=`${l}px`,k.style.bottom="auto")},[o]),Ns(()=>{if(!o)return;let k=c=>{let l=c.target;C.current?.contains(l)||R.current?.contains(l)||r(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[o]);let I=()=>{R.current?.contains(document.activeElement)&&C.current?.focus(),r(!1)};Fo(()=>{if(!o)return;let k=Gt(R.current);(k.find(c=>c.getAttribute("aria-checked")==="true")??k[0])?.focus()},[o]);let f=k=>{if(k.key==="Tab"){k.preventDefault(),I();return}nn(k.currentTarget,k.key)&&k.preventDefault()};return it(o,"popup",I),li(Hs,{children:[De("button",{ref:C,type:"button",className:`rdd-toolbar-btn rdd-toolbar-btn-group${P?" rdd-active":""}`,title:p,"aria-label":p,"aria-expanded":o,"aria-haspopup":"menu",disabled:e.disabled,onClick:E,children:D}),o&&a&&Ws(De("div",{ref:R,className:`rdd-toolbar-group-flyout rdd-${t}`,style:As(a,t,s),role:"menu",dir:s?"rtl":"ltr",onKeyDown:f,children:e.items.map((k,c)=>{if("type"in k)return De("div",{className:"rdd-toolbar-group-flyout-sep",role:"separator"},`sep-${c}`);let l=m===k.id;return li("button",{type:"button",className:`rdd-toolbar-group-flyout-item${l?" rdd-active":""}`,disabled:k.disabled,role:"menuitemradio","aria-checked":l,onClick:()=>{y?e.onActiveItemChange?.(k.id):n.setActiveInGroup(e.id,k.id),k.onActivate?.(k.id),I()},children:[De("span",{className:"rdd-toolbar-group-flyout-icon",children:k.icon}),De("span",{className:"rdd-toolbar-group-flyout-label",children:k.label}),k.shortcut&&De("span",{className:"rdd-toolbar-group-flyout-shortcut",children:k.shortcut})]},k.id)})}),document.body)]})}function Fs(e,t,n,o){switch(e.type){case"separator":return De("div",{className:"rdd-toolbar-separator",role:"separator"},`sep-${t}`);case"action":return De("button",{type:"button",className:"rdd-toolbar-btn rdd-toolbar-btn-action",title:e.label,"aria-label":e.label,disabled:e.disabled,onClick:e.onClick,children:e.icon},e.id);case"radio":{let r=n.getActiveInGroup(e.group)===e.id;return De("button",{type:"button",className:`rdd-toolbar-btn rdd-toolbar-btn-radio${r?" rdd-active":""}`,title:e.label,"aria-label":e.label,"aria-pressed":r,disabled:e.disabled,onClick:()=>{n.setActiveInGroup(e.group,e.id),e.onActivate?.(e.id)},children:e.icon},e.id)}case"toggle":{let r=e.active!==void 0,a=r?e.active:n.isModifierActive(e.id);return De("button",{type:"button",className:`rdd-toolbar-btn rdd-toolbar-btn-toggle${a?" rdd-active":""}`,title:e.label,"aria-label":e.label,"aria-pressed":a,disabled:e.disabled,onClick:()=>{r||n.toggleModifier(e.id),e.onToggle?.(!a)},children:e.icon},e.id)}case"group":return De(zs,{item:e,position:o,toolbar:n},e.id)}}var _s=Ls(function({position:t="left",items:n,visible:o,onVisibilityChange:r,className:a,style:u},s){let d=Wn(),C=t==="left"||t==="right";Os(s,()=>({show:()=>r?.(!0),hide:()=>r?.(!1),toggle:()=>r?.(o===!1)}),[o,r]);let R=o===!1,y=R?C?{width:"0px"}:{height:"0px"}:{},m=zo(null);return Fo(()=>{let M=m.current;M&&(R?M.setAttribute("inert",""):M.removeAttribute("inert"))},[R]),De("div",{ref:m,className:`rdd-toolbar-strip rdd-${t}${R?" rdd-collapsed":""}${a?` ${a}`:""}`,role:"toolbar","aria-orientation":C?"vertical":"horizontal","aria-hidden":R||void 0,style:{...y,...u},children:n.map((M,P)=>Fs(M,P,d,t))})});import{useCallback as Ho,useContext as $s,useEffect as gn,useLayoutEffect as Bs,useRef as It,useState as $o}from"react";import{createPortal as ci}from"react-dom";import{jsx as be,jsxs as bn}from"react/jsx-runtime";var Bo=class{listeners=new Set;counter=0;subscribe(t){this.listeners.add(t)}unsubscribe(t){this.listeners.delete(t)}show(t,n={}){let o=n.id??`toast-${++this.counter}`;return this.emit({kind:"show",id:o,message:t,rawOpts:{...n,id:o}}),o}update(t,n,o){this.emit({kind:"update",id:t,message:n,patch:o})}dismiss(t){this.emit({kind:"dismiss",id:t})}emit(t){this.listeners.forEach(n=>n(t))}},Te=new Bo,Gs=Object.assign((e,t)=>Te.show(e,t),{info:(e,t)=>Te.show(e,{...t,type:"info"}),success:(e,t)=>Te.show(e,{...t,type:"success"}),warning:(e,t)=>Te.show(e,{...t,type:"warning"}),error:(e,t)=>Te.show(e,{...t,type:"error"}),dismiss:e=>Te.dismiss(e),promise:(e,t,n)=>{let o=Te.show(t.pending,{...n,type:"info",duration:0});return e.then(r=>{let a=typeof t.success=="function"?t.success(r):t.success;Te.update(o,a,{type:"success",duration:n?.duration??5e3})},r=>{let a=typeof t.error=="function"?t.error(r):t.error;Te.update(o,a,{type:"error",duration:n?.duration??5e3})}),e}}),Ys=()=>bn("svg",{className:"rdd-toast__icon",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[be("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),be("path",{d:"M8 5v.01M8 7.5v3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Ks=()=>bn("svg",{className:"rdd-toast__icon",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[be("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),be("path",{d:"M5 8l2 2 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),Xs=()=>bn("svg",{className:"rdd-toast__icon",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[be("path",{d:"M8 2.5L14 13.5H2L8 2.5z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),be("path",{d:"M8 7v2.5M8 11.5v.01",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Vs=()=>bn("svg",{className:"rdd-toast__icon",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[be("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),be("path",{d:"M5.5 5.5l5 5M10.5 5.5l-5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Zs=()=>be("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:be("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),js={info:be(Ys,{}),success:be(Ks,{}),warning:be(Xs,{}),error:be(Vs,{})};function qs({id:e,message:t,options:n,exiting:o,isLeft:r,showProgress:a,pauseOnHover:u,animation:s,closeLabel:d,onDismiss:C,onExited:R}){let y=It(null),m=It(null),M=It(null),P=It(n.duration),D=It(0),[p,E]=$o(!1),I=s==="none"?"rdd-toast--visible":s==="fade"?"rdd-toast--fade-entering":r?"rdd-toast--entering-left":"rdd-toast--entering",[f,k]=$o(I);Bs(()=>{let S=y.current,A=m.current;if(!S||!A||o)return;let W=()=>{S.style.maxHeight=`${S.scrollHeight}px`};W();let N=new ResizeObserver(W);return N.observe(A),()=>N.disconnect()},[o]),gn(()=>{if(s==="none")return;let S=requestAnimationFrame(()=>k("rdd-toast--visible"));return()=>cancelAnimationFrame(S)},[]);let c=Ho(S=>{S<=0||(D.current=Date.now(),M.current=setTimeout(()=>C(e),S))},[e,C]);gn(()=>(M.current&&clearTimeout(M.current),P.current=n.duration,c(n.duration),()=>{M.current&&clearTimeout(M.current)}),[n.duration,c]),gn(()=>{if(!o)return;let S=y.current;if(!S||s==="none"){R(e);return}let A=N=>{N.propertyName==="max-height"&&R(e)};S.addEventListener("transitionend",A);let W=setTimeout(()=>R(e),520);return()=>{S.removeEventListener("transitionend",A),clearTimeout(W)}},[o,e,R,s]);let l=()=>{!u||n.duration===0||(M.current&&(clearTimeout(M.current),M.current=null,P.current=Math.max(0,P.current-(Date.now()-D.current))),E(!0))},g=()=>{!u||n.duration===0||(E(!1),c(P.current))},F=["rdd-toast",n.type&&`rdd-toast--${n.type}`,f,o&&"rdd-toast--exiting",p&&"rdd-toast--paused"].filter(Boolean).join(" "),H=n.icon!==void 0?n.icon:n.type?js[n.type]:null;return bn("div",{ref:y,role:"status","aria-live":"polite",className:F,onMouseEnter:l,onMouseLeave:g,children:[H&&H,be("div",{ref:m,className:"rdd-toast__body",children:n.content!==void 0?n.content:t}),n.closable&&be("button",{type:"button",className:"rdd-toast__close",onClick:()=>C(e),"aria-label":d,children:be(Zs,{})}),a&&n.duration>0&&be("div",{className:"rdd-toast__progress",style:{animationDuration:`${n.duration}ms`}})]})}function _o(e,t,n){return{id:e.id,type:e.type??"info",duration:e.duration??t,closable:e.closable??n,icon:e.icon,content:e.content,onClose:e.onClose}}function Us({position:e="top-right",maxVisible:t=3,defaultDuration:n=5e3,defaultClosable:o=!0,pauseOnHover:r=!0,animation:a="slide",newestOnTop:u=!1,progressBar:s=!1,width:d=320,adapter:C}){let[R,y]=$o([]),m=fe(),M=de(),P=q(M.notifications,m),D=$s(ot)?.dir,p=An(),E=q(M.closeNotification,m),I=It([]),f=It(R);f.current=R;let k=Ho(H=>{y(S=>S.map(A=>A.id===H?{...A,exiting:!0}:A)),f.current.find(S=>S.id===H)?.options.onClose?.()},[]),c=Ho(H=>{let S=I.current.shift()??null;y(A=>{let W=A.filter(w=>w.id!==H);if(!S)return W;let N=_o(S.rawOpts,n,o);return[...W,{id:S.id,message:S.message,options:N,exiting:!1}]})},[n,o]);if(gn(()=>{if(C)return;let H=S=>{if(S.kind==="show"){let A=_o(S.rawOpts,n,o),W={id:S.id,message:S.message,options:A,exiting:!1},N={id:S.id,message:S.message,rawOpts:S.rawOpts};y(w=>w.find(L=>L.id===S.id)?w.map(L=>L.id===S.id?{...L,message:S.message,options:A}:L):w.filter(L=>!L.exiting).length<t?[...w,W]:(I.current.some(L=>L.id===N.id)||I.current.push(N),w))}else S.kind==="update"?(y(A=>A.map(W=>{if(W.id!==S.id)return W;let N={...W.options,...S.patch,id:W.id};return{...W,message:S.message,options:N}})),I.current=I.current.map(A=>A.id!==S.id?A:{...A,message:S.message,rawOpts:{...A.rawOpts,...S.patch}})):S.kind==="dismiss"&&(S.id===void 0?(y(A=>A.map(W=>({...W,exiting:!0}))),I.current=[]):f.current.some(W=>W.id===S.id)?k(S.id):I.current=I.current.filter(W=>W.id!==S.id))};return Te.subscribe(H),()=>Te.unsubscribe(H)},[C,t,n,o,k]),gn(()=>{if(!C)return;let H=S=>{if(S.kind==="show"){let A=_o(S.rawOpts,n,o);C.show(S.id,S.message,A)}else S.kind==="update"?C.update(S.id,S.message,S.patch):S.kind==="dismiss"&&C.dismiss(S.id)};return Te.subscribe(H),()=>Te.unsubscribe(H)},[C,n,o]),!p)return null;if(C){if(!C.Container)return null;let H=C.Container;return ci(be(H,{position:e}),document.body)}let l=e.endsWith("left"),g="";u===!0&&(g="rdd-toast-container--newest-top"),u===!1&&(g="rdd-toast-container--newest-bottom");let F=["rdd-toast-container",`rdd-toast-container--${e}`,g].filter(Boolean).join(" ");return ci(be("div",{className:F,style:{width:d},role:"region","aria-label":P,dir:D==="rtl"?"rtl":void 0,children:R.map(H=>be(qs,{id:H.id,message:H.message,options:H.options,exiting:H.exiting,isLeft:l,showProgress:s,pauseOnHover:r,animation:a,closeLabel:E,onDismiss:k,onExited:c},H.id))}),document.body)}import{useState as pt,useRef as Pi,useCallback as ft,useMemo as to}from"react";import{createContext as Go}from"react";var jn=Go(null),qn=Go(null),Un=Go(null);var Ye=e=>e==="width"||e==="both",Fe=e=>e==="height"||e==="both",Yo=(e,t)=>t==="inline"?Fe(e)?"both":"width":Ye(e)?"both":"height",hn=(e,t)=>t==="inline"?e==="both"?"height":Ye(e)?null:e:e==="both"?"width":Fe(e)?null:e,Jn=(e,t)=>Fe(t)?[]:Ye(t)?e.startsWith("top-")?["top-left","top-right"]:["bottom-left","bottom-right"]:[e],di=(e,t)=>`${e.startsWith("top-")?"top":"bottom"}-${t}`,ui=(e,t)=>`${t}-${e.endsWith("-right")?"right":"left"}`,Ko=["top-left","top-right","bottom-left","bottom-right"];import Js,{useState as Ut,useContext as yi,useRef as _e,useLayoutEffect as hi,useCallback as Qs,useEffect as vi}from"react";function pi(e){return e==="top-left"?"top-right":e==="top-right"?"top-left":e==="bottom-left"?"bottom-right":"bottom-left"}function fi(e,t,n){let o=e.getBoundingClientRect(),r=t-o.left,a=n-o.top;return r<80&&a<80?"top-left":r>o.width-80&&a<80?"top-right":r<80&&a>o.height-80?"bottom-left":r>o.width-80&&a>o.height-80?"bottom-right":null}var mi=120,gi=60,Dt=8,bi=8,Xo=16,Vo=40;import{jsx as ut,jsxs as Qn}from"react/jsx-runtime";function eo(e){let t=yi(Un);return e.open?ut(el,{ctx:t,...e},e.id):null}function el({id:e,title:t,icon:n,defaultAnchor:o,defaultWidth:r,defaultHeight:a,defaultStretch:u,stretch:s,onPlacementChange:d,stretchable:C=!0,children:R,ctx:y,onClose:m}){let M=yi(ot)?.isRtl??!1,P=fe(),D=de(),[p,E]=Ut("docked"),[I,f]=Ut(o),[k,c]=Ut(u??null),l=s!==void 0,g=l?s??null:k,[F,H]=Ut(null),[S,A]=Ut({w:r,h:a}),W=_e(null),N=_e(p);N.current=p;let w=_e(F);w.current=F;let h=_e(S);h.current=S;let x=_e(g);x.current=g;let L=_e(I);L.current=I;let $=_e(d);$.current=d;let[Y,U]=Ut({inline:!1,block:!1}),j=_e(Y);j.current=Y;let oe=_e(0),re=Qs((X,Q)=>{f(X),l||c(Q),$.current?.({anchor:X,stretch:Q})},[l]),te=_e(null);hi(()=>{p==="docked"&&y?.dockWindow(e,I,g)},[p,I,g]),hi(()=>()=>{y?.undockWindow(e)},[]);let he=_e(!1);vi(()=>{if(process.env.NODE_ENV!=="development"||he.current||p!=="docked"||!Fe(g)||!y)return;let X=I.endsWith("-right")?"right":"left",Q=[`top-${X}`,`bottom-${X}`].flatMap(ie=>y.stacks[ie]??[]).filter(ie=>ie!==e);Q.length!==0&&(he.current=!0,console.warn(`[react-dockable-desktop] RddFloatingWidget "${e}" stretches the block axis (stretch: "${g}") while ${Q.length} other widget(s) are anchored to the same side (${Q.join(", ")}). A block-stretched widget spans the axis that stacking uses to separate siblings, so it cannot stack and will overlap them \u2014 z-order decides which is on top. Either give it a fixed height, or move the other widgets to the opposite side.`))},[p,g,I,y?.stacks,e]),vi(()=>{y?.reportDockedSize(e,S.h)},[S.h]);let we=y?.zOrders[e]??101,ne=!y||y.topId===e,Ke=()=>{let X=W.current?.offsetParent;return{cw:X?.clientWidth??9999,ch:X?.clientHeight??9999}},Le=()=>{let X=y?.insetInlineStart??0,Q=y?.insetInlineEnd??0;return{left:(M?Q:X)+Dt,right:(M?X:Q)+Dt,top:y?.insetTop??0,bottom:y?.insetBottom??0}},$e=()=>{y?.focusWindow(e)},Xe=X=>{if(X.button!==0)return;X.preventDefault();let Q,ie;if(N.current==="docked"){let le=W.current,i=y?.containerRef?.current;if(le&&i){let b=le.getBoundingClientRect(),T=i.getBoundingClientRect();Q=b.left-T.left,ie=b.top-T.top}else Q=Dt,ie=y?.insetTop??0}else Q=w.current?.x??0,ie=w.current?.y??0;te.current={mouseX:X.clientX,mouseY:X.clientY,posX:Q,posY:ie,hasDragged:!1},W.current?.setPointerCapture(X.pointerId)},mt=X=>Q=>{if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let ie=0,le=0;if(N.current==="free")ie=w.current?.x??0,le=w.current?.y??0;else{let V=W.current,Z=V?.offsetParent;if(V&&Z){let O=V.getBoundingClientRect(),G=Z.getBoundingClientRect();ie=O.left-G.left,le=O.top-G.top}}let i=W.current?.getBoundingClientRect(),b={x:ie,y:le,w:Ye(x.current)&&i?i.width:h.current.w,h:Fe(x.current)&&i?i.height:h.current.h},T=X.includes("e")||X.includes("w"),v=X.includes("n")||X.includes("s"),_=!1,z={inline:!1,block:!1},K=()=>{if(_||N.current!=="docked")return;let V=x.current,Z=T&&Ye(V),O=v&&Fe(V);if(!Z&&!O)return;_=!0;let G=V,B=L.current;if(Z){G=hn(G,"inline");let J=X.includes("e");B=di(B,J!==M?"left":"right")}O&&(G=hn(G,"block"),B=ui(B,X.includes("s")?"top":"bottom")),re(B,G)};Ue({element:Q.currentTarget,pointerId:Q.pointerId,startClientX:Q.clientX,startClientY:Q.clientY,captureStart:()=>b,activeClasses:[{el:document.body,classes:["rdd-resizing-active"]}],onMove:(V,Z,O)=>{let{cw:G,ch:B}=Ke(),J=N.current==="docked"?Le():{left:0,right:0,top:0,bottom:0},{x:ae,y:ce,w:Re,h:Oe}=dn(X,V,Z,O,{minW:mi,minH:gi,maxW:G-J.right-O.x,maxH:B-J.bottom-O.y,minX:J.left,minY:J.top});if(K(),N.current==="docked"&&C){let Ee=G-J.left-J.right,Me=B-J.top-J.bottom-oe.current,ye=x.current,Ne={...z};T&&!Ye(ye)&&(Re>=Ee-Xo?Ne.inline=!0:z.inline&&Re<Ee-Vo&&(Ne.inline=!1)),v&&!Fe(ye)&&(Oe>=Me-Xo?Ne.block=!0:z.block&&Oe<Me-Vo&&(Ne.block=!1)),(Ne.inline!==z.inline||Ne.block!==z.block)&&(z=Ne,U(Ne))}let ke=_?hn(hn(x.current,T?"inline":"block"),v?"block":"inline"):x.current;A(Ee=>({w:Ye(ke)?Ee.w:Re,h:Fe(ke)?Ee.h:Oe})),N.current==="free"&&H({x:ae,y:ce})},onEnd:V=>{if(!z.inline&&!z.block){(j.current.inline||j.current.block)&&U({inline:!1,block:!1});return}A(O=>({w:z.inline?V.w:O.w,h:z.block?V.h:O.h}));let Z=x.current;z.inline&&(Z=Yo(Z,"inline")),z.block&&(Z=Yo(Z,"block")),re(L.current,Z),U({inline:!1,block:!1})}})},Qe=X=>{if(te.current){let Q=te.current;if(!Q.hasDragged){if(Math.abs(X.clientX-Q.mouseX)+Math.abs(X.clientY-Q.mouseY)<4)return;if(Q.hasDragged=!0,N.current==="docked"){if(x.current){let _=W.current?.getBoundingClientRect();_&&A({w:Math.round(_.width),h:Math.round(_.height)}),re(L.current,null)}y?.undockWindow(e),E("free")}document.body.classList.add("rdd-dragging-active"),y?.setDraggingId(e)}let{cw:ie,ch:le}=Ke(),i=Math.max(0,Math.min(Q.posX+X.clientX-Q.mouseX,ie-h.current.w)),b=Math.max(0,Math.min(Q.posY+X.clientY-Q.mouseY,le-h.current.h));H({x:i,y:b});let T=y?.containerRef?.current;if(T){let v=fi(T,X.clientX,X.clientY);y?.setHoveredZone(v&&M?pi(v):v)}}},et=()=>{if(te.current?.hasDragged){let X=y?.hoveredZone;X&&(y?.dockWindow(e,X,x.current),E("docked"),H(null),re(X,x.current)),y?.setHoveredZone(null),y?.setDraggingId(null)}document.body.classList.remove("rdd-dragging-active"),te.current=null},Se=()=>{te.current?.hasDragged&&(y?.setHoveredZone(null),y?.setDraggingId(null)),document.body.classList.remove("rdd-dragging-active"),te.current=null},pe;if(p==="docked"&&y){let X=Jn(I,g),Q=0,ie=X.length===0;for(let i of X){let b=y.stacks[i]??[],T=b.indexOf(e);if(T===-1)continue;ie=!0;let v=0;for(let _=0;_<T;_++)v+=(y.dockedSizes[b[_]]??a)+bi;Q=Math.max(Q,v)}oe.current=Q;let le=Le();pe={zIndex:we,transition:"top 0.2s ease, bottom 0.2s ease",opacity:ie?void 0:0,pointerEvents:ie?void 0:"none"},Ye(g)?(pe.insetInlineStart=(y.insetInlineStart??0)+Dt,pe.insetInlineEnd=(y.insetInlineEnd??0)+Dt):(pe[I.endsWith("-right")?"insetInlineEnd":"insetInlineStart"]=Dt,pe.width=S.w),Fe(g)?(pe.top=le.top,pe.bottom=le.bottom):I.startsWith("top-")?(pe.top=le.top+Q,pe.height=S.h):(pe.bottom=le.bottom+Q,pe.height=S.h)}else pe={left:F?.x??0,top:F?.y??0,width:S.w,height:S.h,zIndex:we};let gt=Js.useMemo(()=>{if(p==="free")return["n","ne","e","se","s","sw","w","nw"];let X=I.startsWith("top-")?"s":"n",ie=I.endsWith("-right")!==M?"w":"e",le=Ye(g),i=Fe(g),b=[];return b.push(...le?["e","w"]:[ie]),b.push(...i?["n","s"]:[X]),!le&&!i&&b.push(`${X}${ie}`),b},[p,I,M,g]),ee=Qn("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[ut("line",{x1:"1",y1:"1",x2:"9",y2:"9"}),ut("line",{x1:"9",y1:"1",x2:"1",y2:"9"})]});return Qn("div",{ref:W,dir:M?"rtl":"ltr","data-rdd-widget":e,className:["rdd-panel-float",ne?"rdd-panel-float--active":"",Y.inline||Y.block?"rdd-panel-float--snapping":""].filter(Boolean).join(" "),style:pe,onPointerDown:$e,onPointerMove:Qe,onPointerUp:et,onPointerCancel:Se,children:[Qn("div",{className:"rdd-panel-float__frame",children:[Qn("div",{className:"rdd-panel-float__header",onPointerDown:Xe,children:[n&&ut("span",{className:"rdd-panel-float__icon",children:n}),ut("span",{className:"rdd-panel-float__title",children:q(t,P)}),ut("button",{type:"button",className:"rdd-panel-float__close",onClick:m,onPointerDown:X=>X.stopPropagation(),title:q(D.closeTooltip,P),"aria-label":q(D.closeTooltip,P),children:ee})]}),ut("div",{className:"rdd-panel-float__body",children:R})]}),gt.map(X=>ut("div",{className:`rdd-resize-handle rdd-resize-${X}`,onPointerDown:mt(X)},X))]})}import{Fragment as ol,jsx as Lt,jsxs as nl}from"react/jsx-runtime";function xi({children:e,className:t,style:n}){let[o,r]=pt({}),[a,u]=pt({}),[s,d]=pt({"top-left":[],"top-right":[],"bottom-left":[],"bottom-right":[]}),[C,R]=pt({}),[y,m]=pt(null),[M,P]=pt(null),[D,p]=pt(null),[E,I]=pt(()=>new Map),f=Pi(100),k=Pi(null),c=ft((L,$)=>(r(Y=>({...Y,[L]:$})),()=>r(Y=>{let U={...Y};return delete U[L],U})),[]),l=ft(L=>{f.current+=1;let $=f.current;u(Y=>({...Y,[L]:$})),p(L)},[]),g=ft((L,$,Y=null)=>{let U=Jn($,Y);d(j=>{let oe={"top-left":j["top-left"].filter(te=>te!==L),"top-right":j["top-right"].filter(te=>te!==L),"bottom-left":j["bottom-left"].filter(te=>te!==L),"bottom-right":j["bottom-right"].filter(te=>te!==L)};for(let te of U)oe[te]=[...oe[te],L];return Ko.every(te=>oe[te].length===j[te].length&&oe[te].every((he,we)=>he===j[te][we]))?j:oe})},[]),F=ft(L=>{d($=>({"top-left":$["top-left"].filter(Y=>Y!==L),"top-right":$["top-right"].filter(Y=>Y!==L),"bottom-left":$["bottom-left"].filter(Y=>Y!==L),"bottom-right":$["bottom-right"].filter(Y=>Y!==L)}))},[]),H=ft((L,$)=>{R(Y=>Y[L]===$?Y:{...Y,[L]:$})},[]),S=ft((L,$)=>{I(Y=>{let U=new Map(Y);return U.set(L,$),U})},[]),A=ft(L=>{I($=>{let Y=new Map($);return Y.delete(L),Y})},[]),W=ft(()=>{I(new Map)},[]),N=to(()=>Array.from(E.keys()),[E]),w=to(()=>({registerToolbar:c,insetTop:o.top??0,insetBottom:o.bottom??0}),[c,o]),h=to(()=>({managedWindowIds:N,openManaged:S,closeManaged:A,closeAllManaged:W}),[N,S,A,W]),x=to(()=>({topId:D,zOrders:a,focusWindow:l,containerRef:k,stacks:s,dockedSizes:C,dockWindow:g,undockWindow:F,reportDockedSize:H,draggingId:y,setDraggingId:m,hoveredZone:M,setHoveredZone:P,insetTop:o.top??0,insetBottom:o.bottom??0,insetInlineStart:o.left??0,insetInlineEnd:o.right??0}),[D,a,l,s,C,g,F,H,y,M,o]);return Lt(jn.Provider,{value:w,children:Lt(qn.Provider,{value:h,children:Lt(Un.Provider,{value:x,children:nl("div",{ref:k,className:`rdd-panel-overlay-root${y!==null?" rdd-dragging-active":""}${t?" "+t:""}`,style:n,children:[e,y!==null&&Lt(tl,{hoveredZone:M}),Array.from(E.entries()).map(([L,$])=>Lt(eo,{id:L,title:$.title,icon:$.icon,open:!0,onClose:()=>A(L),defaultAnchor:$.anchor??"top-right",defaultWidth:$.width??320,defaultHeight:$.height??240,defaultStretch:$.stretch,children:$.content},L))]})})})})}function tl({hoveredZone:e}){return Lt(ol,{children:Ko.map(t=>Lt("div",{className:`rdd-panel-float-dropzone rdd-panel-float-dropzone--${t}${e===t?" rdd-panel-float-dropzone--hovered":""}`,"aria-hidden":"true"},t))})}import{useContext as rl,useRef as Ri,useLayoutEffect as il}from"react";import{jsx as Ot}from"react/jsx-runtime";function Ci({position:e,variant:t="transparent",buttonVariant:n="ghost",buttonSize:o,style:r,className:a,children:u}){let s=rl(jn),d=Ri(null),C=Ri(null);il(()=>{let P=d.current;if(!P||!s)return;let D=()=>{let E=e==="top"||e==="bottom"?P.offsetHeight:P.offsetWidth;C.current?.(),C.current=s.registerToolbar(e,E)};D();let p=new ResizeObserver(D);return p.observe(P),()=>{p.disconnect(),C.current?.(),C.current=null}},[e,s?.registerToolbar]);let R={position:"absolute",zIndex:5,pointerEvents:"none",boxSizing:"border-box"};e==="top"?(R.top=0,R.left=0,R.right=0):e==="bottom"?(R.bottom=0,R.left=0,R.right=0):e==="left"?(R.insetInlineStart=0,R.top=s?.insetTop??0,R.bottom=s?.insetBottom??0):(R.insetInlineEnd=0,R.top=s?.insetTop??0,R.bottom=s?.insetBottom??0);let m=e==="left"||e==="right"?{...(s?.insetTop??0)>0?{paddingTop:0}:{},...(s?.insetBottom??0)>0?{paddingBottom:0}:{}}:{},M=o!=null?{"--rdd-panel-toolbar-btn-size":`${o}px`}:{};return Ot("div",{ref:d,className:`rdd-panel-toolbar rdd-panel-toolbar--${e}${a?" "+a:""}`,"data-variant":t,"data-btn-variant":n,style:{...R,...m,...M,...r},children:u})}function wi({icon:e,onClick:t,disabled:n,title:o,variant:r}){return Ot("button",{type:"button",className:"rdd-panel-toolbar-btn",onClick:t,disabled:n,title:o,"aria-label":o,...r?{"data-variant":r}:{},children:e})}function ki({icon:e,active:t,onToggle:n,disabled:o,title:r,variant:a}){return Ot("button",{type:"button",className:`rdd-panel-toolbar-btn${t?" rdd-panel-toolbar-btn--active":""}`,onClick:n,disabled:o,title:r,"aria-label":r,"aria-pressed":t,...a?{"data-variant":a}:{},children:e})}function Mi(){return Ot("span",{className:"rdd-panel-toolbar__sep","aria-hidden":"true"})}function Ti(){return Ot("span",{className:"rdd-panel-toolbar__spacer","aria-hidden":"true"})}function Si({children:e}){return Ot("span",{className:"rdd-panel-toolbar__item",children:e})}function Ei({children:e}){return Ot("div",{className:"rdd-panel-toolbar__center",children:e})}import al,{useState as no,useRef as oo,useMemo as sl,useEffect as ll}from"react";import{createPortal as cl}from"react-dom";import{jsx as He,jsxs as ro}from"react/jsx-runtime";function Ii({placeholder:e,onSearch:t,onSelect:n}){let o=fe(),r=de(),a=q(r.search,o),u=q(r.closeSearch,o),s=e??q(r.searchPlaceholder,o),[d,C]=no(!1),[R,y]=no(""),[m,M]=no([]),[P,D]=no(null),p=oo(null),E=oo(null),I=oo(null),f=oo(null);ll(()=>()=>{I.current?.abort(),f.current&&clearTimeout(f.current)},[]);let k=()=>{C(!0),setTimeout(()=>E.current?.focus({preventScroll:!0}),0)},c=()=>{C(!1),y(""),M([]),D(null),I.current?.abort(),f.current&&clearTimeout(f.current)},l=W=>{let N=W.target.value;if(y(N),I.current?.abort(),f.current&&clearTimeout(f.current),!N.trim()){M([]),D(null);return}f.current=setTimeout(async()=>{let w=new AbortController;I.current=w;try{let h=await t(N,w.signal);if(!w.signal.aborted){M(h);let x=p.current;if(x&&h.length>0){let L=x.getBoundingClientRect(),$=Math.max(L.width,240),Y=L.left;Y+$>window.innerWidth-8&&(Y=window.innerWidth-$-8),D({top:L.bottom+4,left:Y,width:$})}else D(null)}}catch{}},300)},g=W=>{n(W),c()},F=W=>{p.current?.contains(W.relatedTarget)||c()},H=W=>{W.key==="Escape"&&(W.preventDefault(),c())},S=sl(()=>{let W={};for(let N of m){let w=N.group??"";W[w]||(W[w]=[]),W[w].push(N)}return W},[m]),A=ro("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[He("circle",{cx:"6.5",cy:"6.5",r:"4.5"}),He("line",{x1:"10",y1:"10",x2:"14",y2:"14"})]});return d?ro("div",{ref:p,className:"rdd-panel-toolbar-search rdd-panel-toolbar-search--open",onBlur:F,children:[He("button",{type:"button",className:"rdd-panel-toolbar-btn",onClick:c,"aria-label":u,title:u,children:A}),He("input",{ref:E,className:"rdd-panel-toolbar-search__input",type:"text",value:R,onChange:l,onKeyDown:H,placeholder:s,"aria-label":a,autoComplete:"off"}),P&&m.length>0&&cl(He("div",{className:"rdd-panel-toolbar-search__dropdown",style:{top:P.top,left:P.left,width:P.width},onMouseDown:W=>W.preventDefault(),children:Object.entries(S).map(([W,N])=>ro(al.Fragment,{children:[W&&He("div",{className:"rdd-panel-toolbar-search__group",children:W}),N.map(w=>ro("button",{type:"button",className:"rdd-panel-toolbar-search__item",onClick:()=>g(w),children:[w.icon&&He("span",{className:"rdd-panel-toolbar-search__item-icon",children:w.icon}),He("span",{className:"rdd-panel-toolbar-search__item-label",children:w.label}),w.description&&He("span",{className:"rdd-panel-toolbar-search__item-desc",children:w.description})]},w.id))]},W||"__default__"))}),document.body)]}):He("div",{ref:p,className:"rdd-panel-toolbar-search",children:He("button",{type:"button",className:"rdd-panel-toolbar-btn",onClick:k,title:a,"aria-label":a,children:A})})}import{useState as sf,useContext as dl,useCallback as lf,useMemo as ul}from"react";var pl=[];function Di(){let e=dl(qn),t=e?.managedWindowIds??pl;return ul(()=>({open:(n,o)=>e?.openManaged(n,o),close:n=>e?.closeManaged(n),closeAll:()=>e?.closeAllManaged(),isOpen:n=>t.includes(n),openIds:t}),[e,t])}export{Xa as DockableDesktopProvider,Nt as PanelRegistry,xt as RddConfirm,Sa as RddContextMenu,bs as RddDesktop,eo as RddFloatingWidget,xs as RddModals,xi as RddPanelOverlay,Ci as RddPanelToolbar,Es as RddSecondarySidebar,Ta as RddSidePanels,si as RddSidebar,Us as RddToasts,_s as RddToolbar,wi as RddToolbarButton,Ei as RddToolbarCenter,Si as RddToolbarItem,Ii as RddToolbarSearch,Mi as RddToolbarSeparator,Ti as RddToolbarSpacer,ki as RddToolbarToggle,dn as computeResizedRect,va as createWorkspace,Jt as defaultMessages,q as formatLabel,xe as isComputedRtl,la as isElementRtl,At as isSerializable,Ir as sectionToTab,Ue as startPointerDrag,Gs as toast,Po as useActiveContribution,Ca as useBeforeClose,Co as useColorScheme,ma as useContextMenu,Di as useFloatingWidgets,fe as useFormatMessage,Ze as useHostClasses,Ba as useMergedSidebarTabs,$a as useMergedToolbarItems,de as useMessages,ka as useModals,xa as usePanel,$i as usePanelContextMenu,Ha as usePanelContribution,Ra as usePanelEvents,Ai as usePanelSize,wa as useSaveState,Ma as useSidePanels,Is as useSidebar,Ds as useSidebarTab,Wn as useToolbar,ya as useWorkspace,Ce as useWorkspaceState};
|
|
28
|
+
(Before 7.0 the stylesheet fixed html, body and #root to 100% height; it no longer styles the host page.)`)),n({width:Math.max(100,d.width),height:Math.max(100,d.height)})});return u.observe(o),()=>{u.disconnect()}},[]),t}import"react";function ci(e){let{state:t,workspaceSize:n}=e,{activeDropZoneRef:o,hoveredTabRef:r,activeEdgeDropRef:i,activeCornerAnchorRef:u,setActiveCornerAnchor:l,clearDragState:d,flipRtl:R,updateHoverFromPoint:w}=e.targets,{focusPanel:C,updateFloatingPosition:f,dockPanelToWorkspaceEdge:P,movePanelOrder:b,dockPanelToGroup:I,setDraggedPanelId:h}=e.actions;return{startDrag:(x,m)=>{m.preventDefault();let c=t.floating.find(W=>W.id===x);if(!c||c.maximized)return;C(x);let a=m.currentTarget,p=a.closest(".rdd-floating-window"),D=m.clientX,_=m.clientY,M=p?p.offsetLeft:0,A=p?p.offsetTop:0,z=()=>{let W=o.current,T=r.current,v=i.current,k=u.current;if(k)f(x,{anchor:k});else if(v)P(x,R(v));else if(T){let L=T.index;T.side==="right"&&(L+=1),b(x,T.leafId,L)}else W&&I(x,W.leafId,R(W.position));l(null),d()};if(m.pointerType==="touch"){let W=m.pointerId,T=!1,v=()=>{T=!0,clearTimeout(L),a.removeEventListener("pointermove",k),a.removeEventListener("pointerup",v),a.removeEventListener("pointercancel",v)},k=H=>{Math.hypot(H.clientX-D,H.clientY-_)>Et&&v()},L=setTimeout(()=>{if(T)return;a.removeEventListener("pointermove",k),a.removeEventListener("pointerup",v),a.removeEventListener("pointercancel",v);try{a.setPointerCapture(W)}catch{return}a.classList.add("rdd-long-press-active"),document.body.classList.add("rdd-dragging-active"),h(x);let H=K=>{let oe=K.clientX-D,le=K.clientY-_;f(x,{x:M+oe,y:A+le,anchor:null}),w(K.clientX,K.clientY)},Y=()=>{a.classList.remove("rdd-long-press-active"),document.body.classList.remove("rdd-dragging-active"),a.removeEventListener("pointermove",H),a.removeEventListener("pointerup",Y),a.removeEventListener("pointercancel",U),window.removeEventListener("blur",U),z()},U=()=>{a.classList.remove("rdd-long-press-active"),document.body.classList.remove("rdd-dragging-active"),a.removeEventListener("pointermove",H),a.removeEventListener("pointerup",Y),a.removeEventListener("pointercancel",U),window.removeEventListener("blur",U),d()};a.addEventListener("pointermove",H),a.addEventListener("pointerup",Y),a.addEventListener("pointercancel",U),window.addEventListener("blur",U)},St);a.addEventListener("pointermove",k),a.addEventListener("pointerup",v),a.addEventListener("pointercancel",v)}else{let W=!1,T=L=>{let H=L.clientX-D,Y=L.clientY-_;!W&&(Math.abs(H)>5||Math.abs(Y)>5)&&(W=!0,h(x)),W&&f(x,{x:M+H,y:A+Y,anchor:null})},v=()=>{document.body.classList.remove("rdd-dragging-active"),window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",k),window.removeEventListener("blur",k),W&&z()},k=()=>{document.body.classList.remove("rdd-dragging-active"),window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",k),window.removeEventListener("blur",k),W&&d()};document.body.classList.add("rdd-dragging-active"),window.addEventListener("pointermove",T),window.addEventListener("pointerup",v),window.addEventListener("pointercancel",k),window.addEventListener("blur",k)}},startResize:(x,m,c)=>{c.preventDefault(),c.stopPropagation();let a=t.floating.find(H=>H.id===x);if(!a||a.maximized)return;C(x);let p=c.currentTarget,D=p.closest(".rdd-floating-window"),_={x:D?D.offsetLeft:0,y:D?D.offsetTop:0,w:D?D.offsetWidth:400,h:D?D.offsetHeight:300},M=n.width,A=n.height,z=typeof a.x=="string"?parseFloat(a.x):a.x,W=typeof a.y=="string"?parseFloat(a.y):a.y,T=typeof a.width=="string"?parseFloat(a.width):a.width,v=typeof a.height=="string"?parseFloat(a.height):a.height,k=m==="se"&&Math.abs(z+T-M)<4,L=m==="se"&&Math.abs(W+v-A)<4;Qe({element:p,pointerId:c.pointerId,startClientX:c.clientX,startClientY:c.clientY,captureStart:()=>_,activeClasses:[{el:document.body,classes:["rdd-resizing-active"]}],onMove:(H,Y,U)=>{let K=mn(m,H,Y,U,{minW:200,minH:150}),{x:oe,y:le,w:te,h:re}=K;k&&(oe=M-te,oe<0&&(oe=0,te=M)),L&&(le=A-re,le<0&&(le=0,re=A)),f(x,{x:oe,y:le,width:te,height:re})}})}}}import{jsx as et,jsxs as Ho}from"react/jsx-runtime";var Ia=({skin:e="vscode",defaultPanelIcon:t,taskbarVisibility:n="autohide",animations:o=!0})=>{let r=dn,i=we(),u=Bt(),{restorePanel:l,minimizePanel:d,requestClosePanel:R,maximizePanel:w,updateFloatingPosition:C,focusPanel:f,floatPanel:P,setDraggedPanelId:b,dockPanelToGroup:I,movePanelOrder:h,dockPanelToWorkspaceEdge:E,setActivePanel:N,getPanelContextMenuItems:x,showContextMenu:m,registerContextMenuFn:c}=In(),{openModal:a}=Ue(),p=pe(),D=ae(),_=Ta.useCallback(O=>{let G=i.panels[O];return R(O,{onConfirm:B=>new Promise(Q=>{let se=B||G?.dirtyOptions,ue=q(G?G.title:D.untitledPanel,p);a(Je,{title:se?.title||D.unsavedChangesTitle,message:se?.message||{id:D.unsavedChangesMessage.id,defaultMessage:D.unsavedChangesMessage.defaultMessage,values:{title:ue}},alert:se?.alert,alertType:se?.alertType||"danger",useYesNoTitles:!0,onSettled:Q},{size:"small"})})})},[R,i.panels,p,a,D]),{windowClass:M,windowBodyClass:A}=je(),z=Sa(Xt),W=ut(null);Oe(()=>c(z!==null?O=>z.show(O):O=>W.current?.show(O)),[z,c]);let T=ut(null),[v,k]=Fo(!1),L=ut(null),H=ut(!1),Y=ut(i.minimized.length),[U,K]=Fo(null),oe=ut(null),le=ut("mouse"),[te,re]=Fo(!1),Re=z!==null?z.isOpen:te;Oe(()=>()=>{oe.current&&clearTimeout(oe.current)},[]),Oe(()=>{U&&(i.minimized.some(G=>G.id===U.id)||K(null))},[i.minimized,U]),Oe(()=>{if(!U?.fromTouch)return;let O=G=>{G.pointerType!=="touch"||document.querySelector(".rdd-taskbar-item-tooltip")?.contains(G.target)||K(null)};return document.addEventListener("pointerdown",O,{capture:!0}),()=>document.removeEventListener("pointerdown",O,{capture:!0})},[U?.fromTouch]);let ne=ii({setDraggedPanelId:b,isRtl:i.isRtl}),{activeDropZone:Xe,setActiveDropZone:We,dragPos:Ge,activeEdgeDrop:Ve,setActiveEdgeDrop:ht,activeCornerAnchor:tt,setActiveCornerAnchor:nt,hoveredTab:Ee,setHoveredTab:me,handleTabHover:bt,handleHoverDropZone:ee}=ne,{handleTabRightClick:V,handleMinimizedRightClick:J}=ai({state:i,registry:u,messages:D,formatMessage:p,handleRequestClose:_,setHoveredMinimized:K,actions:{floatPanel:P,minimizePanel:d,restorePanel:l,maximizePanel:w,getPanelContextMenuItems:x,showContextMenu:m}}),{handleTabDragStart:ie}=si({state:i,targets:ne,handleTabRightClick:V,actions:{dockPanelToWorkspaceEdge:E,movePanelOrder:h,dockPanelToGroup:I,floatPanel:P,setDraggedPanelId:b}});Oe(()=>{let O=Object.keys(i.panels);for(let G of Array.from(jt.keys()))O.includes(G)||(jt.delete(G),Yr(G))},[i.panels]),Oe(()=>{let O=()=>{i.draggedPanelId!==null&&(b(null),We(null),me(null))};return window.addEventListener("blur",O),()=>{window.removeEventListener("blur",O)}},[i.draggedPanelId]);let de=ut(null),s=li(de);Oe(()=>{let O=s.width,G=s.height;i.floating.forEach(B=>{let Q=typeof B.width=="string"?parseFloat(B.width):B.width,se=typeof B.height=="string"?parseFloat(B.height):B.height,ue=typeof B.x=="string"?parseFloat(B.x):B.x,Ce=typeof B.y=="string"?parseFloat(B.y):B.y,Ae=Q,ke=se,Ie=ue,Me=Ce,ye=!1;if(Ae>O&&(Ae=Math.max(200,O-20),ye=!0),ke>G&&(ke=Math.max(150,G-40),ye=!0),!B.anchor){let ze=O-100;Ie>ze&&(Ie=Math.max(0,ze),ye=!0);let or=G-40;Me>or&&(Me=Math.max(0,or),ye=!0)}ye&&C(B.id,{x:Ie,y:Me,width:Ae,height:ke})})},[s,i.floating,C]),Oe(()=>{let O=G=>{if(G.button!==0)return;let B=G.target;if(!B||typeof B.closest!="function")return;let Q=B.closest(".rdd-floating-window");if(Q){let ue=Q.getAttribute("data-window-id");ue&&(N(ue),f(ue));return}let se=B.closest(".rdd-workspace-panel");if(se){let ue=se.getAttribute("data-active-panel-id");ue&&N(ue)}};return document.addEventListener("pointerdown",O),()=>{document.removeEventListener("pointerdown",O)}},[f,N]);let{startDrag:g,startResize:S}=ci({state:i,workspaceSize:s,targets:ne,actions:{focusPanel:f,updateFloatingPosition:C,dockPanelToWorkspaceEdge:E,movePanelOrder:h,dockPanelToGroup:I,setDraggedPanelId:b}}),y=O=>{if(T.current){let G=O==="left"?-150:150;T.current.scrollBy({left:G,behavior:"smooth"})}},$=_o(O=>{L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{L.current=null,H.current||k(!1)},O)},[]),F=_o(()=>{H.current=!0,L.current&&clearTimeout(L.current),k(!0)},[]),X=_o(()=>{H.current=!1,$(400)},[$]);Oe(()=>()=>{L.current&&clearTimeout(L.current)},[]),Oe(()=>{n==="autohide"&&i.minimized.length>Y.current&&(k(!0),$(2e3)),i.minimized.length===0&&(H.current=!1),Y.current=i.minimized.length},[i.minimized.length,n,$]);let Z=Lo(),j=Gn();return Oe(()=>(e?document.documentElement.setAttribute("data-rdd-skin",e):document.documentElement.removeAttribute("data-rdd-skin"),()=>{document.documentElement.removeAttribute("data-rdd-skin")}),[e]),Oe(()=>(o?document.documentElement.classList.remove("rdd-no-animations"):document.documentElement.classList.add("rdd-no-animations"),()=>{document.documentElement.classList.remove("rdd-no-animations")}),[o]),Ho("div",{className:`rdd-workspace${o?"":" rdd-no-animations"}`,"data-rdd-skin":e,"data-color-scheme":Z,dir:i.dir,tabIndex:-1,children:[Ho("div",{ref:de,className:`rdd-workspace-viewport${i.draggedPanelId?" rdd-dragging-active":""}`,children:[et(ti,{state:i,activeEdgeDrop:Ve,activeCornerAnchor:tt,setActiveEdgeDrop:ht,setActiveCornerAnchor:nt}),et("div",{className:"rdd-workspace-grid-host",children:i.gridRoot?et(zo,{node:i.gridRoot,path:[],onTabRightClick:V,activeDropZone:Xe,onHoverDropZone:ee,onTabDragStart:ie,hoveredTab:Ee,onTabHover:bt,defaultPanelIcon:t,onRequestClosePanel:_}):et("div",{className:"rdd-empty-workspace-grid",children:q(D.emptyGrid,p)})}),et(oi,{state:i,registry:u,windowClass:M,windowBodyClass:A,defaultPanelIcon:t,messages:D,formatMessage:p,setActivePanel:N,focusPanel:f,maximizePanel:w,minimizePanel:d,getPanelContextMenuItems:x,showContextMenu:m,handleRequestClose:_,startDrag:g,startResize:S})]}),et(ri,{state:i,registry:u,taskbarVisibility:n,taskbarExpanded:v,expandTaskbar:F,leaveTaskbar:X,scrollTaskbar:y,taskbarRef:T,defaultPanelIcon:t,messages:D,formatMessage:p,lastTaskbarPointerTypeRef:le,hoveredMinimized:U,setHoveredMinimized:K,minimizedTooltipTimeoutRef:oe,isContextMenuOpen:Re,handleMinimizedRightClick:J,handleRequestClose:_,restorePanel:l}),j&&Object.keys(i.panels).map(O=>{let G=i.panels[O];if(!G)return null;let B=Oo(O);return Ea(et(Zr,{panelId:O,children:et("div",{className:"rdd-panel-content","data-rdd-panel":O,dir:i.dir,children:Xr(O,G,u,D,p)})}),B,O)}),z===null&&et(r.Component,{ref:W,theme:"dark",formatMessageProvider:p,onShow:()=>re(!0),onHide:()=>re(!1)}),i.draggedPanelId!==null&&!i.floating.some(O=>O.id===i.draggedPanelId)&&Ho("div",{className:"rdd-drag-ghost-tab",style:{left:Ge.x+12,top:Ge.y+12},children:["\u{1F4C4} ",q(i.panels[i.draggedPanelId]?.title||D.untitledPanel,p)]})]})},Da=Ia;import{useCallback as Jt,useRef as di,useState as La,useMemo as Oa}from"react";import{Fragment as za,jsx as _e,jsxs as $o}from"react/jsx-runtime";var Na=({modal:e,index:t})=>{let{close:n,openModal:o,updateInstance:r,setDirty:i,onInstanceClose:u}=Ue(),l=pe(),d=ae(),{dir:R}=we(),{modalClass:w,modalBodyClass:C}=je(),f=di(null),{id:P,Component:b,props:I,options:h,dirty:E,dirtyOptions:N}=e,x=h,[m,c]=La(x.icon||null),a=di(x);a.current=x;let p=q(x.title,l),D=Jt(async K=>{if(K?.force){n(P);return}if(f.current){if(!await f.current())return;n(P);return}if(E){o(Je,{title:N?.title||d.unsavedChangesTitle,message:N?.message||{id:d.unsavedChangesMessage.id,defaultMessage:d.unsavedChangesMessage.defaultMessage,values:{title:p}},alert:N?.alert,alertType:N?.alertType||"danger",useYesNoTitles:!0,onOK:()=>n(P)},{size:"small"});return}n(P)},[n,o,P,E,N,p,d]),_=Jt((K,oe)=>i(P,K,oe),[i,P]),M=Jt(K=>r(P,{options:{...a.current,title:K}}),[r,P]),A=Jt(K=>c(K),[]),z=Jt(K=>(f.current=K,()=>{f.current=null}),[]),W=Jt(K=>u(P,K),[u,P]),T=Oa(()=>({requestClose:D,setDirty:_,setTitle:M,setIcon:A,onCloseRequested:z,containerType:"modal",instanceId:P,onClose:W}),[D,W,_,M,A,z,P]),v=E?`${p} *`:p,k=x.size?`rdd-modal-size-${x.size}`:"rdd-modal-size-auto",L=x.closable!==!1,H=x.bodyPadding,Y=H!=null?typeof H=="number"?`${H}px`:H:void 0;at(!0,"modal",()=>{L&&D()});let U=`calc(var(--rdd-z-base, 1000) + 9000 + ${t*10})`;return $o("div",{className:"rdd-modal-overlay",style:{zIndex:U},dir:R,children:[_e("div",{className:"rdd-modal-curtain",onClick:L?()=>D():void 0}),$o("div",{className:`rdd-modal-window ${k} ${w??""}`,children:[$o("div",{className:"rdd-modal-header",children:[m&&_e("div",{className:"rdd-modal-icon",children:m}),_e("h4",{className:"rdd-modal-title",children:v}),L&&_e("button",{className:"rdd-modal-close-button",onClick:()=>D(),title:l(d.closeTooltip),type:"button",children:_e("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:_e("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),_e("div",{className:`rdd-modal-body ${C??""}`,style:Y!=null?{padding:Y}:void 0,children:_e(zt,{value:T,children:_e(b,{...I,panelId:P})})})]})]})},Wa=()=>{let{modals:e}=qe();return e.length===0?null:_e(za,{children:e.map((t,n)=>_e(Na,{modal:t,index:n},t.id))})},Aa=Wa;import Fa,{useState as Un,useEffect as Jn,useRef as Bo,useCallback as Qn,useImperativeHandle as _a,useContext as to,useMemo as pt,createContext as mi,forwardRef as gi,memo as Ha}from"react";import{jsx as fe,jsxs as eo}from"react/jsx-runtime";function Go(e){return"renderContent"in e}function $a(e){return"render"in e}function ui(e){return e==null?[]:Array.isArray(e)?e:[e]}var Yo=mi(null),hi=mi(null);function Ba({tabId:e,onClose:t,onOpen:n,setActiveTabId:o,children:r}){let i=pt(()=>({tabId:e,onClose:t,onOpen:n,openTab:u=>o(u)}),[e,t,n,o]);return fe(hi.Provider,{value:i,children:r})}function pi(e,t,n,o){if($a(e))return fe(Fa.Fragment,{children:e.render()},e.id??t);if(Go(e)){if(e.hidden)return null;let r=n===e.id;return fe("button",{type:"button",onClick:()=>o(e.id),"data-rdd-sidebar-tab":e.id,className:`rdd-sidebar-tab-btn${r?" rdd-active":""}`,title:e.label,"aria-pressed":r,children:e.icon},e.id)}return fe("button",{type:"button",onClick:e.onClick,disabled:e.disabled,className:"rdd-sidebar-tab-btn rdd-sidebar-header-action-btn",title:e.label,"aria-label":e.label,children:e.icon},e.id??t)}var fi=Ha(function({tabs:t,headerEntries:n,footerEntries:o,activeTabId:r,isVisible:i,position:u,onTabClick:l}){return fe("div",{className:`rdd-sidebar-strip-wrap${i?"":" rdd-sidebar-strip-wrap--collapsed"}`,children:eo("div",{className:`rdd-sidebar-tabs-strip rdd-${u}${n.length?" rdd-sidebar-tabs-strip--has-header-action":""}${o.length?" rdd-sidebar-tabs-strip--has-footer-action":""}`,children:[n.length>0&&fe("div",{className:"rdd-sidebar-header-area",children:n.map((d,R)=>pi(d,R,r,l))}),fe("div",{className:"rdd-sidebar-tabs-list",children:t.map(d=>{if(d.hidden)return null;let R=r===d.id;return fe("button",{type:"button",onClick:()=>l(d.id),"data-rdd-sidebar-tab":d.id,className:`rdd-sidebar-tab-btn${R?" rdd-active":""}`,title:d.label,"aria-pressed":R,children:d.icon},d.id)})}),o.length>0&&fe("div",{className:"rdd-sidebar-footer-area",children:o.map((d,R)=>pi(d,R,r,l))})]})})});function Ga({position:e,currentWidth:t,minWidth:n,maxWidth:o,onWidthChange:r,onResizeStart:i,onResizeEnd:u}){return fe("div",{className:"rdd-resizer-bar rdd-resizer-bar--vertical",onPointerDown:d=>{d.preventDefault();let R=d.currentTarget,w=[{el:R,classes:["rdd-active"]},{el:document.body,classes:["rdd-resizing-active","rdd-resizing-col-active"]}];i();let C=e==="right"!==xe(R);Qe({element:R,pointerId:d.pointerId,startClientX:d.clientX,startClientY:d.clientY,captureStart:()=>t,activeClasses:w,onMove:(f,P,b)=>{let I=C?b-f:b+f;r(Math.max(n,Math.min(o,I)))},onEnd:()=>u()})}})}var bi=gi(function({position:t="right",tabs:n,headerAction:o,footerAction:r,defaultWidth:i,minWidth:u=150,maxWidth:l=600,onWidthChange:d,activeTabId:R,onActiveTabChange:w,visible:C,onVisibilityChange:f,stripVisible:P,onStripVisibilityChange:b,showCloseButton:I=!1,hideDefaultHeader:h=!1,renderHeader:E,isSecondary:N=!1,children:x},m){let c=to(it)?.dir,a=R!==void 0,p=pe(),D=q(ae().closeTooltip,p),[_,M]=Un(()=>i??280),A=Qn(ee=>{M(ee),d?.(ee)},[d]),[z,W]=Un(!1),[T,v]=Un(null),k=a?R:T,L=pt(()=>ui(o),[o]),H=pt(()=>ui(r),[r]),Y=pt(()=>L.filter(Go),[L]),U=pt(()=>H.filter(Go),[H]),K=pt(()=>[...Y,...n,...U],[Y,n,U]),[oe,le]=Un(()=>new Set),te=pt(()=>{let ee=new Set(oe);k&&ee.add(k);for(let V of K)V.eagerMount&&ee.add(V.id);return ee},[oe,k,K]),re=Bo(k??null);Jn(()=>{re.current=k??null},[k]);let Re=Bo(_);Jn(()=>{Re.current=_},[_]);let ne=Qn(ee=>{le(ee!==null?V=>{if(V.has(ee))return V;let J=new Set(V);return J.add(ee),J}:V=>{let J=!1,ie=new Set(V);for(let de of V){let s=K.find(g=>g.id===de);s&&!s.eagerMount&&!s.preserveState&&(ie.delete(de),J=!0)}return J?ie:V}),a||v(ee),w?.(ee)},[a,w,K]);Jn(()=>{k!=null&&!K.some(ee=>ee.id===k)&&ne(null)},[k,K,ne]),_a(m,()=>({openTab:ee=>ne(ee),closeDrawer:()=>ne(null),getActiveTab:()=>re.current,show:()=>f?.(!0),hide:()=>f?.(!1),toggle:()=>f?.(C===!1),showStrip:()=>b?.(!0),hideStrip:()=>b?.(!1),setWidth:ee=>A(Math.max(u,Math.min(l,ee))),getWidth:()=>Re.current}),[ne,C,f,b,A,u,l]);let Xe=Qn(ee=>{ne(k===ee?null:ee)},[k,ne]),We=Qn(()=>ne(null),[ne]),Ge=h||E!=null,Ve=Bo(!1);Jn(()=>{process.env.NODE_ENV==="development"&&(!I||!Ge||Ve.current||(Ve.current=!0,console.warn('[react-dockable-desktop] `showCloseButton` has no effect because the default header is suppressed (`hideDefaultHeader` is set, or `renderHeader` was passed). The "X" close button only renders as part of the library\'s own default header, which is skipped in this case. Add your own close control inside `renderHeader` (or `renderContent`), wired to its `onClose` parameter or `useSidebarTab().onClose`.')))},[I,Ge]);let ht=pt(()=>({openTab:ee=>ne(ee),closeDrawer:()=>ne(null),getActiveTab:()=>re.current,position:t,isSecondary:N}),[ne,t,N]),tt=C!==!1,nt=tt&&P!==!1,Ee=tt&&k!=null,me=fe("div",{className:`rdd-sidebar-content-drawer rdd-${t}`,style:{flexBasis:Ee?`${_}px`:"0px",minWidth:Ee?`${u}px`:"0px",maxWidth:Ee?`${l}px`:"0px",transition:z?"none":"flex-basis 0.2s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.2s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.2s cubic-bezier(0.4, 0, 0.2, 1)"},children:K.map(ee=>{if(!te.has(ee.id))return null;let J=k===ee.id,ie=()=>ne(ee.id);return eo("div",{className:"rdd-sidebar-pane",style:{display:J?"flex":"none"},children:[Ge?E?.(ee,We,ie):eo("div",{className:"rdd-sidebar-drawer-header",children:[fe("span",{className:"rdd-sidebar-header-title",children:ee.label}),I&&fe("button",{type:"button",className:"rdd-sidebar-drawer-close-button",onClick:We,title:D,"aria-label":D,children:fe("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:fe("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),fe("div",{className:"rdd-sidebar-drawer-body",children:fe(Ba,{tabId:ee.id,onClose:We,onOpen:ie,setActiveTabId:ne,children:ee.renderContent(ee.id,We,ie)})})]},ee.id)})}),bt=Ee?fe(Ga,{position:t,currentWidth:_,minWidth:u,maxWidth:l,onWidthChange:A,onResizeStart:()=>W(!0),onResizeEnd:()=>W(!1)}):null;return fe(Yo.Provider,{value:ht,children:eo("div",{className:"rdd-sidebar-layout",dir:c==="rtl"?"rtl":void 0,children:[t==="left"&&fe(fi,{tabs:n,headerEntries:L,footerEntries:H,activeTabId:k,isVisible:nt,position:t,onTabClick:Xe}),t==="left"&&me,t==="left"&&bt,fe("div",{className:"rdd-sidebar-content",children:x}),t==="right"&&bt,t==="right"&&me,t==="right"&&fe(fi,{tabs:n,headerEntries:L,footerEntries:H,activeTabId:k,isVisible:nt,position:t,onTabClick:Xe})]})})}),Ya=gi(function(t,n){let o=to(Yo);if(!o)throw new Error("RddSecondarySidebar must be rendered inside a primary RddSidebar's children");if(o.isSecondary)throw new Error("RddSecondarySidebar cannot be nested inside another RddSecondarySidebar");let r=o.position==="left"?"right":"left";return fe(bi,{ref:n,...t,position:r,isSecondary:!0})});function Ka(){let e=to(Yo);if(!e)throw new Error("useSidebar must be used within <RddSidebar>");return e}function Xa(){let e=to(hi);if(!e)throw new Error("useSidebarTab must be used within an RddSidebar tab's renderContent");return e}import{forwardRef as Va,useImperativeHandle as Za,useState as Ko,useRef as Xo,useEffect as ja,useLayoutEffect as Vo}from"react";import{createPortal as qa}from"react-dom";import{Fragment as tl,jsx as Ne,jsxs as vi}from"react/jsx-runtime";function Ua(e,t,n=!1,o=8){switch(t){case"left":return n?{right:window.innerWidth-e.left+o,top:e.top}:{left:e.right+o,top:e.top};case"right":return n?{left:e.right+o,top:e.top}:{right:window.innerWidth-e.left+o,top:e.top};case"top":return n?{top:e.bottom+o,right:window.innerWidth-e.right}:{top:e.bottom+o,left:e.left};case"bottom":return n?{bottom:window.innerHeight-e.top+o,right:window.innerWidth-e.right}:{bottom:window.innerHeight-e.top+o,left:e.left}}}function Ja({item:e,position:t,toolbar:n}){let[o,r]=Ko(!1),[i,u]=Ko(null),[l,d]=Ko(!1),R=Xo(null),w=Xo(null),C=e.activeItemId!==void 0,f=C?e.activeItemId:n.getActiveInGroup(e.id),P=e.items.find(m=>!("type"in m)&&m.id===f),b=f!==null,I=P?.icon??e.defaultIcon,h=P?.label??e.label,E=()=>{e.disabled||(!o&&R.current&&(u(R.current.getBoundingClientRect()),d(xe(R.current))),r(m=>!m))};Vo(()=>{if(!o||!w.current)return;let m=w.current,c=m.getBoundingClientRect(),a=8;c.right>window.innerWidth-a&&(m.style.left=`${Math.max(a,window.innerWidth-c.width-a)}px`,m.style.right="auto"),c.left<a&&(m.style.left=`${a}px`,m.style.right="auto"),c.bottom>window.innerHeight-a&&(m.style.top=`${Math.max(a,window.innerHeight-c.height-a)}px`,m.style.bottom="auto"),c.top<a&&(m.style.top=`${a}px`,m.style.bottom="auto")},[o]),ja(()=>{if(!o)return;let m=c=>{let a=c.target;R.current?.contains(a)||w.current?.contains(a)||r(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[o]);let N=()=>{w.current?.contains(document.activeElement)&&R.current?.focus(),r(!1)};Vo(()=>{if(!o)return;let m=Yt(w.current);(m.find(c=>c.getAttribute("aria-checked")==="true")??m[0])?.focus()},[o]);let x=m=>{if(m.key==="Tab"){m.preventDefault(),N();return}an(m.currentTarget,m.key)&&m.preventDefault()};return at(o,"popup",N),vi(tl,{children:[Ne("button",{ref:R,type:"button",className:`rdd-toolbar-btn rdd-toolbar-btn-group${b?" rdd-active":""}`,title:h,"aria-label":h,"aria-expanded":o,"aria-haspopup":"menu",disabled:e.disabled,onClick:E,children:I}),o&&i&&qa(Ne("div",{ref:w,className:`rdd-toolbar-group-flyout rdd-${t}`,style:Ua(i,t,l),role:"menu",dir:l?"rtl":"ltr",onKeyDown:x,children:e.items.map((m,c)=>{if("type"in m)return Ne("div",{className:"rdd-toolbar-group-flyout-sep",role:"separator"},`sep-${c}`);let a=f===m.id;return vi("button",{type:"button",className:`rdd-toolbar-group-flyout-item${a?" rdd-active":""}`,disabled:m.disabled,role:"menuitemradio","aria-checked":a,onClick:()=>{C?e.onActiveItemChange?.(m.id):n.setActiveInGroup(e.id,m.id),m.onActivate?.(m.id),N()},children:[Ne("span",{className:"rdd-toolbar-group-flyout-icon",children:m.icon}),Ne("span",{className:"rdd-toolbar-group-flyout-label",children:m.label}),m.shortcut&&Ne("span",{className:"rdd-toolbar-group-flyout-shortcut",children:m.shortcut})]},m.id)})}),document.body)]})}function Qa(e,t,n,o){switch(e.type){case"separator":return Ne("div",{className:"rdd-toolbar-separator",role:"separator"},`sep-${t}`);case"action":return Ne("button",{type:"button",className:"rdd-toolbar-btn rdd-toolbar-btn-action",title:e.label,"aria-label":e.label,disabled:e.disabled,onClick:e.onClick,children:e.icon},e.id);case"radio":{let r=n.getActiveInGroup(e.group)===e.id;return Ne("button",{type:"button",className:`rdd-toolbar-btn rdd-toolbar-btn-radio${r?" rdd-active":""}`,title:e.label,"aria-label":e.label,"aria-pressed":r,disabled:e.disabled,onClick:()=>{n.setActiveInGroup(e.group,e.id),e.onActivate?.(e.id)},children:e.icon},e.id)}case"toggle":{let r=e.active!==void 0,i=r?e.active:n.isModifierActive(e.id);return Ne("button",{type:"button",className:`rdd-toolbar-btn rdd-toolbar-btn-toggle${i?" rdd-active":""}`,title:e.label,"aria-label":e.label,"aria-pressed":i,disabled:e.disabled,onClick:()=>{r||n.toggleModifier(e.id),e.onToggle?.(!i)},children:e.icon},e.id)}case"group":return Ne(Ja,{item:e,position:o,toolbar:n},e.id)}}var el=Va(function({position:t="left",items:n,visible:o,onVisibilityChange:r,className:i,style:u},l){let d=Bn(),R=t==="left"||t==="right";Za(l,()=>({show:()=>r?.(!0),hide:()=>r?.(!1),toggle:()=>r?.(o===!1)}),[o,r]);let w=o===!1,C=w?R?{width:"0px"}:{height:"0px"}:{},f=Xo(null);return Vo(()=>{let P=f.current;P&&(w?P.setAttribute("inert",""):P.removeAttribute("inert"))},[w]),Ne("div",{ref:f,className:`rdd-toolbar-strip rdd-${t}${w?" rdd-collapsed":""}${i?` ${i}`:""}`,role:"toolbar","aria-orientation":R?"vertical":"horizontal","aria-hidden":w||void 0,style:{...C,...u},children:n.map((P,b)=>Qa(P,b,d,t))})});import{useCallback as jo,useContext as nl,useEffect as vn,useLayoutEffect as ol,useRef as Lt,useState as qo}from"react";import{createPortal as yi}from"react-dom";import{jsx as be,jsxs as yn}from"react/jsx-runtime";var Uo=class{listeners=new Set;counter=0;subscribe(t){this.listeners.add(t)}unsubscribe(t){this.listeners.delete(t)}show(t,n={}){let o=n.id??`toast-${++this.counter}`;return this.emit({kind:"show",id:o,message:t,rawOpts:{...n,id:o}}),o}update(t,n,o){this.emit({kind:"update",id:t,message:n,patch:o})}dismiss(t){this.emit({kind:"dismiss",id:t})}emit(t){this.listeners.forEach(n=>n(t))}},Se=new Uo,rl=Object.assign((e,t)=>Se.show(e,t),{info:(e,t)=>Se.show(e,{...t,type:"info"}),success:(e,t)=>Se.show(e,{...t,type:"success"}),warning:(e,t)=>Se.show(e,{...t,type:"warning"}),error:(e,t)=>Se.show(e,{...t,type:"error"}),dismiss:e=>Se.dismiss(e),promise:(e,t,n)=>{let o=Se.show(t.pending,{...n,type:"info",duration:0});return e.then(r=>{let i=typeof t.success=="function"?t.success(r):t.success;Se.update(o,i,{type:"success",duration:n?.duration??5e3})},r=>{let i=typeof t.error=="function"?t.error(r):t.error;Se.update(o,i,{type:"error",duration:n?.duration??5e3})}),e}}),il=()=>yn("svg",{className:"rdd-toast__icon",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[be("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),be("path",{d:"M8 5v.01M8 7.5v3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),sl=()=>yn("svg",{className:"rdd-toast__icon",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[be("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),be("path",{d:"M5 8l2 2 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),al=()=>yn("svg",{className:"rdd-toast__icon",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[be("path",{d:"M8 2.5L14 13.5H2L8 2.5z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),be("path",{d:"M8 7v2.5M8 11.5v.01",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),ll=()=>yn("svg",{className:"rdd-toast__icon",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[be("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),be("path",{d:"M5.5 5.5l5 5M10.5 5.5l-5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),cl=()=>be("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:be("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),dl={info:be(il,{}),success:be(sl,{}),warning:be(al,{}),error:be(ll,{})};function ul({id:e,message:t,options:n,exiting:o,isLeft:r,showProgress:i,pauseOnHover:u,animation:l,closeLabel:d,onDismiss:R,onExited:w}){let C=Lt(null),f=Lt(null),P=Lt(null),b=Lt(n.duration),I=Lt(0),[h,E]=qo(!1),N=l==="none"?"rdd-toast--visible":l==="fade"?"rdd-toast--fade-entering":r?"rdd-toast--entering-left":"rdd-toast--entering",[x,m]=qo(N);ol(()=>{let M=C.current,A=f.current;if(!M||!A||o)return;let z=()=>{M.style.maxHeight=`${M.scrollHeight}px`};z();let W=new ResizeObserver(z);return W.observe(A),()=>W.disconnect()},[o]),vn(()=>{if(l==="none")return;let M=requestAnimationFrame(()=>m("rdd-toast--visible"));return()=>cancelAnimationFrame(M)},[]);let c=jo(M=>{M<=0||(I.current=Date.now(),P.current=setTimeout(()=>R(e),M))},[e,R]);vn(()=>(P.current&&clearTimeout(P.current),b.current=n.duration,c(n.duration),()=>{P.current&&clearTimeout(P.current)}),[n.duration,c]),vn(()=>{if(!o)return;let M=C.current;if(!M||l==="none"){w(e);return}let A=W=>{W.propertyName==="max-height"&&w(e)};M.addEventListener("transitionend",A);let z=setTimeout(()=>w(e),520);return()=>{M.removeEventListener("transitionend",A),clearTimeout(z)}},[o,e,w,l]);let a=()=>{!u||n.duration===0||(P.current&&(clearTimeout(P.current),P.current=null,b.current=Math.max(0,b.current-(Date.now()-I.current))),E(!0))},p=()=>{!u||n.duration===0||(E(!1),c(b.current))},D=["rdd-toast",n.type&&`rdd-toast--${n.type}`,x,o&&"rdd-toast--exiting",h&&"rdd-toast--paused"].filter(Boolean).join(" "),_=n.icon!==void 0?n.icon:n.type?dl[n.type]:null;return yn("div",{ref:C,role:"status","aria-live":"polite",className:D,onMouseEnter:a,onMouseLeave:p,children:[_&&_,be("div",{ref:f,className:"rdd-toast__body",children:n.content!==void 0?n.content:t}),n.closable&&be("button",{type:"button",className:"rdd-toast__close",onClick:()=>R(e),"aria-label":d,children:be(cl,{})}),i&&n.duration>0&&be("div",{className:"rdd-toast__progress",style:{animationDuration:`${n.duration}ms`}})]})}function Zo(e,t,n){return{id:e.id,type:e.type??"info",duration:e.duration??t,closable:e.closable??n,icon:e.icon,content:e.content,onClose:e.onClose}}function pl({position:e="top-right",maxVisible:t=3,defaultDuration:n=5e3,defaultClosable:o=!0,pauseOnHover:r=!0,animation:i="slide",newestOnTop:u=!1,progressBar:l=!1,width:d=320,adapter:R}){let[w,C]=qo([]),f=pe(),P=ae(),b=q(P.notifications,f),I=nl(it)?.dir,h=Gn(),E=q(P.closeNotification,f),N=Lt([]),x=Lt(w);x.current=w;let m=jo(_=>{C(M=>M.map(A=>A.id===_?{...A,exiting:!0}:A)),x.current.find(M=>M.id===_)?.options.onClose?.()},[]),c=jo(_=>{let M=N.current.shift()??null;C(A=>{let z=A.filter(T=>T.id!==_);if(!M)return z;let W=Zo(M.rawOpts,n,o);return[...z,{id:M.id,message:M.message,options:W,exiting:!1}]})},[n,o]);if(vn(()=>{if(R)return;let _=M=>{if(M.kind==="show"){let A=Zo(M.rawOpts,n,o),z={id:M.id,message:M.message,options:A,exiting:!1},W={id:M.id,message:M.message,rawOpts:M.rawOpts};C(T=>T.find(L=>L.id===M.id)?T.map(L=>L.id===M.id?{...L,message:M.message,options:A}:L):T.filter(L=>!L.exiting).length<t?[...T,z]:(N.current.some(L=>L.id===W.id)||N.current.push(W),T))}else M.kind==="update"?(C(A=>A.map(z=>{if(z.id!==M.id)return z;let W={...z.options,...M.patch,id:z.id};return{...z,message:M.message,options:W}})),N.current=N.current.map(A=>A.id!==M.id?A:{...A,message:M.message,rawOpts:{...A.rawOpts,...M.patch}})):M.kind==="dismiss"&&(M.id===void 0?(C(A=>A.map(z=>({...z,exiting:!0}))),N.current=[]):x.current.some(z=>z.id===M.id)?m(M.id):N.current=N.current.filter(z=>z.id!==M.id))};return Se.subscribe(_),()=>Se.unsubscribe(_)},[R,t,n,o,m]),vn(()=>{if(!R)return;let _=M=>{if(M.kind==="show"){let A=Zo(M.rawOpts,n,o);R.show(M.id,M.message,A)}else M.kind==="update"?R.update(M.id,M.message,M.patch):M.kind==="dismiss"&&R.dismiss(M.id)};return Se.subscribe(_),()=>Se.unsubscribe(_)},[R,n,o]),!h)return null;if(R){if(!R.Container)return null;let _=R.Container;return yi(be(_,{position:e}),document.body)}let a=e.endsWith("left"),p="";u===!0&&(p="rdd-toast-container--newest-top"),u===!1&&(p="rdd-toast-container--newest-bottom");let D=["rdd-toast-container",`rdd-toast-container--${e}`,p].filter(Boolean).join(" ");return yi(be("div",{className:D,style:{width:d},role:"region","aria-label":b,dir:I==="rtl"?"rtl":void 0,children:w.map(_=>be(ul,{id:_.id,message:_.message,options:_.options,exiting:_.exiting,isLeft:a,showProgress:l,pauseOnHover:r,animation:i,closeLabel:E,onDismiss:m,onExited:c},_.id))}),document.body)}import{useState as mt,useRef as Ii,useCallback as gt,useMemo as lo}from"react";import{createContext as Jo}from"react";var no=Jo(null),oo=Jo(null),ro=Jo(null);var Ke=e=>e==="width"||e==="both",He=e=>e==="height"||e==="both",Qo=(e,t)=>t==="inline"?He(e)?"both":"width":Ke(e)?"both":"height",Pn=(e,t)=>t==="inline"?e==="both"?"height":Ke(e)?null:e:e==="both"?"width":He(e)?null:e,io=(e,t)=>He(t)?[]:Ke(t)?e.startsWith("top-")?["top-left","top-right"]:["bottom-left","bottom-right"]:[e],Pi=(e,t)=>`${e.startsWith("top-")?"top":"bottom"}-${t}`,xi=(e,t)=>`${t}-${e.endsWith("-right")?"right":"left"}`,er=["top-left","top-right","bottom-left","bottom-right"];import fl,{useState as Qt,useContext as Ei,useRef as $e,useLayoutEffect as Ti,useCallback as ml,useEffect as Si}from"react";function Ri(e){return e==="top-left"?"top-right":e==="top-right"?"top-left":e==="bottom-left"?"bottom-right":"bottom-left"}function Ci(e,t,n){let o=e.getBoundingClientRect(),r=t-o.left,i=n-o.top;return r<80&&i<80?"top-left":r>o.width-80&&i<80?"top-right":r<80&&i>o.height-80?"bottom-left":r>o.width-80&&i>o.height-80?"bottom-right":null}var wi=120,ki=60,Ot=8,Mi=8,tr=16,nr=40;import{jsx as ft,jsxs as so}from"react/jsx-runtime";function ao(e){let t=Ei(ro);return e.open?ft(gl,{ctx:t,...e},e.id):null}function gl({id:e,title:t,icon:n,defaultAnchor:o,defaultWidth:r,defaultHeight:i,defaultStretch:u,stretch:l,onPlacementChange:d,stretchable:R=!0,children:w,ctx:C,onClose:f}){let P=Ei(it)?.isRtl??!1,b=pe(),I=ae(),[h,E]=Qt("docked"),[N,x]=Qt(o),[m,c]=Qt(u??null),a=l!==void 0,p=a?l??null:m,[D,_]=Qt(null),[M,A]=Qt({w:r,h:i}),z=$e(null),W=$e(h);W.current=h;let T=$e(D);T.current=D;let v=$e(M);v.current=M;let k=$e(p);k.current=p;let L=$e(N);L.current=N;let H=$e(d);H.current=d;let[Y,U]=Qt({inline:!1,block:!1}),K=$e(Y);K.current=Y;let oe=$e(0),le=ml((V,J)=>{x(V),a||c(J),H.current?.({anchor:V,stretch:J})},[a]),te=$e(null);Ti(()=>{h==="docked"&&C?.dockWindow(e,N,p)},[h,N,p]),Ti(()=>()=>{C?.undockWindow(e)},[]);let re=$e(!1);Si(()=>{if(process.env.NODE_ENV!=="development"||re.current||h!=="docked"||!He(p)||!C)return;let V=N.endsWith("-right")?"right":"left",J=[`top-${V}`,`bottom-${V}`].flatMap(ie=>C.stacks[ie]??[]).filter(ie=>ie!==e);J.length!==0&&(re.current=!0,console.warn(`[react-dockable-desktop] RddFloatingWidget "${e}" stretches the block axis (stretch: "${p}") while ${J.length} other widget(s) are anchored to the same side (${J.join(", ")}). A block-stretched widget spans the axis that stacking uses to separate siblings, so it cannot stack and will overlap them \u2014 z-order decides which is on top. Either give it a fixed height, or move the other widgets to the opposite side.`))},[h,p,N,C?.stacks,e]),Si(()=>{C?.reportDockedSize(e,M.h)},[M.h]);let Re=C?.zOrders[e]??101,ne=!C||C.topId===e,Xe=()=>{let V=z.current?.offsetParent;return{cw:V?.clientWidth??9999,ch:V?.clientHeight??9999}},We=()=>{let V=C?.insetInlineStart??0,J=C?.insetInlineEnd??0;return{left:(P?J:V)+Ot,right:(P?V:J)+Ot,top:C?.insetTop??0,bottom:C?.insetBottom??0}},Ge=()=>{C?.focusWindow(e)},Ve=V=>{if(V.button!==0)return;V.preventDefault();let J,ie;if(W.current==="docked"){let de=z.current,s=C?.containerRef?.current;if(de&&s){let g=de.getBoundingClientRect(),S=s.getBoundingClientRect();J=g.left-S.left,ie=g.top-S.top}else J=Ot,ie=C?.insetTop??0}else J=T.current?.x??0,ie=T.current?.y??0;te.current={mouseX:V.clientX,mouseY:V.clientY,posX:J,posY:ie,hasDragged:!1},z.current?.setPointerCapture(V.pointerId)},ht=V=>J=>{if(J.button!==0)return;J.preventDefault(),J.stopPropagation();let ie=0,de=0;if(W.current==="free")ie=T.current?.x??0,de=T.current?.y??0;else{let Z=z.current,j=Z?.offsetParent;if(Z&&j){let O=Z.getBoundingClientRect(),G=j.getBoundingClientRect();ie=O.left-G.left,de=O.top-G.top}}let s=z.current?.getBoundingClientRect(),g={x:ie,y:de,w:Ke(k.current)&&s?s.width:v.current.w,h:He(k.current)&&s?s.height:v.current.h},S=V.includes("e")||V.includes("w"),y=V.includes("n")||V.includes("s"),$=!1,F={inline:!1,block:!1},X=()=>{if($||W.current!=="docked")return;let Z=k.current,j=S&&Ke(Z),O=y&&He(Z);if(!j&&!O)return;$=!0;let G=Z,B=L.current;if(j){G=Pn(G,"inline");let Q=V.includes("e");B=Pi(B,Q!==P?"left":"right")}O&&(G=Pn(G,"block"),B=xi(B,V.includes("s")?"top":"bottom")),le(B,G)};Qe({element:J.currentTarget,pointerId:J.pointerId,startClientX:J.clientX,startClientY:J.clientY,captureStart:()=>g,activeClasses:[{el:document.body,classes:["rdd-resizing-active"]}],onMove:(Z,j,O)=>{let{cw:G,ch:B}=Xe(),Q=W.current==="docked"?We():{left:0,right:0,top:0,bottom:0},{x:se,y:ue,w:Ce,h:Ae}=mn(V,Z,j,O,{minW:wi,minH:ki,maxW:G-Q.right-O.x,maxH:B-Q.bottom-O.y,minX:Q.left,minY:Q.top});if(X(),W.current==="docked"&&R){let Ie=G-Q.left-Q.right,Me=B-Q.top-Q.bottom-oe.current,ye=k.current,ze={...F};S&&!Ke(ye)&&(Ce>=Ie-tr?ze.inline=!0:F.inline&&Ce<Ie-nr&&(ze.inline=!1)),y&&!He(ye)&&(Ae>=Me-tr?ze.block=!0:F.block&&Ae<Me-nr&&(ze.block=!1)),(ze.inline!==F.inline||ze.block!==F.block)&&(F=ze,U(ze))}let ke=$?Pn(Pn(k.current,S?"inline":"block"),y?"block":"inline"):k.current;A(Ie=>({w:Ke(ke)?Ie.w:Ce,h:He(ke)?Ie.h:Ae})),W.current==="free"&&_({x:se,y:ue})},onEnd:Z=>{if(!F.inline&&!F.block){(K.current.inline||K.current.block)&&U({inline:!1,block:!1});return}A(O=>({w:F.inline?Z.w:O.w,h:F.block?Z.h:O.h}));let j=k.current;F.inline&&(j=Qo(j,"inline")),F.block&&(j=Qo(j,"block")),le(L.current,j),U({inline:!1,block:!1})}})},tt=V=>{if(te.current){let J=te.current;if(!J.hasDragged){if(Math.abs(V.clientX-J.mouseX)+Math.abs(V.clientY-J.mouseY)<4)return;if(J.hasDragged=!0,W.current==="docked"){if(k.current){let $=z.current?.getBoundingClientRect();$&&A({w:Math.round($.width),h:Math.round($.height)}),le(L.current,null)}C?.undockWindow(e),E("free")}document.body.classList.add("rdd-dragging-active"),C?.setDraggingId(e)}let{cw:ie,ch:de}=Xe(),s=Math.max(0,Math.min(J.posX+V.clientX-J.mouseX,ie-v.current.w)),g=Math.max(0,Math.min(J.posY+V.clientY-J.mouseY,de-v.current.h));_({x:s,y:g});let S=C?.containerRef?.current;if(S){let y=Ci(S,V.clientX,V.clientY);C?.setHoveredZone(y&&P?Ri(y):y)}}},nt=()=>{if(te.current?.hasDragged){let V=C?.hoveredZone;V&&(C?.dockWindow(e,V,k.current),E("docked"),_(null),le(V,k.current)),C?.setHoveredZone(null),C?.setDraggingId(null)}document.body.classList.remove("rdd-dragging-active"),te.current=null},Ee=()=>{te.current?.hasDragged&&(C?.setHoveredZone(null),C?.setDraggingId(null)),document.body.classList.remove("rdd-dragging-active"),te.current=null},me;if(h==="docked"&&C){let V=io(N,p),J=0,ie=V.length===0;for(let s of V){let g=C.stacks[s]??[],S=g.indexOf(e);if(S===-1)continue;ie=!0;let y=0;for(let $=0;$<S;$++)y+=(C.dockedSizes[g[$]]??i)+Mi;J=Math.max(J,y)}oe.current=J;let de=We();me={zIndex:Re,transition:"top 0.2s ease, bottom 0.2s ease",opacity:ie?void 0:0,pointerEvents:ie?void 0:"none"},Ke(p)?(me.insetInlineStart=(C.insetInlineStart??0)+Ot,me.insetInlineEnd=(C.insetInlineEnd??0)+Ot):(me[N.endsWith("-right")?"insetInlineEnd":"insetInlineStart"]=Ot,me.width=M.w),He(p)?(me.top=de.top,me.bottom=de.bottom):N.startsWith("top-")?(me.top=de.top+J,me.height=M.h):(me.bottom=de.bottom+J,me.height=M.h)}else me={left:D?.x??0,top:D?.y??0,width:M.w,height:M.h,zIndex:Re};let bt=fl.useMemo(()=>{if(h==="free")return["n","ne","e","se","s","sw","w","nw"];let V=N.startsWith("top-")?"s":"n",ie=N.endsWith("-right")!==P?"w":"e",de=Ke(p),s=He(p),g=[];return g.push(...de?["e","w"]:[ie]),g.push(...s?["n","s"]:[V]),!de&&!s&&g.push(`${V}${ie}`),g},[h,N,P,p]),ee=so("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[ft("line",{x1:"1",y1:"1",x2:"9",y2:"9"}),ft("line",{x1:"9",y1:"1",x2:"1",y2:"9"})]});return so("div",{ref:z,dir:P?"rtl":"ltr","data-rdd-widget":e,className:["rdd-panel-float",ne?"rdd-panel-float--active":"",Y.inline||Y.block?"rdd-panel-float--snapping":""].filter(Boolean).join(" "),style:me,onPointerDown:Ge,onPointerMove:tt,onPointerUp:nt,onPointerCancel:Ee,children:[so("div",{className:"rdd-panel-float__frame",children:[so("div",{className:"rdd-panel-float__header",onPointerDown:Ve,children:[n&&ft("span",{className:"rdd-panel-float__icon",children:n}),ft("span",{className:"rdd-panel-float__title",children:q(t,b)}),ft("button",{type:"button",className:"rdd-panel-float__close",onClick:f,onPointerDown:V=>V.stopPropagation(),title:q(I.closeTooltip,b),"aria-label":q(I.closeTooltip,b),children:ee})]}),ft("div",{className:"rdd-panel-float__body",children:w})]}),bt.map(V=>ft("div",{className:`rdd-resize-handle rdd-resize-${V}`,onPointerDown:ht(V)},V))]})}import{Fragment as vl,jsx as Nt,jsxs as bl}from"react/jsx-runtime";function Di({children:e,className:t,style:n}){let[o,r]=mt({}),[i,u]=mt({}),[l,d]=mt({"top-left":[],"top-right":[],"bottom-left":[],"bottom-right":[]}),[R,w]=mt({}),[C,f]=mt(null),[P,b]=mt(null),[I,h]=mt(null),[E,N]=mt(()=>new Map),x=Ii(100),m=Ii(null),c=gt((L,H)=>(r(Y=>({...Y,[L]:H})),()=>r(Y=>{let U={...Y};return delete U[L],U})),[]),a=gt(L=>{x.current+=1;let H=x.current;u(Y=>({...Y,[L]:H})),h(L)},[]),p=gt((L,H,Y=null)=>{let U=io(H,Y);d(K=>{let oe={"top-left":K["top-left"].filter(te=>te!==L),"top-right":K["top-right"].filter(te=>te!==L),"bottom-left":K["bottom-left"].filter(te=>te!==L),"bottom-right":K["bottom-right"].filter(te=>te!==L)};for(let te of U)oe[te]=[...oe[te],L];return er.every(te=>oe[te].length===K[te].length&&oe[te].every((re,Re)=>re===K[te][Re]))?K:oe})},[]),D=gt(L=>{d(H=>({"top-left":H["top-left"].filter(Y=>Y!==L),"top-right":H["top-right"].filter(Y=>Y!==L),"bottom-left":H["bottom-left"].filter(Y=>Y!==L),"bottom-right":H["bottom-right"].filter(Y=>Y!==L)}))},[]),_=gt((L,H)=>{w(Y=>Y[L]===H?Y:{...Y,[L]:H})},[]),M=gt((L,H)=>{N(Y=>{let U=new Map(Y);return U.set(L,H),U})},[]),A=gt(L=>{N(H=>{let Y=new Map(H);return Y.delete(L),Y})},[]),z=gt(()=>{N(new Map)},[]),W=lo(()=>Array.from(E.keys()),[E]),T=lo(()=>({registerToolbar:c,insetTop:o.top??0,insetBottom:o.bottom??0}),[c,o]),v=lo(()=>({managedWindowIds:W,openManaged:M,closeManaged:A,closeAllManaged:z}),[W,M,A,z]),k=lo(()=>({topId:I,zOrders:i,focusWindow:a,containerRef:m,stacks:l,dockedSizes:R,dockWindow:p,undockWindow:D,reportDockedSize:_,draggingId:C,setDraggingId:f,hoveredZone:P,setHoveredZone:b,insetTop:o.top??0,insetBottom:o.bottom??0,insetInlineStart:o.left??0,insetInlineEnd:o.right??0}),[I,i,a,l,R,p,D,_,C,P,o]);return Nt(no.Provider,{value:T,children:Nt(oo.Provider,{value:v,children:Nt(ro.Provider,{value:k,children:bl("div",{ref:m,className:`rdd-panel-overlay-root${C!==null?" rdd-dragging-active":""}${t?" "+t:""}`,style:n,children:[e,C!==null&&Nt(hl,{hoveredZone:P}),Array.from(E.entries()).map(([L,H])=>Nt(ao,{id:L,title:H.title,icon:H.icon,open:!0,onClose:()=>A(L),defaultAnchor:H.anchor??"top-right",defaultWidth:H.width??320,defaultHeight:H.height??240,defaultStretch:H.stretch,children:H.content},L))]})})})})}function hl({hoveredZone:e}){return Nt(vl,{children:er.map(t=>Nt("div",{className:`rdd-panel-float-dropzone rdd-panel-float-dropzone--${t}${e===t?" rdd-panel-float-dropzone--hovered":""}`,"aria-hidden":"true"},t))})}import{useContext as yl,useRef as Li,useLayoutEffect as Pl}from"react";import{jsx as Wt}from"react/jsx-runtime";function Oi({position:e,variant:t="transparent",buttonVariant:n="ghost",buttonSize:o,style:r,className:i,children:u}){let l=yl(no),d=Li(null),R=Li(null);Pl(()=>{let b=d.current;if(!b||!l)return;let I=()=>{let E=e==="top"||e==="bottom"?b.offsetHeight:b.offsetWidth;R.current?.(),R.current=l.registerToolbar(e,E)};I();let h=new ResizeObserver(I);return h.observe(b),()=>{h.disconnect(),R.current?.(),R.current=null}},[e,l?.registerToolbar]);let w={position:"absolute",zIndex:5,pointerEvents:"none",boxSizing:"border-box"};e==="top"?(w.top=0,w.left=0,w.right=0):e==="bottom"?(w.bottom=0,w.left=0,w.right=0):e==="left"?(w.insetInlineStart=0,w.top=l?.insetTop??0,w.bottom=l?.insetBottom??0):(w.insetInlineEnd=0,w.top=l?.insetTop??0,w.bottom=l?.insetBottom??0);let f=e==="left"||e==="right"?{...(l?.insetTop??0)>0?{paddingTop:0}:{},...(l?.insetBottom??0)>0?{paddingBottom:0}:{}}:{},P=o!=null?{"--rdd-panel-toolbar-btn-size":`${o}px`}:{};return Wt("div",{ref:d,className:`rdd-panel-toolbar rdd-panel-toolbar--${e}${i?" "+i:""}`,"data-variant":t,"data-btn-variant":n,style:{...w,...f,...P,...r},children:u})}function Ni({icon:e,onClick:t,disabled:n,title:o,variant:r}){return Wt("button",{type:"button",className:"rdd-panel-toolbar-btn",onClick:t,disabled:n,title:o,"aria-label":o,...r?{"data-variant":r}:{},children:e})}function Wi({icon:e,active:t,onToggle:n,disabled:o,title:r,variant:i}){return Wt("button",{type:"button",className:`rdd-panel-toolbar-btn${t?" rdd-panel-toolbar-btn--active":""}`,onClick:n,disabled:o,title:r,"aria-label":r,"aria-pressed":t,...i?{"data-variant":i}:{},children:e})}function Ai(){return Wt("span",{className:"rdd-panel-toolbar__sep","aria-hidden":"true"})}function zi(){return Wt("span",{className:"rdd-panel-toolbar__spacer","aria-hidden":"true"})}function Fi({children:e}){return Wt("span",{className:"rdd-panel-toolbar__item",children:e})}function _i({children:e}){return Wt("div",{className:"rdd-panel-toolbar__center",children:e})}import xl,{useState as co,useRef as uo,useMemo as Rl,useEffect as Cl}from"react";import{createPortal as wl}from"react-dom";import{jsx as Be,jsxs as po}from"react/jsx-runtime";function Hi({placeholder:e,onSearch:t,onSelect:n}){let o=pe(),r=ae(),i=q(r.search,o),u=q(r.closeSearch,o),l=e??q(r.searchPlaceholder,o),[d,R]=co(!1),[w,C]=co(""),[f,P]=co([]),[b,I]=co(null),h=uo(null),E=uo(null),N=uo(null),x=uo(null);Cl(()=>()=>{N.current?.abort(),x.current&&clearTimeout(x.current)},[]);let m=()=>{R(!0),setTimeout(()=>E.current?.focus({preventScroll:!0}),0)},c=()=>{R(!1),C(""),P([]),I(null),N.current?.abort(),x.current&&clearTimeout(x.current)},a=z=>{let W=z.target.value;if(C(W),N.current?.abort(),x.current&&clearTimeout(x.current),!W.trim()){P([]),I(null);return}x.current=setTimeout(async()=>{let T=new AbortController;N.current=T;try{let v=await t(W,T.signal);if(!T.signal.aborted){P(v);let k=h.current;if(k&&v.length>0){let L=k.getBoundingClientRect(),H=Math.max(L.width,240),Y=L.left;Y+H>window.innerWidth-8&&(Y=window.innerWidth-H-8),I({top:L.bottom+4,left:Y,width:H})}else I(null)}}catch{}},300)},p=z=>{n(z),c()},D=z=>{h.current?.contains(z.relatedTarget)||c()},_=z=>{z.key==="Escape"&&(z.preventDefault(),c())},M=Rl(()=>{let z={};for(let W of f){let T=W.group??"";z[T]||(z[T]=[]),z[T].push(W)}return z},[f]),A=po("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[Be("circle",{cx:"6.5",cy:"6.5",r:"4.5"}),Be("line",{x1:"10",y1:"10",x2:"14",y2:"14"})]});return d?po("div",{ref:h,className:"rdd-panel-toolbar-search rdd-panel-toolbar-search--open",onBlur:D,children:[Be("button",{type:"button",className:"rdd-panel-toolbar-btn",onClick:c,"aria-label":u,title:u,children:A}),Be("input",{ref:E,className:"rdd-panel-toolbar-search__input",type:"text",value:w,onChange:a,onKeyDown:_,placeholder:l,"aria-label":i,autoComplete:"off"}),b&&f.length>0&&wl(Be("div",{className:"rdd-panel-toolbar-search__dropdown",style:{top:b.top,left:b.left,width:b.width},onMouseDown:z=>z.preventDefault(),children:Object.entries(M).map(([z,W])=>po(xl.Fragment,{children:[z&&Be("div",{className:"rdd-panel-toolbar-search__group",children:z}),W.map(T=>po("button",{type:"button",className:"rdd-panel-toolbar-search__item",onClick:()=>p(T),children:[T.icon&&Be("span",{className:"rdd-panel-toolbar-search__item-icon",children:T.icon}),Be("span",{className:"rdd-panel-toolbar-search__item-label",children:T.label}),T.description&&Be("span",{className:"rdd-panel-toolbar-search__item-desc",children:T.description})]},T.id))]},z||"__default__"))}),document.body)]}):Be("div",{ref:h,className:"rdd-panel-toolbar-search",children:Be("button",{type:"button",className:"rdd-panel-toolbar-btn",onClick:m,title:i,"aria-label":i,children:A})})}import{useState as Af,useContext as kl,useCallback as zf,useMemo as Ml}from"react";var Tl=[];function $i(){let e=kl(oo),t=e?.managedWindowIds??Tl;return Ml(()=>({open:(n,o)=>e?.openManaged(n,o),close:n=>e?.closeManaged(n),closeAll:()=>e?.closeAllManaged(),isOpen:n=>t.includes(n),openIds:t}),[e,t])}export{aa as DockableDesktopProvider,At as PanelRegistry,Co as RddAlert,Je as RddConfirm,Gs as RddContextMenu,Da as RddDesktop,ao as RddFloatingWidget,Aa as RddModals,Di as RddPanelOverlay,Oi as RddPanelToolbar,Ya as RddSecondarySidebar,Bs as RddSidePanels,bi as RddSidebar,pl as RddToasts,el as RddToolbar,Ni as RddToolbarButton,_i as RddToolbarCenter,Fi as RddToolbarItem,Hi as RddToolbarSearch,Ai as RddToolbarSeparator,zi as RddToolbarSpacer,Wi as RddToolbarToggle,mn as computeResizedRect,Os as createWorkspace,en as defaultMessages,q as formatLabel,xe as isComputedRtl,Cs as isElementRtl,Ft as isSerializable,Hr as sectionToTab,Qe as startPointerDrag,rl as toast,Eo as useActiveContribution,Fs as useBeforeClose,Lo as useColorScheme,Es as useContextMenu,$i as useFloatingWidgets,pe as useFormatMessage,je as useHostClasses,oa as useMergedSidebarTabs,na as useMergedToolbarItems,ae as useMessages,Hs as useModals,As as usePanel,Ui as usePanelContextMenu,ta as usePanelContribution,zs as usePanelEvents,Xi as usePanelSize,_s as useSaveState,$s as useSidePanels,Ka as useSidebar,Xa as useSidebarTab,Bn as useToolbar,Ns as useWorkspace,we as useWorkspaceState};
|
|
29
29
|
//# sourceMappingURL=index.js.map
|