dockview 1.7.2 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dockview.amd.js +284 -196
- package/dist/dockview.amd.min.js +2 -2
- package/dist/dockview.amd.min.noStyle.js +2 -2
- package/dist/dockview.amd.noStyle.js +284 -196
- package/dist/dockview.cjs.js +284 -196
- package/dist/dockview.esm.js +284 -196
- package/dist/dockview.esm.min.js +2 -2
- package/dist/dockview.js +284 -196
- package/dist/dockview.min.js +2 -2
- package/dist/dockview.min.noStyle.js +2 -2
- package/dist/dockview.noStyle.js +284 -196
- package/package.json +4 -5
package/dist/dockview.esm.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview
|
|
3
|
-
* @version 1.7.
|
|
3
|
+
* @version 1.7.4
|
|
4
4
|
* @link https://github.com/mathuo/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import*as e from"react";import*as t from"react-dom";var i,s;!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&s.firstChild?s.insertBefore(n,s.firstChild):s.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}('@import "dockview-core/dist/styles/dockview.css";\n.tab .dockview-react-tab {\n display: flex;\n padding: 0px 8px;\n align-items: center;\n height: 100%;\n}\n.tab .dockview-react-tab .dockview-react-tab-title {\n padding: 0px 8px;\n flex-grow: 1;\n}\n.tab .dockview-react-tab .dockview-react-tab-action {\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n}\n.tab .dockview-react-tab .dockview-react-tab-action:hover {\n border-radius: 2px;\n background-color: var(--dv-icon-hover-background-color);\n}\n.tab.inactive-tab:not(:hover) .dockview-react-tab-action {\n visibility: hidden;\n}\n.dockview-react-part {\n height: 100%;\n width: 100%;\n}');class n{constructor(){}}class o extends n{constructor(e,t,i){super(),this.viewId=e,this.groupId=t,this.panelId=i}}class r extends n{constructor(e,t){super(),this.viewId=e,this.paneId=t}}class a{constructor(){}static getInstance(){return a.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 h(){const e=a.getInstance();if(e.hasData(o.prototype))return e.getData(o.prototype)[0]}function d(){const e=a.getInstance();if(e.hasData(r.prototype))return e.getData(r.prototype)[0]}a.INSTANCE=new a,function(e){e.any=(...e)=>t=>{const i=e.map((e=>e(t)));return{dispose:()=>{i.forEach((e=>{e.dispose()}))}}}}(i||(i={}));class l{constructor(e){this.options=e,this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=e=>{var t;return(null===(t=this.options)||void 0===t?void 0:t.replay)&&void 0!==this._last&&e(this._last),this._listeners.push(e),{dispose:()=>{const t=this._listeners.indexOf(e);t>-1&&this._listeners.splice(t,1)}}}),this._event}fire(e){this._last=e;for(const t of this._listeners)t(e)}dispose(){this._listeners=[],this._disposed=!0}}function p(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i)}}}function m(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i)}}}class c{constructor(){this._onFired=new l,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:()=>{}}}(s||(s={}));class u{get isDisposed(){return this._isDisposed}static from(...e){return new u(...e)}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 v{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 g(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 w=(e,...t)=>{for(const i of t)e.classList.contains(i)&&e.classList.remove(i)},_=(e,...t)=>{for(const i of t)e.classList.contains(i)||e.classList.add(i)},f=(e,t,i)=>{const s=e.classList.contains(t);i&&!s&&e.classList.add(t),!i&&s&&e.classList.remove(t)};function D(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function b(e){return Array.prototype.slice.call(document.getElementsByTagName(e),0)}function C(e){return new y(e)}class y extends u{constructor(e){super(),this._onDidFocus=new l,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new l,this.onDidBlur=this._onDidBlur.event;let t=D(document.activeElement,e),i=!1;const s=()=>{i=!1,t||(t=!0,this._onDidFocus.fire())},n=()=>{t&&(i=!0,window.setTimeout((()=>{i&&(i=!1,t=!1,this._onDidBlur.fire())}),0))};this._refreshStateHandler=()=>{D(document.activeElement,e)!==t&&(t?n():s())},e instanceof HTMLElement?(this.addDisposables(m(e,"focus",s,!0)),this.addDisposables(m(e,"blur",n,!0))):(this.addDisposables(p(e,"focus",s,!0)),this.addDisposables(p(e,"blur",n,!0)))}refreshState(){this._refreshStateHandler()}dispose(){super.dispose(),this._onDidBlur.dispose(),this._onDidFocus.dispose()}}function S(e,t,i={},s={},n,o){const r="string"==typeof t?i[t]:void 0,a="string"==typeof t?s[t]:void 0;if(r&&a)throw new Error(`Cannot create '${e}'. component '${t}' registered as both a component and frameworkComponent`);if(a){if(!n)throw new Error(`Cannot create '${e}' for framework component '${t}'. you must register a frameworkPanelWrapper to use framework components`);return n.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 z(e){if(0===e.length)throw new Error("Invalid tail call");return[e.slice(0,e.length-1),e[e.length-1]]}function x(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 E(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.unshift(t))}function A(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.push(t))}const P=(e,t,i)=>{if(t>i)throw new Error(`${t} > ${i} is an invalid condition`);return Math.min(i,Math.max(e,t))},O=()=>{let e=1;return{next:()=>(e++).toString()}},I=(e,t)=>{const i=[];if("number"!=typeof t&&(t=e,e=0),e<=t)for(let s=e;s<t;s++)i.push(s);else for(let s=e;s>t;s--)i.push(s);return i};class N{set size(e){this._size=e}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return void 0===this._cachedVisibleSize}get minimumSize(){return this.visible?this.view.minimumSize:0}get viewMinimumSize(){return this.view.minimumSize}get maximumSize(){return this.visible?this.view.maximumSize:0}get viewMaximumSize(){return this.view.maximumSize}get priority(){return this.view.priority}get snap(){return!!this.view.snap}set enabled(e){this.container.style.pointerEvents=e?"":"none"}constructor(e,t,i,s){this.container=e,this.view=t,this.disposable=s,this._cachedVisibleSize=void 0,"number"==typeof i?(this._size=i,this._cachedVisibleSize=void 0,e.classList.add("visible")):(this._size=0,this._cachedVisibleSize=i.cachedVisibleSize)}setVisible(e,t){var i;e!==this.visible&&(e?(this.size=P(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 V,L,k,G;!function(e){e.HORIZONTAL="HORIZONTAL",e.VERTICAL="VERTICAL"}(V||(V={})),function(e){e[e.MAXIMUM=0]="MAXIMUM",e[e.MINIMUM=1]="MINIMUM",e[e.DISABLED=2]="DISABLED",e[e.ENABLED=3]="ENABLED"}(L||(L={})),function(e){e.Low="low",e.High="high",e.Normal="normal"}(k||(k={})),function(e){e.Distribute={type:"distribute"},e.Split=function(e){return{type:"split",index:e}},e.Invisible=function(e){return{type:"invisible",cachedVisibleSize:e}}}(G||(G={}));class T{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.views.length}get proportions(){return this._proportions?[...this._proportions]:void 0}get orientation(){return this._orientation}set orientation(e){this._orientation=e;const t=this.size;this.size=this.orthogonalSize,this.orthogonalSize=t,w(this.element,"horizontal","vertical"),this.element.classList.add(this.orientation==V.HORIZONTAL?"horizontal":"vertical")}get minimumSize(){return this.views.reduce(((e,t)=>e+t.minimumSize),0)}get maximumSize(){return 0===this.length?Number.POSITIVE_INFINITY:this.views.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.views=[],this.sashes=[],this._size=0,this._orthogonalSize=0,this.contentSize=0,this._proportions=void 0,this._startSnappingEnabled=!0,this._endSnappingEnabled=!0,this._onDidSashEnd=new l,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new l,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new l,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(e,t,i=this.views.map((e=>e.size)),s,n,o=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY,a,h)=>{if(e<0||e>this.views.length)return 0;const d=I(e,-1),l=I(e+1,this.views.length);if(n)for(const e of n)E(d,e),E(l,e);if(s)for(const e of s)A(d,e),A(l,e);const p=d.map((e=>this.views[e])),m=d.map((e=>i[e])),c=l.map((e=>this.views[e])),u=l.map((e=>i[e])),v=d.reduce(((e,t)=>e+this.views[t].minimumSize-i[t]),0),g=d.reduce(((e,t)=>e+this.views[t].maximumSize-i[t]),0),w=0===l.length?Number.POSITIVE_INFINITY:l.reduce(((e,t)=>e+i[t]-this.views[t].minimumSize),0),_=0===l.length?Number.NEGATIVE_INFINITY:l.reduce(((e,t)=>e+i[t]-this.views[t].maximumSize),0),f=Math.max(v,_),D=Math.min(w,g);let b=!1;if(a){const e=this.views[a.index],i=t>=a.limitDelta;b=i!==e.visible,e.setVisible(i,a.size)}if(!b&&h){const e=this.views[h.index],i=t<h.limitDelta;b=i!==e.visible,e.setVisible(i,h.size)}if(b)return this.resize(e,t,i,s,n,o,r);let C=0,y=P(t,f,D);for(let e=0;e<p.length;e++){const t=p[e],i=P(m[e]+y,t.minimumSize,t.maximumSize),s=i-m[e];C+=s,y-=s,t.size=i}let S=C;for(let e=0;e<c.length;e++){const t=c[e],i=P(u[e]-S,t.minimumSize,t.maximumSize);S+=i-u[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},s=e.view;this.addView(s,i,t,!0)})),this.contentSize=this.views.reduce(((e,t)=>e+t.size),0),this.saveProportions())}style(e){"transparent"===(null==e?void 0:e.separatorBorder)?(w(this.element,"separator-border"),this.element.style.removeProperty("--dv-separator-border")):(_(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.views.length)throw new Error("Index out of bounds");return this.views[e].visible}setViewVisible(e,t){if(e<0||e>=this.views.length)throw new Error("Index out of bounds");f(this.container,"visible",t);const i=this.views[e];f(this.container,"visible",t),i.setVisible(t,i.size),this.distributeEmptySpace(e),this.layoutViews(),this.saveProportions()}getViewSize(e){return e<0||e>=this.views.length?-1:this.views[e].size}resizeView(e,t){if(e<0||e>=this.views.length)return;const i=I(this.views.length).filter((t=>t!==e)),s=[...i.filter((e=>this.views[e].priority===k.Low)),e],n=i.filter((e=>this.views[e].priority===k.High)),o=this.views[e];t=Math.round(t),t=P(t,o.minimumSize,Math.min(o.maximumSize,this._size)),o.size=t,this.relayout(s,n)}getViews(){return this.views.map((e=>e.view))}onDidChange(e,t){const i=this.views.indexOf(e);i<0||i>=this.views.length||(t="number"==typeof t?t:e.size,t=P(t,e.minimumSize,e.maximumSize),e.size=t,this.relayout([i]))}addView(e,t={type:"distribute"},i=this.views.length,s){const n=document.createElement("div");let o;n.className="view",n.appendChild(e.element),o="number"==typeof t?t:"split"===t.type?this.getViewSize(t.index)/2:"invisible"===t.type?{cachedVisibleSize:t.cachedVisibleSize}:e.minimumSize;const r=e.onDidChange((e=>this.onDidChange(a,e.size))),a=new N(n,e,o,{dispose:()=>{null==r||r.dispose(),this.viewContainer.removeChild(n)}});if(i===this.views.length?this.viewContainer.appendChild(n):this.viewContainer.insertBefore(n,this.viewContainer.children.item(i)),this.views.splice(i,0,a),this.views.length>1){const e=document.createElement("div");e.className="sash";const t=t=>{for(const e of this.views)e.enabled=!1;const i=[...b("iframe"),...b("webview")];for(const e of i)e.style.pointerEvents="none";const s=this._orientation===V.HORIZONTAL?t.clientX:t.clientY,n=function(e,t){for(let i=0;i<e.length;i++)if(t(e[i]))return i;return-1}(this.sashes,(t=>t.container===e)),o=this.views.map((e=>e.size));let r,a;const h=I(n,-1),d=I(n+1,this.views.length),l=h.reduce(((e,t)=>e+(this.views[t].minimumSize-o[t])),0),p=h.reduce(((e,t)=>e+(this.views[t].viewMaximumSize-o[t])),0),m=0===d.length?Number.POSITIVE_INFINITY:d.reduce(((e,t)=>e+(o[t]-this.views[t].minimumSize)),0),c=0===d.length?Number.NEGATIVE_INFINITY:d.reduce(((e,t)=>e+(o[t]-this.views[t].viewMaximumSize)),0),u=Math.max(l,c),v=Math.min(m,p),g=this.findFirstSnapIndex(h),w=this.findFirstSnapIndex(d);if("number"==typeof g){const e=this.views[g],t=Math.floor(e.viewMinimumSize/2);r={index:g,limitDelta:e.visible?u-t:u+t,size:e.size}}if("number"==typeof w){const e=this.views[w],t=Math.floor(e.viewMinimumSize/2);a={index:w,limitDelta:e.visible?v+t:v-t,size:e.size}}const _=e=>{const t=(this._orientation===V.HORIZONTAL?e.clientX:e.clientY)-s;this.resize(n,t,o,void 0,void 0,u,v,r,a),this.distributeEmptySpace(),this.layoutViews()},f=()=>{for(const e of this.views)e.enabled=!0;for(const e of i)e.style.pointerEvents="auto";this.saveProportions(),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",f),document.removeEventListener("mouseend",f),this._onDidSashEnd.fire(void 0)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",f),document.addEventListener("mouseend",f)};e.addEventListener("mousedown",t);const i={container:e,disposable:()=>{e.removeEventListener("mousedown",t),this.sashContainer.removeChild(e)}};this.sashContainer.appendChild(e),this.sashes.push(i)}s||this.relayout([i]),s||"number"==typeof t||"distribute"!==t.type||this.distributeViewSizes(),this._onDidAddView.fire(e)}distributeViewSizes(){const e=[];let t=0;for(const i of this.views)i.maximumSize-i.minimumSize>0&&(e.push(i),t+=i.size);const i=Math.floor(t/e.length);for(const t of e)t.size=P(i,t.minimumSize,t.maximumSize);const s=I(this.views.length),n=s.filter((e=>this.views[e].priority===k.Low)),o=s.filter((e=>this.views[e].priority===k.High));this.relayout(n,o)}removeView(e,t,i=!1){const s=this.views.splice(e,1)[0];if(s.dispose(),this.views.length>=1){const t=Math.max(e-1,0);this.sashes.splice(t,1)[0].disposable()}return i||this.relayout(),t&&"distribute"===t.type&&this.distributeViewSizes(),this._onDidRemoveView.fire(s.view),s.view}getViewCachedVisibleSize(e){if(e<0||e>=this.views.length)throw new Error("Index out of bounds");return this.views[e].cachedVisibleSize}moveView(e,t){const i=this.getViewCachedVisibleSize(e),s=void 0===i?this.getViewSize(e):G.Invisible(i),n=this.removeView(e,void 0,!0);this.addView(n,s,t)}layout(e,t){const i=Math.max(this.size,this.contentSize);if(this.size=e,this.orthogonalSize=t,this.proportions)for(let t=0;t<this.views.length;t++){const i=this.views[t];i.size=P(Math.round(this.proportions[t]*e),i.minimumSize,i.maximumSize)}else{const t=I(this.views.length),s=t.filter((e=>this.views[e].priority===k.Low)),n=t.filter((e=>this.views[e].priority===k.High));this.resize(this.views.length-1,e-i,void 0,s,n)}this.distributeEmptySpace(),this.layoutViews()}relayout(e,t){const i=this.views.reduce(((e,t)=>e+t.size),0);this.resize(this.views.length-1,this._size-i,void 0,e,t),this.distributeEmptySpace(),this.layoutViews(),this.saveProportions()}distributeEmptySpace(e){const t=this.views.reduce(((e,t)=>e+t.size),0);let i=this.size-t;const s=I(this.views.length-1,-1),n=s.filter((e=>this.views[e].priority===k.Low)),o=s.filter((e=>this.views[e].priority===k.High));for(const e of o)E(s,e);for(const e of n)A(s,e);"number"==typeof e&&A(s,e);for(let e=0;0!==i&&e<s.length;e++){const t=this.views[s[e]],n=P(t.size+i,t.minimumSize,t.maximumSize);i-=n-t.size,t.size=n}}saveProportions(){this.proportionalLayout&&this.contentSize>0&&(this._proportions=this.views.map((e=>e.size/this.contentSize)))}layoutViews(){this.contentSize=this.views.reduce(((e,t)=>e+t.size),0);let e=0;const t=[];this.updateSashEnablement();for(let i=0;i<this.views.length-1;i++){e+=this.views[i].size,t.push(e);const s=Math.min(Math.max(0,e-2),this.size-4);this._orientation===V.HORIZONTAL&&(this.sashes[i].container.style.left=`${s}px`,this.sashes[i].container.style.top="0px"),this._orientation===V.VERTICAL&&(this.sashes[i].container.style.left="0px",this.sashes[i].container.style.top=`${s}px`)}this.views.forEach(((e,i)=>{this._orientation===V.HORIZONTAL&&(e.container.style.width=`${e.size}px`,e.container.style.left=0==i?"0px":`${t[i-1]}px`,e.container.style.top="",e.container.style.height=""),this._orientation===V.VERTICAL&&(e.container.style.height=`${e.size}px`,e.container.style.top=0==i?"0px":`${t[i-1]}px`,e.container.style.width="",e.container.style.left=""),e.view.layout(e.size,this._orthogonalSize)}))}findFirstSnapIndex(e){for(const t of e){const e=this.views[t];if(e.visible&&e.snap)return t}for(const t of e){const e=this.views[t];if(e.visible&&e.maximumSize-e.minimumSize>0)return;if(!e.visible&&e.snap)return t}}updateSashEnablement(){let e=!1;const t=this.views.map((t=>e=t.size-t.minimumSize>0||e));e=!1;const i=this.views.map((t=>e=t.maximumSize-t.size>0||e)),s=[...this.views].reverse();e=!1;const n=s.map((t=>e=t.size-t.minimumSize>0||e)).reverse();e=!1;const o=s.map((t=>e=t.maximumSize-t.size>0||e)).reverse();let r=0;for(let e=0;e<this.sashes.length;e++){const s=this.sashes[e];r+=this.views[e].size;const a=!(t[e]&&o[e+1]),h=!(i[e]&&n[e+1]);if(a&&h){const i=I(e,-1),o=I(e+1,this.views.length),a=this.findFirstSnapIndex(i),h=this.findFirstSnapIndex(o),d="number"==typeof a&&!this.views[a].visible,l="number"==typeof h&&!this.views[h].visible;d&&n[e]&&(r>0||this.startSnappingEnabled)?this.updateSash(s,L.MINIMUM):l&&t[e]&&(r<this.contentSize||this.endSnappingEnabled)?this.updateSash(s,L.MAXIMUM):this.updateSash(s,L.DISABLED)}else a&&!h?this.updateSash(s,L.MINIMUM):!a&&h?this.updateSash(s,L.MAXIMUM):this.updateSash(s,L.ENABLED)}}updateSash(e,t){f(e.container,"disabled",t===L.DISABLED),f(e.container,"enabled",t===L.ENABLED),f(e.container,"maximum",t===L.MAXIMUM),f(e.container,"minimum",t===L.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 e=document.createElement("div"),t=this._orientation===V.HORIZONTAL?"horizontal":"vertical";return e.className=`split-view-container ${t}`,e}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.removeChild(this.element);break}this.element.remove()}}class R extends u{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(e,t){var i;super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new l,this.onDidChange=this._onDidChange.event,this._orientation=null!==(i=t.orientation)&&void 0!==i?i:V.VERTICAL,this.element=document.createElement("div"),this.element.className="pane-container",e.appendChild(this.element),this.splitview=new T(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:t.descriptor}),this.getPanes().forEach((e=>{const t=new u(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,s=!1){const n=e.onDidChangeExpansionState((()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),o={pane:e,disposable:{dispose:()=>{n.dispose()}}};this.paneItems.splice(i,0,o),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,i,s)}getViewSize(e){return this.splitview.getViewSize(e)}getPanes(){return this.splitview.getViews()}removePane(e,t={skipDispose:!1}){const i=this.paneItems.splice(e,1)[0];return this.splitview.removeView(e),t.skipDispose||(i.disposable.dispose(),i.pane.dispose()),i}moveView(e,t){if(e===t)return;const i=this.removePane(e,{skipDispose:!0});this.skipAnimation=!0;try{this.addPane(i.pane,i.pane.size,t,!1)}finally{this.skipAnimation=!1}}layout(e,t){this.splitview.layout(e,t)}setupAnimation(){this.skipAnimation||(this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=void 0),_(this.element,"animated"),this.animationTimer=setTimeout((()=>{this.animationTimer=void 0,w(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 H{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===V.HORIZONTAL?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===V.HORIZONTAL?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===V.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===V.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===V.HORIZONTAL?this.orthogonalSize:this.size}get height(){return this.orientation===V.HORIZONTAL?this.size:this.orthogonalSize}constructor(e,t,i,s=0){this.view=e,this.orientation=t,this._onDidChange=new l,this.onDidChange=this._onDidChange.event,this._orthogonalSize=i,this._size=s,this._disposable=this.view.onDidChange((e=>{e?this._onDidChange.fire({size:this.orientation===V.VERTICAL?e.width:e.height,orthogonalSize:this.orientation===V.VERTICAL?e.height:e.width}):this._onDidChange.fire({})}))}setVisible(e){this.view.setVisible&&(this.view.setVisible(e),this._onDidChange.fire({}))}layout(e,t){this._size=e,this._orthogonalSize=t,this.view.layout(this.width,this.height)}dispose(){this._onDidChange.dispose(),this._disposable.dispose()}}class M extends u{get width(){return this.orientation===V.HORIZONTAL?this.size:this.orthogonalSize}get height(){return this.orientation===V.HORIZONTAL?this.orthogonalSize:this.size}get minimumSize(){return 0===this.children.length?0:Math.max(...this.children.map((e=>e.minimumOrthogonalSize)))}get maximumSize(){return Math.min(...this.children.map((e=>e.maximumOrthogonalSize)))}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===V.HORIZONTAL?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===V.HORIZONTAL?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===V.HORIZONTAL?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===V.HORIZONTAL?this.maximumSize:this.maximumOrthogonalSize}get priority(){if(0===this.children.length)return k.Normal;const e=this.children.map((e=>void 0===e.priority?k.Normal:e.priority));return e.some((e=>e===k.High))?k.High:e.some((e=>e===k.Low))?k.Low:k.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 l,this.onDidChange=this._onDidChange.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 H&&void 0!==e.visible)||e.visible}))),size:this.size};this.children=r.map((e=>e.node)),this.splitview=new T(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:t})}else this.splitview=new T(this.element,{orientation:this.orientation,proportionalLayout:t,styles:i}),this.splitview.layout(this.size,this.orthogonalSize);this.addDisposables(this._onDidChange,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");this.splitview.isViewVisible(e)!==t&&this.splitview.setViewVisible(e,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(this.size,this.orthogonalSize)}addChild(e,t,i,s){if(i<0||i>this.children.length)throw new Error("Invalid index");this.splitview.addView(e,t,i,s),this._addChild(e,i)}getChildCachedVisibleSize(e){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewCachedVisibleSize(e)}removeChild(e,t){if(e<0||e>=this.children.length)throw new Error("Invalid index");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=i.any(...this.children.map((e=>e.onDidChange)))((e=>{this._onDidChange.fire({size:e.orthogonalSize})}))}dispose(){super.dispose(),this._childrenDisposable.dispose(),this.children.forEach((e=>e.dispose())),this.splitview.dispose()}}function F(e,t){if(e instanceof H)return e;if(e instanceof M)return F(e.children[t?e.children.length-1:0],t);throw new Error("invalid node")}function W(e,t,i){if(e instanceof M){const s=new M(U(e.orientation),e.proportionalLayout,e.styles,t,i);let n=0;for(let o=e.children.length-1;o>=0;o--){const r=e.children[o],a=r instanceof M?r.orthogonalSize:r.size;let h=0===e.size?0:Math.round(t*a/e.size);n+=h,0===o&&(h+=t-n),s.addChild(W(r,i,h),h,0,!0)}return s}return new H(e.view,U(e.orientation),i)}function J(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");let i=t.firstElementChild,s=0;for(;i!==e&&i!==t.lastElementChild&&i;)i=i.nextElementSibling,s++;return s}function B(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");if(/\bgrid-view\b/.test(t.className))return[];const i=J(t);return[...B(t.parentElement.parentElement.parentElement),i]}function j(e,t,i){if(Z(e,t)===$(i)){const[e,s]=z(t);let n=s;return"right"!==i&&"bottom"!==i||(n+=1),[...e,n]}{const e="right"===i||"bottom"===i?1:0;return[...t,e]}}function $(e){return"top"===e||"bottom"===e?V.VERTICAL:V.HORIZONTAL}function Z(e,t){return t.length%2==0?U(e):e}const U=e=>e===V.HORIZONTAL?V.VERTICAL:V.HORIZONTAL;function Y(e){return!!e.children}const X=(e,t)=>{const i=t===V.VERTICAL?e.box.width:e.box.height;return Y(e)?{type:"branch",data:e.children.map((e=>X(e,U(t)))),size:i}:"number"==typeof e.cachedVisibleSize?{type:"leaf",data:e.view.toJSON(),size:e.cachedVisibleSize,visible:!1}:{type:"leaf",data:e.view.toJSON(),size:i}};class Q{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=W(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}serialize(){return{root:X(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this.root.dispose(),this.element.remove()}clear(){const e=this.root.orientation;this.root=new M(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize)}deserialize(e,t){const i=e.orientation,s=i===V.VERTICAL?e.height:e.width;this._deserialize(e.root,i,t,s)}_deserialize(e,t,i,s){this.root=this._deserializeNode(e,t,i,s,!0)}_deserializeNode(e,t,i,s,n=!1){let o;if("branch"===e.type){const r=e.data.map((s=>({node:this._deserializeNode(s,U(t),i,e.size),visible:s.visible})));o=new M(t,this.proportionalLayout,this.styles,n?s:e.size,n?e.size:s,r)}else o=new H(i.fromJSON(e),t,s,e.size);return o}get root(){return this._root}set root(e){const t=this._root;t&&(t.dispose(),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 e=this.root;if(e.element.remove(),this._root=new M(U(e.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size),1===e.children.length){const t=e.children[0];e.removeChild(0),e.dispose(),this._root.addChild(W(t,t.orthogonalSize,t.size),G.Distribute,0)}else this._root.addChild(e,G.Distribute,0);this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange((e=>{this._onDidChange.fire(e)}))}next(e){return this.progmaticSelect(e)}previous(e){return this.progmaticSelect(e,!0)}getView(e){const t=e?this.getNode(e)[1]:this.root;return this._getViews(t,this.orientation)}_getViews(e,t,i){const s={height:e.height,width:e.width};if(e instanceof H)return{box:s,view:e.view,cachedVisibleSize:i};const n=[];for(let i=0;i<e.children.length;i++){const s=e.children[i],o=e.getChildCachedVisibleSize(i);n.push(this._getViews(s,U(t),o))}return{box:s,children:n}}progmaticSelect(e,t=!1){const[i,s]=this.getNode(e);if(!(s instanceof H))throw new Error("invalid location");for(let s=i.length-1;s>-1;s--){const n=i[s],o=e[s]||0;if(t?o-1>-1:o+1<n.children.length)return F(n.children[t?o-1:o+1],t)}return F(this.root,t)}constructor(e,t,i){this.proportionalLayout=e,this.styles=t,this.disposable=new v,this._onDidChange=new l,this.onDidChange=this._onDidChange.event,this.element=document.createElement("div"),this.element.className="grid-view",this.root=new M(i,e,t,0,0)}isViewVisible(e){const[t,i]=z(e),[,s]=this.getNode(t);if(!(s instanceof M))throw new Error("Invalid from location");return s.isChildVisible(i)}setViewVisible(e,t){const[i,s]=z(e),[,n]=this.getNode(i);if(!(n instanceof M))throw new Error("Invalid from location");n.setChildVisible(s,t)}moveView(e,t,i){const[,s]=this.getNode(e);if(!(s instanceof M))throw new Error("Invalid location");s.moveChild(t,i)}addView(e,t,i){const[s,n]=z(i),[o,r]=this.getNode(s);if(r instanceof M){const i=new H(e,U(r.orientation),r.orthogonalSize);r.addChild(i,t,n)}else{const[i,...a]=[...o].reverse(),[h,...d]=[...s].reverse();let l=0;const p=i.getChildCachedVisibleSize(h);"number"==typeof p&&(l=G.Invisible(p)),i.removeChild(h);const m=new M(r.orientation,this.proportionalLayout,this.styles,r.size,r.orthogonalSize);i.addChild(m,r.size,h);const c=new H(r.view,i.orientation,r.size);m.addChild(c,l,0),"number"!=typeof t&&"split"===t.type&&(t={type:"split",index:0});const u=new H(e,i.orientation,r.size);m.addChild(u,t,n)}}remove(e,t){const i=B(e.element);return this.removeView(i,t)}removeView(e,t){const[i,s]=z(e),[n,o]=this.getNode(i);if(!(o instanceof M))throw new Error("Invalid location");const r=o.children[s];if(!(r instanceof H))throw new Error("Invalid location");if(o.removeChild(s,t),0===o.children.length)return r.view;if(o.children.length>1)return r.view;const a=o.children[0];if(0===n.length)return a instanceof H||(o.removeChild(0,t),this.root=a),r.view;const[h,...d]=[...n].reverse(),[l,...p]=[...i].reverse(),m=o.isChildVisible(0);o.removeChild(0,t);const c=h.children.map(((e,t)=>h.getChildSize(t)));if(h.removeChild(l,t),a instanceof M){c.splice(l,1,...a.children.map((e=>e.size)));for(let e=0;e<a.children.length;e++){const t=a.children[e];h.addChild(t,t.size,l+e)}}else{const e=new H(a.view,U(a.orientation),a.size),t=m?a.orthogonalSize:G.Invisible(a.orthogonalSize);h.addChild(e,t,l)}for(let e=0;e<c.length;e++)h.resizeChild(e,c[e]);return r.view}layout(e,t){const[i,s]=this.root.orientation===V.HORIZONTAL?[t,e]:[e,t];this.root.layout(i,s)}getNode(e,t=this.root,i=[]){if(0===e.length)return[i,t];if(!(t instanceof M))throw new Error("Invalid location");const[s,...n]=e;if(s<0||s>=t.children.length)throw new Error("Invalid location");const o=t.children[s];return i.push(t),this.getNode(n,o,i)}}class q{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get height(){return this.component.height}get width(){return this.component.width}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 K{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get height(){return this.component.height}get width(){return this.component.width}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 l,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 ee{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 width(){return this.component.width}get height(){return this.component.height}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 te{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 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)}addGroup(e){return this.component.addGroup(e)}moveToNext(e){this.component.moveToNext(e)}moveToPrevious(e){this.component.moveToPrevious(e)}closeAllGroups(){return this.component.closeAllGroups()}removeGroup(e){this.component.removeGroup(e)}getGroup(e){return this.component.getPanel(e)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}}class ie extends u{constructor(e,t){super(),this.element=e,this.callbacks=t,this.target=null,this.registerListeners()}registerListeners(){this.addDisposables(m(this.element,"dragenter",(e=>{this.target=e.target,this.callbacks.onDragEnter(e)}),!0)),this.addDisposables(m(this.element,"dragover",(e=>{e.preventDefault(),this.callbacks.onDragOver&&this.callbacks.onDragOver(e)}),!0)),this.addDisposables(m(this.element,"dragleave",(e=>{this.target===e.target&&(this.target=null,this.callbacks.onDragLeave(e))}))),this.addDisposables(m(this.element,"dragend",(e=>{this.target=null,this.callbacks.onDragEnd(e)}))),this.addDisposables(m(this.element,"drop",(e=>{this.callbacks.onDrop(e)})))}}function se(e){switch(e){case"above":return"top";case"below":return"bottom";case"left":return"left";case"right":return"right";case"within":return"center";default:throw new Error(`invalid direction '${e}'`)}}function ne(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 oe extends u{get state(){return this._state}constructor(e,t){super(),this.element=e,this.options=t,this._onDrop=new l,this.onDrop=this._onDrop.event;const i=new Set(this.options.acceptedTargetZones);this.addDisposables(this._onDrop,new ie(this.element,{onDragEnter:()=>{},onDragOver:e=>{const t=this.element.clientWidth,s=this.element.clientHeight;if(0===t||0===s)return;const n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left,r=e.clientY-n.top,a=this.calculateQuadrant(i,o,r,t,s);if(null!==a){if("boolean"==typeof this.options.canDisplayOverlay){if(!this.options.canDisplayOverlay)return}else if(!this.options.canDisplayOverlay(e,a))return;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)),0!==this.options.acceptedTargetZones.length&&this.targetElement&&this.overlayElement&&(this.toggleClasses(a,t,s),this.setState(a))}else this.removeDropTarget()},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}))}}))}dispose(){this.removeDropTarget()}toggleClasses(e,t,i){var s,n,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,c=!a&&l,u=!a&&d,v=!h&&p,g=!h&&m;let w=.5;"percentage"===(null===(n=null===(s=this.options.overlayModel)||void 0===s?void 0:s.size)||void 0===n?void 0:n.type)&&(w=P(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)&&((c||u)&&(w=P(0,this.options.overlayModel.size.value,t)/t),(v||g)&&(w=P(0,this.options.overlayModel.size.value,i)/i));const _=(1-w)/2;let D;D=c?`translateX(${100*_}%) scaleX(${w})`:u?`translateX(-${100*_}%) scaleX(${w})`:v?`translateY(-${100*_}%) scaleY(${w})`:g?`translateY(${100*_}%) scaleY(${w})`:"",this.overlayElement.style.transform=D,f(this.overlayElement,"small-right",a&&l),f(this.overlayElement,"small-left",a&&d),f(this.overlayElement,"small-top",h&&p),f(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,s,n){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=(c=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,u=20,"number"==typeof c?c:u);var c,u;return p?function(e,t,i,s,n,o){const r=100*t/s,a=100*i/n;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,s,n,m):function(e,t,i,s,n,o){if(e.has("left")&&t<o)return"left";if(e.has("right")&&t>s-o)return"right";if(e.has("top")&&i<o)return"top";if(e.has("bottom")&&i>n-o)return"bottom";if(!e.has("center"))return null;return"center"}(e,t,i,s,n,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"))}}class re extends u{get element(){return this._element}constructor(){super(),this.disposable=new v,this._onDidFocus=new l,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new l,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)}show(){this.element.style.display=""}hide(){this.element.style.display="none"}openPanel(e){var t;if(this.panel===e)return;this.panel&&((null===(t=this.panel.view)||void 0===t?void 0:t.content)&&this._element.removeChild(this.panel.view.content.element),this.panel=void 0),this.panel=e;const i=new u;if(this.panel.view){const e=this.panel.view.content.onDidFocus,t=this.panel.view.content.onDidBlur,{onDidFocus:s,onDidBlur:n}=C(this._element);i.addDisposables(s((()=>this._onDidFocus.fire())),n((()=>this._onDidBlur.fire()))),e&&i.addDisposables(e((()=>this._onDidFocus.fire()))),t&&i.addDisposables(t((()=>this._onDidBlur.fire()))),this._element.appendChild(this.panel.view.content.element)}this.disposable.value=i}layout(e,t){}closePanel(){var e,t,i;(null===(i=null===(t=null===(e=this.panel)||void 0===e?void 0:e.view)||void 0===t?void 0:t.content)||void 0===i?void 0:i.element)&&(this._element.removeChild(this.panel.view.content.element),this.panel=void 0)}dispose(){this.disposable.dispose(),super.dispose()}}var ae;!function(e){e[e.Tab=0]="Tab",e[e.Panel=1]="Panel",e[e.TabContainer=2]="TabContainer",e[e.Edge=3]="Edge"}(ae||(ae={}));class he extends u{constructor(e){super(),this.el=e,this.disposable=new v,this._onDragStart=new l,this.onDragStart=this._onDragStart.event,this.iframes=[],this.configure()}configure(){this.addDisposables(this._onDragStart,m(this.el,"dragstart",(e=>{this.iframes=[...b("iframe"),...b("webview")];for(const e of this.iframes)e.style.pointerEvents="none";this.el.classList.add("dv-dragged"),setTimeout((()=>this.el.classList.remove("dv-dragged")),0),this.disposable.value=this.getData(e.dataTransfer),e.dataTransfer&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain","__dockview_internal_drag_event__"))})),m(this.el,"dragend",(()=>{for(const e of this.iframes)e.style.pointerEvents="auto";this.iframes=[],this.disposable.dispose()})))}}class de extends u{get element(){return this._element}constructor(e,t,i){super(),this.panelId=e,this.accessor=t,this.group=i,this._onChanged=new l,this.onChanged=this._onChanged.event,this._onDropped=new l,this.onDrop=this._onDropped.event,this.addDisposables(this._onChanged,this._onDropped),this._element=document.createElement("div"),this._element.className="tab",this._element.tabIndex=0,this._element.draggable=!0,f(this.element,"inactive-tab",!0),this.addDisposables(new class extends he{constructor(){super(...arguments),this.panelTransfer=a.getInstance()}getData(){return this.panelTransfer.setData([new o(t.id,i.id,e)],o.prototype),{dispose:()=>{this.panelTransfer.clearData(o.prototype)}}}dispose(){}}(this._element)),this.addDisposables(m(this._element,"mousedown",(e=>{e.defaultPrevented||(e.stopPropagation(),this._onChanged.fire(e))}))),this.droptarget=new oe(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:(e,t)=>{if(this.group.locked)return!1;const i=h();return i&&this.accessor.id===i.viewId?(null!==i.panelId||i.groupId!==this.group.id)&&this.panelId!==i.panelId:this.group.model.canDisplayOverlay(e,t,ae.Tab)}}),this.addDisposables(this.droptarget.onDrop((e=>{this._onDropped.fire(e)})))}setActive(e){f(this.element,"active-tab",e),f(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(),this.droptarget.dispose()}}class le extends he{constructor(e,t,i){super(e),this.accessorId=t,this.group=i,this.panelTransfer=a.getInstance()}getData(e){this.panelTransfer.setData([new o(this.accessorId,this.group.id,null)],o.prototype);const t=window.getComputedStyle(this.el),i=t.getPropertyValue("--dv-activegroup-visiblepanel-tab-background-color"),s=t.getPropertyValue("--dv-activegroup-visiblepanel-tab-color");if(e){const t=document.createElement("div");t.style.backgroundColor=i,t.style.color=s,t.style.padding="2px 8px",t.style.height="24px",t.style.fontSize="11px",t.style.lineHeight="20px",t.style.borderRadius="12px",t.style.position="absolute",t.textContent=`Multiple Panels (${this.group.size})`,function(e,t){_(t,"dv-dragged"),document.body.appendChild(t),e.setDragImage(t,0,0),setTimeout((()=>{w(t,"dv-dragged"),t.remove()}),0)}(e,t)}return{dispose:()=>{this.panelTransfer.clearData(o.prototype)}}}dispose(){}}class pe extends u{get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this._onDrop=new l,this.onDrop=this._onDrop.event,this._element=document.createElement("div"),this._element.className="void-container",this._element.tabIndex=0,this._element.draggable=!0,this.addDisposables(this._onDrop,m(this._element,"click",(()=>{this.accessor.doSetGroupActive(this.group)})));const i=new le(this._element,e.id,t);this.voidDropTarget=new oe(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:(e,i)=>{var s;const n=h();return n&&this.accessor.id===n.viewId?(null!==n.panelId||n.groupId!==this.group.id)&&(null===(s=(o=this.group.panels).length>0?o[o.length-1]:void 0)||void 0===s?void 0:s.id)!==n.panelId:t.model.canDisplayOverlay(e,i,ae.Panel);var o}}),this.addDisposables(i,this.voidDropTarget.onDrop((e=>{this._onDrop.fire(e)})),this.voidDropTarget)}}class me extends u{get panels(){return this.tabs.map((e=>e.value.panelId))}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"}setActionElement(e){this.actions!==e&&(this.actions&&(this.actions.remove(),this.actions=void 0),e&&(this.actionContainer.appendChild(e),this.actions=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.panelId===e))}constructor(e,t){super(),this.accessor=e,this.group=t,this.tabs=[],this.selectedIndex=-1,this._hidden=!1,this._onDrop=new l,this.onDrop=this._onDrop.event,this.addDisposables(this._onDrop),this._element=document.createElement("div"),this._element.className="tabs-and-actions-container",f(this._element,"dv-full-width-single-tab","fullwidth"===this.accessor.options.singleTabMode),this.addDisposables(this.accessor.onDidAddPanel((e=>{e.api.group===this.group&&f(this._element,"dv-single-tab",1===this.size)})),this.accessor.onDidRemovePanel((e=>{e.api.group===this.group&&f(this._element,"dv-single-tab",1===this.size)}))),this.actionContainer=document.createElement("div"),this.actionContainer.className="action-container",this.tabContainer=document.createElement("div"),this.tabContainer.className="tabs-container",this.voidContainer=new pe(this.accessor,this.group),this._element.appendChild(this.tabContainer),this._element.appendChild(this.voidContainer.element),this._element.appendChild(this.actionContainer),this.addDisposables(this.voidContainer,this.voidContainer.onDrop((e=>{this._onDrop.fire({event:e.nativeEvent,index:this.tabs.length})})),m(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.panelId===e)),i=this.tabs.splice(t,1)[0],{value:s,disposable:n}=i;n.dispose(),s.element.remove()}setActivePanel(e){this.tabs.forEach((t=>{const i=e.id===t.value.panelId;t.value.setActive(i)}))}openPanel(e,t=this.tabs.length){var i;if(this.tabs.find((t=>t.value.panelId===e.id)))return;const s=new de(e.id,this.accessor,this.group);if(!(null===(i=e.view)||void 0===i?void 0:i.tab))throw new Error("invalid header component");s.setContent(e.view.tab);const n=u.from(s.onChanged((t=>{var i;const s=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:s})})),s.onDrop((e=>{this._onDrop.fire({event:e.nativeEvent,index:this.tabs.findIndex((e=>e.value===s))})}))),o={value:s,disposable:n};this.addTab(o,t)}closePanel(e){this.delete(e.id)}dispose(){super.dispose(),this.tabs.forEach((e=>{e.disposable.dispose()})),this.tabs=[]}}class ce extends u{get element(){throw new Error("not supported")}get activePanel(){return this._activePanel}get locked(){return this._locked}set locked(e){this._locked=e,f(this.container,"locked-groupview",e)}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return 0===this._panels.length}get hasWatermark(){return!(!this.watermark||!this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get isContentFocused(){return!!document.activeElement&&D(document.activeElement,this.contentContainer.element)}constructor(e,t,i,s,n){super(),this.container=e,this.accessor=t,this.id=i,this.options=s,this.groupPanel=n,this._isGroupActive=!1,this._locked=!1,this.mostRecentlyUsed=[],this._onDidChange=new l,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._onMove=new l,this.onMove=this._onMove.event,this._onDidDrop=new l,this.onDidDrop=this._onDidDrop.event,this._onDidAddPanel=new l,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidRemovePanel=new l,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new l,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this.container.classList.add("groupview"),this.tabsContainer=new me(this.accessor,this.groupPanel),this.contentContainer=new re,this.dropTarget=new oe(this.contentContainer.element,{acceptedTargetZones:["top","bottom","left","right","center"],canDisplayOverlay:(e,t)=>{if(this.locked&&"center"===t)return!1;const i=h();if(i&&i.viewId===this.accessor.id){if(i.groupId===this.id){if("center"===t)return!1;if(null===i.panelId)return!1}return!(1===this._panels.length&&i.groupId===this.id)}return this.canDisplayOverlay(e,t,ae.Panel)}}),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!s.hideHeader,this.locked=!!s.locked,this.addDisposables(this._onMove,this._onDidChange,this._onDidDrop,this._onDidAddPanel,this._onDidRemovePanel,this._onDidActivePanelChange,this.tabsContainer.onDrop((e=>{this.handleDropEvent(e.event,"center",e.index)})),this.contentContainer.onDidFocus((()=>{this.accessor.doSetGroupActive(this.groupPanel,!0)})),this.contentContainer.onDidBlur((()=>{})),this.dropTarget.onDrop((e=>{this.handleDropEvent(e.nativeEvent,e.position)})))}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.createGroupControlElement&&(this._control=this.accessor.options.createGroupControlElement(this.groupPanel),this.addDisposables(this._control),this._control.init({containerApi:new te(this.accessor),api:this.groupPanel.api}),this.tabsContainer.setActionElement(this._control.element))}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 this.locked&&(t.locked=!0),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,s=!!t.skipSetGroupActive;e.updateParentGroup(this.groupPanel,!0),this._activePanel!==e?(this.doAddPanel(e,t.index,i),i||this.doSetActivePanel(e),s||this.accessor.doSetGroupActive(this.groupPanel,!!t.skipFocus),this.updateContainer()):s||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.setActionElement(e)}setActive(e,t=!1,i=!1){var s,n,o,r;i||this.isActive!==e?(this._isGroupActive=e,f(this.container,"active-group",e),f(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===(n=null===(s=this._activePanel)||void 0===s?void 0:s.focus)||void 0===n||n.call(s)}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 s=this._panels.indexOf(e)>-1;this.tabsContainer.openPanel(e,t),i||this.contentContainer.openPanel(e),this.tabsContainer.show(),this.contentContainer.show(),s||(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(f(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 te(this.accessor),group:this.groupPanel}),this.watermark=e,m(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:h})}handleDropEvent(e,t,i){const s=h();if(s&&s.viewId===this.accessor.id){if(null===s.panelId){const{groupId:e}=s;return void this._onMove.fire({target:t,groupId:e,index:i})}if(-1!==this.tabsContainer.indexOf(s.panelId)&&1===this.tabsContainer.size)return;const{groupId:e,panelId:n}=s;if(this.id===e&&!t){if(this.tabsContainer.indexOf(n)===i)return}this._onMove.fire({target:t,groupId:s.groupId,itemId:s.panelId,index:i})}else this._onDidDrop.fire({nativeEvent:e,position:t,index:i,getData:()=>h()})}dispose(){var e,t;super.dispose(),null===(t=null===(e=this.watermark)||void 0===e?void 0:e.dispose)||void 0===t||t.call(e);for(const e of this.panels)e.dispose();this.dropTarget.dispose(),this.tabsContainer.dispose(),this.contentContainer.dispose()}}class ue extends u{get element(){return this._element}constructor(e){super(),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(g(this._element,(e=>{if(this.isDisposed)return;const{width:t,height:i}=e.contentRect;this.layout(t,i)})))}}const ve=O();function ge(e){switch(e){case"left":return"left";case"right":return"right";case"above":return"top";case"below":return"bottom";default:return"center"}}class we extends ue{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(e){super(e.parentElement),this._id=ve.next(),this._groups=new Map,this._onDidLayoutChange=new l,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidRemoveGroup=new l,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new l,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new l,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._bufferOnDidLayoutChange=new c,this.gridview=new Q(!!e.proportionalLayout,e.styles,e.orientation),this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidChange((()=>{this._bufferOnDidLayoutChange.fire()}))),this.addDisposables(i.any(this.onDidAddGroup,this.onDidRemoveGroup,this.onDidActiveGroupChange)((()=>{this._bufferOnDidLayoutChange.fire()})),this._bufferOnDidLayoutChange.onEvent((()=>{this._onDidLayoutChange.fire()})),this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(B(e.element),t),this._onDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(B(e.element))}doAddGroup(e,t=[0],i){this.gridview.addView(e,null!=i?i:G.Distribute,t),this._onDidAddGroup.fire(e),this.doSetGroupActive(e)}doRemoveGroup(e,t){if(!this._groups.has(e.id))throw new Error("invalid operation");const i=this._groups.get(e.id),s=this.gridview.remove(e,G.Distribute);if(i&&!(null==t?void 0:t.skipDispose)&&(i.disposable.dispose(),i.value.dispose(),this._groups.delete(e.id)),this._onDidRemoveGroup.fire(e),!(null==t?void 0:t.skipActive)&&this._activeGroup===e){const e=Array.from(this._groups.values());this.doSetGroupActive(e.length>0?e[0].value:void 0)}return s}getPanel(e){var t;return null===(t=this._groups.get(e))||void 0===t?void 0:t.value}doSetGroupActive(e,t){var i,s,n;this._activeGroup!==e&&(this._activeGroup&&(this._activeGroup.setActive(!1),t||null===(s=(i=this._activeGroup).focus)||void 0===s||s.call(i)),e&&(e.setActive(!0),t||null===(n=e.focus)||void 0===n||n.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=B(e.group.element),s=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}moveToPrevious(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=B(e.group.element),s=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}layout(e,t,i){(i||e!==this.width||t!==this.height)&&(this.gridview.element.style.height=`${t}px`,this.gridview.element.style.width=`${e}px`,this.gridview.layout(e,t))}dispose(){super.dispose(),this._onDidActiveGroupChange.dispose(),this._onDidAddGroup.dispose(),this._onDidRemoveGroup.dispose(),this._onDidLayoutChange.dispose();for(const e of this.groups)e.dispose();this.gridview.dispose()}}class _e extends u{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 v,this._onDidDimensionChange=new l({replay:!0}),this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new l({replay:!0}),this.onDidFocusChange=this._onDidChangeFocus.event,this._onFocusEvent=new l,this.onFocusEvent=this._onFocusEvent.event,this._onDidVisibilityChange=new l({replay:!0}),this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onVisibilityChange=new l,this.onVisibilityChange=this._onVisibilityChange.event,this._onDidActiveChange=new l({replay:!0}),this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new l,this.onActiveChange=this._onActiveChange.event,this._onUpdateParameters=new l,this.onUpdateParameters=this._onUpdateParameters.event,this.addDisposables(this.panelUpdatesDisposable,this._onDidDimensionChange,this._onDidChangeFocus,this._onDidVisibilityChange,this._onDidActiveChange,this._onFocusEvent,this._onActiveChange,this._onVisibilityChange,this._onUpdateParameters,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})))}initialize(e){this.panelUpdatesDisposable.value=this._onUpdateParameters.event((t=>{e.update({params:{params:t}})}))}setVisible(e){this._onVisibilityChange.fire({isVisible:e})}setActive(){this._onActiveChange.fire()}updateParameters(e){this._onUpdateParameters.fire(e)}dispose(){super.dispose()}}class fe extends _e{constructor(e){super(e),this._onDidConstraintsChangeInternal=new l,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new l({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new l,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 De extends fe{set pane(e){this._pane=e}constructor(e){super(e),this._onDidExpansionChange=new l({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new l({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new l({}),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 be extends u{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{onDidFocus:s,onDidBlur:n}=C(this._element);this.addDisposables(this.api,s((()=>{this.api._onDidChangeFocus.fire({isFocused:!0})})),n((()=>{this.api._onDidChangeFocus.fire({isFocused:!1})})))}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)}),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;super.dispose(),this.api.dispose(),null===(e=this.part)||void 0===e||e.dispose()}}class Ce extends be{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,s,n,o){super(e,t,new De(e)),this.headerComponent=i,this._onDidChangeExpansionState=new l({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new l,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=n,this._headerVisible=o,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=s,this.element.classList.add("pane"),this.addDisposables(this.api.onDidSizeChange((e=>{this._onDidChange.fire({size:e.size})})),m(this.element,"mouseenter",(e=>{this.api._onMouseEnter.fire(e)})),m(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?_(this.header,"focused"):w(this.header,"focused"))}))),this.renderOnce()}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}isExpanded(){return this._isExpanded}setExpanded(e){this._isExpanded!==e&&(this._isExpanded=e,e?(this.animationTimer&&clearTimeout(this.animationTimer),this.body&&this.element.appendChild(this.body)):this.animationTimer=setTimeout((()=>{var e;null===(e=this.body)||void 0===e||e.remove()}),200),this._onDidChange.fire(e?{size:this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(e,t){this._size=e,this._orthogonalSize=t;const[i,s]=this.orientation===V.HORIZONTAL?[e,t]:[t,e];this.isExpanded()&&(this.expandedSize=i),super.layout(i,s)}init(e){var t,i;super.init(e),"number"==typeof e.minimumBodySize&&(this.minimumBodySize=e.minimumBodySize),"number"==typeof e.maximumBodySize&&(this.maximumBodySize=e.maximumBodySize),this.bodyPart=this.getBodyComponent(),this.headerPart=this.getHeaderComponent(),this.bodyPart.init(Object.assign(Object.assign({},e),{api:this.api})),this.headerPart.init(Object.assign(Object.assign({},e),{api:this.api})),null===(t=this.body)||void 0===t||t.append(this.bodyPart.element),null===(i=this.header)||void 0===i||i.append(this.headerPart.element),"boolean"==typeof e.isExpanded&&this.setExpanded(e.isExpanded)}toJSON(){const e=this._params;return Object.assign(Object.assign({},super.toJSON()),{headerComponent:this.headerComponent,title:e.title})}renderOnce(){this.header=document.createElement("div"),this.header.tabIndex=0,this.header.className="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 ye extends Ce{constructor(e,t,i,s,n,o,r){super(t,i,s,n,o,!0),this.accessor=e,this._onDidDrop=new l,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 he{getData(){return a.getInstance().setData([new r(t,e)],r.prototype),{dispose:()=>{a.getInstance().clearData(r.prototype)}}}}(this.header),this.target=new oe(this.element,{acceptedTargetZones:["top","bottom"],overlayModel:{activationSize:{type:"percentage",value:50}},canDisplayOverlay:e=>{const t=d();return!(!t||t.paneId===this.id||t.viewId!==this.accessor.id)||!!this.accessor.options.showDndOverlay&&this.accessor.options.showDndOverlay({nativeEvent:e,getData:d,panel:this})}}),this.addDisposables(this._onDidDrop,this.handler,this.target,this.target.onDrop((e=>{this.onDrop(e)})))}onDrop(e){const t=d();if(!t||t.viewId!==this.accessor.id)return void this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,api:new K(this.accessor),getData:d}));const i=this._params.containerApi,s=t.paneId,n=i.getPanel(s);if(!n)return void this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,getData:d,api:new K(this.accessor)}));const o=i.panels,r=o.indexOf(n);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 Se extends _e{constructor(e,t){super(e),this._onDidConstraintsChangeInternal=new l,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new l({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new l,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 ze extends be{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){super(e,t,new Se(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 l,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._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.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})})))}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})}}class xe extends ze{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}),this._model=new ce(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 Ee(e){return!!e.referencePanel}function Ae(e){return!!e.referenceGroup}function Pe(e){return!!e.referencePanel}function Oe(e){return!!e.referenceGroup}class Ie extends Se{get title(){return this.panel.title}get isGroupActive(){var e;return!!(null===(e=this.group)||void 0===e?void 0:e.isActive)}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){super(e.id),this.panel=e,this._onDidTitleChange=new l,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidActiveGroupChange=new l,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new l,this.onDidGroupChange=this._onDidGroupChange.event,this.disposable=new v,this.initialize(e),this._group=t,this.addDisposables(this.disposable,this._onDidTitleChange,this._onDidGroupChange,this._onDidActiveGroupChange)}setTitle(e){this.panel.update({params:{title:e}})}close(){this.group.model.closePanel(this.panel)}}class Ne extends u{get params(){return this._params}get title(){return this._title}get group(){return this._group}constructor(e,t,i,s,n){super(),this.id=e,this.containerApi=i,this.view=n,this._title="",this._group=s,this.api=new Ie(this,this._group),this.addDisposables(this.api.onActiveChange((()=>{t.setActivePanel(this)})),this.api.onDidSizeChange((e=>{this.group.api.setSize(e)})))}init(e){this._params=e.params,this.setTitle(e.title),this.view.init(Object.assign(Object.assign({},e),{api:this.api,containerApi:this.containerApi}))}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}}setTitle(e){var t,i;e!==(null===(t=this._params)||void 0===t?void 0:t.title)&&(this._title=e,null===(i=this.view)||void 0===i||i.update({params:{params:this._params,title:this.title}}),this.api._onDidTitleChange.fire({title:e}))}update(e){var t;const i=e.params;this._params=Object.assign(Object.assign({},this._params||{}),e.params.params),i.title!==this.title&&(this._title=i.title,this.api._onDidTitleChange.fire({title:this.title})),null===(t=this.view)||void 0===t||t.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 Ve=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},Le=()=>Ve({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 ke extends u{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(Le()),this._element.appendChild(this._content),this._element.appendChild(this._actionContainer),this._actionContainer.appendChild(this._list),this._list.appendChild(this.action),this.addDisposables(m(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,m(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 Ge{get content(){return this._content}get tab(){return this._tab}constructor(e,t,i,s){this.accessor=e,this.id=t,this.contentComponent=i,this.tabComponent=s,this._group=null,this._isPanelVisible=null,this._content=this.createContentComponent(this.id,i),this._tab=this.createTabComponent(this.id,s)}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,s;null===(s=(i=this.content).layout)||void 0===s||s.call(i,e,t)}update(e){var t,i,s,n;null===(i=(t=this.content).update)||void 0===i||i.call(t,e),null===(n=(s=this.tab).update)||void 0===n||n.call(s,e)}dispose(){var e,t,i,s;null===(t=(e=this.content).dispose)||void 0===t||t.call(e),null===(s=(i=this.tab).dispose)||void 0===s||s.call(i)}createContentComponent(e,t){var i;return S(e,t,this.accessor.options.components||{},this.accessor.options.frameworkComponents,null===(i=this.accessor.options.frameworkComponentFactory)||void 0===i?void 0:i.content)}createTabComponent(e,t){var i,s;return t?S(e,t,this.accessor.options.tabComponents,this.accessor.options.frameworkTabComponents,null===(i=this.accessor.options.frameworkComponentFactory)||void 0===i?void 0:i.tab,(()=>new ke)):this.accessor.options.defaultTabComponent?S(e,this.accessor.options.defaultTabComponent,this.accessor.options.tabComponents,this.accessor.options.frameworkTabComponents,null===(s=this.accessor.options.frameworkComponentFactory)||void 0===s?void 0:s.tab,(()=>new ke)):new ke}}class Te{constructor(e){this.layout=e}fromJSON(e,t){var i;const s=e.id,n=e.params,o=e.title,r=e.view,a=r?r.content.id:e.contentComponent||"unknown",h=r?null===(i=r.tab)||void 0===i?void 0:i.id:e.tabComponent,d=new Ge(this.layout,s,a,h),l=new Ne(s,this.layout,new te(this.layout),t,d);return l.init({title:o||s,params:n||{}}),l}}class Re extends u{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 s=document.createElement("div");s.className="actions-container";const n=document.createElement("div");n.className="close-action",n.appendChild(Le()),s.appendChild(n),e.appendChild(t),e.appendChild(s),this.addDisposables(m(n,"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);f(this.element,"has-actions",e)}}class He extends we{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}constructor(e){super({proportionalLayout:!0,orientation:e.orientation||V.HORIZONTAL,styles:e.styles,parentElement:e.parentElement}),this.nextGroupId=O(),this._deserializer=new Te(this),this.watermark=null,this._onDidDrop=new l,this.onDidDrop=this._onDidDrop.event,this._onDidRemovePanel=new l,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new l,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidLayoutFromJSON=new l,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new l,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this.element.classList.add("dv-dockview"),this.addDisposables(this._onDidDrop,i.any(this.onDidAddGroup,this.onDidRemoveGroup)((()=>{this.updateWatermark()})),i.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidActivePanelChange)((()=>{this._bufferOnDidLayoutChange.fire()}))),this._options=e,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=Re);const t=new oe(this.element,{canDisplayOverlay:(e,t)=>{const i=h();return i?i.viewId===this.id:!!this.options.showDndOverlay&&this.options.showDndOverlay({nativeEvent:e,position:t,target:ae.Edge,getData:h})},acceptedTargetZones:["top","bottom","left","right"],overlayModel:{activationSize:{type:"pixels",value:10},size:{type:"pixels",value:20}}});this.addDisposables(t,t.onDrop((e=>{const t=h();t?this.moveGroupOrPanel(this.orthogonalize(e.position),t.groupId,t.panelId||void 0,"center"):this._onDidDrop.fire(Object.assign(Object.assign({},e),{api:this._api,group:null,getData:h}))}))),this._api=new te(this),this.updateWatermark()}orthogonalize(e){switch(e){case"top":case"bottom":this.gridview.orientation===V.HORIZONTAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case"left":case"right":this.gridview.orientation===V.VERTICAL&&this.gridview.insertOrthogonalSplitviewAtRoot()}switch(e){case"top":case"left":return this.createGroupAtLocation([0]);case"bottom":case"right":return this.createGroupAtLocation([this.gridview.length]);default:throw new Error(`unsupported position ${e}`)}}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)}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=B(e.group.element),s=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}moveToPrevious(e={}){var t;if(!e.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=B(e.group.element),s=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;s&&this.doSetGroupActive(s)}toJSON(){var e;return{grid:this.gridview.serialize(),panels:this.panels.reduce(((e,t)=>(e[t.id]=t.toJSON(),e)),{}),activeGroup:null===(e=this.activeGroup)||void 0===e?void 0:e.id}}fromJSON(e){this.clear();const{grid:t,panels:i,activeGroup:s}=e;if("branch"!==t.root.type||!Array.isArray(t.root.data))throw new Error("root must be of type branch");if(this.gridview.deserialize(t,{fromJSON:e=>{const{id:t,locked:s,hideHeader:n,views:o,activeView:r}=e.data,a=this.createGroup({id:t,locked:!!s,hideHeader:!!n});this._onDidAddGroup.fire(a);for(const e of o){const t=this._deserializer.fromJSON(i[e],a),s="string"==typeof r&&r===t.id;a.model.openPanel(t,{skipSetPanelActive:!s,skipSetGroupActive:!0})}return!a.activePanel&&a.panels.length>0&&a.model.openPanel(a.panels[a.panels.length-1],{skipSetGroupActive:!0}),a}}),"string"==typeof s){const e=this.getPanel(s);e&&this.doSetGroupActive(e)}this.gridview.layout(this.width,this.height),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,!0);t&&this.doSetGroupActive(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 s,n;if(e.position)if(Ee(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`);s=this.findGroup(t)}else{if(!Ae(e.position)){const t=this.orthogonalize(se(e.position.direction)),i=this.createPanel(e,t);return t.model.openPanel(i),i}if(s="string"==typeof e.position.referenceGroup?null===(t=this._groups.get(e.position.referenceGroup))||void 0===t?void 0:t.value:e.position.referenceGroup,!s)throw new Error(`referencePanel ${e.position.referenceGroup} does not exist`)}else s=this.activeGroup;if(s){const t=ge((null===(i=e.position)||void 0===i?void 0:i.direction)||"within");if("center"===t)n=this.createPanel(e,s),s.model.openPanel(n);else{const i=B(s.element),o=j(this.gridview.orientation,i,t),r=this.createGroupAtLocation(o);n=this.createPanel(e,r),r.model.openPanel(n)}}else{const t=this.createGroupAtLocation();n=this.createPanel(e,t),t.model.openPanel(n)}return n}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),e.dispose(),0===i.size&&t.removeEmptyGroup&&this.removeGroup(i)}createWatermarkComponent(){var e;return S("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.length){if(!this.watermark){this.watermark=this.createWatermarkComponent(),this.watermark.init({containerApi:new te(this)});const e=document.createElement("div");e.className="dv-watermark-container",e.appendChild(this.watermark.element),this.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 s;if(Pe(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(s=this.findGroup(t),!s)throw new Error(`reference group for reference panel ${e.referencePanel} does not exist`)}else{if(!Oe(e)){return this.orthogonalize(se(e.direction))}if(s="string"==typeof e.referenceGroup?null===(t=this._groups.get(e.referenceGroup))||void 0===t?void 0:t.value:e.referenceGroup,!s)throw new Error(`reference group ${e.referenceGroup} does not exist`)}const n=ge(e.direction||"within"),o=B(s.element),r=j(this.gridview.orientation,o,n);return this.doAddGroup(i,r),i}return this.doAddGroup(i),i}removeGroup(e,t=!1){const i=[...e.panels];for(const e of i)this.removePanel(e,{removeEmptyGroup:!1,skipDispose:!1});super.doRemoveGroup(e,{skipActive:t})}moveGroupOrPanel(e,t,i,s,n){var o;const r=t?null===(o=this._groups.get(t))||void 0===o?void 0:o.value:void 0;if(void 0!==i)if(s&&"center"!==s){const t=B(e.element),n=j(this.gridview.orientation,t,s);if(r&&r.size<2){const[t,i]=z(n),o=B(r.element),[a,h]=z(o);if(x(a,t))this.gridview.moveView(a,h,i);else{const t=this.doRemoveGroup(r,{skipActive:!0,skipDispose:!0}),i=B(e.element),n=j(this.gridview.orientation,i,s);this.doAddGroup(t,n)}}else{const e=(null==r?void 0:r.model.removePanel(i))||this.panels.find((e=>e.id===i));if(!e)throw new Error(`No panel with id ${i}`);const n=j(this.gridview.orientation,t,s);this.createGroupAtLocation(n).model.openPanel(e)}}else{const t=(null==r?void 0:r.model.removePanel(i))||this.panels.find((e=>e.id===i));if(!t)throw new Error(`No panel with id ${i}`);0===(null==r?void 0:r.model.size)&&this.doRemoveGroup(r),e.model.openPanel(t,{index:n})}else r&&this.moveGroup(r,e,s)}moveGroup(e,t,i){if(e)if(i&&"center"!==i){this.gridview.removeView(B(e.element));const s=B(t.element),n=j(this.gridview.orientation,s,i);this.gridview.addView(e,G.Distribute,n)}else{const i=e.activePanel,s=[...e.panels].map((t=>e.model.removePanel(t.id)));0===(null==e?void 0:e.model.size)&&this.doRemoveGroup(e);for(const e of s)t.model.openPanel(e,{skipSetPanelActive:e!==i})}}doSetGroupActive(e,t){var i,s;const n=this._activeGroup===e;super.doSetGroupActive(e,t),!n&&(null===(i=this._activeGroup)||void 0===i?void 0:i.activePanel)&&this._onDidActivePanelChange.fire(null===(s=this._activeGroup)||void 0===s?void 0:s.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 xe(this,t,e);if(i.init({params:{},accessor:null}),!this._groups.has(i.id)){const e=new u(i.model.onMove((e=>{const{groupId:t,itemId:s,target:n,index:o}=e;this.moveGroupOrPanel(i,t,s,n,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){const i=e.component,s=e.tabComponent||this.options.defaultTabComponent,n=new Ge(this,e.id,i,s),o=new Ne(e.id,this,this._api,t,n);return o.init({title:e.title||e.id,params:(null==e?void 0:e.params)||{}}),o}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}dispose(){super.dispose(),this._onDidActivePanelChange.dispose(),this._onDidAddPanel.dispose(),this._onDidRemovePanel.dispose(),this._onDidLayoutFromJSON.dispose()}}class Me extends we{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}),this._onDidLayoutfromJSON=new l,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(B(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,s=[];if(this.gridview.deserialize(t,{fromJSON:e=>{const{data:t}=e,i=S(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkComponentFactory?{createComponent:this.options.frameworkComponentFactory.createComponent}:void 0);return s.push((()=>i.init({params:t.params,minimumWidth:t.minimumWidth,maximumWidth:t.maximumWidth,minimumHeight:t.minimumHeight,maximumHeight:t.maximumHeight,priority:t.priority,snap:!!t.snap,accessor:this,isVisible:e.visible}))),this._onDidAddGroup.fire(i),this.registerPanel(i),i}}),this.layout(this.width,this.height,!0),s.forEach((e=>e())),"string"==typeof i){const e=this.getPanel(i);e&&this.doSetGroupActive(e)}this._onDidLayoutfromJSON.fire()}clear(){const e=this.activeGroup,t=Array.from(this._groups.values());for(const e of t)e.disposable.dispose(),this.doRemoveGroup(e.value,{skipActive:!0});e&&this.doSetGroupActive(void 0),this.gridview.clear()}movePanel(e,t){var i;let s;const n=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=ge(t.direction);if("center"===r)throw new Error(`${r} not supported as an option`);{const e=B(o.element);s=j(this.gridview.orientation,e,r)}this.doAddGroup(n,s,t.size)}addPanel(e){var t,i;let s=e.location||[0];if(null===(t=e.position)||void 0===t?void 0:t.referencePanel){const t=null===(i=this._groups.get(e.position.referencePanel))||void 0===i?void 0:i.value;if(!t)throw new Error(`reference group ${e.position.referencePanel} does not exist`);const n=ge(e.position.direction);if("center"===n)throw new Error(`${n} not supported as an option`);{const e=B(t.element);s=j(this.gridview.orientation,e,n)}}const n=S(e.id,e.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkComponentFactory?{createComponent:this.options.frameworkComponentFactory.createComponent}:void 0);return n.init({params:e.params||{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.registerPanel(n),this.doAddGroup(n,s,e.size),n}registerPanel(e){const t=new u(e.api.onDidFocusChange((t=>{t.isFocused&&this._groups.forEach((t=>{const i=t.value;i!==e?i.setActive(!1):i.setActive(!0)}))})));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,i){const s=this.getPanel(t);if(!s)throw new Error("invalid operation");const n=B(e.element),o=j(this.gridview.orientation,n,i),[r,a]=z(o),h=B(s.element),[d,l]=z(h);if(x(d,r))return void this.gridview.moveView(d,l,a);const p=this.doRemoveGroup(s,{skipActive:!0,skipDispose:!0}),m=B(e.element),c=j(this.gridview.orientation,m,i);this.doAddGroup(p,c)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}}class Fe extends ue{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._disposable.value=new u(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===V.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===V.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}constructor(e){super(e.parentElement),this._disposable=new v,this._panels=new Map,this._onDidLayoutfromJSON=new l,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new l,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new l,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new l,this.onDidLayoutChange=this._onDidLayoutChange.event,this._options=e,e.components||(e.components={}),e.frameworkComponents||(e.frameworkComponents={}),this.splitview=new T(this.element,e),this.addDisposables(this._disposable,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.disposable.dispose(),i.value.dispose(),this._panels.delete(e.id);const s=this.panels.findIndex((t=>t===e));this.splitview.removeView(s,t);const n=this.panels;n.length>0&&this.setActive(n[n.length-1])}getPanel(e){return this.panels.find((t=>t.id===e))}addPanel(e){if(this._panels.has(e.id))throw new Error(`panel ${e.id} already exists`);const t=S(e.id,e.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.createComponent}:void 0);t.orientation=this.splitview.orientation,t.init({params:e.params||{},minimumSize:e.minimumSize,maximumSize:e.maximumSize,snap:e.snap,priority:e.priority,accessor:this});const i="number"==typeof e.size?e.size:G.Distribute,s="number"==typeof e.index?e.index:void 0;return this.splitview.addView(t,i,s),this.doAddView(t),this.setActive(t),t}layout(e,t){const[i,s]=this.splitview.orientation===V.HORIZONTAL?[e,t]:[t,e];this.splitview.layout(i,s)}doAddView(e){const t=e.api.onDidFocusChange((t=>{t.isFocused&&this.setActive(e,!0)}));this._panels.set(e.id,{disposable:t,value:e})}toJSON(){var e;return{views:this.splitview.getViews().map(((e,t)=>({size:this.splitview.getViewSize(t),data:e.toJSON(),snap:!!e.snap,priority:e.priority}))),activeView:null===(e=this._activePanel)||void 0===e?void 0:e.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){this.clear();const{views:t,orientation:i,size:s,activeView:n}=e,o=[];if(this.splitview=new T(this.element,{orientation:i,proportionalLayout:this.options.proportionalLayout,descriptor:{size:s,views:t.map((e=>{const t=e.data;if(this._panels.has(t.id))throw new Error(`panel ${t.id} already exists`);const s=S(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.createComponent}:void 0);return o.push((()=>{s.init({params:t.params||{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:e.snap,priority:e.priority,accessor:this})})),s.orientation=i,this.doAddView(s),setTimeout((()=>{this._onDidAddView.fire(s)}),0),{size:e.size,view:s}}))}}),this.layout(this.width,this.height),o.forEach((e=>e())),"string"==typeof n){const e=this.getPanel(n);e&&this.setActive(e)}this._onDidLayoutfromJSON.fire()}clear(){for(const[e,t]of this._panels.entries())t.disposable.dispose(),t.value.dispose();this._panels.clear(),this.splitview.dispose()}dispose(){for(const[e,t]of this._panels.entries())t.disposable.dispose(),t.value.dispose();this._panels.clear(),this.splitview.dispose(),super.dispose()}}class We extends u{get element(){return this._element}constructor(){super(),this._expandedIcon=Ve({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=Ve({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 v,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(m(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);f(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 Je=O();class Be extends ye{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 je extends ue{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new u(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===V.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===V.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(e){super(e.parentElement),this._id=Je.next(),this._disposable=new v,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new l,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new l,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new l,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new l,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new l,this.onDidRemoveView=this._onDidRemoveView.event,this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView),this._options=e,e.components||(e.components={}),e.frameworkComponents||(e.frameworkComponents={}),this.paneview=new R(this.element,{orientation:V.VERTICAL}),this.addDisposables(this._disposable)}focus(){}updateOptions(e){this._options=Object.assign(Object.assign({},this.options),e)}addPanel(e){const t=S(e.id,e.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.body.createComponent}:void 0);let i;i=e.headerComponent?S(e.id,e.headerComponent,this.options.headerComponents||{},this.options.headerframeworkComponents,this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.header.createComponent}:void 0):new We;const s=new Be({id:e.id,component:e.component,headerComponent:e.headerComponent,header:i,body:t,orientation:V.VERTICAL,isExpanded:!!e.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this});this.doAddPanel(s);const n="number"==typeof e.size?e.size:G.Distribute,o="number"==typeof e.index?e.index:void 0;return s.init({params:e.params||{},minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize,isExpanded:e.isExpanded,title:e.title,containerApi:new K(this)}),this.paneview.addPane(s,n,o),s.orientation=this.paneview.orientation,s}removePanel(e){const t=this.panels.findIndex((t=>t===e));this.paneview.removePane(t),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find((t=>t.id===e))}layout(e,t){const[i,s]=this.paneview.orientation===V.HORIZONTAL?[e,t]:[t,e];this.paneview.layout(i,s)}toJSON(){const e=e=>e===Number.MAX_SAFE_INTEGER||e===Number.POSITIVE_INFINITY?void 0:e;return{views:this.paneview.getPanes().map(((t,i)=>{return{size:this.paneview.getViewSize(i),data:t.toJSON(),minimumSize:(s=t.minimumBodySize,s<=0?void 0:s),maximumSize:e(t.maximumBodySize),expanded:t.isExpanded()};var s})),size:this.paneview.size}}fromJSON(e){this.clear();const{views:t,size:i}=e,s=[];this.paneview=new R(this.element,{orientation:V.VERTICAL,descriptor:{size:i,views:t.map((e=>{const t=e.data,i=S(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.body.createComponent}:void 0);let n;n=t.headerComponent?S(t.id,t.headerComponent,this.options.headerComponents||{},this.options.headerframeworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.header.createComponent}:void 0):new We;const o=new Be({id:t.id,component:t.component,headerComponent:t.headerComponent,header:n,body:i,orientation:V.VERTICAL,isExpanded:!!e.expanded,disableDnd:!!this.options.disableDnd,accessor:this});return this.doAddPanel(o),s.push((()=>{o.init({params:t.params||{},minimumBodySize:e.minimumSize,maximumBodySize:e.maximumSize,title:t.title,isExpanded:!!e.expanded,containerApi:new K(this)}),o.orientation=this.paneview.orientation})),setTimeout((()=>{this._onDidAddView.fire(o)}),0),{size:e.size,view:o}}))}}),this.layout(this.width,this.height),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 $e extends be{get priority(){return this._priority}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){const e="function"==typeof this._minimumSize?this._minimumSize():this._minimumSize;return e!==this._evaluatedMinimumSize&&(this._evaluatedMinimumSize=e,this.updateConstraints()),e}get maximumSize(){const e="function"==typeof this._maximumSize?this._maximumSize():this._maximumSize;return e!==this._evaluatedMaximumSize&&(this._evaluatedMaximumSize=e,this.updateConstraints()),e}get snap(){return this._snap}constructor(e,t){super(e,t,new fe(e)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=Number.POSITIVE_INFINITY,this._minimumSize=0,this._maximumSize=Number.POSITIVE_INFINITY,this._snap=!1,this._onDidChange=new l,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(e,t){const[i,s]=this.orientation===V.HORIZONTAL?[e,t]:[t,e];super.layout(i,s)}init(e){super.init(e),this._priority=e.priority,e.minimumSize&&(this._minimumSize=e.minimumSize),e.maximumSize&&(this._maximumSize=e.maximumSize),e.snap&&(this._snap=e.snap)}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{minimumSize:(e=this.minimumSize,e<=0?void 0:e),maximumSize:(e=>e===Number.MAX_SAFE_INTEGER||e===Number.POSITIVE_INFINITY?void 0:e)(this.maximumSize)});var e}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}}const Ze=(t,i)=>{const[s,n]=e.useState(),o=e.useRef(t.componentProps);return e.useImperativeHandle(i,(()=>({update:e=>{o.current=Object.assign(Object.assign({},o.current),e),n(Date.now())}})),[]),e.createElement(t.component,o.current)};Ze.displayName="DockviewReactJsBridge";const Ue=(()=>{let e=1;return{next:()=>`dockview_react_portal_key_${(e++).toString()}`}})(),Ye=e.createContext({});class Xe{constructor(e,t,i,s,n){this.parent=e,this.portalStore=t,this.component=i,this.parameters=s,this.context=n,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 i=e.createElement(e.forwardRef(Ze),{component:this.component,componentProps:this.parameters,ref:e=>{this.componentInstance=e,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),s=this.context?e.createElement(Ye.Provider,{value:this.context},i):i,n=t.createPortal(s,this.parent,Ue.next());this.ref={portal:n,disposable:this.portalStore.addPortal(n)}}dispose(){var e;null===(e=this.ref)||void 0===e||e.disposable.dispose(),this.disposed=!0}}const Qe=()=>{const[t,i]=e.useState([]);e.useDebugValue(`Portal count: ${t.length}`);return[t,e.useCallback((e=>{i((t=>[...t,e]));let t=!1;return{dispose:()=>{if(t)throw new Error("invalid operation: resource already disposed");t=!0,i((t=>t.filter((t=>t!==e))))}}}),[])]};function qe(e){return null==e?void 0:e.type}class Ke{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._onDidFocus=new l,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new l,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dockview-react-part"}focus(){}init(e){this.part=new Xe(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 et{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 Xe(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 tt{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 Xe(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;this.parameters&&(this.parameters.params=e.params),null===(t=this.part)||void 0===t||t.update({params:(null===(i=this.parameters)||void 0===i?void 0:i.params)||{}})}layout(e,t){}updateParentGroup(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class it{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 v,this._element=document.createElement("div"),this._element.className="dockview-react-part"}focus(){}init(e){this.mutableDisposable.value=new u(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 Xe(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})}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 st(e,t){return e?i=>new it(e,t,i):void 0}const nt="props.defaultTabComponent",ot=e.forwardRef(((t,i)=>{const s=e.useRef(null),n=e.useRef(),[o,r]=Qe();return e.useImperativeHandle(i,(()=>s.current),[]),e.useEffect((()=>{if(!s.current)return()=>{};const e={content:{createComponent:(e,t,i)=>new Ke(t,i,{addPortal:r})},tab:{createComponent:(e,t,i)=>new et(t,i,{addPortal:r})},watermark:{createComponent:(e,t,i)=>new tt(t,i,{addPortal:r})}},i=t.tabComponents||{};t.defaultTabComponent&&(i[nt]=t.defaultTabComponent);const o=new He({parentElement:s.current,frameworkComponentFactory:e,frameworkComponents:t.components,frameworkTabComponents:i,watermarkFrameworkComponent:t.watermarkComponent,defaultTabComponent:t.defaultTabComponent?nt:void 0,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,showDndOverlay:t.showDndOverlay,createGroupControlElement:st(t.groupControlComponent,{addPortal:r}),singleTabMode:t.singleTabMode}),{clientWidth:a,clientHeight:h}=s.current;return o.layout(a,h),t.onReady&&t.onReady({api:new te(o)}),n.current=o,()=>{o.dispose()}}),[]),e.useEffect((()=>{if(!n.current)return()=>{};const e=n.current.onDidDrop((e=>{t.onDidDrop&&t.onDidDrop(e)}));return()=>{e.dispose()}}),[t.onDidDrop]),e.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:t.components})}),[t.components]),e.useEffect((()=>{n.current&&n.current.updateOptions({watermarkFrameworkComponent:t.watermarkComponent})}),[t.watermarkComponent]),e.useEffect((()=>{n.current&&n.current.updateOptions({showDndOverlay:t.showDndOverlay})}),[t.showDndOverlay]),e.useEffect((()=>{n.current&&n.current.updateOptions({frameworkTabComponents:t.tabComponents})}),[t.tabComponents]),e.useEffect((()=>{if(!n.current)return;const e=t.tabComponents||{};t.defaultTabComponent&&(e[nt]=t.defaultTabComponent),n.current.updateOptions({defaultTabComponent:t.defaultTabComponent?nt:void 0,frameworkTabComponents:e})}),[t.defaultTabComponent]),e.useEffect((()=>{n.current&&n.current.updateOptions({createGroupControlElement:st(t.groupControlComponent,{addPortal:r})})}),[t.groupControlComponent]),e.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:s},o)}));ot.displayName="DockviewComponent";const rt=()=>e.createElement("svg",{height:"11",width:"11",viewBox:"0 0 28 28","aria-hidden":"false",focusable:!1,className:"dockview-svg"},e.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"})),at=t=>{var{api:i,containerApi:s,params:n}=t,o=function(e,t){var i={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(i[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(i[s[n]]=e[s[n]])}return i}(t,["api","containerApi","params"]);const r=e.useCallback((e=>{e.stopPropagation(),i.close()}),[i]),a=e.useCallback((e=>{i.setActive(),o.onClick&&o.onClick(e)}),[i,o.onClick]),h=e.useMemo((()=>["dockview-react-tab-action"].join(",")),[]);return e.createElement("div",Object.assign({},o,{onClick:a,className:"dockview-react-tab"}),e.createElement("span",{className:"dockview-react-tab-title"},i.title),e.createElement("div",{className:h,onClick:r},e.createElement(rt,null)))};class ht extends $e{constructor(e,t,i,s){super(e,t),this.reactComponent=i,this.reactPortalStore=s}getComponent(){var e;return new Xe(this.element,this.reactPortalStore,this.reactComponent,{params:(null===(e=this._params)||void 0===e?void 0:e.params)||{},api:this.api,containerApi:new q(this._params.accessor)})}}const dt=e.forwardRef(((t,i)=>{const s=e.useRef(null),n=e.useRef(),[o,r]=Qe();return e.useImperativeHandle(i,(()=>s.current),[]),e.useEffect((()=>{const e=new Fe({parentElement:s.current,orientation:t.orientation||V.HORIZONTAL,frameworkComponents:t.components,frameworkWrapper:{createComponent:(e,t,i)=>new ht(e,t,i,{addPortal:r})},proportionalLayout:"boolean"!=typeof t.proportionalLayout||t.proportionalLayout,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0}),{clientWidth:i,clientHeight:o}=s.current;return e.layout(i,o),t.onReady&&t.onReady({api:new q(e)}),n.current=e,()=>{e.dispose()}}),[]),e.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:t.components})}),[t.components]),e.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:s},o)}));dt.displayName="SplitviewComponent";class lt extends ze{constructor(e,t,i,s){super(e,t),this.reactComponent=i,this.reactPortalStore=s}getComponent(){var e;return new Xe(this.element,this.reactPortalStore,this.reactComponent,{params:(null===(e=this._params)||void 0===e?void 0:e.params)||{},api:this.api,containerApi:new ee(this._params.accessor)})}}const pt=e.forwardRef(((t,i)=>{const s=e.useRef(null),n=e.useRef(),[o,r]=Qe();return e.useImperativeHandle(i,(()=>s.current),[]),e.useEffect((()=>{if(!s.current)return()=>{};const e=new Me({parentElement:s.current,proportionalLayout:"boolean"!=typeof t.proportionalLayout||t.proportionalLayout,orientation:t.orientation||V.HORIZONTAL,frameworkComponents:t.components,frameworkComponentFactory:{createComponent:(e,t,i)=>new lt(e,t,i,{addPortal:r})},styles:t.hideBorders?{separatorBorder:"transparent"}:void 0}),{clientWidth:i,clientHeight:o}=s.current;return e.layout(i,o),t.onReady&&t.onReady({api:new ee(e)}),n.current=e,()=>{e.dispose()}}),[]),e.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:t.components})}),[t.components]),e.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:s},o)}));pt.displayName="GridviewComponent";class mt{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 Xe(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 ct=e.forwardRef(((t,i)=>{const s=e.useRef(null),n=e.useRef(),[o,r]=Qe();return e.useImperativeHandle(i,(()=>s.current),[]),e.useEffect((()=>{const e=(e,t,i)=>new mt(e,i,{addPortal:r}),i=new je({parentElement:s.current,frameworkComponents:t.components,components:{},headerComponents:{},disableDnd:t.disableDnd,headerframeworkComponents:t.headerComponents,frameworkWrapper:{header:{createComponent:e},body:{createComponent:e}},showDndOverlay:t.showDndOverlay}),o=new K(i),{clientWidth:a,clientHeight:h}=s.current;return i.layout(a,h),t.onReady&&t.onReady({api:o}),n.current=i,()=>{i.dispose()}}),[]),e.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:t.components})}),[t.components]),e.useEffect((()=>{n.current&&n.current.updateOptions({headerframeworkComponents:t.headerComponents})}),[t.headerComponents]),e.useEffect((()=>{if(!n.current)return()=>{};const e=n.current,i=e.onDidDrop((i=>{t.onDidDrop&&t.onDidDrop(Object.assign(Object.assign({},i),{api:new K(e)}))}));return()=>{i.dispose()}}),[t.onDidDrop]),e.useEffect((()=>{n.current&&n.current.updateOptions({showDndOverlay:t.showDndOverlay})}),[t.showDndOverlay]),e.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:s},o)}));ct.displayName="PaneviewComponent";export{we as BaseGrid,re as ContentContainer,Te as DefaultDockviewDeserialzier,ke as DefaultTab,te as DockviewApi,He as DockviewComponent,u as DockviewCompositeDisposable,at as DockviewDefaultTab,ae as DockviewDropTargets,l as DockviewEmitter,i as DockviewEvent,xe as DockviewGroupPanel,ce as DockviewGroupPanelModel,v as DockviewMutableDisposable,Ne as DockviewPanel,ot as DockviewReact,ye as DraggablePaneviewPanel,Q as Gridview,ee as GridviewApi,Me as GridviewComponent,ze as GridviewPanel,pt as GridviewReact,k as LayoutPriority,a as LocalSelectionTransfer,V as Orientation,Be as PaneFramework,r as PaneTransfer,o as PanelTransfer,R as Paneview,K as PaneviewApi,je as PaneviewComponent,Ce as PaneviewPanel,ct as PaneviewReact,Xe as ReactPart,Ye as ReactPartContext,L as SashState,G as Sizing,T as Splitview,q as SplitviewApi,Fe as SplitviewComponent,$e as SplitviewPanel,dt as SplitviewReact,de as Tab,S as createComponent,se as directionToPosition,$ as getDirectionOrientation,B as getGridLocation,Z as getLocationOrientation,d as getPaneData,h as getPanelData,j as getRelativeLocation,J as indexInParent,Y as isGridBranchNode,Oe as isGroupOptionsWithGroup,Pe as isGroupOptionsWithPanel,Ae as isPanelOptionsWithGroup,Ee as isPanelOptionsWithPanel,qe as isReactElement,U as orthogonal,ne as positionToDirection,ge as toTarget,Qe as usePortalsLifecycle,g as watchElementResize};
|
|
7
|
+
import*as e from"react";import*as t from"react-dom";var i,s;!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&s.firstChild?s.insertBefore(n,s.firstChild):s.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}('@import "dockview-core/dist/styles/dockview.css";\n.tab .dockview-react-tab {\n display: flex;\n padding: 0px 8px;\n align-items: center;\n height: 100%;\n}\n.tab .dockview-react-tab .dockview-react-tab-title {\n padding: 0px 8px;\n flex-grow: 1;\n}\n.tab .dockview-react-tab .dockview-react-tab-action {\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n}\n.tab .dockview-react-tab .dockview-react-tab-action:hover {\n border-radius: 2px;\n background-color: var(--dv-icon-hover-background-color);\n}\n.tab.inactive-tab:not(:hover) .dockview-react-tab-action {\n visibility: hidden;\n}\n.dockview-react-part {\n height: 100%;\n width: 100%;\n}');class n{constructor(){}}class o extends n{constructor(e,t,i){super(),this.viewId=e,this.groupId=t,this.panelId=i}}class r extends n{constructor(e,t){super(),this.viewId=e,this.paneId=t}}class a{constructor(){}static getInstance(){return a.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 h(){const e=a.getInstance();if(e.hasData(o.prototype))return e.getData(o.prototype)[0]}function d(){const e=a.getInstance();if(e.hasData(r.prototype))return e.getData(r.prototype)[0]}a.INSTANCE=new a,function(e){e.any=(...e)=>t=>{const i=e.map((e=>e(t)));return{dispose:()=>{i.forEach((e=>{e.dispose()}))}}}}(i||(i={}));class l{static create(){var e;return new l(null!==(e=(new Error).stack)&&void 0!==e?e:"")}constructor(e){this.value=e}print(){console.warn(this.value)}}class p{constructor(e,t){this.callback=e,this.stacktrace=t}}class m{static setLeakageMonitorEnabled(e){e!==m.ENABLE_TRACKING&&m.MEMORY_LEAK_WATCHER.clear(),m.ENABLE_TRACKING=e}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 p(e,m.ENABLE_TRACKING?l.create():void 0);return this._listeners.push(i),{dispose:()=>{const e=this._listeners.indexOf(i);e>-1?this._listeners.splice(e,1):m.ENABLE_TRACKING}}},m.ENABLE_TRACKING&&m.MEMORY_LEAK_WATCHER.add(this._event,l.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&&(m.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=[]),m.ENABLE_TRACKING&&this._event&&m.MEMORY_LEAK_WATCHER.delete(this._event))}}function c(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i)}}}function u(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i)}}}m.ENABLE_TRACKING=!1,m.MEMORY_LEAK_WATCHER=new class{constructor(){this.events=new Map}get size(){return this.events.size}add(e,t){this.events.set(e,t)}delete(e){this.events.delete(e)}clear(){this.events.clear()}};class v{constructor(){this._onFired=new m,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:()=>{}}}(s||(s={}));class g{get isDisposed(){return this._isDisposed}static from(...e){return new g(...e)}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 w{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 _(e,t){const i=new ResizeObserver((e=>{requestAnimationFrame((()=>{const i=e[0];t(i)}))}));return i.observe(e),{dispose:()=>{i.unobserve(e),i.disconnect()}}}const f=(e,...t)=>{for(const i of t)e.classList.contains(i)&&e.classList.remove(i)},D=(e,...t)=>{for(const i of t)e.classList.contains(i)||e.classList.add(i)},b=(e,t,i)=>{const s=e.classList.contains(t);i&&!s&&e.classList.add(t),!i&&s&&e.classList.remove(t)};function C(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function y(e){return Array.prototype.slice.call(document.getElementsByTagName(e),0)}function S(e){return new z(e)}class z extends g{constructor(e){super(),this._onDidFocus=new m,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new m,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=C(document.activeElement,e),i=!1;const s=()=>{i=!1,t||(t=!0,this._onDidFocus.fire())},n=()=>{t&&(i=!0,window.setTimeout((()=>{i&&(i=!1,t=!1,this._onDidBlur.fire())}),0))};this._refreshStateHandler=()=>{C(document.activeElement,e)!==t&&(t?n():s())},e instanceof HTMLElement?(this.addDisposables(u(e,"focus",s,!0)),this.addDisposables(u(e,"blur",n,!0))):(this.addDisposables(c(e,"focus",s,!0)),this.addDisposables(c(e,"blur",n,!0)))}refreshState(){this._refreshStateHandler()}}function E(e,t,i={},s={},n,o){const r="string"==typeof t?i[t]:void 0,a="string"==typeof t?s[t]:void 0;if(r&&a)throw new Error(`Cannot create '${e}'. component '${t}' registered as both a component and frameworkComponent`);if(a){if(!n)throw new Error(`Cannot create '${e}' for framework component '${t}'. you must register a frameworkPanelWrapper to use framework components`);return n.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 x(e){if(0===e.length)throw new Error("Invalid tail call");return[e.slice(0,e.length-1),e[e.length-1]]}function A(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 P(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.unshift(t))}function I(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.push(t))}const O=(e,t,i)=>{if(t>i)throw new Error(`${t} > ${i} is an invalid condition`);return Math.min(i,Math.max(e,t))},N=()=>{let e=1;return{next:()=>(e++).toString()}},V=(e,t)=>{const i=[];if("number"!=typeof t&&(t=e,e=0),e<=t)for(let s=e;s<t;s++)i.push(s);else for(let s=e;s>t;s--)i.push(s);return i};class L{set size(e){this._size=e}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return void 0===this._cachedVisibleSize}get minimumSize(){return this.visible?this.view.minimumSize:0}get viewMinimumSize(){return this.view.minimumSize}get maximumSize(){return this.visible?this.view.maximumSize:0}get viewMaximumSize(){return this.view.maximumSize}get priority(){return this.view.priority}get snap(){return!!this.view.snap}set enabled(e){this.container.style.pointerEvents=e?"":"none"}constructor(e,t,i,s){this.container=e,this.view=t,this.disposable=s,this._cachedVisibleSize=void 0,"number"==typeof i?(this._size=i,this._cachedVisibleSize=void 0,e.classList.add("visible")):(this._size=0,this._cachedVisibleSize=i.cachedVisibleSize)}setVisible(e,t){var i;e!==this.visible&&(e?(this.size=O(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 k,G,T,R;!function(e){e.HORIZONTAL="HORIZONTAL",e.VERTICAL="VERTICAL"}(k||(k={})),function(e){e[e.MAXIMUM=0]="MAXIMUM",e[e.MINIMUM=1]="MINIMUM",e[e.DISABLED=2]="DISABLED",e[e.ENABLED=3]="ENABLED"}(G||(G={})),function(e){e.Low="low",e.High="high",e.Normal="normal"}(T||(T={})),function(e){e.Distribute={type:"distribute"},e.Split=function(e){return{type:"split",index:e}},e.Invisible=function(e){return{type:"invisible",cachedVisibleSize:e}}}(R||(R={}));class H{get size(){return this._size}set size(e){this._size=e}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get length(){return this.viewItems.length}get proportions(){return this._proportions?[...this._proportions]:void 0}get orientation(){return this._orientation}set orientation(e){this._orientation=e;const t=this.size;this.size=this.orthogonalSize,this.orthogonalSize=t,f(this.element,"horizontal","vertical"),this.element.classList.add(this.orientation==k.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 m,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new m,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new m,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(e,t,i=this.viewItems.map((e=>e.size)),s,n,o=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY,a,h)=>{if(e<0||e>this.viewItems.length)return 0;const d=V(e,-1),l=V(e+1,this.viewItems.length);if(n)for(const e of n)P(d,e),P(l,e);if(s)for(const e of s)I(d,e),I(l,e);const p=d.map((e=>this.viewItems[e])),m=d.map((e=>i[e])),c=l.map((e=>this.viewItems[e])),u=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),_=0===l.length?Number.NEGATIVE_INFINITY:l.reduce(((e,t)=>e+i[t]-this.viewItems[t].maximumSize),0),f=Math.max(v,_),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,s,n,o,r);let C=0,y=O(t,f,D);for(let e=0;e<p.length;e++){const t=p[e],i=O(m[e]+y,t.minimumSize,t.maximumSize),s=i-m[e];C+=s,y-=s,t.size=i}let S=C;for(let e=0;e<c.length;e++){const t=c[e],i=O(u[e]-S,t.minimumSize,t.maximumSize);S+=i-u[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},s=e.view;this.addView(s,i,t,!0)})),this.contentSize=this.viewItems.reduce(((e,t)=>e+t.size),0),this.saveProportions())}style(e){"transparent"===(null==e?void 0:e.separatorBorder)?(f(this.element,"separator-border"),this.element.style.removeProperty("--dv-separator-border")):(D(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");b(this.container,"visible",t);const i=this.viewItems[e];b(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(e,t){if(e<0||e>=this.viewItems.length)return;const i=V(this.viewItems.length).filter((t=>t!==e)),s=[...i.filter((e=>this.viewItems[e].priority===T.Low)),e],n=i.filter((e=>this.viewItems[e].priority===T.High)),o=this.viewItems[e];t=Math.round(t),t=O(t,o.minimumSize,Math.min(o.maximumSize,this._size)),o.size=t,this.relayout(s,n)}getViews(){return this.viewItems.map((e=>e.view))}onDidChange(e,t){const i=this.viewItems.indexOf(e);i<0||i>=this.viewItems.length||(t="number"==typeof t?t:e.size,t=O(t,e.minimumSize,e.maximumSize),e.size=t,this.relayout([i]))}addView(e,t={type:"distribute"},i=this.viewItems.length,s){const n=document.createElement("div");let o;n.className="view",n.appendChild(e.element),o="number"==typeof t?t:"split"===t.type?this.getViewSize(t.index)/2:"invisible"===t.type?{cachedVisibleSize:t.cachedVisibleSize}:e.minimumSize;const r=e.onDidChange((e=>this.onDidChange(a,e.size))),a=new L(n,e,o,{dispose:()=>{r.dispose(),this.viewContainer.removeChild(n)}});if(i===this.viewItems.length?this.viewContainer.appendChild(n):this.viewContainer.insertBefore(n,this.viewContainer.children.item(i)),this.viewItems.splice(i,0,a),this.viewItems.length>1){const e=document.createElement("div");e.className="sash";const t=t=>{for(const e of this.viewItems)e.enabled=!1;const i=[...y("iframe"),...y("webview")];for(const e of i)e.style.pointerEvents="none";const s=this._orientation===k.HORIZONTAL?t.clientX:t.clientY,n=function(e,t){for(let i=0;i<e.length;i++)if(t(e[i]))return i;return-1}(this.sashes,(t=>t.container===e)),o=this.viewItems.map((e=>e.size));let r,a;const h=V(n,-1),d=V(n+1,this.viewItems.length),l=h.reduce(((e,t)=>e+(this.viewItems[t].minimumSize-o[t])),0),p=h.reduce(((e,t)=>e+(this.viewItems[t].viewMaximumSize-o[t])),0),m=0===d.length?Number.POSITIVE_INFINITY:d.reduce(((e,t)=>e+(o[t]-this.viewItems[t].minimumSize)),0),c=0===d.length?Number.NEGATIVE_INFINITY:d.reduce(((e,t)=>e+(o[t]-this.viewItems[t].viewMaximumSize)),0),u=Math.max(l,c),v=Math.min(m,p),g=this.findFirstSnapIndex(h),w=this.findFirstSnapIndex(d);if("number"==typeof g){const e=this.viewItems[g],t=Math.floor(e.viewMinimumSize/2);r={index:g,limitDelta:e.visible?u-t:u+t,size:e.size}}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}}const _=e=>{const t=(this._orientation===k.HORIZONTAL?e.clientX:e.clientY)-s;this.resize(n,t,o,void 0,void 0,u,v,r,a),this.distributeEmptySpace(),this.layoutViews()},f=()=>{for(const e of this.viewItems)e.enabled=!0;for(const e of i)e.style.pointerEvents="auto";this.saveProportions(),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",f),document.removeEventListener("mouseend",f),this._onDidSashEnd.fire(void 0)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",f),document.addEventListener("mouseend",f)};e.addEventListener("mousedown",t);const i={container:e,disposable:()=>{e.removeEventListener("mousedown",t),this.sashContainer.removeChild(e)}};this.sashContainer.appendChild(e),this.sashes.push(i)}s||this.relayout([i]),s||"number"==typeof t||"distribute"!==t.type||this.distributeViewSizes(),this._onDidAddView.fire(e)}distributeViewSizes(){const e=[];let t=0;for(const i of this.viewItems)i.maximumSize-i.minimumSize>0&&(e.push(i),t+=i.size);const i=Math.floor(t/e.length);for(const t of e)t.size=O(i,t.minimumSize,t.maximumSize);const s=V(this.viewItems.length),n=s.filter((e=>this.viewItems[e].priority===T.Low)),o=s.filter((e=>this.viewItems[e].priority===T.High));this.relayout(n,o)}removeView(e,t,i=!1){const s=this.viewItems.splice(e,1)[0];if(s.dispose(),this.viewItems.length>=1){const t=Math.max(e-1,0);this.sashes.splice(t,1)[0].disposable()}return i||this.relayout(),t&&"distribute"===t.type&&this.distributeViewSizes(),this._onDidRemoveView.fire(s.view),s.view}getViewCachedVisibleSize(e){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");return this.viewItems[e].cachedVisibleSize}moveView(e,t){const i=this.getViewCachedVisibleSize(e),s=void 0===i?this.getViewSize(e):R.Invisible(i),n=this.removeView(e,void 0,!0);this.addView(n,s,t)}layout(e,t){const i=Math.max(this.size,this.contentSize);if(this.size=e,this.orthogonalSize=t,this.proportions)for(let t=0;t<this.viewItems.length;t++){const i=this.viewItems[t];i.size=O(Math.round(this.proportions[t]*e),i.minimumSize,i.maximumSize)}else{const t=V(this.viewItems.length),s=t.filter((e=>this.viewItems[e].priority===T.Low)),n=t.filter((e=>this.viewItems[e].priority===T.High));this.resize(this.viewItems.length-1,e-i,void 0,s,n)}this.distributeEmptySpace(),this.layoutViews()}relayout(e,t){const i=this.viewItems.reduce(((e,t)=>e+t.size),0);this.resize(this.viewItems.length-1,this._size-i,void 0,e,t),this.distributeEmptySpace(),this.layoutViews(),this.saveProportions()}distributeEmptySpace(e){const t=this.viewItems.reduce(((e,t)=>e+t.size),0);let i=this.size-t;const s=V(this.viewItems.length-1,-1),n=s.filter((e=>this.viewItems[e].priority===T.Low)),o=s.filter((e=>this.viewItems[e].priority===T.High));for(const e of o)P(s,e);for(const e of n)I(s,e);"number"==typeof e&&I(s,e);for(let e=0;0!==i&&e<s.length;e++){const t=this.viewItems[s[e]],n=O(t.size+i,t.minimumSize,t.maximumSize);i-=n-t.size,t.size=n}}saveProportions(){this.proportionalLayout&&this.contentSize>0&&(this._proportions=this.viewItems.map((e=>e.size/this.contentSize)))}layoutViews(){this.contentSize=this.viewItems.reduce(((e,t)=>e+t.size),0);let e=0;const t=[];this.updateSashEnablement();for(let i=0;i<this.viewItems.length-1;i++){e+=this.viewItems[i].size,t.push(e);const s=Math.min(Math.max(0,e-2),this.size-4);this._orientation===k.HORIZONTAL&&(this.sashes[i].container.style.left=`${s}px`,this.sashes[i].container.style.top="0px"),this._orientation===k.VERTICAL&&(this.sashes[i].container.style.left="0px",this.sashes[i].container.style.top=`${s}px`)}this.viewItems.forEach(((e,i)=>{this._orientation===k.HORIZONTAL&&(e.container.style.width=`${e.size}px`,e.container.style.left=0==i?"0px":`${t[i-1]}px`,e.container.style.top="",e.container.style.height=""),this._orientation===k.VERTICAL&&(e.container.style.height=`${e.size}px`,e.container.style.top=0==i?"0px":`${t[i-1]}px`,e.container.style.width="",e.container.style.left=""),e.view.layout(e.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 e=!1;const t=this.viewItems.map((t=>e=t.size-t.minimumSize>0||e));e=!1;const i=this.viewItems.map((t=>e=t.maximumSize-t.size>0||e)),s=[...this.viewItems].reverse();e=!1;const n=s.map((t=>e=t.size-t.minimumSize>0||e)).reverse();e=!1;const o=s.map((t=>e=t.maximumSize-t.size>0||e)).reverse();let r=0;for(let e=0;e<this.sashes.length;e++){const s=this.sashes[e];r+=this.viewItems[e].size;const a=!(t[e]&&o[e+1]),h=!(i[e]&&n[e+1]);if(a&&h){const i=V(e,-1),o=V(e+1,this.viewItems.length),a=this.findFirstSnapIndex(i),h=this.findFirstSnapIndex(o),d="number"==typeof a&&!this.viewItems[a].visible,l="number"==typeof h&&!this.viewItems[h].visible;d&&n[e]&&(r>0||this.startSnappingEnabled)?this.updateSash(s,G.MINIMUM):l&&t[e]&&(r<this.contentSize||this.endSnappingEnabled)?this.updateSash(s,G.MAXIMUM):this.updateSash(s,G.DISABLED)}else a&&!h?this.updateSash(s,G.MINIMUM):!a&&h?this.updateSash(s,G.MAXIMUM):this.updateSash(s,G.ENABLED)}}updateSash(e,t){b(e.container,"disabled",t===G.DISABLED),b(e.container,"enabled",t===G.ENABLED),b(e.container,"maximum",t===G.MAXIMUM),b(e.container,"minimum",t===G.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 e=document.createElement("div"),t=this._orientation===k.HORIZONTAL?"horizontal":"vertical";return e.className=`split-view-container ${t}`,e}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.removeChild(this.element);break}for(const e of this.viewItems)e.dispose();this.element.remove()}}class M extends g{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(e,t){var i;super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this._orientation=null!==(i=t.orientation)&&void 0!==i?i:k.VERTICAL,this.element=document.createElement("div"),this.element.className="pane-container",e.appendChild(this.element),this.splitview=new H(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:t.descriptor}),this.getPanes().forEach((e=>{const t=new g(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,s=!1){const n=e.onDidChangeExpansionState((()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),o={pane:e,disposable:{dispose:()=>{n.dispose()}}};this.paneItems.splice(i,0,o),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,i,s)}getViewSize(e){return this.splitview.getViewSize(e)}getPanes(){return this.splitview.getViews()}removePane(e,t={skipDispose:!1}){const i=this.paneItems.splice(e,1)[0];return this.splitview.removeView(e),t.skipDispose||(i.disposable.dispose(),i.pane.dispose()),i}moveView(e,t){if(e===t)return;const i=this.removePane(e,{skipDispose:!0});this.skipAnimation=!0;try{this.addPane(i.pane,i.pane.size,t,!1)}finally{this.skipAnimation=!1}}layout(e,t){this.splitview.layout(e,t)}setupAnimation(){this.skipAnimation||(this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=void 0),D(this.element,"animated"),this.animationTimer=setTimeout((()=>{this.animationTimer=void 0,f(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 F{get minimumWidth(){return this.view.minimumWidth}get maximumWidth(){return this.view.maximumWidth}get minimumHeight(){return this.view.minimumHeight}get maximumHeight(){return this.view.maximumHeight}get priority(){return this.view.priority}get snap(){return this.view.snap}get minimumSize(){return this.orientation===k.HORIZONTAL?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===k.HORIZONTAL?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===k.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===k.HORIZONTAL?this.maximumWidth:this.maximumHeight}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get element(){return this.view.element}get width(){return this.orientation===k.HORIZONTAL?this.orthogonalSize:this.size}get height(){return this.orientation===k.HORIZONTAL?this.size:this.orthogonalSize}constructor(e,t,i,s=0){this.view=e,this.orientation=t,this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this._orthogonalSize=i,this._size=s,this._disposable=this.view.onDidChange((e=>{e?this._onDidChange.fire({size:this.orientation===k.VERTICAL?e.width:e.height,orthogonalSize:this.orientation===k.VERTICAL?e.height:e.width}):this._onDidChange.fire({})}))}setVisible(e){this.view.setVisible&&(this.view.setVisible(e),this._onDidChange.fire({}))}layout(e,t){this._size=e,this._orthogonalSize=t,this.view.layout(this.width,this.height)}dispose(){this._onDidChange.dispose(),this._disposable.dispose()}}class W extends g{get width(){return this.orientation===k.HORIZONTAL?this.size:this.orthogonalSize}get height(){return this.orientation===k.HORIZONTAL?this.orthogonalSize:this.size}get minimumSize(){return 0===this.children.length?0:Math.max(...this.children.map((e=>e.minimumOrthogonalSize)))}get maximumSize(){return Math.min(...this.children.map((e=>e.maximumOrthogonalSize)))}get minimumOrthogonalSize(){return this.splitview.minimumSize}get maximumOrthogonalSize(){return this.splitview.maximumSize}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get minimumWidth(){return this.orientation===k.HORIZONTAL?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===k.HORIZONTAL?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===k.HORIZONTAL?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===k.HORIZONTAL?this.maximumSize:this.maximumOrthogonalSize}get priority(){if(0===this.children.length)return T.Normal;const e=this.children.map((e=>void 0===e.priority?T.Normal:e.priority));return e.some((e=>e===T.High))?T.High:e.some((e=>e===T.Low))?T.Low:T.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 m,this.onDidChange=this._onDidChange.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 F&&void 0!==e.visible)||e.visible}))),size:this.size};this.children=r.map((e=>e.node)),this.splitview=new H(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:t})}else this.splitview=new H(this.element,{orientation:this.orientation,proportionalLayout:t,styles:i}),this.splitview.layout(this.size,this.orthogonalSize);this.addDisposables(this._onDidChange,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");this.splitview.isViewVisible(e)!==t&&this.splitview.setViewVisible(e,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(this.size,this.orthogonalSize)}addChild(e,t,i,s){if(i<0||i>this.children.length)throw new Error("Invalid index");this.splitview.addView(e,t,i,s),this._addChild(e,i)}getChildCachedVisibleSize(e){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewCachedVisibleSize(e)}removeChild(e,t){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.removeView(e,t),this._removeChild(e)}_addChild(e,t){this.children.splice(t,0,e),this.setupChildrenEvents()}_removeChild(e){const[t]=this.children.splice(e,1);return this.setupChildrenEvents(),t}setupChildrenEvents(){this._childrenDisposable.dispose(),this._childrenDisposable=i.any(...this.children.map((e=>e.onDidChange)))((e=>{this._onDidChange.fire({size:e.orthogonalSize})}))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach((e=>e.dispose())),super.dispose()}}function B(e,t){if(e instanceof F)return e;if(e instanceof W)return B(e.children[t?e.children.length-1:0],t);throw new Error("invalid node")}function J(e,t,i){if(e instanceof W){const s=new W(X(e.orientation),e.proportionalLayout,e.styles,t,i);let n=0;for(let o=e.children.length-1;o>=0;o--){const r=e.children[o],a=r instanceof W?r.orthogonalSize:r.size;let h=0===e.size?0:Math.round(t*a/e.size);n+=h,0===o&&(h+=t-n),s.addChild(J(r,i,h),h,0,!0)}return s}return new F(e.view,X(e.orientation),i)}function j(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");let i=t.firstElementChild,s=0;for(;i!==e&&i!==t.lastElementChild&&i;)i=i.nextElementSibling,s++;return s}function $(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");if(/\bgrid-view\b/.test(t.className))return[];const i=j(t);return[...$(t.parentElement.parentElement.parentElement),i]}function Z(e,t,i){if(Y(e,t)===U(i)){const[e,s]=x(t);let n=s;return"right"!==i&&"bottom"!==i||(n+=1),[...e,n]}{const e="right"===i||"bottom"===i?1:0;return[...t,e]}}function U(e){return"top"===e||"bottom"===e?k.VERTICAL:k.HORIZONTAL}function Y(e,t){return t.length%2==0?X(e):e}const X=e=>e===k.HORIZONTAL?k.VERTICAL:k.HORIZONTAL;function K(e){return!!e.children}const q=(e,t)=>{const i=t===k.VERTICAL?e.box.width:e.box.height;return K(e)?{type:"branch",data:e.children.map((e=>q(e,X(t)))),size:i}:"number"==typeof e.cachedVisibleSize?{type:"leaf",data:e.view.toJSON(),size:e.cachedVisibleSize,visible:!1}:{type:"leaf",data:e.view.toJSON(),size:i}};class Q{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=J(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}serialize(){return{root:q(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this.root.dispose(),this.element.remove()}clear(){const e=this.root.orientation;this.root=new W(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize)}deserialize(e,t){const i=e.orientation,s=i===k.VERTICAL?e.height:e.width;this._deserialize(e.root,i,t,s)}_deserialize(e,t,i,s){this.root=this._deserializeNode(e,t,i,s,!0)}_deserializeNode(e,t,i,s,n=!1){let o;if("branch"===e.type){const r=e.data.map((s=>({node:this._deserializeNode(s,X(t),i,e.size),visible:s.visible})));o=new W(t,this.proportionalLayout,this.styles,n?s:e.size,n?e.size:s,r)}else o=new F(i.fromJSON(e),t,s,e.size);return o}get root(){return this._root}set root(e){const t=this._root;t&&(t.dispose(),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 e=this.root;if(e.element.remove(),this._root=new W(X(e.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size),1===e.children.length){const t=e.children[0];e.removeChild(0).dispose(),e.dispose(),this._root.addChild(J(t,t.orthogonalSize,t.size),R.Distribute,0)}else this._root.addChild(e,R.Distribute,0);this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange((e=>{this._onDidChange.fire(e)}))}next(e){return this.progmaticSelect(e)}previous(e){return this.progmaticSelect(e,!0)}getView(e){const t=e?this.getNode(e)[1]:this.root;return this._getViews(t,this.orientation)}_getViews(e,t,i){const s={height:e.height,width:e.width};if(e instanceof F)return{box:s,view:e.view,cachedVisibleSize:i};const n=[];for(let i=0;i<e.children.length;i++){const s=e.children[i],o=e.getChildCachedVisibleSize(i);n.push(this._getViews(s,X(t),o))}return{box:s,children:n}}progmaticSelect(e,t=!1){const[i,s]=this.getNode(e);if(!(s instanceof F))throw new Error("invalid location");for(let s=i.length-1;s>-1;s--){const n=i[s],o=e[s]||0;if(t?o-1>-1:o+1<n.children.length)return B(n.children[t?o-1:o+1],t)}return B(this.root,t)}constructor(e,t,i){this.proportionalLayout=e,this.styles=t,this.disposable=new w,this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this.element=document.createElement("div"),this.element.className="grid-view",this.root=new W(i,e,t,0,0)}isViewVisible(e){const[t,i]=x(e),[,s]=this.getNode(t);if(!(s instanceof W))throw new Error("Invalid from location");return s.isChildVisible(i)}setViewVisible(e,t){const[i,s]=x(e),[,n]=this.getNode(i);if(!(n instanceof W))throw new Error("Invalid from location");n.setChildVisible(s,t)}moveView(e,t,i){const[,s]=this.getNode(e);if(!(s instanceof W))throw new Error("Invalid location");s.moveChild(t,i)}addView(e,t,i){const[s,n]=x(i),[o,r]=this.getNode(s);if(r instanceof W){const i=new F(e,X(r.orientation),r.orthogonalSize);r.addChild(i,t,n)}else{const[i,...a]=[...o].reverse(),[h,...d]=[...s].reverse();let l=0;const p=i.getChildCachedVisibleSize(h);"number"==typeof p&&(l=R.Invisible(p));i.removeChild(h).dispose();const m=new W(r.orientation,this.proportionalLayout,this.styles,r.size,r.orthogonalSize);i.addChild(m,r.size,h);const c=new F(r.view,i.orientation,r.size);m.addChild(c,l,0),"number"!=typeof t&&"split"===t.type&&(t={type:"split",index:0});const u=new F(e,i.orientation,r.size);m.addChild(u,t,n)}}remove(e,t){const i=$(e.element);return this.removeView(i,t)}removeView(e,t){const[i,s]=x(e),[n,o]=this.getNode(i);if(!(o instanceof W))throw new Error("Invalid location");const r=o.children[s];if(!(r instanceof F))throw new Error("Invalid location");const a=r.view;r.dispose();if(o.removeChild(s,t).dispose(),0===o.children.length)return a;if(o.children.length>1)return a;const h=o.children[0];if(0===n.length){if(h instanceof F)return a;return o.removeChild(0,t).dispose(),this.root=h,a}const[d,...l]=[...n].reverse(),[p,...m]=[...i].reverse(),c=o.isChildVisible(0);o.removeChild(0,t).dispose();const u=d.children.map(((e,t)=>d.getChildSize(t)));if(d.removeChild(p,t).dispose(),h instanceof W){u.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)}}else{const e=new F(h.view,X(h.orientation),h.size),t=c?h.orthogonalSize:R.Invisible(h.orthogonalSize);d.addChild(e,t,p)}for(let e=0;e<u.length;e++)d.resizeChild(e,u[e]);return a}layout(e,t){const[i,s]=this.root.orientation===k.HORIZONTAL?[t,e]:[e,t];this.root.layout(i,s)}getNode(e,t=this.root,i=[]){if(0===e.length)return[i,t];if(!(t instanceof W))throw new Error("Invalid location");const[s,...n]=e;if(s<0||s>=t.children.length)throw new Error("Invalid location");const o=t.children[s];return i.push(t),this.getNode(n,o,i)}}class ee{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get height(){return this.component.height}get width(){return this.component.width}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 te{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get height(){return this.component.height}get width(){return this.component.width}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 m,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 ie{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 width(){return this.component.width}get height(){return this.component.height}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 se{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 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)}addGroup(e){return this.component.addGroup(e)}moveToNext(e){this.component.moveToNext(e)}moveToPrevious(e){this.component.moveToPrevious(e)}closeAllGroups(){return this.component.closeAllGroups()}removeGroup(e){this.component.removeGroup(e)}getGroup(e){return this.component.getPanel(e)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}}class ne extends g{constructor(e,t){super(),this.element=e,this.callbacks=t,this.target=null,this.registerListeners()}registerListeners(){this.addDisposables(u(this.element,"dragenter",(e=>{this.target=e.target,this.callbacks.onDragEnter(e)}),!0)),this.addDisposables(u(this.element,"dragover",(e=>{e.preventDefault(),this.callbacks.onDragOver&&this.callbacks.onDragOver(e)}),!0)),this.addDisposables(u(this.element,"dragleave",(e=>{this.target===e.target&&(this.target=null,this.callbacks.onDragLeave(e))}))),this.addDisposables(u(this.element,"dragend",(e=>{this.target=null,this.callbacks.onDragEnd(e)}))),this.addDisposables(u(this.element,"drop",(e=>{this.callbacks.onDrop(e)})))}}function oe(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 re(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 ae extends g{get state(){return this._state}constructor(e,t){super(),this.element=e,this.options=t,this._onDrop=new m,this.onDrop=this._onDrop.event;const i=new Set(this.options.acceptedTargetZones);this.addDisposables(this._onDrop,new ne(this.element,{onDragEnter:()=>{},onDragOver:e=>{const t=this.element.clientWidth,s=this.element.clientHeight;if(0===t||0===s)return;const n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left,r=e.clientY-n.top,a=this.calculateQuadrant(i,o,r,t,s);if(null!==a){if("boolean"==typeof this.options.canDisplayOverlay){if(!this.options.canDisplayOverlay)return}else if(!this.options.canDisplayOverlay(e,a))return;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)),0!==this.options.acceptedTargetZones.length&&this.targetElement&&this.overlayElement&&(this.toggleClasses(a,t,s),this.setState(a))}else this.removeDropTarget()},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}))}}))}dispose(){this.removeDropTarget(),super.dispose()}toggleClasses(e,t,i){var s,n,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,c=!a&&l,u=!a&&d,v=!h&&p,g=!h&&m;let w=.5;"percentage"===(null===(n=null===(s=this.options.overlayModel)||void 0===s?void 0:s.size)||void 0===n?void 0:n.type)&&(w=O(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)&&((c||u)&&(w=O(0,this.options.overlayModel.size.value,t)/t),(v||g)&&(w=O(0,this.options.overlayModel.size.value,i)/i));const _=(1-w)/2;let f;f=c?`translateX(${100*_}%) scaleX(${w})`:u?`translateX(-${100*_}%) scaleX(${w})`:v?`translateY(-${100*_}%) scaleY(${w})`:g?`translateY(${100*_}%) scaleY(${w})`:"",this.overlayElement.style.transform=f,b(this.overlayElement,"small-right",a&&l),b(this.overlayElement,"small-left",a&&d),b(this.overlayElement,"small-top",h&&p),b(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,s,n){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=(c=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,u=20,"number"==typeof c?c:u);var c,u;return p?function(e,t,i,s,n,o){const r=100*t/s,a=100*i/n;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,s,n,m):function(e,t,i,s,n,o){if(e.has("left")&&t<o)return"left";if(e.has("right")&&t>s-o)return"right";if(e.has("top")&&i<o)return"top";if(e.has("bottom")&&i>n-o)return"bottom";if(!e.has("center"))return null;return"center"}(e,t,i,s,n,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"))}}class he extends g{get element(){return this._element}constructor(){super(),this.disposable=new w,this._onDidFocus=new m,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new m,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="content-container",this._element.tabIndex=-1,this.addDisposables(this._onDidFocus,this._onDidBlur)}show(){this.element.style.display=""}hide(){this.element.style.display="none"}openPanel(e){var t;if(this.panel===e)return;this.panel&&((null===(t=this.panel.view)||void 0===t?void 0:t.content)&&this._element.removeChild(this.panel.view.content.element),this.panel=void 0),this.panel=e;const i=new g;if(this.panel.view){const e=this.panel.view.content.onDidFocus,t=this.panel.view.content.onDidBlur,s=S(this._element);i.addDisposables(s,s.onDidFocus((()=>this._onDidFocus.fire())),s.onDidBlur((()=>this._onDidBlur.fire()))),e&&i.addDisposables(e((()=>this._onDidFocus.fire()))),t&&i.addDisposables(t((()=>this._onDidBlur.fire()))),this._element.appendChild(this.panel.view.content.element)}this.disposable.value=i}layout(e,t){}closePanel(){var e,t,i;(null===(i=null===(t=null===(e=this.panel)||void 0===e?void 0:e.view)||void 0===t?void 0:t.content)||void 0===i?void 0:i.element)&&(this._element.removeChild(this.panel.view.content.element),this.panel=void 0)}dispose(){this.disposable.dispose(),super.dispose()}}var de;!function(e){e[e.Tab=0]="Tab",e[e.Panel=1]="Panel",e[e.TabContainer=2]="TabContainer",e[e.Edge=3]="Edge"}(de||(de={}));class le extends g{constructor(e){super(),this.el=e,this.disposable=new w,this._onDragStart=new m,this.onDragStart=this._onDragStart.event,this.iframes=[],this.addDisposables(this._onDragStart),this.configure()}configure(){this.addDisposables(this._onDragStart,u(this.el,"dragstart",(e=>{this.iframes=[...y("iframe"),...y("webview")];for(const e of this.iframes)e.style.pointerEvents="none";this.el.classList.add("dv-dragged"),setTimeout((()=>this.el.classList.remove("dv-dragged")),0),this.disposable.value=this.getData(e.dataTransfer),e.dataTransfer&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain","__dockview_internal_drag_event__"))})),u(this.el,"dragend",(()=>{for(const e of this.iframes)e.style.pointerEvents="auto";this.iframes=[],this.disposable.dispose()})))}}class pe extends g{get element(){return this._element}constructor(e,t,i){super(),this.panelId=e,this.accessor=t,this.group=i,this._onChanged=new m,this.onChanged=this._onChanged.event,this._onDropped=new m,this.onDrop=this._onDropped.event,this._element=document.createElement("div"),this._element.className="tab",this._element.tabIndex=0,this._element.draggable=!0,b(this.element,"inactive-tab",!0),this.addDisposables(this._onChanged,this._onDropped,new class extends le{constructor(){super(...arguments),this.panelTransfer=a.getInstance()}getData(){return this.panelTransfer.setData([new o(t.id,i.id,e)],o.prototype),{dispose:()=>{this.panelTransfer.clearData(o.prototype)}}}}(this._element)),this.addDisposables(u(this._element,"mousedown",(e=>{e.defaultPrevented||(e.stopPropagation(),this._onChanged.fire(e))}))),this.droptarget=new ae(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:(e,t)=>{if(this.group.locked)return!1;const i=h();return i&&this.accessor.id===i.viewId?(null!==i.panelId||i.groupId!==this.group.id)&&this.panelId!==i.panelId:this.group.model.canDisplayOverlay(e,t,de.Tab)}}),this.addDisposables(this.droptarget.onDrop((e=>{this._onDropped.fire(e)})),this.droptarget)}setActive(e){b(this.element,"active-tab",e),b(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 me extends le{constructor(e,t,i){super(e),this.accessorId=t,this.group=i,this.panelTransfer=a.getInstance()}getData(e){this.panelTransfer.setData([new o(this.accessorId,this.group.id,null)],o.prototype);const t=window.getComputedStyle(this.el),i=t.getPropertyValue("--dv-activegroup-visiblepanel-tab-background-color"),s=t.getPropertyValue("--dv-activegroup-visiblepanel-tab-color");if(e){const t=document.createElement("div");t.style.backgroundColor=i,t.style.color=s,t.style.padding="2px 8px",t.style.height="24px",t.style.fontSize="11px",t.style.lineHeight="20px",t.style.borderRadius="12px",t.style.position="absolute",t.textContent=`Multiple Panels (${this.group.size})`,function(e,t){D(t,"dv-dragged"),document.body.appendChild(t),e.setDragImage(t,0,0),setTimeout((()=>{f(t,"dv-dragged"),t.remove()}),0)}(e,t)}return{dispose:()=>{this.panelTransfer.clearData(o.prototype)}}}}class ce extends g{get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this._onDrop=new m,this.onDrop=this._onDrop.event,this._element=document.createElement("div"),this._element.className="void-container",this._element.tabIndex=0,this._element.draggable=!0,this.addDisposables(this._onDrop,u(this._element,"click",(()=>{this.accessor.doSetGroupActive(this.group)})));const i=new me(this._element,e.id,t);this.voidDropTarget=new ae(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:(e,i)=>{var s;const n=h();return n&&this.accessor.id===n.viewId?(null!==n.panelId||n.groupId!==this.group.id)&&(null===(s=(o=this.group.panels).length>0?o[o.length-1]:void 0)||void 0===s?void 0:s.id)!==n.panelId:t.model.canDisplayOverlay(e,i,de.Panel);var o}}),this.addDisposables(i,this.voidDropTarget.onDrop((e=>{this._onDrop.fire(e)})),this.voidDropTarget)}}class ue extends g{get panels(){return this.tabs.map((e=>e.value.panelId))}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"}setActionElement(e){this.actions!==e&&(this.actions&&(this.actions.remove(),this.actions=void 0),e&&(this.actionContainer.appendChild(e),this.actions=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.panelId===e))}constructor(e,t){super(),this.accessor=e,this.group=t,this.tabs=[],this.selectedIndex=-1,this._hidden=!1,this._onDrop=new m,this.onDrop=this._onDrop.event,this.addDisposables(this._onDrop),this._element=document.createElement("div"),this._element.className="tabs-and-actions-container",b(this._element,"dv-full-width-single-tab","fullwidth"===this.accessor.options.singleTabMode),this.addDisposables(this.accessor.onDidAddPanel((e=>{e.api.group===this.group&&b(this._element,"dv-single-tab",1===this.size)})),this.accessor.onDidRemovePanel((e=>{e.api.group===this.group&&b(this._element,"dv-single-tab",1===this.size)}))),this.actionContainer=document.createElement("div"),this.actionContainer.className="action-container",this.tabContainer=document.createElement("div"),this.tabContainer.className="tabs-container",this.voidContainer=new ce(this.accessor,this.group),this._element.appendChild(this.tabContainer),this._element.appendChild(this.voidContainer.element),this._element.appendChild(this.actionContainer),this.addDisposables(this.voidContainer,this.voidContainer.onDrop((e=>{this._onDrop.fire({event:e.nativeEvent,index:this.tabs.length})})),u(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.panelId===e)),i=this.tabs.splice(t,1)[0],{value:s,disposable:n}=i;n.dispose(),s.dispose(),s.element.remove()}setActivePanel(e){this.tabs.forEach((t=>{const i=e.id===t.value.panelId;t.value.setActive(i)}))}openPanel(e,t=this.tabs.length){var i;if(this.tabs.find((t=>t.value.panelId===e.id)))return;const s=new pe(e.id,this.accessor,this.group);if(!(null===(i=e.view)||void 0===i?void 0:i.tab))throw new Error("invalid header component");s.setContent(e.view.tab);const n=g.from(s.onChanged((t=>{var i;const s=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:s})})),s.onDrop((e=>{this._onDrop.fire({event:e.nativeEvent,index:this.tabs.findIndex((e=>e.value===s))})}))),o={value:s,disposable:n};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 ve extends g{get element(){throw new Error("not supported")}get activePanel(){return this._activePanel}get locked(){return this._locked}set locked(e){this._locked=e,b(this.container,"locked-groupview",e)}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return 0===this._panels.length}get hasWatermark(){return!(!this.watermark||!this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get isContentFocused(){return!!document.activeElement&&C(document.activeElement,this.contentContainer.element)}constructor(e,t,i,s,n){super(),this.container=e,this.accessor=t,this.id=i,this.options=s,this.groupPanel=n,this._isGroupActive=!1,this._locked=!1,this.mostRecentlyUsed=[],this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._onMove=new m,this.onMove=this._onMove.event,this._onDidDrop=new m,this.onDidDrop=this._onDidDrop.event,this._onDidAddPanel=new m,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidRemovePanel=new m,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new m,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this.container.classList.add("groupview"),this.tabsContainer=new ue(this.accessor,this.groupPanel),this.contentContainer=new he,this.dropTarget=new ae(this.contentContainer.element,{acceptedTargetZones:["top","bottom","left","right","center"],canDisplayOverlay:(e,t)=>{if(this.locked&&"center"===t)return!1;const i=h();if(i&&i.viewId===this.accessor.id){if(i.groupId===this.id){if("center"===t)return!1;if(null===i.panelId)return!1}return!(1===this._panels.length&&i.groupId===this.id)}return this.canDisplayOverlay(e,t,de.Panel)}}),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!s.hideHeader,this.locked=!!s.locked,this.addDisposables(this.tabsContainer.onDrop((e=>{this.handleDropEvent(e.event,"center",e.index)})),this.contentContainer.onDidFocus((()=>{this.accessor.doSetGroupActive(this.groupPanel,!0)})),this.contentContainer.onDidBlur((()=>{})),this.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.createGroupControlElement&&(this._control=this.accessor.options.createGroupControlElement(this.groupPanel),this.addDisposables(this._control),this._control.init({containerApi:new se(this.accessor),api:this.groupPanel.api}),this.tabsContainer.setActionElement(this._control.element))}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 this.locked&&(t.locked=!0),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,s=!!t.skipSetGroupActive;e.updateParentGroup(this.groupPanel,!0),this._activePanel!==e?(this.doAddPanel(e,t.index,i),i||this.doSetActivePanel(e),s||this.accessor.doSetGroupActive(this.groupPanel,!!t.skipFocus),this.updateContainer()):s||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.setActionElement(e)}setActive(e,t=!1,i=!1){var s,n,o,r;i||this.isActive!==e?(this._isGroupActive=e,b(this.container,"active-group",e),b(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===(n=null===(s=this._activePanel)||void 0===s?void 0:s.focus)||void 0===n||n.call(s)}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 s=this._panels.indexOf(e)>-1;this.tabsContainer.openPanel(e,t),i||this.contentContainer.openPanel(e),this.tabsContainer.show(),this.contentContainer.show(),s||(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(b(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 se(this.accessor),group:this.groupPanel}),this.watermark=e,u(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:h})}handleDropEvent(e,t,i){const s=h();if(s&&s.viewId===this.accessor.id){if(null===s.panelId){const{groupId:e}=s;return void this._onMove.fire({target:t,groupId:e,index:i})}if(-1!==this.tabsContainer.indexOf(s.panelId)&&1===this.tabsContainer.size)return;const{groupId:e,panelId:n}=s;if(this.id===e&&!t){if(this.tabsContainer.indexOf(n)===i)return}this._onMove.fire({target:t,groupId:s.groupId,itemId:s.panelId,index:i})}else this._onDidDrop.fire({nativeEvent:e,position:t,index:i,getData:()=>h()})}dispose(){var e,t;super.dispose(),null===(t=null===(e=this.watermark)||void 0===e?void 0:e.dispose)||void 0===t||t.call(e);for(const e of this.panels)e.dispose();this.dropTarget.dispose(),this.tabsContainer.dispose(),this.contentContainer.dispose()}}class ge extends g{get element(){return this._element}constructor(e){super(),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(_(this._element,(e=>{if(this.isDisposed)return;const{width:t,height:i}=e.contentRect;this.layout(t,i)})))}}const we=N();function _e(e){switch(e){case"left":return"left";case"right":return"right";case"above":return"top";case"below":return"bottom";default:return"center"}}class fe extends ge{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(e){super(e.parentElement),this._id=we.next(),this._groups=new Map,this._onDidLayoutChange=new m,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidRemoveGroup=new m,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new m,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new m,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._bufferOnDidLayoutChange=new v,this.gridview=new Q(!!e.proportionalLayout,e.styles,e.orientation),this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidChange((()=>{this._bufferOnDidLayoutChange.fire()})),i.any(this.onDidAddGroup,this.onDidRemoveGroup,this.onDidActiveGroupChange)((()=>{this._bufferOnDidLayoutChange.fire()})),this._bufferOnDidLayoutChange.onEvent((()=>{this._onDidLayoutChange.fire()})),this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible($(e.element),t),this._onDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible($(e.element))}doAddGroup(e,t=[0],i){this.gridview.addView(e,null!=i?i:R.Distribute,t),this._onDidAddGroup.fire(e),this.doSetGroupActive(e)}doRemoveGroup(e,t){if(!this._groups.has(e.id))throw new Error("invalid operation");const i=this._groups.get(e.id),s=this.gridview.remove(e,R.Distribute);if(i&&!(null==t?void 0:t.skipDispose)&&(i.disposable.dispose(),i.value.dispose(),this._groups.delete(e.id)),this._onDidRemoveGroup.fire(e),!(null==t?void 0:t.skipActive)&&this._activeGroup===e){const e=Array.from(this._groups.values());this.doSetGroupActive(e.length>0?e[0].value:void 0)}return s}getPanel(e){var t;return null===(t=this._groups.get(e))||void 0===t?void 0:t.value}doSetGroupActive(e,t){var i,s,n;this._activeGroup!==e&&(this._activeGroup&&(this._activeGroup.setActive(!1),t||null===(s=(i=this._activeGroup).focus)||void 0===s||s.call(i)),e&&(e.setActive(!0),t||null===(n=e.focus)||void 0===n||n.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=$(e.group.element),s=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}moveToPrevious(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=$(e.group.element),s=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}layout(e,t,i){(i||e!==this.width||t!==this.height)&&(this.gridview.element.style.height=`${t}px`,this.gridview.element.style.width=`${e}px`,this.gridview.layout(e,t))}dispose(){this._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 De extends g{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 w,this._onDidDimensionChange=new m({replay:!0}),this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new m({replay:!0}),this.onDidFocusChange=this._onDidChangeFocus.event,this._onFocusEvent=new m,this.onFocusEvent=this._onFocusEvent.event,this._onDidVisibilityChange=new m({replay:!0}),this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onVisibilityChange=new m,this.onVisibilityChange=this._onVisibilityChange.event,this._onDidActiveChange=new m({replay:!0}),this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new m,this.onActiveChange=this._onActiveChange.event,this._onUpdateParameters=new m,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 be extends De{constructor(e){super(e),this._onDidConstraintsChangeInternal=new m,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new m({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new m,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}}class Ce extends be{set pane(e){this._pane=e}constructor(e){super(e),this._onDidExpansionChange=new m({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new m({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new m({}),this.onMouseLeave=this._onMouseLeave.event,this.addDisposables(this._onDidExpansionChange,this._onMouseEnter,this._onMouseLeave)}setExpanded(e){var t;null===(t=this._pane)||void 0===t||t.setExpanded(e)}get isExpanded(){var e;return!!(null===(e=this._pane)||void 0===e?void 0:e.isExpanded())}}class ye extends g{get element(){return this._element}get width(){return this._width}get height(){return this._height}get params(){var e;return null===(e=this._params)||void 0===e?void 0:e.params}constructor(e,t,i){super(),this.id=e,this.component=t,this.api=i,this._height=0,this._width=0,this._element=document.createElement("div"),this._element.tabIndex=-1,this._element.style.outline="none",this._element.style.height="100%",this._element.style.width="100%",this._element.style.overflow="hidden";const s=S(this._element);this.addDisposables(this.api,s.onDidFocus((()=>{this.api._onDidChangeFocus.fire({isFocused:!0})})),s.onDidBlur((()=>{this.api._onDidChangeFocus.fire({isFocused:!1})})),s)}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 Se extends ye{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,s,n,o){super(e,t,new Ce(e)),this.headerComponent=i,this._onDidChangeExpansionState=new m({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new m,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=n,this._headerVisible=o,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=s,this.element.classList.add("pane"),this.addDisposables(this.api.onDidSizeChange((e=>{this._onDidChange.fire({size:e.size})})),u(this.element,"mouseenter",(e=>{this.api._onMouseEnter.fire(e)})),u(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?D(this.header,"focused"):f(this.header,"focused"))}))),this.renderOnce()}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}isExpanded(){return this._isExpanded}setExpanded(e){this._isExpanded!==e&&(this._isExpanded=e,e?(this.animationTimer&&clearTimeout(this.animationTimer),this.body&&this.element.appendChild(this.body)):this.animationTimer=setTimeout((()=>{var e;null===(e=this.body)||void 0===e||e.remove()}),200),this._onDidChange.fire(e?{size:this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(e,t){this._size=e,this._orthogonalSize=t;const[i,s]=this.orientation===k.HORIZONTAL?[e,t]:[t,e];this.isExpanded()&&(this.expandedSize=i),super.layout(i,s)}init(e){var t,i;super.init(e),"number"==typeof e.minimumBodySize&&(this.minimumBodySize=e.minimumBodySize),"number"==typeof e.maximumBodySize&&(this.maximumBodySize=e.maximumBodySize),this.bodyPart=this.getBodyComponent(),this.headerPart=this.getHeaderComponent(),this.bodyPart.init(Object.assign(Object.assign({},e),{api:this.api})),this.headerPart.init(Object.assign(Object.assign({},e),{api:this.api})),null===(t=this.body)||void 0===t||t.append(this.bodyPart.element),null===(i=this.header)||void 0===i||i.append(this.headerPart.element),"boolean"==typeof e.isExpanded&&this.setExpanded(e.isExpanded)}toJSON(){const e=this._params;return Object.assign(Object.assign({},super.toJSON()),{headerComponent:this.headerComponent,title:e.title})}renderOnce(){this.header=document.createElement("div"),this.header.tabIndex=0,this.header.className="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 ze extends Se{constructor(e,t,i,s,n,o,r){super(t,i,s,n,o,!0),this.accessor=e,this._onDidDrop=new m,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 le{getData(){return a.getInstance().setData([new r(t,e)],r.prototype),{dispose:()=>{a.getInstance().clearData(r.prototype)}}}}(this.header),this.target=new ae(this.element,{acceptedTargetZones:["top","bottom"],overlayModel:{activationSize:{type:"percentage",value:50}},canDisplayOverlay:e=>{const t=d();return!(!t||t.paneId===this.id||t.viewId!==this.accessor.id)||!!this.accessor.options.showDndOverlay&&this.accessor.options.showDndOverlay({nativeEvent:e,getData:d,panel:this})}}),this.addDisposables(this._onDidDrop,this.handler,this.target,this.target.onDrop((e=>{this.onDrop(e)})))}onDrop(e){const t=d();if(!t||t.viewId!==this.accessor.id)return void this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,api:new te(this.accessor),getData:d}));const i=this._params.containerApi,s=t.paneId,n=i.getPanel(s);if(!n)return void this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,getData:d,api:new te(this.accessor)}));const o=i.panels,r=o.indexOf(n);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 Ee extends De{constructor(e,t){super(e),this._onDidConstraintsChangeInternal=new m,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new m({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new m,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange),t&&this.initialize(t)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}}class xe extends ye{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){super(e,t,new Ee(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 m,this.onDidChange=this._onDidChange.event,"number"==typeof(null==i?void 0:i.minimumWidth)&&(this._minimumWidth=i.minimumWidth),"number"==typeof(null==i?void 0:i.maximumWidth)&&(this._maximumWidth=i.maximumWidth),"number"==typeof(null==i?void 0:i.minimumHeight)&&(this._minimumHeight=i.minimumHeight),"number"==typeof(null==i?void 0:i.maximumHeight)&&(this._maximumHeight=i.maximumHeight),this.api.initialize(this),this.addDisposables(this.api.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})}}class Ae extends xe{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}),this._model=new ve(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 Pe(e){return!!e.referencePanel}function Ie(e){return!!e.referenceGroup}function Oe(e){return!!e.referencePanel}function Ne(e){return!!e.referenceGroup}class Ve extends Ee{get title(){return this.panel.title}get isGroupActive(){var e;return!!(null===(e=this.group)||void 0===e?void 0:e.isActive)}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){super(e.id),this.panel=e,this._onDidTitleChange=new m,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidActiveGroupChange=new m,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new m,this.onDidGroupChange=this._onDidGroupChange.event,this.disposable=new w,this.initialize(e),this._group=t,this.addDisposables(this.disposable,this._onDidTitleChange,this._onDidGroupChange,this._onDidActiveGroupChange)}setTitle(e){this.panel.setTitle(e)}close(){this.group.model.closePanel(this.panel)}}class Le extends g{get params(){return this._params}get title(){return this._title}get group(){return this._group}constructor(e,t,i,s,n){super(),this.id=e,this.containerApi=i,this.view=n,this._group=s,this.api=new Ve(this,this._group),this.addDisposables(this.api.onActiveChange((()=>{t.setActivePanel(this)})),this.api.onDidSizeChange((e=>{this.group.api.setSize(e)})))}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}}setTitle(e){e!==this.title&&(this._title=e,this.view.update({params:{params:this._params,title:this.title}}),this.api._onDidTitleChange.fire({title:e}))}update(e){this._params=Object.assign(Object.assign({},this._params||{}),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 ke=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},Ge=()=>ke({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 Te extends g{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(Ge()),this._element.appendChild(this._content),this._element.appendChild(this._actionContainer),this._actionContainer.appendChild(this._list),this._list.appendChild(this.action),this.addDisposables(u(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,u(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 Re{get content(){return this._content}get tab(){return this._tab}constructor(e,t,i,s){this.accessor=e,this.id=t,this.contentComponent=i,this.tabComponent=s,this._group=null,this._isPanelVisible=null,this._content=this.createContentComponent(this.id,i),this._tab=this.createTabComponent(this.id,s)}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,s;null===(s=(i=this.content).layout)||void 0===s||s.call(i,e,t)}update(e){var t,i,s,n;null===(i=(t=this.content).update)||void 0===i||i.call(t,e),null===(n=(s=this.tab).update)||void 0===n||n.call(s,e)}dispose(){var e,t,i,s;null===(t=(e=this.content).dispose)||void 0===t||t.call(e),null===(s=(i=this.tab).dispose)||void 0===s||s.call(i)}createContentComponent(e,t){var i;return E(e,t,this.accessor.options.components||{},this.accessor.options.frameworkComponents,null===(i=this.accessor.options.frameworkComponentFactory)||void 0===i?void 0:i.content)}createTabComponent(e,t){var i,s;return t?E(e,t,this.accessor.options.tabComponents,this.accessor.options.frameworkTabComponents,null===(i=this.accessor.options.frameworkComponentFactory)||void 0===i?void 0:i.tab,(()=>new Te)):this.accessor.options.defaultTabComponent?E(e,this.accessor.options.defaultTabComponent,this.accessor.options.tabComponents,this.accessor.options.frameworkTabComponents,null===(s=this.accessor.options.frameworkComponentFactory)||void 0===s?void 0:s.tab,(()=>new Te)):new Te}}class He{constructor(e){this.layout=e}fromJSON(e,t){var i;const s=e.id,n=e.params,o=e.title,r=e.view,a=r?r.content.id:e.contentComponent||"unknown",h=r?null===(i=r.tab)||void 0===i?void 0:i.id:e.tabComponent,d=new Re(this.layout,s,a,h),l=new Le(s,this.layout,new se(this.layout),t,d);return l.init({title:o||s,params:n||{}}),l}}class Me extends g{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 s=document.createElement("div");s.className="actions-container";const n=document.createElement("div");n.className="close-action",n.appendChild(Ge()),s.appendChild(n),e.appendChild(t),e.appendChild(s),this.addDisposables(u(n,"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);b(this.element,"has-actions",e)}}class Fe extends fe{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}constructor(e){super({proportionalLayout:!0,orientation:e.orientation||k.HORIZONTAL,styles:e.styles,parentElement:e.parentElement}),this.nextGroupId=N(),this._deserializer=new He(this),this.watermark=null,this._onDidDrop=new m,this.onDidDrop=this._onDidDrop.event,this._onDidRemovePanel=new m,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new m,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidLayoutFromJSON=new m,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new m,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this.element.classList.add("dv-dockview"),this.addDisposables(this._onDidDrop,i.any(this.onDidAddGroup,this.onDidRemoveGroup)((()=>{this.updateWatermark()})),i.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidActivePanelChange)((()=>{this._bufferOnDidLayoutChange.fire()}))),this._options=e,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=Me);const t=new ae(this.element,{canDisplayOverlay:(e,t)=>{const i=h();return i?i.viewId===this.id:!!this.options.showDndOverlay&&this.options.showDndOverlay({nativeEvent:e,position:t,target:de.Edge,getData:h})},acceptedTargetZones:["top","bottom","left","right"],overlayModel:{activationSize:{type:"pixels",value:10},size:{type:"pixels",value:20}}});this.addDisposables(t.onDrop((e=>{const t=h();t?this.moveGroupOrPanel(this.orthogonalize(e.position),t.groupId,t.panelId||void 0,"center"):this._onDidDrop.fire(Object.assign(Object.assign({},e),{api:this._api,group:null,getData:h}))})),t),this._api=new se(this),this.updateWatermark()}orthogonalize(e){switch(e){case"top":case"bottom":this.gridview.orientation===k.HORIZONTAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case"left":case"right":this.gridview.orientation===k.VERTICAL&&this.gridview.insertOrthogonalSplitviewAtRoot()}switch(e){case"top":case"left":return this.createGroupAtLocation([0]);case"bottom":case"right":return this.createGroupAtLocation([this.gridview.length]);default:throw new Error(`unsupported position ${e}`)}}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)}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=$(e.group.element),s=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}moveToPrevious(e={}){var t;if(!e.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=$(e.group.element),s=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;s&&this.doSetGroupActive(s)}toJSON(){var e;return{grid:this.gridview.serialize(),panels:this.panels.reduce(((e,t)=>(e[t.id]=t.toJSON(),e)),{}),activeGroup:null===(e=this.activeGroup)||void 0===e?void 0:e.id}}fromJSON(e){this.clear();const{grid:t,panels:i,activeGroup:s}=e;if("branch"!==t.root.type||!Array.isArray(t.root.data))throw new Error("root must be of type branch");if(this.gridview.deserialize(t,{fromJSON:e=>{const{id:t,locked:s,hideHeader:n,views:o,activeView:r}=e.data,a=this.createGroup({id:t,locked:!!s,hideHeader:!!n});this._onDidAddGroup.fire(a);for(const e of o){const t=this._deserializer.fromJSON(i[e],a),s="string"==typeof r&&r===t.id;a.model.openPanel(t,{skipSetPanelActive:!s,skipSetGroupActive:!0})}return!a.activePanel&&a.panels.length>0&&a.model.openPanel(a.panels[a.panels.length-1],{skipSetGroupActive:!0}),a}}),"string"==typeof s){const e=this.getPanel(s);e&&this.doSetGroupActive(e)}this.gridview.layout(this.width,this.height),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,!0);t&&this.doSetGroupActive(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 s,n;if(e.position)if(Pe(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`);s=this.findGroup(t)}else{if(!Ie(e.position)){const t=this.orthogonalize(oe(e.position.direction)),i=this.createPanel(e,t);return t.model.openPanel(i),i}if(s="string"==typeof e.position.referenceGroup?null===(t=this._groups.get(e.position.referenceGroup))||void 0===t?void 0:t.value:e.position.referenceGroup,!s)throw new Error(`referencePanel ${e.position.referenceGroup} does not exist`)}else s=this.activeGroup;if(s){const t=_e((null===(i=e.position)||void 0===i?void 0:i.direction)||"within");if("center"===t)n=this.createPanel(e,s),s.model.openPanel(n);else{const i=$(s.element),o=Z(this.gridview.orientation,i,t),r=this.createGroupAtLocation(o);n=this.createPanel(e,r),r.model.openPanel(n)}}else{const t=this.createGroupAtLocation();n=this.createPanel(e,t),t.model.openPanel(n)}return n}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),e.dispose(),0===i.size&&t.removeEmptyGroup&&this.removeGroup(i)}createWatermarkComponent(){var e;return E("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.length){if(!this.watermark){this.watermark=this.createWatermarkComponent(),this.watermark.init({containerApi:new se(this)});const e=document.createElement("div");e.className="dv-watermark-container",e.appendChild(this.watermark.element),this.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 s;if(Oe(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(s=this.findGroup(t),!s)throw new Error(`reference group for reference panel ${e.referencePanel} does not exist`)}else{if(!Ne(e)){return this.orthogonalize(oe(e.direction))}if(s="string"==typeof e.referenceGroup?null===(t=this._groups.get(e.referenceGroup))||void 0===t?void 0:t.value:e.referenceGroup,!s)throw new Error(`reference group ${e.referenceGroup} does not exist`)}const n=_e(e.direction||"within"),o=$(s.element),r=Z(this.gridview.orientation,o,n);return this.doAddGroup(i,r),i}return this.doAddGroup(i),i}removeGroup(e,t=!1){const i=[...e.panels];for(const e of i)this.removePanel(e,{removeEmptyGroup:!1,skipDispose:!1});super.doRemoveGroup(e,{skipActive:t})}moveGroupOrPanel(e,t,i,s,n){var o;const r=t?null===(o=this._groups.get(t))||void 0===o?void 0:o.value:void 0;if(void 0!==i)if(s&&"center"!==s){const t=$(e.element),n=Z(this.gridview.orientation,t,s);if(r&&r.size<2){const[t,i]=x(n),o=$(r.element),[a,h]=x(o);if(A(a,t))this.gridview.moveView(a,h,i);else{const t=this.doRemoveGroup(r,{skipActive:!0,skipDispose:!0}),i=$(e.element),n=Z(this.gridview.orientation,i,s);this.doAddGroup(t,n)}}else{const e=(null==r?void 0:r.model.removePanel(i))||this.panels.find((e=>e.id===i));if(!e)throw new Error(`No panel with id ${i}`);const n=Z(this.gridview.orientation,t,s);this.createGroupAtLocation(n).model.openPanel(e)}}else{const t=(null==r?void 0:r.model.removePanel(i))||this.panels.find((e=>e.id===i));if(!t)throw new Error(`No panel with id ${i}`);0===(null==r?void 0:r.model.size)&&this.doRemoveGroup(r),e.model.openPanel(t,{index:n})}else r&&this.moveGroup(r,e,s)}moveGroup(e,t,i){if(e)if(i&&"center"!==i){this.gridview.removeView($(e.element));const s=$(t.element),n=Z(this.gridview.orientation,s,i);this.gridview.addView(e,R.Distribute,n)}else{const i=e.activePanel,s=[...e.panels].map((t=>e.model.removePanel(t.id)));0===(null==e?void 0:e.model.size)&&this.doRemoveGroup(e);for(const e of s)t.model.openPanel(e,{skipSetPanelActive:e!==i})}}doSetGroupActive(e,t){var i,s;const n=this._activeGroup===e;super.doSetGroupActive(e,t),!n&&(null===(i=this._activeGroup)||void 0===i?void 0:i.activePanel)&&this._onDidActivePanelChange.fire(null===(s=this._activeGroup)||void 0===s?void 0:s.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 Ae(this,t,e);if(i.init({params:{},accessor:null}),!this._groups.has(i.id)){const e=new g(i.model.onMove((e=>{const{groupId:t,itemId:s,target:n,index:o}=e;this.moveGroupOrPanel(i,t,s,n,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){const i=e.component,s=e.tabComponent||this.options.defaultTabComponent,n=new Re(this,e.id,i,s),o=new Le(e.id,this,this._api,t,n);return o.init({title:e.title||e.id,params:(null==e?void 0:e.params)||{}}),o}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}dispose(){this._onDidActivePanelChange.dispose(),this._onDidAddPanel.dispose(),this._onDidRemovePanel.dispose(),this._onDidLayoutFromJSON.dispose(),super.dispose()}}class We extends fe{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}),this._onDidLayoutfromJSON=new m,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($(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,s=[];if(this.gridview.deserialize(t,{fromJSON:e=>{const{data:t}=e,i=E(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkComponentFactory?{createComponent:this.options.frameworkComponentFactory.createComponent}:void 0);return s.push((()=>i.init({params:t.params,minimumWidth:t.minimumWidth,maximumWidth:t.maximumWidth,minimumHeight:t.minimumHeight,maximumHeight:t.maximumHeight,priority:t.priority,snap:!!t.snap,accessor:this,isVisible:e.visible}))),this._onDidAddGroup.fire(i),this.registerPanel(i),i}}),this.layout(this.width,this.height,!0),s.forEach((e=>e())),"string"==typeof i){const e=this.getPanel(i);e&&this.doSetGroupActive(e)}this._onDidLayoutfromJSON.fire()}clear(){const e=this.activeGroup,t=Array.from(this._groups.values());for(const e of t)e.disposable.dispose(),this.doRemoveGroup(e.value,{skipActive:!0});e&&this.doSetGroupActive(void 0),this.gridview.clear()}movePanel(e,t){var i;let s;const n=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=_e(t.direction);if("center"===r)throw new Error(`${r} not supported as an option`);{const e=$(o.element);s=Z(this.gridview.orientation,e,r)}this.doAddGroup(n,s,t.size)}addPanel(e){var t,i;let s=e.location||[0];if(null===(t=e.position)||void 0===t?void 0:t.referencePanel){const t=null===(i=this._groups.get(e.position.referencePanel))||void 0===i?void 0:i.value;if(!t)throw new Error(`reference group ${e.position.referencePanel} does not exist`);const n=_e(e.position.direction);if("center"===n)throw new Error(`${n} not supported as an option`);{const e=$(t.element);s=Z(this.gridview.orientation,e,n)}}const n=E(e.id,e.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkComponentFactory?{createComponent:this.options.frameworkComponentFactory.createComponent}:void 0);return n.init({params:e.params||{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.registerPanel(n),this.doAddGroup(n,s,e.size),n}registerPanel(e){const t=new g(e.api.onDidFocusChange((t=>{t.isFocused&&this._groups.forEach((t=>{const i=t.value;i!==e?i.setActive(!1):i.setActive(!0)}))})));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,i){const s=this.getPanel(t);if(!s)throw new Error("invalid operation");const n=$(e.element),o=Z(this.gridview.orientation,n,i),[r,a]=x(o),h=$(s.element),[d,l]=x(h);if(A(d,r))return void this.gridview.moveView(d,l,a);const p=this.doRemoveGroup(s,{skipActive:!0,skipDispose:!0}),m=$(e.element),c=Z(this.gridview.orientation,m,i);this.doAddGroup(p,c)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}}class Be extends ge{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 g(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===k.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===k.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}constructor(e){super(e.parentElement),this._splitviewChangeDisposable=new w,this._panels=new Map,this._onDidLayoutfromJSON=new m,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new m,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new m,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new m,this.onDidLayoutChange=this._onDidLayoutChange.event,this._options=e,e.components||(e.components={}),e.frameworkComponents||(e.frameworkComponents={}),this.splitview=new H(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 s=this.panels.findIndex((t=>t===e));this.splitview.removeView(s,t).dispose();const n=this.panels;n.length>0&&this.setActive(n[n.length-1])}getPanel(e){return this.panels.find((t=>t.id===e))}addPanel(e){if(this._panels.has(e.id))throw new Error(`panel ${e.id} already exists`);const t=E(e.id,e.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.createComponent}:void 0);t.orientation=this.splitview.orientation,t.init({params:e.params||{},minimumSize:e.minimumSize,maximumSize:e.maximumSize,snap:e.snap,priority:e.priority,accessor:this});const i="number"==typeof e.size?e.size:R.Distribute,s="number"==typeof e.index?e.index:void 0;return this.splitview.addView(t,i,s),this.doAddView(t),this.setActive(t),t}layout(e,t){const[i,s]=this.splitview.orientation===k.HORIZONTAL?[e,t]:[t,e];this.splitview.layout(i,s)}doAddView(e){const t=e.api.onDidFocusChange((t=>{t.isFocused&&this.setActive(e,!0)}));this._panels.set(e.id,t)}toJSON(){var e;return{views:this.splitview.getViews().map(((e,t)=>({size:this.splitview.getViewSize(t),data:e.toJSON(),snap:!!e.snap,priority:e.priority}))),activeView:null===(e=this._activePanel)||void 0===e?void 0:e.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){this.clear();const{views:t,orientation:i,size:s,activeView:n}=e,o=[];if(this.splitview=new H(this.element,{orientation:i,proportionalLayout:this.options.proportionalLayout,descriptor:{size:s,views:t.map((e=>{const t=e.data;if(this._panels.has(t.id))throw new Error(`panel ${t.id} already exists`);const s=E(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.createComponent}:void 0);return o.push((()=>{s.init({params:t.params||{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:e.snap,priority:e.priority,accessor:this})})),s.orientation=i,this.doAddView(s),setTimeout((()=>{this._onDidAddView.fire(s)}),0),{size:e.size,view:s}}))}}),this.layout(this.width,this.height),o.forEach((e=>e())),"string"==typeof n){const e=this.getPanel(n);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,R.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 Je extends g{get element(){return this._element}constructor(){super(),this._expandedIcon=ke({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=ke({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 w,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(u(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);b(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 je=N();class $e extends ze{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 Ze extends ge{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new g(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===k.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===k.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(e){super(e.parentElement),this._id=je.next(),this._disposable=new w,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new m,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new m,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new m,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new m,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new m,this.onDidRemoveView=this._onDidRemoveView.event,this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView),this._options=e,e.components||(e.components={}),e.frameworkComponents||(e.frameworkComponents={}),this.paneview=new M(this.element,{orientation:k.VERTICAL}),this.addDisposables(this._disposable)}focus(){}updateOptions(e){this._options=Object.assign(Object.assign({},this.options),e)}addPanel(e){const t=E(e.id,e.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.body.createComponent}:void 0);let i;i=e.headerComponent?E(e.id,e.headerComponent,this.options.headerComponents||{},this.options.headerframeworkComponents,this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.header.createComponent}:void 0):new Je;const s=new $e({id:e.id,component:e.component,headerComponent:e.headerComponent,header:i,body:t,orientation:k.VERTICAL,isExpanded:!!e.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this});this.doAddPanel(s);const n="number"==typeof e.size?e.size:R.Distribute,o="number"==typeof e.index?e.index:void 0;return s.init({params:e.params||{},minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize,isExpanded:e.isExpanded,title:e.title,containerApi:new te(this)}),this.paneview.addPane(s,n,o),s.orientation=this.paneview.orientation,s}removePanel(e){const t=this.panels.findIndex((t=>t===e));this.paneview.removePane(t),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find((t=>t.id===e))}layout(e,t){const[i,s]=this.paneview.orientation===k.HORIZONTAL?[e,t]:[t,e];this.paneview.layout(i,s)}toJSON(){const e=e=>e===Number.MAX_SAFE_INTEGER||e===Number.POSITIVE_INFINITY?void 0:e;return{views:this.paneview.getPanes().map(((t,i)=>{return{size:this.paneview.getViewSize(i),data:t.toJSON(),minimumSize:(s=t.minimumBodySize,s<=0?void 0:s),maximumSize:e(t.maximumBodySize),expanded:t.isExpanded()};var s})),size:this.paneview.size}}fromJSON(e){this.clear();const{views:t,size:i}=e,s=[];this.paneview=new M(this.element,{orientation:k.VERTICAL,descriptor:{size:i,views:t.map((e=>{const t=e.data,i=E(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.body.createComponent}:void 0);let n;n=t.headerComponent?E(t.id,t.headerComponent,this.options.headerComponents||{},this.options.headerframeworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.header.createComponent}:void 0):new Je;const o=new $e({id:t.id,component:t.component,headerComponent:t.headerComponent,header:n,body:i,orientation:k.VERTICAL,isExpanded:!!e.expanded,disableDnd:!!this.options.disableDnd,accessor:this});return this.doAddPanel(o),s.push((()=>{o.init({params:t.params||{},minimumBodySize:e.minimumSize,maximumBodySize:e.maximumSize,title:t.title,isExpanded:!!e.expanded,containerApi:new te(this)}),o.orientation=this.paneview.orientation})),setTimeout((()=>{this._onDidAddView.fire(o)}),0),{size:e.size,view:o}}))}}),this.layout(this.width,this.height),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 Ue extends ye{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 be(e)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=Number.POSITIVE_INFINITY,this._minimumSize=0,this._maximumSize=Number.POSITIVE_INFINITY,this._snap=!1,this._onDidChange=new m,this.onDidChange=this._onDidChange.event,this.api.initialize(this),this.addDisposables(this._onDidChange,this.api.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(e,t){const[i,s]=this.orientation===k.HORIZONTAL?[e,t]:[t,e];super.layout(i,s)}init(e){super.init(e),this._priority=e.priority,e.minimumSize&&(this._minimumSize=e.minimumSize),e.maximumSize&&(this._maximumSize=e.maximumSize),e.snap&&(this._snap=e.snap)}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{minimumSize:(e=this.minimumSize,e<=0?void 0:e),maximumSize:(e=>e===Number.MAX_SAFE_INTEGER||e===Number.POSITIVE_INFINITY?void 0:e)(this.maximumSize)});var e}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}}const Ye=(t,i)=>{const[s,n]=e.useState(),o=e.useRef(t.componentProps);return e.useImperativeHandle(i,(()=>({update:e=>{o.current=Object.assign(Object.assign({},o.current),e),n(Date.now())}})),[]),e.createElement(t.component,o.current)};Ye.displayName="DockviewReactJsBridge";const Xe=(()=>{let e=1;return{next:()=>`dockview_react_portal_key_${(e++).toString()}`}})(),Ke=e.createContext({});class qe{constructor(e,t,i,s,n){this.parent=e,this.portalStore=t,this.component=i,this.parameters=s,this.context=n,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 i=e.createElement(e.forwardRef(Ye),{component:this.component,componentProps:this.parameters,ref:e=>{this.componentInstance=e,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),s=this.context?e.createElement(Ke.Provider,{value:this.context},i):i,n=t.createPortal(s,this.parent,Xe.next());this.ref={portal:n,disposable:this.portalStore.addPortal(n)}}dispose(){var e;null===(e=this.ref)||void 0===e||e.disposable.dispose(),this.disposed=!0}}const Qe=()=>{const[t,i]=e.useState([]);e.useDebugValue(`Portal count: ${t.length}`);return[t,e.useCallback((e=>{i((t=>[...t,e]));let t=!1;return{dispose:()=>{if(t)throw new Error("invalid operation: resource already disposed");t=!0,i((t=>t.filter((t=>t!==e))))}}}),[])]};function et(e){return null==e?void 0:e.type}class tt{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._onDidFocus=new m,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new m,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dockview-react-part"}focus(){}init(e){this.part=new qe(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 it{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 qe(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 qe(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;this.parameters&&(this.parameters.params=e.params),null===(t=this.part)||void 0===t||t.update({params:(null===(i=this.parameters)||void 0===i?void 0:i.params)||{}})}layout(e,t){}updateParentGroup(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class nt{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 w,this._element=document.createElement("div"),this._element.className="dockview-react-part"}focus(){}init(e){this.mutableDisposable.value=new g(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 qe(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})}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 ot(e,t){return e?i=>new nt(e,t,i):void 0}const rt="props.defaultTabComponent",at=e.forwardRef(((t,i)=>{const s=e.useRef(null),n=e.useRef(),[o,r]=Qe();return e.useImperativeHandle(i,(()=>s.current),[]),e.useEffect((()=>{if(!s.current)return()=>{};const e={content:{createComponent:(e,t,i)=>new tt(t,i,{addPortal:r})},tab:{createComponent:(e,t,i)=>new it(t,i,{addPortal:r})},watermark:{createComponent:(e,t,i)=>new st(t,i,{addPortal:r})}},i=t.tabComponents||{};t.defaultTabComponent&&(i[rt]=t.defaultTabComponent);const o=new Fe({parentElement:s.current,frameworkComponentFactory:e,frameworkComponents:t.components,frameworkTabComponents:i,watermarkFrameworkComponent:t.watermarkComponent,defaultTabComponent:t.defaultTabComponent?rt:void 0,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,showDndOverlay:t.showDndOverlay,createGroupControlElement:ot(t.groupControlComponent,{addPortal:r}),singleTabMode:t.singleTabMode}),{clientWidth:a,clientHeight:h}=s.current;return o.layout(a,h),t.onReady&&t.onReady({api:new se(o)}),n.current=o,()=>{o.dispose()}}),[]),e.useEffect((()=>{if(!n.current)return()=>{};const e=n.current.onDidDrop((e=>{t.onDidDrop&&t.onDidDrop(e)}));return()=>{e.dispose()}}),[t.onDidDrop]),e.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:t.components})}),[t.components]),e.useEffect((()=>{n.current&&n.current.updateOptions({watermarkFrameworkComponent:t.watermarkComponent})}),[t.watermarkComponent]),e.useEffect((()=>{n.current&&n.current.updateOptions({showDndOverlay:t.showDndOverlay})}),[t.showDndOverlay]),e.useEffect((()=>{n.current&&n.current.updateOptions({frameworkTabComponents:t.tabComponents})}),[t.tabComponents]),e.useEffect((()=>{if(!n.current)return;const e=t.tabComponents||{};t.defaultTabComponent&&(e[rt]=t.defaultTabComponent),n.current.updateOptions({defaultTabComponent:t.defaultTabComponent?rt:void 0,frameworkTabComponents:e})}),[t.defaultTabComponent]),e.useEffect((()=>{n.current&&n.current.updateOptions({createGroupControlElement:ot(t.groupControlComponent,{addPortal:r})})}),[t.groupControlComponent]),e.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:s},o)}));at.displayName="DockviewComponent";const ht=()=>e.createElement("svg",{height:"11",width:"11",viewBox:"0 0 28 28","aria-hidden":"false",focusable:!1,className:"dockview-svg"},e.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"})),dt=t=>{var{api:i,containerApi:s,params:n}=t,o=function(e,t){var i={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(i[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(i[s[n]]=e[s[n]])}return i}(t,["api","containerApi","params"]);const r=e.useCallback((e=>{e.stopPropagation(),i.close()}),[i]),a=e.useCallback((e=>{i.setActive(),o.onClick&&o.onClick(e)}),[i,o.onClick]),h=e.useMemo((()=>["dockview-react-tab-action"].join(",")),[]);return e.createElement("div",Object.assign({},o,{onClick:a,className:"dockview-react-tab"}),e.createElement("span",{className:"dockview-react-tab-title"},i.title),e.createElement("div",{className:h,onClick:r},e.createElement(ht,null)))};class lt extends Ue{constructor(e,t,i,s){super(e,t),this.reactComponent=i,this.reactPortalStore=s}getComponent(){var e;return new qe(this.element,this.reactPortalStore,this.reactComponent,{params:(null===(e=this._params)||void 0===e?void 0:e.params)||{},api:this.api,containerApi:new ee(this._params.accessor)})}}const pt=e.forwardRef(((t,i)=>{const s=e.useRef(null),n=e.useRef(),[o,r]=Qe();return e.useImperativeHandle(i,(()=>s.current),[]),e.useEffect((()=>{const e=new Be({parentElement:s.current,orientation:t.orientation||k.HORIZONTAL,frameworkComponents:t.components,frameworkWrapper:{createComponent:(e,t,i)=>new lt(e,t,i,{addPortal:r})},proportionalLayout:"boolean"!=typeof t.proportionalLayout||t.proportionalLayout,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0}),{clientWidth:i,clientHeight:o}=s.current;return e.layout(i,o),t.onReady&&t.onReady({api:new ee(e)}),n.current=e,()=>{e.dispose()}}),[]),e.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:t.components})}),[t.components]),e.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:s},o)}));pt.displayName="SplitviewComponent";class mt extends xe{constructor(e,t,i,s){super(e,t),this.reactComponent=i,this.reactPortalStore=s}getComponent(){var e;return new qe(this.element,this.reactPortalStore,this.reactComponent,{params:(null===(e=this._params)||void 0===e?void 0:e.params)||{},api:this.api,containerApi:new ie(this._params.accessor)})}}const ct=e.forwardRef(((t,i)=>{const s=e.useRef(null),n=e.useRef(),[o,r]=Qe();return e.useImperativeHandle(i,(()=>s.current),[]),e.useEffect((()=>{if(!s.current)return()=>{};const e=new We({parentElement:s.current,proportionalLayout:"boolean"!=typeof t.proportionalLayout||t.proportionalLayout,orientation:t.orientation||k.HORIZONTAL,frameworkComponents:t.components,frameworkComponentFactory:{createComponent:(e,t,i)=>new mt(e,t,i,{addPortal:r})},styles:t.hideBorders?{separatorBorder:"transparent"}:void 0}),{clientWidth:i,clientHeight:o}=s.current;return e.layout(i,o),t.onReady&&t.onReady({api:new ie(e)}),n.current=e,()=>{e.dispose()}}),[]),e.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:t.components})}),[t.components]),e.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:s},o)}));ct.displayName="GridviewComponent";class ut{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 qe(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 vt=e.forwardRef(((t,i)=>{const s=e.useRef(null),n=e.useRef(),[o,r]=Qe();return e.useImperativeHandle(i,(()=>s.current),[]),e.useEffect((()=>{const e=(e,t,i)=>new ut(e,i,{addPortal:r}),i=new Ze({parentElement:s.current,frameworkComponents:t.components,components:{},headerComponents:{},disableDnd:t.disableDnd,headerframeworkComponents:t.headerComponents,frameworkWrapper:{header:{createComponent:e},body:{createComponent:e}},showDndOverlay:t.showDndOverlay}),o=new te(i),{clientWidth:a,clientHeight:h}=s.current;return i.layout(a,h),t.onReady&&t.onReady({api:o}),n.current=i,()=>{i.dispose()}}),[]),e.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:t.components})}),[t.components]),e.useEffect((()=>{n.current&&n.current.updateOptions({headerframeworkComponents:t.headerComponents})}),[t.headerComponents]),e.useEffect((()=>{if(!n.current)return()=>{};const e=n.current,i=e.onDidDrop((i=>{t.onDidDrop&&t.onDidDrop(Object.assign(Object.assign({},i),{api:new te(e)}))}));return()=>{i.dispose()}}),[t.onDidDrop]),e.useEffect((()=>{n.current&&n.current.updateOptions({showDndOverlay:t.showDndOverlay})}),[t.showDndOverlay]),e.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:s},o)}));vt.displayName="PaneviewComponent";export{fe as BaseGrid,he as ContentContainer,He as DefaultDockviewDeserialzier,Te as DefaultTab,se as DockviewApi,Fe as DockviewComponent,g as DockviewCompositeDisposable,dt as DockviewDefaultTab,de as DockviewDropTargets,m as DockviewEmitter,i as DockviewEvent,Ae as DockviewGroupPanel,ve as DockviewGroupPanelModel,w as DockviewMutableDisposable,Le as DockviewPanel,at as DockviewReact,ze as DraggablePaneviewPanel,Q as Gridview,ie as GridviewApi,We as GridviewComponent,xe as GridviewPanel,ct as GridviewReact,T as LayoutPriority,a as LocalSelectionTransfer,k as Orientation,$e as PaneFramework,r as PaneTransfer,o as PanelTransfer,M as Paneview,te as PaneviewApi,Ze as PaneviewComponent,Se as PaneviewPanel,vt as PaneviewReact,qe as ReactPart,Ke as ReactPartContext,G as SashState,R as Sizing,H as Splitview,ee as SplitviewApi,Be as SplitviewComponent,Ue as SplitviewPanel,pt as SplitviewReact,pe as Tab,E as createComponent,oe as directionToPosition,U as getDirectionOrientation,$ as getGridLocation,Y as getLocationOrientation,d as getPaneData,h as getPanelData,Z as getRelativeLocation,j as indexInParent,K as isGridBranchNode,Ne as isGroupOptionsWithGroup,Oe as isGroupOptionsWithPanel,Ie as isPanelOptionsWithGroup,Pe as isPanelOptionsWithPanel,et as isReactElement,X as orthogonal,re as positionToDirection,_e as toTarget,Qe as usePortalsLifecycle,_ as watchElementResize};
|