dockview-core 6.3.0 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/dnd/backend.d.ts +70 -0
  3. package/dist/cjs/dnd/backend.js +171 -0
  4. package/dist/cjs/dnd/dropOverlay.d.ts +20 -0
  5. package/dist/cjs/dnd/dropOverlay.js +197 -0
  6. package/dist/cjs/dnd/droptarget.d.ts +20 -6
  7. package/dist/cjs/dnd/droptarget.js +14 -208
  8. package/dist/cjs/dnd/pointer/index.d.ts +11 -0
  9. package/dist/cjs/dnd/pointer/index.js +13 -0
  10. package/dist/cjs/dnd/pointer/longPress.d.ts +32 -0
  11. package/dist/cjs/dnd/pointer/longPress.js +151 -0
  12. package/dist/cjs/dnd/pointer/pointerDragController.d.ts +60 -0
  13. package/dist/cjs/dnd/pointer/pointerDragController.js +241 -0
  14. package/dist/cjs/dnd/pointer/pointerDragSource.d.ts +61 -0
  15. package/dist/cjs/dnd/pointer/pointerDragSource.js +195 -0
  16. package/dist/cjs/dnd/pointer/pointerDropTarget.d.ts +39 -0
  17. package/dist/cjs/dnd/pointer/pointerDropTarget.js +198 -0
  18. package/dist/cjs/dnd/pointer/pointerGhost.d.ts +30 -0
  19. package/dist/cjs/dnd/pointer/pointerGhost.js +44 -0
  20. package/dist/cjs/dnd/pointer/types.d.ts +16 -0
  21. package/dist/cjs/dnd/pointer/types.js +2 -0
  22. package/dist/cjs/dockview/components/panel/content.d.ts +3 -1
  23. package/dist/cjs/dockview/components/panel/content.js +33 -16
  24. package/dist/cjs/dockview/components/popupService.js +34 -0
  25. package/dist/cjs/dockview/components/tab/tab.d.ts +11 -3
  26. package/dist/cjs/dockview/components/tab/tab.js +151 -117
  27. package/dist/cjs/dockview/components/titlebar/tabGroupChip.d.ts +9 -2
  28. package/dist/cjs/dockview/components/titlebar/tabGroupChip.js +15 -6
  29. package/dist/cjs/dockview/components/titlebar/tabGroups.d.ts +33 -5
  30. package/dist/cjs/dockview/components/titlebar/tabGroups.js +231 -40
  31. package/dist/cjs/dockview/components/titlebar/tabs.d.ts +38 -1
  32. package/dist/cjs/dockview/components/titlebar/tabs.js +372 -251
  33. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +5 -3
  34. package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts +6 -2
  35. package/dist/cjs/dockview/components/titlebar/voidContainer.js +189 -27
  36. package/dist/cjs/dockview/contextMenu.js +19 -4
  37. package/dist/cjs/dockview/dndCapabilities.d.ts +19 -0
  38. package/dist/cjs/dockview/dndCapabilities.js +39 -0
  39. package/dist/cjs/dockview/dockviewComponent.d.ts +1 -0
  40. package/dist/cjs/dockview/dockviewComponent.js +54 -33
  41. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +9 -5
  42. package/dist/cjs/dockview/dockviewGroupPanelModel.js +25 -11
  43. package/dist/cjs/dockview/events.d.ts +2 -1
  44. package/dist/cjs/dockview/events.js +1 -0
  45. package/dist/cjs/dockview/options.d.ts +18 -3
  46. package/dist/cjs/dockview/options.js +1 -0
  47. package/dist/cjs/dom.js +7 -3
  48. package/dist/cjs/overlay/overlay.d.ts +12 -0
  49. package/dist/cjs/overlay/overlay.js +84 -16
  50. package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +3 -1
  51. package/dist/cjs/paneview/draggablePaneviewPanel.js +27 -26
  52. package/dist/cjs/paneview/options.d.ts +4 -3
  53. package/dist/dockview-core.js +2199 -834
  54. package/dist/dockview-core.min.js +2 -2
  55. package/dist/dockview-core.min.js.map +1 -1
  56. package/dist/dockview-core.min.noStyle.js +2 -2
  57. package/dist/dockview-core.min.noStyle.js.map +1 -1
  58. package/dist/dockview-core.noStyle.js +2202 -837
  59. package/dist/esm/dnd/backend.d.ts +70 -0
  60. package/dist/esm/dnd/backend.js +148 -0
  61. package/dist/esm/dnd/dropOverlay.d.ts +20 -0
  62. package/dist/esm/dnd/dropOverlay.js +192 -0
  63. package/dist/esm/dnd/droptarget.d.ts +20 -6
  64. package/dist/esm/dnd/droptarget.js +16 -210
  65. package/dist/esm/dnd/pointer/index.d.ts +11 -0
  66. package/dist/esm/dnd/pointer/index.js +5 -0
  67. package/dist/esm/dnd/pointer/longPress.d.ts +32 -0
  68. package/dist/esm/dnd/pointer/longPress.js +127 -0
  69. package/dist/esm/dnd/pointer/pointerDragController.d.ts +60 -0
  70. package/dist/esm/dnd/pointer/pointerDragController.js +191 -0
  71. package/dist/esm/dnd/pointer/pointerDragSource.d.ts +61 -0
  72. package/dist/esm/dnd/pointer/pointerDragSource.js +171 -0
  73. package/dist/esm/dnd/pointer/pointerDropTarget.d.ts +39 -0
  74. package/dist/esm/dnd/pointer/pointerDropTarget.js +168 -0
  75. package/dist/esm/dnd/pointer/pointerGhost.d.ts +30 -0
  76. package/dist/esm/dnd/pointer/pointerGhost.js +39 -0
  77. package/dist/esm/dnd/pointer/types.d.ts +16 -0
  78. package/dist/esm/dnd/pointer/types.js +1 -0
  79. package/dist/esm/dockview/components/panel/content.d.ts +3 -1
  80. package/dist/esm/dockview/components/panel/content.js +33 -16
  81. package/dist/esm/dockview/components/popupService.js +34 -0
  82. package/dist/esm/dockview/components/tab/tab.d.ts +11 -3
  83. package/dist/esm/dockview/components/tab/tab.js +139 -114
  84. package/dist/esm/dockview/components/titlebar/tabGroupChip.d.ts +9 -2
  85. package/dist/esm/dockview/components/titlebar/tabGroupChip.js +15 -6
  86. package/dist/esm/dockview/components/titlebar/tabGroups.d.ts +33 -5
  87. package/dist/esm/dockview/components/titlebar/tabGroups.js +177 -12
  88. package/dist/esm/dockview/components/titlebar/tabs.d.ts +38 -1
  89. package/dist/esm/dockview/components/titlebar/tabs.js +348 -227
  90. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +5 -3
  91. package/dist/esm/dockview/components/titlebar/voidContainer.d.ts +6 -2
  92. package/dist/esm/dockview/components/titlebar/voidContainer.js +179 -31
  93. package/dist/esm/dockview/contextMenu.js +19 -4
  94. package/dist/esm/dockview/dndCapabilities.d.ts +19 -0
  95. package/dist/esm/dockview/dndCapabilities.js +36 -0
  96. package/dist/esm/dockview/dockviewComponent.d.ts +1 -0
  97. package/dist/esm/dockview/dockviewComponent.js +55 -34
  98. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +9 -5
  99. package/dist/esm/dockview/dockviewGroupPanelModel.js +24 -11
  100. package/dist/esm/dockview/events.d.ts +2 -1
  101. package/dist/esm/dockview/events.js +1 -0
  102. package/dist/esm/dockview/options.d.ts +18 -3
  103. package/dist/esm/dockview/options.js +1 -0
  104. package/dist/esm/dom.js +7 -3
  105. package/dist/esm/overlay/overlay.d.ts +12 -0
  106. package/dist/esm/overlay/overlay.js +85 -17
  107. package/dist/esm/paneview/draggablePaneviewPanel.d.ts +3 -1
  108. package/dist/esm/paneview/draggablePaneviewPanel.js +26 -20
  109. package/dist/esm/paneview/options.d.ts +4 -3
  110. package/dist/package/main.cjs.js +2202 -837
  111. package/dist/package/main.cjs.min.js +2 -2
  112. package/dist/package/main.esm.min.mjs +2 -2
  113. package/dist/package/main.esm.mjs +2202 -837
  114. package/dist/styles/dockview.css +117 -1
  115. package/package.json +3 -1
  116. package/dist/cjs/dnd/abstractDragHandler.d.ts +0 -14
  117. package/dist/cjs/dnd/abstractDragHandler.js +0 -86
  118. package/dist/cjs/dnd/groupDragHandler.d.ts +0 -12
  119. package/dist/cjs/dnd/groupDragHandler.js +0 -104
  120. package/dist/esm/dnd/abstractDragHandler.d.ts +0 -14
  121. package/dist/esm/dnd/abstractDragHandler.js +0 -63
  122. package/dist/esm/dnd/groupDragHandler.d.ts +0 -12
  123. package/dist/esm/dnd/groupDragHandler.js +0 -81
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 6.3.0
3
+ * @version 6.5.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
7
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["dockview-core"]={})}(this,function(e){"use strict";class t{}class i extends t{constructor(e,t,i,s){super(),this.viewId=e,this.groupId=t,this.panelId=i,this.tabGroupId=s}}class s extends t{constructor(e,t){super(),this.viewId=e,this.paneId=t}}class o{constructor(){}static getInstance(){return o.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)}}function n(){const e=o.getInstance();if(e.hasData(i.prototype))return e.getData(i.prototype)[0]}function r(){const e=o.getInstance();if(e.hasData(s.prototype))return e.getData(s.prototype)[0]}var a;o.INSTANCE=new o,e.DockviewDisposable=void 0,(a=e.DockviewDisposable||(e.DockviewDisposable={})).NONE={dispose:()=>{}},a.from=function(e){return{dispose:()=>{e()}}};class h{get isDisposed(){return this._isDisposed}constructor(...e){this._isDisposed=!1,this._disposables=new Set(e)}addDisposables(...e){e.forEach(e=>this._disposables.add(e))}removeDisposable(e){this._disposables.delete(e)}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposables.forEach(e=>e.dispose()),this._disposables.clear())}}class l{constructor(){this._disposable=e.DockviewDisposable.NONE}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&(this._disposable.dispose(),this._disposable=e.DockviewDisposable.NONE)}}e.DockviewEvent=void 0,(e.DockviewEvent||(e.DockviewEvent={})).any=(...e)=>t=>{const i=e.map(e=>e(t));return{dispose:()=>{i.forEach(e=>{e.dispose()})}}};class d{constructor(){this._defaultPrevented=!1}get defaultPrevented(){return this._defaultPrevented}preventDefault(){this._defaultPrevented=!0}}class p{constructor(){this._isAccepted=!1}get isAccepted(){return this._isAccepted}accept(){this._isAccepted=!0}}class u{static create(){var e;return new u(null!==(e=(new Error).stack)&&void 0!==e?e:"")}constructor(e){this.value=e}print(){console.warn("dockview: stacktrace",this.value)}}class c{constructor(e,t){this.callback=e,this.stacktrace=t}}class m{static setLeakageMonitorEnabled(e){e!==m.ENABLE_TRACKING&&m.MEMORY_LEAK_WATCHER.clear(),m.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;(null===(t=this.options)||void 0===t?void 0:t.replay)&&void 0!==this._last&&e(this._last);const i=new c(e,m.ENABLE_TRACKING?u.create():void 0);return this._listeners.push(i),{dispose:()=>{const e=this._listeners.indexOf(i);e>-1?this._listeners.splice(e,1):m.ENABLE_TRACKING}}},m.ENABLE_TRACKING&&m.MEMORY_LEAK_WATCHER.add(this._event,u.create())),this._event}fire(e){var t;if(!(this._pauseTokens.size>0)){(null===(t=this.options)||void 0===t?void 0:t.replay)&&(this._last=e);for(const t of this._listeners)t.callback(e)}}pause(){const t={};return this._pauseTokens.add(t),e.DockviewDisposable.from(()=>this._pauseTokens.delete(t))}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&(m.ENABLE_TRACKING&&queueMicrotask(()=>{var e;for(const t of this._listeners)console.warn("dockview: stacktrace",null===(e=t.stacktrace)||void 0===e?void 0:e.print())}),this._listeners=[]),m.ENABLE_TRACKING&&this._event&&m.MEMORY_LEAK_WATCHER.delete(this._event))}}function v(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i,s)}}}m.ENABLE_TRACKING=!1,m.MEMORY_LEAK_WATCHER=new class{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 g{constructor(){this._onFired=new m,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 _ extends h{constructor(e){super(),this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this._value=null,this.addDisposables(this._onDidChange,f(e,e=>{const t=e.target.scrollWidth>e.target.clientWidth,i=e.target.scrollHeight>e.target.clientHeight;this._value={hasScrollX:t,hasScrollY:i},this._onDidChange.fire(this._value)}))}}function f(e,t){const i=new ResizeObserver(e=>{requestAnimationFrame(()=>{const i=e[0];t(i)})});return i.observe(e),{dispose:()=>{i.unobserve(e),i.disconnect()}}}const b=(e,...t)=>{for(const i of t)e.classList.contains(i)&&e.classList.remove(i)},w=(e,...t)=>{for(const i of t)e.classList.contains(i)||e.classList.add(i)},D=(e,t,i)=>{const s=e.classList.contains(t);i&&!s&&e.classList.add(t),!i&&s&&e.classList.remove(t)};function C(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function y(e){return new S(e)}class S extends h{constructor(e){super(),this._onDidFocus=new m,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new m,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=C(document.activeElement,e),i=!1;const s=()=>{i=!1,t||(t=!0,this._onDidFocus.fire())},o=()=>{t&&(i=!0,window.setTimeout(()=>{i&&(i=!1,t=!1,this._onDidBlur.fire())},0))};this._refreshStateHandler=()=>{C(document.activeElement,e)!==t&&(t?o():s())},this.addDisposables(v(e,"focus",s,!0)),this.addDisposables(v(e,"blur",o,!0))}refreshState(){this._refreshStateHandler()}}const x="dv-quasiPreventDefault";function G(e){return e[x]}function P(e){const{left:t,top:i,width:s,height:o}=e.getBoundingClientRect();return{left:t+window.scrollX,top:i+window.scrollY,width:s,height:o}}function A(e=document){const t=function(e){const t=[];return function i(s){if(s.nodeType===Node.ELEMENT_NODE){e.includes(s.tagName)&&t.push(s),s.shadowRoot&&i(s.shadowRoot);for(const e of s.children)i(e)}}(document.documentElement),t}(["IFRAME","WEBVIEW"]),i=new WeakMap;for(const e of t)i.set(e,e.style.pointerEvents),e.style.pointerEvents="none";return{release:()=>{var e;for(const s of t)s.style.pointerEvents=null!==(e=i.get(s))&&void 0!==e?e:"auto";t.splice(0,t.length)}}}class z{constructor(e){this.element=e,this._classNames=[]}setClassNames(e){for(const e of this._classNames)D(this.element,e,!1);this._classNames=e.split(" ").filter(e=>e.trim().length>0);for(const e of this._classNames)D(this.element,e,!0)}}function I(e,t){const i=P(e),s=P(t);return!(i.left<s.left)&&(!(i.left+i.width>s.left+s.width)&&(!(i.top<s.top)&&!(i.top+i.height>s.top+s.height)))}function T(e){let t=e;for(;t&&("auto"===t.style.zIndex||""===t.style.zIndex);)t=t.parentElement;return t}function E(e){if(0===e.length)throw new Error("Invalid tail call");return[e.slice(0,e.length-1),e[e.length-1]]}function O(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}function k(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.unshift(t))}function V(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.push(t))}function M(e,t){const i=e.findIndex(e=>e===t);return i>-1&&(e.splice(i,1),!0)}const L=(e,t,i)=>t>i?t:Math.min(i,Math.max(e,t)),N=()=>{let e=1;return{next:()=>(e++).toString()}},R=(e,t)=>{const i=[];if("number"!=typeof t&&(t=e,e=0),e<=t)for(let s=e;s<t;s++)i.push(s);else for(let s=e;s>t;s--)i.push(s);return i};class W{set size(e){this._size=e}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return void 0===this._cachedVisibleSize}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,s){this.container=e,this.view=t,this.disposable=s,this._cachedVisibleSize=void 0,"number"==typeof i?(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=L(null!==(i=this._cachedVisibleSize)&&void 0!==i?i:0,this.viewMinimumSize,this.viewMaximumSize),this._cachedVisibleSize=void 0):(this._cachedVisibleSize="number"==typeof t?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 H,F,$,B;e.Orientation=void 0,(H=e.Orientation||(e.Orientation={})).HORIZONTAL="HORIZONTAL",H.VERTICAL="VERTICAL",e.SashState=void 0,(F=e.SashState||(e.SashState={}))[F.MAXIMUM=0]="MAXIMUM",F[F.MINIMUM=1]="MINIMUM",F[F.DISABLED=2]="DISABLED",F[F.ENABLED=3]="ENABLED",e.LayoutPriority=void 0,($=e.LayoutPriority||(e.LayoutPriority={})).Low="low",$.High="high",$.Normal="normal",e.Sizing=void 0,(B=e.Sizing||(e.Sizing={})).Distribute={type:"distribute"},B.Split=function(e){return{type:"split",index:e}},B.Invisible=function(e){return{type:"invisible",cachedVisibleSize:e}};class U{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(t){this._orientation=t;const i=this.size;this.size=this.orthogonalSize,this.orthogonalSize=i,b(this.element,"dv-horizontal","dv-vertical"),this.element.classList.add(this.orientation==e.Orientation.HORIZONTAL?"dv-horizontal":"dv-vertical")}get minimumSize(){return this.viewItems.reduce((e,t)=>e+t.minimumSize,0)}get maximumSize(){return 0===this.length?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,D(this.element,"dv-splitview-disabled",e)}get margin(){return this._margin}set margin(e){this._margin=e,D(this.element,"dv-splitview-has-margin",0!==e)}constructor(t,i){var s,o;this.container=t,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 m,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new m,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new m,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(e,t,i=this.viewItems.map(e=>e.size),s,o,n=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY,a,h)=>{if(e<0||e>this.viewItems.length)return 0;const l=R(e,-1),d=R(e+1,this.viewItems.length);if(o)for(const e of o)k(l,e),k(d,e);if(s)for(const e of s)V(l,e),V(d,e);const p=l.map(e=>this.viewItems[e]),u=l.map(e=>i[e]),c=d.map(e=>this.viewItems[e]),m=d.map(e=>i[e]),v=l.reduce((e,t)=>e+this.viewItems[t].minimumSize-i[t],0),g=l.reduce((e,t)=>e+this.viewItems[t].maximumSize-i[t],0),_=0===d.length?Number.POSITIVE_INFINITY:d.reduce((e,t)=>e+i[t]-this.viewItems[t].minimumSize,0),f=0===d.length?Number.NEGATIVE_INFINITY:d.reduce((e,t)=>e+i[t]-this.viewItems[t].maximumSize,0),b=Math.max(v,f),w=Math.min(_,g);let D=!1;if(a){const e=this.viewItems[a.index],i=t>=a.limitDelta;D=i!==e.visible,e.setVisible(i,a.size)}if(!D&&h){const e=this.viewItems[h.index],i=t<h.limitDelta;D=i!==e.visible,e.setVisible(i,h.size)}if(D)return this.resize(e,t,i,s,o,n,r);let C=0,y=L(t,b,w);for(let e=0;e<p.length;e++){const t=p[e],i=L(u[e]+y,t.minimumSize,t.maximumSize),s=i-u[e];C+=s,y-=s,t.size=i}let S=C;for(let e=0;e<c.length;e++){const t=c[e],i=L(m[e]-S,t.minimumSize,t.maximumSize);S+=i-m[e],t.size=i}return t},this._orientation=null!==(s=i.orientation)&&void 0!==s?s:e.Orientation.VERTICAL,this.element=this.createContainer(),this.margin=null!==(o=i.margin)&&void 0!==o?o:0,this.proportionalLayout=void 0===i.proportionalLayout||!!i.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(i.styles),i.descriptor&&(this._size=i.descriptor.size,i.descriptor.views.forEach((e,t)=>{const i=void 0===e.visible||e.visible?e.size:{type:"invisible",cachedVisibleSize:e.size},s=e.view;this.addView(s,i,t,!0)}),this._contentSize=this.viewItems.reduce((e,t)=>e+t.size,0),this.saveProportions())}style(e){"transparent"===(null==e?void 0:e.separatorBorder)?(b(this.element,"dv-separator-border"),this.element.style.removeProperty("--dv-separator-border")):(w(this.element,"dv-separator-border"),(null==e?void 0: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(t,i){if(t<0||t>=this.viewItems.length)return;const s=R(this.viewItems.length).filter(e=>e!==t),o=[...s.filter(t=>this.viewItems[t].priority===e.LayoutPriority.Low),t],n=s.filter(t=>this.viewItems[t].priority===e.LayoutPriority.High),r=this.viewItems[t];i=Math.round(i),i=L(i,r.minimumSize,Math.min(r.maximumSize,this._size)),r.size=i,this.relayout(o,n)}getViews(){return this.viewItems.map(e=>e.view)}onDidChange(t,i){const s=this.viewItems.indexOf(t);if(s<0||s>=this.viewItems.length)return;i="number"==typeof i?i:t.size,i=L(i,t.minimumSize,t.maximumSize),t.size=i;const o=R(this.viewItems.length).filter(e=>e!==s),n=[...o.filter(t=>this.viewItems[t].priority===e.LayoutPriority.Low),s],r=o.filter(t=>this.viewItems[t].priority===e.LayoutPriority.High);this.relayout([...n,s],r)}addView(t,i={type:"distribute"},s=this.viewItems.length,o){const n=document.createElement("div");let r;n.className="dv-view",n.appendChild(t.element),r="number"==typeof i?i:"split"===i.type?this.getViewSize(i.index)/2:"invisible"===i.type?{cachedVisibleSize:i.cachedVisibleSize}:t.minimumSize;const a=t.onDidChange(e=>this.onDidChange(h,e.size)),h=new W(n,t,r,{dispose:()=>{a.dispose(),this.viewContainer.removeChild(n)}});if(s===this.viewItems.length?this.viewContainer.appendChild(n):this.viewContainer.insertBefore(n,this.viewContainer.children.item(s)),this.viewItems.splice(s,0,h),this.viewItems.length>1){const t=document.createElement("div");t.className="dv-sash";const i=i=>{for(const e of this.viewItems)e.enabled=!1;const s=A(),o=this._orientation===e.Orientation.HORIZONTAL?i.clientX:i.clientY,n=function(e,t){for(let i=0;i<e.length;i++)if(t(e[i]))return i;return-1}(this.sashes,e=>e.container===t),r=this.viewItems.map(e=>e.size);let a,h;const l=R(n,-1),d=R(n+1,this.viewItems.length),p=l.reduce((e,t)=>e+(this.viewItems[t].minimumSize-r[t]),0),u=l.reduce((e,t)=>e+(this.viewItems[t].viewMaximumSize-r[t]),0),c=0===d.length?Number.POSITIVE_INFINITY:d.reduce((e,t)=>e+(r[t]-this.viewItems[t].minimumSize),0),m=0===d.length?Number.NEGATIVE_INFINITY:d.reduce((e,t)=>e+(r[t]-this.viewItems[t].viewMaximumSize),0),v=Math.max(p,m),g=Math.min(c,u),_=this.findFirstSnapIndex(l),f=this.findFirstSnapIndex(d);if("number"==typeof _){const e=this.viewItems[_],t=Math.floor(e.viewMinimumSize/2);a={index:_,limitDelta:e.visible?v-t:v+t,size:e.size}}if("number"==typeof f){const e=this.viewItems[f],t=Math.floor(e.viewMinimumSize/2);h={index:f,limitDelta:e.visible?g+t:g-t,size:e.size}}const b=t=>{const i=(this._orientation===e.Orientation.HORIZONTAL?t.clientX:t.clientY)-o;this.resize(n,i,r,void 0,void 0,v,g,a,h),this.distributeEmptySpace(),this.layoutViews()},w=()=>{for(const e of this.viewItems)e.enabled=!0;s.release(),this.saveProportions(),document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",w),document.removeEventListener("pointercancel",w),document.removeEventListener("contextmenu",w),this._onDidSashEnd.fire(void 0)};document.addEventListener("pointermove",b),document.addEventListener("pointerup",w),document.addEventListener("pointercancel",w),document.addEventListener("contextmenu",w)};t.addEventListener("pointerdown",i);const s={container:t,disposable:()=>{t.removeEventListener("pointerdown",i),this.sashContainer.removeChild(t)}};this.sashContainer.appendChild(t),this.sashes.push(s)}o||this.relayout([s]),o||"number"==typeof i||"distribute"!==i.type||this.distributeViewSizes(),this._onDidAddView.fire(t)}distributeViewSizes(){const t=[];let i=0;for(const e of this.viewItems)e.maximumSize-e.minimumSize>0&&(t.push(e),i+=e.size);const s=Math.floor(i/t.length);for(const e of t)e.size=L(s,e.minimumSize,e.maximumSize);const o=R(this.viewItems.length),n=o.filter(t=>this.viewItems[t].priority===e.LayoutPriority.Low),r=o.filter(t=>this.viewItems[t].priority===e.LayoutPriority.High);this.relayout(n,r)}removeView(e,t,i=!1){const s=this.viewItems.splice(e,1)[0];if(s.dispose(),this.viewItems.length>=1){const t=Math.max(e-1,0);this.sashes.splice(t,1)[0].disposable()}return i||this.relayout(),t&&"distribute"===t.type&&this.distributeViewSizes(),this._onDidRemoveView.fire(s.view),s.view}getViewCachedVisibleSize(e){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");return this.viewItems[e].cachedVisibleSize}moveView(t,i){const s=this.getViewCachedVisibleSize(t),o=void 0===s?this.getViewSize(t):e.Sizing.Invisible(s),n=this.removeView(t,void 0,!0);this.addView(n,o,i)}layout(t,i){const s=Math.max(this.size,this._contentSize);if(this.size=t,this.orthogonalSize=i,this.proportions){let e=0;for(let i=0;i<this.viewItems.length;i++){const s=this.viewItems[i],o=this.proportions[i];"number"==typeof o?e+=o:t-=s.size}for(let i=0;i<this.viewItems.length;i++){const s=this.viewItems[i],o=this.proportions[i];"number"==typeof o&&e>0&&(s.size=L(Math.round(o*t/e),s.minimumSize,s.maximumSize))}}else{const i=R(this.viewItems.length),o=i.filter(t=>this.viewItems[t].priority===e.LayoutPriority.Low),n=i.filter(t=>this.viewItems[t].priority===e.LayoutPriority.High);this.resize(this.viewItems.length-1,t-s,void 0,o,n)}this.distributeEmptySpace(),this.layoutViews()}relayout(e,t){const i=this.viewItems.reduce((e,t)=>e+t.size,0);this.resize(this.viewItems.length-1,this._size-i,void 0,e,t),this.distributeEmptySpace(),this.layoutViews(),this.saveProportions()}distributeEmptySpace(t){const i=this.viewItems.reduce((e,t)=>e+t.size,0);let s=this.size-i;const o=R(this.viewItems.length-1,-1),n=o.filter(t=>this.viewItems[t].priority===e.LayoutPriority.Low),r=o.filter(t=>this.viewItems[t].priority===e.LayoutPriority.High);for(const e of r)k(o,e);for(const e of n)V(o,e);"number"==typeof t&&V(o,t);for(let e=0;0!==s&&e<o.length;e++){const t=this.viewItems[o[e]],i=L(t.size+s,t.minimumSize,t.maximumSize);s-=i-t.size,t.size=i}}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((e,t)=>e+t.size,0),this.updateSashEnablement(),0===this.viewItems.length)return;const t=this.viewItems.filter(e=>e.visible),i=Math.max(0,t.length-1),s=this.margin*i/Math.max(1,t.length);let o=0;const n=[],r=this.viewItems.reduce((e,t,i)=>{const s=t.visible?1:0;return 0===i?e.push(s):e.push(e[i-1]+s),e},[]);this.viewItems.forEach((t,a)=>{o+=this.viewItems[a].size,n.push(o);const h=t.visible?t.size-s:0,l=Math.max(0,r[a]-1),d=0===a||0===l?0:n[a-1]+l/i*s;if(a<this.viewItems.length-1){const i=t.visible?d+h-2+this.margin/2:d;this._orientation===e.Orientation.HORIZONTAL&&(this.sashes[a].container.style.left=`${i}px`,this.sashes[a].container.style.top="0px"),this._orientation===e.Orientation.VERTICAL&&(this.sashes[a].container.style.left="0px",this.sashes[a].container.style.top=`${i}px`)}this._orientation===e.Orientation.HORIZONTAL&&(t.container.style.width=`${h}px`,t.container.style.left=`${d}px`,t.container.style.top="",t.container.style.height=""),this._orientation===e.Orientation.VERTICAL&&(t.container.style.height=`${h}px`,t.container.style.top=`${d}px`,t.container.style.width="",t.container.style.left=""),t.view.layout(t.size-s,this._orthogonalSize)})}findFirstSnapIndex(e){for(const t of e){const e=this.viewItems[t];if(e.visible&&e.snap)return t}for(const t of e){const e=this.viewItems[t];if(e.visible&&e.maximumSize-e.minimumSize>0)return;if(!e.visible&&e.snap)return t}}updateSashEnablement(){let t=!1;const i=this.viewItems.map(e=>t=e.size-e.minimumSize>0||t);t=!1;const s=this.viewItems.map(e=>t=e.maximumSize-e.size>0||t),o=[...this.viewItems].reverse();t=!1;const n=o.map(e=>t=e.size-e.minimumSize>0||t).reverse();t=!1;const r=o.map(e=>t=e.maximumSize-e.size>0||t).reverse();let a=0;for(let t=0;t<this.sashes.length;t++){const o=this.sashes[t];a+=this.viewItems[t].size;const h=!(i[t]&&r[t+1]),l=!(s[t]&&n[t+1]);if(h&&l){const s=R(t,-1),r=R(t+1,this.viewItems.length),h=this.findFirstSnapIndex(s),l=this.findFirstSnapIndex(r),d="number"==typeof h&&!this.viewItems[h].visible,p="number"==typeof l&&!this.viewItems[l].visible;d&&n[t]&&(a>0||this.startSnappingEnabled)?this.updateSash(o,e.SashState.MINIMUM):p&&i[t]&&(a<this._contentSize||this.endSnappingEnabled)?this.updateSash(o,e.SashState.MAXIMUM):this.updateSash(o,e.SashState.DISABLED)}else h&&!l?this.updateSash(o,e.SashState.MINIMUM):!h&&l?this.updateSash(o,e.SashState.MAXIMUM):this.updateSash(o,e.SashState.ENABLED)}}updateSash(t,i){D(t.container,"dv-disabled",i===e.SashState.DISABLED),D(t.container,"dv-enabled",i===e.SashState.ENABLED),D(t.container,"dv-maximum",i===e.SashState.MAXIMUM),D(t.container,"dv-minimum",i===e.SashState.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 t=document.createElement("div"),i=this._orientation===e.Orientation.HORIZONTAL?"dv-horizontal":"dv-vertical";return t.className=`dv-split-view-container ${i}`,t}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 J=(()=>{const e={orientation:void 0,descriptor:void 0,proportionalLayout:void 0,styles:void 0,margin:void 0,disableAutoResizing:void 0,className:void 0};return Object.keys(e)})();class j extends h{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(t,i){var s;super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this._orientation=null!==(s=i.orientation)&&void 0!==s?s:e.Orientation.VERTICAL,this.element=document.createElement("div"),this.element.className="dv-pane-container",t.appendChild(this.element),this.splitview=new U(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:i.descriptor}),this.getPanes().forEach(e=>{const t=new h(e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),i={pane:e,disposable:{dispose:()=>{t.dispose()}}};this.paneItems.push(i),e.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,s=!1){const o=e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)}),n={pane:e,disposable:{dispose:()=>{o.dispose()}}};this.paneItems.splice(i,0,n),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,i,s)}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),w(this.element,"dv-animated"),this.animationTimer=setTimeout(()=>{this.animationTimer=void 0,b(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 Z{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===e.Orientation.HORIZONTAL?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===e.Orientation.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===e.Orientation.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===e.Orientation.HORIZONTAL?this.orthogonalSize:this.size}get height(){return this.orientation===e.Orientation.HORIZONTAL?this.size:this.orthogonalSize}constructor(t,i,s,o=0){this.view=t,this.orientation=i,this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this._orthogonalSize=s,this._size=o,this._disposable=this.view.onDidChange(t=>{t?this._onDidChange.fire({size:this.orientation===e.Orientation.VERTICAL?t.width:t.height,orthogonalSize:this.orientation===e.Orientation.VERTICAL?t.height:t.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 Y extends h{get width(){return this.orientation===e.Orientation.HORIZONTAL?this.size:this.orthogonalSize}get height(){return this.orientation===e.Orientation.HORIZONTAL?this.orthogonalSize:this.size}get minimumSize(){return 0===this.children.length?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===e.Orientation.HORIZONTAL?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===e.Orientation.HORIZONTAL?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumSize:this.maximumOrthogonalSize}get priority(){if(0===this.children.length)return e.LayoutPriority.Normal;const t=this.children.map(t=>void 0===t.priority?e.LayoutPriority.Normal:t.priority);return t.some(t=>t===e.LayoutPriority.High)?e.LayoutPriority.High:t.some(t=>t===e.LayoutPriority.Low)?e.LayoutPriority.Low:e.LayoutPriority.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 Y&&(t.margin=e)})}constructor(t,i,s,o,n,r,a,h){if(super(),this.orientation=t,this.proportionalLayout=i,this.styles=s,this._childrenDisposable=e.DockviewDisposable.NONE,this.children=[],this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new m,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._orthogonalSize=n,this._size=o,this.element=document.createElement("div"),this.element.className="dv-branch-node",h){const e={views:h.map(e=>({view:e.node,size:e.node.size,visible:!(e.node instanceof Z&&void 0!==e.visible)||e.visible})),size:this.orthogonalSize};this.children=h.map(e=>e.node),this.splitview=new U(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:i,styles:s,margin:a})}else this.splitview=new U(this.element,{orientation:this.orientation,proportionalLayout:i,styles:s,margin:a}),this.splitview.layout(this.size,this.orthogonalSize);this.disabled=r,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=0===this.splitview.contentSize;this.splitview.setViewVisible(e,t);const s=0===this.splitview.contentSize;(t&&i||!t&&s)&&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,s){if(i<0||i>this.children.length)throw new Error("Invalid index");this.splitview.addView(e,t,i,s),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 h(e.DockviewEvent.any(...this.children.map(e=>e.onDidChange))(e=>{this._onDidChange.fire({size:e.orthogonalSize})}),...this.children.map((t,i)=>t instanceof Y?t.onDidVisibilityChange(({visible:e})=>{this.setChildVisible(i,e)}):e.DockviewDisposable.NONE))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach(e=>e.dispose()),super.dispose()}}function X(e,t){if(e instanceof Z)return e;if(e instanceof Y)return X(e.children[t?e.children.length-1:0],t);throw new Error("invalid node")}function q(e,t,i){if(e instanceof Y){const s=new Y(e.orientation,e.proportionalLayout,e.styles,t,i,e.disabled,e.margin);for(let t=e.children.length-1;t>=0;t--){const i=e.children[t];s.addChild(q(i,i.size,i.orthogonalSize),i.size,0,!0)}return s}return new Z(e.view,e.orientation,i)}function K(e,t,i){if(e instanceof Y){const s=new Y(oe(e.orientation),e.proportionalLayout,e.styles,t,i,e.disabled,e.margin);let o=0;for(let n=e.children.length-1;n>=0;n--){const r=e.children[n],a=r instanceof Y?r.orthogonalSize:r.size;let h=0===e.size?0:Math.round(t*a/e.size);o+=h,0===n&&(h+=t-o),s.addChild(K(r,i,h),h,0,!0)}return s}return new Z(e.view,oe(e.orientation),i)}function Q(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");let i=t.firstElementChild,s=0;for(;i!==e&&i!==t.lastElementChild&&i;)i=i.nextElementSibling,s++;return s}function ee(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");if(/\bdv-grid-view\b/.test(t.className))return[];const i=Q(t);return[...ee(t.parentElement.parentElement.parentElement),i]}function te(e,t,i){if(se(e,t)===ie(i)){const[e,s]=E(t);let o=s;return"right"!==i&&"bottom"!==i||(o+=1),[...e,o]}{const e="right"===i||"bottom"===i?1:0;return[...t,e]}}function ie(t){return"top"===t||"bottom"===t?e.Orientation.VERTICAL:e.Orientation.HORIZONTAL}function se(e,t){return t.length%2==0?oe(e):e}const oe=t=>t===e.Orientation.HORIZONTAL?e.Orientation.VERTICAL:e.Orientation.HORIZONTAL;function ne(e){return!!e.children}const re=(t,i)=>{const s=i===e.Orientation.VERTICAL?t.box.width:t.box.height;return ne(t)?{type:"branch",data:t.children.map(e=>re(e,oe(i))),size:s}:"number"==typeof t.cachedVisibleSize?{type:"leaf",data:t.view.toJSON(),size:t.cachedVisibleSize,visible:!1}:{type:"leaf",data:t.view.toJSON(),size:s}};class ae{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=K(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 Y&&(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 null===(e=this._maximizedNode)||void 0===e?void 0:e.leaf.view}hasMaximizedView(){return void 0!==this._maximizedNode}maximizeView(e){var t;const i=ee(e.element),[s,o]=this.getNode(i);if(!(o instanceof Z))return;if((null===(t=this._maximizedNode)||void 0===t?void 0:t.leaf)===o)return;this.hasMaximizedView()&&this.exitMaximizedView(),re(this.getView(),this.orientation);const n=[];!function e(t,i){for(let s=0;s<t.children.length;s++){const o=t.children[s];o instanceof Z?o!==i&&(t.isChildVisible(s)?t.setChildVisible(s,!1):n.push(o)):e(o,i)}}(this.root,o),this._maximizedNode={leaf:o,hiddenOnMaximize:n},this._onDidMaximizedNodeChange.fire({view:o.view,isMaximized:!0})}exitMaximizedView(){if(!this._maximizedNode)return;const e=this._maximizedNode.hiddenOnMaximize;!function t(i){for(let s=i.children.length-1;s>=0;s--){const o=i.children[s];o instanceof Z?e.includes(o)||i.setChildVisible(s,!0):t(o)}}(this.root);const t=this._maximizedNode.leaf;this._maximizedNode=void 0,this._onDidMaximizedNodeChange.fire({view:t.view,isMaximized:!1})}serialize(){const e=this.maximizedView();let t;e&&(t=ee(e.element));const i=this._onDidMaximizedNodeChange.pause();try{this.hasMaximizedView()&&this.exitMaximizedView();const i={root:re(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation};return t&&(i.maximizedNode={location:t}),e&&this.maximizeView(e),i}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 Y(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize,this.locked,this.margin)}deserialize(t,i){const s=t.orientation,o=s===e.Orientation.VERTICAL?t.height:t.width;if(this._deserialize(t.root,s,i,o),this.layout(t.width,t.height),t.maximizedNode){const e=t.maximizedNode.location,[i,s]=this.getNode(e);if(!(s instanceof Z))return;this.maximizeView(s.view)}}_deserialize(e,t,i,s){this.root=this._deserializeNode(e,t,i,s)}_deserializeNode(e,t,i,s){var o;let n;if("branch"===e.type){const o=e.data.map(s=>({node:this._deserializeNode(s,oe(t),i,e.size),visible:s.visible}));n=new Y(t,this.proportionalLayout,this.styles,e.size,s,this.locked,this.margin,o)}else{const r=i.fromJSON(e);"boolean"==typeof e.visible&&(null===(o=r.setVisible)||void 0===o||o.call(r,e.visible)),n=new Z(r,t,s,e.size)}return n}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(e=>{this._onDidChange.fire(e)})}normalize(){if(!this._root)return;if(1!==this._root.children.length)return;const e=this.root,t=e.children[0];if(t instanceof Z)return;e.element.remove();const i=e.removeChild(0);e.dispose(),i.dispose(),this._root=q(t,t.size,t.orthogonalSize),this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}insertOrthogonalSplitviewAtRoot(){if(!this._root)return;const t=this.root;if(t.element.remove(),this._root=new Y(oe(t.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size,this.locked,this.margin),0===t.children.length);else if(1===t.children.length){const i=t.children[0];t.removeChild(0).dispose(),t.dispose(),this._root.addChild(K(i,i.orthogonalSize,i.size),e.Sizing.Distribute,0)}else this._root.addChild(t,e.Sizing.Distribute,0);this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}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 s={height:e.height,width:e.width};if(e instanceof Z)return{box:s,view:e.view,cachedVisibleSize:i};const o=[];for(let i=0;i<e.children.length;i++){const s=e.children[i],n=e.getChildCachedVisibleSize(i);o.push(this._getViews(s,oe(t),n))}return{box:s,children:o}}progmaticSelect(e,t=!1){const[i,s]=this.getNode(e);if(!(s instanceof Z))throw new Error("invalid location");for(let s=i.length-1;s>-1;s--){const o=i[s],n=e[s]||0;if(t?n-1>-1:n+1<o.children.length)return X(o.children[t?n-1:n+1],t)}return X(this.root,t)}constructor(e,t,i,s,o){this.proportionalLayout=e,this.styles=t,this._locked=!1,this._margin=0,this._maximizedNode=void 0,this.disposable=new l,this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this._onDidViewVisibilityChange=new m,this.onDidViewVisibilityChange=this._onDidViewVisibilityChange.event,this._onDidMaximizedNodeChange=new m,this.onDidMaximizedNodeChange=this._onDidMaximizedNodeChange.event,this.element=document.createElement("div"),this.element.className="dv-grid-view",this._locked=null!=s&&s,this._margin=null!=o?o:0,this.root=new Y(i,e,t,0,0,this.locked,this.margin)}isViewVisible(e){const[t,i]=E(e),[,s]=this.getNode(t);if(!(s instanceof Y))throw new Error("Invalid from location");return s.isChildVisible(i)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,s]=E(e),[,o]=this.getNode(i);if(!(o instanceof Y))throw new Error("Invalid from location");this._onDidViewVisibilityChange.fire(),o.setChildVisible(s,t)}moveView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[,s]=this.getNode(e);if(!(s instanceof Y))throw new Error("Invalid location");s.moveChild(t,i)}addView(t,i,s){this.hasMaximizedView()&&this.exitMaximizedView();const[o,n]=E(s),[r,a]=this.getNode(o);if(a instanceof Y){const e=new Z(t,oe(a.orientation),a.orthogonalSize);a.addChild(e,i,n)}else{const[s,...h]=[...r].reverse(),[l,...d]=[...o].reverse();let p=0;const u=s.getChildCachedVisibleSize(l);"number"==typeof u&&(p=e.Sizing.Invisible(u));s.removeChild(l).dispose();const c=new Y(a.orientation,this.proportionalLayout,this.styles,a.size,a.orthogonalSize,this.locked,this.margin);s.addChild(c,a.size,l);const m=new Z(a.view,s.orientation,a.size);c.addChild(m,p,0),"number"!=typeof i&&"split"===i.type&&(i={type:"split",index:0});const v=new Z(t,s.orientation,a.size);c.addChild(v,i,n)}}remove(e,t){const i=ee(e.element);return this.removeView(i,t)}removeView(t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[s,o]=E(t),[n,r]=this.getNode(s);if(!(r instanceof Y))throw new Error("Invalid location");const a=r.children[o];if(!(a instanceof Z))throw new Error("Invalid location");if(r.removeChild(o,i),a.dispose(),1!==r.children.length)return a.view;const h=r.children[0];if(0===n.length)return h instanceof Z||(r.removeChild(0,i),this.root=h),a.view;const[l,...d]=[...n].reverse(),[p,...u]=[...s].reverse(),c=r.isChildVisible(0);r.removeChild(0,i);const m=l.children.map((e,t)=>l.getChildSize(t));if(l.removeChild(p,i).dispose(),h instanceof Y){m.splice(p,1,...h.children.map(e=>e.size));for(let e=0;e<h.children.length;e++){const t=h.children[e];l.addChild(t,t.size,p+e)}for(;h.children.length>0;)h.removeChild(0)}else{const t=new Z(h.view,oe(h.orientation),h.size),i=c?h.orthogonalSize:e.Sizing.Invisible(h.orthogonalSize);l.addChild(t,i,p)}h.dispose();for(let e=0;e<m.length;e++)l.resizeChild(e,m[e]);return a.view}layout(t,i){const[s,o]=this.root.orientation===e.Orientation.HORIZONTAL?[i,t]:[t,i];this.root.layout(s,o)}getNode(e,t=this.root,i=[]){if(0===e.length)return[i,t];if(!(t instanceof Y))throw new Error("Invalid location");const[s,...o]=e;if(s<0||s>=t.children.length)throw new Error("Invalid location");const n=t.children[s];return i.push(t),this.getNode(o,n,i)}}const he=(()=>{const e={disableAutoResizing:void 0,proportionalLayout:void 0,orientation:void 0,hideBorders:void 0,className:void 0};return Object.keys(e)})();class le extends h{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(f(this._element,e=>{if(this.isDisposed)return;if(this.disableResizing)return;if(!this._element.offsetParent)return;if(!function(e){let t=e;for(;null==t?void 0:t.parentNode;){if(t.parentNode===document)return!0;t=t.parentNode instanceof DocumentFragment?t.parentNode.host:t.parentNode}return!1}(this._element))return;const t=Math.round(e.contentRect.width),i=Math.round(e.contentRect.height);t===this._lastWidth&&i===this._lastHeight||(this._lastWidth=t,this._lastHeight=i,this.layout(t,i))}))}}const de=N();function pe(e){switch(e){case"left":return"left";case"right":return"right";case"above":return"top";case"below":return"bottom";default:return"center"}}class ue extends le{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(t,i){var s;super(document.createElement("div"),i.disableAutoResizing),this._id=de.next(),this._groups=new Map,this._onDidRemove=new m,this.onDidRemove=this._onDidRemove.event,this._onDidAdd=new m,this.onDidAdd=this._onDidAdd.event,this._onDidMaximizedChange=new m,this.onDidMaximizedChange=this._onDidMaximizedChange.event,this._onDidActiveChange=new m,this.onDidActiveChange=this._onDidActiveChange.event,this._bufferOnDidLayoutChange=new g,this.onDidLayoutChange=this._bufferOnDidLayoutChange.onEvent,this._onDidViewVisibilityChangeMicroTaskQueue=new g,this.onDidViewVisibilityChangeMicroTaskQueue=this._onDidViewVisibilityChangeMicroTaskQueue.onEvent,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new z(this.element),this._classNames.setClassNames(null!==(s=i.className)&&void 0!==s?s:""),t.appendChild(this.element),this.gridview=new ae(!!i.proportionalLayout,i.styles,i.orientation,i.locked,i.margin),this.gridview.locked=!!i.locked,this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidMaximizedNodeChange(e=>{this._onDidMaximizedChange.fire({panel:e.view,isMaximized:e.isMaximized})}),this.gridview.onDidViewVisibilityChange(()=>this._onDidViewVisibilityChangeMicroTaskQueue.fire()),this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.forceRelayout()}),e.DockviewDisposable.from(()=>{var e;null===(e=this.element.parentElement)||void 0===e||e.removeChild(this.element)}),this.gridview.onDidChange(()=>{this._bufferOnDidLayoutChange.fire()}),e.DockviewEvent.any(this.onDidAdd,this.onDidRemove,this.onDidActiveChange)(()=>{this._bufferOnDidLayoutChange.fire()}),this._onDidMaximizedChange,this._onDidViewVisibilityChangeMicroTaskQueue,this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(ee(e.element),t),this._bufferOnDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(ee(e.element))}updateOptions(e){var t,i,s,o;e.proportionalLayout,e.orientation&&(this.gridview.orientation=e.orientation),"disableResizing"in e&&(this.disableResizing=null!==(t=e.disableAutoResizing)&&void 0!==t&&t),"locked"in e&&(this.locked=null!==(i=e.locked)&&void 0!==i&&i),"margin"in e&&(this.gridview.margin=null!==(s=e.margin)&&void 0!==s?s:0),"className"in e&&this._classNames.setClassNames(null!==(o=e.className)&&void 0!==o?o:"")}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(t,i=[0],s){this.gridview.addView(t,null!=s?s:e.Sizing.Distribute,i),this._onDidAdd.fire(t)}doRemoveGroup(t,i){if(!this._groups.has(t.id))throw new Error("invalid operation");const s=this._groups.get(t.id),o=this.gridview.remove(t,e.Sizing.Distribute);if(s&&!(null==i?void 0:i.skipDispose)&&(s.disposable.dispose(),s.value.dispose(),this._groups.delete(t.id),this._onDidRemove.fire(t)),!(null==i?void 0:i.skipActive)&&this._activeGroup===t){const e=Array.from(this._groups.values());this.doSetGroupActive(e.length>0?e[0].value:void 0)}return o}getPanel(e){var t;return null===(t=this._groups.get(e))||void 0===t?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=ee(e.group.element),s=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}moveToPrevious(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=ee(e.group.element),s=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}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 ce{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 me{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 ve{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 ge{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 _e extends h{constructor(e,t){super(),this.el=e,this.disabled=t,this.dataDisposable=new l,this.pointerEventsDisposable=new l,this._onDragStart=new m,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,v(this.el,"dragstart",e=>{if(e.defaultPrevented||this.isCancelled(e)||this.disabled)return void e.preventDefault();const t=A();if(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","")}}),v(this.el,"dragend",()=>{this.pointerEventsDisposable.dispose(),setTimeout(()=>{this.dataDisposable.dispose()},0)}))}}class fe extends h{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(v(this.element,"dragenter",e=>{this.onDragEnter(e)},!0)),this.addDisposables(v(this.element,"dragover",e=>{this.onDragOver(e)},!0)),this.addDisposables(v(this.element,"dragleave",e=>{this.onDragLeave(e)})),this.addDisposables(v(this.element,"dragend",e=>{this.onDragEnd(e)})),this.addDisposables(v(this.element,"drop",e=>{this.onDrop(e)}))}}class be extends d{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}constructor(e){super(),this.options=e}}function we(e){switch(e){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 '${e}'`)}}function De(e){switch(e){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 '${e}'`)}}const Ce={value:20,type:"percentage"},ye={value:50,type:"percentage"};class Se extends h{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 m,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new m,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(this.options.acceptedTargetZones),this.dnd=new fe(this.element,{onDragEnter:()=>{var e,t,i;null===(i=null===(t=(e=this.options).getOverrideTarget)||void 0===t?void 0:t.call(e))||void 0===i||i.getElements()},onDragOver:e=>{var t,i,s,o,n,r,a;Se.ACTUAL_TARGET=this;const h=null===(i=(t=this.options).getOverrideTarget)||void 0===i?void 0:i.call(t);if(0===this._acceptedTargetZonesSet.size){if(h)return;return void this.removeDropTarget()}const l=null!==(n=null===(o=(s=this.options).getOverlayOutline)||void 0===o?void 0:o.call(s))&&void 0!==n?n:this.element,d=l.offsetWidth,p=l.offsetHeight;if(0===d||0===p)return;const u=e.currentTarget.getBoundingClientRect(),c=(null!==(r=e.clientX)&&void 0!==r?r:0)-u.left,m=(null!==(a=e.clientY)&&void 0!==a?a:0)-u.top,v=this.calculateQuadrant(this._acceptedTargetZonesSet,c,m,d,p);if(this.isAlreadyUsed(e)||null===v)return void this.removeDropTarget();if(!this.options.canDisplayOverlay(e,v)){if(h)return;return void this.removeDropTarget()}const g=new be({nativeEvent:e,position:v});this._onWillShowOverlay.fire(g),g.defaultPrevented?this.removeDropTarget():(this.markAsUsed(e),h||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),l.classList.add("dv-drop-target"),l.append(this.targetElement)),this.toggleClasses(v,d,p),this._state=v)},onDragLeave:()=>{var e,t;(null===(t=(e=this.options).getOverrideTarget)||void 0===t?void 0:t.call(e))||this.removeDropTarget()},onDragEnd:e=>{var t,i;const s=null===(i=(t=this.options).getOverrideTarget)||void 0===i?void 0:i.call(t);s&&Se.ACTUAL_TARGET===this&&this._state&&(e.stopPropagation(),this._onDrop.fire({position:this._state,nativeEvent:e})),this.removeDropTarget(),null==s||s.clear()},onDrop:e=>{var t,i,s;e.preventDefault();const o=this._state;this.removeDropTarget(),null===(s=null===(i=(t=this.options).getOverrideTarget)||void 0===i?void 0:i.call(t))||void 0===s||s.clear(),o&&(e.stopPropagation(),this._onDrop.fire({position:o,nativeEvent:e}))}}),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[Se.USED_EVENT_ID]=!0}isAlreadyUsed(e){const t=e[Se.USED_EVENT_ID];return"boolean"==typeof t&&t}toggleClasses(e,t,i){var s,o,n,r,a,h,l,d,p,u,c;const m=null===(o=(s=this.options).getOverrideTarget)||void 0===o?void 0:o.call(s);if(!m&&!this.overlayElement)return;const v=t<(null!==(r=null===(n=this.options.overlayModel)||void 0===n?void 0:n.smallWidthBoundary)&&void 0!==r?r:100),g=i<(null!==(h=null===(a=this.options.overlayModel)||void 0===a?void 0:a.smallHeightBoundary)&&void 0!==h?h:100),_="left"===e,f="right"===e,b="top"===e,w="bottom"===e,C=!v&&f,y=!v&&_,S=!g&&b,x=!g&&w;let G=1;const P=null!==(d=null===(l=this.options.overlayModel)||void 0===l?void 0:l.size)&&void 0!==d?d:ye;if("percentage"===P.type?G=L(P.value,0,100)/100:((C||y)&&(G=L(0,P.value,t)/t),(S||x)&&(G=L(0,P.value,i)/i)),m){const s=null!==(c=null===(u=(p=this.options).getOverlayOutline)||void 0===u?void 0:u.call(p))&&void 0!==c?c:this.element,o=s.getBoundingClientRect(),n=m.getElements(void 0,s),r=n.root,a=n.overlay,h=r.getBoundingClientRect(),l=o.top-h.top,d=o.left-h.left,P={top:l,left:d,width:t,height:i};if(C?(P.left=d+t*(1-G),P.width=t*G):y?P.width=t*G:S?P.height=i*G:x&&(P.top=l+i*(1-G),P.height=i*G),v&&_&&(P.width=4),v&&f&&(P.left=d+t-4,P.width=4),g&&b&&(P.height=4),g&&w&&(P.top=l+i-4,P.height=4),!function(e,t){const{top:i,left:s,width:o,height:n}=t,r=`${Math.round(i)}px`,a=`${Math.round(s)}px`,h=`${Math.round(o)}px`,l=`${Math.round(n)}px`;return e.style.top!==r||e.style.left!==a||e.style.width!==h||e.style.height!==l}(a,P))return;return function(e,t){const{top:i,left:s,width:o,height:n}=t,r=`${Math.round(i)}px`,a=`${Math.round(s)}px`,h=`${Math.round(o)}px`,l=`${Math.round(n)}px`;e.style.top=r,e.style.left=a,e.style.width=h,e.style.height=l,e.style.visibility="visible",e.style.transform&&""!==e.style.transform||(e.style.transform="translate3d(0, 0, 0)")}(a,P),a.className="dv-drop-target-anchor"+(this.options.className?` ${this.options.className}`:""),D(a,"dv-drop-target-left",_),D(a,"dv-drop-target-right",f),D(a,"dv-drop-target-top",b),D(a,"dv-drop-target-bottom",w),D(a,"dv-drop-target-anchor-line",v&&(_||f)||g&&(b||w)),D(a,"dv-drop-target-center","center"===e),void(n.changed&&(D(a,"dv-drop-target-anchor-container-changed",!0),setTimeout(()=>{D(a,"dv-drop-target-anchor-container-changed",!1)},10)))}if(!this.overlayElement)return;const A={top:"0px",left:"0px",width:"100%",height:"100%"};C?(A.left=100*(1-G)+"%",A.width=100*G+"%"):y?A.width=100*G+"%":S?A.height=100*G+"%":x&&(A.top=100*(1-G)+"%",A.height=100*G+"%"),v&&_&&(A.width="4px"),v&&f&&(A.left=t-4+"px",A.width="4px"),g&&b&&(A.height="4px"),g&&w&&(A.top=i-4+"px",A.height="4px"),function(e,t){const{top:i,left:s,width:o,height:n}=t;e.style.top=i,e.style.left=s,e.style.width=o,e.style.height=n,e.style.visibility="visible",e.style.transform&&""!==e.style.transform||(e.style.transform="translate3d(0, 0, 0)")}(this.overlayElement,A);const z=v&&(_||f)||g&&(b||w);D(this.overlayElement,"dv-drop-target-small-vertical",g),D(this.overlayElement,"dv-drop-target-small-horizontal",v),D(this.overlayElement,"dv-drop-target-selection-line",z),D(this.overlayElement,"dv-drop-target-left",_),D(this.overlayElement,"dv-drop-target-right",f),D(this.overlayElement,"dv-drop-target-top",b),D(this.overlayElement,"dv-drop-target-bottom",w),D(this.overlayElement,"dv-drop-target-center","center"===e)}calculateQuadrant(e,t,i,s,o){var n,r;const a=null!==(r=null===(n=this.options.overlayModel)||void 0===n?void 0:n.activationSize)&&void 0!==r?r:Ce;return"percentage"===a.type?function(e,t,i,s,o,n){const r=100*t/s,a=100*i/o;if(e.has("left")&&r<n)return"left";if(e.has("right")&&r>100-n)return"right";if(e.has("top")&&a<n)return"top";if(e.has("bottom")&&a>100-n)return"bottom";if(!e.has("center"))return null;return"center"}(e,t,i,s,o,a.value):function(e,t,i,s,o,n){if(e.has("left")&&t<n)return"left";if(e.has("right")&&t>s-n)return"right";if(e.has("top")&&i<n)return"top";if(e.has("bottom")&&i>o-n)return"bottom";if(!e.has("center"))return null;return"center"}(e,t,i,s,o,a.value)}removeDropTarget(){var e;this.targetElement&&(this._state=void 0,null===(e=this.targetElement.parentElement)||void 0===e||e.classList.remove("dv-drop-target"),this.targetElement.remove(),this.targetElement=void 0,this.overlayElement=void 0)}}Se.USED_EVENT_ID="__dockview_droptarget_event_is_used__";const xe=(()=>{const e={disableAutoResizing:void 0,disableDnd:void 0,className:void 0};return Object.keys(e)})();class Ge extends p{constructor(e,t,i,s){super(),this.nativeEvent=e,this.position=t,this.getData=i,this.panel=s}}class Pe extends d{constructor(){super()}}class Ae extends h{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 l,this._onDidDimensionChange=new m,this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new m,this.onDidFocusChange=this._onDidChangeFocus.event,this._onWillFocus=new m,this.onWillFocus=this._onWillFocus.event,this._onDidVisibilityChange=new m,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onWillVisibilityChange=new m,this.onWillVisibilityChange=this._onWillVisibilityChange.event,this._onDidActiveChange=new m,this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new m,this.onActiveChange=this._onActiveChange.event,this._onDidParametersChange=new m,this.onDidParametersChange=this._onDidParametersChange.event,this.addDisposables(this.onDidFocusChange(e=>{this._isFocused=e.isFocused}),this.onDidActiveChange(e=>{this._isActive=e.isActive}),this.onDidVisibilityChange(e=>{this._isVisible=e.isVisible}),this.onDidDimensionsChange(e=>{this._width=e.width,this._height=e.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 ze extends Ae{constructor(e,t){super(e,t),this._onDidConstraintsChangeInternal=new m,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new m({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new m,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 Ie extends ze{set pane(e){this._pane=e}constructor(e,t){super(e,t),this._onDidExpansionChange=new m({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new m({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new m({}),this.onMouseLeave=this._onMouseLeave.event,this.addDisposables(this._onDidExpansionChange,this._onMouseEnter,this._onMouseLeave)}setExpanded(e){var t;null===(t=this._pane)||void 0===t||t.setExpanded(e)}get isExpanded(){var e;return!!(null===(e=this._pane)||void 0===e?void 0:e.isExpanded())}}class Te extends h{get element(){return this._element}get width(){return this._width}get height(){return this._height}get params(){var e;return null===(e=this._params)||void 0===e?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 s=y(this._element);this.addDisposables(this.api,s.onDidFocus(()=>{this.api._onDidChangeFocus.fire({isFocused:!0})}),s.onDidBlur(()=>{this.api._onDidChangeFocus.fire({isFocused:!1})}),s)}focus(){const e=new Pe;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({},null===(t=this._params)||void 0===t?void 0:t.params),e.params)});for(const t of Object.keys(e.params))void 0===e.params[t]&&delete this._params.params[t];null===(i=this.part)||void 0===i||i.update({params:this._params.params})}toJSON(){var e,t;const i=null!==(t=null===(e=this._params)||void 0===e?void 0:e.params)&&void 0!==t?t:{};return{id:this.id,component:this.component,params:Object.keys(i).length>0?i:void 0}}dispose(){var e;this.api.dispose(),null===(e=this.part)||void 0===e||e.dispose(),super.dispose()}}class Ee extends Te{set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){return this.headerSize+(this.isExpanded()?this._minimumBodySize:0)}get maximumSize(){return this.headerSize+(this.isExpanded()?this._maximumBodySize:0)}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="number"==typeof e?e:0}get maximumBodySize(){return this._maximumBodySize}set maximumBodySize(e){this._maximumBodySize="number"==typeof e?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 Ie(e.id,e.component)),this._onDidChangeExpansionState=new m({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new m,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(e=>{const{isVisible:t}=e,{accessor:i}=this._params;i.setVisible(this,t)}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({size:e.size})}),v(this.element,"mouseenter",e=>{this.api._onMouseEnter.fire(e)}),v(this.element,"mouseleave",e=>{this.api._onMouseLeave.fire(e)})),this.addDisposables(this._onDidChangeExpansionState,this.onDidChangeExpansionState(e=>{this.api._onDidExpansionChange.fire({isExpanded:e})}),this.api.onDidFocusChange(e=>{this.header&&(e.isFocused?w(this.header,"focused"):b(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 e;null===(e=this.body)||void 0===e||e.remove()},200),this._onDidChange.fire(e?{size:this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(t,i){this._size=t,this._orthogonalSize=i;const[s,o]=this.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];super.layout(s,o)}init(e){var t,i;super.init(e),"number"==typeof e.minimumBodySize&&(this.minimumBodySize=e.minimumBodySize),"number"==typeof e.maximumBodySize&&(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})),null===(t=this.body)||void 0===t||t.append(this.bodyPart.element),null===(i=this.header)||void 0===i||i.append(this.headerPart.element),"boolean"==typeof e.isExpanded&&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;null===(t=this.bodyPart)||void 0===t||t.update({params:e}),null===(i=this.headerPart)||void 0===i||i.update({params:e})},dispose:()=>{var e,t;null===(e=this.bodyPart)||void 0===e||e.dispose(),null===(t=this.headerPart)||void 0===t||t.dispose()}}}}class Oe extends Ee{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 m,this.onDidDrop=this._onDidDrop.event,this._onUnhandledDragOverEvent=new m,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 _e{getData(){return o.getInstance().setData([new s(t,e)],s.prototype),{dispose:()=>{o.getInstance().clearData(s.prototype)}}}}(this.header),this.target=new Se(this.element,{acceptedTargetZones:["top","bottom"],overlayModel:{activationSize:{type:"percentage",value:50}},canDisplayOverlay:(e,t)=>{const i=r();if(i&&i.paneId!==this.id&&i.viewId===this.accessor.id)return!0;const s=new Ge(e,t,r,this);return this._onUnhandledDragOverEvent.fire(s),s.isAccepted}}),this.addDisposables(this._onDidDrop,this.handler,this.target,this.target.onDrop(e=>{this.onDrop(e)}))}onDrop(e){const t=r();if(!t||t.viewId!==this.accessor.id)return void this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,api:new me(this.accessor),getData:r}));const i=this._params.containerApi,s=t.paneId,o=i.getPanel(s);if(!o)return void this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,getData:r,api:new me(this.accessor)}));const n=i.panels,a=n.indexOf(o);let h=i.panels.indexOf(this);"left"!==e.position&&"top"!==e.position||(h=Math.max(0,h-1)),"right"!==e.position&&"bottom"!==e.position||(a>h&&h++,h=Math.min(n.length-1,h)),i.movePanel(a,h)}}class ke extends h{get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this.disposable=new l,this._onDidFocus=new m,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new m,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 Se(this.element,{getOverlayOutline:()=>{var t;return"group"===(null===(t=e.options.theme)||void 0===t?void 0:t.dndPanelOverlay)?this.element.parentElement:null},className:"dv-drop-target-content",acceptedTargetZones:["top","bottom","left","right","center"],canDisplayOverlay:(e,t)=>{if("no-drop-target"===this.group.locked||this.group.locked&&"center"===t)return!1;const i=n();return!(!i&&e.shiftKey&&"floating"!==this.group.location.type)&&(!(!i||i.viewId!==this.accessor.id)||this.group.canDisplayOverlay(e,t,"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,s,o,n;const r=t.asActive||this.panel&&this.group.isPanelActive(this.panel);let a;switch(this.panel&&this.panel.view.content.element.parentElement===this._element&&(this._element.removeChild(this.panel.view.content.element),null===(s=(i=this.panel.view.content).onHide)||void 0===s||s.call(i)),this.panel=e,e.api.renderer){case"onlyWhenVisible":this.group.renderContainer.detatch(e),this.panel&&r&&(this._element.appendChild(this.panel.view.content.element),null===(n=(o=this.panel.view.content).onShow)||void 0===n||n.call(o)),a=this._element;break;case"always":e.view.content.element.parentElement===this._element&&this._element.removeChild(e.view.content.element),a=this.group.renderContainer.attach({panel:e,referenceContainer:this});break;default:throw new Error(`dockview: invalid renderer type '${e.api.renderer}'`)}if(r){const e=y(a);this.focusTracker=e;const t=new h;t.addDisposables(e,e.onDidFocus(()=>this._onDidFocus.fire()),e.onDidBlur(()=>this._onDidBlur.fire())),this.disposable.value=t}}openPanel(e){this.panel!==e&&this.renderPanel(e)}layout(e,t){}closePanel(){var e,t,i;this.panel&&"onlyWhenVisible"===this.panel.api.renderer&&(null===(e=this.panel.view.content.element.parentElement)||void 0===e||e.removeChild(this.panel.view.content.element),null===(i=(t=this.panel.view.content).onHide)||void 0===i||i.call(t)),this.panel=void 0}dispose(){this.disposable.dispose(),super.dispose()}refreshFocusState(){var e;(null===(e=this.focusTracker)||void 0===e?void 0:e.refreshState)&&this.focusTracker.refreshState()}}function Ve(e,t,i){var s,o;w(t,"dv-dragged"),t.style.top="-9999px",document.body.appendChild(t),e.setDragImage(t,null!==(s=null==i?void 0:i.x)&&void 0!==s?s:0,null!==(o=null==i?void 0:i.y)&&void 0!==o?o:0),setTimeout(()=>{b(t,"dv-dragged"),t.remove()},0)}class Me extends _e{constructor(e,t,i,s,n){super(e,n),this.accessor=t,this.group=i,this.panel=s,this.panelTransfer=o.getInstance()}getData(e){return this.panelTransfer.setData([new i(this.accessor.id,this.group.id,this.panel.id)],i.prototype),{dispose:()=>{this.panelTransfer.clearData(i.prototype)}}}}class Le extends h{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 m,this.onPointerDown=this._onPointDown.event,this._onTabClick=new m,this.onTabClick=this._onTabClick.event,this._onDropped=new m,this.onDrop=this._onDropped.event,this._onDragStart=new m,this.onDragStart=this._onDragStart.event,this._onDragEnd=new m,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,D(this.element,"dv-inactive-tab",!0),this.dragHandler=new Me(this._element,this.accessor,this.group,this.panel,!!this.accessor.options.disableDnd),this.dropTarget=new Se(this._element,{acceptedTargetZones:["left","right"],overlayModel:this._buildOverlayModel(),canDisplayOverlay:(e,t)=>{var i;if(this.group.locked)return!1;const s=n();return s&&this.accessor.id===s.viewId?"smooth"!==(null===(i=this.accessor.options.theme)||void 0===i?void 0:i.tabAnimation):this.group.model.canDisplayOverlay(e,t,"tab")},getOverrideTarget:()=>{var e;return null===(e=i.model.dropTargetContainer)||void 0===e?void 0:e.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(e=>{var t;if(e.dataTransfer){const t=getComputedStyle(this.element),i=this.element.cloneNode(!0),s="vertical"===this._direction,o=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(t).forEach(e=>{s&&o.has(e)||i.style.setProperty(e,t.getPropertyValue(e),t.getPropertyPriority(e))}),s&&(i.style.setProperty("writing-mode","horizontal-tb"),i.style.setProperty("width",t.height),i.style.setProperty("height",t.width)),i.style.position="absolute",i.classList.add("dv-tab-ghost-drag"),Ve(e.dataTransfer,i,{y:-10,x:30})}this._onDragStart.fire(e),"smooth"===(null===(t=this.accessor.options.theme)||void 0===t?void 0:t.tabAnimation)&&requestAnimationFrame(()=>{D(this.element,"dv-tab--dragging",!0)})}),v(this._element,"dragend",e=>{D(this.element,"dv-tab--dragging",!1),this._onDragEnd.fire(e)}),this.dragHandler,v(this._element,"pointerdown",e=>{this._onPointDown.fire(e)}),v(this._element,"click",e=>{this._onTabClick.fire(e)}),v(this._element,"contextmenu",e=>{this.accessor.contextMenuController.show(this.panel,this.group,e)}),this.dropTarget.onDrop(e=>{this._onDropped.fire(e)}),this.dropTarget)}setActive(e){D(this.element,"dv-active-tab",e),D(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="line"===(null===(e=this.accessor.options.theme)||void 0===e?void 0:e.dndTabIndicator)?Number.POSITIVE_INFINITY:0;return{activationSize:{value:50,type:"percentage"},smallWidthBoundary:t,smallHeightBoundary:t}}setDirection(e){this._direction=e,this.dropTarget.setTargetZones("vertical"===e?["top","bottom"]:["left","right"])}updateDragAndDropState(){this._element.draggable=!this.accessor.options.disableDnd,this.dragHandler.setDisabled(!!this.accessor.options.disableDnd)}}class Ne{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 Re extends _e{constructor(e,t,i,s){super(e,s),this.accessor=t,this.group=i,this.panelTransfer=o.getInstance(),this.addDisposables(v(e,"pointerdown",e=>{e.shiftKey&&(e[x]=!0)},!0))}isCancelled(e){return"floating"===this.group.api.location.type&&!e.shiftKey||"edge"===this.group.api.location.type&&0===this.group.size}getData(e){const t=e.dataTransfer;this.panelTransfer.setData([new i(this.accessor.id,this.group.id,null)],i.prototype);const s=window.getComputedStyle(this.el),o=s.getPropertyValue("--dv-activegroup-visiblepanel-tab-background-color"),n=s.getPropertyValue("--dv-activegroup-visiblepanel-tab-color");if(t){const e=this.accessor.options.createGroupDragGhostComponent;let i,s;if(e?(s=e(this.group),s.init({group:this.group,api:this.accessor.api}),i=s.element,i.style.position="absolute",i.style.pointerEvents="none",i.style.top="-9999px"):(i=document.createElement("div"),i.style.backgroundColor=o,i.style.color=n,i.style.padding="2px 8px",i.style.height="24px",i.style.fontSize="11px",i.style.lineHeight="20px",i.style.borderRadius="12px",i.style.position="absolute",i.style.pointerEvents="none",i.style.top="-9999px",i.textContent=`Multiple Panels (${this.group.size})`),Ve(t,i,{y:-10,x:30}),null==s?void 0:s.dispose){const e=s;setTimeout(()=>{var t;return null===(t=e.dispose)||void 0===t?void 0:t.call(e)},0)}}return{dispose:()=>{this.panelTransfer.clearData(i.prototype)}}}}class We extends h{get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this._onDrop=new m,this.onDrop=this._onDrop.event,this._onDragStart=new m,this.onDragStart=this._onDragStart.event,this._element=document.createElement("div"),this._element.className="dv-void-container",this._element.draggable=!this.accessor.options.disableDnd,D(this._element,"dv-draggable",!this.accessor.options.disableDnd),this.addDisposables(this._onDrop,this._onDragStart,v(this._element,"pointerdown",()=>{this.accessor.doSetGroupActive(this.group)})),this.handler=new Re(this._element,e,t,!!this.accessor.options.disableDnd),this.dropTarget=new Se(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:(e,i)=>{if(this.group.api.locked)return!1;const s=n();return!(!s||this.accessor.id!==s.viewId)||t.model.canDisplayOverlay(e,i,"header_space")},getOverrideTarget:()=>{var e;return null===(e=t.model.dropTargetContainer)||void 0===e?void 0:e.model}}),this.onWillShowOverlay=this.dropTarget.onWillShowOverlay,this.addDisposables(this.handler,this.handler.onDragStart(e=>{this._onDragStart.fire(e)}),this.dropTarget.onDrop(e=>{this._onDrop.fire(e)}),this.dropTarget)}updateDragAndDropState(){this._element.draggable=!this.accessor.options.disableDnd,D(this._element,"dv-draggable",!this.accessor.options.disableDnd),this.handler.setDisabled(!!this.accessor.options.disableDnd)}}class He extends h{get element(){return this._element}get orientation(){return this._orientation}set orientation(e){this._orientation!==e&&(this._scrollOffset=0,this._orientation=e,b(this._scrollbar,"dv-scrollbar-vertical","dv-scrollbar-horizontal"),w(this._scrollbar,"vertical"===e?"dv-scrollbar-vertical":"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(v(this.element,"wheel",e=>{this._scrollOffset+=e.deltaY*He.MouseWheelSpeed,this.calculateScrollbarStyles()}),v(this._scrollbar,"pointerdown",e=>{e.preventDefault(),D(this.element,"dv-scrollable-scrolling",!0);const t="horizontal"===this._orientation?e.clientX:e.clientY,i=this._scrollOffset,s=e=>{const s="horizontal"===this._orientation?e.clientX-t:e.clientY-t,o=("horizontal"===this._orientation?this.element.clientWidth:this.element.clientHeight)/("horizontal"===this._orientation?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight);this._scrollOffset=i+s/o,this.calculateScrollbarStyles()},o=()=>{D(this.element,"dv-scrollable-scrolling",!1),document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",o),document.removeEventListener("pointercancel",o)};document.addEventListener("pointermove",s),document.addEventListener("pointerup",o),document.addEventListener("pointercancel",o)}),v(this.element,"scroll",()=>{this.calculateScrollbarStyles()}),v(this.scrollableElement,"scroll",()=>{this._scrollOffset="horizontal"===this._orientation?this.scrollableElement.scrollLeft:this.scrollableElement.scrollTop,this.calculateScrollbarStyles()}),f(this.element,()=>{D(this.element,"dv-scrollable-resizing",!0),this._animationTimer&&clearTimeout(this._animationTimer),this._animationTimer=setTimeout(()=>{clearTimeout(this._animationTimer),D(this.element,"dv-scrollable-resizing",!1)},500),this.calculateScrollbarStyles()}))}calculateScrollbarStyles(){const e="horizontal"===this._orientation?this.element.clientWidth:this.element.clientHeight,t="horizontal"===this._orientation?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight;if(t>e){const i=e*(e/t);"horizontal"===this._orientation?(this._scrollbar.style.width=`${i}px`,this._scrollbar.style.height=""):(this._scrollbar.style.height=`${i}px`,this._scrollbar.style.width=""),this._scrollOffset=L(this._scrollOffset,0,t-e),"horizontal"===this._orientation?this.scrollableElement.scrollLeft=this._scrollOffset:this.scrollableElement.scrollTop=this._scrollOffset;const s=this._scrollOffset/(t-e);"horizontal"===this._orientation?(this._scrollbar.style.left=(e-i)*s+"px",this._scrollbar.style.top=""):(this._scrollbar.style.top=(e-i)*s+"px",this._scrollbar.style.left="")}else"horizontal"===this._orientation?(this._scrollbar.style.width="0px",this._scrollbar.style.left="0px"):(this._scrollbar.style.height="0px",this._scrollbar.style.top="0px"),this._scrollOffset=0}}He.MouseWheelSpeed=1;const Fe=[{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 $e{constructor(e,t=!0){this._entries=e.slice(),this._byId=new Map(e.map(e=>[e.id,e])),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(e=>[e.id,e]))}entries(){return this._entries}has(e){return this._byId.has(e)}get(e){return this._byId.get(e)}defaultId(){var e;return null===(e=this._entries[0])||void 0===e?void 0:e.id}resolveValue(e){if(!this._enabled||!e)return;const t=this._byId.get(e);return t?t.value:e}}let Be;function Ue(){return Be||(Be=new $e(Fe,!0)),Be}function Je(e,t,i){const s=(null!=i?i:Ue()).resolveValue(t);void 0===s?e.style.removeProperty("--dv-tab-group-color"):e.style.setProperty("--dv-tab-group-color",s)}function je(e,t){return(null!=t?t:Ue()).resolveValue(e)}class Ze extends h{get element(){return this._element}constructor(e){super(),this._palette=e,this._onClick=new m,this.onClick=this._onClick.event,this._onContextMenu=new m,this.onContextMenu=this._onContextMenu.event,this._onDragStart=new m,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,v(this._element,"click",e=>{this._onClick.fire(e)}),v(this._element,"contextmenu",e=>{this._onContextMenu.fire(e)}),v(this._element,"dragstart",e=>{this._onDragStart.fire(e)}))}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(e=>{this.updateCollapsed(e)}),this._onClick.event(()=>{var e;null===(e=this._tabGroup)||void 0===e||e.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;Je(this._element,e,this._palette),D(this._element,"dv-tab-group-chip--accent-off",!1===(null===(t=this._palette)||void 0===t?void 0:t.enabled))}updateLabel(e){this._label.textContent=e,D(this._label,"dv-tab-group-chip-label--empty",!e)}updateCollapsed(e){D(this._element,"dv-tab-group-chip--collapsed",e)}}class Ye{get underlines(){return this._underlines}constructor(e){this._ctx=e,this._underlines=new Map,this._rafId=null}positionUnderlines(){requestAnimationFrame(()=>{this._positionUnderlinesSync()})}trackUnderlines(){null!==this._rafId&&cancelAnimationFrame(this._rafId);const e=performance.now(),t=()=>{this._positionUnderlinesSync(),performance.now()-e<250?this._rafId=requestAnimationFrame(t):this._rafId=null};this._rafId=requestAnimationFrame(t)}syncUnderlineElements(e){for(const t of e)if(!this._underlines.has(t)){const e=document.createElement("div");e.className="dv-tab-group-underline",this._ctx.tabsList.appendChild(e),this._underlines.set(t,e)}for(const[t,i]of this._underlines)e.has(t)||(i.remove(),this._underlines.delete(t))}getUnderline(e){return this._underlines.get(e)}dispose(){null!==this._rafId&&(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="vertical"===this._ctx.getDirection(),s=i?e.width:e.height,o=this._ctx.getActivePanelId(),n=this._ctx.getTabMap();for(const r of t){const t=this._underlines.get(r.id);if(!t)continue;const a=r.panelIds;if(0===a.length){t.style.display="none";continue}t.style.display="";const h=this._ctx.getChipElement(r.id);let l;if(h){const t=h.getBoundingClientRect(),s=getComputedStyle(h),o=i?Number.parseFloat(s.marginTop)||0:Number.parseFloat(s.marginLeft)||0;l=i?t.top-e.top-o:t.left-e.left-o}else{const t=a[0],s=n.get(t);if(s){const t=s.value.element.getBoundingClientRect();l=i?t.top-e.top:t.left-e.left}else l=0}const d=a[a.length-1],p=n.get(d);if(!p){i?(t.style.top=`${l}px`,t.style.height="0px",t.style.left="",t.style.width=""):(t.style.left=`${l}px`,t.style.width="0px",t.style.top="",t.style.height="");continue}const u=p.value.element.getBoundingClientRect();let c=i?u.bottom-e.top:u.right-e.left,m=c-l;if((r.collapsed||r.panelIds.some(e=>{const t=n.get(e);return t&&t.value.element.classList.contains("dv-tab--group-expanding")}))&&h){const t=h.getBoundingClientRect(),s=i?t.top+t.height/2-e.top:t.left+t.width/2-e.left;let o=0,a=0;for(const e of r.panelIds){const t=n.get(e);if(!t)continue;const s=t.value.element;i?(o+=s.getBoundingClientRect().height,a+=s.scrollHeight):(o+=s.getBoundingClientRect().width,a+=s.scrollWidth)}const d=a>0?Math.min(1,o/a):0;l=s+(l-s)*d,c=s+(c-s)*d,m=Math.max(0,c-l)}i?(t.style.top=`${l}px`,t.style.height=`${Math.max(0,m)}px`,t.style.left="",t.style.width=""):(t.style.left=`${l}px`,t.style.width=`${Math.max(0,m)}px`,t.style.top="",t.style.height=""),this.applyShape(t,r,l,m,s,o,e,i)}}}class Xe extends Ye{_applyStraightLine(e,t,i,s,o,n){n?(e.setAttribute("width",String(s)),e.setAttribute("height",String(o)),i.style.width=`${s}px`,i.style.height=`${o}px`,t.setAttribute("d",`M ${s/2},0 L ${s/2},${o}`)):(e.setAttribute("width",String(o)),e.setAttribute("height",String(s)),i.style.width=`${o}px`,i.style.height=`${s}px`,t.setAttribute("d",`M 0,${s/2} L ${o},${s/2}`))}applyShape(e,t,i,s,o,n,r,a){const h=o,l=s,d=je(t.color,this._ctx.getColorPalette());if(l<=0||h<=0||void 0===d)return void(e.style.display="none");let p;e.style.display="",n&&t.panelIds.includes(n)&&(p=this._ctx.getTabMap().get(n));let u,c=e.firstElementChild;if(c&&"svg"===c.tagName?u=c.firstElementChild:(e.replaceChildren(),c=document.createElementNS("http://www.w3.org/2000/svg","svg"),c.style.display="block",u=document.createElementNS("http://www.w3.org/2000/svg","path"),u.setAttribute("fill","none"),c.appendChild(u),e.appendChild(c)),u.setAttribute("stroke",d),u.setAttribute("stroke-width",String(2)),!p)return void this._applyStraightLine(c,u,e,2,l,a);const m=p.value.element.getBoundingClientRect();let v,g;if(a?(v=Math.max(0,m.top-r.top-i),g=Math.min(l,m.bottom-r.top-i)):(v=Math.max(0,m.left-r.left-i),g=Math.min(l,m.right-r.left-i)),g<=v)return void this._applyStraightLine(c,u,e,2,l,a);if(a){const t=h,i=l;c.setAttribute("width",String(t)),c.setAttribute("height",String(i)),e.style.width=`${t}px`,e.style.height=`${i}px`;const s=1,o=t-1,n=[`M ${s},0`,`L ${s},${v-6}`,`Q ${s},${v} ${s+6},${v}`,`L ${o-6},${v}`,`Q ${o},${v} ${o},${v+6}`,`L ${o},${g-6}`,`Q ${o},${g} ${o-6},${g}`,`L ${s+6},${g}`,`Q ${s},${g} ${s},${g+6}`,`L ${s},${i}`].join(" ");u.setAttribute("d",n)}else{const t=l,i=h;c.setAttribute("width",String(t)),c.setAttribute("height",String(i)),e.style.width=`${t}px`,e.style.height=`${i}px`;const s=i-1,o=1,n=[`M 0,${s}`,`L ${v-6},${s}`,`Q ${v},${s} ${v},${s-6}`,`L ${v},${o+6}`,`Q ${v},${o} ${v+6},${o}`,`L ${g-6},${o}`,`Q ${g},${o} ${g},${o+6}`,`L ${g},${s-6}`,`Q ${g},${s} ${g+6},${s}`,`L ${t},${s}`].join(" ");u.setAttribute("d",n)}}}class qe extends Ye{applyShape(e,t,i,s,o,n,r,a){const h=je(t.color,this._ctx.getColorPalette());s<=0||void 0===h?e.style.display="none":(e.style.display="",e.firstElementChild&&e.replaceChildren(),e.style.backgroundColor=h,a?(e.style.width="2px",e.style.height=`${s}px`):(e.style.width=`${s}px`,e.style.height="2px"))}}const Ke=new Map;class Qe{get chipRenderers(){return this._chipRenderers}get groupUnderlines(){var e,t;return null!==(t=null===(e=this._indicator)||void 0===e?void 0:e.underlines)&&void 0!==t?t:Ke}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 e=this._ctx.group.model.getTabGroups(),t=new Set;for(const i of e)t.add(i.id),this._ensureChipForGroup(i),this._positionChipForGroup(i);for(const[e,i]of this._chipRenderers)t.has(e)||(i.chip.element.remove(),i.chip.dispose(),i.disposable.dispose(),this._chipRenderers.delete(e));this._updateTabGroupClasses()}refreshAccents(){var e,t;for(const i of this._ctx.group.model.getTabGroups()){const s=this._chipRenderers.get(i.id);null===(t=null==s?void 0:(e=s.chip).update)||void 0===t||t.call(e,{tabGroup:i})}this._updateTabGroupClasses()}positionAllChips(){if(0!==this._chipRenderers.size)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;null===(e=this._indicator)||void 0===e||e.positionUnderlines()}trackUnderlines(){var e;null===(e=this._indicator)||void 0===e||e.trackUnderlines()}setGroupDragImage(e,t,i){if(!e.dataTransfer)return;const s="vertical"===this._ctx.getDirection(),o=this._ctx.tabsList.cloneNode(!0);s?(o.classList.remove("dv-tabs-container-vertical","dv-vertical"),o.classList.add("dv-horizontal"),o.style.writingMode="horizontal-tb",o.style.height=`${this._ctx.tabsList.offsetWidth}px`):o.style.height=`${this._ctx.tabsList.offsetHeight}px`,o.style.width="auto",o.style.overflow="visible",o.style.pointerEvents="none";const n=Array.from(o.children),r=Array.from(this._ctx.tabsList.children);for(let e=n.length-1;e>=0;e--){r[e]!==i&&n[e].remove()}const a=document.createElement("div");a.className="dv-groupview dv-active-group",a.style.position="fixed",a.style.top="-10000px",a.style.left="0px",a.style.height="auto",a.style.width="auto",a.style.pointerEvents="none";const h=document.createElement("div");h.className="dv-tabs-and-actions-container",h.style.height="auto",h.style.width="auto",a.appendChild(h),h.appendChild(o),this._ctx.accessor.element.appendChild(a);const l=o.querySelector(".dv-tab-group-chip"),d=i.getBoundingClientRect(),p=e.clientX-d.left,u=e.clientY-d.top;if(l){const t=l.getBoundingClientRect(),i=a.getBoundingClientRect(),s=t.left-i.left+p,o=t.top-i.top+u;e.dataTransfer.setDragImage(a,s,o)}else e.dataTransfer.setDragImage(a,p,u);requestAnimationFrame(()=>{a.remove()})}cleanupTransition(e){var t;null===(t=this._pendingTransitionCleanups.get(e))||void 0===t||t(),this._pendingTransitionCleanups.delete(e)}disposeAll(){var e;null===(e=this._indicator)||void 0===e||e.dispose(),this._indicator=null;for(const[,e]of this._pendingTransitionCleanups)e();this._pendingTransitionCleanups.clear();for(const[,e]of this._chipRenderers)e.chip.element.remove(),e.chip.dispose(),e.disposable.dispose();this._chipRenderers.clear()}_ensureIndicator(){var e,t;const i="none"===(null!==(t=null===(e=this._ctx.accessor.options.theme)||void 0===e?void 0:e.tabGroupIndicator)&&void 0!==t?t:"wrap")?qe:Xe;!this._indicator||this._indicator instanceof i||(this._indicator.dispose(),this._indicator=null),this._indicator||(this._indicator=new i({tabsList:this._ctx.tabsList,getTabGroups:()=>this._ctx.group.model.getTabGroups(),getActivePanelId:()=>{var e;return null===(e=this._ctx.group.activePanel)||void 0===e?void 0:e.id},getTabMap:()=>this._ctx.getTabMap(),getChipElement:e=>{var t;return null===(t=this._chipRenderers.get(e))||void 0===t?void 0:t.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 Ze(this._ctx.accessor.tabGroupColorPalette);i.init({tabGroup:e,api:this._ctx.accessor.api});const s=[e.onDidChange(()=>{var t;null===(t=i.update)||void 0===t||t.call(i,{tabGroup:e}),this._updateTabGroupClasses()}),e.onDidPanelChange(()=>{this._positionChipForGroup(e),this._updateTabGroupClasses()}),e.onDidCollapseChange(()=>{this._updateTabGroupClasses()})];i instanceof Ze?s.push(i.onContextMenu(t=>{this._callbacks.onChipContextMenu(e,t)}),i.onDragStart(t=>{this._callbacks.onChipDragStart(e,i,t)})):s.push(v(i.element,"contextmenu",t=>{this._callbacks.onChipContextMenu(e,t)}),v(i.element,"dragstart",t=>{this._callbacks.onChipDragStart(e,i,t)}));const o=new h(...s);this._chipRenderers.set(e.id,{chip:i,disposable:o}),e.collapsed&&(this._skipNextCollapseAnimation=!0)}_positionChipForGroup(e){const t=this._chipRenderers.get(e.id);if(!t)return;const i=t.chip.element,s=e.panelIds;if(0===s.length)return void i.remove();const o=s[0],n=this._ctx.getTabMap().get(o);if(!n)return void i.remove();const r=n.value.element;i.nextSibling!==r&&this._ctx.tabsList.insertBefore(i,r)}_updateTabGroupClasses(){var e;const t=this._ctx.group.model.getTabGroups(),i=this._ctx.getTabs(),s=this._ctx.getTabMap();let o=!1;const n=new Map;for(const e of t)for(const t of e.panelIds)n.set(t,e);for(const t of i){const i=t.value,s=i.panel.id,r=n.get(s),a=!!r;if(D(i.element,"dv-tab--grouped",a),r){const t=r.panelIds,n=t[0]===s,a=t[t.length-1]===s;D(i.element,"dv-tab--group-first",n),D(i.element,"dv-tab--group-last",a),Je(i.element,r.color,this._ctx.accessor.tabGroupColorPalette);const h=i.element.classList.contains("dv-tab--group-collapsed");if(!r.collapsed&&h){o=!0,i.element.classList.remove("dv-tab--group-collapsed"),i.element.classList.add("dv-tab--group-expanding"),null===(e=this._pendingTransitionCleanups.get(s))||void 0===e||e();const t=()=>{i.element.classList.remove("dv-tab--group-expanding"),i.element.style.removeProperty("width"),i.element.removeEventListener("transitionend",t),clearTimeout(n),this._pendingTransitionCleanups.delete(s)},n=setTimeout(t,300);this._pendingTransitionCleanups.set(s,t),i.element.addEventListener("transitionend",t)}}else D(i.element,"dv-tab--group-first",!1),D(i.element,"dv-tab--group-last",!1),i.element.classList.remove("dv-tab--group-collapsed","dv-tab--group-expanding"),i.element.style.removeProperty("width"),i.element.style.removeProperty("--dv-tab-group-color")}const r=new Set;for(const e of t){r.add(e.id);if(e.collapsed&&e.panelIds.some(e=>{const t=s.get(e);return t&&!t.value.element.classList.contains("dv-tab--group-collapsed")}))if(this._skipNextCollapseAnimation){const t=[];for(const i of e.panelIds){const e=s.get(i);e&&(e.value.element.style.transition="none",e.value.element.classList.add("dv-tab--group-collapsed"),t.push(e.value.element))}if(t.length>0){t[0].offsetHeight;for(const e of t)e.style.removeProperty("transition")}}else{o=!0;const t="vertical"===this._ctx.getDirection();for(const i of e.panelIds){const e=s.get(i);if(e&&!e.value.element.classList.contains("dv-tab--group-collapsed")){const i=e.value.element.getBoundingClientRect();t?e.value.element.style.height=`${i.height}px`:e.value.element.style.width=`${i.width}px`,e.value.element.offsetHeight,e.value.element.classList.add("dv-tab--group-collapsed")}}}}this._skipNextCollapseAnimation=!1,this._ensureIndicator(),this._indicator&&(this._indicator.syncUnderlineElements(r),o?this._indicator.trackUnderlines():this._indicator.positionUnderlines())}}class et extends h{get showTabsOverflowControl(){return this._showTabsOverflowControl}set showTabsOverflowControl(e){if(this._showTabsOverflowControl!=e&&(this._showTabsOverflowControl=e,e)){const e=new _(this._tabsList);this._observerDisposable.value=new h(e,e.onDidChange(e=>{const t=e.hasScrollX||e.hasScrollY;this.toggleDropdown({reset:!t}),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}),v(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;null===(t=this._voidContainerListeners)||void 0===t||t.dispose(),this._voidContainerListeners=null,this._voidContainer=e,e&&(this._voidContainerListeners=new h(v(e,"dragover",e=>{this._animState&&e.preventDefault()}),v(e,"drop",e=>{var t;(null===(t=this._animState)||void 0===t?void 0:t.sourceTabGroupId)&&null!==this._animState.currentInsertionIndex&&(e.preventDefault(),e.stopPropagation(),this.handleVoidDrop())})))}handleVoidDrop(){var e,t;if(!(null===(e=this._animState)||void 0===e?void 0:e.sourceTabGroupId))return!1;const i=this._animState.sourceTabGroupId,s=null!==(t=this._animState.currentInsertionIndex)&&void 0!==t?t:this._tabs.length;return this._animState=null,this._commitGroupMove(i,s),!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),b(this._tabsList,"dv-horizontal","dv-vertical"),"vertical"===e?w(this._tabsList,"dv-tabs-container-vertical","dv-vertical"):(b(this._tabsList,"dv-tabs-container-vertical"),w(this._tabsList,"dv-horizontal"));for(const t of this._tabs)t.value.setDirection(e)}}constructor(t,i,s){super(),this.group=t,this.accessor=i,this._observerDisposable=new l,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 m,this.onTabDragStart=this._onTabDragStart.event,this._onDrop=new m,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new m,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onOverflowTabsChange=new m,this.onOverflowTabsChange=this._onOverflowTabsChange.event,this._tabsList=document.createElement("div"),this._tabsList.className="dv-tabs-container",this.showTabsOverflowControl=s.showTabsOverflowControl,"native"===i.options.scrollbars?this._element=this._tabsList:(this._scrollbar=new He(this._tabsList),this._scrollbar.orientation=this.direction,this._element=this._scrollbar.element,this.addDisposables(this._scrollbar)),this._tabGroupManager=new Qe({group:this.group,accessor:this.accessor,tabsList:this._tabsList,getTabs:()=>this._tabs,getTabMap:()=>this._tabMap,getDirection:()=>this._direction},{onChipContextMenu:(e,t)=>{this.accessor.contextMenuController.showForChip(e,this.group,t)},onChipDragStart:(e,t,i)=>{this._handleChipDragStart(e,t,i)}}),this.addDisposables(this._onOverflowTabsChange,this._observerDisposable,this._onWillShowOverlay,this._onDrop,this._onTabDragStart,{dispose:()=>{var e;null===(e=this._flipTransitionCleanup)||void 0===e||e.call(this)}},v(this.element,"pointerdown",e=>{if(e.defaultPrevented)return;0===e.button&&this.accessor.doSetGroupActive(this.group)}),v(this._tabsList,"dragover",e=>{var t,i,s,o;if(!this.accessor.options.disableDnd){if(this._animState){const e=n();(null==e?void 0:e.tabGroupId)&&e.groupId!==this.group.id&&this._animState.sourceTabGroupId!==e.tabGroupId&&(this._animState=null)}if(!this._animState){const e=n();if("default"===(null===(t=this.accessor.options.theme)||void 0===t?void 0:t.tabAnimation)&&!(null==e?void 0:e.tabGroupId))return;if(!e||!e.panelId&&!e.tabGroupId||e.groupId===this.group.id)return;{const t=this.getAverageTabWidth();if(e.tabGroupId){const s=this.accessor.getPanel(e.groupId),o=null==s?void 0:s.model.getTabGroups().find(t=>t.id===e.tabGroupId),n=t*(null!==(i=null==o?void 0:o.panelIds.length)&&void 0!==i?i:1)+t;this._animState={sourceTabId:"",sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.tabGroupId,sourceGroupPanelIds:o?new Set(o.panelIds):new Set,sourceChipWidth:t,cursorOffsetFromDragLeft:n/2,sourceGapWidth:n,containerLeft:this._tabsList.getBoundingClientRect().left}}else this._animState={sourceTabId:e.panelId,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:t/2,sourceGapWidth:t,containerLeft:this._tabsList.getBoundingClientRect().left}}}e.preventDefault(),-1!==this._animState.sourceIndex&&(null===(o=null===(s=this.group.model.dropTargetContainer)||void 0===s?void 0:s.model)||void 0===o||o.clear()),this.handleDragOver(e)}},!0),v(this._tabsList,"dragleave",e=>{var t,i,s;if(!this._animState)return;const o=e.relatedTarget;if(o&&this._tabsList.contains(o))return;if(o&&(null===(t=this._extendedDropZone)||void 0===t?void 0:t.contains(o)))return this.resetTabTransforms(),void(this._animState.currentInsertionIndex=null);const n=e.relatedTarget;this._voidContainer&&n&&(n===this._voidContainer||this._voidContainer.contains(n))||(this.resetTabTransforms(),this._animState&&(-1===this._animState.sourceIndex?(null===(s=null===(i=this.group.model.dropTargetContainer)||void 0===i?void 0:i.model)||void 0===s||s.clear(),this._animState=null):this._animState.currentInsertionIndex=null))},!0),v(this._tabsList,"dragend",()=>{this.resetDragAnimation()}),v(this._tabsList,"drop",e=>{var t,i,s;if(!this._animState||null===this._animState.currentInsertionIndex)return;if("smooth"!==(null===(t=this.accessor.options.theme)||void 0===t?void 0:t.tabAnimation)&&!this._animState.sourceTabGroupId)return;e.stopPropagation(),e.preventDefault(),null===(s=null===(i=this.group.model.dropTargetContainer)||void 0===i?void 0:i.model)||void 0===s||s.clear();const o=this._animState;if(this._animState=null,this._pendingCollapse=!1,o.sourceTabGroupId)return void this._commitGroupMove(o.sourceTabGroupId,o.currentInsertionIndex);const n=o.currentInsertionIndex,r=o.sourceIndex,a=n-(-1!==r&&r<n?1:0),h=this.group.model.getTabGroupForPanel(o.sourceTabId);if(a===r&&!o.targetTabGroupId&&!h)return this._uncollapsSourceTab(o.sourceTabId),void this.resetTabTransforms();this._uncollapsSourceTab(o.sourceTabId);const l=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:e,index:a,targetTabGroupId:o.targetTabGroupId}),this.runFlipAnimation(l,o.sourceTabId,-1===o.sourceIndex,{from:Math.min(r,a),to:Math.max(r,a)})},!0),e.DockviewDisposable.from(()=>{var e;null===(e=this._voidContainerListeners)||void 0===e||e.dispose(),this.resetDragAnimation(),this._tabGroupManager.disposeAll();for(const{value:e,disposable:t}of this._tabs)t.dispose(),e.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="vertical"===this._direction;let i=0;for(const s of this._tabs){const o=e.id===s.value.panel.id;if(s.value.setActive(o),o){const e=s.value.element,o=e.parentElement;t?(i<o.scrollTop||i+e.clientHeight>o.scrollTop+o.clientHeight)&&(o.scrollTop=i):(i<o.scrollLeft||i+e.clientWidth>o.scrollLeft+o.clientWidth)&&(o.scrollLeft=i)}i+=t?s.value.element.clientHeight:s.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 Le(e,this.accessor,this.group);i.setContent(e.view.tab),"horizontal"!==this._direction&&i.setDirection(this._direction);const s=new h(i.onDragStart(t=>{var s;if(this._onTabDragStart.fire({nativeEvent:t,panel:e}),"smooth"===(null===(s=this.accessor.options.theme)||void 0===s?void 0:s.tabAnimation)){const t=i.element.getBoundingClientRect().width,s=this._tabs.findIndex(e=>e.value===i);this._animState={sourceTabId:e.id,sourceIndex:s,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:t/2,sourceGapWidth:t,containerLeft:this._tabsList.getBoundingClientRect().left},this._pendingCollapse=!0,requestAnimationFrame(()=>{var e,t;this._pendingCollapse=!1,this._animState&&(i.element.style.transition="none",D(i.element,"dv-tab--dragging",!0),i.element.offsetHeight,null!==(e=(t=this._animState).currentInsertionIndex)&&void 0!==e||(t.currentInsertionIndex=s),this.applyDragOverTransforms(!0),i.element.style.removeProperty("transition"))})}}),i.onTabClick(t=>{t.defaultPrevented||"edge"===this.group.api.location.type&&(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(t=>{if(t.defaultPrevented)return;const s=!this.accessor.options.disableFloatingGroups,o="floating"===this.group.api.location.type&&1===this.size;if(s&&!o&&t.shiftKey){t.preventDefault();const e=this.accessor.getGroupPanel(i.panel.id),{top:s,left:o}=i.element.getBoundingClientRect(),{top:n,left:r}=this.accessor.element.getBoundingClientRect();return void this.accessor.addFloatingGroup(e,{x:o-r,y:s-n,inDragMode:!0})}if(0===t.button)"edge"===this.group.api.location.type||this.group.activePanel!==e&&this.group.model.openPanel(e)}),i.onDrop(e=>{var t,s,o,r;const a=this._animState;this._animState=null,this._pendingCollapse=!1;const h=this._tabs.findIndex(e=>e.value===i);if(a){const i="right"===e.position?h+1:h;if(a.sourceTabGroupId)return void this._commitGroupMove(a.sourceTabGroupId,null!==(t=a.currentInsertionIndex)&&void 0!==t?t:i);this._uncollapsSourceTab(a.sourceTabId);const o=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:e.nativeEvent,index:i,targetTabGroupId:a.targetTabGroupId}),"smooth"===(null===(s=this.accessor.options.theme)||void 0===s?void 0:s.tabAnimation)&&this.runFlipAnimation(o,a.sourceTabId,-1===a.sourceIndex,-1!==a.sourceIndex?{from:Math.min(a.sourceIndex,i),to:Math.max(a.sourceIndex,i)}:void 0)}else{const t="vertical"===this._direction?"bottom":"right",s=e.position===t?h+1:h,a=n(),l=a?this._tabs.findIndex(e=>e.value.panel.id===a.panelId):-1,d=s-(-1!==l&&l<s?1:0),p=null!==(r=null===(o=this.group.model.getTabGroupForPanel(i.panel.id))||void 0===o?void 0:o.id)&&void 0!==r?r:null;this._onDrop.fire({event:e.nativeEvent,index:d,targetTabGroupId:p})}}),i.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new Ne(e,{kind:"tab",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:n}))})),o={value:i,disposable:s};this.addTab(o,t),this._tabGroupManager.positionAllChips(),this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}delete(e){var t;(null===(t=this._animState)||void 0===t?void 0:t.sourceTabId)===e&&(this.resetTabTransforms(),this._animState=null),this._tabGroupManager.cleanupTransition(e);const i=this.indexOf(e),s=this._tabs.splice(i,1)[0];if(this._tabMap.delete(e),s){const{value:e,disposable:t}=s;t.dispose(),e.dispose(),e.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)return void this._onOverflowTabsChange.fire({tabs:[],tabGroups:[],reset:!0});const t=this._tabs.filter(e=>!I(e.value.element,this._tabsList)).map(e=>e.value.panel.id),i=new Set(t),s=[];for(const e of this.group.model.getTabGroups()){const o=this._tabGroupManager.chipRenderers.get(e.id),n=o&&!I(o.chip.element,this._tabsList),r=e.panelIds.length>0&&e.panelIds.every(e=>i.has(e));if((n||r)&&(s.push(e.id),e.collapsed))for(const s of e.panelIds)i.has(s)||(i.add(s),t.push(s))}this._onOverflowTabsChange.fire({tabs:t,tabGroups:s,reset:!1})}updateDragAndDropState(){for(const e of this._tabs)e.value.updateDragAndDropState()}updateTabGroups(){this._tabGroupManager.update()}refreshTabGroupAccent(){this._tabGroupManager.refreshAccents()}_handleChipDragStart(e,t,s){var n;const r=e.panelIds[0],a=r?this._tabs.findIndex(e=>e.value.panel.id===r):-1,h=t.element.getBoundingClientRect();let l=h.width;for(const t of e.panelIds){const e=this._tabMap.get(t);e&&(l+=e.value.element.getBoundingClientRect().width)}this._animState={sourceTabId:"",sourceIndex:a,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.id,sourceGroupPanelIds:new Set(e.panelIds),sourceChipWidth:h.width,cursorOffsetFromDragLeft:s.clientX-h.left,sourceGapWidth:l,containerLeft:this._tabsList.getBoundingClientRect().left};const d=o.getInstance();d.setData([new i(this.accessor.id,this.group.id,null,e.id)],i.prototype);const p=A(),u=t.element,c=()=>{u.removeEventListener("dragend",c),this.resetDragAnimation()};if(u.addEventListener("dragend",c),this._chipDragCleanup={dispose:()=>{u.removeEventListener("dragend",c),d.clearData(i.prototype),p.release()}},s.dataTransfer&&(s.dataTransfer.effectAllowed="move",0===s.dataTransfer.items.length&&s.dataTransfer.setData("text/plain","")),"smooth"===(null===(n=this.accessor.options.theme)||void 0===n?void 0:n.tabAnimation)){const t=new Set(e.panelIds);this._pendingCollapse=!0,requestAnimationFrame(()=>{var i,s;if(this._pendingCollapse=!1,!this._animState)return;for(const e of this._tabs)t.has(e.value.panel.id)&&(e.value.element.style.transition="none",D(e.value.element,"dv-tab--dragging",!0));const o=this._tabGroupManager.chipRenderers.get(e.id);o&&(o.chip.element.style.transition="none",D(o.chip.element,"dv-tab-group-chip--dragging",!0)),this._tabsList.offsetHeight;const n=this._tabGroupManager.groupUnderlines.get(e.id);n&&(n.style.display="none"),null!==(i=(s=this._animState).currentInsertionIndex)&&void 0!==i||(s.currentInsertionIndex=a),this.applyDragOverTransforms(!0);for(const e of this._tabs)t.has(e.value.panel.id)&&e.value.element.style.removeProperty("transition");o&&o.chip.element.style.removeProperty("transition")})}this._tabGroupManager.setGroupDragImage(s,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(),-1===this._animState.sourceIndex?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(0===this._tabs.length)return 0;const e="vertical"===this._direction;let t=0;for(const i of this._tabs){const s=i.value.element.getBoundingClientRect();t+=e?s.height:s.width}return t/this._tabs.length}handleDragOver(e){var t,i,s,o,n;if(!this._animState)return;const r=e.clientX;let a=null,h=null;const l=this._animState.sourceGroupPanelIds,d=r-this._animState.cursorOffsetFromDragLeft-this._animState.containerLeft;let p=0;const u=new Map;if(this._tabGroupManager.chipRenderers.size>0){const e=this.group.model.getTabGroups();for(const t of e)t.id!==this._animState.sourceTabGroupId&&t.panelIds.length>0&&u.set(t.panelIds[0],t.id)}for(let e=0;e<this._tabs.length;e++){const i=this._tabs[e].value;if(i.panel.id===this._animState.sourceTabId)continue;if(null==l?void 0:l.has(i.panel.id))continue;const s=u.get(i.panel.id);if(s){const i=null!==(t=this._animState.chipPositions.get(s))&&void 0!==t?t:0;if(p+i>d){null!=a||(a=e);break}p+=i}const o=this._animState.tabPositions.get(i.panel.id),n=o?o.width:i.element.getBoundingClientRect().width;if(!(p+n/2<=d)){null!=a||(a=e);break}p+=n,a=e+1}if(null!==a&&this._tabGroupManager.chipRenderers.size>0){const e=!!this._animState.sourceTabGroupId,t=this.group.model.getTabGroups();let n=0;for(let e=0;e<this._tabs.length;e++){const t=this._tabs[e].value;if(t.panel.id===this._animState.sourceTabId)continue;if(null==l?void 0:l.has(t.panel.id))continue;if(e>=a)break;const s=u.get(t.panel.id);s&&(n+=null!==(i=this._animState.chipPositions.get(s))&&void 0!==i?i:0);const o=this._animState.tabPositions.get(t.panel.id);n+=o?o.width:t.element.getBoundingClientRect().width}for(const i of t){const t=i.panelIds.filter(e=>e!==this._animState.sourceTabId&&!(null==l?void 0:l.has(e)));if(0===t.length)continue;const d=this._tabs.findIndex(e=>e.value.panel.id===t[0]),p=this._tabs.findIndex(e=>e.value.panel.id===t[t.length-1]);if(-1===d||-1===p)continue;const u=a>=d&&a<=p,c=!u&&a===d-1;if(u||c){if(e&&u){a=a<(d+p+1)/2?d:p+1;break}if(e&&c)break;if(c){let e=!0;for(let t=a;t<d;t++){const i=this._tabs[t].value.panel.id;if(i!==this._animState.sourceTabId&&!(null==l?void 0:l.has(i))){e=!1;break}}if(!e)continue;const t=null!==(s=this._animState.chipPositions.get(i.id))&&void 0!==s?s:0;r>=(i.collapsed?this._animState.containerLeft+n+t/2:this._animState.containerLeft+n+t)&&(a=d,h=i.id);break}if(u){const e=null!==(o=this._animState.chipPositions.get(i.id))&&void 0!==o?o:0,t=this._animState.containerLeft+n+e;a===d?r>=t&&(h=i.id):h=i.id;break}}}}a===this._animState.currentInsertionIndex&&h===this._animState.targetTabGroupId||(this._animState.currentInsertionIndex=a,this._animState.targetTabGroupId=h,"smooth"===(null===(n=this.accessor.options.theme)||void 0===n?void 0:n.tabAnimation)&&this.applyDragOverTransforms())}_removeClassInstantlyBatch(e,t){const i=[];for(const s of e)s.classList.contains(t)&&(s.style.transition="none",D(s,t,!1),i.push(s));if(i.length>0){i[0].offsetHeight;for(const e of i)e.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||null===this._animState.currentInsertionIndex)return void this.resetTabTransforms();if(this._pendingCollapse)return;const t=this._animState.currentInsertionIndex;let i;const s=this._animState.sourceGroupPanelIds;if(this._animState.sourceTabGroupId&&s)i=this._animState.sourceGapWidth;else{const e=this._animState.tabPositions.get(this._animState.sourceTabId);i=e?e.width:this.getAverageTabWidth()}let o=null;if(this._tabGroupManager.chipRenderers.size>0){const e=this.group.model.getTabGroups();for(const i of e){if(i.id===this._animState.sourceTabGroupId)continue;if(i.panelIds.includes(this._animState.sourceTabId))continue;const e=i.panelIds.filter(e=>e!==this._animState.sourceTabId&&!(null==s?void 0:s.has(e)));if(0===e.length)continue;const n=this._tabs.findIndex(t=>t.value.panel.id===e[0]);if((!this._animState.targetTabGroupId||this._animState.targetTabGroupId===i.id&&i.collapsed)&&n>=t){let e=!1;for(let i=t;i<n;i++){const t=this._tabs[i].value.panel.id;if(t!==this._animState.sourceTabId&&!(null==s?void 0:s.has(t))){e=!0;break}}if(!e){const e=this._tabGroupManager.chipRenderers.get(i.id);e&&(o=e.chip.element)}break}}}const n=e=>e.classList.contains("dv-tab-group-chip")?"dv-tab-group-chip--shifting":"dv-tab--shifting",r=(t,i)=>{e?(t.style.transition="none",t.style.marginLeft=i,t.offsetHeight,t.style.removeProperty("transition")):t.style.marginLeft=i,D(t,n(t),!0)},a=t=>{const i=n(t),s=this._pendingMarginCleanups.get(t);if(s&&s(),e||!t.style.marginLeft)t.style.removeProperty("margin-left"),D(t,i,!1);else{t.style.marginLeft="0px",D(t,i,!0);const e=()=>{t.style.removeProperty("margin-left"),D(t,i,!1),t.removeEventListener("transitionend",e),clearTimeout(s),this._pendingMarginCleanups.delete(t)},s=setTimeout(e,300);this._pendingMarginCleanups.set(t,e),t.addEventListener("transitionend",e)}};let h=!1;for(const[e,t]of this._tabGroupManager.chipRenderers)e!==this._animState.sourceTabGroupId&&a(t.chip.element);o&&(r(o,`${i}px`),h=!0);for(let e=0;e<this._tabs.length;e++){const o=this._tabs[e].value;o.panel.id!==this._animState.sourceTabId&&((null==s?void 0:s.has(o.panel.id))||(!h&&e>=t?(r(o.element,`${i}px`),h=!0):a(o.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"),D(e.value.element,"dv-tab--shifting",!1);for(const[,e]of this._tabGroupManager.chipRenderers)e.chip.element.style.removeProperty("margin-left"),D(e.chip.element,"dv-tab-group-chip--shifting",!1);this._tabGroupManager.positionUnderlines()}_commitGroupMove(e,t){var i,s,o;const r=n();null===(i=this._chipDragCleanup)||void 0===i||i.dispose(),this._chipDragCleanup=null;if(this.group.model.getTabGroups().some(t=>t.id===e))if("smooth"===(null===(s=this.accessor.options.theme)||void 0===s?void 0:s.tabAnimation)){this._clearGroupDragClasses(e);const i=this.snapshotTabPositions();this.resetTabTransforms(),this.group.model.moveTabGroup(e,t),this.runFlipAnimation(i,"",!1)}else this._tabGroupManager.skipNextCollapseAnimation=!0,this.group.model.moveTabGroup(e,t);else r&&(this.resetTabTransforms(),this.accessor.moveGroupOrPanel({from:{groupId:r.groupId,tabGroupId:null!==(o=r.tabGroupId)&&void 0!==o?o: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(e=>e.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(),(null===(e=this._animState)||void 0===e?void 0:e.sourceTabGroupId)?this._clearGroupDragClasses(this._animState.sourceTabGroupId):this._removeClassInstantlyBatch(this._tabs.map(e=>e.value.element),"dv-tab--dragging"),this._animState=null,null===(t=this._chipDragCleanup)||void 0===t||t.dispose(),this._chipDragCleanup=null;for(const[,e]of this._tabGroupManager.groupUnderlines)e.style.removeProperty("display")}runFlipAnimation(e,t,i=!1,s){const o="vertical"===this._direction;let n=!1;for(let r=0;r<this._tabs.length;r++){const a=this._tabs[r],h=a.value.panel.id;if(h===t){if(i){const e=a.value.element.getBoundingClientRect();a.value.element.style.transform=o?`translateY(${e.height}px)`:`translateX(${e.width}px)`,D(a.value.element,"dv-tab--shifting",!0),n=!0}continue}if(void 0!==s&&(r<s.from||r>s.to))continue;const l=e.get(h);if(!l)continue;const d=a.value.element.getBoundingClientRect(),p=o?l.top-d.top:l.left-d.left;Math.abs(p)<1||(a.value.element.style.transform=o?`translateY(${p}px)`:`translateX(${p}px)`,D(a.value.element,"dv-tab--shifting",!0),n=!0)}n&&requestAnimationFrame(()=>{var e;for(const e of this._tabs)e.value.element.style.transform&&(e.value.element.style.transform="");this._tabGroupManager.trackUnderlines(),null===(e=this._flipTransitionCleanup)||void 0===e||e.call(this);const t=e=>{if("transform"===e.propertyName){i();for(const e of this._tabs)D(e.value.element,"dv-tab--shifting",!1);this._tabGroupManager.positionUnderlines()}},i=()=>{this._tabsList.removeEventListener("transitionend",t),this._flipTransitionCleanup=null};this._flipTransitionCleanup=i,this._tabsList.addEventListener("transitionend",t)})}}const tt=e=>{const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttributeNS(null,"height",e.height),t.setAttributeNS(null,"width",e.width),t.setAttributeNS(null,"viewBox",e.viewbox),t.setAttributeNS(null,"aria-hidden","false"),t.setAttributeNS(null,"focusable","false"),t.classList.add("dv-svg");const i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttributeNS(null,"d",e.path),t.appendChild(i),t},it=()=>tt({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"});class st extends h{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,"vertical"===e?(w(this._element,"dv-groupview-header-vertical"),w(this.rightActionsContainer,"dv-right-actions-container-vertical"),this.tabs.direction=e):(b(this._element,"dv-groupview-header-vertical"),b(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 l,this._onDrop=new m,this.onDrop=this._onDrop.event,this._onGroupDragStart=new m,this.onGroupDragStart=this._onGroupDragStart.event,this._onWillShowOverlay=new m,this.onWillShowOverlay=this._onWillShowOverlay.event,this._element=document.createElement("div"),this._element.className="dv-tabs-and-actions-container",D(this._element,"dv-full-width-single-tab","fullwidth"===this.accessor.options.singleTabMode),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 et(t,e,{showTabsOverflowControl:!e.options.disableTabsOverflowList}),this.voidContainer=new We(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(e=>this._onDrop.fire(e)),this.tabs.onWillShowOverlay(e=>this._onWillShowOverlay.fire(e)),e.onDidOptionsChange(()=>{this.tabs.showTabsOverflowControl=!e.options.disableTabsOverflowList}),this.tabs.onOverflowTabsChange(e=>{this.toggleDropdown(e)}),this.tabs,this._onWillShowOverlay,this._onDrop,this._onGroupDragStart,this.voidContainer,this.voidContainer.onDragStart(e=>{this._onGroupDragStart.fire({nativeEvent:e,group:this.group})}),this.voidContainer.onDrop(e=>{this.tabs.handleVoidDrop()||this._onDrop.fire({event:e.nativeEvent,index:this.tabs.size})}),this.voidContainer.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new Ne(e,{kind:"header_space",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:n}))}),v(this.leftActionsContainer,"dragleave",e=>{const t=e.relatedTarget;this.leftActionsContainer.contains(t)||this._element.contains(t)||this.tabs.clearExternalAnimState()}),v(this.voidContainer.element,"dragleave",e=>{const t=e.relatedTarget;this.voidContainer.element.contains(t)||(this._element.contains(t)?this.tabs.setExternalInsertionIndex(null):this.tabs.clearExternalAnimState())}),v(this.voidContainer.element,"pointerdown",e=>{if(e.defaultPrevented)return;if(!this.accessor.options.disableFloatingGroups&&e.shiftKey&&"floating"!==this.group.api.location.type&&"edge"!==this.group.api.location.type){e.preventDefault();const{top:t,left:i}=this.element.getBoundingClientRect(),{top:s,left:o}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(this.group,{x:i-o+20,y:t-s+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(){D(this._element,"dv-single-tab",1===this.size)}toggleDropdown(t){const i=t.reset?[]:t.tabs,s=t.reset?[]:t.tabGroups;this._overflowTabs=i,this._overflowTabGroups=s;const o=this._overflowTabs.length;if(o>0&&this.dropdownPart)return void this.dropdownPart.update({tabs:o});if(0===o)return void this._dropdownDisposable.dispose();const n=document.createElement("div");n.className="dv-tabs-overflow-dropdown-root";const r=function(){const e=document.createElement("div");e.className="dv-tabs-overflow-dropdown-default";const t=document.createElement("span");t.textContent="";const i=it();return e.appendChild(i),e.appendChild(t),{element:e,update:e=>{t.textContent=`${e.tabs}`}}}();r.update({tabs:o}),this.dropdownPart=r,n.appendChild(r.element),this.rightActionsContainer.prepend(n),this._dropdownDisposable.value=new h(e.DockviewDisposable.from(()=>{var e,t;n.remove(),null===(t=null===(e=this.dropdownPart)||void 0===e?void 0:e.dispose)||void 0===t||t.call(e),this.dropdownPart=null}),v(n,"pointerdown",e=>{e.preventDefault()},{capture:!0}),v(n,"click",e=>{const t=document.createElement("div");t.style.overflow="auto",t.className="dv-tabs-overflow-container";const i=new Set(this._overflowTabGroups),s=this.group.model.getTabGroups(),o=new Map;for(const e of s)if(i.has(e.id))for(const t of e.panelIds)o.set(t,e);const r=new Set;for(const e of this.tabs.tabs.filter(e=>this._overflowTabs.includes(e.panel.id))){const i=o.get(e.panel.id);if(i&&!r.has(i.id)){r.add(i.id);const e=document.createElement("div");e.className="dv-tabs-overflow-group-header";const s=document.createElement("span");s.className="dv-tabs-overflow-group-color",Je(s,i.color,this.accessor.tabGroupColorPalette),e.appendChild(s);const o=document.createElement("span");if(o.className="dv-tabs-overflow-group-label",o.textContent=i.label||i.id,e.appendChild(o),i.collapsed){const t=document.createElement("span");t.className="dv-tabs-overflow-group-collapsed-badge",t.textContent=`${i.panelIds.length}`,e.appendChild(t)}e.addEventListener("click",()=>{this.accessor.getPopupServiceForGroup(this.group).close(),i.collapsed&&i.expand();const e=i.panelIds[0];if(e){const t=this.group.panels.find(t=>t.id===e);null==t||t.api.setActive()}}),t.appendChild(e)}const s=this.group.panels.find(t=>t===e.panel),n=s.view.createTabRenderer("headerOverflow").element,a=document.createElement("div");D(a,"dv-tab",!0),D(a,"dv-active-tab",s.api.isActive),D(a,"dv-inactive-tab",!s.api.isActive),i&&D(a,"dv-tab--grouped",!0),a.addEventListener("click",t=>{this.accessor.getPopupServiceForGroup(this.group).close(),t.defaultPrevented||((null==i?void 0:i.collapsed)&&i.expand(),e.element.scrollIntoView(),e.panel.api.setActive())}),a.appendChild(n),t.appendChild(a)}const a=T(n);this.accessor.getPopupServiceForGroup(this.group).openPopover(t,{x:e.clientX,y:e.clientY,zIndex:(null==a?void 0:a.style.zIndex)?`calc(${a.style.zIndex} * 2)`:void 0})}))}updateDragAndDropState(){this.tabs.updateDragAndDropState(),this.voidContainer.updateDragAndDropState()}updateTabGroups(){this.tabs.updateTabGroups()}refreshTabGroupAccent(){this.tabs.refreshTabGroupAccent()}}class ot extends p{constructor(e,t,i,s,o){super(),this.nativeEvent=e,this.target=t,this.position=i,this.getData=s,this.group=o}}const nt=(()=>{const e={disableAutoResizing:void 0,hideBorders:void 0,singleTabMode:void 0,disableFloatingGroups:void 0,floatingGroupBounds:void 0,popoutUrl:void 0,nonce: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,createGroupDragGhostComponent:void 0,tabGroupColors:void 0,tabGroupAccent:void 0};return Object.keys(e)})();function rt(e){return!!e.referencePanel}function at(e){return!!e.referenceGroup}function ht(e){return!!e.referencePanel}function lt(e){return!!e.referenceGroup}class dt extends h{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 0===this._panelIds.length}constructor(e,t){var i,s;super(),this.id=e,this._collapsed=!1,this._panelIds=[],this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this._onDidPanelChange=new m,this.onDidPanelChange=this._onDidPanelChange.event,this._onDidCollapseChange=new m,this.onDidCollapseChange=this._onDidCollapseChange.event,this._onDidDestroy=new m,this.onDidDestroy=this._onDidDestroy.event,this._label=null!==(i=null==t?void 0:t.label)&&void 0!==i?i:"",this._color=""===(null==t?void 0:t.color)||null==t?void 0:t.color,this._collapsed=null!==(s=null==t?void 0:t.collapsed)&&void 0!==s&&s,this._componentParams=null==t?void 0:t.componentParams,this.addDisposables(this._onDidChange,this._onDidPanelChange,this._onDidCollapseChange,this._onDidDestroy)}addPanel(e,t){if(this.isDisposed)return;if(this._panelIds.includes(e))return;const i=void 0!==t?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-1!==t&&(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),void 0!==this._color&&(e.color=this._color),void 0!==this._componentParams&&(e.componentParams=this._componentParams),e}dispose(){this._onDidDestroy.fire(),super.dispose()}}class pt extends d{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 ut extends pt{get kind(){return this._kind}constructor(e){super(e),this._kind=e.kind}}class ct extends h{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,D(this.container,"dv-locked-groupview","no-drop-target"===e||e)}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return 0===this._panels.length}get hasWatermark(){return!(!this.watermark||!this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get isContentFocused(){return!!document.activeElement&&C(document.activeElement,this.contentContainer.element)}get headerPosition(){var e;return null!==(e=this._headerPosition)&&void 0!==e?e:"top"}set headerPosition(e){var t;this._headerPosition=e,b(this.container,"dv-groupview-header-top","dv-groupview-header-bottom","dv-groupview-header-left","dv-groupview-header-right"),w(this.container,`dv-groupview-header-${e}`);const i="top"===e||"bottom"===e?"horizontal":"vertical";this.tabsContainer.direction=i,this.header.direction=i,(null===(t=this._activePanel)||void 0===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,D(this.container,"dv-groupview-floating",!1),D(this.container,"dv-groupview-popout",!1),D(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"]),D(this.container,"dv-groupview-floating",!0);break;case"popout":this.contentContainer.dropTarget.setTargetZones(["center"]),D(this.container,"dv-groupview-popout",!0);break;case"edge":this.contentContainer.dropTarget.setTargetZones(["center"]),D(this.container,"dv-groupview-edge",!0)}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,i,s,o){var r,a;super(),this.container=e,this.accessor=t,this.id=i,this.options=s,this.groupPanel=o,this._isGroupActive=!1,this._locked=!1,this._rightHeaderActionsDisposable=new l,this._leftHeaderActionsDisposable=new l,this._prefixHeaderActionsDisposable=new l,this._location={type:"grid"},this.mostRecentlyUsed=[],this._overwriteRenderContainer=null,this._overwriteDropTargetContainer=null,this._onDidChange=new m,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 m,this.onMove=this._onMove.event,this._onDidDrop=new m,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new m,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new m,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onTabDragStart=new m,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new m,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new m,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPanelTitleChange=new m,this.onDidPanelTitleChange=this._onDidPanelTitleChange.event,this._onDidPanelParametersChange=new m,this.onDidPanelParametersChange=this._onDidPanelParametersChange.event,this._onDidRemovePanel=new m,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new m,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onUnhandledDragOverEvent=new m,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this._tabGroups=[],this._tabGroupMap=new Map,this._panelToTabGroup=new Map,this._tabGroupIdCounter=0,this._pendingTabGroupUpdate=!1,this._onDidCreateTabGroup=new m,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new m,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new m,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new m,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new m,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new m,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,D(this.container,"dv-groupview",!0),this._api=new ge(this.accessor),this.tabsContainer=new st(this.accessor,this.groupPanel),this.contentContainer=new ke(this.accessor,this),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!s.hideHeader,this.locked=null!==(r=s.locked)&&void 0!==r&&r,this.headerPosition=null!==(a=s.headerPosition)&&void 0!==a?a:t.defaultHeaderPosition,this.addDisposables(this._onTabDragStart,this._onGroupDragStart,this._onWillShowOverlay,this._rightHeaderActionsDisposable,this._leftHeaderActionsDisposable,this._prefixHeaderActionsDisposable,this.tabsContainer.onTabDragStart(e=>{this._onTabDragStart.fire(e)}),this.tabsContainer.onGroupDragStart(e=>{this._onGroupDragStart.fire(e)}),this.tabsContainer.onDrop(e=>{var t;const i=n(),s=null!==(t=null==i?void 0:i.panelId)&&void 0!==t?t:null;if(this.handleDropEvent("header",e.event,"center",e.index),s&&e.targetTabGroupId){const t=this._tabGroupMap.get(e.targetTabGroupId);let i;if(t){const e=this._panels.findIndex(e=>e.id===s);if(-1!==e){i=0;for(const s of t.panelIds){this._panels.findIndex(e=>e.id===s)<e&&i++}}}this.addPanelToTabGroup(e.targetTabGroupId,s,i)}else s&&null===e.targetTabGroupId&&this.removePanelFromTabGroup(s)}),this.contentContainer.onDidFocus(()=>{this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.onDidBlur(()=>{}),this.contentContainer.dropTarget.onDrop(e=>{this.handleDropEvent("content",e.nativeEvent,e.position)}),this.tabsContainer.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(e)}),this.contentContainer.dropTarget.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new Ne(e,{kind:"content",panel:this.activePanel,api:this._api,group:this.groupPanel,getData:n}))}),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=null!==(t=null==e?void 0:e.id)&&void 0!==t?t:`tg-${this.id}-${this._tabGroupIdCounter++}`,s=new dt(i,{label:null==e?void 0:e.label,color:null==e?void 0:e.color,collapsed:null==e?void 0:e.collapsed,componentParams:null==e?void 0:e.componentParams});return this._tabGroups.push(s),this._tabGroupMap.set(i,s),this._tabGroupDisposables.set(i,new h(s.onDidChange(()=>{this._onDidTabGroupChange.fire({tabGroup:s})}),s.onDidCollapseChange(e=>{e?this._handleGroupCollapse(s):this._handleGroupExpand(s),this._onDidTabGroupCollapsedChange.fire({tabGroup:s})}),s.onDidDestroy(()=>{this._removeTabGroupInternal(s)}))),this._onDidCreateTabGroup.fire({tabGroup:s}),s}dissolveTabGroup(e){const t=this._tabGroupMap.get(e);if(!t)return;const i=[...t.panelIds];for(const e of i)t.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:e});t.dispose()}addPanelToTabGroup(e,t,i){const s=this._tabGroupMap.get(e);if(!s)return;if(!this._panels.some(e=>e.id===t))return;const o=this.getTabGroupForPanel(t);if(o){if(o.id===e)return;this.removePanelFromTabGroup(t)}s.addPanel(t,i),this._panelToTabGroup.set(t,s),this._enforceContiguity(s,t),this._onDidAddPanelToTabGroup.fire({tabGroup:s,panelId:t})}movePanelWithinGroup(e,t,i){const s=this._tabGroupMap.get(e);s&&s.containsPanel(t)&&(s.removePanel(t),s.addPanel(t,i),this._enforceContiguity(s,t),this.tabsContainer.updateTabGroups())}movePanelBetweenGroups(e,t,i){const s=this._findTabGroupForPanel(e),o=this._tabGroupMap.get(t);o&&(s&&(s.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:s,panelId:e}),s.isEmpty&&s.dispose()),o.addPanel(e,i),this._panelToTabGroup.set(e,o),this._enforceContiguity(o,e),this._onDidAddPanelToTabGroup.fire({tabGroup:o,panelId:e}))}moveTabGroup(e,t){const i=this._tabGroupMap.get(e);if(!i||0===i.panelIds.length)return;const s=new Set(i.panelIds),o=i.panelIds.map(e=>this._panels.find(t=>t.id===e)).filter(e=>void 0!==e);if(0===o.length)return;let n=0;for(let e=0;e<Math.min(t,this._panels.length);e++)s.has(this._panels[e].id)&&n++;for(const e of o){const t=this._panels.indexOf(e);-1!==t&&this._panels.splice(t,1)}const r=t-n,a=Math.max(0,Math.min(r,this._panels.length));this._panels.splice(a,0,...o);for(const e of this._panels)this.tabsContainer.delete(e.id);for(let e=0;e<this._panels.length;e++)this.tabsContainer.openPanel(this._panels[e],e);this.tabsContainer.updateTabGroups()}_enforceContiguity(e,t){const i=this._panels.find(e=>e.id===t);if(!i)return;const s=e.indexOfPanel(t),o=this._computeGlobalIndex(e,s),n=this._panels.indexOf(i);if(n===o)return;this._panels.splice(n,1);const r=o>n?o-1:o;this._panels.splice(r,0,i),this.tabsContainer.delete(t),this.tabsContainer.openPanel(i,r)}_computeGlobalIndex(e,t){const i=e.panelIds;if(i.length<=1){const e=this._panels.find(e=>e.id===i[0]);return e?this._panels.indexOf(e):this._panels.length}for(let e=0;e<i.length;e++){if(e===t)continue;const s=this._panels.find(t=>t.id===i[e]);if(s){const i=this._panels.indexOf(s);return Math.max(0,i+(t-e))}}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()}refreshWatermark(){var e,t;this.watermark&&(this.watermark.element.remove(),null===(t=(e=this.watermark).dispose)||void 0===t||t.call(e),this.watermark=void 0),this.updateContainer()}getTabGroupForPanel(e){return this._findTabGroupForPanel(e)}_findTabGroupForPanel(e){return this._panelToTabGroup.get(e)}_removeTabGroupInternal(e){const t=this._tabGroups.indexOf(e);if(-1!==t){this._tabGroups.splice(t,1),this._tabGroupMap.delete(e.id);for(const t of e.panelIds)this._panelToTabGroup.delete(t);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)return;if(!e.containsPanel(this._activePanel.id))return;const t=this._panels.indexOf(this._activePanel);for(let e=t+1;e<this._panels.length;e++){const t=this._panels[e],i=this._findTabGroupForPanel(t.id);if(!i||!i.collapsed)return this.doSetActivePanel(t),void this.updateContainer()}for(let e=t-1;e>=0;e--){const t=this._panels[e],i=this._findTabGroupForPanel(t.id);if(!i||!i.collapsed)return this.doSetActivePanel(t),void this.updateContainer()}this.contentContainer.closePanel(),this.doSetActivePanel(void 0),this.updateContainer()}_handleGroupExpand(e){if(this._activePanel)return;const t=e.panelIds[0];if(t){const e=this._panels.find(e=>e.id===t);e&&(this.doSetActivePanel(e),this.updateContainer())}}restoreTabGroups(e){for(const t of e){const e=t.id.match(/-(\d+)$/);if(e){const t=parseInt(e[1],10)+1;t>this._tabGroupIdCounter&&(this._tabGroupIdCounter=t)}}for(const t of e){const e=this.createTabGroup({id:t.id,label:t.label,color:t.color,componentParams:t.componentParams}),i=this._tabGroupMap.get(e.id);for(const s of t.panelIds)this._panels.some(e=>e.id===s)&&(e.addPanel(s),this._panelToTabGroup.set(s,i),this._enforceContiguity(i,s));t.collapsed&&e.collapse(),e.isEmpty&&e.dispose()}}focusContent(){this.contentContainer.element.focus()}set renderContainer(e){this.panels.forEach(e=>{this.renderContainer.detatch(e)}),this._overwriteRenderContainer=e,this.panels.forEach(e=>{this.rerender(e)})}get renderContainer(){var e;return null!==(e=this._overwriteRenderContainer)&&void 0!==e?e:this.accessor.overlayRenderContainer}set dropTargetContainer(e){this._overwriteDropTargetContainer=e}get dropTargetContainer(){var e;return null!==(e=this._overwriteDropTargetContainer)&&void 0!==e?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:null===(e=this._activePanel)||void 0===e?void 0:e.id,id:this.id};return!1!==this.locked&&(t.locked=this.locked),this.header.hidden&&(t.hideHeader=!0),"top"!==this.headerPosition&&(t.headerPosition=this.headerPosition),this._tabGroups.length>0&&(t.tabGroups=this._tabGroups.map(e=>e.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)return;i=0}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)return;i=this.panels.length-1}this.openPanel(this.panels[i])}containsPanel(e){return this.panels.includes(e)}init(e){}update(e){}focus(){var e;null===(e=this._activePanel)||void 0===e||e.focus()}openPanel(e,t={}){("number"!=typeof t.index||t.index>this.panels.length)&&(t.index=this.panels.length);const i=!!t.skipSetActive;e.updateParentGroup(this.groupPanel,{skipSetActive:t.skipSetActive}),this.doAddPanel(e,t.index,{skipSetActive:i}),this._activePanel!==e?(i||this.doSetActivePanel(e),t.skipSetGroupActive||this.accessor.doSetGroupActive(this.groupPanel),t.skipSetActive||this.updateContainer()):this.contentContainer.renderPanel(e,{asActive:!0})}removePanel(e,t={skipSetActive:!1}){const i="string"==typeof e?e:e.id,s=this._panels.find(e=>e.id===i);if(!s)throw new Error("invalid operation");return this._removePanel(s,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=1===this.panels.length&&1===this.accessor.groups.length;this.accessor.removePanel(e,t&&"emptyGroup"===this.accessor.options.noPanelsOverlay?{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,D(this.container,"dv-active-group",e),D(this.container,"dv-inactive-group",!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0){const e=this._panels.find(e=>{const t=this._findTabGroupForPanel(e.id);return!t||!t.collapsed});e&&this.doSetActivePanel(e)}this.updateContainer()}}layout(e,t){var i;this._width=e,this._height=t,this.contentContainer.layout(this._width,this._height),(null===(i=this._activePanel)||void 0===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 e=this.mostRecentlyUsed[0];this.openPanel(e,{skipSetActive:t.skipSetActive,skipSetGroupActive:t.skipSetActiveGroup})}return this._activePanel&&0===this.panels.length&&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 t=this.mostRecentlyUsed.indexOf(e);this.mostRecentlyUsed.splice(t,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?"always"===e.api.renderer&&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 h(e.api.onDidTitleChange(e=>this._onDidPanelTitleChange.fire(e)),e.api.onDidParametersChange(e=>this._onDidPanelParametersChange.fire(e)))),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(e=>e.runEvents());const i=this.isEmpty||!this._activePanel;if(i&&!this.watermark){const e=this.accessor.createWatermarkComponent();e.init({containerApi:this._api,group:this.groupPanel}),this.watermark=e,v(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(),null===(t=(e=this.watermark).dispose)||void 0===t||t.call(e),this.watermark=void 0)}canDisplayOverlay(e,t,i){const s=new ot(e,i,t,n,this.accessor.getPanel(this.id));return this._onUnhandledDragOverEvent.fire(s),s.isAccepted}handleDropEvent(e,t,i,s){if("no-drop-target"===this.locked)return;const o="number"==typeof s?this.panels[s]:void 0,r=new ut({nativeEvent:t,position:i,panel:o,getData:()=>n(),kind:function(){switch(e){case"header":return"number"==typeof s?"tab":"header_space";case"content":return"content"}}(),group:this.groupPanel,api:this._api});if(this._onWillDrop.fire(r),r.defaultPrevented)return;const a=n();if(a&&a.viewId===this.accessor.id){if("content"===e&&a.groupId===this.id){if("center"===i)return;if(null===a.panelId&&!a.tabGroupId)return}if("header"===e&&a.groupId===this.id&&null===a.panelId&&!a.tabGroupId)return;if(null===a.panelId){const{groupId:e}=a;return void this._onMove.fire({target:i,groupId:e,index:s,tabGroupId:a.tabGroupId})}if(-1!==this.tabsContainer.indexOf(a.panelId)&&1===this.tabsContainer.size)return;const{groupId:t,panelId:o}=a;if(this.id===t&&!i){if(this.tabsContainer.indexOf(o)===s)return}this._onMove.fire({target:i,groupId:a.groupId,itemId:a.panelId,index:s})}else this._onDidDrop.fire(new pt({nativeEvent:t,position:i,panel:o,getData:()=>n(),group:this.groupPanel,api:this._api}))}updateDragAndDropState(){this.tabsContainer.updateDragAndDropState()}dispose(){var e,t,i;super.dispose(),null===(e=this.watermark)||void 0===e||e.element.remove(),null===(i=null===(t=this.watermark)||void 0===t?void 0:t.dispose)||void 0===i||i.call(t),this.watermark=void 0;for(const e of[...this._tabGroups])e.dispose();for(const e of this._tabGroupDisposables.values())e.dispose();this._tabGroupDisposables.clear();for(const e of this._pendingMicrotaskDisposables)e.dispose();this._pendingMicrotaskDisposables.clear();for(const e of this.panels)e.dispose();this.tabsContainer.dispose(),this.contentContainer.dispose()}}class mt extends Ae{constructor(e,t,i){super(e,t),this._onDidConstraintsChangeInternal=new m,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new m,this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new m,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 vt extends Te{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="function"==typeof this._minimumWidth?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}__maximumWidth(){const e="function"==typeof this._maximumWidth?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}__minimumHeight(){const e="function"==typeof this._minimumHeight?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}__maximumHeight(){const e="function"==typeof this._maximumHeight?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,s){super(e,t,null!=s?s:new mt(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 m,this.onDidChange=this._onDidChange.event,"number"==typeof(null==i?void 0:i.minimumWidth)&&(this._minimumWidth=i.minimumWidth),"number"==typeof(null==i?void 0:i.maximumWidth)&&(this._maximumWidth=i.maximumWidth),"number"==typeof(null==i?void 0:i.minimumHeight)&&(this._minimumHeight=i.minimumHeight),"number"==typeof(null==i?void 0:i.maximumHeight)&&(this._maximumHeight=i.maximumHeight),this.api.initialize(this),this.addDisposables(this.api.onWillVisibilityChange(e=>{const{isVisible:t}=e,{accessor:i}=this._params;i.setVisible(this,t)}),this.api.onActiveChange(()=>{const{accessor:e}=this._params;e.doSetGroupActive(this)}),this.api.onDidConstraintsChangeInternal(e=>{"number"!=typeof e.minimumWidth&&"function"!=typeof e.minimumWidth||(this._minimumWidth=e.minimumWidth),"number"!=typeof e.minimumHeight&&"function"!=typeof e.minimumHeight||(this._minimumHeight=e.minimumHeight),"number"!=typeof e.maximumWidth&&"function"!=typeof e.maximumWidth||(this._maximumWidth=e.maximumWidth),"number"!=typeof e.maximumHeight&&"function"!=typeof e.maximumHeight||(this._maximumHeight=e.maximumHeight)}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({height:e.height,width:e.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),"boolean"==typeof e.isVisible&&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=e=>e===Number.MAX_SAFE_INTEGER?void 0:e,i=e=>e<=0?void 0:e;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 gt="dockview: DockviewGroupPanelApiImpl not initialized";class _t extends mt{get location(){if(!this._group)throw new Error(gt);return this._group.model.location}get locked(){if(!this._group)throw new Error(gt);return this._group.locked}set locked(e){if(!this._group)throw new Error(gt);this._group.locked=e}constructor(e,t){super(e,"__dockviewgroup__"),this.accessor=t,this._onDidLocationChange=new m,this.onDidLocationChange=this._onDidLocationChange.event,this._onDidActivePanelChange=new m,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidCollapsedChange=new m,this.onDidCollapsedChange=this._onDidCollapsedChange.event,this.addDisposables(this._onDidLocationChange,this._onDidActivePanelChange,this._onDidCollapsedChange,this._onDidVisibilityChange.event(e=>{e.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"popout"===this.location.type?this.location.getWindow():window}setHeaderPosition(e){if(!this._group)throw new Error(gt);this._group.model.headerPosition=e}getHeaderPosition(){if(!this._group)throw new Error(gt);return this._group.model.headerPosition}moveTo(e){var t,i,s,o;if(!this._group)throw new Error(gt);const n=null!==(t=e.group)&&void 0!==t?t:this.accessor.addGroup({direction:De(null!==(i=e.position)&&void 0!==i?i:"right"),skipSetActive:null!==(s=e.skipSetActive)&&void 0!==s&&s});this.accessor.moveGroupOrPanel({from:{groupId:this._group.id},to:{group:n,position:e.group&&null!==(o=e.position)&&void 0!==o?o:"center",index:e.index},skipSetActive:e.skipSetActive})}maximize(){if(!this._group)throw new Error(gt);"grid"===this.location.type&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw new Error(gt);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw new Error(gt);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)}initialize(e){this._group=e}}class ft extends vt{get minimumWidth(){var e;if("number"==typeof this._explicitConstraints.minimumWidth)return this._explicitConstraints.minimumWidth;const t=null===(e=this.activePanel)||void 0===e?void 0:e.minimumWidth;return"number"==typeof t?t:super.__minimumWidth()}get minimumHeight(){var e;if("number"==typeof this._explicitConstraints.minimumHeight)return this._explicitConstraints.minimumHeight;const t=null===(e=this.activePanel)||void 0===e?void 0:e.minimumHeight;return"number"==typeof t?t:super.__minimumHeight()}get maximumWidth(){var e;if("number"==typeof this._explicitConstraints.maximumWidth)return this._explicitConstraints.maximumWidth;const t=null===(e=this.activePanel)||void 0===e?void 0:e.maximumWidth;return"number"==typeof t?t:super.__maximumWidth()}get maximumHeight(){var e;if("number"==typeof this._explicitConstraints.maximumHeight)return this._explicitConstraints.maximumHeight;const t=null===(e=this.activePanel)||void 0===e?void 0:e.maximumHeight;return"number"==typeof t?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 s,o,n,r,a,h;super(t,"groupview_default",{minimumHeight:null!==(o=null===(s=i.constraints)||void 0===s?void 0:s.minimumHeight)&&void 0!==o?o:100,minimumWidth:null!==(r=null===(n=i.constraints)||void 0===n?void 0:n.minimumWidth)&&void 0!==r?r:100,maximumHeight:null===(a=i.constraints)||void 0===a?void 0:a.maximumHeight,maximumWidth:null===(h=i.constraints)||void 0===h?void 0:h.maximumWidth},new _t(t,e)),this._explicitConstraints={},this.api.initialize(this),this._model=new ct(this.element,e,t,i,this),this.addDisposables(this.model.onDidActivePanelChange(e=>{this.api._onDidActivePanelChange.fire(e)}),this.api.onDidConstraintsChangeInternal(e=>{void 0!==e.minimumWidth&&(this._explicitConstraints.minimumWidth="function"==typeof e.minimumWidth?e.minimumWidth():e.minimumWidth),void 0!==e.minimumHeight&&(this._explicitConstraints.minimumHeight="function"==typeof e.minimumHeight?e.minimumHeight():e.minimumHeight),void 0!==e.maximumWidth&&(this._explicitConstraints.maximumWidth="function"==typeof e.maximumWidth?e.maximumWidth():e.maximumWidth),void 0!==e.maximumHeight&&(this._explicitConstraints.maximumHeight="function"==typeof e.maximumHeight?e.maximumHeight():e.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 bt={name:"abyss",className:"dockview-theme-abyss",colorScheme:"dark",tabGroupIndicator:"none"};class wt extends mt{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,s,o){super(e.id,s),this.panel=e,this.accessor=i,this._onDidTitleChange=new m,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidActiveGroupChange=new m,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new m,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new m,this.onDidRendererChange=this._onDidRendererChange.event,this._onDidLocationChange=new m,this.onDidLocationChange=this._onDidLocationChange.event,this.groupEventsDisposable=new l,this._tabComponent=o,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:null!==(t=e.group)&&void 0!==t?t:this._group,position:e.group&&null!==(i=e.position)&&void 0!==i?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=null!==(t=null==e?void 0:e.isActive)&&void 0!==t&&t;this.groupEventsDisposable.value=new h(this.group.api.onDidVisibilityChange(e=>{const t=!e.isVisible&&this.isVisible,i=e.isVisible&&!this.isVisible,s=this.group.model.isPanelActive(this.panel);(t||i&&s)&&this._onDidVisibilityChange.fire(e)}),this.group.api.onDidLocationChange(e=>{this.group===this.panel.group&&this._onDidLocationChange.fire(e)}),this.group.api.onDidActiveChange(()=>{this.group===this.panel.group&&i!==this.isGroupActive&&(i=this.isGroupActive,this._onDidActiveGroupChange.fire({isActive:this.isGroupActive}))}))}}class Dt extends h{get params(){return this._params}get title(){return this._title}get group(){return this._group}get renderer(){var e;return null!==(e=this._renderer)&&void 0!==e?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,s,o,n,r,a){super(),this.id=e,this.accessor=s,this.containerApi=o,this.view=r,this._renderer=a.renderer,this._group=n,this._minimumWidth=a.minimumWidth,this._minimumHeight=a.minimumHeight,this._maximumWidth=a.maximumWidth,this._maximumHeight=a.maximumHeight,this.api=new wt(this,this._group,s,t,i),this.addDisposables(this.api.onActiveChange(()=>{s.setActivePanel(this)}),this.api.onDidSizeChange(e=>{this.group.api.setSize(e)}),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 Pe;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.view.setTitle(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({},null!==(t=this._params)&&void 0!==t?t:{}),e.params);for(const t of Object.keys(e.params))void 0===e.params[t]&&delete this._params[t];this.view.update({params:this._params})}updateFromStateModel(e){var t,i,s;this._maximumHeight=e.maximumHeight,this._minimumHeight=e.minimumHeight,this._maximumWidth=e.maximumWidth,this._minimumWidth=e.minimumWidth,this.update({params:null!==(t=e.params)&&void 0!==t?t:{}}),this.setTitle(null!==(i=e.title)&&void 0!==i?i:this.id),this.setRenderer(null!==(s=e.renderer)&&void 0!==s?s:this.accessor.renderer)}updateParentGroup(e,t){this._group=e,this.api.group=this._group;const i=this._group.model.isPanelActive(this),s=this.group.api.isActive&&i;(null==t?void 0:t.skipSetActive)||this.api.isActive!==s&&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 Ct extends h{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(tt({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"})),this._element.appendChild(this._content),this._element.appendChild(this.action),this.render()}init(e){this._title=e.title,this.addDisposables(e.api.onDidTitleChange(e=>{this._title=e.title,this.render()}),v(this.action,"pointerdown",e=>{e.preventDefault()}),v(this.action,"click",t=>{t.defaultPrevented||(t.preventDefault(),e.api.close())})),this.render()}render(){var e;this._content.textContent!==this._title&&(this._content.textContent=null!==(e=this._title)&&void 0!==e?e:"")}}class yt{get content(){return this._content}get tab(){return this._tab}constructor(e,t,i,s){this.accessor=e,this.id=t,this.contentComponent=i,this.tabComponent=s,this._content=this.createContentComponent(this.id,i),this._tab=this.createTabComponent(this.id,s)}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&&(null===(t=i.update)||void 0===t||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"}))}setTitle(e){this._params&&(this._params.title=e)}layout(e,t){var i,s;null===(s=(i=this.content).layout)||void 0===s||s.call(i,e,t)}update(e){var t,i,s,o;this._updateEvent=e,null===(i=(t=this.content).update)||void 0===i||i.call(t,e),null===(o=(s=this.tab).update)||void 0===o||o.call(s,e)}dispose(){var e,t,i,s;null===(t=(e=this.content).dispose)||void 0===t||t.call(e),null===(s=(i=this.tab).dispose)||void 0===s||s.call(i)}createContentComponent(e,t){return this.accessor.options.createComponent({id:e,name:t})}createTabComponent(e,t){const i=null!=t?t:this.accessor.options.defaultTabComponent;if(i){if(this.accessor.options.createTabComponent){const t=this.accessor.options.createTabComponent({id:e,name:i});return t||new Ct}console.warn(`dockview: tabComponent '${t}' was not found. falling back to the default tab.`)}return new Ct}}class St{constructor(e){this.accessor=e}fromJSON(e,t){var i,s;const o=e.id,n=e.params,r=e.title,a=e.view,h=a?a.content.id:null!==(i=e.contentComponent)&&void 0!==i?i:"unknown",l=a?null===(s=a.tab)||void 0===s?void 0:s.id:e.tabComponent,d=new yt(this.accessor,o,h,l),p=new Dt(o,h,l,this.accessor,new ge(this.accessor),t,d,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return p.init({title:null!=r?r:o,params:null!=n?n:{}}),p}}class xt extends h{get element(){return this._element}constructor(){super(),this._element=document.createElement("div"),this._element.className="dv-watermark"}init(e){}}const Gt=new class{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) + ${2*e})`}};class Pt extends h{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 m,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new m,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})),Gt.push(this._element)}setVisible(e){e!==this.isVisible&&(this._isVisible=e,D(this.element,"dv-hidden",!this.isVisible))}bringToFront(){Gt.push(this._element)}setBounds(e={}){"number"==typeof e.height&&(this._element.style.height=`${e.height}px`),"number"==typeof e.width&&(this._element.style.width=`${e.width}px`),"top"in e&&"number"==typeof e.top&&(this._element.style.top=`${e.top}px`,this._element.style.bottom="auto",this.verticalAlignment="top"),"bottom"in e&&"number"==typeof e.bottom&&(this._element.style.bottom=`${e.bottom}px`,this._element.style.top="auto",this.verticalAlignment="bottom"),"left"in e&&"number"==typeof e.left&&(this._element.style.left=`${e.left}px`,this._element.style.right="auto",this.horiziontalAlignment="left"),"right"in e&&"number"==typeof e.right&&(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(),s=Math.max(0,this.getMinimumWidth(i.width)),o=Math.max(0,this.getMinimumHeight(i.height));if("top"===this.verticalAlignment){const e=L(i.top-t.top,-o,Math.max(0,t.height-i.height+o));this._element.style.top=`${e}px`,this._element.style.bottom="auto"}if("bottom"===this.verticalAlignment){const e=L(t.bottom-i.bottom,-o,Math.max(0,t.height-i.height+o));this._element.style.bottom=`${e}px`,this._element.style.top="auto"}if("left"===this.horiziontalAlignment){const e=L(i.left-t.left,-s,Math.max(0,t.width-i.width+s));this._element.style.left=`${e}px`,this._element.style.right="auto"}if("right"===this.horiziontalAlignment){const e=L(t.right-i.right,-s,Math.max(0,t.width-i.width+s));this._element.style.right=`${e}px`,this._element.style.left="auto"}this._onDidChange.fire()}toJSON(){const e=this.options.container.getBoundingClientRect(),t=this._element.getBoundingClientRect(),i={};return"top"===this.verticalAlignment?i.top=parseFloat(this._element.style.top):"bottom"===this.verticalAlignment?i.bottom=parseFloat(this._element.style.bottom):i.top=t.top-e.top,"left"===this.horiziontalAlignment?i.left=parseFloat(this._element.style.left):"right"===this.horiziontalAlignment?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 l,s=()=>{let e=null;const t=A();i.value=new h({dispose:()=>{t.release()}},v(window,"pointermove",t=>{const i=this.options.container.getBoundingClientRect(),s=t.clientX-i.left,o=t.clientY-i.top;D(this._element,"dv-resize-container-dragging",!0);const n=this._element.getBoundingClientRect();null===e&&(e={x:t.clientX-n.left,y:t.clientY-n.top});const r=Math.max(0,this.getMinimumWidth(n.width)),a=Math.max(0,this.getMinimumHeight(n.height)),h=L(o-e.y,-a,Math.max(0,i.height-n.height+a)),l=L(e.y-o+i.height-n.height,-a,Math.max(0,i.height-n.height+a)),d=L(s-e.x,-r,Math.max(0,i.width-n.width+r)),p=L(e.x-s+i.width-n.width,-r,Math.max(0,i.width-n.width+r)),u={};h<=l?u.top=h:u.bottom=l,d<=p?u.left=d:u.right=p,this.setBounds(u)}),v(window,"pointerup",()=>{D(this._element,"dv-resize-container-dragging",!1),i.dispose(),this._onDidChangeEnd.fire()}))};this.addDisposables(i,v(e,"pointerdown",e=>{e.defaultPrevented?e.preventDefault():G(e)||s()}),v(this.options.content,"pointerdown",e=>{e.defaultPrevented||G(e)||e.shiftKey&&s()}),v(this.options.content,"pointerdown",()=>{Gt.push(this._element)},!0)),t.inDragMode&&s()}setupResize(e){const t=document.createElement("div");t.className=`dv-resize-handle-${e}`,this._element.appendChild(t);const i=new l;this.addDisposables(i,v(t,"pointerdown",t=>{t.preventDefault();let s=null;const o=A();i.value=new h(v(window,"pointermove",t=>{const i=this.options.container.getBoundingClientRect(),o=this._element.getBoundingClientRect(),n=t.clientY-i.top,r=t.clientX-i.left;let a,h,l,d,p,u;null===s&&(s={originalY:n,originalHeight:o.height,originalX:r,originalWidth:o.width});const c=()=>{const e=s.originalY+s.originalHeight>i.height?Math.max(0,i.height-Pt.MINIMUM_HEIGHT):Math.max(0,s.originalY+s.originalHeight-Pt.MINIMUM_HEIGHT);a=L(n,0,e),l=s.originalY+s.originalHeight-a,h=i.height-a-l},m=()=>{a=s.originalY-s.originalHeight;const e=a<0&&"number"==typeof this.options.minimumInViewportHeight?-a+this.options.minimumInViewportHeight:Pt.MINIMUM_HEIGHT,t=i.height-Math.max(0,a);l=L(n-a,e,t),h=i.height-a-l},v=()=>{const e=s.originalX+s.originalWidth>i.width?Math.max(0,i.width-Pt.MINIMUM_WIDTH):Math.max(0,s.originalX+s.originalWidth-Pt.MINIMUM_WIDTH);d=L(r,0,e),u=s.originalX+s.originalWidth-d,p=i.width-d-u},g=()=>{d=s.originalX-s.originalWidth;const e=d<0&&"number"==typeof this.options.minimumInViewportWidth?-d+this.options.minimumInViewportWidth:Pt.MINIMUM_WIDTH,t=i.width-Math.max(0,d);u=L(r-d,e,t),p=i.width-d-u};switch(e){case"top":c();break;case"bottom":m();break;case"left":v();break;case"right":g();break;case"topleft":c(),v();break;case"topright":c(),g();break;case"bottomleft":m(),v();break;case"bottomright":m(),g()}const _={};a<=h?_.top=a:_.bottom=h,d<=p?_.left=d:_.right=p,_.height=l,_.width=u,this.setBounds(_)}),{dispose:()=>{o.release()}},v(window,"pointerup",()=>{i.dispose(),this._onDidChangeEnd.fire()}))}))}getMinimumWidth(e){return"number"==typeof this.options.minimumInViewportWidth?e-this.options.minimumInViewportWidth:0}getMinimumHeight(e){return"number"==typeof this.options.minimumInViewportHeight?e-this.options.minimumInViewportHeight:0}dispose(){Gt.destroy(this._element),this._element.remove(),super.dispose()}}Pt.MINIMUM_HEIGHT=20,Pt.MINIMUM_WIDTH=20;class At extends h{constructor(e,t){super(),this.group=e,this.overlay=t,this.addDisposables(t)}position(e){this.overlay.setBounds(e)}}const zt=100,It=100,Tt=100,Et=300,Ot=300;class kt{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=P(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}))}}class Vt extends h{constructor(t,i){super(),this.element=t,this.accessor=i,this.map={},this._disposed=!1,this.positionCache=new kt,this.pendingUpdates=new Set,this.addDisposables(e.DockviewDisposable.from(()=>{for(const e of Object.values(this.map))e.disposable.dispose(),e.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(t){const{panel:i,referenceContainer:s}=t;if(!this.map[i.api.id]){const t=function(){const e=document.createElement("div");return e.tabIndex=-1,e}();t.className="dv-render-overlay",t.style.visibility="hidden",this.map[i.api.id]={panel:i,disposable:e.DockviewDisposable.NONE,destroy:e.DockviewDisposable.NONE,element:t}}const o=this.map[i.api.id].element,n=i.view.content.element;n.parentElement!==o&&o.appendChild(n),o.parentElement!==this.element&&this.element.appendChild(o);const r=()=>{const e=i.api.id;this.pendingUpdates.has(e)||(this.pendingUpdates.add(e),requestAnimationFrame(()=>{if(this.pendingUpdates.delete(e),this.isDisposed||!this.map[e])return;const t=this.positionCache.getPosition(s.element),n=this.positionCache.getPosition(this.element),r=t.left-n.left,a=t.top-n.top,h=t.width,l=t.height;o.style.left=`${r}px`,o.style.top=`${a}px`,o.style.width=`${h}px`,o.style.height=`${l}px`,i.api.isVisible?(o.style.visibility="",o.style.pointerEvents=""):(o.style.visibility="hidden",o.style.pointerEvents="none"),D(o,"dv-render-overlay-float","floating"===i.group.api.location.type)}))},a=()=>{i.api.isVisible?(this.positionCache.invalidate(),r(),o.style.pointerEvents=""):(o.style.visibility="hidden",o.style.pointerEvents="none")},d=new l,p=()=>{"floating"===i.api.location.type?queueMicrotask(()=>{const t=this.accessor.floatingGroups.find(e=>e.group===i.api.group);if(!t)return;const s=t.overlay.element,n=()=>{const e=Number(s.getAttribute("aria-level"));o.style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${2*e+1})`},r=new MutationObserver(()=>{n()});d.value=e.DockviewDisposable.from(()=>r.disconnect()),r.observe(s,{attributeFilter:["aria-level"],attributes:!0}),n()}):o.style.zIndex=""},u=new h(d,new fe(o,{onDragEnd:e=>{s.dropTarget.dnd.onDragEnd(e)},onDragEnter:e=>{s.dropTarget.dnd.onDragEnter(e)},onDragLeave:e=>{s.dropTarget.dnd.onDragLeave(e)},onDrop:e=>{s.dropTarget.dnd.onDrop(e)},onDragOver:e=>{s.dropTarget.dnd.onDragOver(e)}}),i.api.onDidVisibilityChange(()=>{a()}),i.api.onDidDimensionsChange(()=>{i.api.isVisible&&r()}),i.api.onDidLocationChange(()=>{p()}));return this.map[i.api.id].destroy=e.DockviewDisposable.from(()=>{var e;n.parentElement===o&&o.removeChild(n),null===(e=o.parentElement)||void 0===e||e.removeChild(o)}),p(),queueMicrotask(()=>{this.isDisposed||a()}),this.map[i.api.id].disposable.dispose(),this.map[i.api.id].disposable=u,this.map[i.api.id].resize=r,o}}function Mt(e,t,i,s){return new(i||(i=Promise))(function(o,n){function r(e){try{h(s.next(e))}catch(e){n(e)}}function a(e){try{h(s.throw(e))}catch(e){n(e)}}function h(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,a)}h((s=s.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class Lt extends h{get window(){var e,t;return null!==(t=null===(e=this._window)||void 0===e?void 0:e.value)&&void 0!==t?t:null}constructor(e,t,i){super(),this.target=e,this.className=t,this.options=i,this._onWillClose=new m,this.onWillClose=this._onWillClose.event,this._onDidClose=new m,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;return{top:this._window.value.screenY,left:e,width:this._window.value.innerWidth,height:this._window.value.innerHeight}}close(){var e,t;this._window&&(this._onWillClose.fire(),null===(t=(e=this.options).onWillClose)||void 0===t||t.call(e,{id:this.target,window:this._window.value}),this._window.disposable.dispose(),this._window=null,this._onDidClose.fire())}open(){return Mt(this,void 0,void 0,function*(){var t,i;if(this._window)throw new Error("instance of popout window is already open");const s=`${this.options.url}`;!function(e){let t;try{t=new URL(e,window.location.href)}catch(t){throw new Error(`dockview: invalid popout URL: ${e}`)}if("http:"!==t.protocol&&"https:"!==t.protocol||t.origin!==window.location.origin)throw new Error(`dockview: popout URL must be same-origin http(s); got: ${e}`)}(s);const o=Object.entries({top:this.options.top,left:this.options.left,width:this.options.width,height:this.options.height}).map(([e,t])=>`${e}=${t}`).join(","),n=window.open(s,this.target,o);if(!n)return null;const r=new h;this._window={value:n,disposable:r},r.addDisposables(e.DockviewDisposable.from(()=>{n.close()}),v(window,"beforeunload",()=>{this.close()}));const a=this.createPopoutWindowContainer();return this.className&&a.classList.add(this.className),null===(i=(t=this.options).onDidOpen)||void 0===i||i.call(t,{id:this.target,window:n}),new Promise((e,t)=>{n.addEventListener("unload",e=>{}),n.addEventListener("load",()=>{try{const t=n.document;t.title=document.title,t.body.appendChild(a),function(e,t,i={}){const s=Array.from(t),{nonce:o}=i,n="function"==typeof o?o(e):o;for(const t of s){if(t.href){const i=e.createElement("link");i.href=t.href,i.type=t.type,i.rel="stylesheet",e.head.appendChild(i);continue}let i=[];try{t.cssRules&&(i=Array.from(t.cssRules).map(e=>e.cssText))}catch(e){console.warn("dockview: failed to access stylesheet rules due to security restrictions",e)}const s=e.createDocumentFragment();for(const t of i){const i=e.createElement("style");n&&i.setAttribute("nonce",n),i.appendChild(e.createTextNode(t)),s.appendChild(i)}e.head.appendChild(s)}}(t,window.document.styleSheets,{nonce:this.options.nonce}),v(n,"beforeunload",()=>{this.close()}),e(a)}catch(e){t(e)}})})})}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 Nt extends h{constructor(e){super(),this.accessor=e,this.init()}init(){const e=new Set,t=new Set;this.addDisposables(this.accessor.onDidAddPanel(t=>{if(e.has(t.api.id))throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${t.api.id} but panel already exists`);e.add(t.api.id)}),this.accessor.onDidRemovePanel(t=>{if(!e.has(t.api.id))throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${t.api.id} but panel does not exists`);e.delete(t.api.id)}),this.accessor.onDidAddGroup(e=>{if(t.has(e.api.id))throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${e.api.id} but group already exists`);t.add(e.api.id)}),this.accessor.onDidRemoveGroup(e=>{if(!t.has(e.api.id))throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${e.api.id} but group does not exists`);t.delete(e.api.id)}))}}class Rt extends h{constructor(t,i=window){super(),this._active=null,this._activeDisposable=new l,this._root=t,this._window=i,this._element=i.document.createElement("div"),this._element.className="dv-popover-anchor",this._element.style.position="relative",this._root.prepend(this._element),this.addDisposables(e.DockviewDisposable.from(()=>{this.close()}),this._activeDisposable)}updateRoot(e){e.prepend(this._element),this._root=e}openPopover(e,t){var i;this.close();const s=this._window.document.createElement("div");s.style.position="absolute",s.style.zIndex=null!==(i=t.zIndex)&&void 0!==i?i:"var(--dv-overlay-z-index)",s.appendChild(e);const o=this._element.getBoundingClientRect(),n=o.left,r=o.top;s.style.top=t.y-r+"px",s.style.left=t.x-n+"px",this._element.appendChild(s),this._active=s,this._activeDisposable.value=new h(v(this._window,"pointerdown",e=>{var t;const i=e.target;if(!(i instanceof HTMLElement))return;let o=i;for(;o&&o!==s;)o=null!==(t=null==o?void 0:o.parentElement)&&void 0!==t?t:null;o||this.close()}),v(this._window,"keydown",e=>{"Escape"!==e.key&&"Enter"!==e.key||this.close()}),v(this._window,"resize",()=>{this.close()})),this._window.requestAnimationFrame(()=>{!function(e,t,i={buffer:10}){const s=i.buffer,o=e.getBoundingClientRect(),n=t.getBoundingClientRect();let r=0,a=0;const h=o.left-n.left,l=o.top-n.top,d=o.bottom-n.bottom,p=o.right-n.right;h<s?r=s-h:p>s&&(r=-s-p),l<s?a=s-l:d>s&&(a=-d-s),0===r&&0===a||(e.style.transform=`translate(${r}px, ${a}px)`)}(s,this._root)})}close(){this._active&&(this._active.remove(),this._activeDisposable.dispose(),this._active=null)}}function Wt(e){if(!(e instanceof HTMLElement))return;const t=T(e);return(null==t?void 0:t.style.zIndex)?`calc(${t.style.zIndex} * 2)`:void 0}let Ht=0;const Ft=()=>"dv-ctx-menu-item-"+Ht++;function $t(e){return"object"==typeof e}function Bt(e,t,i,s){const o=document.createElement("div");return o.className="dv-context-menu-item",o.setAttribute("role","menuitem"),s&&(o.classList.add("dv-context-menu-item--disabled"),o.setAttribute("aria-disabled","true")),o.textContent=e,s||o.addEventListener("click",()=>{i(),t()}),o}function Ut(){const e=document.createElement("div");return e.className="dv-context-menu-separator",e.setAttribute("role","separator"),e}function Jt(e){const t=document.createElement("div");t.className="dv-context-menu-rename";const i=document.createElement("input");return i.className="dv-context-menu-rename-input",i.type="text",i.placeholder="Name This Group",i.value=e.label,i.addEventListener("input",()=>{e.setLabel(i.value)}),i.addEventListener("keydown",e=>{"Escape"!==e.key&&"Enter"!==e.key&&e.stopPropagation()}),i.addEventListener("click",e=>{e.stopPropagation()}),t.appendChild(i),requestAnimationFrame(()=>{i.focus(),i.select()}),t}function jt(e,t){const i=document.createElement("div");if(i.className="dv-context-menu-color-picker",!t.enabled)return i;for(const s of t.entries()){const t=document.createElement("div");t.className="dv-context-menu-color-swatch",t.style.setProperty("--dv-tab-group-color",s.value),s.label&&(t.title=s.label),e.color===s.id&&t.classList.add("dv-context-menu-color-swatch--selected"),t.addEventListener("click",()=>{e.setColor(s.id)}),i.appendChild(t)}return i}class Zt{constructor(e){this.accessor=e}show(e,t,i){var s,o;if(!this.accessor.options.getTabContextMenuItems)return;const n=this.accessor.options.getTabContextMenuItems({panel:e,group:t,api:this.accessor.api,event:i});if(0===n.length)return;i.preventDefault();const r=this.accessor.getPopupServiceForGroup(t),a=()=>r.close(),h=document.createElement("div");h.className="dv-context-menu",h.setAttribute("role","menu");for(const i of n)if("separator"===i)h.appendChild(Ut());else if("close"===i)h.appendChild(Bt("Close",a,()=>e.api.close()));else if("closeOthers"===i)h.appendChild(Bt("Close Others",a,()=>{t.panels.filter(t=>t!==e).forEach(e=>e.api.close())}));else if("closeAll"===i)h.appendChild(Bt("Close All",a,()=>{[...t.panels].forEach(e=>e.api.close())}));else if($t(i)&&i.element)h.appendChild(i.element);else if($t(i)&&i.component){const n=null===(o=(s=this.accessor.options).createContextMenuItemComponent)||void 0===o?void 0:o.call(s,{id:Ft(),component:i.component});n&&(n.init({panel:e,group:t,api:this.accessor.api,close:a,componentProps:i.componentProps}),h.appendChild(n.element))}else $t(i)&&i.label&&h.appendChild(Bt(i.label,a,()=>{var e;return null===(e=i.action)||void 0===e?void 0:e.call(i)},i.disabled));r.openPopover(h,{x:i.clientX,y:i.clientY,zIndex:Wt(i.target)})}showForChip(e,t,i){if(!this.accessor.options.getTabGroupChipContextMenuItems)return;const s=this.accessor.options.getTabGroupChipContextMenuItems({tabGroup:e,group:t,api:this.accessor.api,event:i});if(0===s.length)return;i.preventDefault();const o=this.accessor.getPopupServiceForGroup(t),n=()=>o.close(),r=document.createElement("div");r.className="dv-context-menu",r.setAttribute("role","menu");for(const t of s)"separator"===t?r.appendChild(Ut()):"rename"===t?r.appendChild(Jt(e)):"colorPicker"===t?r.appendChild(jt(e,this.accessor.tabGroupColorPalette)):$t(t)&&t.element?r.appendChild(t.element):$t(t)&&t.label&&r.appendChild(Bt(t.label,n,()=>{var e;return null===(e=t.action)||void 0===e?void 0:e.call(t)},t.disabled));o.openPopover(r,{x:i.clientX,y:i.clientY,zIndex:Wt(i.target)})}}class Yt extends h{get disabled(){return this._disabled}set disabled(e){var t;this.disabled!==e&&(this._disabled=e,e&&(null===(t=this.model)||void 0===t||t.clear()))}get model(){if(!this.disabled)return{clear:()=>{var e;this._model&&(null===(e=this._model.root.parentElement)||void 0===e||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 s=this.createContainer(),o=this.createAnchor();if(this._model={root:s,overlay:o,changed:i},s.appendChild(o),this.element.appendChild(s),(null==e?void 0:e.target)instanceof HTMLElement){const t=e.target.getBoundingClientRect(),i=this.element.getBoundingClientRect();o.style.left=t.left-i.left+"px",o.style.top=t.top-i.top+"px"}return this._model}}}constructor(t,i){super(),this.element=t,this._disabled=!1,this._disabled=i.disabled,this.addDisposables(e.DockviewDisposable.from(()=>{var e;null===(e=this.model)||void 0===e||e.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 Xt{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(t,i,s){var o,n,r;this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this.snap=!1,this.priority=e.LayoutPriority.Low,this._isCollapsed=!1,this._group=i,this._orientation=s,i.element.classList.add("dv-edge-group"),i.element.dataset.testid=`dv-edge-group-${t.id}`,this._collapsedSize=null!==(o=t.collapsedSize)&&void 0!==o?o:35,this._expandedMaximumSize=null!==(n=t.maximumSize)&&void 0!==n?n:Number.POSITIVE_INFINITY,this._expandedMinimumSize=void 0!==t.minimumSize?t.minimumSize:this._collapsedSize+50,this._lastExpandedSize=null!==(r=t.initialSize)&&void 0!==r?r:200,t.collapsed&&(this._isCollapsed=!0,i.element.classList.add("dv-edge-collapsed"))}layout(e,t){this._isCollapsed||(this._lastExpandedSize=e),"horizontal"===this._orientation?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 qt{get element(){return this._dockviewElement}constructor(t,i){this._dockviewElement=t,this._layoutDockview=i,this.priority=e.LayoutPriority.High,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this._onDidChange=new m,this.onDidChange=this._onDidChange.event}layout(e,t){this._layoutDockview(t,e)}setVisible(e){}dispose(){this._onDidChange.dispose()}}class Kt{get element(){return this._element}constructor(t,i=0){this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this.priority=e.LayoutPriority.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 U(this._element,{orientation:e.Orientation.VERTICAL,proportionalLayout:!1,margin:i}),this._centerIndex=0,this._splitview.addView(t,{type:"distribute"},0)}addTopView(e,t){this._splitview.addView(e,t,0),this._topIndex=0,this._centerIndex+=1,void 0!==this._bottomIndex&&(this._bottomIndex+=1)}addBottomView(e,t){const i=this._splitview.length;this._splitview.addView(e,t,i),this._bottomIndex=i}removeView(e){const t="top"===e?this._topIndex:this._bottomIndex;void 0!==t&&(this._splitview.removeView(t),"top"===e?(this._topIndex=void 0,this._centerIndex-=1,void 0!==this._bottomIndex&&(this._bottomIndex-=1)):this._bottomIndex=void 0)}layout(e,t){this._splitview.layout(t,e)}setVisible(e){}setViewVisible(e,t){const i="top"===e?this._topIndex:this._bottomIndex;void 0!==i&&this._splitview.setViewVisible(i,t)}isViewVisible(e){const t="top"===e?this._topIndex:this._bottomIndex;return void 0!==t&&this._splitview.isViewVisible(t)}getViewSize(e){const t="top"===e?this._topIndex:this._bottomIndex;return void 0!==t?this._splitview.getViewSize(t):0}resizeView(e,t){const i="top"===e?this._topIndex:this._bottomIndex;void 0!==i&&this._splitview.resizeView(i,t)}updateMargin(e){this._splitview.margin=e}dispose(){this._onDidChange.dispose(),this._splitview.dispose()}}class Qt{constructor(t,i,s,o=0,n=35){this._disposables=new h,this._viewConfigs=new Map,this._currentWidth=0,this._currentHeight=0,this._gap=o,this._defaultCollapsedSize=n,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",t.appendChild(this._shellElement);const r=new qt(i,s);this._middleColumn=new Kt(r,o),this._outerSplitview=new U(this._shellElement,{orientation:e.Orientation.HORIZONTAL,proportionalLayout:!1,margin:o}),this._middleIndex=0,this._outerSplitview.addView(this._middleColumn,{type:"distribute"},0),this._disposables.addDisposables(f(this._shellElement,e=>{const t=Math.round(e.contentRect.width),i=Math.round(e.contentRect.height);t===this._currentWidth&&i===this._currentHeight||(this._currentWidth=t,this._currentHeight=i,this.layout(t,i))}),this._outerSplitview,this._middleColumn,r)}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 s=1+(this._viewConfigs.has("left")?1:0)+(this._viewConfigs.has("right")?1:0),o=1+(this._viewConfigs.has("top")?1:0)+(this._viewConfigs.has("bottom")?1:0),n=s>1?this._gap*(s-1)/s:0,r=o>1?this._gap*(o-1)/o:0,a="left"===e||"right"===e,h=a?n:r,l=a?"horizontal":"vertical",d=new Xt(function(e,t,i){var s;const o=(null!==(s=e.collapsedSize)&&void 0!==s?s:t)+i,n=Object.assign(Object.assign({},e),{collapsedSize:o});return void 0!==e.minimumSize&&(n.minimumSize=e.minimumSize+i),n}(Object.assign({collapsedSize:this._defaultCollapsedSize},t),this._defaultCollapsedSize,h),i,l),p=d.isCollapsed?d.collapsedSize:d.lastExpandedSize;switch(e){case"left":this._outerSplitview.addView(d,p,0),this._leftIndex=0,this._middleIndex+=1,void 0!==this._rightIndex&&(this._rightIndex+=1),this._leftView=d;break;case"right":{const e=this._outerSplitview.length;this._outerSplitview.addView(d,p,e),this._rightIndex=e,this._rightView=d}break;case"top":this._middleColumn.addTopView(d,p),this._topView=d;break;case"bottom":this._middleColumn.addBottomView(d,p),this._bottomView=d}return this._disposables.addDisposables(d),this.updateTheme(this._gap,this._defaultCollapsedSize),d}layout(e,t){this._outerSplitview.layout(e,t)}updateTheme(e,t){var i,s,o,n;this._gap=e,this._defaultCollapsedSize=t;const r=1+(this._viewConfigs.has("left")?1:0)+(this._viewConfigs.has("right")?1:0),a=1+(this._viewConfigs.has("top")?1:0)+(this._viewConfigs.has("bottom")?1:0),h=r>1?e*(r-1)/r:0,l=a>1?e*(a-1)/a:0;this._outerSplitview.margin=e,this._middleColumn.updateMargin(e);const d=(e,i,s)=>{var o;const n=(null!==(o=i.collapsedSize)&&void 0!==o?o:t)+s,r=i.minimumSize,a=void 0!==r?r+s:n+50;e.updateCollapsedSize(n,a)},p=this._viewConfigs.get("top");this._topView&&p&&d(this._topView,p,l);const u=this._viewConfigs.get("bottom");this._bottomView&&u&&d(this._bottomView,u,l);const c=this._viewConfigs.get("left");this._leftView&&c&&d(this._leftView,c,h);const m=this._viewConfigs.get("right");this._rightView&&m&&d(this._rightView,m,h),(null===(i=this._leftView)||void 0===i?void 0:i.isCollapsed)&&void 0!==this._leftIndex&&this._outerSplitview.resizeView(this._leftIndex,this._leftView.collapsedSize),(null===(s=this._rightView)||void 0===s?void 0:s.isCollapsed)&&void 0!==this._rightIndex&&this._outerSplitview.resizeView(this._rightIndex,this._rightView.collapsedSize),(null===(o=this._topView)||void 0===o?void 0:o.isCollapsed)&&this._middleColumn.resizeView("top",this._topView.collapsedSize),(null===(n=this._bottomView)||void 0===n?void 0:n.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,void 0!==this._rightIndex&&(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}this._disposables.removeDisposable(t),t.dispose(),this._viewConfigs.delete(e),this.updateTheme(this._gap,this._defaultCollapsedSize)}}hasEdgeGroup(e){switch(e){case"top":return void 0!==this._topView;case"bottom":return void 0!==this._bottomView;case"left":return void 0!==this._leftView;case"right":return void 0!==this._rightView}}setEdgeGroupVisible(e,t){switch(e){case"left":void 0!==this._leftIndex&&this._outerSplitview.setViewVisible(this._leftIndex,t);break;case"right":void 0!==this._rightIndex&&this._outerSplitview.setViewVisible(this._rightIndex,t);break;case"top":case"bottom":this._middleColumn.setViewVisible(e,t)}}isEdgeGroupVisible(e){switch(e){case"left":return void 0!==this._leftIndex&&this._outerSplitview.isViewVisible(this._leftIndex);case"right":return void 0!==this._rightIndex&&this._outerSplitview.isViewVisible(this._rightIndex);case"top":case"bottom":return this._middleColumn.isViewVisible(e)}}setEdgeGroupCollapsed(e,t){const i=this._getView(e);if(!i)return;i.setCollapsed(t);const s=t?i.collapsedSize:i.lastExpandedSize;switch(e){case"left":void 0!==this._leftIndex&&this._outerSplitview.resizeView(this._leftIndex,s);break;case"right":void 0!==this._rightIndex&&this._outerSplitview.resizeView(this._rightIndex,s);break;case"top":case"bottom":this._middleColumn.resizeView(e,s)}}isEdgeGroupCollapsed(e){var t,i;return null!==(i=null===(t=this._getView(e))||void 0===t?void 0:t.isCollapsed)&&void 0!==i&&i}_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&&void 0!==this._leftIndex&&(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&&void 0!==this._rightIndex&&(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,s,o,n,r,a,h,l,d,p,u,c,m,v,g,_,f,b,w;e.left&&void 0!==this._leftIndex&&(null===(t=this._leftView)||void 0===t||t.restoreExpandedSize(e.left.size),null===(i=this._leftView)||void 0===i||i.setCollapsed(null!==(s=e.left.collapsed)&&void 0!==s&&s),this._outerSplitview.resizeView(this._leftIndex,e.left.collapsed&&null!==(n=null===(o=this._leftView)||void 0===o?void 0:o.collapsedSize)&&void 0!==n?n:e.left.size),e.left.visible||this._outerSplitview.setViewVisible(this._leftIndex,!1)),e.right&&void 0!==this._rightIndex&&(null===(r=this._rightView)||void 0===r||r.restoreExpandedSize(e.right.size),null===(a=this._rightView)||void 0===a||a.setCollapsed(null!==(h=e.right.collapsed)&&void 0!==h&&h),this._outerSplitview.resizeView(this._rightIndex,e.right.collapsed&&null!==(d=null===(l=this._rightView)||void 0===l?void 0:l.collapsedSize)&&void 0!==d?d:e.right.size),e.right.visible||this._outerSplitview.setViewVisible(this._rightIndex,!1)),e.top&&(null===(p=this._topView)||void 0===p||p.restoreExpandedSize(e.top.size),null===(u=this._topView)||void 0===u||u.setCollapsed(null!==(c=e.top.collapsed)&&void 0!==c&&c),this._middleColumn.resizeView("top",e.top.collapsed&&null!==(v=null===(m=this._topView)||void 0===m?void 0:m.collapsedSize)&&void 0!==v?v:e.top.size),e.top.visible||this._middleColumn.setViewVisible("top",!1)),e.bottom&&(null===(g=this._bottomView)||void 0===g||g.restoreExpandedSize(e.bottom.size),null===(_=this._bottomView)||void 0===_||_.setCollapsed(null!==(f=e.bottom.collapsed)&&void 0!==f&&f),this._middleColumn.resizeView("bottom",e.bottom.collapsed&&null!==(w=null===(b=this._bottomView)||void 0===b?void 0:b.collapsedSize)&&void 0!==w?w:e.bottom.size),e.bottom.visible||this._middleColumn.setViewVisible("bottom",!1))}dispose(){var e;this._disposables.dispose(),null===(e=this._shellElement.parentElement)||void 0===e||e.removeChild(this._shellElement)}}const ei={activationSize:{type:"pixels",value:10},size:{type:"pixels",value:20}};function ti(e){const t=e.from.activePanel;[...e.from.panels].map(t=>{const i=e.from.model.removePanel(t);return e.from.model.renderContainer.detatch(t),i}).forEach(i=>{e.to.model.openPanel(i,{skipSetActive:t!==i,skipSetGroupActive:!0})})}class ii extends ue{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 null!==(e=this.options.defaultRenderer)&&void 0!==e?e:"onlyWhenVisible"}get defaultHeaderPosition(){var e;return null!==(e=this.options.defaultHeaderPosition)&&void 0!==e?e:"top"}get api(){return this._api}get floatingGroups(){return this._floatingGroups}get popoutRestorationPromise(){return this._popoutRestorationPromise}constructor(t,i){var s,o,r,a,h,l;super(t,{proportionalLayout:!0,orientation:e.Orientation.HORIZONTAL,styles:i.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:i.disableAutoResizing,locked:i.locked,margin:null!==(o=null===(s=i.theme)||void 0===s?void 0:s.gap)&&void 0!==o?o:0,className:i.className}),this.nextGroupId=N(),this._deserializer=new St(this),this._watermark=null,this._popoutPopupServices=new Map,this._onWillDragPanel=new m,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new m,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new m,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new m,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new m,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onUnhandledDragOverEvent=new m,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this._onDidRemovePanel=new m,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new m,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPopoutGroupSizeChange=new m,this.onDidPopoutGroupSizeChange=this._onDidPopoutGroupSizeChange.event,this._onDidPopoutGroupPositionChange=new m,this.onDidPopoutGroupPositionChange=this._onDidPopoutGroupPositionChange.event,this._onDidOpenPopoutWindowFail=new m,this.onDidOpenPopoutWindowFail=this._onDidOpenPopoutWindowFail.event,this._onDidLayoutFromJSON=new m,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new m({replay:!0}),this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidMovePanel=new m,this.onDidMovePanel=this._onDidMovePanel.event,this._onDidCreateTabGroup=new m,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new m,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new m,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new m,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new m,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new m,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,this._onDidMaximizedGroupChange=new m,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._popoutRestorationCleanups=new Set,this._onDidRemoveGroup=new m,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new m,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidOptionsChange=new m,this.onDidOptionsChange=this._onDidOptionsChange.event,this._onDidActiveGroupChange=new m,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._moving=!1,this._options=i,this._tabGroupColorPalette=function(e){var t;const i=null!==(t=e.tabGroupColors)&&void 0!==t?t:Fe,s="off"!==e.tabGroupAccent;return new $e(i,s)}(i),this.popupService=new Rt(this.element),this.contextMenuController=new Zt(this),this._api=new ge(this),this.disableResizing=!0,t.removeChild(this.element),this._shellManager=new Qt(t,this.element,(e,t)=>this._layoutFromShell(e,t),null!==(a=null===(r=i.theme)||void 0===r?void 0:r.gap)&&void 0!==a?a:0,null===(h=i.theme)||void 0===h?void 0:h.edgeGroupCollapsedSize),this.popupService.updateRoot(this._shellManager.element),this._shellThemeClassnames=new z(this._shellManager.element),this.rootDropTargetContainer=new Yt(this._shellManager.element,{disabled:!0}),this.overlayRenderContainer=new Vt(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 Se(this.element,{className:"dv-drop-target-edge",canDisplayOverlay:(e,t)=>{const i=n();if(i)return i.viewId===this.id&&("center"!==t||0===this.gridview.length);if("center"===t&&0!==this.gridview.length)return!1;const s=new ot(e,"edge",t,n);return this._onUnhandledDragOverEvent.fire(s),s.isAccepted},acceptedTargetZones:["top","bottom","left","right","center"],overlayModel:null!==(l=i.rootOverlayModel)&&void 0!==l?l:ei,getOverrideTarget:()=>{var e;return null===(e=this.rootDropTargetContainer)||void 0===e?void 0:e.model}}),this.updateDropTargetModel(i),D(this.gridview.element,"dv-dockview",!0),D(this.element,"dv-debug",!!i.debug),this.updateTheme(),this.updateWatermark(),i.debug&&this.addDisposables(new Nt(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(e=>{this._moving||this._onDidAddGroup.fire(e)}),this.onDidRemove(e=>{this._moving||this._onDidRemoveGroup.fire(e)}),this.onDidActiveChange(e=>{this._moving||this._onDidActiveGroupChange.fire(e)}),this.onDidMaximizedChange(e=>{this._onDidMaximizedGroupChange.fire({group:e.panel,isMaximized:e.isMaximized})}),e.DockviewEvent.any(this.onDidAdd,this.onDidRemove)(()=>{this.updateWatermark()}),e.DockviewEvent.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()}),e.DockviewDisposable.from(()=>{var e;for(const e of[...this._popoutRestorationCleanups])e();this._popoutRestorationCleanups.clear();for(const e of[...this._floatingGroups])e.dispose();for(const e of[...this._popoutGroups])e.disposable.dispose();null===(e=this._shellManager)||void 0===e||e.dispose();for(const e of this._edgeGroupDisposables.values())e.dispose();this._edgeGroupDisposables.clear()}),this._rootDropTarget,this._rootDropTarget.onWillShowOverlay(e=>{this.gridview.length>0&&"center"===e.position||this._onWillShowOverlay.fire(new Ne(e,{kind:"edge",panel:void 0,api:this._api,group:void 0,getData:n}))}),this._rootDropTarget.onDrop(e=>{var t;const i=new ut({nativeEvent:e.nativeEvent,position:e.position,panel:void 0,api:this._api,group:void 0,getData:n,kind:"edge"});if(this._onWillDrop.fire(i),i.defaultPrevented)return;const s=n();s?this.moveGroupOrPanel({from:{groupId:s.groupId,panelId:null!==(t=s.panelId)&&void 0!==t?t:void 0},to:{group:this.orthogonalize(e.position),position:"center"}}):this._onDidDrop.fire(new pt({nativeEvent:e.nativeEvent,position:e.position,panel:void 0,api:this._api,group:void 0,getData:n}))}),this._rootDropTarget)}setVisible(e,t){switch(e.api.location.type){case"grid":super.setVisible(e,t);break;case"floating":{const i=this.floatingGroups.find(t=>t.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")}}getPopupServiceForGroup(e){var t;return null!==(t=this._popoutPopupServices.get(e.id))&&void 0!==t?t:this.popupService}addPopoutGroup(t,i){var s,o,n,r,a,l;if(t instanceof ft&&"edge"===t.model.location.type)return Promise.resolve(!1);if(t instanceof Dt&&1===t.group.size)return this.addPopoutGroup(t.group,i);const d=function(e){function t(e){const t=[];for(let i=0;i<e.classList.length;i++)t.push(e.classList.item(i));return t}let i,s=e;for(;null!==s&&(i=t(s).find(e=>e.startsWith("dockview-theme-")),"string"!=typeof i);)s=s.parentElement;return i}(this.gridview.element),p=this.element;const u=(null==i?void 0:i.position)?i.position:t instanceof ft?t.element.getBoundingClientRect():t.group?t.group.element.getBoundingClientRect():p.getBoundingClientRect(),c=null!==(o=null===(s=null==i?void 0:i.overridePopoutGroup)||void 0===s?void 0:s.id)&&void 0!==o?o:this.getNextGroupId(),g=new Lt(`${this.id}-${c}`,null!=d?d:"",{url:null!==(a=null!==(n=null==i?void 0:i.popoutUrl)&&void 0!==n?n:null===(r=this.options)||void 0===r?void 0:r.popoutUrl)&&void 0!==a?a:"/popout.html",left:window.screenX+u.left,top:window.screenY+u.top,width:u.width,height:u.height,onDidOpen:null==i?void 0:i.onDidOpen,onWillClose:null==i?void 0:i.onWillClose,nonce:null===(l=this.options)||void 0===l?void 0:l.nonce}),_=new h(g,g.onDidClose(()=>{_.dispose()}));return g.open().then(s=>{var o;if(g.isDisposed)return!1;const n=(null==i?void 0:i.referenceGroup)?i.referenceGroup:t instanceof Dt?t.group:t,r=t.api.location.type,a=null!==n.element.parentElement;let l;if(a?(null==i?void 0:i.overridePopoutGroup)?l=i.overridePopoutGroup:(l=this.createGroup({id:c}),s&&this._onDidAddGroup.fire(l)):l=n,null===s)return console.error("dockview: failed to create popout. perhaps you need to allow pop-ups for this website"),_.dispose(),this._onDidOpenPopoutWindowFail.fire(),this.movingLock(()=>ti({from:l,to:n})),n.api.isVisible||n.api.setVisible(!0),!1;const d=document.createElement("div");d.className="dv-overlay-render-container";const p=new Vt(d,this);let u;if(l.model.renderContainer=p,l.layout(g.window.innerWidth,g.window.innerHeight),!(null==i?void 0:i.overridePopoutGroup)&&a)if(t instanceof Dt)this.movingLock(()=>{const e=n.model.removePanel(t);l.model.openPanel(e)});else switch(this.movingLock(()=>ti({from:n,to:l})),r){case"grid":n.api.setVisible(!1);break;case"floating":case"popout":u=null===(o=this._floatingGroups.find(e=>e.group.api.id===t.api.id))||void 0===o?void 0:o.overlay.toJSON(),this.removeGroup(n)}s.classList.add("dv-dockview"),s.style.overflow="hidden",s.appendChild(d),s.appendChild(l.element);const f=document.createElement("div"),b=new Yt(f,{disabled:this.rootDropTargetContainer.disabled});s.appendChild(f),l.model.dropTargetContainer=b;const w=new Rt(s,g.window);let D;this._popoutPopupServices.set(l.id,w),_.addDisposables(w,e.DockviewDisposable.from(()=>{this._popoutPopupServices.delete(l.id)})),l.model.location={type:"popout",getWindow:()=>g.window,popoutUrl:null==i?void 0:i.popoutUrl},a&&"grid"===t.api.location.type&&t.api.setVisible(!1),this.doSetGroupAndPanelActive(l),_.addDisposables(l.api.onDidActiveChange(e=>{var t;e.isActive&&(null===(t=g.window)||void 0===t||t.focus())}),l.api.onWillFocus(()=>{var e;null===(e=g.window)||void 0===e||e.focus()}));const C=a&&n&&this.getPanel(n.id),y={window:g,popoutGroup:l,referenceGroup:C?n.id:void 0,disposable:{dispose:()=>(_.dispose(),D)}},S=function(e){const t=new m;let i,s=e.screenX,o=e.screenY;const n=()=>{if(e.closed)return;const r=e.screenX,a=e.screenY;r===s&&a===o||(clearTimeout(i),i=setTimeout(()=>{t.fire()},100),s=r,o=a),requestAnimationFrame(n)};return n(),t}(g.window);return _.addDisposables(S,function(e,t){let i;return new h(v(e,"resize",()=>{clearTimeout(i),i=setTimeout(()=>{t()},100)}))}(g.window,()=>{this._onDidPopoutGroupSizeChange.fire({width:g.window.innerWidth,height:g.window.innerHeight,group:l})}),S.event(()=>{this._onDidPopoutGroupPositionChange.fire({screenX:g.window.screenX,screenY:g.window.screenX,group:l})}),v(g.window,"resize",()=>{l.layout(g.window.innerWidth,g.window.innerHeight)}),p,e.DockviewDisposable.from(()=>{if(!this.isDisposed)if(a&&this.getPanel(n.id))this.movingLock(()=>ti({from:l,to:n})),n.api.isVisible||n.api.setVisible(!0),this.getPanel(l.id)&&this.doRemoveGroup(l,{skipPopoutAssociated:!0});else if(this.getPanel(l.id)){l.model.renderContainer=this.overlayRenderContainer,l.model.dropTargetContainer=this.rootDropTargetContainer,D=l;if(!this._popoutGroups.find(e=>e.popoutGroup===l))return;u?this.addFloatingGroup(l,{height:u.height,width:u.width,position:u}):(this.doRemoveGroup(l,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),l.model.location={type:"grid"},this.movingLock(()=>{this.doAddGroup(l,[0])})),this.doSetGroupAndPanelActive(l)}})),this._popoutGroups.push(y),this.updateWatermark(),!0}).catch(e=>(console.error("dockview: failed to create popout.",e),!1))}addFloatingGroup(e,t){var i,s,o,n,r,a;if(e instanceof ft&&"edge"===e.model.location.type)return;let l;if(e instanceof Dt)l=this.createGroup(),this._onDidAddGroup.fire(l),this.movingLock(()=>this.removePanel(e,{removeEmptyGroup:!0,skipDispose:!0,skipSetActiveGroup:!0})),this.movingLock(()=>l.model.openPanel(e,{skipSetGroupActive:!0}));else{l=e;const s=null===(i=this._popoutGroups.find(e=>e.popoutGroup===l))||void 0===i?void 0:i.referenceGroup,o=s?this.getPanel(s):void 0;"boolean"==typeof(null==t?void 0:t.skipRemoveGroup)&&t.skipRemoveGroup||(o?(this.movingLock(()=>ti({from:e,to:o})),this.doRemoveGroup(e,{skipPopoutReturn:!0,skipPopoutAssociated:!0}),this.doRemoveGroup(o,{skipDispose:!0}),l=o):this.doRemoveGroup(e,{skipDispose:!0,skipPopoutReturn:!0,skipPopoutAssociated:!1}))}const d=function(){if(null==t?void 0:t.position){const e={};return"left"in t.position?e.left=Math.max(t.position.left,0):"right"in t.position?e.right=Math.max(t.position.right,0):e.left=It,"top"in t.position?e.top=Math.max(t.position.top,0):"bottom"in t.position?e.bottom=Math.max(t.position.bottom,0):e.top=Tt,"number"==typeof t.width?e.width=Math.max(t.width,0):e.width=Et,"number"==typeof t.height?e.height=Math.max(t.height,0):e.height=Ot,e}return{left:"number"==typeof(null==t?void 0:t.x)?Math.max(t.x,0):It,top:"number"==typeof(null==t?void 0:t.y)?Math.max(t.y,0):Tt,width:"number"==typeof(null==t?void 0:t.width)?Math.max(t.width,0):Et,height:"number"==typeof(null==t?void 0:t.height)?Math.max(t.height,0):Ot}}(),p=new Pt(Object.assign(Object.assign({container:null!==(s=this._floatingOverlayHost)&&void 0!==s?s:this.gridview.element,content:l.element},d),{minimumInViewportWidth:"boundedWithinViewport"===this.options.floatingGroupBounds?void 0:null!==(n=null===(o=this.options.floatingGroupBounds)||void 0===o?void 0:o.minimumWidthWithinViewport)&&void 0!==n?n:zt,minimumInViewportHeight:"boundedWithinViewport"===this.options.floatingGroupBounds?void 0:null!==(a=null===(r=this.options.floatingGroupBounds)||void 0===r?void 0:r.minimumHeightWithinViewport)&&void 0!==a?a:zt})),u=l.element.querySelector(".dv-void-container");if(!u)throw new Error("dockview: failed to find drag handle");p.setupDrag(u,{inDragMode:"boolean"==typeof(null==t?void 0:t.inDragMode)&&t.inDragMode});const c=new At(l,p),m=new h(l.api.onDidActiveChange(e=>{e.isActive&&p.bringToFront()}),(()=>{let e=-1,t=-1;return f(l.element,i=>{const s=Math.round(i.contentRect.width),o=Math.round(i.contentRect.height);s===e&&o===t||(e=s,t=o,l.layout(s,o))})})());c.addDisposables(p.onDidChange(()=>{l.layout(l.width,l.height)}),p.onDidChangeEnd(()=>{this._bufferOnDidLayoutChange.fire()}),l.onDidChange(e=>{p.setBounds({height:null==e?void 0:e.height,width:null==e?void 0:e.width})}),{dispose:()=>{m.dispose(),M(this._floatingGroups,c),l.model.location={type:"grid"},this.updateWatermark()}}),this._floatingGroups.push(c),l.model.location={type:"floating"},(null==t?void 0:t.skipActiveGroup)||this.doSetGroupAndPanelActive(l),this.updateWatermark()}orthogonalize(t,i){switch(this.gridview.normalize(),t){case"top":case"bottom":this.gridview.orientation===e.Orientation.HORIZONTAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case"left":case"right":this.gridview.orientation===e.Orientation.VERTICAL&&this.gridview.insertOrthogonalSplitviewAtRoot()}switch(t){case"top":case"left":case"center":return this.createGroupAtLocation([0],void 0,i);case"bottom":case"right":return this.createGroupAtLocation([this.gridview.length],void 0,i);default:throw new Error(`dockview: unsupported position ${t}`)}}updateOptions(e){var t,i,s,o,n;if(super.updateOptions(e),"floatingGroupBounds"in e)for(const s of this._floatingGroups){switch(e.floatingGroupBounds){case"boundedWithinViewport":s.overlay.minimumInViewportHeight=void 0,s.overlay.minimumInViewportWidth=void 0;break;case void 0:s.overlay.minimumInViewportHeight=zt,s.overlay.minimumInViewportWidth=zt;break;default:s.overlay.minimumInViewportHeight=null===(t=e.floatingGroupBounds)||void 0===t?void 0:t.minimumHeightWithinViewport,s.overlay.minimumInViewportWidth=null===(i=e.floatingGroupBounds)||void 0===i?void 0:i.minimumWidthWithinViewport}s.overlay.setBounds()}this.updateDropTargetModel(e);const r=this.options.disableDnd;this._options=Object.assign(Object.assign({},this.options),e);if(r!==this.options.disableDnd&&this.updateDragAndDropState(),"theme"in e&&this.updateTheme(),"createRightHeaderActionComponent"in e||"createLeftHeaderActionComponent"in e||"createPrefixHeaderActionComponent"in e)for(const e of this.groups)e.model.updateHeaderActions();if("createWatermarkComponent"in e){this._watermark&&(this._watermark.element.parentElement.remove(),null===(o=(s=this._watermark).dispose)||void 0===o||o.call(s),this._watermark=null),this.updateWatermark();for(const e of this.groups)e.model.refreshWatermark()}if("tabGroupColors"in e||"tabGroupAccent"in e){this._tabGroupColorPalette.setEntries(null!==(n=this._options.tabGroupColors)&&void 0!==n?n:Fe),this._tabGroupColorPalette.enabled="off"!==this._options.tabGroupAccent;for(const e of this.groups)e.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 e of this._floatingGroups)e.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 s=i.model.onDidRemovePanel(()=>{i.model.isEmpty&&this.setEdgeGroupCollapsed(i,!0)});return this._edgeGroupDisposables.set(e,s),this._shellManager.addEdgeView(e,t,i),i.api}getEdgeGroup(e){var t;return null===(t=this._edgeGroups.get(e))||void 0===t?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 e of[...i.panels])this.removePanel(e,{removeEmptyGroup:!1,skipDispose:!1});null===(t=this._edgeGroupDisposables.get(e))||void 0===t||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,s]of this._edgeGroups)if(s===e){if(this._shellManager.isEdgeGroupCollapsed(i)===t)return;return this._shellManager.setEdgeGroupCollapsed(i,t),void s.api._onDidCollapsedChange.fire({isCollapsed:t})}}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;null===(e=this.activeGroup)||void 0===e||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])return void e.group.model.moveToNext({suppressRoll:!0});const i=ee(e.group.element),s=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupAndPanelActive(s)}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])return void e.group.model.moveToPrevious({suppressRoll:!0});const i=ee(e.group.element),s=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;s&&this.doSetGroupAndPanelActive(s)}toJSON(){var e;const t=this.gridview.serialize(),i=this.panels.reduce((e,t)=>(e[t.id]=t.toJSON(),e),{}),s=this._floatingGroups.map(e=>({data:e.group.toJSON(),position:e.overlay.toJSON()})),o=this._popoutGroups.map(e=>({data:e.popoutGroup.toJSON(),gridReferenceGroup:e.referenceGroup,position:e.window.dimensions(),url:"popout"===e.popoutGroup.api.location.type?e.popoutGroup.api.location.popoutUrl:void 0})),n={grid:t,panels:i,activeGroup:null===(e=this.activeGroup)||void 0===e?void 0:e.id};if(s.length>0&&(n.floatingGroups=s),o.length>0&&(n.popoutGroups=o),this._edgeGroups.size>0){const e=this._shellManager.toJSON();for(const[t,i]of this._edgeGroups){const s=e[t];s&&(s.group=i.toJSON())}n.edgeGroups=e}return n}fromJSON(e,t){var i,s,o;const n=new Map;let r;if(null==t?void 0:t.reuseExistingPanels){r=this.createGroup(),this._groups.delete(r.api.id);const t=Object.keys(e.panels);for(const e of this.panels)t.includes(e.api.id)&&n.set(e.api.id,e);this.movingLock(()=>{Array.from(n.values()).forEach(e=>{this.moveGroupOrPanel({from:{groupId:e.api.group.api.id,panelId:e.api.id},to:{group:r,position:"center"},keepEmptyGroups:!0})})})}if(this.clear(),"object"!=typeof e||null===e)throw new Error("dockview: serialized layout must be a non-null object");const{grid:a,panels:h,activeGroup:l}=e;if("branch"!==a.root.type||!Array.isArray(a.root.data))throw new Error("dockview: root must be of type branch");try{const t=this.width,d=this.height,p=e=>{const{id:t,locked:i,hideHeader:s,headerPosition:o,views:a,activeView:l}=e;if("string"!=typeof t)throw new Error("dockview: group id must be of type string");const d=this.createGroup({id:t,locked:!!i,hideHeader:!!s,headerPosition:o});this._onDidAddGroup.fire(d);const p=[];for(const e of a){const t=n.get(e);if(r&&t)this.movingLock(()=>{r.model.removePanel(t)}),p.push(t),t.updateFromStateModel(h[e]);else{const t=this._deserializer.fromJSON(h[e],d);p.push(t)}}for(let e=0;e<a.length;e++){const t=p[e],i="string"==typeof l&&l===t.id;n.has(t.api.id)?this.movingLock(()=>{d.model.openPanel(t,{skipSetActive:!i,skipSetGroupActive:!0})}):d.model.openPanel(t,{skipSetActive:!i,skipSetGroupActive:!0})}return e.tabGroups&&e.tabGroups.length>0&&d.model.restoreTabGroups(e.tabGroups),!d.activePanel&&d.panels.length>0&&d.model.openPanel(d.panels[d.panels.length-1],{skipSetGroupActive:!0}),d};if(this.gridview.deserialize(a,{fromJSON:e=>p(e.data)}),this._layoutFromShell(t,d),e.edgeGroups){for(const t of["top","bottom","left","right"]){const s=e.edgeGroups[t];if(s&&!this._edgeGroups.has(t)){const e=s.group,o=null!==(i=null==e?void 0:e.id)&&void 0!==i?i:`${t}-group`;this.addEdgeGroup(t,{id:o})}}for(const[t,i]of this._edgeGroups){const s=e.edgeGroups[t],o=null==s?void 0:s.group;if(o){const{views:e,activeView:t}=o,s=[];for(const t of e)if(h[t]){const e=this._deserializer.fromJSON(h[t],i);s.push(e)}for(let e=0;e<s.length;e++){const o=s[e],n=t===o.id;i.model.openPanel(o,{skipSetActive:!n,skipSetGroupActive:!0})}o.tabGroups&&o.tabGroups.length>0&&i.model.restoreTabGroups(o.tabGroups),!i.activePanel&&i.panels.length>0&&i.model.openPanel(i.panels[i.panels.length-1],{skipSetGroupActive:!0})}}this._shellManager.fromJSON(e.edgeGroups)}const u=null!==(s=e.floatingGroups)&&void 0!==s?s:[];for(const e of u){const{data:t,position:i}=e,s=p(t);this.addFloatingGroup(s,{position:i,width:i.width,height:i.height,skipRemoveGroup:!0,inDragMode:!1})}const c=null!==(o=e.popoutGroups)&&void 0!==o?o:[],m=[];c.forEach((e,t)=>{const{data:i,position:s,gridReferenceGroup:o,url:n}=e,r=p(i),a=new Promise(e=>{const i=()=>{this._popoutRestorationCleanups.delete(i),clearTimeout(a),e()},a=setTimeout(()=>{this._popoutRestorationCleanups.delete(i),this.isDisposed||this.addPopoutGroup(r,{position:null!=s?s:void 0,overridePopoutGroup:o?r:void 0,referenceGroup:o?this.getPanel(o):void 0,popoutUrl:n}),e()},100*t);this._popoutRestorationCleanups.add(i)});m.push(a)}),this._popoutRestorationPromise=Promise.all(m).then(()=>{});for(const e of this._floatingGroups)e.overlay.setBounds();if("string"==typeof l){const e=this.getPanel(l);e&&this.doSetGroupAndPanelActive(e)}}catch(e){console.error("dockview: failed to deserialize layout. Reverting changes",e);for(const e of this.groups)for(const t of e.panels)this.removePanel(t,{removeEmptyGroup:!1,skipDispose:!1});for(const e of this.groups)e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e);for(const e of[...this._floatingGroups])e.dispose();throw this.clear(),e}this.updateWatermark(),this.debouncedUpdateAllPositions(),this._onDidLayoutFromJSON.fire()}clear(){const e=Array.from(this._groups.values()).map(e=>e.value),t=!!this.activeGroup;for(const t of e){if([...this._edgeGroups.values()].includes(t)){const e=[...t.panels];for(const t of e)this.removePanel(t,{removeEmptyGroup:!1});continue}this.removeGroup(t,{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(t){var i,s;if(this.panels.find(e=>e.id===t.id))throw new Error(`dockview: panel with id ${t.id} already exists`);let o;if(t.position&&t.floating)throw new Error("dockview: you can only provide one of: position, floating as arguments to .addPanel(...)");const n={width:t.initialWidth,height:t.initialHeight};let r,a;if(t.position)if(rt(t.position)){const e="string"==typeof t.position.referencePanel?this.getGroupPanel(t.position.referencePanel):t.position.referencePanel;if(r=t.position.index,!e)throw new Error(`dockview: referencePanel '${t.position.referencePanel}' does not exist`);o=this.findGroup(e)}else{if(!at(t.position)){const e=this.orthogonalize(we(t.position.direction)),i=this.createPanel(t,e);return e.model.openPanel(i,{skipSetActive:t.inactive,skipSetGroupActive:t.inactive,index:r}),t.inactive||this.doSetGroupAndPanelActive(e),e.api.setSize({height:null==n?void 0:n.height,width:null==n?void 0:n.width}),i}if(o="string"==typeof t.position.referenceGroup?null===(i=this._groups.get(t.position.referenceGroup))||void 0===i?void 0:i.value:t.position.referenceGroup,r=t.position.index,!o)throw new Error(`dockview: referenceGroup '${t.position.referenceGroup}' does not exist`)}else o=this.activeGroup;if(o){const i=pe((null===(s=t.position)||void 0===s?void 0:s.direction)||"within");if(t.floating){const e=this.createGroup();this._onDidAddGroup.fire(e);const i="object"==typeof t.floating&&null!==t.floating?t.floating:{};this.addFloatingGroup(e,Object.assign(Object.assign({},i),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),a=this.createPanel(t,e),e.model.openPanel(a,{skipSetActive:t.inactive,skipSetGroupActive:t.inactive,index:r})}else if("floating"===o.api.location.type||"edge"===o.api.location.type||"center"===i)a=this.createPanel(t,o),o.model.openPanel(a,{skipSetActive:t.inactive,skipSetGroupActive:t.inactive,index:r}),o.api.setSize({width:null==n?void 0:n.width,height:null==n?void 0:n.height}),t.inactive||this.doSetGroupAndPanelActive(o);else{const s=ee(o.element),h=te(this.gridview.orientation,s,i),l=this.createGroupAtLocation(h,this.orientationAtLocation(h)===e.Orientation.VERTICAL?null==n?void 0:n.height:null==n?void 0:n.width);a=this.createPanel(t,l),l.model.openPanel(a,{skipSetActive:t.inactive,skipSetGroupActive:t.inactive,index:r}),t.inactive||this.doSetGroupAndPanelActive(l)}}else if(t.floating){const e=this.createGroup();this._onDidAddGroup.fire(e);const i="object"==typeof t.floating&&null!==t.floating?t.floating:{};this.addFloatingGroup(e,Object.assign(Object.assign({},i),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),a=this.createPanel(t,e),e.model.openPanel(a,{skipSetActive:t.inactive,skipSetGroupActive:t.inactive,index:r})}else{const i=this.createGroupAtLocation([0],this.gridview.orientation===e.Orientation.VERTICAL?null==n?void 0:n.height:null==n?void 0:n.width);a=this.createPanel(t,i),i.model.openPanel(a,{skipSetActive:t.inactive,skipSetGroupActive:t.inactive,index:r}),t.inactive||this.doSetGroupAndPanelActive(i)}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()),0===i.size&&t.removeEmptyGroup&&this.removeGroup(i,{skipActive:t.skipSetActiveGroup})}createWatermarkComponent(){return this.options.createWatermarkComponent?this.options.createWatermarkComponent():new xt}updateWatermark(){var e,t,i;if(0===this.groups.filter(e=>"grid"===e.api.location.type&&e.api.isVisible).length){if(!this._watermark){this._watermark=this.createWatermarkComponent(),this._watermark.init({containerApi:new ge(this)});const e=document.createElement("div");e.className="dv-watermark-container",i="watermark-component",e.setAttribute("data-testid",i),e.appendChild(this._watermark.element),this.gridview.element.appendChild(e)}}else this._watermark&&(this._watermark.element.parentElement.remove(),null===(t=(e=this._watermark).dispose)||void 0===t||t.call(e),this._watermark=null)}addGroup(t){var i;if(t){let s;if(ht(t)){const e="string"==typeof t.referencePanel?this.panels.find(e=>e.id===t.referencePanel):t.referencePanel;if(!e)throw new Error(`dockview: reference panel ${t.referencePanel} does not exist`);if(s=this.findGroup(e),!s)throw new Error(`dockview: reference group for reference panel ${t.referencePanel} does not exist`)}else{if(!lt(t)){const e=this.orthogonalize(we(t.direction),t);return t.skipSetActive||this.doSetGroupAndPanelActive(e),e}if(s="string"==typeof t.referenceGroup?null===(i=this._groups.get(t.referenceGroup))||void 0===i?void 0:i.value:t.referenceGroup,!s)throw new Error(`dockview: reference group ${t.referenceGroup} does not exist`)}const o=pe(t.direction||"within"),n=ee(s.element),r=te(this.gridview.orientation,n,o),a=this.createGroup(t),h=this.getLocationOrientation(r)===e.Orientation.VERTICAL?t.initialHeight:t.initialWidth;return this.doAddGroup(a,r,h),t.skipSetActive||this.doSetGroupAndPanelActive(a),a}{const e=this.createGroup(t);return this.doAddGroup(e),this.doSetGroupAndPanelActive(e),e}}getLocationOrientation(t){return t.length%2==0&&this.gridview.orientation===e.Orientation.HORIZONTAL?e.Orientation.HORIZONTAL:e.Orientation.VERTICAL}removeGroup(e,t){this.doRemoveGroup(e,t)}doRemoveGroup(e,t){var i;if([...this._edgeGroups.values()].includes(e))return e;const s=[...e.panels];if(!(null==t?void 0:t.skipDispose))for(const e of s)this.removePanel(e,{removeEmptyGroup:!1,skipDispose:null!==(i=null==t?void 0:t.skipDispose)&&void 0!==i&&i});const o=this.activePanel;if("floating"===e.api.location.type){const i=this._floatingGroups.find(t=>t.group===e);if(i){if((null==t?void 0:t.skipDispose)||(i.group.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)),M(this._floatingGroups,i),i.dispose(),!(null==t?void 0:t.skipActive)&&this._activeGroup===e){const e=Array.from(this._groups.values());this.doSetGroupAndPanelActive(e.length>0?e[0].value:void 0)}return i.group}throw new Error("dockview: failed to find floating group")}if("popout"===e.api.location.type){const i=this._popoutGroups.find(t=>t.popoutGroup===e);if(i){if(!(null==t?void 0:t.skipDispose)){if(!(null==t?void 0:t.skipPopoutAssociated)){const e=i.referenceGroup?this.getPanel(i.referenceGroup):void 0;e&&0===e.panels.length&&this.removeGroup(e)}i.popoutGroup.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}M(this._popoutGroups,i);const s=i.disposable.dispose();if(!(null==t?void 0:t.skipPopoutReturn)&&s&&(this.doAddGroup(s,[0]),this.doSetGroupAndPanelActive(s)),!(null==t?void 0:t.skipActive)&&this._activeGroup===e){const e=Array.from(this._groups.values());this.doSetGroupAndPanelActive(e.length>0?e[0].value:void 0)}return this.updateWatermark(),i.popoutGroup}throw new Error("dockview: failed to find popout group")}const n=super.doRemoveGroup(e,t);return(null==t?void 0:t.skipActive)||this.activePanel!==o&&this._onDidActivePanelChange.fire(this.activePanel),n}debouncedUpdateAllPositions(){void 0!==this._updatePositionsFrameId&&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,s=e.from.groupId,o=e.from.panelId,n=e.to.position,r=e.to.index,a=s?null===(t=this._groups.get(s))||void 0===t?void 0:t.value:void 0;if(!a)throw new Error(`dockview: Failed to find group id ${s}`);if(void 0!==o)if(n&&"center"!==n){const e=ee(i.element),t=te(this.gridview.orientation,e,n);if(a.size<2){const[e,s]=E(t);if("grid"===a.api.location.type){const t=ee(a.element),[i,n]=E(t);if(O(i,e))return this.gridview.moveView(i,n,s),void this._onDidMovePanel.fire({panel:this.getGroupPanel(o),from:a})}if("popout"===a.api.location.type){const e=this._popoutGroups.find(e=>e.popoutGroup===a),t=this.movingLock(()=>e.popoutGroup.model.removePanel(e.popoutGroup.panels[0],{skipSetActive:!0,skipSetActiveGroup:!0}));this.doRemoveGroup(a,{skipActive:!0});const s=te(this.gridview.orientation,ee(i.element),n),r=this.createGroupAtLocation(s);return this.movingLock(()=>r.model.openPanel(t,{skipSetActive:!0})),this.doSetGroupAndPanelActive(r),void this._onDidMovePanel.fire({panel:this.getGroupPanel(o),from:a})}if("edge"===a.api.location.type){const e=this.movingLock(()=>a.model.removePanel(o,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!e)throw new Error(`dockview: No panel with id ${o}`);const i=this.createGroupAtLocation(t);return this.movingLock(()=>i.model.openPanel(e,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(i),void this._onDidMovePanel.fire({panel:e,from:a})}const r=this.movingLock(()=>this.doRemoveGroup(a,{skipActive:!0,skipDispose:!0})),h=ee(i.element),l=te(this.gridview.orientation,h,n);this.movingLock(()=>this.doAddGroup(r,l)),this.doSetGroupAndPanelActive(r),this._onDidMovePanel.fire({panel:this.getGroupPanel(o),from:a})}else{const t=this.movingLock(()=>a.model.removePanel(o,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!t)throw new Error(`dockview: No panel with id ${o}`);const i=te(this.gridview.orientation,e,n),s=this.createGroupAtLocation(i);this.movingLock(()=>s.model.openPanel(t,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(s),this._onDidMovePanel.fire({panel:t,from:a})}}else{const t=this.movingLock(()=>a.model.removePanel(o,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!t)throw new Error(`dockview: No panel with id ${o}`);e.keepEmptyGroups||0!==a.model.size||this.doRemoveGroup(a,{skipActive:!0});const s=0===i.model.size;this.movingLock(()=>{var o;return i.model.openPanel(t,{index:r,skipSetActive:null!==(o=e.skipSetActive)&&void 0!==o&&o&&!s,skipSetGroupActive:!0})}),e.skipSetActive||this.doSetGroupAndPanelActive(i),this._onDidMovePanel.fire({panel:t,from:a})}else e.from.tabGroupId?this.moveTabGroupToGroup({sourceGroup:a,tabGroupId:e.from.tabGroupId,destinationGroup:i,destinationTarget:n,destinationIndex:r,skipSetActive:e.skipSetActive,keepEmptyGroups:e.keepEmptyGroups}):this.moveGroup({from:{group:a},to:{group:i,position:n},skipSetActive:e.skipSetActive})}moveTabGroupToGroup(e){const{sourceGroup:t,tabGroupId:i,destinationGroup:s,destinationTarget:o,destinationIndex:n}=e,r=t.model.getTabGroups().find(e=>e.id===i);if(!r||0===r.panelIds.length)return;const a=r.label,h=r.color,l=r.collapsed,d=r.componentParams,p=[...r.panelIds],u=o&&"center"!==o?ee(s.element):void 0,c=this.movingLock(()=>p.map(e=>t.model.removePanel(e,{skipSetActive:!1,skipSetActiveGroup:!0})).filter(e=>void 0!==e));if(0===c.length)return;let m;if(o&&"center"!==o&&u){const e=te(this.gridview.orientation,u,o);m=this.createGroupAtLocation(e)}else m=s;e.keepEmptyGroups||0!==t.model.size||t===m||this.doRemoveGroup(t,{skipActive:!0}),(i=>{this.movingLock(()=>{for(const e of c)i.model.openPanel(e,{index:n,skipSetActive:!0,skipSetGroupActive:!0})});const s=i.model.createTabGroup({label:a,color:h,collapsed:l,componentParams:d});for(const e of c)i.model.addPanelToTabGroup(s.id,e.id);e.skipSetActive||this.doSetGroupAndPanelActive(i);for(const e of c)this._onDidMovePanel.fire({panel:e,from:t})})(m)}moveGroup(t){const i=t.from.group,s=t.to.group,o=t.to.position;let n=i;if("center"===o){const e=i.activePanel,o=i.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),n=this.movingLock(()=>[...i.panels].map(e=>i.model.removePanel(e.id,{skipSetActive:!0})));0===(null==i?void 0:i.model.size)&&this.doRemoveGroup(i,{skipActive:!0}),this.movingLock(()=>{for(const t of n)s.model.openPanel(t,{skipSetActive:t!==e,skipSetGroupActive:!0})});for(const e of o){const t=s.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(const i of e.panelIds)s.model.addPanelToTabGroup(t.id,i)}!0!==t.skipSetActive?this.doSetGroupAndPanelActive(s):this.activePanel||this.doSetGroupAndPanelActive(s)}else{if("edge"===i.api.location.type){const e=i.activePanel,t=i.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),s=this.movingLock(()=>[...i.panels].map(e=>i.model.removePanel(e.id,{skipSetActive:!0})));n=this.createGroup(),this.movingLock(()=>{for(const t of s)n.model.openPanel(t,{skipSetActive:t!==e,skipSetGroupActive:!0})});for(const e of t){const t=n.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(const i of e.panelIds)n.model.addPanelToTabGroup(t.id,i)}}else switch(i.api.location.type){case"grid":this.gridview.removeView(ee(i.element));break;case"floating":{const e=this._floatingGroups.find(e=>e.group===i);if(!e)throw new Error("dockview: failed to find floating group");e.dispose();break}case"popout":{const e=this._popoutGroups.find(e=>e.popoutGroup===i);if(!e)throw new Error("dockview: failed to find popout group");const t=this._popoutGroups.indexOf(e);if(t>=0&&this._popoutGroups.splice(t,1),e.referenceGroup){const t=this.getPanel(e.referenceGroup);t&&!t.api.isVisible&&this.doRemoveGroup(t,{skipActive:!0})}e.window.dispose(),"grid"===s.api.location.type?(i.model.renderContainer=this.overlayRenderContainer,i.model.dropTargetContainer=this.rootDropTargetContainer,i.model.location={type:"grid"}):"floating"===s.api.location.type&&(i.model.renderContainer=this.overlayRenderContainer,i.model.dropTargetContainer=this.rootDropTargetContainer,i.model.location={type:"floating"});break}}if("grid"===s.api.location.type){const t=ee(s.element),r=te(this.gridview.orientation,t,o);let a;switch(this.gridview.orientation){case e.Orientation.VERTICAL:a=t.length%2==0?i.api.width:i.api.height;break;case e.Orientation.HORIZONTAL:a=t.length%2==0?i.api.height:i.api.width}this.gridview.addView(n,a,r)}else if("floating"===s.api.location.type){const e=this._floatingGroups.find(e=>e.group===s);if(e){const t=e.overlay.toJSON();let i,s;i="left"in t?t.left+50:"right"in t?Math.max(0,t.right-t.width-50):50,s="top"in t?t.top+50:"bottom"in t?Math.max(0,t.bottom-t.height-50):50,this.addFloatingGroup(n,{height:t.height,width:t.width,position:{left:i,top:s}})}}}if(n.panels.forEach(e=>{this._onDidMovePanel.fire({panel:e,from:i})}),this.debouncedUpdateAllPositions(),!1===t.skipSetActive){const e=null!=s?s:i;this.doSetGroupAndPanelActive(e)}else n!==i&&!0!==t.skipSetActive&&this.doSetGroupAndPanelActive(n)}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(t){t||(t={});let i=null==t?void 0:t.id;if(i&&this._groups.has(t.id)&&(console.warn(`dockview: Duplicate group id ${null==t?void 0:t.id}. reassigning group id to avoid errors`),i=void 0),!i)for(i=this.nextGroupId.next();this._groups.has(i);)i=this.nextGroupId.next();const s=new ft(this,i,t);if(s.init({params:{},accessor:this}),!this._groups.has(s.id)){const t=new h(s.model.onTabDragStart(e=>{this._onWillDragPanel.fire(e)}),s.model.onGroupDragStart(e=>{this._onWillDragGroup.fire(e)}),s.model.onMove(e=>{const{groupId:t,itemId:i,target:o,index:n,tabGroupId:r}=e;this.moveGroupOrPanel({from:{groupId:t,panelId:i,tabGroupId:r},to:{group:s,position:o,index:n}})}),s.model.onDidDrop(e=>{this._onDidDrop.fire(e)}),s.model.onWillDrop(e=>{this._onWillDrop.fire(e)}),s.model.onWillShowOverlay(e=>{this.options.disableDnd?e.preventDefault():this._onWillShowOverlay.fire(e)}),s.model.onUnhandledDragOverEvent(e=>{this._onUnhandledDragOverEvent.fire(e)}),s.model.onDidAddPanel(e=>{this._moving||this._onDidAddPanel.fire(e.panel)}),s.model.onDidRemovePanel(e=>{this._moving||this._onDidRemovePanel.fire(e.panel)}),s.model.onDidActivePanelChange(e=>{this._moving||e.panel===this.activePanel&&this._onDidActivePanelChange.value!==e.panel&&this._onDidActivePanelChange.fire(e.panel)}),s.model.onDidCreateTabGroup(e=>{this._onDidCreateTabGroup.fire(e)}),s.model.onDidDestroyTabGroup(e=>{this._onDidDestroyTabGroup.fire(e)}),s.model.onDidAddPanelToTabGroup(e=>{this._onDidAddPanelToTabGroup.fire(e)}),s.model.onDidRemovePanelFromTabGroup(e=>{this._onDidRemovePanelFromTabGroup.fire(e)}),s.model.onDidTabGroupChange(e=>{this._onDidTabGroupChange.fire(e)}),s.model.onDidTabGroupCollapsedChange(e=>{this._onDidTabGroupCollapsedChange.fire(e)}),e.DockviewEvent.any(s.model.onDidPanelTitleChange,s.model.onDidPanelParametersChange)(()=>{this._bufferOnDidLayoutChange.fire()}));this._groups.set(s.id,{value:s,disposable:t})}return s.initialize(),s}createPanel(e,t){var i,s,o;const n=e.component,r=null!==(i=e.tabComponent)&&void 0!==i?i:this.options.defaultTabComponent,a=new yt(this,e.id,n,r),h=new Dt(e.id,n,r,this,this._api,t,a,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return h.init({title:null!==(s=e.title)&&void 0!==s?s:e.id,params:null!==(o=null==e?void 0:e.params)&&void 0!==o?o:{}}),h}createGroupAtLocation(e,t,i){const s=this.createGroup(i);return this.doAddGroup(s,e,t),s}findGroup(e){var t;return null===(t=Array.from(this._groups.values()).find(t=>t.value.model.containsPanel(e)))||void 0===t?void 0:t.value}orientationAtLocation(e){const t=this.gridview.orientation;return e.length%2==1?t:oe(t)}updateDropTargetModel(e){"dndEdges"in e&&(this._rootDropTarget.disabled="boolean"==typeof e.dndEdges&&!1===e.dndEdges,"object"==typeof e.dndEdges&&null!==e.dndEdges?this._rootDropTarget.setOverlayModel(e.dndEdges):this._rootDropTarget.setOverlayModel(ei)),"rootOverlayModel"in e&&this.updateDropTargetModel({dndEdges:e.dndEdges})}updateTheme(){var e,t,i,s,o,n,r,a,h;const l=null!==(e=this._options.theme)&&void 0!==e?e:bt;if(null===(t=this._shellThemeClassnames)||void 0===t||t.setClassNames(l.className),this.gridview.margin=null!==(i=l.gap)&&void 0!==i?i:0,null===(s=this._shellManager)||void 0===s||s.updateTheme(null!==(o=l.gap)&&void 0!==o?o:0,null!==(n=l.edgeGroupCollapsedSize)&&void 0!==n?n:35),void 0!==l.dndOverlayBorder?(this.element.style.setProperty("--dv-drag-over-border",l.dndOverlayBorder),null===(r=this._shellManager)||void 0===r||r.element.style.setProperty("--dv-drag-over-border",l.dndOverlayBorder)):(this.element.style.removeProperty("--dv-drag-over-border"),null===(a=this._shellManager)||void 0===a||a.element.style.removeProperty("--dv-drag-over-border")),"absolute"===l.dndOverlayMounting)this.rootDropTargetContainer.disabled=!1;else this.rootDropTargetContainer.disabled=!0;const d="none"===(null!==(h=l.tabGroupIndicator)&&void 0!==h?h:"wrap");D(this.element,"dv-tab-group-indicator-none",d),this._shellManager&&D(this._shellManager.element,"dv-tab-group-indicator-none",d);for(const e of this.groups)e.model.updateTabGroups()}}class si extends ue{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:null===(i=t.proportionalLayout)||void 0===i||i,orientation:t.orientation,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:t.disableAutoResizing,className:t.className}),this._onDidLayoutfromJSON=new m,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidRemoveGroup=new m,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new m,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new m,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._options=t,this.addDisposables(this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this.onDidAdd(e=>{this._onDidAddGroup.fire(e)}),this.onDidRemove(e=>{this._onDidRemoveGroup.fire(e)}),this.onDidActiveChange(e=>{this._onDidActiveGroupChange.fire(e)}))}updateOptions(e){super.updateOptions(e);const t="string"==typeof e.orientation&&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:null===(e=this.activeGroup)||void 0===e?void 0:e.id}}setVisible(e,t){this.gridview.setViewVisible(ee(e.element),t)}setActive(e){this._groups.forEach((t,i)=>{t.value.setActive(e===t.value)})}focus(){var e;null===(e=this.activeGroup)||void 0===e||e.focus()}fromJSON(e){this.clear();const{grid:t,activePanel:i}=e;try{const e=[],s=this.width,o=this.height;if(this.gridview.deserialize(t,{fromJSON:t=>{const{data:i}=t,s=this.options.createComponent({id:i.id,name:i.component});return e.push(()=>s.init({params:i.params,minimumWidth:i.minimumWidth,maximumWidth:i.maximumWidth,minimumHeight:i.minimumHeight,maximumHeight:i.maximumHeight,priority:i.priority,snap:!!i.snap,accessor:this,isVisible:t.visible})),this._onDidAddGroup.fire(s),this.registerPanel(s),s}}),this.layout(s,o,!0),e.forEach(e=>e()),"string"==typeof i){const e=this.getPanel(i);e&&this.doSetGroupActive(e)}}catch(e){for(const e of this.groups)e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e);throw this.clear(),e}this._onDidLayoutfromJSON.fire()}clear(){const e=this.activeGroup,t=Array.from(this._groups.values());for(const e of t)e.disposable.dispose(),this.doRemoveGroup(e.value,{skipActive:!0});e&&this.doSetGroupActive(void 0),this.gridview.clear()}movePanel(e,t){var i;let s;const o=this.gridview.remove(e),n=null===(i=this._groups.get(t.reference))||void 0===i?void 0:i.value;if(!n)throw new Error(`reference group ${t.reference} does not exist`);const r=pe(t.direction);if("center"===r)throw new Error(`${r} not supported as an option`);{const e=ee(n.element);s=te(this.gridview.orientation,e,r)}this.doAddGroup(o,s,t.size)}addPanel(e){var t,i,s,o;let n=null!==(t=e.location)&&void 0!==t?t:[0];if(null===(i=e.position)||void 0===i?void 0:i.referencePanel){const t=null===(s=this._groups.get(e.position.referencePanel))||void 0===s?void 0:s.value;if(!t)throw new Error(`reference group ${e.position.referencePanel} does not exist`);const i=pe(e.position.direction);if("center"===i)throw new Error(`${i} not supported as an option`);{const e=ee(t.element);n=te(this.gridview.orientation,e,i)}}const r=this.options.createComponent({id:e.id,name:e.component});return r.init({params:null!==(o=e.params)&&void 0!==o?o:{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.doAddGroup(r,n,e.size),this.registerPanel(r),this.doSetGroupActive(r),r}registerPanel(e){const t=new h(e.api.onDidFocusChange(t=>{t.isFocused&&this._groups.forEach(t=>{const i=t.value;i!==e?i.setActive(!1):i.setActive(!0)})}));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,i){const s=this.getPanel(t);if(!s)throw new Error("invalid operation");const o=ee(e.element),n=te(this.gridview.orientation,o,i),[r,a]=E(n),h=ee(s.element),[l,d]=E(h);if(O(l,r))return void this.gridview.moveView(l,d,a);const p=this.doRemoveGroup(s,{skipActive:!0,skipDispose:!0}),u=ee(e.element),c=te(this.gridview.orientation,u,i);this.doAddGroup(p,c)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}}class oi extends le{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 h(this._splitview.onDidSashEnd(()=>{this._onDidLayoutChange.fire(void 0)}),this._splitview.onDidAddView(e=>this._onDidAddView.fire(e)),this._splitview.onDidRemoveView(e=>this._onDidRemoveView.fire(e)))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation===e.Orientation.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===e.Orientation.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._splitviewChangeDisposable=new l,this._panels=new Map,this._onDidLayoutfromJSON=new m,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new m,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new m,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new m,this.onDidLayoutChange=this._onDidLayoutChange.event,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new z(this.element),this._classNames.setClassNames(null!==(i=t.className)&&void 0!==i?i:""),e.appendChild(this.element),this._options=t,this.splitview=new U(this.element,t),this.addDisposables(this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange)}updateOptions(e){var t,i;"className"in e&&this._classNames.setClassNames(null!==(t=e.className)&&void 0!==t?t:""),"disableResizing"in e&&(this.disableResizing=null!==(i=e.disableAutoResizing)&&void 0!==i&&i),"string"==typeof e.orientation&&(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;null===(e=this._activePanel)||void 0===e||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(t=>t!==e).forEach(e=>{e.api._onDidActiveChange.fire({isActive:!1}),t||e.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 s=this.panels.findIndex(t=>t===e);this.splitview.removeView(s,t).dispose();const o=this.panels;o.length>0&&this.setActive(o[o.length-1])}getPanel(e){return this.panels.find(t=>t.id===e)}addPanel(t){var i;if(this._panels.has(t.id))throw new Error(`panel ${t.id} already exists`);const s=this.options.createComponent({id:t.id,name:t.component});s.orientation=this.splitview.orientation,s.init({params:null!==(i=t.params)&&void 0!==i?i:{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:t.snap,priority:t.priority,accessor:this});const o="number"==typeof t.size?t.size:e.Sizing.Distribute,n="number"==typeof t.index?t.index:void 0;return this.splitview.addView(s,o,n),this.doAddView(s),this.setActive(s),s}layout(t,i){const[s,o]=this.splitview.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.splitview.layout(s,o)}doAddView(e){const t=e.api.onDidFocusChange(t=>{t.isFocused&&this.setActive(e,!0)});this._panels.set(e.id,t)}toJSON(){var e;return{views:this.splitview.getViews().map((e,t)=>({size:this.splitview.getViewSize(t),data:e.toJSON(),snap:!!e.snap,priority:e.priority})),activeView:null===(e=this._activePanel)||void 0===e?void 0:e.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){this.clear();const{views:t,orientation:i,size:s,activeView:o}=e,n=[],r=this.width,a=this.height;if(this.splitview=new U(this.element,{orientation:i,proportionalLayout:this.options.proportionalLayout,descriptor:{size:s,views:t.map(e=>{const t=e.data;if(this._panels.has(t.id))throw new Error(`panel ${t.id} already exists`);const s=this.options.createComponent({id:t.id,name:t.component});return n.push(()=>{var i;s.init({params:null!==(i=t.params)&&void 0!==i?i:{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:e.snap,priority:e.priority,accessor:this})}),s.orientation=i,this.doAddView(s),setTimeout(()=>{this._onDidAddView.fire(s)},0),{size:e.size,view:s}})}}),this.layout(r,a),n.forEach(e=>e()),"string"==typeof o){const e=this.getPanel(o);e&&this.setActive(e)}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,e.Sizing.Distribute,!0).dispose()}}dispose(){for(const e of this._panels.values())e.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 ni extends h{get element(){return this._element}constructor(){super(),this._expandedIcon=tt({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"}),this._collapsedIcon=it(),this.disposable=new l,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(v(this._element,"click",()=>{var e;null===(e=this.apiRef.api)||void 0===e||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=!!(null===(e=this.apiRef.api)||void 0===e?void 0:e.isExpanded);D(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 ri=N(),ai=Number.MAX_SAFE_INTEGER;class hi extends Oe{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 li extends le{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new h(this._paneview.onDidChange(()=>{this._onDidLayoutChange.fire(void 0)}),this._paneview.onDidAddView(e=>this._onDidAddView.fire(e)),this._paneview.onDidRemoveView(e=>this._onDidRemoveView.fire(e)))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation===e.Orientation.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===e.Orientation.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(t,i){var s;super(document.createElement("div"),i.disableAutoResizing),this._id=ri.next(),this._disposable=new l,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new m,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new m,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new m,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new m,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new m,this.onDidRemoveView=this._onDidRemoveView.event,this._onUnhandledDragOverEvent=new m,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 z(this.element),this._classNames.setClassNames(null!==(s=i.className)&&void 0!==s?s:""),t.appendChild(this.element),this._options=i,this.paneview=new j(this.element,{orientation:e.Orientation.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(null!==(t=e.className)&&void 0!==t?t:""),"disableResizing"in e&&(this.disableResizing=null!==(i=e.disableAutoResizing)&&void 0!==i&&i),this._options=Object.assign(Object.assign({},this.options),e)}addPanel(t){var i,s;const o=this.options.createComponent({id:t.id,name:t.component});let n;t.headerComponent&&this.options.createHeaderComponent&&(n=this.options.createHeaderComponent({id:t.id,name:t.headerComponent})),n||(n=new ni);const r=new hi({id:t.id,component:t.component,headerComponent:t.headerComponent,header:n,body:o,orientation:e.Orientation.VERTICAL,isExpanded:!!t.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:null!==(i=t.headerSize)&&void 0!==i?i:22,minimumBodySize:0,maximumBodySize:ai});this.doAddPanel(r);const a="number"==typeof t.size?t.size:e.Sizing.Distribute,h="number"==typeof t.index?t.index:void 0;return r.init({params:null!==(s=t.params)&&void 0!==s?s:{},minimumBodySize:t.minimumBodySize,maximumBodySize:t.maximumBodySize,isExpanded:t.isExpanded,title:t.title,containerApi:new me(this),accessor:this}),this.paneview.addPane(r,a,h),r.orientation=this.paneview.orientation,r}removePanel(e){const t=this.panels.findIndex(t=>t===e);this.paneview.removePane(t),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find(t=>t.id===e)}layout(t,i){const[s,o]=this.paneview.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.paneview.layout(s,o)}toJSON(){const e=e=>e===Number.MAX_SAFE_INTEGER||e===Number.POSITIVE_INFINITY?void 0:e;return{views:this.paneview.getPanes().map((t,i)=>{return{size:this.paneview.getViewSize(i),data:t.toJSON(),minimumSize:(s=t.minimumBodySize,s<=0?void 0:s),maximumSize:e(t.maximumBodySize),headerSize:t.headerSize,expanded:t.isExpanded()};var s}),size:this.paneview.size}}fromJSON(t){this.clear();const{views:i,size:s}=t,o=[],n=this.width,r=this.height;this.paneview=new j(this.element,{orientation:e.Orientation.VERTICAL,descriptor:{size:s,views:i.map(t=>{var i,s,n;const r=t.data,a=this.options.createComponent({id:r.id,name:r.component});let h;r.headerComponent&&this.options.createHeaderComponent&&(h=this.options.createHeaderComponent({id:r.id,name:r.headerComponent})),h||(h=new ni);const l=new hi({id:r.id,component:r.component,headerComponent:r.headerComponent,header:h,body:a,orientation:e.Orientation.VERTICAL,isExpanded:!!t.expanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:null!==(i=t.headerSize)&&void 0!==i?i:22,minimumBodySize:null!==(s=t.minimumSize)&&void 0!==s?s:0,maximumBodySize:null!==(n=t.maximumSize)&&void 0!==n?n:ai});return this.doAddPanel(l),o.push(()=>{var e;l.init({params:null!==(e=r.params)&&void 0!==e?e:{},minimumBodySize:t.minimumSize,maximumBodySize:t.maximumSize,title:r.title,isExpanded:!!t.expanded,containerApi:new me(this),accessor:this}),l.orientation=this.paneview.orientation}),setTimeout(()=>{this._onDidAddView.fire(l)},0),{size:t.size,view:l}})}}),this.layout(n,r),o.forEach(e=>e()),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 h(e.onDidDrop(e=>{this._onDidDrop.fire(e)}),e.onUnhandledDragOverEvent(e=>{this._onUnhandledDragOverEvent.fire(e)}));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()}}e.BaseGrid=ue,e.ContentContainer=ke,e.DEFAULT_TAB_GROUP_COLORS=Fe,e.DefaultDockviewDeserialzier=St,e.DefaultTab=Ct,e.DockviewApi=ge,e.DockviewComponent=ii,e.DockviewCompositeDisposable=h,e.DockviewDidDropEvent=pt,e.DockviewEmitter=m,e.DockviewGroupPanel=ft,e.DockviewGroupPanelModel=ct,e.DockviewMutableDisposable=l,e.DockviewPanel=Dt,e.DockviewUnhandledDragOverEvent=ot,e.DockviewWillDropEvent=ut,e.DockviewWillShowOverlayLocationEvent=Ne,e.DraggablePaneviewPanel=Oe,e.Gridview=ae,e.GridviewApi=ve,e.GridviewComponent=si,e.GridviewPanel=vt,e.PROPERTY_KEYS_DOCKVIEW=nt,e.PROPERTY_KEYS_GRIDVIEW=he,e.PROPERTY_KEYS_PANEVIEW=xe,e.PROPERTY_KEYS_SPLITVIEW=J,e.PaneFramework=hi,e.PaneTransfer=s,e.PanelTransfer=i,e.Paneview=j,e.PaneviewApi=me,e.PaneviewComponent=li,e.PaneviewPanel=Ee,e.PaneviewUnhandledDragOverEvent=Ge,e.Splitview=U,e.SplitviewApi=ce,e.SplitviewComponent=oi,e.SplitviewPanel=class extends Te{get priority(){return this._priority}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){const e="function"==typeof this._minimumSize?this._minimumSize():this._minimumSize;return e!==this._evaluatedMinimumSize&&(this._evaluatedMinimumSize=e,this.updateConstraints()),e}get maximumSize(){const e="function"==typeof this._maximumSize?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 ze(e,t)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=Number.POSITIVE_INFINITY,this._minimumSize=0,this._maximumSize=Number.POSITIVE_INFINITY,this._snap=!1,this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this.api.initialize(this),this.addDisposables(this._onDidChange,this.api.onWillVisibilityChange(e=>{const{isVisible:t}=e,{accessor:i}=this._params;i.setVisible(this,t)}),this.api.onActiveChange(()=>{const{accessor:e}=this._params;e.setActive(this)}),this.api.onDidConstraintsChangeInternal(e=>{"number"!=typeof e.minimumSize&&"function"!=typeof e.minimumSize||(this._minimumSize=e.minimumSize),"number"!=typeof e.maximumSize&&"function"!=typeof e.maximumSize||(this._maximumSize=e.maximumSize),this.updateConstraints()}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({size:e.size})}))}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(t,i){const[s,o]=this.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];super.layout(s,o)}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(){return Object.assign(Object.assign({},super.toJSON()),{minimumSize:(e=this.minimumSize,e<=0?void 0:e),maximumSize:(e=>e===Number.MAX_SAFE_INTEGER||e===Number.POSITIVE_INFINITY?void 0:e)(this.maximumSize)});var e}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}},e.Tab=Le,e.TabGroupColorPalette=$e,e.applyTabGroupAccent=Je,e.createDockview=function(e,t){return new ii(e,t).api},e.createGridview=function(e,t){const i=new si(e,t);return new ve(i)},e.createPaneview=function(e,t){const i=new li(e,t);return new me(i)},e.createSplitview=function(e,t){const i=new oi(e,t);return new ce(i)},e.directionToPosition=we,e.getDirectionOrientation=ie,e.getGridLocation=ee,e.getLocationOrientation=se,e.getPaneData=r,e.getPanelData=n,e.getRelativeLocation=te,e.indexInParent=Q,e.isGridBranchNode=ne,e.isGroupOptionsWithGroup=lt,e.isGroupOptionsWithPanel=ht,e.isPanelOptionsWithGroup=at,e.isPanelOptionsWithPanel=rt,e.orthogonal=oe,e.positionToDirection=De,e.resolveTabGroupAccent=je,e.themeAbyss=bt,e.themeAbyssSpaced={name:"abyssSpaced",className:"dockview-theme-abyss-spaced",colorScheme:"dark",gap:10,edgeGroupCollapsedSize:44,dndOverlayMounting:"absolute",dndPanelOverlay:"group",dndTabIndicator:"line",dndOverlayBorder:"2px solid var(--dv-active-sash-color)"},e.themeCatppuccinMocha={name:"catppuccinMocha",className:"dockview-theme-catppuccin-mocha",colorScheme:"dark"},e.themeCatppuccinMochaSpaced={name:"catppuccinMochaSpaced",className:"dockview-theme-catppuccin-mocha-spaced",colorScheme:"dark",gap:10,edgeGroupCollapsedSize:44,dndOverlayMounting:"absolute",dndPanelOverlay:"group",dndTabIndicator:"line",dndOverlayBorder:"2px solid var(--dv-active-sash-color)"},e.themeDark={name:"dark",className:"dockview-theme-dark",colorScheme:"dark"},e.themeDracula={name:"dracula",className:"dockview-theme-dracula",colorScheme:"dark"},e.themeGithubDark={name:"githubDark",className:"dockview-theme-github-dark",colorScheme:"dark"},e.themeGithubDarkSpaced={name:"githubDarkSpaced",className:"dockview-theme-github-dark-spaced",colorScheme:"dark",gap:10,edgeGroupCollapsedSize:44,dndOverlayMounting:"absolute",dndPanelOverlay:"group",dndTabIndicator:"line",dndOverlayBorder:"2px solid var(--dv-active-sash-color)"},e.themeGithubLight={name:"githubLight",className:"dockview-theme-github-light",colorScheme:"light"},e.themeGithubLightSpaced={name:"githubLightSpaced",className:"dockview-theme-github-light-spaced",colorScheme:"light",gap:10,edgeGroupCollapsedSize:44,dndOverlayMounting:"absolute",dndPanelOverlay:"group",dndTabIndicator:"line",dndOverlayBorder:"2px solid var(--dv-active-sash-color)"},e.themeLight={name:"light",className:"dockview-theme-light",colorScheme:"light"},e.themeLightSpaced={name:"lightSpaced",className:"dockview-theme-light-spaced",colorScheme:"light",gap:10,edgeGroupCollapsedSize:44,dndOverlayMounting:"absolute",dndPanelOverlay:"group",dndTabIndicator:"line",dndOverlayBorder:"2px solid var(--dv-active-sash-color)"},e.themeMonokai={name:"monokai",className:"dockview-theme-monokai",colorScheme:"dark"},e.themeNord={name:"nord",className:"dockview-theme-nord",colorScheme:"dark"},e.themeNordSpaced={name:"nordSpaced",className:"dockview-theme-nord-spaced",colorScheme:"dark",gap:10,edgeGroupCollapsedSize:44,dndOverlayMounting:"absolute",dndPanelOverlay:"group",dndTabIndicator:"line",dndOverlayBorder:"2px solid var(--dv-active-sash-color)"},e.themeSolarizedLight={name:"solarizedLight",className:"dockview-theme-solarized-light",colorScheme:"light"},e.themeSolarizedLightSpaced={name:"solarizedLightSpaced",className:"dockview-theme-solarized-light-spaced",colorScheme:"light",gap:10,edgeGroupCollapsedSize:44,dndOverlayMounting:"absolute",dndPanelOverlay:"group",dndTabIndicator:"line",dndOverlayBorder:"2px solid var(--dv-active-sash-color)"},e.themeVisualStudio={name:"visualStudio",className:"dockview-theme-vs",colorScheme:"dark",edgeGroupCollapsedSize:22},e.toTarget=pe});
7
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["dockview-core"]={})}(this,function(e){"use strict";class t{}class i extends t{constructor(e,t,i,s){super(),this.viewId=e,this.groupId=t,this.panelId=i,this.tabGroupId=s}}class s extends t{constructor(e,t){super(),this.viewId=e,this.paneId=t}}class o{constructor(){}static getInstance(){return o.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)}}function n(){const e=o.getInstance();if(e.hasData(i.prototype))return e.getData(i.prototype)[0]}function r(){const e=o.getInstance();if(e.hasData(s.prototype))return e.getData(s.prototype)[0]}var a;o.INSTANCE=new o,e.DockviewDisposable=void 0,(a=e.DockviewDisposable||(e.DockviewDisposable={})).NONE={dispose:()=>{}},a.from=function(e){return{dispose:()=>{e()}}};class l{get isDisposed(){return this._isDisposed}constructor(...e){this._isDisposed=!1,this._disposables=new Set(e)}addDisposables(...e){e.forEach(e=>this._disposables.add(e))}removeDisposable(e){this._disposables.delete(e)}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposables.forEach(e=>e.dispose()),this._disposables.clear())}}class h{constructor(){this._disposable=e.DockviewDisposable.NONE}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&(this._disposable.dispose(),this._disposable=e.DockviewDisposable.NONE)}}e.DockviewEvent=void 0,(e.DockviewEvent||(e.DockviewEvent={})).any=(...e)=>t=>{const i=e.map(e=>e(t));return{dispose:()=>{i.forEach(e=>{e.dispose()})}}};class d{constructor(){this._defaultPrevented=!1}get defaultPrevented(){return this._defaultPrevented}preventDefault(){this._defaultPrevented=!0}}class p{constructor(){this._isAccepted=!1}get isAccepted(){return this._isAccepted}accept(){this._isAccepted=!0}}class c{static create(){var e;return new c(null!==(e=(new Error).stack)&&void 0!==e?e:"")}constructor(e){this.value=e}print(){console.warn("dockview: stacktrace",this.value)}}class u{constructor(e,t){this.callback=e,this.stacktrace=t}}class m{static setLeakageMonitorEnabled(e){e!==m.ENABLE_TRACKING&&m.MEMORY_LEAK_WATCHER.clear(),m.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;(null===(t=this.options)||void 0===t?void 0:t.replay)&&void 0!==this._last&&e(this._last);const i=new u(e,m.ENABLE_TRACKING?c.create():void 0);return this._listeners.push(i),{dispose:()=>{const e=this._listeners.indexOf(i);e>-1?this._listeners.splice(e,1):m.ENABLE_TRACKING}}},m.ENABLE_TRACKING&&m.MEMORY_LEAK_WATCHER.add(this._event,c.create())),this._event}fire(e){var t;if(!(this._pauseTokens.size>0)){(null===(t=this.options)||void 0===t?void 0:t.replay)&&(this._last=e);for(const t of this._listeners)t.callback(e)}}pause(){const t={};return this._pauseTokens.add(t),e.DockviewDisposable.from(()=>this._pauseTokens.delete(t))}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&(m.ENABLE_TRACKING&&queueMicrotask(()=>{var e;for(const t of this._listeners)console.warn("dockview: stacktrace",null===(e=t.stacktrace)||void 0===e?void 0:e.print())}),this._listeners=[]),m.ENABLE_TRACKING&&this._event&&m.MEMORY_LEAK_WATCHER.delete(this._event))}}function v(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i,s)}}}m.ENABLE_TRACKING=!1,m.MEMORY_LEAK_WATCHER=new class{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 g{constructor(){this._onFired=new m,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 _ extends l{constructor(e){super(),this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this._value=null,this.addDisposables(this._onDidChange,f(e,e=>{const t=e.target.scrollWidth>e.target.clientWidth,i=e.target.scrollHeight>e.target.clientHeight;this._value={hasScrollX:t,hasScrollY:i},this._onDidChange.fire(this._value)}))}}function f(e,t){const i=new ResizeObserver(e=>{requestAnimationFrame(()=>{const i=e[0];t(i)})});return i.observe(e),{dispose:()=>{i.unobserve(e),i.disconnect()}}}const b=(e,...t)=>{for(const i of t)e.classList.contains(i)&&e.classList.remove(i)},w=(e,...t)=>{for(const i of t)e.classList.contains(i)||e.classList.add(i)},D=(e,t,i)=>{const s=e.classList.contains(t);i&&!s&&e.classList.add(t),!i&&s&&e.classList.remove(t)};function C(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function y(e){return new S(e)}class S extends l{constructor(e){super(),this._onDidFocus=new m,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new m,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=C(document.activeElement,e),i=!1;const s=()=>{i=!1,t||(t=!0,this._onDidFocus.fire())},o=()=>{t&&(i=!0,window.setTimeout(()=>{i&&(i=!1,t=!1,this._onDidBlur.fire())},0))};this._refreshStateHandler=()=>{C(document.activeElement,e)!==t&&(t?o():s())},this.addDisposables(v(e,"focus",s,!0)),this.addDisposables(v(e,"blur",o,!0))}refreshState(){this._refreshStateHandler()}}const x="dv-quasiPreventDefault";function G(e){return e[x]}function P(e){const{left:t,top:i,width:s,height:o}=e.getBoundingClientRect();return{left:t+window.scrollX,top:i+window.scrollY,width:s,height:o}}function T(e=document){const t=function(e,t){const i=[];return function t(s){if(s.nodeType===Node.ELEMENT_NODE){e.includes(s.tagName)&&i.push(s),s.shadowRoot&&t(s.shadowRoot);for(const e of s.children)t(e)}}(t instanceof Document?t.documentElement:t),i}(["IFRAME","WEBVIEW"],e),i=new WeakMap;for(const e of t)i.set(e,e.style.pointerEvents),e.style.pointerEvents="none";return{release:()=>{var e;for(const s of t)s.style.pointerEvents=null!==(e=i.get(s))&&void 0!==e?e:"auto";t.splice(0,t.length)}}}class I{constructor(e){this.element=e,this._classNames=[]}setClassNames(e){for(const e of this._classNames)D(this.element,e,!1);this._classNames=e.split(" ").filter(e=>e.trim().length>0);for(const e of this._classNames)D(this.element,e,!0)}}function z(e,t){const i=P(e),s=P(t);return!(i.left<s.left)&&(!(i.left+i.width>s.left+s.width)&&(!(i.top<s.top)&&!(i.top+i.height>s.top+s.height)))}function A(e){let t=e;for(;t&&("auto"===t.style.zIndex||""===t.style.zIndex);)t=t.parentElement;return t}function E(e){if(0===e.length)throw new Error("Invalid tail call");return[e.slice(0,e.length-1),e[e.length-1]]}function O(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}function M(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.unshift(t))}function k(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.push(t))}function V(e,t){const i=e.findIndex(e=>e===t);return i>-1&&(e.splice(i,1),!0)}const L=(e,t,i)=>t>i?t:Math.min(i,Math.max(e,t)),N=()=>{let e=1;return{next:()=>(e++).toString()}},R=(e,t)=>{const i=[];if("number"!=typeof t&&(t=e,e=0),e<=t)for(let s=e;s<t;s++)i.push(s);else for(let s=e;s>t;s--)i.push(s);return i};class W{set size(e){this._size=e}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return void 0===this._cachedVisibleSize}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,s){this.container=e,this.view=t,this.disposable=s,this._cachedVisibleSize=void 0,"number"==typeof i?(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=L(null!==(i=this._cachedVisibleSize)&&void 0!==i?i:0,this.viewMinimumSize,this.viewMaximumSize),this._cachedVisibleSize=void 0):(this._cachedVisibleSize="number"==typeof t?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 H,F,B,$;e.Orientation=void 0,(H=e.Orientation||(e.Orientation={})).HORIZONTAL="HORIZONTAL",H.VERTICAL="VERTICAL",e.SashState=void 0,(F=e.SashState||(e.SashState={}))[F.MAXIMUM=0]="MAXIMUM",F[F.MINIMUM=1]="MINIMUM",F[F.DISABLED=2]="DISABLED",F[F.ENABLED=3]="ENABLED",e.LayoutPriority=void 0,(B=e.LayoutPriority||(e.LayoutPriority={})).Low="low",B.High="high",B.Normal="normal",e.Sizing=void 0,($=e.Sizing||(e.Sizing={})).Distribute={type:"distribute"},$.Split=function(e){return{type:"split",index:e}},$.Invisible=function(e){return{type:"invisible",cachedVisibleSize:e}};class U{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(t){this._orientation=t;const i=this.size;this.size=this.orthogonalSize,this.orthogonalSize=i,b(this.element,"dv-horizontal","dv-vertical"),this.element.classList.add(this.orientation==e.Orientation.HORIZONTAL?"dv-horizontal":"dv-vertical")}get minimumSize(){return this.viewItems.reduce((e,t)=>e+t.minimumSize,0)}get maximumSize(){return 0===this.length?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,D(this.element,"dv-splitview-disabled",e)}get margin(){return this._margin}set margin(e){this._margin=e,D(this.element,"dv-splitview-has-margin",0!==e)}constructor(t,i){var s,o;this.container=t,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 m,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new m,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new m,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(e,t,i=this.viewItems.map(e=>e.size),s,o,n=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY,a,l)=>{if(e<0||e>this.viewItems.length)return 0;const h=R(e,-1),d=R(e+1,this.viewItems.length);if(o)for(const e of o)M(h,e),M(d,e);if(s)for(const e of s)k(h,e),k(d,e);const p=h.map(e=>this.viewItems[e]),c=h.map(e=>i[e]),u=d.map(e=>this.viewItems[e]),m=d.map(e=>i[e]),v=h.reduce((e,t)=>e+this.viewItems[t].minimumSize-i[t],0),g=h.reduce((e,t)=>e+this.viewItems[t].maximumSize-i[t],0),_=0===d.length?Number.POSITIVE_INFINITY:d.reduce((e,t)=>e+i[t]-this.viewItems[t].minimumSize,0),f=0===d.length?Number.NEGATIVE_INFINITY:d.reduce((e,t)=>e+i[t]-this.viewItems[t].maximumSize,0),b=Math.max(v,f),w=Math.min(_,g);let D=!1;if(a){const e=this.viewItems[a.index],i=t>=a.limitDelta;D=i!==e.visible,e.setVisible(i,a.size)}if(!D&&l){const e=this.viewItems[l.index],i=t<l.limitDelta;D=i!==e.visible,e.setVisible(i,l.size)}if(D)return this.resize(e,t,i,s,o,n,r);let C=0,y=L(t,b,w);for(let e=0;e<p.length;e++){const t=p[e],i=L(c[e]+y,t.minimumSize,t.maximumSize),s=i-c[e];C+=s,y-=s,t.size=i}let S=C;for(let e=0;e<u.length;e++){const t=u[e],i=L(m[e]-S,t.minimumSize,t.maximumSize);S+=i-m[e],t.size=i}return t},this._orientation=null!==(s=i.orientation)&&void 0!==s?s:e.Orientation.VERTICAL,this.element=this.createContainer(),this.margin=null!==(o=i.margin)&&void 0!==o?o:0,this.proportionalLayout=void 0===i.proportionalLayout||!!i.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(i.styles),i.descriptor&&(this._size=i.descriptor.size,i.descriptor.views.forEach((e,t)=>{const i=void 0===e.visible||e.visible?e.size:{type:"invisible",cachedVisibleSize:e.size},s=e.view;this.addView(s,i,t,!0)}),this._contentSize=this.viewItems.reduce((e,t)=>e+t.size,0),this.saveProportions())}style(e){"transparent"===(null==e?void 0:e.separatorBorder)?(b(this.element,"dv-separator-border"),this.element.style.removeProperty("--dv-separator-border")):(w(this.element,"dv-separator-border"),(null==e?void 0: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(t,i){if(t<0||t>=this.viewItems.length)return;const s=R(this.viewItems.length).filter(e=>e!==t),o=[...s.filter(t=>this.viewItems[t].priority===e.LayoutPriority.Low),t],n=s.filter(t=>this.viewItems[t].priority===e.LayoutPriority.High),r=this.viewItems[t];i=Math.round(i),i=L(i,r.minimumSize,Math.min(r.maximumSize,this._size)),r.size=i,this.relayout(o,n)}getViews(){return this.viewItems.map(e=>e.view)}onDidChange(t,i){const s=this.viewItems.indexOf(t);if(s<0||s>=this.viewItems.length)return;i="number"==typeof i?i:t.size,i=L(i,t.minimumSize,t.maximumSize),t.size=i;const o=R(this.viewItems.length).filter(e=>e!==s),n=[...o.filter(t=>this.viewItems[t].priority===e.LayoutPriority.Low),s],r=o.filter(t=>this.viewItems[t].priority===e.LayoutPriority.High);this.relayout([...n,s],r)}addView(t,i={type:"distribute"},s=this.viewItems.length,o){const n=document.createElement("div");let r;n.className="dv-view",n.appendChild(t.element),r="number"==typeof i?i:"split"===i.type?this.getViewSize(i.index)/2:"invisible"===i.type?{cachedVisibleSize:i.cachedVisibleSize}:t.minimumSize;const a=t.onDidChange(e=>this.onDidChange(l,e.size)),l=new W(n,t,r,{dispose:()=>{a.dispose(),this.viewContainer.removeChild(n)}});if(s===this.viewItems.length?this.viewContainer.appendChild(n):this.viewContainer.insertBefore(n,this.viewContainer.children.item(s)),this.viewItems.splice(s,0,l),this.viewItems.length>1){const t=document.createElement("div");t.className="dv-sash";const i=i=>{for(const e of this.viewItems)e.enabled=!1;const s=T(),o=this._orientation===e.Orientation.HORIZONTAL?i.clientX:i.clientY,n=function(e,t){for(let i=0;i<e.length;i++)if(t(e[i]))return i;return-1}(this.sashes,e=>e.container===t),r=this.viewItems.map(e=>e.size);let a,l;const h=R(n,-1),d=R(n+1,this.viewItems.length),p=h.reduce((e,t)=>e+(this.viewItems[t].minimumSize-r[t]),0),c=h.reduce((e,t)=>e+(this.viewItems[t].viewMaximumSize-r[t]),0),u=0===d.length?Number.POSITIVE_INFINITY:d.reduce((e,t)=>e+(r[t]-this.viewItems[t].minimumSize),0),m=0===d.length?Number.NEGATIVE_INFINITY:d.reduce((e,t)=>e+(r[t]-this.viewItems[t].viewMaximumSize),0),v=Math.max(p,m),g=Math.min(u,c),_=this.findFirstSnapIndex(h),f=this.findFirstSnapIndex(d);if("number"==typeof _){const e=this.viewItems[_],t=Math.floor(e.viewMinimumSize/2);a={index:_,limitDelta:e.visible?v-t:v+t,size:e.size}}if("number"==typeof f){const e=this.viewItems[f],t=Math.floor(e.viewMinimumSize/2);l={index:f,limitDelta:e.visible?g+t:g-t,size:e.size}}const b=t=>{const i=(this._orientation===e.Orientation.HORIZONTAL?t.clientX:t.clientY)-o;this.resize(n,i,r,void 0,void 0,v,g,a,l),this.distributeEmptySpace(),this.layoutViews()},w=()=>{for(const e of this.viewItems)e.enabled=!0;s.release(),this.saveProportions(),document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",w),document.removeEventListener("pointercancel",w),document.removeEventListener("contextmenu",w),this._onDidSashEnd.fire(void 0)};document.addEventListener("pointermove",b),document.addEventListener("pointerup",w),document.addEventListener("pointercancel",w),document.addEventListener("contextmenu",w)};t.addEventListener("pointerdown",i);const s={container:t,disposable:()=>{t.removeEventListener("pointerdown",i),this.sashContainer.removeChild(t)}};this.sashContainer.appendChild(t),this.sashes.push(s)}o||this.relayout([s]),o||"number"==typeof i||"distribute"!==i.type||this.distributeViewSizes(),this._onDidAddView.fire(t)}distributeViewSizes(){const t=[];let i=0;for(const e of this.viewItems)e.maximumSize-e.minimumSize>0&&(t.push(e),i+=e.size);const s=Math.floor(i/t.length);for(const e of t)e.size=L(s,e.minimumSize,e.maximumSize);const o=R(this.viewItems.length),n=o.filter(t=>this.viewItems[t].priority===e.LayoutPriority.Low),r=o.filter(t=>this.viewItems[t].priority===e.LayoutPriority.High);this.relayout(n,r)}removeView(e,t,i=!1){const s=this.viewItems.splice(e,1)[0];if(s.dispose(),this.viewItems.length>=1){const t=Math.max(e-1,0);this.sashes.splice(t,1)[0].disposable()}return i||this.relayout(),t&&"distribute"===t.type&&this.distributeViewSizes(),this._onDidRemoveView.fire(s.view),s.view}getViewCachedVisibleSize(e){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");return this.viewItems[e].cachedVisibleSize}moveView(t,i){const s=this.getViewCachedVisibleSize(t),o=void 0===s?this.getViewSize(t):e.Sizing.Invisible(s),n=this.removeView(t,void 0,!0);this.addView(n,o,i)}layout(t,i){const s=Math.max(this.size,this._contentSize);if(this.size=t,this.orthogonalSize=i,this.proportions){let e=0;for(let i=0;i<this.viewItems.length;i++){const s=this.viewItems[i],o=this.proportions[i];"number"==typeof o?e+=o:t-=s.size}for(let i=0;i<this.viewItems.length;i++){const s=this.viewItems[i],o=this.proportions[i];"number"==typeof o&&e>0&&(s.size=L(Math.round(o*t/e),s.minimumSize,s.maximumSize))}}else{const i=R(this.viewItems.length),o=i.filter(t=>this.viewItems[t].priority===e.LayoutPriority.Low),n=i.filter(t=>this.viewItems[t].priority===e.LayoutPriority.High);this.resize(this.viewItems.length-1,t-s,void 0,o,n)}this.distributeEmptySpace(),this.layoutViews()}relayout(e,t){const i=this.viewItems.reduce((e,t)=>e+t.size,0);this.resize(this.viewItems.length-1,this._size-i,void 0,e,t),this.distributeEmptySpace(),this.layoutViews(),this.saveProportions()}distributeEmptySpace(t){const i=this.viewItems.reduce((e,t)=>e+t.size,0);let s=this.size-i;const o=R(this.viewItems.length-1,-1),n=o.filter(t=>this.viewItems[t].priority===e.LayoutPriority.Low),r=o.filter(t=>this.viewItems[t].priority===e.LayoutPriority.High);for(const e of r)M(o,e);for(const e of n)k(o,e);"number"==typeof t&&k(o,t);for(let e=0;0!==s&&e<o.length;e++){const t=this.viewItems[o[e]],i=L(t.size+s,t.minimumSize,t.maximumSize);s-=i-t.size,t.size=i}}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((e,t)=>e+t.size,0),this.updateSashEnablement(),0===this.viewItems.length)return;const t=this.viewItems.filter(e=>e.visible),i=Math.max(0,t.length-1),s=this.margin*i/Math.max(1,t.length);let o=0;const n=[],r=this.viewItems.reduce((e,t,i)=>{const s=t.visible?1:0;return 0===i?e.push(s):e.push(e[i-1]+s),e},[]);this.viewItems.forEach((t,a)=>{o+=this.viewItems[a].size,n.push(o);const l=t.visible?t.size-s:0,h=Math.max(0,r[a]-1),d=0===a||0===h?0:n[a-1]+h/i*s;if(a<this.viewItems.length-1){const i=t.visible?d+l-2+this.margin/2:d;this._orientation===e.Orientation.HORIZONTAL&&(this.sashes[a].container.style.left=`${i}px`,this.sashes[a].container.style.top="0px"),this._orientation===e.Orientation.VERTICAL&&(this.sashes[a].container.style.left="0px",this.sashes[a].container.style.top=`${i}px`)}this._orientation===e.Orientation.HORIZONTAL&&(t.container.style.width=`${l}px`,t.container.style.left=`${d}px`,t.container.style.top="",t.container.style.height=""),this._orientation===e.Orientation.VERTICAL&&(t.container.style.height=`${l}px`,t.container.style.top=`${d}px`,t.container.style.width="",t.container.style.left=""),t.view.layout(t.size-s,this._orthogonalSize)})}findFirstSnapIndex(e){for(const t of e){const e=this.viewItems[t];if(e.visible&&e.snap)return t}for(const t of e){const e=this.viewItems[t];if(e.visible&&e.maximumSize-e.minimumSize>0)return;if(!e.visible&&e.snap)return t}}updateSashEnablement(){let t=!1;const i=this.viewItems.map(e=>t=e.size-e.minimumSize>0||t);t=!1;const s=this.viewItems.map(e=>t=e.maximumSize-e.size>0||t),o=[...this.viewItems].reverse();t=!1;const n=o.map(e=>t=e.size-e.minimumSize>0||t).reverse();t=!1;const r=o.map(e=>t=e.maximumSize-e.size>0||t).reverse();let a=0;for(let t=0;t<this.sashes.length;t++){const o=this.sashes[t];a+=this.viewItems[t].size;const l=!(i[t]&&r[t+1]),h=!(s[t]&&n[t+1]);if(l&&h){const s=R(t,-1),r=R(t+1,this.viewItems.length),l=this.findFirstSnapIndex(s),h=this.findFirstSnapIndex(r),d="number"==typeof l&&!this.viewItems[l].visible,p="number"==typeof h&&!this.viewItems[h].visible;d&&n[t]&&(a>0||this.startSnappingEnabled)?this.updateSash(o,e.SashState.MINIMUM):p&&i[t]&&(a<this._contentSize||this.endSnappingEnabled)?this.updateSash(o,e.SashState.MAXIMUM):this.updateSash(o,e.SashState.DISABLED)}else l&&!h?this.updateSash(o,e.SashState.MINIMUM):!l&&h?this.updateSash(o,e.SashState.MAXIMUM):this.updateSash(o,e.SashState.ENABLED)}}updateSash(t,i){D(t.container,"dv-disabled",i===e.SashState.DISABLED),D(t.container,"dv-enabled",i===e.SashState.ENABLED),D(t.container,"dv-maximum",i===e.SashState.MAXIMUM),D(t.container,"dv-minimum",i===e.SashState.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 t=document.createElement("div"),i=this._orientation===e.Orientation.HORIZONTAL?"dv-horizontal":"dv-vertical";return t.className=`dv-split-view-container ${i}`,t}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 Y=(()=>{const e={orientation:void 0,descriptor:void 0,proportionalLayout:void 0,styles:void 0,margin:void 0,disableAutoResizing:void 0,className:void 0};return Object.keys(e)})();class X extends l{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(t,i){var s;super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this._orientation=null!==(s=i.orientation)&&void 0!==s?s:e.Orientation.VERTICAL,this.element=document.createElement("div"),this.element.className="dv-pane-container",t.appendChild(this.element),this.splitview=new U(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:i.descriptor}),this.getPanes().forEach(e=>{const t=new l(e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),i={pane:e,disposable:{dispose:()=>{t.dispose()}}};this.paneItems.push(i),e.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,s=!1){const o=e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)}),n={pane:e,disposable:{dispose:()=>{o.dispose()}}};this.paneItems.splice(i,0,n),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,i,s)}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),w(this.element,"dv-animated"),this.animationTimer=setTimeout(()=>{this.animationTimer=void 0,b(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 J{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===e.Orientation.HORIZONTAL?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===e.Orientation.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===e.Orientation.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===e.Orientation.HORIZONTAL?this.orthogonalSize:this.size}get height(){return this.orientation===e.Orientation.HORIZONTAL?this.size:this.orthogonalSize}constructor(t,i,s,o=0){this.view=t,this.orientation=i,this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this._orthogonalSize=s,this._size=o,this._disposable=this.view.onDidChange(t=>{t?this._onDidChange.fire({size:this.orientation===e.Orientation.VERTICAL?t.width:t.height,orthogonalSize:this.orientation===e.Orientation.VERTICAL?t.height:t.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 j extends l{get width(){return this.orientation===e.Orientation.HORIZONTAL?this.size:this.orthogonalSize}get height(){return this.orientation===e.Orientation.HORIZONTAL?this.orthogonalSize:this.size}get minimumSize(){return 0===this.children.length?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===e.Orientation.HORIZONTAL?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===e.Orientation.HORIZONTAL?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumSize:this.maximumOrthogonalSize}get priority(){if(0===this.children.length)return e.LayoutPriority.Normal;const t=this.children.map(t=>void 0===t.priority?e.LayoutPriority.Normal:t.priority);return t.some(t=>t===e.LayoutPriority.High)?e.LayoutPriority.High:t.some(t=>t===e.LayoutPriority.Low)?e.LayoutPriority.Low:e.LayoutPriority.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 j&&(t.margin=e)})}constructor(t,i,s,o,n,r,a,l){if(super(),this.orientation=t,this.proportionalLayout=i,this.styles=s,this._childrenDisposable=e.DockviewDisposable.NONE,this.children=[],this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new m,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._orthogonalSize=n,this._size=o,this.element=document.createElement("div"),this.element.className="dv-branch-node",l){const e={views:l.map(e=>({view:e.node,size:e.node.size,visible:!(e.node instanceof J&&void 0!==e.visible)||e.visible})),size:this.orthogonalSize};this.children=l.map(e=>e.node),this.splitview=new U(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:i,styles:s,margin:a})}else this.splitview=new U(this.element,{orientation:this.orientation,proportionalLayout:i,styles:s,margin:a}),this.splitview.layout(this.size,this.orthogonalSize);this.disabled=r,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=0===this.splitview.contentSize;this.splitview.setViewVisible(e,t);const s=0===this.splitview.contentSize;(t&&i||!t&&s)&&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,s){if(i<0||i>this.children.length)throw new Error("Invalid index");this.splitview.addView(e,t,i,s),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 l(e.DockviewEvent.any(...this.children.map(e=>e.onDidChange))(e=>{this._onDidChange.fire({size:e.orthogonalSize})}),...this.children.map((t,i)=>t instanceof j?t.onDidVisibilityChange(({visible:e})=>{this.setChildVisible(i,e)}):e.DockviewDisposable.NONE))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach(e=>e.dispose()),super.dispose()}}function Z(e,t){if(e instanceof J)return e;if(e instanceof j)return Z(e.children[t?e.children.length-1:0],t);throw new Error("invalid node")}function q(e,t,i){if(e instanceof j){const s=new j(e.orientation,e.proportionalLayout,e.styles,t,i,e.disabled,e.margin);for(let t=e.children.length-1;t>=0;t--){const i=e.children[t];s.addChild(q(i,i.size,i.orthogonalSize),i.size,0,!0)}return s}return new J(e.view,e.orientation,i)}function K(e,t,i){if(e instanceof j){const s=new j(oe(e.orientation),e.proportionalLayout,e.styles,t,i,e.disabled,e.margin);let o=0;for(let n=e.children.length-1;n>=0;n--){const r=e.children[n],a=r instanceof j?r.orthogonalSize:r.size;let l=0===e.size?0:Math.round(t*a/e.size);o+=l,0===n&&(l+=t-o),s.addChild(K(r,i,l),l,0,!0)}return s}return new J(e.view,oe(e.orientation),i)}function Q(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");let i=t.firstElementChild,s=0;for(;i!==e&&i!==t.lastElementChild&&i;)i=i.nextElementSibling,s++;return s}function ee(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");if(/\bdv-grid-view\b/.test(t.className))return[];const i=Q(t);return[...ee(t.parentElement.parentElement.parentElement),i]}function te(e,t,i){if(se(e,t)===ie(i)){const[e,s]=E(t);let o=s;return"right"!==i&&"bottom"!==i||(o+=1),[...e,o]}{const e="right"===i||"bottom"===i?1:0;return[...t,e]}}function ie(t){return"top"===t||"bottom"===t?e.Orientation.VERTICAL:e.Orientation.HORIZONTAL}function se(e,t){return t.length%2==0?oe(e):e}const oe=t=>t===e.Orientation.HORIZONTAL?e.Orientation.VERTICAL:e.Orientation.HORIZONTAL;function ne(e){return!!e.children}const re=(t,i)=>{const s=i===e.Orientation.VERTICAL?t.box.width:t.box.height;return ne(t)?{type:"branch",data:t.children.map(e=>re(e,oe(i))),size:s}:"number"==typeof t.cachedVisibleSize?{type:"leaf",data:t.view.toJSON(),size:t.cachedVisibleSize,visible:!1}:{type:"leaf",data:t.view.toJSON(),size:s}};class ae{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=K(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 j&&(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 null===(e=this._maximizedNode)||void 0===e?void 0:e.leaf.view}hasMaximizedView(){return void 0!==this._maximizedNode}maximizeView(e){var t;const i=ee(e.element),[s,o]=this.getNode(i);if(!(o instanceof J))return;if((null===(t=this._maximizedNode)||void 0===t?void 0:t.leaf)===o)return;this.hasMaximizedView()&&this.exitMaximizedView(),re(this.getView(),this.orientation);const n=[];!function e(t,i){for(let s=0;s<t.children.length;s++){const o=t.children[s];o instanceof J?o!==i&&(t.isChildVisible(s)?t.setChildVisible(s,!1):n.push(o)):e(o,i)}}(this.root,o),this._maximizedNode={leaf:o,hiddenOnMaximize:n},this._onDidMaximizedNodeChange.fire({view:o.view,isMaximized:!0})}exitMaximizedView(){if(!this._maximizedNode)return;const e=this._maximizedNode.hiddenOnMaximize;!function t(i){for(let s=i.children.length-1;s>=0;s--){const o=i.children[s];o instanceof J?e.includes(o)||i.setChildVisible(s,!0):t(o)}}(this.root);const t=this._maximizedNode.leaf;this._maximizedNode=void 0,this._onDidMaximizedNodeChange.fire({view:t.view,isMaximized:!1})}serialize(){const e=this.maximizedView();let t;e&&(t=ee(e.element));const i=this._onDidMaximizedNodeChange.pause();try{this.hasMaximizedView()&&this.exitMaximizedView();const i={root:re(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation};return t&&(i.maximizedNode={location:t}),e&&this.maximizeView(e),i}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 j(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize,this.locked,this.margin)}deserialize(t,i){const s=t.orientation,o=s===e.Orientation.VERTICAL?t.height:t.width;if(this._deserialize(t.root,s,i,o),this.layout(t.width,t.height),t.maximizedNode){const e=t.maximizedNode.location,[i,s]=this.getNode(e);if(!(s instanceof J))return;this.maximizeView(s.view)}}_deserialize(e,t,i,s){this.root=this._deserializeNode(e,t,i,s)}_deserializeNode(e,t,i,s){var o;let n;if("branch"===e.type){const o=e.data.map(s=>({node:this._deserializeNode(s,oe(t),i,e.size),visible:s.visible}));n=new j(t,this.proportionalLayout,this.styles,e.size,s,this.locked,this.margin,o)}else{const r=i.fromJSON(e);"boolean"==typeof e.visible&&(null===(o=r.setVisible)||void 0===o||o.call(r,e.visible)),n=new J(r,t,s,e.size)}return n}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(e=>{this._onDidChange.fire(e)})}normalize(){if(!this._root)return;if(1!==this._root.children.length)return;const e=this.root,t=e.children[0];if(t instanceof J)return;e.element.remove();const i=e.removeChild(0);e.dispose(),i.dispose(),this._root=q(t,t.size,t.orthogonalSize),this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}insertOrthogonalSplitviewAtRoot(){if(!this._root)return;const t=this.root;if(t.element.remove(),this._root=new j(oe(t.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size,this.locked,this.margin),0===t.children.length);else if(1===t.children.length){const i=t.children[0];t.removeChild(0).dispose(),t.dispose(),this._root.addChild(K(i,i.orthogonalSize,i.size),e.Sizing.Distribute,0)}else this._root.addChild(t,e.Sizing.Distribute,0);this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}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 s={height:e.height,width:e.width};if(e instanceof J)return{box:s,view:e.view,cachedVisibleSize:i};const o=[];for(let i=0;i<e.children.length;i++){const s=e.children[i],n=e.getChildCachedVisibleSize(i);o.push(this._getViews(s,oe(t),n))}return{box:s,children:o}}progmaticSelect(e,t=!1){const[i,s]=this.getNode(e);if(!(s instanceof J))throw new Error("invalid location");for(let s=i.length-1;s>-1;s--){const o=i[s],n=e[s]||0;if(t?n-1>-1:n+1<o.children.length)return Z(o.children[t?n-1:n+1],t)}return Z(this.root,t)}constructor(e,t,i,s,o){this.proportionalLayout=e,this.styles=t,this._locked=!1,this._margin=0,this._maximizedNode=void 0,this.disposable=new h,this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this._onDidViewVisibilityChange=new m,this.onDidViewVisibilityChange=this._onDidViewVisibilityChange.event,this._onDidMaximizedNodeChange=new m,this.onDidMaximizedNodeChange=this._onDidMaximizedNodeChange.event,this.element=document.createElement("div"),this.element.className="dv-grid-view",this._locked=null!=s&&s,this._margin=null!=o?o:0,this.root=new j(i,e,t,0,0,this.locked,this.margin)}isViewVisible(e){const[t,i]=E(e),[,s]=this.getNode(t);if(!(s instanceof j))throw new Error("Invalid from location");return s.isChildVisible(i)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,s]=E(e),[,o]=this.getNode(i);if(!(o instanceof j))throw new Error("Invalid from location");this._onDidViewVisibilityChange.fire(),o.setChildVisible(s,t)}moveView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[,s]=this.getNode(e);if(!(s instanceof j))throw new Error("Invalid location");s.moveChild(t,i)}addView(t,i,s){this.hasMaximizedView()&&this.exitMaximizedView();const[o,n]=E(s),[r,a]=this.getNode(o);if(a instanceof j){const e=new J(t,oe(a.orientation),a.orthogonalSize);a.addChild(e,i,n)}else{const[s,...l]=[...r].reverse(),[h,...d]=[...o].reverse();let p=0;const c=s.getChildCachedVisibleSize(h);"number"==typeof c&&(p=e.Sizing.Invisible(c));s.removeChild(h).dispose();const u=new j(a.orientation,this.proportionalLayout,this.styles,a.size,a.orthogonalSize,this.locked,this.margin);s.addChild(u,a.size,h);const m=new J(a.view,s.orientation,a.size);u.addChild(m,p,0),"number"!=typeof i&&"split"===i.type&&(i={type:"split",index:0});const v=new J(t,s.orientation,a.size);u.addChild(v,i,n)}}remove(e,t){const i=ee(e.element);return this.removeView(i,t)}removeView(t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[s,o]=E(t),[n,r]=this.getNode(s);if(!(r instanceof j))throw new Error("Invalid location");const a=r.children[o];if(!(a instanceof J))throw new Error("Invalid location");if(r.removeChild(o,i),a.dispose(),1!==r.children.length)return a.view;const l=r.children[0];if(0===n.length)return l instanceof J||(r.removeChild(0,i),this.root=l),a.view;const[h,...d]=[...n].reverse(),[p,...c]=[...s].reverse(),u=r.isChildVisible(0);r.removeChild(0,i);const m=h.children.map((e,t)=>h.getChildSize(t));if(h.removeChild(p,i).dispose(),l instanceof j){m.splice(p,1,...l.children.map(e=>e.size));for(let e=0;e<l.children.length;e++){const t=l.children[e];h.addChild(t,t.size,p+e)}for(;l.children.length>0;)l.removeChild(0)}else{const t=new J(l.view,oe(l.orientation),l.size),i=u?l.orthogonalSize:e.Sizing.Invisible(l.orthogonalSize);h.addChild(t,i,p)}l.dispose();for(let e=0;e<m.length;e++)h.resizeChild(e,m[e]);return a.view}layout(t,i){const[s,o]=this.root.orientation===e.Orientation.HORIZONTAL?[i,t]:[t,i];this.root.layout(s,o)}getNode(e,t=this.root,i=[]){if(0===e.length)return[i,t];if(!(t instanceof j))throw new Error("Invalid location");const[s,...o]=e;if(s<0||s>=t.children.length)throw new Error("Invalid location");const n=t.children[s];return i.push(t),this.getNode(o,n,i)}}const le=(()=>{const e={disableAutoResizing:void 0,proportionalLayout:void 0,orientation:void 0,hideBorders:void 0,className:void 0};return Object.keys(e)})();class he extends l{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(f(this._element,e=>{if(this.isDisposed)return;if(this.disableResizing)return;if(!this._element.offsetParent)return;if(!function(e){let t=e;for(;null==t?void 0:t.parentNode;){if(t.parentNode===document)return!0;t=t.parentNode instanceof DocumentFragment?t.parentNode.host:t.parentNode}return!1}(this._element))return;const t=Math.round(e.contentRect.width),i=Math.round(e.contentRect.height);t===this._lastWidth&&i===this._lastHeight||(this._lastWidth=t,this._lastHeight=i,this.layout(t,i))}))}}const de=N();function pe(e){switch(e){case"left":return"left";case"right":return"right";case"above":return"top";case"below":return"bottom";default:return"center"}}class ce extends he{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(t,i){var s;super(document.createElement("div"),i.disableAutoResizing),this._id=de.next(),this._groups=new Map,this._onDidRemove=new m,this.onDidRemove=this._onDidRemove.event,this._onDidAdd=new m,this.onDidAdd=this._onDidAdd.event,this._onDidMaximizedChange=new m,this.onDidMaximizedChange=this._onDidMaximizedChange.event,this._onDidActiveChange=new m,this.onDidActiveChange=this._onDidActiveChange.event,this._bufferOnDidLayoutChange=new g,this.onDidLayoutChange=this._bufferOnDidLayoutChange.onEvent,this._onDidViewVisibilityChangeMicroTaskQueue=new g,this.onDidViewVisibilityChangeMicroTaskQueue=this._onDidViewVisibilityChangeMicroTaskQueue.onEvent,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new I(this.element),this._classNames.setClassNames(null!==(s=i.className)&&void 0!==s?s:""),t.appendChild(this.element),this.gridview=new ae(!!i.proportionalLayout,i.styles,i.orientation,i.locked,i.margin),this.gridview.locked=!!i.locked,this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidMaximizedNodeChange(e=>{this._onDidMaximizedChange.fire({panel:e.view,isMaximized:e.isMaximized})}),this.gridview.onDidViewVisibilityChange(()=>this._onDidViewVisibilityChangeMicroTaskQueue.fire()),this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.forceRelayout()}),e.DockviewDisposable.from(()=>{var e;null===(e=this.element.parentElement)||void 0===e||e.removeChild(this.element)}),this.gridview.onDidChange(()=>{this._bufferOnDidLayoutChange.fire()}),e.DockviewEvent.any(this.onDidAdd,this.onDidRemove,this.onDidActiveChange)(()=>{this._bufferOnDidLayoutChange.fire()}),this._onDidMaximizedChange,this._onDidViewVisibilityChangeMicroTaskQueue,this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(ee(e.element),t),this._bufferOnDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(ee(e.element))}updateOptions(e){var t,i,s,o;e.proportionalLayout,e.orientation&&(this.gridview.orientation=e.orientation),"disableResizing"in e&&(this.disableResizing=null!==(t=e.disableAutoResizing)&&void 0!==t&&t),"locked"in e&&(this.locked=null!==(i=e.locked)&&void 0!==i&&i),"margin"in e&&(this.gridview.margin=null!==(s=e.margin)&&void 0!==s?s:0),"className"in e&&this._classNames.setClassNames(null!==(o=e.className)&&void 0!==o?o:"")}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(t,i=[0],s){this.gridview.addView(t,null!=s?s:e.Sizing.Distribute,i),this._onDidAdd.fire(t)}doRemoveGroup(t,i){if(!this._groups.has(t.id))throw new Error("invalid operation");const s=this._groups.get(t.id),o=this.gridview.remove(t,e.Sizing.Distribute);if(s&&!(null==i?void 0:i.skipDispose)&&(s.disposable.dispose(),s.value.dispose(),this._groups.delete(t.id),this._onDidRemove.fire(t)),!(null==i?void 0:i.skipActive)&&this._activeGroup===t){const e=Array.from(this._groups.values());this.doSetGroupActive(e.length>0?e[0].value:void 0)}return o}getPanel(e){var t;return null===(t=this._groups.get(e))||void 0===t?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=ee(e.group.element),s=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}moveToPrevious(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=ee(e.group.element),s=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}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 ue{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 me{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 ve{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 ge{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 _e extends l{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(v(this.element,"dragenter",e=>{this.onDragEnter(e)},!0)),this.addDisposables(v(this.element,"dragover",e=>{this.onDragOver(e)},!0)),this.addDisposables(v(this.element,"dragleave",e=>{this.onDragLeave(e)})),this.addDisposables(v(this.element,"dragend",e=>{this.onDragEnd(e)})),this.addDisposables(v(this.element,"drop",e=>{this.onDrop(e)}))}}const fe={value:50,type:"percentage"};function be(){const e=document.createElement("div");e.className="dv-drop-target-dropzone";const t=document.createElement("div");return t.className="dv-drop-target-selection",e.appendChild(t),{dropzone:e,selection:t}}function we(e,t,i,s){var o,n,r;const a=t<(null!==(o=null==s?void 0:s.smallWidthBoundary)&&void 0!==o?o:100),l=i<(null!==(n=null==s?void 0:s.smallHeightBoundary)&&void 0!==n?n:100),h="left"===e,d="right"===e,p="top"===e,c="bottom"===e,u=!a&&d,m=!a&&h,v=!l&&p,g=!l&&c;let _=1;const f=null!==(r=null==s?void 0:s.size)&&void 0!==r?r:fe;return"percentage"===f.type?_=L(f.value,0,100)/100:((u||m)&&(_=L(0,f.value,t)/t),(v||g)&&(_=L(0,f.value,i)/i)),{isSmallX:a,isSmallY:l,isLeft:h,isRight:d,isTop:p,isBottom:c,rightClass:u,leftClass:m,topClass:v,bottomClass:g,size:_}}function De(e,t,i,s,o){const n=we(t,i,s,o),{rightClass:r,leftClass:a,topClass:l,bottomClass:h,size:d}=n,p={top:"0px",left:"0px",width:"100%",height:"100%"};r?(p.left=100*(1-d)+"%",p.width=100*d+"%"):a?p.width=100*d+"%":l?p.height=100*d+"%":h&&(p.top=100*(1-d)+"%",p.height=100*d+"%"),n.isSmallX&&n.isLeft&&(p.width="4px"),n.isSmallX&&n.isRight&&(p.left=i-4+"px",p.width="4px"),n.isSmallY&&n.isTop&&(p.height="4px"),n.isSmallY&&n.isBottom&&(p.top=s-4+"px",p.height="4px"),e.style.top=p.top,e.style.left=p.left,e.style.width=p.width,e.style.height=p.height,e.style.visibility="visible",e.style.transform&&""!==e.style.transform||(e.style.transform="translate3d(0, 0, 0)");const c=n.isSmallX&&(n.isLeft||n.isRight)||n.isSmallY&&(n.isTop||n.isBottom);D(e,"dv-drop-target-small-vertical",n.isSmallY),D(e,"dv-drop-target-small-horizontal",n.isSmallX),D(e,"dv-drop-target-selection-line",c),D(e,"dv-drop-target-left",n.isLeft),D(e,"dv-drop-target-right",n.isRight),D(e,"dv-drop-target-top",n.isTop),D(e,"dv-drop-target-bottom",n.isBottom),D(e,"dv-drop-target-center","center"===t)}function Ce(e){const t=we(e.quadrant,e.width,e.height,e.overlayModel),{rightClass:i,leftClass:s,topClass:o,bottomClass:n,size:r}=t,a=e.outlineElement.getBoundingClientRect(),l=e.targetModel.getElements(void 0,e.outlineElement),h=l.root,d=l.overlay,p=h.getBoundingClientRect(),c=a.top-p.top,u=a.left-p.left,m={top:c,left:u,width:e.width,height:e.height};return i?(m.left=u+e.width*(1-r),m.width=e.width*r):s?m.width=e.width*r:o?m.height=e.height*r:n&&(m.top=c+e.height*(1-r),m.height=e.height*r),t.isSmallX&&t.isLeft&&(m.width=4),t.isSmallX&&t.isRight&&(m.left=u+e.width-4,m.width=4),t.isSmallY&&t.isTop&&(m.height=4),t.isSmallY&&t.isBottom&&(m.top=c+e.height-4,m.height=4),function(e,t){const i=`${Math.round(t.top)}px`,s=`${Math.round(t.left)}px`,o=`${Math.round(t.width)}px`,n=`${Math.round(t.height)}px`;return e.style.top!==i||e.style.left!==s||e.style.width!==o||e.style.height!==n}(d,m)?(function(e,t){e.style.top=`${Math.round(t.top)}px`,e.style.left=`${Math.round(t.left)}px`,e.style.width=`${Math.round(t.width)}px`,e.style.height=`${Math.round(t.height)}px`,e.style.visibility="visible",e.style.transform&&""!==e.style.transform||(e.style.transform="translate3d(0, 0, 0)")}(d,m),d.className="dv-drop-target-anchor"+(e.className?` ${e.className}`:""),D(d,"dv-drop-target-left",t.isLeft),D(d,"dv-drop-target-right",t.isRight),D(d,"dv-drop-target-top",t.isTop),D(d,"dv-drop-target-bottom",t.isBottom),D(d,"dv-drop-target-anchor-line",t.isSmallX&&(t.isLeft||t.isRight)||t.isSmallY&&(t.isTop||t.isBottom)),D(d,"dv-drop-target-center","center"===e.quadrant),l.changed&&(D(d,"dv-drop-target-anchor-container-changed",!0),setTimeout(()=>{D(d,"dv-drop-target-anchor-container-changed",!1)},10)),{boundsChanged:!0,targetChanged:l.changed}):{boundsChanged:!1,targetChanged:l.changed}}class ye extends d{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}constructor(e){super(),this.options=e}}function Se(e){switch(e){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 '${e}'`)}}function xe(e){switch(e){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 '${e}'`)}}const Ge={value:20,type:"percentage"};class Pe extends l{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 m,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new m,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(this.options.acceptedTargetZones),this.dnd=new _e(this.element,{onDragEnter:()=>{var e,t,i;null===(i=null===(t=(e=this.options).getOverrideTarget)||void 0===t?void 0:t.call(e))||void 0===i||i.getElements()},onDragOver:e=>{var t,i,s,o,n,r,a;Pe.ACTUAL_TARGET=this;const l=null===(i=(t=this.options).getOverrideTarget)||void 0===i?void 0:i.call(t);if(0===this._acceptedTargetZonesSet.size){if(l)return;return void this.removeDropTarget()}const h=null!==(n=null===(o=(s=this.options).getOverlayOutline)||void 0===o?void 0:o.call(s))&&void 0!==n?n:this.element,d=h.offsetWidth,p=h.offsetHeight;if(0===d||0===p)return;const c=e.currentTarget.getBoundingClientRect(),u=(null!==(r=e.clientX)&&void 0!==r?r:0)-c.left,m=(null!==(a=e.clientY)&&void 0!==a?a:0)-c.top,v=this.calculateQuadrant(this._acceptedTargetZonesSet,u,m,d,p);if(this.isAlreadyUsed(e)||null===v)return void this.removeDropTarget();if(!this.options.canDisplayOverlay(e,v)){if(l)return;return void this.removeDropTarget()}const g=new ye({nativeEvent:e,position:v});if(this._onWillShowOverlay.fire(g),g.defaultPrevented)this.removeDropTarget();else{if(this.markAsUsed(e),l);else if(!this.targetElement){const e=be();this.targetElement=e.dropzone,this.overlayElement=e.selection,this._state="center",h.classList.add("dv-drop-target"),h.append(this.targetElement)}this.toggleClasses(v,d,p),this._state=v}},onDragLeave:()=>{var e,t;(null===(t=(e=this.options).getOverrideTarget)||void 0===t?void 0:t.call(e))||this.removeDropTarget()},onDragEnd:e=>{var t,i;const s=null===(i=(t=this.options).getOverrideTarget)||void 0===i?void 0:i.call(t);s&&Pe.ACTUAL_TARGET===this&&this._state&&(e.stopPropagation(),this._onDrop.fire({position:this._state,nativeEvent:e})),this.removeDropTarget(),null==s||s.clear()},onDrop:e=>{var t,i,s;e.preventDefault();const o=this._state;this.removeDropTarget(),null===(s=null===(i=(t=this.options).getOverrideTarget)||void 0===i?void 0:i.call(t))||void 0===s||s.clear(),o&&(e.stopPropagation(),this._onDrop.fire({position:o,nativeEvent:e}))}}),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[Pe.USED_EVENT_ID]=!0}isAlreadyUsed(e){const t=e[Pe.USED_EVENT_ID];return"boolean"==typeof t&&t}toggleClasses(e,t,i){var s,o,n,r,a;const l=null===(o=(s=this.options).getOverrideTarget)||void 0===o?void 0:o.call(s);if(l){return void Ce({outlineElement:null!==(a=null===(r=(n=this.options).getOverlayOutline)||void 0===r?void 0:r.call(n))&&void 0!==a?a:this.element,targetModel:l,quadrant:e,width:t,height:i,overlayModel:this.options.overlayModel,className:this.options.className})}this.overlayElement&&De(this.overlayElement,e,t,i,this.options.overlayModel)}calculateQuadrant(e,t,i,s,o){var n,r;const a=null!==(r=null===(n=this.options.overlayModel)||void 0===n?void 0:n.activationSize)&&void 0!==r?r:Ge;return"percentage"===a.type?Te(e,t,i,s,o,a.value):Ie(e,t,i,s,o,a.value)}removeDropTarget(){var e;this.targetElement&&(this._state=void 0,null===(e=this.targetElement.parentElement)||void 0===e||e.classList.remove("dv-drop-target"),this.targetElement.remove(),this.targetElement=void 0,this.overlayElement=void 0)}}function Te(e,t,i,s,o,n){const r=100*t/s,a=100*i/o;return e.has("left")&&r<n?"left":e.has("right")&&r>100-n?"right":e.has("top")&&a<n?"top":e.has("bottom")&&a>100-n?"bottom":e.has("center")?"center":null}function Ie(e,t,i,s,o,n){return e.has("left")&&t<n?"left":e.has("right")&&t>s-n?"right":e.has("top")&&i<n?"top":e.has("bottom")&&i>o-n?"bottom":e.has("center")?"center":null}Pe.USED_EVENT_ID="__dockview_droptarget_event_is_used__";class ze extends l{static getInstance(){return ze._instance||(ze._instance=new ze),ze._instance}constructor(){super(),this._targets=new Set,this._targetByElement=new Map,this._onDragStart=new m,this.onDragStart=this._onDragStart.event,this._onDragMove=new m,this.onDragMove=this._onDragMove.event,this._onDragEnd=new m,this.onDragEnd=this._onDragEnd.event,this.addDisposables(this._onDragStart,this._onDragMove,this._onDragEnd)}get active(){return this._active}registerTarget(e){return this._targets.add(e),this._targetByElement.set(e.element,e),{dispose:()=>{this._targets.delete(e),this._targetByElement.get(e.element)===e&&this._targetByElement.delete(e.element),this._currentTarget===e&&(this._currentTarget=void 0)}}}beginDrag(e){var t,i,s;this._active&&this.cancel();const{pointerEvent:o,source:n}=e,r=e.getData();this._active={pointerId:o.pointerId,startX:o.clientX,startY:o.clientY,source:n},this._onDragMoveCallback=e.onDragMove,this._onDragEndCallback=e.onDragEnd,this._dataDisposable=r,this._ghost=e.ghost,this._iframeShield=T(null!==(t=n.ownerDocument)&&void 0!==t?t:document);const a={clientX:o.clientX,clientY:o.clientY,pointerEvent:o};this._onDragStart.fire(a);const l=null!==(s=null===(i=n.ownerDocument)||void 0===i?void 0:i.defaultView)&&void 0!==s?s:window;this._moveListener=v(l,"pointermove",e=>{this._active&&e.pointerId===this._active.pointerId&&this._handleMove(e)}),this._upListener=v(l,"pointerup",e=>{this._active&&e.pointerId===this._active.pointerId&&this._handleEnd(e,!0)}),this._cancelListener=v(l,"pointercancel",e=>{this._active&&e.pointerId===this._active.pointerId&&this._handleEnd(e,!1)})}cancel(){var e,t;this._active&&(null===(e=this._currentTarget)||void 0===e||e.handleDragLeave(),this._teardown(),null===(t=this._dataDisposable)||void 0===t||t.dispose(),this._dataDisposable=void 0)}_findTargetUnder(e,t){var i,s;const o=(null!==(s=null===(i=this._active)||void 0===i?void 0:i.source.ownerDocument)&&void 0!==s?s:document).elementsFromPoint(e,t);for(const e of o){let t=e;for(;t;){const e=this._targetByElement.get(t);if(e)return e;t=t.parentElement}}}_handleMove(e){var t,i,s;null===(t=this._ghost)||void 0===t||t.update(e.clientX,e.clientY);const o={clientX:e.clientX,clientY:e.clientY,pointerEvent:e},n=this._findTargetUnder(e.clientX,e.clientY);n!==this._currentTarget&&(null===(i=this._currentTarget)||void 0===i||i.handleDragLeave(),this._currentTarget=n),n&&n.handleDragOver(o),null===(s=this._onDragMoveCallback)||void 0===s||s.call(this,o),this._onDragMove.fire(o)}_handleEnd(e,t){var i;const s={clientX:e.clientX,clientY:e.clientY,pointerEvent:e};t&&this._currentTarget?this._currentTarget.handleDrop(s):null===(i=this._currentTarget)||void 0===i||i.handleDragLeave();const o=this._onDragEndCallback,n=this._dataDisposable;this._teardown(),this._dataDisposable=void 0,setTimeout(()=>null==n?void 0:n.dispose(),0),null==o||o(s,t),this._onDragEnd.fire(s)}_teardown(){var e,t,i,s,o;this._currentTarget=void 0,this._active=void 0,this._onDragMoveCallback=void 0,this._onDragEndCallback=void 0,null===(e=this._ghost)||void 0===e||e.dispose(),this._ghost=void 0,null===(t=this._iframeShield)||void 0===t||t.release(),this._iframeShield=void 0,null===(i=this._moveListener)||void 0===i||i.dispose(),null===(s=this._upListener)||void 0===s||s.dispose(),null===(o=this._cancelListener)||void 0===o||o.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}}const Ae={value:20,type:"percentage"};class Ee extends l{get disabled(){return this._disabled}set disabled(e){this._disabled=e,e&&this._removeOverlay()}get state(){return this._state}constructor(e,t){super(),this.element=e,this.options=t,this._onDrop=new m,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new m,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(t.acceptedTargetZones);const i={element:this.element,handleDragOver:e=>this._onDragOver(e),handleDragLeave:()=>this._onDragLeave(),handleDrop:e=>this._onDropEvent(e)};this.addDisposables(this._onDrop,this._onWillShowOverlay,ze.getInstance().registerTarget(i))}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this._removeOverlay(),super.dispose()}_onDragOver(e){var t,i,s,o,n;if(this._disabled)return void this._removeOverlay();const r=null===(i=(t=this.options).getOverrideTarget)||void 0===i?void 0:i.call(t);if(0===this._acceptedTargetZonesSet.size){if(r)return;return void this._removeOverlay()}const a=null!==(n=null===(o=(s=this.options).getOverlayOutline)||void 0===o?void 0:o.call(s))&&void 0!==n?n:this.element,l=a.offsetWidth,h=a.offsetHeight;if(0===l||0===h)return;const d=a.getBoundingClientRect(),p=e.clientX-d.left,c=e.clientY-d.top,u=this._calculateQuadrant(p,c,l,h);if(null===u)return void this._removeOverlay();if(!this.options.canDisplayOverlay(e.pointerEvent,u)){if(r)return;return void this._removeOverlay()}const m=new ye({nativeEvent:e.pointerEvent,position:u});if(this._onWillShowOverlay.fire(m),m.defaultPrevented)this._removeOverlay();else{if(r)return Ce({outlineElement:a,targetModel:r,quadrant:u,width:l,height:h,overlayModel:this.options.overlayModel,className:this.options.className}),void(this._state=u);if(!this._targetElement){const e=be();this._targetElement=e.dropzone,this._overlayElement=e.selection,this._state="center",this.element.classList.add("dv-drop-target"),this.element.append(this._targetElement)}this._overlayElement&&De(this._overlayElement,u,l,h,this.options.overlayModel),this._state=u}}_onDragLeave(){var e,t;const i=null===(t=(e=this.options).getOverrideTarget)||void 0===t?void 0:t.call(e);if(i)return this._state=void 0,void i.clear();this._removeOverlay()}_onDropEvent(e){var t,i;const s=this._state,o=null===(i=(t=this.options).getOverrideTarget)||void 0===i?void 0:i.call(t);this._removeOverlay(),null==o||o.clear(),s&&this._onDrop.fire({position:s,nativeEvent:e.pointerEvent})}_calculateQuadrant(e,t,i,s){var o,n;const r=null!==(n=null===(o=this.options.overlayModel)||void 0===o?void 0:o.activationSize)&&void 0!==n?n:Ae;return"percentage"===r.type?Te(this._acceptedTargetZonesSet,e,t,i,s,r.value):Ie(this._acceptedTargetZonesSet,e,t,i,s,r.value)}_removeOverlay(){var e;this._targetElement?(this._state=void 0,null===(e=this._targetElement.parentElement)||void 0===e||e.classList.remove("dv-drop-target"),this._targetElement.remove(),this._targetElement=void 0,this._overlayElement=void 0):this._state=void 0}}class Oe extends l{constructor(e,t){var i;super(),this.element=e,this.options=t,this._disabled=!1,this._armed=!1,this._startX=0,this._startY=0,this._touchOnly=null===(i=t.touchOnly)||void 0===i||i,this.addDisposables(v(this.element,"pointerdown",e=>{this._onPointerDown(e)}))}setDisabled(e){this._disabled=e,e&&this._cancelPending()}setTouchOnly(e){this._touchOnly!==e&&(this._touchOnly=e,e&&this._cancelPending())}_shouldHandle(e){var t,i;return!this._disabled&&((!this._touchOnly||"touch"===e.pointerType||"pen"===e.pointerType)&&!(null===(i=(t=this.options).isCancelled)||void 0===i?void 0:i.call(t,e)))}_onPointerDown(e){var t,i,s,o,n;if(!this._shouldHandle(e))return;this._cancelPending(),this._pendingPointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY,this._startEvent=e;const r="touch"===e.pointerType||"pen"===e.pointerType,a=this.options.touchInitiationDelay,l=null!==(t="function"==typeof a?a():a)&&void 0!==t?t:250;this._armed=!r||l<=0,r&&l>0&&isFinite(l)&&(this._armTimer=setTimeout(()=>{this._armTimer=void 0,this._armed=!0},l));const h=null!==(i=this.options.threshold)&&void 0!==i?i:5,d=this.options.pressTolerance,p=null!==(s="function"==typeof d?d():d)&&void 0!==s?s:8,c=null!==(n=null===(o=this.element.ownerDocument)||void 0===o?void 0:o.defaultView)&&void 0!==n?n:window;this._pendingMoveListener=v(c,"pointermove",e=>{if(e.pointerId!==this._pendingPointerId)return;const t=e.clientX-this._startX,i=e.clientY-this._startY,s=Math.hypot(t,i);this._armed?s>=h&&this._beginDrag(e):s>p&&this._beginDrag(e)}),this._pendingUpListener=v(c,"pointerup",e=>{e.pointerId===this._pendingPointerId&&this._cancelPending()}),this._pendingCancelListener=v(c,"pointercancel",e=>{e.pointerId===this._pendingPointerId&&this._cancelPending()})}cancelPending(){this._cancelPending()}_cancelPending(){var e,t,i;this._pendingPointerId=void 0,void 0!==this._armTimer&&(clearTimeout(this._armTimer),this._armTimer=void 0),this._armed=!1,null===(e=this._pendingMoveListener)||void 0===e||e.dispose(),null===(t=this._pendingUpListener)||void 0===t||t.dispose(),null===(i=this._pendingCancelListener)||void 0===i||i.dispose(),this._pendingMoveListener=void 0,this._pendingUpListener=void 0,this._pendingCancelListener=void 0,this._startEvent=void 0}_beginDrag(e){var t,i,s,o,n;const r=null!==(t=this._startEvent)&&void 0!==t?t:e;this._cancelPending(),null===(s=(i=this.options).onDragStart)||void 0===s||s.call(i,r);const a=null===(n=(o=this.options).createGhost)||void 0===n?void 0:n.call(o,r);ze.getInstance().beginDrag({pointerEvent:e,source:this.element,getData:()=>this.options.getData(r),ghost:a,onDragMove:this.options.onDragMove,onDragEnd:this.options.onDragEnd})}dispose(){this._cancelPending(),super.dispose()}}class Me{constructor(e){var t,i,s,o,n;this._disposed=!1,this.element=e.element,this.offsetX=null!==(t=e.offsetX)&&void 0!==t?t:0,this.offsetY=null!==(i=e.offsetY)&&void 0!==i?i:0,this.element.style.position="fixed",this.element.style.left="0px",this.element.style.top="0px",this.element.style.pointerEvents="none",this.element.style.zIndex="99999",this.element.style.opacity=String(null!==(s=e.opacity)&&void 0!==s?s:.8),this.element.style.willChange="transform",this.element.style.transform=`translate3d(${e.initialX-this.offsetX}px, ${e.initialY-this.offsetY}px, 0)`;(null!==(n=null===(o=e.owner)||void 0===o?void 0:o.ownerDocument)&&void 0!==n?n:document).body.appendChild(this.element)}update(e,t){this._disposed||(this.element.style.transform=`translate3d(${e-this.offsetX}px, ${t-this.offsetY}px, 0)`)}dispose(){this._disposed||(this._disposed=!0,this.element.remove())}}class ke extends l{constructor(e,t){super(),this.el=e,this.opts=t,this._dataDisposable=new h,this._pointerEventsDisposable=new h,this._disabled=!!t.disabled,this.addDisposables(this._dataDisposable,this._pointerEventsDisposable,v(this.el,"dragstart",e=>{var t,i,s,o,n,r,a,l,h;if(e.defaultPrevented||this._disabled||(null===(i=(t=this.opts).isCancelled)||void 0===i?void 0:i.call(t,e)))return void e.preventDefault();const d=T(null!==(s=this.el.ownerDocument)&&void 0!==s?s:document);this._pointerEventsDisposable.value={dispose:()=>d.release()},this.el.classList.add("dv-dragged"),setTimeout(()=>this.el.classList.remove("dv-dragged"),0),this._dataDisposable.value=this.opts.getData(e);const p=null===(n=(o=this.opts).createGhost)||void 0===n?void 0:n.call(o,e);if(p&&e.dataTransfer&&(function(e,t,i){var s,o;w(t,"dv-dragged"),t.style.top="-9999px",document.body.appendChild(t),e.setDragImage(t,null!==(s=null==i?void 0:i.x)&&void 0!==s?s:0,null!==(o=null==i?void 0:i.y)&&void 0!==o?o:0),setTimeout(()=>{b(t,"dv-dragged"),t.remove()},0)}(e.dataTransfer,p.element,{x:null!==(r=p.offsetX)&&void 0!==r?r:0,y:null!==(a=p.offsetY)&&void 0!==a?a:0}),p.dispose)){const e=p.dispose;setTimeout(()=>e(),0)}e.dataTransfer&&(e.dataTransfer.effectAllowed="move",0===e.dataTransfer.items.length&&e.dataTransfer.setData("text/plain","")),null===(h=(l=this.opts).onDragStart)||void 0===h||h.call(l,e)}),v(this.el,"dragend",e=>{var t,i;this._pointerEventsDisposable.dispose(),setTimeout(()=>this._dataDisposable.dispose(),0),null===(i=(t=this.opts).onDragEnd)||void 0===i||i.call(t,e)}))}setDisabled(e){this._disabled=e}setTouchOnly(e){}cancelPending(){}}const Ve=new class{constructor(){this.kind="html5"}createDropTarget(e,t){return new Pe(e,t)}createDragSource(e,t){return new ke(e,t)}},Le=new class{constructor(){this.kind="pointer"}createDropTarget(e,t){return new Ee(e,t)}createDragSource(e,t){const i=t.createGhost?i=>{const s=t.createGhost(i);if(!s)return;const o=new Me({element:s.element,initialX:i.clientX,initialY:i.clientY,offsetX:s.offsetX,offsetY:s.offsetY,owner:e});if(s.dispose){const e=o.dispose.bind(o),t=s.dispose;o.dispose=()=>{e(),t()}}return o}:void 0,s=new Oe(e,{getData:t.getData,isCancelled:t.isCancelled,onDragStart:t.onDragStart,onDragEnd:t.onDragEnd?e=>t.onDragEnd(e.pointerEvent):void 0,createGhost:i,touchOnly:t.touchOnly,touchInitiationDelay:t.touchInitiationDelay,pressTolerance:t.pressTolerance,threshold:t.threshold});return t.disabled&&s.setDisabled(!0),s}},Ne=(()=>{const e={disableAutoResizing:void 0,disableDnd:void 0,className:void 0};return Object.keys(e)})();class Re extends p{constructor(e,t,i,s){super(),this.nativeEvent=e,this.position=t,this.getData=i,this.panel=s}}class We extends d{constructor(){super()}}class He extends l{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 h,this._onDidDimensionChange=new m,this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new m,this.onDidFocusChange=this._onDidChangeFocus.event,this._onWillFocus=new m,this.onWillFocus=this._onWillFocus.event,this._onDidVisibilityChange=new m,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onWillVisibilityChange=new m,this.onWillVisibilityChange=this._onWillVisibilityChange.event,this._onDidActiveChange=new m,this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new m,this.onActiveChange=this._onActiveChange.event,this._onDidParametersChange=new m,this.onDidParametersChange=this._onDidParametersChange.event,this.addDisposables(this.onDidFocusChange(e=>{this._isFocused=e.isFocused}),this.onDidActiveChange(e=>{this._isActive=e.isActive}),this.onDidVisibilityChange(e=>{this._isVisible=e.isVisible}),this.onDidDimensionsChange(e=>{this._width=e.width,this._height=e.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 Fe extends He{constructor(e,t){super(e,t),this._onDidConstraintsChangeInternal=new m,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new m({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new m,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 Be extends Fe{set pane(e){this._pane=e}constructor(e,t){super(e,t),this._onDidExpansionChange=new m({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new m({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new m({}),this.onMouseLeave=this._onMouseLeave.event,this.addDisposables(this._onDidExpansionChange,this._onMouseEnter,this._onMouseLeave)}setExpanded(e){var t;null===(t=this._pane)||void 0===t||t.setExpanded(e)}get isExpanded(){var e;return!!(null===(e=this._pane)||void 0===e?void 0:e.isExpanded())}}class $e extends l{get element(){return this._element}get width(){return this._width}get height(){return this._height}get params(){var e;return null===(e=this._params)||void 0===e?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 s=y(this._element);this.addDisposables(this.api,s.onDidFocus(()=>{this.api._onDidChangeFocus.fire({isFocused:!0})}),s.onDidBlur(()=>{this.api._onDidChangeFocus.fire({isFocused:!1})}),s)}focus(){const e=new We;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({},null===(t=this._params)||void 0===t?void 0:t.params),e.params)});for(const t of Object.keys(e.params))void 0===e.params[t]&&delete this._params.params[t];null===(i=this.part)||void 0===i||i.update({params:this._params.params})}toJSON(){var e,t;const i=null!==(t=null===(e=this._params)||void 0===e?void 0:e.params)&&void 0!==t?t:{};return{id:this.id,component:this.component,params:Object.keys(i).length>0?i:void 0}}dispose(){var e;this.api.dispose(),null===(e=this.part)||void 0===e||e.dispose(),super.dispose()}}class Ue extends $e{set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){return this.headerSize+(this.isExpanded()?this._minimumBodySize:0)}get maximumSize(){return this.headerSize+(this.isExpanded()?this._maximumBodySize:0)}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="number"==typeof e?e:0}get maximumBodySize(){return this._maximumBodySize}set maximumBodySize(e){this._maximumBodySize="number"==typeof e?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 Be(e.id,e.component)),this._onDidChangeExpansionState=new m({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new m,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(e=>{const{isVisible:t}=e,{accessor:i}=this._params;i.setVisible(this,t)}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({size:e.size})}),v(this.element,"mouseenter",e=>{this.api._onMouseEnter.fire(e)}),v(this.element,"mouseleave",e=>{this.api._onMouseLeave.fire(e)})),this.addDisposables(this._onDidChangeExpansionState,this.onDidChangeExpansionState(e=>{this.api._onDidExpansionChange.fire({isExpanded:e})}),this.api.onDidFocusChange(e=>{this.header&&(e.isFocused?w(this.header,"focused"):b(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 e;null===(e=this.body)||void 0===e||e.remove()},200),this._onDidChange.fire(e?{size:this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(t,i){this._size=t,this._orthogonalSize=i;const[s,o]=this.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];super.layout(s,o)}init(e){var t,i;super.init(e),"number"==typeof e.minimumBodySize&&(this.minimumBodySize=e.minimumBodySize),"number"==typeof e.maximumBodySize&&(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})),null===(t=this.body)||void 0===t||t.append(this.bodyPart.element),null===(i=this.header)||void 0===i||i.append(this.headerPart.element),"boolean"==typeof e.isExpanded&&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;null===(t=this.bodyPart)||void 0===t||t.update({params:e}),null===(i=this.headerPart)||void 0===i||i.update({params:e})},dispose:()=>{var e,t;null===(e=this.bodyPart)||void 0===e||e.dispose(),null===(t=this.headerPart)||void 0===t||t.dispose()}}}}class Ye extends Ue{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 m,this.onDidDrop=this._onDidDrop.event,this._onUnhandledDragOverEvent=new m,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;const i={getData:()=>(o.getInstance().setData([new s(t,e)],s.prototype),{dispose:()=>{o.getInstance().clearData(s.prototype)}})};this.html5DragSource=Ve.createDragSource(this.header,i),this.pointerDragSource=Le.createDragSource(this.header,i);const n={acceptedTargetZones:["top","bottom"],overlayModel:{activationSize:{type:"percentage",value:50}},canDisplayOverlay:(e,t)=>{const i=r();if(i&&i.paneId!==this.id&&i.viewId===this.accessor.id)return!0;const s=new Re(e,t,r,this);return this._onUnhandledDragOverEvent.fire(s),s.isAccepted}};this.target=Ve.createDropTarget(this.element,n),this.pointerTarget=Le.createDropTarget(this.element,n),this.addDisposables(this._onDidDrop,this.html5DragSource,this.pointerDragSource,this.target,this.pointerTarget,this.target.onDrop(e=>{this.onDrop(e)}),this.pointerTarget.onDrop(e=>{this.onDrop(e)}))}onDrop(e){const t=r();if(!t||t.viewId!==this.accessor.id)return void this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,api:new me(this.accessor),getData:r}));const i=this._params.containerApi,s=t.paneId,o=i.getPanel(s);if(!o)return void this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,getData:r,api:new me(this.accessor)}));const n=i.panels,a=n.indexOf(o);let l=i.panels.indexOf(this);"left"!==e.position&&"top"!==e.position||(l=Math.max(0,l-1)),"right"!==e.position&&"bottom"!==e.position||(a>l&&l++,l=Math.min(n.length-1,l)),i.movePanel(a,l)}}class Xe extends l{get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this.disposable=new h,this._onDidFocus=new m,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new m,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,s=(e,t)=>{if("no-drop-target"===this.group.locked||this.group.locked&&"center"===t)return!1;const i=n();return!(!i&&e.shiftKey&&"floating"!==this.group.location.type)&&(!(!i||i.viewId!==this.accessor.id)||this.group.canDisplayOverlay(e,t,"content"))};this.dropTarget=new Pe(this.element,{getOverlayOutline:()=>{var t;return"group"===(null===(t=e.options.theme)||void 0===t?void 0:t.dndPanelOverlay)?this.element.parentElement:null},className:"dv-drop-target-content",acceptedTargetZones:["top","bottom","left","right","center"],canDisplayOverlay:s,getOverrideTarget:i?()=>i.model:void 0}),this.pointerDropTarget=Le.createDropTarget(this.element,{acceptedTargetZones:["top","bottom","left","right","center"],canDisplayOverlay:s,getOverlayOutline:()=>{var t;return"group"===(null===(t=e.options.theme)||void 0===t?void 0:t.dndPanelOverlay)?this.element.parentElement:null},className:"dv-drop-target-content",getOverrideTarget:i?()=>i.model:void 0}),this.addDisposables(this.dropTarget,this.pointerDropTarget)}show(){this.element.style.display=""}hide(){this.element.style.display="none"}renderPanel(e,t={asActive:!0}){var i,s,o,n;const r=t.asActive||this.panel&&this.group.isPanelActive(this.panel);let a;switch(this.panel&&this.panel.view.content.element.parentElement===this._element&&(this._element.removeChild(this.panel.view.content.element),null===(s=(i=this.panel.view.content).onHide)||void 0===s||s.call(i)),this.panel=e,e.api.renderer){case"onlyWhenVisible":this.group.renderContainer.detatch(e),this.panel&&r&&(this._element.appendChild(this.panel.view.content.element),null===(n=(o=this.panel.view.content).onShow)||void 0===n||n.call(o)),a=this._element;break;case"always":e.view.content.element.parentElement===this._element&&this._element.removeChild(e.view.content.element),a=this.group.renderContainer.attach({panel:e,referenceContainer:this});break;default:throw new Error(`dockview: invalid renderer type '${e.api.renderer}'`)}if(r){const e=y(a);this.focusTracker=e;const t=new l;t.addDisposables(e,e.onDidFocus(()=>this._onDidFocus.fire()),e.onDidBlur(()=>this._onDidBlur.fire())),this.disposable.value=t}}openPanel(e){this.panel!==e&&this.renderPanel(e)}layout(e,t){}closePanel(){var e,t,i;this.panel&&"onlyWhenVisible"===this.panel.api.renderer&&(null===(e=this.panel.view.content.element.parentElement)||void 0===e||e.removeChild(this.panel.view.content.element),null===(i=(t=this.panel.view.content).onHide)||void 0===i||i.call(t)),this.panel=void 0}dispose(){this.disposable.dispose(),super.dispose()}refreshFocusState(){var e;(null===(e=this.focusTracker)||void 0===e?void 0:e.refreshState)&&this.focusTracker.refreshState()}}class Je extends l{constructor(e,t){super(),this.element=e,this.options=t,this._startX=0,this._startY=0,this.addDisposables(v(this.element,"pointerdown",e=>{this._onPointerDown(e)}))}_onPointerDown(e){var t,i,s,o,n;if((null===(t=this.options.touchOnly)||void 0===t||t)&&"touch"!==e.pointerType&&"pen"!==e.pointerType)return;this._cancelPending(),this._pointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY;const r=null!==(i=this.options.delay)&&void 0!==i?i:500,a=null!==(s=this.options.tolerance)&&void 0!==s?s:8,l=null!==(n=null===(o=this.element.ownerDocument)||void 0===o?void 0:o.defaultView)&&void 0!==n?n:window;this._timer=setTimeout(()=>{this._timer=void 0,this._cancelPending(),this._installContextMenuGuard(l),this._installClickGuard(l),this.options.onLongPress(e)},r),this._moveListener=v(l,"pointermove",e=>{if(e.pointerId!==this._pointerId)return;const t=e.clientX-this._startX,i=e.clientY-this._startY;Math.hypot(t,i)>a&&this._cancelPending()}),this._upListener=v(l,"pointerup",e=>{e.pointerId===this._pointerId&&this._cancelPending()}),this._cancelListener=v(l,"pointercancel",e=>{e.pointerId===this._pointerId&&this._cancelPending()})}_installContextMenuGuard(e){let t;const i=setTimeout(()=>null==t?void 0:t.dispose(),500);t=v(e,"contextmenu",e=>{e.preventDefault(),clearTimeout(i),null==t||t.dispose()},{capture:!0})}_installClickGuard(e){let t;const i=setTimeout(()=>null==t?void 0:t.dispose(),500);t=v(e,"click",e=>{const s=e.target;s&&this.element.contains(s)&&(e.preventDefault(),e.stopPropagation()),clearTimeout(i),null==t||t.dispose()},{capture:!0})}_cancelPending(){var e,t,i;void 0!==this._timer&&(clearTimeout(this._timer),this._timer=void 0),this._pointerId=void 0,null===(e=this._moveListener)||void 0===e||e.dispose(),null===(t=this._upListener)||void 0===t||t.dispose(),null===(i=this._cancelListener)||void 0===i||i.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}dispose(){this._cancelPending(),super.dispose()}}function je(e){if(e.disableDnd)return{html5:!1,pointer:!1,pointerHandlesMouse:!1};switch(e.dndStrategy){case"pointer":return{html5:!1,pointer:!0,pointerHandlesMouse:!0};case"html5":return{html5:!0,pointer:!1,pointerHandlesMouse:!1};default:return function(){if("undefined"==typeof window||!window.matchMedia)return!1;const e=window.matchMedia("(pointer: coarse)").matches,t=window.matchMedia("(pointer: fine)").matches;return e&&!t}()?{html5:!1,pointer:!0,pointerHandlesMouse:!0}:{html5:!0,pointer:!0,pointerHandlesMouse:!1}}}class Ze extends l{get element(){return this._element}constructor(t,s,r){super(),this.panel=t,this.accessor=s,this.group=r,this.content=void 0,this.panelTransfer=o.getInstance(),this._direction="horizontal",this._onPointDown=new m,this.onPointerDown=this._onPointDown.event,this._onTabClick=new m,this.onTabClick=this._onTabClick.event,this._onDropped=new m,this.onDrop=this._onDropped.event,this._onDragStart=new m,this.onDragStart=this._onDragStart.event,this._onDragEnd=new m,this.onDragEnd=this._onDragEnd.event;const a=je(this.accessor.options);this._element=document.createElement("div"),this._element.className="dv-tab",this._element.tabIndex=0,this._element.draggable=a.html5,D(this.element,"dv-inactive-tab",!0);const l=(e,t)=>{var i;if(this.group.locked)return!1;const s=n();return s&&this.accessor.id===s.viewId?"smooth"!==(null===(i=this.accessor.options.theme)||void 0===i?void 0:i.tabAnimation):this.group.model.canDisplayOverlay(e,t,"tab")};this.dropTarget=Ve.createDropTarget(this._element,{acceptedTargetZones:["left","right"],overlayModel:this._buildOverlayModel(),canDisplayOverlay:l,getOverrideTarget:()=>{var e;return null===(e=r.model.dropTargetContainer)||void 0===e?void 0:e.model}}),this.pointerDropTarget=Le.createDropTarget(this._element,{acceptedTargetZones:["left","right"],overlayModel:this._buildOverlayModel(),canDisplayOverlay:l,getOverrideTarget:()=>{var e;return null===(e=r.model.dropTargetContainer)||void 0===e?void 0:e.model}});const h={getData:()=>(this.panelTransfer.setData([new i(this.accessor.id,this.group.id,this.panel.id)],i.prototype),{dispose:()=>{this.panelTransfer.clearData(i.prototype)}}),createGhost:()=>({element:this._buildGhostElement(),offsetX:30,offsetY:-10}),onDragStart:e=>{var t;this._onDragStart.fire(e),e instanceof PointerEvent||"smooth"!==(null===(t=this.accessor.options.theme)||void 0===t?void 0:t.tabAnimation)||requestAnimationFrame(()=>{D(this.element,"dv-tab--dragging",!0)})},onDragEnd:e=>{this._onDragEnd.fire(e)}};this.html5DragSource=Ve.createDragSource(this._element,Object.assign(Object.assign({},h),{disabled:!a.html5})),this.pointerDragSource=Le.createDragSource(this._element,Object.assign(Object.assign({},h),{disabled:!a.pointer,touchOnly:!a.pointerHandlesMouse,isCancelled:()=>!je(this.accessor.options).pointer})),this.onWillShowOverlay=e.DockviewEvent.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this._onPointDown,this._onTabClick,this._onDropped,this._onDragStart,this._onDragEnd,this.accessor.onDidOptionsChange(()=>{const e=this._buildOverlayModel();this.dropTarget.setOverlayModel(e),this.pointerDropTarget.setOverlayModel(e)}),v(this._element,"dragend",()=>{D(this.element,"dv-tab--dragging",!1)}),this.html5DragSource,v(this._element,"pointerdown",e=>{this._onPointDown.fire(e)}),v(this._element,"click",e=>{this._onTabClick.fire(e)}),v(this._element,"contextmenu",e=>{this.accessor.contextMenuController.show(this.panel,this.group,e)}),new Je(this._element,{onLongPress:e=>{this.pointerDragSource.cancelPending(),this.accessor.contextMenuController.show(this.panel,this.group,e)}}),this.dropTarget.onDrop(e=>{this._onDropped.fire(e)}),this.pointerDropTarget.onDrop(e=>{this._onDropped.fire(e)}),this.dropTarget,this.pointerDropTarget,this.pointerDragSource)}setActive(e){D(this.element,"dv-active-tab",e),D(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="line"===(null===(e=this.accessor.options.theme)||void 0===e?void 0:e.dndTabIndicator)?Number.POSITIVE_INFINITY:0;return{activationSize:{value:50,type:"percentage"},smallWidthBoundary:t,smallHeightBoundary:t}}setDirection(e){this._direction=e;const t="vertical"===e?["top","bottom"]:["left","right"];this.dropTarget.setTargetZones(t),this.pointerDropTarget.setTargetZones(t)}updateDragAndDropState(){const e=je(this.accessor.options);this._element.draggable=e.html5,this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}_buildGhostElement(){const e=getComputedStyle(this.element),t=this.element.cloneNode(!0),i="vertical"===this._direction,s=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"]);return Array.from(e).forEach(o=>{i&&s.has(o)||t.style.setProperty(o,e.getPropertyValue(o),e.getPropertyPriority(o))}),i&&(t.style.setProperty("writing-mode","horizontal-tb"),t.style.setProperty("width",e.height),t.style.setProperty("height",e.width)),t.style.position="absolute",t.classList.add("dv-tab-ghost-drag"),t}}class qe{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 Ke extends l{get element(){return this._element}constructor(t,s){var r,a;super(),this.accessor=t,this.group=s,this.panelTransfer=o.getInstance(),this._onDrop=new m,this.onDrop=this._onDrop.event,this._onDragStart=new m,this.onDragStart=this._onDragStart.event;const l=je(this.accessor.options);this._element=document.createElement("div"),this._element.className="dv-void-container",this._element.draggable=l.html5,D(this._element,"dv-draggable",l.html5||l.pointer),this.addDisposables(this._onDrop,this._onDragStart,v(this._element,"pointerdown",()=>{this.accessor.doSetGroupActive(this.group)}),v(this._element,"pointerdown",e=>{e.shiftKey&&(e[x]=!0)},!0));const d=(e,t)=>{if(this.group.api.locked)return!1;const i=n();return!(!i||this.accessor.id!==i.viewId)||s.model.canDisplayOverlay(e,t,"header_space")};this.dropTarget=Ve.createDropTarget(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:d,getOverrideTarget:()=>{var e;return null===(e=s.model.dropTargetContainer)||void 0===e?void 0:e.model}}),this.pointerDropTarget=Le.createDropTarget(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:d,getOverrideTarget:()=>{var e;return null===(e=s.model.dropTargetContainer)||void 0===e?void 0:e.model}});const p=()=>{const e=document.createElement("div"),t=window.getComputedStyle(this._element),i=t.getPropertyValue("--dv-activegroup-visiblepanel-tab-background-color"),s=t.getPropertyValue("--dv-activegroup-visiblepanel-tab-color");return e.style.backgroundColor=i,e.style.color=s,e.style.padding="2px 8px",e.style.height="24px",e.style.fontSize="11px",e.style.lineHeight="20px",e.style.borderRadius="12px",e.style.whiteSpace="nowrap",e.style.boxSizing="border-box",e.style.display="inline-block",e.textContent=`Multiple Panels (${this.group.size})`,e},c={getData:()=>(this.panelTransfer.setData([new i(this.accessor.id,this.group.id,null)],i.prototype),{dispose:()=>{this.panelTransfer.clearData(i.prototype)}}),createGhost:()=>{const e=this.accessor.options.createGroupDragGhostComponent;if(e){const t=e(this.group);return t.init({group:this.group,api:this.accessor.api}),{element:t.element,offsetX:30,offsetY:-10,dispose:t.dispose?()=>{var e;return null===(e=t.dispose)||void 0===e?void 0:e.call(t)}:void 0}}return{element:p(),offsetX:30,offsetY:-10}},onDragStart:e=>{this._onDragStart.fire(e)}};this.html5DragSource=Ve.createDragSource(this._element,Object.assign(Object.assign({},c),{disabled:!l.html5,isCancelled:e=>"floating"===this.group.api.location.type&&!e.shiftKey||"edge"===this.group.api.location.type&&0===this.group.size}));const u=()=>{var e,t,i;return"floating"===(null===(i=null===(t=null===(e=this.group)||void 0===e?void 0:e.api)||void 0===t?void 0:t.location)||void 0===i?void 0:i.type)};this.pointerDragSource=Le.createDragSource(this._element,Object.assign(Object.assign({},c),{disabled:!l.pointer,touchOnly:!l.pointerHandlesMouse,touchInitiationDelay:()=>u()?500:250,pressTolerance:()=>u()?1/0:8,isCancelled:()=>!je(this.accessor.options).pointer||"edge"===this.group.api.location.type&&0===this.group.size,onDragStart:e=>{var t;null===(t=this.getFloatingOverlay())||void 0===t||t.cancelPendingDrag(),this._onDragStart.fire(e)}}));const g=new h,_=()=>{const t=this.getFloatingOverlay();g.value=t?t.onDidStartMoving(()=>{this.pointerDragSource.cancelPending()}):e.DockviewDisposable.NONE};_(),this.addDisposables(g);const f=null===(a=null===(r=this.group)||void 0===r?void 0:r.api)||void 0===a?void 0:a.onDidLocationChange;f&&this.addDisposables(f(_)),this.onWillShowOverlay=e.DockviewEvent.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this.html5DragSource,this.dropTarget.onDrop(e=>{this._onDrop.fire(e)}),this.pointerDropTarget.onDrop(e=>{this._onDrop.fire(e)}),this.dropTarget,this.pointerDropTarget,this.pointerDragSource)}updateDragAndDropState(){const e=je(this.accessor.options);this._element.draggable=e.html5,D(this._element,"dv-draggable",e.html5||e.pointer),this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}getFloatingOverlay(){var e,t;if(this.group)return null===(t=null===(e=this.accessor.floatingGroups)||void 0===e?void 0:e.find(e=>e.group===this.group))||void 0===t?void 0:t.overlay}}class Qe extends l{get element(){return this._element}get orientation(){return this._orientation}set orientation(e){this._orientation!==e&&(this._scrollOffset=0,this._orientation=e,b(this._scrollbar,"dv-scrollbar-vertical","dv-scrollbar-horizontal"),w(this._scrollbar,"vertical"===e?"dv-scrollbar-vertical":"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(v(this.element,"wheel",e=>{this._scrollOffset+=e.deltaY*Qe.MouseWheelSpeed,this.calculateScrollbarStyles()}),v(this._scrollbar,"pointerdown",e=>{e.preventDefault(),D(this.element,"dv-scrollable-scrolling",!0);const t="horizontal"===this._orientation?e.clientX:e.clientY,i=this._scrollOffset,s=e=>{const s="horizontal"===this._orientation?e.clientX-t:e.clientY-t,o=("horizontal"===this._orientation?this.element.clientWidth:this.element.clientHeight)/("horizontal"===this._orientation?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight);this._scrollOffset=i+s/o,this.calculateScrollbarStyles()},o=()=>{D(this.element,"dv-scrollable-scrolling",!1),document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",o),document.removeEventListener("pointercancel",o)};document.addEventListener("pointermove",s),document.addEventListener("pointerup",o),document.addEventListener("pointercancel",o)}),v(this.element,"scroll",()=>{this.calculateScrollbarStyles()}),v(this.scrollableElement,"scroll",()=>{this._scrollOffset="horizontal"===this._orientation?this.scrollableElement.scrollLeft:this.scrollableElement.scrollTop,this.calculateScrollbarStyles()}),f(this.element,()=>{D(this.element,"dv-scrollable-resizing",!0),this._animationTimer&&clearTimeout(this._animationTimer),this._animationTimer=setTimeout(()=>{clearTimeout(this._animationTimer),D(this.element,"dv-scrollable-resizing",!1)},500),this.calculateScrollbarStyles()}))}calculateScrollbarStyles(){const e="horizontal"===this._orientation?this.element.clientWidth:this.element.clientHeight,t="horizontal"===this._orientation?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight;if(t>e){const i=e*(e/t);"horizontal"===this._orientation?(this._scrollbar.style.width=`${i}px`,this._scrollbar.style.height=""):(this._scrollbar.style.height=`${i}px`,this._scrollbar.style.width=""),this._scrollOffset=L(this._scrollOffset,0,t-e),"horizontal"===this._orientation?this.scrollableElement.scrollLeft=this._scrollOffset:this.scrollableElement.scrollTop=this._scrollOffset;const s=this._scrollOffset/(t-e);"horizontal"===this._orientation?(this._scrollbar.style.left=(e-i)*s+"px",this._scrollbar.style.top=""):(this._scrollbar.style.top=(e-i)*s+"px",this._scrollbar.style.left="")}else"horizontal"===this._orientation?(this._scrollbar.style.width="0px",this._scrollbar.style.left="0px"):(this._scrollbar.style.height="0px",this._scrollbar.style.top="0px"),this._scrollOffset=0}}Qe.MouseWheelSpeed=1;const et=[{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 tt{constructor(e,t=!0){this._entries=e.slice(),this._byId=new Map(e.map(e=>[e.id,e])),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(e=>[e.id,e]))}entries(){return this._entries}has(e){return this._byId.has(e)}get(e){return this._byId.get(e)}defaultId(){var e;return null===(e=this._entries[0])||void 0===e?void 0:e.id}resolveValue(e){if(!this._enabled||!e)return;const t=this._byId.get(e);return t?t.value:e}}let it;function st(){return it||(it=new tt(et,!0)),it}function ot(e,t,i){const s=(null!=i?i:st()).resolveValue(t);void 0===s?e.style.removeProperty("--dv-tab-group-color"):e.style.setProperty("--dv-tab-group-color",s)}function nt(e,t){return(null!=t?t:st()).resolveValue(e)}class rt extends l{get element(){return this._element}constructor(e){super(),this._palette=e,this._onClick=new m,this.onClick=this._onClick.event,this._onContextMenu=new m,this.onContextMenu=this._onContextMenu.event,this._element=document.createElement("div"),this._element.className="dv-tab-group-chip",this._element.tabIndex=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,new Je(this._element,{onLongPress:e=>{this._onContextMenu.fire(e)}}),v(this._element,"click",e=>{this._onClick.fire(e)}),v(this._element,"contextmenu",e=>{this._onContextMenu.fire(e)}))}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(e=>{this.updateCollapsed(e)}),this._onClick.event(()=>{var e;null===(e=this._tabGroup)||void 0===e||e.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;ot(this._element,e,this._palette),D(this._element,"dv-tab-group-chip--accent-off",!1===(null===(t=this._palette)||void 0===t?void 0:t.enabled))}updateLabel(e){this._label.textContent=e,D(this._label,"dv-tab-group-chip-label--empty",!e)}updateCollapsed(e){D(this._element,"dv-tab-group-chip--collapsed",e)}}class at{get underlines(){return this._underlines}constructor(e){this._ctx=e,this._underlines=new Map,this._rafId=null}positionUnderlines(){requestAnimationFrame(()=>{this._positionUnderlinesSync()})}trackUnderlines(){null!==this._rafId&&cancelAnimationFrame(this._rafId);const e=performance.now(),t=()=>{this._positionUnderlinesSync(),performance.now()-e<250?this._rafId=requestAnimationFrame(t):this._rafId=null};this._rafId=requestAnimationFrame(t)}syncUnderlineElements(e){for(const t of e)if(!this._underlines.has(t)){const e=document.createElement("div");e.className="dv-tab-group-underline",this._ctx.tabsList.appendChild(e),this._underlines.set(t,e)}for(const[t,i]of this._underlines)e.has(t)||(i.remove(),this._underlines.delete(t))}getUnderline(e){return this._underlines.get(e)}dispose(){null!==this._rafId&&(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="vertical"===this._ctx.getDirection(),s=i?e.width:e.height,o=this._ctx.getActivePanelId(),n=this._ctx.getTabMap();for(const r of t){const t=this._underlines.get(r.id);if(!t)continue;const a=r.panelIds;if(0===a.length){t.style.display="none";continue}t.style.display="";const l=this._ctx.getChipElement(r.id);let h;if(l){const t=l.getBoundingClientRect(),s=getComputedStyle(l),o=i?Number.parseFloat(s.marginTop)||0:Number.parseFloat(s.marginLeft)||0;h=i?t.top-e.top-o:t.left-e.left-o}else{const t=a[0],s=n.get(t);if(s){const t=s.value.element.getBoundingClientRect();h=i?t.top-e.top:t.left-e.left}else h=0}const d=a[a.length-1],p=n.get(d);if(!p){i?(t.style.top=`${h}px`,t.style.height="0px",t.style.left="",t.style.width=""):(t.style.left=`${h}px`,t.style.width="0px",t.style.top="",t.style.height="");continue}const c=p.value.element.getBoundingClientRect();let u=i?c.bottom-e.top:c.right-e.left,m=u-h;if((r.collapsed||r.panelIds.some(e=>{const t=n.get(e);return t&&t.value.element.classList.contains("dv-tab--group-expanding")}))&&l){const t=l.getBoundingClientRect(),s=i?t.top+t.height/2-e.top:t.left+t.width/2-e.left;let o=0,a=0;for(const e of r.panelIds){const t=n.get(e);if(!t)continue;const s=t.value.element;i?(o+=s.getBoundingClientRect().height,a+=s.scrollHeight):(o+=s.getBoundingClientRect().width,a+=s.scrollWidth)}const d=a>0?Math.min(1,o/a):0;h=s+(h-s)*d,u=s+(u-s)*d,m=Math.max(0,u-h)}i?(t.style.top=`${h}px`,t.style.height=`${Math.max(0,m)}px`,t.style.left="",t.style.width=""):(t.style.left=`${h}px`,t.style.width=`${Math.max(0,m)}px`,t.style.top="",t.style.height=""),this.applyShape(t,r,h,m,s,o,e,i)}}}class lt extends at{_applyStraightLine(e,t,i,s,o,n){n?(e.setAttribute("width",String(s)),e.setAttribute("height",String(o)),i.style.width=`${s}px`,i.style.height=`${o}px`,t.setAttribute("d",`M ${s/2},0 L ${s/2},${o}`)):(e.setAttribute("width",String(o)),e.setAttribute("height",String(s)),i.style.width=`${o}px`,i.style.height=`${s}px`,t.setAttribute("d",`M 0,${s/2} L ${o},${s/2}`))}applyShape(e,t,i,s,o,n,r,a){const l=o,h=s,d=nt(t.color,this._ctx.getColorPalette());if(h<=0||l<=0||void 0===d)return void(e.style.display="none");let p;e.style.display="",n&&t.panelIds.includes(n)&&(p=this._ctx.getTabMap().get(n));let c,u=e.firstElementChild;if(u&&"svg"===u.tagName?c=u.firstElementChild:(e.replaceChildren(),u=document.createElementNS("http://www.w3.org/2000/svg","svg"),u.style.display="block",c=document.createElementNS("http://www.w3.org/2000/svg","path"),c.setAttribute("fill","none"),u.appendChild(c),e.appendChild(u)),c.setAttribute("stroke",d),c.setAttribute("stroke-width",String(2)),!p)return void this._applyStraightLine(u,c,e,2,h,a);const m=p.value.element.getBoundingClientRect();let v,g;if(a?(v=Math.max(0,m.top-r.top-i),g=Math.min(h,m.bottom-r.top-i)):(v=Math.max(0,m.left-r.left-i),g=Math.min(h,m.right-r.left-i)),g<=v)return void this._applyStraightLine(u,c,e,2,h,a);if(a){const t=l,i=h;u.setAttribute("width",String(t)),u.setAttribute("height",String(i)),e.style.width=`${t}px`,e.style.height=`${i}px`;const s=1,o=t-1,n=[`M ${s},0`,`L ${s},${v-6}`,`Q ${s},${v} ${s+6},${v}`,`L ${o-6},${v}`,`Q ${o},${v} ${o},${v+6}`,`L ${o},${g-6}`,`Q ${o},${g} ${o-6},${g}`,`L ${s+6},${g}`,`Q ${s},${g} ${s},${g+6}`,`L ${s},${i}`].join(" ");c.setAttribute("d",n)}else{const t=h,i=l;u.setAttribute("width",String(t)),u.setAttribute("height",String(i)),e.style.width=`${t}px`,e.style.height=`${i}px`;const s=i-1,o=1,n=[`M 0,${s}`,`L ${v-6},${s}`,`Q ${v},${s} ${v},${s-6}`,`L ${v},${o+6}`,`Q ${v},${o} ${v+6},${o}`,`L ${g-6},${o}`,`Q ${g},${o} ${g},${o+6}`,`L ${g},${s-6}`,`Q ${g},${s} ${g+6},${s}`,`L ${t},${s}`].join(" ");c.setAttribute("d",n)}}}class ht extends at{applyShape(e,t,i,s,o,n,r,a){const l=nt(t.color,this._ctx.getColorPalette());s<=0||void 0===l?e.style.display="none":(e.style.display="",e.firstElementChild&&e.replaceChildren(),e.style.backgroundColor=l,a?(e.style.width="2px",e.style.height=`${s}px`):(e.style.width=`${s}px`,e.style.height="2px"))}}const dt=new Map;class pt{get chipRenderers(){return this._chipRenderers}get groupUnderlines(){var e,t;return null!==(t=null===(e=this._indicator)||void 0===e?void 0:e.underlines)&&void 0!==t?t:dt}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 e=this._ctx.group.model.getTabGroups(),t=new Set;for(const i of e)t.add(i.id),this._ensureChipForGroup(i),this._positionChipForGroup(i);for(const[e,i]of this._chipRenderers)t.has(e)||(i.chip.element.remove(),i.chip.dispose(),i.disposable.dispose(),this._chipRenderers.delete(e));this._updateTabGroupClasses()}refreshAccents(){var e,t;for(const i of this._ctx.group.model.getTabGroups()){const s=this._chipRenderers.get(i.id);null===(t=null==s?void 0:(e=s.chip).update)||void 0===t||t.call(e,{tabGroup:i})}this._updateTabGroupClasses()}positionAllChips(){if(0!==this._chipRenderers.size)for(const e of this._ctx.group.model.getTabGroups())this._positionChipForGroup(e)}updateDirection(){const e="vertical"===this._ctx.getDirection();for(const[,t]of this._chipRenderers)t.dropTarget.setTargetZones(e?["top"]:["left"])}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;null===(e=this._indicator)||void 0===e||e.positionUnderlines()}trackUnderlines(){var e;null===(e=this._indicator)||void 0===e||e.trackUnderlines()}setGroupDragImage(e,t,i){if(!e.dataTransfer)return;const s="vertical"===this._ctx.getDirection(),o=this._ctx.tabsList.cloneNode(!0);s?(o.classList.remove("dv-tabs-container-vertical","dv-vertical"),o.classList.add("dv-horizontal"),o.style.writingMode="horizontal-tb",o.style.height=`${this._ctx.tabsList.offsetWidth}px`):o.style.height=`${this._ctx.tabsList.offsetHeight}px`,o.style.width="auto",o.style.overflow="visible",o.style.pointerEvents="none";const n=Array.from(o.children),r=Array.from(this._ctx.tabsList.children);for(let e=n.length-1;e>=0;e--){r[e]!==i&&n[e].remove()}const a=document.createElement("div");a.className="dv-groupview dv-active-group",a.style.position="fixed",a.style.top="-10000px",a.style.left="0px",a.style.height="auto",a.style.width="auto",a.style.pointerEvents="none";const l=document.createElement("div");l.className="dv-tabs-and-actions-container",l.style.height="auto",l.style.width="auto",a.appendChild(l),l.appendChild(o),this._ctx.accessor.element.appendChild(a);const h=o.querySelector(".dv-tab-group-chip"),d=i.getBoundingClientRect(),p=e.clientX-d.left,c=e.clientY-d.top;if(h){const t=h.getBoundingClientRect(),i=a.getBoundingClientRect(),s=t.left-i.left+p,o=t.top-i.top+c;e.dataTransfer.setDragImage(a,s,o)}else e.dataTransfer.setDragImage(a,p,c);requestAnimationFrame(()=>{a.remove()})}cleanupTransition(e){var t;null===(t=this._pendingTransitionCleanups.get(e))||void 0===t||t(),this._pendingTransitionCleanups.delete(e)}updateDragAndDropState(){const e=je(this._ctx.accessor.options);for(const t of this._chipRenderers.values())t.chip.element.draggable=e.html5,t.html5DragSource.setDisabled(!e.html5),t.pointerDragSource.setDisabled(!e.pointer),t.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}disposeChipDrag(e){var t,i;const s=this._chipRenderers.get(e);s&&(null===(t=s.html5DragSource)||void 0===t||t.dispose(),null===(i=s.pointerDragSource)||void 0===i||i.dispose())}_buildChipGhostElement(e){const t=getComputedStyle(e),i=e.cloneNode(!0);return Array.from(t).forEach(e=>{i.style.setProperty(e,t.getPropertyValue(e),t.getPropertyPriority(e))}),i.style.position="absolute",i}disposeAll(){var e;null===(e=this._indicator)||void 0===e||e.dispose(),this._indicator=null;for(const[,e]of this._pendingTransitionCleanups)e();this._pendingTransitionCleanups.clear();for(const[,e]of this._chipRenderers)e.chip.element.remove(),e.chip.dispose(),e.disposable.dispose();this._chipRenderers.clear()}_ensureIndicator(){var e,t;const i="none"===(null!==(t=null===(e=this._ctx.accessor.options.theme)||void 0===e?void 0:e.tabGroupIndicator)&&void 0!==t?t:"wrap")?ht:lt;!this._indicator||this._indicator instanceof i||(this._indicator.dispose(),this._indicator=null),this._indicator||(this._indicator=new i({tabsList:this._ctx.tabsList,getTabGroups:()=>this._ctx.group.model.getTabGroups(),getActivePanelId:()=>{var e;return null===(e=this._ctx.group.activePanel)||void 0===e?void 0:e.id},getTabMap:()=>this._ctx.getTabMap(),getChipElement:e=>{var t;return null===(t=this._chipRenderers.get(e))||void 0===t?void 0:t.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,s=t?t(e):new rt(this._ctx.accessor.tabGroupColorPalette);s.init({tabGroup:e,api:this._ctx.accessor.api});const r=je(this._ctx.accessor.options);s.element.draggable=r.html5;const a=o.getInstance(),h=()=>(a.setData([new i(this._ctx.accessor.id,this._ctx.group.id,null,e.id)],i.prototype),{dispose:()=>{a.clearData(i.prototype)}}),d=Ve.createDragSource(s.element,{getData:h,disabled:!r.html5,isCancelled:()=>!je(this._ctx.accessor.options).html5,onDragStart:t=>{"dataTransfer"in t&&t.dataTransfer&&this.setGroupDragImage(t,e,s.element),this._callbacks.onChipDragStart(e,s,t)},onDragEnd:t=>{var i,o;null===(o=(i=this._callbacks).onChipDragEnd)||void 0===o||o.call(i,e,s,t)}});s.element.addEventListener("dragend",()=>{a.clearData(i.prototype)},{once:!0});const p=Le.createDragSource(s.element,{getData:h,disabled:!r.pointer,touchOnly:!r.pointerHandlesMouse,isCancelled:()=>!je(this._ctx.accessor.options).pointer,createGhost:()=>({element:this._buildChipGhostElement(s.element),offsetX:8,offsetY:8}),onDragStart:t=>{this._callbacks.onChipDragStart(e,s,t)}}),c=[e.onDidChange(()=>{var t;null===(t=s.update)||void 0===t||t.call(s,{tabGroup:e}),this._updateTabGroupClasses()}),e.onDidPanelChange(()=>{this._positionChipForGroup(e),this._updateTabGroupClasses()}),e.onDidCollapseChange(()=>{this._updateTabGroupClasses()}),d,p],u=t=>{p.cancelPending(),this._callbacks.onChipContextMenu(e,t)};s instanceof rt?c.push(s.onContextMenu(u)):c.push(new Je(s.element,{onLongPress:u}),v(s.element,"contextmenu",u));const m="vertical"===this._ctx.getDirection(),g=new Pe(s.element,{acceptedTargetZones:m?["top"]:["left"],overlayModel:{activationSize:{value:100,type:"percentage"}},canDisplayOverlay:(e,t)=>{var i;if(this._ctx.group.locked)return!1;if(this._ctx.accessor.options.disableDnd)return!1;const s=n();return s&&this._ctx.accessor.id===s.viewId?"smooth"!==(null===(i=this._ctx.accessor.options.theme)||void 0===i?void 0:i.tabAnimation):this._ctx.group.model.canDisplayOverlay(e,t,"tab")}});c.push(g,g.onDrop(t=>{this._callbacks.onChipDrop(e,t)}));const _=new l(...c);this._chipRenderers.set(e.id,{chip:s,html5DragSource:d,pointerDragSource:p,disposable:_,dropTarget:g}),e.collapsed&&(this._skipNextCollapseAnimation=!0)}_positionChipForGroup(e){const t=this._chipRenderers.get(e.id);if(!t)return;const i=t.chip.element,s=e.panelIds;if(0===s.length)return void i.remove();const o=s[0],n=this._ctx.getTabMap().get(o);if(!n)return void i.remove();const r=n.value.element;i.nextSibling!==r&&this._ctx.tabsList.insertBefore(i,r)}_updateTabGroupClasses(){var e;const t=this._ctx.group.model.getTabGroups(),i=this._ctx.getTabs(),s=this._ctx.getTabMap();let o=!1;const n=new Map;for(const e of t)for(const t of e.panelIds)n.set(t,e);for(const t of i){const i=t.value,s=i.panel.id,r=n.get(s),a=!!r;if(D(i.element,"dv-tab--grouped",a),r){const t=r.panelIds,n=t[0]===s,a=t[t.length-1]===s;D(i.element,"dv-tab--group-first",n),D(i.element,"dv-tab--group-last",a),ot(i.element,r.color,this._ctx.accessor.tabGroupColorPalette);const l=i.element.classList.contains("dv-tab--group-collapsed");if(!r.collapsed&&l){o=!0,i.element.classList.remove("dv-tab--group-collapsed"),i.element.classList.add("dv-tab--group-expanding"),null===(e=this._pendingTransitionCleanups.get(s))||void 0===e||e();const t=()=>{i.element.classList.remove("dv-tab--group-expanding"),i.element.style.removeProperty("width"),i.element.removeEventListener("transitionend",t),clearTimeout(n),this._pendingTransitionCleanups.delete(s)},n=setTimeout(t,300);this._pendingTransitionCleanups.set(s,t),i.element.addEventListener("transitionend",t)}}else D(i.element,"dv-tab--group-first",!1),D(i.element,"dv-tab--group-last",!1),i.element.classList.remove("dv-tab--group-collapsed","dv-tab--group-expanding"),i.element.style.removeProperty("width"),i.element.style.removeProperty("--dv-tab-group-color")}const r=new Set;for(const e of t){r.add(e.id);if(e.collapsed&&e.panelIds.some(e=>{const t=s.get(e);return t&&!t.value.element.classList.contains("dv-tab--group-collapsed")}))if(this._skipNextCollapseAnimation){const t=[];for(const i of e.panelIds){const e=s.get(i);e&&(e.value.element.style.transition="none",e.value.element.classList.add("dv-tab--group-collapsed"),t.push(e.value.element))}if(t.length>0){t[0].offsetHeight;for(const e of t)e.style.removeProperty("transition")}}else{o=!0;const t="vertical"===this._ctx.getDirection();for(const i of e.panelIds){const e=s.get(i);if(e&&!e.value.element.classList.contains("dv-tab--group-collapsed")){const i=e.value.element.getBoundingClientRect();t?e.value.element.style.height=`${i.height}px`:e.value.element.style.width=`${i.width}px`,e.value.element.offsetHeight,e.value.element.classList.add("dv-tab--group-collapsed")}}}}this._skipNextCollapseAnimation=!1,this._ensureIndicator(),this._indicator&&(this._indicator.syncUnderlineElements(r),o?this._indicator.trackUnderlines():this._indicator.positionUnderlines())}}class ct extends l{get showTabsOverflowControl(){return this._showTabsOverflowControl}set showTabsOverflowControl(e){if(this._showTabsOverflowControl!=e&&(this._showTabsOverflowControl=e,e)){const e=new _(this._tabsList);this._observerDisposable.value=new l(e,e.onDidChange(e=>{const t=e.hasScrollX||e.hasScrollY;this.toggleDropdown({reset:!t}),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}),v(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;null===(t=this._voidContainerListeners)||void 0===t||t.dispose(),this._voidContainerListeners=null,this._voidContainer=e,e&&(this._voidContainerListeners=new l(v(e,"dragover",e=>{this._animState&&e.preventDefault()}),v(e,"drop",e=>{var t;(null===(t=this._animState)||void 0===t?void 0:t.sourceTabGroupId)&&null!==this._animState.currentInsertionIndex&&(e.preventDefault(),e.stopPropagation(),this.handleVoidDrop())})))}handleVoidDrop(){var e,t;if(!(null===(e=this._animState)||void 0===e?void 0:e.sourceTabGroupId))return!1;const i=this._animState.sourceTabGroupId,s=null!==(t=this._animState.currentInsertionIndex)&&void 0!==t?t:this._tabs.length;return this._animState=null,this._commitGroupMove(i,s),!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),b(this._tabsList,"dv-horizontal","dv-vertical"),"vertical"===e?w(this._tabsList,"dv-tabs-container-vertical","dv-vertical"):(b(this._tabsList,"dv-tabs-container-vertical"),w(this._tabsList,"dv-horizontal"));for(const t of this._tabs)t.value.setDirection(e);this._tabGroupManager.updateDirection()}}constructor(t,i,s){super(),this.group=t,this.accessor=i,this._observerDisposable=new h,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._pointerInsideTabsList=!1,this._onTabDragStart=new m,this.onTabDragStart=this._onTabDragStart.event,this._onDrop=new m,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new m,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onOverflowTabsChange=new m,this.onOverflowTabsChange=this._onOverflowTabsChange.event,this._tabsList=document.createElement("div"),this._tabsList.className="dv-tabs-container",this.showTabsOverflowControl=s.showTabsOverflowControl,"native"===i.options.scrollbars?this._element=this._tabsList:(this._scrollbar=new Qe(this._tabsList),this._scrollbar.orientation=this.direction,this._element=this._scrollbar.element,this.addDisposables(this._scrollbar)),this._tabGroupManager=new pt({group:this.group,accessor:this.accessor,tabsList:this._tabsList,getTabs:()=>this._tabs,getTabMap:()=>this._tabMap,getDirection:()=>this._direction},{onChipContextMenu:(e,t)=>{this.accessor.contextMenuController.showForChip(e,this.group,t)},onChipDragStart:(e,t,i)=>{this._handleChipDragStart(e,t,i)},onChipDragEnd:()=>{this.resetDragAnimation()},onChipDrop:(e,t)=>{this._handleChipDrop(e,t)}}),this.addDisposables(this._onOverflowTabsChange,this._observerDisposable,this._onWillShowOverlay,this._onDrop,this._onTabDragStart,{dispose:()=>{var e;null===(e=this._flipTransitionCleanup)||void 0===e||e.call(this)}},ze.getInstance().onDragEnd(()=>{this._pointerInsideTabsList=!1,this.resetDragAnimation()}),ze.getInstance().onDragMove(e=>{this._handlePointerDragMove(e.clientX,e.clientY)}),v(this.element,"pointerdown",e=>{if(e.defaultPrevented)return;0===e.button&&this.accessor.doSetGroupActive(this.group)}),v(this._tabsList,"wheel",e=>{const t="vertical"===this._direction,i=t?e.deltaY||e.deltaX:e.deltaX||e.deltaY;if(0===i)return;const s=t?this._tabsList.scrollHeight-this._tabsList.clientHeight:this._tabsList.scrollWidth-this._tabsList.clientWidth;if(s<=0)return;const o=t?this._tabsList.scrollTop:this._tabsList.scrollLeft;i<0&&o<=0||i>0&&o>=s||(e.preventDefault(),e.stopPropagation(),t?this._tabsList.scrollTop=o+i:this._tabsList.scrollLeft=o+i)},{passive:!1}),v(this._tabsList,"dragover",e=>{this._processDragOver(e.clientX)&&e.preventDefault()},!0),v(this._tabsList,"dragleave",e=>{this._processDragLeave(e.relatedTarget)},!0),v(this._tabsList,"dragend",()=>{this.resetDragAnimation()}),v(this._tabsList,"drop",e=>{var t,i,s;if(!this._animState||null===this._animState.currentInsertionIndex)return;if("smooth"!==(null===(t=this.accessor.options.theme)||void 0===t?void 0:t.tabAnimation)&&!this._animState.sourceTabGroupId)return;e.stopPropagation(),e.preventDefault(),null===(s=null===(i=this.group.model.dropTargetContainer)||void 0===i?void 0:i.model)||void 0===s||s.clear();const o=this._animState;if(this._animState=null,this._pendingCollapse=!1,o.sourceTabGroupId)return void this._commitGroupMove(o.sourceTabGroupId,o.currentInsertionIndex);const n=o.currentInsertionIndex,r=o.sourceIndex,a=n-(-1!==r&&r<n?1:0),l=this.group.model.getTabGroupForPanel(o.sourceTabId);if(a===r&&!o.targetTabGroupId&&!l)return this._uncollapsSourceTab(o.sourceTabId),void this.resetTabTransforms();this._uncollapsSourceTab(o.sourceTabId);const h=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:e,index:a,targetTabGroupId:o.targetTabGroupId}),this.runFlipAnimation(h,o.sourceTabId,-1===o.sourceIndex,{from:Math.min(r,a),to:Math.max(r,a)})},!0),e.DockviewDisposable.from(()=>{var e;null===(e=this._voidContainerListeners)||void 0===e||e.dispose(),this.resetDragAnimation(),this._tabGroupManager.disposeAll();for(const{value:e,disposable:t}of this._tabs)t.dispose(),e.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="vertical"===this._direction;let i=0;for(const s of this._tabs){const o=e.id===s.value.panel.id;if(s.value.setActive(o),o){const e=s.value.element,o=e.parentElement;t?(i<o.scrollTop||i+e.clientHeight>o.scrollTop+o.clientHeight)&&(o.scrollTop=i):(i<o.scrollLeft||i+e.clientWidth>o.scrollLeft+o.clientWidth)&&(o.scrollLeft=i)}i+=t?s.value.element.clientHeight:s.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 Ze(e,this.accessor,this.group);i.setContent(e.view.tab),"horizontal"!==this._direction&&i.setDirection(this._direction);const s=new l(i.onDragStart(t=>{var s;if(this._onTabDragStart.fire({nativeEvent:t,panel:e}),"smooth"===(null===(s=this.accessor.options.theme)||void 0===s?void 0:s.tabAnimation)){const t=i.element.getBoundingClientRect().width,s=this._tabs.findIndex(e=>e.value===i);this._animState={sourceTabId:e.id,sourceIndex:s,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:t/2,sourceGapWidth:t,containerLeft:this._tabsList.getBoundingClientRect().left},this._pendingCollapse=!0,requestAnimationFrame(()=>{var e,t;this._pendingCollapse=!1,this._animState&&(i.element.style.transition="none",D(i.element,"dv-tab--dragging",!0),i.element.offsetHeight,null!==(e=(t=this._animState).currentInsertionIndex)&&void 0!==e||(t.currentInsertionIndex=s),this.applyDragOverTransforms(!0),i.element.style.removeProperty("transition"))})}}),i.onTabClick(t=>{t.defaultPrevented||"edge"===this.group.api.location.type&&(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(t=>{if(t.defaultPrevented)return;const s=!this.accessor.options.disableFloatingGroups,o="floating"===this.group.api.location.type&&1===this.size;if(s&&!o&&t.shiftKey){t.preventDefault();const e=this.accessor.getGroupPanel(i.panel.id),{top:s,left:o}=i.element.getBoundingClientRect(),{top:n,left:r}=this.accessor.element.getBoundingClientRect();return void this.accessor.addFloatingGroup(e,{x:o-r,y:s-n,inDragMode:!0})}if(0===t.button)"edge"===this.group.api.location.type||this.group.activePanel!==e&&this.group.model.openPanel(e)}),i.onDrop(e=>{var t,s,o,r;const a=this._animState;this._animState=null,this._pendingCollapse=!1;const l=this._tabs.findIndex(e=>e.value===i);if(a){const i="right"===e.position?l+1:l;if(a.sourceTabGroupId)return void this._commitGroupMove(a.sourceTabGroupId,null!==(t=a.currentInsertionIndex)&&void 0!==t?t:i);this._uncollapsSourceTab(a.sourceTabId);const o=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:e.nativeEvent,index:i,targetTabGroupId:a.targetTabGroupId}),"smooth"===(null===(s=this.accessor.options.theme)||void 0===s?void 0:s.tabAnimation)&&this.runFlipAnimation(o,a.sourceTabId,-1===a.sourceIndex,-1!==a.sourceIndex?{from:Math.min(a.sourceIndex,i),to:Math.max(a.sourceIndex,i)}:void 0)}else{const t="vertical"===this._direction?"bottom":"right",s=e.position===t?l+1:l,a=n(),h=a?this._tabs.findIndex(e=>e.value.panel.id===a.panelId):-1,d=s-(-1!==h&&h<s?1:0),p=null!==(r=null===(o=this.group.model.getTabGroupForPanel(i.panel.id))||void 0===o?void 0:o.id)&&void 0!==r?r:null;this._onDrop.fire({event:e.nativeEvent,index:d,targetTabGroupId:p})}}),i.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new qe(e,{kind:"tab",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:n}))})),o={value:i,disposable:s};this.addTab(o,t),this._tabGroupManager.positionAllChips(),this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}delete(e){var t;(null===(t=this._animState)||void 0===t?void 0:t.sourceTabId)===e&&(this.resetTabTransforms(),this._animState=null),this._tabGroupManager.cleanupTransition(e);const i=this.indexOf(e),s=this._tabs.splice(i,1)[0];if(this._tabMap.delete(e),s){const{value:e,disposable:t}=s;t.dispose(),e.dispose(),e.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)return void this._onOverflowTabsChange.fire({tabs:[],tabGroups:[],reset:!0});const t=this._tabs.filter(e=>!z(e.value.element,this._tabsList)).map(e=>e.value.panel.id),i=new Set(t),s=[];for(const e of this.group.model.getTabGroups()){const o=this._tabGroupManager.chipRenderers.get(e.id),n=o&&!z(o.chip.element,this._tabsList),r=e.panelIds.length>0&&e.panelIds.every(e=>i.has(e));if((n||r)&&(s.push(e.id),e.collapsed))for(const s of e.panelIds)i.has(s)||(i.add(s),t.push(s))}this._onOverflowTabsChange.fire({tabs:t,tabGroups:s,reset:!1})}updateDragAndDropState(){for(const e of this._tabs)e.value.updateDragAndDropState();this._tabGroupManager.updateDragAndDropState()}updateTabGroups(){this._tabGroupManager.update()}refreshTabGroupAccent(){this._tabGroupManager.refreshAccents()}_handleChipDragStart(e,t,i){var s;const o=e.panelIds[0],n=o?this._tabs.findIndex(e=>e.value.panel.id===o):-1,r=t.element.getBoundingClientRect();let a=r.width;for(const t of e.panelIds){const e=this._tabMap.get(t);e&&(a+=e.value.element.getBoundingClientRect().width)}if(this._animState={sourceTabId:"",sourceIndex:n,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.id,sourceGroupPanelIds:new Set(e.panelIds),sourceChipWidth:r.width,cursorOffsetFromDragLeft:i.clientX-r.left,sourceGapWidth:a,containerLeft:this._tabsList.getBoundingClientRect().left},"smooth"!==(null===(s=this.accessor.options.theme)||void 0===s?void 0:s.tabAnimation))return;const l=new Set(e.panelIds);this._pendingCollapse=!0,requestAnimationFrame(()=>{var t,i;if(this._pendingCollapse=!1,!this._animState)return;for(const e of this._tabs)l.has(e.value.panel.id)&&(e.value.element.style.transition="none",D(e.value.element,"dv-tab--dragging",!0));const s=this._tabGroupManager.chipRenderers.get(e.id);s&&(s.chip.element.style.transition="none",D(s.chip.element,"dv-tab-group-chip--dragging",!0)),this._tabsList.offsetHeight;const o=this._tabGroupManager.groupUnderlines.get(e.id);o&&(o.style.display="none"),null!==(t=(i=this._animState).currentInsertionIndex)&&void 0!==t||(i.currentInsertionIndex=n),this.applyDragOverTransforms(!0);for(const e of this._tabs)l.has(e.value.panel.id)&&e.value.element.style.removeProperty("transition");s&&s.chip.element.style.removeProperty("transition")})}_handleChipDrop(e,t){const i=e.panelIds[0];if(!i)return;const s=this._tabs.findIndex(e=>e.value.panel.id===i);if(-1===s)return;const o=n(),r=o&&o.groupId===this.group.id&&o.panelId?this._tabs.findIndex(e=>e.value.panel.id===o.panelId):-1,a=s-(-1!==r&&r<s?1:0);this._onDrop.fire({event:t.nativeEvent,index:a,targetTabGroupId:null})}setExtendedDropZone(e){this._extendedDropZone=e}setExternalInsertionIndex(e){this._animState&&e!==this._animState.currentInsertionIndex&&(this._animState.currentInsertionIndex=e,this.applyDragOverTransforms())}clearExternalAnimState(){this._animState&&(this.resetTabTransforms(),-1===this._animState.sourceIndex?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(0===this._tabs.length)return 0;const e="vertical"===this._direction;let t=0;for(const i of this._tabs){const s=i.value.element.getBoundingClientRect();t+=e?s.height:s.width}return t/this._tabs.length}_handlePointerDragMove(e,t){var i;const s=(null!==(i=this._tabsList.ownerDocument)&&void 0!==i?i:document).elementFromPoint(e,t);!!s&&(this._tabsList.contains(s)||!!this._extendedDropZone&&this._extendedDropZone.contains(s))?(this._pointerInsideTabsList=!0,this._processDragOver(e)):this._pointerInsideTabsList&&(this._pointerInsideTabsList=!1,this._processDragLeave(s))}_processDragOver(e){var t,i,s,o;if(this.accessor.options.disableDnd)return!1;if(this._animState){const e=n();(null==e?void 0:e.tabGroupId)&&e.groupId!==this.group.id&&this._animState.sourceTabGroupId!==e.tabGroupId&&(this._animState=null)}if(!this._animState){const e=n();if("default"===(null===(t=this.accessor.options.theme)||void 0===t?void 0:t.tabAnimation)&&!(null==e?void 0:e.tabGroupId))return!1;if(!e||!e.panelId&&!e.tabGroupId||e.groupId===this.group.id)return!1;{const t=this.getAverageTabWidth();if(e.tabGroupId){const s=this.accessor.getPanel(e.groupId),o=null==s?void 0:s.model.getTabGroups().find(t=>t.id===e.tabGroupId),n=t*(null!==(i=null==o?void 0:o.panelIds.length)&&void 0!==i?i:1)+t;this._animState={sourceTabId:"",sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.tabGroupId,sourceGroupPanelIds:o?new Set(o.panelIds):new Set,sourceChipWidth:t,cursorOffsetFromDragLeft:n/2,sourceGapWidth:n,containerLeft:this._tabsList.getBoundingClientRect().left}}else this._animState={sourceTabId:e.panelId,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:t/2,sourceGapWidth:t,containerLeft:this._tabsList.getBoundingClientRect().left}}}return-1!==this._animState.sourceIndex&&(null===(o=null===(s=this.group.model.dropTargetContainer)||void 0===s?void 0:s.model)||void 0===o||o.clear()),this.handleDragOver({clientX:e}),!0}_processDragLeave(e){var t,i,s;if(!this._animState)return;if(e&&this._tabsList.contains(e))return;if(e&&(null===(t=this._extendedDropZone)||void 0===t?void 0:t.contains(e)))return this.resetTabTransforms(),void(this._animState.currentInsertionIndex=null);this._voidContainer&&e&&(e===this._voidContainer||this._voidContainer.contains(e))||(this.resetTabTransforms(),-1===this._animState.sourceIndex?(null===(s=null===(i=this.group.model.dropTargetContainer)||void 0===i?void 0:i.model)||void 0===s||s.clear(),this._animState=null):this._animState.currentInsertionIndex=null)}handleDragOver(e){var t,i,s,o,n;if(!this._animState)return;const r=e.clientX;let a=null,l=null;const h=this._animState.sourceGroupPanelIds,d=r-this._animState.cursorOffsetFromDragLeft-this._animState.containerLeft;let p=0;const c=new Map;if(this._tabGroupManager.chipRenderers.size>0){const e=this.group.model.getTabGroups();for(const t of e)t.id!==this._animState.sourceTabGroupId&&t.panelIds.length>0&&c.set(t.panelIds[0],t.id)}for(let e=0;e<this._tabs.length;e++){const i=this._tabs[e].value;if(i.panel.id===this._animState.sourceTabId)continue;if(null==h?void 0:h.has(i.panel.id))continue;const s=c.get(i.panel.id);if(s){const i=null!==(t=this._animState.chipPositions.get(s))&&void 0!==t?t:0;if(p+i>d){null!=a||(a=e);break}p+=i}const o=this._animState.tabPositions.get(i.panel.id),n=o?o.width:i.element.getBoundingClientRect().width;if(!(p+n/2<=d)){null!=a||(a=e);break}p+=n,a=e+1}if(null!==a&&this._tabGroupManager.chipRenderers.size>0){const e=!!this._animState.sourceTabGroupId,t=this.group.model.getTabGroups();let n=0;for(let e=0;e<this._tabs.length;e++){const t=this._tabs[e].value;if(t.panel.id===this._animState.sourceTabId)continue;if(null==h?void 0:h.has(t.panel.id))continue;if(e>=a)break;const s=c.get(t.panel.id);s&&(n+=null!==(i=this._animState.chipPositions.get(s))&&void 0!==i?i:0);const o=this._animState.tabPositions.get(t.panel.id);n+=o?o.width:t.element.getBoundingClientRect().width}for(const i of t){const t=i.panelIds.filter(e=>e!==this._animState.sourceTabId&&!(null==h?void 0:h.has(e)));if(0===t.length)continue;const d=this._tabs.findIndex(e=>e.value.panel.id===t[0]),p=this._tabs.findIndex(e=>e.value.panel.id===t[t.length-1]);if(-1===d||-1===p)continue;const c=a>=d&&a<=p,u=!c&&a===d-1;if(c||u){if(e&&c){a=a<(d+p+1)/2?d:p+1;break}if(e&&u)break;if(u){let e=!0;for(let t=a;t<d;t++){const i=this._tabs[t].value.panel.id;if(i!==this._animState.sourceTabId&&!(null==h?void 0:h.has(i))){e=!1;break}}if(!e)continue;const t=null!==(s=this._animState.chipPositions.get(i.id))&&void 0!==s?s:0;r>=(i.collapsed?this._animState.containerLeft+n+t/2:this._animState.containerLeft+n+t)&&(a=d,l=i.id);break}if(c){const e=null!==(o=this._animState.chipPositions.get(i.id))&&void 0!==o?o:0,t=this._animState.containerLeft+n+e;a===d?r>=t&&(l=i.id):l=i.id;break}}}}a===this._animState.currentInsertionIndex&&l===this._animState.targetTabGroupId||(this._animState.currentInsertionIndex=a,this._animState.targetTabGroupId=l,"smooth"===(null===(n=this.accessor.options.theme)||void 0===n?void 0:n.tabAnimation)&&this.applyDragOverTransforms())}_removeClassInstantlyBatch(e,t){const i=[];for(const s of e)s.classList.contains(t)&&(s.style.transition="none",D(s,t,!1),i.push(s));if(i.length>0){i[0].offsetHeight;for(const e of i)e.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||null===this._animState.currentInsertionIndex)return void this.resetTabTransforms();if(this._pendingCollapse)return;const t=this._animState.currentInsertionIndex;let i;const s=this._animState.sourceGroupPanelIds;if(this._animState.sourceTabGroupId&&s)i=this._animState.sourceGapWidth;else{const e=this._animState.tabPositions.get(this._animState.sourceTabId);i=e?e.width:this.getAverageTabWidth()}let o=null;if(this._tabGroupManager.chipRenderers.size>0){const e=this.group.model.getTabGroups();for(const i of e){if(i.id===this._animState.sourceTabGroupId)continue;if(i.panelIds.includes(this._animState.sourceTabId))continue;const e=i.panelIds.filter(e=>e!==this._animState.sourceTabId&&!(null==s?void 0:s.has(e)));if(0===e.length)continue;const n=this._tabs.findIndex(t=>t.value.panel.id===e[0]);if((!this._animState.targetTabGroupId||this._animState.targetTabGroupId===i.id&&i.collapsed)&&n>=t){let e=!1;for(let i=t;i<n;i++){const t=this._tabs[i].value.panel.id;if(t!==this._animState.sourceTabId&&!(null==s?void 0:s.has(t))){e=!0;break}}if(!e){const e=this._tabGroupManager.chipRenderers.get(i.id);e&&(o=e.chip.element)}break}}}const n=e=>e.classList.contains("dv-tab-group-chip")?"dv-tab-group-chip--shifting":"dv-tab--shifting",r=(t,i)=>{e?(t.style.transition="none",t.style.marginLeft=i,t.offsetHeight,t.style.removeProperty("transition")):t.style.marginLeft=i,D(t,n(t),!0)},a=t=>{const i=n(t),s=this._pendingMarginCleanups.get(t);if(s&&s(),e||!t.style.marginLeft)t.style.removeProperty("margin-left"),D(t,i,!1);else{t.style.marginLeft="0px",D(t,i,!0);const e=()=>{t.style.removeProperty("margin-left"),D(t,i,!1),t.removeEventListener("transitionend",e),clearTimeout(s),this._pendingMarginCleanups.delete(t)},s=setTimeout(e,300);this._pendingMarginCleanups.set(t,e),t.addEventListener("transitionend",e)}};let l=!1;for(const[e,t]of this._tabGroupManager.chipRenderers)e!==this._animState.sourceTabGroupId&&a(t.chip.element);o&&(r(o,`${i}px`),l=!0);for(let e=0;e<this._tabs.length;e++){const o=this._tabs[e].value;o.panel.id!==this._animState.sourceTabId&&((null==s?void 0:s.has(o.panel.id))||(!l&&e>=t?(r(o.element,`${i}px`),l=!0):a(o.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"),D(e.value.element,"dv-tab--shifting",!1);for(const[,e]of this._tabGroupManager.chipRenderers)e.chip.element.style.removeProperty("margin-left"),D(e.chip.element,"dv-tab-group-chip--shifting",!1);this._tabGroupManager.positionUnderlines()}_commitGroupMove(e,t){var i,s;const o=n();this._tabGroupManager.disposeChipDrag(e);if(this.group.model.getTabGroups().some(t=>t.id===e))if("smooth"===(null===(i=this.accessor.options.theme)||void 0===i?void 0:i.tabAnimation)){this._clearGroupDragClasses(e);const i=this.snapshotTabPositions();this.resetTabTransforms(),this.group.model.moveTabGroup(e,t),this.runFlipAnimation(i,"",!1)}else this._tabGroupManager.skipNextCollapseAnimation=!0,this.group.model.moveTabGroup(e,t);else o&&(this.resetTabTransforms(),this.accessor.moveGroupOrPanel({from:{groupId:o.groupId,tabGroupId:null!==(s=o.tabGroupId)&&void 0!==s?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(e=>e.value.element),"dv-tab--dragging");const i=this._tabGroupManager.groupUnderlines.get(e);i&&i.style.removeProperty("display"),this._tabGroupManager.skipNextCollapseAnimation=!0}resetDragAnimation(){if(this._pendingCollapse=!1,this._animState){this.resetTabTransforms(),this._animState.sourceTabGroupId?this._clearGroupDragClasses(this._animState.sourceTabGroupId):this._removeClassInstantlyBatch(this._tabs.map(e=>e.value.element),"dv-tab--dragging"),this._animState=null;for(const[,e]of this._tabGroupManager.groupUnderlines)e.style.removeProperty("display")}}runFlipAnimation(e,t,i=!1,s){const o="vertical"===this._direction;let n=!1;for(let r=0;r<this._tabs.length;r++){const a=this._tabs[r],l=a.value.panel.id;if(l===t){if(i){const e=a.value.element.getBoundingClientRect();a.value.element.style.transform=o?`translateY(${e.height}px)`:`translateX(${e.width}px)`,D(a.value.element,"dv-tab--shifting",!0),n=!0}continue}if(void 0!==s&&(r<s.from||r>s.to))continue;const h=e.get(l);if(!h)continue;const d=a.value.element.getBoundingClientRect(),p=o?h.top-d.top:h.left-d.left;Math.abs(p)<1||(a.value.element.style.transform=o?`translateY(${p}px)`:`translateX(${p}px)`,D(a.value.element,"dv-tab--shifting",!0),n=!0)}n&&requestAnimationFrame(()=>{var e;for(const e of this._tabs)e.value.element.style.transform&&(e.value.element.style.transform="");this._tabGroupManager.trackUnderlines(),null===(e=this._flipTransitionCleanup)||void 0===e||e.call(this);const t=e=>{if("transform"===e.propertyName){i();for(const e of this._tabs)D(e.value.element,"dv-tab--shifting",!1);this._tabGroupManager.positionUnderlines()}},i=()=>{this._tabsList.removeEventListener("transitionend",t),this._flipTransitionCleanup=null};this._flipTransitionCleanup=i,this._tabsList.addEventListener("transitionend",t)})}}const ut=e=>{const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttributeNS(null,"height",e.height),t.setAttributeNS(null,"width",e.width),t.setAttributeNS(null,"viewBox",e.viewbox),t.setAttributeNS(null,"aria-hidden","false"),t.setAttributeNS(null,"focusable","false"),t.classList.add("dv-svg");const i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttributeNS(null,"d",e.path),t.appendChild(i),t},mt=()=>ut({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"});class vt extends l{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,"vertical"===e?(w(this._element,"dv-groupview-header-vertical"),w(this.rightActionsContainer,"dv-right-actions-container-vertical"),this.tabs.direction=e):(b(this._element,"dv-groupview-header-vertical"),b(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 h,this._onDrop=new m,this.onDrop=this._onDrop.event,this._onGroupDragStart=new m,this.onGroupDragStart=this._onGroupDragStart.event,this._onWillShowOverlay=new m,this.onWillShowOverlay=this._onWillShowOverlay.event,this._element=document.createElement("div"),this._element.className="dv-tabs-and-actions-container",D(this._element,"dv-full-width-single-tab","fullwidth"===this.accessor.options.singleTabMode),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 ct(t,e,{showTabsOverflowControl:!e.options.disableTabsOverflowList}),this.voidContainer=new Ke(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(e=>this._onDrop.fire(e)),this.tabs.onWillShowOverlay(e=>this._onWillShowOverlay.fire(e)),e.onDidOptionsChange(()=>{this.tabs.showTabsOverflowControl=!e.options.disableTabsOverflowList}),this.tabs.onOverflowTabsChange(e=>{this.toggleDropdown(e)}),this.tabs,this._onWillShowOverlay,this._onDrop,this._onGroupDragStart,this.voidContainer,this.voidContainer.onDragStart(e=>{this._onGroupDragStart.fire({nativeEvent:e,group:this.group})}),this.voidContainer.onDrop(e=>{this.tabs.handleVoidDrop()||this._onDrop.fire({event:e.nativeEvent,index:this.tabs.size})}),this.voidContainer.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new qe(e,{kind:"header_space",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:n}))}),v(this.leftActionsContainer,"dragleave",e=>{const t=e.relatedTarget;this.leftActionsContainer.contains(t)||this._element.contains(t)||this.tabs.clearExternalAnimState()}),v(this.voidContainer.element,"dragleave",e=>{const t=e.relatedTarget;this.voidContainer.element.contains(t)||(this._element.contains(t)?this.tabs.setExternalInsertionIndex(null):this.tabs.clearExternalAnimState())}),v(this.voidContainer.element,"pointerdown",e=>{if(e.defaultPrevented)return;if(!this.accessor.options.disableFloatingGroups&&e.shiftKey&&"floating"!==this.group.api.location.type&&"edge"!==this.group.api.location.type){e.preventDefault();const{top:t,left:i}=this.element.getBoundingClientRect(),{top:s,left:o}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(this.group,{x:i-o+20,y:t-s+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(){D(this._element,"dv-single-tab",1===this.size)}toggleDropdown(t){const i=t.reset?[]:t.tabs,s=t.reset?[]:t.tabGroups;this._overflowTabs=i,this._overflowTabGroups=s;const o=this._overflowTabs.length;if(o>0&&this.dropdownPart)return void this.dropdownPart.update({tabs:o});if(0===o)return void this._dropdownDisposable.dispose();const n=document.createElement("div");n.className="dv-tabs-overflow-dropdown-root";const r=function(){const e=document.createElement("div");e.className="dv-tabs-overflow-dropdown-default";const t=document.createElement("span");t.textContent="";const i=mt();return e.appendChild(i),e.appendChild(t),{element:e,update:e=>{t.textContent=`${e.tabs}`}}}();r.update({tabs:o}),this.dropdownPart=r,n.appendChild(r.element),this.rightActionsContainer.prepend(n),this._dropdownDisposable.value=new l(e.DockviewDisposable.from(()=>{var e,t;n.remove(),null===(t=null===(e=this.dropdownPart)||void 0===e?void 0:e.dispose)||void 0===t||t.call(e),this.dropdownPart=null}),v(n,"pointerdown",e=>{e.preventDefault()},{capture:!0}),v(n,"click",e=>{const t=document.createElement("div");t.style.overflow="auto",t.className="dv-tabs-overflow-container";const i=new Set(this._overflowTabGroups),s=this.group.model.getTabGroups(),o=new Map;for(const e of s)if(i.has(e.id))for(const t of e.panelIds)o.set(t,e);const r=new Set;for(const e of this.tabs.tabs.filter(e=>this._overflowTabs.includes(e.panel.id))){const i=o.get(e.panel.id);if(i&&!r.has(i.id)){r.add(i.id);const e=document.createElement("div");e.className="dv-tabs-overflow-group-header";const s=document.createElement("span");s.className="dv-tabs-overflow-group-color",ot(s,i.color,this.accessor.tabGroupColorPalette),e.appendChild(s);const o=document.createElement("span");if(o.className="dv-tabs-overflow-group-label",o.textContent=i.label||i.id,e.appendChild(o),i.collapsed){const t=document.createElement("span");t.className="dv-tabs-overflow-group-collapsed-badge",t.textContent=`${i.panelIds.length}`,e.appendChild(t)}e.addEventListener("click",()=>{this.accessor.getPopupServiceForGroup(this.group).close(),i.collapsed&&i.expand();const e=i.panelIds[0];if(e){const t=this.group.panels.find(t=>t.id===e);null==t||t.api.setActive()}}),t.appendChild(e)}const s=this.group.panels.find(t=>t===e.panel),n=s.view.createTabRenderer("headerOverflow").element,a=document.createElement("div");D(a,"dv-tab",!0),D(a,"dv-active-tab",s.api.isActive),D(a,"dv-inactive-tab",!s.api.isActive),i&&D(a,"dv-tab--grouped",!0),a.addEventListener("click",t=>{this.accessor.getPopupServiceForGroup(this.group).close(),t.defaultPrevented||((null==i?void 0:i.collapsed)&&i.expand(),e.element.scrollIntoView(),e.panel.api.setActive())}),a.appendChild(n),t.appendChild(a)}const a=A(n);this.accessor.getPopupServiceForGroup(this.group).openPopover(t,{x:e.clientX,y:e.clientY,zIndex:(null==a?void 0:a.style.zIndex)?`calc(${a.style.zIndex} * 2)`:void 0})}))}updateDragAndDropState(){this.tabs.updateDragAndDropState(),this.voidContainer.updateDragAndDropState()}updateTabGroups(){this.tabs.updateTabGroups()}refreshTabGroupAccent(){this.tabs.refreshTabGroupAccent()}}class gt extends p{constructor(e,t,i,s,o){super(),this.nativeEvent=e,this.target=t,this.position=i,this.getData=s,this.group=o}}const _t=(()=>{const e={disableAutoResizing:void 0,hideBorders:void 0,singleTabMode:void 0,disableFloatingGroups:void 0,floatingGroupBounds:void 0,popoutUrl:void 0,nonce:void 0,defaultRenderer:void 0,defaultHeaderPosition:void 0,debug:void 0,rootOverlayModel:void 0,locked:void 0,disableDnd:void 0,dndStrategy: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,createGroupDragGhostComponent:void 0,tabGroupColors:void 0,tabGroupAccent:void 0};return Object.keys(e)})();function ft(e){return!!e.referencePanel}function bt(e){return!!e.referenceGroup}function wt(e){return!!e.referencePanel}function Dt(e){return!!e.referenceGroup}class Ct extends l{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 0===this._panelIds.length}constructor(e,t){var i,s;super(),this.id=e,this._collapsed=!1,this._panelIds=[],this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this._onDidPanelChange=new m,this.onDidPanelChange=this._onDidPanelChange.event,this._onDidCollapseChange=new m,this.onDidCollapseChange=this._onDidCollapseChange.event,this._onDidDestroy=new m,this.onDidDestroy=this._onDidDestroy.event,this._label=null!==(i=null==t?void 0:t.label)&&void 0!==i?i:"",this._color=""===(null==t?void 0:t.color)||null==t?void 0:t.color,this._collapsed=null!==(s=null==t?void 0:t.collapsed)&&void 0!==s&&s,this._componentParams=null==t?void 0:t.componentParams,this.addDisposables(this._onDidChange,this._onDidPanelChange,this._onDidCollapseChange,this._onDidDestroy)}addPanel(e,t){if(this.isDisposed)return;if(this._panelIds.includes(e))return;const i=void 0!==t?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-1!==t&&(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),void 0!==this._color&&(e.color=this._color),void 0!==this._componentParams&&(e.componentParams=this._componentParams),e}dispose(){this._onDidDestroy.fire(),super.dispose()}}class yt extends d{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 St extends yt{get kind(){return this._kind}constructor(e){super(e),this._kind=e.kind}}class xt extends l{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,D(this.container,"dv-locked-groupview","no-drop-target"===e||e)}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return 0===this._panels.length}get hasWatermark(){return!(!this.watermark||!this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get isContentFocused(){return!!document.activeElement&&C(document.activeElement,this.contentContainer.element)}get headerPosition(){var e;return null!==(e=this._headerPosition)&&void 0!==e?e:"top"}set headerPosition(e){var t;this._headerPosition=e,b(this.container,"dv-groupview-header-top","dv-groupview-header-bottom","dv-groupview-header-left","dv-groupview-header-right"),w(this.container,`dv-groupview-header-${e}`);const i="top"===e||"bottom"===e?"horizontal":"vertical";this.tabsContainer.direction=i,this.header.direction=i,(null===(t=this._activePanel)||void 0===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){this._location=e,D(this.container,"dv-groupview-floating",!1),D(this.container,"dv-groupview-popout",!1),D(this.container,"dv-groupview-edge",!1);const t=e=>{this.contentContainer.dropTarget.setTargetZones(e),this.contentContainer.pointerDropTarget.setTargetZones(e)};switch(e.type){case"grid":t(["top","bottom","left","right","center"]);break;case"floating":t(["center"]),t(e?["center"]:["top","bottom","left","right","center"]),D(this.container,"dv-groupview-floating",!0);break;case"popout":t(["center"]),D(this.container,"dv-groupview-popout",!0);break;case"edge":t(["center"]),D(this.container,"dv-groupview-edge",!0)}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,i,s,o){var r,a;super(),this.container=e,this.accessor=t,this.id=i,this.options=s,this.groupPanel=o,this._isGroupActive=!1,this._locked=!1,this._rightHeaderActionsDisposable=new h,this._leftHeaderActionsDisposable=new h,this._prefixHeaderActionsDisposable=new h,this._location={type:"grid"},this.mostRecentlyUsed=[],this._overwriteRenderContainer=null,this._overwriteDropTargetContainer=null,this._onDidChange=new m,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 m,this.onMove=this._onMove.event,this._onDidDrop=new m,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new m,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new m,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onTabDragStart=new m,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new m,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new m,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPanelTitleChange=new m,this.onDidPanelTitleChange=this._onDidPanelTitleChange.event,this._onDidPanelParametersChange=new m,this.onDidPanelParametersChange=this._onDidPanelParametersChange.event,this._onDidRemovePanel=new m,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new m,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onUnhandledDragOverEvent=new m,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this._tabGroups=[],this._tabGroupMap=new Map,this._panelToTabGroup=new Map,this._tabGroupIdCounter=0,this._pendingTabGroupUpdate=!1,this._onDidCreateTabGroup=new m,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new m,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new m,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new m,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new m,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new m,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,D(this.container,"dv-groupview",!0),this._api=new ge(this.accessor),this.tabsContainer=new vt(this.accessor,this.groupPanel),this.contentContainer=new Xe(this.accessor,this),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!s.hideHeader,this.locked=null!==(r=s.locked)&&void 0!==r&&r,this.headerPosition=null!==(a=s.headerPosition)&&void 0!==a?a:t.defaultHeaderPosition,this.addDisposables(this._onTabDragStart,this._onGroupDragStart,this._onWillShowOverlay,this._rightHeaderActionsDisposable,this._leftHeaderActionsDisposable,this._prefixHeaderActionsDisposable,this.tabsContainer.onTabDragStart(e=>{this._onTabDragStart.fire(e)}),this.tabsContainer.onGroupDragStart(e=>{this._onGroupDragStart.fire(e)}),this.tabsContainer.onDrop(e=>{var t;const i=n(),s=null!==(t=null==i?void 0:i.panelId)&&void 0!==t?t:null;if(this.handleDropEvent("header",e.event,"center",e.index),s&&e.targetTabGroupId){const t=this._tabGroupMap.get(e.targetTabGroupId);let i;if(t){const e=this._panels.findIndex(e=>e.id===s);if(-1!==e){i=0;for(const s of t.panelIds){this._panels.findIndex(e=>e.id===s)<e&&i++}}}this.addPanelToTabGroup(e.targetTabGroupId,s,i)}else s&&null===e.targetTabGroupId&&this.removePanelFromTabGroup(s)}),this.contentContainer.onDidFocus(()=>{this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.onDidBlur(()=>{}),this.contentContainer.dropTarget.onDrop(e=>{this.handleDropEvent("content",e.nativeEvent,e.position)}),this.contentContainer.pointerDropTarget.onDrop(e=>{this.handleDropEvent("content",e.nativeEvent,e.position)}),this.tabsContainer.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(e)}),this.contentContainer.dropTarget.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new qe(e,{kind:"content",panel:this.activePanel,api:this._api,group:this.groupPanel,getData:n}))}),this.contentContainer.pointerDropTarget.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new qe(e,{kind:"content",panel:this.activePanel,api:this._api,group:this.groupPanel,getData:n}))}),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=null!==(t=null==e?void 0:e.id)&&void 0!==t?t:`tg-${this.id}-${this._tabGroupIdCounter++}`,s=new Ct(i,{label:null==e?void 0:e.label,color:null==e?void 0:e.color,collapsed:null==e?void 0:e.collapsed,componentParams:null==e?void 0:e.componentParams});return this._tabGroups.push(s),this._tabGroupMap.set(i,s),this._tabGroupDisposables.set(i,new l(s.onDidChange(()=>{this._onDidTabGroupChange.fire({tabGroup:s})}),s.onDidCollapseChange(e=>{e?this._handleGroupCollapse(s):this._handleGroupExpand(s),this._onDidTabGroupCollapsedChange.fire({tabGroup:s})}),s.onDidDestroy(()=>{this._removeTabGroupInternal(s)}))),this._onDidCreateTabGroup.fire({tabGroup:s}),s}dissolveTabGroup(e){const t=this._tabGroupMap.get(e);if(!t)return;const i=[...t.panelIds];for(const e of i)t.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:e});t.dispose()}addPanelToTabGroup(e,t,i){const s=this._tabGroupMap.get(e);if(!s)return;if(!this._panels.some(e=>e.id===t))return;const o=this.getTabGroupForPanel(t);if(o){if(o.id===e)return;this.removePanelFromTabGroup(t)}s.addPanel(t,i),this._panelToTabGroup.set(t,s),this._enforceContiguity(s,t),this._onDidAddPanelToTabGroup.fire({tabGroup:s,panelId:t})}movePanelWithinGroup(e,t,i){const s=this._tabGroupMap.get(e);s&&s.containsPanel(t)&&(s.removePanel(t),s.addPanel(t,i),this._enforceContiguity(s,t),this.tabsContainer.updateTabGroups())}movePanelBetweenGroups(e,t,i){const s=this._findTabGroupForPanel(e),o=this._tabGroupMap.get(t);o&&(s&&(s.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:s,panelId:e}),s.isEmpty&&s.dispose()),o.addPanel(e,i),this._panelToTabGroup.set(e,o),this._enforceContiguity(o,e),this._onDidAddPanelToTabGroup.fire({tabGroup:o,panelId:e}))}moveTabGroup(e,t){const i=this._tabGroupMap.get(e);if(!i||0===i.panelIds.length)return;const s=new Set(i.panelIds),o=i.panelIds.map(e=>this._panels.find(t=>t.id===e)).filter(e=>void 0!==e);if(0===o.length)return;let n=0;for(let e=0;e<Math.min(t,this._panels.length);e++)s.has(this._panels[e].id)&&n++;for(const e of o){const t=this._panels.indexOf(e);-1!==t&&this._panels.splice(t,1)}const r=t-n,a=Math.max(0,Math.min(r,this._panels.length));this._panels.splice(a,0,...o);for(const e of this._panels)this.tabsContainer.delete(e.id);for(let e=0;e<this._panels.length;e++)this.tabsContainer.openPanel(this._panels[e],e);this.tabsContainer.updateTabGroups()}_enforceContiguity(e,t){const i=this._panels.find(e=>e.id===t);if(!i)return;const s=e.indexOfPanel(t),o=this._computeGlobalIndex(e,s),n=this._panels.indexOf(i);if(n===o)return;this._panels.splice(n,1);const r=o>n?o-1:o;this._panels.splice(r,0,i),this.tabsContainer.delete(t),this.tabsContainer.openPanel(i,r)}_computeGlobalIndex(e,t){const i=e.panelIds;if(i.length<=1){const e=this._panels.find(e=>e.id===i[0]);return e?this._panels.indexOf(e):this._panels.length}for(let e=0;e<i.length;e++){if(e===t)continue;const s=this._panels.find(t=>t.id===i[e]);if(s){const i=this._panels.indexOf(s);return Math.max(0,i+(t-e))}}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()}refreshWatermark(){var e,t;this.watermark&&(this.watermark.element.remove(),null===(t=(e=this.watermark).dispose)||void 0===t||t.call(e),this.watermark=void 0),this.updateContainer()}getTabGroupForPanel(e){return this._findTabGroupForPanel(e)}_findTabGroupForPanel(e){return this._panelToTabGroup.get(e)}_removeTabGroupInternal(e){const t=this._tabGroups.indexOf(e);if(-1!==t){this._tabGroups.splice(t,1),this._tabGroupMap.delete(e.id);for(const t of e.panelIds)this._panelToTabGroup.delete(t);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)return;if(!e.containsPanel(this._activePanel.id))return;const t=this._panels.indexOf(this._activePanel);for(let e=t+1;e<this._panels.length;e++){const t=this._panels[e],i=this._findTabGroupForPanel(t.id);if(!i||!i.collapsed)return this.doSetActivePanel(t),void this.updateContainer()}for(let e=t-1;e>=0;e--){const t=this._panels[e],i=this._findTabGroupForPanel(t.id);if(!i||!i.collapsed)return this.doSetActivePanel(t),void this.updateContainer()}this.contentContainer.closePanel(),this.doSetActivePanel(void 0),this.updateContainer()}_handleGroupExpand(e){if(this._activePanel)return;const t=e.panelIds[0];if(t){const e=this._panels.find(e=>e.id===t);e&&(this.doSetActivePanel(e),this.updateContainer())}}restoreTabGroups(e){for(const t of e){const e=t.id.match(/-(\d+)$/);if(e){const t=parseInt(e[1],10)+1;t>this._tabGroupIdCounter&&(this._tabGroupIdCounter=t)}}for(const t of e){const e=this.createTabGroup({id:t.id,label:t.label,color:t.color,componentParams:t.componentParams}),i=this._tabGroupMap.get(e.id);for(const s of t.panelIds)this._panels.some(e=>e.id===s)&&(e.addPanel(s),this._panelToTabGroup.set(s,i),this._enforceContiguity(i,s));t.collapsed&&e.collapse(),e.isEmpty&&e.dispose()}}focusContent(){this.contentContainer.element.focus()}set renderContainer(e){this.panels.forEach(e=>{this.renderContainer.detatch(e)}),this._overwriteRenderContainer=e,this.panels.forEach(e=>{this.rerender(e)})}get renderContainer(){var e;return null!==(e=this._overwriteRenderContainer)&&void 0!==e?e:this.accessor.overlayRenderContainer}set dropTargetContainer(e){this._overwriteDropTargetContainer=e}get dropTargetContainer(){var e;return null!==(e=this._overwriteDropTargetContainer)&&void 0!==e?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:null===(e=this._activePanel)||void 0===e?void 0:e.id,id:this.id};return!1!==this.locked&&(t.locked=this.locked),this.header.hidden&&(t.hideHeader=!0),"top"!==this.headerPosition&&(t.headerPosition=this.headerPosition),this._tabGroups.length>0&&(t.tabGroups=this._tabGroups.map(e=>e.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)return;i=0}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)return;i=this.panels.length-1}this.openPanel(this.panels[i])}containsPanel(e){return this.panels.includes(e)}init(e){}update(e){}focus(){var e;null===(e=this._activePanel)||void 0===e||e.focus()}openPanel(e,t={}){("number"!=typeof t.index||t.index>this.panels.length)&&(t.index=this.panels.length);const i=!!t.skipSetActive;e.updateParentGroup(this.groupPanel,{skipSetActive:t.skipSetActive}),this.doAddPanel(e,t.index,{skipSetActive:i}),this._activePanel!==e?(i||this.doSetActivePanel(e),t.skipSetGroupActive||this.accessor.doSetGroupActive(this.groupPanel),t.skipSetActive||this.updateContainer()):this.contentContainer.renderPanel(e,{asActive:!0})}removePanel(e,t={skipSetActive:!1}){const i="string"==typeof e?e:e.id,s=this._panels.find(e=>e.id===i);if(!s)throw new Error("invalid operation");return this._removePanel(s,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=1===this.panels.length&&1===this.accessor.groups.length;this.accessor.removePanel(e,t&&"emptyGroup"===this.accessor.options.noPanelsOverlay?{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,D(this.container,"dv-active-group",e),D(this.container,"dv-inactive-group",!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0){const e=this._panels.find(e=>{const t=this._findTabGroupForPanel(e.id);return!t||!t.collapsed});e&&this.doSetActivePanel(e)}this.updateContainer()}}layout(e,t){var i;this._width=e,this._height=t,this.contentContainer.layout(this._width,this._height),(null===(i=this._activePanel)||void 0===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 e=this.mostRecentlyUsed[0];this.openPanel(e,{skipSetActive:t.skipSetActive,skipSetGroupActive:t.skipSetActiveGroup})}return this._activePanel&&0===this.panels.length&&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 t=this.mostRecentlyUsed.indexOf(e);this.mostRecentlyUsed.splice(t,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?"always"===e.api.renderer&&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 l(e.api.onDidTitleChange(e=>this._onDidPanelTitleChange.fire(e)),e.api.onDidParametersChange(e=>this._onDidPanelParametersChange.fire(e)))),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(e=>e.runEvents());const i=this.isEmpty||!this._activePanel;if(i&&!this.watermark){const e=this.accessor.createWatermarkComponent();e.init({containerApi:this._api,group:this.groupPanel}),this.watermark=e,v(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(),null===(t=(e=this.watermark).dispose)||void 0===t||t.call(e),this.watermark=void 0)}canDisplayOverlay(e,t,i){const s=new gt(e,i,t,n,this.accessor.getPanel(this.id));return this._onUnhandledDragOverEvent.fire(s),s.isAccepted}handleDropEvent(e,t,i,s){if("no-drop-target"===this.locked)return;const o="number"==typeof s?this.panels[s]:void 0,r=new St({nativeEvent:t,position:i,panel:o,getData:()=>n(),kind:function(){switch(e){case"header":return"number"==typeof s?"tab":"header_space";case"content":return"content"}}(),group:this.groupPanel,api:this._api});if(this._onWillDrop.fire(r),r.defaultPrevented)return;const a=n();if(a&&a.viewId===this.accessor.id){if("content"===e&&a.groupId===this.id){if("center"===i)return;if(null===a.panelId&&!a.tabGroupId)return}if("header"===e&&a.groupId===this.id&&null===a.panelId&&!a.tabGroupId)return;if(null===a.panelId){const{groupId:e}=a;return void this._onMove.fire({target:i,groupId:e,index:s,tabGroupId:a.tabGroupId})}if(-1!==this.tabsContainer.indexOf(a.panelId)&&1===this.tabsContainer.size)return;const{groupId:t,panelId:o}=a;if(this.id===t&&!i){if(this.tabsContainer.indexOf(o)===s)return}this._onMove.fire({target:i,groupId:a.groupId,itemId:a.panelId,index:s})}else this._onDidDrop.fire(new yt({nativeEvent:t,position:i,panel:o,getData:()=>n(),group:this.groupPanel,api:this._api}))}updateDragAndDropState(){this.tabsContainer.updateDragAndDropState()}dispose(){var e,t,i;super.dispose(),null===(e=this.watermark)||void 0===e||e.element.remove(),null===(i=null===(t=this.watermark)||void 0===t?void 0:t.dispose)||void 0===i||i.call(t),this.watermark=void 0;for(const e of[...this._tabGroups])e.dispose();for(const e of this._tabGroupDisposables.values())e.dispose();this._tabGroupDisposables.clear();for(const e of this._pendingMicrotaskDisposables)e.dispose();this._pendingMicrotaskDisposables.clear();for(const e of this.panels)e.dispose();this.tabsContainer.dispose(),this.contentContainer.dispose()}}class Gt extends He{constructor(e,t,i){super(e,t),this._onDidConstraintsChangeInternal=new m,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new m,this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new m,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 Pt extends $e{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="function"==typeof this._minimumWidth?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}__maximumWidth(){const e="function"==typeof this._maximumWidth?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}__minimumHeight(){const e="function"==typeof this._minimumHeight?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}__maximumHeight(){const e="function"==typeof this._maximumHeight?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,s){super(e,t,null!=s?s:new Gt(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 m,this.onDidChange=this._onDidChange.event,"number"==typeof(null==i?void 0:i.minimumWidth)&&(this._minimumWidth=i.minimumWidth),"number"==typeof(null==i?void 0:i.maximumWidth)&&(this._maximumWidth=i.maximumWidth),"number"==typeof(null==i?void 0:i.minimumHeight)&&(this._minimumHeight=i.minimumHeight),"number"==typeof(null==i?void 0:i.maximumHeight)&&(this._maximumHeight=i.maximumHeight),this.api.initialize(this),this.addDisposables(this.api.onWillVisibilityChange(e=>{const{isVisible:t}=e,{accessor:i}=this._params;i.setVisible(this,t)}),this.api.onActiveChange(()=>{const{accessor:e}=this._params;e.doSetGroupActive(this)}),this.api.onDidConstraintsChangeInternal(e=>{"number"!=typeof e.minimumWidth&&"function"!=typeof e.minimumWidth||(this._minimumWidth=e.minimumWidth),"number"!=typeof e.minimumHeight&&"function"!=typeof e.minimumHeight||(this._minimumHeight=e.minimumHeight),"number"!=typeof e.maximumWidth&&"function"!=typeof e.maximumWidth||(this._maximumWidth=e.maximumWidth),"number"!=typeof e.maximumHeight&&"function"!=typeof e.maximumHeight||(this._maximumHeight=e.maximumHeight)}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({height:e.height,width:e.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),"boolean"==typeof e.isVisible&&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=e=>e===Number.MAX_SAFE_INTEGER?void 0:e,i=e=>e<=0?void 0:e;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 Tt="dockview: DockviewGroupPanelApiImpl not initialized";class It extends Gt{get location(){if(!this._group)throw new Error(Tt);return this._group.model.location}get locked(){if(!this._group)throw new Error(Tt);return this._group.locked}set locked(e){if(!this._group)throw new Error(Tt);this._group.locked=e}constructor(e,t){super(e,"__dockviewgroup__"),this.accessor=t,this._onDidLocationChange=new m,this.onDidLocationChange=this._onDidLocationChange.event,this._onDidActivePanelChange=new m,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidCollapsedChange=new m,this.onDidCollapsedChange=this._onDidCollapsedChange.event,this.addDisposables(this._onDidLocationChange,this._onDidActivePanelChange,this._onDidCollapsedChange,this._onDidVisibilityChange.event(e=>{e.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"popout"===this.location.type?this.location.getWindow():window}setHeaderPosition(e){if(!this._group)throw new Error(Tt);this._group.model.headerPosition=e}getHeaderPosition(){if(!this._group)throw new Error(Tt);return this._group.model.headerPosition}moveTo(e){var t,i,s,o;if(!this._group)throw new Error(Tt);const n=null!==(t=e.group)&&void 0!==t?t:this.accessor.addGroup({direction:xe(null!==(i=e.position)&&void 0!==i?i:"right"),skipSetActive:null!==(s=e.skipSetActive)&&void 0!==s&&s});this.accessor.moveGroupOrPanel({from:{groupId:this._group.id},to:{group:n,position:e.group&&null!==(o=e.position)&&void 0!==o?o:"center",index:e.index},skipSetActive:e.skipSetActive})}maximize(){if(!this._group)throw new Error(Tt);"grid"===this.location.type&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw new Error(Tt);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw new Error(Tt);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)}initialize(e){this._group=e}}class zt extends Pt{get minimumWidth(){var e;if("number"==typeof this._explicitConstraints.minimumWidth)return this._explicitConstraints.minimumWidth;const t=null===(e=this.activePanel)||void 0===e?void 0:e.minimumWidth;return"number"==typeof t?t:super.__minimumWidth()}get minimumHeight(){var e;if("number"==typeof this._explicitConstraints.minimumHeight)return this._explicitConstraints.minimumHeight;const t=null===(e=this.activePanel)||void 0===e?void 0:e.minimumHeight;return"number"==typeof t?t:super.__minimumHeight()}get maximumWidth(){var e;if("number"==typeof this._explicitConstraints.maximumWidth)return this._explicitConstraints.maximumWidth;const t=null===(e=this.activePanel)||void 0===e?void 0:e.maximumWidth;return"number"==typeof t?t:super.__maximumWidth()}get maximumHeight(){var e;if("number"==typeof this._explicitConstraints.maximumHeight)return this._explicitConstraints.maximumHeight;const t=null===(e=this.activePanel)||void 0===e?void 0:e.maximumHeight;return"number"==typeof t?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 s,o,n,r,a,l;super(t,"groupview_default",{minimumHeight:null!==(o=null===(s=i.constraints)||void 0===s?void 0:s.minimumHeight)&&void 0!==o?o:100,minimumWidth:null!==(r=null===(n=i.constraints)||void 0===n?void 0:n.minimumWidth)&&void 0!==r?r:100,maximumHeight:null===(a=i.constraints)||void 0===a?void 0:a.maximumHeight,maximumWidth:null===(l=i.constraints)||void 0===l?void 0:l.maximumWidth},new It(t,e)),this._explicitConstraints={},this.api.initialize(this),this._model=new xt(this.element,e,t,i,this),this.addDisposables(this.model.onDidActivePanelChange(e=>{this.api._onDidActivePanelChange.fire(e)}),this.api.onDidConstraintsChangeInternal(e=>{void 0!==e.minimumWidth&&(this._explicitConstraints.minimumWidth="function"==typeof e.minimumWidth?e.minimumWidth():e.minimumWidth),void 0!==e.minimumHeight&&(this._explicitConstraints.minimumHeight="function"==typeof e.minimumHeight?e.minimumHeight():e.minimumHeight),void 0!==e.maximumWidth&&(this._explicitConstraints.maximumWidth="function"==typeof e.maximumWidth?e.maximumWidth():e.maximumWidth),void 0!==e.maximumHeight&&(this._explicitConstraints.maximumHeight="function"==typeof e.maximumHeight?e.maximumHeight():e.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 At={name:"abyss",className:"dockview-theme-abyss",colorScheme:"dark",tabGroupIndicator:"none"};class Et extends Gt{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,s,o){super(e.id,s),this.panel=e,this.accessor=i,this._onDidTitleChange=new m,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidActiveGroupChange=new m,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new m,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new m,this.onDidRendererChange=this._onDidRendererChange.event,this._onDidLocationChange=new m,this.onDidLocationChange=this._onDidLocationChange.event,this.groupEventsDisposable=new h,this._tabComponent=o,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:null!==(t=e.group)&&void 0!==t?t:this._group,position:e.group&&null!==(i=e.position)&&void 0!==i?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=null!==(t=null==e?void 0:e.isActive)&&void 0!==t&&t;this.groupEventsDisposable.value=new l(this.group.api.onDidVisibilityChange(e=>{const t=!e.isVisible&&this.isVisible,i=e.isVisible&&!this.isVisible,s=this.group.model.isPanelActive(this.panel);(t||i&&s)&&this._onDidVisibilityChange.fire(e)}),this.group.api.onDidLocationChange(e=>{this.group===this.panel.group&&this._onDidLocationChange.fire(e)}),this.group.api.onDidActiveChange(()=>{this.group===this.panel.group&&i!==this.isGroupActive&&(i=this.isGroupActive,this._onDidActiveGroupChange.fire({isActive:this.isGroupActive}))}))}}class Ot extends l{get params(){return this._params}get title(){return this._title}get group(){return this._group}get renderer(){var e;return null!==(e=this._renderer)&&void 0!==e?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,s,o,n,r,a){super(),this.id=e,this.accessor=s,this.containerApi=o,this.view=r,this._renderer=a.renderer,this._group=n,this._minimumWidth=a.minimumWidth,this._minimumHeight=a.minimumHeight,this._maximumWidth=a.maximumWidth,this._maximumHeight=a.maximumHeight,this.api=new Et(this,this._group,s,t,i),this.addDisposables(this.api.onActiveChange(()=>{s.setActivePanel(this)}),this.api.onDidSizeChange(e=>{this.group.api.setSize(e)}),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 We;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.view.setTitle(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({},null!==(t=this._params)&&void 0!==t?t:{}),e.params);for(const t of Object.keys(e.params))void 0===e.params[t]&&delete this._params[t];this.view.update({params:this._params})}updateFromStateModel(e){var t,i,s;this._maximumHeight=e.maximumHeight,this._minimumHeight=e.minimumHeight,this._maximumWidth=e.maximumWidth,this._minimumWidth=e.minimumWidth,this.update({params:null!==(t=e.params)&&void 0!==t?t:{}}),this.setTitle(null!==(i=e.title)&&void 0!==i?i:this.id),this.setRenderer(null!==(s=e.renderer)&&void 0!==s?s:this.accessor.renderer)}updateParentGroup(e,t){this._group=e,this.api.group=this._group;const i=this._group.model.isPanelActive(this),s=this.group.api.isActive&&i;(null==t?void 0:t.skipSetActive)||this.api.isActive!==s&&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 Mt extends l{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(ut({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"})),this._element.appendChild(this._content),this._element.appendChild(this.action),this.render()}init(e){this._title=e.title,this.addDisposables(e.api.onDidTitleChange(e=>{this._title=e.title,this.render()}),v(this.action,"pointerdown",e=>{e.preventDefault()}),v(this.action,"click",t=>{t.defaultPrevented||(t.preventDefault(),e.api.close())})),this.render()}render(){var e;this._content.textContent!==this._title&&(this._content.textContent=null!==(e=this._title)&&void 0!==e?e:"")}}class kt{get content(){return this._content}get tab(){return this._tab}constructor(e,t,i,s){this.accessor=e,this.id=t,this.contentComponent=i,this.tabComponent=s,this._content=this.createContentComponent(this.id,i),this._tab=this.createTabComponent(this.id,s)}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&&(null===(t=i.update)||void 0===t||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"}))}setTitle(e){this._params&&(this._params.title=e)}layout(e,t){var i,s;null===(s=(i=this.content).layout)||void 0===s||s.call(i,e,t)}update(e){var t,i,s,o;this._updateEvent=e,null===(i=(t=this.content).update)||void 0===i||i.call(t,e),null===(o=(s=this.tab).update)||void 0===o||o.call(s,e)}dispose(){var e,t,i,s;null===(t=(e=this.content).dispose)||void 0===t||t.call(e),null===(s=(i=this.tab).dispose)||void 0===s||s.call(i)}createContentComponent(e,t){return this.accessor.options.createComponent({id:e,name:t})}createTabComponent(e,t){const i=null!=t?t:this.accessor.options.defaultTabComponent;if(i){if(this.accessor.options.createTabComponent){const t=this.accessor.options.createTabComponent({id:e,name:i});return t||new Mt}console.warn(`dockview: tabComponent '${t}' was not found. falling back to the default tab.`)}return new Mt}}class Vt{constructor(e){this.accessor=e}fromJSON(e,t){var i,s;const o=e.id,n=e.params,r=e.title,a=e.view,l=a?a.content.id:null!==(i=e.contentComponent)&&void 0!==i?i:"unknown",h=a?null===(s=a.tab)||void 0===s?void 0:s.id:e.tabComponent,d=new kt(this.accessor,o,l,h),p=new Ot(o,l,h,this.accessor,new ge(this.accessor),t,d,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return p.init({title:null!=r?r:o,params:null!=n?n:{}}),p}}class Lt extends l{get element(){return this._element}constructor(){super(),this._element=document.createElement("div"),this._element.className="dv-watermark"}init(e){}}const Nt=new class{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) + ${2*e})`}};class Rt extends l{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 m,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new m,this.onDidChangeEnd=this._onDidChangeEnd.event,this._onDidStartMoving=new m,this.onDidStartMoving=this._onDidStartMoving.event,this._dragMove=new h,this._dragCancelled=!1,this.addDisposables(this._onDidChange,this._onDidChangeEnd,this._onDidStartMoving,this._dragMove),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})),Nt.push(this._element)}setVisible(e){e!==this.isVisible&&(this._isVisible=e,D(this.element,"dv-hidden",!this.isVisible))}bringToFront(){Nt.push(this._element)}setBounds(e={}){"number"==typeof e.height&&(this._element.style.height=`${e.height}px`),"number"==typeof e.width&&(this._element.style.width=`${e.width}px`),"top"in e&&"number"==typeof e.top&&(this._element.style.top=`${e.top}px`,this._element.style.bottom="auto",this.verticalAlignment="top"),"bottom"in e&&"number"==typeof e.bottom&&(this._element.style.bottom=`${e.bottom}px`,this._element.style.top="auto",this.verticalAlignment="bottom"),"left"in e&&"number"==typeof e.left&&(this._element.style.left=`${e.left}px`,this._element.style.right="auto",this.horiziontalAlignment="left"),"right"in e&&"number"==typeof e.right&&(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(),s=Math.max(0,this.getMinimumWidth(i.width)),o=Math.max(0,this.getMinimumHeight(i.height));if("top"===this.verticalAlignment){const e=L(i.top-t.top,-o,Math.max(0,t.height-i.height+o));this._element.style.top=`${e}px`,this._element.style.bottom="auto"}if("bottom"===this.verticalAlignment){const e=L(t.bottom-i.bottom,-o,Math.max(0,t.height-i.height+o));this._element.style.bottom=`${e}px`,this._element.style.top="auto"}if("left"===this.horiziontalAlignment){const e=L(i.left-t.left,-s,Math.max(0,t.width-i.width+s));this._element.style.left=`${e}px`,this._element.style.right="auto"}if("right"===this.horiziontalAlignment){const e=L(t.right-i.right,-s,Math.max(0,t.width-i.width+s));this._element.style.right=`${e}px`,this._element.style.left="auto"}this._onDidChange.fire()}toJSON(){const e=this.options.container.getBoundingClientRect(),t=this._element.getBoundingClientRect(),i={};return"top"===this.verticalAlignment?i.top=parseFloat(this._element.style.top):"bottom"===this.verticalAlignment?i.bottom=parseFloat(this._element.style.bottom):i.top=t.top-e.top,"left"===this.horiziontalAlignment?i.left=parseFloat(this._element.style.left):"right"===this.horiziontalAlignment?i.right=parseFloat(this._element.style.right):i.left=t.left-e.left,i.width=t.width,i.height=t.height,i}cancelPendingDrag(){this._dragMove.value&&(this._dragCancelled=!0,D(this._element,"dv-resize-container-dragging",!1),this._dragMove.value=e.DockviewDisposable.NONE)}setupDrag(t,i={inDragMode:!1}){const s=(t,i)=>{let s=null,o=!1;this._dragCancelled=!1;const n=T();if(t&&"number"==typeof i&&"function"==typeof t.setPointerCapture)try{t.setPointerCapture(i)}catch(e){}const r=()=>{D(this._element,"dv-resize-container-dragging",!1),this._dragMove.value=e.DockviewDisposable.NONE,this._onDidChangeEnd.fire()};this._dragMove.value=new l({dispose:()=>{if(n.release(),t&&"number"==typeof i&&"function"==typeof t.releasePointerCapture)try{t.releasePointerCapture(i)}catch(e){}}},v(window,"pointermove",e=>{if(this._dragCancelled)return;const t=this.options.container.getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top;D(this._element,"dv-resize-container-dragging",!0);const r=this._element.getBoundingClientRect();null===s&&(s={x:e.clientX-r.left,y:e.clientY-r.top});const a=Math.max(0,this.getMinimumWidth(r.width)),l=Math.max(0,this.getMinimumHeight(r.height)),h=L(n-s.y,-l,Math.max(0,t.height-r.height+l)),d=L(s.y-n+t.height-r.height,-l,Math.max(0,t.height-r.height+l)),p=L(i-s.x,-a,Math.max(0,t.width-r.width+a)),c=L(s.x-i+t.width-r.width,-a,Math.max(0,t.width-r.width+a)),u={};h<=d?u.top=h:u.bottom=d,p<=c?u.left=p:u.right=c,this.setBounds(u),o||(o=!0,this._onDidStartMoving.fire())}),v(window,"pointerup",r),v(window,"pointercancel",r))};this.addDisposables(v(t,"pointerdown",e=>{e.defaultPrevented?e.preventDefault():G(e)||s(t,e.pointerId)}),v(this.options.content,"pointerdown",e=>{e.defaultPrevented||G(e)||e.shiftKey&&s(this.options.content,e.pointerId)}),v(this.options.content,"pointerdown",()=>{Nt.push(this._element)},!0)),i.inDragMode&&s()}setupResize(e){const t=document.createElement("div");t.className=`dv-resize-handle-${e}`,this._element.appendChild(t);const i=new h;this.addDisposables(i,v(t,"pointerdown",s=>{s.preventDefault();let o=null;const n=T(),r=s.pointerId;if("function"==typeof t.setPointerCapture)try{t.setPointerCapture(r)}catch(e){}const a=()=>{i.dispose(),this._onDidChangeEnd.fire()};i.value=new l(v(window,"pointermove",t=>{const i=this.options.container.getBoundingClientRect(),s=this._element.getBoundingClientRect(),n=t.clientY-i.top,r=t.clientX-i.left;let a,l,h,d,p,c;null===o&&(o={originalY:n,originalHeight:s.height,originalX:r,originalWidth:s.width});const u=()=>{const e=o.originalY+o.originalHeight>i.height?Math.max(0,i.height-Rt.MINIMUM_HEIGHT):Math.max(0,o.originalY+o.originalHeight-Rt.MINIMUM_HEIGHT);a=L(n,0,e),h=o.originalY+o.originalHeight-a,l=i.height-a-h},m=()=>{a=o.originalY-o.originalHeight;const e=a<0&&"number"==typeof this.options.minimumInViewportHeight?-a+this.options.minimumInViewportHeight:Rt.MINIMUM_HEIGHT,t=i.height-Math.max(0,a);h=L(n-a,e,t),l=i.height-a-h},v=()=>{const e=o.originalX+o.originalWidth>i.width?Math.max(0,i.width-Rt.MINIMUM_WIDTH):Math.max(0,o.originalX+o.originalWidth-Rt.MINIMUM_WIDTH);d=L(r,0,e),c=o.originalX+o.originalWidth-d,p=i.width-d-c},g=()=>{d=o.originalX-o.originalWidth;const e=d<0&&"number"==typeof this.options.minimumInViewportWidth?-d+this.options.minimumInViewportWidth:Rt.MINIMUM_WIDTH,t=i.width-Math.max(0,d);c=L(r-d,e,t),p=i.width-d-c};switch(e){case"top":u();break;case"bottom":m();break;case"left":v();break;case"right":g();break;case"topleft":u(),v();break;case"topright":u(),g();break;case"bottomleft":m(),v();break;case"bottomright":m(),g()}const _={};a<=l?_.top=a:_.bottom=l,d<=p?_.left=d:_.right=p,_.height=h,_.width=c,this.setBounds(_)}),{dispose:()=>{if(n.release(),"function"==typeof t.releasePointerCapture)try{t.releasePointerCapture(r)}catch(e){}}},v(window,"pointerup",a),v(window,"pointercancel",a))}))}getMinimumWidth(e){return"number"==typeof this.options.minimumInViewportWidth?e-this.options.minimumInViewportWidth:0}getMinimumHeight(e){return"number"==typeof this.options.minimumInViewportHeight?e-this.options.minimumInViewportHeight:0}dispose(){Nt.destroy(this._element),this._element.remove(),super.dispose()}}Rt.MINIMUM_HEIGHT=20,Rt.MINIMUM_WIDTH=20;class Wt extends l{constructor(e,t){super(),this.group=e,this.overlay=t,this.addDisposables(t)}position(e){this.overlay.setBounds(e)}}const Ht=100,Ft=100,Bt=100,$t=300,Ut=300;class Yt{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=P(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}))}}class Xt extends l{constructor(t,i){super(),this.element=t,this.accessor=i,this.map={},this._disposed=!1,this.positionCache=new Yt,this.pendingUpdates=new Set,this.addDisposables(e.DockviewDisposable.from(()=>{for(const e of Object.values(this.map))e.disposable.dispose(),e.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(t){const{panel:i,referenceContainer:s}=t;if(!this.map[i.api.id]){const t=function(){const e=document.createElement("div");return e.tabIndex=-1,e}();t.className="dv-render-overlay",t.style.visibility="hidden",this.map[i.api.id]={panel:i,disposable:e.DockviewDisposable.NONE,destroy:e.DockviewDisposable.NONE,element:t}}const o=this.map[i.api.id].element,n=i.view.content.element;n.parentElement!==o&&o.appendChild(n),o.parentElement!==this.element&&this.element.appendChild(o);const r=()=>{const e=i.api.id;this.pendingUpdates.has(e)||(this.pendingUpdates.add(e),requestAnimationFrame(()=>{if(this.pendingUpdates.delete(e),this.isDisposed||!this.map[e])return;const t=this.positionCache.getPosition(s.element),n=this.positionCache.getPosition(this.element),r=t.left-n.left,a=t.top-n.top,l=t.width,h=t.height;o.style.left=`${r}px`,o.style.top=`${a}px`,o.style.width=`${l}px`,o.style.height=`${h}px`,i.api.isVisible?(o.style.visibility="",o.style.pointerEvents=""):(o.style.visibility="hidden",o.style.pointerEvents="none"),D(o,"dv-render-overlay-float","floating"===i.group.api.location.type)}))},a=()=>{i.api.isVisible?(this.positionCache.invalidate(),r(),o.style.pointerEvents=""):(o.style.visibility="hidden",o.style.pointerEvents="none")},d=new h,p=()=>{"floating"===i.api.location.type?queueMicrotask(()=>{const t=this.accessor.floatingGroups.find(e=>e.group===i.api.group);if(!t)return;const s=t.overlay.element,n=()=>{const e=Number(s.getAttribute("aria-level"));o.style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${2*e+1})`},r=new MutationObserver(()=>{n()});d.value=e.DockviewDisposable.from(()=>r.disconnect()),r.observe(s,{attributeFilter:["aria-level"],attributes:!0}),n()}):o.style.zIndex=""},c=new l(d,new _e(o,{onDragEnd:e=>{s.dropTarget.dnd.onDragEnd(e)},onDragEnter:e=>{s.dropTarget.dnd.onDragEnter(e)},onDragLeave:e=>{s.dropTarget.dnd.onDragLeave(e)},onDrop:e=>{s.dropTarget.dnd.onDrop(e)},onDragOver:e=>{s.dropTarget.dnd.onDragOver(e)}}),i.api.onDidVisibilityChange(()=>{a()}),i.api.onDidDimensionsChange(()=>{i.api.isVisible&&r()}),i.api.onDidLocationChange(()=>{p()}));return this.map[i.api.id].destroy=e.DockviewDisposable.from(()=>{var e;n.parentElement===o&&o.removeChild(n),null===(e=o.parentElement)||void 0===e||e.removeChild(o)}),p(),queueMicrotask(()=>{this.isDisposed||a()}),this.map[i.api.id].disposable.dispose(),this.map[i.api.id].disposable=c,this.map[i.api.id].resize=r,o}}function Jt(e,t,i,s){return new(i||(i=Promise))(function(o,n){function r(e){try{l(s.next(e))}catch(e){n(e)}}function a(e){try{l(s.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,a)}l((s=s.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class jt extends l{get window(){var e,t;return null!==(t=null===(e=this._window)||void 0===e?void 0:e.value)&&void 0!==t?t:null}constructor(e,t,i){super(),this.target=e,this.className=t,this.options=i,this._onWillClose=new m,this.onWillClose=this._onWillClose.event,this._onDidClose=new m,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;return{top:this._window.value.screenY,left:e,width:this._window.value.innerWidth,height:this._window.value.innerHeight}}close(){var e,t;this._window&&(this._onWillClose.fire(),null===(t=(e=this.options).onWillClose)||void 0===t||t.call(e,{id:this.target,window:this._window.value}),this._window.disposable.dispose(),this._window=null,this._onDidClose.fire())}open(){return Jt(this,void 0,void 0,function*(){var t,i;if(this._window)throw new Error("instance of popout window is already open");const s=`${this.options.url}`;!function(e){let t;try{t=new URL(e,window.location.href)}catch(t){throw new Error(`dockview: invalid popout URL: ${e}`)}if("http:"!==t.protocol&&"https:"!==t.protocol||t.origin!==window.location.origin)throw new Error(`dockview: popout URL must be same-origin http(s); got: ${e}`)}(s);const o=Object.entries({top:this.options.top,left:this.options.left,width:this.options.width,height:this.options.height}).map(([e,t])=>`${e}=${t}`).join(","),n=window.open(s,this.target,o);if(!n)return null;const r=new l;this._window={value:n,disposable:r},r.addDisposables(e.DockviewDisposable.from(()=>{n.close()}),v(window,"beforeunload",()=>{this.close()}));const a=this.createPopoutWindowContainer();return this.className&&a.classList.add(this.className),null===(i=(t=this.options).onDidOpen)||void 0===i||i.call(t,{id:this.target,window:n}),new Promise((e,t)=>{n.addEventListener("unload",e=>{}),n.addEventListener("load",()=>{try{const t=n.document;t.title=document.title,t.body.appendChild(a),function(e,t,i={}){const s=Array.from(t),{nonce:o}=i,n="function"==typeof o?o(e):o;for(const t of s){if(t.href){const i=e.createElement("link");i.href=t.href,i.type=t.type,i.rel="stylesheet",e.head.appendChild(i);continue}let i=[];try{t.cssRules&&(i=Array.from(t.cssRules).map(e=>e.cssText))}catch(e){console.warn("dockview: failed to access stylesheet rules due to security restrictions",e)}const s=e.createDocumentFragment();for(const t of i){const i=e.createElement("style");n&&i.setAttribute("nonce",n),i.appendChild(e.createTextNode(t)),s.appendChild(i)}e.head.appendChild(s)}}(t,window.document.styleSheets,{nonce:this.options.nonce}),v(n,"beforeunload",()=>{this.close()}),e(a)}catch(e){t(e)}})})})}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 Zt extends l{constructor(e){super(),this.accessor=e,this.init()}init(){const e=new Set,t=new Set;this.addDisposables(this.accessor.onDidAddPanel(t=>{if(e.has(t.api.id))throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${t.api.id} but panel already exists`);e.add(t.api.id)}),this.accessor.onDidRemovePanel(t=>{if(!e.has(t.api.id))throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${t.api.id} but panel does not exists`);e.delete(t.api.id)}),this.accessor.onDidAddGroup(e=>{if(t.has(e.api.id))throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${e.api.id} but group already exists`);t.add(e.api.id)}),this.accessor.onDidRemoveGroup(e=>{if(!t.has(e.api.id))throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${e.api.id} but group does not exists`);t.delete(e.api.id)}))}}class qt extends l{constructor(t,i=window){super(),this._active=null,this._activeDisposable=new h,this._root=t,this._window=i,this._element=i.document.createElement("div"),this._element.className="dv-popover-anchor",this._element.style.position="relative",this._root.prepend(this._element),this.addDisposables(e.DockviewDisposable.from(()=>{this.close()}),this._activeDisposable)}updateRoot(e){e.prepend(this._element),this._root=e}openPopover(e,t){var i;this.close();const s=this._window.document.createElement("div");s.style.position="absolute",s.style.zIndex=null!==(i=t.zIndex)&&void 0!==i?i:"var(--dv-overlay-z-index)",s.appendChild(e);const o=this._element.getBoundingClientRect(),n=o.left,r=o.top;s.style.top=t.y-r+"px",s.style.left=t.x-n+"px",this._element.appendChild(s),this._active=s;const a=Date.now();this._activeDisposable.value=new l(v(this._window,"pointerdown",e=>{var t;if(Date.now()-a<200)return;const i=e.target;if(!(i instanceof HTMLElement))return;let o=i;for(;o&&o!==s;)o=null!==(t=null==o?void 0:o.parentElement)&&void 0!==t?t:null;o||this.close()}),v(this._window,"keydown",e=>{"Escape"!==e.key&&"Enter"!==e.key||this.close()}),v(this._window,"resize",()=>{(function(e){if(!e.matchMedia)return!1;const t=e.matchMedia("(pointer: coarse)").matches,i=e.matchMedia("(pointer: fine)").matches;return t&&!i})(this._window)||this.close()})),this._window.requestAnimationFrame(()=>{!function(e,t,i={buffer:10}){const s=i.buffer,o=e.getBoundingClientRect(),n=t.getBoundingClientRect();let r=0,a=0;const l=o.left-n.left,h=o.top-n.top,d=o.bottom-n.bottom,p=o.right-n.right;l<s?r=s-l:p>s&&(r=-s-p),h<s?a=s-h:d>s&&(a=-d-s),0===r&&0===a||(e.style.transform=`translate(${r}px, ${a}px)`)}(s,this._root)})}close(){this._active&&(this._active.remove(),this._activeDisposable.dispose(),this._active=null)}}function Kt(e){if(!(e instanceof HTMLElement))return;const t=A(e);return(null==t?void 0:t.style.zIndex)?`calc(${t.style.zIndex} * 2)`:void 0}let Qt=0;const ei=()=>"dv-ctx-menu-item-"+Qt++;function ti(e){return"object"==typeof e}function ii(e,t,i,s){const o=document.createElement("div");return o.className="dv-context-menu-item",o.setAttribute("role","menuitem"),s&&(o.classList.add("dv-context-menu-item--disabled"),o.setAttribute("aria-disabled","true")),o.textContent=e,s||o.addEventListener("click",()=>{i(),t()}),o}function si(){const e=document.createElement("div");return e.className="dv-context-menu-separator",e.setAttribute("role","separator"),e}function oi(e){const t=document.createElement("div");t.className="dv-context-menu-rename";const i=document.createElement("input");return i.className="dv-context-menu-rename-input",i.type="text",i.placeholder="Name This Group",i.value=e.label,i.addEventListener("input",()=>{e.setLabel(i.value)}),i.addEventListener("keydown",e=>{"Escape"!==e.key&&"Enter"!==e.key&&e.stopPropagation()}),i.addEventListener("click",e=>{e.stopPropagation()}),t.appendChild(i),function(){if("undefined"==typeof window||!window.matchMedia)return!1;const e=window.matchMedia("(pointer: coarse)").matches,t=window.matchMedia("(pointer: fine)").matches;return e&&!t}()||requestAnimationFrame(()=>{i.focus(),i.select()}),t}function ni(e,t){const i=document.createElement("div");if(i.className="dv-context-menu-color-picker",!t.enabled)return i;for(const s of t.entries()){const t=document.createElement("div");t.className="dv-context-menu-color-swatch",t.style.setProperty("--dv-tab-group-color",s.value),s.label&&(t.title=s.label),e.color===s.id&&t.classList.add("dv-context-menu-color-swatch--selected"),t.addEventListener("click",()=>{e.setColor(s.id)}),i.appendChild(t)}return i}class ri{constructor(e){this.accessor=e}show(e,t,i){var s,o;if(!this.accessor.options.getTabContextMenuItems)return;const n=this.accessor.options.getTabContextMenuItems({panel:e,group:t,api:this.accessor.api,event:i});if(0===n.length)return;i.preventDefault();const r=this.accessor.getPopupServiceForGroup(t),a=()=>r.close(),l=document.createElement("div");l.className="dv-context-menu",l.setAttribute("role","menu");for(const i of n)if("separator"===i)l.appendChild(si());else if("close"===i)l.appendChild(ii("Close",a,()=>e.api.close()));else if("closeOthers"===i)l.appendChild(ii("Close Others",a,()=>{t.panels.filter(t=>t!==e).forEach(e=>e.api.close())}));else if("closeAll"===i)l.appendChild(ii("Close All",a,()=>{[...t.panels].forEach(e=>e.api.close())}));else if(ti(i)&&i.element)l.appendChild(i.element);else if(ti(i)&&i.component){const n=null===(o=(s=this.accessor.options).createContextMenuItemComponent)||void 0===o?void 0:o.call(s,{id:ei(),component:i.component});n&&(n.init({panel:e,group:t,api:this.accessor.api,close:a,componentProps:i.componentProps}),l.appendChild(n.element))}else ti(i)&&i.label&&l.appendChild(ii(i.label,a,()=>{var e;return null===(e=i.action)||void 0===e?void 0:e.call(i)},i.disabled));r.openPopover(l,{x:i.clientX,y:i.clientY,zIndex:Kt(i.target)})}showForChip(e,t,i){if(!this.accessor.options.getTabGroupChipContextMenuItems)return;const s=this.accessor.options.getTabGroupChipContextMenuItems({tabGroup:e,group:t,api:this.accessor.api,event:i});if(0===s.length)return;i.preventDefault();const o=this.accessor.getPopupServiceForGroup(t),n=()=>o.close(),r=document.createElement("div");r.className="dv-context-menu",r.setAttribute("role","menu");for(const t of s)"separator"===t?r.appendChild(si()):"rename"===t?r.appendChild(oi(e)):"colorPicker"===t?r.appendChild(ni(e,this.accessor.tabGroupColorPalette)):ti(t)&&t.element?r.appendChild(t.element):ti(t)&&t.label&&r.appendChild(ii(t.label,n,()=>{var e;return null===(e=t.action)||void 0===e?void 0:e.call(t)},t.disabled));o.openPopover(r,{x:i.clientX,y:i.clientY,zIndex:Kt(i.target)})}}class ai extends l{get disabled(){return this._disabled}set disabled(e){var t;this.disabled!==e&&(this._disabled=e,e&&(null===(t=this.model)||void 0===t||t.clear()))}get model(){if(!this.disabled)return{clear:()=>{var e;this._model&&(null===(e=this._model.root.parentElement)||void 0===e||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 s=this.createContainer(),o=this.createAnchor();if(this._model={root:s,overlay:o,changed:i},s.appendChild(o),this.element.appendChild(s),(null==e?void 0:e.target)instanceof HTMLElement){const t=e.target.getBoundingClientRect(),i=this.element.getBoundingClientRect();o.style.left=t.left-i.left+"px",o.style.top=t.top-i.top+"px"}return this._model}}}constructor(t,i){super(),this.element=t,this._disabled=!1,this._disabled=i.disabled,this.addDisposables(e.DockviewDisposable.from(()=>{var e;null===(e=this.model)||void 0===e||e.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 li{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(t,i,s){var o,n,r;this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this.snap=!1,this.priority=e.LayoutPriority.Low,this._isCollapsed=!1,this._group=i,this._orientation=s,i.element.classList.add("dv-edge-group"),i.element.dataset.testid=`dv-edge-group-${t.id}`,this._collapsedSize=null!==(o=t.collapsedSize)&&void 0!==o?o:35,this._expandedMaximumSize=null!==(n=t.maximumSize)&&void 0!==n?n:Number.POSITIVE_INFINITY,this._expandedMinimumSize=void 0!==t.minimumSize?t.minimumSize:this._collapsedSize+50,this._lastExpandedSize=null!==(r=t.initialSize)&&void 0!==r?r:200,t.collapsed&&(this._isCollapsed=!0,i.element.classList.add("dv-edge-collapsed"))}layout(e,t){this._isCollapsed||(this._lastExpandedSize=e),"horizontal"===this._orientation?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 hi{get element(){return this._dockviewElement}constructor(t,i){this._dockviewElement=t,this._layoutDockview=i,this.priority=e.LayoutPriority.High,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this._onDidChange=new m,this.onDidChange=this._onDidChange.event}layout(e,t){this._layoutDockview(t,e)}setVisible(e){}dispose(){this._onDidChange.dispose()}}class di{get element(){return this._element}constructor(t,i=0){this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this.priority=e.LayoutPriority.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 U(this._element,{orientation:e.Orientation.VERTICAL,proportionalLayout:!1,margin:i}),this._centerIndex=0,this._splitview.addView(t,{type:"distribute"},0)}addTopView(e,t){this._splitview.addView(e,t,0),this._topIndex=0,this._centerIndex+=1,void 0!==this._bottomIndex&&(this._bottomIndex+=1)}addBottomView(e,t){const i=this._splitview.length;this._splitview.addView(e,t,i),this._bottomIndex=i}removeView(e){const t="top"===e?this._topIndex:this._bottomIndex;void 0!==t&&(this._splitview.removeView(t),"top"===e?(this._topIndex=void 0,this._centerIndex-=1,void 0!==this._bottomIndex&&(this._bottomIndex-=1)):this._bottomIndex=void 0)}layout(e,t){this._splitview.layout(t,e)}setVisible(e){}setViewVisible(e,t){const i="top"===e?this._topIndex:this._bottomIndex;void 0!==i&&this._splitview.setViewVisible(i,t)}isViewVisible(e){const t="top"===e?this._topIndex:this._bottomIndex;return void 0!==t&&this._splitview.isViewVisible(t)}getViewSize(e){const t="top"===e?this._topIndex:this._bottomIndex;return void 0!==t?this._splitview.getViewSize(t):0}resizeView(e,t){const i="top"===e?this._topIndex:this._bottomIndex;void 0!==i&&this._splitview.resizeView(i,t)}updateMargin(e){this._splitview.margin=e}dispose(){this._onDidChange.dispose(),this._splitview.dispose()}}class pi{constructor(t,i,s,o=0,n=35){this._disposables=new l,this._viewConfigs=new Map,this._currentWidth=0,this._currentHeight=0,this._gap=o,this._defaultCollapsedSize=n,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",t.appendChild(this._shellElement);const r=new hi(i,s);this._middleColumn=new di(r,o),this._outerSplitview=new U(this._shellElement,{orientation:e.Orientation.HORIZONTAL,proportionalLayout:!1,margin:o}),this._middleIndex=0,this._outerSplitview.addView(this._middleColumn,{type:"distribute"},0),this._disposables.addDisposables(f(this._shellElement,e=>{const t=Math.round(e.contentRect.width),i=Math.round(e.contentRect.height);t===this._currentWidth&&i===this._currentHeight||(this._currentWidth=t,this._currentHeight=i,this.layout(t,i))}),this._outerSplitview,this._middleColumn,r)}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 s=1+(this._viewConfigs.has("left")?1:0)+(this._viewConfigs.has("right")?1:0),o=1+(this._viewConfigs.has("top")?1:0)+(this._viewConfigs.has("bottom")?1:0),n=s>1?this._gap*(s-1)/s:0,r=o>1?this._gap*(o-1)/o:0,a="left"===e||"right"===e,l=a?n:r,h=a?"horizontal":"vertical",d=new li(function(e,t,i){var s;const o=(null!==(s=e.collapsedSize)&&void 0!==s?s:t)+i,n=Object.assign(Object.assign({},e),{collapsedSize:o});return void 0!==e.minimumSize&&(n.minimumSize=e.minimumSize+i),n}(Object.assign({collapsedSize:this._defaultCollapsedSize},t),this._defaultCollapsedSize,l),i,h),p=d.isCollapsed?d.collapsedSize:d.lastExpandedSize;switch(e){case"left":this._outerSplitview.addView(d,p,0),this._leftIndex=0,this._middleIndex+=1,void 0!==this._rightIndex&&(this._rightIndex+=1),this._leftView=d;break;case"right":{const e=this._outerSplitview.length;this._outerSplitview.addView(d,p,e),this._rightIndex=e,this._rightView=d}break;case"top":this._middleColumn.addTopView(d,p),this._topView=d;break;case"bottom":this._middleColumn.addBottomView(d,p),this._bottomView=d}return this._disposables.addDisposables(d),this.updateTheme(this._gap,this._defaultCollapsedSize),d}layout(e,t){this._outerSplitview.layout(e,t)}updateTheme(e,t){var i,s,o,n;this._gap=e,this._defaultCollapsedSize=t;const r=1+(this._viewConfigs.has("left")?1:0)+(this._viewConfigs.has("right")?1:0),a=1+(this._viewConfigs.has("top")?1:0)+(this._viewConfigs.has("bottom")?1:0),l=r>1?e*(r-1)/r:0,h=a>1?e*(a-1)/a:0;this._outerSplitview.margin=e,this._middleColumn.updateMargin(e);const d=(e,i,s)=>{var o;const n=(null!==(o=i.collapsedSize)&&void 0!==o?o:t)+s,r=i.minimumSize,a=void 0!==r?r+s:n+50;e.updateCollapsedSize(n,a)},p=this._viewConfigs.get("top");this._topView&&p&&d(this._topView,p,h);const c=this._viewConfigs.get("bottom");this._bottomView&&c&&d(this._bottomView,c,h);const u=this._viewConfigs.get("left");this._leftView&&u&&d(this._leftView,u,l);const m=this._viewConfigs.get("right");this._rightView&&m&&d(this._rightView,m,l),(null===(i=this._leftView)||void 0===i?void 0:i.isCollapsed)&&void 0!==this._leftIndex&&this._outerSplitview.resizeView(this._leftIndex,this._leftView.collapsedSize),(null===(s=this._rightView)||void 0===s?void 0:s.isCollapsed)&&void 0!==this._rightIndex&&this._outerSplitview.resizeView(this._rightIndex,this._rightView.collapsedSize),(null===(o=this._topView)||void 0===o?void 0:o.isCollapsed)&&this._middleColumn.resizeView("top",this._topView.collapsedSize),(null===(n=this._bottomView)||void 0===n?void 0:n.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,void 0!==this._rightIndex&&(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}this._disposables.removeDisposable(t),t.dispose(),this._viewConfigs.delete(e),this.updateTheme(this._gap,this._defaultCollapsedSize)}}hasEdgeGroup(e){switch(e){case"top":return void 0!==this._topView;case"bottom":return void 0!==this._bottomView;case"left":return void 0!==this._leftView;case"right":return void 0!==this._rightView}}setEdgeGroupVisible(e,t){switch(e){case"left":void 0!==this._leftIndex&&this._outerSplitview.setViewVisible(this._leftIndex,t);break;case"right":void 0!==this._rightIndex&&this._outerSplitview.setViewVisible(this._rightIndex,t);break;case"top":case"bottom":this._middleColumn.setViewVisible(e,t)}}isEdgeGroupVisible(e){switch(e){case"left":return void 0!==this._leftIndex&&this._outerSplitview.isViewVisible(this._leftIndex);case"right":return void 0!==this._rightIndex&&this._outerSplitview.isViewVisible(this._rightIndex);case"top":case"bottom":return this._middleColumn.isViewVisible(e)}}setEdgeGroupCollapsed(e,t){const i=this._getView(e);if(!i)return;i.setCollapsed(t);const s=t?i.collapsedSize:i.lastExpandedSize;switch(e){case"left":void 0!==this._leftIndex&&this._outerSplitview.resizeView(this._leftIndex,s);break;case"right":void 0!==this._rightIndex&&this._outerSplitview.resizeView(this._rightIndex,s);break;case"top":case"bottom":this._middleColumn.resizeView(e,s)}}isEdgeGroupCollapsed(e){var t,i;return null!==(i=null===(t=this._getView(e))||void 0===t?void 0:t.isCollapsed)&&void 0!==i&&i}_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&&void 0!==this._leftIndex&&(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&&void 0!==this._rightIndex&&(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,s,o,n,r,a,l,h,d,p,c,u,m,v,g,_,f,b,w;e.left&&void 0!==this._leftIndex&&(null===(t=this._leftView)||void 0===t||t.restoreExpandedSize(e.left.size),null===(i=this._leftView)||void 0===i||i.setCollapsed(null!==(s=e.left.collapsed)&&void 0!==s&&s),this._outerSplitview.resizeView(this._leftIndex,e.left.collapsed&&null!==(n=null===(o=this._leftView)||void 0===o?void 0:o.collapsedSize)&&void 0!==n?n:e.left.size),e.left.visible||this._outerSplitview.setViewVisible(this._leftIndex,!1)),e.right&&void 0!==this._rightIndex&&(null===(r=this._rightView)||void 0===r||r.restoreExpandedSize(e.right.size),null===(a=this._rightView)||void 0===a||a.setCollapsed(null!==(l=e.right.collapsed)&&void 0!==l&&l),this._outerSplitview.resizeView(this._rightIndex,e.right.collapsed&&null!==(d=null===(h=this._rightView)||void 0===h?void 0:h.collapsedSize)&&void 0!==d?d:e.right.size),e.right.visible||this._outerSplitview.setViewVisible(this._rightIndex,!1)),e.top&&(null===(p=this._topView)||void 0===p||p.restoreExpandedSize(e.top.size),null===(c=this._topView)||void 0===c||c.setCollapsed(null!==(u=e.top.collapsed)&&void 0!==u&&u),this._middleColumn.resizeView("top",e.top.collapsed&&null!==(v=null===(m=this._topView)||void 0===m?void 0:m.collapsedSize)&&void 0!==v?v:e.top.size),e.top.visible||this._middleColumn.setViewVisible("top",!1)),e.bottom&&(null===(g=this._bottomView)||void 0===g||g.restoreExpandedSize(e.bottom.size),null===(_=this._bottomView)||void 0===_||_.setCollapsed(null!==(f=e.bottom.collapsed)&&void 0!==f&&f),this._middleColumn.resizeView("bottom",e.bottom.collapsed&&null!==(w=null===(b=this._bottomView)||void 0===b?void 0:b.collapsedSize)&&void 0!==w?w:e.bottom.size),e.bottom.visible||this._middleColumn.setViewVisible("bottom",!1))}dispose(){var e;this._disposables.dispose(),null===(e=this._shellElement.parentElement)||void 0===e||e.removeChild(this._shellElement)}}const ci={activationSize:{type:"pixels",value:10},size:{type:"pixels",value:20}};function ui(e){const t=e.from.activePanel;[...e.from.panels].map(t=>{const i=e.from.model.removePanel(t);return e.from.model.renderContainer.detatch(t),i}).forEach(i=>{e.to.model.openPanel(i,{skipSetActive:t!==i,skipSetGroupActive:!0})})}class mi extends ce{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 null!==(e=this.options.defaultRenderer)&&void 0!==e?e:"onlyWhenVisible"}get defaultHeaderPosition(){var e;return null!==(e=this.options.defaultHeaderPosition)&&void 0!==e?e:"top"}get api(){return this._api}get floatingGroups(){return this._floatingGroups}get popoutRestorationPromise(){return this._popoutRestorationPromise}constructor(t,i){var s,o,r,a,l,h,d;super(t,{proportionalLayout:!0,orientation:e.Orientation.HORIZONTAL,styles:i.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:i.disableAutoResizing,locked:i.locked,margin:null!==(o=null===(s=i.theme)||void 0===s?void 0:s.gap)&&void 0!==o?o:0,className:i.className}),this.nextGroupId=N(),this._deserializer=new Vt(this),this._watermark=null,this._popoutPopupServices=new Map,this._onWillDragPanel=new m,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new m,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new m,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new m,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new m,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onUnhandledDragOverEvent=new m,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this._onDidRemovePanel=new m,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new m,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPopoutGroupSizeChange=new m,this.onDidPopoutGroupSizeChange=this._onDidPopoutGroupSizeChange.event,this._onDidPopoutGroupPositionChange=new m,this.onDidPopoutGroupPositionChange=this._onDidPopoutGroupPositionChange.event,this._onDidOpenPopoutWindowFail=new m,this.onDidOpenPopoutWindowFail=this._onDidOpenPopoutWindowFail.event,this._onDidLayoutFromJSON=new m,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new m({replay:!0}),this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidMovePanel=new m,this.onDidMovePanel=this._onDidMovePanel.event,this._onDidCreateTabGroup=new m,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new m,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new m,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new m,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new m,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new m,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,this._onDidMaximizedGroupChange=new m,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._popoutRestorationCleanups=new Set,this._onDidRemoveGroup=new m,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new m,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidOptionsChange=new m,this.onDidOptionsChange=this._onDidOptionsChange.event,this._onDidActiveGroupChange=new m,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._moving=!1,this._options=i,this._tabGroupColorPalette=function(e){var t;const i=null!==(t=e.tabGroupColors)&&void 0!==t?t:et,s="off"!==e.tabGroupAccent;return new tt(i,s)}(i),this.popupService=new qt(this.element),this.contextMenuController=new ri(this),this._api=new ge(this),this.disableResizing=!0,t.removeChild(this.element),this._shellManager=new pi(t,this.element,(e,t)=>this._layoutFromShell(e,t),null!==(a=null===(r=i.theme)||void 0===r?void 0:r.gap)&&void 0!==a?a:0,null===(l=i.theme)||void 0===l?void 0:l.edgeGroupCollapsedSize),this.popupService.updateRoot(this._shellManager.element),this._shellThemeClassnames=new I(this._shellManager.element),this.rootDropTargetContainer=new ai(this._shellManager.element,{disabled:!0}),this.overlayRenderContainer=new Xt(this._shellManager.element,this),this._floatingOverlayHost=document.createElement("div"),this._floatingOverlayHost.className="dv-floating-overlay-host",this._shellManager.element.appendChild(this._floatingOverlayHost);const p=(e,t)=>{const i=n();if(i)return i.viewId===this.id&&("center"!==t||0===this.gridview.length);if("center"===t&&0!==this.gridview.length)return!1;const s=new gt(e,"edge",t,n);return this._onUnhandledDragOverEvent.fire(s),s.isAccepted};this._rootDropTarget=Ve.createDropTarget(this.element,{className:"dv-drop-target-edge",canDisplayOverlay:p,acceptedTargetZones:["top","bottom","left","right","center"],overlayModel:null!==(h=i.rootOverlayModel)&&void 0!==h?h:ci,getOverrideTarget:()=>{var e;return null===(e=this.rootDropTargetContainer)||void 0===e?void 0:e.model}}),this._rootPointerDropTarget=Le.createDropTarget(this.element,{className:"dv-drop-target-edge",canDisplayOverlay:p,acceptedTargetZones:["top","bottom","left","right","center"],overlayModel:null!==(d=i.rootOverlayModel)&&void 0!==d?d:ci,getOverrideTarget:()=>{var e;return null===(e=this.rootDropTargetContainer)||void 0===e?void 0:e.model}}),this.updateDropTargetModel(i),D(this.gridview.element,"dv-dockview",!0),D(this.element,"dv-debug",!!i.debug),this.updateTheme(),this.updateWatermark(),i.debug&&this.addDisposables(new Zt(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(e=>{this._moving||this._onDidAddGroup.fire(e)}),this.onDidRemove(e=>{this._moving||this._onDidRemoveGroup.fire(e)}),this.onDidActiveChange(e=>{this._moving||this._onDidActiveGroupChange.fire(e)}),this.onDidMaximizedChange(e=>{this._onDidMaximizedGroupChange.fire({group:e.panel,isMaximized:e.isMaximized})}),e.DockviewEvent.any(this.onDidAdd,this.onDidRemove)(()=>{this.updateWatermark()}),e.DockviewEvent.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()}),e.DockviewDisposable.from(()=>{var e;for(const e of[...this._popoutRestorationCleanups])e();this._popoutRestorationCleanups.clear();for(const e of[...this._floatingGroups])e.dispose();for(const e of[...this._popoutGroups])e.disposable.dispose();null===(e=this._shellManager)||void 0===e||e.dispose();for(const e of this._edgeGroupDisposables.values())e.dispose();this._edgeGroupDisposables.clear()}),this._rootDropTarget,this._rootPointerDropTarget,e.DockviewEvent.any(this._rootDropTarget.onWillShowOverlay,this._rootPointerDropTarget.onWillShowOverlay)(e=>{this.gridview.length>0&&"center"===e.position||this._onWillShowOverlay.fire(new qe(e,{kind:"edge",panel:void 0,api:this._api,group:void 0,getData:n}))}),e.DockviewEvent.any(this._rootDropTarget.onDrop,this._rootPointerDropTarget.onDrop)(e=>{var t;const i=new St({nativeEvent:e.nativeEvent,position:e.position,panel:void 0,api:this._api,group:void 0,getData:n,kind:"edge"});if(this._onWillDrop.fire(i),i.defaultPrevented)return;const s=n();s?this.moveGroupOrPanel({from:{groupId:s.groupId,panelId:null!==(t=s.panelId)&&void 0!==t?t:void 0},to:{group:this.orthogonalize(e.position),position:"center"}}):this._onDidDrop.fire(new yt({nativeEvent:e.nativeEvent,position:e.position,panel:void 0,api:this._api,group:void 0,getData:n}))}))}setVisible(e,t){switch(e.api.location.type){case"grid":super.setVisible(e,t);break;case"floating":{const i=this.floatingGroups.find(t=>t.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")}}getPopupServiceForGroup(e){var t;return null!==(t=this._popoutPopupServices.get(e.id))&&void 0!==t?t:this.popupService}addPopoutGroup(t,i){var s,o,n,r,a,h;if(t instanceof zt&&"edge"===t.model.location.type)return Promise.resolve(!1);if(t instanceof Ot&&1===t.group.size)return this.addPopoutGroup(t.group,i);const d=function(e){function t(e){const t=[];for(let i=0;i<e.classList.length;i++)t.push(e.classList.item(i));return t}let i,s=e;for(;null!==s&&(i=t(s).find(e=>e.startsWith("dockview-theme-")),"string"!=typeof i);)s=s.parentElement;return i}(this.gridview.element),p=this.element;const c=(null==i?void 0:i.position)?i.position:t instanceof zt?t.element.getBoundingClientRect():t.group?t.group.element.getBoundingClientRect():p.getBoundingClientRect(),u=null!==(o=null===(s=null==i?void 0:i.overridePopoutGroup)||void 0===s?void 0:s.id)&&void 0!==o?o:this.getNextGroupId(),g=new jt(`${this.id}-${u}`,null!=d?d:"",{url:null!==(a=null!==(n=null==i?void 0:i.popoutUrl)&&void 0!==n?n:null===(r=this.options)||void 0===r?void 0:r.popoutUrl)&&void 0!==a?a:"/popout.html",left:window.screenX+c.left,top:window.screenY+c.top,width:c.width,height:c.height,onDidOpen:null==i?void 0:i.onDidOpen,onWillClose:null==i?void 0:i.onWillClose,nonce:null===(h=this.options)||void 0===h?void 0:h.nonce}),_=new l(g,g.onDidClose(()=>{_.dispose()}));return g.open().then(s=>{var o;if(g.isDisposed)return!1;const n=(null==i?void 0:i.referenceGroup)?i.referenceGroup:t instanceof Ot?t.group:t,r=t.api.location.type,a=null!==n.element.parentElement;let h;if(a?(null==i?void 0:i.overridePopoutGroup)?h=i.overridePopoutGroup:(h=this.createGroup({id:u}),s&&this._onDidAddGroup.fire(h)):h=n,null===s)return console.error("dockview: failed to create popout. perhaps you need to allow pop-ups for this website"),_.dispose(),this._onDidOpenPopoutWindowFail.fire(),this.movingLock(()=>ui({from:h,to:n})),n.api.isVisible||n.api.setVisible(!0),!1;const d=document.createElement("div");d.className="dv-overlay-render-container";const p=new Xt(d,this);let c;if(h.model.renderContainer=p,h.layout(g.window.innerWidth,g.window.innerHeight),!(null==i?void 0:i.overridePopoutGroup)&&a)if(t instanceof Ot)this.movingLock(()=>{const e=n.model.removePanel(t);h.model.openPanel(e)});else switch(this.movingLock(()=>ui({from:n,to:h})),r){case"grid":n.api.setVisible(!1);break;case"floating":case"popout":c=null===(o=this._floatingGroups.find(e=>e.group.api.id===t.api.id))||void 0===o?void 0:o.overlay.toJSON(),this.removeGroup(n)}s.classList.add("dv-dockview"),s.style.overflow="hidden",s.appendChild(d),s.appendChild(h.element);const f=document.createElement("div"),b=new ai(f,{disabled:this.rootDropTargetContainer.disabled});s.appendChild(f),h.model.dropTargetContainer=b;const w=new qt(s,g.window);let D;this._popoutPopupServices.set(h.id,w),_.addDisposables(w,e.DockviewDisposable.from(()=>{this._popoutPopupServices.delete(h.id)})),h.model.location={type:"popout",getWindow:()=>g.window,popoutUrl:null==i?void 0:i.popoutUrl},a&&"grid"===t.api.location.type&&t.api.setVisible(!1),this.doSetGroupAndPanelActive(h),_.addDisposables(h.api.onDidActiveChange(e=>{var t;e.isActive&&(null===(t=g.window)||void 0===t||t.focus())}),h.api.onWillFocus(()=>{var e;null===(e=g.window)||void 0===e||e.focus()}));const C=a&&n&&this.getPanel(n.id),y={window:g,popoutGroup:h,referenceGroup:C?n.id:void 0,disposable:{dispose:()=>(_.dispose(),D)}},S=function(e){const t=new m;let i,s=e.screenX,o=e.screenY;const n=()=>{if(e.closed)return;const r=e.screenX,a=e.screenY;r===s&&a===o||(clearTimeout(i),i=setTimeout(()=>{t.fire()},100),s=r,o=a),requestAnimationFrame(n)};return n(),t}(g.window);return _.addDisposables(S,function(e,t){let i;return new l(v(e,"resize",()=>{clearTimeout(i),i=setTimeout(()=>{t()},100)}))}(g.window,()=>{this._onDidPopoutGroupSizeChange.fire({width:g.window.innerWidth,height:g.window.innerHeight,group:h})}),S.event(()=>{this._onDidPopoutGroupPositionChange.fire({screenX:g.window.screenX,screenY:g.window.screenX,group:h})}),v(g.window,"resize",()=>{h.layout(g.window.innerWidth,g.window.innerHeight)}),p,e.DockviewDisposable.from(()=>{if(!this.isDisposed)if(a&&this.getPanel(n.id))this.movingLock(()=>ui({from:h,to:n})),n.api.isVisible||n.api.setVisible(!0),this.getPanel(h.id)&&this.doRemoveGroup(h,{skipPopoutAssociated:!0});else if(this.getPanel(h.id)){h.model.renderContainer=this.overlayRenderContainer,h.model.dropTargetContainer=this.rootDropTargetContainer,D=h;if(!this._popoutGroups.find(e=>e.popoutGroup===h))return;c?this.addFloatingGroup(h,{height:c.height,width:c.width,position:c}):(this.doRemoveGroup(h,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),h.model.location={type:"grid"},this.movingLock(()=>{this.doAddGroup(h,[0])})),this.doSetGroupAndPanelActive(h)}})),this._popoutGroups.push(y),this.updateWatermark(),!0}).catch(e=>(console.error("dockview: failed to create popout.",e),!1))}addFloatingGroup(e,t){var i,s,o,n,r,a;if(e instanceof zt&&"edge"===e.model.location.type)return;let h;if(e instanceof Ot)h=this.createGroup(),this._onDidAddGroup.fire(h),this.movingLock(()=>this.removePanel(e,{removeEmptyGroup:!0,skipDispose:!0,skipSetActiveGroup:!0})),this.movingLock(()=>h.model.openPanel(e,{skipSetGroupActive:!0}));else{h=e;const s=null===(i=this._popoutGroups.find(e=>e.popoutGroup===h))||void 0===i?void 0:i.referenceGroup,o=s?this.getPanel(s):void 0;"boolean"==typeof(null==t?void 0:t.skipRemoveGroup)&&t.skipRemoveGroup||(o?(this.movingLock(()=>ui({from:e,to:o})),this.doRemoveGroup(e,{skipPopoutReturn:!0,skipPopoutAssociated:!0}),this.doRemoveGroup(o,{skipDispose:!0}),h=o):this.doRemoveGroup(e,{skipDispose:!0,skipPopoutReturn:!0,skipPopoutAssociated:!1}))}const d=function(){if(null==t?void 0:t.position){const e={};return"left"in t.position?e.left=Math.max(t.position.left,0):"right"in t.position?e.right=Math.max(t.position.right,0):e.left=Ft,"top"in t.position?e.top=Math.max(t.position.top,0):"bottom"in t.position?e.bottom=Math.max(t.position.bottom,0):e.top=Bt,"number"==typeof t.width?e.width=Math.max(t.width,0):e.width=$t,"number"==typeof t.height?e.height=Math.max(t.height,0):e.height=Ut,e}return{left:"number"==typeof(null==t?void 0:t.x)?Math.max(t.x,0):Ft,top:"number"==typeof(null==t?void 0:t.y)?Math.max(t.y,0):Bt,width:"number"==typeof(null==t?void 0:t.width)?Math.max(t.width,0):$t,height:"number"==typeof(null==t?void 0:t.height)?Math.max(t.height,0):Ut}}(),p=new Rt(Object.assign(Object.assign({container:null!==(s=this._floatingOverlayHost)&&void 0!==s?s:this.gridview.element,content:h.element},d),{minimumInViewportWidth:"boundedWithinViewport"===this.options.floatingGroupBounds?void 0:null!==(n=null===(o=this.options.floatingGroupBounds)||void 0===o?void 0:o.minimumWidthWithinViewport)&&void 0!==n?n:Ht,minimumInViewportHeight:"boundedWithinViewport"===this.options.floatingGroupBounds?void 0:null!==(a=null===(r=this.options.floatingGroupBounds)||void 0===r?void 0:r.minimumHeightWithinViewport)&&void 0!==a?a:Ht})),c=h.element.querySelector(".dv-void-container");if(!c)throw new Error("dockview: failed to find drag handle");p.setupDrag(c,{inDragMode:"boolean"==typeof(null==t?void 0:t.inDragMode)&&t.inDragMode});const u=new Wt(h,p),m=new l(h.api.onDidActiveChange(e=>{e.isActive&&p.bringToFront()}),(()=>{let e=-1,t=-1;return f(h.element,i=>{const s=Math.round(i.contentRect.width),o=Math.round(i.contentRect.height);s===e&&o===t||(e=s,t=o,h.layout(s,o))})})());u.addDisposables(p.onDidChange(()=>{h.layout(h.width,h.height)}),p.onDidChangeEnd(()=>{this._bufferOnDidLayoutChange.fire()}),h.onDidChange(e=>{p.setBounds({height:null==e?void 0:e.height,width:null==e?void 0:e.width})}),{dispose:()=>{m.dispose(),V(this._floatingGroups,u),h.model.location={type:"grid"},this.updateWatermark()}}),this._floatingGroups.push(u),h.model.location={type:"floating"},(null==t?void 0:t.skipActiveGroup)||this.doSetGroupAndPanelActive(h),this.updateWatermark()}orthogonalize(t,i){switch(this.gridview.normalize(),t){case"top":case"bottom":this.gridview.orientation===e.Orientation.HORIZONTAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case"left":case"right":this.gridview.orientation===e.Orientation.VERTICAL&&this.gridview.insertOrthogonalSplitviewAtRoot()}switch(t){case"top":case"left":case"center":return this.createGroupAtLocation([0],void 0,i);case"bottom":case"right":return this.createGroupAtLocation([this.gridview.length],void 0,i);default:throw new Error(`dockview: unsupported position ${t}`)}}updateOptions(e){var t,i,s,o,n;if(super.updateOptions(e),"floatingGroupBounds"in e)for(const s of this._floatingGroups){switch(e.floatingGroupBounds){case"boundedWithinViewport":s.overlay.minimumInViewportHeight=void 0,s.overlay.minimumInViewportWidth=void 0;break;case void 0:s.overlay.minimumInViewportHeight=Ht,s.overlay.minimumInViewportWidth=Ht;break;default:s.overlay.minimumInViewportHeight=null===(t=e.floatingGroupBounds)||void 0===t?void 0:t.minimumHeightWithinViewport,s.overlay.minimumInViewportWidth=null===(i=e.floatingGroupBounds)||void 0===i?void 0:i.minimumWidthWithinViewport}s.overlay.setBounds()}this.updateDropTargetModel(e);const r=this.options.disableDnd,a=this.options.dndStrategy;this._options=Object.assign(Object.assign({},this.options),e);const l=this.options.disableDnd,h=this.options.dndStrategy;if(r===l&&a===h||this.updateDragAndDropState(),"theme"in e&&this.updateTheme(),"createRightHeaderActionComponent"in e||"createLeftHeaderActionComponent"in e||"createPrefixHeaderActionComponent"in e)for(const e of this.groups)e.model.updateHeaderActions();if("createWatermarkComponent"in e){this._watermark&&(this._watermark.element.parentElement.remove(),null===(o=(s=this._watermark).dispose)||void 0===o||o.call(s),this._watermark=null),this.updateWatermark();for(const e of this.groups)e.model.refreshWatermark()}if("tabGroupColors"in e||"tabGroupAccent"in e){this._tabGroupColorPalette.setEntries(null!==(n=this._options.tabGroupColors)&&void 0!==n?n:et),this._tabGroupColorPalette.enabled="off"!==this._options.tabGroupAccent;for(const e of this.groups)e.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 e of this._floatingGroups)e.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 s=i.model.onDidRemovePanel(()=>{i.model.isEmpty&&this.setEdgeGroupCollapsed(i,!0)});return this._edgeGroupDisposables.set(e,s),this._shellManager.addEdgeView(e,t,i),i.api}getEdgeGroup(e){var t;return null===(t=this._edgeGroups.get(e))||void 0===t?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 e of[...i.panels])this.removePanel(e,{removeEmptyGroup:!1,skipDispose:!1});null===(t=this._edgeGroupDisposables.get(e))||void 0===t||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,s]of this._edgeGroups)if(s===e){if(this._shellManager.isEdgeGroupCollapsed(i)===t)return;return this._shellManager.setEdgeGroupCollapsed(i,t),void s.api._onDidCollapsedChange.fire({isCollapsed:t})}}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;null===(e=this.activeGroup)||void 0===e||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])return void e.group.model.moveToNext({suppressRoll:!0});const i=ee(e.group.element),s=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupAndPanelActive(s)}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])return void e.group.model.moveToPrevious({suppressRoll:!0});const i=ee(e.group.element),s=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;s&&this.doSetGroupAndPanelActive(s)}toJSON(){var e;const t=this.gridview.serialize(),i=this.panels.reduce((e,t)=>(e[t.id]=t.toJSON(),e),{}),s=this._floatingGroups.map(e=>({data:e.group.toJSON(),position:e.overlay.toJSON()})),o=this._popoutGroups.map(e=>({data:e.popoutGroup.toJSON(),gridReferenceGroup:e.referenceGroup,position:e.window.dimensions(),url:"popout"===e.popoutGroup.api.location.type?e.popoutGroup.api.location.popoutUrl:void 0})),n={grid:t,panels:i,activeGroup:null===(e=this.activeGroup)||void 0===e?void 0:e.id};if(s.length>0&&(n.floatingGroups=s),o.length>0&&(n.popoutGroups=o),this._edgeGroups.size>0){const e=this._shellManager.toJSON();for(const[t,i]of this._edgeGroups){const s=e[t];s&&(s.group=i.toJSON())}n.edgeGroups=e}return n}fromJSON(e,t){var i,s,o;const n=new Map;let r;if(null==t?void 0:t.reuseExistingPanels){r=this.createGroup(),this._groups.delete(r.api.id);const t=Object.keys(e.panels);for(const e of this.panels)t.includes(e.api.id)&&n.set(e.api.id,e);this.movingLock(()=>{Array.from(n.values()).forEach(e=>{this.moveGroupOrPanel({from:{groupId:e.api.group.api.id,panelId:e.api.id},to:{group:r,position:"center"},keepEmptyGroups:!0})})})}if(this.clear(),"object"!=typeof e||null===e)throw new Error("dockview: serialized layout must be a non-null object");const{grid:a,panels:l,activeGroup:h}=e;if("branch"!==a.root.type||!Array.isArray(a.root.data))throw new Error("dockview: root must be of type branch");try{const t=this.width,d=this.height,p=e=>{const{id:t,locked:i,hideHeader:s,headerPosition:o,views:a,activeView:h}=e;if("string"!=typeof t)throw new Error("dockview: group id must be of type string");const d=this.createGroup({id:t,locked:!!i,hideHeader:!!s,headerPosition:o});this._onDidAddGroup.fire(d);const p=[];for(const e of a){const t=n.get(e);if(r&&t)this.movingLock(()=>{r.model.removePanel(t)}),p.push(t),t.updateFromStateModel(l[e]);else{const t=this._deserializer.fromJSON(l[e],d);p.push(t)}}for(let e=0;e<a.length;e++){const t=p[e],i="string"==typeof h&&h===t.id;n.has(t.api.id)?this.movingLock(()=>{d.model.openPanel(t,{skipSetActive:!i,skipSetGroupActive:!0})}):d.model.openPanel(t,{skipSetActive:!i,skipSetGroupActive:!0})}return e.tabGroups&&e.tabGroups.length>0&&d.model.restoreTabGroups(e.tabGroups),!d.activePanel&&d.panels.length>0&&d.model.openPanel(d.panels[d.panels.length-1],{skipSetGroupActive:!0}),d};if(this.gridview.deserialize(a,{fromJSON:e=>p(e.data)}),this._layoutFromShell(t,d),e.edgeGroups){for(const t of["top","bottom","left","right"]){const s=e.edgeGroups[t];if(s&&!this._edgeGroups.has(t)){const e=s.group,o=null!==(i=null==e?void 0:e.id)&&void 0!==i?i:`${t}-group`;this.addEdgeGroup(t,{id:o})}}for(const[t,i]of this._edgeGroups){const s=e.edgeGroups[t],o=null==s?void 0:s.group;if(o){const{views:e,activeView:t}=o,s=[];for(const t of e)if(l[t]){const e=this._deserializer.fromJSON(l[t],i);s.push(e)}for(let e=0;e<s.length;e++){const o=s[e],n=t===o.id;i.model.openPanel(o,{skipSetActive:!n,skipSetGroupActive:!0})}o.tabGroups&&o.tabGroups.length>0&&i.model.restoreTabGroups(o.tabGroups),!i.activePanel&&i.panels.length>0&&i.model.openPanel(i.panels[i.panels.length-1],{skipSetGroupActive:!0})}}this._shellManager.fromJSON(e.edgeGroups)}const c=null!==(s=e.floatingGroups)&&void 0!==s?s:[];for(const e of c){const{data:t,position:i}=e,s=p(t);this.addFloatingGroup(s,{position:i,width:i.width,height:i.height,skipRemoveGroup:!0,inDragMode:!1})}const u=null!==(o=e.popoutGroups)&&void 0!==o?o:[],m=[];u.forEach((e,t)=>{const{data:i,position:s,gridReferenceGroup:o,url:n}=e,r=p(i),a=new Promise(e=>{const i=()=>{this._popoutRestorationCleanups.delete(i),clearTimeout(a),e()},a=setTimeout(()=>{this._popoutRestorationCleanups.delete(i),this.isDisposed||this.addPopoutGroup(r,{position:null!=s?s:void 0,overridePopoutGroup:o?r:void 0,referenceGroup:o?this.getPanel(o):void 0,popoutUrl:n}),e()},100*t);this._popoutRestorationCleanups.add(i)});m.push(a)}),this._popoutRestorationPromise=Promise.all(m).then(()=>{});for(const e of this._floatingGroups)e.overlay.setBounds();if("string"==typeof h){const e=this.getPanel(h);e&&this.doSetGroupAndPanelActive(e)}}catch(e){console.error("dockview: failed to deserialize layout. Reverting changes",e);for(const e of this.groups)for(const t of e.panels)this.removePanel(t,{removeEmptyGroup:!1,skipDispose:!1});for(const e of this.groups)e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e);for(const e of[...this._floatingGroups])e.dispose();throw this.clear(),e}this.updateWatermark(),this.debouncedUpdateAllPositions(),this._onDidLayoutFromJSON.fire()}clear(){const e=Array.from(this._groups.values()).map(e=>e.value),t=!!this.activeGroup;for(const t of e){if([...this._edgeGroups.values()].includes(t)){const e=[...t.panels];for(const t of e)this.removePanel(t,{removeEmptyGroup:!1});continue}this.removeGroup(t,{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(t){var i,s;if(this.panels.find(e=>e.id===t.id))throw new Error(`dockview: panel with id ${t.id} already exists`);let o;if(t.position&&t.floating)throw new Error("dockview: you can only provide one of: position, floating as arguments to .addPanel(...)");const n={width:t.initialWidth,height:t.initialHeight};let r,a;if(t.position)if(ft(t.position)){const e="string"==typeof t.position.referencePanel?this.getGroupPanel(t.position.referencePanel):t.position.referencePanel;if(r=t.position.index,!e)throw new Error(`dockview: referencePanel '${t.position.referencePanel}' does not exist`);o=this.findGroup(e)}else{if(!bt(t.position)){const e=this.orthogonalize(Se(t.position.direction)),i=this.createPanel(t,e);return e.model.openPanel(i,{skipSetActive:t.inactive,skipSetGroupActive:t.inactive,index:r}),t.inactive||this.doSetGroupAndPanelActive(e),e.api.setSize({height:null==n?void 0:n.height,width:null==n?void 0:n.width}),i}if(o="string"==typeof t.position.referenceGroup?null===(i=this._groups.get(t.position.referenceGroup))||void 0===i?void 0:i.value:t.position.referenceGroup,r=t.position.index,!o)throw new Error(`dockview: referenceGroup '${t.position.referenceGroup}' does not exist`)}else o=this.activeGroup;if(o){const i=pe((null===(s=t.position)||void 0===s?void 0:s.direction)||"within");if(t.floating){const e=this.createGroup();this._onDidAddGroup.fire(e);const i="object"==typeof t.floating&&null!==t.floating?t.floating:{};this.addFloatingGroup(e,Object.assign(Object.assign({},i),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),a=this.createPanel(t,e),e.model.openPanel(a,{skipSetActive:t.inactive,skipSetGroupActive:t.inactive,index:r})}else if("floating"===o.api.location.type||"edge"===o.api.location.type||"center"===i)a=this.createPanel(t,o),o.model.openPanel(a,{skipSetActive:t.inactive,skipSetGroupActive:t.inactive,index:r}),o.api.setSize({width:null==n?void 0:n.width,height:null==n?void 0:n.height}),t.inactive||this.doSetGroupAndPanelActive(o);else{const s=ee(o.element),l=te(this.gridview.orientation,s,i),h=this.createGroupAtLocation(l,this.orientationAtLocation(l)===e.Orientation.VERTICAL?null==n?void 0:n.height:null==n?void 0:n.width);a=this.createPanel(t,h),h.model.openPanel(a,{skipSetActive:t.inactive,skipSetGroupActive:t.inactive,index:r}),t.inactive||this.doSetGroupAndPanelActive(h)}}else if(t.floating){const e=this.createGroup();this._onDidAddGroup.fire(e);const i="object"==typeof t.floating&&null!==t.floating?t.floating:{};this.addFloatingGroup(e,Object.assign(Object.assign({},i),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),a=this.createPanel(t,e),e.model.openPanel(a,{skipSetActive:t.inactive,skipSetGroupActive:t.inactive,index:r})}else{const i=this.createGroupAtLocation([0],this.gridview.orientation===e.Orientation.VERTICAL?null==n?void 0:n.height:null==n?void 0:n.width);a=this.createPanel(t,i),i.model.openPanel(a,{skipSetActive:t.inactive,skipSetGroupActive:t.inactive,index:r}),t.inactive||this.doSetGroupAndPanelActive(i)}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()),0===i.size&&t.removeEmptyGroup&&this.removeGroup(i,{skipActive:t.skipSetActiveGroup})}createWatermarkComponent(){return this.options.createWatermarkComponent?this.options.createWatermarkComponent():new Lt}updateWatermark(){var e,t,i;if(0===this.groups.filter(e=>"grid"===e.api.location.type&&e.api.isVisible).length){if(!this._watermark){this._watermark=this.createWatermarkComponent(),this._watermark.init({containerApi:new ge(this)});const e=document.createElement("div");e.className="dv-watermark-container",i="watermark-component",e.setAttribute("data-testid",i),e.appendChild(this._watermark.element),this.gridview.element.appendChild(e)}}else this._watermark&&(this._watermark.element.parentElement.remove(),null===(t=(e=this._watermark).dispose)||void 0===t||t.call(e),this._watermark=null)}addGroup(t){var i;if(t){let s;if(wt(t)){const e="string"==typeof t.referencePanel?this.panels.find(e=>e.id===t.referencePanel):t.referencePanel;if(!e)throw new Error(`dockview: reference panel ${t.referencePanel} does not exist`);if(s=this.findGroup(e),!s)throw new Error(`dockview: reference group for reference panel ${t.referencePanel} does not exist`)}else{if(!Dt(t)){const e=this.orthogonalize(Se(t.direction),t);return t.skipSetActive||this.doSetGroupAndPanelActive(e),e}if(s="string"==typeof t.referenceGroup?null===(i=this._groups.get(t.referenceGroup))||void 0===i?void 0:i.value:t.referenceGroup,!s)throw new Error(`dockview: reference group ${t.referenceGroup} does not exist`)}const o=pe(t.direction||"within"),n=ee(s.element),r=te(this.gridview.orientation,n,o),a=this.createGroup(t),l=this.getLocationOrientation(r)===e.Orientation.VERTICAL?t.initialHeight:t.initialWidth;return this.doAddGroup(a,r,l),t.skipSetActive||this.doSetGroupAndPanelActive(a),a}{const e=this.createGroup(t);return this.doAddGroup(e),this.doSetGroupAndPanelActive(e),e}}getLocationOrientation(t){return t.length%2==0&&this.gridview.orientation===e.Orientation.HORIZONTAL?e.Orientation.HORIZONTAL:e.Orientation.VERTICAL}removeGroup(e,t){this.doRemoveGroup(e,t)}doRemoveGroup(e,t){var i;if([...this._edgeGroups.values()].includes(e))return e;const s=[...e.panels];if(!(null==t?void 0:t.skipDispose))for(const e of s)this.removePanel(e,{removeEmptyGroup:!1,skipDispose:null!==(i=null==t?void 0:t.skipDispose)&&void 0!==i&&i});const o=this.activePanel;if("floating"===e.api.location.type){const i=this._floatingGroups.find(t=>t.group===e);if(i){if((null==t?void 0:t.skipDispose)||(i.group.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)),V(this._floatingGroups,i),i.dispose(),!(null==t?void 0:t.skipActive)&&this._activeGroup===e){const e=Array.from(this._groups.values());this.doSetGroupAndPanelActive(e.length>0?e[0].value:void 0)}return i.group}throw new Error("dockview: failed to find floating group")}if("popout"===e.api.location.type){const i=this._popoutGroups.find(t=>t.popoutGroup===e);if(i){if(!(null==t?void 0:t.skipDispose)){if(!(null==t?void 0:t.skipPopoutAssociated)){const e=i.referenceGroup?this.getPanel(i.referenceGroup):void 0;e&&0===e.panels.length&&this.removeGroup(e)}i.popoutGroup.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}V(this._popoutGroups,i);const s=i.disposable.dispose();if(!(null==t?void 0:t.skipPopoutReturn)&&s&&(this.doAddGroup(s,[0]),this.doSetGroupAndPanelActive(s)),!(null==t?void 0:t.skipActive)&&this._activeGroup===e){const e=Array.from(this._groups.values());this.doSetGroupAndPanelActive(e.length>0?e[0].value:void 0)}return this.updateWatermark(),i.popoutGroup}throw new Error("dockview: failed to find popout group")}const n=super.doRemoveGroup(e,t);return(null==t?void 0:t.skipActive)||this.activePanel!==o&&this._onDidActivePanelChange.fire(this.activePanel),n}debouncedUpdateAllPositions(){void 0!==this._updatePositionsFrameId&&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,s=e.from.groupId,o=e.from.panelId,n=e.to.position,r=e.to.index,a=s?null===(t=this._groups.get(s))||void 0===t?void 0:t.value:void 0;if(!a)throw new Error(`dockview: Failed to find group id ${s}`);if(void 0!==o)if(n&&"center"!==n){const e=ee(i.element),t=te(this.gridview.orientation,e,n);if(a.size<2){const[e,s]=E(t);if("grid"===a.api.location.type){const t=ee(a.element),[i,n]=E(t);if(O(i,e))return this.gridview.moveView(i,n,s),void this._onDidMovePanel.fire({panel:this.getGroupPanel(o),from:a})}if("popout"===a.api.location.type){const e=this._popoutGroups.find(e=>e.popoutGroup===a),t=this.movingLock(()=>e.popoutGroup.model.removePanel(e.popoutGroup.panels[0],{skipSetActive:!0,skipSetActiveGroup:!0}));this.doRemoveGroup(a,{skipActive:!0});const s=te(this.gridview.orientation,ee(i.element),n),r=this.createGroupAtLocation(s);return this.movingLock(()=>r.model.openPanel(t,{skipSetActive:!0})),this.doSetGroupAndPanelActive(r),void this._onDidMovePanel.fire({panel:this.getGroupPanel(o),from:a})}if("edge"===a.api.location.type){const e=this.movingLock(()=>a.model.removePanel(o,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!e)throw new Error(`dockview: No panel with id ${o}`);const i=this.createGroupAtLocation(t);return this.movingLock(()=>i.model.openPanel(e,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(i),void this._onDidMovePanel.fire({panel:e,from:a})}const r=this.movingLock(()=>this.doRemoveGroup(a,{skipActive:!0,skipDispose:!0})),l=ee(i.element),h=te(this.gridview.orientation,l,n);this.movingLock(()=>this.doAddGroup(r,h)),this.doSetGroupAndPanelActive(r),this._onDidMovePanel.fire({panel:this.getGroupPanel(o),from:a})}else{const t=this.movingLock(()=>a.model.removePanel(o,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!t)throw new Error(`dockview: No panel with id ${o}`);const i=te(this.gridview.orientation,e,n),s=this.createGroupAtLocation(i);this.movingLock(()=>s.model.openPanel(t,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(s),this._onDidMovePanel.fire({panel:t,from:a})}}else{const t=this.movingLock(()=>a.model.removePanel(o,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!t)throw new Error(`dockview: No panel with id ${o}`);e.keepEmptyGroups||0!==a.model.size||this.doRemoveGroup(a,{skipActive:!0});const s=0===i.model.size;this.movingLock(()=>{var o;return i.model.openPanel(t,{index:r,skipSetActive:null!==(o=e.skipSetActive)&&void 0!==o&&o&&!s,skipSetGroupActive:!0})}),e.skipSetActive||this.doSetGroupAndPanelActive(i),this._onDidMovePanel.fire({panel:t,from:a})}else e.from.tabGroupId?this.moveTabGroupToGroup({sourceGroup:a,tabGroupId:e.from.tabGroupId,destinationGroup:i,destinationTarget:n,destinationIndex:r,skipSetActive:e.skipSetActive,keepEmptyGroups:e.keepEmptyGroups}):this.moveGroup({from:{group:a},to:{group:i,position:n},skipSetActive:e.skipSetActive})}moveTabGroupToGroup(e){const{sourceGroup:t,tabGroupId:i,destinationGroup:s,destinationTarget:o,destinationIndex:n}=e,r=t.model.getTabGroups().find(e=>e.id===i);if(!r||0===r.panelIds.length)return;const a=r.label,l=r.color,h=r.collapsed,d=r.componentParams,p=[...r.panelIds],c=o&&"center"!==o?ee(s.element):void 0,u=this.movingLock(()=>p.map(e=>t.model.removePanel(e,{skipSetActive:!1,skipSetActiveGroup:!0})).filter(e=>void 0!==e));if(0===u.length)return;let m;if(o&&"center"!==o&&c){const e=te(this.gridview.orientation,c,o);m=this.createGroupAtLocation(e)}else m=s;e.keepEmptyGroups||0!==t.model.size||t===m||this.doRemoveGroup(t,{skipActive:!0}),(i=>{this.movingLock(()=>{for(const e of u)i.model.openPanel(e,{index:n,skipSetActive:!0,skipSetGroupActive:!0})});const s=i.model.createTabGroup({label:a,color:l,collapsed:h,componentParams:d});for(const e of u)i.model.addPanelToTabGroup(s.id,e.id);e.skipSetActive||this.doSetGroupAndPanelActive(i);for(const e of u)this._onDidMovePanel.fire({panel:e,from:t})})(m)}moveGroup(t){const i=t.from.group,s=t.to.group,o=t.to.position;let n=i;if("center"===o){const e=i.activePanel,o=i.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),n=this.movingLock(()=>[...i.panels].map(e=>i.model.removePanel(e.id,{skipSetActive:!0})));0===(null==i?void 0:i.model.size)&&this.doRemoveGroup(i,{skipActive:!0}),this.movingLock(()=>{for(const t of n)s.model.openPanel(t,{skipSetActive:t!==e,skipSetGroupActive:!0})});for(const e of o){const t=s.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(const i of e.panelIds)s.model.addPanelToTabGroup(t.id,i)}!0!==t.skipSetActive?this.doSetGroupAndPanelActive(s):this.activePanel||this.doSetGroupAndPanelActive(s)}else{if("edge"===i.api.location.type){const e=i.activePanel,t=i.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),s=this.movingLock(()=>[...i.panels].map(e=>i.model.removePanel(e.id,{skipSetActive:!0})));n=this.createGroup(),this.movingLock(()=>{for(const t of s)n.model.openPanel(t,{skipSetActive:t!==e,skipSetGroupActive:!0})});for(const e of t){const t=n.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(const i of e.panelIds)n.model.addPanelToTabGroup(t.id,i)}}else switch(i.api.location.type){case"grid":this.gridview.removeView(ee(i.element));break;case"floating":{const e=this._floatingGroups.find(e=>e.group===i);if(!e)throw new Error("dockview: failed to find floating group");e.dispose();break}case"popout":{const e=this._popoutGroups.find(e=>e.popoutGroup===i);if(!e)throw new Error("dockview: failed to find popout group");const t=this._popoutGroups.indexOf(e);if(t>=0&&this._popoutGroups.splice(t,1),e.referenceGroup){const t=this.getPanel(e.referenceGroup);t&&!t.api.isVisible&&this.doRemoveGroup(t,{skipActive:!0})}e.window.dispose(),"grid"===s.api.location.type?(i.model.renderContainer=this.overlayRenderContainer,i.model.dropTargetContainer=this.rootDropTargetContainer,i.model.location={type:"grid"}):"floating"===s.api.location.type&&(i.model.renderContainer=this.overlayRenderContainer,i.model.dropTargetContainer=this.rootDropTargetContainer,i.model.location={type:"floating"});break}}if("grid"===s.api.location.type){const t=ee(s.element),r=te(this.gridview.orientation,t,o);let a;switch(this.gridview.orientation){case e.Orientation.VERTICAL:a=t.length%2==0?i.api.width:i.api.height;break;case e.Orientation.HORIZONTAL:a=t.length%2==0?i.api.height:i.api.width}this.gridview.addView(n,a,r)}else if("floating"===s.api.location.type){const e=this._floatingGroups.find(e=>e.group===s);if(e){const t=e.overlay.toJSON();let i,s;i="left"in t?t.left+50:"right"in t?Math.max(0,t.right-t.width-50):50,s="top"in t?t.top+50:"bottom"in t?Math.max(0,t.bottom-t.height-50):50,this.addFloatingGroup(n,{height:t.height,width:t.width,position:{left:i,top:s}})}}}if(n.panels.forEach(e=>{this._onDidMovePanel.fire({panel:e,from:i})}),this.debouncedUpdateAllPositions(),!1===t.skipSetActive){const e=null!=s?s:i;this.doSetGroupAndPanelActive(e)}else n!==i&&!0!==t.skipSetActive&&this.doSetGroupAndPanelActive(n)}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(t){t||(t={});let i=null==t?void 0:t.id;if(i&&this._groups.has(t.id)&&(console.warn(`dockview: Duplicate group id ${null==t?void 0:t.id}. reassigning group id to avoid errors`),i=void 0),!i)for(i=this.nextGroupId.next();this._groups.has(i);)i=this.nextGroupId.next();const s=new zt(this,i,t);if(s.init({params:{},accessor:this}),!this._groups.has(s.id)){const t=new l(s.model.onTabDragStart(e=>{this._onWillDragPanel.fire(e)}),s.model.onGroupDragStart(e=>{this._onWillDragGroup.fire(e)}),s.model.onMove(e=>{const{groupId:t,itemId:i,target:o,index:n,tabGroupId:r}=e;this.moveGroupOrPanel({from:{groupId:t,panelId:i,tabGroupId:r},to:{group:s,position:o,index:n}})}),s.model.onDidDrop(e=>{this._onDidDrop.fire(e)}),s.model.onWillDrop(e=>{this._onWillDrop.fire(e)}),s.model.onWillShowOverlay(e=>{this.options.disableDnd?e.preventDefault():this._onWillShowOverlay.fire(e)}),s.model.onUnhandledDragOverEvent(e=>{this._onUnhandledDragOverEvent.fire(e)}),s.model.onDidAddPanel(e=>{this._moving||this._onDidAddPanel.fire(e.panel)}),s.model.onDidRemovePanel(e=>{this._moving||this._onDidRemovePanel.fire(e.panel)}),s.model.onDidActivePanelChange(e=>{this._moving||e.panel===this.activePanel&&this._onDidActivePanelChange.value!==e.panel&&this._onDidActivePanelChange.fire(e.panel)}),s.model.onDidCreateTabGroup(e=>{this._onDidCreateTabGroup.fire(e)}),s.model.onDidDestroyTabGroup(e=>{this._onDidDestroyTabGroup.fire(e)}),s.model.onDidAddPanelToTabGroup(e=>{this._onDidAddPanelToTabGroup.fire(e)}),s.model.onDidRemovePanelFromTabGroup(e=>{this._onDidRemovePanelFromTabGroup.fire(e)}),s.model.onDidTabGroupChange(e=>{this._onDidTabGroupChange.fire(e)}),s.model.onDidTabGroupCollapsedChange(e=>{this._onDidTabGroupCollapsedChange.fire(e)}),e.DockviewEvent.any(s.model.onDidPanelTitleChange,s.model.onDidPanelParametersChange)(()=>{this._bufferOnDidLayoutChange.fire()}));this._groups.set(s.id,{value:s,disposable:t})}return s.initialize(),s}createPanel(e,t){var i,s,o;const n=e.component,r=null!==(i=e.tabComponent)&&void 0!==i?i:this.options.defaultTabComponent,a=new kt(this,e.id,n,r),l=new Ot(e.id,n,r,this,this._api,t,a,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return l.init({title:null!==(s=e.title)&&void 0!==s?s:e.id,params:null!==(o=null==e?void 0:e.params)&&void 0!==o?o:{}}),l}createGroupAtLocation(e,t,i){const s=this.createGroup(i);return this.doAddGroup(s,e,t),s}findGroup(e){var t;return null===(t=Array.from(this._groups.values()).find(t=>t.value.model.containsPanel(e)))||void 0===t?void 0:t.value}orientationAtLocation(e){const t=this.gridview.orientation;return e.length%2==1?t:oe(t)}updateDropTargetModel(e){if("dndEdges"in e){const t="boolean"==typeof e.dndEdges&&!1===e.dndEdges;this._rootDropTarget.disabled=t,this._rootPointerDropTarget.disabled=t,"object"==typeof e.dndEdges&&null!==e.dndEdges?(this._rootDropTarget.setOverlayModel(e.dndEdges),this._rootPointerDropTarget.setOverlayModel(e.dndEdges)):(this._rootDropTarget.setOverlayModel(ci),this._rootPointerDropTarget.setOverlayModel(ci))}"rootOverlayModel"in e&&this.updateDropTargetModel({dndEdges:e.dndEdges})}updateTheme(){var e,t,i,s,o,n,r,a,l;const h=null!==(e=this._options.theme)&&void 0!==e?e:At;if(null===(t=this._shellThemeClassnames)||void 0===t||t.setClassNames(h.className),this.gridview.margin=null!==(i=h.gap)&&void 0!==i?i:0,null===(s=this._shellManager)||void 0===s||s.updateTheme(null!==(o=h.gap)&&void 0!==o?o:0,null!==(n=h.edgeGroupCollapsedSize)&&void 0!==n?n:35),void 0!==h.dndOverlayBorder?(this.element.style.setProperty("--dv-drag-over-border",h.dndOverlayBorder),null===(r=this._shellManager)||void 0===r||r.element.style.setProperty("--dv-drag-over-border",h.dndOverlayBorder)):(this.element.style.removeProperty("--dv-drag-over-border"),null===(a=this._shellManager)||void 0===a||a.element.style.removeProperty("--dv-drag-over-border")),"absolute"===h.dndOverlayMounting)this.rootDropTargetContainer.disabled=!1;else this.rootDropTargetContainer.disabled=!0;const d="none"===(null!==(l=h.tabGroupIndicator)&&void 0!==l?l:"wrap");D(this.element,"dv-tab-group-indicator-none",d),this._shellManager&&D(this._shellManager.element,"dv-tab-group-indicator-none",d);for(const e of this.groups)e.model.updateTabGroups()}}class vi extends ce{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:null===(i=t.proportionalLayout)||void 0===i||i,orientation:t.orientation,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:t.disableAutoResizing,className:t.className}),this._onDidLayoutfromJSON=new m,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidRemoveGroup=new m,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new m,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new m,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._options=t,this.addDisposables(this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this.onDidAdd(e=>{this._onDidAddGroup.fire(e)}),this.onDidRemove(e=>{this._onDidRemoveGroup.fire(e)}),this.onDidActiveChange(e=>{this._onDidActiveGroupChange.fire(e)}))}updateOptions(e){super.updateOptions(e);const t="string"==typeof e.orientation&&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:null===(e=this.activeGroup)||void 0===e?void 0:e.id}}setVisible(e,t){this.gridview.setViewVisible(ee(e.element),t)}setActive(e){this._groups.forEach((t,i)=>{t.value.setActive(e===t.value)})}focus(){var e;null===(e=this.activeGroup)||void 0===e||e.focus()}fromJSON(e){this.clear();const{grid:t,activePanel:i}=e;try{const e=[],s=this.width,o=this.height;if(this.gridview.deserialize(t,{fromJSON:t=>{const{data:i}=t,s=this.options.createComponent({id:i.id,name:i.component});return e.push(()=>s.init({params:i.params,minimumWidth:i.minimumWidth,maximumWidth:i.maximumWidth,minimumHeight:i.minimumHeight,maximumHeight:i.maximumHeight,priority:i.priority,snap:!!i.snap,accessor:this,isVisible:t.visible})),this._onDidAddGroup.fire(s),this.registerPanel(s),s}}),this.layout(s,o,!0),e.forEach(e=>e()),"string"==typeof i){const e=this.getPanel(i);e&&this.doSetGroupActive(e)}}catch(e){for(const e of this.groups)e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e);throw this.clear(),e}this._onDidLayoutfromJSON.fire()}clear(){const e=this.activeGroup,t=Array.from(this._groups.values());for(const e of t)e.disposable.dispose(),this.doRemoveGroup(e.value,{skipActive:!0});e&&this.doSetGroupActive(void 0),this.gridview.clear()}movePanel(e,t){var i;let s;const o=this.gridview.remove(e),n=null===(i=this._groups.get(t.reference))||void 0===i?void 0:i.value;if(!n)throw new Error(`reference group ${t.reference} does not exist`);const r=pe(t.direction);if("center"===r)throw new Error(`${r} not supported as an option`);{const e=ee(n.element);s=te(this.gridview.orientation,e,r)}this.doAddGroup(o,s,t.size)}addPanel(e){var t,i,s,o;let n=null!==(t=e.location)&&void 0!==t?t:[0];if(null===(i=e.position)||void 0===i?void 0:i.referencePanel){const t=null===(s=this._groups.get(e.position.referencePanel))||void 0===s?void 0:s.value;if(!t)throw new Error(`reference group ${e.position.referencePanel} does not exist`);const i=pe(e.position.direction);if("center"===i)throw new Error(`${i} not supported as an option`);{const e=ee(t.element);n=te(this.gridview.orientation,e,i)}}const r=this.options.createComponent({id:e.id,name:e.component});return r.init({params:null!==(o=e.params)&&void 0!==o?o:{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.doAddGroup(r,n,e.size),this.registerPanel(r),this.doSetGroupActive(r),r}registerPanel(e){const t=new l(e.api.onDidFocusChange(t=>{t.isFocused&&this._groups.forEach(t=>{const i=t.value;i!==e?i.setActive(!1):i.setActive(!0)})}));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,i){const s=this.getPanel(t);if(!s)throw new Error("invalid operation");const o=ee(e.element),n=te(this.gridview.orientation,o,i),[r,a]=E(n),l=ee(s.element),[h,d]=E(l);if(O(h,r))return void this.gridview.moveView(h,d,a);const p=this.doRemoveGroup(s,{skipActive:!0,skipDispose:!0}),c=ee(e.element),u=te(this.gridview.orientation,c,i);this.doAddGroup(p,u)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}}class gi extends he{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 l(this._splitview.onDidSashEnd(()=>{this._onDidLayoutChange.fire(void 0)}),this._splitview.onDidAddView(e=>this._onDidAddView.fire(e)),this._splitview.onDidRemoveView(e=>this._onDidRemoveView.fire(e)))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation===e.Orientation.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===e.Orientation.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._splitviewChangeDisposable=new h,this._panels=new Map,this._onDidLayoutfromJSON=new m,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new m,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new m,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new m,this.onDidLayoutChange=this._onDidLayoutChange.event,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new I(this.element),this._classNames.setClassNames(null!==(i=t.className)&&void 0!==i?i:""),e.appendChild(this.element),this._options=t,this.splitview=new U(this.element,t),this.addDisposables(this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange)}updateOptions(e){var t,i;"className"in e&&this._classNames.setClassNames(null!==(t=e.className)&&void 0!==t?t:""),"disableResizing"in e&&(this.disableResizing=null!==(i=e.disableAutoResizing)&&void 0!==i&&i),"string"==typeof e.orientation&&(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;null===(e=this._activePanel)||void 0===e||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(t=>t!==e).forEach(e=>{e.api._onDidActiveChange.fire({isActive:!1}),t||e.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 s=this.panels.findIndex(t=>t===e);this.splitview.removeView(s,t).dispose();const o=this.panels;o.length>0&&this.setActive(o[o.length-1])}getPanel(e){return this.panels.find(t=>t.id===e)}addPanel(t){var i;if(this._panels.has(t.id))throw new Error(`panel ${t.id} already exists`);const s=this.options.createComponent({id:t.id,name:t.component});s.orientation=this.splitview.orientation,s.init({params:null!==(i=t.params)&&void 0!==i?i:{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:t.snap,priority:t.priority,accessor:this});const o="number"==typeof t.size?t.size:e.Sizing.Distribute,n="number"==typeof t.index?t.index:void 0;return this.splitview.addView(s,o,n),this.doAddView(s),this.setActive(s),s}layout(t,i){const[s,o]=this.splitview.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.splitview.layout(s,o)}doAddView(e){const t=e.api.onDidFocusChange(t=>{t.isFocused&&this.setActive(e,!0)});this._panels.set(e.id,t)}toJSON(){var e;return{views:this.splitview.getViews().map((e,t)=>({size:this.splitview.getViewSize(t),data:e.toJSON(),snap:!!e.snap,priority:e.priority})),activeView:null===(e=this._activePanel)||void 0===e?void 0:e.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){this.clear();const{views:t,orientation:i,size:s,activeView:o}=e,n=[],r=this.width,a=this.height;if(this.splitview=new U(this.element,{orientation:i,proportionalLayout:this.options.proportionalLayout,descriptor:{size:s,views:t.map(e=>{const t=e.data;if(this._panels.has(t.id))throw new Error(`panel ${t.id} already exists`);const s=this.options.createComponent({id:t.id,name:t.component});return n.push(()=>{var i;s.init({params:null!==(i=t.params)&&void 0!==i?i:{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:e.snap,priority:e.priority,accessor:this})}),s.orientation=i,this.doAddView(s),setTimeout(()=>{this._onDidAddView.fire(s)},0),{size:e.size,view:s}})}}),this.layout(r,a),n.forEach(e=>e()),"string"==typeof o){const e=this.getPanel(o);e&&this.setActive(e)}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,e.Sizing.Distribute,!0).dispose()}}dispose(){for(const e of this._panels.values())e.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 _i extends l{get element(){return this._element}constructor(){super(),this._expandedIcon=ut({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"}),this._collapsedIcon=mt(),this.disposable=new h,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(v(this._element,"click",()=>{var e;null===(e=this.apiRef.api)||void 0===e||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=!!(null===(e=this.apiRef.api)||void 0===e?void 0:e.isExpanded);D(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 fi=N(),bi=Number.MAX_SAFE_INTEGER;class wi extends Ye{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 Di extends he{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new l(this._paneview.onDidChange(()=>{this._onDidLayoutChange.fire(void 0)}),this._paneview.onDidAddView(e=>this._onDidAddView.fire(e)),this._paneview.onDidRemoveView(e=>this._onDidRemoveView.fire(e)))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation===e.Orientation.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===e.Orientation.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(t,i){var s;super(document.createElement("div"),i.disableAutoResizing),this._id=fi.next(),this._disposable=new h,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new m,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new m,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new m,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new m,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new m,this.onDidRemoveView=this._onDidRemoveView.event,this._onUnhandledDragOverEvent=new m,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 I(this.element),this._classNames.setClassNames(null!==(s=i.className)&&void 0!==s?s:""),t.appendChild(this.element),this._options=i,this.paneview=new X(this.element,{orientation:e.Orientation.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(null!==(t=e.className)&&void 0!==t?t:""),"disableResizing"in e&&(this.disableResizing=null!==(i=e.disableAutoResizing)&&void 0!==i&&i),this._options=Object.assign(Object.assign({},this.options),e)}addPanel(t){var i,s;const o=this.options.createComponent({id:t.id,name:t.component});let n;t.headerComponent&&this.options.createHeaderComponent&&(n=this.options.createHeaderComponent({id:t.id,name:t.headerComponent})),n||(n=new _i);const r=new wi({id:t.id,component:t.component,headerComponent:t.headerComponent,header:n,body:o,orientation:e.Orientation.VERTICAL,isExpanded:!!t.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:null!==(i=t.headerSize)&&void 0!==i?i:22,minimumBodySize:0,maximumBodySize:bi});this.doAddPanel(r);const a="number"==typeof t.size?t.size:e.Sizing.Distribute,l="number"==typeof t.index?t.index:void 0;return r.init({params:null!==(s=t.params)&&void 0!==s?s:{},minimumBodySize:t.minimumBodySize,maximumBodySize:t.maximumBodySize,isExpanded:t.isExpanded,title:t.title,containerApi:new me(this),accessor:this}),this.paneview.addPane(r,a,l),r.orientation=this.paneview.orientation,r}removePanel(e){const t=this.panels.findIndex(t=>t===e);this.paneview.removePane(t),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find(t=>t.id===e)}layout(t,i){const[s,o]=this.paneview.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.paneview.layout(s,o)}toJSON(){const e=e=>e===Number.MAX_SAFE_INTEGER||e===Number.POSITIVE_INFINITY?void 0:e;return{views:this.paneview.getPanes().map((t,i)=>{return{size:this.paneview.getViewSize(i),data:t.toJSON(),minimumSize:(s=t.minimumBodySize,s<=0?void 0:s),maximumSize:e(t.maximumBodySize),headerSize:t.headerSize,expanded:t.isExpanded()};var s}),size:this.paneview.size}}fromJSON(t){this.clear();const{views:i,size:s}=t,o=[],n=this.width,r=this.height;this.paneview=new X(this.element,{orientation:e.Orientation.VERTICAL,descriptor:{size:s,views:i.map(t=>{var i,s,n;const r=t.data,a=this.options.createComponent({id:r.id,name:r.component});let l;r.headerComponent&&this.options.createHeaderComponent&&(l=this.options.createHeaderComponent({id:r.id,name:r.headerComponent})),l||(l=new _i);const h=new wi({id:r.id,component:r.component,headerComponent:r.headerComponent,header:l,body:a,orientation:e.Orientation.VERTICAL,isExpanded:!!t.expanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:null!==(i=t.headerSize)&&void 0!==i?i:22,minimumBodySize:null!==(s=t.minimumSize)&&void 0!==s?s:0,maximumBodySize:null!==(n=t.maximumSize)&&void 0!==n?n:bi});return this.doAddPanel(h),o.push(()=>{var e;h.init({params:null!==(e=r.params)&&void 0!==e?e:{},minimumBodySize:t.minimumSize,maximumBodySize:t.maximumSize,title:r.title,isExpanded:!!t.expanded,containerApi:new me(this),accessor:this}),h.orientation=this.paneview.orientation}),setTimeout(()=>{this._onDidAddView.fire(h)},0),{size:t.size,view:h}})}}),this.layout(n,r),o.forEach(e=>e()),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 l(e.onDidDrop(e=>{this._onDidDrop.fire(e)}),e.onUnhandledDragOverEvent(e=>{this._onUnhandledDragOverEvent.fire(e)}));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()}}e.BaseGrid=ce,e.ContentContainer=Xe,e.DEFAULT_TAB_GROUP_COLORS=et,e.DefaultDockviewDeserialzier=Vt,e.DefaultTab=Mt,e.DockviewApi=ge,e.DockviewComponent=mi,e.DockviewCompositeDisposable=l,e.DockviewDidDropEvent=yt,e.DockviewEmitter=m,e.DockviewGroupPanel=zt,e.DockviewGroupPanelModel=xt,e.DockviewMutableDisposable=h,e.DockviewPanel=Ot,e.DockviewUnhandledDragOverEvent=gt,e.DockviewWillDropEvent=St,e.DockviewWillShowOverlayLocationEvent=qe,e.DraggablePaneviewPanel=Ye,e.Gridview=ae,e.GridviewApi=ve,e.GridviewComponent=vi,e.GridviewPanel=Pt,e.PROPERTY_KEYS_DOCKVIEW=_t,e.PROPERTY_KEYS_GRIDVIEW=le,e.PROPERTY_KEYS_PANEVIEW=Ne,e.PROPERTY_KEYS_SPLITVIEW=Y,e.PaneFramework=wi,e.PaneTransfer=s,e.PanelTransfer=i,e.Paneview=X,e.PaneviewApi=me,e.PaneviewComponent=Di,e.PaneviewPanel=Ue,e.PaneviewUnhandledDragOverEvent=Re,e.Splitview=U,e.SplitviewApi=ue,e.SplitviewComponent=gi,e.SplitviewPanel=class extends $e{get priority(){return this._priority}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){const e="function"==typeof this._minimumSize?this._minimumSize():this._minimumSize;return e!==this._evaluatedMinimumSize&&(this._evaluatedMinimumSize=e,this.updateConstraints()),e}get maximumSize(){const e="function"==typeof this._maximumSize?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 Fe(e,t)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=Number.POSITIVE_INFINITY,this._minimumSize=0,this._maximumSize=Number.POSITIVE_INFINITY,this._snap=!1,this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this.api.initialize(this),this.addDisposables(this._onDidChange,this.api.onWillVisibilityChange(e=>{const{isVisible:t}=e,{accessor:i}=this._params;i.setVisible(this,t)}),this.api.onActiveChange(()=>{const{accessor:e}=this._params;e.setActive(this)}),this.api.onDidConstraintsChangeInternal(e=>{"number"!=typeof e.minimumSize&&"function"!=typeof e.minimumSize||(this._minimumSize=e.minimumSize),"number"!=typeof e.maximumSize&&"function"!=typeof e.maximumSize||(this._maximumSize=e.maximumSize),this.updateConstraints()}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({size:e.size})}))}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(t,i){const[s,o]=this.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];super.layout(s,o)}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(){return Object.assign(Object.assign({},super.toJSON()),{minimumSize:(e=this.minimumSize,e<=0?void 0:e),maximumSize:(e=>e===Number.MAX_SAFE_INTEGER||e===Number.POSITIVE_INFINITY?void 0:e)(this.maximumSize)});var e}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}},e.Tab=Ze,e.TabGroupColorPalette=tt,e.applyTabGroupAccent=ot,e.createDockview=function(e,t){return new mi(e,t).api},e.createGridview=function(e,t){const i=new vi(e,t);return new ve(i)},e.createPaneview=function(e,t){const i=new Di(e,t);return new me(i)},e.createSplitview=function(e,t){const i=new gi(e,t);return new ue(i)},e.directionToPosition=Se,e.getDirectionOrientation=ie,e.getGridLocation=ee,e.getLocationOrientation=se,e.getPaneData=r,e.getPanelData=n,e.getRelativeLocation=te,e.indexInParent=Q,e.isGridBranchNode=ne,e.isGroupOptionsWithGroup=Dt,e.isGroupOptionsWithPanel=wt,e.isPanelOptionsWithGroup=bt,e.isPanelOptionsWithPanel=ft,e.orthogonal=oe,e.positionToDirection=xe,e.resolveTabGroupAccent=nt,e.themeAbyss=At,e.themeAbyssSpaced={name:"abyssSpaced",className:"dockview-theme-abyss-spaced",colorScheme:"dark",gap:10,edgeGroupCollapsedSize:44,dndOverlayMounting:"absolute",dndPanelOverlay:"group",dndTabIndicator:"line",dndOverlayBorder:"2px solid var(--dv-active-sash-color)"},e.themeCatppuccinMocha={name:"catppuccinMocha",className:"dockview-theme-catppuccin-mocha",colorScheme:"dark"},e.themeCatppuccinMochaSpaced={name:"catppuccinMochaSpaced",className:"dockview-theme-catppuccin-mocha-spaced",colorScheme:"dark",gap:10,edgeGroupCollapsedSize:44,dndOverlayMounting:"absolute",dndPanelOverlay:"group",dndTabIndicator:"line",dndOverlayBorder:"2px solid var(--dv-active-sash-color)"},e.themeDark={name:"dark",className:"dockview-theme-dark",colorScheme:"dark"},e.themeDracula={name:"dracula",className:"dockview-theme-dracula",colorScheme:"dark"},e.themeGithubDark={name:"githubDark",className:"dockview-theme-github-dark",colorScheme:"dark"},e.themeGithubDarkSpaced={name:"githubDarkSpaced",className:"dockview-theme-github-dark-spaced",colorScheme:"dark",gap:10,edgeGroupCollapsedSize:44,dndOverlayMounting:"absolute",dndPanelOverlay:"group",dndTabIndicator:"line",dndOverlayBorder:"2px solid var(--dv-active-sash-color)"},e.themeGithubLight={name:"githubLight",className:"dockview-theme-github-light",colorScheme:"light"},e.themeGithubLightSpaced={name:"githubLightSpaced",className:"dockview-theme-github-light-spaced",colorScheme:"light",gap:10,edgeGroupCollapsedSize:44,dndOverlayMounting:"absolute",dndPanelOverlay:"group",dndTabIndicator:"line",dndOverlayBorder:"2px solid var(--dv-active-sash-color)"},e.themeLight={name:"light",className:"dockview-theme-light",colorScheme:"light"},e.themeLightSpaced={name:"lightSpaced",className:"dockview-theme-light-spaced",colorScheme:"light",gap:10,edgeGroupCollapsedSize:44,dndOverlayMounting:"absolute",dndPanelOverlay:"group",dndTabIndicator:"line",dndOverlayBorder:"2px solid var(--dv-active-sash-color)"},e.themeMonokai={name:"monokai",className:"dockview-theme-monokai",colorScheme:"dark"},e.themeNord={name:"nord",className:"dockview-theme-nord",colorScheme:"dark"},e.themeNordSpaced={name:"nordSpaced",className:"dockview-theme-nord-spaced",colorScheme:"dark",gap:10,edgeGroupCollapsedSize:44,dndOverlayMounting:"absolute",dndPanelOverlay:"group",dndTabIndicator:"line",dndOverlayBorder:"2px solid var(--dv-active-sash-color)"},e.themeSolarizedLight={name:"solarizedLight",className:"dockview-theme-solarized-light",colorScheme:"light"},e.themeSolarizedLightSpaced={name:"solarizedLightSpaced",className:"dockview-theme-solarized-light-spaced",colorScheme:"light",gap:10,edgeGroupCollapsedSize:44,dndOverlayMounting:"absolute",dndPanelOverlay:"group",dndTabIndicator:"line",dndOverlayBorder:"2px solid var(--dv-active-sash-color)"},e.themeVisualStudio={name:"visualStudio",className:"dockview-theme-vs",colorScheme:"dark",edgeGroupCollapsedSize:22},e.toTarget=pe});
8
8
  //# sourceMappingURL=dockview-core.min.noStyle.js.map