dockview 1.9.0 → 1.9.2

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.
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.9.0
3
+ * @version 1.9.2
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
7
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).dockview={},e.React,e.ReactDOM)}(this,(function(e,t,i){"use strict";function n(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var n=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}var s,o=n(t),r=n(i);class a{}class h extends a{constructor(e,t,i){super(),this.viewId=e,this.groupId=t,this.panelId=i}}class d extends a{constructor(e,t){super(),this.viewId=e,this.paneId=t}}class l{constructor(){}static getInstance(){return l.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 p(){const e=l.getInstance();if(e.hasData(h.prototype))return e.getData(h.prototype)[0]}function m(){const e=l.getInstance();if(e.hasData(d.prototype))return e.getData(d.prototype)[0]}l.INSTANCE=new l,e.DockviewEvent=void 0,(e.DockviewEvent||(e.DockviewEvent={})).any=(...e)=>t=>{const i=e.map((e=>e(t)));return{dispose:()=>{i.forEach((e=>{e.dispose()}))}}};class u{static create(){var e;return new u(null!==(e=(new Error).stack)&&void 0!==e?e:"")}constructor(e){this.value=e}print(){console.warn(this.value)}}class c{constructor(e,t){this.callback=e,this.stacktrace=t}}class v{static setLeakageMonitorEnabled(e){e!==v.ENABLE_TRACKING&&v.MEMORY_LEAK_WATCHER.clear(),v.ENABLE_TRACKING=e}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 c(e,v.ENABLE_TRACKING?u.create():void 0);return this._listeners.push(i),{dispose:()=>{const e=this._listeners.indexOf(i);e>-1?this._listeners.splice(e,1):v.ENABLE_TRACKING}}},v.ENABLE_TRACKING&&v.MEMORY_LEAK_WATCHER.add(this._event,u.create())),this._event}fire(e){this._last=e;for(const t of this._listeners)t.callback(e)}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&(v.ENABLE_TRACKING&&queueMicrotask((()=>{var e;for(const t of this._listeners)console.warn(null===(e=t.stacktrace)||void 0===e?void 0:e.print())})),this._listeners=[]),v.ENABLE_TRACKING&&this._event&&v.MEMORY_LEAK_WATCHER.delete(this._event))}}function g(e,t,i,n){return e.addEventListener(t,i,n),{dispose:()=>{e.removeEventListener(t,i,n)}}}function w(e,t,i,n){return e.addEventListener(t,i,n),{dispose:()=>{e.removeEventListener(t,i,n)}}}v.ENABLE_TRACKING=!1,v.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 f{constructor(){this._onFired=new v,this.onEvent=this._onFired.event}fire(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout((()=>{this._onFired.fire(),clearTimeout(this.timer)}))}dispose(){this._onFired.dispose()}}!function(e){e.NONE={dispose:()=>{}},e.from=function(e){return{dispose:()=>{e()}}}}(s||(s={}));class _{get isDisposed(){return this._isDisposed}constructor(...e){this._isDisposed=!1,this._disposables=e}addDisposables(...e){e.forEach((e=>this._disposables.push(e)))}dispose(){this._disposables.forEach((e=>e.dispose())),this._isDisposed=!0}}class D{constructor(){this._disposable=s.NONE}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&(this._disposable.dispose(),this._disposable=s.NONE)}}function b(e,t,i={},n={},s,o){const r="string"==typeof t?i[t]:void 0,a="string"==typeof t?n[t]:void 0;if(r&&a)throw new Error(`Cannot create '${e}'. component '${t}' registered as both a component and frameworkComponent`);if(a){if(!s)throw new Error(`Cannot create '${e}' for framework component '${t}'. you must register a frameworkPanelWrapper to use framework components`);return s.createComponent(e,t,a)}if(!r){if(o)return o();throw new Error(`Cannot create '${e}', no component '${t}' provided`)}return new r(e,t)}function C(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 y=(e,...t)=>{for(const i of t)e.classList.contains(i)&&e.classList.remove(i)},S=(e,...t)=>{for(const i of t)e.classList.contains(i)||e.classList.add(i)},z=(e,t,i)=>{const n=e.classList.contains(t);i&&!n&&e.classList.add(t),!i&&n&&e.classList.remove(t)};function x(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function E(e){return Array.prototype.slice.call(document.getElementsByTagName(e),0)}function A(e){return new P(e)}class P extends _{constructor(e){super(),this._onDidFocus=new v,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new v,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=x(document.activeElement,e),i=!1;const n=()=>{i=!1,t||(t=!0,this._onDidFocus.fire())},s=()=>{t&&(i=!0,window.setTimeout((()=>{i&&(i=!1,t=!1,this._onDidBlur.fire())}),0))};this._refreshStateHandler=()=>{x(document.activeElement,e)!==t&&(t?s():n())},e instanceof HTMLElement?(this.addDisposables(w(e,"focus",n,!0)),this.addDisposables(w(e,"blur",s,!0))):(this.addDisposables(g(e,"focus",n,!0)),this.addDisposables(g(e,"blur",s,!0)))}refreshState(){this._refreshStateHandler()}}const I="dv-quasiPreventDefault";function O(e){return e[I]}function G(e){const{left:t,top:i,width:n,height:s}=e.getBoundingClientRect();return{left:t+window.scrollX,top:i+window.scrollY,width:n,height:s}}function N(e){if(0===e.length)throw new Error("Invalid tail call");return[e.slice(0,e.length-1),e[e.length-1]]}function V(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 L(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.unshift(t))}function k(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.push(t))}function R(e,t){const i=e.findIndex((e=>e===t));return i>-1&&(e.splice(i,1),!0)}const T=(e,t,i)=>{if(t>i)throw new Error(`${t} > ${i} is an invalid condition`);return Math.min(i,Math.max(e,t))},M=()=>{let e=1;return{next:()=>(e++).toString()}},H=(e,t)=>{const i=[];if("number"!=typeof t&&(t=e,e=0),e<=t)for(let n=e;n<t;n++)i.push(n);else for(let n=e;n>t;n--)i.push(n);return i};class W{set size(e){this._size=e}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return void 0===this._cachedVisibleSize}get minimumSize(){return this.visible?this.view.minimumSize:0}get viewMinimumSize(){return this.view.minimumSize}get maximumSize(){return this.visible?this.view.maximumSize:0}get viewMaximumSize(){return this.view.maximumSize}get priority(){return this.view.priority}get snap(){return!!this.view.snap}set enabled(e){this.container.style.pointerEvents=e?"":"none"}constructor(e,t,i,n){this.container=e,this.view=t,this.disposable=n,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=T(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 F,B,J,j;e.Orientation=void 0,(F=e.Orientation||(e.Orientation={})).HORIZONTAL="HORIZONTAL",F.VERTICAL="VERTICAL",e.SashState=void 0,(B=e.SashState||(e.SashState={}))[B.MAXIMUM=0]="MAXIMUM",B[B.MINIMUM=1]="MINIMUM",B[B.DISABLED=2]="DISABLED",B[B.ENABLED=3]="ENABLED",e.LayoutPriority=void 0,(J=e.LayoutPriority||(e.LayoutPriority={})).Low="low",J.High="high",J.Normal="normal",e.Sizing=void 0,(j=e.Sizing||(e.Sizing={})).Distribute={type:"distribute"},j.Split=function(e){return{type:"split",index:e}},j.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(t){this._orientation=t;const i=this.size;this.size=this.orthogonalSize,this.orthogonalSize=i,y(this.element,"horizontal","vertical"),this.element.classList.add(this.orientation==e.Orientation.HORIZONTAL?"horizontal":"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())}constructor(e,t){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._onDidSashEnd=new v,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new v,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new v,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(e,t,i=this.viewItems.map((e=>e.size)),n,s,o=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY,a,h)=>{if(e<0||e>this.viewItems.length)return 0;const d=H(e,-1),l=H(e+1,this.viewItems.length);if(s)for(const e of s)L(d,e),L(l,e);if(n)for(const e of n)k(d,e),k(l,e);const p=d.map((e=>this.viewItems[e])),m=d.map((e=>i[e])),u=l.map((e=>this.viewItems[e])),c=l.map((e=>i[e])),v=d.reduce(((e,t)=>e+this.viewItems[t].minimumSize-i[t]),0),g=d.reduce(((e,t)=>e+this.viewItems[t].maximumSize-i[t]),0),w=0===l.length?Number.POSITIVE_INFINITY:l.reduce(((e,t)=>e+i[t]-this.viewItems[t].minimumSize),0),f=0===l.length?Number.NEGATIVE_INFINITY:l.reduce(((e,t)=>e+i[t]-this.viewItems[t].maximumSize),0),_=Math.max(v,f),D=Math.min(w,g);let b=!1;if(a){const e=this.viewItems[a.index],i=t>=a.limitDelta;b=i!==e.visible,e.setVisible(i,a.size)}if(!b&&h){const e=this.viewItems[h.index],i=t<h.limitDelta;b=i!==e.visible,e.setVisible(i,h.size)}if(b)return this.resize(e,t,i,n,s,o,r);let C=0,y=T(t,_,D);for(let e=0;e<p.length;e++){const t=p[e],i=T(m[e]+y,t.minimumSize,t.maximumSize),n=i-m[e];C+=n,y-=n,t.size=i}let S=C;for(let e=0;e<u.length;e++){const t=u[e],i=T(c[e]-S,t.minimumSize,t.maximumSize);S+=i-c[e],t.size=i}return t},this._orientation=t.orientation,this.element=this.createContainer(),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},n=e.view;this.addView(n,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)?(y(this.element,"separator-border"),this.element.style.removeProperty("--dv-separator-border")):(S(this.element,"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");z(this.container,"visible",t);const i=this.viewItems[e];z(this.container,"visible",t),i.setVisible(t,i.size),this.distributeEmptySpace(e),this.layoutViews(),this.saveProportions()}getViewSize(e){return e<0||e>=this.viewItems.length?-1:this.viewItems[e].size}resizeView(t,i){if(t<0||t>=this.viewItems.length)return;const n=H(this.viewItems.length).filter((e=>e!==t)),s=[...n.filter((t=>this.viewItems[t].priority===e.LayoutPriority.Low)),t],o=n.filter((t=>this.viewItems[t].priority===e.LayoutPriority.High)),r=this.viewItems[t];i=Math.round(i),i=T(i,r.minimumSize,Math.min(r.maximumSize,this._size)),r.size=i,this.relayout(s,o)}getViews(){return this.viewItems.map((e=>e.view))}onDidChange(t,i){const n=this.viewItems.indexOf(t);if(n<0||n>=this.viewItems.length)return;i="number"==typeof i?i:t.size,i=T(i,t.minimumSize,t.maximumSize),t.size=i;const s=H(this.viewItems.length).filter((e=>e!==n)),o=[...s.filter((t=>this.viewItems[t].priority===e.LayoutPriority.Low)),n],r=s.filter((t=>this.viewItems[t].priority===e.LayoutPriority.High));this.relayout([...o,n],r)}addView(t,i={type:"distribute"},n=this.viewItems.length,s){const o=document.createElement("div");let r;o.className="view",o.appendChild(t.element),r="number"==typeof i?i:"split"===i.type?this.getViewSize(i.index)/2:"invisible"===i.type?{cachedVisibleSize:i.cachedVisibleSize}:t.minimumSize;const a=t.onDidChange((e=>this.onDidChange(h,e.size))),h=new W(o,t,r,{dispose:()=>{a.dispose(),this.viewContainer.removeChild(o)}});if(n===this.viewItems.length?this.viewContainer.appendChild(o):this.viewContainer.insertBefore(o,this.viewContainer.children.item(n)),this.viewItems.splice(n,0,h),this.viewItems.length>1){const t=document.createElement("div");t.className="sash";const i=i=>{for(const e of this.viewItems)e.enabled=!1;const n=[...E("iframe"),...E("webview")];for(const e of n)e.style.pointerEvents="none";const s=this._orientation===e.Orientation.HORIZONTAL?i.clientX:i.clientY,o=function(e,t){for(let i=0;i<e.length;i++)if(t(e[i]))return i;return-1}(this.sashes,(e=>e.container===t)),r=this.viewItems.map((e=>e.size));let a,h;const d=H(o,-1),l=H(o+1,this.viewItems.length),p=d.reduce(((e,t)=>e+(this.viewItems[t].minimumSize-r[t])),0),m=d.reduce(((e,t)=>e+(this.viewItems[t].viewMaximumSize-r[t])),0),u=0===l.length?Number.POSITIVE_INFINITY:l.reduce(((e,t)=>e+(r[t]-this.viewItems[t].minimumSize)),0),c=0===l.length?Number.NEGATIVE_INFINITY:l.reduce(((e,t)=>e+(r[t]-this.viewItems[t].viewMaximumSize)),0),v=Math.max(p,c),g=Math.min(u,m),w=this.findFirstSnapIndex(d),f=this.findFirstSnapIndex(l);if("number"==typeof w){const e=this.viewItems[w],t=Math.floor(e.viewMinimumSize/2);a={index:w,limitDelta:e.visible?v-t:v+t,size:e.size}}if("number"==typeof f){const e=this.viewItems[f],t=Math.floor(e.viewMinimumSize/2);h={index:f,limitDelta:e.visible?g+t:g-t,size:e.size}}const _=t=>{const i=(this._orientation===e.Orientation.HORIZONTAL?t.clientX:t.clientY)-s;this.resize(o,i,r,void 0,void 0,v,g,a,h),this.distributeEmptySpace(),this.layoutViews()},D=()=>{for(const e of this.viewItems)e.enabled=!0;for(const e of n)e.style.pointerEvents="auto";this.saveProportions(),document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",D),document.removeEventListener("pointercancel",D),this._onDidSashEnd.fire(void 0)};document.addEventListener("pointermove",_),document.addEventListener("pointerup",D),document.addEventListener("pointercancel",D)};t.addEventListener("pointerdown",i);const n={container:t,disposable:()=>{t.removeEventListener("pointerdown",i),this.sashContainer.removeChild(t)}};this.sashContainer.appendChild(t),this.sashes.push(n)}s||this.relayout([n]),s||"number"==typeof i||"distribute"!==i.type||this.distributeViewSizes(),this._onDidAddView.fire(t)}distributeViewSizes(){const t=[];let i=0;for(const e of this.viewItems)e.maximumSize-e.minimumSize>0&&(t.push(e),i+=e.size);const n=Math.floor(i/t.length);for(const e of t)e.size=T(n,e.minimumSize,e.maximumSize);const s=H(this.viewItems.length),o=s.filter((t=>this.viewItems[t].priority===e.LayoutPriority.Low)),r=s.filter((t=>this.viewItems[t].priority===e.LayoutPriority.High));this.relayout(o,r)}removeView(e,t,i=!1){const n=this.viewItems.splice(e,1)[0];if(n.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(n.view),n.view}getViewCachedVisibleSize(e){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");return this.viewItems[e].cachedVisibleSize}moveView(t,i){const n=this.getViewCachedVisibleSize(t),s=void 0===n?this.getViewSize(t):e.Sizing.Invisible(n),o=this.removeView(t,void 0,!0);this.addView(o,s,i)}layout(t,i){const n=Math.max(this.size,this._contentSize);if(this.size=t,this.orthogonalSize=i,this.proportions){let e=0;for(let i=0;i<this.viewItems.length;i++){const n=this.viewItems[i],s=this.proportions[i];"number"==typeof s?e+=s:t-=n.size}for(let i=0;i<this.viewItems.length;i++){const n=this.viewItems[i],s=this.proportions[i];"number"==typeof s&&e>0&&(n.size=T(Math.round(s*t/e),n.minimumSize,n.maximumSize))}}else{const i=H(this.viewItems.length),s=i.filter((t=>this.viewItems[t].priority===e.LayoutPriority.Low)),o=i.filter((t=>this.viewItems[t].priority===e.LayoutPriority.High));this.resize(this.viewItems.length-1,t-n,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(t){const i=this.viewItems.reduce(((e,t)=>e+t.size),0);let n=this.size-i;const s=H(this.viewItems.length-1,-1),o=s.filter((t=>this.viewItems[t].priority===e.LayoutPriority.Low)),r=s.filter((t=>this.viewItems[t].priority===e.LayoutPriority.High));for(const e of r)L(s,e);for(const e of o)k(s,e);"number"==typeof t&&k(s,t);for(let e=0;0!==n&&e<s.length;e++){const t=this.viewItems[s[e]],i=T(t.size+n,t.minimumSize,t.maximumSize);n-=i-t.size,t.size=i}}saveProportions(){this.proportionalLayout&&this._contentSize>0&&(this._proportions=this.viewItems.map((e=>e.visible?e.size/this._contentSize:void 0)))}layoutViews(){this._contentSize=this.viewItems.reduce(((e,t)=>e+t.size),0);let t=0;const i=[];this.updateSashEnablement();for(let n=0;n<this.viewItems.length-1;n++){t+=this.viewItems[n].size,i.push(t);const s=Math.min(Math.max(0,t-2),this.size-4);this._orientation===e.Orientation.HORIZONTAL&&(this.sashes[n].container.style.left=`${s}px`,this.sashes[n].container.style.top="0px"),this._orientation===e.Orientation.VERTICAL&&(this.sashes[n].container.style.left="0px",this.sashes[n].container.style.top=`${s}px`)}this.viewItems.forEach(((t,n)=>{this._orientation===e.Orientation.HORIZONTAL&&(t.container.style.width=`${t.size}px`,t.container.style.left=0==n?"0px":`${i[n-1]}px`,t.container.style.top="",t.container.style.height=""),this._orientation===e.Orientation.VERTICAL&&(t.container.style.height=`${t.size}px`,t.container.style.top=0==n?"0px":`${i[n-1]}px`,t.container.style.width="",t.container.style.left=""),t.view.layout(t.size,this._orthogonalSize)}))}findFirstSnapIndex(e){for(const t of e){const e=this.viewItems[t];if(e.visible&&e.snap)return t}for(const t of e){const e=this.viewItems[t];if(e.visible&&e.maximumSize-e.minimumSize>0)return;if(!e.visible&&e.snap)return t}}updateSashEnablement(){let t=!1;const i=this.viewItems.map((e=>t=e.size-e.minimumSize>0||t));t=!1;const n=this.viewItems.map((e=>t=e.maximumSize-e.size>0||t)),s=[...this.viewItems].reverse();t=!1;const o=s.map((e=>t=e.size-e.minimumSize>0||t)).reverse();t=!1;const r=s.map((e=>t=e.maximumSize-e.size>0||t)).reverse();let a=0;for(let t=0;t<this.sashes.length;t++){const s=this.sashes[t];a+=this.viewItems[t].size;const h=!(i[t]&&r[t+1]),d=!(n[t]&&o[t+1]);if(h&&d){const n=H(t,-1),r=H(t+1,this.viewItems.length),h=this.findFirstSnapIndex(n),d=this.findFirstSnapIndex(r),l="number"==typeof h&&!this.viewItems[h].visible,p="number"==typeof d&&!this.viewItems[d].visible;l&&o[t]&&(a>0||this.startSnappingEnabled)?this.updateSash(s,e.SashState.MINIMUM):p&&i[t]&&(a<this._contentSize||this.endSnappingEnabled)?this.updateSash(s,e.SashState.MAXIMUM):this.updateSash(s,e.SashState.DISABLED)}else h&&!d?this.updateSash(s,e.SashState.MINIMUM):!h&&d?this.updateSash(s,e.SashState.MAXIMUM):this.updateSash(s,e.SashState.ENABLED)}}updateSash(t,i){z(t.container,"disabled",i===e.SashState.DISABLED),z(t.container,"enabled",i===e.SashState.ENABLED),z(t.container,"maximum",i===e.SashState.MAXIMUM),z(t.container,"minimum",i===e.SashState.MINIMUM)}createViewContainer(){const e=document.createElement("div");return e.className="view-container",e}createSashContainer(){const e=document.createElement("div");return e.className="sash-container",e}createContainer(){const t=document.createElement("div"),i=this._orientation===e.Orientation.HORIZONTAL?"horizontal":"vertical";return t.className=`split-view-container ${i}`,t}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.removeChild(this.element);break}for(const e of this.viewItems)e.dispose();this.element.remove()}}class Z extends _{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(t,i){var n;super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this._orientation=null!==(n=i.orientation)&&void 0!==n?n:e.Orientation.VERTICAL,this.element=document.createElement("div"),this.element.className="pane-container",t.appendChild(this.element),this.splitview=new $(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:i.descriptor}),this.getPanes().forEach((e=>{const t=new _(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()})))}addPane(e,t,i=this.splitview.length,n=!1){const s=e.onDidChangeExpansionState((()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),o={pane:e,disposable:{dispose:()=>{s.dispose()}}};this.paneItems.splice(i,0,o),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,i,n)}getViewSize(e){return this.splitview.getViewSize(e)}getPanes(){return this.splitview.getViews()}removePane(e,t={skipDispose:!1}){const i=this.paneItems.splice(e,1)[0];return this.splitview.removeView(e),t.skipDispose||(i.disposable.dispose(),i.pane.dispose()),i}moveView(e,t){if(e===t)return;const i=this.removePane(e,{skipDispose:!0});this.skipAnimation=!0;try{this.addPane(i.pane,i.pane.size,t,!1)}finally{this.skipAnimation=!1}}layout(e,t){this.splitview.layout(e,t)}setupAnimation(){this.skipAnimation||(this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=void 0),S(this.element,"animated"),this.animationTimer=setTimeout((()=>{this.animationTimer=void 0,y(this.element,"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 U{get minimumWidth(){return this.view.minimumWidth}get maximumWidth(){return this.view.maximumWidth}get minimumHeight(){return this.view.minimumHeight}get maximumHeight(){return this.view.maximumHeight}get priority(){return this.view.priority}get snap(){return this.view.snap}get minimumSize(){return this.orientation===e.Orientation.HORIZONTAL?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===e.Orientation.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumWidth:this.maximumHeight}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get element(){return this.view.element}get width(){return this.orientation===e.Orientation.HORIZONTAL?this.orthogonalSize:this.size}get height(){return this.orientation===e.Orientation.HORIZONTAL?this.size:this.orthogonalSize}constructor(t,i,n,s=0){this.view=t,this.orientation=i,this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this._orthogonalSize=n,this._size=s,this._disposable=this.view.onDidChange((t=>{t?this._onDidChange.fire({size:this.orientation===e.Orientation.VERTICAL?t.width:t.height,orthogonalSize:this.orientation===e.Orientation.VERTICAL?t.height:t.width}):this._onDidChange.fire({})}))}setVisible(e){this.view.setVisible&&this.view.setVisible(e)}layout(e,t){this._size=e,this._orthogonalSize=t,this.view.layout(this.width,this.height)}dispose(){this._onDidChange.dispose(),this._disposable.dispose()}}class Y extends _{get width(){return this.orientation===e.Orientation.HORIZONTAL?this.size:this.orthogonalSize}get height(){return this.orientation===e.Orientation.HORIZONTAL?this.orthogonalSize:this.size}get minimumSize(){return 0===this.children.length?0:Math.max(...this.children.map(((e,t)=>this.splitview.isViewVisible(t)?e.minimumOrthogonalSize:0)))}get maximumSize(){return Math.min(...this.children.map(((e,t)=>this.splitview.isViewVisible(t)?e.maximumOrthogonalSize:Number.POSITIVE_INFINITY)))}get minimumOrthogonalSize(){return this.splitview.minimumSize}get maximumOrthogonalSize(){return this.splitview.maximumSize}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get minimumWidth(){return this.orientation===e.Orientation.HORIZONTAL?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===e.Orientation.HORIZONTAL?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumSize:this.maximumOrthogonalSize}get priority(){if(0===this.children.length)return e.LayoutPriority.Normal;const t=this.children.map((t=>void 0===t.priority?e.LayoutPriority.Normal:t.priority));return t.some((t=>t===e.LayoutPriority.High))?e.LayoutPriority.High:t.some((t=>t===e.LayoutPriority.Low))?e.LayoutPriority.Low:e.LayoutPriority.Normal}constructor(e,t,i,n,o,r){if(super(),this.orientation=e,this.proportionalLayout=t,this.styles=i,this._childrenDisposable=s.NONE,this.children=[],this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new v,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._orthogonalSize=o,this._size=n,this.element=document.createElement("div"),this.element.className="branch-node",r){const e={views:r.map((e=>({view:e.node,size:e.node.size,visible:!(e.node instanceof U&&void 0!==e.visible)||e.visible}))),size:this.orthogonalSize};this.children=r.map((e=>e.node)),this.splitview=new $(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:t,styles:i})}else this.splitview=new $(this.element,{orientation:this.orientation,proportionalLayout:t,styles:i}),this.splitview.layout(this.size,this.orthogonalSize);this.addDisposables(this._onDidChange,this._onDidVisibilityChange,this.splitview.onDidSashEnd((()=>{this._onDidChange.fire({})}))),this.setupChildrenEvents()}setVisible(e){for(const t of this.children)t.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 n=0===this.splitview.contentSize;(t&&i||!t&&n)&&this._onDidVisibilityChange.fire(t)}moveChild(e,t){if(e===t)return;if(e<0||e>=this.children.length)throw new Error("Invalid from index");e<t&&t--,this.splitview.moveView(e,t);const i=this._removeChild(e);this._addChild(i,t)}getChildSize(e){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewSize(e)}resizeChild(e,t){if(e<0||e>=this.children.length)throw new Error("Invalid index");this.splitview.resizeView(e,t)}layout(e,t){this._size=t,this._orthogonalSize=e,this.splitview.layout(t,e)}addChild(e,t,i,n){if(i<0||i>this.children.length)throw new Error("Invalid index");this.splitview.addView(e,t,i,n),this._addChild(e,i)}getChildCachedVisibleSize(e){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewCachedVisibleSize(e)}removeChild(e,t){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.removeView(e,t),this._removeChild(e)}_addChild(e,t){this.children.splice(t,0,e),this.setupChildrenEvents()}_removeChild(e){const[t]=this.children.splice(e,1);return this.setupChildrenEvents(),t}setupChildrenEvents(){this._childrenDisposable.dispose(),this._childrenDisposable=new _(e.DockviewEvent.any(...this.children.map((e=>e.onDidChange)))((e=>{this._onDidChange.fire({size:e.orthogonalSize})})),...this.children.map(((e,t)=>e instanceof Y?e.onDidVisibilityChange((e=>{this.setChildVisible(t,e)})):s.NONE)))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach((e=>e.dispose())),super.dispose()}}function X(e,t){if(e instanceof U)return e;if(e instanceof Y)return X(e.children[t?e.children.length-1:0],t);throw new Error("invalid node")}function K(e,t,i){if(e instanceof Y){const n=new Y(ne(e.orientation),e.proportionalLayout,e.styles,t,i);let s=0;for(let o=e.children.length-1;o>=0;o--){const r=e.children[o],a=r instanceof Y?r.orthogonalSize:r.size;let h=0===e.size?0:Math.round(t*a/e.size);s+=h,0===o&&(h+=t-s),n.addChild(K(r,i,h),h,0,!0)}return n}return new U(e.view,ne(e.orientation),i)}function q(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");let i=t.firstElementChild,n=0;for(;i!==e&&i!==t.lastElementChild&&i;)i=i.nextElementSibling,n++;return n}function Q(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");if(/\bgrid-view\b/.test(t.className))return[];const i=q(t);return[...Q(t.parentElement.parentElement.parentElement),i]}function ee(e,t,i){if(ie(e,t)===te(i)){const[e,n]=N(t);let s=n;return"right"!==i&&"bottom"!==i||(s+=1),[...e,s]}{const e="right"===i||"bottom"===i?1:0;return[...t,e]}}function te(t){return"top"===t||"bottom"===t?e.Orientation.VERTICAL:e.Orientation.HORIZONTAL}function ie(e,t){return t.length%2==0?ne(e):e}const ne=t=>t===e.Orientation.HORIZONTAL?e.Orientation.VERTICAL:e.Orientation.HORIZONTAL;function se(e){return!!e.children}const oe=(t,i)=>{const n=i===e.Orientation.VERTICAL?t.box.width:t.box.height;return se(t)?{type:"branch",data:t.children.map((e=>oe(e,ne(i)))),size:n}:"number"==typeof t.cachedVisibleSize?{type:"leaf",data:t.view.toJSON(),size:t.cachedVisibleSize,visible:!1}:{type:"leaf",data:t.view.toJSON(),size:n}};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=K(this.root,i,t),this.root.layout(t,i)}get width(){return this.root.width}get height(){return this.root.height}get minimumWidth(){return this.root.minimumWidth}get minimumHeight(){return this.root.minimumHeight}get maximumWidth(){return this.root.maximumHeight}get maximumHeight(){return this.root.maximumHeight}maximizedView(){var e;return null===(e=this._maximizedNode)||void 0===e?void 0:e.view}hasMaximizedView(){return void 0!==this._maximizedNode}maximizeView(e){const t=Q(e.element),[i,n]=this.getNode(t);n instanceof U&&this._maximizedNode!==n&&(this.hasMaximizedView()&&this.exitMaximizedView(),function e(t,i){for(let n=0;n<t.children.length;n++){const s=t.children[n];s instanceof U?s!==i&&t.setChildVisible(n,!1):e(s,i)}}(this.root,n),this._maximizedNode=n,this._onDidMaxmizedNodeChange.fire())}exitMaximizedView(){this._maximizedNode&&(!function e(t){for(let i=t.children.length-1;i>=0;i--){const n=t.children[i];n instanceof U?t.setChildVisible(i,!0):e(n)}}(this.root),this._maximizedNode=void 0,this._onDidMaxmizedNodeChange.fire())}serialize(){this.hasMaximizedView()&&this.exitMaximizedView();return{root:oe(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this._onDidMaxmizedNodeChange.dispose(),this.root.dispose(),this._maximizedNode=void 0,this.element.remove()}clear(){const e=this.root.orientation;this.root=new Y(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize)}deserialize(t,i){const n=t.orientation,s=n===e.Orientation.VERTICAL?t.height:t.width;this._deserialize(t.root,n,i,s)}_deserialize(e,t,i,n){this.root=this._deserializeNode(e,t,i,n)}_deserializeNode(e,t,i,n){let s;if("branch"===e.type){const o=e.data.map((n=>({node:this._deserializeNode(n,ne(t),i,e.size),visible:n.visible})));s=new Y(t,this.proportionalLayout,this.styles,e.size,n,o)}else s=new U(i.fromJSON(e),t,n,e.size);return s}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)}))}insertOrthogonalSplitviewAtRoot(){if(!this._root)return;const t=this.root;if(t.element.remove(),this._root=new Y(ne(t.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size),0===t.children.length);else if(1===t.children.length){const i=t.children[0];t.removeChild(0).dispose(),t.dispose(),this._root.addChild(K(i,i.orthogonalSize,i.size),e.Sizing.Distribute,0)}else this._root.addChild(t,e.Sizing.Distribute,0);this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange((e=>{this._onDidChange.fire(e)}))}next(e){return this.progmaticSelect(e)}previous(e){return this.progmaticSelect(e,!0)}getView(e){const t=e?this.getNode(e)[1]:this.root;return this._getViews(t,this.orientation)}_getViews(e,t,i){const n={height:e.height,width:e.width};if(e instanceof U)return{box:n,view:e.view,cachedVisibleSize:i};const s=[];for(let i=0;i<e.children.length;i++){const n=e.children[i],o=e.getChildCachedVisibleSize(i);s.push(this._getViews(n,ne(t),o))}return{box:n,children:s}}progmaticSelect(e,t=!1){const[i,n]=this.getNode(e);if(!(n instanceof U))throw new Error("invalid location");for(let n=i.length-1;n>-1;n--){const s=i[n],o=e[n]||0;if(t?o-1>-1:o+1<s.children.length)return X(s.children[t?o-1:o+1],t)}return X(this.root,t)}constructor(e,t,i){this.proportionalLayout=e,this.styles=t,this._maximizedNode=void 0,this.disposable=new D,this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this._onDidMaxmizedNodeChange=new v,this.onDidMaxmizedNodeChange=this._onDidMaxmizedNodeChange.event,this.element=document.createElement("div"),this.element.className="grid-view",this.root=new Y(i,e,t,0,0)}isViewVisible(e){const[t,i]=N(e),[,n]=this.getNode(t);if(!(n instanceof Y))throw new Error("Invalid from location");return n.isChildVisible(i)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,n]=N(e),[,s]=this.getNode(i);if(!(s instanceof Y))throw new Error("Invalid from location");s.setChildVisible(n,t)}moveView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[,n]=this.getNode(e);if(!(n instanceof Y))throw new Error("Invalid location");n.moveChild(t,i)}addView(t,i,n){this.hasMaximizedView()&&this.exitMaximizedView();const[s,o]=N(n),[r,a]=this.getNode(s);if(a instanceof Y){const e=new U(t,ne(a.orientation),a.orthogonalSize);a.addChild(e,i,o)}else{const[n,...h]=[...r].reverse(),[d,...l]=[...s].reverse();let p=0;const m=n.getChildCachedVisibleSize(d);"number"==typeof m&&(p=e.Sizing.Invisible(m));n.removeChild(d).dispose();const u=new Y(a.orientation,this.proportionalLayout,this.styles,a.size,a.orthogonalSize);n.addChild(u,a.size,d);const c=new U(a.view,n.orientation,a.size);u.addChild(c,p,0),"number"!=typeof i&&"split"===i.type&&(i={type:"split",index:0});const v=new U(t,n.orientation,a.size);u.addChild(v,i,o)}}remove(e,t){const i=Q(e.element);return this.removeView(i,t)}removeView(t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[n,s]=N(t),[o,r]=this.getNode(n);if(!(r instanceof Y))throw new Error("Invalid location");const a=r.children[s];if(!(a instanceof U))throw new Error("Invalid location");if(r.removeChild(s,i),a.dispose(),1!==r.children.length)return a.view;const h=r.children[0];if(0===o.length)return h instanceof U||(r.removeChild(0,i),this.root=h),a.view;const[d,...l]=[...o].reverse(),[p,...m]=[...n].reverse(),u=r.isChildVisible(0);r.removeChild(0,i);const c=d.children.map(((e,t)=>d.getChildSize(t)));if(d.removeChild(p,i).dispose(),h instanceof Y){c.splice(p,1,...h.children.map((e=>e.size)));for(let e=0;e<h.children.length;e++){const t=h.children[e];d.addChild(t,t.size,p+e)}for(;h.children.length>0;)h.removeChild(0)}else{const t=new U(h.view,ne(h.orientation),h.size),i=u?h.orthogonalSize:e.Sizing.Invisible(h.orthogonalSize);d.addChild(t,i,p)}h.dispose();for(let e=0;e<c.length;e++)d.resizeChild(e,c[e]);return a.view}layout(t,i){const[n,s]=this.root.orientation===e.Orientation.HORIZONTAL?[i,t]:[t,i];this.root.layout(n,s)}getNode(e,t=this.root,i=[]){if(0===e.length)return[i,t];if(!(t instanceof Y))throw new Error("Invalid location");const[n,...s]=e;if(n<0||n>=t.children.length)throw new Error("Invalid location");const o=t.children[n];return i.push(t),this.getNode(s,o,i)}}class ae{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}updateOptions(e){this.component.updateOptions(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()}}class he{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(){const e=new v,t=this.component.onDidDrop((t=>{e.fire(Object.assign(Object.assign({},t),{api:this}))}));return e.dispose=()=>{t.dispose(),e.dispose()},e.event}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()}}class de{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()}}class le{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 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 onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidDrop(){return this.component.onDidDrop}get onWillDragGroup(){return this.component.onWillDragGroup}get onWillDragPanel(){return this.component.onWillDragPanel}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){this.component.fromJSON(e)}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()}exitMaxmizedGroup(){this.component.exitMaximizedGroup()}get onDidMaxmizedGroupChange(){return this.component.onDidMaxmizedGroupChange}addPopoutGroup(e,t){this.component.addPopoutGroup(e,t)}}class pe extends _{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(w(this.element,"dragenter",(e=>{this.onDragEnter(e)}),!0)),this.addDisposables(w(this.element,"dragover",(e=>{this.onDragOver(e)}),!0)),this.addDisposables(w(this.element,"dragleave",(e=>{this.onDragLeave(e)}))),this.addDisposables(w(this.element,"dragend",(e=>{this.onDragEnd(e)}))),this.addDisposables(w(this.element,"drop",(e=>{this.onDrop(e)})))}}function me(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 ue(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}'`)}}class ce extends _{get state(){return this._state}constructor(e,t){super(),this.element=e,this.options=t,this._onDrop=new v,this.onDrop=this._onDrop.event,this._acceptedTargetZonesSet=new Set(this.options.acceptedTargetZones),this.dnd=new pe(this.element,{onDragEnter:()=>{},onDragOver:e=>{if(0===this._acceptedTargetZonesSet.size)return void this.removeDropTarget();const t=this.element.clientWidth,i=this.element.clientHeight;if(0===t||0===i)return;const n=e.currentTarget.getBoundingClientRect(),s=e.clientX-n.left,o=e.clientY-n.top,r=this.calculateQuadrant(this._acceptedTargetZonesSet,s,o,t,i);if(this.isAlreadyUsed(e)||null===r)this.removeDropTarget();else{if("boolean"==typeof this.options.canDisplayOverlay){if(!this.options.canDisplayOverlay)return void this.removeDropTarget()}else if(!this.options.canDisplayOverlay(e,r))return void this.removeDropTarget();this.markAsUsed(e),this.targetElement||(this.targetElement=document.createElement("div"),this.targetElement.className="drop-target-dropzone",this.overlayElement=document.createElement("div"),this.overlayElement.className="drop-target-selection",this._state="center",this.targetElement.appendChild(this.overlayElement),this.element.classList.add("drop-target"),this.element.append(this.targetElement)),this.toggleClasses(r,t,i),this.setState(r)}},onDragLeave:()=>{this.removeDropTarget()},onDragEnd:()=>{this.removeDropTarget()},onDrop:e=>{e.preventDefault();const t=this._state;this.removeDropTarget(),t&&(e.stopPropagation(),this._onDrop.fire({position:t,nativeEvent:e}))}}),this.addDisposables(this._onDrop,this.dnd)}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}dispose(){this.removeDropTarget(),super.dispose()}markAsUsed(e){e[ce.USED_EVENT_ID]=!0}isAlreadyUsed(e){const t=e[ce.USED_EVENT_ID];return"boolean"==typeof t&&t}toggleClasses(e,t,i){var n,s,o,r;if(!this.overlayElement)return;const a=t<100,h=i<100,d="left"===e,l="right"===e,p="top"===e,m="bottom"===e,u=!a&&l,c=!a&&d,v=!h&&p,g=!h&&m;let w=.5;"percentage"===(null===(s=null===(n=this.options.overlayModel)||void 0===n?void 0:n.size)||void 0===s?void 0:s.type)&&(w=T(this.options.overlayModel.size.value,0,100)/100),"pixels"===(null===(r=null===(o=this.options.overlayModel)||void 0===o?void 0:o.size)||void 0===r?void 0:r.type)&&((u||c)&&(w=T(0,this.options.overlayModel.size.value,t)/t),(v||g)&&(w=T(0,this.options.overlayModel.size.value,i)/i));const f=(1-w)/2;let _;_=u?`translateX(${100*f}%) scaleX(${w})`:c?`translateX(-${100*f}%) scaleX(${w})`:v?`translateY(-${100*f}%) scaleY(${w})`:g?`translateY(${100*f}%) scaleY(${w})`:"",this.overlayElement.style.transform=_,z(this.overlayElement,"small-right",a&&l),z(this.overlayElement,"small-left",a&&d),z(this.overlayElement,"small-top",h&&p),z(this.overlayElement,"small-bottom",h&&m)}setState(e){switch(e){case"top":this._state="top";break;case"left":this._state="left";break;case"bottom":this._state="bottom";break;case"right":this._state="right";break;case"center":this._state="center"}}calculateQuadrant(e,t,i,n,s){var o,r,a,h,d,l;const p=void 0===(null===(o=this.options.overlayModel)||void 0===o?void 0:o.activationSize)||"percentage"===(null===(a=null===(r=this.options.overlayModel)||void 0===r?void 0:r.activationSize)||void 0===a?void 0:a.type),m=(u=null===(l=null===(d=null===(h=this.options)||void 0===h?void 0:h.overlayModel)||void 0===d?void 0:d.activationSize)||void 0===l?void 0:l.value,c=20,"number"==typeof u?u:c);var u,c;return p?function(e,t,i,n,s,o){const r=100*t/n,a=100*i/s;if(e.has("left")&&r<o)return"left";if(e.has("right")&&r>100-o)return"right";if(e.has("top")&&a<o)return"top";if(e.has("bottom")&&a>100-o)return"bottom";if(!e.has("center"))return null;return"center"}(e,t,i,n,s,m):function(e,t,i,n,s,o){if(e.has("left")&&t<o)return"left";if(e.has("right")&&t>n-o)return"right";if(e.has("top")&&i<o)return"top";if(e.has("bottom")&&i>s-o)return"bottom";if(!e.has("center"))return null;return"center"}(e,t,i,n,s,m)}removeDropTarget(){this.targetElement&&(this._state=void 0,this.element.removeChild(this.targetElement),this.targetElement=void 0,this.overlayElement=void 0,this.element.classList.remove("drop-target"))}}var ve;ce.USED_EVENT_ID="__dockview_droptarget_event_is_used__",e.DockviewDropTargets=void 0,(ve=e.DockviewDropTargets||(e.DockviewDropTargets={}))[ve.Tab=0]="Tab",ve[ve.Panel=1]="Panel",ve[ve.TabContainer=2]="TabContainer",ve[ve.Edge=3]="Edge";class ge extends _{get element(){return this._element}constructor(t,i){super(),this.accessor=t,this.group=i,this.disposable=new D,this._onDidFocus=new v,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new v,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="content-container",this._element.tabIndex=-1,this.addDisposables(this._onDidFocus,this._onDidBlur),this.dropTarget=new ce(this.element,{acceptedTargetZones:["top","bottom","left","right","center"],canDisplayOverlay:(t,i)=>{if("no-drop-target"===this.group.locked||this.group.locked&&"center"===i)return!1;const n=p();if(!n&&t.shiftKey&&"floating"!==this.group.location)return!1;if(n&&n.viewId===this.accessor.id){if(n.groupId===this.group.id){if("center"===i)return!1;if(null===n.panelId)return!1}return!(1===this.group.panels.length&&n.groupId===this.group.id)}return this.group.canDisplayOverlay(t,i,e.DockviewDropTargets.Panel)}}),this.addDisposables(this.dropTarget)}show(){this.element.style.display=""}hide(){this.element.style.display="none"}renderPanel(e,t={asActive:!0}){const i=t.asActive||this.panel&&this.group.isPanelActive(this.panel);let n;switch(this.panel&&this.panel.view.content.element.parentElement===this._element&&this._element.removeChild(this.panel.view.content.element),this.panel=e,e.api.renderer){case"onlyWhenVisibile":this.accessor.overlayRenderContainer.detatch(e),this.panel&&i&&this._element.appendChild(this.panel.view.content.element),n=this._element;break;case"always":e.view.content.element.parentElement===this._element&&this._element.removeChild(e.view.content.element),n=this.accessor.overlayRenderContainer.attach({panel:e,referenceContainer:this})}if(i){const t=e.view.content.onDidFocus,i=e.view.content.onDidBlur,s=A(n),o=new _;o.addDisposables(s,s.onDidFocus((()=>this._onDidFocus.fire())),s.onDidBlur((()=>this._onDidBlur.fire()))),t&&o.addDisposables(t((()=>this._onDidFocus.fire()))),i&&o.addDisposables(i((()=>this._onDidBlur.fire()))),this.disposable.value=o}}openPanel(e){this.panel!==e&&this.renderPanel(e)}layout(e,t){}closePanel(){this.panel&&("onlyWhenVisibile"===this.accessor.options.defaultRenderer&&this._element.removeChild(this.panel.view.content.element),this.panel=void 0)}dispose(){this.disposable.dispose(),super.dispose()}}class we extends _{constructor(e){super(),this.el=e,this.dataDisposable=new D,this.pointerEventsDisposable=new D,this._onDragStart=new v,this.onDragStart=this._onDragStart.event,this.addDisposables(this._onDragStart,this.dataDisposable,this.pointerEventsDisposable),this.configure()}isCancelled(e){return!1}configure(){this.addDisposables(this._onDragStart,w(this.el,"dragstart",(e=>{if(e.defaultPrevented||this.isCancelled(e))return void e.preventDefault();const t=[...E("iframe"),...E("webview")];this.pointerEventsDisposable.value={dispose:()=>{for(const e of t)e.style.pointerEvents="auto"}};for(const e of t)e.style.pointerEvents="none";if(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","__dockview_internal_drag_event__")}})),w(this.el,"dragend",(()=>{this.pointerEventsDisposable.dispose(),this.dataDisposable.dispose()})))}}class fe extends we{constructor(e,t,i,n){super(e),this.accessor=t,this.group=i,this.panel=n,this.panelTransfer=l.getInstance()}getData(e){return this.panelTransfer.setData([new h(this.accessor.id,this.group.id,this.panel.id)],h.prototype),{dispose:()=>{this.panelTransfer.clearData(h.prototype)}}}}class _e extends _{get element(){return this._element}constructor(t,i,n){super(),this.panel=t,this.accessor=i,this.group=n,this.content=void 0,this._onChanged=new v,this.onChanged=this._onChanged.event,this._onDropped=new v,this.onDrop=this._onDropped.event,this._onDragStart=new v,this.onDragStart=this._onDragStart.event,this._element=document.createElement("div"),this._element.className="tab",this._element.tabIndex=0,this._element.draggable=!0,z(this.element,"inactive-tab",!0);const s=new fe(this._element,this.accessor,this.group,this.panel);this.droptarget=new ce(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:(t,i)=>{if(this.group.locked)return!1;const n=p();return n&&this.accessor.id===n.viewId?(null!==n.panelId||n.groupId!==this.group.id)&&this.panel.id!==n.panelId:this.group.model.canDisplayOverlay(t,i,e.DockviewDropTargets.Tab)}}),this.addDisposables(this._onChanged,this._onDropped,this._onDragStart,s.onDragStart((e=>{this._onDragStart.fire(e)})),s,w(this._element,"mousedown",(e=>{e.defaultPrevented||this._onChanged.fire(e)})),this.droptarget.onDrop((e=>{this._onDropped.fire(e)})),this.droptarget)}setActive(e){z(this.element,"active-tab",e),z(this.element,"inactive-tab",!e)}setContent(e){this.content&&this._element.removeChild(this.content.element),this.content=e,this._element.appendChild(this.content.element)}dispose(){super.dispose()}}class De extends we{constructor(e,t,i){super(e),this.accessor=t,this.group=i,this.panelTransfer=l.getInstance(),this.addDisposables(w(e,"mousedown",(e=>{e.shiftKey&&(e[I]=!0)}),!0))}isCancelled(e){return"floating"===this.group.api.location&&!e.shiftKey}getData(e){const t=e.dataTransfer;this.panelTransfer.setData([new h(this.accessor.id,this.group.id,null)],h.prototype);const i=window.getComputedStyle(this.el),n=i.getPropertyValue("--dv-activegroup-visiblepanel-tab-background-color"),s=i.getPropertyValue("--dv-activegroup-visiblepanel-tab-color");if(t){const e=document.createElement("div");e.style.backgroundColor=n,e.style.color=s,e.style.padding="2px 8px",e.style.height="24px",e.style.fontSize="11px",e.style.lineHeight="20px",e.style.borderRadius="12px",e.style.position="absolute",e.textContent=`Multiple Panels (${this.group.size})`,function(e,t){S(t,"dv-dragged"),document.body.appendChild(t),e.setDragImage(t,0,0),setTimeout((()=>{y(t,"dv-dragged"),t.remove()}),0)}(t,e)}return{dispose:()=>{this.panelTransfer.clearData(h.prototype)}}}}class be extends _{get element(){return this._element}constructor(t,i){super(),this.accessor=t,this.group=i,this._onDrop=new v,this.onDrop=this._onDrop.event,this._onDragStart=new v,this.onDragStart=this._onDragStart.event,this._element=document.createElement("div"),this._element.className="void-container",this._element.tabIndex=0,this._element.draggable=!0,this.addDisposables(this._onDrop,this._onDragStart,w(this._element,"click",(()=>{this.accessor.doSetGroupActive(this.group)})));const n=new De(this._element,t,i);this.voidDropTarget=new ce(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:(t,n)=>{var s;const o=p();return o&&this.accessor.id===o.viewId?(null!==o.panelId||o.groupId!==this.group.id)&&(null===(s=(r=this.group.panels).length>0?r[r.length-1]:void 0)||void 0===s?void 0:s.id)!==o.panelId:i.model.canDisplayOverlay(t,n,e.DockviewDropTargets.Panel);var r}}),this.addDisposables(n,n.onDragStart((e=>{this._onDragStart.fire(e)})),this.voidDropTarget.onDrop((e=>{this._onDrop.fire(e)})),this.voidDropTarget)}}class Ce extends _{get panels(){return this.tabs.map((e=>e.value.panel.id))}get size(){return this.tabs.length}get hidden(){return this._hidden}set hidden(e){this._hidden=e,this.element.style.display=e?"none":""}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))}get element(){return this._element}isActive(e){return this.selectedIndex>-1&&this.tabs[this.selectedIndex].value===e}indexOf(e){return this.tabs.findIndex((t=>t.value.panel.id===e))}constructor(e,t){super(),this.accessor=e,this.group=t,this.tabs=[],this.selectedIndex=-1,this._hidden=!1,this._onDrop=new v,this.onDrop=this._onDrop.event,this._onTabDragStart=new v,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new v,this.onGroupDragStart=this._onGroupDragStart.event,this.addDisposables(this._onDrop,this._onTabDragStart,this._onGroupDragStart),this._element=document.createElement("div"),this._element.className="tabs-and-actions-container",z(this._element,"dv-full-width-single-tab","fullwidth"===this.accessor.options.singleTabMode),this.addDisposables(this.accessor.onDidAddPanel((e=>{e.api.group===this.group&&z(this._element,"dv-single-tab",1===this.size)})),this.accessor.onDidRemovePanel((e=>{e.api.group===this.group&&z(this._element,"dv-single-tab",1===this.size)}))),this.rightActionsContainer=document.createElement("div"),this.rightActionsContainer.className="right-actions-container",this.leftActionsContainer=document.createElement("div"),this.leftActionsContainer.className="left-actions-container",this.preActionsContainer=document.createElement("div"),this.preActionsContainer.className="pre-actions-container",this.tabContainer=document.createElement("div"),this.tabContainer.className="tabs-container",this.voidContainer=new be(this.accessor,this.group),this._element.appendChild(this.preActionsContainer),this._element.appendChild(this.tabContainer),this._element.appendChild(this.leftActionsContainer),this._element.appendChild(this.voidContainer.element),this._element.appendChild(this.rightActionsContainer),this.addDisposables(this.voidContainer,this.voidContainer.onDragStart((e=>{this._onGroupDragStart.fire({nativeEvent:e,group:this.group})})),this.voidContainer.onDrop((e=>{this._onDrop.fire({event:e.nativeEvent,index:this.tabs.length})})),w(this.voidContainer.element,"mousedown",(e=>{if(!this.accessor.options.disableFloatingGroups&&e.shiftKey&&"floating"!==this.group.api.location){e.preventDefault();const{top:t,left:i}=this.element.getBoundingClientRect(),{top:n,left:s}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(this.group,{x:i-s+20,y:t-n+20},{inDragMode:!0})}})),w(this.tabContainer,"mousedown",(e=>{if(e.defaultPrevented)return;0===e.button&&this.accessor.doSetGroupActive(this.group)})))}setActive(e){}addTab(e,t=this.tabs.length){if(t<0||t>this.tabs.length)throw new Error("invalid location");this.tabContainer.insertBefore(e.value.element,this.tabContainer.children[t]),this.tabs=[...this.tabs.slice(0,t),e,...this.tabs.slice(t)],this.selectedIndex<0&&(this.selectedIndex=t)}delete(e){const t=this.tabs.findIndex((t=>t.value.panel.id===e)),i=this.tabs.splice(t,1)[0],{value:n,disposable:s}=i;s.dispose(),n.dispose(),n.element.remove()}setActivePanel(e){this.tabs.forEach((t=>{const i=e.id===t.value.panel.id;t.value.setActive(i)}))}openPanel(e,t=this.tabs.length){var i;if(this.tabs.find((t=>t.value.panel.id===e.id)))return;const n=new _e(e,this.accessor,this.group);if(!(null===(i=e.view)||void 0===i?void 0:i.tab))throw new Error("invalid header component");n.setContent(e.view.tab);const s=new _(n.onDragStart((t=>{this._onTabDragStart.fire({nativeEvent:t,panel:e})})),n.onChanged((t=>{var i;const s=!this.accessor.options.disableFloatingGroups,o="floating"===this.group.api.location&&1===this.size;if(s&&!o&&t.shiftKey){t.preventDefault();const e=this.accessor.getGroupPanel(n.panel.id),{top:i,left:s}=n.element.getBoundingClientRect(),{top:o,left:r}=this.accessor.element.getBoundingClientRect();return void this.accessor.addFloatingGroup(e,{x:s-r,y:i-o},{inDragMode:!0})}const r=e.id===(null===(i=this.group.model.activePanel)||void 0===i?void 0:i.id)&&this.group.model.isContentFocused;0===t.button&&!t.defaultPrevented&&this.group.model.openPanel(e,{skipFocus:r})})),n.onDrop((e=>{this._onDrop.fire({event:e.nativeEvent,index:this.tabs.findIndex((e=>e.value===n))})}))),o={value:n,disposable:s};this.addTab(o,t)}closePanel(e){this.delete(e.id)}dispose(){super.dispose();for(const{value:e,disposable:t}of this.tabs)t.dispose(),e.dispose();this.tabs=[]}}class ye extends _{get element(){throw new Error("not supported")}get activePanel(){return this._activePanel}get locked(){return this._locked}set locked(e){this._locked=e,z(this.container,"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&&x(document.activeElement,this.contentContainer.element)}get location(){return this._location}set location(e){switch(this._location=e,z(this.container,"dv-groupview-floating",!1),z(this.container,"dv-groupview-popout",!1),e){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"]),z(this.container,"dv-groupview-floating",!0);break;case"popout":this.contentContainer.dropTarget.setTargetZones(["center"]),z(this.container,"dv-groupview-popout",!0)}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,i,n,s){var o;super(),this.container=e,this.accessor=t,this.id=i,this.options=n,this.groupPanel=s,this._isGroupActive=!1,this._locked=!1,this._location="grid",this.mostRecentlyUsed=[],this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._onMove=new v,this.onMove=this._onMove.event,this._onDidDrop=new v,this.onDidDrop=this._onDidDrop.event,this._onTabDragStart=new v,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new v,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new v,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidRemovePanel=new v,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new v,this.onDidActivePanelChange=this._onDidActivePanelChange.event,z(this.container,"groupview",!0),this.tabsContainer=new Ce(this.accessor,this.groupPanel),this.contentContainer=new ge(this.accessor,this),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!n.hideHeader,this.locked=null!==(o=n.locked)&&void 0!==o&&o,this.addDisposables(this._onTabDragStart,this._onGroupDragStart,this.tabsContainer.onTabDragStart((e=>{this._onTabDragStart.fire(e)})),this.tabsContainer.onGroupDragStart((e=>{this._onGroupDragStart.fire(e)})),this.tabsContainer.onDrop((e=>{this.handleDropEvent(e.event,"center",e.index)})),this.contentContainer.onDidFocus((()=>{this.accessor.doSetGroupActive(this.groupPanel,!0)})),this.contentContainer.onDidBlur((()=>{})),this.contentContainer.dropTarget.onDrop((e=>{this.handleDropEvent(e.nativeEvent,e.position)})),this._onMove,this._onDidChange,this._onDidDrop,this._onDidAddPanel,this._onDidRemovePanel,this._onDidActivePanelChange)}initialize(){var e,t;(null===(e=this.options)||void 0===e?void 0:e.panels)&&this.options.panels.forEach((e=>{this.doAddPanel(e)})),(null===(t=this.options)||void 0===t?void 0:t.activePanel)&&this.openPanel(this.options.activePanel),this.setActive(this.isActive,!0,!0),this.updateContainer(),this.accessor.options.createRightHeaderActionsElement&&(this._rightHeaderActions=this.accessor.options.createRightHeaderActionsElement(this.groupPanel),this.addDisposables(this._rightHeaderActions),this._rightHeaderActions.init({containerApi:new le(this.accessor),api:this.groupPanel.api}),this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element)),this.accessor.options.createLeftHeaderActionsElement&&(this._leftHeaderActions=this.accessor.options.createLeftHeaderActionsElement(this.groupPanel),this.addDisposables(this._leftHeaderActions),this._leftHeaderActions.init({containerApi:new le(this.accessor),api:this.groupPanel.api}),this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element)),this.accessor.options.createPrefixHeaderActionsElement&&(this._prefixHeaderActions=this.accessor.options.createPrefixHeaderActionsElement(this.groupPanel),this.addDisposables(this._prefixHeaderActions),this._prefixHeaderActions.init({containerApi:new le(this.accessor),api:this.groupPanel.api}),this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element))}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),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,t;null===(t=null===(e=this._activePanel)||void 0===e?void 0:e.focus)||void 0===t||t.call(e)}openPanel(e,t={}){("number"!=typeof t.index||t.index>this.panels.length)&&(t.index=this.panels.length);const i=!!t.skipSetPanelActive,n=!!t.skipSetGroupActive;e.updateParentGroup(this.groupPanel,!0),this._activePanel!==e?(this.doAddPanel(e,t.index,i),i||this.doSetActivePanel(e),n||this.accessor.doSetGroupActive(this.groupPanel,!!t.skipFocus),this.updateContainer()):n||this.accessor.doSetGroupActive(this.groupPanel)}removePanel(e){const t="string"==typeof e?e:e.id,i=this._panels.find((e=>e.id===t));if(!i)throw new Error("invalid operation");return this._removePanel(i)}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){this.accessor.removePanel(e)}isPanelActive(e){return this._activePanel===e}updateActions(e){this.tabsContainer.setRightActionsElement(e)}setActive(e,t=!1,i=!1){var n,s,o,r;i||this.isActive!==e?(this._isGroupActive=e,z(this.container,"active-group",e),z(this.container,"inactive-group",!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0&&this.doSetActivePanel(this.panels[0]),this.updateContainer(),e&&(t||null===(r=null===(o=this._activePanel)||void 0===o?void 0:o.focus)||void 0===r||r.call(o))):t||null===(s=null===(n=this._activePanel)||void 0===n?void 0:n.focus)||void 0===s||s.call(n)}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){const t=this._activePanel===e;if(this.doRemovePanel(e),t&&this.panels.length>0){const e=this.mostRecentlyUsed[0];this.openPanel(e)}return this._activePanel&&0===this.panels.length&&this.doSetActivePanel(void 0),this.updateContainer(),e}doRemovePanel(e){const t=this.panels.indexOf(e);this._activePanel===e&&this.contentContainer.closePanel(),this.tabsContainer.delete(e.id),this._panels.splice(t,1),this.mostRecentlyUsed.includes(e)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(e),1),this._onDidRemovePanel.fire({panel:e})}doAddPanel(e,t=this.panels.length,i=!1){const n=this._panels.indexOf(e)>-1;this.tabsContainer.show(),this.contentContainer.show(),this.tabsContainer.openPanel(e,t),i||this.contentContainer.openPanel(e),n||(this.updateMru(e),this.panels.splice(t,0,e),this._onDidAddPanel.fire({panel:e}))}doSetActivePanel(e){this._activePanel=e,e&&(this.tabsContainer.setActivePanel(e),e.layout(this._width,this._height),this.updateMru(e),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;if(z(this.container,"empty",this.isEmpty),this.panels.forEach((e=>e.updateParentGroup(this.groupPanel,this.isActive))),this.isEmpty&&!this.watermark){const e=this.accessor.createWatermarkComponent();e.init({containerApi:new le(this.accessor),group:this.groupPanel}),this.watermark=e,w(this.watermark.element,"click",(()=>{this.isActive||this.accessor.doSetGroupActive(this.groupPanel)})),this.tabsContainer.hide(),this.contentContainer.element.appendChild(this.watermark.element),this.watermark.updateParentGroup(this.groupPanel,!0)}!this.isEmpty&&this.watermark&&(this.watermark.element.remove(),null===(t=(e=this.watermark).dispose)||void 0===t||t.call(e),this.watermark=void 0,this.tabsContainer.show())}canDisplayOverlay(e,t,i){return!!this.accessor.options.showDndOverlay&&this.accessor.options.showDndOverlay({nativeEvent:e,target:i,group:this.accessor.getPanel(this.id),position:t,getData:p})}handleDropEvent(e,t,i){if("no-drop-target"===this.locked)return;const n=p();if(n&&n.viewId===this.accessor.id){if(null===n.panelId){const{groupId:e}=n;return void this._onMove.fire({target:t,groupId:e,index:i})}if(-1!==this.tabsContainer.indexOf(n.panelId)&&1===this.tabsContainer.size)return;const{groupId:e,panelId:s}=n;if(this.id===e&&!t){if(this.tabsContainer.indexOf(s)===i)return}this._onMove.fire({target:t,groupId:n.groupId,itemId:n.panelId,index:i})}else this._onDidDrop.fire({nativeEvent:e,position:t,index:i,getData:()=>p()})}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);for(const e of this.panels)e.dispose();this.tabsContainer.dispose(),this.contentContainer.dispose()}}class Se extends _{get element(){return this._element}get disableResizing(){return this._disableResizing}set disableResizing(e){this._disableResizing=e}constructor(e,t=!1){super(),this._disableResizing=t,e?this._element=e:(this._element=document.createElement("div"),this._element.style.height="100%",this._element.style.width="100%",this._element.className="dv-resizable-container"),this.addDisposables(C(this._element,(e=>{if(this.isDisposed)return;if(this.disableResizing)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{width:t,height:i}=e.contentRect;this.layout(t,i)})))}}const ze=M();function xe(e){switch(e){case"left":return"left";case"right":return"right";case"above":return"top";case"below":return"bottom";default:return"center"}}class Ee extends Se{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}constructor(t){super(t.parentElement,t.disableAutoResizing),this._id=ze.next(),this._groups=new Map,this._onDidLayoutChange=new v,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidRemoveGroup=new v,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new v,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new v,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._bufferOnDidLayoutChange=new f,this.gridview=new re(!!t.proportionalLayout,t.styles,t.orientation),this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidChange((()=>{this._bufferOnDidLayoutChange.fire()})),e.DockviewEvent.any(this.onDidAddGroup,this.onDidRemoveGroup,this.onDidActiveGroupChange)((()=>{this._bufferOnDidLayoutChange.fire()})),this._bufferOnDidLayoutChange.onEvent((()=>{this._onDidLayoutChange.fire()})),this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(Q(e.element),t),this._onDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(Q(e.element))}maximizeGroup(e){this.gridview.maximizeView(e)}isMaximizedGroup(e){return this.gridview.maximizedView()===e}exitMaximizedGroup(){this.gridview.exitMaximizedView()}hasMaximizedGroup(){return this.gridview.hasMaximizedView()}get onDidMaxmizedGroupChange(){return this.gridview.onDidMaxmizedNodeChange}doAddGroup(t,i=[0],n){this.gridview.addView(t,null!=n?n:e.Sizing.Distribute,i),this._onDidAddGroup.fire(t),this.doSetGroupActive(t)}doRemoveGroup(t,i){if(!this._groups.has(t.id))throw new Error("invalid operation");const n=this._groups.get(t.id),s=this.gridview.remove(t,e.Sizing.Distribute);if(n&&!(null==i?void 0:i.skipDispose)&&(n.disposable.dispose(),n.value.dispose(),this._groups.delete(t.id)),this._onDidRemoveGroup.fire(t),!(null==i?void 0:i.skipActive)&&this._activeGroup===t){const e=Array.from(this._groups.values());this.doSetGroupActive(e.length>0?e[0].value:void 0)}return s}getPanel(e){var t;return null===(t=this._groups.get(e))||void 0===t?void 0:t.value}doSetGroupActive(e,t){var i,n,s;this._activeGroup!==e&&(this._activeGroup&&(this._activeGroup.setActive(!1),t||null===(n=(i=this._activeGroup).focus)||void 0===n||n.call(i)),e&&(e.setActive(!0),t||null===(s=e.focus)||void 0===s||s.call(e)),this._activeGroup=e,this._onDidActiveGroupChange.fire(e))}removeGroup(e){this.doRemoveGroup(e)}moveToNext(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=Q(e.group.element),n=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupActive(n)}moveToPrevious(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=Q(e.group.element),n=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;this.doSetGroupActive(n)}layout(e,t,i){(null!=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._onDidActiveGroupChange.dispose(),this._onDidAddGroup.dispose(),this._onDidRemoveGroup.dispose(),this._onDidLayoutChange.dispose();for(const e of this.groups)e.dispose();this.gridview.dispose(),super.dispose()}}class Ae extends _{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){super(),this.id=e,this._isFocused=!1,this._isActive=!1,this._isVisible=!0,this._width=0,this._height=0,this.panelUpdatesDisposable=new D,this._onDidDimensionChange=new v({replay:!0}),this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new v({replay:!0}),this.onDidFocusChange=this._onDidChangeFocus.event,this._onFocusEvent=new v,this.onFocusEvent=this._onFocusEvent.event,this._onDidVisibilityChange=new v({replay:!0}),this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onVisibilityChange=new v,this.onVisibilityChange=this._onVisibilityChange.event,this._onDidActiveChange=new v({replay:!0}),this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new v,this.onActiveChange=this._onActiveChange.event,this._onUpdateParameters=new v,this.onUpdateParameters=this._onUpdateParameters.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._onFocusEvent,this._onActiveChange,this._onVisibilityChange,this._onUpdateParameters)}initialize(e){this.panelUpdatesDisposable.value=this._onUpdateParameters.event((t=>{e.update({params:t})}))}setVisible(e){this._onVisibilityChange.fire({isVisible:e})}setActive(){this._onActiveChange.fire()}updateParameters(e){this._onUpdateParameters.fire(e)}dispose(){super.dispose()}}class Pe extends Ae{constructor(e){super(e),this._onDidConstraintsChangeInternal=new v,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new v({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new v,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}}class Ie extends Pe{set pane(e){this._pane=e}constructor(e){super(e),this._onDidExpansionChange=new v({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new v({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new v({}),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 Oe extends _{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 n=A(this._element);this.addDisposables(this.api,n.onDidFocus((()=>{this.api._onDidChangeFocus.fire({isFocused:!0})})),n.onDidBlur((()=>{this.api._onDidChangeFocus.fire({isFocused:!1})})),n)}focus(){this.api._onFocusEvent.fire()}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 Ge extends Oe{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,t,i,n,s,o){super(e,t,new Ie(e)),this.headerComponent=i,this._onDidChangeExpansionState=new v({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this.headerSize=22,this._orthogonalSize=0,this._size=0,this._minimumBodySize=100,this._maximumBodySize=Number.POSITIVE_INFINITY,this._isExpanded=!1,this.expandedSize=0,this.api.pane=this,this.api.initialize(this),this._isExpanded=s,this._headerVisible=o,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=n,this.element.classList.add("pane"),this.addDisposables(this.api.onDidSizeChange((e=>{this._onDidChange.fire({size:e.size})})),w(this.element,"mouseenter",(e=>{this.api._onMouseEnter.fire(e)})),w(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?S(this.header,"focused"):y(this.header,"focused"))}))),this.renderOnce()}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}isExpanded(){return this._isExpanded}setExpanded(e){this._isExpanded!==e&&(this._isExpanded=e,e?(this.animationTimer&&clearTimeout(this.animationTimer),this.body&&this.element.appendChild(this.body)):this.animationTimer=setTimeout((()=>{var e;null===(e=this.body)||void 0===e||e.remove()}),200),this._onDidChange.fire(e?{size:this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(t,i){this._size=t,this._orthogonalSize=i;const[n,s]=this.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.isExpanded()&&(this.expandedSize=n),super.layout(n,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="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="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 Ne extends Ge{constructor(e,t,i,n,s,o,r){super(t,i,n,s,o,!0),this.accessor=e,this._onDidDrop=new v,this.onDidDrop=this._onDidDrop.event,r||this.initDragFeatures()}initDragFeatures(){if(!this.header)return;const e=this.id,t=this.accessor.id;this.header.draggable=!0,this.handler=new class extends we{getData(){return l.getInstance().setData([new d(t,e)],d.prototype),{dispose:()=>{l.getInstance().clearData(d.prototype)}}}}(this.header),this.target=new ce(this.element,{acceptedTargetZones:["top","bottom"],overlayModel:{activationSize:{type:"percentage",value:50}},canDisplayOverlay:e=>{const t=m();return!(!t||t.paneId===this.id||t.viewId!==this.accessor.id)||!!this.accessor.options.showDndOverlay&&this.accessor.options.showDndOverlay({nativeEvent:e,getData:m,panel:this})}}),this.addDisposables(this._onDidDrop,this.handler,this.target,this.target.onDrop((e=>{this.onDrop(e)})))}onDrop(e){const t=m();if(!t||t.viewId!==this.accessor.id)return void this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,api:new he(this.accessor),getData:m}));const i=this._params.containerApi,n=t.paneId,s=i.getPanel(n);if(!s)return void this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,getData:m,api:new he(this.accessor)}));const o=i.panels,r=o.indexOf(s);let a=i.panels.indexOf(this);"left"!==e.position&&"top"!==e.position||(a=Math.max(0,a-1)),"right"!==e.position&&"bottom"!==e.position||(r>a&&a++,a=Math.min(o.length-1,a)),i.movePanel(r,a)}}class Ve extends Ae{constructor(e,t){super(e),this._onDidConstraintsChangeInternal=new v,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new v({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new v,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange),t&&this.initialize(t)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}}class Le extends Oe{get priority(){return this._priority}get snap(){return this._snap}get minimumWidth(){const e="function"==typeof this._minimumWidth?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}get minimumHeight(){const e="function"==typeof this._minimumHeight?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}get maximumHeight(){const e="function"==typeof this._maximumHeight?this._maximumHeight():this._maximumHeight;return e!==this._evaluatedMaximumHeight&&(this._evaluatedMaximumHeight=e,this.updateConstraints()),e}get maximumWidth(){const e="function"==typeof this._maximumWidth?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}get isActive(){return this.api.isActive}constructor(e,t,i,n){super(e,t,null!=n?n:new Ve(e)),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 v,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.onVisibilityChange((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.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 ke="DockviewGroupPanelApiImpl not initialized";class Re extends Ve{get location(){if(!this._group)throw new Error(ke);return this._group.model.location}constructor(e,t){super(e),this.accessor=t,this._onDidLocationChange=new v,this.onDidLocationChange=this._onDidLocationChange.event,this.addDisposables(this._onDidLocationChange)}moveTo(e){var t,i,n;if(!this._group)throw new Error(ke);const s=null!==(t=e.group)&&void 0!==t?t:this.accessor.addGroup({direction:ue(null!==(i=e.position)&&void 0!==i?i:"right")});this.accessor.moveGroupOrPanel(s,this._group.id,void 0,e.group&&null!==(n=e.position)&&void 0!==n?n:"center")}maximize(){if(!this._group)throw new Error(ke);"grid"===this.location&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw new Error(ke);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw new Error(ke);this.isMaximized()&&this.accessor.exitMaximizedGroup()}initialize(e){this._group=e}}class Te extends Le{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){super(t,"groupview_default",{minimumHeight:100,minimumWidth:100},new Re(t,e)),this.api.initialize(this),this._model=new ye(this.element,e,t,i,this)}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()}}function Me(e){return!!e.referencePanel}function He(e){return!!e.referenceGroup}function We(e){return!!e.referencePanel}function Fe(e){return!!e.referenceGroup}class Be extends Ve{get title(){return this.panel.title}get isGroupActive(){return this.group.isActive}get renderer(){return this.panel.renderer}set group(e){const t=this.isGroupActive;this._group=e,this._onDidGroupChange.fire(),this._group&&(this.disposable.value=this._group.api.onDidActiveChange((()=>{this._onDidActiveGroupChange.fire()})),this.isGroupActive!==t&&this._onDidActiveGroupChange.fire())}get group(){return this._group}constructor(e,t,i){super(e.id),this.panel=e,this.accessor=i,this._onDidTitleChange=new v,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidActiveGroupChange=new v,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new v,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new v,this.onDidRendererChange=this._onDidRendererChange.event,this.disposable=new D,this.initialize(e),this._group=t,this.addDisposables(this.disposable,this._onDidRendererChange,this._onDidTitleChange,this._onDidGroupChange,this._onDidActiveGroupChange)}moveTo(e){var t;this.accessor.moveGroupOrPanel(e.group,this._group.id,this.panel.id,null!==(t=e.position)&&void 0!==t?t:"center",e.index)}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()}}class Je extends _{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}constructor(e,t,i,n,s,o){super(),this.id=e,this.accessor=t,this.containerApi=i,this.view=s,this._renderer=o.renderer,this._group=n,this.api=new Be(this,this._group,t),this.addDisposables(this.api.onActiveChange((()=>{t.setActivePanel(this)})),this.api.onDidSizeChange((e=>{this.group.api.setSize(e)})),this.api.onDidRendererChange((e=>{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(){this.api._onFocusEvent.fire()}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}}setTitle(e){e!==this.title&&(this._title=e,this.view.update({params:{params:this._params,title:this.title}}),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:{params:this._params,title:this.title}})}updateParentGroup(e,t){this._group=e,this.api.group=e;const i=this._group.model.isPanelActive(this);this.api._onDidActiveChange.fire({isActive:t&&i}),this.api._onDidVisibilityChange.fire({isVisible:i}),this.view.updateParentGroup(this._group,this._group.model.isPanelActive(this))}layout(e,t){this.api._onDidDimensionChange.fire({width:e,height:t}),this.view.layout(e,t)}dispose(){this.api.dispose(),this.view.dispose()}}const je=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("dockview-svg");const i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttributeNS(null,"d",e.path),t.appendChild(i),t},$e=()=>je({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"});class Ze extends _{get element(){return this._element}constructor(){super(),this.params={},this._element=document.createElement("div"),this._element.className="default-tab",this._content=document.createElement("div"),this._content.className="tab-content",this._actionContainer=document.createElement("div"),this._actionContainer.className="action-container",this._list=document.createElement("ul"),this._list.className="tab-list",this.action=document.createElement("div"),this.action.className="tab-action",this.action.appendChild($e()),this._element.appendChild(this._content),this._element.appendChild(this._actionContainer),this._actionContainer.appendChild(this._list),this._list.appendChild(this.action),this.addDisposables(w(this._actionContainer,"mousedown",(e=>{e.preventDefault()}))),this.render()}update(e){this.params=Object.assign(Object.assign({},this.params),e.params),this.render()}focus(){}init(e){this.params=e,this._content.textContent=e.title,w(this.action,"click",(e=>{e.preventDefault(),this.params.api.close()}))}onGroupChange(e){this.render()}onPanelVisibleChange(e){this.render()}layout(e,t){}render(){this._content.textContent!==this.params.title&&(this._content.textContent=this.params.title)}}class Ue{get content(){return this._content}get tab(){return this._tab}constructor(e,t,i,n){this.accessor=e,this.id=t,this.contentComponent=i,this.tabComponent=n,this._group=null,this._isPanelVisible=null,this._content=this.createContentComponent(this.id,i),this._tab=this.createTabComponent(this.id,n)}init(e){this.content.init(Object.assign(Object.assign({},e),{tab:this.tab})),this.tab.init(e)}updateParentGroup(e,t){e!==this._group&&(this._group=e,this._content.onGroupChange&&this._content.onGroupChange(e),this._tab.onGroupChange&&this._tab.onGroupChange(e)),t!==this._isPanelVisible&&(this._isPanelVisible=t,this._content.onPanelVisibleChange&&this._content.onPanelVisibleChange(t),this._tab.onPanelVisibleChange&&this._tab.onPanelVisibleChange(t))}layout(e,t){var i,n;null===(n=(i=this.content).layout)||void 0===n||n.call(i,e,t)}update(e){var t,i,n,s;null===(i=(t=this.content).update)||void 0===i||i.call(t,e),null===(s=(n=this.tab).update)||void 0===s||s.call(n,e)}dispose(){var e,t,i,n;null===(t=(e=this.content).dispose)||void 0===t||t.call(e),null===(n=(i=this.tab).dispose)||void 0===n||n.call(i)}createContentComponent(e,t){var i,n;return b(e,t,null!==(i=this.accessor.options.components)&&void 0!==i?i:{},this.accessor.options.frameworkComponents,null===(n=this.accessor.options.frameworkComponentFactory)||void 0===n?void 0:n.content)}createTabComponent(e,t){var i,n;return t?b(e,t,this.accessor.options.tabComponents,this.accessor.options.frameworkTabComponents,null===(i=this.accessor.options.frameworkComponentFactory)||void 0===i?void 0:i.tab,(()=>new Ze)):this.accessor.options.defaultTabComponent?b(e,this.accessor.options.defaultTabComponent,this.accessor.options.tabComponents,this.accessor.options.frameworkTabComponents,null===(n=this.accessor.options.frameworkComponentFactory)||void 0===n?void 0:n.tab,(()=>new Ze)):new Ze}}class Ye{constructor(e){this.accessor=e}fromJSON(e,t){var i,n;const s=e.id,o=e.params,r=e.title,a=e.view,h=a?a.content.id:null!==(i=e.contentComponent)&&void 0!==i?i:"unknown",d=a?null===(n=a.tab)||void 0===n?void 0:n.id:e.tabComponent,l=new Ue(this.accessor,s,h,d),p=new Je(s,this.accessor,new le(this.accessor),t,l,{renderer:e.renderer});return p.init({title:null!=r?r:s,params:null!=o?o:{}}),p}}class Xe extends _{get element(){return this._element}constructor(){super(),this._element=document.createElement("div"),this._element.className="watermark";const e=document.createElement("div");e.className="watermark-title";const t=document.createElement("span");t.style.flexGrow="1";const i=document.createElement("div");i.className="watermark-content",this._element.appendChild(e),this._element.appendChild(i);const n=document.createElement("div");n.className="actions-container";const s=document.createElement("div");s.className="close-action",s.appendChild($e()),n.appendChild(s),e.appendChild(t),e.appendChild(n),this.addDisposables(w(s,"click",(e=>{var t;e.preventDefault(),this._group&&(null===(t=this._api)||void 0===t||t.removeGroup(this._group))})))}update(e){}focus(){}layout(e,t){}init(e){this._api=e.containerApi,this.render()}updateParentGroup(e,t){this._group=e,this.render()}dispose(){super.dispose()}render(){const e=!!(this._api&&this._api.size<=1);z(this.element,"has-actions",e)}}const Ke=(()=>{let e=null;return function(t){e!==t&&null!==e&&z(e,"dv-bring-to-front",!1),z(t,"dv-bring-to-front",!0),e=t}})();class qe extends _{set minimumInViewportWidth(e){this.options.minimumInViewportWidth=e}set minimumInViewportHeight(e){this.options.minimumInViewportHeight=e}constructor(e){super(),this.options=e,this._element=document.createElement("div"),this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new v,this.onDidChangeEnd=this._onDidChangeEnd.event,this.addDisposables(this._onDidChange,this._onDidChangeEnd),this._element.className="dv-resize-container",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({height:this.options.height,width:this.options.width,top:this.options.top,left:this.options.left})}setBounds(e={}){"number"==typeof e.height&&(this._element.style.height=`${e.height}px`),"number"==typeof e.width&&(this._element.style.width=`${e.width}px`),"number"==typeof e.top&&(this._element.style.top=`${e.top}px`),"number"==typeof e.left&&(this._element.style.left=`${e.left}px`);const t=this.options.container.getBoundingClientRect(),i=this._element.getBoundingClientRect(),n=Math.max(0,this.getMinimumWidth(i.width)),s="number"==typeof this.options.minimumInViewportHeight?Math.max(0,this.getMinimumHeight(i.height)):0,o=T(i.left-t.left,-n,Math.max(0,t.width-i.width+n)),r=T(i.top-t.top,-s,Math.max(0,t.height-i.height+s));this._element.style.left=`${o}px`,this._element.style.top=`${r}px`,this._onDidChange.fire()}toJSON(){const e=this.options.container.getBoundingClientRect(),t=this._element.getBoundingClientRect();return{top:t.top-e.top,left:t.left-e.left,width:t.width,height:t.height}}setupDrag(e,t={inDragMode:!1}){const i=new D,n=()=>{let e=null;const t=[...E("iframe"),...E("webview")];for(const e of t)e.style.pointerEvents="none";i.value=new _({dispose:()=>{for(const e of t)e.style.pointerEvents="auto"}},g(window,"mousemove",(t=>{const i=this.options.container.getBoundingClientRect(),n=t.clientX-i.left,s=t.clientY-i.top;z(this._element,"dv-resize-container-dragging",!0);const o=this._element.getBoundingClientRect();null===e&&(e={x:t.clientX-o.left,y:t.clientY-o.top});const r=Math.max(0,this.getMinimumWidth(o.width)),a=Math.max(0,this.options.minimumInViewportHeight?this.getMinimumHeight(o.height):0),h=T(n-e.x,-r,Math.max(0,i.width-o.width+r)),d=T(s-e.y,-a,Math.max(0,i.height-o.height+a));this.setBounds({top:d,left:h})})),g(window,"mouseup",(()=>{z(this._element,"dv-resize-container-dragging",!1),i.dispose(),this._onDidChangeEnd.fire()})))};this.addDisposables(i,w(e,"mousedown",(e=>{e.defaultPrevented?e.preventDefault():O(e)||n()})),w(this.options.content,"mousedown",(e=>{e.defaultPrevented||O(e)||e.shiftKey&&n()})),w(this.options.content,"mousedown",(()=>{Ke(this._element)}),!0)),Ke(this._element),t.inDragMode&&n()}setupResize(e){const t=document.createElement("div");t.className=`dv-resize-handle-${e}`,this._element.appendChild(t);const i=new D;this.addDisposables(i,w(t,"mousedown",(t=>{t.preventDefault();let n=null;const s=[...E("iframe"),...E("webview")];for(const e of s)e.style.pointerEvents="none";i.value=new _(g(window,"mousemove",(t=>{const i=this.options.container.getBoundingClientRect(),s=this._element.getBoundingClientRect(),o=t.clientY-i.top,r=t.clientX-i.left;let a,h,d,l;null===n&&(n={originalY:o,originalHeight:s.height,originalX:r,originalWidth:s.width});const p=()=>{a=T(o,-Number.MAX_VALUE,n.originalY+n.originalHeight>i.height?this.getMinimumHeight(i.height):Math.max(0,n.originalY+n.originalHeight-qe.MINIMUM_HEIGHT)),h=n.originalY+n.originalHeight-a},m=()=>{a=n.originalY-n.originalHeight,h=T(o-a,a<0&&"number"==typeof this.options.minimumInViewportHeight?-a+this.options.minimumInViewportHeight:qe.MINIMUM_HEIGHT,Number.MAX_VALUE)},u=()=>{d=T(r,-Number.MAX_VALUE,n.originalX+n.originalWidth>i.width?this.getMinimumWidth(i.width):Math.max(0,n.originalX+n.originalWidth-qe.MINIMUM_WIDTH)),l=n.originalX+n.originalWidth-d},c=()=>{d=n.originalX-n.originalWidth,l=T(r-d,d<0&&"number"==typeof this.options.minimumInViewportWidth?-d+this.options.minimumInViewportWidth:qe.MINIMUM_WIDTH,Number.MAX_VALUE)};switch(e){case"top":p();break;case"bottom":m();break;case"left":u();break;case"right":c();break;case"topleft":p(),u();break;case"topright":p(),c();break;case"bottomleft":m(),u();break;case"bottomright":m(),c()}this.setBounds({height:h,width:l,top:a,left:d})})),{dispose:()=>{for(const e of s)e.style.pointerEvents="auto"}},g(window,"mouseup",(()=>{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:e}dispose(){this._element.remove(),super.dispose()}}qe.MINIMUM_HEIGHT=20,qe.MINIMUM_WIDTH=20;class Qe extends _{constructor(e,t){super(),this.group=e,this.overlay=t,this.addDisposables(t)}position(e){this.overlay.setBounds(e)}}class et extends _{constructor(e,t,i){super(),this.id=e,this.className=t,this.options=i,this._onDidClose=new v,this.onDidClose=this._onDidClose.event,this._window=null,this.addDisposables(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(){this._window&&(this._window.disposable.dispose(),this._window.value.close(),this._window=null)}open(e){if(this._window)throw new Error("instance of popout window is already open");const t=`${this.options.url}`,i=Object.entries({top:this.options.top,left:this.options.left,width:this.options.width,height:this.options.height}).map((([e,t])=>`${e}=${t}`)).join(","),n=window.open(t,this.id,i);if(!n)return;const s=new _;this._window={value:n,disposable:s};const o=()=>{this._onDidClose.fire(),this._window=null};s.addDisposables(g(window,"beforeunload",(()=>{o(),this.close()}))),n.addEventListener("load",(()=>{const t=n.document;t.title=document.title;const i=document.createElement("div");i.classList.add("dv-popout-window"),i.style.position="absolute",i.style.width="100%",i.style.height="100%",i.style.top="0px",i.style.left="0px",i.classList.add(this.className),i.appendChild(e),t.body.replaceChildren(i),t.body.classList.add(this.className),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){}for(const t of i){const i=e.createElement("style");i.appendChild(e.createTextNode(t)),e.head.appendChild(i)}}}(t,window.document.styleSheets),n.addEventListener("beforeunload",(()=>{o()}))}))}}class tt extends _{constructor(e,t,i){var n;super(),this.id=e,this.group=t,this.options=i,this.window=new et(e,null!==(n=i.className)&&void 0!==n?n:"",{url:this.options.popoutUrl,left:this.options.box.left,top:this.options.box.top,width:this.options.box.width,height:this.options.box.height}),t.model.location="popout",this.addDisposables(this.window,{dispose:()=>{t.model.location="grid"}},this.window.onDidClose((()=>{this.dispose()}))),this.window.open(t.element)}}const it=100,nt=100,st=100;class ot extends _{constructor(e){super(),this.element=e,this.map={},this.addDisposables(s.from((()=>{for(const e of Object.values(this.map))e.disposable.dispose(),e.destroy.dispose()})))}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",this.map[t.api.id]={panel:t,disposable:s.NONE,destroy:s.NONE,element:e}}const n=this.map[t.api.id].element;t.view.content.element.parentElement!==n&&n.appendChild(t.view.content.element),n.parentElement!==this.element&&this.element.appendChild(n);const o=()=>{const e=G(i.element),s=G(this.element);n.style.left=e.left-s.left+"px",n.style.top=e.top-s.top+"px",n.style.width=`${e.width}px`,n.style.height=`${e.height}px`,z(n,"dv-render-overlay-float","floating"===t.group.api.location)},r=()=>{t.api.isVisible&&o(),n.style.display=t.api.isVisible?"":"none"},a=new _(new pe(n,{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((e=>{r()})),t.api.onDidDimensionsChange((()=>{t.api.isVisible&&o()})));return this.map[t.api.id].destroy=s.from((()=>{n.removeChild(t.view.content.element),this.element.removeChild(n)})),queueMicrotask((()=>{this.isDisposed||r()})),this.map[t.api.id].disposable.dispose(),this.map[t.api.id].disposable=a,n}}class rt extends Ee{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 activePanel(){const e=this.activeGroup;if(e)return e.activePanel}get renderer(){var e;return null!==(e=this.options.defaultRenderer)&&void 0!==e?e:"onlyWhenVisibile"}constructor(t){var i;super({proportionalLayout:!0,orientation:null!==(i=t.orientation)&&void 0!==i?i:e.Orientation.HORIZONTAL,styles:t.styles,parentElement:t.parentElement,disableAutoResizing:t.disableAutoResizing}),this.nextGroupId=M(),this._deserializer=new Ye(this),this.watermark=null,this._onWillDragPanel=new v,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new v,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new v,this.onDidDrop=this._onDidDrop.event,this._onDidRemovePanel=new v,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new v,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidLayoutFromJSON=new v,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new v,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._floatingGroups=[],this._popoutGroups=[];const n=document.createElement("div");n.className="dv-overlay-render-container",this.gridview.element.appendChild(n),this.overlayRenderContainer=new ot(n),z(this.gridview.element,"dv-dockview",!0),z(this.element,"dv-debug",!!t.debug),this.addDisposables(this.overlayRenderContainer,this._onWillDragPanel,this._onWillDragGroup,this._onDidActivePanelChange,this._onDidAddPanel,this._onDidRemovePanel,this._onDidLayoutFromJSON,this._onDidDrop,e.DockviewEvent.any(this.onDidAddGroup,this.onDidRemoveGroup)((()=>{this.updateWatermark()})),e.DockviewEvent.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidActivePanelChange)((()=>{this._bufferOnDidLayoutChange.fire()})),s.from((()=>{for(const e of[...this._floatingGroups])e.dispose();for(const e of[...this._popoutGroups])e.dispose()}))),this._options=t,this.options.components||(this.options.components={}),this.options.frameworkComponents||(this.options.frameworkComponents={}),this.options.frameworkTabComponents||(this.options.frameworkTabComponents={}),this.options.tabComponents||(this.options.tabComponents={}),this.options.watermarkComponent||this.options.watermarkFrameworkComponent||(this.options.watermarkComponent=Xe);const o=new ce(this.element,{canDisplayOverlay:(t,i)=>{const n=p();return n?n.viewId===this.id&&("center"!==i||0===this.gridview.length):!!this.options.showDndOverlay&&(("center"!==i||0===this.gridview.length)&&this.options.showDndOverlay({nativeEvent:t,position:i,target:e.DockviewDropTargets.Edge,getData:p}))},acceptedTargetZones:["top","bottom","left","right","center"],overlayModel:{activationSize:{type:"pixels",value:10},size:{type:"pixels",value:20}}});this.addDisposables(o.onDrop((e=>{var t;const i=p();i?this.moveGroupOrPanel(this.orthogonalize(e.position),i.groupId,null!==(t=i.panelId)&&void 0!==t?t:void 0,"center"):this._onDidDrop.fire(Object.assign(Object.assign({},e),{api:this._api,group:null,getData:p}))})),o),this._api=new le(this),this.updateWatermark()}addPopoutGroup(e,t){var i;let n,s=null==t?void 0:t.position;if(e instanceof Je)n=this.createGroup(),this.removePanel(e,{removeEmptyGroup:!0,skipDispose:!0}),n.model.openPanel(e),s||(s=this.element.getBoundingClientRect());else{n=e,s||(s=n.element.getBoundingClientRect());"boolean"==typeof(null==t?void 0:t.skipRemoveGroup)&&t.skipRemoveGroup||this.doRemoveGroup(e,{skipDispose:!0})}const o=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,n=e;for(;null!==n&&(i=t(n).find((e=>e.startsWith("dockview-theme-"))),"string"!=typeof i);)n=n.parentElement;return i}(this.gridview.element),r=new tt(`${this.id}-${n.id}`,n,{className:null!=o?o:"",popoutUrl:null!==(i=null==t?void 0:t.popoutUrl)&&void 0!==i?i:"/popout.html",box:{left:window.screenX+s.left,top:window.screenY+s.top,width:s.width,height:s.height}});r.addDisposables({dispose:()=>{R(this._popoutGroups,r),this.updateWatermark()}},r.window.onDidClose((()=>{this.doAddGroup(n,[0])}))),this._popoutGroups.push(r),this.updateWatermark()}addFloatingGroup(e,t,i){var n,s,o,r,a,h;let d;if(e instanceof Je)d=this.createGroup(),this.removePanel(e,{removeEmptyGroup:!0,skipDispose:!0}),d.model.openPanel(e);else{d=e;"boolean"==typeof(null==i?void 0:i.skipRemoveGroup)&&i.skipRemoveGroup||this.doRemoveGroup(e,{skipDispose:!0})}d.model.location="floating";const l="number"==typeof(null==t?void 0:t.x)?Math.max(t.x,0):nt,p="number"==typeof(null==t?void 0:t.y)?Math.max(t.y,0):st,m=new qe({container:this.gridview.element,content:d.element,height:null!==(n=null==t?void 0:t.height)&&void 0!==n?n:300,width:null!==(s=null==t?void 0:t.width)&&void 0!==s?s:300,left:l,top:p,minimumInViewportWidth:"boundedWithinViewport"===this.options.floatingGroupBounds?void 0:null!==(r=null===(o=this.options.floatingGroupBounds)||void 0===o?void 0:o.minimumWidthWithinViewport)&&void 0!==r?r:it,minimumInViewportHeight:"boundedWithinViewport"===this.options.floatingGroupBounds?void 0:null!==(h=null===(a=this.options.floatingGroupBounds)||void 0===a?void 0:a.minimumHeightWithinViewport)&&void 0!==h?h:it}),u=d.element.querySelector(".void-container");if(!u)throw new Error("failed to find drag handle");m.setupDrag(u,{inDragMode:"boolean"==typeof(null==i?void 0:i.inDragMode)&&i.inDragMode});const c=new Qe(d,m),v=C(d.element,(e=>{const{width:t,height:i}=e.contentRect;d.layout(t,i)}));c.addDisposables(m.onDidChange((()=>{d.layout(d.height,d.width)})),m.onDidChangeEnd((()=>{this._bufferOnDidLayoutChange.fire()})),d.onDidChange((e=>{m.setBounds({height:null==e?void 0:e.height,width:null==e?void 0:e.width})})),{dispose:()=>{v.dispose(),d.model.location="grid",R(this._floatingGroups,c),this.updateWatermark()}}),this._floatingGroups.push(c),this.updateWatermark()}orthogonalize(t){switch(t){case"top":case"bottom":this.gridview.orientation===e.Orientation.HORIZONTAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case"left":case"right":this.gridview.orientation===e.Orientation.VERTICAL&&this.gridview.insertOrthogonalSplitviewAtRoot()}switch(t){case"top":case"left":case"center":return this.createGroupAtLocation([0]);case"bottom":case"right":return this.createGroupAtLocation([this.gridview.length]);default:throw new Error(`unsupported position ${t}`)}}updateOptions(e){var t,i;const n="string"==typeof e.orientation&&this.gridview.orientation!==e.orientation,s=void 0!==e.floatingGroupBounds&&e.floatingGroupBounds!==this.options.floatingGroupBounds;if(this._options=Object.assign(Object.assign({},this.options),e),n&&(this.gridview.orientation=e.orientation),s)for(const e of this._floatingGroups){switch(this.options.floatingGroupBounds){case"boundedWithinViewport":e.overlay.minimumInViewportHeight=void 0,e.overlay.minimumInViewportWidth=void 0;break;case void 0:e.overlay.minimumInViewportHeight=it,e.overlay.minimumInViewportWidth=it;break;default:e.overlay.minimumInViewportHeight=null===(t=this.options.floatingGroupBounds)||void 0===t?void 0:t.minimumHeightWithinViewport,e.overlay.minimumInViewportWidth=null===(i=this.options.floatingGroupBounds)||void 0===i?void 0:i.minimumWidthWithinViewport}e.overlay.setBounds({})}this.layout(this.gridview.width,this.gridview.height,!0)}layout(e,t,i){if(super.layout(e,t,i),this._floatingGroups)for(const e of this._floatingGroups)e.overlay.setBounds()}focus(){var e;null===(e=this.activeGroup)||void 0===e||e.focus()}getGroupPanel(e){return this.panels.find((t=>t.id===e))}setActivePanel(e){this.doSetGroupActive(e.group),e.group.model.openPanel(e)}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),n=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupAndPanelActive(n)}moveToPrevious(e={}){var t;if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[0])return void e.group.model.moveToPrevious({suppressRoll:!0});const i=Q(e.group.element),n=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;n&&this.doSetGroupAndPanelActive(n)}toJSON(){var e;const t=this.gridview.serialize(),i=this.panels.reduce(((e,t)=>(e[t.id]=t.toJSON(),e)),{}),n=this._floatingGroups.map((e=>({data:e.group.toJSON(),position:e.overlay.toJSON()}))),s=this._popoutGroups.map((e=>({data:e.group.toJSON(),position:e.window.dimensions()}))),o={grid:t,panels:i,activeGroup:null===(e=this.activeGroup)||void 0===e?void 0:e.id};return n.length>0&&(o.floatingGroups=n),s.length>0&&(o.popoutGroups=s),o}fromJSON(e){var t,i;if(this.clear(),"object"!=typeof e||null===e)throw new Error("serialized layout must be a non-null object");const{grid:n,panels:s,activeGroup:o}=e;if("branch"!==n.root.type||!Array.isArray(n.root.data))throw new Error("root must be of type branch");try{const r=this.width,a=this.height,h=e=>{const{id:t,locked:i,hideHeader:n,views:o,activeView:r}=e;if("string"!=typeof t)throw new Error("group id must be of type string");const a=this.createGroup({id:t,locked:!!i,hideHeader:!!n}),h=[];for(const e of o){const t=this._deserializer.fromJSON(s[e],a);h.push(t)}this._onDidAddGroup.fire(a);for(let e=0;e<o.length;e++){const t=h[e],i="string"==typeof r&&r===t.id;a.model.openPanel(t,{skipSetPanelActive:!i,skipSetGroupActive:!0})}return!a.activePanel&&a.panels.length>0&&a.model.openPanel(a.panels[a.panels.length-1],{skipSetGroupActive:!0}),a};this.gridview.deserialize(n,{fromJSON:e=>h(e.data)}),this.layout(r,a,!0);const d=null!==(t=e.floatingGroups)&&void 0!==t?t:[];for(const e of d){const{data:t,position:i}=e,n=h(t);this.addFloatingGroup(n,{x:i.left,y:i.top,height:i.height,width:i.width},{skipRemoveGroup:!0,inDragMode:!1})}const l=null!==(i=e.popoutGroups)&&void 0!==i?i:[];for(const e of l){const{data:t,position:i}=e,n=h(t);this.addPopoutGroup(n,{skipRemoveGroup:!0,position:null!=i?i:void 0})}for(const e of this._floatingGroups)e.overlay.setBounds();if("string"==typeof o){const e=this.getPanel(o);e&&this.doSetGroupAndPanelActive(e)}}catch(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._onDidLayoutFromJSON.fire()}clear(){const e=Array.from(this._groups.values()).map((e=>e.value)),t=!!this.activeGroup,i=!!this.activePanel;for(const t of e)this.removeGroup(t,{skipActive:!0});t&&this.doSetGroupAndPanelActive(void 0),i&&this._onDidActivePanelChange.fire(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(`panel with id ${e.id} already exists`);let n,s;if(e.position&&e.floating)throw new Error("you can only provide one of: position, floating as arguments to .addPanel(...)");if(e.position)if(Me(e.position)){const t="string"==typeof e.position.referencePanel?this.getGroupPanel(e.position.referencePanel):e.position.referencePanel;if(!t)throw new Error(`referencePanel ${e.position.referencePanel} does not exist`);n=this.findGroup(t)}else{if(!He(e.position)){const t=this.orthogonalize(me(e.position.direction)),i=this.createPanel(e,t);return t.model.openPanel(i),i}if(n="string"==typeof e.position.referenceGroup?null===(t=this._groups.get(e.position.referenceGroup))||void 0===t?void 0:t.value:e.position.referenceGroup,!n)throw new Error(`referencePanel ${e.position.referenceGroup} does not exist`)}else n=this.activeGroup;if(n){const t=xe((null===(i=e.position)||void 0===i?void 0:i.direction)||"within");if(e.floating){const t=this.createGroup(),i="object"==typeof e.floating&&null!==e.floating?e.floating:{};this.addFloatingGroup(t,i,{inDragMode:!1,skipRemoveGroup:!0}),this._onDidAddGroup.fire(t),s=this.createPanel(e,t),t.model.openPanel(s),this.doSetGroupAndPanelActive(t)}else if("floating"===n.api.location||"center"===t)s=this.createPanel(e,n),n.model.openPanel(s);else{const i=Q(n.element),o=ee(this.gridview.orientation,i,t),r=this.createGroupAtLocation(o);s=this.createPanel(e,r),r.model.openPanel(s)}}else if(e.floating){const t=this.createGroup(),i="object"==typeof e.floating&&null!==e.floating?e.floating:{};this.addFloatingGroup(t,i,{inDragMode:!1,skipRemoveGroup:!0}),this._onDidAddGroup.fire(t),s=this.createPanel(e,t),t.model.openPanel(s),this.doSetGroupAndPanelActive(t)}else{const t=this.createGroupAtLocation();s=this.createPanel(e,t),t.model.openPanel(s)}return s}removePanel(e,t={removeEmptyGroup:!0,skipDispose:!1}){const i=e.group;if(!i)throw new Error(`cannot remove panel ${e.id}. it's missing a group.`);i.model.removePanel(e),t.skipDispose||(this.overlayRenderContainer.detatch(e),e.dispose()),0===i.size&&t.removeEmptyGroup&&this.removeGroup(i)}createWatermarkComponent(){var e;return b("watermark-id","watermark-name",this.options.watermarkComponent?{"watermark-name":this.options.watermarkComponent}:{},this.options.watermarkFrameworkComponent?{"watermark-name":this.options.watermarkFrameworkComponent}:{},null===(e=this.options.frameworkComponentFactory)||void 0===e?void 0:e.watermark)}updateWatermark(){var e,t;if(0===this.groups.filter((e=>"grid"===e.api.location)).length){if(!this.watermark){this.watermark=this.createWatermarkComponent(),this.watermark.init({containerApi:new le(this)});const e=document.createElement("div");e.className="dv-watermark-container",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;const i=this.createGroup();if(e){let n;if(We(e)){const t="string"==typeof e.referencePanel?this.panels.find((t=>t.id===e.referencePanel)):e.referencePanel;if(!t)throw new Error(`reference panel ${e.referencePanel} does not exist`);if(n=this.findGroup(t),!n)throw new Error(`reference group for reference panel ${e.referencePanel} does not exist`)}else{if(!Fe(e)){return this.orthogonalize(me(e.direction))}if(n="string"==typeof e.referenceGroup?null===(t=this._groups.get(e.referenceGroup))||void 0===t?void 0:t.value:e.referenceGroup,!n)throw new Error(`reference group ${e.referenceGroup} does not exist`)}const s=xe(e.direction||"within"),o=Q(n.element),r=ee(this.gridview.orientation,o,s);return this.doAddGroup(i,r),i}return this.doAddGroup(i),i}removeGroup(e,t){var i;const n=[...e.panels];for(const e of n)this.removePanel(e,{removeEmptyGroup:!1,skipDispose:null!==(i=null==t?void 0:t.skipDispose)&&void 0!==i&&i});const s=this.activePanel;this.doRemoveGroup(e,t),this.activePanel!==s&&this._onDidActivePanelChange.fire(this.activePanel)}doRemoveGroup(e,t){if("floating"===e.api.location){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)),R(this._floatingGroups,i),i.dispose(),!(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 i.group}throw new Error("failed to find floating group")}if("popout"===e.api.location){const i=this._popoutGroups.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)),i.dispose(),!(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 i.group}throw new Error("failed to find popout group")}return super.doRemoveGroup(e,t)}moveGroupOrPanel(e,t,i,n,s){var o,r,a;const h=t?null===(o=this._groups.get(t))||void 0===o?void 0:o.value:void 0;if(void 0!==i)if(n&&"center"!==n){const t=Q(e.element),s=ee(this.gridview.orientation,t,n);if(h&&h.size<2){const[t,i]=N(s);if("grid"===h.api.location){const e=Q(h.element),[n,s]=N(e);V(n,t)&&this.gridview.moveView(n,s,i)}const o=this.doRemoveGroup(h,{skipActive:!0,skipDispose:!0}),r=Q(e.element),a=ee(this.gridview.orientation,r,n);this.doAddGroup(o,a)}else{const e=null!==(a=null==h?void 0:h.model.removePanel(i))&&void 0!==a?a:this.panels.find((e=>e.id===i));if(!e)throw new Error(`No panel with id ${i}`);const s=ee(this.gridview.orientation,t,n);this.createGroupAtLocation(s).model.openPanel(e)}}else{const t=null!==(r=null==h?void 0:h.model.removePanel(i))&&void 0!==r?r:this.panels.find((e=>e.id===i));if(!t)throw new Error(`No panel with id ${i}`);0===(null==h?void 0:h.model.size)&&this.doRemoveGroup(h),e.model.openPanel(t,{index:s})}else h&&this.moveGroup(h,e,n)}moveGroup(t,i,n){if(t)if(n&&"center"!==n){switch(t.api.location){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("failed to find floating group");e.dispose();break}case"popout":{const e=this._popoutGroups.find((e=>e.group===t));if(!e)throw new Error("failed to find popout group");e.dispose()}}const s=Q(i.element),o=ee(this.gridview.orientation,s,n);this.gridview.addView(t,e.Sizing.Distribute,o)}else{const e=t.activePanel,n=[...t.panels].map((e=>t.model.removePanel(e.id)));0===(null==t?void 0:t.model.size)&&this.doRemoveGroup(t);for(const t of n)i.model.openPanel(t,{skipSetPanelActive:t!==e})}}doSetGroupAndPanelActive(e,t){var i,n;const s=this.activePanel;super.doSetGroupActive(e,t),(null===(i=this._activeGroup)||void 0===i?void 0:i.activePanel)!==s&&this._onDidActivePanelChange.fire(null===(n=this._activeGroup)||void 0===n?void 0:n.activePanel)}createGroup(e){e||(e={});let t=null==e?void 0:e.id;if(t&&this._groups.has(e.id)&&(console.warn(`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 Te(this,t,e);if(i.init({params:{},accessor:null}),!this._groups.has(i.id)){const e=new _(i.model.onTabDragStart((e=>{this._onWillDragPanel.fire(e)})),i.model.onGroupDragStart((e=>{this._onWillDragGroup.fire(e)})),i.model.onMove((e=>{const{groupId:t,itemId:n,target:s,index:o}=e;this.moveGroupOrPanel(i,t,n,s,o)})),i.model.onDidDrop((e=>{this._onDidDrop.fire(Object.assign(Object.assign({},e),{api:this._api,group:i}))})),i.model.onDidAddPanel((e=>{this._onDidAddPanel.fire(e.panel)})),i.model.onDidRemovePanel((e=>{this._onDidRemovePanel.fire(e.panel)})),i.model.onDidActivePanelChange((e=>{this._onDidActivePanelChange.fire(e.panel)})));this._groups.set(i.id,{value:i,disposable:e})}return i.initialize(),i}createPanel(e,t){var i,n,s;const o=e.component,r=null!==(i=e.tabComponent)&&void 0!==i?i:this.options.defaultTabComponent,a=new Ue(this,e.id,o,r),h=new Je(e.id,this,this._api,t,a,{renderer:e.renderer});return h.init({title:null!==(n=e.title)&&void 0!==n?n:e.id,params:null!==(s=null==e?void 0:e.params)&&void 0!==s?s:{}}),h}createGroupAtLocation(e=[0]){const t=this.createGroup();return this.doAddGroup(t,e),t}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}}class at extends Ee{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){super({parentElement:e.parentElement,proportionalLayout:e.proportionalLayout,orientation:e.orientation,styles:e.styles,disableAutoResizing:e.disableAutoResizing}),this._onDidLayoutfromJSON=new v,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._options=e,this.options.components||(this.options.components={}),this.options.frameworkComponents||(this.options.frameworkComponents={})}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=[],n=this.width,s=this.height;if(this.gridview.deserialize(t,{fromJSON:t=>{var i,n;const{data:s}=t,o=b(s.id,s.component,null!==(i=this.options.components)&&void 0!==i?i:{},null!==(n=this.options.frameworkComponents)&&void 0!==n?n:{},this.options.frameworkComponentFactory?{createComponent:this.options.frameworkComponentFactory.createComponent}:void 0);return e.push((()=>o.init({params:s.params,minimumWidth:s.minimumWidth,maximumWidth:s.maximumWidth,minimumHeight:s.minimumHeight,maximumHeight:s.maximumHeight,priority:s.priority,snap:!!s.snap,accessor:this,isVisible:t.visible}))),this._onDidAddGroup.fire(o),this.registerPanel(o),o}}),this.layout(n,s,!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 n;const s=this.gridview.remove(e),o=null===(i=this._groups.get(t.reference))||void 0===i?void 0:i.value;if(!o)throw new Error(`reference group ${t.reference} does not exist`);const r=xe(t.direction);if("center"===r)throw new Error(`${r} not supported as an option`);{const e=Q(o.element);n=ee(this.gridview.orientation,e,r)}this.doAddGroup(s,n,t.size)}addPanel(e){var t,i,n,s,o,r;let a=null!==(t=e.location)&&void 0!==t?t:[0];if(null===(i=e.position)||void 0===i?void 0:i.referencePanel){const t=null===(n=this._groups.get(e.position.referencePanel))||void 0===n?void 0:n.value;if(!t)throw new Error(`reference group ${e.position.referencePanel} does not exist`);const i=xe(e.position.direction);if("center"===i)throw new Error(`${i} not supported as an option`);{const e=Q(t.element);a=ee(this.gridview.orientation,e,i)}}const h=b(e.id,e.component,null!==(s=this.options.components)&&void 0!==s?s:{},null!==(o=this.options.frameworkComponents)&&void 0!==o?o:{},this.options.frameworkComponentFactory?{createComponent:this.options.frameworkComponentFactory.createComponent}:void 0);return h.init({params:null!==(r=e.params)&&void 0!==r?r:{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.registerPanel(h),this.doAddGroup(h,a,e.size),h}registerPanel(e){const t=new _(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 n=this.getPanel(t);if(!n)throw new Error("invalid operation");const s=Q(e.element),o=ee(this.gridview.orientation,s,i),[r,a]=N(o),h=Q(n.element),[d,l]=N(h);if(V(d,r))return void this.gridview.moveView(d,l,a);const p=this.doRemoveGroup(n,{skipActive:!0,skipDispose:!0}),m=Q(e.element),u=ee(this.gridview.orientation,m,i);this.doAddGroup(p,u)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}}class ht extends Se{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=e,this._splitviewChangeDisposable.value=new _(this._splitview.onDidSashEnd((()=>{this._onDidLayoutChange.fire(void 0)})),this._splitview.onDidAddView((e=>this._onDidAddView.fire(e))),this._splitview.onDidRemoveView((e=>this._onDidRemoveView.fire(e))))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation===e.Orientation.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===e.Orientation.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}constructor(e){super(e.parentElement,e.disableAutoResizing),this._splitviewChangeDisposable=new D,this._panels=new Map,this._onDidLayoutfromJSON=new v,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new v,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new v,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new v,this.onDidLayoutChange=this._onDidLayoutChange.event,this._options=e,e.components||(e.components={}),e.frameworkComponents||(e.frameworkComponents={}),this.splitview=new $(this.element,e),this.addDisposables(this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange)}updateOptions(e){const t="string"==typeof e.orientation&&this.options.orientation!==e.orientation;this._options=Object.assign(Object.assign({},this.options),e),t&&(this.splitview.orientation=e.orientation),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 n=this.panels.findIndex((t=>t===e));this.splitview.removeView(n,t).dispose();const s=this.panels;s.length>0&&this.setActive(s[s.length-1])}getPanel(e){return this.panels.find((t=>t.id===e))}addPanel(t){var i,n,s;if(this._panels.has(t.id))throw new Error(`panel ${t.id} already exists`);const o=b(t.id,t.component,null!==(i=this.options.components)&&void 0!==i?i:{},null!==(n=this.options.frameworkComponents)&&void 0!==n?n:{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.createComponent}:void 0);o.orientation=this.splitview.orientation,o.init({params:null!==(s=t.params)&&void 0!==s?s:{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:t.snap,priority:t.priority,accessor:this});const r="number"==typeof t.size?t.size:e.Sizing.Distribute,a="number"==typeof t.index?t.index:void 0;return this.splitview.addView(o,r,a),this.doAddView(o),this.setActive(o),o}layout(t,i){const[n,s]=this.splitview.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.splitview.layout(n,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:n,activeView:s}=e,o=[],r=this.width,a=this.height;if(this.splitview=new $(this.element,{orientation:i,proportionalLayout:this.options.proportionalLayout,descriptor:{size:n,views:t.map((e=>{var t,n;const s=e.data;if(this._panels.has(s.id))throw new Error(`panel ${s.id} already exists`);const r=b(s.id,s.component,null!==(t=this.options.components)&&void 0!==t?t:{},null!==(n=this.options.frameworkComponents)&&void 0!==n?n:{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.createComponent}:void 0);return o.push((()=>{var t;r.init({params:null!==(t=s.params)&&void 0!==t?t:{},minimumSize:s.minimumSize,maximumSize:s.maximumSize,snap:e.snap,priority:e.priority,accessor:this})})),r.orientation=i,this.doAddView(r),setTimeout((()=>{this._onDidAddView.fire(r)}),0),{size:e.size,view:r}}))}}),this.layout(r,a),o.forEach((e=>e())),"string"==typeof s){const e=this.getPanel(s);e&&this.setActive(e)}this._onDidLayoutfromJSON.fire()}clear(){for(const e of this._panels.values())e.dispose();for(this._panels.clear();this.splitview.length>0;){this.splitview.removeView(0,e.Sizing.Distribute,!0).dispose()}}dispose(){for(const e of this._panels.values())e.dispose();this._panels.clear();const e=this.splitview.getViews();this._splitviewChangeDisposable.dispose(),this.splitview.dispose();for(const t of e)t.dispose();super.dispose()}}class dt extends _{get element(){return this._element}constructor(){super(),this._expandedIcon=je({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=je({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"}),this.disposable=new D,this.apiRef={api:null},this._element=document.createElement("div"),this.element.className="default-header",this._content=document.createElement("span"),this._expander=document.createElement("div"),this._expander.className="dockview-pane-header-icon",this.element.appendChild(this._expander),this.element.appendChild(this._content),this.addDisposables(w(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);z(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 lt=M();class pt extends Ne{constructor(e){super(e.accessor,e.id,e.component,e.headerComponent,e.orientation,e.isExpanded,e.disableDnd),this.options=e}getBodyComponent(){return this.options.body}getHeaderComponent(){return this.options.header}}class mt extends Se{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new _(this._paneview.onDidChange((()=>{this._onDidLayoutChange.fire(void 0)})),this._paneview.onDidAddView((e=>this._onDidAddView.fire(e))),this._paneview.onDidRemoveView((e=>this._onDidRemoveView.fire(e))))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation===e.Orientation.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===e.Orientation.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(t){super(t.parentElement,t.disableAutoResizing),this._id=lt.next(),this._disposable=new D,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new v,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new v,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new v,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new v,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new v,this.onDidRemoveView=this._onDidRemoveView.event,this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView),this._options=t,t.components||(t.components={}),t.frameworkComponents||(t.frameworkComponents={}),this.paneview=new Z(this.element,{orientation:e.Orientation.VERTICAL}),this.addDisposables(this._disposable)}focus(){}updateOptions(e){this._options=Object.assign(Object.assign({},this.options),e)}addPanel(t){var i,n,s,o;const r=b(t.id,t.component,null!==(i=this.options.components)&&void 0!==i?i:{},null!==(n=this.options.frameworkComponents)&&void 0!==n?n:{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.body.createComponent}:void 0);let a;a=t.headerComponent?b(t.id,t.headerComponent,null!==(s=this.options.headerComponents)&&void 0!==s?s:{},this.options.headerframeworkComponents,this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.header.createComponent}:void 0):new dt;const h=new pt({id:t.id,component:t.component,headerComponent:t.headerComponent,header:a,body:r,orientation:e.Orientation.VERTICAL,isExpanded:!!t.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this});this.doAddPanel(h);const d="number"==typeof t.size?t.size:e.Sizing.Distribute,l="number"==typeof t.index?t.index:void 0;return h.init({params:null!==(o=t.params)&&void 0!==o?o:{},minimumBodySize:t.minimumBodySize,maximumBodySize:t.maximumBodySize,isExpanded:t.isExpanded,title:t.title,containerApi:new he(this)}),this.paneview.addPane(h,d,l),h.orientation=this.paneview.orientation,h}removePanel(e){const t=this.panels.findIndex((t=>t===e));this.paneview.removePane(t),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find((t=>t.id===e))}layout(t,i){const[n,s]=this.paneview.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.paneview.layout(n,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:(n=t.minimumBodySize,n<=0?void 0:n),maximumSize:e(t.maximumBodySize),expanded:t.isExpanded()};var n})),size:this.paneview.size}}fromJSON(t){this.clear();const{views:i,size:n}=t,s=[],o=this.width,r=this.height;this.paneview=new Z(this.element,{orientation:e.Orientation.VERTICAL,descriptor:{size:n,views:i.map((t=>{var i,n,o,r;const a=t.data,h=b(a.id,a.component,null!==(i=this.options.components)&&void 0!==i?i:{},null!==(n=this.options.frameworkComponents)&&void 0!==n?n:{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.body.createComponent}:void 0);let d;d=a.headerComponent?b(a.id,a.headerComponent,null!==(o=this.options.headerComponents)&&void 0!==o?o:{},null!==(r=this.options.headerframeworkComponents)&&void 0!==r?r:{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.header.createComponent}:void 0):new dt;const l=new pt({id:a.id,component:a.component,headerComponent:a.headerComponent,header:d,body:h,orientation:e.Orientation.VERTICAL,isExpanded:!!t.expanded,disableDnd:!!this.options.disableDnd,accessor:this});return this.doAddPanel(l),s.push((()=>{var e;l.init({params:null!==(e=a.params)&&void 0!==e?e:{},minimumBodySize:t.minimumSize,maximumBodySize:t.maximumSize,title:a.title,isExpanded:!!t.expanded,containerApi:new he(this)}),l.orientation=this.paneview.orientation})),setTimeout((()=>{this._onDidAddView.fire(l)}),0),{size:t.size,view:l}}))}}),this.layout(o,r),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=e.onDidDrop((e=>{this._onDidDrop.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.paneview.dispose()}}class ut extends Oe{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 Pe(e)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=Number.POSITIVE_INFINITY,this._minimumSize=0,this._maximumSize=Number.POSITIVE_INFINITY,this._snap=!1,this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this.api.initialize(this),this.addDisposables(this._onDidChange,this.api.onVisibilityChange((e=>{const{isVisible:t}=e,{accessor:i}=this._params;i.setVisible(this,t)})),this.api.onActiveChange((()=>{const{accessor:e}=this._params;e.setActive(this)})),this.api.onDidConstraintsChangeInternal((e=>{"number"!=typeof e.minimumSize&&"function"!=typeof e.minimumSize||(this._minimumSize=e.minimumSize),"number"!=typeof e.maximumSize&&"function"!=typeof e.maximumSize||(this._maximumSize=e.maximumSize),this.updateConstraints()})),this.api.onDidSizeChange((e=>{this._onDidChange.fire({size:e.size})})))}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(t,i){const[n,s]=this.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];super.layout(n,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})}}const ct=(e,t)=>{const[i,n]=o.useState(),s=o.useRef(e.componentProps);return o.useImperativeHandle(t,(()=>({update:e=>{s.current=Object.assign(Object.assign({},s.current),e),n(Date.now())}})),[]),o.createElement(e.component,s.current)};ct.displayName="DockviewReactJsBridge";const vt=(()=>{let e=1;return{next:()=>`dockview_react_portal_key_${(e++).toString()}`}})(),gt=o.createContext({});class wt{constructor(e,t,i,n,s){this.parent=e,this.portalStore=t,this.component=i,this.parameters=n,this.context=s,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw new Error("invalid operation: resource is already disposed");this.componentInstance?this.componentInstance.update(e):this._initialProps=Object.assign(Object.assign({},this._initialProps),e)}createPortal(){if(this.disposed)throw new Error("invalid operation: resource is already disposed");if("function"!=typeof this.component)throw new Error("Invalid Operation. dockview only supports React Functional Components.");const e=o.createElement(o.forwardRef(ct),{component:this.component,componentProps:this.parameters,ref:e=>{this.componentInstance=e,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),t=this.context?o.createElement(gt.Provider,{value:this.context},e):e,i=r.createPortal(t,this.parent,vt.next());this.ref={portal:i,disposable:this.portalStore.addPortal(i)}}dispose(){var e;null===(e=this.ref)||void 0===e||e.disposable.dispose(),this.disposed=!0}}const ft=()=>{const[e,t]=o.useState([]);o.useDebugValue(`Portal count: ${e.length}`);return[e,o.useCallback((e=>{t((t=>[...t,e]));let i=!1;return{dispose:()=>{if(i)throw new Error("invalid operation: resource already disposed");i=!0,t((t=>t.filter((t=>t!==e))))}}}),[])]};class _t{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._onDidFocus=new v,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new v,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dockview-react-part"}focus(){}init(e){this.part=new wt(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;null===(t=this.part)||void 0===t||t.update(e.params)}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),null===(e=this.part)||void 0===e||e.dispose()}}class Dt{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dockview-react-part"}focus(){}init(e){this.part=new wt(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;null===(t=this.part)||void 0===t||t.update(e.params)}layout(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class bt{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dockview-react-part"}init(e){this.part=new wt(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi,close:()=>{e.group&&e.containerApi.removeGroup(e.group)}})}focus(){}update(e){var t,i,n;this.parameters&&(this.parameters.params=e.params),null===(t=this.part)||void 0===t||t.update({params:null!==(n=null===(i=this.parameters)||void 0===i?void 0:i.params)&&void 0!==n?n:{}})}layout(e,t){}updateParentGroup(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class Ct{get element(){return this._element}get part(){return this._part}get group(){return this._group}constructor(e,t,i){this.component=e,this.reactPortalStore=t,this._group=i,this.mutableDisposable=new D,this._element=document.createElement("div"),this._element.className="dockview-react-part"}focus(){}init(e){this.mutableDisposable.value=new _(this._group.model.onDidAddPanel((()=>{this.updatePanels()})),this._group.model.onDidRemovePanel((()=>{this.updatePanels()})),this._group.model.onDidActivePanelChange((()=>{this.updateActivePanel()})),e.api.onDidActiveChange((()=>{this.updateGroupActive()}))),this._part=new wt(this.element,this.reactPortalStore,this.component,{api:e.api,containerApi:e.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group})}update(e){var t;null===(t=this._part)||void 0===t||t.update(e.params)}dispose(){var e;this.mutableDisposable.dispose(),null===(e=this._part)||void 0===e||e.dispose()}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}}function yt(e,t){return e?i=>new Ct(e,t,i):void 0}const St="props.defaultTabComponent",zt=o.forwardRef(((e,t)=>{const i=o.useRef(null),n=o.useRef(),[s,r]=ft();return o.useImperativeHandle(t,(()=>i.current),[]),o.useEffect((()=>{var t;if(!i.current)return()=>{};const s={content:{createComponent:(e,t,i)=>new _t(t,i,{addPortal:r})},tab:{createComponent:(e,t,i)=>new Dt(t,i,{addPortal:r})},watermark:{createComponent:(e,t,i)=>new bt(t,i,{addPortal:r})}},o=null!==(t=e.tabComponents)&&void 0!==t?t:{};e.defaultTabComponent&&(o[St]=e.defaultTabComponent);const a=new rt({parentElement:i.current,frameworkComponentFactory:s,frameworkComponents:e.components,disableAutoResizing:e.disableAutoResizing,frameworkTabComponents:o,watermarkFrameworkComponent:e.watermarkComponent,defaultTabComponent:e.defaultTabComponent?St:void 0,styles:e.hideBorders?{separatorBorder:"transparent"}:void 0,showDndOverlay:e.showDndOverlay,createLeftHeaderActionsElement:yt(e.leftHeaderActionsComponent,{addPortal:r}),createRightHeaderActionsElement:yt(e.rightHeaderActionsComponent,{addPortal:r}),createPrefixHeaderActionsElement:yt(e.prefixHeaderActionsComponent,{addPortal:r}),singleTabMode:e.singleTabMode,disableFloatingGroups:e.disableFloatingGroups,floatingGroupBounds:e.floatingGroupBounds,defaultRenderer:e.defaultRenderer,debug:e.debug}),{clientWidth:h,clientHeight:d}=i.current;return a.layout(h,d),e.onReady&&e.onReady({api:new le(a)}),n.current=a,()=>{a.dispose()}}),[]),o.useEffect((()=>{if(!n.current)return()=>{};const t=n.current.onDidDrop((t=>{e.onDidDrop&&e.onDidDrop(t)}));return()=>{t.dispose()}}),[e.onDidDrop]),o.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:e.components})}),[e.components]),o.useEffect((()=>{n.current&&n.current.updateOptions({floatingGroupBounds:e.floatingGroupBounds})}),[e.floatingGroupBounds]),o.useEffect((()=>{n.current&&n.current.updateOptions({watermarkFrameworkComponent:e.watermarkComponent})}),[e.watermarkComponent]),o.useEffect((()=>{n.current&&n.current.updateOptions({showDndOverlay:e.showDndOverlay})}),[e.showDndOverlay]),o.useEffect((()=>{n.current&&n.current.updateOptions({frameworkTabComponents:e.tabComponents})}),[e.tabComponents]),o.useEffect((()=>{n.current&&n.current.updateOptions({disableFloatingGroups:e.disableFloatingGroups})}),[e.disableFloatingGroups]),o.useEffect((()=>{var t;if(!n.current)return;const i=null!==(t=e.tabComponents)&&void 0!==t?t:{};e.defaultTabComponent&&(i[St]=e.defaultTabComponent),n.current.updateOptions({defaultTabComponent:e.defaultTabComponent?St:void 0,frameworkTabComponents:i})}),[e.defaultTabComponent]),o.useEffect((()=>{n.current&&n.current.updateOptions({createRightHeaderActionsElement:yt(e.rightHeaderActionsComponent,{addPortal:r})})}),[e.rightHeaderActionsComponent]),o.useEffect((()=>{n.current&&n.current.updateOptions({createLeftHeaderActionsElement:yt(e.leftHeaderActionsComponent,{addPortal:r})})}),[e.leftHeaderActionsComponent]),o.useEffect((()=>{n.current&&n.current.updateOptions({createPrefixHeaderActionsElement:yt(e.prefixHeaderActionsComponent,{addPortal:r})})}),[e.prefixHeaderActionsComponent]),o.createElement("div",{className:e.className,style:{height:"100%",width:"100%"},ref:i},s)}));zt.displayName="DockviewComponent","function"==typeof SuppressedError&&SuppressedError;const xt=()=>o.createElement("svg",{height:"11",width:"11",viewBox:"0 0 28 28","aria-hidden":"false",focusable:!1,className:"dockview-svg"},o.createElement("path",{d:"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"}));class Et extends ut{constructor(e,t,i,n){super(e,t),this.reactComponent=i,this.reactPortalStore=n}getComponent(){var e,t;return new wt(this.element,this.reactPortalStore,this.reactComponent,{params:null!==(t=null===(e=this._params)||void 0===e?void 0:e.params)&&void 0!==t?t:{},api:this.api,containerApi:new ae(this._params.accessor)})}}const At=o.forwardRef(((t,i)=>{const n=o.useRef(null),s=o.useRef(),[r,a]=ft();return o.useImperativeHandle(i,(()=>n.current),[]),o.useEffect((()=>{var i;const o=new ht({parentElement:n.current,disableAutoResizing:t.disableAutoResizing,orientation:null!==(i=t.orientation)&&void 0!==i?i:e.Orientation.HORIZONTAL,frameworkComponents:t.components,frameworkWrapper:{createComponent:(e,t,i)=>new Et(e,t,i,{addPortal:a})},proportionalLayout:"boolean"!=typeof t.proportionalLayout||t.proportionalLayout,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0}),{clientWidth:r,clientHeight:h}=n.current;return o.layout(r,h),t.onReady&&t.onReady({api:new ae(o)}),s.current=o,()=>{o.dispose()}}),[]),o.useEffect((()=>{s.current&&s.current.updateOptions({frameworkComponents:t.components})}),[t.components]),o.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:n},r)}));At.displayName="SplitviewComponent";class Pt extends Le{constructor(e,t,i,n){super(e,t),this.reactComponent=i,this.reactPortalStore=n}getComponent(){var e,t;return new wt(this.element,this.reactPortalStore,this.reactComponent,{params:null!==(t=null===(e=this._params)||void 0===e?void 0:e.params)&&void 0!==t?t:{},api:this.api,containerApi:new de(this._params.accessor)})}}const It=o.forwardRef(((t,i)=>{const n=o.useRef(null),s=o.useRef(),[r,a]=ft();return o.useImperativeHandle(i,(()=>n.current),[]),o.useEffect((()=>{var i;if(!n.current)return()=>{};const o=new at({parentElement:n.current,disableAutoResizing:t.disableAutoResizing,proportionalLayout:"boolean"!=typeof t.proportionalLayout||t.proportionalLayout,orientation:null!==(i=t.orientation)&&void 0!==i?i:e.Orientation.HORIZONTAL,frameworkComponents:t.components,frameworkComponentFactory:{createComponent:(e,t,i)=>new Pt(e,t,i,{addPortal:a})},styles:t.hideBorders?{separatorBorder:"transparent"}:void 0}),{clientWidth:r,clientHeight:h}=n.current;return o.layout(r,h),t.onReady&&t.onReady({api:new de(o)}),s.current=o,()=>{o.dispose()}}),[]),o.useEffect((()=>{s.current&&s.current.updateOptions({frameworkComponents:t.components})}),[t.components]),o.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:n},r)}));It.displayName="GridviewComponent";class Ot{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new wt(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;null===(t=this.part)||void 0===t||t.update(e.params)}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}const Gt=o.forwardRef(((e,t)=>{const i=o.useRef(null),n=o.useRef(),[s,r]=ft();return o.useImperativeHandle(t,(()=>i.current),[]),o.useEffect((()=>{const t=(e,t,i)=>new Ot(e,i,{addPortal:r}),s=new mt({parentElement:i.current,disableAutoResizing:e.disableAutoResizing,frameworkComponents:e.components,components:{},headerComponents:{},disableDnd:e.disableDnd,headerframeworkComponents:e.headerComponents,frameworkWrapper:{header:{createComponent:t},body:{createComponent:t}},showDndOverlay:e.showDndOverlay}),o=new he(s),{clientWidth:a,clientHeight:h}=i.current;return s.layout(a,h),e.onReady&&e.onReady({api:o}),n.current=s,()=>{s.dispose()}}),[]),o.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:e.components})}),[e.components]),o.useEffect((()=>{n.current&&n.current.updateOptions({headerframeworkComponents:e.headerComponents})}),[e.headerComponents]),o.useEffect((()=>{if(!n.current)return()=>{};const t=n.current,i=t.onDidDrop((i=>{e.onDidDrop&&e.onDidDrop(Object.assign(Object.assign({},i),{api:new he(t)}))}));return()=>{i.dispose()}}),[e.onDidDrop]),o.useEffect((()=>{n.current&&n.current.updateOptions({showDndOverlay:e.showDndOverlay})}),[e.showDndOverlay]),o.createElement("div",{className:e.className,style:{height:"100%",width:"100%"},ref:i},s)}));Gt.displayName="PaneviewComponent",e.BaseGrid=Ee,e.ContentContainer=ge,e.DefaultDockviewDeserialzier=Ye,e.DefaultTab=Ze,e.DockviewApi=le,e.DockviewComponent=rt,e.DockviewCompositeDisposable=_,e.DockviewDefaultTab=e=>{var{api:t,containerApi:i,params:n,hideClose:s,closeActionOverride:r}=e,a=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(i[n[s]]=e[n[s]])}return i}(e,["api","containerApi","params","hideClose","closeActionOverride"]);const h=o.useCallback((e=>{e.preventDefault(),r?r():t.close()}),[t,r]),d=o.useCallback((e=>{e.preventDefault()}),[]),l=o.useCallback((e=>{e.defaultPrevented||(t.setActive(),a.onClick&&a.onClick(e))}),[t,a.onClick]);return o.createElement("div",Object.assign({"data-testid":"dockview-default-tab"},a,{onClick:l,className:"dockview-react-tab"}),o.createElement("span",{className:"dockview-react-tab-title"},t.title),!s&&o.createElement("div",{className:"dv-react-tab-close-btn",onMouseDown:d,onClick:h},o.createElement(xt,null)))},e.DockviewEmitter=v,e.DockviewGroupPanel=Te,e.DockviewGroupPanelModel=ye,e.DockviewMutableDisposable=D,e.DockviewPanel=Je,e.DockviewReact=zt,e.DraggablePaneviewPanel=Ne,e.Gridview=re,e.GridviewApi=de,e.GridviewComponent=at,e.GridviewPanel=Le,e.GridviewReact=It,e.LocalSelectionTransfer=l,e.PaneFramework=pt,e.PaneTransfer=d,e.PanelTransfer=h,e.Paneview=Z,e.PaneviewApi=he,e.PaneviewComponent=mt,e.PaneviewPanel=Ge,e.PaneviewReact=Gt,e.ReactPart=wt,e.ReactPartContext=gt,e.Splitview=$,e.SplitviewApi=ae,e.SplitviewComponent=ht,e.SplitviewPanel=ut,e.SplitviewReact=At,e.Tab=_e,e.createComponent=b,e.directionToPosition=me,e.getDirectionOrientation=te,e.getGridLocation=Q,e.getLocationOrientation=ie,e.getPaneData=m,e.getPanelData=p,e.getRelativeLocation=ee,e.indexInParent=q,e.isGridBranchNode=se,e.isGroupOptionsWithGroup=Fe,e.isGroupOptionsWithPanel=We,e.isPanelOptionsWithGroup=He,e.isPanelOptionsWithPanel=Me,e.isReactElement=function(e){return!!(null==e?void 0:e.type)},e.orthogonal=ne,e.positionToDirection=ue,e.toTarget=xe,e.usePortalsLifecycle=ft}));
7
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).dockview={},e.React,e.ReactDOM)}(this,(function(e,t,i){"use strict";function n(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var n=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}var s,o=n(t),r=n(i);class a{}class h extends a{constructor(e,t,i){super(),this.viewId=e,this.groupId=t,this.panelId=i}}class d extends a{constructor(e,t){super(),this.viewId=e,this.paneId=t}}class l{constructor(){}static getInstance(){return l.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 p(){const e=l.getInstance();if(e.hasData(h.prototype))return e.getData(h.prototype)[0]}function m(){const e=l.getInstance();if(e.hasData(d.prototype))return e.getData(d.prototype)[0]}l.INSTANCE=new l,e.DockviewEvent=void 0,(e.DockviewEvent||(e.DockviewEvent={})).any=(...e)=>t=>{const i=e.map((e=>e(t)));return{dispose:()=>{i.forEach((e=>{e.dispose()}))}}};class u{static create(){var e;return new u(null!==(e=(new Error).stack)&&void 0!==e?e:"")}constructor(e){this.value=e}print(){console.warn(this.value)}}class c{constructor(e,t){this.callback=e,this.stacktrace=t}}class v{static setLeakageMonitorEnabled(e){e!==v.ENABLE_TRACKING&&v.MEMORY_LEAK_WATCHER.clear(),v.ENABLE_TRACKING=e}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 c(e,v.ENABLE_TRACKING?u.create():void 0);return this._listeners.push(i),{dispose:()=>{const e=this._listeners.indexOf(i);e>-1?this._listeners.splice(e,1):v.ENABLE_TRACKING}}},v.ENABLE_TRACKING&&v.MEMORY_LEAK_WATCHER.add(this._event,u.create())),this._event}fire(e){this._last=e;for(const t of this._listeners)t.callback(e)}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&(v.ENABLE_TRACKING&&queueMicrotask((()=>{var e;for(const t of this._listeners)console.warn(null===(e=t.stacktrace)||void 0===e?void 0:e.print())})),this._listeners=[]),v.ENABLE_TRACKING&&this._event&&v.MEMORY_LEAK_WATCHER.delete(this._event))}}function g(e,t,i,n){return e.addEventListener(t,i,n),{dispose:()=>{e.removeEventListener(t,i,n)}}}function w(e,t,i,n){return e.addEventListener(t,i,n),{dispose:()=>{e.removeEventListener(t,i,n)}}}v.ENABLE_TRACKING=!1,v.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 f{constructor(){this._onFired=new v,this.onEvent=this._onFired.event}fire(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout((()=>{this._onFired.fire(),clearTimeout(this.timer)}))}dispose(){this._onFired.dispose()}}!function(e){e.NONE={dispose:()=>{}},e.from=function(e){return{dispose:()=>{e()}}}}(s||(s={}));class _{get isDisposed(){return this._isDisposed}constructor(...e){this._isDisposed=!1,this._disposables=e}addDisposables(...e){e.forEach((e=>this._disposables.push(e)))}dispose(){this._disposables.forEach((e=>e.dispose())),this._isDisposed=!0}}class D{constructor(){this._disposable=s.NONE}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&(this._disposable.dispose(),this._disposable=s.NONE)}}function b(e,t,i={},n={},s,o){const r="string"==typeof t?i[t]:void 0,a="string"==typeof t?n[t]:void 0;if(r&&a)throw new Error(`Cannot create '${e}'. component '${t}' registered as both a component and frameworkComponent`);if(a){if(!s)throw new Error(`Cannot create '${e}' for framework component '${t}'. you must register a frameworkPanelWrapper to use framework components`);return s.createComponent(e,t,a)}if(!r){if(o)return o();throw new Error(`Cannot create '${e}', no component '${t}' provided`)}return new r(e,t)}function C(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 y=(e,...t)=>{for(const i of t)e.classList.contains(i)&&e.classList.remove(i)},S=(e,...t)=>{for(const i of t)e.classList.contains(i)||e.classList.add(i)},z=(e,t,i)=>{const n=e.classList.contains(t);i&&!n&&e.classList.add(t),!i&&n&&e.classList.remove(t)};function x(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function E(e){return Array.prototype.slice.call(document.getElementsByTagName(e),0)}function A(e){return new P(e)}class P extends _{constructor(e){super(),this._onDidFocus=new v,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new v,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=x(document.activeElement,e),i=!1;const n=()=>{i=!1,t||(t=!0,this._onDidFocus.fire())},s=()=>{t&&(i=!0,window.setTimeout((()=>{i&&(i=!1,t=!1,this._onDidBlur.fire())}),0))};this._refreshStateHandler=()=>{x(document.activeElement,e)!==t&&(t?s():n())},e instanceof HTMLElement?(this.addDisposables(w(e,"focus",n,!0)),this.addDisposables(w(e,"blur",s,!0))):(this.addDisposables(g(e,"focus",n,!0)),this.addDisposables(g(e,"blur",s,!0)))}refreshState(){this._refreshStateHandler()}}const I="dv-quasiPreventDefault";function O(e){return e[I]}function G(e){const{left:t,top:i,width:n,height:s}=e.getBoundingClientRect();return{left:t+window.scrollX,top:i+window.scrollY,width:n,height:s}}function N(e){if(0===e.length)throw new Error("Invalid tail call");return[e.slice(0,e.length-1),e[e.length-1]]}function V(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 L(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.unshift(t))}function k(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.push(t))}function R(e,t){const i=e.findIndex((e=>e===t));return i>-1&&(e.splice(i,1),!0)}const T=(e,t,i)=>{if(t>i)throw new Error(`${t} > ${i} is an invalid condition`);return Math.min(i,Math.max(e,t))},M=()=>{let e=1;return{next:()=>(e++).toString()}},H=(e,t)=>{const i=[];if("number"!=typeof t&&(t=e,e=0),e<=t)for(let n=e;n<t;n++)i.push(n);else for(let n=e;n>t;n--)i.push(n);return i};class W{set size(e){this._size=e}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return void 0===this._cachedVisibleSize}get minimumSize(){return this.visible?this.view.minimumSize:0}get viewMinimumSize(){return this.view.minimumSize}get maximumSize(){return this.visible?this.view.maximumSize:0}get viewMaximumSize(){return this.view.maximumSize}get priority(){return this.view.priority}get snap(){return!!this.view.snap}set enabled(e){this.container.style.pointerEvents=e?"":"none"}constructor(e,t,i,n){this.container=e,this.view=t,this.disposable=n,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=T(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 F,B,J,j;e.Orientation=void 0,(F=e.Orientation||(e.Orientation={})).HORIZONTAL="HORIZONTAL",F.VERTICAL="VERTICAL",e.SashState=void 0,(B=e.SashState||(e.SashState={}))[B.MAXIMUM=0]="MAXIMUM",B[B.MINIMUM=1]="MINIMUM",B[B.DISABLED=2]="DISABLED",B[B.ENABLED=3]="ENABLED",e.LayoutPriority=void 0,(J=e.LayoutPriority||(e.LayoutPriority={})).Low="low",J.High="high",J.Normal="normal",e.Sizing=void 0,(j=e.Sizing||(e.Sizing={})).Distribute={type:"distribute"},j.Split=function(e){return{type:"split",index:e}},j.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(t){this._orientation=t;const i=this.size;this.size=this.orthogonalSize,this.orthogonalSize=i,y(this.element,"horizontal","vertical"),this.element.classList.add(this.orientation==e.Orientation.HORIZONTAL?"horizontal":"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())}constructor(e,t){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._onDidSashEnd=new v,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new v,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new v,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(e,t,i=this.viewItems.map((e=>e.size)),n,s,o=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY,a,h)=>{if(e<0||e>this.viewItems.length)return 0;const d=H(e,-1),l=H(e+1,this.viewItems.length);if(s)for(const e of s)L(d,e),L(l,e);if(n)for(const e of n)k(d,e),k(l,e);const p=d.map((e=>this.viewItems[e])),m=d.map((e=>i[e])),u=l.map((e=>this.viewItems[e])),c=l.map((e=>i[e])),v=d.reduce(((e,t)=>e+this.viewItems[t].minimumSize-i[t]),0),g=d.reduce(((e,t)=>e+this.viewItems[t].maximumSize-i[t]),0),w=0===l.length?Number.POSITIVE_INFINITY:l.reduce(((e,t)=>e+i[t]-this.viewItems[t].minimumSize),0),f=0===l.length?Number.NEGATIVE_INFINITY:l.reduce(((e,t)=>e+i[t]-this.viewItems[t].maximumSize),0),_=Math.max(v,f),D=Math.min(w,g);let b=!1;if(a){const e=this.viewItems[a.index],i=t>=a.limitDelta;b=i!==e.visible,e.setVisible(i,a.size)}if(!b&&h){const e=this.viewItems[h.index],i=t<h.limitDelta;b=i!==e.visible,e.setVisible(i,h.size)}if(b)return this.resize(e,t,i,n,s,o,r);let C=0,y=T(t,_,D);for(let e=0;e<p.length;e++){const t=p[e],i=T(m[e]+y,t.minimumSize,t.maximumSize),n=i-m[e];C+=n,y-=n,t.size=i}let S=C;for(let e=0;e<u.length;e++){const t=u[e],i=T(c[e]-S,t.minimumSize,t.maximumSize);S+=i-c[e],t.size=i}return t},this._orientation=t.orientation,this.element=this.createContainer(),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},n=e.view;this.addView(n,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)?(y(this.element,"separator-border"),this.element.style.removeProperty("--dv-separator-border")):(S(this.element,"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");z(this.container,"visible",t);const i=this.viewItems[e];z(this.container,"visible",t),i.setVisible(t,i.size),this.distributeEmptySpace(e),this.layoutViews(),this.saveProportions()}getViewSize(e){return e<0||e>=this.viewItems.length?-1:this.viewItems[e].size}resizeView(t,i){if(t<0||t>=this.viewItems.length)return;const n=H(this.viewItems.length).filter((e=>e!==t)),s=[...n.filter((t=>this.viewItems[t].priority===e.LayoutPriority.Low)),t],o=n.filter((t=>this.viewItems[t].priority===e.LayoutPriority.High)),r=this.viewItems[t];i=Math.round(i),i=T(i,r.minimumSize,Math.min(r.maximumSize,this._size)),r.size=i,this.relayout(s,o)}getViews(){return this.viewItems.map((e=>e.view))}onDidChange(t,i){const n=this.viewItems.indexOf(t);if(n<0||n>=this.viewItems.length)return;i="number"==typeof i?i:t.size,i=T(i,t.minimumSize,t.maximumSize),t.size=i;const s=H(this.viewItems.length).filter((e=>e!==n)),o=[...s.filter((t=>this.viewItems[t].priority===e.LayoutPriority.Low)),n],r=s.filter((t=>this.viewItems[t].priority===e.LayoutPriority.High));this.relayout([...o,n],r)}addView(t,i={type:"distribute"},n=this.viewItems.length,s){const o=document.createElement("div");let r;o.className="view",o.appendChild(t.element),r="number"==typeof i?i:"split"===i.type?this.getViewSize(i.index)/2:"invisible"===i.type?{cachedVisibleSize:i.cachedVisibleSize}:t.minimumSize;const a=t.onDidChange((e=>this.onDidChange(h,e.size))),h=new W(o,t,r,{dispose:()=>{a.dispose(),this.viewContainer.removeChild(o)}});if(n===this.viewItems.length?this.viewContainer.appendChild(o):this.viewContainer.insertBefore(o,this.viewContainer.children.item(n)),this.viewItems.splice(n,0,h),this.viewItems.length>1){const t=document.createElement("div");t.className="sash";const i=i=>{for(const e of this.viewItems)e.enabled=!1;const n=[...E("iframe"),...E("webview")];for(const e of n)e.style.pointerEvents="none";const s=this._orientation===e.Orientation.HORIZONTAL?i.clientX:i.clientY,o=function(e,t){for(let i=0;i<e.length;i++)if(t(e[i]))return i;return-1}(this.sashes,(e=>e.container===t)),r=this.viewItems.map((e=>e.size));let a,h;const d=H(o,-1),l=H(o+1,this.viewItems.length),p=d.reduce(((e,t)=>e+(this.viewItems[t].minimumSize-r[t])),0),m=d.reduce(((e,t)=>e+(this.viewItems[t].viewMaximumSize-r[t])),0),u=0===l.length?Number.POSITIVE_INFINITY:l.reduce(((e,t)=>e+(r[t]-this.viewItems[t].minimumSize)),0),c=0===l.length?Number.NEGATIVE_INFINITY:l.reduce(((e,t)=>e+(r[t]-this.viewItems[t].viewMaximumSize)),0),v=Math.max(p,c),g=Math.min(u,m),w=this.findFirstSnapIndex(d),f=this.findFirstSnapIndex(l);if("number"==typeof w){const e=this.viewItems[w],t=Math.floor(e.viewMinimumSize/2);a={index:w,limitDelta:e.visible?v-t:v+t,size:e.size}}if("number"==typeof f){const e=this.viewItems[f],t=Math.floor(e.viewMinimumSize/2);h={index:f,limitDelta:e.visible?g+t:g-t,size:e.size}}const _=t=>{const i=(this._orientation===e.Orientation.HORIZONTAL?t.clientX:t.clientY)-s;this.resize(o,i,r,void 0,void 0,v,g,a,h),this.distributeEmptySpace(),this.layoutViews()},D=()=>{for(const e of this.viewItems)e.enabled=!0;for(const e of n)e.style.pointerEvents="auto";this.saveProportions(),document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",D),document.removeEventListener("pointercancel",D),this._onDidSashEnd.fire(void 0)};document.addEventListener("pointermove",_),document.addEventListener("pointerup",D),document.addEventListener("pointercancel",D)};t.addEventListener("pointerdown",i);const n={container:t,disposable:()=>{t.removeEventListener("pointerdown",i),this.sashContainer.removeChild(t)}};this.sashContainer.appendChild(t),this.sashes.push(n)}s||this.relayout([n]),s||"number"==typeof i||"distribute"!==i.type||this.distributeViewSizes(),this._onDidAddView.fire(t)}distributeViewSizes(){const t=[];let i=0;for(const e of this.viewItems)e.maximumSize-e.minimumSize>0&&(t.push(e),i+=e.size);const n=Math.floor(i/t.length);for(const e of t)e.size=T(n,e.minimumSize,e.maximumSize);const s=H(this.viewItems.length),o=s.filter((t=>this.viewItems[t].priority===e.LayoutPriority.Low)),r=s.filter((t=>this.viewItems[t].priority===e.LayoutPriority.High));this.relayout(o,r)}removeView(e,t,i=!1){const n=this.viewItems.splice(e,1)[0];if(n.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(n.view),n.view}getViewCachedVisibleSize(e){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");return this.viewItems[e].cachedVisibleSize}moveView(t,i){const n=this.getViewCachedVisibleSize(t),s=void 0===n?this.getViewSize(t):e.Sizing.Invisible(n),o=this.removeView(t,void 0,!0);this.addView(o,s,i)}layout(t,i){const n=Math.max(this.size,this._contentSize);if(this.size=t,this.orthogonalSize=i,this.proportions){let e=0;for(let i=0;i<this.viewItems.length;i++){const n=this.viewItems[i],s=this.proportions[i];"number"==typeof s?e+=s:t-=n.size}for(let i=0;i<this.viewItems.length;i++){const n=this.viewItems[i],s=this.proportions[i];"number"==typeof s&&e>0&&(n.size=T(Math.round(s*t/e),n.minimumSize,n.maximumSize))}}else{const i=H(this.viewItems.length),s=i.filter((t=>this.viewItems[t].priority===e.LayoutPriority.Low)),o=i.filter((t=>this.viewItems[t].priority===e.LayoutPriority.High));this.resize(this.viewItems.length-1,t-n,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(t){const i=this.viewItems.reduce(((e,t)=>e+t.size),0);let n=this.size-i;const s=H(this.viewItems.length-1,-1),o=s.filter((t=>this.viewItems[t].priority===e.LayoutPriority.Low)),r=s.filter((t=>this.viewItems[t].priority===e.LayoutPriority.High));for(const e of r)L(s,e);for(const e of o)k(s,e);"number"==typeof t&&k(s,t);for(let e=0;0!==n&&e<s.length;e++){const t=this.viewItems[s[e]],i=T(t.size+n,t.minimumSize,t.maximumSize);n-=i-t.size,t.size=i}}saveProportions(){this.proportionalLayout&&this._contentSize>0&&(this._proportions=this.viewItems.map((e=>e.visible?e.size/this._contentSize:void 0)))}layoutViews(){this._contentSize=this.viewItems.reduce(((e,t)=>e+t.size),0);let t=0;const i=[];this.updateSashEnablement();for(let n=0;n<this.viewItems.length-1;n++){t+=this.viewItems[n].size,i.push(t);const s=Math.min(Math.max(0,t-2),this.size-4);this._orientation===e.Orientation.HORIZONTAL&&(this.sashes[n].container.style.left=`${s}px`,this.sashes[n].container.style.top="0px"),this._orientation===e.Orientation.VERTICAL&&(this.sashes[n].container.style.left="0px",this.sashes[n].container.style.top=`${s}px`)}this.viewItems.forEach(((t,n)=>{this._orientation===e.Orientation.HORIZONTAL&&(t.container.style.width=`${t.size}px`,t.container.style.left=0==n?"0px":`${i[n-1]}px`,t.container.style.top="",t.container.style.height=""),this._orientation===e.Orientation.VERTICAL&&(t.container.style.height=`${t.size}px`,t.container.style.top=0==n?"0px":`${i[n-1]}px`,t.container.style.width="",t.container.style.left=""),t.view.layout(t.size,this._orthogonalSize)}))}findFirstSnapIndex(e){for(const t of e){const e=this.viewItems[t];if(e.visible&&e.snap)return t}for(const t of e){const e=this.viewItems[t];if(e.visible&&e.maximumSize-e.minimumSize>0)return;if(!e.visible&&e.snap)return t}}updateSashEnablement(){let t=!1;const i=this.viewItems.map((e=>t=e.size-e.minimumSize>0||t));t=!1;const n=this.viewItems.map((e=>t=e.maximumSize-e.size>0||t)),s=[...this.viewItems].reverse();t=!1;const o=s.map((e=>t=e.size-e.minimumSize>0||t)).reverse();t=!1;const r=s.map((e=>t=e.maximumSize-e.size>0||t)).reverse();let a=0;for(let t=0;t<this.sashes.length;t++){const s=this.sashes[t];a+=this.viewItems[t].size;const h=!(i[t]&&r[t+1]),d=!(n[t]&&o[t+1]);if(h&&d){const n=H(t,-1),r=H(t+1,this.viewItems.length),h=this.findFirstSnapIndex(n),d=this.findFirstSnapIndex(r),l="number"==typeof h&&!this.viewItems[h].visible,p="number"==typeof d&&!this.viewItems[d].visible;l&&o[t]&&(a>0||this.startSnappingEnabled)?this.updateSash(s,e.SashState.MINIMUM):p&&i[t]&&(a<this._contentSize||this.endSnappingEnabled)?this.updateSash(s,e.SashState.MAXIMUM):this.updateSash(s,e.SashState.DISABLED)}else h&&!d?this.updateSash(s,e.SashState.MINIMUM):!h&&d?this.updateSash(s,e.SashState.MAXIMUM):this.updateSash(s,e.SashState.ENABLED)}}updateSash(t,i){z(t.container,"disabled",i===e.SashState.DISABLED),z(t.container,"enabled",i===e.SashState.ENABLED),z(t.container,"maximum",i===e.SashState.MAXIMUM),z(t.container,"minimum",i===e.SashState.MINIMUM)}createViewContainer(){const e=document.createElement("div");return e.className="view-container",e}createSashContainer(){const e=document.createElement("div");return e.className="sash-container",e}createContainer(){const t=document.createElement("div"),i=this._orientation===e.Orientation.HORIZONTAL?"horizontal":"vertical";return t.className=`split-view-container ${i}`,t}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.removeChild(this.element);break}for(const e of this.viewItems)e.dispose();this.element.remove()}}class Z extends _{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(t,i){var n;super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this._orientation=null!==(n=i.orientation)&&void 0!==n?n:e.Orientation.VERTICAL,this.element=document.createElement("div"),this.element.className="pane-container",t.appendChild(this.element),this.splitview=new $(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:i.descriptor}),this.getPanes().forEach((e=>{const t=new _(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()})))}addPane(e,t,i=this.splitview.length,n=!1){const s=e.onDidChangeExpansionState((()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),o={pane:e,disposable:{dispose:()=>{s.dispose()}}};this.paneItems.splice(i,0,o),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,i,n)}getViewSize(e){return this.splitview.getViewSize(e)}getPanes(){return this.splitview.getViews()}removePane(e,t={skipDispose:!1}){const i=this.paneItems.splice(e,1)[0];return this.splitview.removeView(e),t.skipDispose||(i.disposable.dispose(),i.pane.dispose()),i}moveView(e,t){if(e===t)return;const i=this.removePane(e,{skipDispose:!0});this.skipAnimation=!0;try{this.addPane(i.pane,i.pane.size,t,!1)}finally{this.skipAnimation=!1}}layout(e,t){this.splitview.layout(e,t)}setupAnimation(){this.skipAnimation||(this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=void 0),S(this.element,"animated"),this.animationTimer=setTimeout((()=>{this.animationTimer=void 0,y(this.element,"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 U{get minimumWidth(){return this.view.minimumWidth}get maximumWidth(){return this.view.maximumWidth}get minimumHeight(){return this.view.minimumHeight}get maximumHeight(){return this.view.maximumHeight}get priority(){return this.view.priority}get snap(){return this.view.snap}get minimumSize(){return this.orientation===e.Orientation.HORIZONTAL?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===e.Orientation.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumWidth:this.maximumHeight}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get element(){return this.view.element}get width(){return this.orientation===e.Orientation.HORIZONTAL?this.orthogonalSize:this.size}get height(){return this.orientation===e.Orientation.HORIZONTAL?this.size:this.orthogonalSize}constructor(t,i,n,s=0){this.view=t,this.orientation=i,this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this._orthogonalSize=n,this._size=s,this._disposable=this.view.onDidChange((t=>{t?this._onDidChange.fire({size:this.orientation===e.Orientation.VERTICAL?t.width:t.height,orthogonalSize:this.orientation===e.Orientation.VERTICAL?t.height:t.width}):this._onDidChange.fire({})}))}setVisible(e){this.view.setVisible&&this.view.setVisible(e)}layout(e,t){this._size=e,this._orthogonalSize=t,this.view.layout(this.width,this.height)}dispose(){this._onDidChange.dispose(),this._disposable.dispose()}}class Y extends _{get width(){return this.orientation===e.Orientation.HORIZONTAL?this.size:this.orthogonalSize}get height(){return this.orientation===e.Orientation.HORIZONTAL?this.orthogonalSize:this.size}get minimumSize(){return 0===this.children.length?0:Math.max(...this.children.map(((e,t)=>this.splitview.isViewVisible(t)?e.minimumOrthogonalSize:0)))}get maximumSize(){return Math.min(...this.children.map(((e,t)=>this.splitview.isViewVisible(t)?e.maximumOrthogonalSize:Number.POSITIVE_INFINITY)))}get minimumOrthogonalSize(){return this.splitview.minimumSize}get maximumOrthogonalSize(){return this.splitview.maximumSize}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get minimumWidth(){return this.orientation===e.Orientation.HORIZONTAL?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===e.Orientation.HORIZONTAL?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumSize:this.maximumOrthogonalSize}get priority(){if(0===this.children.length)return e.LayoutPriority.Normal;const t=this.children.map((t=>void 0===t.priority?e.LayoutPriority.Normal:t.priority));return t.some((t=>t===e.LayoutPriority.High))?e.LayoutPriority.High:t.some((t=>t===e.LayoutPriority.Low))?e.LayoutPriority.Low:e.LayoutPriority.Normal}constructor(e,t,i,n,o,r){if(super(),this.orientation=e,this.proportionalLayout=t,this.styles=i,this._childrenDisposable=s.NONE,this.children=[],this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new v,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._orthogonalSize=o,this._size=n,this.element=document.createElement("div"),this.element.className="branch-node",r){const e={views:r.map((e=>({view:e.node,size:e.node.size,visible:!(e.node instanceof U&&void 0!==e.visible)||e.visible}))),size:this.orthogonalSize};this.children=r.map((e=>e.node)),this.splitview=new $(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:t,styles:i})}else this.splitview=new $(this.element,{orientation:this.orientation,proportionalLayout:t,styles:i}),this.splitview.layout(this.size,this.orthogonalSize);this.addDisposables(this._onDidChange,this._onDidVisibilityChange,this.splitview.onDidSashEnd((()=>{this._onDidChange.fire({})}))),this.setupChildrenEvents()}setVisible(e){for(const t of this.children)t.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 n=0===this.splitview.contentSize;(t&&i||!t&&n)&&this._onDidVisibilityChange.fire(t)}moveChild(e,t){if(e===t)return;if(e<0||e>=this.children.length)throw new Error("Invalid from index");e<t&&t--,this.splitview.moveView(e,t);const i=this._removeChild(e);this._addChild(i,t)}getChildSize(e){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewSize(e)}resizeChild(e,t){if(e<0||e>=this.children.length)throw new Error("Invalid index");this.splitview.resizeView(e,t)}layout(e,t){this._size=t,this._orthogonalSize=e,this.splitview.layout(t,e)}addChild(e,t,i,n){if(i<0||i>this.children.length)throw new Error("Invalid index");this.splitview.addView(e,t,i,n),this._addChild(e,i)}getChildCachedVisibleSize(e){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewCachedVisibleSize(e)}removeChild(e,t){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.removeView(e,t),this._removeChild(e)}_addChild(e,t){this.children.splice(t,0,e),this.setupChildrenEvents()}_removeChild(e){const[t]=this.children.splice(e,1);return this.setupChildrenEvents(),t}setupChildrenEvents(){this._childrenDisposable.dispose(),this._childrenDisposable=new _(e.DockviewEvent.any(...this.children.map((e=>e.onDidChange)))((e=>{this._onDidChange.fire({size:e.orthogonalSize})})),...this.children.map(((e,t)=>e instanceof Y?e.onDidVisibilityChange((e=>{this.setChildVisible(t,e)})):s.NONE)))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach((e=>e.dispose())),super.dispose()}}function X(e,t){if(e instanceof U)return e;if(e instanceof Y)return X(e.children[t?e.children.length-1:0],t);throw new Error("invalid node")}function K(e,t,i){if(e instanceof Y){const n=new Y(ne(e.orientation),e.proportionalLayout,e.styles,t,i);let s=0;for(let o=e.children.length-1;o>=0;o--){const r=e.children[o],a=r instanceof Y?r.orthogonalSize:r.size;let h=0===e.size?0:Math.round(t*a/e.size);s+=h,0===o&&(h+=t-s),n.addChild(K(r,i,h),h,0,!0)}return n}return new U(e.view,ne(e.orientation),i)}function q(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");let i=t.firstElementChild,n=0;for(;i!==e&&i!==t.lastElementChild&&i;)i=i.nextElementSibling,n++;return n}function Q(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");if(/\bgrid-view\b/.test(t.className))return[];const i=q(t);return[...Q(t.parentElement.parentElement.parentElement),i]}function ee(e,t,i){if(ie(e,t)===te(i)){const[e,n]=N(t);let s=n;return"right"!==i&&"bottom"!==i||(s+=1),[...e,s]}{const e="right"===i||"bottom"===i?1:0;return[...t,e]}}function te(t){return"top"===t||"bottom"===t?e.Orientation.VERTICAL:e.Orientation.HORIZONTAL}function ie(e,t){return t.length%2==0?ne(e):e}const ne=t=>t===e.Orientation.HORIZONTAL?e.Orientation.VERTICAL:e.Orientation.HORIZONTAL;function se(e){return!!e.children}const oe=(t,i)=>{const n=i===e.Orientation.VERTICAL?t.box.width:t.box.height;return se(t)?{type:"branch",data:t.children.map((e=>oe(e,ne(i)))),size:n}:"number"==typeof t.cachedVisibleSize?{type:"leaf",data:t.view.toJSON(),size:t.cachedVisibleSize,visible:!1}:{type:"leaf",data:t.view.toJSON(),size:n}};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=K(this.root,i,t),this.root.layout(t,i)}get width(){return this.root.width}get height(){return this.root.height}get minimumWidth(){return this.root.minimumWidth}get minimumHeight(){return this.root.minimumHeight}get maximumWidth(){return this.root.maximumHeight}get maximumHeight(){return this.root.maximumHeight}maximizedView(){var e;return null===(e=this._maximizedNode)||void 0===e?void 0:e.view}hasMaximizedView(){return void 0!==this._maximizedNode}maximizeView(e){const t=Q(e.element),[i,n]=this.getNode(t);n instanceof U&&this._maximizedNode!==n&&(this.hasMaximizedView()&&this.exitMaximizedView(),function e(t,i){for(let n=0;n<t.children.length;n++){const s=t.children[n];s instanceof U?s!==i&&t.setChildVisible(n,!1):e(s,i)}}(this.root,n),this._maximizedNode=n,this._onDidMaxmizedNodeChange.fire())}exitMaximizedView(){this._maximizedNode&&(!function e(t){for(let i=t.children.length-1;i>=0;i--){const n=t.children[i];n instanceof U?t.setChildVisible(i,!0):e(n)}}(this.root),this._maximizedNode=void 0,this._onDidMaxmizedNodeChange.fire())}serialize(){this.hasMaximizedView()&&this.exitMaximizedView();return{root:oe(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this._onDidMaxmizedNodeChange.dispose(),this.root.dispose(),this._maximizedNode=void 0,this.element.remove()}clear(){const e=this.root.orientation;this.root=new Y(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize)}deserialize(t,i){const n=t.orientation,s=n===e.Orientation.VERTICAL?t.height:t.width;this._deserialize(t.root,n,i,s)}_deserialize(e,t,i,n){this.root=this._deserializeNode(e,t,i,n)}_deserializeNode(e,t,i,n){let s;if("branch"===e.type){const o=e.data.map((n=>({node:this._deserializeNode(n,ne(t),i,e.size),visible:n.visible})));s=new Y(t,this.proportionalLayout,this.styles,e.size,n,o)}else s=new U(i.fromJSON(e),t,n,e.size);return s}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)}))}insertOrthogonalSplitviewAtRoot(){if(!this._root)return;const t=this.root;if(t.element.remove(),this._root=new Y(ne(t.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size),0===t.children.length);else if(1===t.children.length){const i=t.children[0];t.removeChild(0).dispose(),t.dispose(),this._root.addChild(K(i,i.orthogonalSize,i.size),e.Sizing.Distribute,0)}else this._root.addChild(t,e.Sizing.Distribute,0);this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange((e=>{this._onDidChange.fire(e)}))}next(e){return this.progmaticSelect(e)}previous(e){return this.progmaticSelect(e,!0)}getView(e){const t=e?this.getNode(e)[1]:this.root;return this._getViews(t,this.orientation)}_getViews(e,t,i){const n={height:e.height,width:e.width};if(e instanceof U)return{box:n,view:e.view,cachedVisibleSize:i};const s=[];for(let i=0;i<e.children.length;i++){const n=e.children[i],o=e.getChildCachedVisibleSize(i);s.push(this._getViews(n,ne(t),o))}return{box:n,children:s}}progmaticSelect(e,t=!1){const[i,n]=this.getNode(e);if(!(n instanceof U))throw new Error("invalid location");for(let n=i.length-1;n>-1;n--){const s=i[n],o=e[n]||0;if(t?o-1>-1:o+1<s.children.length)return X(s.children[t?o-1:o+1],t)}return X(this.root,t)}constructor(e,t,i){this.proportionalLayout=e,this.styles=t,this._maximizedNode=void 0,this.disposable=new D,this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this._onDidMaxmizedNodeChange=new v,this.onDidMaxmizedNodeChange=this._onDidMaxmizedNodeChange.event,this.element=document.createElement("div"),this.element.className="grid-view",this.root=new Y(i,e,t,0,0)}isViewVisible(e){const[t,i]=N(e),[,n]=this.getNode(t);if(!(n instanceof Y))throw new Error("Invalid from location");return n.isChildVisible(i)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,n]=N(e),[,s]=this.getNode(i);if(!(s instanceof Y))throw new Error("Invalid from location");s.setChildVisible(n,t)}moveView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[,n]=this.getNode(e);if(!(n instanceof Y))throw new Error("Invalid location");n.moveChild(t,i)}addView(t,i,n){this.hasMaximizedView()&&this.exitMaximizedView();const[s,o]=N(n),[r,a]=this.getNode(s);if(a instanceof Y){const e=new U(t,ne(a.orientation),a.orthogonalSize);a.addChild(e,i,o)}else{const[n,...h]=[...r].reverse(),[d,...l]=[...s].reverse();let p=0;const m=n.getChildCachedVisibleSize(d);"number"==typeof m&&(p=e.Sizing.Invisible(m));n.removeChild(d).dispose();const u=new Y(a.orientation,this.proportionalLayout,this.styles,a.size,a.orthogonalSize);n.addChild(u,a.size,d);const c=new U(a.view,n.orientation,a.size);u.addChild(c,p,0),"number"!=typeof i&&"split"===i.type&&(i={type:"split",index:0});const v=new U(t,n.orientation,a.size);u.addChild(v,i,o)}}remove(e,t){const i=Q(e.element);return this.removeView(i,t)}removeView(t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[n,s]=N(t),[o,r]=this.getNode(n);if(!(r instanceof Y))throw new Error("Invalid location");const a=r.children[s];if(!(a instanceof U))throw new Error("Invalid location");if(r.removeChild(s,i),a.dispose(),1!==r.children.length)return a.view;const h=r.children[0];if(0===o.length)return h instanceof U||(r.removeChild(0,i),this.root=h),a.view;const[d,...l]=[...o].reverse(),[p,...m]=[...n].reverse(),u=r.isChildVisible(0);r.removeChild(0,i);const c=d.children.map(((e,t)=>d.getChildSize(t)));if(d.removeChild(p,i).dispose(),h instanceof Y){c.splice(p,1,...h.children.map((e=>e.size)));for(let e=0;e<h.children.length;e++){const t=h.children[e];d.addChild(t,t.size,p+e)}for(;h.children.length>0;)h.removeChild(0)}else{const t=new U(h.view,ne(h.orientation),h.size),i=u?h.orthogonalSize:e.Sizing.Invisible(h.orthogonalSize);d.addChild(t,i,p)}h.dispose();for(let e=0;e<c.length;e++)d.resizeChild(e,c[e]);return a.view}layout(t,i){const[n,s]=this.root.orientation===e.Orientation.HORIZONTAL?[i,t]:[t,i];this.root.layout(n,s)}getNode(e,t=this.root,i=[]){if(0===e.length)return[i,t];if(!(t instanceof Y))throw new Error("Invalid location");const[n,...s]=e;if(n<0||n>=t.children.length)throw new Error("Invalid location");const o=t.children[n];return i.push(t),this.getNode(s,o,i)}}class ae{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}updateOptions(e){this.component.updateOptions(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()}}class he{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(){const e=new v,t=this.component.onDidDrop((t=>{e.fire(Object.assign(Object.assign({},t),{api:this}))}));return e.dispose=()=>{t.dispose(),e.dispose()},e.event}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()}}class de{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()}}class le{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 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 onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidDrop(){return this.component.onDidDrop}get onWillDragGroup(){return this.component.onWillDragGroup}get onWillDragPanel(){return this.component.onWillDragPanel}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){this.component.fromJSON(e)}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()}exitMaxmizedGroup(){this.component.exitMaximizedGroup()}get onDidMaxmizedGroupChange(){return this.component.onDidMaxmizedGroupChange}addPopoutGroup(e,t){this.component.addPopoutGroup(e,t)}}class pe extends _{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(w(this.element,"dragenter",(e=>{this.onDragEnter(e)}),!0)),this.addDisposables(w(this.element,"dragover",(e=>{this.onDragOver(e)}),!0)),this.addDisposables(w(this.element,"dragleave",(e=>{this.onDragLeave(e)}))),this.addDisposables(w(this.element,"dragend",(e=>{this.onDragEnd(e)}))),this.addDisposables(w(this.element,"drop",(e=>{this.onDrop(e)})))}}function me(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 ue(e){switch(e){case"top":return"above";case"bottom":return"below";case"left":return"left";case"right":return"right";case"center":return"within";default:throw new Error(`invalid position '${e}'`)}}const ce={value:20,type:"percentage"},ve={value:50,type:"percentage"};class ge extends _{get state(){return this._state}constructor(e,t){super(),this.element=e,this.options=t,this._onDrop=new v,this.onDrop=this._onDrop.event,this._acceptedTargetZonesSet=new Set(this.options.acceptedTargetZones),this.dnd=new pe(this.element,{onDragEnter:()=>{},onDragOver:e=>{if(0===this._acceptedTargetZonesSet.size)return void this.removeDropTarget();const t=this.element.clientWidth,i=this.element.clientHeight;if(0===t||0===i)return;const n=e.currentTarget.getBoundingClientRect(),s=e.clientX-n.left,o=e.clientY-n.top,r=this.calculateQuadrant(this._acceptedTargetZonesSet,s,o,t,i);if(this.isAlreadyUsed(e)||null===r)this.removeDropTarget();else{if("boolean"==typeof this.options.canDisplayOverlay){if(!this.options.canDisplayOverlay)return void this.removeDropTarget()}else if(!this.options.canDisplayOverlay(e,r))return void this.removeDropTarget();this.markAsUsed(e),this.targetElement||(this.targetElement=document.createElement("div"),this.targetElement.className="drop-target-dropzone",this.overlayElement=document.createElement("div"),this.overlayElement.className="drop-target-selection",this._state="center",this.targetElement.appendChild(this.overlayElement),this.element.classList.add("drop-target"),this.element.append(this.targetElement)),this.toggleClasses(r,t,i),this._state=r}},onDragLeave:()=>{this.removeDropTarget()},onDragEnd:()=>{this.removeDropTarget()},onDrop:e=>{e.preventDefault();const t=this._state;this.removeDropTarget(),t&&(e.stopPropagation(),this._onDrop.fire({position:t,nativeEvent:e}))}}),this.addDisposables(this._onDrop,this.dnd)}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this.removeDropTarget(),super.dispose()}markAsUsed(e){e[ge.USED_EVENT_ID]=!0}isAlreadyUsed(e){const t=e[ge.USED_EVENT_ID];return"boolean"==typeof t&&t}toggleClasses(e,t,i){var n,s;if(!this.overlayElement)return;const o=t<100,r=i<100,a="left"===e,h="right"===e,d="top"===e,l="bottom"===e,p=!o&&h,m=!o&&a,u=!r&&d,c=!r&&l;let v=1;const g=null!==(s=null===(n=this.options.overlayModel)||void 0===n?void 0:n.size)&&void 0!==s?s:ve;"percentage"===g.type?v=T(g.value,0,100)/100:((p||m)&&(v=T(0,g.value,t)/t),(u||c)&&(v=T(0,g.value,i)/i));const w=(1-v)/2;let f;f=p?`translateX(${100*w}%) scaleX(${v})`:m?`translateX(-${100*w}%) scaleX(${v})`:u?`translateY(-${100*w}%) scaleY(${v})`:c?`translateY(${100*w}%) scaleY(${v})`:"",this.overlayElement.style.transform=f,z(this.overlayElement,"dv-drop-target-small-vertical",r),z(this.overlayElement,"dv-drop-target-small-horizontal",o),z(this.overlayElement,"dv-drop-target-left",a),z(this.overlayElement,"dv-drop-target-right",h),z(this.overlayElement,"dv-drop-target-top",d),z(this.overlayElement,"dv-drop-target-bottom",l),z(this.overlayElement,"dv-drop-target-center","center"===e)}calculateQuadrant(e,t,i,n,s){var o,r;const a=null!==(r=null===(o=this.options.overlayModel)||void 0===o?void 0:o.activationSize)&&void 0!==r?r:ce;return"percentage"===a.type?function(e,t,i,n,s,o){const r=100*t/n,a=100*i/s;if(e.has("left")&&r<o)return"left";if(e.has("right")&&r>100-o)return"right";if(e.has("top")&&a<o)return"top";if(e.has("bottom")&&a>100-o)return"bottom";if(!e.has("center"))return null;return"center"}(e,t,i,n,s,a.value):function(e,t,i,n,s,o){if(e.has("left")&&t<o)return"left";if(e.has("right")&&t>n-o)return"right";if(e.has("top")&&i<o)return"top";if(e.has("bottom")&&i>s-o)return"bottom";if(!e.has("center"))return null;return"center"}(e,t,i,n,s,a.value)}removeDropTarget(){this.targetElement&&(this._state=void 0,this.element.removeChild(this.targetElement),this.targetElement=void 0,this.overlayElement=void 0,this.element.classList.remove("drop-target"))}}var we;ge.USED_EVENT_ID="__dockview_droptarget_event_is_used__",e.DockviewDropTargets=void 0,(we=e.DockviewDropTargets||(e.DockviewDropTargets={}))[we.Tab=0]="Tab",we[we.Panel=1]="Panel",we[we.TabContainer=2]="TabContainer",we[we.Edge=3]="Edge";class fe extends _{get element(){return this._element}constructor(t,i){super(),this.accessor=t,this.group=i,this.disposable=new D,this._onDidFocus=new v,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new v,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="content-container",this._element.tabIndex=-1,this.addDisposables(this._onDidFocus,this._onDidBlur),this.dropTarget=new ge(this.element,{acceptedTargetZones:["top","bottom","left","right","center"],canDisplayOverlay:(t,i)=>{if("no-drop-target"===this.group.locked||this.group.locked&&"center"===i)return!1;const n=p();if(!n&&t.shiftKey&&"floating"!==this.group.location)return!1;if(n&&n.viewId===this.accessor.id){if(n.groupId===this.group.id){if("center"===i)return!1;if(null===n.panelId)return!1}return!(1===this.group.panels.length&&n.groupId===this.group.id)}return this.group.canDisplayOverlay(t,i,e.DockviewDropTargets.Panel)}}),this.addDisposables(this.dropTarget)}show(){this.element.style.display=""}hide(){this.element.style.display="none"}renderPanel(e,t={asActive:!0}){const i=t.asActive||this.panel&&this.group.isPanelActive(this.panel);let n;switch(this.panel&&this.panel.view.content.element.parentElement===this._element&&this._element.removeChild(this.panel.view.content.element),this.panel=e,e.api.renderer){case"onlyWhenVisibile":this.accessor.overlayRenderContainer.detatch(e),this.panel&&i&&this._element.appendChild(this.panel.view.content.element),n=this._element;break;case"always":e.view.content.element.parentElement===this._element&&this._element.removeChild(e.view.content.element),n=this.accessor.overlayRenderContainer.attach({panel:e,referenceContainer:this})}if(i){const t=e.view.content.onDidFocus,i=e.view.content.onDidBlur,s=A(n),o=new _;o.addDisposables(s,s.onDidFocus((()=>this._onDidFocus.fire())),s.onDidBlur((()=>this._onDidBlur.fire()))),t&&o.addDisposables(t((()=>this._onDidFocus.fire()))),i&&o.addDisposables(i((()=>this._onDidBlur.fire()))),this.disposable.value=o}}openPanel(e){this.panel!==e&&this.renderPanel(e)}layout(e,t){}closePanel(){this.panel&&"onlyWhenVisibile"===this.panel.api.renderer&&this._element.removeChild(this.panel.view.content.element),this.panel=void 0}dispose(){this.disposable.dispose(),super.dispose()}}class _e extends _{constructor(e){super(),this.el=e,this.dataDisposable=new D,this.pointerEventsDisposable=new D,this._onDragStart=new v,this.onDragStart=this._onDragStart.event,this.addDisposables(this._onDragStart,this.dataDisposable,this.pointerEventsDisposable),this.configure()}isCancelled(e){return!1}configure(){this.addDisposables(this._onDragStart,w(this.el,"dragstart",(e=>{if(e.defaultPrevented||this.isCancelled(e))return void e.preventDefault();const t=[...E("iframe"),...E("webview")];this.pointerEventsDisposable.value={dispose:()=>{for(const e of t)e.style.pointerEvents="auto"}};for(const e of t)e.style.pointerEvents="none";if(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","__dockview_internal_drag_event__")}})),w(this.el,"dragend",(()=>{this.pointerEventsDisposable.dispose(),this.dataDisposable.dispose()})))}}class De extends _e{constructor(e,t,i,n){super(e),this.accessor=t,this.group=i,this.panel=n,this.panelTransfer=l.getInstance()}getData(e){return this.panelTransfer.setData([new h(this.accessor.id,this.group.id,this.panel.id)],h.prototype),{dispose:()=>{this.panelTransfer.clearData(h.prototype)}}}}class be extends _{get element(){return this._element}constructor(t,i,n){super(),this.panel=t,this.accessor=i,this.group=n,this.content=void 0,this._onChanged=new v,this.onChanged=this._onChanged.event,this._onDropped=new v,this.onDrop=this._onDropped.event,this._onDragStart=new v,this.onDragStart=this._onDragStart.event,this._element=document.createElement("div"),this._element.className="tab",this._element.tabIndex=0,this._element.draggable=!0,z(this.element,"inactive-tab",!0);const s=new De(this._element,this.accessor,this.group,this.panel);this.droptarget=new ge(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:(t,i)=>{if(this.group.locked)return!1;const n=p();return n&&this.accessor.id===n.viewId?(null!==n.panelId||n.groupId!==this.group.id)&&this.panel.id!==n.panelId:this.group.model.canDisplayOverlay(t,i,e.DockviewDropTargets.Tab)}}),this.addDisposables(this._onChanged,this._onDropped,this._onDragStart,s.onDragStart((e=>{this._onDragStart.fire(e)})),s,w(this._element,"mousedown",(e=>{e.defaultPrevented||this._onChanged.fire(e)})),this.droptarget.onDrop((e=>{this._onDropped.fire(e)})),this.droptarget)}setActive(e){z(this.element,"active-tab",e),z(this.element,"inactive-tab",!e)}setContent(e){this.content&&this._element.removeChild(this.content.element),this.content=e,this._element.appendChild(this.content.element)}dispose(){super.dispose()}}class Ce extends _e{constructor(e,t,i){super(e),this.accessor=t,this.group=i,this.panelTransfer=l.getInstance(),this.addDisposables(w(e,"mousedown",(e=>{e.shiftKey&&(e[I]=!0)}),!0))}isCancelled(e){return"floating"===this.group.api.location&&!e.shiftKey}getData(e){const t=e.dataTransfer;this.panelTransfer.setData([new h(this.accessor.id,this.group.id,null)],h.prototype);const i=window.getComputedStyle(this.el),n=i.getPropertyValue("--dv-activegroup-visiblepanel-tab-background-color"),s=i.getPropertyValue("--dv-activegroup-visiblepanel-tab-color");if(t){const e=document.createElement("div");e.style.backgroundColor=n,e.style.color=s,e.style.padding="2px 8px",e.style.height="24px",e.style.fontSize="11px",e.style.lineHeight="20px",e.style.borderRadius="12px",e.style.position="absolute",e.textContent=`Multiple Panels (${this.group.size})`,function(e,t){S(t,"dv-dragged"),document.body.appendChild(t),e.setDragImage(t,0,0),setTimeout((()=>{y(t,"dv-dragged"),t.remove()}),0)}(t,e)}return{dispose:()=>{this.panelTransfer.clearData(h.prototype)}}}}class ye extends _{get element(){return this._element}constructor(t,i){super(),this.accessor=t,this.group=i,this._onDrop=new v,this.onDrop=this._onDrop.event,this._onDragStart=new v,this.onDragStart=this._onDragStart.event,this._element=document.createElement("div"),this._element.className="void-container",this._element.tabIndex=0,this._element.draggable=!0,this.addDisposables(this._onDrop,this._onDragStart,w(this._element,"click",(()=>{this.accessor.doSetGroupActive(this.group)})));const n=new Ce(this._element,t,i);this.voidDropTarget=new ge(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:(t,n)=>{var s;const o=p();return o&&this.accessor.id===o.viewId?(null!==o.panelId||o.groupId!==this.group.id)&&(null===(s=(r=this.group.panels).length>0?r[r.length-1]:void 0)||void 0===s?void 0:s.id)!==o.panelId:i.model.canDisplayOverlay(t,n,e.DockviewDropTargets.Panel);var r}}),this.addDisposables(n,n.onDragStart((e=>{this._onDragStart.fire(e)})),this.voidDropTarget.onDrop((e=>{this._onDrop.fire(e)})),this.voidDropTarget)}}class Se extends _{get panels(){return this.tabs.map((e=>e.value.panel.id))}get size(){return this.tabs.length}get hidden(){return this._hidden}set hidden(e){this._hidden=e,this.element.style.display=e?"none":""}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))}get element(){return this._element}isActive(e){return this.selectedIndex>-1&&this.tabs[this.selectedIndex].value===e}indexOf(e){return this.tabs.findIndex((t=>t.value.panel.id===e))}constructor(e,t){super(),this.accessor=e,this.group=t,this.tabs=[],this.selectedIndex=-1,this._hidden=!1,this._onDrop=new v,this.onDrop=this._onDrop.event,this._onTabDragStart=new v,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new v,this.onGroupDragStart=this._onGroupDragStart.event,this.addDisposables(this._onDrop,this._onTabDragStart,this._onGroupDragStart),this._element=document.createElement("div"),this._element.className="tabs-and-actions-container",z(this._element,"dv-full-width-single-tab","fullwidth"===this.accessor.options.singleTabMode),this.addDisposables(this.accessor.onDidAddPanel((e=>{e.api.group===this.group&&z(this._element,"dv-single-tab",1===this.size)})),this.accessor.onDidRemovePanel((e=>{e.api.group===this.group&&z(this._element,"dv-single-tab",1===this.size)}))),this.rightActionsContainer=document.createElement("div"),this.rightActionsContainer.className="right-actions-container",this.leftActionsContainer=document.createElement("div"),this.leftActionsContainer.className="left-actions-container",this.preActionsContainer=document.createElement("div"),this.preActionsContainer.className="pre-actions-container",this.tabContainer=document.createElement("div"),this.tabContainer.className="tabs-container",this.voidContainer=new ye(this.accessor,this.group),this._element.appendChild(this.preActionsContainer),this._element.appendChild(this.tabContainer),this._element.appendChild(this.leftActionsContainer),this._element.appendChild(this.voidContainer.element),this._element.appendChild(this.rightActionsContainer),this.addDisposables(this.voidContainer,this.voidContainer.onDragStart((e=>{this._onGroupDragStart.fire({nativeEvent:e,group:this.group})})),this.voidContainer.onDrop((e=>{this._onDrop.fire({event:e.nativeEvent,index:this.tabs.length})})),w(this.voidContainer.element,"mousedown",(e=>{if(!this.accessor.options.disableFloatingGroups&&e.shiftKey&&"floating"!==this.group.api.location){e.preventDefault();const{top:t,left:i}=this.element.getBoundingClientRect(),{top:n,left:s}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(this.group,{x:i-s+20,y:t-n+20},{inDragMode:!0})}})),w(this.tabContainer,"mousedown",(e=>{if(e.defaultPrevented)return;0===e.button&&this.accessor.doSetGroupActive(this.group)})))}setActive(e){}addTab(e,t=this.tabs.length){if(t<0||t>this.tabs.length)throw new Error("invalid location");this.tabContainer.insertBefore(e.value.element,this.tabContainer.children[t]),this.tabs=[...this.tabs.slice(0,t),e,...this.tabs.slice(t)],this.selectedIndex<0&&(this.selectedIndex=t)}delete(e){const t=this.tabs.findIndex((t=>t.value.panel.id===e)),i=this.tabs.splice(t,1)[0],{value:n,disposable:s}=i;s.dispose(),n.dispose(),n.element.remove()}setActivePanel(e){this.tabs.forEach((t=>{const i=e.id===t.value.panel.id;t.value.setActive(i)}))}openPanel(e,t=this.tabs.length){var i;if(this.tabs.find((t=>t.value.panel.id===e.id)))return;const n=new be(e,this.accessor,this.group);if(!(null===(i=e.view)||void 0===i?void 0:i.tab))throw new Error("invalid header component");n.setContent(e.view.tab);const s=new _(n.onDragStart((t=>{this._onTabDragStart.fire({nativeEvent:t,panel:e})})),n.onChanged((t=>{var i;const s=!this.accessor.options.disableFloatingGroups,o="floating"===this.group.api.location&&1===this.size;if(s&&!o&&t.shiftKey){t.preventDefault();const e=this.accessor.getGroupPanel(n.panel.id),{top:i,left:s}=n.element.getBoundingClientRect(),{top:o,left:r}=this.accessor.element.getBoundingClientRect();return void this.accessor.addFloatingGroup(e,{x:s-r,y:i-o},{inDragMode:!0})}const r=e.id===(null===(i=this.group.model.activePanel)||void 0===i?void 0:i.id)&&this.group.model.isContentFocused;0===t.button&&!t.defaultPrevented&&this.group.model.openPanel(e,{skipFocus:r})})),n.onDrop((e=>{this._onDrop.fire({event:e.nativeEvent,index:this.tabs.findIndex((e=>e.value===n))})}))),o={value:n,disposable:s};this.addTab(o,t)}closePanel(e){this.delete(e.id)}dispose(){super.dispose();for(const{value:e,disposable:t}of this.tabs)t.dispose(),e.dispose();this.tabs=[]}}class ze extends _{get element(){throw new Error("not supported")}get activePanel(){return this._activePanel}get locked(){return this._locked}set locked(e){this._locked=e,z(this.container,"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&&x(document.activeElement,this.contentContainer.element)}get location(){return this._location}set location(e){switch(this._location=e,z(this.container,"dv-groupview-floating",!1),z(this.container,"dv-groupview-popout",!1),e){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"]),z(this.container,"dv-groupview-floating",!0);break;case"popout":this.contentContainer.dropTarget.setTargetZones(["center"]),z(this.container,"dv-groupview-popout",!0)}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,i,n,s){var o;super(),this.container=e,this.accessor=t,this.id=i,this.options=n,this.groupPanel=s,this._isGroupActive=!1,this._locked=!1,this._location="grid",this.mostRecentlyUsed=[],this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._onMove=new v,this.onMove=this._onMove.event,this._onDidDrop=new v,this.onDidDrop=this._onDidDrop.event,this._onTabDragStart=new v,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new v,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new v,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidRemovePanel=new v,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new v,this.onDidActivePanelChange=this._onDidActivePanelChange.event,z(this.container,"groupview",!0),this.tabsContainer=new Se(this.accessor,this.groupPanel),this.contentContainer=new fe(this.accessor,this),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!n.hideHeader,this.locked=null!==(o=n.locked)&&void 0!==o&&o,this.addDisposables(this._onTabDragStart,this._onGroupDragStart,this.tabsContainer.onTabDragStart((e=>{this._onTabDragStart.fire(e)})),this.tabsContainer.onGroupDragStart((e=>{this._onGroupDragStart.fire(e)})),this.tabsContainer.onDrop((e=>{this.handleDropEvent(e.event,"center",e.index)})),this.contentContainer.onDidFocus((()=>{this.accessor.doSetGroupActive(this.groupPanel,!0)})),this.contentContainer.onDidBlur((()=>{})),this.contentContainer.dropTarget.onDrop((e=>{this.handleDropEvent(e.nativeEvent,e.position)})),this._onMove,this._onDidChange,this._onDidDrop,this._onDidAddPanel,this._onDidRemovePanel,this._onDidActivePanelChange)}initialize(){var e,t;(null===(e=this.options)||void 0===e?void 0:e.panels)&&this.options.panels.forEach((e=>{this.doAddPanel(e)})),(null===(t=this.options)||void 0===t?void 0:t.activePanel)&&this.openPanel(this.options.activePanel),this.setActive(this.isActive,!0,!0),this.updateContainer(),this.accessor.options.createRightHeaderActionsElement&&(this._rightHeaderActions=this.accessor.options.createRightHeaderActionsElement(this.groupPanel),this.addDisposables(this._rightHeaderActions),this._rightHeaderActions.init({containerApi:new le(this.accessor),api:this.groupPanel.api}),this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element)),this.accessor.options.createLeftHeaderActionsElement&&(this._leftHeaderActions=this.accessor.options.createLeftHeaderActionsElement(this.groupPanel),this.addDisposables(this._leftHeaderActions),this._leftHeaderActions.init({containerApi:new le(this.accessor),api:this.groupPanel.api}),this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element)),this.accessor.options.createPrefixHeaderActionsElement&&(this._prefixHeaderActions=this.accessor.options.createPrefixHeaderActionsElement(this.groupPanel),this.addDisposables(this._prefixHeaderActions),this._prefixHeaderActions.init({containerApi:new le(this.accessor),api:this.groupPanel.api}),this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element))}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),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,t;null===(t=null===(e=this._activePanel)||void 0===e?void 0:e.focus)||void 0===t||t.call(e)}openPanel(e,t={}){("number"!=typeof t.index||t.index>this.panels.length)&&(t.index=this.panels.length);const i=!!t.skipSetPanelActive,n=!!t.skipSetGroupActive;if(e.updateParentGroup(this.groupPanel,!0),this._activePanel===e)return n||this.accessor.doSetGroupActive(this.groupPanel),void this.contentContainer.renderPanel(e,{asActive:!0});this.doAddPanel(e,t.index,i),i||this.doSetActivePanel(e),n||this.accessor.doSetGroupActive(this.groupPanel,!!t.skipFocus),this.updateContainer()}removePanel(e){const t="string"==typeof e?e:e.id,i=this._panels.find((e=>e.id===t));if(!i)throw new Error("invalid operation");return this._removePanel(i)}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){this.accessor.removePanel(e)}isPanelActive(e){return this._activePanel===e}updateActions(e){this.tabsContainer.setRightActionsElement(e)}setActive(e,t=!1,i=!1){var n,s,o,r;i||this.isActive!==e?(this._isGroupActive=e,z(this.container,"active-group",e),z(this.container,"inactive-group",!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0&&this.doSetActivePanel(this.panels[0]),this.updateContainer(),e&&(t||null===(r=null===(o=this._activePanel)||void 0===o?void 0:o.focus)||void 0===r||r.call(o))):t||null===(s=null===(n=this._activePanel)||void 0===n?void 0:n.focus)||void 0===s||s.call(n)}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){const t=this._activePanel===e;if(this.doRemovePanel(e),t&&this.panels.length>0){const e=this.mostRecentlyUsed[0];this.openPanel(e)}return this._activePanel&&0===this.panels.length&&this.doSetActivePanel(void 0),this.updateContainer(),e}doRemovePanel(e){const t=this.panels.indexOf(e);this._activePanel===e&&this.contentContainer.closePanel(),this.tabsContainer.delete(e.id),this._panels.splice(t,1),this.mostRecentlyUsed.includes(e)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(e),1),this._onDidRemovePanel.fire({panel:e})}doAddPanel(e,t=this.panels.length,i=!1){const n=this._panels.indexOf(e)>-1;this.tabsContainer.show(),this.contentContainer.show(),this.tabsContainer.openPanel(e,t),i||this.contentContainer.openPanel(e),n||(this.updateMru(e),this.panels.splice(t,0,e),this._onDidAddPanel.fire({panel:e}))}doSetActivePanel(e){this._activePanel=e,e&&(this.tabsContainer.setActivePanel(e),e.layout(this._width,this._height),this.updateMru(e),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;if(z(this.container,"empty",this.isEmpty),this.panels.forEach((e=>e.updateParentGroup(this.groupPanel,this.isActive))),this.isEmpty&&!this.watermark){const e=this.accessor.createWatermarkComponent();e.init({containerApi:new le(this.accessor),group:this.groupPanel}),this.watermark=e,w(this.watermark.element,"click",(()=>{this.isActive||this.accessor.doSetGroupActive(this.groupPanel)})),this.tabsContainer.hide(),this.contentContainer.element.appendChild(this.watermark.element),this.watermark.updateParentGroup(this.groupPanel,!0)}!this.isEmpty&&this.watermark&&(this.watermark.element.remove(),null===(t=(e=this.watermark).dispose)||void 0===t||t.call(e),this.watermark=void 0,this.tabsContainer.show())}canDisplayOverlay(e,t,i){return!!this.accessor.options.showDndOverlay&&this.accessor.options.showDndOverlay({nativeEvent:e,target:i,group:this.accessor.getPanel(this.id),position:t,getData:p})}handleDropEvent(e,t,i){if("no-drop-target"===this.locked)return;const n=p();if(n&&n.viewId===this.accessor.id){if(null===n.panelId){const{groupId:e}=n;return void this._onMove.fire({target:t,groupId:e,index:i})}if(-1!==this.tabsContainer.indexOf(n.panelId)&&1===this.tabsContainer.size)return;const{groupId:e,panelId:s}=n;if(this.id===e&&!t){if(this.tabsContainer.indexOf(s)===i)return}this._onMove.fire({target:t,groupId:n.groupId,itemId:n.panelId,index:i})}else this._onDidDrop.fire({nativeEvent:e,position:t,index:i,getData:()=>p()})}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);for(const e of this.panels)e.dispose();this.tabsContainer.dispose(),this.contentContainer.dispose()}}class xe extends _{get element(){return this._element}get disableResizing(){return this._disableResizing}set disableResizing(e){this._disableResizing=e}constructor(e,t=!1){super(),this._disableResizing=t,e?this._element=e:(this._element=document.createElement("div"),this._element.style.height="100%",this._element.style.width="100%",this._element.className="dv-resizable-container"),this.addDisposables(C(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{width:t,height:i}=e.contentRect;this.layout(t,i)})))}}const Ee=M();function Ae(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 xe{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}constructor(t){super(t.parentElement,t.disableAutoResizing),this._id=Ee.next(),this._groups=new Map,this._onDidLayoutChange=new v,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidRemoveGroup=new v,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new v,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new v,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._bufferOnDidLayoutChange=new f,this.gridview=new re(!!t.proportionalLayout,t.styles,t.orientation),this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidChange((()=>{this._bufferOnDidLayoutChange.fire()})),e.DockviewEvent.any(this.onDidAddGroup,this.onDidRemoveGroup,this.onDidActiveGroupChange)((()=>{this._bufferOnDidLayoutChange.fire()})),this._bufferOnDidLayoutChange.onEvent((()=>{this._onDidLayoutChange.fire()})),this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(Q(e.element),t),this._onDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(Q(e.element))}maximizeGroup(e){this.gridview.maximizeView(e)}isMaximizedGroup(e){return this.gridview.maximizedView()===e}exitMaximizedGroup(){this.gridview.exitMaximizedView()}hasMaximizedGroup(){return this.gridview.hasMaximizedView()}get onDidMaxmizedGroupChange(){return this.gridview.onDidMaxmizedNodeChange}doAddGroup(t,i=[0],n){this.gridview.addView(t,null!=n?n:e.Sizing.Distribute,i),this._onDidAddGroup.fire(t),this.doSetGroupActive(t)}doRemoveGroup(t,i){if(!this._groups.has(t.id))throw new Error("invalid operation");const n=this._groups.get(t.id),s=this.gridview.remove(t,e.Sizing.Distribute);if(n&&!(null==i?void 0:i.skipDispose)&&(n.disposable.dispose(),n.value.dispose(),this._groups.delete(t.id)),this._onDidRemoveGroup.fire(t),!(null==i?void 0:i.skipActive)&&this._activeGroup===t){const e=Array.from(this._groups.values());this.doSetGroupActive(e.length>0?e[0].value:void 0)}return s}getPanel(e){var t;return null===(t=this._groups.get(e))||void 0===t?void 0:t.value}doSetGroupActive(e,t){var i,n,s;this._activeGroup!==e&&(this._activeGroup&&(this._activeGroup.setActive(!1),t||null===(n=(i=this._activeGroup).focus)||void 0===n||n.call(i)),e&&(e.setActive(!0),t||null===(s=e.focus)||void 0===s||s.call(e)),this._activeGroup=e,this._onDidActiveGroupChange.fire(e))}removeGroup(e){this.doRemoveGroup(e)}moveToNext(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=Q(e.group.element),n=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupActive(n)}moveToPrevious(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=Q(e.group.element),n=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;this.doSetGroupActive(n)}layout(e,t,i){(null!=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._onDidActiveGroupChange.dispose(),this._onDidAddGroup.dispose(),this._onDidRemoveGroup.dispose(),this._onDidLayoutChange.dispose();for(const e of this.groups)e.dispose();this.gridview.dispose(),super.dispose()}}class Ie extends _{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){super(),this.id=e,this._isFocused=!1,this._isActive=!1,this._isVisible=!0,this._width=0,this._height=0,this.panelUpdatesDisposable=new D,this._onDidDimensionChange=new v({replay:!0}),this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new v({replay:!0}),this.onDidFocusChange=this._onDidChangeFocus.event,this._onFocusEvent=new v,this.onFocusEvent=this._onFocusEvent.event,this._onDidVisibilityChange=new v({replay:!0}),this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onVisibilityChange=new v,this.onVisibilityChange=this._onVisibilityChange.event,this._onDidActiveChange=new v({replay:!0}),this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new v,this.onActiveChange=this._onActiveChange.event,this._onUpdateParameters=new v,this.onUpdateParameters=this._onUpdateParameters.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._onFocusEvent,this._onActiveChange,this._onVisibilityChange,this._onUpdateParameters)}initialize(e){this.panelUpdatesDisposable.value=this._onUpdateParameters.event((t=>{e.update({params:t})}))}setVisible(e){this._onVisibilityChange.fire({isVisible:e})}setActive(){this._onActiveChange.fire()}updateParameters(e){this._onUpdateParameters.fire(e)}dispose(){super.dispose()}}class Oe extends Ie{constructor(e){super(e),this._onDidConstraintsChangeInternal=new v,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new v({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new v,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 Ge extends Oe{set pane(e){this._pane=e}constructor(e){super(e),this._onDidExpansionChange=new v({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new v({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new v({}),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 Ne extends _{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 n=A(this._element);this.addDisposables(this.api,n.onDidFocus((()=>{this.api._onDidChangeFocus.fire({isFocused:!0})})),n.onDidBlur((()=>{this.api._onDidChangeFocus.fire({isFocused:!1})})),n)}focus(){this.api._onFocusEvent.fire()}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 Ve extends Ne{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,t,i,n,s,o){super(e,t,new Ge(e)),this.headerComponent=i,this._onDidChangeExpansionState=new v({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this.headerSize=22,this._orthogonalSize=0,this._size=0,this._minimumBodySize=100,this._maximumBodySize=Number.POSITIVE_INFINITY,this._isExpanded=!1,this.expandedSize=0,this.api.pane=this,this.api.initialize(this),this._isExpanded=s,this._headerVisible=o,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=n,this.element.classList.add("pane"),this.addDisposables(this.api.onDidSizeChange((e=>{this._onDidChange.fire({size:e.size})})),w(this.element,"mouseenter",(e=>{this.api._onMouseEnter.fire(e)})),w(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?S(this.header,"focused"):y(this.header,"focused"))}))),this.renderOnce()}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}isExpanded(){return this._isExpanded}setExpanded(e){this._isExpanded!==e&&(this._isExpanded=e,e?(this.animationTimer&&clearTimeout(this.animationTimer),this.body&&this.element.appendChild(this.body)):this.animationTimer=setTimeout((()=>{var e;null===(e=this.body)||void 0===e||e.remove()}),200),this._onDidChange.fire(e?{size:this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(t,i){this._size=t,this._orthogonalSize=i;const[n,s]=this.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.isExpanded()&&(this.expandedSize=n),super.layout(n,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="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="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 Le extends Ve{constructor(e,t,i,n,s,o,r){super(t,i,n,s,o,!0),this.accessor=e,this._onDidDrop=new v,this.onDidDrop=this._onDidDrop.event,r||this.initDragFeatures()}initDragFeatures(){if(!this.header)return;const e=this.id,t=this.accessor.id;this.header.draggable=!0,this.handler=new class extends _e{getData(){return l.getInstance().setData([new d(t,e)],d.prototype),{dispose:()=>{l.getInstance().clearData(d.prototype)}}}}(this.header),this.target=new ge(this.element,{acceptedTargetZones:["top","bottom"],overlayModel:{activationSize:{type:"percentage",value:50}},canDisplayOverlay:e=>{const t=m();return!(!t||t.paneId===this.id||t.viewId!==this.accessor.id)||!!this.accessor.options.showDndOverlay&&this.accessor.options.showDndOverlay({nativeEvent:e,getData:m,panel:this})}}),this.addDisposables(this._onDidDrop,this.handler,this.target,this.target.onDrop((e=>{this.onDrop(e)})))}onDrop(e){const t=m();if(!t||t.viewId!==this.accessor.id)return void this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,api:new he(this.accessor),getData:m}));const i=this._params.containerApi,n=t.paneId,s=i.getPanel(n);if(!s)return void this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,getData:m,api:new he(this.accessor)}));const o=i.panels,r=o.indexOf(s);let a=i.panels.indexOf(this);"left"!==e.position&&"top"!==e.position||(a=Math.max(0,a-1)),"right"!==e.position&&"bottom"!==e.position||(r>a&&a++,a=Math.min(o.length-1,a)),i.movePanel(r,a)}}class ke extends Ie{constructor(e,t){super(e),this._onDidConstraintsChangeInternal=new v,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new v({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new v,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange),t&&this.initialize(t)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}}class Re extends Ne{get priority(){return this._priority}get snap(){return this._snap}get minimumWidth(){const e="function"==typeof this._minimumWidth?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}get minimumHeight(){const e="function"==typeof this._minimumHeight?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}get maximumHeight(){const e="function"==typeof this._maximumHeight?this._maximumHeight():this._maximumHeight;return e!==this._evaluatedMaximumHeight&&(this._evaluatedMaximumHeight=e,this.updateConstraints()),e}get maximumWidth(){const e="function"==typeof this._maximumWidth?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}get isActive(){return this.api.isActive}constructor(e,t,i,n){super(e,t,null!=n?n:new ke(e)),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 v,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.onVisibilityChange((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.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 Te="DockviewGroupPanelApiImpl not initialized";class Me extends ke{get location(){if(!this._group)throw new Error(Te);return this._group.model.location}constructor(e,t){super(e),this.accessor=t,this._onDidLocationChange=new v,this.onDidLocationChange=this._onDidLocationChange.event,this.addDisposables(this._onDidLocationChange)}moveTo(e){var t,i,n;if(!this._group)throw new Error(Te);const s=null!==(t=e.group)&&void 0!==t?t:this.accessor.addGroup({direction:ue(null!==(i=e.position)&&void 0!==i?i:"right")});this.accessor.moveGroupOrPanel(s,this._group.id,void 0,e.group&&null!==(n=e.position)&&void 0!==n?n:"center")}maximize(){if(!this._group)throw new Error(Te);"grid"===this.location&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw new Error(Te);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw new Error(Te);this.isMaximized()&&this.accessor.exitMaximizedGroup()}initialize(e){this._group=e}}class He extends Re{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){super(t,"groupview_default",{minimumHeight:100,minimumWidth:100},new Me(t,e)),this.api.initialize(this),this._model=new ze(this.element,e,t,i,this)}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()}}function We(e){return!!e.referencePanel}function Fe(e){return!!e.referenceGroup}function Be(e){return!!e.referencePanel}function Je(e){return!!e.referenceGroup}class je extends ke{get title(){return this.panel.title}get isGroupActive(){return this.group.isActive}get renderer(){return this.panel.renderer}set group(e){const t=this.isGroupActive;this._group=e,this._onDidGroupChange.fire(),this._group&&(this.disposable.value=this._group.api.onDidActiveChange((()=>{this._onDidActiveGroupChange.fire()})),this.isGroupActive!==t&&this._onDidActiveGroupChange.fire())}get group(){return this._group}constructor(e,t,i){super(e.id),this.panel=e,this.accessor=i,this._onDidTitleChange=new v,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidActiveGroupChange=new v,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new v,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new v,this.onDidRendererChange=this._onDidRendererChange.event,this.disposable=new D,this.initialize(e),this._group=t,this.addDisposables(this.disposable,this._onDidRendererChange,this._onDidTitleChange,this._onDidGroupChange,this._onDidActiveGroupChange)}moveTo(e){var t;this.accessor.moveGroupOrPanel(e.group,this._group.id,this.panel.id,null!==(t=e.position)&&void 0!==t?t:"center",e.index)}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()}}class $e extends _{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}constructor(e,t,i,n,s,o){super(),this.id=e,this.accessor=t,this.containerApi=i,this.view=s,this._renderer=o.renderer,this._group=n,this.api=new je(this,this._group,t),this.addDisposables(this.api.onActiveChange((()=>{t.setActivePanel(this)})),this.api.onDidSizeChange((e=>{this.group.api.setSize(e)})),this.api.onDidRendererChange((e=>{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(){this.api._onFocusEvent.fire()}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}}setTitle(e){e!==this.title&&(this._title=e,this.view.update({params:{params:this._params,title:this.title}}),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:{params:this._params,title:this.title}})}updateParentGroup(e,t){this._group=e,this.api.group=e;const i=this._group.model.isPanelActive(this);this.api._onDidActiveChange.fire({isActive:t&&i}),this.api._onDidVisibilityChange.fire({isVisible:i}),this.view.updateParentGroup(this._group,this._group.model.isPanelActive(this))}layout(e,t){this.api._onDidDimensionChange.fire({width:e,height:t}),this.view.layout(e,t)}dispose(){this.api.dispose(),this.view.dispose()}}const Ze=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("dockview-svg");const i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttributeNS(null,"d",e.path),t.appendChild(i),t},Ue=()=>Ze({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"});class Ye extends _{get element(){return this._element}constructor(){super(),this.params={},this._element=document.createElement("div"),this._element.className="default-tab",this._content=document.createElement("div"),this._content.className="tab-content",this._actionContainer=document.createElement("div"),this._actionContainer.className="action-container",this._list=document.createElement("ul"),this._list.className="tab-list",this.action=document.createElement("div"),this.action.className="tab-action",this.action.appendChild(Ue()),this._element.appendChild(this._content),this._element.appendChild(this._actionContainer),this._actionContainer.appendChild(this._list),this._list.appendChild(this.action),this.addDisposables(w(this._actionContainer,"mousedown",(e=>{e.preventDefault()}))),this.render()}update(e){this.params=Object.assign(Object.assign({},this.params),e.params),this.render()}focus(){}init(e){this.params=e,this._content.textContent=e.title,w(this.action,"click",(e=>{e.preventDefault(),this.params.api.close()}))}onGroupChange(e){this.render()}onPanelVisibleChange(e){this.render()}layout(e,t){}render(){this._content.textContent!==this.params.title&&(this._content.textContent=this.params.title)}}class Xe{get content(){return this._content}get tab(){return this._tab}constructor(e,t,i,n){this.accessor=e,this.id=t,this.contentComponent=i,this.tabComponent=n,this._group=null,this._isPanelVisible=null,this._content=this.createContentComponent(this.id,i),this._tab=this.createTabComponent(this.id,n)}init(e){this.content.init(Object.assign(Object.assign({},e),{tab:this.tab})),this.tab.init(e)}updateParentGroup(e,t){e!==this._group&&(this._group=e,this._content.onGroupChange&&this._content.onGroupChange(e),this._tab.onGroupChange&&this._tab.onGroupChange(e)),t!==this._isPanelVisible&&(this._isPanelVisible=t,this._content.onPanelVisibleChange&&this._content.onPanelVisibleChange(t),this._tab.onPanelVisibleChange&&this._tab.onPanelVisibleChange(t))}layout(e,t){var i,n;null===(n=(i=this.content).layout)||void 0===n||n.call(i,e,t)}update(e){var t,i,n,s;null===(i=(t=this.content).update)||void 0===i||i.call(t,e),null===(s=(n=this.tab).update)||void 0===s||s.call(n,e)}dispose(){var e,t,i,n;null===(t=(e=this.content).dispose)||void 0===t||t.call(e),null===(n=(i=this.tab).dispose)||void 0===n||n.call(i)}createContentComponent(e,t){var i,n;return b(e,t,null!==(i=this.accessor.options.components)&&void 0!==i?i:{},this.accessor.options.frameworkComponents,null===(n=this.accessor.options.frameworkComponentFactory)||void 0===n?void 0:n.content)}createTabComponent(e,t){var i,n;return t?b(e,t,this.accessor.options.tabComponents,this.accessor.options.frameworkTabComponents,null===(i=this.accessor.options.frameworkComponentFactory)||void 0===i?void 0:i.tab,(()=>new Ye)):this.accessor.options.defaultTabComponent?b(e,this.accessor.options.defaultTabComponent,this.accessor.options.tabComponents,this.accessor.options.frameworkTabComponents,null===(n=this.accessor.options.frameworkComponentFactory)||void 0===n?void 0:n.tab,(()=>new Ye)):new Ye}}class Ke{constructor(e){this.accessor=e}fromJSON(e,t){var i,n;const s=e.id,o=e.params,r=e.title,a=e.view,h=a?a.content.id:null!==(i=e.contentComponent)&&void 0!==i?i:"unknown",d=a?null===(n=a.tab)||void 0===n?void 0:n.id:e.tabComponent,l=new Xe(this.accessor,s,h,d),p=new $e(s,this.accessor,new le(this.accessor),t,l,{renderer:e.renderer});return p.init({title:null!=r?r:s,params:null!=o?o:{}}),p}}class qe extends _{get element(){return this._element}constructor(){super(),this._element=document.createElement("div"),this._element.className="watermark";const e=document.createElement("div");e.className="watermark-title";const t=document.createElement("span");t.style.flexGrow="1";const i=document.createElement("div");i.className="watermark-content",this._element.appendChild(e),this._element.appendChild(i);const n=document.createElement("div");n.className="actions-container";const s=document.createElement("div");s.className="close-action",s.appendChild(Ue()),n.appendChild(s),e.appendChild(t),e.appendChild(n),this.addDisposables(w(s,"click",(e=>{var t;e.preventDefault(),this._group&&(null===(t=this._api)||void 0===t||t.removeGroup(this._group))})))}update(e){}focus(){}layout(e,t){}init(e){this._api=e.containerApi,this.render()}updateParentGroup(e,t){this._group=e,this.render()}dispose(){super.dispose()}render(){const e=!!(this._api&&this._api.size<=1);z(this.element,"has-actions",e)}}const Qe=(()=>{let e=null;return function(t){e!==t&&null!==e&&z(e,"dv-bring-to-front",!1),z(t,"dv-bring-to-front",!0),e=t}})();class et extends _{set minimumInViewportWidth(e){this.options.minimumInViewportWidth=e}set minimumInViewportHeight(e){this.options.minimumInViewportHeight=e}constructor(e){super(),this.options=e,this._element=document.createElement("div"),this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new v,this.onDidChangeEnd=this._onDidChangeEnd.event,this.addDisposables(this._onDidChange,this._onDidChangeEnd),this._element.className="dv-resize-container",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({height:this.options.height,width:this.options.width,top:this.options.top,left:this.options.left})}setBounds(e={}){"number"==typeof e.height&&(this._element.style.height=`${e.height}px`),"number"==typeof e.width&&(this._element.style.width=`${e.width}px`),"number"==typeof e.top&&(this._element.style.top=`${e.top}px`),"number"==typeof e.left&&(this._element.style.left=`${e.left}px`);const t=this.options.container.getBoundingClientRect(),i=this._element.getBoundingClientRect(),n=Math.max(0,this.getMinimumWidth(i.width)),s="number"==typeof this.options.minimumInViewportHeight?Math.max(0,this.getMinimumHeight(i.height)):0,o=T(i.left-t.left,-n,Math.max(0,t.width-i.width+n)),r=T(i.top-t.top,-s,Math.max(0,t.height-i.height+s));this._element.style.left=`${o}px`,this._element.style.top=`${r}px`,this._onDidChange.fire()}toJSON(){const e=this.options.container.getBoundingClientRect(),t=this._element.getBoundingClientRect();return{top:t.top-e.top,left:t.left-e.left,width:t.width,height:t.height}}setupDrag(e,t={inDragMode:!1}){const i=new D,n=()=>{let e=null;const t=[...E("iframe"),...E("webview")];for(const e of t)e.style.pointerEvents="none";i.value=new _({dispose:()=>{for(const e of t)e.style.pointerEvents="auto"}},g(window,"mousemove",(t=>{const i=this.options.container.getBoundingClientRect(),n=t.clientX-i.left,s=t.clientY-i.top;z(this._element,"dv-resize-container-dragging",!0);const o=this._element.getBoundingClientRect();null===e&&(e={x:t.clientX-o.left,y:t.clientY-o.top});const r=Math.max(0,this.getMinimumWidth(o.width)),a=Math.max(0,this.options.minimumInViewportHeight?this.getMinimumHeight(o.height):0),h=T(n-e.x,-r,Math.max(0,i.width-o.width+r)),d=T(s-e.y,-a,Math.max(0,i.height-o.height+a));this.setBounds({top:d,left:h})})),g(window,"mouseup",(()=>{z(this._element,"dv-resize-container-dragging",!1),i.dispose(),this._onDidChangeEnd.fire()})))};this.addDisposables(i,w(e,"mousedown",(e=>{e.defaultPrevented?e.preventDefault():O(e)||n()})),w(this.options.content,"mousedown",(e=>{e.defaultPrevented||O(e)||e.shiftKey&&n()})),w(this.options.content,"mousedown",(()=>{Qe(this._element)}),!0)),Qe(this._element),t.inDragMode&&n()}setupResize(e){const t=document.createElement("div");t.className=`dv-resize-handle-${e}`,this._element.appendChild(t);const i=new D;this.addDisposables(i,w(t,"mousedown",(t=>{t.preventDefault();let n=null;const s=[...E("iframe"),...E("webview")];for(const e of s)e.style.pointerEvents="none";i.value=new _(g(window,"mousemove",(t=>{const i=this.options.container.getBoundingClientRect(),s=this._element.getBoundingClientRect(),o=t.clientY-i.top,r=t.clientX-i.left;let a,h,d,l;null===n&&(n={originalY:o,originalHeight:s.height,originalX:r,originalWidth:s.width});const p=()=>{a=T(o,-Number.MAX_VALUE,n.originalY+n.originalHeight>i.height?this.getMinimumHeight(i.height):Math.max(0,n.originalY+n.originalHeight-et.MINIMUM_HEIGHT)),h=n.originalY+n.originalHeight-a},m=()=>{a=n.originalY-n.originalHeight,h=T(o-a,a<0&&"number"==typeof this.options.minimumInViewportHeight?-a+this.options.minimumInViewportHeight:et.MINIMUM_HEIGHT,Number.MAX_VALUE)},u=()=>{d=T(r,-Number.MAX_VALUE,n.originalX+n.originalWidth>i.width?this.getMinimumWidth(i.width):Math.max(0,n.originalX+n.originalWidth-et.MINIMUM_WIDTH)),l=n.originalX+n.originalWidth-d},c=()=>{d=n.originalX-n.originalWidth,l=T(r-d,d<0&&"number"==typeof this.options.minimumInViewportWidth?-d+this.options.minimumInViewportWidth:et.MINIMUM_WIDTH,Number.MAX_VALUE)};switch(e){case"top":p();break;case"bottom":m();break;case"left":u();break;case"right":c();break;case"topleft":p(),u();break;case"topright":p(),c();break;case"bottomleft":m(),u();break;case"bottomright":m(),c()}this.setBounds({height:h,width:l,top:a,left:d})})),{dispose:()=>{for(const e of s)e.style.pointerEvents="auto"}},g(window,"mouseup",(()=>{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:e}dispose(){this._element.remove(),super.dispose()}}et.MINIMUM_HEIGHT=20,et.MINIMUM_WIDTH=20;class tt extends _{constructor(e,t){super(),this.group=e,this.overlay=t,this.addDisposables(t)}position(e){this.overlay.setBounds(e)}}class it extends _{constructor(e,t,i){super(),this.id=e,this.className=t,this.options=i,this._onDidClose=new v,this.onDidClose=this._onDidClose.event,this._window=null,this.addDisposables(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(){this._window&&(this._window.disposable.dispose(),this._window.value.close(),this._window=null)}open(e){if(this._window)throw new Error("instance of popout window is already open");const t=`${this.options.url}`,i=Object.entries({top:this.options.top,left:this.options.left,width:this.options.width,height:this.options.height}).map((([e,t])=>`${e}=${t}`)).join(","),n=window.open(t,this.id,i);if(!n)return;const s=new _;this._window={value:n,disposable:s};const o=()=>{this._onDidClose.fire(),this._window=null};s.addDisposables(g(window,"beforeunload",(()=>{o(),this.close()}))),n.addEventListener("load",(()=>{const t=n.document;t.title=document.title;const i=document.createElement("div");i.classList.add("dv-popout-window"),i.style.position="absolute",i.style.width="100%",i.style.height="100%",i.style.top="0px",i.style.left="0px",i.classList.add(this.className),i.appendChild(e),t.body.replaceChildren(i),t.body.classList.add(this.className),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){}for(const t of i){const i=e.createElement("style");i.appendChild(e.createTextNode(t)),e.head.appendChild(i)}}}(t,window.document.styleSheets),n.addEventListener("beforeunload",(()=>{o()}))}))}}class nt extends _{constructor(e,t,i){var n;super(),this.id=e,this.group=t,this.options=i,this.window=new it(e,null!==(n=i.className)&&void 0!==n?n:"",{url:this.options.popoutUrl,left:this.options.box.left,top:this.options.box.top,width:this.options.box.width,height:this.options.box.height}),t.model.location="popout",this.addDisposables(this.window,{dispose:()=>{t.model.location="grid"}},this.window.onDidClose((()=>{this.dispose()}))),this.window.open(t.element)}}const st=100,ot=100,rt=100;class at extends _{constructor(e){super(),this.element=e,this.map={},this.addDisposables(s.from((()=>{for(const e of Object.values(this.map))e.disposable.dispose(),e.destroy.dispose()})))}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",this.map[t.api.id]={panel:t,disposable:s.NONE,destroy:s.NONE,element:e}}const n=this.map[t.api.id].element;t.view.content.element.parentElement!==n&&n.appendChild(t.view.content.element),n.parentElement!==this.element&&this.element.appendChild(n);const o=()=>{const e=G(i.element),s=G(this.element);n.style.left=e.left-s.left+"px",n.style.top=e.top-s.top+"px",n.style.width=`${e.width}px`,n.style.height=`${e.height}px`,z(n,"dv-render-overlay-float","floating"===t.group.api.location)},r=()=>{t.api.isVisible&&o(),n.style.display=t.api.isVisible?"":"none"},a=new _(new pe(n,{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((e=>{r()})),t.api.onDidDimensionsChange((()=>{t.api.isVisible&&o()})));return this.map[t.api.id].destroy=s.from((()=>{n.removeChild(t.view.content.element),this.element.removeChild(n)})),queueMicrotask((()=>{this.isDisposed||r()})),this.map[t.api.id].disposable.dispose(),this.map[t.api.id].disposable=a,n}}const ht={activationSize:{type:"pixels",value:10},size:{type:"pixels",value:20}};class dt 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 activePanel(){const e=this.activeGroup;if(e)return e.activePanel}get renderer(){var e;return null!==(e=this.options.defaultRenderer)&&void 0!==e?e:"onlyWhenVisibile"}constructor(t){var i,n;super({proportionalLayout:!0,orientation:null!==(i=t.orientation)&&void 0!==i?i:e.Orientation.HORIZONTAL,styles:t.styles,parentElement:t.parentElement,disableAutoResizing:t.disableAutoResizing}),this.nextGroupId=M(),this._deserializer=new Ke(this),this.watermark=null,this._onWillDragPanel=new v,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new v,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new v,this.onDidDrop=this._onDidDrop.event,this._onDidRemovePanel=new v,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new v,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidLayoutFromJSON=new v,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new v,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._floatingGroups=[],this._popoutGroups=[];const o=document.createElement("div");o.className="dv-overlay-render-container",this.gridview.element.appendChild(o),this.overlayRenderContainer=new at(o),z(this.gridview.element,"dv-dockview",!0),z(this.element,"dv-debug",!!t.debug),this.addDisposables(this.overlayRenderContainer,this._onWillDragPanel,this._onWillDragGroup,this._onDidActivePanelChange,this._onDidAddPanel,this._onDidRemovePanel,this._onDidLayoutFromJSON,this._onDidDrop,e.DockviewEvent.any(this.onDidAddGroup,this.onDidRemoveGroup)((()=>{this.updateWatermark()})),e.DockviewEvent.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidActivePanelChange)((()=>{this._bufferOnDidLayoutChange.fire()})),s.from((()=>{for(const e of[...this._floatingGroups])e.dispose();for(const e of[...this._popoutGroups])e.dispose()}))),this._options=t,this.options.components||(this.options.components={}),this.options.frameworkComponents||(this.options.frameworkComponents={}),this.options.frameworkTabComponents||(this.options.frameworkTabComponents={}),this.options.tabComponents||(this.options.tabComponents={}),this.options.watermarkComponent||this.options.watermarkFrameworkComponent||(this.options.watermarkComponent=qe),this._rootDropTarget=new ge(this.element,{canDisplayOverlay:(t,i)=>{const n=p();return n?n.viewId===this.id&&("center"!==i||0===this.gridview.length):!!this.options.showDndOverlay&&(("center"!==i||0===this.gridview.length)&&this.options.showDndOverlay({nativeEvent:t,position:i,target:e.DockviewDropTargets.Edge,getData:p}))},acceptedTargetZones:["top","bottom","left","right","center"],overlayModel:null!==(n=this.options.rootOverlayModel)&&void 0!==n?n:ht}),this.addDisposables(this._rootDropTarget.onDrop((e=>{var t;const i=p();i?this.moveGroupOrPanel(this.orthogonalize(e.position),i.groupId,null!==(t=i.panelId)&&void 0!==t?t:void 0,"center"):this._onDidDrop.fire(Object.assign(Object.assign({},e),{api:this._api,group:null,getData:p}))})),this._rootDropTarget),this._api=new le(this),this.updateWatermark()}addPopoutGroup(e,t){var i;let n,s=null==t?void 0:t.position;if(e instanceof $e)n=this.createGroup(),this.removePanel(e,{removeEmptyGroup:!0,skipDispose:!0}),n.model.openPanel(e),s||(s=this.element.getBoundingClientRect());else{n=e,s||(s=n.element.getBoundingClientRect());"boolean"==typeof(null==t?void 0:t.skipRemoveGroup)&&t.skipRemoveGroup||this.doRemoveGroup(e,{skipDispose:!0})}const o=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,n=e;for(;null!==n&&(i=t(n).find((e=>e.startsWith("dockview-theme-"))),"string"!=typeof i);)n=n.parentElement;return i}(this.gridview.element),r=new nt(`${this.id}-${n.id}`,n,{className:null!=o?o:"",popoutUrl:null!==(i=null==t?void 0:t.popoutUrl)&&void 0!==i?i:"/popout.html",box:{left:window.screenX+s.left,top:window.screenY+s.top,width:s.width,height:s.height}});r.addDisposables({dispose:()=>{R(this._popoutGroups,r),this.updateWatermark()}},r.window.onDidClose((()=>{this.doAddGroup(n,[0])}))),this._popoutGroups.push(r),this.updateWatermark()}addFloatingGroup(e,t,i){var n,s,o,r,a,h;let d;if(e instanceof $e)d=this.createGroup(),this.removePanel(e,{removeEmptyGroup:!0,skipDispose:!0}),d.model.openPanel(e);else{d=e;"boolean"==typeof(null==i?void 0:i.skipRemoveGroup)&&i.skipRemoveGroup||this.doRemoveGroup(e,{skipDispose:!0})}d.model.location="floating";const l="number"==typeof(null==t?void 0:t.x)?Math.max(t.x,0):ot,p="number"==typeof(null==t?void 0:t.y)?Math.max(t.y,0):rt,m=new et({container:this.gridview.element,content:d.element,height:null!==(n=null==t?void 0:t.height)&&void 0!==n?n:300,width:null!==(s=null==t?void 0:t.width)&&void 0!==s?s:300,left:l,top:p,minimumInViewportWidth:"boundedWithinViewport"===this.options.floatingGroupBounds?void 0:null!==(r=null===(o=this.options.floatingGroupBounds)||void 0===o?void 0:o.minimumWidthWithinViewport)&&void 0!==r?r:st,minimumInViewportHeight:"boundedWithinViewport"===this.options.floatingGroupBounds?void 0:null!==(h=null===(a=this.options.floatingGroupBounds)||void 0===a?void 0:a.minimumHeightWithinViewport)&&void 0!==h?h:st}),u=d.element.querySelector(".void-container");if(!u)throw new Error("failed to find drag handle");m.setupDrag(u,{inDragMode:"boolean"==typeof(null==i?void 0:i.inDragMode)&&i.inDragMode});const c=new tt(d,m),v=C(d.element,(e=>{const{width:t,height:i}=e.contentRect;d.layout(t,i)}));c.addDisposables(m.onDidChange((()=>{d.layout(d.height,d.width)})),m.onDidChangeEnd((()=>{this._bufferOnDidLayoutChange.fire()})),d.onDidChange((e=>{m.setBounds({height:null==e?void 0:e.height,width:null==e?void 0:e.width})})),{dispose:()=>{v.dispose(),d.model.location="grid",R(this._floatingGroups,c),this.updateWatermark()}}),this._floatingGroups.push(c),this.updateWatermark()}orthogonalize(t){switch(t){case"top":case"bottom":this.gridview.orientation===e.Orientation.HORIZONTAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case"left":case"right":this.gridview.orientation===e.Orientation.VERTICAL&&this.gridview.insertOrthogonalSplitviewAtRoot()}switch(t){case"top":case"left":case"center":return this.createGroupAtLocation([0]);case"bottom":case"right":return this.createGroupAtLocation([this.gridview.length]);default:throw new Error(`unsupported position ${t}`)}}updateOptions(e){var t,i;const n="string"==typeof e.orientation&&this.gridview.orientation!==e.orientation,s=void 0!==e.floatingGroupBounds&&e.floatingGroupBounds!==this.options.floatingGroupBounds,o=void 0!==e.rootOverlayModel&&e.rootOverlayModel!==this.options.rootOverlayModel;if(this._options=Object.assign(Object.assign({},this.options),e),n&&(this.gridview.orientation=e.orientation),s)for(const e of this._floatingGroups){switch(this.options.floatingGroupBounds){case"boundedWithinViewport":e.overlay.minimumInViewportHeight=void 0,e.overlay.minimumInViewportWidth=void 0;break;case void 0:e.overlay.minimumInViewportHeight=st,e.overlay.minimumInViewportWidth=st;break;default:e.overlay.minimumInViewportHeight=null===(t=this.options.floatingGroupBounds)||void 0===t?void 0:t.minimumHeightWithinViewport,e.overlay.minimumInViewportWidth=null===(i=this.options.floatingGroupBounds)||void 0===i?void 0:i.minimumWidthWithinViewport}e.overlay.setBounds({})}o&&this._rootDropTarget.setOverlayModel(e.rootOverlayModel),this.layout(this.gridview.width,this.gridview.height,!0)}layout(e,t,i){if(super.layout(e,t,i),this._floatingGroups)for(const e of this._floatingGroups)e.overlay.setBounds()}focus(){var e;null===(e=this.activeGroup)||void 0===e||e.focus()}getGroupPanel(e){return this.panels.find((t=>t.id===e))}setActivePanel(e){this.doSetGroupActive(e.group),e.group.model.openPanel(e)}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),n=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupAndPanelActive(n)}moveToPrevious(e={}){var t;if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[0])return void e.group.model.moveToPrevious({suppressRoll:!0});const i=Q(e.group.element),n=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;n&&this.doSetGroupAndPanelActive(n)}toJSON(){var e;const t=this.gridview.serialize(),i=this.panels.reduce(((e,t)=>(e[t.id]=t.toJSON(),e)),{}),n=this._floatingGroups.map((e=>({data:e.group.toJSON(),position:e.overlay.toJSON()}))),s=this._popoutGroups.map((e=>({data:e.group.toJSON(),position:e.window.dimensions()}))),o={grid:t,panels:i,activeGroup:null===(e=this.activeGroup)||void 0===e?void 0:e.id};return n.length>0&&(o.floatingGroups=n),s.length>0&&(o.popoutGroups=s),o}fromJSON(e){var t,i;if(this.clear(),"object"!=typeof e||null===e)throw new Error("serialized layout must be a non-null object");const{grid:n,panels:s,activeGroup:o}=e;if("branch"!==n.root.type||!Array.isArray(n.root.data))throw new Error("root must be of type branch");try{const r=this.width,a=this.height,h=e=>{const{id:t,locked:i,hideHeader:n,views:o,activeView:r}=e;if("string"!=typeof t)throw new Error("group id must be of type string");const a=this.createGroup({id:t,locked:!!i,hideHeader:!!n}),h=[];for(const e of o){const t=this._deserializer.fromJSON(s[e],a);h.push(t)}this._onDidAddGroup.fire(a);for(let e=0;e<o.length;e++){const t=h[e],i="string"==typeof r&&r===t.id;a.model.openPanel(t,{skipSetPanelActive:!i,skipSetGroupActive:!0})}return!a.activePanel&&a.panels.length>0&&a.model.openPanel(a.panels[a.panels.length-1],{skipSetGroupActive:!0}),a};this.gridview.deserialize(n,{fromJSON:e=>h(e.data)}),this.layout(r,a,!0);const d=null!==(t=e.floatingGroups)&&void 0!==t?t:[];for(const e of d){const{data:t,position:i}=e,n=h(t);this.addFloatingGroup(n,{x:i.left,y:i.top,height:i.height,width:i.width},{skipRemoveGroup:!0,inDragMode:!1})}const l=null!==(i=e.popoutGroups)&&void 0!==i?i:[];for(const e of l){const{data:t,position:i}=e,n=h(t);this.addPopoutGroup(n,{skipRemoveGroup:!0,position:null!=i?i:void 0})}for(const e of this._floatingGroups)e.overlay.setBounds();if("string"==typeof o){const e=this.getPanel(o);e&&this.doSetGroupAndPanelActive(e)}}catch(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._onDidLayoutFromJSON.fire()}clear(){const e=Array.from(this._groups.values()).map((e=>e.value)),t=!!this.activeGroup,i=!!this.activePanel;for(const t of e)this.removeGroup(t,{skipActive:!0});t&&this.doSetGroupAndPanelActive(void 0),i&&this._onDidActivePanelChange.fire(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(`panel with id ${e.id} already exists`);let n,s;if(e.position&&e.floating)throw new Error("you can only provide one of: position, floating as arguments to .addPanel(...)");if(e.position)if(We(e.position)){const t="string"==typeof e.position.referencePanel?this.getGroupPanel(e.position.referencePanel):e.position.referencePanel;if(!t)throw new Error(`referencePanel ${e.position.referencePanel} does not exist`);n=this.findGroup(t)}else{if(!Fe(e.position)){const t=this.orthogonalize(me(e.position.direction)),i=this.createPanel(e,t);return t.model.openPanel(i),i}if(n="string"==typeof e.position.referenceGroup?null===(t=this._groups.get(e.position.referenceGroup))||void 0===t?void 0:t.value:e.position.referenceGroup,!n)throw new Error(`referencePanel ${e.position.referenceGroup} does not exist`)}else n=this.activeGroup;if(n){const t=Ae((null===(i=e.position)||void 0===i?void 0:i.direction)||"within");if(e.floating){const t=this.createGroup(),i="object"==typeof e.floating&&null!==e.floating?e.floating:{};this.addFloatingGroup(t,i,{inDragMode:!1,skipRemoveGroup:!0}),this._onDidAddGroup.fire(t),s=this.createPanel(e,t),t.model.openPanel(s),this.doSetGroupAndPanelActive(t)}else if("floating"===n.api.location||"center"===t)s=this.createPanel(e,n),n.model.openPanel(s);else{const i=Q(n.element),o=ee(this.gridview.orientation,i,t),r=this.createGroupAtLocation(o);s=this.createPanel(e,r),r.model.openPanel(s)}}else if(e.floating){const t=this.createGroup(),i="object"==typeof e.floating&&null!==e.floating?e.floating:{};this.addFloatingGroup(t,i,{inDragMode:!1,skipRemoveGroup:!0}),this._onDidAddGroup.fire(t),s=this.createPanel(e,t),t.model.openPanel(s),this.doSetGroupAndPanelActive(t)}else{const t=this.createGroupAtLocation();s=this.createPanel(e,t),t.model.openPanel(s)}return s}removePanel(e,t={removeEmptyGroup:!0,skipDispose:!1}){const i=e.group;if(!i)throw new Error(`cannot remove panel ${e.id}. it's missing a group.`);i.model.removePanel(e),t.skipDispose||(this.overlayRenderContainer.detatch(e),e.dispose()),0===i.size&&t.removeEmptyGroup&&this.removeGroup(i)}createWatermarkComponent(){var e;return b("watermark-id","watermark-name",this.options.watermarkComponent?{"watermark-name":this.options.watermarkComponent}:{},this.options.watermarkFrameworkComponent?{"watermark-name":this.options.watermarkFrameworkComponent}:{},null===(e=this.options.frameworkComponentFactory)||void 0===e?void 0:e.watermark)}updateWatermark(){var e,t;if(0===this.groups.filter((e=>"grid"===e.api.location)).length){if(!this.watermark){this.watermark=this.createWatermarkComponent(),this.watermark.init({containerApi:new le(this)});const e=document.createElement("div");e.className="dv-watermark-container",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;const i=this.createGroup(e);if(e){let n;if(Be(e)){const t="string"==typeof e.referencePanel?this.panels.find((t=>t.id===e.referencePanel)):e.referencePanel;if(!t)throw new Error(`reference panel ${e.referencePanel} does not exist`);if(n=this.findGroup(t),!n)throw new Error(`reference group for reference panel ${e.referencePanel} does not exist`)}else{if(!Je(e)){return this.orthogonalize(me(e.direction))}if(n="string"==typeof e.referenceGroup?null===(t=this._groups.get(e.referenceGroup))||void 0===t?void 0:t.value:e.referenceGroup,!n)throw new Error(`reference group ${e.referenceGroup} does not exist`)}const s=Ae(e.direction||"within"),o=Q(n.element),r=ee(this.gridview.orientation,o,s);return this.doAddGroup(i,r),i}return this.doAddGroup(i),i}removeGroup(e,t){var i;const n=[...e.panels];for(const e of n)this.removePanel(e,{removeEmptyGroup:!1,skipDispose:null!==(i=null==t?void 0:t.skipDispose)&&void 0!==i&&i});const s=this.activePanel;this.doRemoveGroup(e,t),this.activePanel!==s&&this._onDidActivePanelChange.fire(this.activePanel)}doRemoveGroup(e,t){if("floating"===e.api.location){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)),R(this._floatingGroups,i),i.dispose(),!(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 i.group}throw new Error("failed to find floating group")}if("popout"===e.api.location){const i=this._popoutGroups.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)),i.dispose(),!(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 i.group}throw new Error("failed to find popout group")}return super.doRemoveGroup(e,t)}moveGroupOrPanel(e,t,i,n,s){var o,r,a;const h=t?null===(o=this._groups.get(t))||void 0===o?void 0:o.value:void 0;if(void 0!==i)if(n&&"center"!==n){const t=Q(e.element),s=ee(this.gridview.orientation,t,n);if(h&&h.size<2){const[t,i]=N(s);if("grid"===h.api.location){const e=Q(h.element),[n,s]=N(e);V(n,t)&&this.gridview.moveView(n,s,i)}const o=this.doRemoveGroup(h,{skipActive:!0,skipDispose:!0}),r=Q(e.element),a=ee(this.gridview.orientation,r,n);this.doAddGroup(o,a)}else{const e=null!==(a=null==h?void 0:h.model.removePanel(i))&&void 0!==a?a:this.panels.find((e=>e.id===i));if(!e)throw new Error(`No panel with id ${i}`);const s=ee(this.gridview.orientation,t,n);this.createGroupAtLocation(s).model.openPanel(e)}}else{const t=null!==(r=null==h?void 0:h.model.removePanel(i))&&void 0!==r?r:this.panels.find((e=>e.id===i));if(!t)throw new Error(`No panel with id ${i}`);0===(null==h?void 0:h.model.size)&&this.doRemoveGroup(h),e.model.openPanel(t,{index:s})}else h&&this.moveGroup(h,e,n)}moveGroup(t,i,n){if(t)if(n&&"center"!==n){switch(t.api.location){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("failed to find floating group");e.dispose();break}case"popout":{const e=this._popoutGroups.find((e=>e.group===t));if(!e)throw new Error("failed to find popout group");e.dispose()}}const s=Q(i.element),o=ee(this.gridview.orientation,s,n);this.gridview.addView(t,e.Sizing.Distribute,o)}else{const e=t.activePanel,n=[...t.panels].map((e=>t.model.removePanel(e.id)));0===(null==t?void 0:t.model.size)&&this.doRemoveGroup(t);for(const t of n)i.model.openPanel(t,{skipSetPanelActive:t!==e})}}doSetGroupAndPanelActive(e,t){var i,n;const s=this.activePanel;super.doSetGroupActive(e,t),(null===(i=this._activeGroup)||void 0===i?void 0:i.activePanel)!==s&&this._onDidActivePanelChange.fire(null===(n=this._activeGroup)||void 0===n?void 0:n.activePanel)}createGroup(e){e||(e={});let t=null==e?void 0:e.id;if(t&&this._groups.has(e.id)&&(console.warn(`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 He(this,t,e);if(i.init({params:{},accessor:null}),!this._groups.has(i.id)){const e=new _(i.model.onTabDragStart((e=>{this._onWillDragPanel.fire(e)})),i.model.onGroupDragStart((e=>{this._onWillDragGroup.fire(e)})),i.model.onMove((e=>{const{groupId:t,itemId:n,target:s,index:o}=e;this.moveGroupOrPanel(i,t,n,s,o)})),i.model.onDidDrop((e=>{this._onDidDrop.fire(Object.assign(Object.assign({},e),{api:this._api,group:i}))})),i.model.onDidAddPanel((e=>{this._onDidAddPanel.fire(e.panel)})),i.model.onDidRemovePanel((e=>{this._onDidRemovePanel.fire(e.panel)})),i.model.onDidActivePanelChange((e=>{this._onDidActivePanelChange.fire(e.panel)})));this._groups.set(i.id,{value:i,disposable:e})}return i.initialize(),i}createPanel(e,t){var i,n,s;const o=e.component,r=null!==(i=e.tabComponent)&&void 0!==i?i:this.options.defaultTabComponent,a=new Xe(this,e.id,o,r),h=new $e(e.id,this,this._api,t,a,{renderer:e.renderer});return h.init({title:null!==(n=e.title)&&void 0!==n?n:e.id,params:null!==(s=null==e?void 0:e.params)&&void 0!==s?s:{}}),h}createGroupAtLocation(e=[0]){const t=this.createGroup();return this.doAddGroup(t,e),t}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}}class lt 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){super({parentElement:e.parentElement,proportionalLayout:e.proportionalLayout,orientation:e.orientation,styles:e.styles,disableAutoResizing:e.disableAutoResizing}),this._onDidLayoutfromJSON=new v,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._options=e,this.options.components||(this.options.components={}),this.options.frameworkComponents||(this.options.frameworkComponents={})}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=[],n=this.width,s=this.height;if(this.gridview.deserialize(t,{fromJSON:t=>{var i,n;const{data:s}=t,o=b(s.id,s.component,null!==(i=this.options.components)&&void 0!==i?i:{},null!==(n=this.options.frameworkComponents)&&void 0!==n?n:{},this.options.frameworkComponentFactory?{createComponent:this.options.frameworkComponentFactory.createComponent}:void 0);return e.push((()=>o.init({params:s.params,minimumWidth:s.minimumWidth,maximumWidth:s.maximumWidth,minimumHeight:s.minimumHeight,maximumHeight:s.maximumHeight,priority:s.priority,snap:!!s.snap,accessor:this,isVisible:t.visible}))),this._onDidAddGroup.fire(o),this.registerPanel(o),o}}),this.layout(n,s,!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 n;const s=this.gridview.remove(e),o=null===(i=this._groups.get(t.reference))||void 0===i?void 0:i.value;if(!o)throw new Error(`reference group ${t.reference} does not exist`);const r=Ae(t.direction);if("center"===r)throw new Error(`${r} not supported as an option`);{const e=Q(o.element);n=ee(this.gridview.orientation,e,r)}this.doAddGroup(s,n,t.size)}addPanel(e){var t,i,n,s,o,r;let a=null!==(t=e.location)&&void 0!==t?t:[0];if(null===(i=e.position)||void 0===i?void 0:i.referencePanel){const t=null===(n=this._groups.get(e.position.referencePanel))||void 0===n?void 0:n.value;if(!t)throw new Error(`reference group ${e.position.referencePanel} does not exist`);const i=Ae(e.position.direction);if("center"===i)throw new Error(`${i} not supported as an option`);{const e=Q(t.element);a=ee(this.gridview.orientation,e,i)}}const h=b(e.id,e.component,null!==(s=this.options.components)&&void 0!==s?s:{},null!==(o=this.options.frameworkComponents)&&void 0!==o?o:{},this.options.frameworkComponentFactory?{createComponent:this.options.frameworkComponentFactory.createComponent}:void 0);return h.init({params:null!==(r=e.params)&&void 0!==r?r:{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.registerPanel(h),this.doAddGroup(h,a,e.size),h}registerPanel(e){const t=new _(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 n=this.getPanel(t);if(!n)throw new Error("invalid operation");const s=Q(e.element),o=ee(this.gridview.orientation,s,i),[r,a]=N(o),h=Q(n.element),[d,l]=N(h);if(V(d,r))return void this.gridview.moveView(d,l,a);const p=this.doRemoveGroup(n,{skipActive:!0,skipDispose:!0}),m=Q(e.element),u=ee(this.gridview.orientation,m,i);this.doAddGroup(p,u)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}}class pt extends xe{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=e,this._splitviewChangeDisposable.value=new _(this._splitview.onDidSashEnd((()=>{this._onDidLayoutChange.fire(void 0)})),this._splitview.onDidAddView((e=>this._onDidAddView.fire(e))),this._splitview.onDidRemoveView((e=>this._onDidRemoveView.fire(e))))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation===e.Orientation.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===e.Orientation.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}constructor(e){super(e.parentElement,e.disableAutoResizing),this._splitviewChangeDisposable=new D,this._panels=new Map,this._onDidLayoutfromJSON=new v,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new v,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new v,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new v,this.onDidLayoutChange=this._onDidLayoutChange.event,this._options=e,e.components||(e.components={}),e.frameworkComponents||(e.frameworkComponents={}),this.splitview=new $(this.element,e),this.addDisposables(this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange)}updateOptions(e){const t="string"==typeof e.orientation&&this.options.orientation!==e.orientation;this._options=Object.assign(Object.assign({},this.options),e),t&&(this.splitview.orientation=e.orientation),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 n=this.panels.findIndex((t=>t===e));this.splitview.removeView(n,t).dispose();const s=this.panels;s.length>0&&this.setActive(s[s.length-1])}getPanel(e){return this.panels.find((t=>t.id===e))}addPanel(t){var i,n,s;if(this._panels.has(t.id))throw new Error(`panel ${t.id} already exists`);const o=b(t.id,t.component,null!==(i=this.options.components)&&void 0!==i?i:{},null!==(n=this.options.frameworkComponents)&&void 0!==n?n:{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.createComponent}:void 0);o.orientation=this.splitview.orientation,o.init({params:null!==(s=t.params)&&void 0!==s?s:{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:t.snap,priority:t.priority,accessor:this});const r="number"==typeof t.size?t.size:e.Sizing.Distribute,a="number"==typeof t.index?t.index:void 0;return this.splitview.addView(o,r,a),this.doAddView(o),this.setActive(o),o}layout(t,i){const[n,s]=this.splitview.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.splitview.layout(n,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:n,activeView:s}=e,o=[],r=this.width,a=this.height;if(this.splitview=new $(this.element,{orientation:i,proportionalLayout:this.options.proportionalLayout,descriptor:{size:n,views:t.map((e=>{var t,n;const s=e.data;if(this._panels.has(s.id))throw new Error(`panel ${s.id} already exists`);const r=b(s.id,s.component,null!==(t=this.options.components)&&void 0!==t?t:{},null!==(n=this.options.frameworkComponents)&&void 0!==n?n:{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.createComponent}:void 0);return o.push((()=>{var t;r.init({params:null!==(t=s.params)&&void 0!==t?t:{},minimumSize:s.minimumSize,maximumSize:s.maximumSize,snap:e.snap,priority:e.priority,accessor:this})})),r.orientation=i,this.doAddView(r),setTimeout((()=>{this._onDidAddView.fire(r)}),0),{size:e.size,view:r}}))}}),this.layout(r,a),o.forEach((e=>e())),"string"==typeof s){const e=this.getPanel(s);e&&this.setActive(e)}this._onDidLayoutfromJSON.fire()}clear(){for(const e of this._panels.values())e.dispose();for(this._panels.clear();this.splitview.length>0;){this.splitview.removeView(0,e.Sizing.Distribute,!0).dispose()}}dispose(){for(const e of this._panels.values())e.dispose();this._panels.clear();const e=this.splitview.getViews();this._splitviewChangeDisposable.dispose(),this.splitview.dispose();for(const t of e)t.dispose();super.dispose()}}class mt extends _{get element(){return this._element}constructor(){super(),this._expandedIcon=Ze({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=Ze({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"}),this.disposable=new D,this.apiRef={api:null},this._element=document.createElement("div"),this.element.className="default-header",this._content=document.createElement("span"),this._expander=document.createElement("div"),this._expander.className="dockview-pane-header-icon",this.element.appendChild(this._expander),this.element.appendChild(this._content),this.addDisposables(w(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);z(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 ut=M();class ct extends Le{constructor(e){super(e.accessor,e.id,e.component,e.headerComponent,e.orientation,e.isExpanded,e.disableDnd),this.options=e}getBodyComponent(){return this.options.body}getHeaderComponent(){return this.options.header}}class vt extends xe{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new _(this._paneview.onDidChange((()=>{this._onDidLayoutChange.fire(void 0)})),this._paneview.onDidAddView((e=>this._onDidAddView.fire(e))),this._paneview.onDidRemoveView((e=>this._onDidRemoveView.fire(e))))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation===e.Orientation.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===e.Orientation.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(t){super(t.parentElement,t.disableAutoResizing),this._id=ut.next(),this._disposable=new D,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new v,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new v,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new v,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new v,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new v,this.onDidRemoveView=this._onDidRemoveView.event,this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView),this._options=t,t.components||(t.components={}),t.frameworkComponents||(t.frameworkComponents={}),this.paneview=new Z(this.element,{orientation:e.Orientation.VERTICAL}),this.addDisposables(this._disposable)}focus(){}updateOptions(e){this._options=Object.assign(Object.assign({},this.options),e)}addPanel(t){var i,n,s,o;const r=b(t.id,t.component,null!==(i=this.options.components)&&void 0!==i?i:{},null!==(n=this.options.frameworkComponents)&&void 0!==n?n:{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.body.createComponent}:void 0);let a;a=t.headerComponent?b(t.id,t.headerComponent,null!==(s=this.options.headerComponents)&&void 0!==s?s:{},this.options.headerframeworkComponents,this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.header.createComponent}:void 0):new mt;const h=new ct({id:t.id,component:t.component,headerComponent:t.headerComponent,header:a,body:r,orientation:e.Orientation.VERTICAL,isExpanded:!!t.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this});this.doAddPanel(h);const d="number"==typeof t.size?t.size:e.Sizing.Distribute,l="number"==typeof t.index?t.index:void 0;return h.init({params:null!==(o=t.params)&&void 0!==o?o:{},minimumBodySize:t.minimumBodySize,maximumBodySize:t.maximumBodySize,isExpanded:t.isExpanded,title:t.title,containerApi:new he(this)}),this.paneview.addPane(h,d,l),h.orientation=this.paneview.orientation,h}removePanel(e){const t=this.panels.findIndex((t=>t===e));this.paneview.removePane(t),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find((t=>t.id===e))}layout(t,i){const[n,s]=this.paneview.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.paneview.layout(n,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:(n=t.minimumBodySize,n<=0?void 0:n),maximumSize:e(t.maximumBodySize),expanded:t.isExpanded()};var n})),size:this.paneview.size}}fromJSON(t){this.clear();const{views:i,size:n}=t,s=[],o=this.width,r=this.height;this.paneview=new Z(this.element,{orientation:e.Orientation.VERTICAL,descriptor:{size:n,views:i.map((t=>{var i,n,o,r;const a=t.data,h=b(a.id,a.component,null!==(i=this.options.components)&&void 0!==i?i:{},null!==(n=this.options.frameworkComponents)&&void 0!==n?n:{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.body.createComponent}:void 0);let d;d=a.headerComponent?b(a.id,a.headerComponent,null!==(o=this.options.headerComponents)&&void 0!==o?o:{},null!==(r=this.options.headerframeworkComponents)&&void 0!==r?r:{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.header.createComponent}:void 0):new mt;const l=new ct({id:a.id,component:a.component,headerComponent:a.headerComponent,header:d,body:h,orientation:e.Orientation.VERTICAL,isExpanded:!!t.expanded,disableDnd:!!this.options.disableDnd,accessor:this});return this.doAddPanel(l),s.push((()=>{var e;l.init({params:null!==(e=a.params)&&void 0!==e?e:{},minimumBodySize:t.minimumSize,maximumBodySize:t.maximumSize,title:a.title,isExpanded:!!t.expanded,containerApi:new he(this)}),l.orientation=this.paneview.orientation})),setTimeout((()=>{this._onDidAddView.fire(l)}),0),{size:t.size,view:l}}))}}),this.layout(o,r),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=e.onDidDrop((e=>{this._onDidDrop.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.paneview.dispose()}}class gt extends Ne{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 Oe(e)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=Number.POSITIVE_INFINITY,this._minimumSize=0,this._maximumSize=Number.POSITIVE_INFINITY,this._snap=!1,this._onDidChange=new v,this.onDidChange=this._onDidChange.event,this.api.initialize(this),this.addDisposables(this._onDidChange,this.api.onVisibilityChange((e=>{const{isVisible:t}=e,{accessor:i}=this._params;i.setVisible(this,t)})),this.api.onActiveChange((()=>{const{accessor:e}=this._params;e.setActive(this)})),this.api.onDidConstraintsChangeInternal((e=>{"number"!=typeof e.minimumSize&&"function"!=typeof e.minimumSize||(this._minimumSize=e.minimumSize),"number"!=typeof e.maximumSize&&"function"!=typeof e.maximumSize||(this._maximumSize=e.maximumSize),this.updateConstraints()})),this.api.onDidSizeChange((e=>{this._onDidChange.fire({size:e.size})})))}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(t,i){const[n,s]=this.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];super.layout(n,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})}}const wt=(e,t)=>{const[i,n]=o.useState(),s=o.useRef(e.componentProps);return o.useImperativeHandle(t,(()=>({update:e=>{s.current=Object.assign(Object.assign({},s.current),e),n(Date.now())}})),[]),o.createElement(e.component,s.current)};wt.displayName="DockviewReactJsBridge";const ft=(()=>{let e=1;return{next:()=>`dockview_react_portal_key_${(e++).toString()}`}})(),_t=o.createContext({});class Dt{constructor(e,t,i,n,s){this.parent=e,this.portalStore=t,this.component=i,this.parameters=n,this.context=s,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw new Error("invalid operation: resource is already disposed");this.componentInstance?this.componentInstance.update(e):this._initialProps=Object.assign(Object.assign({},this._initialProps),e)}createPortal(){if(this.disposed)throw new Error("invalid operation: resource is already disposed");if("function"!=typeof this.component)throw new Error("Invalid Operation. dockview only supports React Functional Components.");const e=o.createElement(o.forwardRef(wt),{component:this.component,componentProps:this.parameters,ref:e=>{this.componentInstance=e,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),t=this.context?o.createElement(_t.Provider,{value:this.context},e):e,i=r.createPortal(t,this.parent,ft.next());this.ref={portal:i,disposable:this.portalStore.addPortal(i)}}dispose(){var e;null===(e=this.ref)||void 0===e||e.disposable.dispose(),this.disposed=!0}}const bt=()=>{const[e,t]=o.useState([]);o.useDebugValue(`Portal count: ${e.length}`);return[e,o.useCallback((e=>{t((t=>[...t,e]));let i=!1;return{dispose:()=>{if(i)throw new Error("invalid operation: resource already disposed");i=!0,t((t=>t.filter((t=>t!==e))))}}}),[])]};class Ct{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._onDidFocus=new v,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new v,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dockview-react-part"}focus(){}init(e){this.part=new Dt(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;null===(t=this.part)||void 0===t||t.update(e.params)}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),null===(e=this.part)||void 0===e||e.dispose()}}class yt{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dockview-react-part"}focus(){}init(e){this.part=new Dt(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;null===(t=this.part)||void 0===t||t.update(e.params)}layout(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class St{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dockview-react-part"}init(e){this.part=new Dt(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi,close:()=>{e.group&&e.containerApi.removeGroup(e.group)}})}focus(){}update(e){var t,i,n;this.parameters&&(this.parameters.params=e.params),null===(t=this.part)||void 0===t||t.update({params:null!==(n=null===(i=this.parameters)||void 0===i?void 0:i.params)&&void 0!==n?n:{}})}layout(e,t){}updateParentGroup(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class zt{get element(){return this._element}get part(){return this._part}get group(){return this._group}constructor(e,t,i){this.component=e,this.reactPortalStore=t,this._group=i,this.mutableDisposable=new D,this._element=document.createElement("div"),this._element.className="dockview-react-part"}focus(){}init(e){this.mutableDisposable.value=new _(this._group.model.onDidAddPanel((()=>{this.updatePanels()})),this._group.model.onDidRemovePanel((()=>{this.updatePanels()})),this._group.model.onDidActivePanelChange((()=>{this.updateActivePanel()})),e.api.onDidActiveChange((()=>{this.updateGroupActive()}))),this._part=new Dt(this.element,this.reactPortalStore,this.component,{api:e.api,containerApi:e.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group})}update(e){var t;null===(t=this._part)||void 0===t||t.update(e.params)}dispose(){var e;this.mutableDisposable.dispose(),null===(e=this._part)||void 0===e||e.dispose()}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}}function xt(e,t){return e?i=>new zt(e,t,i):void 0}const Et="props.defaultTabComponent",At=o.forwardRef(((e,t)=>{const i=o.useRef(null),n=o.useRef(),[s,r]=bt();return o.useImperativeHandle(t,(()=>i.current),[]),o.useEffect((()=>{var t;if(!i.current)return()=>{};const s={content:{createComponent:(e,t,i)=>new Ct(t,i,{addPortal:r})},tab:{createComponent:(e,t,i)=>new yt(t,i,{addPortal:r})},watermark:{createComponent:(e,t,i)=>new St(t,i,{addPortal:r})}},o=null!==(t=e.tabComponents)&&void 0!==t?t:{};e.defaultTabComponent&&(o[Et]=e.defaultTabComponent);const a=new dt({parentElement:i.current,frameworkComponentFactory:s,frameworkComponents:e.components,disableAutoResizing:e.disableAutoResizing,frameworkTabComponents:o,watermarkFrameworkComponent:e.watermarkComponent,defaultTabComponent:e.defaultTabComponent?Et:void 0,styles:e.hideBorders?{separatorBorder:"transparent"}:void 0,showDndOverlay:e.showDndOverlay,createLeftHeaderActionsElement:xt(e.leftHeaderActionsComponent,{addPortal:r}),createRightHeaderActionsElement:xt(e.rightHeaderActionsComponent,{addPortal:r}),createPrefixHeaderActionsElement:xt(e.prefixHeaderActionsComponent,{addPortal:r}),singleTabMode:e.singleTabMode,disableFloatingGroups:e.disableFloatingGroups,floatingGroupBounds:e.floatingGroupBounds,defaultRenderer:e.defaultRenderer,debug:e.debug,rootOverlayModel:e.rootOverlayModel}),{clientWidth:h,clientHeight:d}=i.current;return a.layout(h,d),e.onReady&&e.onReady({api:new le(a)}),n.current=a,()=>{a.dispose()}}),[]),o.useEffect((()=>{if(!n.current)return()=>{};const t=n.current.onDidDrop((t=>{e.onDidDrop&&e.onDidDrop(t)}));return()=>{t.dispose()}}),[e.onDidDrop]),o.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:e.components})}),[e.components]),o.useEffect((()=>{n.current&&n.current.updateOptions({floatingGroupBounds:e.floatingGroupBounds})}),[e.floatingGroupBounds]),o.useEffect((()=>{n.current&&n.current.updateOptions({watermarkFrameworkComponent:e.watermarkComponent})}),[e.watermarkComponent]),o.useEffect((()=>{n.current&&n.current.updateOptions({showDndOverlay:e.showDndOverlay})}),[e.showDndOverlay]),o.useEffect((()=>{n.current&&n.current.updateOptions({frameworkTabComponents:e.tabComponents})}),[e.tabComponents]),o.useEffect((()=>{n.current&&n.current.updateOptions({disableFloatingGroups:e.disableFloatingGroups})}),[e.disableFloatingGroups]),o.useEffect((()=>{var t;if(!n.current)return;const i=null!==(t=e.tabComponents)&&void 0!==t?t:{};e.defaultTabComponent&&(i[Et]=e.defaultTabComponent),n.current.updateOptions({defaultTabComponent:e.defaultTabComponent?Et:void 0,frameworkTabComponents:i})}),[e.defaultTabComponent]),o.useEffect((()=>{n.current&&n.current.updateOptions({createRightHeaderActionsElement:xt(e.rightHeaderActionsComponent,{addPortal:r})})}),[e.rightHeaderActionsComponent]),o.useEffect((()=>{n.current&&n.current.updateOptions({createLeftHeaderActionsElement:xt(e.leftHeaderActionsComponent,{addPortal:r})})}),[e.leftHeaderActionsComponent]),o.useEffect((()=>{n.current&&n.current.updateOptions({rootOverlayModel:e.rootOverlayModel})}),[e.rootOverlayModel]),o.useEffect((()=>{n.current&&n.current.updateOptions({createPrefixHeaderActionsElement:xt(e.prefixHeaderActionsComponent,{addPortal:r})})}),[e.prefixHeaderActionsComponent]),o.createElement("div",{className:e.className,style:{height:"100%",width:"100%"},ref:i},s)}));At.displayName="DockviewComponent","function"==typeof SuppressedError&&SuppressedError;const Pt=()=>o.createElement("svg",{height:"11",width:"11",viewBox:"0 0 28 28","aria-hidden":"false",focusable:!1,className:"dockview-svg"},o.createElement("path",{d:"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"}));class It extends gt{constructor(e,t,i,n){super(e,t),this.reactComponent=i,this.reactPortalStore=n}getComponent(){var e,t;return new Dt(this.element,this.reactPortalStore,this.reactComponent,{params:null!==(t=null===(e=this._params)||void 0===e?void 0:e.params)&&void 0!==t?t:{},api:this.api,containerApi:new ae(this._params.accessor)})}}const Ot=o.forwardRef(((t,i)=>{const n=o.useRef(null),s=o.useRef(),[r,a]=bt();return o.useImperativeHandle(i,(()=>n.current),[]),o.useEffect((()=>{var i;const o=new pt({parentElement:n.current,disableAutoResizing:t.disableAutoResizing,orientation:null!==(i=t.orientation)&&void 0!==i?i:e.Orientation.HORIZONTAL,frameworkComponents:t.components,frameworkWrapper:{createComponent:(e,t,i)=>new It(e,t,i,{addPortal:a})},proportionalLayout:"boolean"!=typeof t.proportionalLayout||t.proportionalLayout,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0}),{clientWidth:r,clientHeight:h}=n.current;return o.layout(r,h),t.onReady&&t.onReady({api:new ae(o)}),s.current=o,()=>{o.dispose()}}),[]),o.useEffect((()=>{s.current&&s.current.updateOptions({frameworkComponents:t.components})}),[t.components]),o.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:n},r)}));Ot.displayName="SplitviewComponent";class Gt extends Re{constructor(e,t,i,n){super(e,t),this.reactComponent=i,this.reactPortalStore=n}getComponent(){var e,t;return new Dt(this.element,this.reactPortalStore,this.reactComponent,{params:null!==(t=null===(e=this._params)||void 0===e?void 0:e.params)&&void 0!==t?t:{},api:this.api,containerApi:new de(this._params.accessor)})}}const Nt=o.forwardRef(((t,i)=>{const n=o.useRef(null),s=o.useRef(),[r,a]=bt();return o.useImperativeHandle(i,(()=>n.current),[]),o.useEffect((()=>{var i;if(!n.current)return()=>{};const o=new lt({parentElement:n.current,disableAutoResizing:t.disableAutoResizing,proportionalLayout:"boolean"!=typeof t.proportionalLayout||t.proportionalLayout,orientation:null!==(i=t.orientation)&&void 0!==i?i:e.Orientation.HORIZONTAL,frameworkComponents:t.components,frameworkComponentFactory:{createComponent:(e,t,i)=>new Gt(e,t,i,{addPortal:a})},styles:t.hideBorders?{separatorBorder:"transparent"}:void 0}),{clientWidth:r,clientHeight:h}=n.current;return o.layout(r,h),t.onReady&&t.onReady({api:new de(o)}),s.current=o,()=>{o.dispose()}}),[]),o.useEffect((()=>{s.current&&s.current.updateOptions({frameworkComponents:t.components})}),[t.components]),o.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:n},r)}));Nt.displayName="GridviewComponent";class Vt{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new Dt(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;null===(t=this.part)||void 0===t||t.update(e.params)}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}const Lt=o.forwardRef(((e,t)=>{const i=o.useRef(null),n=o.useRef(),[s,r]=bt();return o.useImperativeHandle(t,(()=>i.current),[]),o.useEffect((()=>{const t=(e,t,i)=>new Vt(e,i,{addPortal:r}),s=new vt({parentElement:i.current,disableAutoResizing:e.disableAutoResizing,frameworkComponents:e.components,components:{},headerComponents:{},disableDnd:e.disableDnd,headerframeworkComponents:e.headerComponents,frameworkWrapper:{header:{createComponent:t},body:{createComponent:t}},showDndOverlay:e.showDndOverlay}),o=new he(s),{clientWidth:a,clientHeight:h}=i.current;return s.layout(a,h),e.onReady&&e.onReady({api:o}),n.current=s,()=>{s.dispose()}}),[]),o.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:e.components})}),[e.components]),o.useEffect((()=>{n.current&&n.current.updateOptions({headerframeworkComponents:e.headerComponents})}),[e.headerComponents]),o.useEffect((()=>{if(!n.current)return()=>{};const t=n.current,i=t.onDidDrop((i=>{e.onDidDrop&&e.onDidDrop(Object.assign(Object.assign({},i),{api:new he(t)}))}));return()=>{i.dispose()}}),[e.onDidDrop]),o.useEffect((()=>{n.current&&n.current.updateOptions({showDndOverlay:e.showDndOverlay})}),[e.showDndOverlay]),o.createElement("div",{className:e.className,style:{height:"100%",width:"100%"},ref:i},s)}));Lt.displayName="PaneviewComponent",e.BaseGrid=Pe,e.ContentContainer=fe,e.DefaultDockviewDeserialzier=Ke,e.DefaultTab=Ye,e.DockviewApi=le,e.DockviewComponent=dt,e.DockviewCompositeDisposable=_,e.DockviewDefaultTab=e=>{var{api:t,containerApi:i,params:n,hideClose:s,closeActionOverride:r}=e,a=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(i[n[s]]=e[n[s]])}return i}(e,["api","containerApi","params","hideClose","closeActionOverride"]);const h=o.useCallback((e=>{e.preventDefault(),r?r():t.close()}),[t,r]),d=o.useCallback((e=>{e.preventDefault()}),[]),l=o.useCallback((e=>{e.defaultPrevented||(t.setActive(),a.onClick&&a.onClick(e))}),[t,a.onClick]);return o.createElement("div",Object.assign({"data-testid":"dockview-default-tab"},a,{onClick:l,className:"dockview-react-tab"}),o.createElement("span",{className:"dockview-react-tab-title"},t.title),!s&&o.createElement("div",{className:"dv-react-tab-close-btn",onMouseDown:d,onClick:h},o.createElement(Pt,null)))},e.DockviewEmitter=v,e.DockviewGroupPanel=He,e.DockviewGroupPanelModel=ze,e.DockviewMutableDisposable=D,e.DockviewPanel=$e,e.DockviewReact=At,e.DraggablePaneviewPanel=Le,e.Gridview=re,e.GridviewApi=de,e.GridviewComponent=lt,e.GridviewPanel=Re,e.GridviewReact=Nt,e.LocalSelectionTransfer=l,e.PaneFramework=ct,e.PaneTransfer=d,e.PanelTransfer=h,e.Paneview=Z,e.PaneviewApi=he,e.PaneviewComponent=vt,e.PaneviewPanel=Ve,e.PaneviewReact=Lt,e.ReactPart=Dt,e.ReactPartContext=_t,e.Splitview=$,e.SplitviewApi=ae,e.SplitviewComponent=pt,e.SplitviewPanel=gt,e.SplitviewReact=Ot,e.Tab=be,e.createComponent=b,e.directionToPosition=me,e.getDirectionOrientation=te,e.getGridLocation=Q,e.getLocationOrientation=ie,e.getPaneData=m,e.getPanelData=p,e.getRelativeLocation=ee,e.indexInParent=q,e.isGridBranchNode=se,e.isGroupOptionsWithGroup=Je,e.isGroupOptionsWithPanel=Be,e.isPanelOptionsWithGroup=Fe,e.isPanelOptionsWithPanel=We,e.isReactElement=function(e){return!!(null==e?void 0:e.type)},e.orthogonal=ne,e.positionToDirection=ue,e.toTarget=Ae,e.usePortalsLifecycle=bt}));
8
8
  //# sourceMappingURL=dockview.min.noStyle.js.map