@oneworks/client 0.1.0-alpha.0 → 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/ActionSearchToolbar-BqRwfUQY.js +1 -0
- package/dist/assets/ActionSearchToolbar-CMBns0Zm.css +1 -0
- package/dist/assets/AgentRoomRoute-BYgM7vgg.js +1 -0
- package/dist/assets/AgentRoomSessionRoute-DdoZY7qL.js +3 -0
- package/dist/assets/ArchiveRoute-ydgLUN7p.js +1 -0
- package/dist/assets/{AuthenticatedApp-BTs4l2pB.js → AuthenticatedApp-CK9TT7Nk.js} +236 -224
- package/dist/assets/AuthenticatedApp-scWyvbOf.css +1 -0
- package/dist/assets/AutomationRoute-CpcRbNa8.js +1 -0
- package/dist/assets/BenchmarkRoute-CZRZVolT.js +21 -0
- package/dist/assets/ChatRoute-DdRVEkAb.js +2 -0
- package/dist/assets/Collapse-CxTS9FJh.js +10 -0
- package/dist/assets/{ComposerLanding-Cl6zfbOm.js → ComposerLanding-BChGuCjF.js} +4 -4
- package/dist/assets/ConfigEditors-BuDavOAj.css +1 -0
- package/dist/assets/ConfigRoute-D_EkHryB.js +28 -0
- package/dist/assets/ConfigRoute-TW2qRRNP.css +1 -0
- package/dist/assets/InteractionStructureRoute-Dpjr6hIq.js +1 -0
- package/dist/assets/KnowledgeRoute-Bp4Da65A.js +1 -0
- package/dist/assets/LauncherApp-ByUpDwod.js +2 -0
- package/dist/assets/LauncherRoute-B94P9m3I.js +2 -0
- package/dist/assets/LauncherRoute-NsK8KCzb.css +1 -0
- package/dist/assets/MobileAwareSelect-BySpAJpa.css +1 -0
- package/dist/assets/MobileAwareSelect-CCAQrsxL.js +37 -0
- package/dist/assets/{ModuleManagementRoute-DQACRan1.js → ModuleManagementRoute-DcrMX6P7.js} +3 -3
- package/dist/assets/NotFoundRoute-C1IfsiZY.js +1 -0
- package/dist/assets/PluginStoreRoute-7UBLkrWc.js +1 -0
- package/dist/assets/PluginStoreRoute-Cfalv335.css +1 -0
- package/dist/assets/RouteContainerPanelTabs-D8pC61tF.js +11 -0
- package/dist/assets/RouteContainerPanelTabs-DAjUmk7i.css +1 -0
- package/dist/assets/SchemaObjectEditor-DvwrURac.js +1 -0
- package/dist/assets/StandaloneMobileDebugRoute--yiQ5EdW.js +1 -0
- package/dist/assets/StandaloneMobileDebugRoute-DuOLjUb9.css +1 -0
- package/dist/assets/WorkspaceApp-l-h_IsMp.js +9 -0
- package/dist/assets/agent-room-session-paths-CYMSFD9m.css +32 -0
- package/dist/assets/agent-room-session-paths-DNpYqOr3.js +537 -0
- package/dist/assets/{arc-BXsvCKst.js → arc-Xh4h56Fv.js} +1 -1
- package/dist/assets/azure-C6wcxVWu.ico +0 -0
- package/dist/assets/{blockDiagram-c4efeb88-hc-xNCrG.js → blockDiagram-c4efeb88-CG3HxYeL.js} +2 -2
- package/dist/assets/{c4Diagram-c83219d4-DVHTOuVr.js → c4Diagram-c83219d4-DiEPAqCg.js} +2 -2
- package/dist/assets/channel-DH-F5Uqk.js +1 -0
- package/dist/assets/classDiagram-beda092f-Dwx44PuJ.js +2 -0
- package/dist/assets/classDiagram-v2-2358418a-COXM437u.js +2 -0
- package/dist/assets/client-build-info-6B4KoYHs.js +1 -0
- package/dist/assets/clone-DGri7oGq.js +1 -0
- package/dist/assets/{createText-1719965b-x3Mhf0Jh.js → createText-1719965b-DPLMqVqY.js} +1 -1
- package/dist/assets/cssMode-DfDq4hLs.js +1 -0
- package/dist/assets/customParseFormat-DwjB960X.js +1 -0
- package/dist/assets/dockPanelConstants-4XXOUD0A.css +1 -0
- package/dist/assets/dockPanelConstants-OzU6hJl5.js +8 -0
- package/dist/assets/{edges-96097737-COVuSxRY.js → edges-96097737-ry9ejc8v.js} +1 -1
- package/dist/assets/{erDiagram-0228fc6a-WcgqCWce.js → erDiagram-0228fc6a-AcCPz3wc.js} +2 -2
- package/dist/assets/{flowDb-c6c81e3f-nYly38YN.js → flowDb-c6c81e3f-BGnBxhJf.js} +1 -1
- package/dist/assets/{flowDiagram-50d868cf-DLYALlBY.js → flowDiagram-50d868cf-BnS6RFWo.js} +2 -2
- package/dist/assets/flowDiagram-v2-4f6560a1-C3klqpJG.js +1 -0
- package/dist/assets/{flowchart-elk-definition-6af322e1-Da8rP8k4.js → flowchart-elk-definition-6af322e1-8-ynORZL.js} +2 -2
- package/dist/assets/{freemarker2-OWISI6Bb.js → freemarker2-uFZBYLEW.js} +2 -2
- package/dist/assets/ganttDiagram-a2739b55-3MEPfmMB.js +257 -0
- package/dist/assets/gemini-B9inYaVW.png +0 -0
- package/dist/assets/{gitGraphDiagram-82fe8481-DCk8Jny9.js → gitGraphDiagram-82fe8481-BKYGV9pb.js} +2 -2
- package/dist/assets/{graph-DvFQr_wY.js → graph-BEwlNa_j.js} +1 -1
- package/dist/assets/handlebars-dg6IZCa7.js +1 -0
- package/dist/assets/html-KunL9NkW.js +1 -0
- package/dist/assets/htmlMode-CrFpTEpC.js +1 -0
- package/dist/assets/{index-5325376f-CRF6GGjL.js → index-5325376f-CCcP_Ahl.js} +1 -1
- package/dist/assets/index-BIs5hzci.js +13 -0
- package/dist/assets/index-BggFUwYR.js +1 -0
- package/dist/assets/index-DdUqPqXW.js +727 -0
- package/dist/assets/{index-BnZLa3J3.js → index-DhpAFZQZ.js} +2 -2
- package/dist/assets/index-YzfSzOLk.js +13 -0
- package/dist/assets/index-ZOsqqPVv.js +36 -0
- package/dist/assets/index-jfuA2A4w.css +1 -0
- package/dist/assets/index-nXq6jwfM.js +3 -0
- package/dist/assets/{infoDiagram-8eee0895-dVa2Kh9_.js → infoDiagram-8eee0895-BzZ34kgw.js} +2 -2
- package/dist/assets/interaction-panel-mobile-debug-pages-8AAd4Csf.css +1 -0
- package/dist/assets/interaction-panel-mobile-debug-pages-DXC3HSZU.js +113 -0
- package/dist/assets/javascript-DA3fh3oR.js +1 -0
- package/dist/assets/{journeyDiagram-c64418c1-BJCT1TJ7.js → journeyDiagram-c64418c1-B_kSGErn.js} +2 -2
- package/dist/assets/{jsonMode-RsjNGxUQ.js → jsonMode-BDucSIBv.js} +4 -4
- package/dist/assets/{layout-BMZRkCUf.js → layout-CRLM1T9z.js} +1 -1
- package/dist/assets/{line-C99msl9T.js → line-Cdyr_7ve.js} +1 -1
- package/dist/assets/{linear-CJHB38BG.js → linear-y86GycLK.js} +1 -1
- package/dist/assets/liquid-mJp997il.js +1 -0
- package/dist/assets/{lspLanguageFeatures-D8zjArb3.js → lspLanguageFeatures-DiGGmudW.js} +1 -1
- package/dist/assets/mdx-Co6h2mZ2.js +1 -0
- package/dist/assets/{mermaid.core-DWzpZH_g.js → mermaid.core-VYJIZL_J.js} +4 -4
- package/dist/assets/micu-dUcmmgZZ.png +0 -0
- package/dist/assets/{mindmap-definition-8da855dc-DulNL_Ks.js → mindmap-definition-8da855dc-DKNG2gyr.js} +2 -2
- package/dist/assets/minimax-B5WRVrUt.png +0 -0
- package/dist/assets/openai-ABb0YGGa.svg +71 -0
- package/dist/assets/openrouter-CsJ_bD5Q.ico +0 -0
- package/dist/assets/{pieDiagram-a8764435-CHfubQBm.js → pieDiagram-a8764435-Cu3up9mc.js} +3 -3
- package/dist/assets/project-file-tree-icons-CfonMx-1.js +2 -0
- package/dist/assets/project-file-tree-icons-DXkdVC0r.css +1 -0
- package/dist/assets/python-BUUKzwmG.js +1 -0
- package/dist/assets/{quadrantDiagram-1e28029f-CFHca9nu.js → quadrantDiagram-1e28029f-DHW8R4el.js} +2 -2
- package/dist/assets/qwen-Cla2cGrM.svg +107 -0
- package/dist/assets/razor-ZPlQfY47.js +1 -0
- package/dist/assets/requesty-DAzbbw8F.ico +0 -0
- package/dist/assets/{requirementDiagram-08caed73-ClrFG92W.js → requirementDiagram-08caed73-CXWNC-_B.js} +2 -2
- package/dist/assets/route-plugin-chrome-bV1HEaju.js +1 -0
- package/dist/assets/sankeyDiagram-a04cb91d-DhKL8pMH.js +8 -0
- package/dist/assets/{sequenceDiagram-c5b8d532-ZoeuLa-n.js → sequenceDiagram-c5b8d532-D3fAcQeI.js} +2 -2
- package/dist/assets/shortcutUtils-B8h6g_7o.js +27 -0
- package/dist/assets/stateDiagram-1ecb1508-wKQS4LMF.js +1 -0
- package/dist/assets/stateDiagram-v2-c2b004d7-D5qOKtOa.js +1 -0
- package/dist/assets/{styles-b4e223ce-0VFG2Z9W.js → styles-b4e223ce-CpBwPex_.js} +1 -1
- package/dist/assets/{styles-ca3715f6-DaJIsB-N.js → styles-ca3715f6-4bqpN1KH.js} +1 -1
- package/dist/assets/{styles-d45a18b0-DT8DH24o.js → styles-d45a18b0-B0RCBD5D.js} +1 -1
- package/dist/assets/{svgDrawCommon-b86b1483-DxTZXiLW.js → svgDrawCommon-b86b1483-C9KXk4gS.js} +1 -1
- package/dist/assets/{timeline-definition-faaaa080-lu3ppiNq.js → timeline-definition-faaaa080-B1Bfjd0m.js} +2 -2
- package/dist/assets/{tsMode-B6pOKC1l.js → tsMode-Bd8BwKXc.js} +2 -2
- package/dist/assets/typescript-CLd6MPK0.js +1 -0
- package/dist/assets/use-app-preferences-DGCafwsP.js +1 -0
- package/dist/assets/use-chat-session-actions-wF_HiVzj.js +2 -0
- package/dist/assets/{vendor-react-BNJ5yonH.js → vendor-react-CnooHTJc.js} +1 -1
- package/dist/assets/vendor-state-zjcHRN98.js +1 -0
- package/dist/assets/worker-BZxxbL_z.js +1 -0
- package/dist/assets/workspace-file-openers-Dj_Cfk1S.js +1 -0
- package/dist/assets/workspace-file-openers-fM4AQXug.css +1 -0
- package/dist/assets/xml-BeC1cWk3.js +1 -0
- package/dist/assets/{xychartDiagram-f5964ef8-DvmrNK0s.js → xychartDiagram-f5964ef8-DbJVUSHy.js} +2 -2
- package/dist/assets/yaml-gQrw9AcN.js +1 -0
- package/dist/assets/yunwu-C0h7koCA.png +0 -0
- package/dist/assets/zhipu-CWmkm5qz.png +0 -0
- package/dist/index.html +4 -4
- package/dist/sw.js +5 -3
- package/package.json +20 -15
- package/dist/assets/AgentRoomRoute-rNmmPMvh.js +0 -1
- package/dist/assets/AgentRoomSessionRoute-Dg8yQRY_.js +0 -1
- package/dist/assets/ArchiveRoute-BWE_JVjl.js +0 -1
- package/dist/assets/AuthenticatedApp-Bop-GglJ.css +0 -1
- package/dist/assets/AutomationRoute-CoJ8YGK2.js +0 -1
- package/dist/assets/BenchmarkRoute-BcRZ1AFC.js +0 -21
- package/dist/assets/ChatRoute-DBN4uo7j.js +0 -1
- package/dist/assets/Collapse-DDrFhfKr.js +0 -8
- package/dist/assets/ConfigEditors-jcXiTWRg.css +0 -1
- package/dist/assets/ConfigRoute-D5zxs-kv.css +0 -1
- package/dist/assets/ConfigRoute-z5Dj1ihn.js +0 -2
- package/dist/assets/ConfigSectionPanel-DHIwutHm.js +0 -13
- package/dist/assets/DockPanel-DuxVeJzf.js +0 -11
- package/dist/assets/DockPanel-HEMeJ1MR.css +0 -1
- package/dist/assets/InteractionStructureRoute-B8yJdycA.js +0 -1
- package/dist/assets/KnowledgeRoute-BPYnBocT.js +0 -1
- package/dist/assets/LauncherApp-BqKOigOK.js +0 -2
- package/dist/assets/LauncherRoute-C1g-gjbs.js +0 -2
- package/dist/assets/LauncherRoute-DtjtKtXc.css +0 -1
- package/dist/assets/PluginStoreRoute-Bny2x-oC.css +0 -1
- package/dist/assets/PluginStoreRoute-CGIBez_4.js +0 -3
- package/dist/assets/SchemaObjectEditor-BdzgIkYh.js +0 -1
- package/dist/assets/WorkspaceApp-DGL3CHCp.js +0 -46
- package/dist/assets/agent-room-session-paths-Bl0JdX79.js +0 -153
- package/dist/assets/agent-room-session-paths-CCE5rS0K.css +0 -32
- package/dist/assets/channel-X7k9544o.js +0 -1
- package/dist/assets/classDiagram-beda092f-C--_J0De.js +0 -2
- package/dist/assets/classDiagram-v2-2358418a-VLoB_o-4.js +0 -2
- package/dist/assets/client-build-info-CUyezPn4.js +0 -37
- package/dist/assets/client-build-info-CgBKDSmG.css +0 -1
- package/dist/assets/clone-BsR4Dtrm.js +0 -1
- package/dist/assets/copy-OJ_6Pvs2.js +0 -28
- package/dist/assets/cssMode-Dg95dCSS.js +0 -1
- package/dist/assets/flowDiagram-v2-4f6560a1-DZXqc8d3.js +0 -1
- package/dist/assets/ganttDiagram-a2739b55-SFoaaNUl.js +0 -257
- package/dist/assets/handlebars-DvhbIeVz.js +0 -1
- package/dist/assets/html-B6ANaoGC.js +0 -1
- package/dist/assets/htmlMode-CA_KA1J8.js +0 -1
- package/dist/assets/index-BfLbHhFR.js +0 -13
- package/dist/assets/index-C9FQLbWu.js +0 -1
- package/dist/assets/index-DA1kZA8X.css +0 -1
- package/dist/assets/index-Dn-Bbs_z.js +0 -705
- package/dist/assets/javascript-qaeO24NX.js +0 -1
- package/dist/assets/liquid-yYJuHMAu.js +0 -1
- package/dist/assets/mdx-CrAkCLhE.js +0 -1
- package/dist/assets/python-h0Aqhxqi.js +0 -1
- package/dist/assets/razor-DalkOWO-.js +0 -1
- package/dist/assets/sankeyDiagram-a04cb91d-C9DgEVjM.js +0 -8
- package/dist/assets/stateDiagram-1ecb1508-DDRxhJDf.js +0 -1
- package/dist/assets/stateDiagram-v2-c2b004d7-CIob4OCF.js +0 -1
- package/dist/assets/typescript-Bn-lx_lA.js +0 -1
- package/dist/assets/use-app-preferences-B4K999VJ.js +0 -1
- package/dist/assets/use-chat-session-actions-5N-NQ9my.js +0 -2
- package/dist/assets/use-project-theme-preview-sources-5CPt1X2N.js +0 -1
- package/dist/assets/vendor-state-CBVXPiKY.js +0 -1
- package/dist/assets/workspace-file-openers-DAuX65xw.js +0 -1
- package/dist/assets/workspace-file-openers-erSFu-UO.css +0 -1
- package/dist/assets/xml-C1SO5DSd.js +0 -1
- package/dist/assets/yaml-DihjE03_.js +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{j as H,r as y,R as M,a as jn,c as Kn}from"./vendor-react-CnooHTJc.js";import{bC as Jn}from"./AuthenticatedApp-CK9TT7Nk.js";import{B as Di}from"./index-DdUqPqXW.js";import{e as ei,f as ti,v as ii,M as At}from"./route-plugin-chrome-bV1HEaju.js";import{D as ni}from"./shortcutUtils-B8h6g_7o.js";import{T as Yn}from"./MobileAwareSelect-CCAQrsxL.js";function Zn({actions:o,closeLabel:e,closeIcon:t="disabled_by_default",fullscreenEnterLabel:i,fullscreenExitLabel:n,fullscreenMinimizedIcon:s="open_in_full",fullscreenMinimizedLabel:l,isFullscreen:a,isMinimized:r=!1,meta:d,onClose:h,onToggleFullscreen:c,title:u}){const p=r?l??i:a?n:i,g=r?s:a?"fullscreen_exit":"fullscreen";return H.jsxs("div",{className:"dock-panel__header",children:[H.jsxs("div",{className:"dock-panel__header-main",children:[u!=null&&H.jsx("div",{className:"dock-panel__title",children:u}),d!=null&&H.jsx("span",{className:"dock-panel__meta",children:d})]}),H.jsx("div",{className:"dock-panel__header-spacer"}),(o!=null||c!=null||h!=null)&&H.jsxs("div",{className:"dock-panel__header-actions",children:[o,c!=null&&p!=null&&H.jsx(Di,{type:"text",className:"dock-panel__close-btn dock-panel__fullscreen-btn","data-dock-panel-no-resize":"true",icon:H.jsx("span",{className:"material-symbols-rounded",children:g}),title:p,"aria-label":p,onClick:c}),h!=null&&e!=null&&H.jsx(Di,{type:"text",className:["dock-panel__close-btn",t==="bottom_panel_close"||t==="bottom_panel_open"?"dock-panel__minimize-btn":""].filter(Boolean).join(" "),"data-dock-panel-no-resize":"true",icon:H.jsx("span",{className:"material-symbols-rounded",children:t}),title:e,"aria-label":e,onClick:h})]})]})}const Xn=180;function qn(){const[o,e]=y.useState(!1),[t,i]=y.useState(!1),n=y.useRef(null),s=y.useCallback(()=>{n.current!=null&&(window.clearTimeout(n.current),n.current=null)},[]),l=y.useCallback(()=>{s(),i(!1),e(!0)},[s]),a=y.useCallback(()=>{s(),i(!0),n.current=window.setTimeout(()=>{e(!1),i(!1),n.current=null},Xn)},[s]),r=y.useCallback(()=>{if(o&&!t){a();return}l()},[l,a,o,t]);return y.useEffect(()=>s,[s]),{enterFullscreen:l,exitFullscreen:a,isFullscreen:o,isFullscreenExiting:t,toggleFullscreen:r}}const Qn=240,qi=180,es=240,Vt=(o,e,t)=>Math.min(Math.max(o,e),Math.max(e,t)),yi=(o,e)=>{if(typeof o=="number")return o;const t=o==null?void 0:o.trim().match(/^(\d+(?:\.\d+)?)%$/);return t==null?qi:e==null?0:Math.max(0,Math.round(e*Number(t[1])/100))},ts=o=>typeof o=="number"?`${o}px`:o,is=o=>(o==null?void 0:o.closest('button, a, input, textarea, select, option, [role="button"], [data-dock-panel-no-resize="true"]'))!=null;function Ar({enterMotion:o="slide-up",allowResize:e=!0,allowFullscreen:t=!1,children:i,className:n,closeIcon:s,closeLabel:l,defaultHeight:a=Qn,footer:r,fullscreenEnterLabel:d,fullscreenExitLabel:h,fullscreenMinimizedIcon:c,fullscreenMinimizedLabel:u,hideHeader:p=!1,isMinimized:g=!1,isResizeDisabled:m=!1,isOpen:f=!0,maxHeight:v=520,meta:b,minimizedHeight:w,minHeight:C=qi,onClose:T,onExpandMinimized:I,resizeLabel:G,storageKey:P,title:F,actions:K}){const L=y.useRef(null),{isFullscreen:j,isFullscreenExiting:ne,toggleFullscreen:U}=qn(),S=j&&!g,[z,ce]=y.useState(null),O=y.useMemo(()=>yi(C,z),[z,C]),[Y,B]=y.useState(()=>f&&o==="slide-up"),be=y.useRef(f),[X,ve]=y.useState(()=>{const N=Number(localStorage.getItem(P)),$=yi(C,null);return Number.isFinite(N)&&N>0?Vt(N,$,v):Vt(a,$,v)}),Z=y.useRef(X),De=e&&!m&&!g&&!S,we=y.useCallback(()=>{const N=L.current;N==null||N.scrollTop===0&&N.scrollLeft===0||N.scrollTo(0,0)},[]);y.useEffect(()=>{const N=be.current;if(be.current=f,!f||o!=="slide-up"){B(!1);return}N||B(!0)},[o,f]),y.useEffect(()=>{if(!Y)return;const N=window.setTimeout(()=>B(!1),es);return()=>window.clearTimeout(N)},[Y]);const ue=y.useCallback(()=>{var ge;const N=(ge=L.current)==null?void 0:ge.parentElement,$=N==null?void 0:N.getBoundingClientRect().height;return $!=null&&Number.isFinite($)?Math.max(0,$):null},[]);y.useEffect(()=>{var Se;const N=()=>ce(ue());N();const $=(Se=L.current)==null?void 0:Se.parentElement;if($==null||typeof ResizeObserver>"u")return;const ge=new ResizeObserver(N);return ge.observe($),()=>ge.disconnect()},[ue]),y.useEffect(()=>{const N=L.current;if(N==null)return;let $=0;const ge=()=>{$===0&&($=window.requestAnimationFrame(()=>{$=0,we()}))};return we(),N.addEventListener("scroll",ge,{passive:!0}),()=>{$!==0&&window.cancelAnimationFrame($),N.removeEventListener("scroll",ge)}},[we]),y.useEffect(()=>{Z.current=X,localStorage.setItem(P,String(X))},[X,P]),y.useEffect(()=>{ve(N=>{var ge,Se;const $=Vt(N,O,v);return $===N?N:(Z.current=$,(ge=L.current)==null||ge.style.setProperty("--dock-panel-height",`${$}px`),(Se=L.current)==null||Se.style.removeProperty("--dock-panel-resize-height"),$)})},[O,v]),y.useEffect(()=>{we()},[S,g,f,X,we]);const fe=y.useCallback(()=>{const N=ue();return N!=null?Math.min(v,N-96):v},[v,ue]),ee=y.useCallback(()=>{var N;return((N=L.current)==null?void 0:N.getBoundingClientRect().height)??X},[X]),le=y.useCallback(N=>{var $;Z.current=N,($=L.current)==null||$.style.setProperty("--dock-panel-resize-height",`${N}px`)},[]),pe=y.useCallback(N=>{var $,ge;Z.current=N,($=L.current)==null||$.style.setProperty("--dock-panel-height",`${N}px`),(ge=L.current)==null||ge.style.removeProperty("--dock-panel-resize-height"),ve(N)},[]),Ce=Jn({axis:"y",cursor:"row-resize",direction:-1,disabled:!De,getMaxValue:fe,getStartValue:ee,max:v,min:O,value:X,onCommit:pe,onPreview:le,onResizeStart:le,shouldIgnorePointerDown:is}),Me=()=>{g&&(I==null||I()),U()},Ke=t||g&&I!=null,vt=typeof i=="function"?i({isFullscreen:S,onToggleFullscreen:Me}):i,de=y.useMemo(()=>({"--dock-panel-height":`${X}px`,"--dock-panel-max-height":`${v}px`,"--dock-panel-min-height":`${O}px`,...w==null?{}:{"--dock-panel-minimized-height":ts(w)}}),[O,v,w,X]);return H.jsxs("div",{ref:L,className:`dock-panel ${Y?"is-entering-slide-up":""} ${f?"is-open":"is-closing"} ${n??""} ${Ce.isResizing?"is-resizing":""} ${g?"is-minimized":""} ${De?"is-resizable":"is-static"} ${m||g||S?"is-resize-disabled":""} ${S?"is-fullscreen":""} ${ne?"is-fullscreen-exiting":""}`,style:de,children:[De&&H.jsx("div",{className:"dock-panel__resize-strip",role:"separator","aria-label":G,"aria-orientation":"horizontal","aria-valuemin":O,"aria-valuemax":v,"aria-valuenow":X,tabIndex:0,title:G,onPointerDown:Ce.handlePointerDown,onKeyDown:Ce.handleKeyDown}),!p&&H.jsx(Zn,{actions:K,closeIcon:s,closeLabel:l,fullscreenEnterLabel:d,fullscreenExitLabel:h,fullscreenMinimizedIcon:c,fullscreenMinimizedLabel:u,isFullscreen:S,isMinimized:g,meta:b,title:F,onClose:T,onToggleFullscreen:Ke?Me:void 0}),H.jsx("div",{className:"dock-panel__body",children:vt}),r!=null&&H.jsx("div",{className:"dock-panel__footer",children:r})]})}/**
|
|
2
|
+
* dockview-core
|
|
3
|
+
* @version 6.2.2
|
|
4
|
+
* @link https://github.com/mathuo/dockview
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/class Qi{}class ze extends Qi{constructor(e,t,i,n){super(),this.viewId=e,this.groupId=t,this.panelId=i,this.tabGroupId=n}}class ut extends Qi{constructor(e,t){super(),this.viewId=e,this.paneId=t}}class ke{constructor(){}static getInstance(){return ke.INSTANCE}hasData(e){return e&&e===this.proto}clearData(e){this.hasData(e)&&(this.proto=void 0,this.data=void 0)}getData(e){if(this.hasData(e))return this.data}setData(e,t){t&&(this.data=e,this.proto=t)}}ke.INSTANCE=new ke;function ae(){const o=ke.getInstance();if(o.hasData(ze.prototype))return o.getData(ze.prototype)[0]}function lt(){const o=ke.getInstance();if(o.hasData(ut.prototype))return o.getData(ut.prototype)[0]}var re;(function(o){o.NONE={dispose:()=>{}};function e(t){return{dispose:()=>{t()}}}o.from=e})(re||(re={}));class V{get isDisposed(){return this._isDisposed}constructor(...e){this._isDisposed=!1,this._disposables=new Set(e)}addDisposables(...e){e.forEach(t=>this._disposables.add(t))}removeDisposable(e){this._disposables.delete(e)}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposables.forEach(e=>e.dispose()),this._disposables.clear())}}class he{constructor(){this._disposable=re.NONE}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&(this._disposable.dispose(),this._disposable=re.NONE)}}var Ye;(function(o){o.any=(...e)=>t=>{const i=e.map(n=>n(t));return{dispose:()=>{i.forEach(n=>{n.dispose()})}}}})(Ye||(Ye={}));class si{constructor(){this._defaultPrevented=!1}get defaultPrevented(){return this._defaultPrevented}preventDefault(){this._defaultPrevented=!0}}class en{constructor(){this._isAccepted=!1}get isAccepted(){return this._isAccepted}accept(){this._isAccepted=!0}}class ns{constructor(){this.events=new Map}get size(){return this.events.size}add(e,t){this.events.set(e,t)}delete(e){this.events.delete(e)}clear(){this.events.clear()}}class It{static create(){var e;return new It((e=new Error().stack)!==null&&e!==void 0?e:"")}constructor(e){this.value=e}print(){console.warn("dockview: stacktrace",this.value)}}class ss{constructor(e,t){this.callback=e,this.stacktrace=t}}class _{static setLeakageMonitorEnabled(e){e!==_.ENABLE_TRACKING&&_.MEMORY_LEAK_WATCHER.clear(),_.ENABLE_TRACKING=e}get value(){return this._last}constructor(e){this.options=e,this._listeners=[],this._disposed=!1,this._pauseTokens=new Set}get event(){return this._event||(this._event=e=>{var t;!((t=this.options)===null||t===void 0)&&t.replay&&this._last!==void 0&&e(this._last);const i=new ss(e,_.ENABLE_TRACKING?It.create():void 0);return this._listeners.push(i),{dispose:()=>{const n=this._listeners.indexOf(i);n>-1&&this._listeners.splice(n,1)}}},_.ENABLE_TRACKING&&_.MEMORY_LEAK_WATCHER.add(this._event,It.create())),this._event}fire(e){var t;if(!(this._pauseTokens.size>0)){!((t=this.options)===null||t===void 0)&&t.replay&&(this._last=e);for(const i of this._listeners)i.callback(e)}}pause(){const e={};return this._pauseTokens.add(e),re.from(()=>this._pauseTokens.delete(e))}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&(_.ENABLE_TRACKING&&queueMicrotask(()=>{var e;for(const t of this._listeners)console.warn("dockview: stacktrace",(e=t.stacktrace)===null||e===void 0?void 0:e.print())}),this._listeners=[]),_.ENABLE_TRACKING&&this._event&&_.MEMORY_LEAK_WATCHER.delete(this._event))}}_.ENABLE_TRACKING=!1;_.MEMORY_LEAK_WATCHER=new ns;function R(o,e,t,i){return o.addEventListener(e,t,i),{dispose:()=>{o.removeEventListener(e,t,i)}}}class xi{constructor(){this._onFired=new _,this._currentFireCount=0,this._queued=!1,this.onEvent=e=>{const t=this._currentFireCount;return this._onFired.event(()=>{this._currentFireCount>t&&e()})}}fire(){this._currentFireCount++,!this._queued&&(this._queued=!0,queueMicrotask(()=>{this._queued=!1,this._onFired.fire()}))}dispose(){this._onFired.dispose()}}class os extends V{constructor(e){super(),this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._value=null,this.addDisposables(this._onDidChange,ft(e,t=>{const i=t.target.scrollWidth>t.target.clientWidth,n=t.target.scrollHeight>t.target.clientHeight;this._value={hasScrollX:i,hasScrollY:n},this._onDidChange.fire(this._value)}))}}function ft(o,e){const t=new ResizeObserver(i=>{requestAnimationFrame(()=>{const n=i[0];e(n)})});return t.observe(o),{dispose:()=>{t.unobserve(o),t.disconnect()}}}const Oe=(o,...e)=>{for(const t of e)o.classList.contains(t)&&o.classList.remove(t)},Re=(o,...e)=>{for(const t of e)o.classList.contains(t)||o.classList.add(t)},E=(o,e,t)=>{const i=o.classList.contains(e);t&&!i&&o.classList.add(e),!t&&i&&o.classList.remove(e)};function Bt(o,e){for(;o;){if(o===e)return!0;o=o.parentNode}return!1}function tn(o){return new rs(o)}class rs extends V{constructor(e){super(),this._onDidFocus=new _,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new _,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=Bt(document.activeElement,e),i=!1;const n=()=>{i=!1,t||(t=!0,this._onDidFocus.fire())},s=()=>{t&&(i=!0,window.setTimeout(()=>{i&&(i=!1,t=!1,this._onDidBlur.fire())},0))};this._refreshStateHandler=()=>{Bt(document.activeElement,e)!==t&&(t?s():n())},this.addDisposables(R(e,"focus",n,!0)),this.addDisposables(R(e,"blur",s,!0))}refreshState(){this._refreshStateHandler()}}const nn="dv-quasiPreventDefault";function as(o){o[nn]=!0}function Si(o){return o[nn]}function ls(o,e){const t=Array.from(e);for(const i of t){if(i.href){const s=o.createElement("link");s.href=i.href,s.type=i.type,s.rel="stylesheet",o.head.appendChild(s)}let n=[];try{i.cssRules&&(n=Array.from(i.cssRules).map(s=>s.cssText))}catch(s){console.warn("dockview: failed to access stylesheet rules due to security restrictions",s)}for(const s of n){const l=o.createElement("style");l.appendChild(o.createTextNode(s)),o.head.appendChild(l)}}}function $t(o){const{left:e,top:t,width:i,height:n}=o.getBoundingClientRect();return{left:e+window.scrollX,top:t+window.scrollY,width:i,height:n}}function ds(o){let e=o;for(;e!=null&&e.parentNode;){if(e.parentNode===document)return!0;e.parentNode instanceof DocumentFragment?e=e.parentNode.host:e=e.parentNode}return!1}function hs(o,e){o.setAttribute("data-testid",e)}function cs(o){const e=[];function t(i){if(i.nodeType===Node.ELEMENT_NODE){o.includes(i.tagName)&&e.push(i),i.shadowRoot&&t(i.shadowRoot);for(const n of i.children)t(n)}}return t(document.documentElement),e}function pt(o=document){const e=cs(["IFRAME","WEBVIEW"]),t=new WeakMap;for(const i of e)t.set(i,i.style.pointerEvents),i.style.pointerEvents="none";return{release:()=>{var i;for(const n of e)n.style.pointerEvents=(i=t.get(n))!==null&&i!==void 0?i:"auto";e.splice(0,e.length)}}}function us(o){function e(n){const s=[];for(let l=0;l<n.classList.length;l++)s.push(n.classList.item(l));return s}let t,i=o;for(;i!==null&&(t=e(i).find(n=>n.startsWith("dockview-theme-")),typeof t!="string");)i=i.parentElement;return t}class kt{constructor(e){this.element=e,this._classNames=[]}setClassNames(e){for(const t of this._classNames)E(this.element,t,!1);this._classNames=e.split(" ").filter(t=>t.trim().length>0);for(const t of this._classNames)E(this.element,t,!0)}}const sn=100;function Pi(o,e){const t=$t(o),i=$t(e);return!(t.left<i.left||t.left+t.width>i.left+i.width||t.top<i.top||t.top+t.height>i.top+i.height)}function ps(o){const e=new _;let t=o.screenX,i=o.screenY,n;const s=()=>{if(o.closed)return;const l=o.screenX,a=o.screenY;(l!==t||a!==i)&&(clearTimeout(n),n=setTimeout(()=>{e.fire()},sn),t=l,i=a),requestAnimationFrame(s)};return s(),e}function ms(o,e){let t;return new V(R(o,"resize",()=>{clearTimeout(t),t=setTimeout(()=>{e()},sn)}))}function fs(o,e,t={buffer:10}){const i=t.buffer,n=o.getBoundingClientRect(),s=e.getBoundingClientRect();let l=0,a=0;const r=n.left-s.left,d=n.top-s.top,h=n.bottom-s.bottom,c=n.right-s.right;r<i?l=i-r:c>i&&(l=-i-c),d<i?a=i-d:h>i&&(a=-h-i),(l!==0||a!==0)&&(o.style.transform=`translate(${l}px, ${a}px)`)}function on(o){let e=o;for(;e&&(e.style.zIndex==="auto"||e.style.zIndex==="");)e=e.parentElement;return e}function Fe(o){if(o.length===0)throw new Error("Invalid tail call");return[o.slice(0,o.length-1),o[o.length-1]]}function rn(o,e){if(o.length!==e.length)return!1;for(let t=0;t<o.length;t++)if(o[t]!==e[t])return!1;return!0}function Lt(o,e){const t=o.indexOf(e);t>-1&&(o.splice(t,1),o.unshift(e))}function Ct(o,e){const t=o.indexOf(e);t>-1&&(o.splice(t,1),o.push(e))}function gs(o,e){for(let t=0;t<o.length;t++){const i=o[t];if(e(i))return t}return-1}function Nt(o,e){const t=o.findIndex(i=>i===e);return t>-1?(o.splice(t,1),!0):!1}const q=(o,e,t)=>e>t?e:Math.min(t,Math.max(o,e)),oi=()=>{let o=1;return{next:()=>(o++).toString()}},Ie=(o,e)=>{const t=[];if(typeof e!="number"&&(e=o,o=0),o<=e)for(let i=o;i<e;i++)t.push(i);else for(let i=o;i>e;i--)t.push(i);return t};class vs{set size(e){this._size=e}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return typeof this._cachedVisibleSize>"u"}get minimumSize(){return this.visible?this.view.minimumSize:0}get viewMinimumSize(){return this.view.minimumSize}get maximumSize(){return this.visible?this.view.maximumSize:0}get viewMaximumSize(){return this.view.maximumSize}get priority(){return this.view.priority}get snap(){return!!this.view.snap}set enabled(e){this.container.style.pointerEvents=e?"":"none"}constructor(e,t,i,n){this.container=e,this.view=t,this.disposable=n,this._cachedVisibleSize=void 0,typeof i=="number"?(this._size=i,this._cachedVisibleSize=void 0,e.classList.add("visible")):(this._size=0,this._cachedVisibleSize=i.cachedVisibleSize)}setVisible(e,t){var i;e!==this.visible&&(e?(this.size=q((i=this._cachedVisibleSize)!==null&&i!==void 0?i:0,this.viewMinimumSize,this.viewMaximumSize),this._cachedVisibleSize=void 0):(this._cachedVisibleSize=typeof t=="number"?t:this.size,this.size=0),this.container.classList.toggle("visible",e),this.view.setVisible&&this.view.setVisible(e))}dispose(){return this.disposable.dispose(),this.view}}var k;(function(o){o.HORIZONTAL="HORIZONTAL",o.VERTICAL="VERTICAL"})(k||(k={}));var Ge;(function(o){o[o.MAXIMUM=0]="MAXIMUM",o[o.MINIMUM=1]="MINIMUM",o[o.DISABLED=2]="DISABLED",o[o.ENABLED=3]="ENABLED"})(Ge||(Ge={}));var oe;(function(o){o.Low="low",o.High="high",o.Normal="normal"})(oe||(oe={}));var Ae;(function(o){o.Distribute={type:"distribute"};function e(i){return{type:"split",index:i}}o.Split=e;function t(i){return{type:"invisible",cachedVisibleSize:i}}o.Invisible=t})(Ae||(Ae={}));class Ze{get contentSize(){return this._contentSize}get size(){return this._size}set size(e){this._size=e}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get length(){return this.viewItems.length}get proportions(){return this._proportions?[...this._proportions]:void 0}get orientation(){return this._orientation}set orientation(e){this._orientation=e;const t=this.size;this.size=this.orthogonalSize,this.orthogonalSize=t,Oe(this.element,"dv-horizontal","dv-vertical"),this.element.classList.add(this.orientation==k.HORIZONTAL?"dv-horizontal":"dv-vertical")}get minimumSize(){return this.viewItems.reduce((e,t)=>e+t.minimumSize,0)}get maximumSize(){return this.length===0?Number.POSITIVE_INFINITY:this.viewItems.reduce((e,t)=>e+t.maximumSize,0)}get startSnappingEnabled(){return this._startSnappingEnabled}set startSnappingEnabled(e){this._startSnappingEnabled!==e&&(this._startSnappingEnabled=e,this.updateSashEnablement())}get endSnappingEnabled(){return this._endSnappingEnabled}set endSnappingEnabled(e){this._endSnappingEnabled!==e&&(this._endSnappingEnabled=e,this.updateSashEnablement())}get disabled(){return this._disabled}set disabled(e){this._disabled=e,E(this.element,"dv-splitview-disabled",e)}get margin(){return this._margin}set margin(e){this._margin=e,E(this.element,"dv-splitview-has-margin",e!==0)}constructor(e,t){var i,n;this.container=e,this.viewItems=[],this.sashes=[],this._size=0,this._orthogonalSize=0,this._contentSize=0,this._proportions=void 0,this._startSnappingEnabled=!0,this._endSnappingEnabled=!0,this._disabled=!1,this._margin=0,this._onDidSashEnd=new _,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new _,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new _,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(s,l,a=this.viewItems.map(g=>g.size),r,d,h=Number.NEGATIVE_INFINITY,c=Number.POSITIVE_INFINITY,u,p)=>{if(s<0||s>this.viewItems.length)return 0;const g=Ie(s,-1),m=Ie(s+1,this.viewItems.length);if(d)for(const S of d)Lt(g,S),Lt(m,S);if(r)for(const S of r)Ct(g,S),Ct(m,S);const f=g.map(S=>this.viewItems[S]),v=g.map(S=>a[S]),b=m.map(S=>this.viewItems[S]),w=m.map(S=>a[S]),C=g.reduce((S,z)=>S+this.viewItems[z].minimumSize-a[z],0),T=g.reduce((S,z)=>S+this.viewItems[z].maximumSize-a[z],0),I=m.length===0?Number.POSITIVE_INFINITY:m.reduce((S,z)=>S+a[z]-this.viewItems[z].minimumSize,0),G=m.length===0?Number.NEGATIVE_INFINITY:m.reduce((S,z)=>S+a[z]-this.viewItems[z].maximumSize,0),P=Math.max(C,G),F=Math.min(I,T);let K=!1;if(u){const S=this.viewItems[u.index],z=l>=u.limitDelta;K=z!==S.visible,S.setVisible(z,u.size)}if(!K&&p){const S=this.viewItems[p.index],z=l<p.limitDelta;K=z!==S.visible,S.setVisible(z,p.size)}if(K)return this.resize(s,l,a,r,d,h,c);const L=q(l,P,F);let j=0,ne=L;for(let S=0;S<f.length;S++){const z=f[S],ce=q(v[S]+ne,z.minimumSize,z.maximumSize),O=ce-v[S];j+=O,ne-=O,z.size=ce}let U=j;for(let S=0;S<b.length;S++){const z=b[S],ce=q(w[S]-U,z.minimumSize,z.maximumSize),O=ce-w[S];U+=O,z.size=ce}return l},this._orientation=(i=t.orientation)!==null&&i!==void 0?i:k.VERTICAL,this.element=this.createContainer(),this.margin=(n=t.margin)!==null&&n!==void 0?n:0,this.proportionalLayout=t.proportionalLayout===void 0?!0:!!t.proportionalLayout,this.viewContainer=this.createViewContainer(),this.sashContainer=this.createSashContainer(),this.element.appendChild(this.sashContainer),this.element.appendChild(this.viewContainer),this.container.appendChild(this.element),this.style(t.styles),t.descriptor&&(this._size=t.descriptor.size,t.descriptor.views.forEach((s,l)=>{const a=s.visible===void 0||s.visible?s.size:{type:"invisible",cachedVisibleSize:s.size},r=s.view;this.addView(r,a,l,!0)}),this._contentSize=this.viewItems.reduce((s,l)=>s+l.size,0),this.saveProportions())}style(e){(e==null?void 0:e.separatorBorder)==="transparent"?(Oe(this.element,"dv-separator-border"),this.element.style.removeProperty("--dv-separator-border")):(Re(this.element,"dv-separator-border"),e!=null&&e.separatorBorder&&this.element.style.setProperty("--dv-separator-border",e.separatorBorder))}isViewVisible(e){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");return this.viewItems[e].visible}setViewVisible(e,t){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");const i=this.viewItems[e];i.setVisible(t,i.size),this.distributeEmptySpace(e),this.layoutViews(),this.saveProportions()}getViewSize(e){return e<0||e>=this.viewItems.length?-1:this.viewItems[e].size}resizeView(e,t){if(e<0||e>=this.viewItems.length)return;const i=Ie(this.viewItems.length).filter(a=>a!==e),n=[...i.filter(a=>this.viewItems[a].priority===oe.Low),e],s=i.filter(a=>this.viewItems[a].priority===oe.High),l=this.viewItems[e];t=Math.round(t),t=q(t,l.minimumSize,Math.min(l.maximumSize,this._size)),l.size=t,this.relayout(n,s)}getViews(){return this.viewItems.map(e=>e.view)}onDidChange(e,t){const i=this.viewItems.indexOf(e);if(i<0||i>=this.viewItems.length)return;t=typeof t=="number"?t:e.size,t=q(t,e.minimumSize,e.maximumSize),e.size=t;const n=Ie(this.viewItems.length).filter(a=>a!==i),s=[...n.filter(a=>this.viewItems[a].priority===oe.Low),i],l=n.filter(a=>this.viewItems[a].priority===oe.High);this.relayout([...s,i],l)}addView(e,t={type:"distribute"},i=this.viewItems.length,n){const s=document.createElement("div");s.className="dv-view",s.appendChild(e.element);let l;typeof t=="number"?l=t:t.type==="split"?l=this.getViewSize(t.index)/2:t.type==="invisible"?l={cachedVisibleSize:t.cachedVisibleSize}:l=e.minimumSize;const a=e.onDidChange(d=>this.onDidChange(r,d.size)),r=new vs(s,e,l,{dispose:()=>{a.dispose(),this.viewContainer.removeChild(s)}});if(i===this.viewItems.length?this.viewContainer.appendChild(s):this.viewContainer.insertBefore(s,this.viewContainer.children.item(i)),this.viewItems.splice(i,0,r),this.viewItems.length>1){const d=document.createElement("div");d.className="dv-sash";const h=u=>{for(const S of this.viewItems)S.enabled=!1;const p=pt(),g=this._orientation===k.HORIZONTAL?u.clientX:u.clientY,m=gs(this.sashes,S=>S.container===d),f=this.viewItems.map(S=>S.size);let v,b;const w=Ie(m,-1),C=Ie(m+1,this.viewItems.length),T=w.reduce((S,z)=>S+(this.viewItems[z].minimumSize-f[z]),0),I=w.reduce((S,z)=>S+(this.viewItems[z].viewMaximumSize-f[z]),0),G=C.length===0?Number.POSITIVE_INFINITY:C.reduce((S,z)=>S+(f[z]-this.viewItems[z].minimumSize),0),P=C.length===0?Number.NEGATIVE_INFINITY:C.reduce((S,z)=>S+(f[z]-this.viewItems[z].viewMaximumSize),0),F=Math.max(T,P),K=Math.min(G,I),L=this.findFirstSnapIndex(w),j=this.findFirstSnapIndex(C);if(typeof L=="number"){const S=this.viewItems[L],z=Math.floor(S.viewMinimumSize/2);v={index:L,limitDelta:S.visible?F-z:F+z,size:S.size}}if(typeof j=="number"){const S=this.viewItems[j],z=Math.floor(S.viewMinimumSize/2);b={index:j,limitDelta:S.visible?K+z:K-z,size:S.size}}const ne=S=>{const ce=(this._orientation===k.HORIZONTAL?S.clientX:S.clientY)-g;this.resize(m,ce,f,void 0,void 0,F,K,v,b),this.distributeEmptySpace(),this.layoutViews()},U=()=>{for(const S of this.viewItems)S.enabled=!0;p.release(),this.saveProportions(),document.removeEventListener("pointermove",ne),document.removeEventListener("pointerup",U),document.removeEventListener("pointercancel",U),document.removeEventListener("contextmenu",U),this._onDidSashEnd.fire(void 0)};document.addEventListener("pointermove",ne),document.addEventListener("pointerup",U),document.addEventListener("pointercancel",U),document.addEventListener("contextmenu",U)};d.addEventListener("pointerdown",h);const c={container:d,disposable:()=>{d.removeEventListener("pointerdown",h),this.sashContainer.removeChild(d)}};this.sashContainer.appendChild(d),this.sashes.push(c)}n||this.relayout([i]),!n&&typeof t!="number"&&t.type==="distribute"&&this.distributeViewSizes(),this._onDidAddView.fire(e)}distributeViewSizes(){const e=[];let t=0;for(const a of this.viewItems)a.maximumSize-a.minimumSize>0&&(e.push(a),t+=a.size);const i=Math.floor(t/e.length);for(const a of e)a.size=q(i,a.minimumSize,a.maximumSize);const n=Ie(this.viewItems.length),s=n.filter(a=>this.viewItems[a].priority===oe.Low),l=n.filter(a=>this.viewItems[a].priority===oe.High);this.relayout(s,l)}removeView(e,t,i=!1){const n=this.viewItems.splice(e,1)[0];if(n.dispose(),this.viewItems.length>=1){const s=Math.max(e-1,0);this.sashes.splice(s,1)[0].disposable()}return i||this.relayout(),t&&t.type==="distribute"&&this.distributeViewSizes(),this._onDidRemoveView.fire(n.view),n.view}getViewCachedVisibleSize(e){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");return this.viewItems[e].cachedVisibleSize}moveView(e,t){const i=this.getViewCachedVisibleSize(e),n=typeof i>"u"?this.getViewSize(e):Ae.Invisible(i),s=this.removeView(e,void 0,!0);this.addView(s,n,t)}layout(e,t){const i=Math.max(this.size,this._contentSize);if(this.size=e,this.orthogonalSize=t,this.proportions){let n=0;for(let s=0;s<this.viewItems.length;s++){const l=this.viewItems[s],a=this.proportions[s];typeof a=="number"?n+=a:e-=l.size}for(let s=0;s<this.viewItems.length;s++){const l=this.viewItems[s],a=this.proportions[s];typeof a=="number"&&n>0&&(l.size=q(Math.round(a*e/n),l.minimumSize,l.maximumSize))}}else{const n=Ie(this.viewItems.length),s=n.filter(a=>this.viewItems[a].priority===oe.Low),l=n.filter(a=>this.viewItems[a].priority===oe.High);this.resize(this.viewItems.length-1,e-i,void 0,s,l)}this.distributeEmptySpace(),this.layoutViews()}relayout(e,t){const i=this.viewItems.reduce((n,s)=>n+s.size,0);this.resize(this.viewItems.length-1,this._size-i,void 0,e,t),this.distributeEmptySpace(),this.layoutViews(),this.saveProportions()}distributeEmptySpace(e){const t=this.viewItems.reduce((a,r)=>a+r.size,0);let i=this.size-t;const n=Ie(this.viewItems.length-1,-1),s=n.filter(a=>this.viewItems[a].priority===oe.Low),l=n.filter(a=>this.viewItems[a].priority===oe.High);for(const a of l)Lt(n,a);for(const a of s)Ct(n,a);typeof e=="number"&&Ct(n,e);for(let a=0;i!==0&&a<n.length;a++){const r=this.viewItems[n[a]],d=q(r.size+i,r.minimumSize,r.maximumSize),h=d-r.size;i-=h,r.size=d}}saveProportions(){this.proportionalLayout&&this._contentSize>0&&(this._proportions=this.viewItems.map(e=>e.visible?e.size/this._contentSize:void 0))}layoutViews(){if(this._contentSize=this.viewItems.reduce((r,d)=>r+d.size,0),this.updateSashEnablement(),this.viewItems.length===0)return;const e=this.viewItems.filter(r=>r.visible),t=Math.max(0,e.length-1),i=this.margin*t/Math.max(1,e.length);let n=0;const s=[],l=4,a=this.viewItems.reduce((r,d,h)=>{const c=d.visible?1:0;return h===0?r.push(c):r.push(r[h-1]+c),r},[]);this.viewItems.forEach((r,d)=>{n+=this.viewItems[d].size,s.push(n);const h=r.visible?r.size-i:0,c=Math.max(0,a[d]-1),u=d===0||c===0?0:s[d-1]+c/t*i;if(d<this.viewItems.length-1){const p=r.visible?u+h-l/2+this.margin/2:u;this._orientation===k.HORIZONTAL&&(this.sashes[d].container.style.left=`${p}px`,this.sashes[d].container.style.top="0px"),this._orientation===k.VERTICAL&&(this.sashes[d].container.style.left="0px",this.sashes[d].container.style.top=`${p}px`)}this._orientation===k.HORIZONTAL&&(r.container.style.width=`${h}px`,r.container.style.left=`${u}px`,r.container.style.top="",r.container.style.height=""),this._orientation===k.VERTICAL&&(r.container.style.height=`${h}px`,r.container.style.top=`${u}px`,r.container.style.width="",r.container.style.left=""),r.view.layout(r.size-i,this._orthogonalSize)})}findFirstSnapIndex(e){for(const t of e){const i=this.viewItems[t];if(i.visible&&i.snap)return t}for(const t of e){const i=this.viewItems[t];if(i.visible&&i.maximumSize-i.minimumSize>0)return;if(!i.visible&&i.snap)return t}}updateSashEnablement(){let e=!1;const t=this.viewItems.map(r=>e=r.size-r.minimumSize>0||e);e=!1;const i=this.viewItems.map(r=>e=r.maximumSize-r.size>0||e),n=[...this.viewItems].reverse();e=!1;const s=n.map(r=>e=r.size-r.minimumSize>0||e).reverse();e=!1;const l=n.map(r=>e=r.maximumSize-r.size>0||e).reverse();let a=0;for(let r=0;r<this.sashes.length;r++){const d=this.sashes[r],h=this.viewItems[r];a+=h.size;const c=!(t[r]&&l[r+1]),u=!(i[r]&&s[r+1]);if(c&&u){const p=Ie(r,-1),g=Ie(r+1,this.viewItems.length),m=this.findFirstSnapIndex(p),f=this.findFirstSnapIndex(g),v=typeof m=="number"&&!this.viewItems[m].visible,b=typeof f=="number"&&!this.viewItems[f].visible;v&&s[r]&&(a>0||this.startSnappingEnabled)?this.updateSash(d,Ge.MINIMUM):b&&t[r]&&(a<this._contentSize||this.endSnappingEnabled)?this.updateSash(d,Ge.MAXIMUM):this.updateSash(d,Ge.DISABLED)}else c&&!u?this.updateSash(d,Ge.MINIMUM):!c&&u?this.updateSash(d,Ge.MAXIMUM):this.updateSash(d,Ge.ENABLED)}}updateSash(e,t){E(e.container,"dv-disabled",t===Ge.DISABLED),E(e.container,"dv-enabled",t===Ge.ENABLED),E(e.container,"dv-maximum",t===Ge.MAXIMUM),E(e.container,"dv-minimum",t===Ge.MINIMUM)}createViewContainer(){const e=document.createElement("div");return e.className="dv-view-container",e}createSashContainer(){const e=document.createElement("div");return e.className="dv-sash-container",e}createContainer(){const e=document.createElement("div"),t=this._orientation===k.HORIZONTAL?"dv-horizontal":"dv-vertical";return e.className=`dv-split-view-container ${t}`,e}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.removeChild(this.element);break}for(const e of this.viewItems)e.dispose();this.element.remove()}}const Ut=Object.keys({orientation:void 0,descriptor:void 0,proportionalLayout:void 0,styles:void 0,margin:void 0,disableAutoResizing:void 0,className:void 0});class Gi extends V{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(e,t){var i;super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._orientation=(i=t.orientation)!==null&&i!==void 0?i:k.VERTICAL,this.element=document.createElement("div"),this.element.className="dv-pane-container",e.appendChild(this.element),this.splitview=new Ze(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:t.descriptor}),this.getPanes().forEach(n=>{const s=new V(n.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),l={pane:n,disposable:{dispose:()=>{s.dispose()}}};this.paneItems.push(l),n.orthogonalSize=this.splitview.orthogonalSize}),this.addDisposables(this._onDidChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire(void 0)}),this.splitview.onDidAddView(()=>{this._onDidChange.fire()}),this.splitview.onDidRemoveView(()=>{this._onDidChange.fire()}))}setViewVisible(e,t){this.splitview.setViewVisible(e,t)}addPane(e,t,i=this.splitview.length,n=!1){const s=e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)}),l={pane:e,disposable:{dispose:()=>{s.dispose()}}};this.paneItems.splice(i,0,l),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,i,n)}getViewSize(e){return this.splitview.getViewSize(e)}getPanes(){return this.splitview.getViews()}removePane(e,t={skipDispose:!1}){const i=this.paneItems.splice(e,1)[0];return this.splitview.removeView(e),t.skipDispose||(i.disposable.dispose(),i.pane.dispose()),i}moveView(e,t){if(e===t)return;const i=this.removePane(e,{skipDispose:!0});this.skipAnimation=!0;try{this.addPane(i.pane,i.pane.size,t,!1)}finally{this.skipAnimation=!1}}layout(e,t){this.splitview.layout(e,t)}setupAnimation(){this.skipAnimation||(this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=void 0),Re(this.element,"dv-animated"),this.animationTimer=setTimeout(()=>{this.animationTimer=void 0,Oe(this.element,"dv-animated")},200))}dispose(){super.dispose(),this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=void 0),this.paneItems.forEach(e=>{e.disposable.dispose(),e.pane.dispose()}),this.paneItems=[],this.splitview.dispose(),this.element.remove()}}class me{get minimumWidth(){return this.view.minimumWidth}get maximumWidth(){return this.view.maximumWidth}get minimumHeight(){return this.view.minimumHeight}get maximumHeight(){return this.view.maximumHeight}get priority(){return this.view.priority}get snap(){return this.view.snap}get minimumSize(){return this.orientation===k.HORIZONTAL?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===k.HORIZONTAL?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===k.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===k.HORIZONTAL?this.maximumWidth:this.maximumHeight}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get element(){return this.view.element}get width(){return this.orientation===k.HORIZONTAL?this.orthogonalSize:this.size}get height(){return this.orientation===k.HORIZONTAL?this.size:this.orthogonalSize}constructor(e,t,i,n=0){this.view=e,this.orientation=t,this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._orthogonalSize=i,this._size=n,this._disposable=this.view.onDidChange(s=>{s?this._onDidChange.fire({size:this.orientation===k.VERTICAL?s.width:s.height,orthogonalSize:this.orientation===k.VERTICAL?s.height:s.width}):this._onDidChange.fire({})})}setVisible(e){this.view.setVisible&&this.view.setVisible(e)}layout(e,t){this._size=e,this._orthogonalSize=t,this.view.layout(this.width,this.height)}dispose(){this._onDidChange.dispose(),this._disposable.dispose()}}class se extends V{get width(){return this.orientation===k.HORIZONTAL?this.size:this.orthogonalSize}get height(){return this.orientation===k.HORIZONTAL?this.orthogonalSize:this.size}get minimumSize(){return this.children.length===0?0:Math.max(...this.children.map((e,t)=>this.splitview.isViewVisible(t)?e.minimumOrthogonalSize:0))}get maximumSize(){return Math.min(...this.children.map((e,t)=>this.splitview.isViewVisible(t)?e.maximumOrthogonalSize:Number.POSITIVE_INFINITY))}get minimumOrthogonalSize(){return this.splitview.minimumSize}get maximumOrthogonalSize(){return this.splitview.maximumSize}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get minimumWidth(){return this.orientation===k.HORIZONTAL?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===k.HORIZONTAL?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===k.HORIZONTAL?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===k.HORIZONTAL?this.maximumSize:this.maximumOrthogonalSize}get priority(){if(this.children.length===0)return oe.Normal;const e=this.children.map(t=>typeof t.priority>"u"?oe.Normal:t.priority);return e.some(t=>t===oe.High)?oe.High:e.some(t=>t===oe.Low)?oe.Low:oe.Normal}get disabled(){return this.splitview.disabled}set disabled(e){this.splitview.disabled=e}get margin(){return this.splitview.margin}set margin(e){this.splitview.margin=e,this.children.forEach(t=>{t instanceof se&&(t.margin=e)})}constructor(e,t,i,n,s,l,a,r){if(super(),this.orientation=e,this.proportionalLayout=t,this.styles=i,this._childrenDisposable=re.NONE,this.children=[],this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new _,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._orthogonalSize=s,this._size=n,this.element=document.createElement("div"),this.element.className="dv-branch-node",!r)this.splitview=new Ze(this.element,{orientation:this.orientation,proportionalLayout:t,styles:i,margin:a}),this.splitview.layout(this.size,this.orthogonalSize);else{const d={views:r.map(h=>({view:h.node,size:h.node.size,visible:h.node instanceof me&&h.visible!==void 0?h.visible:!0})),size:this.orthogonalSize};this.children=r.map(h=>h.node),this.splitview=new Ze(this.element,{orientation:this.orientation,descriptor:d,proportionalLayout:t,styles:i,margin:a})}this.disabled=l,this.addDisposables(this._onDidChange,this._onDidVisibilityChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire({})})),this.setupChildrenEvents()}setVisible(e){}isChildVisible(e){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.isViewVisible(e)}setChildVisible(e,t){if(e<0||e>=this.children.length)throw new Error("Invalid index");if(this.splitview.isViewVisible(e)===t)return;const i=this.splitview.contentSize===0;this.splitview.setViewVisible(e,t);const n=this.splitview.contentSize===0;(t&&i||!t&&n)&&this._onDidVisibilityChange.fire({visible:t})}moveChild(e,t){if(e===t)return;if(e<0||e>=this.children.length)throw new Error("Invalid from index");e<t&&t--,this.splitview.moveView(e,t);const i=this._removeChild(e);this._addChild(i,t)}getChildSize(e){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewSize(e)}resizeChild(e,t){if(e<0||e>=this.children.length)throw new Error("Invalid index");this.splitview.resizeView(e,t)}layout(e,t){this._size=t,this._orthogonalSize=e,this.splitview.layout(t,e)}addChild(e,t,i,n){if(i<0||i>this.children.length)throw new Error("Invalid index");this.splitview.addView(e,t,i,n),this._addChild(e,i)}getChildCachedVisibleSize(e){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewCachedVisibleSize(e)}removeChild(e,t){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.removeView(e,t),this._removeChild(e)}_addChild(e,t){this.children.splice(t,0,e),this.setupChildrenEvents()}_removeChild(e){const[t]=this.children.splice(e,1);return this.setupChildrenEvents(),t}setupChildrenEvents(){this._childrenDisposable.dispose(),this._childrenDisposable=new V(Ye.any(...this.children.map(e=>e.onDidChange))(e=>{this._onDidChange.fire({size:e.orthogonalSize})}),...this.children.map((e,t)=>e instanceof se?e.onDidVisibilityChange(({visible:i})=>{this.setChildVisible(t,i)}):re.NONE))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach(e=>e.dispose()),super.dispose()}}function jt(o,e){if(o instanceof me)return o;if(o instanceof se)return jt(o.children[e?o.children.length-1:0],e);throw new Error("invalid node")}function an(o,e,t){if(o instanceof se){const i=new se(o.orientation,o.proportionalLayout,o.styles,e,t,o.disabled,o.margin);for(let n=o.children.length-1;n>=0;n--){const s=o.children[n];i.addChild(an(s,s.size,s.orthogonalSize),s.size,0,!0)}return i}else return new me(o.view,o.orientation,t)}function Kt(o,e,t){if(o instanceof se){const i=new se(He(o.orientation),o.proportionalLayout,o.styles,e,t,o.disabled,o.margin);let n=0;for(let s=o.children.length-1;s>=0;s--){const l=o.children[s],a=l instanceof se?l.orthogonalSize:l.size;let r=o.size===0?0:Math.round(e*a/o.size);n+=r,s===0&&(r+=e-n),i.addChild(Kt(l,t,r),r,0,!0)}return i}else return new me(o.view,He(o.orientation),t)}function _s(o){const e=o.parentElement;if(!e)throw new Error("Invalid grid element");let t=e.firstElementChild,i=0;for(;t!==o&&t!==e.lastElementChild&&t;)t=t.nextElementSibling,i++;return i}function Q(o){const e=o.parentElement;if(!e)throw new Error("Invalid grid element");if(/\bdv-grid-view\b/.test(e.className))return[];const t=_s(e),i=e.parentElement.parentElement.parentElement;return[...Q(i),t]}function Ee(o,e,t){const i=ws(o,e),n=bs(t);if(i===n){const[s,l]=Fe(e);let a=l;return(t==="right"||t==="bottom")&&(a+=1),[...s,a]}else{const s=t==="right"||t==="bottom"?1:0;return[...e,s]}}function bs(o){return o==="top"||o==="bottom"?k.VERTICAL:k.HORIZONTAL}function ws(o,e){return e.length%2===0?He(o):o}const He=o=>o===k.HORIZONTAL?k.VERTICAL:k.HORIZONTAL;function Cs(o){return!!o.children}const Jt=(o,e)=>{const t=e===k.VERTICAL?o.box.width:o.box.height;return Cs(o)?{type:"branch",data:o.children.map(i=>Jt(i,He(e))),size:t}:typeof o.cachedVisibleSize=="number"?{type:"leaf",data:o.view.toJSON(),size:o.cachedVisibleSize,visible:!1}:{type:"leaf",data:o.view.toJSON(),size:t}};class Ds{get length(){return this._root?this._root.children.length:0}get orientation(){return this.root.orientation}set orientation(e){if(this.root.orientation===e)return;const{size:t,orthogonalSize:i}=this.root;this.root=Kt(this.root,i,t),this.root.layout(t,i)}get width(){return this.root.width}get height(){return this.root.height}get minimumWidth(){return this.root.minimumWidth}get minimumHeight(){return this.root.minimumHeight}get maximumWidth(){return this.root.maximumHeight}get maximumHeight(){return this.root.maximumHeight}get locked(){return this._locked}set locked(e){this._locked=e;const t=[this.root];for(;t.length>0;){const i=t.pop();i instanceof se&&(i.disabled=e,t.push(...i.children))}}get margin(){return this._margin}set margin(e){this._margin=e,this.root.margin=e}maximizedView(){var e;return(e=this._maximizedNode)===null||e===void 0?void 0:e.leaf.view}hasMaximizedView(){return this._maximizedNode!==void 0}maximizeView(e){var t;const i=Q(e.element),[n,s]=this.getNode(i);if(!(s instanceof me)||((t=this._maximizedNode)===null||t===void 0?void 0:t.leaf)===s)return;this.hasMaximizedView()&&this.exitMaximizedView(),Jt(this.getView(),this.orientation);const l=[];function a(r,d){for(let h=0;h<r.children.length;h++){const c=r.children[h];c instanceof me?c!==d&&(r.isChildVisible(h)?r.setChildVisible(h,!1):l.push(c)):a(c,d)}}a(this.root,s),this._maximizedNode={leaf:s,hiddenOnMaximize:l},this._onDidMaximizedNodeChange.fire({view:s.view,isMaximized:!0})}exitMaximizedView(){if(!this._maximizedNode)return;const e=this._maximizedNode.hiddenOnMaximize;function t(n){for(let s=n.children.length-1;s>=0;s--){const l=n.children[s];l instanceof me?e.includes(l)||n.setChildVisible(s,!0):t(l)}}t(this.root);const i=this._maximizedNode.leaf;this._maximizedNode=void 0,this._onDidMaximizedNodeChange.fire({view:i.view,isMaximized:!1})}serialize(){const e=this.maximizedView();let t;e&&(t=Q(e.element));const i=this._onDidMaximizedNodeChange.pause();try{this.hasMaximizedView()&&this.exitMaximizedView();const s={root:Jt(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation};return t&&(s.maximizedNode={location:t}),e&&this.maximizeView(e),s}finally{i.dispose()}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this._onDidMaximizedNodeChange.dispose(),this._onDidViewVisibilityChange.dispose(),this.root.dispose(),this._maximizedNode=void 0,this.element.remove()}clear(){const e=this.root.orientation;this.root=new se(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize,this.locked,this.margin)}deserialize(e,t){const i=e.orientation,n=i===k.VERTICAL?e.height:e.width;if(this._deserialize(e.root,i,t,n),this.layout(e.width,e.height),e.maximizedNode){const s=e.maximizedNode.location,[l,a]=this.getNode(s);if(!(a instanceof me))return;this.maximizeView(a.view)}}_deserialize(e,t,i,n){this.root=this._deserializeNode(e,t,i,n)}_deserializeNode(e,t,i,n){var s;let l;if(e.type==="branch"){const r=e.data.map(d=>({node:this._deserializeNode(d,He(t),i,e.size),visible:d.visible}));l=new se(t,this.proportionalLayout,this.styles,e.size,n,this.locked,this.margin,r)}else{const a=i.fromJSON(e);typeof e.visible=="boolean"&&((s=a.setVisible)===null||s===void 0||s.call(a,e.visible)),l=new me(a,t,n,e.size)}return l}get root(){return this._root}set root(e){const t=this._root;t&&(t.dispose(),this._maximizedNode=void 0,this.element.removeChild(t.element)),this._root=e,this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(i=>{this._onDidChange.fire(i)})}normalize(){if(!this._root||this._root.children.length!==1)return;const e=this.root,t=e.children[0];if(t instanceof me)return;e.element.remove();const i=e.removeChild(0);e.dispose(),i.dispose(),this._root=an(t,t.size,t.orthogonalSize),this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(n=>{this._onDidChange.fire(n)})}insertOrthogonalSplitviewAtRoot(){if(!this._root)return;const e=this.root;if(e.element.remove(),this._root=new se(He(e.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size,this.locked,this.margin),e.children.length!==0)if(e.children.length===1){const t=e.children[0];e.removeChild(0).dispose(),e.dispose(),this._root.addChild(Kt(t,t.orthogonalSize,t.size),Ae.Distribute,0)}else this._root.addChild(e,Ae.Distribute,0);this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(t=>{this._onDidChange.fire(t)})}next(e){return this.progmaticSelect(e)}previous(e){return this.progmaticSelect(e,!0)}getView(e){const t=e?this.getNode(e)[1]:this.root;return this._getViews(t,this.orientation)}_getViews(e,t,i){const n={height:e.height,width:e.width};if(e instanceof me)return{box:n,view:e.view,cachedVisibleSize:i};const s=[];for(let l=0;l<e.children.length;l++){const a=e.children[l],r=e.getChildCachedVisibleSize(l);s.push(this._getViews(a,He(t),r))}return{box:n,children:s}}progmaticSelect(e,t=!1){const[i,n]=this.getNode(e);if(!(n instanceof me))throw new Error("invalid location");for(let s=i.length-1;s>-1;s--){const l=i[s],a=e[s]||0;if(t?a-1>-1:a+1<l.children.length)return jt(l.children[t?a-1:a+1],t)}return jt(this.root,t)}constructor(e,t,i,n,s){this.proportionalLayout=e,this.styles=t,this._locked=!1,this._margin=0,this._maximizedNode=void 0,this.disposable=new he,this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._onDidViewVisibilityChange=new _,this.onDidViewVisibilityChange=this._onDidViewVisibilityChange.event,this._onDidMaximizedNodeChange=new _,this.onDidMaximizedNodeChange=this._onDidMaximizedNodeChange.event,this.element=document.createElement("div"),this.element.className="dv-grid-view",this._locked=n??!1,this._margin=s??0,this.root=new se(i,e,t,0,0,this.locked,this.margin)}isViewVisible(e){const[t,i]=Fe(e),[,n]=this.getNode(t);if(!(n instanceof se))throw new Error("Invalid from location");return n.isChildVisible(i)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,n]=Fe(e),[,s]=this.getNode(i);if(!(s instanceof se))throw new Error("Invalid from location");this._onDidViewVisibilityChange.fire(),s.setChildVisible(n,t)}moveView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[,n]=this.getNode(e);if(!(n instanceof se))throw new Error("Invalid location");n.moveChild(t,i)}addView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[n,s]=Fe(i),[l,a]=this.getNode(n);if(a instanceof se){const r=new me(e,He(a.orientation),a.orthogonalSize);a.addChild(r,t,s)}else{const[r,...d]=[...l].reverse(),[h,...c]=[...n].reverse();let u=0;const p=r.getChildCachedVisibleSize(h);typeof p=="number"&&(u=Ae.Invisible(p)),r.removeChild(h).dispose();const m=new se(a.orientation,this.proportionalLayout,this.styles,a.size,a.orthogonalSize,this.locked,this.margin);r.addChild(m,a.size,h);const f=new me(a.view,r.orientation,a.size);m.addChild(f,u,0),typeof t!="number"&&t.type==="split"&&(t={type:"split",index:0});const v=new me(e,r.orientation,a.size);m.addChild(v,t,s)}}remove(e,t){const i=Q(e.element);return this.removeView(i,t)}removeView(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,n]=Fe(e),[s,l]=this.getNode(i);if(!(l instanceof se))throw new Error("Invalid location");const a=l.children[n];if(!(a instanceof me))throw new Error("Invalid location");if(l.removeChild(n,t),a.dispose(),l.children.length!==1)return a.view;const r=l.children[0];if(s.length===0)return r instanceof me||(l.removeChild(0,t),this.root=r),a.view;const[d,...h]=[...s].reverse(),[c,...u]=[...i].reverse(),p=l.isChildVisible(0);l.removeChild(0,t);const g=d.children.map((m,f)=>d.getChildSize(f));if(d.removeChild(c,t).dispose(),r instanceof se){g.splice(c,1,...r.children.map(m=>m.size));for(let m=0;m<r.children.length;m++){const f=r.children[m];d.addChild(f,f.size,c+m)}for(;r.children.length>0;)r.removeChild(0)}else{const m=new me(r.view,He(r.orientation),r.size),f=p?r.orthogonalSize:Ae.Invisible(r.orthogonalSize);d.addChild(m,f,c)}r.dispose();for(let m=0;m<g.length;m++)d.resizeChild(m,g[m]);return a.view}layout(e,t){const[i,n]=this.root.orientation===k.HORIZONTAL?[t,e]:[e,t];this.root.layout(i,n)}getNode(e,t=this.root,i=[]){if(e.length===0)return[i,t];if(!(t instanceof se))throw new Error("Invalid location");const[n,...s]=e;if(n<0||n>=t.children.length)throw new Error("Invalid location");const l=t.children[n];return i.push(t),this.getNode(s,l,i)}}const Yt=Object.keys({disableAutoResizing:void 0,proportionalLayout:void 0,orientation:void 0,hideBorders:void 0,className:void 0});class ri extends V{get element(){return this._element}get disableResizing(){return this._disableResizing}set disableResizing(e){this._disableResizing=e}constructor(e,t=!1){super(),this._lastWidth=-1,this._lastHeight=-1,this._disableResizing=t,this._element=e,this.addDisposables(ft(this._element,i=>{if(this.isDisposed||this.disableResizing||!this._element.offsetParent||!ds(this._element))return;const n=Math.round(i.contentRect.width),s=Math.round(i.contentRect.height);n===this._lastWidth&&s===this._lastHeight||(this._lastWidth=n,this._lastHeight=s,this.layout(n,s))}))}}const ys=oi();function Et(o){switch(o){case"left":return"left";case"right":return"right";case"above":return"top";case"below":return"bottom";case"within":default:return"center"}}class ln extends ri{get id(){return this._id}get size(){return this._groups.size}get groups(){return Array.from(this._groups.values()).map(e=>e.value)}get width(){return this.gridview.width}get height(){return this.gridview.height}get minimumHeight(){return this.gridview.minimumHeight}get maximumHeight(){return this.gridview.maximumHeight}get minimumWidth(){return this.gridview.minimumWidth}get maximumWidth(){return this.gridview.maximumWidth}get activeGroup(){return this._activeGroup}get locked(){return this.gridview.locked}set locked(e){this.gridview.locked=e}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._id=ys.next(),this._groups=new Map,this._onDidRemove=new _,this.onDidRemove=this._onDidRemove.event,this._onDidAdd=new _,this.onDidAdd=this._onDidAdd.event,this._onDidMaximizedChange=new _,this.onDidMaximizedChange=this._onDidMaximizedChange.event,this._onDidActiveChange=new _,this.onDidActiveChange=this._onDidActiveChange.event,this._bufferOnDidLayoutChange=new xi,this.onDidLayoutChange=this._bufferOnDidLayoutChange.onEvent,this._onDidViewVisibilityChangeMicroTaskQueue=new xi,this.onDidViewVisibilityChangeMicroTaskQueue=this._onDidViewVisibilityChangeMicroTaskQueue.onEvent,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new kt(this.element),this._classNames.setClassNames((i=t.className)!==null&&i!==void 0?i:""),e.appendChild(this.element),this.gridview=new Ds(!!t.proportionalLayout,t.styles,t.orientation,t.locked,t.margin),this.gridview.locked=!!t.locked,this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidMaximizedNodeChange(n=>{this._onDidMaximizedChange.fire({panel:n.view,isMaximized:n.isMaximized})}),this.gridview.onDidViewVisibilityChange(()=>this._onDidViewVisibilityChangeMicroTaskQueue.fire()),this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.forceRelayout()}),re.from(()=>{var n;(n=this.element.parentElement)===null||n===void 0||n.removeChild(this.element)}),this.gridview.onDidChange(()=>{this._bufferOnDidLayoutChange.fire()}),Ye.any(this.onDidAdd,this.onDidRemove,this.onDidActiveChange)(()=>{this._bufferOnDidLayoutChange.fire()}),this._onDidMaximizedChange,this._onDidViewVisibilityChangeMicroTaskQueue,this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(Q(e.element),t),this._bufferOnDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(Q(e.element))}updateOptions(e){var t,i,n,s;e.proportionalLayout,e.orientation&&(this.gridview.orientation=e.orientation),"disableResizing"in e&&(this.disableResizing=(t=e.disableAutoResizing)!==null&&t!==void 0?t:!1),"locked"in e&&(this.locked=(i=e.locked)!==null&&i!==void 0?i:!1),"margin"in e&&(this.gridview.margin=(n=e.margin)!==null&&n!==void 0?n:0),"className"in e&&this._classNames.setClassNames((s=e.className)!==null&&s!==void 0?s:"")}maximizeGroup(e){this.gridview.maximizeView(e),this.doSetGroupActive(e)}isMaximizedGroup(e){return this.gridview.maximizedView()===e}exitMaximizedGroup(){this.gridview.exitMaximizedView()}hasMaximizedGroup(){return this.gridview.hasMaximizedView()}doAddGroup(e,t=[0],i){this.gridview.addView(e,i??Ae.Distribute,t),this._onDidAdd.fire(e)}doRemoveGroup(e,t){if(!this._groups.has(e.id))throw new Error("invalid operation");const i=this._groups.get(e.id),n=this.gridview.remove(e,Ae.Distribute);if(i&&!(t!=null&&t.skipDispose)&&(i.disposable.dispose(),i.value.dispose(),this._groups.delete(e.id),this._onDidRemove.fire(e)),!(t!=null&&t.skipActive)&&this._activeGroup===e){const s=Array.from(this._groups.values());this.doSetGroupActive(s.length>0?s[0].value:void 0)}return n}getPanel(e){var t;return(t=this._groups.get(e))===null||t===void 0?void 0:t.value}doSetGroupActive(e){this._activeGroup!==e&&(this._activeGroup&&this._activeGroup.setActive(!1),e&&e.setActive(!0),this._activeGroup=e,this._onDidActiveChange.fire(e))}removeGroup(e){this.doRemoveGroup(e)}moveToNext(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=Q(e.group.element),n=(t=this.gridview.next(i))===null||t===void 0?void 0:t.view;this.doSetGroupActive(n)}moveToPrevious(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=Q(e.group.element),n=(t=this.gridview.previous(i))===null||t===void 0?void 0:t.view;this.doSetGroupActive(n)}forceRelayout(){this.layout(this.width,this.height,!0)}layout(e,t,i){(i||e!==this.width||t!==this.height)&&(this.gridview.element.style.height=`${t}px`,this.gridview.element.style.width=`${e}px`,this.gridview.layout(e,t))}dispose(){this._onDidActiveChange.dispose(),this._onDidAdd.dispose(),this._onDidRemove.dispose();for(const e of this.groups)e.dispose();this.gridview.dispose(),super.dispose()}}class dn{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get length(){return this.component.length}get orientation(){return this.component.orientation}get panels(){return this.component.panels}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}constructor(e){this.component=e}removePanel(e,t){this.component.removePanel(e,t)}focus(){this.component.focus()}getPanel(e){return this.component.getPanel(e)}layout(e,t){return this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}}class mt{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get panels(){return this.component.panels}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}get onDidDrop(){return this.component.onDidDrop}get onUnhandledDragOverEvent(){return this.component.onUnhandledDragOverEvent}constructor(e){this.component=e}removePanel(e){this.component.removePanel(e)}getPanel(e){return this.component.getPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}focus(){this.component.focus()}layout(e,t){this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}}class hn{get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddPanel(){return this.component.onDidAddGroup}get onDidRemovePanel(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActiveGroupChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get panels(){return this.component.groups}get orientation(){return this.component.orientation}set orientation(e){this.component.updateOptions({orientation:e})}constructor(e){this.component=e}focus(){this.component.focus()}layout(e,t,i=!1){this.component.layout(e,t,i)}addPanel(e){return this.component.addPanel(e)}removePanel(e,t){this.component.removePanel(e,t)}movePanel(e,t){this.component.movePanel(e,t)}getPanel(e){return this.component.getPanel(e)}fromJSON(e){return this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}}class Tt{get id(){return this.component.id}get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get size(){return this.component.size}get tabGroupColors(){return this.component.tabGroupColorPalette.entries()}get totalPanels(){return this.component.totalPanels}get onDidActiveGroupChange(){return this.component.onDidActiveGroupChange}get onDidAddGroup(){return this.component.onDidAddGroup}get onDidRemoveGroup(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActivePanelChange}get onDidAddPanel(){return this.component.onDidAddPanel}get onDidRemovePanel(){return this.component.onDidRemovePanel}get onDidMovePanel(){return this.component.onDidMovePanel}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidDrop(){return this.component.onDidDrop}get onWillDrop(){return this.component.onWillDrop}get onWillShowOverlay(){return this.component.onWillShowOverlay}get onWillDragGroup(){return this.component.onWillDragGroup}get onWillDragPanel(){return this.component.onWillDragPanel}get onUnhandledDragOverEvent(){return this.component.onUnhandledDragOverEvent}get onDidPopoutGroupSizeChange(){return this.component.onDidPopoutGroupSizeChange}get onDidPopoutGroupPositionChange(){return this.component.onDidPopoutGroupPositionChange}get onDidOpenPopoutWindowFail(){return this.component.onDidOpenPopoutWindowFail}get onDidCreateTabGroup(){return this.component.onDidCreateTabGroup}get onDidDestroyTabGroup(){return this.component.onDidDestroyTabGroup}get onDidAddPanelToTabGroup(){return this.component.onDidAddPanelToTabGroup}get onDidRemovePanelFromTabGroup(){return this.component.onDidRemovePanelFromTabGroup}get onDidTabGroupChange(){return this.component.onDidTabGroupChange}get onDidTabGroupCollapsedChange(){return this.component.onDidTabGroupCollapsedChange}get panels(){return this.component.panels}get groups(){return this.component.groups}get activePanel(){return this.component.activePanel}get activeGroup(){return this.component.activeGroup}constructor(e){this.component=e}focus(){this.component.focus()}getPanel(e){return this.component.getGroupPanel(e)}layout(e,t,i=!1){this.component.layout(e,t,i)}addPanel(e){return this.component.addPanel(e)}removePanel(e){this.component.removePanel(e)}addGroup(e){return this.component.addGroup(e)}closeAllGroups(){return this.component.closeAllGroups()}removeGroup(e){this.component.removeGroup(e)}getGroup(e){return this.component.getPanel(e)}addFloatingGroup(e,t){return this.component.addFloatingGroup(e,t)}fromJSON(e,t){this.component.fromJSON(e,t)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}moveToNext(e){this.component.moveToNext(e)}moveToPrevious(e){this.component.moveToPrevious(e)}maximizeGroup(e){this.component.maximizeGroup(e.group)}hasMaximizedGroup(){return this.component.hasMaximizedGroup()}exitMaximizedGroup(){this.component.exitMaximizedGroup()}get onDidMaximizedGroupChange(){return this.component.onDidMaximizedGroupChange}addPopoutGroup(e,t){return this.component.addPopoutGroup(e,t)}addEdgeGroup(e,t){return this.component.addEdgeGroup(e,t)}getEdgeGroup(e){return this.component.getEdgeGroup(e)}setEdgeGroupVisible(e,t){this.component.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this.component.isEdgeGroupVisible(e)}removeEdgeGroup(e){this.component.removeEdgeGroup(e)}updateOptions(e){this.component.updateOptions(e)}_getGroupModel(e){const t=this.component.getPanel(e);if(!t)throw new Error(`dockview: group '${e}' not found`);return t.model}createTabGroup(e){return this._getGroupModel(e.groupId).createTabGroup({label:e.label,color:e.color,componentParams:e.componentParams})}dissolveTabGroup(e){this._getGroupModel(e.groupId).dissolveTabGroup(e.tabGroupId)}addPanelToTabGroup(e){this._getGroupModel(e.groupId).addPanelToTabGroup(e.tabGroupId,e.panelId,e.index)}removePanelFromTabGroup(e){this._getGroupModel(e.groupId).removePanelFromTabGroup(e.panelId)}getTabGroups(e){return this._getGroupModel(e.groupId).getTabGroups()}getTabGroupForPanel(e){return this._getGroupModel(e.groupId).getTabGroupForPanel(e.panelId)}moveTabGroup(e){this._getGroupModel(e.groupId).moveTabGroup(e.tabGroupId,e.index)}dispose(){this.component.dispose()}}class ai extends V{constructor(e,t){super(),this.el=e,this.disabled=t,this.dataDisposable=new he,this.pointerEventsDisposable=new he,this._onDragStart=new _,this.onDragStart=this._onDragStart.event,this.addDisposables(this._onDragStart,this.dataDisposable,this.pointerEventsDisposable),this.configure()}setDisabled(e){this.disabled=e}isCancelled(e){return!1}configure(){this.addDisposables(this._onDragStart,R(this.el,"dragstart",e=>{if(e.defaultPrevented||this.isCancelled(e)||this.disabled){e.preventDefault();return}const t=pt();this.pointerEventsDisposable.value={dispose:()=>{t.release()}},this.el.classList.add("dv-dragged"),setTimeout(()=>this.el.classList.remove("dv-dragged"),0),this.dataDisposable.value=this.getData(e),this._onDragStart.fire(e),e.dataTransfer&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.items.length>0||e.dataTransfer.setData("text/plain",""))}),R(this.el,"dragend",()=>{this.pointerEventsDisposable.dispose(),setTimeout(()=>{this.dataDisposable.dispose()},0)}))}}class cn extends V{constructor(e,t){super(),this.element=e,this.callbacks=t,this.target=null,this.registerListeners()}onDragEnter(e){this.target=e.target,this.callbacks.onDragEnter(e)}onDragOver(e){e.preventDefault(),this.callbacks.onDragOver&&this.callbacks.onDragOver(e)}onDragLeave(e){this.target===e.target&&(this.target=null,this.callbacks.onDragLeave(e))}onDragEnd(e){this.target=null,this.callbacks.onDragEnd(e)}onDrop(e){this.callbacks.onDrop(e)}registerListeners(){this.addDisposables(R(this.element,"dragenter",e=>{this.onDragEnter(e)},!0)),this.addDisposables(R(this.element,"dragover",e=>{this.onDragOver(e)},!0)),this.addDisposables(R(this.element,"dragleave",e=>{this.onDragLeave(e)})),this.addDisposables(R(this.element,"dragend",e=>{this.onDragEnd(e)})),this.addDisposables(R(this.element,"drop",e=>{this.onDrop(e)}))}}function xs(o,e){const{top:t,left:i,width:n,height:s}=e,l=`${Math.round(t)}px`,a=`${Math.round(i)}px`,r=`${Math.round(n)}px`,d=`${Math.round(s)}px`;o.style.top=l,o.style.left=a,o.style.width=r,o.style.height=d,o.style.visibility="visible",(!o.style.transform||o.style.transform==="")&&(o.style.transform="translate3d(0, 0, 0)")}function Ss(o,e){const{top:t,left:i,width:n,height:s}=e;o.style.top=t,o.style.left=i,o.style.width=n,o.style.height=s,o.style.visibility="visible",(!o.style.transform||o.style.transform==="")&&(o.style.transform="translate3d(0, 0, 0)")}function Ps(o,e){const{top:t,left:i,width:n,height:s}=e,l=`${Math.round(t)}px`,a=`${Math.round(i)}px`,r=`${Math.round(n)}px`,d=`${Math.round(s)}px`;return o.style.top!==l||o.style.left!==a||o.style.width!==r||o.style.height!==d}class Gs extends si{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}constructor(e){super(),this.options=e}}function Ai(o){switch(o){case"above":return"top";case"below":return"bottom";case"left":return"left";case"right":return"right";case"within":return"center";default:throw new Error(`invalid direction '${o}'`)}}function As(o){switch(o){case"top":return"above";case"bottom":return"below";case"left":return"left";case"right":return"right";case"center":return"within";default:throw new Error(`invalid position '${o}'`)}}const Is={value:20,type:"percentage"},Es={value:50,type:"percentage"},Ts=100,zs=100;class Te extends V{get disabled(){return this._disabled}set disabled(e){this._disabled=e}get state(){return this._state}constructor(e,t){super(),this.element=e,this.options=t,this._onDrop=new _,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new _,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(this.options.acceptedTargetZones),this.dnd=new cn(this.element,{onDragEnter:()=>{var i,n,s;(s=(n=(i=this.options).getOverrideTarget)===null||n===void 0?void 0:n.call(i))===null||s===void 0||s.getElements()},onDragOver:i=>{var n,s,l,a,r,d,h;Te.ACTUAL_TARGET=this;const c=(s=(n=this.options).getOverrideTarget)===null||s===void 0?void 0:s.call(n);if(this._acceptedTargetZonesSet.size===0){if(c)return;this.removeDropTarget();return}const u=(r=(a=(l=this.options).getOverlayOutline)===null||a===void 0?void 0:a.call(l))!==null&&r!==void 0?r:this.element,p=u.offsetWidth,g=u.offsetHeight;if(p===0||g===0)return;const m=i.currentTarget.getBoundingClientRect(),f=((d=i.clientX)!==null&&d!==void 0?d:0)-m.left,v=((h=i.clientY)!==null&&h!==void 0?h:0)-m.top,b=this.calculateQuadrant(this._acceptedTargetZonesSet,f,v,p,g);if(this.isAlreadyUsed(i)||b===null){this.removeDropTarget();return}if(!this.options.canDisplayOverlay(i,b)){if(c)return;this.removeDropTarget();return}const w=new Gs({nativeEvent:i,position:b});if(this._onWillShowOverlay.fire(w),w.defaultPrevented){this.removeDropTarget();return}this.markAsUsed(i),c||this.targetElement||(this.targetElement=document.createElement("div"),this.targetElement.className="dv-drop-target-dropzone",this.overlayElement=document.createElement("div"),this.overlayElement.className="dv-drop-target-selection",this._state="center",this.targetElement.appendChild(this.overlayElement),u.classList.add("dv-drop-target"),u.append(this.targetElement)),this.toggleClasses(b,p,g),this._state=b},onDragLeave:()=>{var i,n;!((n=(i=this.options).getOverrideTarget)===null||n===void 0)&&n.call(i)||this.removeDropTarget()},onDragEnd:i=>{var n,s;const l=(s=(n=this.options).getOverrideTarget)===null||s===void 0?void 0:s.call(n);l&&Te.ACTUAL_TARGET===this&&this._state&&(i.stopPropagation(),this._onDrop.fire({position:this._state,nativeEvent:i})),this.removeDropTarget(),l==null||l.clear()},onDrop:i=>{var n,s,l;i.preventDefault();const a=this._state;this.removeDropTarget(),(l=(s=(n=this.options).getOverrideTarget)===null||s===void 0?void 0:s.call(n))===null||l===void 0||l.clear(),a&&(i.stopPropagation(),this._onDrop.fire({position:a,nativeEvent:i}))}}),this.addDisposables(this._onDrop,this._onWillShowOverlay,this.dnd)}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this.removeDropTarget(),super.dispose()}markAsUsed(e){e[Te.USED_EVENT_ID]=!0}isAlreadyUsed(e){const t=e[Te.USED_EVENT_ID];return typeof t=="boolean"&&t}toggleClasses(e,t,i){var n,s,l,a,r,d,h,c,u,p,g;const m=(s=(n=this.options).getOverrideTarget)===null||s===void 0?void 0:s.call(n);if(!m&&!this.overlayElement)return;const f=(a=(l=this.options.overlayModel)===null||l===void 0?void 0:l.smallWidthBoundary)!==null&&a!==void 0?a:Ts,v=(d=(r=this.options.overlayModel)===null||r===void 0?void 0:r.smallHeightBoundary)!==null&&d!==void 0?d:zs,b=t<f,w=i<v,C=e==="left",T=e==="right",I=e==="top",G=e==="bottom",P=!b&&T,F=!b&&C,K=!w&&I,L=!w&&G;let j=1;const ne=(c=(h=this.options.overlayModel)===null||h===void 0?void 0:h.size)!==null&&c!==void 0?c:Es;if(ne.type==="percentage"?j=q(ne.value,0,100)/100:((P||F)&&(j=q(0,ne.value,t)/t),(K||L)&&(j=q(0,ne.value,i)/i)),m){const z=(g=(p=(u=this.options).getOverlayOutline)===null||p===void 0?void 0:p.call(u))!==null&&g!==void 0?g:this.element,ce=z.getBoundingClientRect(),O=m.getElements(void 0,z),Y=O.root,B=O.overlay,be=Y.getBoundingClientRect(),X=ce.top-be.top,ve=ce.left-be.left,Z={top:X,left:ve,width:t,height:i};if(P?(Z.left=ve+t*(1-j),Z.width=t*j):F?Z.width=t*j:K?Z.height=i*j:L&&(Z.top=X+i*(1-j),Z.height=i*j),b&&C&&(Z.width=4),b&&T&&(Z.left=ve+t-4,Z.width=4),w&&I&&(Z.height=4),w&&G&&(Z.top=X+i-4,Z.height=4),!Ps(B,Z))return;xs(B,Z),B.className=`dv-drop-target-anchor${this.options.className?` ${this.options.className}`:""}`,E(B,"dv-drop-target-left",C),E(B,"dv-drop-target-right",T),E(B,"dv-drop-target-top",I),E(B,"dv-drop-target-bottom",G),E(B,"dv-drop-target-anchor-line",b&&(C||T)||w&&(I||G)),E(B,"dv-drop-target-center",e==="center"),O.changed&&(E(B,"dv-drop-target-anchor-container-changed",!0),setTimeout(()=>{E(B,"dv-drop-target-anchor-container-changed",!1)},10));return}if(!this.overlayElement)return;const U={top:"0px",left:"0px",width:"100%",height:"100%"};P?(U.left=`${100*(1-j)}%`,U.width=`${100*j}%`):F?U.width=`${100*j}%`:K?U.height=`${100*j}%`:L&&(U.top=`${100*(1-j)}%`,U.height=`${100*j}%`),b&&C&&(U.width="4px"),b&&T&&(U.left=`${t-4}px`,U.width="4px"),w&&I&&(U.height="4px"),w&&G&&(U.top=`${i-4}px`,U.height="4px"),Ss(this.overlayElement,U);const S=b&&(C||T)||w&&(I||G);E(this.overlayElement,"dv-drop-target-small-vertical",w),E(this.overlayElement,"dv-drop-target-small-horizontal",b),E(this.overlayElement,"dv-drop-target-selection-line",S),E(this.overlayElement,"dv-drop-target-left",C),E(this.overlayElement,"dv-drop-target-right",T),E(this.overlayElement,"dv-drop-target-top",I),E(this.overlayElement,"dv-drop-target-bottom",G),E(this.overlayElement,"dv-drop-target-center",e==="center")}calculateQuadrant(e,t,i,n,s){var l,a;const r=(a=(l=this.options.overlayModel)===null||l===void 0?void 0:l.activationSize)!==null&&a!==void 0?a:Is;return r.type==="percentage"?ks(e,t,i,n,s,r.value):Os(e,t,i,n,s,r.value)}removeDropTarget(){var e;this.targetElement&&(this._state=void 0,(e=this.targetElement.parentElement)===null||e===void 0||e.classList.remove("dv-drop-target"),this.targetElement.remove(),this.targetElement=void 0,this.overlayElement=void 0)}}Te.USED_EVENT_ID="__dockview_droptarget_event_is_used__";function ks(o,e,t,i,n,s){const l=100*e/i,a=100*t/n;return o.has("left")&&l<s?"left":o.has("right")&&l>100-s?"right":o.has("top")&&a<s?"top":o.has("bottom")&&a>100-s?"bottom":o.has("center")?"center":null}function Os(o,e,t,i,n,s){return o.has("left")&&e<s?"left":o.has("right")&&e>i-s?"right":o.has("top")&&t<s?"top":o.has("bottom")&&t>n-s?"bottom":o.has("center")?"center":null}const Zt=Object.keys({disableAutoResizing:void 0,disableDnd:void 0,className:void 0});class Rs extends en{constructor(e,t,i,n){super(),this.nativeEvent=e,this.position=t,this.getData=i,this.panel=n}}class un extends si{constructor(){super()}}class pn extends V{get isFocused(){return this._isFocused}get isActive(){return this._isActive}get isVisible(){return this._isVisible}get width(){return this._width}get height(){return this._height}constructor(e,t){super(),this.id=e,this.component=t,this._isFocused=!1,this._isActive=!1,this._isVisible=!0,this._width=0,this._height=0,this._parameters={},this.panelUpdatesDisposable=new he,this._onDidDimensionChange=new _,this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new _,this.onDidFocusChange=this._onDidChangeFocus.event,this._onWillFocus=new _,this.onWillFocus=this._onWillFocus.event,this._onDidVisibilityChange=new _,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onWillVisibilityChange=new _,this.onWillVisibilityChange=this._onWillVisibilityChange.event,this._onDidActiveChange=new _,this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new _,this.onActiveChange=this._onActiveChange.event,this._onDidParametersChange=new _,this.onDidParametersChange=this._onDidParametersChange.event,this.addDisposables(this.onDidFocusChange(i=>{this._isFocused=i.isFocused}),this.onDidActiveChange(i=>{this._isActive=i.isActive}),this.onDidVisibilityChange(i=>{this._isVisible=i.isVisible}),this.onDidDimensionsChange(i=>{this._width=i.width,this._height=i.height}),this.panelUpdatesDisposable,this._onDidDimensionChange,this._onDidChangeFocus,this._onDidVisibilityChange,this._onDidActiveChange,this._onWillFocus,this._onActiveChange,this._onWillFocus,this._onWillVisibilityChange,this._onDidParametersChange)}getParameters(){return this._parameters}initialize(e){this.panelUpdatesDisposable.value=this._onDidParametersChange.event(t=>{this._parameters=t,e.update({params:t})})}setVisible(e){this._onWillVisibilityChange.fire({isVisible:e})}setActive(){this._onActiveChange.fire()}updateParameters(e){this._onDidParametersChange.fire(e)}}class mn extends pn{constructor(e,t){super(e,t),this._onDidConstraintsChangeInternal=new _,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new _({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new _,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}}class Ms extends mn{set pane(e){this._pane=e}constructor(e,t){super(e,t),this._onDidExpansionChange=new _({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new _({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new _({}),this.onMouseLeave=this._onMouseLeave.event,this.addDisposables(this._onDidExpansionChange,this._onMouseEnter,this._onMouseLeave)}setExpanded(e){var t;(t=this._pane)===null||t===void 0||t.setExpanded(e)}get isExpanded(){var e;return!!(!((e=this._pane)===null||e===void 0)&&e.isExpanded())}}class li extends V{get element(){return this._element}get width(){return this._width}get height(){return this._height}get params(){var e;return(e=this._params)===null||e===void 0?void 0:e.params}constructor(e,t,i){super(),this.id=e,this.component=t,this.api=i,this._height=0,this._width=0,this._element=document.createElement("div"),this._element.tabIndex=-1,this._element.style.outline="none",this._element.style.height="100%",this._element.style.width="100%",this._element.style.overflow="hidden";const n=tn(this._element);this.addDisposables(this.api,n.onDidFocus(()=>{this.api._onDidChangeFocus.fire({isFocused:!0})}),n.onDidBlur(()=>{this.api._onDidChangeFocus.fire({isFocused:!1})}),n)}focus(){const e=new un;this.api._onWillFocus.fire(e),!e.defaultPrevented&&this._element.focus()}layout(e,t){this._width=e,this._height=t,this.api._onDidDimensionChange.fire({width:e,height:t}),this.part&&this._params&&this.part.update(this._params.params)}init(e){this._params=e,this.part=this.getComponent()}update(e){var t,i;this._params=Object.assign(Object.assign({},this._params),{params:Object.assign(Object.assign({},(t=this._params)===null||t===void 0?void 0:t.params),e.params)});for(const n of Object.keys(e.params))e.params[n]===void 0&&delete this._params.params[n];(i=this.part)===null||i===void 0||i.update({params:this._params.params})}toJSON(){var e,t;const i=(t=(e=this._params)===null||e===void 0?void 0:e.params)!==null&&t!==void 0?t:{};return{id:this.id,component:this.component,params:Object.keys(i).length>0?i:void 0}}dispose(){var e;this.api.dispose(),(e=this.part)===null||e===void 0||e.dispose(),super.dispose()}}class Vs extends li{set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){const e=this.headerSize,i=this.isExpanded()?this._minimumBodySize:0;return e+i}get maximumSize(){const e=this.headerSize,i=this.isExpanded()?this._maximumBodySize:0;return e+i}get size(){return this._size}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get minimumBodySize(){return this._minimumBodySize}set minimumBodySize(e){this._minimumBodySize=typeof e=="number"?e:0}get maximumBodySize(){return this._maximumBodySize}set maximumBodySize(e){this._maximumBodySize=typeof e=="number"?e:Number.POSITIVE_INFINITY}get headerVisible(){return this._headerVisible}set headerVisible(e){this._headerVisible=e,this.header.style.display=e?"":"none"}constructor(e){super(e.id,e.component,new Ms(e.id,e.component)),this._onDidChangeExpansionState=new _({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._orthogonalSize=0,this._size=0,this._isExpanded=!1,this.api.pane=this,this.api.initialize(this),this.headerSize=e.headerSize,this.headerComponent=e.headerComponent,this._minimumBodySize=e.minimumBodySize,this._maximumBodySize=e.maximumBodySize,this._isExpanded=e.isExpanded,this._headerVisible=e.isHeaderVisible,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=e.orientation,this.element.classList.add("dv-pane"),this.addDisposables(this.api.onWillVisibilityChange(t=>{const{isVisible:i}=t,{accessor:n}=this._params;n.setVisible(this,i)}),this.api.onDidSizeChange(t=>{this._onDidChange.fire({size:t.size})}),R(this.element,"mouseenter",t=>{this.api._onMouseEnter.fire(t)}),R(this.element,"mouseleave",t=>{this.api._onMouseLeave.fire(t)})),this.addDisposables(this._onDidChangeExpansionState,this.onDidChangeExpansionState(t=>{this.api._onDidExpansionChange.fire({isExpanded:t})}),this.api.onDidFocusChange(t=>{this.header&&(t.isFocused?Re(this.header,"focused"):Oe(this.header,"focused"))})),this.renderOnce()}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}isExpanded(){return this._isExpanded}setExpanded(e){this._isExpanded!==e&&(this._isExpanded=e,e?(this.animationTimer&&clearTimeout(this.animationTimer),this.body&&this.element.appendChild(this.body)):this.animationTimer=setTimeout(()=>{var t;(t=this.body)===null||t===void 0||t.remove()},200),this._onDidChange.fire(e?{size:this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(e,t){this._size=e,this._orthogonalSize=t;const[i,n]=this.orientation===k.HORIZONTAL?[e,t]:[t,e];super.layout(i,n)}init(e){var t,i;super.init(e),typeof e.minimumBodySize=="number"&&(this.minimumBodySize=e.minimumBodySize),typeof e.maximumBodySize=="number"&&(this.maximumBodySize=e.maximumBodySize),this.bodyPart=this.getBodyComponent(),this.headerPart=this.getHeaderComponent(),this.bodyPart.init(Object.assign(Object.assign({},e),{api:this.api})),this.headerPart.init(Object.assign(Object.assign({},e),{api:this.api})),(t=this.body)===null||t===void 0||t.append(this.bodyPart.element),(i=this.header)===null||i===void 0||i.append(this.headerPart.element),typeof e.isExpanded=="boolean"&&this.setExpanded(e.isExpanded)}toJSON(){const e=this._params;return Object.assign(Object.assign({},super.toJSON()),{headerComponent:this.headerComponent,title:e.title})}renderOnce(){this.header=document.createElement("div"),this.header.tabIndex=0,this.header.className="dv-pane-header",this.header.style.height=`${this.headerSize}px`,this.header.style.lineHeight=`${this.headerSize}px`,this.header.style.minHeight=`${this.headerSize}px`,this.header.style.maxHeight=`${this.headerSize}px`,this.element.appendChild(this.header),this.body=document.createElement("div"),this.body.className="dv-pane-body",this.element.appendChild(this.body)}getComponent(){return{update:e=>{var t,i;(t=this.bodyPart)===null||t===void 0||t.update({params:e}),(i=this.headerPart)===null||i===void 0||i.update({params:e})},dispose:()=>{var e,t;(e=this.bodyPart)===null||e===void 0||e.dispose(),(t=this.headerPart)===null||t===void 0||t.dispose()}}}}class Ls extends Vs{constructor(e){super({id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,isHeaderVisible:!0,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this._onDidDrop=new _,this.onDidDrop=this._onDidDrop.event,this._onUnhandledDragOverEvent=new _,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this.accessor=e.accessor,this.addDisposables(this._onDidDrop,this._onUnhandledDragOverEvent),e.disableDnd||this.initDragFeatures()}initDragFeatures(){if(!this.header)return;const e=this.id,t=this.accessor.id;this.header.draggable=!0,this.handler=new class extends ai{getData(){return ke.getInstance().setData([new ut(t,e)],ut.prototype),{dispose:()=>{ke.getInstance().clearData(ut.prototype)}}}}(this.header),this.target=new Te(this.element,{acceptedTargetZones:["top","bottom"],overlayModel:{activationSize:{type:"percentage",value:50}},canDisplayOverlay:(i,n)=>{const s=lt();if(s&&s.paneId!==this.id&&s.viewId===this.accessor.id)return!0;const l=new Rs(i,n,lt,this);return this._onUnhandledDragOverEvent.fire(l),l.isAccepted}}),this.addDisposables(this._onDidDrop,this.handler,this.target,this.target.onDrop(i=>{this.onDrop(i)}))}onDrop(e){const t=lt();if(!t||t.viewId!==this.accessor.id){this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,api:new mt(this.accessor),getData:lt}));return}const i=this._params.containerApi,n=t.paneId,s=i.getPanel(n);if(!s){this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,getData:lt,api:new mt(this.accessor)}));return}const l=i.panels,a=l.indexOf(s);let r=i.panels.indexOf(this);(e.position==="left"||e.position==="top")&&(r=Math.max(0,r-1)),(e.position==="right"||e.position==="bottom")&&(a>r&&r++,r=Math.min(l.length-1,r)),i.movePanel(a,r)}}class Ns extends V{get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this.disposable=new he,this._onDidFocus=new _,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new _,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dv-content-container",this._element.tabIndex=-1,this.addDisposables(this._onDidFocus,this._onDidBlur);const i=t.dropTargetContainer;this.dropTarget=new Te(this.element,{getOverlayOutline:()=>{var n;return((n=e.options.theme)===null||n===void 0?void 0:n.dndPanelOverlay)==="group"?this.element.parentElement:null},className:"dv-drop-target-content",acceptedTargetZones:["top","bottom","left","right","center"],canDisplayOverlay:(n,s)=>{if(this.group.locked==="no-drop-target"||this.group.locked&&s==="center")return!1;const l=ae();return!l&&n.shiftKey&&this.group.location.type!=="floating"?!1:l&&l.viewId===this.accessor.id?!0:this.group.canDisplayOverlay(n,s,"content")},getOverrideTarget:i?()=>i.model:void 0}),this.addDisposables(this.dropTarget)}show(){this.element.style.display=""}hide(){this.element.style.display="none"}renderPanel(e,t={asActive:!0}){var i,n,s,l;const a=t.asActive||this.panel&&this.group.isPanelActive(this.panel);this.panel&&this.panel.view.content.element.parentElement===this._element&&(this._element.removeChild(this.panel.view.content.element),(n=(i=this.panel.view.content).onHide)===null||n===void 0||n.call(i)),this.panel=e;let r;switch(e.api.renderer){case"onlyWhenVisible":this.group.renderContainer.detatch(e),this.panel&&a&&(this._element.appendChild(this.panel.view.content.element),(l=(s=this.panel.view.content).onShow)===null||l===void 0||l.call(s)),r=this._element;break;case"always":e.view.content.element.parentElement===this._element&&this._element.removeChild(e.view.content.element),r=this.group.renderContainer.attach({panel:e,referenceContainer:this});break;default:throw new Error(`dockview: invalid renderer type '${e.api.renderer}'`)}if(a){const d=tn(r);this.focusTracker=d;const h=new V;h.addDisposables(d,d.onDidFocus(()=>this._onDidFocus.fire()),d.onDidBlur(()=>this._onDidBlur.fire())),this.disposable.value=h}}openPanel(e){this.panel!==e&&this.renderPanel(e)}layout(e,t){}closePanel(){var e,t,i;this.panel&&this.panel.api.renderer==="onlyWhenVisible"&&((e=this.panel.view.content.element.parentElement)===null||e===void 0||e.removeChild(this.panel.view.content.element),(i=(t=this.panel.view.content).onHide)===null||i===void 0||i.call(t)),this.panel=void 0}dispose(){this.disposable.dispose(),super.dispose()}refreshFocusState(){var e;!((e=this.focusTracker)===null||e===void 0)&&e.refreshState&&this.focusTracker.refreshState()}}function fn(o,e,t){var i,n;Re(e,"dv-dragged"),e.style.top="-9999px",document.body.appendChild(e),o.setDragImage(e,(i=t==null?void 0:t.x)!==null&&i!==void 0?i:0,(n=t==null?void 0:t.y)!==null&&n!==void 0?n:0),setTimeout(()=>{Oe(e,"dv-dragged"),e.remove()},0)}class Ws extends ai{constructor(e,t,i,n,s){super(e,s),this.accessor=t,this.group=i,this.panel=n,this.panelTransfer=ke.getInstance()}getData(e){return this.panelTransfer.setData([new ze(this.accessor.id,this.group.id,this.panel.id)],ze.prototype),{dispose:()=>{this.panelTransfer.clearData(ze.prototype)}}}}class Hs extends V{get element(){return this._element}constructor(e,t,i){super(),this.panel=e,this.accessor=t,this.group=i,this.content=void 0,this._direction="horizontal",this._onPointDown=new _,this.onPointerDown=this._onPointDown.event,this._onTabClick=new _,this.onTabClick=this._onTabClick.event,this._onDropped=new _,this.onDrop=this._onDropped.event,this._onDragStart=new _,this.onDragStart=this._onDragStart.event,this._onDragEnd=new _,this.onDragEnd=this._onDragEnd.event,this._element=document.createElement("div"),this._element.className="dv-tab",this._element.tabIndex=0,this._element.draggable=!this.accessor.options.disableDnd,E(this.element,"dv-inactive-tab",!0),this.dragHandler=new Ws(this._element,this.accessor,this.group,this.panel,!!this.accessor.options.disableDnd),this.dropTarget=new Te(this._element,{acceptedTargetZones:["left","right"],overlayModel:this._buildOverlayModel(),canDisplayOverlay:(n,s)=>{var l;if(this.group.locked)return!1;const a=ae();return a&&this.accessor.id===a.viewId?((l=this.accessor.options.theme)===null||l===void 0?void 0:l.tabAnimation)!=="smooth":this.group.model.canDisplayOverlay(n,s,"tab")},getOverrideTarget:()=>{var n;return(n=i.model.dropTargetContainer)===null||n===void 0?void 0:n.model}}),this.onWillShowOverlay=this.dropTarget.onWillShowOverlay,this.addDisposables(this._onPointDown,this._onTabClick,this._onDropped,this._onDragStart,this._onDragEnd,this.accessor.onDidOptionsChange(()=>{this.dropTarget.setOverlayModel(this._buildOverlayModel())}),this.dragHandler.onDragStart(n=>{var s;if(n.dataTransfer){const l=getComputedStyle(this.element),a=this.element.cloneNode(!0),r=this._direction==="vertical",d=new Set(["writing-mode","inline-size","block-size","min-inline-size","min-block-size","max-inline-size","max-block-size","margin-inline","margin-inline-start","margin-inline-end","margin-block","margin-block-start","margin-block-end","padding-inline","padding-inline-start","padding-inline-end","padding-block","padding-block-start","padding-block-end"]);Array.from(l).forEach(h=>{r&&d.has(h)||a.style.setProperty(h,l.getPropertyValue(h),l.getPropertyPriority(h))}),r&&(a.style.setProperty("writing-mode","horizontal-tb"),a.style.setProperty("width",l.height),a.style.setProperty("height",l.width)),a.style.position="absolute",a.classList.add("dv-tab-ghost-drag"),fn(n.dataTransfer,a,{y:-10,x:30})}this._onDragStart.fire(n),((s=this.accessor.options.theme)===null||s===void 0?void 0:s.tabAnimation)==="smooth"&&requestAnimationFrame(()=>{E(this.element,"dv-tab--dragging",!0)})}),R(this._element,"dragend",n=>{E(this.element,"dv-tab--dragging",!1),this._onDragEnd.fire(n)}),this.dragHandler,R(this._element,"pointerdown",n=>{this._onPointDown.fire(n)}),R(this._element,"click",n=>{this._onTabClick.fire(n)}),R(this._element,"contextmenu",n=>{this.accessor.contextMenuController.show(this.panel,this.group,n)}),this.dropTarget.onDrop(n=>{this._onDropped.fire(n)}),this.dropTarget)}setActive(e){E(this.element,"dv-active-tab",e),E(this.element,"dv-inactive-tab",!e)}setContent(e){this.content&&this._element.removeChild(this.content.element),this.content=e,this._element.appendChild(this.content.element)}_buildOverlayModel(){var e;const t=((e=this.accessor.options.theme)===null||e===void 0?void 0:e.dndTabIndicator)==="line"?Number.POSITIVE_INFINITY:0;return{activationSize:{value:50,type:"percentage"},smallWidthBoundary:t,smallHeightBoundary:t}}setDirection(e){this._direction=e,this.dropTarget.setTargetZones(e==="vertical"?["top","bottom"]:["left","right"])}updateDragAndDropState(){this._element.draggable=!this.accessor.options.disableDnd,this.dragHandler.setDisabled(!!this.accessor.options.disableDnd)}}class Ot{get kind(){return this.options.kind}get nativeEvent(){return this.event.nativeEvent}get position(){return this.event.position}get defaultPrevented(){return this.event.defaultPrevented}get panel(){return this.options.panel}get api(){return this.options.api}get group(){return this.options.group}preventDefault(){this.event.preventDefault()}getData(){return this.options.getData()}constructor(e,t){this.event=e,this.options=t}}class Fs extends ai{constructor(e,t,i,n){super(e,n),this.accessor=t,this.group=i,this.panelTransfer=ke.getInstance(),this.addDisposables(R(e,"pointerdown",s=>{s.shiftKey&&as(s)},!0))}isCancelled(e){return this.group.api.location.type==="floating"&&!e.shiftKey||this.group.api.location.type==="edge"&&this.group.size===0}getData(e){const t=e.dataTransfer;this.panelTransfer.setData([new ze(this.accessor.id,this.group.id,null)],ze.prototype);const i=window.getComputedStyle(this.el),n=i.getPropertyValue("--dv-activegroup-visiblepanel-tab-background-color"),s=i.getPropertyValue("--dv-activegroup-visiblepanel-tab-color");if(t){const l=document.createElement("div");l.style.backgroundColor=n,l.style.color=s,l.style.padding="2px 8px",l.style.height="24px",l.style.fontSize="11px",l.style.lineHeight="20px",l.style.borderRadius="12px",l.style.position="absolute",l.style.pointerEvents="none",l.style.top="-9999px",l.textContent=`Multiple Panels (${this.group.size})`,fn(t,l,{y:-10,x:30})}return{dispose:()=>{this.panelTransfer.clearData(ze.prototype)}}}}class Bs extends V{get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this._onDrop=new _,this.onDrop=this._onDrop.event,this._onDragStart=new _,this.onDragStart=this._onDragStart.event,this._element=document.createElement("div"),this._element.className="dv-void-container",this._element.draggable=!this.accessor.options.disableDnd,E(this._element,"dv-draggable",!this.accessor.options.disableDnd),this.addDisposables(this._onDrop,this._onDragStart,R(this._element,"pointerdown",()=>{this.accessor.doSetGroupActive(this.group)})),this.handler=new Fs(this._element,e,t,!!this.accessor.options.disableDnd),this.dropTarget=new Te(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:(i,n)=>{const s=ae();return s&&this.accessor.id===s.viewId?!0:t.model.canDisplayOverlay(i,n,"header_space")},getOverrideTarget:()=>{var i;return(i=t.model.dropTargetContainer)===null||i===void 0?void 0:i.model}}),this.onWillShowOverlay=this.dropTarget.onWillShowOverlay,this.addDisposables(this.handler,this.handler.onDragStart(i=>{this._onDragStart.fire(i)}),this.dropTarget.onDrop(i=>{this._onDrop.fire(i)}),this.dropTarget)}updateDragAndDropState(){this._element.draggable=!this.accessor.options.disableDnd,E(this._element,"dv-draggable",!this.accessor.options.disableDnd),this.handler.setDisabled(!!this.accessor.options.disableDnd)}}class Rt extends V{get element(){return this._element}get orientation(){return this._orientation}set orientation(e){this._orientation!==e&&(this._scrollOffset=0,this._orientation=e,Oe(this._scrollbar,"dv-scrollbar-vertical","dv-scrollbar-horizontal"),e==="vertical"?Re(this._scrollbar,"dv-scrollbar-vertical"):Re(this._scrollbar,"dv-scrollbar-horizontal"))}constructor(e){super(),this.scrollableElement=e,this._scrollOffset=0,this._orientation="horizontal",this._element=document.createElement("div"),this._element.className="dv-scrollable",this._scrollbar=document.createElement("div"),this._scrollbar.className="dv-scrollbar dv-scrollbar-horizontal",this.element.appendChild(e),this.element.appendChild(this._scrollbar),this.addDisposables(R(this.element,"wheel",t=>{this._scrollOffset+=t.deltaY*Rt.MouseWheelSpeed,this.calculateScrollbarStyles()}),R(this._scrollbar,"pointerdown",t=>{t.preventDefault(),E(this.element,"dv-scrollable-scrolling",!0);const i=this._orientation==="horizontal"?t.clientX:t.clientY,n=this._scrollOffset,s=a=>{const r=this._orientation==="horizontal"?a.clientX-i:a.clientY-i,d=this._orientation==="horizontal"?this.element.clientWidth:this.element.clientHeight,h=this._orientation==="horizontal"?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight,c=d/h;this._scrollOffset=n+r/c,this.calculateScrollbarStyles()},l=()=>{E(this.element,"dv-scrollable-scrolling",!1),document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",l),document.removeEventListener("pointercancel",l)};document.addEventListener("pointermove",s),document.addEventListener("pointerup",l),document.addEventListener("pointercancel",l)}),R(this.element,"scroll",()=>{this.calculateScrollbarStyles()}),R(this.scrollableElement,"scroll",()=>{this._scrollOffset=this._orientation==="horizontal"?this.scrollableElement.scrollLeft:this.scrollableElement.scrollTop,this.calculateScrollbarStyles()}),ft(this.element,()=>{E(this.element,"dv-scrollable-resizing",!0),this._animationTimer&&clearTimeout(this._animationTimer),this._animationTimer=setTimeout(()=>{clearTimeout(this._animationTimer),E(this.element,"dv-scrollable-resizing",!1)},500),this.calculateScrollbarStyles()}))}calculateScrollbarStyles(){const e=this._orientation==="horizontal"?this.element.clientWidth:this.element.clientHeight,t=this._orientation==="horizontal"?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight;if(t>e){const n=e*(e/t);this._orientation==="horizontal"?(this._scrollbar.style.width=`${n}px`,this._scrollbar.style.height=""):(this._scrollbar.style.height=`${n}px`,this._scrollbar.style.width=""),this._scrollOffset=q(this._scrollOffset,0,t-e),this._orientation==="horizontal"?this.scrollableElement.scrollLeft=this._scrollOffset:this.scrollableElement.scrollTop=this._scrollOffset;const s=this._scrollOffset/(t-e);this._orientation==="horizontal"?(this._scrollbar.style.left=`${(e-n)*s}px`,this._scrollbar.style.top=""):(this._scrollbar.style.top=`${(e-n)*s}px`,this._scrollbar.style.left="")}else this._orientation==="horizontal"?(this._scrollbar.style.width="0px",this._scrollbar.style.left="0px"):(this._scrollbar.style.height="0px",this._scrollbar.style.top="0px"),this._scrollOffset=0}}Rt.MouseWheelSpeed=1;const di=[{id:"grey",value:"var(--dv-tab-group-color-grey)",label:"Grey"},{id:"blue",value:"var(--dv-tab-group-color-blue)",label:"Blue"},{id:"red",value:"var(--dv-tab-group-color-red)",label:"Red"},{id:"yellow",value:"var(--dv-tab-group-color-yellow)",label:"Yellow"},{id:"green",value:"var(--dv-tab-group-color-green)",label:"Green"},{id:"pink",value:"var(--dv-tab-group-color-pink)",label:"Pink"},{id:"purple",value:"var(--dv-tab-group-color-purple)",label:"Purple"},{id:"cyan",value:"var(--dv-tab-group-color-cyan)",label:"Cyan"},{id:"orange",value:"var(--dv-tab-group-color-orange)",label:"Orange"}];class gn{constructor(e,t=!0){this._entries=e.slice(),this._byId=new Map(e.map(i=>[i.id,i])),this._enabled=t}get enabled(){return this._enabled}set enabled(e){this._enabled=e}setEntries(e){this._entries=e.slice(),this._byId=new Map(e.map(t=>[t.id,t]))}entries(){return this._entries}has(e){return this._byId.has(e)}get(e){return this._byId.get(e)}defaultId(){var e;return(e=this._entries[0])===null||e===void 0?void 0:e.id}resolveValue(e){if(!this._enabled||!e)return;const t=this._byId.get(e);return t?t.value:e}}let Wt;function vn(){return Wt||(Wt=new gn(di,!0)),Wt}function hi(o,e,t){const i=(t??vn()).resolveValue(e);i===void 0?o.style.removeProperty("--dv-tab-group-color"):o.style.setProperty("--dv-tab-group-color",i)}function _n(o,e){return(e??vn()).resolveValue(o)}class Ii extends V{get element(){return this._element}constructor(e){super(),this._palette=e,this._onClick=new _,this.onClick=this._onClick.event,this._onContextMenu=new _,this.onContextMenu=this._onContextMenu.event,this._onDragStart=new _,this.onDragStart=this._onDragStart.event,this._element=document.createElement("div"),this._element.className="dv-tab-group-chip",this._element.tabIndex=0,this._element.draggable=!0,this._label=document.createElement("span"),this._label.className="dv-tab-group-chip-label",this._element.appendChild(this._label),this.addDisposables(this._onClick,this._onContextMenu,this._onDragStart,R(this._element,"click",t=>{this._onClick.fire(t)}),R(this._element,"contextmenu",t=>{this._onContextMenu.fire(t)}),R(this._element,"dragstart",t=>{this._onDragStart.fire(t)}))}init(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed),this.addDisposables(e.tabGroup.onDidChange(()=>{this._tabGroup&&(this.updateColor(this._tabGroup.color),this.updateLabel(this._tabGroup.label))}),e.tabGroup.onDidCollapseChange(t=>{this.updateCollapsed(t)}),this._onClick.event(()=>{var t;(t=this._tabGroup)===null||t===void 0||t.toggle()}))}update(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed)}updateColor(e){var t;hi(this._element,e,this._palette),E(this._element,"dv-tab-group-chip--accent-off",((t=this._palette)===null||t===void 0?void 0:t.enabled)===!1)}updateLabel(e){this._label.textContent=e,E(this._label,"dv-tab-group-chip-label--empty",!e)}updateCollapsed(e){E(this._element,"dv-tab-group-chip--collapsed",e)}}class bn{get underlines(){return this._underlines}constructor(e){this._ctx=e,this._underlines=new Map,this._rafId=null}positionUnderlines(){requestAnimationFrame(()=>{this._positionUnderlinesSync()})}trackUnderlines(){this._rafId!==null&&cancelAnimationFrame(this._rafId);const e=performance.now(),t=250,i=()=>{this._positionUnderlinesSync(),performance.now()-e<t?this._rafId=requestAnimationFrame(i):this._rafId=null};this._rafId=requestAnimationFrame(i)}syncUnderlineElements(e){for(const t of e)if(!this._underlines.has(t)){const i=document.createElement("div");i.className="dv-tab-group-underline",this._ctx.tabsList.appendChild(i),this._underlines.set(t,i)}for(const[t,i]of this._underlines)e.has(t)||(i.remove(),this._underlines.delete(t))}getUnderline(e){return this._underlines.get(e)}dispose(){this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null);for(const[,e]of this._underlines)e.remove();this._underlines.clear()}_positionUnderlinesSync(){const e=this._ctx.tabsList.getBoundingClientRect(),t=this._ctx.getTabGroups(),i=this._ctx.getDirection()==="vertical",n=i?e.width:e.height,s=this._ctx.getActivePanelId(),l=this._ctx.getTabMap();for(const a of t){const r=this._underlines.get(a.id);if(!r)continue;const d=a.panelIds;if(d.length===0){r.style.display="none";continue}r.style.display="";const h=this._ctx.getChipElement(a.id);let c;if(h){const b=h.getBoundingClientRect(),w=getComputedStyle(h),C=i?Number.parseFloat(w.marginTop)||0:Number.parseFloat(w.marginLeft)||0;c=i?b.top-e.top-C:b.left-e.left-C}else{const b=d[0],w=l.get(b);if(w){const C=w.value.element.getBoundingClientRect();c=i?C.top-e.top:C.left-e.left}else c=0}const u=d[d.length-1],p=l.get(u);if(!p){i?(r.style.top=`${c}px`,r.style.height="0px",r.style.left="",r.style.width=""):(r.style.left=`${c}px`,r.style.width="0px",r.style.top="",r.style.height="");continue}const g=p.value.element.getBoundingClientRect();let m=i?g.bottom-e.top:g.right-e.left,f=m-c;if((a.collapsed||a.panelIds.some(b=>{const w=l.get(b);return w&&w.value.element.classList.contains("dv-tab--group-expanding")}))&&h){const b=h.getBoundingClientRect(),w=i?b.top+b.height/2-e.top:b.left+b.width/2-e.left;let C=0,T=0;for(const G of a.panelIds){const P=l.get(G);if(!P)continue;const F=P.value.element;i?(C+=F.getBoundingClientRect().height,T+=F.scrollHeight):(C+=F.getBoundingClientRect().width,T+=F.scrollWidth)}const I=T>0?Math.min(1,C/T):0;c=w+(c-w)*I,m=w+(m-w)*I,f=Math.max(0,m-c)}i?(r.style.top=`${c}px`,r.style.height=`${Math.max(0,f)}px`,r.style.left="",r.style.width=""):(r.style.left=`${c}px`,r.style.width=`${Math.max(0,f)}px`,r.style.top="",r.style.height=""),this.applyShape(r,a,c,f,n,s,e,i)}}}class $s extends bn{_applyStraightLine(e,t,i,n,s,l){l?(e.setAttribute("width",String(n)),e.setAttribute("height",String(s)),i.style.width=`${n}px`,i.style.height=`${s}px`,t.setAttribute("d",`M ${n/2},0 L ${n/2},${s}`)):(e.setAttribute("width",String(s)),e.setAttribute("height",String(n)),i.style.width=`${s}px`,i.style.height=`${n}px`,t.setAttribute("d",`M 0,${n/2} L ${s},${n/2}`))}applyShape(e,t,i,n,s,l,a,r){const h=s,c=n,u=_n(t.color,this._ctx.getColorPalette());if(c<=0||h<=0||u===void 0){e.style.display="none";return}e.style.display="";let p;l&&t.panelIds.includes(l)&&(p=this._ctx.getTabMap().get(l));let g=e.firstElementChild,m;if(!g||g.tagName!=="svg"?(e.innerHTML="",g=document.createElementNS("http://www.w3.org/2000/svg","svg"),g.style.display="block",m=document.createElementNS("http://www.w3.org/2000/svg","path"),m.setAttribute("fill","none"),g.appendChild(m),e.appendChild(g)):m=g.firstElementChild,m.setAttribute("stroke",u),m.setAttribute("stroke-width",String(2)),!p){this._applyStraightLine(g,m,e,2,c,r);return}const f=p.value.element.getBoundingClientRect();let v,b;if(r?(v=Math.max(0,f.top-a.top-i),b=Math.min(c,f.bottom-a.top-i)):(v=Math.max(0,f.left-a.left-i),b=Math.min(c,f.right-a.left-i)),b<=v){this._applyStraightLine(g,m,e,2,c,r);return}const w=6,C=2/2;if(r){const T=h,I=c;g.setAttribute("width",String(T)),g.setAttribute("height",String(I)),e.style.width=`${T}px`,e.style.height=`${I}px`;const G=C,P=T-C,F=[`M ${G},0`,`L ${G},${v-w}`,`Q ${G},${v} ${G+w},${v}`,`L ${P-w},${v}`,`Q ${P},${v} ${P},${v+w}`,`L ${P},${b-w}`,`Q ${P},${b} ${P-w},${b}`,`L ${G+w},${b}`,`Q ${G},${b} ${G},${b+w}`,`L ${G},${I}`].join(" ");m.setAttribute("d",F)}else{const T=c,I=h;g.setAttribute("width",String(T)),g.setAttribute("height",String(I)),e.style.width=`${T}px`,e.style.height=`${I}px`;const G=I-C,P=C,F=[`M 0,${G}`,`L ${v-w},${G}`,`Q ${v},${G} ${v},${G-w}`,`L ${v},${P+w}`,`Q ${v},${P} ${v+w},${P}`,`L ${b-w},${P}`,`Q ${b},${P} ${b},${P+w}`,`L ${b},${G-w}`,`Q ${b},${G} ${b+w},${G}`,`L ${T},${G}`].join(" ");m.setAttribute("d",F)}}}class Us extends bn{applyShape(e,t,i,n,s,l,a,r){const h=_n(t.color,this._ctx.getColorPalette());if(n<=0||h===void 0){e.style.display="none";return}e.style.display="",e.firstElementChild&&(e.innerHTML=""),e.style.backgroundColor=h,r?(e.style.width="2px",e.style.height=`${n}px`):(e.style.width=`${n}px`,e.style.height="2px")}}const js=new Map;class Ks{get chipRenderers(){return this._chipRenderers}get groupUnderlines(){var e,t;return(t=(e=this._indicator)===null||e===void 0?void 0:e.underlines)!==null&&t!==void 0?t:js}get skipNextCollapseAnimation(){return this._skipNextCollapseAnimation}set skipNextCollapseAnimation(e){this._skipNextCollapseAnimation=e}constructor(e,t){this._ctx=e,this._callbacks=t,this._chipRenderers=new Map,this._indicator=null,this._skipNextCollapseAnimation=!1,this._pendingTransitionCleanups=new Map}update(){const t=this._ctx.group.model.getTabGroups(),i=new Set;for(const n of t)i.add(n.id),this._ensureChipForGroup(n),this._positionChipForGroup(n);for(const[n,s]of this._chipRenderers)i.has(n)||(s.chip.element.remove(),s.chip.dispose(),s.disposable.dispose(),this._chipRenderers.delete(n));this._updateTabGroupClasses()}refreshAccents(){var e,t;for(const i of this._ctx.group.model.getTabGroups()){const n=this._chipRenderers.get(i.id);(t=n==null?void 0:(e=n.chip).update)===null||t===void 0||t.call(e,{tabGroup:i})}this._updateTabGroupClasses()}positionAllChips(){if(this._chipRenderers.size!==0)for(const e of this._ctx.group.model.getTabGroups())this._positionChipForGroup(e)}snapshotChipWidths(){const e=new Map;for(const[t,i]of this._chipRenderers)e.set(t,i.chip.element.getBoundingClientRect().width);return e}positionUnderlines(){var e;(e=this._indicator)===null||e===void 0||e.positionUnderlines()}trackUnderlines(){var e;(e=this._indicator)===null||e===void 0||e.trackUnderlines()}setGroupDragImage(e,t,i){if(!e.dataTransfer)return;const n=this._ctx.getDirection()==="vertical",s=this._ctx.tabsList.cloneNode(!0);n?(s.classList.remove("dv-tabs-container-vertical","dv-vertical"),s.classList.add("dv-horizontal"),s.style.writingMode="horizontal-tb",s.style.height=`${this._ctx.tabsList.offsetWidth}px`):s.style.height=`${this._ctx.tabsList.offsetHeight}px`,s.style.width="auto",s.style.overflow="visible",s.style.pointerEvents="none";const l=Array.from(s.children),a=Array.from(this._ctx.tabsList.children);for(let g=l.length-1;g>=0;g--)a[g]!==i&&l[g].remove();const r=document.createElement("div");r.className="dv-groupview dv-active-group",r.style.position="fixed",r.style.top="-10000px",r.style.left="0px",r.style.height="auto",r.style.width="auto",r.style.pointerEvents="none";const d=document.createElement("div");d.className="dv-tabs-and-actions-container",d.style.height="auto",d.style.width="auto",r.appendChild(d),d.appendChild(s),this._ctx.accessor.element.appendChild(r);const h=s.querySelector(".dv-tab-group-chip"),c=i.getBoundingClientRect(),u=e.clientX-c.left,p=e.clientY-c.top;if(h){const g=h.getBoundingClientRect(),m=r.getBoundingClientRect(),f=g.left-m.left+u,v=g.top-m.top+p;e.dataTransfer.setDragImage(r,f,v)}else e.dataTransfer.setDragImage(r,u,p);requestAnimationFrame(()=>{r.remove()})}cleanupTransition(e){var t;(t=this._pendingTransitionCleanups.get(e))===null||t===void 0||t(),this._pendingTransitionCleanups.delete(e)}disposeAll(){var e;(e=this._indicator)===null||e===void 0||e.dispose(),this._indicator=null;for(const[,t]of this._pendingTransitionCleanups)t();this._pendingTransitionCleanups.clear();for(const[,t]of this._chipRenderers)t.chip.element.remove(),t.chip.dispose(),t.disposable.dispose();this._chipRenderers.clear()}_ensureIndicator(){var e,t;const n=((t=(e=this._ctx.accessor.options.theme)===null||e===void 0?void 0:e.tabGroupIndicator)!==null&&t!==void 0?t:"wrap")==="none"?Us:$s;this._indicator&&!(this._indicator instanceof n)&&(this._indicator.dispose(),this._indicator=null),this._indicator||(this._indicator=new n({tabsList:this._ctx.tabsList,getTabGroups:()=>this._ctx.group.model.getTabGroups(),getActivePanelId:()=>{var s;return(s=this._ctx.group.activePanel)===null||s===void 0?void 0:s.id},getTabMap:()=>this._ctx.getTabMap(),getChipElement:s=>{var l;return(l=this._chipRenderers.get(s))===null||l===void 0?void 0:l.chip.element},getDirection:()=>this._ctx.getDirection(),getColorPalette:()=>this._ctx.accessor.tabGroupColorPalette}))}_ensureChipForGroup(e){if(this._chipRenderers.has(e.id))return;const t=this._ctx.accessor.options.createTabGroupChipComponent,i=t?t(e):new Ii(this._ctx.accessor.tabGroupColorPalette);i.init({tabGroup:e,api:this._ctx.accessor.api});const n=[e.onDidChange(()=>{var l;(l=i.update)===null||l===void 0||l.call(i,{tabGroup:e}),this._updateTabGroupClasses()}),e.onDidPanelChange(()=>{this._positionChipForGroup(e),this._updateTabGroupClasses()}),e.onDidCollapseChange(()=>{this._updateTabGroupClasses()})];i instanceof Ii?n.push(i.onContextMenu(l=>{this._callbacks.onChipContextMenu(e,l)}),i.onDragStart(l=>{this._callbacks.onChipDragStart(e,i,l)})):n.push(R(i.element,"contextmenu",l=>{this._callbacks.onChipContextMenu(e,l)}),R(i.element,"dragstart",l=>{this._callbacks.onChipDragStart(e,i,l)}));const s=new V(...n);this._chipRenderers.set(e.id,{chip:i,disposable:s}),e.collapsed&&(this._skipNextCollapseAnimation=!0)}_positionChipForGroup(e){const t=this._chipRenderers.get(e.id);if(!t)return;const i=t.chip.element,n=e.panelIds;if(n.length===0){i.remove();return}const s=n[0],l=this._ctx.getTabMap().get(s);if(!l){i.remove();return}const a=l.value.element;i.nextSibling!==a&&this._ctx.tabsList.insertBefore(i,a)}_updateTabGroupClasses(){var e;const i=this._ctx.group.model.getTabGroups(),n=this._ctx.getTabs(),s=this._ctx.getTabMap();let l=!1;const a=new Map;for(const d of i)for(const h of d.panelIds)a.set(h,d);for(const d of n){const h=d.value,c=h.panel.id,u=a.get(c),p=!!u;if(E(h.element,"dv-tab--grouped",p),u){const g=u.panelIds,m=g[0]===c,f=g[g.length-1]===c;E(h.element,"dv-tab--group-first",m),E(h.element,"dv-tab--group-last",f),hi(h.element,u.color,this._ctx.accessor.tabGroupColorPalette);const v=h.element.classList.contains("dv-tab--group-collapsed");if(!u.collapsed&&v){l=!0,h.element.classList.remove("dv-tab--group-collapsed"),h.element.classList.add("dv-tab--group-expanding"),(e=this._pendingTransitionCleanups.get(c))===null||e===void 0||e();const b=()=>{h.element.classList.remove("dv-tab--group-expanding"),h.element.style.removeProperty("width"),h.element.removeEventListener("transitionend",b),clearTimeout(w),this._pendingTransitionCleanups.delete(c)},w=setTimeout(b,300);this._pendingTransitionCleanups.set(c,b),h.element.addEventListener("transitionend",b)}}else E(h.element,"dv-tab--group-first",!1),E(h.element,"dv-tab--group-last",!1),h.element.classList.remove("dv-tab--group-collapsed","dv-tab--group-expanding"),h.element.style.removeProperty("width"),h.element.style.removeProperty("--dv-tab-group-color")}const r=new Set;for(const d of i)if(r.add(d.id),d.collapsed&&d.panelIds.some(c=>{const u=s.get(c);return u&&!u.value.element.classList.contains("dv-tab--group-collapsed")}))if(this._skipNextCollapseAnimation){const c=[];for(const u of d.panelIds){const p=s.get(u);p&&(p.value.element.style.transition="none",p.value.element.classList.add("dv-tab--group-collapsed"),c.push(p.value.element))}if(c.length>0){c[0].offsetHeight;for(const u of c)u.style.removeProperty("transition")}}else{l=!0;const c=this._ctx.getDirection()==="vertical";for(const u of d.panelIds){const p=s.get(u);if(p&&!p.value.element.classList.contains("dv-tab--group-collapsed")){const g=p.value.element.getBoundingClientRect();c?p.value.element.style.height=`${g.height}px`:p.value.element.style.width=`${g.width}px`,p.value.element.offsetHeight,p.value.element.classList.add("dv-tab--group-collapsed")}}}this._skipNextCollapseAnimation=!1,this._ensureIndicator(),this._indicator&&(this._indicator.syncUnderlineElements(r),l?this._indicator.trackUnderlines():this._indicator.positionUnderlines())}}class Js extends V{get showTabsOverflowControl(){return this._showTabsOverflowControl}set showTabsOverflowControl(e){if(this._showTabsOverflowControl!=e&&(this._showTabsOverflowControl=e,e)){const t=new os(this._tabsList);this._observerDisposable.value=new V(t,t.onDidChange(i=>{const n=i.hasScrollX||i.hasScrollY;this.toggleDropdown({reset:!n}),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}),R(this._tabsList,"scroll",()=>{this.toggleDropdown({reset:!1}),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}))}}get element(){return this._element}set voidContainer(e){var t;(t=this._voidContainerListeners)===null||t===void 0||t.dispose(),this._voidContainerListeners=null,this._voidContainer=e,e&&(this._voidContainerListeners=new V(R(e,"dragover",i=>{this._animState&&i.preventDefault()}),R(e,"drop",i=>{var n;!((n=this._animState)===null||n===void 0)&&n.sourceTabGroupId&&this._animState.currentInsertionIndex!==null&&(i.preventDefault(),i.stopPropagation(),this.handleVoidDrop())})))}handleVoidDrop(){var e,t;if(!(!((e=this._animState)===null||e===void 0)&&e.sourceTabGroupId))return!1;const i=this._animState.sourceTabGroupId,n=(t=this._animState.currentInsertionIndex)!==null&&t!==void 0?t:this._tabs.length;return this._animState=null,this._commitGroupMove(i,n),!0}get panels(){return this._tabs.map(e=>e.value.panel.id)}get size(){return this._tabs.length}get tabs(){return this._tabs.map(e=>e.value)}get direction(){return this._direction}set direction(e){if(this._direction!==e){this._direction=e,this._scrollbar&&(this._scrollbar.orientation=e),Oe(this._tabsList,"dv-horizontal","dv-vertical"),e==="vertical"?Re(this._tabsList,"dv-tabs-container-vertical","dv-vertical"):(Oe(this._tabsList,"dv-tabs-container-vertical"),Re(this._tabsList,"dv-horizontal"));for(const t of this._tabs)t.value.setDirection(e)}}constructor(e,t,i){super(),this.group=e,this.accessor=t,this._observerDisposable=new he,this._scrollbar=null,this._tabs=[],this._tabMap=new Map,this.selectedIndex=-1,this._showTabsOverflowControl=!1,this._direction="horizontal",this._animState=null,this._pendingMarginCleanups=new Map,this._pendingCollapse=!1,this._flipTransitionCleanup=null,this._voidContainer=null,this._voidContainerListeners=null,this._extendedDropZone=null,this._chipDragCleanup=null,this._onTabDragStart=new _,this.onTabDragStart=this._onTabDragStart.event,this._onDrop=new _,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new _,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onOverflowTabsChange=new _,this.onOverflowTabsChange=this._onOverflowTabsChange.event,this._tabsList=document.createElement("div"),this._tabsList.className="dv-tabs-container",this.showTabsOverflowControl=i.showTabsOverflowControl,t.options.scrollbars==="native"?this._element=this._tabsList:(this._scrollbar=new Rt(this._tabsList),this._scrollbar.orientation=this.direction,this._element=this._scrollbar.element,this.addDisposables(this._scrollbar)),this._tabGroupManager=new Ks({group:this.group,accessor:this.accessor,tabsList:this._tabsList,getTabs:()=>this._tabs,getTabMap:()=>this._tabMap,getDirection:()=>this._direction},{onChipContextMenu:(n,s)=>{this.accessor.contextMenuController.showForChip(n,this.group,s)},onChipDragStart:(n,s,l)=>{this._handleChipDragStart(n,s,l)}}),this.addDisposables(this._onOverflowTabsChange,this._observerDisposable,this._onWillShowOverlay,this._onDrop,this._onTabDragStart,{dispose:()=>{var n;(n=this._flipTransitionCleanup)===null||n===void 0||n.call(this)}},R(this.element,"pointerdown",n=>{if(n.defaultPrevented)return;n.button===0&&this.accessor.doSetGroupActive(this.group)}),R(this._tabsList,"dragover",n=>{var s,l,a,r;if(!this.accessor.options.disableDnd){if(this._animState){const d=ae();d!=null&&d.tabGroupId&&d.groupId!==this.group.id&&this._animState.sourceTabGroupId!==d.tabGroupId&&(this._animState=null)}if(!this._animState){const d=ae();if(((s=this.accessor.options.theme)===null||s===void 0?void 0:s.tabAnimation)==="default"&&!(d!=null&&d.tabGroupId))return;if(d&&(d.panelId||d.tabGroupId)&&d.groupId!==this.group.id){const h=this.getAverageTabWidth();if(d.tabGroupId){const c=this.accessor.getPanel(d.groupId),u=c==null?void 0:c.model.getTabGroups().find(m=>m.id===d.tabGroupId),p=(l=u==null?void 0:u.panelIds.length)!==null&&l!==void 0?l:1,g=h*p+h;this._animState={sourceTabId:"",sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:d.tabGroupId,sourceGroupPanelIds:u?new Set(u.panelIds):new Set,sourceChipWidth:h,cursorOffsetFromDragLeft:g/2,sourceGapWidth:g,containerLeft:this._tabsList.getBoundingClientRect().left}}else this._animState={sourceTabId:d.panelId,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:h/2,sourceGapWidth:h,containerLeft:this._tabsList.getBoundingClientRect().left}}else return}n.preventDefault(),this._animState.sourceIndex!==-1&&((r=(a=this.group.model.dropTargetContainer)===null||a===void 0?void 0:a.model)===null||r===void 0||r.clear()),this.handleDragOver(n)}},!0),R(this._tabsList,"dragleave",n=>{var s,l,a;if(!this._animState)return;const r=n.relatedTarget;if(r&&this._tabsList.contains(r))return;if(r&&(!((s=this._extendedDropZone)===null||s===void 0)&&s.contains(r))){this.resetTabTransforms(),this._animState.currentInsertionIndex=null;return}const d=n.relatedTarget;this._voidContainer&&d&&(d===this._voidContainer||this._voidContainer.contains(d))||(this.resetTabTransforms(),this._animState&&(this._animState.sourceIndex===-1?((a=(l=this.group.model.dropTargetContainer)===null||l===void 0?void 0:l.model)===null||a===void 0||a.clear(),this._animState=null):this._animState.currentInsertionIndex=null))},!0),R(this._tabsList,"dragend",()=>{this.resetDragAnimation()}),R(this._tabsList,"drop",n=>{var s,l,a;if(!this._animState||this._animState.currentInsertionIndex===null||((s=this.accessor.options.theme)===null||s===void 0?void 0:s.tabAnimation)!=="smooth"&&!this._animState.sourceTabGroupId)return;n.stopPropagation(),n.preventDefault(),(a=(l=this.group.model.dropTargetContainer)===null||l===void 0?void 0:l.model)===null||a===void 0||a.clear();const r=this._animState;if(this._animState=null,this._pendingCollapse=!1,r.sourceTabGroupId){this._commitGroupMove(r.sourceTabGroupId,r.currentInsertionIndex);return}const d=r.currentInsertionIndex,h=r.sourceIndex,c=d-(h!==-1&&h<d?1:0),u=this.group.model.getTabGroupForPanel(r.sourceTabId);if(c===h&&!r.targetTabGroupId&&!u){this._uncollapsSourceTab(r.sourceTabId),this.resetTabTransforms();return}this._uncollapsSourceTab(r.sourceTabId);const p=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:n,index:c,targetTabGroupId:r.targetTabGroupId}),this.runFlipAnimation(p,r.sourceTabId,r.sourceIndex===-1,{from:Math.min(h,c),to:Math.max(h,c)})},!0),re.from(()=>{var n;(n=this._voidContainerListeners)===null||n===void 0||n.dispose(),this.resetDragAnimation(),this._tabGroupManager.disposeAll();for(const{value:s,disposable:l}of this._tabs)l.dispose(),s.dispose();this._tabs=[],this._tabMap.clear()}))}indexOf(e){return this._tabs.findIndex(t=>t.value.panel.id===e)}isActive(e){return this.selectedIndex>-1&&this._tabs[this.selectedIndex].value===e}setActivePanel(e){const t=this._direction==="vertical";let i=0;for(const n of this._tabs){const s=e.id===n.value.panel.id;if(n.value.setActive(s),s){const l=n.value.element,a=l.parentElement;t?(i<a.scrollTop||i+l.clientHeight>a.scrollTop+a.clientHeight)&&(a.scrollTop=i):(i<a.scrollLeft||i+l.clientWidth>a.scrollLeft+a.clientWidth)&&(a.scrollLeft=i)}i+=t?n.value.element.clientHeight:n.value.element.clientWidth}this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}openPanel(e,t=this._tabs.length){if(this._tabMap.has(e.id))return;const i=new Hs(e,this.accessor,this.group);i.setContent(e.view.tab),this._direction!=="horizontal"&&i.setDirection(this._direction);const n=new V(i.onDragStart(l=>{var a;if(this._onTabDragStart.fire({nativeEvent:l,panel:e}),((a=this.accessor.options.theme)===null||a===void 0?void 0:a.tabAnimation)==="smooth"){const r=i.element.getBoundingClientRect().width,d=this._tabs.findIndex(h=>h.value===i);this._animState={sourceTabId:e.id,sourceIndex:d,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:r/2,sourceGapWidth:r,containerLeft:this._tabsList.getBoundingClientRect().left},this._pendingCollapse=!0,requestAnimationFrame(()=>{var h,c;this._pendingCollapse=!1,this._animState&&(i.element.style.transition="none",E(i.element,"dv-tab--dragging",!0),i.element.offsetHeight,(h=(c=this._animState).currentInsertionIndex)!==null&&h!==void 0||(c.currentInsertionIndex=d),this.applyDragOverTransforms(!0),i.element.style.removeProperty("transition"))})}}),i.onTabClick(l=>{l.defaultPrevented||this.group.api.location.type==="edge"&&(this.group.activePanel===e?this.group.api.isCollapsed()?this.group.api.expand():this.group.api.collapse():(this.group.model.openPanel(e),this.group.api.isCollapsed()&&this.group.api.expand()))}),i.onPointerDown(l=>{if(l.defaultPrevented)return;const a=!this.accessor.options.disableFloatingGroups,r=this.group.api.location.type==="floating"&&this.size===1;if(a&&!r&&l.shiftKey){l.preventDefault();const d=this.accessor.getGroupPanel(i.panel.id),{top:h,left:c}=i.element.getBoundingClientRect(),{top:u,left:p}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(d,{x:c-p,y:h-u,inDragMode:!0});return}switch(l.button){case 0:this.group.api.location.type==="edge"||this.group.activePanel!==e&&this.group.model.openPanel(e);break}}),i.onDrop(l=>{var a,r,d,h;const c=this._animState;this._animState=null,this._pendingCollapse=!1;const u=this._tabs.findIndex(p=>p.value===i);if(c){const p=l.position==="right"?u+1:u;if(c.sourceTabGroupId){this._commitGroupMove(c.sourceTabGroupId,(a=c.currentInsertionIndex)!==null&&a!==void 0?a:p);return}this._uncollapsSourceTab(c.sourceTabId);const g=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:l.nativeEvent,index:p,targetTabGroupId:c.targetTabGroupId}),((r=this.accessor.options.theme)===null||r===void 0?void 0:r.tabAnimation)==="smooth"&&this.runFlipAnimation(g,c.sourceTabId,c.sourceIndex===-1,c.sourceIndex!==-1?{from:Math.min(c.sourceIndex,p),to:Math.max(c.sourceIndex,p)}:void 0)}else{const p=this._direction==="vertical"?"bottom":"right",g=l.position===p?u+1:u,m=ae(),f=m?this._tabs.findIndex(w=>w.value.panel.id===m.panelId):-1,v=g-(f!==-1&&f<g?1:0),b=(h=(d=this.group.model.getTabGroupForPanel(i.panel.id))===null||d===void 0?void 0:d.id)!==null&&h!==void 0?h:null;this._onDrop.fire({event:l.nativeEvent,index:v,targetTabGroupId:b})}}),i.onWillShowOverlay(l=>{this._onWillShowOverlay.fire(new Ot(l,{kind:"tab",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:ae}))})),s={value:i,disposable:n};this.addTab(s,t),this._tabGroupManager.positionAllChips(),this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}delete(e){var t;((t=this._animState)===null||t===void 0?void 0:t.sourceTabId)===e&&(this.resetTabTransforms(),this._animState=null),this._tabGroupManager.cleanupTransition(e);const i=this.indexOf(e),n=this._tabs.splice(i,1)[0];if(this._tabMap.delete(e),n){const{value:s,disposable:l}=n;l.dispose(),s.dispose(),s.element.remove()}this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}addTab(e,t=this._tabs.length){if(t<0||t>this._tabs.length)throw new Error("invalid location");const i=t<this._tabs.length?this._tabs[t].value.element:null;this._tabsList.insertBefore(e.value.element,i),this._tabs=[...this._tabs.slice(0,t),e,...this._tabs.slice(t)],this._tabMap.set(e.value.panel.id,e),this.selectedIndex<0&&(this.selectedIndex=t)}toggleDropdown(e){if(e.reset){this._onOverflowTabsChange.fire({tabs:[],tabGroups:[],reset:!0});return}const t=this._tabs.filter(s=>!Pi(s.value.element,this._tabsList)).map(s=>s.value.panel.id),i=new Set(t),n=[];for(const s of this.group.model.getTabGroups()){const l=this._tabGroupManager.chipRenderers.get(s.id),a=l&&!Pi(l.chip.element,this._tabsList),r=s.panelIds.length>0&&s.panelIds.every(d=>i.has(d));if((a||r)&&(n.push(s.id),s.collapsed))for(const d of s.panelIds)i.has(d)||(i.add(d),t.push(d))}this._onOverflowTabsChange.fire({tabs:t,tabGroups:n,reset:!1})}updateDragAndDropState(){for(const e of this._tabs)e.value.updateDragAndDropState()}updateTabGroups(){this._tabGroupManager.update()}refreshTabGroupAccent(){this._tabGroupManager.refreshAccents()}_handleChipDragStart(e,t,i){var n;const s=e.panelIds[0],l=s?this._tabs.findIndex(p=>p.value.panel.id===s):-1,a=t.element.getBoundingClientRect();let r=a.width;for(const p of e.panelIds){const g=this._tabMap.get(p);g&&(r+=g.value.element.getBoundingClientRect().width)}this._animState={sourceTabId:"",sourceIndex:l,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.id,sourceGroupPanelIds:new Set(e.panelIds),sourceChipWidth:a.width,cursorOffsetFromDragLeft:i.clientX-a.left,sourceGapWidth:r,containerLeft:this._tabsList.getBoundingClientRect().left};const d=ke.getInstance();d.setData([new ze(this.accessor.id,this.group.id,null,e.id)],ze.prototype);const h=pt(),c=t.element,u=()=>{c.removeEventListener("dragend",u),this.resetDragAnimation()};if(c.addEventListener("dragend",u),this._chipDragCleanup={dispose:()=>{c.removeEventListener("dragend",u),d.clearData(ze.prototype),h.release()}},i.dataTransfer&&(i.dataTransfer.effectAllowed="move",i.dataTransfer.items.length===0&&i.dataTransfer.setData("text/plain","")),((n=this.accessor.options.theme)===null||n===void 0?void 0:n.tabAnimation)==="smooth"){const p=new Set(e.panelIds);this._pendingCollapse=!0,requestAnimationFrame(()=>{var g,m;if(this._pendingCollapse=!1,!this._animState)return;for(const b of this._tabs)p.has(b.value.panel.id)&&(b.value.element.style.transition="none",E(b.value.element,"dv-tab--dragging",!0));const f=this._tabGroupManager.chipRenderers.get(e.id);f&&(f.chip.element.style.transition="none",E(f.chip.element,"dv-tab-group-chip--dragging",!0)),this._tabsList.offsetHeight;const v=this._tabGroupManager.groupUnderlines.get(e.id);v&&(v.style.display="none"),(g=(m=this._animState).currentInsertionIndex)!==null&&g!==void 0||(m.currentInsertionIndex=l),this.applyDragOverTransforms(!0);for(const b of this._tabs)p.has(b.value.panel.id)&&b.value.element.style.removeProperty("transition");f&&f.chip.element.style.removeProperty("transition")})}this._tabGroupManager.setGroupDragImage(i,e,t.element)}setExtendedDropZone(e){this._extendedDropZone=e}setExternalInsertionIndex(e){this._animState&&e!==this._animState.currentInsertionIndex&&(this._animState.currentInsertionIndex=e,this.applyDragOverTransforms())}clearExternalAnimState(){this._animState&&(this.resetTabTransforms(),this._animState.sourceIndex===-1?this._animState=null:this._animState.currentInsertionIndex=null)}snapshotTabPositions(){const e=new Map;for(const t of this._tabs)e.set(t.value.panel.id,t.value.element.getBoundingClientRect());return e}getAverageTabWidth(){if(this._tabs.length===0)return 0;const e=this._direction==="vertical";let t=0;for(const i of this._tabs){const n=i.value.element.getBoundingClientRect();t+=e?n.height:n.width}return t/this._tabs.length}handleDragOver(e){var t,i,n,s,l;if(!this._animState)return;const a=e.clientX;let r=null,d=null;const h=this._animState.sourceGroupPanelIds,u=a-this._animState.cursorOffsetFromDragLeft-this._animState.containerLeft;let p=0;const g=new Map;if(this._tabGroupManager.chipRenderers.size>0){const m=this.group.model.getTabGroups();for(const f of m)f.id!==this._animState.sourceTabGroupId&&f.panelIds.length>0&&g.set(f.panelIds[0],f.id)}for(let m=0;m<this._tabs.length;m++){const f=this._tabs[m].value;if(f.panel.id===this._animState.sourceTabId||h!=null&&h.has(f.panel.id))continue;const v=g.get(f.panel.id);if(v){const C=(t=this._animState.chipPositions.get(v))!==null&&t!==void 0?t:0;if(p+C>u){r??(r=m);break}p+=C}const b=this._animState.tabPositions.get(f.panel.id),w=b?b.width:f.element.getBoundingClientRect().width;if(p+w/2<=u)p+=w,r=m+1;else{r??(r=m);break}}if(r!==null&&this._tabGroupManager.chipRenderers.size>0){const m=!!this._animState.sourceTabGroupId,f=this.group.model.getTabGroups();let v=0;for(let b=0;b<this._tabs.length;b++){const w=this._tabs[b].value;if(w.panel.id===this._animState.sourceTabId||h!=null&&h.has(w.panel.id))continue;if(b>=r)break;const C=g.get(w.panel.id);C&&(v+=(i=this._animState.chipPositions.get(C))!==null&&i!==void 0?i:0);const T=this._animState.tabPositions.get(w.panel.id);v+=T?T.width:w.element.getBoundingClientRect().width}for(const b of f){const w=b.panelIds.filter(P=>P!==this._animState.sourceTabId&&!(h!=null&&h.has(P)));if(w.length===0)continue;const C=this._tabs.findIndex(P=>P.value.panel.id===w[0]),T=this._tabs.findIndex(P=>P.value.panel.id===w[w.length-1]);if(C===-1||T===-1)continue;const I=r>=C&&r<=T,G=!I&&r===C-1;if(!(!I&&!G)){if(m){const P=(C+T+1)/2;r<P?r=C:r=T+1;break}if(G){let P=!0;for(let L=r;L<C;L++){const j=this._tabs[L].value.panel.id;if(j!==this._animState.sourceTabId&&!(h!=null&&h.has(j))){P=!1;break}}if(!P)continue;const F=(n=this._animState.chipPositions.get(b.id))!==null&&n!==void 0?n:0,K=b.collapsed?this._animState.containerLeft+v+F/2:this._animState.containerLeft+v+F;a>=K&&(r=C,d=b.id);break}if(I){const P=(s=this._animState.chipPositions.get(b.id))!==null&&s!==void 0?s:0,F=this._animState.containerLeft+v+P;r===C?a>=F&&(d=b.id):d=b.id;break}}}}r===this._animState.currentInsertionIndex&&d===this._animState.targetTabGroupId||(this._animState.currentInsertionIndex=r,this._animState.targetTabGroupId=d,((l=this.accessor.options.theme)===null||l===void 0?void 0:l.tabAnimation)==="smooth"&&this.applyDragOverTransforms())}_removeClassInstantlyBatch(e,t){const i=[];for(const n of e)n.classList.contains(t)&&(n.style.transition="none",E(n,t,!1),i.push(n));if(i.length>0){i[0].offsetHeight;for(const n of i)n.style.removeProperty("transition")}}_uncollapsSourceTab(e){const t=this._tabMap.get(e);t&&this._removeClassInstantlyBatch([t.value.element],"dv-tab--dragging")}applyDragOverTransforms(e=!1){if(!this._animState||this._animState.currentInsertionIndex===null){this.resetTabTransforms();return}if(this._pendingCollapse)return;const t=this._animState.currentInsertionIndex;let i;const n=this._animState.sourceGroupPanelIds;if(this._animState.sourceTabGroupId&&n)i=this._animState.sourceGapWidth;else{const h=this._animState.tabPositions.get(this._animState.sourceTabId);i=h?h.width:this.getAverageTabWidth()}let s=null;if(this._tabGroupManager.chipRenderers.size>0){const h=this.group.model.getTabGroups();for(const c of h){if(c.id===this._animState.sourceTabGroupId||c.panelIds.includes(this._animState.sourceTabId))continue;const u=c.panelIds.filter(m=>m!==this._animState.sourceTabId&&!(n!=null&&n.has(m)));if(u.length===0)continue;const p=this._tabs.findIndex(m=>m.value.panel.id===u[0]);if((!this._animState.targetTabGroupId||this._animState.targetTabGroupId===c.id&&c.collapsed)&&p>=t){let m=!1;for(let f=t;f<p;f++){const v=this._tabs[f].value.panel.id;if(v!==this._animState.sourceTabId&&!(n!=null&&n.has(v))){m=!0;break}}if(!m){const f=this._tabGroupManager.chipRenderers.get(c.id);f&&(s=f.chip.element)}break}}}const l=h=>h.classList.contains("dv-tab-group-chip")?"dv-tab-group-chip--shifting":"dv-tab--shifting",a=(h,c)=>{e?(h.style.transition="none",h.style.marginLeft=c,h.offsetHeight,h.style.removeProperty("transition")):h.style.marginLeft=c,E(h,l(h),!0)},r=h=>{const c=l(h),u=this._pendingMarginCleanups.get(h);if(u&&u(),e||!h.style.marginLeft)h.style.removeProperty("margin-left"),E(h,c,!1);else{h.style.marginLeft="0px",E(h,c,!0);const p=()=>{h.style.removeProperty("margin-left"),E(h,c,!1),h.removeEventListener("transitionend",p),clearTimeout(g),this._pendingMarginCleanups.delete(h)},g=setTimeout(p,300);this._pendingMarginCleanups.set(h,p),h.addEventListener("transitionend",p)}};let d=!1;for(const[h,c]of this._tabGroupManager.chipRenderers)h!==this._animState.sourceTabGroupId&&r(c.chip.element);s&&(a(s,`${i}px`),d=!0);for(let h=0;h<this._tabs.length;h++){const c=this._tabs[h].value;c.panel.id!==this._animState.sourceTabId&&(n!=null&&n.has(c.panel.id)||(!d&&h>=t?(a(c.element,`${i}px`),d=!0):r(c.element)))}this._tabGroupManager.trackUnderlines()}resetTabTransforms(){for(const[,e]of this._pendingMarginCleanups)e();this._pendingMarginCleanups.clear();for(const e of this._tabs)e.value.element.style.removeProperty("margin-left"),e.value.element.style.removeProperty("margin-right"),e.value.element.style.removeProperty("margin-top"),e.value.element.style.removeProperty("margin-bottom"),e.value.element.style.removeProperty("transform"),E(e.value.element,"dv-tab--shifting",!1);for(const[,e]of this._tabGroupManager.chipRenderers)e.chip.element.style.removeProperty("margin-left"),E(e.chip.element,"dv-tab-group-chip--shifting",!1);this._tabGroupManager.positionUnderlines()}_commitGroupMove(e,t){var i,n,s;const l=ae();if((i=this._chipDragCleanup)===null||i===void 0||i.dispose(),this._chipDragCleanup=null,this.group.model.getTabGroups().some(r=>r.id===e))if(((n=this.accessor.options.theme)===null||n===void 0?void 0:n.tabAnimation)==="smooth"){this._clearGroupDragClasses(e);const r=this.snapshotTabPositions();this.resetTabTransforms(),this.group.model.moveTabGroup(e,t),this.runFlipAnimation(r,"",!1)}else this._tabGroupManager.skipNextCollapseAnimation=!0,this.group.model.moveTabGroup(e,t);else l&&(this.resetTabTransforms(),this.accessor.moveGroupOrPanel({from:{groupId:l.groupId,tabGroupId:(s=l.tabGroupId)!==null&&s!==void 0?s:e},to:{group:this.group,position:"center",index:t}}))}_clearGroupDragClasses(e){const t=this._tabGroupManager.chipRenderers.get(e);t&&this._removeClassInstantlyBatch([t.chip.element],"dv-tab-group-chip--dragging"),this._removeClassInstantlyBatch(this._tabs.map(n=>n.value.element),"dv-tab--dragging");const i=this._tabGroupManager.groupUnderlines.get(e);i&&i.style.removeProperty("display"),this._tabGroupManager.skipNextCollapseAnimation=!0}resetDragAnimation(){var e,t;this._pendingCollapse=!1,this.resetTabTransforms(),!((e=this._animState)===null||e===void 0)&&e.sourceTabGroupId?this._clearGroupDragClasses(this._animState.sourceTabGroupId):this._removeClassInstantlyBatch(this._tabs.map(i=>i.value.element),"dv-tab--dragging"),this._animState=null,(t=this._chipDragCleanup)===null||t===void 0||t.dispose(),this._chipDragCleanup=null;for(const[,i]of this._tabGroupManager.groupUnderlines)i.style.removeProperty("display")}runFlipAnimation(e,t,i=!1,n){const s=this._direction==="vertical";let l=!1;for(let a=0;a<this._tabs.length;a++){const r=this._tabs[a],d=r.value.panel.id;if(d===t){if(i){const p=r.value.element.getBoundingClientRect();r.value.element.style.transform=s?`translateY(${p.height}px)`:`translateX(${p.width}px)`,E(r.value.element,"dv-tab--shifting",!0),l=!0}continue}if(n!==void 0&&(a<n.from||a>n.to))continue;const h=e.get(d);if(!h)continue;const c=r.value.element.getBoundingClientRect(),u=s?h.top-c.top:h.left-c.left;Math.abs(u)<1||(r.value.element.style.transform=s?`translateY(${u}px)`:`translateX(${u}px)`,E(r.value.element,"dv-tab--shifting",!0),l=!0)}l&&requestAnimationFrame(()=>{var a;for(const h of this._tabs)h.value.element.style.transform&&(h.value.element.style.transform="");this._tabGroupManager.trackUnderlines(),(a=this._flipTransitionCleanup)===null||a===void 0||a.call(this);const r=h=>{if(h.propertyName==="transform"){d();for(const c of this._tabs)E(c.value.element,"dv-tab--shifting",!1);this._tabGroupManager.positionUnderlines()}},d=()=>{this._tabsList.removeEventListener("transitionend",r),this._flipTransitionCleanup=null};this._flipTransitionCleanup=d,this._tabsList.addEventListener("transitionend",r)})}}const ci=o=>{const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttributeNS(null,"height",o.height),e.setAttributeNS(null,"width",o.width),e.setAttributeNS(null,"viewBox",o.viewbox),e.setAttributeNS(null,"aria-hidden","false"),e.setAttributeNS(null,"focusable","false"),e.classList.add("dv-svg");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttributeNS(null,"d",o.path),e.appendChild(t),e},Ys=()=>ci({width:"11",height:"11",viewbox:"0 0 28 28",path:"M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z"}),Zs=()=>ci({width:"11",height:"11",viewbox:"0 0 24 15",path:"M12 14.15L0 2.15L2.15 0L12 9.9L21.85 0.0499992L24 2.2L12 14.15Z"}),wn=()=>ci({width:"11",height:"11",viewbox:"0 0 15 25",path:"M2.15 24.1L0 21.95L9.9 12.05L0 2.15L2.15 0L14.2 12.05L2.15 24.1Z"});function Xs(){const o=document.createElement("div");o.className="dv-tabs-overflow-dropdown-default";const e=document.createElement("span");e.textContent="";const t=wn();return o.appendChild(t),o.appendChild(e),{element:o,update:i=>{e.textContent=`${i.tabs}`}}}class qs extends V{get onTabDragStart(){return this.tabs.onTabDragStart}get panels(){return this.tabs.panels}get size(){return this.tabs.size}get hidden(){return this._hidden}set hidden(e){this._hidden=e,this.element.style.display=e?"none":""}get direction(){return this._direction}set direction(e){this._direction=e,e==="vertical"?(Re(this._element,"dv-groupview-header-vertical"),Re(this.rightActionsContainer,"dv-right-actions-container-vertical"),this.tabs.direction=e):(Oe(this._element,"dv-groupview-header-vertical"),Oe(this.rightActionsContainer,"dv-right-actions-container-vertical"),this.tabs.direction=e)}get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this._hidden=!1,this._direction="horizontal",this.dropdownPart=null,this._overflowTabs=[],this._overflowTabGroups=[],this._dropdownDisposable=new he,this._onDrop=new _,this.onDrop=this._onDrop.event,this._onGroupDragStart=new _,this.onGroupDragStart=this._onGroupDragStart.event,this._onWillShowOverlay=new _,this.onWillShowOverlay=this._onWillShowOverlay.event,this._element=document.createElement("div"),this._element.className="dv-tabs-and-actions-container",E(this._element,"dv-full-width-single-tab",this.accessor.options.singleTabMode==="fullwidth"),this.rightActionsContainer=document.createElement("div"),this.rightActionsContainer.className="dv-right-actions-container",this.leftActionsContainer=document.createElement("div"),this.leftActionsContainer.className="dv-left-actions-container",this.preActionsContainer=document.createElement("div"),this.preActionsContainer.className="dv-pre-actions-container",this.tabs=new Js(t,e,{showTabsOverflowControl:!e.options.disableTabsOverflowList}),this.voidContainer=new Bs(this.accessor,this.group),this.tabs.voidContainer=this.voidContainer.element,this._element.appendChild(this.preActionsContainer),this._element.appendChild(this.tabs.element),this._element.appendChild(this.leftActionsContainer),this._element.appendChild(this.voidContainer.element),this._element.appendChild(this.rightActionsContainer),this.tabs.setExtendedDropZone(this._element),this.addDisposables(this.tabs.onDrop(i=>this._onDrop.fire(i)),this.tabs.onWillShowOverlay(i=>this._onWillShowOverlay.fire(i)),e.onDidOptionsChange(()=>{this.tabs.showTabsOverflowControl=!e.options.disableTabsOverflowList}),this.tabs.onOverflowTabsChange(i=>{this.toggleDropdown(i)}),this.tabs,this._onWillShowOverlay,this._onDrop,this._onGroupDragStart,this.voidContainer,this.voidContainer.onDragStart(i=>{this._onGroupDragStart.fire({nativeEvent:i,group:this.group})}),this.voidContainer.onDrop(i=>{this.tabs.handleVoidDrop()||this._onDrop.fire({event:i.nativeEvent,index:this.tabs.size})}),this.voidContainer.onWillShowOverlay(i=>{this._onWillShowOverlay.fire(new Ot(i,{kind:"header_space",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:ae}))}),R(this.leftActionsContainer,"dragleave",i=>{const n=i.relatedTarget;!this.leftActionsContainer.contains(n)&&!this._element.contains(n)&&this.tabs.clearExternalAnimState()}),R(this.voidContainer.element,"dragleave",i=>{const n=i.relatedTarget;this.voidContainer.element.contains(n)||(this._element.contains(n)?this.tabs.setExternalInsertionIndex(null):this.tabs.clearExternalAnimState())}),R(this.voidContainer.element,"pointerdown",i=>{if(i.defaultPrevented)return;if(!this.accessor.options.disableFloatingGroups&&i.shiftKey&&this.group.api.location.type!=="floating"&&this.group.api.location.type!=="edge"){i.preventDefault();const{top:s,left:l}=this.element.getBoundingClientRect(),{top:a,left:r}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(this.group,{x:l-r+20,y:s-a+20,inDragMode:!0})}}))}show(){this.hidden||(this.element.style.display="")}hide(){this._element.style.display="none"}setRightActionsElement(e){this.rightActions!==e&&(this.rightActions&&(this.rightActions.remove(),this.rightActions=void 0),e&&(this.rightActionsContainer.appendChild(e),this.rightActions=e))}setLeftActionsElement(e){this.leftActions!==e&&(this.leftActions&&(this.leftActions.remove(),this.leftActions=void 0),e&&(this.leftActionsContainer.appendChild(e),this.leftActions=e))}setPrefixActionsElement(e){this.preActions!==e&&(this.preActions&&(this.preActions.remove(),this.preActions=void 0),e&&(this.preActionsContainer.appendChild(e),this.preActions=e))}isActive(e){return this.tabs.isActive(e)}indexOf(e){return this.tabs.indexOf(e)}setActive(e){}delete(e){this.tabs.delete(e),this.updateClassnames()}setActivePanel(e){this.tabs.setActivePanel(e)}openPanel(e,t=this.tabs.size){this.tabs.openPanel(e,t),this.updateClassnames()}closePanel(e){this.delete(e.id)}updateClassnames(){E(this._element,"dv-single-tab",this.size===1)}toggleDropdown(e){const t=e.reset?[]:e.tabs,i=e.reset?[]:e.tabGroups;this._overflowTabs=t,this._overflowTabGroups=i;const n=this._overflowTabs.length;if(n>0&&this.dropdownPart){this.dropdownPart.update({tabs:n});return}if(n===0){this._dropdownDisposable.dispose();return}const s=document.createElement("div");s.className="dv-tabs-overflow-dropdown-root";const l=Xs();l.update({tabs:n}),this.dropdownPart=l,s.appendChild(l.element),this.rightActionsContainer.prepend(s),this._dropdownDisposable.value=new V(re.from(()=>{var a,r;s.remove(),(r=(a=this.dropdownPart)===null||a===void 0?void 0:a.dispose)===null||r===void 0||r.call(a),this.dropdownPart=null}),R(s,"pointerdown",a=>{a.preventDefault()},{capture:!0}),R(s,"click",a=>{const r=document.createElement("div");r.style.overflow="auto",r.className="dv-tabs-overflow-container";const d=new Set(this._overflowTabGroups),h=this.group.model.getTabGroups(),c=new Map;for(const g of h)if(d.has(g.id))for(const m of g.panelIds)c.set(m,g);const u=new Set;for(const g of this.tabs.tabs.filter(m=>this._overflowTabs.includes(m.panel.id))){const m=c.get(g.panel.id);if(m&&!u.has(m.id)){u.add(m.id);const C=document.createElement("div");C.className="dv-tabs-overflow-group-header";const T=document.createElement("span");T.className="dv-tabs-overflow-group-color",hi(T,m.color,this.accessor.tabGroupColorPalette),C.appendChild(T);const I=document.createElement("span");if(I.className="dv-tabs-overflow-group-label",I.textContent=m.label||m.id,C.appendChild(I),m.collapsed){const G=document.createElement("span");G.className="dv-tabs-overflow-group-collapsed-badge",G.textContent=`${m.panelIds.length}`,C.appendChild(G)}C.addEventListener("click",()=>{this.accessor.getPopupServiceForGroup(this.group).close(),m.collapsed&&m.expand();const G=m.panelIds[0];if(G){const P=this.group.panels.find(F=>F.id===G);P==null||P.api.setActive()}}),r.appendChild(C)}const f=this.group.panels.find(C=>C===g.panel),b=f.view.createTabRenderer("headerOverflow").element,w=document.createElement("div");E(w,"dv-tab",!0),E(w,"dv-active-tab",f.api.isActive),E(w,"dv-inactive-tab",!f.api.isActive),m&&E(w,"dv-tab--grouped",!0),w.addEventListener("click",C=>{this.accessor.getPopupServiceForGroup(this.group).close(),!C.defaultPrevented&&(m!=null&&m.collapsed&&m.expand(),g.element.scrollIntoView(),g.panel.api.setActive())}),w.appendChild(b),r.appendChild(w)}const p=on(s);this.accessor.getPopupServiceForGroup(this.group).openPopover(r,{x:a.clientX,y:a.clientY,zIndex:p!=null&&p.style.zIndex?`calc(${p.style.zIndex} * 2)`:void 0})}))}updateDragAndDropState(){this.tabs.updateDragAndDropState(),this.voidContainer.updateDragAndDropState()}updateTabGroups(){this.tabs.updateTabGroups()}refreshTabGroupAccent(){this.tabs.refreshTabGroupAccent()}}class Cn extends en{constructor(e,t,i,n,s){super(),this.nativeEvent=e,this.target=t,this.position=i,this.getData=n,this.group=s}}const Xt=Object.keys({disableAutoResizing:void 0,hideBorders:void 0,singleTabMode:void 0,disableFloatingGroups:void 0,floatingGroupBounds:void 0,popoutUrl:void 0,defaultRenderer:void 0,defaultHeaderPosition:void 0,debug:void 0,rootOverlayModel:void 0,locked:void 0,disableDnd:void 0,className:void 0,noPanelsOverlay:void 0,dndEdges:void 0,theme:void 0,disableTabsOverflowList:void 0,scrollbars:void 0,getTabContextMenuItems:void 0,getTabGroupChipContextMenuItems:void 0,createTabGroupChipComponent:void 0,tabGroupColors:void 0,tabGroupAccent:void 0});function Qs(o){return!!o.referencePanel}function eo(o){return!!o.referenceGroup}function to(o){return!!o.referencePanel}function io(o){return!!o.referenceGroup}class no extends V{get label(){return this._label}get color(){return this._color}get componentParams(){return this._componentParams}setLabel(e){this.isDisposed||this._label===e||(this._label=e,this._onDidChange.fire())}setColor(e){if(this.isDisposed)return;const t=e===""?void 0:e;this._color!==t&&(this._color=t,this._onDidChange.fire())}setComponentParams(e){this.isDisposed||(this._componentParams=e,this._onDidChange.fire())}get collapsed(){return this._collapsed}get panelIds(){return this._panelIds}get size(){return this._panelIds.length}get isEmpty(){return this._panelIds.length===0}constructor(e,t){var i,n;super(),this.id=e,this._collapsed=!1,this._panelIds=[],this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._onDidPanelChange=new _,this.onDidPanelChange=this._onDidPanelChange.event,this._onDidCollapseChange=new _,this.onDidCollapseChange=this._onDidCollapseChange.event,this._onDidDestroy=new _,this.onDidDestroy=this._onDidDestroy.event,this._label=(i=t==null?void 0:t.label)!==null&&i!==void 0?i:"",this._color=(t==null?void 0:t.color)===""||t==null?void 0:t.color,this._collapsed=(n=t==null?void 0:t.collapsed)!==null&&n!==void 0?n:!1,this._componentParams=t==null?void 0:t.componentParams,this.addDisposables(this._onDidChange,this._onDidPanelChange,this._onDidCollapseChange,this._onDidDestroy)}addPanel(e,t){if(this.isDisposed||this._panelIds.includes(e))return;const i=t!==void 0?Math.max(0,Math.min(t,this._panelIds.length)):this._panelIds.length;this._panelIds.splice(i,0,e),this._onDidPanelChange.fire({panelId:e,type:"add"})}removePanel(e){if(this.isDisposed)return!1;const t=this._panelIds.indexOf(e);return t===-1?!1:(this._panelIds.splice(t,1),this._onDidPanelChange.fire({panelId:e,type:"remove"}),!0)}indexOfPanel(e){return this._panelIds.indexOf(e)}containsPanel(e){return this._panelIds.includes(e)}collapse(){this.isDisposed||this._collapsed||(this._collapsed=!0,this._onDidCollapseChange.fire(!0))}expand(){this.isDisposed||!this._collapsed||(this._collapsed=!1,this._onDidCollapseChange.fire(!1))}toggle(){this._collapsed?this.expand():this.collapse()}toJSON(){const e={id:this.id,collapsed:this._collapsed,panelIds:[...this._panelIds]};return this._label&&(e.label=this._label),this._color!==void 0&&(e.color=this._color),this._componentParams!==void 0&&(e.componentParams=this._componentParams),e}dispose(){this._onDidDestroy.fire(),super.dispose()}}class ui extends si{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}get panel(){return this.options.panel}get group(){return this.options.group}get api(){return this.options.api}constructor(e){super(),this.options=e}getData(){return this.options.getData()}}class Dn extends ui{get kind(){return this._kind}constructor(e){super(e),this._kind=e.kind}}class so extends V{get tabGroups(){return this._tabGroups}get element(){throw new Error("dockview: not supported")}get activePanel(){return this._activePanel}get locked(){return this._locked}set locked(e){this._locked=e,E(this.container,"dv-locked-groupview",e==="no-drop-target"||e)}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return this._panels.length===0}get hasWatermark(){return!!(this.watermark&&this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get isContentFocused(){return document.activeElement?Bt(document.activeElement,this.contentContainer.element):!1}get headerPosition(){var e;return(e=this._headerPosition)!==null&&e!==void 0?e:"top"}set headerPosition(e){var t;this._headerPosition=e,Oe(this.container,"dv-groupview-header-top","dv-groupview-header-bottom","dv-groupview-header-left","dv-groupview-header-right"),Re(this.container,`dv-groupview-header-${e}`);const i=e==="top"||e==="bottom"?"horizontal":"vertical";this.tabsContainer.direction=i,this.header.direction=i,!((t=this._activePanel)===null||t===void 0)&&t.layout&&this._activePanel.layout(this._width,this._height),(this._leftHeaderActions||this._rightHeaderActions||this._prefixHeaderActions)&&this.updateHeaderActions()}get location(){return this._location}set location(e){switch(this._location=e,E(this.container,"dv-groupview-floating",!1),E(this.container,"dv-groupview-popout",!1),E(this.container,"dv-groupview-edge",!1),e.type){case"grid":this.contentContainer.dropTarget.setTargetZones(["top","bottom","left","right","center"]);break;case"floating":this.contentContainer.dropTarget.setTargetZones(["center"]),this.contentContainer.dropTarget.setTargetZones(e?["center"]:["top","bottom","left","right","center"]),E(this.container,"dv-groupview-floating",!0);break;case"popout":this.contentContainer.dropTarget.setTargetZones(["center"]),E(this.container,"dv-groupview-popout",!0);break;case"edge":this.contentContainer.dropTarget.setTargetZones(["center"]),E(this.container,"dv-groupview-edge",!0);break}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,i,n,s){var l,a;super(),this.container=e,this.accessor=t,this.id=i,this.options=n,this.groupPanel=s,this._isGroupActive=!1,this._locked=!1,this._rightHeaderActionsDisposable=new he,this._leftHeaderActionsDisposable=new he,this._prefixHeaderActionsDisposable=new he,this._location={type:"grid"},this.mostRecentlyUsed=[],this._overwriteRenderContainer=null,this._overwriteDropTargetContainer=null,this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._panelDisposables=new Map,this._tabGroupDisposables=new Map,this._pendingMicrotaskDisposables=new Set,this._onMove=new _,this.onMove=this._onMove.event,this._onDidDrop=new _,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new _,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new _,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onTabDragStart=new _,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new _,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new _,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPanelTitleChange=new _,this.onDidPanelTitleChange=this._onDidPanelTitleChange.event,this._onDidPanelParametersChange=new _,this.onDidPanelParametersChange=this._onDidPanelParametersChange.event,this._onDidRemovePanel=new _,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new _,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onUnhandledDragOverEvent=new _,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this._tabGroups=[],this._tabGroupMap=new Map,this._panelToTabGroup=new Map,this._tabGroupIdCounter=0,this._pendingTabGroupUpdate=!1,this._onDidCreateTabGroup=new _,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new _,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new _,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new _,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new _,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new _,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,E(this.container,"dv-groupview",!0),this._api=new Tt(this.accessor),this.tabsContainer=new qs(this.accessor,this.groupPanel),this.contentContainer=new Ns(this.accessor,this),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!n.hideHeader,this.locked=(l=n.locked)!==null&&l!==void 0?l:!1,this.headerPosition=(a=n.headerPosition)!==null&&a!==void 0?a:t.defaultHeaderPosition,this.addDisposables(this._onTabDragStart,this._onGroupDragStart,this._onWillShowOverlay,this._rightHeaderActionsDisposable,this._leftHeaderActionsDisposable,this._prefixHeaderActionsDisposable,this.tabsContainer.onTabDragStart(r=>{this._onTabDragStart.fire(r)}),this.tabsContainer.onGroupDragStart(r=>{this._onGroupDragStart.fire(r)}),this.tabsContainer.onDrop(r=>{var d;const h=ae(),c=(d=h==null?void 0:h.panelId)!==null&&d!==void 0?d:null;if(this.handleDropEvent("header",r.event,"center",r.index),c&&r.targetTabGroupId){const u=this._tabGroupMap.get(r.targetTabGroupId);let p;if(u){const g=this._panels.findIndex(m=>m.id===c);if(g!==-1){p=0;for(const m of u.panelIds)this._panels.findIndex(v=>v.id===m)<g&&p++}}this.addPanelToTabGroup(r.targetTabGroupId,c,p)}else c&&r.targetTabGroupId===null&&this.removePanelFromTabGroup(c)}),this.contentContainer.onDidFocus(()=>{this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.onDidBlur(()=>{}),this.contentContainer.dropTarget.onDrop(r=>{this.handleDropEvent("content",r.nativeEvent,r.position)}),this.tabsContainer.onWillShowOverlay(r=>{this._onWillShowOverlay.fire(r)}),this.contentContainer.dropTarget.onWillShowOverlay(r=>{this._onWillShowOverlay.fire(new Ot(r,{kind:"content",panel:this.activePanel,api:this._api,group:this.groupPanel,getData:ae}))}),this._onMove,this._onDidChange,this._onDidDrop,this._onWillDrop,this._onDidAddPanel,this._onDidRemovePanel,this._onDidActivePanelChange,this._onUnhandledDragOverEvent,this._onDidPanelTitleChange,this._onDidPanelParametersChange,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,this._onDidCreateTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidDestroyTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidAddPanelToTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidRemovePanelFromTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupChange.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupCollapsedChange.event(()=>{this._scheduleTabGroupUpdate()}))}_scheduleTabGroupUpdate(){this._pendingTabGroupUpdate||(this._pendingTabGroupUpdate=!0,queueMicrotask(()=>{this._pendingTabGroupUpdate=!1,this.isDisposed||this.tabsContainer.updateTabGroups()}))}createTabGroup(e){var t;const i=(t=e==null?void 0:e.id)!==null&&t!==void 0?t:`tg-${this.id}-${this._tabGroupIdCounter++}`,n=new no(i,{label:e==null?void 0:e.label,color:e==null?void 0:e.color,collapsed:e==null?void 0:e.collapsed,componentParams:e==null?void 0:e.componentParams});return this._tabGroups.push(n),this._tabGroupMap.set(i,n),this._tabGroupDisposables.set(i,new V(n.onDidChange(()=>{this._onDidTabGroupChange.fire({tabGroup:n})}),n.onDidCollapseChange(s=>{s?this._handleGroupCollapse(n):this._handleGroupExpand(n),this._onDidTabGroupCollapsedChange.fire({tabGroup:n})}),n.onDidDestroy(()=>{this._removeTabGroupInternal(n)}))),this._onDidCreateTabGroup.fire({tabGroup:n}),n}dissolveTabGroup(e){const t=this._tabGroupMap.get(e);if(!t)return;const i=[...t.panelIds];for(const n of i)t.removePanel(n),this._panelToTabGroup.delete(n),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:n});t.dispose()}addPanelToTabGroup(e,t,i){const n=this._tabGroupMap.get(e);if(!n||!this._panels.some(l=>l.id===t))return;const s=this.getTabGroupForPanel(t);if(s){if(s.id===e)return;this.removePanelFromTabGroup(t)}n.addPanel(t,i),this._panelToTabGroup.set(t,n),this._enforceContiguity(n,t),this._onDidAddPanelToTabGroup.fire({tabGroup:n,panelId:t})}movePanelWithinGroup(e,t,i){const n=this._tabGroupMap.get(e);!n||!n.containsPanel(t)||(n.removePanel(t),n.addPanel(t,i),this._enforceContiguity(n,t),this.tabsContainer.updateTabGroups())}movePanelBetweenGroups(e,t,i){const n=this._findTabGroupForPanel(e),s=this._tabGroupMap.get(t);s&&(n&&(n.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:n,panelId:e}),n.isEmpty&&n.dispose()),s.addPanel(e,i),this._panelToTabGroup.set(e,s),this._enforceContiguity(s,e),this._onDidAddPanelToTabGroup.fire({tabGroup:s,panelId:e}))}moveTabGroup(e,t){const i=this._tabGroupMap.get(e);if(!i||i.panelIds.length===0)return;const n=new Set(i.panelIds),s=i.panelIds.map(d=>this._panels.find(h=>h.id===d)).filter(d=>d!==void 0);if(s.length===0)return;let l=0;for(let d=0;d<Math.min(t,this._panels.length);d++)n.has(this._panels[d].id)&&l++;for(const d of s){const h=this._panels.indexOf(d);h!==-1&&this._panels.splice(h,1)}const a=t-l,r=Math.max(0,Math.min(a,this._panels.length));this._panels.splice(r,0,...s);for(const d of this._panels)this.tabsContainer.delete(d.id);for(let d=0;d<this._panels.length;d++)this.tabsContainer.openPanel(this._panels[d],d);this.tabsContainer.updateTabGroups()}_enforceContiguity(e,t){const i=this._panels.find(r=>r.id===t);if(!i)return;const n=e.indexOfPanel(t),s=this._computeGlobalIndex(e,n),l=this._panels.indexOf(i);if(l===s)return;this._panels.splice(l,1);const a=s>l?s-1:s;this._panels.splice(a,0,i),this.tabsContainer.delete(t),this.tabsContainer.openPanel(i,a)}_computeGlobalIndex(e,t){const i=e.panelIds;if(i.length<=1){const n=this._panels.find(s=>s.id===i[0]);return n?this._panels.indexOf(n):this._panels.length}for(let n=0;n<i.length;n++){if(n===t)continue;const s=this._panels.find(l=>l.id===i[n]);if(s){const l=this._panels.indexOf(s);return Math.max(0,l+(t-n))}}return this._panels.length}removePanelFromTabGroup(e){const t=this._findTabGroupForPanel(e);t&&(t.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:e}),t.isEmpty&&t.dispose())}getTabGroups(){return this._tabGroups}updateTabGroups(){this.tabsContainer.updateTabGroups()}refreshTabGroupAccent(){this.tabsContainer.refreshTabGroupAccent()}getTabGroupForPanel(e){return this._findTabGroupForPanel(e)}_findTabGroupForPanel(e){return this._panelToTabGroup.get(e)}_removeTabGroupInternal(e){const t=this._tabGroups.indexOf(e);if(t!==-1){this._tabGroups.splice(t,1),this._tabGroupMap.delete(e.id);for(const n of e.panelIds)this._panelToTabGroup.delete(n);this._onDidDestroyTabGroup.fire({tabGroup:e});const i=this._tabGroupDisposables.get(e.id);this._tabGroupDisposables.delete(e.id),i&&(this._pendingMicrotaskDisposables.add(i),queueMicrotask(()=>{this._pendingMicrotaskDisposables.delete(i),i.dispose()}))}}_handleGroupCollapse(e){if(!this._activePanel||!e.containsPanel(this._activePanel.id))return;const t=this._panels.indexOf(this._activePanel);for(let i=t+1;i<this._panels.length;i++){const n=this._panels[i],s=this._findTabGroupForPanel(n.id);if(!s||!s.collapsed){this.doSetActivePanel(n),this.updateContainer();return}}for(let i=t-1;i>=0;i--){const n=this._panels[i],s=this._findTabGroupForPanel(n.id);if(!s||!s.collapsed){this.doSetActivePanel(n),this.updateContainer();return}}this.contentContainer.closePanel(),this.doSetActivePanel(void 0),this.updateContainer()}_handleGroupExpand(e){if(this._activePanel)return;const t=e.panelIds[0];if(t){const i=this._panels.find(n=>n.id===t);i&&(this.doSetActivePanel(i),this.updateContainer())}}restoreTabGroups(e){for(const t of e){const i=t.id.match(/-(\d+)$/);if(i){const n=parseInt(i[1],10)+1;n>this._tabGroupIdCounter&&(this._tabGroupIdCounter=n)}}for(const t of e){const i=this.createTabGroup({id:t.id,label:t.label,color:t.color,componentParams:t.componentParams}),n=this._tabGroupMap.get(i.id);for(const s of t.panelIds)this._panels.some(l=>l.id===s)&&(i.addPanel(s),this._panelToTabGroup.set(s,n),this._enforceContiguity(n,s));t.collapsed&&i.collapse(),i.isEmpty&&i.dispose()}}focusContent(){this.contentContainer.element.focus()}set renderContainer(e){this.panels.forEach(t=>{this.renderContainer.detatch(t)}),this._overwriteRenderContainer=e,this.panels.forEach(t=>{this.rerender(t)})}get renderContainer(){var e;return(e=this._overwriteRenderContainer)!==null&&e!==void 0?e:this.accessor.overlayRenderContainer}set dropTargetContainer(e){this._overwriteDropTargetContainer=e}get dropTargetContainer(){var e;return(e=this._overwriteDropTargetContainer)!==null&&e!==void 0?e:this.accessor.rootDropTargetContainer}initialize(){this.options.panels&&this.options.panels.forEach(e=>{this.doAddPanel(e)}),this.options.activePanel&&this.openPanel(this.options.activePanel),this.setActive(this.isActive,!0),this.updateContainer(),this.updateHeaderActions()}updateHeaderActions(){this.accessor.options.createRightHeaderActionComponent?(this._rightHeaderActions=this.accessor.options.createRightHeaderActionComponent(this.groupPanel),this._rightHeaderActionsDisposable.value=this._rightHeaderActions,this._rightHeaderActions.init({containerApi:this._api,api:this.groupPanel.api,group:this.groupPanel}),this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element)):(this._rightHeaderActions=void 0,this._rightHeaderActionsDisposable.dispose(),this.tabsContainer.setRightActionsElement(void 0)),this.accessor.options.createLeftHeaderActionComponent?(this._leftHeaderActions=this.accessor.options.createLeftHeaderActionComponent(this.groupPanel),this._leftHeaderActionsDisposable.value=this._leftHeaderActions,this._leftHeaderActions.init({containerApi:this._api,api:this.groupPanel.api,group:this.groupPanel}),this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element)):(this._leftHeaderActions=void 0,this._leftHeaderActionsDisposable.dispose(),this.tabsContainer.setLeftActionsElement(void 0)),this.accessor.options.createPrefixHeaderActionComponent?(this._prefixHeaderActions=this.accessor.options.createPrefixHeaderActionComponent(this.groupPanel),this._prefixHeaderActionsDisposable.value=this._prefixHeaderActions,this._prefixHeaderActions.init({containerApi:this._api,api:this.groupPanel.api,group:this.groupPanel}),this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element)):(this._prefixHeaderActions=void 0,this._prefixHeaderActionsDisposable.dispose(),this.tabsContainer.setPrefixActionsElement(void 0))}rerender(e){this.contentContainer.renderPanel(e,{asActive:!1})}indexOf(e){return this.tabsContainer.indexOf(e.id)}toJSON(){var e;const t={views:this.tabsContainer.panels,activeView:(e=this._activePanel)===null||e===void 0?void 0:e.id,id:this.id};return this.locked!==!1&&(t.locked=this.locked),this.header.hidden&&(t.hideHeader=!0),this.headerPosition!=="top"&&(t.headerPosition=this.headerPosition),this._tabGroups.length>0&&(t.tabGroups=this._tabGroups.map(i=>i.toJSON())),t}moveToNext(e){e||(e={}),e.panel||(e.panel=this.activePanel);const t=e.panel?this.panels.indexOf(e.panel):-1;let i;if(t<this.panels.length-1)i=t+1;else if(!e.suppressRoll)i=0;else return;this.openPanel(this.panels[i])}moveToPrevious(e){if(e||(e={}),e.panel||(e.panel=this.activePanel),!e.panel)return;const t=this.panels.indexOf(e.panel);let i;if(t>0)i=t-1;else if(!e.suppressRoll)i=this.panels.length-1;else return;this.openPanel(this.panels[i])}containsPanel(e){return this.panels.includes(e)}init(e){}update(e){}focus(){var e;(e=this._activePanel)===null||e===void 0||e.focus()}openPanel(e,t={}){(typeof t.index!="number"||t.index>this.panels.length)&&(t.index=this.panels.length);const i=!!t.skipSetActive;if(e.updateParentGroup(this.groupPanel,{skipSetActive:t.skipSetActive}),this.doAddPanel(e,t.index,{skipSetActive:i}),this._activePanel===e){this.contentContainer.renderPanel(e,{asActive:!0});return}i||this.doSetActivePanel(e),t.skipSetGroupActive||this.accessor.doSetGroupActive(this.groupPanel),t.skipSetActive||this.updateContainer()}removePanel(e,t={skipSetActive:!1}){const i=typeof e=="string"?e:e.id,n=this._panels.find(s=>s.id===i);if(!n)throw new Error("invalid operation");return this._removePanel(n,t)}closeAllPanels(){if(this.panels.length>0){const e=[...this.panels];for(const t of e)this.doClose(t)}else this.accessor.removeGroup(this.groupPanel)}closePanel(e){this.doClose(e)}doClose(e){const t=this.panels.length===1&&this.accessor.groups.length===1;this.accessor.removePanel(e,t&&this.accessor.options.noPanelsOverlay==="emptyGroup"?{removeEmptyGroup:!1}:void 0)}isPanelActive(e){return this._activePanel===e}updateActions(e){this.tabsContainer.setRightActionsElement(e)}setActive(e,t=!1){if(!(!t&&this.isActive===e)){if(this._isGroupActive=e,E(this.container,"dv-active-group",e),E(this.container,"dv-inactive-group",!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0){const i=this._panels.find(n=>{const s=this._findTabGroupForPanel(n.id);return!s||!s.collapsed});i&&this.doSetActivePanel(i)}this.updateContainer()}}layout(e,t){var i;this._width=e,this._height=t,this.contentContainer.layout(this._width,this._height),!((i=this._activePanel)===null||i===void 0)&&i.layout&&this._activePanel.layout(this._width,this._height)}_removePanel(e,t){const i=this._activePanel===e;if(this.doRemovePanel(e),i&&this.panels.length>0){const n=this.mostRecentlyUsed[0];this.openPanel(n,{skipSetActive:t.skipSetActive,skipSetGroupActive:t.skipSetActiveGroup})}return this._activePanel&&this.panels.length===0&&this.doSetActivePanel(void 0),t.skipSetActive||this.updateContainer(),e}doRemovePanel(e){const t=this.panels.indexOf(e);if(this._activePanel===e&&this.contentContainer.closePanel(),this.tabsContainer.delete(e.id),this._panels.splice(t,1),this.mostRecentlyUsed.includes(e)){const n=this.mostRecentlyUsed.indexOf(e);this.mostRecentlyUsed.splice(n,1)}const i=this._panelDisposables.get(e.id);i&&(i.dispose(),this._panelDisposables.delete(e.id)),this.removePanelFromTabGroup(e.id),this._onDidRemovePanel.fire({panel:e})}doAddPanel(e,t=this.panels.length,i={skipSetActive:!1}){const s=this._panels.indexOf(e)>-1;this.tabsContainer.show(),this.contentContainer.show(),this.tabsContainer.openPanel(e,t),i.skipSetActive?e.api.renderer==="always"&&this.contentContainer.renderPanel(e,{asActive:!1}):this.contentContainer.openPanel(e),!s&&(this.updateMru(e),this.panels.splice(t,0,e),this._panelDisposables.set(e.id,new V(e.api.onDidTitleChange(l=>this._onDidPanelTitleChange.fire(l)),e.api.onDidParametersChange(l=>this._onDidPanelParametersChange.fire(l)))),this._onDidAddPanel.fire({panel:e}))}doSetActivePanel(e){this._activePanel!==e&&(this._activePanel=e,e&&(this.tabsContainer.setActivePanel(e),this.contentContainer.openPanel(e),e.layout(this._width,this._height),this.updateMru(e),this.contentContainer.refreshFocusState(),this._onDidActivePanelChange.fire({panel:e})))}updateMru(e){this.mostRecentlyUsed.includes(e)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(e),1),this.mostRecentlyUsed=[e,...this.mostRecentlyUsed]}updateContainer(){var e,t;this.panels.forEach(n=>n.runEvents());const i=this.isEmpty||!this._activePanel;if(i&&!this.watermark){const n=this.accessor.createWatermarkComponent();n.init({containerApi:this._api,group:this.groupPanel}),this.watermark=n,R(this.watermark.element,"pointerdown",()=>{this.isActive||this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.element.appendChild(this.watermark.element)}!i&&this.watermark&&(this.watermark.element.remove(),(t=(e=this.watermark).dispose)===null||t===void 0||t.call(e),this.watermark=void 0)}canDisplayOverlay(e,t,i){const n=new Cn(e,i,t,ae,this.accessor.getPanel(this.id));return this._onUnhandledDragOverEvent.fire(n),n.isAccepted}handleDropEvent(e,t,i,n){if(this.locked==="no-drop-target")return;function s(){switch(e){case"header":return typeof n=="number"?"tab":"header_space";case"content":return"content"}}const l=typeof n=="number"?this.panels[n]:void 0,a=new Dn({nativeEvent:t,position:i,panel:l,getData:()=>ae(),kind:s(),group:this.groupPanel,api:this._api});if(this._onWillDrop.fire(a),a.defaultPrevented)return;const r=ae();if(r&&r.viewId===this.accessor.id){if(e==="content"&&r.groupId===this.id&&(i==="center"||r.panelId===null&&!r.tabGroupId)||e==="header"&&r.groupId===this.id&&r.panelId===null&&!r.tabGroupId)return;if(r.panelId===null){const{groupId:p}=r;this._onMove.fire({target:i,groupId:p,index:n,tabGroupId:r.tabGroupId});return}if(this.tabsContainer.indexOf(r.panelId)!==-1&&this.tabsContainer.size===1)return;const{groupId:h,panelId:c}=r;if(this.id===h&&!i&&this.tabsContainer.indexOf(c)===n)return;this._onMove.fire({target:i,groupId:r.groupId,itemId:r.panelId,index:n})}else this._onDidDrop.fire(new ui({nativeEvent:t,position:i,panel:l,getData:()=>ae(),group:this.groupPanel,api:this._api}))}updateDragAndDropState(){this.tabsContainer.updateDragAndDropState()}dispose(){var e,t,i;super.dispose(),(e=this.watermark)===null||e===void 0||e.element.remove(),(i=(t=this.watermark)===null||t===void 0?void 0:t.dispose)===null||i===void 0||i.call(t),this.watermark=void 0;for(const n of[...this._tabGroups])n.dispose();for(const n of this._tabGroupDisposables.values())n.dispose();this._tabGroupDisposables.clear();for(const n of this._pendingMicrotaskDisposables)n.dispose();this._pendingMicrotaskDisposables.clear();for(const n of this.panels)n.dispose();this.tabsContainer.dispose(),this.contentContainer.dispose()}}class pi extends pn{constructor(e,t,i){super(e,t),this._onDidConstraintsChangeInternal=new _,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new _,this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new _,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange),i&&this.initialize(i)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}}class yn extends li{get priority(){return this._priority}get snap(){return this._snap}get minimumWidth(){return this.__minimumWidth()}get minimumHeight(){return this.__minimumHeight()}get maximumHeight(){return this.__maximumHeight()}get maximumWidth(){return this.__maximumWidth()}__minimumWidth(){const e=typeof this._minimumWidth=="function"?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}__maximumWidth(){const e=typeof this._maximumWidth=="function"?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}__minimumHeight(){const e=typeof this._minimumHeight=="function"?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}__maximumHeight(){const e=typeof this._maximumHeight=="function"?this._maximumHeight():this._maximumHeight;return e!==this._evaluatedMaximumHeight&&(this._evaluatedMaximumHeight=e,this.updateConstraints()),e}get isActive(){return this.api.isActive}get isVisible(){return this.api.isVisible}constructor(e,t,i,n){super(e,t,n??new pi(e,t)),this._evaluatedMinimumWidth=0,this._evaluatedMaximumWidth=Number.MAX_SAFE_INTEGER,this._evaluatedMinimumHeight=0,this._evaluatedMaximumHeight=Number.MAX_SAFE_INTEGER,this._minimumWidth=0,this._minimumHeight=0,this._maximumWidth=Number.MAX_SAFE_INTEGER,this._maximumHeight=Number.MAX_SAFE_INTEGER,this._snap=!1,this._onDidChange=new _,this.onDidChange=this._onDidChange.event,typeof(i==null?void 0:i.minimumWidth)=="number"&&(this._minimumWidth=i.minimumWidth),typeof(i==null?void 0:i.maximumWidth)=="number"&&(this._maximumWidth=i.maximumWidth),typeof(i==null?void 0:i.minimumHeight)=="number"&&(this._minimumHeight=i.minimumHeight),typeof(i==null?void 0:i.maximumHeight)=="number"&&(this._maximumHeight=i.maximumHeight),this.api.initialize(this),this.addDisposables(this.api.onWillVisibilityChange(s=>{const{isVisible:l}=s,{accessor:a}=this._params;a.setVisible(this,l)}),this.api.onActiveChange(()=>{const{accessor:s}=this._params;s.doSetGroupActive(this)}),this.api.onDidConstraintsChangeInternal(s=>{(typeof s.minimumWidth=="number"||typeof s.minimumWidth=="function")&&(this._minimumWidth=s.minimumWidth),(typeof s.minimumHeight=="number"||typeof s.minimumHeight=="function")&&(this._minimumHeight=s.minimumHeight),(typeof s.maximumWidth=="number"||typeof s.maximumWidth=="function")&&(this._maximumWidth=s.maximumWidth),(typeof s.maximumHeight=="number"||typeof s.maximumHeight=="function")&&(this._maximumHeight=s.maximumHeight)}),this.api.onDidSizeChange(s=>{this._onDidChange.fire({height:s.height,width:s.width})}),this._onDidChange)}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}init(e){e.maximumHeight&&(this._maximumHeight=e.maximumHeight),e.minimumHeight&&(this._minimumHeight=e.minimumHeight),e.maximumWidth&&(this._maximumWidth=e.maximumWidth),e.minimumWidth&&(this._minimumWidth=e.minimumWidth),this._priority=e.priority,this._snap=!!e.snap,super.init(e),typeof e.isVisible=="boolean"&&this.setVisible(e.isVisible)}updateConstraints(){this.api._onDidConstraintsChange.fire({minimumWidth:this._evaluatedMinimumWidth,maximumWidth:this._evaluatedMaximumWidth,minimumHeight:this._evaluatedMinimumHeight,maximumHeight:this._evaluatedMaximumHeight})}toJSON(){const e=super.toJSON(),t=n=>n===Number.MAX_SAFE_INTEGER?void 0:n,i=n=>n<=0?void 0:n;return Object.assign(Object.assign({},e),{minimumHeight:i(this.minimumHeight),maximumHeight:t(this.maximumHeight),minimumWidth:i(this.minimumWidth),maximumWidth:t(this.maximumWidth),snap:this.snap,priority:this.priority})}}const Je="dockview: DockviewGroupPanelApiImpl not initialized";class oo extends pi{get location(){if(!this._group)throw new Error(Je);return this._group.model.location}constructor(e,t){super(e,"__dockviewgroup__"),this.accessor=t,this._onDidLocationChange=new _,this.onDidLocationChange=this._onDidLocationChange.event,this._onDidActivePanelChange=new _,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidCollapsedChange=new _,this.onDidCollapsedChange=this._onDidCollapsedChange.event,this.addDisposables(this._onDidLocationChange,this._onDidActivePanelChange,this._onDidCollapsedChange,this._onDidVisibilityChange.event(i=>{i.isVisible&&this._pendingSize&&(super.setSize(this._pendingSize),this._pendingSize=void 0)}))}setSize(e){this._pendingSize=Object.assign({},e),super.setSize(e)}close(){if(this._group)return this.accessor.removeGroup(this._group)}getWindow(){return this.location.type==="popout"?this.location.getWindow():window}setHeaderPosition(e){if(!this._group)throw new Error(Je);this._group.model.headerPosition=e}getHeaderPosition(){if(!this._group)throw new Error(Je);return this._group.model.headerPosition}moveTo(e){var t,i,n,s;if(!this._group)throw new Error(Je);const l=(t=e.group)!==null&&t!==void 0?t:this.accessor.addGroup({direction:As((i=e.position)!==null&&i!==void 0?i:"right"),skipSetActive:(n=e.skipSetActive)!==null&&n!==void 0?n:!1});this.accessor.moveGroupOrPanel({from:{groupId:this._group.id},to:{group:l,position:e.group&&(s=e.position)!==null&&s!==void 0?s:"center",index:e.index},skipSetActive:e.skipSetActive})}maximize(){if(!this._group)throw new Error(Je);this.location.type==="grid"&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw new Error(Je);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw new Error(Je);this.isMaximized()&&this.accessor.exitMaximizedGroup()}collapse(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!0)}expand(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!1)}isCollapsed(){return this._group?this.accessor.isEdgeGroupCollapsed(this._group):!1}initialize(e){this._group=e}}const ro=100,ao=100;class Dt extends yn{get minimumWidth(){var e;if(typeof this._explicitConstraints.minimumWidth=="number")return this._explicitConstraints.minimumWidth;const t=(e=this.activePanel)===null||e===void 0?void 0:e.minimumWidth;return typeof t=="number"?t:super.__minimumWidth()}get minimumHeight(){var e;if(typeof this._explicitConstraints.minimumHeight=="number")return this._explicitConstraints.minimumHeight;const t=(e=this.activePanel)===null||e===void 0?void 0:e.minimumHeight;return typeof t=="number"?t:super.__minimumHeight()}get maximumWidth(){var e;if(typeof this._explicitConstraints.maximumWidth=="number")return this._explicitConstraints.maximumWidth;const t=(e=this.activePanel)===null||e===void 0?void 0:e.maximumWidth;return typeof t=="number"?t:super.__maximumWidth()}get maximumHeight(){var e;if(typeof this._explicitConstraints.maximumHeight=="number")return this._explicitConstraints.maximumHeight;const t=(e=this.activePanel)===null||e===void 0?void 0:e.maximumHeight;return typeof t=="number"?t:super.__maximumHeight()}get panels(){return this._model.panels}get activePanel(){return this._model.activePanel}get size(){return this._model.size}get model(){return this._model}get locked(){return this._model.locked}set locked(e){this._model.locked=e}get header(){return this._model.header}constructor(e,t,i){var n,s,l,a,r,d;super(t,"groupview_default",{minimumHeight:(s=(n=i.constraints)===null||n===void 0?void 0:n.minimumHeight)!==null&&s!==void 0?s:ao,minimumWidth:(a=(l=i.constraints)===null||l===void 0?void 0:l.minimumWidth)!==null&&a!==void 0?a:ro,maximumHeight:(r=i.constraints)===null||r===void 0?void 0:r.maximumHeight,maximumWidth:(d=i.constraints)===null||d===void 0?void 0:d.maximumWidth},new oo(t,e)),this._explicitConstraints={},this.api.initialize(this),this._model=new so(this.element,e,t,i,this),this.addDisposables(this.model.onDidActivePanelChange(h=>{this.api._onDidActivePanelChange.fire(h)}),this.api.onDidConstraintsChangeInternal(h=>{h.minimumWidth!==void 0&&(this._explicitConstraints.minimumWidth=typeof h.minimumWidth=="function"?h.minimumWidth():h.minimumWidth),h.minimumHeight!==void 0&&(this._explicitConstraints.minimumHeight=typeof h.minimumHeight=="function"?h.minimumHeight():h.minimumHeight),h.maximumWidth!==void 0&&(this._explicitConstraints.maximumWidth=typeof h.maximumWidth=="function"?h.maximumWidth():h.maximumWidth),h.maximumHeight!==void 0&&(this._explicitConstraints.maximumHeight=typeof h.maximumHeight=="function"?h.maximumHeight():h.maximumHeight)}))}focus(){this.api.isActive||this.api.setActive(),super.focus()}initialize(){this._model.initialize()}setActive(e){super.setActive(e),this.model.setActive(e)}layout(e,t){super.layout(e,t),this.model.layout(e,t)}getComponent(){return this._model}toJSON(){return this.model.toJSON()}}const lo={className:"dockview-theme-abyss",tabGroupIndicator:"none"};class ho extends pi{get location(){return this.group.api.location}get title(){return this.panel.title}get isGroupActive(){return this.group.isActive}get renderer(){return this.panel.renderer}set group(e){const t=this._group;this._group!==e&&(this._group=e,this._onDidGroupChange.fire({}),this.setupGroupEventListeners(t),this._onDidLocationChange.fire({location:this.group.api.location}))}get group(){return this._group}get tabComponent(){return this._tabComponent}constructor(e,t,i,n,s){super(e.id,n),this.panel=e,this.accessor=i,this._onDidTitleChange=new _,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidActiveGroupChange=new _,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new _,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new _,this.onDidRendererChange=this._onDidRendererChange.event,this._onDidLocationChange=new _,this.onDidLocationChange=this._onDidLocationChange.event,this.groupEventsDisposable=new he,this._tabComponent=s,this.initialize(e),this._group=t,this.setupGroupEventListeners(),this.addDisposables(this.groupEventsDisposable,this._onDidRendererChange,this._onDidTitleChange,this._onDidGroupChange,this._onDidActiveGroupChange,this._onDidLocationChange)}getWindow(){return this.group.api.getWindow()}moveTo(e){var t,i;this.accessor.moveGroupOrPanel({from:{groupId:this._group.id,panelId:this.panel.id},to:{group:(t=e.group)!==null&&t!==void 0?t:this._group,position:e.group&&(i=e.position)!==null&&i!==void 0?i:"center",index:e.index},skipSetActive:e.skipSetActive})}setTitle(e){this.panel.setTitle(e)}setRenderer(e){this.panel.setRenderer(e)}close(){this.group.model.closePanel(this.panel)}maximize(){this.group.api.maximize()}isMaximized(){return this.group.api.isMaximized()}exitMaximized(){this.group.api.exitMaximized()}setupGroupEventListeners(e){var t;let i=(t=e==null?void 0:e.isActive)!==null&&t!==void 0?t:!1;this.groupEventsDisposable.value=new V(this.group.api.onDidVisibilityChange(n=>{const s=!n.isVisible&&this.isVisible,l=n.isVisible&&!this.isVisible,a=this.group.model.isPanelActive(this.panel);(s||l&&a)&&this._onDidVisibilityChange.fire(n)}),this.group.api.onDidLocationChange(n=>{this.group===this.panel.group&&this._onDidLocationChange.fire(n)}),this.group.api.onDidActiveChange(()=>{this.group===this.panel.group&&i!==this.isGroupActive&&(i=this.isGroupActive,this._onDidActiveGroupChange.fire({isActive:this.isGroupActive}))}))}}class ot extends V{get params(){return this._params}get title(){return this._title}get group(){return this._group}get renderer(){var e;return(e=this._renderer)!==null&&e!==void 0?e:this.accessor.renderer}get minimumWidth(){return this._minimumWidth}get minimumHeight(){return this._minimumHeight}get maximumWidth(){return this._maximumWidth}get maximumHeight(){return this._maximumHeight}constructor(e,t,i,n,s,l,a,r){super(),this.id=e,this.accessor=n,this.containerApi=s,this.view=a,this._renderer=r.renderer,this._group=l,this._minimumWidth=r.minimumWidth,this._minimumHeight=r.minimumHeight,this._maximumWidth=r.maximumWidth,this._maximumHeight=r.maximumHeight,this.api=new ho(this,this._group,n,t,i),this.addDisposables(this.api.onActiveChange(()=>{n.setActivePanel(this)}),this.api.onDidSizeChange(d=>{this.group.api.setSize(d)}),this.api.onDidRendererChange(()=>{this.group.model.rerender(this)}))}init(e){this._params=e.params,this.view.init(Object.assign(Object.assign({},e),{api:this.api,containerApi:this.containerApi})),this.setTitle(e.title)}focus(){const e=new un;this.api._onWillFocus.fire(e),!e.defaultPrevented&&(this.api.isActive||this.api.setActive())}toJSON(){return{id:this.id,contentComponent:this.view.contentComponent,tabComponent:this.view.tabComponent,params:Object.keys(this._params||{}).length>0?this._params:void 0,title:this.title,renderer:this._renderer,minimumHeight:this._minimumHeight,maximumHeight:this._maximumHeight,minimumWidth:this._minimumWidth,maximumWidth:this._maximumWidth}}setTitle(e){e!==this.title&&(this._title=e,this.api._onDidTitleChange.fire({title:e}))}setRenderer(e){e!==this.renderer&&(this._renderer=e,this.api._onDidRendererChange.fire({renderer:e}))}update(e){var t;this._params=Object.assign(Object.assign({},(t=this._params)!==null&&t!==void 0?t:{}),e.params);for(const i of Object.keys(e.params))e.params[i]===void 0&&delete this._params[i];this.view.update({params:this._params})}updateFromStateModel(e){var t,i,n;this._maximumHeight=e.maximumHeight,this._minimumHeight=e.minimumHeight,this._maximumWidth=e.maximumWidth,this._minimumWidth=e.minimumWidth,this.update({params:(t=e.params)!==null&&t!==void 0?t:{}}),this.setTitle((i=e.title)!==null&&i!==void 0?i:this.id),this.setRenderer((n=e.renderer)!==null&&n!==void 0?n:this.accessor.renderer)}updateParentGroup(e,t){this._group=e,this.api.group=this._group;const i=this._group.model.isPanelActive(this),n=this.group.api.isActive&&i;t!=null&&t.skipSetActive||this.api.isActive!==n&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&i}),this.api.isVisible!==i&&this.api._onDidVisibilityChange.fire({isVisible:i})}runEvents(){const e=this._group.model.isPanelActive(this),t=this.group.api.isActive&&e;this.api.isActive!==t&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&e}),this.api.isVisible!==e&&this.api._onDidVisibilityChange.fire({isVisible:e})}layout(e,t){this.api._onDidDimensionChange.fire({width:e,height:t}),this.view.layout(e,t)}dispose(){this.api.dispose(),this.view.dispose()}}class Ei extends V{get element(){return this._element}constructor(){super(),this._element=document.createElement("div"),this._element.className="dv-default-tab",this._content=document.createElement("div"),this._content.className="dv-default-tab-content",this.action=document.createElement("div"),this.action.className="dv-default-tab-action",this.action.appendChild(Ys()),this._element.appendChild(this._content),this._element.appendChild(this.action),this.render()}init(e){this._title=e.title,this.addDisposables(e.api.onDidTitleChange(t=>{this._title=t.title,this.render()}),R(this.action,"pointerdown",t=>{t.preventDefault()}),R(this.action,"click",t=>{t.defaultPrevented||(t.preventDefault(),e.api.close())})),this.render()}render(){var e;this._content.textContent!==this._title&&(this._content.textContent=(e=this._title)!==null&&e!==void 0?e:"")}}class xn{get content(){return this._content}get tab(){return this._tab}constructor(e,t,i,n){this.accessor=e,this.id=t,this.contentComponent=i,this.tabComponent=n,this._content=this.createContentComponent(this.id,i),this._tab=this.createTabComponent(this.id,n)}createTabRenderer(e){var t;const i=this.createTabComponent(this.id,this.tabComponent);return this._params&&i.init(Object.assign(Object.assign({},this._params),{tabLocation:e})),this._updateEvent&&((t=i.update)===null||t===void 0||t.call(i,this._updateEvent)),i}init(e){this._params=e,this.content.init(e),this.tab.init(Object.assign(Object.assign({},e),{tabLocation:"header"}))}layout(e,t){var i,n;(n=(i=this.content).layout)===null||n===void 0||n.call(i,e,t)}update(e){var t,i,n,s;this._updateEvent=e,(i=(t=this.content).update)===null||i===void 0||i.call(t,e),(s=(n=this.tab).update)===null||s===void 0||s.call(n,e)}dispose(){var e,t,i,n;(t=(e=this.content).dispose)===null||t===void 0||t.call(e),(n=(i=this.tab).dispose)===null||n===void 0||n.call(i)}createContentComponent(e,t){return this.accessor.options.createComponent({id:e,name:t})}createTabComponent(e,t){const i=t??this.accessor.options.defaultTabComponent;if(i){if(this.accessor.options.createTabComponent){const n=this.accessor.options.createTabComponent({id:e,name:i});return n||new Ei}console.warn(`dockview: tabComponent '${t}' was not found. falling back to the default tab.`)}return new Ei}}class co{constructor(e){this.accessor=e}fromJSON(e,t){var i,n;const s=e.id,l=e.params,a=e.title,r=e.view,d=r?r.content.id:(i=e.contentComponent)!==null&&i!==void 0?i:"unknown",h=r?(n=r.tab)===null||n===void 0?void 0:n.id:e.tabComponent,c=new xn(this.accessor,s,d,h),u=new ot(s,d,h,this.accessor,new Tt(this.accessor),t,c,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return u.init({title:a??s,params:l??{}}),u}}class uo extends V{get element(){return this._element}constructor(){super(),this._element=document.createElement("div"),this._element.className="dv-watermark"}init(e){}}class po{constructor(){this._orderedList=[]}push(e){this._orderedList=[...this._orderedList.filter(t=>t!==e),e],this.update()}destroy(e){this._orderedList=this._orderedList.filter(t=>t!==e),this.update()}update(){for(let e=0;e<this._orderedList.length;e++)this._orderedList[e].setAttribute("aria-level",`${e}`),this._orderedList[e].style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2})`}}const yt=new po;class We extends V{set minimumInViewportWidth(e){this.options.minimumInViewportWidth=e}set minimumInViewportHeight(e){this.options.minimumInViewportHeight=e}get element(){return this._element}get isVisible(){return this._isVisible}constructor(e){super(),this.options=e,this._element=document.createElement("div"),this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new _,this.onDidChangeEnd=this._onDidChangeEnd.event,this.addDisposables(this._onDidChange,this._onDidChangeEnd),this._element.className="dv-resize-container",this._isVisible=!0,this.setupResize("top"),this.setupResize("bottom"),this.setupResize("left"),this.setupResize("right"),this.setupResize("topleft"),this.setupResize("topright"),this.setupResize("bottomleft"),this.setupResize("bottomright"),this._element.appendChild(this.options.content),this.options.container.appendChild(this._element),this.setBounds(Object.assign(Object.assign(Object.assign(Object.assign({height:this.options.height,width:this.options.width},"top"in this.options&&{top:this.options.top}),"bottom"in this.options&&{bottom:this.options.bottom}),"left"in this.options&&{left:this.options.left}),"right"in this.options&&{right:this.options.right})),yt.push(this._element)}setVisible(e){e!==this.isVisible&&(this._isVisible=e,E(this.element,"dv-hidden",!this.isVisible))}bringToFront(){yt.push(this._element)}setBounds(e={}){typeof e.height=="number"&&(this._element.style.height=`${e.height}px`),typeof e.width=="number"&&(this._element.style.width=`${e.width}px`),"top"in e&&typeof e.top=="number"&&(this._element.style.top=`${e.top}px`,this._element.style.bottom="auto",this.verticalAlignment="top"),"bottom"in e&&typeof e.bottom=="number"&&(this._element.style.bottom=`${e.bottom}px`,this._element.style.top="auto",this.verticalAlignment="bottom"),"left"in e&&typeof e.left=="number"&&(this._element.style.left=`${e.left}px`,this._element.style.right="auto",this.horiziontalAlignment="left"),"right"in e&&typeof e.right=="number"&&(this._element.style.right=`${e.right}px`,this._element.style.left="auto",this.horiziontalAlignment="right");const t=this.options.container.getBoundingClientRect(),i=this._element.getBoundingClientRect(),n=Math.max(0,this.getMinimumWidth(i.width)),s=Math.max(0,this.getMinimumHeight(i.height));if(this.verticalAlignment==="top"){const l=q(i.top-t.top,-s,Math.max(0,t.height-i.height+s));this._element.style.top=`${l}px`,this._element.style.bottom="auto"}if(this.verticalAlignment==="bottom"){const l=q(t.bottom-i.bottom,-s,Math.max(0,t.height-i.height+s));this._element.style.bottom=`${l}px`,this._element.style.top="auto"}if(this.horiziontalAlignment==="left"){const l=q(i.left-t.left,-n,Math.max(0,t.width-i.width+n));this._element.style.left=`${l}px`,this._element.style.right="auto"}if(this.horiziontalAlignment==="right"){const l=q(t.right-i.right,-n,Math.max(0,t.width-i.width+n));this._element.style.right=`${l}px`,this._element.style.left="auto"}this._onDidChange.fire()}toJSON(){const e=this.options.container.getBoundingClientRect(),t=this._element.getBoundingClientRect(),i={};return this.verticalAlignment==="top"?i.top=parseFloat(this._element.style.top):this.verticalAlignment==="bottom"?i.bottom=parseFloat(this._element.style.bottom):i.top=t.top-e.top,this.horiziontalAlignment==="left"?i.left=parseFloat(this._element.style.left):this.horiziontalAlignment==="right"?i.right=parseFloat(this._element.style.right):i.left=t.left-e.left,i.width=t.width,i.height=t.height,i}setupDrag(e,t={inDragMode:!1}){const i=new he,n=()=>{let s=null;const l=pt();i.value=new V({dispose:()=>{l.release()}},R(window,"pointermove",a=>{const r=this.options.container.getBoundingClientRect(),d=a.clientX-r.left,h=a.clientY-r.top;E(this._element,"dv-resize-container-dragging",!0);const c=this._element.getBoundingClientRect();s===null&&(s={x:a.clientX-c.left,y:a.clientY-c.top});const u=Math.max(0,this.getMinimumWidth(c.width)),p=Math.max(0,this.getMinimumHeight(c.height)),g=q(h-s.y,-p,Math.max(0,r.height-c.height+p)),m=q(s.y-h+r.height-c.height,-p,Math.max(0,r.height-c.height+p)),f=q(d-s.x,-u,Math.max(0,r.width-c.width+u)),v=q(s.x-d+r.width-c.width,-u,Math.max(0,r.width-c.width+u)),b={};g<=m?b.top=g:b.bottom=m,f<=v?b.left=f:b.right=v,this.setBounds(b)}),R(window,"pointerup",()=>{E(this._element,"dv-resize-container-dragging",!1),i.dispose(),this._onDidChangeEnd.fire()}))};this.addDisposables(i,R(e,"pointerdown",s=>{if(s.defaultPrevented){s.preventDefault();return}Si(s)||n()}),R(this.options.content,"pointerdown",s=>{s.defaultPrevented||Si(s)||s.shiftKey&&n()}),R(this.options.content,"pointerdown",()=>{yt.push(this._element)},!0)),t.inDragMode&&n()}setupResize(e){const t=document.createElement("div");t.className=`dv-resize-handle-${e}`,this._element.appendChild(t);const i=new he;this.addDisposables(i,R(t,"pointerdown",n=>{n.preventDefault();let s=null;const l=pt();i.value=new V(R(window,"pointermove",a=>{const r=this.options.container.getBoundingClientRect(),d=this._element.getBoundingClientRect(),h=a.clientY-r.top,c=a.clientX-r.left;s===null&&(s={originalY:h,originalHeight:d.height,originalX:c,originalWidth:d.width});let u,p,g,m,f,v;const b=()=>{const G=s.originalY+s.originalHeight>r.height?Math.max(0,r.height-We.MINIMUM_HEIGHT):Math.max(0,s.originalY+s.originalHeight-We.MINIMUM_HEIGHT);u=q(h,0,G),g=s.originalY+s.originalHeight-u,p=r.height-u-g},w=()=>{u=s.originalY-s.originalHeight;const G=u<0&&typeof this.options.minimumInViewportHeight=="number"?-u+this.options.minimumInViewportHeight:We.MINIMUM_HEIGHT,P=r.height-Math.max(0,u);g=q(h-u,G,P),p=r.height-u-g},C=()=>{const G=s.originalX+s.originalWidth>r.width?Math.max(0,r.width-We.MINIMUM_WIDTH):Math.max(0,s.originalX+s.originalWidth-We.MINIMUM_WIDTH);m=q(c,0,G),v=s.originalX+s.originalWidth-m,f=r.width-m-v},T=()=>{m=s.originalX-s.originalWidth;const G=m<0&&typeof this.options.minimumInViewportWidth=="number"?-m+this.options.minimumInViewportWidth:We.MINIMUM_WIDTH,P=r.width-Math.max(0,m);v=q(c-m,G,P),f=r.width-m-v};switch(e){case"top":b();break;case"bottom":w();break;case"left":C();break;case"right":T();break;case"topleft":b(),C();break;case"topright":b(),T();break;case"bottomleft":w(),C();break;case"bottomright":w(),T();break}const I={};u<=p?I.top=u:I.bottom=p,m<=f?I.left=m:I.right=f,I.height=g,I.width=v,this.setBounds(I)}),{dispose:()=>{l.release()}},R(window,"pointerup",()=>{i.dispose(),this._onDidChangeEnd.fire()}))}))}getMinimumWidth(e){return typeof this.options.minimumInViewportWidth=="number"?e-this.options.minimumInViewportWidth:0}getMinimumHeight(e){return typeof this.options.minimumInViewportHeight=="number"?e-this.options.minimumInViewportHeight:0}dispose(){yt.destroy(this._element),this._element.remove(),super.dispose()}}We.MINIMUM_HEIGHT=20;We.MINIMUM_WIDTH=20;class mo extends V{constructor(e,t){super(),this.group=e,this.overlay=t,this.addDisposables(t)}position(e){this.overlay.setBounds(e)}}const xt=100,je={left:100,top:100,width:300,height:300},fo=100;class go{constructor(){this.cache=new Map,this.currentFrameId=0,this.rafId=null}getPosition(e){const t=this.cache.get(e);if(t&&t.frameId===this.currentFrameId)return t.rect;this.scheduleFrameUpdate();const i=$t(e);return this.cache.set(e,{rect:i,frameId:this.currentFrameId}),i}invalidate(){this.currentFrameId++}scheduleFrameUpdate(){this.rafId||(this.rafId=requestAnimationFrame(()=>{this.currentFrameId++,this.rafId=null}))}}function vo(){const o=document.createElement("div");return o.tabIndex=-1,o}class Ti extends V{constructor(e,t){super(),this.element=e,this.accessor=t,this.map={},this._disposed=!1,this.positionCache=new go,this.pendingUpdates=new Set,this.addDisposables(re.from(()=>{for(const i of Object.values(this.map))i.disposable.dispose(),i.destroy.dispose();this._disposed=!0}))}updateAllPositions(){if(!this._disposed){this.positionCache.invalidate();for(const e of Object.values(this.map))e.panel.api.isVisible&&e.resize&&e.resize()}}detatch(e){if(this.map[e.api.id]){const{disposable:t,destroy:i}=this.map[e.api.id];return t.dispose(),i.dispose(),delete this.map[e.api.id],!0}return!1}attach(e){const{panel:t,referenceContainer:i}=e;if(!this.map[t.api.id]){const c=vo();c.className="dv-render-overlay",c.style.visibility="hidden",this.map[t.api.id]={panel:t,disposable:re.NONE,destroy:re.NONE,element:c}}const n=this.map[t.api.id].element,s=t.view.content.element;s.parentElement!==n&&n.appendChild(s),n.parentElement!==this.element&&this.element.appendChild(n);const l=()=>{const c=t.api.id;this.pendingUpdates.has(c)||(this.pendingUpdates.add(c),requestAnimationFrame(()=>{if(this.pendingUpdates.delete(c),this.isDisposed||!this.map[c])return;const u=this.positionCache.getPosition(i.element),p=this.positionCache.getPosition(this.element),g=u.left-p.left,m=u.top-p.top,f=u.width,v=u.height;n.style.left=`${g}px`,n.style.top=`${m}px`,n.style.width=`${f}px`,n.style.height=`${v}px`,t.api.isVisible?(n.style.visibility="",n.style.pointerEvents=""):(n.style.visibility="hidden",n.style.pointerEvents="none"),E(n,"dv-render-overlay-float",t.group.api.location.type==="floating")}))},a=()=>{t.api.isVisible?(this.positionCache.invalidate(),l(),n.style.pointerEvents=""):(n.style.visibility="hidden",n.style.pointerEvents="none")},r=new he,d=()=>{t.api.location.type==="floating"?queueMicrotask(()=>{const c=this.accessor.floatingGroups.find(m=>m.group===t.api.group);if(!c)return;const u=c.overlay.element,p=()=>{const m=Number(u.getAttribute("aria-level"));n.style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${m*2+1})`},g=new MutationObserver(()=>{p()});r.value=re.from(()=>g.disconnect()),g.observe(u,{attributeFilter:["aria-level"],attributes:!0}),p()}):n.style.zIndex=""},h=new V(r,new cn(n,{onDragEnd:c=>{i.dropTarget.dnd.onDragEnd(c)},onDragEnter:c=>{i.dropTarget.dnd.onDragEnter(c)},onDragLeave:c=>{i.dropTarget.dnd.onDragLeave(c)},onDrop:c=>{i.dropTarget.dnd.onDrop(c)},onDragOver:c=>{i.dropTarget.dnd.onDragOver(c)}}),t.api.onDidVisibilityChange(()=>{a()}),t.api.onDidDimensionsChange(()=>{t.api.isVisible&&l()}),t.api.onDidLocationChange(()=>{d()}));return this.map[t.api.id].destroy=re.from(()=>{var c;s.parentElement===n&&n.removeChild(s),(c=n.parentElement)===null||c===void 0||c.removeChild(n)}),d(),queueMicrotask(()=>{this.isDisposed||a()}),this.map[t.api.id].disposable.dispose(),this.map[t.api.id].disposable=h,this.map[t.api.id].resize=l,n}}function _o(o,e,t,i){function n(s){return s instanceof t?s:new t(function(l){l(s)})}return new(t||(t=Promise))(function(s,l){function a(h){try{d(i.next(h))}catch(c){l(c)}}function r(h){try{d(i.throw(h))}catch(c){l(c)}}function d(h){h.done?s(h.value):n(h.value).then(a,r)}d((i=i.apply(o,[])).next())})}function bo(o){let e;try{e=new URL(o,window.location.href)}catch{throw new Error(`dockview: invalid popout URL: ${o}`)}if(!(e.protocol==="http:"||e.protocol==="https:")||e.origin!==window.location.origin)throw new Error(`dockview: popout URL must be same-origin http(s); got: ${o}`)}class wo extends V{get window(){var e,t;return(t=(e=this._window)===null||e===void 0?void 0:e.value)!==null&&t!==void 0?t:null}constructor(e,t,i){super(),this.target=e,this.className=t,this.options=i,this._onWillClose=new _,this.onWillClose=this._onWillClose.event,this._onDidClose=new _,this.onDidClose=this._onDidClose.event,this._window=null,this.addDisposables(this._onWillClose,this._onDidClose,{dispose:()=>{this.close()}})}dimensions(){if(!this._window)return null;const e=this._window.value.screenX,t=this._window.value.screenY,i=this._window.value.innerWidth,n=this._window.value.innerHeight;return{top:t,left:e,width:i,height:n}}close(){var e,t;this._window&&(this._onWillClose.fire(),(t=(e=this.options).onWillClose)===null||t===void 0||t.call(e,{id:this.target,window:this._window.value}),this._window.disposable.dispose(),this._window=null,this._onDidClose.fire())}open(){return _o(this,void 0,void 0,function*(){var e,t;if(this._window)throw new Error("instance of popout window is already open");const i=`${this.options.url}`;bo(i);const n=Object.entries({top:this.options.top,left:this.options.left,width:this.options.width,height:this.options.height}).map(([r,d])=>`${r}=${d}`).join(","),s=window.open(i,this.target,n);if(!s)return null;const l=new V;this._window={value:s,disposable:l},l.addDisposables(re.from(()=>{s.close()}),R(window,"beforeunload",()=>{this.close()}));const a=this.createPopoutWindowContainer();return this.className&&a.classList.add(this.className),(t=(e=this.options).onDidOpen)===null||t===void 0||t.call(e,{id:this.target,window:s}),new Promise((r,d)=>{s.addEventListener("unload",h=>{}),s.addEventListener("load",()=>{try{const h=s.document;h.title=document.title,h.body.appendChild(a),ls(h,window.document.styleSheets),R(s,"beforeunload",()=>{this.close()}),r(a)}catch(h){d(h)}})})})}createPopoutWindowContainer(){const e=document.createElement("div");return e.classList.add("dv-popout-window"),e.id="dv-popout-window",e.style.position="absolute",e.style.width="100%",e.style.height="100%",e.style.top="0px",e.style.left="0px",e}}class Co extends V{constructor(e){super(),this.accessor=e,this.init()}init(){const e=new Set,t=new Set;this.addDisposables(this.accessor.onDidAddPanel(i=>{if(e.has(i.api.id))throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${i.api.id} but panel already exists`);e.add(i.api.id)}),this.accessor.onDidRemovePanel(i=>{if(e.has(i.api.id))e.delete(i.api.id);else throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${i.api.id} but panel does not exists`)}),this.accessor.onDidAddGroup(i=>{if(t.has(i.api.id))throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${i.api.id} but group already exists`);t.add(i.api.id)}),this.accessor.onDidRemoveGroup(i=>{if(t.has(i.api.id))t.delete(i.api.id);else throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${i.api.id} but group does not exists`)}))}}class zi extends V{constructor(e,t=window){super(),this._active=null,this._activeDisposable=new he,this._root=e,this._window=t,this._element=t.document.createElement("div"),this._element.className="dv-popover-anchor",this._element.style.position="relative",this._root.prepend(this._element),this.addDisposables(re.from(()=>{this.close()}),this._activeDisposable)}updateRoot(e){e.prepend(this._element),this._root=e}openPopover(e,t){var i;this.close();const n=this._window.document.createElement("div");n.style.position="absolute",n.style.zIndex=(i=t.zIndex)!==null&&i!==void 0?i:"var(--dv-overlay-z-index)",n.appendChild(e);const s=this._element.getBoundingClientRect(),l=s.left,a=s.top;n.style.top=`${t.y-a}px`,n.style.left=`${t.x-l}px`,this._element.appendChild(n),this._active=n,this._activeDisposable.value=new V(R(this._window,"pointerdown",r=>{var d;const h=r.target;if(!(h instanceof HTMLElement))return;let c=h;for(;c&&c!==n;)c=(d=c==null?void 0:c.parentElement)!==null&&d!==void 0?d:null;c||this.close()}),R(this._window,"keydown",r=>{(r.key==="Escape"||r.key==="Enter")&&this.close()}),R(this._window,"resize",()=>{this.close()})),this._window.requestAnimationFrame(()=>{fs(n,this._root)})}close(){this._active&&(this._active.remove(),this._activeDisposable.dispose(),this._active=null)}}function ki(o){if(!(o instanceof HTMLElement))return;const e=on(o);return e!=null&&e.style.zIndex?`calc(${e.style.zIndex} * 2)`:void 0}let Do=0;const yo=()=>`dv-ctx-menu-item-${Do++}`;function dt(o){return typeof o=="object"}function ht(o,e,t,i){const n=document.createElement("div");return n.className="dv-context-menu-item",n.setAttribute("role","menuitem"),i&&(n.classList.add("dv-context-menu-item--disabled"),n.setAttribute("aria-disabled","true")),n.textContent=o,i||n.addEventListener("click",()=>{t(),e()}),n}function Oi(){const o=document.createElement("div");return o.className="dv-context-menu-separator",o.setAttribute("role","separator"),o}function xo(o){const e=document.createElement("div");e.className="dv-context-menu-rename";const t=document.createElement("input");return t.className="dv-context-menu-rename-input",t.type="text",t.placeholder="Name This Group",t.value=o.label,t.addEventListener("input",()=>{o.setLabel(t.value)}),t.addEventListener("keydown",i=>{i.key!=="Escape"&&i.key!=="Enter"&&i.stopPropagation()}),t.addEventListener("click",i=>{i.stopPropagation()}),e.appendChild(t),requestAnimationFrame(()=>{t.focus(),t.select()}),e}function So(o,e){const t=document.createElement("div");if(t.className="dv-context-menu-color-picker",!e.enabled)return t;for(const i of e.entries()){const n=document.createElement("div");n.className="dv-context-menu-color-swatch",n.style.setProperty("--dv-tab-group-color",i.value),i.label&&(n.title=i.label),o.color===i.id&&n.classList.add("dv-context-menu-color-swatch--selected"),n.addEventListener("click",()=>{o.setColor(i.id)}),t.appendChild(n)}return t}class Po{constructor(e){this.accessor=e}show(e,t,i){var n,s;if(!this.accessor.options.getTabContextMenuItems)return;const l=this.accessor.options.getTabContextMenuItems({panel:e,group:t,api:this.accessor.api,event:i});if(l.length===0)return;i.preventDefault();const a=this.accessor.getPopupServiceForGroup(t),r=()=>a.close(),d=document.createElement("div");d.className="dv-context-menu",d.setAttribute("role","menu");for(const h of l)if(h==="separator")d.appendChild(Oi());else if(h==="close")d.appendChild(ht("Close",r,()=>e.api.close()));else if(h==="closeOthers")d.appendChild(ht("Close Others",r,()=>{t.panels.filter(c=>c!==e).forEach(c=>c.api.close())}));else if(h==="closeAll")d.appendChild(ht("Close All",r,()=>{[...t.panels].forEach(c=>c.api.close())}));else if(dt(h)&&h.element)d.appendChild(h.element);else if(dt(h)&&h.component){const c=(s=(n=this.accessor.options).createContextMenuItemComponent)===null||s===void 0?void 0:s.call(n,{id:yo(),component:h.component});c&&(c.init({panel:e,group:t,api:this.accessor.api,close:r,componentProps:h.componentProps}),d.appendChild(c.element))}else dt(h)&&h.label&&d.appendChild(ht(h.label,r,()=>{var c;return(c=h.action)===null||c===void 0?void 0:c.call(h)},h.disabled));a.openPopover(d,{x:i.clientX,y:i.clientY,zIndex:ki(i.target)})}showForChip(e,t,i){if(!this.accessor.options.getTabGroupChipContextMenuItems)return;const n=this.accessor.options.getTabGroupChipContextMenuItems({tabGroup:e,group:t,api:this.accessor.api,event:i});if(n.length===0)return;i.preventDefault();const s=this.accessor.getPopupServiceForGroup(t),l=()=>s.close(),a=document.createElement("div");a.className="dv-context-menu",a.setAttribute("role","menu");for(const r of n)r==="separator"?a.appendChild(Oi()):r==="rename"?a.appendChild(xo(e)):r==="colorPicker"?a.appendChild(So(e,this.accessor.tabGroupColorPalette)):dt(r)&&r.element?a.appendChild(r.element):dt(r)&&r.label&&a.appendChild(ht(r.label,l,()=>{var d;return(d=r.action)===null||d===void 0?void 0:d.call(r)},r.disabled));s.openPopover(a,{x:i.clientX,y:i.clientY,zIndex:ki(i.target)})}}class Ri extends V{get disabled(){return this._disabled}set disabled(e){var t;this.disabled!==e&&(this._disabled=e,e&&((t=this.model)===null||t===void 0||t.clear()))}get model(){if(!this.disabled)return{clear:()=>{var e;this._model&&((e=this._model.root.parentElement)===null||e===void 0||e.removeChild(this._model.root)),this._model=void 0},exists:()=>!!this._model,getElements:(e,t)=>{const i=this._outline!==t;if(this._outline=t,this._model)return this._model.changed=i,this._model;const n=this.createContainer(),s=this.createAnchor();if(this._model={root:n,overlay:s,changed:i},n.appendChild(s),this.element.appendChild(n),(e==null?void 0:e.target)instanceof HTMLElement){const l=e.target.getBoundingClientRect(),a=this.element.getBoundingClientRect();s.style.left=`${l.left-a.left}px`,s.style.top=`${l.top-a.top}px`}return this._model}}}constructor(e,t){super(),this.element=e,this._disabled=!1,this._disabled=t.disabled,this.addDisposables(re.from(()=>{var i;(i=this.model)===null||i===void 0||i.clear()}))}createContainer(){const e=document.createElement("div");return e.className="dv-drop-target-container",e}createAnchor(){const e=document.createElement("div");return e.className="dv-drop-target-anchor",e.style.visibility="hidden",e}}class Go{get minimumSize(){return this._isCollapsed?this._collapsedSize:this._expandedMinimumSize}get maximumSize(){return this._isCollapsed?this._collapsedSize:this._expandedMaximumSize}get element(){return this._group.element}get isCollapsed(){return this._isCollapsed}get lastExpandedSize(){return this._lastExpandedSize}get collapsedSize(){return this._collapsedSize}constructor(e,t,i){var n,s,l;this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this.snap=!1,this.priority=oe.Low,this._isCollapsed=!1,this._group=t,this._orientation=i,t.element.classList.add("dv-edge-group"),t.element.dataset.testid=`dv-edge-group-${e.id}`,this._collapsedSize=(n=e.collapsedSize)!==null&&n!==void 0?n:35,this._expandedMaximumSize=(s=e.maximumSize)!==null&&s!==void 0?s:Number.POSITIVE_INFINITY,this._expandedMinimumSize=e.minimumSize!==void 0?e.minimumSize:this._collapsedSize+50,this._lastExpandedSize=(l=e.initialSize)!==null&&l!==void 0?l:200,e.collapsed&&(this._isCollapsed=!0,t.element.classList.add("dv-edge-collapsed"))}layout(e,t){this._isCollapsed||(this._lastExpandedSize=e),this._orientation==="horizontal"?this._group.layout(e,t):this._group.layout(t,e)}setCollapsed(e){this._isCollapsed!==e&&(this._isCollapsed=e,this._group.element.classList.toggle("dv-edge-collapsed",e))}setVisible(e){}restoreExpandedSize(e){this._lastExpandedSize=e}updateCollapsedSize(e,t){this._collapsedSize=e,this._expandedMinimumSize=t}dispose(){this._onDidChange.dispose()}}class Ao{get element(){return this._dockviewElement}constructor(e,t){this._dockviewElement=e,this._layoutDockview=t,this.priority=oe.High,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this._onDidChange=new _,this.onDidChange=this._onDidChange.event}layout(e,t){this._layoutDockview(t,e)}setVisible(e){}dispose(){this._onDidChange.dispose()}}class Io{get element(){return this._element}constructor(e,t=0){this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this.priority=oe.High,this._element=document.createElement("div"),this._element.className="dv-shell-middle-column",this._element.style.height="100%",this._element.style.width="100%",this._splitview=new Ze(this._element,{orientation:k.VERTICAL,proportionalLayout:!1,margin:t}),this._centerIndex=0,this._splitview.addView(e,{type:"distribute"},0)}addTopView(e,t){this._splitview.addView(e,t,0),this._topIndex=0,this._centerIndex+=1,this._bottomIndex!==void 0&&(this._bottomIndex+=1)}addBottomView(e,t){const i=this._splitview.length;this._splitview.addView(e,t,i),this._bottomIndex=i}removeView(e){const t=e==="top"?this._topIndex:this._bottomIndex;t!==void 0&&(this._splitview.removeView(t),e==="top"?(this._topIndex=void 0,this._centerIndex-=1,this._bottomIndex!==void 0&&(this._bottomIndex-=1)):this._bottomIndex=void 0)}layout(e,t){this._splitview.layout(t,e)}setVisible(e){}setViewVisible(e,t){const i=e==="top"?this._topIndex:this._bottomIndex;i!==void 0&&this._splitview.setViewVisible(i,t)}isViewVisible(e){const t=e==="top"?this._topIndex:this._bottomIndex;return t!==void 0?this._splitview.isViewVisible(t):!1}getViewSize(e){const t=e==="top"?this._topIndex:this._bottomIndex;return t!==void 0?this._splitview.getViewSize(t):0}resizeView(e,t){const i=e==="top"?this._topIndex:this._bottomIndex;i!==void 0&&this._splitview.resizeView(i,t)}updateMargin(e){this._splitview.margin=e}dispose(){this._onDidChange.dispose(),this._splitview.dispose()}}function Eo(o,e,t){var i;const n=((i=o.collapsedSize)!==null&&i!==void 0?i:e)+t,s=Object.assign(Object.assign({},o),{collapsedSize:n});return o.minimumSize!==void 0&&(s.minimumSize=o.minimumSize+t),s}class To{constructor(e,t,i,n=0,s=35){this._disposables=new V,this._viewConfigs=new Map,this._currentWidth=0,this._currentHeight=0,this._gap=n,this._defaultCollapsedSize=s,this._shellElement=document.createElement("div"),this._shellElement.className="dv-shell",this._shellElement.style.height="100%",this._shellElement.style.width="100%",this._shellElement.style.position="relative",e.appendChild(this._shellElement);const l=new Ao(t,i);this._middleColumn=new Io(l,n),this._outerSplitview=new Ze(this._shellElement,{orientation:k.HORIZONTAL,proportionalLayout:!1,margin:n}),this._middleIndex=0,this._outerSplitview.addView(this._middleColumn,{type:"distribute"},0),this._disposables.addDisposables(ft(this._shellElement,a=>{const r=Math.round(a.contentRect.width),d=Math.round(a.contentRect.height);r===this._currentWidth&&d===this._currentHeight||(this._currentWidth=r,this._currentHeight=d,this.layout(r,d))}),this._outerSplitview,this._middleColumn,l)}get element(){return this._shellElement}addEdgeView(e,t,i){if(this.hasEdgeGroup(e))throw new Error(`dockview: edge group already registered at position '${e}'`);this._viewConfigs.set(e,t);const n=1+(this._viewConfigs.has("left")?1:0)+(this._viewConfigs.has("right")?1:0),s=1+(this._viewConfigs.has("top")?1:0)+(this._viewConfigs.has("bottom")?1:0),l=n>1?this._gap*(n-1)/n:0,a=s>1?this._gap*(s-1)/s:0,r=e==="left"||e==="right",d=r?l:a,h=r?"horizontal":"vertical",c=new Go(Eo(Object.assign({collapsedSize:this._defaultCollapsedSize},t),this._defaultCollapsedSize,d),i,h),u=c.isCollapsed?c.collapsedSize:c.lastExpandedSize;switch(e){case"left":this._outerSplitview.addView(c,u,0),this._leftIndex=0,this._middleIndex+=1,this._rightIndex!==void 0&&(this._rightIndex+=1),this._leftView=c;break;case"right":{const p=this._outerSplitview.length;this._outerSplitview.addView(c,u,p),this._rightIndex=p,this._rightView=c}break;case"top":this._middleColumn.addTopView(c,u),this._topView=c;break;case"bottom":this._middleColumn.addBottomView(c,u),this._bottomView=c;break}return this._disposables.addDisposables(c),this.updateTheme(this._gap,this._defaultCollapsedSize),c}layout(e,t){this._outerSplitview.layout(e,t)}updateTheme(e,t){var i,n,s,l;this._gap=e,this._defaultCollapsedSize=t;const a=1+(this._viewConfigs.has("left")?1:0)+(this._viewConfigs.has("right")?1:0),r=1+(this._viewConfigs.has("top")?1:0)+(this._viewConfigs.has("bottom")?1:0),d=a>1?e*(a-1)/a:0,h=r>1?e*(r-1)/r:0;this._outerSplitview.margin=e,this._middleColumn.updateMargin(e);const c=(f,v,b)=>{var w;const T=((w=v.collapsedSize)!==null&&w!==void 0?w:t)+b,I=v.minimumSize,G=I!==void 0?I+b:T+50;f.updateCollapsedSize(T,G)},u=this._viewConfigs.get("top");this._topView&&u&&c(this._topView,u,h);const p=this._viewConfigs.get("bottom");this._bottomView&&p&&c(this._bottomView,p,h);const g=this._viewConfigs.get("left");this._leftView&&g&&c(this._leftView,g,d);const m=this._viewConfigs.get("right");this._rightView&&m&&c(this._rightView,m,d),!((i=this._leftView)===null||i===void 0)&&i.isCollapsed&&this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,this._leftView.collapsedSize),!((n=this._rightView)===null||n===void 0)&&n.isCollapsed&&this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,this._rightView.collapsedSize),!((s=this._topView)===null||s===void 0)&&s.isCollapsed&&this._middleColumn.resizeView("top",this._topView.collapsedSize),!((l=this._bottomView)===null||l===void 0)&&l.isCollapsed&&this._middleColumn.resizeView("bottom",this._bottomView.collapsedSize),this._currentWidth>0&&this._currentHeight>0&&this.layout(this._currentWidth,this._currentHeight)}removeEdgeView(e){const t=this._getView(e);if(t){switch(e){case"left":this._outerSplitview.removeView(this._leftIndex),this._leftIndex=void 0,this._leftView=void 0,this._middleIndex-=1,this._rightIndex!==void 0&&(this._rightIndex-=1);break;case"right":this._outerSplitview.removeView(this._rightIndex),this._rightIndex=void 0,this._rightView=void 0;break;case"top":this._middleColumn.removeView("top"),this._topView=void 0;break;case"bottom":this._middleColumn.removeView("bottom"),this._bottomView=void 0;break}this._disposables.removeDisposable(t),t.dispose(),this._viewConfigs.delete(e),this.updateTheme(this._gap,this._defaultCollapsedSize)}}hasEdgeGroup(e){switch(e){case"top":return this._topView!==void 0;case"bottom":return this._bottomView!==void 0;case"left":return this._leftView!==void 0;case"right":return this._rightView!==void 0}}setEdgeGroupVisible(e,t){switch(e){case"left":this._leftIndex!==void 0&&this._outerSplitview.setViewVisible(this._leftIndex,t);break;case"right":this._rightIndex!==void 0&&this._outerSplitview.setViewVisible(this._rightIndex,t);break;case"top":case"bottom":this._middleColumn.setViewVisible(e,t);break}}isEdgeGroupVisible(e){switch(e){case"left":return this._leftIndex!==void 0?this._outerSplitview.isViewVisible(this._leftIndex):!1;case"right":return this._rightIndex!==void 0?this._outerSplitview.isViewVisible(this._rightIndex):!1;case"top":case"bottom":return this._middleColumn.isViewVisible(e)}}setEdgeGroupCollapsed(e,t){const i=this._getView(e);if(!i)return;i.setCollapsed(t);const n=t?i.collapsedSize:i.lastExpandedSize;switch(e){case"left":this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,n);break;case"right":this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,n);break;case"top":case"bottom":this._middleColumn.resizeView(e,n);break}}isEdgeGroupCollapsed(e){var t,i;return(i=(t=this._getView(e))===null||t===void 0?void 0:t.isCollapsed)!==null&&i!==void 0?i:!1}_getView(e){switch(e){case"top":return this._topView;case"bottom":return this._bottomView;case"left":return this._leftView;case"right":return this._rightView}}toJSON(){const e={};return this._leftView&&this._leftIndex!==void 0&&(e.left={size:this._leftView.isCollapsed?this._leftView.lastExpandedSize:this._outerSplitview.getViewSize(this._leftIndex),visible:this._outerSplitview.isViewVisible(this._leftIndex),collapsed:this._leftView.isCollapsed||void 0}),this._rightView&&this._rightIndex!==void 0&&(e.right={size:this._rightView.isCollapsed?this._rightView.lastExpandedSize:this._outerSplitview.getViewSize(this._rightIndex),visible:this._outerSplitview.isViewVisible(this._rightIndex),collapsed:this._rightView.isCollapsed||void 0}),this._topView&&(e.top={size:this._topView.isCollapsed?this._topView.lastExpandedSize:this._middleColumn.getViewSize("top"),visible:this._middleColumn.isViewVisible("top"),collapsed:this._topView.isCollapsed||void 0}),this._bottomView&&(e.bottom={size:this._bottomView.isCollapsed?this._bottomView.lastExpandedSize:this._middleColumn.getViewSize("bottom"),visible:this._middleColumn.isViewVisible("bottom"),collapsed:this._bottomView.isCollapsed||void 0}),e}fromJSON(e){var t,i,n,s,l,a,r,d,h,c,u,p,g,m,f,v,b,w,C,T;e.left&&this._leftIndex!==void 0&&((t=this._leftView)===null||t===void 0||t.restoreExpandedSize(e.left.size),(i=this._leftView)===null||i===void 0||i.setCollapsed((n=e.left.collapsed)!==null&&n!==void 0?n:!1),this._outerSplitview.resizeView(this._leftIndex,e.left.collapsed&&(l=(s=this._leftView)===null||s===void 0?void 0:s.collapsedSize)!==null&&l!==void 0?l:e.left.size),e.left.visible||this._outerSplitview.setViewVisible(this._leftIndex,!1)),e.right&&this._rightIndex!==void 0&&((a=this._rightView)===null||a===void 0||a.restoreExpandedSize(e.right.size),(r=this._rightView)===null||r===void 0||r.setCollapsed((d=e.right.collapsed)!==null&&d!==void 0?d:!1),this._outerSplitview.resizeView(this._rightIndex,e.right.collapsed&&(c=(h=this._rightView)===null||h===void 0?void 0:h.collapsedSize)!==null&&c!==void 0?c:e.right.size),e.right.visible||this._outerSplitview.setViewVisible(this._rightIndex,!1)),e.top&&((u=this._topView)===null||u===void 0||u.restoreExpandedSize(e.top.size),(p=this._topView)===null||p===void 0||p.setCollapsed((g=e.top.collapsed)!==null&&g!==void 0?g:!1),this._middleColumn.resizeView("top",e.top.collapsed&&(f=(m=this._topView)===null||m===void 0?void 0:m.collapsedSize)!==null&&f!==void 0?f:e.top.size),e.top.visible||this._middleColumn.setViewVisible("top",!1)),e.bottom&&((v=this._bottomView)===null||v===void 0||v.restoreExpandedSize(e.bottom.size),(b=this._bottomView)===null||b===void 0||b.setCollapsed((w=e.bottom.collapsed)!==null&&w!==void 0?w:!1),this._middleColumn.resizeView("bottom",e.bottom.collapsed&&(T=(C=this._bottomView)===null||C===void 0?void 0:C.collapsedSize)!==null&&T!==void 0?T:e.bottom.size),e.bottom.visible||this._middleColumn.setViewVisible("bottom",!1))}dispose(){var e;this._disposables.dispose(),(e=this._shellElement.parentElement)===null||e===void 0||e.removeChild(this._shellElement)}}const Mi={activationSize:{type:"pixels",value:10},size:{type:"pixels",value:20}};function zo(o){var e;const t=(e=o.tabGroupColors)!==null&&e!==void 0?e:di,i=o.tabGroupAccent!=="off";return new gn(t,i)}function St(o){const e=o.from.activePanel;[...o.from.panels].map(i=>{const n=o.from.model.removePanel(i);return o.from.model.renderContainer.detatch(i),n}).forEach(i=>{o.to.model.openPanel(i,{skipSetActive:e!==i,skipSetGroupActive:!0})})}class ko extends ln{get orientation(){return this.gridview.orientation}get totalPanels(){return this.panels.length}get panels(){return this.groups.flatMap(e=>e.panels)}get options(){return this._options}get tabGroupColorPalette(){return this._tabGroupColorPalette}get activePanel(){const e=this.activeGroup;if(e)return e.activePanel}get renderer(){var e;return(e=this.options.defaultRenderer)!==null&&e!==void 0?e:"onlyWhenVisible"}get defaultHeaderPosition(){var e;return(e=this.options.defaultHeaderPosition)!==null&&e!==void 0?e:"top"}get api(){return this._api}get floatingGroups(){return this._floatingGroups}get popoutRestorationPromise(){return this._popoutRestorationPromise}constructor(e,t){var i,n,s,l,a,r;super(e,{proportionalLayout:!0,orientation:k.HORIZONTAL,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:t.disableAutoResizing,locked:t.locked,margin:(n=(i=t.theme)===null||i===void 0?void 0:i.gap)!==null&&n!==void 0?n:0,className:t.className}),this.nextGroupId=oi(),this._deserializer=new co(this),this._watermark=null,this._popoutPopupServices=new Map,this._onWillDragPanel=new _,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new _,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new _,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new _,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new _,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onUnhandledDragOverEvent=new _,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this._onDidRemovePanel=new _,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new _,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPopoutGroupSizeChange=new _,this.onDidPopoutGroupSizeChange=this._onDidPopoutGroupSizeChange.event,this._onDidPopoutGroupPositionChange=new _,this.onDidPopoutGroupPositionChange=this._onDidPopoutGroupPositionChange.event,this._onDidOpenPopoutWindowFail=new _,this.onDidOpenPopoutWindowFail=this._onDidOpenPopoutWindowFail.event,this._onDidLayoutFromJSON=new _,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new _({replay:!0}),this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidMovePanel=new _,this.onDidMovePanel=this._onDidMovePanel.event,this._onDidCreateTabGroup=new _,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new _,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new _,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new _,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new _,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new _,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,this._onDidMaximizedGroupChange=new _,this.onDidMaximizedGroupChange=this._onDidMaximizedGroupChange.event,this._inShellLayout=!1,this._edgeGroups=new Map,this._edgeGroupDisposables=new Map,this._floatingGroups=[],this._popoutGroups=[],this._popoutRestorationPromise=Promise.resolve(),this._onDidRemoveGroup=new _,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new _,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidOptionsChange=new _,this.onDidOptionsChange=this._onDidOptionsChange.event,this._onDidActiveGroupChange=new _,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._moving=!1,this._options=t,this._tabGroupColorPalette=zo(t),this.popupService=new zi(this.element),this.contextMenuController=new Po(this),this._api=new Tt(this),this.disableResizing=!0,e.removeChild(this.element),this._shellManager=new To(e,this.element,(d,h)=>this._layoutFromShell(d,h),(l=(s=t.theme)===null||s===void 0?void 0:s.gap)!==null&&l!==void 0?l:0,(a=t.theme)===null||a===void 0?void 0:a.edgeGroupCollapsedSize),this.popupService.updateRoot(this._shellManager.element),this._shellThemeClassnames=new kt(this._shellManager.element),this.rootDropTargetContainer=new Ri(this._shellManager.element,{disabled:!0}),this.overlayRenderContainer=new Ti(this._shellManager.element,this),this._floatingOverlayHost=document.createElement("div"),this._floatingOverlayHost.className="dv-floating-overlay-host",this._shellManager.element.appendChild(this._floatingOverlayHost),this._rootDropTarget=new Te(this.element,{className:"dv-drop-target-edge",canDisplayOverlay:(d,h)=>{const c=ae();if(c)return c.viewId!==this.id?!1:h==="center"?this.gridview.length===0:!0;if(h==="center"&&this.gridview.length!==0)return!1;const u=new Cn(d,"edge",h,ae);return this._onUnhandledDragOverEvent.fire(u),u.isAccepted},acceptedTargetZones:["top","bottom","left","right","center"],overlayModel:(r=t.rootOverlayModel)!==null&&r!==void 0?r:Mi,getOverrideTarget:()=>{var d;return(d=this.rootDropTargetContainer)===null||d===void 0?void 0:d.model}}),this.updateDropTargetModel(t),E(this.gridview.element,"dv-dockview",!0),E(this.element,"dv-debug",!!t.debug),this.updateTheme(),this.updateWatermark(),t.debug&&this.addDisposables(new Co(this)),this.addDisposables(this.rootDropTargetContainer,this.overlayRenderContainer,this._onWillDragPanel,this._onWillDragGroup,this._onWillShowOverlay,this._onDidActivePanelChange,this._onDidAddPanel,this._onDidRemovePanel,this._onDidLayoutFromJSON,this._onDidDrop,this._onWillDrop,this._onDidMovePanel,this._onDidMovePanel.event(()=>{this.debouncedUpdateAllPositions()}),this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this._onUnhandledDragOverEvent,this._onDidMaximizedGroupChange,this._onDidOptionsChange,this._onDidPopoutGroupSizeChange,this._onDidPopoutGroupPositionChange,this._onDidOpenPopoutWindowFail,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.updateWatermark()}),this.onDidAdd(d=>{this._moving||this._onDidAddGroup.fire(d)}),this.onDidRemove(d=>{this._moving||this._onDidRemoveGroup.fire(d)}),this.onDidActiveChange(d=>{this._moving||this._onDidActiveGroupChange.fire(d)}),this.onDidMaximizedChange(d=>{this._onDidMaximizedGroupChange.fire({group:d.panel,isMaximized:d.isMaximized})}),Ye.any(this.onDidAdd,this.onDidRemove)(()=>{this.updateWatermark()}),Ye.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidAddGroup,this.onDidRemove,this.onDidRemoveGroup,this.onDidMovePanel,this.onDidActivePanelChange,this.onDidPopoutGroupPositionChange,this.onDidPopoutGroupSizeChange,this.onDidCreateTabGroup,this.onDidDestroyTabGroup,this.onDidAddPanelToTabGroup,this.onDidRemovePanelFromTabGroup,this.onDidTabGroupChange,this.onDidTabGroupCollapsedChange)(()=>{this._bufferOnDidLayoutChange.fire()}),re.from(()=>{var d;for(const h of[...this._floatingGroups])h.dispose();for(const h of[...this._popoutGroups])h.disposable.dispose();(d=this._shellManager)===null||d===void 0||d.dispose();for(const h of this._edgeGroupDisposables.values())h.dispose();this._edgeGroupDisposables.clear()}),this._rootDropTarget,this._rootDropTarget.onWillShowOverlay(d=>{this.gridview.length>0&&d.position==="center"||this._onWillShowOverlay.fire(new Ot(d,{kind:"edge",panel:void 0,api:this._api,group:void 0,getData:ae}))}),this._rootDropTarget.onDrop(d=>{var h;const c=new Dn({nativeEvent:d.nativeEvent,position:d.position,panel:void 0,api:this._api,group:void 0,getData:ae,kind:"edge"});if(this._onWillDrop.fire(c),c.defaultPrevented)return;const u=ae();u?this.moveGroupOrPanel({from:{groupId:u.groupId,panelId:(h=u.panelId)!==null&&h!==void 0?h:void 0},to:{group:this.orthogonalize(d.position),position:"center"}}):this._onDidDrop.fire(new ui({nativeEvent:d.nativeEvent,position:d.position,panel:void 0,api:this._api,group:void 0,getData:ae}))}),this._rootDropTarget)}setVisible(e,t){switch(e.api.location.type){case"grid":super.setVisible(e,t);break;case"floating":{const i=this.floatingGroups.find(n=>n.group===e);i&&(i.overlay.setVisible(t),e.api._onDidVisibilityChange.fire({isVisible:t}));break}case"popout":console.warn("dockview: You cannot hide a group that is in a popout window");break}}getPopupServiceForGroup(e){var t;return(t=this._popoutPopupServices.get(e.id))!==null&&t!==void 0?t:this.popupService}addPopoutGroup(e,t){var i,n,s,l,a;if(e instanceof Dt&&e.model.location.type==="edge")return Promise.resolve(!1);if(e instanceof ot&&e.group.size===1)return this.addPopoutGroup(e.group,t);const r=us(this.gridview.element),d=this.element;function h(){return t!=null&&t.position?t.position:e instanceof Dt?e.element.getBoundingClientRect():e.group?e.group.element.getBoundingClientRect():d.getBoundingClientRect()}const c=h(),u=(n=(i=t==null?void 0:t.overridePopoutGroup)===null||i===void 0?void 0:i.id)!==null&&n!==void 0?n:this.getNextGroupId(),p=new wo(`${this.id}-${u}`,r??"",{url:(a=(s=t==null?void 0:t.popoutUrl)!==null&&s!==void 0?s:(l=this.options)===null||l===void 0?void 0:l.popoutUrl)!==null&&a!==void 0?a:"/popout.html",left:window.screenX+c.left,top:window.screenY+c.top,width:c.width,height:c.height,onDidOpen:t==null?void 0:t.onDidOpen,onWillClose:t==null?void 0:t.onWillClose}),g=new V(p,p.onDidClose(()=>{g.dispose()}));return p.open().then(m=>{var f;if(p.isDisposed)return!1;const v=t!=null&&t.referenceGroup?t.referenceGroup:e instanceof ot?e.group:e,b=e.api.location.type,w=v.element.parentElement!==null;let C;if(w?t!=null&&t.overridePopoutGroup?C=t.overridePopoutGroup:(C=this.createGroup({id:u}),m&&this._onDidAddGroup.fire(C)):C=v,m===null)return console.error("dockview: failed to create popout. perhaps you need to allow pop-ups for this website"),g.dispose(),this._onDidOpenPopoutWindowFail.fire(),this.movingLock(()=>St({from:C,to:v})),v.api.isVisible||v.api.setVisible(!0),!1;const T=document.createElement("div");T.className="dv-overlay-render-container";const I=new Ti(T,this);C.model.renderContainer=I,C.layout(p.window.innerWidth,p.window.innerHeight);let G;if(!(t!=null&&t.overridePopoutGroup)&&w)if(e instanceof ot)this.movingLock(()=>{const S=v.model.removePanel(e);C.model.openPanel(S)});else switch(this.movingLock(()=>St({from:v,to:C})),b){case"grid":v.api.setVisible(!1);break;case"floating":case"popout":G=(f=this._floatingGroups.find(S=>S.group.api.id===e.api.id))===null||f===void 0?void 0:f.overlay.toJSON(),this.removeGroup(v);break}m.classList.add("dv-dockview"),m.style.overflow="hidden",m.appendChild(T),m.appendChild(C.element);const P=document.createElement("div"),F=new Ri(P,{disabled:this.rootDropTargetContainer.disabled});m.appendChild(P),C.model.dropTargetContainer=F;const K=new zi(m,p.window);this._popoutPopupServices.set(C.id,K),g.addDisposables(K,re.from(()=>{this._popoutPopupServices.delete(C.id)})),C.model.location={type:"popout",getWindow:()=>p.window,popoutUrl:t==null?void 0:t.popoutUrl},w&&e.api.location.type==="grid"&&e.api.setVisible(!1),this.doSetGroupAndPanelActive(C),g.addDisposables(C.api.onDidActiveChange(S=>{var z;S.isActive&&((z=p.window)===null||z===void 0||z.focus())}),C.api.onWillFocus(()=>{var S;(S=p.window)===null||S===void 0||S.focus()}));let L;const j=w&&v&&this.getPanel(v.id),ne={window:p,popoutGroup:C,referenceGroup:j?v.id:void 0,disposable:{dispose:()=>(g.dispose(),L)}},U=ps(p.window);return g.addDisposables(U,ms(p.window,()=>{this._onDidPopoutGroupSizeChange.fire({width:p.window.innerWidth,height:p.window.innerHeight,group:C})}),U.event(()=>{this._onDidPopoutGroupPositionChange.fire({screenX:p.window.screenX,screenY:p.window.screenX,group:C})}),R(p.window,"resize",()=>{C.layout(p.window.innerWidth,p.window.innerHeight)}),I,re.from(()=>{if(!this.isDisposed){if(w&&this.getPanel(v.id))this.movingLock(()=>St({from:C,to:v})),v.api.isVisible||v.api.setVisible(!0),this.getPanel(C.id)&&this.doRemoveGroup(C,{skipPopoutAssociated:!0});else if(this.getPanel(C.id)){if(C.model.renderContainer=this.overlayRenderContainer,C.model.dropTargetContainer=this.rootDropTargetContainer,L=C,!this._popoutGroups.find(z=>z.popoutGroup===C))return;G?this.addFloatingGroup(C,{height:G.height,width:G.width,position:G}):(this.doRemoveGroup(C,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),C.model.location={type:"grid"},this.movingLock(()=>{this.doAddGroup(C,[0])})),this.doSetGroupAndPanelActive(C)}}})),this._popoutGroups.push(ne),this.updateWatermark(),!0}).catch(m=>(console.error("dockview: failed to create popout.",m),!1))}addFloatingGroup(e,t){var i,n,s,l,a,r;if(e instanceof Dt&&e.model.location.type==="edge")return;let d;if(e instanceof ot)d=this.createGroup(),this._onDidAddGroup.fire(d),this.movingLock(()=>this.removePanel(e,{removeEmptyGroup:!0,skipDispose:!0,skipSetActiveGroup:!0})),this.movingLock(()=>d.model.openPanel(e,{skipSetGroupActive:!0}));else{d=e;const f=(i=this._popoutGroups.find(w=>w.popoutGroup===d))===null||i===void 0?void 0:i.referenceGroup,v=f?this.getPanel(f):void 0;typeof(t==null?void 0:t.skipRemoveGroup)=="boolean"&&t.skipRemoveGroup||(v?(this.movingLock(()=>St({from:e,to:v})),this.doRemoveGroup(e,{skipPopoutReturn:!0,skipPopoutAssociated:!0}),this.doRemoveGroup(v,{skipDispose:!0}),d=v):this.doRemoveGroup(e,{skipDispose:!0,skipPopoutReturn:!0,skipPopoutAssociated:!1}))}function h(){if(t!=null&&t.position){const f={};return"left"in t.position?f.left=Math.max(t.position.left,0):"right"in t.position?f.right=Math.max(t.position.right,0):f.left=je.left,"top"in t.position?f.top=Math.max(t.position.top,0):"bottom"in t.position?f.bottom=Math.max(t.position.bottom,0):f.top=je.top,typeof t.width=="number"?f.width=Math.max(t.width,0):f.width=je.width,typeof t.height=="number"?f.height=Math.max(t.height,0):f.height=je.height,f}return{left:typeof(t==null?void 0:t.x)=="number"?Math.max(t.x,0):je.left,top:typeof(t==null?void 0:t.y)=="number"?Math.max(t.y,0):je.top,width:typeof(t==null?void 0:t.width)=="number"?Math.max(t.width,0):je.width,height:typeof(t==null?void 0:t.height)=="number"?Math.max(t.height,0):je.height}}const c=h(),u=new We(Object.assign(Object.assign({container:(n=this._floatingOverlayHost)!==null&&n!==void 0?n:this.gridview.element,content:d.element},c),{minimumInViewportWidth:this.options.floatingGroupBounds==="boundedWithinViewport"?void 0:(l=(s=this.options.floatingGroupBounds)===null||s===void 0?void 0:s.minimumWidthWithinViewport)!==null&&l!==void 0?l:xt,minimumInViewportHeight:this.options.floatingGroupBounds==="boundedWithinViewport"?void 0:(r=(a=this.options.floatingGroupBounds)===null||a===void 0?void 0:a.minimumHeightWithinViewport)!==null&&r!==void 0?r:xt})),p=d.element.querySelector(".dv-void-container");if(!p)throw new Error("dockview: failed to find drag handle");u.setupDrag(p,{inDragMode:typeof(t==null?void 0:t.inDragMode)=="boolean"?t.inDragMode:!1});const g=new mo(d,u),m=new V(d.api.onDidActiveChange(f=>{f.isActive&&u.bringToFront()}),(()=>{let f=-1,v=-1;return ft(d.element,b=>{const w=Math.round(b.contentRect.width),C=Math.round(b.contentRect.height);w===f&&C===v||(f=w,v=C,d.layout(w,C))})})());g.addDisposables(u.onDidChange(()=>{d.layout(d.width,d.height)}),u.onDidChangeEnd(()=>{this._bufferOnDidLayoutChange.fire()}),d.onDidChange(f=>{u.setBounds({height:f==null?void 0:f.height,width:f==null?void 0:f.width})}),{dispose:()=>{m.dispose(),Nt(this._floatingGroups,g),d.model.location={type:"grid"},this.updateWatermark()}}),this._floatingGroups.push(g),d.model.location={type:"floating"},t!=null&&t.skipActiveGroup||this.doSetGroupAndPanelActive(d),this.updateWatermark()}orthogonalize(e,t){switch(this.gridview.normalize(),e){case"top":case"bottom":this.gridview.orientation===k.HORIZONTAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case"left":case"right":this.gridview.orientation===k.VERTICAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break}switch(e){case"top":case"left":case"center":return this.createGroupAtLocation([0],void 0,t);case"bottom":case"right":return this.createGroupAtLocation([this.gridview.length],void 0,t);default:throw new Error(`dockview: unsupported position ${e}`)}}updateOptions(e){var t,i,n;if(super.updateOptions(e),"floatingGroupBounds"in e)for(const a of this._floatingGroups){switch(e.floatingGroupBounds){case"boundedWithinViewport":a.overlay.minimumInViewportHeight=void 0,a.overlay.minimumInViewportWidth=void 0;break;case void 0:a.overlay.minimumInViewportHeight=xt,a.overlay.minimumInViewportWidth=xt;break;default:a.overlay.minimumInViewportHeight=(t=e.floatingGroupBounds)===null||t===void 0?void 0:t.minimumHeightWithinViewport,a.overlay.minimumInViewportWidth=(i=e.floatingGroupBounds)===null||i===void 0?void 0:i.minimumWidthWithinViewport}a.overlay.setBounds()}this.updateDropTargetModel(e);const s=this.options.disableDnd;this._options=Object.assign(Object.assign({},this.options),e);const l=this.options.disableDnd;if(s!==l&&this.updateDragAndDropState(),"theme"in e&&this.updateTheme(),"createRightHeaderActionComponent"in e||"createLeftHeaderActionComponent"in e||"createPrefixHeaderActionComponent"in e)for(const a of this.groups)a.model.updateHeaderActions();if("tabGroupColors"in e||"tabGroupAccent"in e){this._tabGroupColorPalette.setEntries((n=this._options.tabGroupColors)!==null&&n!==void 0?n:di),this._tabGroupColorPalette.enabled=this._options.tabGroupAccent!=="off";for(const a of this.groups)a.model.refreshTabGroupAccent()}this._onDidOptionsChange.fire(),this._layoutFromShell(this.gridview.width,this.gridview.height)}layout(e,t,i){if(this._shellManager&&!this._inShellLayout?this._shellManager.layout(e,t):super.layout(e,t,i),this._syncFloatingOverlayHost(),this._floatingGroups)for(const n of this._floatingGroups)n.overlay.setBounds()}_syncFloatingOverlayHost(){if(!this._floatingOverlayHost||!this._shellManager)return;const e=this._shellManager.element.getBoundingClientRect(),t=this.element.getBoundingClientRect(),i=this._floatingOverlayHost;i.style.left=`${t.left-e.left}px`,i.style.top=`${t.top-e.top}px`,i.style.width=`${t.width}px`,i.style.height=`${t.height}px`}_layoutFromShell(e,t){this._inShellLayout=!0,this.layout(e,t,!0),this._inShellLayout=!1}forceRelayout(){this._shellManager?this._layoutFromShell(this.width,this.height):super.forceRelayout()}addEdgeGroup(e,t){if(this._edgeGroups.has(e))throw new Error(`dockview: edge group already exists at position '${e}'`);const i=this.createGroup({id:t.id});i.model.location={type:"edge",position:e},i.model.headerPosition=e,this._edgeGroups.set(e,i),this._onDidAddGroup.fire(i);const n=i.model.onDidRemovePanel(()=>{i.model.isEmpty&&this.setEdgeGroupCollapsed(i,!0)});return this._edgeGroupDisposables.set(e,n),this._shellManager.addEdgeView(e,t,i),i.api}getEdgeGroup(e){var t;return(t=this._edgeGroups.get(e))===null||t===void 0?void 0:t.api}setEdgeGroupVisible(e,t){this._shellManager.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this._shellManager.isEdgeGroupVisible(e)}removeEdgeGroup(e){var t;const i=this._edgeGroups.get(e);if(!i)throw new Error(`dockview: no edge group exists at position '${e}'`);for(const n of[...i.panels])this.removePanel(n,{removeEmptyGroup:!1,skipDispose:!1});(t=this._edgeGroupDisposables.get(e))===null||t===void 0||t.dispose(),this._edgeGroupDisposables.delete(e),this._shellManager.removeEdgeView(e),this._edgeGroups.delete(e),i.dispose(),this._groups.delete(i.id),this._onDidRemoveGroup.fire(i)}setEdgeGroupCollapsed(e,t){for(const[i,n]of this._edgeGroups)if(n===e){if(this._shellManager.isEdgeGroupCollapsed(i)===t)return;this._shellManager.setEdgeGroupCollapsed(i,t),n.api._onDidCollapsedChange.fire({isCollapsed:t});return}}isEdgeGroupCollapsed(e){for(const[t,i]of this._edgeGroups)if(i===e)return this._shellManager.isEdgeGroupCollapsed(t);return!1}updateDragAndDropState(){for(const e of this.groups)e.model.updateDragAndDropState()}focus(){var e;(e=this.activeGroup)===null||e===void 0||e.focus()}getGroupPanel(e){return this.panels.find(t=>t.id===e)}setActivePanel(e){e.group.model.openPanel(e),this.doSetGroupAndPanelActive(e.group)}moveToNext(e={}){var t;if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[e.group.panels.length-1]){e.group.model.moveToNext({suppressRoll:!0});return}const i=Q(e.group.element),n=(t=this.gridview.next(i))===null||t===void 0?void 0:t.view;this.doSetGroupAndPanelActive(n)}moveToPrevious(e={}){var t;if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[0]){e.group.model.moveToPrevious({suppressRoll:!0});return}const i=Q(e.group.element),n=(t=this.gridview.previous(i))===null||t===void 0?void 0:t.view;n&&this.doSetGroupAndPanelActive(n)}toJSON(){var e;const t=this.gridview.serialize(),i=this.panels.reduce((a,r)=>(a[r.id]=r.toJSON(),a),{}),n=this._floatingGroups.map(a=>({data:a.group.toJSON(),position:a.overlay.toJSON()})),s=this._popoutGroups.map(a=>({data:a.popoutGroup.toJSON(),gridReferenceGroup:a.referenceGroup,position:a.window.dimensions(),url:a.popoutGroup.api.location.type==="popout"?a.popoutGroup.api.location.popoutUrl:void 0})),l={grid:t,panels:i,activeGroup:(e=this.activeGroup)===null||e===void 0?void 0:e.id};if(n.length>0&&(l.floatingGroups=n),s.length>0&&(l.popoutGroups=s),this._edgeGroups.size>0){const a=this._shellManager.toJSON();for(const[r,d]of this._edgeGroups){const h=a[r];h&&(h.group=d.toJSON())}l.edgeGroups=a}return l}fromJSON(e,t){var i,n,s;const l=new Map;let a;if(t!=null&&t.reuseExistingPanels){a=this.createGroup(),this._groups.delete(a.api.id);const c=Object.keys(e.panels);for(const u of this.panels)c.includes(u.api.id)&&l.set(u.api.id,u);this.movingLock(()=>{Array.from(l.values()).forEach(u=>{this.moveGroupOrPanel({from:{groupId:u.api.group.api.id,panelId:u.api.id},to:{group:a,position:"center"},keepEmptyGroups:!0})})})}if(this.clear(),typeof e!="object"||e===null)throw new Error("dockview: serialized layout must be a non-null object");const{grid:r,panels:d,activeGroup:h}=e;if(r.root.type!=="branch"||!Array.isArray(r.root.data))throw new Error("dockview: root must be of type branch");try{const c=this.width,u=this.height,p=v=>{const{id:b,locked:w,hideHeader:C,headerPosition:T,views:I,activeView:G}=v;if(typeof b!="string")throw new Error("dockview: group id must be of type string");const P=this.createGroup({id:b,locked:!!w,hideHeader:!!C,headerPosition:T});this._onDidAddGroup.fire(P);const F=[];for(const K of I){const L=l.get(K);if(a&&L)this.movingLock(()=>{a.model.removePanel(L)}),F.push(L),L.updateFromStateModel(d[K]);else{const j=this._deserializer.fromJSON(d[K],P);F.push(j)}}for(let K=0;K<I.length;K++){const L=F[K],j=typeof G=="string"&&G===L.id;l.has(L.api.id)?this.movingLock(()=>{P.model.openPanel(L,{skipSetActive:!j,skipSetGroupActive:!0})}):P.model.openPanel(L,{skipSetActive:!j,skipSetGroupActive:!0})}return v.tabGroups&&v.tabGroups.length>0&&P.model.restoreTabGroups(v.tabGroups),!P.activePanel&&P.panels.length>0&&P.model.openPanel(P.panels[P.panels.length-1],{skipSetGroupActive:!0}),P};if(this.gridview.deserialize(r,{fromJSON:v=>p(v.data)}),this._layoutFromShell(c,u),e.edgeGroups){for(const v of["top","bottom","left","right"]){const b=e.edgeGroups[v];if(b&&!this._edgeGroups.has(v)){const w=b.group,C=(i=w==null?void 0:w.id)!==null&&i!==void 0?i:`${v}-group`;this.addEdgeGroup(v,{id:C})}}for(const[v,b]of this._edgeGroups){const w=e.edgeGroups[v],C=w==null?void 0:w.group;if(C){const{views:T,activeView:I}=C,G=[];for(const P of T)if(d[P]){const F=this._deserializer.fromJSON(d[P],b);G.push(F)}for(let P=0;P<G.length;P++){const F=G[P],K=I===F.id;b.model.openPanel(F,{skipSetActive:!K,skipSetGroupActive:!0})}C.tabGroups&&C.tabGroups.length>0&&b.model.restoreTabGroups(C.tabGroups),!b.activePanel&&b.panels.length>0&&b.model.openPanel(b.panels[b.panels.length-1],{skipSetGroupActive:!0})}}this._shellManager.fromJSON(e.edgeGroups)}const g=(n=e.floatingGroups)!==null&&n!==void 0?n:[];for(const v of g){const{data:b,position:w}=v,C=p(b);this.addFloatingGroup(C,{position:w,width:w.width,height:w.height,skipRemoveGroup:!0,inDragMode:!1})}const m=(s=e.popoutGroups)!==null&&s!==void 0?s:[],f=[];m.forEach((v,b)=>{const{data:w,position:C,gridReferenceGroup:T,url:I}=v,G=p(w),P=new Promise(F=>{setTimeout(()=>{this.addPopoutGroup(G,{position:C??void 0,overridePopoutGroup:T?G:void 0,referenceGroup:T?this.getPanel(T):void 0,popoutUrl:I}),F()},b*fo)});f.push(P)}),this._popoutRestorationPromise=Promise.all(f).then(()=>{});for(const v of this._floatingGroups)v.overlay.setBounds();if(typeof h=="string"){const v=this.getPanel(h);v&&this.doSetGroupAndPanelActive(v)}}catch(c){console.error("dockview: failed to deserialize layout. Reverting changes",c);for(const u of this.groups)for(const p of u.panels)this.removePanel(p,{removeEmptyGroup:!1,skipDispose:!1});for(const u of this.groups)u.dispose(),this._groups.delete(u.id),this._onDidRemoveGroup.fire(u);for(const u of[...this._floatingGroups])u.dispose();throw this.clear(),c}this.updateWatermark(),this.debouncedUpdateAllPositions(),this._onDidLayoutFromJSON.fire()}clear(){const e=Array.from(this._groups.values()).map(i=>i.value),t=!!this.activeGroup;for(const i of e){if([...this._edgeGroups.values()].includes(i)){const n=[...i.panels];for(const s of n)this.removePanel(s,{removeEmptyGroup:!1});continue}this.removeGroup(i,{skipActive:!0})}t&&this.doSetGroupAndPanelActive(void 0),this.gridview.clear()}closeAllGroups(){for(const e of this._groups.entries()){const[t,i]=e;i.value.model.closeAllPanels()}}addPanel(e){var t,i;if(this.panels.find(r=>r.id===e.id))throw new Error(`dockview: panel with id ${e.id} already exists`);let n;if(e.position&&e.floating)throw new Error("dockview: you can only provide one of: position, floating as arguments to .addPanel(...)");const s={width:e.initialWidth,height:e.initialHeight};let l;if(e.position)if(Qs(e.position)){const r=typeof e.position.referencePanel=="string"?this.getGroupPanel(e.position.referencePanel):e.position.referencePanel;if(l=e.position.index,!r)throw new Error(`dockview: referencePanel '${e.position.referencePanel}' does not exist`);n=this.findGroup(r)}else if(eo(e.position)){if(n=typeof e.position.referenceGroup=="string"?(t=this._groups.get(e.position.referenceGroup))===null||t===void 0?void 0:t.value:e.position.referenceGroup,l=e.position.index,!n)throw new Error(`dockview: referenceGroup '${e.position.referenceGroup}' does not exist`)}else{const r=this.orthogonalize(Ai(e.position.direction)),d=this.createPanel(e,r);return r.model.openPanel(d,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:l}),e.inactive||this.doSetGroupAndPanelActive(r),r.api.setSize({height:s==null?void 0:s.height,width:s==null?void 0:s.width}),d}else n=this.activeGroup;let a;if(n){const r=Et(((i=e.position)===null||i===void 0?void 0:i.direction)||"within");if(e.floating){const d=this.createGroup();this._onDidAddGroup.fire(d);const h=typeof e.floating=="object"&&e.floating!==null?e.floating:{};this.addFloatingGroup(d,Object.assign(Object.assign({},h),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),a=this.createPanel(e,d),d.model.openPanel(a,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:l})}else if(n.api.location.type==="floating"||n.api.location.type==="edge"||r==="center")a=this.createPanel(e,n),n.model.openPanel(a,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:l}),n.api.setSize({width:s==null?void 0:s.width,height:s==null?void 0:s.height}),e.inactive||this.doSetGroupAndPanelActive(n);else{const d=Q(n.element),h=Ee(this.gridview.orientation,d,r),c=this.createGroupAtLocation(h,this.orientationAtLocation(h)===k.VERTICAL?s==null?void 0:s.height:s==null?void 0:s.width);a=this.createPanel(e,c),c.model.openPanel(a,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:l}),e.inactive||this.doSetGroupAndPanelActive(c)}}else if(e.floating){const r=this.createGroup();this._onDidAddGroup.fire(r);const d=typeof e.floating=="object"&&e.floating!==null?e.floating:{};this.addFloatingGroup(r,Object.assign(Object.assign({},d),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),a=this.createPanel(e,r),r.model.openPanel(a,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:l})}else{const r=this.createGroupAtLocation([0],this.gridview.orientation===k.VERTICAL?s==null?void 0:s.height:s==null?void 0:s.width);a=this.createPanel(e,r),r.model.openPanel(a,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:l}),e.inactive||this.doSetGroupAndPanelActive(r)}return a}removePanel(e,t={removeEmptyGroup:!0}){const i=e.group;if(!i)throw new Error(`dockview: cannot remove panel ${e.id}. it's missing a group.`);i.model.removePanel(e,{skipSetActiveGroup:t.skipSetActiveGroup}),t.skipDispose||(e.group.model.renderContainer.detatch(e),e.dispose()),i.size===0&&t.removeEmptyGroup&&this.removeGroup(i,{skipActive:t.skipSetActiveGroup})}createWatermarkComponent(){return this.options.createWatermarkComponent?this.options.createWatermarkComponent():new uo}updateWatermark(){var e,t;if(this.groups.filter(i=>i.api.location.type==="grid"&&i.api.isVisible).length===0){if(!this._watermark){this._watermark=this.createWatermarkComponent(),this._watermark.init({containerApi:new Tt(this)});const i=document.createElement("div");i.className="dv-watermark-container",hs(i,"watermark-component"),i.appendChild(this._watermark.element),this.gridview.element.appendChild(i)}}else this._watermark&&(this._watermark.element.parentElement.remove(),(t=(e=this._watermark).dispose)===null||t===void 0||t.call(e),this._watermark=null)}addGroup(e){var t;if(e){let i;if(to(e)){const d=typeof e.referencePanel=="string"?this.panels.find(h=>h.id===e.referencePanel):e.referencePanel;if(!d)throw new Error(`dockview: reference panel ${e.referencePanel} does not exist`);if(i=this.findGroup(d),!i)throw new Error(`dockview: reference group for reference panel ${e.referencePanel} does not exist`)}else if(io(e)){if(i=typeof e.referenceGroup=="string"?(t=this._groups.get(e.referenceGroup))===null||t===void 0?void 0:t.value:e.referenceGroup,!i)throw new Error(`dockview: reference group ${e.referenceGroup} does not exist`)}else{const d=this.orthogonalize(Ai(e.direction),e);return e.skipSetActive||this.doSetGroupAndPanelActive(d),d}const n=Et(e.direction||"within"),s=Q(i.element),l=Ee(this.gridview.orientation,s,n),a=this.createGroup(e),r=this.getLocationOrientation(l)===k.VERTICAL?e.initialHeight:e.initialWidth;return this.doAddGroup(a,l,r),e.skipSetActive||this.doSetGroupAndPanelActive(a),a}else{const i=this.createGroup(e);return this.doAddGroup(i),this.doSetGroupAndPanelActive(i),i}}getLocationOrientation(e){return e.length%2==0&&this.gridview.orientation===k.HORIZONTAL?k.HORIZONTAL:k.VERTICAL}removeGroup(e,t){this.doRemoveGroup(e,t)}doRemoveGroup(e,t){var i;if([...this._edgeGroups.values()].includes(e))return e;const n=[...e.panels];if(!(t!=null&&t.skipDispose))for(const a of n)this.removePanel(a,{removeEmptyGroup:!1,skipDispose:(i=t==null?void 0:t.skipDispose)!==null&&i!==void 0?i:!1});const s=this.activePanel;if(e.api.location.type==="floating"){const a=this._floatingGroups.find(r=>r.group===e);if(a){if(t!=null&&t.skipDispose||(a.group.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)),Nt(this._floatingGroups,a),a.dispose(),!(t!=null&&t.skipActive)&&this._activeGroup===e){const r=Array.from(this._groups.values());this.doSetGroupAndPanelActive(r.length>0?r[0].value:void 0)}return a.group}throw new Error("dockview: failed to find floating group")}if(e.api.location.type==="popout"){const a=this._popoutGroups.find(r=>r.popoutGroup===e);if(a){if(!(t!=null&&t.skipDispose)){if(!(t!=null&&t.skipPopoutAssociated)){const d=a.referenceGroup?this.getPanel(a.referenceGroup):void 0;d&&d.panels.length===0&&this.removeGroup(d)}a.popoutGroup.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}Nt(this._popoutGroups,a);const r=a.disposable.dispose();if(!(t!=null&&t.skipPopoutReturn)&&r&&(this.doAddGroup(r,[0]),this.doSetGroupAndPanelActive(r)),!(t!=null&&t.skipActive)&&this._activeGroup===e){const d=Array.from(this._groups.values());this.doSetGroupAndPanelActive(d.length>0?d[0].value:void 0)}return this.updateWatermark(),a.popoutGroup}throw new Error("dockview: failed to find popout group")}const l=super.doRemoveGroup(e,t);return t!=null&&t.skipActive||this.activePanel!==s&&this._onDidActivePanelChange.fire(this.activePanel),l}debouncedUpdateAllPositions(){this._updatePositionsFrameId!==void 0&&cancelAnimationFrame(this._updatePositionsFrameId),this._updatePositionsFrameId=requestAnimationFrame(()=>{this._updatePositionsFrameId=void 0,this.overlayRenderContainer.updateAllPositions()})}movingLock(e){const t=this._moving;try{return this._moving=!0,e()}finally{this._moving=t}}moveGroupOrPanel(e){var t;const i=e.to.group,n=e.from.groupId,s=e.from.panelId,l=e.to.position,a=e.to.index,r=n?(t=this._groups.get(n))===null||t===void 0?void 0:t.value:void 0;if(!r)throw new Error(`dockview: Failed to find group id ${n}`);if(s===void 0){e.from.tabGroupId?this.moveTabGroupToGroup({sourceGroup:r,tabGroupId:e.from.tabGroupId,destinationGroup:i,destinationTarget:l,destinationIndex:a,skipSetActive:e.skipSetActive,keepEmptyGroups:e.keepEmptyGroups}):this.moveGroup({from:{group:r},to:{group:i,position:l},skipSetActive:e.skipSetActive});return}if(!l||l==="center"){const d=this.movingLock(()=>r.model.removePanel(s,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!d)throw new Error(`dockview: No panel with id ${s}`);!e.keepEmptyGroups&&r.model.size===0&&this.doRemoveGroup(r,{skipActive:!0});const h=i.model.size===0;this.movingLock(()=>{var c;return i.model.openPanel(d,{index:a,skipSetActive:((c=e.skipSetActive)!==null&&c!==void 0?c:!1)&&!h,skipSetGroupActive:!0})}),e.skipSetActive||this.doSetGroupAndPanelActive(i),this._onDidMovePanel.fire({panel:d,from:r})}else{const d=Q(i.element),h=Ee(this.gridview.orientation,d,l);if(r.size<2){const[c,u]=Fe(h);if(r.api.location.type==="grid"){const f=Q(r.element),[v,b]=Fe(f);if(rn(v,c)){this.gridview.moveView(v,b,u),this._onDidMovePanel.fire({panel:this.getGroupPanel(s),from:r});return}}if(r.api.location.type==="popout"){const f=this._popoutGroups.find(w=>w.popoutGroup===r),v=this.movingLock(()=>f.popoutGroup.model.removePanel(f.popoutGroup.panels[0],{skipSetActive:!0,skipSetActiveGroup:!0}));this.doRemoveGroup(r,{skipActive:!0});const b=this.createGroupAtLocation(h);this.movingLock(()=>b.model.openPanel(v,{skipSetActive:!0})),this.doSetGroupAndPanelActive(b),this._onDidMovePanel.fire({panel:this.getGroupPanel(s),from:r});return}if(r.api.location.type==="edge"){const f=this.movingLock(()=>r.model.removePanel(s,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!f)throw new Error(`dockview: No panel with id ${s}`);const v=this.createGroupAtLocation(h);this.movingLock(()=>v.model.openPanel(f,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(v),this._onDidMovePanel.fire({panel:f,from:r});return}const p=this.movingLock(()=>this.doRemoveGroup(r,{skipActive:!0,skipDispose:!0})),g=Q(i.element),m=Ee(this.gridview.orientation,g,l);this.movingLock(()=>this.doAddGroup(p,m)),this.doSetGroupAndPanelActive(p),this._onDidMovePanel.fire({panel:this.getGroupPanel(s),from:r})}else{const c=this.movingLock(()=>r.model.removePanel(s,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!c)throw new Error(`dockview: No panel with id ${s}`);const u=Ee(this.gridview.orientation,d,l),p=this.createGroupAtLocation(u);this.movingLock(()=>p.model.openPanel(c,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(p),this._onDidMovePanel.fire({panel:c,from:r})}}}moveTabGroupToGroup(e){const{sourceGroup:t,tabGroupId:i,destinationGroup:n,destinationTarget:s,destinationIndex:l}=e,a=t.model.getTabGroups().find(v=>v.id===i);if(!a||a.panelIds.length===0)return;const r=a.label,d=a.color,h=a.collapsed,c=a.componentParams,u=[...a.panelIds],p=s&&s!=="center"?Q(n.element):void 0,g=this.movingLock(()=>u.map(v=>t.model.removePanel(v,{skipSetActive:!1,skipSetActiveGroup:!0})).filter(v=>v!==void 0));if(g.length===0)return;const m=v=>{this.movingLock(()=>{for(const w of g)v.model.openPanel(w,{index:l,skipSetActive:!0,skipSetGroupActive:!0})});const b=v.model.createTabGroup({label:r,color:d,collapsed:h,componentParams:c});for(const w of g)v.model.addPanelToTabGroup(b.id,w.id);e.skipSetActive||this.doSetGroupAndPanelActive(v);for(const w of g)this._onDidMovePanel.fire({panel:w,from:t})};let f;if(!s||s==="center"||!p)f=n;else{const v=Ee(this.gridview.orientation,p,s);f=this.createGroupAtLocation(v)}!e.keepEmptyGroups&&t.model.size===0&&t!==f&&this.doRemoveGroup(t,{skipActive:!0}),m(f)}moveGroup(e){const t=e.from.group,i=e.to.group,n=e.to.position;let s=t;if(n==="center"){const l=t.activePanel,a=t.model.getTabGroups().map(d=>({label:d.label,color:d.color,collapsed:d.collapsed,componentParams:d.componentParams,panelIds:[...d.panelIds]})),r=this.movingLock(()=>[...t.panels].map(d=>t.model.removePanel(d.id,{skipSetActive:!0})));(t==null?void 0:t.model.size)===0&&this.doRemoveGroup(t,{skipActive:!0}),this.movingLock(()=>{for(const d of r)i.model.openPanel(d,{skipSetActive:d!==l,skipSetGroupActive:!0})});for(const d of a){const h=i.model.createTabGroup({label:d.label,color:d.color,collapsed:d.collapsed,componentParams:d.componentParams});for(const c of d.panelIds)i.model.addPanelToTabGroup(h.id,c)}e.skipSetActive!==!0?this.doSetGroupAndPanelActive(i):this.activePanel||this.doSetGroupAndPanelActive(i)}else{if(t.api.location.type==="edge"){const l=t.activePanel,a=t.model.getTabGroups().map(d=>({label:d.label,color:d.color,collapsed:d.collapsed,componentParams:d.componentParams,panelIds:[...d.panelIds]})),r=this.movingLock(()=>[...t.panels].map(d=>t.model.removePanel(d.id,{skipSetActive:!0})));s=this.createGroup(),this.movingLock(()=>{for(const d of r)s.model.openPanel(d,{skipSetActive:d!==l,skipSetGroupActive:!0})});for(const d of a){const h=s.model.createTabGroup({label:d.label,color:d.color,collapsed:d.collapsed,componentParams:d.componentParams});for(const c of d.panelIds)s.model.addPanelToTabGroup(h.id,c)}}else switch(t.api.location.type){case"grid":this.gridview.removeView(Q(t.element));break;case"floating":{const l=this._floatingGroups.find(a=>a.group===t);if(!l)throw new Error("dockview: failed to find floating group");l.dispose();break}case"popout":{const l=this._popoutGroups.find(r=>r.popoutGroup===t);if(!l)throw new Error("dockview: failed to find popout group");const a=this._popoutGroups.indexOf(l);if(a>=0&&this._popoutGroups.splice(a,1),l.referenceGroup){const r=this.getPanel(l.referenceGroup);r&&!r.api.isVisible&&this.doRemoveGroup(r,{skipActive:!0})}l.window.dispose(),i.api.location.type==="grid"?(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,t.model.location={type:"grid"}):i.api.location.type==="floating"&&(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,t.model.location={type:"floating"});break}}if(i.api.location.type==="grid"){const l=Q(i.element),a=Ee(this.gridview.orientation,l,n);let r;switch(this.gridview.orientation){case k.VERTICAL:r=l.length%2==0?t.api.width:t.api.height;break;case k.HORIZONTAL:r=l.length%2==0?t.api.height:t.api.width;break}this.gridview.addView(s,r,a)}else if(i.api.location.type==="floating"){const l=this._floatingGroups.find(a=>a.group===i);if(l){const a=l.overlay.toJSON();let r,d;"left"in a?r=a.left+50:"right"in a?r=Math.max(0,a.right-a.width-50):r=50,"top"in a?d=a.top+50:"bottom"in a?d=Math.max(0,a.bottom-a.height-50):d=50,this.addFloatingGroup(s,{height:a.height,width:a.width,position:{left:r,top:d}})}}}if(s.panels.forEach(l=>{this._onDidMovePanel.fire({panel:l,from:t})}),this.debouncedUpdateAllPositions(),e.skipSetActive===!1){const l=i??t;this.doSetGroupAndPanelActive(l)}else s!==t&&e.skipSetActive!==!0&&this.doSetGroupAndPanelActive(s)}doSetGroupActive(e){super.doSetGroupActive(e);const t=this.activePanel;!this._moving&&t!==this._onDidActivePanelChange.value&&this._onDidActivePanelChange.fire(t)}doSetGroupAndPanelActive(e){super.doSetGroupActive(e);const t=this.activePanel;e&&this.hasMaximizedGroup()&&!this.isMaximizedGroup(e)&&this.exitMaximizedGroup(),!this._moving&&t!==this._onDidActivePanelChange.value&&this._onDidActivePanelChange.fire(t)}getNextGroupId(){let e=this.nextGroupId.next();for(;this._groups.has(e);)e=this.nextGroupId.next();return e}createGroup(e){e||(e={});let t=e==null?void 0:e.id;if(t&&this._groups.has(e.id)&&(console.warn(`dockview: Duplicate group id ${e==null?void 0:e.id}. reassigning group id to avoid errors`),t=void 0),!t)for(t=this.nextGroupId.next();this._groups.has(t);)t=this.nextGroupId.next();const i=new Dt(this,t,e);if(i.init({params:{},accessor:this}),!this._groups.has(i.id)){const n=new V(i.model.onTabDragStart(s=>{this._onWillDragPanel.fire(s)}),i.model.onGroupDragStart(s=>{this._onWillDragGroup.fire(s)}),i.model.onMove(s=>{const{groupId:l,itemId:a,target:r,index:d,tabGroupId:h}=s;this.moveGroupOrPanel({from:{groupId:l,panelId:a,tabGroupId:h},to:{group:i,position:r,index:d}})}),i.model.onDidDrop(s=>{this._onDidDrop.fire(s)}),i.model.onWillDrop(s=>{this._onWillDrop.fire(s)}),i.model.onWillShowOverlay(s=>{if(this.options.disableDnd){s.preventDefault();return}this._onWillShowOverlay.fire(s)}),i.model.onUnhandledDragOverEvent(s=>{this._onUnhandledDragOverEvent.fire(s)}),i.model.onDidAddPanel(s=>{this._moving||this._onDidAddPanel.fire(s.panel)}),i.model.onDidRemovePanel(s=>{this._moving||this._onDidRemovePanel.fire(s.panel)}),i.model.onDidActivePanelChange(s=>{this._moving||s.panel===this.activePanel&&this._onDidActivePanelChange.value!==s.panel&&this._onDidActivePanelChange.fire(s.panel)}),i.model.onDidCreateTabGroup(s=>{this._onDidCreateTabGroup.fire(s)}),i.model.onDidDestroyTabGroup(s=>{this._onDidDestroyTabGroup.fire(s)}),i.model.onDidAddPanelToTabGroup(s=>{this._onDidAddPanelToTabGroup.fire(s)}),i.model.onDidRemovePanelFromTabGroup(s=>{this._onDidRemovePanelFromTabGroup.fire(s)}),i.model.onDidTabGroupChange(s=>{this._onDidTabGroupChange.fire(s)}),i.model.onDidTabGroupCollapsedChange(s=>{this._onDidTabGroupCollapsedChange.fire(s)}),Ye.any(i.model.onDidPanelTitleChange,i.model.onDidPanelParametersChange)(()=>{this._bufferOnDidLayoutChange.fire()}));this._groups.set(i.id,{value:i,disposable:n})}return i.initialize(),i}createPanel(e,t){var i,n,s;const l=e.component,a=(i=e.tabComponent)!==null&&i!==void 0?i:this.options.defaultTabComponent,r=new xn(this,e.id,l,a),d=new ot(e.id,l,a,this,this._api,t,r,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return d.init({title:(n=e.title)!==null&&n!==void 0?n:e.id,params:(s=e==null?void 0:e.params)!==null&&s!==void 0?s:{}}),d}createGroupAtLocation(e,t,i){const n=this.createGroup(i);return this.doAddGroup(n,e,t),n}findGroup(e){var t;return(t=Array.from(this._groups.values()).find(i=>i.value.model.containsPanel(e)))===null||t===void 0?void 0:t.value}orientationAtLocation(e){const t=this.gridview.orientation;return e.length%2==1?t:He(t)}updateDropTargetModel(e){"dndEdges"in e&&(this._rootDropTarget.disabled=typeof e.dndEdges=="boolean"&&e.dndEdges===!1,typeof e.dndEdges=="object"&&e.dndEdges!==null?this._rootDropTarget.setOverlayModel(e.dndEdges):this._rootDropTarget.setOverlayModel(Mi)),"rootOverlayModel"in e&&this.updateDropTargetModel({dndEdges:e.dndEdges})}updateTheme(){var e,t,i,n,s,l,a,r,d;const h=(e=this._options.theme)!==null&&e!==void 0?e:lo;switch((t=this._shellThemeClassnames)===null||t===void 0||t.setClassNames(h.className),this.gridview.margin=(i=h.gap)!==null&&i!==void 0?i:0,(n=this._shellManager)===null||n===void 0||n.updateTheme((s=h.gap)!==null&&s!==void 0?s:0,(l=h.edgeGroupCollapsedSize)!==null&&l!==void 0?l:35),h.dndOverlayBorder!==void 0?(this.element.style.setProperty("--dv-drag-over-border",h.dndOverlayBorder),(a=this._shellManager)===null||a===void 0||a.element.style.setProperty("--dv-drag-over-border",h.dndOverlayBorder)):(this.element.style.removeProperty("--dv-drag-over-border"),(r=this._shellManager)===null||r===void 0||r.element.style.removeProperty("--dv-drag-over-border")),h.dndOverlayMounting){case"absolute":this.rootDropTargetContainer.disabled=!1;break;case"relative":default:this.rootDropTargetContainer.disabled=!0;break}const c=((d=h.tabGroupIndicator)!==null&&d!==void 0?d:"wrap")==="none";E(this.element,"dv-tab-group-indicator-none",c),this._shellManager&&E(this._shellManager.element,"dv-tab-group-indicator-none",c);for(const u of this.groups)u.model.updateTabGroups()}}class Oo extends ln{get orientation(){return this.gridview.orientation}set orientation(e){this.gridview.orientation=e}get options(){return this._options}get deserializer(){return this._deserializer}set deserializer(e){this._deserializer=e}constructor(e,t){var i;super(e,{proportionalLayout:(i=t.proportionalLayout)!==null&&i!==void 0?i:!0,orientation:t.orientation,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:t.disableAutoResizing,className:t.className}),this._onDidLayoutfromJSON=new _,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidRemoveGroup=new _,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new _,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new _,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._options=t,this.addDisposables(this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this.onDidAdd(n=>{this._onDidAddGroup.fire(n)}),this.onDidRemove(n=>{this._onDidRemoveGroup.fire(n)}),this.onDidActiveChange(n=>{this._onDidActiveGroupChange.fire(n)}))}updateOptions(e){super.updateOptions(e);const t=typeof e.orientation=="string"&&this.gridview.orientation!==e.orientation;this._options=Object.assign(Object.assign({},this.options),e),t&&(this.gridview.orientation=e.orientation),this.layout(this.gridview.width,this.gridview.height,!0)}removePanel(e){this.removeGroup(e)}toJSON(){var e;return{grid:this.gridview.serialize(),activePanel:(e=this.activeGroup)===null||e===void 0?void 0:e.id}}setVisible(e,t){this.gridview.setViewVisible(Q(e.element),t)}setActive(e){this._groups.forEach((t,i)=>{t.value.setActive(e===t.value)})}focus(){var e;(e=this.activeGroup)===null||e===void 0||e.focus()}fromJSON(e){this.clear();const{grid:t,activePanel:i}=e;try{const n=[],s=this.width,l=this.height;if(this.gridview.deserialize(t,{fromJSON:a=>{const{data:r}=a,d=this.options.createComponent({id:r.id,name:r.component});return n.push(()=>d.init({params:r.params,minimumWidth:r.minimumWidth,maximumWidth:r.maximumWidth,minimumHeight:r.minimumHeight,maximumHeight:r.maximumHeight,priority:r.priority,snap:!!r.snap,accessor:this,isVisible:a.visible})),this._onDidAddGroup.fire(d),this.registerPanel(d),d}}),this.layout(s,l,!0),n.forEach(a=>a()),typeof i=="string"){const a=this.getPanel(i);a&&this.doSetGroupActive(a)}}catch(n){for(const s of this.groups)s.dispose(),this._groups.delete(s.id),this._onDidRemoveGroup.fire(s);throw this.clear(),n}this._onDidLayoutfromJSON.fire()}clear(){const e=this.activeGroup,t=Array.from(this._groups.values());for(const i of t)i.disposable.dispose(),this.doRemoveGroup(i.value,{skipActive:!0});e&&this.doSetGroupActive(void 0),this.gridview.clear()}movePanel(e,t){var i;let n;const s=this.gridview.remove(e),l=(i=this._groups.get(t.reference))===null||i===void 0?void 0:i.value;if(!l)throw new Error(`reference group ${t.reference} does not exist`);const a=Et(t.direction);if(a==="center")throw new Error(`${a} not supported as an option`);{const r=Q(l.element);n=Ee(this.gridview.orientation,r,a)}this.doAddGroup(s,n,t.size)}addPanel(e){var t,i,n,s;let l=(t=e.location)!==null&&t!==void 0?t:[0];if(!((i=e.position)===null||i===void 0)&&i.referencePanel){const r=(n=this._groups.get(e.position.referencePanel))===null||n===void 0?void 0:n.value;if(!r)throw new Error(`reference group ${e.position.referencePanel} does not exist`);const d=Et(e.position.direction);if(d==="center")throw new Error(`${d} not supported as an option`);{const h=Q(r.element);l=Ee(this.gridview.orientation,h,d)}}const a=this.options.createComponent({id:e.id,name:e.component});return a.init({params:(s=e.params)!==null&&s!==void 0?s:{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.doAddGroup(a,l,e.size),this.registerPanel(a),this.doSetGroupActive(a),a}registerPanel(e){const t=new V(e.api.onDidFocusChange(i=>{i.isFocused&&this._groups.forEach(n=>{const s=n.value;s!==e?s.setActive(!1):s.setActive(!0)})}));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,i){const n=this.getPanel(t);if(!n)throw new Error("invalid operation");const s=Q(e.element),l=Ee(this.gridview.orientation,s,i),[a,r]=Fe(l),d=Q(n.element),[h,c]=Fe(d);if(rn(h,a)){this.gridview.moveView(h,c,r);return}const u=this.doRemoveGroup(n,{skipActive:!0,skipDispose:!0}),p=Q(e.element),g=Ee(this.gridview.orientation,p,i);this.doAddGroup(u,g)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}}class Ro extends ri{get panels(){return this.splitview.getViews()}get options(){return this._options}get length(){return this._panels.size}get orientation(){return this.splitview.orientation}get splitview(){return this._splitview}set splitview(e){this._splitview&&this._splitview.dispose(),this._splitview=e,this._splitviewChangeDisposable.value=new V(this._splitview.onDidSashEnd(()=>{this._onDidLayoutChange.fire(void 0)}),this._splitview.onDidAddView(t=>this._onDidAddView.fire(t)),this._splitview.onDidRemoveView(t=>this._onDidRemoveView.fire(t)))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation===k.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===k.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._splitviewChangeDisposable=new he,this._panels=new Map,this._onDidLayoutfromJSON=new _,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new _,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new _,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new _,this.onDidLayoutChange=this._onDidLayoutChange.event,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new kt(this.element),this._classNames.setClassNames((i=t.className)!==null&&i!==void 0?i:""),e.appendChild(this.element),this._options=t,this.splitview=new Ze(this.element,t),this.addDisposables(this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange)}updateOptions(e){var t,i;"className"in e&&this._classNames.setClassNames((t=e.className)!==null&&t!==void 0?t:""),"disableResizing"in e&&(this.disableResizing=(i=e.disableAutoResizing)!==null&&i!==void 0?i:!1),typeof e.orientation=="string"&&(this.splitview.orientation=e.orientation),this._options=Object.assign(Object.assign({},this.options),e),this.splitview.layout(this.splitview.size,this.splitview.orthogonalSize)}focus(){var e;(e=this._activePanel)===null||e===void 0||e.focus()}movePanel(e,t){this.splitview.moveView(e,t)}setVisible(e,t){const i=this.panels.indexOf(e);this.splitview.setViewVisible(i,t)}setActive(e,t){this._activePanel=e,this.panels.filter(i=>i!==e).forEach(i=>{i.api._onDidActiveChange.fire({isActive:!1}),t||i.focus()}),e.api._onDidActiveChange.fire({isActive:!0}),t||e.focus()}removePanel(e,t){const i=this._panels.get(e.id);if(!i)throw new Error(`unknown splitview panel ${e.id}`);i.dispose(),this._panels.delete(e.id);const n=this.panels.findIndex(a=>a===e);this.splitview.removeView(n,t).dispose();const l=this.panels;l.length>0&&this.setActive(l[l.length-1])}getPanel(e){return this.panels.find(t=>t.id===e)}addPanel(e){var t;if(this._panels.has(e.id))throw new Error(`panel ${e.id} already exists`);const i=this.options.createComponent({id:e.id,name:e.component});i.orientation=this.splitview.orientation,i.init({params:(t=e.params)!==null&&t!==void 0?t:{},minimumSize:e.minimumSize,maximumSize:e.maximumSize,snap:e.snap,priority:e.priority,accessor:this});const n=typeof e.size=="number"?e.size:Ae.Distribute,s=typeof e.index=="number"?e.index:void 0;return this.splitview.addView(i,n,s),this.doAddView(i),this.setActive(i),i}layout(e,t){const[i,n]=this.splitview.orientation===k.HORIZONTAL?[e,t]:[t,e];this.splitview.layout(i,n)}doAddView(e){const t=e.api.onDidFocusChange(i=>{i.isFocused&&this.setActive(e,!0)});this._panels.set(e.id,t)}toJSON(){var e;return{views:this.splitview.getViews().map((i,n)=>({size:this.splitview.getViewSize(n),data:i.toJSON(),snap:!!i.snap,priority:i.priority})),activeView:(e=this._activePanel)===null||e===void 0?void 0:e.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){this.clear();const{views:t,orientation:i,size:n,activeView:s}=e,l=[],a=this.width,r=this.height;if(this.splitview=new Ze(this.element,{orientation:i,proportionalLayout:this.options.proportionalLayout,descriptor:{size:n,views:t.map(d=>{const h=d.data;if(this._panels.has(h.id))throw new Error(`panel ${h.id} already exists`);const c=this.options.createComponent({id:h.id,name:h.component});return l.push(()=>{var u;c.init({params:(u=h.params)!==null&&u!==void 0?u:{},minimumSize:h.minimumSize,maximumSize:h.maximumSize,snap:d.snap,priority:d.priority,accessor:this})}),c.orientation=i,this.doAddView(c),setTimeout(()=>{this._onDidAddView.fire(c)},0),{size:d.size,view:c}})}}),this.layout(a,r),l.forEach(d=>d()),typeof s=="string"){const d=this.getPanel(s);d&&this.setActive(d)}this._onDidLayoutfromJSON.fire()}clear(){for(const e of this._panels.values())e.dispose();for(this._panels.clear();this.splitview.length>0;)this.splitview.removeView(0,Ae.Distribute,!0).dispose()}dispose(){for(const t of this._panels.values())t.dispose();this._panels.clear();const e=this.splitview.getViews();this._splitviewChangeDisposable.dispose(),this.splitview.dispose();for(const t of e)t.dispose();this.element.remove(),super.dispose()}}class Vi extends V{get element(){return this._element}constructor(){super(),this._expandedIcon=Zs(),this._collapsedIcon=wn(),this.disposable=new he,this.apiRef={api:null},this._element=document.createElement("div"),this.element.className="dv-default-header",this._content=document.createElement("span"),this._expander=document.createElement("div"),this._expander.className="dv-pane-header-icon",this.element.appendChild(this._expander),this.element.appendChild(this._content),this.addDisposables(R(this._element,"click",()=>{var e;(e=this.apiRef.api)===null||e===void 0||e.setExpanded(!this.apiRef.api.isExpanded)}))}init(e){this.apiRef.api=e.api,this._content.textContent=e.title,this.updateIcon(),this.disposable.value=e.api.onDidExpansionChange(()=>{this.updateIcon()})}updateIcon(){var e;const t=!!(!((e=this.apiRef.api)===null||e===void 0)&&e.isExpanded);E(this._expander,"collapsed",!t),t?(this._expander.contains(this._collapsedIcon)&&this._collapsedIcon.remove(),this._expander.contains(this._expandedIcon)||this._expander.appendChild(this._expandedIcon)):(this._expander.contains(this._expandedIcon)&&this._expandedIcon.remove(),this._expander.contains(this._collapsedIcon)||this._expander.appendChild(this._collapsedIcon))}update(e){}dispose(){this.disposable.dispose(),super.dispose()}}const Mo=oi(),Li=22,Ni=0,Wi=Number.MAX_SAFE_INTEGER;class Hi extends Ls{constructor(e){super({accessor:e.accessor,id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,disableDnd:e.disableDnd,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this.options=e}getBodyComponent(){return this.options.body}getHeaderComponent(){return this.options.header}}class Vo extends ri{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new V(this._paneview.onDidChange(()=>{this._onDidLayoutChange.fire(void 0)}),this._paneview.onDidAddView(t=>this._onDidAddView.fire(t)),this._paneview.onDidRemoveView(t=>this._onDidRemoveView.fire(t)))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation===k.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===k.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._id=Mo.next(),this._disposable=new he,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new _,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new _,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new _,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new _,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new _,this.onDidRemoveView=this._onDidRemoveView.event,this._onUnhandledDragOverEvent=new _,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this.element.style.height="100%",this.element.style.width="100%",this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView,this._onUnhandledDragOverEvent),this._classNames=new kt(this.element),this._classNames.setClassNames((i=t.className)!==null&&i!==void 0?i:""),e.appendChild(this.element),this._options=t,this.paneview=new Gi(this.element,{orientation:k.VERTICAL}),this.addDisposables(this._disposable)}setVisible(e,t){const i=this.panels.indexOf(e);this.paneview.setViewVisible(i,t)}focus(){}updateOptions(e){var t,i;"className"in e&&this._classNames.setClassNames((t=e.className)!==null&&t!==void 0?t:""),"disableResizing"in e&&(this.disableResizing=(i=e.disableAutoResizing)!==null&&i!==void 0?i:!1),this._options=Object.assign(Object.assign({},this.options),e)}addPanel(e){var t,i;const n=this.options.createComponent({id:e.id,name:e.component});let s;e.headerComponent&&this.options.createHeaderComponent&&(s=this.options.createHeaderComponent({id:e.id,name:e.headerComponent})),s||(s=new Vi);const l=new Hi({id:e.id,component:e.component,headerComponent:e.headerComponent,header:s,body:n,orientation:k.VERTICAL,isExpanded:!!e.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:(t=e.headerSize)!==null&&t!==void 0?t:Li,minimumBodySize:Ni,maximumBodySize:Wi});this.doAddPanel(l);const a=typeof e.size=="number"?e.size:Ae.Distribute,r=typeof e.index=="number"?e.index:void 0;return l.init({params:(i=e.params)!==null&&i!==void 0?i:{},minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize,isExpanded:e.isExpanded,title:e.title,containerApi:new mt(this),accessor:this}),this.paneview.addPane(l,a,r),l.orientation=this.paneview.orientation,l}removePanel(e){const i=this.panels.findIndex(n=>n===e);this.paneview.removePane(i),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find(t=>t.id===e)}layout(e,t){const[i,n]=this.paneview.orientation===k.HORIZONTAL?[e,t]:[t,e];this.paneview.layout(i,n)}toJSON(){const e=n=>n===Number.MAX_SAFE_INTEGER||n===Number.POSITIVE_INFINITY?void 0:n,t=n=>n<=0?void 0:n;return{views:this.paneview.getPanes().map((n,s)=>({size:this.paneview.getViewSize(s),data:n.toJSON(),minimumSize:t(n.minimumBodySize),maximumSize:e(n.maximumBodySize),headerSize:n.headerSize,expanded:n.isExpanded()})),size:this.paneview.size}}fromJSON(e){this.clear();const{views:t,size:i}=e,n=[],s=this.width,l=this.height;this.paneview=new Gi(this.element,{orientation:k.VERTICAL,descriptor:{size:i,views:t.map(a=>{var r,d,h;const c=a.data,u=this.options.createComponent({id:c.id,name:c.component});let p;c.headerComponent&&this.options.createHeaderComponent&&(p=this.options.createHeaderComponent({id:c.id,name:c.headerComponent})),p||(p=new Vi);const g=new Hi({id:c.id,component:c.component,headerComponent:c.headerComponent,header:p,body:u,orientation:k.VERTICAL,isExpanded:!!a.expanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:(r=a.headerSize)!==null&&r!==void 0?r:Li,minimumBodySize:(d=a.minimumSize)!==null&&d!==void 0?d:Ni,maximumBodySize:(h=a.maximumSize)!==null&&h!==void 0?h:Wi});return this.doAddPanel(g),n.push(()=>{var m;g.init({params:(m=c.params)!==null&&m!==void 0?m:{},minimumBodySize:a.minimumSize,maximumBodySize:a.maximumSize,title:c.title,isExpanded:!!a.expanded,containerApi:new mt(this),accessor:this}),g.orientation=this.paneview.orientation}),setTimeout(()=>{this._onDidAddView.fire(g)},0),{size:a.size,view:g}})}}),this.layout(s,l),n.forEach(a=>a()),this._onDidLayoutfromJSON.fire()}clear(){for(const[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.paneview.dispose()}doAddPanel(e){const t=new V(e.onDidDrop(i=>{this._onDidDrop.fire(i)}),e.onUnhandledDragOverEvent(i=>{this._onUnhandledDragOverEvent.fire(i)}));this._viewDisposables.set(e.id,t)}doRemovePanel(e){const t=this._viewDisposables.get(e.id);t&&(t.dispose(),this._viewDisposables.delete(e.id))}dispose(){super.dispose();for(const[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.element.remove(),this.paneview.dispose()}}class Lo extends li{get priority(){return this._priority}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){const e=typeof this._minimumSize=="function"?this._minimumSize():this._minimumSize;return e!==this._evaluatedMinimumSize&&(this._evaluatedMinimumSize=e,this.updateConstraints()),e}get maximumSize(){const e=typeof this._maximumSize=="function"?this._maximumSize():this._maximumSize;return e!==this._evaluatedMaximumSize&&(this._evaluatedMaximumSize=e,this.updateConstraints()),e}get snap(){return this._snap}constructor(e,t){super(e,t,new mn(e,t)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=Number.POSITIVE_INFINITY,this._minimumSize=0,this._maximumSize=Number.POSITIVE_INFINITY,this._snap=!1,this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this.api.initialize(this),this.addDisposables(this._onDidChange,this.api.onWillVisibilityChange(i=>{const{isVisible:n}=i,{accessor:s}=this._params;s.setVisible(this,n)}),this.api.onActiveChange(()=>{const{accessor:i}=this._params;i.setActive(this)}),this.api.onDidConstraintsChangeInternal(i=>{(typeof i.minimumSize=="number"||typeof i.minimumSize=="function")&&(this._minimumSize=i.minimumSize),(typeof i.maximumSize=="number"||typeof i.maximumSize=="function")&&(this._maximumSize=i.maximumSize),this.updateConstraints()}),this.api.onDidSizeChange(i=>{this._onDidChange.fire({size:i.size})}))}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(e,t){const[i,n]=this.orientation===k.HORIZONTAL?[e,t]:[t,e];super.layout(i,n)}init(e){super.init(e),this._priority=e.priority,e.minimumSize&&(this._minimumSize=e.minimumSize),e.maximumSize&&(this._maximumSize=e.maximumSize),e.snap&&(this._snap=e.snap)}toJSON(){const e=i=>i===Number.MAX_SAFE_INTEGER||i===Number.POSITIVE_INFINITY?void 0:i,t=i=>i<=0?void 0:i;return Object.assign(Object.assign({},super.toJSON()),{minimumSize:t(this.minimumSize),maximumSize:e(this.maximumSize)})}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}}function No(o,e){return new ko(o,e).api}function Wo(o,e){const t=new Ro(o,e);return new dn(t)}function Ho(o,e){const t=new Oo(o,e);return new hn(t)}function Fo(o,e){const t=new Vo(o,e);return new mt(t)}/**
|
|
7
|
+
* dockview
|
|
8
|
+
* @version 6.2.2
|
|
9
|
+
* @link https://github.com/mathuo/dockview
|
|
10
|
+
* @license MIT
|
|
11
|
+
*/const Sn=(o,e)=>{const[,t]=M.useState(0),i=M.useRef(o.componentProps);return M.useImperativeHandle(e,()=>({update:n=>{i.current=Object.assign(Object.assign({},i.current),n),t(s=>s+1)}}),[]),M.createElement(o.component,i.current)};Sn.displayName="DockviewReactJsBridge";const Bo=(()=>{let o=1;return{next:()=>`dockview_react_portal_key_${(o++).toString()}`}})(),$o=M.createContext({});class Be{constructor(e,t,i,n,s){this.parent=e,this.portalStore=t,this.component=i,this.parameters=n,this.context=s,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw new Error("invalid operation: resource is already disposed");this.componentInstance?this.componentInstance.update(e):this._initialProps=Object.assign(Object.assign({},this._initialProps),e)}createPortal(){if(this.disposed)throw new Error("invalid operation: resource is already disposed");if(!Uo(this.component))throw new Error("Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components");const e=M.createElement(M.forwardRef(Sn),{component:this.component,componentProps:this.parameters,ref:n=>{this.componentInstance=n,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),t=this.context?M.createElement($o.Provider,{value:this.context},e):e,i=jn.createPortal(t,this.parent,Bo.next());this.ref={portal:i,disposable:this.portalStore.addPortal(i)}}dispose(){var e;(e=this.ref)===null||e===void 0||e.disposable.dispose(),this.disposed=!0}}const Mt=()=>{const[o,e]=M.useState([]);M.useDebugValue(`Portal count: ${o.length}`);const t=M.useCallback(i=>{e(s=>[...s,i]);let n=!1;return re.from(()=>{if(n)throw new Error("invalid operation: resource already disposed");n=!0,e(s=>s.filter(l=>l!==i))})},[]);return[o,t]};function Uo(o){return typeof o=="function"||!!(o!=null&&o.$$typeof)}class Fi{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._onDidFocus=new _,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new _,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new Be(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;(t=this.part)===null||t===void 0||t.update({params:e.params})}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),(e=this.part)===null||e===void 0||e.dispose()}}class Bi{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new Be(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,tabLocation:e.tabLocation})}update(e){var t;(t=this.part)===null||t===void 0||t.update({params:e.params})}layout(e,t){}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}class $i{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new Be(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi})}focus(){}update(e){var t,i,n;this.parameters&&(this.parameters.params=e.params),(t=this.part)===null||t===void 0||t.update({params:(n=(i=this.parameters)===null||i===void 0?void 0:i.params)!==null&&n!==void 0?n:{}})}layout(e,t){}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}class jo{get element(){return this._element}get part(){return this._part}constructor(e,t,i){this.component=e,this.reactPortalStore=t,this._group=i,this.mutableDisposable=new he,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.mutableDisposable.value=new V(this._group.model.onDidAddPanel(()=>{this.updatePanels()}),this._group.model.onDidRemovePanel(()=>{this.updatePanels()}),this._group.model.onDidActivePanelChange(()=>{this.updateActivePanel()}),e.api.onDidActiveChange(()=>{this.updateGroupActive()}),e.api.onDidLocationChange(t=>{this.updateLocation(t.location)})),this._part=new Be(this.element,this.reactPortalStore,this.component,{api:e.api,containerApi:e.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group,headerPosition:this._group.model.headerPosition,location:e.api.location})}dispose(){var e;this.mutableDisposable.dispose(),(e=this._part)===null||e===void 0||e.dispose()}update(e){var t;(t=this._part)===null||t===void 0||t.update(e.params)}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}updateLocation(e){this.update({params:{location:e}})}}class Ko{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new Be(this._element,this.reactPortalStore,this.component,e)}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}class Ui{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new Be(this._element,this.reactPortalStore,this.component,{tabGroup:e.tabGroup,api:e.api})}update(e){var t;(t=this.part)===null||t===void 0||t.update({tabGroup:e.tabGroup})}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}function st(o,e){return o?t=>new jo(o,e,t):void 0}const Pt="props.defaultTabComponent";function Jo(o){return Xt.reduce((t,i)=>(i in o&&(t[i]=o[i]),t),{})}const Pn=M.forwardRef((o,e)=>{const t=M.useRef(null),i=M.useRef(void 0),[n,s]=Mt();M.useImperativeHandle(e,()=>t.current,[]);const l=M.useRef({});return M.useEffect(()=>{const a={};Xt.forEach(r=>{const d=r,h=o[d];d in o&&h!==l.current[d]&&(a[d]=h)}),i.current&&i.current.updateOptions(a),l.current=o},Xt.map(a=>o[a])),M.useEffect(()=>{var a;if(!t.current)return;const r=(a=o.tabComponents)!==null&&a!==void 0?a:{};o.defaultTabComponent&&(r[Pt]=o.defaultTabComponent);const d={createLeftHeaderActionComponent:st(o.leftHeaderActionsComponent,{addPortal:s}),createRightHeaderActionComponent:st(o.rightHeaderActionsComponent,{addPortal:s}),createPrefixHeaderActionComponent:st(o.prefixHeaderActionsComponent,{addPortal:s}),createComponent:g=>new Fi(g.id,o.components[g.name],{addPortal:s}),createTabComponent(g){return new Bi(g.id,r[g.name],{addPortal:s})},createWatermarkComponent:o.watermarkComponent?()=>new $i("watermark",o.watermarkComponent,{addPortal:s}):void 0,defaultTabComponent:o.defaultTabComponent?Pt:void 0,createContextMenuItemComponent:g=>{if(g.component)return new Ko(g.id,g.component,{addPortal:s})}},h=Jo(o);if(o.tabGroupChipComponent){const g=o.tabGroupChipComponent;h.createTabGroupChipComponent=()=>new Ui(g,{addPortal:s})}const c=No(t.current,Object.assign(Object.assign({},h),d)),{clientWidth:u,clientHeight:p}=t.current;return c.layout(u,p),o.onReady&&o.onReady({api:c}),i.current=c,()=>{i.current=void 0,c.dispose()}},[]),M.useEffect(()=>{if(!i.current)return()=>{};const a=i.current.onDidDrop(r=>{o.onDidDrop&&o.onDidDrop(r)});return()=>{a.dispose()}},[o.onDidDrop]),M.useEffect(()=>{if(!i.current)return()=>{};const a=i.current.onWillDrop(r=>{o.onWillDrop&&o.onWillDrop(r)});return()=>{a.dispose()}},[o.onWillDrop]),M.useEffect(()=>{i.current&&i.current.updateOptions({createTabGroupChipComponent:o.tabGroupChipComponent?()=>new Ui(o.tabGroupChipComponent,{addPortal:s}):void 0})},[o.tabGroupChipComponent]),M.useEffect(()=>{i.current&&i.current.updateOptions({createComponent:a=>new Fi(a.id,o.components[a.name],{addPortal:s})})},[o.components]),M.useEffect(()=>{var a;if(!i.current)return;const r=(a=o.tabComponents)!==null&&a!==void 0?a:{};o.defaultTabComponent&&(r[Pt]=o.defaultTabComponent),i.current.updateOptions({defaultTabComponent:o.defaultTabComponent?Pt:void 0,createTabComponent(d){return new Bi(d.id,r[d.name],{addPortal:s})}})},[o.tabComponents,o.defaultTabComponent]),M.useEffect(()=>{i.current&&i.current.updateOptions({createWatermarkComponent:o.watermarkComponent?()=>new $i("watermark",o.watermarkComponent,{addPortal:s}):void 0})},[o.watermarkComponent]),M.useEffect(()=>{i.current&&i.current.updateOptions({createRightHeaderActionComponent:st(o.rightHeaderActionsComponent,{addPortal:s})})},[o.rightHeaderActionsComponent]),M.useEffect(()=>{i.current&&i.current.updateOptions({createLeftHeaderActionComponent:st(o.leftHeaderActionsComponent,{addPortal:s})})},[o.leftHeaderActionsComponent]),M.useEffect(()=>{i.current&&i.current.updateOptions({createPrefixHeaderActionComponent:st(o.prefixHeaderActionsComponent,{addPortal:s})})},[o.prefixHeaderActionsComponent]),M.createElement("div",{style:{height:"100%",width:"100%"},ref:t},n)});Pn.displayName="DockviewComponent";class ji extends Lo{constructor(e,t,i,n){super(e,t),this.reactComponent=i,this.reactPortalStore=n}getComponent(){var e,t;return new Be(this.element,this.reactPortalStore,this.reactComponent,{params:(t=(e=this._params)===null||e===void 0?void 0:e.params)!==null&&t!==void 0?t:{},api:this.api,containerApi:new dn(this._params.accessor)})}}function Yo(o){return Ut.reduce((t,i)=>(i in o&&(t[i]=o[i]),t),{})}const Zo=M.forwardRef((o,e)=>{const t=M.useRef(null),i=M.useRef(void 0),[n,s]=Mt();M.useImperativeHandle(e,()=>t.current,[]);const l=M.useRef({});return M.useEffect(()=>{const a={};Ut.forEach(r=>{const d=r,h=o[d];d in o&&h!==l.current[d]&&(a[d]=h)}),i.current&&i.current.updateOptions(a),l.current=o},Ut.map(a=>o[a])),M.useEffect(()=>{if(!t.current)return()=>{};const a={createComponent:c=>new ji(c.id,c.name,o.components[c.name],{addPortal:s})},r=Wo(t.current,Object.assign(Object.assign({},Yo(o)),a)),{clientWidth:d,clientHeight:h}=t.current;return r.layout(d,h),o.onReady&&o.onReady({api:r}),i.current=r,()=>{i.current=void 0,r.dispose()}},[]),M.useEffect(()=>{i.current&&i.current.updateOptions({createComponent:a=>new ji(a.id,a.name,o.components[a.name],{addPortal:s})})},[o.components]),M.createElement("div",{style:{height:"100%",width:"100%"},ref:t},n)});Zo.displayName="SplitviewComponent";class Ki extends yn{constructor(e,t,i,n){super(e,t),this.reactComponent=i,this.reactPortalStore=n}getComponent(){var e,t;return new Be(this.element,this.reactPortalStore,this.reactComponent,{params:(t=(e=this._params)===null||e===void 0?void 0:e.params)!==null&&t!==void 0?t:{},api:this.api,containerApi:new hn(this._params.accessor)})}}function Xo(o){return Yt.reduce((t,i)=>(i in o&&(t[i]=o[i]),t),{})}const qo=M.forwardRef((o,e)=>{const t=M.useRef(null),i=M.useRef(void 0),[n,s]=Mt();M.useImperativeHandle(e,()=>t.current,[]);const l=M.useRef({});return M.useEffect(()=>{const a={};Yt.forEach(r=>{const d=r,h=o[d];d in o&&h!==l.current[d]&&(a[d]=h)}),i.current&&i.current.updateOptions(a),l.current=o},Yt.map(a=>o[a])),M.useEffect(()=>{if(!t.current)return()=>{};const a={createComponent:c=>new Ki(c.id,c.name,o.components[c.name],{addPortal:s})},r=Ho(t.current,Object.assign(Object.assign({},Xo(o)),a)),{clientWidth:d,clientHeight:h}=t.current;return r.layout(d,h),o.onReady&&o.onReady({api:r}),i.current=r,()=>{i.current=void 0,r.dispose()}},[]),M.useEffect(()=>{i.current&&i.current.updateOptions({createComponent:a=>new Ki(a.id,a.name,o.components[a.name],{addPortal:s})})},[o.components]),M.createElement("div",{style:{height:"100%",width:"100%"},ref:t},n)});qo.displayName="GridviewComponent";class Gt{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new Be(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;(t=this.part)===null||t===void 0||t.update(e.params)}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}function Qo(o){return Zt.reduce((t,i)=>(i in o&&(t[i]=o[i]),t),{})}const er=M.forwardRef((o,e)=>{const t=M.useRef(null),i=M.useRef(void 0),[n,s]=Mt();M.useImperativeHandle(e,()=>t.current,[]);const l=M.useRef({});return M.useEffect(()=>{const a={};Zt.forEach(r=>{const d=r,h=o[d];d in o&&h!==l.current[d]&&(a[d]=h)}),i.current&&i.current.updateOptions(a),l.current=o},Zt.map(a=>o[a])),M.useEffect(()=>{var a;if(!t.current)return()=>{};const r=(a=o.headerComponents)!==null&&a!==void 0?a:{},d={createComponent:p=>new Gt(p.id,o.components[p.name],{addPortal:s}),createHeaderComponent:p=>new Gt(p.id,r[p.name],{addPortal:s})},h=Fo(t.current,Object.assign(Object.assign({},Qo(o)),d)),{clientWidth:c,clientHeight:u}=t.current;return h.layout(c,u),o.onReady&&o.onReady({api:h}),i.current=h,()=>{i.current=void 0,h.dispose()}},[]),M.useEffect(()=>{i.current&&i.current.updateOptions({createComponent:a=>new Gt(a.id,o.components[a.name],{addPortal:s})})},[o.components]),M.useEffect(()=>{var a;if(!i.current)return;const r=(a=o.headerComponents)!==null&&a!==void 0?a:{};i.current.updateOptions({createHeaderComponent:d=>new Gt(d.id,r[d.name],{addPortal:s})})},[o.headerComponents]),M.useEffect(()=>{if(!i.current)return()=>{};const a=i.current.onDidDrop(r=>{o.onDidDrop&&o.onDidDrop(r)});return()=>{a.dispose()}},[o.onDidDrop]),M.createElement("div",{style:{height:"100%",width:"100%"},ref:t},n)});er.displayName="PaneviewComponent";const Gn="route-container-panel-dock-content",An="route-container-panel-dock-tab",tr="application/vnd.oneworks.route-container-panel-tab+json",qt="route-container-panel-dock:external-tab-drop",Ht="route-container-panel-dock:context-menu-open",ir=12,nr=".route-container-panel-dock",sr=120,or=()=>{var o;try{return new URLSearchParams(((o=window.location)==null?void 0:o.search)??"").get("oneworks_debug")==="1"}catch{return!1}},ie=(o,e)=>{if(or())try{const t=window,i=t.__oneworksDebugEvents??[];i.push({at:Date.now(),data:e,message:o,scope:"route-panel-dock"}),i.length>1e3&&i.splice(0,i.length-1e3),t.__oneworksDebugEvents=i}catch{}},In=o=>{var t,i,n;if(!(o instanceof Element))return null;const e=o.closest("[data-route-container-panel-dock-tab-key]");return{className:(i=(t=o.className)==null?void 0:t.toString)==null?void 0:i.call(t),tabKey:e instanceof HTMLElement?e.dataset.routeContainerPanelDockTabKey:void 0,tagName:o.tagName,text:(n=o.textContent)==null?void 0:n.trim().replace(/\s+/g," ").slice(0,80)}},Ji=o=>o!=null&&typeof o=="object"&&!Array.isArray(o),rr=o=>o.toLowerCase().includes("active"),zt=(o,e,t={})=>{if(Array.isArray(o)){const i=o.reduce((n,s)=>!Ji(s)||typeof s.size!="number"?n:n+s.size,0);return o.map(n=>zt(n,i>0?i:void 0,t))}return Ji(o)?Object.fromEntries(Object.entries(o).flatMap(([i,n])=>t.ignoreActiveState===!0&&rr(i)?[]:i==="height"||i==="width"?[]:i==="size"?typeof n!="number"||e==null||e<=0?[]:[["sizeRatio",Math.round(n/e*1e4)/1e4]]:[[i,zt(n,void 0,t)]]).sort(([i],[n])=>i.localeCompare(n))):o},rt=o=>JSON.stringify(zt(o))??"undefined",Yi=o=>JSON.stringify(zt(o,void 0,{ignoreActiveState:!0}))??"undefined",Er=(o,e)=>rt(o??null)===rt(e??null),ct=(o,e,t,i)=>t==null||t.enabled===!1?null:{icon:t.icon??e,key:t.key??o,label:t.label,...t.active!=null?{active:t.active}:{},...t.activeIcon!=null||i!=null?{activeIcon:t.activeIcon??i}:{},...t.disabled!=null?{disabled:t.disabled}:{},onSelect:t.onSelect},ar=o=>[ct("before-fullscreen","open_in_new",o==null?void 0:o.beforeFullscreen),ct("fullscreen","fullscreen",o==null?void 0:o.fullscreen,"fullscreen_exit"),ct("minimize","bottom_panel_close",o==null?void 0:o.minimize),ct("before-close","more_horiz",o==null?void 0:o.beforeClose),ct("close","disabled_by_default",o==null?void 0:o.close)].filter(e=>e!=null),Zi=(o,e)=>{const t=new Set(o),i=new Set,n=[];for(const s of e)!t.has(s)||i.has(s)||(i.add(s),n.push(s));return n},Qt=(o,e)=>{const t=new Set(e.map(i=>i.key));return o==null||typeof o!="object"||o.panels==null||typeof o.panels!="object"?null:Object.keys(o.panels).every(i=>t.has(i))?o:null},lr=(o,e)=>{if(o==null||typeof window>"u")return null;try{return Qt(JSON.parse(window.localStorage.getItem(o)??"null"),e)}catch{return null}},dr=(o,e)=>{o==null||typeof window>"u"||window.localStorage.setItem(o,JSON.stringify(e))},hr=o=>{try{const e=JSON.parse(o.getData(tr));return e==null||typeof e!="object"||typeof e.scope!="string"||typeof e.sourceWorkspaceKey!="string"||typeof e.tabKey!="string"?null:e}catch{return null}},cr=o=>o==null||typeof o!="object"||typeof o.scope!="string"||typeof o.sourceWorkspaceKey!="string"||typeof o.targetWorkspaceKey!="string"||typeof o.tabKey!="string"?null:o,ur=(o,e,t)=>{const i=document.elementFromPoint(o,e);if(!(i instanceof Element))return null;const n=i.closest(nr);if(n instanceof HTMLElement){const s=n.dataset.routeContainerPanelDockWorkspaceKey;if(n.dataset.routeContainerPanelDockDroppable==="true"&&n.dataset.routeContainerPanelDockScope===t.scope&&s!=null&&s!==t.sourceWorkspaceKey)return{element:n,targetWorkspaceKey:s}}for(const s of t.dropTargets??[])if(s.targetWorkspaceKey!==t.sourceWorkspaceKey)try{const l=i.closest(s.selector);if(!(l instanceof HTMLElement))continue;return{element:l,targetWorkspaceKey:s.targetWorkspaceKey}}catch{continue}return null},pr=o=>{var i;const e=o.filter(n=>n.api.isVisible&&n.panels.length>0&&n.api.location.type==="grid").map(n=>({group:n,rect:n.element.getBoundingClientRect()})).filter(({rect:n})=>n.width>0&&n.height>0);if(e.length===0)return;const t=Math.min(...e.map(({rect:n})=>n.top));return(i=e.filter(({rect:n})=>Math.abs(n.top-t)<=2).sort((n,s)=>s.rect.right-n.rect.right||n.rect.left-s.rect.left)[0])==null?void 0:i.group.api.id},En=y.createContext(null),at=o=>{var t;const e=(t=o.title)==null?void 0:t.trim();return e!=null&&e.length>0?e:o.label},mr=o=>{var t;const e=(t=o.title)==null?void 0:t.trim();return e!=null&&e.length>0},Xi=o=>o.group.panels.length,fr=o=>o instanceof Element&&o.closest(".route-container-panel-dock-context-dropdown, .route-container-panel-dock__context-anchor")!=null,gt=()=>{const o=y.useContext(En);if(o==null)throw new Error("RouteContainerPanelDockWorkspace must be rendered inside its context provider");return o};function gr({api:o,params:e}){const{tabByKey:t}=gt(),i=t[e.tabKey],[n,s]=y.useState(()=>o.isVisible);if(y.useEffect(()=>{s(o.isVisible);const r=o.onDidVisibilityChange(()=>{s(o.isVisible)});return()=>r.dispose()},[o]),i==null)return null;const l=typeof i.content=="function"?i.content({isVisible:n,tab:i,tabKey:i.key}):i.content,a=`route-container-panel-dock__content ${n?"is-visible":"is-hidden"}`;return H.jsx("div",{className:a,children:l})}function vr({api:o,containerApi:e,params:t}){const{activeTab:i,closeLabel:n,closeTab:s,externalTabDrag:l,hasContextMenu:a,isTabClosable:r,openContextMenu:d,openedTabs:h,panelKey:c,selectTab:u,tabByKey:p,tabs:g,visibleTabs:m}=gt(),f=p[t.tabKey],[v,b]=y.useState(!1),w=y.useRef(null),C=y.useRef(!1),[T,I]=y.useState(()=>({group:o.group,tabCount:Xi(o)})),G=y.useCallback(()=>{I(O=>{const Y=o.group,B=Xi(o);return O.group===Y&&O.tabCount===B?O:{group:Y,tabCount:B}})},[o]);if(y.useEffect(()=>{G();const O=[o.onDidGroupChange(G),e.onDidLayoutChange(G)];return()=>{O.forEach(Y=>Y.dispose())}},[o,e,G]),y.useEffect(()=>{G();const{model:O}=T.group,Y=[O.onDidAddPanel(G),O.onDidRemovePanel(G),O.onDidActivePanelChange(G)];return()=>{Y.forEach(B=>B.dispose())}},[T.group,G]),f==null)return null;const P=at(f),F=r(f.key,T.tabCount),K=(n==null?void 0:n(P))??P,L=(l==null?void 0:l.draggable)===!0&&f.disabled!==!0,j=O=>{var Y;ie("tab activate",{activeTab:i,apiGroupActivePanelId:(Y=o.group.activePanel)==null?void 0:Y.id,apiIsActive:o.isActive,apiIsVisible:o.isVisible,groupTabCount:T.tabCount,openedTabs:h,panelKey:c,source:O,tabKey:f.key}),u(f.key),o.setActive(),window.setTimeout(()=>{var B;ie("tab activate after tick",{activeTab:i,apiGroupActivePanelId:(B=o.group.activePanel)==null?void 0:B.id,apiIsActive:o.isActive,apiIsVisible:o.isVisible,panelKey:c,source:O,tabKey:f.key})},0)},ne=O=>{a&&d(O,{activeTab:i,closeTab:s,isActive:i===f.key,isClosable:F,isOpened:h.includes(f.key),openedTabs:h,panelKey:c,selectTab:u,tab:f,tabs:g,target:"tab",visibleTabs:m})},U=()=>{var O;(O=w.current)==null||O.element.classList.remove("is-external-drop-target"),w.current=null},S=(O,Y)=>{var be,X;if(l==null)return null;const B=ur(O,Y,{dropTargets:l.dropTargets,scope:l.scope,sourceWorkspaceKey:l.workspaceKey});return(B==null?void 0:B.element)===((be=w.current)==null?void 0:be.element)&&(B==null?void 0:B.targetWorkspaceKey)===((X=w.current)==null?void 0:X.targetWorkspaceKey)||(U(),B==null||B.element.classList.add("is-external-drop-target"),w.current=B),B},z=O=>{if(!L||l==null||O.button!==0)return;O.stopPropagation(),j("external-pointerdown");const Y=O.pointerId,B=O.clientX,be=O.clientY,X=l.workspaceKey,ve=l.scope,Z=f.key;let De=!1;const we=()=>{window.removeEventListener("pointermove",ue),window.removeEventListener("pointerup",fe),window.removeEventListener("pointercancel",ee),U(),b(!1)},ue=le=>{if(le.pointerId!==Y)return;const pe=le.clientX-B,Ce=le.clientY-be;!De&&Math.hypot(pe,Ce)<ir||(De=!0,le.preventDefault(),b(!0),S(le.clientX,le.clientY))},fe=le=>{var Me;if(le.pointerId!==Y)return;const pe=De?S(le.clientX,le.clientY):null;if(we(),De&&(C.current=!0,window.setTimeout(()=>{C.current=!1},0)),pe==null)return;le.preventDefault(),le.stopPropagation();const Ce=pe.targetWorkspaceKey;if(l.onDrop!=null){if(!(((Me=l.canDrop)==null?void 0:Me.call(l,{sourceWorkspaceKey:X,tab:f,tabKey:Z,targetWorkspaceKey:Ce}))??!0))return;l.onDrop({sourceWorkspaceKey:X,tab:f,tabKey:Z,targetWorkspaceKey:Ce});return}window.dispatchEvent(new CustomEvent(qt,{detail:{scope:ve,sourceWorkspaceKey:X,tabKey:Z,targetWorkspaceKey:Ce}}))},ee=le=>{le.pointerId===Y&&we()};window.addEventListener("pointermove",ue,{passive:!1}),window.addEventListener("pointerup",fe),window.addEventListener("pointercancel",ee)},ce=O=>{const Y=O.target,B=Y instanceof Element&&Y.closest(".route-container-panel-dock-tab__close")!=null;ie("tab pointerdown capture",{button:O.button,canDragExternalTab:L,isCloseTarget:B,panelKey:c,tabKey:f.key,target:In(Y)}),!B&&L&&z(O)};return H.jsxs("div",{className:["route-container-panel-dock-tab",F?"is-closable":"",L?"is-external-draggable":"",v?"is-external-dragging":""].filter(Boolean).join(" "),"data-route-container-panel-dock-tab-key":f.key,title:P,onContextMenu:a?ne:void 0,onPointerDownCapture:ce,children:[H.jsx("span",{className:"route-container-panel-dock-tab__icon",children:f.iconNode??H.jsx(At,{name:i===f.key&&f.activeIcon!=null?f.activeIcon:f.icon,"aria-hidden":"true"})}),H.jsx("span",{className:"route-container-panel-dock-tab__label",children:f.label}),f.badge!=null&&H.jsx("span",{className:"route-container-panel-dock-tab__badge",children:f.badge}),F&&H.jsx("button",{type:"button",className:"route-container-panel-dock-tab__close","aria-label":K,title:K,onClick:O=>{if(O.stopPropagation(),C.current){O.preventDefault(),C.current=!1;return}s(f.key)},onPointerDown:L?z:O=>O.stopPropagation(),children:H.jsx(At,{name:"cancel","aria-hidden":"true"})})]})}const Tn=o=>{o.stopPropagation()},mi=()=>H.jsx("span",{className:"material-symbols-rounded nav-menu-submenu-chevron",children:"keyboard_arrow_right"});function _r({api:o}){return H.jsx(zn,{onBeforeOpen:()=>o.setActive()})}function zn({onBeforeOpen:o}){const{createMenuIcon:e,createMenuItems:t,createMenuLabel:i,createMenuSections:n,createMenuSelectedKeys:s,onCreateMenuClick:l,onCreateMenuOpenChange:a}=gt(),[r,d]=y.useState(!1),h=typeof navigator<"u"&&navigator.platform.includes("Mac"),c=y.useCallback(()=>d(!1),[]),u=y.useMemo(()=>ei({closeMenu:c,isMac:h,sections:n}),[c,n,h]),p=t??u,g=y.useMemo(()=>ti(n),[n]),m=s??g,f=v=>{d(v),a==null||a(v)};return i==null||p==null||p.length===0?null:H.jsx("div",{className:"route-container-panel-dock__prefix-actions",onPointerDown:Tn,children:H.jsx(ni,{overlayClassName:`${ii} route-container-panel-dock-create-dropdown`,menu:{expandIcon:mi(),items:p,onClick:l,selectedKeys:m,triggerSubMenuAction:"click"},open:r,placement:"bottomLeft",trigger:["click"],transitionName:"ant-slide-down",onOpenChange:f,children:H.jsx("button",{type:"button",className:["route-container-panel-dock__create-action",r?"is-open":""].filter(Boolean).join(" "),"data-dock-panel-no-resize":"true","aria-label":i,"aria-haspopup":"menu","aria-expanded":r,title:i,onClick:o,children:H.jsx(At,{name:e,"aria-hidden":"true"})})})})}function br({action:o}){const[e,t]=y.useState(!1),i=o.active&&o.activeIcon!=null?o.activeIcon:o.icon,n=o.label,s=typeof navigator<"u"&&navigator.platform.includes("Mac"),l=y.useCallback(()=>t(!1),[]),a=y.useMemo(()=>o.menuSections==null?void 0:ei({closeMenu:l,isMac:s,sections:o.menuSections}),[o.menuSections,l,s]),r=y.useMemo(()=>o.menuSections==null?[]:ti(o.menuSections),[o.menuSections]),d=o.menuItems??a,h=o.menuSelectedKeys??r,c=H.jsx(Yn,{title:n,placement:"top",children:H.jsx("button",{type:"button",className:["route-container-panel-dock__header-action",o.active?"is-active":"",e?"is-open":""].filter(Boolean).join(" "),"aria-label":n,"aria-pressed":o.active,disabled:o.disabled,title:n,onClick:d==null||d.length===0?o.onSelect:void 0,children:H.jsx(At,{name:i,"aria-hidden":"true"})})});return d==null||d.length===0?c:H.jsx(ni,{overlayClassName:`${ii} route-container-panel-dock-action-dropdown`,menu:{expandIcon:mi(),items:d,selectedKeys:h,triggerSubMenuAction:"click"},open:e,placement:"bottomRight",trigger:["click"],transitionName:"ant-slide-down",onOpenChange:u=>{var p;t(u),(p=o.onMenuOpenChange)==null||p.call(o,u)},children:c})}function kn({actions:o}){const e=o;return e.length===0?null:H.jsx("div",{className:"route-container-panel-dock__header-actions",onPointerDown:Tn,children:e.map(t=>H.jsx(br,{action:t},t.key))})}function wr({activePanel:o,containerApi:e,group:t}){const{activeTab:i,getHeaderActions:n,headerActions:s,panelChromeActions:l,panelKey:a,tabByKey:r}=gt(),[d,h]=y.useState(!1),c=y.useCallback(()=>{h(pr(e.groups)===t.api.id)},[e,t]);y.useEffect(()=>{c();const m=window.requestAnimationFrame(c),f=[t.api.onDidDimensionsChange(c),e.onDidAddGroup(c),e.onDidLayoutChange(c),e.onDidMaximizedGroupChange(c),e.onDidRemoveGroup(c)];return()=>{window.cancelAnimationFrame(m);for(const v of f)v.dispose()}},[e,t,c]);const u=o==null?null:r[o.id]??null,p=(n==null?void 0:n({activeTab:i,groupActiveTab:u,groupActiveTabKey:(u==null?void 0:u.key)??null,isTopRightGroup:d,panelKey:a}))??s,g=d?[...p,...l]:p;return g.length===0||n==null&&(!d||o==null)?null:H.jsx(kn,{actions:g})}const Ft=(o,e,t)=>{var n;const i=new Set(e.map(s=>s.key));for(const s of o.panels)i.has(s.id)||o.removePanel(s);for(const s of e){const l=o.getPanel(s.key);if(l==null){o.addPanel({id:s.key,component:Gn,tabComponent:An,title:at(s),renderer:"always",inactive:s.key!==t,params:{tabKey:s.key}});continue}l.api.setTitle(at(s)),l.api.updateParameters({tabKey:s.key}),l.api.renderer!=="always"&&l.api.setRenderer("always")}t!=null&&((n=o.getPanel(t))==null||n.api.setActive())};function Tr({activeTab:o,ariaLabel:e,className:t,closable:i=!1,closeLabel:n,createMenuIcon:s="add_box",createMenuItems:l,createMenuLabel:a,createMenuSections:r=[],createMenuSelectedKeys:d,defaultContent:h,disableFloatingGroups:c=!1,externalTabDrag:u,getContextMenuSections:p,getHeaderActions:g,getTabContextMenuItems:m,headerActions:f=[],labelMode:v="icon-only",layout:b,minOpenTabs:w=0,openedTabs:C,panelChromeActions:T,panelKey:I,storageKey:G,tabs:P,onCreateMenuClick:F,onCreateMenuOpenChange:K,onLayoutChange:L,onTabChange:j,onTabClose:ne}){const U=y.useRef(null),S=y.useRef(null),z=y.useId(),ce=y.useRef([]),O=y.useRef(!1),Y=y.useRef(null),B=y.useRef(null),be=y.useRef(null),X=y.useRef(null),ve=y.useRef(null),Z=y.useRef(L),De=y.useMemo(()=>P.map(D=>D),[P]),we=y.useMemo(()=>P.map(D=>D.key),[P]),ue=y.useMemo(()=>Zi(we,C),[C,we]),fe=o??ue[0]??null,ee=y.useMemo(()=>{const D=new Set(ue);return(i?P.filter(x=>D.has(x.key)||x.key===fe):P).map(x=>x)},[i,fe,ue,P]),le=y.useMemo(()=>ee.map(D=>D.key).join("\0"),[ee]),pe=y.useMemo(()=>Qt(b,ee),[b,ee]),Ce=y.useMemo(()=>rt(pe??null),[pe]),Me=y.useMemo(()=>Yi(pe??null),[pe]),Ke=y.useMemo(()=>Object.fromEntries(ee.map(D=>[D.key,D])),[ee]),vt=y.useMemo(()=>ar(T),[T]),de=y.useRef(fe),N=y.useRef(ue),$=y.useRef(ee),[ge,Se]=y.useState(!1),[_e,fi]=y.useState(null);y.useEffect(()=>{de.current=fe,N.current=ue,$.current=ee},[fe,ue,ee]),y.useEffect(()=>{Z.current=L},[L]);const Xe=y.useCallback(()=>{ce.current.forEach(D=>D.dispose()),ce.current=[]},[]),gi=y.useCallback(()=>{var x;const D=X.current;X.current=null,D!=null&&((x=Z.current)==null||x.call(Z,D))},[]),vi=y.useCallback(D=>{Z.current!=null&&(X.current=D,ie("schedule layout change",{layoutKeyLength:rt(D).length,panelKey:I,visibleTabKeys:$.current.map(x=>x.key)}),ve.current!=null&&(window.clearTimeout(ve.current),ie("reschedule layout change",{panelKey:I})),ve.current=window.setTimeout(()=>{ve.current=null,gi()},sr))},[gi]),_t=y.useCallback(()=>{const D=U.current;if(D==null||O.current){ie("persist layout skipped",{hasApi:D!=null,isSyncing:O.current,panelKey:I});return}const x=Qt(D.toJSON(),$.current);if(x==null){ie("persist layout skipped",{panelKey:I,reason:"empty-layout"});return}const A=rt(x);if(B.current===A){ie("persist layout skipped",{panelKey:I,reason:"same-layout",visibleTabKeys:$.current.map(W=>W.key)});return}B.current=A,ie("persist layout",{layoutKeyLength:A.length,panelKey:I,visibleTabKeys:$.current.map(W=>W.key)}),dr(G,x),vi(x)},[I,vi,G]),qe=y.useCallback(()=>{const D=U.current,x=S.current;if(D==null||x==null)return;const A=x.getBoundingClientRect(),W=Math.round(A.width),J=Math.round(A.height);W<=0||J<=0||D.layout(W,J,!0)},[]);y.useEffect(()=>{const D=S.current;if(D==null||typeof ResizeObserver>"u")return;let x=null;const A=()=>{x!=null&&window.cancelAnimationFrame(x),x=window.requestAnimationFrame(()=>{x=null,qe()})},W=new ResizeObserver(A);return W.observe(D),A(),()=>{x!=null&&window.cancelAnimationFrame(x),W.disconnect()}},[qe]);const Qe=y.useCallback(D=>(u==null?void 0:u.droppable)===!0&&u.onDrop!=null,[u]),bt=y.useCallback(D=>{var W;if(D==null||(u==null?void 0:u.droppable)!==!0||u.onDrop==null)return!1;const x=u.workspaceKey;if(D.scope!==u.scope||D.sourceWorkspaceKey===x)return!1;const A=P.find(J=>J.key===D.tabKey);return A==null||A.disabled===!0?!1:((W=u.canDrop)==null?void 0:W.call(u,{sourceWorkspaceKey:D.sourceWorkspaceKey,tab:A,tabKey:A.key,targetWorkspaceKey:x}))??!0},[u,P]),On=y.useCallback(D=>{Qe(D.dataTransfer)&&(D.preventDefault(),D.dataTransfer.dropEffect="move",Se(!0))},[Qe]),Rn=y.useCallback(D=>{Qe(D.dataTransfer)&&(D.preventDefault(),D.dataTransfer.dropEffect="move",Se(!0))},[Qe]),Mn=y.useCallback(D=>{const x=D.relatedTarget;x instanceof Node&&D.currentTarget.contains(x)||Se(!1)},[]),Vn=y.useCallback(D=>{if(!Qe(D.dataTransfer))return;const x=hr(D.dataTransfer);if(!bt(x)||x==null||(u==null?void 0:u.onDrop)==null){Se(!1);return}const A=P.find(W=>W.key===x.tabKey);if(A==null){Se(!1);return}D.preventDefault(),D.stopPropagation(),Se(!1),u.onDrop({sourceWorkspaceKey:x.sourceWorkspaceKey,tab:A,tabKey:A.key,targetWorkspaceKey:u.workspaceKey})},[bt,Qe,u,P]);y.useEffect(()=>{if((u==null?void 0:u.droppable)!==!0||u.onDrop==null)return;const D=x=>{var te;const A=cr(x.detail);if(A==null||A.targetWorkspaceKey!==u.workspaceKey)return;const W={scope:A.scope,sourceWorkspaceKey:A.sourceWorkspaceKey,tabKey:A.tabKey};if(!bt(W))return;const J=P.find(ye=>ye.key===A.tabKey);J!=null&&((te=u.onDrop)==null||te.call(u,{sourceWorkspaceKey:A.sourceWorkspaceKey,tab:J,tabKey:J.key,targetWorkspaceKey:u.workspaceKey}))};return window.addEventListener(qt,D),()=>{window.removeEventListener(qt,D)}},[bt,u,P]);const et=y.useCallback(()=>{Y.current!=null&&(window.clearTimeout(Y.current),Y.current=null),O.current=!0},[]),tt=y.useCallback(D=>{Y.current=window.setTimeout(()=>{Y.current=null,O.current=!1,D==null||D()},80)},[]),Ve=y.useCallback(D=>{const x=D;if(de.current===x&&N.current.includes(x)){ie("select tab ignored",{reason:"already-active-opened",tabKey:x});return}ie("select tab",{currentActiveTab:de.current,nextActiveTab:x,openedTabs:N.current,tabKeys:we,visibleTabKeys:$.current.map(A=>A.key)}),de.current=x,j(x,Zi(we,[...N.current,x]))},[j,we]),$e=y.useCallback(D=>{const x=D,A=N.current,W=A.indexOf(x),J=A.filter(xe=>xe!==x),te=J[Math.max(0,W-1)]??J[0]??null,ye=de.current===x?te:de.current;(ne==null?void 0:ne(x))!==!1&&j(ye,J)},[j,ne]);y.useEffect(()=>{const D=S.current;if(D==null)return;const x=A=>{var xe,Le,Pe,Ne,bi,wi;if(A.button!==0)return;const W=A.target;if(!(W instanceof Element)||W.closest(".route-container-panel-dock-tab__close")!=null)return;const J=W.closest("[data-route-container-panel-dock-tab-key]");if(!(J instanceof HTMLElement)||!D.contains(J))return;const te=J.dataset.routeContainerPanelDockTabKey;if(te==null||!$.current.some(nt=>nt.key===te))return;if(de.current===te&&((Le=(xe=U.current)==null?void 0:xe.activePanel)==null?void 0:Le.id)===te){ie("root pointerdown ignored",{reason:"already-active",tabKey:te});return}ie("root pointerdown capture",{activeTab:de.current,apiActivePanelId:(Ne=(Pe=U.current)==null?void 0:Pe.activePanel)==null?void 0:Ne.id,target:In(W),tabKey:te,visibleTabKeys:$.current.map(nt=>nt.key)}),Ve(te),(wi=(bi=U.current)==null?void 0:bi.getPanel(te))==null||wi.api.setActive(),window.setTimeout(()=>{var nt,Ci;ie("root pointerdown after tick",{activeTab:de.current,apiActivePanelId:(Ci=(nt=U.current)==null?void 0:nt.activePanel)==null?void 0:Ci.id,tabKey:te})},0)};return D.addEventListener("pointerdown",x,!0),()=>{D.removeEventListener("pointerdown",x,!0)}},[Ve]);const it=y.useCallback((D,x)=>{const A=$.current.find(J=>J.key===D),W=x??N.current.length;return A!=null&&i&&mr(A)&&N.current.includes(D)&&W>w},[i,w]),Ue=y.useCallback(()=>fi(null),[]),wt=y.useCallback((D,x)=>{const A=(p==null?void 0:p(x))??[],W=x.target==="tab"&&x.tab!=null&&x.isClosable?[{items:[{icon:"close",key:`route-container-panel:${x.panelKey??"panel"}:${x.tab.key}:close`,label:(n==null?void 0:n(at(x.tab)))??at(x.tab),onSelect:()=>{x.tab!=null&&x.closeTab(x.tab.key)}}],key:`route-container-panel:${x.panelKey??"panel"}:${x.tab.key}:default`}]:[],J=[...A,...W].filter(te=>te.items.length>0);J.length!==0&&(D.preventDefault(),D.stopPropagation(),window.dispatchEvent(new CustomEvent(Ht,{detail:{ownerId:z}})),fi({sections:J,x:D.clientX,y:D.clientY}))},[n,z,p]),Ln=y.useCallback(D=>{if(p==null)return;const x=D.target;if(!(x instanceof Element))return;const A=x.closest(".dv-tabs-and-actions-container, .route-container-panel-dock__empty-header"),W=x.closest(".route-container-panel-dock__content, .route-container-panel-dock__empty-content, .dv-content-container, .dv-view"),J=A instanceof HTMLElement&&D.currentTarget.contains(A),te=W instanceof HTMLElement&&D.currentTarget.contains(W);if(!J&&!te||x.closest([".dv-tab",".route-container-panel-dock-tab",".dv-pre-actions-container",".dv-right-actions-container",".ant-dropdown",".ant-select",".ant-input",'[contenteditable="true"]','[data-dock-panel-no-resize="true"]','[role="button"]',"a","button","input","select","textarea"].join(", "))!=null)return;const ye=U.current;wt(D,{activeTab:de.current,closeTab:$e,isActive:!1,isClosable:!1,isOpened:!1,openedTabs:N.current,panelKey:I,selectTab:xe=>{var Le;Ve(xe),(Le=ye==null?void 0:ye.getPanel(xe))==null||Le.api.setActive()},tabs:De,target:"blank",visibleTabs:$.current})},[De,p,wt,I,Ve]),Nn=y.useCallback(D=>{var x;U.current=D.api,Xe(),ie("ready begin sync",{activeTab:de.current,hasControlledLayout:pe!=null,panelKey:I,visibleTabKeys:$.current.map(A=>A.key)}),et();try{const A=pe??lr(G,$.current);A!=null&&D.api.fromJSON(A,{reuseExistingPanels:!0}),B.current=rt(A??null),be.current=Yi(A??null),pe==null&&A!=null&&(L==null||L(A)),Ft(D.api,$.current,de.current)}finally{tt(_t)}ie("ready end sync",{activePanelId:(x=D.api.activePanel)==null?void 0:x.id,panelKey:I,panelIds:D.api.panels.map(A=>A.id)}),window.requestAnimationFrame(qe),ce.current=[D.api.onDidActivePanelChange(A=>{if(ie("dock active panel change",{activeTab:de.current,isSyncing:O.current,panelId:A==null?void 0:A.id,visibleTabKeys:$.current.map(J=>J.key)}),O.current||A==null)return;const W=A.id;if(!$.current.some(J=>J.key===W)){ie("dock active panel ignored",{panelId:A.id,reason:"not-visible",visibleTabKeys:$.current.map(J=>J.key)});return}if(de.current===W){ie("dock active panel ignored",{panelId:A.id,reason:"already-active"});return}Ve(W),_t()}),D.api.onDidRemovePanel(A=>{O.current||!it(A.id)||$e(A.id)}),D.api.onDidLayoutChange(_t)]},[et,$e,pe,Xe,tt,it,qe,L,I,_t,Ve,G]),Wn=y.useCallback(({api:D,group:x,panel:A})=>{const W=Ke[A.id];if(W==null)return[];const J=it(W.key,x.panels.length),te={activeTab:de.current,closeTab:Pe=>$e(Pe),isActive:de.current===W.key,isClosable:J,isOpened:N.current.includes(W.key),selectTab:Pe=>{var Ne;Ve(Pe),(Ne=D.getPanel(Pe))==null||Ne.api.setActive()},tab:W},ye=(m==null?void 0:m(te))??[],xe=at(W),Le=J?[{label:(n==null?void 0:n(xe))??xe,action:()=>$e(W.key)}]:[];return[...ye,...Le]},[n,$e,m,it,Ve,Ke]);y.useEffect(()=>{var x;const D=U.current;if(!(D==null||pe==null)){if(be.current===Me){B.current=Ce;return}et(),ie("controlled layout replay begin",{controlledLayoutKeyLength:Ce.length,controlledLayoutStructureKeyLength:Me.length,panelKey:I,visibleTabKeys:$.current.map(A=>A.key)});try{D.fromJSON(pe,{reuseExistingPanels:!0}),Ft(D,$.current,de.current),B.current=Ce,be.current=Me}finally{tt()}ie("controlled layout replay end",{activePanelId:(x=D.activePanel)==null?void 0:x.id,panelKey:I,panelIds:D.panels.map(A=>A.id)}),window.requestAnimationFrame(qe)}},[et,pe,Ce,Me,tt,qe,I]);const _i=typeof navigator<"u"&&navigator.platform.includes("Mac"),Hn=y.useMemo(()=>_e==null?[]:ei({closeMenu:Ue,isMac:_i,sections:_e.sections}),[Ue,_e,_i]),Fn=y.useMemo(()=>_e==null?[]:ti(_e.sections),[_e]);y.useEffect(()=>{var A;const D=U.current;if(D==null||ee.length===0)return;const x=$.current;et(),ie("visible tabs sync begin",{activeTab:fe,panelKey:I,visibleTabKeys:x.map(W=>W.key)});try{Ft(D,x,fe)}finally{tt()}ie("visible tabs sync end",{activePanelId:(A=D.activePanel)==null?void 0:A.id,panelKey:I,panelIds:D.panels.map(W=>W.id)})},[et,fe,tt,I,le,ee.length]),y.useEffect(()=>{ee.length>0||(Xe(),U.current=null)},[Xe,ee.length]),y.useEffect(()=>{const D=S.current;if(D==null||typeof ResizeObserver>"u")return;let x=0,A=-1,W=-1;const J=()=>{x=0;const xe=U.current;if(xe==null)return;const Le=D.getBoundingClientRect(),Pe=Math.max(0,Math.round(Le.width)),Ne=Math.max(0,Math.round(Le.height));Pe<=0||Ne<=0||Pe===A&&Ne===W||(A=Pe,W=Ne,xe.layout(Pe,Ne))},te=()=>{x===0&&(x=window.requestAnimationFrame(J))},ye=new ResizeObserver(te);return ye.observe(D),te(),()=>{x!==0&&window.cancelAnimationFrame(x),ye.disconnect()}},[]),y.useEffect(()=>()=>{ve.current!=null&&window.clearTimeout(ve.current),Y.current!=null&&window.clearTimeout(Y.current),Xe()},[Xe]),y.useEffect(()=>{const D=x=>{const A=x.detail;(A==null?void 0:A.ownerId)!==z&&Ue()};return window.addEventListener(Ht,D),()=>{window.removeEventListener(Ht,D)}},[Ue,z]),y.useEffect(()=>{if(_e==null)return;const D=A=>{fr(A.target)||Ue()},x=A=>{A.key==="Escape"&&Ue()};return window.addEventListener("pointerdown",D,!0),window.addEventListener("keydown",x,!0),()=>{window.removeEventListener("pointerdown",D,!0),window.removeEventListener("keydown",x,!0)}},[Ue,_e]);const Bn=y.useMemo(()=>({activeTab:fe,closeLabel:n,closeTab:$e,closable:i,createMenuIcon:s,createMenuItems:l,createMenuLabel:a,createMenuSections:r,createMenuSelectedKeys:d,externalTabDrag:u,getHeaderActions:g,hasContextMenu:p!=null,headerActions:f,isTabClosable:it,minOpenTabs:w,openContextMenu:wt,openedTabs:ue,panelChromeActions:vt,panelKey:I,selectTab:Ve,tabs:De,tabByKey:Ke,visibleTabs:ee,onCreateMenuClick:F,onCreateMenuOpenChange:K}),[De,n,$e,i,s,l,a,r,d,u,fe,p,g,f,it,w,ue,wt,vt,I,Ve,Ke,ee,F,K]),$n=y.useMemo(()=>typeof h!="function"?h??null:h({activeTab:fe,openedTabs:ue,panelKey:I,tabs:P,visibleTabs:ee}),[h,fe,ue,I,P,ee]),Un=typeof document>"u"||_e==null?null:Kn.createPortal(H.jsx(ni,{overlayClassName:`${ii} route-container-panel-dock-context-dropdown`,menu:{expandIcon:mi(),items:Hn,selectedKeys:Fn,triggerSubMenuAction:"click"},open:!0,placement:"bottomLeft",trigger:[],transitionName:"ant-slide-down",onOpenChange:D=>{D||Ue()},children:H.jsx("span",{className:"route-container-panel-dock__context-anchor",style:{left:(_e==null?void 0:_e.x)??-9999,top:(_e==null?void 0:_e.y)??-9999}})}),document.body);return H.jsxs(En.Provider,{value:Bn,children:[Un,H.jsx("div",{ref:S,className:["route-container-panel-dock",`is-${v}`,"dockview-theme-light",ge?"is-external-drop-target":"",t].filter(Boolean).join(" "),role:"region","aria-label":e,"data-route-container-panel-dock-droppable":(u==null?void 0:u.droppable)===!0?"true":void 0,"data-route-container-panel-dock-scope":u==null?void 0:u.scope,"data-route-container-panel-dock-workspace-key":u==null?void 0:u.workspaceKey,onDragEnter:On,onDragOver:Rn,onDragLeave:Mn,onDrop:Vn,onContextMenuCapture:Ln,children:ee.length===0?H.jsxs("div",{className:"route-container-panel-dock__empty-shell",children:[H.jsxs("div",{className:"route-container-panel-dock__empty-header",children:[H.jsx(zn,{}),H.jsx("span",{className:"route-container-panel-dock__empty-tab-strip"}),H.jsx(Cr,{})]}),H.jsx("div",{className:"route-container-panel-dock__empty-content",children:$n})]}):H.jsx(Pn,{components:{[Gn]:gr},tabComponents:{[An]:vr},prefixHeaderActionsComponent:_r,rightHeaderActionsComponent:wr,disableFloatingGroups:c,noPanelsOverlay:"watermark",floatingGroupBounds:"boundedWithinViewport",onReady:Nn,getTabContextMenuItems:p==null?Wn:void 0})})]})}function Cr(){const{activeTab:o,getHeaderActions:e,headerActions:t,panelChromeActions:i,panelKey:n}=gt(),l=[...(e==null?void 0:e({activeTab:o,groupActiveTab:null,groupActiveTabKey:null,isTopRightGroup:!0,panelKey:n}))??t,...i];return H.jsx(kn,{actions:l})}export{Ar as D,Tr as R,Er as a};
|