react-dockable-desktop 1.1.0 → 1.2.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/dist/index.d.cts CHANGED
@@ -22,8 +22,12 @@ interface PanelRegistryEntry {
22
22
  Component: ComponentType<any>;
23
23
  /** Default metadata settings configuration applied on instantiation. */
24
24
  defaultOptions?: {
25
- /** Tab and window headers text. */
26
- title?: string;
25
+ /** Tab and window headers text — plain string or i18n descriptor. */
26
+ title?: string | {
27
+ id: string;
28
+ defaultMessage?: string;
29
+ values?: Record<string, string | number>;
30
+ };
27
31
  /** Icon placed next to title tags. */
28
32
  icon?: React.ReactNode;
29
33
  /** Initial mounting state inside the desktop layout grid. */
package/dist/index.d.ts CHANGED
@@ -22,8 +22,12 @@ interface PanelRegistryEntry {
22
22
  Component: ComponentType<any>;
23
23
  /** Default metadata settings configuration applied on instantiation. */
24
24
  defaultOptions?: {
25
- /** Tab and window headers text. */
26
- title?: string;
25
+ /** Tab and window headers text — plain string or i18n descriptor. */
26
+ title?: string | {
27
+ id: string;
28
+ defaultMessage?: string;
29
+ values?: Record<string, string | number>;
30
+ };
27
31
  /** Icon placed next to title tags. */
28
32
  icon?: React.ReactNode;
29
33
  /** Initial mounting state inside the desktop layout grid. */
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import ut,{useState as we,useRef as fe,useEffect as ie}from"react";import{createPortal as Tt}from"react-dom";import{createContext as De,useContext as Ae,useState as Yt,useRef as je,useMemo as it,useCallback as Y,useEffect as Xt}from"react";var ot=class{registry=new Map;register(l,r,y){this.registry.set(l,{Component:r,defaultOptions:y})}get(l){return this.registry.get(l)}getRegisteredIds(){return Array.from(this.registry.keys())}},_=new ot;var Oe={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"},anchorToRightEdge:{id:"dockable-desktop-anchorToRightEdge",defaultMessage:"Anchor to Right Edge"},anchorToBottomEdge:{id:"dockable-desktop-anchorToBottomEdge",defaultMessage:"Anchor to Bottom Edge"},windowAnchoringOptions:{id:"dockable-desktop-windowAnchoringOptions",defaultMessage:"Window Anchoring Options"},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"}};import{jsx as We}from"react/jsx-runtime";var ht=De(null),yt=De(null),bt=De(null),vt=De(Oe),Pt=De({}),Pe=()=>Ae(Pt),st=class{listeners={};subscribe(l,r){return this.listeners[l]||(this.listeners[l]=[]),this.listeners[l].push(r),()=>{this.listeners[l]=this.listeners[l].filter(y=>y!==r)}}publish(l,r){this.listeners[l]&&this.listeners[l].forEach(y=>y(r))}},qt={type:"branch",orientation:"vertical",sizes:[.75,.25],children:[{type:"leaf",id:"group-left-top",panels:["main-map","main-editor"],activePanelId:"main-map"},{type:"leaf",id:"group-left-bottom",panels:["system-console","help-docs"],activePanelId:"system-console"}]},jt={"main-map":{id:"main-map",title:"Main Map",component:"mainMap",state:"docked"},"main-editor":{id:"main-editor",title:"Code Editor",component:"editor",state:"docked"},"system-console":{id:"system-console",title:"Console Output",component:"terminal",state:"docked"},"help-docs":{id:"help-docs",title:"Help Center",component:"help",state:"docked"},"live-preview":{id:"live-preview",title:"Live Preview Output",component:"preview",state:"floating"}},Kt=[{id:"live-preview",x:450,y:200,width:320,height:250,z:1e3}],Ut=({children:i,formatMessage:l,predefinedMessages:r,dir:y,modalClass:N,modalBodyClass:C,sidePanelClass:W,sidePanelBodyClass:E,windowClass:w,windowBodyClass:M})=>{let[S,d]=Yt({gridRoot:qt,floating:Kt,minimized:[],panels:jt,draggedPanelId:null,activePanelId:"main-map",dir:y||"ltr",isRtl:y==="rtl"}),P=je(S);P.current=S;let b=je({}),T=it(()=>({...Oe,...r}),[r]),F=je(new st),p=je(1e3),h=Y((t,s)=>F.current.subscribe(t,s),[]),u=Y((t,s)=>{F.current.publish(t,s)},[]),R=Y((t,s)=>{let n=typeof t.x=="string"?parseFloat(t.x):t.x,e=typeof t.y=="string"?parseFloat(t.y):t.y,a=typeof t.width=="string"?parseFloat(t.width):t.width,o=typeof t.height=="string"?parseFloat(t.height):t.height;isNaN(n)&&(n=300),isNaN(e)&&(e=150),isNaN(a)&&(a=450),isNaN(o)&&(o=350);let m=O=>s.some(D=>{let k=typeof D.x=="string"?parseFloat(D.x):D.x,L=typeof D.y=="string"?parseFloat(D.y):D.y;return!D.maximized&&Math.abs(k-O.x)<20&&Math.abs(L-O.y)<20}),c=0;for(;m({x:n,y:e})&&c<10;)n+=30,e+=30,c++;let v=Math.max(100,window.innerWidth||1024),x=Math.max(100,window.innerHeight||768);return(n+a>v||e+o>x)&&(n=100+c%5*30,e=100+c%5*30),n=Math.max(0,Math.min(n,v-100)),e=Math.max(0,Math.min(e,x-40)),{x:n,y:e,width:a,height:o}},[]),A=Y(t=>{p.current+=1;let s=p.current;d(n=>{let e=n.panels[t];if(!e)return n;if(e.state==="floating")return{...n,floating:n.floating.map(a=>a.id===t?{...a,z:s}:a),activePanelId:t};if(e.state==="docked"){let a=o=>o.type==="leaf"?o.panels.includes(t)?{...o,activePanelId:t}:o:{...o,children:o.children.map(a)};return{...n,gridRoot:a(n.gridRoot),activePanelId:t}}return{...n,activePanelId:t}})},[]),H=(t,s)=>{if(t.type==="leaf"){let n=t.panels.indexOf(s);if(n===-1)return t;let e=t.panels.filter(m=>m!==s),a=t.activePanelId===s?e[n]||e[n-1]||e[0]||null:t.activePanelId,o={...t,panels:e,activePanelId:a};return e.length===0&&!t.keepOnEmpty?null:o}else{let n=t.children.map(o=>H(o,s)).filter(o=>o!==null);if(n.length===0)return null;if(n.length===1)return n[0];let e=t.sizes.slice(0,n.length),a=e.reduce((o,m)=>o+m,0);return{...t,children:n,sizes:e.map(o=>o/a)}}},f=(t,s,n)=>{if(t.type==="leaf"){if(t.id===s){let e=t.panels.includes(n)?t.panels:[...t.panels,n];return{...t,panels:e,activePanelId:n}}return t}else return{...t,children:t.children.map(e=>f(e,s,n))}},I=t=>{if(t.type==="leaf")return t.id;for(let s of t.children){let n=I(s);if(n)return n}return null},z=Y((t,s,n)=>{d(e=>{let a=e.panels[t],o=_.get(s),m=n?.title||n?.title||o?.defaultOptions?.title||t,c=n?.initialTarget||o?.defaultOptions?.initialTarget||"docked",v=o?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350};if(a)if(a.state==="minimized"){let k=e.minimized.filter(L=>L.id!==t);if(c==="floating"||!e.gridRoot){p.current+=1;let L=R(v,e.floating);return{...e,minimized:k,floating:[...e.floating,{...L,id:t,z:p.current}],panels:{...e.panels,[t]:{...a,state:"floating"}}}}else{let L=I(e.gridRoot)||"group-left-top";return{...e,minimized:k,gridRoot:f(e.gridRoot,L,t),panels:{...e.panels,[t]:{...a,state:"docked"}}}}}else{if(a.state==="floating")return A(t),e;{let k=L=>L.type==="leaf"?L.panels.includes(t)?{...L,activePanelId:t}:L:{...L,children:L.children.map(k)};return{...e,gridRoot:k(e.gridRoot)}}}let O={id:t,title:m,component:s,state:c==="tabbed"?"docked":c},D={...e.panels,[t]:O};if(c==="floating"){p.current+=1;let k=R(v,e.floating),L=n?.stickyRight??o?.defaultOptions?.defaultStickyRight??!1,j=n?.stickyBottom??o?.defaultOptions?.defaultStickyBottom??!1,J=Math.max(100,window.innerWidth||1024),Q=Math.max(100,window.innerHeight||768),re=typeof k.width=="string"?parseFloat(k.width):k.width,ge=typeof k.height=="string"?parseFloat(k.height):k.height,be=k.x,Re=k.y,Ee=10;return L&&(be=J-re-Ee),j&&(Re=Q-ge-Ee),{...e,floating:[...e.floating,{...k,id:t,z:p.current,x:be,y:Re,stickyRight:L,stickyBottom:j}],panels:D}}else{let k=I(e.gridRoot)||"group-left-top";return{...e,gridRoot:f(e.gridRoot,k,t),panels:D}}})},[R,A]),B=Y(t=>{d(s=>{let n=s.panels[t];if(!n||_.get(n.component)?.defaultOptions?.canClose===!1)return s;delete b.current[t];let a={...s.panels};delete a[t];let o=H(s.gridRoot,t);return{...s,gridRoot:o||{type:"leaf",id:"group-default",panels:[],activePanelId:null},floating:s.floating.filter(m=>m.id!==t),minimized:s.minimized.filter(m=>m.id!==t),panels:a}})},[]),$=Y((t,s)=>{b.current[t]=s},[]),Z=Y(t=>{delete b.current[t]},[]),ne=Y((t,s,n)=>{d(e=>{let a=e.panels[t];return a?{...e,panels:{...e.panels,[t]:{...a,dirty:s,dirtyOptions:n}}}:e})},[]),ce=Y((t,s)=>{d(n=>{let e=n.panels[t];return e?{...n,panels:{...n.panels,[t]:{...e,title:s}}}:n})},[]),q=Y(async(t,s)=>{if(s?.force){B(t);return}let n=b.current[t];if(n&&!await n())return;let e=P.current.panels[t];if(e?.dirty)if(s?.onConfirm){if(!await s.onConfirm(e.dirtyOptions))return}else return;B(t)},[B]),V=Y(t=>{d(s=>{let n=s.panels[t];if(!n||n.state==="minimized"||_.get(n.component)?.defaultOptions?.canMinimize===!1)return s;let a,o;if(n.state==="floating"){let c=s.floating.find(v=>v.id===t);c&&(a={x:c.x,y:c.y,width:c.width,height:c.height,stickyRight:c.stickyRight,stickyBottom:c.stickyBottom})}else if(n.state==="docked"){let c=v=>{if(v.type==="leaf")return v.panels.includes(t)?v.id:null;for(let x of v.children){let O=c(x);if(O)return O}return null};o=c(s.gridRoot)}let m=H(s.gridRoot,t);return{...s,gridRoot:m||{type:"leaf",id:"group-default",panels:[],activePanelId:null},floating:s.floating.filter(c=>c.id!==t),minimized:[...s.minimized,{id:t,title:n.title,component:n.component}],panels:{...s.panels,[t]:{...n,state:"minimized",previousState:n.state,lastFloatingRect:a,lastLeafId:o}}}})},[]),ee=Y(t=>{d(s=>{let n=s.panels[t];if(!n||n.state!=="minimized")return s;let e=s.minimized.filter(o=>o.id!==t);if((n.previousState||"docked")==="floating"){p.current+=1;let o=_.get(n.component),m=n.lastFloatingRect||o?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},c=R(m,s.floating);return{...s,minimized:e,floating:[...s.floating,{...c,id:t,z:p.current,stickyRight:!!n.lastFloatingRect?.stickyRight,stickyBottom:!!n.lastFloatingRect?.stickyBottom}],panels:{...s.panels,[t]:{...n,state:"floating"}}}}else{let o=(x,O)=>x.type==="leaf"?x.id===O:x.children.some(D=>o(D,O)),m=n.lastLeafId&&o(s.gridRoot,n.lastLeafId),c=_.get(n.component),v=c?.defaultOptions?.canDrag!==!1;if(m)return{...s,minimized:e,gridRoot:f(s.gridRoot,n.lastLeafId,t),panels:{...s.panels,[t]:{...n,state:"docked"}}};if(v){p.current+=1;let x=n.lastFloatingRect||c?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},O=R(x,s.floating);return{...s,minimized:e,floating:[...s.floating,{...O,id:t,z:p.current,stickyRight:!!n.lastFloatingRect?.stickyRight,stickyBottom:!!n.lastFloatingRect?.stickyBottom}],panels:{...s.panels,[t]:{...n,state:"floating"}}}}else{let x=I(s.gridRoot)||"group-left-top";return{...s,minimized:e,gridRoot:f(s.gridRoot,x,t),panels:{...s.panels,[t]:{...n,state:"docked"}}}}}})},[R]),me=Y((t,s)=>{d(n=>{let e=n.panels[t];if(!e||_.get(e.component)?.defaultOptions?.canDrag===!1)return n;let o=_.get(e.component),m=s||o?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},c=H(n.gridRoot,t);p.current+=1;let v=R(m,n.floating);return{...n,gridRoot:c||{type:"leaf",id:"group-default",panels:[],activePanelId:null},floating:[...n.floating,{...v,id:t,z:p.current}],panels:{...n.panels,[t]:{...e,state:"floating"}}}})},[R]),he=Y((t,s)=>{d(n=>{let e=n.panels[t];if(!e)return n;let a=n.floating.filter(c=>c.id!==t),o=H(n.gridRoot,t),m=s||I(o||n.gridRoot)||"group-left-top";return{...n,gridRoot:f(o||n.gridRoot,m,t),floating:a,panels:{...n.panels,[t]:{...e,state:"docked"}}}})},[]),U=(t,s,n,e)=>{if(t.type==="leaf"){if(t.id===s){let a={type:"leaf",id:`group-split-${Date.now()}-${Math.floor(Math.random()*1e3)}`,panels:[n],activePanelId:n};return{type:"branch",orientation:e==="left"||e==="right"?"horizontal":"vertical",sizes:[.5,.5],children:e==="left"||e==="top"?[a,t]:[t,a]}}return t}else return{...t,children:t.children.map(a=>U(a,s,n,e))}},te=Y(t=>{d(s=>({...s,draggedPanelId:t}))},[]),X=Y((t,s,n)=>{d(e=>{let a=e.panels[t];if(!a)return e;let o=e.floating.filter(v=>v.id!==t),m=H(e.gridRoot,t),c;return n==="center"?c=f(m||e.gridRoot,s,t):c=U(m||e.gridRoot,s,t,n),{...e,gridRoot:c,floating:o,panels:{...e.panels,[t]:{...a,state:"docked"}},draggedPanelId:null}})},[]),ye=Y((t,s)=>{d(n=>{let e=n.panels[t];if(!e)return n;let a=n.floating.filter(O=>O.id!==t),o=H(n.gridRoot,t),m={type:"leaf",id:`group-edge-${Date.now()}-${Math.floor(Math.random()*1e3)}`,panels:[t],activePanelId:t},c=s==="left"||s==="right"?"horizontal":"vertical",v=s==="left"||s==="top"?[m,o||n.gridRoot]:[o||n.gridRoot,m];return{...n,gridRoot:{type:"branch",orientation:c,sizes:s==="left"||s==="top"?[.3,.7]:[.7,.3],children:v},floating:a,panels:{...n.panels,[t]:{...e,state:"docked"}},draggedPanelId:null}})},[]),Me=Y((t,s,n)=>{d(e=>{let a=e.panels[t];if(!a)return e;let o=H(e.gridRoot,t),m=x=>{if(x.type==="leaf"){if(x.id===s){let O=x.panels.filter(L=>L!==t),D=Math.max(0,Math.min(n,O.length)),k=[...O];return k.splice(D,0,t),{...x,panels:k,activePanelId:t}}return x}else return{...x,children:x.children.map(m)}},c=m(o||e.gridRoot),v=e.floating.filter(x=>x.id!==t);return{...e,gridRoot:c,floating:v,panels:{...e.panels,[t]:{...a,state:"docked"}},draggedPanelId:null}})},[]),ve=Y(t=>{d(s=>{let n=a=>{if(a.type==="leaf")return a.id===t&&a.canClose!==!1?null:a;{let o=a.children.map(v=>n(v)).filter(v=>v!==null);if(o.length===0)return null;if(o.length===1)return o[0];let m=a.sizes.slice(0,o.length),c=m.reduce((v,x)=>v+x,0);return{...a,children:o,sizes:m.map(v=>v/c)}}},e=n(s.gridRoot);return{...s,gridRoot:e||{type:"leaf",id:"group-default",panels:[],activePanelId:null}}})},[]),$e=Y(t=>{d(s=>({...s,floating:s.floating.map(n=>n.id===t?{...n,maximized:!n.maximized}:n)}))},[]),Ge=Y((t,s)=>{let n=(e,a)=>{if(e.type==="leaf")return e;if(a===t.length)return{...e,sizes:s};let o=t[a],m=e.children.map((c,v)=>v===o?n(c,a+1):c);return{...e,children:m}};d(e=>({...e,gridRoot:n(e.gridRoot,0)}))},[]),Ye=Y((t,s)=>{d(n=>({...n,floating:n.floating.map(e=>e.id===t?{...e,...s}:e)}))},[]),Xe=Y(()=>JSON.stringify({gridRoot:S.gridRoot,floating:S.floating,minimized:S.minimized,panels:S.panels}),[S]),qe=Y(t=>{try{let s=JSON.parse(t);if(s.gridRoot&&s.floating&&s.minimized&&s.panels){let n=Object.keys(s.panels)[0]||null;d(e=>({...e,gridRoot:s.gridRoot,floating:s.floating,minimized:s.minimized,panels:s.panels,draggedPanelId:null,activePanelId:n}))}}catch(s){console.error("Failed to parse layout configuration:",s)}},[]),Le=Y(t=>{d(s=>s.activePanelId===t?s:{...s,activePanelId:t})},[]),ue=Y(t=>{d(s=>s.dir===t?s:{...s,dir:t,isRtl:t==="rtl"})},[]);Xt(()=>{y&&d(t=>t.dir===y?t:{...t,dir:y,isRtl:y==="rtl"})},[y]);let _e=it(()=>({openPanel:z,closePanel:B,minimizePanel:V,restorePanel:ee,floatPanel:me,dockPanel:he,maximizePanel:$e,updateSplitSizes:Ge,updateFloatingPosition:Ye,bringToFront:A,saveLayout:Xe,loadLayout:qe,publish:u,subscribe:h,setDraggedPanelId:te,dockPanelToGroup:X,movePanelOrder:Me,closeLeafGroup:ve,registerCloseGuard:$,unregisterCloseGuard:Z,setPanelDirty:ne,updatePanelTitle:ce,requestClosePanel:q,dockPanelToWorkspaceEdge:ye,setActivePanel:Le,setDirection:ue}),[z,B,V,ee,me,he,$e,Ge,Ye,A,Xe,qe,u,h,te,X,Me,ve,$,Z,ne,ce,q,ye,Le,ue]),et=t=>{let s=t.defaultMessage||t.id;return t.values&&Object.entries(t.values).forEach(([n,e])=>{s=s.replace(`{${n}}`,String(e))}),s},tt=it(()=>({modalClass:N,modalBodyClass:C,sidePanelClass:W,sidePanelBodyClass:E,windowClass:w,windowBodyClass:M}),[N,C,W,E,w,M]);return We(Pt.Provider,{value:tt,children:We(ht.Provider,{value:S,children:We(yt.Provider,{value:_e,children:We(bt.Provider,{value:l||et,children:We(vt.Provider,{value:T,children:i})})})})})},pe=()=>{let i=Ae(ht);if(!i)throw new Error("useWindowManagerState must be used within WindowManagerProvider");return i},ke=()=>{let i=Ae(yt);if(!i)throw new Error("useWindowManagerActions must be used within WindowManagerProvider");return i},oe=()=>Ae(bt)||(l=>{let r=l.defaultMessage||l.id;return l.values&&Object.entries(l.values).forEach(([y,N])=>{r=r.replace(`{${y}}`,String(N))}),r}),G=(i,l)=>i?typeof i=="string"?i:l(i):"",Jt=()=>{let{publish:i,subscribe:l}=ke();return{publish:i,subscribe:l}},ae=()=>Ae(vt);function xt(i){if(!i)return typeof document<"u"?document.documentElement.dir?.toLowerCase()==="rtl"||document.body.dir?.toLowerCase()==="rtl":!1;let l=i.closest("[dir]");return l?l.getAttribute("dir")?.toLowerCase()==="rtl":document.documentElement.dir?.toLowerCase()==="rtl"||document.body.dir?.toLowerCase()==="rtl"}import{JsonContextMenu as rn}from"replace-react-contexify";import"replace-react-contexify/styles.css";import{createContext as Zt,useContext as Qt}from"react";var Vt={requestClose:()=>{console.warn("FormContainerContract: requestClose called but no container is present")},setDirty:()=>{},onCloseRequested:()=>()=>{},setTitle:()=>{},setIcon:()=>{},containerType:"standalone",instanceId:"standalone",onClose:()=>()=>{},onMinimize:()=>()=>{},onRestore:()=>()=>{},onResize:()=>()=>{}},at=Zt(Vt),Ie=at.Provider,rt=()=>Qt(at);import{createContext as Mt,useContext as Rt,useState as _t,useCallback as le,useMemo as en,useRef as tn}from"react";import{jsx as Ct}from"react/jsx-runtime";var nn=0,lt=()=>`panel-${++nn}-${Date.now()}`,Ke=new Map,wt={leftPanel:null,rightPanel:null,modals:[]},kt=Mt(null),It=Mt(null),on=({children:i})=>{let[l,r]=_t(wt),y=tn(l);y.current=l;let N=le((p,h)=>{Ke.set(p,h)},[]),C=le(p=>{Ke.delete(p)},[]),W=le(async(p,h,u={})=>{let R=y.current.leftPanel;if(R){let f=Ke.get(R.id);if(f&&!await f())return null}let A=lt(),H={id:A,Component:p,props:h,containerType:"left-panel",options:u};return r(f=>({...f,leftPanel:H})),A},[]),E=le(async(p,h,u={})=>{let R=y.current.rightPanel;if(R){let f=Ke.get(R.id);if(f&&!await f())return null}let A=lt(),H={id:A,Component:p,props:h,containerType:"right-panel",options:u};return r(f=>({...f,rightPanel:H})),A},[]),w=le((p,h,u={})=>{let R=lt(),A=h.title,H={...u,title:u.title||A||"Confirmation"},f={id:R,Component:p,props:h,containerType:"modal",options:H};return r(I=>({...I,modals:[...I.modals,f]})),R},[]),M=le(p=>{r(h=>({leftPanel:h.leftPanel?.id===p?null:h.leftPanel,rightPanel:h.rightPanel?.id===p?null:h.rightPanel,modals:h.modals.filter(u=>u.id!==p)}))},[]),S=le(()=>{r(wt)},[]),d=le(()=>{r(p=>({...p,modals:[]}))},[]),P=le(p=>l.leftPanel?.id===p?l.leftPanel:l.rightPanel?.id===p?l.rightPanel:l.modals.find(h=>h.id===p),[l]),b=le((p,h)=>{r(u=>({leftPanel:u.leftPanel?.id===p?{...u.leftPanel,...h}:u.leftPanel,rightPanel:u.rightPanel?.id===p?{...u.rightPanel,...h}:u.rightPanel,modals:u.modals.map(R=>R.id===p?{...R,...h}:R)}))},[]),T=le((p,h,u)=>{b(p,{dirty:h,dirtyOptions:u})},[b]),F=en(()=>({openLeftPanel:W,openRightPanel:E,openModal:w,close:M,closeAll:S,closeAllModals:d,getInstance:P,updateInstance:b,setDirty:T,registerCloseHandler:N,unregisterCloseHandler:C}),[W,E,w,M,S,d,P,b,T,N,C]);return Ct(kt.Provider,{value:l,children:Ct(It.Provider,{value:F,children:i})})},xe=()=>{let i=Rt(kt);if(!i)throw new Error("usePanelState must be used within PanelProvider");return i},Se=()=>{let i=Rt(It);if(!i)throw new Error("usePanelActions must be used within PanelProvider");return i};import{useEffect as St,useRef as sn}from"react";import{jsx as Te,jsxs as dt}from"react/jsx-runtime";var an=({title:i,message:l,alert:r,alertType:y="info",useYesNoTitles:N=!1,onOK:C,onCancel:W})=>{let{requestClose:E,setIcon:w,setTitle:M}=rt(),S=oe(),d=ae(),P=sn(null);St(()=>{if(i){let u=typeof i=="string"?i:S(i);M(u)}w&&w(Te("span",{children:"\u2753"}))},[i,M,w,S]),St(()=>{P.current?.focus()},[]);let b=typeof l=="string"?l:S(l),T=S(N?d.no:d.cancel),F=S(N?d.yes:d.ok),p=u=>{u.preventDefault(),C?.(),E()},h=()=>{W?.(),E()};return dt("form",{onSubmit:p,className:"p-3 d-flex flex-column gap-3",children:[r&&dt("div",{className:`alert alert-${y==="danger"?"danger":y} d-flex align-items-center gap-2 m-0 p-2.5 small`,children:[Te("span",{children:"\u2139\uFE0F"}),Te("span",{children:r})]}),Te("div",{style:{fontSize:"0.9rem",color:"inherit",lineHeight:1.5},children:b}),Te("hr",{className:"my-2 opacity-10"}),dt("div",{className:"d-flex justify-content-end gap-2",children:[Te("button",{type:"button",className:"btn btn-sm btn-outline-secondary font-monospace",onClick:h,children:T}),Te("button",{type:"submit",className:"btn btn-sm btn-primary font-monospace",ref:P,children:F})]})]})},ze=an;import{Fragment as fn,jsx as g,jsxs as K}from"react/jsx-runtime";var He=new Map,Je="preserved-dom-container",ct=K("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"block"},children:[g("rect",{x:"3",y:"3",width:"7",height:"9",rx:"1"}),g("rect",{x:"14",y:"3",width:"7",height:"5",rx:"1"}),g("rect",{x:"14",y:"12",width:"7",height:"9",rx:"1"}),g("rect",{x:"3",y:"16",width:"7",height:"5",rx:"1"})]}),zt=i=>{let l=He.get(i);return l||(l=document.createElement("div"),l.style.width="100%",l.style.height="100%",He.set(i,l)),l},ln=(i,l)=>{let r=_.get(l);if(!r)return K("div",{className:"w-100 h-100 d-flex flex-column align-items-center justify-content-center bg-transparent text-danger font-monospace p-3 text-center",style:{border:"2px dashed var(--bs-danger, #dc3545)"},children:[g("h6",{className:"fw-bold mb-1",children:"\u26A0\uFE0F Component Unregistered"}),K("span",{className:"small text-muted",children:["Key: ",l]})]});let y=r.Component;return g(y,{panelId:i})},Lt=new Map,Ne=new Map,Ue=i=>{let l=Ne.get(i);return l||(l={onClose:new Set,onMinimize:new Set,onRestore:new Set,onResize:new Set},Ne.set(i,l)),l},Et=({panelId:i})=>{let l=fe(null);return ie(()=>{let r=l.current;if(!r)return;let y=zt(i);r.appendChild(y);let N=new ResizeObserver(C=>{for(let W of C){let{width:E,height:w}=W.contentRect;if(E>0&&w>0){Lt.set(i,{width:E,height:w});let M=Ne.get(i);M&&M.onResize.forEach(S=>S(E,w))}}});return N.observe(r),()=>{N.disconnect();let C=document.getElementById(Je);C||(C=document.createElement("div"),C.id=Je,C.style.display="none",document.body.appendChild(C)),C.appendChild(y)}},[i]),g("div",{ref:l,className:"w-100 h-100"})},dn=({panelId:i})=>{let l=pe(),r=oe(),y=fe(null),N=l.panels[i],C=N?_.get(N.component):null,W=C?.defaultOptions?.disableLivePreview||!1,E=Lt.get(i)||{width:800,height:500},w=E.width,M=E.height,P=Math.min(220/w,140/M);if(ie(()=>{if(W)return;let b=y.current;if(!b)return;let T=He.get(i);if(T)return b.appendChild(T),()=>{let F=document.getElementById(Je);F||(F=document.createElement("div"),F.id=Je,F.style.display="none",document.body.appendChild(F)),F.appendChild(T)}},[i,W]),W){let b=w*P,T=M*P,F=N?.title||C?.defaultOptions?.title||"Panel",p=G(F,r),h=(Array.from(p)[0]||"P").toUpperCase();return g("div",{className:"taskbar-item-preview-frame d-flex align-items-center justify-content-center",style:{width:`${b}px`,height:`${T}px`,background:"rgba(108, 117, 125, 0.15)",border:"1px dashed var(--taskbar-item-border, rgba(255, 255, 255, 0.15))"},children:g("div",{style:{fontSize:"2rem",fontWeight:600,color:"var(--panel-title-color, var(--panel-text, rgba(255, 255, 255, 0.85)))",userSelect:"none"},children:h})})}return g("div",{className:"taskbar-item-preview-frame",style:{width:`${w*P}px`,height:`${M*P}px`},children:g("div",{ref:y,className:"taskbar-item-preview-host",style:{width:`${w}px`,height:`${M}px`,transform:`scale(${P})`,transformOrigin:"top left",position:"absolute",top:0,left:0,"--preview-scale":P}})})},cn=({panelId:i,children:l})=>{let r=pe(),{requestClosePanel:y,setPanelDirty:N,registerCloseGuard:C,unregisterCloseGuard:W,updatePanelTitle:E}=ke(),w=r.minimized.some(d=>d.id===i),M=fe(w);ie(()=>{let d=Ne.get(i);d&&(w&&!M.current?d.onMinimize.forEach(P=>P()):!w&&M.current&&d.onRestore.forEach(P=>P()),M.current=w)},[w,i]),ie(()=>()=>{let d=Ne.get(i);d&&(d.onClose.forEach(P=>P()),Ne.delete(i))},[i]);let S=ut.useMemo(()=>({requestClose:d=>y(i,d),setDirty:d=>N(i,d),onCloseRequested:d=>(C(i,d),()=>W(i)),setTitle:d=>E(i,d),instanceId:i,onClose:d=>{let P=Ue(i);return P.onClose.add(d),()=>P.onClose.delete(d)},onMinimize:d=>{let P=Ue(i);return P.onMinimize.add(d),()=>P.onMinimize.delete(d)},onRestore:d=>{let P=Ue(i);return P.onRestore.add(d),()=>P.onRestore.delete(d)},onResize:d=>{let P=Ue(i);return P.onResize.add(d),()=>P.onResize.delete(d)}}),[i,y,N,C,W,E]);return g(Ie,{value:S,children:l})},Nt=({node:i,path:l,onTabRightClick:r,activeDropZone:y,onHoverDropZone:N,onTabDragStart:C,hoveredTab:W,onTabHover:E,defaultPanelIcon:w,onRequestClosePanel:M})=>{let{updateSplitSizes:S}=ke();if(i.type==="leaf")return g(un,{leaf:i,onTabRightClick:r,activeDropZone:y,onHoverDropZone:N,onTabDragStart:C,hoveredTab:W,onTabHover:E,defaultPanelIcon:w,onRequestClosePanel:M});let d=i.orientation==="horizontal",P=(b,T)=>{T.preventDefault();let F=d?T.clientX:T.clientY,p=[...i.sizes],h=T.currentTarget;h.classList.add("active"),document.body.classList.add("resizing-active",d?"resizing-row-active":"resizing-col-active");let u=T.currentTarget.parentElement,R=u?d?u.clientWidth:u.clientHeight:d?1e3:800,A=f=>{let B=((d?f.clientX:f.clientY)-F)/R,$=[...p];$[b]+=B,$[b+1]-=B,$[b]>.1&&$[b+1]>.1&&S(l,$)},H=()=>{h.classList.remove("active"),document.body.classList.remove("resizing-active","resizing-row-active","resizing-col-active"),window.removeEventListener("mousemove",A),window.removeEventListener("mouseup",H)};window.addEventListener("mousemove",A),window.addEventListener("mouseup",H)};return g("div",{className:`d-flex w-100 h-100 ${d?"flex-row":"flex-column"}`,style:{overflow:"hidden",position:"relative"},children:i.children.map((b,T)=>{let F=i.sizes[T]*100;return K(ut.Fragment,{children:[g("div",{style:{flexGrow:i.sizes[T],flexBasis:`${F}%`,overflow:"hidden",position:"relative"},children:g(Nt,{node:b,path:[...l,T],onTabRightClick:r,activeDropZone:y,onHoverDropZone:N,onTabDragStart:C,hoveredTab:W,onTabHover:E,defaultPanelIcon:w,onRequestClosePanel:M})}),T<i.children.length-1&&g("div",{onMouseDown:p=>P(T,p),style:{cursor:d?"col-resize":"row-resize",width:d?"1px":"100%",height:d?"100%":"1px",zIndex:20},className:"resizer-bar"})]},T)})})},un=({leaf:i,onTabRightClick:l,activeDropZone:r,onHoverDropZone:y,onTabDragStart:N,hoveredTab:C,onTabHover:W,defaultPanelIcon:E,onRequestClosePanel:w})=>{let M=pe(),{openPanel:S,closeLeafGroup:d,setActivePanel:P}=ke(),b=oe(),T=ae(),{windowClass:F,windowBodyClass:p}=Pe(),h=u=>{S(u,M.panels[u].component),P(u)};return K("div",{"data-active-panel-id":i.activePanelId||"",className:`workspace-panel w-100 h-100 d-flex flex-column ${F??""}`,style:{overflow:"hidden",position:"relative"},children:[K("div",{className:"workspace-tab-bar d-flex flex-row justify-content-between align-items-center",style:{minHeight:"38px"},children:[g("div",{className:"d-flex flex-row overflow-x-auto flex-grow-1 tab-headers-container",style:{scrollbarWidth:"none"},onMouseMove:u=>{M.draggedPanelId&&u.target===u.currentTarget&&W(i.id,"EMPTY",i.panels.length,"right")},onMouseLeave:u=>{M.draggedPanelId&&u.target===u.currentTarget&&W(i.id,"",-1,null)},children:i.panels.map((u,R)=>{let A=M.panels[u];if(!A)return null;let H=i.activePanelId===u,f=M.activePanelId===u,z=_.get(A.component)?.defaultOptions,B=C&&C.leafId===i.id&&C.panelId===u,$=R===i.panels.length-1,Z=C&&C.leafId===i.id&&C.panelId==="EMPTY"&&$,ne=B?C.side==="left"?"drag-hover-left":"drag-hover-right":Z?"drag-hover-right":"";return K("div",{onClick:()=>h(u),onMouseDown:q=>{z?.canDrag!==!1&&N(u,q)},onContextMenu:q=>l(u,q),onMouseMove:q=>{if(M.draggedPanelId){let V=q.currentTarget.getBoundingClientRect(),me=q.clientX-V.left<V.width/2?"left":"right";W(i.id,u,R,me)}},onMouseLeave:()=>{M.draggedPanelId&&W(i.id,"",-1,null)},className:`workspace-tab ${H?f?"active workspace-tab-active-focused":"active workspace-tab-active-unfocused":"workspace-tab-inactive"} ${ne}`,style:{cursor:z?.canDrag===!1?"default":"pointer"},children:[K("span",{className:"text-truncate d-flex align-items-center",style:{maxWidth:"120px"},children:[g("span",{className:"workspace-tab-icon",children:z?.icon||E||ct}),K("span",{children:[G(A.title,b),A.dirty?" *":""]})]}),z?.renderHeaderActions&&g("span",{className:"tab-header-actions ms-auto d-flex align-items-center me-1",style:{gap:"var(--header-button-gap, 4px)"},onClick:q=>q.stopPropagation(),onMouseDown:q=>q.stopPropagation(),children:z.renderHeaderActions(u)}),z?.canClose!==!1&&g("span",{onClick:q=>{q.stopPropagation(),w(u)},title:G(T.closeTab,b),className:`close-tab-x ${z?.renderHeaderActions?"":"ms-auto"} d-flex align-items-center justify-content-center`,style:{width:"18px",height:"18px"},children:g("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:g("path",{d:"M18 6L6 18M6 6l12 12"})})})]},u)})}),i.panels.length===0&&i.keepOnEmpty&&i.canClose!==!1&&g("span",{onClick:()=>d(i.id),className:"close-tab-x d-flex align-items-center justify-content-center me-2 header-close-empty-group",style:{width:"18px",height:"18px",cursor:"pointer"},title:G(T.closeEmptyGroup,b),children:g("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:g("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),K("div",{className:`flex-grow-1 w-100 h-100 bg-transparent ${p??""}`,style:{position:"relative",overflow:"hidden"},children:[i.activePanelId&&M.panels[i.activePanelId]?g(Et,{panelId:i.activePanelId},i.activePanelId):g("div",{className:"w-100 h-100 d-flex align-items-center justify-content-center font-monospace text-muted small empty-leaf-placeholder",children:g("span",{children:"Empty Workspace Section"})}),M.draggedPanelId!==null&&g("div",{className:"dock-drop-zone-overlay",children:K("div",{className:"dock-target-cross",children:[g("div",{onMouseEnter:()=>y(i.id,"top"),onMouseLeave:()=>y(i.id,null),className:"dock-target-box dock-target-top",children:"\u25B2"}),g("div",{onMouseEnter:()=>y(i.id,"bottom"),onMouseLeave:()=>y(i.id,null),className:"dock-target-box dock-target-bottom",children:"\u25BC"}),g("div",{onMouseEnter:()=>y(i.id,"left"),onMouseLeave:()=>y(i.id,null),className:"dock-target-box dock-target-left",children:"\u25C0"}),g("div",{onMouseEnter:()=>y(i.id,"right"),onMouseLeave:()=>y(i.id,null),className:"dock-target-box dock-target-right",children:"\u25B6"}),g("div",{onMouseEnter:()=>y(i.id,"center"),onMouseLeave:()=>y(i.id,null),className:"dock-target-box dock-target-center",children:"\u25A3"})]})}),M.draggedPanelId!==null&&r!==null&&r.leafId===i.id&&g("div",{className:"dock-preview-highlight",style:{left:r.position==="right"?"50%":"0",top:r.position==="bottom"?"50%":"0",width:r.position==="left"||r.position==="right"?"50%":"100%",height:r.position==="top"||r.position==="bottom"?"50%":"100%"}})]})]})},gn=({skin:i="vscode",defaultPanelIcon:l})=>{let r=pe(),{restorePanel:y,minimizePanel:N,requestClosePanel:C,maximizePanel:W,updateFloatingPosition:E,bringToFront:w,floatPanel:M,setDraggedPanelId:S,dockPanelToGroup:d,movePanelOrder:P,dockPanelToWorkspaceEdge:b,setActivePanel:T,setDirection:F}=ke(),{openModal:p}=Se(),h=oe(),u=ae(),R=ut.useCallback(e=>{let a=r.panels[e];C(e,{onConfirm:o=>new Promise(m=>{let c=o||a?.dirtyOptions,v=a?G(a.title,h):"Panel";p(ze,{title:c?.title||u.unsavedChangesTitle,message:c?.message||{id:u.unsavedChangesMessage.id,defaultMessage:u.unsavedChangesMessage.defaultMessage,values:{title:v}},alert:c?.alert,alertType:c?.alertType||"danger",useYesNoTitles:!0,onOK:()=>m(!0),onCancel:()=>m(!1)},{size:"small"})})})},[C,r.panels,h,p,u]),{windowClass:A,windowBodyClass:H}=Pe(),f=fe(null),I=fe(null),[z,B]=we(null),$=fe(null),[Z,ne]=we(!1);ie(()=>()=>{$.current&&clearTimeout($.current)},[]),ie(()=>{z&&(r.minimized.some(a=>a.id===z.id)||B(null))},[r.minimized,z]);let[ce,q]=we(null),V=fe(null),[ee,me]=we({x:0,y:0}),[he,U]=we(null),te=fe(null),X=e=>{U(e),te.current=e},[ye,Me]=we(null),ve=fe(null),$e=(e,a,o,m)=>{let c=m?{leafId:e,panelId:a,index:o,side:m}:null;Me(c),ve.current=c},Ge=(e,a)=>{let o=a?{leafId:e,position:a}:null;q(o),V.current=o},Ye=(e,a)=>{if(a.button!==0)return;let o=a.clientX,m=a.clientY,c=!1,v=D=>{let k=D.clientX-o,L=D.clientY-m;!c&&(Math.abs(k)>5||Math.abs(L)>5)&&(c=!0,S(e)),c&&me({x:D.clientX,y:D.clientY})},x=D=>{if(window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",O),c){let k=V.current,L=ve.current,j=te.current;if(j)b(e,j);else if(L){let J=L.index;L.side==="right"&&(J+=1),P(e,L.leafId,J)}else k?d(e,k.leafId,k.position):M(e,{x:D.clientX-150,y:D.clientY-15,width:450,height:350});S(null),q(null),V.current=null,Me(null),ve.current=null,X(null)}},O=D=>{x(D)};window.addEventListener("mousemove",v),window.addEventListener("mouseup",O)},Xe=(e,a)=>{a.preventDefault();let o=r.panels[e];if(!o)return;let c=_.get(o.component)?.defaultOptions,v=[];c?.canDrag!==!1&&v.push({label:G(u.floatWindow,h),action:()=>M(e)}),c?.canMinimize!==!1&&v.push({label:G(u.minimizePanel,h),action:()=>N(e)}),v.length>0&&c?.canClose!==!1&&v.push({separator:!0}),c?.canClose!==!1&&v.push({label:G(u.closeTab,h),action:()=>R(e)}),v.length!==0&&I.current?.show({event:a,contextMenu:{items:v}})},qe=(e,a)=>{a.preventDefault(),B(null),I.current?.show({event:a,contextMenu:{items:[{label:G(u.restorePanel,h),action:()=>y(e)},{label:G(u.maximizePanel,h),action:()=>W(e)},{separator:!0},{label:G(u.closePanel,h),action:()=>R(e)}]}})};ie(()=>{let e=Object.keys(r.panels);for(let a of Array.from(He.keys()))e.includes(a)||He.delete(a)},[r.panels]),ie(()=>{let e=()=>{r.draggedPanelId!==null&&(S(null),q(null),Me(null))};return window.addEventListener("blur",e),()=>{window.removeEventListener("blur",e)}},[r.draggedPanelId]);let Le=fe(null),[ue,_e]=we({width:1024,height:768});ie(()=>{let e=Le.current;if(!e)return;let a=new ResizeObserver(o=>{if(!o||o.length===0)return;let m=o[0].contentRect;_e({width:Math.max(100,m.width),height:Math.max(100,m.height)})});return a.observe(e),()=>{a.disconnect()}},[]),ie(()=>{let e=Le.current;if(!e)return;let a=()=>{let c=xt(e);F(c?"rtl":"ltr")};a();let o=new MutationObserver(a);o.observe(document.documentElement,{attributes:!0,attributeFilter:["dir"]}),o.observe(document.body,{attributes:!0,attributeFilter:["dir"]});let m=e.closest("[dir]");return m&&m!==document.documentElement&&m!==document.body&&o.observe(m,{attributes:!0,attributeFilter:["dir"]}),()=>{o.disconnect()}},[F]),ie(()=>{let e=ue.width,a=ue.height;r.floating.forEach(o=>{let m=typeof o.width=="string"?parseFloat(o.width):o.width,c=typeof o.height=="string"?parseFloat(o.height):o.height,v=typeof o.x=="string"?parseFloat(o.x):o.x,x=typeof o.y=="string"?parseFloat(o.y):o.y,O=m,D=c,k=v,L=x,j=!1;O>e&&(O=Math.max(200,e-20),j=!0),D>a&&(D=Math.max(150,a-40),j=!0);let J=10;if(o.stickyRight)k=e-O-J,j=!0;else{let Q=e-100;k>Q&&(k=Math.max(0,Q),j=!0)}if(o.stickyBottom)L=a-D-J,j=!0;else{let Q=a-40;L>Q&&(L=Math.max(0,Q),j=!0)}j&&E(o.id,{x:k,y:L,width:O,height:D})})},[ue,r.floating,E]),ie(()=>{let e=a=>{if(a.button!==0)return;let o=a.target;if(!o)return;let m=o.closest(".floating-window");if(m){let v=m.getAttribute("data-window-id");v&&(T(v),w(v));return}let c=o.closest(".workspace-panel");if(c){let v=c.getAttribute("data-active-panel-id");v&&T(v)}};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[w,T]);let et=(e,a)=>{let o=r.floating.find(J=>J.id===e);if(!o||o.maximized)return;w(e);let m=a.clientX,c=a.clientY,x=a.currentTarget.closest(".floating-window"),O=x?x.offsetLeft:0,D=x?x.offsetTop:0,k=!1,L=J=>{let Q=J.clientX-m,re=J.clientY-c;if(!k&&(Math.abs(Q)>5||Math.abs(re)>5)&&(k=!0,S(e)),k){let ge=O+Q,be=D+re;E(e,{x:ge,y:be,stickyRight:!1,stickyBottom:!1})}},j=()=>{if(k){let J=V.current,Q=ve.current,re=te.current;if(re)b(e,re);else if(Q){let ge=Q.index;Q.side==="right"&&(ge+=1),P(e,Q.leafId,ge)}else J&&d(e,J.leafId,J.position);S(null),q(null),V.current=null,Me(null),ve.current=null,X(null)}window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",j)};window.addEventListener("mousemove",L),window.addEventListener("mouseup",j)},tt=(e,a)=>{a.stopPropagation();let o=r.floating.find(j=>j.id===e);if(!o||o.maximized)return;w(e);let m=a.clientX,c=a.clientY,x=a.currentTarget.closest(".floating-window"),O=x?x.offsetWidth:400,D=x?x.offsetHeight:300,k=j=>{let J=j.clientX-m,Q=j.clientY-c,re=Math.max(200,O+J),ge=Math.max(150,D+Q),be=o.x,Re=o.y,Ee=ue.width,nt=ue.height,Ht=typeof o.x=="string"?parseFloat(o.x):o.x,Bt=typeof o.y=="string"?parseFloat(o.y):o.y,$t=typeof o.width=="string"?parseFloat(o.width):o.width,Gt=typeof o.height=="string"?parseFloat(o.height):o.height,ft=Math.abs(Ht+$t-Ee)<4,mt=Math.abs(Bt+Gt-nt)<4;ft&&(be=Ee-re,be<0&&(be=0,re=Ee)),mt&&(Re=nt-ge,Re<0&&(Re=0,ge=nt)),E(e,{x:be,y:Re,width:re,height:ge,stickyRight:ft,stickyBottom:mt})},L=()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",L)};window.addEventListener("mousemove",k),window.addEventListener("mouseup",L)},t=e=>{if(f.current){let a=e==="left"?-150:150;f.current.scrollBy({left:a,behavior:"smooth"})}},[s,n]=we("dark");return ie(()=>{let e=()=>{let o=document.documentElement.getAttribute("data-bs-theme")==="light"?"light":"dark";n(o)};e();let a=new MutationObserver(e);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-bs-theme"]}),()=>a.disconnect()},[]),K("div",{"data-workspace-skin":i,"data-bs-theme":s,className:"d-flex flex-column w-100 h-100 overflow-hidden",style:{userSelect:"none"},dir:r.dir,children:[K("div",{ref:Le,className:`flex-grow-1 w-100 position-relative ${r.draggedPanelId?"dragging-active":""}`,style:{overflow:"hidden"},children:[r.draggedPanelId!==null&&K(fn,{children:[g("div",{className:"workspace-edge-trigger edge-trigger-left",onMouseEnter:()=>X("left"),onMouseLeave:()=>X(null)}),g("div",{className:"workspace-edge-trigger edge-trigger-right",onMouseEnter:()=>X("right"),onMouseLeave:()=>X(null)}),g("div",{className:"workspace-edge-trigger edge-trigger-top",onMouseEnter:()=>X("top"),onMouseLeave:()=>X(null)}),g("div",{className:"workspace-edge-trigger edge-trigger-bottom",onMouseEnter:()=>X("bottom"),onMouseLeave:()=>X(null)})]}),r.draggedPanelId!==null&&he!==null&&g("div",{className:`workspace-edge-preview edge-preview-${he}`}),g("div",{className:"w-100 h-100",style:{overflow:"hidden",position:"relative"},children:r.gridRoot?g(Nt,{node:r.gridRoot,path:[],onTabRightClick:Xe,activeDropZone:ce,onHoverDropZone:Ge,onTabDragStart:Ye,hoveredTab:ye,onTabHover:$e,defaultPanelIcon:l,onRequestClosePanel:R}):g("div",{className:"w-100 h-100 d-flex align-items-center justify-content-center text-muted font-monospace small",children:"Grid Empty"})}),r.floating.map(e=>{let a=r.panels[e.id];if(!a)return null;let o=e.maximized,m=r.draggedPanelId===e.id,c=r.activePanelId===e.id,x=_.get(a.component)?.defaultOptions;return K("div",{"data-window-id":e.id,dir:r.dir,onMouseDownCapture:()=>{T(e.id),w(e.id)},className:`floating-window ${o?"maximized":""} ${c?"v2-window-focused":""} ${A??""}`,style:{position:"absolute",left:o?0:typeof e.x=="number"?`${e.x}px`:e.x,top:o?0:typeof e.y=="number"?`${e.y}px`:e.y,width:o?"100%":typeof e.width=="number"?`${e.width}px`:e.width,height:o?"100%":typeof e.height=="number"?`${e.height}px`:e.height,zIndex:e.z,pointerEvents:m?"none":"auto"},children:[K("div",{onDoubleClick:()=>W(e.id),onMouseDown:O=>{x?.canDrag!==!1&&et(e.id,O)},className:"floating-window-titlebar d-flex flex-row justify-content-between align-items-center cursor-move",style:{cursor:o||x?.canDrag===!1?"default":"move"},children:[K("span",{className:"floating-window-title text-truncate me-2 d-flex align-items-center",children:[g("span",{className:"window-title-icon",children:x?.icon||l||ct}),K("span",{children:[G(a.title,h),a.dirty?" *":""]})]}),K("div",{className:"d-flex align-items-center",style:{gap:"var(--header-button-gap, 4px)"},onMouseDown:O=>O.stopPropagation(),children:[x?.renderHeaderActions&&g("div",{className:"window-header-actions d-flex align-items-center me-1",style:{gap:"var(--header-button-gap, 4px)"},children:x.renderHeaderActions(e.id)}),x?.canDrag!==!1&&g("button",{type:"button",title:G(u.windowAnchoringOptions,h),onClick:O=>{let D=!!e.stickyRight,k=!!e.stickyBottom;I.current?.show({event:O,contextMenu:{items:[{label:G(u.anchorToRightEdge,h),checkbox:{active:!0,enabled:!0,value:D},action:()=>{let L=ue.width,j=typeof e.width=="string"?parseFloat(e.width):e.width;D?E(e.id,{stickyRight:!1}):E(e.id,{x:L-j-10,stickyRight:!0})}},{label:G(u.anchorToBottomEdge,h),checkbox:{active:!0,enabled:!0,value:k},action:()=>{let L=ue.height,j=typeof e.height=="string"?parseFloat(e.height):e.height;k?E(e.id,{stickyBottom:!1}):E(e.id,{y:L-j-10,stickyBottom:!0})}}]}})},className:"custom-tab-btn btn-anchor-tab",children:K("svg",{className:`anchor-icon ${e.stickyRight&&e.stickyBottom?"anchor-sticky-both":e.stickyRight?"anchor-sticky-right":e.stickyBottom?"anchor-sticky-bottom":""}`,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[g("circle",{cx:"12",cy:"5",r:"2"}),g("path",{d:"M12 7v7m0 0a4 4 0 0 1-4-4M12 14a4 4 0 0 0 4-4M5 18h14"})]})}),g("button",{type:"button",title:o?G(u.restoreSize,h):G(u.maximize,h),onClick:()=>W(e.id),className:"custom-tab-btn btn-maximize-tab",children:g("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:g("rect",{x:"4",y:"4",width:"16",height:"16",rx:"1.5"})})}),x?.canMinimize!==!1&&g("button",{type:"button",title:G(u.minimize,h),onClick:()=>N(e.id),className:"custom-tab-btn btn-minimize-tab",children:g("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:g("path",{d:"M5 12h14"})})}),x?.canClose!==!1&&g("button",{type:"button",title:G(u.close,h),onClick:()=>R(e.id),className:"custom-tab-btn btn-close-tab",children:g("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:g("path",{d:"M18 6L6 18M6 6l12 12"})})})]})]}),g("div",{className:`flex-grow-1 w-100 overflow-hidden ${H??""}`,style:{position:"relative"},children:g(Et,{panelId:e.id},e.id)}),!o&&g("div",{onMouseDown:O=>tt(e.id,O),style:{position:"absolute",right:0,bottom:0,width:"14px",height:"14px",cursor:"se-resize",zIndex:30,background:"linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.2) 50%)"}})]},e.id)})]}),r.minimized.length>0&&K("div",{className:"flex-shrink-0 w-100 d-flex flex-row align-items-center taskbar-footer-container px-3 py-1.5 justify-content-center",style:{height:"48px",zIndex:100},children:[g("button",{type:"button",onClick:()=>t("left"),className:"btn btn-sm btn-link taskbar-nav-btn text-decoration-none py-0 font-monospace",style:{display:r.minimized.length>4?"block":"none"},children:"\u25C0"}),g("div",{ref:f,className:"d-flex flex-row gap-2 overflow-x-auto align-items-center mx-2 px-1 py-0.5 scrollbar-hidden",style:{maxWidth:"800px",scrollbarWidth:"none",scrollSnapType:"x mandatory"},children:r.minimized.map(e=>{let o=_.get(e.component)?.defaultOptions?.icon||l||ct;return g("div",{onClick:()=>{B(null),y(e.id)},onContextMenu:m=>qe(e.id,m),onMouseEnter:m=>{if(Z)return;$.current&&clearTimeout($.current);let c=m.currentTarget.getBoundingClientRect();m.clientX>=c.left&&m.clientX<=c.right&&m.clientY>=c.top&&m.clientY<=c.bottom&&B({id:e.id,rect:c,title:e.title,component:e.component})},onMouseLeave:()=>{$.current=setTimeout(()=>{B(null)},150)},className:"taskbar-glassmorphic-item rounded d-flex align-items-center justify-content-center cursor-pointer hover-elevate",style:{backdropFilter:"blur(6px)",transition:"all 0.2s",cursor:"pointer",scrollSnapAlign:"start",width:"38px",height:"38px",position:"relative",padding:0},children:g("span",{className:"taskbar-item-icon d-flex align-items-center justify-content-center",children:o})},e.id)})}),z&&Tt(K("div",{className:"taskbar-item-tooltip d-flex flex-column gap-1",dir:r.dir,style:{position:"fixed",left:`${z.rect.left+z.rect.width/2}px`,top:`${z.rect.top-8}px`,transform:"translateX(-50%) translateY(-100%)",opacity:1,pointerEvents:"auto",zIndex:999999},onMouseEnter:()=>{$.current&&clearTimeout($.current)},onMouseLeave:()=>{B(null)},onClick:()=>{y(z.id),B(null)},children:[K("div",{className:"d-flex flex-row align-items-center justify-content-between w-100 gap-3 px-1 py-0.5",children:[K("span",{className:"tooltip-title-text text-truncate",style:{maxWidth:"140px"},children:[G(z.title,h),r.panels[z.id]?.dirty?" *":""]}),g("span",{onClick:e=>{e.stopPropagation(),R(z.id),B(null)},title:G(u.closePanel,h),className:"tooltip-close-x d-flex align-items-center justify-content-center",children:g("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:g("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),g(dn,{panelId:z.id})]}),document.body),g("button",{type:"button",onClick:()=>t("right"),className:"btn btn-sm btn-link taskbar-nav-btn text-decoration-none py-0 font-monospace",style:{display:r.minimized.length>4?"block":"none"},children:"\u25B6"})]}),Object.keys(r.panels).map(e=>{let a=r.panels[e];if(!a)return null;let o=zt(e);return Tt(g(cn,{panelId:e,children:g("div",{style:{width:"100%",height:"100%"},children:ln(e,a.component)})}),o,e)}),g(rn,{ref:I,id:"workspace-context-menu",theme:"dark",onShow:()=>ne(!0),onHide:()=>ne(!1)}),r.draggedPanelId!==null&&!r.floating.some(e=>e.id===r.draggedPanelId)&&K("div",{className:"position-fixed bg-black bg-opacity-80 border border-info rounded text-info font-monospace px-3 py-1.5 shadow-lg d-flex align-items-center gap-2",style:{left:ee.x+12,top:ee.y+12,zIndex:1e5,pointerEvents:"none",fontSize:"0.75rem",boxShadow:"0 8px 24px rgba(0,0,0,0.5)",borderLeft:"3px solid var(--accent-color)",whiteSpace:"nowrap"},children:["\u{1F4C4} ",G(r.panels[r.draggedPanelId]?.title,h)||"Tab"]})]})},pn=gn;import{useCallback as Be,useRef as Ft,useEffect as mn,useState as hn,useMemo as yn}from"react";import{Fragment as xn,jsx as de,jsxs as gt}from"react/jsx-runtime";var bn=({modal:i,index:l,isTopmost:r})=>{let{close:y,openModal:N,updateInstance:C,setDirty:W}=Se(),E=oe(),w=ae(),{dir:M}=pe(),{modalClass:S,modalBodyClass:d}=Pe(),P=Ft(null),{id:b,Component:T,props:F,options:p,dirty:h,dirtyOptions:u}=i,R=p,[A,H]=hn(R.icon||null),f=Ft(R);f.current=R;let I=G(R.title,E),z=Be(async U=>{if(U?.force){y(b);return}if(P.current){if(!await P.current())return;y(b);return}if(h){N(ze,{title:u?.title||w.unsavedChangesTitle,message:u?.message||{id:w.unsavedChangesMessage.id,defaultMessage:w.unsavedChangesMessage.defaultMessage,values:{title:I}},alert:u?.alert,alertType:u?.alertType||"danger",useYesNoTitles:!0,onOK:()=>y(b)},{size:"small"});return}y(b)},[y,N,b,h,u,I,w]),B=Be((U,te)=>W(b,U,te),[W,b]),$=Be(U=>C(b,{options:{...f.current,title:U}}),[C,b]),Z=Be(U=>H(U),[]),ne=Be(U=>(P.current=U,()=>{P.current=null}),[]),ce=yn(()=>({requestClose:z,setDirty:B,setTitle:$,setIcon:Z,onCloseRequested:ne,containerType:"modal",instanceId:b}),[z,B,$,Z,ne,b]),q=h?`${I} *`:I,V=R.size?`v2-modal-size-${R.size}`:"v2-modal-size-auto",ee=R.closable!==!1;mn(()=>{if(!r||!ee)return;let U=te=>{te.key==="Escape"&&(te.stopPropagation(),z())};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[z,ee,r]);let he=1e4+l*10;return gt("div",{className:"v2-modal-overlay",style:{zIndex:he},dir:M,children:[de("div",{className:"v2-modal-curtain",onClick:ee?()=>z():void 0}),gt("div",{className:`v2-modal-window ${V} ${S??""}`,children:[gt("div",{className:"v2-modal-header",children:[A&&de("div",{className:"v2-modal-icon",children:A}),de("h4",{className:"v2-modal-title",children:q}),ee&&de("button",{className:"v2-modal-close-button",onClick:()=>z(),title:E(w.closeTooltip),type:"button",children:de("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:de("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),de("div",{className:`v2-modal-body ${d??""}`,children:de(Ie,{value:ce,children:de(T,{...F,panelId:b})})})]})]})},vn=()=>{let{modals:i}=xe();return i.length===0?null:de(xn,{children:i.map((l,r)=>de(bn,{modal:l,index:r,isTopmost:r===i.length-1},l.id))})},Pn=vn;import{useCallback as Fe,useRef as Ot,useEffect as Wt,useState as wn,useMemo as Cn}from"react";import{Fragment as Sn,jsx as se,jsxs as pt}from"react/jsx-runtime";var Ze=({panel:i,position:l,defaultWidth:r})=>{let{close:y,openModal:N,updateInstance:C,setDirty:W,registerCloseHandler:E,unregisterCloseHandler:w}=Se(),{modals:M}=xe(),S=oe(),d=ae(),{dir:P}=pe(),{sidePanelClass:b,sidePanelBodyClass:T}=Pe(),F=Ot(null),{id:p,Component:h,props:u,options:R,dirty:A,dirtyOptions:H}=i,f=R,[I,z]=wn(f.icon||null),B=Ot(f);B.current=f;let $=G(f.title,S),Z=Fe(async X=>{if(X?.force){y(p);return}if(F.current){if(!await F.current())return;y(p);return}if(A){N(ze,{title:H?.title||d.unsavedChangesTitle,message:H?.message||{id:d.unsavedChangesMessage.id,defaultMessage:d.unsavedChangesMessage.defaultMessage,values:{title:$}},alert:H?.alert,alertType:H?.alertType||"danger",useYesNoTitles:!0,onOK:()=>y(p)},{size:"small"});return}y(p)},[y,N,p,A,H,$,d]),ne=Fe(async()=>F.current?await F.current():!A,[A]);Wt(()=>(E(p,ne),()=>w(p)),[p,ne,E,w]);let ce=Fe((X,ye)=>W(p,X,ye),[W,p]),q=Fe(X=>C(p,{options:{...B.current,title:X}}),[C,p]),V=Fe(X=>z(X),[]),ee=Fe(X=>(F.current=X,()=>{F.current=null}),[]),me=Cn(()=>({requestClose:Z,setDirty:ce,setTitle:q,setIcon:V,onCloseRequested:ee,containerType:l==="left"?"left-panel":"right-panel",instanceId:p}),[Z,ce,q,V,ee,l,p]),he=A?`${$} *`:$;Wt(()=>{let X=ye=>{ye.key==="Escape"&&M.length===0&&Z()};return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},[Z,M.length]);let U=f.width||r||400,te=typeof U=="number"?`${U}px`:U;return se("div",{className:`v2-side-panel v2-side-panel-${l} v2-side-panel-visible ${b??""}`,style:{width:te},dir:P,children:pt("div",{className:"v2-side-panel-window",children:[pt("div",{className:"v2-side-panel-header",children:[I&&se("div",{className:"v2-side-panel-icon",children:I}),se("h4",{className:"v2-side-panel-title",children:he}),se("button",{className:"v2-side-panel-close-button",onClick:()=>Z(),title:S(d.closeTooltip),type:"button",children:se("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:se("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),se("div",{className:`v2-side-panel-body ${T??""}`,children:se(Ie,{value:me,children:se(h,{...u,panelId:p})})})]})})},Mn=({defaultWidth:i})=>{let{leftPanel:l,rightPanel:r}=xe();return pt(Sn,{children:[l&&se(Ze,{panel:l,position:"left",defaultWidth:i},l.id),r&&se(Ze,{panel:r,position:"right",defaultWidth:i},r.id)]})},Rn=({defaultWidth:i})=>{let{leftPanel:l}=xe();return l?se(Ze,{panel:l,position:"left",defaultWidth:i},l.id):null},kn=({defaultWidth:i})=>{let{rightPanel:l}=xe();return l?se(Ze,{panel:l,position:"right",defaultWidth:i},l.id):null},In=Mn;import{useState as Dt,useEffect as Qe,useRef as Tn,useCallback as At,useImperativeHandle as zn,forwardRef as Ln}from"react";import{Fragment as Nn,jsx as Ce,jsxs as Ve}from"react/jsx-runtime";var En=Ln(function({position:l="right",tabs:r,drawerWidth:y="220px",activeTabId:N,onActiveTabChange:C,children:W},E){let w=N!==void 0,M=oe(),S=ae(),[d,P]=Dt(null),b=w?N:d,[T,F]=Dt(()=>{let f=new Set;for(let I of r)I.eagerMount&&f.add(I.id);return f});Qe(()=>{let f=r.filter(I=>I.eagerMount&&!T.has(I.id));f.length>0&&F(I=>{let z=new Set(I);for(let B of f)z.add(B.id);return z})},[r]);let p=Tn(b??null);Qe(()=>{p.current=b??null},[b]);let h=At(f=>{w||P(f),C?.(f)},[w,C]);zn(E,()=>({openTab:f=>h(f),closeDrawer:()=>h(null),getActiveTab:()=>p.current}),[h]);let u=f=>{h(b===f?null:f)},R=At(()=>h(null),[h]);Qe(()=>{b&&!T.has(b)&&F(f=>{let I=new Set(f);return I.add(b),I})},[b,T]),Qe(()=>{b===null&&F(f=>{let I=!1,z=new Set(f);for(let B of f){let $=r.find(Z=>Z.id===B);$&&!$.eagerMount&&!$.preserveState&&(z.delete(B),I=!0)}return I?z:f})},[b,r]);let A=Ce("div",{className:`sidebar-tabs-strip ${l}`,style:{width:"56px",height:"100%"},children:r.map(f=>{let I=b===f.id;return Ce("button",{type:"button",onClick:()=>u(f.id),className:`sidebar-tab-btn ${I?"active":""}`,title:f.label,"aria-pressed":I,children:f.icon},f.id)})}),H=Ce("div",{className:`sidebar-content-drawer h-100 ${l}`,style:{width:b?y:"0px",minWidth:b?y:"0px",overflow:"hidden",flexShrink:0},children:r.map(f=>{if(!T.has(f.id))return null;let z=b===f.id,B=()=>h(f.id);return Ve("div",{style:{display:z?"flex":"none",flexDirection:"column",height:"100%",width:"100%"},children:[Ve("div",{className:"d-flex align-items-center justify-content-between border-bottom border-secondary-subtle px-3 py-2 flex-shrink-0",style:{background:"rgba(0,0,0,0.08)",minHeight:"38px"},children:[Ce("span",{className:"sidebar-header-title",children:f.label}),Ce("button",{type:"button",onClick:R,className:"btn btn-link p-0 text-secondary d-flex align-items-center",style:{textDecoration:"none"},title:M(S.closePanelTooltip),"aria-label":M(S.closePanelTooltip),children:Ve("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[Ce("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Ce("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),Ce("div",{className:"flex-grow-1 overflow-auto",children:f.renderContent(f.id,R,B)})]},f.id)})});return Ve(Nn,{children:[l==="left"&&A,l==="left"&&H,W,l==="right"&&H,l==="right"&&A]})});export{ze as ConfirmationForm,at as FormContainerContext,Ie as FormContainerProvider,Rn as LeftPanelRenderer,Pn as ModalStackRenderer,on as PanelProvider,_ as PanelRegistry,kn as RightPanelRenderer,In as SidePanelRenderer,En as Sidebar,pn as WindowManager,Ut as WindowManagerProvider,Oe as defaultPredefinedMessages,G as formatLabel,rt as useFormContainer,oe as useFormatMessage,Se as usePanelActions,Jt as usePanelContext,xe as usePanelState,ae as usePredefinedMessages,Pe as useStyleClasses,ke as useWindowManagerActions,pe as useWindowManagerState};
1
+ import ut,{useState as Ce,useRef as fe,useEffect as ie}from"react";import{createPortal as St}from"react-dom";import{createContext as De,useContext as Ae,useState as Yt,useRef as Ke,useMemo as it,useCallback as Y,useEffect as Xt}from"react";var ot=class{registry=new Map;register(l,r,y){this.registry.set(l,{Component:r,defaultOptions:y})}get(l){return this.registry.get(l)}getRegisteredIds(){return Array.from(this.registry.keys())}},_=new ot;var Oe={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"},anchorToRightEdge:{id:"dockable-desktop-anchorToRightEdge",defaultMessage:"Anchor to Right Edge"},anchorToBottomEdge:{id:"dockable-desktop-anchorToBottomEdge",defaultMessage:"Anchor to Bottom Edge"},windowAnchoringOptions:{id:"dockable-desktop-windowAnchoringOptions",defaultMessage:"Window Anchoring Options"},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"}};import{jsx as We}from"react/jsx-runtime";var ht=De(null),yt=De(null),bt=De(null),vt=De(Oe),Pt=De({}),Pe=()=>Ae(Pt),st=class{listeners={};subscribe(l,r){return this.listeners[l]||(this.listeners[l]=[]),this.listeners[l].push(r),()=>{this.listeners[l]=this.listeners[l].filter(y=>y!==r)}}publish(l,r){this.listeners[l]&&this.listeners[l].forEach(y=>y(r))}},qt={type:"branch",orientation:"vertical",sizes:[.75,.25],children:[{type:"leaf",id:"group-left-top",panels:["main-map","main-editor"],activePanelId:"main-map"},{type:"leaf",id:"group-left-bottom",panels:["system-console","help-docs"],activePanelId:"system-console"}]},Kt={"main-map":{id:"main-map",title:"Main Map",component:"mainMap",state:"docked"},"main-editor":{id:"main-editor",title:"Code Editor",component:"editor",state:"docked"},"system-console":{id:"system-console",title:"Console Output",component:"terminal",state:"docked"},"help-docs":{id:"help-docs",title:"Help Center",component:"help",state:"docked"},"live-preview":{id:"live-preview",title:"Live Preview Output",component:"preview",state:"floating"}},Ut=[{id:"live-preview",x:450,y:200,width:320,height:250,z:1e3}],jt=({children:i,formatMessage:l,predefinedMessages:r,dir:y,modalClass:N,modalBodyClass:x,sidePanelClass:W,sidePanelBodyClass:E,windowClass:C,windowBodyClass:M})=>{let[T,d]=Yt({gridRoot:qt,floating:Ut,minimized:[],panels:Kt,draggedPanelId:null,activePanelId:"main-map",dir:y||"ltr",isRtl:y==="rtl"}),P=Ke(T);P.current=T;let b=Ke({}),S=it(()=>({...Oe,...r}),[r]),F=Ke(new st),p=Ke(1e3),h=Y((t,s)=>F.current.subscribe(t,s),[]),u=Y((t,s)=>{F.current.publish(t,s)},[]),R=Y((t,s)=>{let n=typeof t.x=="string"?parseFloat(t.x):t.x,e=typeof t.y=="string"?parseFloat(t.y):t.y,a=typeof t.width=="string"?parseFloat(t.width):t.width,o=typeof t.height=="string"?parseFloat(t.height):t.height;isNaN(n)&&(n=300),isNaN(e)&&(e=150),isNaN(a)&&(a=450),isNaN(o)&&(o=350);let m=O=>s.some(D=>{let k=typeof D.x=="string"?parseFloat(D.x):D.x,L=typeof D.y=="string"?parseFloat(D.y):D.y;return!D.maximized&&Math.abs(k-O.x)<20&&Math.abs(L-O.y)<20}),c=0;for(;m({x:n,y:e})&&c<10;)n+=30,e+=30,c++;let v=Math.max(100,window.innerWidth||1024),w=Math.max(100,window.innerHeight||768);return(n+a>v||e+o>w)&&(n=100+c%5*30,e=100+c%5*30),n=Math.max(0,Math.min(n,v-100)),e=Math.max(0,Math.min(e,w-40)),{x:n,y:e,width:a,height:o}},[]),A=Y(t=>{p.current+=1;let s=p.current;d(n=>{let e=n.panels[t];if(!e)return n;if(e.state==="floating")return{...n,floating:n.floating.map(a=>a.id===t?{...a,z:s}:a),activePanelId:t};if(e.state==="docked"){let a=o=>o.type==="leaf"?o.panels.includes(t)?{...o,activePanelId:t}:o:{...o,children:o.children.map(a)};return{...n,gridRoot:a(n.gridRoot),activePanelId:t}}return{...n,activePanelId:t}})},[]),B=(t,s)=>{if(t.type==="leaf"){let n=t.panels.indexOf(s);if(n===-1)return t;let e=t.panels.filter(m=>m!==s),a=t.activePanelId===s?e[n]||e[n-1]||e[0]||null:t.activePanelId,o={...t,panels:e,activePanelId:a};return e.length===0&&!t.keepOnEmpty?null:o}else{let n=t.children.map(o=>B(o,s)).filter(o=>o!==null);if(n.length===0)return null;if(n.length===1)return n[0];let e=t.sizes.slice(0,n.length),a=e.reduce((o,m)=>o+m,0);return{...t,children:n,sizes:e.map(o=>o/a)}}},f=(t,s,n)=>{if(t.type==="leaf"){if(t.id===s){let e=t.panels.includes(n)?t.panels:[...t.panels,n];return{...t,panels:e,activePanelId:n}}return t}else return{...t,children:t.children.map(e=>f(e,s,n))}},I=t=>{if(t.type==="leaf")return t.id;for(let s of t.children){let n=I(s);if(n)return n}return null},z=Y((t,s,n)=>{d(e=>{let a=e.panels[t],o=_.get(s),m=n?.title||n?.title||o?.defaultOptions?.title||t,c=n?.initialTarget||o?.defaultOptions?.initialTarget||"docked",v=o?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350};if(a)if(a.state==="minimized"){let k=e.minimized.filter(L=>L.id!==t);if(c==="floating"||!e.gridRoot){p.current+=1;let L=R(v,e.floating);return{...e,minimized:k,floating:[...e.floating,{...L,id:t,z:p.current}],panels:{...e.panels,[t]:{...a,state:"floating"}}}}else{let L=I(e.gridRoot)||"group-left-top";return{...e,minimized:k,gridRoot:f(e.gridRoot,L,t),panels:{...e.panels,[t]:{...a,state:"docked"}}}}}else{if(a.state==="floating")return A(t),e;{let k=L=>L.type==="leaf"?L.panels.includes(t)?{...L,activePanelId:t}:L:{...L,children:L.children.map(k)};return{...e,gridRoot:k(e.gridRoot)}}}let O={id:t,title:m,component:s,state:c==="tabbed"?"docked":c},D={...e.panels,[t]:O};if(c==="floating"){p.current+=1;let k=R(v,e.floating),L=n?.stickyRight??o?.defaultOptions?.defaultStickyRight??!1,K=n?.stickyBottom??o?.defaultOptions?.defaultStickyBottom??!1,J=Math.max(100,window.innerWidth||1024),Q=Math.max(100,window.innerHeight||768),re=typeof k.width=="string"?parseFloat(k.width):k.width,ge=typeof k.height=="string"?parseFloat(k.height):k.height,be=k.x,Re=k.y,Ee=10;return L&&(be=J-re-Ee),K&&(Re=Q-ge-Ee),{...e,floating:[...e.floating,{...k,id:t,z:p.current,x:be,y:Re,stickyRight:L,stickyBottom:K}],panels:D}}else{let k=I(e.gridRoot)||"group-left-top";return{...e,gridRoot:f(e.gridRoot,k,t),panels:D}}})},[R,A]),H=Y(t=>{d(s=>{let n=s.panels[t];if(!n||_.get(n.component)?.defaultOptions?.canClose===!1)return s;delete b.current[t];let a={...s.panels};delete a[t];let o=B(s.gridRoot,t);return{...s,gridRoot:o||{type:"leaf",id:"group-default",panels:[],activePanelId:null},floating:s.floating.filter(m=>m.id!==t),minimized:s.minimized.filter(m=>m.id!==t),panels:a}})},[]),$=Y((t,s)=>{b.current[t]=s},[]),Z=Y(t=>{delete b.current[t]},[]),ne=Y((t,s,n)=>{d(e=>{let a=e.panels[t];return a?{...e,panels:{...e.panels,[t]:{...a,dirty:s,dirtyOptions:n}}}:e})},[]),ce=Y((t,s)=>{d(n=>{let e=n.panels[t];return e?{...n,panels:{...n.panels,[t]:{...e,title:s}}}:n})},[]),q=Y(async(t,s)=>{if(s?.force){H(t);return}let n=b.current[t];if(n&&!await n())return;let e=P.current.panels[t];if(e?.dirty)if(s?.onConfirm){if(!await s.onConfirm(e.dirtyOptions))return}else return;H(t)},[H]),V=Y(t=>{d(s=>{let n=s.panels[t];if(!n||n.state==="minimized"||_.get(n.component)?.defaultOptions?.canMinimize===!1)return s;let a,o;if(n.state==="floating"){let c=s.floating.find(v=>v.id===t);c&&(a={x:c.x,y:c.y,width:c.width,height:c.height,stickyRight:c.stickyRight,stickyBottom:c.stickyBottom})}else if(n.state==="docked"){let c=v=>{if(v.type==="leaf")return v.panels.includes(t)?v.id:null;for(let w of v.children){let O=c(w);if(O)return O}return null};o=c(s.gridRoot)}let m=B(s.gridRoot,t);return{...s,gridRoot:m||{type:"leaf",id:"group-default",panels:[],activePanelId:null},floating:s.floating.filter(c=>c.id!==t),minimized:[...s.minimized,{id:t,title:n.title,component:n.component}],panels:{...s.panels,[t]:{...n,state:"minimized",previousState:n.state,lastFloatingRect:a,lastLeafId:o}}}})},[]),ee=Y(t=>{d(s=>{let n=s.panels[t];if(!n||n.state!=="minimized")return s;let e=s.minimized.filter(o=>o.id!==t);if((n.previousState||"docked")==="floating"){p.current+=1;let o=_.get(n.component),m=n.lastFloatingRect||o?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},c=R(m,s.floating);return{...s,minimized:e,floating:[...s.floating,{...c,id:t,z:p.current,stickyRight:!!n.lastFloatingRect?.stickyRight,stickyBottom:!!n.lastFloatingRect?.stickyBottom}],panels:{...s.panels,[t]:{...n,state:"floating"}}}}else{let o=(w,O)=>w.type==="leaf"?w.id===O:w.children.some(D=>o(D,O)),m=n.lastLeafId&&o(s.gridRoot,n.lastLeafId),c=_.get(n.component),v=c?.defaultOptions?.canDrag!==!1;if(m)return{...s,minimized:e,gridRoot:f(s.gridRoot,n.lastLeafId,t),panels:{...s.panels,[t]:{...n,state:"docked"}}};if(v){p.current+=1;let w=n.lastFloatingRect||c?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},O=R(w,s.floating);return{...s,minimized:e,floating:[...s.floating,{...O,id:t,z:p.current,stickyRight:!!n.lastFloatingRect?.stickyRight,stickyBottom:!!n.lastFloatingRect?.stickyBottom}],panels:{...s.panels,[t]:{...n,state:"floating"}}}}else{let w=I(s.gridRoot)||"group-left-top";return{...s,minimized:e,gridRoot:f(s.gridRoot,w,t),panels:{...s.panels,[t]:{...n,state:"docked"}}}}}})},[R]),me=Y((t,s)=>{d(n=>{let e=n.panels[t];if(!e||_.get(e.component)?.defaultOptions?.canDrag===!1)return n;let o=_.get(e.component),m=s||o?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},c=B(n.gridRoot,t);p.current+=1;let v=R(m,n.floating);return{...n,gridRoot:c||{type:"leaf",id:"group-default",panels:[],activePanelId:null},floating:[...n.floating,{...v,id:t,z:p.current}],panels:{...n.panels,[t]:{...e,state:"floating"}}}})},[R]),he=Y((t,s)=>{d(n=>{let e=n.panels[t];if(!e)return n;let a=n.floating.filter(c=>c.id!==t),o=B(n.gridRoot,t),m=s||I(o||n.gridRoot)||"group-left-top";return{...n,gridRoot:f(o||n.gridRoot,m,t),floating:a,panels:{...n.panels,[t]:{...e,state:"docked"}}}})},[]),j=(t,s,n,e)=>{if(t.type==="leaf"){if(t.id===s){let a={type:"leaf",id:`group-split-${Date.now()}-${Math.floor(Math.random()*1e3)}`,panels:[n],activePanelId:n};return{type:"branch",orientation:e==="left"||e==="right"?"horizontal":"vertical",sizes:[.5,.5],children:e==="left"||e==="top"?[a,t]:[t,a]}}return t}else return{...t,children:t.children.map(a=>j(a,s,n,e))}},te=Y(t=>{d(s=>({...s,draggedPanelId:t}))},[]),X=Y((t,s,n)=>{d(e=>{let a=e.panels[t];if(!a)return e;let o=e.floating.filter(v=>v.id!==t),m=B(e.gridRoot,t),c;return n==="center"?c=f(m||e.gridRoot,s,t):c=j(m||e.gridRoot,s,t,n),{...e,gridRoot:c,floating:o,panels:{...e.panels,[t]:{...a,state:"docked"}},draggedPanelId:null}})},[]),ye=Y((t,s)=>{d(n=>{let e=n.panels[t];if(!e)return n;let a=n.floating.filter(O=>O.id!==t),o=B(n.gridRoot,t),m={type:"leaf",id:`group-edge-${Date.now()}-${Math.floor(Math.random()*1e3)}`,panels:[t],activePanelId:t},c=s==="left"||s==="right"?"horizontal":"vertical",v=s==="left"||s==="top"?[m,o||n.gridRoot]:[o||n.gridRoot,m];return{...n,gridRoot:{type:"branch",orientation:c,sizes:s==="left"||s==="top"?[.3,.7]:[.7,.3],children:v},floating:a,panels:{...n.panels,[t]:{...e,state:"docked"}},draggedPanelId:null}})},[]),Me=Y((t,s,n)=>{d(e=>{let a=e.panels[t];if(!a)return e;let o=B(e.gridRoot,t),m=w=>{if(w.type==="leaf"){if(w.id===s){let O=w.panels.filter(L=>L!==t),D=Math.max(0,Math.min(n,O.length)),k=[...O];return k.splice(D,0,t),{...w,panels:k,activePanelId:t}}return w}else return{...w,children:w.children.map(m)}},c=m(o||e.gridRoot),v=e.floating.filter(w=>w.id!==t);return{...e,gridRoot:c,floating:v,panels:{...e.panels,[t]:{...a,state:"docked"}},draggedPanelId:null}})},[]),ve=Y(t=>{d(s=>{let n=a=>{if(a.type==="leaf")return a.id===t&&a.canClose!==!1?null:a;{let o=a.children.map(v=>n(v)).filter(v=>v!==null);if(o.length===0)return null;if(o.length===1)return o[0];let m=a.sizes.slice(0,o.length),c=m.reduce((v,w)=>v+w,0);return{...a,children:o,sizes:m.map(v=>v/c)}}},e=n(s.gridRoot);return{...s,gridRoot:e||{type:"leaf",id:"group-default",panels:[],activePanelId:null}}})},[]),$e=Y(t=>{d(s=>({...s,floating:s.floating.map(n=>n.id===t?{...n,maximized:!n.maximized}:n)}))},[]),Ge=Y((t,s)=>{let n=(e,a)=>{if(e.type==="leaf")return e;if(a===t.length)return{...e,sizes:s};let o=t[a],m=e.children.map((c,v)=>v===o?n(c,a+1):c);return{...e,children:m}};d(e=>({...e,gridRoot:n(e.gridRoot,0)}))},[]),Ye=Y((t,s)=>{d(n=>({...n,floating:n.floating.map(e=>e.id===t?{...e,...s}:e)}))},[]),Xe=Y(()=>JSON.stringify({gridRoot:T.gridRoot,floating:T.floating,minimized:T.minimized,panels:T.panels}),[T]),qe=Y(t=>{try{let s=JSON.parse(t);if(s.gridRoot&&s.floating&&s.minimized&&s.panels){let n=Object.keys(s.panels)[0]||null;d(e=>({...e,gridRoot:s.gridRoot,floating:s.floating,minimized:s.minimized,panels:s.panels,draggedPanelId:null,activePanelId:n}))}}catch(s){console.error("Failed to parse layout configuration:",s)}},[]),Le=Y(t=>{d(s=>s.activePanelId===t?s:{...s,activePanelId:t})},[]),ue=Y(t=>{d(s=>s.dir===t?s:{...s,dir:t,isRtl:t==="rtl"})},[]);Xt(()=>{y&&d(t=>t.dir===y?t:{...t,dir:y,isRtl:y==="rtl"})},[y]);let _e=it(()=>({openPanel:z,closePanel:H,minimizePanel:V,restorePanel:ee,floatPanel:me,dockPanel:he,maximizePanel:$e,updateSplitSizes:Ge,updateFloatingPosition:Ye,bringToFront:A,saveLayout:Xe,loadLayout:qe,publish:u,subscribe:h,setDraggedPanelId:te,dockPanelToGroup:X,movePanelOrder:Me,closeLeafGroup:ve,registerCloseGuard:$,unregisterCloseGuard:Z,setPanelDirty:ne,updatePanelTitle:ce,requestClosePanel:q,dockPanelToWorkspaceEdge:ye,setActivePanel:Le,setDirection:ue}),[z,H,V,ee,me,he,$e,Ge,Ye,A,Xe,qe,u,h,te,X,Me,ve,$,Z,ne,ce,q,ye,Le,ue]),et=t=>{let s=t.defaultMessage||t.id;return t.values&&Object.entries(t.values).forEach(([n,e])=>{s=s.replace(`{${n}}`,String(e))}),s},tt=it(()=>({modalClass:N,modalBodyClass:x,sidePanelClass:W,sidePanelBodyClass:E,windowClass:C,windowBodyClass:M}),[N,x,W,E,C,M]);return We(Pt.Provider,{value:tt,children:We(ht.Provider,{value:T,children:We(yt.Provider,{value:_e,children:We(bt.Provider,{value:l||et,children:We(vt.Provider,{value:S,children:i})})})})})},pe=()=>{let i=Ae(ht);if(!i)throw new Error("useWindowManagerState must be used within WindowManagerProvider");return i},ke=()=>{let i=Ae(yt);if(!i)throw new Error("useWindowManagerActions must be used within WindowManagerProvider");return i},oe=()=>Ae(bt)||(l=>{let r=l.defaultMessage||l.id;return l.values&&Object.entries(l.values).forEach(([y,N])=>{r=r.replace(`{${y}}`,String(N))}),r}),G=(i,l)=>i?typeof i=="string"?i:l(i):"",Jt=()=>{let{publish:i,subscribe:l}=ke();return{publish:i,subscribe:l}},ae=()=>Ae(vt);function wt(i){if(!i)return typeof document<"u"?document.documentElement.dir?.toLowerCase()==="rtl"||document.body.dir?.toLowerCase()==="rtl":!1;let l=i.closest("[dir]");return l?l.getAttribute("dir")?.toLowerCase()==="rtl":document.documentElement.dir?.toLowerCase()==="rtl"||document.body.dir?.toLowerCase()==="rtl"}import{JsonContextMenu as rn}from"replace-react-contexify";import"replace-react-contexify/styles.css";import{createContext as Zt,useContext as Qt}from"react";var Vt={requestClose:()=>{console.warn("FormContainerContract: requestClose called but no container is present")},setDirty:()=>{},onCloseRequested:()=>()=>{},setTitle:()=>{},setIcon:()=>{},containerType:"standalone",instanceId:"standalone",onClose:()=>()=>{},onMinimize:()=>()=>{},onRestore:()=>()=>{},onResize:()=>()=>{}},at=Zt(Vt),Ie=at.Provider,rt=()=>Qt(at);import{createContext as Mt,useContext as Rt,useState as _t,useCallback as le,useMemo as en,useRef as tn}from"react";import{jsx as xt}from"react/jsx-runtime";var nn=0,lt=()=>`panel-${++nn}-${Date.now()}`,Ue=new Map,Ct={leftPanel:null,rightPanel:null,modals:[]},kt=Mt(null),It=Mt(null),on=({children:i})=>{let[l,r]=_t(Ct),y=tn(l);y.current=l;let N=le((p,h)=>{Ue.set(p,h)},[]),x=le(p=>{Ue.delete(p)},[]),W=le(async(p,h,u={})=>{let R=y.current.leftPanel;if(R){let f=Ue.get(R.id);if(f&&!await f())return null}let A=lt(),B={id:A,Component:p,props:h,containerType:"left-panel",options:u};return r(f=>({...f,leftPanel:B})),A},[]),E=le(async(p,h,u={})=>{let R=y.current.rightPanel;if(R){let f=Ue.get(R.id);if(f&&!await f())return null}let A=lt(),B={id:A,Component:p,props:h,containerType:"right-panel",options:u};return r(f=>({...f,rightPanel:B})),A},[]),C=le((p,h,u={})=>{let R=lt(),A=h.title,B={...u,title:u.title||A||"Confirmation"},f={id:R,Component:p,props:h,containerType:"modal",options:B};return r(I=>({...I,modals:[...I.modals,f]})),R},[]),M=le(p=>{r(h=>({leftPanel:h.leftPanel?.id===p?null:h.leftPanel,rightPanel:h.rightPanel?.id===p?null:h.rightPanel,modals:h.modals.filter(u=>u.id!==p)}))},[]),T=le(()=>{r(Ct)},[]),d=le(()=>{r(p=>({...p,modals:[]}))},[]),P=le(p=>l.leftPanel?.id===p?l.leftPanel:l.rightPanel?.id===p?l.rightPanel:l.modals.find(h=>h.id===p),[l]),b=le((p,h)=>{r(u=>({leftPanel:u.leftPanel?.id===p?{...u.leftPanel,...h}:u.leftPanel,rightPanel:u.rightPanel?.id===p?{...u.rightPanel,...h}:u.rightPanel,modals:u.modals.map(R=>R.id===p?{...R,...h}:R)}))},[]),S=le((p,h,u)=>{b(p,{dirty:h,dirtyOptions:u})},[b]),F=en(()=>({openLeftPanel:W,openRightPanel:E,openModal:C,close:M,closeAll:T,closeAllModals:d,getInstance:P,updateInstance:b,setDirty:S,registerCloseHandler:N,unregisterCloseHandler:x}),[W,E,C,M,T,d,P,b,S,N,x]);return xt(kt.Provider,{value:l,children:xt(It.Provider,{value:F,children:i})})},we=()=>{let i=Rt(kt);if(!i)throw new Error("usePanelState must be used within PanelProvider");return i},Te=()=>{let i=Rt(It);if(!i)throw new Error("usePanelActions must be used within PanelProvider");return i};import{useEffect as Tt,useRef as sn}from"react";import{jsx as Se,jsxs as dt}from"react/jsx-runtime";var an=({title:i,message:l,alert:r,alertType:y="info",useYesNoTitles:N=!1,onOK:x,onCancel:W})=>{let{requestClose:E,setIcon:C,setTitle:M}=rt(),T=oe(),d=ae(),P=sn(null);Tt(()=>{if(i){let u=typeof i=="string"?i:T(i);M(u)}C&&C(Se("span",{children:"\u2753"}))},[i,M,C,T]),Tt(()=>{P.current?.focus()},[]);let b=typeof l=="string"?l:T(l),S=T(N?d.no:d.cancel),F=T(N?d.yes:d.ok),p=u=>{u.preventDefault(),x?.(),E()},h=()=>{W?.(),E()};return dt("form",{onSubmit:p,className:"confirmation-form-body",children:[r&&dt("div",{className:`confirmation-alert confirmation-alert-${y}`,children:[Se("span",{children:"\u2139\uFE0F"}),Se("span",{children:r})]}),Se("div",{style:{fontSize:"0.9rem",color:"inherit",lineHeight:1.5},children:b}),Se("hr",{style:{marginTop:"0.5rem",marginBottom:"0.5rem",opacity:.1}}),dt("div",{className:"confirmation-actions",children:[Se("button",{type:"button",className:"dw-btn dw-btn-sm dw-btn-outline",onClick:h,children:S}),Se("button",{type:"submit",className:"dw-btn dw-btn-sm dw-btn-primary",ref:P,children:F})]})]})},ze=an;import{Fragment as fn,jsx as g,jsxs as U}from"react/jsx-runtime";var Be=new Map,Je="preserved-dom-container",ct=U("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"block"},children:[g("rect",{x:"3",y:"3",width:"7",height:"9",rx:"1"}),g("rect",{x:"14",y:"3",width:"7",height:"5",rx:"1"}),g("rect",{x:"14",y:"12",width:"7",height:"9",rx:"1"}),g("rect",{x:"3",y:"16",width:"7",height:"5",rx:"1"})]}),zt=i=>{let l=Be.get(i);return l||(l=document.createElement("div"),l.style.width="100%",l.style.height="100%",Be.set(i,l)),l},ln=(i,l)=>{let r=_.get(l);if(!r)return U("div",{className:"dw-unregistered-panel",style:{border:"2px dashed #dc3545"},children:[g("h6",{style:{fontWeight:700,marginBottom:"0.25rem"},children:"\u26A0\uFE0F Component Unregistered"}),U("span",{style:{fontSize:"0.875rem",color:"var(--text-secondary, #94a3b8)"},children:["Key: ",l]})]});let y=r.Component;return g(y,{panelId:i})},Lt=new Map,Ne=new Map,je=i=>{let l=Ne.get(i);return l||(l={onClose:new Set,onMinimize:new Set,onRestore:new Set,onResize:new Set},Ne.set(i,l)),l},Et=({panelId:i})=>{let l=fe(null);return ie(()=>{let r=l.current;if(!r)return;let y=zt(i);r.appendChild(y);let N=new ResizeObserver(x=>{for(let W of x){let{width:E,height:C}=W.contentRect;if(E>0&&C>0){Lt.set(i,{width:E,height:C});let M=Ne.get(i);M&&M.onResize.forEach(T=>T(E,C))}}});return N.observe(r),()=>{N.disconnect();let x=document.getElementById(Je);x||(x=document.createElement("div"),x.id=Je,x.style.display="none",document.body.appendChild(x)),x.appendChild(y)}},[i]),g("div",{ref:l,style:{width:"100%",height:"100%"}})},dn=({panelId:i})=>{let l=pe(),r=oe(),y=fe(null),N=l.panels[i],x=N?_.get(N.component):null,W=x?.defaultOptions?.disableLivePreview||!1,E=Lt.get(i)||{width:800,height:500},C=E.width,M=E.height,P=Math.min(220/C,140/M);if(ie(()=>{if(W)return;let b=y.current;if(!b)return;let S=Be.get(i);if(S)return b.appendChild(S),()=>{let F=document.getElementById(Je);F||(F=document.createElement("div"),F.id=Je,F.style.display="none",document.body.appendChild(F)),F.appendChild(S)}},[i,W]),W){let b=C*P,S=M*P,F=N?.title||x?.defaultOptions?.title||"Panel",p=G(F,r),h=(Array.from(p)[0]||"P").toUpperCase();return g("div",{className:"taskbar-item-preview-frame",style:{width:`${b}px`,height:`${S}px`,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(108, 117, 125, 0.15)",border:"1px dashed var(--taskbar-item-border, rgba(255, 255, 255, 0.15))"},children:g("div",{style:{fontSize:"2rem",fontWeight:600,color:"var(--panel-title-color, var(--panel-text, rgba(255, 255, 255, 0.85)))",userSelect:"none"},children:h})})}return g("div",{className:"taskbar-item-preview-frame",style:{width:`${C*P}px`,height:`${M*P}px`},children:g("div",{ref:y,className:"taskbar-item-preview-host",style:{width:`${C}px`,height:`${M}px`,transform:`scale(${P})`,transformOrigin:"top left",position:"absolute",top:0,left:0,"--preview-scale":P}})})},cn=({panelId:i,children:l})=>{let r=pe(),{requestClosePanel:y,setPanelDirty:N,registerCloseGuard:x,unregisterCloseGuard:W,updatePanelTitle:E}=ke(),C=r.minimized.some(d=>d.id===i),M=fe(C);ie(()=>{let d=Ne.get(i);d&&(C&&!M.current?d.onMinimize.forEach(P=>P()):!C&&M.current&&d.onRestore.forEach(P=>P()),M.current=C)},[C,i]),ie(()=>()=>{let d=Ne.get(i);d&&(d.onClose.forEach(P=>P()),Ne.delete(i))},[i]);let T=ut.useMemo(()=>({requestClose:d=>y(i,d),setDirty:d=>N(i,d),onCloseRequested:d=>(x(i,d),()=>W(i)),setTitle:d=>E(i,d),instanceId:i,onClose:d=>{let P=je(i);return P.onClose.add(d),()=>P.onClose.delete(d)},onMinimize:d=>{let P=je(i);return P.onMinimize.add(d),()=>P.onMinimize.delete(d)},onRestore:d=>{let P=je(i);return P.onRestore.add(d),()=>P.onRestore.delete(d)},onResize:d=>{let P=je(i);return P.onResize.add(d),()=>P.onResize.delete(d)}}),[i,y,N,x,W,E]);return g(Ie,{value:T,children:l})},Nt=({node:i,path:l,onTabRightClick:r,activeDropZone:y,onHoverDropZone:N,onTabDragStart:x,hoveredTab:W,onTabHover:E,defaultPanelIcon:C,onRequestClosePanel:M})=>{let{updateSplitSizes:T}=ke();if(i.type==="leaf")return g(un,{leaf:i,onTabRightClick:r,activeDropZone:y,onHoverDropZone:N,onTabDragStart:x,hoveredTab:W,onTabHover:E,defaultPanelIcon:C,onRequestClosePanel:M});let d=i.orientation==="horizontal",P=(b,S)=>{S.preventDefault();let F=d?S.clientX:S.clientY,p=[...i.sizes],h=S.currentTarget;h.classList.add("active"),document.body.classList.add("resizing-active",d?"resizing-row-active":"resizing-col-active");let u=S.currentTarget.parentElement,R=u?d?u.clientWidth:u.clientHeight:d?1e3:800,A=f=>{let H=((d?f.clientX:f.clientY)-F)/R,$=[...p];$[b]+=H,$[b+1]-=H,$[b]>.1&&$[b+1]>.1&&T(l,$)},B=()=>{h.classList.remove("active"),document.body.classList.remove("resizing-active","resizing-row-active","resizing-col-active"),window.removeEventListener("mousemove",A),window.removeEventListener("mouseup",B)};window.addEventListener("mousemove",A),window.addEventListener("mouseup",B)};return g("div",{style:{display:"flex",flexDirection:d?"row":"column",width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:i.children.map((b,S)=>{let F=i.sizes[S]*100;return U(ut.Fragment,{children:[g("div",{style:{flexGrow:i.sizes[S],flexBasis:`${F}%`,overflow:"hidden",position:"relative"},children:g(Nt,{node:b,path:[...l,S],onTabRightClick:r,activeDropZone:y,onHoverDropZone:N,onTabDragStart:x,hoveredTab:W,onTabHover:E,defaultPanelIcon:C,onRequestClosePanel:M})}),S<i.children.length-1&&g("div",{onMouseDown:p=>P(S,p),style:{cursor:d?"col-resize":"row-resize",width:d?"1px":"100%",height:d?"100%":"1px",zIndex:20},className:"resizer-bar"})]},S)})})},un=({leaf:i,onTabRightClick:l,activeDropZone:r,onHoverDropZone:y,onTabDragStart:N,hoveredTab:x,onTabHover:W,defaultPanelIcon:E,onRequestClosePanel:C})=>{let M=pe(),{openPanel:T,closeLeafGroup:d,setActivePanel:P}=ke(),b=oe(),S=ae(),{windowClass:F,windowBodyClass:p}=Pe(),h=u=>{T(u,M.panels[u].component),P(u)};return U("div",{"data-active-panel-id":i.activePanelId||"",className:`workspace-panel ${F??""}`,style:{overflow:"hidden",position:"relative"},children:[U("div",{className:"workspace-tab-bar",style:{minHeight:"38px"},children:[g("div",{className:"tab-headers-container",style:{scrollbarWidth:"none"},onMouseMove:u=>{M.draggedPanelId&&u.target===u.currentTarget&&W(i.id,"EMPTY",i.panels.length,"right")},onMouseLeave:u=>{M.draggedPanelId&&u.target===u.currentTarget&&W(i.id,"",-1,null)},children:i.panels.map((u,R)=>{let A=M.panels[u];if(!A)return null;let B=i.activePanelId===u,f=M.activePanelId===u,z=_.get(A.component)?.defaultOptions,H=x&&x.leafId===i.id&&x.panelId===u,$=R===i.panels.length-1,Z=x&&x.leafId===i.id&&x.panelId==="EMPTY"&&$,ne=H?x.side==="left"?"drag-hover-left":"drag-hover-right":Z?"drag-hover-right":"";return U("div",{onClick:()=>h(u),onMouseDown:q=>{z?.canDrag!==!1&&N(u,q)},onContextMenu:q=>l(u,q),onMouseMove:q=>{if(M.draggedPanelId){let V=q.currentTarget.getBoundingClientRect(),me=q.clientX-V.left<V.width/2?"left":"right";W(i.id,u,R,me)}},onMouseLeave:()=>{M.draggedPanelId&&W(i.id,"",-1,null)},className:`workspace-tab ${B?f?"active workspace-tab-active-focused":"active workspace-tab-active-unfocused":"workspace-tab-inactive"} ${ne}`,style:{cursor:z?.canDrag===!1?"default":"pointer"},children:[U("span",{className:"text-truncate",style:{maxWidth:"120px",display:"flex",alignItems:"center"},children:[g("span",{className:"workspace-tab-icon",children:z?.icon||E||ct}),U("span",{children:[G(A.title,b),A.dirty?" *":""]})]}),z?.renderHeaderActions&&g("span",{className:"tab-header-actions",onClick:q=>q.stopPropagation(),onMouseDown:q=>q.stopPropagation(),children:z.renderHeaderActions(u)}),z?.canClose!==!1&&g("span",{onClick:q=>{q.stopPropagation(),C(u)},title:G(S.closeTab,b),className:"close-tab-x",style:{width:"18px",height:"18px",...z?.renderHeaderActions?{}:{marginInlineStart:"auto"}},children:g("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:g("path",{d:"M18 6L6 18M6 6l12 12"})})})]},u)})}),i.panels.length===0&&i.keepOnEmpty&&i.canClose!==!1&&g("span",{onClick:()=>d(i.id),className:"close-tab-x header-close-empty-group",style:{width:"18px",height:"18px",cursor:"pointer"},title:G(S.closeEmptyGroup,b),children:g("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:g("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),U("div",{className:`dw-panel-body ${p??""}`,style:{position:"relative",overflow:"hidden"},children:[i.activePanelId&&M.panels[i.activePanelId]?g(Et,{panelId:i.activePanelId},i.activePanelId):g("div",{className:"empty-leaf-placeholder",children:g("span",{children:"Empty Workspace Section"})}),M.draggedPanelId!==null&&g("div",{className:"dock-drop-zone-overlay",children:U("div",{className:"dock-target-cross",children:[g("div",{onMouseEnter:()=>y(i.id,"top"),onMouseLeave:()=>y(i.id,null),className:"dock-target-box dock-target-top",children:"\u25B2"}),g("div",{onMouseEnter:()=>y(i.id,"bottom"),onMouseLeave:()=>y(i.id,null),className:"dock-target-box dock-target-bottom",children:"\u25BC"}),g("div",{onMouseEnter:()=>y(i.id,"left"),onMouseLeave:()=>y(i.id,null),className:"dock-target-box dock-target-left",children:"\u25C0"}),g("div",{onMouseEnter:()=>y(i.id,"right"),onMouseLeave:()=>y(i.id,null),className:"dock-target-box dock-target-right",children:"\u25B6"}),g("div",{onMouseEnter:()=>y(i.id,"center"),onMouseLeave:()=>y(i.id,null),className:"dock-target-box dock-target-center",children:"\u25A3"})]})}),M.draggedPanelId!==null&&r!==null&&r.leafId===i.id&&g("div",{className:"dock-preview-highlight",style:{left:r.position==="right"?"50%":"0",top:r.position==="bottom"?"50%":"0",width:r.position==="left"||r.position==="right"?"50%":"100%",height:r.position==="top"||r.position==="bottom"?"50%":"100%"}})]})]})},gn=({skin:i="vscode",defaultPanelIcon:l})=>{let r=pe(),{restorePanel:y,minimizePanel:N,requestClosePanel:x,maximizePanel:W,updateFloatingPosition:E,bringToFront:C,floatPanel:M,setDraggedPanelId:T,dockPanelToGroup:d,movePanelOrder:P,dockPanelToWorkspaceEdge:b,setActivePanel:S,setDirection:F}=ke(),{openModal:p}=Te(),h=oe(),u=ae(),R=ut.useCallback(e=>{let a=r.panels[e];x(e,{onConfirm:o=>new Promise(m=>{let c=o||a?.dirtyOptions,v=a?G(a.title,h):"Panel";p(ze,{title:c?.title||u.unsavedChangesTitle,message:c?.message||{id:u.unsavedChangesMessage.id,defaultMessage:u.unsavedChangesMessage.defaultMessage,values:{title:v}},alert:c?.alert,alertType:c?.alertType||"danger",useYesNoTitles:!0,onOK:()=>m(!0),onCancel:()=>m(!1)},{size:"small"})})})},[x,r.panels,h,p,u]),{windowClass:A,windowBodyClass:B}=Pe(),f=fe(null),I=fe(null),[z,H]=Ce(null),$=fe(null),[Z,ne]=Ce(!1);ie(()=>()=>{$.current&&clearTimeout($.current)},[]),ie(()=>{z&&(r.minimized.some(a=>a.id===z.id)||H(null))},[r.minimized,z]);let[ce,q]=Ce(null),V=fe(null),[ee,me]=Ce({x:0,y:0}),[he,j]=Ce(null),te=fe(null),X=e=>{j(e),te.current=e},[ye,Me]=Ce(null),ve=fe(null),$e=(e,a,o,m)=>{let c=m?{leafId:e,panelId:a,index:o,side:m}:null;Me(c),ve.current=c},Ge=(e,a)=>{let o=a?{leafId:e,position:a}:null;q(o),V.current=o},Ye=(e,a)=>{if(a.button!==0)return;let o=a.clientX,m=a.clientY,c=!1,v=D=>{let k=D.clientX-o,L=D.clientY-m;!c&&(Math.abs(k)>5||Math.abs(L)>5)&&(c=!0,T(e)),c&&me({x:D.clientX,y:D.clientY})},w=D=>{if(window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",O),c){let k=V.current,L=ve.current,K=te.current;if(K)b(e,K);else if(L){let J=L.index;L.side==="right"&&(J+=1),P(e,L.leafId,J)}else k?d(e,k.leafId,k.position):M(e,{x:D.clientX-150,y:D.clientY-15,width:450,height:350});T(null),q(null),V.current=null,Me(null),ve.current=null,X(null)}},O=D=>{w(D)};window.addEventListener("mousemove",v),window.addEventListener("mouseup",O)},Xe=(e,a)=>{a.preventDefault();let o=r.panels[e];if(!o)return;let c=_.get(o.component)?.defaultOptions,v=[];c?.canDrag!==!1&&v.push({label:G(u.floatWindow,h),action:()=>M(e)}),c?.canMinimize!==!1&&v.push({label:G(u.minimizePanel,h),action:()=>N(e)}),v.length>0&&c?.canClose!==!1&&v.push({separator:!0}),c?.canClose!==!1&&v.push({label:G(u.closeTab,h),action:()=>R(e)}),v.length!==0&&I.current?.show({event:a,contextMenu:{items:v}})},qe=(e,a)=>{a.preventDefault(),H(null),I.current?.show({event:a,contextMenu:{items:[{label:G(u.restorePanel,h),action:()=>y(e)},{label:G(u.maximizePanel,h),action:()=>W(e)},{separator:!0},{label:G(u.closePanel,h),action:()=>R(e)}]}})};ie(()=>{let e=Object.keys(r.panels);for(let a of Array.from(Be.keys()))e.includes(a)||Be.delete(a)},[r.panels]),ie(()=>{let e=()=>{r.draggedPanelId!==null&&(T(null),q(null),Me(null))};return window.addEventListener("blur",e),()=>{window.removeEventListener("blur",e)}},[r.draggedPanelId]);let Le=fe(null),[ue,_e]=Ce({width:1024,height:768});ie(()=>{let e=Le.current;if(!e)return;let a=new ResizeObserver(o=>{if(!o||o.length===0)return;let m=o[0].contentRect;_e({width:Math.max(100,m.width),height:Math.max(100,m.height)})});return a.observe(e),()=>{a.disconnect()}},[]),ie(()=>{let e=Le.current;if(!e)return;let a=()=>{let c=wt(e);F(c?"rtl":"ltr")};a();let o=new MutationObserver(a);o.observe(document.documentElement,{attributes:!0,attributeFilter:["dir"]}),o.observe(document.body,{attributes:!0,attributeFilter:["dir"]});let m=e.closest("[dir]");return m&&m!==document.documentElement&&m!==document.body&&o.observe(m,{attributes:!0,attributeFilter:["dir"]}),()=>{o.disconnect()}},[F]),ie(()=>{let e=ue.width,a=ue.height;r.floating.forEach(o=>{let m=typeof o.width=="string"?parseFloat(o.width):o.width,c=typeof o.height=="string"?parseFloat(o.height):o.height,v=typeof o.x=="string"?parseFloat(o.x):o.x,w=typeof o.y=="string"?parseFloat(o.y):o.y,O=m,D=c,k=v,L=w,K=!1;O>e&&(O=Math.max(200,e-20),K=!0),D>a&&(D=Math.max(150,a-40),K=!0);let J=10;if(o.stickyRight)k=e-O-J,K=!0;else{let Q=e-100;k>Q&&(k=Math.max(0,Q),K=!0)}if(o.stickyBottom)L=a-D-J,K=!0;else{let Q=a-40;L>Q&&(L=Math.max(0,Q),K=!0)}K&&E(o.id,{x:k,y:L,width:O,height:D})})},[ue,r.floating,E]),ie(()=>{let e=a=>{if(a.button!==0)return;let o=a.target;if(!o)return;let m=o.closest(".floating-window");if(m){let v=m.getAttribute("data-window-id");v&&(S(v),C(v));return}let c=o.closest(".workspace-panel");if(c){let v=c.getAttribute("data-active-panel-id");v&&S(v)}};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[C,S]);let et=(e,a)=>{let o=r.floating.find(J=>J.id===e);if(!o||o.maximized)return;C(e);let m=a.clientX,c=a.clientY,w=a.currentTarget.closest(".floating-window"),O=w?w.offsetLeft:0,D=w?w.offsetTop:0,k=!1,L=J=>{let Q=J.clientX-m,re=J.clientY-c;if(!k&&(Math.abs(Q)>5||Math.abs(re)>5)&&(k=!0,T(e)),k){let ge=O+Q,be=D+re;E(e,{x:ge,y:be,stickyRight:!1,stickyBottom:!1})}},K=()=>{if(k){let J=V.current,Q=ve.current,re=te.current;if(re)b(e,re);else if(Q){let ge=Q.index;Q.side==="right"&&(ge+=1),P(e,Q.leafId,ge)}else J&&d(e,J.leafId,J.position);T(null),q(null),V.current=null,Me(null),ve.current=null,X(null)}window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",K)};window.addEventListener("mousemove",L),window.addEventListener("mouseup",K)},tt=(e,a)=>{a.stopPropagation();let o=r.floating.find(K=>K.id===e);if(!o||o.maximized)return;C(e);let m=a.clientX,c=a.clientY,w=a.currentTarget.closest(".floating-window"),O=w?w.offsetWidth:400,D=w?w.offsetHeight:300,k=K=>{let J=K.clientX-m,Q=K.clientY-c,re=Math.max(200,O+J),ge=Math.max(150,D+Q),be=o.x,Re=o.y,Ee=ue.width,nt=ue.height,Bt=typeof o.x=="string"?parseFloat(o.x):o.x,Ht=typeof o.y=="string"?parseFloat(o.y):o.y,$t=typeof o.width=="string"?parseFloat(o.width):o.width,Gt=typeof o.height=="string"?parseFloat(o.height):o.height,ft=Math.abs(Bt+$t-Ee)<4,mt=Math.abs(Ht+Gt-nt)<4;ft&&(be=Ee-re,be<0&&(be=0,re=Ee)),mt&&(Re=nt-ge,Re<0&&(Re=0,ge=nt)),E(e,{x:be,y:Re,width:re,height:ge,stickyRight:ft,stickyBottom:mt})},L=()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",L)};window.addEventListener("mousemove",k),window.addEventListener("mouseup",L)},t=e=>{if(f.current){let a=e==="left"?-150:150;f.current.scrollBy({left:a,behavior:"smooth"})}},[s,n]=Ce("dark");return ie(()=>{let e=()=>{let o=document.documentElement.getAttribute("data-bs-theme")==="light"?"light":"dark";n(o)};e();let a=new MutationObserver(e);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-bs-theme"]}),()=>a.disconnect()},[]),U("div",{"data-workspace-skin":i,"data-bs-theme":s,style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",overflow:"hidden",userSelect:"none"},dir:r.dir,children:[U("div",{ref:Le,className:r.draggedPanelId?"dragging-active":void 0,style:{flexGrow:1,width:"100%",position:"relative",overflow:"hidden"},children:[r.draggedPanelId!==null&&U(fn,{children:[g("div",{className:"workspace-edge-trigger edge-trigger-left",onMouseEnter:()=>X("left"),onMouseLeave:()=>X(null)}),g("div",{className:"workspace-edge-trigger edge-trigger-right",onMouseEnter:()=>X("right"),onMouseLeave:()=>X(null)}),g("div",{className:"workspace-edge-trigger edge-trigger-top",onMouseEnter:()=>X("top"),onMouseLeave:()=>X(null)}),g("div",{className:"workspace-edge-trigger edge-trigger-bottom",onMouseEnter:()=>X("bottom"),onMouseLeave:()=>X(null)})]}),r.draggedPanelId!==null&&he!==null&&g("div",{className:`workspace-edge-preview edge-preview-${he}`}),g("div",{style:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:r.gridRoot?g(Nt,{node:r.gridRoot,path:[],onTabRightClick:Xe,activeDropZone:ce,onHoverDropZone:Ge,onTabDragStart:Ye,hoveredTab:ye,onTabHover:$e,defaultPanelIcon:l,onRequestClosePanel:R}):g("div",{className:"empty-workspace-grid",children:"Grid Empty"})}),r.floating.map(e=>{let a=r.panels[e.id];if(!a)return null;let o=e.maximized,m=r.draggedPanelId===e.id,c=r.activePanelId===e.id,w=_.get(a.component)?.defaultOptions;return U("div",{"data-window-id":e.id,dir:r.dir,onMouseDownCapture:()=>{S(e.id),C(e.id)},className:`floating-window ${o?"maximized":""} ${c?"v2-window-focused":""} ${A??""}`,style:{position:"absolute",left:o?0:typeof e.x=="number"?`${e.x}px`:e.x,top:o?0:typeof e.y=="number"?`${e.y}px`:e.y,width:o?"100%":typeof e.width=="number"?`${e.width}px`:e.width,height:o?"100%":typeof e.height=="number"?`${e.height}px`:e.height,zIndex:e.z,pointerEvents:m?"none":"auto"},children:[U("div",{onDoubleClick:()=>W(e.id),onMouseDown:O=>{w?.canDrag!==!1&&et(e.id,O)},className:"floating-window-titlebar cursor-move",style:{cursor:o||w?.canDrag===!1?"default":"move"},children:[U("span",{className:"floating-window-title",children:[g("span",{className:"window-title-icon",children:w?.icon||l||ct}),U("span",{children:[G(a.title,h),a.dirty?" *":""]})]}),U("div",{className:"fw-titlebar-actions",style:{gap:"var(--header-button-gap, 4px)"},onMouseDown:O=>O.stopPropagation(),children:[w?.renderHeaderActions&&g("div",{className:"window-header-actions",children:w.renderHeaderActions(e.id)}),w?.canDrag!==!1&&g("button",{type:"button",title:G(u.windowAnchoringOptions,h),onClick:O=>{let D=!!e.stickyRight,k=!!e.stickyBottom;I.current?.show({event:O,contextMenu:{items:[{label:G(u.anchorToRightEdge,h),checkbox:{active:!0,enabled:!0,value:D},action:()=>{let L=ue.width,K=typeof e.width=="string"?parseFloat(e.width):e.width;D?E(e.id,{stickyRight:!1}):E(e.id,{x:L-K-10,stickyRight:!0})}},{label:G(u.anchorToBottomEdge,h),checkbox:{active:!0,enabled:!0,value:k},action:()=>{let L=ue.height,K=typeof e.height=="string"?parseFloat(e.height):e.height;k?E(e.id,{stickyBottom:!1}):E(e.id,{y:L-K-10,stickyBottom:!0})}}]}})},className:"custom-tab-btn btn-anchor-tab",children:U("svg",{className:`anchor-icon ${e.stickyRight&&e.stickyBottom?"anchor-sticky-both":e.stickyRight?"anchor-sticky-right":e.stickyBottom?"anchor-sticky-bottom":""}`,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[g("circle",{cx:"12",cy:"5",r:"2"}),g("path",{d:"M12 7v7m0 0a4 4 0 0 1-4-4M12 14a4 4 0 0 0 4-4M5 18h14"})]})}),g("button",{type:"button",title:o?G(u.restoreSize,h):G(u.maximize,h),onClick:()=>W(e.id),className:"custom-tab-btn btn-maximize-tab",children:g("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:g("rect",{x:"4",y:"4",width:"16",height:"16",rx:"1.5"})})}),w?.canMinimize!==!1&&g("button",{type:"button",title:G(u.minimize,h),onClick:()=>N(e.id),className:"custom-tab-btn btn-minimize-tab",children:g("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:g("path",{d:"M5 12h14"})})}),w?.canClose!==!1&&g("button",{type:"button",title:G(u.close,h),onClick:()=>R(e.id),className:"custom-tab-btn btn-close-tab",children:g("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:g("path",{d:"M18 6L6 18M6 6l12 12"})})})]})]}),g("div",{className:B??void 0,style:{flexGrow:1,width:"100%",overflow:"hidden",position:"relative",isolation:"isolate"},children:g(Et,{panelId:e.id},e.id)}),!o&&g("div",{onMouseDown:O=>tt(e.id,O),style:{position:"absolute",right:0,bottom:0,width:"14px",height:"14px",cursor:"se-resize",zIndex:30,background:"linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.2) 50%)"}})]},e.id)})]}),r.minimized.length>0&&U("div",{className:"taskbar-footer-container",style:{height:"48px",zIndex:100},children:[g("button",{type:"button",onClick:()=>t("left"),className:"taskbar-nav-btn",style:{display:r.minimized.length>4?"block":"none"},children:"\u25C0"}),g("div",{ref:f,className:"taskbar-items-container",style:{scrollSnapType:"x mandatory"},children:r.minimized.map(e=>{let o=_.get(e.component)?.defaultOptions?.icon||l||ct;return g("div",{onClick:()=>{H(null),y(e.id)},onContextMenu:m=>qe(e.id,m),onMouseEnter:m=>{if(Z)return;$.current&&clearTimeout($.current);let c=m.currentTarget.getBoundingClientRect();m.clientX>=c.left&&m.clientX<=c.right&&m.clientY>=c.top&&m.clientY<=c.bottom&&H({id:e.id,rect:c,title:e.title,component:e.component})},onMouseLeave:()=>{$.current=setTimeout(()=>{H(null)},150)},className:"taskbar-glassmorphic-item",style:{backdropFilter:"blur(6px)",transition:"all 0.2s",cursor:"pointer",scrollSnapAlign:"start",width:"38px",height:"38px",position:"relative",padding:0},children:g("span",{className:"taskbar-item-icon",children:o})},e.id)})}),z&&St(U("div",{className:"taskbar-item-tooltip",dir:r.dir,style:{position:"fixed",left:`${z.rect.left+z.rect.width/2}px`,top:`${z.rect.top-8}px`,transform:"translateX(-50%) translateY(-100%)",opacity:1,pointerEvents:"auto",zIndex:999999},onMouseEnter:()=>{$.current&&clearTimeout($.current)},onMouseLeave:()=>{H(null)},onClick:()=>{y(z.id),H(null)},children:[U("div",{className:"tooltip-header-row",children:[U("span",{className:"tooltip-title-text text-truncate",style:{maxWidth:"140px"},children:[G(z.title,h),r.panels[z.id]?.dirty?" *":""]}),g("span",{onClick:e=>{e.stopPropagation(),R(z.id),H(null)},title:G(u.closePanel,h),className:"tooltip-close-x",children:g("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:g("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),g(dn,{panelId:z.id})]}),document.body),g("button",{type:"button",onClick:()=>t("right"),className:"taskbar-nav-btn",style:{display:r.minimized.length>4?"block":"none"},children:"\u25B6"})]}),Object.keys(r.panels).map(e=>{let a=r.panels[e];if(!a)return null;let o=zt(e);return St(g(cn,{panelId:e,children:g("div",{style:{width:"100%",height:"100%"},children:ln(e,a.component)})}),o,e)}),g(rn,{ref:I,id:"workspace-context-menu",theme:"dark",onShow:()=>ne(!0),onHide:()=>ne(!1)}),r.draggedPanelId!==null&&!r.floating.some(e=>e.id===r.draggedPanelId)&&U("div",{className:"drag-ghost-tab",style:{left:ee.x+12,top:ee.y+12,zIndex:1e5},children:["\u{1F4C4} ",G(r.panels[r.draggedPanelId]?.title,h)||"Tab"]})]})},pn=gn;import{useCallback as He,useRef as Ft,useEffect as mn,useState as hn,useMemo as yn}from"react";import{Fragment as wn,jsx as de,jsxs as gt}from"react/jsx-runtime";var bn=({modal:i,index:l,isTopmost:r})=>{let{close:y,openModal:N,updateInstance:x,setDirty:W}=Te(),E=oe(),C=ae(),{dir:M}=pe(),{modalClass:T,modalBodyClass:d}=Pe(),P=Ft(null),{id:b,Component:S,props:F,options:p,dirty:h,dirtyOptions:u}=i,R=p,[A,B]=hn(R.icon||null),f=Ft(R);f.current=R;let I=G(R.title,E),z=He(async j=>{if(j?.force){y(b);return}if(P.current){if(!await P.current())return;y(b);return}if(h){N(ze,{title:u?.title||C.unsavedChangesTitle,message:u?.message||{id:C.unsavedChangesMessage.id,defaultMessage:C.unsavedChangesMessage.defaultMessage,values:{title:I}},alert:u?.alert,alertType:u?.alertType||"danger",useYesNoTitles:!0,onOK:()=>y(b)},{size:"small"});return}y(b)},[y,N,b,h,u,I,C]),H=He((j,te)=>W(b,j,te),[W,b]),$=He(j=>x(b,{options:{...f.current,title:j}}),[x,b]),Z=He(j=>B(j),[]),ne=He(j=>(P.current=j,()=>{P.current=null}),[]),ce=yn(()=>({requestClose:z,setDirty:H,setTitle:$,setIcon:Z,onCloseRequested:ne,containerType:"modal",instanceId:b}),[z,H,$,Z,ne,b]),q=h?`${I} *`:I,V=R.size?`v2-modal-size-${R.size}`:"v2-modal-size-auto",ee=R.closable!==!1;mn(()=>{if(!r||!ee)return;let j=te=>{te.key==="Escape"&&(te.stopPropagation(),z())};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[z,ee,r]);let he=1e4+l*10;return gt("div",{className:"v2-modal-overlay",style:{zIndex:he},dir:M,children:[de("div",{className:"v2-modal-curtain",onClick:ee?()=>z():void 0}),gt("div",{className:`v2-modal-window ${V} ${T??""}`,children:[gt("div",{className:"v2-modal-header",children:[A&&de("div",{className:"v2-modal-icon",children:A}),de("h4",{className:"v2-modal-title",children:q}),ee&&de("button",{className:"v2-modal-close-button",onClick:()=>z(),title:E(C.closeTooltip),type:"button",children:de("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:de("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),de("div",{className:`v2-modal-body ${d??""}`,children:de(Ie,{value:ce,children:de(S,{...F,panelId:b})})})]})]})},vn=()=>{let{modals:i}=we();return i.length===0?null:de(wn,{children:i.map((l,r)=>de(bn,{modal:l,index:r,isTopmost:r===i.length-1},l.id))})},Pn=vn;import{useCallback as Fe,useRef as Ot,useEffect as Wt,useState as Cn,useMemo as xn}from"react";import{Fragment as Tn,jsx as se,jsxs as pt}from"react/jsx-runtime";var Ze=({panel:i,position:l,defaultWidth:r})=>{let{close:y,openModal:N,updateInstance:x,setDirty:W,registerCloseHandler:E,unregisterCloseHandler:C}=Te(),{modals:M}=we(),T=oe(),d=ae(),{dir:P}=pe(),{sidePanelClass:b,sidePanelBodyClass:S}=Pe(),F=Ot(null),{id:p,Component:h,props:u,options:R,dirty:A,dirtyOptions:B}=i,f=R,[I,z]=Cn(f.icon||null),H=Ot(f);H.current=f;let $=G(f.title,T),Z=Fe(async X=>{if(X?.force){y(p);return}if(F.current){if(!await F.current())return;y(p);return}if(A){N(ze,{title:B?.title||d.unsavedChangesTitle,message:B?.message||{id:d.unsavedChangesMessage.id,defaultMessage:d.unsavedChangesMessage.defaultMessage,values:{title:$}},alert:B?.alert,alertType:B?.alertType||"danger",useYesNoTitles:!0,onOK:()=>y(p)},{size:"small"});return}y(p)},[y,N,p,A,B,$,d]),ne=Fe(async()=>F.current?await F.current():!A,[A]);Wt(()=>(E(p,ne),()=>C(p)),[p,ne,E,C]);let ce=Fe((X,ye)=>W(p,X,ye),[W,p]),q=Fe(X=>x(p,{options:{...H.current,title:X}}),[x,p]),V=Fe(X=>z(X),[]),ee=Fe(X=>(F.current=X,()=>{F.current=null}),[]),me=xn(()=>({requestClose:Z,setDirty:ce,setTitle:q,setIcon:V,onCloseRequested:ee,containerType:l==="left"?"left-panel":"right-panel",instanceId:p}),[Z,ce,q,V,ee,l,p]),he=A?`${$} *`:$;Wt(()=>{let X=ye=>{ye.key==="Escape"&&M.length===0&&Z()};return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},[Z,M.length]);let j=f.width||r||400,te=typeof j=="number"?`${j}px`:j;return se("div",{className:`v2-side-panel v2-side-panel-${l} v2-side-panel-visible ${b??""}`,style:{width:te},dir:P,children:pt("div",{className:"v2-side-panel-window",children:[pt("div",{className:"v2-side-panel-header",children:[I&&se("div",{className:"v2-side-panel-icon",children:I}),se("h4",{className:"v2-side-panel-title",children:he}),se("button",{className:"v2-side-panel-close-button",onClick:()=>Z(),title:T(d.closeTooltip),type:"button",children:se("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:se("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),se("div",{className:`v2-side-panel-body ${S??""}`,children:se(Ie,{value:me,children:se(h,{...u,panelId:p})})})]})})},Mn=({defaultWidth:i})=>{let{leftPanel:l,rightPanel:r}=we();return pt(Tn,{children:[l&&se(Ze,{panel:l,position:"left",defaultWidth:i},l.id),r&&se(Ze,{panel:r,position:"right",defaultWidth:i},r.id)]})},Rn=({defaultWidth:i})=>{let{leftPanel:l}=we();return l?se(Ze,{panel:l,position:"left",defaultWidth:i},l.id):null},kn=({defaultWidth:i})=>{let{rightPanel:l}=we();return l?se(Ze,{panel:l,position:"right",defaultWidth:i},l.id):null},In=Mn;import{useState as Dt,useEffect as Qe,useRef as Sn,useCallback as At,useImperativeHandle as zn,forwardRef as Ln}from"react";import{Fragment as Nn,jsx as xe,jsxs as Ve}from"react/jsx-runtime";var En=Ln(function({position:l="right",tabs:r,drawerWidth:y="220px",activeTabId:N,onActiveTabChange:x,children:W},E){let C=N!==void 0,M=oe(),T=ae(),[d,P]=Dt(null),b=C?N:d,[S,F]=Dt(()=>{let f=new Set;for(let I of r)I.eagerMount&&f.add(I.id);return f});Qe(()=>{let f=r.filter(I=>I.eagerMount&&!S.has(I.id));f.length>0&&F(I=>{let z=new Set(I);for(let H of f)z.add(H.id);return z})},[r]);let p=Sn(b??null);Qe(()=>{p.current=b??null},[b]);let h=At(f=>{C||P(f),x?.(f)},[C,x]);zn(E,()=>({openTab:f=>h(f),closeDrawer:()=>h(null),getActiveTab:()=>p.current}),[h]);let u=f=>{h(b===f?null:f)},R=At(()=>h(null),[h]);Qe(()=>{b&&!S.has(b)&&F(f=>{let I=new Set(f);return I.add(b),I})},[b,S]),Qe(()=>{b===null&&F(f=>{let I=!1,z=new Set(f);for(let H of f){let $=r.find(Z=>Z.id===H);$&&!$.eagerMount&&!$.preserveState&&(z.delete(H),I=!0)}return I?z:f})},[b,r]);let A=xe("div",{className:`sidebar-tabs-strip ${l}`,style:{width:"56px",height:"100%"},children:r.map(f=>{let I=b===f.id;return xe("button",{type:"button",onClick:()=>u(f.id),className:`sidebar-tab-btn ${I?"active":""}`,title:f.label,"aria-pressed":I,children:f.icon},f.id)})}),B=xe("div",{className:`sidebar-content-drawer h-100 ${l}`,style:{width:b?y:"0px",minWidth:b?y:"0px",overflow:"hidden",flexShrink:0},children:r.map(f=>{if(!S.has(f.id))return null;let z=b===f.id,H=()=>h(f.id);return Ve("div",{style:{display:z?"flex":"none",flexDirection:"column",height:"100%",width:"100%"},children:[Ve("div",{className:"sidebar-drawer-header",children:[xe("span",{className:"sidebar-header-title",children:f.label}),xe("button",{type:"button",onClick:R,className:"sidebar-close-btn",title:M(T.closePanelTooltip),"aria-label":M(T.closePanelTooltip),children:Ve("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[xe("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),xe("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),xe("div",{className:"sidebar-drawer-body",children:f.renderContent(f.id,R,H)})]},f.id)})});return Ve(Nn,{children:[l==="left"&&A,l==="left"&&B,W,l==="right"&&B,l==="right"&&A]})});export{ze as ConfirmationForm,at as FormContainerContext,Ie as FormContainerProvider,Rn as LeftPanelRenderer,Pn as ModalStackRenderer,on as PanelProvider,_ as PanelRegistry,kn as RightPanelRenderer,In as SidePanelRenderer,En as Sidebar,pn as WindowManager,jt as WindowManagerProvider,Oe as defaultPredefinedMessages,G as formatLabel,rt as useFormContainer,oe as useFormatMessage,Te as usePanelActions,Jt as usePanelContext,we as usePanelState,ae as usePredefinedMessages,Pe as useStyleClasses,ke as useWindowManagerActions,pe as useWindowManagerState};
2
2
  //# sourceMappingURL=index.js.map