dockview-core 6.0.6 → 6.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dockview/components/titlebar/tabs.js +15 -0
- package/dist/dockview-core.js +16 -1
- package/dist/dockview-core.min.js +2 -2
- package/dist/dockview-core.min.js.map +1 -1
- package/dist/dockview-core.min.noStyle.js +2 -2
- package/dist/dockview-core.min.noStyle.js.map +1 -1
- package/dist/dockview-core.noStyle.js +16 -1
- package/dist/esm/dockview/components/titlebar/tabs.js +15 -0
- package/dist/package/main.cjs.js +16 -1
- package/dist/package/main.cjs.min.js +2 -2
- package/dist/package/main.esm.min.mjs +2 -2
- package/dist/package/main.esm.mjs +16 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview-core
|
|
3
|
-
* @version 6.0.
|
|
3
|
+
* @version 6.0.7
|
|
4
4
|
* @link https://github.com/mathuo/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";class e{}class t extends e{constructor(e,t,i,s){super(),this.viewId=e,this.groupId=t,this.panelId=i,this.tabGroupId=s}}class i extends e{constructor(e,t){super(),this.viewId=e,this.paneId=t}}class s{constructor(){}static getInstance(){return s.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 o(){const e=s.getInstance();if(e.hasData(t.prototype))return e.getData(t.prototype)[0]}function n(){const e=s.getInstance();if(e.hasData(i.prototype))return e.getData(i.prototype)[0]}s.INSTANCE=new s,exports.DockviewEvent=void 0,(exports.DockviewEvent||(exports.DockviewEvent={})).any=(...e)=>t=>{const i=e.map(e=>e(t));return{dispose:()=>{i.forEach(e=>{e.dispose()})}}};class r{constructor(){this._defaultPrevented=!1}get defaultPrevented(){return this._defaultPrevented}preventDefault(){this._defaultPrevented=!0}}class a{constructor(){this._isAccepted=!1}get isAccepted(){return this._isAccepted}accept(){this._isAccepted=!0}}class h{static create(){var e;return new h(null!==(e=(new Error).stack)&&void 0!==e?e:"")}constructor(e){this.value=e}print(){console.warn("dockview: stacktrace",this.value)}}class l{constructor(e,t){this.callback=e,this.stacktrace=t}}class d{static setLeakageMonitorEnabled(e){e!==d.ENABLE_TRACKING&&d.MEMORY_LEAK_WATCHER.clear(),d.ENABLE_TRACKING=e}get value(){return this._last}constructor(e){this.options=e,this._listeners=[],this._disposed=!1}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 l(e,d.ENABLE_TRACKING?h.create():void 0);return this._listeners.push(i),{dispose:()=>{const e=this._listeners.indexOf(i);e>-1?this._listeners.splice(e,1):d.ENABLE_TRACKING}}},d.ENABLE_TRACKING&&d.MEMORY_LEAK_WATCHER.add(this._event,h.create())),this._event}fire(e){var t;(null===(t=this.options)||void 0===t?void 0:t.replay)&&(this._last=e);for(const t of this._listeners)t.callback(e)}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&(d.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=[]),d.ENABLE_TRACKING&&this._event&&d.MEMORY_LEAK_WATCHER.delete(this._event))}}function p(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i,s)}}}d.ENABLE_TRACKING=!1,d.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 u{constructor(){this._onFired=new d,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()}}var c;exports.DockviewDisposable=void 0,(c=exports.DockviewDisposable||(exports.DockviewDisposable={})).NONE={dispose:()=>{}},c.from=function(e){return{dispose:()=>{e()}}};class m{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 v{constructor(){this._disposable=exports.DockviewDisposable.NONE}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&(this._disposable.dispose(),this._disposable=exports.DockviewDisposable.NONE)}}class g extends m{constructor(e){super(),this._onDidChange=new d,this.onDidChange=this._onDidChange.event,this._value=null,this.addDisposables(this._onDidChange,_(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 _(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 f=(e,...t)=>{for(const i of t)e.classList.contains(i)&&e.classList.remove(i)},b=(e,...t)=>{for(const i of t)e.classList.contains(i)||e.classList.add(i)},w=(e,t,i)=>{const s=e.classList.contains(t);i&&!s&&e.classList.add(t),!i&&s&&e.classList.remove(t)};function D(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function C(e){return new x(e)}class x extends m{constructor(e){super(),this._onDidFocus=new d,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new d,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=D(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=()=>{D(document.activeElement,e)!==t&&(t?o():s())},this.addDisposables(p(e,"focus",s,!0)),this.addDisposables(p(e,"blur",o,!0))}refreshState(){this._refreshStateHandler()}}const y="dv-quasiPreventDefault";function S(e){return e[y]}function G(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 P(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 A{constructor(e){this.element=e,this._classNames=[]}setClassNames(e){for(const e of this._classNames)w(this.element,e,!1);this._classNames=e.split(" ").filter(e=>e.trim().length>0);for(const e of this._classNames)w(this.element,e,!0)}}function z(e,t){const i=G(e),s=G(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 I(e){let t=e;for(;t&&("auto"===t.style.zIndex||""===t.style.zIndex);)t=t.parentElement;return t}function T(e){if(0===e.length)throw new Error("Invalid tail call");return[e.slice(0,e.length-1),e[e.length-1]]}function E(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 O(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 k(e,t){const i=e.findIndex(e=>e===t);return i>-1&&(e.splice(i,1),!0)}const M=(e,t,i)=>t>i?t:Math.min(i,Math.max(e,t)),L=()=>{let e=1;return{next:()=>(e++).toString()}},N=(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 R{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=M(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 W,H,F,B;exports.Orientation=void 0,(W=exports.Orientation||(exports.Orientation={})).HORIZONTAL="HORIZONTAL",W.VERTICAL="VERTICAL",exports.SashState=void 0,(H=exports.SashState||(exports.SashState={}))[H.MAXIMUM=0]="MAXIMUM",H[H.MINIMUM=1]="MINIMUM",H[H.DISABLED=2]="DISABLED",H[H.ENABLED=3]="ENABLED",exports.LayoutPriority=void 0,(F=exports.LayoutPriority||(exports.LayoutPriority={})).Low="low",F.High="high",F.Normal="normal",exports.Sizing=void 0,(B=exports.Sizing||(exports.Sizing={})).Distribute={type:"distribute"},B.Split=function(e){return{type:"split",index:e}},B.Invisible=function(e){return{type:"invisible",cachedVisibleSize:e}};class ${get contentSize(){return this._contentSize}get size(){return this._size}set size(e){this._size=e}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get length(){return this.viewItems.length}get proportions(){return this._proportions?[...this._proportions]:void 0}get orientation(){return this._orientation}set orientation(e){this._orientation=e;const t=this.size;this.size=this.orthogonalSize,this.orthogonalSize=t,f(this.element,"dv-horizontal","dv-vertical"),this.element.classList.add(this.orientation==exports.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,w(this.element,"dv-splitview-disabled",e)}get margin(){return this._margin}set margin(e){this._margin=e,w(this.element,"dv-splitview-has-margin",0!==e)}constructor(e,t){var i,s;this.container=e,this.viewItems=[],this.sashes=[],this._size=0,this._orthogonalSize=0,this._contentSize=0,this._proportions=void 0,this._startSnappingEnabled=!0,this._endSnappingEnabled=!0,this._disabled=!1,this._margin=0,this._onDidSashEnd=new d,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new d,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new d,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=N(e,-1),d=N(e+1,this.viewItems.length);if(o)for(const e of o)O(l,e),O(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,x=M(t,b,w);for(let e=0;e<p.length;e++){const t=p[e],i=M(u[e]+x,t.minimumSize,t.maximumSize),s=i-u[e];C+=s,x-=s,t.size=i}let y=C;for(let e=0;e<c.length;e++){const t=c[e],i=M(m[e]-y,t.minimumSize,t.maximumSize);y+=i-m[e],t.size=i}return t},this._orientation=null!==(i=t.orientation)&&void 0!==i?i:exports.Orientation.VERTICAL,this.element=this.createContainer(),this.margin=null!==(s=t.margin)&&void 0!==s?s:0,this.proportionalLayout=void 0===t.proportionalLayout||!!t.proportionalLayout,this.viewContainer=this.createViewContainer(),this.sashContainer=this.createSashContainer(),this.element.appendChild(this.sashContainer),this.element.appendChild(this.viewContainer),this.container.appendChild(this.element),this.style(t.styles),t.descriptor&&(this._size=t.descriptor.size,t.descriptor.views.forEach((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)?(f(this.element,"dv-separator-border"),this.element.style.removeProperty("--dv-separator-border")):(b(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(e,t){if(e<0||e>=this.viewItems.length)return;const i=N(this.viewItems.length).filter(t=>t!==e),s=[...i.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.Low),e],o=i.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.High),n=this.viewItems[e];t=Math.round(t),t=M(t,n.minimumSize,Math.min(n.maximumSize,this._size)),n.size=t,this.relayout(s,o)}getViews(){return this.viewItems.map(e=>e.view)}onDidChange(e,t){const i=this.viewItems.indexOf(e);if(i<0||i>=this.viewItems.length)return;t="number"==typeof t?t:e.size,t=M(t,e.minimumSize,e.maximumSize),e.size=t;const s=N(this.viewItems.length).filter(e=>e!==i),o=[...s.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.Low),i],n=s.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.High);this.relayout([...o,i],n)}addView(e,t={type:"distribute"},i=this.viewItems.length,s){const o=document.createElement("div");let n;o.className="dv-view",o.appendChild(e.element),n="number"==typeof t?t:"split"===t.type?this.getViewSize(t.index)/2:"invisible"===t.type?{cachedVisibleSize:t.cachedVisibleSize}:e.minimumSize;const r=e.onDidChange(e=>this.onDidChange(a,e.size)),a=new R(o,e,n,{dispose:()=>{r.dispose(),this.viewContainer.removeChild(o)}});if(i===this.viewItems.length?this.viewContainer.appendChild(o):this.viewContainer.insertBefore(o,this.viewContainer.children.item(i)),this.viewItems.splice(i,0,a),this.viewItems.length>1){const e=document.createElement("div");e.className="dv-sash";const t=t=>{for(const e of this.viewItems)e.enabled=!1;const i=P(),s=this._orientation===exports.Orientation.HORIZONTAL?t.clientX:t.clientY,o=function(e,t){for(let i=0;i<e.length;i++)if(t(e[i]))return i;return-1}(this.sashes,t=>t.container===e),n=this.viewItems.map(e=>e.size);let r,a;const h=N(o,-1),l=N(o+1,this.viewItems.length),d=h.reduce((e,t)=>e+(this.viewItems[t].minimumSize-n[t]),0),p=h.reduce((e,t)=>e+(this.viewItems[t].viewMaximumSize-n[t]),0),u=0===l.length?Number.POSITIVE_INFINITY:l.reduce((e,t)=>e+(n[t]-this.viewItems[t].minimumSize),0),c=0===l.length?Number.NEGATIVE_INFINITY:l.reduce((e,t)=>e+(n[t]-this.viewItems[t].viewMaximumSize),0),m=Math.max(d,c),v=Math.min(u,p),g=this.findFirstSnapIndex(h),_=this.findFirstSnapIndex(l);if("number"==typeof g){const e=this.viewItems[g],t=Math.floor(e.viewMinimumSize/2);r={index:g,limitDelta:e.visible?m-t:m+t,size:e.size}}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}}const f=e=>{const t=(this._orientation===exports.Orientation.HORIZONTAL?e.clientX:e.clientY)-s;this.resize(o,t,n,void 0,void 0,m,v,r,a),this.distributeEmptySpace(),this.layoutViews()},b=()=>{for(const e of this.viewItems)e.enabled=!0;i.release(),this.saveProportions(),document.removeEventListener("pointermove",f),document.removeEventListener("pointerup",b),document.removeEventListener("pointercancel",b),document.removeEventListener("contextmenu",b),this._onDidSashEnd.fire(void 0)};document.addEventListener("pointermove",f),document.addEventListener("pointerup",b),document.addEventListener("pointercancel",b),document.addEventListener("contextmenu",b)};e.addEventListener("pointerdown",t);const i={container:e,disposable:()=>{e.removeEventListener("pointerdown",t),this.sashContainer.removeChild(e)}};this.sashContainer.appendChild(e),this.sashes.push(i)}s||this.relayout([i]),s||"number"==typeof t||"distribute"!==t.type||this.distributeViewSizes(),this._onDidAddView.fire(e)}distributeViewSizes(){const e=[];let t=0;for(const i of this.viewItems)i.maximumSize-i.minimumSize>0&&(e.push(i),t+=i.size);const i=Math.floor(t/e.length);for(const t of e)t.size=M(i,t.minimumSize,t.maximumSize);const s=N(this.viewItems.length),o=s.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.Low),n=s.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.High);this.relayout(o,n)}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(e,t){const i=this.getViewCachedVisibleSize(e),s=void 0===i?this.getViewSize(e):exports.Sizing.Invisible(i),o=this.removeView(e,void 0,!0);this.addView(o,s,t)}layout(e,t){const i=Math.max(this.size,this._contentSize);if(this.size=e,this.orthogonalSize=t,this.proportions){let t=0;for(let i=0;i<this.viewItems.length;i++){const s=this.viewItems[i],o=this.proportions[i];"number"==typeof o?t+=o:e-=s.size}for(let i=0;i<this.viewItems.length;i++){const s=this.viewItems[i],o=this.proportions[i];"number"==typeof o&&t>0&&(s.size=M(Math.round(o*e/t),s.minimumSize,s.maximumSize))}}else{const t=N(this.viewItems.length),s=t.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.Low),o=t.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.High);this.resize(this.viewItems.length-1,e-i,void 0,s,o)}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(e){const t=this.viewItems.reduce((e,t)=>e+t.size,0);let i=this.size-t;const s=N(this.viewItems.length-1,-1),o=s.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.Low),n=s.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.High);for(const e of n)O(s,e);for(const e of o)V(s,e);"number"==typeof e&&V(s,e);for(let e=0;0!==i&&e<s.length;e++){const t=this.viewItems[s[e]],o=M(t.size+i,t.minimumSize,t.maximumSize);i-=o-t.size,t.size=o}}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 e=this.viewItems.filter(e=>e.visible),t=Math.max(0,e.length-1),i=this.margin*t/Math.max(1,e.length);let s=0;const o=[],n=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((e,r)=>{s+=this.viewItems[r].size,o.push(s);const a=e.visible?e.size-i:0,h=Math.max(0,n[r]-1),l=0===r||0===h?0:o[r-1]+h/t*i;if(r<this.viewItems.length-1){const t=e.visible?l+a-2+this.margin/2:l;this._orientation===exports.Orientation.HORIZONTAL&&(this.sashes[r].container.style.left=`${t}px`,this.sashes[r].container.style.top="0px"),this._orientation===exports.Orientation.VERTICAL&&(this.sashes[r].container.style.left="0px",this.sashes[r].container.style.top=`${t}px`)}this._orientation===exports.Orientation.HORIZONTAL&&(e.container.style.width=`${a}px`,e.container.style.left=`${l}px`,e.container.style.top="",e.container.style.height=""),this._orientation===exports.Orientation.VERTICAL&&(e.container.style.height=`${a}px`,e.container.style.top=`${l}px`,e.container.style.width="",e.container.style.left=""),e.view.layout(e.size-i,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 e=!1;const t=this.viewItems.map(t=>e=t.size-t.minimumSize>0||e);e=!1;const i=this.viewItems.map(t=>e=t.maximumSize-t.size>0||e),s=[...this.viewItems].reverse();e=!1;const o=s.map(t=>e=t.size-t.minimumSize>0||e).reverse();e=!1;const n=s.map(t=>e=t.maximumSize-t.size>0||e).reverse();let r=0;for(let e=0;e<this.sashes.length;e++){const s=this.sashes[e];r+=this.viewItems[e].size;const a=!(t[e]&&n[e+1]),h=!(i[e]&&o[e+1]);if(a&&h){const i=N(e,-1),n=N(e+1,this.viewItems.length),a=this.findFirstSnapIndex(i),h=this.findFirstSnapIndex(n),l="number"==typeof a&&!this.viewItems[a].visible,d="number"==typeof h&&!this.viewItems[h].visible;l&&o[e]&&(r>0||this.startSnappingEnabled)?this.updateSash(s,exports.SashState.MINIMUM):d&&t[e]&&(r<this._contentSize||this.endSnappingEnabled)?this.updateSash(s,exports.SashState.MAXIMUM):this.updateSash(s,exports.SashState.DISABLED)}else a&&!h?this.updateSash(s,exports.SashState.MINIMUM):!a&&h?this.updateSash(s,exports.SashState.MAXIMUM):this.updateSash(s,exports.SashState.ENABLED)}}updateSash(e,t){w(e.container,"dv-disabled",t===exports.SashState.DISABLED),w(e.container,"dv-enabled",t===exports.SashState.ENABLED),w(e.container,"dv-maximum",t===exports.SashState.MAXIMUM),w(e.container,"dv-minimum",t===exports.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 e=document.createElement("div"),t=this._orientation===exports.Orientation.HORIZONTAL?"dv-horizontal":"dv-vertical";return e.className=`dv-split-view-container ${t}`,e}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.removeChild(this.element);break}for(const e of this.viewItems)e.dispose();this.element.remove()}}const U=(()=>{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 m{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(e,t){var i;super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new d,this.onDidChange=this._onDidChange.event,this._orientation=null!==(i=t.orientation)&&void 0!==i?i:exports.Orientation.VERTICAL,this.element=document.createElement("div"),this.element.className="dv-pane-container",e.appendChild(this.element),this.splitview=new $(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:t.descriptor}),this.getPanes().forEach(e=>{const t=new m(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),b(this.element,"dv-animated"),this.animationTimer=setTimeout(()=>{this.animationTimer=void 0,f(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===exports.Orientation.HORIZONTAL?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===exports.Orientation.HORIZONTAL?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===exports.Orientation.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===exports.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===exports.Orientation.HORIZONTAL?this.orthogonalSize:this.size}get height(){return this.orientation===exports.Orientation.HORIZONTAL?this.size:this.orthogonalSize}constructor(e,t,i,s=0){this.view=e,this.orientation=t,this._onDidChange=new d,this.onDidChange=this._onDidChange.event,this._orthogonalSize=i,this._size=s,this._disposable=this.view.onDidChange(e=>{e?this._onDidChange.fire({size:this.orientation===exports.Orientation.VERTICAL?e.width:e.height,orthogonalSize:this.orientation===exports.Orientation.VERTICAL?e.height:e.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 Z extends m{get width(){return this.orientation===exports.Orientation.HORIZONTAL?this.size:this.orthogonalSize}get height(){return this.orientation===exports.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===exports.Orientation.HORIZONTAL?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===exports.Orientation.HORIZONTAL?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===exports.Orientation.HORIZONTAL?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===exports.Orientation.HORIZONTAL?this.maximumSize:this.maximumOrthogonalSize}get priority(){if(0===this.children.length)return exports.LayoutPriority.Normal;const e=this.children.map(e=>void 0===e.priority?exports.LayoutPriority.Normal:e.priority);return e.some(e=>e===exports.LayoutPriority.High)?exports.LayoutPriority.High:e.some(e=>e===exports.LayoutPriority.Low)?exports.LayoutPriority.Low:exports.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 Z&&(t.margin=e)})}constructor(e,t,i,s,o,n,r,a){if(super(),this.orientation=e,this.proportionalLayout=t,this.styles=i,this._childrenDisposable=exports.DockviewDisposable.NONE,this.children=[],this._onDidChange=new d,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new d,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._orthogonalSize=o,this._size=s,this.element=document.createElement("div"),this.element.className="dv-branch-node",a){const e={views:a.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=a.map(e=>e.node),this.splitview=new $(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:t,styles:i,margin:r})}else this.splitview=new $(this.element,{orientation:this.orientation,proportionalLayout:t,styles:i,margin:r}),this.splitview.layout(this.size,this.orthogonalSize);this.disabled=n,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 m(exports.DockviewEvent.any(...this.children.map(e=>e.onDidChange))(e=>{this._onDidChange.fire({size:e.orthogonalSize})}),...this.children.map((e,t)=>e instanceof Z?e.onDidVisibilityChange(({visible:e})=>{this.setChildVisible(t,e)}):exports.DockviewDisposable.NONE))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach(e=>e.dispose()),super.dispose()}}function Y(e,t){if(e instanceof j)return e;if(e instanceof Z)return Y(e.children[t?e.children.length-1:0],t);throw new Error("invalid node")}function X(e,t,i){if(e instanceof Z){const s=new Z(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(X(i,i.size,i.orthogonalSize),i.size,0,!0)}return s}return new j(e.view,e.orientation,i)}function q(e,t,i){if(e instanceof Z){const s=new Z(se(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 Z?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(q(r,i,h),h,0,!0)}return s}return new j(e.view,se(e.orientation),i)}function K(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 Q(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");if(/\bdv-grid-view\b/.test(t.className))return[];const i=K(t);return[...Q(t.parentElement.parentElement.parentElement),i]}function ee(e,t,i){if(ie(e,t)===te(i)){const[e,s]=T(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 te(e){return"top"===e||"bottom"===e?exports.Orientation.VERTICAL:exports.Orientation.HORIZONTAL}function ie(e,t){return t.length%2==0?se(e):e}const se=e=>e===exports.Orientation.HORIZONTAL?exports.Orientation.VERTICAL:exports.Orientation.HORIZONTAL;function oe(e){return!!e.children}const ne=(e,t)=>{const i=t===exports.Orientation.VERTICAL?e.box.width:e.box.height;return oe(e)?{type:"branch",data:e.children.map(e=>ne(e,se(t))),size:i}:"number"==typeof e.cachedVisibleSize?{type:"leaf",data:e.view.toJSON(),size:e.cachedVisibleSize,visible:!1}:{type:"leaf",data:e.view.toJSON(),size:i}};class re{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=q(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 Z&&(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=Q(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(),ne(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=Q(e.element)),this.hasMaximizedView()&&this.exitMaximizedView();const i={root:ne(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation};return t&&(i.maximizedNode={location:t}),e&&this.maximizeView(e),i}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 Z(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize,this.locked,this.margin)}deserialize(e,t){const i=e.orientation,s=i===exports.Orientation.VERTICAL?e.height:e.width;if(this._deserialize(e.root,i,t,s),this.layout(e.width,e.height),e.maximizedNode){const t=e.maximizedNode.location,[i,s]=this.getNode(t);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,se(t),i,e.size),visible:s.visible}));n=new Z(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=X(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 e=this.root;if(e.element.remove(),this._root=new Z(se(e.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size,this.locked,this.margin),0===e.children.length);else if(1===e.children.length){const t=e.children[0];e.removeChild(0).dispose(),e.dispose(),this._root.addChild(q(t,t.orthogonalSize,t.size),exports.Sizing.Distribute,0)}else this._root.addChild(e,exports.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,se(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 Y(o.children[t?n-1:n+1],t)}return Y(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 v,this._onDidChange=new d,this.onDidChange=this._onDidChange.event,this._onDidViewVisibilityChange=new d,this.onDidViewVisibilityChange=this._onDidViewVisibilityChange.event,this._onDidMaximizedNodeChange=new d,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 Z(i,e,t,0,0,this.locked,this.margin)}isViewVisible(e){const[t,i]=T(e),[,s]=this.getNode(t);if(!(s instanceof Z))throw new Error("Invalid from location");return s.isChildVisible(i)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,s]=T(e),[,o]=this.getNode(i);if(!(o instanceof Z))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 Z))throw new Error("Invalid location");s.moveChild(t,i)}addView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[s,o]=T(i),[n,r]=this.getNode(s);if(r instanceof Z){const i=new j(e,se(r.orientation),r.orthogonalSize);r.addChild(i,t,o)}else{const[i,...a]=[...n].reverse(),[h,...l]=[...s].reverse();let d=0;const p=i.getChildCachedVisibleSize(h);"number"==typeof p&&(d=exports.Sizing.Invisible(p));i.removeChild(h).dispose();const u=new Z(r.orientation,this.proportionalLayout,this.styles,r.size,r.orthogonalSize,this.locked,this.margin);i.addChild(u,r.size,h);const c=new j(r.view,i.orientation,r.size);u.addChild(c,d,0),"number"!=typeof t&&"split"===t.type&&(t={type:"split",index:0});const m=new j(e,i.orientation,r.size);u.addChild(m,t,o)}}remove(e,t){const i=Q(e.element);return this.removeView(i,t)}removeView(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,s]=T(e),[o,n]=this.getNode(i);if(!(n instanceof Z))throw new Error("Invalid location");const r=n.children[s];if(!(r instanceof j))throw new Error("Invalid location");if(n.removeChild(s,t),r.dispose(),1!==n.children.length)return r.view;const a=n.children[0];if(0===o.length)return a instanceof j||(n.removeChild(0,t),this.root=a),r.view;const[h,...l]=[...o].reverse(),[d,...p]=[...i].reverse(),u=n.isChildVisible(0);n.removeChild(0,t);const c=h.children.map((e,t)=>h.getChildSize(t));if(h.removeChild(d,t).dispose(),a instanceof Z){c.splice(d,1,...a.children.map(e=>e.size));for(let e=0;e<a.children.length;e++){const t=a.children[e];h.addChild(t,t.size,d+e)}for(;a.children.length>0;)a.removeChild(0)}else{const e=new j(a.view,se(a.orientation),a.size),t=u?a.orthogonalSize:exports.Sizing.Invisible(a.orthogonalSize);h.addChild(e,t,d)}a.dispose();for(let e=0;e<c.length;e++)h.resizeChild(e,c[e]);return r.view}layout(e,t){const[i,s]=this.root.orientation===exports.Orientation.HORIZONTAL?[t,e]:[e,t];this.root.layout(i,s)}getNode(e,t=this.root,i=[]){if(0===e.length)return[i,t];if(!(t instanceof Z))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 ae=(()=>{const e={disableAutoResizing:void 0,proportionalLayout:void 0,orientation:void 0,hideBorders:void 0,className:void 0};return Object.keys(e)})();class he extends m{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(_(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 le=L();function de(e){switch(e){case"left":return"left";case"right":return"right";case"above":return"top";case"below":return"bottom";default:return"center"}}class pe 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(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._id=le.next(),this._groups=new Map,this._onDidRemove=new d,this.onDidRemove=this._onDidRemove.event,this._onDidAdd=new d,this.onDidAdd=this._onDidAdd.event,this._onDidMaximizedChange=new d,this.onDidMaximizedChange=this._onDidMaximizedChange.event,this._onDidActiveChange=new d,this.onDidActiveChange=this._onDidActiveChange.event,this._bufferOnDidLayoutChange=new u,this.onDidLayoutChange=this._bufferOnDidLayoutChange.onEvent,this._onDidViewVisibilityChangeMicroTaskQueue=new u,this.onDidViewVisibilityChangeMicroTaskQueue=this._onDidViewVisibilityChangeMicroTaskQueue.onEvent,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new A(this.element),this._classNames.setClassNames(null!==(i=t.className)&&void 0!==i?i:""),e.appendChild(this.element),this.gridview=new re(!!t.proportionalLayout,t.styles,t.orientation,t.locked,t.margin),this.gridview.locked=!!t.locked,this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidMaximizedNodeChange(e=>{this._onDidMaximizedChange.fire({panel:e.view,isMaximized:e.isMaximized})}),this.gridview.onDidViewVisibilityChange(()=>this._onDidViewVisibilityChangeMicroTaskQueue.fire()),this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.forceRelayout()}),exports.DockviewDisposable.from(()=>{var e;null===(e=this.element.parentElement)||void 0===e||e.removeChild(this.element)}),this.gridview.onDidChange(()=>{this._bufferOnDidLayoutChange.fire()}),exports.DockviewEvent.any(this.onDidAdd,this.onDidRemove,this.onDidActiveChange)(()=>{this._bufferOnDidLayoutChange.fire()}),this._onDidMaximizedChange,this._onDidViewVisibilityChangeMicroTaskQueue,this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(Q(e.element),t),this._bufferOnDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(Q(e.element))}updateOptions(e){var t,i,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(e,t=[0],i){this.gridview.addView(e,null!=i?i:exports.Sizing.Distribute,t),this._onDidAdd.fire(e)}doRemoveGroup(e,t){if(!this._groups.has(e.id))throw new Error("invalid operation");const i=this._groups.get(e.id),s=this.gridview.remove(e,exports.Sizing.Distribute);if(i&&!(null==t?void 0:t.skipDispose)&&(i.disposable.dispose(),i.value.dispose(),this._groups.delete(e.id),this._onDidRemove.fire(e)),!(null==t?void 0:t.skipActive)&&this._activeGroup===e){const e=Array.from(this._groups.values());this.doSetGroupActive(e.length>0?e[0].value:void 0)}return s}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=Q(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=Q(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 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 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 me{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 ve{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 ge extends m{constructor(e,t){super(),this.el=e,this.disabled=t,this.dataDisposable=new v,this.pointerEventsDisposable=new v,this._onDragStart=new d,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,p(this.el,"dragstart",e=>{if(e.defaultPrevented||this.isCancelled(e)||this.disabled)return void e.preventDefault();const t=P();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","")}}),p(this.el,"dragend",()=>{this.pointerEventsDisposable.dispose(),setTimeout(()=>{this.dataDisposable.dispose()},0)}))}}class _e extends m{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(p(this.element,"dragenter",e=>{this.onDragEnter(e)},!0)),this.addDisposables(p(this.element,"dragover",e=>{this.onDragOver(e)},!0)),this.addDisposables(p(this.element,"dragleave",e=>{this.onDragLeave(e)})),this.addDisposables(p(this.element,"dragend",e=>{this.onDragEnd(e)})),this.addDisposables(p(this.element,"drop",e=>{this.onDrop(e)}))}}class fe extends r{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}constructor(e){super(),this.options=e}}function be(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 we(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 De={value:20,type:"percentage"},Ce={value:50,type:"percentage"};class xe extends m{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 d,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new d,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;xe.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 fe({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&&xe.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[xe.USED_EVENT_ID]=!0}isAlreadyUsed(e){const t=e[xe.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,D="bottom"===e,C=!v&&f,x=!v&&_,y=!g&&b,S=!g&&D;let G=1;const P=null!==(d=null===(l=this.options.overlayModel)||void 0===l?void 0:l.size)&&void 0!==d?d:Ce;if("percentage"===P.type?G=M(P.value,0,100)/100:((C||x)&&(G=M(0,P.value,t)/t),(y||S)&&(G=M(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):x?P.width=t*G:y?P.height=i*G:S&&(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&&D&&(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}`:""),w(a,"dv-drop-target-left",_),w(a,"dv-drop-target-right",f),w(a,"dv-drop-target-top",b),w(a,"dv-drop-target-bottom",D),w(a,"dv-drop-target-anchor-line",v&&(_||f)||g&&(b||D)),w(a,"dv-drop-target-center","center"===e),void(n.changed&&(w(a,"dv-drop-target-anchor-container-changed",!0),setTimeout(()=>{w(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+"%"):x?A.width=100*G+"%":y?A.height=100*G+"%":S&&(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&&D&&(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||D);w(this.overlayElement,"dv-drop-target-small-vertical",g),w(this.overlayElement,"dv-drop-target-small-horizontal",v),w(this.overlayElement,"dv-drop-target-selection-line",z),w(this.overlayElement,"dv-drop-target-left",_),w(this.overlayElement,"dv-drop-target-right",f),w(this.overlayElement,"dv-drop-target-top",b),w(this.overlayElement,"dv-drop-target-bottom",D),w(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:De;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)}}xe.USED_EVENT_ID="__dockview_droptarget_event_is_used__";const ye=(()=>{const e={disableAutoResizing:void 0,disableDnd:void 0,className:void 0};return Object.keys(e)})();class Se extends a{constructor(e,t,i,s){super(),this.nativeEvent=e,this.position=t,this.getData=i,this.panel=s}}class Ge extends r{constructor(){super()}}class Pe extends m{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 v,this._onDidDimensionChange=new d,this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new d,this.onDidFocusChange=this._onDidChangeFocus.event,this._onWillFocus=new d,this.onWillFocus=this._onWillFocus.event,this._onDidVisibilityChange=new d,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onWillVisibilityChange=new d,this.onWillVisibilityChange=this._onWillVisibilityChange.event,this._onDidActiveChange=new d,this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new d,this.onActiveChange=this._onActiveChange.event,this._onDidParametersChange=new d,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 Ae extends Pe{constructor(e,t){super(e,t),this._onDidConstraintsChangeInternal=new d,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new d({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new d,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 ze extends Ae{set pane(e){this._pane=e}constructor(e,t){super(e,t),this._onDidExpansionChange=new d({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new d({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new d({}),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 Ie extends m{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=C(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 Ge;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 Te extends Ie{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 ze(e.id,e.component)),this._onDidChangeExpansionState=new d({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new d,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})}),p(this.element,"mouseenter",e=>{this.api._onMouseEnter.fire(e)}),p(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?b(this.header,"focused"):f(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(e,t){this._size=e,this._orthogonalSize=t;const[i,s]=this.orientation===exports.Orientation.HORIZONTAL?[e,t]:[t,e];super.layout(i,s)}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 Ee extends Te{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 d,this.onDidDrop=this._onDidDrop.event,this._onUnhandledDragOverEvent=new d,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 ge{getData(){return s.getInstance().setData([new i(t,e)],i.prototype),{dispose:()=>{s.getInstance().clearData(i.prototype)}}}}(this.header),this.target=new xe(this.element,{acceptedTargetZones:["top","bottom"],overlayModel:{activationSize:{type:"percentage",value:50}},canDisplayOverlay:(e,t)=>{const i=n();if(i&&i.paneId!==this.id&&i.viewId===this.accessor.id)return!0;const s=new Se(e,t,n,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=n();if(!t||t.viewId!==this.accessor.id)return void this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,api:new ce(this.accessor),getData:n}));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:n,api:new ce(this.accessor)}));const r=i.panels,a=r.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(r.length-1,h)),i.movePanel(a,h)}}class Oe extends m{get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this.disposable=new v,this._onDidFocus=new d,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new d,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 xe(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=o();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=C(a);this.focusTracker=e;const t=new m;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;b(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(()=>{f(t,"dv-dragged"),t.remove()},0)}class ke extends ge{constructor(e,t,i,o,n){super(e,n),this.accessor=t,this.group=i,this.panel=o,this.panelTransfer=s.getInstance()}getData(e){return this.panelTransfer.setData([new t(this.accessor.id,this.group.id,this.panel.id)],t.prototype),{dispose:()=>{this.panelTransfer.clearData(t.prototype)}}}}class Me extends m{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 d,this.onPointerDown=this._onPointDown.event,this._onTabClick=new d,this.onTabClick=this._onTabClick.event,this._onDropped=new d,this.onDrop=this._onDropped.event,this._onDragStart=new d,this.onDragStart=this._onDragStart.event,this._onDragEnd=new d,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,w(this.element,"dv-inactive-tab",!0),this.dragHandler=new ke(this._element,this.accessor,this.group,this.panel,!!this.accessor.options.disableDnd),this.dropTarget=new xe(this._element,{acceptedTargetZones:["left","right"],overlayModel:this._buildOverlayModel(),canDisplayOverlay:(e,t)=>{var i;if(this.group.locked)return!1;const s=o();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(()=>{w(this.element,"dv-tab--dragging",!0)})}),p(this._element,"dragend",e=>{w(this.element,"dv-tab--dragging",!1),this._onDragEnd.fire(e)}),this.dragHandler,p(this._element,"pointerdown",e=>{this._onPointDown.fire(e)}),p(this._element,"click",e=>{this._onTabClick.fire(e)}),p(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){w(this.element,"dv-active-tab",e),w(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 Le{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 Ne extends ge{constructor(e,t,i,o){super(e,o),this.accessor=t,this.group=i,this.panelTransfer=s.getInstance(),this.addDisposables(p(e,"pointerdown",e=>{e.shiftKey&&(e[y]=!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 i=e.dataTransfer;this.panelTransfer.setData([new t(this.accessor.id,this.group.id,null)],t.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(i){const e=document.createElement("div");e.style.backgroundColor=o,e.style.color=n,e.style.padding="2px 8px",e.style.height="24px",e.style.fontSize="11px",e.style.lineHeight="20px",e.style.borderRadius="12px",e.style.position="absolute",e.style.pointerEvents="none",e.style.top="-9999px",e.textContent=`Multiple Panels (${this.group.size})`,Ve(i,e,{y:-10,x:30})}return{dispose:()=>{this.panelTransfer.clearData(t.prototype)}}}}class Re extends m{get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this._onDrop=new d,this.onDrop=this._onDrop.event,this._onDragStart=new d,this.onDragStart=this._onDragStart.event,this._element=document.createElement("div"),this._element.className="dv-void-container",this._element.draggable=!this.accessor.options.disableDnd,w(this._element,"dv-draggable",!this.accessor.options.disableDnd),this.addDisposables(this._onDrop,this._onDragStart,p(this._element,"pointerdown",()=>{this.accessor.doSetGroupActive(this.group)})),this.handler=new Ne(this._element,e,t,!!this.accessor.options.disableDnd),this.dropTarget=new xe(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:(e,i)=>{const s=o();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,w(this._element,"dv-draggable",!this.accessor.options.disableDnd),this.handler.setDisabled(!!this.accessor.options.disableDnd)}}class We extends m{get element(){return this._element}get orientation(){return this._orientation}set orientation(e){this._orientation!==e&&(this._scrollOffset=0,this._orientation=e,f(this._scrollbar,"dv-scrollbar-vertical","dv-scrollbar-horizontal"),b(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(p(this.element,"wheel",e=>{this._scrollOffset+=e.deltaY*We.MouseWheelSpeed,this.calculateScrollbarStyles()}),p(this._scrollbar,"pointerdown",e=>{e.preventDefault(),w(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=()=>{w(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)}),p(this.element,"scroll",()=>{this.calculateScrollbarStyles()}),p(this.scrollableElement,"scroll",()=>{this._scrollOffset="horizontal"===this._orientation?this.scrollableElement.scrollLeft:this.scrollableElement.scrollTop,this.calculateScrollbarStyles()}),_(this.element,()=>{w(this.element,"dv-scrollable-resizing",!0),this._animationTimer&&clearTimeout(this._animationTimer),this._animationTimer=setTimeout(()=>{clearTimeout(this._animationTimer),w(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=M(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}}We.MouseWheelSpeed=1;const He=[{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 Fe{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 $e(){return Be||(Be=new Fe(He,!0)),Be}function Ue(e,t,i){const s=(null!=i?i:$e()).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:$e()).resolveValue(e)}class je extends m{get element(){return this._element}constructor(e){super(),this._palette=e,this._onClick=new d,this.onClick=this._onClick.event,this._onContextMenu=new d,this.onContextMenu=this._onContextMenu.event,this._onDragStart=new d,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,p(this._element,"click",e=>{this._onClick.fire(e)}),p(this._element,"contextmenu",e=>{this._onContextMenu.fire(e)}),p(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;Ue(this._element,e,this._palette),w(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,w(this._label,"dv-tab-group-chip-label--empty",!e)}updateCollapsed(e){w(this._element,"dv-tab-group-chip--collapsed",e)}}class Ze{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 Ye extends Ze{_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.innerHTML="",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 Xe extends Ze{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.innerHTML=""),e.style.backgroundColor=h,a?(e.style.width="2px",e.style.height=`${s}px`):(e.style.width=`${s}px`,e.style.height="2px"))}}const qe=new Map;class Ke{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:qe}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")?Xe:Ye;!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 je(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 je?s.push(i.onContextMenu(t=>{this._callbacks.onChipContextMenu(e,t)}),i.onDragStart(t=>{this._callbacks.onChipDragStart(e,i,t)})):s.push(p(i.element,"contextmenu",t=>{this._callbacks.onChipContextMenu(e,t)}),p(i.element,"dragstart",t=>{this._callbacks.onChipDragStart(e,i,t)}));const o=new m(...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(w(i.element,"dv-tab--grouped",a),r){const t=r.panelIds,n=t[0]===s,a=t[t.length-1]===s;w(i.element,"dv-tab--group-first",n),w(i.element,"dv-tab--group-last",a),Ue(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 w(i.element,"dv-tab--group-first",!1),w(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 Qe extends m{get showTabsOverflowControl(){return this._showTabsOverflowControl}set showTabsOverflowControl(e){if(this._showTabsOverflowControl!=e&&(this._showTabsOverflowControl=e,e)){const e=new g(this._tabsList);this._observerDisposable.value=new m(e,e.onDidChange(e=>{const t=e.hasScrollX||e.hasScrollY;this.toggleDropdown({reset:!t}),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}),p(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 m(p(e,"dragover",e=>{this._animState&&e.preventDefault()}),p(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),f(this._tabsList,"dv-horizontal","dv-vertical"),"vertical"===e?b(this._tabsList,"dv-tabs-container-vertical","dv-vertical"):(f(this._tabsList,"dv-tabs-container-vertical"),b(this._tabsList,"dv-horizontal"));for(const t of this._tabs)t.value.setDirection(e)}}constructor(e,t,i){super(),this.group=e,this.accessor=t,this._observerDisposable=new v,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 d,this.onTabDragStart=this._onTabDragStart.event,this._onDrop=new d,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new d,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onOverflowTabsChange=new d,this.onOverflowTabsChange=this._onOverflowTabsChange.event,this._tabsList=document.createElement("div"),this._tabsList.className="dv-tabs-container",this.showTabsOverflowControl=i.showTabsOverflowControl,"native"===t.options.scrollbars?this._element=this._tabsList:(this._scrollbar=new We(this._tabsList),this._scrollbar.orientation=this.direction,this._element=this._scrollbar.element,this.addDisposables(this._scrollbar)),this._tabGroupManager=new Ke({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)}},p(this.element,"pointerdown",e=>{if(e.defaultPrevented)return;0===e.button&&this.accessor.doSetGroupActive(this.group)}),p(this._tabsList,"dragover",e=>{var t,i,s,n;if(!this.accessor.options.disableDnd){if(this._animState){const e=o();(null==e?void 0:e.tabGroupId)&&e.groupId!==this.group.id&&this._animState.sourceTabGroupId!==e.tabGroupId&&(this._animState=null)}if(!this._animState){const e=o();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===(n=null===(s=this.group.model.dropTargetContainer)||void 0===s?void 0:s.model)||void 0===n||n.clear()),this.handleDragOver(e)}},!0),p(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),p(this._tabsList,"dragend",()=>{this.resetDragAnimation()}),p(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),exports.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 Me(e,this.accessor,this.group);i.setContent(e.view.tab),"horizontal"!==this._direction&&i.setDirection(this._direction);const s=new m(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",w(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,n,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=o(),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===(n=this.group.model.getTabGroupForPanel(i.panel.id))||void 0===n?void 0:n.id)&&void 0!==r?r:null;this._onDrop.fire({event:e.nativeEvent,index:d,targetTabGroupId:p})}}),i.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new Le(e,{kind:"tab",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:o}))})),n={value:i,disposable:s};this.addTab(n,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()}updateTabGroups(){this._tabGroupManager.update()}refreshTabGroupAccent(){this._tabGroupManager.refreshAccents()}_handleChipDragStart(e,i,o){var n;const r=e.panelIds[0],a=r?this._tabs.findIndex(e=>e.value.panel.id===r):-1,h=i.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:o.clientX-h.left,sourceGapWidth:l,containerLeft:this._tabsList.getBoundingClientRect().left};const d=s.getInstance();d.setData([new t(this.accessor.id,this.group.id,null,e.id)],t.prototype);const p=P();if(this._chipDragCleanup={dispose:()=>{d.clearData(t.prototype),p.release()}},o.dataTransfer&&(o.dataTransfer.effectAllowed="move",0===o.dataTransfer.items.length&&o.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",w(e.value.element,"dv-tab--dragging",!0));const o=this._tabGroupManager.chipRenderers.get(e.id);o&&(o.chip.element.style.transition="none",w(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(o,e,i.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){a=a<(d+p+1)/2?d:p+1;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",w(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,w(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"),w(t,i,!1);else{t.style.marginLeft="0px",w(t,i,!0);const e=()=>{t.style.removeProperty("margin-left"),w(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"),w(e.value.element,"dv-tab--shifting",!1);for(const[,e]of this._tabGroupManager.chipRenderers)e.chip.element.style.removeProperty("margin-left"),w(e.chip.element,"dv-tab-group-chip--shifting",!1);this._tabGroupManager.positionUnderlines()}_commitGroupMove(e,t){var i,s,n;const r=o();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!==(n=r.tabGroupId)&&void 0!==n?n: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)`,w(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)`,w(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)w(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 et=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},tt=()=>et({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 it extends m{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?(b(this._element,"dv-groupview-header-vertical"),b(this.rightActionsContainer,"dv-right-actions-container-vertical"),this.tabs.direction=e):(f(this._element,"dv-groupview-header-vertical"),f(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 v,this._onDrop=new d,this.onDrop=this._onDrop.event,this._onGroupDragStart=new d,this.onGroupDragStart=this._onGroupDragStart.event,this._onWillShowOverlay=new d,this.onWillShowOverlay=this._onWillShowOverlay.event,this._element=document.createElement("div"),this._element.className="dv-tabs-and-actions-container",w(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 Qe(t,e,{showTabsOverflowControl:!e.options.disableTabsOverflowList}),this.voidContainer=new Re(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 Le(e,{kind:"header_space",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:o}))}),p(this.leftActionsContainer,"dragleave",e=>{const t=e.relatedTarget;this.leftActionsContainer.contains(t)||this._element.contains(t)||this.tabs.clearExternalAnimState()}),p(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())}),p(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(){w(this._element,"dv-single-tab",1===this.size)}toggleDropdown(e){const t=e.reset?[]:e.tabs,i=e.reset?[]:e.tabGroups;this._overflowTabs=t,this._overflowTabGroups=i;const s=this._overflowTabs.length;if(s>0&&this.dropdownPart)return void this.dropdownPart.update({tabs:s});if(0===s)return void this._dropdownDisposable.dispose();const o=document.createElement("div");o.className="dv-tabs-overflow-dropdown-root";const n=function(){const e=document.createElement("div");e.className="dv-tabs-overflow-dropdown-default";const t=document.createElement("span");t.textContent="";const i=tt();return e.appendChild(i),e.appendChild(t),{element:e,update:e=>{t.textContent=`${e.tabs}`}}}();n.update({tabs:s}),this.dropdownPart=n,o.appendChild(n.element),this.rightActionsContainer.prepend(o),this._dropdownDisposable.value=new m(exports.DockviewDisposable.from(()=>{var e,t;o.remove(),null===(t=null===(e=this.dropdownPart)||void 0===e?void 0:e.dispose)||void 0===t||t.call(e),this.dropdownPart=null}),p(o,"pointerdown",e=>{e.preventDefault()},{capture:!0}),p(o,"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(),n=new Map;for(const e of s)if(i.has(e.id))for(const t of e.panelIds)n.set(t,e);const r=new Set;for(const e of this.tabs.tabs.filter(e=>this._overflowTabs.includes(e.panel.id))){const i=n.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",Ue(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),o=s.view.createTabRenderer("headerOverflow").element,a=document.createElement("div");w(a,"dv-tab",!0),w(a,"dv-active-tab",s.api.isActive),w(a,"dv-inactive-tab",!s.api.isActive),i&&w(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(o),t.appendChild(a)}const a=I(o);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 st extends a{constructor(e,t,i,s,o){super(),this.nativeEvent=e,this.target=t,this.position=i,this.getData=s,this.group=o}}const ot=(()=>{const e={disableAutoResizing:void 0,hideBorders:void 0,singleTabMode:void 0,disableFloatingGroups:void 0,floatingGroupBounds:void 0,popoutUrl:void 0,defaultRenderer:void 0,defaultHeaderPosition:void 0,debug:void 0,rootOverlayModel:void 0,locked:void 0,disableDnd:void 0,className:void 0,noPanelsOverlay:void 0,dndEdges:void 0,theme:void 0,disableTabsOverflowList:void 0,scrollbars:void 0,getTabContextMenuItems:void 0,getTabGroupChipContextMenuItems:void 0,createTabGroupChipComponent:void 0,tabGroupColors:void 0,tabGroupAccent:void 0};return Object.keys(e)})();function nt(e){return!!e.referencePanel}function rt(e){return!!e.referenceGroup}function at(e){return!!e.referencePanel}function ht(e){return!!e.referenceGroup}class lt extends m{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 d,this.onDidChange=this._onDidChange.event,this._onDidPanelChange=new d,this.onDidPanelChange=this._onDidPanelChange.event,this._onDidCollapseChange=new d,this.onDidCollapseChange=this._onDidCollapseChange.event,this._onDidDestroy=new d,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 dt extends r{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 pt extends dt{get kind(){return this._kind}constructor(e){super(e),this._kind=e.kind}}class ut extends m{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,w(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&&D(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,f(this.container,"dv-groupview-header-top","dv-groupview-header-bottom","dv-groupview-header-left","dv-groupview-header-right"),b(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,w(this.container,"dv-groupview-floating",!1),w(this.container,"dv-groupview-popout",!1),w(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"]),w(this.container,"dv-groupview-floating",!0);break;case"popout":this.contentContainer.dropTarget.setTargetZones(["center"]),w(this.container,"dv-groupview-popout",!0);break;case"edge":this.contentContainer.dropTarget.setTargetZones(["center"]),w(this.container,"dv-groupview-edge",!0)}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,i,s,n){var r,a;super(),this.container=e,this.accessor=t,this.id=i,this.options=s,this.groupPanel=n,this._isGroupActive=!1,this._locked=!1,this._rightHeaderActionsDisposable=new v,this._leftHeaderActionsDisposable=new v,this._prefixHeaderActionsDisposable=new v,this._location={type:"grid"},this.mostRecentlyUsed=[],this._overwriteRenderContainer=null,this._overwriteDropTargetContainer=null,this._onDidChange=new d,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 d,this.onMove=this._onMove.event,this._onDidDrop=new d,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new d,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new d,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onTabDragStart=new d,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new d,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new d,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPanelTitleChange=new d,this.onDidPanelTitleChange=this._onDidPanelTitleChange.event,this._onDidPanelParametersChange=new d,this.onDidPanelParametersChange=this._onDidPanelParametersChange.event,this._onDidRemovePanel=new d,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new d,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onUnhandledDragOverEvent=new d,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this._tabGroups=[],this._tabGroupMap=new Map,this._panelToTabGroup=new Map,this._tabGroupIdCounter=0,this._pendingTabGroupUpdate=!1,this._onDidCreateTabGroup=new d,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new d,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new d,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new d,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new d,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new d,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,w(this.container,"dv-groupview",!0),this._api=new ve(this.accessor),this.tabsContainer=new it(this.accessor,this.groupPanel),this.contentContainer=new Oe(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=o(),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 Le(e,{kind:"content",panel:this.activePanel,api:this._api,group:this.groupPanel,getData:o}))}),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 lt(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 m(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()}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,w(this.container,"dv-active-group",e),w(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 m(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,p(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 st(e,i,t,o,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 n="number"==typeof s?this.panels[s]:void 0,r=new pt({nativeEvent:t,position:i,panel:n,getData:()=>o(),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=o();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 dt({nativeEvent:t,position:i,panel:n,getData:()=>o(),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 ct extends Pe{constructor(e,t,i){super(e,t),this._onDidConstraintsChangeInternal=new d,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new d,this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new d,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 mt extends Ie{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 ct(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 d,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 vt="dockview: DockviewGroupPanelApiImpl not initialized";class gt extends ct{get location(){if(!this._group)throw new Error(vt);return this._group.model.location}constructor(e,t){super(e,"__dockviewgroup__"),this.accessor=t,this._onDidLocationChange=new d,this.onDidLocationChange=this._onDidLocationChange.event,this._onDidActivePanelChange=new d,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidCollapsedChange=new d,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(vt);this._group.model.headerPosition=e}getHeaderPosition(){if(!this._group)throw new Error(vt);return this._group.model.headerPosition}moveTo(e){var t,i,s,o;if(!this._group)throw new Error(vt);const n=null!==(t=e.group)&&void 0!==t?t:this.accessor.addGroup({direction:we(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(vt);"grid"===this.location.type&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw new Error(vt);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw new Error(vt);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 _t extends mt{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 gt(t,e)),this._explicitConstraints={},this.api.initialize(this),this._model=new ut(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 ft={name:"abyss",className:"dockview-theme-abyss",colorScheme:"dark",tabGroupIndicator:"none"};class bt extends ct{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 d,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidActiveGroupChange=new d,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new d,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new d,this.onDidRendererChange=this._onDidRendererChange.event,this._onDidLocationChange=new d,this.onDidLocationChange=this._onDidLocationChange.event,this.groupEventsDisposable=new v,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 m(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 wt extends m{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 bt(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 Ge;this.api._onWillFocus.fire(e),e.defaultPrevented||this.api.isActive||this.api.setActive()}toJSON(){return{id:this.id,contentComponent:this.view.contentComponent,tabComponent:this.view.tabComponent,params:Object.keys(this._params||{}).length>0?this._params:void 0,title:this.title,renderer:this._renderer,minimumHeight:this._minimumHeight,maximumHeight:this._maximumHeight,minimumWidth:this._minimumWidth,maximumWidth:this._maximumWidth}}setTitle(e){e!==this.title&&(this._title=e,this.api._onDidTitleChange.fire({title:e}))}setRenderer(e){e!==this.renderer&&(this._renderer=e,this.api._onDidRendererChange.fire({renderer:e}))}update(e){var t;this._params=Object.assign(Object.assign({},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 Dt extends m{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(et({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()}),p(this.action,"pointerdown",e=>{e.preventDefault()}),p(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 Ct{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"}))}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 Dt}console.warn(`dockview: tabComponent '${t}' was not found. falling back to the default tab.`)}return new Dt}}class xt{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 Ct(this.accessor,o,h,l),p=new wt(o,h,l,this.accessor,new ve(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 yt extends m{get element(){return this._element}constructor(){super(),this._element=document.createElement("div"),this._element.className="dv-watermark"}init(e){}}const St=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 Gt extends m{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 d,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new d,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})),St.push(this._element)}setVisible(e){e!==this.isVisible&&(this._isVisible=e,w(this.element,"dv-hidden",!this.isVisible))}bringToFront(){St.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=M(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=M(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=M(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=M(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 v,s=()=>{let e=null;const t=P();i.value=new m({dispose:()=>{t.release()}},p(window,"pointermove",t=>{const i=this.options.container.getBoundingClientRect(),s=t.clientX-i.left,o=t.clientY-i.top;w(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=M(o-e.y,-a,Math.max(0,i.height-n.height+a)),l=M(e.y-o+i.height-n.height,-a,Math.max(0,i.height-n.height+a)),d=M(s-e.x,-r,Math.max(0,i.width-n.width+r)),p=M(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)}),p(window,"pointerup",()=>{w(this._element,"dv-resize-container-dragging",!1),i.dispose(),this._onDidChangeEnd.fire()}))};this.addDisposables(i,p(e,"pointerdown",e=>{e.defaultPrevented?e.preventDefault():S(e)||s()}),p(this.options.content,"pointerdown",e=>{e.defaultPrevented||S(e)||e.shiftKey&&s()}),p(this.options.content,"pointerdown",()=>{St.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 v;this.addDisposables(i,p(t,"pointerdown",t=>{t.preventDefault();let s=null;const o=P();i.value=new m(p(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-Gt.MINIMUM_HEIGHT):Math.max(0,s.originalY+s.originalHeight-Gt.MINIMUM_HEIGHT);a=M(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:Gt.MINIMUM_HEIGHT,t=i.height-Math.max(0,a);l=M(n-a,e,t),h=i.height-a-l},v=()=>{const e=s.originalX+s.originalWidth>i.width?Math.max(0,i.width-Gt.MINIMUM_WIDTH):Math.max(0,s.originalX+s.originalWidth-Gt.MINIMUM_WIDTH);d=M(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:Gt.MINIMUM_WIDTH,t=i.width-Math.max(0,d);u=M(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()}},p(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(){St.destroy(this._element),this._element.remove(),super.dispose()}}Gt.MINIMUM_HEIGHT=20,Gt.MINIMUM_WIDTH=20;class Pt extends m{constructor(e,t){super(),this.group=e,this.overlay=t,this.addDisposables(t)}position(e){this.overlay.setBounds(e)}}const At=100,zt=100,It=100,Tt=300,Et=300;class Ot{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=G(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 m{constructor(e,t){super(),this.element=e,this.accessor=t,this.map={},this._disposed=!1,this.positionCache=new Ot,this.pendingUpdates=new Set,this.addDisposables(exports.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(e){const{panel:t,referenceContainer:i}=e;if(!this.map[t.api.id]){const e=function(){const e=document.createElement("div");return e.tabIndex=-1,e}();e.className="dv-render-overlay",e.style.visibility="hidden",this.map[t.api.id]={panel:t,disposable:exports.DockviewDisposable.NONE,destroy:exports.DockviewDisposable.NONE,element:e}}const s=this.map[t.api.id].element,o=t.view.content.element;o.parentElement!==s&&s.appendChild(o),s.parentElement!==this.element&&this.element.appendChild(s);const n=()=>{const e=t.api.id;this.pendingUpdates.has(e)||(this.pendingUpdates.add(e),requestAnimationFrame(()=>{if(this.pendingUpdates.delete(e),this.isDisposed||!this.map[e])return;const o=this.positionCache.getPosition(i.element),n=this.positionCache.getPosition(this.element),r=o.left-n.left,a=o.top-n.top,h=o.width,l=o.height;s.style.left=`${r}px`,s.style.top=`${a}px`,s.style.width=`${h}px`,s.style.height=`${l}px`,"hidden"===s.style.visibility&&(s.style.visibility=""),w(s,"dv-render-overlay-float","floating"===t.group.api.location.type)}))},r=()=>{t.api.isVisible&&(this.positionCache.invalidate(),n()),s.style.display=t.api.isVisible?"":"none"},a=new v,h=()=>{"floating"===t.api.location.type?queueMicrotask(()=>{const e=this.accessor.floatingGroups.find(e=>e.group===t.api.group);if(!e)return;const i=e.overlay.element,o=()=>{const e=Number(i.getAttribute("aria-level"));s.style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${2*e+1})`},n=new MutationObserver(()=>{o()});a.value=exports.DockviewDisposable.from(()=>n.disconnect()),n.observe(i,{attributeFilter:["aria-level"],attributes:!0}),o()}):s.style.zIndex=""},l=new m(a,new _e(s,{onDragEnd:e=>{i.dropTarget.dnd.onDragEnd(e)},onDragEnter:e=>{i.dropTarget.dnd.onDragEnter(e)},onDragLeave:e=>{i.dropTarget.dnd.onDragLeave(e)},onDrop:e=>{i.dropTarget.dnd.onDrop(e)},onDragOver:e=>{i.dropTarget.dnd.onDragOver(e)}}),t.api.onDidVisibilityChange(()=>{r()}),t.api.onDidDimensionsChange(()=>{t.api.isVisible&&n()}),t.api.onDidLocationChange(()=>{h()}));return this.map[t.api.id].destroy=exports.DockviewDisposable.from(()=>{var e;o.parentElement===s&&s.removeChild(o),null===(e=s.parentElement)||void 0===e||e.removeChild(s)}),h(),queueMicrotask(()=>{this.isDisposed||r()}),this.map[t.api.id].disposable.dispose(),this.map[t.api.id].disposable=l,this.map[t.api.id].resize=n,s}}function kt(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 Mt extends m{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 d,this.onWillClose=this._onWillClose.event,this._onDidClose=new d,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 kt(this,void 0,void 0,function*(){var e,t;if(this._window)throw new Error("instance of popout window is already open");const i=`${this.options.url}`,s=Object.entries({top:this.options.top,left:this.options.left,width:this.options.width,height:this.options.height}).map(([e,t])=>`${e}=${t}`).join(","),o=window.open(i,this.target,s);if(!o)return null;const n=new m;this._window={value:o,disposable:n},n.addDisposables(exports.DockviewDisposable.from(()=>{o.close()}),p(window,"beforeunload",()=>{this.close()}));const r=this.createPopoutWindowContainer();return this.className&&r.classList.add(this.className),null===(t=(e=this.options).onDidOpen)||void 0===t||t.call(e,{id:this.target,window:o}),new Promise((e,t)=>{o.addEventListener("unload",e=>{}),o.addEventListener("load",()=>{try{const t=o.document;t.title=document.title,t.body.appendChild(r),function(e,t){const i=Array.from(t);for(const t of i){if(t.href){const i=e.createElement("link");i.href=t.href,i.type=t.type,i.rel="stylesheet",e.head.appendChild(i)}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)}for(const t of i){const i=e.createElement("style");i.appendChild(e.createTextNode(t)),e.head.appendChild(i)}}}(t,window.document.styleSheets),p(o,"beforeunload",()=>{this.close()}),e(r)}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 Lt extends m{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 Nt extends m{constructor(e,t=window){super(),this._active=null,this._activeDisposable=new v,this._root=e,this._window=t,this._element=t.document.createElement("div"),this._element.className="dv-popover-anchor",this._element.style.position="relative",this._root.prepend(this._element),this.addDisposables(exports.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 m(p(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()}),p(this._window,"keydown",e=>{"Escape"!==e.key&&"Enter"!==e.key||this.close()}),p(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 Rt(e){if(!(e instanceof HTMLElement))return;const t=I(e);return(null==t?void 0:t.style.zIndex)?`calc(${t.style.zIndex} * 2)`:void 0}let Wt=0;const Ht=()=>"dv-ctx-menu-item-"+Wt++;function Ft(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 $t(){const e=document.createElement("div");return e.className="dv-context-menu-separator",e.setAttribute("role","separator"),e}function Ut(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 jt{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($t());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(Ft(i)&&i.element)h.appendChild(i.element);else if(Ft(i)&&i.component){const n=null===(o=(s=this.accessor.options).createContextMenuItemComponent)||void 0===o?void 0:o.call(s,{id:Ht(),component:i.component});n&&(n.init({panel:e,group:t,api:this.accessor.api,close:a,componentProps:i.componentProps}),h.appendChild(n.element))}else Ft(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:Rt(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($t()):"rename"===t?r.appendChild(Ut(e)):"colorPicker"===t?r.appendChild(Jt(e,this.accessor.tabGroupColorPalette)):Ft(t)&&t.element?r.appendChild(t.element):Ft(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:Rt(i.target)})}}class Zt extends m{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(e,t){super(),this.element=e,this._disabled=!1,this._disabled=t.disabled,this.addDisposables(exports.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 Yt{get minimumSize(){return this._isCollapsed?this._collapsedSize:this._expandedMinimumSize}get maximumSize(){return this._isCollapsed?this._collapsedSize:this._expandedMaximumSize}get element(){return this._group.element}get isCollapsed(){return this._isCollapsed}get lastExpandedSize(){return this._lastExpandedSize}get collapsedSize(){return this._collapsedSize}constructor(e,t,i){var s,o,n;this._onDidChange=new d,this.onDidChange=this._onDidChange.event,this.snap=!1,this.priority=exports.LayoutPriority.Low,this._isCollapsed=!1,this._group=t,this._orientation=i,t.element.classList.add("dv-edge-group"),t.element.dataset.testid=`dv-edge-group-${e.id}`,this._collapsedSize=null!==(s=e.collapsedSize)&&void 0!==s?s:35,this._expandedMaximumSize=null!==(o=e.maximumSize)&&void 0!==o?o:Number.POSITIVE_INFINITY,this._expandedMinimumSize=void 0!==e.minimumSize?e.minimumSize:this._collapsedSize+50,this._lastExpandedSize=null!==(n=e.initialSize)&&void 0!==n?n:200,e.collapsed&&(this._isCollapsed=!0,t.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 Xt{get element(){return this._dockviewElement}constructor(e,t){this._dockviewElement=e,this._layoutDockview=t,this.priority=exports.LayoutPriority.High,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this._onDidChange=new d,this.onDidChange=this._onDidChange.event}layout(e,t){this._layoutDockview(t,e)}setVisible(e){}dispose(){this._onDidChange.dispose()}}class qt{get element(){return this._element}constructor(e,t=0){this._onDidChange=new d,this.onDidChange=this._onDidChange.event,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this.priority=exports.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 $(this._element,{orientation:exports.Orientation.VERTICAL,proportionalLayout:!1,margin:t}),this._centerIndex=0,this._splitview.addView(e,{type:"distribute"},0)}addTopView(e,t){this._splitview.addView(e,t,0),this._topIndex=0,this._centerIndex+=1,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 Kt{constructor(e,t,i,s=0,o=35){this._disposables=new m,this._viewConfigs=new Map,this._currentWidth=0,this._currentHeight=0,this._gap=s,this._defaultCollapsedSize=o,this._shellElement=document.createElement("div"),this._shellElement.className="dv-shell",this._shellElement.style.height="100%",this._shellElement.style.width="100%",this._shellElement.style.position="relative",e.appendChild(this._shellElement);const n=new Xt(t,i);this._middleColumn=new qt(n,s),this._outerSplitview=new $(this._shellElement,{orientation:exports.Orientation.HORIZONTAL,proportionalLayout:!1,margin:s}),this._middleIndex=0,this._outerSplitview.addView(this._middleColumn,{type:"distribute"},0),this._disposables.addDisposables(_(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,n)}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 Yt(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 Qt={activationSize:{type:"pixels",value:10},size:{type:"pixels",value:20}};function ei(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 ti extends pe{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(e,t){var i,s,n,r,a,h;super(e,{proportionalLayout:!0,orientation:exports.Orientation.HORIZONTAL,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:t.disableAutoResizing,locked:t.locked,margin:null!==(s=null===(i=t.theme)||void 0===i?void 0:i.gap)&&void 0!==s?s:0,className:t.className}),this.nextGroupId=L(),this._deserializer=new xt(this),this._watermark=null,this._popoutPopupServices=new Map,this._onWillDragPanel=new d,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new d,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new d,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new d,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new d,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onUnhandledDragOverEvent=new d,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this._onDidRemovePanel=new d,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new d,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPopoutGroupSizeChange=new d,this.onDidPopoutGroupSizeChange=this._onDidPopoutGroupSizeChange.event,this._onDidPopoutGroupPositionChange=new d,this.onDidPopoutGroupPositionChange=this._onDidPopoutGroupPositionChange.event,this._onDidOpenPopoutWindowFail=new d,this.onDidOpenPopoutWindowFail=this._onDidOpenPopoutWindowFail.event,this._onDidLayoutFromJSON=new d,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new d({replay:!0}),this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidMovePanel=new d,this.onDidMovePanel=this._onDidMovePanel.event,this._onDidCreateTabGroup=new d,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new d,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new d,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new d,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new d,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new d,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,this._onDidMaximizedGroupChange=new d,this.onDidMaximizedGroupChange=this._onDidMaximizedGroupChange.event,this._inShellLayout=!1,this._edgeGroups=new Map,this._edgeGroupDisposables=new Map,this._floatingGroups=[],this._popoutGroups=[],this._popoutRestorationPromise=Promise.resolve(),this._onDidRemoveGroup=new d,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new d,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidOptionsChange=new d,this.onDidOptionsChange=this._onDidOptionsChange.event,this._onDidActiveGroupChange=new d,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._moving=!1,this._options=t,this._tabGroupColorPalette=function(e){var t;const i=null!==(t=e.tabGroupColors)&&void 0!==t?t:He,s="off"!==e.tabGroupAccent;return new Fe(i,s)}(t),this.popupService=new Nt(this.element),this.contextMenuController=new jt(this),this._api=new ve(this),this.disableResizing=!0,e.removeChild(this.element),this._shellManager=new Kt(e,this.element,(e,t)=>this._layoutFromShell(e,t),null!==(r=null===(n=t.theme)||void 0===n?void 0:n.gap)&&void 0!==r?r:0,null===(a=t.theme)||void 0===a?void 0:a.edgeGroupCollapsedSize),this.popupService.updateRoot(this._shellManager.element),this._shellThemeClassnames=new A(this._shellManager.element),this.rootDropTargetContainer=new Zt(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 xe(this.element,{className:"dv-drop-target-edge",canDisplayOverlay:(e,t)=>{const i=o();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 st(e,"edge",t,o);return this._onUnhandledDragOverEvent.fire(s),s.isAccepted},acceptedTargetZones:["top","bottom","left","right","center"],overlayModel:null!==(h=t.rootOverlayModel)&&void 0!==h?h:Qt,getOverrideTarget:()=>{var e;return null===(e=this.rootDropTargetContainer)||void 0===e?void 0:e.model}}),this.updateDropTargetModel(t),w(this.gridview.element,"dv-dockview",!0),w(this.element,"dv-debug",!!t.debug),this.updateTheme(),this.updateWatermark(),t.debug&&this.addDisposables(new Lt(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})}),exports.DockviewEvent.any(this.onDidAdd,this.onDidRemove)(()=>{this.updateWatermark()}),exports.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()}),exports.DockviewDisposable.from(()=>{var e;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 Le(e,{kind:"edge",panel:void 0,api:this._api,group:void 0,getData:o}))}),this._rootDropTarget.onDrop(e=>{var t;const i=new pt({nativeEvent:e.nativeEvent,position:e.position,panel:void 0,api:this._api,group:void 0,getData:o,kind:"edge"});if(this._onWillDrop.fire(i),i.defaultPrevented)return;const s=o();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 dt({nativeEvent:e.nativeEvent,position:e.position,panel:void 0,api:this._api,group:void 0,getData:o}))}),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(e,t){var i,s,o,n,r;if(e instanceof _t&&"edge"===e.model.location.type)return Promise.resolve(!1);if(e instanceof wt&&1===e.group.size)return this.addPopoutGroup(e.group,t);const a=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),h=this.element;const l=(null==t?void 0:t.position)?t.position:e instanceof _t?e.element.getBoundingClientRect():e.group?e.group.element.getBoundingClientRect():h.getBoundingClientRect(),u=null!==(s=null===(i=null==t?void 0:t.overridePopoutGroup)||void 0===i?void 0:i.id)&&void 0!==s?s:this.getNextGroupId(),c=new Mt(`${this.id}-${u}`,null!=a?a:"",{url:null!==(r=null!==(o=null==t?void 0:t.popoutUrl)&&void 0!==o?o:null===(n=this.options)||void 0===n?void 0:n.popoutUrl)&&void 0!==r?r:"/popout.html",left:window.screenX+l.left,top:window.screenY+l.top,width:l.width,height:l.height,onDidOpen:null==t?void 0:t.onDidOpen,onWillClose:null==t?void 0:t.onWillClose}),v=new m(c,c.onDidClose(()=>{v.dispose()}));return c.open().then(i=>{var s;if(c.isDisposed)return!1;const o=(null==t?void 0:t.referenceGroup)?t.referenceGroup:e instanceof wt?e.group:e,n=e.api.location.type,r=null!==o.element.parentElement;let a;if(r?(null==t?void 0:t.overridePopoutGroup)?a=t.overridePopoutGroup:(a=this.createGroup({id:u}),i&&this._onDidAddGroup.fire(a)):a=o,null===i)return console.error("dockview: failed to create popout. perhaps you need to allow pop-ups for this website"),v.dispose(),this._onDidOpenPopoutWindowFail.fire(),this.movingLock(()=>ei({from:a,to:o})),o.api.isVisible||o.api.setVisible(!0),!1;const h=document.createElement("div");h.className="dv-overlay-render-container";const l=new Vt(h,this);let g;if(a.model.renderContainer=l,a.layout(c.window.innerWidth,c.window.innerHeight),!(null==t?void 0:t.overridePopoutGroup)&&r)if(e instanceof wt)this.movingLock(()=>{const t=o.model.removePanel(e);a.model.openPanel(t)});else switch(this.movingLock(()=>ei({from:o,to:a})),n){case"grid":o.api.setVisible(!1);break;case"floating":case"popout":g=null===(s=this._floatingGroups.find(t=>t.group.api.id===e.api.id))||void 0===s?void 0:s.overlay.toJSON(),this.removeGroup(o)}i.classList.add("dv-dockview"),i.style.overflow="hidden",i.appendChild(h),i.appendChild(a.element);const _=document.createElement("div"),f=new Zt(_,{disabled:this.rootDropTargetContainer.disabled});i.appendChild(_),a.model.dropTargetContainer=f;const b=new Nt(i,c.window);let w;this._popoutPopupServices.set(a.id,b),v.addDisposables(b,exports.DockviewDisposable.from(()=>{this._popoutPopupServices.delete(a.id)})),a.model.location={type:"popout",getWindow:()=>c.window,popoutUrl:null==t?void 0:t.popoutUrl},r&&"grid"===e.api.location.type&&e.api.setVisible(!1),this.doSetGroupAndPanelActive(a),v.addDisposables(a.api.onDidActiveChange(e=>{var t;e.isActive&&(null===(t=c.window)||void 0===t||t.focus())}),a.api.onWillFocus(()=>{var e;null===(e=c.window)||void 0===e||e.focus()}));const D=r&&o&&this.getPanel(o.id),C={window:c,popoutGroup:a,referenceGroup:D?o.id:void 0,disposable:{dispose:()=>(v.dispose(),w)}},x=function(e){const t=new d;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}(c.window);return v.addDisposables(x,function(e,t){let i;return new m(p(e,"resize",()=>{clearTimeout(i),i=setTimeout(()=>{t()},100)}))}(c.window,()=>{this._onDidPopoutGroupSizeChange.fire({width:c.window.innerWidth,height:c.window.innerHeight,group:a})}),x.event(()=>{this._onDidPopoutGroupPositionChange.fire({screenX:c.window.screenX,screenY:c.window.screenX,group:a})}),p(c.window,"resize",()=>{a.layout(c.window.innerWidth,c.window.innerHeight)}),l,exports.DockviewDisposable.from(()=>{if(!this.isDisposed)if(r&&this.getPanel(o.id))this.movingLock(()=>ei({from:a,to:o})),o.api.isVisible||o.api.setVisible(!0),this.getPanel(a.id)&&this.doRemoveGroup(a,{skipPopoutAssociated:!0});else if(this.getPanel(a.id)){a.model.renderContainer=this.overlayRenderContainer,a.model.dropTargetContainer=this.rootDropTargetContainer,w=a;if(!this._popoutGroups.find(e=>e.popoutGroup===a))return;g?this.addFloatingGroup(a,{height:g.height,width:g.width,position:g}):(this.doRemoveGroup(a,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),a.model.location={type:"grid"},this.movingLock(()=>{this.doAddGroup(a,[0])})),this.doSetGroupAndPanelActive(a)}})),this._popoutGroups.push(C),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 _t&&"edge"===e.model.location.type)return;let h;if(e instanceof wt)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(()=>ei({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 l=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=zt,"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=It,"number"==typeof t.width?e.width=Math.max(t.width,0):e.width=Tt,"number"==typeof t.height?e.height=Math.max(t.height,0):e.height=Et,e}return{left:"number"==typeof(null==t?void 0:t.x)?Math.max(t.x,0):zt,top:"number"==typeof(null==t?void 0:t.y)?Math.max(t.y,0):It,width:"number"==typeof(null==t?void 0:t.width)?Math.max(t.width,0):Tt,height:"number"==typeof(null==t?void 0:t.height)?Math.max(t.height,0):Et}}(),d=new Gt(Object.assign(Object.assign({container:null!==(s=this._floatingOverlayHost)&&void 0!==s?s:this.gridview.element,content:h.element},l),{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:At,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:At})),p=h.element.querySelector(".dv-void-container");if(!p)throw new Error("dockview: failed to find drag handle");d.setupDrag(p,{inDragMode:"boolean"==typeof(null==t?void 0:t.inDragMode)&&t.inDragMode});const u=new Pt(h,d),c=new m(h.api.onDidActiveChange(e=>{e.isActive&&d.bringToFront()}),(()=>{let e=-1,t=-1;return _(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(d.onDidChange(()=>{h.layout(h.width,h.height)}),d.onDidChangeEnd(()=>{this._bufferOnDidLayoutChange.fire()}),h.onDidChange(e=>{d.setBounds({height:null==e?void 0:e.height,width:null==e?void 0:e.width})}),{dispose:()=>{c.dispose(),k(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(e,t){switch(this.gridview.normalize(),e){case"top":case"bottom":this.gridview.orientation===exports.Orientation.HORIZONTAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case"left":case"right":this.gridview.orientation===exports.Orientation.VERTICAL&&this.gridview.insertOrthogonalSplitviewAtRoot()}switch(e){case"top":case"left":case"center":return this.createGroupAtLocation([0],void 0,t);case"bottom":case"right":return this.createGroupAtLocation([this.gridview.length],void 0,t);default:throw new Error(`dockview: unsupported position ${e}`)}}updateOptions(e){var t,i,s;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=At,s.overlay.minimumInViewportWidth=At;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 o=this.options.disableDnd;this._options=Object.assign(Object.assign({},this.options),e);if(o!==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("tabGroupColors"in e||"tabGroupAccent"in e){this._tabGroupColorPalette.setEntries(null!==(s=this._options.tabGroupColors)&&void 0!==s?s:He),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=Q(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=Q(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=>{setTimeout(()=>{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)});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(e){var t,i;if(this.panels.find(t=>t.id===e.id))throw new Error(`dockview: panel with id ${e.id} already exists`);let s;if(e.position&&e.floating)throw new Error("dockview: you can only provide one of: position, floating as arguments to .addPanel(...)");const o={width:e.initialWidth,height:e.initialHeight};let n,r;if(e.position)if(nt(e.position)){const t="string"==typeof e.position.referencePanel?this.getGroupPanel(e.position.referencePanel):e.position.referencePanel;if(n=e.position.index,!t)throw new Error(`dockview: referencePanel '${e.position.referencePanel}' does not exist`);s=this.findGroup(t)}else{if(!rt(e.position)){const t=this.orthogonalize(be(e.position.direction)),i=this.createPanel(e,t);return t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:n}),e.inactive||this.doSetGroupAndPanelActive(t),t.api.setSize({height:null==o?void 0:o.height,width:null==o?void 0:o.width}),i}if(s="string"==typeof e.position.referenceGroup?null===(t=this._groups.get(e.position.referenceGroup))||void 0===t?void 0:t.value:e.position.referenceGroup,n=e.position.index,!s)throw new Error(`dockview: referenceGroup '${e.position.referenceGroup}' does not exist`)}else s=this.activeGroup;if(s){const t=de((null===(i=e.position)||void 0===i?void 0:i.direction)||"within");if(e.floating){const t=this.createGroup();this._onDidAddGroup.fire(t);const i="object"==typeof e.floating&&null!==e.floating?e.floating:{};this.addFloatingGroup(t,Object.assign(Object.assign({},i),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),r=this.createPanel(e,t),t.model.openPanel(r,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:n})}else if("floating"===s.api.location.type||"edge"===s.api.location.type||"center"===t)r=this.createPanel(e,s),s.model.openPanel(r,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:n}),s.api.setSize({width:null==o?void 0:o.width,height:null==o?void 0:o.height}),e.inactive||this.doSetGroupAndPanelActive(s);else{const i=Q(s.element),a=ee(this.gridview.orientation,i,t),h=this.createGroupAtLocation(a,this.orientationAtLocation(a)===exports.Orientation.VERTICAL?null==o?void 0:o.height:null==o?void 0:o.width);r=this.createPanel(e,h),h.model.openPanel(r,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:n}),e.inactive||this.doSetGroupAndPanelActive(h)}}else if(e.floating){const t=this.createGroup();this._onDidAddGroup.fire(t);const i="object"==typeof e.floating&&null!==e.floating?e.floating:{};this.addFloatingGroup(t,Object.assign(Object.assign({},i),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),r=this.createPanel(e,t),t.model.openPanel(r,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:n})}else{const t=this.createGroupAtLocation([0],this.gridview.orientation===exports.Orientation.VERTICAL?null==o?void 0:o.height:null==o?void 0:o.width);r=this.createPanel(e,t),t.model.openPanel(r,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:n}),e.inactive||this.doSetGroupAndPanelActive(t)}return r}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 yt}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 ve(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(e){var t;if(e){let i;if(at(e)){const t="string"==typeof e.referencePanel?this.panels.find(t=>t.id===e.referencePanel):e.referencePanel;if(!t)throw new Error(`dockview: reference panel ${e.referencePanel} does not exist`);if(i=this.findGroup(t),!i)throw new Error(`dockview: reference group for reference panel ${e.referencePanel} does not exist`)}else{if(!ht(e)){const t=this.orthogonalize(be(e.direction),e);return e.skipSetActive||this.doSetGroupAndPanelActive(t),t}if(i="string"==typeof e.referenceGroup?null===(t=this._groups.get(e.referenceGroup))||void 0===t?void 0:t.value:e.referenceGroup,!i)throw new Error(`dockview: reference group ${e.referenceGroup} does not exist`)}const s=de(e.direction||"within"),o=Q(i.element),n=ee(this.gridview.orientation,o,s),r=this.createGroup(e),a=this.getLocationOrientation(n)===exports.Orientation.VERTICAL?e.initialHeight:e.initialWidth;return this.doAddGroup(r,n,a),e.skipSetActive||this.doSetGroupAndPanelActive(r),r}{const t=this.createGroup(e);return this.doAddGroup(t),this.doSetGroupAndPanelActive(t),t}}getLocationOrientation(e){return e.length%2==0&&this.gridview.orientation===exports.Orientation.HORIZONTAL?exports.Orientation.HORIZONTAL:exports.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)),k(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)}k(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=Q(i.element),t=ee(this.gridview.orientation,e,n);if(a.size<2){const[e,s]=T(t);if("grid"===a.api.location.type){const t=Q(a.element),[i,n]=T(t);if(E(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),i=this.movingLock(()=>e.popoutGroup.model.removePanel(e.popoutGroup.panels[0],{skipSetActive:!0,skipSetActiveGroup:!0}));this.doRemoveGroup(a,{skipActive:!0});const s=this.createGroupAtLocation(t);return this.movingLock(()=>s.model.openPanel(i,{skipSetActive:!0})),this.doSetGroupAndPanelActive(s),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=Q(i.element),l=ee(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=ee(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?Q(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=ee(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(e){const t=e.from.group,i=e.to.group,s=e.to.position;let o=t;if("center"===s){const s=t.activePanel,o=t.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),n=this.movingLock(()=>[...t.panels].map(e=>t.model.removePanel(e.id,{skipSetActive:!0})));0===(null==t?void 0:t.model.size)&&this.doRemoveGroup(t,{skipActive:!0}),this.movingLock(()=>{for(const e of n)i.model.openPanel(e,{skipSetActive:e!==s,skipSetGroupActive:!0})});for(const e of o){const t=i.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(const s of e.panelIds)i.model.addPanelToTabGroup(t.id,s)}!0!==e.skipSetActive?this.doSetGroupAndPanelActive(i):this.activePanel||this.doSetGroupAndPanelActive(i)}else{if("edge"===t.api.location.type){const e=t.activePanel,i=t.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),s=this.movingLock(()=>[...t.panels].map(e=>t.model.removePanel(e.id,{skipSetActive:!0})));o=this.createGroup(),this.movingLock(()=>{for(const t of s)o.model.openPanel(t,{skipSetActive:t!==e,skipSetGroupActive:!0})});for(const e of i){const t=o.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(const i of e.panelIds)o.model.addPanelToTabGroup(t.id,i)}}else switch(t.api.location.type){case"grid":this.gridview.removeView(Q(t.element));break;case"floating":{const e=this._floatingGroups.find(e=>e.group===t);if(!e)throw new Error("dockview: failed to find floating group");e.dispose();break}case"popout":{const e=this._popoutGroups.find(e=>e.popoutGroup===t);if(!e)throw new Error("dockview: failed to find popout group");const s=this._popoutGroups.indexOf(e);if(s>=0&&this._popoutGroups.splice(s,1),e.referenceGroup){const t=this.getPanel(e.referenceGroup);t&&!t.api.isVisible&&this.doRemoveGroup(t,{skipActive:!0})}e.window.dispose(),"grid"===i.api.location.type?(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,t.model.location={type:"grid"}):"floating"===i.api.location.type&&(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,t.model.location={type:"floating"});break}}if("grid"===i.api.location.type){const e=Q(i.element),n=ee(this.gridview.orientation,e,s);let r;switch(this.gridview.orientation){case exports.Orientation.VERTICAL:r=e.length%2==0?t.api.width:t.api.height;break;case exports.Orientation.HORIZONTAL:r=e.length%2==0?t.api.height:t.api.width}this.gridview.addView(o,r,n)}else if("floating"===i.api.location.type){const e=this._floatingGroups.find(e=>e.group===i);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(o,{height:t.height,width:t.width,position:{left:i,top:s}})}}}if(o.panels.forEach(e=>{this._onDidMovePanel.fire({panel:e,from:t})}),this.debouncedUpdateAllPositions(),!1===e.skipSetActive){const e=null!=i?i:t;this.doSetGroupAndPanelActive(e)}else o!==t&&!0!==e.skipSetActive&&this.doSetGroupAndPanelActive(o)}doSetGroupActive(e){super.doSetGroupActive(e);const t=this.activePanel;this._moving||t===this._onDidActivePanelChange.value||this._onDidActivePanelChange.fire(t)}doSetGroupAndPanelActive(e){super.doSetGroupActive(e);const t=this.activePanel;e&&this.hasMaximizedGroup()&&!this.isMaximizedGroup(e)&&this.exitMaximizedGroup(),this._moving||t===this._onDidActivePanelChange.value||this._onDidActivePanelChange.fire(t)}getNextGroupId(){let e=this.nextGroupId.next();for(;this._groups.has(e);)e=this.nextGroupId.next();return e}createGroup(e){e||(e={});let t=null==e?void 0:e.id;if(t&&this._groups.has(e.id)&&(console.warn(`dockview: Duplicate group id ${null==e?void 0:e.id}. reassigning group id to avoid errors`),t=void 0),!t)for(t=this.nextGroupId.next();this._groups.has(t);)t=this.nextGroupId.next();const i=new _t(this,t,e);if(i.init({params:{},accessor:this}),!this._groups.has(i.id)){const e=new m(i.model.onTabDragStart(e=>{this._onWillDragPanel.fire(e)}),i.model.onGroupDragStart(e=>{this._onWillDragGroup.fire(e)}),i.model.onMove(e=>{const{groupId:t,itemId:s,target:o,index:n,tabGroupId:r}=e;this.moveGroupOrPanel({from:{groupId:t,panelId:s,tabGroupId:r},to:{group:i,position:o,index:n}})}),i.model.onDidDrop(e=>{this._onDidDrop.fire(e)}),i.model.onWillDrop(e=>{this._onWillDrop.fire(e)}),i.model.onWillShowOverlay(e=>{this.options.disableDnd?e.preventDefault():this._onWillShowOverlay.fire(e)}),i.model.onUnhandledDragOverEvent(e=>{this._onUnhandledDragOverEvent.fire(e)}),i.model.onDidAddPanel(e=>{this._moving||this._onDidAddPanel.fire(e.panel)}),i.model.onDidRemovePanel(e=>{this._moving||this._onDidRemovePanel.fire(e.panel)}),i.model.onDidActivePanelChange(e=>{this._moving||e.panel===this.activePanel&&this._onDidActivePanelChange.value!==e.panel&&this._onDidActivePanelChange.fire(e.panel)}),i.model.onDidCreateTabGroup(e=>{this._onDidCreateTabGroup.fire(e)}),i.model.onDidDestroyTabGroup(e=>{this._onDidDestroyTabGroup.fire(e)}),i.model.onDidAddPanelToTabGroup(e=>{this._onDidAddPanelToTabGroup.fire(e)}),i.model.onDidRemovePanelFromTabGroup(e=>{this._onDidRemovePanelFromTabGroup.fire(e)}),i.model.onDidTabGroupChange(e=>{this._onDidTabGroupChange.fire(e)}),i.model.onDidTabGroupCollapsedChange(e=>{this._onDidTabGroupCollapsedChange.fire(e)}),exports.DockviewEvent.any(i.model.onDidPanelTitleChange,i.model.onDidPanelParametersChange)(()=>{this._bufferOnDidLayoutChange.fire()}));this._groups.set(i.id,{value:i,disposable:e})}return i.initialize(),i}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 Ct(this,e.id,n,r),h=new wt(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:se(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(Qt)),"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:ft;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");w(this.element,"dv-tab-group-indicator-none",d),this._shellManager&&w(this._shellManager.element,"dv-tab-group-indicator-none",d);for(const e of this.groups)e.model.updateTabGroups()}}class ii extends pe{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 d,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidRemoveGroup=new d,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new d,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new d,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(Q(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=de(t.direction);if("center"===r)throw new Error(`${r} not supported as an option`);{const e=Q(n.element);s=ee(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=de(e.position.direction);if("center"===i)throw new Error(`${i} not supported as an option`);{const e=Q(t.element);n=ee(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 m(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=Q(e.element),n=ee(this.gridview.orientation,o,i),[r,a]=T(n),h=Q(s.element),[l,d]=T(h);if(E(l,r))return void this.gridview.moveView(l,d,a);const p=this.doRemoveGroup(s,{skipActive:!0,skipDispose:!0}),u=Q(e.element),c=ee(this.gridview.orientation,u,i);this.doAddGroup(p,c)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}}class si 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 m(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===exports.Orientation.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===exports.Orientation.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._splitviewChangeDisposable=new v,this._panels=new Map,this._onDidLayoutfromJSON=new d,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new d,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new d,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new d,this.onDidLayoutChange=this._onDidLayoutChange.event,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new A(this.element),this._classNames.setClassNames(null!==(i=t.className)&&void 0!==i?i:""),e.appendChild(this.element),this._options=t,this.splitview=new $(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(e){var t;if(this._panels.has(e.id))throw new Error(`panel ${e.id} already exists`);const i=this.options.createComponent({id:e.id,name:e.component});i.orientation=this.splitview.orientation,i.init({params:null!==(t=e.params)&&void 0!==t?t:{},minimumSize:e.minimumSize,maximumSize:e.maximumSize,snap:e.snap,priority:e.priority,accessor:this});const s="number"==typeof e.size?e.size:exports.Sizing.Distribute,o="number"==typeof e.index?e.index:void 0;return this.splitview.addView(i,s,o),this.doAddView(i),this.setActive(i),i}layout(e,t){const[i,s]=this.splitview.orientation===exports.Orientation.HORIZONTAL?[e,t]:[t,e];this.splitview.layout(i,s)}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 $(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,exports.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 oi extends m{get element(){return this._element}constructor(){super(),this._expandedIcon=et({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=tt(),this.disposable=new v,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(p(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);w(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 ni=L(),ri=Number.MAX_SAFE_INTEGER;class ai extends Ee{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 hi extends he{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new m(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===exports.Orientation.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===exports.Orientation.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._id=ni.next(),this._disposable=new v,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new d,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new d,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new d,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new d,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new d,this.onDidRemoveView=this._onDidRemoveView.event,this._onUnhandledDragOverEvent=new d,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 A(this.element),this._classNames.setClassNames(null!==(i=t.className)&&void 0!==i?i:""),e.appendChild(this.element),this._options=t,this.paneview=new J(this.element,{orientation:exports.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(e){var t,i;const s=this.options.createComponent({id:e.id,name:e.component});let o;e.headerComponent&&this.options.createHeaderComponent&&(o=this.options.createHeaderComponent({id:e.id,name:e.headerComponent})),o||(o=new oi);const n=new ai({id:e.id,component:e.component,headerComponent:e.headerComponent,header:o,body:s,orientation:exports.Orientation.VERTICAL,isExpanded:!!e.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:null!==(t=e.headerSize)&&void 0!==t?t:22,minimumBodySize:0,maximumBodySize:ri});this.doAddPanel(n);const r="number"==typeof e.size?e.size:exports.Sizing.Distribute,a="number"==typeof e.index?e.index:void 0;return n.init({params:null!==(i=e.params)&&void 0!==i?i:{},minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize,isExpanded:e.isExpanded,title:e.title,containerApi:new ce(this),accessor:this}),this.paneview.addPane(n,r,a),n.orientation=this.paneview.orientation,n}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(e,t){const[i,s]=this.paneview.orientation===exports.Orientation.HORIZONTAL?[e,t]:[t,e];this.paneview.layout(i,s)}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(e){this.clear();const{views:t,size:i}=e,s=[],o=this.width,n=this.height;this.paneview=new J(this.element,{orientation:exports.Orientation.VERTICAL,descriptor:{size:i,views:t.map(e=>{var t,i,o;const n=e.data,r=this.options.createComponent({id:n.id,name:n.component});let a;n.headerComponent&&this.options.createHeaderComponent&&(a=this.options.createHeaderComponent({id:n.id,name:n.headerComponent})),a||(a=new oi);const h=new ai({id:n.id,component:n.component,headerComponent:n.headerComponent,header:a,body:r,orientation:exports.Orientation.VERTICAL,isExpanded:!!e.expanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:null!==(t=e.headerSize)&&void 0!==t?t:22,minimumBodySize:null!==(i=e.minimumSize)&&void 0!==i?i:0,maximumBodySize:null!==(o=e.maximumSize)&&void 0!==o?o:ri});return this.doAddPanel(h),s.push(()=>{var t;h.init({params:null!==(t=n.params)&&void 0!==t?t:{},minimumBodySize:e.minimumSize,maximumBodySize:e.maximumSize,title:n.title,isExpanded:!!e.expanded,containerApi:new ce(this),accessor:this}),h.orientation=this.paneview.orientation}),setTimeout(()=>{this._onDidAddView.fire(h)},0),{size:e.size,view:h}})}}),this.layout(o,n),s.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 m(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()}}exports.BaseGrid=pe,exports.ContentContainer=Oe,exports.DEFAULT_TAB_GROUP_COLORS=He,exports.DefaultDockviewDeserialzier=xt,exports.DefaultTab=Dt,exports.DockviewApi=ve,exports.DockviewComponent=ti,exports.DockviewCompositeDisposable=m,exports.DockviewDidDropEvent=dt,exports.DockviewEmitter=d,exports.DockviewGroupPanel=_t,exports.DockviewGroupPanelModel=ut,exports.DockviewMutableDisposable=v,exports.DockviewPanel=wt,exports.DockviewUnhandledDragOverEvent=st,exports.DockviewWillDropEvent=pt,exports.DockviewWillShowOverlayLocationEvent=Le,exports.DraggablePaneviewPanel=Ee,exports.Gridview=re,exports.GridviewApi=me,exports.GridviewComponent=ii,exports.GridviewPanel=mt,exports.PROPERTY_KEYS_DOCKVIEW=ot,exports.PROPERTY_KEYS_GRIDVIEW=ae,exports.PROPERTY_KEYS_PANEVIEW=ye,exports.PROPERTY_KEYS_SPLITVIEW=U,exports.PaneFramework=ai,exports.PaneTransfer=i,exports.PanelTransfer=t,exports.Paneview=J,exports.PaneviewApi=ce,exports.PaneviewComponent=hi,exports.PaneviewPanel=Te,exports.PaneviewUnhandledDragOverEvent=Se,exports.Splitview=$,exports.SplitviewApi=ue,exports.SplitviewComponent=si,exports.SplitviewPanel=class extends Ie{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 Ae(e,t)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=Number.POSITIVE_INFINITY,this._minimumSize=0,this._maximumSize=Number.POSITIVE_INFINITY,this._snap=!1,this._onDidChange=new d,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(e,t){const[i,s]=this.orientation===exports.Orientation.HORIZONTAL?[e,t]:[t,e];super.layout(i,s)}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})}},exports.Tab=Me,exports.TabGroupColorPalette=Fe,exports.applyTabGroupAccent=Ue,exports.createDockview=function(e,t){return new ti(e,t).api},exports.createGridview=function(e,t){const i=new ii(e,t);return new me(i)},exports.createPaneview=function(e,t){const i=new hi(e,t);return new ce(i)},exports.createSplitview=function(e,t){const i=new si(e,t);return new ue(i)},exports.directionToPosition=be,exports.getDirectionOrientation=te,exports.getGridLocation=Q,exports.getLocationOrientation=ie,exports.getPaneData=n,exports.getPanelData=o,exports.getRelativeLocation=ee,exports.indexInParent=K,exports.isGridBranchNode=oe,exports.isGroupOptionsWithGroup=ht,exports.isGroupOptionsWithPanel=at,exports.isPanelOptionsWithGroup=rt,exports.isPanelOptionsWithPanel=nt,exports.orthogonal=se,exports.positionToDirection=we,exports.resolveTabGroupAccent=Je,exports.themeAbyss=ft,exports.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)"},exports.themeCatppuccinMocha={name:"catppuccinMocha",className:"dockview-theme-catppuccin-mocha",colorScheme:"dark"},exports.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)"},exports.themeDark={name:"dark",className:"dockview-theme-dark",colorScheme:"dark"},exports.themeDracula={name:"dracula",className:"dockview-theme-dracula",colorScheme:"dark"},exports.themeGithubDark={name:"githubDark",className:"dockview-theme-github-dark",colorScheme:"dark"},exports.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)"},exports.themeGithubLight={name:"githubLight",className:"dockview-theme-github-light",colorScheme:"light"},exports.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)"},exports.themeLight={name:"light",className:"dockview-theme-light",colorScheme:"light"},exports.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)"},exports.themeMonokai={name:"monokai",className:"dockview-theme-monokai",colorScheme:"dark"},exports.themeNord={name:"nord",className:"dockview-theme-nord",colorScheme:"dark"},exports.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)"},exports.themeSolarizedLight={name:"solarizedLight",className:"dockview-theme-solarized-light",colorScheme:"light"},exports.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)"},exports.themeVisualStudio={name:"visualStudio",className:"dockview-theme-vs",colorScheme:"dark",edgeGroupCollapsedSize:22},exports.toTarget=de;
|
|
7
|
+
"use strict";class e{}class t extends e{constructor(e,t,i,s){super(),this.viewId=e,this.groupId=t,this.panelId=i,this.tabGroupId=s}}class i extends e{constructor(e,t){super(),this.viewId=e,this.paneId=t}}class s{constructor(){}static getInstance(){return s.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 o(){const e=s.getInstance();if(e.hasData(t.prototype))return e.getData(t.prototype)[0]}function n(){const e=s.getInstance();if(e.hasData(i.prototype))return e.getData(i.prototype)[0]}s.INSTANCE=new s,exports.DockviewEvent=void 0,(exports.DockviewEvent||(exports.DockviewEvent={})).any=(...e)=>t=>{const i=e.map(e=>e(t));return{dispose:()=>{i.forEach(e=>{e.dispose()})}}};class r{constructor(){this._defaultPrevented=!1}get defaultPrevented(){return this._defaultPrevented}preventDefault(){this._defaultPrevented=!0}}class a{constructor(){this._isAccepted=!1}get isAccepted(){return this._isAccepted}accept(){this._isAccepted=!0}}class h{static create(){var e;return new h(null!==(e=(new Error).stack)&&void 0!==e?e:"")}constructor(e){this.value=e}print(){console.warn("dockview: stacktrace",this.value)}}class l{constructor(e,t){this.callback=e,this.stacktrace=t}}class d{static setLeakageMonitorEnabled(e){e!==d.ENABLE_TRACKING&&d.MEMORY_LEAK_WATCHER.clear(),d.ENABLE_TRACKING=e}get value(){return this._last}constructor(e){this.options=e,this._listeners=[],this._disposed=!1}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 l(e,d.ENABLE_TRACKING?h.create():void 0);return this._listeners.push(i),{dispose:()=>{const e=this._listeners.indexOf(i);e>-1?this._listeners.splice(e,1):d.ENABLE_TRACKING}}},d.ENABLE_TRACKING&&d.MEMORY_LEAK_WATCHER.add(this._event,h.create())),this._event}fire(e){var t;(null===(t=this.options)||void 0===t?void 0:t.replay)&&(this._last=e);for(const t of this._listeners)t.callback(e)}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&(d.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=[]),d.ENABLE_TRACKING&&this._event&&d.MEMORY_LEAK_WATCHER.delete(this._event))}}function p(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i,s)}}}d.ENABLE_TRACKING=!1,d.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 u{constructor(){this._onFired=new d,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()}}var c;exports.DockviewDisposable=void 0,(c=exports.DockviewDisposable||(exports.DockviewDisposable={})).NONE={dispose:()=>{}},c.from=function(e){return{dispose:()=>{e()}}};class m{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 v{constructor(){this._disposable=exports.DockviewDisposable.NONE}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&(this._disposable.dispose(),this._disposable=exports.DockviewDisposable.NONE)}}class g extends m{constructor(e){super(),this._onDidChange=new d,this.onDidChange=this._onDidChange.event,this._value=null,this.addDisposables(this._onDidChange,_(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 _(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 f=(e,...t)=>{for(const i of t)e.classList.contains(i)&&e.classList.remove(i)},b=(e,...t)=>{for(const i of t)e.classList.contains(i)||e.classList.add(i)},w=(e,t,i)=>{const s=e.classList.contains(t);i&&!s&&e.classList.add(t),!i&&s&&e.classList.remove(t)};function D(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function C(e){return new x(e)}class x extends m{constructor(e){super(),this._onDidFocus=new d,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new d,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=D(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=()=>{D(document.activeElement,e)!==t&&(t?o():s())},this.addDisposables(p(e,"focus",s,!0)),this.addDisposables(p(e,"blur",o,!0))}refreshState(){this._refreshStateHandler()}}const y="dv-quasiPreventDefault";function S(e){return e[y]}function G(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 P(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 A{constructor(e){this.element=e,this._classNames=[]}setClassNames(e){for(const e of this._classNames)w(this.element,e,!1);this._classNames=e.split(" ").filter(e=>e.trim().length>0);for(const e of this._classNames)w(this.element,e,!0)}}function z(e,t){const i=G(e),s=G(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 I(e){let t=e;for(;t&&("auto"===t.style.zIndex||""===t.style.zIndex);)t=t.parentElement;return t}function T(e){if(0===e.length)throw new Error("Invalid tail call");return[e.slice(0,e.length-1),e[e.length-1]]}function E(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 O(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 k(e,t){const i=e.findIndex(e=>e===t);return i>-1&&(e.splice(i,1),!0)}const M=(e,t,i)=>t>i?t:Math.min(i,Math.max(e,t)),L=()=>{let e=1;return{next:()=>(e++).toString()}},N=(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 R{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=M(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 W,H,F,B;exports.Orientation=void 0,(W=exports.Orientation||(exports.Orientation={})).HORIZONTAL="HORIZONTAL",W.VERTICAL="VERTICAL",exports.SashState=void 0,(H=exports.SashState||(exports.SashState={}))[H.MAXIMUM=0]="MAXIMUM",H[H.MINIMUM=1]="MINIMUM",H[H.DISABLED=2]="DISABLED",H[H.ENABLED=3]="ENABLED",exports.LayoutPriority=void 0,(F=exports.LayoutPriority||(exports.LayoutPriority={})).Low="low",F.High="high",F.Normal="normal",exports.Sizing=void 0,(B=exports.Sizing||(exports.Sizing={})).Distribute={type:"distribute"},B.Split=function(e){return{type:"split",index:e}},B.Invisible=function(e){return{type:"invisible",cachedVisibleSize:e}};class ${get contentSize(){return this._contentSize}get size(){return this._size}set size(e){this._size=e}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get length(){return this.viewItems.length}get proportions(){return this._proportions?[...this._proportions]:void 0}get orientation(){return this._orientation}set orientation(e){this._orientation=e;const t=this.size;this.size=this.orthogonalSize,this.orthogonalSize=t,f(this.element,"dv-horizontal","dv-vertical"),this.element.classList.add(this.orientation==exports.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,w(this.element,"dv-splitview-disabled",e)}get margin(){return this._margin}set margin(e){this._margin=e,w(this.element,"dv-splitview-has-margin",0!==e)}constructor(e,t){var i,s;this.container=e,this.viewItems=[],this.sashes=[],this._size=0,this._orthogonalSize=0,this._contentSize=0,this._proportions=void 0,this._startSnappingEnabled=!0,this._endSnappingEnabled=!0,this._disabled=!1,this._margin=0,this._onDidSashEnd=new d,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new d,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new d,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=N(e,-1),d=N(e+1,this.viewItems.length);if(o)for(const e of o)O(l,e),O(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,x=M(t,b,w);for(let e=0;e<p.length;e++){const t=p[e],i=M(u[e]+x,t.minimumSize,t.maximumSize),s=i-u[e];C+=s,x-=s,t.size=i}let y=C;for(let e=0;e<c.length;e++){const t=c[e],i=M(m[e]-y,t.minimumSize,t.maximumSize);y+=i-m[e],t.size=i}return t},this._orientation=null!==(i=t.orientation)&&void 0!==i?i:exports.Orientation.VERTICAL,this.element=this.createContainer(),this.margin=null!==(s=t.margin)&&void 0!==s?s:0,this.proportionalLayout=void 0===t.proportionalLayout||!!t.proportionalLayout,this.viewContainer=this.createViewContainer(),this.sashContainer=this.createSashContainer(),this.element.appendChild(this.sashContainer),this.element.appendChild(this.viewContainer),this.container.appendChild(this.element),this.style(t.styles),t.descriptor&&(this._size=t.descriptor.size,t.descriptor.views.forEach((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)?(f(this.element,"dv-separator-border"),this.element.style.removeProperty("--dv-separator-border")):(b(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(e,t){if(e<0||e>=this.viewItems.length)return;const i=N(this.viewItems.length).filter(t=>t!==e),s=[...i.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.Low),e],o=i.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.High),n=this.viewItems[e];t=Math.round(t),t=M(t,n.minimumSize,Math.min(n.maximumSize,this._size)),n.size=t,this.relayout(s,o)}getViews(){return this.viewItems.map(e=>e.view)}onDidChange(e,t){const i=this.viewItems.indexOf(e);if(i<0||i>=this.viewItems.length)return;t="number"==typeof t?t:e.size,t=M(t,e.minimumSize,e.maximumSize),e.size=t;const s=N(this.viewItems.length).filter(e=>e!==i),o=[...s.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.Low),i],n=s.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.High);this.relayout([...o,i],n)}addView(e,t={type:"distribute"},i=this.viewItems.length,s){const o=document.createElement("div");let n;o.className="dv-view",o.appendChild(e.element),n="number"==typeof t?t:"split"===t.type?this.getViewSize(t.index)/2:"invisible"===t.type?{cachedVisibleSize:t.cachedVisibleSize}:e.minimumSize;const r=e.onDidChange(e=>this.onDidChange(a,e.size)),a=new R(o,e,n,{dispose:()=>{r.dispose(),this.viewContainer.removeChild(o)}});if(i===this.viewItems.length?this.viewContainer.appendChild(o):this.viewContainer.insertBefore(o,this.viewContainer.children.item(i)),this.viewItems.splice(i,0,a),this.viewItems.length>1){const e=document.createElement("div");e.className="dv-sash";const t=t=>{for(const e of this.viewItems)e.enabled=!1;const i=P(),s=this._orientation===exports.Orientation.HORIZONTAL?t.clientX:t.clientY,o=function(e,t){for(let i=0;i<e.length;i++)if(t(e[i]))return i;return-1}(this.sashes,t=>t.container===e),n=this.viewItems.map(e=>e.size);let r,a;const h=N(o,-1),l=N(o+1,this.viewItems.length),d=h.reduce((e,t)=>e+(this.viewItems[t].minimumSize-n[t]),0),p=h.reduce((e,t)=>e+(this.viewItems[t].viewMaximumSize-n[t]),0),u=0===l.length?Number.POSITIVE_INFINITY:l.reduce((e,t)=>e+(n[t]-this.viewItems[t].minimumSize),0),c=0===l.length?Number.NEGATIVE_INFINITY:l.reduce((e,t)=>e+(n[t]-this.viewItems[t].viewMaximumSize),0),m=Math.max(d,c),v=Math.min(u,p),g=this.findFirstSnapIndex(h),_=this.findFirstSnapIndex(l);if("number"==typeof g){const e=this.viewItems[g],t=Math.floor(e.viewMinimumSize/2);r={index:g,limitDelta:e.visible?m-t:m+t,size:e.size}}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}}const f=e=>{const t=(this._orientation===exports.Orientation.HORIZONTAL?e.clientX:e.clientY)-s;this.resize(o,t,n,void 0,void 0,m,v,r,a),this.distributeEmptySpace(),this.layoutViews()},b=()=>{for(const e of this.viewItems)e.enabled=!0;i.release(),this.saveProportions(),document.removeEventListener("pointermove",f),document.removeEventListener("pointerup",b),document.removeEventListener("pointercancel",b),document.removeEventListener("contextmenu",b),this._onDidSashEnd.fire(void 0)};document.addEventListener("pointermove",f),document.addEventListener("pointerup",b),document.addEventListener("pointercancel",b),document.addEventListener("contextmenu",b)};e.addEventListener("pointerdown",t);const i={container:e,disposable:()=>{e.removeEventListener("pointerdown",t),this.sashContainer.removeChild(e)}};this.sashContainer.appendChild(e),this.sashes.push(i)}s||this.relayout([i]),s||"number"==typeof t||"distribute"!==t.type||this.distributeViewSizes(),this._onDidAddView.fire(e)}distributeViewSizes(){const e=[];let t=0;for(const i of this.viewItems)i.maximumSize-i.minimumSize>0&&(e.push(i),t+=i.size);const i=Math.floor(t/e.length);for(const t of e)t.size=M(i,t.minimumSize,t.maximumSize);const s=N(this.viewItems.length),o=s.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.Low),n=s.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.High);this.relayout(o,n)}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(e,t){const i=this.getViewCachedVisibleSize(e),s=void 0===i?this.getViewSize(e):exports.Sizing.Invisible(i),o=this.removeView(e,void 0,!0);this.addView(o,s,t)}layout(e,t){const i=Math.max(this.size,this._contentSize);if(this.size=e,this.orthogonalSize=t,this.proportions){let t=0;for(let i=0;i<this.viewItems.length;i++){const s=this.viewItems[i],o=this.proportions[i];"number"==typeof o?t+=o:e-=s.size}for(let i=0;i<this.viewItems.length;i++){const s=this.viewItems[i],o=this.proportions[i];"number"==typeof o&&t>0&&(s.size=M(Math.round(o*e/t),s.minimumSize,s.maximumSize))}}else{const t=N(this.viewItems.length),s=t.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.Low),o=t.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.High);this.resize(this.viewItems.length-1,e-i,void 0,s,o)}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(e){const t=this.viewItems.reduce((e,t)=>e+t.size,0);let i=this.size-t;const s=N(this.viewItems.length-1,-1),o=s.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.Low),n=s.filter(e=>this.viewItems[e].priority===exports.LayoutPriority.High);for(const e of n)O(s,e);for(const e of o)V(s,e);"number"==typeof e&&V(s,e);for(let e=0;0!==i&&e<s.length;e++){const t=this.viewItems[s[e]],o=M(t.size+i,t.minimumSize,t.maximumSize);i-=o-t.size,t.size=o}}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 e=this.viewItems.filter(e=>e.visible),t=Math.max(0,e.length-1),i=this.margin*t/Math.max(1,e.length);let s=0;const o=[],n=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((e,r)=>{s+=this.viewItems[r].size,o.push(s);const a=e.visible?e.size-i:0,h=Math.max(0,n[r]-1),l=0===r||0===h?0:o[r-1]+h/t*i;if(r<this.viewItems.length-1){const t=e.visible?l+a-2+this.margin/2:l;this._orientation===exports.Orientation.HORIZONTAL&&(this.sashes[r].container.style.left=`${t}px`,this.sashes[r].container.style.top="0px"),this._orientation===exports.Orientation.VERTICAL&&(this.sashes[r].container.style.left="0px",this.sashes[r].container.style.top=`${t}px`)}this._orientation===exports.Orientation.HORIZONTAL&&(e.container.style.width=`${a}px`,e.container.style.left=`${l}px`,e.container.style.top="",e.container.style.height=""),this._orientation===exports.Orientation.VERTICAL&&(e.container.style.height=`${a}px`,e.container.style.top=`${l}px`,e.container.style.width="",e.container.style.left=""),e.view.layout(e.size-i,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 e=!1;const t=this.viewItems.map(t=>e=t.size-t.minimumSize>0||e);e=!1;const i=this.viewItems.map(t=>e=t.maximumSize-t.size>0||e),s=[...this.viewItems].reverse();e=!1;const o=s.map(t=>e=t.size-t.minimumSize>0||e).reverse();e=!1;const n=s.map(t=>e=t.maximumSize-t.size>0||e).reverse();let r=0;for(let e=0;e<this.sashes.length;e++){const s=this.sashes[e];r+=this.viewItems[e].size;const a=!(t[e]&&n[e+1]),h=!(i[e]&&o[e+1]);if(a&&h){const i=N(e,-1),n=N(e+1,this.viewItems.length),a=this.findFirstSnapIndex(i),h=this.findFirstSnapIndex(n),l="number"==typeof a&&!this.viewItems[a].visible,d="number"==typeof h&&!this.viewItems[h].visible;l&&o[e]&&(r>0||this.startSnappingEnabled)?this.updateSash(s,exports.SashState.MINIMUM):d&&t[e]&&(r<this._contentSize||this.endSnappingEnabled)?this.updateSash(s,exports.SashState.MAXIMUM):this.updateSash(s,exports.SashState.DISABLED)}else a&&!h?this.updateSash(s,exports.SashState.MINIMUM):!a&&h?this.updateSash(s,exports.SashState.MAXIMUM):this.updateSash(s,exports.SashState.ENABLED)}}updateSash(e,t){w(e.container,"dv-disabled",t===exports.SashState.DISABLED),w(e.container,"dv-enabled",t===exports.SashState.ENABLED),w(e.container,"dv-maximum",t===exports.SashState.MAXIMUM),w(e.container,"dv-minimum",t===exports.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 e=document.createElement("div"),t=this._orientation===exports.Orientation.HORIZONTAL?"dv-horizontal":"dv-vertical";return e.className=`dv-split-view-container ${t}`,e}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.removeChild(this.element);break}for(const e of this.viewItems)e.dispose();this.element.remove()}}const U=(()=>{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 m{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(e,t){var i;super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new d,this.onDidChange=this._onDidChange.event,this._orientation=null!==(i=t.orientation)&&void 0!==i?i:exports.Orientation.VERTICAL,this.element=document.createElement("div"),this.element.className="dv-pane-container",e.appendChild(this.element),this.splitview=new $(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:t.descriptor}),this.getPanes().forEach(e=>{const t=new m(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),b(this.element,"dv-animated"),this.animationTimer=setTimeout(()=>{this.animationTimer=void 0,f(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===exports.Orientation.HORIZONTAL?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===exports.Orientation.HORIZONTAL?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===exports.Orientation.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===exports.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===exports.Orientation.HORIZONTAL?this.orthogonalSize:this.size}get height(){return this.orientation===exports.Orientation.HORIZONTAL?this.size:this.orthogonalSize}constructor(e,t,i,s=0){this.view=e,this.orientation=t,this._onDidChange=new d,this.onDidChange=this._onDidChange.event,this._orthogonalSize=i,this._size=s,this._disposable=this.view.onDidChange(e=>{e?this._onDidChange.fire({size:this.orientation===exports.Orientation.VERTICAL?e.width:e.height,orthogonalSize:this.orientation===exports.Orientation.VERTICAL?e.height:e.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 Z extends m{get width(){return this.orientation===exports.Orientation.HORIZONTAL?this.size:this.orthogonalSize}get height(){return this.orientation===exports.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===exports.Orientation.HORIZONTAL?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===exports.Orientation.HORIZONTAL?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===exports.Orientation.HORIZONTAL?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===exports.Orientation.HORIZONTAL?this.maximumSize:this.maximumOrthogonalSize}get priority(){if(0===this.children.length)return exports.LayoutPriority.Normal;const e=this.children.map(e=>void 0===e.priority?exports.LayoutPriority.Normal:e.priority);return e.some(e=>e===exports.LayoutPriority.High)?exports.LayoutPriority.High:e.some(e=>e===exports.LayoutPriority.Low)?exports.LayoutPriority.Low:exports.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 Z&&(t.margin=e)})}constructor(e,t,i,s,o,n,r,a){if(super(),this.orientation=e,this.proportionalLayout=t,this.styles=i,this._childrenDisposable=exports.DockviewDisposable.NONE,this.children=[],this._onDidChange=new d,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new d,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._orthogonalSize=o,this._size=s,this.element=document.createElement("div"),this.element.className="dv-branch-node",a){const e={views:a.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=a.map(e=>e.node),this.splitview=new $(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:t,styles:i,margin:r})}else this.splitview=new $(this.element,{orientation:this.orientation,proportionalLayout:t,styles:i,margin:r}),this.splitview.layout(this.size,this.orthogonalSize);this.disabled=n,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 m(exports.DockviewEvent.any(...this.children.map(e=>e.onDidChange))(e=>{this._onDidChange.fire({size:e.orthogonalSize})}),...this.children.map((e,t)=>e instanceof Z?e.onDidVisibilityChange(({visible:e})=>{this.setChildVisible(t,e)}):exports.DockviewDisposable.NONE))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach(e=>e.dispose()),super.dispose()}}function Y(e,t){if(e instanceof j)return e;if(e instanceof Z)return Y(e.children[t?e.children.length-1:0],t);throw new Error("invalid node")}function X(e,t,i){if(e instanceof Z){const s=new Z(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(X(i,i.size,i.orthogonalSize),i.size,0,!0)}return s}return new j(e.view,e.orientation,i)}function q(e,t,i){if(e instanceof Z){const s=new Z(se(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 Z?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(q(r,i,h),h,0,!0)}return s}return new j(e.view,se(e.orientation),i)}function K(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 Q(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");if(/\bdv-grid-view\b/.test(t.className))return[];const i=K(t);return[...Q(t.parentElement.parentElement.parentElement),i]}function ee(e,t,i){if(ie(e,t)===te(i)){const[e,s]=T(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 te(e){return"top"===e||"bottom"===e?exports.Orientation.VERTICAL:exports.Orientation.HORIZONTAL}function ie(e,t){return t.length%2==0?se(e):e}const se=e=>e===exports.Orientation.HORIZONTAL?exports.Orientation.VERTICAL:exports.Orientation.HORIZONTAL;function oe(e){return!!e.children}const ne=(e,t)=>{const i=t===exports.Orientation.VERTICAL?e.box.width:e.box.height;return oe(e)?{type:"branch",data:e.children.map(e=>ne(e,se(t))),size:i}:"number"==typeof e.cachedVisibleSize?{type:"leaf",data:e.view.toJSON(),size:e.cachedVisibleSize,visible:!1}:{type:"leaf",data:e.view.toJSON(),size:i}};class re{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=q(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 Z&&(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=Q(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(),ne(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=Q(e.element)),this.hasMaximizedView()&&this.exitMaximizedView();const i={root:ne(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation};return t&&(i.maximizedNode={location:t}),e&&this.maximizeView(e),i}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 Z(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize,this.locked,this.margin)}deserialize(e,t){const i=e.orientation,s=i===exports.Orientation.VERTICAL?e.height:e.width;if(this._deserialize(e.root,i,t,s),this.layout(e.width,e.height),e.maximizedNode){const t=e.maximizedNode.location,[i,s]=this.getNode(t);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,se(t),i,e.size),visible:s.visible}));n=new Z(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=X(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 e=this.root;if(e.element.remove(),this._root=new Z(se(e.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size,this.locked,this.margin),0===e.children.length);else if(1===e.children.length){const t=e.children[0];e.removeChild(0).dispose(),e.dispose(),this._root.addChild(q(t,t.orthogonalSize,t.size),exports.Sizing.Distribute,0)}else this._root.addChild(e,exports.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,se(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 Y(o.children[t?n-1:n+1],t)}return Y(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 v,this._onDidChange=new d,this.onDidChange=this._onDidChange.event,this._onDidViewVisibilityChange=new d,this.onDidViewVisibilityChange=this._onDidViewVisibilityChange.event,this._onDidMaximizedNodeChange=new d,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 Z(i,e,t,0,0,this.locked,this.margin)}isViewVisible(e){const[t,i]=T(e),[,s]=this.getNode(t);if(!(s instanceof Z))throw new Error("Invalid from location");return s.isChildVisible(i)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,s]=T(e),[,o]=this.getNode(i);if(!(o instanceof Z))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 Z))throw new Error("Invalid location");s.moveChild(t,i)}addView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[s,o]=T(i),[n,r]=this.getNode(s);if(r instanceof Z){const i=new j(e,se(r.orientation),r.orthogonalSize);r.addChild(i,t,o)}else{const[i,...a]=[...n].reverse(),[h,...l]=[...s].reverse();let d=0;const p=i.getChildCachedVisibleSize(h);"number"==typeof p&&(d=exports.Sizing.Invisible(p));i.removeChild(h).dispose();const u=new Z(r.orientation,this.proportionalLayout,this.styles,r.size,r.orthogonalSize,this.locked,this.margin);i.addChild(u,r.size,h);const c=new j(r.view,i.orientation,r.size);u.addChild(c,d,0),"number"!=typeof t&&"split"===t.type&&(t={type:"split",index:0});const m=new j(e,i.orientation,r.size);u.addChild(m,t,o)}}remove(e,t){const i=Q(e.element);return this.removeView(i,t)}removeView(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,s]=T(e),[o,n]=this.getNode(i);if(!(n instanceof Z))throw new Error("Invalid location");const r=n.children[s];if(!(r instanceof j))throw new Error("Invalid location");if(n.removeChild(s,t),r.dispose(),1!==n.children.length)return r.view;const a=n.children[0];if(0===o.length)return a instanceof j||(n.removeChild(0,t),this.root=a),r.view;const[h,...l]=[...o].reverse(),[d,...p]=[...i].reverse(),u=n.isChildVisible(0);n.removeChild(0,t);const c=h.children.map((e,t)=>h.getChildSize(t));if(h.removeChild(d,t).dispose(),a instanceof Z){c.splice(d,1,...a.children.map(e=>e.size));for(let e=0;e<a.children.length;e++){const t=a.children[e];h.addChild(t,t.size,d+e)}for(;a.children.length>0;)a.removeChild(0)}else{const e=new j(a.view,se(a.orientation),a.size),t=u?a.orthogonalSize:exports.Sizing.Invisible(a.orthogonalSize);h.addChild(e,t,d)}a.dispose();for(let e=0;e<c.length;e++)h.resizeChild(e,c[e]);return r.view}layout(e,t){const[i,s]=this.root.orientation===exports.Orientation.HORIZONTAL?[t,e]:[e,t];this.root.layout(i,s)}getNode(e,t=this.root,i=[]){if(0===e.length)return[i,t];if(!(t instanceof Z))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 ae=(()=>{const e={disableAutoResizing:void 0,proportionalLayout:void 0,orientation:void 0,hideBorders:void 0,className:void 0};return Object.keys(e)})();class he extends m{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(_(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 le=L();function de(e){switch(e){case"left":return"left";case"right":return"right";case"above":return"top";case"below":return"bottom";default:return"center"}}class pe 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(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._id=le.next(),this._groups=new Map,this._onDidRemove=new d,this.onDidRemove=this._onDidRemove.event,this._onDidAdd=new d,this.onDidAdd=this._onDidAdd.event,this._onDidMaximizedChange=new d,this.onDidMaximizedChange=this._onDidMaximizedChange.event,this._onDidActiveChange=new d,this.onDidActiveChange=this._onDidActiveChange.event,this._bufferOnDidLayoutChange=new u,this.onDidLayoutChange=this._bufferOnDidLayoutChange.onEvent,this._onDidViewVisibilityChangeMicroTaskQueue=new u,this.onDidViewVisibilityChangeMicroTaskQueue=this._onDidViewVisibilityChangeMicroTaskQueue.onEvent,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new A(this.element),this._classNames.setClassNames(null!==(i=t.className)&&void 0!==i?i:""),e.appendChild(this.element),this.gridview=new re(!!t.proportionalLayout,t.styles,t.orientation,t.locked,t.margin),this.gridview.locked=!!t.locked,this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidMaximizedNodeChange(e=>{this._onDidMaximizedChange.fire({panel:e.view,isMaximized:e.isMaximized})}),this.gridview.onDidViewVisibilityChange(()=>this._onDidViewVisibilityChangeMicroTaskQueue.fire()),this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.forceRelayout()}),exports.DockviewDisposable.from(()=>{var e;null===(e=this.element.parentElement)||void 0===e||e.removeChild(this.element)}),this.gridview.onDidChange(()=>{this._bufferOnDidLayoutChange.fire()}),exports.DockviewEvent.any(this.onDidAdd,this.onDidRemove,this.onDidActiveChange)(()=>{this._bufferOnDidLayoutChange.fire()}),this._onDidMaximizedChange,this._onDidViewVisibilityChangeMicroTaskQueue,this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(Q(e.element),t),this._bufferOnDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(Q(e.element))}updateOptions(e){var t,i,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(e,t=[0],i){this.gridview.addView(e,null!=i?i:exports.Sizing.Distribute,t),this._onDidAdd.fire(e)}doRemoveGroup(e,t){if(!this._groups.has(e.id))throw new Error("invalid operation");const i=this._groups.get(e.id),s=this.gridview.remove(e,exports.Sizing.Distribute);if(i&&!(null==t?void 0:t.skipDispose)&&(i.disposable.dispose(),i.value.dispose(),this._groups.delete(e.id),this._onDidRemove.fire(e)),!(null==t?void 0:t.skipActive)&&this._activeGroup===e){const e=Array.from(this._groups.values());this.doSetGroupActive(e.length>0?e[0].value:void 0)}return s}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=Q(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=Q(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 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 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 me{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 ve{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 ge extends m{constructor(e,t){super(),this.el=e,this.disabled=t,this.dataDisposable=new v,this.pointerEventsDisposable=new v,this._onDragStart=new d,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,p(this.el,"dragstart",e=>{if(e.defaultPrevented||this.isCancelled(e)||this.disabled)return void e.preventDefault();const t=P();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","")}}),p(this.el,"dragend",()=>{this.pointerEventsDisposable.dispose(),setTimeout(()=>{this.dataDisposable.dispose()},0)}))}}class _e extends m{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(p(this.element,"dragenter",e=>{this.onDragEnter(e)},!0)),this.addDisposables(p(this.element,"dragover",e=>{this.onDragOver(e)},!0)),this.addDisposables(p(this.element,"dragleave",e=>{this.onDragLeave(e)})),this.addDisposables(p(this.element,"dragend",e=>{this.onDragEnd(e)})),this.addDisposables(p(this.element,"drop",e=>{this.onDrop(e)}))}}class fe extends r{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}constructor(e){super(),this.options=e}}function be(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 we(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 De={value:20,type:"percentage"},Ce={value:50,type:"percentage"};class xe extends m{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 d,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new d,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;xe.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 fe({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&&xe.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[xe.USED_EVENT_ID]=!0}isAlreadyUsed(e){const t=e[xe.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,D="bottom"===e,C=!v&&f,x=!v&&_,y=!g&&b,S=!g&&D;let G=1;const P=null!==(d=null===(l=this.options.overlayModel)||void 0===l?void 0:l.size)&&void 0!==d?d:Ce;if("percentage"===P.type?G=M(P.value,0,100)/100:((C||x)&&(G=M(0,P.value,t)/t),(y||S)&&(G=M(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):x?P.width=t*G:y?P.height=i*G:S&&(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&&D&&(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}`:""),w(a,"dv-drop-target-left",_),w(a,"dv-drop-target-right",f),w(a,"dv-drop-target-top",b),w(a,"dv-drop-target-bottom",D),w(a,"dv-drop-target-anchor-line",v&&(_||f)||g&&(b||D)),w(a,"dv-drop-target-center","center"===e),void(n.changed&&(w(a,"dv-drop-target-anchor-container-changed",!0),setTimeout(()=>{w(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+"%"):x?A.width=100*G+"%":y?A.height=100*G+"%":S&&(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&&D&&(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||D);w(this.overlayElement,"dv-drop-target-small-vertical",g),w(this.overlayElement,"dv-drop-target-small-horizontal",v),w(this.overlayElement,"dv-drop-target-selection-line",z),w(this.overlayElement,"dv-drop-target-left",_),w(this.overlayElement,"dv-drop-target-right",f),w(this.overlayElement,"dv-drop-target-top",b),w(this.overlayElement,"dv-drop-target-bottom",D),w(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:De;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)}}xe.USED_EVENT_ID="__dockview_droptarget_event_is_used__";const ye=(()=>{const e={disableAutoResizing:void 0,disableDnd:void 0,className:void 0};return Object.keys(e)})();class Se extends a{constructor(e,t,i,s){super(),this.nativeEvent=e,this.position=t,this.getData=i,this.panel=s}}class Ge extends r{constructor(){super()}}class Pe extends m{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 v,this._onDidDimensionChange=new d,this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new d,this.onDidFocusChange=this._onDidChangeFocus.event,this._onWillFocus=new d,this.onWillFocus=this._onWillFocus.event,this._onDidVisibilityChange=new d,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onWillVisibilityChange=new d,this.onWillVisibilityChange=this._onWillVisibilityChange.event,this._onDidActiveChange=new d,this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new d,this.onActiveChange=this._onActiveChange.event,this._onDidParametersChange=new d,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 Ae extends Pe{constructor(e,t){super(e,t),this._onDidConstraintsChangeInternal=new d,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new d({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new d,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 ze extends Ae{set pane(e){this._pane=e}constructor(e,t){super(e,t),this._onDidExpansionChange=new d({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new d({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new d({}),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 Ie extends m{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=C(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 Ge;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 Te extends Ie{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 ze(e.id,e.component)),this._onDidChangeExpansionState=new d({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new d,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})}),p(this.element,"mouseenter",e=>{this.api._onMouseEnter.fire(e)}),p(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?b(this.header,"focused"):f(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(e,t){this._size=e,this._orthogonalSize=t;const[i,s]=this.orientation===exports.Orientation.HORIZONTAL?[e,t]:[t,e];super.layout(i,s)}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 Ee extends Te{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 d,this.onDidDrop=this._onDidDrop.event,this._onUnhandledDragOverEvent=new d,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 ge{getData(){return s.getInstance().setData([new i(t,e)],i.prototype),{dispose:()=>{s.getInstance().clearData(i.prototype)}}}}(this.header),this.target=new xe(this.element,{acceptedTargetZones:["top","bottom"],overlayModel:{activationSize:{type:"percentage",value:50}},canDisplayOverlay:(e,t)=>{const i=n();if(i&&i.paneId!==this.id&&i.viewId===this.accessor.id)return!0;const s=new Se(e,t,n,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=n();if(!t||t.viewId!==this.accessor.id)return void this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,api:new ce(this.accessor),getData:n}));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:n,api:new ce(this.accessor)}));const r=i.panels,a=r.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(r.length-1,h)),i.movePanel(a,h)}}class Oe extends m{get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this.disposable=new v,this._onDidFocus=new d,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new d,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 xe(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=o();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=C(a);this.focusTracker=e;const t=new m;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;b(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(()=>{f(t,"dv-dragged"),t.remove()},0)}class ke extends ge{constructor(e,t,i,o,n){super(e,n),this.accessor=t,this.group=i,this.panel=o,this.panelTransfer=s.getInstance()}getData(e){return this.panelTransfer.setData([new t(this.accessor.id,this.group.id,this.panel.id)],t.prototype),{dispose:()=>{this.panelTransfer.clearData(t.prototype)}}}}class Me extends m{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 d,this.onPointerDown=this._onPointDown.event,this._onTabClick=new d,this.onTabClick=this._onTabClick.event,this._onDropped=new d,this.onDrop=this._onDropped.event,this._onDragStart=new d,this.onDragStart=this._onDragStart.event,this._onDragEnd=new d,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,w(this.element,"dv-inactive-tab",!0),this.dragHandler=new ke(this._element,this.accessor,this.group,this.panel,!!this.accessor.options.disableDnd),this.dropTarget=new xe(this._element,{acceptedTargetZones:["left","right"],overlayModel:this._buildOverlayModel(),canDisplayOverlay:(e,t)=>{var i;if(this.group.locked)return!1;const s=o();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(()=>{w(this.element,"dv-tab--dragging",!0)})}),p(this._element,"dragend",e=>{w(this.element,"dv-tab--dragging",!1),this._onDragEnd.fire(e)}),this.dragHandler,p(this._element,"pointerdown",e=>{this._onPointDown.fire(e)}),p(this._element,"click",e=>{this._onTabClick.fire(e)}),p(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){w(this.element,"dv-active-tab",e),w(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 Le{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 Ne extends ge{constructor(e,t,i,o){super(e,o),this.accessor=t,this.group=i,this.panelTransfer=s.getInstance(),this.addDisposables(p(e,"pointerdown",e=>{e.shiftKey&&(e[y]=!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 i=e.dataTransfer;this.panelTransfer.setData([new t(this.accessor.id,this.group.id,null)],t.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(i){const e=document.createElement("div");e.style.backgroundColor=o,e.style.color=n,e.style.padding="2px 8px",e.style.height="24px",e.style.fontSize="11px",e.style.lineHeight="20px",e.style.borderRadius="12px",e.style.position="absolute",e.style.pointerEvents="none",e.style.top="-9999px",e.textContent=`Multiple Panels (${this.group.size})`,Ve(i,e,{y:-10,x:30})}return{dispose:()=>{this.panelTransfer.clearData(t.prototype)}}}}class Re extends m{get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this._onDrop=new d,this.onDrop=this._onDrop.event,this._onDragStart=new d,this.onDragStart=this._onDragStart.event,this._element=document.createElement("div"),this._element.className="dv-void-container",this._element.draggable=!this.accessor.options.disableDnd,w(this._element,"dv-draggable",!this.accessor.options.disableDnd),this.addDisposables(this._onDrop,this._onDragStart,p(this._element,"pointerdown",()=>{this.accessor.doSetGroupActive(this.group)})),this.handler=new Ne(this._element,e,t,!!this.accessor.options.disableDnd),this.dropTarget=new xe(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:(e,i)=>{const s=o();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,w(this._element,"dv-draggable",!this.accessor.options.disableDnd),this.handler.setDisabled(!!this.accessor.options.disableDnd)}}class We extends m{get element(){return this._element}get orientation(){return this._orientation}set orientation(e){this._orientation!==e&&(this._scrollOffset=0,this._orientation=e,f(this._scrollbar,"dv-scrollbar-vertical","dv-scrollbar-horizontal"),b(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(p(this.element,"wheel",e=>{this._scrollOffset+=e.deltaY*We.MouseWheelSpeed,this.calculateScrollbarStyles()}),p(this._scrollbar,"pointerdown",e=>{e.preventDefault(),w(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=()=>{w(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)}),p(this.element,"scroll",()=>{this.calculateScrollbarStyles()}),p(this.scrollableElement,"scroll",()=>{this._scrollOffset="horizontal"===this._orientation?this.scrollableElement.scrollLeft:this.scrollableElement.scrollTop,this.calculateScrollbarStyles()}),_(this.element,()=>{w(this.element,"dv-scrollable-resizing",!0),this._animationTimer&&clearTimeout(this._animationTimer),this._animationTimer=setTimeout(()=>{clearTimeout(this._animationTimer),w(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=M(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}}We.MouseWheelSpeed=1;const He=[{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 Fe{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 $e(){return Be||(Be=new Fe(He,!0)),Be}function Ue(e,t,i){const s=(null!=i?i:$e()).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:$e()).resolveValue(e)}class je extends m{get element(){return this._element}constructor(e){super(),this._palette=e,this._onClick=new d,this.onClick=this._onClick.event,this._onContextMenu=new d,this.onContextMenu=this._onContextMenu.event,this._onDragStart=new d,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,p(this._element,"click",e=>{this._onClick.fire(e)}),p(this._element,"contextmenu",e=>{this._onContextMenu.fire(e)}),p(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;Ue(this._element,e,this._palette),w(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,w(this._label,"dv-tab-group-chip-label--empty",!e)}updateCollapsed(e){w(this._element,"dv-tab-group-chip--collapsed",e)}}class Ze{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 Ye extends Ze{_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.innerHTML="",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 Xe extends Ze{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.innerHTML=""),e.style.backgroundColor=h,a?(e.style.width="2px",e.style.height=`${s}px`):(e.style.width=`${s}px`,e.style.height="2px"))}}const qe=new Map;class Ke{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:qe}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")?Xe:Ye;!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 je(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 je?s.push(i.onContextMenu(t=>{this._callbacks.onChipContextMenu(e,t)}),i.onDragStart(t=>{this._callbacks.onChipDragStart(e,i,t)})):s.push(p(i.element,"contextmenu",t=>{this._callbacks.onChipContextMenu(e,t)}),p(i.element,"dragstart",t=>{this._callbacks.onChipDragStart(e,i,t)}));const o=new m(...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(w(i.element,"dv-tab--grouped",a),r){const t=r.panelIds,n=t[0]===s,a=t[t.length-1]===s;w(i.element,"dv-tab--group-first",n),w(i.element,"dv-tab--group-last",a),Ue(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 w(i.element,"dv-tab--group-first",!1),w(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 Qe extends m{get showTabsOverflowControl(){return this._showTabsOverflowControl}set showTabsOverflowControl(e){if(this._showTabsOverflowControl!=e&&(this._showTabsOverflowControl=e,e)){const e=new g(this._tabsList);this._observerDisposable.value=new m(e,e.onDidChange(e=>{const t=e.hasScrollX||e.hasScrollY;this.toggleDropdown({reset:!t}),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}),p(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 m(p(e,"dragover",e=>{this._animState&&e.preventDefault()}),p(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),f(this._tabsList,"dv-horizontal","dv-vertical"),"vertical"===e?b(this._tabsList,"dv-tabs-container-vertical","dv-vertical"):(f(this._tabsList,"dv-tabs-container-vertical"),b(this._tabsList,"dv-horizontal"));for(const t of this._tabs)t.value.setDirection(e)}}constructor(e,t,i){super(),this.group=e,this.accessor=t,this._observerDisposable=new v,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 d,this.onTabDragStart=this._onTabDragStart.event,this._onDrop=new d,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new d,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onOverflowTabsChange=new d,this.onOverflowTabsChange=this._onOverflowTabsChange.event,this._tabsList=document.createElement("div"),this._tabsList.className="dv-tabs-container",this.showTabsOverflowControl=i.showTabsOverflowControl,"native"===t.options.scrollbars?this._element=this._tabsList:(this._scrollbar=new We(this._tabsList),this._scrollbar.orientation=this.direction,this._element=this._scrollbar.element,this.addDisposables(this._scrollbar)),this._tabGroupManager=new Ke({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)}},p(this.element,"pointerdown",e=>{if(e.defaultPrevented)return;0===e.button&&this.accessor.doSetGroupActive(this.group)}),p(this._tabsList,"dragover",e=>{var t,i,s,n;if(!this.accessor.options.disableDnd){if(this._animState){const e=o();(null==e?void 0:e.tabGroupId)&&e.groupId!==this.group.id&&this._animState.sourceTabGroupId!==e.tabGroupId&&(this._animState=null)}if(!this._animState){const e=o();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===(n=null===(s=this.group.model.dropTargetContainer)||void 0===s?void 0:s.model)||void 0===n||n.clear()),this.handleDragOver(e)}},!0),p(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),p(this._tabsList,"dragend",()=>{this.resetDragAnimation()}),p(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),exports.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 Me(e,this.accessor,this.group);i.setContent(e.view.tab),"horizontal"!==this._direction&&i.setDirection(this._direction);const s=new m(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",w(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,n,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=o(),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===(n=this.group.model.getTabGroupForPanel(i.panel.id))||void 0===n?void 0:n.id)&&void 0!==r?r:null;this._onDrop.fire({event:e.nativeEvent,index:d,targetTabGroupId:p})}}),i.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new Le(e,{kind:"tab",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:o}))})),n={value:i,disposable:s};this.addTab(n,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()}updateTabGroups(){this._tabGroupManager.update()}refreshTabGroupAccent(){this._tabGroupManager.refreshAccents()}_handleChipDragStart(e,i,o){var n;const r=e.panelIds[0],a=r?this._tabs.findIndex(e=>e.value.panel.id===r):-1,h=i.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:o.clientX-h.left,sourceGapWidth:l,containerLeft:this._tabsList.getBoundingClientRect().left};const d=s.getInstance();d.setData([new t(this.accessor.id,this.group.id,null,e.id)],t.prototype);const p=P(),u=i.element,c=()=>{u.removeEventListener("dragend",c),this.resetDragAnimation()};if(u.addEventListener("dragend",c),this._chipDragCleanup={dispose:()=>{u.removeEventListener("dragend",c),d.clearData(t.prototype),p.release()}},o.dataTransfer&&(o.dataTransfer.effectAllowed="move",0===o.dataTransfer.items.length&&o.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",w(e.value.element,"dv-tab--dragging",!0));const o=this._tabGroupManager.chipRenderers.get(e.id);o&&(o.chip.element.style.transition="none",w(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(o,e,i.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){a=a<(d+p+1)/2?d:p+1;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",w(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,w(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"),w(t,i,!1);else{t.style.marginLeft="0px",w(t,i,!0);const e=()=>{t.style.removeProperty("margin-left"),w(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"),w(e.value.element,"dv-tab--shifting",!1);for(const[,e]of this._tabGroupManager.chipRenderers)e.chip.element.style.removeProperty("margin-left"),w(e.chip.element,"dv-tab-group-chip--shifting",!1);this._tabGroupManager.positionUnderlines()}_commitGroupMove(e,t){var i,s,n;const r=o();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!==(n=r.tabGroupId)&&void 0!==n?n: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)`,w(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)`,w(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)w(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 et=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},tt=()=>et({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 it extends m{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?(b(this._element,"dv-groupview-header-vertical"),b(this.rightActionsContainer,"dv-right-actions-container-vertical"),this.tabs.direction=e):(f(this._element,"dv-groupview-header-vertical"),f(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 v,this._onDrop=new d,this.onDrop=this._onDrop.event,this._onGroupDragStart=new d,this.onGroupDragStart=this._onGroupDragStart.event,this._onWillShowOverlay=new d,this.onWillShowOverlay=this._onWillShowOverlay.event,this._element=document.createElement("div"),this._element.className="dv-tabs-and-actions-container",w(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 Qe(t,e,{showTabsOverflowControl:!e.options.disableTabsOverflowList}),this.voidContainer=new Re(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 Le(e,{kind:"header_space",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:o}))}),p(this.leftActionsContainer,"dragleave",e=>{const t=e.relatedTarget;this.leftActionsContainer.contains(t)||this._element.contains(t)||this.tabs.clearExternalAnimState()}),p(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())}),p(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(){w(this._element,"dv-single-tab",1===this.size)}toggleDropdown(e){const t=e.reset?[]:e.tabs,i=e.reset?[]:e.tabGroups;this._overflowTabs=t,this._overflowTabGroups=i;const s=this._overflowTabs.length;if(s>0&&this.dropdownPart)return void this.dropdownPart.update({tabs:s});if(0===s)return void this._dropdownDisposable.dispose();const o=document.createElement("div");o.className="dv-tabs-overflow-dropdown-root";const n=function(){const e=document.createElement("div");e.className="dv-tabs-overflow-dropdown-default";const t=document.createElement("span");t.textContent="";const i=tt();return e.appendChild(i),e.appendChild(t),{element:e,update:e=>{t.textContent=`${e.tabs}`}}}();n.update({tabs:s}),this.dropdownPart=n,o.appendChild(n.element),this.rightActionsContainer.prepend(o),this._dropdownDisposable.value=new m(exports.DockviewDisposable.from(()=>{var e,t;o.remove(),null===(t=null===(e=this.dropdownPart)||void 0===e?void 0:e.dispose)||void 0===t||t.call(e),this.dropdownPart=null}),p(o,"pointerdown",e=>{e.preventDefault()},{capture:!0}),p(o,"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(),n=new Map;for(const e of s)if(i.has(e.id))for(const t of e.panelIds)n.set(t,e);const r=new Set;for(const e of this.tabs.tabs.filter(e=>this._overflowTabs.includes(e.panel.id))){const i=n.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",Ue(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),o=s.view.createTabRenderer("headerOverflow").element,a=document.createElement("div");w(a,"dv-tab",!0),w(a,"dv-active-tab",s.api.isActive),w(a,"dv-inactive-tab",!s.api.isActive),i&&w(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(o),t.appendChild(a)}const a=I(o);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 st extends a{constructor(e,t,i,s,o){super(),this.nativeEvent=e,this.target=t,this.position=i,this.getData=s,this.group=o}}const ot=(()=>{const e={disableAutoResizing:void 0,hideBorders:void 0,singleTabMode:void 0,disableFloatingGroups:void 0,floatingGroupBounds:void 0,popoutUrl:void 0,defaultRenderer:void 0,defaultHeaderPosition:void 0,debug:void 0,rootOverlayModel:void 0,locked:void 0,disableDnd:void 0,className:void 0,noPanelsOverlay:void 0,dndEdges:void 0,theme:void 0,disableTabsOverflowList:void 0,scrollbars:void 0,getTabContextMenuItems:void 0,getTabGroupChipContextMenuItems:void 0,createTabGroupChipComponent:void 0,tabGroupColors:void 0,tabGroupAccent:void 0};return Object.keys(e)})();function nt(e){return!!e.referencePanel}function rt(e){return!!e.referenceGroup}function at(e){return!!e.referencePanel}function ht(e){return!!e.referenceGroup}class lt extends m{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 d,this.onDidChange=this._onDidChange.event,this._onDidPanelChange=new d,this.onDidPanelChange=this._onDidPanelChange.event,this._onDidCollapseChange=new d,this.onDidCollapseChange=this._onDidCollapseChange.event,this._onDidDestroy=new d,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 dt extends r{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 pt extends dt{get kind(){return this._kind}constructor(e){super(e),this._kind=e.kind}}class ut extends m{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,w(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&&D(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,f(this.container,"dv-groupview-header-top","dv-groupview-header-bottom","dv-groupview-header-left","dv-groupview-header-right"),b(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,w(this.container,"dv-groupview-floating",!1),w(this.container,"dv-groupview-popout",!1),w(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"]),w(this.container,"dv-groupview-floating",!0);break;case"popout":this.contentContainer.dropTarget.setTargetZones(["center"]),w(this.container,"dv-groupview-popout",!0);break;case"edge":this.contentContainer.dropTarget.setTargetZones(["center"]),w(this.container,"dv-groupview-edge",!0)}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,i,s,n){var r,a;super(),this.container=e,this.accessor=t,this.id=i,this.options=s,this.groupPanel=n,this._isGroupActive=!1,this._locked=!1,this._rightHeaderActionsDisposable=new v,this._leftHeaderActionsDisposable=new v,this._prefixHeaderActionsDisposable=new v,this._location={type:"grid"},this.mostRecentlyUsed=[],this._overwriteRenderContainer=null,this._overwriteDropTargetContainer=null,this._onDidChange=new d,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 d,this.onMove=this._onMove.event,this._onDidDrop=new d,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new d,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new d,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onTabDragStart=new d,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new d,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new d,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPanelTitleChange=new d,this.onDidPanelTitleChange=this._onDidPanelTitleChange.event,this._onDidPanelParametersChange=new d,this.onDidPanelParametersChange=this._onDidPanelParametersChange.event,this._onDidRemovePanel=new d,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new d,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onUnhandledDragOverEvent=new d,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this._tabGroups=[],this._tabGroupMap=new Map,this._panelToTabGroup=new Map,this._tabGroupIdCounter=0,this._pendingTabGroupUpdate=!1,this._onDidCreateTabGroup=new d,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new d,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new d,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new d,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new d,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new d,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,w(this.container,"dv-groupview",!0),this._api=new ve(this.accessor),this.tabsContainer=new it(this.accessor,this.groupPanel),this.contentContainer=new Oe(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=o(),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 Le(e,{kind:"content",panel:this.activePanel,api:this._api,group:this.groupPanel,getData:o}))}),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 lt(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 m(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()}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,w(this.container,"dv-active-group",e),w(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 m(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,p(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 st(e,i,t,o,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 n="number"==typeof s?this.panels[s]:void 0,r=new pt({nativeEvent:t,position:i,panel:n,getData:()=>o(),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=o();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 dt({nativeEvent:t,position:i,panel:n,getData:()=>o(),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 ct extends Pe{constructor(e,t,i){super(e,t),this._onDidConstraintsChangeInternal=new d,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new d,this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new d,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 mt extends Ie{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 ct(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 d,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 vt="dockview: DockviewGroupPanelApiImpl not initialized";class gt extends ct{get location(){if(!this._group)throw new Error(vt);return this._group.model.location}constructor(e,t){super(e,"__dockviewgroup__"),this.accessor=t,this._onDidLocationChange=new d,this.onDidLocationChange=this._onDidLocationChange.event,this._onDidActivePanelChange=new d,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidCollapsedChange=new d,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(vt);this._group.model.headerPosition=e}getHeaderPosition(){if(!this._group)throw new Error(vt);return this._group.model.headerPosition}moveTo(e){var t,i,s,o;if(!this._group)throw new Error(vt);const n=null!==(t=e.group)&&void 0!==t?t:this.accessor.addGroup({direction:we(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(vt);"grid"===this.location.type&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw new Error(vt);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw new Error(vt);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 _t extends mt{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 gt(t,e)),this._explicitConstraints={},this.api.initialize(this),this._model=new ut(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 ft={name:"abyss",className:"dockview-theme-abyss",colorScheme:"dark",tabGroupIndicator:"none"};class bt extends ct{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 d,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidActiveGroupChange=new d,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new d,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new d,this.onDidRendererChange=this._onDidRendererChange.event,this._onDidLocationChange=new d,this.onDidLocationChange=this._onDidLocationChange.event,this.groupEventsDisposable=new v,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 m(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 wt extends m{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 bt(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 Ge;this.api._onWillFocus.fire(e),e.defaultPrevented||this.api.isActive||this.api.setActive()}toJSON(){return{id:this.id,contentComponent:this.view.contentComponent,tabComponent:this.view.tabComponent,params:Object.keys(this._params||{}).length>0?this._params:void 0,title:this.title,renderer:this._renderer,minimumHeight:this._minimumHeight,maximumHeight:this._maximumHeight,minimumWidth:this._minimumWidth,maximumWidth:this._maximumWidth}}setTitle(e){e!==this.title&&(this._title=e,this.api._onDidTitleChange.fire({title:e}))}setRenderer(e){e!==this.renderer&&(this._renderer=e,this.api._onDidRendererChange.fire({renderer:e}))}update(e){var t;this._params=Object.assign(Object.assign({},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 Dt extends m{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(et({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()}),p(this.action,"pointerdown",e=>{e.preventDefault()}),p(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 Ct{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"}))}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 Dt}console.warn(`dockview: tabComponent '${t}' was not found. falling back to the default tab.`)}return new Dt}}class xt{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 Ct(this.accessor,o,h,l),p=new wt(o,h,l,this.accessor,new ve(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 yt extends m{get element(){return this._element}constructor(){super(),this._element=document.createElement("div"),this._element.className="dv-watermark"}init(e){}}const St=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 Gt extends m{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 d,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new d,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})),St.push(this._element)}setVisible(e){e!==this.isVisible&&(this._isVisible=e,w(this.element,"dv-hidden",!this.isVisible))}bringToFront(){St.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=M(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=M(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=M(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=M(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 v,s=()=>{let e=null;const t=P();i.value=new m({dispose:()=>{t.release()}},p(window,"pointermove",t=>{const i=this.options.container.getBoundingClientRect(),s=t.clientX-i.left,o=t.clientY-i.top;w(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=M(o-e.y,-a,Math.max(0,i.height-n.height+a)),l=M(e.y-o+i.height-n.height,-a,Math.max(0,i.height-n.height+a)),d=M(s-e.x,-r,Math.max(0,i.width-n.width+r)),p=M(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)}),p(window,"pointerup",()=>{w(this._element,"dv-resize-container-dragging",!1),i.dispose(),this._onDidChangeEnd.fire()}))};this.addDisposables(i,p(e,"pointerdown",e=>{e.defaultPrevented?e.preventDefault():S(e)||s()}),p(this.options.content,"pointerdown",e=>{e.defaultPrevented||S(e)||e.shiftKey&&s()}),p(this.options.content,"pointerdown",()=>{St.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 v;this.addDisposables(i,p(t,"pointerdown",t=>{t.preventDefault();let s=null;const o=P();i.value=new m(p(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-Gt.MINIMUM_HEIGHT):Math.max(0,s.originalY+s.originalHeight-Gt.MINIMUM_HEIGHT);a=M(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:Gt.MINIMUM_HEIGHT,t=i.height-Math.max(0,a);l=M(n-a,e,t),h=i.height-a-l},v=()=>{const e=s.originalX+s.originalWidth>i.width?Math.max(0,i.width-Gt.MINIMUM_WIDTH):Math.max(0,s.originalX+s.originalWidth-Gt.MINIMUM_WIDTH);d=M(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:Gt.MINIMUM_WIDTH,t=i.width-Math.max(0,d);u=M(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()}},p(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(){St.destroy(this._element),this._element.remove(),super.dispose()}}Gt.MINIMUM_HEIGHT=20,Gt.MINIMUM_WIDTH=20;class Pt extends m{constructor(e,t){super(),this.group=e,this.overlay=t,this.addDisposables(t)}position(e){this.overlay.setBounds(e)}}const At=100,zt=100,It=100,Tt=300,Et=300;class Ot{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=G(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 m{constructor(e,t){super(),this.element=e,this.accessor=t,this.map={},this._disposed=!1,this.positionCache=new Ot,this.pendingUpdates=new Set,this.addDisposables(exports.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(e){const{panel:t,referenceContainer:i}=e;if(!this.map[t.api.id]){const e=function(){const e=document.createElement("div");return e.tabIndex=-1,e}();e.className="dv-render-overlay",e.style.visibility="hidden",this.map[t.api.id]={panel:t,disposable:exports.DockviewDisposable.NONE,destroy:exports.DockviewDisposable.NONE,element:e}}const s=this.map[t.api.id].element,o=t.view.content.element;o.parentElement!==s&&s.appendChild(o),s.parentElement!==this.element&&this.element.appendChild(s);const n=()=>{const e=t.api.id;this.pendingUpdates.has(e)||(this.pendingUpdates.add(e),requestAnimationFrame(()=>{if(this.pendingUpdates.delete(e),this.isDisposed||!this.map[e])return;const o=this.positionCache.getPosition(i.element),n=this.positionCache.getPosition(this.element),r=o.left-n.left,a=o.top-n.top,h=o.width,l=o.height;s.style.left=`${r}px`,s.style.top=`${a}px`,s.style.width=`${h}px`,s.style.height=`${l}px`,"hidden"===s.style.visibility&&(s.style.visibility=""),w(s,"dv-render-overlay-float","floating"===t.group.api.location.type)}))},r=()=>{t.api.isVisible&&(this.positionCache.invalidate(),n()),s.style.display=t.api.isVisible?"":"none"},a=new v,h=()=>{"floating"===t.api.location.type?queueMicrotask(()=>{const e=this.accessor.floatingGroups.find(e=>e.group===t.api.group);if(!e)return;const i=e.overlay.element,o=()=>{const e=Number(i.getAttribute("aria-level"));s.style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${2*e+1})`},n=new MutationObserver(()=>{o()});a.value=exports.DockviewDisposable.from(()=>n.disconnect()),n.observe(i,{attributeFilter:["aria-level"],attributes:!0}),o()}):s.style.zIndex=""},l=new m(a,new _e(s,{onDragEnd:e=>{i.dropTarget.dnd.onDragEnd(e)},onDragEnter:e=>{i.dropTarget.dnd.onDragEnter(e)},onDragLeave:e=>{i.dropTarget.dnd.onDragLeave(e)},onDrop:e=>{i.dropTarget.dnd.onDrop(e)},onDragOver:e=>{i.dropTarget.dnd.onDragOver(e)}}),t.api.onDidVisibilityChange(()=>{r()}),t.api.onDidDimensionsChange(()=>{t.api.isVisible&&n()}),t.api.onDidLocationChange(()=>{h()}));return this.map[t.api.id].destroy=exports.DockviewDisposable.from(()=>{var e;o.parentElement===s&&s.removeChild(o),null===(e=s.parentElement)||void 0===e||e.removeChild(s)}),h(),queueMicrotask(()=>{this.isDisposed||r()}),this.map[t.api.id].disposable.dispose(),this.map[t.api.id].disposable=l,this.map[t.api.id].resize=n,s}}function kt(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 Mt extends m{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 d,this.onWillClose=this._onWillClose.event,this._onDidClose=new d,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 kt(this,void 0,void 0,function*(){var e,t;if(this._window)throw new Error("instance of popout window is already open");const i=`${this.options.url}`,s=Object.entries({top:this.options.top,left:this.options.left,width:this.options.width,height:this.options.height}).map(([e,t])=>`${e}=${t}`).join(","),o=window.open(i,this.target,s);if(!o)return null;const n=new m;this._window={value:o,disposable:n},n.addDisposables(exports.DockviewDisposable.from(()=>{o.close()}),p(window,"beforeunload",()=>{this.close()}));const r=this.createPopoutWindowContainer();return this.className&&r.classList.add(this.className),null===(t=(e=this.options).onDidOpen)||void 0===t||t.call(e,{id:this.target,window:o}),new Promise((e,t)=>{o.addEventListener("unload",e=>{}),o.addEventListener("load",()=>{try{const t=o.document;t.title=document.title,t.body.appendChild(r),function(e,t){const i=Array.from(t);for(const t of i){if(t.href){const i=e.createElement("link");i.href=t.href,i.type=t.type,i.rel="stylesheet",e.head.appendChild(i)}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)}for(const t of i){const i=e.createElement("style");i.appendChild(e.createTextNode(t)),e.head.appendChild(i)}}}(t,window.document.styleSheets),p(o,"beforeunload",()=>{this.close()}),e(r)}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 Lt extends m{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 Nt extends m{constructor(e,t=window){super(),this._active=null,this._activeDisposable=new v,this._root=e,this._window=t,this._element=t.document.createElement("div"),this._element.className="dv-popover-anchor",this._element.style.position="relative",this._root.prepend(this._element),this.addDisposables(exports.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 m(p(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()}),p(this._window,"keydown",e=>{"Escape"!==e.key&&"Enter"!==e.key||this.close()}),p(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 Rt(e){if(!(e instanceof HTMLElement))return;const t=I(e);return(null==t?void 0:t.style.zIndex)?`calc(${t.style.zIndex} * 2)`:void 0}let Wt=0;const Ht=()=>"dv-ctx-menu-item-"+Wt++;function Ft(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 $t(){const e=document.createElement("div");return e.className="dv-context-menu-separator",e.setAttribute("role","separator"),e}function Ut(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 jt{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($t());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(Ft(i)&&i.element)h.appendChild(i.element);else if(Ft(i)&&i.component){const n=null===(o=(s=this.accessor.options).createContextMenuItemComponent)||void 0===o?void 0:o.call(s,{id:Ht(),component:i.component});n&&(n.init({panel:e,group:t,api:this.accessor.api,close:a,componentProps:i.componentProps}),h.appendChild(n.element))}else Ft(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:Rt(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($t()):"rename"===t?r.appendChild(Ut(e)):"colorPicker"===t?r.appendChild(Jt(e,this.accessor.tabGroupColorPalette)):Ft(t)&&t.element?r.appendChild(t.element):Ft(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:Rt(i.target)})}}class Zt extends m{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(e,t){super(),this.element=e,this._disabled=!1,this._disabled=t.disabled,this.addDisposables(exports.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 Yt{get minimumSize(){return this._isCollapsed?this._collapsedSize:this._expandedMinimumSize}get maximumSize(){return this._isCollapsed?this._collapsedSize:this._expandedMaximumSize}get element(){return this._group.element}get isCollapsed(){return this._isCollapsed}get lastExpandedSize(){return this._lastExpandedSize}get collapsedSize(){return this._collapsedSize}constructor(e,t,i){var s,o,n;this._onDidChange=new d,this.onDidChange=this._onDidChange.event,this.snap=!1,this.priority=exports.LayoutPriority.Low,this._isCollapsed=!1,this._group=t,this._orientation=i,t.element.classList.add("dv-edge-group"),t.element.dataset.testid=`dv-edge-group-${e.id}`,this._collapsedSize=null!==(s=e.collapsedSize)&&void 0!==s?s:35,this._expandedMaximumSize=null!==(o=e.maximumSize)&&void 0!==o?o:Number.POSITIVE_INFINITY,this._expandedMinimumSize=void 0!==e.minimumSize?e.minimumSize:this._collapsedSize+50,this._lastExpandedSize=null!==(n=e.initialSize)&&void 0!==n?n:200,e.collapsed&&(this._isCollapsed=!0,t.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 Xt{get element(){return this._dockviewElement}constructor(e,t){this._dockviewElement=e,this._layoutDockview=t,this.priority=exports.LayoutPriority.High,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this._onDidChange=new d,this.onDidChange=this._onDidChange.event}layout(e,t){this._layoutDockview(t,e)}setVisible(e){}dispose(){this._onDidChange.dispose()}}class qt{get element(){return this._element}constructor(e,t=0){this._onDidChange=new d,this.onDidChange=this._onDidChange.event,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this.priority=exports.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 $(this._element,{orientation:exports.Orientation.VERTICAL,proportionalLayout:!1,margin:t}),this._centerIndex=0,this._splitview.addView(e,{type:"distribute"},0)}addTopView(e,t){this._splitview.addView(e,t,0),this._topIndex=0,this._centerIndex+=1,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 Kt{constructor(e,t,i,s=0,o=35){this._disposables=new m,this._viewConfigs=new Map,this._currentWidth=0,this._currentHeight=0,this._gap=s,this._defaultCollapsedSize=o,this._shellElement=document.createElement("div"),this._shellElement.className="dv-shell",this._shellElement.style.height="100%",this._shellElement.style.width="100%",this._shellElement.style.position="relative",e.appendChild(this._shellElement);const n=new Xt(t,i);this._middleColumn=new qt(n,s),this._outerSplitview=new $(this._shellElement,{orientation:exports.Orientation.HORIZONTAL,proportionalLayout:!1,margin:s}),this._middleIndex=0,this._outerSplitview.addView(this._middleColumn,{type:"distribute"},0),this._disposables.addDisposables(_(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,n)}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 Yt(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 Qt={activationSize:{type:"pixels",value:10},size:{type:"pixels",value:20}};function ei(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 ti extends pe{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(e,t){var i,s,n,r,a,h;super(e,{proportionalLayout:!0,orientation:exports.Orientation.HORIZONTAL,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:t.disableAutoResizing,locked:t.locked,margin:null!==(s=null===(i=t.theme)||void 0===i?void 0:i.gap)&&void 0!==s?s:0,className:t.className}),this.nextGroupId=L(),this._deserializer=new xt(this),this._watermark=null,this._popoutPopupServices=new Map,this._onWillDragPanel=new d,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new d,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new d,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new d,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new d,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onUnhandledDragOverEvent=new d,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this._onDidRemovePanel=new d,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new d,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPopoutGroupSizeChange=new d,this.onDidPopoutGroupSizeChange=this._onDidPopoutGroupSizeChange.event,this._onDidPopoutGroupPositionChange=new d,this.onDidPopoutGroupPositionChange=this._onDidPopoutGroupPositionChange.event,this._onDidOpenPopoutWindowFail=new d,this.onDidOpenPopoutWindowFail=this._onDidOpenPopoutWindowFail.event,this._onDidLayoutFromJSON=new d,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new d({replay:!0}),this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidMovePanel=new d,this.onDidMovePanel=this._onDidMovePanel.event,this._onDidCreateTabGroup=new d,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new d,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new d,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new d,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new d,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new d,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,this._onDidMaximizedGroupChange=new d,this.onDidMaximizedGroupChange=this._onDidMaximizedGroupChange.event,this._inShellLayout=!1,this._edgeGroups=new Map,this._edgeGroupDisposables=new Map,this._floatingGroups=[],this._popoutGroups=[],this._popoutRestorationPromise=Promise.resolve(),this._onDidRemoveGroup=new d,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new d,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidOptionsChange=new d,this.onDidOptionsChange=this._onDidOptionsChange.event,this._onDidActiveGroupChange=new d,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._moving=!1,this._options=t,this._tabGroupColorPalette=function(e){var t;const i=null!==(t=e.tabGroupColors)&&void 0!==t?t:He,s="off"!==e.tabGroupAccent;return new Fe(i,s)}(t),this.popupService=new Nt(this.element),this.contextMenuController=new jt(this),this._api=new ve(this),this.disableResizing=!0,e.removeChild(this.element),this._shellManager=new Kt(e,this.element,(e,t)=>this._layoutFromShell(e,t),null!==(r=null===(n=t.theme)||void 0===n?void 0:n.gap)&&void 0!==r?r:0,null===(a=t.theme)||void 0===a?void 0:a.edgeGroupCollapsedSize),this.popupService.updateRoot(this._shellManager.element),this._shellThemeClassnames=new A(this._shellManager.element),this.rootDropTargetContainer=new Zt(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 xe(this.element,{className:"dv-drop-target-edge",canDisplayOverlay:(e,t)=>{const i=o();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 st(e,"edge",t,o);return this._onUnhandledDragOverEvent.fire(s),s.isAccepted},acceptedTargetZones:["top","bottom","left","right","center"],overlayModel:null!==(h=t.rootOverlayModel)&&void 0!==h?h:Qt,getOverrideTarget:()=>{var e;return null===(e=this.rootDropTargetContainer)||void 0===e?void 0:e.model}}),this.updateDropTargetModel(t),w(this.gridview.element,"dv-dockview",!0),w(this.element,"dv-debug",!!t.debug),this.updateTheme(),this.updateWatermark(),t.debug&&this.addDisposables(new Lt(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})}),exports.DockviewEvent.any(this.onDidAdd,this.onDidRemove)(()=>{this.updateWatermark()}),exports.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()}),exports.DockviewDisposable.from(()=>{var e;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 Le(e,{kind:"edge",panel:void 0,api:this._api,group:void 0,getData:o}))}),this._rootDropTarget.onDrop(e=>{var t;const i=new pt({nativeEvent:e.nativeEvent,position:e.position,panel:void 0,api:this._api,group:void 0,getData:o,kind:"edge"});if(this._onWillDrop.fire(i),i.defaultPrevented)return;const s=o();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 dt({nativeEvent:e.nativeEvent,position:e.position,panel:void 0,api:this._api,group:void 0,getData:o}))}),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(e,t){var i,s,o,n,r;if(e instanceof _t&&"edge"===e.model.location.type)return Promise.resolve(!1);if(e instanceof wt&&1===e.group.size)return this.addPopoutGroup(e.group,t);const a=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),h=this.element;const l=(null==t?void 0:t.position)?t.position:e instanceof _t?e.element.getBoundingClientRect():e.group?e.group.element.getBoundingClientRect():h.getBoundingClientRect(),u=null!==(s=null===(i=null==t?void 0:t.overridePopoutGroup)||void 0===i?void 0:i.id)&&void 0!==s?s:this.getNextGroupId(),c=new Mt(`${this.id}-${u}`,null!=a?a:"",{url:null!==(r=null!==(o=null==t?void 0:t.popoutUrl)&&void 0!==o?o:null===(n=this.options)||void 0===n?void 0:n.popoutUrl)&&void 0!==r?r:"/popout.html",left:window.screenX+l.left,top:window.screenY+l.top,width:l.width,height:l.height,onDidOpen:null==t?void 0:t.onDidOpen,onWillClose:null==t?void 0:t.onWillClose}),v=new m(c,c.onDidClose(()=>{v.dispose()}));return c.open().then(i=>{var s;if(c.isDisposed)return!1;const o=(null==t?void 0:t.referenceGroup)?t.referenceGroup:e instanceof wt?e.group:e,n=e.api.location.type,r=null!==o.element.parentElement;let a;if(r?(null==t?void 0:t.overridePopoutGroup)?a=t.overridePopoutGroup:(a=this.createGroup({id:u}),i&&this._onDidAddGroup.fire(a)):a=o,null===i)return console.error("dockview: failed to create popout. perhaps you need to allow pop-ups for this website"),v.dispose(),this._onDidOpenPopoutWindowFail.fire(),this.movingLock(()=>ei({from:a,to:o})),o.api.isVisible||o.api.setVisible(!0),!1;const h=document.createElement("div");h.className="dv-overlay-render-container";const l=new Vt(h,this);let g;if(a.model.renderContainer=l,a.layout(c.window.innerWidth,c.window.innerHeight),!(null==t?void 0:t.overridePopoutGroup)&&r)if(e instanceof wt)this.movingLock(()=>{const t=o.model.removePanel(e);a.model.openPanel(t)});else switch(this.movingLock(()=>ei({from:o,to:a})),n){case"grid":o.api.setVisible(!1);break;case"floating":case"popout":g=null===(s=this._floatingGroups.find(t=>t.group.api.id===e.api.id))||void 0===s?void 0:s.overlay.toJSON(),this.removeGroup(o)}i.classList.add("dv-dockview"),i.style.overflow="hidden",i.appendChild(h),i.appendChild(a.element);const _=document.createElement("div"),f=new Zt(_,{disabled:this.rootDropTargetContainer.disabled});i.appendChild(_),a.model.dropTargetContainer=f;const b=new Nt(i,c.window);let w;this._popoutPopupServices.set(a.id,b),v.addDisposables(b,exports.DockviewDisposable.from(()=>{this._popoutPopupServices.delete(a.id)})),a.model.location={type:"popout",getWindow:()=>c.window,popoutUrl:null==t?void 0:t.popoutUrl},r&&"grid"===e.api.location.type&&e.api.setVisible(!1),this.doSetGroupAndPanelActive(a),v.addDisposables(a.api.onDidActiveChange(e=>{var t;e.isActive&&(null===(t=c.window)||void 0===t||t.focus())}),a.api.onWillFocus(()=>{var e;null===(e=c.window)||void 0===e||e.focus()}));const D=r&&o&&this.getPanel(o.id),C={window:c,popoutGroup:a,referenceGroup:D?o.id:void 0,disposable:{dispose:()=>(v.dispose(),w)}},x=function(e){const t=new d;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}(c.window);return v.addDisposables(x,function(e,t){let i;return new m(p(e,"resize",()=>{clearTimeout(i),i=setTimeout(()=>{t()},100)}))}(c.window,()=>{this._onDidPopoutGroupSizeChange.fire({width:c.window.innerWidth,height:c.window.innerHeight,group:a})}),x.event(()=>{this._onDidPopoutGroupPositionChange.fire({screenX:c.window.screenX,screenY:c.window.screenX,group:a})}),p(c.window,"resize",()=>{a.layout(c.window.innerWidth,c.window.innerHeight)}),l,exports.DockviewDisposable.from(()=>{if(!this.isDisposed)if(r&&this.getPanel(o.id))this.movingLock(()=>ei({from:a,to:o})),o.api.isVisible||o.api.setVisible(!0),this.getPanel(a.id)&&this.doRemoveGroup(a,{skipPopoutAssociated:!0});else if(this.getPanel(a.id)){a.model.renderContainer=this.overlayRenderContainer,a.model.dropTargetContainer=this.rootDropTargetContainer,w=a;if(!this._popoutGroups.find(e=>e.popoutGroup===a))return;g?this.addFloatingGroup(a,{height:g.height,width:g.width,position:g}):(this.doRemoveGroup(a,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),a.model.location={type:"grid"},this.movingLock(()=>{this.doAddGroup(a,[0])})),this.doSetGroupAndPanelActive(a)}})),this._popoutGroups.push(C),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 _t&&"edge"===e.model.location.type)return;let h;if(e instanceof wt)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(()=>ei({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 l=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=zt,"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=It,"number"==typeof t.width?e.width=Math.max(t.width,0):e.width=Tt,"number"==typeof t.height?e.height=Math.max(t.height,0):e.height=Et,e}return{left:"number"==typeof(null==t?void 0:t.x)?Math.max(t.x,0):zt,top:"number"==typeof(null==t?void 0:t.y)?Math.max(t.y,0):It,width:"number"==typeof(null==t?void 0:t.width)?Math.max(t.width,0):Tt,height:"number"==typeof(null==t?void 0:t.height)?Math.max(t.height,0):Et}}(),d=new Gt(Object.assign(Object.assign({container:null!==(s=this._floatingOverlayHost)&&void 0!==s?s:this.gridview.element,content:h.element},l),{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:At,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:At})),p=h.element.querySelector(".dv-void-container");if(!p)throw new Error("dockview: failed to find drag handle");d.setupDrag(p,{inDragMode:"boolean"==typeof(null==t?void 0:t.inDragMode)&&t.inDragMode});const u=new Pt(h,d),c=new m(h.api.onDidActiveChange(e=>{e.isActive&&d.bringToFront()}),(()=>{let e=-1,t=-1;return _(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(d.onDidChange(()=>{h.layout(h.width,h.height)}),d.onDidChangeEnd(()=>{this._bufferOnDidLayoutChange.fire()}),h.onDidChange(e=>{d.setBounds({height:null==e?void 0:e.height,width:null==e?void 0:e.width})}),{dispose:()=>{c.dispose(),k(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(e,t){switch(this.gridview.normalize(),e){case"top":case"bottom":this.gridview.orientation===exports.Orientation.HORIZONTAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case"left":case"right":this.gridview.orientation===exports.Orientation.VERTICAL&&this.gridview.insertOrthogonalSplitviewAtRoot()}switch(e){case"top":case"left":case"center":return this.createGroupAtLocation([0],void 0,t);case"bottom":case"right":return this.createGroupAtLocation([this.gridview.length],void 0,t);default:throw new Error(`dockview: unsupported position ${e}`)}}updateOptions(e){var t,i,s;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=At,s.overlay.minimumInViewportWidth=At;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 o=this.options.disableDnd;this._options=Object.assign(Object.assign({},this.options),e);if(o!==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("tabGroupColors"in e||"tabGroupAccent"in e){this._tabGroupColorPalette.setEntries(null!==(s=this._options.tabGroupColors)&&void 0!==s?s:He),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=Q(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=Q(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=>{setTimeout(()=>{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)});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(e){var t,i;if(this.panels.find(t=>t.id===e.id))throw new Error(`dockview: panel with id ${e.id} already exists`);let s;if(e.position&&e.floating)throw new Error("dockview: you can only provide one of: position, floating as arguments to .addPanel(...)");const o={width:e.initialWidth,height:e.initialHeight};let n,r;if(e.position)if(nt(e.position)){const t="string"==typeof e.position.referencePanel?this.getGroupPanel(e.position.referencePanel):e.position.referencePanel;if(n=e.position.index,!t)throw new Error(`dockview: referencePanel '${e.position.referencePanel}' does not exist`);s=this.findGroup(t)}else{if(!rt(e.position)){const t=this.orthogonalize(be(e.position.direction)),i=this.createPanel(e,t);return t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:n}),e.inactive||this.doSetGroupAndPanelActive(t),t.api.setSize({height:null==o?void 0:o.height,width:null==o?void 0:o.width}),i}if(s="string"==typeof e.position.referenceGroup?null===(t=this._groups.get(e.position.referenceGroup))||void 0===t?void 0:t.value:e.position.referenceGroup,n=e.position.index,!s)throw new Error(`dockview: referenceGroup '${e.position.referenceGroup}' does not exist`)}else s=this.activeGroup;if(s){const t=de((null===(i=e.position)||void 0===i?void 0:i.direction)||"within");if(e.floating){const t=this.createGroup();this._onDidAddGroup.fire(t);const i="object"==typeof e.floating&&null!==e.floating?e.floating:{};this.addFloatingGroup(t,Object.assign(Object.assign({},i),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),r=this.createPanel(e,t),t.model.openPanel(r,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:n})}else if("floating"===s.api.location.type||"edge"===s.api.location.type||"center"===t)r=this.createPanel(e,s),s.model.openPanel(r,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:n}),s.api.setSize({width:null==o?void 0:o.width,height:null==o?void 0:o.height}),e.inactive||this.doSetGroupAndPanelActive(s);else{const i=Q(s.element),a=ee(this.gridview.orientation,i,t),h=this.createGroupAtLocation(a,this.orientationAtLocation(a)===exports.Orientation.VERTICAL?null==o?void 0:o.height:null==o?void 0:o.width);r=this.createPanel(e,h),h.model.openPanel(r,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:n}),e.inactive||this.doSetGroupAndPanelActive(h)}}else if(e.floating){const t=this.createGroup();this._onDidAddGroup.fire(t);const i="object"==typeof e.floating&&null!==e.floating?e.floating:{};this.addFloatingGroup(t,Object.assign(Object.assign({},i),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),r=this.createPanel(e,t),t.model.openPanel(r,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:n})}else{const t=this.createGroupAtLocation([0],this.gridview.orientation===exports.Orientation.VERTICAL?null==o?void 0:o.height:null==o?void 0:o.width);r=this.createPanel(e,t),t.model.openPanel(r,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:n}),e.inactive||this.doSetGroupAndPanelActive(t)}return r}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 yt}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 ve(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(e){var t;if(e){let i;if(at(e)){const t="string"==typeof e.referencePanel?this.panels.find(t=>t.id===e.referencePanel):e.referencePanel;if(!t)throw new Error(`dockview: reference panel ${e.referencePanel} does not exist`);if(i=this.findGroup(t),!i)throw new Error(`dockview: reference group for reference panel ${e.referencePanel} does not exist`)}else{if(!ht(e)){const t=this.orthogonalize(be(e.direction),e);return e.skipSetActive||this.doSetGroupAndPanelActive(t),t}if(i="string"==typeof e.referenceGroup?null===(t=this._groups.get(e.referenceGroup))||void 0===t?void 0:t.value:e.referenceGroup,!i)throw new Error(`dockview: reference group ${e.referenceGroup} does not exist`)}const s=de(e.direction||"within"),o=Q(i.element),n=ee(this.gridview.orientation,o,s),r=this.createGroup(e),a=this.getLocationOrientation(n)===exports.Orientation.VERTICAL?e.initialHeight:e.initialWidth;return this.doAddGroup(r,n,a),e.skipSetActive||this.doSetGroupAndPanelActive(r),r}{const t=this.createGroup(e);return this.doAddGroup(t),this.doSetGroupAndPanelActive(t),t}}getLocationOrientation(e){return e.length%2==0&&this.gridview.orientation===exports.Orientation.HORIZONTAL?exports.Orientation.HORIZONTAL:exports.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)),k(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)}k(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=Q(i.element),t=ee(this.gridview.orientation,e,n);if(a.size<2){const[e,s]=T(t);if("grid"===a.api.location.type){const t=Q(a.element),[i,n]=T(t);if(E(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),i=this.movingLock(()=>e.popoutGroup.model.removePanel(e.popoutGroup.panels[0],{skipSetActive:!0,skipSetActiveGroup:!0}));this.doRemoveGroup(a,{skipActive:!0});const s=this.createGroupAtLocation(t);return this.movingLock(()=>s.model.openPanel(i,{skipSetActive:!0})),this.doSetGroupAndPanelActive(s),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=Q(i.element),l=ee(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=ee(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?Q(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=ee(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(e){const t=e.from.group,i=e.to.group,s=e.to.position;let o=t;if("center"===s){const s=t.activePanel,o=t.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),n=this.movingLock(()=>[...t.panels].map(e=>t.model.removePanel(e.id,{skipSetActive:!0})));0===(null==t?void 0:t.model.size)&&this.doRemoveGroup(t,{skipActive:!0}),this.movingLock(()=>{for(const e of n)i.model.openPanel(e,{skipSetActive:e!==s,skipSetGroupActive:!0})});for(const e of o){const t=i.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(const s of e.panelIds)i.model.addPanelToTabGroup(t.id,s)}!0!==e.skipSetActive?this.doSetGroupAndPanelActive(i):this.activePanel||this.doSetGroupAndPanelActive(i)}else{if("edge"===t.api.location.type){const e=t.activePanel,i=t.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),s=this.movingLock(()=>[...t.panels].map(e=>t.model.removePanel(e.id,{skipSetActive:!0})));o=this.createGroup(),this.movingLock(()=>{for(const t of s)o.model.openPanel(t,{skipSetActive:t!==e,skipSetGroupActive:!0})});for(const e of i){const t=o.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(const i of e.panelIds)o.model.addPanelToTabGroup(t.id,i)}}else switch(t.api.location.type){case"grid":this.gridview.removeView(Q(t.element));break;case"floating":{const e=this._floatingGroups.find(e=>e.group===t);if(!e)throw new Error("dockview: failed to find floating group");e.dispose();break}case"popout":{const e=this._popoutGroups.find(e=>e.popoutGroup===t);if(!e)throw new Error("dockview: failed to find popout group");const s=this._popoutGroups.indexOf(e);if(s>=0&&this._popoutGroups.splice(s,1),e.referenceGroup){const t=this.getPanel(e.referenceGroup);t&&!t.api.isVisible&&this.doRemoveGroup(t,{skipActive:!0})}e.window.dispose(),"grid"===i.api.location.type?(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,t.model.location={type:"grid"}):"floating"===i.api.location.type&&(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,t.model.location={type:"floating"});break}}if("grid"===i.api.location.type){const e=Q(i.element),n=ee(this.gridview.orientation,e,s);let r;switch(this.gridview.orientation){case exports.Orientation.VERTICAL:r=e.length%2==0?t.api.width:t.api.height;break;case exports.Orientation.HORIZONTAL:r=e.length%2==0?t.api.height:t.api.width}this.gridview.addView(o,r,n)}else if("floating"===i.api.location.type){const e=this._floatingGroups.find(e=>e.group===i);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(o,{height:t.height,width:t.width,position:{left:i,top:s}})}}}if(o.panels.forEach(e=>{this._onDidMovePanel.fire({panel:e,from:t})}),this.debouncedUpdateAllPositions(),!1===e.skipSetActive){const e=null!=i?i:t;this.doSetGroupAndPanelActive(e)}else o!==t&&!0!==e.skipSetActive&&this.doSetGroupAndPanelActive(o)}doSetGroupActive(e){super.doSetGroupActive(e);const t=this.activePanel;this._moving||t===this._onDidActivePanelChange.value||this._onDidActivePanelChange.fire(t)}doSetGroupAndPanelActive(e){super.doSetGroupActive(e);const t=this.activePanel;e&&this.hasMaximizedGroup()&&!this.isMaximizedGroup(e)&&this.exitMaximizedGroup(),this._moving||t===this._onDidActivePanelChange.value||this._onDidActivePanelChange.fire(t)}getNextGroupId(){let e=this.nextGroupId.next();for(;this._groups.has(e);)e=this.nextGroupId.next();return e}createGroup(e){e||(e={});let t=null==e?void 0:e.id;if(t&&this._groups.has(e.id)&&(console.warn(`dockview: Duplicate group id ${null==e?void 0:e.id}. reassigning group id to avoid errors`),t=void 0),!t)for(t=this.nextGroupId.next();this._groups.has(t);)t=this.nextGroupId.next();const i=new _t(this,t,e);if(i.init({params:{},accessor:this}),!this._groups.has(i.id)){const e=new m(i.model.onTabDragStart(e=>{this._onWillDragPanel.fire(e)}),i.model.onGroupDragStart(e=>{this._onWillDragGroup.fire(e)}),i.model.onMove(e=>{const{groupId:t,itemId:s,target:o,index:n,tabGroupId:r}=e;this.moveGroupOrPanel({from:{groupId:t,panelId:s,tabGroupId:r},to:{group:i,position:o,index:n}})}),i.model.onDidDrop(e=>{this._onDidDrop.fire(e)}),i.model.onWillDrop(e=>{this._onWillDrop.fire(e)}),i.model.onWillShowOverlay(e=>{this.options.disableDnd?e.preventDefault():this._onWillShowOverlay.fire(e)}),i.model.onUnhandledDragOverEvent(e=>{this._onUnhandledDragOverEvent.fire(e)}),i.model.onDidAddPanel(e=>{this._moving||this._onDidAddPanel.fire(e.panel)}),i.model.onDidRemovePanel(e=>{this._moving||this._onDidRemovePanel.fire(e.panel)}),i.model.onDidActivePanelChange(e=>{this._moving||e.panel===this.activePanel&&this._onDidActivePanelChange.value!==e.panel&&this._onDidActivePanelChange.fire(e.panel)}),i.model.onDidCreateTabGroup(e=>{this._onDidCreateTabGroup.fire(e)}),i.model.onDidDestroyTabGroup(e=>{this._onDidDestroyTabGroup.fire(e)}),i.model.onDidAddPanelToTabGroup(e=>{this._onDidAddPanelToTabGroup.fire(e)}),i.model.onDidRemovePanelFromTabGroup(e=>{this._onDidRemovePanelFromTabGroup.fire(e)}),i.model.onDidTabGroupChange(e=>{this._onDidTabGroupChange.fire(e)}),i.model.onDidTabGroupCollapsedChange(e=>{this._onDidTabGroupCollapsedChange.fire(e)}),exports.DockviewEvent.any(i.model.onDidPanelTitleChange,i.model.onDidPanelParametersChange)(()=>{this._bufferOnDidLayoutChange.fire()}));this._groups.set(i.id,{value:i,disposable:e})}return i.initialize(),i}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 Ct(this,e.id,n,r),h=new wt(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:se(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(Qt)),"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:ft;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");w(this.element,"dv-tab-group-indicator-none",d),this._shellManager&&w(this._shellManager.element,"dv-tab-group-indicator-none",d);for(const e of this.groups)e.model.updateTabGroups()}}class ii extends pe{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 d,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidRemoveGroup=new d,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new d,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new d,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(Q(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=de(t.direction);if("center"===r)throw new Error(`${r} not supported as an option`);{const e=Q(n.element);s=ee(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=de(e.position.direction);if("center"===i)throw new Error(`${i} not supported as an option`);{const e=Q(t.element);n=ee(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 m(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=Q(e.element),n=ee(this.gridview.orientation,o,i),[r,a]=T(n),h=Q(s.element),[l,d]=T(h);if(E(l,r))return void this.gridview.moveView(l,d,a);const p=this.doRemoveGroup(s,{skipActive:!0,skipDispose:!0}),u=Q(e.element),c=ee(this.gridview.orientation,u,i);this.doAddGroup(p,c)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}}class si 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 m(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===exports.Orientation.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===exports.Orientation.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._splitviewChangeDisposable=new v,this._panels=new Map,this._onDidLayoutfromJSON=new d,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new d,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new d,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new d,this.onDidLayoutChange=this._onDidLayoutChange.event,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new A(this.element),this._classNames.setClassNames(null!==(i=t.className)&&void 0!==i?i:""),e.appendChild(this.element),this._options=t,this.splitview=new $(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(e){var t;if(this._panels.has(e.id))throw new Error(`panel ${e.id} already exists`);const i=this.options.createComponent({id:e.id,name:e.component});i.orientation=this.splitview.orientation,i.init({params:null!==(t=e.params)&&void 0!==t?t:{},minimumSize:e.minimumSize,maximumSize:e.maximumSize,snap:e.snap,priority:e.priority,accessor:this});const s="number"==typeof e.size?e.size:exports.Sizing.Distribute,o="number"==typeof e.index?e.index:void 0;return this.splitview.addView(i,s,o),this.doAddView(i),this.setActive(i),i}layout(e,t){const[i,s]=this.splitview.orientation===exports.Orientation.HORIZONTAL?[e,t]:[t,e];this.splitview.layout(i,s)}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 $(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,exports.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 oi extends m{get element(){return this._element}constructor(){super(),this._expandedIcon=et({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=tt(),this.disposable=new v,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(p(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);w(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 ni=L(),ri=Number.MAX_SAFE_INTEGER;class ai extends Ee{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 hi extends he{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new m(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===exports.Orientation.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===exports.Orientation.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._id=ni.next(),this._disposable=new v,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new d,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new d,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new d,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new d,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new d,this.onDidRemoveView=this._onDidRemoveView.event,this._onUnhandledDragOverEvent=new d,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 A(this.element),this._classNames.setClassNames(null!==(i=t.className)&&void 0!==i?i:""),e.appendChild(this.element),this._options=t,this.paneview=new J(this.element,{orientation:exports.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(e){var t,i;const s=this.options.createComponent({id:e.id,name:e.component});let o;e.headerComponent&&this.options.createHeaderComponent&&(o=this.options.createHeaderComponent({id:e.id,name:e.headerComponent})),o||(o=new oi);const n=new ai({id:e.id,component:e.component,headerComponent:e.headerComponent,header:o,body:s,orientation:exports.Orientation.VERTICAL,isExpanded:!!e.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:null!==(t=e.headerSize)&&void 0!==t?t:22,minimumBodySize:0,maximumBodySize:ri});this.doAddPanel(n);const r="number"==typeof e.size?e.size:exports.Sizing.Distribute,a="number"==typeof e.index?e.index:void 0;return n.init({params:null!==(i=e.params)&&void 0!==i?i:{},minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize,isExpanded:e.isExpanded,title:e.title,containerApi:new ce(this),accessor:this}),this.paneview.addPane(n,r,a),n.orientation=this.paneview.orientation,n}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(e,t){const[i,s]=this.paneview.orientation===exports.Orientation.HORIZONTAL?[e,t]:[t,e];this.paneview.layout(i,s)}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(e){this.clear();const{views:t,size:i}=e,s=[],o=this.width,n=this.height;this.paneview=new J(this.element,{orientation:exports.Orientation.VERTICAL,descriptor:{size:i,views:t.map(e=>{var t,i,o;const n=e.data,r=this.options.createComponent({id:n.id,name:n.component});let a;n.headerComponent&&this.options.createHeaderComponent&&(a=this.options.createHeaderComponent({id:n.id,name:n.headerComponent})),a||(a=new oi);const h=new ai({id:n.id,component:n.component,headerComponent:n.headerComponent,header:a,body:r,orientation:exports.Orientation.VERTICAL,isExpanded:!!e.expanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:null!==(t=e.headerSize)&&void 0!==t?t:22,minimumBodySize:null!==(i=e.minimumSize)&&void 0!==i?i:0,maximumBodySize:null!==(o=e.maximumSize)&&void 0!==o?o:ri});return this.doAddPanel(h),s.push(()=>{var t;h.init({params:null!==(t=n.params)&&void 0!==t?t:{},minimumBodySize:e.minimumSize,maximumBodySize:e.maximumSize,title:n.title,isExpanded:!!e.expanded,containerApi:new ce(this),accessor:this}),h.orientation=this.paneview.orientation}),setTimeout(()=>{this._onDidAddView.fire(h)},0),{size:e.size,view:h}})}}),this.layout(o,n),s.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 m(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()}}exports.BaseGrid=pe,exports.ContentContainer=Oe,exports.DEFAULT_TAB_GROUP_COLORS=He,exports.DefaultDockviewDeserialzier=xt,exports.DefaultTab=Dt,exports.DockviewApi=ve,exports.DockviewComponent=ti,exports.DockviewCompositeDisposable=m,exports.DockviewDidDropEvent=dt,exports.DockviewEmitter=d,exports.DockviewGroupPanel=_t,exports.DockviewGroupPanelModel=ut,exports.DockviewMutableDisposable=v,exports.DockviewPanel=wt,exports.DockviewUnhandledDragOverEvent=st,exports.DockviewWillDropEvent=pt,exports.DockviewWillShowOverlayLocationEvent=Le,exports.DraggablePaneviewPanel=Ee,exports.Gridview=re,exports.GridviewApi=me,exports.GridviewComponent=ii,exports.GridviewPanel=mt,exports.PROPERTY_KEYS_DOCKVIEW=ot,exports.PROPERTY_KEYS_GRIDVIEW=ae,exports.PROPERTY_KEYS_PANEVIEW=ye,exports.PROPERTY_KEYS_SPLITVIEW=U,exports.PaneFramework=ai,exports.PaneTransfer=i,exports.PanelTransfer=t,exports.Paneview=J,exports.PaneviewApi=ce,exports.PaneviewComponent=hi,exports.PaneviewPanel=Te,exports.PaneviewUnhandledDragOverEvent=Se,exports.Splitview=$,exports.SplitviewApi=ue,exports.SplitviewComponent=si,exports.SplitviewPanel=class extends Ie{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 Ae(e,t)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=Number.POSITIVE_INFINITY,this._minimumSize=0,this._maximumSize=Number.POSITIVE_INFINITY,this._snap=!1,this._onDidChange=new d,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(e,t){const[i,s]=this.orientation===exports.Orientation.HORIZONTAL?[e,t]:[t,e];super.layout(i,s)}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})}},exports.Tab=Me,exports.TabGroupColorPalette=Fe,exports.applyTabGroupAccent=Ue,exports.createDockview=function(e,t){return new ti(e,t).api},exports.createGridview=function(e,t){const i=new ii(e,t);return new me(i)},exports.createPaneview=function(e,t){const i=new hi(e,t);return new ce(i)},exports.createSplitview=function(e,t){const i=new si(e,t);return new ue(i)},exports.directionToPosition=be,exports.getDirectionOrientation=te,exports.getGridLocation=Q,exports.getLocationOrientation=ie,exports.getPaneData=n,exports.getPanelData=o,exports.getRelativeLocation=ee,exports.indexInParent=K,exports.isGridBranchNode=oe,exports.isGroupOptionsWithGroup=ht,exports.isGroupOptionsWithPanel=at,exports.isPanelOptionsWithGroup=rt,exports.isPanelOptionsWithPanel=nt,exports.orthogonal=se,exports.positionToDirection=we,exports.resolveTabGroupAccent=Je,exports.themeAbyss=ft,exports.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)"},exports.themeCatppuccinMocha={name:"catppuccinMocha",className:"dockview-theme-catppuccin-mocha",colorScheme:"dark"},exports.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)"},exports.themeDark={name:"dark",className:"dockview-theme-dark",colorScheme:"dark"},exports.themeDracula={name:"dracula",className:"dockview-theme-dracula",colorScheme:"dark"},exports.themeGithubDark={name:"githubDark",className:"dockview-theme-github-dark",colorScheme:"dark"},exports.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)"},exports.themeGithubLight={name:"githubLight",className:"dockview-theme-github-light",colorScheme:"light"},exports.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)"},exports.themeLight={name:"light",className:"dockview-theme-light",colorScheme:"light"},exports.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)"},exports.themeMonokai={name:"monokai",className:"dockview-theme-monokai",colorScheme:"dark"},exports.themeNord={name:"nord",className:"dockview-theme-nord",colorScheme:"dark"},exports.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)"},exports.themeSolarizedLight={name:"solarizedLight",className:"dockview-theme-solarized-light",colorScheme:"light"},exports.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)"},exports.themeVisualStudio={name:"visualStudio",className:"dockview-theme-vs",colorScheme:"dark",edgeGroupCollapsedSize:22},exports.toTarget=de;
|